@galacean/engine 0.9.3 → 0.9.5

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,(ov=e.ContainmentType||(e.ContainmentType={}))[ov.Disjoint=0]="Disjoint",ov[ov.Contains=1]="Contains",ov[ov.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(oy=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[oy.Back=0]="Back",oy[oy.Front=1]="Front",oy[oy.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(ox=e.FrustumFace||(e.FrustumFace={}))[ox.Near=0]="Near",ox[ox.Far=1]="Far",ox[ox.Left=2]="Left",ox[ox.Right=3]="Right",ox[ox.Bottom=4]="Bottom",ox[ox.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=((oT=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},oT.equals=function(e,t){return Math.abs(e-t)<=oT.zeroTolerance},oT.isPowerOf2=function(e){return(e&e-1)==0},oT.radianToDegree=function(e){return e*oT.radToDegreeFactor},oT.degreeToRadian=function(e){return e*oT.degreeToRadFactor},oT);se.zeroTolerance=1e-6,se.radToDegreeFactor=180/Math.PI,se.degreeToRadFactor=Math.PI/180;var st=((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 se.equals(e._x,t._x)&&se.equals(e._y,t._y)&&se.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>se.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);st._zero=new st(0,0,0),st._one=new st(1,1,1);var sn=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new st,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)st.add(e[i],r,r);st.scale(r,1/n,t.center);for(var a=0,s=0;s<n;++s){var l=st.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=st.distance(n,i)},o);sn._tempVec30=new st;var sr=((u=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new st,this.max=new st,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return st.add(this.min,this.max,e),st.scale(e,.5,e),e},u.getExtent=function(e){return st.subtract(this.max,this.min,e),st.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 st;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){st.subtract(e,t,n.min),st.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];st.min(n,o,n),st.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),st.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]),st.subtract(r,i,n.min),st.add(r,i,n.max)},l.merge=function(e,t,n){return st.min(e.min,t.min,n.min),st.max(e.max,t.max,n.max),n},l);sr._tempVec30=new st,sr._tempVec31=new st;var si=((c=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var i=e.normal,a=t.normal,o=n.normal;st.cross(a,o,c._tempVec30),st.cross(o,i,c._tempVec31),st.cross(i,a,c._tempVec32);var s=-st.dot(i,c._tempVec30),l=-st.dot(a,c._tempVec31),u=-st.dot(o,c._tempVec32);st.scale(c._tempVec30,e.distance/s,c._tempVec30),st.scale(c._tempVec31,t.distance/l,c._tempVec31),st.scale(c._tempVec32,n.distance/u,c._tempVec32),st.add(c._tempVec30,c._tempVec31,r),st.add(r,c._tempVec32,r)},c.distancePlaneAndPoint=function(e,t){return st.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=se.zeroTolerance,i=st.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=st.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=se.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;st.subtract(n,i,o);var s=st.dot(o,r),l=st.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 st.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))),st.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),st.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);si._tempVec30=new st,si._tempVec31=new st,si._tempVec32=new st;var sa=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new st,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();st.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),so=((f=(_=function(e){void 0===e&&(e=null),this.near=new sa,this.far=new sa,this.left=new sa,this.right=new sa,this.top=new sa,this.bottom=new sa,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 si.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return si.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},_),ss=((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 se.equals(n[0],r[0])&&se.equals(n[1],r[1])&&se.equals(n[2],r[2])&&se.equals(n[3],r[3])&&se.equals(n[4],r[4])&&se.equals(n[5],r[5])&&se.equals(n[6],r[6])&&se.equals(n[7],r[7])&&se.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),sl=((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<se.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 se.equals(e._x,t._x)&&se.equals(e._y,t._y)&&se.equals(e._z,t._z)&&se.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;st.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>se.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-se.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>se.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)<se.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);sl._tempVector3=new st,sl._tempQuat1=new sl;var su=((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)<se.zeroTolerance||Math.abs(x)<se.zeroTolerance||Math.abs(T)<se.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,sl.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>se.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 se.equals(n[0],r[0])&&se.equals(n[1],r[1])&&se.equals(n[2],r[2])&&se.equals(n[3],r[3])&&se.equals(n[4],r[4])&&se.equals(n[5],r[5])&&se.equals(n[6],r[6])&&se.equals(n[7],r[7])&&se.equals(n[8],r[8])&&se.equals(n[9],r[9])&&se.equals(n[10],r[10])&&se.equals(n[11],r[11])&&se.equals(n[12],r[12])&&se.equals(n[13],r[13])&&se.equals(n[14],r[14])&&se.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)<se.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;st.subtract(e,t,s),s.normalize(),st.cross(n,s,a),a.normalize(),st.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]=-st.dot(a,e),i[13]=-st.dot(o,e),i[14]=-st.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)<se.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);su._tempVec30=new st,su._tempVec31=new st,su._tempVec32=new st,su._tempMat30=new ss,su._identity=new su(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var sc=((C=(T=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new st,this.direction=new st,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return si.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return si.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return si.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return st.scale(this.direction,e,t),t.add(this.origin)},T),sh=((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 se.equals(e._x,t._x)&&se.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>se.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);sh._zero=new sh(0,0),sh._one=new sh(1,1);var sd=((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 se.equals(e._x,t._x)&&se.equals(e._y,t._y)&&se.equals(e._z,t._z)&&se.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>se.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);sd._zero=new sd(0,0,0,0),sd._one=new sd(1,1,1,1);var s_=((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 se.equals(e._r,t._r)&&se.equals(e._g,t._g)&&se.equals(e._b,t._b)&&se.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),sf=((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),sp=((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 sg(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sm(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 sv(e,t,n){return t&&sm(e.prototype,t),n&&sm(e,n),e}function sy(e,t){return(sy=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sx(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&&sy(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 sT=((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);sT.zeroTolerance=1e-6,sT.radToDegreeFactor=180/Math.PI,sT.degreeToRadFactor=Math.PI/180;var sC=((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 sT.equals(e._r,t._r)&&sT.equals(e._g,t._g)&&sT.equals(e._b,t._b)&&sT.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},sv(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 sS(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 sw(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function sb(e,t){sP.registerCloneMode(e,t,oC.Ignore)}function sA(e,t){sP.registerCloneMode(e,t,oC.Assignment)}function sM(e,t){sP.registerCloneMode(e,t,oC.Shallow)}function sF(e,t){sP.registerCloneMode(e,t,oC.Deep)}(V=oC||(oC={}))[V.Ignore=0]="Ignore",V[V.Assignment=1]="Assignment",V[V.Shallow=2]="Shallow",V[V.Deep=3]="Deep";var sP=((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(sw(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);sP._subCloneModeMap=new Map,sP._cloneModeMap=new Map,sP._objectType=Object.getPrototypeOf(Object);var sE=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)},sv(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();sE._instanceIdCounter=0,sS([sb],sE.prototype,"instanceId",void 0),sS([sb],sE.prototype,"_engine",void 0);var sR=(sx(z=function(e){var t;return(t=sE.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addRefObject(t.instanceId,sg(t)),t},sE),(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&&(sE.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)},sv(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 sL=((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},sv(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),sB=((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),sD=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},sI=console.log.bind(console),sO=console.info.bind(console),sV=console.warn.bind(console),sU=console.error.bind(console),sz={debug:sD,info:sD,warn:sD,error:sD,isEnabled:!1,enable:function(){this.debug=sI,this.info=sO,this.warn=sV,this.error=sU,this.isEnabled=!0},disable:function(){this.debug=sD,this.info=sD,this.warn=sD,this.error=sD,this.isEnabled=!1}},sN=((J=(Q=function(){this._frameCount=0,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()},J.tick=function(){var e=this.nowTime;this._deltaTime=(e-this._lastTickTime)*this._timeScale,this._lastTickTime=e,this._frameCount++},sv(Q,[{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}}]),Q),sk={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(sk.isArrayLike(e)){t=e.slice();for(var t,n=0,r=e.length;n<r;n++)t[n]=sk.clone(e[n])}else for(var i in t={},e)e.hasOwnProperty(i)&&(t[i]=sk.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 sG(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 sH(e){return Object.keys(e).map(function(t){return e[t]})}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 sW=(sx(ee=function(){var e;return e=sR.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},sR),(et=ee.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},et._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},et._onDestroy=function(){this._platformTexture.destroy(),this._platformTexture=null},et._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},et._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},sv(ee,[{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&&(sz.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(sz.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)}}]),ee),sX=(sx(en=function(t,n,r,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=sE.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=a,i){for(var s,l=sw(i,Array)?i.slice():[i],u=0,c=l.length;u<c;u++)if(l[u]._isDepthTexture)throw"Render texture can't use depth format.";s._colorTextures=l}else s._colorTextures=[];if(sw(a,sW)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(sg(s)),s},sE),(er=en.prototype).getColorTexture=function(e){return void 0===e&&(e=0),this._colorTextures[e]},er.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()}},er.destroy=function(){this._platformRenderTarget.destroy(),this._colorTextures.length=0,this._depthTexture=null,this._depth=null},er._setRenderTargetInfo=function(e,t){this._platformRenderTarget.setRenderTargetInfo(e,t)},er._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},sv(en,[{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}}]),en),sj=(sx(ei=function(t,n,r,i,a){var o;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(o=sW.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(sg(o)),o.filterMode=e.TextureFilterMode.Bilinear,o.wrapModeU=o.wrapModeV=e.TextureWrapMode.Repeat,o},sW),(ea=ei.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)},ea.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)},ea.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)},ei),sK=(sx(eo=function(t,n,r,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=sW.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(sg(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},sW),(es=eo.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)},es.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)},es.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)},sv(eo,[{key:"length",get:function(){return this._length}}]),eo),sq=(sx(el=function(t,n,r,i){var a;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=sW.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(sg(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},sW),(eu=el.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)},eu.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)},eu.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)},el),sY=(sx(ec=function(e){var t;return(t=sR.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},sR),(eh=ec.prototype)._onDestroy=function(){this._texture.destroy(),this._texture=null,this._charInfoMap={}},eh.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},eh.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},eh.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},sv(ec,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture=e}}]),ec),sQ=((e_=(ed=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},e_._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},e_._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},e_._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},e_._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},e_._getLastIndex=function(){return this._lastIndex},e_._createFontAtlas=function(){var e=this._engine,t=new sY(e),n=new sj(e,256,256);return t.texture=n,this._fontAtlases.push(t),t},ed),sJ=(sx(ef=function(e,t){var n;return void 0===t&&(t=""),(n=sR.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},sR),(ep=ef.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new sQ(this.engine),r[n]=i),i},ep._onDestroy=function(){var e=this._subFontMap;for(var t in e)e[t].destroy();this._subFontMap=null,delete ef._fontMap[this._name]},ef.createFromOS=function(e,t){if(t){var n=ef._fontMap,r=n[t];return r||(r=new ef(e,t),n[t]=r),r}return null},sv(ef,[{key:"name",get:function(){return this._name}}]),ef);sJ._fontMap={};var sZ=((em=(eg=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},em.then=function(e,t){var n=this;return new eg(function(r,i){n._promise.then(e,t).then(r).catch(i)})},em.catch=function(e){var t=this;return new eg(function(n,r){t._promise.catch(e).then(n).catch(r)})},em.finally=function(e){return this._promise.finally(e)},em.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},eg.all=function(e){return new eg(function(t,n,r){var i=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},a=function(e,t){sw(e,Promise)||sw(e,eg)?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)})},sv(eg,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),eg);(ev=oS||(oS={})).Pending="pending",ev.Fulfilled="fulfilled",ev.Rejected="rejected",ev.Canceled="canceled";var s$=((ex=(ey=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 sZ.all(n)},ex.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},ex.getAssetPath=function(e){return this._assetPool[e]},ex.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()}):sH(this._loadingPromises).forEach(function(e){e.cancel()})},ex.gc=function(){this._gc(!1)},ex._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},ex._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},ex._addRefObject=function(e,t){this._refObjectPool[e]=t},ex._deleteRefObject=function(e){delete this._refObjectPool[e]},ex._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._refObjectPool=null},ex._assignDefaultOptions=function(e){var t,n,r,i,a;if(e.type=null!=(t=e.type)?t:ey._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},ex._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 sZ(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 sZ(function(e,n){d.then(function(n){e(t._getResolveResource(n,l))}).catch(function(e){n(e)})});var _=ey._loaders[n.type];if(!_)throw"loader not found: "+n.type;n.url=o;var f=_.load(n,this);if(sw(f,sZ))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)})},ex._gc=function(e){for(var t=sH(this._refObjectPool),n=0,r=t.length;n<r;n++)(!t[n].isGCIgnored||e)&&t[n].destroy()},ex._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},ex._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},ex._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},ex._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===s1&&t.push(""),e.replace(s3,function(e,n,r,i){var a=e;r?a=i.replace(s2,"$1"):n&&(a=n.trim()),t.push(a)}),t},ex.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 sz.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})},ex.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},ey._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,i=n.length;r<i;r++)this._extTypeMapping[n[r]]=e},ey._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1)]},ey);function s0(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);s$._addLoader(e,i,t)}}s$._loaders={},s$._extTypeMapping={};var s1=46,s2=/\\(\\)?/g,s3=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),s4=((eC=(eT=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++},eC.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},eC.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},eC.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},eC.garbageCollection=function(){this._elements.length=this.length},eT),s5=((ew=(eS=function(){this._renderers=new s4,this._onStartScripts=new s4,this._onUpdateScripts=new s4,this._onLateUpdateScripts=new s4,this._onPhysicsUpdateScripts=new s4,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new s4,this._onUpdateRenderers=new s4,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},ew.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},ew.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},ew.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},ew.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},ew.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ew.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},ew.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},ew.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},ew.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},ew.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},ew.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ew.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},ew.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ew.addDisableScript=function(e){this._disableScripts.push(e)},ew.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},ew.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}},ew.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)}},ew.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)}},ew.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()}},ew.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n)t[n].update(e)},ew.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},ew.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}},ew.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)}},ew.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)}},ew.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},ew.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},eS),s8=((eb=function(){}).cloneComponent=function(e,t){for(var n=sP.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 oC.Assignment:t[o]=e[o];break;case oC.Shallow:var s=e[o];if(sw(s,Object)){var l=t[o];null==l&&(l=t[o]=s.constructor()),Object.assign(l,s)}else t[o]=s;break;case oC.Deep:var u=e[o];if(sw(u,Object)){var c=t[o];null==c&&(c=t[o]=u.constructor()),sP.deepCloneObject(u,c)}else t[o]=u}}e._cloneTo&&e._cloneTo(t)},eb),s6=((eA=function(){})._register=function(e,t){this._addDependency(e,t,this._dependenciesMap),this._addDependency(t,e,this._invDependenciesMap)},eA._addCheck=function(e,t){var n=eA._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)}},eA._removeCheck=function(e,t){var n=eA._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}},eA._addDependency=function(e,t,n){var r=n.get(e);r||(r=[],n.set(e,r)),-1===r.indexOf(t)&&r.push(t)},eA);function s7(){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 s6._register(e,t)})}}s6._dependenciesMap=new Map,s6._invDependenciesMap=new Map,e.Layer=void 0,(eM=e.Layer||(e.Layer={}))[eM.Layer0=1]="Layer0",eM[eM.Layer1=2]="Layer1",eM[eM.Layer2=4]="Layer2",eM[eM.Layer3=8]="Layer3",eM[eM.Layer4=16]="Layer4",eM[eM.Layer5=32]="Layer5",eM[eM.Layer6=64]="Layer6",eM[eM.Layer7=128]="Layer7",eM[eM.Layer8=256]="Layer8",eM[eM.Layer9=512]="Layer9",eM[eM.Layer10=1024]="Layer10",eM[eM.Layer11=2048]="Layer11",eM[eM.Layer12=4096]="Layer12",eM[eM.Layer13=8192]="Layer13",eM[eM.Layer14=16384]="Layer14",eM[eM.Layer15=32768]="Layer15",eM[eM.Layer16=65536]="Layer16",eM[eM.Layer17=131072]="Layer17",eM[eM.Layer18=262144]="Layer18",eM[eM.Layer19=524288]="Layer19",eM[eM.Layer20=1048576]="Layer20",eM[eM.Layer21=2097152]="Layer21",eM[eM.Layer22=4194304]="Layer22",eM[eM.Layer23=8388608]="Layer23",eM[eM.Layer24=16777216]="Layer24",eM[eM.Layer25=33554432]="Layer25",eM[eM.Layer26=67108864]="Layer26",eM[eM.Layer27=134217728]="Layer27",eM[eM.Layer28=268435456]="Layer28",eM[eM.Layer29=536870912]="Layer29",eM[eM.Layer30=1073741824]="Layer30",eM[eM.Layer31=2147483648]="Layer31",eM[eM.Everything=4294967295]="Everything",eM[eM.Nothing=0]="Nothing";var s9=((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++)sG(e[t]._updateFlags,this)},sx(eE=function(){var e;return e=eF.apply(this,arguments)||this,e.flag=!0,e},eF),eE.prototype.dispatch=function(){this.flag=!0},eE),le=(sx(eR=function(e){var t;return(t=sE.call(this,e.engine)||this)._awoken=!1,t._destroyed=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},sE),(eL=eR.prototype).destroy=function(){this._destroyed||(this._entity._removeComponent(this),this._entity.isActiveInHierarchy&&this._enabled&&this._onDisable(),this._destroyed=!0,this._onDestroy())},eL._onAwake=function(){},eL._onEnable=function(){},eL._onDisable=function(){},eL._onDestroy=function(){},eL._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())},sv(eR,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity.isActiveInHierarchy&&(e?(this._phasedActive=!0,this._onEnable()):(this._phasedActive=!1,this._onDisable())))}},{key:"destroyed",get:function(){return this._destroyed}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),eR);sS([sb],le.prototype,"_entity",void 0),sS([sb],le.prototype,"_awoken",void 0),sS([sb],le.prototype,"_destroyed",void 0),sS([sb],le.prototype,"_phasedActive",void 0),sS([sA],le.prototype,"_enabled",void 0);var lt=((eD=(eB=function(){this._updateFlags=[],this._listensers=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eD.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eD.removeFlag=function(e){sG(this._updateFlags,e)&&sG(e._flagManagers,this)},eD.addListener=function(e){this._listensers.push(e)},eD.removeListener=function(e){sG(this._listensers,e)},eD.dispatch=function(e,t){for(var n=this._updateFlags,r=n.length-1;r>=0;r--)n[r].dispatch(e,t);for(var i=this._listensers,a=i.length-1;a>=0;a--)i[a](e,t)},eB),ln=(sx(eI=function(e){var t;return(t=le.call(this,e)||this)._position=new st,t._rotation=new st,t._rotationQuaternion=new sl,t._scale=new st(1,1,1),t._worldPosition=new st,t._worldRotation=new st,t._worldRotationQuaternion=new sl,t._lossyWorldScale=new st(1,1,1),t._localMatrix=new su,t._worldMatrix=new su,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new lt,t._onPositionChanged=t._onPositionChanged.bind(sg(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(sg(t)),t._onRotationChanged=t._onRotationChanged.bind(sg(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(sg(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(sg(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(sg(t)),t._onScaleChanged=t._onScaleChanged.bind(sg(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},le),(eO=eI.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},eO.setRotation=function(e,t,n){this._rotation.set(e,t,n)},eO.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},eO.setScale=function(e,t,n){this._scale.set(e,t,n)},eO.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},eO.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},eO.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},eO.getWorldForward=function(e){var t=this.worldMatrix.elements;return e.set(-t[8],-t[9],-t[10]),e.normalize()},eO.getWorldRight=function(e){var t=this.worldMatrix.elements;return e.set(t[0],t[1],t[2]),e.normalize()},eO.getWorldUp=function(e){var t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()},eO.translate=function(e,t,n,r){if("number"==typeof e){var i=eI._tempVec30;i.set(e,t,n),this._translate(i,r)}else this._translate(e,t)},eO.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},eO.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*se.degreeToRadFactor;sl.rotationAxisAngle(e,r,eI._tempQuat0),this._rotateByQuat(eI._tempQuat0,n)},eO.lookAt=function(e,t){var n=eI._tempVec30;st.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=se.zeroTolerance)){n.scale(1/r);var i=eI._tempVec31;if(t?st.cross(t,n,i):i.set(n.z,0,-n.x),!((r=i.length())<=se.zeroTolerance)){i.scale(1/r);var a=eI._tempVec32;st.cross(n,i,a);var o=eI._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)}}},eO.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(s9)},eO._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eO._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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},eO._getScaleMatrix=function(){var e=eI._tempQuat0,t=eI._tempMat30,n=eI._tempMat31,r=eI._tempMat32;return n.copyFromMatrix(this.worldMatrix),sl.invert(this.worldRotationQuaternion,e),ss.rotationQuaternion(e,t),ss.multiply(t,n,r),r},eO._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eO._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eO._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eO._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eO._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eO._rotateByQuat=function(e,t){t?sl.multiply(this.rotationQuaternion,e,this._rotationQuaternion):sl.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eO._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=eI._tempVec30;st.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},eO._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var i=se.degreeToRadFactor,a=eI._tempQuat0;sl.rotationEuler(e*i,t*i,n*i,a),this._rotateByQuat(a,r)},eO._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eO._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(su.invert(t.worldMatrix,eI._tempMat41),st.transformCoordinate(e,eI._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eO._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eO._onWorldRotationChanged=function(){var e=this._worldRotation;sl.rotationEuler(se.degreeToRadian(e.x),se.degreeToRadian(e.y),se.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eO._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eO._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=eI._tempQuat0;sl.invert(t.worldRotationQuaternion,n),sl.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eO._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},sv(eI,[{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(se.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(se.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,sl.rotationEuler(se.degreeToRadian(this._rotation.x),se.degreeToRadian(this._rotation.y),se.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):sl.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?sl.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):sl.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)&&(su.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?su.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?(su.invert(t.worldMatrix,eI._tempMat42),su.multiply(eI._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}}]),eI);ln._tempQuat0=new sl,ln._tempVec30=new st,ln._tempVec31=new st,ln._tempVec32=new st,ln._tempMat30=new ss,ln._tempMat31=new ss,ln._tempMat32=new ss,ln._tempMat41=new su,ln._tempMat42=new su,sS([sF],ln.prototype,"_position",void 0),sS([sF],ln.prototype,"_rotation",void 0),sS([sF],ln.prototype,"_rotationQuaternion",void 0),sS([sF],ln.prototype,"_scale",void 0),sS([sF],ln.prototype,"_worldPosition",void 0),sS([sF],ln.prototype,"_worldRotation",void 0),sS([sF],ln.prototype,"_worldRotationQuaternion",void 0),sS([sF],ln.prototype,"_lossyWorldScale",void 0),sS([sF],ln.prototype,"_localMatrix",void 0),sS([sF],ln.prototype,"_worldMatrix",void 0),sS([sb],ln.prototype,"_isParentDirty",void 0),sS([sb],ln.prototype,"_parentTransformCache",void 0),sS([sb],ln.prototype,"_updateFlagManager",void 0),sS([sb],ln.prototype,"_onPositionChanged",null),sS([sb],ln.prototype,"_onWorldPositionChanged",null),sS([sb],ln.prototype,"_onRotationChanged",null),sS([sb],ln.prototype,"_onWorldRotationChanged",null),sS([sb],ln.prototype,"_onRotationQuaternionChanged",null),sS([sb],ln.prototype,"_onWorldRotationQuaternionChanged",null),sS([sb],ln.prototype,"_onScaleChanged",null),(eV=ow||(ow={}))[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 lr=(sx(eU=function(t,n){var r;return(r=sE.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._components=[],r._scripts=new s4,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new su,r.name=n,r.transform=r.addComponent(ln),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},sE),(ez=eU.prototype).addComponent=function(e){s6._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(sw(r,e))return r}},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];sw(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);e._isActive=this._isActive,e.transform.localMatrix=this.transform.localMatrix;for(var t=this._children,n=0,r=this._children.length;n<r;n++){var i=t[n];e.addChild(i.clone())}for(var a=this._components,o=0,s=a.length;o<s;o++){var l=a[o];if(!sw(l,ln)){var u=e.addComponent(l.constructor);s8.cloneComponent(l,u)}}return e},ez.destroy=function(){if(!this._destroyed){sE.prototype.destroy.call(this);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var n=this._children;n.length>0;)n[0].destroy();this._isRoot?(this._scene._removeFromEntityList(this),this._isRoot=!1):this._removeFromParent()}},ez._removeComponent=function(e){s6._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];sw(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&&(su.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)},sv(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);e.ColorSpace=void 0,(eN=e.ColorSpace||(e.ColorSpace={}))[eN.Linear=0]="Linear",eN[eN.Gamma=1]="Gamma",e.PointerPhase=void 0,(ek=e.PointerPhase||(e.PointerPhase={}))[ek.Down=0]="Down",ek[ek.Move=1]="Move",ek[ek.Stationary=2]="Stationary",ek[ek.Up=3]="Up",ek[ek.Leave=4]="Leave";var li=((eH=(eG=function(t){this.phase=e.PointerPhase.Leave,this.position=new sh,this.deltaPosition=new sh,this._events=[],this._upMap=[],this._downMap=[],this._upList=new s4,this._downList=new s4,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}},eH._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},eH._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)}},eH._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}},eG),la=((eW=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?eW.platform=e.Platform.IPhone:/iPad/i.test(n)?eW.platform=e.Platform.IPad:/Android/i.test(n)?eW.platform=e.Platform.Android:/Macintosh/i.test(n)&&(eW.platform=e.Platform.Mac),eW.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"}}},sv(eW,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),eW);la.platform=e.Platform.Unknown,la.operatingSystem="",la._initialize(),e.Keys=void 0,(eX=e.Keys||(e.Keys={}))[eX.Backquote=0]="Backquote",eX[eX.Backslash=1]="Backslash",eX[eX.Backspace=2]="Backspace",eX[eX.BracketLeft=3]="BracketLeft",eX[eX.BracketRight=4]="BracketRight",eX[eX.Comma=5]="Comma",eX[eX.Digit0=6]="Digit0",eX[eX.Digit1=7]="Digit1",eX[eX.Digit2=8]="Digit2",eX[eX.Digit3=9]="Digit3",eX[eX.Digit4=10]="Digit4",eX[eX.Digit5=11]="Digit5",eX[eX.Digit6=12]="Digit6",eX[eX.Digit7=13]="Digit7",eX[eX.Digit8=14]="Digit8",eX[eX.Digit9=15]="Digit9",eX[eX.Equal=16]="Equal",eX[eX.IntlBackslash=17]="IntlBackslash",eX[eX.IntlRo=18]="IntlRo",eX[eX.IntlYen=19]="IntlYen",eX[eX.KeyA=20]="KeyA",eX[eX.KeyB=21]="KeyB",eX[eX.KeyC=22]="KeyC",eX[eX.KeyD=23]="KeyD",eX[eX.KeyE=24]="KeyE",eX[eX.KeyF=25]="KeyF",eX[eX.KeyG=26]="KeyG",eX[eX.KeyH=27]="KeyH",eX[eX.KeyI=28]="KeyI",eX[eX.KeyJ=29]="KeyJ",eX[eX.KeyK=30]="KeyK",eX[eX.KeyL=31]="KeyL",eX[eX.KeyM=32]="KeyM",eX[eX.KeyN=33]="KeyN",eX[eX.KeyO=34]="KeyO",eX[eX.KeyP=35]="KeyP",eX[eX.KeyQ=36]="KeyQ",eX[eX.KeyR=37]="KeyR",eX[eX.KeyS=38]="KeyS",eX[eX.KeyT=39]="KeyT",eX[eX.KeyU=40]="KeyU",eX[eX.KeyV=41]="KeyV",eX[eX.KeyW=42]="KeyW",eX[eX.KeyX=43]="KeyX",eX[eX.KeyY=44]="KeyY",eX[eX.KeyZ=45]="KeyZ",eX[eX.Minus=46]="Minus",eX[eX.Period=47]="Period",eX[eX.Quote=48]="Quote",eX[eX.Semicolon=49]="Semicolon",eX[eX.Slash=50]="Slash",eX[eX.AltLeft=51]="AltLeft",eX[eX.AltRight=52]="AltRight",eX[eX.CapsLock=53]="CapsLock",eX[eX.ContextMenu=54]="ContextMenu",eX[eX.ControlLeft=55]="ControlLeft",eX[eX.ControlRight=56]="ControlRight",eX[eX.Enter=57]="Enter",eX[eX.MetaLeft=58]="MetaLeft",eX[eX.MetaRight=59]="MetaRight",eX[eX.ShiftLeft=60]="ShiftLeft",eX[eX.ShiftRight=61]="ShiftRight",eX[eX.Space=62]="Space",eX[eX.Tab=63]="Tab",eX[eX.Convert=64]="Convert",eX[eX.KanaMode=65]="KanaMode",eX[eX.Lang1=66]="Lang1",eX[eX.Lang2=67]="Lang2",eX[eX.Lang3=68]="Lang3",eX[eX.Lang4=69]="Lang4",eX[eX.Lang5=70]="Lang5",eX[eX.NonConvert=71]="NonConvert",eX[eX.Delete=72]="Delete",eX[eX.End=73]="End",eX[eX.Help=74]="Help",eX[eX.Home=75]="Home",eX[eX.Insert=76]="Insert",eX[eX.PageDown=77]="PageDown",eX[eX.PageUp=78]="PageUp",eX[eX.ArrowDown=79]="ArrowDown",eX[eX.ArrowLeft=80]="ArrowLeft",eX[eX.ArrowRight=81]="ArrowRight",eX[eX.ArrowUp=82]="ArrowUp",eX[eX.NumLock=83]="NumLock",eX[eX.Numpad0=84]="Numpad0",eX[eX.Numpad1=85]="Numpad1",eX[eX.Numpad2=86]="Numpad2",eX[eX.Numpad3=87]="Numpad3",eX[eX.Numpad4=88]="Numpad4",eX[eX.Numpad5=89]="Numpad5",eX[eX.Numpad6=90]="Numpad6",eX[eX.Numpad7=91]="Numpad7",eX[eX.Numpad8=92]="Numpad8",eX[eX.Numpad9=93]="Numpad9",eX[eX.NumpadAdd=94]="NumpadAdd",eX[eX.NumpadBackspace=95]="NumpadBackspace",eX[eX.NumpadClear=96]="NumpadClear",eX[eX.NumpadClearEntry=97]="NumpadClearEntry",eX[eX.NumpadComma=98]="NumpadComma",eX[eX.NumpadDecimal=99]="NumpadDecimal",eX[eX.NumpadDivide=100]="NumpadDivide",eX[eX.NumpadEnter=101]="NumpadEnter",eX[eX.NumpadEqual=102]="NumpadEqual",eX[eX.NumpadHash=103]="NumpadHash",eX[eX.NumpadMemoryAdd=104]="NumpadMemoryAdd",eX[eX.NumpadMemoryClear=105]="NumpadMemoryClear",eX[eX.NumpadMemoryRecall=106]="NumpadMemoryRecall",eX[eX.NumpadMemoryStore=107]="NumpadMemoryStore",eX[eX.NumpadMemorySubtract=108]="NumpadMemorySubtract",eX[eX.NumpadMultiply=109]="NumpadMultiply",eX[eX.NumpadParenLeft=110]="NumpadParenLeft",eX[eX.NumpadParenRight=111]="NumpadParenRight",eX[eX.NumpadStar=112]="NumpadStar",eX[eX.NumpadSubtract=113]="NumpadSubtract",eX[eX.Escape=114]="Escape",eX[eX.F1=115]="F1",eX[eX.F2=116]="F2",eX[eX.F3=117]="F3",eX[eX.F4=118]="F4",eX[eX.F5=119]="F5",eX[eX.F6=120]="F6",eX[eX.F7=121]="F7",eX[eX.F8=122]="F8",eX[eX.F9=123]="F9",eX[eX.F10=124]="F10",eX[eX.F11=125]="F11",eX[eX.F12=126]="F12",eX[eX.F13=127]="F13",eX[eX.F14=128]="F14",eX[eX.F15=129]="F15",eX[eX.Fn=130]="Fn",eX[eX.FnLock=131]="FnLock",eX[eX.PrintScreen=132]="PrintScreen",eX[eX.ScrollLock=133]="ScrollLock",eX[eX.Pause=134]="Pause",eX[eX.BrowserBack=135]="BrowserBack",eX[eX.BrowserFavorites=136]="BrowserFavorites",eX[eX.BrowserForward=137]="BrowserForward",eX[eX.BrowserHome=138]="BrowserHome",eX[eX.BrowserRefresh=139]="BrowserRefresh",eX[eX.BrowserSearch=140]="BrowserSearch",eX[eX.BrowserStop=141]="BrowserStop",eX[eX.Eject=142]="Eject",eX[eX.LaunchApp1=143]="LaunchApp1",eX[eX.LaunchApp2=144]="LaunchApp2",eX[eX.LaunchMail=145]="LaunchMail",eX[eX.MediaPlayPause=146]="MediaPlayPause",eX[eX.MediaSelect=147]="MediaSelect",eX[eX.MediaStop=148]="MediaStop",eX[eX.MediaTrackNext=149]="MediaTrackNext",eX[eX.MediaTrackPrevious=150]="MediaTrackPrevious",eX[eX.Power=151]="Power",eX[eX.Sleep=152]="Sleep",eX[eX.AudioVolumeDown=153]="AudioVolumeDown",eX[eX.AudioVolumeMute=154]="AudioVolumeMute",eX[eX.AudioVolumeUp=155]="AudioVolumeUp",eX[eX.WakeUp=156]="WakeUp",eX[eX.Hyper=157]="Hyper",eX[eX.Super=158]="Super",eX[eX.Turbo=159]="Turbo",eX[eX.Abort=160]="Abort",eX[eX.Resume=161]="Resume",eX[eX.Suspend=162]="Suspend",eX[eX.Again=163]="Again",eX[eX.Copy=164]="Copy",eX[eX.Cut=165]="Cut",eX[eX.Find=166]="Find",eX[eX.Open=167]="Open",eX[eX.Paste=168]="Paste",eX[eX.Props=169]="Props",eX[eX.Select=170]="Select",eX[eX.Undo=171]="Undo",eX[eX.Hiragana=172]="Hiragana",eX[eX.Katakana=173]="Katakana",eX[eX.Unidentified=174]="Unidentified";var lo=((eK=(ej=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new s4,this._curFrameDownList=new s4,this._curFrameUpList=new s4,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,la.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}},eK._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},eK._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)},eK._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},eK._onKeyEvent=function(e){this._nativeEvents.push(e)},ej);e.CameraClearFlags=void 0,(eq=e.CameraClearFlags||(e.CameraClearFlags={}))[eq.None=0]="None",eq[eq.Color=1]="Color",eq[eq.Depth=2]="Depth",eq[eq.Stencil=4]="Stencil",eq[eq.ColorDepth=3]="ColorDepth",eq[eq.ColorStencil=5]="ColorStencil",eq[eq.DepthStencil=6]="DepthStencil",eq[eq.All=7]="All";var ls=function(){this.entity=null,this.distance=0,this.point=new st,this.normal=new st},ll=((eQ=(eY=function(e){var t=this;this._initialized=!1,this._restTime=0,this._colliders=new s4,this._gravity=new st(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||(eY._nativePhysics=e,this._nativePhysicsManager=eY._nativePhysics.createPhysicsManager(this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay),this._initialized=!0)},eQ.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)},eQ._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()},eQ._addColliderShape=function(e){this._physicalObjectsMap[e.id]=e,this._nativePhysicsManager.addColliderShape(e._nativeShape)},eQ._removeColliderShape=function(e){delete this._physicalObjectsMap[e.id],this._nativePhysicsManager.removeColliderShape(e._nativeShape)},eQ._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCollider(e._nativeCollider)},eQ._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCharacterController(e._nativeCollider)},eQ._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCollider(e._nativeCollider)},eQ._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCharacterController(e._nativeCollider)},eQ._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},eQ._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},eQ._setGravity=function(){this._nativePhysicsManager.setGravity(this._gravity)},sv(eY,[{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}}]),eY);e.PhysicsMaterialCombineMode=void 0,(eJ=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[eJ.Average=0]="Average",eJ[eJ.Minimum=1]="Minimum",eJ[eJ.Multiply=2]="Multiply",eJ[eJ.Maximum=3]="Maximum";var lu=((eZ=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=ll._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},sv(eZ,[{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))}}]),eZ);e.Collider=(sx(e$=function(e){var t;return(t=le.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},le),(e0=e$.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))},e0.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))},e0.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},e0._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}},e0._onLateUpdate=function(){},e0._onEnable=function(){this.engine.physicsManager._addCollider(this)},e0._onDisable=function(){this.engine.physicsManager._removeCollider(this)},e0._onDestroy=function(){this.clearShapes(),this._nativeCollider.destroy()},sv(e$,[{key:"shapes",get:function(){return this._shapes}}]),e$),sS([sb],e.Collider.prototype,"_index",void 0),e.Collider=sS([s7(ln)],e.Collider),e.ControllerNonWalkableMode=void 0,(e1=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[e1.PreventClimbing=0]="PreventClimbing",e1[e1.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var lc=(e2=e.Collider,sx(e3=function(t){var n;return(n=e2.call(this,t)||this)._index=-1,n._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new st(0,1,0),n._slopeLimit=.707,n._nativeCollider=ll._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(sg(n)),n._upDirection._onValueChanged=n._setUpDirection,n},e2),(e4=e3.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},e4.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";e2.prototype.addShape.call(this,e),this._updateFlag.flag=!0},e4.clearShapes=function(){this._shapes.length>0&&e2.prototype.removeShape.call(this,this._shapes[0])},e4._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}},e4._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},e4._onEnable=function(){this.engine.physicsManager._addCharacterController(this)},e4._onDisable=function(){this.engine.physicsManager._removeCharacterController(this)},e4._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},sv(e3,[{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))}}]),e3),lh=function(){function e(){this._isTrigger=!1,this._rotation=new st,this._position=new st,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new lu,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)},sv(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}();lh._idGenerator=0;var ld=(sx(e5=function(){var e;return(e=lh.call(this)||this)._size=new st(1,1,1),e._nativeShape=ll._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(sg(e)),e._size._onValueChanged=e._setSize,e},lh),e5.prototype._setSize=function(){this._nativeShape.setSize(this._size)},sv(e5,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),e5),l_=(sx(e8=function(){var e;return(e=lh.call(this)||this)._radius=1,e._nativeShape=ll._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},lh),sv(e8,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),e8),lf=(sx(e6=function(){var e;return(e=lh.call(this)||this)._nativeShape=ll._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},lh),e6);e.ColliderShapeUpAxis=void 0,(e7=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[e7.X=0]="X",e7[e7.Y=1]="Y",e7[e7.Z=2]="Z";var lp=(sx(e9=function(){var t;return(t=lh.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=ll._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},lh),sv(e9,[{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))}}]),e9);e.Joint=(sx(te=function(e){var t;return(t=le.call(this,e)||this)._connectedCollider=new lg,t._collider=new lg,t._force=0,t._torque=0,t._connectedCollider.localPosition=new st,t},le),sv(te,[{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))}}]),te),e.Joint=sS([s7(e.Collider)],e.Joint);var lg=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},lm=(tt=e.Joint,sx(tn=function(){return tt.apply(this,arguments)},tt),tn.prototype._onAwake=function(){var t=this._collider;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ll._nativePhysics.createFixedJoint(t.collider._nativeCollider)},tn);(tr=ob||(ob={}))[tr.LimitEnabled=1]="LimitEnabled",tr[tr.DriveEnabled=2]="DriveEnabled",tr[tr.DriveFreeSpin=4]="DriveFreeSpin";var lv=(ti=e.Joint,sx(ta=function(){var e;return e=ti.apply(this,arguments)||this,e._axis=new st(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},ti),ta.prototype._onAwake=function(){var t=this._collider;t.localPosition=new st,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ll._nativePhysics.createHingeJoint(t.collider._nativeCollider)},sv(ta,[{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))}}]),ta),ly=(to=e.Joint,sx(ts=function(){var e;return e=to.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},to),ts.prototype._onAwake=function(){var t=this._collider;t.localPosition=new st,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ll._nativePhysics.createSpringJoint(t.collider._nativeCollider)},sv(ts,[{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))}}]),ts),lx=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},lT=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1};e.ControllerCollisionFlag=void 0,(tl=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[tl.Sides=1]="Sides",tl[tl.Up=2]="Up",tl[tl.Down=4]="Down";var lC=(tu=e.Collider,sx(tc=function(e){var t,n=(t=tu.call(this,e)||this).entity.transform;return t._nativeCollider=ll._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},tu),tc),lS=(th=e.Collider,sx(td=function(e){(t=th.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new st,t._angularVelocity=new st,t._mass=1,t._centerOfMass=new st,t._inertiaTensor=new st(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=ll._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(sg(t)),t._setAngularVelocity=t._setAngularVelocity.bind(sg(t)),t._setCenterOfMass=t._setCenterOfMass.bind(sg(t)),t._setInertiaTensor=t._setInertiaTensor.bind(sg(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},th),(t_=td.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},t_.applyTorque=function(e){this._nativeCollider.addTorque(e)},t_.move=function(e,t){this._nativeCollider.move(e,t)},t_.sleep=function(){this._nativeCollider.sleep()},t_.wakeUp=function(){this._nativeCollider.wakeUp()},t_._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},t_._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},t_._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},t_._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},t_._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},sv(td,[{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))}}]),td);e.CollisionDetectionMode=void 0,(tf=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[tf.Discrete=0]="Discrete",tf[tf.Continuous=1]="Continuous",tf[tf.ContinuousDynamic=2]="ContinuousDynamic",tf[tf.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(tp=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[tp.None=0]="None",tp[tp.FreezePositionX=1]="FreezePositionX",tp[tp.FreezePositionY=2]="FreezePositionY",tp[tp.FreezePositionZ=4]="FreezePositionZ",tp[tp.FreezeRotationX=8]="FreezeRotationX",tp[tp.FreezeRotationY=16]="FreezeRotationY",tp[tp.FreezeRotationZ=32]="FreezeRotationZ",e.PointerButton=void 0,(tg=e.PointerButton||(e.PointerButton={}))[tg.None=0]="None",tg[tg.Primary=1]="Primary",tg[tg.Secondary=2]="Secondary",tg[tg.Auxiliary=4]="Auxiliary",tg[tg.XButton1=8]="XButton1",tg[tg.XButton2=16]="XButton2",tg[tg.XButton3=32]="XButton3",tg[tg.XButton4=64]="XButton4",tg[tg.XButton5=128]="XButton5",tg[tg.XButton6=256]="XButton6",tg[tg.XButton7=512]="XButton7",tg[tg.XButton8=1024]="XButton8";var lw=[1,4,2,8,16,32,64,128,256,512,1024],lb={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},lA=((tv=(tm=function(t,n){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new s4,this._downList=new s4,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}},tv._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}},tv._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}},tv._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},tv._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},tv._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},tv._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 li(a)),o._uniqueID=e,t.splice(a,0,o),o},tv._pointerRayCast=function(t,n){for(var r=tm._tempPoint,i=tm._tempRay,a=tm._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}}}},tv._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=lw[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))},tv._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=lw[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},tm);lA._tempRay=new sc,lA._tempPoint=new sh,lA._tempHitResult=new ls;var lM=((tx=(ty=function(e){this._delta=new st,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}},tx._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},tx._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},tx._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null},tx._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},ty),lF=((tC=(tT=function(e){this._initialized=!1,this._curFrameCount=0;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&sw(t,OffscreenCanvas)||(this._wheelManager=new lM(t),this._pointerManager=new lA(e,t),this._keyboardManager=new lo(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])},tC.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._curFrameCount)},tC.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._curFrameCount)},tC.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},tC.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[lb[e]]===this._curFrameCount)},tC.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[lb[e]]===this._curFrameCount)},tC._update=function(){this._initialized&&(++this._curFrameCount,this._wheelManager._update(),this._pointerManager._update(this._curFrameCount),this._keyboardManager._update(this._curFrameCount))},tC._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._pointerManager._destroy(),this._keyboardManager._destroy())},tC._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},tC._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},sv(tT,[{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}}]),tT);e.ShadowCascadesMode=void 0,(tS=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[tS.NoCascades=1]="NoCascades",tS[tS.TwoCascades=2]="TwoCascades",tS[tS.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(tw=e.ShadowResolution||(e.ShadowResolution={}))[tw.Low=0]="Low",tw[tw.Medium=1]="Medium",tw[tw.High=2]="High",tw[tw.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(tb=e.ShadowType||(e.ShadowType={}))[tb.None=0]="None",tb[tb.Hard=1]="Hard",tb[tb.SoftLow=2]="SoftLow",tb[tb.SoftHigh=3]="SoftHigh",e.RenderQueueType=void 0,(tA=e.RenderQueueType||(e.RenderQueueType={}))[tA.Opaque=0]="Opaque",tA[tA.AlphaTest=1]="AlphaTest",tA[tA.Transparent=2]="Transparent",e.BlendFactor=void 0,(tM=e.BlendFactor||(e.BlendFactor={}))[tM.Zero=0]="Zero",tM[tM.One=1]="One",tM[tM.SourceColor=2]="SourceColor",tM[tM.OneMinusSourceColor=3]="OneMinusSourceColor",tM[tM.DestinationColor=4]="DestinationColor",tM[tM.OneMinusDestinationColor=5]="OneMinusDestinationColor",tM[tM.SourceAlpha=6]="SourceAlpha",tM[tM.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",tM[tM.DestinationAlpha=8]="DestinationAlpha",tM[tM.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",tM[tM.SourceAlphaSaturate=10]="SourceAlphaSaturate",tM[tM.BlendColor=11]="BlendColor",tM[tM.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(tF=e.BlendOperation||(e.BlendOperation={}))[tF.Add=0]="Add",tF[tF.Subtract=1]="Subtract",tF[tF.ReverseSubtract=2]="ReverseSubtract",tF[tF.Min=3]="Min",tF[tF.Max=4]="Max",e.ColorWriteMask=void 0,(tP=e.ColorWriteMask||(e.ColorWriteMask={}))[tP.None=0]="None",tP[tP.Red=1]="Red",tP[tP.Green=2]="Green",tP[tP.Blue=4]="Blue",tP[tP.Alpha=8]="Alpha",tP[tP.All=15]="All",e.CompareFunction=void 0,(tE=e.CompareFunction||(e.CompareFunction={}))[tE.Never=0]="Never",tE[tE.Less=1]="Less",tE[tE.Equal=2]="Equal",tE[tE.LessEqual=3]="LessEqual",tE[tE.Greater=4]="Greater",tE[tE.NotEqual=5]="NotEqual",tE[tE.GreaterEqual=6]="GreaterEqual",tE[tE.Always=7]="Always",e.CullMode=void 0,(tR=e.CullMode||(e.CullMode={}))[tR.Off=0]="Off",tR[tR.Front=1]="Front",tR[tR.Back=2]="Back",e.ShaderPropertyType=void 0,(tL=e.ShaderPropertyType||(e.ShaderPropertyType={}))[tL.Float=0]="Float",tL[tL.Int=1]="Int",tL[tL.Vector2=2]="Vector2",tL[tL.Vector3=3]="Vector3",tL[tL.Vector4=4]="Vector4",tL[tL.Matrix=5]="Matrix",tL[tL.Color=6]="Color",tL[tL.Texture=7]="Texture",tL[tL.FloatArray=8]="FloatArray",tL[tL.IntArray=9]="IntArray",tL[tL.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(tB=e.StencilOperation||(e.StencilOperation={}))[tB.Keep=0]="Keep",tB[tB.Zero=1]="Zero",tB[tB.Replace=2]="Replace",tB[tB.IncrementSaturate=3]="IncrementSaturate",tB[tB.DecrementSaturate=4]="DecrementSaturate",tB[tB.Invert=5]="Invert",tB[tB.IncrementWrap=6]="IncrementWrap",tB[tB.DecrementWrap=7]="DecrementWrap";var lP=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};lP._macroNameIdMap=Object.create(null),lP._macroNameCounter=0;var lE=((tI=(tD=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},tI.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}},tI.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]},tI.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}},tI.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}},tI.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},tI.clear=function(){this._length=0},tD.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},tD);function lR(){return(lR=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 lL=lR({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();vec3 N=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv);\n#else\nvec3 N=getNormal();\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};",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){geometry.position=v_pos;geometry.viewDir=normalize(u_cameraPos-v_pos);\n#if defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE)\nmat3 tbn=getTBN();\n#endif\n#ifdef NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv);\n#else\ngeometry.normal=getNormal();\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);\n#else\ngeometry.clearCoatNormal=getNormal();\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;\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(0.04),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);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(){\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(gl_FrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(gl_FrontFacing)*2.0-1.0;return normal;}mat3 getTBN(){\n#if defined(O3_HAS_NORMAL) && defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal();vec3 position=v_pos;vec2 uv=gl_FrontFacing? 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;}"}),lB=((tO=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},tO.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=lL[t];return void 0===n?(sz.error('Shader slice "'+e.trim()+'" not founded.'),""):tO.parseIncludes(n)})},tO.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},tO.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},tO._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)},tO);(tV=oA||(oA={}))[tV.Scene=0]="Scene",tV[tV.Camera=1]="Camera",tV[tV.Renderer=2]="Renderer",tV[tV.Material=3]="Material";var lD=((tz=(tU=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)},tz.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},tz.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,s_.gammaToLinearSpace(n.r),s_.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)},tz.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},tz.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,s_.gammaToLinearSpace(n.r),s_.gammaToLinearSpace(n.g),s_.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)},tz.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},tz.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,s_.gammaToLinearSpace(n.r),s_.gammaToLinearSpace(n.g),s_.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)},tz.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},tz.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},tz.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},tz.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)},tz.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},tz.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)},tz.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},tz.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)},tz.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},tz.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},tz.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},tz.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseComporeMode)},tz.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)}},tU),lI=function(){this.constUniforms=[],this.textureUniforms=[]},lO=function(){function e(t,n,r){this.sceneUniformBlock=new lI,this.cameraUniformBlock=new lI,this.rendererUniformBlock=new lI,this.materialUniformBlock=new lI,this.otherUniformBlock=new lI,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=lz._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 oA.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case oA.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case oA.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case oA.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())?(sz.error("Context lost while linking program."),n.deleteShader(r),n.deleteShader(i),null):sz.isEnabled&&!n.getProgramParameter(a,n.LINK_STATUS)?(sz.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):sz.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 lD(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=lz.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 sh(0,0));break;case t.FLOAT_VEC3:u?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new st(0,0,0));break;case t.FLOAT_VEC4:u?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new sd(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 sh(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=u?l.upload3iv:l.upload3i,l.cacheValue=new st(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:u?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new sd(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=lz._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")},sv(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();lO._counter=0;var lV=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=[];lz._getNamesByMacros(n,o);var s=lB.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=lB.parseIncludes(" "+l+"\n "+u+"\n "+s+"\n "+this._vertexSource),d=lB.parseIncludes(" "+l+"\n "+u+"\n "+(a?"":lB.parseExtension(lz._shaderExtension))+"\n "+c+"\n "+s+"\n "+this._fragmentSource);return a&&(h=lB.convertTo300(h),d=lB.convertTo300(d,!0)),i=new lO(t,h,d),r.cache(i),i},t}();lV._shaderPassCounter=0;var lU=function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return sv(e,[{key:"type",get:function(){return this._type}}]),e}();lU._propertyNameCounter=0;var lz=((tN=function(e,t,n){if(this._passes=[],this.name=e,"string"==typeof t)this._passes.push(new lV(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=tN._compileMacros;n.clear();for(var r=0,i=t.length;r<i;r++)n.enable(tN.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},tN.create=function(e,t,n){var r=tN._shaderMap;if(r[e])throw'Shader named "'+e+'" already exists.';return r[e]=new tN(e,t,n)},tN.find=function(e){return tN._shaderMap[e]},tN.getMacroByName=function(e,t){var n=t?e+" "+t:e,r=tN._macroMap[n];if(!r){var i=tN._macroMaskMap,a=tN._macroCounter,o=Math.floor(a/32),s=a%32;r=new lP(e,t,o,1<<s),tN._macroMap[n]=r,o==i.length&&(i.length++,i[o]=Array(32)),i[o][s]=n,tN._macroCounter++}return r},tN.getPropertyByName=function(e){var t=tN._propertyNameMap;if(null!=t[e])return t[e];var n=new lU(e);return t[e]=n,tN._propertyIdMap[n._uniqueId]=n,n},tN._getShaderPropertyGroup=function(e){var t=tN._propertyNameMap[e];return null==t?void 0:t._group},tN._getNamesByMacros=function(e,t){var n=tN._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])},sv(tN,[{key:"passes",get:function(){return this._passes}}]),tN);lz._compileMacros=new lE,lz._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],lz._propertyIdMap=Object.create(null),lz._shaderMap=Object.create(null),lz._propertyNameMap=Object.create(null),lz._macroMaskMap=[],lz._macroCounter=0,lz._macroMap=Object.create(null);var lN=((tG=(tk=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new lE,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=lz.getPropertyByName(e)),this._propertyValueMap[e._uniqueId]},tG.enableMacro=function(e,t){"string"==typeof e&&(e=lz.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=lP._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=lz._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){sP.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=this._propertyValueMap,n=e._propertyValueMap,r=Object.keys(t),i=0,a=r.length;i<a;i++){var o=r[i],s=t[o];if(null!=s){if("number"==typeof s)n[o]=s;else if(sw(s,sW))n[o]=s;else if(sw(s,Array)||sw(s,Float32Array)||sw(s,Int32Array))n[o]=s.slice();else{var l=n[o];l?l.copyFrom(s):n[o]=s.clone()}}else n[o]=s}},tG._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=lz.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 "+oA[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&&sw(r,sW)&&r._addRefCount(e)}},tk),lk=(sx(tH=function(){var t;return t=le.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 s_(1,1,1,1),t._lightColor=new s_,t},le),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},sv(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 su),su.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new su),su.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),tH);lk._maxLight=10,sS([sb],lk.prototype,"_lightIndex",void 0);var lG=(sx(tW=function(){var e;return e=lk.apply(this,arguments)||this,e._forward=new st,e._reverseDirection=new st,e},lk),(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)},sv(tW,[{key:"direction",get:function(){return this.entity.transform.getWorldForward(this._forward),this._forward}},{key:"reverseDirection",get:function(){return st.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tW);lG._cullingMaskProperty=lz.getPropertyByName("u_directLightCullingMask"),lG._colorProperty=lz.getPropertyByName("u_directLightColor"),lG._directionProperty=lz.getPropertyByName("u_directLightDirection"),lG._combinedData={cullingMask:new Int32Array(2*lk._maxLight),color:new Float32Array(3*lk._maxLight),direction:new Float32Array(3*lk._maxLight)};var lH=(sx(tj=function(){var e;return e=lk.apply(this,arguments)||this,e.distance=100,e},lk),(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)},sv(tj,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tj);lH._cullingMaskProperty=lz.getPropertyByName("u_pointLightCullingMask"),lH._colorProperty=lz.getPropertyByName("u_pointLightColor"),lH._positionProperty=lz.getPropertyByName("u_pointLightPosition"),lH._distanceProperty=lz.getPropertyByName("u_pointLightDistance"),lH._combinedData={cullingMask:new Int32Array(2*lk._maxLight),color:new Float32Array(3*lk._maxLight),position:new Float32Array(3*lk._maxLight),distance:new Float32Array(lk._maxLight)};var lW=(sx(tq=function(){var e;return e=lk.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._forward=new st,e._inverseDirection=new st,e._projectMatrix=new su,e},lk),(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)},sv(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 st.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 su.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),tq);lW._cullingMaskProperty=lz.getPropertyByName("u_spotLightCullingMask"),lW._colorProperty=lz.getPropertyByName("u_spotLightColor"),lW._positionProperty=lz.getPropertyByName("u_spotLightPosition"),lW._directionProperty=lz.getPropertyByName("u_spotLightDirection"),lW._distanceProperty=lz.getPropertyByName("u_spotLightDistance"),lW._angleCosProperty=lz.getPropertyByName("u_spotLightAngleCos"),lW._penumbraCosProperty=lz.getPropertyByName("u_spotLightPenumbraCos"),lW._combinedData={cullingMask:new Int32Array(2*lk._maxLight),color:new Float32Array(3*lk._maxLight),position:new Float32Array(3*lk._maxLight),direction:new Float32Array(3*lk._maxLight),distance:new Float32Array(lk._maxLight),angleCos:new Float32Array(lk._maxLight),penumbraCos:new Float32Array(lk._maxLight)};var lX=((tJ=(tQ=function(){this._spotLights=new s4,this._pointLights=new s4,this._directLights=new s4}).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?(lG._updateShaderData(e),e.enableMacro("O3_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("O3_DIRECT_LIGHT_COUNT"),a?(lH._updateShaderData(e),e.enableMacro("O3_POINT_LIGHT_COUNT",a.toString())):e.disableMacro("O3_POINT_LIGHT_COUNT"),i?(lW._updateShaderData(e),e.enableMacro("O3_SPOT_LIGHT_COUNT",i.toString())):e.disableMacro("O3_SPOT_LIGHT_COUNT")},tQ),lj=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},lK=((t$=(tZ=function(){this.targetBlendState=new lj,this.blendColor=new s_(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;s_.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),lq=((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),lY=((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),lQ=((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),lJ=((t8=function(){this.blendState=new lK,this.depthState=new lq,this.stencilState=new lQ,this.rasterState=new lY,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),lZ=(sx(t6=function(e,t){var n;return(n=sR.call(this,e)||this).shaderData=new lN(oA.Material),n._renderStates=[],n.shader=t,n},sR),(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),sP.deepCloneObject(this.renderStates,e.renderStates)},t7._addRefCount=function(e){sR.prototype._addRefCount.call(this,e),this.shaderData._addRefCount(e)},t7._preRender=function(e){},t7._onDestroy=function(){},sv(t6,[{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 lJ);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t6),l$=((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},t9),l0=function(){},l1=(sx(nt=function(){return l0.apply(this,arguments)},l0),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},nt),l2=((nn=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(nn._viewMatrixProperty,e.viewMatrix),t.setMatrix(nn._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(nn._vpMatrixProperty,e.viewProjectionMatrix)},nn);l2._vpMatrixProperty=lz.getPropertyByName("u_VPMat"),l2._viewMatrixProperty=lz.getPropertyByName("u_viewMat"),l2._projectionMatrixProperty=lz.getPropertyByName("u_projMat");var l3=(sx(nr=function(){var e;return(e=l0.call(this)||this).multiRenderData=!1,e},l0),nr.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},nr),l4=(sx(ni=function(){var e;return(e=l0.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},l0),ni.prototype.setValue=function(e,t,n){this.component=e,this.renderData=t,this.material=n},ni);function l5(){return function(e){}}e.SpriteMaskInteraction=void 0,(na=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[na.None=0]="None",na[na.VisibleInsideMask=1]="VisibleInsideMask",na[na.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(sx(no=function(t){(n=le.call(this,t)||this).shaderData=new lN(oA.Renderer),n._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new lE,n._bounds=new sr,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._mvMatrix=new su,n._mvpMatrix=new su,n._mvInvMatrix=new su,n._normalMatrix=new su,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new sd,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(sg(n)),n._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},le),(ns=no.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},ns.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},ns.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},ns.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},ns.getMaterials=function(){return this._materials},ns.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))}},ns.update=function(e){},ns._onEnable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},ns._onDisable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},ns._prepareRender=function(t){var n=t.virtualCamera,r=n.position,i=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(st.subtract(i,r,i),this._distanceForSort=st.dot(i,n.forward)):this._distanceForSort=st.distanceSquared(i,r),this._updateShaderData(t),this._render(t),lE.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},ns._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)},ns._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)},ns._updateTransformShaderData=function(t,n){var r=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;su.multiply(i.viewMatrix,n,a),su.multiply(i.viewProjectionMatrix,n,o),su.invert(a,s),su.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)},ns._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},ns._updateBounds=function(e){},ns._render=function(e){throw"not implement"},ns._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},ns._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}},ns._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},sv(no,[{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}}]),(oM=no)._tempVector0=new st,oM._receiveShadowMacro=lz.getMacroByName("OASIS_RECEIVE_SHADOWS"),oM._localMatrixProperty=lz.getPropertyByName("u_localMat"),oM._worldMatrixProperty=lz.getPropertyByName("u_modelMat"),oM._mvMatrixProperty=lz.getPropertyByName("u_MVMat"),oM._mvpMatrixProperty=lz.getPropertyByName("u_MVPMat"),oM._mvInvMatrixProperty=lz.getPropertyByName("u_MVInvMat"),oM._normalMatrixProperty=lz.getPropertyByName("u_normalMat"),oM._rendererLayerProperty=lz.getPropertyByName("oasis_RendererLayer"),oM),sS([sF],e.Renderer.prototype,"shaderData",void 0),sS([sb],e.Renderer.prototype,"_distanceForSort",void 0),sS([sb],e.Renderer.prototype,"_onUpdateIndex",void 0),sS([sb],e.Renderer.prototype,"_rendererIndex",void 0),sS([sb],e.Renderer.prototype,"_globalShaderMacro",void 0),sS([sF],e.Renderer.prototype,"_bounds",void 0),sS([sb],e.Renderer.prototype,"_renderFrameCount",void 0),sS([sb],e.Renderer.prototype,"_overrideUpdate",void 0),sS([sM],e.Renderer.prototype,"_materials",void 0),sS([sb],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),sS([sb],e.Renderer.prototype,"_mvMatrix",void 0),sS([sb],e.Renderer.prototype,"_mvpMatrix",void 0),sS([sb],e.Renderer.prototype,"_mvInvMatrix",void 0),sS([sb],e.Renderer.prototype,"_normalMatrix",void 0),sS([sb],e.Renderer.prototype,"_materialsInstanced",void 0),sS([sb],e.Renderer.prototype,"_priority",void 0),sS([sA],e.Renderer.prototype,"_receiveShadows",void 0),sS([sb],e.Renderer.prototype,"_rendererLayer",void 0),sS([sb],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=sS([s7(ln)],e.Renderer),(nl=oF||(oF={}))[nl.WorldVolume=1]="WorldVolume";var l8=((nu=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 st),i.push(new sh);t.triangles=l8._rectangleTriangles},nu.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,i=r.pivot,a=i.x,o=i.y,s=l8._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])}sr.transform(r._getBounds(),s,e._bounds)},nu.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)},(oP=nu)._rectangleTriangles=[0,1,2,2,1,3],oP._worldMatrix=new su,oP);l8=sS([l5()],l8);var l6=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,(nc=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[nc.Layer0=1]="Layer0",nc[nc.Layer1=2]="Layer1",nc[nc.Layer2=4]="Layer2",nc[nc.Layer3=8]="Layer3",nc[nc.Layer4=16]="Layer4",nc[nc.Layer5=32]="Layer5",nc[nc.Layer6=64]="Layer6",nc[nc.Layer7=128]="Layer7",nc[nc.Layer8=256]="Layer8",nc[nc.Layer9=512]="Layer9",nc[nc.Layer10=1024]="Layer10",nc[nc.Layer11=2048]="Layer11",nc[nc.Layer12=4096]="Layer12",nc[nc.Layer13=8192]="Layer13",nc[nc.Layer14=16384]="Layer14",nc[nc.Layer15=32768]="Layer15",nc[nc.Layer16=65536]="Layer16",nc[nc.Layer17=131072]="Layer17",nc[nc.Layer18=262144]="Layer18",nc[nc.Layer19=524288]="Layer19",nc[nc.Layer20=1048576]="Layer20",nc[nc.Layer21=2097152]="Layer21",nc[nc.Layer22=4194304]="Layer22",nc[nc.Layer23=8388608]="Layer23",nc[nc.Layer24=16777216]="Layer24",nc[nc.Layer25=33554432]="Layer25",nc[nc.Layer26=67108864]="Layer26",nc[nc.Layer27=134217728]="Layer27",nc[nc.Layer28=268435456]="Layer28",nc[nc.Layer29=536870912]="Layer29",nc[nc.Layer30=1073741824]="Layer30",nc[nc.Layer31=2147483648]="Layer31",nc[nc.Everything=4294967295]="Everything",(nh=oE||(oE={}))[nh.texture=1]="texture",nh[nh.size=2]="size",nh[nh.atlasRotate=4]="atlasRotate",nh[nh.atlasRegion=8]="atlasRegion",nh[nh.atlasRegionOffset=16]="atlasRegionOffset",nh[nh.region=32]="region",nh[nh.pivot=64]="pivot",nh[nh.border=128]="border";var l7=function(t){function n(r){var i;return(i=t.call(this,r)||this).influenceLayers=e.SpriteMaskLayer.Everything,i._sprite=null,i._width=void 0,i._height=void 0,i._flipX=!1,i._flipY=!1,i._alphaCutoff=.5,i._renderData=new l6(4,[],[]),l8.resetData(sg(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(n._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(sg(i)),i}sx(n,t);var r=n.prototype;return r._onDestroy=function(){var e;null==(e=this._sprite)||e._updateFlagManager.removeListener(this._onSpriteChange),this._sprite=null,this._renderData=null,t.prototype._onDestroy.call(this)},r._cloneTo=function(e){e.sprite=this._sprite},r._updateBounds=function(e){var t;(null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height?l8.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&oF.WorldVolume&&(l8.updatePositions(this),this._dirtyUpdateFlag&=~oF.WorldVolume),2&this._dirtyUpdateFlag&&(l8.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._onSpriteChange=function(e){switch(e){case oE.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case oE.region:case oE.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case oE.atlasRegion:this._dirtyUpdateFlag|=2}},sv(n,[{key:"width",get:function(){return void 0===this._width&&this._sprite&&(this.width=this._sprite.width),this._width},set:function(e){this._width!==e&&(this._width=e,this._dirtyUpdateFlag|=oF.WorldVolume)}},{key:"height",get:function(){return void 0===this._height&&this._sprite&&(this.height=this._sprite.height),this._height},set:function(e){this._height!==e&&(this._height=e,this._dirtyUpdateFlag|=oF.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=oF.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=oF.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&t._updateFlagManager.removeListener(this._onSpriteChange),e?(e._updateFlagManager.addListener(this._onSpriteChange),this._dirtyUpdateFlag|=3,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);l7._textureProperty=lz.getPropertyByName("u_maskTexture"),l7._alphaCutoffProperty=lz.getPropertyByName("u_maskAlphaCutoff"),sS([sA],l7.prototype,"influenceLayers",void 0),sS([sb],l7.prototype,"_sprite",void 0),sS([sb],l7.prototype,"_width",void 0),sS([sb],l7.prototype,"_height",void 0),sS([sA],l7.prototype,"_flipX",void 0),sS([sA],l7.prototype,"_flipY",void 0),sS([sA],l7.prototype,"_alphaCutoff",void 0),sS([sb],l7.prototype,"_onSpriteChange",null),(nd=oR||(oR={}))[nd.UV=2]="UV",nd[nd.All=3]="All",e.VertexElementFormat=void 0,(n_=e.VertexElementFormat||(e.VertexElementFormat={}))[n_.Float=0]="Float",n_[n_.Vector2=1]="Vector2",n_[n_.Vector3=2]="Vector3",n_[n_.Vector4=3]="Vector4",n_[n_.Byte4=4]="Byte4",n_[n_.UByte4=5]="UByte4",n_[n_.NormalizedByte4=6]="NormalizedByte4",n_[n_.NormalizedUByte4=7]="NormalizedUByte4",n_[n_.Short2=8]="Short2",n_[n_.UShort2=9]="UShort2",n_[n_.NormalizedShort2=10]="NormalizedShort2",n_[n_.NormalizedUShort2=11]="NormalizedUShort2",n_[n_.Short4=12]="Short4",n_[n_.UShort4=13]="UShort4",n_[n_.NormalizedShort4=14]="NormalizedShort4",n_[n_.NormalizedUShort4=15]="NormalizedUShort4",e.BufferUsage=void 0,(nf=e.BufferUsage||(e.BufferUsage={}))[nf.Static=0]="Static",nf[nf.Dynamic=1]="Dynamic",nf[nf.Stream=2]="Stream",e.IndexFormat=void 0,(np=e.IndexFormat||(e.IndexFormat={}))[np.UInt8=0]="UInt8",np[np.UInt16=1]="UInt16",np[np.UInt32=2]="UInt32";var l9=((ng=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}},ng._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}},ng._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},ng._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}},ng),ue=(sv(nm=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=l9._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}}]),nm);e.BufferBindFlag=void 0,(nv=e.BufferBindFlag||(e.BufferBindFlag={}))[nv.VertexBuffer=0]="VertexBuffer",nv[nv.IndexBuffer=1]="IndexBuffer",e.SetDataOptions=void 0,(ny=e.SetDataOptions||(e.SetDataOptions={}))[ny.None=0]="None",ny[ny.Discard=1]="Discard";var ut=(sx(nx=function(t,n,r,i){void 0===i&&(i=e.BufferUsage.Static),(a=sR.call(this,t)||this)._engine=t,a._type=n,a._bufferUsage=i;var a,o=t._hardwareRenderer,s=o.gl,l=l9._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},sR),(nT=nx.prototype).bind=function(){this._hardwareRenderer.gl.bindBuffer(this._glBindTarget,this._nativeBuffer)},nT.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)},nT.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."},nT._onDestroy=function(){this._hardwareRenderer.gl.deleteBuffer(this._nativeBuffer),this._nativeBuffer=null,this._hardwareRenderer=null},nT.resize=function(e){this.bind(),this._hardwareRenderer.gl.bufferData(this._glBindTarget,e,this._glBufferUsage),this._byteLength=e},sv(nx,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}}]),nx);e.MeshTopology=void 0,(nC=e.MeshTopology||(e.MeshTopology={}))[nC.Points=0]="Points",nC[nC.Lines=1]="Lines",nC[nC.LineLoop=2]="LineLoop",nC[nC.LineStrip=3]="LineStrip",nC[nC.Triangles=4]="Triangles",nC[nC.TriangleStrip=5]="TriangleStrip",nC[nC.TriangleFan=6]="TriangleFan";var un=(sv(nS=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),nS),ur=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},ui=(sx(nw=function(e,t){(n=sR.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new lt,n._bounds=new sr,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(sg(n)),n._onBoundsChanged=n._onBoundsChanged.bind(sg(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},sR),(nb=nw.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new ur(t,n,r)),this._subMeshes.push(t),t},nb.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},nb.clearSubMesh=function(){this._subMeshes.length=0},nb._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},nb._addVertexElement=function(e){var t=e.semantic;this._vertexElementMap[t]=e,this._vertexElements.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},nb._insertVertexElement=function(e,t){var n=t.semantic;this._vertexElementMap[n]=t,this._vertexElements.splice(e,0,t),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},nb._setVertexBufferBinding=function(e,t){if(this._getRefCount()>0){var n=this._vertexBufferBindings[e];n&&n._buffer._addRefCount(-1),t._buffer._addRefCount(1)}this._vertexBufferBindings[e]=t,this._bufferStructChanged=!0},nb._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},nb._addRefCount=function(e){sR.prototype._addRefCount.call(this,e);for(var t=this._vertexBufferBindings,n=0,r=t.length;n<r;n++)t[n]._buffer._addRefCount(e)},nb._onDestroy=function(){this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._platformPrimitive.destroy()},nb._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},nb._setIndexBufferBinding=function(e){var t=this._indexBufferBinding;e?(this._indexBufferBinding=e,this._glIndexType=l9._getGLIndexType(e.format),this._glIndexByteCount=l9._getGLIndexByteCount(e.format),t&&t._buffer===e._buffer||(this._bufferStructChanged=!0)):(this._indexBufferBinding=null,this._glIndexType=void 0,t&&(this._bufferStructChanged=!0))},nb._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},sv(nw,[{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}}]),nw);(nA=oL||(oL={}))[nA.Bounds=1]="Bounds",nA[nA.VertexElements=2]="VertexElements";var ua=(sv(nM=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),nM),uo=((nP=(nF=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 st(0,0,0),this._canUseTextureStoreData=!0,this._dataTextureInfo=new st,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())},nP._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},nP._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(nF._blendShapeMacro),this._useTextureMode())e.enableMacro(nF._blendShapeTextureMacro),e.setTexture(nF._blendShapeTextureProperty,this._vertexTexture),e.setVector3(nF._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(nF._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(nF._blendShapeWeightsProperty,i),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(nF._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(nF._blendShapeTextureMacro),e.disableMacro("OASIS_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(nF._blendShapeNormalMacro):e.disableMacro(nF._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(nF._blendShapeTangentMacro):e.disableMacro(nF._blendShapeTangentMacro)}else e.disableMacro(nF._blendShapeMacro),e.disableMacro("OASIS_BLENDSHAPE_COUNT")},nP._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},nP._layoutOrCountChange=function(){var e=this._lastCreateHostInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},nP._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},nP._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},nP._setAttributeModeOffsetInfo=function(e,t){this._vertexElementOffset=e,this._bufferBindingOffset=t},nP._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 ue("POSITION_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12,this._useBlendNormal&&(t._addVertexElement(new ue("NORMAL_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12),this._useBlendTangent&&(t._addVertexElement(new ue("TANGENT_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12)},nP._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))},nP._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},nP._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 ut(r,e.BufferBindFlag.VertexBuffer,p,g);i._setVertexBufferBinding(h+d,new ua(m,f)),o[d]=m}},nP._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 sK(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)},nP._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=0,h=n.length;c<h;c++){var d=s[c];if(t||d.flag){var _=n[c].frames,f=_.length,p=_[f-1];if(f>0&&p.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var g=Math.floor(c/r),m=c%r,v=a[g],y=v.byteLength/(4*e),x=m*l,T=o[c];T||(o[c]=T=new sh),T.set(g+1,m*u);for(var C=p.deltaPositions,S=0;S<e;S++){var w=x+y*S,b=C[S];b&&(i[w]=b.x,i[w+1]=b.y,i[w+2]=b.z)}if(x+=3,this._useBlendNormal){var A=p.deltaNormals;if(A)for(var M=0;M<e;M++){var F=x+y*M,P=A[M];P&&(i[F]=P.x,i[F+1]=P.y,i[F+2]=P.z)}x+=3}if(this._useBlendTangent){var E=p.deltaTangents;if(E)for(var R=0;R<e;R++){var L=x+y*R,B=E[R];B&&(i[L]=B.x,i[L+1]=B.y,i[L+2]=B.z)}x+=3}(m===r-1||c===h-1)&&v.setData(i,0,0,v.byteLength/4),d.flag=!1}}},nP._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)},nP._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},nP._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}},nP._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},nP._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)}}}},nF);uo._blendShapeMacro=lz.getMacroByName("OASIS_BLENDSHAPE"),uo._blendShapeTextureMacro=lz.getMacroByName("OASIS_BLENDSHAPE_TEXTURE"),uo._blendShapeNormalMacro=lz.getMacroByName("OASIS_BLENDSHAPE_NORMAL"),uo._blendShapeTangentMacro=lz.getMacroByName("OASIS_BLENDSHAPE_TANGENT"),uo._blendShapeWeightsProperty=lz.getPropertyByName("u_blendShapeWeights"),uo._blendShapeTextureProperty=lz.getPropertyByName("u_blendShapeTexture"),uo._blendShapeTextureInfoProperty=lz.getPropertyByName("u_blendShapeTextureInfo"),(nE=oB||(oB={})).Position="POSITION",nE.Normal="NORMAL",nE.Color="COLOR_0",nE.Tangent="TANGENT",nE.BoneWeight="WEIGHTS_0",nE.BoneIndex="JOINTS_0",nE.UV="TEXCOORD_0",nE.UV1="TEXCOORD_1",nE.UV2="TEXCOORD_2",nE.UV3="TEXCOORD_3",nE.UV4="TEXCOORD_4",nE.UV5="TEXCOORD_5",nE.UV6="TEXCOORD_6",nE.UV7="TEXCOORD_7";var us=(sx(nR=function(e,t){var n;return(n=ui.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 uo(e,sg(n)),n},ui),(nL=nR.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}},nL.getPositions=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._positions},nL.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},nL.getNormals=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._normals},nL.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},nL.getColors=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._colors},nL.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},nL.getBoneWeights=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._boneWeights},nL.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},nL.getBoneIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._boneIndices},nL.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},nL.getTangents=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._tangents},nL.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]."}},nL.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]."},nL.setIndices=function(t){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._indices!==t&&(this._indices=t,sw(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:sw(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:sw(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},nL.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},nL.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[oB.Position]?this.getPositions()&&(this._vertexBufferUpdateFlag|=1):this.setPositions(null),n[oB.Normal]?this.getNormals()&&(this._vertexBufferUpdateFlag|=2):this.setNormals(null),n[oB.Color]?this.getColors()&&(this._vertexBufferUpdateFlag|=4):this.setColors(null),n[oB.BoneWeight]?this.getBoneWeights()&&(this._vertexBufferUpdateFlag|=16):this.setBoneWeights(null),n[oB.BoneIndex]?this.getBoneIndices()&&(this._vertexBufferUpdateFlag|=32):this.setBoneIndices(null),n[oB.Tangent]?this.getTangents()&&(this._vertexBufferUpdateFlag|=8):this.setTangents(null),n[oB.UV]?this.getUVs(0)&&(this._vertexBufferUpdateFlag|=64):this.setUVs(null,0),n[oB.UV1]?this.getUVs(1)&&(this._vertexBufferUpdateFlag|=128):this.setUVs(null,1),n[oB.UV2]?this.getUVs(2)&&(this._vertexBufferUpdateFlag|=256):this.setUVs(null,2),n[oB.UV3]?this.getUVs(3)&&(this._vertexBufferUpdateFlag|=512):this.setUVs(null,3),n[oB.UV4]?this.getUVs(4)&&(this._vertexBufferUpdateFlag|=1024):this.setUVs(null,4),n[oB.UV5]?this.getUVs(5)&&(this._vertexBufferUpdateFlag|=2048):this.setUVs(null,5),n[oB.UV6]?this.getUVs(6)&&(this._vertexBufferUpdateFlag|=4096):this.setUVs(null,6),n[oB.UV7]?this.getUVs(7)&&(this._vertexBufferUpdateFlag|=8192):this.setUVs(null,7),this._vertexElementsUpdate=!0},nL.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 ua(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r),this._vertexDataUpdateFlag|=1},nL.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])},nL.addBlendShape=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._blendShapeManager._addBlendShape(e)},nL.clearBlendShapes=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._blendShapeManager._clearBlendShapes()},nL.getBlendShapeName=function(e){return this._accessible?this._blendShapeManager._blendShapes[e].name:this._blendShapeManager._blendShapeNames[e]},nL.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 ut(this._engine,e.BufferBindFlag.VertexBuffer,s,l);this._setVertexBufferBinding(0,new ua(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 un(d,this._indicesFormat)),this._indicesChangeFlag=!1);else{null==d||d.destroy();var _=new ut(this._engine,e.BufferBindFlag.IndexBuffer,h);this._setIndexBufferBinding(new un(_,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())},nL.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=nR._tempVec0,o=nR._tempVec1,s=nR._tempVec2,l=nR._tempVec3,u=nR._tempVec4,c=e?e.length/3:t.length/3,h=Array(i),d=Array(i),_=0;_<i;_++)h[_]=new sd,d[_]=new st;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];st.subtract(y,v,a),st.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);st.scale(a,M*F,s),st.scale(o,A*F,u),st.subtract(s,u,s),st.scale(o,w*F,l),st.scale(a,b*F,u),st.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),st.cross(s,L,u);var D=st.dot(u,R)>0?1:-1;st.scale(R,st.dot(s,R),u),st.subtract(s,u,s),s.normalize(),B.set(s.x,s.y,s.z,D)}this.setTangents(h)},nL._onDestroy=function(){ui.prototype._onDestroy.call(this),this._accessible&&this._releaseCache()},nL._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[oB.Position]&&this._insertVertexAttribute(oB.Position),this._normals&&!r[oB.Normal]&&this._insertVertexAttribute(oB.Normal),this._colors&&!r[oB.Color]&&this._insertVertexAttribute(oB.Color),this._boneWeights&&!r[oB.BoneWeight]&&this._insertVertexAttribute(oB.BoneWeight),this._boneIndices&&!r[oB.BoneIndex]&&this._insertVertexAttribute(oB.BoneIndex),this._tangents&&!r[oB.Tangent]&&this._insertVertexAttribute(oB.Tangent),this._uv&&!r[oB.UV]&&this._insertVertexAttribute(oB.UV),this._uv1&&!r[oB.UV1]&&this._insertVertexAttribute(oB.UV1),this._uv2&&!r[oB.UV2]&&this._insertVertexAttribute(oB.UV2),this._uv3&&!r[oB.UV3]&&this._insertVertexAttribute(oB.UV3),this._uv4&&!r[oB.UV4]&&this._insertVertexAttribute(oB.UV4),this._uv5&&!r[oB.UV5]&&this._insertVertexAttribute(oB.UV5),this._uv6&&!r[oB.UV6]&&this._insertVertexAttribute(oB.UV6),this._uv7&&!r[oB.UV7]&&this._insertVertexAttribute(oB.UV7)},nL._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)},nL._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},nL._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 ue(e,a,t,0)),this._bufferStrides[0]=a+n},nL._getAttributeFormat=function(t){switch(t){case oB.Position:case oB.Normal:return e.VertexElementFormat.Vector3;case oB.Color:case oB.BoneWeight:return e.VertexElementFormat.Vector4;case oB.BoneIndex:return e.VertexElementFormat.UByte4;case oB.Tangent:return e.VertexElementFormat.Vector4;case oB.UV:case oB.UV1:case oB.UV2:case oB.UV3:case oB.UV4:case oB.UV5:case oB.UV6:case oB.UV7:return e.VertexElementFormat.Vector2}},nL._getAttributeByteLength=function(e){switch(e){case oB.Position:case oB.Normal:return 12;case oB.Color:case oB.BoneWeight:return 16;case oB.BoneIndex:return 4;case oB.Tangent:return 16;case oB.UV:case oB.UV1:case oB.UV2:case oB.UV3:case oB.UV4:case oB.UV5:case oB.UV6:case oB.UV7:return 8}},nL._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()},sv(nR,[{key:"accessible",get:function(){return this._accessible}},{key:"vertexCount",get:function(){if(1&this._vertexDataUpdateFlag){var e=0,t=this._vertexElementMap[oB.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}}]),nR);us._tempVec0=new st,us._tempVec1=new st,us._tempVec2=new st,us._tempVec3=new st,us._tempVec4=new st,(nB=oD||(oD={}))[nB.Position=1]="Position",nB[nB.Normal=2]="Normal",nB[nB.Color=4]="Color",nB[nB.Tangent=8]="Tangent",nB[nB.BoneWeight=16]="BoneWeight",nB[nB.BoneIndex=32]="BoneIndex",nB[nB.UV=64]="UV",nB[nB.UV1=128]="UV1",nB[nB.UV2=256]="UV2",nB[nB.UV3=512]="UV3",nB[nB.UV4=1024]="UV4",nB[nB.UV5=2048]="UV5",nB[nB.UV6=4096]="UV6",nB[nB.UV7=8192]="UV7",nB[nB.All=65535]="All";var ul=(sx(nD=function(e){var t;return(t=sE.call(this,null)||this).name=e,t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},sE),nD),uu=(nI=e.Renderer,sx(nO=function(e){var t;return(t=nI.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(sg(t)),t},nI),(nV=nO.prototype)._onDestroy=function(){nI.prototype._onDestroy.call(this);var e=this._mesh;e&&!e.destroyed&&(e._addRefCount(-1),this._mesh=null)},nV._cloneTo=function(e){e.mesh=this._mesh},nV._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;sr.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},nV._render=function(e){var t=this._mesh;if(t){if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(nO._uvMacro),n.disableMacro(nO._uv1Macro),n.disableMacro(nO._normalMacro),n.disableMacro(nO._tangentMacro),n.disableMacro(nO._vertexColorMacro);for(var i=0,a=r.length;i<a;i++)switch(r[i].semantic){case"TEXCOORD_0":n.enableMacro(nO._uvMacro);break;case"TEXCOORD_1":n.enableMacro(nO._uv1Macro);break;case"NORMAL":n.enableMacro(nO._normalMacro);break;case"TANGENT":n.enableMacro(nO._tangentMacro);break;case"COLOR_0":this.enableVertexColor&&n.enableMacro(nO._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 sz.error("mesh is null.")},nV._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},nV._onMeshChanged=function(e){e&oL.Bounds&&(this._dirtyUpdateFlag|=oF.WorldVolume),e&oL.VertexElements&&(this._dirtyUpdateFlag|=2)},sv(nO,[{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)}}]),nO);uu._uvMacro=lz.getMacroByName("O3_HAS_UV"),uu._uv1Macro=lz.getMacroByName("O3_HAS_UV1"),uu._normalMacro=lz.getMacroByName("O3_HAS_NORMAL"),uu._tangentMacro=lz.getMacroByName("O3_HAS_TANGENT"),uu._vertexColorMacro=lz.getMacroByName("O3_HAS_VERTEXCOLOR"),sS([sb],uu.prototype,"_mesh",void 0),sS([sb],uu.prototype,"_onMeshChanged",null),(nU=oI||(oI={}))[nU.VertexElementMacro=2]="VertexElementMacro",nU[nU.All=3]="All";var uc=((nz=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},nz._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},nz._stringToPath=function(e){var t=[];return e.charCodeAt(0)===uh&&t.push(""),e.replace(u_,function(e,n,r,i){var a=e;r?a=i.replace(ud,"$1"):n&&(a=n.trim()),t.push(a)}),t},nz),uh=46,ud=/\\(\\)?/g,u_=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),uf=(sx(nN=function(e){(t=uu.call(this,e)||this)._supportSkinning=!1,t._hasInitSkin=!1,t._jointDataCreateCache=new sh(-1,-1),t._localBounds=new sr,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(sg(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},uu),(nk=nN.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?uc._floatMatrixMultiply(a.transform.worldMatrix,e[i].elements,0,r,o):r.set(e[i].elements,o),uc._floatMatrixMultiply(t,r,o,r,o)}},nk._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 sj(f,4,s,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point),r.disableMacro("O3_JOINTS_NUM"),r.enableMacro("O3_USE_JOINT_TEXTURE"),r.setTexture(nN._jointSamplerProperty,this._jointTexture),this._supportSkinning=!0):(this._supportSkinning=!1,null==(_=this._jointTexture)||_.destroy(),r.disableMacro("O3_HAS_SKIN"),sz.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(nN._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)},nk._cloneTo=function(e){uu.prototype._cloneTo.call(this,e),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},nk._registerEntityTransformListener=function(){},nk._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;sr.transform(t,n,e)}else uu.prototype._updateBounds.call(this,e)},nk._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)sr.transform(this._mesh.bounds,e.inverseBindMatrices[l],this._localBounds);else{var u=new su(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?(su.multiplyScalar(u,1/c,u),sr.transform(this._mesh.bounds,u,this._localBounds)):this._localBounds.copyFrom(this._mesh.bounds)}this._rootBone=s,r?(t.enableMacro("O3_HAS_SKIN"),t.setInt(nN._jointCountProperty,r)):t.disableMacro("O3_HAS_SKIN")}},nk._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?(su.add(r,t[u],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},nk._findByEntityName=function(e,t){return e?e.findByName(t)||this._findByEntityName(e.parent,t):null},nk._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)},nk._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=oF.WorldVolume},sv(nN,[{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|=oF.WorldVolume}}]),nN);uf._tempMatrix=new su,uf._jointCountProperty=lz.getPropertyByName("u_jointCount"),uf._jointSamplerProperty=lz.getPropertyByName("u_jointSampler"),uf._jointMatrixProperty=lz.getPropertyByName("u_jointMatrix"),sS([sb],uf.prototype,"_supportSkinning",void 0),sS([sb],uf.prototype,"_hasInitSkin",void 0),sS([sb],uf.prototype,"_jointDataCreateCache",void 0),sS([sb],uf.prototype,"_blendShapeWeights",void 0),sS([sb],uf.prototype,"_maxVertexUniformVectors",void 0),sS([sb],uf.prototype,"_rootBone",void 0),sS([sb],uf.prototype,"_localBounds",void 0),sS([sb],uf.prototype,"_jointMatrices",void 0),sS([sb],uf.prototype,"_jointTexture",void 0),sS([sb],uf.prototype,"_jointEntities",void 0),sS([sb],uf.prototype,"_condensedBlendShapeWeights",void 0),sS([sb],uf.prototype,"_onLocalBoundsChanged",null);var up=((nG=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 us(e),a=(n=Math.max(2,Math.floor(n)))+1,o=a*a,s=n*n,l=nG._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 st(C,S,w),f[g]=new st(C,S,w),p[g]=new sh(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),nG._initialize(i,_,f,p,l,r),i},nG.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 us(e),o=t/2,s=n/2,l=r/2,u=Array(24),c=Array(24),h=Array(24);u[0]=new st(-o,s,-l),u[1]=new st(o,s,-l),u[2]=new st(o,s,l),u[3]=new st(-o,s,l),c[0]=new st(0,1,0),c[1]=new st(0,1,0),c[2]=new st(0,1,0),c[3]=new st(0,1,0),h[0]=new sh(0,0),h[1]=new sh(1,0),h[2]=new sh(1,1),h[3]=new sh(0,1),u[4]=new st(-o,-s,-l),u[5]=new st(o,-s,-l),u[6]=new st(o,-s,l),u[7]=new st(-o,-s,l),c[4]=new st(0,-1,0),c[5]=new st(0,-1,0),c[6]=new st(0,-1,0),c[7]=new st(0,-1,0),h[4]=new sh(0,1),h[5]=new sh(1,1),h[6]=new sh(1,0),h[7]=new sh(0,0),u[8]=new st(-o,s,-l),u[9]=new st(-o,s,l),u[10]=new st(-o,-s,l),u[11]=new st(-o,-s,-l),c[8]=new st(-1,0,0),c[9]=new st(-1,0,0),c[10]=new st(-1,0,0),c[11]=new st(-1,0,0),h[8]=new sh(0,0),h[9]=new sh(1,0),h[10]=new sh(1,1),h[11]=new sh(0,1),u[12]=new st(o,s,-l),u[13]=new st(o,s,l),u[14]=new st(o,-s,l),u[15]=new st(o,-s,-l),c[12]=new st(1,0,0),c[13]=new st(1,0,0),c[14]=new st(1,0,0),c[15]=new st(1,0,0),h[12]=new sh(1,0),h[13]=new sh(0,0),h[14]=new sh(0,1),h[15]=new sh(1,1),u[16]=new st(-o,s,l),u[17]=new st(o,s,l),u[18]=new st(o,-s,l),u[19]=new st(-o,-s,l),c[16]=new st(0,0,1),c[17]=new st(0,0,1),c[18]=new st(0,0,1),c[19]=new st(0,0,1),h[16]=new sh(0,0),h[17]=new sh(1,0),h[18]=new sh(1,1),h[19]=new sh(0,1),u[20]=new st(-o,s,-l),u[21]=new st(o,s,-l),u[22]=new st(o,-s,-l),u[23]=new st(-o,-s,-l),c[20]=new st(0,0,-1),c[21]=new st(0,0,-1),c[22]=new st(0,0,-1),c[23]=new st(0,0,-1),h[20]=new sh(1,0),h[21]=new sh(0,0),h[22]=new sh(0,1),h[23]=new sh(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),nG._initialize(a,u,c,h,d,i),a},nG.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 us(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=nG._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 st(S*h-u,0,w*d-c),x[C]=new st(0,1,0),T[C]=new sh(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),nG._initialize(o,y,x,T,p,a),o},nG.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 us(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=nG._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 st(U,z,N),T[P]=new st(I,M,O),C[P]=new sh(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 st(0,-c,0),T[d]=new st(0,-1,0),C[d]=new sh(.5,.5),x[d+1]=new st(0,c,0),T[d+1]=new st(0,1,0),C[d+1]=new sh(.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 st($,-c,ee),T[K]=new st(0,-1,0),C[K++]=new sh($*Y+.5,.5-ee*Y);var et=x[J+Q];$=et.x,ee=et.z,x[K]=new st($,c,ee),T[K]=new st(0,1,0),C[K++]=new sh($*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),nG._initialize(s,x,T,C,g,o),s},nG.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 us(e),l=((r=Math.floor(r))+1)*((i=Math.floor(i))+1),u=r*i,c=nG._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 st((t+n*y)*T,(t+n*y)*C,n*x);h[f]=S;var w=t*T,b=t*C;d[f]=new st(S.x-w,S.y-b,S.z).normalize(),_[f++]=new sh(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),nG._initialize(s,h,d,_,c,o),s},nG.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 us(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=nG._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 st(D,I,O),y[b]=new st(R,w,L),x[b]=new sh(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 st(0,-u,0),y[h]=new st(0,-1,0),x[h]=new sh(.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 st(K,-u,q),y[H]=new st(0,-1,0),x[H++]=new sh(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),nG._initialize(o,v,y,x,f,a),o},nG.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 us(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=nG._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 st(t*L,F*c-u,t*B),S[A]=new st(L,0,B),w[A]=new sh(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}nG._createCapsuleCap(t,n,r,T,h,1,C,S,w,g,b),nG._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),nG._initialize(o,C,S,w,g,a),o},nG._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)},nG._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},nG._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 st(S,w,b),s[A]=new st(S,w-d,b),l[A]=new sh(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}},nG),ug=(sx(nH=function(){return ui.apply(this,arguments)},ui),(nW=nH.prototype).setVertexElements=function(e){this._setVertexElements(e)},nW.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 ua(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},nW.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])},nW.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new un(e,t))),this._setIndexBufferBinding(n)},sv(nH,[{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}}]),nH),um=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},uv=((nj=(nX=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new lt,this._dataChangeManager=new lt,this._frames=[],this.name=e}).prototype).addFrame=function(e,t,n,r){if("number"==typeof e){var i=new um(e,t,n,r);return this._addFrame(i),i}this._addFrame(e)},nj.clearFrames=function(){this._frames.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},nj._addDataDirtyFlag=function(e){this._dataChangeManager.addFlag(e)},nj._createSubDataDirtyFlag=function(){return this._dataChangeManager.createFlag(s9)},nj._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()},nj._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))},sv(nX,[{key:"frames",get:function(){return this._frames}}]),nX),uy=function(){function t(e){this._subMeshPool=new l$(ur),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 ug(n,"BufferMesh"+r),o=[],s=this.createVertexElements(o);return this._vertexBuffers[r]=new ut(n,e.BufferBindFlag.VertexBuffer,4*i*s,e.BufferUsage.Dynamic),this._indiceBuffers[r]=new ut(n,e.BufferBindFlag.IndexBuffer,3*i,e.BufferUsage.Dynamic),a.setVertexBufferBinding(this._vertexBuffers[r],s),a.setIndexBufferBinding(this._indiceBuffers[r],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}();uy.MAX_VERTEX_COUNT=4096,uy._canUploadSameBuffer=!0;var ux=(sx(nK=function(){return uy.apply(this,arguments)},uy),(nq=nK.prototype).createVertexElements=function(t){return t[0]=new ue("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ue("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},nq.canBatch=function(e,t){if(e.isAdd!==t.isAdd)return!1;var n=e.component.shaderData,r=t.component.shaderData,i=l7._textureProperty,a=l7._alphaCutoffProperty;return n.getTexture(i)===r.getTexture(i)&&n.getTexture(a)===r.getTexture(a)},nq.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},nq.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=lz._compileMacros;lE.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)}},nK),uT=((nQ=(nY=function(e){this._preMaskLayer=0,this._batcher=new ux(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},nQ.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t,null))},nQ.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},nQ.destroy=function(){this._batcher.destroy(),this._batcher=null},nQ._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)}}}},nY),uC=(sx(nJ=function(){var e;return(e=l0.call(this)||this).charElements=[],e.multiRenderData=!0,e},l0),nJ);e.BackgroundMode=void 0,(nZ=e.BackgroundMode||(e.BackgroundMode={}))[nZ.SolidColor=0]="SolidColor",nZ[nZ.Sky=1]="Sky",nZ[nZ.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(n$=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[n$.AspectFitWidth=0]="AspectFitWidth",n$[n$.AspectFitHeight=1]="AspectFitHeight",n$[n$.Fill=2]="Fill";var uS=((n0=function(){}).prototype._render=function(e){var t=this.material,n=this.mesh;if(!t){sz.warn("The material of sky is not defined.");return}if(!n){sz.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=n0._viewProjMatrix,c=n0._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(se.degreeToRadian(o)/2);c.elements[0]=g/a,c.elements[5]=g,su.multiply(c,u,u);var m=l.getMatrix(l2._vpMatrixProperty);l.setMatrix(l2._vpMatrixProperty,u);var v=lz._compileMacros;lE.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(l2._vpMatrixProperty,m)},n0);uS._epsilon=1e-6,uS._viewProjMatrix=new su,uS._projectionMatrix=new su(1,0,0,0,0,1,0,0,0,0,uS._epsilon-1,-1,0,0,0,0);var uw=((n2=(n1=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new s_(.25,.25,.25,1),this.sky=new uS,this._textureFillMode=e.BackgroundTextureFillMode.AspectFitHeight,this._texture=null,this._mesh=this._createPlane(t)}).prototype)._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)}},n2._createPlane=function(e){var t=new us(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 st,i[a]=new sh(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},sv(n1,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(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())}}]),n1);e.FogMode=void 0,(n3=e.FogMode||(e.FogMode={}))[n3.None=0]="None",n3[n3.Linear=1]="Linear",n3[n3.Exponential=2]="Exponential",n3[n3.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(n4=e.DiffuseMode||(e.DiffuseMode={}))[n4.SolidColor=0]="SolidColor",n4[n4.SphericalHarmonics=1]="SphericalHarmonics";var ub=((n8=(n5=function(){this._diffuseSolidColor=new s_(.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(n5._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(n5._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(n5._specularIntensityProperty,this._specularIntensity),t.setFloatArray(n5._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},n8._removeFromScene=function(e){var t=this._scenes,n=t.indexOf(e);t.splice(n,1)},n8._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(n5._shMacro):t.disableMacro(n5._shMacro)},n8._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(n5._specularTextureProperty,this._specularTexture),e.setFloat(n5._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(n5._specularMacro)):e.disableMacro(n5._specularMacro)},n8._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(n5._decodeRGBMMacro):e.disableMacro(n5._decodeRGBMMacro)},n8._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]},sv(n5,[{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(n5._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(n5._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(n5._specularIntensityProperty,e)}}]),n5);ub._shMacro=lz.getMacroByName("O3_USE_SH"),ub._specularMacro=lz.getMacroByName("O3_USE_SPECULAR_ENV"),ub._decodeRGBMMacro=lz.getMacroByName("O3_DECODE_ENV_RGBM"),ub._diffuseColorProperty=lz.getPropertyByName("u_envMapLight.diffuse"),ub._diffuseSHProperty=lz.getPropertyByName("u_env_sh"),ub._diffuseIntensityProperty=lz.getPropertyByName("u_envMapLight.diffuseIntensity"),ub._specularTextureProperty=lz.getPropertyByName("u_env_specularSampler"),ub._specularIntensityProperty=lz.getPropertyByName("u_envMapLight.specularIntensity"),ub._mipLevelProperty=lz.getPropertyByName("u_envMapLight.mipMapLevel");var uA=function(t){function n(r,i){(a=t.call(this,r)||this).background=new uw(a._engine),a.shaderData=new lN(oA.Scene),a.castShadows=!0,a.shadowResolution=e.ShadowResolution.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new st(1/15,.2,7/15),a.shadowDistance=50,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new lE,a._rootEntities=[],a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new s_(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new sd,a.name=i||"";var a,o=a.shaderData;return o._addRefCount(1),a.ambientLight=new ub,r.sceneManager._allScenes.push(sg(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}sx(n,t);var r=n.prototype;return r.createRootEntity=function(e){var t=new lr(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),lr._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(),lr._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=lr._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):sz.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,n=this._engine._lightManager;n._updateShaderData(this.shaderData);var r=n._getSunLightIndex();-1!==r&&(this._sunLight=n._directLights.get(r)),this.castShadows&&this._sunLight&&this._sunLight.shadowType!==e.ShadowType.None?t.enableMacro("SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SHADOW_TYPE"),lE.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.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)},sv(n,[{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){sz.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}(sE);uA._fogColorProperty=lz.getPropertyByName("oasis_FogColor"),uA._fogParamsProperty=lz.getPropertyByName("oasis_FogParams");var uM=((n7=(n6=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},n7.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,i=n.length;r<i;r++)t.addRootEntity(n[r])},n7._destroyAllScene=function(){for(var e=this._allScenes,t=0,n=e.length;t<n;t++)e[t]._destroy();e.length=0},sv(n6,[{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)}}]),n6),uF="#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}",uP=((n9=function(){}).init=function(){lz.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}"),lz.create("pbr",uF,"#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}"),lz.create("pbr-specular",uF,"#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}"),lz.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}"),lz.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}"),lz.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;}"),lz.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}"),lz.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;}"),lz.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;}"),lz.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);}")},n9),uE=((rt=(re=function(){this._cacheHierarchy=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,n=e._length;n>this._cacheHierarchy&&this._resizeCacheMapHierarchy(t,0,n);for(var r=e._mask,i=e._length-1,a=this._cacheHierarchy-1,o=0;o<a;o++){var s=i<o?0:r[o],l=t[s];l||(t[s]=l=Object.create(null)),t=l}var u=i<a?0:r[a],c=t[u];return c||(this._lastQueryKey=u,this._lastQueryMap=t),c},rt.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},rt._resizeCacheMapHierarchy=function(e,t,n){var r=this._cacheHierarchy-1;if(t==r){for(var i in e)for(var a=e[i],o=e,s=0,l=n-r;s<l;s++)s==l-1?o[0]=a:o=o[0==s?i:0]=Object.create(null);this._cacheHierarchy=n}else for(var u in e)this._resizeCacheMapHierarchy(e[u],++t,n)},re);uP.init();var uR=function(t){function n(r,i,a){(o=t.call(this)||this)._lightManager=new lX,o._componentsManager=new s5,o._lastRenderState=new lJ,o._renderElementPool=new l$(l1),o._spriteElementPool=new l$(l3),o._spriteMaskElementPool=new l$(l4),o._textElementPool=new l$(uC),o._renderContext=new l2,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._macroCollection=new lE,o._settings={},o._resourceManager=new s$(sg(o)),o._sceneManager=new uM(sg(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new sN,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 ll(sg(o)),o._canvas=r,o._sceneManager.activeScene=new uA(sg(o),"DefaultScene"),o._spriteMaskManager=new uT(sg(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=sJ.createFromOS(sg(o),"Arial"),o._textDefaultFont.isGCIgnored=!1,o.inputManager=new lF(sg(o));var o,s=new Uint8Array([255,0,255,255]),l=new sj(sg(o),1,1,e.TextureFormat.R8G8B8A8,!1);l.setPixelBuffer(s),l.isGCIgnored=!0;var u=new sq(sg(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 sj(sg(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 sK(sg(o),1,1,1,e.TextureFormat.R8G8B8A8,!1);h.setPixelBuffer(0,s),h.isGCIgnored=!0,o._magentaTexture2DArray=h}var d=new lZ(sg(o),lz.find("unlit"));d.shaderData.setColor("u_baseColor",new sC(1,0,1.01,1)),o._magentaMaterial=d;var _=new lZ(sg(o),lz.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}sx(n,t);var r=n.prototype;return r.createEntity=function(e){return new lr(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 sL("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 sL("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 uE}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 sz.debug("NO active camera.")},r._createSpriteMaterial=function(){var t=new lZ(this,lz.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 lZ(this,lz.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},sv(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}(sB);uR._gammaMacro=lz.getMacroByName("OASIS_COLORSPACE_GAMMA"),uR._noDepthTextureMacro=lz.getMacroByName("OASIS_NO_DEPTH_TEXTURE"),uR._pixelsPerUnit=100;var uL=(sx(rn=function(){var e;return e=le.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},le),(rr=rn.prototype).onAwake=function(){},rr.onEnable=function(){},rr.onStart=function(){},rr.onUpdate=function(e){},rr.onLateUpdate=function(e){},rr.onBeginRender=function(e){},rr.onEndRender=function(e){},rr.onPhysicsUpdate=function(){},rr.onTriggerEnter=function(e){},rr.onTriggerExit=function(e){},rr.onTriggerStay=function(e){},rr.onCollisionEnter=function(e){},rr.onCollisionExit=function(e){},rr.onCollisionStay=function(e){},rr.onPointerDown=function(e){},rr.onPointerUp=function(e){},rr.onPointerClick=function(e){},rr.onPointerEnter=function(e){},rr.onPointerExit=function(e){},rr.onPointerDrag=function(e){},rr.onDisable=function(){},rr.onDestroy=function(){},rr._onAwake=function(){this.onAwake()},rr._onEnable=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.engine._componentsManager,t=rn.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()},rr._onDisable=function(){this._waitHandlingInValid=!0,this._engine._componentsManager.addDisableScript(this),this.onDisable()},rr._onDestroy=function(){this._engine._componentsManager.addPendingDestroyScript(this)},rr._handlingInValid=function(){var e=this.engine._componentsManager,t=rn.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},rn);sS([sb],uL.prototype,"_started",void 0),sS([sb],uL.prototype,"_onStartIndex",void 0),sS([sb],uL.prototype,"_onUpdateIndex",void 0),sS([sb],uL.prototype,"_onLateUpdateIndex",void 0),sS([sb],uL.prototype,"_onPhysicsUpdateIndex",void 0),sS([sb],uL.prototype,"_onPreRenderIndex",void 0),sS([sb],uL.prototype,"_onPostRenderIndex",void 0),sS([sb],uL.prototype,"_entityScriptsIndex",void 0),sS([sb],uL.prototype,"_waitHandlingInValid",void 0);var uB=(sx(ri=function(){return uy.apply(this,arguments)},uy),(ra=ri.prototype).createVertexElements=function(t){return t[0]=new ue("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ue("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new ue("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},ra.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},ra.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},ra.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},ra.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=lz._compileMacros;lE.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p),(t||f)._preRender(d);var g=d.shaderPass._getShaderProgram(n,p);if(!g.isValid)return;_.shaderData.setTexture(ri._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(_)}},ra.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,n=this._indiceBuffers,r=0,i=e.length;r<i;++r)e[r].destroy();this._meshes=null;for(var a=0,o=t.length;a<o;++a)t[a].destroy();this._vertexBuffers=null;for(var s=0,l=n.length;s<l;++s)n[s].destroy();this._indiceBuffers=null},ri);uB._textureProperty=lz.getPropertyByName("u_spriteTexture");var uD=((rs=(ro=function(e){this.items=[],this._spriteBatcher=new uB(e)}).prototype).pushPrimitive=function(e){this.items.push(e)},rs.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=lz._compileMacros,p=_.component,g=_.material.destroyed?a._magentaMaterial:_.material,m=p.shaderData,v=g.shaderData;(t||g)._preRender(_),lE.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)}},rs.clear=function(){this.items.length=0,this._spriteBatcher.clear()},rs.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rs.sort=function(e){this._quickSort(this.items,0,this.items.length,e)},rs._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=_)}},rs._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.component.priority-t.component.priority||e.component._distanceForSort-t.component._distanceForSort},ro._compareFromFarToNear=function(e,t){return e.component.priority-t.component.priority||t.component._distanceForSort-e.component._distanceForSort},ro),uI=function(){this.position=new st,this.isOrthographic=!1,this.viewMatrix=new su,this.projectionMatrix=new su,this.viewProjectionMatrix=new su,this.forward=new st},uO=function(){this.virtualCamera=new uI,this.cullPlanes=[new sa(new st),new sa(new st),new sa(new st),new sa(new st),new sa(new st),new sa(new st),new sa(new st),new sa(new st),new sa(new st),new sa(new st)],this.splitBoundSphere=new sn(new st,0)};(rl=oO||(oO={}))[rl.FarBottomLeft=0]="FarBottomLeft",rl[rl.FarTopLeft=1]="FarTopLeft",rl[rl.FarTopRight=2]="FarTopRight",rl[rl.FarBottomRight=3]="FarBottomRight",rl[rl.nearBottomLeft=4]="nearBottomLeft",rl[rl.nearTopLeft=5]="nearTopLeft",rl[rl.nearTopRight=6]="nearTopRight",rl[rl.nearBottomRight=7]="nearBottomRight",rl[rl.unknown=8]="unknown";var uV=((ru=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}},ru.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},ru.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},ru.shadowCullFrustum=function(e,t,n,r){var i=n._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&n.castShadows&&ru.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time._frameCount,n._prepareRender(e))},ru.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,u=Math.sqrt(1+s*s)*Math.tan(se.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,st.scale(r,a,_),st.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},ru.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=ru._frustumCorners,s=ru._backPlaneFaces,l=ru._frustumPlaneNeighbors,u=ru._frustumTwoPlaneCorners,c=ru._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=ru._adjustNearPlane,y=ru._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),si.intersectionPointThreePlanes(v,g,p,o[7]),si.intersectionPointThreePlanes(v,m,p,o[6]),si.intersectionPointThreePlanes(v,m,f,o[5]),si.intersectionPointThreePlanes(v,g,f,o[4]),si.intersectionPointThreePlanes(y,g,p,o[3]),si.intersectionPointThreePlanes(y,m,p,o[2]),si.intersectionPointThreePlanes(y,m,f,o[1]),si.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>st.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]];st.add(L,i,c),sa.fromPoints(L,B,c,h[S++])}}a.cullPlaneCount=S},ru.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-ru.atlasBorderSize),_=2*d,f=a/_,p=_/a,g=Math.ceil(st.dot(u,e)*f)*p,m=Math.ceil(st.dot(u,t)*f)*p,v=st.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;st.scale(n,c+i,x),st.subtract(u,x,x),su.lookAt(x,u,e,T),su.ortho(-d,d,-d,d,0,2*c+i,C);var S=y.viewProjectionMatrix;su.multiply(C,T,S),uc._floatMatrixMultiply(ru._shadowMapCoordMatrix,S.elements,0,s,16*r)},ru.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},ru.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)},ru.applySliceTransform=function(e,t,n,r,i,a){var o=ru._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;uc._floatMatrixMultiply(o,a,d,a,d)},ru);uV._tempMatrix0=new su,uV._shadowMapCoordMatrix=new su(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),uV._frustumCorners=[new st,new st,new st,new st,new st,new st,new st,new st],uV._adjustNearPlane=new sa(new st),uV._adjustFarPlane=new sa(new st),uV._backPlaneFaces=[,,,,,],uV._edgePlanePoint2=new st,uV._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]],uV._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]]],uV.atlasBorderSize=4;var uU=function(){function t(n){this._shadowMapSize=new sd,this._shadowBias=new sh,this._shadowSliceData=new uO,this._lightUp=new st,this._lightSide=new st,this._existShadowMap=!1,this._splitBoundSpheres=new Float32Array(4*t._maxCascades),this._shadowMatrices=new Float32Array((t._maxCascades+1)*16),this._shadowInfos=new st,this._viewportOffsets=[new sh,new sh,new sh,new sh],this._camera=n,this._engine=n.engine,this._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),this._shadowCasterShader=lz.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,null,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,su.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(uV.getBoundSphereByFrustum(m[P],m[P+1],i,t._tempVector.normalize(),s),uV.getDirectionLightShadowCullPlanes(i._frustum,m[P],i.nearClipPlane,S,s),uV.getDirectionalLightMatrices(T,C,S,P,b.shadowNearPlane,F,s,u),g>1){var E=this._shadowMapSize;uV.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)uV.shadowCullFrustum(n,b,I[O],s);if(h.items.length||d.items.length){h.sort(uD._compareFromNearToFar),d.sort(uD._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*se.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 sj(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 sX(t,i,a,null,o):this._renderTargets=new sX(t,i,a,o)),s},n._updateShadowSettings=function(){var t=this._camera.scene,n=uV.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=uV.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=uV.getMaxTileResolutionInAtlas(r,r,i);this._shadowTileResolution=a;var o=2*a,s=i==e.ShadowCascadesMode.TwoCascades?a:2*a;this._shadowMapSize.set(1/o,1/s,o,s)}this._renderTargets=null;var l=this._viewportOffsets,u=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:l[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:l[0].set(0,0),l[1].set(u,0);break;case e.ShadowCascadesMode.FourCascades:l[0].set(0,0),l[1].set(u,0),l[2].set(0,u),l[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var i=n.virtualCamera;uV.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}();uU._lightShadowBiasProperty=lz.getPropertyByName("u_shadowBias"),uU._lightDirectionProperty=lz.getPropertyByName("u_lightDirection"),uU._shadowMatricesProperty=lz.getPropertyByName("u_shadowMatrices"),uU._shadowMapSize=lz.getPropertyByName("u_shadowMapSize"),uU._shadowInfosProperty=lz.getPropertyByName("u_shadowInfo"),uU._shadowMapsProperty=lz.getPropertyByName("u_shadowMap"),uU._shadowSplitSpheresProperty=lz.getPropertyByName("u_shadowSplitSpheres"),uU._maxCascades=4,uU._cascadesSplitDistance=Array(uU._maxCascades+1),uU._clearColor=new s_(1,1,1,1),uU._tempVector=new st,uU._tempMatrix0=new su;var uz=0,uN=((rh=(rc=function(t,n,r,i,a){void 0===t&&(t="RENDER_PASS"+uz++),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){},rc),uk=((r_=(rd=function(e){this._allSpriteMasks=new s4,this._lastCanvasSize=new sh,this._camera=e;var t=e.engine;this._opaqueQueue=new uD(t),this._alphaTestQueue=new uD(t),this._transparentQueue=new uD(t),this._cascadedShadowCaster=new uU(e),this._renderPassArray=[],this._defaultPass=new uN("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 uN(e,t,n,r,i);this._renderPassArray.push(a)}else sw(e,uN)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},r_.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):sw(e,uN)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},r_.getRenderPass=function(e){for(var t=0,n=this._renderPassArray.length;t<n;t++){var r=this._renderPassArray[t];if(r.name===e)return r}return null},r_.destroy=function(){this._opaqueQueue.destroy(),this._alphaTestQueue.destroy(),this._transparentQueue.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},r_.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(uD._compareFromNearToFar),l.sort(uD._compareFromNearToFar),u.sort(uD._compareFromFarToNear);for(var c=0,h=this._renderPassArray.length;c<h;c++)this._drawRenderPass(t,this._renderPassArray[c],a,n,r)},r_._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)},r_.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)}},r_._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,lz._compileMacros);s.bind(),s.uploadAll(s.materialUniformBlock,i.shaderData),s.uploadUnGroupTextures(),i.renderState._apply(t,!1),r.drawPrimitive(o,o.subMesh,s)},r_._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))}},sv(rd,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rd);uk._tempVector0=new st,uk._tempVector1=new st;var uG=function(){};uG.tempVec4=new sd,uG.tempVec3=new st,uG.tempVec2=new sh,e.Camera=(sx(rf=function(t){(n=le.call(this,t)||this).shaderData=new lN(oA.Camera),n.priority=0,n.enableFrustumCulling=!0,n.clearFlags=e.CameraClearFlags.All,n.cullingMask=e.Layer.Everything,n._globalShaderMacro=new lE,n._frustum=new so,n._virtualCamera=new uI,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 sd(0,0,1,1),n._inverseProjectionMatrix=new su,n._lastAspectSize=new sh(0,0),n._invViewProjMat=new su;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 uk(sg(n)),n.shaderData._addRefCount(1),n},le),(rp=rf.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},rp.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},rp.worldToViewportPoint=function(e,t){var n=uG.tempVec3,r=uG.tempVec4;st.transformCoordinate(e,this.viewMatrix,n),st.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},rp.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},rp.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 st.subtract(i,r,i),i.normalize(),t},rp.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},rp.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},rp.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},rp.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},rp.screenPointToRay=function(e,t){var n=uG.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},rp.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,i=this.entity.transform;su.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(),lE.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,sz.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},rp._onEnable=function(){this.entity.scene._attachRenderCamera(this)},rp._onDisable=function(){this.entity.scene._detachRenderCamera(this)},rp._onDestroy=function(){var e;null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this.shaderData._addRefCount(-1)},rp._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},rp._innerViewportToWorldPoint=function(e,t,n,r,i){var a=uG.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),st.transformCoordinate(a,r,i),i},rp._updateShaderData=function(){var t=this.shaderData;t.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition)},rp._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,su.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},rp._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,su.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},sv(rf,[{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;su.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;su.ortho(-i,i,-a,a,this._nearClipPlane,this._farClipPlane,t)}else su.perspective(se.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}}]),(oV=rf)._inverseViewMatrixProperty=lz.getPropertyByName("u_viewInvMat"),oV._cameraPositionProperty=lz.getPropertyByName("u_cameraPos"),oV),sS([sF],e.Camera.prototype,"_frustum",void 0),sS([sb],e.Camera.prototype,"_renderPipeline",void 0),sS([sb],e.Camera.prototype,"_virtualCamera",void 0),sS([sb],e.Camera.prototype,"_frustumViewChangeFlag",void 0),sS([sb],e.Camera.prototype,"_transform",void 0),sS([sb],e.Camera.prototype,"_isViewMatrixDirty",void 0),sS([sb],e.Camera.prototype,"_isInvViewProjDirty",void 0),sS([sF],e.Camera.prototype,"_viewport",void 0),sS([sF],e.Camera.prototype,"_inverseProjectionMatrix",void 0),sS([sF],e.Camera.prototype,"_lastAspectSize",void 0),sS([sF],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=sS([s7(ln)],e.Camera);var uH={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},uW=1/0;function uX(e,t){return void 0===t&&(t={}),new sZ(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:uW,t.type=null!=(l=t.type)?l:uH[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?uj:uK,_=new uq(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 uj(e,t){return new sZ(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 uK(e,t){return new sZ(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 uq=((rm=(rg=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()},rm.stop=function(){clearTimeout(this._timeoutId)},rm.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)})},rg),uY=((rv=function(e){this.useCache=e,this.request=uX}).registerClass=function(e,t){this._engineObjects[e]=t},rv.getClass=function(e){return this._engineObjects[e]},rv);uY._engineObjects={},e.AssetType=void 0,(ry=e.AssetType||(e.AssetType={})).Text="text",ry.JSON="json",ry.Buffer="buffer",ry.Texture2D="texture2d",ry.TextureCube="texture-cube",ry.Material="material",ry.Mesh="mesh",ry.AnimationClip="AnimationClip",ry.AnimatorController="AnimatorController",ry.Prefab="prefab",ry.KTX="ktx",ry.KTXCube="ktx-cube",ry.Sprite="sprite",ry.SpriteAtlas="sprite-atlas",ry.Env="environment",ry.Scene="scene",ry.HDR="HDR",ry.Font="font",ry.SourceFont="source-font",e.BlendMode=void 0,(rx=e.BlendMode||(e.BlendMode={}))[rx.Normal=0]="Normal",rx[rx.Additive=1]="Additive",e.RenderFace=void 0,(rT=e.RenderFace||(e.RenderFace={}))[rT.Front=0]="Front",rT[rT.Back=1]="Back",rT[rT.Double=2]="Double";var uQ=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}sx(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},sv(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 lJ),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}(lZ);uQ._baseColorProp=lz.getPropertyByName("u_baseColor"),uQ._baseTextureProp=lz.getPropertyByName("u_baseTexture"),uQ._baseTextureMacro=lz.getMacroByName("BASETEXTURE"),uQ._tilingOffsetProp=lz.getPropertyByName("u_tilingOffset"),uQ._normalTextureProp=lz.getPropertyByName("u_normalTexture"),uQ._normalIntensityProp=lz.getPropertyByName("u_normalIntensity"),uQ._normalTextureMacro=lz.getMacroByName("NORMALTEXTURE"),uQ._emissiveColorProp=lz.getPropertyByName("u_emissiveColor"),uQ._emissiveTextureProp=lz.getPropertyByName("u_emissiveTexture"),uQ._emissiveTextureMacro=lz.getMacroByName("EMISSIVETEXTURE"),uQ._transparentMacro=lz.getMacroByName("OASIS_TRANSPARENT"),uQ._alphaCutoffProp=lz.getPropertyByName("u_alphaCutoff"),uQ._alphaCutoffMacro=lz.getMacroByName("ALPHA_CUTOFF");var uJ=function(e){function t(n){var r,i=(r=e.call(this,n,lz.find("blinn-phong"))||this).shaderData;return i.enableMacro("O3_NEED_WORLDPOS"),i.enableMacro("O3_NEED_TILINGOFFSET"),i.setColor(t._baseColorProp,new s_(1,1,1,1)),i.setColor(t._specularColorProp,new s_(1,1,1,1)),i.setColor(t._emissiveColorProp,new s_(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new sd(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return sx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sv(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}(uQ);uJ._specularColorProp=lz.getPropertyByName("u_specularColor"),uJ._shininessProp=lz.getPropertyByName("u_shininess"),uJ._specularTextureProp=lz.getPropertyByName("u_specularTexture"),e.TextureCoordinate=void 0,(rC=e.TextureCoordinate||(e.TextureCoordinate={}))[rC.UV0=0]="UV0",rC[rC.UV1=1]="UV1",rC[rC.UV2=2]="UV2",rC[rC.UV3=3]="UV3",rC[rC.UV4=4]="UV4",rC[rC.UV5=5]="UV5",rC[rC.UV6=6]="UV6",rC[rC.UV7=7]="UV7";var uZ=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 s_(1,1,1,1)),o.setColor(n._emissiveColorProp,new s_(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new sd(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 sx(n,t),sv(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&&sz.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}(uQ);uZ._occlusionTextureIntensityProp=lz.getPropertyByName("u_occlusionIntensity"),uZ._occlusionTextureCoordProp=lz.getPropertyByName("u_occlusionTextureCoord"),uZ._occlusionTextureProp=lz.getPropertyByName("u_occlusionTexture"),uZ._clearCoatProp=lz.getPropertyByName("u_clearCoat"),uZ._clearCoatTextureProp=lz.getPropertyByName("u_clearCoatTexture"),uZ._clearCoatRoughnessProp=lz.getPropertyByName("u_clearCoatRoughness"),uZ._clearCoatRoughnessTextureProp=lz.getPropertyByName("u_clearCoatRoughnessTexture"),uZ._clearCoatNormalTextureProp=lz.getPropertyByName("u_clearCoatNormalTexture");var u$=function(e){function t(n){var r;return(r=e.call(this,n,lz.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r}return sx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sv(t,[{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}(uZ);u$._metallicProp=lz.getPropertyByName("u_metal"),u$._roughnessProp=lz.getPropertyByName("u_roughness"),u$._roughnessMetallicTextureProp=lz.getPropertyByName("u_roughnessMetallicTexture");var u0=function(e){function t(n){var r;return(r=e.call(this,n,lz.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new s_(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return sx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sv(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}(uZ);u0._specularColorProp=lz.getPropertyByName("u_PBRSpecularColor"),u0._glossinessProp=lz.getPropertyByName("u_glossiness"),u0._specularGlossinessTextureProp=lz.getPropertyByName("u_specularGlossinessTexture"),u0._specularGlossinessTextureMacro=lz.getMacroByName("SPECULARGLOSSINESSTEXTURE");var u1=function(e){function t(n){var r,i=(r=e.call(this,n,lz.find("unlit"))||this).shaderData;return i.enableMacro("OMIT_NORMAL"),i.enableMacro("O3_NEED_TILINGOFFSET"),i.setColor(t._baseColorProp,new s_(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new sd(1,1,0,0)),r}return sx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sv(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}(uQ);e.TextHorizontalAlignment=void 0,(rS=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[rS.Left=0]="Left",rS[rS.Center=1]="Center",rS[rS.Right=2]="Right",e.TextVerticalAlignment=void 0,(rw=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[rw.Top=0]="Top",rw[rw.Center=1]="Center",rw[rw.Bottom=2]="Bottom",e.OverflowMode=void 0,(rb=e.OverflowMode||(e.OverflowMode={}))[rb.Overflow=0]="Overflow",rb[rb.Truncate=1]="Truncate",e.FontStyle=void 0,(rA=e.FontStyle||(e.FontStyle={}))[rA.None=0]="None",rA[rA.Bold=1]="Bold",rA[rA.Italic=2]="Italic";var u2=(sx(rM=function(e){var t;return(t=sR.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},sR),(rF=rM.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},rF.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},rF._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1},rF._onDestroy=function(){this._sprites=null,this._spriteNamesToIndex=null},sv(rM,[{key:"sprites",get:function(){return this._sprites}}]),rM);e.SpriteDrawMode=void 0,(rP=e.SpriteDrawMode||(e.SpriteDrawMode={}))[rP.Simple=0]="Simple",rP[rP.Sliced=1]="Sliced";var u3=(sx(rE=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=sR.call(this,e)||this)._width=void 0,o._height=void 0,o._positions=[new sh,new sh,new sh,new sh],o._uvs=[new sh,new sh,new sh,new sh],o._bounds=new sr,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new sf(0,0,1,1),o._atlasRegionOffset=new sd(0,0,0,0),o._region=new sf(0,0,1,1),o._pivot=new sh(.5,.5),o._border=new sd(0,0,0,0),o._dirtyUpdateFlag=3,o._updateFlagManager=new lt,o._texture=t,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),i&&o._border.copyFrom(i),o.name=a,o},sR),(rR=rE.prototype).clone=function(){var e=new rE(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},rR._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},rR._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},rR._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},rR._onDestroy=function(){this._texture&&(this._texture=null)},rR._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/uR._pixelsPerUnit;this._width=e.width*t.width/(1-n.x-n.z)*r.width*i,this._height=e.height*t.height/(1-n.y-n.w)*r.height*i}},rR._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},rR._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},rR._dispatchSpriteChange=function(e){switch(e){case oE.atlasRegionOffset:case oE.region:this._dirtyUpdateFlag|=3;break;case oE.atlasRegion:case oE.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},sv(rE,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(oE.texture),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oE.size))}},{key:"width",get:function(){return void 0===this._width&&this._calDefaultSize(),this._width},set:function(e){this._width!==e&&(this._width=e,this._dispatchSpriteChange(oE.size))}},{key:"height",get:function(){return void 0===this._height&&this._calDefaultSize(),this._height},set:function(e){this._height!==e&&(this._height=e,this._dispatchSpriteChange(oE.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=se.clamp(e.x,0,1),n=se.clamp(e.y,0,1);this._atlasRegion.set(t,n,se.clamp(e.width,0,1-t),se.clamp(e.height,0,1-n)),this._dispatchSpriteChange(oE.atlasRegion),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oE.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=se.clamp(e.x,0,1),n=se.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,se.clamp(e.z,0,1-t),se.clamp(e.w,0,1-n)),this._dispatchSpriteChange(oE.atlasRegionOffset),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oE.size)}},{key:"region",get:function(){return this._region},set:function(e){var t=this._region,n=se.clamp(e.x,0,1),r=se.clamp(e.y,0,1);t.set(n,r,se.clamp(e.width,0,1-n),se.clamp(e.height,0,1-r)),this._dispatchSpriteChange(oE.region),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oE.size)}},{key:"pivot",get:function(){return this._pivot},set:function(e){var t=this._pivot;if(t===e)this._dispatchSpriteChange(oE.pivot);else{var n=e.x,r=e.y;(t.x!==n||t.y!==r)&&(t.set(n,r),this._dispatchSpriteChange(oE.pivot))}}},{key:"border",get:function(){return this._border},set:function(e){var t=this._border,n=se.clamp(e.x,0,1),r=se.clamp(e.y,0,1);t.set(n,r,se.clamp(e.z,0,1-n),se.clamp(e.w,0,1-r)),this._dispatchSpriteChange(oE.border)}}]),rE);(rL=oU||(oU={}))[rL.positions=1]="positions",rL[rL.uvs=2]="uvs",rL[rL.all=3]="all";var u4=((rB=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 st),r.push(new sh);t.triangles=[]},rB.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=u4._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)},rB.updateUVs=function(e){},rB._worldMatrix=new su,rB);u4=sS([l5()],u4);var u5=(rD=e.Renderer,sx(rI=function(t){var n;return(n=rD.call(this,t)||this)._color=new s_(1,1,1,1),n._sprite=null,n._width=void 0,n._height=void 0,n._flipX=!1,n._flipY=!1,n._maskLayer=e.SpriteMaskLayer.Layer0,n._maskInteraction=e.SpriteMaskInteraction.None,n._renderData=new l6(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(sg(n)),n},rD),(rO=rI.prototype)._cloneTo=function(e){e.sprite=this._sprite},rO._onDestroy=function(){var e;null==(e=this._sprite)||e._updateFlagManager.removeListener(this._onSpriteChange),this._color=null,this._sprite=null,this._assembler=null,this._renderData=null,rD.prototype._onDestroy.call(this)},rO._updateBounds=function(e){var t;(null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},rO._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&oF.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~oF.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)}}},rO._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}},rO._onSpriteChange=function(t){switch(t){case oE.texture:this.shaderData.setTexture(rI._textureProperty,this.sprite.texture);break;case oE.size:(this._drawMode===e.SpriteDrawMode.Sliced||void 0===this._width||void 0===this._height)&&(this._dirtyUpdateFlag|=oF.WorldVolume);break;case oE.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case oE.region:case oE.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case oE.atlasRegion:this._dirtyUpdateFlag|=2;break;case oE.pivot:this._dirtyUpdateFlag|=oF.WorldVolume}},sv(rI,[{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=l8;break;case e.SpriteDrawMode.Sliced:this._assembler=u4}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._updateFlagManager.removeListener(this._onSpriteChange),e?(e._updateFlagManager.addListener(this._onSpriteChange),this._dirtyUpdateFlag|=3,this.shaderData.setTexture(rI._textureProperty,e.texture)):this.shaderData.setTexture(rI._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._width&&this._sprite&&(this.width=this._sprite.width),this._width},set:function(e){void 0===this._width&&this._sprite&&(this._width=this._sprite.width),this._width!==e&&(this._width=e,this._dirtyUpdateFlag|=oF.WorldVolume)}},{key:"height",get:function(){return void 0===this._height&&this._sprite&&(this.height=this._sprite.height),this._height},set:function(e){void 0===this._height&&this._sprite&&(this._height=this._sprite.height),this._height!==e&&(this._height=e,this._dirtyUpdateFlag|=oF.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=oF.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=oF.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())}}]),rI);u5._textureProperty=lz.getPropertyByName("u_spriteTexture"),sS([sb],u5.prototype,"_renderData",void 0),sS([sb],u5.prototype,"_drawMode",void 0),sS([sb],u5.prototype,"_assembler",void 0),sS([sF],u5.prototype,"_color",void 0),sS([sb],u5.prototype,"_sprite",void 0),sS([sb],u5.prototype,"_width",void 0),sS([sb],u5.prototype,"_height",void 0),sS([sA],u5.prototype,"_flipX",void 0),sS([sA],u5.prototype,"_flipY",void 0),sS([sA],u5.prototype,"_maskLayer",void 0),sS([sA],u5.prototype,"_maskInteraction",void 0),sS([sb],u5.prototype,"_onSpriteChange",null),(rV=oz||(oz={}))[rV.UV=2]="UV",rV[rV.All=3]="All";var u8=function e(){this.localPositions=new sd;var t=[new st,new st,new st,new st];this.renderData=new l6(4,t,null,e.triangles,null)};u8.triangles=[0,2,1,2,0,3];var u6=((rz=(rU=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},rz.put=function(e){this._elements.push(e)},rU),u7=((rN=function(){}).textContext=function(){var e=rN._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},rN._textContext=e}return e},rN.measureFont=function(e){var t=rN._fontSizeInfoCache,n=t[e];return n||(n=rN._measureFontOrChar(e),t[e]=n),n},rN.getNativeFontString=function(t,n,r){var i=r&e.FontStyle.Bold?"bold ":"";return r&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rN._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=n+"px "+t},rN.measureChar=function(e,t){return rN._measureFontOrChar(t,e)},rN.measureTextWithWrap=function(t){for(var n=t.fontSize,r=t.fontStyle,i=t._subFont,a=t.font.name,o=rN.getNativeFontString(a,n,r),s=rN.measureFont(o),l=t.text.split(/(?:\r\n|\r|\n)/),u=[],c=[],h=[],d=uR._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=rN._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}},rN.measureTextWithoutWrap=function(t){var n=t.fontSize,r=t.fontStyle,i=t._subFont,a=t.font.name,o=rN.getNativeFontString(a,n,r),s=rN.measureFont(o),l=t.text.split(/(?:\r\n|\r|\n)/),u=l.length,c=[],h=[],d=uR._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=rN._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}},rN.getNativeFontHash=function(t,n,r){var i=r&e.FontStyle.Bold?"bold":"";return r&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rN._genericFontFamilies.indexOf(t)||(t=""+t),i+=n+"px"+t},rN._measureFontOrChar=function(e,t){void 0===t&&(t="");var n,r=rN.textContext(),i=r.canvas,a=r.context;a.font=e;var o=t||rN._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(rN._measureBaseline).width),u=l*rN._heightMultiplier;l=rN._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 sh,new sh,new sh,new sh],ascent:f,descent:p,index:0,data:T}},rN._getCharInfo=function(e,t,n){var r=n._getCharInfo(e);return r||(r=rN.measureChar(e,t),n._uploadCharTexture(r),n._addCharInfo(e,r)),r},rN);u7._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],u7._measureString="|\xc9q\xc5",u7._measureBaseline="M",u7._heightMultiplier=2,u7._baselineMultiplier=1.4,u7._fontSizeInfoCache={},u7._textContext=null;var u9=(rk=e.Renderer,sx(rG=function(t){(n=rk.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new s_(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new sr,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=sg(n).engine;return n._font=r._textDefaultFont,n._font._addRefCount(1),n.setMaterial(r._spriteDefaultMaterial),n},rk),(rH=rG.prototype)._onDestroy=function(){for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)rG._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addRefCount(-1),this._font=null),this._subFont&&(this._subFont=null),rk.prototype._onDestroy.call(this)},rH._cloneTo=function(e){e.font=this._font,e._subFont=this._subFont},rH._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},rH._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},rH._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},rH._updateBounds=function(e){sr.transform(this._localBounds,this._entity.transform.worldMatrix,e)},rH._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)}},rH._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}},rH._resetSubFont=function(){this._subFont=this._font._getSubFont(this.fontSize,this.fontStyle)},rH._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=rG._tempVec31.set(a,o,s),d=rG._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];st.scale(d,g.z-v,T),st.add(x,T,T);var C=m[2];st.scale(h,g.w-y,C),st.add(x,C,m[3]),st.add(T,C,C)}},rH._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=uR._pixelsPerUnit,u=1/l,c=this._subFont,h=.5*(this.width*l),d=this.height*l,_=this.enableWrapping?u7.measureTextWithWrap(this):u7.measureTextWithoutWrap(this),f=_.height,p=_.lines,g=_.lineWidths,m=_.lineHeight,v=_.lineMaxSizes,y=rG._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})},rH._onTransformChanged=function(e){rk.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},sv(rG,[{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}}]),rG);u9._charRenderDataPool=new u6(u8,50),u9._tempVec30=new st,u9._tempVec31=new st,sS([sA],u9.prototype,"_subFont",void 0),sS([sb],u9.prototype,"_charRenderDatas",void 0),sS([sb],u9.prototype,"_dirtyFlag",void 0),sS([sF],u9.prototype,"_color",void 0),sS([sA],u9.prototype,"_text",void 0),sS([sA],u9.prototype,"_width",void 0),sS([sA],u9.prototype,"_height",void 0),sS([sb],u9.prototype,"_localBounds",void 0),sS([sA],u9.prototype,"_font",void 0),sS([sA],u9.prototype,"_fontSize",void 0),sS([sA],u9.prototype,"_fontStyle",void 0),sS([sA],u9.prototype,"_lineSpacing",void 0),sS([sA],u9.prototype,"_horizontalAlignment",void 0),sS([sA],u9.prototype,"_verticalAlignment",void 0),sS([sA],u9.prototype,"_enableWrapping",void 0),sS([sA],u9.prototype,"_overflowMode",void 0),sS([sA],u9.prototype,"_maskInteraction",void 0),sS([sA],u9.prototype,"_maskLayer",void 0),(rW=oN||(oN={}))[rW.SubFont=1]="SubFont",rW[rW.LocalPositionBounds=2]="LocalPositionBounds",rW[rW.WorldPosition=4]="WorldPosition",rW[rW.WorldBounds=8]="WorldBounds",rW[rW.MaskInteraction=16]="MaskInteraction",rW[rW.Position=14]="Position",rW[rW.Font=15]="Font";var ce=((rj=(rX=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},rX),ct=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:ce},e}();ct._assemblerMap=new Map;var cn=((rq=(rK=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},rq.getTargetValue=function(){return this._transform.position},rq.setTargetValue=function(e){this._transform.position=e},rK);ct.registerAssembler(ln,"position",cn);var cr=((rQ=(rY=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},rQ.getTargetValue=function(){return this._transform.rotationQuaternion},rQ.setTargetValue=function(e){this._transform.rotationQuaternion=e},rY);ct.registerAssembler(ln,"rotationQuaternion",cr);var ci=((rZ=(rJ=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},rZ.getTargetValue=function(){return this._transform.scale},rZ.setTargetValue=function(e){this._transform.scale=e},rJ);ct.registerAssembler(ln,"scale",ci);var ca=((r0=(r$=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(uf)},r0.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},r0.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},r$);ct.registerAssembler(uf,"blendShapeWeights",ca);var co=((r2=(r1=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new ct(e,this.type,this.property,t);return t._initializeOwner(n),n},r2._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},r1),cs=function(){},cl=((r4=(r3=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 cs;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})},r4.clearEvents=function(){this._events.length=0},r4.addCurveBinding=function(e,t,n,r){var i=new co;i.relativePath=e,i.type=t,i.property=n,i.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(i)},r4.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},r4._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)}},sv(r3,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),r3);e.InterpolationType=void 0,(r5=e.InterpolationType||(e.InterpolationType={}))[r5.Linear=0]="Linear",r5[r5.CubicSpine=1]="CubicSpine",r5[r5.Step=2]="Step",r5[r5.Hermite=3]="Hermite";var cu=((r6=(r8=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)}},r6.evaluate=function(e){return this._evaluate(e,this._evaluateData)},r6.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},r6._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},r6._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},sv(r8,[{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}}]),r8);e.AnimationArrayCurve=(sx(r7=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=[],e},cu),r7._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},r7._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},r7._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},r7._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},r7._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},r7._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},r7._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},(ok=r7)._isReferenceType=!0,ok._isInterpolationType=!0,ok),e.AnimationArrayCurve=sS([l5()],e.AnimationArrayCurve),e.AnimationBoolCurve=(sx(r9=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=!1,e},cu),r9._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},r9._lerpValue=function(e,t){return t},r9._subtractValue=function(e,t,n){return e},r9._getZeroValue=function(){return!1},r9._additiveValue=function(e,t,n){return e},r9._copyValue=function(e){return e},r9._hermiteInterpolationValue=function(e){return e.value},(oG=r9)._isReferenceType=!1,oG._isInterpolationType=!1,oG),e.AnimationBoolCurve=sS([l5()],e.AnimationBoolCurve),e.AnimationColorCurve=(sx(ie=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=new s_,e},cu),ie._initializeOwner=function(e){e.defaultValue=new s_,e.fixedPoseValue=new s_,e.baseEvaluateData.value=new s_,e.crossEvaluateData.value=new s_},ie._lerpValue=function(e,t,n,r){return s_.lerp(e,t,n,r),r},ie._subtractValue=function(e,t,n){return s_.subtract(e,t,n),n},ie._getZeroValue=function(e){return e.set(0,0,0,0),e},ie._additiveValue=function(e,t,n){return s_.scale(e,t,e),s_.add(n,e,n),n},ie._copyValue=function(e,t){return t.copyFrom(e),t},ie._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},(oH=ie)._isReferenceType=!0,oH._isInterpolationType=!0,oH),e.AnimationColorCurve=sS([l5()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(sx(it=function(){return cu.apply(this,arguments)},cu),it.prototype.addKey=function(e){cu.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)}},it._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)},it._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},it._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},it._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},it._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},it._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},it._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},(oW=it)._isReferenceType=!0,oW._isInterpolationType=!0,oW),e.AnimationFloatArrayCurve=sS([l5()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(sx(ir=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=0,e},cu),ir._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},ir._lerpValue=function(e,t,n){return e+(t-e)*n},ir._additiveValue=function(e,t,n){return n+e*t},ir._subtractValue=function(e,t){return e-t},ir._getZeroValue=function(){return 0},ir._copyValue=function(e){return e},ir._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},(oX=ir)._isReferenceType=!1,oX._isInterpolationType=!0,oX),e.AnimationFloatCurve=sS([l5()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(sx(ii=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=new sl,e},cu),ii._initializeOwner=function(e){e.defaultValue=new sl,e.fixedPoseValue=new sl,e.baseEvaluateData.value=new sl,e.crossEvaluateData.value=new sl},ii._lerpValue=function(e,t,n,r){return sl.slerp(e,t,n,r),r},ii._additiveValue=function(e,t,n){return e.x=e.x*t,e.y=e.y*t,e.z=e.z*t,e.normalize(),n.multiply(e),n},ii._subtractValue=function(t,n,r){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return sl.conjugate(n,i),sl.multiply(i,t,r),r},ii._getZeroValue=function(e){return e.set(0,0,0,1),e},ii._copyValue=function(e,t){return t.copyFrom(e),t},ii._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,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},(oj=ii)._isInterpolationType=!0,oj._isReferenceType=!0,oj._tempConjugateQuat=new sl,oj),e.AnimationQuaternionCurve=sS([l5()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(sx(ia=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=new sh,e},cu),ia._initializeOwner=function(e){e.defaultValue=new sh,e.fixedPoseValue=new sh,e.baseEvaluateData.value=new sh,e.crossEvaluateData.value=new sh},ia._lerpValue=function(e,t,n,r){return sh.lerp(e,t,n,r),r},ia._additiveValue=function(e,t,n){return sh.scale(e,t,e),sh.add(n,e,n),n},ia._subtractValue=function(e,t,n){return sh.subtract(e,t,n),n},ia._getZeroValue=function(e){return e.set(0,0),e},ia._copyValue=function(e,t){return t.copyFrom(e),t},ia._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},(oK=ia)._isReferenceType=!0,oK._isInterpolationType=!0,oK),e.AnimationVector2Curve=sS([l5()],e.AnimationVector2Curve),e.AnimationVector3Curve=(sx(io=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=new st,e},cu),io._initializeOwner=function(e){e.defaultValue=new st,e.fixedPoseValue=new st,e.baseEvaluateData.value=new st,e.crossEvaluateData.value=new st},io._lerpValue=function(e,t,n,r){return st.lerp(e,t,n,r),r},io._relativeBaseValue=function(e,t){return st.subtract(t,e,t),t},io._additiveValue=function(e,t,n){return st.scale(e,t,e),st.add(n,e,n),n},io._subtractValue=function(e,t,n){return st.subtract(e,t,n),n},io._getZeroValue=function(e){return e.set(0,0,0),e},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.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},(oq=io)._isReferenceType=!0,oq._isInterpolationType=!0,oq),e.AnimationVector3Curve=sS([l5()],e.AnimationVector3Curve),e.AnimationVector4Curve=(sx(is=function(){var e;return(e=cu.call(this)||this)._evaluateData.value=new sd,e},cu),is._initializeOwner=function(e){e.defaultValue=new sd,e.fixedPoseValue=new sd,e.baseEvaluateData.value=new sd,e.crossEvaluateData.value=new sd},is._lerpValue=function(e,t,n,r){return sd.lerp(e,t,n,r),r},is._additiveValue=function(e,t,n){return sd.scale(e,t,e),sd.add(n,e,n),n},is._subtractValue=function(e,t,n){return sd.subtract(e,t,n),n},is._getZeroValue=function(e){return e.set(0,0,0,0),e},is._copyValue=function(e,t){return t.copyFrom(e),t},is._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},(oY=is)._isReferenceType=!0,oY._isInterpolationType=!0,oY),e.AnimationVector4Curve=sS([l5()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(il=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[il.None=0]="None",il[il.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iu=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iu.Override=0]="Override",iu[iu.Additive=1]="Additive",(ic=oQ||(oQ={}))[ic.UnStarted=0]="UnStarted",ic[ic.Playing=1]="Playing",ic[ic.Finished=2]="Finished",(ih=oJ||(oJ={}))[ih.Standby=0]="Standby",ih[ih.Playing=1]="Playing",ih[ih.CrossFading=2]="CrossFading",ih[ih.FixedCrossFading=3]="FixedCrossFading";var cc=function(){this.handlers=[]},ch=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(id=e.WrapMode||(e.WrapMode={}))[id.Once=0]="Once",id[id.Loop=1]="Loop";var cd=((ip=(i_=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=oQ.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0},ip.update=function(t){var n=this.state,r=this.frameTime,i=n._getDuration();this.playState=oQ.Playing,n.wrapMode===e.WrapMode.Loop?r=i?r%i:0:Math.abs(r)>i&&(r=r<0?-i:i,this.playState=oQ.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=i),this.clipTime=r+n.clipStartTime*n.clip.length)},i_),c_=((ig=function(){this.animatorStateDataMap={},this.srcPlayData=new cd,this.destPlayData=new cd,this.layerState=oJ.Standby,this.crossCurveMark=0,this.manuallyTransition=new ch}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},ig),cf=function(){this.curveOwners=[],this.eventHandlers=[]},cp=(sx(im=function(t){var n;return(n=le.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._animatorLayersData=[],n._crossOwnerCollection=[],n._animationCurveOwners=[],n._animationEventHandlerPool=new l$(cc),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},le),(iv=im.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=oJ.Playing,o.srcPlayData.reset(a,s,a._getDuration()*n)}},iv.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)},iv.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!==oJ.Standby&&this._updateLayer(l,0===l,t/1e3,r)}},iv.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},iv.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iv._onEnable=function(){this.engine._componentsManager.addOnUpdateAnimations(this),this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iv._onDisable=function(){this.engine._componentsManager.removeOnUpdateAnimations(this)},iv._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)},iv._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},iv._saveDefaultValues=function(e){for(var t,n=e.curveOwners,r=n.length-1;r>=0;r--)null==(t=n[r])||t.saveDefaultValue()},iv._getAnimatorStateData=function(e,t,n){var r=n.animatorStateDataMap,i=r[e];return i||(i=new cf,r[e]=i,this._saveAnimatorStateData(t,i),this._saveAnimatorEventHandlers(t,i)),i},iv._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+".")}},iv._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)}},iv._clearCrossData=function(e){e.crossCurveMark++,this._crossOwnerCollection.length=0},iv._addCrossCurveData=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.push(t)},iv._prepareCrossFading=function(e){var t=this._crossOwnerCollection,n=e.crossCurveMark;this._prepareSrcCrossData(t,e.srcPlayData,n,!1),this._prepareDestCrossData(t,e.destPlayData,n,!1)},iv._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)},iv._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)},iv._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))}},iv._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)))}},iv._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new c_),t},iv._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!==oJ.FixedCrossFading&&this._checkTransition(u,h,t),l.layerState){case oJ.Playing:this._updatePlayingState(u,l,t,s,r,d,i);break;case oJ.FixedCrossFading:this._updateCrossFadeFromPose(c,l,t,s,r,d,i);break;case oJ.CrossFading:this._updateCrossFade(u,c,l,t,s,r,d,i)}},iv._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===oQ.Finished&&(t.layerState=oJ.Standby),h===oQ.UnStarted&&this._callAnimatorScriptOnEnter(c,n),p===oQ.Finished?this._callAnimatorScriptOnExit(c,n):this._callAnimatorScriptOnUpdate(c,n)}},iv._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===oQ.UnStarted&&this._callAnimatorScriptOnEnter(c,r),1===T||C===oQ.Finished?this._callAnimatorScriptOnExit(c,r):this._callAnimatorScriptOnUpdate(c,r),g===oQ.UnStarted&&this._callAnimatorScriptOnEnter(f,r),S===oQ.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)}}},iv._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===oQ.UnStarted&&this._callAnimatorScriptOnEnter(l,n),p===oQ.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)}}},iv._updateCrossFadeData=function(e,t,n,r){var i=e.destPlayData;i.frameTime+=i.state.speed*n,1===t?(i.playState===oQ.Finished?e.layerState=oJ.Standby:e.layerState=oJ.Playing,e.switchPlayData(),e.crossFadeTransition=null):r||(e.srcPlayData.frameTime+=e.srcPlayData.state.speed*n)},iv._preparePlay=function(e,t,n){if(e.layerState===oJ.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)}},iv._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)}},iv._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 oJ.Standby:a.layerState=oJ.FixedCrossFading,this._clearCrossData(a),this._prepareStandbyCrossFading(a);break;case oJ.Playing:a.layerState=oJ.CrossFading,this._clearCrossData(a),this._prepareCrossFading(a);break;case oJ.CrossFading:a.layerState=oJ.FixedCrossFading,this._prepareFixedPoseCrossFading(a);break;case oJ.FixedCrossFading:this._prepareFixedPoseCrossFading(a)}a.crossFadeTransition=e}},iv._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)},iv._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)}}},iv._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)}}},iv._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},iv._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},iv._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},iv._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)}},sv(im,[{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)}}]),im);sS([sA],cp.prototype,"speed",void 0),sS([sb],cp.prototype,"_controllerUpdateFlag",void 0),sS([sb],cp.prototype,"_animatorLayersData",void 0),sS([sb],cp.prototype,"_crossOwnerCollection",void 0),sS([sb],cp.prototype,"_animationCurveOwners",void 0),sS([sb],cp.prototype,"_animationEventHandlerPool",void 0),sS([sb],cp.prototype,"_tempAnimatorStateInfo",void 0),sS([sb],cp.prototype,"_controlledRenderers",void 0);var cg=((ix=(iy=function(){this._updateFlagManager=new lt,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},ix.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},ix.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},ix.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},ix._registerChangeFlag=function(){return this._updateFlagManager.createFlag(s9)},sv(iy,[{key:"layers",get:function(){return this._layers}}]),iy),cm=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},cv=((iC=(iT=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},iC.onStateUpdate=function(e,t,n){},iC.onStateExit=function(e,t,n){},iC.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iT),cy=((iw=(iS=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)},iw.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},iw.addStateMachineScript=function(e){var t=new e;t._state=this;var n=cv.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},iw.clearTransitions=function(){this._transitions.length=0},iw._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iw._removeStateMachineScript=function(e){var t=cv.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)}},sv(iS,[{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)}}]),iS),cx=((iA=(ib=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 cy(e),this.states.push(t),this._statesMap[e]=t),t},iA.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},iA.findStateByName=function(e){return this._statesMap[e]},iA.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},ib);e.AnimatorConditionMode=void 0,(iM=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[iM.If=0]="If",iM[iM.IfNot=1]="IfNot",iM[iM.Greater=2]="Greater",iM[iM.Less=3]="Less",iM[iM.Equals=4]="Equals",iM[iM.NotEquals=5]="NotEquals";var cT=function(){},cC=(sx(iF=function(t){var n;return(n=lZ.call(this,t,lz.find("skybox"))||this)._decodeParam=new sd(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},lZ),sv(iF,[{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)}}]),iF);(iP=oZ||(oZ={}))[iP.Position=1]="Position",iP[iP.Velocity=2]="Velocity",iP[iP.Acceleration=4]="Acceleration",iP[iP.Color=8]="Color",iP[iP.Alpha=16]="Alpha",iP[iP.Size=32]="Size",iP[iP.StartAngle=64]="StartAngle",iP[iP.StartTime=128]="StartTime",iP[iP.LifeTime=256]="LifeTime",iP[iP.RotateVelocity=512]="RotateVelocity",iP[iP.Scale=1024]="Scale",iP[iP.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(iE=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[iE.Transparent=0]="Transparent",iE[iE.Additive=1]="Additive";var cS=(sx(iR=function(e){var t;return(t=uu.call(this,e)||this)._maxCount=1e3,t._position=new st,t._positionRandomness=new st,t._velocity=new st,t._velocityRandomness=new st,t._acceleration=new st,t._accelerationRandomness=new st,t._color=new s_(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(sg(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},uu),(iL=iR.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)}},iL._onEnable=function(){uu.prototype._onEnable.call(this),this._playOnEnable&&this.start()},iL.start=function(){this._isStart=!0,this._time=0},iL.stop=function(){this._isStart=!1},iL._createMaterial=function(){var t=new lZ(this.engine,lz.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},iL._createMesh=function(){var t=new ug(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,i=new Float32Array(r),a=null,o=!1;if(n>iR._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 ue("a_position",0,e.VertexElementFormat.Vector3,0),new ue("a_velocity",12,e.VertexElementFormat.Vector3,0),new ue("a_acceleration",24,e.VertexElementFormat.Vector3,0),new ue("a_color",36,e.VertexElementFormat.Vector4,0),new ue("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new ue("a_rotation",68,e.VertexElementFormat.Vector2,0),new ue("a_uv",76,e.VertexElementFormat.Vector3,0),new ue("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new ut(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new ut(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},iL._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},iL._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,i=iR._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]=se.clamp(T.r+i()*C,0,1),n[o+10]=n[s+10]=n[l+10]=n[u+10]=se.clamp(T.g+i()*C,0,1),n[o+11]=n[s+11]=n[l+11]=n[u+11]=se.clamp(T.b+i()*C,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[u+12]=se.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)},iL._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},iL._onColorChanged=function(){this._updateDirtyFlag|=8},iR._getRandom=function(){return Math.random()-.5},sv(iR,[{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}}]),iR);cS._uint16VertexLimit=65535,sS([sb],cS.prototype,"_onColorChanged",null),lz.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 cw=(sx(iB=function(t){var n,r=(n=lZ.call(this,t,lz.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},lZ),iB),cb=new st,cA=(sx(iD=function(e,t){(n=uu.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 st),n._pointStates.push(n._lifetime),n._strapPoints.push(new st),n._strapPoints.push(new st);n._curPointNum=0;var i=t.material||new cw(n.engine);return n.setMaterial(i),n.setTexture(t.texture),n._initGeometry(),n},uu),(iI=iD.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];st.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++)},iI.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},iI._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),uu.prototype._render.call(this,e)},iI._initGeometry=function(){var t=new ug(this._entity.engine),n=2*this._maxPointNum,r=20*n,i=new Float32Array(r),a=[new ue("POSITION",0,e.VertexElementFormat.Vector3,0),new ue("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new ut(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},iI._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new st(n[0],n[4],n[8]),i=new st(n[1],n[5],n[9]),a=new st(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new st,l=new st,u=new sl;st.transformByQuat(r,u,r),st.transformByQuat(i,u,i);var c=new st,h=new st,d=new st;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?st.subtract(p,t[f-1],d):st.subtract(t[f+1],p,d),this._projectOnPlane(d,a,d),d.normalize();var g=Math.acos(st.dot(r,d));st.cross(r,d,h),0>=st.dot(h,a)&&(g=2*Math.PI-g),sl.rotationAxisAngle(a,g,u),st.transformByQuat(i,u,c),st.add(p,c,s),st.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}},iI._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}}},iI._projectOnVector=function(e,t,n){var r=t.clone();st.normalize(r,r);var i=st.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},iI._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,cb),st.subtract(e,cb,n)},iD),cM=(sx(iO=function(){var t;return t=uL.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},uL),(iV=iO.prototype).onTextureChange=function(e){},iV.onBeginRender=function(t){this.enabled&&(this._camera=t,this._oriCameraCullingMask=t.cullingMask,t.cullingMask=this.probeLayer,this._activeRenderTarget&&this._activeRenderTarget.width===this.width&&this._activeRenderTarget.height===this.height&&this._activeRenderTarget.antiAliasing===this.antiAliasing||(this._renderTarget=new sX(this.engine,this.width,this.height,this._isCube?new sq(this.engine,this.width):new sj(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new sX(this.engine,this.width,this.height,this._isCube?new sq(this.engine,this.width):new sj(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},iV.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},iV._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},sv(iO,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),iO),cF=new st,cP=new st,cE=new st,cR=(sx(iU=function(){var e;return e=cM.apply(this,arguments)||this,e.position=new st(0,0,0),e._isCube=!0,e.oriViewMatrix=new su,e},cM),(iz=iU.prototype).onBeginRender=function(t){if(this.enabled){cM.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),cM.prototype._reset.call(this)}},iz._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},iz._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},iz._setCamera=function(e,t){switch(e){case 0:cP.set(0,-1,0),cE.set(1,0,0);break;case 1:cP.set(0,-1,0),cE.set(-1,0,0);break;case 2:cP.set(0,0,1),cE.set(0,1,0);break;case 3:cP.set(0,0,-1),cE.set(0,-1,0);break;case 4:cP.set(0,-1,0),cE.set(0,0,1);break;case 5:cP.set(0,-1,0),cE.set(0,0,-1)}st.add(this.position,cE,cF),su.lookAt(this.position,cF,cP,t.viewMatrix),t.fieldOfView=90},iU),cL=Object.freeze({__proto__:null,AmbientLight:ub,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:cl,AnimationClipCurveBinding:co,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:cu,AnimationEvent:cs,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:cp,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:cg,AnimatorControllerLayer:cm,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:cy,AnimatorStateMachine:cx,AnimatorStateTransition:ch,AssetPromise:sZ,get AssetType(){return e.AssetType},Background:uw,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uQ,BasicRenderPipeline:uk,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:uv,BlendShapeFrame:um,BlinnPhongMaterial:uJ,BoolUpdateFlag:s9,BoxColliderShape:ld,Buffer:ut,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:ug,get BufferUsage(){return e.BufferUsage},BufferUtil:l9,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:lp,CharacterController:lc,CloneManager:sP,get Collider(){return e.Collider},ColliderShape:lh,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:le,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:cR,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DiffuseMode(){return e.DiffuseMode},DirectLight:lG,DynamicCollider:lS,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:uR,EngineObject:sE,Entity:lr,Event:sL,EventDispatcher:sB,FixedJoint:lm,get FogMode(){return e.FogMode},Font:sJ,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:lv,HitResult:ls,IndexBufferBinding:un,get IndexFormat(){return e.IndexFormat},InputManager:lF,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:lx,JointMotor:lT,Keyframe:cT,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:lk,Loader:uY,Logger:sz,Material:lZ,Mesh:ui,MeshRenderElement:l1,MeshRenderer:uu,get MeshTopology(){return e.MeshTopology},ModelMesh:us,ObjectValues:sH,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:uZ,PBRMaterial:u$,PBRSpecularMaterial:u0,ParticleRenderer:cS,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsManager:ll,PhysicsMaterial:lu,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PlaneColliderShape:lf,get Platform(){return e.Platform},PointLight:lH,Pointer:li,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:up,Probe:cM,RefObject:sR,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:uN,RenderQueue:uD,get RenderQueueType(){return e.RenderQueueType},RenderTarget:sX,get Renderer(){return e.Renderer},ResourceManager:s$,Scene:uA,SceneManager:uM,Script:uL,get SetDataOptions(){return e.SetDataOptions},Shader:lz,ShaderData:lN,ShaderFactory:lB,ShaderPass:lV,ShaderProperty:lU,get ShaderPropertyType(){return e.ShaderPropertyType},get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:ul,SkinnedMeshRenderer:uf,Sky:uS,SkyBoxMaterial:cC,SphereColliderShape:l_,SpotLight:lW,SpringJoint:ly,Sprite:u3,SpriteAtlas:u2,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteElement:l3,SpriteMask:l7,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:u5,StateMachineScript:cv,StaticCollider:lC,get StencilOperation(){return e.StencilOperation},SubMesh:ur,SystemInfo:la,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:u9,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:sW,Texture2D:sj,Texture2DArray:sK,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:sq,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:sN,TrailMaterial:cw,TrailRenderer:cA,Transform:ln,UnlitMaterial:u1,Util:sk,VertexBufferBinding:ua,VertexElement:ue,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:sA,deepClone:sF,dependentComponents:s7,ignoreClone:sb,request:uX,resourceLoader:s0,shallowClone:sM});function cB(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 cD=((ik=(iN=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:sz.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},ik.addCurrentLoad=function(e){this._currentLoad+=e},ik.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},ik.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},ik.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},cB(iN.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),iG&&cB(iN,iG),iN),cI='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',cO="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",cV=((iW=(iH=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)sz.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?uX(""+cO+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,cI].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([uX(""+cO+"draco_wasm_wrapper_gltf.js",{type:"text"}),uX(""+cO+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],i=[n,cI].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},iW.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var n=new cD(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]})},iW.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},iH);function cU(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 cz(e,t,n){return t&&cU(e.prototype,t),n&&cU(e,n),e}function cN(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(iX=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[iX.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",iX[iX.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",iX[iX.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",iX[iX.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",iX[iX.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",iX[iX.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",iX[iX.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",iX[iX.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",iX[iX.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",iX[iX.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",iX[iX.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",iX[iX.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",iX[iX.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",iX[iX.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",iX[iX.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",iX[iX.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",iX[iX.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",iX[iX.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",iX[iX.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",iX[iX.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",iX[iX.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",iX[iX.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",iX[iX.R11_EAC=37488]="R11_EAC",iX[iX.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",iX[iX.RG11_EAC=37490]="RG11_EAC",iX[iX.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",iX[iX.RGB8_ETC2=37492]="RGB8_ETC2",iX[iX.SRGB8_ETC2=37493]="SRGB8_ETC2",iX[iX.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",iX[iX.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",iX[iX.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",iX[iX.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",iX[iX.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",iX[iX.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",iX[iX.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",iX[iX.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",iX[iX.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",iX[iX.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",iX[iX.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",iX[iX.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT";var ck=((iK=(ij=function(e){this._scale=new sh;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&&cN(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},iK.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},cz(ij,[{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&&cN(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&&cN(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),ij);function cG(e,t){return(cG=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cH(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&&cG(e,t)}function cW(){return(cW=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 cX=((iY=(iq=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},iY.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)},iY._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)))},iY._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}},iY._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,cW({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"})},cz(iq,[{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}}]),iq),cj=((iQ=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]},iQ),cK=((iZ=(iJ=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 sz.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()},iZ.destroy=function(){this._useVao&&this._clearVAO()},iZ._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 sz.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},iZ._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},iZ._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)},iZ._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},iJ),cq=((i$=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]},i$),cY=((i1=(i0=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},i1.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},i1.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},i1._bind=function(){this._rhi.bindTexture(this)},i1._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)}},i1._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,sz.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)},i1._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||i0._isPowerOf2(s)&&i0._isPowerOf2(l)||(sz.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)}},i1._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},i0._isPowerOf2=function(e){return(e&e-1)==0},i0._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)}},i0._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)}},i0._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},i0._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},i0._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},cz(i0,[{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)}}}]),i0),cQ=((i3=(i2=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=cN(i,sW),l=0,u=r.length;l<u;l++){var c=r[l]._format;if(!cY._supportRenderBufferColorFormat(c,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[c]+" in RenderTarget")}if(!s&&!cY._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 cN(e,sq)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(sz.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=cN(a,sq);(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=cN(i,sq);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=cY._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()},i3.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)}},i3.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},i3._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},i3._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,cN(u,sq)||e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_2D,u._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(cN(r,sW)&&!cN(r,sq)){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=cY._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)},i3._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=cN(i,sW)?i._platformTexture._formatDetail:cY._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)},i3._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.")},i2),cJ=(cH(i4=function(t,n){(r=cY.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(!cY._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||cY._isPowerOf2(o)&&cY._isPowerOf2(s)||(sz.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=cY._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},cY),(i5=i4.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)},i5.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)},i5.getPixelBuffer=function(e,t,n,r,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");cY.prototype._getPixelBuffer.call(this,null,e,t,n,r,i,a)},i4),cZ=(cH(i8=function(t,n){r=cY.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(!cY._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return r._bind(),r._formatDetail=cY._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r},cY),(i6=i8.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)},i6.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)},i6.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)},i8),c$=(cH(i7=function(t,n){(r=cY.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(!cY._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||cY._isPowerOf2(o)||(sz.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=cY._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},cY),(i9=i7.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)},i9.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)},i9.getPixelBuffer=function(e,t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");cY.prototype._getPixelBuffer.call(this,e,t,n,r,i,a,o)},i7);e.WebGLMode=void 0,(ae=e.WebGLMode||(e.WebGLMode={}))[ae.Auto=0]="Auto",ae[ae.WebGL2=1]="WebGL2",ae[ae.WebGL1=2]="WebGL1";var c0=((an=(at=function(t){void 0===t&&(t={}),this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new sd(null,null,null,null),this._lastScissor=new sd(null,null,null,null),this._lastClearColor=new s_(null,null,null,null),this._scissorEnable=!1;var n=cW({webGLMode:0,alpha:!1,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(la.platform===e.Platform.IPhone||la.platform===e.Platform.IPad){var r=la.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&&cN(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&&cN(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 cj(this),this._capability=new cX(this),t.activeTexture(t.TEXTURE0);var a=t.getExtension("WEBGL_debug_renderer_info");null!=a&&(this._renderer=t.getParameter(a.UNMASKED_RENDERER_WEBGL))},an.createPlatformPrimitive=function(e){return new cK(this,e)},an.createPlatformTexture2D=function(e){return new cJ(this,e)},an.createPlatformTexture2DArray=function(e){return new cZ(this,e)},an.createPlatformTextureCube=function(e){return new c$(this,e)},an.createPlatformRenderTarget=function(e){return new cQ(this,e)},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,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)},an.drawPrimitive=function(e,t,n){e?e._draw(n,t):sz.error("draw primitive failed.")},an.activeRenderTarget=function(e,t,n){var r=this._gl;if(e){null==(i=e._platformRenderTarget)||i._activeRenderTarget();var i,a=e.width>>n,o=e.height>>n;this.viewport(0,0,a,o),this.scissor(0,0,a,o)}else{r.bindFramebuffer(r.FRAMEBUFFER,null);var s=r.drawingBufferWidth,l=r.drawingBufferHeight,u=s*t.z,c=l*t.w,h=t.x*s,d=l-t.y*l-c;this.viewport(h,d,u,c),this.scissor(h,d,u,c)}},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.destroy=function(){},cz(at,[{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}}]),at),c1=(cH(ar=function(e,t){var n=new ck("string"==typeof e?document.getElementById(e):e),r=new c0(t);return uR.call(this,n,r)},uR),cz(ar,[{key:"canvas",get:function(){return this._canvas}}]),ar);function c2(){return(c2=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 c3(e,t){return(c3=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c4(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&&c3(e,t)}function c5(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 c8(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 c6=(c4(ai=function(){return uY.apply(this,arguments)},uY),ai.prototype.load=function(e,t){var n=this;return new sZ(function(r,i){n.request(e.url,c2({},e,{type:"json"})).then(function(e){var n=new cg,i=e.layers,a=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,u=new cm(i);if(u.blendingMode=o,u.weight=s,l){var c=l.states,h=u.stateMachine=new cx;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 ch;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)})},ai);c6=c5([s0(e.AssetType.AnimatorController,["json"],!1)],c6);var c7=(c4(aa=function(){return uY.apply(this,arguments)},uY),aa.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new sZ(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,c2({},e,{type:"arraybuffer"}))},aa);c7=c5([s0(e.AssetType.Buffer,["bin","r3bin"],!1)],c7);var c9=(c4(ao=function(){return uY.apply(this,arguments)},uY),ao.prototype.load=function(t,n){var r=this;return new sZ(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 sq(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 ub,p=new sp;f.diffuseMode=e.DiffuseMode.SphericalHarmonics,p.copyFromArray(r),f.diffuseSphericalHarmonics=p,f.specularTexture=o,f.specularTextureDecodeRGBM=!0,i(f)}).catch(function(e){a(e)})})},ao);function he(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 ht(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){he(a,r,i,o,s,"next",e)}function s(e){he(a,r,i,o,s,"throw",e)}o(void 0)})}}c9=c5([s0(e.AssetType.Env,["env"])],c9);var hn=(c4(as=function(){return uY.apply(this,arguments)},uY),(al=as.prototype).load=function(e,t){var n=this;return new sZ(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 sJ(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new sJ(t.engine,a))}).catch(function(e){i(e)})})},al._registerFont=function(e,t){return ht(function(){var n;return c8(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]}})})()},as);hn=c5([s0(e.AssetType.Font,["font"],!1)],hn);var hr=((au=function(e){this.hasSkinned=!1,this.chainPromises=[],this.accessorBufferCache={},this.texturesPromiseInfo=new ha,this.materialsPromiseInfo=new ha,this.meshesPromiseInfo=new ha,this.animationClipsPromiseInfo=new ha,this.defaultSceneRootPromiseInfo=new ha,this.masterPromiseInfo=new ha,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 sZ(function(t,n,r,i){e.resolve=t,e.reject=n,e.setProgress=r,e.onCancel=i});return e.promise=t,t},au),hi=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},ha=function(){};(ac=o$||(o$={}))[ac.BYTE=5120]="BYTE",ac[ac.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",ac[ac.SHORT=5122]="SHORT",ac[ac.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",ac[ac.UNSIGNED_INT=5125]="UNSIGNED_INT",ac[ac.FLOAT=5126]="FLOAT",(ah=o0||(o0={})).SCALAR="SCALAR",ah.VEC2="VEC2",ah.VEC3="VEC3",ah.VEC4="VEC4",ah.MAT2="MAT2",ah.MAT3="MAT3",ah.MAT4="MAT4",(ad=o1||(o1={})).TRANSLATION="translation",ad.ROTATION="rotation",ad.SCALE="scale",ad.WEIGHTS="weights",(a_=o2||(o2={})).Linear="LINEAR",a_.Step="STEP",a_.CubicSpine="CUBICSPLINE",(af=o3||(o3={})).PERSPECTIVE="perspective",af.ORTHOGRAPHIC="orthographic",(ap=o4||(o4={})).JPEG="image/jpeg",ap.PNG="image/png",(ag=o5||(o5={})).OPAQUE="OPAQUE",ag.MASK="MASK",ag.BLEND="BLEND",(am=o8||(o8={}))[am.NEAREST=9728]="NEAREST",am[am.LINEAR=9729]="LINEAR",(av=o6||(o6={}))[av.NEAREST=9728]="NEAREST",av[av.LINEAR=9729]="LINEAR",av[av.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",av[av.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",av[av.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",av[av.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(ay=o7||(o7={}))[ay.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",ay[ay.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",ay[ay.REPEAT=10497]="REPEAT";var ho=((ax=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new sh(e[r],e[r+1]);return n},ax.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new st(e[r],e[r+1],e[r+2]);return n},ax.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new sd(e[r],e[r+1],e[r+2],e[r+3]);return n},ax.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 s_(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new s_(e[a],e[a+1],e[a+2],e[a+3]);return r},ax.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))},ax.getAccessorTypeSize=function(e){switch(e){case o0.SCALAR:return 1;case o0.VEC2:return 2;case o0.VEC3:return 3;case o0.VEC4:case o0.MAT2:return 4;case o0.MAT3:return 9;case o0.MAT4:return 16}},ax.getComponentType=function(e){switch(e){case o$.BYTE:return Int8Array;case o$.UNSIGNED_BYTE:return Uint8Array;case o$.SHORT:return Int16Array;case o$.UNSIGNED_SHORT:return Uint16Array;case o$.UNSIGNED_INT:return Uint32Array;case o$.FLOAT:return Float32Array}},ax.getNormalizedComponentScale=function(e){switch(e){case o$.BYTE:return 1/127;case o$.UNSIGNED_BYTE:return 1/255;case o$.SHORT:return 1/32767;case o$.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},ax.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=ax.getComponentType(o),d=ax.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 hi(x,!0,g)}}else{var T=new h(l,u+c,p*d);r=new hi(T,!1,f)}if(n.sparse){var C=ax.processingSparseData(t,n,i,r.data);r=new hi(C,!1,r.stride)}return r},ax.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=ax.getAccessorTypeSize(t.type),c=u*t.count,h=null!=(v=i.byteStride)?v:0,d=ax.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=ax.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},ax.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)},ax.processingSparseData=function(e,t,n,r){for(var i,a,o,s,l=e.bufferViews,u=ax.getAccessorTypeSize(t.type),c=ax.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=ax.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},ax.getIndexFormat=function(t){switch(t){case o$.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case o$.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case o$.UNSIGNED_INT:return e.IndexFormat.UInt32}},ax.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==o$.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==o$.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==o$.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==o$.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==o$.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},ax.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)})},ax.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},ax.parseRelativeUrl=function(e,t){return ax.isAbsoluteUrl(t)?t:e.substring(0,e.lastIndexOf("/")+1)+ax._formatRelativePath(t)},ax.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(ax.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}},ax._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},ax);function hs(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 hl(e,t){if(e){if("string"==typeof e)return hs(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 hs(e,t)}}function hu(e){return function(e){if(Array.isArray(e))return hs(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||hl(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 hc=((aT=function(){}).parseEngineResource=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];var s=aT._extensionParsers[e];if(null==s?void 0:s.length)for(var l,u=0;u<s.length;u++)(l=s[u]).parseEngineResource.apply(l,[t,n,r].concat(hu(a)))},aT.createEngineResource=function(e,t,n){for(var r,i=arguments.length,a=Array(i>3?i-3:0),o=3;o<i;o++)a[o-3]=arguments[o];var s=aT._extensionParsers[e];if(null==s?void 0:s.length)return(r=s[0]).createEngineResource.apply(r,[t,n].concat(hu(a)))},aT.hasExtensionParser=function(e){var t=aT._extensionParsers[e];return!!(null==t?void 0:t.length)},aT.initialize=function(e){var t=aT._extensionParsers[e];if(null==t?void 0:t.length)for(var n=0;n<t.length;n++)t[n].initialize()},aT._addExtensionParser=function(e,t){aT._extensionParsers[e]||(aT._extensionParsers[e]=[]),aT._extensionParsers[e].push(t)},aT);function hh(e){return function(t){var n=new t;hc._addExtensionParser(e,n)}}hc._extensionParsers={};var hd=((aS=(aC=function(){}).prototype).initialize=function(){},aS.parseEngineResource=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]},aS.createEngineResource=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return null},aC),h_=(c4(aw=function(){return hd.apply(this,arguments)},hd),(ab=aw.prototype).initialize=function(){h_._decoder||(h_._decoder=new cV)},ab.createEngineResource=function(e,t,n){var r=t.gltf,i=t.buffers,a=r.bufferViews,o=r.accessors,s=e.bufferView,l=e.attributes,u={},c={};for(var h in l)u[h]=l[h];for(var d in n.attributes)if(void 0!==l[d]){var _=o[n.attributes[d]];c[d]=ho.getComponentType(_.componentType).name}var f=o[n.indices],p=ho.getComponentType(f.componentType).name,g=ho.getBufferViewData(a[s],i);return h_._decoder.decode(g,{attributeIDs:u,attributeTypes:c,useUniqueIDs:!0,indexType:p}).then(function(e){return e})},aw);function hf(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}h_=c5([hh("KHR_draco_mesh_compression")],h_);var hp=(c4(aA=function(){return hd.apply(this,arguments)},hd),aA.prototype.parseEngineResource=function(e,t,n){var r,i=e.color,a=e.intensity,o=e.type,s=e.range,l=e.spot,u=n.glTFResource;if("directional"===o?r=t.addComponent(lG):"point"===o?r=t.addComponent(lH):"spot"===o&&(r=t.addComponent(lW)),i&&r.color.set(i[0],i[1],i[2],1),r.intensity=void 0===a?1:a,s&&!hf(r,lG)&&(r.distance=s),l&&hf(r,lW)){var c=l.innerConeAngle,h=void 0===c?0:c,d=l.outerConeAngle;r.angle=h,r.penumbra=(void 0===d?Math.PI/4:d)-h}u.lights||(u.lights=[]),u.lights.push(r)},aA);hp=c5([hh("KHR_lights_punctual")],hp);var hg=(c4(aM=function(){return hc.apply(this,arguments)},hc),aM.prototype.parse=function(t){var n=t.gltf,r=t.glTFResource,i=r.engine,a=r.textures;if(n.materials){for(var o=t.materialsPromiseInfo,s=[],l=0;l<n.materials.length;l++){var u,c,h=n.materials[l],d=h.extensions,_=void 0===d?{}:d,f=h.pbrMetallicRoughness,p=h.normalTexture,g=h.occlusionTexture,m=h.emissiveTexture,v=h.emissiveFactor,y=h.alphaMode,x=h.alphaCutoff,T=h.doubleSided,C=h.name,S=void 0===C?"":C,w=_.KHR_materials_unlit,b=_.KHR_materials_pbrSpecularGlossiness,A=_.KHR_materials_clearcoat,M=_.OASIS_materials_remap,F=null;if((F=w?hc.createEngineResource("KHR_materials_unlit",w,t):b?hc.createEngineResource("KHR_materials_pbrSpecularGlossiness",b,t):new u$(i)).name=S,A&&hc.parseEngineResource("KHR_materials_clearcoat",A,F,t),f){var P=f.baseColorFactor,E=f.baseColorTexture,R=f.metallicFactor,L=f.roughnessFactor,B=f.metallicRoughnessTexture;if(P&&(F.baseColor=new s_(s_.linearToGammaSpace(P[0]),s_.linearToGammaSpace(P[1]),s_.linearToGammaSpace(P[2]),P[3])),E&&(F.baseTexture=a[E.index],aM._parseTextureTransform(F,E.extensions,t)),!w&&!b){var D=F;D.metallic=null!=R?R:1,D.roughness=null!=L?L:1,B&&(D.roughnessMetallicTexture=a[B.index],aM._parseTextureTransform(F,B.extensions,t))}}if(!w){var I=F;if(m&&(I.emissiveTexture=a[m.index],aM._parseTextureTransform(F,m.extensions,t)),v&&(I.emissiveColor=new s_(s_.linearToGammaSpace(v[0]),s_.linearToGammaSpace(v[1]),s_.linearToGammaSpace(v[2]))),p){var O=p.index,V=p.scale;I.normalTexture=a[O],aM._parseTextureTransform(F,p.extensions,t),void 0!==V&&(I.normalTextureIntensity=V)}if(g){var U=g.index,z=g.strength,N=g.texCoord;I.occlusionTexture=a[U],aM._parseTextureTransform(F,g.extensions,t),void 0!==z&&(I.occlusionTextureIntensity=z),N===e.TextureCoordinate.UV1?I.occlusionTextureCoord=e.TextureCoordinate.UV1:N>e.TextureCoordinate.UV1&&sz.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(M&&(n.extensions=null!=(u=n.extensions)?u:{},n.extensions.OASIS_materials_remap=null!=(c=n.extensions.OASIS_materials_remap)?c:{},n.extensions.OASIS_materials_remap[l]=hc.createEngineResource("OASIS_materials_remap",M,t)),T?F.renderFace=e.RenderFace.Double:F.renderFace=e.RenderFace.Front,y){case o5.OPAQUE:F.isTransparent=!1;break;case o5.BLEND:F.isTransparent=!0;break;case o5.MASK:F.alphaCutoff=null!=x?x:.5}s[l]=F}return r.materials=s,o.resolve(s),o.promise}},aM._parseTextureTransform=function(e,t,n){void 0===t&&(t={});var r=t.KHR_texture_transform;r&&hc.parseEngineResource("KHR_texture_transform",r,e,n)},aM),hm=(c4(aF=function(){return hd.apply(this,arguments)},hd),aF.prototype.parseEngineResource=function(e,t,n){var r=n.glTFResource.textures,i=e.clearcoatFactor,a=e.clearcoatTexture,o=e.clearcoatRoughnessFactor,s=e.clearcoatRoughnessTexture,l=e.clearcoatNormalTexture;t.clearCoat=void 0===i?0:i,t.clearCoatRoughness=void 0===o?0:o,a&&(t.clearCoatTexture=r[a.index],hg._parseTextureTransform(t,a.extensions,n)),s&&(t.clearCoatRoughnessTexture=r[s.index],hg._parseTextureTransform(t,s.extensions,n)),l&&(t.clearCoatNormalTexture=r[l.index],hg._parseTextureTransform(t,l.extensions,n))},aF);hm=c5([hh("KHR_materials_clearcoat")],hm);var hv=(c4(aP=function(){return hd.apply(this,arguments)},hd),aP.prototype.createEngineResource=function(e,t){var n=t.glTFResource,r=n.engine,i=n.textures,a=new u0(r),o=e.diffuseFactor,s=e.diffuseTexture,l=e.specularFactor,u=e.glossinessFactor,c=e.specularGlossinessTexture;return o&&(a.baseColor=new s_(s_.linearToGammaSpace(o[0]),s_.linearToGammaSpace(o[1]),s_.linearToGammaSpace(o[2]),o[3])),s&&(a.baseTexture=i[s.index],hg._parseTextureTransform(a,s.extensions,t)),l&&(a.specularColor=new s_(s_.linearToGammaSpace(l[0]),s_.linearToGammaSpace(l[1]),s_.linearToGammaSpace(l[2]))),void 0!==u&&(a.glossiness=u),c&&(a.specularGlossinessTexture=i[c.index],hg._parseTextureTransform(a,c.extensions,t)),a},aP);hv=c5([hh("KHR_materials_pbrSpecularGlossiness")],hv);var hy=(c4(aE=function(){return hd.apply(this,arguments)},hd),aE.prototype.createEngineResource=function(e,t){var n=t.glTFResource.engine;return new u1(n)},aE);hy=c5([hh("KHR_materials_unlit")],hy);var hx=(c4(aR=function(){return hd.apply(this,arguments)},hd),aR.prototype.parseEngineResource=function(e,t,n){for(var r=n.gltf.extensions.KHR_materials_variants.variants,i=n.glTFResource,a=e.mappings,o=0;o<a.length;o++){var s=a[o],l=s.material,u=s.variants;i.variants||(i.variants=[]),i.variants.push({renderer:t,material:i.materials[l],variants:u.map(function(e){return r[e].name})})}},aR);hx=c5([hh("KHR_materials_variants")],hx);var hT=(c4(aL=function(){return hd.apply(this,arguments)},hd),aL);hT=c5([hh("KHR_mesh_quantization")],hT);var hC=(c4(aB=function(){return hd.apply(this,arguments)},hd),aB.prototype.parseEngineResource=function(e,t,n){var r=e.offset,i=e.rotation,a=e.scale,o=e.texCoord;r&&(t.tilingOffset.z=r[0],t.tilingOffset.w=r[1]),a&&(t.tilingOffset.x=a[0],t.tilingOffset.y=a[1]),i&&sz.warn("rotation in KHR_texture_transform is not supported now"),o&&sz.warn("texCoord in KHR_texture_transform is not supported now")},aB);hC=c5([hh("KHR_texture_transform")],hC);var hS=(c4(aD=function(){return hd.apply(this,arguments)},hd),aD.prototype.createEngineResource=function(e,t){return t.glTFResource.engine.resourceManager.getResourceByRef(e)},aD);function hw(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=hl(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.")}hS=c5([hh("OASIS_materials_remap")],hS);var hb=(c4(aI=function(){return hc.apply(this,arguments)},hc),(aO=aI.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 cl(g),v=[],y=0,x=f.length;y<x;y++){var T,C=f[y],S=o[C.input],w=o[C.output],b=ho.getAccessorBuffer(t,n,S).data,A=ho.getAccessorBuffer(t,n,w).data;if(w.normalized){for(var M=ho.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:o2.Linear,B=void 0;switch(L){case o2.CubicSpine:B=e.InterpolationType.CubicSpine;break;case o2.Step:B=e.InterpolationType.Step;break;case o2.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 o1.TRANSLATION:k=ln,G="position";break;case o1.ROTATION:k=ln,G="rotationQuaternion";break;case o1.SCALE:k=ln,G="scale";break;case o1.WEIGHTS:k=uf,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}},aO._addCurve=function(t,n,r){var i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case o1.TRANSLATION:case o1.SCALE:for(var l=new e.AnimationVector3Curve,u=l.interpolation=i.interpolation,c=0,h=0,d=a.length;h<d;h++){var _=new cT;_.time=a[h],u===e.InterpolationType.CubicSpine?(_.inTangent=new st(o[c++],o[c++],o[c++]),_.value=new st(o[c++],o[c++],o[c++]),_.outTangent=new st(o[c++],o[c++],o[c++])):_.value=new st(o[c++],o[c++],o[c++]),l.addKey(_)}return l;case o1.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 cT;y.time=a[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new sd(o[g++],o[g++],o[g++],o[g++]),y.value=new sl(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new sd(o[g++],o[g++],o[g++],o[g++])):y.value=new sl(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case o1.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 cT;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}},aI),hA=(c4(aV=function(){return hc.apply(this,arguments)},hc),(aU=aV.prototype).parse=function(e){var t=e.glTFResource.url;return this._isGLB(t)?uX(t,{type:"arraybuffer"}).then(ho.parseGLB).then(function(t){var n=t.gltf,r=t.buffers;e.gltf=n,e.buffers=r}):uX(t,{type:"json"}).then(function(n){return e.gltf=n,Promise.all(n.buffers.map(function(e){return uX(ho.parseRelativeUrl(t,e.uri),{type:"arraybuffer"})})).then(function(t){e.buffers=t})})},aU._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},aV),hM=(c4(az=function(){return hc.apply(this,arguments)},hc),(aN=az.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 lr(r,o.name||""+az._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)}},aN._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)}}},aN._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 lr(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]}},az);hM._defaultName="_GLTF_ENTITY_";var hF=(c4(ak=function(){return hc.apply(this,arguments)},hc),(aG=ak.prototype).parse=function(e){var t=this,n=e.gltf,r=e.buffers,i=e.glTFResource,a=i.engine;if(n.meshes){for(var o=e.meshesPromiseInfo,s=[],l=0;l<n.meshes.length;l++)!function(i){for(var o=function(i){var o=l.primitives[i],s=o.extensions,c=(void 0===s?{}:s).KHR_draco_mesh_compression;u[i]=new Promise(function(s){var u=new us(a,l.name||i+"");c?hc.createEngineResource("KHR_draco_mesh_compression",c,e,o).then(function(r){return t._parseMeshFromGLTFPrimitiveDraco(u,l,o,n,function(e){for(var t=0;t<r.attributes.length;t++)if(r.attributes[t].name===e)return r.attributes[t].array;return null},function(e,t){throw"BlendShape animation is not supported when using draco."},function(){return r.index.array},e.keepMeshData)}).then(s):t._parseMeshFromGLTFPrimitive(e,u,l,o,n,function(e){return null},function(e,t){var i=o.targets[t][e];if(!i)return null;var a=n.accessors[i];return ho.getAccessorData(n,a,r)},function(){var e=n.accessors[o.indices];return ho.getAccessorData(n,e,r)},e.keepMeshData).then(s)})},l=n.meshes[i],u=[],c=0;c<l.primitives.length;c++)o(c);s[i]=Promise.all(u)}(l);return sZ.all(s).then(function(e){i.meshes=e,o.resolve(e)}).catch(o.reject),o.promise}},aG._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=ho.getAccessorBuffer(t,a,S),b=ho.getAccessorTypeSize(S.type),A=S.count,M=w.data,F=void 0,P=n.instanceId,E=w.vertexBindingInfos,R=S.normalized,L=ho.getElementFormat(S.componentType,b,R),B=void 0;R&&(B=ho.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 ue(C,D,L,T);var V=w.vertexBuffer;V||((V=new ut(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 ue(C,D,L,E[P])}else{D=0,F=new ue(C,D,L,T);var U=new ut(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 st(M[X],M[X+1],M[X+2]);R&&j.scale(B),h[W]=j}}else{var K=ak._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),st.min(N,K,N),st.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 sd(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 sd(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&&this._createBlendShape(n,r,g,s),n.uploadData(!u),n._positions=h,n._boneIndices=d,n._boneWeights=_,Promise.resolve(n)},aG._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?ho.floatBufferToVector3Array(l):null,d=u?ho.floatBufferToVector3Array(u):null,_=c?ho.floatBufferToVector3Array(c):null,f=new uv(s);f.addFrame(1,h,d,_),e.addBlendShape(f)}},aG._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=ho.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=ak._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),st.min(y,v,y),st.max(x,v,x)}}for(var w in u)if("POSITION"!==w){var b=i(w);switch(w){case"NORMAL":var A=ho.floatBufferToVector3Array(b);e.setNormals(A);break;case"TEXCOORD_0":var M=ho.floatBufferToVector2Array(b);e.setUVs(M,0);break;case"TEXCOORD_1":var F=ho.floatBufferToVector2Array(b);e.setUVs(F,1);break;case"TEXCOORD_2":var P=ho.floatBufferToVector2Array(b);e.setUVs(P,2);break;case"TEXCOORD_3":var E=ho.floatBufferToVector2Array(b);e.setUVs(E,3);break;case"TEXCOORD_4":var R=ho.floatBufferToVector2Array(b);e.setUVs(R,4);break;case"TEXCOORD_5":var L=ho.floatBufferToVector2Array(b);e.setUVs(L,5);break;case"TEXCOORD_6":var B=ho.floatBufferToVector2Array(b);e.setUVs(B,6);break;case"TEXCOORD_7":var D=ho.floatBufferToVector2Array(b);e.setUVs(D,7);break;case"COLOR_0":var I=ho.floatBufferToColorArray(b,_[u.COLOR_0].type===o0.VEC3);e.setColors(I);break;case"TANGENT":var O=ho.floatBufferToVector4Array(b);e.setTangents(O);break;case"JOINTS_0":var V=ho.floatBufferToVector4Array(b);e.setBoneIndices(V);break;case"WEIGHTS_0":var U=ho.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&&this._createBlendShape(e,t,c,a),e.uploadData(!s),Promise.resolve(e)},ak);hF._tempVector3=new st;var hP=(c4(aH=function(){return hc.apply(this,arguments)},hc),(aW=aH.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=[],l=0;l<i.length;l++){var u=i[l],c=u.camera,h=u.mesh,d=u.extensions,_=(void 0===d?{}:d).KHR_lights_punctual,f=r[l];if(void 0!==c&&this._createCamera(t,a[c],f),void 0!==h&&s.push(this._createRenderer(e,u,f)),_){var p=_.light,g=n.extensions.KHR_lights_punctual.lights;hc.parseEngineResource("KHR_lights_punctual",g[p],f,e)}}return t.defaultSceneRoot&&this._createAnimator(e),n.extensions&&delete n.extensions.OASIS_materials_remap,sZ.all(s).then(function(){return o.resolve(t.defaultSceneRoot)}).catch(o.reject),o.promise}},aW._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===o3.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===o3.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},aW._createRenderer=function(e,t,n){for(var r=e.glTFResource,i=e.gltf,a=i.meshes,o=r.engine,s=r.meshes,l=r.materials,u=r.skins,c=t.mesh,h=t.skin,d=a[c],_=d.primitives,f=t.weights||d.weights,p=[],g=0;g<_.length;g++)!function(t){var r=s[c][t],a=void 0;if(void 0!==h||f){e.hasSkinned=!0;var d=n.addComponent(uf);d.mesh=r,void 0!==h&&(d.skin=u[h]),f&&(d.blendShapeWeights=new Float32Array(f)),a=d}else(a=n.addComponent(uu)).mesh=r;var g=_[t].material,m=i.extensions&&i.extensions.OASIS_materials_remap;if(m&&m[g])p.push(m[g].then(function(e){a.setMaterial(e)}));else{var v=(null==l?void 0:l[g])||aH._getDefaultMaterial(o);a.setMaterial(v),r.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(a.enableVertexColor=!0)})}var y=_[t].extensions,x=(void 0===y?{}:y).KHR_materials_variants;x&&hc.parseEngineResource("KHR_materials_variants",x,a,e)}(g);return Promise.all(p)},aW._createAnimator=function(e){if(e.hasSkinned||e.glTFResource.animations){var t=e.glTFResource,n=t.defaultSceneRoot,r=t.animations,i=n.addComponent(cp),a=new cg,o=new cm("layer"),s=new cx;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}}},aH._getDefaultMaterial=function(e){return aH._defaultMaterial||(aH._defaultMaterial=new uJ(e)),aH._defaultMaterial},aH),hE=(c4(aX=function(){return hc.apply(this,arguments)},hc),(aj=aX.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 ul(_);p.inverseBindMatrices.length=f;for(var g=n.accessors[u],m=ho.getAccessorBuffer(e,n,g).data,v=0;v<f;v++){var y=new su;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}},aj._findSkeletonRootBone=function(e,t){for(var n,r={},i=hw(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}},aX),hR=(c4(aK=function(){return hc.apply(this,arguments)},hc),(aq=aK.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 sZ.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:ho.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=ho.getBufferViewData(v,a);return ho.loadImageBuffer(y,f).then(function(e){var t=new sj(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}},aq._parseSampler=function(t,n){var r=n.magFilter,i=n.minFilter,a=n.wrapS,o=n.wrapT;(r||i)&&(r===o8.NEAREST?t.filterMode=e.TextureFilterMode.Point:i<=o6.LINEAR_MIPMAP_NEAREST?t.filterMode=e.TextureFilterMode.Bilinear:t.filterMode=e.TextureFilterMode.Trilinear),a&&(t.wrapModeU=aK._wrapMap[a]),o&&(t.wrapModeV=aK._wrapMap[o])},aK);hR._wrapMap=((aY={})[o7.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,aY[o7.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,aY[o7.REPEAT]=e.TextureWrapMode.Repeat,aY);var hL=(c4(aQ=function(){return hc.apply(this,arguments)},hc),aQ.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.";if(r){sz.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++)hc.hasExtensionParser(r[o])||sz.warn("Extension "+r[o]+" is not implemented, you can customize this extension in gltf.")}if(i){sz.info("extensionsRequired: "+i);for(var s=0;s<i.length;s++){var l=i[s];hc.hasExtensionParser(l)?hc.initialize(l):sz.error("GLTF parser has not supported required extension "+l+".")}}},aQ),hB=((aJ=function(e){var t=this;this._pipes=[],e.forEach(function(e,n){t._pipes[n]=new e})}).prototype.parse=function(e){var t,n=this,r=e.glTFResource;return new sZ(function(i,a){n._pipes.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)})},aJ);hB.defaultPipeline=new hB([hA,hL,hR,hg,hF,hM,hE,hb,hP]);var hD=(c4(aZ=function(e,t){var n;return(n=sE.call(this,e)||this).url=t,n},sE),aZ.prototype.destroy=function(){this._destroyed||(sE.prototype.destroy.call(this),this.defaultSceneRoot.destroy(),this.textures=null,this.materials=null,this.meshes=null,this.skins=null,this.animations=null,this.entities=null,this.cameras=null,this.lights=null,this.sceneRoots=null,this.variants=null)},aZ),hI=(c4(a$=function(){return uY.apply(this,arguments)},uY),a$.prototype.load=function(e,t){var n,r,i=e.url,a=new hr(i),o=new hD(t.engine,i),s=a.masterPromiseInfo;return a.glTFResource=o,a.keepMeshData=null!=(r=null==(n=e.params)?void 0:n.keepMeshData)&&r,s.onCancel(function(){for(var e,t=a.chainPromises,n=hw(t);!(e=n()).done;)e.value.cancel()}),hB.defaultPipeline.parse(a).then(s.resolve).catch(function(e){console.error(e),s.reject("Error loading glTF model from "+i+" .")}),a.promiseMap},a$);hI=c5([s0(e.AssetType.Prefab,["gltf","glb"])],hI);var hO=Math.PI,hV=(c4(a0=function(){return uY.apply(this,arguments)},uY),a0.prototype.load=function(t,n){var r=this;return new sZ(function(i,a){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=hV._parseHeader(n),a=r.width,s=r.height,l=r.dataPosition,u=hV._readPixels(n.subarray(l),a,s),c=s>>1,h=hV._convertToCubemap(u,a,s,c),d=new sq(o,c),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),i(d)}).catch(a)})},a0._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)]},a0._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},a0._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,-e.x),a=Math.acos(e.y);i<-hO;)i+=2*hO;for(;i>hO;)i-=2*hO;var o=i/hO,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/hO*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 s_(c,h,d,_)},a0._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},a0._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}},a0._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},a0._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},a0._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},(o9=a0)._rightBottomBack=new st(1,-1,-1),o9._rightBottomFront=new st(1,-1,1),o9._rightUpBack=new st(1,1,-1),o9._rightUpFront=new st(1,1,1),o9._leftBottomBack=new st(-1,-1,-1),o9._leftBottomFront=new st(-1,-1,1),o9._leftUpBack=new st(-1,1,-1),o9._leftUpFront=new st(-1,1,1),o9._faceRight=[o9._rightBottomBack,o9._rightBottomFront,o9._rightUpBack,o9._rightUpFront],o9._faceLeft=[o9._leftBottomFront,o9._leftBottomBack,o9._leftUpFront,o9._leftUpBack],o9._faceUp=[o9._leftBottomFront,o9._rightBottomFront,o9._leftBottomBack,o9._rightBottomBack],o9._faceBottom=[o9._leftUpBack,o9._rightUpBack,o9._leftUpFront,o9._rightUpFront],o9._faceFront=[o9._leftBottomBack,o9._rightBottomBack,o9._leftUpBack,o9._rightUpBack],o9._faceBack=[o9._rightBottomFront,o9._leftBottomFront,o9._rightUpFront,o9._leftUpFront],o9._tempVector3=new st,o9._temp2Vector3=new st,o9._temp3Vector3=new st,o9._temp4Vector3=new st,o9._temp5Vector3=new st,o9);hV=c5([s0(e.AssetType.HDR,["hdr"])],hV);var hU=(c4(a1=function(){return uY.apply(this,arguments)},uY),a1.prototype.load=function(e){return this.request(e.url,c2({},e,{type:"json"}))},a1);hU=c5([s0(e.AssetType.JSON,["json"],!1)],hU);var hz={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 hN(e){var t=hz.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var hk=(c4(a2=function(){return uY.apply(this,arguments)},uY),a2.prototype.load=function(t,n){var r=this;return new sZ(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,c2({},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=hz.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 sq(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)})})},a2);hk=c5([s0(e.AssetType.KTXCube,[])],hk);var hG=(c4(a3=function(){return uY.apply(this,arguments)},uY),a3.prototype.load=function(e,t){var n=this;return new sZ(function(r,i){n.request(e.url,c2({},e,{type:"arraybuffer"})).then(function(e){for(var n=hN(e),i=n.width,a=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,u=new sj(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)})})},a3);hG=c5([s0(e.AssetType.KTX,["ktx"])],hG);var hH=(c4(a4=function(){return uY.apply(this,arguments)},uY),a4.prototype.load=function(e,t){var n=this;return new sZ(function(r,i){n.request(e.url,c2({},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 sh(i.x,i.y));break;case"Vector3":d.setVector3(e,new st(i.x,i.y,i.z));break;case"Vector4":d.setVector4(e,new sd(i.x,i.y,i.z,i.w));break;case"Color":d.setColor(e,new s_(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 u$(a);break;case"pbr-specular":n=new u0(a);break;case"unlit":n=new u1(a);break;case"blinn-phong":n=new uJ(a);break;case"bake-pbr":n=new uZ(a,lz.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)})},a4);function hW(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 hX(e,t,n){return t&&hW(e.prototype,t),n&&hW(e,n),e}hH=c5([s0(e.AssetType.Material,["json"])],hH);var hj=((a8=(a5=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},a8.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},a8.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},a8.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},a8.nextInt32Array=function(e){var t=new Int32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a8.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},a8.nextFloat32Array=function(e){var t=new Float32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a8.nextUint32Array=function(e){var t=new Uint32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a8.nextUint8Array=function(e){var t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,t},a8.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},a8.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,ho.decodeText(t)},a8.nextImageData=function(e){return this.buffer.slice(this._offset)},a8.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},a8.skip=function(e){return this._offset+=e,this},a8.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)},hX(a5,[{key:"offset",get:function(){return this._offset}}]),a5);hj.imageMapping={0:"image/png",1:"image/jpg",2:"image/webp",3:"ktx"};var hK={};function hq(e){return function(t){hK[e]=t}}var hY=((a6=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=ho.decodeText(s),u=ho.decodeText(a),c=new a6;return c.totalLength=n,c.name=l,c.type=u,c.version=r,c.headerLength=s.byteLength+a.byteLength+9,c},hX(a6,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),a6);function hQ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sd(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function hJ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new st(e[3*r],e[3*r+1],e[3*r+2]);return n}function hZ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sh(e[2*r],e[2*r+1]);return n}function h$(e,t,n){return(h$=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&c3(i,n.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((a7=function(){}).decode=function(e,t){return new Promise(function(n){var r=new us(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=hJ(o,s);if(r.setPositions(l),i.normals){var u=hJ(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(hZ(c,s))}if(i.uv1){var h=new Float32Array(t.buffer,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);r.setUVs(hZ(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(hZ(d,s),2)}if(i.uv3){var _=new Float32Array(t.buffer,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);r.setUVs(hZ(_,s),3)}if(i.uv4){var f=new Float32Array(t.buffer,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);r.setUVs(hZ(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(hZ(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(hZ(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(hZ(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 s_(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 uv(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=hJ(r,i);e.deltaNormals&&hJ(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)})},a7),e.MeshDecoder=c5([hq("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((a9=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 sj(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)}})},a9),e.Texture2DDecoder=c5([hq("Texture2D")],e.Texture2DDecoder);var h0=((oe=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},oe.parseEntity=function(e,t){return oe.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})},oe.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 lr(t,e.name))},oe.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,i=h$(uY.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(i,e,t,n)},oe.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)},oe.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})},oe.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)})},oe._isClass=function(e){return void 0!=e.class},oe._isRef=function(e){return void 0!=e.refId},oe);h0.customParseComponentHandles=new Map;var h1=((ot=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)}},ot),h2={Transform:ln,Animator:cp,DirectLight:lG,Camera:e.Camera,MeshRenderer:uu,ParticleRenderer:cS,PointLight:lH,SpotLight:lW,Script:uL,SpriteMask:l7,SpriteRenderer:u5,TextRenderer:u9};e.InterpolableValueType=void 0,(on=e.InterpolableValueType||(e.InterpolableValueType={}))[on.Float=0]="Float",on[on.FloatArray=1]="FloatArray",on[on.Vector2=2]="Vector2",on[on.Vector3=3]="Vector3",on[on.Vector4=4]="Vector4",on[on.Quaternion=5]="Quaternion",on[on.Color=6]="Color",on[on.Array=7]="Array",on[on.Boolean=8]="Boolean",e.AnimationClipDecoder=((or=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),i=new cl(r),a=n.nextUint16(),o=0;o<a;++o){var s=new cs;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=h2[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 cT;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 cT;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 cT;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 cT;b.time=n.nextFloat32(),b.value=new sh(n.nextFloat32(),n.nextFloat32()),b.inTangent=new sh(n.nextFloat32(),n.nextFloat32()),b.outTangent=new sh(n.nextFloat32(),n.nextFloat32()),_.addKey(b)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var A=0;A<p;++A){var M=new cT;M.time=n.nextFloat32(),M.value=new st(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new st(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new st(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var F=new cT;F.time=n.nextFloat32(),F.value=new sd(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new sd(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new sd(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 cT;E.time=n.nextFloat32(),E.value=new s_(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),E.inTangent=new sd(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),E.outTangent=new sd(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 cT;L.time=n.nextFloat32(),L.value=new sl(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new sd(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new sd(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}i.addCurveBinding(c,h,d,_)}t(i)})},or),e.AnimationClipDecoder=c5([hq("AnimationClip")],e.AnimationClipDecoder);var h3=((oi=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},oi),h4=((oo=(oa=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)},oo._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),h0.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})},oo._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,i=t.scene,a=t.rootIds,o=hw(a);!(e=o()).done;){var s=e.value;h1.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])},oo._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(uY.getClass(u))),c=c||o.addComponent(uY.getClass(u));var h=h0.parsePropsAndMethods(c,l,o.engine);n.push(h)}return Promise.all(n)},oo._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oa.parse=function(e,t){var n=new uA(e),r=new h3(t,n),i=new oa(r);return i.start(),i.promise},oa);function h5(e,t){var n=hY.decode(e),r=new hj(e,n.headerLength,n.dataLength);return hK[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(c4(os=function(){return uY.apply(this,arguments)},uY),os.prototype.load=function(e,t){var n=this;return new sZ(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){h5(e,t.engine).then(function(e){r(e)})})})},os),e.MeshLoader=c5([s0("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(c4(ol=function(){return uY.apply(this,arguments)},uY),ol.prototype.load=function(e,t){var n=this;return new sZ(function(r){n.request(e.url,{type:"arraybuffer"}).then(function(e){h5(e,t.engine).then(function(e){r(e)})})})},ol),e.EditorTextureLoader=c5([s0("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var h8=(c4(ou=function(){return uY.apply(this,arguments)},uY),ou.prototype.load=function(e,t){var n=this;return new sZ(function(r,i){n.request(e.url,c2({},e,{type:"arraybuffer"})).then(function(e){return h5(e,t.engine)}).then(function(e){r(e)}).catch(i)})},ou);h8=c5([s0(e.AssetType.Mesh,["mesh"])],h8);var h6=(c4(oc=function(){return uY.apply(this,arguments)},uY),(oh=oc.prototype).load=function(e,t){var n=this;return new sZ(function(r,i){var a=e.url;n._registerFont(a,a).then(function(){r(new sJ(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},oh._registerFont=function(e,t){return ht(function(){var n;return c8(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]}})})()},oc);h6=c5([s0(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],h6);var h7=(c4(od=function(){var e;return e=uY.apply(this,arguments)||this,e._tempRect=new sf,e._tempVec2=new sh,e._tempVec4=new sd,e},uY),(o_=od.prototype).load=function(t,n){var r=this;return new sZ(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,c2({},t,{type:"json"}));l.push(u),u.then(function(t){var o=t.atlasItems,s=t.mipmap,u=t.anisoLevel,c=t.filterMode,h=t.wrapModeU,d=t.wrapModeV,_=t.format,f=o?o.length:0,p=n.engine,g=new u2(p);if(f<0){i(g);return}l.length=0;for(var m=0;m<o.length;m++)!function(t){var i=o[t];if(i.img)l.push(n.load({url:i.img,type:e.AssetType.Texture2D,params:{format:_,mipmap:s}}).then(function(e){u&&(e.anisoLevel=u),void 0!==c&&(e.filterMode=c),void 0!==h&&(e.wrapModeU=h),void 0!==d&&(e.wrapModeV=d);for(var t=0;t<i.sprites.length;t++)g._addSprite(r._makeSprite(p,i.sprites[t],e))}).catch(a));else for(var f=0;f<i.sprites.length;f++)g._addSprite(r._makeSprite(p,i.sprites[f]))}(m);sZ.all(l).then(function(){i(g)}).catch(a)}).catch(a)})},o_._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=new u3(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},od);h7=c5([s0(e.AssetType.SpriteAtlas,["atlas"],!1)],h7);var h9=(c4(of=function(){return uY.apply(this,arguments)},uY),of.prototype.load=function(e,t){var n=this;return new sZ(function(r,i){n.request(e.url,c2({},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 u3(t.engine,n,e.region,e.pivot,e.border))}).catch(i):r(new u3(t.engine,null,e.region,e.pivot,e.border))}).catch(i)})},of);h9=c5([s0(e.AssetType.Sprite,["sprite"],!1)],h9);var de=(c4(op=function(){return uY.apply(this,arguments)},uY),op.prototype.load=function(e,t){var n=this;return new sZ(function(r,i){n.request(e.url,c2({},e,{type:"image"})).then(function(n){var i,a=null!=(i=e.params)?i:{},o=new sj(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)})})},op);de=c5([s0(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],de);var dt=(c4(og=function(){return uY.apply(this,arguments)},uY),og.prototype.load=function(t,n){var r=this;return new sZ(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,c2({},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 sq(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)})})},og);dt=c5([s0(e.AssetType.TextureCube,[""])],dt);var dn=(c4(om=function(){return uY.apply(this,arguments)},uY),om.prototype.load=function(t,n){var r=this,i=n.engine;return new sZ(function(a,o){r.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),h4.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 cC(i);n.textureCubeMap=e.specularTexture,n.textureDecodeRGBM=!0,t.material=n,t.mesh=up.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;return 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)),Promise.all([s,u]).then(function(){a(r)})})}).catch(o)})},om);dn=c5([s0(e.AssetType.Scene,["prefab"],!0)],dn),h0.registerCustomParseComponent("TextRenderer",ht(function(e,t,n){var r;return c8(this,function(i){return(r=t.props).font||(e.font=sJ.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var dr="0.9.3";for(var di in console.log("Galacean engine version: "+dr),cL)uY.registerClass(di,cL[di]);e.AmbientLight=ub,e.AnimationClip=cl,e.AnimationClipCurveBinding=co,e.AnimationCurve=cu,e.AnimationEvent=cs,e.Animator=cp,e.AnimatorController=cg,e.AnimatorControllerLayer=cm,e.AnimatorState=cy,e.AnimatorStateMachine=cx,e.AnimatorStateTransition=ch,e.AssetPromise=sZ,e.Background=uw,e.BaseMaterial=uQ,e.BasicRenderPipeline=uk,e.BlendShape=uv,e.BlendShapeFrame=um,e.BlinnPhongMaterial=uJ,e.BoolUpdateFlag=s9,e.BoundingBox=sr,e.BoundingFrustum=so,e.BoundingSphere=sn,e.BoxColliderShape=ld,e.Buffer=ut,e.BufferMesh=ug,e.BufferUtil=l9,e.CapsuleColliderShape=lp,e.CharacterController=lc,e.CloneManager=sP,e.ColliderShape=lh,e.CollisionUtil=si,e.Color=s_,e.Component=le,e.ComponentMap=h2,e.CubeProbe=cR,e.DirectLight=lG,e.DynamicCollider=lS,e.Engine=uR,e.EngineObject=sE,e.Entity=lr,e.Event=sL,e.EventDispatcher=sB,e.FixedJoint=lm,e.Font=sJ,e.GLTFResource=hD,e.HingeJoint=lv,e.HitResult=ls,e.IndexBufferBinding=un,e.InputManager=lF,e.JointLimits=lx,e.JointMotor=lT,e.Keyframe=cT,e.Light=lk,e.Loader=uY,e.Logger=sz,e.Material=lZ,e.MathUtil=se,e.Matrix=su,e.Matrix3x3=ss,e.Mesh=ui,e.MeshRenderElement=l1,e.MeshRenderer=uu,e.ModelMesh=us,e.ObjectValues=sH,e.PBRBaseMaterial=uZ,e.PBRMaterial=u$,e.PBRSpecularMaterial=u0,e.ParticleRenderer=cS,e.PhysicsManager=ll,e.PhysicsMaterial=lu,e.Plane=sa,e.PlaneColliderShape=lf,e.PointLight=lH,e.Pointer=li,e.PrefabParser=h1,e.PrimitiveMesh=up,e.Probe=cM,e.Quaternion=sl,e.Ray=sc,e.Rect=sf,e.RefObject=sR,e.ReflectionParser=h0,e.RenderPass=uN,e.RenderQueue=uD,e.RenderTarget=sX,e.ResourceManager=s$,e.Scene=uA,e.SceneManager=uM,e.SceneParser=h4,e.Script=uL,e.Shader=lz,e.ShaderData=lN,e.ShaderFactory=lB,e.ShaderPass=lV,e.ShaderProperty=lU,e.Skin=ul,e.SkinnedMeshRenderer=uf,e.Sky=uS,e.SkyBoxMaterial=cC,e.SphereColliderShape=l_,e.SphericalHarmonics3=sp,e.SpotLight=lW,e.SpringJoint=ly,e.Sprite=u3,e.SpriteAtlas=u2,e.SpriteElement=l3,e.SpriteMask=l7,e.SpriteRenderer=u5,e.StateMachineScript=cv,e.StaticCollider=lC,e.SubMesh=ur,e.SystemInfo=la,e.TextRenderer=u9,e.Texture=sW,e.Texture2D=sj,e.Texture2DArray=sK,e.TextureCube=sq,e.Time=sN,e.TrailMaterial=cw,e.TrailRenderer=cA,e.Transform=ln,e.UnlitMaterial=u1,e.Util=sk,e.Vector2=sh,e.Vector3=st,e.Vector4=sd,e.VertexBufferBinding=ua,e.VertexElement=ue,e.WebCanvas=ck,e.WebGLEngine=c1,e.WebGLRenderer=c0,e.assignmentClone=sA,e.decode=h5,e.deepClone=sF,e.dependentComponents=s7,e.ignoreClone=sb,e.parseSingleKTX=hN,e.request=uX,e.resourceLoader=s0,e.shallowClone=sM,e.version=dr,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,(oy=e.ContainmentType||(e.ContainmentType={}))[oy.Disjoint=0]="Disjoint",oy[oy.Contains=1]="Contains",oy[oy.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(ox=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[ox.Back=0]="Back",ox[ox.Front=1]="Front",ox[ox.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(oT=e.FrustumFace||(e.FrustumFace={}))[oT.Near=0]="Near",oT[oT.Far=1]="Far",oT[oT.Left=2]="Left",oT[oT.Right=3]="Right",oT[oT.Bottom=4]="Bottom",oT[oT.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,N,z,k,G,H,W,X,K,j,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,eN,ez,ek,eG,eH,eW,eX,eK,ej,eq,eY,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e5,e8,e6,e7,e9,te,tt,tn,tr,ti,ta,to,ts,tl,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,tN,tz,tk,tG,tH,tW,tX,tK,tj,tq,tY,tQ,tJ,tZ,t$,t0,t1,t2,t3,t4,t5,t8,t6,t7,t9,ne,nt,nn,nr,ni,na,no,ns,nl,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,nN,nz,nk,nG,nH,nW,nX,nK,nj,nq,nY,nQ,nJ,nZ,n$,n0,n1,n2,n3,n4,n5,n8,n6,n7,n9,re,rt,rn,rr,ri,ra,ro,rs,rl,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,rN,rz,rk,rG,rH,rW,rX,rK,rj,rq,rY,rQ,rJ,rZ,r$,r0,r1,r2,r3,r4,r5,r8,r6,r7,r9,ie,it,ir,ii,ia,io,is,il,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,iN,iz,ik,iG,iH,iW,iX,iK,ij,iq,iY,iQ,iJ,iZ,i$,i0,i1,i2,i3,i4,i5,i8,i6,i7,i9,ae,at,an,ar,ai,aa,ao,as,al,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,aN,az,ak,aG,aH,aW,aX,aK,aj,aq,aY,aQ,aJ,aZ,a$,a0,a1,a2,a3,a4,a5,a8,a6,a7,a9,oe,ot,on,or,oi,oa,oo,os,ol,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,oN,oz,ok,oG,oH,oW,oX,oK,oj,oq,oY,oQ,oJ,oZ,o$,o0,o1,o2,o3,o4,o5,o8,o6,o7,o9,se,st=((oC=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},oC.equals=function(e,t){return Math.abs(e-t)<=oC.zeroTolerance},oC.isPowerOf2=function(e){return(e&e-1)==0},oC.radianToDegree=function(e){return e*oC.radToDegreeFactor},oC.degreeToRadian=function(e){return e*oC.degreeToRadFactor},oC);st.zeroTolerance=1e-6,st.radToDegreeFactor=180/Math.PI,st.degreeToRadFactor=Math.PI/180;var sn=((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 st.equals(e._x,t._x)&&st.equals(e._y,t._y)&&st.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>st.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);sn._zero=new sn(0,0,0),sn._one=new sn(1,1,1);var sr=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new sn,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)sn.add(e[i],r,r);sn.scale(r,1/n,t.center);for(var a=0,s=0;s<n;++s){var l=sn.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=sn.distance(n,i)},o);sr._tempVec30=new sn;var si=((u=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new sn,this.max=new sn,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return sn.add(this.min,this.max,e),sn.scale(e,.5,e),e},u.getExtent=function(e){return sn.subtract(this.max,this.min,e),sn.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 sn;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){sn.subtract(e,t,n.min),sn.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];sn.min(n,o,n),sn.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),sn.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]),sn.subtract(r,i,n.min),sn.add(r,i,n.max)},l.merge=function(e,t,n){return sn.min(e.min,t.min,n.min),sn.max(e.max,t.max,n.max),n},l);si._tempVec30=new sn,si._tempVec31=new sn;var sa=((c=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var i=e.normal,a=t.normal,o=n.normal;sn.cross(a,o,c._tempVec30),sn.cross(o,i,c._tempVec31),sn.cross(i,a,c._tempVec32);var s=-sn.dot(i,c._tempVec30),l=-sn.dot(a,c._tempVec31),u=-sn.dot(o,c._tempVec32);sn.scale(c._tempVec30,e.distance/s,c._tempVec30),sn.scale(c._tempVec31,t.distance/l,c._tempVec31),sn.scale(c._tempVec32,n.distance/u,c._tempVec32),sn.add(c._tempVec30,c._tempVec31,r),sn.add(r,c._tempVec32,r)},c.distancePlaneAndPoint=function(e,t){return sn.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=st.zeroTolerance,i=sn.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=sn.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=st.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;sn.subtract(n,i,o);var s=sn.dot(o,r),l=sn.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 sn.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))),sn.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),sn.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);sa._tempVec30=new sn,sa._tempVec31=new sn,sa._tempVec32=new sn;var so=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new sn,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();sn.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),ss=((f=(_=function(e){void 0===e&&(e=null),this.near=new so,this.far=new so,this.left=new so,this.right=new so,this.top=new so,this.bottom=new so,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 sa.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return sa.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},_),sl=((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 st.equals(n[0],r[0])&&st.equals(n[1],r[1])&&st.equals(n[2],r[2])&&st.equals(n[3],r[3])&&st.equals(n[4],r[4])&&st.equals(n[5],r[5])&&st.equals(n[6],r[6])&&st.equals(n[7],r[7])&&st.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),su=((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<st.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 st.equals(e._x,t._x)&&st.equals(e._y,t._y)&&st.equals(e._z,t._z)&&st.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;sn.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>st.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-st.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>st.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)<st.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);su._tempVector3=new sn,su._tempQuat1=new su;var sc=((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)<st.zeroTolerance||Math.abs(x)<st.zeroTolerance||Math.abs(T)<st.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,su.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>st.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 st.equals(n[0],r[0])&&st.equals(n[1],r[1])&&st.equals(n[2],r[2])&&st.equals(n[3],r[3])&&st.equals(n[4],r[4])&&st.equals(n[5],r[5])&&st.equals(n[6],r[6])&&st.equals(n[7],r[7])&&st.equals(n[8],r[8])&&st.equals(n[9],r[9])&&st.equals(n[10],r[10])&&st.equals(n[11],r[11])&&st.equals(n[12],r[12])&&st.equals(n[13],r[13])&&st.equals(n[14],r[14])&&st.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)<st.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;sn.subtract(e,t,s),s.normalize(),sn.cross(n,s,a),a.normalize(),sn.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]=-sn.dot(a,e),i[13]=-sn.dot(o,e),i[14]=-sn.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)<st.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);sc._tempVec30=new sn,sc._tempVec31=new sn,sc._tempVec32=new sn,sc._tempMat30=new sl,sc._identity=new sc(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var sh=((C=(T=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new sn,this.direction=new sn,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return sa.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return sa.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return sa.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return sn.scale(this.direction,e,t),t.add(this.origin)},T),sd=((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 st.equals(e._x,t._x)&&st.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>st.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);sd._zero=new sd(0,0),sd._one=new sd(1,1);var s_=((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 st.equals(e._x,t._x)&&st.equals(e._y,t._y)&&st.equals(e._z,t._z)&&st.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>st.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);s_._zero=new s_(0,0,0,0),s_._one=new s_(1,1,1,1);var sf=((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 st.equals(e._r,t._r)&&st.equals(e._g,t._g)&&st.equals(e._b,t._b)&&st.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),sp=((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),sg=((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 sm(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sv(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 sy(e,t,n){return t&&sv(e.prototype,t),n&&sv(e,n),e}function sx(e,t){return(sx=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sT(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&&sx(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 sC=((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);sC.zeroTolerance=1e-6,sC.radToDegreeFactor=180/Math.PI,sC.degreeToRadFactor=Math.PI/180;var sS=((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 sC.equals(e._r,t._r)&&sC.equals(e._g,t._g)&&sC.equals(e._b,t._b)&&sC.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},sy(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 sw(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 sb(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function sA(e,t){sE.registerCloneMode(e,t,oS.Ignore)}function sM(e,t){sE.registerCloneMode(e,t,oS.Assignment)}function sF(e,t){sE.registerCloneMode(e,t,oS.Shallow)}function sP(e,t){sE.registerCloneMode(e,t,oS.Deep)}(V=oS||(oS={}))[V.Ignore=0]="Ignore",V[V.Assignment=1]="Assignment",V[V.Shallow=2]="Shallow",V[V.Deep=3]="Deep";var sE=((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(sb(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);sE._subCloneModeMap=new Map,sE._cloneModeMap=new Map,sE._objectType=Object.getPrototypeOf(Object);var sR=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)},sy(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();sR._instanceIdCounter=0,sw([sA],sR.prototype,"instanceId",void 0),sw([sA],sR.prototype,"_engine",void 0);var sL=(sT(N=function(e){var t;return(t=sR.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addRefObject(t.instanceId,sm(t)),t},sR),(z=N.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&&(sR.prototype.destroy.call(this),t._deleteRefObject(this.instanceId));var n=this._getRefCount();return n>0&&this._addRefCount(-n),this._engine=null,this._onDestroy(),!0},z._getRefCount=function(){return this._refCount},z._addRefCount=function(e){this._refCount+=e},z._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},sy(N,[{key:"refCount",get:function(){return this._refCount}}]),N);e.RenderBufferDepthFormat=void 0,(k=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[k.Depth=0]="Depth",k[k.DepthStencil=1]="DepthStencil",k[k.Stencil=2]="Stencil",k[k.Depth16=3]="Depth16",k[k.Depth24=4]="Depth24",k[k.Depth32=5]="Depth32",k[k.Depth24Stencil8=6]="Depth24Stencil8",k[k.Depth32Stencil8=7]="Depth32Stencil8",e.TextureCubeFace=void 0,(G=e.TextureCubeFace||(e.TextureCubeFace={}))[G.PositiveX=0]="PositiveX",G[G.NegativeX=1]="NegativeX",G[G.PositiveY=2]="PositiveY",G[G.NegativeY=3]="NegativeY",G[G.PositiveZ=4]="PositiveZ",G[G.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(H=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[H.Never=0]="Never",H[H.Less=1]="Less",H[H.Equal=2]="Equal",H[H.LessEqual=3]="LessEqual",H[H.Greater=4]="Greater",H[H.NotEqual=5]="NotEqual",H[H.GreaterEqual=6]="GreaterEqual",H[H.Always=7]="Always",e.TextureFilterMode=void 0,(W=e.TextureFilterMode||(e.TextureFilterMode={}))[W.Point=0]="Point",W[W.Bilinear=1]="Bilinear",W[W.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(X=e.TextureFormat||(e.TextureFormat={}))[X.R8G8B8=0]="R8G8B8",X[X.R8G8B8A8=1]="R8G8B8A8",X[X.R4G4B4A4=2]="R4G4B4A4",X[X.R5G5B5A1=3]="R5G5B5A1",X[X.R5G6B5=4]="R5G6B5",X[X.Alpha8=5]="Alpha8",X[X.LuminanceAlpha=6]="LuminanceAlpha",X[X.R16G16B16A16=7]="R16G16B16A16",X[X.R32G32B32A32=8]="R32G32B32A32",X[X.DXT1=9]="DXT1",X[X.DXT5=10]="DXT5",X[X.ETC1_RGB=11]="ETC1_RGB",X[X.ETC2_RGB=12]="ETC2_RGB",X[X.ETC2_RGBA5=13]="ETC2_RGBA5",X[X.ETC2_RGBA8=14]="ETC2_RGBA8",X[X.PVRTC_RGB2=15]="PVRTC_RGB2",X[X.PVRTC_RGBA2=16]="PVRTC_RGBA2",X[X.PVRTC_RGB4=17]="PVRTC_RGB4",X[X.PVRTC_RGBA4=18]="PVRTC_RGBA4",X[X.ASTC_4x4=19]="ASTC_4x4",X[X.ASTC_5x5=20]="ASTC_5x5",X[X.ASTC_6x6=21]="ASTC_6x6",X[X.ASTC_8x8=22]="ASTC_8x8",X[X.ASTC_10x10=23]="ASTC_10x10",X[X.ASTC_12x12=24]="ASTC_12x12",X[X.Depth=25]="Depth",X[X.DepthStencil=26]="DepthStencil",X[X.Depth16=27]="Depth16",X[X.Depth24=28]="Depth24",X[X.Depth32=29]="Depth32",X[X.Depth24Stencil8=30]="Depth24Stencil8",X[X.Depth32Stencil8=31]="Depth32Stencil8",e.TextureWrapMode=void 0,(K=e.TextureWrapMode||(e.TextureWrapMode={}))[K.Clamp=0]="Clamp",K[K.Repeat=1]="Repeat",K[K.Mirror=2]="Mirror";var sB=((j=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},sy(j,[{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}}]),j),sD=((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),sI=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},sO=console.log.bind(console),sV=console.info.bind(console),sU=console.warn.bind(console),sN=console.error.bind(console),sz={debug:sI,info:sI,warn:sI,error:sI,isEnabled:!1,enable:function(){this.debug=sO,this.info=sV,this.warn=sU,this.error=sN,this.isEnabled=!0},disable:function(){this.debug=sI,this.info=sI,this.warn=sI,this.error=sI,this.isEnabled=!1}},sk=((J=(Q=function(){this._frameCount=0,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()},J.tick=function(){var e=this.nowTime;this._deltaTime=(e-this._lastTickTime)*this._timeScale,this._lastTickTime=e,this._frameCount++},sy(Q,[{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}}]),Q),sG={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(sG.isArrayLike(e)){t=e.slice();for(var t,n=0,r=e.length;n<r;n++)t[n]=sG.clone(e[n])}else for(var i in t={},e)e.hasOwnProperty(i)&&(t[i]=sG.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 sH(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 sW(e){return Object.keys(e).map(function(t){return e[t]})}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 sX=(sT(ee=function(){var e;return e=sL.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},sL),(et=ee.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},et._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},et._onDestroy=function(){this._platformTexture.destroy(),this._platformTexture=null},et._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},et._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},sy(ee,[{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&&(sz.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(sz.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)}}]),ee),sK=(sT(en=function(t,n,r,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=sR.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=a,i){for(var s,l=sb(i,Array)?i.slice():[i],u=0,c=l.length;u<c;u++)if(l[u]._isDepthTexture)throw"Render texture can't use depth format.";s._colorTextures=l}else s._colorTextures=[];if(sb(a,sX)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(sm(s)),s},sR),(er=en.prototype).getColorTexture=function(e){return void 0===e&&(e=0),this._colorTextures[e]},er.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()}},er.destroy=function(){this._platformRenderTarget.destroy(),this._colorTextures.length=0,this._depthTexture=null,this._depth=null},er._setRenderTargetInfo=function(e,t){this._platformRenderTarget.setRenderTargetInfo(e,t)},er._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},sy(en,[{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}}]),en),sj=(sT(ei=function(t,n,r,i,a){var o;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(o=sX.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(sm(o)),o.filterMode=e.TextureFilterMode.Bilinear,o.wrapModeU=o.wrapModeV=e.TextureWrapMode.Repeat,o},sX),(ea=ei.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)},ea.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)},ea.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)},ei),sq=(sT(eo=function(t,n,r,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=sX.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(sm(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},sX),(es=eo.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)},es.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)},es.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)},sy(eo,[{key:"length",get:function(){return this._length}}]),eo),sY=(sT(el=function(t,n,r,i){var a;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=sX.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(sm(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},sX),(eu=el.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)},eu.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)},eu.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)},el),sQ=(sT(ec=function(e){var t;return(t=sL.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},sL),(eh=ec.prototype)._onDestroy=function(){this._texture.destroy(),this._texture=null,this._charInfoMap={}},eh.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},eh.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},eh.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},sy(ec,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture=e}}]),ec),sJ=((e_=(ed=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},e_._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},e_._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},e_._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},e_._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},e_._getLastIndex=function(){return this._lastIndex},e_._createFontAtlas=function(){var e=this._engine,t=new sQ(e),n=new sj(e,256,256);return t.texture=n,this._fontAtlases.push(t),t},ed),sZ=(sT(ef=function(e,t){var n;return void 0===t&&(t=""),(n=sL.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},sL),(ep=ef.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new sJ(this.engine),r[n]=i),i},ep._onDestroy=function(){var e=this._subFontMap;for(var t in e)e[t].destroy();this._subFontMap=null,delete ef._fontMap[this._name]},ef.createFromOS=function(e,t){if(t){var n=ef._fontMap,r=n[t];return r||(r=new ef(e,t),n[t]=r),r}return null},sy(ef,[{key:"name",get:function(){return this._name}}]),ef);sZ._fontMap={};var s$=((em=(eg=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},em.then=function(e,t){var n=this;return new eg(function(r,i){n._promise.then(e,t).then(r).catch(i)})},em.catch=function(e){var t=this;return new eg(function(n,r){t._promise.catch(e).then(n).catch(r)})},em.finally=function(e){return this._promise.finally(e)},em.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},eg.all=function(e){return new eg(function(t,n,r){var i=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},a=function(e,t){sb(e,Promise)||sb(e,eg)?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)})},sy(eg,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),eg);(ev=ow||(ow={})).Pending="pending",ev.Fulfilled="fulfilled",ev.Rejected="rejected",ev.Canceled="canceled";var s0=((ex=(ey=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 s$.all(n)},ex.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},ex.getAssetPath=function(e){return this._assetPool[e]},ex.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()}):sW(this._loadingPromises).forEach(function(e){e.cancel()})},ex.gc=function(){this._gc(!1)},ex._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},ex._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},ex._addRefObject=function(e,t){this._refObjectPool[e]=t},ex._deleteRefObject=function(e){delete this._refObjectPool[e]},ex._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._refObjectPool=null},ex._assignDefaultOptions=function(e){var t,n,r,i,a;if(e.type=null!=(t=e.type)?t:ey._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},ex._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 s$(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 s$(function(e,n){d.then(function(n){e(t._getResolveResource(n,l))}).catch(function(e){n(e)})});var _=ey._loaders[n.type];if(!_)throw"loader not found: "+n.type;n.url=o;var f=_.load(n,this);if(sb(f,s$))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)})},ex._gc=function(e){for(var t=sW(this._refObjectPool),n=0,r=t.length;n<r;n++)(!t[n].isGCIgnored||e)&&t[n].destroy()},ex._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},ex._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},ex._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},ex._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===s2&&t.push(""),e.replace(s4,function(e,n,r,i){var a=e;r?a=i.replace(s3,"$1"):n&&(a=n.trim()),t.push(a)}),t},ex.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 sz.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})},ex.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},ey._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,i=n.length;r<i;r++)this._extTypeMapping[n[r]]=e},ey._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1)]},ey);function s1(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);s0._addLoader(e,i,t)}}s0._loaders={},s0._extTypeMapping={};var s2=46,s3=/\\(\\)?/g,s4=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),s5=((eC=(eT=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++},eC.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},eC.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},eC.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},eC.garbageCollection=function(){this._elements.length=this.length},eT),s8=((ew=(eS=function(){this._renderers=new s5,this._onStartScripts=new s5,this._onUpdateScripts=new s5,this._onLateUpdateScripts=new s5,this._onPhysicsUpdateScripts=new s5,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new s5,this._onUpdateRenderers=new s5,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},ew.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},ew.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},ew.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},ew.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},ew.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ew.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},ew.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},ew.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},ew.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},ew.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},ew.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ew.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},ew.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ew.addDisableScript=function(e){this._disableScripts.push(e)},ew.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},ew.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}},ew.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)}},ew.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)}},ew.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()}},ew.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n)t[n].update(e)},ew.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},ew.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}},ew.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)}},ew.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)}},ew.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},ew.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},eS),s6=((eb=function(){}).cloneComponent=function(e,t){for(var n=sE.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 oS.Assignment:t[o]=e[o];break;case oS.Shallow:var s=e[o];if(sb(s,Object)){var l=t[o];null==l&&(l=t[o]=s.constructor()),Object.assign(l,s)}else t[o]=s;break;case oS.Deep:var u=e[o];if(sb(u,Object)){var c=t[o];null==c&&(c=t[o]=u.constructor()),sE.deepCloneObject(u,c)}else t[o]=u}}e._cloneTo&&e._cloneTo(t)},eb),s7=((eA=function(){})._register=function(e,t){this._addDependency(e,t,this._dependenciesMap),this._addDependency(t,e,this._invDependenciesMap)},eA._addCheck=function(e,t){var n=eA._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)}},eA._removeCheck=function(e,t){var n=eA._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}},eA._addDependency=function(e,t,n){var r=n.get(e);r||(r=[],n.set(e,r)),-1===r.indexOf(t)&&r.push(t)},eA);function s9(){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 s7._register(e,t)})}}s7._dependenciesMap=new Map,s7._invDependenciesMap=new Map,e.Layer=void 0,(eM=e.Layer||(e.Layer={}))[eM.Layer0=1]="Layer0",eM[eM.Layer1=2]="Layer1",eM[eM.Layer2=4]="Layer2",eM[eM.Layer3=8]="Layer3",eM[eM.Layer4=16]="Layer4",eM[eM.Layer5=32]="Layer5",eM[eM.Layer6=64]="Layer6",eM[eM.Layer7=128]="Layer7",eM[eM.Layer8=256]="Layer8",eM[eM.Layer9=512]="Layer9",eM[eM.Layer10=1024]="Layer10",eM[eM.Layer11=2048]="Layer11",eM[eM.Layer12=4096]="Layer12",eM[eM.Layer13=8192]="Layer13",eM[eM.Layer14=16384]="Layer14",eM[eM.Layer15=32768]="Layer15",eM[eM.Layer16=65536]="Layer16",eM[eM.Layer17=131072]="Layer17",eM[eM.Layer18=262144]="Layer18",eM[eM.Layer19=524288]="Layer19",eM[eM.Layer20=1048576]="Layer20",eM[eM.Layer21=2097152]="Layer21",eM[eM.Layer22=4194304]="Layer22",eM[eM.Layer23=8388608]="Layer23",eM[eM.Layer24=16777216]="Layer24",eM[eM.Layer25=33554432]="Layer25",eM[eM.Layer26=67108864]="Layer26",eM[eM.Layer27=134217728]="Layer27",eM[eM.Layer28=268435456]="Layer28",eM[eM.Layer29=536870912]="Layer29",eM[eM.Layer30=1073741824]="Layer30",eM[eM.Layer31=2147483648]="Layer31",eM[eM.Everything=4294967295]="Everything",eM[eM.Nothing=0]="Nothing";var le=((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++)sH(e[t]._updateFlags,this)},sT(eE=function(){var e;return e=eF.apply(this,arguments)||this,e.flag=!0,e},eF),eE.prototype.dispatch=function(){this.flag=!0},eE),lt=(sT(eR=function(e){var t;return(t=sR.call(this,e.engine)||this)._awoken=!1,t._destroyed=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},sR),(eL=eR.prototype).destroy=function(){this._destroyed||(this._entity._removeComponent(this),this._entity.isActiveInHierarchy&&this._enabled&&this._onDisable(),this._destroyed=!0,this._onDestroy())},eL._onAwake=function(){},eL._onEnable=function(){},eL._onDisable=function(){},eL._onDestroy=function(){},eL._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())},sy(eR,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity.isActiveInHierarchy&&(e?(this._phasedActive=!0,this._onEnable()):(this._phasedActive=!1,this._onDisable())))}},{key:"destroyed",get:function(){return this._destroyed}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),eR);sw([sA],lt.prototype,"_entity",void 0),sw([sA],lt.prototype,"_awoken",void 0),sw([sA],lt.prototype,"_destroyed",void 0),sw([sA],lt.prototype,"_phasedActive",void 0),sw([sM],lt.prototype,"_enabled",void 0);var ln=((eD=(eB=function(){this._updateFlags=[],this._listensers=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eD.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eD.removeFlag=function(e){sH(this._updateFlags,e)&&sH(e._flagManagers,this)},eD.addListener=function(e){this._listensers.push(e)},eD.removeListener=function(e){sH(this._listensers,e)},eD.dispatch=function(e,t){for(var n=this._updateFlags,r=n.length-1;r>=0;r--)n[r].dispatch(e,t);for(var i=this._listensers,a=i.length-1;a>=0;a--)i[a](e,t)},eB),lr=(sT(eI=function(e){var t;return(t=lt.call(this,e)||this)._position=new sn,t._rotation=new sn,t._rotationQuaternion=new su,t._scale=new sn(1,1,1),t._worldPosition=new sn,t._worldRotation=new sn,t._worldRotationQuaternion=new su,t._lossyWorldScale=new sn(1,1,1),t._localMatrix=new sc,t._worldMatrix=new sc,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new ln,t._onPositionChanged=t._onPositionChanged.bind(sm(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(sm(t)),t._onRotationChanged=t._onRotationChanged.bind(sm(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(sm(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(sm(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(sm(t)),t._onScaleChanged=t._onScaleChanged.bind(sm(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},lt),(eO=eI.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},eO.setRotation=function(e,t,n){this._rotation.set(e,t,n)},eO.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},eO.setScale=function(e,t,n){this._scale.set(e,t,n)},eO.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},eO.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},eO.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},eO.getWorldForward=function(e){var t=this.worldMatrix.elements;return e.set(-t[8],-t[9],-t[10]),e.normalize()},eO.getWorldRight=function(e){var t=this.worldMatrix.elements;return e.set(t[0],t[1],t[2]),e.normalize()},eO.getWorldUp=function(e){var t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()},eO.translate=function(e,t,n,r){if("number"==typeof e){var i=eI._tempVec30;i.set(e,t,n),this._translate(i,r)}else this._translate(e,t)},eO.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},eO.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*st.degreeToRadFactor;su.rotationAxisAngle(e,r,eI._tempQuat0),this._rotateByQuat(eI._tempQuat0,n)},eO.lookAt=function(e,t){var n=eI._tempVec30;sn.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=st.zeroTolerance)){n.scale(1/r);var i=eI._tempVec31;if(t?sn.cross(t,n,i):i.set(n.z,0,-n.x),!((r=i.length())<=st.zeroTolerance)){i.scale(1/r);var a=eI._tempVec32;sn.cross(n,i,a);var o=eI._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)}}},eO.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(le)},eO._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eO._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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},eO._getScaleMatrix=function(){var e=eI._tempQuat0,t=eI._tempMat30,n=eI._tempMat31,r=eI._tempMat32;return n.copyFromMatrix(this.worldMatrix),su.invert(this.worldRotationQuaternion,e),sl.rotationQuaternion(e,t),sl.multiply(t,n,r),r},eO._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eO._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eO._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eO._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eO._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eO._rotateByQuat=function(e,t){t?su.multiply(this.rotationQuaternion,e,this._rotationQuaternion):su.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eO._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=eI._tempVec30;sn.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},eO._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var i=st.degreeToRadFactor,a=eI._tempQuat0;su.rotationEuler(e*i,t*i,n*i,a),this._rotateByQuat(a,r)},eO._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eO._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(sc.invert(t.worldMatrix,eI._tempMat41),sn.transformCoordinate(e,eI._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eO._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eO._onWorldRotationChanged=function(){var e=this._worldRotation;su.rotationEuler(st.degreeToRadian(e.x),st.degreeToRadian(e.y),st.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eO._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eO._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=eI._tempQuat0;su.invert(t.worldRotationQuaternion,n),su.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eO._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},sy(eI,[{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(st.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(st.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,su.rotationEuler(st.degreeToRadian(this._rotation.x),st.degreeToRadian(this._rotation.y),st.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):su.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?su.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):su.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)&&(sc.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?sc.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?(sc.invert(t.worldMatrix,eI._tempMat42),sc.multiply(eI._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}}]),eI);lr._tempQuat0=new su,lr._tempVec30=new sn,lr._tempVec31=new sn,lr._tempVec32=new sn,lr._tempMat30=new sl,lr._tempMat31=new sl,lr._tempMat32=new sl,lr._tempMat41=new sc,lr._tempMat42=new sc,sw([sP],lr.prototype,"_position",void 0),sw([sP],lr.prototype,"_rotation",void 0),sw([sP],lr.prototype,"_rotationQuaternion",void 0),sw([sP],lr.prototype,"_scale",void 0),sw([sP],lr.prototype,"_worldPosition",void 0),sw([sP],lr.prototype,"_worldRotation",void 0),sw([sP],lr.prototype,"_worldRotationQuaternion",void 0),sw([sP],lr.prototype,"_lossyWorldScale",void 0),sw([sP],lr.prototype,"_localMatrix",void 0),sw([sP],lr.prototype,"_worldMatrix",void 0),sw([sA],lr.prototype,"_isParentDirty",void 0),sw([sA],lr.prototype,"_parentTransformCache",void 0),sw([sA],lr.prototype,"_updateFlagManager",void 0),sw([sA],lr.prototype,"_onPositionChanged",null),sw([sA],lr.prototype,"_onWorldPositionChanged",null),sw([sA],lr.prototype,"_onRotationChanged",null),sw([sA],lr.prototype,"_onWorldRotationChanged",null),sw([sA],lr.prototype,"_onRotationQuaternionChanged",null),sw([sA],lr.prototype,"_onWorldRotationQuaternionChanged",null),sw([sA],lr.prototype,"_onScaleChanged",null),(eV=ob||(ob={}))[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 li=(sT(eU=function(t,n){var r;return(r=sR.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._components=[],r._scripts=new s5,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new sc,r.name=n,r.transform=r.addComponent(lr),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},sR),(eN=eU.prototype).addComponent=function(e){s7._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0),t},eN.getComponent=function(e){for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];if(sb(r,e))return r}},eN.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];sb(a,e)&&t.push(a)}return t},eN.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},eN.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)},eN.removeChild=function(e){e._setParent(null)},eN.getChild=function(e){return this._children[e]},eN.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},eN.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},eN.createChild=function(e){var t=new eU(this.engine,e);return t.layer=this.layer,t.parent=this,t},eN.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},eN.clone=function(){var e=new eU(this._engine,this.name);e._isActive=this._isActive,e.transform.localMatrix=this.transform.localMatrix;for(var t=this._children,n=0,r=this._children.length;n<r;n++){var i=t[n];e.addChild(i.clone())}for(var a=this._components,o=0,s=a.length;o<s;o++){var l=a[o];if(!sb(l,lr)){var u=e.addComponent(l.constructor);s6.cloneComponent(l,u)}}return e},eN.destroy=function(){if(!this._destroyed){sR.prototype.destroy.call(this);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var n=this._children;n.length>0;)n[0].destroy();this._isRoot?(this._scene._removeFromEntityList(this),this._isRoot=!1):this._removeFromParent()}},eN._removeComponent=function(e){s7._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},eN._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},eN._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},eN._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}},eN._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)},eN._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)},eN._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++}},eN._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()}},eN._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];sb(r,e)&&t.push(r)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},eN._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},eN._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)}},eN._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)}},eN._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},eN._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}}},eN.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(sc.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)},sy(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);e.ColorSpace=void 0,(ez=e.ColorSpace||(e.ColorSpace={}))[ez.Linear=0]="Linear",ez[ez.Gamma=1]="Gamma",e.PointerPhase=void 0,(ek=e.PointerPhase||(e.PointerPhase={}))[ek.Down=0]="Down",ek[ek.Move=1]="Move",ek[ek.Stationary=2]="Stationary",ek[ek.Up=3]="Up",ek[ek.Leave=4]="Leave";var la=((eH=(eG=function(t){this.phase=e.PointerPhase.Leave,this.position=new sd,this.deltaPosition=new sd,this._events=[],this._upMap=[],this._downMap=[],this._upList=new s5,this._downList=new s5,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}},eH._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},eH._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)}},eH._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}},eG),lo=((eW=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?eW.platform=e.Platform.IPhone:/iPad/i.test(n)?eW.platform=e.Platform.IPad:/Android/i.test(n)?eW.platform=e.Platform.Android:/Macintosh/i.test(n)&&(eW.platform=e.Platform.Mac),eW.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"}}},sy(eW,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),eW);lo.platform=e.Platform.Unknown,lo.operatingSystem="",lo._initialize(),e.Keys=void 0,(eX=e.Keys||(e.Keys={}))[eX.Backquote=0]="Backquote",eX[eX.Backslash=1]="Backslash",eX[eX.Backspace=2]="Backspace",eX[eX.BracketLeft=3]="BracketLeft",eX[eX.BracketRight=4]="BracketRight",eX[eX.Comma=5]="Comma",eX[eX.Digit0=6]="Digit0",eX[eX.Digit1=7]="Digit1",eX[eX.Digit2=8]="Digit2",eX[eX.Digit3=9]="Digit3",eX[eX.Digit4=10]="Digit4",eX[eX.Digit5=11]="Digit5",eX[eX.Digit6=12]="Digit6",eX[eX.Digit7=13]="Digit7",eX[eX.Digit8=14]="Digit8",eX[eX.Digit9=15]="Digit9",eX[eX.Equal=16]="Equal",eX[eX.IntlBackslash=17]="IntlBackslash",eX[eX.IntlRo=18]="IntlRo",eX[eX.IntlYen=19]="IntlYen",eX[eX.KeyA=20]="KeyA",eX[eX.KeyB=21]="KeyB",eX[eX.KeyC=22]="KeyC",eX[eX.KeyD=23]="KeyD",eX[eX.KeyE=24]="KeyE",eX[eX.KeyF=25]="KeyF",eX[eX.KeyG=26]="KeyG",eX[eX.KeyH=27]="KeyH",eX[eX.KeyI=28]="KeyI",eX[eX.KeyJ=29]="KeyJ",eX[eX.KeyK=30]="KeyK",eX[eX.KeyL=31]="KeyL",eX[eX.KeyM=32]="KeyM",eX[eX.KeyN=33]="KeyN",eX[eX.KeyO=34]="KeyO",eX[eX.KeyP=35]="KeyP",eX[eX.KeyQ=36]="KeyQ",eX[eX.KeyR=37]="KeyR",eX[eX.KeyS=38]="KeyS",eX[eX.KeyT=39]="KeyT",eX[eX.KeyU=40]="KeyU",eX[eX.KeyV=41]="KeyV",eX[eX.KeyW=42]="KeyW",eX[eX.KeyX=43]="KeyX",eX[eX.KeyY=44]="KeyY",eX[eX.KeyZ=45]="KeyZ",eX[eX.Minus=46]="Minus",eX[eX.Period=47]="Period",eX[eX.Quote=48]="Quote",eX[eX.Semicolon=49]="Semicolon",eX[eX.Slash=50]="Slash",eX[eX.AltLeft=51]="AltLeft",eX[eX.AltRight=52]="AltRight",eX[eX.CapsLock=53]="CapsLock",eX[eX.ContextMenu=54]="ContextMenu",eX[eX.ControlLeft=55]="ControlLeft",eX[eX.ControlRight=56]="ControlRight",eX[eX.Enter=57]="Enter",eX[eX.MetaLeft=58]="MetaLeft",eX[eX.MetaRight=59]="MetaRight",eX[eX.ShiftLeft=60]="ShiftLeft",eX[eX.ShiftRight=61]="ShiftRight",eX[eX.Space=62]="Space",eX[eX.Tab=63]="Tab",eX[eX.Convert=64]="Convert",eX[eX.KanaMode=65]="KanaMode",eX[eX.Lang1=66]="Lang1",eX[eX.Lang2=67]="Lang2",eX[eX.Lang3=68]="Lang3",eX[eX.Lang4=69]="Lang4",eX[eX.Lang5=70]="Lang5",eX[eX.NonConvert=71]="NonConvert",eX[eX.Delete=72]="Delete",eX[eX.End=73]="End",eX[eX.Help=74]="Help",eX[eX.Home=75]="Home",eX[eX.Insert=76]="Insert",eX[eX.PageDown=77]="PageDown",eX[eX.PageUp=78]="PageUp",eX[eX.ArrowDown=79]="ArrowDown",eX[eX.ArrowLeft=80]="ArrowLeft",eX[eX.ArrowRight=81]="ArrowRight",eX[eX.ArrowUp=82]="ArrowUp",eX[eX.NumLock=83]="NumLock",eX[eX.Numpad0=84]="Numpad0",eX[eX.Numpad1=85]="Numpad1",eX[eX.Numpad2=86]="Numpad2",eX[eX.Numpad3=87]="Numpad3",eX[eX.Numpad4=88]="Numpad4",eX[eX.Numpad5=89]="Numpad5",eX[eX.Numpad6=90]="Numpad6",eX[eX.Numpad7=91]="Numpad7",eX[eX.Numpad8=92]="Numpad8",eX[eX.Numpad9=93]="Numpad9",eX[eX.NumpadAdd=94]="NumpadAdd",eX[eX.NumpadBackspace=95]="NumpadBackspace",eX[eX.NumpadClear=96]="NumpadClear",eX[eX.NumpadClearEntry=97]="NumpadClearEntry",eX[eX.NumpadComma=98]="NumpadComma",eX[eX.NumpadDecimal=99]="NumpadDecimal",eX[eX.NumpadDivide=100]="NumpadDivide",eX[eX.NumpadEnter=101]="NumpadEnter",eX[eX.NumpadEqual=102]="NumpadEqual",eX[eX.NumpadHash=103]="NumpadHash",eX[eX.NumpadMemoryAdd=104]="NumpadMemoryAdd",eX[eX.NumpadMemoryClear=105]="NumpadMemoryClear",eX[eX.NumpadMemoryRecall=106]="NumpadMemoryRecall",eX[eX.NumpadMemoryStore=107]="NumpadMemoryStore",eX[eX.NumpadMemorySubtract=108]="NumpadMemorySubtract",eX[eX.NumpadMultiply=109]="NumpadMultiply",eX[eX.NumpadParenLeft=110]="NumpadParenLeft",eX[eX.NumpadParenRight=111]="NumpadParenRight",eX[eX.NumpadStar=112]="NumpadStar",eX[eX.NumpadSubtract=113]="NumpadSubtract",eX[eX.Escape=114]="Escape",eX[eX.F1=115]="F1",eX[eX.F2=116]="F2",eX[eX.F3=117]="F3",eX[eX.F4=118]="F4",eX[eX.F5=119]="F5",eX[eX.F6=120]="F6",eX[eX.F7=121]="F7",eX[eX.F8=122]="F8",eX[eX.F9=123]="F9",eX[eX.F10=124]="F10",eX[eX.F11=125]="F11",eX[eX.F12=126]="F12",eX[eX.F13=127]="F13",eX[eX.F14=128]="F14",eX[eX.F15=129]="F15",eX[eX.Fn=130]="Fn",eX[eX.FnLock=131]="FnLock",eX[eX.PrintScreen=132]="PrintScreen",eX[eX.ScrollLock=133]="ScrollLock",eX[eX.Pause=134]="Pause",eX[eX.BrowserBack=135]="BrowserBack",eX[eX.BrowserFavorites=136]="BrowserFavorites",eX[eX.BrowserForward=137]="BrowserForward",eX[eX.BrowserHome=138]="BrowserHome",eX[eX.BrowserRefresh=139]="BrowserRefresh",eX[eX.BrowserSearch=140]="BrowserSearch",eX[eX.BrowserStop=141]="BrowserStop",eX[eX.Eject=142]="Eject",eX[eX.LaunchApp1=143]="LaunchApp1",eX[eX.LaunchApp2=144]="LaunchApp2",eX[eX.LaunchMail=145]="LaunchMail",eX[eX.MediaPlayPause=146]="MediaPlayPause",eX[eX.MediaSelect=147]="MediaSelect",eX[eX.MediaStop=148]="MediaStop",eX[eX.MediaTrackNext=149]="MediaTrackNext",eX[eX.MediaTrackPrevious=150]="MediaTrackPrevious",eX[eX.Power=151]="Power",eX[eX.Sleep=152]="Sleep",eX[eX.AudioVolumeDown=153]="AudioVolumeDown",eX[eX.AudioVolumeMute=154]="AudioVolumeMute",eX[eX.AudioVolumeUp=155]="AudioVolumeUp",eX[eX.WakeUp=156]="WakeUp",eX[eX.Hyper=157]="Hyper",eX[eX.Super=158]="Super",eX[eX.Turbo=159]="Turbo",eX[eX.Abort=160]="Abort",eX[eX.Resume=161]="Resume",eX[eX.Suspend=162]="Suspend",eX[eX.Again=163]="Again",eX[eX.Copy=164]="Copy",eX[eX.Cut=165]="Cut",eX[eX.Find=166]="Find",eX[eX.Open=167]="Open",eX[eX.Paste=168]="Paste",eX[eX.Props=169]="Props",eX[eX.Select=170]="Select",eX[eX.Undo=171]="Undo",eX[eX.Hiragana=172]="Hiragana",eX[eX.Katakana=173]="Katakana",eX[eX.Unidentified=174]="Unidentified";var ls=((ej=(eK=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new s5,this._curFrameDownList=new s5,this._curFrameUpList=new s5,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,lo.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}},ej._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},ej._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)},ej._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},ej._onKeyEvent=function(e){this._nativeEvents.push(e)},eK);e.CameraClearFlags=void 0,(eq=e.CameraClearFlags||(e.CameraClearFlags={}))[eq.None=0]="None",eq[eq.Color=1]="Color",eq[eq.Depth=2]="Depth",eq[eq.Stencil=4]="Stencil",eq[eq.ColorDepth=3]="ColorDepth",eq[eq.ColorStencil=5]="ColorStencil",eq[eq.DepthStencil=6]="DepthStencil",eq[eq.All=7]="All";var ll=function(){this.entity=null,this.distance=0,this.point=new sn,this.normal=new sn},lu=((eQ=(eY=function(e){var t=this;this._initialized=!1,this._restTime=0,this._colliders=new s5,this._gravity=new sn(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||(eY._nativePhysics=e,this._nativePhysicsManager=eY._nativePhysics.createPhysicsManager(this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay),this._initialized=!0)},eQ.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)},eQ._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()},eQ._addColliderShape=function(e){this._physicalObjectsMap[e.id]=e,this._nativePhysicsManager.addColliderShape(e._nativeShape)},eQ._removeColliderShape=function(e){delete this._physicalObjectsMap[e.id],this._nativePhysicsManager.removeColliderShape(e._nativeShape)},eQ._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCollider(e._nativeCollider)},eQ._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCharacterController(e._nativeCollider)},eQ._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCollider(e._nativeCollider)},eQ._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCharacterController(e._nativeCollider)},eQ._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},eQ._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},eQ._setGravity=function(){this._nativePhysicsManager.setGravity(this._gravity)},sy(eY,[{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}}]),eY);e.PhysicsMaterialCombineMode=void 0,(eJ=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[eJ.Average=0]="Average",eJ[eJ.Minimum=1]="Minimum",eJ[eJ.Multiply=2]="Multiply",eJ[eJ.Maximum=3]="Maximum";var lc=((eZ=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=lu._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},sy(eZ,[{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))}}]),eZ);e.Collider=(sT(e$=function(e){var t;return(t=lt.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},lt),(e0=e$.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))},e0.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))},e0.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},e0._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}},e0._onLateUpdate=function(){},e0._onEnable=function(){this.engine.physicsManager._addCollider(this)},e0._onDisable=function(){this.engine.physicsManager._removeCollider(this)},e0._onDestroy=function(){this.clearShapes(),this._nativeCollider.destroy()},sy(e$,[{key:"shapes",get:function(){return this._shapes}}]),e$),sw([sA],e.Collider.prototype,"_index",void 0),e.Collider=sw([s9(lr)],e.Collider),e.ControllerNonWalkableMode=void 0,(e1=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[e1.PreventClimbing=0]="PreventClimbing",e1[e1.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var lh=(e2=e.Collider,sT(e3=function(t){var n;return(n=e2.call(this,t)||this)._index=-1,n._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new sn(0,1,0),n._slopeLimit=.707,n._nativeCollider=lu._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(sm(n)),n._upDirection._onValueChanged=n._setUpDirection,n},e2),(e4=e3.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},e4.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";e2.prototype.addShape.call(this,e),this._updateFlag.flag=!0},e4.clearShapes=function(){this._shapes.length>0&&e2.prototype.removeShape.call(this,this._shapes[0])},e4._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}},e4._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},e4._onEnable=function(){this.engine.physicsManager._addCharacterController(this)},e4._onDisable=function(){this.engine.physicsManager._removeCharacterController(this)},e4._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},sy(e3,[{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))}}]),e3),ld=function(){function e(){this._isTrigger=!1,this._rotation=new sn,this._position=new sn,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new lc,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)},sy(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}();ld._idGenerator=0;var l_=(sT(e5=function(){var e;return(e=ld.call(this)||this)._size=new sn(1,1,1),e._nativeShape=lu._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(sm(e)),e._size._onValueChanged=e._setSize,e},ld),e5.prototype._setSize=function(){this._nativeShape.setSize(this._size)},sy(e5,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),e5),lf=(sT(e8=function(){var e;return(e=ld.call(this)||this)._radius=1,e._nativeShape=lu._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},ld),sy(e8,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),e8),lp=(sT(e6=function(){var e;return(e=ld.call(this)||this)._nativeShape=lu._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},ld),e6);e.ColliderShapeUpAxis=void 0,(e7=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[e7.X=0]="X",e7[e7.Y=1]="Y",e7[e7.Z=2]="Z";var lg=(sT(e9=function(){var t;return(t=ld.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=lu._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},ld),sy(e9,[{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))}}]),e9);e.Joint=(sT(te=function(e){var t;return(t=lt.call(this,e)||this)._connectedCollider=new lm,t._collider=new lm,t._force=0,t._torque=0,t._connectedCollider.localPosition=new sn,t},lt),sy(te,[{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))}}]),te),e.Joint=sw([s9(e.Collider)],e.Joint);var lm=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},lv=(tt=e.Joint,sT(tn=function(){return tt.apply(this,arguments)},tt),tn.prototype._onAwake=function(){var t=this._collider;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=lu._nativePhysics.createFixedJoint(t.collider._nativeCollider)},tn);(tr=oA||(oA={}))[tr.LimitEnabled=1]="LimitEnabled",tr[tr.DriveEnabled=2]="DriveEnabled",tr[tr.DriveFreeSpin=4]="DriveFreeSpin";var ly=(ti=e.Joint,sT(ta=function(){var e;return e=ti.apply(this,arguments)||this,e._axis=new sn(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},ti),ta.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sn,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=lu._nativePhysics.createHingeJoint(t.collider._nativeCollider)},sy(ta,[{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&oA.LimitEnabled)==oA.LimitEnabled},set:function(e){e!==this.useLimits&&(this._hingeFlags|=oA.LimitEnabled),this._nativeJoint.setHingeJointFlag(oA.LimitEnabled,e)}},{key:"useMotor",get:function(){return(this._hingeFlags&oA.DriveEnabled)==oA.DriveEnabled},set:function(e){e!==this.useMotor&&(this._hingeFlags|=oA.DriveEnabled),this._nativeJoint.setHingeJointFlag(oA.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(oA.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))}}]),ta),lx=(to=e.Joint,sT(ts=function(){var e;return e=to.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},to),ts.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sn,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=lu._nativePhysics.createSpringJoint(t.collider._nativeCollider)},sy(ts,[{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))}}]),ts),lT=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},lC=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1};e.ControllerCollisionFlag=void 0,(tl=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[tl.Sides=1]="Sides",tl[tl.Up=2]="Up",tl[tl.Down=4]="Down";var lS=(tu=e.Collider,sT(tc=function(e){var t,n=(t=tu.call(this,e)||this).entity.transform;return t._nativeCollider=lu._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},tu),tc),lw=(th=e.Collider,sT(td=function(e){(t=th.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new sn,t._angularVelocity=new sn,t._mass=1,t._centerOfMass=new sn,t._inertiaTensor=new sn(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=lu._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(sm(t)),t._setAngularVelocity=t._setAngularVelocity.bind(sm(t)),t._setCenterOfMass=t._setCenterOfMass.bind(sm(t)),t._setInertiaTensor=t._setInertiaTensor.bind(sm(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},th),(t_=td.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},t_.applyTorque=function(e){this._nativeCollider.addTorque(e)},t_.move=function(e,t){this._nativeCollider.move(e,t)},t_.sleep=function(){this._nativeCollider.sleep()},t_.wakeUp=function(){this._nativeCollider.wakeUp()},t_._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},t_._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},t_._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},t_._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},t_._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},sy(td,[{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))}}]),td);e.CollisionDetectionMode=void 0,(tf=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[tf.Discrete=0]="Discrete",tf[tf.Continuous=1]="Continuous",tf[tf.ContinuousDynamic=2]="ContinuousDynamic",tf[tf.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(tp=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[tp.None=0]="None",tp[tp.FreezePositionX=1]="FreezePositionX",tp[tp.FreezePositionY=2]="FreezePositionY",tp[tp.FreezePositionZ=4]="FreezePositionZ",tp[tp.FreezeRotationX=8]="FreezeRotationX",tp[tp.FreezeRotationY=16]="FreezeRotationY",tp[tp.FreezeRotationZ=32]="FreezeRotationZ",e.PointerButton=void 0,(tg=e.PointerButton||(e.PointerButton={}))[tg.None=0]="None",tg[tg.Primary=1]="Primary",tg[tg.Secondary=2]="Secondary",tg[tg.Auxiliary=4]="Auxiliary",tg[tg.XButton1=8]="XButton1",tg[tg.XButton2=16]="XButton2",tg[tg.XButton3=32]="XButton3",tg[tg.XButton4=64]="XButton4",tg[tg.XButton5=128]="XButton5",tg[tg.XButton6=256]="XButton6",tg[tg.XButton7=512]="XButton7",tg[tg.XButton8=1024]="XButton8";var lb=[1,4,2,8,16,32,64,128,256,512,1024],lA={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},lM=((tv=(tm=function(t,n){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new s5,this._downList=new s5,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}},tv._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}},tv._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}},tv._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},tv._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},tv._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},tv._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 la(a)),o._uniqueID=e,t.splice(a,0,o),o},tv._pointerRayCast=function(t,n){for(var r=tm._tempPoint,i=tm._tempRay,a=tm._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}}}},tv._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=lb[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))},tv._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=lb[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},tm);lM._tempRay=new sh,lM._tempPoint=new sd,lM._tempHitResult=new ll;var lF=((tx=(ty=function(e){this._delta=new sn,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}},tx._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},tx._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},tx._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null},tx._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},ty),lP=((tC=(tT=function(e){this._initialized=!1,this._curFrameCount=0;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&sb(t,OffscreenCanvas)||(this._wheelManager=new lF(t),this._pointerManager=new lM(e,t),this._keyboardManager=new ls(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])},tC.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._curFrameCount)},tC.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._curFrameCount)},tC.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},tC.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[lA[e]]===this._curFrameCount)},tC.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[lA[e]]===this._curFrameCount)},tC._update=function(){this._initialized&&(++this._curFrameCount,this._wheelManager._update(),this._pointerManager._update(this._curFrameCount),this._keyboardManager._update(this._curFrameCount))},tC._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._pointerManager._destroy(),this._keyboardManager._destroy())},tC._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},tC._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},sy(tT,[{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}}]),tT);e.ShadowCascadesMode=void 0,(tS=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[tS.NoCascades=1]="NoCascades",tS[tS.TwoCascades=2]="TwoCascades",tS[tS.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(tw=e.ShadowResolution||(e.ShadowResolution={}))[tw.Low=0]="Low",tw[tw.Medium=1]="Medium",tw[tw.High=2]="High",tw[tw.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(tb=e.ShadowType||(e.ShadowType={}))[tb.None=0]="None",tb[tb.Hard=1]="Hard",tb[tb.SoftLow=2]="SoftLow",tb[tb.SoftHigh=3]="SoftHigh",e.RenderQueueType=void 0,(tA=e.RenderQueueType||(e.RenderQueueType={}))[tA.Opaque=0]="Opaque",tA[tA.AlphaTest=1]="AlphaTest",tA[tA.Transparent=2]="Transparent",e.BlendFactor=void 0,(tM=e.BlendFactor||(e.BlendFactor={}))[tM.Zero=0]="Zero",tM[tM.One=1]="One",tM[tM.SourceColor=2]="SourceColor",tM[tM.OneMinusSourceColor=3]="OneMinusSourceColor",tM[tM.DestinationColor=4]="DestinationColor",tM[tM.OneMinusDestinationColor=5]="OneMinusDestinationColor",tM[tM.SourceAlpha=6]="SourceAlpha",tM[tM.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",tM[tM.DestinationAlpha=8]="DestinationAlpha",tM[tM.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",tM[tM.SourceAlphaSaturate=10]="SourceAlphaSaturate",tM[tM.BlendColor=11]="BlendColor",tM[tM.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(tF=e.BlendOperation||(e.BlendOperation={}))[tF.Add=0]="Add",tF[tF.Subtract=1]="Subtract",tF[tF.ReverseSubtract=2]="ReverseSubtract",tF[tF.Min=3]="Min",tF[tF.Max=4]="Max",e.ColorWriteMask=void 0,(tP=e.ColorWriteMask||(e.ColorWriteMask={}))[tP.None=0]="None",tP[tP.Red=1]="Red",tP[tP.Green=2]="Green",tP[tP.Blue=4]="Blue",tP[tP.Alpha=8]="Alpha",tP[tP.All=15]="All",e.CompareFunction=void 0,(tE=e.CompareFunction||(e.CompareFunction={}))[tE.Never=0]="Never",tE[tE.Less=1]="Less",tE[tE.Equal=2]="Equal",tE[tE.LessEqual=3]="LessEqual",tE[tE.Greater=4]="Greater",tE[tE.NotEqual=5]="NotEqual",tE[tE.GreaterEqual=6]="GreaterEqual",tE[tE.Always=7]="Always",e.CullMode=void 0,(tR=e.CullMode||(e.CullMode={}))[tR.Off=0]="Off",tR[tR.Front=1]="Front",tR[tR.Back=2]="Back",e.ShaderPropertyType=void 0,(tL=e.ShaderPropertyType||(e.ShaderPropertyType={}))[tL.Float=0]="Float",tL[tL.Int=1]="Int",tL[tL.Vector2=2]="Vector2",tL[tL.Vector3=3]="Vector3",tL[tL.Vector4=4]="Vector4",tL[tL.Matrix=5]="Matrix",tL[tL.Color=6]="Color",tL[tL.Texture=7]="Texture",tL[tL.FloatArray=8]="FloatArray",tL[tL.IntArray=9]="IntArray",tL[tL.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(tB=e.StencilOperation||(e.StencilOperation={}))[tB.Keep=0]="Keep",tB[tB.Zero=1]="Zero",tB[tB.Replace=2]="Replace",tB[tB.IncrementSaturate=3]="IncrementSaturate",tB[tB.DecrementSaturate=4]="DecrementSaturate",tB[tB.Invert=5]="Invert",tB[tB.IncrementWrap=6]="IncrementWrap",tB[tB.DecrementWrap=7]="DecrementWrap";var lE=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};lE._macroNameIdMap=Object.create(null),lE._macroNameCounter=0;var lR=((tI=(tD=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},tI.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}},tI.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]},tI.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}},tI.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}},tI.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},tI.clear=function(){this._length=0},tD.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},tD);function lL(){return(lL=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 lB=lL({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();vec3 N=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv);\n#else\nvec3 N=getNormal();\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){geometry.position=v_pos;geometry.viewDir=normalize(u_cameraPos-v_pos);\n#if defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE)\nmat3 tbn=getTBN();\n#endif\n#ifdef NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv);\n#else\ngeometry.normal=getNormal();\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);\n#else\ngeometry.clearCoatNormal=getNormal();\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);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(){\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(gl_FrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(gl_FrontFacing)*2.0-1.0;return normal;}mat3 getTBN(){\n#if defined(O3_HAS_NORMAL) && defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal();vec3 position=v_pos;vec2 uv=gl_FrontFacing? 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;}"}),lD=((tO=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},tO.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=lB[t];return void 0===n?(sz.error('Shader slice "'+e.trim()+'" not founded.'),""):tO.parseIncludes(n)})},tO.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},tO.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},tO._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)},tO);(tV=oM||(oM={}))[tV.Scene=0]="Scene",tV[tV.Camera=1]="Camera",tV[tV.Renderer=2]="Renderer",tV[tV.Material=3]="Material";var lI=((tN=(tU=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)},tN.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},tN.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,sf.gammaToLinearSpace(n.r),sf.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)},tN.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},tN.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,sf.gammaToLinearSpace(n.r),sf.gammaToLinearSpace(n.g),sf.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)},tN.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},tN.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,sf.gammaToLinearSpace(n.r),sf.gammaToLinearSpace(n.g),sf.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)},tN.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},tN.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},tN.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},tN.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)},tN.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},tN.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)},tN.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},tN.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)},tN.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},tN.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},tN.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},tN.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseComporeMode)},tN.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)}},tU),lO=function(){this.constUniforms=[],this.textureUniforms=[]},lV=function(){function e(t,n,r){this.sceneUniformBlock=new lO,this.cameraUniformBlock=new lO,this.rendererUniformBlock=new lO,this.materialUniformBlock=new lO,this.otherUniformBlock=new lO,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=lz._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 oM.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case oM.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case oM.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case oM.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())?(sz.error("Context lost while linking program."),n.deleteShader(r),n.deleteShader(i),null):sz.isEnabled&&!n.getProgramParameter(a,n.LINK_STATUS)?(sz.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):sz.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 lI(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=lz.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 sd(0,0));break;case t.FLOAT_VEC3:u?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new sn(0,0,0));break;case t.FLOAT_VEC4:u?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new s_(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 sd(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=u?l.upload3iv:l.upload3i,l.cacheValue=new sn(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:u?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new s_(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=lz._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")},sy(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();lV._counter=0;var lU=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=[];lz._getNamesByMacros(n,o);var s=lD.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=lD.parseIncludes(" "+l+"\n "+u+"\n "+s+"\n "+this._vertexSource),d=lD.parseIncludes(" "+l+"\n "+u+"\n "+(a?"":lD.parseExtension(lz._shaderExtension))+"\n "+c+"\n "+s+"\n "+this._fragmentSource);return a&&(h=lD.convertTo300(h),d=lD.convertTo300(d,!0)),i=new lV(t,h,d),r.cache(i),i},t}();lU._shaderPassCounter=0;var lN=function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return sy(e,[{key:"type",get:function(){return this._type}}]),e}();lN._propertyNameCounter=0;var lz=((tz=function(e,t,n){if(this._passes=[],this.name=e,"string"==typeof t)this._passes.push(new lU(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=tz._compileMacros;n.clear();for(var r=0,i=t.length;r<i;r++)n.enable(tz.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},tz.create=function(e,t,n){var r=tz._shaderMap;if(r[e])throw'Shader named "'+e+'" already exists.';return r[e]=new tz(e,t,n)},tz.find=function(e){return tz._shaderMap[e]},tz.getMacroByName=function(e,t){var n=t?e+" "+t:e,r=tz._macroMap[n];if(!r){var i=tz._macroMaskMap,a=tz._macroCounter,o=Math.floor(a/32),s=a%32;r=new lE(e,t,o,1<<s),tz._macroMap[n]=r,o==i.length&&(i.length++,i[o]=Array(32)),i[o][s]=n,tz._macroCounter++}return r},tz.getPropertyByName=function(e){var t=tz._propertyNameMap;if(null!=t[e])return t[e];var n=new lN(e);return t[e]=n,tz._propertyIdMap[n._uniqueId]=n,n},tz._getShaderPropertyGroup=function(e){var t=tz._propertyNameMap[e];return null==t?void 0:t._group},tz._getNamesByMacros=function(e,t){var n=tz._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])},sy(tz,[{key:"passes",get:function(){return this._passes}}]),tz);lz._compileMacros=new lR,lz._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],lz._propertyIdMap=Object.create(null),lz._shaderMap=Object.create(null),lz._propertyNameMap=Object.create(null),lz._macroMaskMap=[],lz._macroCounter=0,lz._macroMap=Object.create(null);var lk=((tG=(tk=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new lR,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=lz.getPropertyByName(e)),this._propertyValueMap[e._uniqueId]},tG.enableMacro=function(e,t){"string"==typeof e&&(e=lz.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=lE._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=lz._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){sE.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=this._propertyValueMap,n=e._propertyValueMap,r=Object.keys(t),i=0,a=r.length;i<a;i++){var o=r[i],s=t[o];if(null!=s){if("number"==typeof s)n[o]=s;else if(sb(s,sX))n[o]=s;else if(sb(s,Array)||sb(s,Float32Array)||sb(s,Int32Array))n[o]=s.slice();else{var l=n[o];l?l.copyFrom(s):n[o]=s.clone()}}else n[o]=s}},tG._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=lz.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 "+oM[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&&sb(r,sX)&&r._addRefCount(e)}},tk),lG=(sT(tH=function(){var t;return t=lt.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 sf(1,1,1,1),t._lightColor=new sf,t},lt),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},sy(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 sc),sc.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new sc),sc.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),tH);lG._maxLight=10,sw([sA],lG.prototype,"_lightIndex",void 0);var lH=(sT(tW=function(){var e;return e=lG.apply(this,arguments)||this,e._forward=new sn,e._reverseDirection=new sn,e},lG),(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)},sy(tW,[{key:"direction",get:function(){return this.entity.transform.getWorldForward(this._forward),this._forward}},{key:"reverseDirection",get:function(){return sn.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tW);lH._cullingMaskProperty=lz.getPropertyByName("u_directLightCullingMask"),lH._colorProperty=lz.getPropertyByName("u_directLightColor"),lH._directionProperty=lz.getPropertyByName("u_directLightDirection"),lH._combinedData={cullingMask:new Int32Array(2*lG._maxLight),color:new Float32Array(3*lG._maxLight),direction:new Float32Array(3*lG._maxLight)};var lW=(sT(tK=function(){var e;return e=lG.apply(this,arguments)||this,e.distance=100,e},lG),(tj=tK.prototype)._appendData=function(e){var t=2*e,n=3*e,r=3*e,i=this._getLightColor(),a=this.position,o=tK._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},tj._onEnable=function(){this.engine._lightManager._attachPointLight(this)},tj._onDisable=function(){this.engine._lightManager._detachPointLight(this)},tK._updateShaderData=function(e){var t=tK._combinedData;e.setIntArray(tK._cullingMaskProperty,t.cullingMask),e.setFloatArray(tK._colorProperty,t.color),e.setFloatArray(tK._positionProperty,t.position),e.setFloatArray(tK._distanceProperty,t.distance)},sy(tK,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tK);lW._cullingMaskProperty=lz.getPropertyByName("u_pointLightCullingMask"),lW._colorProperty=lz.getPropertyByName("u_pointLightColor"),lW._positionProperty=lz.getPropertyByName("u_pointLightPosition"),lW._distanceProperty=lz.getPropertyByName("u_pointLightDistance"),lW._combinedData={cullingMask:new Int32Array(2*lG._maxLight),color:new Float32Array(3*lG._maxLight),position:new Float32Array(3*lG._maxLight),distance:new Float32Array(lG._maxLight)};var lX=(sT(tq=function(){var e;return e=lG.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._forward=new sn,e._inverseDirection=new sn,e._projectMatrix=new sc,e},lG),(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)},sy(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 sn.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 sc.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),tq);lX._cullingMaskProperty=lz.getPropertyByName("u_spotLightCullingMask"),lX._colorProperty=lz.getPropertyByName("u_spotLightColor"),lX._positionProperty=lz.getPropertyByName("u_spotLightPosition"),lX._directionProperty=lz.getPropertyByName("u_spotLightDirection"),lX._distanceProperty=lz.getPropertyByName("u_spotLightDistance"),lX._angleCosProperty=lz.getPropertyByName("u_spotLightAngleCos"),lX._penumbraCosProperty=lz.getPropertyByName("u_spotLightPenumbraCos"),lX._combinedData={cullingMask:new Int32Array(2*lG._maxLight),color:new Float32Array(3*lG._maxLight),position:new Float32Array(3*lG._maxLight),direction:new Float32Array(3*lG._maxLight),distance:new Float32Array(lG._maxLight),angleCos:new Float32Array(lG._maxLight),penumbraCos:new Float32Array(lG._maxLight)};var lK=((tJ=(tQ=function(){this._spotLights=new s5,this._pointLights=new s5,this._directLights=new s5}).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?(lH._updateShaderData(e),e.enableMacro("O3_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("O3_DIRECT_LIGHT_COUNT"),a?(lW._updateShaderData(e),e.enableMacro("O3_POINT_LIGHT_COUNT",a.toString())):e.disableMacro("O3_POINT_LIGHT_COUNT"),i?(lX._updateShaderData(e),e.enableMacro("O3_SPOT_LIGHT_COUNT",i.toString())):e.disableMacro("O3_SPOT_LIGHT_COUNT")},tQ),lj=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},lq=((t$=(tZ=function(){this.targetBlendState=new lj,this.blendColor=new sf(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;sf.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),lY=((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),lQ=((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),lJ=((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),lZ=((t8=function(){this.blendState=new lq,this.depthState=new lY,this.stencilState=new lJ,this.rasterState=new lQ,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),l$=(sT(t6=function(e,t){var n;return(n=sL.call(this,e)||this).shaderData=new lk(oM.Material),n._renderStates=[],n.shader=t,n},sL),(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),sE.deepCloneObject(this.renderStates,e.renderStates)},t7._addRefCount=function(e){sL.prototype._addRefCount.call(this,e),this.shaderData._addRefCount(e)},t7._preRender=function(e){},t7._onDestroy=function(){},sy(t6,[{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 lZ);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t6),l0=((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},t9),l1=function(){},l2=(sT(nt=function(){return l1.apply(this,arguments)},l1),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},nt),l3=((nn=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(nn._viewMatrixProperty,e.viewMatrix),t.setMatrix(nn._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(nn._vpMatrixProperty,e.viewProjectionMatrix)},nn);l3._vpMatrixProperty=lz.getPropertyByName("u_VPMat"),l3._viewMatrixProperty=lz.getPropertyByName("u_viewMat"),l3._projectionMatrixProperty=lz.getPropertyByName("u_projMat");var l4=(sT(nr=function(){var e;return(e=l1.call(this)||this).multiRenderData=!1,e},l1),nr.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},nr),l5=(sT(ni=function(){var e;return(e=l1.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},l1),ni.prototype.setValue=function(e,t,n){this.component=e,this.renderData=t,this.material=n},ni);function l8(){return function(e){}}e.SpriteMaskInteraction=void 0,(na=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[na.None=0]="None",na[na.VisibleInsideMask=1]="VisibleInsideMask",na[na.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(sT(no=function(t){(n=lt.call(this,t)||this).shaderData=new lk(oM.Renderer),n._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new lR,n._bounds=new si,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._mvMatrix=new sc,n._mvpMatrix=new sc,n._mvInvMatrix=new sc,n._normalMatrix=new sc,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new s_,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(sm(n)),n._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},lt),(ns=no.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},ns.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},ns.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},ns.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},ns.getMaterials=function(){return this._materials},ns.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))}},ns.update=function(e){},ns._onEnable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},ns._onDisable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},ns._prepareRender=function(t){var n=t.virtualCamera,r=n.position,i=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(sn.subtract(i,r,i),this._distanceForSort=sn.dot(i,n.forward)):this._distanceForSort=sn.distanceSquared(i,r),this._updateShaderData(t),this._render(t),lR.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},ns._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)},ns._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)},ns._updateTransformShaderData=function(t,n){var r=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;sc.multiply(i.viewMatrix,n,a),sc.multiply(i.viewProjectionMatrix,n,o),sc.invert(a,s),sc.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)},ns._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},ns._updateBounds=function(e){},ns._render=function(e){throw"not implement"},ns._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},ns._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}},ns._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},sy(no,[{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}}]),(oF=no)._tempVector0=new sn,oF._receiveShadowMacro=lz.getMacroByName("OASIS_RECEIVE_SHADOWS"),oF._localMatrixProperty=lz.getPropertyByName("u_localMat"),oF._worldMatrixProperty=lz.getPropertyByName("u_modelMat"),oF._mvMatrixProperty=lz.getPropertyByName("u_MVMat"),oF._mvpMatrixProperty=lz.getPropertyByName("u_MVPMat"),oF._mvInvMatrixProperty=lz.getPropertyByName("u_MVInvMat"),oF._normalMatrixProperty=lz.getPropertyByName("u_normalMat"),oF._rendererLayerProperty=lz.getPropertyByName("oasis_RendererLayer"),oF),sw([sP],e.Renderer.prototype,"shaderData",void 0),sw([sA],e.Renderer.prototype,"_distanceForSort",void 0),sw([sA],e.Renderer.prototype,"_onUpdateIndex",void 0),sw([sA],e.Renderer.prototype,"_rendererIndex",void 0),sw([sA],e.Renderer.prototype,"_globalShaderMacro",void 0),sw([sP],e.Renderer.prototype,"_bounds",void 0),sw([sA],e.Renderer.prototype,"_renderFrameCount",void 0),sw([sA],e.Renderer.prototype,"_overrideUpdate",void 0),sw([sF],e.Renderer.prototype,"_materials",void 0),sw([sA],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),sw([sA],e.Renderer.prototype,"_mvMatrix",void 0),sw([sA],e.Renderer.prototype,"_mvpMatrix",void 0),sw([sA],e.Renderer.prototype,"_mvInvMatrix",void 0),sw([sA],e.Renderer.prototype,"_normalMatrix",void 0),sw([sA],e.Renderer.prototype,"_materialsInstanced",void 0),sw([sA],e.Renderer.prototype,"_priority",void 0),sw([sM],e.Renderer.prototype,"_receiveShadows",void 0),sw([sA],e.Renderer.prototype,"_rendererLayer",void 0),sw([sA],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=sw([s9(lr)],e.Renderer),(nl=oP||(oP={}))[nl.WorldVolume=1]="WorldVolume";var l6=((nu=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 sn),i.push(new sd);t.triangles=l6._rectangleTriangles},nu.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,i=r.pivot,a=i.x,o=i.y,s=l6._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])}si.transform(r._getBounds(),s,e._bounds)},nu.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)},(oE=nu)._rectangleTriangles=[0,1,2,2,1,3],oE._worldMatrix=new sc,oE);l6=sw([l8()],l6);var l7=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,(nc=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[nc.Layer0=1]="Layer0",nc[nc.Layer1=2]="Layer1",nc[nc.Layer2=4]="Layer2",nc[nc.Layer3=8]="Layer3",nc[nc.Layer4=16]="Layer4",nc[nc.Layer5=32]="Layer5",nc[nc.Layer6=64]="Layer6",nc[nc.Layer7=128]="Layer7",nc[nc.Layer8=256]="Layer8",nc[nc.Layer9=512]="Layer9",nc[nc.Layer10=1024]="Layer10",nc[nc.Layer11=2048]="Layer11",nc[nc.Layer12=4096]="Layer12",nc[nc.Layer13=8192]="Layer13",nc[nc.Layer14=16384]="Layer14",nc[nc.Layer15=32768]="Layer15",nc[nc.Layer16=65536]="Layer16",nc[nc.Layer17=131072]="Layer17",nc[nc.Layer18=262144]="Layer18",nc[nc.Layer19=524288]="Layer19",nc[nc.Layer20=1048576]="Layer20",nc[nc.Layer21=2097152]="Layer21",nc[nc.Layer22=4194304]="Layer22",nc[nc.Layer23=8388608]="Layer23",nc[nc.Layer24=16777216]="Layer24",nc[nc.Layer25=33554432]="Layer25",nc[nc.Layer26=67108864]="Layer26",nc[nc.Layer27=134217728]="Layer27",nc[nc.Layer28=268435456]="Layer28",nc[nc.Layer29=536870912]="Layer29",nc[nc.Layer30=1073741824]="Layer30",nc[nc.Layer31=2147483648]="Layer31",nc[nc.Everything=4294967295]="Everything",(nh=oR||(oR={}))[nh.texture=1]="texture",nh[nh.size=2]="size",nh[nh.atlasRotate=4]="atlasRotate",nh[nh.atlasRegion=8]="atlasRegion",nh[nh.atlasRegionOffset=16]="atlasRegionOffset",nh[nh.region=32]="region",nh[nh.pivot=64]="pivot",nh[nh.border=128]="border";var l9=function(t){function n(r){var i;return(i=t.call(this,r)||this).influenceLayers=e.SpriteMaskLayer.Everything,i._sprite=null,i._width=void 0,i._height=void 0,i._flipX=!1,i._flipY=!1,i._alphaCutoff=.5,i._renderData=new l7(4,[],[]),l6.resetData(sm(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(n._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(sm(i)),i}sT(n,t);var r=n.prototype;return r._onDestroy=function(){var e;null==(e=this._sprite)||e._updateFlagManager.removeListener(this._onSpriteChange),this._sprite=null,this._renderData=null,t.prototype._onDestroy.call(this)},r._cloneTo=function(e){e.sprite=this._sprite},r._updateBounds=function(e){var t;(null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height?l6.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&oP.WorldVolume&&(l6.updatePositions(this),this._dirtyUpdateFlag&=~oP.WorldVolume),2&this._dirtyUpdateFlag&&(l6.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._onSpriteChange=function(e){switch(e){case oR.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case oR.region:case oR.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case oR.atlasRegion:this._dirtyUpdateFlag|=2}},sy(n,[{key:"width",get:function(){return void 0===this._width&&this._sprite&&(this.width=this._sprite.width),this._width},set:function(e){this._width!==e&&(this._width=e,this._dirtyUpdateFlag|=oP.WorldVolume)}},{key:"height",get:function(){return void 0===this._height&&this._sprite&&(this.height=this._sprite.height),this._height},set:function(e){this._height!==e&&(this._height=e,this._dirtyUpdateFlag|=oP.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=oP.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=oP.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&t._updateFlagManager.removeListener(this._onSpriteChange),e?(e._updateFlagManager.addListener(this._onSpriteChange),this._dirtyUpdateFlag|=3,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);l9._textureProperty=lz.getPropertyByName("u_maskTexture"),l9._alphaCutoffProperty=lz.getPropertyByName("u_maskAlphaCutoff"),sw([sM],l9.prototype,"influenceLayers",void 0),sw([sA],l9.prototype,"_sprite",void 0),sw([sA],l9.prototype,"_width",void 0),sw([sA],l9.prototype,"_height",void 0),sw([sM],l9.prototype,"_flipX",void 0),sw([sM],l9.prototype,"_flipY",void 0),sw([sM],l9.prototype,"_alphaCutoff",void 0),sw([sA],l9.prototype,"_onSpriteChange",null),(nd=oL||(oL={}))[nd.UV=2]="UV",nd[nd.All=3]="All",e.VertexElementFormat=void 0,(n_=e.VertexElementFormat||(e.VertexElementFormat={}))[n_.Float=0]="Float",n_[n_.Vector2=1]="Vector2",n_[n_.Vector3=2]="Vector3",n_[n_.Vector4=3]="Vector4",n_[n_.Byte4=4]="Byte4",n_[n_.UByte4=5]="UByte4",n_[n_.NormalizedByte4=6]="NormalizedByte4",n_[n_.NormalizedUByte4=7]="NormalizedUByte4",n_[n_.Short2=8]="Short2",n_[n_.UShort2=9]="UShort2",n_[n_.NormalizedShort2=10]="NormalizedShort2",n_[n_.NormalizedUShort2=11]="NormalizedUShort2",n_[n_.Short4=12]="Short4",n_[n_.UShort4=13]="UShort4",n_[n_.NormalizedShort4=14]="NormalizedShort4",n_[n_.NormalizedUShort4=15]="NormalizedUShort4",e.BufferUsage=void 0,(nf=e.BufferUsage||(e.BufferUsage={}))[nf.Static=0]="Static",nf[nf.Dynamic=1]="Dynamic",nf[nf.Stream=2]="Stream",e.IndexFormat=void 0,(np=e.IndexFormat||(e.IndexFormat={}))[np.UInt8=0]="UInt8",np[np.UInt16=1]="UInt16",np[np.UInt32=2]="UInt32";var ue=((ng=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}},ng._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}},ng._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},ng._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}},ng),ut=(sy(nm=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=ue._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}}]),nm);e.BufferBindFlag=void 0,(nv=e.BufferBindFlag||(e.BufferBindFlag={}))[nv.VertexBuffer=0]="VertexBuffer",nv[nv.IndexBuffer=1]="IndexBuffer",e.SetDataOptions=void 0,(ny=e.SetDataOptions||(e.SetDataOptions={}))[ny.None=0]="None",ny[ny.Discard=1]="Discard";var un=(sT(nx=function(t,n,r,i){void 0===i&&(i=e.BufferUsage.Static),(a=sL.call(this,t)||this)._engine=t,a._type=n,a._bufferUsage=i;var a,o=t._hardwareRenderer,s=o.gl,l=ue._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},sL),(nT=nx.prototype).bind=function(){this._hardwareRenderer.gl.bindBuffer(this._glBindTarget,this._nativeBuffer)},nT.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)},nT.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."},nT._onDestroy=function(){this._hardwareRenderer.gl.deleteBuffer(this._nativeBuffer),this._nativeBuffer=null,this._hardwareRenderer=null},nT.resize=function(e){this.bind(),this._hardwareRenderer.gl.bufferData(this._glBindTarget,e,this._glBufferUsage),this._byteLength=e},sy(nx,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}}]),nx);e.MeshTopology=void 0,(nC=e.MeshTopology||(e.MeshTopology={}))[nC.Points=0]="Points",nC[nC.Lines=1]="Lines",nC[nC.LineLoop=2]="LineLoop",nC[nC.LineStrip=3]="LineStrip",nC[nC.Triangles=4]="Triangles",nC[nC.TriangleStrip=5]="TriangleStrip",nC[nC.TriangleFan=6]="TriangleFan";var ur=(sy(nS=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),nS),ui=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},ua=(sT(nw=function(e,t){(n=sL.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new ln,n._bounds=new si,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(sm(n)),n._onBoundsChanged=n._onBoundsChanged.bind(sm(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},sL),(nb=nw.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new ui(t,n,r)),this._subMeshes.push(t),t},nb.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},nb.clearSubMesh=function(){this._subMeshes.length=0},nb._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},nb._addVertexElement=function(e){var t=e.semantic;this._vertexElementMap[t]=e,this._vertexElements.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},nb._insertVertexElement=function(e,t){var n=t.semantic;this._vertexElementMap[n]=t,this._vertexElements.splice(e,0,t),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},nb._setVertexBufferBinding=function(e,t){if(this._getRefCount()>0){var n=this._vertexBufferBindings[e];n&&n._buffer._addRefCount(-1),t._buffer._addRefCount(1)}this._vertexBufferBindings[e]=t,this._bufferStructChanged=!0},nb._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},nb._addRefCount=function(e){sL.prototype._addRefCount.call(this,e);for(var t=this._vertexBufferBindings,n=0,r=t.length;n<r;n++)t[n]._buffer._addRefCount(e)},nb._onDestroy=function(){this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._platformPrimitive.destroy()},nb._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},nb._setIndexBufferBinding=function(e){var t=this._indexBufferBinding;e?(this._indexBufferBinding=e,this._glIndexType=ue._getGLIndexType(e.format),this._glIndexByteCount=ue._getGLIndexByteCount(e.format),t&&t._buffer===e._buffer||(this._bufferStructChanged=!0)):(this._indexBufferBinding=null,this._glIndexType=void 0,t&&(this._bufferStructChanged=!0))},nb._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},sy(nw,[{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}}]),nw);(nA=oB||(oB={}))[nA.Bounds=1]="Bounds",nA[nA.VertexElements=2]="VertexElements";var uo=(sy(nM=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),nM),us=((nP=(nF=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 sn(0,0,0),this._canUseTextureStoreData=!0,this._dataTextureInfo=new sn,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())},nP._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},nP._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(nF._blendShapeMacro),this._useTextureMode())e.enableMacro(nF._blendShapeTextureMacro),e.setTexture(nF._blendShapeTextureProperty,this._vertexTexture),e.setVector3(nF._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(nF._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(nF._blendShapeWeightsProperty,i),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(nF._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(nF._blendShapeTextureMacro),e.disableMacro("OASIS_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(nF._blendShapeNormalMacro):e.disableMacro(nF._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(nF._blendShapeTangentMacro):e.disableMacro(nF._blendShapeTangentMacro)}else e.disableMacro(nF._blendShapeMacro),e.disableMacro("OASIS_BLENDSHAPE_COUNT")},nP._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},nP._layoutOrCountChange=function(){var e=this._lastCreateHostInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},nP._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},nP._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},nP._setAttributeModeOffsetInfo=function(e,t){this._vertexElementOffset=e,this._bufferBindingOffset=t},nP._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 ut("POSITION_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12,this._useBlendNormal&&(t._addVertexElement(new ut("NORMAL_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12),this._useBlendTangent&&(t._addVertexElement(new ut("TANGENT_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12)},nP._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))},nP._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},nP._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 un(r,e.BufferBindFlag.VertexBuffer,p,g);i._setVertexBufferBinding(h+d,new uo(m,f)),o[d]=m}},nP._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 sq(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)},nP._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=0,h=n.length;c<h;c++){var d=s[c];if(t||d.flag){var _=n[c].frames,f=_.length,p=_[f-1];if(f>0&&p.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var g=Math.floor(c/r),m=c%r,v=a[g],y=v.byteLength/(4*e),x=m*l,T=o[c];T||(o[c]=T=new sd),T.set(g+1,m*u);for(var C=p.deltaPositions,S=0;S<e;S++){var w=x+y*S,b=C[S];b&&(i[w]=b.x,i[w+1]=b.y,i[w+2]=b.z)}if(x+=3,this._useBlendNormal){var A=p.deltaNormals;if(A)for(var M=0;M<e;M++){var F=x+y*M,P=A[M];P&&(i[F]=P.x,i[F+1]=P.y,i[F+2]=P.z)}x+=3}if(this._useBlendTangent){var E=p.deltaTangents;if(E)for(var R=0;R<e;R++){var L=x+y*R,B=E[R];B&&(i[L]=B.x,i[L+1]=B.y,i[L+2]=B.z)}x+=3}(m===r-1||c===h-1)&&v.setData(i,0,0,v.byteLength/4),d.flag=!1}}},nP._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)},nP._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},nP._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}},nP._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},nP._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)}}}},nF);us._blendShapeMacro=lz.getMacroByName("OASIS_BLENDSHAPE"),us._blendShapeTextureMacro=lz.getMacroByName("OASIS_BLENDSHAPE_TEXTURE"),us._blendShapeNormalMacro=lz.getMacroByName("OASIS_BLENDSHAPE_NORMAL"),us._blendShapeTangentMacro=lz.getMacroByName("OASIS_BLENDSHAPE_TANGENT"),us._blendShapeWeightsProperty=lz.getPropertyByName("u_blendShapeWeights"),us._blendShapeTextureProperty=lz.getPropertyByName("u_blendShapeTexture"),us._blendShapeTextureInfoProperty=lz.getPropertyByName("u_blendShapeTextureInfo"),(nE=oD||(oD={})).Position="POSITION",nE.Normal="NORMAL",nE.Color="COLOR_0",nE.Tangent="TANGENT",nE.BoneWeight="WEIGHTS_0",nE.BoneIndex="JOINTS_0",nE.UV="TEXCOORD_0",nE.UV1="TEXCOORD_1",nE.UV2="TEXCOORD_2",nE.UV3="TEXCOORD_3",nE.UV4="TEXCOORD_4",nE.UV5="TEXCOORD_5",nE.UV6="TEXCOORD_6",nE.UV7="TEXCOORD_7";var ul=(sT(nR=function(e,t){var n;return(n=ua.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 us(e,sm(n)),n},ua),(nL=nR.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}},nL.getPositions=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._positions},nL.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},nL.getNormals=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._normals},nL.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},nL.getColors=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._colors},nL.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},nL.getBoneWeights=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._boneWeights},nL.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},nL.getBoneIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._boneIndices},nL.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},nL.getTangents=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._tangents},nL.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]."}},nL.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]."},nL.setIndices=function(t){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._indices!==t&&(this._indices=t,sb(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:sb(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:sb(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},nL.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},nL.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[oD.Position]?this.getPositions()&&(this._vertexBufferUpdateFlag|=1):this.setPositions(null),n[oD.Normal]?this.getNormals()&&(this._vertexBufferUpdateFlag|=2):this.setNormals(null),n[oD.Color]?this.getColors()&&(this._vertexBufferUpdateFlag|=4):this.setColors(null),n[oD.BoneWeight]?this.getBoneWeights()&&(this._vertexBufferUpdateFlag|=16):this.setBoneWeights(null),n[oD.BoneIndex]?this.getBoneIndices()&&(this._vertexBufferUpdateFlag|=32):this.setBoneIndices(null),n[oD.Tangent]?this.getTangents()&&(this._vertexBufferUpdateFlag|=8):this.setTangents(null),n[oD.UV]?this.getUVs(0)&&(this._vertexBufferUpdateFlag|=64):this.setUVs(null,0),n[oD.UV1]?this.getUVs(1)&&(this._vertexBufferUpdateFlag|=128):this.setUVs(null,1),n[oD.UV2]?this.getUVs(2)&&(this._vertexBufferUpdateFlag|=256):this.setUVs(null,2),n[oD.UV3]?this.getUVs(3)&&(this._vertexBufferUpdateFlag|=512):this.setUVs(null,3),n[oD.UV4]?this.getUVs(4)&&(this._vertexBufferUpdateFlag|=1024):this.setUVs(null,4),n[oD.UV5]?this.getUVs(5)&&(this._vertexBufferUpdateFlag|=2048):this.setUVs(null,5),n[oD.UV6]?this.getUVs(6)&&(this._vertexBufferUpdateFlag|=4096):this.setUVs(null,6),n[oD.UV7]?this.getUVs(7)&&(this._vertexBufferUpdateFlag|=8192):this.setUVs(null,7),this._vertexElementsUpdate=!0},nL.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 uo(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r),this._vertexDataUpdateFlag|=1},nL.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])},nL.addBlendShape=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._blendShapeManager._addBlendShape(e)},nL.clearBlendShapes=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._blendShapeManager._clearBlendShapes()},nL.getBlendShapeName=function(e){return this._accessible?this._blendShapeManager._blendShapes[e].name:this._blendShapeManager._blendShapeNames[e]},nL.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 un(this._engine,e.BufferBindFlag.VertexBuffer,s,l);this._setVertexBufferBinding(0,new uo(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 ur(d,this._indicesFormat)),this._indicesChangeFlag=!1);else{null==d||d.destroy();var _=new un(this._engine,e.BufferBindFlag.IndexBuffer,h);this._setIndexBufferBinding(new ur(_,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())},nL.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=nR._tempVec0,o=nR._tempVec1,s=nR._tempVec2,l=nR._tempVec3,u=nR._tempVec4,c=e?e.length/3:t.length/3,h=Array(i),d=Array(i),_=0;_<i;_++)h[_]=new s_,d[_]=new sn;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];sn.subtract(y,v,a),sn.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);sn.scale(a,M*F,s),sn.scale(o,A*F,u),sn.subtract(s,u,s),sn.scale(o,w*F,l),sn.scale(a,b*F,u),sn.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),sn.cross(s,L,u);var D=sn.dot(u,R)>0?1:-1;sn.scale(R,sn.dot(s,R),u),sn.subtract(s,u,s),s.normalize(),B.set(s.x,s.y,s.z,D)}this.setTangents(h)},nL._onDestroy=function(){ua.prototype._onDestroy.call(this),this._accessible&&this._releaseCache()},nL._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[oD.Position]&&this._insertVertexAttribute(oD.Position),this._normals&&!r[oD.Normal]&&this._insertVertexAttribute(oD.Normal),this._colors&&!r[oD.Color]&&this._insertVertexAttribute(oD.Color),this._boneWeights&&!r[oD.BoneWeight]&&this._insertVertexAttribute(oD.BoneWeight),this._boneIndices&&!r[oD.BoneIndex]&&this._insertVertexAttribute(oD.BoneIndex),this._tangents&&!r[oD.Tangent]&&this._insertVertexAttribute(oD.Tangent),this._uv&&!r[oD.UV]&&this._insertVertexAttribute(oD.UV),this._uv1&&!r[oD.UV1]&&this._insertVertexAttribute(oD.UV1),this._uv2&&!r[oD.UV2]&&this._insertVertexAttribute(oD.UV2),this._uv3&&!r[oD.UV3]&&this._insertVertexAttribute(oD.UV3),this._uv4&&!r[oD.UV4]&&this._insertVertexAttribute(oD.UV4),this._uv5&&!r[oD.UV5]&&this._insertVertexAttribute(oD.UV5),this._uv6&&!r[oD.UV6]&&this._insertVertexAttribute(oD.UV6),this._uv7&&!r[oD.UV7]&&this._insertVertexAttribute(oD.UV7)},nL._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)},nL._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,N=u[V];N&&(e[U]=N.x,e[U+1]=N.y,e[U+2]=N.z,e[U+3]=N.w)}C+=4}if(c){if(64&o)for(var z=0;z<n;z++){var k=v*z+C,G=c[z];G&&(e[k]=G.x,e[k+1]=G.y)}C+=2}if(h){if(128&o)for(var H=0;H<n;H++){var W=v*H+C,X=h[H];X&&(e[W]=X.x,e[W+1]=X.y)}C+=2}if(d){if(256&o)for(var K=0;K<n;K++){var j=v*K+C,q=d[K];q&&(e[j]=q.x,e[j+1]=q.y)}C+=2}if(_){if(512&o)for(var Y=0;Y<n;Y++){var Q=v*Y+C,J=_[Y];J&&(e[Q]=J.x,e[Q+1]=J.y)}C+=2}if(f){if(1024&o)for(var Z=0;Z<n;Z++){var $=v*Z+C,ee=f[Z];ee&&(e[$]=ee.x,e[$+1]=ee.y)}C+=2}if(p){if(2048&o)for(var et=0;et<n;et++){var en=v*et+C,er=p[et];er&&(e[en]=er.x,e[en+1]=er.y)}C+=2}if(g){if(4096&o)for(var ei=0;ei<n;ei++){var ea=v*ei+C,eo=g[ei];eo&&(e[ea]=eo.x,e[ea+1]=eo.y)}C+=2}if(m){if(8192&o)for(var es=0;es<n;es++){var el=v*es+C,eu=m[es];eu&&(e[el]=eu.x,e[el+1]=eu.y)}C+=2}this._vertexBufferUpdateFlag=0},nL._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 ut(e,a,t,0)),this._bufferStrides[0]=a+n},nL._getAttributeFormat=function(t){switch(t){case oD.Position:case oD.Normal:return e.VertexElementFormat.Vector3;case oD.Color:case oD.BoneWeight:return e.VertexElementFormat.Vector4;case oD.BoneIndex:return e.VertexElementFormat.UByte4;case oD.Tangent:return e.VertexElementFormat.Vector4;case oD.UV:case oD.UV1:case oD.UV2:case oD.UV3:case oD.UV4:case oD.UV5:case oD.UV6:case oD.UV7:return e.VertexElementFormat.Vector2}},nL._getAttributeByteLength=function(e){switch(e){case oD.Position:case oD.Normal:return 12;case oD.Color:case oD.BoneWeight:return 16;case oD.BoneIndex:return 4;case oD.Tangent:return 16;case oD.UV:case oD.UV1:case oD.UV2:case oD.UV3:case oD.UV4:case oD.UV5:case oD.UV6:case oD.UV7:return 8}},nL._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()},sy(nR,[{key:"accessible",get:function(){return this._accessible}},{key:"vertexCount",get:function(){if(1&this._vertexDataUpdateFlag){var e=0,t=this._vertexElementMap[oD.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}}]),nR);ul._tempVec0=new sn,ul._tempVec1=new sn,ul._tempVec2=new sn,ul._tempVec3=new sn,ul._tempVec4=new sn,(nB=oI||(oI={}))[nB.Position=1]="Position",nB[nB.Normal=2]="Normal",nB[nB.Color=4]="Color",nB[nB.Tangent=8]="Tangent",nB[nB.BoneWeight=16]="BoneWeight",nB[nB.BoneIndex=32]="BoneIndex",nB[nB.UV=64]="UV",nB[nB.UV1=128]="UV1",nB[nB.UV2=256]="UV2",nB[nB.UV3=512]="UV3",nB[nB.UV4=1024]="UV4",nB[nB.UV5=2048]="UV5",nB[nB.UV6=4096]="UV6",nB[nB.UV7=8192]="UV7",nB[nB.All=65535]="All";var uu=(sT(nD=function(e){var t;return(t=sR.call(this,null)||this).name=e,t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},sR),nD),uc=(nI=e.Renderer,sT(nO=function(e){var t;return(t=nI.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(sm(t)),t},nI),(nV=nO.prototype)._onDestroy=function(){nI.prototype._onDestroy.call(this);var e=this._mesh;e&&!e.destroyed&&(e._addRefCount(-1),this._mesh=null)},nV._cloneTo=function(e){e.mesh=this._mesh},nV._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;si.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},nV._render=function(e){var t=this._mesh;if(t){if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(nO._uvMacro),n.disableMacro(nO._uv1Macro),n.disableMacro(nO._normalMacro),n.disableMacro(nO._tangentMacro),n.disableMacro(nO._vertexColorMacro);for(var i=0,a=r.length;i<a;i++)switch(r[i].semantic){case"TEXCOORD_0":n.enableMacro(nO._uvMacro);break;case"TEXCOORD_1":n.enableMacro(nO._uv1Macro);break;case"NORMAL":n.enableMacro(nO._normalMacro);break;case"TANGENT":n.enableMacro(nO._tangentMacro);break;case"COLOR_0":this.enableVertexColor&&n.enableMacro(nO._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 sz.error("mesh is null.")},nV._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},nV._onMeshChanged=function(e){e&oB.Bounds&&(this._dirtyUpdateFlag|=oP.WorldVolume),e&oB.VertexElements&&(this._dirtyUpdateFlag|=2)},sy(nO,[{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)}}]),nO);uc._uvMacro=lz.getMacroByName("O3_HAS_UV"),uc._uv1Macro=lz.getMacroByName("O3_HAS_UV1"),uc._normalMacro=lz.getMacroByName("O3_HAS_NORMAL"),uc._tangentMacro=lz.getMacroByName("O3_HAS_TANGENT"),uc._vertexColorMacro=lz.getMacroByName("O3_HAS_VERTEXCOLOR"),sw([sA],uc.prototype,"_mesh",void 0),sw([sA],uc.prototype,"_onMeshChanged",null),(nU=oO||(oO={}))[nU.VertexElementMacro=2]="VertexElementMacro",nU[nU.All=3]="All";var uh=((nN=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},nN._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},nN._stringToPath=function(e){var t=[];return e.charCodeAt(0)===ud&&t.push(""),e.replace(uf,function(e,n,r,i){var a=e;r?a=i.replace(u_,"$1"):n&&(a=n.trim()),t.push(a)}),t},nN),ud=46,u_=/\\(\\)?/g,uf=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),up=(sT(nz=function(e){(t=uc.call(this,e)||this)._supportSkinning=!1,t._hasInitSkin=!1,t._jointDataCreateCache=new sd(-1,-1),t._localBounds=new si,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(sm(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},uc),(nk=nz.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?uh._floatMatrixMultiply(a.transform.worldMatrix,e[i].elements,0,r,o):r.set(e[i].elements,o),uh._floatMatrixMultiply(t,r,o,r,o)}},nk._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 sj(f,4,s,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point),r.disableMacro("O3_JOINTS_NUM"),r.enableMacro("O3_USE_JOINT_TEXTURE"),r.setTexture(nz._jointSamplerProperty,this._jointTexture),this._supportSkinning=!0):(this._supportSkinning=!1,null==(_=this._jointTexture)||_.destroy(),r.disableMacro("O3_HAS_SKIN"),sz.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(nz._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)},nk._cloneTo=function(e){uc.prototype._cloneTo.call(this,e),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},nk._registerEntityTransformListener=function(){},nk._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;si.transform(t,n,e)}else uc.prototype._updateBounds.call(this,e)},nk._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)si.transform(this._mesh.bounds,e.inverseBindMatrices[l],this._localBounds);else{var u=new sc(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?(sc.multiplyScalar(u,1/c,u),si.transform(this._mesh.bounds,u,this._localBounds)):this._localBounds.copyFrom(this._mesh.bounds)}this._rootBone=s,r?(t.enableMacro("O3_HAS_SKIN"),t.setInt(nz._jointCountProperty,r)):t.disableMacro("O3_HAS_SKIN")}},nk._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?(sc.add(r,t[u],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},nk._findByEntityName=function(e,t){return e?e.findByName(t)||this._findByEntityName(e.parent,t):null},nk._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)},nk._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=oP.WorldVolume},sy(nz,[{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|=oP.WorldVolume}}]),nz);up._tempMatrix=new sc,up._jointCountProperty=lz.getPropertyByName("u_jointCount"),up._jointSamplerProperty=lz.getPropertyByName("u_jointSampler"),up._jointMatrixProperty=lz.getPropertyByName("u_jointMatrix"),sw([sA],up.prototype,"_supportSkinning",void 0),sw([sA],up.prototype,"_hasInitSkin",void 0),sw([sA],up.prototype,"_jointDataCreateCache",void 0),sw([sA],up.prototype,"_blendShapeWeights",void 0),sw([sA],up.prototype,"_maxVertexUniformVectors",void 0),sw([sA],up.prototype,"_rootBone",void 0),sw([sA],up.prototype,"_localBounds",void 0),sw([sA],up.prototype,"_jointMatrices",void 0),sw([sA],up.prototype,"_jointTexture",void 0),sw([sA],up.prototype,"_jointEntities",void 0),sw([sA],up.prototype,"_condensedBlendShapeWeights",void 0),sw([sA],up.prototype,"_onLocalBoundsChanged",null);var ug=((nG=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 ul(e),a=(n=Math.max(2,Math.floor(n)))+1,o=a*a,s=n*n,l=nG._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 sn(C,S,w),f[g]=new sn(C,S,w),p[g]=new sd(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),nG._initialize(i,_,f,p,l,r),i},nG.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 ul(e),o=t/2,s=n/2,l=r/2,u=Array(24),c=Array(24),h=Array(24);u[0]=new sn(-o,s,-l),u[1]=new sn(o,s,-l),u[2]=new sn(o,s,l),u[3]=new sn(-o,s,l),c[0]=new sn(0,1,0),c[1]=new sn(0,1,0),c[2]=new sn(0,1,0),c[3]=new sn(0,1,0),h[0]=new sd(0,0),h[1]=new sd(1,0),h[2]=new sd(1,1),h[3]=new sd(0,1),u[4]=new sn(-o,-s,-l),u[5]=new sn(o,-s,-l),u[6]=new sn(o,-s,l),u[7]=new sn(-o,-s,l),c[4]=new sn(0,-1,0),c[5]=new sn(0,-1,0),c[6]=new sn(0,-1,0),c[7]=new sn(0,-1,0),h[4]=new sd(0,1),h[5]=new sd(1,1),h[6]=new sd(1,0),h[7]=new sd(0,0),u[8]=new sn(-o,s,-l),u[9]=new sn(-o,s,l),u[10]=new sn(-o,-s,l),u[11]=new sn(-o,-s,-l),c[8]=new sn(-1,0,0),c[9]=new sn(-1,0,0),c[10]=new sn(-1,0,0),c[11]=new sn(-1,0,0),h[8]=new sd(0,0),h[9]=new sd(1,0),h[10]=new sd(1,1),h[11]=new sd(0,1),u[12]=new sn(o,s,-l),u[13]=new sn(o,s,l),u[14]=new sn(o,-s,l),u[15]=new sn(o,-s,-l),c[12]=new sn(1,0,0),c[13]=new sn(1,0,0),c[14]=new sn(1,0,0),c[15]=new sn(1,0,0),h[12]=new sd(1,0),h[13]=new sd(0,0),h[14]=new sd(0,1),h[15]=new sd(1,1),u[16]=new sn(-o,s,l),u[17]=new sn(o,s,l),u[18]=new sn(o,-s,l),u[19]=new sn(-o,-s,l),c[16]=new sn(0,0,1),c[17]=new sn(0,0,1),c[18]=new sn(0,0,1),c[19]=new sn(0,0,1),h[16]=new sd(0,0),h[17]=new sd(1,0),h[18]=new sd(1,1),h[19]=new sd(0,1),u[20]=new sn(-o,s,-l),u[21]=new sn(o,s,-l),u[22]=new sn(o,-s,-l),u[23]=new sn(-o,-s,-l),c[20]=new sn(0,0,-1),c[21]=new sn(0,0,-1),c[22]=new sn(0,0,-1),c[23]=new sn(0,0,-1),h[20]=new sd(1,0),h[21]=new sd(0,0),h[22]=new sd(0,1),h[23]=new sd(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),nG._initialize(a,u,c,h,d,i),a},nG.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 ul(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=nG._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 sn(S*h-u,0,w*d-c),x[C]=new sn(0,1,0),T[C]=new sd(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),nG._initialize(o,y,x,T,p,a),o},nG.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 ul(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=nG._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,N=R*h-c,z=V*O;x[P]=new sn(U,N,z),T[P]=new sn(I,M,O),C[P]=new sd(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,K=X+1;g[S++]=W,g[S++]=X,g[S++]=H,g[S++]=W,g[S++]=K,g[S++]=X}x[d]=new sn(0,-c,0),T[d]=new sn(0,-1,0),C[d]=new sd(.5,.5),x[d+1]=new sn(0,c,0),T[d+1]=new sn(0,1,0),C[d+1]=new sd(.5,.5);for(var j=d+2,q=1/(2*t),Y=1/(2*n),Q=l*a,J=0;J<i;++J){var Z=x[J],$=Z.x,ee=Z.z;x[j]=new sn($,-c,ee),T[j]=new sn(0,-1,0),C[j++]=new sd($*Y+.5,.5-ee*Y);var et=x[J+Q];$=et.x,ee=et.z,x[j]=new sn($,c,ee),T[j]=new sn(0,1,0),C[j++]=new sd($*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),nG._initialize(s,x,T,C,g,o),s},nG.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 ul(e),l=((r=Math.floor(r))+1)*((i=Math.floor(i))+1),u=r*i,c=nG._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 sn((t+n*y)*T,(t+n*y)*C,n*x);h[f]=S;var w=t*T,b=t*C;d[f]=new sn(S.x-w,S.y-b,S.z).normalize(),_[f++]=new sd(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),nG._initialize(s,h,d,_,c,o),s},nG.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 ul(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=nG._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 sn(D,I,O),y[b]=new sn(R,w,L),x[b]=new sd(F,1-P)}for(var V=0;V<d;++V){var U=V%r,N=(V*g|0)*s+U,z=N+1,k=N+s,G=k+1;f[T++]=z,f[T++]=k,f[T++]=N,f[T++]=z,f[T++]=G,f[T++]=k}v[h]=new sn(0,-u,0),y[h]=new sn(0,-1,0),x[h]=new sd(.5,.5);for(var H=h+1,W=1/(2*t),X=0;X<r;++X){var K=v[X],j=K.x,q=K.z;v[H]=new sn(j,-u,q),y[H]=new sn(0,-1,0),x[H++]=new sd(j*W+.5,.5-q*W)}for(var Y=h+1,Q=0;Q<r;++Q){var J=Q,Z=Q===r-1?0:J+1;f[T++]=h,f[T++]=Y+Z,f[T++]=Y+J}var $=o.bounds;return $.min.set(-t,-u,-t),$.max.set(t,u,t),nG._initialize(o,v,y,x,f,a),o},nG.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 ul(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=nG._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 sn(t*L,F*c-u,t*B),S[A]=new sn(L,0,B),w[A]=new sd(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,N=U+1;g[b++]=V,g[b++]=U,g[b++]=O,g[b++]=V,g[b++]=N,g[b++]=U}nG._createCapsuleCap(t,n,r,T,h,1,C,S,w,g,b),nG._createCapsuleCap(t,n,r,-T,h+_,-1,C,S,w,g,b+6*f);var z=o.bounds;return z.min.set(-t,-t-u,-t),z.max.set(t,t+u,t),nG._initialize(o,C,S,w,g,a),o},nG._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)},nG._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},nG._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 sn(S,w,b),s[A]=new sn(S,w-d,b),l[A]=new sd(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}},nG),um=(sT(nH=function(){return ua.apply(this,arguments)},ua),(nW=nH.prototype).setVertexElements=function(e){this._setVertexElements(e)},nW.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 uo(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},nW.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])},nW.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new ur(e,t))),this._setIndexBufferBinding(n)},sy(nH,[{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}}]),nH),uv=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},uy=((nK=(nX=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new ln,this._dataChangeManager=new ln,this._frames=[],this.name=e}).prototype).addFrame=function(e,t,n,r){if("number"==typeof e){var i=new uv(e,t,n,r);return this._addFrame(i),i}this._addFrame(e)},nK.clearFrames=function(){this._frames.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},nK._addDataDirtyFlag=function(e){this._dataChangeManager.addFlag(e)},nK._createSubDataDirtyFlag=function(){return this._dataChangeManager.createFlag(le)},nK._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()},nK._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))},sy(nX,[{key:"frames",get:function(){return this._frames}}]),nX),ux=function(){function t(e){this._subMeshPool=new l0(ui),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 um(n,"BufferMesh"+r),o=[],s=this.createVertexElements(o);return this._vertexBuffers[r]=new un(n,e.BufferBindFlag.VertexBuffer,4*i*s,e.BufferUsage.Dynamic),this._indiceBuffers[r]=new un(n,e.BufferBindFlag.IndexBuffer,3*i,e.BufferUsage.Dynamic),a.setVertexBufferBinding(this._vertexBuffers[r],s),a.setIndexBufferBinding(this._indiceBuffers[r],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}();ux.MAX_VERTEX_COUNT=4096,ux._canUploadSameBuffer=!0;var uT=(sT(nj=function(){return ux.apply(this,arguments)},ux),(nq=nj.prototype).createVertexElements=function(t){return t[0]=new ut("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ut("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},nq.canBatch=function(e,t){if(e.isAdd!==t.isAdd)return!1;var n=e.component.shaderData,r=t.component.shaderData,i=l9._textureProperty,a=l9._alphaCutoffProperty;return n.getTexture(i)===r.getTexture(i)&&n.getTexture(a)===r.getTexture(a)},nq.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},nq.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=lz._compileMacros;lR.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),uC=((nQ=(nY=function(e){this._preMaskLayer=0,this._batcher=new uT(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},nQ.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t,null))},nQ.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},nQ.destroy=function(){this._batcher.destroy(),this._batcher=null},nQ._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)}}}},nY),uS=(sT(nJ=function(){var e;return(e=l1.call(this)||this).charElements=[],e.multiRenderData=!0,e},l1),nJ);e.BackgroundMode=void 0,(nZ=e.BackgroundMode||(e.BackgroundMode={}))[nZ.SolidColor=0]="SolidColor",nZ[nZ.Sky=1]="Sky",nZ[nZ.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(n$=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[n$.AspectFitWidth=0]="AspectFitWidth",n$[n$.AspectFitHeight=1]="AspectFitHeight",n$[n$.Fill=2]="Fill";var uw=((n0=function(){}).prototype._render=function(e){var t=this.material,n=this.mesh;if(!t){sz.warn("The material of sky is not defined.");return}if(!n){sz.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=n0._viewProjMatrix,c=n0._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(st.degreeToRadian(o)/2);c.elements[0]=g/a,c.elements[5]=g,sc.multiply(c,u,u);var m=l.getMatrix(l3._vpMatrixProperty);l.setMatrix(l3._vpMatrixProperty,u);var v=lz._compileMacros;lR.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(l3._vpMatrixProperty,m)},n0);uw._epsilon=1e-6,uw._viewProjMatrix=new sc,uw._projectionMatrix=new sc(1,0,0,0,0,1,0,0,0,0,uw._epsilon-1,-1,0,0,0,0);var ub=((n2=(n1=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new sf(.25,.25,.25,1),this.sky=new uw,this._textureFillMode=e.BackgroundTextureFillMode.AspectFitHeight,this._texture=null,this._mesh=this._createPlane(t)}).prototype)._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)}},n2._createPlane=function(e){var t=new ul(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 sn,i[a]=new sd(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},sy(n1,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(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())}}]),n1);e.FogMode=void 0,(n3=e.FogMode||(e.FogMode={}))[n3.None=0]="None",n3[n3.Linear=1]="Linear",n3[n3.Exponential=2]="Exponential",n3[n3.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(n4=e.DiffuseMode||(e.DiffuseMode={}))[n4.SolidColor=0]="SolidColor",n4[n4.SphericalHarmonics=1]="SphericalHarmonics";var uA=((n8=(n5=function(){this._diffuseSolidColor=new sf(.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(n5._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(n5._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(n5._specularIntensityProperty,this._specularIntensity),t.setFloatArray(n5._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},n8._removeFromScene=function(e){var t=this._scenes,n=t.indexOf(e);t.splice(n,1)},n8._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(n5._shMacro):t.disableMacro(n5._shMacro)},n8._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(n5._specularTextureProperty,this._specularTexture),e.setFloat(n5._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(n5._specularMacro)):e.disableMacro(n5._specularMacro)},n8._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(n5._decodeRGBMMacro):e.disableMacro(n5._decodeRGBMMacro)},n8._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]},sy(n5,[{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(n5._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(n5._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(n5._specularIntensityProperty,e)}}]),n5);uA._shMacro=lz.getMacroByName("O3_USE_SH"),uA._specularMacro=lz.getMacroByName("O3_USE_SPECULAR_ENV"),uA._decodeRGBMMacro=lz.getMacroByName("O3_DECODE_ENV_RGBM"),uA._diffuseColorProperty=lz.getPropertyByName("u_envMapLight.diffuse"),uA._diffuseSHProperty=lz.getPropertyByName("u_env_sh"),uA._diffuseIntensityProperty=lz.getPropertyByName("u_envMapLight.diffuseIntensity"),uA._specularTextureProperty=lz.getPropertyByName("u_env_specularSampler"),uA._specularIntensityProperty=lz.getPropertyByName("u_envMapLight.specularIntensity"),uA._mipLevelProperty=lz.getPropertyByName("u_envMapLight.mipMapLevel");var uM=function(t){function n(r,i){(a=t.call(this,r)||this).background=new ub(a._engine),a.shaderData=new lk(oM.Scene),a.castShadows=!0,a.shadowResolution=e.ShadowResolution.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new sn(1/15,.2,7/15),a.shadowDistance=50,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new lR,a._rootEntities=[],a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new sf(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new s_,a.name=i||"";var a,o=a.shaderData;return o._addRefCount(1),a.ambientLight=new uA,r.sceneManager._allScenes.push(sm(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}sT(n,t);var r=n.prototype;return r.createRootEntity=function(e){var t=new li(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),li._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(),li._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=li._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):sz.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,n=this._engine._lightManager;n._updateShaderData(this.shaderData);var r=n._getSunLightIndex();-1!==r&&(this._sunLight=n._directLights.get(r)),this.castShadows&&this._sunLight&&this._sunLight.shadowType!==e.ShadowType.None?t.enableMacro("SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SHADOW_TYPE"),lR.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.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)},sy(n,[{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){sz.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}(sR);uM._fogColorProperty=lz.getPropertyByName("oasis_FogColor"),uM._fogParamsProperty=lz.getPropertyByName("oasis_FogParams");var uF=((n7=(n6=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},n7.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,i=n.length;r<i;r++)t.addRootEntity(n[r])},n7._destroyAllScene=function(){for(var e=this._allScenes,t=0,n=e.length;t<n;t++)e[t]._destroy();e.length=0},sy(n6,[{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)}}]),n6),uP="#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=((n9=function(){}).init=function(){lz.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}"),lz.create("pbr",uP,"#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}"),lz.create("pbr-specular",uP,"#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}"),lz.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}"),lz.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}"),lz.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;}"),lz.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}"),lz.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;}"),lz.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;}"),lz.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);}")},n9),uR=((rt=(re=function(){this._cacheHierarchy=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,n=e._length;n>this._cacheHierarchy&&this._resizeCacheMapHierarchy(t,0,n);for(var r=e._mask,i=e._length-1,a=this._cacheHierarchy-1,o=0;o<a;o++){var s=i<o?0:r[o],l=t[s];l||(t[s]=l=Object.create(null)),t=l}var u=i<a?0:r[a],c=t[u];return c||(this._lastQueryKey=u,this._lastQueryMap=t),c},rt.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},rt._resizeCacheMapHierarchy=function(e,t,n){var r=this._cacheHierarchy-1;if(t==r){for(var i in e)for(var a=e[i],o=e,s=0,l=n-r;s<l;s++)s==l-1?o[0]=a:o=o[0==s?i:0]=Object.create(null);this._cacheHierarchy=n}else for(var u in e)this._resizeCacheMapHierarchy(e[u],++t,n)},re);uE.init();var uL=function(t){function n(r,i,a){(o=t.call(this)||this)._lightManager=new lK,o._componentsManager=new s8,o._lastRenderState=new lZ,o._renderElementPool=new l0(l2),o._spriteElementPool=new l0(l4),o._spriteMaskElementPool=new l0(l5),o._textElementPool=new l0(uS),o._renderContext=new l3,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._macroCollection=new lR,o._settings={},o._resourceManager=new s0(sm(o)),o._sceneManager=new uF(sm(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new sk,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 lu(sm(o)),o._canvas=r,o._sceneManager.activeScene=new uM(sm(o),"DefaultScene"),o._spriteMaskManager=new uC(sm(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=sZ.createFromOS(sm(o),"Arial"),o._textDefaultFont.isGCIgnored=!1,o.inputManager=new lP(sm(o));var o,s=new Uint8Array([255,0,255,255]),l=new sj(sm(o),1,1,e.TextureFormat.R8G8B8A8,!1);l.setPixelBuffer(s),l.isGCIgnored=!0;var u=new sY(sm(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 sj(sm(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 sq(sm(o),1,1,1,e.TextureFormat.R8G8B8A8,!1);h.setPixelBuffer(0,s),h.isGCIgnored=!0,o._magentaTexture2DArray=h}var d=new l$(sm(o),lz.find("unlit"));d.shaderData.setColor("u_baseColor",new sS(1,0,1.01,1)),o._magentaMaterial=d;var _=new l$(sm(o),lz.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}sT(n,t);var r=n.prototype;return r.createEntity=function(e){return new li(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 sB("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 sB("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 uR}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 sz.debug("NO active camera.")},r._createSpriteMaterial=function(){var t=new l$(this,lz.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 l$(this,lz.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},sy(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}(sD);uL._gammaMacro=lz.getMacroByName("OASIS_COLORSPACE_GAMMA"),uL._noDepthTextureMacro=lz.getMacroByName("OASIS_NO_DEPTH_TEXTURE"),uL._pixelsPerUnit=100;var uB=(sT(rn=function(){var e;return e=lt.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},lt),(rr=rn.prototype).onAwake=function(){},rr.onEnable=function(){},rr.onStart=function(){},rr.onUpdate=function(e){},rr.onLateUpdate=function(e){},rr.onBeginRender=function(e){},rr.onEndRender=function(e){},rr.onPhysicsUpdate=function(){},rr.onTriggerEnter=function(e){},rr.onTriggerExit=function(e){},rr.onTriggerStay=function(e){},rr.onCollisionEnter=function(e){},rr.onCollisionExit=function(e){},rr.onCollisionStay=function(e){},rr.onPointerDown=function(e){},rr.onPointerUp=function(e){},rr.onPointerClick=function(e){},rr.onPointerEnter=function(e){},rr.onPointerExit=function(e){},rr.onPointerDrag=function(e){},rr.onDisable=function(){},rr.onDestroy=function(){},rr._onAwake=function(){this.onAwake()},rr._onEnable=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.engine._componentsManager,t=rn.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()},rr._onDisable=function(){this._waitHandlingInValid=!0,this._engine._componentsManager.addDisableScript(this),this.onDisable()},rr._onDestroy=function(){this._engine._componentsManager.addPendingDestroyScript(this)},rr._handlingInValid=function(){var e=this.engine._componentsManager,t=rn.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},rn);sw([sA],uB.prototype,"_started",void 0),sw([sA],uB.prototype,"_onStartIndex",void 0),sw([sA],uB.prototype,"_onUpdateIndex",void 0),sw([sA],uB.prototype,"_onLateUpdateIndex",void 0),sw([sA],uB.prototype,"_onPhysicsUpdateIndex",void 0),sw([sA],uB.prototype,"_onPreRenderIndex",void 0),sw([sA],uB.prototype,"_onPostRenderIndex",void 0),sw([sA],uB.prototype,"_entityScriptsIndex",void 0),sw([sA],uB.prototype,"_waitHandlingInValid",void 0);var uD=(sT(ri=function(){return ux.apply(this,arguments)},ux),(ra=ri.prototype).createVertexElements=function(t){return t[0]=new ut("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ut("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new ut("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},ra.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},ra.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},ra.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},ra.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=lz._compileMacros;lR.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p),(t||f)._preRender(d);var g=d.shaderPass._getShaderProgram(n,p);if(!g.isValid)return;_.shaderData.setTexture(ri._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(_)}},ra.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,n=this._indiceBuffers,r=0,i=e.length;r<i;++r)e[r].destroy();this._meshes=null;for(var a=0,o=t.length;a<o;++a)t[a].destroy();this._vertexBuffers=null;for(var s=0,l=n.length;s<l;++s)n[s].destroy();this._indiceBuffers=null},ri);uD._textureProperty=lz.getPropertyByName("u_spriteTexture");var uI=((rs=(ro=function(e){this.items=[],this._spriteBatcher=new uD(e)}).prototype).pushPrimitive=function(e){this.items.push(e)},rs.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=lz._compileMacros,p=_.component,g=_.material.destroyed?a._magentaMaterial:_.material,m=p.shaderData,v=g.shaderData;(t||g)._preRender(_),lR.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)}},rs.clear=function(){this.items.length=0,this._spriteBatcher.clear()},rs.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rs.sort=function(e){this._quickSort(this.items,0,this.items.length,e)},rs._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=_)}},rs._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.component.priority-t.component.priority||e.component._distanceForSort-t.component._distanceForSort},ro._compareFromFarToNear=function(e,t){return e.component.priority-t.component.priority||t.component._distanceForSort-e.component._distanceForSort},ro),uO=function(){this.position=new sn,this.isOrthographic=!1,this.viewMatrix=new sc,this.projectionMatrix=new sc,this.viewProjectionMatrix=new sc,this.forward=new sn},uV=function(){this.virtualCamera=new uO,this.cullPlanes=[new so(new sn),new so(new sn),new so(new sn),new so(new sn),new so(new sn),new so(new sn),new so(new sn),new so(new sn),new so(new sn),new so(new sn)],this.splitBoundSphere=new sr(new sn,0)};(rl=oV||(oV={}))[rl.FarBottomLeft=0]="FarBottomLeft",rl[rl.FarTopLeft=1]="FarTopLeft",rl[rl.FarTopRight=2]="FarTopRight",rl[rl.FarBottomRight=3]="FarBottomRight",rl[rl.nearBottomLeft=4]="nearBottomLeft",rl[rl.nearTopLeft=5]="nearTopLeft",rl[rl.nearTopRight=6]="nearTopRight",rl[rl.nearBottomRight=7]="nearBottomRight",rl[rl.unknown=8]="unknown";var uU=((ru=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}},ru.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},ru.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},ru.shadowCullFrustum=function(e,t,n,r){var i=n._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&n.castShadows&&ru.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time._frameCount,n._prepareRender(e))},ru.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,u=Math.sqrt(1+s*s)*Math.tan(st.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,sn.scale(r,a,_),sn.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},ru.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=ru._frustumCorners,s=ru._backPlaneFaces,l=ru._frustumPlaneNeighbors,u=ru._frustumTwoPlaneCorners,c=ru._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=ru._adjustNearPlane,y=ru._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),sa.intersectionPointThreePlanes(v,g,p,o[7]),sa.intersectionPointThreePlanes(v,m,p,o[6]),sa.intersectionPointThreePlanes(v,m,f,o[5]),sa.intersectionPointThreePlanes(v,g,f,o[4]),sa.intersectionPointThreePlanes(y,g,p,o[3]),sa.intersectionPointThreePlanes(y,m,p,o[2]),sa.intersectionPointThreePlanes(y,m,f,o[1]),sa.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>sn.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]];sn.add(L,i,c),so.fromPoints(L,B,c,h[S++])}}a.cullPlaneCount=S},ru.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-ru.atlasBorderSize),_=2*d,f=a/_,p=_/a,g=Math.ceil(sn.dot(u,e)*f)*p,m=Math.ceil(sn.dot(u,t)*f)*p,v=sn.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;sn.scale(n,c+i,x),sn.subtract(u,x,x),sc.lookAt(x,u,e,T),sc.ortho(-d,d,-d,d,0,2*c+i,C);var S=y.viewProjectionMatrix;sc.multiply(C,T,S),uh._floatMatrixMultiply(ru._shadowMapCoordMatrix,S.elements,0,s,16*r)},ru.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},ru.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)},ru.applySliceTransform=function(e,t,n,r,i,a){var o=ru._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;uh._floatMatrixMultiply(o,a,d,a,d)},ru);uU._tempMatrix0=new sc,uU._shadowMapCoordMatrix=new sc(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),uU._frustumCorners=[new sn,new sn,new sn,new sn,new sn,new sn,new sn,new sn],uU._adjustNearPlane=new so(new sn),uU._adjustFarPlane=new so(new sn),uU._backPlaneFaces=[,,,,,],uU._edgePlanePoint2=new sn,uU._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]],uU._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]]],uU.atlasBorderSize=4;var uN=function(){function t(n){this._shadowMapSize=new s_,this._shadowBias=new sd,this._shadowSliceData=new uV,this._lightUp=new sn,this._lightSide=new sn,this._existShadowMap=!1,this._splitBoundSpheres=new Float32Array(4*t._maxCascades),this._shadowMatrices=new Float32Array((t._maxCascades+1)*16),this._shadowInfos=new sn,this._viewportOffsets=[new sd,new sd,new sd,new sd],this._camera=n,this._engine=n.engine,this._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),this._shadowCasterShader=lz.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,null,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,sc.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(uU.getBoundSphereByFrustum(m[P],m[P+1],i,t._tempVector.normalize(),s),uU.getDirectionLightShadowCullPlanes(i._frustum,m[P],i.nearClipPlane,S,s),uU.getDirectionalLightMatrices(T,C,S,P,b.shadowNearPlane,F,s,u),g>1){var E=this._shadowMapSize;uU.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)uU.shadowCullFrustum(n,b,I[O],s);if(h.items.length||d.items.length){h.sort(uI._compareFromNearToFar),d.sort(uI._compareFromNearToFar);var V=o[P],U=V.x,N=V.y;p.setGlobalDepthBias(1,1),p.viewport(U,N,F,F),p.scissor(U+1,N+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*st.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 sj(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 sK(t,i,a,null,o):this._renderTargets=new sK(t,i,a,o)),s},n._updateShadowSettings=function(){var t=this._camera.scene,n=uU.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=uU.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=uU.getMaxTileResolutionInAtlas(r,r,i);this._shadowTileResolution=a;var o=2*a,s=i==e.ShadowCascadesMode.TwoCascades?a:2*a;this._shadowMapSize.set(1/o,1/s,o,s)}this._renderTargets=null;var l=this._viewportOffsets,u=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:l[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:l[0].set(0,0),l[1].set(u,0);break;case e.ShadowCascadesMode.FourCascades:l[0].set(0,0),l[1].set(u,0),l[2].set(0,u),l[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var i=n.virtualCamera;uU.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}();uN._lightShadowBiasProperty=lz.getPropertyByName("u_shadowBias"),uN._lightDirectionProperty=lz.getPropertyByName("u_lightDirection"),uN._shadowMatricesProperty=lz.getPropertyByName("u_shadowMatrices"),uN._shadowMapSize=lz.getPropertyByName("u_shadowMapSize"),uN._shadowInfosProperty=lz.getPropertyByName("u_shadowInfo"),uN._shadowMapsProperty=lz.getPropertyByName("u_shadowMap"),uN._shadowSplitSpheresProperty=lz.getPropertyByName("u_shadowSplitSpheres"),uN._maxCascades=4,uN._cascadesSplitDistance=Array(uN._maxCascades+1),uN._clearColor=new sf(1,1,1,1),uN._tempVector=new sn,uN._tempMatrix0=new sc;var uz=0,uk=((rh=(rc=function(t,n,r,i,a){void 0===t&&(t="RENDER_PASS"+uz++),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){},rc),uG=((r_=(rd=function(e){this._allSpriteMasks=new s5,this._lastCanvasSize=new sd,this._camera=e;var t=e.engine;this._opaqueQueue=new uI(t),this._alphaTestQueue=new uI(t),this._transparentQueue=new uI(t),this._cascadedShadowCaster=new uN(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 sb(e,uk)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},r_.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):sb(e,uk)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},r_.getRenderPass=function(e){for(var t=0,n=this._renderPassArray.length;t<n;t++){var r=this._renderPassArray[t];if(r.name===e)return r}return null},r_.destroy=function(){this._opaqueQueue.destroy(),this._alphaTestQueue.destroy(),this._transparentQueue.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},r_.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(uI._compareFromNearToFar),l.sort(uI._compareFromNearToFar),u.sort(uI._compareFromFarToNear);for(var c=0,h=this._renderPassArray.length;c<h;c++)this._drawRenderPass(t,this._renderPassArray[c],a,n,r)},r_._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)},r_.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)}},r_._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,lz._compileMacros);s.bind(),s.uploadAll(s.materialUniformBlock,i.shaderData),s.uploadUnGroupTextures(),i.renderState._apply(t,!1),r.drawPrimitive(o,o.subMesh,s)},r_._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))}},sy(rd,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rd);uG._tempVector0=new sn,uG._tempVector1=new sn;var uH=function(){};uH.tempVec4=new s_,uH.tempVec3=new sn,uH.tempVec2=new sd,e.Camera=(sT(rf=function(t){(n=lt.call(this,t)||this).shaderData=new lk(oM.Camera),n.priority=0,n.enableFrustumCulling=!0,n.clearFlags=e.CameraClearFlags.All,n.cullingMask=e.Layer.Everything,n._globalShaderMacro=new lR,n._frustum=new ss,n._virtualCamera=new uO,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 s_(0,0,1,1),n._inverseProjectionMatrix=new sc,n._lastAspectSize=new sd(0,0),n._invViewProjMat=new sc;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 uG(sm(n)),n.shaderData._addRefCount(1),n},lt),(rp=rf.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},rp.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},rp.worldToViewportPoint=function(e,t){var n=uH.tempVec3,r=uH.tempVec4;sn.transformCoordinate(e,this.viewMatrix,n),sn.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},rp.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},rp.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 sn.subtract(i,r,i),i.normalize(),t},rp.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},rp.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},rp.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},rp.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},rp.screenPointToRay=function(e,t){var n=uH.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},rp.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,i=this.entity.transform;sc.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(),lR.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,sz.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},rp._onEnable=function(){this.entity.scene._attachRenderCamera(this)},rp._onDisable=function(){this.entity.scene._detachRenderCamera(this)},rp._onDestroy=function(){var e;null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this.shaderData._addRefCount(-1)},rp._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},rp._innerViewportToWorldPoint=function(e,t,n,r,i){var a=uH.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),sn.transformCoordinate(a,r,i),i},rp._updateShaderData=function(){var t=this.shaderData;t.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition)},rp._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,sc.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},rp._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,sc.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},sy(rf,[{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;sc.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;sc.ortho(-i,i,-a,a,this._nearClipPlane,this._farClipPlane,t)}else sc.perspective(st.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}}]),(oU=rf)._inverseViewMatrixProperty=lz.getPropertyByName("u_viewInvMat"),oU._cameraPositionProperty=lz.getPropertyByName("u_cameraPos"),oU),sw([sP],e.Camera.prototype,"_frustum",void 0),sw([sA],e.Camera.prototype,"_renderPipeline",void 0),sw([sA],e.Camera.prototype,"_virtualCamera",void 0),sw([sA],e.Camera.prototype,"_frustumViewChangeFlag",void 0),sw([sA],e.Camera.prototype,"_transform",void 0),sw([sA],e.Camera.prototype,"_isViewMatrixDirty",void 0),sw([sA],e.Camera.prototype,"_isInvViewProjDirty",void 0),sw([sP],e.Camera.prototype,"_viewport",void 0),sw([sP],e.Camera.prototype,"_inverseProjectionMatrix",void 0),sw([sP],e.Camera.prototype,"_lastAspectSize",void 0),sw([sP],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=sw([s9(lr)],e.Camera);var uW={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},uX=1/0;function uK(e,t){return void 0===t&&(t={}),new s$(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:uX,t.type=null!=(l=t.type)?l:uW[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?uj:uq,_=new uY(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 uj(e,t){return new s$(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 uq(e,t){return new s$(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 uY=((rm=(rg=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()},rm.stop=function(){clearTimeout(this._timeoutId)},rm.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)})},rg),uQ=((rv=function(e){this.useCache=e,this.request=uK}).registerClass=function(e,t){this._engineObjects[e]=t},rv.getClass=function(e){return this._engineObjects[e]},rv);uQ._engineObjects={},e.AssetType=void 0,(ry=e.AssetType||(e.AssetType={})).Text="text",ry.JSON="json",ry.Buffer="buffer",ry.Texture2D="texture2d",ry.TextureCube="texture-cube",ry.Material="material",ry.Mesh="mesh",ry.AnimationClip="AnimationClip",ry.AnimatorController="AnimatorController",ry.Prefab="prefab",ry.KTX="ktx",ry.KTXCube="ktx-cube",ry.Sprite="sprite",ry.SpriteAtlas="sprite-atlas",ry.Env="environment",ry.Scene="scene",ry.HDR="HDR",ry.Font="font",ry.SourceFont="source-font",e.BlendMode=void 0,(rx=e.BlendMode||(e.BlendMode={}))[rx.Normal=0]="Normal",rx[rx.Additive=1]="Additive",e.RenderFace=void 0,(rT=e.RenderFace||(e.RenderFace={}))[rT.Front=0]="Front",rT[rT.Back=1]="Back",rT[rT.Double=2]="Double";var uJ=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}sT(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},sy(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 lZ),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}(l$);uJ._baseColorProp=lz.getPropertyByName("u_baseColor"),uJ._baseTextureProp=lz.getPropertyByName("u_baseTexture"),uJ._baseTextureMacro=lz.getMacroByName("BASETEXTURE"),uJ._tilingOffsetProp=lz.getPropertyByName("u_tilingOffset"),uJ._normalTextureProp=lz.getPropertyByName("u_normalTexture"),uJ._normalIntensityProp=lz.getPropertyByName("u_normalIntensity"),uJ._normalTextureMacro=lz.getMacroByName("NORMALTEXTURE"),uJ._emissiveColorProp=lz.getPropertyByName("u_emissiveColor"),uJ._emissiveTextureProp=lz.getPropertyByName("u_emissiveTexture"),uJ._emissiveTextureMacro=lz.getMacroByName("EMISSIVETEXTURE"),uJ._transparentMacro=lz.getMacroByName("OASIS_TRANSPARENT"),uJ._alphaCutoffProp=lz.getPropertyByName("u_alphaCutoff"),uJ._alphaCutoffMacro=lz.getMacroByName("ALPHA_CUTOFF");var uZ=function(e){function t(n){var r,i=(r=e.call(this,n,lz.find("blinn-phong"))||this).shaderData;return i.enableMacro("O3_NEED_WORLDPOS"),i.enableMacro("O3_NEED_TILINGOFFSET"),i.setColor(t._baseColorProp,new sf(1,1,1,1)),i.setColor(t._specularColorProp,new sf(1,1,1,1)),i.setColor(t._emissiveColorProp,new sf(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new s_(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return sT(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sy(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}(uJ);uZ._specularColorProp=lz.getPropertyByName("u_specularColor"),uZ._shininessProp=lz.getPropertyByName("u_shininess"),uZ._specularTextureProp=lz.getPropertyByName("u_specularTexture"),e.TextureCoordinate=void 0,(rC=e.TextureCoordinate||(e.TextureCoordinate={}))[rC.UV0=0]="UV0",rC[rC.UV1=1]="UV1",rC[rC.UV2=2]="UV2",rC[rC.UV3=3]="UV3",rC[rC.UV4=4]="UV4",rC[rC.UV5=5]="UV5",rC[rC.UV6=6]="UV6",rC[rC.UV7=7]="UV7";var u$=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 sf(1,1,1,1)),o.setColor(n._emissiveColorProp,new sf(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new s_(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 sT(n,t),sy(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&&sz.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}(uJ);u$._occlusionTextureIntensityProp=lz.getPropertyByName("u_occlusionIntensity"),u$._occlusionTextureCoordProp=lz.getPropertyByName("u_occlusionTextureCoord"),u$._occlusionTextureProp=lz.getPropertyByName("u_occlusionTexture"),u$._clearCoatProp=lz.getPropertyByName("u_clearCoat"),u$._clearCoatTextureProp=lz.getPropertyByName("u_clearCoatTexture"),u$._clearCoatRoughnessProp=lz.getPropertyByName("u_clearCoatRoughness"),u$._clearCoatRoughnessTextureProp=lz.getPropertyByName("u_clearCoatRoughnessTexture"),u$._clearCoatNormalTextureProp=lz.getPropertyByName("u_clearCoatNormalTexture");var u0=function(e){function t(n){var r;return(r=e.call(this,n,lz.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r.shaderData.setFloat(t._iorProp,1.5),r}return sT(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sy(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}(u$);u0._metallicProp=lz.getPropertyByName("u_metal"),u0._roughnessProp=lz.getPropertyByName("u_roughness"),u0._roughnessMetallicTextureProp=lz.getPropertyByName("u_roughnessMetallicTexture"),u0._iorProp=lz.getPropertyByName("material_IOR");var u1=function(e){function t(n){var r;return(r=e.call(this,n,lz.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new sf(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return sT(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sy(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}(u$);u1._specularColorProp=lz.getPropertyByName("u_PBRSpecularColor"),u1._glossinessProp=lz.getPropertyByName("u_glossiness"),u1._specularGlossinessTextureProp=lz.getPropertyByName("u_specularGlossinessTexture"),u1._specularGlossinessTextureMacro=lz.getMacroByName("SPECULARGLOSSINESSTEXTURE");var u2=function(e){function t(n){var r,i=(r=e.call(this,n,lz.find("unlit"))||this).shaderData;return i.enableMacro("OMIT_NORMAL"),i.enableMacro("O3_NEED_TILINGOFFSET"),i.setColor(t._baseColorProp,new sf(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new s_(1,1,0,0)),r}return sT(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sy(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}(uJ);e.TextHorizontalAlignment=void 0,(rS=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[rS.Left=0]="Left",rS[rS.Center=1]="Center",rS[rS.Right=2]="Right",e.TextVerticalAlignment=void 0,(rw=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[rw.Top=0]="Top",rw[rw.Center=1]="Center",rw[rw.Bottom=2]="Bottom",e.OverflowMode=void 0,(rb=e.OverflowMode||(e.OverflowMode={}))[rb.Overflow=0]="Overflow",rb[rb.Truncate=1]="Truncate",e.FontStyle=void 0,(rA=e.FontStyle||(e.FontStyle={}))[rA.None=0]="None",rA[rA.Bold=1]="Bold",rA[rA.Italic=2]="Italic";var u3=(sT(rM=function(e){var t;return(t=sL.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},sL),(rF=rM.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},rF.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},rF._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1},rF._onDestroy=function(){this._sprites=null,this._spriteNamesToIndex=null},sy(rM,[{key:"sprites",get:function(){return this._sprites}}]),rM);e.SpriteDrawMode=void 0,(rP=e.SpriteDrawMode||(e.SpriteDrawMode={}))[rP.Simple=0]="Simple",rP[rP.Sliced=1]="Sliced";var u4=(sT(rE=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=sL.call(this,e)||this)._width=void 0,o._height=void 0,o._positions=[new sd,new sd,new sd,new sd],o._uvs=[new sd,new sd,new sd,new sd],o._bounds=new si,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new sp(0,0,1,1),o._atlasRegionOffset=new s_(0,0,0,0),o._region=new sp(0,0,1,1),o._pivot=new sd(.5,.5),o._border=new s_(0,0,0,0),o._dirtyUpdateFlag=3,o._updateFlagManager=new ln,o._texture=t,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),i&&o._border.copyFrom(i),o.name=a,o},sL),(rR=rE.prototype).clone=function(){var e=new rE(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},rR._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},rR._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},rR._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},rR._onDestroy=function(){this._texture&&(this._texture=null)},rR._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/uL._pixelsPerUnit;this._width=e.width*t.width/(1-n.x-n.z)*r.width*i,this._height=e.height*t.height/(1-n.y-n.w)*r.height*i}},rR._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},rR._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},rR._dispatchSpriteChange=function(e){switch(e){case oR.atlasRegionOffset:case oR.region:this._dirtyUpdateFlag|=3;break;case oR.atlasRegion:case oR.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},sy(rE,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(oR.texture),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oR.size))}},{key:"width",get:function(){return void 0===this._width&&this._calDefaultSize(),this._width},set:function(e){this._width!==e&&(this._width=e,this._dispatchSpriteChange(oR.size))}},{key:"height",get:function(){return void 0===this._height&&this._calDefaultSize(),this._height},set:function(e){this._height!==e&&(this._height=e,this._dispatchSpriteChange(oR.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=st.clamp(e.x,0,1),n=st.clamp(e.y,0,1);this._atlasRegion.set(t,n,st.clamp(e.width,0,1-t),st.clamp(e.height,0,1-n)),this._dispatchSpriteChange(oR.atlasRegion),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oR.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=st.clamp(e.x,0,1),n=st.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,st.clamp(e.z,0,1-t),st.clamp(e.w,0,1-n)),this._dispatchSpriteChange(oR.atlasRegionOffset),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oR.size)}},{key:"region",get:function(){return this._region},set:function(e){var t=this._region,n=st.clamp(e.x,0,1),r=st.clamp(e.y,0,1);t.set(n,r,st.clamp(e.width,0,1-n),st.clamp(e.height,0,1-r)),this._dispatchSpriteChange(oR.region),(void 0===this._width||void 0===this._height)&&this._dispatchSpriteChange(oR.size)}},{key:"pivot",get:function(){return this._pivot},set:function(e){var t=this._pivot;if(t===e)this._dispatchSpriteChange(oR.pivot);else{var n=e.x,r=e.y;(t.x!==n||t.y!==r)&&(t.set(n,r),this._dispatchSpriteChange(oR.pivot))}}},{key:"border",get:function(){return this._border},set:function(e){var t=this._border,n=st.clamp(e.x,0,1),r=st.clamp(e.y,0,1);t.set(n,r,st.clamp(e.z,0,1-n),st.clamp(e.w,0,1-r)),this._dispatchSpriteChange(oR.border)}}]),rE);(rL=oN||(oN={}))[rL.positions=1]="positions",rL[rL.uvs=2]="uvs",rL[rL.all=3]="all";var u5=((rB=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 sn),r.push(new sd);t.triangles=[]},rB.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=u5._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,N=0;N<4;N++){for(var z=t[N],k=h[N].x,G=0;G<4;G++){var H=n[G];s[V].set(B[0]*z+B[4]*H+B[12],B[1]*z+B[5]*H+B[13],B[2]*z+B[6]*H+B[14]),l[V].set(k,h[G].y),++V}++U}for(var W=V/U,X=0,K=0;K<U-1;++K)for(var j=0;j<W-1;++j){var q=K*W+j;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)},rB.updateUVs=function(e){},rB._worldMatrix=new sc,rB);u5=sw([l8()],u5);var u8=(rD=e.Renderer,sT(rI=function(t){var n;return(n=rD.call(this,t)||this)._color=new sf(1,1,1,1),n._sprite=null,n._width=void 0,n._height=void 0,n._flipX=!1,n._flipY=!1,n._maskLayer=e.SpriteMaskLayer.Layer0,n._maskInteraction=e.SpriteMaskInteraction.None,n._renderData=new l7(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(sm(n)),n},rD),(rO=rI.prototype)._cloneTo=function(e){e.sprite=this._sprite},rO._onDestroy=function(){var e;null==(e=this._sprite)||e._updateFlagManager.removeListener(this._onSpriteChange),this._color=null,this._sprite=null,this._assembler=null,this._renderData=null,rD.prototype._onDestroy.call(this)},rO._updateBounds=function(e){var t;(null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},rO._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&oP.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~oP.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)}}},rO._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}},rO._onSpriteChange=function(t){switch(t){case oR.texture:this.shaderData.setTexture(rI._textureProperty,this.sprite.texture);break;case oR.size:(this._drawMode===e.SpriteDrawMode.Sliced||void 0===this._width||void 0===this._height)&&(this._dirtyUpdateFlag|=oP.WorldVolume);break;case oR.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case oR.region:case oR.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case oR.atlasRegion:this._dirtyUpdateFlag|=2;break;case oR.pivot:this._dirtyUpdateFlag|=oP.WorldVolume}},sy(rI,[{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=l6;break;case e.SpriteDrawMode.Sliced:this._assembler=u5}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._updateFlagManager.removeListener(this._onSpriteChange),e?(e._updateFlagManager.addListener(this._onSpriteChange),this._dirtyUpdateFlag|=3,this.shaderData.setTexture(rI._textureProperty,e.texture)):this.shaderData.setTexture(rI._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._width&&this._sprite&&(this.width=this._sprite.width),this._width},set:function(e){void 0===this._width&&this._sprite&&(this._width=this._sprite.width),this._width!==e&&(this._width=e,this._dirtyUpdateFlag|=oP.WorldVolume)}},{key:"height",get:function(){return void 0===this._height&&this._sprite&&(this.height=this._sprite.height),this._height},set:function(e){void 0===this._height&&this._sprite&&(this._height=this._sprite.height),this._height!==e&&(this._height=e,this._dirtyUpdateFlag|=oP.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=oP.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=oP.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())}}]),rI);u8._textureProperty=lz.getPropertyByName("u_spriteTexture"),sw([sA],u8.prototype,"_renderData",void 0),sw([sA],u8.prototype,"_drawMode",void 0),sw([sA],u8.prototype,"_assembler",void 0),sw([sP],u8.prototype,"_color",void 0),sw([sA],u8.prototype,"_sprite",void 0),sw([sA],u8.prototype,"_width",void 0),sw([sA],u8.prototype,"_height",void 0),sw([sM],u8.prototype,"_flipX",void 0),sw([sM],u8.prototype,"_flipY",void 0),sw([sM],u8.prototype,"_maskLayer",void 0),sw([sM],u8.prototype,"_maskInteraction",void 0),sw([sA],u8.prototype,"_onSpriteChange",null),(rV=oz||(oz={}))[rV.UV=2]="UV",rV[rV.All=3]="All";var u6=function e(){this.localPositions=new s_;var t=[new sn,new sn,new sn,new sn];this.renderData=new l7(4,t,null,e.triangles,null)};u6.triangles=[0,2,1,2,0,3];var u7=((rN=(rU=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},rN.put=function(e){this._elements.push(e)},rU),u9=((rz=function(){}).textContext=function(){var e=rz._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},rz._textContext=e}return e},rz.measureFont=function(e){var t=rz._fontSizeInfoCache,n=t[e];return n||(n=rz._measureFontOrChar(e),t[e]=n),n},rz.getNativeFontString=function(t,n,r){var i=r&e.FontStyle.Bold?"bold ":"";return r&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rz._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=n+"px "+t},rz.measureChar=function(e,t){return rz._measureFontOrChar(t,e)},rz.measureTextWithWrap=function(t){for(var n=t.fontSize,r=t.fontStyle,i=t._subFont,a=t.font.name,o=rz.getNativeFontString(a,n,r),s=rz.measureFont(o),l=t.text.split(/(?:\r\n|\r|\n)/),u=[],c=[],h=[],d=uL._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=rz._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}},rz.measureTextWithoutWrap=function(t){var n=t.fontSize,r=t.fontStyle,i=t._subFont,a=t.font.name,o=rz.getNativeFontString(a,n,r),s=rz.measureFont(o),l=t.text.split(/(?:\r\n|\r|\n)/),u=l.length,c=[],h=[],d=uL._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=rz._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}},rz.getNativeFontHash=function(t,n,r){var i=r&e.FontStyle.Bold?"bold":"";return r&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rz._genericFontFamilies.indexOf(t)||(t=""+t),i+=n+"px"+t},rz._measureFontOrChar=function(e,t){void 0===t&&(t="");var n,r=rz.textContext(),i=r.canvas,a=r.context;a.font=e;var o=t||rz._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(rz._measureBaseline).width),u=l*rz._heightMultiplier;l=rz._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 sd,new sd,new sd,new sd],ascent:f,descent:p,index:0,data:T}},rz._getCharInfo=function(e,t,n){var r=n._getCharInfo(e);return r||(r=rz.measureChar(e,t),n._uploadCharTexture(r),n._addCharInfo(e,r)),r},rz);u9._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],u9._measureString="|\xc9q\xc5",u9._measureBaseline="M",u9._heightMultiplier=2,u9._baselineMultiplier=1.4,u9._fontSizeInfoCache={},u9._textContext=null;var ce=(rk=e.Renderer,sT(rG=function(t){(n=rk.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new sf(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new si,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=sm(n).engine;return n._font=r._textDefaultFont,n._font._addRefCount(1),n.setMaterial(r._spriteDefaultMaterial),n},rk),(rH=rG.prototype)._onDestroy=function(){for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)rG._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addRefCount(-1),this._font=null),this._subFont&&(this._subFont=null),rk.prototype._onDestroy.call(this)},rH._cloneTo=function(e){e.font=this._font,e._subFont=this._subFont},rH._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},rH._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},rH._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},rH._updateBounds=function(e){si.transform(this._localBounds,this._entity.transform.worldMatrix,e)},rH._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)}},rH._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}},rH._resetSubFont=function(){this._subFont=this._font._getSubFont(this.fontSize,this.fontStyle)},rH._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=rG._tempVec31.set(a,o,s),d=rG._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];sn.scale(d,g.z-v,T),sn.add(x,T,T);var C=m[2];sn.scale(h,g.w-y,C),sn.add(x,C,m[3]),sn.add(T,C,C)}},rH._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=uL._pixelsPerUnit,u=1/l,c=this._subFont,h=.5*(this.width*l),d=this.height*l,_=this.enableWrapping?u9.measureTextWithWrap(this):u9.measureTextWithoutWrap(this),f=_.height,p=_.lines,g=_.lineWidths,m=_.lineHeight,v=_.lineMaxSizes,y=rG._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 N=i[b]||y.get(),z=N.renderData,k=N.localPositions;N.texture=c._getTextureByIndex(U.index),z.color=t,z.uvs=U.uvs;var G=U.w,H=U.ascent,W=U.descent,X=D*u,K=(D+G)*u,j=(C+H)*u,q=(C-W+1)*u;k.set(X,j,K,q),i[b]=N,b++,0===R&&(P=Math.max(P,j)),R===E&&(M=Math.min(M,q)),0===I&&(A=Math.min(A,X)),I===O&&(F=Math.max(F,K))}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})},rH._onTransformChanged=function(e){rk.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},sy(rG,[{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}}]),rG);ce._charRenderDataPool=new u7(u6,50),ce._tempVec30=new sn,ce._tempVec31=new sn,sw([sM],ce.prototype,"_subFont",void 0),sw([sA],ce.prototype,"_charRenderDatas",void 0),sw([sA],ce.prototype,"_dirtyFlag",void 0),sw([sP],ce.prototype,"_color",void 0),sw([sM],ce.prototype,"_text",void 0),sw([sM],ce.prototype,"_width",void 0),sw([sM],ce.prototype,"_height",void 0),sw([sA],ce.prototype,"_localBounds",void 0),sw([sM],ce.prototype,"_font",void 0),sw([sM],ce.prototype,"_fontSize",void 0),sw([sM],ce.prototype,"_fontStyle",void 0),sw([sM],ce.prototype,"_lineSpacing",void 0),sw([sM],ce.prototype,"_horizontalAlignment",void 0),sw([sM],ce.prototype,"_verticalAlignment",void 0),sw([sM],ce.prototype,"_enableWrapping",void 0),sw([sM],ce.prototype,"_overflowMode",void 0),sw([sM],ce.prototype,"_maskInteraction",void 0),sw([sM],ce.prototype,"_maskLayer",void 0),(rW=ok||(ok={}))[rW.SubFont=1]="SubFont",rW[rW.LocalPositionBounds=2]="LocalPositionBounds",rW[rW.WorldPosition=4]="WorldPosition",rW[rW.WorldBounds=8]="WorldBounds",rW[rW.MaskInteraction=16]="MaskInteraction",rW[rW.Position=14]="Position",rW[rW.Font=15]="Font";var ct=((rK=(rX=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]},rK.getTargetValue=function(){return this._mounted[this._propertyName]},rK.setTargetValue=function(e){this._mounted[this._propertyName]=e},rX),cn=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:ct},e}();cn._assemblerMap=new Map;var cr=((rq=(rj=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},rq.getTargetValue=function(){return this._transform.position},rq.setTargetValue=function(e){this._transform.position=e},rj);cn.registerAssembler(lr,"position",cr);var ci=((rQ=(rY=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},rQ.getTargetValue=function(){return this._transform.rotationQuaternion},rQ.setTargetValue=function(e){this._transform.rotationQuaternion=e},rY);cn.registerAssembler(lr,"rotationQuaternion",ci);var ca=((rZ=(rJ=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},rZ.getTargetValue=function(){return this._transform.scale},rZ.setTargetValue=function(e){this._transform.scale=e},rJ);cn.registerAssembler(lr,"scale",ca);var co=((r0=(r$=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(up)},r0.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},r0.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},r$);cn.registerAssembler(up,"blendShapeWeights",co);var cs=((r2=(r1=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new cn(e,this.type,this.property,t);return t._initializeOwner(n),n},r2._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},r1),cl=function(){},cu=((r4=(r3=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 cl;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})},r4.clearEvents=function(){this._events.length=0},r4.addCurveBinding=function(e,t,n,r){var i=new cs;i.relativePath=e,i.type=t,i.property=n,i.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(i)},r4.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},r4._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)}},sy(r3,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),r3);e.InterpolationType=void 0,(r5=e.InterpolationType||(e.InterpolationType={}))[r5.Linear=0]="Linear",r5[r5.CubicSpine=1]="CubicSpine",r5[r5.Step=2]="Step",r5[r5.Hermite=3]="Hermite";var cc=((r6=(r8=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)}},r6.evaluate=function(e){return this._evaluate(e,this._evaluateData)},r6.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},r6._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},r6._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},sy(r8,[{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}}]),r8);e.AnimationArrayCurve=(sT(r7=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=[],e},cc),r7._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},r7._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},r7._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},r7._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},r7._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},r7._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},r7._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},(oG=r7)._isReferenceType=!0,oG._isInterpolationType=!0,oG),e.AnimationArrayCurve=sw([l8()],e.AnimationArrayCurve),e.AnimationBoolCurve=(sT(r9=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=!1,e},cc),r9._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},r9._lerpValue=function(e,t){return t},r9._subtractValue=function(e,t,n){return e},r9._getZeroValue=function(){return!1},r9._additiveValue=function(e,t,n){return e},r9._copyValue=function(e){return e},r9._hermiteInterpolationValue=function(e){return e.value},(oH=r9)._isReferenceType=!1,oH._isInterpolationType=!1,oH),e.AnimationBoolCurve=sw([l8()],e.AnimationBoolCurve),e.AnimationColorCurve=(sT(ie=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=new sf,e},cc),ie._initializeOwner=function(e){e.defaultValue=new sf,e.fixedPoseValue=new sf,e.baseEvaluateData.value=new sf,e.crossEvaluateData.value=new sf},ie._lerpValue=function(e,t,n,r){return sf.lerp(e,t,n,r),r},ie._subtractValue=function(e,t,n){return sf.subtract(e,t,n),n},ie._getZeroValue=function(e){return e.set(0,0,0,0),e},ie._additiveValue=function(e,t,n){return sf.scale(e,t,e),sf.add(n,e,n),n},ie._copyValue=function(e,t){return t.copyFrom(e),t},ie._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},(oW=ie)._isReferenceType=!0,oW._isInterpolationType=!0,oW),e.AnimationColorCurve=sw([l8()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(sT(it=function(){return cc.apply(this,arguments)},cc),it.prototype.addKey=function(e){cc.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)}},it._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)},it._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},it._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},it._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},it._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},it._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},it._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},(oX=it)._isReferenceType=!0,oX._isInterpolationType=!0,oX),e.AnimationFloatArrayCurve=sw([l8()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(sT(ir=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=0,e},cc),ir._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},ir._lerpValue=function(e,t,n){return e+(t-e)*n},ir._additiveValue=function(e,t,n){return n+e*t},ir._subtractValue=function(e,t){return e-t},ir._getZeroValue=function(){return 0},ir._copyValue=function(e){return e},ir._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},(oK=ir)._isReferenceType=!1,oK._isInterpolationType=!0,oK),e.AnimationFloatCurve=sw([l8()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(sT(ii=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=new su,e},cc),ii._initializeOwner=function(e){e.defaultValue=new su,e.fixedPoseValue=new su,e.baseEvaluateData.value=new su,e.crossEvaluateData.value=new su},ii._lerpValue=function(e,t,n,r){return su.slerp(e,t,n,r),r},ii._additiveValue=function(e,t,n){return e.x=e.x*t,e.y=e.y*t,e.z=e.z*t,e.normalize(),n.multiply(e),n},ii._subtractValue=function(t,n,r){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return su.conjugate(n,i),su.multiply(i,t,r),r},ii._getZeroValue=function(e){return e.set(0,0,0,1),e},ii._copyValue=function(e,t){return t.copyFrom(e),t},ii._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,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},(oj=ii)._isInterpolationType=!0,oj._isReferenceType=!0,oj._tempConjugateQuat=new su,oj),e.AnimationQuaternionCurve=sw([l8()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(sT(ia=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=new sd,e},cc),ia._initializeOwner=function(e){e.defaultValue=new sd,e.fixedPoseValue=new sd,e.baseEvaluateData.value=new sd,e.crossEvaluateData.value=new sd},ia._lerpValue=function(e,t,n,r){return sd.lerp(e,t,n,r),r},ia._additiveValue=function(e,t,n){return sd.scale(e,t,e),sd.add(n,e,n),n},ia._subtractValue=function(e,t,n){return sd.subtract(e,t,n),n},ia._getZeroValue=function(e){return e.set(0,0),e},ia._copyValue=function(e,t){return t.copyFrom(e),t},ia._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},(oq=ia)._isReferenceType=!0,oq._isInterpolationType=!0,oq),e.AnimationVector2Curve=sw([l8()],e.AnimationVector2Curve),e.AnimationVector3Curve=(sT(io=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=new sn,e},cc),io._initializeOwner=function(e){e.defaultValue=new sn,e.fixedPoseValue=new sn,e.baseEvaluateData.value=new sn,e.crossEvaluateData.value=new sn},io._lerpValue=function(e,t,n,r){return sn.lerp(e,t,n,r),r},io._relativeBaseValue=function(e,t){return sn.subtract(t,e,t),t},io._additiveValue=function(e,t,n){return sn.scale(e,t,e),sn.add(n,e,n),n},io._subtractValue=function(e,t,n){return sn.subtract(e,t,n),n},io._getZeroValue=function(e){return e.set(0,0,0),e},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.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},(oY=io)._isReferenceType=!0,oY._isInterpolationType=!0,oY),e.AnimationVector3Curve=sw([l8()],e.AnimationVector3Curve),e.AnimationVector4Curve=(sT(is=function(){var e;return(e=cc.call(this)||this)._evaluateData.value=new s_,e},cc),is._initializeOwner=function(e){e.defaultValue=new s_,e.fixedPoseValue=new s_,e.baseEvaluateData.value=new s_,e.crossEvaluateData.value=new s_},is._lerpValue=function(e,t,n,r){return s_.lerp(e,t,n,r),r},is._additiveValue=function(e,t,n){return s_.scale(e,t,e),s_.add(n,e,n),n},is._subtractValue=function(e,t,n){return s_.subtract(e,t,n),n},is._getZeroValue=function(e){return e.set(0,0,0,0),e},is._copyValue=function(e,t){return t.copyFrom(e),t},is._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},(oQ=is)._isReferenceType=!0,oQ._isInterpolationType=!0,oQ),e.AnimationVector4Curve=sw([l8()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(il=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[il.None=0]="None",il[il.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iu=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iu.Override=0]="Override",iu[iu.Additive=1]="Additive",(ic=oJ||(oJ={}))[ic.UnStarted=0]="UnStarted",ic[ic.Playing=1]="Playing",ic[ic.Finished=2]="Finished",(ih=oZ||(oZ={}))[ih.Standby=0]="Standby",ih[ih.Playing=1]="Playing",ih[ih.CrossFading=2]="CrossFading",ih[ih.FixedCrossFading=3]="FixedCrossFading";var ch=function(){this.handlers=[]},cd=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(id=e.WrapMode||(e.WrapMode={}))[id.Once=0]="Once",id[id.Loop=1]="Loop";var c_=((ip=(i_=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=oJ.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0},ip.update=function(t){var n=this.state,r=this.frameTime,i=n._getDuration();this.playState=oJ.Playing,n.wrapMode===e.WrapMode.Loop?r=i?r%i:0:Math.abs(r)>i&&(r=r<0?-i:i,this.playState=oJ.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=i),this.clipTime=r+n.clipStartTime*n.clip.length)},i_),cf=((ig=function(){this.animatorStateDataMap={},this.srcPlayData=new c_,this.destPlayData=new c_,this.layerState=oZ.Standby,this.crossCurveMark=0,this.manuallyTransition=new cd}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},ig),cp=function(){this.curveOwners=[],this.eventHandlers=[]},cg=(sT(im=function(t){var n;return(n=lt.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._animatorLayersData=[],n._crossOwnerCollection=[],n._animationCurveOwners=[],n._animationEventHandlerPool=new l0(ch),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},lt),(iv=im.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=oZ.Playing,o.srcPlayData.reset(a,s,a._getDuration()*n)}},iv.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)},iv.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!==oZ.Standby&&this._updateLayer(l,0===l,t/1e3,r)}},iv.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},iv.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iv._onEnable=function(){this.engine._componentsManager.addOnUpdateAnimations(this),this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iv._onDisable=function(){this.engine._componentsManager.removeOnUpdateAnimations(this)},iv._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)},iv._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},iv._saveDefaultValues=function(e){for(var t,n=e.curveOwners,r=n.length-1;r>=0;r--)null==(t=n[r])||t.saveDefaultValue()},iv._getAnimatorStateData=function(e,t,n){var r=n.animatorStateDataMap,i=r[e];return i||(i=new cp,r[e]=i,this._saveAnimatorStateData(t,i),this._saveAnimatorEventHandlers(t,i)),i},iv._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+".")}},iv._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)}},iv._clearCrossData=function(e){e.crossCurveMark++,this._crossOwnerCollection.length=0},iv._addCrossCurveData=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.push(t)},iv._prepareCrossFading=function(e){var t=this._crossOwnerCollection,n=e.crossCurveMark;this._prepareSrcCrossData(t,e.srcPlayData,n,!1),this._prepareDestCrossData(t,e.destPlayData,n,!1)},iv._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)},iv._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)},iv._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))}},iv._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)))}},iv._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new cf),t},iv._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!==oZ.FixedCrossFading&&this._checkTransition(u,h,t),l.layerState){case oZ.Playing:this._updatePlayingState(u,l,t,s,r,d,i);break;case oZ.FixedCrossFading:this._updateCrossFadeFromPose(c,l,t,s,r,d,i);break;case oZ.CrossFading:this._updateCrossFade(u,c,l,t,s,r,d,i)}},iv._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===oJ.Finished&&(t.layerState=oZ.Standby),h===oJ.UnStarted&&this._callAnimatorScriptOnEnter(c,n),p===oJ.Finished?this._callAnimatorScriptOnExit(c,n):this._callAnimatorScriptOnUpdate(c,n)}},iv._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===oJ.UnStarted&&this._callAnimatorScriptOnEnter(c,r),1===T||C===oJ.Finished?this._callAnimatorScriptOnExit(c,r):this._callAnimatorScriptOnUpdate(c,r),g===oJ.UnStarted&&this._callAnimatorScriptOnEnter(f,r),S===oJ.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)}}},iv._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===oJ.UnStarted&&this._callAnimatorScriptOnEnter(l,n),p===oJ.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)}}},iv._updateCrossFadeData=function(e,t,n,r){var i=e.destPlayData;i.frameTime+=i.state.speed*n,1===t?(i.playState===oJ.Finished?e.layerState=oZ.Standby:e.layerState=oZ.Playing,e.switchPlayData(),e.crossFadeTransition=null):r||(e.srcPlayData.frameTime+=e.srcPlayData.state.speed*n)},iv._preparePlay=function(e,t,n){if(e.layerState===oZ.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)}},iv._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)}},iv._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 oZ.Standby:a.layerState=oZ.FixedCrossFading,this._clearCrossData(a),this._prepareStandbyCrossFading(a);break;case oZ.Playing:a.layerState=oZ.CrossFading,this._clearCrossData(a),this._prepareCrossFading(a);break;case oZ.CrossFading:a.layerState=oZ.FixedCrossFading,this._prepareFixedPoseCrossFading(a);break;case oZ.FixedCrossFading:this._prepareFixedPoseCrossFading(a)}a.crossFadeTransition=e}},iv._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)},iv._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)}}},iv._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)}}},iv._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},iv._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},iv._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},iv._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)}},sy(im,[{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)}}]),im);sw([sM],cg.prototype,"speed",void 0),sw([sA],cg.prototype,"_controllerUpdateFlag",void 0),sw([sA],cg.prototype,"_animatorLayersData",void 0),sw([sA],cg.prototype,"_crossOwnerCollection",void 0),sw([sA],cg.prototype,"_animationCurveOwners",void 0),sw([sA],cg.prototype,"_animationEventHandlerPool",void 0),sw([sA],cg.prototype,"_tempAnimatorStateInfo",void 0),sw([sA],cg.prototype,"_controlledRenderers",void 0);var cm=((ix=(iy=function(){this._updateFlagManager=new ln,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},ix.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},ix.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},ix.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},ix._registerChangeFlag=function(){return this._updateFlagManager.createFlag(le)},sy(iy,[{key:"layers",get:function(){return this._layers}}]),iy),cv=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},cy=((iC=(iT=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},iC.onStateUpdate=function(e,t,n){},iC.onStateExit=function(e,t,n){},iC.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iT),cx=((iw=(iS=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)},iw.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},iw.addStateMachineScript=function(e){var t=new e;t._state=this;var n=cy.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},iw.clearTransitions=function(){this._transitions.length=0},iw._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iw._removeStateMachineScript=function(e){var t=cy.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)}},sy(iS,[{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)}}]),iS),cT=((iA=(ib=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 cx(e),this.states.push(t),this._statesMap[e]=t),t},iA.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},iA.findStateByName=function(e){return this._statesMap[e]},iA.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},ib);e.AnimatorConditionMode=void 0,(iM=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[iM.If=0]="If",iM[iM.IfNot=1]="IfNot",iM[iM.Greater=2]="Greater",iM[iM.Less=3]="Less",iM[iM.Equals=4]="Equals",iM[iM.NotEquals=5]="NotEquals";var cC=function(){},cS=(sT(iF=function(t){var n;return(n=l$.call(this,t,lz.find("skybox"))||this)._decodeParam=new s_(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},l$),sy(iF,[{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)}}]),iF);(iP=o$||(o$={}))[iP.Position=1]="Position",iP[iP.Velocity=2]="Velocity",iP[iP.Acceleration=4]="Acceleration",iP[iP.Color=8]="Color",iP[iP.Alpha=16]="Alpha",iP[iP.Size=32]="Size",iP[iP.StartAngle=64]="StartAngle",iP[iP.StartTime=128]="StartTime",iP[iP.LifeTime=256]="LifeTime",iP[iP.RotateVelocity=512]="RotateVelocity",iP[iP.Scale=1024]="Scale",iP[iP.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(iE=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[iE.Transparent=0]="Transparent",iE[iE.Additive=1]="Additive";var cw=(sT(iR=function(e){var t;return(t=uc.call(this,e)||this)._maxCount=1e3,t._position=new sn,t._positionRandomness=new sn,t._velocity=new sn,t._velocityRandomness=new sn,t._acceleration=new sn,t._accelerationRandomness=new sn,t._color=new sf(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(sm(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},uc),(iL=iR.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)}},iL._onEnable=function(){uc.prototype._onEnable.call(this),this._playOnEnable&&this.start()},iL.start=function(){this._isStart=!0,this._time=0},iL.stop=function(){this._isStart=!1},iL._createMaterial=function(){var t=new l$(this.engine,lz.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},iL._createMesh=function(){var t=new um(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,i=new Float32Array(r),a=null,o=!1;if(n>iR._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 ut("a_position",0,e.VertexElementFormat.Vector3,0),new ut("a_velocity",12,e.VertexElementFormat.Vector3,0),new ut("a_acceleration",24,e.VertexElementFormat.Vector3,0),new ut("a_color",36,e.VertexElementFormat.Vector4,0),new ut("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new ut("a_rotation",68,e.VertexElementFormat.Vector2,0),new ut("a_uv",76,e.VertexElementFormat.Vector3,0),new ut("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new un(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new un(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},iL._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},iL._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,i=iR._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]=st.clamp(T.r+i()*C,0,1),n[o+10]=n[s+10]=n[l+10]=n[u+10]=st.clamp(T.g+i()*C,0,1),n[o+11]=n[s+11]=n[l+11]=n[u+11]=st.clamp(T.b+i()*C,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[u+12]=st.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)},iL._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},iL._onColorChanged=function(){this._updateDirtyFlag|=8},iR._getRandom=function(){return Math.random()-.5},sy(iR,[{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}}]),iR);cw._uint16VertexLimit=65535,sw([sA],cw.prototype,"_onColorChanged",null),lz.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 cb=(sT(iB=function(t){var n,r=(n=l$.call(this,t,lz.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},l$),iB),cA=new sn,cM=(sT(iD=function(e,t){(n=uc.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 sn),n._pointStates.push(n._lifetime),n._strapPoints.push(new sn),n._strapPoints.push(new sn);n._curPointNum=0;var i=t.material||new cb(n.engine);return n.setMaterial(i),n.setTexture(t.texture),n._initGeometry(),n},uc),(iI=iD.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];sn.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++)},iI.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},iI._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),uc.prototype._render.call(this,e)},iI._initGeometry=function(){var t=new um(this._entity.engine),n=2*this._maxPointNum,r=20*n,i=new Float32Array(r),a=[new ut("POSITION",0,e.VertexElementFormat.Vector3,0),new ut("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new un(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},iI._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new sn(n[0],n[4],n[8]),i=new sn(n[1],n[5],n[9]),a=new sn(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new sn,l=new sn,u=new su;sn.transformByQuat(r,u,r),sn.transformByQuat(i,u,i);var c=new sn,h=new sn,d=new sn;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?sn.subtract(p,t[f-1],d):sn.subtract(t[f+1],p,d),this._projectOnPlane(d,a,d),d.normalize();var g=Math.acos(sn.dot(r,d));sn.cross(r,d,h),0>=sn.dot(h,a)&&(g=2*Math.PI-g),su.rotationAxisAngle(a,g,u),sn.transformByQuat(i,u,c),sn.add(p,c,s),sn.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}},iI._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}}},iI._projectOnVector=function(e,t,n){var r=t.clone();sn.normalize(r,r);var i=sn.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},iI._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,cA),sn.subtract(e,cA,n)},iD),cF=(sT(iO=function(){var t;return t=uB.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},uB),(iV=iO.prototype).onTextureChange=function(e){},iV.onBeginRender=function(t){this.enabled&&(this._camera=t,this._oriCameraCullingMask=t.cullingMask,t.cullingMask=this.probeLayer,this._activeRenderTarget&&this._activeRenderTarget.width===this.width&&this._activeRenderTarget.height===this.height&&this._activeRenderTarget.antiAliasing===this.antiAliasing||(this._renderTarget=new sK(this.engine,this.width,this.height,this._isCube?new sY(this.engine,this.width):new sj(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new sK(this.engine,this.width,this.height,this._isCube?new sY(this.engine,this.width):new sj(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},iV.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},iV._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},sy(iO,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),iO),cP=new sn,cE=new sn,cR=new sn,cL=(sT(iU=function(){var e;return e=cF.apply(this,arguments)||this,e.position=new sn(0,0,0),e._isCube=!0,e.oriViewMatrix=new sc,e},cF),(iN=iU.prototype).onBeginRender=function(t){if(this.enabled){cF.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),cF.prototype._reset.call(this)}},iN._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},iN._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},iN._setCamera=function(e,t){switch(e){case 0:cE.set(0,-1,0),cR.set(1,0,0);break;case 1:cE.set(0,-1,0),cR.set(-1,0,0);break;case 2:cE.set(0,0,1),cR.set(0,1,0);break;case 3:cE.set(0,0,-1),cR.set(0,-1,0);break;case 4:cE.set(0,-1,0),cR.set(0,0,1);break;case 5:cE.set(0,-1,0),cR.set(0,0,-1)}sn.add(this.position,cR,cP),sc.lookAt(this.position,cP,cE,t.viewMatrix),t.fieldOfView=90},iU),cB=Object.freeze({__proto__:null,AmbientLight:uA,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:cu,AnimationClipCurveBinding:cs,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:cc,AnimationEvent:cl,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:cg,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:cm,AnimatorControllerLayer:cv,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:cx,AnimatorStateMachine:cT,AnimatorStateTransition:cd,AssetPromise:s$,get AssetType(){return e.AssetType},Background:ub,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uJ,BasicRenderPipeline:uG,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:uy,BlendShapeFrame:uv,BlinnPhongMaterial:uZ,BoolUpdateFlag:le,BoxColliderShape:l_,Buffer:un,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:um,get BufferUsage(){return e.BufferUsage},BufferUtil:ue,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:lg,CharacterController:lh,CloneManager:sE,get Collider(){return e.Collider},ColliderShape:ld,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:lt,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:cL,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DiffuseMode(){return e.DiffuseMode},DirectLight:lH,DynamicCollider:lw,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:uL,EngineObject:sR,Entity:li,Event:sB,EventDispatcher:sD,FixedJoint:lv,get FogMode(){return e.FogMode},Font:sZ,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:ly,HitResult:ll,IndexBufferBinding:ur,get IndexFormat(){return e.IndexFormat},InputManager:lP,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:lT,JointMotor:lC,Keyframe:cC,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:lG,Loader:uQ,Logger:sz,Material:l$,Mesh:ua,MeshRenderElement:l2,MeshRenderer:uc,get MeshTopology(){return e.MeshTopology},ModelMesh:ul,ObjectValues:sW,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:u$,PBRMaterial:u0,PBRSpecularMaterial:u1,ParticleRenderer:cw,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsManager:lu,PhysicsMaterial:lc,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PlaneColliderShape:lp,get Platform(){return e.Platform},PointLight:lW,Pointer:la,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:ug,Probe:cF,RefObject:sL,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:uk,RenderQueue:uI,get RenderQueueType(){return e.RenderQueueType},RenderTarget:sK,get Renderer(){return e.Renderer},ResourceManager:s0,Scene:uM,SceneManager:uF,Script:uB,get SetDataOptions(){return e.SetDataOptions},Shader:lz,ShaderData:lk,ShaderFactory:lD,ShaderPass:lU,ShaderProperty:lN,get ShaderPropertyType(){return e.ShaderPropertyType},get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:uu,SkinnedMeshRenderer:up,Sky:uw,SkyBoxMaterial:cS,SphereColliderShape:lf,SpotLight:lX,SpringJoint:lx,Sprite:u4,SpriteAtlas:u3,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteElement:l4,SpriteMask:l9,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:u8,StateMachineScript:cy,StaticCollider:lS,get StencilOperation(){return e.StencilOperation},SubMesh:ui,SystemInfo:lo,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:ce,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:sX,Texture2D:sj,Texture2DArray:sq,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:sY,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:sk,TrailMaterial:cb,TrailRenderer:cM,Transform:lr,UnlitMaterial:u2,Util:sG,VertexBufferBinding:uo,VertexElement:ut,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:sM,deepClone:sP,dependentComponents:s9,ignoreClone:sA,request:uK,resourceLoader:s1,shallowClone:sF});function cD(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 cI=((ik=(iz=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:sz.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},ik.addCurrentLoad=function(e){this._currentLoad+=e},ik.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},ik.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},ik.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},cD(iz.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),iG&&cD(iz,iG),iz),cO='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',cV="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",cU=((iW=(iH=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)sz.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?uK(""+cV+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,cO].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([uK(""+cV+"draco_wasm_wrapper_gltf.js",{type:"text"}),uK(""+cV+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],i=[n,cO].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},iW.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var n=new cI(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]})},iW.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},iH);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 cz(e,t,n){return t&&cN(e.prototype,t),n&&cN(e,n),e}function ck(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(iX=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[iX.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",iX[iX.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",iX[iX.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",iX[iX.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",iX[iX.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",iX[iX.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",iX[iX.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",iX[iX.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",iX[iX.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",iX[iX.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",iX[iX.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",iX[iX.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",iX[iX.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",iX[iX.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",iX[iX.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",iX[iX.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",iX[iX.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",iX[iX.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",iX[iX.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",iX[iX.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",iX[iX.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",iX[iX.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",iX[iX.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",iX[iX.R11_EAC=37488]="R11_EAC",iX[iX.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",iX[iX.RG11_EAC=37490]="RG11_EAC",iX[iX.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",iX[iX.RGB8_ETC2=37492]="RGB8_ETC2",iX[iX.SRGB8_ETC2=37493]="SRGB8_ETC2",iX[iX.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",iX[iX.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",iX[iX.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",iX[iX.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",iX[iX.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",iX[iX.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",iX[iX.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",iX[iX.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",iX[iX.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",iX[iX.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",iX[iX.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",iX[iX.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT";var cG=((ij=(iK=function(e){this._scale=new sd;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&&ck(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},ij.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},cz(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&&ck(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&&ck(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),iK);function cH(e,t){return(cH=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cW(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&&cH(e,t)}function cX(){return(cX=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=((iY=(iq=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},iY.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)},iY._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)))},iY._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}},iY._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,cX({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"})},cz(iq,[{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}}]),iq),cj=((iQ=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]},iQ),cq=((iZ=(iJ=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 sz.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()},iZ.destroy=function(){this._useVao&&this._clearVAO()},iZ._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 sz.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},iZ._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},iZ._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)},iZ._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},iJ),cY=((i$=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]},i$),cQ=((i1=(i0=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},i1.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},i1.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},i1._bind=function(){this._rhi.bindTexture(this)},i1._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)}},i1._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,sz.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)},i1._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||i0._isPowerOf2(s)&&i0._isPowerOf2(l)||(sz.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)}},i1._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},i0._isPowerOf2=function(e){return(e&e-1)==0},i0._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)}},i0._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)}},i0._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},i0._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},i0._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},cz(i0,[{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)}}}]),i0),cJ=((i3=(i2=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=ck(i,sX),l=0,u=r.length;l<u;l++){var c=r[l]._format;if(!cQ._supportRenderBufferColorFormat(c,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[c]+" in RenderTarget")}if(!s&&!cQ._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 ck(e,sY)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(sz.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=ck(a,sY);(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=ck(i,sY);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=cQ._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()},i3.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)}},i3.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},i3._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},i3._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,ck(u,sY)||e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_2D,u._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(ck(r,sX)&&!ck(r,sY)){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=cQ._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)},i3._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=ck(i,sX)?i._platformTexture._formatDetail:cQ._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)},i3._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.")},i2),cZ=(cW(i4=function(t,n){(r=cQ.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(!cQ._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||cQ._isPowerOf2(o)&&cQ._isPowerOf2(s)||(sz.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=cQ._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},cQ),(i5=i4.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)},i5.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)},i5.getPixelBuffer=function(e,t,n,r,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");cQ.prototype._getPixelBuffer.call(this,null,e,t,n,r,i,a)},i4),c$=(cW(i8=function(t,n){r=cQ.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(!cQ._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return r._bind(),r._formatDetail=cQ._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r},cQ),(i6=i8.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)},i6.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)},i6.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)},i8),c0=(cW(i7=function(t,n){(r=cQ.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(!cQ._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||cQ._isPowerOf2(o)||(sz.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=cQ._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},cQ),(i9=i7.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)},i9.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)},i9.getPixelBuffer=function(e,t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");cQ.prototype._getPixelBuffer.call(this,e,t,n,r,i,a,o)},i7);e.WebGLMode=void 0,(ae=e.WebGLMode||(e.WebGLMode={}))[ae.Auto=0]="Auto",ae[ae.WebGL2=1]="WebGL2",ae[ae.WebGL1=2]="WebGL1";var c1=((an=(at=function(t){void 0===t&&(t={}),this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new s_(null,null,null,null),this._lastScissor=new s_(null,null,null,null),this._lastClearColor=new sf(null,null,null,null),this._scissorEnable=!1;var n=cX({webGLMode:0,alpha:!1,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(lo.platform===e.Platform.IPhone||lo.platform===e.Platform.IPad){var r=lo.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&&ck(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&&ck(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 cY(t),this._extensions=new cj(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))},an.createPlatformPrimitive=function(e){return new cq(this,e)},an.createPlatformTexture2D=function(e){return new cZ(this,e)},an.createPlatformTexture2DArray=function(e){return new c$(this,e)},an.createPlatformTextureCube=function(e){return new c0(this,e)},an.createPlatformRenderTarget=function(e){return new cJ(this,e)},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,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)},an.drawPrimitive=function(e,t,n){e?e._draw(n,t):sz.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,u=t.x*r,c=i-t.y*i-l;this.viewport(u,c,s,l),this.scissor(u,c,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.destroy=function(){},cz(at,[{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}}]),at),c2=(cW(ar=function(e,t){var n=new cG("string"==typeof e?document.getElementById(e):e),r=new c1(t);return uL.call(this,n,r)},uL),cz(ar,[{key:"canvas",get:function(){return this._canvas}}]),ar);function c3(){return(c3=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 c4(e,t){return(c4=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c5(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&&c4(e,t)}function c8(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 c6(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 c7=(c5(ai=function(){return uQ.apply(this,arguments)},uQ),ai.prototype.load=function(e,t){var n=this;return new s$(function(r,i){n.request(e.url,c3({},e,{type:"json"})).then(function(e){var n=new cm,i=e.layers,a=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,u=new cv(i);if(u.blendingMode=o,u.weight=s,l){var c=l.states,h=u.stateMachine=new cT;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 cd;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)})},ai);c7=c8([s1(e.AssetType.AnimatorController,["json"],!1)],c7);var c9=(c5(aa=function(){return uQ.apply(this,arguments)},uQ),aa.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new s$(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,c3({},e,{type:"arraybuffer"}))},aa);c9=c8([s1(e.AssetType.Buffer,["bin","r3bin"],!1)],c9);var he=(c5(ao=function(){return uQ.apply(this,arguments)},uQ),ao.prototype.load=function(t,n){var r=this;return new s$(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 sY(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 uA,p=new sg;f.diffuseMode=e.DiffuseMode.SphericalHarmonics,p.copyFromArray(r),f.diffuseSphericalHarmonics=p,f.specularTexture=o,f.specularTextureDecodeRGBM=!0,i(f)}).catch(function(e){a(e)})})},ao);function ht(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 hn(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){ht(a,r,i,o,s,"next",e)}function s(e){ht(a,r,i,o,s,"throw",e)}o(void 0)})}}he=c8([s1(e.AssetType.Env,["env"])],he);var hr=(c5(as=function(){return uQ.apply(this,arguments)},uQ),(al=as.prototype).load=function(e,t){var n=this;return new s$(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 sZ(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new sZ(t.engine,a))}).catch(function(e){i(e)})})},al._registerFont=function(e,t){return hn(function(){var n;return c6(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]}})})()},as);hr=c8([s1(e.AssetType.Font,["font"],!1)],hr);var hi=((au=function(e){this.hasSkinned=!1,this.chainPromises=[],this.accessorBufferCache={},this.texturesPromiseInfo=new ho,this.materialsPromiseInfo=new ho,this.meshesPromiseInfo=new ho,this.animationClipsPromiseInfo=new ho,this.defaultSceneRootPromiseInfo=new ho,this.masterPromiseInfo=new ho,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 s$(function(t,n,r,i){e.resolve=t,e.reject=n,e.setProgress=r,e.onCancel=i});return e.promise=t,t},au),ha=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},ho=function(){};(ac=o0||(o0={}))[ac.BYTE=5120]="BYTE",ac[ac.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",ac[ac.SHORT=5122]="SHORT",ac[ac.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",ac[ac.UNSIGNED_INT=5125]="UNSIGNED_INT",ac[ac.FLOAT=5126]="FLOAT",(ah=o1||(o1={})).SCALAR="SCALAR",ah.VEC2="VEC2",ah.VEC3="VEC3",ah.VEC4="VEC4",ah.MAT2="MAT2",ah.MAT3="MAT3",ah.MAT4="MAT4",(ad=o2||(o2={})).TRANSLATION="translation",ad.ROTATION="rotation",ad.SCALE="scale",ad.WEIGHTS="weights",(a_=o3||(o3={})).Linear="LINEAR",a_.Step="STEP",a_.CubicSpine="CUBICSPLINE",(af=o4||(o4={})).PERSPECTIVE="perspective",af.ORTHOGRAPHIC="orthographic",(ap=o5||(o5={})).JPEG="image/jpeg",ap.PNG="image/png",(ag=o8||(o8={})).OPAQUE="OPAQUE",ag.MASK="MASK",ag.BLEND="BLEND",(am=o6||(o6={}))[am.NEAREST=9728]="NEAREST",am[am.LINEAR=9729]="LINEAR",(av=o7||(o7={}))[av.NEAREST=9728]="NEAREST",av[av.LINEAR=9729]="LINEAR",av[av.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",av[av.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",av[av.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",av[av.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(ay=o9||(o9={}))[ay.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",ay[ay.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",ay[ay.REPEAT=10497]="REPEAT";var hs=((ax=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new sd(e[r],e[r+1]);return n},ax.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new sn(e[r],e[r+1],e[r+2]);return n},ax.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new s_(e[r],e[r+1],e[r+2],e[r+3]);return n},ax.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 sf(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new sf(e[a],e[a+1],e[a+2],e[a+3]);return r},ax.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))},ax.getAccessorTypeSize=function(e){switch(e){case o1.SCALAR:return 1;case o1.VEC2:return 2;case o1.VEC3:return 3;case o1.VEC4:case o1.MAT2:return 4;case o1.MAT3:return 9;case o1.MAT4:return 16}},ax.getComponentType=function(e){switch(e){case o0.BYTE:return Int8Array;case o0.UNSIGNED_BYTE:return Uint8Array;case o0.SHORT:return Int16Array;case o0.UNSIGNED_SHORT:return Uint16Array;case o0.UNSIGNED_INT:return Uint32Array;case o0.FLOAT:return Float32Array}},ax.getNormalizedComponentScale=function(e){switch(e){case o0.BYTE:return 1/127;case o0.UNSIGNED_BYTE:return 1/255;case o0.SHORT:return 1/32767;case o0.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},ax.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=ax.getComponentType(o),d=ax.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 ha(x,!0,g)}}else{var T=new h(l,u+c,p*d);r=new ha(T,!1,f)}if(n.sparse){var C=ax.processingSparseData(t,n,i,r.data);r=new ha(C,!1,r.stride)}return r},ax.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=ax.getAccessorTypeSize(t.type),c=u*t.count,h=null!=(v=i.byteStride)?v:0,d=ax.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=ax.getComponentType(A.componentType),V=new O(E,L,B/O.BYTES_PER_ELEMENT),U=new d(R,D,I/d.BYTES_PER_ELEMENT),N=0;N<b;N++)for(var z=V[N],k=0;k<u;k++)m[z*u+k]=U[N*u+k];return m},ax.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)},ax.processingSparseData=function(e,t,n,r){for(var i,a,o,s,l=e.bufferViews,u=ax.getAccessorTypeSize(t.type),c=ax.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=ax.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},ax.getIndexFormat=function(t){switch(t){case o0.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case o0.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case o0.UNSIGNED_INT:return e.IndexFormat.UInt32}},ax.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==o0.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==o0.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==o0.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==o0.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==o0.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},ax.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)})},ax.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},ax.parseRelativeUrl=function(e,t){return ax.isAbsoluteUrl(t)?t:e.substring(0,e.lastIndexOf("/")+1)+ax._formatRelativePath(t)},ax.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(ax.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}},ax._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},ax);function hl(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 hu(e,t){if(e){if("string"==typeof e)return hl(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 hl(e,t)}}function hc(e){return function(e){if(Array.isArray(e))return hl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||hu(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 hh=((aT=function(){}).parseEngineResource=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];var s=aT._extensionParsers[e];if(null==s?void 0:s.length)for(var l,u=0;u<s.length;u++)(l=s[u]).parseEngineResource.apply(l,[t,n,r].concat(hc(a)))},aT.createEngineResource=function(e,t,n){for(var r,i=arguments.length,a=Array(i>3?i-3:0),o=3;o<i;o++)a[o-3]=arguments[o];var s=aT._extensionParsers[e];if(null==s?void 0:s.length)return(r=s[0]).createEngineResource.apply(r,[t,n].concat(hc(a)))},aT.hasExtensionParser=function(e){var t=aT._extensionParsers[e];return!!(null==t?void 0:t.length)},aT.initialize=function(e){var t=aT._extensionParsers[e];if(null==t?void 0:t.length)for(var n=0;n<t.length;n++)t[n].initialize()},aT._addExtensionParser=function(e,t){aT._extensionParsers[e]||(aT._extensionParsers[e]=[]),aT._extensionParsers[e].push(t)},aT);function hd(e){return function(t){var n=new t;hh._addExtensionParser(e,n)}}hh._extensionParsers={};var h_=((aS=(aC=function(){}).prototype).initialize=function(){},aS.parseEngineResource=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]},aS.createEngineResource=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return null},aC),hf=(c5(aw=function(){return h_.apply(this,arguments)},h_),(ab=aw.prototype).initialize=function(){hf._decoder||(hf._decoder=new cU)},ab.createEngineResource=function(e,t,n){var r=t.gltf,i=t.buffers,a=r.bufferViews,o=r.accessors,s=e.bufferView,l=e.attributes,u={},c={};for(var h in l)u[h]=l[h];for(var d in n.attributes)if(void 0!==l[d]){var _=o[n.attributes[d]];c[d]=hs.getComponentType(_.componentType).name}var f=o[n.indices],p=hs.getComponentType(f.componentType).name,g=hs.getBufferViewData(a[s],i);return hf._decoder.decode(g,{attributeIDs:u,attributeTypes:c,useUniqueIDs:!0,indexType:p}).then(function(e){return e})},aw);function hp(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}hf=c8([hd("KHR_draco_mesh_compression")],hf);var hg=(c5(aA=function(){return h_.apply(this,arguments)},h_),aA.prototype.parseEngineResource=function(e,t,n){var r,i=e.color,a=e.intensity,o=e.type,s=e.range,l=e.spot,u=n.glTFResource;if("directional"===o?r=t.addComponent(lH):"point"===o?r=t.addComponent(lW):"spot"===o&&(r=t.addComponent(lX)),i&&r.color.set(i[0],i[1],i[2],1),r.intensity=void 0===a?1:a,s&&!hp(r,lH)&&(r.distance=s),l&&hp(r,lX)){var c=l.innerConeAngle,h=void 0===c?0:c,d=l.outerConeAngle;r.angle=h,r.penumbra=(void 0===d?Math.PI/4:d)-h}u.lights||(u.lights=[]),u.lights.push(r)},aA);hg=c8([hd("KHR_lights_punctual")],hg);var hm=(c5(aM=function(){return hh.apply(this,arguments)},hh),aM.prototype.parse=function(t){var n=t.gltf,r=t.glTFResource,i=r.engine,a=r.textures;if(n.materials){for(var o=t.materialsPromiseInfo,s=[],l=0;l<n.materials.length;l++){var u,c,h=n.materials[l],d=h.extensions,_=void 0===d?{}:d,f=h.pbrMetallicRoughness,p=h.normalTexture,g=h.occlusionTexture,m=h.emissiveTexture,v=h.emissiveFactor,y=h.alphaMode,x=h.alphaCutoff,T=h.doubleSided,C=h.name,S=void 0===C?"":C,w=_.KHR_materials_unlit,b=_.KHR_materials_pbrSpecularGlossiness,A=_.KHR_materials_clearcoat,M=_.KHR_materials_ior,F=_.OASIS_materials_remap,P=null;if((P=w?hh.createEngineResource("KHR_materials_unlit",w,t):b?hh.createEngineResource("KHR_materials_pbrSpecularGlossiness",b,t):new u0(i)).name=S,A&&hh.parseEngineResource("KHR_materials_clearcoat",A,P,t),M&&hh.parseEngineResource("KHR_materials_ior",M,P,t),f){var E=f.baseColorFactor,R=f.baseColorTexture,L=f.metallicFactor,B=f.roughnessFactor,D=f.metallicRoughnessTexture;if(E&&(P.baseColor=new sf(sf.linearToGammaSpace(E[0]),sf.linearToGammaSpace(E[1]),sf.linearToGammaSpace(E[2]),E[3])),R&&(P.baseTexture=a[R.index],aM._parseTextureTransform(P,R.extensions,t)),!w&&!b){var I=P;I.metallic=null!=L?L:1,I.roughness=null!=B?B:1,D&&(I.roughnessMetallicTexture=a[D.index],aM._parseTextureTransform(P,D.extensions,t))}}if(!w){var O=P;if(m&&(O.emissiveTexture=a[m.index],aM._parseTextureTransform(P,m.extensions,t)),v&&(O.emissiveColor=new sf(sf.linearToGammaSpace(v[0]),sf.linearToGammaSpace(v[1]),sf.linearToGammaSpace(v[2]))),p){var V=p.index,U=p.scale;O.normalTexture=a[V],aM._parseTextureTransform(P,p.extensions,t),void 0!==U&&(O.normalTextureIntensity=U)}if(g){var N=g.index,z=g.strength,k=g.texCoord;O.occlusionTexture=a[N],aM._parseTextureTransform(P,g.extensions,t),void 0!==z&&(O.occlusionTextureIntensity=z),k===e.TextureCoordinate.UV1?O.occlusionTextureCoord=e.TextureCoordinate.UV1:k>e.TextureCoordinate.UV1&&sz.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(F&&(n.extensions=null!=(u=n.extensions)?u:{},n.extensions.OASIS_materials_remap=null!=(c=n.extensions.OASIS_materials_remap)?c:{},n.extensions.OASIS_materials_remap[l]=hh.createEngineResource("OASIS_materials_remap",F,t)),T?P.renderFace=e.RenderFace.Double:P.renderFace=e.RenderFace.Front,y){case o8.OPAQUE:P.isTransparent=!1;break;case o8.BLEND:P.isTransparent=!0;break;case o8.MASK:P.alphaCutoff=null!=x?x:.5}s[l]=P}return r.materials=s,o.resolve(s),o.promise}},aM._parseTextureTransform=function(e,t,n){void 0===t&&(t={});var r=t.KHR_texture_transform;r&&hh.parseEngineResource("KHR_texture_transform",r,e,n)},aM),hv=(c5(aF=function(){return h_.apply(this,arguments)},h_),aF.prototype.parseEngineResource=function(e,t,n){var r=n.glTFResource.textures,i=e.clearcoatFactor,a=e.clearcoatTexture,o=e.clearcoatRoughnessFactor,s=e.clearcoatRoughnessTexture,l=e.clearcoatNormalTexture;t.clearCoat=void 0===i?0:i,t.clearCoatRoughness=void 0===o?0:o,a&&(t.clearCoatTexture=r[a.index],hm._parseTextureTransform(t,a.extensions,n)),s&&(t.clearCoatRoughnessTexture=r[s.index],hm._parseTextureTransform(t,s.extensions,n)),l&&(t.clearCoatNormalTexture=r[l.index],hm._parseTextureTransform(t,l.extensions,n))},aF);hv=c8([hd("KHR_materials_clearcoat")],hv);var hy=(c5(aP=function(){return h_.apply(this,arguments)},h_),aP.prototype.parseEngineResource=function(e,t,n){var r=e.ior;t.ior=void 0===r?1.5:r},aP);hy=c8([hd("KHR_materials_ior")],hy);var hx=(c5(aE=function(){return h_.apply(this,arguments)},h_),aE.prototype.createEngineResource=function(e,t){var n=t.glTFResource,r=n.engine,i=n.textures,a=new u1(r),o=e.diffuseFactor,s=e.diffuseTexture,l=e.specularFactor,u=e.glossinessFactor,c=e.specularGlossinessTexture;return o&&(a.baseColor=new sf(sf.linearToGammaSpace(o[0]),sf.linearToGammaSpace(o[1]),sf.linearToGammaSpace(o[2]),o[3])),s&&(a.baseTexture=i[s.index],hm._parseTextureTransform(a,s.extensions,t)),l&&(a.specularColor=new sf(sf.linearToGammaSpace(l[0]),sf.linearToGammaSpace(l[1]),sf.linearToGammaSpace(l[2]))),void 0!==u&&(a.glossiness=u),c&&(a.specularGlossinessTexture=i[c.index],hm._parseTextureTransform(a,c.extensions,t)),a},aE);hx=c8([hd("KHR_materials_pbrSpecularGlossiness")],hx);var hT=(c5(aR=function(){return h_.apply(this,arguments)},h_),aR.prototype.createEngineResource=function(e,t){var n=t.glTFResource.engine;return new u2(n)},aR);hT=c8([hd("KHR_materials_unlit")],hT);var hC=(c5(aL=function(){return h_.apply(this,arguments)},h_),aL.prototype.parseEngineResource=function(e,t,n){for(var r=n.gltf.extensions.KHR_materials_variants.variants,i=n.glTFResource,a=e.mappings,o=0;o<a.length;o++){var s=a[o],l=s.material,u=s.variants;i.variants||(i.variants=[]),i.variants.push({renderer:t,material:i.materials[l],variants:u.map(function(e){return r[e].name})})}},aL);hC=c8([hd("KHR_materials_variants")],hC);var hS=(c5(aB=function(){return h_.apply(this,arguments)},h_),aB);hS=c8([hd("KHR_mesh_quantization")],hS);var hw=(c5(aD=function(){return h_.apply(this,arguments)},h_),aD.prototype.parseEngineResource=function(e,t,n){var r=e.offset,i=e.rotation,a=e.scale,o=e.texCoord;r&&(t.tilingOffset.z=r[0],t.tilingOffset.w=r[1]),a&&(t.tilingOffset.x=a[0],t.tilingOffset.y=a[1]),i&&sz.warn("rotation in KHR_texture_transform is not supported now"),o&&sz.warn("texCoord in KHR_texture_transform is not supported now")},aD);hw=c8([hd("KHR_texture_transform")],hw);var hb=(c5(aI=function(){return h_.apply(this,arguments)},h_),aI.prototype.createEngineResource=function(e,t){return t.glTFResource.engine.resourceManager.getResourceByRef(e)},aI);function hA(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=hu(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.")}hb=c8([hd("OASIS_materials_remap")],hb);var hM=(c5(aO=function(){return hh.apply(this,arguments)},hh),(aV=aO.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 cu(g),v=[],y=0,x=f.length;y<x;y++){var T,C=f[y],S=o[C.input],w=o[C.output],b=hs.getAccessorBuffer(t,n,S).data,A=hs.getAccessorBuffer(t,n,w).data;if(w.normalized){for(var M=hs.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:o3.Linear,B=void 0;switch(L){case o3.CubicSpine:B=e.InterpolationType.CubicSpine;break;case o3.Step:B=e.InterpolationType.Step;break;case o3.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],N="",z=U;z.parent;)N=""===N?""+z.name:z.name+"/"+N,z=z.parent;var k=void 0,G=void 0;switch(V.path){case o2.TRANSLATION:k=lr,G="position";break;case o2.ROTATION:k=lr,G="rotationQuaternion";break;case o2.SCALE:k=lr,G="scale";break;case o2.WEIGHTS:k=up,G="blendShapeWeights"}var H=this._addCurve(V.path,O,v);m.addCurveBinding(N,k,G,H)}u[h]=m,c[h]={name:g,index:h}}return r.animations=u,r._animationsIndices=c,s.resolve(u),s.promise}},aV._addCurve=function(t,n,r){var i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case o2.TRANSLATION:case o2.SCALE:for(var l=new e.AnimationVector3Curve,u=l.interpolation=i.interpolation,c=0,h=0,d=a.length;h<d;h++){var _=new cC;_.time=a[h],u===e.InterpolationType.CubicSpine?(_.inTangent=new sn(o[c++],o[c++],o[c++]),_.value=new sn(o[c++],o[c++],o[c++]),_.outTangent=new sn(o[c++],o[c++],o[c++])):_.value=new sn(o[c++],o[c++],o[c++]),l.addKey(_)}return l;case o2.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 cC;y.time=a[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new s_(o[g++],o[g++],o[g++],o[g++]),y.value=new su(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new s_(o[g++],o[g++],o[g++],o[g++])):y.value=new su(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case o2.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 cC;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}},aO),hF=(c5(aU=function(){return hh.apply(this,arguments)},hh),(aN=aU.prototype).parse=function(e){var t=e.glTFResource.url;return this._isGLB(t)?uK(t,{type:"arraybuffer"}).then(hs.parseGLB).then(function(t){var n=t.gltf,r=t.buffers;e.gltf=n,e.buffers=r}):uK(t,{type:"json"}).then(function(n){return e.gltf=n,Promise.all(n.buffers.map(function(e){return uK(hs.parseRelativeUrl(t,e.uri),{type:"arraybuffer"})})).then(function(t){e.buffers=t})})},aN._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},aU),hP=(c5(az=function(){return hh.apply(this,arguments)},hh),(ak=az.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 li(r,o.name||""+az._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)}},ak._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)}}},ak._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 li(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]}},az);hP._defaultName="_GLTF_ENTITY_";var hE=(c5(aG=function(){return hh.apply(this,arguments)},hh),(aH=aG.prototype).parse=function(e){var t=this,n=e.gltf,r=e.buffers,i=e.glTFResource,a=i.engine;if(n.meshes){for(var o=e.meshesPromiseInfo,s=[],l=0;l<n.meshes.length;l++)!function(i){for(var o=function(i){var o=l.primitives[i],s=o.extensions,c=(void 0===s?{}:s).KHR_draco_mesh_compression;u[i]=new Promise(function(s){var u=new ul(a,l.name||i+"");c?hh.createEngineResource("KHR_draco_mesh_compression",c,e,o).then(function(r){return t._parseMeshFromGLTFPrimitiveDraco(u,l,o,n,function(e){for(var t=0;t<r.attributes.length;t++)if(r.attributes[t].name===e)return r.attributes[t].array;return null},function(e,t){throw"BlendShape animation is not supported when using draco."},function(){return r.index.array},e.keepMeshData)}).then(s):t._parseMeshFromGLTFPrimitive(e,u,l,o,n,function(e){return null},function(e,t){var i=o.targets[t][e];if(!i)return null;var a=n.accessors[i];return hs.getAccessorData(n,a,r)},function(){var e=n.accessors[o.indices];return hs.getAccessorData(n,e,r)},e.keepMeshData).then(s)})},l=n.meshes[i],u=[],c=0;c<l.primitives.length;c++)o(c);s[i]=Promise.all(u)}(l);return s$.all(s).then(function(e){i.meshes=e,o.resolve(e)}).catch(o.reject),o.promise}},aH._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=hs.getAccessorBuffer(t,a,S),b=hs.getAccessorTypeSize(S.type),A=S.count,M=w.data,F=void 0,P=n.instanceId,E=w.vertexBindingInfos,R=S.normalized,L=hs.getElementFormat(S.componentType,b,R),B=void 0;R&&(B=hs.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 ut(C,D,L,T);var V=w.vertexBuffer;V||((V=new un(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 ut(C,D,L,E[P])}else{D=0,F=new ut(C,D,L,T);var U=new un(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 N=n.bounds,z=N.min,k=N.max;if(S.min&&S.max){if(z.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,K=new sn(M[X],M[X+1],M[X+2]);R&&K.scale(B),h[W]=K}}else{var j=aG._tempVector3;z.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(j.copyFromArray(M,J),sn.min(z,j,z),sn.max(k,j,k),u){var Z=j.clone();R&&Z.scale(B),h[Q]=Z}}}R&&(z.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 s_(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 s_(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&&this._createBlendShape(n,r,g,s),n.uploadData(!u),n._positions=h,n._boneIndices=d,n._boneWeights=_,Promise.resolve(n)},aH._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?hs.floatBufferToVector3Array(l):null,d=u?hs.floatBufferToVector3Array(u):null,_=c?hs.floatBufferToVector3Array(c):null,f=new uy(s);f.addFrame(1,h,d,_),e.addBlendShape(f)}},aH._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=hs.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=aG._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),sn.min(y,v,y),sn.max(x,v,x)}}for(var w in u)if("POSITION"!==w){var b=i(w);switch(w){case"NORMAL":var A=hs.floatBufferToVector3Array(b);e.setNormals(A);break;case"TEXCOORD_0":var M=hs.floatBufferToVector2Array(b);e.setUVs(M,0);break;case"TEXCOORD_1":var F=hs.floatBufferToVector2Array(b);e.setUVs(F,1);break;case"TEXCOORD_2":var P=hs.floatBufferToVector2Array(b);e.setUVs(P,2);break;case"TEXCOORD_3":var E=hs.floatBufferToVector2Array(b);e.setUVs(E,3);break;case"TEXCOORD_4":var R=hs.floatBufferToVector2Array(b);e.setUVs(R,4);break;case"TEXCOORD_5":var L=hs.floatBufferToVector2Array(b);e.setUVs(L,5);break;case"TEXCOORD_6":var B=hs.floatBufferToVector2Array(b);e.setUVs(B,6);break;case"TEXCOORD_7":var D=hs.floatBufferToVector2Array(b);e.setUVs(D,7);break;case"COLOR_0":var I=hs.floatBufferToColorArray(b,_[u.COLOR_0].type===o1.VEC3);e.setColors(I);break;case"TANGENT":var O=hs.floatBufferToVector4Array(b);e.setTangents(O);break;case"JOINTS_0":var V=hs.floatBufferToVector4Array(b);e.setBoneIndices(V);break;case"WEIGHTS_0":var U=hs.floatBufferToVector4Array(b);e.setBoneWeights(U)}}if(void 0!==h){var N=r.accessors[h],z=o();e.setIndices(z),e.addSubMesh(0,N.count,d)}else e.addSubMesh(0,l,d);return c&&this._createBlendShape(e,t,c,a),e.uploadData(!s),Promise.resolve(e)},aG);hE._tempVector3=new sn;var hR=(c5(aW=function(){return hh.apply(this,arguments)},hh),(aX=aW.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=[],l=0;l<i.length;l++){var u=i[l],c=u.camera,h=u.mesh,d=u.extensions,_=(void 0===d?{}:d).KHR_lights_punctual,f=r[l];if(void 0!==c&&this._createCamera(t,a[c],f),void 0!==h&&s.push(this._createRenderer(e,u,f)),_){var p=_.light,g=n.extensions.KHR_lights_punctual.lights;hh.parseEngineResource("KHR_lights_punctual",g[p],f,e)}}return t.defaultSceneRoot&&this._createAnimator(e),n.extensions&&delete n.extensions.OASIS_materials_remap,s$.all(s).then(function(){return o.resolve(t.defaultSceneRoot)}).catch(o.reject),o.promise}},aX._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===o4.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===o4.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},aX._createRenderer=function(e,t,n){for(var r=e.glTFResource,i=e.gltf,a=i.meshes,o=r.engine,s=r.meshes,l=r.materials,u=r.skins,c=t.mesh,h=t.skin,d=a[c],_=d.primitives,f=t.weights||d.weights,p=[],g=0;g<_.length;g++)!function(t){var r=s[c][t],a=void 0;if(void 0!==h||f){e.hasSkinned=!0;var d=n.addComponent(up);d.mesh=r,void 0!==h&&(d.skin=u[h]),f&&(d.blendShapeWeights=new Float32Array(f)),a=d}else(a=n.addComponent(uc)).mesh=r;var g=_[t].material,m=i.extensions&&i.extensions.OASIS_materials_remap;if(m&&m[g])p.push(m[g].then(function(e){a.setMaterial(e)}));else{var v=(null==l?void 0:l[g])||aW._getDefaultMaterial(o);a.setMaterial(v),r.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(a.enableVertexColor=!0)})}var y=_[t].extensions,x=(void 0===y?{}:y).KHR_materials_variants;x&&hh.parseEngineResource("KHR_materials_variants",x,a,e)}(g);return Promise.all(p)},aX._createAnimator=function(e){if(e.hasSkinned||e.glTFResource.animations){var t=e.glTFResource,n=t.defaultSceneRoot,r=t.animations,i=n.addComponent(cg),a=new cm,o=new cv("layer"),s=new cT;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}}},aW._getDefaultMaterial=function(e){return aW._defaultMaterial||(aW._defaultMaterial=new uZ(e)),aW._defaultMaterial},aW),hL=(c5(aK=function(){return hh.apply(this,arguments)},hh),(aj=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 uu(_);p.inverseBindMatrices.length=f;for(var g=n.accessors[u],m=hs.getAccessorBuffer(e,n,g).data,v=0;v<f;v++){var y=new sc;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}},aj._findSkeletonRootBone=function(e,t){for(var n,r={},i=hA(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),hB=(c5(aq=function(){return hh.apply(this,arguments)},hh),(aY=aq.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 s$.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:hs.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=hs.getBufferViewData(v,a);return hs.loadImageBuffer(y,f).then(function(e){var t=new sj(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}},aY._parseSampler=function(t,n){var r=n.magFilter,i=n.minFilter,a=n.wrapS,o=n.wrapT;(r||i)&&(r===o6.NEAREST?t.filterMode=e.TextureFilterMode.Point:i<=o7.LINEAR_MIPMAP_NEAREST?t.filterMode=e.TextureFilterMode.Bilinear:t.filterMode=e.TextureFilterMode.Trilinear),a&&(t.wrapModeU=aq._wrapMap[a]),o&&(t.wrapModeV=aq._wrapMap[o])},aq);hB._wrapMap=((aQ={})[o9.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,aQ[o9.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,aQ[o9.REPEAT]=e.TextureWrapMode.Repeat,aQ);var hD=(c5(aJ=function(){return hh.apply(this,arguments)},hh),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.";if(r){sz.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++)hh.hasExtensionParser(r[o])||sz.warn("Extension "+r[o]+" is not implemented, you can customize this extension in gltf.")}if(i){sz.info("extensionsRequired: "+i);for(var s=0;s<i.length;s++){var l=i[s];hh.hasExtensionParser(l)?hh.initialize(l):sz.error("GLTF parser has not supported required extension "+l+".")}}},aJ),hI=((aZ=function(e){var t=this;this._pipes=[],e.forEach(function(e,n){t._pipes[n]=new e})}).prototype.parse=function(e){var t,n=this,r=e.glTFResource;return new s$(function(i,a){n._pipes.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)})},aZ);hI.defaultPipeline=new hI([hF,hD,hB,hm,hE,hP,hL,hM,hR]);var hO=(c5(a$=function(e,t){var n;return(n=sR.call(this,e)||this).url=t,n},sR),a$.prototype.destroy=function(){this._destroyed||(sR.prototype.destroy.call(this),this.defaultSceneRoot.destroy(),this.textures=null,this.materials=null,this.meshes=null,this.skins=null,this.animations=null,this.entities=null,this.cameras=null,this.lights=null,this.sceneRoots=null,this.variants=null)},a$),hV=(c5(a0=function(){return uQ.apply(this,arguments)},uQ),a0.prototype.load=function(e,t){var n,r,i=e.url,a=new hi(i),o=new hO(t.engine,i),s=a.masterPromiseInfo;return a.glTFResource=o,a.keepMeshData=null!=(r=null==(n=e.params)?void 0:n.keepMeshData)&&r,s.onCancel(function(){for(var e,t=a.chainPromises,n=hA(t);!(e=n()).done;)e.value.cancel()}),hI.defaultPipeline.parse(a).then(s.resolve).catch(function(e){console.error(e),s.reject("Error loading glTF model from "+i+" .")}),a.promiseMap},a0);hV=c8([s1(e.AssetType.Prefab,["gltf","glb"])],hV);var hU=Math.PI,hN=(c5(a1=function(){return uQ.apply(this,arguments)},uQ),a1.prototype.load=function(t,n){var r=this;return new s$(function(i,a){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=hN._parseHeader(n),a=r.width,s=r.height,l=r.dataPosition,u=hN._readPixels(n.subarray(l),a,s),c=s>>1,h=hN._convertToCubemap(u,a,s,c),d=new sY(o,c),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),i(d)}).catch(a)})},a1._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)]},a1._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},a1._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,-e.x),a=Math.acos(e.y);i<-hU;)i+=2*hU;for(;i>hU;)i-=2*hU;var o=i/hU,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/hU*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 sf(c,h,d,_)},a1._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},a1._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}},a1._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},a1._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},a1._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},(se=a1)._rightBottomBack=new sn(1,-1,-1),se._rightBottomFront=new sn(1,-1,1),se._rightUpBack=new sn(1,1,-1),se._rightUpFront=new sn(1,1,1),se._leftBottomBack=new sn(-1,-1,-1),se._leftBottomFront=new sn(-1,-1,1),se._leftUpBack=new sn(-1,1,-1),se._leftUpFront=new sn(-1,1,1),se._faceRight=[se._rightBottomBack,se._rightBottomFront,se._rightUpBack,se._rightUpFront],se._faceLeft=[se._leftBottomFront,se._leftBottomBack,se._leftUpFront,se._leftUpBack],se._faceUp=[se._leftBottomFront,se._rightBottomFront,se._leftBottomBack,se._rightBottomBack],se._faceBottom=[se._leftUpBack,se._rightUpBack,se._leftUpFront,se._rightUpFront],se._faceFront=[se._leftBottomBack,se._rightBottomBack,se._leftUpBack,se._rightUpBack],se._faceBack=[se._rightBottomFront,se._leftBottomFront,se._rightUpFront,se._leftUpFront],se._tempVector3=new sn,se._temp2Vector3=new sn,se._temp3Vector3=new sn,se._temp4Vector3=new sn,se._temp5Vector3=new sn,se);hN=c8([s1(e.AssetType.HDR,["hdr"])],hN);var hz=(c5(a2=function(){return uQ.apply(this,arguments)},uQ),a2.prototype.load=function(e){return this.request(e.url,c3({},e,{type:"json"}))},a2);hz=c8([s1(e.AssetType.JSON,["json"],!1)],hz);var hk={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 hG(e){var t=hk.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var hH=(c5(a3=function(){return uQ.apply(this,arguments)},uQ),a3.prototype.load=function(t,n){var r=this;return new s$(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,c3({},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=hk.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 sY(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)})})},a3);hH=c8([s1(e.AssetType.KTXCube,[])],hH);var hW=(c5(a4=function(){return uQ.apply(this,arguments)},uQ),a4.prototype.load=function(e,t){var n=this;return new s$(function(r,i){n.request(e.url,c3({},e,{type:"arraybuffer"})).then(function(e){for(var n=hG(e),i=n.width,a=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,u=new sj(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)})})},a4);hW=c8([s1(e.AssetType.KTX,["ktx"])],hW);var hX=(c5(a5=function(){return uQ.apply(this,arguments)},uQ),a5.prototype.load=function(e,t){var n=this;return new s$(function(r,i){n.request(e.url,c3({},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 sd(i.x,i.y));break;case"Vector3":d.setVector3(e,new sn(i.x,i.y,i.z));break;case"Vector4":d.setVector4(e,new s_(i.x,i.y,i.z,i.w));break;case"Color":d.setColor(e,new sf(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 u0(a);break;case"pbr-specular":n=new u1(a);break;case"unlit":n=new u2(a);break;case"blinn-phong":n=new uZ(a);break;case"bake-pbr":n=new u$(a,lz.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)})},a5);function hK(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 hj(e,t,n){return t&&hK(e.prototype,t),n&&hK(e,n),e}hX=c8([s1(e.AssetType.Material,["json"])],hX);var hq=((a6=(a8=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},a6.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},a6.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},a6.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},a6.nextInt32Array=function(e){var t=new Int32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a6.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},a6.nextFloat32Array=function(e){var t=new Float32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a6.nextUint32Array=function(e){var t=new Uint32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a6.nextUint8Array=function(e){var t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,t},a6.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},a6.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,hs.decodeText(t)},a6.nextImageData=function(e){return this.buffer.slice(this._offset)},a6.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},a6.skip=function(e){return this._offset+=e,this},a6.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)},hj(a8,[{key:"offset",get:function(){return this._offset}}]),a8);hq.imageMapping={0:"image/png",1:"image/jpg",2:"image/webp",3:"ktx"};var hY={};function hQ(e){return function(t){hY[e]=t}}var hJ=((a7=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=hs.decodeText(s),u=hs.decodeText(a),c=new a7;return c.totalLength=n,c.name=l,c.type=u,c.version=r,c.headerLength=s.byteLength+a.byteLength+9,c},hj(a7,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),a7);function hZ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new s_(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function h$(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sn(e[3*r],e[3*r+1],e[3*r+2]);return n}function h0(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sd(e[2*r],e[2*r+1]);return n}function h1(e,t,n){return(h1=!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&&c4(i,n.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((a9=function(){}).decode=function(e,t){return new Promise(function(n){var r=new ul(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=h$(o,s);if(r.setPositions(l),i.normals){var u=h$(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(h0(c,s))}if(i.uv1){var h=new Float32Array(t.buffer,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);r.setUVs(h0(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(h0(d,s),2)}if(i.uv3){var _=new Float32Array(t.buffer,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);r.setUVs(h0(_,s),3)}if(i.uv4){var f=new Float32Array(t.buffer,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);r.setUVs(h0(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(h0(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(h0(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(h0(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 sf(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(hZ(y,s))}if(i.boneIndices){var x=new Float32Array(t.buffer,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);r.setBoneIndices(hZ(x,s))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var n=new uy(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=h$(r,i);e.deltaNormals&&h$(new Float32Array(t.buffer,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),i),e.deltaTangents&&hZ(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)})},a9),e.MeshDecoder=c8([hQ("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oe=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 sj(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)}})},oe),e.Texture2DDecoder=c8([hQ("Texture2D")],e.Texture2DDecoder);var h2=((ot=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},ot.parseEntity=function(e,t){return ot.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})},ot.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 li(t,e.name))},ot.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,i=h1(uQ.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(i,e,t,n)},ot.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)},ot.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})},ot.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)})},ot._isClass=function(e){return void 0!=e.class},ot._isRef=function(e){return void 0!=e.refId},ot);h2.customParseComponentHandles=new Map;var h3=((on=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)}},on),h4={Transform:lr,Animator:cg,DirectLight:lH,Camera:e.Camera,MeshRenderer:uc,ParticleRenderer:cw,PointLight:lW,SpotLight:lX,Script:uB,SpriteMask:l9,SpriteRenderer:u8,TextRenderer:ce};e.InterpolableValueType=void 0,(or=e.InterpolableValueType||(e.InterpolableValueType={}))[or.Float=0]="Float",or[or.FloatArray=1]="FloatArray",or[or.Vector2=2]="Vector2",or[or.Vector3=3]="Vector3",or[or.Vector4=4]="Vector4",or[or.Quaternion=5]="Quaternion",or[or.Color=6]="Color",or[or.Array=7]="Array",or[or.Boolean=8]="Boolean",e.AnimationClipDecoder=((oi=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),i=new cu(r),a=n.nextUint16(),o=0;o<a;++o){var s=new cl;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=h4[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 cC;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 cC;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 cC;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 cC;b.time=n.nextFloat32(),b.value=new sd(n.nextFloat32(),n.nextFloat32()),b.inTangent=new sd(n.nextFloat32(),n.nextFloat32()),b.outTangent=new sd(n.nextFloat32(),n.nextFloat32()),_.addKey(b)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var A=0;A<p;++A){var M=new cC;M.time=n.nextFloat32(),M.value=new sn(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new sn(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new sn(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var F=new cC;F.time=n.nextFloat32(),F.value=new s_(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new s_(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new s_(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 cC;E.time=n.nextFloat32(),E.value=new sf(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),E.inTangent=new s_(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),E.outTangent=new s_(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 cC;L.time=n.nextFloat32(),L.value=new su(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new s_(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new s_(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}i.addCurveBinding(c,h,d,_)}t(i)})},oi),e.AnimationClipDecoder=c8([hQ("AnimationClip")],e.AnimationClipDecoder);var h5=((oa=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},oa),h8=((os=(oo=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)},os._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),h2.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})},os._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,i=t.scene,a=t.rootIds,o=hA(a);!(e=o()).done;){var s=e.value;h3.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])},os._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(uQ.getClass(u))),c=c||o.addComponent(uQ.getClass(u));var h=h2.parsePropsAndMethods(c,l,o.engine);n.push(h)}return Promise.all(n)},os._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oo.parse=function(e,t){var n=new uM(e),r=new h5(t,n),i=new oo(r);return i.start(),i.promise},oo);function h6(e,t){var n=hJ.decode(e),r=new hq(e,n.headerLength,n.dataLength);return hY[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(c5(ol=function(){return uQ.apply(this,arguments)},uQ),ol.prototype.load=function(e,t){var n=this;return new s$(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){h6(e,t.engine).then(function(e){r(e)})})})},ol),e.MeshLoader=c8([s1("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(c5(ou=function(){return uQ.apply(this,arguments)},uQ),ou.prototype.load=function(e,t){var n=this;return new s$(function(r){n.request(e.url,{type:"arraybuffer"}).then(function(e){h6(e,t.engine).then(function(e){r(e)})})})},ou),e.EditorTextureLoader=c8([s1("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var h7=(c5(oc=function(){return uQ.apply(this,arguments)},uQ),oc.prototype.load=function(e,t){var n=this;return new s$(function(r,i){n.request(e.url,c3({},e,{type:"arraybuffer"})).then(function(e){return h6(e,t.engine)}).then(function(e){r(e)}).catch(i)})},oc);h7=c8([s1(e.AssetType.Mesh,["mesh"])],h7);var h9=(c5(oh=function(){return uQ.apply(this,arguments)},uQ),(od=oh.prototype).load=function(e,t){var n=this;return new s$(function(r,i){var a=e.url;n._registerFont(a,a).then(function(){r(new sZ(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},od._registerFont=function(e,t){return hn(function(){var n;return c6(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]}})})()},oh);h9=c8([s1(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],h9);var de=(c5(o_=function(){var e;return e=uQ.apply(this,arguments)||this,e._tempRect=new sp,e._tempVec2=new sd,e._tempVec4=new s_,e},uQ),(of=o_.prototype).load=function(t,n){var r=this;return new s$(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,c3({},t,{type:"json"}));l.push(u),u.then(function(t){var o=t.atlasItems,s=t.mipmap,u=t.anisoLevel,c=t.filterMode,h=t.wrapModeU,d=t.wrapModeV,_=t.format,f=o?o.length:0,p=n.engine,g=new u3(p);if(f<0){i(g);return}l.length=0;for(var m=0;m<o.length;m++)!function(t){var i=o[t];if(i.img)l.push(n.load({url:i.img,type:e.AssetType.Texture2D,params:{format:_,mipmap:s}}).then(function(e){u&&(e.anisoLevel=u),void 0!==c&&(e.filterMode=c),void 0!==h&&(e.wrapModeU=h),void 0!==d&&(e.wrapModeV=d);for(var t=0;t<i.sprites.length;t++)g._addSprite(r._makeSprite(p,i.sprites[t],e))}).catch(a));else for(var f=0;f<i.sprites.length;f++)g._addSprite(r._makeSprite(p,i.sprites[f]))}(m);s$.all(l).then(function(){i(g)}).catch(a)}).catch(a)})},of._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=new u4(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},o_);de=c8([s1(e.AssetType.SpriteAtlas,["atlas"],!1)],de);var dt=(c5(op=function(){return uQ.apply(this,arguments)},uQ),op.prototype.load=function(e,t){var n=this;return new s$(function(r,i){n.request(e.url,c3({},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 u4(t.engine,n,e.region,e.pivot,e.border))}).catch(i):r(new u4(t.engine,null,e.region,e.pivot,e.border))}).catch(i)})},op);dt=c8([s1(e.AssetType.Sprite,["sprite"],!1)],dt);var dn=(c5(og=function(){return uQ.apply(this,arguments)},uQ),og.prototype.load=function(e,t){var n=this;return new s$(function(r,i){n.request(e.url,c3({},e,{type:"image"})).then(function(n){var i,a=null!=(i=e.params)?i:{},o=new sj(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)})})},og);dn=c8([s1(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],dn);var dr=(c5(om=function(){return uQ.apply(this,arguments)},uQ),om.prototype.load=function(t,n){var r=this;return new s$(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,c3({},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 sY(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)})})},om);dr=c8([s1(e.AssetType.TextureCube,[""])],dr);var di=(c5(ov=function(){return uQ.apply(this,arguments)},uQ),ov.prototype.load=function(t,n){var r=this,i=n.engine;return new s$(function(a,o){r.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),h8.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 cS(i);n.textureCubeMap=e.specularTexture,n.textureDecodeRGBM=!0,t.material=n,t.mesh=ug.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;return 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)),Promise.all([s,u]).then(function(){a(r)})})}).catch(o)})},ov);di=c8([s1(e.AssetType.Scene,["prefab"],!0)],di),h2.registerCustomParseComponent("TextRenderer",hn(function(e,t,n){var r;return c6(this,function(i){return(r=t.props).font||(e.font=sZ.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var da="0.9.5";for(var ds in console.log("Galacean engine version: "+da),cB)uQ.registerClass(ds,cB[ds]);e.AmbientLight=uA,e.AnimationClip=cu,e.AnimationClipCurveBinding=cs,e.AnimationCurve=cc,e.AnimationEvent=cl,e.Animator=cg,e.AnimatorController=cm,e.AnimatorControllerLayer=cv,e.AnimatorState=cx,e.AnimatorStateMachine=cT,e.AnimatorStateTransition=cd,e.AssetPromise=s$,e.Background=ub,e.BaseMaterial=uJ,e.BasicRenderPipeline=uG,e.BlendShape=uy,e.BlendShapeFrame=uv,e.BlinnPhongMaterial=uZ,e.BoolUpdateFlag=le,e.BoundingBox=si,e.BoundingFrustum=ss,e.BoundingSphere=sr,e.BoxColliderShape=l_,e.Buffer=un,e.BufferMesh=um,e.BufferUtil=ue,e.CapsuleColliderShape=lg,e.CharacterController=lh,e.CloneManager=sE,e.ColliderShape=ld,e.CollisionUtil=sa,e.Color=sf,e.Component=lt,e.ComponentMap=h4,e.CubeProbe=cL,e.DirectLight=lH,e.DynamicCollider=lw,e.Engine=uL,e.EngineObject=sR,e.Entity=li,e.Event=sB,e.EventDispatcher=sD,e.FixedJoint=lv,e.Font=sZ,e.GLTFResource=hO,e.HingeJoint=ly,e.HitResult=ll,e.IndexBufferBinding=ur,e.InputManager=lP,e.JointLimits=lT,e.JointMotor=lC,e.Keyframe=cC,e.Light=lG,e.Loader=uQ,e.Logger=sz,e.Material=l$,e.MathUtil=st,e.Matrix=sc,e.Matrix3x3=sl,e.Mesh=ua,e.MeshRenderElement=l2,e.MeshRenderer=uc,e.ModelMesh=ul,e.ObjectValues=sW,e.PBRBaseMaterial=u$,e.PBRMaterial=u0,e.PBRSpecularMaterial=u1,e.ParticleRenderer=cw,e.PhysicsManager=lu,e.PhysicsMaterial=lc,e.Plane=so,e.PlaneColliderShape=lp,e.PointLight=lW,e.Pointer=la,e.PrefabParser=h3,e.PrimitiveMesh=ug,e.Probe=cF,e.Quaternion=su,e.Ray=sh,e.Rect=sp,e.RefObject=sL,e.ReflectionParser=h2,e.RenderPass=uk,e.RenderQueue=uI,e.RenderTarget=sK,e.ResourceManager=s0,e.Scene=uM,e.SceneManager=uF,e.SceneParser=h8,e.Script=uB,e.Shader=lz,e.ShaderData=lk,e.ShaderFactory=lD,e.ShaderPass=lU,e.ShaderProperty=lN,e.Skin=uu,e.SkinnedMeshRenderer=up,e.Sky=uw,e.SkyBoxMaterial=cS,e.SphereColliderShape=lf,e.SphericalHarmonics3=sg,e.SpotLight=lX,e.SpringJoint=lx,e.Sprite=u4,e.SpriteAtlas=u3,e.SpriteElement=l4,e.SpriteMask=l9,e.SpriteRenderer=u8,e.StateMachineScript=cy,e.StaticCollider=lS,e.SubMesh=ui,e.SystemInfo=lo,e.TextRenderer=ce,e.Texture=sX,e.Texture2D=sj,e.Texture2DArray=sq,e.TextureCube=sY,e.Time=sk,e.TrailMaterial=cb,e.TrailRenderer=cM,e.Transform=lr,e.UnlitMaterial=u2,e.Util=sG,e.Vector2=sd,e.Vector3=sn,e.Vector4=s_,e.VertexBufferBinding=uo,e.VertexElement=ut,e.WebCanvas=cG,e.WebGLEngine=c2,e.WebGLRenderer=c1,e.assignmentClone=sM,e.decode=h6,e.deepClone=sP,e.dependentComponents=s9,e.ignoreClone=sA,e.parseSingleKTX=hG,e.request=uK,e.resourceLoader=s1,e.shallowClone=sF,e.version=da,Object.defineProperty(e,"__esModule",{value:!0})});