@galacean/engine 1.4.0-alpha.0 → 1.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean={})}(this,function(e){"use strict";function t(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function n(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var r,a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,b,S,C,T,A,E,R,M,w,P,F,L,D,B,I,O,V,N,k,z,U,G,H,W,j,X,K,Y,q,Q,Z,J,$,ee,et,en,er,ea,ei,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eS,eC,eT,eA,eE,eR,eM,ew,eP,eF,eL,eD,eB,eI,eO,eV,eN,ek,ez,eU,eG,eH,eW,ej,eX,eK,eY,eq,eQ,eZ,eJ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tn,tr,ta,ti,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv=((td={})[td.Disjoint=0]="Disjoint",td[td.Contains=1]="Contains",td[td.Intersects=2]="Intersects",td),ty=((r={})[r.Back=0]="Back",r[r.Front=1]="Front",r[r.Intersecting=2]="Intersecting",r),tx=((a={})[a.Near=0]="Near",a[a.Far=1]="Far",a[a.Left=2]="Left",a[a.Right=3]="Right",a[a.Bottom=4]="Bottom",a[a.Top=5]="Top",a);function tb(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tS(e,t,n){return t&&tb(e.prototype,t),n&&tb(e,n),e}var tC=/*#__PURE__*/function(){function e(){}return e.clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},e.equals=function(t,n){return Math.abs(t-n)<=e.zeroTolerance},e.isPowerOf2=function(e){return(e&e-1)==0},e.radianToDegree=function(t){return t*e.radToDegreeFactor},e.degreeToRadian=function(t){return t*e.degreeToRadFactor},e.lerp=function(e,t,n){return e+(t-e)*n},e}();tC.zeroTolerance=1e-6,tC.radToDegreeFactor=180/Math.PI,tC.degreeToRadFactor=Math.PI/180;var tT=/*#__PURE__*/function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=n}var t=e.prototype;return t.set=function(e,t,n){return this._x=e,this._y=t,this._z=n,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z;return Math.sqrt(e*e+t*t+n*n)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z;return e*e+t*t+n*n},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},t.transformNormal=function(t){return e.transformNormal(this,t,this),this},t.transformToVec3=function(t){return e.transformToVec3(this,t,this),this},t.transformCoordinate=function(t){return e.transformCoordinate(this,t,this),this},t.transformByQuat=function(t){return e.transformByQuat(this,t,this),this},t.clone=function(){return new e(this._x,this._y,this._z)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._z=e._z-t._z,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._z=e._z*t._z,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._z=e._z/t._z,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},e.cross=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z;n.set(a*l-i*s,i*o-r*l,r*s-a*o)},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z;return Math.sqrt(n*n+r*r+a*a)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z;return n*n+r*r+a*a},e.equals=function(e,t){return tC.equals(e._x,t._x)&&tC.equals(e._y,t._y)&&tC.equals(e._z,t._z)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y,o=e._z;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._z=o+(t._z-o)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._z=Math.max(e._z,t._z),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._z=Math.min(e._z,t._z),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=Math.sqrt(n*n+r*r+a*a);i>tC.zeroTolerance&&(i=1/i,t.set(n*i,r*i,a*i))},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._onValueChanged&&n._onValueChanged()},e.transformNormal=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8],n._y=r*o[1]+a*o[5]+i*o[9],n._z=r*o[2]+a*o[6]+i*o[10],n._onValueChanged&&n._onValueChanged()},e.transformToVec3=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8]+o[12],n._y=r*o[1]+a*o[5]+i*o[9]+o[13],n._z=r*o[2]+a*o[6]+i*o[10]+o[14],n._onValueChanged&&n._onValueChanged()},e.transformToVec4=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8]+o[12],n._y=r*o[1]+a*o[5]+i*o[9]+o[13],n._z=r*o[2]+a*o[6]+i*o[10]+o[14],n._w=r*o[3]+a*o[7]+i*o[11]+o[15],n._onValueChanged&&n._onValueChanged()},e.transformCoordinate=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements,s=r*o[3]+a*o[7]+i*o[11]+o[15];s=1/s,n._x=(r*o[0]+a*o[4]+i*o[8]+o[12])*s,n._y=(r*o[1]+a*o[5]+i*o[9]+o[13])*s,n._z=(r*o[2]+a*o[6]+i*o[10]+o[14])*s,n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*r+s*i-l*a,d=c*a+l*r-o*i,h=c*i+o*a-s*r,_=-o*r-s*a-l*i;n._x=u*c-_*o-d*l+h*s,n._y=d*c-_*s-h*o+u*l,n._z=h*c-_*l-u*s+d*o,n._onValueChanged&&n._onValueChanged()},tS(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tT._zero=new tT(0,0,0),tT._one=new tT(1,1,1);var tA=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new tT,this.radius=0,e&&this.center.copyFrom(e),this.radius=t}var t=e.prototype;return t.clone=function(){return new e(this.center,this.radius)},t.copyFrom=function(e){return this.center.copyFrom(e.center),this.radius=e.radius,this},e.fromPoints=function(t,n){if(!t||0===t.length)throw Error("points must be array and length must > 0");var r=t.length,a=e._tempVec30;a.x=a.y=a.z=0;for(var i=0;i<r;++i)tT.add(t[i],a,a);tT.scale(a,1/r,n.center);for(var o=0,s=0;s<r;++s){var l=tT.distanceSquared(a,t[s]);l>o&&(o=l)}n.radius=Math.sqrt(o)},e.fromBox=function(e,t){var n=t.center,r=e.min,a=e.max;n.x=(r.x+a.x)*.5,n.y=(r.y+a.y)*.5,n.z=(r.z+a.z)*.5,t.radius=tT.distance(n,a)},e}();tA._tempVec30=new tT;var tE=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new tT,this.max=new tT,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}var t=e.prototype;return t.getCenter=function(e){var t=this.min,n=this.max,r=n._x+t._x,a=n._y+t._y,i=n._z+t._z;return e.set(isNaN(r)?0:.5*r,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},t.getExtent=function(e){var t=this.min,n=this.max,r=n._x-t._x,a=n._y-t._y,i=n._z-t._z;return e.set(isNaN(r)?0:.5*r,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},t.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,n=this.max,r=t.x,a=t.y,i=t.z,o=n.x,s=n.y,l=n.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new tT;return e[0].set(r,s,l),e[1].set(o,s,l),e[2].set(o,a,l),e[3].set(r,a,l),e[4].set(r,s,i),e[5].set(o,s,i),e[6].set(o,a,i),e[7].set(r,a,i),e},t.transform=function(t){return e.transform(this,t,this),this},t.clone=function(){return new e(this.min,this.max)},t.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},e.fromCenterAndExtent=function(e,t,n){tT.subtract(e,t,n.min),tT.add(e,t,n.max)},e.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var n=t.min,r=t.max;n.x=n.y=n.z=Number.MAX_VALUE,r.x=r.y=r.z=-Number.MAX_VALUE;for(var a=0,i=e.length;a<i;++a){var o=e[a];tT.min(n,o,n),tT.max(r,o,r)}},e.fromSphere=function(e,t){var n=e.center,r=e.radius,a=t.min,i=t.max;a.x=n.x-r,a.y=n.y-r,a.z=n.z-r,i.x=n.x+r,i.y=n.y+r,i.z=n.z+r},e.transform=function(t,n,r){var a=e._tempVec30,i=e._tempVec31;t.getCenter(a),t.getExtent(i),tT.transformCoordinate(a,n,a);var o=i.x,s=i.y,l=i.z,c=n.elements,u=c[0],d=c[1],h=c[2],_=c[4],f=c[5],p=c[6],m=c[8],g=c[9],v=c[10];i.set((0===u?0:Math.abs(o*u))+(0===_?0:Math.abs(s*_))+(0===m?0:Math.abs(l*m)),(0===d?0:Math.abs(o*d))+(0===f?0:Math.abs(s*f))+(0===g?0:Math.abs(l*g)),(0===h?0:Math.abs(o*h))+(0===p?0:Math.abs(s*p))+(0===v?0:Math.abs(l*v))),tT.subtract(a,i,r.min),tT.add(a,i,r.max)},e.merge=function(e,t,n){return tT.min(e.min,t.min,n.min),tT.max(e.max,t.max,n.max),n},e}();tE._tempVec30=new tT,tE._tempVec31=new tT;var tR=/*#__PURE__*/function(){function e(){}return e.intersectionPointThreePlanes=function(t,n,r,a){var i=t.normal,o=n.normal,s=r.normal;tT.cross(o,s,e._tempVec30),tT.cross(s,i,e._tempVec31),tT.cross(i,o,e._tempVec32);var l=-tT.dot(i,e._tempVec30),c=-tT.dot(o,e._tempVec31),u=-tT.dot(s,e._tempVec32);tT.scale(e._tempVec30,t.distance/l,e._tempVec30),tT.scale(e._tempVec31,n.distance/c,e._tempVec31),tT.scale(e._tempVec32,r.distance/u,e._tempVec32),tT.add(e._tempVec30,e._tempVec31,a),tT.add(a,e._tempVec32,a)},e.distancePlaneAndPoint=function(e,t){return tT.dot(e.normal,t)+e.distance},e.intersectsPlaneAndPoint=function(t,n){var r=e.distancePlaneAndPoint(t,n);return r>0?ty.Front:r<0?ty.Back:ty.Intersecting},e.intersectsPlaneAndBox=function(t,n){var r=n.min,a=n.max,i=t.normal,o=e._tempVec30,s=e._tempVec31;return(i.x>=0?(o.x=a.x,s.x=r.x):(o.x=r.x,s.x=a.x),i.y>=0?(o.y=a.y,s.y=r.y):(o.y=r.y,s.y=a.y),i.z>=0?(o.z=a.z,s.z=r.z):(o.z=r.z,s.z=a.z),0>e.distancePlaneAndPoint(t,o))?ty.Back:e.distancePlaneAndPoint(t,s)>0?ty.Front:ty.Intersecting},e.intersectsPlaneAndSphere=function(t,n){var r=n.center,a=n.radius,i=e.distancePlaneAndPoint(t,r);return i>a?ty.Front:i<-a?ty.Back:ty.Intersecting},e.intersectsRayAndPlane=function(e,t){var n=t.normal,r=tC.zeroTolerance,a=tT.dot(n,e.direction);if(Math.abs(a)<r)return -1;var i=tT.dot(n,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-r)return -1;o=0}return o},e.intersectsRayAndBox=function(e,t){var n=tC.zeroTolerance,r=e.origin,a=e.direction,i=t.min,o=t.max,s=a.x,l=a.y,c=a.z,u=r.x,d=r.y,h=r.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<n){if(u<i.x||u>o.x)return -1}else{var p=1/s,m=(i.x-u)*p,g=(o.x-u)*p;if(m>g){var v=m;m=g,g=v}if((_=Math.max(m,_))>(f=Math.min(g,f)))return -1}if(Math.abs(l)<n){if(d<i.y||d>o.y)return -1}else{var y=1/l,x=(i.y-d)*y,b=(o.y-d)*y;if(x>b){var S=x;x=b,b=S}if((_=Math.max(x,_))>(f=Math.min(b,f)))return -1}if(Math.abs(c)<n){if(h<i.z||h>o.z)return -1}else{var C=1/c,T=(i.z-h)*C,A=(o.z-h)*C;if(T>A){var E=T;T=A,A=E}if((_=Math.max(T,_))>(f=Math.min(A,f)))return -1}return _},e.intersectsRayAndSphere=function(t,n){var r=t.origin,a=t.direction,i=n.center,o=n.radius,s=e._tempVec30;tT.subtract(r,i,s);var l=tT.dot(s,a),c=tT.dot(s,s)-o*o;if(l>0&&c>0)return -1;var u=l*l-c;if(u<0)return -1;var d=-l-Math.sqrt(u);return d<0&&(d=0),d},e.intersectsBoxAndBox=function(e,t){return!(e.min.x>t.max.x)&&!(t.min.x>e.max.x)&&!(e.min.y>t.max.y)&&!(t.min.y>e.max.y)&&!(e.min.z>t.max.z||t.min.z>e.max.z)},e.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return tT.distanceSquared(e.center,t.center)<n*n},e.intersectsSphereAndBox=function(t,n){var r=t.center,a=n.max,i=n.min,o=e._tempVec30;return o.set(Math.max(i.x,Math.min(r.x,a.x)),Math.max(i.y,Math.min(r.y,a.y)),Math.max(i.z,Math.min(r.z,a.z))),tT.distanceSquared(r,o)<=t.radius*t.radius},e.intersectsFrustumAndBox=function(t,n){for(var r=n.min,a=n.max,i=e._tempVec30,o=0;o<6;++o){var s=t.getPlane(o),l=s.normal;if(i.set(l.x>=0?a.x:r.x,l.y>=0?a.y:r.y,l.z>=0?a.z:r.z),tT.dot(l,i)<-s.distance)return!1}return!0},e.frustumContainsPoint=function(t,n){var r=e.distancePlaneAndPoint(t.near,n);return Math.abs(r)<tC.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.far,n))<tC.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.left,n))<tC.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.right,n))<tC.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.top,n))<tC.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.bottom,n))<tC.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:tv.Contains},e.frustumContainsBox=function(t,n){for(var r=n.min,a=n.max,i=e._tempVec30,o=e._tempVec31,s=tv.Contains,l=0;l<6;++l){var c=t.getPlane(l),u=c.normal;if(u.x>=0?(i.x=a.x,o.x=r.x):(i.x=r.x,o.x=a.x),u.y>=0?(i.y=a.y,o.y=r.y):(i.y=r.y,o.y=a.y),u.z>=0?(i.z=a.z,o.z=r.z):(i.z=r.z,o.z=a.z),e.intersectsPlaneAndPoint(c,i)===ty.Back)return tv.Disjoint;e.intersectsPlaneAndPoint(c,o)===ty.Back&&(s=tv.Intersects)}return s},e.frustumContainsSphere=function(t,n){for(var r=tv.Contains,a=0;a<6;++a){var i=t.getPlane(a),o=e.intersectsPlaneAndSphere(i,n);if(o===ty.Back)return tv.Disjoint;if(o===ty.Intersecting){r=tv.Intersects;break}}return r},e}();tR._tempVec30=new tT,tR._tempVec31=new tT,tR._tempVec32=new tT;var tM=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new tT,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}var t=e.prototype;return t.normalize=function(){return e.normalize(this,this),this},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},e.normalize=function(e,t){var n=e.normal,r=1/n.length();tT.scale(n,r,t.normal),t.distance=e.distance*r},e.fromPoints=function(e,t,n,r){var a=e.x,i=e.y,o=e.z,s=t.x-a,l=t.y-i,c=t.z-o,u=n.x-a,d=n.y-i,h=n.z-o,_=l*h-c*d,f=c*u-s*h,p=s*d-l*u,m=1/Math.sqrt(_*_+f*f+p*p),g=_*m,v=f*m,y=p*m,x=r.normal;x.x=g,x.y=v,x.z=y,r.distance=-(g*a+v*i+y*o)},e}(),tw=/*#__PURE__*/function(){function e(e){void 0===e&&(e=null),this.near=new tM,this.far=new tM,this.left=new tM,this.right=new tM,this.top=new tM,this.bottom=new tM,e&&this.calculateFromMatrix(e)}var t=e.prototype;return t.getPlane=function(e){switch(e){case tx.Near:return this.near;case tx.Far:return this.far;case tx.Left:return this.left;case tx.Right:return this.right;case tx.Bottom:return this.bottom;case tx.Top:return this.top;default:return null}},t.calculateFromMatrix=function(e){var t=e.elements,n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],_=t[11],f=t[12],p=t[13],m=t[14],g=t[15];this.near.normal.set(i+a,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(i-a,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(i+n,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(i-n,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(i+r,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(i-r,c-s,_-d),this.top.distance=g-p,this.top.normalize()},t.intersectsBox=function(e){return tR.intersectsFrustumAndBox(this,e)},t.intersectsSphere=function(e){return tR.frustumContainsSphere(this,e)!==tv.Disjoint},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return this.near.copyFrom(e.near),this.far.copyFrom(e.far),this.left.copyFrom(e.left),this.right.copyFrom(e.right),this.bottom.copyFrom(e.bottom),this.top.copyFrom(e.top),this},e}(),tP=/*#__PURE__*/function(){function e(e,t,n,r,a,i,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l}var t=e.prototype;return t.set=function(e,t,n,r,a,i,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l,this},t.add=function(t){return e.add(this,t,this),this},t.subtract=function(t){return e.subtract(this,t,this),this},t.multiply=function(t){return e.multiply(this,t,this),this},t.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+n*(-c*a+o*s)+r*(l*a-i*s)},t.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},t.invert=function(){return e.invert(this,this),this},t.rotate=function(t){return e.rotate(this,t,this),this},t.scale=function(t){return e.scale(this,t,this),this},t.translate=function(t){return e.translate(this,t,this),this},t.transpose=function(){return e.transpose(this,this),this},t.clone=function(){var t=this.elements;return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},t.copyFrom=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},t.copyFromArray=function(e,t){void 0===t&&(t=0);for(var n=this.elements,r=0;r<12;r++)n[r]=e[r+t];return this},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.elements;e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8]},t.copyFromMatrix=function(e){var t=e.elements,n=this.elements;return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[4],n[4]=t[5],n[5]=t[6],n[6]=t[8],n[7]=t[9],n[8]=t[10],this},e.add=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3],i[4]=r[4]+a[4],i[5]=r[5]+a[5],i[6]=r[6]+a[6],i[7]=r[7]+a[7],i[8]=r[8]+a[8]},e.subtract=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]-a[0],i[1]=r[1]-a[1],i[2]=r[2]-a[2],i[3]=r[3]-a[3],i[4]=r[4]-a[4],i[5]=r[5]-a[5],i[6]=r[6]-a[6],i[7]=r[7]-a[7],i[8]=r[8]-a[8]},e.multiply=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],_=r[7],f=r[8],p=a[0],m=a[1],g=a[2],v=a[3],y=a[4],x=a[5],b=a[6],S=a[7],C=a[8];i[0]=o*p+c*m+h*g,i[1]=s*p+u*m+_*g,i[2]=l*p+d*m+f*g,i[3]=o*v+c*y+h*x,i[4]=s*v+u*y+_*x,i[5]=l*v+d*y+f*x,i[6]=o*b+c*S+h*C,i[7]=s*b+u*S+_*C,i[8]=l*b+d*S+f*C},e.equals=function(e,t){var n=e.elements,r=t.elements;return tC.equals(n[0],r[0])&&tC.equals(n[1],r[1])&&tC.equals(n[2],r[2])&&tC.equals(n[3],r[3])&&tC.equals(n[4],r[4])&&tC.equals(n[5],r[5])&&tC.equals(n[6],r[6])&&tC.equals(n[7],r[7])&&tC.equals(n[8],r[8])},e.lerp=function(e,t,n,r){var a=e.elements,i=t.elements,o=r.elements,s=1-n;o[0]=a[0]*s+i[0]*n,o[1]=a[1]*s+i[1]*n,o[2]=a[2]*s+i[2]*n,o[3]=a[3]*s+i[3]*n,o[4]=a[4]*s+i[4]*n,o[5]=a[5]*s+i[5]*n,o[6]=a[6]*s+i[6]*n,o[7]=a[7]*s+i[7]*n,o[8]=a[8]*s+i[8]*n},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,a=e._y,i=e._z,o=e._w,s=r+r,l=a+a,c=i+i,u=r*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;n[0]=1-h-p,n[3]=d-v,n[6]=_+g,n[1]=d+v,n[4]=1-u-p,n[7]=f-m,n[2]=_-g,n[5]=f+m,n[8]=1-u-h},e.scaling=function(e,t){var n=t.elements;n[0]=e._x,n[1]=0,n[2]=0,n[3]=0,n[4]=e._y,n[5]=0,n[6]=0,n[7]=0,n[8]=1},e.translation=function(e,t){var n=t.elements;n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=1,n[5]=0,n[6]=e._x,n[7]=e._y,n[8]=1},e.invert=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=h*l-c*d,f=-h*s+c*u,p=d*s-l*u,m=a*_+i*f+o*p;m&&(m=1/m,r[0]=_*m,r[1]=(-h*i+o*d)*m,r[2]=(c*i-o*l)*m,r[3]=f*m,r[4]=(h*a-o*u)*m,r[5]=(-c*a+o*s)*m,r[6]=p*m,r[7]=(-d*a+i*u)*m,r[8]=(l*a-i*s)*m)},e.normalMatrix=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15],x=a*c-i*l,b=a*u-o*l,S=a*d-s*l,C=i*u-o*c,T=i*d-s*c,A=o*d-s*u,E=h*g-_*m,R=h*v-f*m,M=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+S*w+C*M-T*R+A*E;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(u*M-l*F-d*R)*L,r[2]=(l*P-c*M+d*E)*L,r[3]=(o*P-i*F-s*w)*L,r[4]=(a*F-o*M+s*R)*L,r[5]=(i*M-a*P-s*E)*L,r[6]=(g*A-v*T+y*C)*L,r[7]=(v*S-m*A-y*b)*L,r[8]=(m*T-g*S+y*x)*L},e.rotate=function(e,t,n){var r=e.elements,a=n.elements,i=Math.sin(t),o=Math.cos(t),s=r[0],l=r[1],c=r[2],u=r[3],d=r[4],h=r[5],_=r[6],f=r[7],p=r[8];a[0]=o*s+i*u,a[1]=o*l+i*d,a[2]=o*c+i*h,a[3]=o*u-i*s,a[4]=o*d-i*l,a[5]=o*h-i*c,a[6]=_,a[7]=f,a[8]=p},e.scale=function(e,t,n){var r=t._x,a=t._y,i=e.elements,o=n.elements;o[0]=r*i[0],o[1]=r*i[1],o[2]=r*i[2],o[3]=a*i[3],o[4]=a*i[4],o[5]=a*i[5],o[6]=i[6],o[7]=i[7],o[8]=i[8]},e.translate=function(e,t,n){var r=t._x,a=t._y,i=e.elements,o=n.elements,s=i[0],l=i[1],c=i[2],u=i[3],d=i[4],h=i[5],_=i[6],f=i[7],p=i[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=d,o[5]=h,o[6]=r*s+a*u+_,o[7]=r*l+a*d+f,o[8]=r*c+a*h+p},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var a=n[1],i=n[2],o=n[5];r[1]=n[3],r[2]=n[6],r[3]=a,r[5]=n[7],r[6]=i,r[7]=o}else r[0]=n[0],r[1]=n[3],r[2]=n[6],r[3]=n[1],r[4]=n[4],r[5]=n[7],r[6]=n[2],r[7]=n[5],r[8]=n[8]},e}(),tF=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),this._onValueChanged=null,this._x=e,this._y=t,this._z=n,this._w=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},t.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},t.getAxisAngle=function(e){var t=this._x,n=this._y,r=this._z,a=t*t+n*n+r*r;if(a<tC.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var i=1/a;return e._x=this._x*i,e._y=this._y*i,e._z=this._z*i,2*Math.acos(this._w)},t.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},t.normalize=function(){return e.normalize(this,this),this},t.toEuler=function(e){this._toYawPitchRoll(e);var t=e._x;return e._x=e._y,e._y=t,e._onValueChanged&&e._onValueChanged(),e},t.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),e._onValueChanged&&e._onValueChanged(),e},t.rotateX=function(t){return e.rotateX(this,t,this),this},t.rotateY=function(t){return e.rotateY(this,t,this),this},t.rotateZ=function(t){return e.rotateZ(this,t,this),this},t.rotationAxisAngle=function(t,n){return e.rotationAxisAngle(t,n,this),this},t.multiply=function(t){return e.multiply(this,t,this),this},t.invert=function(){return e.invert(this,this),this},t.dot=function(t){return e.dot(this,t)},t.lerp=function(t,n){return e.lerp(this,t,n,this),this},t.rotateAxisAngle=function(t,n){return e._tempQuat1.rotationAxisAngle(t,n),this.multiply(e._tempQuat1),this},t.clone=function(){return new e(this._x,this._y,this._z,this._w)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},t._toYawPitchRoll=function(e){var t=this._x,n=this._y,r=this._z,a=this._w,i=t*t,o=n*n,s=r*r,l=a*a,c=i+o+s+l,u=2*(t*a-n*r);u>(1-tC.zeroTolerance)*c?(e._x=Math.atan2(2*(a*n-t*r),i+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-tC.zeroTolerance)*c?(e._x=Math.atan2(2*(a*n-t*r),i+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(r*t+n*a),s+l-o-i),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*n+r*a),o+l-s-i))},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._w=e._w+t._w,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;n._x=r*u+o*s+a*c-i*l,n._y=a*u+o*l+i*s-r*c,n._z=i*u+o*c+r*l-a*s,n._w=o*u-r*s-a*l-i*c,n._onValueChanged&&n._onValueChanged()},e.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.equals=function(e,t){return tC.equals(e._x,t._x)&&tC.equals(e._y,t._y)&&tC.equals(e._z,t._z)&&tC.equals(e._w,t._w)},e.rotationAxisAngle=function(t,n,r){var a=e._tempVector3;tT.normalize(t,a);var i=Math.sin(n*=.5);r._x=a._x*i,r._y=a._y*i,r._z=a._z*i,r._w=Math.cos(n),r._onValueChanged&&r._onValueChanged()},e.rotationEuler=function(t,n,r,a){e.rotationYawPitchRoll(n,t,r,a)},e.rotationYawPitchRoll=function(e,t,n,r){var a=.5*n,i=.5*t,o=.5*e,s=Math.sin(a),l=Math.cos(a),c=Math.sin(i),u=Math.cos(i),d=Math.sin(o),h=Math.cos(o),_=h*u,f=d*c;r._x=h*c*l+d*u*s,r._y=d*u*l-h*c*s,r._z=_*s-f*l,r._w=_*l+f*s,r._onValueChanged&&r._onValueChanged()},e.rotationMatrix3x3=function(e,t){var n,r,a=e.elements,i=a[0],o=a[1],s=a[2],l=a[3],c=a[4],u=a[5],d=a[6],h=a[7],_=a[8],f=i+c+_;f>0?(n=Math.sqrt(f+1),t._w=.5*n,n=.5/n,t._x=(u-h)*n,t._y=(d-s)*n,t._z=(o-l)*n):i>=c&&i>=_?(r=.5/(n=Math.sqrt(1+i-c-_)),t._x=.5*n,t._y=(o+l)*r,t._z=(s+d)*r,t._w=(u-h)*r):c>_?(r=.5/(n=Math.sqrt(1+c-i-_)),t._x=(l+o)*r,t._y=.5*n,t._z=(h+u)*r,t._w=(d-s)*r):(r=.5/(n=Math.sqrt(1+_-i-c)),t._x=(s+d)*r,t._y=(u+h)*r,t._z=.5*n,t._w=(o-l)*r),t._onValueChanged&&t._onValueChanged()},e.invert=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=n*n+r*r+a*a+i*i;if(o>tC.zeroTolerance){var s=1/o;t._x=-n*s,t._y=-r*s,t._z=-a*s,t._w=i*s,t._onValueChanged&&t._onValueChanged()}},e.lerp=function(t,n,r,a){var i=1-r;e.dot(t,n)>=0?(a._x=t._x*i+n._x*r,a._y=t._y*i+n._y*r,a._z=t._z*i+n._z*r,a._w=t._w*i+n._w*r):(a._x=t._x*i-n._x*r,a._y=t._y*i-n._y*r,a._z=t._z*i-n._z*r,a._w=t._w*i-n._w*r),a.normalize()},e.slerp=function(t,n,r,a){var i,o,s=e.dot(t,n);if(Math.abs(s)>1-tC.zeroTolerance)o=1-r,i=r*Math.sign(s);else{var l=Math.acos(Math.abs(s)),c=1/Math.sin(l);o=Math.sin((1-r)*l)*c,i=Math.sin(r*l)*c*Math.sign(s)}a.x=o*t.x+i*n.x,a.y=o*t.y+i*n.y,a.z=o*t.z+i*n.z,a.w=o*t.w+i*n.w,a._onValueChanged&&a._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=Math.sqrt(n*n+r*r+a*a+i*i);o>tC.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},e.rotationX=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=n,t._y=0,t._z=0,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotationY=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=0,t._y=n,t._z=0,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotationZ=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=0,t._y=0,t._z=n,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotateX=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+o*s,n._y=a*l+i*s,n._z=i*l-a*s,n._w=o*l-r*s,n._onValueChanged&&n._onValueChanged()},e.rotateY=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l-i*s,n._y=a*l+o*s,n._z=i*l+r*s,n._w=o*l-a*s,n._onValueChanged&&n._onValueChanged()},e.rotateZ=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+a*s,n._y=a*l-r*s,n._z=i*l+o*s,n._w=o*l-i*s,n._onValueChanged&&n._onValueChanged()},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._w=e._w*t,n._onValueChanged&&n._onValueChanged()},tS(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<tC.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tF._tempVector3=new tT,tF._tempQuat1=new tF;var tL=/*#__PURE__*/function(){function e(e,t,n,r,a,i,o,s,l,c,u,d,h,_,f,p){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===u&&(u=1),void 0===d&&(d=0),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===p&&(p=1),this.elements=new Float32Array(16);var m=this.elements;m[0]=e,m[1]=t,m[2]=n,m[3]=r,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,m[12]=h,m[13]=_,m[14]=f,m[15]=p}var t=e.prototype;return t.set=function(e,t,n,r,a,i,o,s,l,c,u,d,h,_,f,p){var m=this.elements;return m[0]=e,m[1]=t,m[2]=n,m[3]=r,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,m[12]=h,m[13]=_,m[14]=f,m[15]=p,this},t.multiply=function(t){return e.multiply(this,t,this),this},t.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],_=e[12],f=e[13],p=e[14],m=e[15];return(t*o-n*i)*(d*m-h*p)-(t*s-r*i)*(u*m-h*f)+(t*l-a*i)*(u*p-d*f)+(n*s-r*o)*(c*m-h*_)-(n*l-a*o)*(c*p-d*_)+(r*l-a*s)*(c*f-u*_)},t.decompose=function(t,n,r){var a=e._tempMat30,i=this.elements,o=a.elements,s=i[0],l=i[1],c=i[2],u=i[4],d=i[5],h=i[6],_=i[8],f=i[9],p=i[10];t.set(i[12],i[13],i[14]);var m=Math.sqrt(s*s+l*l+c*c),g=Math.sqrt(u*u+d*d+h*h),v=Math.sqrt(_*_+f*f+p*p);if(0>this.determinant()&&(m=-m),r.set(m,g,v),Math.abs(m)<tC.zeroTolerance||Math.abs(g)<tC.zeroTolerance||Math.abs(v)<tC.zeroTolerance)return n.identity(),!1;var y=1/m,x=1/g,b=1/v;return o[0]=s*y,o[1]=l*y,o[2]=c*y,o[3]=u*x,o[4]=d*x,o[5]=h*x,o[6]=_*b,o[7]=f*b,o[8]=p*b,tF.rotationMatrix3x3(a,n),!0},t.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>tC.zeroTolerance){var r=2*Math.sqrt(n+1);e._w=.25*r,e._x=(t[6]-t[9])/r,e._y=(t[8]-t[2])/r,e._z=(t[1]-t[4])/r}else if(t[0]>t[5]&&t[0]>t[10]){var a=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/a,e._x=.25*a,e._y=(t[1]+t[4])/a,e._z=(t[8]+t[2])/a}else if(t[5]>t[10]){var i=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/i,e._x=(t[1]+t[4])/i,e._y=.25*i,e._z=(t[6]+t[9])/i}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},t.getScaling=function(e){var t=this.elements,n=t[0],r=t[1],a=t[2],i=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(n*n+r*r+a*a),Math.sqrt(i*i+o*o+s*s),Math.sqrt(l*l+c*c+u*u)),e},t.getTranslation=function(e){var t=this.elements;return e.set(t[12],t[13],t[14]),e},t.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},t.invert=function(){return e.invert(this,this),this},t.rotateAxisAngle=function(t,n){return e.rotateAxisAngle(this,t,n,this),this},t.scale=function(t){return e.scale(this,t,this),this},t.translate=function(t){return e.translate(this,t,this),this},t.transpose=function(){return e.transpose(this,this),this},t.clone=function(){var t=this.elements;return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},t.copyFrom=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},t.copyFromArray=function(e,t){void 0===t&&(t=0);for(var n=this.elements,r=0;r<16;r++)n[r]=e[r+t];return this},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.elements;e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15]},e.multiply=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],_=r[7],f=r[8],p=r[9],m=r[10],g=r[11],v=r[12],y=r[13],x=r[14],b=r[15],S=a[0],C=a[1],T=a[2],A=a[3],E=a[4],R=a[5],M=a[6],w=a[7],P=a[8],F=a[9],L=a[10],D=a[11],B=a[12],I=a[13],O=a[14],V=a[15];i[0]=o*S+u*C+f*T+v*A,i[1]=s*S+d*C+p*T+y*A,i[2]=l*S+h*C+m*T+x*A,i[3]=c*S+_*C+g*T+b*A,i[4]=o*E+u*R+f*M+v*w,i[5]=s*E+d*R+p*M+y*w,i[6]=l*E+h*R+m*M+x*w,i[7]=c*E+_*R+g*M+b*w,i[8]=o*P+u*F+f*L+v*D,i[9]=s*P+d*F+p*L+y*D,i[10]=l*P+h*F+m*L+x*D,i[11]=c*P+_*F+g*L+b*D,i[12]=o*B+u*I+f*O+v*V,i[13]=s*B+d*I+p*O+y*V,i[14]=l*B+h*I+m*O+x*V,i[15]=c*B+_*I+g*O+b*V},e.equals=function(e,t){var n=e.elements,r=t.elements;return tC.equals(n[0],r[0])&&tC.equals(n[1],r[1])&&tC.equals(n[2],r[2])&&tC.equals(n[3],r[3])&&tC.equals(n[4],r[4])&&tC.equals(n[5],r[5])&&tC.equals(n[6],r[6])&&tC.equals(n[7],r[7])&&tC.equals(n[8],r[8])&&tC.equals(n[9],r[9])&&tC.equals(n[10],r[10])&&tC.equals(n[11],r[11])&&tC.equals(n[12],r[12])&&tC.equals(n[13],r[13])&&tC.equals(n[14],r[14])&&tC.equals(n[15],r[15])},e.lerp=function(e,t,n,r){var a=e.elements,i=t.elements,o=r.elements,s=1-n;o[0]=a[0]*s+i[0]*n,o[1]=a[1]*s+i[1]*n,o[2]=a[2]*s+i[2]*n,o[3]=a[3]*s+i[3]*n,o[4]=a[4]*s+i[4]*n,o[5]=a[5]*s+i[5]*n,o[6]=a[6]*s+i[6]*n,o[7]=a[7]*s+i[7]*n,o[8]=a[8]*s+i[8]*n,o[9]=a[9]*s+i[9]*n,o[10]=a[10]*s+i[10]*n,o[11]=a[11]*s+i[11]*n,o[12]=a[12]*s+i[12]*n,o[13]=a[13]*s+i[13]*n,o[14]=a[14]*s+i[14]*n,o[15]=a[15]*s+i[15]*n},e.add=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3],i[4]=r[4]+a[4],i[5]=r[5]+a[5],i[6]=r[6]+a[6],i[7]=r[7]+a[7],i[8]=r[8]+a[8],i[9]=r[9]+a[9],i[10]=r[10]+a[10],i[11]=r[11]+a[11],i[12]=r[12]+a[12],i[13]=r[13]+a[13],i[14]=r[14]+a[14],i[15]=r[15]+a[15]},e.multiplyScalar=function(e,t,n){var r=e.elements,a=n.elements;a[0]=r[0]*t,a[1]=r[1]*t,a[2]=r[2]*t,a[3]=r[3]*t,a[4]=r[4]*t,a[5]=r[5]*t,a[6]=r[6]*t,a[7]=r[7]*t,a[8]=r[8]*t,a[9]=r[9]*t,a[10]=r[10]*t,a[11]=r[11]*t,a[12]=r[12]*t,a[13]=r[13]*t,a[14]=r[14]*t,a[15]=r[15]*t},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,a=e._y,i=e._z,o=e._w,s=r+r,l=a+a,c=i+i,u=r*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;n[0]=1-h-p,n[1]=d+v,n[2]=_-g,n[3]=0,n[4]=d-v,n[5]=1-u-p,n[6]=f+m,n[7]=0,n[8]=_+g,n[9]=f-m,n[10]=1-u-h,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},e.rotationAxisAngle=function(e,t,n){var r,a,i,o=n.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<tC.zeroTolerance||(s*=u=1/u,l*=u,c*=u,r=Math.sin(t),i=1-(a=Math.cos(t)),o[0]=s*s*i+a,o[1]=l*s*i+c*r,o[2]=c*s*i-l*r,o[3]=0,o[4]=s*l*i-c*r,o[5]=l*l*i+a,o[6]=c*l*i+s*r,o[7]=0,o[8]=s*c*i+l*r,o[9]=l*c*i-s*r,o[10]=c*c*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},e.rotationTranslation=function(t,n,r){e.rotationQuaternion(t,r);var a=r.elements;a[12]=n._x,a[13]=n._y,a[14]=n._z},e.affineTransformation=function(e,t,n,r){var a=r.elements,i=t._x,o=t._y,s=t._z,l=t._w,c=i+i,u=o+o,d=s+s,h=i*c,_=i*u,f=i*d,p=o*u,m=o*d,g=s*d,v=l*c,y=l*u,x=l*d,b=e._x,S=e._y,C=e._z;a[0]=(1-(p+g))*b,a[1]=(_+x)*b,a[2]=(f-y)*b,a[3]=0,a[4]=(_-x)*S,a[5]=(1-(h+g))*S,a[6]=(m+v)*S,a[7]=0,a[8]=(f+y)*C,a[9]=(m-v)*C,a[10]=(1-(h+p))*C,a[11]=0,a[12]=n._x,a[13]=n._y,a[14]=n._z,a[15]=1},e.scaling=function(e,t){var n=t.elements;n[0]=e._x,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e._y,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e._z,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},e.translation=function(e,t){var n=t.elements;n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e._x,n[13]=e._y,n[14]=e._z,n[15]=1},e.invert=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15],x=a*c-i*l,b=a*u-o*l,S=a*d-s*l,C=i*u-o*c,T=i*d-s*c,A=o*d-s*u,E=h*g-_*m,R=h*v-f*m,M=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+S*w+C*M-T*R+A*E;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(o*P-i*F-s*w)*L,r[2]=(g*A-v*T+y*C)*L,r[3]=(f*T-_*A-p*C)*L,r[4]=(u*M-l*F-d*R)*L,r[5]=(a*F-o*M+s*R)*L,r[6]=(v*S-m*A-y*b)*L,r[7]=(h*A-f*S+p*b)*L,r[8]=(l*P-c*M+d*E)*L,r[9]=(i*M-a*P-s*E)*L,r[10]=(m*T-g*S+y*x)*L,r[11]=(_*S-h*T-p*x)*L,r[12]=(c*R-l*w-u*E)*L,r[13]=(a*w-i*R+o*E)*L,r[14]=(g*b-m*C-v*x)*L,r[15]=(h*C-_*b+f*x)*L},e.lookAt=function(t,n,r,a){var i=a.elements,o=e._tempVec30,s=e._tempVec31,l=e._tempVec32;tT.subtract(t,n,l),l.normalize(),tT.cross(r,l,o),o.normalize(),tT.cross(l,o,s),i[0]=o._x,i[1]=s._x,i[2]=l._x,i[3]=0,i[4]=o._y,i[5]=s._y,i[6]=l._y,i[7]=0,i[8]=o._z,i[9]=s._z,i[10]=l._z,i[11]=0,i[12]=-tT.dot(o,t),i[13]=-tT.dot(s,t),i[14]=-tT.dot(l,t),i[15]=1},e.ortho=function(e,t,n,r,a,i,o){var s=o.elements,l=1/(e-t),c=1/(n-r),u=1/(a-i);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*u,s[11]=0,s[12]=(e+t)*l,s[13]=(r+n)*c,s[14]=(i+a)*u,s[15]=1},e.perspective=function(e,t,n,r,a){var i=a.elements,o=1/Math.tan(e/2),s=1/(n-r);i[0]=o/t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(r+n)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=2*r*n*s,i[15]=0},e.rotateAxisAngle=function(e,t,n,r){var a,i,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<tC.zeroTolerance)){var d=e.elements,h=r.elements;s*=u=1/u,l*=u,c*=u,a=Math.sin(n),o=1-(i=Math.cos(n));var _=d[0],f=d[1],p=d[2],m=d[3],g=d[4],v=d[5],y=d[6],x=d[7],b=d[8],S=d[9],C=d[10],T=d[11],A=s*s*o+i,E=l*s*o+c*a,R=c*s*o-l*a,M=s*l*o-c*a,w=l*l*o+i,P=c*l*o+s*a,F=s*c*o+l*a,L=l*c*o-s*a,D=c*c*o+i;h[0]=_*A+g*E+b*R,h[1]=f*A+v*E+S*R,h[2]=p*A+y*E+C*R,h[3]=m*A+x*E+T*R,h[4]=_*M+g*w+b*P,h[5]=f*M+v*w+S*P,h[6]=p*M+y*w+C*P,h[7]=m*M+x*w+T*P,h[8]=_*F+g*L+b*D,h[9]=f*F+v*L+S*D,h[10]=p*F+y*L+C*D,h[11]=m*F+x*L+T*D,e!==r&&(h[12]=d[12],h[13]=d[13],h[14]=d[14],h[15]=d[15])}},e.scale=function(e,t,n){var r=e.elements,a=n.elements,i=t._x,o=t._y,s=t._z;a[0]=r[0]*i,a[1]=r[1]*i,a[2]=r[2]*i,a[3]=r[3]*i,a[4]=r[4]*o,a[5]=r[5]*o,a[6]=r[6]*o,a[7]=r[7]*o,a[8]=r[8]*s,a[9]=r[9]*s,a[10]=r[10]*s,a[11]=r[11]*s,a[12]=r[12],a[13]=r[13],a[14]=r[14],a[15]=r[15]},e.translate=function(e,t,n){var r=e.elements,a=n.elements,i=t._x,o=t._y,s=t._z;if(e===n)a[12]=r[0]*i+r[4]*o+r[8]*s+r[12],a[13]=r[1]*i+r[5]*o+r[9]*s+r[13],a[14]=r[2]*i+r[6]*o+r[10]*s+r[14],a[15]=r[3]*i+r[7]*o+r[11]*s+r[15];else{var l=r[0],c=r[1],u=r[2],d=r[3],h=r[4],_=r[5],f=r[6],p=r[7],m=r[8],g=r[9],v=r[10],y=r[11];a[0]=l,a[1]=c,a[2]=u,a[3]=d,a[4]=h,a[5]=_,a[6]=f,a[7]=p,a[8]=m,a[9]=g,a[10]=v,a[11]=y,a[12]=l*i+h*o+m*s+r[12],a[13]=c*i+_*o+g*s+r[13],a[14]=u*i+f*o+v*s+r[14],a[15]=d*i+p*o+y*s+r[15]}},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var a=n[1],i=n[2],o=n[3],s=n[6],l=n[7],c=n[11];r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=a,r[6]=n[9],r[7]=n[13],r[8]=i,r[9]=s,r[11]=n[14],r[12]=o,r[13]=l,r[14]=c}else r[0]=n[0],r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=n[1],r[5]=n[5],r[6]=n[9],r[7]=n[13],r[8]=n[2],r[9]=n[6],r[10]=n[10],r[11]=n[14],r[12]=n[3],r[13]=n[7],r[14]=n[11],r[15]=n[15]},e}();tL._tempVec30=new tT,tL._tempVec31=new tT,tL._tempVec32=new tT,tL._tempMat30=new tP,tL._identity=new tL(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var tD=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new tT,this.direction=new tT,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}var t=e.prototype;return t.intersectPlane=function(e){return tR.intersectsRayAndPlane(this,e)},t.intersectSphere=function(e){return tR.intersectsRayAndSphere(this,e)},t.intersectBox=function(e){return tR.intersectsRayAndBox(this,e)},t.getPoint=function(e,t){return tT.scale(this.direction,e,t),t.add(this.origin)},e}(),tB=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}var t=e.prototype;return t.set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},t.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._x,this._y)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},t.toJSON=function(){return{x:this._x,y:this._y}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y;return Math.sqrt(n*n+r*r)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y;return n*n+r*r},e.equals=function(e,t){return tC.equals(e._x,t._x)&&tC.equals(e._y,t._y)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=Math.sqrt(n*n+r*r);a>tC.zeroTolerance&&(a=1/a,t._x=n*a,t._y=r*a,t._onValueChanged&&t._onValueChanged())},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._onValueChanged&&n._onValueChanged()},tS(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tB._zero=new tB(0,0),tB._one=new tB(1,1);var tI=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=n,this._w=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._x,this._y,this._z,this._w)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._w=e._w+t._w,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._z=e._z-t._z,n._w=e._w-t._w,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._z=e._z*t._z,n._w=e._w*t._w,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._z=e._z/t._z,n._w=e._w/t._w,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return Math.sqrt(n*n+r*r+a*a+i*i)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return n*n+r*r+a*a+i*i},e.equals=function(e,t){return tC.equals(e._x,t._x)&&tC.equals(e._y,t._y)&&tC.equals(e._z,t._z)&&tC.equals(e._w,t._w)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y,o=e._z,s=e._w;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._z=o+(t._z-o)*n,r._w=s+(t._w-s)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._z=Math.max(e._z,t._z),n._w=Math.max(e._w,t._w),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._z=Math.min(e._z,t._z),n._w=Math.min(e._w,t._w),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=Math.sqrt(n*n+r*r+a*a+i*i);o>tC.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._w=e._w*t,n._onValueChanged&&n._onValueChanged()},e.transform=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t.elements;n._x=r*s[0]+a*s[4]+i*s[8]+o*s[12],n._y=r*s[1]+a*s[5]+i*s[9]+o*s[13],n._z=r*s[2]+a*s[6]+i*s[10]+o*s[14],n._w=r*s[3]+a*s[7]+i*s[11]+o*s[15],n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,d=u*r+l*i-c*a,h=u*a+c*r-s*i,_=u*i+s*a-l*r,f=-s*r-l*a-c*i;n._x=d*u-f*s-h*c+_*l,n._y=h*u-f*l-_*s+d*c,n._z=_*u-f*c-d*l+h*s,n._w=o,n._onValueChanged&&n._onValueChanged()},tS(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tI._zero=new tI(0,0,0,0),tI._one=new tI(1,1,1,1);var tO=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),this._onValueChanged=null,this._r=e,this._g=t,this._b=n,this._a=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,this._onValueChanged&&this._onValueChanged(),this},t.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._r,this._g,this._b,this._a)},t.copyFrom=function(e){return this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.r=this._r,e.g=this._g,e.b=this._b,e.a=this._a,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._r=e[t],this._g=e[t+1],this._b=e[t+2],this._a=e[t+3],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._r,e[t+1]=this._g,e[t+2]=this._b,e[t+3]=this._a},t.toLinear=function(t){return t._r=e.gammaToLinearSpace(this._r),t._g=e.gammaToLinearSpace(this._g),t._b=e.gammaToLinearSpace(this._b),t._onValueChanged&&t._onValueChanged(),t},t.toGamma=function(t){return t._r=e.linearToGammaSpace(this._r),t._g=e.linearToGammaSpace(this._g),t._b=e.linearToGammaSpace(this._b),t._onValueChanged&&t._onValueChanged(),t},t.getBrightness=function(){var e=this.r,t=this.g,n=this.b,r=e,a=e;return t>r&&(r=t),n>r&&(r=n),t<a&&(a=t),n<a&&(a=n),(r+a)/2},t.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},e.gammaToLinearSpace=function(e){return e<=0?0:e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},e.linearToGammaSpace=function(e){return e<=0?0:e<.0031308?12.92*e:e<1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},e.equals=function(e,t){return tC.equals(e._r,t._r)&&tC.equals(e._g,t._g)&&tC.equals(e._b,t._b)&&tC.equals(e._a,t._a)},e.add=function(e,t,n){return n._r=e._r+t._r,n._g=e._g+t._g,n._b=e._b+t._b,n._a=e._a+t._a,n._onValueChanged&&n._onValueChanged(),n},e.subtract=function(e,t,n){n._r=e._r-t._r,n._g=e._g-t._g,n._b=e._b-t._b,n._a=e._a-t._a,n._onValueChanged&&n._onValueChanged()},e.scale=function(e,t,n){return n._r=e._r*t,n._g=e._g*t,n._b=e._b*t,n._a=e._a*t,n._onValueChanged&&n._onValueChanged(),n},e.lerp=function(e,t,n,r){var a=e._r,i=e._g,o=e._b,s=e._a;return r._r=a+(t._r-a)*n,r._g=i+(t._g-i)*n,r._b=o+(t._b-o)*n,r._a=s+(t._a-s)*n,r._onValueChanged&&r._onValueChanged(),r},tS(e,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,this._onValueChanged&&this._onValueChanged()}}]),e}(),tV=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._width=n,this._height=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._width=n,this._height=r,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this.x,this.y,this.width,this.height)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._width=e.width,this._height=e.height,this._onValueChanged&&this._onValueChanged(),this},tS(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._onValueChanged&&this._onValueChanged()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._onValueChanged&&this._onValueChanged()}}]),e}(),tN=/*#__PURE__*/function(){function e(){this.coefficients=new Float32Array(27)}var t=e.prototype;return t.addLight=function(e,t,n){t.scale(n);var r=this.coefficients,a=e._x,i=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*i,d=.488603*o,h=-.488603*a,_=a*i*1.092548,f=-(i*o*1.092548),p=.315392*(3*o*o-1),m=-(a*o*1.092548),g=.546274*(a*a-i*i);r[0]+=.282095*s,r[1]+=.282095*l,r[2]+=.282095*c,r[3]+=s*u,r[4]+=l*u,r[5]+=c*u,r[6]+=s*d,r[7]+=l*d,r[8]+=c*d,r[9]+=s*h,r[10]+=l*h,r[11]+=c*h,r[12]+=s*_,r[13]+=l*_,r[14]+=c*_,r[15]+=s*f,r[16]+=l*f,r[17]+=c*f,r[18]+=s*p,r[19]+=l*p,r[20]+=c*p,r[21]+=s*m,r[22]+=l*m,r[23]+=c*m,r[24]+=s*g,r[25]+=l*g,r[26]+=c*g},t.evaluate=function(e,t){var n=this.coefficients,r=e._x,a=e._y,i=e._z,o=-1.023327*a,s=1.023327*i,l=-1.023327*r,c=.858086*a*r,u=-.858086*a*i,d=.247708*(3*i*i-1),h=-.858086*i*r,_=.429042*(r*r-a*a),f=.886227*n[0],p=.886227*n[1],m=.886227*n[2];return f+=n[3]*o+n[6]*s+n[9]*l,p+=n[4]*o+n[7]*s+n[10]*l,m+=n[5]*o+n[8]*s+n[11]*l,f+=n[12]*c+n[15]*u+n[18]*d+n[21]*h+n[24]*_,p+=n[13]*c+n[16]*u+n[19]*d+n[22]*h+n[25]*_,m+=n[14]*c+n[17]*u+n[20]*d+n[23]*h+n[26]*_,t.set(f,p,m,1),t},t.scale=function(e){var t=this.coefficients;t[0]*=e,t[1]*=e,t[2]*=e,t[3]*=e,t[4]*=e,t[5]*=e,t[6]*=e,t[7]*=e,t[8]*=e,t[9]*=e,t[10]*=e,t[11]*=e,t[12]*=e,t[13]*=e,t[14]*=e,t[15]*=e,t[16]*=e,t[17]*=e,t[18]*=e,t[19]*=e,t[20]*=e,t[21]*=e,t[22]*=e,t[23]*=e,t[24]*=e,t[25]*=e,t[26]*=e},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return e.copyToArray(this.coefficients),this},t.copyFromArray=function(e,t){void 0===t&&(t=0);var n=this.coefficients;n[0]=e[t],n[1]=e[1+t],n[2]=e[2+t],n[3]=e[3+t],n[4]=e[4+t],n[5]=e[5+t],n[6]=e[6+t],n[7]=e[7+t],n[8]=e[8+t],n[9]=e[9+t],n[10]=e[10+t],n[11]=e[11+t],n[12]=e[12+t],n[13]=e[13+t],n[14]=e[14+t],n[15]=e[15+t],n[16]=e[16+t],n[17]=e[17+t],n[18]=e[18+t],n[19]=e[19+t],n[20]=e[20+t],n[21]=e[21+t],n[22]=e[22+t],n[23]=e[23+t],n[24]=e[24+t],n[25]=e[25+t],n[26]=e[26+t]},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.coefficients;e[0+t]=n[0],e[1+t]=n[1],e[2+t]=n[2],e[3+t]=n[3],e[4+t]=n[4],e[5+t]=n[5],e[6+t]=n[6],e[7+t]=n[7],e[8+t]=n[8],e[9+t]=n[9],e[10+t]=n[10],e[11+t]=n[11],e[12+t]=n[12],e[13+t]=n[13],e[14+t]=n[14],e[15+t]=n[15],e[16+t]=n[16],e[17+t]=n[17],e[18+t]=n[18],e[19+t]=n[19],e[20+t]=n[20],e[21+t]=n[21],e[22+t]=n[22],e[23+t]=n[23],e[24+t]=n[24],e[25+t]=n[25],e[26+t]=n[26]},e}(),tk=/*#__PURE__*/function(){function e(e,t){this.reset(e,t)}var t=e.prototype;return t.randomInt32=function(){var e=this._state0,t=this._state1;return this._state0=t,e^=e<<23,e^=e>>>17,e^=t^t>>>26,this._state1=e,this._state0+this._state1>>>0},t.random=function(){return this.randomInt32()/0xffffffff},t.reset=function(e,t){this._state0=e>>>0,this._state1=t>>>0},e}(),tz=((i={})[i.Android=0]="Android",i[i.IPhone=1]="IPhone",i[i.IPad=2]="IPad",i[i.Mac=3]="Mac",i[i.Unknown=4]="Unknown",i);function tU(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tG(e,t,n){return t&&tU(e.prototype,t),n&&tU(e,n),e}function tH(e,t){return(tH=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tW(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tH(e,t)}var tj=/*#__PURE__*/function(){function e(){this.localPositions=new tI}return e.prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},e}();function tX(e,t,r,a){var i,o=arguments.length,s=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function tK(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}tj.triangles=[0,2,1,2,0,3],"function"==typeof SuppressedError&&SuppressedError;var tY=((o={})[o.Ignore=0]="Ignore",o[o.Assignment=1]="Assignment",o[o.Shallow=2]="Shallow",o[o.Deep=3]="Deep",o);function tq(e,t){t$.registerCloneMode(e,t,tY.Ignore)}function tQ(e,t){t$.registerCloneMode(e,t,tY.Assignment)}function tZ(e,t){t$.registerCloneMode(e,t,tY.Shallow)}function tJ(e,t){t$.registerCloneMode(e,t,tY.Deep)}var t$=/*#__PURE__*/function(){function e(){}return e.registerCloneMode=function(t,n,r){var a=e._subCloneModeMap.get(t.constructor);a||(a=Object.create(null),e._subCloneModeMap.set(t.constructor,a)),a[n]=r},e.getCloneMode=function(t){var n=e._cloneModeMap.get(t);if(!n){n=Object.create(null),e._cloneModeMap.set(t,n);for(var r=e._objectType,a=e._subCloneModeMap;t!==r;){var i=a.get(t);i&&Object.assign(n,i),t=Object.getPrototypeOf(t)}}return n},e.cloneProperty=function(t,n,r,a,i,o,s){if(a!==tY.Ignore){var l=t[r];if(tK(l,Object)){if(void 0===a||a===tY.Assignment){n[r]=l;return}switch(l.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var c=n[r];null==c||c.length!==l.length?n[r]=l.slice():c.set(l);break;case Array:var u=n[r],d=l.length;null==u?n[r]=u=Array(d):u.length=d;for(var h=0;h<d;h++)e.cloneProperty(l,u,h,a,i,o,s);break;default:var _=n[r];if(_||((_=s.get(l))||(_=new l.constructor,s.set(l,_)),n[r]=_),l.copyFrom)_.copyFrom(l);else{var f=e.getCloneMode(l.constructor);for(var p in l)e.cloneProperty(l,_,p,f[p],i,o,s);l._cloneTo&&l._cloneTo(_,i,o)}}}else n[r]=l}},e.deepCloneObject=function(t,n,r){for(var a in t)e.cloneProperty(t,n,a,tY.Deep,null,null,r)},e}();t$._subCloneModeMap=new Map,t$._cloneModeMap=new Map,t$._objectType=Object.getPrototypeOf(Object);var t0=/*#__PURE__*/function(){function e(t){this.instanceId=++e._instanceIdCounter,this._destroyed=!1,this._engine=t}var t=e.prototype;return t.destroy=function(){this._destroyed||(this._onDestroy(),this._destroyed=!0)},t._onDestroy=function(){var e=this._engine.resourceManager;e._deleteAsset(this),e._deleteContentRestorer(this)},tG(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();t0._instanceIdCounter=0,tX([tq],t0.prototype,"instanceId",void 0),tX([tq],t0.prototype,"_engine",void 0);var t1=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).isGCIgnored=!1,n._refCount=0,n._superResources=null,t.resourceManager._addReferResource(n),n}tW(t,e);var n=t.prototype;return n.destroy=function(t,n){if(void 0===t&&(t=!1),!t){if(0!==this._refCount)return!1;var r=this._superResources;if(null==r?void 0:r.length){if(!n)return!1;for(var a=0,i=r.length;a<i;a++)if(r[a].refCount>0)return!1}}return e.prototype.destroy.call(this),!0},n._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},n._disassociationSuperResource=function(e){var t=this._superResources,n=t.indexOf(e);t.splice(n,1)},n._getReferCount=function(){return this._refCount},n._addReferCount=function(e){this._refCount+=e},n._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var t=this._getReferCount();t>0&&this._addReferCount(-t)},tG(t,[{key:"refCount",get:function(){return this._refCount}}]),t}(t0),t2=function(e){this.resource=e},t3=((s={})[s.Depth=27]="Depth",s[s.Stencil=28]="Stencil",s[s.DepthStencil=29]="DepthStencil",s[s.Depth16=30]="Depth16",s[s.Depth24=31]="Depth24",s[s.Depth32=32]="Depth32",s[s.Depth24Stencil8=33]="Depth24Stencil8",s[s.Depth32Stencil8=34]="Depth32Stencil8",s),t4=((l={})[l.PositiveX=0]="PositiveX",l[l.NegativeX=1]="NegativeX",l[l.PositiveY=2]="PositiveY",l[l.NegativeY=3]="NegativeY",l[l.PositiveZ=4]="PositiveZ",l[l.NegativeZ=5]="NegativeZ",l),t8=((c={})[c.Never=0]="Never",c[c.Less=1]="Less",c[c.Equal=2]="Equal",c[c.LessEqual=3]="LessEqual",c[c.Greater=4]="Greater",c[c.NotEqual=5]="NotEqual",c[c.GreaterEqual=6]="GreaterEqual",c[c.Always=7]="Always",c),t5=((u={})[u.Point=0]="Point",u[u.Bilinear=1]="Bilinear",u[u.Trilinear=2]="Trilinear",u),t9=((d={})[d.R8G8B8=0]="R8G8B8",d[d.R8G8B8A8=1]="R8G8B8A8",d[d.R4G4B4A4=2]="R4G4B4A4",d[d.R5G5B5A1=3]="R5G5B5A1",d[d.R5G6B5=4]="R5G6B5",d[d.Alpha8=5]="Alpha8",d[d.LuminanceAlpha=6]="LuminanceAlpha",d[d.R16G16B16A16=7]="R16G16B16A16",d[d.R32G32B32A32=8]="R32G32B32A32",d[d.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",d[d.R11G11B10_UFloat=35]="R11G11B10_UFloat",d[d.BC1=10]="BC1",d[d.BC3=11]="BC3",d[d.BC7=12]="BC7",d[d.ETC1_RGB=13]="ETC1_RGB",d[d.ETC2_RGB=14]="ETC2_RGB",d[d.ETC2_RGBA5=15]="ETC2_RGBA5",d[d.ETC2_RGBA8=16]="ETC2_RGBA8",d[d.PVRTC_RGB2=17]="PVRTC_RGB2",d[d.PVRTC_RGBA2=18]="PVRTC_RGBA2",d[d.PVRTC_RGB4=19]="PVRTC_RGB4",d[d.PVRTC_RGBA4=20]="PVRTC_RGBA4",d[d.ASTC_4x4=21]="ASTC_4x4",d[d.ASTC_5x5=22]="ASTC_5x5",d[d.ASTC_6x6=23]="ASTC_6x6",d[d.ASTC_8x8=24]="ASTC_8x8",d[d.ASTC_10x10=25]="ASTC_10x10",d[d.ASTC_12x12=26]="ASTC_12x12",d[d.Depth=27]="Depth",d[d.Stencil=28]="Stencil",d[d.DepthStencil=29]="DepthStencil",d[d.Depth16=30]="Depth16",d[d.Depth24=31]="Depth24",d[d.Depth32=32]="Depth32",d[d.Depth24Stencil8=33]="Depth24Stencil8",d[d.Depth32Stencil8=34]="Depth32Stencil8",d[d.DXT1=10]="DXT1",d[d.DXT5=11]="DXT5",d),t6=((h={})[h.Static=0]="Static",h[h.Dynamic=1]="Dynamic",h),t7=((_={})[_.Clamp=0]="Clamp",_[_.Repeat=1]="Repeat",_[_.Mirror=2]="Mirror",_),ne=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._isContentLost=!1,t.resourceManager._addGraphicResource(n),n}return tW(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},tG(t,[{key:"isContentLost",get:function(){return this._isContentLost}}]),t}(t1),nt=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},nn=console.log.bind(console),nr=console.info.bind(console),na=console.warn.bind(console),ni=console.error.bind(console),no={debug:nt,info:nt,warn:nt,error:nt,isEnabled:!1,enable:function(){this.debug=nn,this.info=nr,this.warn=na,this.error=ni,this.isEnabled=!0},disable:function(){this.debug=nt,this.info=nt,this.warn=nt,this.error=nt,this.isEnabled=!1}},ns=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._isDepthTexture=!1,t._anisoLevel=1,t._useDepthCompareMode=!1,t}tW(t,e);var n=t.prototype;return n.generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},n._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},n._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,this._engine._hardwareRenderer._isWebGL2&&(e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode))},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},n._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},n._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},n._isIntFormat=function(){return t9.R32G32B32A32_UInt===this._format},tG(t,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){if(e!==this._filterMode){if(e!==t5.Point&&this._isIntFormat()){e=t5.Point,no.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=e,this._platformTexture.filterMode=e}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(no.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(no.warn("anisoLevel:"+e+", must be greater than 0, and is automatically downgraded to 1"),e=1),e!==this._anisoLevel&&(this._anisoLevel=e,this._platformTexture.anisoLevel=e)}},{key:"depthCompareFunction",get:function(){return this._depthCompareFunction},set:function(e){if(!this._engine._hardwareRenderer._isWebGL2){console.warn("depthCompareFunction only support WebGL2");return}e!==this._depthCompareFunction&&(this._depthCompareFunction=e,this._platformTexture.depthCompareFunction=e)}}]),t}(ne),nl=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){if(void 0===i&&(i=t9.Depth),void 0===o&&(o=1),(s=e.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._width=n,s._height=r,s._antiAliasing=o,s._depth=i,a){for(var s,l=tK(a,Array)?a.slice():[a],c=0,u=l.length;c<u;c++){var d=l[c];if(d._isDepthTexture)throw"Render texture can't use depth format.";d._addReferCount(1)}s._colorTextures=l}else s._colorTextures=[];if(tK(i,ns)){if(!i._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=i,s._depthTexture._addReferCount(1),s._depthFormat=i.format}else"number"==typeof i&&(s._depthFormat=i);return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(s),s}tW(t,e);var n=t.prototype;return n.getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},n.generateMipmaps=function(){if(this._autoGenerateMipmaps){for(var e=this._colorTextures,t=0,n=e.length;t<n;t++)e[t].generateMipmaps();this._depthTexture&&this._depthTexture.generateMipmaps()}},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var t,n=this._colorTextures,r=0,a=n.length;r<a;r++)n[r]._addReferCount(-1);n.length=0,null==(t=this._depthTexture)||t._addReferCount(-1),this._depthTexture=null,this._depth=null},n._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},n._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},tG(t,[{key:"autoGenerateMipmaps",get:function(){return this._autoGenerateMipmaps},set:function(e){this._autoGenerateMipmaps=e}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"colorTextureCount",get:function(){return this._colorTextures.length}},{key:"depthTexture",get:function(){return this._depthTexture}},{key:"antiAliasing",get:function(){return this._antiAliasing}}]),t}(ne),nc=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===a&&(a=t9.R8G8B8A8),void 0===i&&(i=!0),void 0===o&&(o=t6.Static),(s=e.call(this,t)||this)._mipmap=i,s._width=n,s._height=r,s._usage=o,s._format=a,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=a==t9.Depth||a==t9.DepthStencil||a==t9.Depth16||a==t9.Depth24||a==t9.Depth32||a==t9.Depth24Stencil8||a==t9.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(s),s.filterMode=s._isIntFormat()?t5.Point:t5.Bilinear,s.wrapModeU=s.wrapModeV=t7.Repeat,s}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===a&&(a=0),void 0===i&&(i=0),this._platformTexture.setImageSource(e,t,n,r,a,i),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,a,i){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,n,r,0,a):6===o&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),e.prototype._rebuild.call(this)},t}(ns),nu=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===i&&(i=t9.R8G8B8A8),void 0===o&&(o=!0),(s=e.call(this,t)||this)._mipmap=o,s._width=n,s._height=r,s._length=a,s._format=i,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(s),s.filterMode=t5.Bilinear,s.wrapModeU=s.wrapModeV=t7.Repeat,s}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o,s){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i,o,s),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,a,i,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,a,i,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):5===s?this._platformTexture.getPixelBuffer(e,t,n,r,a,0,i):6===s&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),e.prototype._rebuild.call(this)},tG(t,[{key:"length",get:function(){return this._length}}]),t}(ns),nd=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return void 0===r&&(r=t9.R8G8B8A8),void 0===a&&(a=!0),(i=e.call(this,t)||this)._mipmap=a,i._width=n,i._height=n,i._format=r,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(i),i.filterMode=t5.Bilinear,i.wrapModeU=i.wrapModeV=t7.Clamp,i}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i,o),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,a,i,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,a,i,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):6===s?this._platformTexture.getPixelBuffer(e,t,n,r,a,0,i):7===s&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),e.prototype._rebuild.call(this)},t}(ns),nh=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._charInfoMap={},n._space=1,n._curX=1,n._curY=1,n._nextY=1,n}tW(t,e);var n=t.prototype;return n.uploadCharTexture=function(e){var t=e.w,n=e.h,r=e.data,a=this._space,i=this.texture,o=i.width,s=t+a,l=n+a;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=a,this._curY=this._nextY+a);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&n>0&&r&&(e.bufferOffset=new tB(this._curX,this._curY),i.setPixelBuffer(r,0,this._curX,this._curY,t,n),i.generateMipmaps());var u=1/o,d=this._curX,h=this._curY,_=d*u,f=(d+t)*u,p=h*u,m=(h+n)*u;e.x=d,e.y=h;var g=e.uvs;return g[0].set(_,p),g[1].set(f,p),g[2].set(f,m),g[3].set(_,m),this._curX+=s+a,!0},n.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},n.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},t}(t1),n_=((f={})[f.None=0]="None",f[f.Bold=1]="Bold",f[f.Italic=2]="Italic",f),nf=((p={})[p.Overflow=0]="Overflow",p[p.Truncate=1]="Truncate",p),np=/*#__PURE__*/function(){function e(){}return e.textContext=function(){var t=e._textContext;if(!t){try{n=new OffscreenCanvas(0,0)}catch(e){n=document.createElement("canvas")}var n,r=n.getContext("2d",{willReadFrequently:!0});t={canvas:n,context:r},e._textContext=t}return t},e.measureFont=function(t){var n=e._fontSizeInfoCache,r=n[t];return r||(r=e._measureFontOrChar(t,e._measureString,!1),n[t]=r),r},e.getNativeFontString=function(t,n,r){var a=r&n_.Bold?"bold ":"";return r&n_.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=n+"px "+t},e.measureChar=function(t,n){return e._measureFontOrChar(n,t,!0)},e.measureTextWithWrap=function(t){var n=t._getSubFont(),r=n.nativeFontString,a=e.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=iZ._pixelsPerUnit,u=a.size+t.lineSpacing*c,d=t.width*c,h=0;n.nativeFontString=r;for(var _=0,f=i.length;_<f;_++){var p=i[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",b=0,S=0,C=0,T=!1,A=0,E=p.length;A<E;++A){var R=p[A],M=e._getCharInfo(R,r,n),w=R.charCodeAt(0),P=32===w;if(!P||!T||0!==x.length||0!==m.length){var F=P||w>=19968&&w<=40959,L=M.w,D=M.offsetY,B=.5*M.h,I=B+D,O=B-D;F?(m.length>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),T=!0,x=m,b=g,S=v,C=y):(x+=m,b+=g,S=Math.max(S,v),C=Math.max(C,y)),m="",g=v=y=0),b+L>d&&b>0?(this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),T=!0,P?(x="",b=S=C=0):(x=R,b=M.xAdvance,S=I,C=O)):(x+=R,b+=M.xAdvance,S=Math.max(S,I),C=Math.max(C,O))):g+M.w>d?(b>0&&(this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),x="",b=S=C=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),T=!0,m=R,g=M.xAdvance,v=I,y=O):(m+=R,g+=M.xAdvance,v=Math.max(v,I),y=Math.max(y,O))}}g>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),b=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,b+=g,S=Math.max(S,v),C=Math.max(C,y))),b>0&&(this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b))}var V=t.height*c;return t.overflowMode===nf.Overflow&&(V=u*o.length),{width:h,height:V,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},e.measureTextWithoutWrap=function(t){var n=t._getSubFont(),r=n.nativeFontString,a=e.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],u=iZ._pixelsPerUnit,d=a.size+t.lineSpacing*u,h=0;n.nativeFontString=r;for(var _=0;_<o;++_){for(var f=i[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=e._getCharInfo(f[v],r,n);p+=x.xAdvance;var b=x.offsetY,S=.5*x.h,C=S+b,T=S-b;m<C&&(m=C),g<T&&(g=T)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var A=t.height*u;return t.overflowMode===nf.Overflow&&(A=d*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},e.getNativeFontHash=function(t,n,r){var a=r&n_.Bold?"bold":"";return r&n_.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t=""+t),a+=n+"px"+t},e._measureFontOrChar=function(t,n,r){var a,i=e.textContext(),o=i.canvas,s=i.context;s.font=t;var l=s.measureText(n),c=l.actualBoundingBoxLeft,u=l.actualBoundingBoxRight,d=l.width,h=Math.max(1,Math.round(Math.max(u+Math.abs(c),d))),_=Math.ceil(s.measureText(e._measureBaseline).width),f=_*e._heightMultiplier;_=e._baselineMultiplier*_|0;var p=e._extendHeight;f+=p,_+=.5*p,o.width=h,o.height=f,s.font=t,s.fillStyle="#000",s.clearRect(0,0,h,f),s.textBaseline="middle",s.fillStyle="#fff",c>0?s.fillText(n,c,_):s.fillText(n,0,_);for(var m=s.getImageData(0,0,h,f).data,g=m.length,v=-1,y=-1,x=0,b=0,S=0,C=o.width,T=1/C,A=0;A<g;A+=4)0!==m[A+3]?(a=~~(.25*A*T),-1===v&&(v=a),a>y&&(y=a)):m[A]=m[A+1]=m[A+2]=255;if(-1!==v&&-1!==y&&(S=(x=_-v)+(b=y-_+1)),!r)return{ascent:x,descent:b,size:S};var E=null;if(S>0){var R=4*C;E=new Uint8Array(m.buffer,v*R,S*R)}return{char:n,x:0,y:0,w:h,h:S,offsetX:c>0?c:0,offsetY:(x-b)*.5,xAdvance:Math.round(d),uvs:[new tB,new tB,new tB,new tB],ascent:x,descent:b,index:0,data:E}},e._getCharInfo=function(t,n,r){var a=r._getCharInfo(t);return a||(a=e.measureChar(t,n),r._uploadCharTexture(a),r._addCharInfo(t,a)),a},e._pushLine=function(e,t,n,r,a,i,o){e.push(r),t.push(a),n.push({ascent:i,descent:o,size:i+o})},e}();np._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],np._extendHeight=0,np._measureString="|\xc9q\xc5",np._measureBaseline="M",np._heightMultiplier=2,np._baselineMultiplier=1.4,np._fontSizeInfoCache={},np._textContext=null;var nm=/*#__PURE__*/function(){function e(e){this._fontAtlases=[],this._lastIndex=-1,this._engine=e}var t=e.prototype;return t.destroy=function(){for(var e=this._fontAtlases,t=0,n=e.length;t<n;++t)e[t].destroy(!0);e.length=0},t._uploadCharTexture=function(e){var t=this._fontAtlases,n=this._lastIndex;-1===n&&(this._createFontAtlas(),n++);var r=t[n];!r.uploadCharTexture(e)&&((r=this._createFontAtlas()).uploadCharTexture(e),n++),this._lastIndex=n,e.data=null},t._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},t._getCharInfo=function(e){for(var t=this._fontAtlases,n=0,r=t.length;n<r;++n){var a=t[n].getCharInfo(e);if(a)return a}return null},t._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},t._getLastIndex=function(){return this._lastIndex},t._createFontAtlas=function(){var e=this._engine,t=new nh(e),n=new nc(e,256,256,t9.R8G8B8A8,!1);n.filterMode=t5.Bilinear,t.texture=n,t.isGCIgnored=n.isGCIgnored=!0,this._fontAtlases.push(t);var r=this.nativeFontString;return e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,t)||this}return tW(n,e),n.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var a in t){var i=t[a],o=np.measureChar(i.char,r).data;if(i.w>0&&i.h>0&&o){var s=i.bufferOffset;n.setPixelBuffer(o,0,s.x,s.y,i.w,i.h)}}n.generateMipmaps()},n}(t2))),t},e}(),ng=/*#__PURE__*/function(e){function t(t,n){var r;return void 0===n&&(n=""),(r=e.call(this,t)||this)._name="",r._subFontMap={},r._name=n,r}tW(t,e);var n=t.prototype;return n._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,a=r[n];return a||(a=new nm(this.engine),r[n]=a),a},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._subFontMap;for(var n in t)t[n].destroy();this._subFontMap=null,delete this.engine._fontMap[this._name]},t.createFromOS=function(e,n){if(n){var r=e._fontMap,a=r[n];return a||(a=new t(e,n),r[n]=a),a}return null},tG(t,[{key:"name",get:function(){return this._name}}]),t}(t1),nv=((m={})[m.None=0]="None",m[m.VisibleInsideMask=1]="VisibleInsideMask",m[m.VisibleOutsideMask=2]="VisibleOutsideMask",m),ny=((g={})[g.Left=0]="Left",g[g.Center=1]="Center",g[g.Right=2]="Right",g),nx=((v={})[v.Top=0]="Top",v[v.Center=1]="Center",v[v.Bottom=2]="Bottom",v),nb=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._sprites=[],n._spriteNamesToIndex={},n}tW(t,e);var n=t.prototype;return n.getSprite=function(e){var t=this._sprites[this._spriteNamesToIndex[e]];return t||console.warn("There is no sprite named "+e+" in the atlas."),t},n.getSprites=function(e,t){t.length=0;var n=this._spriteNamesToIndex[e];if(void 0!==n)for(var r=this._sprites;n>=0;n--){var a=r[n];a.name===e&&t.push(a)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},n._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},n._onDestroy=function(){e.prototype._onDestroy.call(this);for(var t=this._sprites,n=0,r=t.length;n<r;n++)t[n].destroy();t.length=0,this._sprites=null,this._spriteNamesToIndex=null},tG(t,[{key:"sprites",get:function(){return this._sprites}}]),t}(t1),nS=((y={})[y.Simple=0]="Simple",y[y.Sliced=1]="Sliced",y[y.Tiled=2]="Tiled",y),nC=((x={})[x.Continuous=0]="Continuous",x[x.Adaptive=1]="Adaptive",x),nT=/*#__PURE__*/function(){function e(){}return e.removeFromArray=function(e,t){var n=e.indexOf(t);if(n<0)return!1;var r=e.length-1;if(n!==r){var a=e[r];e[n]=a}return e.length--,!0},e.decodeText=function(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);for(var t="",n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);return decodeURIComponent(encodeURIComponent(t))},e.isAbsoluteUrl=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},e.isBase64Url=function(e){return/^data:.*,.*$/i.test(e)},e.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},e.resolveAbsoluteUrl=function(t,n){if(e.isAbsoluteUrl(n)||e.isBase64Url(n))return n;if(!/^https?:/.test(t)){var r="files://";return new URL(n,t=r+t).href.substring(r.length)}return n?new URL(n,t).href:t},e._floatMatrixMultiply=function(e,t,n,r,a){var i=e.elements,o=i[0],s=i[1],l=i[2],c=i[3],u=i[4],d=i[5],h=i[6],_=i[7],f=i[8],p=i[9],m=i[10],g=i[11],v=i[12],y=i[13],x=i[14],b=i[15],S=t[n],C=t[n+1],T=t[n+2],A=t[n+3],E=t[n+4],R=t[n+5],M=t[n+6],w=t[n+7],P=t[n+8],F=t[n+9],L=t[n+10],D=t[n+11],B=t[n+12],I=t[n+13],O=t[n+14],V=t[n+15];r[a]=o*S+u*C+f*T+v*A,r[a+1]=s*S+d*C+p*T+y*A,r[a+2]=l*S+h*C+m*T+x*A,r[a+3]=c*S+_*C+g*T+b*A,r[a+4]=o*E+u*R+f*M+v*w,r[a+5]=s*E+d*R+p*M+y*w,r[a+6]=l*E+h*R+m*M+x*w,r[a+7]=c*E+_*R+g*M+b*w,r[a+8]=o*P+u*F+f*L+v*D,r[a+9]=s*P+d*F+p*L+y*D,r[a+10]=l*P+h*F+m*L+x*D,r[a+11]=c*P+_*F+g*L+b*D,r[a+12]=o*B+u*I+f*O+v*V,r[a+13]=s*B+d*I+p*O+y*V,r[a+14]=l*B+h*I+m*O+x*V,r[a+15]=c*B+_*I+g*O+b*V},e._reflectGet=function(e,t){for(var n=this._stringToPath(t),r=e,a=0,i=n.length;null!=r&&a<i;)r=r[n[a++]];return a&&a==i?r:void 0},e._quickSort=function(e,t,n,r){for(;;){if(n-t<=10){this._insertionSort(e,t,n,r);return}var a=t+n>>1,i=e[t],o=e[n-1],s=e[a];if(r(i,o)>0){var l=i;i=o,o=l}if(r(i,s)>=0){var c=i;i=s,s=o,o=c}else if(r(o,s)>0){var u=o;o=s,s=u}e[t]=i,e[n-1]=s;var d=o,h=t+1,_=n-1;e[a]=e[h],e[h]=d;e:for(var f=h+1;f<_;f++){var p=e[f],m=r(p,d);if(m<0)e[f]=e[h],e[h]=p,h++;else if(m>0){do{if(--_==f)break e;m=r(e[_],d)}while(m>0);e[f]=e[_],e[_]=p,m<0&&(p=e[f],e[f]=e[h],e[h]=p,h++)}}n-_<h-t?(this._quickSort(e,_,n,r),n=h):(this._quickSort(e,t,h,r),t=_)}},e._stringToPath=function(e){var t=[];return e.charCodeAt(0)===nA&&t.push(""),e.replace(nR,function(e,n,r,a){var i=e;r?i=a.replace(nE,"$1"):n&&(i=n.trim()),t.push(i)}),t},e._insertionSort=function(e,t,n,r){for(var a=t+1;a<n;a++){var i=void 0,o=e[a];for(i=a-1;i>=t;i--){var s=e[i];if(r(s,o)>0)e[i+1]=s;else break}e[i+1]=o}},e}(),nA=46,nE=/\\(\\)?/g,nR=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),nM=/*#__PURE__*/function(){function e(){this._updateFlags=[],this._listeners=[]}var t=e.prototype;return t.createFlag=function(e){var t=new e;return this.addFlag(t),t},t.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},t.removeFlag=function(e){nT.removeFromArray(this._updateFlags,e)&&nT.removeFromArray(e._flagManagers,this)},t.addListener=function(e){this._listeners.push(e)},t.removeListener=function(e){nT.removeFromArray(this._listeners,e)},t.dispatch=function(e,t){for(var n=this._updateFlags,r=n.length-1;r>=0;r--)n[r].dispatch(e,t);for(var a=this._listeners,i=a.length-1;i>=0;i--)a[i](e,t)},e}(),nw=((b={})[b.texture=1]="texture",b[b.size=2]="size",b[b.atlasRotate=4]="atlasRotate",b[b.atlasRegion=8]="atlasRegion",b[b.atlasRegionOffset=16]="atlasRegionOffset",b[b.region=32]="region",b[b.pivot=64]="pivot",b[b.border=128]="border",b[b.destroy=256]="destroy",b),nP=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===n&&(n=null),void 0===r&&(r=null),void 0===a&&(a=null),void 0===i&&(i=null),void 0===o&&(o=null),(s=e.call(this,t)||this)._automaticWidth=0,s._automaticHeight=0,s._customWidth=void 0,s._customHeight=void 0,s._positions=[new tB,new tB,new tB,new tB],s._uvs=[new tB,new tB,new tB,new tB],s._bounds=new tE,s._texture=null,s._atlasRotated=!1,s._atlasRegion=new tV(0,0,1,1),s._atlasRegionOffset=new tI(0,0,0,0),s._region=new tV(0,0,1,1),s._pivot=new tB(.5,.5),s._border=new tI(0,0,0,0),s._dirtyUpdateFlag=7,s._updateFlagManager=new nM,s._texture=n,s._onRegionChange=s._onRegionChange.bind(s),s._onPivotChange=s._onPivotChange.bind(s),s._onBorderChange=s._onBorderChange.bind(s),s._region._onValueChanged=s._onRegionChange,s._pivot._onValueChanged=s._onPivotChange,s._border._onValueChanged=s._onBorderChange,r&&s._region.copyFrom(r),a&&s._pivot.copyFrom(a),i&&s._border.copyFrom(i),s.name=o,s}tW(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},n._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},n._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},n._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},n._addReferCount=function(t){var n;e.prototype._addReferCount.call(this,t),null==(n=this._atlas)||n._addReferCount(t)},n._onDestroy=function(){this._dispatchSpriteChange(nw.destroy),e.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},n._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,a=1/iZ._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-n.x-n.z)*r.width*a,this._automaticHeight=e.height*t.height/(1-n.y-n.w)*r.height*a}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},n._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,n=t.x,r=t.y,a=t.width,i=t.height,o=Math.max(e.x-n,0)/a,s=Math.max(e.w-r,0)/i,l=1-Math.max(e.z-(1-n-a),0)/a,c=1-Math.max(e.y-(1-r-i),0)/i,u=this._positions;u[0].set(o,s),u[1].set(l,s),u[2].set(o,c),u[3].set(l,c);var d=this._bounds,h=d.min,_=d.max;h.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},n._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,n=this._region,r=n.x,a=n.y,i=n.width,o=n.height,s=1-r-i,l=1-a-o,c=this._atlasRegion,u=c.x,d=c.y,h=c.width,_=c.height,f=t.x,p=t.y,m=t.z,g=t.w,v=h/(1-f-m),y=_/(1-p-g),x=Math.max(r-f,0)*v+u,b=Math.max(l-p,0)*y+d,S=h+u-Math.max(s-m,0)*v,C=_+d-Math.max(a-g,0)*y,T=this._border,A=T.x,E=T.y,R=T.z,M=T.w;e[0].set(x,C),e[1].set((r-f+A*i)*v+u,_+d-(a-g+E*o)*y),e[2].set(h+u-(s-m+R*i)*v,(l-p+M*o)*y+d),e[3].set(S,b),this._dirtyUpdateFlag&=-3},n._dispatchSpriteChange=function(e){switch(e){case nw.texture:this._dirtyUpdateFlag|=4;break;case nw.atlasRegionOffset:case nw.region:this._dirtyUpdateFlag|=7;break;case nw.atlasRegion:this._dirtyUpdateFlag|=6;break;case nw.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},n._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=tC.clamp(e.x,0,1),n=tC.clamp(e.y,0,1);e.set(t,n,tC.clamp(e.width,0,1-t),tC.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nw.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size),e._onValueChanged=this._onRegionChange},n._onPivotChange=function(){this._dispatchSpriteChange(nw.pivot)},n._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=tC.clamp(e.x,0,1),n=tC.clamp(e.y,0,1);e.set(t,n,tC.clamp(e.z,0,1-t),tC.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nw.border),e._onValueChanged=this._onBorderChange},tG(t,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(nw.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size))}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dispatchSpriteChange(nw.size))}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dispatchSpriteChange(nw.size))}},{key:"atlasRotated",get:function(){return this._atlasRotated},set:function(e){this._atlasRotated!=e&&(this._atlasRotated=e)}},{key:"atlasRegion",get:function(){return this._atlasRegion},set:function(e){var t=tC.clamp(e.x,0,1),n=tC.clamp(e.y,0,1);this._atlasRegion.set(t,n,tC.clamp(e.width,0,1-t),tC.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nw.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=tC.clamp(e.x,0,1),n=tC.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,tC.clamp(e.z,0,1-t),tC.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nw.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),t}(t1),nF=((S={})[S.Zero=0]="Zero",S[S.One=1]="One",S[S.SourceColor=2]="SourceColor",S[S.OneMinusSourceColor=3]="OneMinusSourceColor",S[S.DestinationColor=4]="DestinationColor",S[S.OneMinusDestinationColor=5]="OneMinusDestinationColor",S[S.SourceAlpha=6]="SourceAlpha",S[S.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",S[S.DestinationAlpha=8]="DestinationAlpha",S[S.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",S[S.SourceAlphaSaturate=10]="SourceAlphaSaturate",S[S.BlendColor=11]="BlendColor",S[S.OneMinusBlendColor=12]="OneMinusBlendColor",S),nL=((C={})[C.Add=0]="Add",C[C.Subtract=1]="Subtract",C[C.ReverseSubtract=2]="ReverseSubtract",C[C.Min=3]="Min",C[C.Max=4]="Max",C),nD=((T={})[T.None=0]="None",T[T.Red=1]="Red",T[T.Green=2]="Green",T[T.Blue=4]="Blue",T[T.Alpha=8]="Alpha",T[T.All=15]="All",T),nB=((A={})[A.Never=0]="Never",A[A.Less=1]="Less",A[A.Equal=2]="Equal",A[A.LessEqual=3]="LessEqual",A[A.Greater=4]="Greater",A[A.NotEqual=5]="NotEqual",A[A.GreaterEqual=6]="GreaterEqual",A[A.Always=7]="Always",A),nI=((E={})[E.Off=0]="Off",E[E.Front=1]="Front",E[E.Back=2]="Back",E),nO=((R={})[R.BlendStateEnabled0=0]="BlendStateEnabled0",R[R.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",R[R.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",R[R.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",R[R.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",R[R.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",R[R.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",R[R.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",R[R.BlendStateBlendColor=8]="BlendStateBlendColor",R[R.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",R[R.DepthStateEnabled=10]="DepthStateEnabled",R[R.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",R[R.DepthStateCompareFunction=12]="DepthStateCompareFunction",R[R.StencilStateEnabled=13]="StencilStateEnabled",R[R.StencilStateReferenceValue=14]="StencilStateReferenceValue",R[R.StencilStateMask=15]="StencilStateMask",R[R.StencilStateWriteMask=16]="StencilStateWriteMask",R[R.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",R[R.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",R[R.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",R[R.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",R[R.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",R[R.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",R[R.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",R[R.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",R[R.RasterStateCullMode=25]="RasterStateCullMode",R[R.RasterStateDepthBias=26]="RasterStateDepthBias",R[R.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",R[R.RenderQueueType=28]="RenderQueueType",R),nV=((M={})[M.Opaque=0]="Opaque",M[M.AlphaTest=1]="AlphaTest",M[M.Transparent=2]="Transparent",M),nN=((w={})[w.Float=0]="Float",w[w.Int=1]="Int",w[w.Vector2=2]="Vector2",w[w.Vector3=3]="Vector3",w[w.Vector4=4]="Vector4",w[w.Matrix=5]="Matrix",w[w.Color=6]="Color",w[w.Texture=7]="Texture",w[w.FloatArray=8]="FloatArray",w[w.IntArray=9]="IntArray",w[w.TextureArray=10]="TextureArray",w),nk=((P={})[P.Keep=0]="Keep",P[P.Zero=1]="Zero",P[P.Replace=2]="Replace",P[P.IncrementSaturate=3]="IncrementSaturate",P[P.DecrementSaturate=4]="DecrementSaturate",P[P.Invert=5]="Invert",P[P.IncrementWrap=6]="IncrementWrap",P[P.DecrementWrap=7]="DecrementWrap",P),nz=((F={})[F.GLES100=0]="GLES100",F[F.GLES300=1]="GLES300",F);function nU(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function nG(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return nU(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nU(e,void 0)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nH=/*#__PURE__*/function(){function e(t,n,r,a){this.name=t,this._maskIndex=r,this._maskValue=a,this.value=n;var i=e._macroNameIdMap,o=i[t];void 0===i[t]&&(i[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,n){var r=n?t+" "+n:t,a=e._macroMap[r];if(!a){var i=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;a=new e(t,n,s,1<<l),e._macroMap[r]=a,s==i.length&&(i.length++,i[s]=Array(32)),i[s][l]=a,e._macroCounter++}return a},e._getMacrosElements=function(t,n){var r=e._macroMaskMap,a=t._mask;n.length=0;for(var i=0,o=t._length;i<o;i++)for(var s=r[i],l=a[i],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&n.push(s[u])},e}();nH._macroMaskMap=[],nH._macroNameIdMap=Object.create(null),nH._macroNameCounter=0,nH._macroCounter=0,nH._macroMap=Object.create(null);var nW=/*#__PURE__*/function(){function e(){this._mask=[],this._length=0}var t=e.prototype;return t.enable=function(e){var t=e._maskIndex,n=t+1,r=this._mask,a=this._length;if(a<n){for(r.length<n&&(r.length=n);a<t;a++)r[a]=0;r[t]=e._maskValue,this._length=n}else r[t]|=e._maskValue},t.disable=function(e){var t=e._maskIndex,n=this._mask,r=this._length-1;if(!(t>r)){var a=n[t]&~e._maskValue;t==r&&0===a?this._length--:n[t]=a}},t.unionCollection=function(e){var t=e._mask,n=e._length,r=this._mask,a=this._length;if(a<n){r.length<n&&(r.length=n);for(var i=0;i<a;i++)r[i]|=t[i];for(;i<n;i++)r[i]=t[i];this._length=n}else for(var o=0;o<n;o++)r[o]|=t[o]},t.complementaryCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1,a=Math.min(e._length-1,r);a>=0;a--){var i=n[a]&~t[a];a==r&&0===i?(r--,this._length--):n[a]=i}},t.intersectionCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1;r>=0;r--){var a=n[r]&t[r];0==a&&r==this._length-1?this._length--:n[r]=a}},t.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},t.clear=function(){this._length=0},e.unionCollection=function(e,t,n){var r,a,i,o,s=n._mask;e._length<t._length?(r=e._length,a=t._length,i=e._mask,o=t._mask):(r=t._length,a=e._length,i=t._mask,o=e._mask);var l=0;for(s.length<a&&(s.length=a);l<r;l++)s[l]=i[l]|o[l];for(;l<a;l++)s[l]=o[l];n._length=a},e}();function nj(){return(nj=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var nX=((L={}).DepthOnly="DepthOnly",L.ShadowCaster="ShadowCaster",L.Forward="Forward",L),nK=/*#__PURE__*/function(){function e(){this._events=Object.create(null),this._eventCount=0}var t=e.prototype;return t.hasEvent=function(e){return null!=this._events[e]},t.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},t.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},t.dispatch=function(t,n){if(!this._events[t])return!1;var r=this._events[t];if(Array.isArray(r)){var a=r.length,i=e._dispatchingListenersPool,o=i.length>0?i.pop():[];o.length=a;for(var s=0;s<a;s++)o[s]=r[s];for(var l=0;l<a;l++){var c=o[l];c.destroyed||(c.once&&this.off(t,c.fn),c.fn(n))}o.length=0,i.push(o)}else r.once&&this.off(t,r.fn),r.fn(n);return!0},t.on=function(e,t){return this._addEventListener(e,t)},t.once=function(e,t){return this._addEventListener(e,t,!0)},t.off=function(e,t){if(!this._events[e])return this;if(!t)return this._clearEvent(e),this;var n=this._events[e],r=Array.isArray(n);if(r||n.fn!==t){if(r){for(var a=n.length-1;a>=0;a--)n[a].fn===t&&(n[a].destroyed=!0,n.splice(a,1));0===n.length?this._clearEvent(e):1===n.length&&(this._events[e]=n[0])}}else this._clearEvent(e);return this},t.removeEventListener=function(e,t){return this.off(e,t)},t.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},t._addEventListener=function(e,t,n){var r={fn:t,once:n},a=this._events,i=a[e];return i?Array.isArray(i)?i.push(r):a[e]=[i,r]:(a[e]=r,this._eventCount++),this},t._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},e}();nK._dispatchingListenersPool=[];var nY=/*#__PURE__*/function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return e.getByName=function(t){var n=e._propertyNameMap;if(null!=n[t])return n[t];var r=new e(t);return n[t]=r,e._propertyIdMap[r._uniqueId]=r,r},e._getShaderPropertyGroup=function(t){var n=e._propertyNameMap[t];return null==n?void 0:n._group},tG(e,[{key:"type",get:function(){return this._type}}]),e}();nY._propertyIdMap=Object.create(null),nY._propertyNameCounter=0,nY._propertyNameMap=Object.create(null);var nq=/*#__PURE__*/function(){function e(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new tI,this._deltaTimeValue=new tI,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}var t=e.prototype;return t._reset=function(){this._lastSystemTime=performance.now()/1e3},t._update=function(){var e=performance.now()/1e3,t=e-this._lastSystemTime;this._actualDeltaTime=t,this._actualElapsedTime+=t;var n=Math.min(t,this.maximumDeltaTime)*this.timeScale;this._deltaTime=n,this._elapsedTime+=n,this._frameCount++,this._lastSystemTime=e},t._updateSceneShaderData=function(t){var n=this._elapsedTimeValue,r=this._deltaTimeValue,a=this._elapsedTime;n.set(a,Math.sin(a),Math.cos(a),0),t.setVector4(e._elapsedTimeProperty,n),r.set(this._deltaTime,0,0,0),t.setVector4(e._deltaTimeProperty,r)},tG(e,[{key:"frameCount",get:function(){return this._frameCount}},{key:"deltaTime",get:function(){return this._deltaTime}},{key:"elapsedTime",get:function(){return this._elapsedTime}},{key:"actualDeltaTime",get:function(){return this._actualDeltaTime}},{key:"actualElapsedTime",get:function(){return this._actualElapsedTime}}]),e}();nq._elapsedTimeProperty=nY.getByName("scene_ElapsedTime"),nq._deltaTimeProperty=nY.getByName("scene_DeltaTime");var nQ=((D={})[D.FLOAT=5126]="FLOAT",D[D.FLOAT_VEC2=35664]="FLOAT_VEC2",D[D.FLOAT_VEC3=35665]="FLOAT_VEC3",D[D.FLOAT_VEC4=35666]="FLOAT_VEC4",D[D.INT=5124]="INT",D[D.INT_VEC2=35667]="INT_VEC2",D[D.INT_VEC3=35668]="INT_VEC3",D[D.INT_VEC4=35669]="INT_VEC4",D[D.BOOL=35670]="BOOL",D[D.BOOL_VEC2=35671]="BOOL_VEC2",D[D.BOOL_VEC3=35672]="BOOL_VEC3",D[D.BOOL_VEC4=35673]="BOOL_VEC4",D[D.FLOAT_MAT2=35674]="FLOAT_MAT2",D[D.FLOAT_MAT3=35675]="FLOAT_MAT3",D[D.FLOAT_MAT4=35676]="FLOAT_MAT4",D[D.FLOAT_ARRAY=35677]="FLOAT_ARRAY",D[D.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",D[D.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",D[D.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",D[D.INT_ARRAY=100003]="INT_ARRAY",D[D.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",D[D.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",D[D.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",D[D.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",D[D.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",D[D.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",D[D.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",D[D.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",D[D.SAMPLER_2D=35678]="SAMPLER_2D",D[D.SAMPLER_CUBE=35680]="SAMPLER_CUBE",D[D.BYTE=5120]="BYTE",D[D.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",D[D.SHORT=5122]="SHORT",D[D.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",D[D.UNSIGNED_INT=5125]="UNSIGNED_INT",D),nZ=((B={}).shaderVertexID="shaderVertexID",B.standardDerivatives="OES_standard_derivatives",B.shaderTextureLod="EXT_shader_texture_lod",B.elementIndexUint="OES_element_index_uint",B.depthTexture="WEBGL_depth_texture",B.drawBuffers="WEBGL_draw_buffers",B.vertexArrayObject="OES_vertex_array_object",B.instancedArrays="ANGLE_instanced_arrays",B.multipleSample="multipleSampleOnlySupportedInWebGL2",B.textureFloat="OES_texture_float",B.textureFloatLinear="OES_texture_float_linear",B.textureHalfFloat="OES_texture_half_float",B.textureHalfFloatLinear="OES_texture_half_float_linear",B.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",B.colorBufferFloat="EXT_color_buffer_float",B.colorBufferHalfFloat="EXT_color_buffer_half_float",B.textureFilterAnisotropic="EXT_texture_filter_anisotropic",B.blendMinMax="EXT_blend_minmax",B.fragDepth="EXT_frag_depth",B.astc="WEBGL_compressed_texture_astc",B.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",B.etc="WEBGL_compressed_texture_etc",B.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",B.etc1="WEBGL_compressed_texture_etc1",B.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",B.pvrtc="WEBGL_compressed_texture_pvrtc",B.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",B.s3tc="WEBGL_compressed_texture_s3tc",B.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",B.bptc="EXT_texture_compression_bptc",B.WEBGL_lose_context="WEBGL_lose_context",B),nJ=nj({common:"#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){linearIn=max(linearIn,0.0);return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(v_normal,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,v_normal);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.0;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.roughness+getAARoughnessFactor(geometry.normal),1.0));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.clearCoatRoughness+getAARoughnessFactor(geometry.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"},{particle_common:"#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}",velocity_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}",rotation_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nuniform vec2 renderer_ROLMaxCurveZ[4];\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec2 renderer_ROLMinCurveZ[4];\n#endif\n#else\nuniform vec3 renderer_ROLMaxConst;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec3 renderer_ROLMinConst;\n#endif\n#endif\n#endif\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge){\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nfloat lifeRotation=evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ,normalizedAge);\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ,normalizedAge),lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*a_ShapePositionStartLifeTime.w;\n#else\nfloat lifeRotation=renderer_ROLMaxConst.z;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(renderer_ROLMinConst.z,lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*age;\n#endif\n#endif\nreturn rotation;}\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge){\n#ifdef ROTATION_OVER_LIFETIME\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nfloat ageRot=u_ROLAngularVelocityConst*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n#endif\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nvec3 ageRot=u_ROLAngularVelocityConstSeparate*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nvec3 ageRot=mix(u_ROLAngularVelocityConstSeparate,renderer_ROLMaxConst,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,normalizedAge),a_Random0.w));\n#endif\n#endif\nreturn rotation;}\n#endif\n",size_over_lifetime_module:"#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\nuniform vec2 renderer_SOLMaxCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMaxCurveY[4];uniform vec2 renderer_SOLMaxCurveZ[4];\n#endif\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nuniform vec2 renderer_SOLMinCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMinCurveY[4];uniform vec2 renderer_SOLMinCurveZ[4];\n#endif\n#endif\n#endif\nvec2 computeParticleSizeBillboard(in vec2 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE_MODE\nfloat lifeSizeX=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeX=mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),lifeSizeX,a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_IS_SEPARATE\nfloat lifeSizeY=evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeY=mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),lifeSizeY,a_Random0.z);\n#endif\nsize*=vec2(lifeSizeX,lifeSizeY);\n#else\nsize*=lifeSizeX;\n#endif\n#endif\nreturn size;}\n#ifdef RENDERER_MODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE\nsize*=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES\nsize*=mix(evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),evaluateParticleCurve(u_SOLSizeGradientMax,normalizedAge),a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_CURVE_SEPARATE\nsize*=vec3(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge));\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\nsize*=vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveZ,normalizedAge),a_Random0.z));\n#endif\nreturn size;}\n#endif\n",color_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nuniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4];\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\nuniform vec4 renderer_COLMinGradientColor[4];uniform vec2 renderer_COLMinGradientAlpha[4];\n#endif\nuniform vec4 renderer_COLGradientKeysMaxTime;\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 evaluateParticleGradient(in vec4 colorKeys[4],in float colorKeysMaxTime,in vec2 alphaKeys[4],in float alphaKeysMaxTime,in float normalizedAge){vec4 value;float alphaAge=min(normalizedAge,alphaKeysMaxTime);for(int i=0;i<4;i++){vec2 key=alphaKeys[i];float time=key.x;if(alphaAge<=time){if(i==0){value.a=alphaKeys[0].y;}else{vec2 lastKey=alphaKeys[i-1];float lastTime=lastKey.x;float age=(alphaAge-lastTime)/(time-lastTime);value.a=mix(lastKey.y,key.y,age);}break;}}float colorAge=min(normalizedAge,colorKeysMaxTime);for(int i=0;i<4;i++){vec4 key=colorKeys[i];float time=key.x;if(colorAge<=time){if(i==0){value.rgb=colorKeys[0].yzw;}else{vec4 lastKey=colorKeys[i-1];float lastTime=lastKey.x;float age=(colorAge-lastTime)/(time-lastTime);value.rgb=mix(lastKey.yzw,key.yzw,age);}break;}}return value;}\n#endif\nvec4 computeParticleColor(in vec4 color,in float normalizedAge){\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 gradientColor=evaluateParticleGradient(renderer_COLMaxGradientColor,renderer_COLGradientKeysMaxTime.z,renderer_COLMaxGradientAlpha,renderer_COLGradientKeysMaxTime.w,normalizedAge);\n#endif\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\ngradientColor=mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x,renderer_COLMinGradientAlpha,renderer_COLGradientKeysMaxTime.y,normalizedAge),gradientColor,a_Random0.y);\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\ncolor*=gradientColor;\n#endif\nreturn color;}",texture_sheet_animation_module:"#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nuniform float renderer_TSACycles;uniform vec3 renderer_TSATillingParams;uniform vec2 renderer_TSAFrameMaxCurve[4];\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\n#endif\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge){\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nfloat scaledNormalizedAge=normalizedAge*renderer_TSACycles;float cycleNormalizedAge=scaledNormalizedAge-floor(scaledNormalizedAge);float normalizedFrame=evaluateParticleCurve(renderer_TSAFrameMaxCurve,cycleNormalizedAge);\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nnormalizedFrame=mix(evaluateParticleCurve(renderer_TSAFrameMinCurve,cycleNormalizedAge),normalizedFrame,a_Random1.x);\n#endif\nfloat frame=floor(normalizedFrame*renderer_TSATillingParams.z);float tileRow=frame*renderer_TSATillingParams.x;float tileRowIndex=floor(tileRow);uv.x+=tileRow-tileRowIndex;uv.y+=tileRowIndex*renderer_TSATillingParams.y;\n#endif\nreturn uv;}",sphere_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 sideVector=normalize(cross(camera_Forward,camera_Up));vec3 upVector=normalize(cross(sideVector,camera_Forward));corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);}else{float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#else\nif(renderer_ThreeDStartRotation){center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);}else{float c=cos(a_StartRotation0.x);float s=sin(a_StartRotation0.x);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#endif\n#endif\n",stretched_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nif(renderer_VOLSpace==0){velocity=rotationByQuaternions(renderer_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;}else{velocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;}\n#else\nvelocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n#endif\nvec3 cameraUpVector=normalize(velocity);vec3 direction=normalize(center-camera_Position);vec3 sideVector=normalize(cross(direction,normalize(velocity)));sideVector=renderer_SizeScale.xzy*sideVector;cameraUpVector=length(vec3(renderer_SizeScale.x,0.0,0.0))*cameraUpVector;vec2 size=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);const mat2 rotationZHalfPI=mat2(0.0,-1.0,1.0,0.0);corner=rotationZHalfPI*corner;corner.y=corner.y-abs(corner.y);float speed=length(velocity);center+=sign(renderer_SizeScale.x)*(sign(renderer_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*renderer_StretchedBillboardSpeedScale+size.y*renderer_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n#endif\n",vertical_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,1.0,0.0);vec3 sideVector=normalize(cross(camera_Forward,cameraUpVector));float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",horizontal_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,0.0,1.0);const vec3 sideVector=vec3(-1.0,0.0,0.0);float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",particle_mesh:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_MESH\nvec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);}else{\n#ifdef RENDERER_ROL_IS_SEPARATE\nfloat angle=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){center+=(rotationByQuaternions(rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));}else{\n#ifdef SHAPE\ncenter+=renderer_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);\n#endif\n}\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\nvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x),age,normalizedAge);center+=(rotationByQuaternions(rotationByEuler(renderer_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));\n#endif\n}\n#else\nif(renderer_ThreeDStartRotation){center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);}else{if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){if(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=(rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));}else{\n#ifdef SHAPE\nif(renderer_SimulationSpace==1)center+=renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);\n#endif\n}}\n#endif\nv_MeshColor=a_MeshColor;\n#endif\n"}),n$=/*#__PURE__*/function(){function e(){}return e.parseCustomMacros=function(e){return e.map(function(e){return"#define "+(e.value?e.name+" "+e.value:e.name)+"\n"}).join("")},e.registerInclude=function(e,t){if(nJ[e])throw'The "'+e+'" shader include already exist';nJ[e]=t},e.unRegisterInclude=function(e){delete nJ[e]},e.parseIncludes=function(t,n){return void 0===n&&(n=/^[ \t]*#include +<([\w\d.]+)>/gm),t.replace(n,function(t,r){var a=nJ[r];return void 0===a?(no.error('Shader slice "'+t.trim()+'" not founded.'),""):e.parseIncludes(a,n)})},e.convertTo300=function(t,n){if(t=(t=(t=t.replace(/\bvarying\b/g,n?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj"),n){if(t=(t=(t=(t=(t=t.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\btexture2DProjLodEXT\b/g,"textureProjLod")).replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!e._has300Output(t)){if(/\bgl_FragData\[.+?\]/g.test(t)){var r=(t=t.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);t=this._replaceMRTShader(t,r)}else t=(t=t.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}}else t=t.replace(/\battribute\b/g,"in");return t},e._has300Output=function(t){return e._has300OutInFragReg.test(t)},e._replaceMRTShader=function(e,t){for(var n="",r=new Set,a=0;a<t.length;a++){var i=t[a].match(/\bgl_FragData\[(.+?)\]/);r.add(i[1])}return r.forEach(function(e){n+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),n+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,n)},e}();n$._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers","GL_EXT_frag_depth"].map(function(e){return"#extension "+e+" : enable\n"}).join(""),n$._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var n0=/*#__PURE__*/function(){function e(t){this.name=t,this._uniqueId=e._nameCounter++}return e.getByName=function(t){var n=e._nameMap;return n[t]||(n[t]=new e(t))},e}();n0._nameCounter=0,n0._nameMap=Object.create(null);var n1=/*#__PURE__*/function(){function e(){this._tagsMap=Object.create(null)}var t=e.prototype;return t.setTag=function(e,t){var n="string"==typeof e?n0.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&no.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},t.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?n0.getByName(e):e)._uniqueId]},t.getTagValue=function(e){return this._tagsMap["string"==typeof e?n0.getByName(e)._uniqueId:e._uniqueId]},tG(e,[{key:"name",get:function(){return this._name}}]),e}(),n2=((I={})[I.Linear=0]="Linear",I[I.Gamma=1]="Gamma",I),n3=/*#__PURE__*/function(){function e(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=e.settings.colorSpace}var t=e.prototype;return t.upload1f=function(e,t){this.cacheValue!==t&&(this._gl.uniform1f(e.location,t),this.cacheValue=t)},t.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},t.upload2f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g)&&(this._colorSpace===n2.Linear?this._gl.uniform2f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g)):this._gl.uniform2f(e.location,t.r,t.g),n.x=t.r,n.y=t.g):(n.x!==t.x||n.y!==t.y)&&(this._gl.uniform2f(e.location,t.x,t.y),n.x=t.x,n.y=t.y)},t.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},t.upload3f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b)&&(this._colorSpace===n2.Linear?this._gl.uniform3f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g),tO.gammaToLinearSpace(t.b)):this._gl.uniform3f(e.location,t.r,t.g,t.b),n.x=t.r,n.y=t.g,n.z=t.b):(n.x!==t.x||n.y!==t.y||n.z!==t.z)&&(this._gl.uniform3f(e.location,t.x,t.y,t.z),n.x=t.x,n.y=t.y,n.z=t.z)},t.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},t.upload4f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b||n.w!==t.a)&&(this._colorSpace===n2.Linear?this._gl.uniform4f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g),tO.gammaToLinearSpace(t.b),t.a):this._gl.uniform4f(e.location,t.r,t.g,t.b,t.a),n.x=t.r,n.y=t.g,n.z=t.b,n.w=t.a):(n.x!==t.x||n.y!==t.y||n.z!==t.z||n.w!==t.w)&&(this._gl.uniform4f(e.location,t.x,t.y,t.z,t.w),n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w)},t.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},t.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},t.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},t.upload2i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g)&&(this._gl.uniform2i(e.location,t.r,t.g),n.x=t.r,n.y=t.g):(n.x!==t.x||n.y!==t.y)&&(this._gl.uniform2i(e.location,t.x,t.y),n.x=t.x,n.y=t.y)},t.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},t.upload3i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b)&&(this._gl.uniform3i(e.location,t.r,t.g,t.b),n.x=t.r,n.y=t.g,n.z=t.b):(n.x!==t.x||n.y!==t.y||n.z!==t.z)&&(this._gl.uniform3i(e.location,t.x,t.y,t.z),n.x=t.x,n.y=t.y,n.z=t.z)},t.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},t.upload4i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b||n.w!==t.a)&&(this._gl.uniform4i(e.location,t.r,t.g,t.b,t.a),n.x=t.r,n.y=t.g,n.z=t.b,n.w=t.a):(n.x!==t.x||n.y!==t.y||n.z!==t.z||n.w!==t.w)&&(this._gl.uniform4i(e.location,t.x,t.y,t.z,t.w),n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w)},t.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},t.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},t.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},t.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},t.uploadTextureArray=function(e,t){for(var n=this._rhi,r=e.textureIndex,a=0;a<t.length;a++){var i=t[a];n.activeTexture(r[a]),n.bindTexture(i._platformTexture),i._setUseDepthCompareMode(e.textureUseCompareMode)}},e}(),n4=function(){this.constUniforms=[],this.textureUniforms=[]},n8=((O={})[O.Scene=0]="Scene",O[O.Camera=1]="Camera",O[O.Renderer=2]="Renderer",O[O.Material=3]="Material",O[O.RenderElement=4]="RenderElement",O),n5=/*#__PURE__*/function(){function e(t,n,r){this.sceneUniformBlock=new n4,this.cameraUniformBlock=new n4,this.rendererUniformBlock=new n4,this.materialUniformBlock=new n4,this.renderElementUniformBlock=new n4,this.otherUniformBlock=new n4,this._uploadRenderCount=-1,this._uploadSceneId=-1,this._uploadCameraId=-1,this._uploadRendererId=-1,this._uploadMaterialId=-1,this.attributeLocation=Object.create(null),this._activeTextureUint=0,this._engine=t,this._gl=t._hardwareRenderer.gl,this._glProgram=this._createProgram(n,r),this._glProgram?(this._isValid=!0,this._recordLocation()):this._isValid=!1,this.id=e._counter++}var t=e.prototype;return t.uploadAll=function(e,t){this.uploadUniforms(e,t),this.uploadTextures(e,t)},t.uploadUniforms=function(e,t){for(var n=t._propertyValueMap,r=e.constUniforms,a=0,i=r.length;a<i;a++){var o=r[a],s=n[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var n=t._propertyValueMap,r=e.textureUniforms;if(r)for(var a=0,i=r.length;a<i;a++){var o=r[a],s=n[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,n=e.length;t<n;t++){var r=e[t];r.applyFunc(r,r.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,n=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),n.length>0&&this._groupingSubOtherUniforms(n,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n],a=nY._getShaderPropertyGroup(r.name);void 0!==a&&(e.splice(e.indexOf(r),1),this._groupingUniform(r,a,t))}},t._groupingUniform=function(e,t,n){switch(t){case n8.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case n8.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case n8.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case n8.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case n8.RenderElement:n?this.renderElementUniformBlock.textureUniforms.push(e):this.renderElementUniformBlock.constUniforms.push(e);break;default:n?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var n=this._gl,r=this._createShader(n.VERTEX_SHADER,e);if(!r)return null;var a=this._createShader(n.FRAGMENT_SHADER,t);if(!a)return null;var i=n.createProgram();return i?(n.attachShader(i,r),n.attachShader(i,a),n.linkProgram(i),n.validateProgram(i),n.deleteShader(r),n.deleteShader(a),!no.isEnabled||n.getProgramParameter(i,n.LINK_STATUS)||n.isContextLost())?i:(no.error("Could not link WebGL program\n\nShader error: "+n.getError()+"\n\nValidate status: "+n.getProgramParameter(i,n.VALIDATE_STATUS)+"\n\nProgram information log: "+n.getProgramInfoLog(i)),n.deleteProgram(i),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,n){var r=this._gl,a=r.createShader(t);return a?(r.shaderSource(a,n),r.compileShader(a),!no.isEnabled||r.getShaderParameter(a,r.COMPILE_STATUS)||r.isContextLost())?a:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==r.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+r.getShaderInfoLog(a)+"\nShader source:\n"+e._addLineNum(n)),r.deleteShader(a),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,n=this._glProgram,r=this._getUniformInfos(),a=this._getAttributeInfos(),i=this._engine._basicResources;r.forEach(function(r){var a,o=r.name,s=r.size,l=r.type,c=new n3(e._engine),u=!1,d=!1;o.indexOf("[0]")>0&&(o=o.substr(0,o.length-3),u=!0);var h=t.getUniformLocation(n,o);switch(c.name=o,c.propertyId=nY.getByName(o)._uniqueId,c.location=h,l){case t.FLOAT:u?c.applyFunc=c.upload1fv:(c.applyFunc=c.upload1f,c.cacheValue=0);break;case t.FLOAT_VEC2:u?c.applyFunc=c.upload2fv:(c.applyFunc=c.upload2f,c.cacheValue=new tB(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new tT(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new tI(0,0,0,0));break;case t.BOOL:case t.INT:u?c.applyFunc=c.upload1iv:(c.applyFunc=c.upload1i,c.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:u?c.applyFunc=c.upload2iv:(c.applyFunc=c.upload2i,c.cacheValue=new tB(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new tT(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new tI(0,0,0));break;case t.FLOAT_MAT4:c.applyFunc=u?c.uploadMat4v:c.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.UNSIGNED_INT_SAMPLER_2D:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(l){case t.SAMPLER_2D:a=i.whiteTexture2D;break;case t.SAMPLER_CUBE:a=i.whiteTextureCube;break;case t.UNSIGNED_INT_SAMPLER_2D:a=i.uintWhiteTexture2D;break;case t.SAMPLER_2D_ARRAY:a=i.whiteTexture2DArray;break;case t.SAMPLER_2D_SHADOW:a=e._engine._depthTexture2D,c.textureUseCompareMode=!0}if(d=!0,u){for(var _=Array(s),f=new Int32Array(s),p=Array(s),m=0;m<s;m++)_[m]=a,f[m]=e._activeTextureUint,p[m]=t.TEXTURE0+e._activeTextureUint++;c.textureDefault=_,c.textureIndex=p,c.applyFunc=c.uploadTextureArray,e.bind(),t.uniform1iv(h,f)}else{var g=t.TEXTURE0+e._activeTextureUint;c.textureDefault=a,c.textureIndex=g,c.applyFunc=c.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var v=nY._getShaderPropertyGroup(o);e._groupingUniform(c,v,d)}),a.forEach(function(r){var a=r.name;e.attributeLocation[a]=t.getAttribLocation(n,a)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=Array(n),a=0;a<n;++a){var i=e.getActiveUniform(t,a);r[a]=i}return r},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,n=[],r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a<r;++a){var i=e.getActiveAttrib(t,a);n[a]=i}return n},e._addLineNum=function(e){var t,n=e.split("\n"),r=(n.length+1).toString().length+6;return n.map(function(e,n){if((t="0:"+(n+1)).length>=r)return t.substring(0,r)+e;for(var a=0;a<r-t.length;a++)t+=" ";return t+e}).join("\n")},tG(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();n5._counter=0;var n9=((V={})[V.Canonical=0]="Canonical",V[V.ShaderLab=1]="ShaderLab",V),n6=/*#__PURE__*/function(e){function t(n,r,a,i,o){var s;for(var l in(s=e.call(this)||this)._shaderPassId=0,s._renderStateDataMap={},s._shaderProgramPools=[],s._path="",s._platformMacros=[],s._shaderPassId=t._shaderPassCounter++,s._type=n9.Canonical,"string"==typeof i?(s._name=n,s._shaderLabSource=r,s._vertexEntry=a,s._fragmentEntry=i,o=nj({pipelineStage:nX.Forward},o),s._type=n9.ShaderLab):"string"==typeof a?(s._name=n,s._vertexSource=r,s._fragmentSource=a,o=null!=i?i:{pipelineStage:nX.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=r,o=null!=a?a:{pipelineStage:nX.Forward}),o)s.setTag(l,o[l]);return s}tW(t,e);var n=t.prototype;return n._getShaderProgram=function(e,t){var n=e._getShaderProgramPool(this),r=n.get(t);return r||(r=this._type===n9.Canonical?this._getCanonicalShaderProgram(e,t):this._compileShaderProgram(e,t,this._vertexEntry,this._fragmentEntry),n.cache(r)),r},n._destroy=function(){for(var e=this._shaderProgramPools,t=0,n=e.length;t<n;t++){var r=e[t];r._destroy(),delete r.engine._shaderProgramPools[this._shaderPassId]}e.length=0},n._compileShaderProgram=function(e,n,r,a){var i=this._path,o=this._platformMacros,s=e._hardwareRenderer.isWebGL2,l=[];nH._getMacrosElements(n,l),o.length=0,e._hardwareRenderer.canIUse(nZ.shaderTextureLod)&&o.push("HAS_TEX_LOD"),e._hardwareRenderer.canIUse(nZ.standardDerivatives)&&o.push("HAS_DERIVATIVES"),s?o.push("GRAPHICS_API_WEBGL2"):o.push("GRAPHICS_API_WEBGL1");var c=performance.now(),u=ro._shaderLab._parseShaderPass(this._shaderLabSource,r,a,l,s?nz.GLES300:nz.GLES100,o,new URL(i,t._shaderRootPath).href);return(no.info("[ShaderLab compilation] cost time: "+(performance.now()-c)+"ms"),u)?new n5(e,u.vertex,u.fragment):new n5(e,"","")},n._getCanonicalShaderProgram=function(e,t){var n=e._hardwareRenderer.isWebGL2,r=[];nH._getMacrosElements(t,r);var a=n$.parseCustomMacros(r),i=n?"#version 300 es":"#version 100",o=n?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",s="\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";e._hardwareRenderer.canIUse(nZ.shaderTextureLod)&&(s+="#define HAS_TEX_LOD\n"),e._hardwareRenderer.canIUse(nZ.standardDerivatives)&&(s+="#define HAS_DERIVATIVES\n");var l=" "+i+"\n "+o+"\n "+a+"\n "+n$.parseIncludes(this._vertexSource),c=" "+i+"\n "+o+"\n "+(n?"":n$._shaderExtension)+"\n "+s+"\n "+a+"\n "+n$.parseIncludes(this._fragmentSource);return n&&(l=n$.convertTo300(l),c=n$.convertTo300(c,!0)),new n5(e,l,c)},t}(n1);n6._shaderPassCounter=0,n6._shaderRootPath="shaders://root/";var n7=/*#__PURE__*/function(e){function t(t,n,r){var a;if((a=e.call(this)||this)._name=t,n.length<1)throw" count must large than 0.";for(var i in a._passes=n.slice(),r)a.setTag(i,r[i]);return a}return tW(t,e),tG(t,[{key:"passes",get:function(){return this._passes}}]),t}(n1),re=function(){this.enabled=!1,this.colorBlendOperation=nL.Add,this.alphaBlendOperation=nL.Add,this.sourceColorBlendFactor=nF.One,this.sourceAlphaBlendFactor=nF.One,this.destinationColorBlendFactor=nF.Zero,this.destinationAlphaBlendFactor=nF.Zero,this.colorWriteMask=nD.All},rt=/*#__PURE__*/function(){function e(){this.targetBlendState=new re,this.blendColor=new tO(0,0,0,0),this.alphaToCoverage=!1}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i,o,s,l,c=this.targetBlendState,u=e[nO.BlendStateEnabled0];if(void 0!==u){var d=t.getFloat(u);c.enabled=void 0!==d&&!!d}var h=e[nO.BlendStateColorBlendOperation0];void 0!==h&&(c.colorBlendOperation=null!=(n=t.getFloat(h))?n:nL.Add);var _=e[nO.BlendStateAlphaBlendOperation0];void 0!==_&&(c.alphaBlendOperation=null!=(r=t.getFloat(_))?r:nL.Add);var f=e[nO.BlendStateSourceColorBlendFactor0];void 0!==f&&(c.sourceColorBlendFactor=null!=(a=t.getFloat(f))?a:nF.One);var p=e[nO.BlendStateSourceAlphaBlendFactor0];void 0!==p&&(c.sourceAlphaBlendFactor=null!=(i=t.getFloat(p))?i:nF.One);var m=e[nO.BlendStateDestinationColorBlendFactor0];void 0!==m&&(c.destinationColorBlendFactor=null!=(o=t.getFloat(m))?o:nF.Zero);var g=e[nO.BlendStateDestinationAlphaBlendFactor0];void 0!==g&&(c.destinationAlphaBlendFactor=null!=(s=t.getFloat(g))?s:nF.Zero);var v=e[nO.BlendStateColorWriteMask0];void 0!==v&&(c.colorWriteMask=null!=(l=t.getFloat(v))?l:nD.All);var y=e[nO.BlendStateBlendColor];if(void 0!==y){var x=t.getColor(y);void 0!==x&&this.blendColor.copyFrom(x)}var b=e[nO.BlendStateAlphaToCoverage];if(void 0!==b){var S=t.getFloat(b);this.alphaToCoverage=void 0!==S&&!!S}},t._apply=function(e,t,n){this._platformApply(e,t.blendState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=n.targetBlendState,o=this.targetBlendState,s=o.enabled,l=o.colorBlendOperation,c=o.alphaBlendOperation,u=o.sourceColorBlendFactor,d=o.destinationColorBlendFactor,h=o.sourceAlphaBlendFactor,_=o.destinationAlphaBlendFactor,f=o.colorWriteMask;if(r){var p=r[nO.BlendStateColorWriteMask0];void 0!==p&&(f=p)}if(s!==i.enabled&&(s?a.enable(a.BLEND):a.disable(a.BLEND),i.enabled=s),s){(u!==i.sourceColorBlendFactor||d!==i.destinationColorBlendFactor||h!==i.sourceAlphaBlendFactor||_!==i.destinationAlphaBlendFactor)&&(a.blendFuncSeparate(e._getGLBlendFactor(t,u),e._getGLBlendFactor(t,d),e._getGLBlendFactor(t,h),e._getGLBlendFactor(t,_)),i.sourceColorBlendFactor=u,i.destinationColorBlendFactor=d,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=_),(l!==i.colorBlendOperation||c!==i.alphaBlendOperation)&&(a.blendEquationSeparate(e._getGLBlendOperation(t,l),e._getGLBlendOperation(t,c)),i.colorBlendOperation=l,i.alphaBlendOperation=c);var m=this.blendColor;tO.equals(n.blendColor,m)||(a.blendColor(m.r,m.g,m.b,m.a),n.blendColor.copyFrom(m))}f!==i.colorWriteMask&&(a.colorMask((f&nD.Red)!=0,(f&nD.Green)!=0,(f&nD.Blue)!=0,(f&nD.Alpha)!=0),i.colorWriteMask=f);var g=this.alphaToCoverage;g!==n.alphaToCoverage&&(g?a.enable(a.SAMPLE_ALPHA_TO_COVERAGE):a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),n.alphaToCoverage=g)},e._getGLBlendFactor=function(e,t){var n=e.gl;switch(t){case nF.Zero:return n.ZERO;case nF.One:return n.ONE;case nF.SourceColor:return n.SRC_COLOR;case nF.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case nF.DestinationColor:return n.DST_COLOR;case nF.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case nF.SourceAlpha:return n.SRC_ALPHA;case nF.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case nF.DestinationAlpha:return n.DST_ALPHA;case nF.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case nF.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case nF.BlendColor:return n.CONSTANT_COLOR;case nF.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},e._getGLBlendOperation=function(e,t){var n=e.gl;switch(t){case nL.Add:return n.FUNC_ADD;case nL.Subtract:return n.FUNC_SUBTRACT;case nL.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case nL.Min:if(!e.canIUse(nZ.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case nL.Max:if(!e.canIUse(nZ.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},e}();tX([tJ],rt.prototype,"targetBlendState",void 0),tX([tJ],rt.prototype,"blendColor",void 0);var rn=/*#__PURE__*/function(){function e(){this.enabled=!0,this.compareFunction=nB.Less,this.writeEnabled=!0}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r=e[nO.DepthStateEnabled];if(void 0!==r){var a=t.getFloat(r);this.enabled=void 0!==a&&!!a}var i=e[nO.DepthStateWriteEnabled];if(void 0!==i){var o=t.getFloat(i);this.writeEnabled=void 0!==o&&!!o}var s=e[nO.DepthStateCompareFunction];void 0!==s&&(this.compareFunction=null!=(n=t.getFloat(s))?n:nB.Less)},t._apply=function(e,t,n){this._platformApply(e,t.depthState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=this.enabled,o=this.compareFunction,s=this.writeEnabled;if(r){var l=r[nO.DepthStateEnabled];void 0!==l&&(i=l)}i!=n.enabled&&(i?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST),n.enabled=i),i&&o!=n.compareFunction&&(a.depthFunc(e._getGLCompareFunction(t,o)),n.compareFunction=o),s!=n.writeEnabled&&(a.depthMask(s),n.writeEnabled=s)},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nB.Never:return n.NEVER;case nB.Less:return n.LESS;case nB.Equal:return n.EQUAL;case nB.LessEqual:return n.LEQUAL;case nB.Greater:return n.GREATER;case nB.NotEqual:return n.NOTEQUAL;case nB.GreaterEqual:return n.GEQUAL;case nB.Always:return n.ALWAYS}},e}(),rr=/*#__PURE__*/function(){function e(){this.cullMode=nI.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i=e[nO.RasterStateCullMode];void 0!==i&&(this.cullMode=null!=(n=t.getFloat(i))?n:nI.Back);var o=e[nO.RasterStateDepthBias];void 0!==o&&(this.depthBias=null!=(r=t.getFloat(o))?r:0);var s=e[nO.RasterStateSlopeScaledDepthBias];void 0!==s&&(this.slopeScaledDepthBias=null!=(a=t.getFloat(s))?a:0)},t._apply=function(e,t,n,r){this._platformApply(e,t.rasterState,n,r)},t._platformApply=function(e,t,n,r){var a=e.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias;if(r){var l=r[nO.RasterStateCullMode];void 0!==l&&(i=l)}var c=i!==nI.Off;c!==t._cullFaceEnable&&(c?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),t._cullFaceEnable=c),c&&i!==t.cullMode&&(i==nI.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),t.cullMode=i),n!==t._frontFaceInvert&&(n?a.frontFace(a.CW):a.frontFace(a.CCW),t._frontFaceInvert=n),e._enableGlobalDepthBias||o===t.depthBias&&s===t.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),t.depthBias=o,t.slopeScaledDepthBias=s)},e}(),ra=/*#__PURE__*/function(){function e(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=nB.Always,this.compareFunctionBack=nB.Always,this.passOperationFront=nk.Keep,this.passOperationBack=nk.Keep,this.failOperationFront=nk.Keep,this.failOperationBack=nk.Keep,this.zFailOperationFront=nk.Keep,this.zFailOperationBack=nk.Keep}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i,o,s,l,c,u,d,h,_=e[nO.StencilStateEnabled];if(void 0!==_){var f=t.getFloat(_);this.enabled=void 0!==f&&!!f}var p=e[nO.StencilStateReferenceValue];void 0!==p&&(this.referenceValue=null!=(n=t.getFloat(p))?n:0);var m=e[nO.StencilStateMask];void 0!==m&&(this.mask=null!=(r=t.getFloat(m))?r:255);var g=e[nO.StencilStateWriteMask];void 0!==g&&(this.writeMask=null!=(a=t.getFloat(g))?a:255);var v=e[nO.StencilStateCompareFunctionFront];void 0!==v&&(this.compareFunctionFront=null!=(i=t.getFloat(v))?i:nB.Always);var y=e[nO.StencilStateCompareFunctionBack];void 0!==y&&(this.compareFunctionBack=null!=(o=t.getFloat(y))?o:nB.Always);var x=e[nO.StencilStatePassOperationFront];void 0!==x&&(this.passOperationFront=null!=(s=t.getFloat(x))?s:nk.Keep);var b=e[nO.StencilStatePassOperationBack];void 0!==b&&(this.passOperationBack=null!=(l=t.getFloat(b))?l:nk.Keep);var S=e[nO.StencilStateFailOperationFront];void 0!==S&&(this.failOperationFront=null!=(c=t.getFloat(S))?c:nk.Keep);var C=e[nO.StencilStateFailOperationBack];void 0!==C&&(this.failOperationBack=null!=(u=t.getFloat(C))?u:nk.Keep);var T=e[nO.StencilStateZFailOperationFront];void 0!==T&&(this.zFailOperationFront=null!=(d=t.getFloat(T))?d:nk.Keep);var A=e[nO.StencilStateZFailOperationBack];void 0!==A&&(this.zFailOperationBack=null!=(h=t.getFloat(A))?h:nk.Keep)},t._apply=function(e,t,n){this._platformApply(e,t.stencilState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=this.enabled,o=this.referenceValue,s=this.mask,l=this.compareFunctionFront,c=this.compareFunctionBack,u=this.failOperationFront,d=this.zFailOperationFront,h=this.passOperationFront,_=this.failOperationBack,f=this.zFailOperationBack,p=this.passOperationBack,m=this.writeMask;if(r){var g=r[nO.StencilStateEnabled];void 0!==g&&(i=g);var v=r[nO.StencilStateWriteMask];void 0!==v&&(m=v);var y=r[nO.StencilStateReferenceValue];void 0!==y&&(o=y);var x=r[nO.StencilStateCompareFunctionFront];void 0!==x&&(l=x);var b=r[nO.StencilStateCompareFunctionBack];void 0!==b&&(c=b);var S=r[nO.StencilStatePassOperationFront];void 0!==S&&(h=S);var C=r[nO.StencilStatePassOperationBack];void 0!==C&&(p=C);var T=r[nO.StencilStateFailOperationFront];void 0!==T&&(u=T);var A=r[nO.StencilStateFailOperationBack];void 0!==A&&(_=A);var E=r[nO.StencilStateZFailOperationFront];void 0!==E&&(d=E);var R=r[nO.StencilStateZFailOperationBack];void 0!==R&&(f=R)}if(i!=n.enabled&&(i?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),n.enabled=i),i){var M=o!==n.referenceValue||s!==n.mask;(M||l!==n.compareFunctionFront)&&(a.stencilFuncSeparate(a.FRONT,e._getGLCompareFunction(t,l),o,s),n.compareFunctionFront=l),(M||c!==n.compareFunctionBack)&&(a.stencilFuncSeparate(a.BACK,e._getGLCompareFunction(t,c),o,s),n.compareFunctionBack=c),M&&(n.referenceValue=o,n.mask=s),(u!==n.failOperationFront||d!==n.zFailOperationFront||h!==n.passOperationFront)&&(a.stencilOpSeparate(a.FRONT,e._getGLStencilOperation(t,u),e._getGLStencilOperation(t,d),e._getGLStencilOperation(t,h)),n.failOperationFront=u,n.zFailOperationFront=d,n.passOperationFront=h),(_!==n.failOperationBack||f!==n.zFailOperationBack||p!==n.passOperationBack)&&(a.stencilOpSeparate(a.BACK,e._getGLStencilOperation(t,_),e._getGLStencilOperation(t,f),e._getGLStencilOperation(t,p)),n.failOperationBack=_,n.zFailOperationBack=f,n.passOperationBack=p),m!==n.writeMask&&(a.stencilMask(m),n.writeMask=m)}},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nB.Never:return n.NEVER;case nB.Less:return n.LESS;case nB.Equal:return n.EQUAL;case nB.LessEqual:return n.LEQUAL;case nB.Greater:return n.GREATER;case nB.NotEqual:return n.NOTEQUAL;case nB.GreaterEqual:return n.GEQUAL;case nB.Always:return n.ALWAYS}},e._getGLStencilOperation=function(e,t){var n=e.gl;switch(t){case nk.Keep:return n.KEEP;case nk.Zero:return n.ZERO;case nk.Replace:return n.REPLACE;case nk.IncrementSaturate:return n.INCR;case nk.DecrementSaturate:return n.DECR;case nk.Invert:return n.INVERT;case nk.IncrementWrap:return n.INCR_WRAP;case nk.DecrementWrap:return n.DECR_WRAP}},e}(),ri=/*#__PURE__*/function(){function e(){this.blendState=new rt,this.depthState=new rn,this.stencilState=new ra,this.rasterState=new rr,this.renderQueueType=nV.Opaque}var t=e.prototype;return t._applyStates=function(e,t,n,r,a){n&&this._applyStatesByShaderData(n,r);var i=e._hardwareRenderer,o=e._lastRenderState,s=e._renderContext;this.blendState._apply(i,o,a),this.depthState._apply(i,o,a),this.stencilState._apply(i,o,a),this.rasterState._apply(i,o,s.flipProjection?!t:t,a)},t._applyRenderQueueByShaderData=function(e,t){var n,r=e[nO.RenderQueueType];void 0!==r&&(this.renderQueueType=null!=(n=t.getFloat(r))?n:nV.Opaque)},t._applyStatesByShaderData=function(e,t){this.blendState._applyShaderDataValue(e,t),this.depthState._applyShaderDataValue(e,t),this.stencilState._applyShaderDataValue(e,t),this.rasterState._applyShaderDataValue(e,t)},e}();tX([tJ],ri.prototype,"blendState",void 0),tX([tJ],ri.prototype,"depthState",void 0),tX([tJ],ri.prototype,"stencilState",void 0),tX([tJ],ri.prototype,"rasterState",void 0);var ro=/*#__PURE__*/function(){function e(e,t){this.name=e,this._refCount=0,this._destroyed=!1,this.name=e,this._subShaders=t}var t=e.prototype;return t._registerPath=function(e){for(var t,n=nG(this._subShaders);!(t=n()).done;)for(var r,a=t.value,i=nG(a.passes);!(r=i()).done;)r.value._path=e},t.compileVariant=function(t,n){var r=e._compileMacros;r.clear();for(var a=0,i=n.length;a<i;a++)r.enable(nH.getByName(n[a]));for(var o=!1,s=this._subShaders,l=0,c=s.length;l<c;l++)for(var u=s[l].passes,d=0,h=u.length;d<h;d++){var _=u[d]._getShaderProgram(t,r);o=0===d?_.isValid:o&&_.isValid}return o},t.destroy=function(t){if(void 0===t&&(t=!1),!t&&0!==this._refCount)return!1;for(var n=this._subShaders,r=0,a=n.length;r<a;r++)for(var i=n[r].passes,o=0,s=i.length;o<s;o++)i[o]._destroy();return delete e._shaderMap[this.name],this._destroyed=!0,!0},t._getReferCount=function(){return this._refCount},t._addReferCount=function(e){this._refCount+=e},e.create=function(t,n,r){var a,i=e._shaderMap;if(n){if(i[t]){console.error('Shader named "'+t+'" already exists.');return}if("string"==typeof n)a=new e(t,[new n7("Default",[new n6(n,r)])]);else if(n.length>0)a=n[0].constructor===n6?new e(t,[new n7("Default",n)]):new e(t,n.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!e._shaderLab)throw"ShaderLab has not been set up yet.";var o=e._shaderLab._parseShaderContent(t);if(i[o.name]){console.error('Shader named "'+o.name+'" already exists.');return}var s=o.subShaders.map(function(t){var n=t.passes.map(function(t){if(t.isUsePass){var n,r,a=t.name.split("/");return null==(r=e.find(a[0]))?void 0:null==(n=r.subShaders.find(function(e){return e.name===a[1]}))?void 0:n.passes.find(function(e){return e.name===a[2]})}var i=new n6(t.name,t.contents,t.vertexEntry,t.fragmentEntry,t.tags),o=t.renderStates,s=o.constantMap,l=o.variableMap;if(Object.keys(s).length>0||Object.keys(l).length>0){var c=new ri;for(var u in i._renderState=c,s)e._applyConstRenderStates(c,parseInt(u),s[u]);var d={};for(var h in l)d[h]=nY.getByName(l[h]);i._renderStateDataMap=d}return i});return new n7(t.name,n,t.tags)});return a=new e(o.name,s),i[o.name]=a,a}return i[t]=a,a},e.find=function(t){return e._shaderMap[t]},e._applyConstRenderStates=function(e,t,n){switch(t){case nO.BlendStateEnabled0:e.blendState.targetBlendState.enabled=n;break;case nO.BlendStateColorBlendOperation0:e.blendState.targetBlendState.colorBlendOperation=n;break;case nO.BlendStateAlphaBlendOperation0:e.blendState.targetBlendState.alphaBlendOperation=n;break;case nO.BlendStateSourceColorBlendFactor0:e.blendState.targetBlendState.sourceColorBlendFactor=n;break;case nO.BlendStateDestinationColorBlendFactor0:e.blendState.targetBlendState.destinationColorBlendFactor=n;break;case nO.BlendStateSourceAlphaBlendFactor0:e.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case nO.BlendStateDestinationAlphaBlendFactor0:e.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case nO.BlendStateColorWriteMask0:e.blendState.targetBlendState.colorWriteMask=n;break;case nO.DepthStateEnabled:e.depthState.enabled=n;break;case nO.DepthStateWriteEnabled:e.depthState.writeEnabled=n;break;case nO.DepthStateCompareFunction:e.depthState.compareFunction=n;break;case nO.StencilStateEnabled:e.stencilState.enabled=n;break;case nO.StencilStateReferenceValue:e.stencilState.referenceValue=n;break;case nO.StencilStateMask:e.stencilState.mask=n;break;case nO.StencilStateWriteMask:e.stencilState.writeMask=n;break;case nO.StencilStateCompareFunctionFront:e.stencilState.compareFunctionFront=n;break;case nO.StencilStateCompareFunctionBack:e.stencilState.compareFunctionBack=n;break;case nO.StencilStatePassOperationFront:e.stencilState.passOperationFront=n;break;case nO.StencilStatePassOperationBack:e.stencilState.passOperationBack=n;break;case nO.StencilStateFailOperationFront:e.stencilState.failOperationFront=n;break;case nO.StencilStateFailOperationBack:e.stencilState.failOperationBack=n;break;case nO.StencilStateZFailOperationFront:e.stencilState.zFailOperationFront=n;break;case nO.StencilStateZFailOperationBack:e.stencilState.zFailOperationBack=n;break;case nO.RasterStateCullMode:e.rasterState.cullMode=n;break;case nO.RasterStateDepthBias:e.rasterState.depthBias=n;break;case nO.RasterStateSlopeScaledDepthBias:e.rasterState.slopeScaledDepthBias=n;break;case nO.RenderQueueType:e.renderQueueType=n}},e.getMacroByName=function(e,t){return nH.getByName(e,t)},e.getPropertyByName=function(e){return nY.getByName(e)},tG(e,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();ro._compileMacros=new nW,ro._shaderMap=Object.create(null);var rs=/*#__PURE__*/function(){function e(e){this._propertyValueMap=Object.create(null),this._macroCollection=new nW,this._macroMap=Object.create(null),this._refCount=0,this._group=e}var t=e.prototype;return t.getFloat=function(e){return this.getPropertyValue(e)},t.setFloat=function(e,t){this._setPropertyValue(e,nN.Float,t)},t.getInt=function(e){return this.getPropertyValue(e)},t.setInt=function(e,t){this._setPropertyValue(e,nN.Int,t)},t.getFloatArray=function(e){return this.getPropertyValue(e)},t.setFloatArray=function(e,t){this._setPropertyValue(e,nN.FloatArray,t)},t.getIntArray=function(e){return this.getPropertyValue(e)},t.setIntArray=function(e,t){this._setPropertyValue(e,nN.IntArray,t)},t.getVector2=function(e){return this.getPropertyValue(e)},t.setVector2=function(e,t){this._setPropertyValue(e,nN.Vector2,t)},t.getVector3=function(e){return this.getPropertyValue(e)},t.setVector3=function(e,t){this._setPropertyValue(e,nN.Vector3,t)},t.getVector4=function(e){return this.getPropertyValue(e)},t.setVector4=function(e,t){this._setPropertyValue(e,nN.Vector4,t)},t.getMatrix=function(e){return this.getPropertyValue(e)},t.setMatrix=function(e,t){this._setPropertyValue(e,nN.Matrix,t)},t.getColor=function(e){return this.getPropertyValue(e)},t.setColor=function(e,t){this._setPropertyValue(e,nN.Color,t)},t.getTexture=function(e){return this.getPropertyValue(e)},t.setTexture=function(e,t){var n=this._refCount;if(n>0){var r=this.getPropertyValue(e);r&&r._addReferCount(-n),t&&t._addReferCount(n)}this._setPropertyValue(e,nN.Texture,t)},t.getTextureArray=function(e){return this.getPropertyValue(e)},t.setTextureArray=function(e,t){var n=this._refCount;if(n>0){var r=this.getPropertyValue(e);if(r)for(var a=0,i=r.length;a<i;a++)r[a]._addReferCount(-n);if(t)for(var o=0,s=t.length;o<s;o++)t[o]._addReferCount(n)}this._setPropertyValue(e,nN.TextureArray,t)},t.getPropertyValue=function(e){return"string"==typeof e&&(e=nY.getByName(e)),this._propertyValueMap[e._uniqueId]},t.enableMacro=function(e,t){"string"==typeof e&&(e=nH.getByName(e,t));var n=e._nameId,r=this._macroMap[n];if(r!==e){var a=this._macroCollection;r&&a.disable(r),a.enable(e),this._macroMap[n]=e}},t.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=nH._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},t.getMacros=function(e){if(!e)return Object.values(this._macroMap);var t=this._macroMap;for(var n in e.length=0,t)e.push(t[n])},t.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=nY._propertyIdMap;for(var a in n)t.push(r[a]);if(!e)return t},t.clone=function(){var t=new e(this._group);return this.cloneTo(t),t},t.cloneTo=function(e){t$.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),n=this._propertyValueMap,r=e._propertyValueMap,a=Object.keys(n),i=0,o=a.length;i<o;i++){var s=a[i],l=n[s];if(null!=l){if("number"==typeof l)r[s]=l;else if(tK(l,ns))r[s]=l,t>0&&l._addReferCount(t);else if(tK(l,Array)||tK(l,Float32Array)||tK(l,Int32Array))r[s]=l.slice();else{var c=r[s];c?c.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},t._setPropertyValue=function(e,t,n){if("string"==typeof e&&(e=nY.getByName(e)),e._group!==this._group){if(void 0===e._group)e._group=this._group;else throw"Shader property "+e.name+" has been used as "+n8[e._group]+" group."}if(e._type!==t){if(void 0===e._type)e._type=t;else throw"Shader property "+e.name+" has been used as "+nN[e._type]+" type."}this._propertyValueMap[e._uniqueId]=n},t._getReferCount=function(){return this._refCount},t._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&tK(r,ns)&&r._addReferCount(e)}},e}();tX([tq],rs.prototype,"_group",void 0),tX([tq],rs.prototype,"_propertyValueMap",void 0),tX([tq],rs.prototype,"_macroCollection",void 0),tX([tq],rs.prototype,"_macroMap",void 0),tX([tq],rs.prototype,"_refCount",void 0);var rl=/*#__PURE__*/function(){function e(){}return e.canBatchSprite=function(t,n){if(!0===n.shaderPasses[0].getTagValue(e._disableBatchTag)||t.subChunk.chunk!==n.subChunk.chunk)return!1;var r=t.component,a=n.component,i=r.maskInteraction;return i===a.maskInteraction&&(i===nv.None||r.maskLayer===a.maskLayer)&&t.texture===n.texture&&t.material===n.material},e.canBatchSpriteMask=function(e,t){if(e.subChunk.chunk!==t.subChunk.chunk)return!1;var n=r2._alphaCutoffProperty;return e.texture===t.texture&&e.component.shaderData.getFloat(n)===t.component.shaderData.getFloat(n)},e.batchFor2D=function(e,t){var n=t?t.subChunk:e.subChunk,r=n.chunk,a=n.indices,i=a.length,o=r.updateIndexLength;if(t)e.subChunk.subMesh.count+=i;else{var s=n.subMesh;s.start=o,s.count=i}for(var l=n.vertexArea,c=l.start,u=l.size,d=c/9,h=r.indices,_=0;_<i;++_)h[o++]=d+a[_];r.updateIndexLength+=i,r.updateVertexStart=Math.min(r.updateVertexStart,c),r.updateVertexEnd=Math.max(r.updateVertexEnd,c+u)},e}();rl._disableBatchTag=n0.getByName("spriteDisableBatching");var rc=((N={})[N.None=0]="None",N[N.Scene=1]="Scene",N[N.Hierarchy=2]="Hierarchy",N[N.All=3]="All",N),ru=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t.engine)||this)._awoken=!1,n._phasedActiveInScene=!1,n._phasedActive=!1,n._enabled=!0,n._entity=t,n}tW(t,e);var n=t.prototype;return n._onAwake=function(){},n._onEnable=function(){},n._onDisable=function(){},n._onEnableInScene=function(){},n._onDisableInScene=function(){},n._setActive=function(e,t){var n=this._entity;t&rc.Scene&&(e?!this._phasedActiveInScene&&n._isActiveInScene&&this._enabled&&(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&!(n._isActiveInScene&&this._enabled)&&(this._phasedActiveInScene=!1,this._onDisableInScene())),t&rc.Hierarchy&&(e?(!this._awoken&&n._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&n._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(n._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable()))},n._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._entity;t._removeComponent(this),this._enabled&&(t._isActiveInScene&&this._onDisableInScene(),t._isActiveInHierarchy&&this._onDisable())},tG(t,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity._isActiveInScene&&(e?this._phasedActiveInScene||(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&(this._phasedActiveInScene=!1,this._onDisableInScene())),this._entity.isActiveInHierarchy&&(e?this._phasedActive||(this._phasedActive=!0,this._onEnable()):this._phasedActive&&(this._phasedActive=!1,this._onDisable())))}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),t}(t0);tX([tq],ru.prototype,"_entity",void 0),tX([tq],ru.prototype,"_awoken",void 0),tX([tq],ru.prototype,"_phasedActiveInScene",void 0),tX([tq],ru.prototype,"_phasedActive",void 0),tX([tQ],ru.prototype,"_enabled",void 0);var rd=/*#__PURE__*/function(){function e(){}return e._addCheck=function(t,n){for(;n!==ru;){var r=e._dependenciesMap.get(n);if(r)for(var a=r.components,i=r.mode,o=0,s=a.length;o<s;o++){var l=a[o];if(!t.getComponent(l)){if(1===i)t.addComponent(l);else throw"Should add "+l.name+" before adding "+n.name}}n=Object.getPrototypeOf(n)}},e._removeCheck=function(t,n){for(;n!==ru;){var r=e._invDependenciesMap.get(n);if(r){for(var a=0,i=r.length;a<i;a++)if(t.getComponent(r[a]))throw"Should remove "+r[a].name+" before adding "+n.name}n=Object.getPrototypeOf(n)}},e._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},e._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},e}();function rh(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){rd._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return rd._addInvDependency(t,e)})}}rd._invDependenciesMap=new Map,rd._dependenciesMap=new Map;var r_=((k={})[k.CheckOnly=0]="CheckOnly",k[k.AutoAdd=1]="AutoAdd",k),rf=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.flag=!0,t}return tW(t,e),t.prototype.dispatch=function(){this.flag=!0},t}(/*#__PURE__*/function(){function e(){this._flagManagers=[]}var t=e.prototype;return t.clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},t.destroy=function(){this._removeFromManagers(),this._flagManagers=null},t._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)nT.removeFromArray(e[t]._updateFlags,this)},e}()),rp=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._position=new tT,n._rotation=new tT,n._rotationQuaternion=new tF,n._scale=new tT(1,1,1),n._worldPosition=new tT,n._worldRotation=new tT,n._worldRotationQuaternion=new tF,n._lossyWorldScale=new tT(1,1,1),n._localMatrix=new tL,n._worldMatrix=new tL,n._worldForward=null,n._worldRight=null,n._worldUp=null,n._isParentDirty=!0,n._parentTransformCache=null,n._dirtyFlag=188,n._updateFlagManager=new nM,n._onPositionChanged=n._onPositionChanged.bind(n),n._onWorldPositionChanged=n._onWorldPositionChanged.bind(n),n._onRotationChanged=n._onRotationChanged.bind(n),n._onWorldRotationChanged=n._onWorldRotationChanged.bind(n),n._onRotationQuaternionChanged=n._onRotationQuaternionChanged.bind(n),n._onWorldRotationQuaternionChanged=n._onWorldRotationQuaternionChanged.bind(n),n._onScaleChanged=n._onScaleChanged.bind(n),n._position._onValueChanged=n._onPositionChanged,n._worldPosition._onValueChanged=n._onWorldPositionChanged,n._rotation._onValueChanged=n._onRotationChanged,n._worldRotation._onValueChanged=n._onWorldRotationChanged,n._rotationQuaternion._onValueChanged=n._onRotationQuaternionChanged,n._worldRotationQuaternion._onValueChanged=n._onWorldRotationQuaternionChanged,n._scale._onValueChanged=n._onScaleChanged,n}tW(t,e);var n=t.prototype;return n.setPosition=function(e,t,n){this._position.set(e,t,n)},n.setRotation=function(e,t,n){this._rotation.set(e,t,n)},n.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},n.setScale=function(e,t,n){this._scale.set(e,t,n)},n.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},n.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},n.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},n.translate=function(e,n,r,a){if("number"==typeof e){var i=t._tempVec30;i.set(e,n,r),this._translate(i,a)}else this._translate(e,n)},n.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},n.rotateByAxis=function(e,n,r){void 0===r&&(r=!0);var a=n*tC.degreeToRadFactor;tF.rotationAxisAngle(e,a,t._tempQuat0),this._rotateByQuat(t._tempQuat0,r)},n.lookAt=function(e,n){var r=t._tempVec30;tT.subtract(this.worldPosition,e,r);var a=r.length();if(!(a<=tC.zeroTolerance)){r.scale(1/a);var i=t._tempVec31;if(n?tT.cross(n,r,i):i.set(r.z,0,-r.x),!((a=i.length())<=tC.zeroTolerance)){i.scale(1/a);var o=t._tempVec32;tT.cross(r,i,o);var s=t._tempMat41,l=s.elements;l[0]=i.x,l[1]=i.y,l[2]=i.z,l[4]=o.x,l[5]=o.y,l[6]=o.z,l[8]=r.x,l[9]=r.y,l[10]=r.z,s.getRotation(this._worldRotationQuaternion)}}},n.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(rf)},n._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},n._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._worldPosition._onValueChanged=null,this._rotation._onValueChanged=null,this._worldRotation._onValueChanged=null,this._rotationQuaternion._onValueChanged=null,this._worldRotationQuaternion._onValueChanged=null,this._position._onValueChanged=null,this._scale._onValueChanged=null},n._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)){this._worldAssociatedChange(132);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionFlag()}},n._updateWorldRotationFlag=function(){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()}},n._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()}},n._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()}},n._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()}},n._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()}},n._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;for(var e=null,t=this._entity.parent;t;){var n=t.transform;if(n){e=n;break}t=t.parent}return this._parentTransformCache=e,this._isParentDirty=!1,e},n._getScaleMatrix=function(){var e=t._tempQuat0,n=t._tempMat30,r=t._tempMat31,a=t._tempMat32;return r.copyFromMatrix(this.worldMatrix),tF.invert(this.worldRotationQuaternion,e),tP.rotationQuaternion(e,n),tP.multiply(n,r,a),a},n._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},n._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},n._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},n._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},n._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},n._rotateByQuat=function(e,t){t?tF.multiply(this.rotationQuaternion,e,this._rotationQuaternion):tF.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},n._translate=function(e,n){if(void 0===n&&(n=!0),n){var r=t._tempVec30;tT.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},n._rotateXYZ=function(e,n,r,a){void 0===a&&(a=!0);var i=tC.degreeToRadFactor,o=t._tempQuat0;tF.rotationEuler(e*i,n*i,r*i,o),this._rotateByQuat(o,a)},n._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},n._onWorldPositionChanged=function(){var e=this._worldPosition,n=this._getParentTransform();n?(tL.invert(n.worldMatrix,t._tempMat41),tT.transformCoordinate(e,t._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},n._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},n._onWorldRotationChanged=function(){var e=this._worldRotation;tF.rotationEuler(tC.degreeToRadian(e.x),tC.degreeToRadian(e.y),tC.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},n._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},n._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,n=this._getParentTransform();if(n){var r=t._tempQuat0;tF.invert(n.worldRotationQuaternion,r),tF.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},n._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},tG(t,[{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"worldPosition",get:function(){var e=this._worldPosition;return this._isContainDirtyFlag(4)&&(e._onValueChanged=null,this._getParentTransform()?this.worldMatrix.getTranslation(e):e.copyFrom(this._position),e._onValueChanged=this._onWorldPositionChanged,this._setDirtyFlagFalse(4)),e},set:function(e){this._worldPosition!==e&&this._worldPosition.copyFrom(e)}},{key:"rotation",get:function(){var e=this._rotation;return this._isContainDirtyFlag(1)&&(e._onValueChanged=null,this._rotationQuaternion.toEuler(e),e.scale(tC.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(tC.radToDegreeFactor),e._onValueChanged=this._onWorldRotationChanged,this._setDirtyFlagFalse(8)),e},set:function(e){this._worldRotation!==e&&this._worldRotation.copyFrom(e)}},{key:"rotationQuaternion",get:function(){var e=this._rotationQuaternion;return this._isContainDirtyFlag(2)&&(e._onValueChanged=null,tF.rotationEuler(tC.degreeToRadian(this._rotation.x),tC.degreeToRadian(this._rotation.y),tC.degreeToRadian(this._rotation.z),e),e._onValueChanged=this._onRotationQuaternionChanged,this._setDirtyFlagFalse(2)),e},set:function(e){this._rotationQuaternion!==e?e.normalized?this._rotationQuaternion.copyFrom(e):tF.normalize(e,this._rotationQuaternion):e.normalized||e.normalize()}},{key:"worldRotationQuaternion",get:function(){var e=this._worldRotationQuaternion;if(this._isContainDirtyFlag(16)){e._onValueChanged=null;var t=this._getParentTransform();null!=t?tF.multiply(t.worldRotationQuaternion,this.rotationQuaternion,e):e.copyFrom(this.rotationQuaternion),e._onValueChanged=this._onWorldRotationQuaternionChanged,this._setDirtyFlagFalse(16)}return e},set:function(e){this._worldRotationQuaternion!==e&&(e.normalized?this._worldRotationQuaternion.copyFrom(e):tF.normalize(e,this._worldRotationQuaternion)),e.normalized||e.normalize()}},{key:"scale",get:function(){return this._scale},set:function(e){this._scale!==e&&this._scale.copyFrom(e)}},{key:"lossyWorldScale",get:function(){if(this._isContainDirtyFlag(32)){if(this._getParentTransform()){var e=this._getScaleMatrix().elements;this._lossyWorldScale.set(e[0],e[4],e[8])}else this._lossyWorldScale.copyFrom(this._scale);this._setDirtyFlagFalse(32)}return this._lossyWorldScale}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(tL.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(e){this._localMatrix!==e&&this._localMatrix.copyFrom(e),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?tL.multiply(e.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(e){this._worldMatrix!==e&&this._worldMatrix.copyFrom(e);var n=this._getParentTransform();n?(tL.invert(n.worldMatrix,t._tempMat42),tL.multiply(t._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}},{key:"worldForward",get:function(){var e=this._worldForward||(this._worldForward=new tT),t=this.worldMatrix.elements;return e.set(-t[8],-t[9],-t[10]),e.normalize()}},{key:"worldRight",get:function(){var e=this._worldRight||(this._worldRight=new tT),t=this.worldMatrix.elements;return e.set(t[0],t[1],t[2]),e.normalize()}},{key:"worldUp",get:function(){var e=this._worldUp||(this._worldUp=new tT),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),t}(ru);rp._tempQuat0=new tF,rp._tempVec30=new tT,rp._tempVec31=new tT,rp._tempVec32=new tT,rp._tempMat30=new tP,rp._tempMat31=new tP,rp._tempMat32=new tP,rp._tempMat41=new tL,rp._tempMat42=new tL,tX([tJ],rp.prototype,"_position",void 0),tX([tJ],rp.prototype,"_rotation",void 0),tX([tJ],rp.prototype,"_rotationQuaternion",void 0),tX([tJ],rp.prototype,"_scale",void 0),tX([tJ],rp.prototype,"_worldPosition",void 0),tX([tJ],rp.prototype,"_worldRotation",void 0),tX([tJ],rp.prototype,"_worldRotationQuaternion",void 0),tX([tJ],rp.prototype,"_lossyWorldScale",void 0),tX([tJ],rp.prototype,"_localMatrix",void 0),tX([tJ],rp.prototype,"_worldMatrix",void 0),tX([tq],rp.prototype,"_worldForward",void 0),tX([tq],rp.prototype,"_worldRight",void 0),tX([tq],rp.prototype,"_worldUp",void 0),tX([tq],rp.prototype,"_isParentDirty",void 0),tX([tq],rp.prototype,"_parentTransformCache",void 0),tX([tq],rp.prototype,"_updateFlagManager",void 0),tX([tq],rp.prototype,"_onPositionChanged",null),tX([tq],rp.prototype,"_onWorldPositionChanged",null),tX([tq],rp.prototype,"_onRotationChanged",null),tX([tq],rp.prototype,"_onWorldRotationChanged",null),tX([tq],rp.prototype,"_onRotationQuaternionChanged",null),tX([tq],rp.prototype,"_onWorldRotationQuaternionChanged",null),tX([tq],rp.prototype,"_onScaleChanged",null);var rm=((z={})[z.LocalEuler=1]="LocalEuler",z[z.LocalQuat=2]="LocalQuat",z[z.WorldPosition=4]="WorldPosition",z[z.WorldEuler=8]="WorldEuler",z[z.WorldQuat=16]="WorldQuat",z[z.WorldScale=32]="WorldScale",z[z.LocalMatrix=64]="LocalMatrix",z[z.WorldMatrix=128]="WorldMatrix",z[z.WmWp=132]="WmWp",z[z.WmWeWq=152]="WmWeWq",z[z.WmWpWeWq=156]="WmWpWeWq",z[z.WmWs=160]="WmWs",z[z.WmWpWs=164]="WmWpWs",z[z.WmWpWeWqWs=188]="WmWpWeWqWs",z),rg=((U={})[U.Layer0=1]="Layer0",U[U.Layer1=2]="Layer1",U[U.Layer2=4]="Layer2",U[U.Layer3=8]="Layer3",U[U.Layer4=16]="Layer4",U[U.Layer5=32]="Layer5",U[U.Layer6=64]="Layer6",U[U.Layer7=128]="Layer7",U[U.Layer8=256]="Layer8",U[U.Layer9=512]="Layer9",U[U.Layer10=1024]="Layer10",U[U.Layer11=2048]="Layer11",U[U.Layer12=4096]="Layer12",U[U.Layer13=8192]="Layer13",U[U.Layer14=16384]="Layer14",U[U.Layer15=32768]="Layer15",U[U.Layer16=65536]="Layer16",U[U.Layer17=131072]="Layer17",U[U.Layer18=262144]="Layer18",U[U.Layer19=524288]="Layer19",U[U.Layer20=1048576]="Layer20",U[U.Layer21=2097152]="Layer21",U[U.Layer22=4194304]="Layer22",U[U.Layer23=8388608]="Layer23",U[U.Layer24=0x1000000]="Layer24",U[U.Layer25=0x2000000]="Layer25",U[U.Layer26=0x4000000]="Layer26",U[U.Layer27=0x8000000]="Layer27",U[U.Layer28=0x10000000]="Layer28",U[U.Layer29=0x20000000]="Layer29",U[U.Layer30=0x40000000]="Layer30",U[U.Layer31=0x80000000]="Layer31",U[U.Everything=0xffffffff]="Everything",U[U.Nothing=0]="Nothing",U);e.Renderer=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new nW,r._bounds=new tE,r._maskInteraction=nv.None,r._maskLayer=rg.Layer0,r._batchedTransformShaderData=!1,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new tI,r._shaderData=new rs(n8.Renderer),r._mvMatrix=new tL,r._mvpMatrix=new tL,r._mvInvMatrix=new tL,r._normalMatrix=new tL,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r.castShadows=!0;var r,a=t.prototype,i=r.shaderData;return r._overrideUpdate=r.update!==a.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(r),r._setTransform(n.transform),i.enableMacro(t._receiveShadowMacro),i.setVector4(t._rendererLayerProperty,r._rendererLayer),r}tW(t,e);var n=t.prototype;return n.getInstanceMaterial=function(e){void 0===e&&(e=0);var t=this._materials;if(t.length>e){var n=t[e];if(n)return this._materialsInstanced[e]?n:this._createInstanceMaterial(n,e)}return null},n.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},n.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},n.getInstanceMaterials=function(){for(var e=this._materials,t=this._materialsInstanced,n=0,r=e.length;n<r;n++)t[n]||this._createInstanceMaterial(this._materials[n],n);return e},n.getMaterials=function(){return this._materials},n.setMaterials=function(e){for(var t=e.length,n=this._materials,r=this._materialsInstanced,a=t,i=n.length;a<i;a++){var o=n[a];o&&this._addResourceReferCount(o,-1)}n.length!==t&&(n.length=t),0!==r.length&&(r.length=0);for(var s=0;s<t;s++){var l=n[s],c=e[s];l!==c&&(n[s]=c,l&&this._addResourceReferCount(l,-1),c&&this._addResourceReferCount(c,1))}},n.update=function(e){},n._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},n._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},n._prepareRender=function(e){this._renderFrameCount!==this.engine.time.frameCount&&this._update(e);var n=e.virtualCamera,r=n.position,a=this.bounds.getCenter(t._tempVector0);n.isOrthographic?(tT.subtract(a,r,a),this._distanceForSort=tT.dot(a,n.forward)):this._distanceForSort=tT.distanceSquared(a,r),this._render(e),nW.unionCollection(e.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},n._cloneTo=function(e,t,n){for(var r=this._materials,a=0,i=r.length;a<i;a++)e._setMaterial(a,r[a])},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._setTransform(null),this._addResourceReferCount(this.shaderData,-1);for(var t=this._materials,n=0,r=t.length;n<r;n++){var a=t[n];a&&this._addResourceReferCount(a,-1)}this._entity=null,this._globalShaderMacro=null,this._bounds=null,this._materials=null,this._shaderData=null,this._mvMatrix=null,this._mvpMatrix=null,this._mvInvMatrix=null,this._normalMatrix=null,this._materialsInstanced=null,this._rendererLayer=null},n._updateTransformShaderData=function(e,t,n){var r=this._transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,r,n):this._updateWorldViewRelatedShaderData(e,r,n)},n._canBatch=function(e,t){return!1},n._batch=function(e,t){},n._update=function(e){var t=this.entity.layer;this._rendererLayer.set(65535&t,t>>>16&65535,0,0)},n._updateWorldViewRelatedShaderData=function(e,n,r){var a=this.shaderData,i=this._mvInvMatrix;if(r){var o=tL._identity;tL.invert(e.viewMatrix,i),a.setMatrix(t._localMatrixProperty,o),a.setMatrix(t._worldMatrixProperty,o),a.setMatrix(t._mvMatrixProperty,e.viewMatrix),a.setMatrix(t._mvInvMatrixProperty,i),a.setMatrix(t._normalMatrixProperty,o)}else{var s=this._mvMatrix,l=this._normalMatrix;tL.multiply(e.viewMatrix,n,s),tL.invert(s,i),tL.invert(n,l),l.transpose(),a.setMatrix(t._localMatrixProperty,this._transform.localMatrix),a.setMatrix(t._worldMatrixProperty,n),a.setMatrix(t._mvMatrixProperty,s),a.setMatrix(t._mvInvMatrixProperty,i),a.setMatrix(t._normalMatrixProperty,l)}this._updateProjectionRelatedShaderData(e,n,r)},n._updateProjectionRelatedShaderData=function(e,n,r){if(r)this.shaderData.setMatrix(t._mvpMatrixProperty,e.viewProjectionMatrix);else{var a=this._mvpMatrix;tL.multiply(e.viewProjectionMatrix,n,a),this.shaderData.setMatrix(t._mvpMatrixProperty,a)}},n._setTransform=function(e){var t;null==(t=this._transform)||t._updateFlagManager.removeListener(this._onTransformChanged),null==e||e._updateFlagManager.addListener(this._onTransformChanged),this._transform=e},n._updateBounds=function(e){},n._render=function(e){throw"not implement"},n._createInstanceMaterial=function(e,t){var n=e.clone();return n.name=n.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(n,1),this._materialsInstanced[t]=!0,this._materials[t]=n,n},n._setMaterial=function(e,t){var n=this._materials;e>=n.length&&(n.length=e+1);var r=n[e];if(r!==t){var a=this._materialsInstanced;e<a.length&&(a[e]=!1),r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),n[e]=t}},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},tG(t,[{key:"shaderData",get:function(){return this._shaderData}},{key:"isCulled",get:function(){return!(void 0===this._renderFrameCount||this._renderFrameCount===this._engine.time.frameCount-1)}},{key:"receiveShadows",get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(e?this.shaderData.enableMacro(t._receiveShadowMacro):this.shaderData.disableMacro(t._receiveShadowMacro),this._receiveShadows=e)}},{key:"materialCount",get:function(){return this._materials.length},set:function(e){var t=this._materials,n=this._materialsInstanced;t.length!==e&&(t.length=e),n.length>e&&(n.length=e)}},{key:"bounds",get:function(){return 1&this._dirtyUpdateFlag&&(this._updateBounds(this._bounds),this._dirtyUpdateFlag&=-2),this._bounds}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}}]),t}(ru),e.Renderer._tempVector0=new tT,e.Renderer._receiveShadowMacro=nH.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e.Renderer._localMatrixProperty=nY.getByName("renderer_LocalMat"),e.Renderer._worldMatrixProperty=nY.getByName("renderer_ModelMat"),e.Renderer._mvMatrixProperty=nY.getByName("renderer_MVMat"),e.Renderer._mvpMatrixProperty=nY.getByName("renderer_MVPMat"),e.Renderer._mvInvMatrixProperty=nY.getByName("renderer_MVInvMat"),e.Renderer._normalMatrixProperty=nY.getByName("renderer_NormalMat"),e.Renderer._rendererLayerProperty=nY.getByName("renderer_Layer"),tX([tq],e.Renderer.prototype,"_distanceForSort",void 0),tX([tq],e.Renderer.prototype,"_onUpdateIndex",void 0),tX([tq],e.Renderer.prototype,"_rendererIndex",void 0),tX([tq],e.Renderer.prototype,"_globalShaderMacro",void 0),tX([tq],e.Renderer.prototype,"_bounds",void 0),tX([tq],e.Renderer.prototype,"_renderFrameCount",void 0),tX([tQ],e.Renderer.prototype,"_maskInteraction",void 0),tX([tQ],e.Renderer.prototype,"_maskLayer",void 0),tX([tq],e.Renderer.prototype,"_batchedTransformShaderData",void 0),tX([tq],e.Renderer.prototype,"_overrideUpdate",void 0),tX([tq],e.Renderer.prototype,"_materials",void 0),tX([tq],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),tX([tq],e.Renderer.prototype,"_rendererLayer",void 0),tX([tq],e.Renderer.prototype,"_transform",void 0),tX([tJ],e.Renderer.prototype,"_shaderData",void 0),tX([tq],e.Renderer.prototype,"_mvMatrix",void 0),tX([tq],e.Renderer.prototype,"_mvpMatrix",void 0),tX([tq],e.Renderer.prototype,"_mvInvMatrix",void 0),tX([tq],e.Renderer.prototype,"_normalMatrix",void 0),tX([tq],e.Renderer.prototype,"_materialsInstanced",void 0),tX([tQ],e.Renderer.prototype,"_priority",void 0),tX([tQ],e.Renderer.prototype,"_receiveShadows",void 0),tX([tq],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=tX([rh(rp,r_.CheckOnly)],e.Renderer);var rv=((G={})[G.WorldVolume=1]="WorldVolume",G);function ry(){return function(e){}}var rx=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var a=n.allocateSubChunk(4);a.indices=e._rectangleTriangles,t._subChunk=a},e.updatePositions=function(t){var n=t.width,r=t.height,a=t.sprite,i=a.pivot,o=i.x,s=i.y,l=e._worldMatrix,c=l.elements,u=t.entity.transform.worldMatrix.elements,d=t.flipX?-n:n,h=t.flipY?-r:r;c[0]=u[0]*d,c[1]=u[1]*d,c[2]=u[2]*d,c[4]=u[4]*h,c[5]=u[5]*h,c[6]=u[6]*h,c[8]=u[8],c[9]=u[9],c[10]=u[10],c[12]=u[12]-o*c[0]-s*c[4],c[13]=u[13]-o*c[1]-s*c[5],c[14]=u[14]-o*c[2]-s*c[6];for(var _=a._getPositions(),f=t._subChunk,p=f.chunk.vertices,m=0,g=f.vertexArea.start;m<4;++m,g+=9){var v=_[m],y=v.x,x=v.y;p[g]=c[0]*y+c[4]*x+c[12],p[g+1]=c[1]*y+c[5]*x+c[13],p[g+2]=c[2]*y+c[6]*x+c[14]}tE.transform(a._getBounds(),l,t._bounds)},e.updateUVs=function(e){var t=e.sprite._getUVs(),n=t[0],r=n.x,a=n.y,i=t[3],o=i.x,s=i.y,l=e._subChunk,c=l.chunk.vertices,u=l.vertexArea.start+3;c[u]=r,c[u+1]=a,c[u+9]=o,c[u+10]=a,c[u+18]=r,c[u+19]=s,c[u+27]=o,c[u+28]=s},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<4;++l,c+=9)s[c]=r,s[c+1]=a,s[c+2]=i,s[c+3]=o},e}();rx._rectangleTriangles=[0,1,2,2,1,3],rx._worldMatrix=new tL,rx=tX([ry()],rx);var rb=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var a=n.allocateSubChunk(16);a.indices=e._rectangleTriangles,t._subChunk=a},e.updatePositions=function(t){var n,r,a=t.width,i=t.height,o=t.sprite,s=o.border,l=o._getPositions(),c=l[0],u=c.x,d=c.y,h=l[3],_=h.x,f=h.y,p=o.width,m=o.height,g=p*s.x,v=m*s.y,y=p*s.z,x=m*s.w;if(g+y>a){var b=a/(g+y);n=[p*u*b,g*b,g*b,a-p*(1-_)*b]}else n=[p*u,g,a-y,a-p*(1-_)];if(x+v>i){var S=i/(x+v);r=[m*d*S,v*S,v*S,i-m*(1-f)*S]}else r=[m*d,v,i-x,i-m*(1-f)];var C=t.sprite.pivot,T=C.x,A=C.y,E=t.width*T,R=t.height*A,M=e._worldMatrix,w=M.elements,P=t.entity.transform.worldMatrix.elements,F=t.flipX?-1:1,L=t.flipY?-1:1;w[0]=P[0]*F,w[1]=P[1]*F,w[2]=P[2]*F,w[4]=P[4]*L,w[5]=P[5]*L,w[6]=P[6]*L,w[8]=P[8],w[9]=P[9],w[10]=P[10],w[12]=P[12]-E*w[0]-R*w[4],w[13]=P[13]-E*w[1]-R*w[5],w[14]=P[14]-E*w[2]-R*w[6];for(var D=t._subChunk,B=D.chunk.vertices,I=0,O=D.vertexArea.start;I<4;I++)for(var V=n[I],N=0;N<4;N++,O+=9){var k=r[N];B[O]=w[0]*V+w[4]*k+w[12],B[O+1]=w[1]*V+w[5]*k+w[13],B[O+2]=w[2]*V+w[6]*k+w[14]}var z=t._bounds,U=z.min,G=z.max;U.set(n[0],r[0],0),G.set(n[3],r[3],0),t._bounds.transform(M)},e.updateUVs=function(e){for(var t=e._subChunk,n=t.chunk.vertices,r=e.sprite._getUVs(),a=0,i=t.vertexArea.start+3;a<4;a++)for(var o=r[a].x,s=0;s<4;s++,i+=9)n[i]=o,n[i+1]=r[s].y},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<16;++l,c+=9)s[c]=r,s[c+1]=a,s[c+2]=i,s[c+3]=o},e}();rb._rectangleTriangles=[0,1,4,1,5,4,1,2,5,2,6,5,2,3,6,3,7,6,4,5,8,5,9,8,5,6,9,6,10,9,6,7,10,7,11,10,8,9,12,9,13,12,9,10,13,10,14,13,10,11,14,11,15,14],rb._worldMatrix=new tL,rb=tX([ry()],rb);var rS=/*#__PURE__*/function(){function e(e){void 0===e&&(e=0),this.length=0,this._loopCounter=0,this._blankCount=0,this._elements=Array(e)}var t=e.prototype;return t.add=function(e){this.length===this._elements.length?this._elements.push(e):this._elements[this.length]=e,this.length++},t.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},t.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},t.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},t.deleteByIndex=function(e){var t,n=this._elements;if(this._loopCounter>0)this._elements[e]=null,this._blankCount++;else{var r=this.length-1;e!==r&&(t=n[r],n[e]=t),n[r]=null,this.length--}return t},t.forEach=function(e,t){this._startLoop();for(var n=this._elements,r=0,a=this.length;r<a;r++){var i=n[r];i&&e(i,r)}this._endLoop(t)},t.forEachAndClean=function(e,t){this._startLoop();for(var n=this.length,r=this._elements,a=0;a<n;a++){var i=r[a];i&&e(i,a)}this._endLoopAndClean(n,r,t)},t.sort=function(e){nT._quickSort(this._elements,0,this.length,e)},t.garbageCollection=function(){this._elements.length=this.length},t._startLoop=function(){++this._loopCounter},t._endLoop=function(e){if(0==--this._loopCounter&&this._blankCount){var t=0,n=this.length-1,r=this._elements;e:do{for(;r[t];)if(++t>=n)break e;for(;!r[n];)if(t>=--n)break e;var a=r[n];null==e||e(a,t),r[t++]=a,r[n--]=null}while(t<n);this.length-=this._blankCount,this._blankCount=0}},t._endLoopAndClean=function(e,t,n){if(0==--this._loopCounter){for(var r=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[r]=o,null==n||n(o,r),r++)}this.length=r,this._blankCount=0}},tG(e,[{key:"isLopping",get:function(){return this._loopCounter>0}}]),e}(),rC=/*#__PURE__*/function(){function e(){}return e.resetData=function(e,t){if(t){var n=e._getChunkManager(),r=e._subChunk,a=r&&r.vertexArea.size!==9*t;if(a&&n.freeSubChunk(r),!r||a){var i=n.allocateSubChunk(t);i.indices=[],e._subChunk=i}}},e.updatePositions=function(t){var n,r,a,i,o,s,l=t.width,c=t.height,u=t.sprite,d=t.tileMode,h=t.tiledAdaptiveThreshold,_=e._posRow,f=e._posColumn,p=e._uvRow,m=e._uvColumn,g=t._getChunkManager().maxVertexCount;_.length=f.length=p.length=m.length=0;var v=d===nC.Adaptive?e._calculateAdaptiveDividing(u,l,c,h,_,f,p,m,g):e._calculateContinuousDividing(u,l,c,_,f,p,m,g);e.resetData(t,v);var y=t.sprite.pivot,x=y.x,b=y.y,S=t.width*x,C=t.height*b,T=e._worldMatrix,A=T.elements,E=t.entity.transform.worldMatrix.elements,R=t.flipX?-1:1,M=t.flipY?-1:1;n=A[0]=E[0]*R,r=A[1]=E[1]*R,a=A[2]=E[2]*R,i=A[4]=E[4]*M,o=A[5]=E[5]*M,s=A[6]=E[6]*M,A[8]=E[8],A[9]=E[9],A[10]=E[10];for(var w=A[12]=E[12]-S*A[0]-C*A[4],P=A[13]=E[13]-S*A[1]-C*A[5],F=A[14]=E[14]-S*A[2]-C*A[6],L=_.length-1,D=f.length-1,B=t._subChunk,I=B.chunk.vertices,O=B.indices,V=0,N=0,k=0,z=B.vertexArea.start;k<D;k++)for(var U=2*k,G=0;G<L;G++){var H=p.get(2*G),W=p.get(2*G+1),j=m.get(U+1);if(!(isNaN(H)||isNaN(W)||isNaN(j))){O[N++]=V,O[N++]=V+1,O[N++]=V+2,O[N++]=V+2,O[N++]=V+1,O[N++]=V+3,V+=4;var X=_.get(G),K=f.get(k),Y=_.get(G+1),q=f.get(k+1);I[z]=n*X+i*K+w,I[z+1]=r*X+o*K+P,I[z+2]=a*X+s*K+F,I[z+9]=n*Y+i*K+w,I[z+10]=r*Y+o*K+P,I[z+11]=a*Y+s*K+F,I[z+18]=n*X+i*q+w,I[z+19]=r*X+o*q+P,I[z+20]=a*X+s*q+F,I[z+27]=n*Y+i*q+w,I[z+28]=r*Y+o*q+P,I[z+29]=a*Y+s*q+F,z+=36}}var Q=t._bounds,Z=Q.min,J=Q.max;Z.set(_.get(0),f.get(0),0),J.set(_.get(L),f.get(D),0),t._bounds.transform(T)},e.updateUVs=function(t){for(var n=e._posRow,r=e._posColumn,a=e._uvRow,i=e._uvColumn,o=n.length-1,s=r.length-1,l=t._subChunk,c=l.chunk.vertices,u=0,d=l.vertexArea.start+3;u<s;u++)for(var h=2*u,_=0;_<o;_++){var f=a.get(2*_),p=i.get(h),m=a.get(2*_+1),g=i.get(h+1);isNaN(f)||isNaN(p)||isNaN(m)||isNaN(g)||(c[d]=f,c[d+1]=p,c[d+9]=m,c[d+10]=p,c[d+18]=f,c[d+19]=g,c[d+27]=m,c[d+28]=g,d+=36)}},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=t.vertexArea,c=0,u=l.start+5,d=l.size/9;c<d;++c,u+=9)s[u]=r,s[u+1]=a,s[u+2]=i,s[u+3]=o},e._calculateAdaptiveDividing=function(e,t,n,r,a,i,o,s,l){var c,u,d,h,_,f,p,m=e.border,g=e._getPositions(),v=g[0],y=v.x,x=v.y,b=g[3],S=b.x,C=b.y,T=e._getUVs(),A=T[0],E=T[1],R=T[2],M=T[3],w=e.width,P=e.height,F=w*m.x,L=w*m.z,D=F+L,B=w-D,I=P*m.w,O=P*m.y,V=I+O,N=P-V;D>=t?(h=3,u=0):B>tC.zeroTolerance?(h=4+(f=(f=(t-D)/B)%1>=r?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),V>=n?(_=3,d=0):N>tC.zeroTolerance?(_=4+(p=(p=(n-V)/N)%1>=r?Math.ceil(p):Math.floor(p))-1,d=2):(_=4,d=1);var k=0,z=0;if((h-1)*(_-1)*4>l)return a.add(t*y),a.add(t*S),i.add(n*x),i.add(n*C),o.add(A.x),o.add(M.x),s.add(A.y),s.add(M.y),k+=2,z+=2,no.warn("The number of vertices exceeds the upper limit("+l+")."),k*z;switch(u){case 0:c=t/D,a.add(w*y*c),a.add(F*c),a.add(t-w*(1-S)*c),o.add(A.x),o.add(E.x),o.add(R.x),o.add(M.x),k+=4;break;case 1:a.add(w*y),a.add(F),a.add(t-L),a.add(t-w*(1-S)),o.add(A.x),o.add(E.x),o.add(NaN),o.add(NaN),o.add(R.x),o.add(M.x),k+=4;break;case 2:c=t/(D+f*B),a.add(w*y*c),a.add(F*c),o.add(A.x),o.add(E.x),o.add(E.x),k+=3;for(var U=0,G=f-1;U<G;U++)a.add(F+(U+1)*B*c),o.add(R.x),o.add(E.x),k+=2;a.add(t-L*c),a.add(t-w*(1-S)*c),o.add(R.x),o.add(R.x),o.add(M.x),k+=3}switch(d){case 0:c=n/V,i.add(P*x*c),i.add(O*c),i.add(n-P*(1-C)*c),s.add(A.y),s.add(E.y),s.add(R.y),s.add(M.y),z+=4;break;case 1:i.add(P*x),i.add(O),i.add(n-I),i.add(n-P*(1-C)),s.add(A.y),s.add(E.y),s.add(NaN),s.add(NaN),s.add(R.y),s.add(M.y),z+=4;break;case 2:c=n/(V+p*N),i.add(P*x*c),i.add(O*c),s.add(A.y),s.add(E.y),s.add(E.y),z+=3;for(var H=0,W=p-1;H<W;H++)i.add(O+(H+1)*N*c),s.add(R.y),s.add(E.y),z+=2;i.add(n-I*c),i.add(n-P*(1-C)*c),s.add(R.y),s.add(R.y),s.add(M.y),z+=3}return k*z},e._calculateContinuousDividing=function(e,t,n,r,a,i,o,s){var l,c,u,d,h,_,f=e.border,p=e._getPositions(),m=p[0],g=m.x,v=m.y,y=p[3],x=y.x,b=y.y,S=e._getUVs(),C=S[0],T=S[1],A=S[2],E=S[3],R=e.width,M=e.height,w=R*f.x,P=R*f.z,F=w+P,L=R-F,D=M*f.w,B=M*f.y,I=D+B,O=M-I;F>=t?(u=3,l=0):L>tC.zeroTolerance?(u=4+(0|(h=(t-F)/L)),l=2):(u=4,l=1),I>=n?(d=3,c=0):O>tC.zeroTolerance?(d=4+(0|(_=(n-I)/O)),c=2):(d=4,c=1);var V=0,N=0;if((u-1)*(d-1)*4>s)return r.add(t*g),r.add(t*x),a.add(n*v),a.add(n*b),i.add(C.x),i.add(E.x),o.add(C.y),o.add(E.y),V+=2,N+=2,no.warn("The number of vertices exceeds the upper limit("+s+")."),V*N;switch(l){case 0:var k=t/F;r.add(R*g*k),r.add(w*k),r.add(t-R*(1-x)*k),i.add(C.x),i.add(T.x),i.add(A.x),i.add(E.x),V+=4;break;case 1:r.add(R*g),r.add(w),r.add(t-P),r.add(t-R*(1-x)),i.add(C.x),i.add(T.x),i.add(NaN),i.add(NaN),i.add(A.x),i.add(E.x),V+=4;break;case 2:r.add(R*g),r.add(w),i.add(C.x),i.add(T.x),i.add(T.x),V+=3;for(var z=0|h,U=0;U<z;U++)r.add(w+(U+1)*L),i.add(A.x),i.add(T.x),V+=2;r.add(t-P),r.add(t-R*(1-x)),i.add((A.x-T.x)*(h-z)+T.x),i.add(A.x),i.add(E.x),V+=3}switch(c){case 0:var G=n/I;a.add(M*v*G),a.add(B*G),a.add(n-M*(1-b)*G),o.add(C.y),o.add(T.y),o.add(A.y),o.add(E.y),N+=4;break;case 1:a.add(M*v),a.add(B),a.add(n-D),a.add(n-M*(1-b)),o.add(C.y),o.add(T.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(E.y),N+=4;break;case 2:a.add(M*v),a.add(B),o.add(C.y),o.add(T.y),o.add(T.y),N+=3;for(var H=0|_,W=0;W<H;W++)a.add(B+(W+1)*O),o.add(A.y),o.add(T.y),N+=2;a.add(n-D),a.add(n-M*(1-b)),o.add((A.y-T.y)*(_-H)+T.y),o.add(A.y),o.add(E.y),N+=3}return V*N},e}();rC._worldMatrix=new tL,rC._posRow=new rS,rC._posColumn=new rS,rC._uvRow=new rS,rC._uvColumn=new rS,rC=tX([ry()],rC);var rT=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._tileMode=nC.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new tO(1,1,1,1),n._sprite=null,n._automaticWidth=0,n._automaticHeight=0,n._customWidth=void 0,n._customHeight=void 0,n._flipX=!1,n._flipY=!1,n.drawMode=nS.Simple,n._dirtyUpdateFlag|=4,n.setMaterial(n._engine._basicResources.spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(n),n._color._onValueChanged=n._onColorChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t._assembler.resetData(t),t.sprite=this._sprite,t.drawMode=this._drawMode},n._canBatch=function(e,t){return rl.canBatchSprite(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},n._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,n=this.getMaterial();if(n){n.destroyed&&(n=this._engine._basicResources.spriteDefaultMaterial),this._dirtyUpdateFlag&rv.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~rv.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3),4&this._dirtyUpdateFlag&&(this._assembler.updateColor(this),this._dirtyUpdateFlag&=-5);var r=e.camera,a=r.engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get(),s=this._subChunk;o.set(this,n,s.chunk.primitive,s.subMesh,this.sprite.texture,s),i.addSubRenderElement(o),r._renderPipeline.pushRenderElement(e,i)}}},n._onDestroy=function(){var t=this._sprite;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),e.prototype._onDestroy.call(this),this._sprite=null,this._assembler=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null)},n._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-9},n._onSpriteChange=function(e){switch(e){case nw.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nw.size:var n=this._drawMode;this._dirtyUpdateFlag|=8,this._drawMode===nS.Sliced?this._dirtyUpdateFlag|=rv.WorldVolume:n===nS.Tiled?this._dirtyUpdateFlag|=rA.WorldVolumeAndUV:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rv.WorldVolume);break;case nw.border:this._drawMode===nS.Sliced&&(this._dirtyUpdateFlag|=rA.WorldVolumeAndUV);break;case nw.region:case nw.atlasRegionOffset:this._dirtyUpdateFlag|=rA.WorldVolumeAndUV;break;case nw.atlasRegion:this._dirtyUpdateFlag|=2;break;case nw.pivot:this._dirtyUpdateFlag|=rv.WorldVolume;break;case nw.destroy:this.sprite=null}},n._onColorChanged=function(){this._dirtyUpdateFlag|=4},tG(t,[{key:"drawMode",get:function(){return this._drawMode},set:function(e){if(this._drawMode!==e){switch(this._drawMode=e,e){case nS.Simple:this._assembler=rx;break;case nS.Sliced:this._assembler=rb;break;case nS.Tiled:this._assembler=rC}this._assembler.resetData(this),this._dirtyUpdateFlag|=rA.VertexData}}},{key:"tileMode",get:function(){return this._tileMode},set:function(e){this._tileMode!==e&&(this._tileMode=e,this.drawMode===nS.Tiled&&(this._dirtyUpdateFlag|=rA.VertexData))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(e){e!==this._tiledAdaptiveThreshold&&(e=tC.clamp(e,0,1),this._tiledAdaptiveThreshold=e,this.drawMode===nS.Tiled&&(this._dirtyUpdateFlag|=rA.VertexData))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var n=this._sprite;n!==e&&(n&&(this._addResourceReferCount(n,-1),n._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=15,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(t._textureProperty,e.texture)):this.shaderData.setTexture(t._textureProperty,null),this._sprite=e)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=this._drawMode===nS.Tiled?rA.VertexData:rv.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=this._drawMode===nS.Tiled?rA.VertexData:rv.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e)}}]),t}(e.Renderer);rT._textureProperty=nY.getByName("renderer_SpriteTexture"),tX([tq],rT.prototype,"_subChunk",void 0),tX([tq],rT.prototype,"_drawMode",void 0),tX([tQ],rT.prototype,"_assembler",void 0),tX([tQ],rT.prototype,"_tileMode",void 0),tX([tQ],rT.prototype,"_tiledAdaptiveThreshold",void 0),tX([tJ],rT.prototype,"_color",void 0),tX([tq],rT.prototype,"_sprite",void 0),tX([tq],rT.prototype,"_automaticWidth",void 0),tX([tq],rT.prototype,"_automaticHeight",void 0),tX([tQ],rT.prototype,"_customWidth",void 0),tX([tQ],rT.prototype,"_customHeight",void 0),tX([tQ],rT.prototype,"_flipX",void 0),tX([tQ],rT.prototype,"_flipY",void 0),tX([tq],rT.prototype,"_onSpriteChange",null),tX([tq],rT.prototype,"_onColorChanged",null);var rA=((H=rA||{})[H.UV=2]="UV",H[H.Color=4]="Color",H[H.AutomaticSize=8]="AutomaticSize",H[H.WorldVolumeAndUV=2|rv.WorldVolume]="WorldVolumeAndUV",H[H.VertexData=4|H.WorldVolumeAndUV]="VertexData",H[H.All=15]="All",H),rE=((W={})[W.Layer0=1]="Layer0",W[W.Layer1=2]="Layer1",W[W.Layer2=4]="Layer2",W[W.Layer3=8]="Layer3",W[W.Layer4=16]="Layer4",W[W.Layer5=32]="Layer5",W[W.Layer6=64]="Layer6",W[W.Layer7=128]="Layer7",W[W.Layer8=256]="Layer8",W[W.Layer9=512]="Layer9",W[W.Layer10=1024]="Layer10",W[W.Layer11=2048]="Layer11",W[W.Layer12=4096]="Layer12",W[W.Layer13=8192]="Layer13",W[W.Layer14=16384]="Layer14",W[W.Layer15=32768]="Layer15",W[W.Layer16=65536]="Layer16",W[W.Layer17=131072]="Layer17",W[W.Layer18=262144]="Layer18",W[W.Layer19=524288]="Layer19",W[W.Layer20=1048576]="Layer20",W[W.Layer21=2097152]="Layer21",W[W.Layer22=4194304]="Layer22",W[W.Layer23=8388608]="Layer23",W[W.Layer24=0x1000000]="Layer24",W[W.Layer25=0x2000000]="Layer25",W[W.Layer26=0x4000000]="Layer26",W[W.Layer27=0x8000000]="Layer27",W[W.Layer28=0x10000000]="Layer28",W[W.Layer29=0x20000000]="Layer29",W[W.Layer30=0x40000000]="Layer30",W[W.Layer31=0x80000000]="Layer31",W[W.Everything=0xffffffff]="Everything",W[W.Nothing=0]="Nothing",W),rR=/*#__PURE__*/function(){function e(){}return e.recreateTextureIfNeeded=function(e,t,n,r,a,i,o,s){return t?(t.width!==n||t.height!==r||t.format!==a||t.mipmapCount>1!==i)&&(t.destroy(!0),(t=new nc(e,n,r,a,i)).isGCIgnored=!0):(t=new nc(e,n,r,a,i)).isGCIgnored=!0,t.wrapModeU=t.wrapModeV=o,t.filterMode=s,t},e.recreateRenderTargetIfNeeded=function(t,n,r,a,i,o,s,l,c,u,d){var h=null==n?void 0:n.getColorTexture(0),_=i?e.recreateTextureIfNeeded(t,h,r,a,i,l,u,d):null;if(s){var f=null==n?void 0:n.depthTexture,p=o?e.recreateTextureIfNeeded(t,f,r,a,o,l,u,d):null;(h!==_||f!==p)&&(null==n||n.destroy(!0),(n=new nl(t,r,a,_,p,c)).isGCIgnored=!0)}else(h!==_||(null==n?void 0:n._depthFormat)!==o||n.antiAliasing!==c)&&(null==n||n.destroy(!0),(n=new nl(t,r,a,_,o,c)).isGCIgnored=!0);return n},e.blitTexture=function(t,n,r,a,i,o,s){void 0===a&&(a=0),void 0===i&&(i=e.defaultViewport),void 0===o&&(o=null),void 0===s&&(s=0);var l=t._basicResources,c=r?l.flipYBlitMesh:l.blitMesh,u=o||l.blitMaterial,d=t._hardwareRenderer,h=t._renderContext;h.flipProjection=!!r,d.activeRenderTarget(r,i,h.flipProjection,0);var _=e._rendererShaderData;_.setTexture(e._blitTextureProperty,n),_.setFloat(e._blitMipLevelProperty,a),e._texelSize.set(1/n.width,1/n.height,n.width,n.height),_.setVector4(e._blitTexelSizeProperty,e._texelSize);var f=u.shader.subShaders[0].passes[s],p=ro._compileMacros;nW.unionCollection(h.camera._globalShaderMacro,u.shaderData._macroCollection,p);var m=f._getShaderProgram(t,p);m.bind(),m.groupingOtherUniformBlock(),m.uploadAll(m.rendererUniformBlock,_),m.uploadAll(m.materialUniformBlock,u.shaderData),m.uploadUnGroupTextures(),(f._renderState||u.renderState)._applyStates(t,!1,f._renderStateDataMap,u.shaderData),d.drawPrimitive(c._primitive,c.subMesh,m)},e}();rR._blitTextureProperty=nY.getByName("renderer_BlitTexture"),rR._blitMipLevelProperty=nY.getByName("renderer_BlitMipLevel"),rR._blitTexelSizeProperty=nY.getByName("renderer_texelSize"),rR._rendererShaderData=new rs(n8.Renderer),rR._texelSize=new tI,rR.defaultViewport=new tI(0,0,1,1);var rM=function(){this.position=new tT,this.isOrthographic=!1,this.viewMatrix=new tL,this.projectionMatrix=new tL,this.viewProjectionMatrix=new tL,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new tT},rw=((j={})[j.None=0]="None",j[j.Color=1]="Color",j[j.Depth=2]="Depth",j[j.Stencil=4]="Stencil",j[j.ColorDepth=3]="ColorDepth",j[j.ColorStencil=5]="ColorStencil",j[j.DepthStencil=6]="DepthStencil",j[j.All=7]="All",j),rP=((X={})[X.Normal=0]="Normal",X[X.XRCenterCamera=1]="XRCenterCamera",X[X.XRLeftCamera=2]="XRLeftCamera",X[X.XRRightCamera=4]="XRRightCamera",X),rF=((K={})[K.None=0]="None",K[K.PrePass=1]="PrePass",K),rL=((Y={})[Y.None=1]="None",Y[Y.TwoX=2]="TwoX",Y[Y.FourX=4]="FourX",Y),rD=((q={})[q.None=1]="None",q[q.TwoX=2]="TwoX",q[q.FourX=4]="FourX",q[q.EightX=8]="EightX",q),rB=((Q={})[Q.KeepOriginalShader=0]="KeepOriginalShader",Q[Q.DoNotRender=1]="DoNotRender",Q),rI=function(){};rI.tempVec4=new tI,rI.tempVec3=new tT,rI.tempVec2=new tB,e.Camera=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this).enableFrustumCulling=!0,n.clearFlags=rw.All,n.cullingMask=rE.Everything,n.depthTextureMode=rF.None,n.opaqueTextureDownsampling=rL.TwoX,n.msaaSamples=rD.None,n._cameraType=rP.Normal,n._globalShaderMacro=new nW,n._frustum=new tw,n._virtualCamera=new rM,n._replacementShader=null,n._replacementSubShaderTag=null,n._replacementFailureStrategy=null,n._cameraIndex=-1,n._priority=0,n._shaderData=new rs(n8.Camera),n._isCustomViewMatrix=!1,n._isCustomProjectionMatrix=!1,n._fieldOfView=45,n._orthographicSize=10,n._isProjectionDirty=!0,n._isInvProjMatDirty=!0,n._customAspectRatio=void 0,n._renderTarget=null,n._depthBufferParams=new tI,n._opaqueTextureEnabled=!1,n._enableHDR=!1,n._enablePostProcess=!1,n._viewport=new tI(0,0,1,1),n._pixelViewport=new tV(0,0,0,0),n._inverseProjectionMatrix=new tL,n._invViewProjMat=new tL;var n,r=n.entity.transform;return n._transform=r,n._isViewMatrixDirty=r.registerWorldChangeFlag(),n._isInvViewProjDirty=r.registerWorldChangeFlag(),n._frustumChangeFlag=r.registerWorldChangeFlag(),n._renderPipeline=new rJ(n),n._addResourceReferCount(n.shaderData,1),n._updatePixelViewport(),n._onPixelViewportChanged=n._onPixelViewportChanged.bind(n),n._viewport._onValueChanged=n._onPixelViewportChanged,n.engine.canvas._sizeUpdateFlagManager.addListener(n._onPixelViewportChanged),n}tW(t,e);var n=t.prototype;return n.resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},n.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},n.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},n.worldToViewportPoint=function(e,t){var n=rI.tempVec3,r=rI.tempVec4;tT.transformCoordinate(e,this.viewMatrix,n),tT.transformToVec4(n,this.projectionMatrix,r);var a=r.w;return t.set((r.x/a+1)*.5,(1-r.y/a)*.5,-n.z),t},n.viewportToWorldPoint=function(e,t){var n,r=this.nearClipPlane,a=this.farClipPlane,i=1/(r-a);if(this.isOrthographic)n=-(2*e.z)*i+(a+r)*i;else{var o=e.z;n=(-o*(r+a)*i+2*r*a*i)/o}return this._innerViewportToWorldPoint(e.x,e.y,(n+1)/2,this._getInvViewProjMat(),t),t},n.viewportPointToRay=function(e,t){var n=this._getInvViewProjMat(),r=this._innerViewportToWorldPoint(e.x,e.y,0,n,t.origin),a=this._innerViewportToWorldPoint(e.x,e.y,1-tC.zeroTolerance,n,t.direction);return tT.subtract(a,r,a),a.normalize(),t},n.screenToViewportPoint=function(e,t){var n=this.engine.canvas,r=this.viewport;return t.x=(e.x/n.width-r.x)/r.z,t.y=(e.y/n.height-r.y)/r.w,void 0!==e.z&&(t.z=e.z),t},n.viewportToScreenPoint=function(e,t){var n=this.engine.canvas,r=this.viewport;return t.x=(r.x+e.x*r.z)*n.width,t.y=(r.y+e.y*r.w)*n.height,void 0!==e.z&&(t.z=e.z),t},n.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},n.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},n.screenPointToRay=function(e,t){var n=rI.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},n.render=function(e,t){void 0===t&&(t=0);var n,r=this._engine,a=r._renderContext,i=this._virtualCamera,o=this.entity.transform;tL.multiply(this.projectionMatrix,this.viewMatrix,i.viewProjectionMatrix),i.position.copyFrom(o.worldPosition),i.isOrthographic&&i.forward.copyFrom(o.worldForward),a.camera=this,a.virtualCamera=i,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,a.replacementFailureStrategy=this._replacementFailureStrategy,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(i.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),nW.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!r._hardwareRenderer.isWebGL2&&(t=0,no.error("mipLevel only take effect in WebGL2.0")),this._cameraType===rP.Normal||this._renderTarget||this.independentCanvasEnabled||(n=r.xrManager._getCameraIgnoreClearFlags(this._cameraType)),this._renderPipeline.render(a,e,t,n),r._renderCount++},n.setReplacementShader=function(e,t,n){void 0===n&&(n=rB.KeepOriginalShader),this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?n0.getByName(t):t,this._replacementFailureStrategy=n},n.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null,this._replacementFailureStrategy=null},n._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},n._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},n._getInternalColorTextureFormat=function(){return this._enableHDR?this.engine._hardwareRenderer.isWebGL2?t9.R11G11B10_UFloat:t9.R16G16B16A16:t9.R8G8B8A8},n._onDestroy=function(){var t;e.prototype._onDestroy.call(this),null==(t=this._renderPipeline)||t.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},n._updatePixelViewport=function(){var e,t,n=this._renderTarget;if(n)e=n.width,t=n.height;else{var r=this.engine.canvas;e=r.width,t=r.height}var a=this._viewport;this._pixelViewport.set(a.x*e,a.y*t,a.z*e,a.w*t)},n._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},n._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},n._innerViewportToWorldPoint=function(e,t,n,r,a){var i=rI.tempVec3;return i.set(2*e-1,1-2*t,2*n-1),tT.transformCoordinate(i,r,a),a},n._updateShaderData=function(){var e=this.shaderData,n=this._transform;e.setMatrix(t._inverseViewMatrixProperty,n.worldMatrix),e.setVector3(t._cameraPositionProperty,n.worldPosition),e.setVector3(t._cameraForwardProperty,n.worldForward),e.setVector3(t._cameraUpProperty,n.worldUp);var r=this._depthBufferParams,a=this.farClipPlane/this.nearClipPlane;r.set(1-a,a,0,0),e.setVector4(t._cameraDepthBufferParamsProperty,r)},n._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,tL.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},n._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,tL.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},n._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},n._checkMainCanvasAntialiasWaste=function(){this._phasedActiveInScene&&this.independentCanvasEnabled&&tI.equals(this._viewport,rR.defaultViewport)&&no.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},tG(t,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){return!!this.enableHDR||!!this.enablePostProcess&&!!this.scene._postProcessManager.hasActiveEffect||this.opaqueTextureEnabled&&!this._renderTarget}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e,t=this.pixelViewport;return null!=(e=this._customAspectRatio)?e:t.width/t.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var t=this._transform;return tL.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return t;this._isProjectionDirty=!1;var n=this.aspectRatio;if(e.isOrthographic){var r=this._orthographicSize*n,a=this._orthographicSize;tL.ortho(-r,r,-a,a,this.nearClipPlane,this.farClipPlane,t)}else tL.perspective(tC.degreeToRadian(this._fieldOfView),n,this.nearClipPlane,this.farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return this._enableHDR},set:function(e){if(this.enableHDR!==e){var t=this.engine._hardwareRenderer,n=t.isWebGL2||t.canIUse(nZ.textureHalfFloat);if(e&&!n){no.warn("Can't enable HDR in this device.");return}this._enableHDR=e,this._checkMainCanvasAntialiasWaste()}}},{key:"enablePostProcess",get:function(){return this._enablePostProcess},set:function(e){this._enablePostProcess!==e&&(this._enablePostProcess=e,this._checkMainCanvasAntialiasWaste())}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged())}}]),t}(ru),e.Camera._cameraDepthTextureProperty=nY.getByName("camera_DepthTexture"),e.Camera._cameraOpaqueTextureProperty=nY.getByName("camera_OpaqueTexture"),e.Camera._inverseViewMatrixProperty=nY.getByName("camera_ViewInvMat"),e.Camera._cameraPositionProperty=nY.getByName("camera_Position"),e.Camera._cameraForwardProperty=nY.getByName("camera_Forward"),e.Camera._cameraUpProperty=nY.getByName("camera_Up"),e.Camera._cameraDepthBufferParamsProperty=nY.getByName("camera_DepthBufferParams"),tX([tJ],e.Camera.prototype,"_frustum",void 0),tX([tq],e.Camera.prototype,"_renderPipeline",void 0),tX([tq],e.Camera.prototype,"_virtualCamera",void 0),tX([tq],e.Camera.prototype,"_cameraIndex",void 0),tX([tq],e.Camera.prototype,"_frustumChangeFlag",void 0),tX([tq],e.Camera.prototype,"_transform",void 0),tX([tq],e.Camera.prototype,"_isViewMatrixDirty",void 0),tX([tq],e.Camera.prototype,"_isInvViewProjDirty",void 0),tX([tJ],e.Camera.prototype,"_viewport",void 0),tX([tJ],e.Camera.prototype,"_pixelViewport",void 0),tX([tJ],e.Camera.prototype,"_inverseProjectionMatrix",void 0),tX([tJ],e.Camera.prototype,"_invViewProjMat",void 0),tX([tq],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=tX([rh(rp,r_.CheckOnly)],e.Camera);var rO=((Z={})[Z.SolidColor=0]="SolidColor",Z[Z.Sky=1]="Sky",Z[Z.Texture=2]="Texture",Z),rV=((J={})[J.AspectFitWidth=0]="AspectFitWidth",J[J.AspectFitHeight=1]="AspectFitHeight",J[J.Fill=2]="Fill",J),rN=function(e){this.engine=e},rk=/*#__PURE__*/function(){function e(){this._projectionParams=new tI,this.flipProjection=!1,this.rendererUpdateFlag=0}var t=e.prototype;return t.applyVirtualCamera=function(t,n){this.virtualCamera=t,this.flipProjection=n;var r=this.camera.shaderData,a=t.viewMatrix,i=t.projectionMatrix,o=t.viewProjectionMatrix;n&&(tL.multiply(e._flipYMatrix,i,e._flipYProjectionMatrix),tL.multiply(e._flipYProjectionMatrix,a,e._flipYViewProjectionMatrix),i=e._flipYProjectionMatrix,o=e._flipYViewProjectionMatrix),this.viewMatrix=a,this.projectionMatrix=i,this.viewProjectionMatrix=o,r.setMatrix(e._viewMatrixProperty,a),r.setMatrix(e._projectionMatrixProperty,i),r.setMatrix(e.vpMatrixProperty,o);var s=this._projectionParams;s.set(n?-1:1,t.nearClipPlane,t.farClipPlane,0),r.setVector4(e._cameraProjectionProperty,s)},t.garbageCollection=function(){this.camera=null},e}();rk.vpMatrixProperty=nY.getByName("camera_VPMat"),rk.pipelineStageKey=n0.getByName("pipelineStage"),rk._flipYMatrix=new tL(1,0,0,0,0,-1),rk._cameraProjectionProperty=nY.getByName("camera_ProjectionParams"),rk._viewMatrixProperty=nY.getByName("camera_ViewMat"),rk._projectionMatrixProperty=nY.getByName("camera_ProjMat"),rk._flipYProjectionMatrix=new tL,rk._flipYViewProjectionMatrix=new tL;var rz=(($={})[$.None=0]="None",$[$.WorldMatrix=1]="WorldMatrix",$[$.viewMatrix=2]="viewMatrix",$[$.ProjectionMatrix=4]="ProjectionMatrix",$[$.WorldViewMatrix=3]="WorldViewMatrix",$[$.viewProjectionMatrix=6]="viewProjectionMatrix",$[$.All=7]="All",$),rU=((ee={})[ee.No=0]="No",ee[ee.Increment=1]="Increment",ee[ee.Decrement=2]="Decrement",ee),rG=/*#__PURE__*/function(){function e(e){this.renderQueueType=e,this.elements=[],this.batchedSubElements=[]}var t=e.prototype;return t.pushRenderElement=function(e){this.elements.push(e)},t.sortBatch=function(e,t){nT._quickSort(this.elements,0,this.elements.length,e),this.batch(t)},t.batch=function(e){e.batch(this)},t.render=function(e,t,n){void 0===n&&(n=rU.No);var r=this.batchedSubElements,a=r.length;if(0!==a)for(var i=e.rendererUpdateFlag,o=e.camera,s=o.engine,l=o.scene,c=o.instanceId,u=o.shaderData,d=l.instanceId,h=l.shaderData,_=l._maskManager,f=s._renderCount,p=s._hardwareRenderer,m=rk.pipelineStageKey,g=this.renderQueueType,v=0;v<a;v++){var y=r[v],x=y.component,b=y.batched,S=y.material;i&rz.WorldViewMatrix||x._batchedTransformShaderData!=b?(x._updateTransformShaderData(e,!1,b),x._batchedTransformShaderData=b):i&rz.ProjectionMatrix&&x._updateTransformShaderData(e,!0,b);var C=x._maskInteraction,T=C!==nv.None,A=n!==rU.No,E=null;A?E=aY.getMaskTypeRenderStates(n):(T?(_.drawMask(e,t,y.component._maskLayer),E=aY.getMaskInteractionRenderStates(C)):_.isReadStencil(S)&&_.clearMask(e,t),_.isStencilWritten(S)&&(_.hasStencilWritten=!0));var R=ro._compileMacros,M=y.primitive,w=y.shaderPasses,P=y.shaderData,F=x.shaderData,L=x.instanceId,D=S.shaderData,B=S.instanceId,I=S.renderStates;nW.unionCollection(x._globalShaderMacro,D._macroCollection,R);for(var O=0,V=w.length;O<V;O++){var N,k,z=w[O];if(z.getTagValue(m)===t&&(A||(null!=(N=z._renderState)?N:I[O]).renderQueueType===g)){var U=z._getShaderProgram(s,R);if(U.isValid){var G=U.bind();f!==U._uploadRenderCount?(U.groupingOtherUniformBlock(),U.uploadAll(U.sceneUniformBlock,h),U.uploadAll(U.cameraUniformBlock,u),U.uploadAll(U.rendererUniformBlock,F),U.uploadAll(U.materialUniformBlock,D),P&&U.uploadAll(U.renderElementUniformBlock,P),U.uploadUnGroupTextures(),U._uploadSceneId=d,U._uploadCameraId=c,U._uploadRendererId=L,U._uploadMaterialId=B,U._uploadRenderCount=f):(U._uploadSceneId!==d?(U.uploadAll(U.sceneUniformBlock,h),U._uploadSceneId=d):G&&U.uploadTextures(U.sceneUniformBlock,h),U._uploadCameraId!==c?(U.uploadAll(U.cameraUniformBlock,u),U._uploadCameraId=c):G&&U.uploadTextures(U.cameraUniformBlock,u),U._uploadRendererId!==L?(U.uploadAll(U.rendererUniformBlock,F),U._uploadRendererId=L):G&&U.uploadTextures(U.rendererUniformBlock,F),U._uploadMaterialId!==B?(U.uploadAll(U.materialUniformBlock,D),U._uploadMaterialId=B):G&&U.uploadTextures(U.materialUniformBlock,D),P&&U.uploadAll(U.renderElementUniformBlock,P),G&&U.uploadUnGroupTextures()),(null!=(k=z._renderState)?k:I[O])._applyStates(s,x.entity.transform._isFrontFaceInvert(),z._renderStateDataMap,S.shaderData,E),p.drawPrimitive(M,y.subPrimitive,U)}}}}},t.clear=function(){this.elements.length=0,this.batchedSubElements.length=0},t.destroy=function(){},e.compareForOpaque=function(e,t){return e.priority-t.priority||e.distanceForSort-t.distanceForSort},e.compareForTransparent=function(e,t){return e.priority-t.priority||t.distanceForSort-e.distanceForSort},e}(),rH=function(){this.virtualCamera=new rM,this.cullPlanes=[new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT)],this.splitBoundSphere=new tA(new tT,0)},rW=((et={})[et.Low=0]="Low",et[et.Medium=1]="Medium",et[et.High=2]="High",et[et.VeryHigh=3]="VeryHigh",et),rj=((en={})[en.None=0]="None",en[en.Hard=1]="Hard",en[en.SoftLow=2]="SoftLow",en[en.SoftHigh=3]="SoftHigh",en),rX=/*#__PURE__*/function(){function e(){}return e.shadowResolution=function(e){switch(e){case rW.Low:return 512;case rW.Medium:return 1024;case rW.High:return 2048;case rW.VeryHigh:return 4096}},e.shadowDepthFormat=function(e,t){return t?t9.Depth16:t9.R8G8B8A8},e.cullingRenderBounds=function(e,t,n){for(var r=e.min,a=e.max,i=0;i<t;i++){var o=n[i],s=o.normal;if(s.x*(s.x>=0?a.x:r.x)+s.y*(s.y>=0?a.y:r.y)+s.z*(s.z>=0?a.z:r.z)<-o.distance)return!1}return!0},e.shadowCullFrustum=function(t,n,r,a){var i=r._entity.layer;t.camera.cullingMask&i&&n.cullingMask&i&&r.castShadows&&e.cullingRenderBounds(r.bounds,a.cullPlaneCount,a.cullPlanes)&&(r._prepareRender(t),r._renderFrameCount=r.engine.time.frameCount)},e.getBoundSphereByFrustum=function(e,t,n,r,a){var i,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(tC.degreeToRadian(l)/2),u=c*c,d=t-e,h=t+e;u>d/h?(i=t,o=t*c):(i=.5*h*(1+u),o=.5*Math.sqrt(d*d+2*(t*t+e*e)*u+h*h*u*u));var _=a.splitBoundSphere.center;a.splitBoundSphere.radius=o,tT.scale(r,i,_),tT.add(n.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},e.getDirectionLightShadowCullPlanes=function(t,n,r,a,i){var o=e._frustumCorners,s=e._backPlaneFaces,l=e._frustumPlaneNeighbors,c=e._frustumTwoPlaneCorners,u=e._edgePlanePoint2,d=i.cullPlanes,h=t.getPlane(tx.Near),_=t.getPlane(tx.Far),f=t.getPlane(tx.Left),p=t.getPlane(tx.Right),m=t.getPlane(tx.Bottom),g=t.getPlane(tx.Top),v=e._adjustNearPlane,y=e._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(n-r),y.distance=Math.min(-h.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),tR.intersectionPointThreePlanes(v,m,p,o[7]),tR.intersectionPointThreePlanes(v,g,p,o[6]),tR.intersectionPointThreePlanes(v,g,f,o[5]),tR.intersectionPointThreePlanes(v,m,f,o[4]),tR.intersectionPointThreePlanes(y,m,p,o[3]),tR.intersectionPointThreePlanes(y,g,p,o[2]),tR.intersectionPointThreePlanes(y,g,f,o[1]),tR.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var S=void 0;switch(b){case tx.Near:S=v;break;case tx.Far:S=y;break;default:S=t.getPlane(b)}0>tT.dot(S.normal,a)&&(d[x].copyFrom(S),s[x]=b,x++)}for(var C=x,T=0;T<x;T++)for(var A=s[T],E=l[A],R=0;R<4;R++){for(var M=E[R],w=!0,P=0;P<x;P++)if(M==s[P]){w=!1;break}if(w){var F=c[A][M],L=o[F[0]],D=o[F[1]];tT.add(L,a,u),tM.fromPoints(L,D,u,d[C++])}}i.cullPlaneCount=C},e.getDirectionalLightMatrices=function(t,n,r,a,i,o,s,l){var c=s.splitBoundSphere;s.resolution=o;var u=c.center,d=c.radius,h=o/2,_=d*h/(h-e.atlasBorderSize),f=2*_,p=o/f,m=f/o,g=Math.ceil(tT.dot(u,t)*p)*m,v=Math.ceil(tT.dot(u,n)*p)*m,y=tT.dot(u,r);u.x=t.x*g+n.x*v+r.x*y,u.y=t.y*g+n.y*v+r.y*y,u.z=t.z*g+n.z*v+r.z*y;var x=s.virtualCamera,b=x.position,S=x.viewMatrix,C=x.projectionMatrix;tT.scale(r,d+i,b),tT.subtract(u,b,b),tL.lookAt(b,u,t,S),tL.ortho(-_,_,-_,_,0,2*d+i,C);var T=x.viewProjectionMatrix;tL.multiply(C,S,T),nT._floatMatrixMultiply(e._shadowMapCoordMatrix,T.elements,0,l,16*a)},e.getMaxTileResolutionInAtlas=function(e,t,n){for(var r=Math.min(e,t),a=Math.floor(e/r)*Math.floor(t/r);a<n;)a=Math.floor(e/(r=Math.floor(r>>1)))*Math.floor(t/r);return r},e.getShadowBias=function(e,t,n,r){var a=2/t.elements[0]/n,i=-e.shadowBias*a,o=-e.shadowNormalBias*a;e.shadowType==rj.SoftHigh&&(i*=2.5,o*=2.5),r.set(i,o)},e.applySliceTransform=function(t,n,r,a,i,o){var s=e._tempMatrix0,l=s.elements,c=1/n,u=1/r,d=i.x*c,h=i.y*u;l[0]=t*c,l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=t*u,l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=1,l[11]=0,l[12]=d,l[13]=h,l[14]=0,l[15]=1;var _=16*a;nT._floatMatrixMultiply(s,o,_,o,_)},e.getScaleAndBiasForLinearDistanceFade=function(e,t,n){if(t<1e-4){n.z=1e3,n.w=-(1e3*e);return}t=1-t;var r=(t*=t)*e,a=e-r;n.z=1/a,n.w=-r/a},e}();rX._tempMatrix0=new tL,rX._shadowMapCoordMatrix=new tL(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),rX._frustumCorners=[new tT,new tT,new tT,new tT,new tT,new tT,new tT,new tT],rX._adjustNearPlane=new tM(new tT),rX._adjustFarPlane=new tM(new tT),rX._backPlaneFaces=[,,,,,],rX._edgePlanePoint2=new tT,rX._frustumPlaneNeighbors=[[tx.Left,tx.Right,tx.Top,tx.Bottom],[tx.Left,tx.Right,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Left,tx.Right],[tx.Near,tx.Far,tx.Left,tx.Right]],rX._frustumTwoPlaneCorners=[[[8,8],[8,8],[4,5],[6,7],[7,4],[5,6]],[[8,8],[8,8],[1,0],[3,2],[0,3],[2,1]],[[5,4],[0,1],[8,8],[8,8],[4,0],[1,5]],[[7,6],[2,3],[8,8],[8,8],[3,7],[6,2]],[[4,7],[3,0],[0,4],[7,3],[8,8],[8,8]],[[6,5],[1,2],[5,1],[2,6],[8,8],[8,8]]],rX.atlasBorderSize=4;var rK=((er={})[er.NoCascades=1]="NoCascades",er[er.TwoCascades=2]="TwoCascades",er[er.FourCascades=4]="FourCascades",er),rY=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n.engine)||this)._shadowMapSize=new tI,r._shadowBias=new tB,r._shadowSliceData=new rH,r._lightUp=new tT,r._lightSide=new tT,r._splitBoundSpheres=new Float32Array(4*t._maxCascades),r._shadowMatrices=new Float32Array((t._maxCascades+1)*16),r._shadowInfos=new tI,r._viewportOffsets=[new tB,new tB,new tB,new tB],r._camera=n,r._supportDepthTexture=n.engine._hardwareRenderer.canIUse(nZ.depthTexture),r._shadowSliceData.virtualCamera.isOrthographic=!0,r}tW(t,e);var n=t.prototype;return n.onRender=function(e){var t=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,t),this._updateReceiversShaderData(t)},n._renderDirectShadowMap=function(e,n){var r,a,i=this.engine,o=this._camera,s=this._viewportOffsets,l=this._shadowSliceData,c=this._splitBoundSpheres,u=this._shadowMatrices,d=o._renderPipeline._cullingResults,h=d.opaqueQueue,_=d.alphaTestQueue,f=o.scene,p=f._componentsManager,m=i._hardwareRenderer,g=f.shadowCascades,v=t._cascadesSplitDistance,y=l.splitBoundSphere,x=t._tempMatrix0,b=x.elements,S=this._lightUp,C=this._lightSide,T=l.virtualCamera.forward,A=this._shadowMapSize,E=A.z,R=A.w,M=this._shadowMapFormat;a=this._supportDepthTexture?(r=rR.recreateRenderTargetIfNeeded(i,this._renderTarget,E,R,null,M,!0,!1,1,t7.Clamp,t5.Bilinear)).depthTexture:(r=rR.recreateRenderTargetIfNeeded(i,this._renderTarget,E,R,M,null,!1,!1,1,t7.Clamp,t5.Bilinear)).getColorTexture(0),i._hardwareRenderer._isWebGL2&&(a.depthCompareFunction=t8.Less),this._renderTarget=r,this._depthTexture=a,m.activeRenderTarget(r,t._viewport,e.flipProjection,0),this._supportDepthTexture?m.clearRenderTarget(i,rw.Depth,null):m.clearRenderTarget(i,rw.All,t._clearColor),tL.rotationQuaternion(n.entity.transform.worldRotationQuaternion,x),C.set(b[0],b[1],b[2]),S.set(b[4],b[5],b[6]),T.set(-b[8],-b[9],-b[10]);var w=t._tempVector;w.copyFrom(o.entity.transform.worldForward);for(var P=this._shadowTileResolution,F=0;F<g;F++){rX.getBoundSphereByFrustum(v[F],v[F+1],o,w,l),rX.getDirectionLightShadowCullPlanes(o._frustum,v[F],o.nearClipPlane,T,l),rX.getDirectionalLightMatrices(S,C,T,F,n.shadowNearPlaneOffset,P,l,u),g>1&&rX.applySliceTransform(P,E,R,F,this._viewportOffsets[F],u),this._updateSingleShadowCasterShaderData(n,l,e);var L=y.center,D=y.radius,B=4*F;c[B]=L.x,c[B+1]=L.y,c[B+2]=L.z,c[B+3]=D*D,h.clear(),_.clear();for(var I=p._renderers,O=I._elements,V=I.length-1;V>=0;--V)rX.shadowCullFrustum(e,n,O[V],l);if(h.elements.length||_.elements.length){i._renderCount++;var N=i._batcherManager;h.sortBatch(rG.compareForOpaque,N),_.sortBatch(rG.compareForOpaque,N);var k=s[F],z=k.x,U=k.y;m.setGlobalDepthBias(1,1),m.viewport(z,U,P,P),m.scissor(z+1,U+1,P-2,P-2),h.render(e,nX.ShadowCaster),_.render(e,nX.ShadowCaster),m.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var n=this._camera,r=n.scene,a=this._splitBoundSpheres,i=this._shadowMatrices,o=r.shadowCascades,s=Math.min(r.shadowDistance,n.farClipPlane);if(rX.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),r.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,o>1)for(var l=4*o,c=a.length;l<c;l++)a[l]=0;for(var u=16*o,d=i.length;u<d;u++)i[u]=0;var h=r.shaderData;h.setFloatArray(t._shadowMatricesProperty,this._shadowMatrices),h.setVector4(t._shadowInfosProperty,this._shadowInfos),h.setTexture(t._shadowMapsProperty,this._depthTexture),h.setFloatArray(t._shadowSplitSpheresProperty,this._splitBoundSpheres),h.setVector4(t._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(e){var n=t._cascadesSplitDistance,r=this._camera.scene,a=r.shadowTwoCascadeSplits,i=r.shadowFourCascadeSplits,o=r.shadowCascades,s=this._camera,l=s.nearClipPlane,c=s.aspectRatio,u=s.fieldOfView;n[0]=l;var d=e-l,h=Math.tan(.5*tC.degreeToRadian(u)),_=1+h*h*(c*c+1);switch(o){case rK.NoCascades:n[1]=this._getFarWithRadius(e,_);break;case rK.TwoCascades:n[1]=this._getFarWithRadius(l+d*a,_),n[2]=this._getFarWithRadius(e,_);break;case rK.FourCascades:n[1]=this._getFarWithRadius(l+d*i.x,_),n[2]=this._getFarWithRadius(l+d*i.y,_),n[3]=this._getFarWithRadius(l+d*i.z,_),n[4]=this._getFarWithRadius(e,_)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._updateShadowSettings=function(){var e=this._camera,t=e.scene,n=rX.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=rX.shadowResolution(t.shadowResolution),a=t.shadowCascades,i=Math.min(t.shadowDistance,e.farClipPlane);if(this._getCascadesSplitDistance(i),n!==this._shadowMapFormat||r!==this._shadowMapResolution||a!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=r,this._shadowCascadeMode=a,a==rK.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var o=rX.getMaxTileResolutionInAtlas(r,r,a);this._shadowTileResolution=o;var s=2*o,l=a==rK.TwoCascades?o:2*o;this._shadowMapSize.set(1/s,1/l,s,l)}this._renderTarget=null;var c=this._viewportOffsets,u=this._shadowTileResolution;switch(a){case rK.NoCascades:c[0].set(0,0);break;case rK.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case rK.FourCascades:c[0].set(0,0),c[1].set(u,0),c[2].set(0,u),c[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var a=n.virtualCamera;rX.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(t._lightShadowBiasProperty,this._shadowBias),i.setVector3(t._lightDirectionProperty,e.direction),r.rendererUpdateFlag|=rz.viewProjectionMatrix,r.applyVirtualCamera(a,!0)},t}(rN);rY._lightShadowBiasProperty=nY.getByName("scene_ShadowBias"),rY._lightDirectionProperty=nY.getByName("scene_LightDirection"),rY._shadowMatricesProperty=nY.getByName("scene_ShadowMatrices"),rY._shadowMapSize=nY.getByName("scene_ShadowMapSize"),rY._shadowInfosProperty=nY.getByName("scene_ShadowInfo"),rY._shadowMapsProperty=nY.getByName("scene_ShadowMap"),rY._shadowSplitSpheresProperty=nY.getByName("scene_ShadowSplitSpheres"),rY._maxCascades=4,rY._cascadesSplitDistance=Array(rY._maxCascades+1),rY._viewport=new tI(0,0,1,1),rY._clearColor=new tO(1,1,1,1),rY._tempVector=new tT,rY._tempMatrix0=new tL;var rq=/*#__PURE__*/function(){function e(){this.opaqueQueue=new rG(nV.Opaque),this.transparentQueue=new rG(nV.Transparent),this.alphaTestQueue=new rG(nV.AlphaTest)}var t=e.prototype;return t.reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},t.sortBatch=function(e){this.opaqueQueue.sortBatch(rG.compareForOpaque,e),this.alphaTestQueue.sortBatch(rG.compareForOpaque,e),this.transparentQueue.sortBatch(rG.compareForTransparent,e)},t.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},e}(),rQ=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._supportDepthTexture=e._hardwareRenderer.canIUse(nZ.depthTexture),n}tW(n,t);var r=n.prototype;return r.onConfig=function(e){var t=this.engine,n=e.pixelViewport,r=n.width,a=n.height,i=rR.recreateRenderTargetIfNeeded(t,this._renderTarget,r,a,null,t9.Depth16,!0,!1,1,t7.Clamp,t5.Point);this._renderTarget=i},r.onRender=function(t,n){var r=this.engine,a=this._renderTarget,i=t.camera,o=r._hardwareRenderer;o.activeRenderTarget(a,rR.defaultViewport,t.flipProjection,0),o.clearRenderTarget(r,rw.Depth,null),r._renderCount++,n.opaqueQueue.render(t,nX.DepthOnly),n.alphaTestQueue.render(t,nX.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},n}(rN),rZ=/*#__PURE__*/function(t){function n(e){return t.call(this,e)||this}tW(n,t);var r=n.prototype;return r.onConfig=function(e,t){this._cameraColorTexture=t;var n=e.opaqueTextureDownsampling,r=n===rL.None,a=e.pixelViewport,i=r?1:n===rL.TwoX?.5:.25,o=rR.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,a.width*i,a.height*i,e._getInternalColorTextureFormat(),null,!1,!1,1,t7.Clamp,r?t5.Point:t5.Bilinear);this._renderTarget=o},r.onRender=function(t){rR.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},n}(rN),rJ=/*#__PURE__*/function(){function t(e){this._lastCanvasSize=new tB,this._internalColorTarget=null,this._camera=e;var t=e.engine;this._cullingResults=new rq,this._cascadedShadowCasterPass=new rY(e),this._depthOnlyPass=new rQ(t),this._opaqueTexturePass=new rZ(t)}var n=t.prototype;return n.destroy=function(){this._cullingResults.destroy(),this._camera=null},n.render=function(t,n,r,a){t.rendererUpdateFlag=rz.All;var i=this._camera,o=i.scene,s=i.engine,l=this._cullingResults,c=o._lightManager._sunlight,u=this._depthOnlyPass,d=i.depthTextureMode===rF.PrePass&&u._supportDepthTexture;o.castShadows&&c&&c.shadowType!==rj.None&&(this._cascadedShadowCasterPass.onRender(t),t.rendererUpdateFlag=rz.None);var h=s._batcherManager;if(l.reset(),t.rendererUpdateFlag|=rz.viewProjectionMatrix,t.applyVirtualCamera(i._virtualCamera,d),this._prepareRender(t),l.sortBatch(h),h.uploadBuffer(),d?(u.onConfig(i),u.onRender(t,l),t.rendererUpdateFlag=rz.None):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),i.independentCanvasEnabled){var _=i.pixelViewport,f=rR.recreateRenderTargetIfNeeded(s,this._internalColorTarget,_.width,_.height,i._getInternalColorTextureFormat(),t9.Depth24Stencil8,!1,!1,i.msaaSamples,t7.Clamp,t5.Bilinear);this._internalColorTarget=f}else{var p,m=this._internalColorTarget;m&&(null==(p=m.getColorTexture(0))||p.destroy(!0),m.destroy(!0),this._internalColorTarget=null)}this._drawRenderPass(t,i,n,r,a)},n._drawRenderPass=function(t,n,r,a,i){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue,u=n.engine,d=n.scene,h=d.background,_=u._hardwareRenderer,f=this._internalColorTarget,p=f||n.renderTarget,m=f?rR.defaultViewport:n.viewport,g=!!f||n.renderTarget&&void 0==r;t.flipProjection!==g&&(t.rendererUpdateFlag|=rz.ProjectionMatrix,t.applyVirtualCamera(n._virtualCamera,g)),_.activeRenderTarget(p,m,t.flipProjection,a,r);var v=n.clearFlags&~(null!=i?i:rw.None),y=h.solidColor;v!==rw.None&&_.clearRenderTarget(u,v,y);var x=d._maskManager;if(v&rw.Stencil&&(x.hasStencilWritten=!1),s.render(t,nX.Forward),l.render(t,nX.Forward),v&rw.Color&&(h.mode===rO.Sky?h.sky._render(t):h.mode===rO.Texture&&h.texture&&this._drawBackgroundTexture(n,h)),n.opaqueTextureEnabled){p._blitRenderTarget();var b=this._opaqueTexturePass;b.onConfig(n,p.getColorTexture(0)),b.onRender(t),_.activeRenderTarget(p,m,t.flipProjection,a,r)}else n.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);c.render(t,nX.Forward),x.clearMask(t,nX.Forward);var S=d._postProcessManager,C=n.renderTarget;n.enablePostProcess&&S.hasActiveEffect?S._render(t,f,C):f&&(f._blitRenderTarget(),rR.blitTexture(u,f.getColorTexture(0),C,0,n.viewport)),null==C||C._blitRenderTarget(),null==C||C.generateMipmaps()},n.pushRenderElement=function(e,t){t.renderQueueFlags=0;for(var n=t.subRenderElements,r=0,a=n.length;r<a;++r){var i=n[r],o=i.material,s=o.renderStates,l=o.shader.subShaders[0],c=e.replacementShader;if(c){var u=c.subShaders,d=e.replacementTag;if(d){for(var h=!1,_=0,f=u.length;_<f;_++){var p=u[_];p.getTagValue(d)===l.getTagValue(d)&&(this.pushRenderElementByType(t,i,p.passes,s),h=!0)}h||e.replacementFailureStrategy!==rB.KeepOriginalShader||this.pushRenderElementByType(t,i,l.passes,s)}else this.pushRenderElementByType(t,i,u[0].passes,s)}else this.pushRenderElementByType(t,i,l.passes,s)}},n.pushRenderElementByType=function(e,t,n,r){for(var a=this._cullingResults,i=0,o=n.length;i<o;i++){var s=void 0,l=n[i],c=l._renderState;c?(c._applyRenderQueueByShaderData(l._renderStateDataMap,t.material.shaderData),s=c.renderQueueType):s=r[i].renderQueueType;var u=1<<s;if(t.shaderPasses=n,t.renderQueueFlags|=u,!(e.renderQueueFlags&u)){switch(s){case nV.Opaque:a.opaqueQueue.pushRenderElement(e);break;case nV.AlphaTest:a.alphaTestQueue.pushRenderElement(e);break;case nV.Transparent:a.transparentQueue.pushRenderElement(e)}e.renderQueueFlags|=u}}},n._drawBackgroundTexture=function(e,t){var n=e.engine,r=n._hardwareRenderer,a=n.canvas,i=t._material,o=t._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&t._textureFillMode!==rV.Fill&&(this._lastCanvasSize.set(a.width,a.height),t._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0],l=s._getShaderProgram(n,ro._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,i.shaderData),l.uploadAll(l.cameraUniformBlock,e.shaderData),l.uploadUnGroupTextures(),(s._renderState||i.renderState)._applyStates(n,!1,s._renderStateDataMap,i.shaderData),r.drawPrimitive(o._primitive,o.subMesh,l)},n._prepareRender=function(e){for(var t=e.camera,n=t.engine,r=t.scene._componentsManager._renderers,a=r._elements,i=r.length-1;i>=0;--i){var o=a[i];t.cullingMask&o._entity.layer&&(!t.enableFrustumCulling||t._frustum.intersectsBox(o.bounds))&&(o._prepareRender(e),o._renderFrameCount=n.time.frameCount)}},t}(),r$=((ea={})[ea.None=0]="None",ea[ea.Opaque=1]="Opaque",ea[ea.AlphaTest=2]="AlphaTest",ea[ea.Transparent=4]="Transparent",ea[ea.All=7]="All",ea),r0=/*#__PURE__*/function(){function e(){this.subRenderElements=[]}var t=e.prototype;return t.set=function(e,t){this.priority=e,this.distanceForSort=t,this.subRenderElements.length=0},t.addSubRenderElement=function(e){this.subRenderElements.push(e)},t.dispose=function(){this.subRenderElements.length=0},e}(),r1=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.set=function(e,t,n,r,a,i){this.component=e,this.material=t,this.primitive=n,this.subPrimitive=r,this.texture=a,this.subChunk=i},t.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null,this.shaderPasses=null,this.shaderData&&(this.shaderData=null),this.texture&&(this.texture=null),this.subChunk&&(this.subChunk=null)},e}(),r2=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).influenceLayers=rg.Everything,r._maskIndex=-1,r._sprite=null,r._automaticWidth=0,r._automaticHeight=0,r._customWidth=void 0,r._customHeight=void 0,r._flipX=!1,r._flipY=!1,r._alphaCutoff=.5,rx.resetData(r),r.setMaterial(r._engine._basicResources.spriteMaskDefaultMaterial),r.shaderData.setFloat(t._alphaCutoffProperty,r._alphaCutoff),r._renderElement=new r0,r._renderElement.addSubRenderElement(new r1),r._onSpriteChange=r._onSpriteChange.bind(r),r}tW(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.sprite=this._sprite},n._canBatch=function(e,t){return rl.canBatchSpriteMask(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._onEnableInScene=function(){e.prototype._onEnableInScene.call(this),this.scene._maskManager.addSpriteMask(this)},n._onDisableInScene=function(){e.prototype._onDisableInScene.call(this),this.scene._maskManager.removeSpriteMask(this)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManagerMask},n._updateBounds=function(e){this.sprite?rx.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},n._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,n=this.getMaterial();if(n){var r=this._engine;n.destroyed&&(n=r._basicResources.spriteMaskDefaultMaterial),this._dirtyUpdateFlag&rv.WorldVolume&&(rx.updatePositions(this),this._dirtyUpdateFlag&=~rv.WorldVolume),2&this._dirtyUpdateFlag&&(rx.updateUVs(this),this._dirtyUpdateFlag&=-3);var a=this._renderElement,i=a.subRenderElements[0];a.set(this.priority,this._distanceForSort);var o=this._subChunk;i.set(this,n,o.chunk.primitive,o.subMesh,this.sprite.texture,o),i.shaderPasses=n.shader.subShaders[0].passes,i.renderQueueFlags=r$.All,a.addSubRenderElement(i)}}},n._onDestroy=function(){var t=this._sprite;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),e.prototype._onDestroy.call(this),this._sprite=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null),this._renderElement=null},n._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},n._onSpriteChange=function(e){switch(e){case nw.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nw.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rv.WorldVolume);break;case nw.region:case nw.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case nw.atlasRegion:this._dirtyUpdateFlag|=2;break;case nw.pivot:this._dirtyUpdateFlag|=rv.WorldVolume;break;case nw.destroy:this.sprite=null}},tG(t,[{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var n=this._sprite;n!==e&&(n&&(this._addResourceReferCount(n,-1),n._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(t._textureProperty,e.texture)):this.shaderData.setTexture(t._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(t._alphaCutoffProperty,e))}}]),t}(e.Renderer);r2._textureProperty=nY.getByName("renderer_MaskTexture"),r2._alphaCutoffProperty=nY.getByName("renderer_MaskAlphaCutoff"),tX([tQ],r2.prototype,"influenceLayers",void 0),tX([tq],r2.prototype,"_renderElement",void 0),tX([tq],r2.prototype,"_subChunk",void 0),tX([tq],r2.prototype,"_maskIndex",void 0),tX([tq],r2.prototype,"_sprite",void 0),tX([tq],r2.prototype,"_automaticWidth",void 0),tX([tq],r2.prototype,"_automaticHeight",void 0),tX([tQ],r2.prototype,"_customWidth",void 0),tX([tQ],r2.prototype,"_customHeight",void 0),tX([tQ],r2.prototype,"_flipX",void 0),tX([tQ],r2.prototype,"_flipY",void 0),tX([tQ],r2.prototype,"_alphaCutoff",void 0),tX([tq],r2.prototype,"_onSpriteChange",null);var r3=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._textChunks=[],n._subFont=null,n._dirtyFlag=15,n._color=new tO(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new tE,n._font=null,n._fontSize=24,n._fontStyle=n_.None,n._lineSpacing=0,n._horizontalAlignment=ny.Center,n._verticalAlignment=nx.Center,n._enableWrapping=!1,n._overflowMode=nf.Overflow;var n,r=n.engine;return n._font=r._textDefaultFont,n._addResourceReferCount(n._font,1),n.setMaterial(r._basicResources.textDefaultMaterial),n._color._onValueChanged=n._onColorChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),e.prototype._onDestroy.call(this),this._freeTextChunks(),this._textChunks=null,this._subFont&&(this._subFont=null)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.font=this._font,t._subFont=this._subFont},n._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},n._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},n._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},n._getSubFont=function(){return this._subFont||this._resetSubFont(),this._subFont},n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._canBatch=function(e,t){return rl.canBatchSprite(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){tE.transform(this._localBounds,this._entity.transform.worldMatrix,e)},n._render=function(e){if(!this._isTextNoVisible()){this._isContainDirtyFlag(1)&&(this._resetSubFont(),this._setDirtyFlagFalse(1)),this._isContainDirtyFlag(2)&&(this._updateLocalData(),this._setDirtyFlagFalse(2)),this._isContainDirtyFlag(4)&&(this._updatePosition(),this._setDirtyFlagFalse(4)),this._isContainDirtyFlag(16)&&(this._updateColor(),this._setDirtyFlagFalse(16));var n=e.camera,r=n.engine,a=r._textSubRenderElementPool,i=this.getMaterial(),o=r._renderElementPool.get();o.set(this.priority,this._distanceForSort);for(var s=this._textChunks,l=0,c=s.length;l<c;++l){var u=s[l],d=u.subChunk,h=u.texture,_=a.get();_.set(this,i,d.chunk.primitive,d.subMesh,h,d),_.shaderData||(_.shaderData=new rs(n8.RenderElement)),_.shaderData.setTexture(t._textureProperty,h),o.addSubRenderElement(_)}n._renderPipeline.pushRenderElement(e,o)}},n._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=np.getNativeFontString(e.name,this.fontSize,this.fontStyle)},n._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,n=e[0],r=e[1],a=e[2],i=e[4],o=e[5],s=e[6],l=e[12],c=e[13],u=e[14],d=t._tempVec31.set(i,o,s),h=t._tempVec30.set(n,r,a),_=t._worldPositions,f=_[0],p=_[1],m=_[2],g=_[3],v=this._textChunks,y=0,x=v.length;y<x;++y)for(var b=v[y],S=b.subChunk,C=b.charRenderInfos,T=0,A=C.length;T<A;++T){var E=C[T],R=E.localPositions,M=R.x,w=R.y;f.set(M*n+w*i+l,M*r+w*o+c,M*a+w*s+u),tT.scale(h,R.z-M,p),tT.add(f,p,p),tT.scale(d,R.w-w,m),tT.add(f,m,g),tT.add(p,m,m);for(var P=S.chunk.vertices,F=0,L=S.vertexArea.start+36*E.indexInChunk;F<4;++F,L+=9)_[F].copyToArray(P,L)}},n._updateColor=function(){for(var e=this._color,t=e.r,n=e.g,r=e.b,a=e.a,i=this._textChunks,o=0,s=i.length;o<s;++o)for(var l=i[o].subChunk,c=l.vertexArea,u=c.size/9,d=l.chunk.vertices,h=0,_=c.start+5;h<u;++h,_+=9)d[_]=t,d[_+1]=n,d[_+2]=r,d[_+3]=a},n._updateLocalData=function(){var e=this._localBounds,n=e.min,r=e.max,a=t._charRenderInfos,i=this._subFont,o=this.enableWrapping?np.measureTextWithWrap(this):np.measureTextWithoutWrap(this),s=o.height,l=o.lines,c=o.lineWidths,u=o.lineHeight,d=o.lineMaxSizes,h=this.engine._charRenderInfoPool,_=l.length,f=0;if(_>0){var p=iZ._pixelsPerUnit,m=this.horizontalAlignment,g=1/p,v=.5*(this.width*p),y=this.height*p,x=.5*u,b=0,S=.5*u-d[0].ascent,C=.5*u-d[_-1].descent-1;switch(this.verticalAlignment){case nx.Top:b=.5*y-x+S;break;case nx.Center:b=.5*s-x-(C-S)*.5;break;case nx.Bottom:b=s-.5*y-x-C}for(var T=-1,A=Number.MAX_SAFE_INTEGER,E=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,M=Number.MIN_SAFE_INTEGER,w=0;w<_;++w){var P=c[w];if(P>0){var F=l[w],L=0,D=-1;switch(T<0&&(T=w),m){case ny.Left:L=-v;break;case ny.Center:L=-(.5*P);break;case ny.Right:L=v-P}for(var B=0,I=F.length;B<I;++B){var O=F[B],V=i._getCharInfo(O);if(V.h>0){D<0&&(D=B);var N=a[f++]=h.get(),k=N.localPositions;N.texture=i._getTextureByIndex(V.index),N.uvs=V.uvs;var z=V.w,U=V.ascent,G=V.descent,H=L*g,W=(L+z)*g,j=(b+U)*g,X=(b-G)*g;k.set(H,j,W,X),w===T&&(M=Math.max(M,j)),E=Math.min(E,X),B===D&&(A=Math.min(A,H)),R=Math.max(R,W)}L+=V.xAdvance+V.offsetX}}b-=u}T<0?(n.set(0,0,0),r.set(0,0,0)):(n.set(A,E,0),r.set(R,M,0))}else n.set(0,0,0),r.set(0,0,0);if(i._getLastIndex()>0&&a.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId}),this._freeTextChunks(),0!==f){var K=this._textChunks,Y=new r4;K.push(Y);var q=this._getChunkManager().maxVertexCount,Q=a[0],Z=Q.texture;Y.texture=Z;var J=Y.charRenderInfos;J.push(Q);for(var $=1;$<f;++$){var ee=a[$],et=ee.texture;(Z!==et||4*J.length+4>q)&&(this._buildChunk(Y,J.length),Y=new r4,K.push(Y),Z=et,Y.texture=et,J=Y.charRenderInfos),J.push(ee)}var en=J.length;en>0&&this._buildChunk(Y,en),a.length=0}},n._onTransformChanged=function(t){e.prototype._onTransformChanged.call(this,t),this._setDirtyFlagTrue(12)},n._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===nf.Truncate&&this.height<=0},n._buildChunk=function(e,t){for(var n=this.color,r=n.r,a=n.g,i=n.b,o=n.a,s=tj.triangles,l=s.length,c=e.subChunk=this._getChunkManager().allocateSubChunk(4*t),u=c.chunk.vertices,d=c.indices=[],h=e.charRenderInfos,_=0,f=0,p=0,m=c.vertexArea.start+3;_<t;++_,p+=4){var g=h[_];g.indexInChunk=_;for(var v=0;v<l;++v)d[f++]=s[v]+p;for(var y=0;y<4;++y,m+=9)g.uvs[y].copyToArray(u,m),u[m+2]=r,u[m+3]=a,u[m+4]=i,u[m+5]=o}return c},n._freeTextChunks=function(){for(var e=this._textChunks,t=this.engine._charRenderInfoPool,n=this._getChunkManager(),r=0,a=e.length;r<a;++r){for(var i=e[r],o=i.charRenderInfos,s=0,l=o.length;s<l;++s)t.return(o[s]);o.length=0,n.freeSubChunk(i.subChunk),i.subChunk=null,i.texture=null}e.length=0},n._onColorChanged=function(){this._setDirtyFlagTrue(16)},tG(t,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e)}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),t}(e.Renderer);r3._textureProperty=nY.getByName("renderElement_TextTexture"),r3._tempVec30=new tT,r3._tempVec31=new tT,r3._worldPositions=[new tT,new tT,new tT,new tT],r3._charRenderInfos=[],tX([tq],r3.prototype,"_textChunks",void 0),tX([tQ],r3.prototype,"_subFont",void 0),tX([tq],r3.prototype,"_dirtyFlag",void 0),tX([tJ],r3.prototype,"_color",void 0),tX([tQ],r3.prototype,"_text",void 0),tX([tQ],r3.prototype,"_width",void 0),tX([tQ],r3.prototype,"_height",void 0),tX([tq],r3.prototype,"_localBounds",void 0),tX([tQ],r3.prototype,"_font",void 0),tX([tQ],r3.prototype,"_fontSize",void 0),tX([tQ],r3.prototype,"_fontStyle",void 0),tX([tQ],r3.prototype,"_lineSpacing",void 0),tX([tQ],r3.prototype,"_horizontalAlignment",void 0),tX([tQ],r3.prototype,"_verticalAlignment",void 0),tX([tQ],r3.prototype,"_enableWrapping",void 0),tX([tQ],r3.prototype,"_overflowMode",void 0),tX([tq],r3.prototype,"_onColorChanged",null);var r4=function(){this.charRenderInfos=[]},r8=((ei={})[ei.Static=0]="Static",ei[ei.Dynamic=1]="Dynamic",ei[ei.Stream=2]="Stream",ei),r5=((eo={})[eo.None=0]="None",eo[eo.Discard=1]="Discard",eo),r9=/*#__PURE__*/function(e){function t(t,n,r,a,i){if(void 0===a&&(a=r8.Static),void 0===i&&(i=!1),(o=e.call(this,t)||this)._dataUpdateManager=new nM,o._engine=t,o._type=n,o._bufferUsage=a,o._readable=i,"number"==typeof r)o._byteLength=r,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,r,a),i&&(o._data=new Uint8Array(r));else{var o,s=r.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,s,a,r),i){var l=r.constructor===ArrayBuffer?r.slice(0):r.buffer.slice(r.byteOffset,r.byteOffset+s);o._data=new Uint8Array(l)}}return o}tW(t,e);var n=t.prototype;return n.bind=function(){this._platformBuffer.bind()},n.setData=function(e,t,n,r,a){if(void 0===t&&(t=0),void 0===n&&(n=0),void 0===a&&(a=r5.None),this._platformBuffer.setData(this._byteLength,e,t,n,r,a),this._readable){var i=e.constructor===ArrayBuffer?e:e.buffer;if(this._data.buffer!==i){var o=e.BYTES_PER_ELEMENT||1,s=r?o*r:e.byteLength,l=new Uint8Array(i,void 0!==e.byteOffset?e.byteOffset+n*o:n,s);this._data.set(l,t)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},n.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},n.markAsUnreadable=function(){this._data=null,this._readable=!1},n._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformBuffer.destroy()},tG(t,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}},{key:"readable",get:function(){return this._readable}},{key:"data",get:function(){if(this._readable)return this._data;throw"Buffer is not readable."}}]),t}(ne),r6=((es={})[es.UInt8=0]="UInt8",es[es.UInt16=1]="UInt16",es[es.UInt32=2]="UInt32",es),r7=((el={})[el.Float=0]="Float",el[el.Vector2=1]="Vector2",el[el.Vector3=2]="Vector3",el[el.Vector4=3]="Vector4",el[el.Byte4=4]="Byte4",el[el.UByte4=5]="UByte4",el[el.NormalizedByte4=6]="NormalizedByte4",el[el.NormalizedUByte4=7]="NormalizedUByte4",el[el.Short2=8]="Short2",el[el.UShort2=9]="UShort2",el[el.NormalizedShort2=10]="NormalizedShort2",el[el.NormalizedUShort2=11]="NormalizedUShort2",el[el.Short4=12]="Short4",el[el.UShort4=13]="UShort4",el[el.NormalizedShort4=14]="NormalizedShort4",el[el.NormalizedUShort4=15]="NormalizedUShort4",el),ae=/*#__PURE__*/function(){function e(){}return e._getGLIndexType=function(e){switch(e){case r6.UInt8:return nQ.UNSIGNED_BYTE;case r6.UInt16:return nQ.UNSIGNED_SHORT;case r6.UInt32:return nQ.UNSIGNED_INT}},e._getGLIndexByteCount=function(e){switch(e){case r6.UInt8:return 1;case r6.UInt16:return 2;case r6.UInt32:return 4}},e._getElementInfo=function(e){var t,n,r,a=!1;switch(e){case r7.Float:t=1,n=nQ.FLOAT;break;case r7.Vector2:t=2,n=nQ.FLOAT;break;case r7.Vector3:t=3,n=nQ.FLOAT;break;case r7.Vector4:t=4,n=nQ.FLOAT;break;case r7.Byte4:t=4,n=nQ.BYTE;break;case r7.UByte4:t=4,n=nQ.UNSIGNED_BYTE;break;case r7.NormalizedByte4:t=4,n=nQ.BYTE,a=!0,r=1/127;break;case r7.NormalizedUByte4:t=4,n=nQ.UNSIGNED_BYTE,a=!0,r=1/255;break;case r7.Short2:t=2,n=nQ.SHORT;break;case r7.UShort2:t=2,n=nQ.UNSIGNED_SHORT;break;case r7.NormalizedShort2:t=2,n=nQ.SHORT,a=!0,r=1/32767;break;case r7.NormalizedUShort2:t=2,n=nQ.UNSIGNED_SHORT,a=!0,r=1/65535;break;case r7.Short4:t=4,n=nQ.SHORT;break;case r7.UShort4:t=4,n=nQ.UNSIGNED_SHORT;break;case r7.NormalizedShort4:t=4,n=nQ.SHORT,a=!0,r=1/32767;break;case r7.NormalizedUShort4:t=4,n=nQ.UNSIGNED_SHORT,a=!0,r=1/65535}return{size:t,type:n,normalized:a,normalizedScaleFactor:r}},e}(),at=/*#__PURE__*/function(){function e(e,t,n,r,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=n,this._bindingIndex=r,this._formatMetaInfo=ae._getElementInfo(this.format),this._instanceStepRate=Math.floor(a)}return tG(e,[{key:"attribute",get:function(){return this._attributeName}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset=e}},{key:"format",get:function(){return this._format}},{key:"bindingIndex",get:function(){return this._bindingIndex},set:function(e){this._bindingIndex=e}},{key:"instanceStepRate",get:function(){return this._instanceStepRate}},{key:"semantic",get:function(){return this.attribute}}]),e}(),an=((ec={})[ec.VertexBuffer=0]="VertexBuffer",ec[ec.IndexBuffer=1]="IndexBuffer",ec),ar=((eu={})[eu.Points=0]="Points",eu[eu.Lines=1]="Lines",eu[eu.LineLoop=2]="LineLoop",eu[eu.LineStrip=3]="LineStrip",eu[eu.Triangles=4]="Triangles",eu[eu.TriangleStrip=5]="TriangleStrip",eu[eu.TriangleFan=6]="TriangleFan",eu),aa=((ed={})[ed.Normal=0]="Normal",ed[ed.Additive=1]="Additive",ed),ai=((eh={})[eh.Front=0]="Front",eh[eh.Back=1]="Back",eh[eh.Double=2]="Double",eh),ao=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._renderStates=[],r._shaderData=new rs(n8.Material),r.shader=n,r}tW(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),t$.deepCloneObject(this.renderStates,e.renderStates,new Map)},n._addReferCount=function(t){this._destroyed||(e.prototype._addReferCount.call(this,t),this.shaderData._addReferCount(t),this._shader._addReferCount(t))},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},tG(t,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var t,n=this._getReferCount();n>0&&(null==(t=this._shader)||t._addReferCount(-n),e._addReferCount(n)),this._shader=e;for(var r=this._renderStates,a=r.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)r.push(new ri);else r.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t}(t1),as=/*#__PURE__*/function(e){function t(n,r){(a=e.call(this,n,r)||this)._renderFace=ai.Front,a._isTransparent=!1,a._blendMode=aa.Normal;var a,i=a.shaderData;return i.setFloat(t._alphaCutoffProp,0),i.setFloat(t._shadowCasterRenderQueueProp,nV.Opaque),a}tW(t,e);var n=t.prototype;return n.setIsTransparent=function(e,n){var r=this.renderStates;if(r.length<e)throw"Pass should less than pass count.";var a=r[e],i=this.shaderData;n?(a.blendState.targetBlendState.enabled=!0,a.depthState.writeEnabled=!1,a.renderQueueType=nV.Transparent,i.enableMacro(t._transparentMacro)):(a.blendState.targetBlendState.enabled=!1,a.depthState.writeEnabled=!0,a.renderQueueType=i.getFloat(t._alphaCutoffProp)?nV.AlphaTest:nV.Opaque,i.disableMacro(t._transparentMacro))},n.setBlendMode=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";var r=n[e].blendState.targetBlendState;switch(t){case aa.Normal:r.sourceColorBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=nF.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=nF.One,r.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nL.Add;break;case aa.Additive:r.sourceColorBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=nF.One,r.sourceAlphaBlendFactor=nF.One,r.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nL.Add}},n.setRenderFace=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";switch(t){case ai.Front:n[e].rasterState.cullMode=nI.Back;break;case ai.Back:n[e].rasterState.cullMode=nI.Front;break;case ai.Double:n[e].rasterState.cullMode=nI.Off}},n.clone=function(){var e=new t(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t),t._renderFace=this._renderFace,t._isTransparent=this._isTransparent,t._blendMode=this._blendMode},tG(t,[{key:"shader",get:function(){return this._shader},set:function(e){var t,n=this._getReferCount();n>0&&(null==(t=this._shader)||t._addReferCount(-n),e._addReferCount(n)),this._shader=e;for(var r=this._renderStates,a=r.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)r.push(new ri),this.setBlendMode(l,aa.Normal);else r.length=i}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){if(e!==this._isTransparent){this.setIsTransparent(0,e);var n=this.shaderData;e?n.setFloat(t._shadowCasterRenderQueueProp,nV.AlphaTest):n.getFloat(t._alphaCutoffProp)?n.setFloat(t._shadowCasterRenderQueueProp,nV.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nV.Opaque),this._isTransparent=e}}},{key:"blendMode",get:function(){return this._blendMode},set:function(e){e!==this._blendMode&&(this.setBlendMode(0,e),this._blendMode=e)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(t._alphaCutoffProp)},set:function(e){var n=this.shaderData;if(n.getFloat(t._alphaCutoffProp)!==e){e?(n.enableMacro(t._alphaCutoffMacro),n.setFloat(t._shadowCasterRenderQueueProp,nV.AlphaTest)):(n.disableMacro(t._alphaCutoffMacro),this._isTransparent?n.setFloat(t._shadowCasterRenderQueueProp,nV.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nV.Opaque));for(var r=this.renderStates,a=0,i=r.length;a<i;a++){var o=r[a];e>0?o.renderQueueType=o.blendState.targetBlendState.enabled?nV.Transparent:nV.AlphaTest:o.renderQueueType=o.blendState.targetBlendState.enabled?nV.Transparent:nV.Opaque}n.setFloat(t._alphaCutoffProp,e)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),t}(ao);as._shadowCasterRenderQueueProp=nY.getByName("material_ShadowCasterRenderQueue"),as._baseTextureMacro=nH.getByName("MATERIAL_HAS_BASETEXTURE"),as._normalTextureMacro=nH.getByName("MATERIAL_HAS_NORMALTEXTURE"),as._emissiveTextureMacro=nH.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),as._transparentMacro=nH.getByName("MATERIAL_IS_TRANSPARENT"),as._baseColorProp=nY.getByName("material_BaseColor"),as._baseTextureProp=nY.getByName("material_BaseTexture"),as._tilingOffsetProp=nY.getByName("material_TilingOffset"),as._normalTextureProp=nY.getByName("material_NormalTexture"),as._normalIntensityProp=nY.getByName("material_NormalIntensity"),as._emissiveColorProp=nY.getByName("material_EmissiveColor"),as._emissiveTextureProp=nY.getByName("material_EmissiveTexture"),as._alphaCutoffProp=nY.getByName("material_AlphaCutoff"),as._alphaCutoffMacro=nH.getByName("MATERIAL_IS_ALPHA_CUTOFF");var al=/*#__PURE__*/function(e){function t(n){var r,a=(r=e.call(this,n,ro.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new tO(1,1,1,1)),a.setColor(t._specularColorProp,new tO(1,1,1,1)),a.setColor(t._emissiveColorProp,new tO(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var n=this.shaderData.getColor(t._specularColorProp);e!==n&&n.copyFrom(e)}},{key:"specularTexture",get:function(){return this.shaderData.getTexture(t._specularTextureProp)},set:function(e){this.shaderData.setTexture(t._specularTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SPECULAR_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SPECULAR_TEXTURE")}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(t._emissiveColorProp)},set:function(e){var n=this.shaderData.getColor(t._emissiveColorProp);e!==n&&n.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(t._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(t._emissiveTextureProp,e),e?this.shaderData.enableMacro(t._emissiveTextureMacro):this.shaderData.disableMacro(t._emissiveTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(t._normalTextureProp)},set:function(e){this.shaderData.setTexture(t._normalTextureProp,e),e?this.shaderData.enableMacro(t._normalTextureMacro):this.shaderData.disableMacro(t._normalTextureMacro)}},{key:"normalIntensity",get:function(){return this.shaderData.getFloat(t._normalIntensityProp)},set:function(e){this.shaderData.setFloat(t._normalIntensityProp,e)}},{key:"shininess",get:function(){return this.shaderData.getFloat(t._shininessProp)},set:function(e){this.shaderData.setFloat(t._shininessProp,Math.max(e,1e-4))}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}}]),t}(as);al._specularColorProp=nY.getByName("material_SpecularColor"),al._shininessProp=nY.getByName("material_Shininess"),al._specularTextureProp=nY.getByName("material_SpecularTexture");var ac=((e_={})[e_.UV0=0]="UV0",e_[e_.UV1=1]="UV1",e_[e_.UV2=2]="UV2",e_[e_.UV3=3]="UV3",e_[e_.UV4=4]="UV4",e_[e_.UV5=5]="UV5",e_[e_.UV6=6]="UV6",e_[e_.UV7=7]="UV7",e_),au=/*#__PURE__*/function(e){function t(n,r){var a,i=(a=e.call(this,n,r)||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tO(1,1,1,1)),i.setColor(t._emissiveColorProp,new tO(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),i.setFloat(t._normalIntensityProp,1),i.setFloat(t._occlusionTextureIntensityProp,1),i.setFloat(t._occlusionTextureCoordProp,ac.UV0),i.setFloat(t._clearCoatProp,0),i.setFloat(t._clearCoatRoughnessProp,0),a}return tW(t,e),tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(t._normalTextureProp)},set:function(e){this.shaderData.setTexture(t._normalTextureProp,e),e?this.shaderData.enableMacro(t._normalTextureMacro):this.shaderData.disableMacro(t._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(t._normalIntensityProp)},set:function(e){this.shaderData.setFloat(t._normalIntensityProp,e)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(t._emissiveColorProp)},set:function(e){var n=this.shaderData.getColor(t._emissiveColorProp);e!==n&&n.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(t._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(t._emissiveTextureProp,e),e?this.shaderData.enableMacro(t._emissiveTextureMacro):this.shaderData.disableMacro(t._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(t._occlusionTextureProp)},set:function(e){this.shaderData.setTexture(t._occlusionTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE")}},{key:"occlusionTextureIntensity",get:function(){return this.shaderData.getFloat(t._occlusionTextureIntensityProp)},set:function(e){this.shaderData.setFloat(t._occlusionTextureIntensityProp,e)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(t._occlusionTextureCoordProp)},set:function(e){e>ac.UV1&&no.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(t._occlusionTextureCoordProp,e)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(t._clearCoatProp)},set:function(e){!!this.shaderData.getFloat(t._clearCoatProp)!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(t._clearCoatProp,e)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(t._clearCoatTextureProp)},set:function(e){this.shaderData.setTexture(t._clearCoatTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE")}},{key:"clearCoatRoughness",get:function(){return this.shaderData.getFloat(t._clearCoatRoughnessProp)},set:function(e){this.shaderData.setFloat(t._clearCoatRoughnessProp,e)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(t._clearCoatRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(t._clearCoatRoughnessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE")}},{key:"clearCoatNormalTexture",get:function(){return this.shaderData.getTexture(t._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(t._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),t}(as);au._occlusionTextureIntensityProp=nY.getByName("material_OcclusionIntensity"),au._occlusionTextureCoordProp=nY.getByName("material_OcclusionTextureCoord"),au._occlusionTextureProp=nY.getByName("material_OcclusionTexture"),au._clearCoatProp=nY.getByName("material_ClearCoat"),au._clearCoatTextureProp=nY.getByName("material_ClearCoatTexture"),au._clearCoatRoughnessProp=nY.getByName("material_ClearCoatRoughness"),au._clearCoatRoughnessTextureProp=nY.getByName("material_ClearCoatRoughnessTexture"),au._clearCoatNormalTextureProp=nY.getByName("material_ClearCoatNormalTexture");var ad=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n,ro.find("pbr"))||this)._anisotropyRotation=0,r._iridescenceRange=new tB(100,400);var r,a=r.shaderData;return a.setFloat(t._metallicProp,1),a.setFloat(t._roughnessProp,1),a.setFloat(t._iorProp,1.5),a.setVector3(t._anisotropyInfoProp,new tT(1,0,0)),a.setVector4(t._iridescenceInfoProp,new tI(0,1.3,100,400)),r._iridescenceRange._onValueChanged=r._onIridescenceRangeChanged.bind(r),r}tW(t,e);var n=t.prototype;return n._onIridescenceRangeChanged=function(){var e=this.shaderData.getVector4(t._iridescenceInfoProp);e.z=this._iridescenceRange.x,e.w=this._iridescenceRange.y},n.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(t._anisotropyInfoProp).z},set:function(e){var n=this.shaderData.getVector3(t._anisotropyInfoProp);!!n.z!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),n.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var n=this.shaderData.getVector3(t._anisotropyInfoProp),r=tC.degreeToRadFactor*e;n.x=Math.cos(r),n.y=Math.sin(r)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(t._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(t._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}},{key:"iridescence",get:function(){return this.shaderData.getVector4(t._iridescenceInfoProp).x},set:function(e){e=Math.max(0,Math.min(1,e));var n=this.shaderData.getVector4(t._iridescenceInfoProp);!!n.x!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_IRIDESCENCE"):this.shaderData.enableMacro("MATERIAL_ENABLE_IRIDESCENCE")),n.x=e}},{key:"iridescenceTexture",get:function(){return this.shaderData.getTexture(t._iridescenceTextureProp)},set:function(e){this.shaderData.setTexture(t._iridescenceTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_IRIDESCENCE_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_IRIDESCENCE_TEXTURE")}},{key:"iridescenceIOR",get:function(){return this.shaderData.getVector4(t._iridescenceInfoProp).y},set:function(e){this.shaderData.getVector4(t._iridescenceInfoProp).y=Math.max(e,1)}},{key:"iridescenceThicknessRange",get:function(){return this._iridescenceRange},set:function(e){this._iridescenceRange!==e&&this._iridescenceRange.copyFrom(e)}},{key:"iridescenceThicknessTexture",get:function(){return this.shaderData.getTexture(t._iridescenceThicknessTextureProp)},set:function(e){this.shaderData.setTexture(t._iridescenceThicknessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE")}}]),t}(au);ad._metallicProp=nY.getByName("material_Metal"),ad._roughnessProp=nY.getByName("material_Roughness"),ad._roughnessMetallicTextureProp=nY.getByName("material_RoughnessMetallicTexture"),ad._iorProp=nY.getByName("material_IOR"),ad._anisotropyInfoProp=nY.getByName("material_AnisotropyInfo"),ad._anisotropyTextureProp=nY.getByName("material_AnisotropyTexture"),ad._iridescenceInfoProp=nY.getByName("material_IridescenceInfo"),ad._iridescenceThicknessTextureProp=nY.getByName("material_IridescenceThicknessTexture"),ad._iridescenceTextureProp=nY.getByName("material_IridescenceTexture");var ah=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,ro.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new tO(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var n=this.shaderData.getColor(t._specularColorProp);e!==n&&n.copyFrom(e)}},{key:"glossiness",get:function(){return this.shaderData.getFloat(t._glossinessProp)},set:function(e){this.shaderData.setFloat(t._glossinessProp,e)}},{key:"specularGlossinessTexture",get:function(){return this.shaderData.getTexture(t._specularGlossinessTextureProp)},set:function(e){this.shaderData.setTexture(t._specularGlossinessTextureProp,e),e?this.shaderData.enableMacro(t._specularGlossinessTextureMacro):this.shaderData.disableMacro(t._specularGlossinessTextureMacro)}}]),t}(au);ah._specularColorProp=nY.getByName("material_PBRSpecularColor"),ah._glossinessProp=nY.getByName("material_Glossiness"),ah._specularGlossinessTextureProp=nY.getByName("material_SpecularGlossinessTexture"),ah._specularGlossinessTextureMacro=nH.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var a_=/*#__PURE__*/function(e){function t(n){var r,a=(r=e.call(this,n,ro.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new tO(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}}]),t}(as),af=/*#__PURE__*/function(){function e(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new nM,this._dirty=7,n&&n.length!==t.length)throw"deltaNormals length must same with deltaPositions length.";if(r&&r.length!==t.length)throw"deltaTangents length must same with deltaPositions length.";this.weight=e,this._deltaPositions=t,this._deltaNormals=n,this._deltaTangents=r}return e.prototype._releaseData=function(){this._deltaPositions=null,this._deltaNormals=null,this._deltaTangents=null},tG(e,[{key:"deltaPositions",get:function(){return this._deltaPositions},set:function(e){this._deltaPositions=e,this._dirty|=1,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaNormals",get:function(){return this._deltaNormals},set:function(e){this._deltaNormals=e,this._dirty|=2,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaTangents",get:function(){return this._deltaTangents},set:function(e){this._deltaTangents=e,this._dirty|=4,this._dataChangeManager.dispatch(this._dirty,this)}}]),e}(),ap=((ef={})[ef.Position=1]="Position",ef[ef.Normal=2]="Normal",ef[ef.Tangent=4]="Tangent",ef[ef.All=7]="All",ef),am=/*#__PURE__*/function(){function e(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new nM,this._dataChangeManager=new nM,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}var t=e.prototype;return t.addFrame=function(e,t,n,r){if("number"==typeof e){var a=new af(e,t,n,r);return this._addFrame(a),a}this._addFrame(e)},t.clearFrames=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._dataChangeManager.removeListener(this._frameDataChangeListener);e.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},t._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},t._addFrame=function(e){var t=this._frames,n=t.length;if(n>0&&e.deltaPositions.length!==t[n-1].deltaPositions.length)throw"Frame's deltaPositions length must same with before frame deltaPositions length.";this._frames.push(e),this._frameDataChangeListener(ap.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},t._updateUseNormalAndTangent=function(e,t){var n=this._useBlendShapeNormal&&e,r=this._useBlendShapeTangent&&t;(this._useBlendShapeNormal!==n||this._useBlendShapeTangent!==r)&&(this._useBlendShapeNormal=n,this._useBlendShapeTangent=r,this._layoutChangeManager.dispatch(0,this))},t._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},tG(e,[{key:"frames",get:function(){return this._frames}}]),e}(),ag=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._format=t}return tG(e,[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),e}(),av=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=ar.Triangles),this.start=e,this.count=t,this.topology=n},ay=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tW(t,e),t.prototype.dispose=function(){},t}(av),ax=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableVAO=!0,n.instanceCount=0,n.vertexBufferBindings=[],n._vertexElementMap={},n._bufferStructChanged=!1,n._vertexElements=[],n._platformPrimitive=t._hardwareRenderer.createPlatformPrimitive(n),n}tW(t,e);var n=t.prototype;return n.addVertexElement=function(e){var t=this._vertexElementMap,n=this._vertexElements,r=e.attribute,a=t[r];a&&(console.warn("VertexElement "+r+" already exists."),n.splice(n.indexOf(a),1)),t[r]=e,n.push(e),this._bufferStructChanged=!0},n.removeVertexElement=function(e){var t=this._vertexElements,n=t[e];t.splice(e,1),delete this._vertexElementMap[n.attribute],this._bufferStructChanged=!0},n.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},n.setVertexElement=function(e,t){var n=this._vertexElementMap,r=this._vertexElements,a=r[e];a&&delete n[a.attribute],n[t.attribute]=t,r[e]=t,this._bufferStructChanged=!0},n.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,n=this._vertexElements,r=e,a=n.length;r<a;r++){var i=n[r];delete t[i.attribute]}n.length=e},n.setVertexBufferBinding=function(e,t){var n,r=this._getReferCount(),a=this.vertexBufferBindings;r>0&&(null==(n=a[e])||n.buffer._addReferCount(-r),null==t||t.buffer._addReferCount(r)),a[e]=t,this._bufferStructChanged=!0},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this.vertexBufferBindings,r=e.length,a=t+r;n.length<a&&(n.length=a);for(var i=0;i<r;i++)this.setVertexBufferBinding(t+i,e[i])},n.setIndexBufferBinding=function(e){var t=this.indexBufferBinding,n=this._getReferCount();t!==e&&(this._indexBufferBinding=e,n>0&&(null==t||t.buffer._addReferCount(-n)),e?(n>0&&e.buffer._addReferCount(n),this._glIndexType=ae._getGLIndexType(e.format),this._glIndexByteCount=ae._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},n.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},n._addReferCount=function(t){e.prototype._addReferCount.call(this,t);for(var n,r,a=this.vertexBufferBindings,i=0,o=a.length;i<o;i++)null==(r=a[i])||r.buffer._addReferCount(t);null==(n=this.indexBufferBinding)||n._buffer._addReferCount(t)},n._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},tG(t,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t}(ne),ab=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._updateFlagManager=new nM,r._bounds=new tE,r._subMeshes=[],r.name=n,r._primitive=new ax(t),r._onBoundsChanged=r._onBoundsChanged.bind(r);var r,a=r._bounds;return a.min._onValueChanged=r._onBoundsChanged,a.max._onValueChanged=r._onBoundsChanged,r}tW(t,e);var n=t.prototype;return n.addSubMesh=function(e,t,n){return void 0===n&&(n=ar.Triangles),"number"==typeof e&&(e=new ay(e,t,n)),this._subMeshes.push(e),e},n.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},n.clearSubMesh=function(){this._subMeshes.length=0},n._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},n._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},n._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},n._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},n._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},n._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},n._addReferCount=function(t){e.prototype._addReferCount.call(this,t),this._primitive._addReferCount(t)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._primitive.destroy()},n._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},n._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},n._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},tG(t,[{key:"bounds",get:function(){return this._bounds},set:function(e){this._bounds!==e&&this._bounds.copyFrom(e)}},{key:"subMesh",get:function(){return this._subMeshes[0]||null}},{key:"subMeshes",get:function(){return this._subMeshes}}]),t}(t1),aS=((ep={})[ep.Bounds=1]="Bounds",ep[ep.VertexElements=2]="VertexElements",ep),aC=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._stride=t}return tG(e,[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),e}(),aT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}tW(t,e);var n=t.prototype;return n.setVertexElements=function(e){this._setVertexElements(e)},n.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,a=void 0!==r.buffer;a||(r=new aC(e,t));var i=this._primitive.vertexBufferBindings;i.length<=n&&(i.length=n+1),this._setVertexBufferBinding(a?t:n,r)},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this._primitive.vertexBufferBindings,r=e.length,a=t+r;n.length<a&&(n.length=a);for(var i=0;i<r;i++)this._setVertexBufferBinding(t+i,e[i])},n.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new ag(e,t))),this._setIndexBufferBinding(n)},tG(t,[{key:"instanceCount",get:function(){return this._primitive.instanceCount},set:function(e){this._primitive.instanceCount=e}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"indexBufferBinding",get:function(){return this._primitive.indexBufferBinding}},{key:"vertexElements",get:function(){return this._primitive.vertexElements}}]),t}(ab),aA=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._enableVertexColor=!1,n._onMeshChanged=n._onMeshChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){var t=this._mesh;t&&(t.destroyed||this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),e.prototype._onDestroy.call(this)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.mesh=this._mesh},n._prepareRender=function(t){if(!this._mesh){no.error("mesh is null.");return}if(this._mesh.destroyed){no.error("mesh is destroyed.");return}e.prototype._prepareRender.call(this,t)},n._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;tE.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},n._render=function(e){var n=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,a=n._primitive.vertexElements;r.disableMacro(t._uvMacro),r.disableMacro(t._uv1Macro),r.disableMacro(t._normalMacro),r.disableMacro(t._tangentMacro),r.disableMacro(t._enableVertexColorMacro);for(var i=0,o=a.length;i<o;i++)switch(a[i].attribute){case"TEXCOORD_0":r.enableMacro(t._uvMacro);break;case"TEXCOORD_1":r.enableMacro(t._uv1Macro);break;case"NORMAL":r.enableMacro(t._normalMacro);break;case"TANGENT":r.enableMacro(t._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(t._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}var s=this._materials,l=this._engine,c=n.subMeshes,u=l._renderElementPool.get();u.set(this.priority,this._distanceForSort);for(var d=l._subRenderElementPool,h=0,_=c.length;h<_;h++){var f=s[h];if(f){(f.destroyed||f.shader.destroyed)&&(f=this.engine._meshMagentaMaterial);var p=d.get();p.set(this,f,n._primitive,c[h]),u.addSubRenderElement(p)}}e.camera._renderPipeline.pushRenderElement(e,u)},n._setMesh=function(e){var t=this._mesh;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},n._onMeshChanged=function(e){e&aS.Bounds&&(this._dirtyUpdateFlag|=rv.WorldVolume),e&aS.VertexElements&&(this._dirtyUpdateFlag|=2)},tG(t,[{key:"mesh",get:function(){return this._mesh},set:function(e){this._mesh!==e&&this._setMesh(e)}},{key:"enableVertexColor",get:function(){return this._enableVertexColor},set:function(e){e!==this._enableVertexColor&&(this._dirtyUpdateFlag|=2,this._enableVertexColor=e)}}]),t}(e.Renderer);aA._uvMacro=nH.getByName("RENDERER_HAS_UV"),aA._uv1Macro=nH.getByName("RENDERER_HAS_UV1"),aA._normalMacro=nH.getByName("RENDERER_HAS_NORMAL"),aA._tangentMacro=nH.getByName("RENDERER_HAS_TANGENT"),aA._enableVertexColorMacro=nH.getByName("RENDERER_ENABLE_VERTEXCOLOR"),tX([tq],aA.prototype,"_mesh",void 0),tX([tq],aA.prototype,"_onMeshChanged",null);var aE=/*#__PURE__*/function(){function e(e,t){this._blendShapeCount=0,this._blendShapes=[],this._subDataDirtyFlags=[],this._vertexBuffers=[],this._uniformOccupiesCount=0,this._bufferBindingOffset=-1,this._vertexElementOffset=0,this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._storeInVertexBufferInfo=[],this._maxCountSingleVertexBuffer=0,this._lastHostCreatedInfo=new tI,this._canUseTextureStoreData=!0,this._dataTextureInfo=new tT,this._engine=e,this._modelMesh=t,this._canUseTextureStoreData=this._engine._hardwareRenderer.capability.canUseFloatTextureBlendShape,this._updateLayoutChange=this._updateLayoutChange.bind(this)}var t=e.prototype;return t._addBlendShape=function(e){this._blendShapes.push(e),this._blendShapeCount++,e._layoutChangeManager.addListener(this._updateLayoutChange),this._updateLayoutChange(0,e),this._subDataDirtyFlags.push(e._dataChangeManager.createFlag(rf))},t._clearBlendShapes=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._layoutChangeManager.removeListener(this._updateLayoutChange);this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._blendShapes.length=0,this._blendShapeCount=0;for(var r=this._subDataDirtyFlags,a=0,i=r.length;a<i;a++)r[a].destroy();r.length=0},t._updateShaderData=function(t,n){var r=this._blendShapeCount;if(r>0){if(t.enableMacro(e._blendShapeMacro),this._useTextureMode())t.enableMacro(e._blendShapeTextureMacro),t.setTexture(e._blendShapeTextureProperty,this._vertexTexture),t.setVector3(e._blendShapeTextureInfoProperty,this._dataTextureInfo),t.setFloatArray(e._blendShapeWeightsProperty,n.blendShapeWeights),t.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var a=this._getVertexBufferModeSupportCount();if(r>a){var i=n._condensedBlendShapeWeights;i||(i=new Float32Array(a),n._condensedBlendShapeWeights=i),this._filterCondensedBlendShapeWeights(n.blendShapeWeights,i),t.setFloatArray(e._blendShapeWeightsProperty,i),this._modelMesh._primitive.enableVAO=!1,r=a}else t.setFloatArray(e._blendShapeWeightsProperty,n.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;t.disableMacro(e._blendShapeTextureMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?t.enableMacro(e._blendShapeNormalMacro):t.disableMacro(e._blendShapeNormalMacro),this._useBlendTangent?t.enableMacro(e._blendShapeTangentMacro):t.disableMacro(e._blendShapeTangentMacro)}else t.disableMacro(e._blendShapeMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT")},t._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},t._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},t._vertexElementsNeedUpdate=function(){var e=this._getVertexBufferModeSupportCount(),t=this._lastHostCreatedInfo;return Math.min(t.x,e)!==Math.min(this._blendShapeCount,e)||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent},t._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},t._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,n=e._primitive.vertexBufferBindings,r=0,a=Math.max(n.length,t+1);r<a&&(n[r]||r===t);r++);this._bufferBindingOffset=r}},t._addVertexElements=function(e){this._updateVertexBufferIndex();for(var t=this._vertexElementOffset,n=this._bufferBindingOffset,r=0,a=0,i=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());a<i;a++)e._setVertexElement(t++,new at("POSITION_BS"+a,r,r7.Vector3,n)),r+=12,this._useBlendNormal&&(e._setVertexElement(t++,new at("NORMAL_BS"+a,r,r7.Vector3,n)),r+=12),this._useBlendTangent&&(e._setVertexElement(t++,new at("TANGENT_BS"+a,r,r7.Vector3,n)),r+=12);return t},t._update=function(e){var t=this._modelMesh.vertexCount,n=this._useTextureMode(),r=this._isCreateHost(t);r&&(n?this._createTextureArray(t):this._createVertexBuffers(t,e),this._lastHostCreatedInfo.set(this._blendShapeCount,+this._useBlendNormal,+this._useBlendTangent,t)),this._needUpdateData()&&(n?this._updateTextureArray(t,r):this._updateVertexBuffers(t,r))},t._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},t._createVertexBuffers=function(e,t){var n=this._engine,r=this._modelMesh,a=this._blendShapeCount,i=this._vertexBuffers,o=3*this._vertexElementCount,s=4*o,l=Math.floor(255/s),c=Math.ceil(a/l),u=o*e*Math.min(l,a);i.length=c,this._vertices=new Float32Array(u),this._maxCountSingleVertexBuffer=l,this._storeInVertexBufferInfo.length=a;for(var d=this._bufferBindingOffset,h=0;h<c;h++){var _=c-1,f=(h===_?a-_*l:l)*s,p=f*e,m=t?r8.Static:r8.Dynamic,g=new r9(n,an.VertexBuffer,p,m);r._setVertexBufferBinding(d+h,new aC(g,f)),i[h]=g}},t._createTextureArray=function(e){var t=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,r=n*e,a=1;r>t&&(a=Math.ceil(r/t),r=t);var i=this._vertexTexture,o=this._blendShapes.length;i&&i.destroy(),(i=new nu(this._engine,r,a,o,t9.R32G32B32A32,!1)).filterMode=t5.Point,this._vertices=new Float32Array(o*r*a*4),this._vertexTexture=i,this._dataTextureInfo.set(n,r,a)},t._updateVertexBuffers=function(e,t){for(var n=this._blendShapes,r=this._maxCountSingleVertexBuffer,a=this._vertices,i=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,u=this._bufferBindingOffset,d=0,h=n.length;d<h;d++){var _=s[d];if(t||_.flag){var f=n[d].frames,p=f.length,m=f[p-1];if(p>0&&m.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var g=Math.floor(d/r),v=d%r,y=i[g],x=y.byteLength/(4*e),b=v*l,S=o[d];S||(o[d]=S=new tB),S.set(u+g,v*c);for(var C=m.deltaPositions,T=0;T<e;T++){var A=b+x*T,E=C[T];E&&(a[A]=E.x,a[A+1]=E.y,a[A+2]=E.z)}if(b+=3,this._useBlendNormal){var R=m.deltaNormals;if(R)for(var M=0;M<e;M++){var w=b+x*M,P=R[M];P&&(a[w]=P.x,a[w+1]=P.y,a[w+2]=P.z)}b+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=b+x*L,B=F[L];B&&(a[D]=B.x,a[D+1]=B.y,a[D+2]=B.z)}b+=3}(v===r-1||d===h-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},t._updateTextureArray=function(e,t){for(var n=this._blendShapes,r=this._vertexTexture,a=this._vertices,i=this._subDataDirtyFlags,o=0,s=n.length;o<s;o++){var l=i[o],c=r.width*r.height*4;if(t||l.flag){var u=n[o].frames,d=u.length,h=u[d-1];if(d>0&&h.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var _=h.deltaPositions,f=h.deltaNormals,p=h.deltaTangents,m=o*c,g=0;g<e;g++){var v=_[g];if(a[m]=v.x,a[m+1]=v.y,a[m+2]=v.z,m+=4,f){var y=f[g];a[m]=y.x,a[m+1]=y.y,a[m+2]=y.z,m+=4}if(p){var x=p[g];a[m]=x.x,a[m+1]=x.y,a[m+2]=x.z,m+=4}}l.flag=!1}}r.setPixelBuffer(0,a)},t._updateLayoutChange=function(e,t){var n=this._blendShapeCount>1,r=1,a=t._useBlendShapeNormal,i=t._useBlendShapeTangent;n&&(a&&(a=this._useBlendNormal),i&&(i=this._useBlendTangent)),a&&r++,i&&r++,this._useBlendNormal=a,this._useBlendTangent=i,this._vertexElementCount=r},t._attributeModeUpdateVertexElement=function(e,t,n,r){var a=this._vertexElementOffset+this._vertexElementCount*r,i=t[n],o=i.x,s=i.y,l=e[a];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++a];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++a];s+=12,u.bindingIndex=o,u.offset=s}},t._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},t._filterCondensedBlendShapeWeights=function(e,t){for(var n,r=t.length,a=this._modelMesh._primitive.vertexElements,i=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<r)this._attributeModeUpdateVertexElement(a,i,s,s),t[s]=c,c<o&&(o=c,n=s);else if(c>o){this._attributeModeUpdateVertexElement(a,i,s,n),t[n]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<r;u++){var d=t[u];d<o&&(o=d,n=u)}}}},e}();aE._blendShapeMacro=nH.getByName("RENDERER_HAS_BLENDSHAPE"),aE._blendShapeTextureMacro=nH.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),aE._blendShapeNormalMacro=nH.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),aE._blendShapeTangentMacro=nH.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),aE._blendShapeWeightsProperty=nY.getByName("renderer_BlendShapeWeights"),aE._blendShapeTextureProperty=nY.getByName("renderer_BlendShapeTexture"),aE._blendShapeTextureInfoProperty=nY.getByName("renderer_BlendShapeTextureInfo");var aR=((em={}).Position="POSITION",em.Normal="NORMAL",em.Color="COLOR_0",em.Tangent="TANGENT",em.BoneWeight="WEIGHTS_0",em.BoneIndex="JOINTS_0",em.UV="TEXCOORD_0",em.UV1="TEXCOORD_1",em.UV2="TEXCOORD_2",em.UV3="TEXCOORD_3",em.UV4="TEXCOORD_4",em.UV5="TEXCOORD_5",em.UV6="TEXCOORD_6",em.UV7="TEXCOORD_7",em),aM=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._internalVertexBufferIndex=-1,r._vertexCount=0,r._vertexCountDirty=!1,r._dataVersionCounter=0,r._positions=null,r._normals=null,r._colors=null,r._tangents=null,r._uv=null,r._uv1=null,r._uv2=null,r._uv3=null,r._uv4=null,r._uv5=null,r._uv6=null,r._uv7=null,r._boneWeights=null,r._boneIndices=null,r._advancedElementUpdateFlag=0,r._advancedDataUpdateFlag=0,r._advancedVertexDataVersions=Array(14),r._advancedDataSyncToBuffer=!1,r._internalVertexBufferStride=0,r._internalVertexBufferCreatedInfo=new tT(0,0,-1),r._internalVertexElementsOffset=0,r._internalVertexElementsFlags=0,r._vertexBufferInfos=[],r._indices=null,r._indicesFormat=null,r._indicesChangeFlag=!1,r._accessible=!0,r.name=n,r._blendShapeManager=new aE(t,r),r}tW(t,e);var n=t.prototype;return n.setPositions=function(e){var t;(this._positions||e)&&(this._updateAdvancedVertexDataMarks(1,0),this._positions=e,this._vertexCount=null!=(t=null==e?void 0:e.length)?t:0,this._vertexCountDirty=!1)},n.getPositions=function(){var e=this._getVertexElementData(this._positions,aR.Position,0,this._readVector3VertexData);return this._positions=e,e},n.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},n.getNormals=function(){var e=this._getVertexElementData(this._normals,aR.Normal,1,this._readVector3VertexData);return this._normals=e,e},n.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},n.getColors=function(){var e=this._getVertexElementData(this._colors,aR.Color,2,this._readColorVertexData);return this._colors=e,e},n.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},n.getBoneWeights=function(){var e=this._getVertexElementData(this._boneWeights,aR.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=e,e},n.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},n.getBoneIndices=function(){var e=this._getVertexElementData(this._boneIndices,aR.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=e,e},n.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},n.getTangents=function(){var e=this._getVertexElementData(this._tangents,aR.Tangent,3,this._readVector4VertexData);return this._tangents=e,e},n.setUVs=function(e,t){switch(t=null!=t?t:0){case 0:this._beforeSetAdvancedVertexData(e,64,6),this._uv=e;break;case 1:this._beforeSetAdvancedVertexData(e,128,7),this._uv1=e;break;case 2:this._beforeSetAdvancedVertexData(e,256,8),this._uv2=e;break;case 3:this._beforeSetAdvancedVertexData(e,512,9),this._uv3=e;break;case 4:this._beforeSetAdvancedVertexData(e,1024,10),this._uv4=e;break;case 5:this._beforeSetAdvancedVertexData(e,2048,11),this._uv5=e;break;case 6:this._beforeSetAdvancedVertexData(e,4096,12),this._uv6=e;break;case 7:this._beforeSetAdvancedVertexData(e,8192,13),this._uv7=e;break;default:throw"The index of channel needs to be in range [0 - 7]."}},n.getUVs=function(e){switch(e=null!=e?e:0){case 0:var t=this._getVertexElementData(this._uv,aR.UV,6,this._readVector2VertexData);return this._uv=t,t;case 1:var n=this._getVertexElementData(this._uv1,aR.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var r=this._getVertexElementData(this._uv2,aR.UV2,8,this._readVector2VertexData);return this._uv2=r,r;case 3:var a=this._getVertexElementData(this._uv3,aR.UV3,9,this._readVector2VertexData);return this._uv3=a,a;case 4:var i=this._getVertexElementData(this._uv4,aR.UV4,10,this._readVector2VertexData);return this._uv4=i,i;case 5:var o=this._getVertexElementData(this._uv5,aR.UV5,11,this._readVector2VertexData);return this._uv5=o,o;case 6:var s=this._getVertexElementData(this._uv6,aR.UV6,12,this._readVector2VertexData);return this._uv6=s,s;case 7:var l=this._getVertexElementData(this._uv7,aR.UV7,13,this._readVector2VertexData);return this._uv7=l,l}throw"The index of channel needs to be in range [0 - 7]."},n.setIndices=function(e){this._indices!==e&&(this._indices=e,tK(e,Uint8Array)?this._indicesFormat=r6.UInt8:tK(e,Uint16Array)?this._indicesFormat=r6.UInt16:tK(e,Uint32Array)&&(this._indicesFormat=r6.UInt32)),this._indicesChangeFlag=!0},n.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},n.setVertexElements=function(e){this._clearVertexElements();for(var t,n=e.length,r=0;r<n;r++)this._addVertexElement(e[r]);var a=this._primitive._vertexElementMap;a[aR.Position]||this.setPositions(null),a[aR.Normal]||this.setNormals(null),a[aR.Color]||this.setColors(null),a[aR.BoneWeight]||this.setBoneWeights(null),a[aR.BoneIndex]||this.setBoneIndices(null),a[aR.Tangent]||this.setTangents(null),a[aR.UV]||this.setUVs(null,0),a[aR.UV1]||this.setUVs(null,1),a[aR.UV2]||this.setUVs(null,2),a[aR.UV3]||this.setUVs(null,3),a[aR.UV4]||this.setUVs(null,4),a[aR.UV5]||this.setUVs(null,5),a[aR.UV6]||this.setUVs(null,6),a[aR.UV7]||this.setUVs(null,7);var i=this._internalVertexBufferCreatedInfo.z;-1!==i&&(null==(t=this._primitive.vertexBufferBindings[i])||t.buffer.destroy(),this._setVertexBufferBinding(i,null),this._internalVertexBufferCreatedInfo.z=-1),this._internalVertexBufferStride=0,this._internalVertexElementsOffset=n,this._advancedElementUpdateFlag=0,this._vertexCountDirty=!0,this._blendShapeManager._bufferBindingOffset=-1,this._blendShapeManager._vertexElementOffset=n},n.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,a=void 0!==r.buffer;a||(r=new aC(e,t));var i=a?t:n,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=i+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(i,r),i===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),i===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=e.length,r=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=t+n;r.length<i&&(r.length=i,a.length=i);for(var o=0;o<n;o++){var s=t+o;this._setVertexBufferBinding(s,e[o]),s===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),s===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1)}this._vertexCountDirty=!0},n.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},n.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},n.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},n.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},n.uploadData=function(e){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(e),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var t=this._vertexBufferInfos,n=this._primitive.vertexBufferBindings,r=0,a=n.length;r<a;r++){var i=t[r];if(null==i?void 0:i.uploadAdvancedData){var o,s=null==(o=n[r])?void 0:o.buffer;s.setData(s.data),i.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var l,c=this._indices,u=null==(l=this._primitive.indexBufferBinding)?void 0:l._buffer;if(c){if(u&&c.byteLength==u.byteLength)u.setData(c),this._primitive.indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new ag(u,this._indicesFormat));else{null==u||u.destroy();var d=new r9(this._engine,an.IndexBuffer,c);this._setIndexBufferBinding(new ag(d,this._indicesFormat))}}else u&&(u.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var h=this._blendShapeManager;h._blendShapeCount>0&&h._update(e),e&&(this._accessible=!1,this._releaseCache(!1))},n.calculateTangents=function(){var e=this.getPositions(),n=this.getNormals(),r=this.getUVs();if(!n||!r)throw"Set normal and uv before calculation.";for(var a=this._indices,i=this.vertexCount,o=t._tempVec0,s=t._tempVec1,l=t._tempVec2,c=t._tempVec3,u=t._tempVec4,d=a?a.length/3:e.length/3,h=Array(i),_=Array(i),f=0;f<i;f++)h[f]=new tI,_[f]=new tT;for(var p=0;p<d;p++){var m=3*p,g=3*p+1,v=3*p+2;a&&(m=a[m],g=a[g],v=a[v]);var y=e[m],x=e[g],b=e[v],S=r[m],C=r[g],T=r[v];tT.subtract(x,y,o),tT.subtract(b,y,s);var A=C.x-S.x,E=T.x-S.x,R=C.y-S.y,M=T.y-S.y,w=1/(A*M-E*R);tT.scale(o,M*w,l),tT.scale(s,R*w,u),tT.subtract(l,u,l),tT.scale(s,A*w,c),tT.scale(o,E*w,u),tT.subtract(c,u,c);var P=h[m];P.set(P.x+l.x,P.y+l.y,P.z+l.z,1),(P=h[g]).set(P.x+l.x,P.y+l.y,P.z+l.z,1),(P=h[v]).set(P.x+l.x,P.y+l.y,P.z+l.z,1),_[m].add(c),_[g].add(c),_[v].add(c)}for(var F=0;F<i;F++){var L=n[F],D=_[F],B=h[F];l.set(B.x,B.y,B.z),tT.cross(l,D,u);var I=tT.dot(u,L)>0?1:-1;tT.scale(L,tT.dot(l,L),u),tT.subtract(l,u,l),l.normalize(),B.set(l.x,l.y,l.z,I)}this.setTangents(h)},n._setVertexBufferBinding=function(t,n){var r=this,a=this._primitive.vertexBufferBindings,i=this._vertexBufferInfos,o=function(){r._advancedDataSyncToBuffer||(i[t].dataVersion=r._dataVersionCounter++)},s=a[t];s&&s.buffer._dataUpdateManager.removeListener(o),e.prototype._setVertexBufferBinding.call(this,t,n),n?(n.buffer._dataUpdateManager.addListener(o),(i[t]||(i[t]=new aw)).reset(),o()):t+1==a.length&&a.length--},n._getVertexTypedArray=function(e,t){switch(t){case nQ.BYTE:return new Int8Array(e);case nQ.UNSIGNED_BYTE:return new Uint8Array(e);case nQ.SHORT:return new Int16Array(e);case nQ.UNSIGNED_SHORT:return new Uint16Array(e);case nQ.FLOAT:return new Float32Array(e)}},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._releaseCache(!0)},n._getVertexElementData=function(e,t,n,r){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[n])?a:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[n]=l,r.call(this,t))},n._beforeSetAdvancedVertexData=function(e,t,n){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";this._updateAdvancedVertexDataMarks(t,n)},n._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},n._updateInternalVertexBuffer=function(e){var t=this._internalVertexBufferStride,n=this.vertexCount,r=this._internalVertexBufferCreatedInfo,a=t*n;if(r.x*r.y!==a){var i,o=r.z;-1!==o&&(null==(i=this._primitive.vertexBufferBindings[o])||i.buffer.destroy(),this._setVertexBufferBinding(o,null));var s=this._internalVertexBufferIndex,l=t*this.vertexCount>0;if(l){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var c=e?r8.Static:r8.Dynamic,u=new r9(this._engine,an.VertexBuffer,a,c,!0);this._setVertexBufferBinding(s,new aC(u,t))}r.set(t,n,l?s:-1)}},n._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new tB(e[t],e[t+1])})},n._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new tT(e[t],e[t+1],e[t+2])})},n._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new tI(e[t],e[t+1],e[t+2],e[t+3])})},n._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new tO(e[t],e[t+1],e[t+2],e[t+3])})},n._readVertexData=function(e,t){var n=this._primitive,r=n._vertexElementMap[e];if(!r)return null;var a=n.vertexBufferBindings[r.bindingIndex],i=null==a?void 0:a.buffer;if(!i)return null;if(!i.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var o=this.vertexCount,s=r._formatMetaInfo,l=Array(o),c=this._getVertexTypedArray(i.data.buffer,s.type),u=r.offset,d=a.stride,h=0;h<o;h++){var _=(h*d+u)/c.BYTES_PER_ELEMENT,f=t(c,_);s.normalized&&f.scale(s.normalizedScaleFactor),l[h]=f}return l},n._updateAdvancedVertexElement=function(e,t,n){var r=this._primitive._vertexElementMap;if(e){if(!r[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new at(t,i,a,o)),this._internalVertexBufferStride+=this._getAttributeByteLength(t),this._internalVertexElementsFlags|=n,this._blendShapeManager._vertexElementOffset++}}else{var s=r[t];if(s){var l=this._primitive.vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~n):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},n._updateAdvancedVertexElements=function(){var e=this._advancedElementUpdateFlag;1&e&&this._updateAdvancedVertexElement(this._positions,aR.Position,1),2&e&&this._updateAdvancedVertexElement(this._normals,aR.Normal,2),4&e&&this._updateAdvancedVertexElement(this._colors,aR.Color,4),16&e&&this._updateAdvancedVertexElement(this._boneWeights,aR.BoneWeight,16),32&e&&this._updateAdvancedVertexElement(this._boneIndices,aR.BoneIndex,32),8&e&&this._updateAdvancedVertexElement(this._tangents,aR.Tangent,8),64&e&&this._updateAdvancedVertexElement(this._uv,aR.UV,64),128&e&&this._updateAdvancedVertexElement(this._uv1,aR.UV1,128),256&e&&this._updateAdvancedVertexElement(this._uv2,aR.UV2,256),512&e&&this._updateAdvancedVertexElement(this._uv3,aR.UV3,512),1024&e&&this._updateAdvancedVertexElement(this._uv4,aR.UV4,1024),2048&e&&this._updateAdvancedVertexElement(this._uv5,aR.UV5,2048),4096&e&&this._updateAdvancedVertexElement(this._uv6,aR.UV6,4096),8192&e&&this._updateAdvancedVertexElement(this._uv7,aR.UV7,8192)},n._updateVertexElements=function(){var e=this._primitive.vertexElements,t=this._blendShapeManager,n=e.length,r=t._vertexElementOffset;65535&this._advancedElementUpdateFlag&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var a=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(r!==t._vertexElementOffset||a&&t._blendShapeCount>0){var i=t._addVertexElements(this);i<n&&this._setVertexElementsLength(i)}},n._writeVector2AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y)})},n._writeVector3AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z)})},n._writeVector4AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z,e[t+3]=a.w)})},n._writeColorAdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.r,e[t+1]=a.g,e[t+2]=a.b,e[t+3]=a.a)})},n._writeAdvancedVertexData=function(e,t,n){var r,a=this._primitive,i=a._vertexElementMap[e],o=i.bindingIndex,s=a.vertexBufferBindings[o],l=null==s?void 0:s.buffer;if(l){if(!l.readable)throw"Vertex buffer is not readable, can't write vertex data.";var c=null!=(r=this._advancedVertexDataVersions[t])?r:-1,u=this._vertexBufferInfos[o];if(c>u.dataVersion){for(var d=i._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,d.type),_=i.offset,f=s.stride,p=h.BYTES_PER_ELEMENT,m=d.normalized,g=d.size,v=d.normalizedScaleFactor,y=0,x=this._vertexCount;y<x;y++){var b=(y*f+_)/p;if(n(h,b,y),m)for(var S=0;S<g;S++)h[b+S]/=v}u.uploadAdvancedData=!0}}},n._updateAdvancedVertices=function(){var e=this._positions,t=this._normals,n=this._colors,r=this._advancedDataUpdateFlag,a=this._boneWeights,i=this._boneIndices,o=this._tangents,s=this._uv,l=this._uv1,c=this._uv2,u=this._uv3,d=this._uv4,h=this._uv5,_=this._uv6,f=this._uv7;1&r&&this._writeVector3AdvancedVertexData(aR.Position,0,e),t&&2&r&&this._writeVector3AdvancedVertexData(aR.Normal,1,t),n&&4&r&&this._writeColorAdvancedVertexData(aR.Color,2,n),a&&16&r&&this._writeVector4AdvancedVertexData(aR.BoneWeight,4,a),i&&32&r&&this._writeVector4AdvancedVertexData(aR.BoneIndex,5,i),o&&8&r&&this._writeVector4AdvancedVertexData(aR.Tangent,3,o),s&&64&r&&this._writeVector2AdvancedVertexData(aR.UV,6,s),l&&128&r&&this._writeVector2AdvancedVertexData(aR.UV1,7,l),c&&256&r&&this._writeVector2AdvancedVertexData(aR.UV2,8,c),u&&512&r&&this._writeVector2AdvancedVertexData(aR.UV3,9,u),d&&1024&r&&this._writeVector2AdvancedVertexData(aR.UV4,10,d),h&&2048&r&&this._writeVector2AdvancedVertexData(aR.UV5,11,h),_&&4096&r&&this._writeVector2AdvancedVertexData(aR.UV6,12,_),f&&8192&r&&this._writeVector2AdvancedVertexData(aR.UV7,13,f),this._advancedDataUpdateFlag=0},n._getInternalVertexBufferIndex=function(){var e=this._internalVertexBufferIndex;if(-1!==e)return e;for(var t=0,n=this._primitive.vertexBufferBindings,r=n.length;t<r&&n[t];t++);return this._internalVertexBufferIndex=t,t},n._getAttributeFormat=function(e){switch(e){case aR.Position:case aR.Normal:return r7.Vector3;case aR.Color:case aR.BoneWeight:case aR.Tangent:return r7.Vector4;case aR.BoneIndex:return r7.UByte4;case aR.UV:case aR.UV1:case aR.UV2:case aR.UV3:case aR.UV4:case aR.UV5:case aR.UV6:case aR.UV7:return r7.Vector2}},n._getAttributeByteLength=function(e){switch(e){case aR.Position:case aR.Normal:return 12;case aR.Color:case aR.BoneWeight:case aR.Tangent:return 16;case aR.BoneIndex:return 4;case aR.UV:case aR.UV1:case aR.UV2:case aR.UV3:case aR.UV4:case aR.UV5:case aR.UV6:case aR.UV7:return 8}},n._releaseCache=function(e){if(this._positions=null,this._tangents=null,this._normals=null,this._colors=null,this._boneIndices=null,this._boneWeights=null,this._uv=null,this._uv1=null,this._uv2=null,this._uv3=null,this._uv4=null,this._uv5=null,this._uv6=null,this._uv7=null,this._indices=null,this._blendShapeManager._releaseMemoryCache(),!e){null==(t=this._primitive.vertexBufferBindings[this._internalVertexBufferIndex])||t.buffer.markAsUnreadable();for(var t,n=this._dataVersionCounter++,r=this._vertexBufferInfos,a=0,i=r.length;a<i;a++){var o=r[a];o&&(o.dataVersion=n)}}},tG(t,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var e=0,t=this._primitive._vertexElementMap[aR.Position];if(t){var n=this._primitive.vertexBufferBindings[t.bindingIndex];n&&(e=n.buffer.byteLength/n.stride)}this._vertexCount=e,this._vertexCountDirty=!1}return this._vertexCount}},{key:"vertexElements",get:function(){return this._updateVertexElements(),this._primitive.vertexElements}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"blendShapes",get:function(){return this._blendShapeManager._blendShapes}},{key:"blendShapeCount",get:function(){return this._blendShapeManager._blendShapeCount}},{key:"accessible",get:function(){return this._accessible}}]),t}(ab);aM._tempVec0=new tT,aM._tempVec1=new tT,aM._tempVec2=new tT,aM._tempVec3=new tT,aM._tempVec4=new tT;var aw=/*#__PURE__*/function(){function e(){this.dataVersion=-1,this.uploadAdvancedData=!1}return e.prototype.reset=function(){this.uploadAdvancedData=!1},e}(),aP=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).primitiveInfo=n,r}return tW(t,e),t.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:az._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:az._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:az._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:az._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:az._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:az._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:az._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:az._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t}(t2),aF=function(e,t,n){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=n},aL=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return(i=e.call(this,0,r,a)||this).radius=t,i.segments=n,i}return tW(t,e),t}(aF),aD=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return(i=e.call(this,7,r,a)||this).radius=t,i.step=n,i}return tW(t,e),t}(aF),aB=/*#__PURE__*/function(e){function t(t,n,r,a,i){var o;return(o=e.call(this,1,a,i)||this).width=t,o.height=n,o.depth=r,o}return tW(t,e),t}(aF),aI=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,2,i,o)||this).width=t,s.height=n,s.horizontalSegments=r,s.verticalSegments=a,s}return tW(t,e),t}(aF),aO=/*#__PURE__*/function(e){function t(t,n,r,a,i,o,s){var l;return(l=e.call(this,3,o,s)||this).radiusTop=t,l.radiusBottom=n,l.height=r,l.radialSegments=a,l.heightSegments=i,l}return tW(t,e),t}(aF),aV=/*#__PURE__*/function(e){function t(t,n,r,a,i,o,s){var l;return(l=e.call(this,4,o,s)||this).radius=t,l.tubeRadius=n,l.radialSegments=r,l.tubularSegments=a,l.arc=i,l}return tW(t,e),t}(aF),aN=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,5,i,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=a,s}return tW(t,e),t}(aF),ak=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,6,i,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=a,s}return tW(t,e),t}(aF),az=/*#__PURE__*/function(){function e(){}return e.createSphere=function(t,n,r,a){void 0===n&&(n=.5),void 0===r&&(r=18),void 0===a&&(a=!0);var i=new aM(t);e._setSphereData(i,n,r,a,!1);var o=i.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(i,new aL(n,r,o,a))),i},e.createSubdivisionSurfaceSphere=function(t,n,r,a){void 0===n&&(n=.5),void 0===r&&(r=3),void 0===a&&(a=!0);var i=new aM(t);e._setSubdivisionSurfaceSphereData(i,n,r,a,!1);var o=i.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(i,new aD(n,r,o,a))),i},e.createCuboid=function(t,n,r,a,i){void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new aM(t);e._setCuboidData(o,n,r,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(o,new aB(n,r,a,s,i))),o},e.createPlane=function(t,n,r,a,i,o){void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setPlaneData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new aI(n,r,a,i,l,o))),s},e.createCylinder=function(t,n,r,a,i,o,s){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===a&&(a=2),void 0===i&&(i=20),void 0===o&&(o=1),void 0===s&&(s=!0);var l=new aM(t);e._setCylinderData(l,n,r,a,i,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(l,new aO(n,r,a,i,o,c,s))),l},e.createTorus=function(t,n,r,a,i,o,s){void 0===n&&(n=.5),void 0===r&&(r=.1),void 0===a&&(a=30),void 0===i&&(i=30),void 0===o&&(o=360),void 0===s&&(s=!0);var l=new aM(t);e._setTorusData(l,n,r,a,i,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(l,new aV(n,r,a,i,o,c,s))),l},e.createCone=function(t,n,r,a,i,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===a&&(a=20),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setConeData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new aN(n,r,a,i,l,o))),s},e.createCapsule=function(t,n,r,a,i,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===a&&(a=6),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setCapsuleData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new ak(n,r,a,i,l,o))),s},e._setSubdivisionSurfaceSphereData=function(t,n,r,a,i,o){var s=new Float32Array(3*(6*Math.pow(4,r=tC.clamp(Math.floor(r),1,6))+2)),l=new Float32Array(24*Math.pow(4,r));e._subdiveCatmullClark(r,s,l);for(var c=s.length/3,u=l.length/4,d=c+Math.pow(2,r+1)-1,h=new Float32Array(8*(d+16)),_=e._generateIndices(t.engine,c,6*u),f=0,p={},m=0;m<c;m++){var g=3*m,v=s[g],y=s[g+1],x=s[g+2],b=1/Math.sqrt(v*v+y*y+x*x);if(v*=b,y*=b,x*=b,h[g=8*m]=v*n,h[g+1]=y*n,h[g+2]=x*n,h[g+3]=v,h[g+4]=y,h[g+5]=x,h[g+6]=(Math.PI-Math.atan2(x,v))/(2*Math.PI),h[g+7]=Math.acos(y)/Math.PI,0===h[g+6]){var S=8*(c+f++);h.set(h.subarray(g,g+8),S),h[S+6]=1,p[g/8]=S/8}}var C=0;this._spherePoleIdx=0;for(var T=0;T<u;T++){var A=4*T,E=l[A],R=l[A+1],M=l[A+2],w=l[A+3],P=8*E,F=8*R,L=8*M,D=8*w;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(E=p[E]),0===h[F+6]&&(R=p[R]),0===h[L+6]&&(M=p[M]),0===h[D+6]&&(w=p[w])),_[C]=E,_[C+1]=R,_[C+2]=M,this._generateAndReplacePoleUV(_,h,C,d),_[C+3]=E,_[C+4]=M,_[C+5]=w,this._generateAndReplacePoleUV(_,h,C+3,d),C+=6}if(!i){var B=t.bounds;B.min.set(-n,-n,-n),B.max.set(n,n,n)}e._initialize(t,h,_,a,i,o)},e._setSphereData=function(t,n,r,a,i,o){for(var s=(r=Math.max(2,Math.floor(r)))+1,l=s*s,c=r*r,u=e._generateIndices(t.engine,l,6*c),d=Math.PI,h=2*d,_=1/s,f=1/r,p=new Float32Array(8*l),m=0;m<l;++m){var g=m%s*f,v=(m*_|0)*f,y=g*h,x=v*d,b=Math.sin(x),S=-n*Math.cos(y)*b,C=n*Math.cos(x),T=n*Math.sin(y)*b,A=8*m;p[A++]=S,p[A++]=C,p[A++]=T,p[A++]=S,p[A++]=C,p[A++]=T,p[A++]=g,p[A++]=v}for(var E=0,R=0;R<c;++R){var M=R%r,w=(R*f|0)*s+M,P=w+1,F=w+s,L=F+1;u[E++]=P,u[E++]=w,u[E++]=L,u[E++]=w,u[E++]=F,u[E++]=L}if(!i){var D=t.bounds;D.min.set(-n,-n,-n),D.max.set(n,n,n)}e._initialize(t,p,u,a,i,o)},e._subdiveCatmullClark=function(t,n,r){var a=new Map,i=[];n.set(e._sphereSeedPositions),r.set(e._sphereSeedCells);for(var o=0;o<t;o++){var s=6*Math.pow(4,o),l=4*s+2;a.clear(),i.length=0;for(var c=0;c<s;c++){for(var u=i[c]={facePoint:new tT,adjacentEdges:[,,,,]},d=0;d<4;d++){var h=3*r[4*c+d];u.facePoint.x+=.25*n[h],u.facePoint.y+=.25*n[h+1],u.facePoint.z+=.25*n[h+2]}for(var _=0;_<4;_++){var f=r[4*c+_],p=r[4*c+(_+1)%4],m=Math.min(f,p)*l+Math.max(f,p);if(!a.has(m)){var g={edgePoint:new tT,edgePointIndex:void 0},v=3*f,y=3*p;g.edgePoint.set(.25*(n[v]+n[y]),.25*(n[v+1]+n[y+1]),.25*(n[v+2]+n[y+2])),a.set(m,g)}var x=a.get(m);u.adjacentEdges[_]=x;var b=x.edgePoint,S=u.facePoint;b.x+=.25*S.x,b.y+=.25*S.y,b.z+=.25*S.z}}var C=s+2,T=C+s,A=0;this._sphereEdgeIdx=0;for(var E=r.slice(0,4*s),R=0;R<s;R++){var M=i[R];M.facePoint.copyToArray(n,3*(C+R));for(var w=C+R,P=void 0,F=void 0,L=void 0,D=0;D<4;D++){var B=E[A++];switch(D){case 0:var I=M.adjacentEdges[D%4],O=M.adjacentEdges[(D+3)%4];F=this._calculateEdgeIndex(n,I,T),L=P=this._calculateEdgeIndex(n,O,T);break;case 1:case 2:var V=M.adjacentEdges[D%4];P=F,F=this._calculateEdgeIndex(n,V,T);break;case 3:P=F,F=L}var N=4*(4*R+D);r[N]=B,r[N+1]=F,r[N+2]=w,r[N+3]=P}}}},e._generateAndReplacePoleUV=function(e,t,n,r){var a=t[8*e[n]+7];if(0===a||1===a){var i=8*e[n],o=8*(r+this._spherePoleIdx);t.set(t.subarray(i,i+8),o),t[o+6]=.5*(t[i+6]+t[8*e[n+1]+6]+t[8*e[n+2]+6]-.5),e[n]=r+this._spherePoleIdx++}},e._calculateEdgeIndex=function(t,n,r){if(void 0!==n.edgePointIndex)return n.edgePointIndex;n.edgePoint.copyToArray(t,3*(r+e._sphereEdgeIdx));var a=r+e._sphereEdgeIdx++;return n.edgePointIndex=a,a},e._setCuboidData=function(t,n,r,a,i,o,s){var l=n/2,c=r/2,u=a/2,d=new Float32Array(192);d[0]=-l,d[1]=c,d[2]=-u,d[6]=0,d[7]=0,d[8]=l,d[9]=c,d[10]=-u,d[14]=1,d[15]=0,d[16]=l,d[17]=c,d[18]=u,d[22]=1,d[23]=1,d[24]=-l,d[25]=c,d[26]=u,d[30]=0,d[31]=1;for(var h=0;h<4;h++){var _=8*h+3;d[_++]=0,d[_++]=1,d[_++]=0}d[32]=-l,d[33]=-c,d[34]=-u,d[38]=0,d[39]=1,d[40]=l,d[41]=-c,d[42]=-u,d[46]=1,d[47]=1,d[48]=l,d[49]=-c,d[50]=u,d[54]=1,d[55]=0,d[56]=-l,d[57]=-c,d[58]=u,d[62]=0,d[63]=0;for(var f=0;f<4;f++){var p=8*f+35;d[p++]=0,d[p++]=-1,d[p++]=0}d[64]=-l,d[65]=c,d[66]=-u,d[70]=0,d[71]=0,d[72]=-l,d[73]=c,d[74]=u,d[78]=1,d[79]=0,d[80]=-l,d[81]=-c,d[82]=u,d[86]=1,d[87]=1,d[88]=-l,d[89]=-c,d[90]=-u,d[94]=0,d[95]=1;for(var m=0;m<4;m++){var g=8*m+67;d[g++]=-1,d[g++]=0,d[g++]=0}d[96]=l,d[97]=c,d[98]=-u,d[102]=1,d[103]=0,d[104]=l,d[105]=c,d[106]=u,d[110]=0,d[111]=0,d[112]=l,d[113]=-c,d[114]=u,d[118]=0,d[119]=1,d[120]=l,d[121]=-c,d[122]=-u,d[126]=1,d[127]=1;for(var v=0;v<4;v++){var y=8*v+99;d[y++]=1,d[y++]=0,d[y++]=0}d[128]=-l,d[129]=c,d[130]=u,d[134]=0,d[135]=0,d[136]=l,d[137]=c,d[138]=u,d[142]=1,d[143]=0,d[144]=l,d[145]=-c,d[146]=u,d[150]=1,d[151]=1,d[152]=-l,d[153]=-c,d[154]=u,d[158]=0,d[159]=1;for(var x=0;x<4;x++){var b=8*x+131;d[b++]=0,d[b++]=0,d[b++]=1}d[160]=-l,d[161]=c,d[162]=-u,d[166]=1,d[167]=0,d[168]=l,d[169]=c,d[170]=-u,d[174]=0,d[175]=0,d[176]=l,d[177]=-c,d[178]=-u,d[182]=0,d[183]=1,d[184]=-l,d[185]=-c,d[186]=-u,d[190]=1,d[191]=1;for(var S=0;S<4;S++){var C=8*S+163;d[C++]=0,d[C++]=0,d[C++]=-1}var T=new Uint16Array(36);if(T[0]=0,T[1]=2,T[2]=1,T[3]=2,T[4]=0,T[5]=3,T[6]=4,T[7]=6,T[8]=7,T[9]=6,T[10]=4,T[11]=5,T[12]=8,T[13]=10,T[14]=9,T[15]=10,T[16]=8,T[17]=11,T[18]=12,T[19]=14,T[20]=15,T[21]=14,T[22]=12,T[23]=13,T[24]=16,T[25]=18,T[26]=17,T[27]=18,T[28]=16,T[29]=19,T[30]=20,T[31]=22,T[32]=23,T[33]=22,T[34]=20,T[35]=21,!o){var A=t.bounds;A.min.set(-l,-c,-u),A.max.set(l,c,u)}e._initialize(t,d,T,i,o,s)},e._setPlaneData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.max(1,Math.floor(a)))+1,u=(i=Math.max(1,Math.floor(i)))+1,d=n/2,h=r/2,_=n/a,f=r/i,p=c*u,m=i*a,g=e._generateIndices(t.engine,p,6*m),v=1/c,y=1/a,x=1/i,b=new Float32Array(8*p),S=0;S<p;++S){var C=S%c,T=S*v|0,A=8*S;b[A++]=C*_-d,b[A++]=0,b[A++]=T*f-h,b[A++]=0,b[A++]=1,b[A++]=0,b[A++]=C*y,b[A++]=T*x}for(var E=0,R=0;R<m;++R){var M=R%a,w=(R*y|0)*c+M,P=w+1,F=w+c,L=F+1;g[E++]=w,g[E++]=F,g[E++]=P,g[E++]=F,g[E++]=L,g[E++]=P}if(!s){var D=t.bounds;D.min.set(-d,0,-h),D.max.set(d,0,h)}e._initialize(t,b,g,o,s,l)},e._setCylinderData=function(t,n,r,a,i,o,s,l,c){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===a&&(a=2),void 0===i&&(i=20),void 0===o&&(o=1);for(var u=(i=Math.floor(i))+1,d=(o=Math.floor(o))+1,h=.5*a,_=a/o,f=u*d,p=i*o,m=2*i,g=f+2+m,v=e._generateIndices(t.engine,g,6*p+3*m),y=1/u,x=1/i,b=1/o,S=new Float32Array(8*g),C=0,T=Math.PI,A=2*Math.PI,E=r-n,R=E/a,M=E/o,w=0;w<f;++w){var P=w%u,F=w*y|0,L=P*x,D=F*b,B=T+L*A,I=Math.sin(B),O=Math.cos(B),V=r-F*M,N=V*I,k=F*_-h,z=V*O,U=8*w;S[U++]=N,S[U++]=k,S[U++]=z,S[U++]=I,S[U++]=R,S[U++]=O,S[U++]=L,S[U++]=1-D}for(var G=0;G<p;++G){var H=G%i,W=(G*x|0)*u+H,j=W+1,X=W+u,K=X+1;v[C++]=j,v[C++]=X,v[C++]=W,v[C++]=j,v[C++]=K,v[C++]=X}var Y=8*f;S[Y++]=0,S[Y++]=-h,S[Y++]=0,S[Y++]=0,S[Y++]=-1,S[Y++]=0,S[Y++]=.5,S[Y++]=.5,S[Y++]=0,S[Y++]=h,S[Y++]=0,S[Y++]=0,S[Y++]=1,S[Y++]=0,S[Y++]=.5,S[Y++]=.5,Y=(f+2)*8;for(var q=1/(2*n),Q=1/(2*r),Z=u*o,J=0;J<i;++J){var $=8*J,ee=S[$],et=S[$+2];S[Y++]=ee,S[Y++]=-h,S[Y++]=et,S[Y++]=0,S[Y++]=-1,S[Y++]=0,S[Y++]=ee*Q+.5,S[Y++]=.5-et*Q;var en=(J+Z)*8;ee=S[en],et=S[en+2],S[Y++]=ee,S[Y++]=h,S[Y++]=et,S[Y++]=0,S[Y++]=1,S[Y++]=0,S[Y++]=ee*q+.5,S[Y++]=.5-et*q}for(var er=f+1,ea=f+2,ei=ea+1,eo=0;eo<i;++eo){var es=2*eo,el=eo===i-1?0:es+2;v[C++]=f,v[C++]=ea+el,v[C++]=ea+es,v[C++]=er,v[C++]=ei+es,v[C++]=ei+el}if(!l){var ec=t.bounds,eu=Math.max(n,r);ec.min.set(-eu,-h,-eu),ec.max.set(eu,h,eu)}e._initialize(t,S,v,s,l,c)},e._setTorusData=function(t,n,r,a,i,o,s,l,c){var u=((a=Math.floor(a))+1)*((i=Math.floor(i))+1),d=a*i,h=e._generateIndices(t.engine,u,6*d),_=new Float32Array(8*u);o=o/180*Math.PI;for(var f=0,p=e._tempVec30,m=0;m<=a;m++)for(var g=0;g<=i;g++){var v=g/i*o,y=m/a*Math.PI*2,x=Math.cos(y),b=Math.cos(v),S=Math.sin(v),C=(n+r*x)*b,T=(n+r*x)*S,A=r*Math.sin(y);_[f++]=C,_[f++]=T,_[f++]=A;var E=n*b,R=n*S;p.set(C-E,T-R,A).normalize(),_[f++]=p.x,_[f++]=p.y,_[f++]=p.z,_[f++]=g/i,_[f++]=m/a}f=0;for(var M=1;M<=a;M++)for(var w=1;w<=i;w++){var P=(i+1)*M+w-1,F=(i+1)*(M-1)+w-1,L=(i+1)*(M-1)+w,D=(i+1)*M+w;h[f++]=P,h[f++]=F,h[f++]=D,h[f++]=F,h[f++]=L,h[f++]=D}if(!l){var B=t.bounds,I=n+r;B.min.set(-I,-I,-r),B.max.set(I,I,r)}e._initialize(t,_,h,s,l,c)},e._setConeData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.floor(a))+1,u=(i=Math.floor(i))+1,d=.5*r,h=r/i,_=c*u,f=a*i,p=_+1+a,m=e._generateIndices(t.engine,p,6*f+3*a),g=1/c,v=1/a,y=1/i,x=new Float32Array(8*p),b=0,S=Math.PI,C=2*Math.PI,T=n/r,A=0;A<_;++A){var E=A%c,R=A*g|0,M=E*v,w=R*y,P=S+M*C,F=Math.sin(P),L=Math.cos(P),D=n-w*n,B=D*F,I=R*h-d,O=D*L,V=8*A;x[V++]=B,x[V++]=I,x[V++]=O,x[V++]=F,x[V++]=T,x[V++]=L,x[V++]=M,x[V++]=1-w}for(var N=0;N<f;++N){var k=N%a,z=(N*v|0)*c+k,U=z+1,G=z+c,H=G+1;m[b++]=U,m[b++]=G,m[b++]=z,m[b++]=U,m[b++]=H,m[b++]=G}var W=8*_;x[W++]=0,x[W++]=-d,x[W++]=0,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=.5,x[W++]=.5,W=(_+1)*8;for(var j=1/(2*n),X=0;X<a;++X){var K=x[8*X],Y=x[8*X+2];x[W++]=K,x[W++]=-d,x[W++]=Y,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=K*j+.5,x[W++]=.5-Y*j}for(var q=_+1,Q=0;Q<a;++Q){var Z=Q,J=Q===a-1?0:Z+1;m[b++]=_,m[b++]=q+J,m[b++]=q+Z}if(!s){var $=t.bounds;$.min.set(-n,-d,-n),$.max.set(n,d,n)}e._initialize(t,x,m,o,s,l)},e._setCapsuleData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.max(2,Math.floor(a)))+1,u=(i=Math.floor(i))+1,d=.5*r,h=r/i,_=c*u,f=a*i,p=c*c,m=a*a,g=_+2*p,v=e._generateIndices(t.engine,g,(f+2*m)*6),y=1/c,x=1/a,b=1/i,S=Math.PI,C=2*Math.PI,T=new Float32Array(8*g),A=0,E=0;E<_;++E){var R=E%c,M=E*y|0,w=R*x,P=M*b,F=S+w*C,L=Math.sin(F),D=Math.cos(F),B=8*E;T[B++]=n*L,T[B++]=M*h-d,T[B++]=n*D,T[B++]=L,T[B++]=0,T[B++]=D,T[B++]=w,T[B++]=1-P}for(var I=0;I<f;++I){var O=I%a,V=(I*x|0)*c+O,N=V+1,k=V+c,z=k+1;v[A++]=N,v[A++]=k,v[A++]=V,v[A++]=N,v[A++]=z,v[A++]=k}if(e._createCapsuleCap(n,r,a,S,C,_,1,T,v,A),e._createCapsuleCap(n,r,a,S,-C,_+p,-1,T,v,A+6*m),!s){var U=t.bounds;U.min.set(-n,-n-d,-n),U.max.set(n,n+d,n)}e._initialize(t,T,v,o,s,l)},e._initialize=function(e,t,n,r,a,i){if(a)i.setData(t),e.setIndices(n),e.uploadData(r);else{var o=[new at(aR.Position,0,r7.Vector3,0),new at(aR.Normal,12,r7.Vector3,0),new at(aR.UV,24,r7.Vector2,0)];e.setVertexElements(o);var s=new r9(e.engine,an.VertexBuffer,t,r8.Static,!0);e.setVertexBufferBinding(s,32,0),e.setIndices(n),e.calculateTangents(),e.uploadData(r),e.addSubMesh(0,n.length)}},e._generateIndices=function(e,t,n){var r=null;if(t>65535){if(e._hardwareRenderer.canIUse(nZ.elementIndexUint))r=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else r=new Uint16Array(n);return r},e._createCapsuleCap=function(e,t,n,r,a,i,o,s,l,c){for(var u=n+1,d=.5*t*o,h=u*u,_=n*n,f=1/u,p=1/n,m=0;m<h;++m){var g=m%u*p,v=(m*f|0)*p,y=r+g*a,x=v*Math.PI*.5,b=Math.sin(x),S=e*Math.sin(y)*b,C=e*Math.cos(x)*o+d,T=e*Math.cos(y)*b,A=(m+i)*8;s[A++]=S,s[A++]=C,s[A++]=T,s[A++]=S,s[A++]=C-d,s[A++]=T,s[A++]=g,s[A++]=v}for(var E=0;E<_;++E){var R=E%n,M=(E*p|0)*u+R+i,w=M+1,P=M+u,F=P+1;l[c++]=w,l[c++]=M,l[c++]=F,l[c++]=M,l[c++]=P,l[c++]=F}},e}();function aU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(aU=function(){return!!e})()}function aG(e,t,n){return(aG=aU()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&tH(a,n.prototype),a}).apply(null,arguments)}az._tempVec30=new tT,az._sphereSeedPositions=new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1]),az._sphereSeedCells=new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1]),az._sphereEdgeIdx=0,az._spherePoleIdx=0;var aH=/*#__PURE__*/function(){function e(){}return e.cloneComponent=function(e,t,n,r,a){var i=t$.getCloneMode(e.constructor);for(var o in e)t$.cloneProperty(e,t,o,i[o],n,r,a);e._cloneTo&&e._cloneTo(t,n,r)},e}(),aW=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).layer=rE.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new rS,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._isTemplate=!1,r._parent=null,r._invModelMatrix=new tL,r.name=n,r.transform=r.addComponent(rp),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r}tW(t,e);var n=t.prototype;return n.addComponent=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];rd._addCheck(this,e);var a=aG(e,[].concat([this],n));return this._components.push(a),a._setActive(!0,rc.All),a},n.getComponent=function(e){for(var t=this._components,n=0,r=t.length;n<r;n++){var a=t[n];if(tK(a,e))return a}return null},n.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];tK(i,e)&&t.push(i)}return t},n.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},n.addChild=function(e,n){var r;if("number"==typeof e?r=e:(r=void 0,n=e),n._isRoot){n._scene._removeFromEntityList(n),n._isRoot=!1,this._addToChildrenList(r,n),n._parent=this;var a=n._scene,i=this._scene,o=rc.None;!this._isActiveInHierarchy&&n._isActiveInHierarchy&&(o|=rc.Hierarchy),n._isActiveInScene&&(this._isActiveInScene?a!==i&&(o|=rc.Scene):o|=rc.Scene),o&&n._processInActive(o),n._scene!==i&&t._traverseSetOwnerScene(n,i);var s=rc.None;n._isActive&&(this._isActiveInHierarchy&&(n._isActiveInHierarchy||(s|=rc.Hierarchy)),this._isActiveInScene&&(n._isActiveInScene&&a===i||(s|=rc.Scene))),s&&n._processActive(s),n._setTransformDirty()}else n._setParent(this,r)},n.removeChild=function(e){e._setParent(null)},n.getChild=function(e){return this._children[e]},n.findByName=function(e){if(e===this.name)return this;for(var t=this._children,n=0,r=t.length;n<r;n++){var a=t[n].findByName(e);if(a)return a}return null},n.findByPath=function(e){for(var n=e.split("/"),r=this,a=0,i=n.length;a<i;++a){var o=n[a];if(o&&!(r=t._findChildByName(r,o)))return null}return r},n.createChild=function(e){var n=new t(this.engine,e);return n.layer=this.layer,n.parent=this,n},n.clearChildren=function(){for(var e=this._children,n=e.length-1;n>=0;n--){var r=e[n];r._parent=null;var a=rc.None;r._isActiveInHierarchy&&(a|=rc.Hierarchy),r._isActiveInScene&&(a|=rc.Scene),a&&r._processInActive(a),t._traverseSetOwnerScene(r,null)}e.length=0},n.clone=function(){var e=this._createCloneEntity();return this._parseCloneEntity(this,e,this,e,new Map),e},n._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},n._createCloneEntity=function(){var e=new t(this._engine,this.name),n=this._templateResource;n&&(e._templateResource=n,n._addReferCount(1)),e.layer=this.layer,e._isActive=this._isActive;var r=e.transform,a=this.transform;r.position=a.position,r.rotation=a.rotation,r.scale=a.scale;for(var i=this._children,o=0,s=i.length;o<s;o++)e.addChild(i[o]._createCloneEntity());return e},n._parseCloneEntity=function(e,t,n,r,a){for(var i=e._children,o=t._children,s=0,l=i.length;s<l;s++)this._parseCloneEntity(i[s],o[s],n,r,a);for(var c=e._components,u=0,d=c.length;u<d;u++){var h=c[u];if(!tK(h,rp)){var _=t.addComponent(h.constructor);aH.cloneComponent(h,_,n,r,a)}}},n.destroy=function(){if(!this._destroyed){e.prototype.destroy.call(this),this._templateResource&&(this._isTemplate||this._templateResource._addReferCount(-1),this._templateResource=null);for(var t=this._components,n=t.length-1;n>=0;n--)t[n].destroy();this._components.length=0;for(var r=this._children;r.length>0;)r[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},n._removeComponent=function(e){rd._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},n._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},n._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},n._removeFromParent=function(){var e=this._parent;if(null!=e){var t=e._children,n=this._siblingIndex;t.splice(n,1);for(var r=t.length;n<r;n++)t[n]._siblingIndex--;this._parent=null,this._siblingIndex=-1}},n._processActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!0,e)},n._processInActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setInActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!1,e)},n._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},n._addToChildrenList=function(e,t){var n=this._children,r=n.length;if(void 0===e)t._siblingIndex=r,n.push(t);else{if(e<0||e>r)throw"The index "+e+" is out of child list bounds "+r;t._siblingIndex=e,n.splice(e,0,t);for(var a=e+1,i=r+1;a<i;a++)n[a]._siblingIndex++}},n._setParent=function(e,n){var r=this._parent;if(e!==r){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(n,this);var a=this._scene,i=e._scene,o=rc.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(o|=rc.Hierarchy),e._isActiveInScene?this._isActiveInScene&&a!==i&&(o|=rc.Scene):this._isActiveInScene&&(o|=rc.Scene),o&&this._processInActive(o),a!==i&&t._traverseSetOwnerScene(this,i);var s=rc.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(s|=rc.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&a===i||(s|=rc.Scene))),s&&this._processActive(s)}else{var l=rc.None;this._isActiveInHierarchy&&(l|=rc.Hierarchy),this._isActiveInScene&&(l|=rc.Scene),l&&this._processInActive(l),r&&t._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},n._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];tK(r,e)&&t.push(r)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},n._setActiveComponents=function(e,t){for(var n=this._activeChangedComponents,r=0,a=n.length;r<a;++r)n[r]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(n),this._activeChangedComponents=null},n._setActiveInHierarchy=function(e,t){t&rc.Hierarchy&&(this._isActiveInHierarchy=!0),t&rc.Scene&&(this._isActiveInScene=!0);for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];(i.enabled||!i._awoken)&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setActiveInHierarchy(e,t)}},n._setInActiveInHierarchy=function(e,t){t&rc.Hierarchy&&(this._isActiveInHierarchy=!1),t&rc.Scene&&(this._isActiveInScene=!1);for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];i.enabled&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setInActiveInHierarchy(e,t)}},n._setSiblingIndex=function(e,t){if((t=Math.min(t,e.length-1))<0)throw"Sibling index "+t+" should large than 0";if(this._siblingIndex!==t){var n=this._siblingIndex;if(t<n)for(var r=n;r>=t;r--){var a=r==t?this:e[r-1];e[r]=a,a._siblingIndex=r}else for(var i=n;i<=t;i++){var o=i==t?this:e[i+1];e[i]=o,o._siblingIndex=i}}},n.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(tL.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t._findChildByName=function(e,t){for(var n=e._children,r=n.length-1;r>=0;r--){var a=n[r];if(a.name===t)return a}return null},t._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=n.length-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},t._getEntityHierarchyPath=function(e,t,n){for(n.length=0;t!==e;){var r=t.parent;if(!r)return!1;n.push(t.siblingIndex),t=r}return!0},t._getEntityByHierarchyPath=function(e,t){for(var n=e,r=t.length-1;r>=0;r--)n=n.children[t[r]];return n},tG(t,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,n=rc.None;this._isRoot&&this._scene._isActiveInEngine?n|=rc.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=rc.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=rc.Scene)),n&&this._processActive(n)}else{var r=rc.None;this._isActiveInHierarchy&&(r|=rc.Hierarchy),this._isActiveInScene&&(r|=rc.Scene),r&&this._processInActive(r)}}}},{key:"isActiveInHierarchy",get:function(){return this._isActiveInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this._setParent(e)}},{key:"children",get:function(){return this._children}},{key:"childCount",get:function(){return this._children.length}},{key:"scene",get:function(){return this._scene}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(e){if(-1===this._siblingIndex)throw"The entity "+this.name+" is not in the hierarchy";this._setSiblingIndex(this._isRoot?this._scene._rootEntities:this._parent._children,e)}}]),t}(t0),aj=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n.inverseBindMatrices=[],n._updatedManager=new nM,n._bones=[],n._updateMark=-1,n.joints=[],n}tW(t,e);var n=t.prototype;return n._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,n=this.bones,r=this.inverseBindMatrices,a=this._skinMatrices,i=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=n.length-1;o>=0;o--){var s=n[o],l=16*o;s?nT._floatMatrixMultiply(s.transform.worldMatrix,r[o].elements,0,a,l):a.set(r[o].elements,l),nT._floatMatrixMultiply(i,a,l,a,l)}this._updateMark=e.engine.time.frameCount}},n._cloneTo=function(e,t,n){var r=[],a=this.rootBone;if(a){var i=aW._getEntityHierarchyPath(t,a,r);e.rootBone=i?aW._getEntityByHierarchyPath(n,r):a}var o=this.bones;if(o.length>0){for(var s=o.length,l=Array(s),c=0;c<s;c++){var u=o[c],d=aW._getEntityHierarchyPath(t,u,r);l[c]=d?aW._getEntityByHierarchyPath(n,r):u}e.bones=l}},tG(t,[{key:"rootBone",get:function(){return this._rootBone},set:function(e){this._rootBone!==e&&(this._updatedManager.dispatch(1,e),this._rootBone=e)}},{key:"bones",get:function(){return this._bones},set:function(e){var t,n=this._bones,r=null!=(t=null==e?void 0:e.length)?t:0,a=n.length;n.length=r;for(var i=0;i<r;i++)n[i]=e[i];a!==r&&(this._skinMatrices=new Float32Array(16*r),this._updatedManager.dispatch(0,r))}},{key:"skeleton",get:function(){var e;return null==(e=this.rootBone)?void 0:e.name},set:function(e){var t=this._rootBone;t&&(t.name=e)}}]),t}(t0);tX([tJ],aj.prototype,"inverseBindMatrices",void 0),tX([tq],aj.prototype,"_skinMatrices",void 0),tX([tq],aj.prototype,"_updatedManager",void 0),tX([tq],aj.prototype,"_rootBone",void 0),tX([tq],aj.prototype,"_bones",void 0),tX([tq],aj.prototype,"_updateMark",void 0);var aX=((eg={})[eg.BoneCountChanged=0]="BoneCountChanged",eg[eg.RootBoneChanged=1]="RootBoneChanged",eg),aK=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._localBounds=new tE,n._jointDataCreateCache=new tB(-1,-1),n._skin=null;var n,r=n.entity.engine._hardwareRenderer,a=r.renderStates.getParameter(r.gl.MAX_VERTEX_UNIFORM_VECTORS);a=Math.min(a,r._options._maxAllowSkinUniformVectorCount),n._maxVertexUniformVectors=a,n._onLocalBoundsChanged=n._onLocalBoundsChanged.bind(n),n._onSkinUpdated=n._onSkinUpdated.bind(n);var i=n._localBounds;return i.min._onValueChanged=n._onLocalBoundsChanged,i.max._onValueChanged=n._onLocalBoundsChanged,n}tW(t,e);var n=t.prototype;return n._updateTransformShaderData=function(e,t,n){var r=this._transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,r,n):this._updateWorldViewRelatedShaderData(e,r,n)},n._onDestroy=function(){var t;e.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(t=this._jointTexture)||t.destroy(),this._jointTexture=null},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),this.skin&&t._applySkin(null,t.skin),this._blendShapeWeights&&(t._blendShapeWeights=this._blendShapeWeights.slice())},n._update=function(n){var r=this.skin;(null==r?void 0:r.bones.length)>0&&r._updateSkinMatrices(this);var a=this.shaderData,i=this.mesh._blendShapeManager;i._updateShaderData(a,this);var o=null==r?void 0:r.bones;if(o){var s=i._uniformOccupiesCount,l=o.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var d,h=Math.ceil((this._maxVertexUniformVectors-(44+s))/4);if(l>h){var _,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(_=this._jointTexture)||_.destroy(),this._jointTexture=new nc(f,4,l,t9.R32G32B32A32,!1),this._jointTexture.filterMode=t5.Point,this._jointTexture.isGCIgnored=!0),a.disableMacro("RENDERER_JOINTS_NUM"),a.enableMacro("RENDERER_USE_JOINT_TEXTURE"),a.setTexture(t._jointSamplerProperty,this._jointTexture)):no.error("component's joints count("+l+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+h+".",this)}else null==(d=this._jointTexture)||d.destroy(),a.disableMacro("RENDERER_USE_JOINT_TEXTURE"),a.enableMacro("RENDERER_JOINTS_NUM",h.toString()),a.setFloatArray(t._jointMatrixProperty,r._skinMatrices);c.set(l,s)}this._jointTexture&&this._jointTexture.setPixelBuffer(r._skinMatrices)}e.prototype._update.call(this,n)},n._updateBounds=function(t){var n;(null==(n=this.skin)?void 0:n.rootBone)?tE.transform(this._localBounds,this._transform.worldMatrix,t):e.prototype._updateBounds.call(this,t)},n._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,n=this._blendShapeWeights;if(n){var r=n.length;if(r!==t){var a=new Float32Array(t);if(t>r)a.set(n);else for(var i=0;i<t;i++)a[i]=n[i];this._blendShapeWeights=a}}else this._blendShapeWeights=new Float32Array(t)},n._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=rv.WorldVolume},n._onSkinUpdated=function(e,n){switch(e){case aX.BoneCountChanged:var r=this.shaderData;n>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(t._jointCountProperty,n)):r.disableMacro("RENDERER_HAS_SKIN");break;case aX.RootBoneChanged:this._setTransform(n.transform),this._dirtyUpdateFlag|=rv.WorldVolume}},n._applySkin=function(e,t){var n,r,a,i,o,s,l=null!=(a=null==e?void 0:null==(n=e.bones)?void 0:n.length)?a:0,c=null!=(i=null==e?void 0:e.rootBone)?i:this.entity;null==e||e._updatedManager.removeListener(this._onSkinUpdated);var u=null!=(o=null==t?void 0:null==(r=t.bones)?void 0:r.length)?o:0,d=null!=(s=null==t?void 0:t.rootBone)?s:this.entity;null==t||t._updatedManager.addListener(this._onSkinUpdated),l!==u&&this._onSkinUpdated(aX.BoneCountChanged,u),c!==d&&this._onSkinUpdated(aX.RootBoneChanged,d)},tG(t,[{key:"skin",get:function(){return this._skin},set:function(e){var t=this._skin;t!==e&&(this._applySkin(t,e),this._skin=e)}},{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var t=this._blendShapeWeights;if(e.length<=t.length)t.set(e);else for(var n=0,r=t.length;n<r;n++)t[n]=e[n]}},{key:"localBounds",get:function(){return this._localBounds},set:function(e){this._localBounds!==e&&this._localBounds.copyFrom(e)}},{key:"rootBone",get:function(){return this.skin.rootBone},set:function(e){this.skin.rootBone=e}},{key:"bones",get:function(){return this.skin.bones},set:function(e){this.skin.bones=e}}]),t}(aA);aK._jointCountProperty=nY.getByName("renderer_JointCount"),aK._jointSamplerProperty=nY.getByName("renderer_JointSampler"),aK._jointMatrixProperty=nY.getByName("renderer_JointMatrix"),tX([tq],aK.prototype,"_condensedBlendShapeWeights",void 0),tX([tJ],aK.prototype,"_localBounds",void 0),tX([tq],aK.prototype,"_jointDataCreateCache",void 0),tX([tq],aK.prototype,"_blendShapeWeights",void 0),tX([tq],aK.prototype,"_maxVertexUniformVectors",void 0),tX([tq],aK.prototype,"_jointTexture",void 0),tX([tJ],aK.prototype,"_skin",void 0),tX([tq],aK.prototype,"_onLocalBoundsChanged",null),tX([tq],aK.prototype,"_onSkinUpdated",null);var aY=/*#__PURE__*/function(){function e(e){var t=new Float32Array([-1,-1,0,1,3,-1,2,1,-1,3,0,-1]),n=new Float32Array([3,-1,2,0,-1,-1,0,0,-1,3,0,2]),r=new ao(e,ro.find("blit"));r._addReferCount(1),r.renderState.depthState.enabled=!1,r.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(e,t),this.flipYBlitMesh=this._createBlitMesh(e,n),this.blitMaterial=r;var a=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(e,0,t9.R8G8B8A8,a),this.whiteTextureCube=this._create1x1Texture(e,1,t9.R8G8B8A8,a),e._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(e,2,t9.R8G8B8A8,a);var i=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(e,0,t9.R32G32B32A32_UInt,i)}this.spriteDefaultMaterial=this._create2DMaterial(e,ro.find("Sprite")),this.textDefaultMaterial=this._create2DMaterial(e,ro.find("Text")),this.spriteMaskDefaultMaterial=this._createSpriteMaskMaterial(e)}var t=e.prototype;return t._createBlitMesh=function(e,t){var n=new aM(e);n._addReferCount(1),n.setVertexElements([new at("POSITION_UV",0,r7.Vector4,0)]);var r=new r9(e,an.VertexBuffer,t,r8.Static,!0);return n.setVertexBufferBinding(r,16),n.addSubMesh(0,3,ar.Triangles),e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tW(t,e),t.prototype.restoreContent=function(){r.setData(r.data)},t}(t2))),n},t._create1x1Texture=function(e,t,n,r){var a;switch(t){case 0:var i=new nc(e,1,1,n,!1);i.setPixelBuffer(r),a=i;break;case 2:var o=new nu(e,1,1,1,n,!1);o.setPixelBuffer(0,r),a=o;break;case 1:for(var s=new nd(e,1,n,!1),l=0;l<6;l++)s.setPixelBuffer(t4.PositiveX+l,r);a=s;break;default:throw"Invalid texture type"}return a.isGCIgnored=!0,e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,a)||this}return tW(n,e),n.prototype.restoreContent=function(){switch(t){case 0:this.resource.setPixelBuffer(r);break;case 2:this.resource.setPixelBuffer(0,r);break;case 1:for(var e=0;e<6;e++)this.resource.setPixelBuffer(t4.PositiveX+e,r)}},n}(t2))),a},t._create2DMaterial=function(e,t){var n=new ao(e,t),r=n.renderState,a=r.blendState.targetBlendState;return a.enabled=!0,a.sourceColorBlendFactor=nF.SourceAlpha,a.destinationColorBlendFactor=nF.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=nF.One,a.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=nL.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=nI.Off,r.renderQueueType=nV.Transparent,n.isGCIgnored=!0,n},t._createSpriteMaskMaterial=function(e){var t=new ao(e,ro.find("SpriteMask"));return t.isGCIgnored=!0,t},e.getMaskInteractionRenderStates=function(t){var n,r;if(t===nv.VisibleInsideMask){if(n=e._maskReadInsideRenderStates)return n;e._maskReadInsideRenderStates=n={},r=nB.LessEqual}else{if(n=e._maskReadOutsideRenderStates)return n;e._maskReadOutsideRenderStates=n={},r=nB.Greater}return n[nO.StencilStateEnabled]=!0,n[nO.StencilStateWriteMask]=0,n[nO.StencilStateReferenceValue]=1,n[nO.StencilStateCompareFunctionFront]=r,n[nO.StencilStateCompareFunctionBack]=r,n},e.getMaskTypeRenderStates=function(t){if(t===rU.Increment){if(n=e._maskWriteIncrementRenderStates)return n;e._maskWriteIncrementRenderStates=n={},r=nk.IncrementSaturate}else{if(n=e._maskWriteDecrementRenderStates)return n;e._maskWriteDecrementRenderStates=n={},r=nk.DecrementSaturate}n[nO.StencilStateEnabled]=!0,n[nO.StencilStatePassOperationFront]=r,n[nO.StencilStatePassOperationBack]=r,n[nO.StencilStateCompareFunctionFront]=nB.Always,n[nO.StencilStateCompareFunctionBack]=nB.Always;var n,r,a=nk.Keep;return n[nO.StencilStateFailOperationFront]=a,n[nO.StencilStateFailOperationBack]=a,n[nO.StencilStateZFailOperationFront]=a,n[nO.StencilStateZFailOperationBack]=a,n[nO.BlendStateColorWriteMask0]=nD.None,n[nO.DepthStateEnabled]=!1,n[nO.RasterStateCullMode]=nI.Off,n},e}();aY._maskReadInsideRenderStates=null,aY._maskReadOutsideRenderStates=null,aY._maskWriteIncrementRenderStates=null,aY._maskWriteDecrementRenderStates=null;var aq=/*#__PURE__*/function(){function e(e){this._type=e}return e.prototype.garbageCollection=function(){for(var e=this._elements,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose();e.length=0},e}(),aQ=/*#__PURE__*/function(e){function t(t,n){void 0===n&&(n=1),(r=e.call(this,t)||this)._lastElementIndex=n-1;for(var r,a=r._elements=Array(n),i=0;i<n;++i)a[i]=new t;return r}tW(t,e);var n=t.prototype;return n.get=function(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]},n.return=function(e){this._elements[++this._lastElementIndex]=e},t}(aq),aZ=/*#__PURE__*/function(){function e(){}return e.prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},e}(),aJ=/*#__PURE__*/function(){function e(e,t){this.start=e,this.size=t}return e.prototype.dispose=function(){},e}(),a$=/*#__PURE__*/function(){function e(e,t){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new ax(e);n.addVertexElement(new at("POSITION",0,r7.Vector3,0)),n.addVertexElement(new at("TEXCOORD_0",12,r7.Vector2,0)),n.addVertexElement(new at("COLOR_0",20,r7.Vector4,0)),n._addReferCount(1);var r=new r9(e,an.VertexBuffer,36*t,r8.Dynamic,!0);n.setVertexBufferBinding(0,new aC(r,36));var a=new r9(e,an.IndexBuffer,8*t,r8.Dynamic,!0);n.setIndexBufferBinding(new ag(a,r6.UInt16)),this.primitive=n,this.vertices=new Float32Array(r.data.buffer),this.indices=new Uint16Array(a.data.buffer),this.vertexFreeAreas=[new aJ(0,9*t)]}var t=e.prototype;return t.allocateSubChunk=function(t){var n=this._allocateArea(9*t);if(n){var r=e.subChunkPool.get();r.chunk=this,r.vertexArea=n;var a=e.subMeshPool.get();return a.topology=ar.Triangles,r.subMesh=a,r}return null},t.freeSubChunk=function(t){this._freeArea(t.vertexArea),e.subMeshPool.return(t.subMesh),e.subChunkPool.return(t)},t.uploadBuffer=function(){var e=this.primitive,t=this.updateVertexStart,n=this.updateVertexEnd;t!==Number.MAX_SAFE_INTEGER&&n!==Number.MIN_SAFE_INTEGER&&(e.vertexBufferBindings[0].buffer.setData(this.vertices,4*t,t,n-t,r5.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER),e.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,r5.Discard),this.updateIndexLength=0},t.destroy=function(){this.primitive._addReferCount(-1),this.primitive.destroy(),this.primitive=null,this.vertices=null,this.indices=null},t._allocateArea=function(t){for(var n=this.vertexFreeAreas,r=e.areaPool,a=0,i=n.length;a<i;++a){var o=n[a],s=o.size;if(s>t){var l=r.get();return l.start=o.start,l.size=t,o.start+=t,o.size-=t,l}if(s===t)return n.splice(a,1),o}return null},t._freeArea=function(t){for(var n=t.start,r=t.size,a=this.vertexFreeAreas,i=n+r,o=e.areaPool,s=0,l=a.length;s<l;++s){var c=a[s],u=c.start,d=u+c.size;if(i<u){a.splice(s,0,t);return}if(i===u){c.start=n,c.size+=r,o.return(t);return}if(n===d){c.size+=r,o.return(t);var h=s+1;if(h<l){var _=a[h];i===_.start&&(c.size+=_.size,a.splice(h,1),o.return(_))}return}}a.push(t)},e}();a$.areaPool=new aQ(aJ,10),a$.subChunkPool=new aQ(aZ,10),a$.subMeshPool=new aQ(ay,10);var a0=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t=4096),this.engine=e,this.maxVertexCount=t,this.primitiveChunks=[]}var t=e.prototype;return t.allocateSubChunk=function(e){for(var t=this.primitiveChunks,n=t.length,r=null,a=0;a<n;++a)if(r=t[a].allocateSubChunk(e))return r;return(t[n]||(t[n]=new a$(this.engine,this.maxVertexCount))).allocateSubChunk(e)},t.freeSubChunk=function(e){e.chunk.freeSubChunk(e)},t.uploadBuffer=function(){for(var e=this.primitiveChunks,t=0,n=e.length;t<n;++t)e[t].uploadBuffer()},t.destroy=function(){for(var e=this.primitiveChunks,t=0,n=e.length;t<n;++t)e[t].destroy();e.length=0,this.primitiveChunks=null,this.engine=null},e}(),a1=/*#__PURE__*/function(){function e(e){this.primitiveChunkManager2D=new a0(e),this.primitiveChunkManagerMask=new a0(e,128)}var t=e.prototype;return t.destroy=function(){this.primitiveChunkManager2D.destroy(),this.primitiveChunkManagerMask.destroy(),this.primitiveChunkManager2D=null,this.primitiveChunkManagerMask=null},t.batch=function(e){for(var t,n,r,a=e.elements,i=e.batchedSubElements,o=e.renderQueueType,s=0,l=a.length;s<l;++s)for(var c=a[s].subRenderElements,u=0,d=c.length;u<d;++u){var h=c[u];if(h.renderQueueFlags&1<<o){var _=h.component,f=_.constructor;t?r===f&&n._canBatch(t,h)?(n._batch(t,h),t.batched=!0):(i.push(t),t=h,n=_,r=f,_._batch(h),h.batched=!1):(t=h,n=_,r=f,_._batch(h),h.batched=!1)}}t&&i.push(t)},t.uploadBuffer=function(){this.primitiveChunkManager2D.uploadBuffer(),this.primitiveChunkManagerMask.uploadBuffer()},e}(),a2=((ev={}).Text="Text",ev.JSON="JSON",ev.Buffer="Buffer",ev.Texture2D="Texture2D",ev.TextureCube="TextureCube",ev.Material="Material",ev.Shader="Shader",ev.Mesh="Mesh",ev.AnimationClip="AnimationClip",ev.AnimatorController="AnimatorController",ev.Prefab="Prefab",ev.GLTF="GLTF",ev.KTX="KTX",ev.KTXCube="KTXCube",ev.KTX2="KTX2",ev.Sprite="Sprite",ev.PrimitiveMesh="PrimitiveMesh",ev.SpriteAtlas="SpriteAtlas",ev.Env="Environment",ev.Scene="Scene",ev.HDR="HDR",ev.Font="Font",ev.SourceFont="SourceFont",ev.Project="project",ev),a3=/*#__PURE__*/function(){function e(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}var t=e.prototype;return t.push=function(e){this._array.push(e),this._loopArrayDirty=!0},t.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},t.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},t.findAndRemove=function(e){for(var t=this._array,n=t.length-1;n>=0;n--)e(t[n])&&this.removeByIndex(n)},t.indexOf=function(e){return this._array.indexOf(e)},t.getArray=function(){return this._array},t.getLoopArray=function(){var e=this._loopArray;if(this._loopArrayDirty){var t=this._array,n=t.length;e.length=n;for(var r=0;r<n;r++)e[r]=t[r];this._loopArrayDirty=!1}return e},tG(e,[{key:"length",get:function(){return this._array.length}}]),e}(),a4=/*#__PURE__*/function(){function e(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new a3}var t=e.prototype;return t.addScene=function(e,t){var n,r=this._scenes;if("number"==typeof e){if(e<0||e>r.length)throw"The index is out of range.";n=e}else n=r.length,t=e;if(t.engine!==this.engine)throw"The scene is not belong to this engine.";if(t._sceneManager){var a=r.indexOf(t);a!==n&&(r.removeByIndex(a),r.add(n,t))}else t._sceneManager=this,r.add(n,t),t.isActive&&t._processActive(!0)},t.removeScene=function(e){var t=this._scenes,n=t.indexOf(e);if(-1!==n){var r=t.getArray()[n];t.removeByIndex(n),e._sceneManager=null,r.isActive&&r._processActive(!1)}},t.loadScene=function(e,t){var n=this;void 0===t&&(t=!0);var r=this.engine.resourceManager.load({url:e,type:a2.Scene});return r.then(function(e){if(t)for(var r=n._scenes.getArray(),a=0,i=r.length;a<i;a++)r[a].destroy();n.addScene(e)}),r},t.mergeScenes=function(e,t){for(var n=e.rootEntities;n.length>0;)t.addRootEntity(n[0])},t._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},tG(e,[{key:"scenes",get:function(){return this._scenes.getArray()}},{key:"activeScene",get:function(){return this._scenes.getArray()[0]},set:function(e){var t=this.scenes[0];t&&this.removeScene(t),e&&this.addScene(0,e)}}]),e}(),a8=/*#__PURE__*/function(){function e(e){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(n,r){t._reject=r,e(function(e){"pending"===t._state&&(n(e),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e){"pending"===t._state&&(r(e),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e,n){if("pending"===t._state){var r=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:e,total:n});r.loaded=e,r.total=n,t._onTaskCompleteCallbacks.forEach(function(t){return t(e,n)})}},function(e,n,r){if("pending"===t._state){t._taskDetailProgress||(t._taskDetailProgress={});var a,i=(a=t._taskDetailProgress)[e]||(a[e]={loaded:n,total:r});i.loaded=n,i.total=r,t._onTaskDetailCallbacks.forEach(function(t){return t(e,n,r)})}},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}var t=e.prototype;return t.onProgress=function(e,t){var n=this._taskCompleteProgress,r=this._taskDetailProgress;if(n&&e(n.loaded,n.total),r)for(var a in r){var i=r[a];t(a,i.loaded,i.total)}return"pending"===this._state&&(e&&this._onTaskCompleteCallbacks.push(e),t&&this._onTaskDetailCallbacks.push(t)),this},t.then=function(t,n){var r=this;return new e(function(e,a){r._promise.then(t,n).then(e).catch(a)})},t.catch=function(t){var n=this;return new e(function(e,r){n._promise.catch(t).then(e).catch(r)})},t.finally=function(e){return this._promise.finally(e)},t.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},e.all=function(t){return new e(function(n,r,a){var i=function(e,t){c++,l[e]=t,a(c,s),c===s&&n(l)},o=function(t,n){tK(t,Promise)||tK(t,e)?t.then(function(e){i(n,e)},r):Promise.resolve().then(function(){i(n,t)})},s=t.length,l=Array(s),c=0;if(0===s)return n(l);for(var u=0;u<s;u++)o(t[u],u)})},tG(e,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),e}(),a5={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},a9=1/0;function a6(e,t){return void 0===t&&(t={}),new a8(function(n,r,a,i){var o,s,l,c,u=null!=(o=t.retryCount)?o:1,d=null!=(s=t.retryInterval)?s:500;t.timeout=null!=(l=t.timeout)?l:a9,t.type=null!=(c=t.type)?c:a5[e.substring(e.lastIndexOf(".")+1)],new a7(function(){var n;return(n=t,new a8(function(t,r,a,i){var o,s=new XMLHttpRequest,l="image"===n.type;s.timeout=n.timeout,n.method=null!=(o=n.method)?o:"get",s.onload=function(){if(s.status<200||s.status>=300){r(Error("request failed from: "+e));return}var n,i=null!=(n=s.response)?n:s.responseText;if(l){var o=new Image;o.onload=function(){requestAnimationFrame(function(){a(1,1),t(o),o.onload=null,o.onerror=null,o.onabort=null,URL.revokeObjectURL(o.src)})},o.onerror=o.onabort=function(){r(Error("request "+o.src+" fail")),URL.revokeObjectURL(o.src)},o.crossOrigin="anonymous",o.src=URL.createObjectURL(i)}else a(1,1),t(i)},s.onerror=function(){r(Error("request failed from: "+e))},s.ontimeout=function(){r(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&i(e,t.loaded,t.total)},s.open(n.method,e,!0),s.withCredentials="include"===n.credentials,s.responseType=l?"blob":n.type;var c=n.headers;c&&Object.keys(c).forEach(function(e){s.setRequestHeader(e,c[e])}),s.send(n.body)})).onProgress(a,i)},u,d).start().onError(r).onComplete(n)})}var a7=/*#__PURE__*/function(){function e(e,t,n){this.execFunc=e,this.totalCount=t,this.interval=n,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}var t=e.prototype;return t.start=function(){return this.exec(),this},t.onComplete=function(e){return this._onComplete=e,this},t.onError=function(e){return this._onError=e,this},t.cancel=function(){window.clearTimeout(this._timeoutId)},t.exec=function(){var e=this;if(this._currentCount>=this.totalCount){this._onError&&this._onError(this._error);return}this._currentCount++,this.execFunc(this._currentCount).then(function(t){return e._onComplete&&e._onComplete(t)}).catch(function(t){e._error=t,e._timeoutId=window.setTimeout(e.exec,e.interval)})},e}(),ie=/*#__PURE__*/function(){function e(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this.baseUrl=null,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._subAssetPromiseCallbacks={},this._objectPool=Object.create(null),this._editorResourceConfig=Object.create(null),this._virtualPathMap=Object.create(null)}var t=e.prototype;return t.load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var n=e.map(function(e){return t._loadSingleItem(e)});return a8.all(n)},t.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},t.findResourcesByType=function(e){var t=[],n=this._referResourcePool;for(var r in n){var a=n[r];tK(a,e)&&t.push(a)}return t},t.getAssetPath=function(e){return this._assetPool[e]},t.cancelNotLoaded=function(e){var t,n=this;e?"string"==typeof e?null==(t=this._loadingPromises[e])||t.cancel():e.forEach(function(e){var t;null==(t=n._loadingPromises[e])||t.cancel()}):nT.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},t.gc=function(){this._gc(!1),this.engine._pendingGC()},t.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},t._getRemoteUrl=function(e){var t;return null!=(t=this._virtualPathMap[e])?t:e},t._requestByRemoteUrl=function(e,t){return a6(e,t)},t._request=function(e,t){var n=this._getRemoteUrl(e);return this._requestByRemoteUrl(n,t)},t._onSubAssetSuccess=function(e,t,n){var r,a,i,o=null!=(a=this._virtualPathMap[e])?a:e,s=null==(r=this._subAssetPromiseCallbacks[o])?void 0:r[t];s?s.resolve(n):((i=this._subAssetPromiseCallbacks)[o]||(i[o]={}))[t]={resolvedValue:n}},t._onSubAssetFail=function(e,t,n){var r,a,i=null==(r=this._subAssetPromiseCallbacks[e])?void 0:r[t];i?i.reject(n):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={rejectedValue:n}},t._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},t._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},t._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},t._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},t._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},t._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},t._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},t._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},t._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},t._restoreResourcesContent=function(){var e=this._contentRestorerPool,t=[];for(var n in e){var r=e[n].restoreContent();r&&t.push(r)}return Promise.all(t)},t._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._referResourcePool=null,this._graphicResourcePool=null,this._contentRestorerPool=null,this._loadingPromises=null},t._assignDefaultOptions=function(t){var n,r,a,i,o;if(t.type=null!=(n=t.type)?n:e._getTypeByUrl(t.url),void 0===t.type)throw"asset type should be specified: "+t.url;return t.retryCount=null!=(r=t.retryCount)?r:this.retryCount,t.timeout=null!=(a=t.timeout)?a:this.timeout,t.retryInterval=null!=(i=t.retryInterval)?i:this.retryInterval,t.url=null!=(o=t.url)?o:t.urls.join(","),t},t._loadSingleItem=function(t){var n,r,a=this,i=this._assignDefaultOptions("string"==typeof t?{url:t}:t),o=i.url;!nT.isAbsoluteUrl(o)&&this.baseUrl&&(o=nT.resolveAbsoluteUrl(this.baseUrl,o));var s=this._parseURL(o),l=s.assetBaseURL,c=s.queryPath,u=c?this._parseQueryPath(c):[],d=null!=(n=this._virtualPathMap[l])?n:l,h=this._assetUrlPool[d];if(h)return new a8(function(e){e(a._getResolveResource(h,u))});var _=d;if(c)for(_+="?q="+u.shift();r=u.shift();)_+="["+r+"]";var f=this._loadingPromises,p=f[_];if(p)return new a8(function(e,t,n,r){p.onProgress(n,r).then(function(t){e(t)}).catch(function(e){t(e)})});var m=e._loaders[i.type];if(!m)throw"loader not found: "+i.type;return c?((f[d]||this._loadMainAsset(m,i,d,l)).catch(function(e){a._onSubAssetFail(d,c,e)}),this._createSubAssetPromiseCallback(d,_,c)):this._loadMainAsset(m,i,d,l)},t._loadMainAsset=function(e,t,n,r){var a=this;t.url=r;var i=this._loadingPromises,o=e.load(t,this);return i[n]=o,o.then(function(t){e.useCache&&a._addAsset(n,t),delete i[n],a._releaseSubAssetPromiseCallback(n)},function(){delete i[n],a._releaseSubAssetPromiseCallback(n)}),o},t._createSubAssetPromiseCallback=function(e,t,n){var r,a=this,i=this._loadingPromises,o=null==(r=this._subAssetPromiseCallbacks[e])?void 0:r[n],s=null==o?void 0:o.resolvedValue,l=null==o?void 0:o.rejectedValue;if(s||l)return new a8(function(e,t){s?e(s):l&&t(l)});var c=new a8(function(t,r){var i;((i=a._subAssetPromiseCallbacks)[e]||(i[e]={}))[n]={resolve:t,reject:r}});return i[t]=c,c.then(function(){delete i[t]},function(){return delete i[t]}),c},t._gc=function(e){for(var t=nT.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++){var a=t[n];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},t._getResolveResource=function(e,t){var n=e;if(t)for(var r=0,a=t.length;r<a;r++)n=n[t[r]];return n},t._parseURL=function(e){var t=e.split("?"),n=t[0],r=t[1],a=void 0,i=n;if(r){for(var o=r.split("&"),s=0;s<o.length;s++){var l=o[s];if(l.startsWith("q=")){a=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}i=o.length>0?n+"?"+o.join("&"):n}return{assetBaseURL:i,queryPath:a}},t._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===ir&&t.push(""),e.replace(ii,function(e,n,r,a){var i=e;r?i=a.replace(ia,"$1"):n&&(i=n.trim()),t.push(i)}),t},t._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},t.getResourceByRef=function(e){var t,n=e.refId,r=e.key,a=e.isClone,i=this._objectPool[n];if(i)t=Promise.resolve(i);else{var o=this._editorResourceConfig[n];if(!o)return no.warn("refId:"+n+" is not find in this._editorResourceConfig."),Promise.resolve(null);var s=new URL(o.path).search,l=o.virtualPath+s;r&&(l+=(l.indexOf("?")>-1?"&":"?")+"q="+r),t=this.load({url:l,type:o.type})}return t.then(function(e){return a?e.clone():e})},t.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},e._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,a=n.length;r<a;r++)this._extTypeMapping[n[r].toLowerCase()]=e},e._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},e}();function it(e,t,n){return void 0===n&&(n=!0),function(r){var a=new r(n);ie._addLoader(e,a,t)}}ie._loaders={},ie._extTypeMapping={};var ir=46,ia=/\\(\\)?/g,ii=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),io=((ey={})[ey.Down=0]="Down",ey[ey.Move=1]="Move",ey[ey.Stationary=2]="Stationary",ey[ey.Up=3]="Up",ey[ey.Leave=4]="Leave",ey),is=/*#__PURE__*/function(){function e(e){this.phase=io.Leave,this.position=new tB,this.deltaPosition=new tB,this._events=[],this._upMap=[],this._downMap=[],this._upList=new rS,this._downList=new rS,this.id=e}var t=e.prototype;return t._firePointerExitAndEnter=function(e){var t=this;this._currentEnteredEntity!==e&&(this._currentEnteredEntity&&this._currentEnteredEntity._scripts.forEach(function(e){e.onPointerExit(t)},function(e,t){e._entityScriptsIndex=t}),e&&e._scripts.forEach(function(e){e.onPointerEnter(t)},function(e,t){e._entityScriptsIndex=t}),this._currentEnteredEntity=e)},t._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},t._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},t._firePointerUpAndClick=function(e){var t=this,n=this._currentPressedEntity;if(n){var r=n===e;n._scripts.forEach(function(e){r&&e.onPointerClick(t),e.onPointerUp(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=null}},e}(),il=((ex={})[ex.None=0]="None",ex[ex.Primary=1]="Primary",ex[ex.Secondary=2]="Secondary",ex[ex.Auxiliary=4]="Auxiliary",ex[ex.XButton1=8]="XButton1",ex[ex.XButton2=16]="XButton2",ex[ex.XButton3=32]="XButton3",ex[ex.XButton4=64]="XButton4",ex[ex.XButton5=128]="XButton5",ex[ex.XButton6=256]="XButton6",ex[ex.XButton7=512]="XButton7",ex[ex.XButton8=1024]="XButton8",ex),ic=[1,4,2,8,16,32,64,128,256,512,1024],iu={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},id=/*#__PURE__*/function(){function e(){}return e._initialize=function(){if("undefined"==typeof navigator){e._isBrowser=!1;return}var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?e.platform=tz.IPhone:/iPad/i.test(n)?e.platform=tz.IPad:/Android/i.test(n)?e.platform=tz.Android:/Macintosh/i.test(n)&&(e.platform=tz.Mac),e.platform){case tz.IPhone:t=n.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPhone OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPhone OS";break;case tz.IPad:t=n.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPad OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPad OS";break;case tz.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case tz.Mac:t=n.match(/Mac OS X (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"Mac OS X "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Mac OS X"}},e._detectSIMDSupported=function(){return null===this._simdSupported&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},tG(e,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),e}();id.platform=tz.Unknown,id.operatingSystem="",id._isBrowser=!0,id._simdSupported=null,id._initialize();var ih=((eb={})[eb.Backquote=0]="Backquote",eb[eb.Backslash=1]="Backslash",eb[eb.Backspace=2]="Backspace",eb[eb.BracketLeft=3]="BracketLeft",eb[eb.BracketRight=4]="BracketRight",eb[eb.Comma=5]="Comma",eb[eb.Digit0=6]="Digit0",eb[eb.Digit1=7]="Digit1",eb[eb.Digit2=8]="Digit2",eb[eb.Digit3=9]="Digit3",eb[eb.Digit4=10]="Digit4",eb[eb.Digit5=11]="Digit5",eb[eb.Digit6=12]="Digit6",eb[eb.Digit7=13]="Digit7",eb[eb.Digit8=14]="Digit8",eb[eb.Digit9=15]="Digit9",eb[eb.Equal=16]="Equal",eb[eb.IntlBackslash=17]="IntlBackslash",eb[eb.IntlRo=18]="IntlRo",eb[eb.IntlYen=19]="IntlYen",eb[eb.KeyA=20]="KeyA",eb[eb.KeyB=21]="KeyB",eb[eb.KeyC=22]="KeyC",eb[eb.KeyD=23]="KeyD",eb[eb.KeyE=24]="KeyE",eb[eb.KeyF=25]="KeyF",eb[eb.KeyG=26]="KeyG",eb[eb.KeyH=27]="KeyH",eb[eb.KeyI=28]="KeyI",eb[eb.KeyJ=29]="KeyJ",eb[eb.KeyK=30]="KeyK",eb[eb.KeyL=31]="KeyL",eb[eb.KeyM=32]="KeyM",eb[eb.KeyN=33]="KeyN",eb[eb.KeyO=34]="KeyO",eb[eb.KeyP=35]="KeyP",eb[eb.KeyQ=36]="KeyQ",eb[eb.KeyR=37]="KeyR",eb[eb.KeyS=38]="KeyS",eb[eb.KeyT=39]="KeyT",eb[eb.KeyU=40]="KeyU",eb[eb.KeyV=41]="KeyV",eb[eb.KeyW=42]="KeyW",eb[eb.KeyX=43]="KeyX",eb[eb.KeyY=44]="KeyY",eb[eb.KeyZ=45]="KeyZ",eb[eb.Minus=46]="Minus",eb[eb.Period=47]="Period",eb[eb.Quote=48]="Quote",eb[eb.Semicolon=49]="Semicolon",eb[eb.Slash=50]="Slash",eb[eb.AltLeft=51]="AltLeft",eb[eb.AltRight=52]="AltRight",eb[eb.CapsLock=53]="CapsLock",eb[eb.ContextMenu=54]="ContextMenu",eb[eb.ControlLeft=55]="ControlLeft",eb[eb.ControlRight=56]="ControlRight",eb[eb.Enter=57]="Enter",eb[eb.MetaLeft=58]="MetaLeft",eb[eb.MetaRight=59]="MetaRight",eb[eb.ShiftLeft=60]="ShiftLeft",eb[eb.ShiftRight=61]="ShiftRight",eb[eb.Space=62]="Space",eb[eb.Tab=63]="Tab",eb[eb.Convert=64]="Convert",eb[eb.KanaMode=65]="KanaMode",eb[eb.Lang1=66]="Lang1",eb[eb.Lang2=67]="Lang2",eb[eb.Lang3=68]="Lang3",eb[eb.Lang4=69]="Lang4",eb[eb.Lang5=70]="Lang5",eb[eb.NonConvert=71]="NonConvert",eb[eb.Delete=72]="Delete",eb[eb.End=73]="End",eb[eb.Help=74]="Help",eb[eb.Home=75]="Home",eb[eb.Insert=76]="Insert",eb[eb.PageDown=77]="PageDown",eb[eb.PageUp=78]="PageUp",eb[eb.ArrowDown=79]="ArrowDown",eb[eb.ArrowLeft=80]="ArrowLeft",eb[eb.ArrowRight=81]="ArrowRight",eb[eb.ArrowUp=82]="ArrowUp",eb[eb.NumLock=83]="NumLock",eb[eb.Numpad0=84]="Numpad0",eb[eb.Numpad1=85]="Numpad1",eb[eb.Numpad2=86]="Numpad2",eb[eb.Numpad3=87]="Numpad3",eb[eb.Numpad4=88]="Numpad4",eb[eb.Numpad5=89]="Numpad5",eb[eb.Numpad6=90]="Numpad6",eb[eb.Numpad7=91]="Numpad7",eb[eb.Numpad8=92]="Numpad8",eb[eb.Numpad9=93]="Numpad9",eb[eb.NumpadAdd=94]="NumpadAdd",eb[eb.NumpadBackspace=95]="NumpadBackspace",eb[eb.NumpadClear=96]="NumpadClear",eb[eb.NumpadClearEntry=97]="NumpadClearEntry",eb[eb.NumpadComma=98]="NumpadComma",eb[eb.NumpadDecimal=99]="NumpadDecimal",eb[eb.NumpadDivide=100]="NumpadDivide",eb[eb.NumpadEnter=101]="NumpadEnter",eb[eb.NumpadEqual=102]="NumpadEqual",eb[eb.NumpadHash=103]="NumpadHash",eb[eb.NumpadMemoryAdd=104]="NumpadMemoryAdd",eb[eb.NumpadMemoryClear=105]="NumpadMemoryClear",eb[eb.NumpadMemoryRecall=106]="NumpadMemoryRecall",eb[eb.NumpadMemoryStore=107]="NumpadMemoryStore",eb[eb.NumpadMemorySubtract=108]="NumpadMemorySubtract",eb[eb.NumpadMultiply=109]="NumpadMultiply",eb[eb.NumpadParenLeft=110]="NumpadParenLeft",eb[eb.NumpadParenRight=111]="NumpadParenRight",eb[eb.NumpadStar=112]="NumpadStar",eb[eb.NumpadSubtract=113]="NumpadSubtract",eb[eb.Escape=114]="Escape",eb[eb.F1=115]="F1",eb[eb.F2=116]="F2",eb[eb.F3=117]="F3",eb[eb.F4=118]="F4",eb[eb.F5=119]="F5",eb[eb.F6=120]="F6",eb[eb.F7=121]="F7",eb[eb.F8=122]="F8",eb[eb.F9=123]="F9",eb[eb.F10=124]="F10",eb[eb.F11=125]="F11",eb[eb.F12=126]="F12",eb[eb.F13=127]="F13",eb[eb.F14=128]="F14",eb[eb.F15=129]="F15",eb[eb.Fn=130]="Fn",eb[eb.FnLock=131]="FnLock",eb[eb.PrintScreen=132]="PrintScreen",eb[eb.ScrollLock=133]="ScrollLock",eb[eb.Pause=134]="Pause",eb[eb.BrowserBack=135]="BrowserBack",eb[eb.BrowserFavorites=136]="BrowserFavorites",eb[eb.BrowserForward=137]="BrowserForward",eb[eb.BrowserHome=138]="BrowserHome",eb[eb.BrowserRefresh=139]="BrowserRefresh",eb[eb.BrowserSearch=140]="BrowserSearch",eb[eb.BrowserStop=141]="BrowserStop",eb[eb.Eject=142]="Eject",eb[eb.LaunchApp1=143]="LaunchApp1",eb[eb.LaunchApp2=144]="LaunchApp2",eb[eb.LaunchMail=145]="LaunchMail",eb[eb.MediaPlayPause=146]="MediaPlayPause",eb[eb.MediaSelect=147]="MediaSelect",eb[eb.MediaStop=148]="MediaStop",eb[eb.MediaTrackNext=149]="MediaTrackNext",eb[eb.MediaTrackPrevious=150]="MediaTrackPrevious",eb[eb.Power=151]="Power",eb[eb.Sleep=152]="Sleep",eb[eb.AudioVolumeDown=153]="AudioVolumeDown",eb[eb.AudioVolumeMute=154]="AudioVolumeMute",eb[eb.AudioVolumeUp=155]="AudioVolumeUp",eb[eb.WakeUp=156]="WakeUp",eb[eb.Hyper=157]="Hyper",eb[eb.Super=158]="Super",eb[eb.Turbo=159]="Turbo",eb[eb.Abort=160]="Abort",eb[eb.Resume=161]="Resume",eb[eb.Suspend=162]="Suspend",eb[eb.Again=163]="Again",eb[eb.Copy=164]="Copy",eb[eb.Cut=165]="Cut",eb[eb.Find=166]="Find",eb[eb.Open=167]="Open",eb[eb.Paste=168]="Paste",eb[eb.Props=169]="Props",eb[eb.Select=170]="Select",eb[eb.Undo=171]="Undo",eb[eb.Hiragana=172]="Hiragana",eb[eb.Katakana=173]="Katakana",eb[eb.Unidentified=174]="Unidentified",eb),i_=/*#__PURE__*/function(){function e(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new rS,this._curFrameDownList=new rS,this._curFrameUpList=new rS,this._nativeEvents=[],this._engine=e,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}var t=e.prototype;return t._update=function(){var e=this._nativeEvents,t=this._curFrameDownList,n=this._curFrameUpList;if(t.length=0,n.length=0,e.length>0){for(var r=this._engine.time.frameCount,a=this._curHeldDownKeyToIndexMap,i=this._curFrameHeldDownList,o=this._downKeyToFrameCountMap,s=this._upKeyToFrameCountMap,l=0,c=e.length;l<c;l++){var u=e[l],d=ih[u.code];switch(u.type){case"keydown":null==a[d]&&(t.add(d),i.add(d),a[d]=i.length-1,o[d]=r);break;case"keyup":var h=a[d];if(null!=h){a[d]=null;var _=i.deleteByIndex(h);_&&(a[_]=h)}if(n.add(d),s[d]=r,id.platform===tz.Mac&&(d===ih.MetaLeft||d===ih.MetaRight)){for(var f=0,p=i.length;f<p;f++)a[i.get(f)]=null;i.length=0}}}e.length=0}},t._destroy=function(){this._removeEventListener(),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._engine=null},t._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},t._onKeyEvent=function(e){this._nativeEvents.push(e)},t._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},t._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},e}();e.Collider=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._index=-1,n._shapes=[],n._updateFlag=n.entity.transform.registerWorldChangeFlag(),n}tW(t,e);var n=t.prototype;return n.addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e))},n.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this._phasedActiveInScene&&this.scene.physics._removeColliderShape(e),e._collider=null,this._nativeCollider.removeShape(e._nativeShape))},n.clearShapes=function(){for(var e=this._shapes,t=0,n=e.length;t<n;t++){var r=e[t];this._phasedActiveInScene&&this.scene.physics._removeColliderShape(r),r._destroy(),this._nativeCollider.removeShape(r._nativeShape)}e.length=0},n._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform;this._nativeCollider.setWorldTransform(e.worldPosition,e.worldRotationQuaternion);for(var t=e.lossyWorldScale,n=0,r=this.shapes.length;n<r;n++)this.shapes[n]._nativeShape.setWorldScale(t);this._updateFlag.flag=!1}},n._onLateUpdate=function(){},n._onEnableInScene=function(){var e=this.scene.physics;e._addCollider(this);for(var t=this.shapes,n=0,r=t.length;n<r;n++)e._addColliderShape(t[n])},n._onDisableInScene=function(){var e=this.scene.physics;e._removeCollider(this);for(var t=this.shapes,n=0,r=t.length;n<r;n++)e._removeColliderShape(t[n])},n._cloneTo=function(e){for(var t=e._shapes,n=0,r=t.length;n<r;n++)e._addPhysicsShape(t[n])},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},n._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},tG(t,[{key:"shapes",get:function(){return this._shapes}}]),t}(ru),tX([tq],e.Collider.prototype,"_index",void 0),tX([tq],e.Collider.prototype,"_nativeCollider",void 0),tX([tq],e.Collider.prototype,"_updateFlag",void 0),tX([tJ],e.Collider.prototype,"_shapes",void 0),e.Collider=tX([rh(rp,r_.CheckOnly)],e.Collider);var ip=/*#__PURE__*/function(){function e(t){var n=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new rS,this._gravity=new tT(0,-9.81,0),this._onContactEnter=function(t,r){var a=n._scene.engine._physicalObjectsMap,i=a[t],o=a[r];i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=o,t.onCollisionEnter(n)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionEnter(n)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(t,r){var a=n._scene.engine._physicalObjectsMap,i=a[t],o=a[r];i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=o,t.onCollisionExit(n)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionExit(n)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(t,r){var a=n._scene.engine._physicalObjectsMap,i=a[t],o=a[r];i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=o,t.onCollisionStay(n)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionStay(n)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var r=n._scene.engine._physicalObjectsMap,a=r[e],i=r[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var r=n._scene.engine._physicalObjectsMap,a=r[e],i=r[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var r=n._scene.engine._physicalObjectsMap,a=r[e],i=r[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t})},this._scene=t,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var r=t.engine;r._physicsInitialized&&(this._nativePhysicsScene=e._nativePhysics.createPhysicsScene(r._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var t=e.prototype;return t.raycast=function(e,t,n,r){var a,i=this,o=Number.MAX_VALUE;"number"==typeof t?o=t:void 0!=t&&(a=t);var s=rE.Everything;"number"==typeof n?s=n:void 0!=n&&(a=n),r&&(a=r);var l=function(e){var t=i._scene.engine._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&s&&t.isSceneQuery};return void 0==a?this._nativePhysicsScene.raycast(e,o,l):!!this._nativePhysicsScene.raycast(e,o,l,function(e,t,n,r){var o=i._scene.engine._physicalObjectsMap[e];a.entity=o._collider.entity,a.shape=o,a.distance=t,a.normal.copyFrom(r),a.point.copyFrom(n)})||(a.entity=null,a.shape=null,a.distance=0,a.point.set(0,0,0),a.normal.set(0,0,0),!1)},t._update=function(e){var t=this._fixedTimeStep,n=this._nativePhysicsScene,r=this._scene._componentsManager,a=this._restTime+e,i=Math.floor(a/t);this._restTime=a-i*t;for(var o=0;o<i;o++)r.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),n.update(t),this._callColliderOnLateUpdate()},t._addColliderShape=function(e){this._scene.engine._physicalObjectsMap[e.id]=e,this._nativePhysicsScene.addColliderShape(e._nativeShape)},t._removeColliderShape=function(e){delete this._scene.engine._physicalObjectsMap[e.id],this._nativePhysicsScene.removeColliderShape(e._nativeShape)},t._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},t._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},t._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},t._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},t._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},t._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},t._gc=function(){this._colliders.garbageCollection()},t._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},tG(e,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(e){this._fixedTimeStep=Math.max(e,tC.zeroTolerance)}}]),e}();ip._collision=new function(){};var im=((eS={})[eS.PreventClimbing=0]="PreventClimbing",eS[eS.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding",eS),ig=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=im.PreventClimbing,n._upDirection=new tT(0,1,0),n._slopeLimit=.707,n._nativeCollider=ip._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(n),n._upDirection._onValueChanged=n._setUpDirection,n._onUpdate(),n}tW(t,e);var n=t.prototype;return n.move=function(e,t,n){var r=this._nativeCollider.move(e,t,n);return this._syncWorldPositionFromPhysicalSpace(),r},n.addShape=function(t){if(this._shapes.length>0)throw"only allow single shape on controller!";e.prototype.addShape.call(this,t),this._updateFlag.flag=!0},n.clearShapes=function(){this._shapes.length>0&&e.prototype.removeShape.call(this,this._shapes[0])},n._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,t=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var n=e.lossyWorldScale,r=0,a=t.length;r<a;r++)t[r]._nativeShape.setWorldScale(n);this._updateFlag.flag=!1}},n._onLateUpdate=function(){this._syncWorldPositionFromPhysicalSpace(),this._updateFlag.flag=!1},n._onEnableInScene=function(){var e=this.scene.physics;e._addCharacterController(this);for(var t=this.shapes,n=0,r=t.length;n<r;n++)e._addColliderShape(t[n])},n._onDisableInScene=function(){var e=this.scene.physics;e._removeCharacterController(this);for(var t=this.shapes,n=0,r=t.length;n<r;n++)e._removeColliderShape(t[n])},n._syncWorldPositionFromPhysicalSpace=function(){this._nativeCollider.getWorldPosition(this.entity.transform.worldPosition)},n._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},tG(t,[{key:"stepOffset",get:function(){return this._stepOffset},set:function(e){this._stepOffset!==e&&(this._stepOffset=e,this._nativeCollider.setStepOffset(e))}},{key:"nonWalkableMode",get:function(){return this._nonWalkableMode},set:function(e){this._nonWalkableMode!==e&&(this._nonWalkableMode=e,this._nativeCollider.setNonWalkableMode(e))}},{key:"upDirection",get:function(){return this._upDirection},set:function(e){this._upDirection!==e&&this._upDirection.copyFrom(e)}},{key:"slopeLimit",get:function(){return this._slopeLimit},set:function(e){this._slopeLimit!==e&&(this._slopeLimit=e,this._nativeCollider.setSlopeLimit(e))}}]),t}(e.Collider),iv=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._linearDamping=0,n._angularDamping=.05,n._linearVelocity=new tT,n._angularVelocity=new tT,n._mass=1,n._centerOfMass=new tT,n._inertiaTensor=new tT(1,1,1),n._maxAngularVelocity=100,n._maxDepenetrationVelocity=1e3,n._solverIterations=4,n._isKinematic=!1,n._constraints=0,n._collisionDetectionMode=0,n._sleepThreshold=.005;var n,r=n.entity.transform;return n._nativeCollider=ip._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),n._setLinearVelocity=n._setLinearVelocity.bind(n),n._setAngularVelocity=n._setAngularVelocity.bind(n),n._setCenterOfMass=n._setCenterOfMass.bind(n),n._setInertiaTensor=n._setInertiaTensor.bind(n),n._linearVelocity._onValueChanged=n._setLinearVelocity,n._angularVelocity._onValueChanged=n._setAngularVelocity,n._centerOfMass._onValueChanged=n._setCenterOfMass,n._inertiaTensor._onValueChanged=n._setInertiaTensor,n}tW(t,e);var n=t.prototype;return n.applyForce=function(e){this._nativeCollider.addForce(e)},n.applyTorque=function(e){this._nativeCollider.addTorque(e)},n.move=function(e,t){this._nativeCollider.move(e,t)},n.sleep=function(){this._nativeCollider.sleep()},n.wakeUp=function(){this._nativeCollider.wakeUp()},n._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},n._cloneTo=function(t){e.prototype._cloneTo.call(this,t),t.linearDamping=this.linearDamping,t.angularDamping=this.angularDamping,t.linearVelocity=this.linearVelocity,t.angularVelocity=this.angularVelocity,t.mass=this.mass,t.centerOfMass=this.centerOfMass,t.inertiaTensor=this.inertiaTensor,t.maxAngularVelocity=this.maxAngularVelocity,t.maxDepenetrationVelocity=this.maxDepenetrationVelocity,t.sleepThreshold=this.sleepThreshold,t.solverIterations=this.solverIterations,t.isKinematic=this.isKinematic,t.constraints=this.constraints,t.collisionDetectionMode=this.collisionDetectionMode},n._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},n._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},n._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},n._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},tG(t,[{key:"linearDamping",get:function(){return this._linearDamping},set:function(e){this._linearDamping!==e&&(this._linearDamping=e,this._nativeCollider.setLinearDamping(e))}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(e){this._angularDamping!==e&&(this._angularDamping=e,this._nativeCollider.setAngularDamping(e))}},{key:"linearVelocity",get:function(){return this._linearVelocity},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))}}]),t}(e.Collider);tX([tq],iv.prototype,"_linearDamping",void 0),tX([tq],iv.prototype,"_angularDamping",void 0),tX([tq],iv.prototype,"_linearVelocity",void 0),tX([tq],iv.prototype,"_angularVelocity",void 0),tX([tq],iv.prototype,"_mass",void 0),tX([tq],iv.prototype,"_centerOfMass",void 0),tX([tq],iv.prototype,"_inertiaTensor",void 0),tX([tq],iv.prototype,"_maxAngularVelocity",void 0),tX([tq],iv.prototype,"_maxDepenetrationVelocity",void 0),tX([tq],iv.prototype,"_solverIterations",void 0),tX([tq],iv.prototype,"_isKinematic",void 0),tX([tq],iv.prototype,"_constraints",void 0),tX([tq],iv.prototype,"_collisionDetectionMode",void 0),tX([tq],iv.prototype,"_sleepThreshold",void 0);var iy=((eC={})[eC.Discrete=0]="Discrete",eC[eC.Continuous=1]="Continuous",eC[eC.ContinuousDynamic=2]="ContinuousDynamic",eC[eC.ContinuousSpeculative=3]="ContinuousSpeculative",eC),ix=((eT={})[eT.None=0]="None",eT[eT.FreezePositionX=1]="FreezePositionX",eT[eT.FreezePositionY=2]="FreezePositionY",eT[eT.FreezePositionZ=4]="FreezePositionZ",eT[eT.FreezeRotationX=8]="FreezeRotationX",eT[eT.FreezeRotationY=16]="FreezeRotationY",eT[eT.FreezeRotationZ=32]="FreezeRotationZ",eT),ib=function(){this.entity=null,this.distance=0,this.point=new tT,this.normal=new tT,this.shape=null},iS=((eA={})[eA.Average=0]="Average",eA[eA.Minimum=1]="Minimum",eA[eA.Multiply=2]="Multiply",eA[eA.Maximum=3]="Maximum",eA),iC=/*#__PURE__*/function(){function e(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=iS.Average,this._frictionCombine=iS.Average,this._nativeMaterial=ip._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}return e.prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},tG(e,[{key:"bounciness",get:function(){return this._bounciness},set:function(e){this._bounciness!==e&&(this._bounciness=e,this._nativeMaterial.setBounciness(e))}},{key:"dynamicFriction",get:function(){return this._dynamicFriction},set:function(e){this._dynamicFriction!==e&&(this._dynamicFriction=e,this._nativeMaterial.setDynamicFriction(e))}},{key:"staticFriction",get:function(){return this._staticFriction},set:function(e){this._staticFriction!==e&&(this._staticFriction=e,this._nativeMaterial.setStaticFriction(e))}},{key:"bounceCombine",get:function(){return this._bounceCombine},set:function(e){this._bounceCombine!==e&&(this._bounceCombine=e,this._nativeMaterial.setBounceCombine(e))}},{key:"frictionCombine",get:function(){return this._frictionCombine},set:function(e){this._frictionCombine!==e&&(this._frictionCombine=e,this._nativeMaterial.setFrictionCombine(e))}}]),e}(),iT=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t)||this).entity.transform;return n._nativeCollider=ip._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),n}return tW(t,e),t}(e.Collider),iA=((eE={})[eE.X=0]="X",eE[eE.Y=1]="Y",eE[eE.Z=2]="Z",eE),iE=((eR={})[eR.Sides=1]="Sides",eR[eR.Up=2]="Up",eR[eR.Down=4]="Down",eR);e.Joint=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._colliderInfo=new iR,n._connectedColliderInfo=new iR,n._force=0,n._torque=0,n._connectedColliderInfo.localPosition=new tT,n}return tW(t,e),t.prototype._cloneTo=function(e){e.connectedCollider=this.connectedCollider,e.connectedAnchor=this.connectedAnchor,e.connectedMassScale=this.connectedMassScale,e.connectedInertiaScale=this.connectedInertiaScale,e.massScale=this.massScale,e.inertiaScale=this.inertiaScale,e.breakForce=this.breakForce,e.breakTorque=this.breakTorque},tG(t,[{key:"connectedCollider",get:function(){return this._connectedColliderInfo.collider},set:function(e){this._connectedColliderInfo.collider!==e&&(this._connectedColliderInfo.collider=e,this._nativeJoint.setConnectedCollider(e._nativeCollider))}},{key:"connectedAnchor",get:function(){return this._connectedColliderInfo.localPosition},set:function(e){var t=this._connectedColliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setConnectedAnchor(e)}},{key:"connectedMassScale",get:function(){return this._connectedColliderInfo.massScale},set:function(e){e!==this._connectedColliderInfo.massScale&&(this._connectedColliderInfo.massScale=e,this._nativeJoint.setConnectedMassScale(e))}},{key:"connectedInertiaScale",get:function(){return this._connectedColliderInfo.inertiaScale},set:function(e){e!==this._connectedColliderInfo.inertiaScale&&(this._connectedColliderInfo.inertiaScale=e,this._nativeJoint.setConnectedInertiaScale(e))}},{key:"massScale",get:function(){return this._colliderInfo.massScale},set:function(e){e!==this._colliderInfo.massScale&&(this._colliderInfo.massScale=e,this._nativeJoint.setMassScale(e))}},{key:"inertiaScale",get:function(){return this._colliderInfo.inertiaScale},set:function(e){e!==this._colliderInfo.inertiaScale&&(this._colliderInfo.inertiaScale=e,this._nativeJoint.setInertiaScale(e))}},{key:"breakForce",get:function(){return this._force},set:function(e){e!==this._force&&(this._force=e,this._nativeJoint.setBreakForce(e))}},{key:"breakTorque",get:function(){return this._torque},set:function(e){e!==this._torque&&(this._torque=e,this._nativeJoint.setBreakTorque(e))}}]),t}(ru),tX([tq],e.Joint.prototype,"_colliderInfo",void 0),tX([tq],e.Joint.prototype,"_connectedColliderInfo",void 0),tX([tq],e.Joint.prototype,"_nativeJoint",void 0),tX([tq],e.Joint.prototype,"_force",void 0),tX([tq],e.Joint.prototype,"_torque",void 0),e.Joint=tX([rh(e.Collider,r_.CheckOnly)],e.Joint);var iR=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},iM=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return tW(n,t),n.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n}(e.Joint),iw=((eM={})[eM.None=0]="None",eM[eM.LimitEnabled=1]="LimitEnabled",eM[eM.DriveEnabled=2]="DriveEnabled",eM[eM.DriveFreeSpin=4]="DriveFreeSpin",eM),iP=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e._axis=new tT(1,0,0),e._hingeFlags=iw.None,e._useSpring=!1,e}tW(n,t);var r=n.prototype;return r._onAwake=function(){var t=this._colliderInfo;t.localPosition=new tT,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createHingeJoint(t.collider._nativeCollider)},r._cloneTo=function(e){e.axis=this.axis,e.swingOffset=this.swingOffset,e.useLimits=this.useLimits,e.useMotor=this.useMotor,e.useSpring=this.useSpring,e.motor=this.motor,e.limits=this.limits},tG(n,[{key:"axis",get:function(){return this._axis},set:function(e){var t=this._axis;e!==t&&t.copyFrom(e),this._nativeJoint.setAxis(t)}},{key:"swingOffset",get:function(){return this._colliderInfo.localPosition},set:function(e){var t=this._colliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setSwingOffset(t)}},{key:"angle",get:function(){return this._nativeJoint.getAngle()}},{key:"velocity",get:function(){return this._nativeJoint.getVelocity()}},{key:"useLimits",get:function(){return(this._hingeFlags&iw.LimitEnabled)==iw.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=iw.LimitEnabled:this._hingeFlags&=~iw.LimitEnabled,this._nativeJoint.setHingeJointFlag(iw.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&iw.DriveEnabled)==iw.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=iw.DriveEnabled:this._hingeFlags&=~iw.DriveEnabled,this._nativeJoint.setHingeJointFlag(iw.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(iw.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))}}]),n}(e.Joint);tX([tq],iP.prototype,"_axis",void 0),tX([tq],iP.prototype,"_hingeFlags",void 0),tX([tq],iP.prototype,"_useSpring",void 0),tX([tq],iP.prototype,"_jointMonitor",void 0),tX([tq],iP.prototype,"_limits",void 0);var iF=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e}tW(n,t);var r=n.prototype;return r._onAwake=function(){var t=this._colliderInfo;t.localPosition=new tT,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createSpringJoint(t.collider._nativeCollider)},r._cloneTo=function(e){e.swingOffset=this.swingOffset,e.minDistance=this.minDistance,e.maxDistance=this.maxDistance,e.tolerance=this.tolerance,e.stiffness=this.stiffness,e.damping=this.damping},tG(n,[{key:"swingOffset",get:function(){return this._colliderInfo.localPosition},set:function(e){var t=this._colliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setSwingOffset(e)}},{key:"minDistance",get:function(){return this._minDistance},set:function(e){this._minDistance!==e&&(this._minDistance=e,this._nativeJoint.setMinDistance(e))}},{key:"maxDistance",get:function(){return this._maxDistance},set:function(e){this._maxDistance!==e&&(this._maxDistance=e,this._nativeJoint.setMaxDistance(e))}},{key:"tolerance",get:function(){return this._tolerance},set:function(e){this._tolerance!==e&&(this._tolerance=e,this._nativeJoint.setTolerance(e))}},{key:"stiffness",get:function(){return this._stiffness},set:function(e){this._stiffness!==e&&(this._stiffness=e,this._nativeJoint.setStiffness(e))}},{key:"damping",get:function(){return this._damping},set:function(e){this._damping!==e&&(this._damping=e,this._nativeJoint.setDamping(e))}}]),n}(e.Joint),iL=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},iD=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},iB=/*#__PURE__*/function(){function e(){this._isTrigger=!1,this._rotation=new tT,this._position=new tT,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new iC,this._id=e._idGenerator++,this._setRotation=this._setRotation.bind(this),this._setPosition=this._setPosition.bind(this),this._rotation._onValueChanged=this._setRotation,this._position._onValueChanged=this._setPosition}var t=e.prototype;return t._cloneTo=function(e){e.contactOffset=this.contactOffset,e.rotation=this.rotation,e.position=this.position,e.isTrigger=this.isTrigger,e.material=this.material},t._destroy=function(){this._material._destroy(),this._nativeShape.destroy()},t._setPosition=function(){this._nativeShape.setPosition(this._position)},t._setRotation=function(){this._nativeShape.setRotation(this._rotation)},tG(e,[{key:"collider",get:function(){return this._collider}},{key:"id",get:function(){return this._id}},{key:"contactOffset",get:function(){return this._contactOffset},set:function(e){this._contactOffset!==e&&(this._contactOffset=e,this._nativeShape.setContactOffset(e))}},{key:"material",get:function(){return this._material},set:function(e){this._material!==e&&(this._material=e,this._nativeShape.setMaterial(e._nativeMaterial))}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation!=e&&this._rotation.copyFrom(e)}},{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"isTrigger",get:function(){return this._isTrigger},set:function(e){this._isTrigger!==e&&(this._isTrigger=e,this._nativeShape.setIsTrigger(e))}}]),e}();iB._idGenerator=0,tX([tq],iB.prototype,"_collider",void 0),tX([tq],iB.prototype,"_nativeShape",void 0),tX([tq],iB.prototype,"_id",void 0),tX([tq],iB.prototype,"_material",void 0),tX([tq],iB.prototype,"_isTrigger",void 0),tX([tq],iB.prototype,"_rotation",void 0),tX([tq],iB.prototype,"_position",void 0),tX([tq],iB.prototype,"_contactOffset",void 0);var iI=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._size=new tT(1,1,1),t._nativeShape=ip._nativePhysics.createBoxColliderShape(t._id,t._size,t._material._nativeMaterial),t._setSize=t._setSize.bind(t),t._size._onValueChanged=t._setSize,t}tW(t,e);var n=t.prototype;return n._cloneTo=function(t){e.prototype._cloneTo.call(this,t),t.size=this.size},n._setSize=function(){this._nativeShape.setSize(this._size)},tG(t,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),t}(iB);tX([tq],iI.prototype,"_size",void 0);var iO=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._nativeShape=ip._nativePhysics.createSphereColliderShape(t._id,t._radius,t._material._nativeMaterial),t}return tW(t,e),t.prototype._cloneTo=function(t){e.prototype._cloneTo.call(this,t),t.radius=this.radius},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),t}(iB);tX([tq],iO.prototype,"_radius",void 0);var iV=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._nativeShape=ip._nativePhysics.createPlaneColliderShape(t._id,t._material._nativeMaterial),t}return tW(t,e),t}(iB),iN=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._height=2,t._upAxis=iA.Y,t._nativeShape=ip._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t}return tW(t,e),t.prototype._cloneTo=function(t){e.prototype._cloneTo.call(this,t),t.radius=this.radius,t.height=this.height,t.upAxis=this.upAxis},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._nativeShape.setHeight(e))}},{key:"upAxis",get:function(){return this._upAxis},set:function(e){this._upAxis!==e&&(this._upAxis=e,this._nativeShape.setUpAxis(e))}}]),t}(iB);tX([tq],iN.prototype,"_radius",void 0),tX([tq],iN.prototype,"_height",void 0),tX([tq],iN.prototype,"_upAxis",void 0);var ik=/*#__PURE__*/function(){function e(e,t){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=il.None,this._upMap=[],this._downMap=[],this._upList=new rS,this._downList=new rS,this._nativeEvents=[],"undefined"!=typeof Window&&tK(t,Window))throw"Do not set window as target because window cannot listen to pointer leave event.";this._engine=e,this._target=t,this._canvas=e.canvas,this._htmlCanvas=e._canvas._webCanvas,this._pointerPool=Array(11),this._onPointerEvent=this._onPointerEvent.bind(this),this._addEventListener()}var t=e.prototype;return t._update=function(){for(var e=this._pointers,t=this._nativeEvents,n=this._htmlCanvas,r=this._canvas,a=r.width,i=r.height,o=n.clientWidth,s=n.clientHeight,l=n.getBoundingClientRect(),c=l.left,u=l.top,d=a/o,h=i/s,_=e.length-1;_>=0;_--)e[_].phase===io.Leave&&e.splice(_,1);for(var f=0,p=t.length;f<p;f++){var m=t[f],g=m.pointerId,v=this._getPointerByID(g);if(v)v._events.push(m);else{var y=e.length;if(0===y||this._multiPointerEnabled){for(var x,b=this._pointerPool,S=0;S<y&&!(e[S].id>S);S++);(v=b[x=S]||(b[x]=new is(S)))._uniqueID=g,v._events.push(m),v.position.set((m.clientX-c)*d,(m.clientY-u)*h),e.splice(S,0,v)}}}t.length=0,this._upList.length=this._downList.length=0,this._buttons=il.None;for(var C=this._engine.time.frameCount,T=0,A=e.length;T<A;T++){var E=e[T];E._upList.length=E._downList.length=0,this._updatePointerInfo(C,E,c,u,d,h),this._buttons|=E.pressedButtons}},t._firePointerScript=function(e){for(var t=this._pointers,n=this._canvas,r=0,a=t.length;r<a;r++){var i=t[r],o=i._events,s=i.position;i._firePointerDrag();var l=this._pointerRayCast(e,s.x/n.width,s.y/n.height);i._firePointerExitAndEnter(l);var c=o.length;if(c>0){for(var u=0;u<c;u++)switch(o[u].type){case"pointerdown":i.phase=io.Down,i._firePointerDown(l);break;case"pointerup":i.phase=io.Up,i._firePointerUpAndClick(l);break;case"pointerleave":case"pointercancel":i.phase=io.Leave,i._firePointerExitAndEnter(null)}o.length=0}}},t._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},t._onPointerEvent=function(e){this._nativeEvents.push(e)},t._getPointerByID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return t[n];return null},t._updatePointerInfo=function(e,t,n,r,a,i){var o=t._events,s=t.position,l=o.length;if(l>0){var c=this._upList,u=this._upMap,d=this._downList,h=this._downMap,_=o[l-1],f=(_.clientX-n)*a,p=(_.clientY-r)*i;t.deltaPosition.set(f-s.x,p-s.y),s.set(f,p);for(var m=0;m<l;m++){var g=o[m],v=g.button;switch(t.button=ic[v]||il.None,t.pressedButtons=g.buttons,g.type){case"pointerdown":d.add(v),h[v]=e,t._downList.add(v),t._downMap[v]=e,t.phase=io.Down;break;case"pointerup":c.add(v),u[v]=e,t._upList.add(v),t._upMap[v]=e,t.phase=io.Up;break;case"pointermove":t.phase=io.Move;break;case"pointerleave":case"pointercancel":t.phase=io.Leave}}this._engine._physicsInitialized||(o.length=0)}else t.deltaPosition.set(0,0),t.phase=io.Stationary},t._pointerRayCast=function(t,n,r){for(var a=e._tempPoint,i=e._tempRay,o=e._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(l.isActive&&!l.destroyed)for(var c=l._componentsManager._activeCameras,u=c._elements,d=c.length-1;d>=0;d--){var h=u[d];if(!h.renderTarget){var _=h.viewport,f=_.x,p=_.y,m=_.z,g=_.w;if(n>=f&&r>=p&&n-f<=m&&r-p<=g){if(a.set((n-f)/m,(r-p)/g),l.physics.raycast(h.viewportPointToRay(a,i),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&rw.Color)return null}}}}return null},t._addEventListener=function(){var e=this._target,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t)},t._removeEventListener=function(){var e=this._target,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},e}();ik._tempRay=new tD,ik._tempPoint=new tB,ik._tempHitResult=new ib;var iz=/*#__PURE__*/function(){function e(e,t){this._delta=new tT,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}var t=e.prototype;return t._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var n=t.length-1;n>=0;n--){var r=t[n];e.x+=r.deltaX,e.y+=r.deltaY,e.z+=r.deltaZ}t.length=0}},t._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},t._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},t._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},t._onWheelEvent=function(e){this._nativeEvents.push(e)},e}(),iU=/*#__PURE__*/function(){function e(e,t){this._initialized=!1,this._engine=e;var n,r,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&tK(i,OffscreenCanvas)||(this._wheelManager=new iz(e,null!=(n=null==t?void 0:t.wheelTarget)?n:i),this._pointerManager=new ik(e,null!=(r=null==t?void 0:t.pointerTarget)?r:i),this._keyboardManager=new i_(e,null!=(a=null==t?void 0:t.keyboardTarget)?a:window),this._initialized=!0)}var t=e.prototype;return t.isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},t.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},t.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},t.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},t.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[iu[e]]===this._engine.time.frameCount)},t.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[iu[e]]===this._engine.time.frameCount)},t._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},t._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},t._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},tG(e,[{key:"pointers",get:function(){return this._initialized?this._pointerManager._pointers:[]}},{key:"multiPointerEnabled",get:function(){return!!this._initialized&&this._pointerManager._multiPointerEnabled},set:function(e){this._initialized&&(this._pointerManager._multiPointerEnabled=e)}},{key:"wheelDelta",get:function(){return this._initialized?this._wheelManager._delta:null}}]),e}(),iG=((ew={}).cornerTextureCoordinate="a_CornerTextureCoordinate",ew),iH=((eP={}).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",eP.DirectionTime="a_DirectionTime",eP.StartColor="a_StartColor",eP.StartSize="a_StartSize",eP.StartRotation0="a_StartRotation0",eP.StartSpeed="a_StartSpeed",eP.Random0="a_Random0",eP.Random1="a_Random1",eP.SimulationWorldPosition="a_SimulationWorldPosition",eP.SimulationWorldRotation="a_SimulationWorldRotation",eP.SimulationUV="a_SimulationUV",eP),iW=function e(t){this.billboardVertexElement=new at(iG.cornerTextureCoordinate,0,r7.Vector4,0),this.instanceVertexElements=[new at(iH.ShapePositionStartLifeTime,0,r7.Vector4,1,1),new at(iH.DirectionTime,16,r7.Vector4,1,1),new at(iH.StartColor,32,r7.Vector4,1,1),new at(iH.StartSize,48,r7.Vector3,1,1),new at(iH.StartRotation0,60,r7.Vector3,1,1),new at(iH.StartSpeed,72,r7.Float,1,1),new at(iH.Random0,76,r7.Vector4,1,1),new at(iH.Random1,92,r7.Vector4,1,1),new at(iH.SimulationWorldPosition,108,r7.Vector3,1,1),new at(iH.SimulationWorldRotation,120,r7.Vector4,1,1),new at(iH.SimulationUV,136,r7.Vector4,1,1)];var n=new r9(t,an.VertexBuffer,64,r8.Static,!1);n.isGCIgnored=!0,this.billboardVertexBufferBinding=new aC(n,16);var r=new r9(t,an.IndexBuffer,e.billboardIndexCount,r8.Static,!1);r.isGCIgnored=!0,this.billboardIndexBufferBinding=new ag(r,r6.UInt8);var a=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),i=new Uint8Array([0,2,3,0,1,2]);n.setData(a),r.setData(i),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tW(t,e),t.prototype.restoreContent=function(){n.setData(a)},t}(t2))),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,r)||this}return tW(t,e),t.prototype.restoreContent=function(){},t}(t2)))};iW.instanceVertexStride=152,iW.instanceVertexFloatStride=iW.instanceVertexStride/4,iW.startLifeTimeOffset=3,iW.timeOffset=7,iW.simulationUVOffset=34,iW.billboardIndexCount=6,iW.boundsFloatStride=8,iW.boundsTimeOffset=6,iW.boundsMaxLifetimeOffset=7;var ij="#define GLSLIFY 1\nattribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}",iX="#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}",iK=/*#__PURE__*/function(){function e(){}return e.init=function(){var e=new n6("ShadowCaster","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\n#include <uv_share>\nuniform mat4 camera_VPMat;uniform vec2 scene_ShadowBias;uniform vec3 scene_LightDirection;vec3 applyShadowBias(vec3 positionWS){positionWS-=scene_LightDirection*scene_ShadowBias.x;return positionWS;}vec3 applyShadowNormalBias(vec3 positionWS,vec3 normalWS){float invNdotL=1.0-clamp(dot(-scene_LightDirection,normalWS),0.0,1.0);float scale=invNdotL*scene_ShadowBias.y;positionWS+=normalWS*vec3(scale);return positionWS;}void main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\nvec4 positionWS=renderer_ModelMat*position;positionWS.xyz=applyShadowBias(positionWS.xyz);\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS=normalize(mat3(renderer_NormalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS);\n#endif\n#endif\nvec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}","#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nvec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;}\n#endif\nuniform vec4 material_BaseColor;uniform sampler2D material_BaseTexture;uniform float material_AlphaCutoff;varying vec2 v_uv;void main(){\n#if defined(MATERIAL_IS_ALPHA_CUTOFF) || (defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT))\nfloat alpha=material_BaseColor.a;\n#ifdef MATERIAL_HAS_BASETEXTURE\nalpha*=texture2D(material_BaseTexture,v_uv).a;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(alpha<material_AlphaCutoff){discard;}\n#endif\n#if defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT)\nfloat noise=fract(52.982919*fract(dot(vec2(0.06711,0.00584),gl_FragCoord.xy)));if(alpha<=noise){discard;};\n#endif\n#endif\n#ifdef ENGINE_NO_DEPTH_TEXTURE\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\n#endif\n}",{pipelineStage:nX.ShadowCaster});e._renderState=new ri,e._renderStateDataMap[nO.RenderQueueType]=as._shadowCasterRenderQueueProp;var t=[e,new n6("DepthOnly","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;void main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <position_vert>\n}","#define GLSLIFY 1\nvoid main(){}",{pipelineStage:nX.DepthOnly})],n={pipelineStage:nX.Forward};ro.create("blinn-phong",[].concat([new n6("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("pbr",[].concat([new n6("Forward",iX,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("pbr-specular",[].concat([new n6("Forward",iX,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("unlit",[].concat([new n6("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <position_vert>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\nuniform vec4 material_BaseColor;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\nvoid main(){vec4 baseColor=material_BaseColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\nbaseColor*=textureColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\ngl_FragColor=baseColor;\n#ifndef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("blit",[new n6("Forward",ij,"#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,v_uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,v_uv);\n#endif\n}",n)]),ro.create("skybox",[new n6("Forward","#define GLSLIFY 1\n#include <common_vert>\nuniform mat4 camera_VPMat;varying vec3 v_cubeUV;uniform float material_Rotation;vec4 rotateY(vec4 v,float angle){const float deg2rad=3.1415926/180.0;float radian=angle*deg2rad;float sina=sin(radian);float cosa=cos(radian);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*v.xz,v.yw).xzyw;}void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=camera_VPMat*rotateY(vec4(POSITION,1.0),material_Rotation);}","#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;varying vec3 v_cubeUV;uniform float material_Exposure;uniform vec4 material_TintColor;void main(){vec4 textureColor=textureCube(material_CubeTexture,v_cubeUV);\n#ifdef MATERIAL_IS_DECODE_SKY_RGBM\ntextureColor=RGBMToLinear(textureColor,5.0);\n#elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\ntextureColor=gammaToLinear(textureColor);\n#endif\ntextureColor.rgb*=material_Exposure*material_TintColor.rgb;gl_FragColor=textureColor;\n#if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)]),ro.create("SkyProcedural",[new n6("Forward","#define GLSLIFY 1\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);attribute vec4 POSITION;uniform mat4 camera_VPMat;uniform vec3 material_SkyTint;uniform vec3 material_GroundTint;uniform float material_Exposure;uniform float material_AtmosphereThickness;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define COLOR_2_GAMMA(color) color\n#define COLOR_2_LINEAR(color) color*color\n#else\n#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=camera_VPMat*vec4(POSITION.xyz,1.0);vec3 skyTintInGammaSpace=COLOR_2_GAMMA(material_SkyTint);vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(POSITION.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-scene_SunlightDirection,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_Vertex=-POSITION.xyz;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=material_Exposure*(cIn+COLOR_2_LINEAR(material_GroundTint)*cOut);v_SkyColor=material_Exposure*(cIn*getRayleighPhase(-scene_SunlightDirection,-eyeRay));float lightColorIntensity=clamp(length(scene_SunlightColor.xyz),0.25,1.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#endif\n}","#define GLSLIFY 1\n#include <common>\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(material_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),material_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,material_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-scene_SunlightDirection,-ray);\n#endif\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\ncol=LINEAR_2_OUTPUT(col);\n#endif\ngl_FragColor=vec4(col,1.0);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)]),ro.create("particle-shader",[new n6("Forward","#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERER_MODE_MESH\nattribute vec3 a_MeshPosition;attribute vec4 a_MeshColor;attribute vec2 a_MeshTextureCoordinate;varying vec4 v_MeshColor;\n#endif\nattribute vec4 a_ShapePositionStartLifeTime;attribute vec4 a_DirectionTime;attribute vec4 a_StartColor;attribute vec3 a_StartSize;attribute vec3 a_StartRotation0;attribute float a_StartSpeed;attribute vec4 a_Random0;\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nattribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPosition;attribute vec4 a_SimulationWorldRotation;varying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\nattribute vec4 a_SimulationUV;varying vec2 v_TextureCoordinate;\n#endif\nuniform float renderer_CurrentTime;uniform vec3 renderer_Gravity;uniform vec2 u_DragConstant;uniform vec3 renderer_WorldPosition;uniform vec4 renderer_WorldRotation;uniform bool renderer_ThreeDStartRotation;uniform int renderer_ScalingMode;uniform vec3 renderer_PositionScale;uniform vec3 renderer_SizeScale;uniform vec3 renderer_PivotOffset;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nuniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward;uniform vec3 camera_Up;uniform float renderer_StretchedBillboardLengthScale;uniform float renderer_StretchedBillboardSpeedScale;uniform int renderer_SimulationSpace;\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\nvoid main(){float age=renderer_CurrentTime-a_DirectionTime.w;float normalizedAge=age/a_ShapePositionStartLifeTime.w;vec3 lifeVelocity;if(normalizedAge<1.0){vec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifeVelocity=computeParticleLifeVelocity(normalizedAge);\n#endif\nvec3 gravityVelocity=renderer_Gravity*a_Random0.x*age;vec4 worldRotation;if(renderer_SimulationSpace==0){worldRotation=renderer_WorldRotation;}else{worldRotation=a_SimulationWorldRotation;}vec3 dragData=a_DirectionTime.xyz*mix(u_DragConstant.x,u_DragConstant.y,a_Random0.x);vec3 center=computeParticlePosition(startVelocity,lifeVelocity,age,normalizedAge,gravityVelocity,worldRotation,dragData);\n#include <sphere_billboard>\n#include <stretched_billboard>\n#include <horizontal_billboard>\n#include <vertical_billboard>\n#include <particle_mesh>\ngl_Position=camera_ProjMat*camera_ViewMat*vec4(center,1.0);v_Color=computeParticleColor(a_StartColor,normalizedAge);\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec2 simulateUV;\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nsimulateUV=a_CornerTextureCoordinate.zw*a_SimulationUV.xy+a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#ifdef RENDERER_MODE_MESH\nsimulateUV=a_SimulationUV.xy+a_MeshTextureCoordinate*a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#endif\n}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}","#define GLSLIFY 1\n#include <common>\nvarying vec4 v_Color;varying vec2 v_TextureCoordinate;uniform sampler2D material_BaseTexture;uniform vec4 material_BaseColor;\n#ifdef RENDERER_MODE_MESH\nvarying vec4 v_MeshColor;\n#endif\nvoid main(){vec4 color=material_BaseColor*v_Color;\n#ifdef RENDERER_MODE_MESH\ncolor*=v_MeshColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_TextureCoordinate);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\ncolor*=textureColor;\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)]),ro.create("SpriteMask",[new n6("Forward","#define GLSLIFY 1\nuniform mat4 camera_VPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=camera_VPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;uniform float renderer_MaskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(renderer_MaskTexture,v_uv);if(color.a<renderer_MaskAlphaCutoff){discard;}gl_FragColor=color;}",n)]),ro.create("Sprite",[new n6("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderer_SpriteTexture,v_uv);gl_FragColor=baseColor*v_color;}",n)]),ro.create("Text",[new n6("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderElement_TextTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderElement_TextTexture,v_uv);gl_FragColor=baseColor*v_color;}",n)]),ro.create("background-texture",[new n6("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform vec4 camera_ProjectionParams;void main(){gl_Position=vec4(POSITION,1.0);gl_Position.y*=camera_ProjectionParams.x;v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",n)])},e}(),iY=/*#__PURE__*/function(){function e(e){this.engine=e,this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}var t=e.prototype;return t.get=function(e){var t=this._cacheMap,n=e._length,r=this._cacheHierarchyDepth;n>r&&(this._resizeCacheMapHierarchy(t,0,r,n-r),this._cacheHierarchyDepth=n);for(var a=e._mask,i=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=i<s?0:a[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var u=i<o?0:a[o],d=t[u];return d||(this._lastQueryKey=u,this._lastQueryMap=t),d},t.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},t._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},t._recursiveDestroy=function(e,t){if(e===this._cacheHierarchyDepth-1){for(var n in t)t[n].destroy();return}for(var r in++e,t)this._recursiveDestroy(e,t[r])},t._resizeCacheMapHierarchy=function(e,t,n,r){if(t==n-1)for(var a in e){for(var i=e[a],o=e,s=0;s<r;s++)o[0==s?a:0]=o=Object.create(null);o[0]=i}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,n,r)},e}(),iq=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._usedElementCount=0,n._elements=[],n}tW(t,e);var n=t.prototype;return n.get=function(){var e=this._usedElementCount,t=this._elements;if(this._usedElementCount++,t.length!==e)return t[e];var n=new this._type;return t.push(n),n},n.clear=function(){this._usedElementCount=0},t}(aq),iQ=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t._initialize=function(e,t){},t._update=function(){},t._destroy=function(){},t._getRequestAnimationFrame=function(){return null},t._getCancelAnimationFrame=function(){return null},t._getCameraIgnoreClearFlags=function(e){return rw.None},e}();iK.init();var iZ=/*#__PURE__*/function(e){function t(n,r,a){(i=e.call(this)||this)._physicsInitialized=!1,i._physicalObjectsMap={},i._lastRenderState=new ri,i._renderElementPool=new iq(r0),i._subRenderElementPool=new iq(r1),i._textSubRenderElementPool=new iq(r1),i._charRenderInfoPool=new aQ(tj,50),i._renderContext=new rk,i._renderCount=0,i._shaderProgramPools=[],i._fontMap={},i._macroCollection=new nW,i._settings={},i._resourceManager=new ie(i),i._sceneManager=new a4(i),i._vSyncCount=1,i._targetFrameRate=60,i._time=new nq,i._isPaused=!0,i._vSyncCounter=1,i._targetFrameInterval=1e3/60,i._destroyed=!1,i._frameInProcess=!1,i._waitingDestroy=!1,i._isDeviceLost=!1,i._waitingGC=!1,i._animate=function(){if(i._vSyncCount){var e,t=(null==(e=i.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;i._requestId=t(i._animate),i._vSyncCounter++%i._vSyncCount==0&&(i.update(),i._vSyncCounter=1)}else i._timeoutId=window.setTimeout(i._animate,i._targetFrameInterval),i.update()},i._hardwareRenderer=r,i._hardwareRenderer.init(n,i._onDeviceLost.bind(i),i._onDeviceRestored.bind(i)),i._canvas=n,i._textDefaultFont=ng.createFromOS(i,"Arial"),i._textDefaultFont.isGCIgnored=!0,i._batcherManager=new a1(i),i.inputManager=new iU(i,a.input);var i,o=a.xrDevice;if(o&&(i.xrManager=new iQ,i.xrManager._initialize(i,o)),r.canIUse(nZ.depthTexture)){var s=new nc(i,1,1,t9.Depth16,!1);s.isGCIgnored=!0,i._depthTexture2D=s}else i._macroCollection.enable(t._noDepthTextureMacro);var l=new ao(i,ro.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new tO(1,0,1.01,1)),i._meshMagentaMaterial=l;var c=new ao(i,ro.find("particle-shader"));c.isGCIgnored=!0,c.shaderData.setColor("material_BaseColor",new tO(1,0,1.01,1)),i._particleMagentaMaterial=c;var u=i._settings,d=a.colorSpace||n2.Linear;return d===n2.Gamma&&i._macroCollection.enable(t._gammaMacro),u.colorSpace=d,i._basicResources=new aY(i),i._particleBufferUtils=new iW(i),i}tW(t,e);var n=t.prototype;return n.createEntity=function(e){return new aW(this,e)},n.pause=function(){var e;this._isPaused=!0,((null==(e=this.xrManager)?void 0:e._getCancelAnimationFrame())||cancelAnimationFrame)(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){if(this._isPaused){if(this._isPaused=!1,this.time._reset(),this._vSyncCount){var e,t=(null==(e=this.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;this._requestId=t(this._animate)}else this._timeoutId=window.setTimeout(this._animate,this._targetFrameInterval)}},n.update=function(){var e,t=this._time;t._update();var n=t.deltaTime;this._frameInProcess=!0,this._subRenderElementPool.clear(),this._textSubRenderElementPool.clear(),this._renderElementPool.clear(),null==(e=this.xrManager)||e._update();var r=this.inputManager,a=this._physicsInitialized;r._update();for(var i=this._sceneManager._scenes.getLoopArray(),o=i.length,s=0;s<o;s++){var l=i[s];if(l.isActive&&!l.destroyed){var c=l._componentsManager;c.sortCameras(),c.callScriptOnStart()}}if(a)for(var u=0;u<o;u++){var d=i[u];d.isActive&&!d.destroyed&&d.physics._update(n)}a&&r._firePointerScript(i);for(var h=0;h<o;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(n)}for(var f=0;f<o;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(n)}for(var m=0;m<o;m++){var g=i[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(n)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var v=0;v<o;v++){var y=i[v];y.isActive&&!y.destroyed&&y._componentsManager.handlingInvalidScripts()}this._waitingGC&&(this._gc(),this._waitingGC=!1),this._frameInProcess=!1},n.run=function(){this.resume(),this.dispatch("run",this)},n.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},n.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},n._destroy=function(){var e;this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),this._batcherManager.destroy(),null==(e=this.xrManager)||e._destroy(),this.dispatch("shutdown",this),this.pause(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e){var t=e._shaderPassId,n=this._shaderProgramPools,r=n[t];if(!r){var a=t+1;a>n.length&&(n.length=a),n[t]=r=new iY(this),e._shaderProgramPools.push(r)}return r},n._render=function(e){for(var t=this,n=this.time.deltaTime,r=0,a=e.length;r<a;r++){var i=e[r];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(n),i._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(n,r){var a=e[n];if(a.isActive&&!a.destroyed){var i=a._componentsManager._activeCameras;if(0===i.length)return no.debug("No active camera in scene.");i.forEach(function(e){var n=a._componentsManager;n.callCameraOnBeginRender(e),e.render(),n.callCameraOnEndRender(e),t._hardwareRenderer._options._forceFlush&&t._hardwareRenderer.flush()},function(e,t){e._cameraIndex=t})}}(o)},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,n=e.shaderLab,r=e.physics;n&&!ro._shaderLab&&(ro._shaderLab=n);var a=[];r&&a.push(r.initialize().then(function(){return ip._nativePhysics=r,t._nativePhysicsManager=r.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=ie._loaders;for(var o in i){var s=i[o];s.initialize&&a.push(s.initialize(this,e))}return Promise.all(a).then(function(){return t})},n._onDeviceLost=function(){this._isDeviceLost=!0,this.resourceManager._lostGraphicResources(),console.log("Device lost."),this.dispatch("devicelost",this)},n._onDeviceRestored=function(){var e=this;this._hardwareRenderer.resetState(),this._lastRenderState=new ri,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),t._restoreResourcesContent().then(function(){console.log("Graphic resource content restored.\n\nDevice restored."),e.dispatch("devicerestored",e),e._isDeviceLost=!1}).catch(function(e){console.error(e)})},n._gc=function(){this._subRenderElementPool.garbageCollection(),this._textSubRenderElementPool.garbageCollection(),this._renderElementPool.garbageCollection(),this._renderContext.garbageCollection()},tG(t,[{key:"settings",get:function(){return this._settings}},{key:"canvas",get:function(){return this._canvas}},{key:"resourceManager",get:function(){return this._resourceManager}},{key:"sceneManager",get:function(){return this._sceneManager}},{key:"time",get:function(){return this._time}},{key:"isPaused",get:function(){return this._isPaused}},{key:"vSyncCount",get:function(){return this._vSyncCount},set:function(e){this._vSyncCount=Math.max(0,Math.floor(e))}},{key:"targetFrameRate",get:function(){return this._targetFrameRate},set:function(e){e=Math.max(1e-6,e),this._targetFrameRate=e,this._targetFrameInterval=1e3/e}},{key:"destroyed",get:function(){return this._destroyed}},{key:"physicsManager",get:function(){var e;return null==(e=this.sceneManager.scenes[0])?void 0:e.physics}}]),t}(nK);iZ._gammaMacro=nH.getByName("ENGINE_IS_COLORSPACE_GAMMA"),iZ._noDepthTextureMacro=nH.getByName("ENGINE_NO_DEPTH_TEXTURE"),iZ._pixelsPerUnit=100;var iJ=/*#__PURE__*/function(){function e(){this._sizeUpdateFlagManager=new nM}return tG(e,[{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._onWidthChanged(e),this._sizeUpdateFlagManager.dispatch())}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._onHeightChange(e),this._sizeUpdateFlagManager.dispatch())}}]),e}(),i$=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.destroy=function(){this.mesh=null,this.material=null},t._render=function(t){var n=this.material,r=this.mesh;if(!n){no.warn("The material of sky is not defined.");return}if(n.destroyed){no.warn("The material of sky is destroyed.");return}if(!r){no.warn("The mesh of sky is not defined.");return}if(r.destroyed){no.warn("The mesh of sky is destroyed.");return}var a=t.camera,i=a.engine,o=a.scene,s=a.aspectRatio,l=a.fieldOfView,c=a.viewMatrix,u=a.shaderData,d=o.shaderData,h=e._viewProjMatrix,_=e._projectionMatrix,f=i._hardwareRenderer,p=n.shaderData,m=n.shader,g=n.renderState;h.copyFrom(c);var v=h.elements;v[12]=v[13]=v[14]=0;var y=1/Math.tan(tC.degreeToRadian(l)/2);_.elements[0]=y/s,_.elements[5]=y,tL.multiply(_,h,h);var x=u.getMatrix(rk.vpMatrixProperty);t.flipProjection&&tL.multiply(rk._flipYMatrix,h,h),u.setMatrix(rk.vpMatrixProperty,h);var b=ro._compileMacros;nW.unionCollection(t.camera._globalShaderMacro,p._macroCollection,b);var S=m.subShaders[0].passes[0],C=S._getShaderProgram(i,b);C.bind(),C.groupingOtherUniformBlock(),C.uploadAll(C.sceneUniformBlock,d),C.uploadAll(C.cameraUniformBlock,u),C.uploadAll(C.materialUniformBlock,p),C.uploadUnGroupTextures(),g._applyStates(i,!1,S._renderStateDataMap,p),f.drawPrimitive(r._primitive,r.subMesh,C),u.setMatrix(rk.vpMatrixProperty,x)},tG(e,[{key:"material",get:function(){return this._material},set:function(e){if(this._material!==e){var t;null==e||e._addReferCount(1),null==(t=this._material)||t._addReferCount(-1),this._material=e}}},{key:"mesh",get:function(){return this._mesh},set:function(e){if(this._mesh!==e){var t;null==e||e._addReferCount(1),null==(t=this._mesh)||t._addReferCount(-1),this._mesh=e}}}]),e}();i$._epsilon=1e-6,i$._viewProjMatrix=new tL,i$._projectionMatrix=new tL(1,0,0,0,0,1,0,0,0,0,i$._epsilon-1,-1,0,0,0,0);var i0=/*#__PURE__*/function(){function e(e){this._engine=e,this.mode=rO.SolidColor,this.solidColor=new tO(.25,.25,.25,1),this.sky=new i$,this._textureFillMode=rV.AspectFitHeight,this._texture=null,this._initMesh(e),this._initMaterial(e)}var t=e.prototype;return t.destroy=function(){this.texture=null,this._mesh._addReferCount(-1),this._mesh=null,this._material._addReferCount(-1),this._material=null,this.solidColor=null,this.sky.destroy()},t._resizeBackgroundTexture=function(){var e=this._texture,t=this._mesh;if(this._texture){var n=this._engine.canvas,r=n.width,a=n.height,i=t.getPositions();switch(this._textureFillMode){case rV.Fill:i[0].set(-1,-1,1),i[1].set(1,-1,1),i[2].set(-1,1,1),i[3].set(1,1,1);break;case rV.AspectFitWidth:var o=e.height*r/e.width/a;i[0].set(-1,-o,1),i[1].set(1,-o,1),i[2].set(-1,o,1),i[3].set(1,o,1);break;case rV.AspectFitHeight:var s=e.width*a/e.height/r;i[0].set(-s,-1,1),i[1].set(s,-1,1),i[2].set(-s,1,1),i[3].set(s,1,1)}t.setPositions(i),t.uploadData(!1)}},t._initMesh=function(e){var t=this._mesh=this._createPlane(e);e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,t)||this}return tW(n,e),n.prototype.restoreContent=function(){t.setPositions(t.getPositions()),t.setUVs(t.getUVs()),t.setIndices(t.getIndices()),t.uploadData(!1)},n}(t2))),this._mesh._addReferCount(1)},t._initMaterial=function(e){var t=this._material=new ao(e,ro.find("background-texture"));t.renderState.depthState.compareFunction=nB.LessEqual,t._addReferCount(1)},t._createPlane=function(e){for(var t=new aM(e),n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],a=[,,,,],i=0;i<4;++i)r[i]=new tT,a[i]=new tB(i%2,1-(.5*i|0));return t.setPositions(r),t.setUVs(a),t.setIndices(n),t.uploadData(!1),t.addSubMesh(0,n.length),t},tG(e,[{key:"texture",get:function(){return this._texture},set:function(e){if(this._texture!==e){var t;null==e||e._addReferCount(1),null==(t=this._texture)||t._addReferCount(-1),this._texture=e,this._material.shaderData.setTexture("material_BaseTexture",e),this._resizeBackgroundTexture()}}},{key:"textureFillMode",get:function(){return this._textureFillMode},set:function(e){e!==this._textureFillMode&&(this._textureFillMode=e,this._resizeBackgroundTexture())}}]),e}(),i1=/*#__PURE__*/function(){function e(){this._cameraNeedSorting=!1,this._activeCameras=new rS,this._renderers=new rS,this._onStartScripts=new rS,this._onUpdateScripts=new rS,this._onLateUpdateScripts=new rS,this._onPhysicsUpdateScripts=new rS,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new rS,this._onUpdateRenderers=new rS,this._componentsContainerPool=[]}var t=e.prototype;return t.addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},t.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},t.sortCameras=function(){if(this._cameraNeedSorting){var e=this._activeCameras;e.sort(function(e,t){return e.priority-t.priority});for(var t=0,n=e.length;t<n;t++)e.get(t)._cameraIndex=t;this._cameraNeedSorting=!1}},t.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},t.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},t.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},t.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},t.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},t.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},t.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},t.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},t.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},t.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},t.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},t.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},t.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()},function(e,t){e._onStartIndex=t})},t.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},t.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},t.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},t.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},t.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},t.handlingInvalidScripts=function(){var e=this._disposeDestroyScripts,t=this._pendingDestroyScripts;this._disposeDestroyScripts=t,this._pendingDestroyScripts=e;var n=t.length;if(n>0){for(var r=n-1;r>=0;r--)t[r].onDestroy();t.length=0}},t.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},t.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},t.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},t.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},t._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},e}(),i2=/*#__PURE__*/function(){function e(){this.hasStencilWritten=!1,this._preMaskLayer=rg.Nothing,this._allSpriteMasks=new rS}var t=e.prototype;return t.addSpriteMask=function(e){e._maskIndex=this._allSpriteMasks.length,this._allSpriteMasks.add(e)},t.removeSpriteMask=function(e){var t=this._allSpriteMasks.deleteByIndex(e._maskIndex);t&&(t._maskIndex=e._maskIndex),e._maskIndex=-1},t.drawMask=function(t,n,r){var a=e.getMaskIncrementRenderQueue();a.clear();var i=e.getMaskDecrementRenderQueue();i.clear(),this._buildMaskRenderElement(r,a,i);var o=t.camera.engine._batcherManager;a.batch(o),o.uploadBuffer(),a.render(t,n,rU.Increment),i.batch(o),o.uploadBuffer(),i.render(t,n,rU.Decrement)},t.clearMask=function(t,n){var r=this._preMaskLayer;if(r!==rg.Nothing){if(this.hasStencilWritten){var a=e.getMaskDecrementRenderQueue();a.clear();for(var i=this._allSpriteMasks,o=0,s=i.length;o<s;o++){var l=i.get(o);l.influenceLayers&r&&a.pushRenderElement(l._renderElement)}var c=t.camera.engine._batcherManager;a.batch(c),c.uploadBuffer(),a.render(t,n,rU.Decrement)}else{var u=t.camera.engine;u._hardwareRenderer.clearRenderTarget(u,rw.Stencil,null)}this._preMaskLayer=rg.Nothing}},t.isStencilWritten=function(e){var t=e.renderState.stencilState,n=nk.Keep;return!!t.enabled&&0!==t.writeMask&&(t.passOperationFront!==n||t.passOperationBack!==n||t.failOperationFront!==n||t.failOperationBack!==n||t.zFailOperationFront!==n||t.zFailOperationBack!==n)},t.isReadStencil=function(e){var t=e.renderState.stencilState,n=t.enabled,r=t.mask,a=t.compareFunctionFront,i=t.compareFunctionBack;return!!n&&0!==r&&(a!==nB.Always&&a!==nB.Never||i!==nB.Always&&i!==nB.Never)},t.destroy=function(){var e=this._allSpriteMasks;e.length=0,e.garbageCollection()},t._buildMaskRenderElement=function(e,t,n){var r=this._preMaskLayer;if(r!==e){for(var a=this._allSpriteMasks,i=r&e,o=r&~e,s=a._elements,l=0,c=a.length;l<c;l++){var u=s[l],d=u.influenceLayers;!(d&i)&&(d&e?t.pushRenderElement(u._renderElement):d&o&&n.pushRenderElement(u._renderElement))}this._preMaskLayer=e}},e.getMaskIncrementRenderQueue=function(){return e._maskIncrementRenderQueue||(e._maskIncrementRenderQueue=new rG(nV.Transparent))},e.getMaskDecrementRenderQueue=function(){return e._maskDecrementRenderQueue||(e._maskDecrementRenderQueue=new rG(nV.Transparent))},e}(),i3=((eF={})[eF.None=0]="None",eF[eF.Linear=1]="Linear",eF[eF.Exponential=2]="Exponential",eF[eF.ExponentialSquared=3]="ExponentialSquared",eF),i4=((eL={})[eL.SolidColor=0]="SolidColor",eL[eL.SphericalHarmonics=1]="SphericalHarmonics",eL),i8=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._diffuseSolidColor=new tO(.212,.227,.259),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=i4.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n._specularTextureDecodeRGBM=!1,n}tW(t,e);var n=t.prototype;return n._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var n=e.shaderData;n.setColor(t._diffuseColorProperty,this._diffuseSolidColor),n.setFloat(t._diffuseIntensityProperty,this._diffuseIntensity),n.setFloat(t._specularIntensityProperty,this._specularIntensity),n.setFloatArray(t._diffuseSHProperty,this._shArray),this._setDiffuseMode(n),this._setSpecularTextureDecodeRGBM(n),this._setSpecularTexture(n)},n._removeFromScene=function(e){this._addReferCount(-1);var n=this._scenes,r=n.indexOf(e);n.splice(r,1);var a=e.shaderData;a.setTexture(t._specularTextureProperty,null),a.disableMacro(t._specularMacro)},n._setDiffuseMode=function(e){this._diffuseMode===i4.SphericalHarmonics?e.enableMacro(t._shMacro):e.disableMacro(t._shMacro)},n._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(t._specularTextureProperty,this._specularTexture),e.setFloat(t._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(t._specularMacro)):e.disableMacro(t._specularMacro)},n._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(t._decodeRGBMMacro):e.disableMacro(t._decodeRGBMMacro)},n._preComputeSH=function(e,t){var n=e.coefficients;t[0]=.886227*n[0],t[1]=.886227*n[1],t[2]=.886227*n[2],t[3]=-1.023327*n[3],t[4]=-1.023327*n[4],t[5]=-1.023327*n[5],t[6]=1.023327*n[6],t[7]=1.023327*n[7],t[8]=1.023327*n[8],t[9]=-1.023327*n[9],t[10]=-1.023327*n[10],t[11]=-1.023327*n[11],t[12]=.858086*n[12],t[13]=.858086*n[13],t[14]=.858086*n[14],t[15]=-.858086*n[15],t[16]=-.858086*n[16],t[17]=-.858086*n[17],t[18]=.247708*n[18],t[19]=.247708*n[19],t[20]=.247708*n[20],t[21]=-.858086*n[21],t[22]=-.858086*n[22],t[23]=-.858086*n[23],t[24]=.429042*n[24],t[25]=.429042*n[25],t[26]=.429042*n[26]},tG(t,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTextureDecodeRGBM(t[n].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setDiffuseMode(t[n].shaderData)}},{key:"diffuseSolidColor",get:function(){return this._diffuseSolidColor},set:function(e){e!==this._diffuseSolidColor&&this._diffuseSolidColor.copyFrom(e)}},{key:"diffuseSphericalHarmonics",get:function(){return this._diffuseSphericalHarmonics},set:function(e){if(this._diffuseSphericalHarmonics=e,e){this._preComputeSH(e,this._shArray);for(var n=this._scenes,r=0,a=n.length;r<a;r++)n[r].shaderData.setFloatArray(t._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var n=this._scenes,r=0,a=n.length;r<a;r++)n[r].shaderData.setFloat(t._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTexture(t[n].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var n=0,r=this._scenes.length;n<r;n++)this._scenes[n].shaderData.setFloat(t._specularIntensityProperty,e)}}]),t}(t1);i8._shMacro=nH.getByName("SCENE_USE_SH"),i8._specularMacro=nH.getByName("SCENE_USE_SPECULAR_ENV"),i8._decodeRGBMMacro=nH.getByName("SCENE_IS_DECODE_ENV_RGBM"),i8._diffuseColorProperty=nY.getByName("scene_EnvMapLight.diffuse"),i8._diffuseSHProperty=nY.getByName("scene_EnvSH"),i8._diffuseIntensityProperty=nY.getByName("scene_EnvMapLight.diffuseIntensity"),i8._specularTextureProperty=nY.getByName("scene_EnvSpecularSampler"),i8._specularIntensityProperty=nY.getByName("scene_EnvMapLight.specularIntensity"),i8._mipLevelProperty=nY.getByName("scene_EnvMapLight.mipMapLevel");var i5=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.intensity=1,t.cullingMask=rE.Everything,t.shadowType=rj.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t._lightIndex=-1,t._lightColor=new tO,t._shadowStrength=1,t._color=new tO(1,1,1,1),t}return tW(t,e),t.prototype._getLightIntensityColor=function(){return this._lightColor.r=this.color.r*this.intensity,this._lightColor.g=this.color.g*this.intensity,this._lightColor.b=this.color.b*this.intensity,this._lightColor.a=this.color.a*this.intensity,this._lightColor},tG(t,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=tC.clamp(e,0,1)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"viewMatrix",get:function(){return this._viewMat||(this._viewMat=new tL),tL.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new tL),tL.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),t}(ru);tX([tq],i5.prototype,"_lightIndex",void 0);var i9=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shadowNearPlaneOffset=.1,t._reverseDirection=new tT,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=this._getLightIntensityColor(),o=this.direction,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(i.r),t.color[r+1]=tO.gammaToLinearSpace(i.g),t.color[r+2]=tO.gammaToLinearSpace(i.b)):(t.color[r]=i.r,t.color[r+1]=i.g,t.color[r+2]=i.b),t.direction[a]=o.x,t.direction[a+1]=o.y,t.direction[a+2]=o.z},n._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._directionProperty,n.direction)},tG(t,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tT.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}}]),t}(i5);i9._cullingMaskProperty=nY.getByName("scene_DirectLightCullingMask"),i9._colorProperty=nY.getByName("scene_DirectLightColor"),i9._directionProperty=nY.getByName("scene_DirectLightDirection");var i6=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=this._getLightIntensityColor(),o=this.position,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(i.r),t.color[r+1]=tO.gammaToLinearSpace(i.g),t.color[r+2]=tO.gammaToLinearSpace(i.b)):(t.color[r]=i.r,t.color[r+1]=i.g,t.color[r+2]=i.b),t.position[a]=o.x,t.position[a+1]=o.y,t.position[a+2]=o.z,t.distance[e]=this.distance},n._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._positionProperty,n.position),e.setFloatArray(t._distanceProperty,n.distance)},tG(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}}]),t}(i5);i6._cullingMaskProperty=nY.getByName("scene_PointLightCullingMask"),i6._colorProperty=nY.getByName("scene_PointLightColor"),i6._positionProperty=nY.getByName("scene_PointLightPosition"),i6._distanceProperty=nY.getByName("scene_PointLightDistance");var i7=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t.angle=Math.PI/6,t.penumbra=Math.PI/12,t._inverseDirection=new tT,t._projectMatrix=new tL,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=3*e,o=this._getLightIntensityColor(),s=this.position,l=this.direction,c=this.cullingMask;t.cullingMask[n]=65535&c,t.cullingMask[n+1]=c>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(o.r),t.color[r+1]=tO.gammaToLinearSpace(o.g),t.color[r+2]=tO.gammaToLinearSpace(o.b)):(t.color[r]=o.r,t.color[r+1]=o.g,t.color[r+2]=o.b),t.position[a]=s.x,t.position[a+1]=s.y,t.position[a+2]=s.z,t.direction[i]=l.x,t.direction[i+1]=l.y,t.direction[i+2]=l.z,t.distance[e]=this.distance,t.angleCos[e]=Math.cos(this.angle),t.penumbraCos[e]=Math.cos(this.angle+this.penumbra)},n._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._positionProperty,n.position),e.setFloatArray(t._directionProperty,n.direction),e.setFloatArray(t._distanceProperty,n.distance),e.setFloatArray(t._angleCosProperty,n.angleCos),e.setFloatArray(t._penumbraCosProperty,n.penumbraCos)},tG(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tT.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}}]),t}(i5);i7._cullingMaskProperty=nY.getByName("scene_SpotLightCullingMask"),i7._colorProperty=nY.getByName("scene_SpotLightColor"),i7._positionProperty=nY.getByName("scene_SpotLightPosition"),i7._directionProperty=nY.getByName("scene_SpotLightDirection"),i7._distanceProperty=nY.getByName("scene_SpotLightDistance"),i7._angleCosProperty=nY.getByName("scene_SpotLightAngleCos"),i7._penumbraCosProperty=nY.getByName("scene_SpotLightPenumbraCos");var oe=/*#__PURE__*/function(){function e(){this._spotLights=new rS,this._pointLights=new rS,this._directLights=new rS,this._directData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),direction:new Float32Array(3*e._maxLight)},this._pointData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),position:new Float32Array(3*e._maxLight),distance:new Float32Array(e._maxLight)},this._spotData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),position:new Float32Array(3*e._maxLight),direction:new Float32Array(3*e._maxLight),distance:new Float32Array(e._maxLight),angleCos:new Float32Array(e._maxLight),penumbraCos:new Float32Array(e._maxLight)}}var t=e.prototype;return t._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},t._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},t._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},t._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._updateShaderData=function(t){for(var n=this._spotLights,r=this._pointLights,a=this._directLights,i=this._spotData,o=this._pointData,s=this._directData,l=e._maxLight,c=Math.min(n.length,l),u=Math.min(r.length,l),d=Math.min(a.length,l),h=0;h<c;h++)n.get(h)._appendData(h,i);for(var _=0;_<u;_++)r.get(_)._appendData(_,o);for(var f=0;f<d;f++)a.get(f)._appendData(f,s);d?(i9._updateShaderData(t,s),t.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):t.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(i6._updateShaderData(t,o),t.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):t.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(i7._updateShaderData(t,i),t.enableMacro("SCENE_SPOT_LIGHT_COUNT",c.toString())):t.disableMacro("SCENE_SPOT_LIGHT_COUNT")},t._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},t._updateSunlightIndex=function(e){var t=this._directLights,n=e._lightIndex;if(n>0){var r=t.get(0),a=t.get(n);t.set(0,a),t.set(n,r),a._lightIndex=0,r._lightIndex=n}},t._getMaxBrightestSunlight=function(){for(var e=this._directLights,t=null,n=Number.NEGATIVE_INFINITY,r=!1,a=0,i=e.length;a<i;a++){var o=e.get(a);o.shadowType===rj.None||r||(n=Number.NEGATIVE_INFINITY,r=!0);var s=o.intensity*o.color.getBrightness();r?o.shadowType!==rj.None&&n<s&&(n=s,t=o):n<s&&(n=s,t=o)}return t},e}();oe._sunlightColorProperty=nY.getByName("scene_SunlightColor"),oe._sunlightDirectionProperty=nY.getByName("scene_SunlightDirection"),oe._maxLight=10;var ot=((eD={})[eD.Half=0]="Half",eD[eD.Quarter=1]="Quarter",eD),on=/*#__PURE__*/function(){function e(t){this._uberMaterial=t,this._highQualityFiltering=!1,this._mipDownRT=[],this._mipUpRT=[],this._maxIterations=6,this._enabled=!1,this.downScale=0;var n=new ao(t.engine,ro.find(e.SHADER_NAME)),r=n.renderState.depthState;r.enabled=!1,r.writeEnabled=!1;var a=n.shaderData,i=t.shaderData;a.setVector4(e._bloomParams,new tI),a.setVector4(e._lowMipTexelSizeProp,new tI),i.setVector4(e._bloomIntensityParams,new tI(1,1,0,0)),i.setVector4(e._dirtTilingOffsetProp,new tI),i.setColor(e._tintProp,new tO(1,1,1,1)),this._bloomMaterial=n,this.threshold=.9,this.scatter=.7,this.intensity=1,this.dirtIntensity=1}var t=e.prototype;return t.onRender=function(e,t){var n=e.camera,r=0===this.downScale?1:2,a=n.pixelViewport,i=a.width>>r,o=a.height>>r,s=this._calculateMipCount(i,o);this._prefilter(n,t,i,o,s),this._downsample(s),this._upsample(s),this._setupUber(n)},t._calculateMipCount=function(e,t){return Math.min(Math.max(Math.floor(Math.log2(Math.max(e,t))-1),1),this._maxIterations)},t._prefilter=function(e,t,n,r,a){for(var i=this._uberMaterial.engine,o=e._getInternalColorTextureFormat(),s=n,l=r,c=0;c<a;c++)this._mipUpRT[c]=rR.recreateRenderTargetIfNeeded(i,this._mipUpRT[c],s,l,o,null,!1,!1,1,t7.Clamp,t5.Bilinear),this._mipDownRT[c]=rR.recreateRenderTargetIfNeeded(i,this._mipDownRT[c],s,l,o,null,!1,!1,1,t7.Clamp,t5.Bilinear),s=Math.max(1,Math.floor(s/2)),l=Math.max(1,Math.floor(l/2));rR.blitTexture(i,t,this._mipDownRT[0],void 0,void 0,this._bloomMaterial,0)},t._downsample=function(e){for(var t=this._bloomMaterial,n=t.engine,r=this._mipDownRT[0],a=1;a<e;a++)rR.blitTexture(n,r.getColorTexture(0),this._mipUpRT[a],void 0,void 0,t,1),rR.blitTexture(n,this._mipUpRT[a].getColorTexture(0),this._mipDownRT[a],void 0,void 0,t,2),r=this._mipDownRT[a]},t._upsample=function(t){for(var n=this._bloomMaterial,r=n.engine,a=n.shaderData,i=t-2;i>=0;i--){var o=i==t-2?this._mipDownRT[i+1]:this._mipUpRT[i+1],s=this._mipDownRT[i],l=this._mipUpRT[i];a.setTexture(e._lowMipTextureProp,o.getColorTexture(0)),this.highQualityFiltering&&a.getVector4(e._lowMipTexelSizeProp).set(1/o.width,1/o.height,o.width,o.height),rR.blitTexture(r,s.getColorTexture(0),l,void 0,void 0,n,3)}},t._setupUber=function(t){var n=this._uberMaterial.shaderData,r=this.dirtTexture;if(r){var a=n.getVector4(e._dirtTilingOffsetProp),i=r.width/r.height,o=t.aspectRatio;i>o?a.set(o/i,1,(1-a.x)*.5,0):i<o?a.set(1,i/o,0,(1-a.y)*.5):a.set(1,1,0,0)}n.setTexture(e._bloomTextureProp,this._mipUpRT[0].getColorTexture(0))},t._releaseRenderTargets=function(){for(var e=this._mipDownRT.length,t=0;t<e;t++){var n=this._mipDownRT[t],r=this._mipUpRT[t];n&&(n.getColorTexture(0).destroy(!0),n.destroy(!0)),r&&(r.getColorTexture(0).destroy(!0),r.destroy(!0))}this._mipDownRT.length=0,this._mipUpRT.length=0},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){t!==this._enabled&&(this._enabled=t,t?this._uberMaterial.shaderData.enableMacro(e._enableMacro):(this._uberMaterial.shaderData.disableMacro(e._enableMacro),this._releaseRenderTargets()))}},{key:"threshold",get:function(){return this._threshold},set:function(t){if((t=Math.max(0,t))!==this._threshold){this._threshold=t;var n=tO.gammaToLinearSpace(t),r=.5*n,a=this._bloomMaterial.shaderData.getVector4(e._bloomParams);a.x=n,a.y=r}}},{key:"scatter",get:function(){return this._scatter},set:function(t){if((t=tC.clamp(t,0,1))!==this._scatter){this._scatter=t;var n=this._bloomMaterial.shaderData.getVector4(e._bloomParams),r=tC.lerp(.05,.95,t);n.z=r}}},{key:"intensity",get:function(){return this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).x},set:function(t){t=Math.max(0,t),this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).x=t}},{key:"tint",get:function(){return this._uberMaterial.shaderData.getColor(e._tintProp)},set:function(t){var n=this._uberMaterial.shaderData.getColor(e._tintProp);t!==n&&n.copyFrom(t)}},{key:"highQualityFiltering",get:function(){return this._highQualityFiltering},set:function(t){t!==this._highQualityFiltering&&(this._highQualityFiltering=t,t?(this._bloomMaterial.shaderData.enableMacro(e._hqMacro),this._uberMaterial.shaderData.enableMacro(e._hqMacro)):(this._bloomMaterial.shaderData.disableMacro(e._hqMacro),this._uberMaterial.shaderData.disableMacro(e._hqMacro)))}},{key:"dirtTexture",get:function(){return this._uberMaterial.shaderData.getTexture(e._dirtTextureProp)},set:function(t){this._uberMaterial.shaderData.setTexture(e._dirtTextureProp,t),t?this._uberMaterial.shaderData.enableMacro(e._dirtMacro):this._uberMaterial.shaderData.disableMacro(e._dirtMacro)}},{key:"dirtIntensity",get:function(){return this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).y},set:function(t){t=Math.max(0,t),this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).y=t}}]),e}();on.SHADER_NAME="PostProcessEffect Bloom",on._hqMacro=nH.getByName("BLOOM_HQ"),on._dirtMacro=nH.getByName("BLOOM_DIRT"),on._bloomParams=nY.getByName("material_BloomParams"),on._lowMipTextureProp=nY.getByName("material_lowMipTexture"),on._lowMipTexelSizeProp=nY.getByName("material_lowMipTexelSize"),on._enableMacro=nH.getByName("ENABLE_EFFECT_BLOOM"),on._bloomTextureProp=nY.getByName("material_BloomTexture"),on._dirtTextureProp=nY.getByName("material_BloomDirtTexture"),on._tintProp=nY.getByName("material_BloomTint"),on._bloomIntensityParams=nY.getByName("material_BloomIntensityParams"),on._dirtTilingOffsetProp=nY.getByName("material_BloomDirtTilingOffset"),ro.create(on.SHADER_NAME,[new n6("Bloom Prefilter",ij,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 material_BloomParams;uniform vec4 renderer_texelSize;void main(){\n#ifdef BLOOM_HQ\nvec2 texelSize=renderer_texelSize.xy;mediump vec4 A=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,-1.0));mediump vec4 B=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,-1.0));mediump vec4 C=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,-1.0));mediump vec4 D=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,-0.5));mediump vec4 E=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,-0.5));mediump vec4 F=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,0.0));mediump vec4 G=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 H=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,0.0));mediump vec4 I=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,0.5));mediump vec4 J=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,0.5));mediump vec4 K=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,1.0));mediump vec4 L=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,1.0));mediump vec4 M=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,1.0));mediump vec2 scale=vec2(0.5,0.125);mediump vec2 div=(1.0/4.0)*scale;mediump vec4 samplerColor=(D+E+I+J)*div.x;samplerColor+=(A+B+G+F)*div.y;samplerColor+=(B+C+H+G)*div.y;samplerColor+=(F+G+L+K)*div.y;samplerColor+=(G+H+M+L)*div.y;\n#else\nmediump vec4 samplerColor=sampleTexture(renderer_BlitTexture,v_uv);\n#endif\nmediump vec3 color=samplerColor.rgb;color=min(color,HALF_MAX);mediump float brightness=max3(color);float threshold=material_BloomParams.x;float thresholdKnee=material_BloomParams.y;mediump float softness=clamp(brightness-threshold+thresholdKnee,0.0,2.0*thresholdKnee);softness=(softness*softness)/(4.0*thresholdKnee+1e-4);mediump float multiplier=max(brightness-threshold,softness)/max(brightness,1e-4);color*=multiplier;color=max(color,0.0);gl_FragColor=vec4(color,samplerColor.a);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new n6("Bloom Blur Horizontal",ij,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy*2.0;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*4.0,0.0));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*3.0,0.0));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*2.0,0.0));mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*1.0,0.0));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c5=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*1.0,0.0));mediump vec4 c6=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*2.0,0.0));mediump vec4 c7=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*3.0,0.0));mediump vec4 c8=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*4.0,0.0));gl_FragColor=c0*0.01621622+c1*0.05405405+c2*0.12162162+c3*0.19459459+c4*0.22702703+c5*0.19459459+c6*0.12162162+c7*0.05405405+c8*0.01621622;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new n6("Bloom Blur Vertical",ij,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*3.23076923));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*1.38461538));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*1.38461538));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*3.23076923));gl_FragColor=c0*0.07027027+c1*0.31621622+c2*0.22702703+c3*0.31621622+c4*0.07027027;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new n6("Bloom Upsample",ij,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform sampler2D material_lowMipTexture;uniform vec4 material_BloomParams;uniform vec4 material_lowMipTexelSize;void main(){mediump vec4 highMip=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef BLOOM_HQ\nmediump vec4 lowMip=sampleTexture2DBicubic(material_lowMipTexture,v_uv,material_lowMipTexelSize);\n#else\nmediump vec4 lowMip=sampleTexture(material_lowMipTexture,v_uv);\n#endif\ngl_FragColor=mix(highMip,lowMip,material_BloomParams.z);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}")]);var or=((eB={})[eB.Neutral=0]="Neutral",eB[eB.ACES=1]="ACES",eB),oa=/*#__PURE__*/function(){function e(e){this._uberMaterial=e,this._enabled=!1,this.mode=0}return tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){t!==this._enabled&&(this._enabled=t,t?this._uberMaterial.shaderData.enableMacro(e._enableMacro):this._uberMaterial.shaderData.disableMacro(e._enableMacro))}},{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE",e.toString()))}}]),e}();oa._enableMacro=nH.getByName("ENABLE_EFFECT_TONEMAPPING");var oi=/*#__PURE__*/function(){function e(t){this.scene=t,this.isActive=!0;var n=ro.find(e.UBER_SHADER_NAME),r=new ao(t.engine,n),a=r.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=new on(r),o=new oa(r);this._uberMaterial=r,this._bloomEffect=i,this._tonemappingEffect=o}return e.prototype._render=function(e,t,n){var r=e.camera,a=r.engine;t._blitRenderTarget();var i=t.getColorTexture(),o=this._bloomEffect;o.enabled&&o.onRender(e,i),rR.blitTexture(a,i,n,0,r.viewport,this._uberMaterial)},tG(e,[{key:"hasActiveEffect",get:function(){return this.isActive&&(this._bloomEffect.enabled||this._tonemappingEffect.enabled)}}]),e}();oi.UBER_SHADER_NAME="UberPost",Object.assign(nJ,{PostCommon:"#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n#include <common>\n#define FLT_MIN 1.175494351e-38\n#define HALF_MIN 6.103515625e-5\n#define HALF_MAX 65504.0\nfloat min3(vec3 val){return min(min(val.x,val.y),val.z);}float max3(vec3 val){return max(max(val.x,val.y),val.z);}const float INVERT_LOG10=0.43429448190325176;float log10(float x){return log(x)*INVERT_LOG10;}vec4 sampleTexture(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ncolor=gammaToLinear(color);\n#endif\nreturn color;}\n#endif\n",Filtering:"#define GLSLIFY 1\n#ifndef FILTERING\n#define FILTERING\nvec2 bSpline3MiddleLeft(vec2 x){return 0.16666667+x*(0.5+x*(0.5-x*0.5));}vec2 bSpline3MiddleRight(vec2 x){return 0.66666667+x*(-1.0+0.5*x)*x;}vec2 bSpline3Rightmost(vec2 x){return 0.16666667+x*(-0.5+x*(0.5-x*0.16666667));}void bicubicFilter(vec2 fracCoord,out vec2 weights[2],out vec2 offsets[2]){vec2 r=bSpline3Rightmost(fracCoord);vec2 mr=bSpline3MiddleRight(fracCoord);vec2 ml=bSpline3MiddleLeft(fracCoord);vec2 l=1.0-mr-ml-r;weights[0]=r+mr;weights[1]=ml+l;offsets[0]=-1.0+mr/weights[0];offsets[1]=1.0+l/weights[1];}vec4 sampleTexture2DBicubic(sampler2D tex,vec2 coord,vec4 texSize){vec2 xy=coord*texSize.zw+0.5;vec2 ic=floor(xy);vec2 fc=fract(xy);vec2 weights[2],offsets[2];bicubicFilter(fc,weights,offsets);return weights[0].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[0].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[0].y)-0.5)*texSize.xy))+weights[1].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[1].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[1].y)-0.5)*texSize.xy));}\n#endif\n",ODT:"#define GLSLIFY 1\n#include <Tonescale>\nconst float CINEMA_WHITE=48.0;const float CINEMA_BLACK=0.02;const float ODT_SAT_FACTOR=0.93;mediump vec3 Y_2_linCV(mediump vec3 Y,mediump float Ymax,mediump float Ymin){return(Y-Ymin)/(Ymax-Ymin);}mediump vec3 XYZ_2_xyY(mediump vec3 XYZ){mediump float divisor=max(dot(XYZ,vec3(1.0)),1e-4);return vec3(XYZ.xy/divisor,XYZ.y);}mediump vec3 xyY_2_XYZ(mediump vec3 xyY){mediump float m=xyY.z/max(xyY.y,1e-4);mediump vec3 XYZ=vec3(xyY.xz,(1.0-xyY.x-xyY.y));XYZ.xz*=m;return XYZ;}const mediump float DIM_SURROUND_GAMMA=0.9811;mediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;mediump vec3 xyY=XYZ_2_xyY(XYZ);xyY.z=clamp(xyY.z,0.0,HALF_MAX);xyY.z=pow(xyY.z,DIM_SURROUND_GAMMA);XYZ=xyY_2_XYZ(xyY);return XYZ_2_AP1_MAT*XYZ;}mediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){mediump vec3 rgbPre=AP0_2_AP1_MAT*oces;mediump vec3 rgbPost;rgbPost.r=segmented_spline_c9_fwd(rgbPre.r);rgbPost.g=segmented_spline_c9_fwd(rgbPre.g);rgbPost.b=segmented_spline_c9_fwd(rgbPre.b);mediump vec3 linearCV=Y_2_linCV(rgbPost,CINEMA_WHITE,CINEMA_BLACK);linearCV=darkSurround_to_dimSurround(linearCV);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;linearCV=clamp(linearCV,vec3(0),vec3(1));return linearCV;}",RRT:"#define GLSLIFY 1\n#include <Tonescale>\nmediump float sigmoid_shaper(mediump float x){mediump float t=max(1.0-abs(x/2.0),0.0);mediump float y=1.0+sign(x)*(1.0-t*t);return y*0.5;}mediump float glow_fwd(mediump float ycIn,mediump float glowGainIn,mediump float glowMid){mediump float glowGainOut;if(ycIn<=2.0/3.0*glowMid){glowGainOut=glowGainIn;}else if(ycIn>=2.0*glowMid){glowGainOut=0.0;}else{glowGainOut=glowGainIn*(glowMid/ycIn-1.0/2.0);}return glowGainOut;}const mediump float RRT_GLOW_GAIN=0.05;const mediump float RRT_GLOW_MID=0.08;const mediump float RRT_RED_SCALE=0.82;const mediump float RRT_RED_PIVOT=0.03;const mediump float RRT_RED_HUE=0.0;const mediump float RRT_RED_WIDTH=135.0;const mediump float RRT_SAT_FACTOR=0.96;mediump vec3 RRT(mediump vec3 aces){mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);mediump float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(aces);mediump float centeredHue=center_hue(hue,RRT_RED_HUE);mediump float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);aces=clamp(aces,0.0,HALF_MAX);mediump vec3 rgbPre=AP0_2_AP1_MAT*aces;rgbPre=clamp(rgbPre,0.0,HALF_MAX);rgbPre=mix(vec3(dot(rgbPre,AP1_RGB2Y)),rgbPre,RRT_SAT_FACTOR);mediump vec3 rgbPost;rgbPost.x=segmented_spline_c5_fwd(rgbPre.x);rgbPost.y=segmented_spline_c5_fwd(rgbPre.y);rgbPost.z=segmented_spline_c5_fwd(rgbPre.z);mediump vec3 outputVal=AP1_2_AP0_MAT*rgbPost;return outputVal;}",Tonescale:"#define GLSLIFY 1\n#ifndef TONE_SCALE\n#define TONE_SCALE\nconst mediump mat3 M=mat3(vec3(0.5,-1.0,0.5),vec3(-1.0,1.0,0.5),vec3(0.5,0.0,0.0));mediump float segmented_spline_c5_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[6]=float[6](-4.0000000000,-4.0000000000,-3.1573765773,-0.4852499958,1.8477324706,1.8477324706);const mediump float coefsHigh[6]=float[6](-0.7185482425,2.0810307172,3.6681241237,4.0000000000,4.0000000000,4.0000000000);\n#else\nconst mediump float coefsLow_0=-4.0000000000;const mediump float coefsLow_1=-4.0000000000;const mediump float coefsLow_2=-3.1573765773;const mediump float coefsLow_3=-0.4852499958;const mediump float coefsLow_4=1.8477324706;const mediump float coefsLow_5=1.8477324706;const mediump float coefsHigh_0=-0.7185482425;const mediump float coefsHigh_1=2.0810307172;const mediump float coefsHigh_2=3.6681241237;const mediump float coefsHigh_3=4.0000000000;const mediump float coefsHigh_4=4.0000000000;const mediump float coefsHigh_5=4.0000000000;\n#endif\nconst mediump vec2 minPoint=vec2(0.0000054931640625,0.0001);const mediump vec2 midPoint=vec2(0.18,0.48);const mediump vec2 maxPoint=vec2(47185.92,10000.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.0;const int N_KNOTS_LOW=4;const int N_KNOTS_HIGH=4;mediump float logx=log10(max(x,HALF_MIN));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else{cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else{cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}mediump float segmented_spline_c9_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[10]=float[10](-1.6989700043,-1.6989700043,-1.4779000000,-1.2291000000,-0.8648000000,-0.4480000000,0.0051800000,0.4511080334,0.9113744414,0.9113744414);const mediump float coefsHigh[10]=float[10](0.5154386965,0.8470437783,1.1358000000,1.3802000000,1.5197000000,1.5985000000,1.6467000000,1.6746091357,1.6878733390,1.6878733390);\n#else\nconst mediump float coefsLow_0=-1.6989700043;const mediump float coefsLow_1=-1.6989700043;const mediump float coefsLow_2=-1.4779000000;const mediump float coefsLow_3=-1.2291000000;const mediump float coefsLow_4=-0.8648000000;const mediump float coefsLow_5=-0.4480000000;const mediump float coefsLow_6=0.0051800000;const mediump float coefsLow_7=0.4511080334;const mediump float coefsLow_8=0.9113744414;const mediump float coefsLow_9=0.9113744414;const mediump float coefsHigh_0=0.5154386965;const mediump float coefsHigh_1=0.8470437783;const mediump float coefsHigh_2=1.1358000000;const mediump float coefsHigh_3=1.3802000000;const mediump float coefsHigh_4=1.5197000000;const mediump float coefsHigh_5=1.5985000000;const mediump float coefsHigh_6=1.6467000000;const mediump float coefsHigh_7=1.6746091357;const mediump float coefsHigh_8=1.6878733390;const mediump float coefsHigh_9=1.6878733390;\n#endif\nconst mediump vec2 minPoint=vec2(0.0028799,0.02);const mediump vec2 midPoint=vec2(4.799999,4.8);const mediump vec2 maxPoint=vec2(1005.719,48.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.04;const int N_KNOTS_LOW=8;const int N_KNOTS_HIGH=8;mediump float logx=log10(max(x,1e-4));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else if(j==3){cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}else if(j==4){cf=vec3(coefsLow_4,coefsLow_5,coefsLow_6);}else if(j==5){cf=vec3(coefsLow_5,coefsLow_6,coefsLow_7);}else if(j==6){cf=vec3(coefsLow_6,coefsLow_7,coefsLow_8);}else{cf=vec3(coefsLow_7,coefsLow_8,coefsLow_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else if(j==3){cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}else if(j==4){cf=vec3(coefsHigh_4,coefsHigh_5,coefsHigh_6);}else if(j==5){cf=vec3(coefsHigh_5,coefsHigh_6,coefsHigh_7);}else if(j==6){cf=vec3(coefsHigh_6,coefsHigh_7,coefsHigh_8);}else{cf=vec3(coefsHigh_7,coefsHigh_8,coefsHigh_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}\n#endif\n",ColorTransform:"#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\nconst mediump mat3 sRGB_2_AP0=mat3(0.4397010,0.0897923,0.0175440,0.3829780,0.8134230,0.1115440,0.1773350,0.0967616,0.8707040);const mediump mat3 AP1_2_AP0_MAT=mat3(vec3(0.6954522414,0.0447945634,-0.0055258826),vec3(0.1406786965,0.8596711185,0.0040252103),vec3(0.1638690622,0.0955343182,1.0015006723));const mediump mat3 AP0_2_AP1_MAT=mat3(vec3(1.4514393161,-0.0765537734,0.0083161484),vec3(-0.2365107469,1.1762296998,-0.0060324498),vec3(-0.2149285693,-0.0996759264,0.9977163014));const mediump mat3 AP1_2_XYZ_MAT=mat3(vec3(0.6624541811,0.2722287168,-0.0055746495),vec3(0.1340042065,0.6740817658,0.0040607335),vec3(0.1561876870,0.0536895174,1.0103391003));const mediump mat3 XYZ_2_AP1_MAT=mat3(vec3(1.6410233797,-0.6636628587,0.0117218943),vec3(-0.3248032942,1.6153315917,-0.0082844420),vec3(-0.2364246952,0.0167563477,0.9883948585));const mediump mat3 D60_2_D65_CAT=mat3(vec3(0.987224,-0.00759836,0.00307257),vec3(-0.00611327,1.00186,-0.00509595),vec3(0.0159533,0.00533002,1.08168));const mediump mat3 XYZ_2_REC709_MAT=mat3(vec3(3.2409699419,-0.9692436363,0.0556300797),vec3(-1.5373831776,1.8759675015,-0.2039769589),vec3(-0.498610760,0.0415550574,1.0569715142));const mediump vec3 AP1_RGB2Y=vec3(0.2722287168,0.6740817658,0.0536895174);mediump float rgb_2_saturation(mediump vec3 rgb){const mediump float TINY=1e-4;mediump float mi=min3(rgb);mediump float ma=max3(rgb);return(max(ma,TINY)-max(mi,TINY))/max(ma,1e-2);}mediump float rgb_2_yc(mediump vec3 rgb){const mediump float ycRadiusWeight=1.75;mediump float r=rgb.x;mediump float g=rgb.y;mediump float b=rgb.z;mediump float k=b*(b-g)+g*(g-r)+r*(r-b);k=max(k,0.0);float chroma=k==0.0 ? 0.0 : sqrt(k);return(b+g+r+ycRadiusWeight*chroma)/3.0;}mediump float rgb_2_hue(mediump vec3 rgb){mediump float hue;if(rgb.x==rgb.y&&rgb.y==rgb.z){hue=0.0;}else{hue=(180.0/PI)*atan(sqrt(3.0)*(rgb.y-rgb.z),2.0*rgb.x-rgb.y-rgb.z);}if(hue<0.0){hue=hue+360.0;}return hue;}mediump float center_hue(mediump float hue,mediump float centerH){mediump float hueCentered=hue-centerH;if(hueCentered<-180.0){hueCentered=hueCentered+360.0;}else if(hueCentered>180.0){hueCentered=hueCentered-360.0;}return hueCentered;}\n#endif\n",NeutralTonemapping:"#define GLSLIFY 1\nvec3 neutralCurve(vec3 x,float a,float b,float c,float d,float e,float f){return vec3(((x*(a*x+c*b)+d*e)/(x*(a*x+b)+d*f))-e/f);}\n#define TONEMAPPING_CLAMP_MAX 435.18712\nvec3 neutralTonemap(vec3 color){const float a=0.2;const float b=0.29;const float c=0.24;const float d=0.272;const float e=0.02;const float f=0.3;\n#ifndef GL_FRAGMENT_PRECISION_HIGH\ncolor=min(color,TONEMAPPING_CLAMP_MAX);\n#endif\nconst float whiteScale=1.31338;color=neutralCurve(color*whiteScale,a,b,c,d,e,f);color*=whiteScale;return color;}",ACESTonemapping:"#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\nvec3 ACESTonemap(vec3 color){vec3 aces=sRGB_2_AP0*color;mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(vec3(aces));mediump float centeredHue=center_hue(hue,RRT_RED_HUE);float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);vec3 acescg=max(AP0_2_AP1_MAT*aces,0.0);acescg=mix(vec3(dot(acescg,AP1_RGB2Y)),acescg,RRT_SAT_FACTOR);const float a=0.0245786;const float b=0.000090537;const float c=0.983729;const float d=0.4329510;const float e=0.238081;vec3 rcpAcesCG=1.0/(acescg+FLT_MIN);mediump vec3 rgbPost=(acescg+a-b*rcpAcesCG)/(acescg*c+d+e*rcpAcesCG);vec3 linearCV=darkSurround_to_dimSurround(rgbPost);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;return linearCV;}"}),ro.create(oi.UBER_SHADER_NAME,ij,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;\n#ifdef ENABLE_EFFECT_BLOOM\nuniform sampler2D material_BloomTexture;uniform sampler2D material_BloomDirtTexture;uniform vec4 material_BloomTint;uniform vec4 material_BloomDirtTilingOffset;uniform vec4 material_BloomIntensityParams;\n#endif\nvoid main(){mediump vec4 color=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef ENABLE_EFFECT_BLOOM\n#ifdef BLOOM_HQ\nmediump vec4 bloom=sampleTexture2DBicubic(material_BloomTexture,v_uv,renderer_texelSize);\n#else\nmediump vec4 bloom=sampleTexture(material_BloomTexture,v_uv);\n#endif\nbloom*=material_BloomIntensityParams.x;color+=bloom*material_BloomTint;\n#ifdef BLOOM_DIRT\nmediump vec4 dirt=sampleTexture(material_BloomDirtTexture,v_uv*material_BloomDirtTilingOffset.xy+material_BloomDirtTilingOffset.zw);dirt*=material_BloomIntensityParams.y;color+=dirt*bloom;\n#endif\n#endif\n#ifdef ENABLE_EFFECT_TONEMAPPING\n#if TONEMAPPING_MODE == 0\ncolor.rgb=neutralTonemap(color.rgb);\n#elif TONEMAPPING_MODE == 1\ncolor.rgb=ACESTonemap(color.rgb);\n#endif\ncolor.rgb=clamp(color.rgb,vec3(0),vec3(1));\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}");var oo=/*#__PURE__*/function(e){function t(n,r){(a=e.call(this,n)||this).physics=new ip(a),a.castShadows=!0,a.shadowResolution=rW.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new tT(1/15,.2,7/15),a.shadowDistance=50,a.shadowFadeBorder=.1,a._lightManager=new oe,a._componentsManager=new i1,a._maskManager=new i2,a._isActiveInEngine=!1,a._globalShaderMacro=new nW,a._rootEntities=[],a._postProcessManager=new oi(a),a._background=new i0(a._engine),a._shaderData=new rs(n8.Scene),a._shadowCascades=rK.NoCascades,a._fogMode=i3.None,a._fogColor=new tO(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new tI,a._isActive=!0,a._enableTransparentShadow=!1,a.name=r||"";var a,i=a.shaderData;return i._addReferCount(1),a.ambientLight=new i8(n),n.sceneManager._allCreatedScenes.push(a),i.enableMacro("SCENE_FOG_MODE",a._fogMode.toString()),i.enableMacro("SCENE_SHADOW_CASCADED_COUNT",a.shadowCascades.toString()),i.setColor(t._fogColorProperty,a._fogColor),i.setVector4(t._fogParamsProperty,a._fogParams),a._computeLinearFogParams(a._fogStart,a._fogEnd),a._computeExponentialFogParams(a._fogDensity),a}tW(t,e);var n=t.prototype;return n.createRootEntity=function(e){var t=new aW(this._engine,e);return this.addRootEntity(t),t},n.addRootEntity=function(e,t){"number"==typeof e?n=e:(n=void 0,t=e);var n,r=t._isRoot;r||(t._isRoot=!0,t._removeFromParent(),t._setTransformDirty());var a=t._scene;a!==this?(a&&r&&a._removeFromEntityList(t),this._addToRootEntityList(n,t)):r||this._addToRootEntityList(n,t);var i=rc.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=rc.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=rc.Scene),i&&t._processInActive(i),a!==this&&aW._traverseSetOwnerScene(t,this);var o=rc.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=rc.Hierarchy)),t._isActiveInScene&&a===this||(o|=rc.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=rc.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=rc.Hierarchy),e._isActiveInScene&&(t|=rc.Scene),t&&e._processInActive(t),aW._traverseSetOwnerScene(e,null)}},n.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},n.findEntityByName=function(e){for(var t=this._rootEntities,n=0,r=t.length;n<r;n++){var a=t[n].findByName(e);if(a)return a}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),n=0,r=this.rootEntitiesCount;n<r;n++){var a=this.getRootEntity(n);if(a.name==t[0]){for(var i=1,o=t.length;i<o&&(a=aW._findChildByName(a,t[i]));++i);return a}}return null},n._processActive=function(e){this._isActiveInEngine=e;for(var t=this._rootEntities,n=t.length-1;n>=0;n--){var r=t[n];r._isActive&&(e?r._processActive(rc.Hierarchy):r._processInActive(rc.Hierarchy))}},n._updateShaderData=function(){var e=this.shaderData,t=this._engine,n=this._lightManager;t.time._updateSceneShaderData(e),n._updateShaderData(this.shaderData);var r=this._lightManager._sunlight=this._getSunlight();r?(n._updateSunlightIndex(r),e.setColor(oe._sunlightColorProperty,r._lightColor),e.setVector3(oe._sunlightDirectionProperty,r.direction)):e.setVector3(oe._sunlightDirectionProperty,tT._zero),this.castShadows&&r&&r.shadowType!==rj.None?e.enableMacro("SCENE_SHADOW_TYPE",r.shadowType.toString()):e.disableMacro("SCENE_SHADOW_TYPE"),nW.unionCollection(this.engine._macroCollection,e._macroCollection,this._globalShaderMacro)},n._removeFromEntityList=function(e){var t=this._rootEntities,n=e._siblingIndex;t.splice(n,1);for(var r=t.length;n<r;n++)t[n]._siblingIndex--;e._siblingIndex=-1},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._engine.sceneManager;for(t.removeScene(this);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts(),this._maskManager.destroy();var n=t._allCreatedScenes;n.splice(n.indexOf(this),1)},n._addToRootEntityList=function(e,t){var n=this._rootEntities,r=n.length;if(void 0===e)t._siblingIndex=r,n.push(t);else{if(e<0||e>r)throw"The index "+e+" is out of child list bounds "+r;t._siblingIndex=e,n.splice(e,0,t);for(var a=e+1,i=r+1;a<i;a++)n[a]._siblingIndex++}},n._computeLinearFogParams=function(e,t){var n=t-e,r=this._fogParams;r.x=-1/n,r.y=t/n},n._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},n._getSunlight=function(){return this._sun?this._sun.enabled?this._sun:null:this._lightManager._getMaxBrightestSunlight()},tG(t,[{key:"isActive",get:function(){return this._isActive},set:function(e){this._isActive!==e&&(this._isActive=e,e?this._sceneManager&&this._processActive(!0):this._sceneManager&&this._processActive(!1))}},{key:"shaderData",get:function(){return this._shaderData}},{key:"background",get:function(){return this._background}},{key:"shadowCascades",get:function(){return this._shadowCascades},set:function(e){this._shadowCascades!==e&&(this.shaderData.enableMacro("SCENE_SHADOW_CASCADED_COUNT",e.toString()),this._shadowCascades=e)}},{key:"ambientLight",get:function(){return this._ambientLight},set:function(e){if(!e){no.warn("The scene must have one ambient light");return}var t=this._ambientLight;t!==e&&(t&&t._removeFromScene(this),e._addToScene(this),this._ambientLight=e)}},{key:"fogMode",get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this.shaderData.enableMacro("SCENE_FOG_MODE",e.toString()),this._fogMode=e)}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor!==e&&this._fogColor.copyFrom(e)}},{key:"fogStart",get:function(){return this._fogStart},set:function(e){this._fogStart!==e&&(this._computeLinearFogParams(e,this._fogEnd),this._fogStart=e)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(e){this._fogEnd!==e&&(this._computeLinearFogParams(this._fogStart,e),this._fogEnd=e)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(e){this._fogDensity!==e&&(this._computeExponentialFogParams(e),this._fogDensity=e)}},{key:"rootEntitiesCount",get:function(){return this._rootEntities.length}},{key:"rootEntities",get:function(){return this._rootEntities}},{key:"sun",get:function(){return this._sun},set:function(e){this._sun=e}},{key:"enableTransparentShadow",get:function(){return this._enableTransparentShadow},set:function(e){e!==this._enableTransparentShadow&&(this._enableTransparentShadow=e,e?this.shaderData.enableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"):this.shaderData.disableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"))}}]),t}(t0);oo._fogColorProperty=nY.getByName("scene_FogColor"),oo._fogParamsProperty=nY.getByName("scene_FogParams");var os=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._started=!1,t._onStartIndex=-1,t._onUpdateIndex=-1,t._onLateUpdateIndex=-1,t._onPhysicsUpdateIndex=-1,t._onPreRenderIndex=-1,t._onPostRenderIndex=-1,t._entityScriptsIndex=-1,t}tW(t,e);var n=t.prototype;return n.onAwake=function(){},n.onEnable=function(){},n.onStart=function(){},n.onUpdate=function(e){},n.onLateUpdate=function(e){},n.onBeginRender=function(e){},n.onEndRender=function(e){},n.onPhysicsUpdate=function(){},n.onTriggerEnter=function(e){},n.onTriggerExit=function(e){},n.onTriggerStay=function(e){},n.onCollisionEnter=function(e){},n.onCollisionExit=function(e){},n.onCollisionStay=function(e){},n.onPointerDown=function(e){},n.onPointerUp=function(e){},n.onPointerClick=function(e){},n.onPointerEnter=function(e){},n.onPointerExit=function(e){},n.onPointerDrag=function(e){},n.onDisable=function(){},n.onDestroy=function(){},n._onAwake=function(){this.onAwake()},n._onEnable=function(){this.onEnable()},n._onDisable=function(){this.onDisable()},n._onEnableInScene=function(){var e=this.scene._componentsManager,n=t.prototype;this._started||e.addOnStartScript(this),this.onUpdate!==n.onUpdate&&e.addOnUpdateScript(this),this.onLateUpdate!==n.onLateUpdate&&e.addOnLateUpdateScript(this),this.onPhysicsUpdate!==n.onPhysicsUpdate&&e.addOnPhysicsUpdateScript(this),this._entity._addScript(this)},n._onDisableInScene=function(){var e=this.scene._componentsManager,n=t.prototype;this._started||e.removeOnStartScript(this),this.onUpdate!==n.onUpdate&&e.removeOnUpdateScript(this),this.onLateUpdate!==n.onLateUpdate&&e.removeOnLateUpdateScript(this),this.onPhysicsUpdate!==n.onPhysicsUpdate&&e.removeOnPhysicsUpdateScript(this),this._entity._removeScript(this)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},t}(ru);tX([tq],os.prototype,"_started",void 0),tX([tq],os.prototype,"_onStartIndex",void 0),tX([tq],os.prototype,"_onUpdateIndex",void 0),tX([tq],os.prototype,"_onLateUpdateIndex",void 0),tX([tq],os.prototype,"_onPhysicsUpdateIndex",void 0),tX([tq],os.prototype,"_onPreRenderIndex",void 0),tX([tq],os.prototype,"_onPostRenderIndex",void 0),tX([tq],os.prototype,"_entityScriptsIndex",void 0);var ol=/*#__PURE__*/function(){function e(e){this.useCache=e}return e.registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},e.getClass=function(e){return this._engineObjects[e]},e.getClassName=function(e){return this._classNameMap.get(e)},e}();ol._engineObjects={},ol._classNameMap=new Map;var oc=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){var t=e.component,n=e.property.split(".");if(e.getProperty){var r=e.getProperty.split(".");this._initializeMounted(t,r,1),this._initializeMounted(t,n,2)}else this._initializeMounted(t,n,3)},t.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},t.setTargetValue=function(e){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=e;break;case 1:var t=this._setArgs;t[this._replaceValueIndex]=e,this._setMounted[this._setValueName].apply(this._setMounted,t);break;case 0:this._setMounted[this._setValueName]=e}},t._initializeMounted=function(e,t,n){for(var r,a,i,o,s=t.length-1,l=0;l<s;l++){var c=t[l];if(c.indexOf("[")>-1){var u=c.indexOf("[");e=(e=e[c.slice(0,u)])[parseInt(c.slice(u+1,-1))]}else if(c.endsWith(")")){var d=c.slice(0,c.indexOf("(")),h=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e});e=e[d].apply(e,h)}else e=e[c]}var _=t[s];if(_.indexOf("[")>-1){var f=_.indexOf("[");r=2,e=e[_.slice(0,f)],a=parseInt(_.slice(f+1,-1))}else if(_.endsWith(")")){if(i=_.slice(0,_.indexOf("(")),o=_.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e}),r=1,2&n){var p=o.indexOf("$value");this._replaceValueIndex=p>-1?p:o.length}}else r=0;2&n&&(this._setMounted=e,this._setType=r,this._setArrayIndex=a,this._setValueName=_,i&&(this._setValueName=i),this._setArgs=o),1&n&&(this._getMounted=e,this._getType=r,this._getArrayIndex=a,this._getValueName=_,i&&(this._getValueName=i),this._getArgs=o)},e}(),ou=/*#__PURE__*/function(){function e(t,n,r,a,i,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=a,this.getProperty=i,this.component=r,this.cureType=o;var s=e.getAssemblerType(n,a);this._assembler=new s,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateValue=function(e,t,n){return n?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,n,r,a,i){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,r,!1);var o=e&&e.keys.length?i?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):i?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?i?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):i?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,a)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var a=r?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,i=e&&e.keys.length?r?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):r?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(a,i,n)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.getEvaluateValue=function(e){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,e),e):this.baseEvaluateData.value},t.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},t.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t.applyValue=function(e,t,n){var r=this.cureType;if(n){var a=this._assembler;if(r._isCopyMode)r._additiveValue(e,t,this.referenceTargetValue);else{var i=a.getTargetValue(),o=r._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)r._isCopyMode?r._setValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(r._isCopyMode){var s=this.referenceTargetValue;r._lerpValue(s,e,t,s)}else{var l=this._assembler.getTargetValue(),c=r._lerpValue(l,e,t);this._assembler.setTargetValue(c)}},t._lerpValue=function(e,t,n){return this.cureType._isCopyMode?this.cureType._lerpValue(e,t,n,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(e,t,n),this.baseEvaluateData.value)},e.registerAssembler=function(t,n,r){var a=e._assemblerMap.get(t);a||(a={},e._assemblerMap.set(t,a)),a[n]=r},e.getAssemblerType=function(t,n){var r=e._assemblerMap.get(t),a=r?r[n]:void 0;return null!=a?a:oc},e}();ou._components=[],ou._assemblerMap=new Map;var od=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.position},t.setTargetValue=function(e){this._transform.position=e},e}();ou.registerAssembler(rp,"position",od);var oh=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.rotationQuaternion},t.setTargetValue=function(e){this._transform.rotationQuaternion=e},e}();ou.registerAssembler(rp,"rotationQuaternion",oh);var o_=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.scale},t.setTargetValue=function(e){this._transform.scale=e},e}();ou.registerAssembler(rp,"scale",o_);var of=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._skinnedMeshRenderer=e.component},t.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},t.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},e}();ou.registerAssembler(aK,"blendShapeWeights",of);var op=/*#__PURE__*/function(){function e(){this.crossCurveMark=0,this.isActive=!0}var t=e.prototype;return t.initFinalValue=function(){var e=this.curveOwner,t=e.cureType,n=e.defaultValue;t._isCopyMode?t._setValue(n,this.finalValue):this.finalValue=n},t.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},e}(),om=/*#__PURE__*/function(){function e(){this.typeIndex=0,this._tempCurveOwner={}}var t=e.prototype;return t._createCurveOwner=function(e,t){var n=this.curve.constructor,r=new ou(e,this.type,t,this.property,this.getProperty,n);return n._initializeOwner(r),r.saveDefaultValue(),r},t._createCurveLayerOwner=function(e){var t=this.curve.constructor,n=new op;return n.curveOwner=e,t._initializeLayerOwner(n),n.initFinalValue(),n},t._getTempCurveOwner=function(e,t){var n=e.instanceId;return this._tempCurveOwner[n]||(this._tempCurveOwner[n]=this._createCurveOwner(e,t)),this._tempCurveOwner[n]},e}(),og=function(){},ov=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n._curveBindings=[],n._updateFlagManager=new nM,n._length=0,n._events=[],n}tW(t,e);var n=t.prototype;return n.addEvent=function(e,t,n){if("string"==typeof e){var r,a=new og;a.functionName=e,a.time=t,a.parameter=n,r=a}else r=e;var i=this._events,o=i.length,s=r.time;if(s>=(o?i[o-1].time:0))i.push(r);else{for(var l=o;--l>=0&&s<i[l].time;);i.splice(l+1,0,r)}this._updateFlagManager.dispatch()},n.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},n.addCurveBinding=function(e,t,n,r,a,i){var o=new om;o.relativePath=e,o.type=t,"number"==typeof n?(o.typeIndex=n,o.property=r,"string"==typeof a?(o.getProperty=a,o.curve=i):o.curve=a):(o.property=n,"string"==typeof r?(o.getProperty=r,o.curve=a):o.curve=r),this._length=Math.max(this._length,o.curve.length),this._curveBindings.push(o)},n.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},n._sampleAnimation=function(e,t){for(var n=this._curveBindings,r=n.length-1;r>=0;r--){var a=n[r],i=e.findByPath(a.relativePath);if(i){var o=a.typeIndex>0?i.getComponents(a.type,ou._components)[a.typeIndex]:i.getComponent(a.type);if(!o)continue;var s=a._getTempCurveOwner(i,o);if(s&&a.curve.keys.length){var l=s.evaluateValue(a.curve,t,!1);s.applyValue(l,1,!1)}}}},tG(t,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),t}(t0),oy=((eI={})[eI.Linear=0]="Linear",eI[eI.CubicSpine=1]="CubicSpine",eI[eI.Step=2]="Step",eI[eI.Hermite=3]="Hermite",eI),ox=/*#__PURE__*/function(){function e(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var e=this.constructor;this._interpolation=e._supportInterpolationMode?oy.Linear:oy.Step,this._type=e}var t=e.prototype;return t.addKey=function(e){var t=e.time,n=this.keys;if(t>=this._length)n.push(e),this._length=t;else{for(var r=n.length;--r>=0&&t<n[r].time;);n.splice(r+1,0,e)}},t.evaluate=function(e){return this._evaluate(e,this._evaluateData)},t.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,n=0,r=t.length-1;r>=0;r--){var a=t[r];a.time>this._length&&(n=a.time)}this._length=n},t._evaluate=function(e,t){var n,r=this.keys.length;if(!r){console.warn("This curve don't have any keyframes: ",this);return}var a=this.keys,i=this.interpolation,o=t.curKeyframeIndex;-1!==o&&(o>=r||e<a[o].time)&&(o=-1);for(var s=o+1;s<r&&!(e<a[s].time);)o++,s++;if(t.curKeyframeIndex=o,-1===o)n=this._type._setValue(a[0].value,t.value);else if(s===r)n=this._type._setValue(a[o].value,t.value);else{var l=a[o],c=a[s],u=l.time,d=c.time-u,h=(e-u)/d;switch(i){case oy.Linear:n=this._type._lerpValue(l.value,c.value,h,t.value);break;case oy.Step:n=this._type._setValue(l.value,t.value);break;case oy.CubicSpine:case oy.Hermite:n=this._type._hermiteInterpolationValue(l,c,h,d,t.value)}}return t.value=n,n},t._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},tG(e,[{key:"interpolation",get:function(){return this._interpolation},set:function(e){this._type._supportInterpolationMode||e===oy.Step?this._interpolation=e:(this._interpolation=oy.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),e}();e.AnimationArrayCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=[],t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},t._initializeLayerOwner=function(e){e.finalValue=[]},t._lerpValue=function(e,t,n,r){for(var a=0,i=r.length;a<i;++a){var o=e[a];r[a]=o+(t[a]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},t._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},t._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},t._setValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},t._hermiteInterpolationValue=function(e,t,n,r,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},t}(ox),e.AnimationArrayCurve._isCopyMode=!0,e.AnimationArrayCurve._supportInterpolationMode=!0,e.AnimationArrayCurve=tX([ry()],e.AnimationArrayCurve),e.AnimationBoolCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=!1,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},t._initializeLayerOwner=function(e){e.finalValue=!1},t._lerpValue=function(e,t){return e},t._subtractValue=function(e,t,n){return e},t._getZeroValue=function(){return!1},t._additiveValue=function(e,t,n){return e},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e){return e.value},t}(ox),e.AnimationBoolCurve._isCopyMode=!1,e.AnimationBoolCurve._supportInterpolationMode=!1,e.AnimationBoolCurve=tX([ry()],e.AnimationBoolCurve),e.AnimationColorCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tO,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tO,e.fixedPoseValue=new tO,e.baseEvaluateData.value=new tO,e.crossEvaluateData.value=new tO},t._initializeLayerOwner=function(e){e.finalValue=new tO},t._lerpValue=function(e,t,n,r){return tO.lerp(e,t,n,r),r},t._subtractValue=function(e,t,n){return tO.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._additiveValue=function(e,t,n){return tO.scale(e,t,e),tO.add(n,e,n),n},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.r=d*i.r+h*p*r+_*m*r+f*s.r:a.r=i.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.g=d*i.g+h*p*r+_*m*r+f*s.g:a.g=i.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.b=d*i.b+h*p*r+_*m*r+f*s.b:a.b=i.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.a=d*i.a+h*p*r+_*m*r+f*s.a:a.a=i.a,a},t}(ox),e.AnimationColorCurve._isCopyMode=!0,e.AnimationColorCurve._supportInterpolationMode=!0,e.AnimationColorCurve=tX([ry()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tW(t,e),t.prototype.addKey=function(t){e.prototype.addKey.call(this,t);var n=this._evaluateData;if(!n.value||n.value.length!==t.value.length){var r=t.value.length;n.value=new Float32Array(r)}},t._initializeOwner=function(e){var t=e.referenceTargetValue.length;e.defaultValue=new Float32Array(t),e.fixedPoseValue=new Float32Array(t),e.baseEvaluateData.value=new Float32Array(t),e.crossEvaluateData.value=new Float32Array(t)},t._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},t._lerpValue=function(e,t,n,r){for(var a=0,i=r.length;a<i;++a){var o=e[a];r[a]=o+(t[a]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},t._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},t._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},t._setValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},t._hermiteInterpolationValue=function(e,t,n,r,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},t}(ox),e.AnimationFloatArrayCurve._isCopyMode=!0,e.AnimationFloatArrayCurve._supportInterpolationMode=!0,e.AnimationFloatArrayCurve=tX([ry()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=0,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},t._initializeLayerOwner=function(e){e.finalValue=0},t._lerpValue=function(e,t,n){return e+(t-e)*n},t._additiveValue=function(e,t,n){return n+e*t},t._subtractValue=function(e,t){return e-t},t._getZeroValue=function(){return 0},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e,t,n,r){var a=e.outTangent,i=t.inTangent;if(!(Number.isFinite(a)&&Number.isFinite(i)))return e.value;var o=n*n,s=o*n;return(2*s-3*o+1)*e.value+(s-2*o+n)*a*r+(s-o)*i*r+(-2*s+3*o)*t.value},t}(ox),e.AnimationFloatCurve._isCopyMode=!1,e.AnimationFloatCurve._supportInterpolationMode=!0,e.AnimationFloatCurve=tX([ry()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tF,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tF,e.fixedPoseValue=new tF,e.baseEvaluateData.value=new tF,e.crossEvaluateData.value=new tF},t._initializeLayerOwner=function(e){e.finalValue=new tF},t._lerpValue=function(e,t,n,r){return tF.slerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return e.x=e.x*t,e.y=e.y*t,e.z=e.z*t,e.normalize(),n.multiply(e),n},t._subtractValue=function(e,n,r){var a=t._tempConjugateQuat;return tF.conjugate(n,a),tF.multiply(a,e,r),r},t._getZeroValue=function(e){return e.set(0,0,0,1),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*r+_*m*r+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*r+_*m*r+f*s.w:a.w=i.w,a},t}(ox),e.AnimationQuaternionCurve._supportInterpolationMode=!0,e.AnimationQuaternionCurve._isCopyMode=!0,e.AnimationQuaternionCurve._tempConjugateQuat=new tF,e.AnimationQuaternionCurve=tX([ry()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tB,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tB,e.fixedPoseValue=new tB,e.baseEvaluateData.value=new tB,e.crossEvaluateData.value=new tB},t._initializeLayerOwner=function(e){e.finalValue=new tB},t._lerpValue=function(e,t,n,r){return tB.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tB.scale(e,t,e),tB.add(n,e,n),n},t._subtractValue=function(e,t,n){return tB.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,a},t}(ox),e.AnimationVector2Curve._isCopyMode=!0,e.AnimationVector2Curve._supportInterpolationMode=!0,e.AnimationVector2Curve=tX([ry()],e.AnimationVector2Curve),e.AnimationVector3Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tT,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tT,e.fixedPoseValue=new tT,e.baseEvaluateData.value=new tT,e.crossEvaluateData.value=new tT},t._initializeLayerOwner=function(e){e.finalValue=new tT},t._lerpValue=function(e,t,n,r){return tT.lerp(e,t,n,r),r},t._relativeBaseValue=function(e,t){return tT.subtract(t,e,t),t},t._additiveValue=function(e,t,n){return tT.scale(e,t,e),tT.add(n,e,n),n},t._subtractValue=function(e,t,n){return tT.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*r+_*m*r+f*s.z:a.z=i.z,a},t}(ox),e.AnimationVector3Curve._isCopyMode=!0,e.AnimationVector3Curve._supportInterpolationMode=!0,e.AnimationVector3Curve=tX([ry()],e.AnimationVector3Curve),e.AnimationVector4Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tI,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tI,e.fixedPoseValue=new tI,e.baseEvaluateData.value=new tI,e.crossEvaluateData.value=new tI},t._initializeLayerOwner=function(e){e.finalValue=new tI},t._lerpValue=function(e,t,n,r){return tI.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tI.scale(e,t,e),tI.add(n,e,n),n},t._subtractValue=function(e,t,n){return tI.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*r+_*m*r+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*r+_*m*r+f*s.w:a.w=i.w,a},t}(ox),e.AnimationVector4Curve._isCopyMode=!0,e.AnimationVector4Curve._supportInterpolationMode=!0,e.AnimationVector4Curve=tX([ry()],e.AnimationVector4Curve),e.AnimationRefCurve=/*#__PURE__*/function(e){function t(){return e.call(this)||this}return tW(t,e),t._initializeOwner=function(e){},t._initializeLayerOwner=function(e){},t._setValue=function(e){return e},t}(ox),e.AnimationRefCurve._isCopyMode=!1,e.AnimationRefCurve._supportInterpolationMode=!1,e.AnimationRefCurve=tX([ry()],e.AnimationRefCurve),e.AnimationRectCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tV,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tV,e.fixedPoseValue=new tV,e.baseEvaluateData.value=new tV,e.crossEvaluateData.value=new tV},t._initializeLayerOwner=function(e){e.finalValue=new tV},t._setValue=function(e,t){return t.copyFrom(e),t},t}(ox),e.AnimationRectCurve._isCopyMode=!0,e.AnimationRectCurve._supportInterpolationMode=!1,e.AnimationRectCurve=tX([ry()],e.AnimationRectCurve),e.AnimationStringCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value="",t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},t._initializeLayerOwner=function(e){e.finalValue=""},t._lerpValue=function(e,t){return e},t._subtractValue=function(e,t,n){return e},t._getZeroValue=function(){return""},t._additiveValue=function(e,t,n){return e},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e){return e.value},t}(ox),e.AnimationStringCurve._isCopyMode=!1,e.AnimationStringCurve._supportInterpolationMode=!1,e.AnimationStringCurve=tX([ry()],e.AnimationStringCurve);var ob=((eO={})[eO.If=0]="If",eO[eO.IfNot=1]="IfNot",eO[eO.Greater=2]="Greater",eO[eO.Less=3]="Less",eO[eO.Equals=4]="Equals",eO[eO.NotEquals=5]="NotEquals",eO),oS=((eV={})[eV.None=0]="None",eV[eV.Complete=1]="Complete",eV),oC=((eN={})[eN.Override=0]="Override",eN[eN.Additive=1]="Additive",eN),oT=((ek={})[ek.UnStarted=0]="UnStarted",ek[ek.Playing=1]="Playing",ek[ek.Finished=2]="Finished",ek),oA=((ez={})[ez.Standby=0]="Standby",ez[ez.Playing=1]="Playing",ez[ez.CrossFading=2]="CrossFading",ez[ez.FixedCrossFading=3]="FixedCrossFading",ez[ez.Finished=4]="Finished",ez),oE=/*#__PURE__*/function(){function e(){this.handlers=[]}return e.prototype.dispose=function(){},e}(),oR=function(){},oM=/*#__PURE__*/function(){function e(){this.duration=0,this.offset=0,this.exitTime=1,this.mute=!1,this.isFixedDuration=!1,this._isExit=!1,this._conditions=[],this._solo=!1,this._hasExitTime=!0}var t=e.prototype;return t.addCondition=function(e,t,n){if((void 0===e?"undefined":e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object")return this._conditions.push(e),e;var r=new oR;return r.parameterName=e,r.mode=null!=t?t:ob.If,r.threshold=n,this._conditions.push(r),r},t.removeCondition=function(e){var t=this._conditions.indexOf(e);-1!==t&&this._conditions.splice(t,1)},t._getFixedDuration=function(){return this.isFixedDuration?this.duration:this.duration*this.destinationState._getDuration()},tG(e,[{key:"isExit",get:function(){return this._isExit}},{key:"solo",get:function(){return this._solo},set:function(e){var t;this._solo!==e&&(this._solo=e,null==(t=this._collection)||t.updateTransitionSolo(e))}},{key:"conditions",get:function(){return this._conditions}},{key:"hasExitTime",get:function(){return this._hasExitTime},set:function(e){var t;this._hasExitTime!==e&&(this._hasExitTime=e,null==(t=this._collection)||t.updateTransitionsIndex(this,e))}}]),e}(),ow=((eU={})[eU.Once=0]="Once",eU[eU.Loop=1]="Loop",eU),oP=/*#__PURE__*/function(){function e(){this.isForward=!0,this._changedOrientation=!1}var t=e.prototype;return t.reset=function(e,t,n){this.state=e,this.playedTime=0,this.offsetFrameTime=n,this.stateData=t,this.playState=oT.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.isForward=!0,this.state._transitionCollection.needResetCurrentCheckIndex=!0},t.updateOrientation=function(e){if(0!==e){var t=this.isForward;this.isForward=e>0,this.isForward!==t&&(this._changedOrientation=!0,this.isForward||this._correctTime())}},t.update=function(e){this.playedTime+=e;var t=this.state,n=this.playedTime+this.offsetFrameTime,r=t._getDuration();this.playState=oT.Playing,t.wrapMode===ow.Loop?n=r?n%r:0:Math.abs(n)>=r&&(n=n<0?-r:r,this.playState=oT.Finished),n<0&&(n+=r),this.clipTime=n+t.clipStartTime*t.clip.length,this._changedOrientation&&(this.isForward||this._correctTime(),this._changedOrientation=!1)},t._correctTime=function(){var e=this.state;0===this.clipTime&&(this.clipTime=e.clipEndTime*e.clip.length)},e}(),oF=/*#__PURE__*/function(){function e(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new oP,this.destPlayData=new oP,this.layerState=oA.Standby,this.crossCurveMark=0,this.manuallyTransition=new oM,this.crossLayerOwnerCollection=[]}var t=e.prototype;return t.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},t.resetCurrentCheckIndex=function(){this.layer.stateMachine._entryTransitionCollection.needResetCurrentCheckIndex=!0,this.layer.stateMachine._anyStateTransitionCollection.needResetCurrentCheckIndex=!0},e}(),oL=function(){this.curveLayerOwner=[],this.eventHandlers=[]},oD=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this).cullingMode=oS.None,n.speed=1,n._playFrameCount=-1,n._onUpdateIndex=-1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new iq(oE),n._parametersValueMap=Object.create(null),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n}tW(n,t);var r=n.prototype;return r.play=function(e,t,n){void 0===t&&(t=-1),void 0===n&&(n=0),(null==(r=this._controllerUpdateFlag)?void 0:r.flag)&&this._reset();var r,a=this._getAnimatorStateInfo(e,t),i=a.state;i&&this._preparePlay(i,a.layerIndex,n)&&(this._playFrameCount=this.engine.time.frameCount)},r.crossFade=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!1)},r.crossFadeInFixedDuration=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!0)},r.update=function(e){if(this._playFrameCount===this.engine.time.frameCount&&(e=0),this.cullingMode===oS.Complete){n=!1;for(var t,n,r=this._controlledRenderers,a=0,i=r.length;a<i;a++)if(!r[a].isCulled){n=!0;break}}else n=!0;var o=this._animatorController;if(o){(null==(t=this._controllerUpdateFlag)?void 0:t.flag)&&this._reset(),this._updateMark++;for(var s=o.layers,l=0,c=s.length;l<c;l++){var u=this._getAnimatorLayerData(l);this._updateState(u,e,n)}}},r.getCurrentAnimatorState=function(e){var t,n;return null==(n=this._animatorLayersData[e])?void 0:null==(t=n.srcPlayData)?void 0:t.state},r.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},r.findLayerByName=function(e){var t;return null==(t=this._animatorController)?void 0:t._layersMap[e]},r.getParameter=function(e){var t,n;return null!=(n=null==(t=this._animatorController)?void 0:t._parametersMap[e])?n:null},r.getParameterValue=function(e){var t,n,r=null==(t=this._animatorController)?void 0:t._parametersMap[e];if(r)return null!=(n=this._parametersValueMap[e])?n:r.defaultValue},r.setParameterValue=function(e,t){var n;(null==(n=this._animatorController)?void 0:n._parametersMap[e])&&(this._parametersValueMap[e]=t)},r.activateTriggerParameter=function(e){var t,n=null==(t=this._animatorController)?void 0:t._parametersMap[e];(null==n?void 0:n._isTrigger)&&(this._parametersValueMap[e]=!0)},r.deactivateTriggerParameter=function(e){var t,n=null==(t=this._animatorController)?void 0:t._parametersMap[e];(null==n?void 0:n._isTrigger)&&(this._parametersValueMap[e]=!1)},r._onEnable=function(){this._reset(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},r._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},r._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},r._reset=function(){var e=this._curveOwnerPool;for(var t in e){var n=e[t];for(var r in n)n[r].revertDefaultValue()}this._animatorLayersData.length=0,this._curveOwnerPool=Object.create(null),this._parametersValueMap=Object.create(null),this._animationEventHandlerPool.clear(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},r._crossFade=function(e,t,n,r,a){(null==(i=this._controllerUpdateFlag)?void 0:i.flag)&&this._reset();var i,o=this._getAnimatorStateInfo(e,n),s=o.state,l=o.layerIndex,c=this._getAnimatorLayerData(l).manuallyTransition;c.duration=t,c.offset=r,c.isFixedDuration=a,c.destinationState=s,this._prepareCrossFadeByTransition(c,l)&&(this._playFrameCount=this.engine.time.frameCount)},r._getAnimatorStateInfo=function(e,t){var n=this._animatorController,r=this._tempAnimatorStateInfo,a=null;if(n){var i=n.layers;if(-1===t){for(var o=0,s=i.length;o<s;o++)if(a=i[o].stateMachine.findStateByName(e)){t=o;break}}else a=i[t].stateMachine.findStateByName(e)}return r.layerIndex=t,r.state=a,r},r._getAnimatorStateData=function(e,t,n,r){var a=n.animatorStateDataMap,i=a[e];return i||(i=new oL,a[e]=i,this._saveAnimatorStateData(t,i,n,r),this._saveAnimatorEventHandlers(t,i)),i},r._saveAnimatorStateData=function(e,t,n,r){for(var a=this.entity,i=this._curveOwnerPool,o=this._animatorController.layers[r].mask,s=t.curveLayerOwner,l=e.clip._curveBindings,c=n.curveOwnerPool,u=l.length-1;u>=0;u--){var d=l[u],h=d.relativePath,_=""===d.relativePath?a:a.findByPath(d.relativePath);if(_){var f,p,m=d.typeIndex>0?_.getComponents(d.type,ou._components)[d.typeIndex]:_.getComponent(d.type);if(!m)continue;var g=d.property,v=m.instanceId,y=i[v]||(i[v]=Object.create(null)),x=y[g]||(y[g]=d._createCurveOwner(_,m)),b=c[v]||(c[v]=Object.create(null)),S=b[g]||(b[g]=d._createCurveLayerOwner(x));o&&o.pathMasks.length&&(S.isActive=null==(p=null==(f=o.getPathMask(h))?void 0:f.active)||p),s[u]=S}else s[u]=null,no.warn("The entity don't have the child entity which path is "+d.relativePath+".")}},r._saveAnimatorEventHandlers=function(e,t){var n=this,r=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){n._entity.getComponents(os,a);var t=a.length,o=e.clip.events;i.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=r.get(),d=c.functionName,h=u.handlers;u.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f,p=a[_],m=null==(f=p[d])?void 0:f.bind(p);m&&h.push(m)}i.push(u)}};o(),e._updateFlagManager.addListener(o)},r._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},r._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},r._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},r._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},r._prepareFixedPoseCrossFading=function(e){for(var t=e.crossLayerOwnerCollection,n=t.length-1;n>=0;n--){var r=t[n];r&&(r.curveOwner.saveFixedPoseValue(),r.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},r._prepareSrcCrossData=function(e,t){for(var n=e.srcPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var a=n[r];a&&(a.crossCurveMark=e.crossCurveMark,t&&a.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,a,r,-1))}},r._prepareDestCrossData=function(e,t){for(var n=e.destPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var a=n[r];if(a){if(a.crossCurveMark===e.crossCurveMark)a.crossDestCurveIndex=r;else{var i=a.curveOwner;t&&i.saveFixedPoseValue(),a.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,a,-1,r)}}}},r._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||((t=new oF).layerIndex=e,t.layer=this._animatorController.layers[e],this._animatorLayersData[e]=t),t},r._updateState=function(e,t,n){var r=e.layer,a=r.weight,i=r.blendingMode===oC.Additive;switch(0===e.layerIndex&&(a=1),e.layerState){case oA.Standby:this._checkAnyAndEntryState(e,t,n);break;case oA.Playing:this._updatePlayingState(e,a,i,t,n);break;case oA.Finished:this._updateFinishedState(e,a,i,t,n);break;case oA.CrossFading:this._updateCrossFadeState(e,a,i,t,n);break;case oA.FixedCrossFading:this._updateCrossFadeFromPoseState(e,a,i,t,n)}},r._updatePlayingState=function(e,t,n,r,a){var i,o=e.srcPlayData,s=o.state,l=s.speed*this.speed,c=l*r;o.updateOrientation(c);var u=o.clipTime,d=o.playState;o.update(c);var h=o.clipTime,_=o.isForward,f=s._transitionCollection,p=e.layer.stateMachine._anyStateTransitionCollection,m=p.count&&this._applyStateTransitions(e,_,o,p,u,h,c,a)||f.count&&this._applyStateTransitions(e,_,o,f,u,h,c,a);if(m){var g=s._getClipActualEndTime();if(m.hasExitTime){var v=m.exitTime*s._getDuration()+s._getClipActualStartTime();if(_)i=v<u?v+g-u:v-u;else{var y=s._getClipActualStartTime();i=-(i=u<v?g-v+u-y:u-v)}}else i=0;o.update(i-c)}else i=c,o.playState===oT.Finished&&(e.layerState=oA.Finished);if(this._evaluatePlayingState(o,t,n,a),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,u,d,i),m){var x=r-i/l;x>0&&this._updateState(e,x,a)}},r._evaluatePlayingState=function(e,t,n,r){var a=e.state.clip._curveBindings,i=e.playState===oT.Finished;if(r||i)for(var o=e.stateData.curveLayerOwner,s=a.length-1;s>=0;s--){var l=o[s],c=null==l?void 0:l.curveOwner;if(c&&l.isActive){var u=a[s].curve;if(u.keys.length){this._checkRevertOwner(c,n);var d=c.evaluateValue(u,e.clipTime,n);r&&c.applyValue(d,t,n),i&&l.saveFinalValue()}}}},r._updateCrossFadeState=function(e,t,n,r,a){var i,o=e.srcPlayData,s=e.destPlayData,l=e.layerIndex,c=this.speed,u=o.state,d=s.state,h=e.crossFadeTransition._getFixedDuration(),_=u.speed*c,f=d.speed*c,p=f*r;o&&o.updateOrientation(_*r),s&&s.updateOrientation(p);var m=o.clipTime,g=o.playState,v=s.clipTime,y=s.playState;if(s.isForward){var x=s.playedTime;i=x+p>h?h-x:p}else{var b=s.playedTime;i=b-p>h?b-h:p}var S=0===f?r:i/f,C=S*_;o.update(C),s.update(i);var T=Math.abs(s.playedTime)/h;(T>=1-tC.zeroTolerance||0===h)&&(T=1);var A=1===T;if(A?(o.playState=oT.Finished,this._preparePlayOwner(e,d),this._evaluatePlayingState(s,t,n,a)):this._evaluateCrossFadeState(e,o,s,t,T,n,a),this._fireAnimationEventsAndCallScripts(l,o,u,m,g,C),this._fireAnimationEventsAndCallScripts(l,s,d,v,y,i),A){this._updateCrossFadeData(e);var E=r-S;E>0&&this._updateState(e,E,a)}},r._evaluateCrossFadeState=function(e,t,n,r,a,i,o){var s=e.crossLayerOwnerCollection,l=t.state.clip._curveBindings,c=n.state.clip._curveBindings,u=n.playState===oT.Finished;if(o||u)for(var d=s.length-1;d>=0;d--){var h=s[d],_=null==h?void 0:h.curveOwner;if(_){var f=h.crossSrcCurveIndex,p=h.crossDestCurveIndex;this._checkRevertOwner(_,i);var m=_.evaluateCrossFadeValue(f>=0?l[f].curve:null,p>=0?c[p].curve:null,t.clipTime,n.clipTime,a,i);o&&_.applyValue(m,r,i),u&&h.saveFinalValue()}}},r._updateCrossFadeFromPoseState=function(e,t,n,r,a){var i,o=e.destPlayData,s=o.state,l=e.crossFadeTransition._getFixedDuration(),c=s.speed*this.speed,u=c*r;o.updateOrientation(u);var d=o.clipTime,h=o.playState;if(o.isForward){var _=o.playedTime;i=_+u>l?l-_:u}else{var f=o.playedTime;i=f-u>l?f-l:u}var p=0===c?r:i/c;o.update(i);var m=Math.abs(o.playedTime)/l;(m>=1-tC.zeroTolerance||0===l)&&(m=1);var g=1===m;if(g?(this._preparePlayOwner(e,s),this._evaluatePlayingState(o,t,n,a)):this._evaluateCrossFadeFromPoseState(e,o,t,m,n,a),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,d,h,i),g){this._updateCrossFadeData(e);var v=r-p;v>0&&this._updateState(e,v,a)}},r._evaluateCrossFadeFromPoseState=function(e,t,n,r,a,i){var o=e.crossLayerOwnerCollection,s=t.state.clip._curveBindings,l=t.clipTime,c=t.playState===oT.Finished;if(i||c)for(var u=o.length-1;u>=0;u--){var d=o[u],h=null==d?void 0:d.curveOwner;if(h){var _=d.crossDestCurveIndex;this._checkRevertOwner(h,a);var f=d.curveOwner.crossFadeFromPoseAndApplyValue(_>=0?s[_].curve:null,l,r,a);i&&h.applyValue(f,n,a),c&&d.saveFinalValue()}}},r._updateFinishedState=function(e,t,n,r,a){var i=e.srcPlayData,o=i.state,s=o.speed*this.speed*r;i.updateOrientation(s);var l=i.clipTime,c=i.isForward,u=o._transitionCollection,d=e.layer.stateMachine._anyStateTransitionCollection;d.count&&this._applyTransitionsByCondition(e,d,a)||u.count&&this._applyStateTransitions(e,c,i,u,l,l,s,a)?this._updateState(e,r,a):this._evaluateFinishedState(i,t,n,a)},r._evaluateFinishedState=function(e,t,n,r){if(r)for(var a=e.stateData.curveLayerOwner,i=e.state.clip._curveBindings,o=i.length-1;o>=0;o--){var s=a[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,n),l.applyValue(s.finalValue,t,n))}},r._updateCrossFadeData=function(e){e.destPlayData.playState===oT.Finished?e.layerState=oA.Finished:e.layerState=oA.Playing,e.switchPlayData(),e.crossFadeTransition=null},r._preparePlayOwner=function(e,t){if(e.layerState===oA.Playing){var n=e.srcPlayData;if(n.state!==t)for(var r,a=n.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(r=a[i])||r.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},r._applyStateTransitions=function(e,t,n,r,a,i,o,s){var l=n.state,c=l.clip.length,u=null,d=l.clipStartTime*c,h=l.clipEndTime*c;return r.noExitTimeCount&&(u=this._checkNoExitTimeTransition(e,r,s))||(t?a+o>=h?(u=this._checkSubTransition(e,l,r,a,h,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkSubTransition(e,l,r,d,i,s)):u=this._checkSubTransition(e,l,r,a,i,s):a+o<=d?(u=this._checkBackwardsSubTransition(e,l,r,a,d,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkBackwardsSubTransition(e,l,r,i,h,s)):u=this._checkBackwardsSubTransition(e,l,r,a,i,s)),u},r._checkNoExitTimeTransition=function(e,t,n){for(var r=0,a=t.count;r<a;++r){var i=t.get(r);if(!i.mute&&(!t.isSoloMode||i.solo)&&this._checkConditions(i))return this._applyTransition(e,i,n)}return null},r._checkSubTransition=function(e,t,n,r,a,i){n.needResetCurrentCheckIndex&&n.resetCurrentCheckIndex(!0);for(var o=n.transitions,s=n.noExitTimeCount+n.currentCheckIndex,l=o.length;s<l;s++){var c=o[s],u=c.exitTime*t._getDuration()+t._getClipActualStartTime();if(u>a)break;if(!(u<r)){if(n.updateCurrentCheckIndex(!0),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,i)}}return null},r._checkBackwardsSubTransition=function(e,t,n,r,a,i){n.needResetCurrentCheckIndex&&n.resetCurrentCheckIndex(!1);for(var o=n.transitions,s=n.noExitTimeCount,l=n.currentCheckIndex+s;l>=s;l--){var c=o[l],u=c.exitTime*t._getDuration()+t._getClipActualStartTime();if(u<a)break;if(!(u>r)){if(n.updateCurrentCheckIndex(!1),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,i)}}return null},r._applyTransitionsByCondition=function(e,t,n){for(var r=0,a=t.count;r<a;r++){var i=t.get(r);if(!i.mute&&(!t.isSoloMode||i.solo)&&this._checkConditions(i)){if(this._applyTransition(e,i,n))return i;return null}}},r._preparePlay=function(e,t,n){void 0===n&&(n=0);var r=e.name;if(!e.clip)return no.warn("The state named "+r+" has no AnimationClip data."),!1;var a=this._getAnimatorLayerData(t),i=this._getAnimatorStateData(r,e,a,t);return this._preparePlayOwner(a,e),a.layerState=oA.Playing,a.srcPlayData.reset(e,i,e._getClipActualEndTime()*n),a.resetCurrentCheckIndex(),!0},r._applyTransition=function(e,t,n){var r=this._prepareCrossFadeByTransition(t,e.layerIndex);return t.isExit?(this._checkAnyAndEntryState(e,0,n),t):r?t:null},r._checkConditions=function(e){for(var t=e.conditions,r=!0,a=0,i=t.length;a<i;++a){var o=!1,s=t[a],l=s.mode,c=s.parameterName,u=s.threshold,d=this.getParameterValue(c);if(void 0===d)return!1;if(!0===d){var h=this.getParameter(c);(null==h?void 0:h._isTrigger)&&(n._passedTriggerParameterNames.push(c),o=!0)}if(!o)switch(l){case ob.Equals:d===u&&(o=!0);break;case ob.Greater:d>u&&(o=!0);break;case ob.Less:d<u&&(o=!0);break;case ob.NotEquals:d!==u&&(o=!0);break;case ob.If:!0===d&&(o=!0);break;case ob.IfNot:!1===d&&(o=!0)}if(!o){r=!1;break}}return r&&this._deactivateTriggeredParameters(),n._passedTriggerParameterNames.length=0,r},r._prepareCrossFadeByTransition=function(e,t){var n=e.destinationState;if(!n)return!1;if(!n.clip)return no.warn("The state named "+n.name+" has no AnimationClip data."),!1;var r=this._getAnimatorLayerData(t),a=this._getAnimatorStateData(n.name,n,r,t);switch(r.destPlayData.reset(n,a,e.offset*n._getClipActualEndTime()),r.resetCurrentCheckIndex(),r.layerState){case oA.Standby:case oA.Finished:r.layerState=oA.FixedCrossFading,this._clearCrossData(r),this._prepareStandbyCrossFading(r);break;case oA.Playing:r.layerState=oA.CrossFading,this._clearCrossData(r),this._prepareCrossFading(r);break;case oA.CrossFading:r.layerState=oA.FixedCrossFading,this._prepareFixedPoseCrossFading(r);break;case oA.FixedCrossFading:this._prepareFixedPoseCrossFading(r)}return r.crossFadeTransition=e,!0},r._fireAnimationEvents=function(e,t,n,r){var a=e.state,i=e.isForward,o=e.clipTime,s=a._getClipActualStartTime(),l=a._getClipActualEndTime();i?n+r>=l?(this._fireSubAnimationEvents(e,t,n,l),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,s,o)):this._fireSubAnimationEvents(e,t,n,o):n+r<=s?(this._fireBackwardSubAnimationEvents(e,t,n,s),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,l,o)):this._fireBackwardSubAnimationEvents(e,t,n,o)},r._fireSubAnimationEvents=function(e,t,n,r){for(var a=e.currentEventIndex,i=t.length;a<i;a++){var o=t[a],s=o.event,l=s.time,c=s.parameter;if(l>r)break;var u=o.handlers;if(l>=n){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(a+1,i-1)}}},r._fireBackwardSubAnimationEvents=function(e,t,n,r){for(var a=e.currentEventIndex;a>=0;a--){var i=t[a],o=i.event,s=o.time,l=o.parameter;if(s<r)break;if(s<=n){for(var c=i.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(a-1,0)}}},r._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,a=n.length;r<a;r++)n[r].onStateEnter(this,e,t)},r._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,a=n.length;r<a;r++)n[r].onStateUpdate(this,e,t)},r._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,a=n.length;r<a;r++)n[r].onStateExit(this,e,t)},r._checkAnyAndEntryState=function(e,t,n){var r,a=e.layer.stateMachine,i=a._anyStateTransitionCollection,o=a._entryTransitionCollection;if((r=i.count&&this._applyTransitionsByCondition(e,i,n))||(r=o.count&&this._applyTransitionsByCondition(e,o,n)),r)this._updateState(e,t,n);else{var s=a.defaultState;s&&(this._preparePlay(s,e.layerIndex),this._updateState(e,t,n))}},r._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},r._fireAnimationEventsAndCallScripts=function(e,t,n,r,a,i){var o=t.stateData.eventHandlers;o.length&&this._fireAnimationEvents(t,o,r,i),a===oT.UnStarted&&this._callAnimatorScriptOnEnter(n,e),a!==oT.Finished&&t.playState===oT.Finished?this._callAnimatorScriptOnExit(n,e):this._callAnimatorScriptOnUpdate(n,e)},r._deactivateTriggeredParameters=function(){for(var e=n._passedTriggerParameterNames,t=0,r=e.length;t<r;t++)this._parametersValueMap[e[t]]=!1},tG(n,[{key:"animatorController",get:function(){return this._animatorController},set:function(e){e!==this._animatorController&&(this._reset(),this._controllerUpdateFlag&&this._controllerUpdateFlag.destroy(),this._controllerUpdateFlag=e&&e._registerChangeFlag(),this._animatorController=e)}},{key:"layers",get:function(){var e;return null==(e=this._animatorController)?void 0:e._layers}},{key:"parameters",get:function(){var e;return null==(e=this._animatorController)?void 0:e._parameters}}]),n}(ru);oD._passedTriggerParameterNames=[],tX([tQ],oD.prototype,"speed",void 0),tX([tq],oD.prototype,"_controllerUpdateFlag",void 0),tX([tq],oD.prototype,"_updateMark",void 0),tX([tq],oD.prototype,"_animatorLayersData",void 0),tX([tq],oD.prototype,"_curveOwnerPool",void 0),tX([tq],oD.prototype,"_animationEventHandlerPool",void 0),tX([tq],oD.prototype,"_parametersValueMap",void 0),tX([tq],oD.prototype,"_tempAnimatorStateInfo",void 0),tX([tq],oD.prototype,"_controlledRenderers",void 0);var oB=/*#__PURE__*/function(){function e(){this._onNameChanged=null,this._isTrigger=!1}return tG(e,[{key:"name",get:function(){return this._name},set:function(e){if(this._name!==e){var t=this._name;this._name=e,null==this._onNameChanged||this._onNameChanged.call(this,t,e)}}}]),e}(),oI=/*#__PURE__*/function(e){function t(t){var n;return t&&((n=e.call(this,t)||this)._parameters=[],n._parametersMap={},n._layers=[],n._layersMap={},n._updateFlagManager=new nM),function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}tW(t,e);var n=t.prototype;return n.addParameter=function(e,t){return this._addParameter(e,t,!1)},n.addTriggerParameter=function(e){return this._addParameter(e,!1,!0)},n.removeParameter=function(e){var t=this._parametersMap[e],n=this._parameters.indexOf(t);-1!==n&&(this._parameters.splice(n,1),delete this._parametersMap[t.name])},n.clearParameters=function(){for(var e in this._parameters.length=0,this._parametersMap)delete this._parametersMap[e]},n.getParameter=function(e){return this._parametersMap[e]||null},n.findLayerByName=function(e){return this._layersMap[e]},n.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},n.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},n.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},n._registerChangeFlag=function(){return this._updateFlagManager.createFlag(rf)},n._addParameter=function(e,t,n){var r=this;if(void 0===n&&(n=!1),this._parametersMap[e])return console.warn("Parameter "+e+" already exists."),null;var a=new oB;return a.name=e,a.defaultValue=t,a._isTrigger=n,a._onNameChanged=function(e,t){delete r._parametersMap[e],r._parametersMap[t]=a},this._parametersMap[e]=a,this._parameters.push(a),a},tG(t,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),t}(t1),oO=/*#__PURE__*/function(){function e(){this.transitions=[],this.noExitTimeCount=0,this.needResetCurrentCheckIndex=!0,this._soloCount=0}var t=e.prototype;return t.get=function(e){return this.transitions[e]},t.add=function(e){var t;return tK(e,oN)?((t=new oM).hasExitTime=!1,t.destinationState=e):t=e,this._addTransition(t),t._collection=this,t.solo&&this._soloCount++,t},t.remove=function(e){var t=this.transitions,n=t.indexOf(e);-1!==n&&(t.splice(n,1),!e.hasExitTime&&this.noExitTimeCount--),e._collection=null,e.solo&&this._soloCount--},t.clear=function(){for(var e=this.transitions,t=0,n=e.length;t<n;t++)e[t]._collection=null;e.length=0,this._soloCount=0,this.noExitTimeCount=0},t.updateTransitionSolo=function(e){this._soloCount+=e?1:-1},t.updateTransitionsIndex=function(e,t){var n=this.transitions;n.splice(n.indexOf(e),1),this._addTransition(e)},t.updateCurrentCheckIndex=function(e){this.currentCheckIndex=e?Math.min(this.currentCheckIndex+1,this.count-this.noExitTimeCount-1):Math.max(this.currentCheckIndex-1,0)},t.resetCurrentCheckIndex=function(e){this.currentCheckIndex=e?0:this.count-this.noExitTimeCount-1,this.needResetCurrentCheckIndex=!1},t._addTransition=function(e){var t=this.transitions;if(!e.hasExitTime){t.unshift(e),this.noExitTimeCount++;return}var n=e.exitTime,r=t.length;if(n>=(r?t[r-1].exitTime:0))t.push(e);else{for(var a=r;--a>=0&&n<t[a].exitTime;);t.splice(a+1,0,e)}},tG(e,[{key:"isSoloMode",get:function(){return this._soloCount>0}},{key:"count",get:function(){return this.transitions.length}}]),e}(),oV=/*#__PURE__*/function(){function e(){this._destroyed=!1}var t=e.prototype;return t.onStateEnter=function(e,t,n){},t.onStateUpdate=function(e,t,n){},t.onStateExit=function(e,t,n){},t.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},e}(),oN=/*#__PURE__*/function(){function e(e){this.name=e,this.speed=1,this.wrapMode=ow.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new nM,this._transitionCollection=new oO,this._clipStartTime=0,this._clipEndTime=1,this._onClipChanged=this._onClipChanged.bind(this)}var t=e.prototype;return t.addTransition=function(e){return this._transitionCollection.add(e)},t.addExitTransition=function(e){void 0===e&&(e=1);var t=new oM;return t._isExit=!0,t.exitTime=e,this._transitionCollection.add(t)},t.removeTransition=function(e){this._transitionCollection.remove(e),e._isExit&&(e._isExit=!1)},t.addStateMachineScript=function(e){var t=new e;t._state=this;var n=oV.prototype;return t.onStateEnter!==n.onStateEnter&&this._onStateEnterScripts.push(t),t.onStateUpdate!==n.onStateUpdate&&this._onStateUpdateScripts.push(t),t.onStateExit!==n.onStateExit&&this._onStateExitScripts.push(t),t},t.clearTransitions=function(){this._transitionCollection.clear()},t._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},t._removeStateMachineScript=function(e){var t=oV.prototype;if(e.onStateEnter!==t.onStateEnter){var n=this._onStateEnterScripts.indexOf(e);-1!==n&&this._onStateEnterScripts.splice(n,1)}if(e.onStateUpdate!==t.onStateUpdate){var r=this._onStateUpdateScripts.indexOf(e);-1!==r&&this._onStateUpdateScripts.splice(r,1)}if(e.onStateExit!==t.onStateExit){var a=this._onStateExitScripts.indexOf(e);-1!==a&&this._onStateExitScripts.splice(a,1)}},t._onClipChanged=function(){this._updateFlagManager.dispatch()},t._getClipActualStartTime=function(){return this._clipStartTime*this.clip.length},t._getClipActualEndTime=function(){return this._clipEndTime*this.clip.length},tG(e,[{key:"transitions",get:function(){return this._transitionCollection.transitions}},{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._updateFlagManager.removeListener(this._onClipChanged),this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1),this._onClipChanged(),e&&e._updateFlagManager.addListener(this._onClipChanged))}},{key:"clipStartTime",get:function(){return this._clipStartTime},set:function(e){this._clipStartTime=Math.max(e,0)}},{key:"clipEndTime",get:function(){return this._clipEndTime},set:function(e){this._clipEndTime=Math.min(e,1)}}]),e}(),ok=/*#__PURE__*/function(){function e(){this.states=[],this._entryTransitionCollection=new oO,this._anyStateTransitionCollection=new oO,this._statesMap={}}var t=e.prototype;return t.addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new oN(e),this.states.push(t),this._statesMap[e]=t),t},t.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},t.findStateByName=function(e){return this._statesMap[e]},t.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},t.addEntryStateTransition=function(e){return this._entryTransitionCollection.add(e)},t.removeEntryStateTransition=function(e){this._entryTransitionCollection.remove(e)},t.addAnyStateTransition=function(e){return this._anyStateTransitionCollection.add(e)},t.removeAnyStateTransition=function(e){this._anyStateTransitionCollection.remove(e)},t.clearEntryStateTransitions=function(){this._entryTransitionCollection.clear()},t.clearAnyStateTransitions=function(){this._anyStateTransitionCollection.clear()},tG(e,[{key:"entryTransitions",get:function(){return this._entryTransitionCollection.transitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitionCollection.transitions}}]),e}(),oz=function(e){this.name=e,this.weight=1,this.blendingMode=oC.Override,this.stateMachine=new ok},oU=function(){},oG=function(){},oH=/*#__PURE__*/function(){function e(){this._pathMasks=[],this._pathMaskMap={}}var t=e.prototype;return t.addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var n=new oG;return n.path=e,n.active=!0,this._pathMasks.push(n),this._pathMaskMap[e]=n,n},t.removePathMask=function(e){for(var t=this._pathMasks,n=0,r=this._pathMasks.length;n<r;++n)if(t[n].path===e){t.splice(n,1),delete this._pathMaskMap[e];break}},t.getPathMask=function(e){return this._pathMaskMap[e]},t.setPathMaskActive=function(e,t,n){void 0===n&&(n=!1);var r=this._pathMaskMap[e];if(r&&(r.active=t),n)for(var a in this._pathMaskMap)a.startsWith(e)&&(this._pathMaskMap[a].active=t)},e.createByEntity=function(t){var n=new e;return n.addPathMask(""),e._addPathMaskWithChildren(n,t,""),n},e._addPathMaskWithChildren=function(t,n,r){for(var a=n.children,i=0,o=a.length;i<o;++i){var s=a[i],l=r?r+"/"+s.name:s.name;t.addPathMask(l),e._addPathMaskWithChildren(t,s,l)}},tG(e,[{key:"pathMasks",get:function(){return this._pathMasks}}]),e}(),oW=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,ro.find("skybox"))||this)._textureDecodeRGBM=!1,r._tintColor=new tO(1,1,1,1),r.renderState.rasterState.cullMode=nI.Off,r.renderState.depthState.compareFunction=nB.LessEqual,r.shaderData.setFloat(t._rotationProp,0),r.shaderData.setFloat(t._exposureProp,1),r.shaderData.setColor(t._tintColorProp,r._tintColor),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(t._decodeSkyRGBMMacro):this.shaderData.disableMacro(t._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(t._textureCubeProp)},set:function(e){this.shaderData.setTexture(t._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(t._rotationProp)},set:function(e){this.shaderData.setFloat(t._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(t._exposureProp)},set:function(e){this.shaderData.setFloat(t._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),t}(ao);oW._tintColorProp=nY.getByName("material_TintColor"),oW._textureCubeProp=nY.getByName("material_CubeTexture"),oW._rotationProp=nY.getByName("material_Rotation"),oW._exposureProp=nY.getByName("material_Exposure"),oW._decodeSkyRGBMMacro=nH.getByName("MATERIAL_IS_DECODE_SKY_RGBM");var oj=((eG={})[eG.None=0]="None",eG[eG.Simple=1]="Simple",eG[eG.HighQuality=2]="HighQuality",eG),oX=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,ro.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new tO(.5,.5,.5,1),n.groundTint=new tO(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=nI.Off,n.renderState.depthState.compareFunction=nB.LessEqual,n}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var n=this.shaderData;switch(e){case 2:n.disableMacro(t._sunSimpleMacro),n.enableMacro(t._sunHighQualityMacro);break;case 1:n.disableMacro(t._sunHighQualityMacro),n.enableMacro(t._sunSimpleMacro);break;case 0:n.disableMacro(t._sunHighQualityMacro),n.disableMacro(t._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(t._sunSizeProp)},set:function(e){this.shaderData.setFloat(t._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(t._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(t._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(t._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(t._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(t._skyTintProp)},set:function(e){this.shaderData.setColor(t._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(t._groundTintProp)},set:function(e){this.shaderData.setColor(t._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(t._exposureProp)},set:function(e){this.shaderData.setFloat(t._exposureProp,Math.min(Math.max(0,e),8))}}]),t}(ao);oX._sunSizeProp=nY.getByName("material_SunSize"),oX._sunSizeConvergenceProp=nY.getByName("material_SunSizeConvergence"),oX._atmosphereThicknessProp=nY.getByName("material_AtmosphereThickness"),oX._skyTintProp=nY.getByName("material_SkyTint"),oX._groundTintProp=nY.getByName("material_GroundTint"),oX._exposureProp=nY.getByName("material_Exposure"),oX._sunHighQualityMacro=nH.getByName("MATERIAL_SUN_HIGH_QUALITY"),oX._sunSimpleMacro=nH.getByName("MATERIAL_SUN_SIMPLE");var oK=((eH={})[eH.Billboard=0]="Billboard",eH[eH.StretchBillboard=1]="StretchBillboard",eH[eH.HorizontalBillboard=2]="HorizontalBillboard",eH[eH.VerticalBillboard=3]="VerticalBillboard",eH[eH.Mesh=4]="Mesh",eH[eH.None=5]="None",eH),oY=((eW={})[eW.Local=0]="Local",eW[eW.World=1]="World",eW),oq=((ej={})[ej.StopEmittingAndClear=0]="StopEmittingAndClear",ej[ej.StopEmitting=1]="StopEmitting",ej),oQ=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).velocityScale=0,r.lengthScale=2,r.pivot=new tT,r._generatorBounds=new tE,r._transformedBounds=new tE,r._onGeneratorParamsChanged=r._onGeneratorParamsChanged.bind(r),r.generator=new ss(r),r._currentRenderModeMacro=t._billboardModeMacro,r.shaderData.enableMacro(t._billboardModeMacro),r._supportInstancedArrays=r.engine._hardwareRenderer.canIUse(nZ.instancedArrays),r._onGeneratorParamsChanged(),r}tW(t,e);var n=t.prototype;return n._onEnable=function(){this.generator.main.playOnEnabled&&this.generator.play(!1)},n._onDisable=function(){this.generator.stop(!1,oq.StopEmittingAndClear)},n._prepareRender=function(t){this._supportInstancedArrays&&e.prototype._prepareRender.call(this,t)},n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._updateBounds=function(e){var t=this.generator;if(!t.isAlive){var n=this.entity.transform.worldPosition;e.min.copyFrom(n),e.max.copyFrom(n);return}t.main.simulationSpace===oY.Local?t._updateBoundsSimulationLocal(e):(this._isContainDirtyFlag(2)&&(t._generateTransformedBounds(),this._setDirtyFlagFalse(2)),t._updateBoundsSimulationWorld(e))},n._update=function(e){var n=this.generator;if(n._update(this.engine.time.deltaTime),n._firstActiveElement!==n._firstFreeElement){var r=this.shaderData;r.setFloat(t._lengthScale,this.lengthScale),r.setFloat(t._speedScale,this.velocityScale),r.setFloat(t._currentTime,this.generator._playTime),r.setVector3(t._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(r)}},n._render=function(e){var t=this.generator;t._primitive.instanceCount=t._getAliveParticleCount();var n=this.getMaterial();if(n){(n.destroyed||n.shader.destroyed)&&(n=this.engine._particleMagentaMaterial);var r=this._engine,a=r._renderElementPool.get();a.set(this.priority,this._distanceForSort);var i=r._subRenderElementPool.get();i.set(this,n,t._primitive,t._subPrimitive),a.addSubRenderElement(i),e.camera._renderPipeline.pushRenderElement(e,a)}},n._onDestroy=function(){var t=this._mesh;t&&(t.destroyed||this._addResourceReferCount(t,-1)),e.prototype._onDestroy.call(this),this.generator._destroy()},n._isContainDirtyFlag=function(e){return(this._dirtyUpdateFlag&e)!=0},n._setDirtyFlagFalse=function(e){this._dirtyUpdateFlag&=~e},n._onWorldVolumeChanged=function(){this._dirtyUpdateFlag|=rv.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|rv.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|rv.WorldVolume},tG(t,[{key:"renderMode",get:function(){return this._renderMode},set:function(e){if(this._renderMode!==e){var n=this._renderMode;this._renderMode=e;var r=null,a=this.shaderData;switch(e){case oK.Billboard:r=t._billboardModeMacro;break;case oK.StretchBillboard:r=t._stretchedBillboardModeMacro;break;case oK.HorizontalBillboard:case oK.VerticalBillboard:case oK.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==r&&(this._currentRenderModeMacro&&a.disableMacro(this._currentRenderModeMacro),r&&a.enableMacro(r),this._currentRenderModeMacro=r),n!==oK.Mesh!=(e===oK.Mesh)&&this.generator._reorganizeGeometryBuffers()}}},{key:"mesh",get:function(){return this._mesh},set:function(e){var t=this._mesh;t!==e&&(this._mesh=e,t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this.renderMode===oK.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),t}(e.Renderer);oQ._billboardModeMacro=nH.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),oQ._stretchedBillboardModeMacro=nH.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),oQ._horizontalBillboardModeMacro=nH.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),oQ._verticalBillboardModeMacro=nH.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),oQ._renderModeMeshMacro=nH.getByName("RENDERER_MODE_MESH"),oQ._pivotOffsetProperty=nY.getByName("renderer_PivotOffset"),oQ._lengthScale=nY.getByName("renderer_StretchedBillboardLengthScale"),oQ._speedScale=nY.getByName("renderer_StretchedBillboardSpeedScale"),oQ._currentTime=nY.getByName("renderer_CurrentTime"),tX([tJ],oQ.prototype,"generator",void 0),tX([tZ],oQ.prototype,"pivot",void 0),tX([tq],oQ.prototype,"_generatorBounds",void 0),tX([tq],oQ.prototype,"_transformedBounds",void 0),tX([tq],oQ.prototype,"_onGeneratorParamsChanged",null);var oZ=((eX={})[eX.TransformVolume=2]="TransformVolume",eX[eX.GeneratorVolume=4]="GeneratorVolume",eX),oJ=((eK={})[eK.Constant=0]="Constant",eK[eK.TwoConstants=1]="TwoConstants",eK[eK.Curve=2]="Curve",eK[eK.TwoCurves=3]="TwoCurves",eK),o$=((eY={})[eY.Constant=0]="Constant",eY[eY.TwoConstants=1]="TwoConstants",eY[eY.Gradient=2]="Gradient",eY[eY.TwoGradients=3]="TwoGradients",eY),o0=((eq={})[eq.Burst=0x23571a3e]="Burst",eq[eq.StartDelay=0x13371337]="StartDelay",eq[eq.StartColor=0x12460f3b]="StartColor",eq[eq.StartSize=0x6aed452e]="StartSize",eq[eq.StartRotation=0xdec4aea1]="StartRotation",eq[eq.randomizeRotationDirection=0x96aa4de3]="randomizeRotationDirection",eq[eq.StartLifetime=0x8d2c8431]="StartLifetime",eq[eq.StartSpeed=0xf3857f6f]="StartSpeed",eq[eq.VelocityOverLifetime=0xe0fbd834]="VelocityOverLifetime",eq[eq.ColorOverLifetime=0x13740583]="ColorOverLifetime",eq[eq.SizeOverLifetime=0x591bc05c]="SizeOverLifetime",eq[eq.RotationOverLifetime=0x40eb95e4]="RotationOverLifetime",eq[eq.TextureSheetAnimation=0xbc524e5]="TextureSheetAnimation",eq[eq.Shape=0xaf502044]="Shape",eq[eq.GravityModifier=0xa47b8c4d]="GravityModifier",eq),o1=/*#__PURE__*/function(){function e(e,t){if(void 0===e&&(e=null),void 0===t&&(t=null),this._colorKeys=[],this._alphaKeys=[],this._colorTypeArrayDirty=!1,this._alphaTypeArrayDirty=!1,e)for(var n=0,r=e.length;n<r;n++){var a=e[n];this.addColorKey(a)}if(t)for(var i=0,o=t.length;i<o;i++){var s=t[i];this.addAlphaKey(s)}}var t=e.prototype;return t.addColorKey=function(e,t){var n=this._colorKeys;if(4===n.length)throw Error("Gradient can only have 4 color keys");var r="number"==typeof e?new o2(e,t):e;r._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(n,r),this._colorTypeArrayDirty=!0},t.addAlphaKey=function(e,t){var n=this._alphaKeys;if(4===n.length)throw Error("Gradient can only have 4 alpha keys");var r="number"==typeof e?new o3(e,t):e;r._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(n,r),this._alphaTypeArrayDirty=!0},t.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},t.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},t.setKeys=function(e,t){for(var n=this._colorKeys,r=this._alphaKeys,a=0,i=n.length;a<i;a++)n[a]._onValueChanged=null;for(var o=0,s=r.length;o<s;o++)r[o]._onValueChanged=null;n.length=0,r.length=0;for(var l=0,c=e.length;l<c;l++)this._addKey(n,e[l]);for(var u=0,d=t.length;u<d;u++)this._addKey(r,t[u]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},t._getColorTypeArray=function(e){var t=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,r=0,a=Math.min(n.length,4);r<a;r++){var i=4*r,o=n[r];t[i]=o.time;var s=o.color;e===n2.Linear?(t[i+1]=tO.gammaToLinearSpace(s.r),t[i+2]=tO.gammaToLinearSpace(s.g),t[i+3]=tO.gammaToLinearSpace(s.b)):(t[i+1]=s.r,t[i+2]=s.g,t[i+3]=s.b)}this._colorTypeArrayDirty=!1}return t},t._getAlphaTypeArray=function(){var e=this._alphaTypeArray||(this._alphaTypeArray=new Float32Array(8));if(this._alphaTypeArrayDirty){for(var t=this._alphaKeys,n=0,r=Math.min(t.length,4);n<r;n++){var a=2*n,i=t[n];e[a]=i.time,e[a+1]=i.alpha}this._alphaTypeArrayDirty=!1}return e},t._addKey=function(e,t){var n=t.time,r=e.length;if(n>=(r?e[r-1].time:0))e.push(t);else{for(var a=r;--a>=0&&n<e[a].time;);e.splice(a+1,0,t)}},t._removeKey=function(e,t){e.splice(t,1)},t._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},t._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},tG(e,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),e}();tX([tJ],o1.prototype,"_colorKeys",void 0),tX([tJ],o1.prototype,"_alphaKeys",void 0),tX([tq],o1.prototype,"_colorTypeArray",void 0),tX([tq],o1.prototype,"_alphaTypeArray",void 0),tX([tq],o1.prototype,"_setColorTypeArrayDirty",null),tX([tq],o1.prototype,"_setAlphaTypeArrayDirty",null);var o2=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._color=new tO,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged}return tG(e,[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}}]),e}(),o3=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._time=e,this._alpha=t}return tG(e,[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"alpha",get:function(){return this._alpha},set:function(e){this._alpha=e,this._onValueChanged&&this._onValueChanged()}}]),e}(),o4=/*#__PURE__*/function(){function e(e,t){this.mode=o$.Constant,this.constantMin=new tO,this.constantMax=new tO,this.gradientMin=new o1,this.gradientMax=new o1,e.constructor===tO?t?(this.constantMin.copyFrom(e),this.constantMax.copyFrom(t),this.mode=o$.TwoConstants):(this.constant.copyFrom(e),this.mode=o$.Constant):t?(this.gradientMin=e,this.gradientMax=t,this.mode=o$.TwoGradients):(this.gradient=e,this.mode=o$.Gradient)}return e.prototype.evaluate=function(e,t,n){switch(this.mode){case o$.Constant:n.copyFrom(this.constant);break;case o$.TwoConstants:tO.lerp(this.constantMin,this.constantMax,t,n)}},tG(e,[{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"gradient",get:function(){return this.gradientMax},set:function(e){this.gradientMax=e}}]),e}();tX([tJ],o4.prototype,"constantMin",void 0),tX([tJ],o4.prototype,"constantMax",void 0),tX([tJ],o4.prototype,"gradientMin",void 0),tX([tJ],o4.prototype,"gradientMax",void 0);var o8=/*#__PURE__*/function(){function e(e){this._enabled=!1,this._generator=e}return e.prototype._enableMacro=function(e,t,n){return t!==n&&(t&&e.disableMacro(t),n&&e.enableMacro(n)),n},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),e}();tX([tq],o8.prototype,"_generator",void 0);var o5=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.color=new o4(new o1([new o2(0,new tO(1,1,1)),new o2(1,new tO(1,1,1))],[new o3(0,1),new o3(1,1)])),t._colorGradientRand=new tk(0,o0.ColorOverLifetime),t._gradientKeysCount=new tI(0,0,0,0),t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.color.mode;if(r!==o$.Gradient&&r!==o$.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var a=this.color,i=this._generator._renderer.engine.settings.colorSpace;e.setFloatArray(t._maxGradientColor,a.gradientMax._getColorTypeArray(i)),e.setFloatArray(t._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),r===o$.Gradient?n=t._gradientMacro:(e.setFloatArray(t._minGradientColor,a.gradientMin._getColorTypeArray(i)),e.setFloatArray(t._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),n=t._randomGradientsMacro);var o=a.gradientMin.colorKeys,s=a.gradientMin.alphaKeys,l=a.gradientMax.colorKeys,c=a.gradientMax.alphaKeys;this._gradientKeysCount.set(o.length?o[o.length-1].time:0,s.length?s[s.length-1].time:0,l.length?l[l.length-1].time:0,c.length?c[c.length-1].time:0),e.setVector4(t._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(e,this._colorMacro,n)},n._resetRandomSeed=function(e){this._colorGradientRand.reset(e,o0.ColorOverLifetime)},t}(o8);o5._gradientMacro=nH.getByName("RENDERER_COL_GRADIENT"),o5._randomGradientsMacro=nH.getByName("RENDERER_COL_RANDOM_GRADIENTS"),o5._minGradientColor=nY.getByName("renderer_COLMinGradientColor"),o5._minGradientAlpha=nY.getByName("renderer_COLMinGradientAlpha"),o5._maxGradientColor=nY.getByName("renderer_COLMaxGradientColor"),o5._maxGradientAlpha=nY.getByName("renderer_COLMaxGradientAlpha"),o5._gradientKeysCount=nY.getByName("renderer_COLGradientKeysMaxTime"),tX([tJ],o5.prototype,"color",void 0),tX([tq],o5.prototype,"_colorGradientRand",void 0),tX([tq],o5.prototype,"_gradientKeysCount",void 0),tX([tq],o5.prototype,"_colorMacro",void 0);var o9=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nM,this._mode=oJ.Constant,this._constantMin=0,this._constantMax=0,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager),"number"==typeof e?t?(this.constantMin=e,this.constantMax=t,this.mode=oJ.TwoConstants):(this.constant=e,this.mode=oJ.Constant):t?(this.curveMin=e,this.curveMax=t,this.mode=oJ.TwoCurves):(this.curve=e,this.mode=oJ.Curve)}var t=e.prototype;return t.evaluate=function(e,t){switch(this.mode){case oJ.Constant:return this.constant;case oJ.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*t}},t._getMax=function(){switch(this.mode){case oJ.Constant:return this.constantMax;case oJ.TwoConstants:return Math.max(this.constantMin,this.constantMax);case oJ.Curve:var e;return this._getMaxKeyValue(null==(e=this.curveMax)?void 0:e.keys);case oJ.TwoCurves:var t,n,r=this._getMaxKeyValue(null==(t=this.curveMin)?void 0:t.keys),a=this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys);return r>a?r:a}},t._getMinMax=function(e){switch(this.mode){case oJ.Constant:e.x=e.y=this.constantMax;break;case oJ.TwoConstants:e.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case oJ.Curve:var t,n;e.set(this._getMinKeyValue(null==(t=this.curveMax)?void 0:t.keys),this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys));break;case oJ.TwoCurves:var r,a,i,o,s=this._getMinKeyValue(null==(r=this.curveMax)?void 0:r.keys),l=this._getMinKeyValue(null==(a=this.curveMin)?void 0:a.keys),c=this._getMaxKeyValue(null==(i=this.curveMax)?void 0:i.keys),u=this._getMaxKeyValue(null==(o=this.curveMin)?void 0:o.keys);e.set(s<l?s:l,c>u?c:u)}},t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},t._getMaxKeyValue=function(e){var t,n=void 0,r=null!=(t=null==e?void 0:e.length)?t:0;if(r>0){n=e[0].value;for(var a=1;a<r;a++)n=Math.max(n,e[a].value)}return n},t._getMinKeyValue=function(e){var t,n=void 0,r=null!=(t=null==e?void 0:e.length)?t:0;if(r>0){n=e[0].value;for(var a=1;a<r;a++)n=Math.min(n,e[a].value)}return n},t._onCurveChange=function(e,t){var n=this._updateDispatch;null==e||e._unRegisterOnValueChanged(n),null==t||t._registerOnValueChanged(n),n()},tG(e,[{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._updateDispatch())}},{key:"constantMin",get:function(){return this._constantMin},set:function(e){e!==this._constantMin&&(this._constantMin=e,this._updateDispatch())}},{key:"constantMax",get:function(){return this._constantMax},set:function(e){e!==this._constantMax&&(this._constantMax=e,this._updateDispatch())}},{key:"curveMin",get:function(){return this._curveMin},set:function(e){var t=this._curveMin;e!==t&&(this._curveMin=e,this._onCurveChange(t,e))}},{key:"curveMax",get:function(){return this._curveMax},set:function(e){var t=this._curveMax;e!==t&&(this._curveMax=e,this._onCurveChange(t,e))}},{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"curve",get:function(){return this.curveMax},set:function(e){this.curveMax=e}}]),e}();tX([tq],o9.prototype,"_updateManager",void 0),tX([tJ],o9.prototype,"_curveMin",void 0),tX([tJ],o9.prototype,"_curveMax",void 0),tX([tq],o9.prototype,"_updateDispatch",void 0);var o6=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.rateOverTime=new o9(10),t.rateOverDistance=new o9(0),t._shapeRand=new tk(0,o0.Shape),t._frameRateTime=0,t._bursts=[],t._currentBurstIndex=0,t._burstRand=new tk(0,o0.Burst),t}tW(t,e);var n=t.prototype;return n.addBurst=function(e){for(var t=this._bursts,n=t.length;--n>=0&&e.time<t[n].time;);t.splice(n+1,0,e)},n.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},n.removeBurstByIndex=function(e){this._bursts.splice(e,1)},n.clearBurst=function(){this._bursts.length=0},n._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},n._resetRandomSeed=function(e){this._burstRand.reset(e,o0.Burst),this._shapeRand.reset(e,o0.Shape)},n._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},n._destroy=function(){var e;null==(e=this._shape)||e._unRegisterOnValueChanged(this._generator._renderer._onGeneratorParamsChanged)},n._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var n=this._generator,r=1/t,a=e-this._frameRateTime;a>=r;)a-=r,this._frameRateTime+=r,n._emit(this._frameRateTime,1)},n._emitByBurst=function(e,t){var n=this._generator.main,r=n.duration,a=Math.floor((t-e)/r);if(n.isLoop&&(a>0||t%r<e%r)){var i=Math.ceil(e/r)*r;this._emitBySubBurst(e,i,r),this._currentBurstIndex=0;for(var o=0;o<a;o++){var s=i;i+=r,this._emitBySubBurst(s,i,r),this._currentBurstIndex=0}this._emitBySubBurst(i,t,r)}else this._emitBySubBurst(e,t,r)},n._emitBySubBurst=function(e,t,n){for(var r=this._generator,a=this._burstRand,i=this.bursts,o=Math.floor(e/n)*n,s=e%n,l=s+(t-e),c=this._currentBurstIndex,u=i.length;c<u;c++){var d=i[c],h=d.time;if(h>l)break;if(h>=s){var _=d.count.evaluate(void 0,a.random());r._emit(o+h,_)}}this._currentBurstIndex=c},tG(t,[{key:"shape",get:function(){return this._shape},set:function(e){var t=this._shape;if(e!==t){this._shape=e;var n=this._generator._renderer;null==t||t._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==e||e._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()}}},{key:"bursts",get:function(){return this._bursts}}]),t}(o8);tX([tJ],o6.prototype,"rateOverTime",void 0),tX([tJ],o6.prototype,"rateOverDistance",void 0),tX([tJ],o6.prototype,"_shape",void 0),tX([tq],o6.prototype,"_shapeRand",void 0),tX([tJ],o6.prototype,"_bursts",void 0),tX([tq],o6.prototype,"_burstRand",void 0);var o7=((eQ={})[eQ.Hierarchy=0]="Hierarchy",eQ[eQ.Local=1]="Local",eQ[eQ.World=2]="World",eQ),se=/*#__PURE__*/function(){function e(e){this._tempVector40=new tI,this.duration=5,this.isLoop=!0,this.startDelay=new o9(0),this.startRotation3D=!1,this.startRotationX=new o9(0),this.startRotationY=new o9(0),this.startRotationZ=new o9(0),this.flipRotation=0,this.startColor=new o4(new tO(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=o7.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startDelayRand=new tk(0,o0.StartDelay),this._startSpeedRand=new tk(0,o0.StartSpeed),this._startLifeTimeRand=new tk(0,o0.StartLifetime),this._startColorRand=new tk(0,o0.StartColor),this._startSizeRand=new tk(0,o0.StartSize),this._startRotationRand=new tk(0,o0.StartRotation),this._gravityModifierRand=new tk(0,o0.GravityModifier),this._startSize3D=!1,this._simulationSpace=oY.Local,this._generator=e,this.startLifetime=new o9(5),this.startSpeed=new o9(5),this.startSizeX=new o9(1),this.startSizeY=new o9(1),this.startSizeZ=new o9(1),this.gravityModifier=new o9(0)}var t=e.prototype;return t._resetRandomSeed=function(e){this._startSpeedRand.reset(e,o0.StartSpeed),this._startLifeTimeRand.reset(e,o0.StartLifetime),this._startColorRand.reset(e,o0.StartColor),this._startSizeRand.reset(e,o0.StartSize),this._startRotationRand.reset(e,o0.StartRotation)},t._getPositionScale=function(){var e=this._generator._renderer.entity.transform;switch(this.scalingMode){case o7.Hierarchy:case o7.World:return e.lossyWorldScale;case o7.Local:return e.scale}},t._updateShaderData=function(t){var n=this._generator._renderer,r=n.entity.transform;switch(this.simulationSpace){case oY.Local:t.setVector3(e._worldPosition,r.worldPosition);var a=r.worldRotationQuaternion,i=this._tempVector40.copyFrom(a);t.setVector4(e._worldRotation,i);break;case oY.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case o7.Hierarchy:var o=r.lossyWorldScale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case o7.Local:var o=r.scale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case o7.World:t.setVector3(e._positionScale,r.lossyWorldScale),t.setVector3(e._sizeScale,e._vector3One)}t.setVector3(e._gravity,n.scene.physics.gravity),t.setInt(e._simulationSpace,this.simulationSpace),t.setFloat(e._startRotation3D,+this.startRotation3D),t.setInt(e._scaleMode,this.scalingMode)},t._cloneTo=function(e){e.maxParticles=this.maxParticles,e._simulationSpace===oY.World&&e._generator._generateTransformedBounds()},t._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(e,[{key:"startLifetime",get:function(){return this._startLifetime},set:function(e){var t=this._startLifetime;e!==t&&(this._startLifetime=e,this._onCompositeCurveChange(t,e))}},{key:"startSpeed",get:function(){return this._startSpeed},set:function(e){var t=this._startSpeed;e!==t&&(this._startSpeed=e,this._onCompositeCurveChange(t,e))}},{key:"startSize3D",get:function(){return this._startSize3D},set:function(e){e!==this._startSize3D&&(this._startSize3D=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"startSizeX",get:function(){return this._startSizeX},set:function(e){var t=this._startSizeX;e!==t&&(this._startSizeX=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeY",get:function(){return this._startSizeY},set:function(e){var t=this._startSizeY;e!==t&&(this._startSizeY=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeZ",get:function(){return this._startSizeZ},set:function(e){var t=this._startSizeZ;e!==t&&(this._startSizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"gravityModifier",get:function(){return this._gravityModifier},set:function(e){var t=this._gravityModifier;e!==t&&(this._gravityModifier=e,this._onCompositeCurveChange(t,e))}},{key:"simulationSpace",get:function(){return this._simulationSpace},set:function(e){if(e!==this._simulationSpace){this._simulationSpace=e;var t=this._generator;t._renderer._onTransformChanged(rm.WorldMatrix),e===oY.Local&&t._freeBoundsArray()}}},{key:"maxParticles",get:function(){return this._maxParticleBuffer-1},set:function(e){this._maxParticleBuffer=e+1}},{key:"startSize",get:function(){return this.startSizeX},set:function(e){this.startSizeX=e}}]),e}();se._vector3One=new tT(1,1,1),se._positionScale=nY.getByName("renderer_PositionScale"),se._sizeScale=nY.getByName("renderer_SizeScale"),se._worldPosition=nY.getByName("renderer_WorldPosition"),se._worldRotation=nY.getByName("renderer_WorldRotation"),se._gravity=nY.getByName("renderer_Gravity"),se._simulationSpace=nY.getByName("renderer_SimulationSpace"),se._startRotation3D=nY.getByName("renderer_ThreeDStartRotation"),se._scaleMode=nY.getByName("renderer_ScalingMode"),tX([tJ],se.prototype,"startDelay",void 0),tX([tJ],se.prototype,"startRotationX",void 0),tX([tJ],se.prototype,"startRotationY",void 0),tX([tJ],se.prototype,"startRotationZ",void 0),tX([tJ],se.prototype,"startColor",void 0),tX([tq],se.prototype,"_maxParticleBuffer",void 0),tX([tq],se.prototype,"_startDelayRand",void 0),tX([tq],se.prototype,"_startSpeedRand",void 0),tX([tq],se.prototype,"_startLifeTimeRand",void 0),tX([tq],se.prototype,"_startColorRand",void 0),tX([tq],se.prototype,"_startSizeRand",void 0),tX([tq],se.prototype,"_startRotationRand",void 0),tX([tq],se.prototype,"_gravityModifierRand",void 0),tX([tJ],se.prototype,"_startLifetime",void 0),tX([tJ],se.prototype,"_startSpeed",void 0),tX([tJ],se.prototype,"_startSizeX",void 0),tX([tJ],se.prototype,"_startSizeY",void 0),tX([tJ],se.prototype,"_startSizeZ",void 0),tX([tJ],se.prototype,"_gravityModifier",void 0),tX([tq],se.prototype,"_generator",void 0);var st=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new o9(0),t.rotationY=new o9(0),t.rotationZ=new o9(45),t._rotationRand=new tk(0,o0.RotationOverLifetime),t._rotationMinConstant=new tT,t._rotationMaxConstant=new tT,t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,a=null;if(this.enabled){var i=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?i.mode===oJ.TwoCurves&&o.mode===oJ.TwoCurves&&s.mode===oJ.TwoCurves:s.mode===oJ.TwoCurves;if(c||l?i.mode===oJ.Curve&&o.mode===oJ.Curve&&s.mode===oJ.Curve:s.mode===oJ.Curve)e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveXProperty,i.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveXProperty,i.curveMin._getTypeArray()),e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray())),a=t._isRandomTwoMacro),r=t._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(tC.degreeToRadian(i.constantMax),tC.degreeToRadian(o.constantMax),tC.degreeToRadian(s.constantMax)),e.setVector3(t._maxConstantProperty,u),l?i.mode===oJ.TwoConstants&&o.mode===oJ.TwoConstants&&s.mode===oJ.TwoConstants:s.mode===oJ.TwoConstants){var d=this._rotationMinConstant;d.set(tC.degreeToRadian(i.constantMin),tC.degreeToRadian(o.constantMin),tC.degreeToRadian(s.constantMin)),e.setVector3(t._minConstantProperty,d),a=t._isRandomTwoMacro}r=t._constantModeMacro}l&&(n=t._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,n),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,a)},n._resetRandomSeed=function(e){this._rotationRand.reset(e,o0.RotationOverLifetime)},t}(o8);st._constantModeMacro=nH.getByName("RENDERER_ROL_CONSTANT_MODE"),st._curveModeMacro=nH.getByName("RENDERER_ROL_CURVE_MODE"),st._isSeparateMacro=nH.getByName("RENDERER_ROL_IS_SEPARATE"),st._isRandomTwoMacro=nH.getByName("RENDERER_ROL_IS_RANDOM_TWO"),st._minConstantProperty=nY.getByName("renderer_ROLMinConst"),st._minCurveXProperty=nY.getByName("renderer_ROLMinCurveX"),st._minCurveYProperty=nY.getByName("renderer_ROLMinCurveY"),st._minCurveZProperty=nY.getByName("renderer_ROLMinCurveZ"),st._maxConstantProperty=nY.getByName("renderer_ROLMaxConst"),st._maxCurveXProperty=nY.getByName("renderer_ROLMaxCurveX"),st._maxCurveYProperty=nY.getByName("renderer_ROLMaxCurveY"),st._maxCurveZProperty=nY.getByName("renderer_ROLMaxCurveZ"),tX([tJ],st.prototype,"rotationX",void 0),tX([tJ],st.prototype,"rotationY",void 0),tX([tJ],st.prototype,"rotationZ",void 0),tX([tq],st.prototype,"_rotationRand",void 0),tX([tq],st.prototype,"_rotationMinConstant",void 0),tX([tq],st.prototype,"_rotationMaxConstant",void 0),tX([tq],st.prototype,"_enableSeparateMacro",void 0),tX([tq],st.prototype,"_isCurveMacro",void 0),tX([tq],st.prototype,"_isRandomTwoMacro",void 0);var sn=/*#__PURE__*/function(){function e(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._updateManager=new nM,this._keys=[],this._typeArrayDirty=!1,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager);for(var r=0,a=t.length;r<a;r++){var i=t[r];this.addKey(i)}}var t=e.prototype;return t.addKey=function(e,t){var n=this._keys;if(4===n.length)throw Error("Curve can only have 4 keys");var r="number"==typeof e?new sr(e,t):e;this._addKey(n,r),r._registerOnValueChanged(this._updateDispatch),this._updateDispatch(),this._typeArrayDirty=!0},t.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0,this._keys[e]._unRegisterOnValueChanged(this._updateDispatch),this._updateDispatch()},t.setKeys=function(e){this._keys.length=0;for(var t=0,n=e.length;t<n;t++)this.addKey(e[t]);this._typeArrayDirty=!0},t._getTypeArray=function(){var e=this._typeArray||(this._typeArray=new Float32Array(8));if(this._typeArrayDirty){for(var t=this._keys,n=0,r=Math.min(t.length,4);n<r;n++){var a=2*n,i=t[n];e[a]=i.time,e[a+1]=i.value}this._typeArrayDirty=!1}return e},t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},t._addKey=function(e,t){var n=e.length,r=t.time;if(r>=(n?e[n-1].time:0))e.push(t);else{for(var a=n;--a>=0&&r<e[a].time;);e.splice(a+1,0,t)}},tG(e,[{key:"keys",get:function(){return this._keys}}]),e}();tX([tq],sn.prototype,"_updateManager",void 0),tX([tJ],sn.prototype,"_keys",void 0),tX([tq],sn.prototype,"_typeArray",void 0),tX([tq],sn.prototype,"_updateDispatch",void 0);var sr=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nM,this._time=e,this._value=t}var t=e.prototype;return t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},tG(e,[{key:"time",get:function(){return this._time},set:function(e){e!==this._time&&(this._time=e,this._updateManager.dispatch())}},{key:"value",get:function(){return this._value},set:function(e){e!==this._value&&(this._value=e,this._updateManager.dispatch())}}]),e}();tX([tq],sr.prototype,"_updateManager",void 0);var sa=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._separateAxes=!1,n.sizeX=new o9(new sn(new sr(0,0),new sr(1,1))),n.sizeY=new o9(new sn(new sr(0,0),new sr(1,1))),n.sizeZ=new o9(new sn(new sr(0,0),new sr(1,1))),n}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,a=null;if(this.enabled){var i=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?i.mode===oJ.TwoCurves&&o.mode===oJ.TwoCurves&&s.mode===oJ.TwoCurves:i.mode===oJ.TwoCurves;(c||l?i.mode===oJ.Curve&&o.mode===oJ.Curve&&s.mode===oJ.Curve:i.mode===oJ.Curve)&&(e.setFloatArray(t._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveXProperty,i.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray()),e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray())),a=t._isRandomTwoMacro),r=t._curveModeMacro),l&&(n=t._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,n),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,a)},n._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(t,[{key:"separateAxes",get:function(){return this._separateAxes},set:function(e){e!==this._separateAxes&&(this._separateAxes=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"sizeX",get:function(){return this._sizeX},set:function(e){var t=this._sizeX;e!==t&&(this._sizeX=e,this._onCompositeCurveChange(t,e))}},{key:"sizeY",get:function(){return this._sizeY},set:function(e){var t=this._sizeY;e!==t&&(this._sizeY=e,this._onCompositeCurveChange(t,e))}},{key:"sizeZ",get:function(){return this._sizeZ},set:function(e){var t=this._sizeZ;e!==t&&(this._sizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),t}(o8);sa._curveModeMacro=nH.getByName("RENDERER_SOL_CURVE_MODE"),sa._isSeparateMacro=nH.getByName("RENDERER_SOL_IS_SEPARATE"),sa._isRandomTwoMacro=nH.getByName("RENDERER_SOL_IS_RANDOM_TWO"),sa._minCurveXProperty=nY.getByName("renderer_SOLMinCurveX"),sa._minCurveYProperty=nY.getByName("renderer_SOLMinCurveY"),sa._minCurveZProperty=nY.getByName("renderer_SOLMinCurveZ"),sa._maxCurveXProperty=nY.getByName("renderer_SOLMaxCurveX"),sa._maxCurveYProperty=nY.getByName("renderer_SOLMaxCurveY"),sa._maxCurveZProperty=nY.getByName("renderer_SOLMaxCurveZ"),tX([tJ],sa.prototype,"_sizeX",void 0),tX([tJ],sa.prototype,"_sizeY",void 0),tX([tJ],sa.prototype,"_sizeZ",void 0),tX([tq],sa.prototype,"_enableSeparateMacro",void 0),tX([tq],sa.prototype,"_isCurveMacro",void 0),tX([tq],sa.prototype,"_isRandomTwoMacro",void 0);var si=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.frameOverTime=new o9(new sn(new sr(0,0),new sr(1,1))),t.type=0,t.cycleCount=1,t._tillingInfo=new tT(1,1,1),t._frameOverTimeRand=new tk(0,o0.TextureSheetAnimation),t._tiling=new tB(1,1),t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.frameOverTime.mode;if(r===oJ.Curve||r===oJ.TwoCurves){var a=this.frameOverTime;e.setFloatArray(t._frameMaxCurveProperty,a.curveMax._getTypeArray()),r===oJ.Curve?n=t._frameCurveMacro:(e.setFloatArray(t._frameMinCurveProperty,a.curveMin._getTypeArray()),n=t._frameRandomCurvesMacro),e.setFloat(t._cycleCountProperty,this.cycleCount),e.setVector3(t._tillingParamsProperty,this._tillingInfo)}}this._frameCurveMacro=this._enableMacro(e,this._frameCurveMacro,n)},n._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,o0.TextureSheetAnimation)},tG(t,[{key:"tiling",get:function(){return this._tiling},set:function(e){this._tiling=e,this._tillingInfo.set(1/e.x,1/e.y,e.x*e.y)}}]),t}(o8);si._frameCurveMacro=nH.getByName("RENDERER_TSA_FRAME_CURVE"),si._frameRandomCurvesMacro=nH.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),si._frameMinCurveProperty=nY.getByName("renderer_TSAFrameMinCurve"),si._frameMaxCurveProperty=nY.getByName("renderer_TSAFrameMaxCurve"),si._cycleCountProperty=nY.getByName("renderer_TSACycles"),si._tillingParamsProperty=nY.getByName("renderer_TSATillingParams"),tX([tJ],si.prototype,"frameOverTime",void 0),tX([tZ],si.prototype,"_tillingInfo",void 0),tX([tq],si.prototype,"_frameOverTimeRand",void 0),tX([tJ],si.prototype,"_tiling",void 0),tX([tq],si.prototype,"_frameCurveMacro",void 0);var so=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._velocityRand=new tk(0,o0.VelocityOverLifetime),n._velocityMinConstant=new tT,n._velocityMaxConstant=new tT,n._space=oY.Local,n.velocityX=new o9(0),n.velocityY=new o9(0),n.velocityZ=new o9(0),n}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.velocityX,a=this.velocityY,i=this.velocityZ,o=r.mode===oJ.TwoCurves&&a.mode===oJ.TwoCurves&&i.mode===oJ.TwoCurves;if(o||r.mode===oJ.Curve&&a.mode===oJ.Curve&&i.mode===oJ.Curve)e.setFloatArray(t._maxGradientXProperty,r.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientYProperty,a.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientZProperty,i.curveMax._getTypeArray()),o?(e.setFloatArray(t._minGradientXProperty,r.curveMin._getTypeArray()),e.setFloatArray(t._minGradientYProperty,a.curveMin._getTypeArray()),e.setFloatArray(t._minGradientZProperty,i.curveMin._getTypeArray()),n=t._randomCurveMacro):n=t._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(r.constantMax,a.constantMax,i.constantMax),e.setVector3(t._maxConstantProperty,s),r.mode===oJ.TwoConstants&&a.mode===oJ.TwoConstants&&i.mode===oJ.TwoConstants){var l=this._velocityMinConstant;l.set(r.constantMin,a.constantMin,i.constantMin),e.setVector3(t._minConstantProperty,l),n=t._randomConstantMacro}else n=t._constantMacro}e.setInt(t._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(e,this._velocityMacro,n)},n._resetRandomSeed=function(e){this._velocityRand.reset(e,o0.VelocityOverLifetime)},n._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(t,[{key:"velocityX",get:function(){return this._velocityX},set:function(e){var t=this._velocityX;e!==t&&(this._velocityX=e,this._onCompositeCurveChange(t,e))}},{key:"velocityY",get:function(){return this._velocityY},set:function(e){var t=this._velocityY;e!==t&&(this._velocityY=e,this._onCompositeCurveChange(t,e))}},{key:"velocityZ",get:function(){return this._velocityZ},set:function(e){var t=this._velocityZ;e!==t&&(this._velocityZ=e,this._onCompositeCurveChange(t,e))}},{key:"space",get:function(){return this._space},set:function(e){e!==this._space&&(this._space=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._generator._renderer._onGeneratorParamsChanged())}}]),t}(o8);so._constantMacro=nH.getByName("RENDERER_VOL_CONSTANT"),so._curveMacro=nH.getByName("RENDERER_VOL_CURVE"),so._randomConstantMacro=nH.getByName("RENDERER_VOL_RANDOM_CONSTANT"),so._randomCurveMacro=nH.getByName("RENDERER_VOL_RANDOM_CURVE"),so._minConstantProperty=nY.getByName("renderer_VOLMinConst"),so._maxConstantProperty=nY.getByName("renderer_VOLMaxConst"),so._minGradientXProperty=nY.getByName("renderer_VOLMinGradientX"),so._minGradientYProperty=nY.getByName("renderer_VOLMinGradientY"),so._minGradientZProperty=nY.getByName("renderer_VOLMinGradientZ"),so._maxGradientXProperty=nY.getByName("renderer_VOLMaxGradientX"),so._maxGradientYProperty=nY.getByName("renderer_VOLMaxGradientY"),so._maxGradientZProperty=nY.getByName("renderer_VOLMaxGradientZ"),so._spaceProperty=nY.getByName("renderer_VOLSpace"),tX([tq],so.prototype,"_velocityRand",void 0),tX([tq],so.prototype,"_velocityMinConstant",void 0),tX([tq],so.prototype,"_velocityMaxConstant",void 0),tX([tq],so.prototype,"_velocityMacro",void 0),tX([tJ],so.prototype,"_velocityX",void 0),tX([tJ],so.prototype,"_velocityY",void 0),tX([tJ],so.prototype,"_velocityZ",void 0);var ss=/*#__PURE__*/function(){function e(t){this.useAutoRandomSeed=!0,this.emission=new o6(this),this.rotationOverLifetime=new st(this),this.colorOverLifetime=new o5(this),this.textureSheetAnimation=new si(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new ay(0,0,ar.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0,this._playStartDelay=0,this._renderer=t,new av().start=0,this._primitive=new ax(t.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,e._particleIncreaseCount),this.main=new se(this),this.velocityOverLifetime=new so(this),this.sizeOverLifetime=new sa(this),this.emission.enabled=!0}var t=e.prototype;return t.play=function(t){if(void 0===t&&(t=!0),t)for(var n=this._renderer.entity.getComponentsIncludeChildren(oQ,e._tempParticleRenderers),r=0,a=n.length;r<a;r++)n[r].generator.play(!1);else this._isPlaying=!0,this.useAutoRandomSeed&&this._resetGlobalRandSeed(Math.floor(0xffffffff*Math.random())),this._playStartDelay=this.main.startDelay.evaluate(void 0,this.main._startDelayRand.random())},t.stop=function(t,n){if(void 0===t&&(t=!0),void 0===n&&(n=oq.StopEmitting),t)for(var r=this._renderer.entity.getComponentsIncludeChildren(oQ,e._tempParticleRenderers),a=0,i=r.length;a<i;a++)r[a].generator.stop(!1,n);else if(this._isPlaying=!1,n===oq.StopEmittingAndClear){var o=this._firstFreeElement;this._firstRetiredElement=o,this._firstActiveElement=o,this._firstNewElement=o,this._playTime=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox,this.emission._reset()}},t.emit=function(e){this._emit(this._playTime,e)},t._emit=function(t,n){if(this.emission.enabled&&!(this.main._maxParticleBuffer<this._currentParticleCount))for(var r=e._tempVector30,a=e._tempVector31,i=this._renderer.entity.transform,o=this.emission.shape,s=0;s<n;s++){if(null==o?void 0:o.enabled){o._generatePositionAndDirection(this.emission._shapeRand,t,r,a);var l=this.main._getPositionScale();r.multiply(l),a.normalize().multiply(l)}else r.set(0,0,0),a.set(0,0,-1);this._addNewParticle(r,a,i,t)}},t._update=function(e){var t=this.isAlive,n=this.main,r=this.emission,a=n.duration,i=this._playTime,o=e*n.simulationSpeed;if(this._playStartDelay>0){var s=this._playStartDelay-=o;if(!(s<0))return;this._playTime-=s,this._playStartDelay=0}if(this._playTime+=o,this._retireActiveParticles(),this._freeRetiredParticles(),n.simulationSpace===oY.World&&this._retireTransformedBounds(),r.enabled&&this._isPlaying&&(this._currentParticleCount>n._maxParticleBuffer&&this._getNotRetiredParticleCount()<n._maxParticleBuffer&&this._resizeInstanceBuffer(!1),r._emit(i,this._playTime),!n.isLoop&&this._playTime>a&&(this._isPlaying=!1)),this.isAlive)n.simulationSpace===oY.World&&this._generateTransformedBounds();else{var l=Math.min(r._frameRateTime,Math.floor(this._playTime/a)*a);this._playTime-=l,r._frameRateTime-=l}this.isAlive!==t&&this._renderer._onWorldVolumeChanged(),(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},t._reorganizeGeometryBuffers=function(){var e=this._renderer,t=e.engine._particleBufferUtils,n=this._primitive,r=this._vertexBufferBindings;if(n.clearVertexElements(),r.length=0,e.renderMode===oK.Mesh){var a=e.mesh;if(!a)return;var i=a.getVertexElement(aR.Position),o=a.getVertexElement(aR.Color),s=a.getVertexElement(aR.UV),l=i?a.vertexBufferBindings[i.bindingIndex]:null,c=o?a.vertexBufferBindings[o.bindingIndex]:null,u=s?a.vertexBufferBindings[s.bindingIndex]:null;if(l){var d=this._addVertexBufferBindingsFilterDuplicate(l,r);n.addVertexElement(new at(aR.Position,i.offset,i.format,d))}if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,r);n.addVertexElement(new at(aR.Color,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,r);n.addVertexElement(new at(aR.UV,s.offset,s.format,_))}var f=a._primitive.indexBufferBinding;n.setIndexBufferBinding(f),this._subPrimitive.count=f.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(t.billboardVertexElement),r.push(t.billboardVertexBufferBinding),n.setIndexBufferBinding(t.billboardIndexBufferBinding),this._subPrimitive.count=iW.billboardIndexCount;n.setVertexBufferBindings(r);for(var p=t.instanceVertexElements,m=r.length,g=0,v=p.length;g<v;g++){var y=p[g];n.addVertexElement(new at(y.attribute,y.offset,y.format,m,y.instanceStepRate))}},t._resizeInstanceBuffer=function(e,t){null==(u=this._instanceVertexBufferBinding)||u.buffer.destroy();var n=iW.instanceVertexStride,r=e?this._currentParticleCount+t:this.main._maxParticleBuffer,a=n*r,i=new r9(this._renderer.engine,an.VertexBuffer,a,r8.Dynamic,!1);i.isGCIgnored=!0;var o=this._primitive.vertexBufferBindings,s=new aC(i,n),l=new Float32Array(a/4),c=this._instanceVertices;if(c){var u,d,h,_=iW.instanceVertexFloatStride,f=this._firstFreeElement,p=this._firstRetiredElement;if(e){l.set(new Float32Array(c.buffer,0,f*_));var m=f+1;l.set(new Float32Array(c.buffer,m*_*4),(m+t)*_),this._firstNewElement>f&&(this._firstNewElement+=t),this._firstActiveElement>f&&(this._firstActiveElement+=t),p>f&&(this._firstRetiredElement+=t)}else p<=f?(d=f-p,h=0,this._firstFreeElement-=p,this._firstNewElement-=p,this._firstActiveElement-=p,this._firstRetiredElement=0):(d=this._currentParticleCount-p,h=f,this._firstNewElement>f&&(this._firstNewElement-=f),this._firstActiveElement>f&&(this._firstActiveElement-=f),p>f&&(this._firstRetiredElement-=f)),l.set(new Float32Array(c.buffer,p*_*4,d*_),h*_);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(c?o.length-1:o.length,s),this._instanceVertices=l,this._instanceVertexBufferBinding=s,this._currentParticleCount=r},t._updateShaderData=function(e){this.main._updateShaderData(e),this.velocityOverLifetime._updateShaderData(e),this.textureSheetAnimation._updateShaderData(e),this.sizeOverLifetime._updateShaderData(e),this.rotationOverLifetime._updateShaderData(e),this.colorOverLifetime._updateShaderData(e)},t._resetGlobalRandSeed=function(e){this._randomSeed=e,this.main._resetRandomSeed(e),this.emission._resetRandomSeed(e),this.textureSheetAnimation._resetRandomSeed(e),this.velocityOverLifetime._resetRandomSeed(e),this.rotationOverLifetime._resetRandomSeed(e),this.colorOverLifetime._resetRandomSeed(e)},t._getAliveParticleCount=function(){if(this._firstActiveElement<=this._firstFreeElement)return this._firstFreeElement-this._firstActiveElement;var e=this._currentParticleCount-this._firstActiveElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},t._getNotRetiredParticleCount=function(){if(this._firstRetiredElement<=this._firstFreeElement)return this._firstFreeElement-this._firstRetiredElement;var e=this._currentParticleCount-this._firstRetiredElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},t._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy(),this.emission._destroy()},t._updateBoundsSimulationLocal=function(e){var t=this._renderer,n=this.main.startLifetime._getMax(),r=t._generatorBounds,a=t._transformedBounds;t._isContainDirtyFlag(oZ.GeneratorVolume)&&(this._calculateGeneratorBounds(n,r),t._setDirtyFlagFalse(oZ.GeneratorVolume)),t._isContainDirtyFlag(oZ.TransformVolume)&&(this._calculateTransformedBounds(n,r,a),t._setDirtyFlagFalse(oZ.TransformVolume)),this._addGravityToBounds(n,a,e)},t._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,n=this._firstActiveTransformedBoundingBox,r=this._firstFreeTransformedBoundingBox,a=n*iW.boundsFloatStride;if(e.min.copyFromArray(t,a),e.max.copyFromArray(t,a+3),n<r)for(var i=n+1;i<r;i++)this._mergeTransformedBounds(i,e);else{for(var o=n+1,s=this._transformedBoundsCount;o<s;o++)this._mergeTransformedBounds(o,e);if(r>0)for(var l=0;l<r;l++)this._mergeTransformedBounds(l,e)}var c=this.main.startLifetime._getMax();this._addGravityToBounds(c,e,e)},t._freeBoundsArray=function(){this._transformedBoundsArray=null,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0},t._generateTransformedBounds=function(){var e=this._renderer,t=this.main.startLifetime._getMax(),n=e._generatorBounds;e._isContainDirtyFlag(oZ.GeneratorVolume)&&(this._calculateGeneratorBounds(t,n),e._setDirtyFlagFalse(oZ.GeneratorVolume));var r=iW.boundsFloatStride,a=iW.boundsTimeOffset,i=iW.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(oZ.TransformVolume)){var s=o+1;s>=this._transformedBoundsCount&&(s=0),s===this._firstActiveTransformedBoundingBox&&(this._resizeTransformedBoundsArray(),s=o+1);var l=e._transformedBounds;this._calculateTransformedBounds(t,n,l);var c=o*r,u=this._transformedBoundsArray;l.min.copyToArray(u,c),l.max.copyToArray(u,c+3),u[c+a]=this._playTime,u[c+i]=t,this._firstFreeTransformedBoundingBox=s,e._setDirtyFlagFalse(oZ.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*iW.boundsFloatStride+a]=this._playTime}},t._addNewParticle=function(t,n,r,a){var i,o,s=this._firstFreeElement,l=s+1;l>=this._currentParticleCount&&(l=0);var c=this.main;if(l===this._firstRetiredElement){var u=Math.min(e._particleIncreaseCount,c._maxParticleBuffer-this._currentParticleCount);if(0===u)return;this._resizeInstanceBuffer(!0,u),l=s+1}c.simulationSpace===oY.World&&(i=r.worldPosition,o=r.worldRotationQuaternion);var d=c.startSpeed.evaluate(void 0,c._startSpeedRand.random()),h=this._instanceVertices,_=s*iW.instanceVertexFloatStride;h[_]=t.x,h[_+1]=t.y,h[_+2]=t.z,h[_+iW.startLifeTimeOffset]=c.startLifetime.evaluate(void 0,c._startLifeTimeRand.random()),h[_+4]=n.x,h[_+5]=n.y,h[_+6]=n.z,h[_+iW.timeOffset]=a;var f=e._tempColor0;c.startColor.evaluate(void 0,c._startColorRand.random(),f),this._renderer.engine.settings.colorSpace===n2.Linear&&f.toLinear(f),h[_+8]=f.r,h[_+9]=f.g,h[_+10]=f.b,h[_+11]=f.a;var p=c._startSizeRand;if(c.startSize3D)h[_+12]=c.startSizeX.evaluate(void 0,p.random()),h[_+13]=c.startSizeY.evaluate(void 0,p.random()),h[_+14]=c.startSizeZ.evaluate(void 0,p.random());else{var m=c.startSize.evaluate(void 0,p.random());h[_+12]=m,h[_+13]=m,h[_+14]=m}var g=c._startRotationRand;switch(c.startRotation3D?(h[_+15]=tC.degreeToRadian(c.startRotationX.evaluate(void 0,g.random())),h[_+16]=tC.degreeToRadian(c.startRotationY.evaluate(void 0,g.random())),h[_+17]=tC.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random()))):h[_+15]=tC.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random())),h[_+18]=d,c.gravityModifier.mode){case oJ.Constant:h[_+19]=c.gravityModifier.constant;break;case oJ.TwoConstants:h[_+19]=c.gravityModifier.evaluate(void 0,c._gravityModifierRand.random())}var v=this.colorOverLifetime;v.enabled&&v.color.mode===o$.TwoGradients&&(h[_+20]=v._colorGradientRand.random());var y=this.rotationOverLifetime;y.enabled&&y.rotationZ.mode===oJ.TwoConstants&&(h[_+22]=y._rotationRand.random());var x=this.textureSheetAnimation;x.enabled&&x.frameOverTime.mode===oJ.TwoCurves&&(h[_+23]=x._frameOverTimeRand.random());var b=this.velocityOverLifetime;if(b.enabled&&b.velocityX.mode===oJ.TwoConstants&&b.velocityY.mode===oJ.TwoConstants&&b.velocityZ.mode===oJ.TwoConstants){var S=b._velocityRand;h[_+24]=S.random(),h[_+25]=S.random(),h[_+26]=S.random()}if(this.main.simulationSpace===oY.World&&(h[_+27]=i.x,h[_+28]=i.y,h[_+29]=i.z,h[_+30]=o.x,h[_+31]=o.y,h[_+32]=o.z,h[_+33]=o.w),x.enabled){var C=x.frameOverTime,T=x._tillingInfo,A=T.x,E=T.y,R=T.z,M=0;(C.mode===oJ.Constant||C.mode===oJ.TwoConstants)&&(M=Math.floor(C.evaluate(void 0,x._frameOverTimeRand.random())*R)*A);var w=Math.floor(M);h[_+iW.simulationUVOffset]=A,h[_+35]=E,h[_+36]=M-w,h[_+37]=w*E}else h[_+iW.simulationUVOffset]=1,h[_+35]=1,h[_+36]=0,h[_+37]=0;this._firstFreeElement=l},t._retireActiveParticles=function(){for(var e=this._renderer.engine.time.frameCount,t=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var n=this._firstActiveElement*iW.instanceVertexFloatStride,r=n+iW.timeOffset;if(Math.fround(this._playTime-t[r])<t[n+iW.startLifeTimeOffset])break;t[r]=e,++this._firstActiveElement>=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},t._freeRetiredParticles=function(){for(var e=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var t=this._firstRetiredElement*iW.instanceVertexFloatStride+iW.startLifeTimeOffset;if(e-this._instanceVertices[t]<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},t._addActiveParticlesToVertexBuffer=function(){var e=this._firstActiveElement,t=this._firstFreeElement;if(e!==t){var n=iW.instanceVertexStride,r=e*n,a=this._instanceVertexBufferBinding.buffer,i=this._instanceVertices.buffer;if(e<t)a.setData(i,0,r,(t-e)*n,r5.Discard);else{var o=(this._currentParticleCount-e)*n;a.setData(i,0,r,o,r5.Discard),t>0&&a.setData(i,o,0,t*n)}this._firstNewElement=t,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},t._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return t.push(e),n},t._resizeTransformedBoundsArray=function(){var t=iW.boundsFloatStride,n=e._transformedBoundsIncreaseCount;this._transformedBoundsCount+=n;var r=this._transformedBoundsArray,a=new Float32Array(this._transformedBoundsCount*t);if(r){var i=this._firstFreeTransformedBoundingBox;a.set(new Float32Array(r.buffer,0,i*t));var o=i+1;a.set(new Float32Array(r.buffer,o*t*4),(o+n)*t),this._firstActiveTransformedBoundingBox>i&&(this._firstActiveTransformedBoundingBox+=n)}this._transformedBoundsArray=a},t._retireTransformedBounds=function(){for(var e=iW.boundsFloatStride,t=iW.boundsTimeOffset,n=iW.boundsMaxLifetimeOffset,r=this._transformedBoundsArray,a=this._firstFreeTransformedBoundingBox,i=this._transformedBoundsCount;this._firstActiveTransformedBoundingBox!==a;){var o=this._firstActiveTransformedBoundingBox*e;if(this._playTime-r[o+t]<=r[o+n])break;++this._firstActiveTransformedBoundingBox>=i&&(this._firstActiveTransformedBoundingBox=0),this._renderer._onWorldVolumeChanged()}},t._calculateGeneratorBounds=function(t,n){var r=e._tempVector30,a=e._tempVector31,i=e._tempVector20,o=n.min,s=n.max,l=this.main,c=this.emission.shape;(null==c?void 0:c.enabled)?(c._getPositionRange(o,s),c._getDirectionRange(a,r)):(o.set(0,0,0),s.set(0,0,0),a.set(0,0,-1),r.set(0,0,0)),this._getExtremeValueFromZero(l.startSpeed,i);var u=i.x,d=i.y,h=a.x,_=a.y,f=a.z,p=r.x,m=r.y,g=r.z;o.set(o.x+Math.min(h*d,p*u)*t,o.y+Math.min(_*d,m*u)*t,o.z+Math.min(f*d,g*u)*t),s.set(s.x+Math.max(h*u,p*d)*t,s.y+Math.max(_*u,m*d)*t,s.z+Math.max(f*u,g*d)*t);var v=l.startSize._getMax();if(l.startSize3D){var y=l.startSizeY._getMax();v=this._renderer.renderMode===oK.Billboard||oK.StretchBillboard||oK.HorizontalBillboard?Math.max(v,y):Math.max(v,y,l.startSizeZ._getMax())}v*=1.414;var x=this.sizeOverLifetime;if(x.enabled){var b=x.size._getMax();x.separateAxes&&(b=Math.max(b,x.sizeY._getMax(),x.sizeZ._getMax())),v*=b}o.set(o.x-v,o.y-v,o.z-v),s.set(s.x+v,s.y+v,s.z+v)},t._mergeTransformedBounds=function(e,t){var n=t.min,r=t.max,a=this._transformedBoundsArray,i=e*iW.boundsFloatStride;n.set(Math.min(n.x,a[i]),Math.min(n.y,a[i+1]),Math.min(n.z,a[i+2])),r.set(Math.max(r.x,a[i+3]),Math.max(r.y,a[i+4]),Math.max(r.z,a[i+5]))},t._calculateTransformedBounds=function(t,n,r){var a=e._tempVector20,i=e._tempVector21,o=e._tempVector22,s=e._tempMat,l=this._renderer.entity.transform,c=l.worldPosition;tL.rotationQuaternion(l.worldRotationQuaternion,s);var u=n.min,d=n.max,h=r.min,_=r.max,f=this.velocityOverLifetime;f.enabled?(this._getExtremeValueFromZero(f.velocityX,a),this._getExtremeValueFromZero(f.velocityY,i),this._getExtremeValueFromZero(f.velocityZ,o),f.space===oY.Local?(h.set(u.x+a.x*t,u.y+i.x*t,u.z+o.x*t),_.set(d.x+a.y*t,d.y+i.y*t,d.z+o.y*t),r.transform(s)):(r.transform(s),h.set(u.x+a.x*t,u.y+i.x*t,u.z+o.x*t),_.set(d.x+a.y*t,d.y+i.y*t,d.z+o.y*t))):tE.transform(n,s,r),h.add(c),_.add(c)},t._addGravityToBounds=function(t,n,r){var a=n.min,i=n.max,o=e._tempVector20;this._getExtremeValueFromZero(this.main.gravityModifier,o);var s=this._renderer.scene.physics.gravity,l=s.x,c=s.y,u=s.z,d=.5*t*t,h=o.x*d,_=o.y*d,f=l*h,p=l*_,m=c*h,g=c*_,v=u*h,y=u*_;r.min.set(Math.min(f,p)+a.x,Math.min(m,g)+a.y,Math.min(v,y)+a.z),r.max.set(Math.max(f,p)+i.x,Math.max(m,g)+i.y,Math.max(v,y)+i.z)},t._getExtremeValueFromZero=function(e,t){e._getMinMax(t),t.x=Math.min(0,t.x),t.y=Math.max(0,t.y)},tG(e,[{key:"isAlive",get:function(){return!!this._isPlaying||this._firstActiveElement!==this._firstFreeElement}},{key:"randomSeed",get:function(){return this._randomSeed},set:function(e){this._resetGlobalRandSeed(e),this.useAutoRandomSeed=!1}}]),e}();ss._tempVector20=new tB,ss._tempVector21=new tB,ss._tempVector22=new tB,ss._tempVector30=new tT,ss._tempVector31=new tT,ss._tempMat=new tL,ss._tempColor0=new tO,ss._tempParticleRenderers=[],ss._particleIncreaseCount=128,ss._transformedBoundsIncreaseCount=16,tX([tJ],ss.prototype,"main",void 0),tX([tJ],ss.prototype,"emission",void 0),tX([tJ],ss.prototype,"velocityOverLifetime",void 0),tX([tJ],ss.prototype,"sizeOverLifetime",void 0),tX([tJ],ss.prototype,"rotationOverLifetime",void 0),tX([tJ],ss.prototype,"colorOverLifetime",void 0),tX([tJ],ss.prototype,"textureSheetAnimation",void 0),tX([tq],ss.prototype,"_playTime",void 0),tX([tq],ss.prototype,"_firstNewElement",void 0),tX([tq],ss.prototype,"_firstActiveElement",void 0),tX([tq],ss.prototype,"_firstFreeElement",void 0),tX([tq],ss.prototype,"_firstRetiredElement",void 0),tX([tq],ss.prototype,"_primitive",void 0),tX([tq],ss.prototype,"_vertexBufferBindings",void 0),tX([tq],ss.prototype,"_subPrimitive",void 0),tX([tq],ss.prototype,"_renderer",void 0),tX([tq],ss.prototype,"_isPlaying",void 0),tX([tq],ss.prototype,"_instanceBufferResized",void 0),tX([tq],ss.prototype,"_waitProcessRetiredElementCount",void 0),tX([tq],ss.prototype,"_instanceVertexBufferBinding",void 0),tX([tq],ss.prototype,"_instanceVertices",void 0),tX([tq],ss.prototype,"_transformedBoundsArray",void 0),tX([tq],ss.prototype,"_transformedBoundsCount",void 0),tX([tq],ss.prototype,"_firstActiveTransformedBoundingBox",void 0),tX([tq],ss.prototype,"_firstFreeTransformedBoundingBox",void 0),tX([tq],ss.prototype,"_playStartDelay",void 0);var sl=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,ro.find("particle-shader"))||this).shaderData.setColor(as._baseColorProp,new tO(1,1,1,1)),n.isTransparent=!0,n}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(as._baseColorProp)},set:function(e){var t=this.shaderData.getColor(as._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(as._baseTextureProp)},set:function(e){this.shaderData.setTexture(as._baseTextureProp,e),e?this.shaderData.enableMacro(as._baseTextureMacro):this.shaderData.disableMacro(as._baseTextureMacro)}}]),t}(as),sc=function(e,t){this.time=e,this.count=t};tX([tJ],sc.prototype,"count",void 0);var su=/*#__PURE__*/function(){function e(){this._updateManager=new nM,this._enabled=!0,this._randomDirectionAmount=0}var t=e.prototype;return t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._updateManager.dispatch())}},{key:"randomDirectionAmount",get:function(){return this._randomDirectionAmount},set:function(e){e!==this._randomDirectionAmount&&(this._randomDirectionAmount=e,this._updateManager.dispatch())}}]),e}();tX([tq],su.prototype,"_updateManager",void 0);var sd=/*#__PURE__*/function(){function e(){}return e.randomPointUnitArcCircle=function(e,t,n){var r=n.random()*e;t.x=Math.cos(r),t.y=Math.sin(r)},e.randomPointInsideUnitArcCircle=function(t,n,r){e.randomPointUnitArcCircle(t,n,r);var a=Math.sqrt(r.random());n.x=n.x*a,n.y=n.y*a},e.randomPointUnitCircle=function(e,t){var n=t.random()*Math.PI*2;e.x=Math.cos(n),e.y=Math.sin(n)},e.randomPointInsideUnitCircle=function(t,n){e.randomPointUnitCircle(t,n);var r=Math.sqrt(n.random());t.x=t.x*r,t.y=t.y*r},e._randomPointUnitSphere=function(e,t){var n=2*t.random()-1,r=t.random()*Math.PI*2,a=Math.sqrt(1-n*n);e.x=a*Math.cos(r),e.y=a*Math.sin(r),e.z=n},e._randomPointInsideUnitSphere=function(t,n){e._randomPointUnitSphere(t,n);var r=Math.pow(n.random(),1/3);t.x=t.x*r,t.y=t.y*r,t.z=t.z*r},e._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},e}(),sh=((eZ={})[eZ.Box=0]="Box",eZ[eZ.Circle=1]="Circle",eZ[eZ.Cone=2]="Cone",eZ[eZ.Hemisphere=3]="Hemisphere",eZ[eZ.Sphere=4]="Sphere",eZ),s_=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).shapeType=sh.Box,t._size=new tT(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){sd._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var i=t._tempVector30;i.set(0,0,-1),sd._randomPointUnitSphere(a,e),tT.lerp(i,a,this.randomDirectionAmount,a)},n._getDirectionRange=function(e,t){var n=Math.PI*this.randomDirectionAmount;if(this.randomDirectionAmount<.5){var r=Math.sin(n);e.set(-r,-r,-1),t.set(r,r,0)}else{var a=Math.cos(n);e.set(-1,-1,-1),t.set(1,1,-a)}},n._getPositionRange=function(e,t){var n=this._size,r=n.x,a=n.y,i=n.z;e.set(-(.5*r),-(.5*a),-(.5*i)),t.set(.5*r,.5*a,.5*i)},tG(t,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),t}(su);s_._tempVector30=new tT,tX([tJ],s_.prototype,"_size",void 0);var sf=((eJ={})[eJ.Random=0]="Random",eJ[eJ.Loop=1]="Loop",eJ),sp=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Circle,t._radius=1,t._arc=360,t._arcMode=sf.Random,t._arcSpeed=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){var i=t._tempPositionPoint;switch(this.arcMode){case sf.Loop:var o=n*this.arcSpeed*(360/this.arc)%1,s=tC.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(e.random());break;case sf.Random:sd.randomPointInsideUnitArcCircle(tC.degreeToRadian(this.arc),i,e)}r.set(i.x,i.y,0),r.scale(this.radius),sd._randomPointUnitSphere(a,e),tT.lerp(r,a,this.randomDirectionAmount,a)},n._getDirectionRange=function(e,t){var n=this.randomDirectionAmount>.5?1:Math.sin(this.randomDirectionAmount*Math.PI),r=.5*(360-this._arc)*this.randomDirectionAmount,a=r>90?-1:-Math.sin(r);this._getUnitArcRange(this._arc+r,e,t,a,n)},n._getPositionRange=function(e,t){this._getUnitArcRange(this._arc,e,t,0,0),e.scale(this._radius),t.scale(this._radius)},n._getUnitArcRange=function(e,t,n,r,a){var i=tC.degreeToRadian(e),o=Math.sin(i),s=Math.cos(i);e<90?(t.set(0,r,-a),n.set(1,o,a)):(e<180?t.set(s,r,-a):e<270?t.set(-1,Math.min(o,r),-a):t.set(-1,-1,-a),n.set(1,1,a))},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"arc",get:function(){return this._arc},set:function(e){e!==this._arc&&(this._arc=e,this._updateManager.dispatch())}},{key:"arcMode",get:function(){return this._arcMode},set:function(e){e!==this._arcMode&&(this._arcMode=e,this._updateManager.dispatch())}},{key:"arcSpeed",get:function(){return this._arcSpeed},set:function(e){e!==this._arcSpeed&&(this._arcSpeed=e,this._updateManager.dispatch())}}]),t}(su);sp._tempPositionPoint=new tB;var sm=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){var i=t._tempVector20,o=tC.degreeToRadian(this.angle),s=Math.sin(o),l=Math.cos(o);switch(this.emitType){case 0:sd.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0);var c=t._tempVector21;sd.randomPointInsideUnitCircle(c,e),tB.lerp(i,c,this.randomDirectionAmount,c),a.set(c.x*s,c.y*s,-l);break;case 1:sd.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0),a.set(i.x*s,i.y*s,-l),a.normalize();var u=t._tempVector30;tT.scale(a,this.length*e.random(),u),r.add(u);var d=t._tempVector31;sd._randomPointUnitSphere(d,e),tT.lerp(a,d,this.randomDirectionAmount,a)}},n._getDirectionRange=function(e,t){var n=0;switch(this.emitType){case 0:n=tC.degreeToRadian(this._angle);break;case 1:n=Math.sin(tC.degreeToRadian((180-this._angle)*this.randomDirectionAmount+this._angle))}var r=Math.sin(n);e.set(-r,-r,-1),t.set(r,r,0)},n._getPositionRange=function(e,t){var n=this.radius;switch(this.emitType){case 0:e.set(-n,-n,0),t.set(n,n,0);break;case 1:var r=this.length,a=Math.sin(tC.degreeToRadian(this._angle));e.set(-n-a*r,-n-a*r,-r),t.set(n+a*r,n+a*r,0)}},tG(t,[{key:"angle",get:function(){return this._angle},set:function(e){e!==this._angle&&(this._angle=e,this._updateManager.dispatch())}},{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"length",get:function(){return this._length},set:function(e){e!==this._length&&(this._length=e,this._updateManager.dispatch())}},{key:"emitType",get:function(){return this._emitType},set:function(e){e!==this._emitType&&(this._emitType=e,this._updateManager.dispatch())}}]),t}(su);sm._tempVector20=new tB,sm._tempVector21=new tB,sm._tempVector30=new tT,sm._tempVector31=new tT;var sg=((e$={})[e$.Base=0]="Base",e$[e$.Volume=1]="Volume",e$),sv=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Hemisphere,t._radius=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sd._randomPointInsideUnitSphere(n,e),n.scale(this.radius);var a=n.z;a>0&&(n.z=-a),sd._randomPointUnitSphere(r,e),tT.lerp(n,r,this.randomDirectionAmount,r)},n._getDirectionRange=function(e,t){var n=Math.sin(.5*this.randomDirectionAmount*Math.PI);e.set(-1,-1,-1),t.set(1,1,n)},n._getPositionRange=function(e,t){var n=this._radius;e.set(-n,-n,-n),t.set(n,n,0)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(su),sy=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Sphere,t._radius=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sd._randomPointInsideUnitSphere(n,e),n.scale(this.radius),sd._randomPointUnitSphere(r,e),tT.lerp(n,r,this.randomDirectionAmount,r)},n._getDirectionRange=function(e,t){e.set(-1,-1,-1),t.set(1,1,1)},n._getPositionRange=function(e,t){var n=this._radius;e.set(-n,-n,-n),t.set(n,n,n)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(su);ro.create("trail","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;void main(){gl_Position=camera_ProjMat*camera_ViewMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nvarying vec2 v_uv;uniform sampler2D u_texture;void main(void){gl_FragColor=texture2D(u_texture,v_uv);}");var sx=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t,ro.find("trail"))||this).renderState.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=r.sourceAlphaBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=r.destinationAlphaBlendFactor=nF.One,n.renderState.depthState.writeEnabled=!1,n}return tW(t,e),t}(ao),sb=new tT,sS=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._stroke=n.stroke||.2,r._minSeg=n.minSeg||.02,r._lifetime=n.lifetime||1e3,r._maxPointNum=r._lifetime/1e3*t.engine.targetFrameRate,r._points=[],r._pointStates=[],r._strapPoints=[];for(var r,a=0;a<r._maxPointNum;a++)r._points.push(new tT),r._pointStates.push(r._lifetime),r._strapPoints.push(new tT),r._strapPoints.push(new tT);r._curPointNum=0;var i=n.material||new sx(r.engine);return r.setMaterial(i),r.setTexture(n.texture),r._initGeometry(),r}tW(t,e);var n=t.prototype;return n.update=function(e){for(var t=0,n=0,r=0;r<this._curPointNum;r++)this._pointStates[r]-=e,this._pointStates[r]<0?t++:t>0&&(n=r-t,this._pointStates[n]=this._pointStates[r],this._points[n].copyFrom(this._points[r]));this._curPointNum-=t;var a=!0;if(this._curPointNum===this._maxPointNum)a=!1;else if(this._curPointNum>0){var i=this._points[this._points.length-1];tT.distance(this.entity.transform.worldPosition,i)<this._minSeg&&(a=!1)}a&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},n.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},n._render=function(t){this._updateStrapVertices(t.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),e.prototype._render.call(this,t)},n._initGeometry=function(){var e=new aT(this._entity.engine),t=2*this._maxPointNum,n=20*t,r=new Float32Array(n),a=[new at("POSITION",0,r7.Vector3,0),new at("TEXCOORD_0",12,r7.Vector2,0)],i=new r9(this.engine,4*n,r8.Dynamic);e.setVertexBufferBinding(i,20),e.setVertexElements(a),e.addSubMesh(0,t,ar.TriangleStrip),this._vertexBuffer=i,this._vertexStride=20,this._vertices=r,this.mesh=e},n._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new tT(n[0],n[4],n[8]),a=new tT(n[1],n[5],n[9]),i=new tT(n[2],n[6],n[10]),o=this._stroke;a.scale(o);var s=new tT,l=new tT,c=new tF;tT.transformByQuat(r,c,r),tT.transformByQuat(a,c,a);var u=new tT,d=new tT,h=new tT;r.normalize();for(var _=this._vertices,f=0;f<this._maxPointNum;f++){if(f<this._curPointNum){var p=t[f];f===this._curPointNum-1&&0!==f?tT.subtract(p,t[f-1],h):tT.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(tT.dot(r,h));tT.cross(r,h,d),0>=tT.dot(d,i)&&(m=2*Math.PI-m),tF.rotationAxisAngle(i,m,c),tT.transformByQuat(a,c,u),tT.add(p,u,s),tT.subtract(p,u,l)}var g=2*f*this._vertexStride/4,v=(2*f+1)*this._vertexStride/4;_[g]=s.x,_[g+1]=s.y,_[g+2]=s.z,_[v]=l.x,_[v+1]=l.y,_[v+2]=l.z}},n._updateStrapCoords=function(){if(this._prePointsNum!==this._curPointNum){this._prePointsNum=this._curPointNum;for(var e=this._curPointNum,t=1/e,n=this._vertices,r=0;r<e;r++){var a=1-r*t,i=2*r*this._vertexStride/4,o=(2*r+1)*this._vertexStride/4;n[i]=0,n[i+1]=a,n[o]=1,n[o+1]=a}}},n._projectOnVector=function(e,t,n){var r=t.clone();tT.normalize(r,r);var a=tT.dot(e,r);n.x=r.x*a,n.y=r.y*a,n.z=r.z*a},n._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,sb),tT.subtract(e,sb,n)},t}(aA),sC=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.probeLayer=rE.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t}tW(t,e);var n=t.prototype;return n.onTextureChange=function(e){},n.onBeginRender=function(e){this.enabled&&(this._camera=e,this._oriCameraCullingMask=e.cullingMask,e.cullingMask=this.probeLayer,this._activeRenderTarget&&this._activeRenderTarget.width===this.width&&this._activeRenderTarget.height===this.height&&this._activeRenderTarget.antiAliasing===this.antiAliasing||(this._renderTarget=new nl(this.engine,this.width,this.height,this._isCube?new nd(this.engine,this.width):new nc(this.engine,this.width,this.height),t3.Depth,this.antiAliasing),this._renderTargetSwap=new nl(this.engine,this.width,this.height,this._isCube?new nd(this.engine,this.width):new nc(this.engine,this.width,this.height),t3.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=e.renderTarget,e.renderTarget=this._activeRenderTarget)},n.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},n._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},tG(t,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),t}(os),sT=new tT,sA=new tT,sE=new tT,sR=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.position=new tT(0,0,0),t._isCube=!0,t.oriViewMatrix=new tL,t}tW(t,e);var n=t.prototype;return n.onBeginRender=function(t){if(this.enabled){e.prototype.onBeginRender.call(this,t),this._storeCamera(t);for(var n=0;n<6;n++)this._setCamera(n,t),t.render(t4.PositiveX+n);this._restoreCamera(t),e.prototype._reset.call(this)}},n._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},n._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},n._setCamera=function(e,t){switch(e){case 0:sA.set(0,-1,0),sE.set(1,0,0);break;case 1:sA.set(0,-1,0),sE.set(-1,0,0);break;case 2:sA.set(0,0,1),sE.set(0,1,0);break;case 3:sA.set(0,0,-1),sE.set(0,-1,0);break;case 4:sA.set(0,-1,0),sE.set(0,0,1);break;case 5:sA.set(0,-1,0),sE.set(0,0,-1)}tT.add(this.position,sE,sT),tL.lookAt(this.position,sT,sA,t.viewMatrix),t.fieldOfView=90},t}(sC),sM=/*#__PURE__*/Object.freeze({__proto__:null,AmbientLight:i8,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:ov,AnimationClipCurveBinding:om,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:ox,AnimationEvent:og,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationRectCurve(){return e.AnimationRectCurve},get AnimationRefCurve(){return e.AnimationRefCurve},get AnimationStringCurve(){return e.AnimationStringCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:oD,AnimatorCondition:oR,AnimatorConditionMode:ob,AnimatorController:oI,AnimatorControllerLayer:oz,AnimatorControllerParameter:oB,AnimatorCullingMode:oS,AnimatorLayerBlendingMode:oC,AnimatorLayerMask:oH,AnimatorState:oN,AnimatorStateMachine:ok,AnimatorStateTransition:oM,AssetPromise:a8,AssetType:a2,Background:i0,BackgroundMode:rO,BackgroundTextureFillMode:rV,BaseMaterial:as,BasicRenderPipeline:rJ,BlendFactor:nF,BlendMode:aa,BlendOperation:nL,BlendShape:am,BlendShapeFrame:af,BlendState:rt,BlinnPhongMaterial:al,BloomDownScaleMode:ot,BloomEffect:on,BoolUpdateFlag:rf,BoxColliderShape:iI,BoxShape:s_,Buffer:r9,BufferBindFlag:an,BufferMesh:aT,BufferUsage:r8,BufferUtil:ae,Burst:sc,get Camera(){return e.Camera},CameraClearFlags:rw,CameraType:rP,Canvas:iJ,CapsuleColliderShape:iN,CharacterController:ig,CircleShape:sp,ClearableObjectPool:iq,CloneManager:t$,get Collider(){return e.Collider},ColliderShape:iB,ColliderShapeUpAxis:iA,CollisionDetectionMode:iy,ColorOverLifetimeModule:o5,ColorSpace:n2,ColorWriteMask:nD,CompareFunction:nB,Component:ru,ConeEmitType:sg,ConeShape:sm,ContentRestorer:t2,ControllerCollisionFlag:iE,ControllerNonWalkableMode:im,CubeProbe:sR,CullMode:nI,CurveKey:sr,DataType:nQ,DependentMode:r_,DepthState:rn,DepthTextureMode:rF,DiffuseMode:i4,DirectLight:i9,DisorderedArray:rS,Downsampling:rL,DynamicCollider:iv,DynamicColliderConstraints:ix,EmissionModule:o6,Engine:iZ,EngineObject:t0,Entity:aW,EventDispatcher:nK,FixedJoint:iM,FogMode:i3,Font:ng,FontStyle:n_,GLCapabilityType:nZ,GradientAlphaKey:o3,GradientColorKey:o2,HemisphereShape:sv,HingeJoint:iP,HitResult:ib,IndexBufferBinding:ag,IndexFormat:r6,InputManager:iU,InterpolationType:oy,get Joint(){return e.Joint},JointLimits:iL,JointMotor:iD,Keyframe:oU,Keys:ih,Layer:rE,LayerPathMask:oG,Light:i5,Loader:ol,Logger:no,MSAASamples:rD,MainModule:se,Material:ao,Mesh:ab,MeshRenderer:aA,MeshTopology:ar,ModelMesh:aM,OverflowMode:nf,PBRBaseMaterial:au,PBRMaterial:ad,PBRSpecularMaterial:ah,ParticleCompositeCurve:o9,ParticleCompositeGradient:o4,ParticleCurve:sn,ParticleCurveMode:oJ,ParticleGenerator:ss,ParticleGradient:o1,ParticleGradientMode:o$,ParticleMaterial:sl,ParticleRenderMode:oK,ParticleRenderer:oQ,ParticleScaleMode:o7,ParticleShapeArcMode:sf,ParticleShapeType:sh,ParticleSimulationSpace:oY,ParticleStopMode:oq,PhysicsMaterial:iC,PhysicsMaterialCombineMode:iS,PhysicsScene:ip,PipelineStage:nX,PlaneColliderShape:iV,Platform:tz,PointLight:i6,Pointer:is,PointerButton:il,PointerPhase:io,Primitive:ax,PrimitiveMesh:az,Probe:sC,RasterState:rr,ReferResource:t1,RenderBufferDepthFormat:t3,RenderFace:ai,RenderQueue:rG,RenderQueueType:nV,RenderState:ri,RenderStateDataKey:nO,RenderTarget:nl,RenderTargetBlendState:re,get Renderer(){return e.Renderer},ReplacementFailureStrategy:rB,ResourceManager:ie,ReturnableObjectPool:aQ,RotationOverLifetimeModule:st,SafeLoopArray:a3,Scene:oo,SceneManager:a4,Script:os,SetDataOptions:r5,Shader:ro,ShaderData:rs,ShaderFactory:n$,ShaderLib:nJ,ShaderMacro:nH,ShaderMacroCollection:nW,ShaderPass:n6,ShaderPlatformTarget:nz,ShaderProperty:nY,ShaderPropertyType:nN,ShaderTagKey:n0,ShadowCascadesMode:rK,ShadowResolution:rW,ShadowType:rj,SizeOverLifetimeModule:sa,Skin:aj,SkinnedMeshRenderer:aK,Sky:i$,SkyBoxMaterial:oW,SkyProceduralMaterial:oX,SphereColliderShape:iO,SphereShape:sy,SpotLight:i7,SpringJoint:iF,Sprite:nP,SpriteAtlas:nb,SpriteDrawMode:nS,SpriteMask:r2,SpriteMaskInteraction:nv,SpriteMaskLayer:rg,SpriteRenderer:rT,SpriteTileMode:nC,StateMachineScript:oV,StaticCollider:iT,StencilOperation:nk,StencilState:ra,SubMesh:ay,SubPrimitive:av,SubShader:n7,SunMode:oj,SystemInfo:id,TextHorizontalAlignment:ny,TextRenderer:r3,TextUtils:np,TextVerticalAlignment:nx,Texture:ns,Texture2D:nc,Texture2DArray:nu,TextureCoordinate:ac,TextureCube:nd,TextureCubeFace:t4,TextureDepthCompareFunction:t8,TextureFilterMode:t5,TextureFormat:t9,TextureSheetAnimationModule:si,TextureUsage:t6,TextureWrapMode:t7,Time:nq,TonemappingEffect:oa,TonemappingMode:or,TrailMaterial:sx,TrailRenderer:sS,Transform:rp,UnlitMaterial:a_,Utils:nT,VelocityOverLifetimeModule:so,VertexAttribute:aR,VertexBufferBinding:aC,VertexElement:at,VertexElementFormat:r7,WrapMode:ow,XRManager:iQ,_PostProcessManager:oi,assignmentClone:tQ,deepClone:tJ,dependentComponents:rh,ignoreClone:tq,request:a6,resourceLoader:it,shallowClone:tZ}),sw=((e0={})[e0.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",e0[e0.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",e0[e0.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",e0[e0.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",e0[e0.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",e0[e0.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",e0[e0.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",e0[e0.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",e0[e0.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",e0[e0.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",e0[e0.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",e0[e0.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",e0[e0.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",e0[e0.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",e0[e0.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",e0[e0.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",e0[e0.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",e0[e0.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",e0[e0.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",e0[e0.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",e0[e0.R11_EAC=37488]="R11_EAC",e0[e0.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",e0[e0.RG11_EAC=37490]="RG11_EAC",e0[e0.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",e0[e0.RGB8_ETC2=37492]="RGB8_ETC2",e0[e0.SRGB8_ETC2=37493]="SRGB8_ETC2",e0[e0.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e0[e0.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e0[e0.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",e0[e0.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",e0[e0.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",e0[e0.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",e0[e0.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",e0[e0.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",e0[e0.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",e0[e0.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",e0[e0.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",e0[e0.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",e0[e0.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",e0[e0.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",e0[e0.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",e0[e0.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT",e0);function sP(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 sF(e,t,n){return t&&sP(e.prototype,t),n&&sP(e,n),e}function sL(e,t){return(sL=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sD(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&&sL(e,t)}function sB(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var sI=/*#__PURE__*/function(e){function t(t){(n=e.call(this)||this)._scale=new tB;var n,r=t.width,a=t.height;return n._webCanvas=t,n.width=r,n.height=a,n}sD(t,e);var n=t.prototype;return n.resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!sB(t,OffscreenCanvas)){var n=t.clientWidth*e,r=t.clientHeight*e;this.width=n,this.height=r}},n.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},n._onWidthChanged=function(e){this._webCanvas.width=e},n._onHeightChange=function(e){this._webCanvas.height=e},sF(t,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&sB(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&&sB(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),t}(iJ),sO=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sD(t,e),t.create=function(e){var n=e.canvas,r=new t(new sI("string"==typeof n?document.getElementById(n):n),new sq(e.graphicDeviceOptions),e);return r._initialize(e).then(function(){return r.sceneManager.addScene(new oo(r,"DefaultScene")),r})},sF(t,[{key:"canvas",get:function(){return this._canvas}}]),t}(iZ);function sV(){return(sV=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 sN=/*#__PURE__*/function(){function e(e,t,n,r,a){void 0===r&&(r=r8.Static);var i=e.gl,o=i.createBuffer(),s=this._getGLBufferUsage(i,r),l=t===an.VertexBuffer?i.ARRAY_BUFFER:i.ELEMENT_ARRAY_BUFFER;this._gl=i,this._glBuffer=o,this._glBufferUsage=s,this._glBindTarget=l,this._isWebGL2=e.isWebGL2,this.bind(),a?i.bufferData(l,a,s):i.bufferData(l,n,s),i.bindBuffer(l,null)}var t=e.prototype;return t.bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},t.setData=function(e,t,n,r,a,i){var o=this._gl,s=this._glBindTarget;this.bind(),i===r5.Discard&&o.bufferData(s,e,this._glBufferUsage);var l=t.BYTES_PER_ELEMENT||1,c=a?l*a:t.byteLength;if(0!==r||c<t.byteLength){var u=void 0!==t.byteOffset;if(this._isWebGL2&&u)o.bufferSubData(s,n,t,r,c/l);else{var d=new Uint8Array(u?t.buffer:t,r*l,c);o.bufferSubData(s,n,d)}}else o.bufferSubData(s,n,t);o.bindBuffer(s,null)},t.getData=function(e,t,n,r){if(this._isWebGL2){var a=this._gl;this.bind(),a.getBufferSubData(this._glBindTarget,t,e,n,r)}else throw"Buffer is write-only on WebGL1.0 platforms."},t.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},t._getGLBufferUsage=function(e,t){switch(t){case r8.Static:return e.STATIC_DRAW;case r8.Dynamic:return e.DYNAMIC_DRAW;case r8.Stream:return e.STREAM_DRAW}},e}(),sk=/*#__PURE__*/function(){function e(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}var t=e.prototype;return t.canIUse=function(e){return this.capabilityList.get(e)},t.canIUseCompressedTextureInternalFormat=function(e){var t=sw.RGBA_ASTC_4X4_KHR,n=sw.RGBA_ASTC_12X12_KHR,r=sw.SRGB8_ALPHA8_ASTC_4X4_KHR,a=sw.SRGB8_ALPHA8_ASTC_12X12_KHR,i=sw.RGB_ETC1_WEBGL,o=sw.R11_EAC,s=sw.SRGB8_ALPHA8_ETC2_EAC,l=sw.RGB_PVRTC_4BPPV1_IMG,c=sw.RGBA_PVRTC_2BPPV1_IMG,u=sw.RGB_S3TC_DXT1_EXT,d=sw.RGBA_S3TC_DXT5_EXT,h=sw.RGBA_BPTC_UNORM_EXT,_=sw.RGB_BPTC_UNSIGNED_FLOAT_EXT;return e>=t&&n<=n||e>=r&&e<=a?this.canIUse(nZ.astc):e===i?this.canIUse(nZ.etc1):e>=o&&e<=s?this.canIUse(nZ.etc):e>=l&&e<=c?this.canIUse(nZ.pvrtc):e>=u&&e<=d?this.canIUse(nZ.s3tc):!!(e>=h)&&!!(e<=_)&&this.canIUse(nZ.bptc)},t._init=function(){var e=this.capabilityList,t=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),r=nZ.shaderVertexID,a=nZ.standardDerivatives,i=nZ.shaderTextureLod,o=nZ.elementIndexUint,s=nZ.depthTexture,l=nZ.vertexArrayObject,c=nZ.instancedArrays,u=nZ.multipleSample,d=nZ.drawBuffers,h=nZ.blendMinMax,_=nZ.astc,f=nZ.astc_webkit,p=nZ.etc,m=nZ.etc_webkit,g=nZ.etc1,v=nZ.etc1_webkit,y=nZ.pvrtc,x=nZ.pvrtc_webkit,b=nZ.s3tc,S=nZ.s3tc_webkit,C=nZ.bptc,T=nZ.textureFloat,A=nZ.textureHalfFloat,E=nZ.textureFloatLinear,R=nZ.textureHalfFloatLinear,M=nZ.WEBGL_colorBufferFloat,w=nZ.colorBufferFloat,P=nZ.colorBufferHalfFloat,F=nZ.textureFilterAnisotropic,L=nZ.fragDepth;e.set(r,t),e.set(a,t||!!n(a)),e.set(i,t||!!n(i)),e.set(o,t||!!n(o)),e.set(s,t||!!n(s)),e.set(l,t||!!n(l)),e.set(c,t||!!n(c)),e.set(u,t),e.set(d,t||!!n(d)),e.set(h,t||!!n(h)),e.set(T,t||!!n(T)),e.set(A,t||!!n(A)),e.set(E,!!n(E)),e.set(R,t||!!n(R)),e.set(w,t&&!!n(w)||!!n(M)),e.set(P,t&&!!n(w)||!!n(P)),e.set(F,!!n(F)),e.set(L,t||!!n(L)),e.set(_,!!(n(_)||n(f))),e.set(p,!!(n(p)||n(m))),e.set(g,!!(n(g)||n(v))),e.set(y,!!(n(y)||n(x))),e.set(b,!!(n(b)||n(S))),e.set(C,!!n(C))},t._compatibleInterface=function(e,t){var n=this.rhi,r=n.gl,a=null;if(a=n.requireExtension(e))for(var i in t){var o=a[t[i]];(null==o?void 0:o.bind)?r[i]=o.bind(a):r[i]=o}},t._compatibleAllInterface=function(){var e=nZ.depthTexture,t=nZ.vertexArrayObject,n=nZ.instancedArrays,r=nZ.drawBuffers,a=nZ.textureFilterAnisotropic,i=nZ.textureHalfFloat,o=nZ.colorBufferHalfFloat,s=nZ.WEBGL_colorBufferFloat,l=nZ.blendMinMax;if(!this.rhi.isWebGL2){this._compatibleInterface(l,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(e,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(t,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(n,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(r,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var c={};if(this.canIUse(nZ.drawBuffers)){for(var u=this.maxDrawBuffers,d=0;d<u;d++)0!=d&&(c["COLOR_ATTACHMENT"+d]="COLOR_ATTACHMENT"+d+"_WEBGL"),c["DRAW_BUFFER"+d]="DRAW_BUFFER"+d+"_WEBGL";this._compatibleInterface(r,sV({drawBuffers:"drawBuffersWEBGL"},c))}this._compatibleInterface(i,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(o,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(s,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(a,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},sF(e,[{key:"maxTextureSize",get:function(){return this.rhi.renderStates.getParameter(this.rhi.gl.MAX_TEXTURE_SIZE)}},{key:"canUseFloatTextureBlendShape",get:function(){return this.canIUse(nZ.shaderVertexID)&&this.canIUse(nZ.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(nZ.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(nZ.drawBuffers)?this._maxDrawBuffers=this._rhi.gl.getParameter(this._rhi.gl.MAX_DRAW_BUFFERS):this._maxDrawBuffers=1),this._maxDrawBuffers}},{key:"maxAnisoLevel",get:function(){if(!this._maxAnisoLevel){var e=this._rhi.requireExtension(nZ.textureFilterAnisotropic);this._maxAnisoLevel=e?this._rhi.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1}return this._maxAnisoLevel}},{key:"maxAntiAliasing",get:function(){if(!this._maxAntiAliasing){var e=this._rhi.gl,t=this.canIUse(nZ.multipleSample);this._maxAntiAliasing=t?e.getParameter(e.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),e}(),sz=/*#__PURE__*/function(){function e(e){this.rhi=e,this._requireResult={}}return e.prototype.requireExtension=function(e){return void 0!==this._requireResult[e]||(this._requireResult[e]=this.rhi.gl.getExtension(e)),this._requireResult[e]},e}(),sU=/*#__PURE__*/function(){function e(e,t){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=t,this._canUseInstancedArrays=e.canIUse(nZ.instancedArrays),this._isSupportVAO=e.canIUse(nZ.vertexArrayObject),this._gl=e.gl}var t=e.prototype;return t.draw=function(e,t){var n=this._gl,r=this._primitive,a=this._isSupportVAO&&r.enableVAO;if(a){r._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var i=this._vaoMap.get(e.id);n.bindVertexArray(i)}else this._bindBufferAndAttrib(e);var o=r.indexBufferBinding,s=r.instanceCount,l=r._glIndexType,c=r._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)n.drawElementsInstanced(u,h,l,d*c,s);else{var _=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,_),n.drawElementsInstanced(u,h,l,d*c,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArraysInstanced(u,d,h,s)}else no.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)n.drawElements(u,h,l,d*c);else{var f=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.drawElements(u,h,l,d*c),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArrays(u,d,h);a?n.bindVertexArray(null):this._disableAttrib()},t.destroy=function(){this._isSupportVAO&&this._clearVAO()},t._bindBufferAndAttrib=function(e){var t,n,r=this._gl,a=this._primitive,i=a.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=a._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var d=i[u.bindingIndex],h=d.buffer,_=d.stride;n!==(t=h._platformBuffer._glBuffer)&&(n=t,r.bindBuffer(r.ARRAY_BUFFER,t)),r.enableVertexAttribArray(c);var f=u._formatMetaInfo;r.vertexAttribPointer(c,f.size,f.type,f.normalized,_,u.offset),this._canUseInstancedArrays&&r.vertexAttribDivisor(c,u.instanceStepRate),this._attribLocArray.push(c)}else no.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},t._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},t._registerVAO=function(e){var t=this._gl,n=t.createVertexArray();t.bindVertexArray(n);var r=this._primitive.indexBufferBinding;r&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.buffer._platformBuffer._glBuffer),this._bindBufferAndAttrib(e),t.bindVertexArray(null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this._disableAttrib(),this._vaoMap.set(e.id,n)},t._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},e}(),sG=/*#__PURE__*/function(){function e(e){this._parameters={},this._gl=e,this._parameters={},this._parameters[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_VERTEX_UNIFORM_VECTORS]=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this._parameters[e.MAX_VERTEX_ATTRIBS]=e.getParameter(e.MAX_VERTEX_ATTRIBS),this._parameters[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_TEXTURE_SIZE]=e.getParameter(e.MAX_TEXTURE_SIZE),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.colorMask(!0,!0,!0,!0),e.blendColor(0,0,0,0),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.enable(e.DEPTH_TEST),e.depthFunc(e.LESS),e.depthMask(!0),e.disable(e.STENCIL_TEST),e.stencilFuncSeparate(e.FRONT,e.ALWAYS,0,255),e.stencilFuncSeparate(e.BACK,e.ALWAYS,0,255),e.stencilOpSeparate(e.FRONT,e.KEEP,e.KEEP,e.KEEP),e.stencilOpSeparate(e.BACK,e.KEEP,e.KEEP,e.KEEP),e.stencilMask(255),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.disable(e.POLYGON_OFFSET_FILL),e.polygonOffset(0,0)}return e.prototype.getParameter=function(e){return this._parameters[e]},e}(),sH=/*#__PURE__*/function(){function e(e,t,n){this._texture=t,this._rhi=e,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=n,this._glTexture=this._gl.createTexture()}var t=e.prototype;return t.destroy=function(){this._gl.deleteTexture(this._glTexture),this._texture=null,this._glTexture=null,this._formatDetail=null},t.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},t.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},t._bind=function(){this._rhi.bindTexture(this)},t._init=function(e){var t=this._gl,n=this._isWebGL2,r=this._formatDetail,a=r.internalFormat,i=r.baseFormat,o=r.dataType,s=this._texture,l=s.mipmapCount,c=s.width,u=s.height,d=s.usage,h=s._isDepthTexture;if(this._bind(),n&&!(i===t.LUMINANCE_ALPHA||i===t.ALPHA)&&d!==t6.Dynamic)t.texStorage2D(this._target,l,a,c,u);else if(e)for(var _=0;_<l;_++)for(var f=Math.max(1,c>>_),p=0;p<6;p++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,_,a,f,f,0,i,o,null);else if(h)t.texImage2D(this._target,0,a,c,u,0,i,o,null);else for(var m=0;m<l;m++){var g=Math.max(1,c>>m),v=Math.max(1,u>>m);t.texImage2D(this._target,m,a,g,v,0,i,o,null)}},t._getPixelBuffer=function(e,t,n,r,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),i>0&&!this._isWebGL2&&(i=0,no.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,i):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,i),s.readPixels(t,n,r,a,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t._setWrapMode=function(t,n){var r=this._gl,a=this._isWebGL2,i=this._target,o=this._texture,s=o.width,l=o.height;switch(a||t===t7.Clamp||e._isPowerOf2(s)&&e._isPowerOf2(l)||(no.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=t7.Clamp),t){case t7.Clamp:r.texParameteri(i,n,r.CLAMP_TO_EDGE);break;case t7.Repeat:r.texParameteri(i,n,r.REPEAT);break;case t7.Mirror:r.texParameteri(i,n,r.MIRRORED_REPEAT)}},t._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},e._isPowerOf2=function(e){return(e&e-1)==0},e._getFormatDetail=function(e,t,n){switch(e){case t9.R8G8B8:return{internalFormat:n?t.RGB8:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R8G8B8A8:return{internalFormat:n?t.RGBA8:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R4G4B4A4:return{internalFormat:n?t.RGBA4:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case t9.R5G5B5A1:return{internalFormat:n?t.RGB5_A1:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case t9.R5G6B5:return{internalFormat:n?t.RGB565:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case t9.Alpha8:return{internalFormat:t.ALPHA,baseFormat:t.ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.LuminanceAlpha:return{internalFormat:t.LUMINANCE_ALPHA,baseFormat:t.LUMINANCE_ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R11G11B10_UFloat:return{internalFormat:n?t.R11F_G11F_B10F:t.NONE,baseFormat:t.RGB,dataType:t.FLOAT,isCompressed:!1};case t9.R16G16B16A16:return{internalFormat:n?t.RGBA16F:t.RGBA,baseFormat:t.RGBA,dataType:t.HALF_FLOAT,isCompressed:!1};case t9.R32G32B32A32:return{internalFormat:n?t.RGBA32F:t.RGBA,baseFormat:t.RGBA,dataType:t.FLOAT,isCompressed:!1};case t9.R32G32B32A32_UInt:return{internalFormat:n?t.RGBA32UI:t.NONE,baseFormat:t.RGBA_INTEGER,dataType:t.UNSIGNED_INT,isCompressed:!1};case t9.BC1:return{internalFormat:sw.RGB_S3TC_DXT1_EXT,isCompressed:!0};case t9.BC3:return{internalFormat:sw.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case t9.BC7:return{internalFormat:sw.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case t9.ETC1_RGB:return{internalFormat:sw.RGB_ETC1_WEBGL,isCompressed:!0};case t9.ETC2_RGB:return{internalFormat:sw.RGB8_ETC2,isCompressed:!0};case t9.ETC2_RGBA5:return{internalFormat:sw.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case t9.ETC2_RGBA8:return{internalFormat:sw.RGBA8_ETC2_EAC,isCompressed:!0};case t9.PVRTC_RGB2:return{internalFormat:sw.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGBA2:return{internalFormat:sw.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGB4:return{internalFormat:sw.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGBA4:return{internalFormat:sw.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case t9.ASTC_4x4:return{internalFormat:sw.RGBA_ASTC_4X4_KHR,isCompressed:!0};case t9.ASTC_5x5:return{internalFormat:sw.RGBA_ASTC_5X5_KHR,isCompressed:!0};case t9.ASTC_6x6:return{internalFormat:sw.RGBA_ASTC_6X6_KHR,isCompressed:!0};case t9.ASTC_8x8:return{internalFormat:sw.RGBA_ASTC_8X8_KHR,isCompressed:!0};case t9.ASTC_10x10:return{internalFormat:sw.RGBA_ASTC_10X10_KHR,isCompressed:!0};case t9.ASTC_12x12:return{internalFormat:sw.RGBA_ASTC_12X12_KHR,isCompressed:!0};case t9.Depth:return{internalFormat:n?t.DEPTH_COMPONENT32F:t.DEPTH_COMPONENT,baseFormat:t.DEPTH_COMPONENT,dataType:n?t.FLOAT:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.DepthStencil:return{internalFormat:n?t.DEPTH32F_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:n?t.FLOAT_32_UNSIGNED_INT_24_8_REV:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth16:return{internalFormat:n?t.DEPTH_COMPONENT16:t.DEPTH_COMPONENT,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth24Stencil8:return{internalFormat:n?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32Stencil8:return{internalFormat:t.DEPTH32F_STENCIL8,baseFormat:t.DEPTH_STENCIL,dataType:t.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+e)}},e._getRenderBufferDepthFormatDetail=function(e,t,n){switch(e){case t9.Depth:return{internalFormat:n?t.DEPTH_COMPONENT32F:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:n?t.FLOAT:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.DepthStencil:return{internalFormat:n?t.DEPTH32F_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:n?t.FLOAT_32_UNSIGNED_INT_24_8_REV:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Stencil:return{internalFormat:t.STENCIL_INDEX8,baseFormat:t.STENCIL_ATTACHMENT,dataType:t.UNSIGNED_BYTE,isCompressed:!1,attachment:t.STENCIL_ATTACHMENT};case t9.Depth16:return{internalFormat:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth24Stencil8:return{internalFormat:n?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32Stencil8:return{internalFormat:t.DEPTH32F_STENCIL8,baseFormat:t.DEPTH_STENCIL,dataType:t.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+e)}},e._supportTextureFormat=function(e,t){switch(e){case t9.R16G16B16A16:if(!t.canIUse(nZ.textureHalfFloat))return!1;break;case t9.R32G32B32A32:if(!t.canIUse(nZ.textureFloat))return!1;break;case t9.Depth16:case t9.Depth24Stencil8:case t9.Depth:case t9.DepthStencil:if(!t.canIUse(nZ.depthTexture))return!1;break;case t9.R11G11B10_UFloat:case t9.R32G32B32A32_UInt:case t9.Depth24:case t9.Depth32:case t9.Depth32Stencil8:return t.isWebGL2}return!0},e._supportRenderBufferColorFormat=function(e,t){var n=!0;switch(e){case t9.R16G16B16A16:t.canIUse(nZ.colorBufferHalfFloat)&&t.canIUse(nZ.textureHalfFloat)||(n=!1);break;case t9.R32G32B32A32:t.canIUse(nZ.colorBufferFloat)&&t.canIUse(nZ.textureFloat)||(n=!1);break;case t9.R11G11B10_UFloat:n=t.isWebGL2}return n},e._supportRenderBufferDepthFormat=function(e,t){if(!t.isWebGL2)switch(e){case t9.Depth24:case t9.Depth32:case t9.Depth32Stencil8:return!1}return!0},sF(e,[{key:"wrapModeU",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(e){var t=this._gl,n=this._target,r=this._texture._mipmap;switch(this._bind(),e){case t5.Point:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.NEAREST_MIPMAP_NEAREST:t.NEAREST);break;case t5.Bilinear:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.LINEAR_MIPMAP_NEAREST:t.LINEAR);break;case t5.Trilinear:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.LINEAR_MIPMAP_LINEAR:t.LINEAR)}}},{key:"anisoLevel",set:function(e){var t=this._gl;this._bind(),t.texParameterf(this._target,t.TEXTURE_MAX_ANISOTROPY_EXT,e)}},{key:"depthCompareFunction",set:function(e){this._bind();var t=this._gl;switch(e){case t8.Never:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NEVER);break;case t8.Less:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LESS);break;case t8.Equal:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.EQUAL);break;case t8.LessEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LEQUAL);break;case t8.Greater:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GREATER);break;case t8.NotEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NOTEQUAL);break;case t8.GreaterEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GEQUAL);break;case t8.Always:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.ALWAYS)}}}]),e}(),sW=/*#__PURE__*/function(){function e(e,t){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=t;for(var n=t._colorTextures,r=t._depth,a=t.width,i=t.height,o=sB(r,ns),s=0,l=n.length;s<l;s++){var c=n[s]._format;if(!sH._supportRenderBufferColorFormat(c,e))throw Error("TextureFormat is not supported:"+t9[c]+" in RenderTarget")}if(!o&&!sH._supportRenderBufferDepthFormat(r,e))throw Error("TextureFormat is not supported:"+t9[r]+" in RenderTarget");if(n.length>1&&!e.canIUse(nZ.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==a||e.height!==i}))throw Error("ColorTexture's size must as same as RenderTarget");if(o&&(r.width!==a||r.height!==i))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return sB(e,nd)}))throw Error("MRT+Cube+[,MSAA] is not supported");var u=e.capability.maxAntiAliasing;t.antiAliasing>u&&(no.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+u),t._antiAliasing=u),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),t.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}var t=e.prototype;return t.activeRenderTarget=function(e,t){var n=this._gl,r=this._target;n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer);var a=e!==this._curMipLevel,i=t!==this._curFaceIndex,o=r.getColorTexture(0);if(o){var s=sB(o,nd);(a||s&&i)&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,s?n.TEXTURE_CUBE_MAP_POSITIVE_X+t:n.TEXTURE_2D,o._platformTexture._glTexture,e)}var l=r.depthTexture;if(l){var c=sB(l,nd);if(a||c){var u=l._platformTexture;n.framebufferTexture2D(n.FRAMEBUFFER,u._formatDetail.attachment,c?n.TEXTURE_CUBE_MAP_POSITIVE_X+t:n.TEXTURE_2D,u._glTexture,e)}}else if(a){var d=sH._getRenderBufferDepthFormatDetail(r._depth,n,this._isWebGL2).internalFormat;n.bindRenderbuffer(n.RENDERBUFFER,this._depthRenderBuffer),n.renderbufferStorage(n.RENDERBUFFER,d,r.width>>e,r.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&n.bindFramebuffer(n.FRAMEBUFFER,this._MSAAFrameBuffer)},t.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),n=this._target,r=n.colorTextureCount,a=n.width,i=n.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<r;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,a,i,0,0,a,i,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},t.destroy=function(){var e=this._gl;this._frameBuffer&&e.deleteFramebuffer(this._frameBuffer),this._depthRenderBuffer&&e.deleteRenderbuffer(this._depthRenderBuffer),this._MSAAFrameBuffer&&e.deleteFramebuffer(this._MSAAFrameBuffer),this._MSAADepthRenderBuffer&&e.deleteRenderbuffer(this._MSAADepthRenderBuffer);for(var t=0;t<this._MSAAColorRenderBuffers.length;t++)e.deleteRenderbuffer(this._MSAAColorRenderBuffers[t]);this._frameBuffer=null,this._depthRenderBuffer=null,this._MSAAFrameBuffer=null,this._MSAAColorRenderBuffers.length=0,this._MSAADepthRenderBuffer=null},t._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,n=this._target,r=n._depth,a=n.colorTextureCount,i=n.width,o=n.height,s=Array(a);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<a;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,sB(c,nd)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(sB(r,ns)&&!sB(r,nd)){var d=r._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,d._formatDetail.attachment,e.TEXTURE_2D,d._glTexture,0)}else if(this._target.antiAliasing<=1){var h=sH._getRenderBufferDepthFormatDetail(r,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,i,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,n=e.createRenderbuffer(),r=this._target,a=r._depth,i=r.colorTextureCount,o=r.antiAliasing,s=r.width,l=r.height;this._blitDrawBuffers=Array(i),this._MSAADepthRenderBuffer=n,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<i;c++){var u=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=u,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,u),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,u)}if(e.drawBuffers(this._oriDrawBuffers),null!==a){var d=sB(a,ns)?a._platformTexture._formatDetail:sH._getRenderBufferDepthFormatDetail(a,e,t),h=d.internalFormat,_=d.attachment;e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,h,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,n)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._checkFrameBuffer=function(){var e=this._gl,t=this._isWebGL2,n=e.checkFramebufferStatus(e.FRAMEBUFFER);switch(n){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw Error("The attachment types are mismatched or not all framebuffer attachment points are framebuffer attachment complete");case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw Error("There is no attachment");case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw Error(" Height and width of the attachment are not the same.");case e.FRAMEBUFFER_UNSUPPORTED:throw Error("The format of the attachment is not supported or if depth and stencil attachments are not the same renderbuffer")}if(t&&n===e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE)throw Error("The values of gl.RENDERBUFFER_SAMPLES are different among attached renderbuffers, or are non-zero if the attached images are a mix of renderbuffers and textures.")},e}(),sj=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var r,a=n.format,i=n._mipmap,o=n.width,s=n.height,l=r._isWebGL2;if(!sH._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return!i||l||sH._isPowerOf2(o)&&sH._isPowerOf2(s)||(no.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),n._mipmap=!1,n._mipmapCount=n._getMipmapCount()),r._formatDetail=sH._getFormatDetail(a,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r}sD(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,d=l.dataType,h=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(a=a||_-n,i=i||f-r,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),h){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,n,r,a,i,c,e):(o.compressedTexImage2D(this._target,t,c,a,i,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,n,r,a,i,u,d,e)},n.setImageSource=function(e,t,n,r,a,i){var o=this._gl,s=this._formatDetail,l=s.internalFormat,c=s.baseFormat,u=s.dataType;this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,+n),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+r),this._texture.usage===t6.Dynamic?o.texImage2D(this._target,t,l,c,u,e):o.texSubImage2D(this._target,t,a||0,i||0,c,u,e)},n.getPixelBuffer=function(t,n,r,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,null,t,n,r,a,i,o)},t}(sH),sX=/*#__PURE__*/function(e){function t(t,n){r=e.call(this,t,n,t.gl.TEXTURE_2D_ARRAY)||this;var r,a=n.format,i=n.width,o=n.height,s=n.length,l=n.mipmapCount;if(!r._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!sH._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return r._bind(),r._formatDetail=sH._getFormatDetail(a,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,i,o,s),r}sD(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;i=i||Math.max(1,this._texture.width>>n)-r,o=o||Math.max(1,this._texture.height>>n)-a,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,n,r,a,e,i,o,s,d,t):c.texSubImage3D(l,n,r,a,e,i,o,s,h,_,t)},n.setImageSource=function(e,t,n,r,a,i,o){var s,l,c=this._gl,u=this._formatDetail,d=u.baseFormat,h=u.dataType;this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,+r),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),c.texSubImage3D(this._target,n,i,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},n.getPixelBuffer=function(e,t,n,r,a,i,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,i,e),s.readPixels(t,n,r,a,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t}(sH),sK=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var r,a=n.format,i=n._mipmap,o=n.width,s=r._isWebGL2;if(!sH._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return!i||s||sH._isPowerOf2(o)||(no.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),n._mipmap=!1,n._mipmapCount=n._getMipmapCount()),r._formatDetail=sH._getFormatDetail(a,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r}sD(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,u=c.internalFormat,d=c.baseFormat,h=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>n);if(i=i||f-r,o=o||f-a,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<n;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,a,i,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,u,i,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,a,i,o,d,h,t)},n.setImageSource=function(e,t,n,r,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,i||0,o||0,c,u,t)},n.getPixelBuffer=function(t,n,r,a,i,o,s){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,t,n,r,a,i,o,s)},t}(sH),sY=((e1={})[e1.Auto=0]="Auto",e1[e1.WebGL2=1]="WebGL2",e1[e1.WebGL1=2]="WebGL1",e1),sq=/*#__PURE__*/function(){function e(e){void 0===e&&(e={}),this._readFrameBuffer=null,this._mainFrameBuffer=null,this._mainFrameWidth=0,this._mainFrameHeight=0,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new tI(null,null,null,null),this._lastScissor=new tI(null,null,null,null),this._lastClearColor=new tO(null,null,null,null),this._scissorEnable=!1;var t=sV({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},e);if(id.platform===tz.IPhone||id.platform===tz.IPad){var n=id.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var r=parseInt(n[1]),a=parseInt(n[2]);15===r&&a>=0&&a<=4&&(t._forceFlush=!0)}}this._options=t,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}var t=e.prototype;return t.init=function(e,t,n){var r,a=this._options,i=e._webCanvas,o=a.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=n,i.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),i.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),i.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=i,(0==o||1==o)&&((r=i.getContext("webgl2",a))||"undefined"!=typeof OffscreenCanvas&&sB(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl2",a)),this._isWebGL2=!0,r&&!r.deleteQuery&&(this._isWebGL2=!1)),r||0!=o&&2!=o||((r=i.getContext("webgl",a))||"undefined"!=typeof OffscreenCanvas&&sB(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},t.createPlatformPrimitive=function(e){return new sU(this,e)},t.createPlatformTexture2D=function(e){return new sj(this,e)},t.createPlatformTexture2DArray=function(e){return new sX(this,e)},t.createPlatformTextureCube=function(e){return new sK(this,e)},t.createPlatformRenderTarget=function(e){return new sW(this,e)},t.createPlatformBuffer=function(e,t,n,r){return void 0===n&&(n=r8.Static),new sN(this,e,t,n,r)},t.requireExtension=function(e){return this._extensions.requireExtension(e)},t.canIUse=function(e){return this.capability.canIUse(e)},t.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},t.viewport=function(e,t,n,r){var a=this._gl,i=this._lastViewport;(e!==i.x||t!==i.y||n!==i.z||r!==i.w)&&(a.viewport(e,t,n,r),i.set(e,t,n,r))},t.scissor=function(e,t,n,r){var a=this._gl,i=this._lastScissor;if(e!==i.x||t!==i.y||n!==i.z||r!==i.w){var o=this._webCanvas;0===e&&0===t&&n===o.width&&r===o.height?this._scissorEnable&&(a.disable(a.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(a.enable(a.SCISSOR_TEST),this._scissorEnable=!0),a.scissor(e,t,n,r)),i.set(e,t,n,r)}},t.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},t.clearRenderTarget=function(e,t,n){var r=this._gl,a=e._lastRenderState,i=a.blendState.targetBlendState,o=a.depthState,s=a.stencilState,l=0;if(t&rw.Color){l|=r.COLOR_BUFFER_BIT;var c=this._lastClearColor,u=n.r,d=n.g,h=n.b,_=n.a;n&&(u!==c.r||d!==c.g||h!==c.b||_!==c.a)&&(r.clearColor(u,d,h,_),c.set(u,d,h,_)),i.colorWriteMask!==nD.All&&(r.colorMask(!0,!0,!0,!0),i.colorWriteMask=nD.All)}t&rw.Depth&&(l|=r.DEPTH_BUFFER_BIT,!0!==o.writeEnabled&&(r.depthMask(!0),o.writeEnabled=!0)),t&rw.Stencil&&(l|=r.STENCIL_BUFFER_BIT,255!==s.writeMask&&(r.stencilMask(255),s.writeMask=255)),r.clear(l)},t.drawPrimitive=function(e,t,n){e?e.draw(n,t):no.error("draw primitive failed.")},t.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},t.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},t.activeRenderTarget=function(e,t,n,r,a){if(e){var i,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(r,a),i=e.width>>r,o=e.height>>r}else{var s=this._gl;s.bindFramebuffer(s.FRAMEBUFFER,this._mainFrameBuffer),i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight()}var l=i*t.z,c=o*t.w,u=t.x*i,d=n?t.y*o:o-t.y*o-c;this.viewport(u,d,l,c),this.scissor(u,d,l,c)},t.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},t.bindTexture=function(e){var t=this._activeTextureID-this._gl.TEXTURE0;this._activeTextures[t]!==e&&(this._gl.bindTexture(e._target,e._glTexture),this._activeTextures[t]=e)},t.setGlobalDepthBias=function(e,t){var n=this._gl,r=0!==e||0!==t;r?(n.enable(n.POLYGON_OFFSET_FILL),n.polygonOffset(t,e)):n.disable(n.POLYGON_OFFSET_FILL),this._enableGlobalDepthBias=r},t.flush=function(){this._gl.flush()},t.forceLoseDevice=function(){this.requireExtension(nZ.WEBGL_lose_context).loseContext()},t.forceRestoreDevice=function(){this.requireExtension(nZ.WEBGL_lose_context).restoreContext()},t.resetState=function(){this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._currentBindShaderProgram=null;for(var e=this._activeTextures,t=0,n=e.length;t<n;t++)e[t]=null;this._lastViewport.set(null,null,null,null),this._lastScissor.set(null,null,null,null),this._lastClearColor.set(null,null,null,null),this._scissorEnable=!1,this._initGLState(this._gl)},t._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new sG(e),this._extensions=new sz(this),this._capability=new sk(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},t.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},t._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},t._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},t._onWebGLContextRestored=function(e){this._onDeviceRestored()},sF(e,[{key:"isWebGL2",get:function(){return this._isWebGL2}},{key:"renderer",get:function(){return this._renderer}},{key:"gl",get:function(){return this._gl}},{key:"renderStates",get:function(){return this._renderStates}},{key:"capability",get:function(){return this._capability}},{key:"canIUseMoreJoints",get:function(){return this.capability.canIUseMoreJoints}}]),e}();function sQ(){return(sQ=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 sZ(e,t){return(sZ=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sJ(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&&sZ(e,t)}function s$(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function s0(e,t,r,a){var i,o=arguments.length,s=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function s1(e,t){var n,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function s2(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 s3(e,t,n){return t&&s2(e.prototype,t),n&&s2(e,n),e}"function"==typeof SuppressedError&&SuppressedError;var s4=/*#__PURE__*/function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===r&&(r=!0),this.data=e,this._dataView=new DataView(e.buffer,e.byteOffset+t,null!=n?n:e.byteLength-t),this._littleEndian=r,this._position=0,this._baseOffset=t}var t=e.prototype;return t.nextUint8=function(){var e=this._dataView.getUint8(this._position);return this._position+=1,e},t.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},t.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},t.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},t.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},t.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},t.nextUint64=function(){var e=this._dataView.getUint32(this._position,this._littleEndian),t=this._dataView.getUint32(this._position+4,this._littleEndian);return this._position+=8,e+0x100000000*t},t.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,nT.decodeText(t)},t.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},t.nextImagesData=function(e){for(var t=Array(e),n=0;n<e;n++){var r=this._dataView.getUint32(this._position,this._littleEndian);t[n]=r,this._position+=4}for(var a=[],i=0;i<e;i++){var o=t[i],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,a.push(s)}return a},t.skip=function(e){return this._position+=e,this},t.scan=function(e,t){void 0===t&&(t=0);for(var n=this._position,r=0;this._dataView.getUint8(this._position)!==t&&r<e;)r++,this._position++;return r<e&&this._position++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,r)},s3(e,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),e}(),s8={};function s5(e){return function(t){s8[e]=t}}var s9=/*#__PURE__*/function(){function e(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}return e.decode=function(t){var n=new DataView(t),r=n.getUint32(0,!0),a=n.getUint8(4),i=n.getUint16(5,!0),o=new Uint8Array(t,7,i),s=n.getUint16(7+i,!0),l=new Uint8Array(t,9+i,s),c=nT.decodeText(l),u=nT.decodeText(o),d=new e;return d.totalLength=r,d.name=c,d.type=u,d.version=a,d.headerLength=l.byteLength+o.byteLength+9,d},s3(e,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),e}();function s6(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tI(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function s7(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tT(e[3*r],e[3*r+1],e[3*r+2]);return n}function le(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tB(e[2*r],e[2*r+1]);return n}function lt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(lt=function(){return!!e})()}function ln(e,t,n){return(ln=lt()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&sZ(a,n.prototype),a}).apply(null,arguments)}e.MeshDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n){var r=new aM(e),a=JSON.parse(t.nextStr());a.bounds&&r.bounds.copyFrom(a.bounds);var i=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,a.positions.start+i,(a.positions.end-a.positions.start)/4),l=s.length/3,c=s7(s,l);if(r.setPositions(c),a.normals){var u=s7(new Float32Array(o,a.normals.start+i,(a.normals.end-a.normals.start)/4),l);r.setNormals(u)}if(a.uvs){var d=new Float32Array(o,a.uvs.start+i,(a.uvs.end-a.uvs.start)/4);r.setUVs(le(d,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);r.setUVs(le(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);r.setUVs(le(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);r.setUVs(le(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);r.setUVs(le(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);r.setUVs(le(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);r.setUVs(le(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);r.setUVs(le(v,l),7)}if(a.colors){var y=new Float32Array(o,a.colors.start+i,(a.colors.end-a.colors.start)/4);r.setColors(function(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tO(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}(y,l))}if(a.boneWeights){var x=new Float32Array(o,a.boneWeights.start+i,(a.boneWeights.end-a.boneWeights.start)/4);r.setBoneWeights(s6(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);r.setBoneIndices(s6(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new am(e.name);e.frames.forEach(function(e){var n=new Float32Array(o,e.deltaPosition.start+i,(e.deltaPosition.end-e.deltaPosition.start)/4),r=n.length/3,a=s7(n,r);e.deltaNormals&&s7(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),r),e.deltaTangents&&s6(new Float32Array(o,e.deltaTangents.start+i,(e.deltaTangents.end-e.deltaTangents.start)/4),r),t.addFrame(e.weight,a)}),r.addBlendShape(t)}),a.indices){var S=null;S=0===a.indices.type?new Uint16Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/2):new Uint32Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/4),r.setIndices(S)}a.subMeshes.forEach(function(e){return r.addSubMesh(e)}),r.uploadData(!1),n(r)})},e}(),e.MeshDecoder=s0([s5("Mesh")],e.MeshDecoder),e.Texture2DDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n,r){var a=t.nextStr(),i=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new nc(e,d,h,u,i);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),i){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[a]=m,n(m)}else{var x=new window.Blob([p[0]]),b=new Image;b.onload=function(){m.setImageSource(b);var e=0,t=function(){++e>=f&&n(m)};if(t(),i){var r=function(e){var n=new window.Blob([p[e]]),r=new Image;r.onload=function(){m.setImageSource(r,e),t()},r.src=URL.createObjectURL(n)};m.generateMipmaps();for(var a=1;a<f;a++)r(a)}},b.src=URL.createObjectURL(x)}})},e}(),e.Texture2DDecoder=s0([s5("Texture2D")],e.Texture2DDecoder);var lr=((e2={})[e2.Prefab=0]="Prefab",e2[e2.Scene=1]="Scene",e2),la=/*#__PURE__*/function(){function e(e,t,n){void 0===t&&(t=1),this.engine=e,this.type=t,this.resource=n,this.entityMap=new Map,this.entityConfigMap=new Map,this.components=new Map,this.rootIds=[],this.strippedIds=[],this.resourceManager=e.resourceManager}return e.prototype.clear=function(){this.entityMap.clear(),this.components.clear(),this.entityConfigMap.clear(),this.rootIds.length=0,this.strippedIds.length=0},e}(),li=/*#__PURE__*/function(){function e(e){this._context=e}var t=e.prototype;return t.parseEntity=function(e){var t=this;return this._getEntityByConfig(e).then(function(n){n.isActive=null==(r=e.isActive)||r;var r,a,i=e.position,o=e.rotation,s=e.scale;return i&&n.transform.position.copyFrom(i),o&&n.transform.rotation.copyFrom(o),s&&n.transform.scale.copyFrom(s),n.layer=null!=(a=e.layer)?a:n.layer,t._context.type===lr.Prefab&&n._markAsTemplate(t._context.resource),n})},t.parseClassObject=function(e){var t,n=this,r=ol.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return n.parseBasicType(e)})).then(function(e){return ln(r,[].concat(e))}).then(function(t){return n.parsePropsAndMethods(t,e)})},t.parsePropsAndMethods=function(t,n){var r=[];if(n.methods)for(var a in n.methods)for(var i=n.methods[a],o=0,s=i.length;o<s;o++)r.push(this.parseMethod(t,a,i[o]));if(n.props){var l,c=function(e){var a=n.props[e],i=l.parseBasicType(a,t[e]).then(function(n){return t[e]=n});r.push(i)};for(var u in n.props)l=this,c(u)}return Promise.all(r).then(function(){var r=e.customParseComponentHandles[t.constructor.name];return r?r(t,n):t})},t.parseMethod=function(e,t,n){var r=this;return Promise.all(n.map(function(e){return r.parseBasicType(e)})).then(function(n){return e[t].apply(e,[].concat(n))})},t.parseBasicType=function(t,n){var r=this;if(Array.isArray(t))return Promise.all(t.map(function(e){return r.parseBasicType(e)}));if((void 0===t?"undefined":s$(t))==="object"&&null!=t){if(e._isClass(t))return this.parseClassObject(t);if(e._isAssetRef(t)){var a=this._context;return a.resourceManager.getResourceByRef(t).then(function(e){return a.type===lr.Prefab&&a.resource._addDependenceAsset(e),e})}if(e._isEntityRef(t))return Promise.resolve(this._context.entityMap.get(t.entityId));if(n){var i,o=function(e){if("methods"===e){var r=t[e];for(var a in r)for(var o=r[a],l=0,c=o.length;l<c;l++){var u=o[l];s.push(i.parseMethod(n,a,u))}}else s.push(i.parseBasicType(t[e],n[e]).then(function(t){return n[e]=t}))},s=[];for(var l in t)i=this,o(l);return Promise.all(s).then(function(){return n})}}return Promise.resolve(t)},t._getEntityByConfig=function(e){var t=this,n=e.assetRefId,r=this._context.engine;return n?r.resourceManager.getResourceByRef({refId:n,key:e.key,isClone:e.isClone}).then(function(a){var i=r.resourceManager._objectPool[n];return t._context.type===lr.Prefab&&t._context.resource._addDependenceAsset(i),a.name=e.name,a}):Promise.resolve(new aW(r,e.name))},e.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},e._isClass=function(e){return void 0!=e.class},e._isAssetRef=function(e){return void 0!=e.refId},e._isEntityRef=function(e){return void 0!=e.entityId},e}();li.customParseComponentHandles=new Map;var lo=((e3={})[e3.Float=0]="Float",e3[e3.FloatArray=1]="FloatArray",e3[e3.Vector2=2]="Vector2",e3[e3.Vector3=3]="Vector3",e3[e3.Vector4=4]="Vector4",e3[e3.Quaternion=5]="Quaternion",e3[e3.Color=6]="Color",e3[e3.Array=7]="Array",e3[e3.Boolean=8]="Boolean",e3[e3.Rect=9]="Rect",e3[e3.ReferResource=10]="ReferResource",e3);e.AnimationClipDecoder=/*#__PURE__*/function(){function t(){}return t.decode=function(t,n){return new Promise(function(t){for(var r=new ov(n.nextStr()),a=n.nextUint16(),i=0;i<a;++i){var o=new og;o.time=n.nextFloat32(),o.functionName=n.nextStr(),o.parameter=JSON.parse(n.nextStr()).val,r.addEvent(o)}for(var s=n.nextUint16(),l=0;l<s;++l){var c=n.nextStr(),u=n.nextStr(),d=ol.getClass(u),h=n.nextStr(),_=n.nextStr(),f=void 0,p=n.nextUint8(),m=n.nextUint16();switch(n.nextStr()){case"AnimationFloatCurve":(f=new e.AnimationFloatCurve).interpolation=p;for(var g=0;g<m;++g){var v=new oU;v.time=n.nextFloat32(),v.value=n.nextFloat32(),v.inTangent=n.nextFloat32(),v.outTangent=n.nextFloat32(),f.addKey(v)}break;case"AnimationArrayCurve":(f=new e.AnimationArrayCurve).interpolation=p;for(var y=0;y<m;++y){var x=new oU;x.time=n.nextFloat32();var b=n.nextUint16();x.value=Array.from(n.nextFloat32Array(b)),x.inTangent=Array.from(n.nextFloat32Array(b)),x.outTangent=Array.from(n.nextFloat32Array(b)),f.addKey(x)}break;case"AnimationFloatArrayCurve":(f=new e.AnimationFloatArrayCurve).interpolation=p;for(var S=0;S<m;++S){var C=new oU;C.time=n.nextFloat32();var T=n.nextUint16();C.value=n.nextFloat32Array(T),C.inTangent=Array.from(n.nextFloat32Array(T)),C.outTangent=Array.from(n.nextFloat32Array(T)),f.addKey(C)}break;case"AnimationVector2Curve":(f=new e.AnimationVector2Curve).interpolation=p;for(var A=0;A<m;++A){var E=new oU;E.time=n.nextFloat32(),E.value=new tB(n.nextFloat32(),n.nextFloat32()),E.inTangent=new tB(n.nextFloat32(),n.nextFloat32()),E.outTangent=new tB(n.nextFloat32(),n.nextFloat32()),f.addKey(E)}break;case"AnimationVector3Curve":(f=new e.AnimationVector3Curve).interpolation=p;for(var R=0;R<m;++R){var M=new oU;M.time=n.nextFloat32(),M.value=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(M)}break;case"AnimationVector4Curve":(f=new e.AnimationVector4Curve).interpolation=p;var w=new oU;w.time=n.nextFloat32(),w.value=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(w);break;case"AnimationColorCurve":(f=new e.AnimationColorCurve).interpolation=p;for(var P=0;P<m;++P){var F=new oU;F.time=n.nextFloat32(),F.value=new tO(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(F)}break;case"AnimationQuaternionCurve":(f=new e.AnimationQuaternionCurve).interpolation=p;for(var L=0;L<m;++L){var D=new oU;D.time=n.nextFloat32(),D.value=new tF(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(D)}break;case"AnimationRefCurve":(f=new e.AnimationRefCurve).interpolation=p;for(var B=0;B<m;++B){var I=new oU;I.time=n.nextFloat32();var O=n.nextStr();O?I.value=JSON.parse(O):I.value=null,f.addKey(I)}break;case"AnimationBoolCurve":(f=new e.AnimationBoolCurve).interpolation=p;for(var V=0;V<m;++V){var N=new oU;N.time=n.nextFloat32(),N.value=1===n.nextUint8(),f.addKey(N)}break;case"AnimationStringCurve":(f=new e.AnimationStringCurve).interpolation=p;for(var k=0;k<m;++k){var z=new oU;z.time=n.nextFloat32(),z.value=n.nextStr(),f.addKey(z)}}r.addCurveBinding(c,d,h,_,f)}t(r)})},t}(),e.AnimationClipDecoder=s0([s5("AnimationClip")],e.AnimationClipDecoder);var ls=((e4={}).Vector2="Vector2",e4.Vector3="Vector3",e4.Vector4="Vector4",e4.Color="Color",e4.Float="Float",e4.Texture="Texture",e4.Boolean="Boolean",e4.Integer="Integer",e4),ll=((e8={}).Sky="Sky",e8.Custom="Custom",e8);function lc(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function lu(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 ld(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return lu(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lu(e,void 0)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var lh=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r._dependenceAssets=new Set,r}sJ(t,e);var n=t.prototype;return n.instantiate=function(){var e;return null==(e=this._root)?void 0:e.clone()},n._addDependenceAsset=function(e){this._dependenceAssets.add(e),e._associationSuperResource(this)},n._onDestroy=function(){var t=this;e.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(e){e._disassociationSuperResource(t)})},t}(t1),l_=/*#__PURE__*/function(){function e(e,t){var n=this;this.data=e,this.context=t,this._prefabContextMap=new WeakMap,this._prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,t){n._reject=t,n._resolve=e}),this._reflectionParser=new li(t)}var t=e.prototype;return t.start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},t._parseEntities=function(){var e=this,t=this.data.entities,n=this.context.entityConfigMap,r=this.context.entityMap,a=this._engine;return Promise.all(t.map(function(t){var r,i=null!=(r=t.strippedId)?r:t.id;return t.id=i,n.set(i,t),e._getEntityByConfig(t,a)})).then(function(e){for(var n=0,a=e.length;n<a;n++)r.set(t[n].id,e[n]);return e})},t._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,n=this.context.components,r=[],a=0,i=e.length;a<i;a++)for(var o=e[a],s=t.get(o.id),l=0;l<o.components.length;l++){var c=o.components[l],u=c.refId?c.refId:c.class,d=s.addComponent(ol.getClass(u));n.set(c.id,d);var h=this._reflectionParser.parsePropsAndMethods(d,c);r.push(h)}return Promise.all(r)},t._parsePrefabModification=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.modifications;if(null==l?void 0:l.length){var c=n.get(s);r.push.apply(r,[].concat(l.map(function(t){var n=t.target,r=t.props,a=t.methods,i=n.entityId,o=n.componentId,s=e._prefabContextMap.get(c),l=s.entityMap.get(i),u=s.components.get(o);return u?e._reflectionParser.parsePropsAndMethods(u,{props:r,methods:a}):l?Promise.resolve(e._applyEntityData(l,r)):void 0})))}}(a);return Promise.all(r)},t._parsePrefabRemovedEntities=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedEntities;if(null==l?void 0:l.length){var c=n.get(s);r.push.apply(r,[].concat(l.map(function(t){var n=t.entityId,r=e._prefabContextMap.get(c).entityMap.get(n);r&&r.destroy()})))}}(a);return Promise.all(r)},t._parsePrefabRemovedComponents=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedComponents;if(null==l?void 0:l.length){var c=n.get(s);r.concat.apply(r,[].concat(l.map(function(t){var n=t.componentId,r=e._prefabContextMap.get(c).components.get(n);r&&r.destroy()})))}}(a);return Promise.all(r)},t._organizeEntities=function(){for(var e,t=this.context,n=t.rootIds,r=t.strippedIds,a=n.concat(r),i=ld(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<n.length;s++)this._handleRootEntity(n[s])},t._getEntityByConfig=function(e,t){var n=this;return(e.assetRefId?this._parsePrefab(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return n._applyEntityData(t,e)})},t._parseEntity=function(e,t){var n=new aW(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(n)},t._parsePrefab=function(e,t){var n=this,r=e.assetRefId;return t.resourceManager.getResourceByRef({refId:r}).then(function(r){var a=lc(r,lh)?r.instantiate():r.instantiateSceneRoot(),i=new la(t,lr.Prefab,null);e.parent||n.context.rootIds.push(e.id),n._generateInstanceContext(a,i,""),n._prefabContextMap.set(a,i);var o=n._prefabPromiseMap.get(e.id);if(o)for(var s=0,l=o.length;s<l;s++)o[s].resolve(i);return a})},t._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(n,r){var a,i=null!=(a=t._prefabPromiseMap.get(e.prefabInstanceId))?a:[];i.push({resolve:n,reject:r}),t._prefabPromiseMap.set(e.prefabInstanceId,i)}).then(function(t){var n=e.prefabSource.entityId;return t.entityMap.get(n)})},t._parseChildren=function(e){var t=this.context,n=t.entityConfigMap,r=t.entityMap,a=n.get(e).children;if(a&&a.length>0)for(var i=r.get(e),o=0;o<a.length;o++){var s=a[o],l=r.get(s);i.addChild(l),this._parseChildren(s)}},t._applyEntityData=function(e,t){void 0===t&&(t={}),e.isActive=null!=(n=t.isActive)?n:e.isActive,e.name=null!=(r=t.name)?r:e.name;var n,r,a=t.position,i=t.rotation,o=t.scale,s=t.layer;return a&&e.transform.position.copyFrom(a),i&&e.transform.rotation.copyFrom(i),o&&e.transform.scale.copyFrom(o),s&&(e.layer=s),e},t._generateInstanceContext=function(e,t,n){var r=t.entityMap,a=t.components,i={},o={};r.set(n,e),e._components.forEach(function(t){var r=ol.getClassName(t.constructor);i[r]||(i[r]=e.getComponents(t.constructor,[]),o[r]=0),a.set(n+":"+r+"/"+o[r]++,t)});for(var s=0,l=e.children.length;s<l;s++){var c=e.children[s],u=n?n+"/"+s:""+s;this._generateInstanceContext(c,t,u)}},e}(),lf=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).scene=r,a}sJ(t,e);var n=t.prototype;return n._handleRootEntity=function(e){var t=this.context.entityMap;this.scene.addRootEntity(t.get(e))},n._clearAndResolve=function(){return this.context.clear(),this.scene},t.parse=function(e,n){var r=new oo(e),a=new t(n,new la(e,lr.Scene,r),r);return a.start(),a.promise.then(function(){return r})},t}(l_);function lp(e,t){var n=s9.decode(e),r=new s4(new Uint8Array(e),n.headerLength,n.dataLength);return s8[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.EditorTextureLoader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,sQ({},e,{type:"arraybuffer"})).then(function(e){lp(e,t.engine).then(function(e){n(e)})}).catch(r)})},t}(ol),e.EditorTextureLoader=s0([it("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var lm=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,sQ({},e,{type:"arraybuffer"})).then(function(e){return lp(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){return n._parseKeyframeValue(e,t).then(function(t){e.value=t})}))})).then(function(){r(e)})}).catch(a)}).catch(a)})},n._parseKeyframeValue=function(e,t){var n=e.value;return(void 0===n?"undefined":s$(n))==="object"&&(null==n?void 0:n.refId)?new Promise(function(r){t.getResourceByRef(n).then(function(t){e.value=t,r(e.value)})}):Promise.resolve(e.value)},t}(ol);lm=s0([it(a2.AnimationClip,["ani"])],lm);var lg=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,sQ({},e,{type:"json"})).then(function(e){var a=new oI(t.engine),i=e.layers,o=e.parameters,s=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,l=e.weight,c=e.stateMachine,u=new oz(i);if(u.blendingMode=o,u.weight=l,c){var d=c.states,h=c.transitions,_=c.entryTransitions,f=c.anyTransitions,p=u.stateMachine,m={},g={};d.forEach(function(e,n){var a=e.id,i=e.name,o=e.speed,l=e.wrapMode,c=e.clipStartNormalizedTime,u=e.clipEndNormalizedTime,d=e.clip,h=e.scripts,_=p.addState(i);_.speed=o,_.wrapMode=l,_.clipStartTime=c,_.clipEndTime=u,h.forEach(function(e){_.addStateMachineScript(ol.getClass(e))}),m[a]=_,d&&s.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:r,stateIndex:n,clip:t})})}))}),h.forEach(function(e){var t=n._createTransition(e,m[e.destinationStateId]);g[e.id]=t}),d.forEach(function(e){var t=e.id;e.transitions.forEach(function(e){var n=g[e];n&&m[t].addTransition(n)})}),_.forEach(function(e){p.addEntryStateTransition(n._createTransition(e,m[e.destinationStateId]))}),f.forEach(function(e){p.addAnyStateTransition(n._createTransition(e,m[e.destinationStateId]))})}a.addLayer(u)}),o.forEach(function(e){e.isTrigger?a.addTriggerParameter(e.name):a.addParameter(e.name,e.defaultValue)}),Promise.all(s).then(function(e){e.forEach(function(e){var t=e.layerIndex,n=e.stateIndex,r=e.clip;a.layers[t].stateMachine.states[n].clip=r}),r(a)})}).catch(a)})},n._createTransition=function(e,t){var n=new oM;return n.hasExitTime=e.hasExitTime,n.isFixedDuration=e.isFixedDuration,n.duration=e.duration,n.offset=e.offset,n.exitTime=e.exitTime,n.solo=e.solo,n.mute=e.mute,n._isExit=e.isExit,n.destinationState=t,e.conditions.forEach(function(e){n.addCondition(e.parameterName,e.mode,e.threshold)}),n},t}(ol);lg=s0([it(a2.AnimatorController,["json"],!1)],lg);var lv=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){var n=e.url;return/^data:(.+?);base64,/.test(n)?new a8(function(e){var t=n.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(t),function(e){return e.charCodeAt(0)}).buffer)}):t._request(n,sQ({},e,{type:"arraybuffer"}))},t}(ol);lv=s0([it(a2.Buffer,["bin","r3bin"],!1)],lv);var ly=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,sQ({},e,{type:"arraybuffer"})).then(function(e){var r=new Float32Array(e,0,27),a=new Uint16Array(e,108,1)[0],i=t.engine,o=new nd(i,a);o.filterMode=t5.Trilinear;for(var s=o.mipmapCount,l=110,c=0;c<s;c++)for(var u=a>>c,d=0;d<6;d++){var h=u*u*4,_=new Uint8Array(e,l,h);l+=h,o.setPixelBuffer(t4.PositiveX+d,_,c)}var f=new i8(i),p=new tN;f.diffuseMode=i4.SphericalHarmonics,p.copyFromArray(r),f.diffuseSphericalHarmonics=p,f.specularTexture=o,f.specularTextureDecodeRGBM=!0,n(f)}).catch(function(e){r(e)})})},t}(ol);function lx(e,t,n,r,a,i,o){try{var s=e[i](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,a)}function lb(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function o(e){lx(i,r,a,o,s,"next",e)}function s(e){lx(i,r,a,o,s,"throw",e)}o(void 0)})}}ly=s0([it(a2.Env,["env"])],ly);var lS=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,sQ({},e,{type:"json"})).then(function(e){var i=e.fontName,o=e.fontUrl;o?n._registerFont(i,o).then(function(){r(new ng(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):r(new ng(t.engine,i))}).catch(function(e){a(e)})})},n._registerFont=function(e,t){return lb(function(){var n;return s1(this,function(r){switch(r.label){case 0:return[4,(n=new FontFace(e,"url("+t+")")).load()];case 1:return r.sent(),document.fonts.add(n),[2]}})})()},t}(ol);lS=s0([it(a2.Font,["font"],!1)],lS);var lC=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r}sJ(t,e);var n=t.prototype;return n.instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this.textures,n=this.materials,r=this.meshes;if(t&&this._disassociationSuperResource(t),n&&this._disassociationSuperResource(n),r)for(var a=0,i=r.length;a<i;a++)this._disassociationSuperResource(r[a])},n._disassociationSuperResource=function(e){for(var t=0,n=e.length;t<n;t++)e[t]._disassociationSuperResource(this)},s3(t,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),t}(t1),lT=((e5={})[e5.BYTE=5120]="BYTE",e5[e5.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e5[e5.SHORT=5122]="SHORT",e5[e5.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e5[e5.UNSIGNED_INT=5125]="UNSIGNED_INT",e5[e5.FLOAT=5126]="FLOAT",e5),lA=((e9={}).SCALAR="SCALAR",e9.VEC2="VEC2",e9.VEC3="VEC3",e9.VEC4="VEC4",e9.MAT2="MAT2",e9.MAT3="MAT3",e9.MAT4="MAT4",e9),lE=((e6={}).TRANSLATION="translation",e6.ROTATION="rotation",e6.SCALE="scale",e6.WEIGHTS="weights",e6),lR=((e7={}).Linear="LINEAR",e7.Step="STEP",e7.CubicSpine="CUBICSPLINE",e7),lM=((te={}).PERSPECTIVE="perspective",te.ORTHOGRAPHIC="orthographic",te),lw=((tt={}).OPAQUE="OPAQUE",tt.MASK="MASK",tt.BLEND="BLEND",tt),lP=((tn={})[tn.NEAREST=9728]="NEAREST",tn[tn.LINEAR=9729]="LINEAR",tn),lF=((tr={})[tr.NEAREST=9728]="NEAREST",tr[tr.LINEAR=9729]="LINEAR",tr[tr.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",tr[tr.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",tr[tr.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",tr[tr.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",tr),lL=((ta={})[ta.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",ta[ta.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",ta[ta.REPEAT=10497]="REPEAT",ta),lD=/*#__PURE__*/function(){function e(e,t,n){var r=this;this.glTFResource=e,this.resourceManager=t,this.params=n,this.accessorBufferCache={},this.needAnimatorController=!1,this._resourceCache=new Map,this._progress={taskDetail:{},taskComplete:{loaded:0,total:0}},this._onTaskDetail=function(e,t,n){var a,i=(a=r._progress.taskDetail)[e]||(a[e]={});i.loaded=t,i.total=n,r._setTaskDetailProgress(e,t,n)},this.contentRestorer=new lJ(e)}var t=e.prototype;return t.get=function(t,n){var r=this,a=e._parsers[t];if(!a)return Promise.resolve(null);var i=this._resourceCache,o=void 0===n?""+t:t+":"+n,s=i.get(o);if(s)return s;var l=lO[t],c=!!lV[t];if(l){var u=this.glTF[l];u&&(void 0===n||u[n])?void 0===n?s=8===t?u.map(function(e,n){return r.get(t,n)}):Promise.all(u.map(function(e,n){return r.get(t,n)})):(s=a.parse(this,n),c&&this._handleSubAsset(s,t,n)):s=Promise.resolve(null)}else s=a.parse(this,n),c&&this._handleSubAsset(s,t,n);return i.set(o,s),s},t.parse=function(){var e=this,t=this.get(0).then(function(t){return e.glTF=t,e.needAnimatorController=!!(t.skins||t.animations),Promise.all([e.get(1),e.get(5),e.get(6),e.get(7),e.get(9),e.get(10),e.get(11),e.get(2)]).then(function(){var t=e.glTFResource,n=t.animatorController;return n&&(t._defaultSceneRoot.addComponent(oD).animatorController=n),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},t._addTaskCompletePromise=function(e){var t=this,n=this._progress.taskComplete;n.total+=1,e.then(function(){t._setTaskCompleteProgress(++n.loaded,n.total)})},t._handleSubAsset=function(e,t,n){var r,a=this,i=lV[t];if(8===t)((r=this.glTFResource)[i]||(r[i]=[]))[n]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==n?a.glTFResource[i]=e:((r=a.glTFResource)[i]||(r[i]=[]))[n]=e,7===t)for(var r,s,l=0,c=e.length;l<c;l++){var u=e[l];a.resourceManager._onSubAssetSuccess(o,i+"["+n+"]["+l+"]",u)}else a.resourceManager._onSubAssetSuccess(o,""+i+(void 0===n?"":"["+n+"]"),e),2===t&&(null!=(s=a.glTF.scene)?s:0)===n&&a.resourceManager._onSubAssetSuccess(o,"defaultSceneRoot",e)})}},e.addParser=function(e,t){this._parsers[e]=t},e}();lD._parsers={};var lB=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},lI=((ti={})[ti.Schema=0]="Schema",ti[ti.Validator=1]="Validator",ti[ti.Scene=2]="Scene",ti[ti.Buffer=3]="Buffer",ti[ti.BufferView=4]="BufferView",ti[ti.Texture=5]="Texture",ti[ti.Material=6]="Material",ti[ti.Mesh=7]="Mesh",ti[ti.Entity=8]="Entity",ti[ti.Skin=9]="Skin",ti[ti.Animation=10]="Animation",ti[ti.AnimatorController=11]="AnimatorController",ti),lO=((th={})[2]="scenes",th[3]="buffers",th[5]="textures",th[6]="materials",th[7]="meshes",th[8]="nodes",th[9]="skins",th[10]="animations",th[4]="bufferViews",th),lV=((t_={})[2]="_sceneRoots",t_[5]="textures",t_[6]="materials",t_[7]="meshes",t_[8]="entities",t_[9]="skins",t_[10]="animations",t_[11]="animatorController",t_);function lN(e){return function(t){var n=new t;lD.addParser(e,n)}}var lk=/*#__PURE__*/function(){function t(){}return t.floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new tB(e[r],e[r+1]);return n},t.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new tT(e[r],e[r+1],e[r+2]);return n},t.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new tI(e[r],e[r+1],e[r+2],e[r+3]);return n},t.floatBufferToColorArray=function(e,t){var n=e.length,r=Array(n/(t?3:4));if(t)for(var a=0;a<n;a+=3)r[a/3]=new tO(e[a],e[a+1],e[a+2],1);else for(var i=0;i<n;i+=4)r[i/4]=new tO(e[i],e[i+1],e[i+2],e[i+3]);return r},t.getAccessorTypeSize=function(e){switch(e){case lA.SCALAR:return 1;case lA.VEC2:return 2;case lA.VEC3:return 3;case lA.VEC4:case lA.MAT2:return 4;case lA.MAT3:return 9;case lA.MAT4:return 16}},t.getComponentType=function(e){switch(e){case lT.BYTE:return Int8Array;case lT.UNSIGNED_BYTE:return Uint8Array;case lT.SHORT:return Int16Array;case lT.UNSIGNED_SHORT:return Uint16Array;case lT.UNSIGNED_INT:return Uint32Array;case lT.FLOAT:return Float32Array}},t.getNormalizedComponentScale=function(e){switch(e){case lT.BYTE:return 1/127;case lT.UNSIGNED_BYTE:return 1/255;case lT.SHORT:return 1/32767;case lT.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},t.getAccessorBuffer=function(e,n,r){var a,i=r.componentType,o=t.getComponentType(i),s=t.getAccessorTypeSize(r.type),l=o.BYTES_PER_ELEMENT,c=s*l,u=r.count;if(void 0!==r.bufferView){var d=r.bufferView,h=n[d];a=e.get(lI.BufferView,r.bufferView).then(function(t){var n,a,_,f=h.buffer,p=null!=(n=t.byteOffset)?n:0,m=null!=(a=r.byteOffset)?a:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=d+":"+i+":"+v+":"+u,x=e.accessorBufferCache;if(!(_=x[y])){var b=p+v*g,S=g/l*u,C=new o(t.buffer,b,S);x[y]=_=new lB(C,!0,g),_.restoreInfo=new l3(new l4(f,o,b,S))}}else{var T=p+m,A=u*s;(_=new lB(new o(t.buffer,T,A),!1,c)).restoreInfo=new l3(new l4(f,o,T,A))}return _})}else{var _=u*s,f=new lB(new o(_),!1,c);f.restoreInfo=new l3(new l4(void 0,o,void 0,_)),a=Promise.resolve(f)}return r.sparse?a.then(function(n){return t.processingSparseData(e,r,n).then(function(){return n})}):a},t.bufferToVector3Array=function(e,n,r,a,i){for(var o=n/e.BYTES_PER_ELEMENT,s=e.length/r,l=Array(r),c=a?t.getNormalizedComponentScale(i):1,u=0;u<r;u++){var d=o+u*s;l[u]=new tT(e[d]*c,e[d+1]*c,e[d+2]*c)}return l},t.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},t.processingSparseData=function(e,n,r){var a=r.restoreInfo,i=e.glTF.bufferViews,o=t.getAccessorTypeSize(n.type),s=t.getComponentType(n.componentType),l=r.data.slice(),c=n.sparse,u=c.count,d=c.indices,h=c.values,_=i[d.bufferView],f=i[h.bufferView];return Promise.all([e.get(lI.BufferView,d.bufferView),e.get(lI.BufferView,h.bufferView)]).then(function(e){var n,i,c,p,m=e[0],g=e[1],v=(null!=(n=d.byteOffset)?n:0)+(null!=(i=m.byteOffset)?i:0),y=m.byteLength,x=(null!=(c=h.byteOffset)?c:0)+(null!=(p=g.byteOffset)?p:0),b=g.byteLength;a.typeSize=o,a.sparseCount=u;var S=t.getComponentType(d.componentType),C=y/S.BYTES_PER_ELEMENT,T=new S(m.buffer,v,C);a.sparseIndices=new l4(_.buffer,S,v,C);var A=b/s.BYTES_PER_ELEMENT,E=new s(g.buffer,x,A);a.sparseValues=new l4(f.buffer,s,x,A);for(var R=0;R<u;R++)for(var M=T[R],w=0;w<o;w++)l[M*o+w]=E[R*o+w];r.data=l})},t.getIndexFormat=function(e){switch(e){case lT.UNSIGNED_BYTE:return r6.UInt8;case lT.UNSIGNED_SHORT:return r6.UInt16;case lT.UNSIGNED_INT:return r6.UInt32}},t.getElementFormat=function(e,t,n){if(void 0===n&&(n=!1),e==lT.FLOAT)switch(t){case 1:return r7.Float;case 2:return r7.Vector2;case 3:return r7.Vector3;case 4:return r7.Vector4}if(e==lT.SHORT)switch(t){case 2:return n?r7.NormalizedShort2:r7.Short2;case 3:case 4:return n?r7.NormalizedShort4:r7.Short4}if(e==lT.UNSIGNED_SHORT)switch(t){case 2:return n?r7.NormalizedUShort2:r7.UShort2;case 3:case 4:return n?r7.NormalizedUShort4:r7.UShort4}if(e==lT.BYTE)switch(t){case 2:case 3:case 4:return n?r7.NormalizedByte4:r7.Byte4}if(e==lT.UNSIGNED_BYTE)switch(t){case 2:case 3:case 4:return n?r7.NormalizedUByte4:r7.UByte4}},t.loadImageBuffer=function(e,t){return new Promise(function(n,r){var a=new window.Blob([e],{type:t}),i=new Image;i.onerror=function(){r(Error("Failed to load image buffer"))},i.onload=function(){requestAnimationFrame(function(){n(i),i.onload=null,i.onerror=null,i.onabort=null})},i.crossOrigin="anonymous",i.src=URL.createObjectURL(a)})},t.parseGLB=function(e,t){var n={JSON:0x4e4f534a,BIN:5130562},r=new DataView(t),a={magic:r.getUint32(0,!0),version:r.getUint32(4,!0),length:r.getUint32(8,!0)};if(0x46546c67!==a.magic)return{originBuffer:t};var i=r.getUint32(12,!0),o=r.getUint32(16,!0);if(o!==n.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+o.toString(16)),null;for(var s=new Uint8Array(t,20,i),l=JSON.parse(nT.decodeText(s)),c=[],u=20+i,d=e.contentRestorer.glbBufferSlices;u<a.length;){if(i=r.getUint32(u,!0),(o=r.getUint32(u+4,!0))!==n.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+o.toString(16)),null;var h=u+8,_=t.slice(h,h+i);c.push(_),d.push(new tB(h,i)),u+=i+8}return{glTF:l,buffers:c}},t.parseSampler=function(e,t){var n=t.filterMode,r=t.wrapModeU,a=t.wrapModeV;void 0!==n&&(e.filterMode=n),void 0!==r&&(e.wrapModeU=r),void 0!==a&&(e.wrapModeV=a)},t.getSamplerInfo=function(t){var n=t.minFilter,r=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(n||r)&&(o.mipmap=n>=lF.NEAREST_MIPMAP_NEAREST,r===lP.NEAREST?o.filterMode=t5.Point:n<=lF.LINEAR_MIPMAP_NEAREST?o.filterMode=t5.Bilinear:o.filterMode=t5.Trilinear),a&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[a]),i&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[i]),o},t}(),lz=((to={})[to.None=0]="None",to[to.BasisLZ=1]="BasisLZ",to[to.Zstd=2]="Zstd",to[to.ZLib=3]="ZLib",to),lU=/*#__PURE__*/function(){function e(e){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.keyValue={},this.globalData=null,this.parse(e)}return e.prototype.parse=function(e){var t=e.buffer,n=e.byteOffset,r=new s4(e,12);this.vkFormat=r.nextUint32(),this.typeSize=r.nextUint32(),this.pixelWidth=r.nextUint32(),this.pixelHeight=r.nextUint32(),this.pixelDepth=r.nextUint32(),this.layerCount=r.nextUint32(),this.faceCount=r.nextUint32();var a=Math.max(1,r.nextUint32());this.supercompressionScheme=r.nextUint32();var i=r.nextUint32(),o=r.nextUint32(),s=r.nextUint32(),l=r.nextUint32(),c=r.nextUint64(),u=r.nextUint64(),d=Array(a),h=24*a,_=new s4(e,r.offset,h);this.levels=d;for(var f=0;f<a;f++)d[f]={levelData:new Uint8Array(t,n+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new s4(e,i,o),m={vendorId:p.skip(4).nextUint16(),descriptorType:p.nextUint16(),versionNumber:p.nextUint16(),descriptorBlockSize:p.nextUint16(),colorModel:p.nextUint8(),colorPrimaries:p.nextUint8(),transferFunction:p.nextUint8(),flags:p.nextUint8(),texelBlockDimension:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],bytesPlane:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],samples:[]};this.dataFormatDescriptor=m;for(var g=(m.descriptorBlockSize/4-6)/4,v=0;v<g;v++){var y={bitOffset:p.nextUint16(),bitLength:p.nextUint8(),channelType:p.nextUint8(),samplePosition:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&y.channelType?(y.sampleLower=p.nextInt32(),y.sampleUpper=p.nextInt32()):(y.sampleLower=p.nextUint32(),y.sampleUpper=p.nextUint32()),m.samples[v]=y}for(var x=new s4(e,s,l,!0);x.position<l;){var b=x.nextUint32(),S=x.scan(b),C=nT.decodeText(S),T=x.nextUint8Array(b-S.byteLength-1);this.keyValue[C]=C.match(/^ktx/i)?nT.decodeText(T).replace(/^(.*)\x00$/,"$1"):T;var A=b%4?4-b%4:0;x.skip(A)}if(u<=0)return this;for(var E=new s4(e,c,u,!0),R=E.nextUint16(),M=E.nextUint16(),w=E.nextUint32(),P=E.nextUint32(),F=E.nextUint32(),L=E.nextUint32(),D=Array(a),B=0;B<a;B++)D[B]={imageFlags:E.nextUint32(),rgbSliceByteOffset:E.nextUint32(),rgbSliceByteLength:E.nextUint32(),alphaSliceByteOffset:E.nextUint32(),alphaSliceByteLength:E.nextUint32()};var I=c+E.position,O=I+w,V=O+P,N=V+F,k=new Uint8Array(t,n+I,w),z=new Uint8Array(t,n+O,P),U=new Uint8Array(t,n+V,F),G=new Uint8Array(t,n+N,L);this.globalData={endpointCount:R,selectorCount:M,imageDescs:D,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},s3(e,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),e}(),lG=((ts={})[ts.ASTC=0]="ASTC",ts[ts.BC7=1]="BC7",ts[ts.BC1_BC3=2]="BC1_BC3",ts[ts.PVRTC=3]="PVRTC",ts[ts.ETC=4]="ETC",ts[ts.R8=5]="R8",ts[ts.R8G8=6]="R8G8",ts[ts.R8G8B8A8=7]="R8G8B8A8",ts),lH=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=4),this.limitedCount=e,this._workerCreator=t,this._taskQueue=[],this._workerStatus=0,this._workerItems=Array(e)}var t=e.prototype;return t.prepareWorker=function(){for(var e=this.limitedCount,t=Array(e),n=0;n<e;n++)t.push(this._initWorker(n));return Promise.all(t)},t.postMessage=function(e){var t=this;return new Promise(function(n,r){var a=t._getIdleWorkerId();if(-1!==a){t._workerStatus|=1<<a;var i,o=t._workerItems;Promise.resolve(null!=(i=o[a])?i:t._initWorker(a)).then(function(){var t=o[a];t.resolve=n,t.reject=r,t.worker.postMessage(e)}).catch(r)}else t._taskQueue.push({resolve:n,reject:r,message:e})})},t.destroy=function(){for(var e=this._workerItems,t=0,n=e.length;t<n;t++){var r=e[t];r.worker.terminate(),r.reject=null,r.resolve=null}e.length=0,this._taskQueue.length=0,this._workerStatus=0},t._initWorker=function(e){var t=this;return Promise.resolve(this._workerCreator()).then(function(n){return n.addEventListener("message",t._onMessage.bind(t,e)),t._workerItems[e]={worker:n,resolve:null,reject:null},n})},t._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},t._onMessage=function(e,t){var n=t.data.error;n?this._workerItems[e].reject(n):this._workerItems[e].resolve(t.data),this._nextTask(e)},t._nextTask=function(e){if(this._taskQueue.length){var t=this._taskQueue.shift(),n=this._workerItems[e];n.resolve=t.resolve,n.reject=t.reject,n.worker.postMessage(t.message)}else this._workerStatus^=1<<e},e}(),lW=/*#__PURE__*/function(){function e(e){this.workerLimitCount=e}var t=e.prototype;return t.init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},t.destroy=function(){this._transcodeWorkerPool.destroy()},t._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new lH(this.workerLimitCount,function(){return new Promise(function(n,r){var a=new Worker(e);a.addEventListener("message",function(e){e.data.error?r(e.data.error):n(a)}),a.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},e}();function lj(){var e,t=function(t){return e||(e=new Promise(function(e,n){var r={wasmBinary:t,onRuntimeInitialized:function(){return e(r)},onAbort:n};self.BASIS(r)}).then(function(e){return e.initializeBasis(),e.KTX2File})),e};self.onmessage=function(e){var n=e.data;switch(n.type){case"init":t(n.transcoderWasm).then(function(){self.postMessage("init-completed")}).catch(function(e){return self.postMessage({error:e})});break;case"transcode":t().then(function(e){var t=lK(n.buffer,n.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var lX=function(e){return tl||(tl=new Promise(function(t,n){var r={wasmBinary:e,onRuntimeInitialized:function(){return t(r)},onAbort:n};self.BASIS(r)}).then(function(e){return e.initializeBasis(),e.KTX2File})),tl};function lK(e,t,n){var r=new n(new Uint8Array(e));function a(){r.close(),r.delete()}if(!r.isValid())throw a(),Error("Invalid or unsupported .ktx2 file");if(!r.startTranscoding())throw a(),Error("KTX2 startTranscoding failed");for(var i=r.getWidth(),o=r.getHeight(),s=r.getLayers()||1,l=r.getLevels(),c=r.getHasAlpha(),u=r.getFaces(),d=function(e,t){switch(e){case 2:return t?3:2;case 4:return t?1:0;case 3:return t?9:8;case 7:return 13;case 0:return 10;case 1:return 7}}(t,c),h=Array(u),_=2===d||3===d||7===d,f=0;f<u;f++){for(var p=Array(l),m=0;m<l;m++){for(var g=Array(s),v=void 0,y=void 0,x=0;x<s;x++){var b=r.getImageLevelInfo(m,x,f);_&&0===m&&(i!==b.width||o!==b.height)?console.warn("KTX2 transcode to BC will resize to width: "+(i=v=b.width)+", height: "+(o=y=b.height)+". You'd better use an image whose size if multiple of 4."):(v=b.origWidth,y=b.origHeight);var S=new Uint8Array(r.getImageTranscodedSizeInBytes(m,x,0,d));if(!r.transcodeImage(S,m,x,f,d,0,-1,-1))throw a(),Error("transcodeImage failed.");g[x]=S}p[m]={data:function(e){if(1===e.length)return e[0];for(var t=0,n=0;n<e.length;n++)t+=e[n].byteLength;for(var r=new Uint8Array(t),a=0,i=0;i<e.length;i++)r.set(e[i],a),a+=e[i].byteLength;return r}(g),width:v,height:y}}h[f]=p}return a(),{faces:h,width:i,height:o,hasAlpha:c,faceCount:u,format:d}}var lY=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}sJ(t,e);var n=t.prototype;return n._initTranscodeWorkerPool=function(){var e=this;return Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*nG8SR6vCgXgAAAAAAAAAAAAAARQnAQ/basis_transcoder.js").then(function(e){return e.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qEUfQ7317KsAAAAAAAAAAAAAARQnAQ/basis_transcoder.wasm").then(function(e){return e.arrayBuffer()})]).then(function(t){var n=t[0],r=t[1];if(0===e.workerLimitCount)return new Promise(function(e,t){var a=document.createElement("script");a.src=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),document.body.appendChild(a),a.onload=function(){lX(r).then(function(){e(null)})},a.onerror=function(){t()}});var a=lj.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+n+"\n "+lK.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,r)})},n.transcode=function(e,t){return 0===this.workerLimitCount?lX().then(function(n){return lK(e,t,n)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},t}(lW);function lq(){var e,t=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.init=function(){return this._initPromise||(this._initPromise=fetch(e.WasmModuleURL).then(function(e){if(e.ok)return e.arrayBuffer();throw Error("Could not fetch the wasm component for the Zstandard decompression lib: "+e.status+" - "+e.statusText)}).then(function(t){return WebAssembly.instantiate(t,e.IMPORT_OBJECT)}).then(this._init)),this._initPromise},t._init=function(t){e.instance=t.instance,e.IMPORT_OBJECT.env.emscripten_notify_memory_growth()},t.decode=function(t,n){if(void 0===n&&(n=0),!e.instance)throw Error("ZSTDDecoder: Await .init() before decoding.");var r=e.instance.exports,a=t.byteLength,i=r.malloc(a);e.heap.set(t,i),n=n||Number(r.ZSTD_findDecompressedSize(i,a));var o=r.malloc(n),s=r.ZSTD_decompress(o,n,i,a),l=e.heap.slice(o,o+s);return r.free(i),r.free(o),l},e}();t.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){t.heap=new Uint8Array(t.instance.exports.memory.buffer)}}},t.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var n=new t;self.onmessage=function(t){var r,a=t.data;switch(a.type){case"init":(r=a.transcoderWasm,e=WebAssembly.instantiate(r,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(e){return e.instance.exports})).then(function(){self.postMessage("init-completed")}).catch(function(e){self.postMessage({error:e})});break;case"transcode":e.then(function(e){var t,r,i,o,s;(t=a.data,r=a.needZstd,o=Array(i=t.length),s=Promise.resolve(),r&&(n.init(),s=n._initPromise),s.then(function(){for(var a=0;a<i;a++){for(var s=t[a].length,l=Array(s),c=0;c<s;c++){var u=t[a][c],d=u.buffer,h=u.levelHeight,_=u.levelWidth,f=u.uncompressedByteLength;r&&(d=n.decode(d.slice(),f));var p=d.byteLength/i,m=d.byteOffset,g=function(e,t,n,r){var a=(n+3>>2)*(r+3>>2),i=16*a+65535>>16,o=e.memory,s=i+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*a);return l.set(t),0===e.transcode(a)?l:null}(e,new Uint8Array(d.buffer,m+a*p,p),_,h);if(g)l[c]={data:g.slice(),width:_,height:h};else throw"buffer decoded error"}o[a]=l}return o})).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var lQ=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).type=n,r}sJ(t,e);var n=t.prototype;return n._initTranscodeWorkerPool=function(){var e=this;return fetch(t.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var n=lq.toString(),r=URL.createObjectURL(new Blob([n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(r,t)})},n.transcode=function(e){for(var t=e.supercompressionScheme===lz.Zstd,n=e.levels.length,r=e.faceCount,a={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},i={type:"transcode",format:0,needZstd:t,data:Array(r)},o=i.data,s=0;s<r;s++){for(var l=Array(n),c=0;c<n;c++){var u=e.levels[c],d=Math.floor(e.pixelWidth/(1<<c))||1,h=Math.floor(e.pixelHeight/(1<<c))||1,_=u.levelData.buffer,f=u.levelData.byteOffset,p=u.levelData.byteLength;l[c]={buffer:new Uint8Array(_,f,p),levelWidth:d,levelHeight:h,uncompressedByteLength:u.uncompressedByteLength}}o[s]=l}return this._transcodeWorkerPool.postMessage(i).then(function(e){return a.faces=e,a.hasAlpha=!0,a})},t}(lW);lQ.transcoderMap=((tf={})[lG.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",tf),e.KTX2Loader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.initialize=function(e,n){if(n.ktx2Loader){var r=n.ktx2Loader;return(r.priorityFormats&&(t._priorityFormats.etc1s=r.priorityFormats,t._priorityFormats.uastc=r.priorityFormats),1===r.transcoder)?t._getKhronosTranscoder(r.workerCount).init():t._getBinomialLLCTranscoder(r.workerCount).init()}},n.load=function(e,n){return new a8(function(r,a,i,o){n._request(e.url,{type:"arraybuffer"}).onProgress(i,o).then(function(r){return t._parseBuffer(new Uint8Array(r),n.engine,e.params).then(function(e){var n=e.engine,r=e.result,a=e.targetFormat,i=e.params;return t._createTextureByBuffer(n,r,a,i)})}).then(r).catch(a)})},t.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},t._parseBuffer=function(e,n,r){var a,i,o=new lU(e),s=null!=(a=null==r?void 0:r.priorityFormats)?a:t._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=t._decideTargetFormat(n,o,s);if(!t._isBinomialInit&&lQ.transcoderMap[l]&&o.isUASTC){var c=t._getKhronosTranscoder();i=c.init().then(function(){return c.transcode(o)})}else{var u=t._getBinomialLLCTranscoder();i=u.init().then(function(){return u.transcode(e,l)})}return i.then(function(e){return{engine:n,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},t._createTextureByBuffer=function(e,t,n,r){var a,i=t.width,o=t.height,s=t.faces,l=s.length,c=s[0],u=c.length>1,d=this._getEngineTextureFormat(n,t);if(6!==l){a=new nc(e,i,o,d,u);for(var h=0;h<c.length;h++){var _=c[h].data;a.setPixelBuffer(_,h)}}else{a=new nd(e,o,d,u);for(var f=0;f<s.length;f++)for(var p=s[f],m=0;m<c.length;m++)a.setPixelBuffer(t4.PositiveX+f,p[m].data,m)}return r&&(a.wrapModeU=r[0],a.wrapModeV=r[1],a.filterMode=r[2],a.anisoLevel=r[3]),a},t._decideTargetFormat=function(e,t,n){var r=e._hardwareRenderer,a=this._detectSupportedFormat(r,n);return a!==lG.PVRTC||tC.isPowerOf2(t.pixelWidth)&&tC.isPowerOf2(t.pixelHeight)&&t.pixelWidth===t.pixelHeight?null===a?(no.warn("Can't support any compressed texture, downgrade to RGBA8"),lG.R8G8B8A8):a:(no.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),lG.R8G8B8A8)},t._detectSupportedFormat=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],a=this._supportedMap[r];if(a){for(var i=0;i<a.length;i++)if(e.canIUse(a[i]))return r}else switch(t[n]){case lG.R8G8B8A8:return r;case lG.R8:case lG.R8G8:if(e.isWebGL2)return r}}return null},t._getBinomialLLCTranscoder=function(e){var n;return void 0===e&&(e=4),t._isBinomialInit=!0,null!=(n=this._binomialLLCTranscoder)?n:this._binomialLLCTranscoder=new lY(e)},t._getKhronosTranscoder=function(e){var t;return void 0===e&&(e=4),null!=(t=this._khronosTranscoder)?t:this._khronosTranscoder=new lQ(e,lG.ASTC)},t._getEngineTextureFormat=function(e,t){var n=t.hasAlpha;switch(e){case lG.ASTC:return t9.ASTC_4x4;case lG.ETC:return n?t9.ETC2_RGBA8:t9.ETC2_RGB;case lG.BC7:return t9.BC7;case lG.BC1_BC3:return n?t9.BC3:t9.BC1;case lG.PVRTC:return n?t9.PVRTC_RGBA4:t9.PVRTC_RGB4;case lG.R8G8B8A8:return t9.R8G8B8A8}},t}(ol),e.KTX2Loader._isBinomialInit=!1,e.KTX2Loader._priorityFormats={etc1s:[lG.ETC,lG.BC7,lG.ASTC,lG.BC1_BC3,lG.PVRTC],uastc:[lG.ASTC,lG.BC7,lG.ETC,lG.BC1_BC3,lG.PVRTC]},e.KTX2Loader._supportedMap=((tp={})[lG.ASTC]=[nZ.astc],tp[lG.ETC]=[nZ.etc],tp[lG.BC7]=[nZ.bptc],tp[lG.BC1_BC3]=[nZ.s3tc],tp[lG.PVRTC]=[nZ.pvrtc,nZ.pvrtc_webkit],tp),e.KTX2Loader=s0([it(a2.KTX2,["ktx2"])],e.KTX2Loader);var lZ=((tc={})[tc.BinomialLLC=0]="BinomialLLC",tc[tc.Khronos=1]="Khronos",tc),lJ=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e}sJ(n,t);var r=n.prototype;return r.restoreContent=function(){var t=this;return new a8(function(n,r){Promise.all(t.bufferRequests.map(function(e){return a6(e.url,e.config)})).then(function(a){if(t.isGLB){var i=t.glbBufferSlices,o=a[0],s=i.length;a.length=s;for(var l=0;l<s;l++){var c=i[l];a[l]=o.slice(c.x,c.x+c.y)}}a8.all(t.bufferTextures.map(function(t){var n,r=t.bufferView,i=new Uint8Array(a[r.buffer],null!=(n=r.byteOffset)?n:0,r.byteLength),o=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(i,o.engine).then(function(e){for(var t=e.result.faces[0],n=0;n<t.length;n++)o.setPixelBuffer(t[n].data,n)}):lk.loadImageBuffer(i,t.mimeType).then(function(e){o.setImageSource(e),o.generateMipmaps()})})).then(function(){for(var e,r=ld(t.meshes);!(e=r()).done;){for(var i,o=e.value,s=o.mesh,l=ld(o.vertexBuffers);!(i=l()).done;){var c=i.value,u=t._getBufferData(a,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=t._getBufferData(a,o.indexBuffer);s.setIndices(d)}for(var h,_=ld(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(a,m.buffer);if(p.deltaPositions=lk.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=lk.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,b=t._getBufferData(a,x.buffer);p.deltaTangents=lk.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}n(t.resource)}).catch(r)}).catch(r)})},r._getBufferData=function(e,t){var n,r=t.main;if(r){var a=e[r.bufferIndex];n=new r.TypedArray(a,r.byteOffset,r.length)}else n=new r.TypedArray(r.length);var i=t.sparseCount;if(i)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],d=new c.TypedArray(u,c.byteOffset,c.length),h=t.typeSize,_=0;_<i;_++)for(var f=l[_],p=0;p<h;p++)n[f*h+p]=d[_*h+p];return n},n}(t2),l$=function(e,t){this.url=e,this.config=t},l0=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},l1=function(){this.vertexBuffers=[],this.blendShapes=[]},l2=function(e,t){this.buffer=e,this.data=t},l3=function(e,t,n,r,a){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=a},l4=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},l8=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},l5=function(e,t,n,r,a){this.buffer=e,this.byteOffset=t,this.count=n,this.normalized=r,this.componentType=a},l9=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.createAndParse=function(e,t,n){for(var r=arguments.length,a=Array(r>3?r-3:0),i=3;i<r;i++)a[i-3]=arguments[i];throw"Not implemented."},t.additiveParse=function(e,t,n,r){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];throw"Not implemented."},e}(),l6=((tu={})[tu.CreateAndParse=0]="CreateAndParse",tu[tu.AdditiveParse=1]="AdditiveParse",tu),l7=/*#__PURE__*/function(){function e(){}return e.executeExtensionsCreateAndParse=function(t,n,r){void 0===t&&(t={});for(var a=arguments.length,i=Array(a>3?a-3:0),o=3;o<a;o++)i[o-3]=arguments[o];for(var s=null,l=Object.keys(t),c=l.length-1;c>=0;--c){var u=l[c],d=t[u];if(s=e._createAndParse.apply(e,[].concat([u,n,d,r],i)))return s}},e.executeExtensionsAdditiveAndParse=function(t,n,r,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];for(var l in t){var c=t[l];e._additiveParse.apply(e,[].concat([l,n,r,c,a],o))}},e.hasExtensionParser=function(t){var n;return!!(null==(n=e._extensionParsers[t])?void 0:n.length)},e.getExtensionParser=function(t,n){var r=e._extensionParsers[t],a=null==r?void 0:r.length;if(a)for(var i=a-1;i>=0;--i){var o=r[i];if(o._mode===n)return o}},e._addExtensionParser=function(t,n){e._extensionParsers[t]||(e._extensionParsers[t]=[]),e._extensionParsers[t].push(n)},e._createAndParse=function(t,n,r,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];var l=e.getExtensionParser(t,l6.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat([n,r,a],o))},e._additiveParse=function(t,n,r,a,i){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=e.getExtensionParser(t,l6.AdditiveParse);c&&c.additiveParse.apply(c,[].concat([n,r,a,i],s))},e}();function ce(e,t){return function(n){var r=new n;r._mode=t,l7._addExtensionParser(e,r)}}function ct(){if(tg)return tg;var e,t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),n=id._detectSIMDSupported()?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";function r(e){for(var n=new Uint8Array(e.length),r=0;r<e.length;++r){var a=e.charCodeAt(r);n[r]=a>96?a-97:a>64?a-39:a+4}for(var i=0,o=0;o<e.length;++o)n[i++]=n[o]<60?t[n[o]]:(n[o]-60)*64+n[++o];return n.buffer.slice(0,i)}tg=WebAssembly.instantiate(r(n)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:tg,useWorkers:function(e){this.workerCount=null!=e?e:this.workerCount,function(e){for(var t=new Blob(["var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r(n))+']), {}).then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\nself.onmessage = workerProcess;\nfunction decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\nfunction workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }'],{type:"text/javascript"}),a=URL.createObjectURL(t),i=0;i<e;++i)o[i]=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}(a);URL.revokeObjectURL(a)}(this.workerCount)},decodeGltfBuffer:function(t,n,r,l,c){return(this.workerCount>0&&0===o.length&&this.useWorkers(),o.length>0)?function(e,t,n,r,a){for(var i=o[0],l=1;l<o.length;++l)o[l].pending<i.pending&&(i=o[l]);return new Promise(function(o,l){var c=new Uint8Array(n),u=s++;i.pending+=e,i.requests[u]={resolve:o,reject:l},i.object.postMessage({id:u,count:e,size:t,source:c,mode:r,filter:a},[c.buffer])})}(t,n,r,i[l],a[c]):tg.then(function(){var o=new Uint8Array(t*n);return function(t,n,r,a,i,o){var s=e.exports.sbrk,l=r+3&-4,c=s(l*a),u=s(i.length),d=new Uint8Array(e.exports.memory.buffer);d.set(i,u);var h=t(c,r,a,u,i.length);if(0==h&&o&&o(c,l,a),n.set(d.subarray(c,c+r*a)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)}(e.exports[i[l]],o,t,n,r,e.exports[a[c]]),o})},release:function(){for(var e=0;e<o.length;e++)o[e].object.terminate()}}});var a={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},o=[],s=0;return tg}l7._extensionParsers={},e.GLTFSchemaParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.parse=function(e){var t=e.glTFResource,n=e.contentRestorer,r=e.resourceManager,a=t.url,i=n.bufferRequests,o={type:"arraybuffer"},s=r._getRemoteUrl(a);return r._requestByRemoteUrl(s,o).onProgress(void 0,e._onTaskDetail).then(function(t){var n=lk.parseGLB(e,t);return(null==n?void 0:n.glTF)&&i.push(new l$(s,o)),n}).then(function(t){return(null==t?void 0:t.glTF)?(n.isGLB=!0,e.buffers=t.buffers,t.glTF):(n.isGLB=!1,JSON.parse(nT.decodeText(new Uint8Array(t.originBuffer))))})},t}(l7),e.GLTFSchemaParser=s0([lN(lI.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return sJ(n,t),n.prototype.parse=function(e,t){var r=e.glTF.animations[t],a=r.name;return Promise.resolve(l7.executeExtensionsCreateAndParse(r.extensions,e,r)||n._parseStandardProperty(e,new ov(void 0===a?"AnimationClip"+t:a),r)).then(function(t){return l7.executeExtensionsAdditiveAndParse(r.extensions,e,t,r),t})},n._parseStandardProperty=function(e,t,n){for(var r=function(t,n){var r=c[t],a=o[r.input],i=o[r.output];_.push(Promise.all([lk.getAccessorBuffer(e,s,a),lk.getAccessorBuffer(e,s,i)]).then(function(e){var n,a,o=e[0].data,s=e[1].data;if(i.normalized){for(var l=lk.getNormalizedComponentScale(i.componentType),c=new Float32Array(s.length),u=0,h=s.length;u<h;u++)c[u]=s[u]*l;s=c}var _=s.length/o.length;switch(null!=(n=r.interpolation)?n:lR.Linear){case lR.CubicSpine:a=oy.CubicSpine;break;case lR.Step:a=oy.Step;break;case lR.Linear:a=oy.Linear}o[o.length-1],d[t]={type:i.type,interpolation:a,input:o,output:s,outputSize:_}}))},a=this,i=e.glTF,o=i.accessors,s=i.bufferViews,l=n.channels,c=n.samplers,u=c.length,d=Array(u),h=e.get(lI.Entity),_=[],f=0;f<u;f++)r(f);return _.push(e.get(lI.Scene)),Promise.all(_).then(function(){for(var n=0,r=l.length;n<r;n++){for(var o=l[n],s=o.target,c=h[s.node],u="",_=c;_.parent;)u=""===u?""+_.name:_.name+"/"+u,_=_.parent;if(-1!==e.glTFResource.sceneRoots.indexOf(_)){var f=void 0,p=void 0;switch(s.path){case lE.TRANSLATION:f=rp,p="position";break;case lE.ROTATION:f=rp,p="rotationQuaternion";break;case lE.SCALE:f=rp,p="scale";break;case lE.WEIGHTS:f=aK,p="blendShapeWeights"}var m=a._addCurve(s.path,o,d);if(s.path===lE.WEIGHTS)for(var g=i.nodes[s.node].mesh,v=0,y=i.meshes[g].primitives.length;v<y;v++)t.addCurveBinding(u,f,v,p,m);else t.addCurveBinding(u,f,p,m)}}return t})},n._addCurve=function(t,n,r){var a=r[n.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case lE.TRANSLATION:case lE.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,u=0,d=0,h=i.length;d<h;d++){var _=new oU;_.time=i[d],c===oy.CubicSpine?(_.inTangent=new tT(o[u++],o[u++],o[u++]),_.value=new tT(o[u++],o[u++],o[u++]),_.outTangent=new tT(o[u++],o[u++],o[u++])):_.value=new tT(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case lE.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=a.interpolation,m=0,g=0,v=i.length;g<v;g++){var y=new oU;y.time=i[g],p===oy.CubicSpine?(y.inTangent=new tI(o[m++],o[m++],o[m++],o[m++]),y.value=new tF(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new tI(o[m++],o[m++],o[m++],o[m++])):y.value=new tF(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case lE.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var b=0,S=0,C=i.length;S<C;S++){var T=new oU;T.time=i[S],x.interpolation===oy.CubicSpine?(T.inTangent=Array.from(o.subarray(b,b+s)),b+=s,T.value=o.slice(b,b+s),b+=s,T.outTangent=Array.from(o.subarray(b,b+s))):T.value=o.slice(b,b+s),b+=s,x.addKey(T)}return x}},n}(l7),e.GLTFAnimationParser=s0([lN(lI.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.parse=function(e,t){var n=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,n[t])},n._parseSingleBuffer=function(e,t){var n=e.glTFResource,r=e.contentRestorer,a=e.resourceManager,i=n.url,o=a._getRemoteUrl(i),s=r.bufferRequests,l={type:"arraybuffer"},c=nT.resolveAbsoluteUrl(o,t.uri);s.push(new l$(c,l));var u=a._requestByRemoteUrl(c,l).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(u),u},t}(l7),e.GLTFBufferParser=s0([lN(lI.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.parse=function(e,t){var n=e.glTFResource,r=e.glTF.nodes[t],a=n.engine,i=r.matrix,o=r.translation,s=r.rotation,l=r.scale,c=r.extensions,u=new aW(a,r.name||"_GLTF_ENTITY_"+t);u._markAsTemplate(n);var d=u.transform;if(i){var h=d.localMatrix;h.copyFromArray(i),d.localMatrix=h}else o&&d.setPosition(o[0],o[1],o[2]),s&&d.setRotationQuaternion(s[0],s[1],s[2],s[3]),l&&d.setScale(l[0],l[1],l[2]);var _=r.children;if(_)for(var f=0;f<_.length;f++){var p=_[f],m=e.get(lI.Entity,p);u.addChild(m)}return l7.executeExtensionsAdditiveAndParse(c,e,u,r),u},t}(l7),e.GLTFEntityParser=s0([lN(lI.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.parse=function(e,n){var r=e.glTF.materials[n],a=e.glTFResource,i=a.engine,o=l7.executeExtensionsCreateAndParse(r.extensions,e,r);return o||((o=new ad(i)).name=r.name,t._parseStandardProperty(e,o,r)),Promise.resolve(o).then(function(n){return n||(n=t._getDefaultMaterial(i)),l7.executeExtensionsAdditiveAndParse(r.extensions,e,n,r),n._associationSuperResource(a),n})},t._getDefaultMaterial=function(e){return t._defaultMaterial||(t._defaultMaterial=new al(e))},t._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&no.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},t._parseStandardProperty=function(e,n,r){var a=r.pbrMetallicRoughness,i=r.normalTexture,o=r.occlusionTexture,s=r.emissiveTexture,l=r.emissiveFactor,c=r.alphaMode,u=r.alphaCutoff,d=r.doubleSided;if(a){var h=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,m=a.metallicRoughnessTexture;h&&(n.baseColor=new tO(tO.linearToGammaSpace(h[0]),tO.linearToGammaSpace(h[1]),tO.linearToGammaSpace(h[2]),h[3])),_&&e.get(lI.Texture,_.index).then(function(t){n.baseTexture=t,l7.executeExtensionsAdditiveAndParse(_.extensions,e,n,_)}),n.constructor===ad&&(n.metallic=null!=f?f:1,n.roughness=null!=p?p:1,m&&(t._checkOtherTextureTransform(m,"Roughness metallic"),e.get(lI.Texture,m.index).then(function(e){n.roughnessMetallicTexture=e})))}if(n.constructor===ad||n.constructor===ah){if(s&&(t._checkOtherTextureTransform(s,"Emissive"),e.get(lI.Texture,s.index).then(function(e){n.emissiveTexture=e})),l&&(n.emissiveColor=new tO(tO.linearToGammaSpace(l[0]),tO.linearToGammaSpace(l[1]),tO.linearToGammaSpace(l[2]))),i){var g=i.index,v=i.scale;t._checkOtherTextureTransform(i,"Normal"),e.get(lI.Texture,g).then(function(e){n.normalTexture=e}),void 0!==v&&(n.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,b=o.texCoord;t._checkOtherTextureTransform(o,"Occlusion"),e.get(lI.Texture,y).then(function(e){n.occlusionTexture=e}),void 0!==x&&(n.occlusionTextureIntensity=x),b===ac.UV1?n.occlusionTextureCoord=ac.UV1:b>ac.UV1&&no.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=ai.Double:n.renderFace=ai.Front,c){case lw.OPAQUE:n.isTransparent=!1;break;case lw.BLEND:n.isTransparent=!0;break;case lw.MASK:n.alphaCutoff=null!=u?u:.5}},t}(l7),e.GLTFMaterialParser=s0([lN(lI.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.parse=function(e,n){for(var r=function(n,r){var c=a.primitives[n];l[n]=new Promise(function(r){var l=l7.executeExtensionsCreateAndParse(c.extensions,e,c,a);if(l)lc(l,aM)?(l._associationSuperResource(o),r(l)):l.then(function(e){e._associationSuperResource(o),r(e)});else{var u=new aM(s,a.name||n+"");u._associationSuperResource(o);var d=new l1;d.mesh=u,e.contentRestorer.meshes.push(d),t._parseMeshFromGLTFPrimitive(e,u,d,a,c,i,e.params.keepMeshData).then(r)}})},a=e.glTF.meshes[n],i=e.glTF,o=e.glTFResource,s=o.engine,l=[],c=0,u=a.primitives.length;c<u;c++)r(c);return Promise.all(l)},t._parseMeshFromGLTFPrimitive=function(e,n,r,a,i,o,s){var l,c=function(a){var i=u[d[a]],c=lk.getAccessorBuffer(e,o.bufferViews,i).then(function(e){var o,c,u,d=lk.getAccessorTypeSize(i.type),h=i.count,_=e.data,f=n.instanceId,v=e.vertexBindingInfos,y=i.normalized,x=lk.getElementFormat(i.componentType,d,y);if(y&&(c=lk.getNormalizedComponentScale(i.componentType)),e.interleaved){var b=i.byteOffset||0,S=e.stride;if(u=b%S,void 0===v[f]){o=new at(a,u,x,g);var C=e.vertexBuffer;C||(C=new r9(p,an.VertexBuffer,_,r8.Static,s),e.vertexBuffer=C,r.vertexBuffers.push(new l2(C,e.restoreInfo))),n.setVertexBufferBinding(C,S,g),v[f]=g++}else o=new at(a,u,x,v[f])}else{o=new at(a,u=0,x,g);var T=e.vertexBuffer;T||(T=new r9(p,an.VertexBuffer,_,r8.Static,s),r.vertexBuffers.push(new l2(T,e.restoreInfo))),n.setVertexBufferBinding(T,e.stride,g),v[f]=g++}if(m.push(o),"POSITION"===a){l=h;var A=n.bounds,E=A.min,R=A.max;if(i.min&&i.max)E.copyFromArray(i.min),R.copyFromArray(i.max);else{var M=t._tempVector3;E.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),R.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var w=u/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=w+F*P;M.copyFromArray(_,L),tT.min(E,M,E),tT.max(R,M,R)}}y&&(E.scale(c),R.scale(c))}});v.push(c)},u=o.accessors,d=i.attributes,h=i.targets,_=i.indices,f=i.mode,p=n.engine,m=[],g=0,v=[];for(var y in d)c(y);return Promise.all(v).then(function(){if(n.setVertexElements(m),void 0!==_){var c=o.accessors[_],u=lk.getAccessorBuffer(e,o.bufferViews,c).then(function(e){n.setIndices(e.data),n.addSubMesh(0,c.count,f),r.indexBuffer=e.restoreInfo});v.push(u)}else n.addSubMesh(0,l,f);return h&&v.push(t._createBlendShape(e,n,r,a,i,h)),Promise.all(v).then(function(){return n.uploadData(!s),n})})},t._getBlendShapeData=function(e,t,n){return lk.getAccessorBuffer(e,t.bufferViews,n).then(function(e){var t,r=e.data,a=e.interleaved?(null!=(t=n.byteOffset)?t:0)%e.stride:0,i=n.count,o=n.normalized,s=n.componentType;return{vertices:lk.bufferToVector3Array(r,a,i,o,s),restoreInfo:new l5(e.restoreInfo,a,i,o,s)}})},t._createBlendShape=function(e,t,n,r,a,i){for(var o,s=e.glTF,l=s.accessors,c=r.extras?r.extras.targetNames:null,u=[],d=i.length,h=Array(d),_=0;_<d;_++)o=this,function(t){var n={};h[t]=n;var r=c?c[t]:"blendShape"+t,i=a.targets[t],d=i.NORMAL,_=i.TANGENT,f=void 0!==d,p=void 0!==_;u.push(Promise.all([o._getBlendShapeData(e,s,l[i.POSITION]),f?o._getBlendShapeData(e,s,l[d]):null,p?o._getBlendShapeData(e,s,l[_]):null]).then(function(e){var t=e[0],a=e[1],i=e[2],o=new am(r);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),n.blendShape=o,n.restoreInfo=new l8(o,t.restoreInfo,f?a.restoreInfo:null,p?null==i?void 0:i.restoreInfo:null)}))}(_);return Promise.all(u).then(function(){for(var e,r=ld(h);!(e=r()).done;){var a=e.value;t.addBlendShape(a.blendShape),n.blendShapes.push(a.restoreInfo)}})},t}(l7),e.GLTFMeshParser._tempVector3=new tT,e.GLTFMeshParser=s0([lN(lI.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}sJ(n,t);var r=n.prototype;return r.parse=function(e,t){var n,r=e.glTF,a=r.scenes,i=r.scene,o=e.glTFResource,s=a[t],l=s.extensions,c=o.engine,u=s.nodes||[];if(1===u.length)n=e.get(lI.Entity,u[0]);else{(n=new aW(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=e.get(lI.Entity,u[d]);n.addChild(h)}}(void 0===i?0:i)===t&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(e,u[f]));return Promise.all(_).then(function(){return l7.executeExtensionsAdditiveAndParse(l,e,n,s),n})},r._parseEntityComponent=function(e,t){var n,r=this,a=e.glTF,i=e.glTFResource,o=a.nodes[t],s=o.camera,l=o.mesh,c=e.get(lI.Entity,t);return void 0!==s&&this._createCamera(i,a.cameras[s],c),void 0!==l&&(n=this._createRenderer(e,o,c)),Promise.resolve(n).then(function(){var t=[],n=o.children;if(n)for(var a=0;a<n.length;a++)t.push(r._parseEntityComponent(e,n[a]));return Promise.all(t)})},r._createCamera=function(t,n,r){var a=n.orthographic,i=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===lM.ORTHOGRAPHIC){var l=a.xmag,c=a.ymag,u=a.zfar,d=a.znear;s.isOrthographic=!0,void 0!==d&&(s.nearClipPlane=d),void 0!==u&&(s.farClipPlane=u),s.orthographicSize=Math.max(null!=c?c:0,null!=l?l:0)/2}else if(o===lM.PERSPECTIVE){var h=i.aspectRatio,_=i.yfov,f=i.zfar,p=i.znear;void 0!==h&&(s.aspectRatio=h),void 0!==_&&(s.fieldOfView=180*_/Math.PI),void 0!==f&&(s.farClipPlane=f),void 0!==p&&(s.nearClipPlane=p)}t.cameras||(t.cameras=[]),t.cameras.push(s),s.enabled=!1},r._createRenderer=function(t,n,r){for(var a,i=this,o=n.mesh,s=n.skin,l=t.glTF.meshes[o],c=l.primitives,u=c.length,d=n.weights||l.weights,h=Array(u),_=0;_<u;_++)h[_]=t.get(lI.Material,null!=(a=c[_].material)?a:-1);return Promise.all([t.get(lI.Mesh,o),void 0!==s&&t.get(lI.Skin,s),Promise.all(h)]).then(function(n){for(var a=n[0],o=n[1],s=n[2],l=0;l<u;l++)!function(n){var l=s[n]||e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine),u=c[n],h=a[n],_=void 0;if(o||d){var f=r.addComponent(aK);f.mesh=h,o&&(i._computeLocalBounds(f,h,o.bones,o.rootBone,o.inverseBindMatrices),f.skin=o),d&&(f.blendShapeWeights=new Float32Array(d)),_=f}else(_=r.addComponent(aA)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),l7.executeExtensionsAdditiveAndParse(u.extensions,t,_,u)}(l)})},r._computeLocalBounds=function(e,t,n,r,a){var i=n.indexOf(r);if(-1!==i)tE.transform(t.bounds,a[i],e.localBounds);else{var o=new tL(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(n,a,r,o);0!==s?(tL.multiplyScalar(o,1/s,o),tE.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},r._computeApproximateBindMatrix=function(e,t,n,r){for(var a=0,i=n.children,o=0,s=i.length;o<s;o++){var l=i[o],c=e.indexOf(l);-1!==c?(tL.add(r,t[c],r),a++):a+=this._computeApproximateBindMatrix(e,t,l,r)}return a},n}(l7),e.GLTFSceneParser=s0([lN(lI.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.parse=function(e,t){var n=this,r=e.glTF,a=r.skins[t],i=a.inverseBindMatrices,o=a.skeleton,s=a.joints,l=a.name,c=s.length,u=new aj(void 0===l?"SKIN_"+t:l);u.inverseBindMatrices.length=c;var d=Array(c),h=r.accessors[i];return Promise.resolve(lk.getAccessorBuffer(e,r.bufferViews,h).then(function(t){for(var r=e.get(lI.Entity),a=t.data,i=0;i<c;i++){var l=new tL;l.copyFromArray(a,16*i),u.inverseBindMatrices[i]=l;var h=r[s[i]];d[i]=h,u.joints[i]=h.name}if(u.bones=d,void 0!==o){var _=r[o];u.rootBone=_}else{var f=n._findSkeletonRootBone(s,r);if(f)u.rootBone=f;else throw"Failed to find skeleton root bone."}return u}))},n._findSkeletonRootBone=function(e,t){for(var n,r={},a=ld(e);!(n=a()).done;){for(var i=n.value,o=[],s=t[i];s;)o.unshift(s),s=s.parent;r[i]=o}for(var l=null,c=0;;c++){var u=r[e[0]];if(c>=u.length)return l;for(var d=u[c],h=1,_=e.length;h<_;h++)if(c>=(u=r[e[h]]).length||d!==u[c])return l;l=d}},t}(l7),e.GLTFSkinParser=s0([lN(lI.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.parse=function(e,n){var r=e.glTF.textures[n],a=e.glTFResource,i=r.sampler,o=r.source,s=r.name,l=r.extensions,c=l7.executeExtensionsCreateAndParse(l,e,r,n);return c||(c=t._parseTexture(e,void 0===o?0:o,n,i,s)),Promise.resolve(c).then(function(t){return l7.executeExtensionsAdditiveAndParse(l,e,t,r),t._associationSuperResource(a),t})},t._parseTexture=function(e,t,n,r,a){var i,o=e.glTFResource,s=e.glTF,l=o.engine,c=o.url,u=s.images[t],d=u.uri,h=u.bufferView,_=u.mimeType,f=u.name,p=void 0!==r,m=p&&lk.getSamplerInfo(s.samplers[r]);if(d){var g=d.lastIndexOf("."),v=d.substring(g+1).startsWith("ktx")?a2.KTX:a2.Texture2D;i=l.resourceManager.load({url:nT.resolveAbsoluteUrl(c,d),type:v,params:{mipmap:null==m?void 0:m.mipmap}}).onProgress(void 0,e._onTaskDetail).then(function(e){return e.name=a||f||e.name||"texture_"+n,p&&lk.parseSampler(e,m),e}),e._addTaskCompletePromise(i)}else{var y=s.bufferViews[h];i=e.get(lI.Buffer).then(function(t){var r=new Uint8Array(t[y.buffer],y.byteOffset,y.byteLength);return lk.loadImageBuffer(r,_).then(function(t){var r=new nc(l,t.width,t.height,void 0,null==m?void 0:m.mipmap);r.setImageSource(t),r.generateMipmaps(),r.name=a||f||"texture_"+n,p&&lk.parseSampler(r,m);var i=new l0(r,y,_);return e.contentRestorer.bufferTextures.push(i),r})})}return i},t}(l7),e.GLTFTextureParser._wrapMap=((tm={})[lL.CLAMP_TO_EDGE]=t7.Clamp,tm[lL.MIRRORED_REPEAT]=t7.Mirror,tm[lL.REPEAT]=t7.Repeat,tm),e.GLTFTextureParser=s0([lN(lI.Texture)],e.GLTFTextureParser),e.GLTFValidator=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.parse=function(e){var t=e.glTF,n=t.asset.version,r=t.extensionsUsed,a=t.extensionsRequired,i=Number(n);if(!(i>=2&&i<3))throw"Only support glTF 2.x.";if(r){no.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++){var s=r[o];l7.hasExtensionParser(s)||no.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){no.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];l7.hasExtensionParser(c)||no.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},t}(l7),e.GLTFValidator=s0([lN(lI.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.parse=function(e,t){var n=e.glTF.bufferViews[t],r=n.extensions,a=n.byteOffset,i=void 0===a?0:a,o=n.byteLength,s=n.buffer;return r?l7.executeExtensionsCreateAndParse(r,e,n):e.get(lI.Buffer,s).then(function(e){return new Uint8Array(e,i,o)})},t}(l7),e.GLTFBufferViewParser=s0([lN(lI.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.parse=function(e){var t=this;return e.needAnimatorController?e.get(lI.Animation).then(function(n){return Promise.resolve(t._createAnimatorController(e,n))}):Promise.resolve(null)},n._createAnimatorController=function(e,t){var n=new oI(e.glTFResource.engine),r=new oz("layer"),a=new ok;if(n.addLayer(r),r.stateMachine=a,t)for(var i=0;i<t.length;i++){var o=t[i],s=o.name,l=a.makeUniqueStateName(s);l!==s&&console.warn("AnimatorState name is existed, name: "+s+" reset to "+l),a.addState(l).clip=o}return n},t}(l7),e.GLTFAnimatorControllerParser=s0([lN(lI.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.initialize=function(e,t){var n,r,a,i=null!=(a=null==(n=t.glTFLoader)?void 0:n.meshOpt)?a:null==(r=t.glTF)?void 0:r.meshOpt;return i?ct().then(function(e){e.useWorkers(i.workerCount)}):Promise.resolve()},n.load=function(e,t){var n=e.params,r=new lD(new lC(t.engine,e.url),t,sQ({keepMeshData:!1},n));return new a8(function(e,t,n,a){r._setTaskCompleteProgress=n,r._setTaskDetailProgress=a,r.parse().then(e).catch(t)})},t.release=function(){tg&&ct().then(function(e){e.release()})},t}(ol),e.GLTFLoader=s0([it(a2.GLTF,["gltf","glb"])],e.GLTFLoader);var cn=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).prefabResource=r,a}sJ(t,e);var n=t.prototype;return n._handleRootEntity=function(e){this.prefabResource._root=this.context.entityMap.get(e)},n._clearAndResolve=function(){return this.context.clear(),this.prefabResource},t.parse=function(e,n,r){var a=new lh(e,n),i=new t(r,new la(e,lr.Prefab,a),a);return i.start(),i.promise.then(function(){return a})},t}(l_),cr=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,sQ({},e,{type:"json"})).then(function(t){cn.parse(n,e.url,t).then(r).catch(a)})})},t}(ol);cr=s0([it(a2.Prefab,["prefab"])],cr);var ca=Math.PI,ci=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,n){return new a8(function(r,a){var i=n.engine,o=sQ({},e,{type:"arraybuffer"});n._request(e.url,o).then(function(n){var a=t._setTextureByBuffer(i,n);i.resourceManager.addContentRestorer(new co(a,e.url,o)),r(a)}).catch(a)})},t._setTextureByBuffer=function(e,n,r){var a=new Uint8Array(n),i=t._parseHeader(a),o=i.width,s=i.height,l=i.dataPosition,c=s>>1;r||(r=new nd(e,c));for(var u=t._readPixels(a.subarray(l),o,s),d=t._convertToCubemap(u,o,s,c),h=0;h<6;h++)r.setPixelBuffer(t4.PositiveX+h,d[h],0);return r.generateMipmaps(),r},t._convertToCubemap=function(e,t,n,r){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*n*4)throw"ConvertPanoramaToCubemap: input size is wrong";return[this._createCubemapData(r,this._faceRight,e,t,n),this._createCubemapData(r,this._faceLeft,e,t,n),this._createCubemapData(r,this._faceUp,e,t,n),this._createCubemapData(r,this._faceBottom,e,t,n),this._createCubemapData(r,this._faceFront,e,t,n),this._createCubemapData(r,this._faceBack,e,t,n)]},t._createCubemapData=function(e,t,n,r,a){for(var i=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,u=0;u<e;u++){for(var d=this._temp3Vector3.set(0,0,0).add(t[0]),h=this._temp4Vector3.set(0,0,0).add(t[2]),_=0;_<e;_++){var f=this._temp5Vector3.set(0,0,0).add(h).subtract(d).scale(c).add(d);f.normalize();var p=this._calcProjectionSpherical(f,n,r,a);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;i[m]=p.r,i[m+1]=p.g,i[m+2]=p.b,i[m+3]=p.a,d.add(o),h.add(s)}c+=l}return i},t._calcProjectionSpherical=function(e,t,n,r){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-ca;)a+=2*ca;for(;a>ca;)a-=2*ca;var o=a/ca,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(i/ca*r);l<0?l=0:l>=r&&(l=r-1);var c=(r-l-1)*n*4+4*s;return new tO(t[c],t[c+1],t[c+2],t[c+3])},t._readStringLine=function(e,t){for(var n="",r="",a=t;a<e.length-t&&"\n"!=(r=String.fromCharCode(e[a]));a++)n+=r;return n},t._parseHeader=function(e){var t=0,n=0,r=this._readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var a=!1,i=!1,o=0;do o+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this._readStringLine(e,o))?i=!0:0==r.length&&(a=!0);while(!a);if(!i)throw"HDR Bad header format, unsupported FORMAT";o+=r.length+1,r=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!s||s.length<3)throw"HDR Bad header format, no size";if(n=parseInt(s[2]),t=parseInt(s[1]),n<8||n>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:o+=r.length+1}},t._readPixels=function(e,t,n){for(var r=e.byteLength,a=new Uint8Array(4*t*n),i=0,o=0,s=4*t,l=new Uint8Array(s),c=n;c>0&&o<r;){var u=e[o++],d=e[o++],h=e[o++],_=e[o++];if(2!=u||2!=d||128&h||t<8||t>32767)return e;if((h<<8|_)!=t)throw"HDR Bad header format, wrong scan line width";for(var f=0,p=void 0;f<s&&o<r;){var m=(p=e[o++])>128;if(m&&(p-=128),0===p||f+p>s)throw"HDR Bad Format, bad scanline data (run)";if(m)for(var g=e[o++],v=0;v<p;v++)l[f++]=g;else l.set(e.subarray(o,o+p),f),f+=p,o+=p}for(var y=0;y<t;y++){var x=0;a[i]=l[y+x],x+=t,a[i+1]=l[y+x],x+=t,a[i+2]=l[y+x],x+=t,a[i+3]=l[y+x],i+=4}c--}return a},t._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},t._linearToRGBM=function(e,t){var n=Math.min(Math.max(e.r,Math.max(e.g,e.b))/t,1),r=65025/((n=Math.ceil(255*n))*t);e.r*=r,e.g*=r,e.b*=r,e.a*=n},t}(ol);ci._rightBottomBack=new tT(1,-1,-1),ci._rightBottomFront=new tT(1,-1,1),ci._rightUpBack=new tT(1,1,-1),ci._rightUpFront=new tT(1,1,1),ci._leftBottomBack=new tT(-1,-1,-1),ci._leftBottomFront=new tT(-1,-1,1),ci._leftUpBack=new tT(-1,1,-1),ci._leftUpFront=new tT(-1,1,1),ci._faceRight=[ci._rightBottomBack,ci._rightBottomFront,ci._rightUpBack,ci._rightUpFront],ci._faceLeft=[ci._leftBottomFront,ci._leftBottomBack,ci._leftUpFront,ci._leftUpBack],ci._faceUp=[ci._leftBottomFront,ci._rightBottomFront,ci._leftBottomBack,ci._rightBottomBack],ci._faceBottom=[ci._leftUpBack,ci._rightUpBack,ci._leftUpFront,ci._rightUpFront],ci._faceFront=[ci._leftBottomBack,ci._rightBottomBack,ci._leftUpBack,ci._rightUpBack],ci._faceBack=[ci._rightBottomFront,ci._leftBottomFront,ci._rightUpFront,ci._leftUpFront],ci._tempVector3=new tT,ci._temp2Vector3=new tT,ci._temp3Vector3=new tT,ci._temp4Vector3=new tT,ci._temp5Vector3=new tT,ci=s0([it(a2.HDR,["hdr"])],ci);var co=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return sJ(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){a6(e.url,e.requestConfig).then(function(n){ci._setTextureByBuffer(e.resource.engine,n,e.resource),t(e.resource)}).catch(n)})},t}(t2),cs=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return t._request(e.url,sQ({},e,{type:"json"}))},t}(ol);cs=s0([it(a2.JSON,["json"],!1)],cs);var cl={parse:function(e,t,n,r){if(void 0===r&&(r=!1),!function(e){if(e.byteLength>=12){var t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}(e))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var a=Uint32Array.BYTES_PER_ELEMENT,i=new DataView(e,12,13*a),o=0x4030201===i.getUint32(0,!0),s={buffer:e,glType:i.getUint32(1*a,o),glTypeSize:i.getUint32(2*a,o),glFormat:i.getUint32(3*a,o),glInternalFormat:i.getUint32(4*a,o),glBaseInternalFormat:i.getUint32(5*a,o),pixelWidth:i.getUint32(6*a,o),pixelHeight:i.getUint32(7*a,o),pixelDepth:i.getUint32(8*a,o),numberOfArrayElements:i.getUint32(9*a,o),numberOfFaces:i.getUint32(10*a,o),numberOfMipmapLevels:i.getUint32(11*a,o),bytesOfKeyValueData:i.getUint32(12*a,o),loadType:0};if(0!==s.glType)throw Error("only compressed formats currently supported");if(s.numberOfMipmapLevels=Math.max(1,s.numberOfMipmapLevels),0===s.pixelHeight||0!==s.pixelDepth)throw Error("only 2D textures currently supported");if(0!==s.numberOfArrayElements)throw Error("texture arrays not currently supported");if(s.numberOfFaces!==t)throw Error("number of faces expected"+t+", but found "+s.numberOfFaces);return n&&(s.mipmaps=function(e,t){for(var n=[],r=64+e.bytesOfKeyValueData,a=e.pixelWidth,i=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,r,1)[0];r+=4;for(var c=0;c<e.numberOfFaces;c++){var u=new Uint8Array(e.buffer,r,l);n.push({data:u,width:a,height:i}),r+=l,r+=3-(l+3)%4}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return n}(s,!0)),r&&(s.engineFormat=function(e){switch(e){case sw.RGB_S3TC_DXT1_EXT:return t9.BC1;case sw.RGBA_S3TC_DXT5_EXT:return t9.BC3;case sw.RGBA_BPTC_UNORM_EXT:return t9.BC7;case sw.RGB_ETC1_WEBGL:return t9.ETC1_RGB;case sw.RGB8_ETC2:return t9.ETC2_RGB;case sw.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return t9.ETC2_RGBA5;case sw.RGBA8_ETC2_EAC:return t9.ETC2_RGBA8;case sw.RGB_PVRTC_2BPPV1_IMG:return t9.PVRTC_RGB2;case sw.RGBA_PVRTC_2BPPV1_IMG:return t9.PVRTC_RGBA2;case sw.RGB_PVRTC_4BPPV1_IMG:return t9.PVRTC_RGB4;case sw.RGBA_PVRTC_4BPPV1_IMG:return t9.PVRTC_RGBA4;case sw.RGBA_ASTC_4X4_KHR:return t9.ASTC_4x4;case sw.RGBA_ASTC_5X5_KHR:return t9.ASTC_5x5;case sw.RGBA_ASTC_6X6_KHR:return t9.ASTC_6x6;case sw.RGBA_ASTC_8X8_KHR:return t9.ASTC_8x8;case sw.RGBA_ASTC_10X10_KHR:return t9.ASTC_10x10;case sw.RGBA_ASTC_12X12_KHR:return t9.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+sw[e])}}(s.glInternalFormat)),s}};function cc(e){var t=cl.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var cu=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){Promise.all(e.urls.map(function(n){return t._request(n,sQ({},e,{type:"arraybuffer"}))})).then(function(e){for(var r=function(e){for(var t,n,r,a,i=[],o=0;o<e.length;o++){var s=cl.parse(e[o],1,!0,!0);i.push(s.mipmaps),0===o&&(r=s.pixelWidth,a=s.pixelHeight,t=s.glInternalFormat,n=s.engineFormat)}return{mipmapsFaces:i,engineFormat:n,internalFormat:t,width:r,height:a}}(e),a=r.width,i=r.mipmapsFaces,o=r.engineFormat,s=i[0].length>1,l=new nd(t.engine,a,o,s),c=0;c<6;c++)for(var u=i[c].length,d=0;d<u;d++){var h=i[c][d],_=h.data,f=h.width,p=h.height;l.setPixelBuffer(t4.PositiveX+c,_,d,0,0,f,p)}n(l)}).catch(function(e){r(e)})})},t}(ol);cu=s0([it(a2.KTXCube,[])],cu);var cd=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,sQ({},e,{type:"arraybuffer"})).then(function(e){for(var r=cc(e),a=r.width,i=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new nc(t.engine,a,i,s,l),u=0;u<o.length;u++){var d=o[u],h=d.width,_=d.height,f=d.data;c.setPixelBuffer(f,u,0,0,h,_)}n(c)}).catch(function(e){r(e)})})},t}(ol);cd=s0([it(a2.KTX,["ktx"])],cd);var ch=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,sQ({},e,{type:"json"})).then(function(e){var a=t.engine,i=e.shaderRef,o=e.shader,s=ro.find(o);s?r(n._getMaterialByShader(e,s,a)):i&&r(t.getResourceByRef(i).then(function(t){return n._getMaterialByShader(e,t,a)}))}).catch(a)})},n._getMaterialByShader=function(e,t,n){var r=function(e){var t=i[e],r=t.type,a=t.value;switch(r){case ls.Vector2:u.setVector2(e,new tB(a.x,a.y));break;case ls.Vector3:u.setVector3(e,new tT(a.x,a.y,a.z));break;case ls.Vector4:u.setVector4(e,new tI(a.x,a.y,a.z,a.w));break;case ls.Color:u.setColor(e,new tO(a.r,a.g,a.b,a.a));break;case ls.Float:u.setFloat(e,a);break;case ls.Texture:c.push(n.resourceManager.getResourceByRef(a).then(function(t){u.setTexture(e,t)}));break;case ls.Boolean:u.setInt(e,a?1:0);break;case ls.Integer:u.setInt(e,Number(a))}},a=e.name,i=e.shaderData,o=e.macros,s=e.renderState,l=new ao(n,t);l.name=a;var c=[],u=l.shaderData;for(var d in i)r(d);for(var h=0,_=o.length;h<_;h++){var f=o[h],p=f.name,m=f.value;void 0==m?u.enableMacro(p):u.enableMacro(p,m)}return function e(t,n,r){if((void 0===r?"undefined":s$(r))==="object")for(var a in r)e(t[n],a,r[a]);else t[n]=r}(l,"renderState",s),Promise.all(c).then(function(){return l})},t}(ol);ch=s0([it(a2.Material,["json"])],ch);var c_=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,sQ({},e,{type:"arraybuffer"})).then(function(e){return lp(e,t.engine)}).then(function(e){n(e)}).catch(r)})},t}(ol);c_=s0([it(a2.Mesh,["mesh"])],c_);var cf=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){var n=t.engine;return t._request(e.url,sQ({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return az.createSubdivisionSurfaceSphere(n,e.sphereRadius,e.sphereStep);case"capsule":return az.createCapsule(n,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return az.createCone(n,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return az.createCuboid(n,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return az.createCylinder(n,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return az.createPlane(n,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return az.createTorus(n,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},t}(ol);cf=s0([it(a2.PrimitiveMesh,["mesh"],!1)],cf);var cp=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,sQ({},e,{type:"json"})).then(function(e){return n.resourceManager.initVirtualResources(e.files),t.load({type:a2.Scene,url:e.scene}).then(function(e){n.sceneManager.activeScene=e,r()})}).catch(a)})},t}(ol);cp=s0([it(a2.Project,["proj"],!1)],cp);var cm=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){var i=t._getRemoteUrl(e.url);n._registerFont(i,i).then(function(){r(new ng(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},n._registerFont=function(e,t){return lb(function(){var n;return s1(this,function(r){switch(r.label){case 0:return[4,(n=new FontFace(e,"url("+t+")")).load()];case 1:return r.sent(),document.fonts.add(n),[2]}})})()},t}(ol);cm=s0([it(a2.SourceFont,["ttf","otf","woff"],!1)],cm);var cg=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._tempRect=new tV,t._tempVec2=new tB,t._tempVec4=new tI,t}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a,i,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=t._request(e.url,sQ({},e,{type:"json"}));l.push(c),c.then(function(i){var o=i.atlasItems,s=i.mipmap,c=i.anisoLevel,u=i.filterMode,d=i.wrapModeU,h=i.wrapModeV,_=i.format,f=o?o.length:0,p=t.engine,m=new nb(p);if(f<=0){r(m);return}l.length=0;for(var g=0;g<f;g++)!function(r){var i,f=o[r];if(f.img)l.push(t.load({url:nT.resolveAbsoluteUrl(e.url,f.img),type:null!=(i=f.type)?i:a2.Texture2D,params:{format:_,mipmap:s}}).then(function(e){c&&(e.anisoLevel=c),void 0!==u&&(e.filterMode=u),void 0!==d&&(e.wrapModeU=d),void 0!==h&&(e.wrapModeV=h);for(var t=0;t<f.sprites.length;t++)m._addSprite(n._makeSprite(p,f.sprites[t],e))}).catch(a));else for(var g=0;g<f.sprites.length;g++)m._addSprite(n._makeSprite(p,f.sprites[g]))}(g);a8.all(l).then(function(){r(m)}).catch(a)}).catch(a)})},n._makeSprite=function(e,t,n){var r=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new nP(e,n,r?this._tempRect.set(r.x,r.y,r.w,r.h):void 0,o?this._tempVec2.set(o.x,o.y):void 0,s?this._tempVec4.set(s.x,s.y,s.z,s.w):void 0,t.name);if(n){var d=1/n.width,h=1/n.height;if(u.atlasRegion.set(i.x*d,i.y*h,i.w*d,i.h*h),a){var _=a.x,f=a.y,p=a.z,m=a.w;u.atlasRegionOffset.set(_*d,f*h,p*d,m*h)}t.atlasRotated&&(u.atlasRotated=!0)}return isNaN(l)||(u.width=l),isNaN(c)||(u.height=c),u},t}(ol);cg=s0([it(a2.SpriteAtlas,["atlas"],!1)],cg);var cv=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return t._request(e.url,sQ({},e,{type:"json"})).then(function(e){return e.belongToAtlas?n._loadFromAtlas(t,e):n._loadFromTexture(t,e)})},n._loadFromAtlas=function(e,t){var n=this;return e.getResourceByRef(t.belongToAtlas).then(function(r){return r.getSprite(t.fullPath)||n._loadFromTexture(e,t)})},n._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(n){var r=new nP(e.engine,n,t.region,t.pivot,t.border),a=t.width,i=t.height;return isNaN(a)||(r.width=a),isNaN(i)||(r.height=i),r}):new a8(function(n){var r=new nP(e.engine,null,t.region,t.pivot,t.border),a=t.width,i=t.height;isNaN(a)||(r.width=a),isNaN(i)||(r.height=i),n(r)})},t}(ol);cv=s0([it(a2.Sprite,["sprite"],!1)],cv);var cy=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return sJ(t,e),t.prototype.restoreContent=function(){var e=this;return a6(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},t}(t2),cx=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return new a8(function(n,r,a,i){var o=e.url,s=sQ({},e,{type:"image"});t._request(o,s).onProgress(a,i).then(function(r){var a,i=null!=(a=e.params)?a:{},l=i.format,c=i.mipmap,u=i.anisoLevel,d=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new nc(t.engine,r.width,r.height,l,c);if(f.anisoLevel=null!=u?u:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=d?d:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(r),f.generateMipmaps(),0!==o.indexOf("data:")){var p=o.lastIndexOf("/");f.name=o.substring(p+1)}t.addContentRestorer(new cy(f,o,s)),n(f)}).catch(function(e){r(e)})})},t}(ol);cx=s0([it(a2.Texture2D,["png","jpg","webp","jpeg"])],cx);var cb=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).urls=n,a.requestConfig=r,a}return sJ(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){Promise.all(e.urls.map(function(t){return a6(t,e.requestConfig)})).then(function(n){for(var r=e.resource,a=0;a<6;a++)r.setImageSource(t4.PositiveX+a,n[a],0);r.generateMipmaps(),t(r)}).catch(function(e){n(e)})})},t}(t2),cS=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){var a=e.urls,i=sQ({},e,{type:"image"});Promise.all(a.map(function(e){return t._request(e,i)})).then(function(e){var r=e[0],o=r.width;if(o!==r.height){console.error("The cube texture must have the same width and height");return}for(var s=new nd(t.engine,o),l=0;l<6;l++)s.setImageSource(t4.PositiveX+l,e[l],0);s.generateMipmaps(),t.addContentRestorer(new cb(s,a,i)),n(s)}).catch(function(e){r(e)})})},t}(ol);cS=s0([it(a2.TextureCube,[""])],cS);var cC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,n){var r=e.url;return n._request(r,sQ({},e,{type:"text"})).then(function(e){return n$.registerInclude(r.substring(1),e),t._loadChunksInCode(e,r,n)})},t._loadChunksInCode=function(e,n,r){for(var a,i=[],o=e.matchAll(t._shaderIncludeRegex),s=ld(o);!(a=s()).done;){var l=a.value,c=nT.resolveAbsoluteUrl(n,l[1]);nJ[c.substring(1)]||i.push(c)}return Promise.all(i.map(function(e){return r.load({type:"ShaderChunk",url:e})}))},t}(ol);cC._shaderIncludeRegex=/\s#include\s+"([./][^\\"]+)"/gm,cC=s0([it("ShaderChunk",["glsl"])],cC);var cT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}sJ(t,e);var n=t.prototype;return n.load=function(e,t){var n=this,r=e.url;return t._request(r,sQ({},e,{type:"text"})).then(function(e){var a=n._getBuiltinShader(e);return a?ro.find(a):cC._loadChunksInCode(e,r,t).then(function(){var t=ro.create(e);return t._registerPath(r),t})})},n._getBuiltinShader=function(e){var n=e.match(t._builtinRegex);if(n&&n[1])return n[1]},t}(ol);cT._builtinRegex=/^\s*\/\/\s*@builtin\s+(\w+)/,cT=s0([it(a2.Shader,["gs","gsl"])],cT);var cA=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,sQ({},e,{type:"json"})).then(function(e){return lf.parse(n,e).then(function(n){var a,i,o=[],s=e.scene.ambient;if(s){var l=s.specularMode===ll.Custom,c=s.diffuseMode===i4.SphericalHarmonics;n.ambientLight.diffuseIntensity=s.diffuseIntensity,n.ambientLight.specularIntensity=s.specularIntensity,n.ambientLight.diffuseMode=s.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(s.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,l&&s.customAmbientLight&&o.push(t.getResourceByRef(s.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),s.ambientLight&&(!l||c)&&o.push(t.getResourceByRef(s.ambientLight).then(function(e){l||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),c&&(n.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var u=e.scene.background;switch(n.background.mode=u.mode,n.background.mode){case rO.SolidColor:n.background.solidColor.copyFrom(u.color);break;case rO.Sky:if(u.skyMesh&&u.skyMaterial){var d=t.getResourceByRef(u.skyMesh).then(function(e){n.background.sky.mesh=e}),h=t.getResourceByRef(u.skyMaterial).then(function(e){n.background.sky.material=e});o.push(d,h)}else no.warn("Sky background mode requires skyMesh and skyMaterial");break;case rO.Texture:if(u.texture){var _,f=t.getResourceByRef(u.texture).then(function(e){n.background.texture=e});o.push(f),n.background.textureFillMode=null!=(_=u.textureFillMode)?_:n.background.textureFillMode}}var p=e.scene.shadow;p&&(void 0!=p.castShadows&&(n.castShadows=p.castShadows),void 0!=p.shadowResolution&&(n.shadowResolution=p.shadowResolution),void 0!=p.shadowDistance&&(n.shadowDistance=p.shadowDistance),void 0!=p.shadowCascades&&(n.shadowCascades=p.shadowCascades),void 0!=p.enableTransparentShadow&&(n.enableTransparentShadow=p.enableTransparentShadow),n.shadowTwoCascadeSplits=null!=(a=p.shadowTwoCascadeSplits)?a:n.shadowTwoCascadeSplits,p.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(p.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(i=p.shadowFadeBorder)?i:n.shadowFadeBorder);var m=e.scene.fog;m&&(void 0!=m.fogMode&&(n.fogMode=m.fogMode),void 0!=m.fogStart&&(n.fogStart=m.fogStart),void 0!=m.fogEnd&&(n.fogEnd=m.fogEnd),void 0!=m.fogDensity&&(n.fogDensity=m.fogDensity),void 0!=m.fogColor&&n.fogColor.copyFrom(m.fogColor));var g=e.scene.postProcess;if(g){var v=n._postProcessManager,y=v._bloomEffect,x=v._tonemappingEffect;if(v.isActive=g.isActive,y.enabled=g.bloom.enabled,y.downScale=g.bloom.downScale,y.threshold=g.bloom.threshold,y.scatter=g.bloom.scatter,y.intensity=g.bloom.intensity,y.tint.copyFrom(g.bloom.tint),y.dirtIntensity=g.bloom.dirtIntensity,x.enabled=g.tonemapping.enabled,x.mode=g.tonemapping.mode,g.bloom.dirtTexture){var b=t.getResourceByRef(g.bloom.dirtTexture).then(function(e){y.dirtTexture=e});o.push(b)}}return Promise.all(o).then(function(){r(n)})})}).catch(a)})},t}(ol);cA=s0([it(a2.Scene,["scene"],!0)],cA),li.registerCustomParseComponent("TextRenderer",/*#__PURE__*/lb(function(e,t){var n;return s1(this,function(r){return(n=t.props).font||(e.font=ng.createFromOS(e.engine,n.fontFamily||"Arial")),[2,e]})}));var cE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.additiveParse=function(e,t,n){var r,a=e.glTF.extensions.KHR_lights_punctual.lights[n.light],i=a.color,o=a.intensity,s=a.type,l=a.range,c=a.spot,u=e.glTFResource;if("directional"===s?r=t.addComponent(i9):"point"===s?r=t.addComponent(i6):"spot"===s&&(r=t.addComponent(i7)),i&&r.color.set(i[0],i[1],i[2],1),r.intensity=void 0===o?1:o,l&&!lc(r,i9)&&(r.distance=l),c&&lc(r,i7)){var d=c.innerConeAngle,h=void 0===d?0:d,_=c.outerConeAngle,f=void 0===_?Math.PI/4:_;r.angle=h,r.penumbra=f-h}u.lights||(u.lights=[]),u.lights.push(r)},t}(l9);cE=s0([ce("KHR_lights_punctual",l6.AdditiveParse)],cE);var cR=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return sJ(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.clearcoatFactor,i=r.clearcoatTexture,o=r.clearcoatRoughnessFactor,s=r.clearcoatRoughnessTexture,l=r.clearcoatNormalTexture;n.clearCoat=void 0===a?0:a,n.clearCoatRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Clear coat"),t.get(lI.Texture,i.index).then(function(e){n.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(lI.Texture,s.index).then(function(e){n.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(lI.Texture,l.index).then(function(e){n.clearCoatNormalTexture=e}))},n}(l9);cR=s0([ce("KHR_materials_clearcoat",l6.AdditiveParse)],cR);var cM=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},t}(l9);cM=s0([ce("KHR_materials_ior",l6.AdditiveParse)],cM);var cw=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return sJ(n,t),n.prototype.createAndParse=function(t,n,r){var a=new ah(t.glTFResource.engine),i=n.diffuseFactor,o=n.diffuseTexture,s=n.specularFactor,l=n.glossinessFactor,c=n.specularGlossinessTexture;return i&&(a.baseColor=new tO(tO.linearToGammaSpace(i[0]),tO.linearToGammaSpace(i[1]),tO.linearToGammaSpace(i[2]),i[3])),o&&t.get(lI.Texture,o.index).then(function(e){a.baseTexture=e,l7.executeExtensionsAdditiveAndParse(o.extensions,t,a,o)}),s&&(a.specularColor=new tO(tO.linearToGammaSpace(s[0]),tO.linearToGammaSpace(s[1]),tO.linearToGammaSpace(s[2]))),void 0!==l&&(a.glossiness=l),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"Specular glossiness"),t.get(lI.Texture,c.index).then(function(e){a.specularGlossinessTexture=e})),a.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,a,r),a},n}(l9);cw=s0([ce("KHR_materials_pbrSpecularGlossiness",l6.CreateAndParse)],cw);var cP=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return sJ(n,t),n.prototype.createAndParse=function(t,n,r){var a=new a_(t.glTFResource.engine);return a.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,a,r),a},n}(l9);cP=s0([ce("KHR_materials_unlit",l6.CreateAndParse)],cP);var cF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.additiveParse=function(e,t,n){var r=e.glTF.extensions.KHR_materials_variants.variants,a=e.glTFResource,i=n.mappings;a._extensionsData||(a._extensionsData={});var o=[];a.extensionsData.variants=o;for(var s=0;s<i.length;s++)!function(n){var a=i[n],s=a.material,l=a.variants;e.get(lI.Material,s).then(function(e){o.push({renderer:t,material:e,variants:l.map(function(e){return r[e].name})})})}(s)},t}(l9);cF=s0([ce("KHR_materials_variants",l6.AdditiveParse)],cF);var cL=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t}(l9);cL=s0([ce("KHR_mesh_quantization",l6.AdditiveParse)],cL);var cD=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return sJ(n,t),n.prototype.createAndParse=function(t,n,r){return lb(function(){var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y;return s1(this,function(x){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=r.sampler,c=r.name,u=n.source,h=(d=a.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&lk.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:nT.resolveAbsoluteUrl(s,h),type:a2.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&lk.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=a.bufferViews[_],[2,t.get(lI.Buffer,y.buffer).then(function(n){var r=new Uint8Array(n,y.byteOffset,y.byteLength);return e.KTX2Loader._parseBuffer(r,o).then(function(t){var n=t.engine,r=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(n,r,a,i)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&lk.parseSampler(e,m);var n=new l0(e,y,f);return t.contentRestorer.bufferTextures.push(n),e})})])})})()},n}(l9);cD=s0([ce("KHR_texture_basisu",l6.CreateAndParse)],cD);var cB=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.offset,a=n.rotation,i=n.scale,o=n.texCoord;r&&(t.tilingOffset.z=r[0],t.tilingOffset.w=r[1]),i&&(t.tilingOffset.x=i[0],t.tilingOffset.y=i[1]),a&&no.warn("rotation in KHR_texture_transform is not supported now"),o&&no.warn("texCoord in KHR_texture_transform is not supported now")},t}(l9);cB=s0([ce("KHR_texture_transform",l6.AdditiveParse)],cB);var cI=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.createAndParse=function(e,t){var n=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(n),n},t}(l9);cI=s0([ce("GALACEAN_materials_remap",l6.CreateAndParse)],cI);var cO=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new og;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},t}(l9);cO=s0([ce("GALACEAN_animation_event",l6.AdditiveParse)],cO);var cV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sJ(t,e),t.prototype.createAndParse=function(e,t){return e.get(lI.Buffer,t.buffer).then(function(e){return ct().then(function(n){return n.decodeGltfBuffer(t.count,t.byteStride,new Uint8Array(e,t.byteOffset,t.byteLength),t.mode,t.filter)})})},t}(l9);cV=s0([ce("EXT_meshopt_compression",l6.CreateAndParse)],cV);var cN=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return sJ(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.anisotropyStrength,i=r.anisotropyRotation,o=r.anisotropyTexture;n.anisotropy=void 0===a?0:a,n.anisotropyRotation=void 0===i?0:i,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(lI.Texture,o.index).then(function(e){n.anisotropyTexture=e}))},n}(l9);cN=s0([ce("KHR_materials_anisotropy",l6.AdditiveParse)],cN);var ck=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return sJ(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.iridescenceFactor,i=r.iridescenceTexture,o=r.iridescenceIor,s=r.iridescenceThicknessMinimum,l=r.iridescenceThicknessMaximum,c=r.iridescenceThicknessTexture;n.iridescence=void 0===a?0:a,n.iridescenceIOR=void 0===o?1.3:o,n.iridescenceThicknessRange.set(void 0===s?100:s,void 0===l?400:l),i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Iridescence texture"),t.get(lI.Texture,i.index).then(function(e){n.iridescenceTexture=e})),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"IridescenceThickness texture"),t.get(lI.Texture,c.index).then(function(e){n.iridescenceThicknessTexture=e}))},n}(l9);ck=s0([ce("KHR_materials_iridescence",l6.AdditiveParse)],ck);var cz=/*#__PURE__*/function(t){function n(){var e;if((e=t.call(this)||this)._supportWebP=!1,id._isBrowser){var n=document.createElement("canvas");n.width=n.height=1,e._supportWebP=0==n.toDataURL("image/webp").indexOf("data:image/webp")}else e._supportWebP=!1;return e}return sJ(n,t),n.prototype.createAndParse=function(t,n,r,a){var i=this;return lb(function(){var o,s,l,c,u;return s1(this,function(d){return o=n.source,s=r.sampler,c=void 0===(l=r.source)?0:l,u=r.name,[2,e.GLTFTextureParser._parseTexture(t,i._supportWebP?o:c,a,s,u)]})})()},n}(l9);cz=s0([ce("EXT_texture_webp",l6.CreateAndParse)],cz);var cU="1.4.0-alpha.0";for(var cG in console.log("Galacean engine version: "+cU),sM)ol.registerClass(cG,sM[cG]);e.AccessorType=lA,e.AmbientLight=i8,e.AnimationClip=ov,e.AnimationClipCurveBinding=om,e.AnimationCurve=ox,e.AnimationEvent=og,e.Animator=oD,e.AnimatorCondition=oR,e.AnimatorConditionMode=ob,e.AnimatorController=oI,e.AnimatorControllerLayer=oz,e.AnimatorControllerParameter=oB,e.AnimatorCullingMode=oS,e.AnimatorLayerBlendingMode=oC,e.AnimatorLayerMask=oH,e.AnimatorState=oN,e.AnimatorStateMachine=ok,e.AnimatorStateTransition=oM,e.AssetPromise=a8,e.AssetType=a2,e.Background=i0,e.BackgroundMode=rO,e.BackgroundTextureFillMode=rV,e.BaseMaterial=as,e.BasicRenderPipeline=rJ,e.BlendFactor=nF,e.BlendMode=aa,e.BlendOperation=nL,e.BlendShape=am,e.BlendShapeFrame=af,e.BlendState=rt,e.BlinnPhongMaterial=al,e.BloomDownScaleMode=ot,e.BloomEffect=on,e.BoolUpdateFlag=rf,e.BoundingBox=tE,e.BoundingFrustum=tw,e.BoundingSphere=tA,e.BoxColliderShape=iI,e.BoxShape=s_,e.Buffer=r9,e.BufferBindFlag=an,e.BufferInfo=lB,e.BufferMesh=aT,e.BufferReader=s4,e.BufferUsage=r8,e.BufferUtil=ae,e.Burst=sc,e.CameraClearFlags=rw,e.CameraType=rP,e.Canvas=iJ,e.CapsuleColliderShape=iN,e.CharacterController=ig,e.CircleShape=sp,e.ClearableObjectPool=iq,e.CloneManager=t$,e.ColliderShape=iB,e.ColliderShapeUpAxis=iA,e.CollisionDetectionMode=iy,e.CollisionUtil=tR,e.Color=tO,e.ColorOverLifetimeModule=o5,e.ColorSpace=n2,e.ColorWriteMask=nD,e.CompareFunction=nB,e.Component=ru,e.ConeEmitType=sg,e.ConeShape=sm,e.ContainmentType=tv,e.ContentRestorer=t2,e.ControllerCollisionFlag=iE,e.ControllerNonWalkableMode=im,e.CubeProbe=sR,e.CullMode=nI,e.CurveKey=sr,e.DataType=nQ,e.DependentMode=r_,e.DepthState=rn,e.DepthTextureMode=rF,e.DiffuseMode=i4,e.DirectLight=i9,e.DisorderedArray=rS,e.Downsampling=rL,e.DynamicCollider=iv,e.DynamicColliderConstraints=ix,e.EmissionModule=o6,e.Engine=iZ,e.EngineObject=t0,e.Entity=aW,e.EventDispatcher=nK,e.FileHeader=s9,e.FixedJoint=iM,e.FogMode=i3,e.Font=ng,e.FontStyle=n_,e.FrustumFace=tx,e.GLCapabilityType=nZ,e.GLCompressedTextureInternalFormat=sw,e.GLTFExtensionMode=l6,e.GLTFExtensionParser=l9,e.GLTFParser=l7,e.GLTFParserContext=lD,e.GLTFParserType=lI,e.GLTFResource=lC,e.GLTFUtils=lk,e.GradientAlphaKey=o3,e.GradientColorKey=o2,e.HemisphereShape=sv,e.HingeJoint=iP,e.HitResult=ib,e.IndexBufferBinding=ag,e.IndexFormat=r6,e.InputManager=iU,e.InterpolableValueType=lo,e.InterpolationType=oy,e.JointLimits=iL,e.JointMotor=iD,e.KTX2TargetFormat=lG,e.KTX2Transcoder=lZ,e.Keyframe=oU,e.Keys=ih,e.Layer=rE,e.LayerPathMask=oG,e.Light=i5,e.Loader=ol,e.Logger=no,e.MSAASamples=rD,e.MainModule=se,e.Material=ao,e.MaterialLoaderType=ls,e.MathUtil=tC,e.Matrix=tL,e.Matrix3x3=tP,e.Mesh=ab,e.MeshRenderer=aA,e.MeshTopology=ar,e.ModelMesh=aM,e.OverflowMode=nf,e.PBRBaseMaterial=au,e.PBRMaterial=ad,e.PBRSpecularMaterial=ah,e.ParserContext=la,e.ParserType=lr,e.ParticleCompositeCurve=o9,e.ParticleCompositeGradient=o4,e.ParticleCurve=sn,e.ParticleCurveMode=oJ,e.ParticleGenerator=ss,e.ParticleGradient=o1,e.ParticleGradientMode=o$,e.ParticleMaterial=sl,e.ParticleRenderMode=oK,e.ParticleRenderer=oQ,e.ParticleScaleMode=o7,e.ParticleShapeArcMode=sf,e.ParticleShapeType=sh,e.ParticleSimulationSpace=oY,e.ParticleStopMode=oq,e.PhysicsMaterial=iC,e.PhysicsMaterialCombineMode=iS,e.PhysicsScene=ip,e.PipelineStage=nX,e.Plane=tM,e.PlaneColliderShape=iV,e.PlaneIntersectionType=ty,e.Platform=tz,e.PointLight=i6,e.Pointer=is,e.PointerButton=il,e.PointerPhase=io,e.PrefabResource=lh,e.Primitive=ax,e.PrimitiveMesh=az,e.Probe=sC,e.Quaternion=tF,e.Rand=tk,e.RasterState=rr,e.Ray=tD,e.Rect=tV,e.ReferResource=t1,e.ReflectionParser=li,e.RenderBufferDepthFormat=t3,e.RenderFace=ai,e.RenderQueue=rG,e.RenderQueueType=nV,e.RenderState=ri,e.RenderStateDataKey=nO,e.RenderTarget=nl,e.RenderTargetBlendState=re,e.ReplacementFailureStrategy=rB,e.ResourceManager=ie,e.ReturnableObjectPool=aQ,e.RotationOverLifetimeModule=st,e.SafeLoopArray=a3,e.Scene=oo,e.SceneManager=a4,e.SceneParser=lf,e.Script=os,e.SetDataOptions=r5,e.Shader=ro,e.ShaderData=rs,e.ShaderFactory=n$,e.ShaderLib=nJ,e.ShaderMacro=nH,e.ShaderMacroCollection=nW,e.ShaderPass=n6,e.ShaderPlatformTarget=nz,e.ShaderProperty=nY,e.ShaderPropertyType=nN,e.ShaderTagKey=n0,e.ShadowCascadesMode=rK,e.ShadowResolution=rW,e.ShadowType=rj,e.SizeOverLifetimeModule=sa,e.Skin=aj,e.SkinnedMeshRenderer=aK,e.Sky=i$,e.SkyBoxMaterial=oW,e.SkyProceduralMaterial=oX,e.SpecularMode=ll,e.SphereColliderShape=iO,e.SphereShape=sy,e.SphericalHarmonics3=tN,e.SpotLight=i7,e.SpringJoint=iF,e.Sprite=nP,e.SpriteAtlas=nb,e.SpriteDrawMode=nS,e.SpriteMask=r2,e.SpriteMaskInteraction=nv,e.SpriteMaskLayer=rg,e.SpriteRenderer=rT,e.SpriteTileMode=nC,e.StateMachineScript=oV,e.StaticCollider=iT,e.StencilOperation=nk,e.StencilState=ra,e.SubMesh=ay,e.SubPrimitive=av,e.SubShader=n7,e.SunMode=oj,e.SystemInfo=id,e.TextHorizontalAlignment=ny,e.TextRenderer=r3,e.TextUtils=np,e.TextVerticalAlignment=nx,e.Texture=ns,e.Texture2D=nc,e.Texture2DArray=nu,e.TextureCoordinate=ac,e.TextureCube=nd,e.TextureCubeFace=t4,e.TextureDepthCompareFunction=t8,e.TextureFilterMode=t5,e.TextureFormat=t9,e.TextureSheetAnimationModule=si,e.TextureUsage=t6,e.TextureWrapMode=t7,e.Time=nq,e.TonemappingEffect=oa,e.TonemappingMode=or,e.TrailMaterial=sx,e.TrailRenderer=sS,e.Transform=rp,e.UnlitMaterial=a_,e.Utils=nT,e.Vector2=tB,e.Vector3=tT,e.Vector4=tI,e.VelocityOverLifetimeModule=so,e.VertexAttribute=aR,e.VertexBufferBinding=aC,e.VertexElement=at,e.VertexElementFormat=r7,e.WebCanvas=sI,e.WebGLEngine=sO,e.WebGLGraphicDevice=sq,e.WebGLMode=sY,e.WrapMode=ow,e.XRManager=iQ,e._PostProcessManager=oi,e.assignmentClone=tQ,e.decode=lp,e.decoder=s5,e.decoderMap=s8,e.deepClone=tJ,e.dependentComponents=rh,e.ignoreClone=tq,e.parseSingleKTX=cc,e.registerGLTFExtension=ce,e.registerGLTFParser=lN,e.request=a6,e.resourceLoader=it,e.shallowClone=tZ,e.version=cU,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean={})}(this,function(e){"use strict";function t(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function n(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var r,a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,b,C,S,T,A,E,R,M,w,P,F,L,D,B,I,O,N,V,k,z,U,G,H,W,j,X,K,Y,q,Q,J,Z,$,ee,et,en,er,ea,ei,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eC,eS,eT,eA,eE,eR,eM,ew,eP,eF,eL,eD,eB,eI,eO,eN,eV,ek,ez,eU,eG,eH,eW,ej,eX,eK,eY,eq,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tn,tr,ta,ti,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv=((td={})[td.Disjoint=0]="Disjoint",td[td.Contains=1]="Contains",td[td.Intersects=2]="Intersects",td),ty=((r={})[r.Back=0]="Back",r[r.Front=1]="Front",r[r.Intersecting=2]="Intersecting",r),tx=((a={})[a.Near=0]="Near",a[a.Far=1]="Far",a[a.Left=2]="Left",a[a.Right=3]="Right",a[a.Bottom=4]="Bottom",a[a.Top=5]="Top",a);function tb(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tC(e,t,n){return t&&tb(e.prototype,t),n&&tb(e,n),e}var tS=/*#__PURE__*/function(){function e(){}return e.clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},e.equals=function(t,n){return Math.abs(t-n)<=e.zeroTolerance},e.isPowerOf2=function(e){return(e&e-1)==0},e.radianToDegree=function(t){return t*e.radToDegreeFactor},e.degreeToRadian=function(t){return t*e.degreeToRadFactor},e.lerp=function(e,t,n){return e+(t-e)*n},e}();tS.zeroTolerance=1e-6,tS.radToDegreeFactor=180/Math.PI,tS.degreeToRadFactor=Math.PI/180;var tT=/*#__PURE__*/function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=n}var t=e.prototype;return t.set=function(e,t,n){return this._x=e,this._y=t,this._z=n,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z;return Math.sqrt(e*e+t*t+n*n)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z;return e*e+t*t+n*n},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},t.transformNormal=function(t){return e.transformNormal(this,t,this),this},t.transformToVec3=function(t){return e.transformToVec3(this,t,this),this},t.transformCoordinate=function(t){return e.transformCoordinate(this,t,this),this},t.transformByQuat=function(t){return e.transformByQuat(this,t,this),this},t.clone=function(){return new e(this._x,this._y,this._z)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._z=e._z-t._z,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._z=e._z*t._z,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._z=e._z/t._z,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},e.cross=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z;n.set(a*l-i*s,i*o-r*l,r*s-a*o)},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z;return Math.sqrt(n*n+r*r+a*a)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z;return n*n+r*r+a*a},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)&&tS.equals(e._z,t._z)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y,o=e._z;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._z=o+(t._z-o)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._z=Math.max(e._z,t._z),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._z=Math.min(e._z,t._z),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=Math.sqrt(n*n+r*r+a*a);i>tS.zeroTolerance&&(i=1/i,t.set(n*i,r*i,a*i))},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._onValueChanged&&n._onValueChanged()},e.transformNormal=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8],n._y=r*o[1]+a*o[5]+i*o[9],n._z=r*o[2]+a*o[6]+i*o[10],n._onValueChanged&&n._onValueChanged()},e.transformToVec3=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8]+o[12],n._y=r*o[1]+a*o[5]+i*o[9]+o[13],n._z=r*o[2]+a*o[6]+i*o[10]+o[14],n._onValueChanged&&n._onValueChanged()},e.transformToVec4=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8]+o[12],n._y=r*o[1]+a*o[5]+i*o[9]+o[13],n._z=r*o[2]+a*o[6]+i*o[10]+o[14],n._w=r*o[3]+a*o[7]+i*o[11]+o[15],n._onValueChanged&&n._onValueChanged()},e.transformCoordinate=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements,s=r*o[3]+a*o[7]+i*o[11]+o[15];s=1/s,n._x=(r*o[0]+a*o[4]+i*o[8]+o[12])*s,n._y=(r*o[1]+a*o[5]+i*o[9]+o[13])*s,n._z=(r*o[2]+a*o[6]+i*o[10]+o[14])*s,n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*r+s*i-l*a,d=c*a+l*r-o*i,h=c*i+o*a-s*r,_=-o*r-s*a-l*i;n._x=u*c-_*o-d*l+h*s,n._y=d*c-_*s-h*o+u*l,n._z=h*c-_*l-u*s+d*o,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tT._zero=new tT(0,0,0),tT._one=new tT(1,1,1);var tA=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new tT,this.radius=0,e&&this.center.copyFrom(e),this.radius=t}var t=e.prototype;return t.clone=function(){return new e(this.center,this.radius)},t.copyFrom=function(e){return this.center.copyFrom(e.center),this.radius=e.radius,this},e.fromPoints=function(t,n){if(!t||0===t.length)throw Error("points must be array and length must > 0");var r=t.length,a=e._tempVec30;a.x=a.y=a.z=0;for(var i=0;i<r;++i)tT.add(t[i],a,a);tT.scale(a,1/r,n.center);for(var o=0,s=0;s<r;++s){var l=tT.distanceSquared(a,t[s]);l>o&&(o=l)}n.radius=Math.sqrt(o)},e.fromBox=function(e,t){var n=t.center,r=e.min,a=e.max;n.x=(r.x+a.x)*.5,n.y=(r.y+a.y)*.5,n.z=(r.z+a.z)*.5,t.radius=tT.distance(n,a)},e}();tA._tempVec30=new tT;var tE=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new tT,this.max=new tT,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}var t=e.prototype;return t.getCenter=function(e){var t=this.min,n=this.max,r=n._x+t._x,a=n._y+t._y,i=n._z+t._z;return e.set(isNaN(r)?0:.5*r,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},t.getExtent=function(e){var t=this.min,n=this.max,r=n._x-t._x,a=n._y-t._y,i=n._z-t._z;return e.set(isNaN(r)?0:.5*r,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},t.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,n=this.max,r=t.x,a=t.y,i=t.z,o=n.x,s=n.y,l=n.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new tT;return e[0].set(r,s,l),e[1].set(o,s,l),e[2].set(o,a,l),e[3].set(r,a,l),e[4].set(r,s,i),e[5].set(o,s,i),e[6].set(o,a,i),e[7].set(r,a,i),e},t.transform=function(t){return e.transform(this,t,this),this},t.clone=function(){return new e(this.min,this.max)},t.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},e.fromCenterAndExtent=function(e,t,n){tT.subtract(e,t,n.min),tT.add(e,t,n.max)},e.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var n=t.min,r=t.max;n.x=n.y=n.z=Number.MAX_VALUE,r.x=r.y=r.z=-Number.MAX_VALUE;for(var a=0,i=e.length;a<i;++a){var o=e[a];tT.min(n,o,n),tT.max(r,o,r)}},e.fromSphere=function(e,t){var n=e.center,r=e.radius,a=t.min,i=t.max;a.x=n.x-r,a.y=n.y-r,a.z=n.z-r,i.x=n.x+r,i.y=n.y+r,i.z=n.z+r},e.transform=function(t,n,r){var a=e._tempVec30,i=e._tempVec31;t.getCenter(a),t.getExtent(i),tT.transformCoordinate(a,n,a);var o=i.x,s=i.y,l=i.z,c=n.elements,u=c[0],d=c[1],h=c[2],_=c[4],f=c[5],p=c[6],m=c[8],g=c[9],v=c[10];i.set((0===u?0:Math.abs(o*u))+(0===_?0:Math.abs(s*_))+(0===m?0:Math.abs(l*m)),(0===d?0:Math.abs(o*d))+(0===f?0:Math.abs(s*f))+(0===g?0:Math.abs(l*g)),(0===h?0:Math.abs(o*h))+(0===p?0:Math.abs(s*p))+(0===v?0:Math.abs(l*v))),tT.subtract(a,i,r.min),tT.add(a,i,r.max)},e.merge=function(e,t,n){return tT.min(e.min,t.min,n.min),tT.max(e.max,t.max,n.max),n},e}();tE._tempVec30=new tT,tE._tempVec31=new tT;var tR=/*#__PURE__*/function(){function e(){}return e.intersectionPointThreePlanes=function(t,n,r,a){var i=t.normal,o=n.normal,s=r.normal;tT.cross(o,s,e._tempVec30),tT.cross(s,i,e._tempVec31),tT.cross(i,o,e._tempVec32);var l=-tT.dot(i,e._tempVec30),c=-tT.dot(o,e._tempVec31),u=-tT.dot(s,e._tempVec32);tT.scale(e._tempVec30,t.distance/l,e._tempVec30),tT.scale(e._tempVec31,n.distance/c,e._tempVec31),tT.scale(e._tempVec32,r.distance/u,e._tempVec32),tT.add(e._tempVec30,e._tempVec31,a),tT.add(a,e._tempVec32,a)},e.distancePlaneAndPoint=function(e,t){return tT.dot(e.normal,t)+e.distance},e.intersectsPlaneAndPoint=function(t,n){var r=e.distancePlaneAndPoint(t,n);return r>0?ty.Front:r<0?ty.Back:ty.Intersecting},e.intersectsPlaneAndBox=function(t,n){var r=n.min,a=n.max,i=t.normal,o=e._tempVec30,s=e._tempVec31;return(i.x>=0?(o.x=a.x,s.x=r.x):(o.x=r.x,s.x=a.x),i.y>=0?(o.y=a.y,s.y=r.y):(o.y=r.y,s.y=a.y),i.z>=0?(o.z=a.z,s.z=r.z):(o.z=r.z,s.z=a.z),0>e.distancePlaneAndPoint(t,o))?ty.Back:e.distancePlaneAndPoint(t,s)>0?ty.Front:ty.Intersecting},e.intersectsPlaneAndSphere=function(t,n){var r=n.center,a=n.radius,i=e.distancePlaneAndPoint(t,r);return i>a?ty.Front:i<-a?ty.Back:ty.Intersecting},e.intersectsRayAndPlane=function(e,t){var n=t.normal,r=tS.zeroTolerance,a=tT.dot(n,e.direction);if(Math.abs(a)<r)return -1;var i=tT.dot(n,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-r)return -1;o=0}return o},e.intersectsRayAndBox=function(e,t){var n=tS.zeroTolerance,r=e.origin,a=e.direction,i=t.min,o=t.max,s=a.x,l=a.y,c=a.z,u=r.x,d=r.y,h=r.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<n){if(u<i.x||u>o.x)return -1}else{var p=1/s,m=(i.x-u)*p,g=(o.x-u)*p;if(m>g){var v=m;m=g,g=v}if((_=Math.max(m,_))>(f=Math.min(g,f)))return -1}if(Math.abs(l)<n){if(d<i.y||d>o.y)return -1}else{var y=1/l,x=(i.y-d)*y,b=(o.y-d)*y;if(x>b){var C=x;x=b,b=C}if((_=Math.max(x,_))>(f=Math.min(b,f)))return -1}if(Math.abs(c)<n){if(h<i.z||h>o.z)return -1}else{var S=1/c,T=(i.z-h)*S,A=(o.z-h)*S;if(T>A){var E=T;T=A,A=E}if((_=Math.max(T,_))>(f=Math.min(A,f)))return -1}return _},e.intersectsRayAndSphere=function(t,n){var r=t.origin,a=t.direction,i=n.center,o=n.radius,s=e._tempVec30;tT.subtract(r,i,s);var l=tT.dot(s,a),c=tT.dot(s,s)-o*o;if(l>0&&c>0)return -1;var u=l*l-c;if(u<0)return -1;var d=-l-Math.sqrt(u);return d<0&&(d=0),d},e.intersectsBoxAndBox=function(e,t){return!(e.min.x>t.max.x)&&!(t.min.x>e.max.x)&&!(e.min.y>t.max.y)&&!(t.min.y>e.max.y)&&!(e.min.z>t.max.z||t.min.z>e.max.z)},e.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return tT.distanceSquared(e.center,t.center)<n*n},e.intersectsSphereAndBox=function(t,n){var r=t.center,a=n.max,i=n.min,o=e._tempVec30;return o.set(Math.max(i.x,Math.min(r.x,a.x)),Math.max(i.y,Math.min(r.y,a.y)),Math.max(i.z,Math.min(r.z,a.z))),tT.distanceSquared(r,o)<=t.radius*t.radius},e.intersectsFrustumAndBox=function(t,n){for(var r=n.min,a=n.max,i=e._tempVec30,o=0;o<6;++o){var s=t.getPlane(o),l=s.normal;if(i.set(l.x>=0?a.x:r.x,l.y>=0?a.y:r.y,l.z>=0?a.z:r.z),tT.dot(l,i)<-s.distance)return!1}return!0},e.frustumContainsPoint=function(t,n){var r=e.distancePlaneAndPoint(t.near,n);return Math.abs(r)<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.far,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.left,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.right,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.top,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.bottom,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:tv.Contains},e.frustumContainsBox=function(t,n){for(var r=n.min,a=n.max,i=e._tempVec30,o=e._tempVec31,s=tv.Contains,l=0;l<6;++l){var c=t.getPlane(l),u=c.normal;if(u.x>=0?(i.x=a.x,o.x=r.x):(i.x=r.x,o.x=a.x),u.y>=0?(i.y=a.y,o.y=r.y):(i.y=r.y,o.y=a.y),u.z>=0?(i.z=a.z,o.z=r.z):(i.z=r.z,o.z=a.z),e.intersectsPlaneAndPoint(c,i)===ty.Back)return tv.Disjoint;e.intersectsPlaneAndPoint(c,o)===ty.Back&&(s=tv.Intersects)}return s},e.frustumContainsSphere=function(t,n){for(var r=tv.Contains,a=0;a<6;++a){var i=t.getPlane(a),o=e.intersectsPlaneAndSphere(i,n);if(o===ty.Back)return tv.Disjoint;if(o===ty.Intersecting){r=tv.Intersects;break}}return r},e}();tR._tempVec30=new tT,tR._tempVec31=new tT,tR._tempVec32=new tT;var tM=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new tT,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}var t=e.prototype;return t.normalize=function(){return e.normalize(this,this),this},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},e.normalize=function(e,t){var n=e.normal,r=1/n.length();tT.scale(n,r,t.normal),t.distance=e.distance*r},e.fromPoints=function(e,t,n,r){var a=e.x,i=e.y,o=e.z,s=t.x-a,l=t.y-i,c=t.z-o,u=n.x-a,d=n.y-i,h=n.z-o,_=l*h-c*d,f=c*u-s*h,p=s*d-l*u,m=1/Math.sqrt(_*_+f*f+p*p),g=_*m,v=f*m,y=p*m,x=r.normal;x.x=g,x.y=v,x.z=y,r.distance=-(g*a+v*i+y*o)},e}(),tw=/*#__PURE__*/function(){function e(e){void 0===e&&(e=null),this.near=new tM,this.far=new tM,this.left=new tM,this.right=new tM,this.top=new tM,this.bottom=new tM,e&&this.calculateFromMatrix(e)}var t=e.prototype;return t.getPlane=function(e){switch(e){case tx.Near:return this.near;case tx.Far:return this.far;case tx.Left:return this.left;case tx.Right:return this.right;case tx.Bottom:return this.bottom;case tx.Top:return this.top;default:return null}},t.calculateFromMatrix=function(e){var t=e.elements,n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],_=t[11],f=t[12],p=t[13],m=t[14],g=t[15];this.near.normal.set(i+a,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(i-a,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(i+n,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(i-n,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(i+r,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(i-r,c-s,_-d),this.top.distance=g-p,this.top.normalize()},t.intersectsBox=function(e){return tR.intersectsFrustumAndBox(this,e)},t.intersectsSphere=function(e){return tR.frustumContainsSphere(this,e)!==tv.Disjoint},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return this.near.copyFrom(e.near),this.far.copyFrom(e.far),this.left.copyFrom(e.left),this.right.copyFrom(e.right),this.bottom.copyFrom(e.bottom),this.top.copyFrom(e.top),this},e}(),tP=/*#__PURE__*/function(){function e(e,t,n,r,a,i,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l}var t=e.prototype;return t.set=function(e,t,n,r,a,i,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l,this},t.add=function(t){return e.add(this,t,this),this},t.subtract=function(t){return e.subtract(this,t,this),this},t.multiply=function(t){return e.multiply(this,t,this),this},t.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+n*(-c*a+o*s)+r*(l*a-i*s)},t.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},t.invert=function(){return e.invert(this,this),this},t.rotate=function(t){return e.rotate(this,t,this),this},t.scale=function(t){return e.scale(this,t,this),this},t.translate=function(t){return e.translate(this,t,this),this},t.transpose=function(){return e.transpose(this,this),this},t.clone=function(){var t=this.elements;return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},t.copyFrom=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},t.copyFromArray=function(e,t){void 0===t&&(t=0);for(var n=this.elements,r=0;r<12;r++)n[r]=e[r+t];return this},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.elements;e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8]},t.copyFromMatrix=function(e){var t=e.elements,n=this.elements;return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[4],n[4]=t[5],n[5]=t[6],n[6]=t[8],n[7]=t[9],n[8]=t[10],this},e.add=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3],i[4]=r[4]+a[4],i[5]=r[5]+a[5],i[6]=r[6]+a[6],i[7]=r[7]+a[7],i[8]=r[8]+a[8]},e.subtract=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]-a[0],i[1]=r[1]-a[1],i[2]=r[2]-a[2],i[3]=r[3]-a[3],i[4]=r[4]-a[4],i[5]=r[5]-a[5],i[6]=r[6]-a[6],i[7]=r[7]-a[7],i[8]=r[8]-a[8]},e.multiply=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],_=r[7],f=r[8],p=a[0],m=a[1],g=a[2],v=a[3],y=a[4],x=a[5],b=a[6],C=a[7],S=a[8];i[0]=o*p+c*m+h*g,i[1]=s*p+u*m+_*g,i[2]=l*p+d*m+f*g,i[3]=o*v+c*y+h*x,i[4]=s*v+u*y+_*x,i[5]=l*v+d*y+f*x,i[6]=o*b+c*C+h*S,i[7]=s*b+u*C+_*S,i[8]=l*b+d*C+f*S},e.equals=function(e,t){var n=e.elements,r=t.elements;return tS.equals(n[0],r[0])&&tS.equals(n[1],r[1])&&tS.equals(n[2],r[2])&&tS.equals(n[3],r[3])&&tS.equals(n[4],r[4])&&tS.equals(n[5],r[5])&&tS.equals(n[6],r[6])&&tS.equals(n[7],r[7])&&tS.equals(n[8],r[8])},e.lerp=function(e,t,n,r){var a=e.elements,i=t.elements,o=r.elements,s=1-n;o[0]=a[0]*s+i[0]*n,o[1]=a[1]*s+i[1]*n,o[2]=a[2]*s+i[2]*n,o[3]=a[3]*s+i[3]*n,o[4]=a[4]*s+i[4]*n,o[5]=a[5]*s+i[5]*n,o[6]=a[6]*s+i[6]*n,o[7]=a[7]*s+i[7]*n,o[8]=a[8]*s+i[8]*n},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,a=e._y,i=e._z,o=e._w,s=r+r,l=a+a,c=i+i,u=r*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;n[0]=1-h-p,n[3]=d-v,n[6]=_+g,n[1]=d+v,n[4]=1-u-p,n[7]=f-m,n[2]=_-g,n[5]=f+m,n[8]=1-u-h},e.scaling=function(e,t){var n=t.elements;n[0]=e._x,n[1]=0,n[2]=0,n[3]=0,n[4]=e._y,n[5]=0,n[6]=0,n[7]=0,n[8]=1},e.translation=function(e,t){var n=t.elements;n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=1,n[5]=0,n[6]=e._x,n[7]=e._y,n[8]=1},e.invert=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=h*l-c*d,f=-h*s+c*u,p=d*s-l*u,m=a*_+i*f+o*p;m&&(m=1/m,r[0]=_*m,r[1]=(-h*i+o*d)*m,r[2]=(c*i-o*l)*m,r[3]=f*m,r[4]=(h*a-o*u)*m,r[5]=(-c*a+o*s)*m,r[6]=p*m,r[7]=(-d*a+i*u)*m,r[8]=(l*a-i*s)*m)},e.normalMatrix=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15],x=a*c-i*l,b=a*u-o*l,C=a*d-s*l,S=i*u-o*c,T=i*d-s*c,A=o*d-s*u,E=h*g-_*m,R=h*v-f*m,M=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+C*w+S*M-T*R+A*E;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(u*M-l*F-d*R)*L,r[2]=(l*P-c*M+d*E)*L,r[3]=(o*P-i*F-s*w)*L,r[4]=(a*F-o*M+s*R)*L,r[5]=(i*M-a*P-s*E)*L,r[6]=(g*A-v*T+y*S)*L,r[7]=(v*C-m*A-y*b)*L,r[8]=(m*T-g*C+y*x)*L},e.rotate=function(e,t,n){var r=e.elements,a=n.elements,i=Math.sin(t),o=Math.cos(t),s=r[0],l=r[1],c=r[2],u=r[3],d=r[4],h=r[5],_=r[6],f=r[7],p=r[8];a[0]=o*s+i*u,a[1]=o*l+i*d,a[2]=o*c+i*h,a[3]=o*u-i*s,a[4]=o*d-i*l,a[5]=o*h-i*c,a[6]=_,a[7]=f,a[8]=p},e.scale=function(e,t,n){var r=t._x,a=t._y,i=e.elements,o=n.elements;o[0]=r*i[0],o[1]=r*i[1],o[2]=r*i[2],o[3]=a*i[3],o[4]=a*i[4],o[5]=a*i[5],o[6]=i[6],o[7]=i[7],o[8]=i[8]},e.translate=function(e,t,n){var r=t._x,a=t._y,i=e.elements,o=n.elements,s=i[0],l=i[1],c=i[2],u=i[3],d=i[4],h=i[5],_=i[6],f=i[7],p=i[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=d,o[5]=h,o[6]=r*s+a*u+_,o[7]=r*l+a*d+f,o[8]=r*c+a*h+p},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var a=n[1],i=n[2],o=n[5];r[1]=n[3],r[2]=n[6],r[3]=a,r[5]=n[7],r[6]=i,r[7]=o}else r[0]=n[0],r[1]=n[3],r[2]=n[6],r[3]=n[1],r[4]=n[4],r[5]=n[7],r[6]=n[2],r[7]=n[5],r[8]=n[8]},e}(),tF=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),this._onValueChanged=null,this._x=e,this._y=t,this._z=n,this._w=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},t.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},t.getAxisAngle=function(e){var t=this._x,n=this._y,r=this._z,a=t*t+n*n+r*r;if(a<tS.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var i=1/a;return e._x=this._x*i,e._y=this._y*i,e._z=this._z*i,2*Math.acos(this._w)},t.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},t.normalize=function(){return e.normalize(this,this),this},t.toEuler=function(e){this._toYawPitchRoll(e);var t=e._x;return e._x=e._y,e._y=t,e._onValueChanged&&e._onValueChanged(),e},t.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),e._onValueChanged&&e._onValueChanged(),e},t.rotateX=function(t){return e.rotateX(this,t,this),this},t.rotateY=function(t){return e.rotateY(this,t,this),this},t.rotateZ=function(t){return e.rotateZ(this,t,this),this},t.rotationAxisAngle=function(t,n){return e.rotationAxisAngle(t,n,this),this},t.multiply=function(t){return e.multiply(this,t,this),this},t.invert=function(){return e.invert(this,this),this},t.dot=function(t){return e.dot(this,t)},t.lerp=function(t,n){return e.lerp(this,t,n,this),this},t.rotateAxisAngle=function(t,n){return e._tempQuat1.rotationAxisAngle(t,n),this.multiply(e._tempQuat1),this},t.clone=function(){return new e(this._x,this._y,this._z,this._w)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},t._toYawPitchRoll=function(e){var t=this._x,n=this._y,r=this._z,a=this._w,i=t*t,o=n*n,s=r*r,l=a*a,c=i+o+s+l,u=2*(t*a-n*r);u>(1-tS.zeroTolerance)*c?(e._x=Math.atan2(2*(a*n-t*r),i+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-tS.zeroTolerance)*c?(e._x=Math.atan2(2*(a*n-t*r),i+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(r*t+n*a),s+l-o-i),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*n+r*a),o+l-s-i))},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._w=e._w+t._w,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;n._x=r*u+o*s+a*c-i*l,n._y=a*u+o*l+i*s-r*c,n._z=i*u+o*c+r*l-a*s,n._w=o*u-r*s-a*l-i*c,n._onValueChanged&&n._onValueChanged()},e.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)&&tS.equals(e._z,t._z)&&tS.equals(e._w,t._w)},e.rotationAxisAngle=function(t,n,r){var a=e._tempVector3;tT.normalize(t,a);var i=Math.sin(n*=.5);r._x=a._x*i,r._y=a._y*i,r._z=a._z*i,r._w=Math.cos(n),r._onValueChanged&&r._onValueChanged()},e.rotationEuler=function(t,n,r,a){e.rotationYawPitchRoll(n,t,r,a)},e.rotationYawPitchRoll=function(e,t,n,r){var a=.5*n,i=.5*t,o=.5*e,s=Math.sin(a),l=Math.cos(a),c=Math.sin(i),u=Math.cos(i),d=Math.sin(o),h=Math.cos(o),_=h*u,f=d*c;r._x=h*c*l+d*u*s,r._y=d*u*l-h*c*s,r._z=_*s-f*l,r._w=_*l+f*s,r._onValueChanged&&r._onValueChanged()},e.rotationMatrix3x3=function(e,t){var n,r,a=e.elements,i=a[0],o=a[1],s=a[2],l=a[3],c=a[4],u=a[5],d=a[6],h=a[7],_=a[8],f=i+c+_;f>0?(n=Math.sqrt(f+1),t._w=.5*n,n=.5/n,t._x=(u-h)*n,t._y=(d-s)*n,t._z=(o-l)*n):i>=c&&i>=_?(r=.5/(n=Math.sqrt(1+i-c-_)),t._x=.5*n,t._y=(o+l)*r,t._z=(s+d)*r,t._w=(u-h)*r):c>_?(r=.5/(n=Math.sqrt(1+c-i-_)),t._x=(l+o)*r,t._y=.5*n,t._z=(h+u)*r,t._w=(d-s)*r):(r=.5/(n=Math.sqrt(1+_-i-c)),t._x=(s+d)*r,t._y=(u+h)*r,t._z=.5*n,t._w=(o-l)*r),t._onValueChanged&&t._onValueChanged()},e.invert=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=n*n+r*r+a*a+i*i;if(o>tS.zeroTolerance){var s=1/o;t._x=-n*s,t._y=-r*s,t._z=-a*s,t._w=i*s,t._onValueChanged&&t._onValueChanged()}},e.lerp=function(t,n,r,a){var i=1-r;e.dot(t,n)>=0?(a._x=t._x*i+n._x*r,a._y=t._y*i+n._y*r,a._z=t._z*i+n._z*r,a._w=t._w*i+n._w*r):(a._x=t._x*i-n._x*r,a._y=t._y*i-n._y*r,a._z=t._z*i-n._z*r,a._w=t._w*i-n._w*r),a.normalize()},e.slerp=function(t,n,r,a){var i,o,s=e.dot(t,n);if(Math.abs(s)>1-tS.zeroTolerance)o=1-r,i=r*Math.sign(s);else{var l=Math.acos(Math.abs(s)),c=1/Math.sin(l);o=Math.sin((1-r)*l)*c,i=Math.sin(r*l)*c*Math.sign(s)}a.x=o*t.x+i*n.x,a.y=o*t.y+i*n.y,a.z=o*t.z+i*n.z,a.w=o*t.w+i*n.w,a._onValueChanged&&a._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=Math.sqrt(n*n+r*r+a*a+i*i);o>tS.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},e.rotationX=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=n,t._y=0,t._z=0,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotationY=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=0,t._y=n,t._z=0,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotationZ=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=0,t._y=0,t._z=n,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotateX=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+o*s,n._y=a*l+i*s,n._z=i*l-a*s,n._w=o*l-r*s,n._onValueChanged&&n._onValueChanged()},e.rotateY=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l-i*s,n._y=a*l+o*s,n._z=i*l+r*s,n._w=o*l-a*s,n._onValueChanged&&n._onValueChanged()},e.rotateZ=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+a*s,n._y=a*l-r*s,n._z=i*l+o*s,n._w=o*l-i*s,n._onValueChanged&&n._onValueChanged()},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._w=e._w*t,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<tS.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tF._tempVector3=new tT,tF._tempQuat1=new tF;var tL=/*#__PURE__*/function(){function e(e,t,n,r,a,i,o,s,l,c,u,d,h,_,f,p){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===u&&(u=1),void 0===d&&(d=0),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===p&&(p=1),this.elements=new Float32Array(16);var m=this.elements;m[0]=e,m[1]=t,m[2]=n,m[3]=r,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,m[12]=h,m[13]=_,m[14]=f,m[15]=p}var t=e.prototype;return t.set=function(e,t,n,r,a,i,o,s,l,c,u,d,h,_,f,p){var m=this.elements;return m[0]=e,m[1]=t,m[2]=n,m[3]=r,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,m[12]=h,m[13]=_,m[14]=f,m[15]=p,this},t.multiply=function(t){return e.multiply(this,t,this),this},t.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],_=e[12],f=e[13],p=e[14],m=e[15];return(t*o-n*i)*(d*m-h*p)-(t*s-r*i)*(u*m-h*f)+(t*l-a*i)*(u*p-d*f)+(n*s-r*o)*(c*m-h*_)-(n*l-a*o)*(c*p-d*_)+(r*l-a*s)*(c*f-u*_)},t.decompose=function(t,n,r){var a=e._tempMat30,i=this.elements,o=a.elements,s=i[0],l=i[1],c=i[2],u=i[4],d=i[5],h=i[6],_=i[8],f=i[9],p=i[10];t.set(i[12],i[13],i[14]);var m=Math.sqrt(s*s+l*l+c*c),g=Math.sqrt(u*u+d*d+h*h),v=Math.sqrt(_*_+f*f+p*p);if(0>this.determinant()&&(m=-m),r.set(m,g,v),Math.abs(m)<tS.zeroTolerance||Math.abs(g)<tS.zeroTolerance||Math.abs(v)<tS.zeroTolerance)return n.identity(),!1;var y=1/m,x=1/g,b=1/v;return o[0]=s*y,o[1]=l*y,o[2]=c*y,o[3]=u*x,o[4]=d*x,o[5]=h*x,o[6]=_*b,o[7]=f*b,o[8]=p*b,tF.rotationMatrix3x3(a,n),!0},t.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>tS.zeroTolerance){var r=2*Math.sqrt(n+1);e._w=.25*r,e._x=(t[6]-t[9])/r,e._y=(t[8]-t[2])/r,e._z=(t[1]-t[4])/r}else if(t[0]>t[5]&&t[0]>t[10]){var a=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/a,e._x=.25*a,e._y=(t[1]+t[4])/a,e._z=(t[8]+t[2])/a}else if(t[5]>t[10]){var i=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/i,e._x=(t[1]+t[4])/i,e._y=.25*i,e._z=(t[6]+t[9])/i}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},t.getScaling=function(e){var t=this.elements,n=t[0],r=t[1],a=t[2],i=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(n*n+r*r+a*a),Math.sqrt(i*i+o*o+s*s),Math.sqrt(l*l+c*c+u*u)),e},t.getTranslation=function(e){var t=this.elements;return e.set(t[12],t[13],t[14]),e},t.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},t.invert=function(){return e.invert(this,this),this},t.rotateAxisAngle=function(t,n){return e.rotateAxisAngle(this,t,n,this),this},t.scale=function(t){return e.scale(this,t,this),this},t.translate=function(t){return e.translate(this,t,this),this},t.transpose=function(){return e.transpose(this,this),this},t.clone=function(){var t=this.elements;return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},t.copyFrom=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},t.copyFromArray=function(e,t){void 0===t&&(t=0);for(var n=this.elements,r=0;r<16;r++)n[r]=e[r+t];return this},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.elements;e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15]},e.multiply=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],_=r[7],f=r[8],p=r[9],m=r[10],g=r[11],v=r[12],y=r[13],x=r[14],b=r[15],C=a[0],S=a[1],T=a[2],A=a[3],E=a[4],R=a[5],M=a[6],w=a[7],P=a[8],F=a[9],L=a[10],D=a[11],B=a[12],I=a[13],O=a[14],N=a[15];i[0]=o*C+u*S+f*T+v*A,i[1]=s*C+d*S+p*T+y*A,i[2]=l*C+h*S+m*T+x*A,i[3]=c*C+_*S+g*T+b*A,i[4]=o*E+u*R+f*M+v*w,i[5]=s*E+d*R+p*M+y*w,i[6]=l*E+h*R+m*M+x*w,i[7]=c*E+_*R+g*M+b*w,i[8]=o*P+u*F+f*L+v*D,i[9]=s*P+d*F+p*L+y*D,i[10]=l*P+h*F+m*L+x*D,i[11]=c*P+_*F+g*L+b*D,i[12]=o*B+u*I+f*O+v*N,i[13]=s*B+d*I+p*O+y*N,i[14]=l*B+h*I+m*O+x*N,i[15]=c*B+_*I+g*O+b*N},e.equals=function(e,t){var n=e.elements,r=t.elements;return tS.equals(n[0],r[0])&&tS.equals(n[1],r[1])&&tS.equals(n[2],r[2])&&tS.equals(n[3],r[3])&&tS.equals(n[4],r[4])&&tS.equals(n[5],r[5])&&tS.equals(n[6],r[6])&&tS.equals(n[7],r[7])&&tS.equals(n[8],r[8])&&tS.equals(n[9],r[9])&&tS.equals(n[10],r[10])&&tS.equals(n[11],r[11])&&tS.equals(n[12],r[12])&&tS.equals(n[13],r[13])&&tS.equals(n[14],r[14])&&tS.equals(n[15],r[15])},e.lerp=function(e,t,n,r){var a=e.elements,i=t.elements,o=r.elements,s=1-n;o[0]=a[0]*s+i[0]*n,o[1]=a[1]*s+i[1]*n,o[2]=a[2]*s+i[2]*n,o[3]=a[3]*s+i[3]*n,o[4]=a[4]*s+i[4]*n,o[5]=a[5]*s+i[5]*n,o[6]=a[6]*s+i[6]*n,o[7]=a[7]*s+i[7]*n,o[8]=a[8]*s+i[8]*n,o[9]=a[9]*s+i[9]*n,o[10]=a[10]*s+i[10]*n,o[11]=a[11]*s+i[11]*n,o[12]=a[12]*s+i[12]*n,o[13]=a[13]*s+i[13]*n,o[14]=a[14]*s+i[14]*n,o[15]=a[15]*s+i[15]*n},e.add=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3],i[4]=r[4]+a[4],i[5]=r[5]+a[5],i[6]=r[6]+a[6],i[7]=r[7]+a[7],i[8]=r[8]+a[8],i[9]=r[9]+a[9],i[10]=r[10]+a[10],i[11]=r[11]+a[11],i[12]=r[12]+a[12],i[13]=r[13]+a[13],i[14]=r[14]+a[14],i[15]=r[15]+a[15]},e.multiplyScalar=function(e,t,n){var r=e.elements,a=n.elements;a[0]=r[0]*t,a[1]=r[1]*t,a[2]=r[2]*t,a[3]=r[3]*t,a[4]=r[4]*t,a[5]=r[5]*t,a[6]=r[6]*t,a[7]=r[7]*t,a[8]=r[8]*t,a[9]=r[9]*t,a[10]=r[10]*t,a[11]=r[11]*t,a[12]=r[12]*t,a[13]=r[13]*t,a[14]=r[14]*t,a[15]=r[15]*t},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,a=e._y,i=e._z,o=e._w,s=r+r,l=a+a,c=i+i,u=r*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;n[0]=1-h-p,n[1]=d+v,n[2]=_-g,n[3]=0,n[4]=d-v,n[5]=1-u-p,n[6]=f+m,n[7]=0,n[8]=_+g,n[9]=f-m,n[10]=1-u-h,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},e.rotationAxisAngle=function(e,t,n){var r,a,i,o=n.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<tS.zeroTolerance||(s*=u=1/u,l*=u,c*=u,r=Math.sin(t),i=1-(a=Math.cos(t)),o[0]=s*s*i+a,o[1]=l*s*i+c*r,o[2]=c*s*i-l*r,o[3]=0,o[4]=s*l*i-c*r,o[5]=l*l*i+a,o[6]=c*l*i+s*r,o[7]=0,o[8]=s*c*i+l*r,o[9]=l*c*i-s*r,o[10]=c*c*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},e.rotationTranslation=function(t,n,r){e.rotationQuaternion(t,r);var a=r.elements;a[12]=n._x,a[13]=n._y,a[14]=n._z},e.affineTransformation=function(e,t,n,r){var a=r.elements,i=t._x,o=t._y,s=t._z,l=t._w,c=i+i,u=o+o,d=s+s,h=i*c,_=i*u,f=i*d,p=o*u,m=o*d,g=s*d,v=l*c,y=l*u,x=l*d,b=e._x,C=e._y,S=e._z;a[0]=(1-(p+g))*b,a[1]=(_+x)*b,a[2]=(f-y)*b,a[3]=0,a[4]=(_-x)*C,a[5]=(1-(h+g))*C,a[6]=(m+v)*C,a[7]=0,a[8]=(f+y)*S,a[9]=(m-v)*S,a[10]=(1-(h+p))*S,a[11]=0,a[12]=n._x,a[13]=n._y,a[14]=n._z,a[15]=1},e.scaling=function(e,t){var n=t.elements;n[0]=e._x,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e._y,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e._z,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},e.translation=function(e,t){var n=t.elements;n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e._x,n[13]=e._y,n[14]=e._z,n[15]=1},e.invert=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15],x=a*c-i*l,b=a*u-o*l,C=a*d-s*l,S=i*u-o*c,T=i*d-s*c,A=o*d-s*u,E=h*g-_*m,R=h*v-f*m,M=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+C*w+S*M-T*R+A*E;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(o*P-i*F-s*w)*L,r[2]=(g*A-v*T+y*S)*L,r[3]=(f*T-_*A-p*S)*L,r[4]=(u*M-l*F-d*R)*L,r[5]=(a*F-o*M+s*R)*L,r[6]=(v*C-m*A-y*b)*L,r[7]=(h*A-f*C+p*b)*L,r[8]=(l*P-c*M+d*E)*L,r[9]=(i*M-a*P-s*E)*L,r[10]=(m*T-g*C+y*x)*L,r[11]=(_*C-h*T-p*x)*L,r[12]=(c*R-l*w-u*E)*L,r[13]=(a*w-i*R+o*E)*L,r[14]=(g*b-m*S-v*x)*L,r[15]=(h*S-_*b+f*x)*L},e.lookAt=function(t,n,r,a){var i=a.elements,o=e._tempVec30,s=e._tempVec31,l=e._tempVec32;tT.subtract(t,n,l),l.normalize(),tT.cross(r,l,o),o.normalize(),tT.cross(l,o,s),i[0]=o._x,i[1]=s._x,i[2]=l._x,i[3]=0,i[4]=o._y,i[5]=s._y,i[6]=l._y,i[7]=0,i[8]=o._z,i[9]=s._z,i[10]=l._z,i[11]=0,i[12]=-tT.dot(o,t),i[13]=-tT.dot(s,t),i[14]=-tT.dot(l,t),i[15]=1},e.ortho=function(e,t,n,r,a,i,o){var s=o.elements,l=1/(e-t),c=1/(n-r),u=1/(a-i);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*u,s[11]=0,s[12]=(e+t)*l,s[13]=(r+n)*c,s[14]=(i+a)*u,s[15]=1},e.perspective=function(e,t,n,r,a){var i=a.elements,o=1/Math.tan(e/2),s=1/(n-r);i[0]=o/t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(r+n)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=2*r*n*s,i[15]=0},e.rotateAxisAngle=function(e,t,n,r){var a,i,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<tS.zeroTolerance)){var d=e.elements,h=r.elements;s*=u=1/u,l*=u,c*=u,a=Math.sin(n),o=1-(i=Math.cos(n));var _=d[0],f=d[1],p=d[2],m=d[3],g=d[4],v=d[5],y=d[6],x=d[7],b=d[8],C=d[9],S=d[10],T=d[11],A=s*s*o+i,E=l*s*o+c*a,R=c*s*o-l*a,M=s*l*o-c*a,w=l*l*o+i,P=c*l*o+s*a,F=s*c*o+l*a,L=l*c*o-s*a,D=c*c*o+i;h[0]=_*A+g*E+b*R,h[1]=f*A+v*E+C*R,h[2]=p*A+y*E+S*R,h[3]=m*A+x*E+T*R,h[4]=_*M+g*w+b*P,h[5]=f*M+v*w+C*P,h[6]=p*M+y*w+S*P,h[7]=m*M+x*w+T*P,h[8]=_*F+g*L+b*D,h[9]=f*F+v*L+C*D,h[10]=p*F+y*L+S*D,h[11]=m*F+x*L+T*D,e!==r&&(h[12]=d[12],h[13]=d[13],h[14]=d[14],h[15]=d[15])}},e.scale=function(e,t,n){var r=e.elements,a=n.elements,i=t._x,o=t._y,s=t._z;a[0]=r[0]*i,a[1]=r[1]*i,a[2]=r[2]*i,a[3]=r[3]*i,a[4]=r[4]*o,a[5]=r[5]*o,a[6]=r[6]*o,a[7]=r[7]*o,a[8]=r[8]*s,a[9]=r[9]*s,a[10]=r[10]*s,a[11]=r[11]*s,a[12]=r[12],a[13]=r[13],a[14]=r[14],a[15]=r[15]},e.translate=function(e,t,n){var r=e.elements,a=n.elements,i=t._x,o=t._y,s=t._z;if(e===n)a[12]=r[0]*i+r[4]*o+r[8]*s+r[12],a[13]=r[1]*i+r[5]*o+r[9]*s+r[13],a[14]=r[2]*i+r[6]*o+r[10]*s+r[14],a[15]=r[3]*i+r[7]*o+r[11]*s+r[15];else{var l=r[0],c=r[1],u=r[2],d=r[3],h=r[4],_=r[5],f=r[6],p=r[7],m=r[8],g=r[9],v=r[10],y=r[11];a[0]=l,a[1]=c,a[2]=u,a[3]=d,a[4]=h,a[5]=_,a[6]=f,a[7]=p,a[8]=m,a[9]=g,a[10]=v,a[11]=y,a[12]=l*i+h*o+m*s+r[12],a[13]=c*i+_*o+g*s+r[13],a[14]=u*i+f*o+v*s+r[14],a[15]=d*i+p*o+y*s+r[15]}},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var a=n[1],i=n[2],o=n[3],s=n[6],l=n[7],c=n[11];r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=a,r[6]=n[9],r[7]=n[13],r[8]=i,r[9]=s,r[11]=n[14],r[12]=o,r[13]=l,r[14]=c}else r[0]=n[0],r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=n[1],r[5]=n[5],r[6]=n[9],r[7]=n[13],r[8]=n[2],r[9]=n[6],r[10]=n[10],r[11]=n[14],r[12]=n[3],r[13]=n[7],r[14]=n[11],r[15]=n[15]},e}();tL._tempVec30=new tT,tL._tempVec31=new tT,tL._tempVec32=new tT,tL._tempMat30=new tP,tL._identity=new tL(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var tD=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new tT,this.direction=new tT,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}var t=e.prototype;return t.intersectPlane=function(e){return tR.intersectsRayAndPlane(this,e)},t.intersectSphere=function(e){return tR.intersectsRayAndSphere(this,e)},t.intersectBox=function(e){return tR.intersectsRayAndBox(this,e)},t.getPoint=function(e,t){return tT.scale(this.direction,e,t),t.add(this.origin)},e}(),tB=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}var t=e.prototype;return t.set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},t.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._x,this._y)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},t.toJSON=function(){return{x:this._x,y:this._y}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y;return Math.sqrt(n*n+r*r)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y;return n*n+r*r},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=Math.sqrt(n*n+r*r);a>tS.zeroTolerance&&(a=1/a,t._x=n*a,t._y=r*a,t._onValueChanged&&t._onValueChanged())},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tB._zero=new tB(0,0),tB._one=new tB(1,1);var tI=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=n,this._w=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._x,this._y,this._z,this._w)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._w=e._w+t._w,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._z=e._z-t._z,n._w=e._w-t._w,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._z=e._z*t._z,n._w=e._w*t._w,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._z=e._z/t._z,n._w=e._w/t._w,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return Math.sqrt(n*n+r*r+a*a+i*i)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return n*n+r*r+a*a+i*i},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)&&tS.equals(e._z,t._z)&&tS.equals(e._w,t._w)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y,o=e._z,s=e._w;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._z=o+(t._z-o)*n,r._w=s+(t._w-s)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._z=Math.max(e._z,t._z),n._w=Math.max(e._w,t._w),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._z=Math.min(e._z,t._z),n._w=Math.min(e._w,t._w),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=Math.sqrt(n*n+r*r+a*a+i*i);o>tS.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._w=e._w*t,n._onValueChanged&&n._onValueChanged()},e.transform=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t.elements;n._x=r*s[0]+a*s[4]+i*s[8]+o*s[12],n._y=r*s[1]+a*s[5]+i*s[9]+o*s[13],n._z=r*s[2]+a*s[6]+i*s[10]+o*s[14],n._w=r*s[3]+a*s[7]+i*s[11]+o*s[15],n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,d=u*r+l*i-c*a,h=u*a+c*r-s*i,_=u*i+s*a-l*r,f=-s*r-l*a-c*i;n._x=d*u-f*s-h*c+_*l,n._y=h*u-f*l-_*s+d*c,n._z=_*u-f*c-d*l+h*s,n._w=o,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tI._zero=new tI(0,0,0,0),tI._one=new tI(1,1,1,1);var tO=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),this._onValueChanged=null,this._r=e,this._g=t,this._b=n,this._a=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,this._onValueChanged&&this._onValueChanged(),this},t.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._r,this._g,this._b,this._a)},t.copyFrom=function(e){return this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.r=this._r,e.g=this._g,e.b=this._b,e.a=this._a,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._r=e[t],this._g=e[t+1],this._b=e[t+2],this._a=e[t+3],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._r,e[t+1]=this._g,e[t+2]=this._b,e[t+3]=this._a},t.toLinear=function(t){return t._r=e.gammaToLinearSpace(this._r),t._g=e.gammaToLinearSpace(this._g),t._b=e.gammaToLinearSpace(this._b),t._onValueChanged&&t._onValueChanged(),t},t.toGamma=function(t){return t._r=e.linearToGammaSpace(this._r),t._g=e.linearToGammaSpace(this._g),t._b=e.linearToGammaSpace(this._b),t._onValueChanged&&t._onValueChanged(),t},t.getBrightness=function(){var e=this.r,t=this.g,n=this.b,r=e,a=e;return t>r&&(r=t),n>r&&(r=n),t<a&&(a=t),n<a&&(a=n),(r+a)/2},t.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},e.gammaToLinearSpace=function(e){return e<=0?0:e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},e.linearToGammaSpace=function(e){return e<=0?0:e<.0031308?12.92*e:e<1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},e.equals=function(e,t){return tS.equals(e._r,t._r)&&tS.equals(e._g,t._g)&&tS.equals(e._b,t._b)&&tS.equals(e._a,t._a)},e.add=function(e,t,n){return n._r=e._r+t._r,n._g=e._g+t._g,n._b=e._b+t._b,n._a=e._a+t._a,n._onValueChanged&&n._onValueChanged(),n},e.subtract=function(e,t,n){n._r=e._r-t._r,n._g=e._g-t._g,n._b=e._b-t._b,n._a=e._a-t._a,n._onValueChanged&&n._onValueChanged()},e.scale=function(e,t,n){return n._r=e._r*t,n._g=e._g*t,n._b=e._b*t,n._a=e._a*t,n._onValueChanged&&n._onValueChanged(),n},e.lerp=function(e,t,n,r){var a=e._r,i=e._g,o=e._b,s=e._a;return r._r=a+(t._r-a)*n,r._g=i+(t._g-i)*n,r._b=o+(t._b-o)*n,r._a=s+(t._a-s)*n,r._onValueChanged&&r._onValueChanged(),r},tC(e,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,this._onValueChanged&&this._onValueChanged()}}]),e}(),tN=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._width=n,this._height=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._width=n,this._height=r,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this.x,this.y,this.width,this.height)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._width=e.width,this._height=e.height,this._onValueChanged&&this._onValueChanged(),this},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._onValueChanged&&this._onValueChanged()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._onValueChanged&&this._onValueChanged()}}]),e}(),tV=/*#__PURE__*/function(){function e(){this.coefficients=new Float32Array(27)}var t=e.prototype;return t.addLight=function(e,t,n){t.scale(n);var r=this.coefficients,a=e._x,i=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*i,d=.488603*o,h=-.488603*a,_=a*i*1.092548,f=-(i*o*1.092548),p=.315392*(3*o*o-1),m=-(a*o*1.092548),g=.546274*(a*a-i*i);r[0]+=.282095*s,r[1]+=.282095*l,r[2]+=.282095*c,r[3]+=s*u,r[4]+=l*u,r[5]+=c*u,r[6]+=s*d,r[7]+=l*d,r[8]+=c*d,r[9]+=s*h,r[10]+=l*h,r[11]+=c*h,r[12]+=s*_,r[13]+=l*_,r[14]+=c*_,r[15]+=s*f,r[16]+=l*f,r[17]+=c*f,r[18]+=s*p,r[19]+=l*p,r[20]+=c*p,r[21]+=s*m,r[22]+=l*m,r[23]+=c*m,r[24]+=s*g,r[25]+=l*g,r[26]+=c*g},t.evaluate=function(e,t){var n=this.coefficients,r=e._x,a=e._y,i=e._z,o=-1.023327*a,s=1.023327*i,l=-1.023327*r,c=.858086*a*r,u=-.858086*a*i,d=.247708*(3*i*i-1),h=-.858086*i*r,_=.429042*(r*r-a*a),f=.886227*n[0],p=.886227*n[1],m=.886227*n[2];return f+=n[3]*o+n[6]*s+n[9]*l,p+=n[4]*o+n[7]*s+n[10]*l,m+=n[5]*o+n[8]*s+n[11]*l,f+=n[12]*c+n[15]*u+n[18]*d+n[21]*h+n[24]*_,p+=n[13]*c+n[16]*u+n[19]*d+n[22]*h+n[25]*_,m+=n[14]*c+n[17]*u+n[20]*d+n[23]*h+n[26]*_,t.set(f,p,m,1),t},t.scale=function(e){var t=this.coefficients;t[0]*=e,t[1]*=e,t[2]*=e,t[3]*=e,t[4]*=e,t[5]*=e,t[6]*=e,t[7]*=e,t[8]*=e,t[9]*=e,t[10]*=e,t[11]*=e,t[12]*=e,t[13]*=e,t[14]*=e,t[15]*=e,t[16]*=e,t[17]*=e,t[18]*=e,t[19]*=e,t[20]*=e,t[21]*=e,t[22]*=e,t[23]*=e,t[24]*=e,t[25]*=e,t[26]*=e},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return e.copyToArray(this.coefficients),this},t.copyFromArray=function(e,t){void 0===t&&(t=0);var n=this.coefficients;n[0]=e[t],n[1]=e[1+t],n[2]=e[2+t],n[3]=e[3+t],n[4]=e[4+t],n[5]=e[5+t],n[6]=e[6+t],n[7]=e[7+t],n[8]=e[8+t],n[9]=e[9+t],n[10]=e[10+t],n[11]=e[11+t],n[12]=e[12+t],n[13]=e[13+t],n[14]=e[14+t],n[15]=e[15+t],n[16]=e[16+t],n[17]=e[17+t],n[18]=e[18+t],n[19]=e[19+t],n[20]=e[20+t],n[21]=e[21+t],n[22]=e[22+t],n[23]=e[23+t],n[24]=e[24+t],n[25]=e[25+t],n[26]=e[26+t]},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.coefficients;e[0+t]=n[0],e[1+t]=n[1],e[2+t]=n[2],e[3+t]=n[3],e[4+t]=n[4],e[5+t]=n[5],e[6+t]=n[6],e[7+t]=n[7],e[8+t]=n[8],e[9+t]=n[9],e[10+t]=n[10],e[11+t]=n[11],e[12+t]=n[12],e[13+t]=n[13],e[14+t]=n[14],e[15+t]=n[15],e[16+t]=n[16],e[17+t]=n[17],e[18+t]=n[18],e[19+t]=n[19],e[20+t]=n[20],e[21+t]=n[21],e[22+t]=n[22],e[23+t]=n[23],e[24+t]=n[24],e[25+t]=n[25],e[26+t]=n[26]},e}(),tk=/*#__PURE__*/function(){function e(e,t){this.reset(e,t)}var t=e.prototype;return t.randomInt32=function(){var e=this._state0,t=this._state1;return this._state0=t,e^=e<<23,e^=e>>>17,e^=t^t>>>26,this._state1=e,this._state0+this._state1>>>0},t.random=function(){return this.randomInt32()/0xffffffff},t.reset=function(e,t){this._state0=e>>>0,this._state1=t>>>0},e}(),tz=((i={})[i.Android=0]="Android",i[i.IPhone=1]="IPhone",i[i.IPad=2]="IPad",i[i.Mac=3]="Mac",i[i.Unknown=4]="Unknown",i);function tU(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tG(e,t,n){return t&&tU(e.prototype,t),n&&tU(e,n),e}function tH(e,t){return(tH=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tW(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tH(e,t)}var tj=/*#__PURE__*/function(){function e(){this.localPositions=new tI}return e.prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},e}();function tX(e,t,r,a){var i,o=arguments.length,s=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function tK(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}tj.triangles=[0,2,1,2,0,3],"function"==typeof SuppressedError&&SuppressedError;var tY=((o={})[o.Ignore=0]="Ignore",o[o.Assignment=1]="Assignment",o[o.Shallow=2]="Shallow",o[o.Deep=3]="Deep",o);function tq(e,t){t$.registerCloneMode(e,t,tY.Ignore)}function tQ(e,t){t$.registerCloneMode(e,t,tY.Assignment)}function tJ(e,t){t$.registerCloneMode(e,t,tY.Shallow)}function tZ(e,t){t$.registerCloneMode(e,t,tY.Deep)}var t$=/*#__PURE__*/function(){function e(){}return e.registerCloneMode=function(t,n,r){var a=e._subCloneModeMap.get(t.constructor);a||(a=Object.create(null),e._subCloneModeMap.set(t.constructor,a)),a[n]=r},e.getCloneMode=function(t){var n=e._cloneModeMap.get(t);if(!n){n=Object.create(null),e._cloneModeMap.set(t,n);for(var r=e._objectType,a=e._subCloneModeMap;t!==r;){var i=a.get(t);i&&Object.assign(n,i),t=Object.getPrototypeOf(t)}}return n},e.cloneProperty=function(t,n,r,a,i,o,s){if(a!==tY.Ignore){var l=t[r];if(tK(l,Object)){if(void 0===a||a===tY.Assignment){n[r]=l;return}switch(l.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var c=n[r];null==c||c.length!==l.length?n[r]=l.slice():c.set(l);break;case Array:var u=n[r],d=l.length;null==u?n[r]=u=Array(d):u.length=d;for(var h=0;h<d;h++)e.cloneProperty(l,u,h,a,i,o,s);break;default:var _=n[r];if(_||((_=s.get(l))||(_=new l.constructor,s.set(l,_)),n[r]=_),l.copyFrom)_.copyFrom(l);else{var f=e.getCloneMode(l.constructor);for(var p in l)e.cloneProperty(l,_,p,f[p],i,o,s);l._cloneTo&&l._cloneTo(_,i,o)}}}else n[r]=l}},e.deepCloneObject=function(t,n,r){for(var a in t)e.cloneProperty(t,n,a,tY.Deep,null,null,r)},e}();t$._subCloneModeMap=new Map,t$._cloneModeMap=new Map,t$._objectType=Object.getPrototypeOf(Object);var t0=/*#__PURE__*/function(){function e(t){this.instanceId=++e._instanceIdCounter,this._destroyed=!1,this._engine=t}var t=e.prototype;return t.destroy=function(){this._destroyed||(this._onDestroy(),this._destroyed=!0)},t._onDestroy=function(){var e=this._engine.resourceManager;e._deleteAsset(this),e._deleteContentRestorer(this)},tG(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();t0._instanceIdCounter=0,tX([tq],t0.prototype,"instanceId",void 0),tX([tq],t0.prototype,"_engine",void 0);var t1=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).isGCIgnored=!1,n._refCount=0,n._superResources=null,t.resourceManager._addReferResource(n),n}tW(t,e);var n=t.prototype;return n.destroy=function(t,n){if(void 0===t&&(t=!1),!t){if(0!==this._refCount)return!1;var r=this._superResources;if(null==r?void 0:r.length){if(!n)return!1;for(var a=0,i=r.length;a<i;a++)if(r[a].refCount>0)return!1}}return e.prototype.destroy.call(this),!0},n._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},n._disassociationSuperResource=function(e){var t=this._superResources,n=t.indexOf(e);t.splice(n,1)},n._getReferCount=function(){return this._refCount},n._addReferCount=function(e){this._refCount+=e},n._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var t=this._getReferCount();t>0&&this._addReferCount(-t)},tG(t,[{key:"refCount",get:function(){return this._refCount}}]),t}(t0),t2=function(e){this.resource=e},t3=((s={})[s.Depth=27]="Depth",s[s.Stencil=28]="Stencil",s[s.DepthStencil=29]="DepthStencil",s[s.Depth16=30]="Depth16",s[s.Depth24=31]="Depth24",s[s.Depth32=32]="Depth32",s[s.Depth24Stencil8=33]="Depth24Stencil8",s[s.Depth32Stencil8=34]="Depth32Stencil8",s),t4=((l={})[l.PositiveX=0]="PositiveX",l[l.NegativeX=1]="NegativeX",l[l.PositiveY=2]="PositiveY",l[l.NegativeY=3]="NegativeY",l[l.PositiveZ=4]="PositiveZ",l[l.NegativeZ=5]="NegativeZ",l),t8=((c={})[c.Never=0]="Never",c[c.Less=1]="Less",c[c.Equal=2]="Equal",c[c.LessEqual=3]="LessEqual",c[c.Greater=4]="Greater",c[c.NotEqual=5]="NotEqual",c[c.GreaterEqual=6]="GreaterEqual",c[c.Always=7]="Always",c),t5=((u={})[u.Point=0]="Point",u[u.Bilinear=1]="Bilinear",u[u.Trilinear=2]="Trilinear",u),t9=((d={})[d.R8G8B8=0]="R8G8B8",d[d.R8G8B8A8=1]="R8G8B8A8",d[d.R4G4B4A4=2]="R4G4B4A4",d[d.R5G5B5A1=3]="R5G5B5A1",d[d.R5G6B5=4]="R5G6B5",d[d.Alpha8=5]="Alpha8",d[d.LuminanceAlpha=6]="LuminanceAlpha",d[d.R16G16B16A16=7]="R16G16B16A16",d[d.R32G32B32A32=8]="R32G32B32A32",d[d.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",d[d.R11G11B10_UFloat=35]="R11G11B10_UFloat",d[d.BC1=10]="BC1",d[d.BC3=11]="BC3",d[d.BC7=12]="BC7",d[d.ETC1_RGB=13]="ETC1_RGB",d[d.ETC2_RGB=14]="ETC2_RGB",d[d.ETC2_RGBA5=15]="ETC2_RGBA5",d[d.ETC2_RGBA8=16]="ETC2_RGBA8",d[d.PVRTC_RGB2=17]="PVRTC_RGB2",d[d.PVRTC_RGBA2=18]="PVRTC_RGBA2",d[d.PVRTC_RGB4=19]="PVRTC_RGB4",d[d.PVRTC_RGBA4=20]="PVRTC_RGBA4",d[d.ASTC_4x4=21]="ASTC_4x4",d[d.ASTC_5x5=22]="ASTC_5x5",d[d.ASTC_6x6=23]="ASTC_6x6",d[d.ASTC_8x8=24]="ASTC_8x8",d[d.ASTC_10x10=25]="ASTC_10x10",d[d.ASTC_12x12=26]="ASTC_12x12",d[d.Depth=27]="Depth",d[d.Stencil=28]="Stencil",d[d.DepthStencil=29]="DepthStencil",d[d.Depth16=30]="Depth16",d[d.Depth24=31]="Depth24",d[d.Depth32=32]="Depth32",d[d.Depth24Stencil8=33]="Depth24Stencil8",d[d.Depth32Stencil8=34]="Depth32Stencil8",d[d.DXT1=10]="DXT1",d[d.DXT5=11]="DXT5",d),t6=((h={})[h.Static=0]="Static",h[h.Dynamic=1]="Dynamic",h),t7=((_={})[_.Clamp=0]="Clamp",_[_.Repeat=1]="Repeat",_[_.Mirror=2]="Mirror",_),ne=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._isContentLost=!1,t.resourceManager._addGraphicResource(n),n}return tW(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},tG(t,[{key:"isContentLost",get:function(){return this._isContentLost}}]),t}(t1),nt=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},nn=console.log.bind(console),nr=console.info.bind(console),na=console.warn.bind(console),ni=console.error.bind(console),no={debug:nt,info:nt,warn:nt,error:nt,isEnabled:!1,enable:function(){this.debug=nn,this.info=nr,this.warn=na,this.error=ni,this.isEnabled=!0},disable:function(){this.debug=nt,this.info=nt,this.warn=nt,this.error=nt,this.isEnabled=!1}},ns=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._isDepthTexture=!1,t._anisoLevel=1,t._useDepthCompareMode=!1,t}tW(t,e);var n=t.prototype;return n.generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},n._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},n._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,this._engine._hardwareRenderer._isWebGL2&&(e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode))},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},n._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},n._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},n._isIntFormat=function(){return t9.R32G32B32A32_UInt===this._format},tG(t,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){if(e!==this._filterMode){if(e!==t5.Point&&this._isIntFormat()){e=t5.Point,no.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=e,this._platformTexture.filterMode=e}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(no.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(no.warn("anisoLevel:"+e+", must be greater than 0, and is automatically downgraded to 1"),e=1),e!==this._anisoLevel&&(this._anisoLevel=e,this._platformTexture.anisoLevel=e)}},{key:"depthCompareFunction",get:function(){return this._depthCompareFunction},set:function(e){if(!this._engine._hardwareRenderer._isWebGL2){console.warn("depthCompareFunction only support WebGL2");return}e!==this._depthCompareFunction&&(this._depthCompareFunction=e,this._platformTexture.depthCompareFunction=e)}}]),t}(ne),nl=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){if(void 0===i&&(i=t9.Depth),void 0===o&&(o=1),(s=e.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._width=n,s._height=r,s._antiAliasing=o,s._depth=i,a){for(var s,l=tK(a,Array)?a.slice():[a],c=0,u=l.length;c<u;c++){var d=l[c];if(d._isDepthTexture)throw"Render texture can't use depth format.";d._addReferCount(1)}s._colorTextures=l}else s._colorTextures=[];if(tK(i,ns)){if(!i._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=i,s._depthTexture._addReferCount(1),s._depthFormat=i.format}else"number"==typeof i&&(s._depthFormat=i);return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(s),s}tW(t,e);var n=t.prototype;return n.getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},n.generateMipmaps=function(){if(this._autoGenerateMipmaps){for(var e=this._colorTextures,t=0,n=e.length;t<n;t++)e[t].generateMipmaps();this._depthTexture&&this._depthTexture.generateMipmaps()}},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var t,n=this._colorTextures,r=0,a=n.length;r<a;r++)n[r]._addReferCount(-1);n.length=0,null==(t=this._depthTexture)||t._addReferCount(-1),this._depthTexture=null,this._depth=null},n._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},n._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},tG(t,[{key:"autoGenerateMipmaps",get:function(){return this._autoGenerateMipmaps},set:function(e){this._autoGenerateMipmaps=e}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"colorTextureCount",get:function(){return this._colorTextures.length}},{key:"depthTexture",get:function(){return this._depthTexture}},{key:"antiAliasing",get:function(){return this._antiAliasing}}]),t}(ne),nc=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===a&&(a=t9.R8G8B8A8),void 0===i&&(i=!0),void 0===o&&(o=t6.Static),(s=e.call(this,t)||this)._mipmap=i,s._width=n,s._height=r,s._usage=o,s._format=a,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=a==t9.Depth||a==t9.DepthStencil||a==t9.Depth16||a==t9.Depth24||a==t9.Depth32||a==t9.Depth24Stencil8||a==t9.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(s),s.filterMode=s._isIntFormat()?t5.Point:t5.Bilinear,s.wrapModeU=s.wrapModeV=t7.Repeat,s}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===a&&(a=0),void 0===i&&(i=0),this._platformTexture.setImageSource(e,t,n,r,a,i),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,a,i){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,n,r,0,a):6===o&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),e.prototype._rebuild.call(this)},t}(ns),nu=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===i&&(i=t9.R8G8B8A8),void 0===o&&(o=!0),(s=e.call(this,t)||this)._mipmap=o,s._width=n,s._height=r,s._length=a,s._format=i,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(s),s.filterMode=t5.Bilinear,s.wrapModeU=s.wrapModeV=t7.Repeat,s}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o,s){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i,o,s),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,a,i,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,a,i,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):5===s?this._platformTexture.getPixelBuffer(e,t,n,r,a,0,i):6===s&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),e.prototype._rebuild.call(this)},tG(t,[{key:"length",get:function(){return this._length}}]),t}(ns),nd=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return void 0===r&&(r=t9.R8G8B8A8),void 0===a&&(a=!0),(i=e.call(this,t)||this)._mipmap=a,i._width=n,i._height=n,i._format=r,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(i),i.filterMode=t5.Bilinear,i.wrapModeU=i.wrapModeV=t7.Clamp,i}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i,o),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,a,i,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,a,i,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):6===s?this._platformTexture.getPixelBuffer(e,t,n,r,a,0,i):7===s&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),e.prototype._rebuild.call(this)},t}(ns),nh=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._charInfoMap={},n._space=1,n._curX=1,n._curY=1,n._nextY=1,n}tW(t,e);var n=t.prototype;return n.uploadCharTexture=function(e){var t=e.w,n=e.h,r=e.data,a=this._space,i=this.texture,o=i.width,s=t+a,l=n+a;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=a,this._curY=this._nextY+a);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&n>0&&r&&(e.bufferOffset=new tB(this._curX,this._curY),i.setPixelBuffer(r,0,this._curX,this._curY,t,n),i.generateMipmaps());var u=1/o,d=this._curX,h=this._curY,_=d*u,f=(d+t)*u,p=h*u,m=(h+n)*u;e.x=d,e.y=h;var g=e.uvs;return g[0].set(_,p),g[1].set(f,p),g[2].set(f,m),g[3].set(_,m),this._curX+=s+a,!0},n.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},n.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},t}(t1),n_=((f={})[f.None=0]="None",f[f.Bold=1]="Bold",f[f.Italic=2]="Italic",f),nf=((p={})[p.Overflow=0]="Overflow",p[p.Truncate=1]="Truncate",p),np=/*#__PURE__*/function(){function e(){}return e.textContext=function(){var t=e._textContext;if(!t){try{n=new OffscreenCanvas(0,0)}catch(e){n=document.createElement("canvas")}var n,r=n.getContext("2d",{willReadFrequently:!0});t={canvas:n,context:r},e._textContext=t}return t},e.measureFont=function(t){var n=e._fontSizeInfoCache,r=n[t];return r||(r=e._measureFontOrChar(t,e._measureString,!1),n[t]=r),r},e.getNativeFontString=function(t,n,r){var a=r&n_.Bold?"bold ":"";return r&n_.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=n+"px "+t},e.measureChar=function(t,n){return e._measureFontOrChar(n,t,!0)},e.measureTextWithWrap=function(t){var n=t._getSubFont(),r=n.nativeFontString,a=e.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=iJ._pixelsPerUnit,u=a.size+t.lineSpacing*c,d=t.width*c,h=0;n.nativeFontString=r;for(var _=0,f=i.length;_<f;_++){var p=i[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",b=0,C=0,S=0,T=!1,A=0,E=p.length;A<E;++A){var R=p[A],M=e._getCharInfo(R,r,n),w=R.charCodeAt(0),P=32===w;if(!P||!T||0!==x.length||0!==m.length){var F=P||w>=19968&&w<=40959,L=M.w,D=M.offsetY,B=.5*M.h,I=B+D,O=B-D;F?(m.length>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b),T=!0,x=m,b=g,C=v,S=y):(x+=m,b+=g,C=Math.max(C,v),S=Math.max(S,y)),m="",g=v=y=0),b+L>d&&b>0?(this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b),T=!0,P?(x="",b=C=S=0):(x=R,b=M.xAdvance,C=I,S=O)):(x+=R,b+=M.xAdvance,C=Math.max(C,I),S=Math.max(S,O))):g+M.w>d?(b>0&&(this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b),x="",b=C=S=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),T=!0,m=R,g=M.xAdvance,v=I,y=O):(m+=R,g+=M.xAdvance,v=Math.max(v,I),y=Math.max(y,O))}}g>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b),b=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,b+=g,C=Math.max(C,v),S=Math.max(S,y))),b>0&&(this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b))}var N=t.height*c;return t.overflowMode===nf.Overflow&&(N=u*o.length),{width:h,height:N,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},e.measureTextWithoutWrap=function(t){var n=t._getSubFont(),r=n.nativeFontString,a=e.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],u=iJ._pixelsPerUnit,d=a.size+t.lineSpacing*u,h=0;n.nativeFontString=r;for(var _=0;_<o;++_){for(var f=i[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=e._getCharInfo(f[v],r,n);p+=x.xAdvance;var b=x.offsetY,C=.5*x.h,S=C+b,T=C-b;m<S&&(m=S),g<T&&(g=T)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var A=t.height*u;return t.overflowMode===nf.Overflow&&(A=d*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},e.getNativeFontHash=function(t,n,r){var a=r&n_.Bold?"bold":"";return r&n_.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t=""+t),a+=n+"px"+t},e._measureFontOrChar=function(t,n,r){var a,i=e.textContext(),o=i.canvas,s=i.context;s.font=t;var l=s.measureText(n),c=l.actualBoundingBoxLeft,u=l.actualBoundingBoxRight,d=l.width,h=Math.max(1,Math.round(Math.max(u+Math.abs(c),d))),_=Math.ceil(s.measureText(e._measureBaseline).width),f=_*e._heightMultiplier;_=e._baselineMultiplier*_|0;var p=e._extendHeight;f+=p,_+=.5*p,o.width=h,o.height=f,s.font=t,s.fillStyle="#000",s.clearRect(0,0,h,f),s.textBaseline="middle",s.fillStyle="#fff",c>0?s.fillText(n,c,_):s.fillText(n,0,_);for(var m=s.getImageData(0,0,h,f).data,g=m.length,v=-1,y=-1,x=0,b=0,C=0,S=o.width,T=1/S,A=0;A<g;A+=4)0!==m[A+3]?(a=~~(.25*A*T),-1===v&&(v=a),a>y&&(y=a)):m[A]=m[A+1]=m[A+2]=255;if(-1!==v&&-1!==y&&(C=(x=_-v)+(b=y-_+1)),!r)return{ascent:x,descent:b,size:C};var E=null;if(C>0){var R=4*S;E=new Uint8Array(m.buffer,v*R,C*R)}return{char:n,x:0,y:0,w:h,h:C,offsetX:c>0?c:0,offsetY:(x-b)*.5,xAdvance:Math.round(d),uvs:[new tB,new tB,new tB,new tB],ascent:x,descent:b,index:0,data:E}},e._getCharInfo=function(t,n,r){var a=r._getCharInfo(t);return a||(a=e.measureChar(t,n),r._uploadCharTexture(a),r._addCharInfo(t,a)),a},e._pushLine=function(e,t,n,r,a,i,o){e.push(r),t.push(a),n.push({ascent:i,descent:o,size:i+o})},e}();np._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],np._extendHeight=0,np._measureString="|\xc9q\xc5",np._measureBaseline="M",np._heightMultiplier=2,np._baselineMultiplier=1.4,np._fontSizeInfoCache={},np._textContext=null;var nm=/*#__PURE__*/function(){function e(e){this._fontAtlases=[],this._lastIndex=-1,this._engine=e}var t=e.prototype;return t.destroy=function(){for(var e=this._fontAtlases,t=0,n=e.length;t<n;++t)e[t].destroy(!0);e.length=0},t._uploadCharTexture=function(e){var t=this._fontAtlases,n=this._lastIndex;-1===n&&(this._createFontAtlas(),n++);var r=t[n];!r.uploadCharTexture(e)&&((r=this._createFontAtlas()).uploadCharTexture(e),n++),this._lastIndex=n,e.data=null},t._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},t._getCharInfo=function(e){for(var t=this._fontAtlases,n=0,r=t.length;n<r;++n){var a=t[n].getCharInfo(e);if(a)return a}return null},t._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},t._getLastIndex=function(){return this._lastIndex},t._createFontAtlas=function(){var e=this._engine,t=new nh(e),n=new nc(e,256,256,t9.R8G8B8A8,!1);n.filterMode=t5.Bilinear,t.texture=n,t.isGCIgnored=n.isGCIgnored=!0,this._fontAtlases.push(t);var r=this.nativeFontString;return e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,t)||this}return tW(n,e),n.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var a in t){var i=t[a],o=np.measureChar(i.char,r).data;if(i.w>0&&i.h>0&&o){var s=i.bufferOffset;n.setPixelBuffer(o,0,s.x,s.y,i.w,i.h)}}n.generateMipmaps()},n}(t2))),t},e}(),ng=/*#__PURE__*/function(e){function t(t,n){var r;return void 0===n&&(n=""),(r=e.call(this,t)||this)._name="",r._subFontMap={},r._name=n,r}tW(t,e);var n=t.prototype;return n._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,a=r[n];return a||(a=new nm(this.engine),r[n]=a),a},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._subFontMap;for(var n in t)t[n].destroy();this._subFontMap=null,delete this.engine._fontMap[this._name]},t.createFromOS=function(e,n){if(n){var r=e._fontMap,a=r[n];return a||(a=new t(e,n),r[n]=a),a}return null},tG(t,[{key:"name",get:function(){return this._name}}]),t}(t1),nv=((m={})[m.None=0]="None",m[m.VisibleInsideMask=1]="VisibleInsideMask",m[m.VisibleOutsideMask=2]="VisibleOutsideMask",m),ny=((g={})[g.Left=0]="Left",g[g.Center=1]="Center",g[g.Right=2]="Right",g),nx=((v={})[v.Top=0]="Top",v[v.Center=1]="Center",v[v.Bottom=2]="Bottom",v),nb=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._sprites=[],n._spriteNamesToIndex={},n}tW(t,e);var n=t.prototype;return n.getSprite=function(e){var t=this._sprites[this._spriteNamesToIndex[e]];return t||console.warn("There is no sprite named "+e+" in the atlas."),t},n.getSprites=function(e,t){t.length=0;var n=this._spriteNamesToIndex[e];if(void 0!==n)for(var r=this._sprites;n>=0;n--){var a=r[n];a.name===e&&t.push(a)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},n._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},n._onDestroy=function(){e.prototype._onDestroy.call(this);for(var t=this._sprites,n=0,r=t.length;n<r;n++)t[n].destroy();t.length=0,this._sprites=null,this._spriteNamesToIndex=null},tG(t,[{key:"sprites",get:function(){return this._sprites}}]),t}(t1),nC=((y={})[y.Simple=0]="Simple",y[y.Sliced=1]="Sliced",y[y.Tiled=2]="Tiled",y),nS=((x={})[x.Continuous=0]="Continuous",x[x.Adaptive=1]="Adaptive",x),nT=/*#__PURE__*/function(){function e(){}return e.removeFromArray=function(e,t){var n=e.indexOf(t);if(n<0)return!1;var r=e.length-1;if(n!==r){var a=e[r];e[n]=a}return e.length--,!0},e.decodeText=function(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);for(var t="",n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);return decodeURIComponent(encodeURIComponent(t))},e.isAbsoluteUrl=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},e.isBase64Url=function(e){return/^data:.*,.*$/i.test(e)},e.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},e.resolveAbsoluteUrl=function(t,n){if(e.isAbsoluteUrl(n)||e.isBase64Url(n))return n;if(!/^https?:/.test(t)){var r="files://";return new URL(n,t=r+t).href.substring(r.length)}return n?new URL(n,t).href:t},e._floatMatrixMultiply=function(e,t,n,r,a){var i=e.elements,o=i[0],s=i[1],l=i[2],c=i[3],u=i[4],d=i[5],h=i[6],_=i[7],f=i[8],p=i[9],m=i[10],g=i[11],v=i[12],y=i[13],x=i[14],b=i[15],C=t[n],S=t[n+1],T=t[n+2],A=t[n+3],E=t[n+4],R=t[n+5],M=t[n+6],w=t[n+7],P=t[n+8],F=t[n+9],L=t[n+10],D=t[n+11],B=t[n+12],I=t[n+13],O=t[n+14],N=t[n+15];r[a]=o*C+u*S+f*T+v*A,r[a+1]=s*C+d*S+p*T+y*A,r[a+2]=l*C+h*S+m*T+x*A,r[a+3]=c*C+_*S+g*T+b*A,r[a+4]=o*E+u*R+f*M+v*w,r[a+5]=s*E+d*R+p*M+y*w,r[a+6]=l*E+h*R+m*M+x*w,r[a+7]=c*E+_*R+g*M+b*w,r[a+8]=o*P+u*F+f*L+v*D,r[a+9]=s*P+d*F+p*L+y*D,r[a+10]=l*P+h*F+m*L+x*D,r[a+11]=c*P+_*F+g*L+b*D,r[a+12]=o*B+u*I+f*O+v*N,r[a+13]=s*B+d*I+p*O+y*N,r[a+14]=l*B+h*I+m*O+x*N,r[a+15]=c*B+_*I+g*O+b*N},e._reflectGet=function(e,t){for(var n=this._stringToPath(t),r=e,a=0,i=n.length;null!=r&&a<i;)r=r[n[a++]];return a&&a==i?r:void 0},e._quickSort=function(e,t,n,r){for(;;){if(n-t<=10){this._insertionSort(e,t,n,r);return}var a=t+n>>1,i=e[t],o=e[n-1],s=e[a];if(r(i,o)>0){var l=i;i=o,o=l}if(r(i,s)>=0){var c=i;i=s,s=o,o=c}else if(r(o,s)>0){var u=o;o=s,s=u}e[t]=i,e[n-1]=s;var d=o,h=t+1,_=n-1;e[a]=e[h],e[h]=d;e:for(var f=h+1;f<_;f++){var p=e[f],m=r(p,d);if(m<0)e[f]=e[h],e[h]=p,h++;else if(m>0){do{if(--_==f)break e;m=r(e[_],d)}while(m>0);e[f]=e[_],e[_]=p,m<0&&(p=e[f],e[f]=e[h],e[h]=p,h++)}}n-_<h-t?(this._quickSort(e,_,n,r),n=h):(this._quickSort(e,t,h,r),t=_)}},e._stringToPath=function(e){var t=[];return e.charCodeAt(0)===nA&&t.push(""),e.replace(nR,function(e,n,r,a){var i=e;r?i=a.replace(nE,"$1"):n&&(i=n.trim()),t.push(i)}),t},e._insertionSort=function(e,t,n,r){for(var a=t+1;a<n;a++){var i=void 0,o=e[a];for(i=a-1;i>=t;i--){var s=e[i];if(r(s,o)>0)e[i+1]=s;else break}e[i+1]=o}},e}(),nA=46,nE=/\\(\\)?/g,nR=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),nM=/*#__PURE__*/function(){function e(){this._updateFlags=[],this._listeners=[]}var t=e.prototype;return t.createFlag=function(e){var t=new e;return this.addFlag(t),t},t.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},t.removeFlag=function(e){nT.removeFromArray(this._updateFlags,e)&&nT.removeFromArray(e._flagManagers,this)},t.addListener=function(e){this._listeners.push(e)},t.removeListener=function(e){nT.removeFromArray(this._listeners,e)},t.dispatch=function(e,t){for(var n=this._updateFlags,r=n.length-1;r>=0;r--)n[r].dispatch(e,t);for(var a=this._listeners,i=a.length-1;i>=0;i--)a[i](e,t)},e}(),nw=((b={})[b.texture=1]="texture",b[b.size=2]="size",b[b.atlasRotate=4]="atlasRotate",b[b.atlasRegion=8]="atlasRegion",b[b.atlasRegionOffset=16]="atlasRegionOffset",b[b.region=32]="region",b[b.pivot=64]="pivot",b[b.border=128]="border",b[b.destroy=256]="destroy",b),nP=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===n&&(n=null),void 0===r&&(r=null),void 0===a&&(a=null),void 0===i&&(i=null),void 0===o&&(o=null),(s=e.call(this,t)||this)._automaticWidth=0,s._automaticHeight=0,s._customWidth=void 0,s._customHeight=void 0,s._positions=[new tB,new tB,new tB,new tB],s._uvs=[new tB,new tB,new tB,new tB],s._bounds=new tE,s._texture=null,s._atlasRotated=!1,s._atlasRegion=new tN(0,0,1,1),s._atlasRegionOffset=new tI(0,0,0,0),s._region=new tN(0,0,1,1),s._pivot=new tB(.5,.5),s._border=new tI(0,0,0,0),s._dirtyUpdateFlag=7,s._updateFlagManager=new nM,s._texture=n,s._onRegionChange=s._onRegionChange.bind(s),s._onPivotChange=s._onPivotChange.bind(s),s._onBorderChange=s._onBorderChange.bind(s),s._region._onValueChanged=s._onRegionChange,s._pivot._onValueChanged=s._onPivotChange,s._border._onValueChanged=s._onBorderChange,r&&s._region.copyFrom(r),a&&s._pivot.copyFrom(a),i&&s._border.copyFrom(i),s.name=o,s}tW(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},n._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},n._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},n._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},n._addReferCount=function(t){var n;e.prototype._addReferCount.call(this,t),null==(n=this._atlas)||n._addReferCount(t)},n._onDestroy=function(){this._dispatchSpriteChange(nw.destroy),e.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},n._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,a=1/iJ._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-n.x-n.z)*r.width*a,this._automaticHeight=e.height*t.height/(1-n.y-n.w)*r.height*a}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},n._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,n=t.x,r=t.y,a=t.width,i=t.height,o=Math.max(e.x-n,0)/a,s=Math.max(e.w-r,0)/i,l=1-Math.max(e.z-(1-n-a),0)/a,c=1-Math.max(e.y-(1-r-i),0)/i,u=this._positions;u[0].set(o,s),u[1].set(l,s),u[2].set(o,c),u[3].set(l,c);var d=this._bounds,h=d.min,_=d.max;h.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},n._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,n=this._region,r=n.x,a=n.y,i=n.width,o=n.height,s=1-r-i,l=1-a-o,c=this._atlasRegion,u=c.x,d=c.y,h=c.width,_=c.height,f=t.x,p=t.y,m=t.z,g=t.w,v=h/(1-f-m),y=_/(1-p-g),x=Math.max(r-f,0)*v+u,b=Math.max(l-p,0)*y+d,C=h+u-Math.max(s-m,0)*v,S=_+d-Math.max(a-g,0)*y,T=this._border,A=T.x,E=T.y,R=T.z,M=T.w;e[0].set(x,S),e[1].set((r-f+A*i)*v+u,_+d-(a-g+E*o)*y),e[2].set(h+u-(s-m+R*i)*v,(l-p+M*o)*y+d),e[3].set(C,b),this._dirtyUpdateFlag&=-3},n._dispatchSpriteChange=function(e){switch(e){case nw.texture:this._dirtyUpdateFlag|=4;break;case nw.atlasRegionOffset:case nw.region:this._dirtyUpdateFlag|=7;break;case nw.atlasRegion:this._dirtyUpdateFlag|=6;break;case nw.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},n._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);e.set(t,n,tS.clamp(e.width,0,1-t),tS.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nw.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size),e._onValueChanged=this._onRegionChange},n._onPivotChange=function(){this._dispatchSpriteChange(nw.pivot)},n._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);e.set(t,n,tS.clamp(e.z,0,1-t),tS.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nw.border),e._onValueChanged=this._onBorderChange},tG(t,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(nw.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size))}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dispatchSpriteChange(nw.size))}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dispatchSpriteChange(nw.size))}},{key:"atlasRotated",get:function(){return this._atlasRotated},set:function(e){this._atlasRotated!=e&&(this._atlasRotated=e)}},{key:"atlasRegion",get:function(){return this._atlasRegion},set:function(e){var t=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);this._atlasRegion.set(t,n,tS.clamp(e.width,0,1-t),tS.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nw.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,tS.clamp(e.z,0,1-t),tS.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nw.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),t}(t1),nF=((C={})[C.Zero=0]="Zero",C[C.One=1]="One",C[C.SourceColor=2]="SourceColor",C[C.OneMinusSourceColor=3]="OneMinusSourceColor",C[C.DestinationColor=4]="DestinationColor",C[C.OneMinusDestinationColor=5]="OneMinusDestinationColor",C[C.SourceAlpha=6]="SourceAlpha",C[C.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",C[C.DestinationAlpha=8]="DestinationAlpha",C[C.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",C[C.SourceAlphaSaturate=10]="SourceAlphaSaturate",C[C.BlendColor=11]="BlendColor",C[C.OneMinusBlendColor=12]="OneMinusBlendColor",C),nL=((S={})[S.Add=0]="Add",S[S.Subtract=1]="Subtract",S[S.ReverseSubtract=2]="ReverseSubtract",S[S.Min=3]="Min",S[S.Max=4]="Max",S),nD=((T={})[T.None=0]="None",T[T.Red=1]="Red",T[T.Green=2]="Green",T[T.Blue=4]="Blue",T[T.Alpha=8]="Alpha",T[T.All=15]="All",T),nB=((A={})[A.Never=0]="Never",A[A.Less=1]="Less",A[A.Equal=2]="Equal",A[A.LessEqual=3]="LessEqual",A[A.Greater=4]="Greater",A[A.NotEqual=5]="NotEqual",A[A.GreaterEqual=6]="GreaterEqual",A[A.Always=7]="Always",A),nI=((E={})[E.Off=0]="Off",E[E.Front=1]="Front",E[E.Back=2]="Back",E),nO=((R={})[R.BlendStateEnabled0=0]="BlendStateEnabled0",R[R.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",R[R.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",R[R.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",R[R.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",R[R.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",R[R.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",R[R.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",R[R.BlendStateBlendColor=8]="BlendStateBlendColor",R[R.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",R[R.DepthStateEnabled=10]="DepthStateEnabled",R[R.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",R[R.DepthStateCompareFunction=12]="DepthStateCompareFunction",R[R.StencilStateEnabled=13]="StencilStateEnabled",R[R.StencilStateReferenceValue=14]="StencilStateReferenceValue",R[R.StencilStateMask=15]="StencilStateMask",R[R.StencilStateWriteMask=16]="StencilStateWriteMask",R[R.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",R[R.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",R[R.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",R[R.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",R[R.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",R[R.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",R[R.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",R[R.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",R[R.RasterStateCullMode=25]="RasterStateCullMode",R[R.RasterStateDepthBias=26]="RasterStateDepthBias",R[R.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",R[R.RenderQueueType=28]="RenderQueueType",R),nN=((M={})[M.Opaque=0]="Opaque",M[M.AlphaTest=1]="AlphaTest",M[M.Transparent=2]="Transparent",M),nV=((w={})[w.Float=0]="Float",w[w.Int=1]="Int",w[w.Vector2=2]="Vector2",w[w.Vector3=3]="Vector3",w[w.Vector4=4]="Vector4",w[w.Matrix=5]="Matrix",w[w.Color=6]="Color",w[w.Texture=7]="Texture",w[w.FloatArray=8]="FloatArray",w[w.IntArray=9]="IntArray",w[w.TextureArray=10]="TextureArray",w),nk=((P={})[P.Keep=0]="Keep",P[P.Zero=1]="Zero",P[P.Replace=2]="Replace",P[P.IncrementSaturate=3]="IncrementSaturate",P[P.DecrementSaturate=4]="DecrementSaturate",P[P.Invert=5]="Invert",P[P.IncrementWrap=6]="IncrementWrap",P[P.DecrementWrap=7]="DecrementWrap",P),nz=((F={})[F.GLES100=0]="GLES100",F[F.GLES300=1]="GLES300",F);function nU(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function nG(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return nU(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nU(e,void 0)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nH=/*#__PURE__*/function(){function e(t,n,r,a){this.name=t,this._maskIndex=r,this._maskValue=a,this.value=n;var i=e._macroNameIdMap,o=i[t];void 0===i[t]&&(i[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,n){var r=n?t+" "+n:t,a=e._macroMap[r];if(!a){var i=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;a=new e(t,n,s,1<<l),e._macroMap[r]=a,s==i.length&&(i.length++,i[s]=Array(32)),i[s][l]=a,e._macroCounter++}return a},e._getMacrosElements=function(t,n){var r=e._macroMaskMap,a=t._mask;n.length=0;for(var i=0,o=t._length;i<o;i++)for(var s=r[i],l=a[i],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&n.push(s[u])},e}();nH._macroMaskMap=[],nH._macroNameIdMap=Object.create(null),nH._macroNameCounter=0,nH._macroCounter=0,nH._macroMap=Object.create(null);var nW=/*#__PURE__*/function(){function e(){this._mask=[],this._length=0}var t=e.prototype;return t.enable=function(e){var t=e._maskIndex,n=t+1,r=this._mask,a=this._length;if(a<n){for(r.length<n&&(r.length=n);a<t;a++)r[a]=0;r[t]=e._maskValue,this._length=n}else r[t]|=e._maskValue},t.disable=function(e){var t=e._maskIndex,n=this._mask,r=this._length-1;if(!(t>r)){var a=n[t]&~e._maskValue;t==r&&0===a?this._length--:n[t]=a}},t.unionCollection=function(e){var t=e._mask,n=e._length,r=this._mask,a=this._length;if(a<n){r.length<n&&(r.length=n);for(var i=0;i<a;i++)r[i]|=t[i];for(;i<n;i++)r[i]=t[i];this._length=n}else for(var o=0;o<n;o++)r[o]|=t[o]},t.complementaryCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1,a=Math.min(e._length-1,r);a>=0;a--){var i=n[a]&~t[a];a==r&&0===i?(r--,this._length--):n[a]=i}},t.intersectionCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1;r>=0;r--){var a=n[r]&t[r];0==a&&r==this._length-1?this._length--:n[r]=a}},t.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},t.clear=function(){this._length=0},e.unionCollection=function(e,t,n){var r,a,i,o,s=n._mask;e._length<t._length?(r=e._length,a=t._length,i=e._mask,o=t._mask):(r=t._length,a=e._length,i=t._mask,o=e._mask);var l=0;for(s.length<a&&(s.length=a);l<r;l++)s[l]=i[l]|o[l];for(;l<a;l++)s[l]=o[l];n._length=a},e}();function nj(){return(nj=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var nX=((L={}).DepthOnly="DepthOnly",L.ShadowCaster="ShadowCaster",L.Forward="Forward",L),nK=/*#__PURE__*/function(){function e(){this._events=Object.create(null),this._eventCount=0}var t=e.prototype;return t.hasEvent=function(e){return null!=this._events[e]},t.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},t.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},t.dispatch=function(t,n){if(!this._events[t])return!1;var r=this._events[t];if(Array.isArray(r)){var a=r.length,i=e._dispatchingListenersPool,o=i.length>0?i.pop():[];o.length=a;for(var s=0;s<a;s++)o[s]=r[s];for(var l=0;l<a;l++){var c=o[l];c.destroyed||(c.once&&this.off(t,c.fn),c.fn(n))}o.length=0,i.push(o)}else r.once&&this.off(t,r.fn),r.fn(n);return!0},t.on=function(e,t){return this._addEventListener(e,t)},t.once=function(e,t){return this._addEventListener(e,t,!0)},t.off=function(e,t){if(!this._events[e])return this;if(!t)return this._clearEvent(e),this;var n=this._events[e],r=Array.isArray(n);if(r||n.fn!==t){if(r){for(var a=n.length-1;a>=0;a--)n[a].fn===t&&(n[a].destroyed=!0,n.splice(a,1));0===n.length?this._clearEvent(e):1===n.length&&(this._events[e]=n[0])}}else this._clearEvent(e);return this},t.removeEventListener=function(e,t){return this.off(e,t)},t.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},t._addEventListener=function(e,t,n){var r={fn:t,once:n},a=this._events,i=a[e];return i?Array.isArray(i)?i.push(r):a[e]=[i,r]:(a[e]=r,this._eventCount++),this},t._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},e}();nK._dispatchingListenersPool=[];var nY=/*#__PURE__*/function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return e.getByName=function(t){var n=e._propertyNameMap;if(null!=n[t])return n[t];var r=new e(t);return n[t]=r,e._propertyIdMap[r._uniqueId]=r,r},e._getShaderPropertyGroup=function(t){var n=e._propertyNameMap[t];return null==n?void 0:n._group},tG(e,[{key:"type",get:function(){return this._type}}]),e}();nY._propertyIdMap=Object.create(null),nY._propertyNameCounter=0,nY._propertyNameMap=Object.create(null);var nq=/*#__PURE__*/function(){function e(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new tI,this._deltaTimeValue=new tI,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}var t=e.prototype;return t._reset=function(){this._lastSystemTime=performance.now()/1e3},t._update=function(){var e=performance.now()/1e3,t=e-this._lastSystemTime;this._actualDeltaTime=t,this._actualElapsedTime+=t;var n=Math.min(t,this.maximumDeltaTime)*this.timeScale;this._deltaTime=n,this._elapsedTime+=n,this._frameCount++,this._lastSystemTime=e},t._updateSceneShaderData=function(t){var n=this._elapsedTimeValue,r=this._deltaTimeValue,a=this._elapsedTime;n.set(a,Math.sin(a),Math.cos(a),0),t.setVector4(e._elapsedTimeProperty,n),r.set(this._deltaTime,0,0,0),t.setVector4(e._deltaTimeProperty,r)},tG(e,[{key:"frameCount",get:function(){return this._frameCount}},{key:"deltaTime",get:function(){return this._deltaTime}},{key:"elapsedTime",get:function(){return this._elapsedTime}},{key:"actualDeltaTime",get:function(){return this._actualDeltaTime}},{key:"actualElapsedTime",get:function(){return this._actualElapsedTime}}]),e}();nq._elapsedTimeProperty=nY.getByName("scene_ElapsedTime"),nq._deltaTimeProperty=nY.getByName("scene_DeltaTime");var nQ=((D={})[D.FLOAT=5126]="FLOAT",D[D.FLOAT_VEC2=35664]="FLOAT_VEC2",D[D.FLOAT_VEC3=35665]="FLOAT_VEC3",D[D.FLOAT_VEC4=35666]="FLOAT_VEC4",D[D.INT=5124]="INT",D[D.INT_VEC2=35667]="INT_VEC2",D[D.INT_VEC3=35668]="INT_VEC3",D[D.INT_VEC4=35669]="INT_VEC4",D[D.BOOL=35670]="BOOL",D[D.BOOL_VEC2=35671]="BOOL_VEC2",D[D.BOOL_VEC3=35672]="BOOL_VEC3",D[D.BOOL_VEC4=35673]="BOOL_VEC4",D[D.FLOAT_MAT2=35674]="FLOAT_MAT2",D[D.FLOAT_MAT3=35675]="FLOAT_MAT3",D[D.FLOAT_MAT4=35676]="FLOAT_MAT4",D[D.FLOAT_ARRAY=35677]="FLOAT_ARRAY",D[D.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",D[D.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",D[D.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",D[D.INT_ARRAY=100003]="INT_ARRAY",D[D.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",D[D.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",D[D.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",D[D.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",D[D.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",D[D.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",D[D.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",D[D.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",D[D.SAMPLER_2D=35678]="SAMPLER_2D",D[D.SAMPLER_CUBE=35680]="SAMPLER_CUBE",D[D.BYTE=5120]="BYTE",D[D.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",D[D.SHORT=5122]="SHORT",D[D.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",D[D.UNSIGNED_INT=5125]="UNSIGNED_INT",D),nJ=((B={}).shaderVertexID="shaderVertexID",B.standardDerivatives="OES_standard_derivatives",B.shaderTextureLod="EXT_shader_texture_lod",B.elementIndexUint="OES_element_index_uint",B.depthTexture="WEBGL_depth_texture",B.drawBuffers="WEBGL_draw_buffers",B.vertexArrayObject="OES_vertex_array_object",B.instancedArrays="ANGLE_instanced_arrays",B.multipleSample="multipleSampleOnlySupportedInWebGL2",B.textureFloat="OES_texture_float",B.textureFloatLinear="OES_texture_float_linear",B.textureHalfFloat="OES_texture_half_float",B.textureHalfFloatLinear="OES_texture_half_float_linear",B.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",B.colorBufferFloat="EXT_color_buffer_float",B.colorBufferHalfFloat="EXT_color_buffer_half_float",B.textureFilterAnisotropic="EXT_texture_filter_anisotropic",B.blendMinMax="EXT_blend_minmax",B.fragDepth="EXT_frag_depth",B.astc="WEBGL_compressed_texture_astc",B.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",B.etc="WEBGL_compressed_texture_etc",B.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",B.etc1="WEBGL_compressed_texture_etc1",B.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",B.pvrtc="WEBGL_compressed_texture_pvrtc",B.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",B.s3tc="WEBGL_compressed_texture_s3tc",B.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",B.bptc="EXT_texture_compression_bptc",B.WEBGL_lose_context="WEBGL_lose_context",B),nZ=nj({common:"#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){linearIn=max(linearIn,0.0);return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(v_normal,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,v_normal);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.0;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.roughness+getAARoughnessFactor(geometry.normal),1.0));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.clearCoatRoughness+getAARoughnessFactor(geometry.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"},{particle_common:"#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}",velocity_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}",rotation_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nuniform vec2 renderer_ROLMaxCurveZ[4];\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec2 renderer_ROLMinCurveZ[4];\n#endif\n#else\nuniform vec3 renderer_ROLMaxConst;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec3 renderer_ROLMinConst;\n#endif\n#endif\n#endif\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge){\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nfloat lifeRotation=evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ,normalizedAge);\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ,normalizedAge),lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*a_ShapePositionStartLifeTime.w;\n#else\nfloat lifeRotation=renderer_ROLMaxConst.z;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(renderer_ROLMinConst.z,lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*age;\n#endif\n#endif\nreturn rotation;}\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge){\n#ifdef ROTATION_OVER_LIFETIME\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nfloat ageRot=u_ROLAngularVelocityConst*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n#endif\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nvec3 ageRot=u_ROLAngularVelocityConstSeparate*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nvec3 ageRot=mix(u_ROLAngularVelocityConstSeparate,renderer_ROLMaxConst,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,normalizedAge),a_Random0.w));\n#endif\n#endif\nreturn rotation;}\n#endif\n",size_over_lifetime_module:"#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\nuniform vec2 renderer_SOLMaxCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMaxCurveY[4];uniform vec2 renderer_SOLMaxCurveZ[4];\n#endif\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nuniform vec2 renderer_SOLMinCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMinCurveY[4];uniform vec2 renderer_SOLMinCurveZ[4];\n#endif\n#endif\n#endif\nvec2 computeParticleSizeBillboard(in vec2 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE_MODE\nfloat lifeSizeX=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeX=mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),lifeSizeX,a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_IS_SEPARATE\nfloat lifeSizeY=evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeY=mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),lifeSizeY,a_Random0.z);\n#endif\nsize*=vec2(lifeSizeX,lifeSizeY);\n#else\nsize*=lifeSizeX;\n#endif\n#endif\nreturn size;}\n#ifdef RENDERER_MODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE\nsize*=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES\nsize*=mix(evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),evaluateParticleCurve(u_SOLSizeGradientMax,normalizedAge),a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_CURVE_SEPARATE\nsize*=vec3(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge));\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\nsize*=vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveZ,normalizedAge),a_Random0.z));\n#endif\nreturn size;}\n#endif\n",color_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nuniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4];\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\nuniform vec4 renderer_COLMinGradientColor[4];uniform vec2 renderer_COLMinGradientAlpha[4];\n#endif\nuniform vec4 renderer_COLGradientKeysMaxTime;\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 evaluateParticleGradient(in vec4 colorKeys[4],in float colorKeysMaxTime,in vec2 alphaKeys[4],in float alphaKeysMaxTime,in float normalizedAge){vec4 value;float alphaAge=min(normalizedAge,alphaKeysMaxTime);for(int i=0;i<4;i++){vec2 key=alphaKeys[i];float time=key.x;if(alphaAge<=time){if(i==0){value.a=alphaKeys[0].y;}else{vec2 lastKey=alphaKeys[i-1];float lastTime=lastKey.x;float age=(alphaAge-lastTime)/(time-lastTime);value.a=mix(lastKey.y,key.y,age);}break;}}float colorAge=min(normalizedAge,colorKeysMaxTime);for(int i=0;i<4;i++){vec4 key=colorKeys[i];float time=key.x;if(colorAge<=time){if(i==0){value.rgb=colorKeys[0].yzw;}else{vec4 lastKey=colorKeys[i-1];float lastTime=lastKey.x;float age=(colorAge-lastTime)/(time-lastTime);value.rgb=mix(lastKey.yzw,key.yzw,age);}break;}}return value;}\n#endif\nvec4 computeParticleColor(in vec4 color,in float normalizedAge){\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 gradientColor=evaluateParticleGradient(renderer_COLMaxGradientColor,renderer_COLGradientKeysMaxTime.z,renderer_COLMaxGradientAlpha,renderer_COLGradientKeysMaxTime.w,normalizedAge);\n#endif\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\ngradientColor=mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x,renderer_COLMinGradientAlpha,renderer_COLGradientKeysMaxTime.y,normalizedAge),gradientColor,a_Random0.y);\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\ncolor*=gradientColor;\n#endif\nreturn color;}",texture_sheet_animation_module:"#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nuniform float renderer_TSACycles;uniform vec3 renderer_TSATillingParams;uniform vec2 renderer_TSAFrameMaxCurve[4];\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\n#endif\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge){\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nfloat scaledNormalizedAge=normalizedAge*renderer_TSACycles;float cycleNormalizedAge=scaledNormalizedAge-floor(scaledNormalizedAge);float normalizedFrame=evaluateParticleCurve(renderer_TSAFrameMaxCurve,cycleNormalizedAge);\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nnormalizedFrame=mix(evaluateParticleCurve(renderer_TSAFrameMinCurve,cycleNormalizedAge),normalizedFrame,a_Random1.x);\n#endif\nfloat frame=floor(normalizedFrame*renderer_TSATillingParams.z);float tileRow=frame*renderer_TSATillingParams.x;float tileRowIndex=floor(tileRow);uv.x+=tileRow-tileRowIndex;uv.y+=tileRowIndex*renderer_TSATillingParams.y;\n#endif\nreturn uv;}",sphere_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 sideVector=normalize(cross(camera_Forward,camera_Up));vec3 upVector=normalize(cross(sideVector,camera_Forward));corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);}else{float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#else\nif(renderer_ThreeDStartRotation){center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);}else{float c=cos(a_StartRotation0.x);float s=sin(a_StartRotation0.x);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#endif\n#endif\n",stretched_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nif(renderer_VOLSpace==0){velocity=rotationByQuaternions(renderer_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;}else{velocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;}\n#else\nvelocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n#endif\nvec3 cameraUpVector=normalize(velocity);vec3 direction=normalize(center-camera_Position);vec3 sideVector=normalize(cross(direction,normalize(velocity)));sideVector=renderer_SizeScale.xzy*sideVector;cameraUpVector=length(vec3(renderer_SizeScale.x,0.0,0.0))*cameraUpVector;vec2 size=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);const mat2 rotationZHalfPI=mat2(0.0,-1.0,1.0,0.0);corner=rotationZHalfPI*corner;corner.y=corner.y-abs(corner.y);float speed=length(velocity);center+=sign(renderer_SizeScale.x)*(sign(renderer_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*renderer_StretchedBillboardSpeedScale+size.y*renderer_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n#endif\n",vertical_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,1.0,0.0);vec3 sideVector=normalize(cross(camera_Forward,cameraUpVector));float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",horizontal_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,0.0,1.0);const vec3 sideVector=vec3(-1.0,0.0,0.0);float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",particle_mesh:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_MESH\nvec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);}else{\n#ifdef RENDERER_ROL_IS_SEPARATE\nfloat angle=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){center+=(rotationByQuaternions(rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));}else{\n#ifdef SHAPE\ncenter+=renderer_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);\n#endif\n}\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\nvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x),age,normalizedAge);center+=(rotationByQuaternions(rotationByEuler(renderer_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));\n#endif\n}\n#else\nif(renderer_ThreeDStartRotation){center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);}else{if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){if(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=(rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));}else{\n#ifdef SHAPE\nif(renderer_SimulationSpace==1)center+=renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);\n#endif\n}}\n#endif\nv_MeshColor=a_MeshColor;\n#endif\n"}),n$=/*#__PURE__*/function(){function e(){}return e.parseCustomMacros=function(e){return e.map(function(e){return"#define "+(e.value?e.name+" "+e.value:e.name)+"\n"}).join("")},e.registerInclude=function(e,t){if(nZ[e])throw'The "'+e+'" shader include already exist';nZ[e]=t},e.unRegisterInclude=function(e){delete nZ[e]},e.parseIncludes=function(t,n){return void 0===n&&(n=/^[ \t]*#include +<([\w\d.]+)>/gm),t.replace(n,function(t,r){var a=nZ[r];return void 0===a?(no.error('Shader slice "'+t.trim()+'" not founded.'),""):e.parseIncludes(a,n)})},e.convertTo300=function(t,n){if(t=(t=(t=t.replace(/\bvarying\b/g,n?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj"),n){if(t=(t=(t=(t=(t=t.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\btexture2DProjLodEXT\b/g,"textureProjLod")).replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!e._has300Output(t)){if(/\bgl_FragData\[.+?\]/g.test(t)){var r=(t=t.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);t=this._replaceMRTShader(t,r)}else t=(t=t.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}}else t=t.replace(/\battribute\b/g,"in");return t},e._has300Output=function(t){return e._has300OutInFragReg.test(t)},e._replaceMRTShader=function(e,t){for(var n="",r=new Set,a=0;a<t.length;a++){var i=t[a].match(/\bgl_FragData\[(.+?)\]/);r.add(i[1])}return r.forEach(function(e){n+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),n+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,n)},e}();n$._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers","GL_EXT_frag_depth"].map(function(e){return"#extension "+e+" : enable\n"}).join(""),n$._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var n0=/*#__PURE__*/function(){function e(t){this.name=t,this._uniqueId=e._nameCounter++}return e.getByName=function(t){var n=e._nameMap;return n[t]||(n[t]=new e(t))},e}();n0._nameCounter=0,n0._nameMap=Object.create(null);var n1=/*#__PURE__*/function(){function e(){this._tagsMap=Object.create(null)}var t=e.prototype;return t.setTag=function(e,t){var n="string"==typeof e?n0.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&no.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},t.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?n0.getByName(e):e)._uniqueId]},t.getTagValue=function(e){return this._tagsMap["string"==typeof e?n0.getByName(e)._uniqueId:e._uniqueId]},tG(e,[{key:"name",get:function(){return this._name}}]),e}(),n2=((I={})[I.Linear=0]="Linear",I[I.Gamma=1]="Gamma",I),n3=/*#__PURE__*/function(){function e(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=e.settings.colorSpace}var t=e.prototype;return t.upload1f=function(e,t){this.cacheValue!==t&&(this._gl.uniform1f(e.location,t),this.cacheValue=t)},t.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},t.upload2f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g)&&(this._colorSpace===n2.Linear?this._gl.uniform2f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g)):this._gl.uniform2f(e.location,t.r,t.g),n.x=t.r,n.y=t.g):(n.x!==t.x||n.y!==t.y)&&(this._gl.uniform2f(e.location,t.x,t.y),n.x=t.x,n.y=t.y)},t.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},t.upload3f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b)&&(this._colorSpace===n2.Linear?this._gl.uniform3f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g),tO.gammaToLinearSpace(t.b)):this._gl.uniform3f(e.location,t.r,t.g,t.b),n.x=t.r,n.y=t.g,n.z=t.b):(n.x!==t.x||n.y!==t.y||n.z!==t.z)&&(this._gl.uniform3f(e.location,t.x,t.y,t.z),n.x=t.x,n.y=t.y,n.z=t.z)},t.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},t.upload4f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b||n.w!==t.a)&&(this._colorSpace===n2.Linear?this._gl.uniform4f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g),tO.gammaToLinearSpace(t.b),t.a):this._gl.uniform4f(e.location,t.r,t.g,t.b,t.a),n.x=t.r,n.y=t.g,n.z=t.b,n.w=t.a):(n.x!==t.x||n.y!==t.y||n.z!==t.z||n.w!==t.w)&&(this._gl.uniform4f(e.location,t.x,t.y,t.z,t.w),n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w)},t.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},t.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},t.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},t.upload2i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g)&&(this._gl.uniform2i(e.location,t.r,t.g),n.x=t.r,n.y=t.g):(n.x!==t.x||n.y!==t.y)&&(this._gl.uniform2i(e.location,t.x,t.y),n.x=t.x,n.y=t.y)},t.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},t.upload3i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b)&&(this._gl.uniform3i(e.location,t.r,t.g,t.b),n.x=t.r,n.y=t.g,n.z=t.b):(n.x!==t.x||n.y!==t.y||n.z!==t.z)&&(this._gl.uniform3i(e.location,t.x,t.y,t.z),n.x=t.x,n.y=t.y,n.z=t.z)},t.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},t.upload4i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b||n.w!==t.a)&&(this._gl.uniform4i(e.location,t.r,t.g,t.b,t.a),n.x=t.r,n.y=t.g,n.z=t.b,n.w=t.a):(n.x!==t.x||n.y!==t.y||n.z!==t.z||n.w!==t.w)&&(this._gl.uniform4i(e.location,t.x,t.y,t.z,t.w),n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w)},t.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},t.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},t.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},t.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},t.uploadTextureArray=function(e,t){for(var n=this._rhi,r=e.textureIndex,a=0;a<t.length;a++){var i=t[a];n.activeTexture(r[a]),n.bindTexture(i._platformTexture),i._setUseDepthCompareMode(e.textureUseCompareMode)}},e}(),n4=function(){this.constUniforms=[],this.textureUniforms=[]},n8=((O={})[O.Scene=0]="Scene",O[O.Camera=1]="Camera",O[O.Renderer=2]="Renderer",O[O.Material=3]="Material",O[O.RenderElement=4]="RenderElement",O),n5=/*#__PURE__*/function(){function e(t,n,r){this.sceneUniformBlock=new n4,this.cameraUniformBlock=new n4,this.rendererUniformBlock=new n4,this.materialUniformBlock=new n4,this.renderElementUniformBlock=new n4,this.otherUniformBlock=new n4,this._uploadRenderCount=-1,this._uploadSceneId=-1,this._uploadCameraId=-1,this._uploadRendererId=-1,this._uploadMaterialId=-1,this.attributeLocation=Object.create(null),this._activeTextureUint=0,this._engine=t,this._gl=t._hardwareRenderer.gl,this._glProgram=this._createProgram(n,r),this._glProgram?(this._isValid=!0,this._recordLocation()):this._isValid=!1,this.id=e._counter++}var t=e.prototype;return t.uploadAll=function(e,t){this.uploadUniforms(e,t),this.uploadTextures(e,t)},t.uploadUniforms=function(e,t){for(var n=t._propertyValueMap,r=e.constUniforms,a=0,i=r.length;a<i;a++){var o=r[a],s=n[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var n=t._propertyValueMap,r=e.textureUniforms;if(r)for(var a=0,i=r.length;a<i;a++){var o=r[a],s=n[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,n=e.length;t<n;t++){var r=e[t];r.applyFunc(r,r.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,n=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),n.length>0&&this._groupingSubOtherUniforms(n,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n],a=nY._getShaderPropertyGroup(r.name);void 0!==a&&(e.splice(e.indexOf(r),1),this._groupingUniform(r,a,t))}},t._groupingUniform=function(e,t,n){switch(t){case n8.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case n8.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case n8.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case n8.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case n8.RenderElement:n?this.renderElementUniformBlock.textureUniforms.push(e):this.renderElementUniformBlock.constUniforms.push(e);break;default:n?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var n=this._gl,r=this._createShader(n.VERTEX_SHADER,e);if(!r)return null;var a=this._createShader(n.FRAGMENT_SHADER,t);if(!a)return null;var i=n.createProgram();return i?(n.attachShader(i,r),n.attachShader(i,a),n.linkProgram(i),n.validateProgram(i),n.deleteShader(r),n.deleteShader(a),!no.isEnabled||n.getProgramParameter(i,n.LINK_STATUS)||n.isContextLost())?i:(no.error("Could not link WebGL program\n\nShader error: "+n.getError()+"\n\nValidate status: "+n.getProgramParameter(i,n.VALIDATE_STATUS)+"\n\nProgram information log: "+n.getProgramInfoLog(i)),n.deleteProgram(i),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,n){var r=this._gl,a=r.createShader(t);return a?(r.shaderSource(a,n),r.compileShader(a),!no.isEnabled||r.getShaderParameter(a,r.COMPILE_STATUS)||r.isContextLost())?a:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==r.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+r.getShaderInfoLog(a)+"\nShader source:\n"+e._addLineNum(n)),r.deleteShader(a),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,n=this._glProgram,r=this._getUniformInfos(),a=this._getAttributeInfos(),i=this._engine._basicResources;r.forEach(function(r){var a,o=r.name,s=r.size,l=r.type,c=new n3(e._engine),u=!1,d=!1;o.indexOf("[0]")>0&&(o=o.substr(0,o.length-3),u=!0);var h=t.getUniformLocation(n,o);switch(c.name=o,c.propertyId=nY.getByName(o)._uniqueId,c.location=h,l){case t.FLOAT:u?c.applyFunc=c.upload1fv:(c.applyFunc=c.upload1f,c.cacheValue=0);break;case t.FLOAT_VEC2:u?c.applyFunc=c.upload2fv:(c.applyFunc=c.upload2f,c.cacheValue=new tB(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new tT(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new tI(0,0,0,0));break;case t.BOOL:case t.INT:u?c.applyFunc=c.upload1iv:(c.applyFunc=c.upload1i,c.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:u?c.applyFunc=c.upload2iv:(c.applyFunc=c.upload2i,c.cacheValue=new tB(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new tT(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new tI(0,0,0));break;case t.FLOAT_MAT4:c.applyFunc=u?c.uploadMat4v:c.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.UNSIGNED_INT_SAMPLER_2D:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(l){case t.SAMPLER_2D:a=i.whiteTexture2D;break;case t.SAMPLER_CUBE:a=i.whiteTextureCube;break;case t.UNSIGNED_INT_SAMPLER_2D:a=i.uintWhiteTexture2D;break;case t.SAMPLER_2D_ARRAY:a=i.whiteTexture2DArray;break;case t.SAMPLER_2D_SHADOW:a=e._engine._depthTexture2D,c.textureUseCompareMode=!0}if(d=!0,u){for(var _=Array(s),f=new Int32Array(s),p=Array(s),m=0;m<s;m++)_[m]=a,f[m]=e._activeTextureUint,p[m]=t.TEXTURE0+e._activeTextureUint++;c.textureDefault=_,c.textureIndex=p,c.applyFunc=c.uploadTextureArray,e.bind(),t.uniform1iv(h,f)}else{var g=t.TEXTURE0+e._activeTextureUint;c.textureDefault=a,c.textureIndex=g,c.applyFunc=c.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var v=nY._getShaderPropertyGroup(o);e._groupingUniform(c,v,d)}),a.forEach(function(r){var a=r.name;e.attributeLocation[a]=t.getAttribLocation(n,a)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=Array(n),a=0;a<n;++a){var i=e.getActiveUniform(t,a);r[a]=i}return r},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,n=[],r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a<r;++a){var i=e.getActiveAttrib(t,a);n[a]=i}return n},e._addLineNum=function(e){var t,n=e.split("\n"),r=(n.length+1).toString().length+6;return n.map(function(e,n){if((t="0:"+(n+1)).length>=r)return t.substring(0,r)+e;for(var a=0;a<r-t.length;a++)t+=" ";return t+e}).join("\n")},tG(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();n5._counter=0;var n9=((N={})[N.Canonical=0]="Canonical",N[N.ShaderLab=1]="ShaderLab",N),n6=/*#__PURE__*/function(e){function t(n,r,a,i,o){var s;for(var l in(s=e.call(this)||this)._shaderPassId=0,s._renderStateDataMap={},s._shaderProgramPools=[],s._path="",s._platformMacros=[],s._shaderPassId=t._shaderPassCounter++,s._type=n9.Canonical,"string"==typeof i?(s._name=n,s._shaderLabSource=r,s._vertexEntry=a,s._fragmentEntry=i,o=nj({pipelineStage:nX.Forward},o),s._type=n9.ShaderLab):"string"==typeof a?(s._name=n,s._vertexSource=r,s._fragmentSource=a,o=null!=i?i:{pipelineStage:nX.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=r,o=null!=a?a:{pipelineStage:nX.Forward}),o)s.setTag(l,o[l]);return s}tW(t,e);var n=t.prototype;return n._getShaderProgram=function(e,t){var n=e._getShaderProgramPool(this),r=n.get(t);return r||(r=this._type===n9.Canonical?this._getCanonicalShaderProgram(e,t):this._compileShaderProgram(e,t,this._vertexEntry,this._fragmentEntry),n.cache(r)),r},n._destroy=function(){for(var e=this._shaderProgramPools,t=0,n=e.length;t<n;t++){var r=e[t];r._destroy(),delete r.engine._shaderProgramPools[this._shaderPassId]}e.length=0},n._compileShaderProgram=function(e,n,r,a){var i=this._path,o=this._platformMacros,s=e._hardwareRenderer.isWebGL2,l=[];nH._getMacrosElements(n,l),o.length=0,e._hardwareRenderer.canIUse(nJ.shaderTextureLod)&&o.push("HAS_TEX_LOD"),e._hardwareRenderer.canIUse(nJ.standardDerivatives)&&o.push("HAS_DERIVATIVES"),s?o.push("GRAPHICS_API_WEBGL2"):o.push("GRAPHICS_API_WEBGL1");var c=performance.now(),u=ro._shaderLab._parseShaderPass(this._shaderLabSource,r,a,l,s?nz.GLES300:nz.GLES100,o,new URL(i,t._shaderRootPath).href);return(no.info("[ShaderLab compilation] cost time: "+(performance.now()-c)+"ms"),u)?new n5(e,u.vertex,u.fragment):new n5(e,"","")},n._getCanonicalShaderProgram=function(e,t){var n=e._hardwareRenderer.isWebGL2,r=[];nH._getMacrosElements(t,r);var a=n$.parseCustomMacros(r),i=n?"#version 300 es":"#version 100",o=n?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",s="\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";e._hardwareRenderer.canIUse(nJ.shaderTextureLod)&&(s+="#define HAS_TEX_LOD\n"),e._hardwareRenderer.canIUse(nJ.standardDerivatives)&&(s+="#define HAS_DERIVATIVES\n");var l=" "+i+"\n "+o+"\n "+a+"\n "+n$.parseIncludes(this._vertexSource),c=" "+i+"\n "+o+"\n "+(n?"":n$._shaderExtension)+"\n "+s+"\n "+a+"\n "+n$.parseIncludes(this._fragmentSource);return n&&(l=n$.convertTo300(l),c=n$.convertTo300(c,!0)),new n5(e,l,c)},t}(n1);n6._shaderPassCounter=0,n6._shaderRootPath="shaders://root/";var n7=/*#__PURE__*/function(e){function t(t,n,r){var a;if((a=e.call(this)||this)._name=t,n.length<1)throw" count must large than 0.";for(var i in a._passes=n.slice(),r)a.setTag(i,r[i]);return a}return tW(t,e),tG(t,[{key:"passes",get:function(){return this._passes}}]),t}(n1),re=function(){this.enabled=!1,this.colorBlendOperation=nL.Add,this.alphaBlendOperation=nL.Add,this.sourceColorBlendFactor=nF.One,this.sourceAlphaBlendFactor=nF.One,this.destinationColorBlendFactor=nF.Zero,this.destinationAlphaBlendFactor=nF.Zero,this.colorWriteMask=nD.All},rt=/*#__PURE__*/function(){function e(){this.targetBlendState=new re,this.blendColor=new tO(0,0,0,0),this.alphaToCoverage=!1}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i,o,s,l,c=this.targetBlendState,u=e[nO.BlendStateEnabled0];if(void 0!==u){var d=t.getFloat(u);c.enabled=void 0!==d&&!!d}var h=e[nO.BlendStateColorBlendOperation0];void 0!==h&&(c.colorBlendOperation=null!=(n=t.getFloat(h))?n:nL.Add);var _=e[nO.BlendStateAlphaBlendOperation0];void 0!==_&&(c.alphaBlendOperation=null!=(r=t.getFloat(_))?r:nL.Add);var f=e[nO.BlendStateSourceColorBlendFactor0];void 0!==f&&(c.sourceColorBlendFactor=null!=(a=t.getFloat(f))?a:nF.One);var p=e[nO.BlendStateSourceAlphaBlendFactor0];void 0!==p&&(c.sourceAlphaBlendFactor=null!=(i=t.getFloat(p))?i:nF.One);var m=e[nO.BlendStateDestinationColorBlendFactor0];void 0!==m&&(c.destinationColorBlendFactor=null!=(o=t.getFloat(m))?o:nF.Zero);var g=e[nO.BlendStateDestinationAlphaBlendFactor0];void 0!==g&&(c.destinationAlphaBlendFactor=null!=(s=t.getFloat(g))?s:nF.Zero);var v=e[nO.BlendStateColorWriteMask0];void 0!==v&&(c.colorWriteMask=null!=(l=t.getFloat(v))?l:nD.All);var y=e[nO.BlendStateBlendColor];if(void 0!==y){var x=t.getColor(y);void 0!==x&&this.blendColor.copyFrom(x)}var b=e[nO.BlendStateAlphaToCoverage];if(void 0!==b){var C=t.getFloat(b);this.alphaToCoverage=void 0!==C&&!!C}},t._apply=function(e,t,n){this._platformApply(e,t.blendState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=n.targetBlendState,o=this.targetBlendState,s=o.enabled,l=o.colorBlendOperation,c=o.alphaBlendOperation,u=o.sourceColorBlendFactor,d=o.destinationColorBlendFactor,h=o.sourceAlphaBlendFactor,_=o.destinationAlphaBlendFactor,f=o.colorWriteMask;if(r){var p=r[nO.BlendStateColorWriteMask0];void 0!==p&&(f=p)}if(s!==i.enabled&&(s?a.enable(a.BLEND):a.disable(a.BLEND),i.enabled=s),s){(u!==i.sourceColorBlendFactor||d!==i.destinationColorBlendFactor||h!==i.sourceAlphaBlendFactor||_!==i.destinationAlphaBlendFactor)&&(a.blendFuncSeparate(e._getGLBlendFactor(t,u),e._getGLBlendFactor(t,d),e._getGLBlendFactor(t,h),e._getGLBlendFactor(t,_)),i.sourceColorBlendFactor=u,i.destinationColorBlendFactor=d,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=_),(l!==i.colorBlendOperation||c!==i.alphaBlendOperation)&&(a.blendEquationSeparate(e._getGLBlendOperation(t,l),e._getGLBlendOperation(t,c)),i.colorBlendOperation=l,i.alphaBlendOperation=c);var m=this.blendColor;tO.equals(n.blendColor,m)||(a.blendColor(m.r,m.g,m.b,m.a),n.blendColor.copyFrom(m))}f!==i.colorWriteMask&&(a.colorMask((f&nD.Red)!=0,(f&nD.Green)!=0,(f&nD.Blue)!=0,(f&nD.Alpha)!=0),i.colorWriteMask=f);var g=this.alphaToCoverage;g!==n.alphaToCoverage&&(g?a.enable(a.SAMPLE_ALPHA_TO_COVERAGE):a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),n.alphaToCoverage=g)},e._getGLBlendFactor=function(e,t){var n=e.gl;switch(t){case nF.Zero:return n.ZERO;case nF.One:return n.ONE;case nF.SourceColor:return n.SRC_COLOR;case nF.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case nF.DestinationColor:return n.DST_COLOR;case nF.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case nF.SourceAlpha:return n.SRC_ALPHA;case nF.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case nF.DestinationAlpha:return n.DST_ALPHA;case nF.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case nF.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case nF.BlendColor:return n.CONSTANT_COLOR;case nF.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},e._getGLBlendOperation=function(e,t){var n=e.gl;switch(t){case nL.Add:return n.FUNC_ADD;case nL.Subtract:return n.FUNC_SUBTRACT;case nL.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case nL.Min:if(!e.canIUse(nJ.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case nL.Max:if(!e.canIUse(nJ.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},e}();tX([tZ],rt.prototype,"targetBlendState",void 0),tX([tZ],rt.prototype,"blendColor",void 0);var rn=/*#__PURE__*/function(){function e(){this.enabled=!0,this.compareFunction=nB.Less,this.writeEnabled=!0}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r=e[nO.DepthStateEnabled];if(void 0!==r){var a=t.getFloat(r);this.enabled=void 0!==a&&!!a}var i=e[nO.DepthStateWriteEnabled];if(void 0!==i){var o=t.getFloat(i);this.writeEnabled=void 0!==o&&!!o}var s=e[nO.DepthStateCompareFunction];void 0!==s&&(this.compareFunction=null!=(n=t.getFloat(s))?n:nB.Less)},t._apply=function(e,t,n){this._platformApply(e,t.depthState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=this.enabled,o=this.compareFunction,s=this.writeEnabled;if(r){var l=r[nO.DepthStateEnabled];void 0!==l&&(i=l)}i!=n.enabled&&(i?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST),n.enabled=i),i&&o!=n.compareFunction&&(a.depthFunc(e._getGLCompareFunction(t,o)),n.compareFunction=o),s!=n.writeEnabled&&(a.depthMask(s),n.writeEnabled=s)},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nB.Never:return n.NEVER;case nB.Less:return n.LESS;case nB.Equal:return n.EQUAL;case nB.LessEqual:return n.LEQUAL;case nB.Greater:return n.GREATER;case nB.NotEqual:return n.NOTEQUAL;case nB.GreaterEqual:return n.GEQUAL;case nB.Always:return n.ALWAYS}},e}(),rr=/*#__PURE__*/function(){function e(){this.cullMode=nI.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i=e[nO.RasterStateCullMode];void 0!==i&&(this.cullMode=null!=(n=t.getFloat(i))?n:nI.Back);var o=e[nO.RasterStateDepthBias];void 0!==o&&(this.depthBias=null!=(r=t.getFloat(o))?r:0);var s=e[nO.RasterStateSlopeScaledDepthBias];void 0!==s&&(this.slopeScaledDepthBias=null!=(a=t.getFloat(s))?a:0)},t._apply=function(e,t,n,r){this._platformApply(e,t.rasterState,n,r)},t._platformApply=function(e,t,n,r){var a=e.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias;if(r){var l=r[nO.RasterStateCullMode];void 0!==l&&(i=l)}var c=i!==nI.Off;c!==t._cullFaceEnable&&(c?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),t._cullFaceEnable=c),c&&i!==t.cullMode&&(i==nI.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),t.cullMode=i),n!==t._frontFaceInvert&&(n?a.frontFace(a.CW):a.frontFace(a.CCW),t._frontFaceInvert=n),e._enableGlobalDepthBias||o===t.depthBias&&s===t.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),t.depthBias=o,t.slopeScaledDepthBias=s)},e}(),ra=/*#__PURE__*/function(){function e(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=nB.Always,this.compareFunctionBack=nB.Always,this.passOperationFront=nk.Keep,this.passOperationBack=nk.Keep,this.failOperationFront=nk.Keep,this.failOperationBack=nk.Keep,this.zFailOperationFront=nk.Keep,this.zFailOperationBack=nk.Keep}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i,o,s,l,c,u,d,h,_=e[nO.StencilStateEnabled];if(void 0!==_){var f=t.getFloat(_);this.enabled=void 0!==f&&!!f}var p=e[nO.StencilStateReferenceValue];void 0!==p&&(this.referenceValue=null!=(n=t.getFloat(p))?n:0);var m=e[nO.StencilStateMask];void 0!==m&&(this.mask=null!=(r=t.getFloat(m))?r:255);var g=e[nO.StencilStateWriteMask];void 0!==g&&(this.writeMask=null!=(a=t.getFloat(g))?a:255);var v=e[nO.StencilStateCompareFunctionFront];void 0!==v&&(this.compareFunctionFront=null!=(i=t.getFloat(v))?i:nB.Always);var y=e[nO.StencilStateCompareFunctionBack];void 0!==y&&(this.compareFunctionBack=null!=(o=t.getFloat(y))?o:nB.Always);var x=e[nO.StencilStatePassOperationFront];void 0!==x&&(this.passOperationFront=null!=(s=t.getFloat(x))?s:nk.Keep);var b=e[nO.StencilStatePassOperationBack];void 0!==b&&(this.passOperationBack=null!=(l=t.getFloat(b))?l:nk.Keep);var C=e[nO.StencilStateFailOperationFront];void 0!==C&&(this.failOperationFront=null!=(c=t.getFloat(C))?c:nk.Keep);var S=e[nO.StencilStateFailOperationBack];void 0!==S&&(this.failOperationBack=null!=(u=t.getFloat(S))?u:nk.Keep);var T=e[nO.StencilStateZFailOperationFront];void 0!==T&&(this.zFailOperationFront=null!=(d=t.getFloat(T))?d:nk.Keep);var A=e[nO.StencilStateZFailOperationBack];void 0!==A&&(this.zFailOperationBack=null!=(h=t.getFloat(A))?h:nk.Keep)},t._apply=function(e,t,n){this._platformApply(e,t.stencilState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=this.enabled,o=this.referenceValue,s=this.mask,l=this.compareFunctionFront,c=this.compareFunctionBack,u=this.failOperationFront,d=this.zFailOperationFront,h=this.passOperationFront,_=this.failOperationBack,f=this.zFailOperationBack,p=this.passOperationBack,m=this.writeMask;if(r){var g=r[nO.StencilStateEnabled];void 0!==g&&(i=g);var v=r[nO.StencilStateWriteMask];void 0!==v&&(m=v);var y=r[nO.StencilStateReferenceValue];void 0!==y&&(o=y);var x=r[nO.StencilStateCompareFunctionFront];void 0!==x&&(l=x);var b=r[nO.StencilStateCompareFunctionBack];void 0!==b&&(c=b);var C=r[nO.StencilStatePassOperationFront];void 0!==C&&(h=C);var S=r[nO.StencilStatePassOperationBack];void 0!==S&&(p=S);var T=r[nO.StencilStateFailOperationFront];void 0!==T&&(u=T);var A=r[nO.StencilStateFailOperationBack];void 0!==A&&(_=A);var E=r[nO.StencilStateZFailOperationFront];void 0!==E&&(d=E);var R=r[nO.StencilStateZFailOperationBack];void 0!==R&&(f=R)}if(i!=n.enabled&&(i?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),n.enabled=i),i){var M=o!==n.referenceValue||s!==n.mask;(M||l!==n.compareFunctionFront)&&(a.stencilFuncSeparate(a.FRONT,e._getGLCompareFunction(t,l),o,s),n.compareFunctionFront=l),(M||c!==n.compareFunctionBack)&&(a.stencilFuncSeparate(a.BACK,e._getGLCompareFunction(t,c),o,s),n.compareFunctionBack=c),M&&(n.referenceValue=o,n.mask=s),(u!==n.failOperationFront||d!==n.zFailOperationFront||h!==n.passOperationFront)&&(a.stencilOpSeparate(a.FRONT,e._getGLStencilOperation(t,u),e._getGLStencilOperation(t,d),e._getGLStencilOperation(t,h)),n.failOperationFront=u,n.zFailOperationFront=d,n.passOperationFront=h),(_!==n.failOperationBack||f!==n.zFailOperationBack||p!==n.passOperationBack)&&(a.stencilOpSeparate(a.BACK,e._getGLStencilOperation(t,_),e._getGLStencilOperation(t,f),e._getGLStencilOperation(t,p)),n.failOperationBack=_,n.zFailOperationBack=f,n.passOperationBack=p),m!==n.writeMask&&(a.stencilMask(m),n.writeMask=m)}},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nB.Never:return n.NEVER;case nB.Less:return n.LESS;case nB.Equal:return n.EQUAL;case nB.LessEqual:return n.LEQUAL;case nB.Greater:return n.GREATER;case nB.NotEqual:return n.NOTEQUAL;case nB.GreaterEqual:return n.GEQUAL;case nB.Always:return n.ALWAYS}},e._getGLStencilOperation=function(e,t){var n=e.gl;switch(t){case nk.Keep:return n.KEEP;case nk.Zero:return n.ZERO;case nk.Replace:return n.REPLACE;case nk.IncrementSaturate:return n.INCR;case nk.DecrementSaturate:return n.DECR;case nk.Invert:return n.INVERT;case nk.IncrementWrap:return n.INCR_WRAP;case nk.DecrementWrap:return n.DECR_WRAP}},e}(),ri=/*#__PURE__*/function(){function e(){this.blendState=new rt,this.depthState=new rn,this.stencilState=new ra,this.rasterState=new rr,this.renderQueueType=nN.Opaque}var t=e.prototype;return t._applyStates=function(e,t,n,r,a){n&&this._applyStatesByShaderData(n,r);var i=e._hardwareRenderer,o=e._lastRenderState,s=e._renderContext;this.blendState._apply(i,o,a),this.depthState._apply(i,o,a),this.stencilState._apply(i,o,a),this.rasterState._apply(i,o,s.flipProjection?!t:t,a)},t._getRenderQueueByShaderData=function(e,t){var n,r=e[nO.RenderQueueType];return void 0===r?this.renderQueueType:null!=(n=t.getFloat(r))?n:nN.Opaque},t._applyStatesByShaderData=function(e,t){this.blendState._applyShaderDataValue(e,t),this.depthState._applyShaderDataValue(e,t),this.stencilState._applyShaderDataValue(e,t),this.rasterState._applyShaderDataValue(e,t)},e}();tX([tZ],ri.prototype,"blendState",void 0),tX([tZ],ri.prototype,"depthState",void 0),tX([tZ],ri.prototype,"stencilState",void 0),tX([tZ],ri.prototype,"rasterState",void 0);var ro=/*#__PURE__*/function(){function e(e,t){this.name=e,this._refCount=0,this._destroyed=!1,this.name=e,this._subShaders=t}var t=e.prototype;return t._registerPath=function(e){for(var t,n=nG(this._subShaders);!(t=n()).done;)for(var r,a=t.value,i=nG(a.passes);!(r=i()).done;)r.value._path=e},t.compileVariant=function(t,n){var r=e._compileMacros;r.clear();for(var a=0,i=n.length;a<i;a++)r.enable(nH.getByName(n[a]));for(var o=!1,s=this._subShaders,l=0,c=s.length;l<c;l++)for(var u=s[l].passes,d=0,h=u.length;d<h;d++){var _=u[d]._getShaderProgram(t,r);o=0===d?_.isValid:o&&_.isValid}return o},t.destroy=function(t){if(void 0===t&&(t=!1),!t&&0!==this._refCount)return!1;for(var n=this._subShaders,r=0,a=n.length;r<a;r++)for(var i=n[r].passes,o=0,s=i.length;o<s;o++)i[o]._destroy();return delete e._shaderMap[this.name],this._destroyed=!0,!0},t._getReferCount=function(){return this._refCount},t._addReferCount=function(e){this._refCount+=e},e.create=function(t,n,r){var a,i=e._shaderMap;if(n){if(i[t]){console.error('Shader named "'+t+'" already exists.');return}if("string"==typeof n)a=new e(t,[new n7("Default",[new n6(n,r)])]);else if(n.length>0)a=n[0].constructor===n6?new e(t,[new n7("Default",n)]):new e(t,n.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!e._shaderLab)throw"ShaderLab has not been set up yet.";var o=e._shaderLab._parseShaderContent(t);if(i[o.name]){console.error('Shader named "'+o.name+'" already exists.');return}var s=o.subShaders.map(function(t){var n=t.passes.map(function(t){if(t.isUsePass){var n,r,a=t.name.split("/");return null==(r=e.find(a[0]))?void 0:null==(n=r.subShaders.find(function(e){return e.name===a[1]}))?void 0:n.passes.find(function(e){return e.name===a[2]})}var i=new n6(t.name,t.contents,t.vertexEntry,t.fragmentEntry,t.tags),o=t.renderStates,s=o.constantMap,l=o.variableMap;if(Object.keys(s).length>0||Object.keys(l).length>0){var c=new ri;for(var u in i._renderState=c,s)e._applyConstRenderStates(c,parseInt(u),s[u]);var d={};for(var h in l)d[h]=nY.getByName(l[h]);i._renderStateDataMap=d}return i});return new n7(t.name,n,t.tags)});return a=new e(o.name,s),i[o.name]=a,a}return i[t]=a,a},e.find=function(t){return e._shaderMap[t]},e._applyConstRenderStates=function(e,t,n){switch(t){case nO.BlendStateEnabled0:e.blendState.targetBlendState.enabled=n;break;case nO.BlendStateColorBlendOperation0:e.blendState.targetBlendState.colorBlendOperation=n;break;case nO.BlendStateAlphaBlendOperation0:e.blendState.targetBlendState.alphaBlendOperation=n;break;case nO.BlendStateSourceColorBlendFactor0:e.blendState.targetBlendState.sourceColorBlendFactor=n;break;case nO.BlendStateDestinationColorBlendFactor0:e.blendState.targetBlendState.destinationColorBlendFactor=n;break;case nO.BlendStateSourceAlphaBlendFactor0:e.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case nO.BlendStateDestinationAlphaBlendFactor0:e.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case nO.BlendStateColorWriteMask0:e.blendState.targetBlendState.colorWriteMask=n;break;case nO.DepthStateEnabled:e.depthState.enabled=n;break;case nO.DepthStateWriteEnabled:e.depthState.writeEnabled=n;break;case nO.DepthStateCompareFunction:e.depthState.compareFunction=n;break;case nO.StencilStateEnabled:e.stencilState.enabled=n;break;case nO.StencilStateReferenceValue:e.stencilState.referenceValue=n;break;case nO.StencilStateMask:e.stencilState.mask=n;break;case nO.StencilStateWriteMask:e.stencilState.writeMask=n;break;case nO.StencilStateCompareFunctionFront:e.stencilState.compareFunctionFront=n;break;case nO.StencilStateCompareFunctionBack:e.stencilState.compareFunctionBack=n;break;case nO.StencilStatePassOperationFront:e.stencilState.passOperationFront=n;break;case nO.StencilStatePassOperationBack:e.stencilState.passOperationBack=n;break;case nO.StencilStateFailOperationFront:e.stencilState.failOperationFront=n;break;case nO.StencilStateFailOperationBack:e.stencilState.failOperationBack=n;break;case nO.StencilStateZFailOperationFront:e.stencilState.zFailOperationFront=n;break;case nO.StencilStateZFailOperationBack:e.stencilState.zFailOperationBack=n;break;case nO.RasterStateCullMode:e.rasterState.cullMode=n;break;case nO.RasterStateDepthBias:e.rasterState.depthBias=n;break;case nO.RasterStateSlopeScaledDepthBias:e.rasterState.slopeScaledDepthBias=n;break;case nO.RenderQueueType:e.renderQueueType=n}},e.getMacroByName=function(e,t){return nH.getByName(e,t)},e.getPropertyByName=function(e){return nY.getByName(e)},tG(e,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();ro._compileMacros=new nW,ro._shaderMap=Object.create(null);var rs=/*#__PURE__*/function(){function e(e){this._propertyValueMap=Object.create(null),this._macroCollection=new nW,this._macroMap=Object.create(null),this._refCount=0,this._group=e}var t=e.prototype;return t.getFloat=function(e){return this.getPropertyValue(e)},t.setFloat=function(e,t){this._setPropertyValue(e,nV.Float,t)},t.getInt=function(e){return this.getPropertyValue(e)},t.setInt=function(e,t){this._setPropertyValue(e,nV.Int,t)},t.getFloatArray=function(e){return this.getPropertyValue(e)},t.setFloatArray=function(e,t){this._setPropertyValue(e,nV.FloatArray,t)},t.getIntArray=function(e){return this.getPropertyValue(e)},t.setIntArray=function(e,t){this._setPropertyValue(e,nV.IntArray,t)},t.getVector2=function(e){return this.getPropertyValue(e)},t.setVector2=function(e,t){this._setPropertyValue(e,nV.Vector2,t)},t.getVector3=function(e){return this.getPropertyValue(e)},t.setVector3=function(e,t){this._setPropertyValue(e,nV.Vector3,t)},t.getVector4=function(e){return this.getPropertyValue(e)},t.setVector4=function(e,t){this._setPropertyValue(e,nV.Vector4,t)},t.getMatrix=function(e){return this.getPropertyValue(e)},t.setMatrix=function(e,t){this._setPropertyValue(e,nV.Matrix,t)},t.getColor=function(e){return this.getPropertyValue(e)},t.setColor=function(e,t){this._setPropertyValue(e,nV.Color,t)},t.getTexture=function(e){return this.getPropertyValue(e)},t.setTexture=function(e,t){var n=this._refCount;if(n>0){var r=this.getPropertyValue(e);r&&r._addReferCount(-n),t&&t._addReferCount(n)}this._setPropertyValue(e,nV.Texture,t)},t.getTextureArray=function(e){return this.getPropertyValue(e)},t.setTextureArray=function(e,t){var n=this._refCount;if(n>0){var r=this.getPropertyValue(e);if(r)for(var a=0,i=r.length;a<i;a++)r[a]._addReferCount(-n);if(t)for(var o=0,s=t.length;o<s;o++)t[o]._addReferCount(n)}this._setPropertyValue(e,nV.TextureArray,t)},t.getPropertyValue=function(e){return"string"==typeof e&&(e=nY.getByName(e)),this._propertyValueMap[e._uniqueId]},t.enableMacro=function(e,t){"string"==typeof e&&(e=nH.getByName(e,t));var n=e._nameId,r=this._macroMap[n];if(r!==e){var a=this._macroCollection;r&&a.disable(r),a.enable(e),this._macroMap[n]=e}},t.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=nH._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},t.getMacros=function(e){if(!e)return Object.values(this._macroMap);var t=this._macroMap;for(var n in e.length=0,t)e.push(t[n])},t.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=nY._propertyIdMap;for(var a in n)t.push(r[a]);if(!e)return t},t.clone=function(){var t=new e(this._group);return this.cloneTo(t),t},t.cloneTo=function(e){t$.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),n=this._propertyValueMap,r=e._propertyValueMap,a=Object.keys(n),i=0,o=a.length;i<o;i++){var s=a[i],l=n[s];if(null!=l){if("number"==typeof l)r[s]=l;else if(tK(l,ns))r[s]=l,t>0&&l._addReferCount(t);else if(tK(l,Array)||tK(l,Float32Array)||tK(l,Int32Array))r[s]=l.slice();else{var c=r[s];c?c.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},t._setPropertyValue=function(e,t,n){if("string"==typeof e&&(e=nY.getByName(e)),e._group!==this._group){if(void 0===e._group)e._group=this._group;else throw"Shader property "+e.name+" has been used as "+n8[e._group]+" group."}if(e._type!==t){if(void 0===e._type)e._type=t;else throw"Shader property "+e.name+" has been used as "+nV[e._type]+" type."}this._propertyValueMap[e._uniqueId]=n},t._getReferCount=function(){return this._refCount},t._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&tK(r,ns)&&r._addReferCount(e)}},e}();tX([tq],rs.prototype,"_group",void 0),tX([tq],rs.prototype,"_propertyValueMap",void 0),tX([tq],rs.prototype,"_macroCollection",void 0),tX([tq],rs.prototype,"_macroMap",void 0),tX([tq],rs.prototype,"_refCount",void 0);var rl=/*#__PURE__*/function(){function e(){}return e.canBatchSprite=function(t,n){if(!0===n.shaderPasses[0].getTagValue(e._disableBatchTag)||t.subChunk.chunk!==n.subChunk.chunk)return!1;var r=t.component,a=n.component,i=r.maskInteraction;return i===a.maskInteraction&&(i===nv.None||r.maskLayer===a.maskLayer)&&t.texture===n.texture&&t.material===n.material},e.canBatchSpriteMask=function(e,t){if(e.subChunk.chunk!==t.subChunk.chunk)return!1;var n=r2._alphaCutoffProperty;return e.texture===t.texture&&e.component.shaderData.getFloat(n)===t.component.shaderData.getFloat(n)},e.batchFor2D=function(e,t){var n=t?t.subChunk:e.subChunk,r=n.chunk,a=n.indices,i=a.length,o=r.updateIndexLength;if(t)e.subChunk.subMesh.count+=i;else{var s=n.subMesh;s.start=o,s.count=i}for(var l=n.vertexArea,c=l.start,u=l.size,d=c/9,h=r.indices,_=0;_<i;++_)h[o++]=d+a[_];r.updateIndexLength+=i,r.updateVertexStart=Math.min(r.updateVertexStart,c),r.updateVertexEnd=Math.max(r.updateVertexEnd,c+u)},e}();rl._disableBatchTag=n0.getByName("spriteDisableBatching");var rc=((V={})[V.None=0]="None",V[V.Scene=1]="Scene",V[V.Hierarchy=2]="Hierarchy",V[V.All=3]="All",V),ru=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t.engine)||this)._awoken=!1,n._phasedActiveInScene=!1,n._phasedActive=!1,n._enabled=!0,n._entity=t,n}tW(t,e);var n=t.prototype;return n._onAwake=function(){},n._onEnable=function(){},n._onDisable=function(){},n._onEnableInScene=function(){},n._onDisableInScene=function(){},n._setActive=function(e,t){var n=this._entity;t&rc.Scene&&(e?!this._phasedActiveInScene&&n._isActiveInScene&&this._enabled&&(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&!(n._isActiveInScene&&this._enabled)&&(this._phasedActiveInScene=!1,this._onDisableInScene())),t&rc.Hierarchy&&(e?(!this._awoken&&n._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&n._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(n._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable()))},n._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._entity;t._removeComponent(this),this._enabled&&(t._isActiveInScene&&this._onDisableInScene(),t._isActiveInHierarchy&&this._onDisable())},tG(t,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity._isActiveInScene&&(e?this._phasedActiveInScene||(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&(this._phasedActiveInScene=!1,this._onDisableInScene())),this._entity.isActiveInHierarchy&&(e?this._phasedActive||(this._phasedActive=!0,this._onEnable()):this._phasedActive&&(this._phasedActive=!1,this._onDisable())))}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),t}(t0);tX([tq],ru.prototype,"_entity",void 0),tX([tq],ru.prototype,"_awoken",void 0),tX([tq],ru.prototype,"_phasedActiveInScene",void 0),tX([tq],ru.prototype,"_phasedActive",void 0),tX([tQ],ru.prototype,"_enabled",void 0);var rd=/*#__PURE__*/function(){function e(){}return e._addCheck=function(t,n){for(;n!==ru;){var r=e._dependenciesMap.get(n);if(r)for(var a=r.components,i=r.mode,o=0,s=a.length;o<s;o++){var l=a[o];if(!t.getComponent(l)){if(1===i)t.addComponent(l);else throw"Should add "+l.name+" before adding "+n.name}}n=Object.getPrototypeOf(n)}},e._removeCheck=function(t,n){for(var r=t._components,a=r.length;n!==ru;){for(var i=0,o=0;o<a;o++)if(tK(r[o],n)&&++i>1)return;var s=e._invDependenciesMap.get(n);if(s){for(var l=0,c=s.length;l<c;l++)if(t.getComponent(s[l]))throw"Should remove "+s[l].name+" before remove "+n.name}n=Object.getPrototypeOf(n)}},e._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},e._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},e}();function rh(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){rd._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return rd._addInvDependency(t,e)})}}rd._invDependenciesMap=new Map,rd._dependenciesMap=new Map;var r_=((k={})[k.CheckOnly=0]="CheckOnly",k[k.AutoAdd=1]="AutoAdd",k),rf=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.flag=!0,t}return tW(t,e),t.prototype.dispatch=function(){this.flag=!0},t}(/*#__PURE__*/function(){function e(){this._flagManagers=[]}var t=e.prototype;return t.clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},t.destroy=function(){this._removeFromManagers(),this._flagManagers=null},t._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)nT.removeFromArray(e[t]._updateFlags,this)},e}()),rp=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._position=new tT,n._rotation=new tT,n._rotationQuaternion=new tF,n._scale=new tT(1,1,1),n._localUniformScaling=!0,n._worldPosition=new tT,n._worldRotation=new tT,n._worldRotationQuaternion=new tF,n._worldUniformScaling=!0,n._lossyWorldScale=new tT(1,1,1),n._localMatrix=new tL,n._worldMatrix=new tL,n._worldForward=null,n._worldRight=null,n._worldUp=null,n._isParentDirty=!0,n._parentTransformCache=null,n._dirtyFlag=188,n._onPositionChanged=n._onPositionChanged.bind(n),n._onWorldPositionChanged=n._onWorldPositionChanged.bind(n),n._onRotationChanged=n._onRotationChanged.bind(n),n._onWorldRotationChanged=n._onWorldRotationChanged.bind(n),n._onRotationQuaternionChanged=n._onRotationQuaternionChanged.bind(n),n._onWorldRotationQuaternionChanged=n._onWorldRotationQuaternionChanged.bind(n),n._onScaleChanged=n._onScaleChanged.bind(n),n._position._onValueChanged=n._onPositionChanged,n._worldPosition._onValueChanged=n._onWorldPositionChanged,n._rotation._onValueChanged=n._onRotationChanged,n._worldRotation._onValueChanged=n._onWorldRotationChanged,n._rotationQuaternion._onValueChanged=n._onRotationQuaternionChanged,n._worldRotationQuaternion._onValueChanged=n._onWorldRotationQuaternionChanged,n._scale._onValueChanged=n._onScaleChanged,n}tW(t,e);var n=t.prototype;return n.setPosition=function(e,t,n){this._position.set(e,t,n)},n.setRotation=function(e,t,n){this._rotation.set(e,t,n)},n.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},n.setScale=function(e,t,n){this._scale.set(e,t,n)},n.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},n.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},n.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},n.translate=function(e,n,r,a){if("number"==typeof e){var i=t._tempVec30;i.set(e,n,r),this._translate(i,a)}else this._translate(e,n)},n.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},n.rotateByAxis=function(e,n,r){void 0===r&&(r=!0);var a=n*tS.degreeToRadFactor;tF.rotationAxisAngle(e,a,t._tempQuat0),this._rotateByQuat(t._tempQuat0,r)},n.lookAt=function(e,n){var r=t._tempVec30;tT.subtract(this.worldPosition,e,r);var a=r.length();if(!(a<=tS.zeroTolerance)){r.scale(1/a);var i=t._tempVec31;if(n?tT.cross(n,r,i):i.set(r.z,0,-r.x),!((a=i.length())<=tS.zeroTolerance)){i.scale(1/a);var o=t._tempVec32;tT.cross(r,i,o);var s=t._tempMat41,l=s.elements;l[0]=i.x,l[1]=i.y,l[2]=i.z,l[4]=o.x,l[5]=o.y,l[6]=o.z,l[8]=r.x,l[9]=r.y,l[10]=r.z,s.getRotation(this._worldRotationQuaternion)}}},n._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag(444)},n._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},n._copyFrom=function(e){this._position.copyFrom(e.position),this._rotation.copyFrom(e.rotation),this._scale.copyFrom(e.scale)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._worldPosition._onValueChanged=null,this._rotation._onValueChanged=null,this._worldRotation._onValueChanged=null,this._rotationQuaternion._onValueChanged=null,this._worldRotationQuaternion._onValueChanged=null,this._position._onValueChanged=null,this._scale._onValueChanged=null},n._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)){this._worldAssociatedChange(132);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionFlag()}},n._updateWorldRotationFlag=function(){var e=this._getParentTransform(),t=!e||e._getWorldUniformScaling()?152:184;if(!this._isContainDirtyFlags(t)){this._worldAssociatedChange(t),t=this._getWorldUniformScaling()?156:188;for(var n,r=this._entity._children,a=0,i=r.length;a<i;a++)null==(n=r[a].transform)||n._updateWorldPositionAndRotationFlag(t)}},n._updateWorldPositionAndRotationFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e),e=this._getWorldUniformScaling()?156:188;for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateWorldPositionAndRotationFlag(e)}},n._updateWorldScaleFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e),e|=4;for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateWorldPositionAndScaleFlag(e)}},n._updateWorldPositionAndScaleFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e);for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateWorldPositionAndScaleFlag(e)}},n._updateAllWorldFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e);for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateAllWorldFlag(e)}},n._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;for(var e=null,t=this._entity.parent;t;){var n=t.transform;if(n){e=n;break}t=t.parent}return this._parentTransformCache=e,this._isParentDirty=!1,e},n._getScaleMatrix=function(){var e=t._tempQuat0,n=t._tempMat30,r=t._tempMat31,a=t._tempMat32;return r.copyFromMatrix(this.worldMatrix),tF.invert(this.worldRotationQuaternion,e),tP.rotationQuaternion(e,n),tP.multiply(n,r,a),a},n._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},n._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},n._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},n._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},n._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._entity._updateFlagManager.dispatch(e)},n._rotateByQuat=function(e,t){t?tF.multiply(this.rotationQuaternion,e,this._rotationQuaternion):tF.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},n._translate=function(e,n){if(void 0===n&&(n=!0),n){var r=t._tempVec30;tT.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},n._rotateXYZ=function(e,n,r,a){void 0===a&&(a=!0);var i=tS.degreeToRadFactor,o=t._tempQuat0;tF.rotationEuler(e*i,n*i,r*i,o),this._rotateByQuat(o,a)},n._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},n._onWorldPositionChanged=function(){var e=this._worldPosition,n=this._getParentTransform();n?(tL.invert(n.worldMatrix,t._tempMat41),tT.transformCoordinate(e,t._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},n._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},n._onWorldRotationChanged=function(){var e=this._worldRotation;tF.rotationEuler(tS.degreeToRadian(e.x),tS.degreeToRadian(e.y),tS.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},n._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},n._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,n=this._getParentTransform();if(n){var r=t._tempQuat0;tF.invert(n.worldRotationQuaternion,r),tF.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},n._onScaleChanged=function(){var e=this._scale,t=e.x,n=e.y,r=e.z;this._setDirtyFlagTrue(64);var a=t==n&&n==r;this._localUniformScaling!==a?(this._localUniformScaling=a,this._updateWorldScaleFlag(416)):this._updateWorldScaleFlag(160)},n._getWorldUniformScaling=function(){if(this._isContainDirtyFlag(256)){var e=this._localUniformScaling;if(e){var t=this._getParentTransform();this._worldUniformScaling=e&&(!t||t._getWorldUniformScaling())}else this._worldUniformScaling=!1;this._setDirtyFlagFalse(256)}return this._worldUniformScaling},n.registerWorldChangeFlag=function(){return this.entity._updateFlagManager.createFlag(rf)},tG(t,[{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"worldPosition",get:function(){var e=this._worldPosition;return this._isContainDirtyFlag(4)&&(e._onValueChanged=null,this._getParentTransform()?this.worldMatrix.getTranslation(e):e.copyFrom(this._position),e._onValueChanged=this._onWorldPositionChanged,this._setDirtyFlagFalse(4)),e},set:function(e){this._worldPosition!==e&&this._worldPosition.copyFrom(e)}},{key:"rotation",get:function(){var e=this._rotation;return this._isContainDirtyFlag(1)&&(e._onValueChanged=null,this._rotationQuaternion.toEuler(e),e.scale(tS.radToDegreeFactor),e._onValueChanged=this._onRotationChanged,this._setDirtyFlagFalse(1)),e},set:function(e){this._rotation!==e&&this._rotation.copyFrom(e)}},{key:"worldRotation",get:function(){var e=this._worldRotation;return this._isContainDirtyFlag(8)&&(e._onValueChanged=null,this.worldRotationQuaternion.toEuler(e),e.scale(tS.radToDegreeFactor),e._onValueChanged=this._onWorldRotationChanged,this._setDirtyFlagFalse(8)),e},set:function(e){this._worldRotation!==e&&this._worldRotation.copyFrom(e)}},{key:"rotationQuaternion",get:function(){var e=this._rotationQuaternion;return this._isContainDirtyFlag(2)&&(e._onValueChanged=null,tF.rotationEuler(tS.degreeToRadian(this._rotation.x),tS.degreeToRadian(this._rotation.y),tS.degreeToRadian(this._rotation.z),e),e._onValueChanged=this._onRotationQuaternionChanged,this._setDirtyFlagFalse(2)),e},set:function(e){this._rotationQuaternion!==e?e.normalized?this._rotationQuaternion.copyFrom(e):tF.normalize(e,this._rotationQuaternion):e.normalized||e.normalize()}},{key:"worldRotationQuaternion",get:function(){var e=this._worldRotationQuaternion;if(this._isContainDirtyFlag(16)){e._onValueChanged=null;var t=this._getParentTransform();null!=t?tF.multiply(t.worldRotationQuaternion,this.rotationQuaternion,e):e.copyFrom(this.rotationQuaternion),e._onValueChanged=this._onWorldRotationQuaternionChanged,this._setDirtyFlagFalse(16)}return e},set:function(e){this._worldRotationQuaternion!==e&&(e.normalized?this._worldRotationQuaternion.copyFrom(e):tF.normalize(e,this._worldRotationQuaternion)),e.normalized||e.normalize()}},{key:"scale",get:function(){return this._scale},set:function(e){this._scale!==e&&this._scale.copyFrom(e)}},{key:"lossyWorldScale",get:function(){if(this._isContainDirtyFlag(32)){if(this._getParentTransform()){var e=this._getScaleMatrix().elements;this._lossyWorldScale.set(e[0],e[4],e[8])}else this._lossyWorldScale.copyFrom(this._scale);this._setDirtyFlagFalse(32)}return this._lossyWorldScale}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(tL.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(e){this._localMatrix!==e&&this._localMatrix.copyFrom(e);var t=this._position,n=this._rotationQuaternion,r=this._scale;t._onValueChanged=n._onValueChanged=r._onValueChanged=null,this._localMatrix.decompose(t,n,r),t._onValueChanged=this._onPositionChanged,n._onValueChanged=this._onRotationQuaternionChanged,r._onValueChanged=this._onScaleChanged,this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(66);var a=r.x===r.y&&r.y===r.z;this._localUniformScaling!==a?(this._localUniformScaling=a,this._updateAllWorldFlag(444)):this._updateAllWorldFlag(188)}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var e=this._getParentTransform();e?tL.multiply(e.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(e){this._worldMatrix!==e&&this._worldMatrix.copyFrom(e);var n=this._getParentTransform();n?(tL.invert(n.worldMatrix,t._tempMat42),tL.multiply(t._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}},{key:"worldForward",get:function(){var e=this._worldForward||(this._worldForward=new tT),t=this.worldMatrix.elements;return e.set(-t[8],-t[9],-t[10]),e.normalize()}},{key:"worldRight",get:function(){var e=this._worldRight||(this._worldRight=new tT),t=this.worldMatrix.elements;return e.set(t[0],t[1],t[2]),e.normalize()}},{key:"worldUp",get:function(){var e=this._worldUp||(this._worldUp=new tT),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),t}(ru);rp._tempQuat0=new tF,rp._tempVec30=new tT,rp._tempVec31=new tT,rp._tempVec32=new tT,rp._tempMat30=new tP,rp._tempMat31=new tP,rp._tempMat32=new tP,rp._tempMat41=new tL,rp._tempMat42=new tL,tX([tZ],rp.prototype,"_position",void 0),tX([tZ],rp.prototype,"_rotation",void 0),tX([tZ],rp.prototype,"_rotationQuaternion",void 0),tX([tZ],rp.prototype,"_scale",void 0),tX([tQ],rp.prototype,"_localUniformScaling",void 0),tX([tZ],rp.prototype,"_worldPosition",void 0),tX([tZ],rp.prototype,"_worldRotation",void 0),tX([tZ],rp.prototype,"_worldRotationQuaternion",void 0),tX([tQ],rp.prototype,"_worldUniformScaling",void 0),tX([tZ],rp.prototype,"_lossyWorldScale",void 0),tX([tZ],rp.prototype,"_localMatrix",void 0),tX([tZ],rp.prototype,"_worldMatrix",void 0),tX([tq],rp.prototype,"_worldForward",void 0),tX([tq],rp.prototype,"_worldRight",void 0),tX([tq],rp.prototype,"_worldUp",void 0),tX([tq],rp.prototype,"_isParentDirty",void 0),tX([tq],rp.prototype,"_parentTransformCache",void 0),tX([tq],rp.prototype,"_onPositionChanged",null),tX([tq],rp.prototype,"_onWorldPositionChanged",null),tX([tq],rp.prototype,"_onRotationChanged",null),tX([tq],rp.prototype,"_onWorldRotationChanged",null),tX([tq],rp.prototype,"_onRotationQuaternionChanged",null),tX([tq],rp.prototype,"_onWorldRotationQuaternionChanged",null),tX([tq],rp.prototype,"_onScaleChanged",null);var rm=((z={})[z.LocalEuler=1]="LocalEuler",z[z.LocalQuat=2]="LocalQuat",z[z.WorldPosition=4]="WorldPosition",z[z.WorldEuler=8]="WorldEuler",z[z.WorldQuat=16]="WorldQuat",z[z.WorldScale=32]="WorldScale",z[z.LocalMatrix=64]="LocalMatrix",z[z.WorldMatrix=128]="WorldMatrix",z[z.IsWorldUniformScaling=256]="IsWorldUniformScaling",z[z.WmWp=132]="WmWp",z[z.WmWeWq=152]="WmWeWq",z[z.WmWeWqWs=184]="WmWeWqWs",z[z.WmWpWeWq=156]="WmWpWeWq",z[z.WmWs=160]="WmWs",z[z.WmWsWus=416]="WmWsWus",z[z.WmWpWs=164]="WmWpWs",z[z.WmWpWeWqWs=188]="WmWpWeWqWs",z[z.WmWpWeWqWsWus=444]="WmWpWeWqWsWus",z),rg=((U={})[U.Layer0=1]="Layer0",U[U.Layer1=2]="Layer1",U[U.Layer2=4]="Layer2",U[U.Layer3=8]="Layer3",U[U.Layer4=16]="Layer4",U[U.Layer5=32]="Layer5",U[U.Layer6=64]="Layer6",U[U.Layer7=128]="Layer7",U[U.Layer8=256]="Layer8",U[U.Layer9=512]="Layer9",U[U.Layer10=1024]="Layer10",U[U.Layer11=2048]="Layer11",U[U.Layer12=4096]="Layer12",U[U.Layer13=8192]="Layer13",U[U.Layer14=16384]="Layer14",U[U.Layer15=32768]="Layer15",U[U.Layer16=65536]="Layer16",U[U.Layer17=131072]="Layer17",U[U.Layer18=262144]="Layer18",U[U.Layer19=524288]="Layer19",U[U.Layer20=1048576]="Layer20",U[U.Layer21=2097152]="Layer21",U[U.Layer22=4194304]="Layer22",U[U.Layer23=8388608]="Layer23",U[U.Layer24=0x1000000]="Layer24",U[U.Layer25=0x2000000]="Layer25",U[U.Layer26=0x4000000]="Layer26",U[U.Layer27=0x8000000]="Layer27",U[U.Layer28=0x10000000]="Layer28",U[U.Layer29=0x20000000]="Layer29",U[U.Layer30=0x40000000]="Layer30",U[U.Layer31=0x80000000]="Layer31",U[U.Everything=0xffffffff]="Everything",U[U.Nothing=0]="Nothing",U);e.Renderer=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new nW,r._bounds=new tE,r._maskInteraction=nv.None,r._maskLayer=rg.Layer0,r._batchedTransformShaderData=!1,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new tI,r._shaderData=new rs(n8.Renderer),r._mvMatrix=new tL,r._mvpMatrix=new tL,r._mvInvMatrix=new tL,r._normalMatrix=new tL,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r.castShadows=!0;var r,a=t.prototype,i=r.shaderData;return r._overrideUpdate=r.update!==a.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(r),r._setTransformEntity(n),i.enableMacro(t._receiveShadowMacro),i.setVector4(t._rendererLayerProperty,r._rendererLayer),r}tW(t,e);var n=t.prototype;return n.getInstanceMaterial=function(e){void 0===e&&(e=0);var t=this._materials;if(t.length>e){var n=t[e];if(n)return this._materialsInstanced[e]?n:this._createInstanceMaterial(n,e)}return null},n.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},n.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},n.getInstanceMaterials=function(){for(var e=this._materials,t=this._materialsInstanced,n=0,r=e.length;n<r;n++)t[n]||this._createInstanceMaterial(this._materials[n],n);return e},n.getMaterials=function(){return this._materials},n.setMaterials=function(e){for(var t=e.length,n=this._materials,r=this._materialsInstanced,a=t,i=n.length;a<i;a++){var o=n[a];o&&this._addResourceReferCount(o,-1)}n.length!==t&&(n.length=t),0!==r.length&&(r.length=0);for(var s=0;s<t;s++){var l=n[s],c=e[s];l!==c&&(n[s]=c,l&&this._addResourceReferCount(l,-1),c&&this._addResourceReferCount(c,1))}},n.update=function(e){},n._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},n._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},n._prepareRender=function(e){this._renderFrameCount!==this.engine.time.frameCount&&this._update(e);var n=e.virtualCamera,r=n.position,a=this.bounds.getCenter(t._tempVector0);n.isOrthographic?(tT.subtract(a,r,a),this._distanceForSort=tT.dot(a,n.forward)):this._distanceForSort=tT.distanceSquared(a,r),this._render(e),nW.unionCollection(e.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},n._cloneTo=function(e,t,n){for(var r=this._materials,a=0,i=r.length;a<i;a++)e._setMaterial(a,r[a])},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._setTransformEntity(null),this._addResourceReferCount(this.shaderData,-1);for(var t=this._materials,n=0,r=t.length;n<r;n++){var a=t[n];a&&this._addResourceReferCount(a,-1)}this._entity=null,this._globalShaderMacro=null,this._bounds=null,this._materials=null,this._shaderData=null,this._mvMatrix=null,this._mvpMatrix=null,this._mvInvMatrix=null,this._normalMatrix=null,this._materialsInstanced=null,this._rendererLayer=null},n._updateTransformShaderData=function(e,t,n){var r=this._transformEntity.transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,r,n):this._updateWorldViewRelatedShaderData(e,r,n)},n._canBatch=function(e,t){return!1},n._batch=function(e,t){},n._update=function(e){var t=this.entity.layer;this._rendererLayer.set(65535&t,t>>>16&65535,0,0)},n._updateWorldViewRelatedShaderData=function(e,n,r){var a=this.shaderData,i=this._mvInvMatrix;if(r){var o=tL._identity;tL.invert(e.viewMatrix,i),a.setMatrix(t._localMatrixProperty,o),a.setMatrix(t._worldMatrixProperty,o),a.setMatrix(t._mvMatrixProperty,e.viewMatrix),a.setMatrix(t._mvInvMatrixProperty,i),a.setMatrix(t._normalMatrixProperty,o)}else{var s=this._mvMatrix,l=this._normalMatrix;tL.multiply(e.viewMatrix,n,s),tL.invert(s,i),tL.invert(n,l),l.transpose(),a.setMatrix(t._localMatrixProperty,this._transformEntity.transform.localMatrix),a.setMatrix(t._worldMatrixProperty,n),a.setMatrix(t._mvMatrixProperty,s),a.setMatrix(t._mvInvMatrixProperty,i),a.setMatrix(t._normalMatrixProperty,l)}this._updateProjectionRelatedShaderData(e,n,r)},n._updateProjectionRelatedShaderData=function(e,n,r){if(r)this.shaderData.setMatrix(t._mvpMatrixProperty,e.viewProjectionMatrix);else{var a=this._mvpMatrix;tL.multiply(e.viewProjectionMatrix,n,a),this.shaderData.setMatrix(t._mvpMatrixProperty,a)}},n._setTransformEntity=function(e){var t=this._transformEntity;e!==t&&(null==t||t._updateFlagManager.removeListener(this._onTransformChanged),null==e||e._updateFlagManager.addListener(this._onTransformChanged),this._transformEntity=e)},n._updateBounds=function(e){},n._render=function(e){throw"not implement"},n._createInstanceMaterial=function(e,t){var n=e.clone();return n.name=n.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(n,1),this._materialsInstanced[t]=!0,this._materials[t]=n,n},n._setMaterial=function(e,t){var n=this._materials;e>=n.length&&(n.length=e+1);var r=n[e];if(r!==t){var a=this._materialsInstanced;e<a.length&&(a[e]=!1),r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),n[e]=t}},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},tG(t,[{key:"shaderData",get:function(){return this._shaderData}},{key:"isCulled",get:function(){return!(void 0===this._renderFrameCount||this._renderFrameCount===this._engine.time.frameCount-1)}},{key:"receiveShadows",get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(e?this.shaderData.enableMacro(t._receiveShadowMacro):this.shaderData.disableMacro(t._receiveShadowMacro),this._receiveShadows=e)}},{key:"materialCount",get:function(){return this._materials.length},set:function(e){var t=this._materials,n=this._materialsInstanced;t.length!==e&&(t.length=e),n.length>e&&(n.length=e)}},{key:"bounds",get:function(){return 1&this._dirtyUpdateFlag&&(this._updateBounds(this._bounds),this._dirtyUpdateFlag&=-2),this._bounds}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}}]),t}(ru),e.Renderer._tempVector0=new tT,e.Renderer._receiveShadowMacro=nH.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e.Renderer._localMatrixProperty=nY.getByName("renderer_LocalMat"),e.Renderer._worldMatrixProperty=nY.getByName("renderer_ModelMat"),e.Renderer._mvMatrixProperty=nY.getByName("renderer_MVMat"),e.Renderer._mvpMatrixProperty=nY.getByName("renderer_MVPMat"),e.Renderer._mvInvMatrixProperty=nY.getByName("renderer_MVInvMat"),e.Renderer._normalMatrixProperty=nY.getByName("renderer_NormalMat"),e.Renderer._rendererLayerProperty=nY.getByName("renderer_Layer"),tX([tq],e.Renderer.prototype,"_distanceForSort",void 0),tX([tq],e.Renderer.prototype,"_onUpdateIndex",void 0),tX([tq],e.Renderer.prototype,"_rendererIndex",void 0),tX([tq],e.Renderer.prototype,"_globalShaderMacro",void 0),tX([tq],e.Renderer.prototype,"_bounds",void 0),tX([tq],e.Renderer.prototype,"_renderFrameCount",void 0),tX([tQ],e.Renderer.prototype,"_maskInteraction",void 0),tX([tQ],e.Renderer.prototype,"_maskLayer",void 0),tX([tq],e.Renderer.prototype,"_batchedTransformShaderData",void 0),tX([tq],e.Renderer.prototype,"_transformEntity",void 0),tX([tq],e.Renderer.prototype,"_overrideUpdate",void 0),tX([tq],e.Renderer.prototype,"_materials",void 0),tX([tq],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),tX([tq],e.Renderer.prototype,"_rendererLayer",void 0),tX([tZ],e.Renderer.prototype,"_shaderData",void 0),tX([tq],e.Renderer.prototype,"_mvMatrix",void 0),tX([tq],e.Renderer.prototype,"_mvpMatrix",void 0),tX([tq],e.Renderer.prototype,"_mvInvMatrix",void 0),tX([tq],e.Renderer.prototype,"_normalMatrix",void 0),tX([tq],e.Renderer.prototype,"_materialsInstanced",void 0),tX([tQ],e.Renderer.prototype,"_priority",void 0),tX([tQ],e.Renderer.prototype,"_receiveShadows",void 0),tX([tq],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=tX([rh(rp,r_.CheckOnly)],e.Renderer);var rv=((G={})[G.WorldVolume=1]="WorldVolume",G);function ry(){return function(e){}}var rx=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var a=n.allocateSubChunk(4);a.indices=e._rectangleTriangles,t._subChunk=a},e.updatePositions=function(t){var n=t.width,r=t.height,a=t.sprite,i=a.pivot,o=i.x,s=i.y,l=e._worldMatrix,c=l.elements,u=t.entity.transform.worldMatrix.elements,d=t.flipX?-n:n,h=t.flipY?-r:r;c[0]=u[0]*d,c[1]=u[1]*d,c[2]=u[2]*d,c[4]=u[4]*h,c[5]=u[5]*h,c[6]=u[6]*h,c[8]=u[8],c[9]=u[9],c[10]=u[10],c[12]=u[12]-o*c[0]-s*c[4],c[13]=u[13]-o*c[1]-s*c[5],c[14]=u[14]-o*c[2]-s*c[6];for(var _=a._getPositions(),f=t._subChunk,p=f.chunk.vertices,m=0,g=f.vertexArea.start;m<4;++m,g+=9){var v=_[m],y=v.x,x=v.y;p[g]=c[0]*y+c[4]*x+c[12],p[g+1]=c[1]*y+c[5]*x+c[13],p[g+2]=c[2]*y+c[6]*x+c[14]}tE.transform(a._getBounds(),l,t._bounds)},e.updateUVs=function(e){var t=e.sprite._getUVs(),n=t[0],r=n.x,a=n.y,i=t[3],o=i.x,s=i.y,l=e._subChunk,c=l.chunk.vertices,u=l.vertexArea.start+3;c[u]=r,c[u+1]=a,c[u+9]=o,c[u+10]=a,c[u+18]=r,c[u+19]=s,c[u+27]=o,c[u+28]=s},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<4;++l,c+=9)s[c]=r,s[c+1]=a,s[c+2]=i,s[c+3]=o},e}();rx._rectangleTriangles=[0,1,2,2,1,3],rx._worldMatrix=new tL,rx=tX([ry()],rx);var rb=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var a=n.allocateSubChunk(16);a.indices=e._rectangleTriangles,t._subChunk=a},e.updatePositions=function(t){var n,r,a=t.width,i=t.height,o=t.sprite,s=o.border,l=o._getPositions(),c=l[0],u=c.x,d=c.y,h=l[3],_=h.x,f=h.y,p=o.width,m=o.height,g=p*s.x,v=m*s.y,y=p*s.z,x=m*s.w;if(g+y>a){var b=a/(g+y);n=[p*u*b,g*b,g*b,a-p*(1-_)*b]}else n=[p*u,g,a-y,a-p*(1-_)];if(x+v>i){var C=i/(x+v);r=[m*d*C,v*C,v*C,i-m*(1-f)*C]}else r=[m*d,v,i-x,i-m*(1-f)];var S=t.sprite.pivot,T=S.x,A=S.y,E=t.width*T,R=t.height*A,M=e._worldMatrix,w=M.elements,P=t.entity.transform.worldMatrix.elements,F=t.flipX?-1:1,L=t.flipY?-1:1;w[0]=P[0]*F,w[1]=P[1]*F,w[2]=P[2]*F,w[4]=P[4]*L,w[5]=P[5]*L,w[6]=P[6]*L,w[8]=P[8],w[9]=P[9],w[10]=P[10],w[12]=P[12]-E*w[0]-R*w[4],w[13]=P[13]-E*w[1]-R*w[5],w[14]=P[14]-E*w[2]-R*w[6];for(var D=t._subChunk,B=D.chunk.vertices,I=0,O=D.vertexArea.start;I<4;I++)for(var N=n[I],V=0;V<4;V++,O+=9){var k=r[V];B[O]=w[0]*N+w[4]*k+w[12],B[O+1]=w[1]*N+w[5]*k+w[13],B[O+2]=w[2]*N+w[6]*k+w[14]}var z=t._bounds,U=z.min,G=z.max;U.set(n[0],r[0],0),G.set(n[3],r[3],0),t._bounds.transform(M)},e.updateUVs=function(e){for(var t=e._subChunk,n=t.chunk.vertices,r=e.sprite._getUVs(),a=0,i=t.vertexArea.start+3;a<4;a++)for(var o=r[a].x,s=0;s<4;s++,i+=9)n[i]=o,n[i+1]=r[s].y},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<16;++l,c+=9)s[c]=r,s[c+1]=a,s[c+2]=i,s[c+3]=o},e}();rb._rectangleTriangles=[0,1,4,1,5,4,1,2,5,2,6,5,2,3,6,3,7,6,4,5,8,5,9,8,5,6,9,6,10,9,6,7,10,7,11,10,8,9,12,9,13,12,9,10,13,10,14,13,10,11,14,11,15,14],rb._worldMatrix=new tL,rb=tX([ry()],rb);var rC=/*#__PURE__*/function(){function e(e){void 0===e&&(e=0),this.length=0,this._loopCounter=0,this._blankCount=0,this._elements=Array(e)}var t=e.prototype;return t.add=function(e){this.length===this._elements.length?this._elements.push(e):this._elements[this.length]=e,this.length++},t.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},t.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},t.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},t.deleteByIndex=function(e){var t,n=this._elements;if(this._loopCounter>0)this._elements[e]=null,this._blankCount++;else{var r=this.length-1;e!==r&&(t=n[r],n[e]=t),n[r]=null,this.length--}return t},t.forEach=function(e,t){this._startLoop();for(var n=this._elements,r=0,a=this.length;r<a;r++){var i=n[r];i&&e(i,r)}this._endLoop(t)},t.forEachAndClean=function(e,t){this._startLoop();for(var n=this.length,r=this._elements,a=0;a<n;a++){var i=r[a];i&&e(i,a)}this._endLoopAndClean(n,r,t)},t.sort=function(e){nT._quickSort(this._elements,0,this.length,e)},t.garbageCollection=function(){this._elements.length=this.length},t._startLoop=function(){++this._loopCounter},t._endLoop=function(e){if(0==--this._loopCounter&&this._blankCount){var t=0,n=this.length-1,r=this._elements;e:do{for(;r[t];)if(++t>=n)break e;for(;!r[n];)if(t>=--n)break e;var a=r[n];null==e||e(a,t),r[t++]=a,r[n--]=null}while(t<n);this.length-=this._blankCount,this._blankCount=0}},t._endLoopAndClean=function(e,t,n){if(0==--this._loopCounter){for(var r=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[r]=o,null==n||n(o,r),r++)}this.length=r,this._blankCount=0}},tG(e,[{key:"isLopping",get:function(){return this._loopCounter>0}}]),e}(),rS=/*#__PURE__*/function(){function e(){}return e.resetData=function(e,t){if(t){var n=e._getChunkManager(),r=e._subChunk,a=r&&r.vertexArea.size!==9*t;if(a&&n.freeSubChunk(r),!r||a){var i=n.allocateSubChunk(t);i.indices=[],e._subChunk=i}}},e.updatePositions=function(t){var n,r,a,i,o,s,l=t.width,c=t.height,u=t.sprite,d=t.tileMode,h=t.tiledAdaptiveThreshold,_=e._posRow,f=e._posColumn,p=e._uvRow,m=e._uvColumn,g=t._getChunkManager().maxVertexCount;_.length=f.length=p.length=m.length=0;var v=d===nS.Adaptive?e._calculateAdaptiveDividing(u,l,c,h,_,f,p,m,g):e._calculateContinuousDividing(u,l,c,_,f,p,m,g);e.resetData(t,v);var y=t.sprite.pivot,x=y.x,b=y.y,C=t.width*x,S=t.height*b,T=e._worldMatrix,A=T.elements,E=t.entity.transform.worldMatrix.elements,R=t.flipX?-1:1,M=t.flipY?-1:1;n=A[0]=E[0]*R,r=A[1]=E[1]*R,a=A[2]=E[2]*R,i=A[4]=E[4]*M,o=A[5]=E[5]*M,s=A[6]=E[6]*M,A[8]=E[8],A[9]=E[9],A[10]=E[10];for(var w=A[12]=E[12]-C*A[0]-S*A[4],P=A[13]=E[13]-C*A[1]-S*A[5],F=A[14]=E[14]-C*A[2]-S*A[6],L=_.length-1,D=f.length-1,B=t._subChunk,I=B.chunk.vertices,O=B.indices,N=0,V=0,k=0,z=B.vertexArea.start;k<D;k++)for(var U=2*k,G=0;G<L;G++){var H=p.get(2*G),W=p.get(2*G+1),j=m.get(U+1);if(!(isNaN(H)||isNaN(W)||isNaN(j))){O[V++]=N,O[V++]=N+1,O[V++]=N+2,O[V++]=N+2,O[V++]=N+1,O[V++]=N+3,N+=4;var X=_.get(G),K=f.get(k),Y=_.get(G+1),q=f.get(k+1);I[z]=n*X+i*K+w,I[z+1]=r*X+o*K+P,I[z+2]=a*X+s*K+F,I[z+9]=n*Y+i*K+w,I[z+10]=r*Y+o*K+P,I[z+11]=a*Y+s*K+F,I[z+18]=n*X+i*q+w,I[z+19]=r*X+o*q+P,I[z+20]=a*X+s*q+F,I[z+27]=n*Y+i*q+w,I[z+28]=r*Y+o*q+P,I[z+29]=a*Y+s*q+F,z+=36}}var Q=t._bounds,J=Q.min,Z=Q.max;J.set(_.get(0),f.get(0),0),Z.set(_.get(L),f.get(D),0),t._bounds.transform(T)},e.updateUVs=function(t){for(var n=e._posRow,r=e._posColumn,a=e._uvRow,i=e._uvColumn,o=n.length-1,s=r.length-1,l=t._subChunk,c=l.chunk.vertices,u=0,d=l.vertexArea.start+3;u<s;u++)for(var h=2*u,_=0;_<o;_++){var f=a.get(2*_),p=i.get(h),m=a.get(2*_+1),g=i.get(h+1);isNaN(f)||isNaN(p)||isNaN(m)||isNaN(g)||(c[d]=f,c[d+1]=p,c[d+9]=m,c[d+10]=p,c[d+18]=f,c[d+19]=g,c[d+27]=m,c[d+28]=g,d+=36)}},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=t.vertexArea,c=0,u=l.start+5,d=l.size/9;c<d;++c,u+=9)s[u]=r,s[u+1]=a,s[u+2]=i,s[u+3]=o},e._calculateAdaptiveDividing=function(e,t,n,r,a,i,o,s,l){var c,u,d,h,_,f,p,m=e.border,g=e._getPositions(),v=g[0],y=v.x,x=v.y,b=g[3],C=b.x,S=b.y,T=e._getUVs(),A=T[0],E=T[1],R=T[2],M=T[3],w=e.width,P=e.height,F=w*m.x,L=w*m.z,D=F+L,B=w-D,I=P*m.w,O=P*m.y,N=I+O,V=P-N;D>=t?(h=3,u=0):B>tS.zeroTolerance?(h=4+(f=(f=(t-D)/B)%1>=r?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),N>=n?(_=3,d=0):V>tS.zeroTolerance?(_=4+(p=(p=(n-N)/V)%1>=r?Math.ceil(p):Math.floor(p))-1,d=2):(_=4,d=1);var k=0,z=0;if((h-1)*(_-1)*4>l)return a.add(t*y),a.add(t*C),i.add(n*x),i.add(n*S),o.add(A.x),o.add(M.x),s.add(A.y),s.add(M.y),k+=2,z+=2,no.warn("The number of vertices exceeds the upper limit("+l+")."),k*z;switch(u){case 0:c=t/D,a.add(w*y*c),a.add(F*c),a.add(t-w*(1-C)*c),o.add(A.x),o.add(E.x),o.add(R.x),o.add(M.x),k+=4;break;case 1:a.add(w*y),a.add(F),a.add(t-L),a.add(t-w*(1-C)),o.add(A.x),o.add(E.x),o.add(NaN),o.add(NaN),o.add(R.x),o.add(M.x),k+=4;break;case 2:c=t/(D+f*B),a.add(w*y*c),a.add(F*c),o.add(A.x),o.add(E.x),o.add(E.x),k+=3;for(var U=0,G=f-1;U<G;U++)a.add(F+(U+1)*B*c),o.add(R.x),o.add(E.x),k+=2;a.add(t-L*c),a.add(t-w*(1-C)*c),o.add(R.x),o.add(R.x),o.add(M.x),k+=3}switch(d){case 0:c=n/N,i.add(P*x*c),i.add(O*c),i.add(n-P*(1-S)*c),s.add(A.y),s.add(E.y),s.add(R.y),s.add(M.y),z+=4;break;case 1:i.add(P*x),i.add(O),i.add(n-I),i.add(n-P*(1-S)),s.add(A.y),s.add(E.y),s.add(NaN),s.add(NaN),s.add(R.y),s.add(M.y),z+=4;break;case 2:c=n/(N+p*V),i.add(P*x*c),i.add(O*c),s.add(A.y),s.add(E.y),s.add(E.y),z+=3;for(var H=0,W=p-1;H<W;H++)i.add(O+(H+1)*V*c),s.add(R.y),s.add(E.y),z+=2;i.add(n-I*c),i.add(n-P*(1-S)*c),s.add(R.y),s.add(R.y),s.add(M.y),z+=3}return k*z},e._calculateContinuousDividing=function(e,t,n,r,a,i,o,s){var l,c,u,d,h,_,f=e.border,p=e._getPositions(),m=p[0],g=m.x,v=m.y,y=p[3],x=y.x,b=y.y,C=e._getUVs(),S=C[0],T=C[1],A=C[2],E=C[3],R=e.width,M=e.height,w=R*f.x,P=R*f.z,F=w+P,L=R-F,D=M*f.w,B=M*f.y,I=D+B,O=M-I;F>=t?(u=3,l=0):L>tS.zeroTolerance?(u=4+(0|(h=(t-F)/L)),l=2):(u=4,l=1),I>=n?(d=3,c=0):O>tS.zeroTolerance?(d=4+(0|(_=(n-I)/O)),c=2):(d=4,c=1);var N=0,V=0;if((u-1)*(d-1)*4>s)return r.add(t*g),r.add(t*x),a.add(n*v),a.add(n*b),i.add(S.x),i.add(E.x),o.add(S.y),o.add(E.y),N+=2,V+=2,no.warn("The number of vertices exceeds the upper limit("+s+")."),N*V;switch(l){case 0:var k=t/F;r.add(R*g*k),r.add(w*k),r.add(t-R*(1-x)*k),i.add(S.x),i.add(T.x),i.add(A.x),i.add(E.x),N+=4;break;case 1:r.add(R*g),r.add(w),r.add(t-P),r.add(t-R*(1-x)),i.add(S.x),i.add(T.x),i.add(NaN),i.add(NaN),i.add(A.x),i.add(E.x),N+=4;break;case 2:r.add(R*g),r.add(w),i.add(S.x),i.add(T.x),i.add(T.x),N+=3;for(var z=0|h,U=0;U<z;U++)r.add(w+(U+1)*L),i.add(A.x),i.add(T.x),N+=2;r.add(t-P),r.add(t-R*(1-x)),i.add((A.x-T.x)*(h-z)+T.x),i.add(A.x),i.add(E.x),N+=3}switch(c){case 0:var G=n/I;a.add(M*v*G),a.add(B*G),a.add(n-M*(1-b)*G),o.add(S.y),o.add(T.y),o.add(A.y),o.add(E.y),V+=4;break;case 1:a.add(M*v),a.add(B),a.add(n-D),a.add(n-M*(1-b)),o.add(S.y),o.add(T.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(E.y),V+=4;break;case 2:a.add(M*v),a.add(B),o.add(S.y),o.add(T.y),o.add(T.y),V+=3;for(var H=0|_,W=0;W<H;W++)a.add(B+(W+1)*O),o.add(A.y),o.add(T.y),V+=2;a.add(n-D),a.add(n-M*(1-b)),o.add((A.y-T.y)*(_-H)+T.y),o.add(A.y),o.add(E.y),V+=3}return N*V},e}();rS._worldMatrix=new tL,rS._posRow=new rC,rS._posColumn=new rC,rS._uvRow=new rC,rS._uvColumn=new rC,rS=tX([ry()],rS);var rT=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._tileMode=nS.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new tO(1,1,1,1),n._sprite=null,n._automaticWidth=0,n._automaticHeight=0,n._customWidth=void 0,n._customHeight=void 0,n._flipX=!1,n._flipY=!1,n.drawMode=nC.Simple,n._dirtyUpdateFlag|=4,n.setMaterial(n._engine._basicResources.spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(n),n._color._onValueChanged=n._onColorChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t._assembler.resetData(t),t.sprite=this._sprite,t.drawMode=this._drawMode},n._canBatch=function(e,t){return rl.canBatchSprite(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},n._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,n=this.getMaterial();if(n){n.destroyed&&(n=this._engine._basicResources.spriteDefaultMaterial),this._dirtyUpdateFlag&rv.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~rv.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3),4&this._dirtyUpdateFlag&&(this._assembler.updateColor(this),this._dirtyUpdateFlag&=-5);var r=e.camera,a=r.engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get(),s=this._subChunk;o.set(this,n,s.chunk.primitive,s.subMesh,this.sprite.texture,s),i.addSubRenderElement(o),r._renderPipeline.pushRenderElement(e,i)}}},n._onDestroy=function(){var t=this._sprite;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),e.prototype._onDestroy.call(this),this._sprite=null,this._assembler=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null)},n._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-9},n._onSpriteChange=function(e){switch(e){case nw.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nw.size:var n=this._drawMode;this._dirtyUpdateFlag|=8,this._drawMode===nC.Sliced?this._dirtyUpdateFlag|=rv.WorldVolume:n===nC.Tiled?this._dirtyUpdateFlag|=rA.WorldVolumeAndUV:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rv.WorldVolume);break;case nw.border:this._drawMode===nC.Sliced&&(this._dirtyUpdateFlag|=rA.WorldVolumeAndUV);break;case nw.region:case nw.atlasRegionOffset:this._dirtyUpdateFlag|=rA.WorldVolumeAndUV;break;case nw.atlasRegion:this._dirtyUpdateFlag|=2;break;case nw.pivot:this._dirtyUpdateFlag|=rv.WorldVolume;break;case nw.destroy:this.sprite=null}},n._onColorChanged=function(){this._dirtyUpdateFlag|=4},tG(t,[{key:"drawMode",get:function(){return this._drawMode},set:function(e){if(this._drawMode!==e){switch(this._drawMode=e,e){case nC.Simple:this._assembler=rx;break;case nC.Sliced:this._assembler=rb;break;case nC.Tiled:this._assembler=rS}this._assembler.resetData(this),this._dirtyUpdateFlag|=rA.VertexData}}},{key:"tileMode",get:function(){return this._tileMode},set:function(e){this._tileMode!==e&&(this._tileMode=e,this.drawMode===nC.Tiled&&(this._dirtyUpdateFlag|=rA.VertexData))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(e){e!==this._tiledAdaptiveThreshold&&(e=tS.clamp(e,0,1),this._tiledAdaptiveThreshold=e,this.drawMode===nC.Tiled&&(this._dirtyUpdateFlag|=rA.VertexData))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var n=this._sprite;n!==e&&(n&&(this._addResourceReferCount(n,-1),n._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=15,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(t._textureProperty,e.texture)):this.shaderData.setTexture(t._textureProperty,null),this._sprite=e)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=this._drawMode===nC.Tiled?rA.VertexData:rv.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=this._drawMode===nC.Tiled?rA.VertexData:rv.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e)}}]),t}(e.Renderer);rT._textureProperty=nY.getByName("renderer_SpriteTexture"),tX([tq],rT.prototype,"_subChunk",void 0),tX([tq],rT.prototype,"_drawMode",void 0),tX([tQ],rT.prototype,"_assembler",void 0),tX([tQ],rT.prototype,"_tileMode",void 0),tX([tQ],rT.prototype,"_tiledAdaptiveThreshold",void 0),tX([tZ],rT.prototype,"_color",void 0),tX([tq],rT.prototype,"_sprite",void 0),tX([tq],rT.prototype,"_automaticWidth",void 0),tX([tq],rT.prototype,"_automaticHeight",void 0),tX([tQ],rT.prototype,"_customWidth",void 0),tX([tQ],rT.prototype,"_customHeight",void 0),tX([tQ],rT.prototype,"_flipX",void 0),tX([tQ],rT.prototype,"_flipY",void 0),tX([tq],rT.prototype,"_onSpriteChange",null),tX([tq],rT.prototype,"_onColorChanged",null);var rA=((H=rA||{})[H.UV=2]="UV",H[H.Color=4]="Color",H[H.AutomaticSize=8]="AutomaticSize",H[H.WorldVolumeAndUV=2|rv.WorldVolume]="WorldVolumeAndUV",H[H.VertexData=4|H.WorldVolumeAndUV]="VertexData",H[H.All=15]="All",H),rE=((W={})[W.Layer0=1]="Layer0",W[W.Layer1=2]="Layer1",W[W.Layer2=4]="Layer2",W[W.Layer3=8]="Layer3",W[W.Layer4=16]="Layer4",W[W.Layer5=32]="Layer5",W[W.Layer6=64]="Layer6",W[W.Layer7=128]="Layer7",W[W.Layer8=256]="Layer8",W[W.Layer9=512]="Layer9",W[W.Layer10=1024]="Layer10",W[W.Layer11=2048]="Layer11",W[W.Layer12=4096]="Layer12",W[W.Layer13=8192]="Layer13",W[W.Layer14=16384]="Layer14",W[W.Layer15=32768]="Layer15",W[W.Layer16=65536]="Layer16",W[W.Layer17=131072]="Layer17",W[W.Layer18=262144]="Layer18",W[W.Layer19=524288]="Layer19",W[W.Layer20=1048576]="Layer20",W[W.Layer21=2097152]="Layer21",W[W.Layer22=4194304]="Layer22",W[W.Layer23=8388608]="Layer23",W[W.Layer24=0x1000000]="Layer24",W[W.Layer25=0x2000000]="Layer25",W[W.Layer26=0x4000000]="Layer26",W[W.Layer27=0x8000000]="Layer27",W[W.Layer28=0x10000000]="Layer28",W[W.Layer29=0x20000000]="Layer29",W[W.Layer30=0x40000000]="Layer30",W[W.Layer31=0x80000000]="Layer31",W[W.Everything=0xffffffff]="Everything",W[W.Nothing=0]="Nothing",W),rR=/*#__PURE__*/function(){function e(){}return e.recreateTextureIfNeeded=function(e,t,n,r,a,i,o,s){return t?(t.width!==n||t.height!==r||t.format!==a||t.mipmapCount>1!==i)&&(t.destroy(!0),(t=new nc(e,n,r,a,i)).isGCIgnored=!0):(t=new nc(e,n,r,a,i)).isGCIgnored=!0,t.wrapModeU=t.wrapModeV=o,t.filterMode=s,t},e.recreateRenderTargetIfNeeded=function(t,n,r,a,i,o,s,l,c,u,d){var h=null==n?void 0:n.getColorTexture(0),_=i?e.recreateTextureIfNeeded(t,h,r,a,i,l,u,d):null;if(s){var f=null==n?void 0:n.depthTexture,p=o?e.recreateTextureIfNeeded(t,f,r,a,o,l,u,d):null;(h!==_||f!==p)&&(null==n||n.destroy(!0),(n=new nl(t,r,a,_,p,c)).isGCIgnored=!0)}else(h!==_||(null==n?void 0:n._depthFormat)!==o||n.antiAliasing!==c)&&(null==n||n.destroy(!0),(n=new nl(t,r,a,_,o,c)).isGCIgnored=!0);return n},e.blitTexture=function(t,n,r,a,i,o,s,l){void 0===a&&(a=0),void 0===i&&(i=e.defaultViewport),void 0===o&&(o=null),void 0===s&&(s=0),void 0===l&&(l=!1);var c=t._basicResources,u=r?c.flipYBlitMesh:c.blitMesh,d=o||c.blitMaterial,h=t._hardwareRenderer,_=t._renderContext;_.flipProjection=!!r,h.activeRenderTarget(r,i,_.flipProjection,0);var f=e._rendererShaderData;f.setTexture(e._blitTextureProperty,n),f.setFloat(e._blitMipLevelProperty,a),e._texelSize.set(1/n.width,1/n.height,n.width,n.height),f.setVector4(e._blitTexelSizeProperty,e._texelSize),l?f.enableMacro(e._flipYTextureMacro):f.disableMacro(e._flipYTextureMacro);var p=d.shader.subShaders[0].passes[s],m=ro._compileMacros;nW.unionCollection(_.camera._globalShaderMacro,f._macroCollection,m),nW.unionCollection(m,d.shaderData._macroCollection,m);var g=p._getShaderProgram(t,m);g.bind(),g.groupingOtherUniformBlock(),g.uploadAll(g.rendererUniformBlock,f),g.uploadAll(g.materialUniformBlock,d.shaderData),g.uploadUnGroupTextures(),(p._renderState||d.renderState)._applyStates(t,!1,p._renderStateDataMap,d.shaderData),h.drawPrimitive(u._primitive,u.subMesh,g)},e}();rR._blitTextureProperty=nY.getByName("renderer_BlitTexture"),rR._blitMipLevelProperty=nY.getByName("renderer_BlitMipLevel"),rR._blitTexelSizeProperty=nY.getByName("renderer_texelSize"),rR._flipYTextureMacro=nH.getByName("renderer_FlipYBlitTexture"),rR._rendererShaderData=new rs(n8.Renderer),rR._texelSize=new tI,rR.defaultViewport=new tI(0,0,1,1);var rM=function(){this.position=new tT,this.isOrthographic=!1,this.viewMatrix=new tL,this.projectionMatrix=new tL,this.viewProjectionMatrix=new tL,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new tT},rw=((j={})[j.None=0]="None",j[j.Color=1]="Color",j[j.Depth=2]="Depth",j[j.Stencil=4]="Stencil",j[j.ColorDepth=3]="ColorDepth",j[j.ColorStencil=5]="ColorStencil",j[j.DepthStencil=6]="DepthStencil",j[j.All=7]="All",j),rP=((X={})[X.Normal=0]="Normal",X[X.XRCenterCamera=1]="XRCenterCamera",X[X.XRLeftCamera=2]="XRLeftCamera",X[X.XRRightCamera=4]="XRRightCamera",X),rF=((K={})[K.None=0]="None",K[K.PrePass=1]="PrePass",K),rL=((Y={})[Y.None=1]="None",Y[Y.TwoX=2]="TwoX",Y[Y.FourX=4]="FourX",Y),rD=((q={})[q.None=1]="None",q[q.TwoX=2]="TwoX",q[q.FourX=4]="FourX",q[q.EightX=8]="EightX",q),rB=((Q={})[Q.KeepOriginalShader=0]="KeepOriginalShader",Q[Q.DoNotRender=1]="DoNotRender",Q),rI=function(){};rI.tempVec4=new tI,rI.tempVec3=new tT,rI.tempVec2=new tB,e.Camera=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableFrustumCulling=!0,n.clearFlags=rw.All,n.cullingMask=rE.Everything,n.depthTextureMode=rF.None,n.opaqueTextureDownsampling=rL.TwoX,n.msaaSamples=rD.None,n._cameraType=rP.Normal,n._globalShaderMacro=new nW,n._frustum=new tw,n._virtualCamera=new rM,n._replacementShader=null,n._replacementSubShaderTag=null,n._replacementFailureStrategy=null,n._cameraIndex=-1,n._priority=0,n._shaderData=new rs(n8.Camera),n._isCustomViewMatrix=!1,n._isCustomProjectionMatrix=!1,n._fieldOfView=45,n._orthographicSize=10,n._isProjectionDirty=!0,n._isInvProjMatDirty=!0,n._customAspectRatio=void 0,n._renderTarget=null,n._depthBufferParams=new tI,n._opaqueTextureEnabled=!1,n._enableHDR=!1,n._enablePostProcess=!1,n._viewport=new tI(0,0,1,1),n._pixelViewport=new tN(0,0,0,0),n._inverseProjectionMatrix=new tL,n._invViewProjMat=new tL,n._isViewMatrixDirty=t.registerWorldChangeFlag(),n._isInvViewProjDirty=t.registerWorldChangeFlag(),n._frustumChangeFlag=t.registerWorldChangeFlag(),n._renderPipeline=new rZ(n),n._addResourceReferCount(n.shaderData,1),n._updatePixelViewport(),n._onPixelViewportChanged=n._onPixelViewportChanged.bind(n),n._viewport._onValueChanged=n._onPixelViewportChanged,n.engine.canvas._sizeUpdateFlagManager.addListener(n._onPixelViewportChanged),n}tW(t,e);var n=t.prototype;return n.resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},n.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},n.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},n.worldToViewportPoint=function(e,t){var n=rI.tempVec3,r=rI.tempVec4;tT.transformCoordinate(e,this.viewMatrix,n),tT.transformToVec4(n,this.projectionMatrix,r);var a=r.w;return t.set((r.x/a+1)*.5,(1-r.y/a)*.5,-n.z),t},n.viewportToWorldPoint=function(e,t){var n,r=this.nearClipPlane,a=this.farClipPlane,i=1/(r-a);if(this.isOrthographic)n=-(2*e.z)*i+(a+r)*i;else{var o=e.z;n=(-o*(r+a)*i+2*r*a*i)/o}return this._innerViewportToWorldPoint(e.x,e.y,(n+1)/2,this._getInvViewProjMat(),t),t},n.viewportPointToRay=function(e,t){var n=this._getInvViewProjMat(),r=this._innerViewportToWorldPoint(e.x,e.y,0,n,t.origin),a=this._innerViewportToWorldPoint(e.x,e.y,1-tS.zeroTolerance,n,t.direction);return tT.subtract(a,r,a),a.normalize(),t},n.screenToViewportPoint=function(e,t){var n=this.engine.canvas,r=this.viewport;return t.x=(e.x/n.width-r.x)/r.z,t.y=(e.y/n.height-r.y)/r.w,void 0!==e.z&&(t.z=e.z),t},n.viewportToScreenPoint=function(e,t){var n=this.engine.canvas,r=this.viewport;return t.x=(r.x+e.x*r.z)*n.width,t.y=(r.y+e.y*r.w)*n.height,void 0!==e.z&&(t.z=e.z),t},n.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},n.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},n.screenPointToRay=function(e,t){var n=rI.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},n.render=function(e,t){void 0===t&&(t=0);var n,r=this._engine,a=r._renderContext,i=this._virtualCamera,o=this._entity.transform;tL.multiply(this.projectionMatrix,this.viewMatrix,i.viewProjectionMatrix),i.position.copyFrom(o.worldPosition),i.isOrthographic&&i.forward.copyFrom(o.worldForward),a.camera=this,a.virtualCamera=i,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,a.replacementFailureStrategy=this._replacementFailureStrategy,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(i.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),nW.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!r._hardwareRenderer.isWebGL2&&(t=0,no.error("mipLevel only take effect in WebGL2.0")),this._cameraType===rP.Normal||this._renderTarget||this.independentCanvasEnabled||(n=r.xrManager._getCameraIgnoreClearFlags(this._cameraType)),this._renderPipeline.render(a,e,t,n),r._renderCount++},n.setReplacementShader=function(e,t,n){void 0===n&&(n=rB.KeepOriginalShader),this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?n0.getByName(t):t,this._replacementFailureStrategy=n},n.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null,this._replacementFailureStrategy=null},n._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},n._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},n._getInternalColorTextureFormat=function(){return this._enableHDR?this.engine._hardwareRenderer.isWebGL2?t9.R11G11B10_UFloat:t9.R16G16B16A16:t9.R8G8B8A8},n._onDestroy=function(){var t;e.prototype._onDestroy.call(this),null==(t=this._renderPipeline)||t.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},n._updatePixelViewport=function(){var e,t,n=this._renderTarget;if(n)e=n.width,t=n.height;else{var r=this.engine.canvas;e=r.width,t=r.height}var a=this._viewport;this._pixelViewport.set(a.x*e,a.y*t,a.z*e,a.w*t)},n._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},n._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},n._innerViewportToWorldPoint=function(e,t,n,r,a){var i=rI.tempVec3;return i.set(2*e-1,1-2*t,2*n-1),tT.transformCoordinate(i,r,a),a},n._updateShaderData=function(){var e=this.shaderData,n=this._entity.transform;e.setMatrix(t._inverseViewMatrixProperty,n.worldMatrix),e.setVector3(t._cameraPositionProperty,n.worldPosition),e.setVector3(t._cameraForwardProperty,n.worldForward),e.setVector3(t._cameraUpProperty,n.worldUp);var r=this._depthBufferParams,a=this.farClipPlane/this.nearClipPlane;r.set(1-a,a,0,0),e.setVector4(t._cameraDepthBufferParamsProperty,r)},n._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,tL.multiply(this._entity.transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},n._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,tL.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},n._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},n._checkMainCanvasAntialiasWaste=function(){this._phasedActiveInScene&&this.independentCanvasEnabled&&tI.equals(this._viewport,rR.defaultViewport)&&no.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},tG(t,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){if(this.enablePostProcess&&this.scene._postProcessManager.hasActiveEffect)return!0;if(this.enableHDR||this.opaqueTextureEnabled){var e;return this._getInternalColorTextureFormat()!==(null==(e=this.renderTarget)?void 0:e.getColorTexture(0).format)}return!1}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e,t=this.pixelViewport;return null!=(e=this._customAspectRatio)?e:t.width/t.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var t=this._entity.transform;return tL.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return t;this._isProjectionDirty=!1;var n=this.aspectRatio;if(e.isOrthographic){var r=this._orthographicSize*n,a=this._orthographicSize;tL.ortho(-r,r,-a,a,this.nearClipPlane,this.farClipPlane,t)}else tL.perspective(tS.degreeToRadian(this._fieldOfView),n,this.nearClipPlane,this.farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return this._enableHDR},set:function(e){if(this.enableHDR!==e){var t=this.engine._hardwareRenderer,n=t.isWebGL2||t.canIUse(nJ.textureHalfFloat);if(e&&!n){no.warn("Can't enable HDR in this device.");return}this._enableHDR=e,this._checkMainCanvasAntialiasWaste()}}},{key:"enablePostProcess",get:function(){return this._enablePostProcess},set:function(e){this._enablePostProcess!==e&&(this._enablePostProcess=e,this._checkMainCanvasAntialiasWaste())}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged())}}]),t}(ru),e.Camera._cameraDepthTextureProperty=nY.getByName("camera_DepthTexture"),e.Camera._cameraOpaqueTextureProperty=nY.getByName("camera_OpaqueTexture"),e.Camera._inverseViewMatrixProperty=nY.getByName("camera_ViewInvMat"),e.Camera._cameraPositionProperty=nY.getByName("camera_Position"),e.Camera._cameraForwardProperty=nY.getByName("camera_Forward"),e.Camera._cameraUpProperty=nY.getByName("camera_Up"),e.Camera._cameraDepthBufferParamsProperty=nY.getByName("camera_DepthBufferParams"),tX([tZ],e.Camera.prototype,"_frustum",void 0),tX([tq],e.Camera.prototype,"_renderPipeline",void 0),tX([tq],e.Camera.prototype,"_virtualCamera",void 0),tX([tq],e.Camera.prototype,"_cameraIndex",void 0),tX([tq],e.Camera.prototype,"_frustumChangeFlag",void 0),tX([tq],e.Camera.prototype,"_isViewMatrixDirty",void 0),tX([tq],e.Camera.prototype,"_isInvViewProjDirty",void 0),tX([tZ],e.Camera.prototype,"_viewport",void 0),tX([tZ],e.Camera.prototype,"_pixelViewport",void 0),tX([tZ],e.Camera.prototype,"_inverseProjectionMatrix",void 0),tX([tZ],e.Camera.prototype,"_invViewProjMat",void 0),tX([tq],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=tX([rh(rp,r_.CheckOnly)],e.Camera);var rO=((J={})[J.SolidColor=0]="SolidColor",J[J.Sky=1]="Sky",J[J.Texture=2]="Texture",J),rN=((Z={})[Z.AspectFitWidth=0]="AspectFitWidth",Z[Z.AspectFitHeight=1]="AspectFitHeight",Z[Z.Fill=2]="Fill",Z),rV=function(e){this.engine=e},rk=/*#__PURE__*/function(){function e(){this._projectionParams=new tI,this.flipProjection=!1,this.rendererUpdateFlag=0}var t=e.prototype;return t.applyVirtualCamera=function(t,n){this.virtualCamera=t,this.flipProjection=n;var r=this.camera.shaderData,a=t.viewMatrix,i=t.projectionMatrix,o=t.viewProjectionMatrix;n&&(tL.multiply(e._flipYMatrix,i,e._flipYProjectionMatrix),tL.multiply(e._flipYProjectionMatrix,a,e._flipYViewProjectionMatrix),i=e._flipYProjectionMatrix,o=e._flipYViewProjectionMatrix),this.viewMatrix=a,this.projectionMatrix=i,this.viewProjectionMatrix=o,r.setMatrix(e._viewMatrixProperty,a),r.setMatrix(e._projectionMatrixProperty,i),r.setMatrix(e.vpMatrixProperty,o);var s=this._projectionParams;s.set(n?-1:1,t.nearClipPlane,t.farClipPlane,0),r.setVector4(e._cameraProjectionProperty,s)},t.garbageCollection=function(){this.camera=null},e}();rk.vpMatrixProperty=nY.getByName("camera_VPMat"),rk.pipelineStageKey=n0.getByName("pipelineStage"),rk._flipYMatrix=new tL(1,0,0,0,0,-1),rk._cameraProjectionProperty=nY.getByName("camera_ProjectionParams"),rk._viewMatrixProperty=nY.getByName("camera_ViewMat"),rk._projectionMatrixProperty=nY.getByName("camera_ProjMat"),rk._flipYProjectionMatrix=new tL,rk._flipYViewProjectionMatrix=new tL;var rz=(($={})[$.None=0]="None",$[$.WorldMatrix=1]="WorldMatrix",$[$.viewMatrix=2]="viewMatrix",$[$.ProjectionMatrix=4]="ProjectionMatrix",$[$.WorldViewMatrix=3]="WorldViewMatrix",$[$.viewProjectionMatrix=6]="viewProjectionMatrix",$[$.All=7]="All",$),rU=((ee={})[ee.No=0]="No",ee[ee.Increment=1]="Increment",ee[ee.Decrement=2]="Decrement",ee),rG=/*#__PURE__*/function(){function e(e){this.renderQueueType=e,this.elements=[],this.batchedSubElements=[]}var t=e.prototype;return t.pushRenderElement=function(e){this.elements.push(e)},t.sortBatch=function(e,t){nT._quickSort(this.elements,0,this.elements.length,e),this.batch(t)},t.batch=function(e){e.batch(this)},t.render=function(e,t,n){void 0===n&&(n=rU.No);var r=this.batchedSubElements,a=r.length;if(0!==a)for(var i=e.rendererUpdateFlag,o=e.camera,s=o.engine,l=o.scene,c=o.instanceId,u=o.shaderData,d=l.instanceId,h=l.shaderData,_=l._maskManager,f=s._renderCount,p=s._hardwareRenderer,m=rk.pipelineStageKey,g=this.renderQueueType,v=0;v<a;v++){var y=r[v],x=y.component,b=y.batched,C=y.material;i&rz.WorldViewMatrix||x._batchedTransformShaderData!=b?(x._updateTransformShaderData(e,!1,b),x._batchedTransformShaderData=b):i&rz.ProjectionMatrix&&x._updateTransformShaderData(e,!0,b);var S=x._maskInteraction,T=S!==nv.None,A=n!==rU.No,E=null;A?E=aY.getMaskTypeRenderStates(n):(T?(_.drawMask(e,t,y.component._maskLayer),E=aY.getMaskInteractionRenderStates(S)):_.isReadStencil(C)&&_.clearMask(e,t),_.isStencilWritten(C)&&(_.hasStencilWritten=!0));var R=ro._compileMacros,M=y.primitive,w=y.shaderPasses,P=y.shaderData,F=x.shaderData,L=x.instanceId,D=C.shaderData,B=C.instanceId,I=C.renderStates;nW.unionCollection(x._globalShaderMacro,D._macroCollection,R);for(var O=0,N=w.length;O<N;O++){var V=w[O];if(V.getTagValue(m)===t){var k=V._renderState;if(A)k||(k=I[O]);else if((k?k._getRenderQueueByShaderData(V._renderStateDataMap,D):(k=I[O]).renderQueueType)!==g)continue;var z=V._getShaderProgram(s,R);if(z.isValid){var U=z.bind();f!==z._uploadRenderCount?(z.groupingOtherUniformBlock(),z.uploadAll(z.sceneUniformBlock,h),z.uploadAll(z.cameraUniformBlock,u),z.uploadAll(z.rendererUniformBlock,F),z.uploadAll(z.materialUniformBlock,D),P&&z.uploadAll(z.renderElementUniformBlock,P),z.uploadUnGroupTextures(),z._uploadSceneId=d,z._uploadCameraId=c,z._uploadRendererId=L,z._uploadMaterialId=B,z._uploadRenderCount=f):(z._uploadSceneId!==d?(z.uploadAll(z.sceneUniformBlock,h),z._uploadSceneId=d):U&&z.uploadTextures(z.sceneUniformBlock,h),z._uploadCameraId!==c?(z.uploadAll(z.cameraUniformBlock,u),z._uploadCameraId=c):U&&z.uploadTextures(z.cameraUniformBlock,u),z._uploadRendererId!==L?(z.uploadAll(z.rendererUniformBlock,F),z._uploadRendererId=L):U&&z.uploadTextures(z.rendererUniformBlock,F),z._uploadMaterialId!==B?(z.uploadAll(z.materialUniformBlock,D),z._uploadMaterialId=B):U&&z.uploadTextures(z.materialUniformBlock,D),P&&z.uploadAll(z.renderElementUniformBlock,P),U&&z.uploadUnGroupTextures()),k._applyStates(s,x._transformEntity.transform._isFrontFaceInvert(),V._renderStateDataMap,C.shaderData,E),p.drawPrimitive(M,y.subPrimitive,z)}}}}},t.clear=function(){this.elements.length=0,this.batchedSubElements.length=0},t.destroy=function(){},e.compareForOpaque=function(e,t){return e.priority-t.priority||e.distanceForSort-t.distanceForSort},e.compareForTransparent=function(e,t){return e.priority-t.priority||t.distanceForSort-e.distanceForSort},e}(),rH=function(){this.virtualCamera=new rM,this.cullPlanes=[new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT)],this.splitBoundSphere=new tA(new tT,0)},rW=((et={})[et.Low=0]="Low",et[et.Medium=1]="Medium",et[et.High=2]="High",et[et.VeryHigh=3]="VeryHigh",et),rj=((en={})[en.None=0]="None",en[en.Hard=1]="Hard",en[en.SoftLow=2]="SoftLow",en[en.SoftHigh=3]="SoftHigh",en),rX=/*#__PURE__*/function(){function e(){}return e.shadowResolution=function(e){switch(e){case rW.Low:return 512;case rW.Medium:return 1024;case rW.High:return 2048;case rW.VeryHigh:return 4096}},e.shadowDepthFormat=function(e,t){return t?t9.Depth16:t9.R8G8B8A8},e.cullingRenderBounds=function(e,t,n){for(var r=e.min,a=e.max,i=0;i<t;i++){var o=n[i],s=o.normal;if(s.x*(s.x>=0?a.x:r.x)+s.y*(s.y>=0?a.y:r.y)+s.z*(s.z>=0?a.z:r.z)<-o.distance)return!1}return!0},e.shadowCullFrustum=function(t,n,r,a){var i=r._entity.layer;t.camera.cullingMask&i&&n.cullingMask&i&&r.castShadows&&e.cullingRenderBounds(r.bounds,a.cullPlaneCount,a.cullPlanes)&&(r._prepareRender(t),r._renderFrameCount=r.engine.time.frameCount)},e.getBoundSphereByFrustum=function(e,t,n,r,a){var i,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(tS.degreeToRadian(l)/2),u=c*c,d=t-e,h=t+e;u>d/h?(i=t,o=t*c):(i=.5*h*(1+u),o=.5*Math.sqrt(d*d+2*(t*t+e*e)*u+h*h*u*u));var _=a.splitBoundSphere.center;a.splitBoundSphere.radius=o,tT.scale(r,i,_),tT.add(n.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},e.getDirectionLightShadowCullPlanes=function(t,n,r,a,i){var o=e._frustumCorners,s=e._backPlaneFaces,l=e._frustumPlaneNeighbors,c=e._frustumTwoPlaneCorners,u=e._edgePlanePoint2,d=i.cullPlanes,h=t.getPlane(tx.Near),_=t.getPlane(tx.Far),f=t.getPlane(tx.Left),p=t.getPlane(tx.Right),m=t.getPlane(tx.Bottom),g=t.getPlane(tx.Top),v=e._adjustNearPlane,y=e._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(n-r),y.distance=Math.min(-h.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),tR.intersectionPointThreePlanes(v,m,p,o[7]),tR.intersectionPointThreePlanes(v,g,p,o[6]),tR.intersectionPointThreePlanes(v,g,f,o[5]),tR.intersectionPointThreePlanes(v,m,f,o[4]),tR.intersectionPointThreePlanes(y,m,p,o[3]),tR.intersectionPointThreePlanes(y,g,p,o[2]),tR.intersectionPointThreePlanes(y,g,f,o[1]),tR.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var C=void 0;switch(b){case tx.Near:C=v;break;case tx.Far:C=y;break;default:C=t.getPlane(b)}0>tT.dot(C.normal,a)&&(d[x].copyFrom(C),s[x]=b,x++)}for(var S=x,T=0;T<x;T++)for(var A=s[T],E=l[A],R=0;R<4;R++){for(var M=E[R],w=!0,P=0;P<x;P++)if(M==s[P]){w=!1;break}if(w){var F=c[A][M],L=o[F[0]],D=o[F[1]];tT.add(L,a,u),tM.fromPoints(L,D,u,d[S++])}}i.cullPlaneCount=S},e.getDirectionalLightMatrices=function(t,n,r,a,i,o,s,l){var c=s.splitBoundSphere;s.resolution=o;var u=c.center,d=c.radius,h=o/2,_=d*h/(h-e.atlasBorderSize),f=2*_,p=o/f,m=f/o,g=Math.ceil(tT.dot(u,t)*p)*m,v=Math.ceil(tT.dot(u,n)*p)*m,y=tT.dot(u,r);u.x=t.x*g+n.x*v+r.x*y,u.y=t.y*g+n.y*v+r.y*y,u.z=t.z*g+n.z*v+r.z*y;var x=s.virtualCamera,b=x.position,C=x.viewMatrix,S=x.projectionMatrix;tT.scale(r,d+i,b),tT.subtract(u,b,b),tL.lookAt(b,u,t,C),tL.ortho(-_,_,-_,_,0,2*d+i,S);var T=x.viewProjectionMatrix;tL.multiply(S,C,T),nT._floatMatrixMultiply(e._shadowMapCoordMatrix,T.elements,0,l,16*a)},e.getMaxTileResolutionInAtlas=function(e,t,n){for(var r=Math.min(e,t),a=Math.floor(e/r)*Math.floor(t/r);a<n;)a=Math.floor(e/(r=Math.floor(r>>1)))*Math.floor(t/r);return r},e.getShadowBias=function(e,t,n,r){var a=2/t.elements[0]/n,i=-e.shadowBias*a,o=-e.shadowNormalBias*a;e.shadowType==rj.SoftHigh&&(i*=2.5,o*=2.5),r.set(i,o)},e.applySliceTransform=function(t,n,r,a,i,o){var s=e._tempMatrix0,l=s.elements,c=1/n,u=1/r,d=i.x*c,h=i.y*u;l[0]=t*c,l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=t*u,l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=1,l[11]=0,l[12]=d,l[13]=h,l[14]=0,l[15]=1;var _=16*a;nT._floatMatrixMultiply(s,o,_,o,_)},e.getScaleAndBiasForLinearDistanceFade=function(e,t,n){if(t<1e-4){n.z=1e3,n.w=-(1e3*e);return}t=1-t;var r=(t*=t)*e,a=e-r;n.z=1/a,n.w=-r/a},e}();rX._tempMatrix0=new tL,rX._shadowMapCoordMatrix=new tL(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),rX._frustumCorners=[new tT,new tT,new tT,new tT,new tT,new tT,new tT,new tT],rX._adjustNearPlane=new tM(new tT),rX._adjustFarPlane=new tM(new tT),rX._backPlaneFaces=[,,,,,],rX._edgePlanePoint2=new tT,rX._frustumPlaneNeighbors=[[tx.Left,tx.Right,tx.Top,tx.Bottom],[tx.Left,tx.Right,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Left,tx.Right],[tx.Near,tx.Far,tx.Left,tx.Right]],rX._frustumTwoPlaneCorners=[[[8,8],[8,8],[4,5],[6,7],[7,4],[5,6]],[[8,8],[8,8],[1,0],[3,2],[0,3],[2,1]],[[5,4],[0,1],[8,8],[8,8],[4,0],[1,5]],[[7,6],[2,3],[8,8],[8,8],[3,7],[6,2]],[[4,7],[3,0],[0,4],[7,3],[8,8],[8,8]],[[6,5],[1,2],[5,1],[2,6],[8,8],[8,8]]],rX.atlasBorderSize=4;var rK=((er={})[er.NoCascades=1]="NoCascades",er[er.TwoCascades=2]="TwoCascades",er[er.FourCascades=4]="FourCascades",er),rY=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n.engine)||this)._shadowMapSize=new tI,r._shadowBias=new tB,r._shadowSliceData=new rH,r._lightUp=new tT,r._lightSide=new tT,r._splitBoundSpheres=new Float32Array(4*t._maxCascades),r._shadowMatrices=new Float32Array((t._maxCascades+1)*16),r._shadowInfos=new tI,r._viewportOffsets=[new tB,new tB,new tB,new tB],r._camera=n,r._supportDepthTexture=n.engine._hardwareRenderer.canIUse(nJ.depthTexture),r._shadowSliceData.virtualCamera.isOrthographic=!0,r}tW(t,e);var n=t.prototype;return n.onRender=function(e){var t=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,t),this._updateReceiversShaderData(t)},n._renderDirectShadowMap=function(e,n){var r,a,i=this.engine,o=this._camera,s=this._viewportOffsets,l=this._shadowSliceData,c=this._splitBoundSpheres,u=this._shadowMatrices,d=o._renderPipeline._cullingResults,h=d.opaqueQueue,_=d.alphaTestQueue,f=o.scene,p=f._componentsManager,m=i._hardwareRenderer,g=f.shadowCascades,v=t._cascadesSplitDistance,y=l.splitBoundSphere,x=t._tempMatrix0,b=x.elements,C=this._lightUp,S=this._lightSide,T=l.virtualCamera.forward,A=this._shadowMapSize,E=A.z,R=A.w,M=this._shadowMapFormat;a=this._supportDepthTexture?(r=rR.recreateRenderTargetIfNeeded(i,this._renderTarget,E,R,null,M,!0,!1,1,t7.Clamp,t5.Bilinear)).depthTexture:(r=rR.recreateRenderTargetIfNeeded(i,this._renderTarget,E,R,M,null,!1,!1,1,t7.Clamp,t5.Bilinear)).getColorTexture(0),i._hardwareRenderer._isWebGL2&&(a.depthCompareFunction=t8.Less),this._renderTarget=r,this._depthTexture=a,m.activeRenderTarget(r,t._viewport,e.flipProjection,0),this._supportDepthTexture?m.clearRenderTarget(i,rw.Depth,null):m.clearRenderTarget(i,rw.All,t._clearColor),tL.rotationQuaternion(n.entity.transform.worldRotationQuaternion,x),S.set(b[0],b[1],b[2]),C.set(b[4],b[5],b[6]),T.set(-b[8],-b[9],-b[10]);var w=t._tempVector;w.copyFrom(o.entity.transform.worldForward);for(var P=this._shadowTileResolution,F=0;F<g;F++){rX.getBoundSphereByFrustum(v[F],v[F+1],o,w,l),rX.getDirectionLightShadowCullPlanes(o._frustum,v[F],o.nearClipPlane,T,l),rX.getDirectionalLightMatrices(C,S,T,F,n.shadowNearPlaneOffset,P,l,u),g>1&&rX.applySliceTransform(P,E,R,F,this._viewportOffsets[F],u),this._updateSingleShadowCasterShaderData(n,l,e);var L=y.center,D=y.radius,B=4*F;c[B]=L.x,c[B+1]=L.y,c[B+2]=L.z,c[B+3]=D*D,h.clear(),_.clear();for(var I=p._renderers,O=I._elements,N=I.length-1;N>=0;--N)rX.shadowCullFrustum(e,n,O[N],l);if(h.elements.length||_.elements.length){i._renderCount++;var V=i._batcherManager;h.sortBatch(rG.compareForOpaque,V),_.sortBatch(rG.compareForOpaque,V);var k=s[F],z=k.x,U=k.y;m.setGlobalDepthBias(1,1),m.viewport(z,U,P,P),m.scissor(z+1,U+1,P-2,P-2),h.render(e,nX.ShadowCaster),_.render(e,nX.ShadowCaster),m.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var n=this._camera,r=n.scene,a=this._splitBoundSpheres,i=this._shadowMatrices,o=r.shadowCascades,s=Math.min(r.shadowDistance,n.farClipPlane);if(rX.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),r.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,o>1)for(var l=4*o,c=a.length;l<c;l++)a[l]=0;for(var u=16*o,d=i.length;u<d;u++)i[u]=0;var h=r.shaderData;h.setFloatArray(t._shadowMatricesProperty,this._shadowMatrices),h.setVector4(t._shadowInfosProperty,this._shadowInfos),h.setTexture(t._shadowMapsProperty,this._depthTexture),h.setFloatArray(t._shadowSplitSpheresProperty,this._splitBoundSpheres),h.setVector4(t._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(e){var n=t._cascadesSplitDistance,r=this._camera.scene,a=r.shadowTwoCascadeSplits,i=r.shadowFourCascadeSplits,o=r.shadowCascades,s=this._camera,l=s.nearClipPlane,c=s.aspectRatio,u=s.fieldOfView;n[0]=l;var d=e-l,h=Math.tan(.5*tS.degreeToRadian(u)),_=1+h*h*(c*c+1);switch(o){case rK.NoCascades:n[1]=this._getFarWithRadius(e,_);break;case rK.TwoCascades:n[1]=this._getFarWithRadius(l+d*a,_),n[2]=this._getFarWithRadius(e,_);break;case rK.FourCascades:n[1]=this._getFarWithRadius(l+d*i.x,_),n[2]=this._getFarWithRadius(l+d*i.y,_),n[3]=this._getFarWithRadius(l+d*i.z,_),n[4]=this._getFarWithRadius(e,_)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._updateShadowSettings=function(){var e=this._camera,t=e.scene,n=rX.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=rX.shadowResolution(t.shadowResolution),a=t.shadowCascades,i=Math.min(t.shadowDistance,e.farClipPlane);if(this._getCascadesSplitDistance(i),n!==this._shadowMapFormat||r!==this._shadowMapResolution||a!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=r,this._shadowCascadeMode=a,a==rK.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var o=rX.getMaxTileResolutionInAtlas(r,r,a);this._shadowTileResolution=o;var s=2*o,l=a==rK.TwoCascades?o:2*o;this._shadowMapSize.set(1/s,1/l,s,l)}this._renderTarget=null;var c=this._viewportOffsets,u=this._shadowTileResolution;switch(a){case rK.NoCascades:c[0].set(0,0);break;case rK.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case rK.FourCascades:c[0].set(0,0),c[1].set(u,0),c[2].set(0,u),c[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var a=n.virtualCamera;rX.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(t._lightShadowBiasProperty,this._shadowBias),i.setVector3(t._lightDirectionProperty,e.direction),r.rendererUpdateFlag|=rz.viewProjectionMatrix,r.applyVirtualCamera(a,!0)},t}(rV);rY._lightShadowBiasProperty=nY.getByName("scene_ShadowBias"),rY._lightDirectionProperty=nY.getByName("scene_LightDirection"),rY._shadowMatricesProperty=nY.getByName("scene_ShadowMatrices"),rY._shadowMapSize=nY.getByName("scene_ShadowMapSize"),rY._shadowInfosProperty=nY.getByName("scene_ShadowInfo"),rY._shadowMapsProperty=nY.getByName("scene_ShadowMap"),rY._shadowSplitSpheresProperty=nY.getByName("scene_ShadowSplitSpheres"),rY._maxCascades=4,rY._cascadesSplitDistance=Array(rY._maxCascades+1),rY._viewport=new tI(0,0,1,1),rY._clearColor=new tO(1,1,1,1),rY._tempVector=new tT,rY._tempMatrix0=new tL;var rq=/*#__PURE__*/function(){function e(){this.opaqueQueue=new rG(nN.Opaque),this.transparentQueue=new rG(nN.Transparent),this.alphaTestQueue=new rG(nN.AlphaTest)}var t=e.prototype;return t.reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},t.sortBatch=function(e){this.opaqueQueue.sortBatch(rG.compareForOpaque,e),this.alphaTestQueue.sortBatch(rG.compareForOpaque,e),this.transparentQueue.sortBatch(rG.compareForTransparent,e)},t.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},e}(),rQ=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._supportDepthTexture=e._hardwareRenderer.canIUse(nJ.depthTexture),n}tW(n,t);var r=n.prototype;return r.onConfig=function(e){var t=this.engine,n=e.pixelViewport,r=n.width,a=n.height,i=rR.recreateRenderTargetIfNeeded(t,this._renderTarget,r,a,null,t9.Depth16,!0,!1,1,t7.Clamp,t5.Point);this._renderTarget=i},r.onRender=function(t,n){var r=this.engine,a=this._renderTarget,i=t.camera,o=r._hardwareRenderer;o.activeRenderTarget(a,rR.defaultViewport,t.flipProjection,0),o.clearRenderTarget(r,rw.Depth,null),r._renderCount++,n.opaqueQueue.render(t,nX.DepthOnly),n.alphaTestQueue.render(t,nX.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},n}(rV),rJ=/*#__PURE__*/function(t){function n(e){return t.call(this,e)||this}tW(n,t);var r=n.prototype;return r.onConfig=function(e,t){this._cameraColorTexture=t;var n=e.opaqueTextureDownsampling,r=n===rL.None,a=e.pixelViewport,i=r?1:n===rL.TwoX?.5:.25,o=rR.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,a.width*i,a.height*i,e._getInternalColorTextureFormat(),null,!1,!1,1,t7.Clamp,r?t5.Point:t5.Bilinear);this._renderTarget=o},r.onRender=function(t){rR.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},n}(rV),rZ=/*#__PURE__*/function(){function t(e){this._lastCanvasSize=new tB,this._internalColorTarget=null,this._canUseBlitFrameBuffer=!1,this._shouldGrabColor=!1,this._camera=e;var t=e.engine;this._cullingResults=new rq,this._cascadedShadowCasterPass=new rY(e),this._depthOnlyPass=new rQ(t),this._opaqueTexturePass=new rJ(t)}var n=t.prototype;return n.destroy=function(){this._cullingResults.destroy(),this._camera=null},n.render=function(t,n,r,a){t.rendererUpdateFlag=rz.All;var i=this._camera,o=i.scene,s=i.engine,l=s._hardwareRenderer,c=this._cullingResults,u=o._lightManager._sunlight,d=this._depthOnlyPass,h=i.depthTextureMode===rF.PrePass&&d._supportDepthTexture,_=i.clearFlags&~(null!=a?a:rw.None),f=i.independentCanvasEnabled,p=i.renderTarget?i.renderTarget.antiAliasing:i.msaaSamples;this._shouldGrabColor=f&&!(_&rw.Color),this._canUseBlitFrameBuffer=l.isWebGL2&&1===p&&(!!i.renderTarget||!l.context.antialias),o.castShadows&&u&&u.shadowType!==rj.None&&(this._cascadedShadowCasterPass.onRender(t),t.rendererUpdateFlag=rz.None);var m=s._batcherManager;if(c.reset(),t.rendererUpdateFlag|=rz.viewProjectionMatrix,t.applyVirtualCamera(i._virtualCamera,h),this._prepareRender(t),c.sortBatch(m),m.uploadBuffer(),h?(d.onConfig(i),d.onRender(t,c),t.rendererUpdateFlag=rz.None):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),f){y=i.renderTarget?i.renderTarget._depthFormat:l.context.depth&&l.context.stencil?t9.Depth24Stencil8:l.context.depth?t9.Depth24:l.context.stencil?t9.Stencil:null;var g=i.pixelViewport,v=rR.recreateRenderTargetIfNeeded(s,this._internalColorTarget,g.width,g.height,i._getInternalColorTextureFormat(),y,!1,!1,p,t7.Clamp,t5.Bilinear);if(!this._canUseBlitFrameBuffer&&this._shouldGrabColor){var y,x,b,C=rR.recreateTextureIfNeeded(s,this._grabTexture,g.width,g.height,null!=(b=null==(x=i.renderTarget)?void 0:x.getColorTexture(0).format)?b:t9.R8G8B8A8,!1,t7.Clamp,t5.Bilinear);this._grabTexture=C}this._internalColorTarget=v}else{var S,T=this._internalColorTarget,A=this._grabTexture;T&&(null==(S=T.getColorTexture(0))||S.destroy(!0),T.destroy(!0),this._internalColorTarget=null),A&&(A.destroy(!0),this._grabTexture=null)}this._drawRenderPass(t,i,_,n,r)},n._drawRenderPass=function(t,n,r,a,i){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue,u=n.engine,d=n.scene,h=d.background,_=u._hardwareRenderer,f=this._internalColorTarget,p=f||n.renderTarget,m=f?rR.defaultViewport:n.viewport,g=!!f||n.renderTarget&&void 0==a;t.flipProjection!==g&&(t.rendererUpdateFlag|=rz.ProjectionMatrix,t.applyVirtualCamera(n._virtualCamera,g)),_.activeRenderTarget(p,m,t.flipProjection,i,a);var v=h.solidColor;f&&r!==rw.All?(this._canUseBlitFrameBuffer?(r!==rw.None&&_.clearRenderTarget(u,r,v),_.blitInternalRTByBlitFrameBuffer(n.renderTarget,f,r,n.viewport)):(r&rw.Depth&&r&rw.Stencil||no.warn("We clear all depth/stencil state cause of the internalRT can't copy depth/stencil buffer from back buffer when use copy plan"),this._shouldGrabColor?(_.clearRenderTarget(u,rw.DepthStencil),_.copyRenderTargetToSubTexture(n.renderTarget,this._grabTexture,n.viewport),rR.blitTexture(u,this._grabTexture,f,0,void 0,void 0,void 0,!n.renderTarget)):_.clearRenderTarget(u,rw.All,v)),_.activeRenderTarget(p,m,t.flipProjection,i,a)):r!==rw.None&&_.clearRenderTarget(u,r,v);var y=d._maskManager;if(r&rw.Stencil&&(y.hasStencilWritten=!1),s.render(t,nX.Forward),l.render(t,nX.Forward),r&rw.Color&&(h.mode===rO.Sky?h.sky._render(t):h.mode===rO.Texture&&h.texture&&this._drawBackgroundTexture(n,h)),n.opaqueTextureEnabled){p._blitRenderTarget();var x=this._opaqueTexturePass;x.onConfig(n,p.getColorTexture(0)),x.onRender(t),_.activeRenderTarget(p,m,t.flipProjection,i,a)}else n.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);c.render(t,nX.Forward),y.clearMask(t,nX.Forward);var b=d._postProcessManager,C=n.renderTarget;n.enablePostProcess&&b.hasActiveEffect?b._render(t,f,C):f&&(f._blitRenderTarget(),rR.blitTexture(u,f.getColorTexture(0),C,0,n.viewport)),null==C||C._blitRenderTarget(),null==C||C.generateMipmaps()},n.pushRenderElement=function(e,t){t.renderQueueFlags=0;for(var n=t.subRenderElements,r=0,a=n.length;r<a;++r){var i=n[r],o=i.material,s=o.renderStates,l=o.shader.subShaders[0],c=e.replacementShader;if(c){var u=c.subShaders,d=e.replacementTag;if(d){for(var h=!1,_=0,f=u.length;_<f;_++){var p=u[_];p.getTagValue(d)===l.getTagValue(d)&&(this.pushRenderElementByType(t,i,p.passes,s),h=!0)}h||e.replacementFailureStrategy!==rB.KeepOriginalShader||this.pushRenderElementByType(t,i,l.passes,s)}else this.pushRenderElementByType(t,i,u[0].passes,s)}else this.pushRenderElementByType(t,i,l.passes,s)}},n.pushRenderElementByType=function(e,t,n,r){for(var a=this._cullingResults,i=0,o=n.length;i<o;i++){var s=void 0,l=n[i],c=l._renderState,u=1<<(s=c?c._getRenderQueueByShaderData(l._renderStateDataMap,t.material.shaderData):r[i].renderQueueType);if(t.shaderPasses=n,t.renderQueueFlags|=u,!(e.renderQueueFlags&u)){switch(s){case nN.Opaque:a.opaqueQueue.pushRenderElement(e);break;case nN.AlphaTest:a.alphaTestQueue.pushRenderElement(e);break;case nN.Transparent:a.transparentQueue.pushRenderElement(e)}e.renderQueueFlags|=u}}},n._drawBackgroundTexture=function(e,t){var n=e.engine,r=n._hardwareRenderer,a=n.canvas,i=t._material,o=t._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&t._textureFillMode!==rN.Fill&&(this._lastCanvasSize.set(a.width,a.height),t._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0],l=s._getShaderProgram(n,ro._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,i.shaderData),l.uploadAll(l.cameraUniformBlock,e.shaderData),l.uploadUnGroupTextures(),(s._renderState||i.renderState)._applyStates(n,!1,s._renderStateDataMap,i.shaderData),r.drawPrimitive(o._primitive,o.subMesh,l)},n._prepareRender=function(e){for(var t=e.camera,n=t.engine,r=t.scene._componentsManager._renderers,a=r._elements,i=r.length-1;i>=0;--i){var o=a[i];t.cullingMask&o._entity.layer&&(!t.enableFrustumCulling||t._frustum.intersectsBox(o.bounds))&&(o._prepareRender(e),o._renderFrameCount=n.time.frameCount)}},t}(),r$=((ea={})[ea.None=0]="None",ea[ea.Opaque=1]="Opaque",ea[ea.AlphaTest=2]="AlphaTest",ea[ea.Transparent=4]="Transparent",ea[ea.All=7]="All",ea),r0=/*#__PURE__*/function(){function e(){this.subRenderElements=[]}var t=e.prototype;return t.set=function(e,t){this.priority=e,this.distanceForSort=t,this.subRenderElements.length=0},t.addSubRenderElement=function(e){this.subRenderElements.push(e)},t.dispose=function(){this.subRenderElements.length=0},e}(),r1=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.set=function(e,t,n,r,a,i){this.component=e,this.material=t,this.primitive=n,this.subPrimitive=r,this.texture=a,this.subChunk=i},t.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null,this.shaderPasses=null,this.shaderData&&(this.shaderData=null),this.texture&&(this.texture=null),this.subChunk&&(this.subChunk=null)},e}(),r2=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).influenceLayers=rg.Everything,r._maskIndex=-1,r._sprite=null,r._automaticWidth=0,r._automaticHeight=0,r._customWidth=void 0,r._customHeight=void 0,r._flipX=!1,r._flipY=!1,r._alphaCutoff=.5,rx.resetData(r),r.setMaterial(r._engine._basicResources.spriteMaskDefaultMaterial),r.shaderData.setFloat(t._alphaCutoffProperty,r._alphaCutoff),r._renderElement=new r0,r._renderElement.addSubRenderElement(new r1),r._onSpriteChange=r._onSpriteChange.bind(r),r}tW(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.sprite=this._sprite},n._canBatch=function(e,t){return rl.canBatchSpriteMask(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._onEnableInScene=function(){e.prototype._onEnableInScene.call(this),this.scene._maskManager.addSpriteMask(this)},n._onDisableInScene=function(){e.prototype._onDisableInScene.call(this),this.scene._maskManager.removeSpriteMask(this)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManagerMask},n._updateBounds=function(e){this.sprite?rx.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},n._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,n=this.getMaterial();if(n){var r=this._engine;n.destroyed&&(n=r._basicResources.spriteMaskDefaultMaterial),this._dirtyUpdateFlag&rv.WorldVolume&&(rx.updatePositions(this),this._dirtyUpdateFlag&=~rv.WorldVolume),2&this._dirtyUpdateFlag&&(rx.updateUVs(this),this._dirtyUpdateFlag&=-3);var a=this._renderElement,i=a.subRenderElements[0];a.set(this.priority,this._distanceForSort);var o=this._subChunk;i.set(this,n,o.chunk.primitive,o.subMesh,this.sprite.texture,o),i.shaderPasses=n.shader.subShaders[0].passes,i.renderQueueFlags=r$.All,a.addSubRenderElement(i)}}},n._onDestroy=function(){var t=this._sprite;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),e.prototype._onDestroy.call(this),this._sprite=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null),this._renderElement=null},n._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},n._onSpriteChange=function(e){switch(e){case nw.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nw.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rv.WorldVolume);break;case nw.region:case nw.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case nw.atlasRegion:this._dirtyUpdateFlag|=2;break;case nw.pivot:this._dirtyUpdateFlag|=rv.WorldVolume;break;case nw.destroy:this.sprite=null}},tG(t,[{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var n=this._sprite;n!==e&&(n&&(this._addResourceReferCount(n,-1),n._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(t._textureProperty,e.texture)):this.shaderData.setTexture(t._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(t._alphaCutoffProperty,e))}}]),t}(e.Renderer);r2._textureProperty=nY.getByName("renderer_MaskTexture"),r2._alphaCutoffProperty=nY.getByName("renderer_MaskAlphaCutoff"),tX([tQ],r2.prototype,"influenceLayers",void 0),tX([tq],r2.prototype,"_renderElement",void 0),tX([tq],r2.prototype,"_subChunk",void 0),tX([tq],r2.prototype,"_maskIndex",void 0),tX([tq],r2.prototype,"_sprite",void 0),tX([tq],r2.prototype,"_automaticWidth",void 0),tX([tq],r2.prototype,"_automaticHeight",void 0),tX([tQ],r2.prototype,"_customWidth",void 0),tX([tQ],r2.prototype,"_customHeight",void 0),tX([tQ],r2.prototype,"_flipX",void 0),tX([tQ],r2.prototype,"_flipY",void 0),tX([tQ],r2.prototype,"_alphaCutoff",void 0),tX([tq],r2.prototype,"_onSpriteChange",null);var r3=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._textChunks=[],n._subFont=null,n._dirtyFlag=15,n._color=new tO(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new tE,n._font=null,n._fontSize=24,n._fontStyle=n_.None,n._lineSpacing=0,n._horizontalAlignment=ny.Center,n._verticalAlignment=nx.Center,n._enableWrapping=!1,n._overflowMode=nf.Overflow;var n,r=n.engine;return n._font=r._textDefaultFont,n._addResourceReferCount(n._font,1),n.setMaterial(r._basicResources.textDefaultMaterial),n._color._onValueChanged=n._onColorChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),e.prototype._onDestroy.call(this),this._freeTextChunks(),this._textChunks=null,this._subFont&&(this._subFont=null)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.font=this._font,t._subFont=this._subFont},n._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},n._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},n._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},n._getSubFont=function(){return this._subFont||this._resetSubFont(),this._subFont},n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._canBatch=function(e,t){return rl.canBatchSprite(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){tE.transform(this._localBounds,this._entity.transform.worldMatrix,e)},n._render=function(e){if(!this._isTextNoVisible()){this._isContainDirtyFlag(1)&&(this._resetSubFont(),this._setDirtyFlagFalse(1)),this._isContainDirtyFlag(2)&&(this._updateLocalData(),this._setDirtyFlagFalse(2)),this._isContainDirtyFlag(4)&&(this._updatePosition(),this._setDirtyFlagFalse(4)),this._isContainDirtyFlag(16)&&(this._updateColor(),this._setDirtyFlagFalse(16));var n=e.camera,r=n.engine,a=r._textSubRenderElementPool,i=this.getMaterial(),o=r._renderElementPool.get();o.set(this.priority,this._distanceForSort);for(var s=this._textChunks,l=0,c=s.length;l<c;++l){var u=s[l],d=u.subChunk,h=u.texture,_=a.get();_.set(this,i,d.chunk.primitive,d.subMesh,h,d),_.shaderData||(_.shaderData=new rs(n8.RenderElement)),_.shaderData.setTexture(t._textureProperty,h),o.addSubRenderElement(_)}n._renderPipeline.pushRenderElement(e,o)}},n._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=np.getNativeFontString(e.name,this.fontSize,this.fontStyle)},n._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,n=e[0],r=e[1],a=e[2],i=e[4],o=e[5],s=e[6],l=e[12],c=e[13],u=e[14],d=t._tempVec31.set(i,o,s),h=t._tempVec30.set(n,r,a),_=t._worldPositions,f=_[0],p=_[1],m=_[2],g=_[3],v=this._textChunks,y=0,x=v.length;y<x;++y)for(var b=v[y],C=b.subChunk,S=b.charRenderInfos,T=0,A=S.length;T<A;++T){var E=S[T],R=E.localPositions,M=R.x,w=R.y;f.set(M*n+w*i+l,M*r+w*o+c,M*a+w*s+u),tT.scale(h,R.z-M,p),tT.add(f,p,p),tT.scale(d,R.w-w,m),tT.add(f,m,g),tT.add(p,m,m);for(var P=C.chunk.vertices,F=0,L=C.vertexArea.start+36*E.indexInChunk;F<4;++F,L+=9)_[F].copyToArray(P,L)}},n._updateColor=function(){for(var e=this._color,t=e.r,n=e.g,r=e.b,a=e.a,i=this._textChunks,o=0,s=i.length;o<s;++o)for(var l=i[o].subChunk,c=l.vertexArea,u=c.size/9,d=l.chunk.vertices,h=0,_=c.start+5;h<u;++h,_+=9)d[_]=t,d[_+1]=n,d[_+2]=r,d[_+3]=a},n._updateLocalData=function(){var e=this._localBounds,n=e.min,r=e.max,a=t._charRenderInfos,i=this._subFont,o=this.enableWrapping?np.measureTextWithWrap(this):np.measureTextWithoutWrap(this),s=o.height,l=o.lines,c=o.lineWidths,u=o.lineHeight,d=o.lineMaxSizes,h=this.engine._charRenderInfoPool,_=l.length,f=0;if(_>0){var p=iJ._pixelsPerUnit,m=this.horizontalAlignment,g=1/p,v=.5*(this.width*p),y=this.height*p,x=.5*u,b=0,C=.5*u-d[0].ascent,S=.5*u-d[_-1].descent-1;switch(this.verticalAlignment){case nx.Top:b=.5*y-x+C;break;case nx.Center:b=.5*s-x-(S-C)*.5;break;case nx.Bottom:b=s-.5*y-x-S}for(var T=-1,A=Number.MAX_SAFE_INTEGER,E=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,M=Number.MIN_SAFE_INTEGER,w=0;w<_;++w){var P=c[w];if(P>0){var F=l[w],L=0,D=-1;switch(T<0&&(T=w),m){case ny.Left:L=-v;break;case ny.Center:L=-(.5*P);break;case ny.Right:L=v-P}for(var B=0,I=F.length;B<I;++B){var O=F[B],N=i._getCharInfo(O);if(N.h>0){D<0&&(D=B);var V=a[f++]=h.get(),k=V.localPositions;V.texture=i._getTextureByIndex(N.index),V.uvs=N.uvs;var z=N.w,U=N.ascent,G=N.descent,H=L*g,W=(L+z)*g,j=(b+U)*g,X=(b-G)*g;k.set(H,j,W,X),w===T&&(M=Math.max(M,j)),E=Math.min(E,X),B===D&&(A=Math.min(A,H)),R=Math.max(R,W)}L+=N.xAdvance+N.offsetX}}b-=u}T<0?(n.set(0,0,0),r.set(0,0,0)):(n.set(A,E,0),r.set(R,M,0))}else n.set(0,0,0),r.set(0,0,0);if(i._getLastIndex()>0&&a.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId}),this._freeTextChunks(),0!==f){var K=this._textChunks,Y=new r4;K.push(Y);var q=this._getChunkManager().maxVertexCount,Q=a[0],J=Q.texture;Y.texture=J;var Z=Y.charRenderInfos;Z.push(Q);for(var $=1;$<f;++$){var ee=a[$],et=ee.texture;(J!==et||4*Z.length+4>q)&&(this._buildChunk(Y,Z.length),Y=new r4,K.push(Y),J=et,Y.texture=et,Z=Y.charRenderInfos),Z.push(ee)}var en=Z.length;en>0&&this._buildChunk(Y,en),a.length=0}},n._onTransformChanged=function(t){e.prototype._onTransformChanged.call(this,t),this._setDirtyFlagTrue(12)},n._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===nf.Truncate&&this.height<=0},n._buildChunk=function(e,t){for(var n=this.color,r=n.r,a=n.g,i=n.b,o=n.a,s=tj.triangles,l=s.length,c=e.subChunk=this._getChunkManager().allocateSubChunk(4*t),u=c.chunk.vertices,d=c.indices=[],h=e.charRenderInfos,_=0,f=0,p=0,m=c.vertexArea.start+3;_<t;++_,p+=4){var g=h[_];g.indexInChunk=_;for(var v=0;v<l;++v)d[f++]=s[v]+p;for(var y=0;y<4;++y,m+=9)g.uvs[y].copyToArray(u,m),u[m+2]=r,u[m+3]=a,u[m+4]=i,u[m+5]=o}return c},n._freeTextChunks=function(){for(var e=this._textChunks,t=this.engine._charRenderInfoPool,n=this._getChunkManager(),r=0,a=e.length;r<a;++r){for(var i=e[r],o=i.charRenderInfos,s=0,l=o.length;s<l;++s)t.return(o[s]);o.length=0,n.freeSubChunk(i.subChunk),i.subChunk=null,i.texture=null}e.length=0},n._onColorChanged=function(){this._setDirtyFlagTrue(16)},tG(t,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e)}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),t}(e.Renderer);r3._textureProperty=nY.getByName("renderElement_TextTexture"),r3._tempVec30=new tT,r3._tempVec31=new tT,r3._worldPositions=[new tT,new tT,new tT,new tT],r3._charRenderInfos=[],tX([tq],r3.prototype,"_textChunks",void 0),tX([tQ],r3.prototype,"_subFont",void 0),tX([tq],r3.prototype,"_dirtyFlag",void 0),tX([tZ],r3.prototype,"_color",void 0),tX([tQ],r3.prototype,"_text",void 0),tX([tQ],r3.prototype,"_width",void 0),tX([tQ],r3.prototype,"_height",void 0),tX([tq],r3.prototype,"_localBounds",void 0),tX([tQ],r3.prototype,"_font",void 0),tX([tQ],r3.prototype,"_fontSize",void 0),tX([tQ],r3.prototype,"_fontStyle",void 0),tX([tQ],r3.prototype,"_lineSpacing",void 0),tX([tQ],r3.prototype,"_horizontalAlignment",void 0),tX([tQ],r3.prototype,"_verticalAlignment",void 0),tX([tQ],r3.prototype,"_enableWrapping",void 0),tX([tQ],r3.prototype,"_overflowMode",void 0),tX([tq],r3.prototype,"_onColorChanged",null);var r4=function(){this.charRenderInfos=[]},r8=((ei={})[ei.Static=0]="Static",ei[ei.Dynamic=1]="Dynamic",ei[ei.Stream=2]="Stream",ei),r5=((eo={})[eo.None=0]="None",eo[eo.Discard=1]="Discard",eo),r9=/*#__PURE__*/function(e){function t(t,n,r,a,i){if(void 0===a&&(a=r8.Static),void 0===i&&(i=!1),(o=e.call(this,t)||this)._dataUpdateManager=new nM,o._engine=t,o._type=n,o._bufferUsage=a,o._readable=i,"number"==typeof r)o._byteLength=r,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,r,a),i&&(o._data=new Uint8Array(r));else{var o,s=r.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,s,a,r),i){var l=r.constructor===ArrayBuffer?r.slice(0):r.buffer.slice(r.byteOffset,r.byteOffset+s);o._data=new Uint8Array(l)}}return o}tW(t,e);var n=t.prototype;return n.bind=function(){this._platformBuffer.bind()},n.setData=function(e,t,n,r,a){if(void 0===t&&(t=0),void 0===n&&(n=0),void 0===a&&(a=r5.None),this._platformBuffer.setData(this._byteLength,e,t,n,r,a),this._readable){var i=e.constructor===ArrayBuffer?e:e.buffer;if(this._data.buffer!==i){var o=e.BYTES_PER_ELEMENT||1,s=r?o*r:e.byteLength,l=new Uint8Array(i,void 0!==e.byteOffset?e.byteOffset+n*o:n,s);this._data.set(l,t)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},n.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},n.markAsUnreadable=function(){this._data=null,this._readable=!1},n._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformBuffer.destroy()},tG(t,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}},{key:"readable",get:function(){return this._readable}},{key:"data",get:function(){if(this._readable)return this._data;throw"Buffer is not readable."}}]),t}(ne),r6=((es={})[es.UInt8=0]="UInt8",es[es.UInt16=1]="UInt16",es[es.UInt32=2]="UInt32",es),r7=((el={})[el.Float=0]="Float",el[el.Vector2=1]="Vector2",el[el.Vector3=2]="Vector3",el[el.Vector4=3]="Vector4",el[el.Byte4=4]="Byte4",el[el.UByte4=5]="UByte4",el[el.NormalizedByte4=6]="NormalizedByte4",el[el.NormalizedUByte4=7]="NormalizedUByte4",el[el.Short2=8]="Short2",el[el.UShort2=9]="UShort2",el[el.NormalizedShort2=10]="NormalizedShort2",el[el.NormalizedUShort2=11]="NormalizedUShort2",el[el.Short4=12]="Short4",el[el.UShort4=13]="UShort4",el[el.NormalizedShort4=14]="NormalizedShort4",el[el.NormalizedUShort4=15]="NormalizedUShort4",el),ae=/*#__PURE__*/function(){function e(){}return e._getGLIndexType=function(e){switch(e){case r6.UInt8:return nQ.UNSIGNED_BYTE;case r6.UInt16:return nQ.UNSIGNED_SHORT;case r6.UInt32:return nQ.UNSIGNED_INT}},e._getGLIndexByteCount=function(e){switch(e){case r6.UInt8:return 1;case r6.UInt16:return 2;case r6.UInt32:return 4}},e._getElementInfo=function(e){var t,n,r,a=!1;switch(e){case r7.Float:t=1,n=nQ.FLOAT;break;case r7.Vector2:t=2,n=nQ.FLOAT;break;case r7.Vector3:t=3,n=nQ.FLOAT;break;case r7.Vector4:t=4,n=nQ.FLOAT;break;case r7.Byte4:t=4,n=nQ.BYTE;break;case r7.UByte4:t=4,n=nQ.UNSIGNED_BYTE;break;case r7.NormalizedByte4:t=4,n=nQ.BYTE,a=!0,r=1/127;break;case r7.NormalizedUByte4:t=4,n=nQ.UNSIGNED_BYTE,a=!0,r=1/255;break;case r7.Short2:t=2,n=nQ.SHORT;break;case r7.UShort2:t=2,n=nQ.UNSIGNED_SHORT;break;case r7.NormalizedShort2:t=2,n=nQ.SHORT,a=!0,r=1/32767;break;case r7.NormalizedUShort2:t=2,n=nQ.UNSIGNED_SHORT,a=!0,r=1/65535;break;case r7.Short4:t=4,n=nQ.SHORT;break;case r7.UShort4:t=4,n=nQ.UNSIGNED_SHORT;break;case r7.NormalizedShort4:t=4,n=nQ.SHORT,a=!0,r=1/32767;break;case r7.NormalizedUShort4:t=4,n=nQ.UNSIGNED_SHORT,a=!0,r=1/65535}return{size:t,type:n,normalized:a,normalizedScaleFactor:r}},e}(),at=/*#__PURE__*/function(){function e(e,t,n,r,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=n,this._bindingIndex=r,this._formatMetaInfo=ae._getElementInfo(this.format),this._instanceStepRate=Math.floor(a)}return tG(e,[{key:"attribute",get:function(){return this._attributeName}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset=e}},{key:"format",get:function(){return this._format}},{key:"bindingIndex",get:function(){return this._bindingIndex},set:function(e){this._bindingIndex=e}},{key:"instanceStepRate",get:function(){return this._instanceStepRate}},{key:"semantic",get:function(){return this.attribute}}]),e}(),an=((ec={})[ec.VertexBuffer=0]="VertexBuffer",ec[ec.IndexBuffer=1]="IndexBuffer",ec),ar=((eu={})[eu.Points=0]="Points",eu[eu.Lines=1]="Lines",eu[eu.LineLoop=2]="LineLoop",eu[eu.LineStrip=3]="LineStrip",eu[eu.Triangles=4]="Triangles",eu[eu.TriangleStrip=5]="TriangleStrip",eu[eu.TriangleFan=6]="TriangleFan",eu),aa=((ed={})[ed.Normal=0]="Normal",ed[ed.Additive=1]="Additive",ed),ai=((eh={})[eh.Front=0]="Front",eh[eh.Back=1]="Back",eh[eh.Double=2]="Double",eh),ao=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._renderStates=[],r._shaderData=new rs(n8.Material),r.shader=n,r}tW(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),t$.deepCloneObject(this.renderStates,e.renderStates,new Map)},n._addReferCount=function(t){this._destroyed||(e.prototype._addReferCount.call(this,t),this.shaderData._addReferCount(t),this._shader._addReferCount(t))},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},tG(t,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var t,n=this._getReferCount();n>0&&(null==(t=this._shader)||t._addReferCount(-n),e._addReferCount(n)),this._shader=e;for(var r=this._renderStates,a=r.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)r.push(new ri);else r.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t}(t1),as=/*#__PURE__*/function(e){function t(n,r){(a=e.call(this,n,r)||this)._renderFace=ai.Front,a._isTransparent=!1,a._blendMode=aa.Normal;var a,i=a.shaderData;return i.setFloat(t._alphaCutoffProp,0),i.setFloat(t._shadowCasterRenderQueueProp,nN.Opaque),a}tW(t,e);var n=t.prototype;return n.setIsTransparent=function(e,n){var r=this.renderStates;if(r.length<e)throw"Pass should less than pass count.";var a=r[e],i=this.shaderData;n?(a.blendState.targetBlendState.enabled=!0,a.depthState.writeEnabled=!1,a.renderQueueType=nN.Transparent,i.enableMacro(t._transparentMacro)):(a.blendState.targetBlendState.enabled=!1,a.depthState.writeEnabled=!0,a.renderQueueType=i.getFloat(t._alphaCutoffProp)?nN.AlphaTest:nN.Opaque,i.disableMacro(t._transparentMacro))},n.setBlendMode=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";var r=n[e].blendState.targetBlendState;switch(t){case aa.Normal:r.sourceColorBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=nF.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=nF.One,r.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nL.Add;break;case aa.Additive:r.sourceColorBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=nF.One,r.sourceAlphaBlendFactor=nF.One,r.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nL.Add}},n.setRenderFace=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";switch(t){case ai.Front:n[e].rasterState.cullMode=nI.Back;break;case ai.Back:n[e].rasterState.cullMode=nI.Front;break;case ai.Double:n[e].rasterState.cullMode=nI.Off}},n.clone=function(){var e=new t(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t),t._renderFace=this._renderFace,t._isTransparent=this._isTransparent,t._blendMode=this._blendMode},tG(t,[{key:"shader",get:function(){return this._shader},set:function(e){var t,n=this._getReferCount();n>0&&(null==(t=this._shader)||t._addReferCount(-n),e._addReferCount(n)),this._shader=e;for(var r=this._renderStates,a=r.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)r.push(new ri),this.setBlendMode(l,aa.Normal);else r.length=i}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){if(e!==this._isTransparent){this.setIsTransparent(0,e);var n=this.shaderData;e?n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest):n.getFloat(t._alphaCutoffProp)?n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nN.Opaque),this._isTransparent=e}}},{key:"blendMode",get:function(){return this._blendMode},set:function(e){e!==this._blendMode&&(this.setBlendMode(0,e),this._blendMode=e)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(t._alphaCutoffProp)},set:function(e){var n=this.shaderData;if(n.getFloat(t._alphaCutoffProp)!==e){e?(n.enableMacro(t._alphaCutoffMacro),n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest)):(n.disableMacro(t._alphaCutoffMacro),this._isTransparent?n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nN.Opaque));for(var r=this.renderStates,a=0,i=r.length;a<i;a++){var o=r[a];e>0?o.renderQueueType=o.blendState.targetBlendState.enabled?nN.Transparent:nN.AlphaTest:o.renderQueueType=o.blendState.targetBlendState.enabled?nN.Transparent:nN.Opaque}n.setFloat(t._alphaCutoffProp,e)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),t}(ao);as._shadowCasterRenderQueueProp=nY.getByName("material_ShadowCasterRenderQueue"),as._baseTextureMacro=nH.getByName("MATERIAL_HAS_BASETEXTURE"),as._normalTextureMacro=nH.getByName("MATERIAL_HAS_NORMALTEXTURE"),as._emissiveTextureMacro=nH.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),as._transparentMacro=nH.getByName("MATERIAL_IS_TRANSPARENT"),as._baseColorProp=nY.getByName("material_BaseColor"),as._baseTextureProp=nY.getByName("material_BaseTexture"),as._tilingOffsetProp=nY.getByName("material_TilingOffset"),as._normalTextureProp=nY.getByName("material_NormalTexture"),as._normalIntensityProp=nY.getByName("material_NormalIntensity"),as._emissiveColorProp=nY.getByName("material_EmissiveColor"),as._emissiveTextureProp=nY.getByName("material_EmissiveTexture"),as._alphaCutoffProp=nY.getByName("material_AlphaCutoff"),as._alphaCutoffMacro=nH.getByName("MATERIAL_IS_ALPHA_CUTOFF");var al=/*#__PURE__*/function(e){function t(n){var r,a=(r=e.call(this,n,ro.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new tO(1,1,1,1)),a.setColor(t._specularColorProp,new tO(1,1,1,1)),a.setColor(t._emissiveColorProp,new tO(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var n=this.shaderData.getColor(t._specularColorProp);e!==n&&n.copyFrom(e)}},{key:"specularTexture",get:function(){return this.shaderData.getTexture(t._specularTextureProp)},set:function(e){this.shaderData.setTexture(t._specularTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SPECULAR_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SPECULAR_TEXTURE")}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(t._emissiveColorProp)},set:function(e){var n=this.shaderData.getColor(t._emissiveColorProp);e!==n&&n.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(t._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(t._emissiveTextureProp,e),e?this.shaderData.enableMacro(t._emissiveTextureMacro):this.shaderData.disableMacro(t._emissiveTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(t._normalTextureProp)},set:function(e){this.shaderData.setTexture(t._normalTextureProp,e),e?this.shaderData.enableMacro(t._normalTextureMacro):this.shaderData.disableMacro(t._normalTextureMacro)}},{key:"normalIntensity",get:function(){return this.shaderData.getFloat(t._normalIntensityProp)},set:function(e){this.shaderData.setFloat(t._normalIntensityProp,e)}},{key:"shininess",get:function(){return this.shaderData.getFloat(t._shininessProp)},set:function(e){this.shaderData.setFloat(t._shininessProp,Math.max(e,1e-4))}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}}]),t}(as);al._specularColorProp=nY.getByName("material_SpecularColor"),al._shininessProp=nY.getByName("material_Shininess"),al._specularTextureProp=nY.getByName("material_SpecularTexture");var ac=((e_={})[e_.UV0=0]="UV0",e_[e_.UV1=1]="UV1",e_[e_.UV2=2]="UV2",e_[e_.UV3=3]="UV3",e_[e_.UV4=4]="UV4",e_[e_.UV5=5]="UV5",e_[e_.UV6=6]="UV6",e_[e_.UV7=7]="UV7",e_),au=/*#__PURE__*/function(e){function t(n,r){var a,i=(a=e.call(this,n,r)||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tO(1,1,1,1)),i.setColor(t._emissiveColorProp,new tO(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),i.setFloat(t._normalIntensityProp,1),i.setFloat(t._occlusionTextureIntensityProp,1),i.setFloat(t._occlusionTextureCoordProp,ac.UV0),i.setFloat(t._clearCoatProp,0),i.setFloat(t._clearCoatRoughnessProp,0),a}return tW(t,e),tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(t._normalTextureProp)},set:function(e){this.shaderData.setTexture(t._normalTextureProp,e),e?this.shaderData.enableMacro(t._normalTextureMacro):this.shaderData.disableMacro(t._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(t._normalIntensityProp)},set:function(e){this.shaderData.setFloat(t._normalIntensityProp,e)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(t._emissiveColorProp)},set:function(e){var n=this.shaderData.getColor(t._emissiveColorProp);e!==n&&n.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(t._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(t._emissiveTextureProp,e),e?this.shaderData.enableMacro(t._emissiveTextureMacro):this.shaderData.disableMacro(t._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(t._occlusionTextureProp)},set:function(e){this.shaderData.setTexture(t._occlusionTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE")}},{key:"occlusionTextureIntensity",get:function(){return this.shaderData.getFloat(t._occlusionTextureIntensityProp)},set:function(e){this.shaderData.setFloat(t._occlusionTextureIntensityProp,e)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(t._occlusionTextureCoordProp)},set:function(e){e>ac.UV1&&no.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(t._occlusionTextureCoordProp,e)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(t._clearCoatProp)},set:function(e){!!this.shaderData.getFloat(t._clearCoatProp)!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(t._clearCoatProp,e)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(t._clearCoatTextureProp)},set:function(e){this.shaderData.setTexture(t._clearCoatTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE")}},{key:"clearCoatRoughness",get:function(){return this.shaderData.getFloat(t._clearCoatRoughnessProp)},set:function(e){this.shaderData.setFloat(t._clearCoatRoughnessProp,e)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(t._clearCoatRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(t._clearCoatRoughnessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE")}},{key:"clearCoatNormalTexture",get:function(){return this.shaderData.getTexture(t._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(t._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),t}(as);au._occlusionTextureIntensityProp=nY.getByName("material_OcclusionIntensity"),au._occlusionTextureCoordProp=nY.getByName("material_OcclusionTextureCoord"),au._occlusionTextureProp=nY.getByName("material_OcclusionTexture"),au._clearCoatProp=nY.getByName("material_ClearCoat"),au._clearCoatTextureProp=nY.getByName("material_ClearCoatTexture"),au._clearCoatRoughnessProp=nY.getByName("material_ClearCoatRoughness"),au._clearCoatRoughnessTextureProp=nY.getByName("material_ClearCoatRoughnessTexture"),au._clearCoatNormalTextureProp=nY.getByName("material_ClearCoatNormalTexture");var ad=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n,ro.find("pbr"))||this)._anisotropyRotation=0,r._iridescenceRange=new tB(100,400),r._sheenEnabled=!1;var r,a=r.shaderData;a.setFloat(t._metallicProp,1),a.setFloat(t._roughnessProp,1),a.setFloat(t._iorProp,1.5),a.setVector3(t._anisotropyInfoProp,new tT(1,0,0)),a.setVector4(t._iridescenceInfoProp,new tI(0,1.3,100,400));var i=new tO(0,0,0);return a.setColor(t._sheenColorProp,i),r._iridescenceRange._onValueChanged=r._onIridescenceRangeChanged.bind(r),i._onValueChanged=function(){var e=i.r+i.g+i.b>0;e!==r._sheenEnabled&&(r._sheenEnabled=e,e?r.shaderData.enableMacro("MATERIAL_ENABLE_SHEEN"):r.shaderData.disableMacro("MATERIAL_ENABLE_SHEEN"))},r}tW(t,e);var n=t.prototype;return n._onIridescenceRangeChanged=function(){var e=this.shaderData.getVector4(t._iridescenceInfoProp);e.z=this._iridescenceRange.x,e.w=this._iridescenceRange.y},n.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(t._anisotropyInfoProp).z},set:function(e){var n=this.shaderData.getVector3(t._anisotropyInfoProp);!!n.z!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),n.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var n=this.shaderData.getVector3(t._anisotropyInfoProp),r=tS.degreeToRadFactor*e;n.x=Math.cos(r),n.y=Math.sin(r)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(t._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(t._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}},{key:"iridescence",get:function(){return this.shaderData.getVector4(t._iridescenceInfoProp).x},set:function(e){e=Math.max(0,Math.min(1,e));var n=this.shaderData.getVector4(t._iridescenceInfoProp);!!n.x!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_IRIDESCENCE"):this.shaderData.enableMacro("MATERIAL_ENABLE_IRIDESCENCE")),n.x=e}},{key:"iridescenceTexture",get:function(){return this.shaderData.getTexture(t._iridescenceTextureProp)},set:function(e){this.shaderData.setTexture(t._iridescenceTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_IRIDESCENCE_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_IRIDESCENCE_TEXTURE")}},{key:"iridescenceIOR",get:function(){return this.shaderData.getVector4(t._iridescenceInfoProp).y},set:function(e){this.shaderData.getVector4(t._iridescenceInfoProp).y=Math.max(e,1)}},{key:"iridescenceThicknessRange",get:function(){return this._iridescenceRange},set:function(e){this._iridescenceRange!==e&&this._iridescenceRange.copyFrom(e)}},{key:"iridescenceThicknessTexture",get:function(){return this.shaderData.getTexture(t._iridescenceThicknessTextureProp)},set:function(e){this.shaderData.setTexture(t._iridescenceThicknessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE")}},{key:"sheenColor",get:function(){return this.shaderData.getColor(t._sheenColorProp)},set:function(e){var n=this.shaderData.getColor(t._sheenColorProp);e!==n&&n.copyFrom(e)}},{key:"sheenRoughness",get:function(){return this.shaderData.getFloat(t._sheenRoughnessProp)},set:function(e){e=Math.max(0,Math.min(1,e)),this.shaderData.setFloat(t._sheenRoughnessProp,e)}},{key:"sheenColorTexture",get:function(){return this.shaderData.getTexture(t._sheenTextureProp)},set:function(e){this.shaderData.setTexture(t._sheenTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SHEEN_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SHEEN_TEXTURE")}},{key:"sheenRoughnessTexture",get:function(){return this.shaderData.getTexture(t._sheenRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(t._sheenRoughnessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE")}}]),t}(au);ad._metallicProp=nY.getByName("material_Metal"),ad._roughnessProp=nY.getByName("material_Roughness"),ad._roughnessMetallicTextureProp=nY.getByName("material_RoughnessMetallicTexture"),ad._iorProp=nY.getByName("material_IOR"),ad._anisotropyInfoProp=nY.getByName("material_AnisotropyInfo"),ad._anisotropyTextureProp=nY.getByName("material_AnisotropyTexture"),ad._iridescenceInfoProp=nY.getByName("material_IridescenceInfo"),ad._iridescenceThicknessTextureProp=nY.getByName("material_IridescenceThicknessTexture"),ad._iridescenceTextureProp=nY.getByName("material_IridescenceTexture"),ad._sheenColorProp=nY.getByName("material_SheenColor"),ad._sheenRoughnessProp=nY.getByName("material_SheenRoughness"),ad._sheenTextureProp=nY.getByName("material_SheenTexture"),ad._sheenRoughnessTextureProp=nY.getByName("material_SheenRoughnessTexture");var ah=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,ro.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new tO(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var n=this.shaderData.getColor(t._specularColorProp);e!==n&&n.copyFrom(e)}},{key:"glossiness",get:function(){return this.shaderData.getFloat(t._glossinessProp)},set:function(e){this.shaderData.setFloat(t._glossinessProp,e)}},{key:"specularGlossinessTexture",get:function(){return this.shaderData.getTexture(t._specularGlossinessTextureProp)},set:function(e){this.shaderData.setTexture(t._specularGlossinessTextureProp,e),e?this.shaderData.enableMacro(t._specularGlossinessTextureMacro):this.shaderData.disableMacro(t._specularGlossinessTextureMacro)}}]),t}(au);ah._specularColorProp=nY.getByName("material_PBRSpecularColor"),ah._glossinessProp=nY.getByName("material_Glossiness"),ah._specularGlossinessTextureProp=nY.getByName("material_SpecularGlossinessTexture"),ah._specularGlossinessTextureMacro=nH.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var a_=/*#__PURE__*/function(e){function t(n){var r,a=(r=e.call(this,n,ro.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new tO(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}}]),t}(as),af=/*#__PURE__*/function(){function e(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new nM,this._dirty=7,n&&n.length!==t.length)throw"deltaNormals length must same with deltaPositions length.";if(r&&r.length!==t.length)throw"deltaTangents length must same with deltaPositions length.";this.weight=e,this._deltaPositions=t,this._deltaNormals=n,this._deltaTangents=r}return e.prototype._releaseData=function(){this._deltaPositions=null,this._deltaNormals=null,this._deltaTangents=null},tG(e,[{key:"deltaPositions",get:function(){return this._deltaPositions},set:function(e){this._deltaPositions=e,this._dirty|=1,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaNormals",get:function(){return this._deltaNormals},set:function(e){this._deltaNormals=e,this._dirty|=2,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaTangents",get:function(){return this._deltaTangents},set:function(e){this._deltaTangents=e,this._dirty|=4,this._dataChangeManager.dispatch(this._dirty,this)}}]),e}(),ap=((ef={})[ef.Position=1]="Position",ef[ef.Normal=2]="Normal",ef[ef.Tangent=4]="Tangent",ef[ef.All=7]="All",ef),am=/*#__PURE__*/function(){function e(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new nM,this._dataChangeManager=new nM,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}var t=e.prototype;return t.addFrame=function(e,t,n,r){if("number"==typeof e){var a=new af(e,t,n,r);return this._addFrame(a),a}this._addFrame(e)},t.clearFrames=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._dataChangeManager.removeListener(this._frameDataChangeListener);e.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},t._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},t._addFrame=function(e){var t=this._frames,n=t.length;if(n>0&&e.deltaPositions.length!==t[n-1].deltaPositions.length)throw"Frame's deltaPositions length must same with before frame deltaPositions length.";this._frames.push(e),this._frameDataChangeListener(ap.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},t._updateUseNormalAndTangent=function(e,t){var n=this._useBlendShapeNormal&&e,r=this._useBlendShapeTangent&&t;(this._useBlendShapeNormal!==n||this._useBlendShapeTangent!==r)&&(this._useBlendShapeNormal=n,this._useBlendShapeTangent=r,this._layoutChangeManager.dispatch(0,this))},t._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},tG(e,[{key:"frames",get:function(){return this._frames}}]),e}(),ag=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._format=t}return tG(e,[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),e}(),av=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=ar.Triangles),this.start=e,this.count=t,this.topology=n},ay=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tW(t,e),t.prototype.dispose=function(){},t}(av),ax=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableVAO=!0,n.instanceCount=0,n.vertexBufferBindings=[],n._vertexElementMap={},n._bufferStructChanged=!1,n._vertexElements=[],n._platformPrimitive=t._hardwareRenderer.createPlatformPrimitive(n),n}tW(t,e);var n=t.prototype;return n.addVertexElement=function(e){var t=this._vertexElementMap,n=this._vertexElements,r=e.attribute,a=t[r];a&&(console.warn("VertexElement "+r+" already exists."),n.splice(n.indexOf(a),1)),t[r]=e,n.push(e),this._bufferStructChanged=!0},n.removeVertexElement=function(e){var t=this._vertexElements,n=t[e];t.splice(e,1),delete this._vertexElementMap[n.attribute],this._bufferStructChanged=!0},n.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},n.setVertexElement=function(e,t){var n=this._vertexElementMap,r=this._vertexElements,a=r[e];a&&delete n[a.attribute],n[t.attribute]=t,r[e]=t,this._bufferStructChanged=!0},n.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,n=this._vertexElements,r=e,a=n.length;r<a;r++){var i=n[r];delete t[i.attribute]}n.length=e},n.setVertexBufferBinding=function(e,t){var n,r=this._getReferCount(),a=this.vertexBufferBindings;r>0&&(null==(n=a[e])||n.buffer._addReferCount(-r),null==t||t.buffer._addReferCount(r)),a[e]=t,this._bufferStructChanged=!0},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this.vertexBufferBindings,r=e.length,a=t+r;n.length<a&&(n.length=a);for(var i=0;i<r;i++)this.setVertexBufferBinding(t+i,e[i])},n.setIndexBufferBinding=function(e){var t=this.indexBufferBinding,n=this._getReferCount();t!==e&&(this._indexBufferBinding=e,n>0&&(null==t||t.buffer._addReferCount(-n)),e?(n>0&&e.buffer._addReferCount(n),this._glIndexType=ae._getGLIndexType(e.format),this._glIndexByteCount=ae._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},n.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},n._addReferCount=function(t){e.prototype._addReferCount.call(this,t);for(var n,r,a=this.vertexBufferBindings,i=0,o=a.length;i<o;i++)null==(r=a[i])||r.buffer._addReferCount(t);null==(n=this.indexBufferBinding)||n._buffer._addReferCount(t)},n._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},tG(t,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t}(ne),ab=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._updateFlagManager=new nM,r._bounds=new tE,r._subMeshes=[],r.name=n,r._primitive=new ax(t),r._onBoundsChanged=r._onBoundsChanged.bind(r);var r,a=r._bounds;return a.min._onValueChanged=r._onBoundsChanged,a.max._onValueChanged=r._onBoundsChanged,r}tW(t,e);var n=t.prototype;return n.addSubMesh=function(e,t,n){return void 0===n&&(n=ar.Triangles),"number"==typeof e&&(e=new ay(e,t,n)),this._subMeshes.push(e),e},n.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},n.clearSubMesh=function(){this._subMeshes.length=0},n._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},n._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},n._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},n._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},n._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},n._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},n._addReferCount=function(t){e.prototype._addReferCount.call(this,t),this._primitive._addReferCount(t)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._primitive.destroy()},n._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},n._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},n._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},tG(t,[{key:"bounds",get:function(){return this._bounds},set:function(e){this._bounds!==e&&this._bounds.copyFrom(e)}},{key:"subMesh",get:function(){return this._subMeshes[0]||null}},{key:"subMeshes",get:function(){return this._subMeshes}}]),t}(t1),aC=((ep={})[ep.Bounds=1]="Bounds",ep[ep.VertexElements=2]="VertexElements",ep),aS=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._stride=t}return tG(e,[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),e}(),aT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}tW(t,e);var n=t.prototype;return n.setVertexElements=function(e){this._setVertexElements(e)},n.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,a=void 0!==r.buffer;a||(r=new aS(e,t));var i=this._primitive.vertexBufferBindings;i.length<=n&&(i.length=n+1),this._setVertexBufferBinding(a?t:n,r)},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this._primitive.vertexBufferBindings,r=e.length,a=t+r;n.length<a&&(n.length=a);for(var i=0;i<r;i++)this._setVertexBufferBinding(t+i,e[i])},n.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new ag(e,t))),this._setIndexBufferBinding(n)},tG(t,[{key:"instanceCount",get:function(){return this._primitive.instanceCount},set:function(e){this._primitive.instanceCount=e}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"indexBufferBinding",get:function(){return this._primitive.indexBufferBinding}},{key:"vertexElements",get:function(){return this._primitive.vertexElements}}]),t}(ab),aA=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._enableVertexColor=!1,n._onMeshChanged=n._onMeshChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){var t=this._mesh;t&&(t.destroyed||this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),e.prototype._onDestroy.call(this)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.mesh=this._mesh},n._prepareRender=function(t){if(!this._mesh){no.error("mesh is null.");return}if(this._mesh.destroyed){no.error("mesh is destroyed.");return}e.prototype._prepareRender.call(this,t)},n._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds;tE.transform(n,this._transformEntity.transform.worldMatrix,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},n._render=function(e){var n=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,a=n._primitive.vertexElements;r.disableMacro(t._uvMacro),r.disableMacro(t._uv1Macro),r.disableMacro(t._normalMacro),r.disableMacro(t._tangentMacro),r.disableMacro(t._enableVertexColorMacro);for(var i=0,o=a.length;i<o;i++)switch(a[i].attribute){case"TEXCOORD_0":r.enableMacro(t._uvMacro);break;case"TEXCOORD_1":r.enableMacro(t._uv1Macro);break;case"NORMAL":r.enableMacro(t._normalMacro);break;case"TANGENT":r.enableMacro(t._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(t._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}var s=this._materials,l=this._engine,c=n.subMeshes,u=l._renderElementPool.get();u.set(this.priority,this._distanceForSort);for(var d=l._subRenderElementPool,h=0,_=c.length;h<_;h++){var f=s[h];if(f){(f.destroyed||f.shader.destroyed)&&(f=this.engine._meshMagentaMaterial);var p=d.get();p.set(this,f,n._primitive,c[h]),u.addSubRenderElement(p)}}e.camera._renderPipeline.pushRenderElement(e,u)},n._setMesh=function(e){var t=this._mesh;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},n._onMeshChanged=function(e){e&aC.Bounds&&(this._dirtyUpdateFlag|=rv.WorldVolume),e&aC.VertexElements&&(this._dirtyUpdateFlag|=2)},tG(t,[{key:"mesh",get:function(){return this._mesh},set:function(e){this._mesh!==e&&this._setMesh(e)}},{key:"enableVertexColor",get:function(){return this._enableVertexColor},set:function(e){e!==this._enableVertexColor&&(this._dirtyUpdateFlag|=2,this._enableVertexColor=e)}}]),t}(e.Renderer);aA._uvMacro=nH.getByName("RENDERER_HAS_UV"),aA._uv1Macro=nH.getByName("RENDERER_HAS_UV1"),aA._normalMacro=nH.getByName("RENDERER_HAS_NORMAL"),aA._tangentMacro=nH.getByName("RENDERER_HAS_TANGENT"),aA._enableVertexColorMacro=nH.getByName("RENDERER_ENABLE_VERTEXCOLOR"),tX([tq],aA.prototype,"_mesh",void 0),tX([tq],aA.prototype,"_onMeshChanged",null);var aE=/*#__PURE__*/function(){function e(e,t){this._blendShapeCount=0,this._blendShapes=[],this._subDataDirtyFlags=[],this._vertexBuffers=[],this._uniformOccupiesCount=0,this._bufferBindingOffset=-1,this._vertexElementOffset=0,this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._storeInVertexBufferInfo=[],this._maxCountSingleVertexBuffer=0,this._lastHostCreatedInfo=new tI,this._canUseTextureStoreData=!0,this._dataTextureInfo=new tT,this._engine=e,this._modelMesh=t,this._canUseTextureStoreData=this._engine._hardwareRenderer.capability.canUseFloatTextureBlendShape,this._updateLayoutChange=this._updateLayoutChange.bind(this)}var t=e.prototype;return t._addBlendShape=function(e){this._blendShapes.push(e),this._blendShapeCount++,e._layoutChangeManager.addListener(this._updateLayoutChange),this._updateLayoutChange(0,e),this._subDataDirtyFlags.push(e._dataChangeManager.createFlag(rf))},t._clearBlendShapes=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._layoutChangeManager.removeListener(this._updateLayoutChange);this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._blendShapes.length=0,this._blendShapeCount=0;for(var r=this._subDataDirtyFlags,a=0,i=r.length;a<i;a++)r[a].destroy();r.length=0},t._updateShaderData=function(t,n){var r=this._blendShapeCount;if(r>0){if(t.enableMacro(e._blendShapeMacro),this._useTextureMode())t.enableMacro(e._blendShapeTextureMacro),t.setTexture(e._blendShapeTextureProperty,this._vertexTexture),t.setVector3(e._blendShapeTextureInfoProperty,this._dataTextureInfo),t.setFloatArray(e._blendShapeWeightsProperty,n.blendShapeWeights),t.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var a=this._getVertexBufferModeSupportCount();if(r>a){var i=n._condensedBlendShapeWeights;i||(i=new Float32Array(a),n._condensedBlendShapeWeights=i),this._filterCondensedBlendShapeWeights(n.blendShapeWeights,i),t.setFloatArray(e._blendShapeWeightsProperty,i),this._modelMesh._primitive.enableVAO=!1,r=a}else t.setFloatArray(e._blendShapeWeightsProperty,n.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;t.disableMacro(e._blendShapeTextureMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?t.enableMacro(e._blendShapeNormalMacro):t.disableMacro(e._blendShapeNormalMacro),this._useBlendTangent?t.enableMacro(e._blendShapeTangentMacro):t.disableMacro(e._blendShapeTangentMacro)}else t.disableMacro(e._blendShapeMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT")},t._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},t._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},t._vertexElementsNeedUpdate=function(){var e=this._getVertexBufferModeSupportCount(),t=this._lastHostCreatedInfo;return Math.min(t.x,e)!==Math.min(this._blendShapeCount,e)||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent},t._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},t._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,n=e._primitive.vertexBufferBindings,r=0,a=Math.max(n.length,t+1);r<a&&(n[r]||r===t);r++);this._bufferBindingOffset=r}},t._addVertexElements=function(e){this._updateVertexBufferIndex();for(var t=this._vertexElementOffset,n=this._bufferBindingOffset,r=0,a=0,i=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());a<i;a++)e._setVertexElement(t++,new at("POSITION_BS"+a,r,r7.Vector3,n)),r+=12,this._useBlendNormal&&(e._setVertexElement(t++,new at("NORMAL_BS"+a,r,r7.Vector3,n)),r+=12),this._useBlendTangent&&(e._setVertexElement(t++,new at("TANGENT_BS"+a,r,r7.Vector3,n)),r+=12);return t},t._update=function(e){var t=this._modelMesh.vertexCount,n=this._useTextureMode(),r=this._isCreateHost(t);r&&(n?this._createTextureArray(t):this._createVertexBuffers(t,e),this._lastHostCreatedInfo.set(this._blendShapeCount,+this._useBlendNormal,+this._useBlendTangent,t)),this._needUpdateData()&&(n?this._updateTextureArray(t,r):this._updateVertexBuffers(t,r))},t._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},t._createVertexBuffers=function(e,t){var n=this._engine,r=this._modelMesh,a=this._blendShapeCount,i=this._vertexBuffers,o=3*this._vertexElementCount,s=4*o,l=Math.floor(255/s),c=Math.ceil(a/l),u=o*e*Math.min(l,a);i.length=c,this._vertices=new Float32Array(u),this._maxCountSingleVertexBuffer=l,this._storeInVertexBufferInfo.length=a;for(var d=this._bufferBindingOffset,h=0;h<c;h++){var _=c-1,f=(h===_?a-_*l:l)*s,p=f*e,m=t?r8.Static:r8.Dynamic,g=new r9(n,an.VertexBuffer,p,m);r._setVertexBufferBinding(d+h,new aS(g,f)),i[h]=g}},t._createTextureArray=function(e){var t=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,r=n*e,a=1;r>t&&(a=Math.ceil(r/t),r=t);var i=this._vertexTexture,o=this._blendShapes.length;i&&i.destroy(),(i=new nu(this._engine,r,a,o,t9.R32G32B32A32,!1)).filterMode=t5.Point,this._vertices=new Float32Array(o*r*a*4),this._vertexTexture=i,this._dataTextureInfo.set(n,r,a)},t._updateVertexBuffers=function(e,t){for(var n=this._blendShapes,r=this._maxCountSingleVertexBuffer,a=this._vertices,i=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,u=this._bufferBindingOffset,d=0,h=n.length;d<h;d++){var _=s[d];if(t||_.flag){var f=n[d].frames,p=f.length,m=f[p-1];if(p>0&&m.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var g=Math.floor(d/r),v=d%r,y=i[g],x=y.byteLength/(4*e),b=v*l,C=o[d];C||(o[d]=C=new tB),C.set(u+g,v*c);for(var S=m.deltaPositions,T=0;T<e;T++){var A=b+x*T,E=S[T];E&&(a[A]=E.x,a[A+1]=E.y,a[A+2]=E.z)}if(b+=3,this._useBlendNormal){var R=m.deltaNormals;if(R)for(var M=0;M<e;M++){var w=b+x*M,P=R[M];P&&(a[w]=P.x,a[w+1]=P.y,a[w+2]=P.z)}b+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=b+x*L,B=F[L];B&&(a[D]=B.x,a[D+1]=B.y,a[D+2]=B.z)}b+=3}(v===r-1||d===h-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},t._updateTextureArray=function(e,t){for(var n=this._blendShapes,r=this._vertexTexture,a=this._vertices,i=this._subDataDirtyFlags,o=0,s=n.length;o<s;o++){var l=i[o],c=r.width*r.height*4;if(t||l.flag){var u=n[o].frames,d=u.length,h=u[d-1];if(d>0&&h.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var _=h.deltaPositions,f=h.deltaNormals,p=h.deltaTangents,m=o*c,g=0;g<e;g++){var v=_[g];if(a[m]=v.x,a[m+1]=v.y,a[m+2]=v.z,m+=4,f){var y=f[g];a[m]=y.x,a[m+1]=y.y,a[m+2]=y.z,m+=4}if(p){var x=p[g];a[m]=x.x,a[m+1]=x.y,a[m+2]=x.z,m+=4}}l.flag=!1}}r.setPixelBuffer(0,a)},t._updateLayoutChange=function(e,t){var n=this._blendShapeCount>1,r=1,a=t._useBlendShapeNormal,i=t._useBlendShapeTangent;n&&(a&&(a=this._useBlendNormal),i&&(i=this._useBlendTangent)),a&&r++,i&&r++,this._useBlendNormal=a,this._useBlendTangent=i,this._vertexElementCount=r},t._attributeModeUpdateVertexElement=function(e,t,n,r){var a=this._vertexElementOffset+this._vertexElementCount*r,i=t[n],o=i.x,s=i.y,l=e[a];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++a];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++a];s+=12,u.bindingIndex=o,u.offset=s}},t._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},t._filterCondensedBlendShapeWeights=function(e,t){for(var n,r=t.length,a=this._modelMesh._primitive.vertexElements,i=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<r)this._attributeModeUpdateVertexElement(a,i,s,s),t[s]=c,c<o&&(o=c,n=s);else if(c>o){this._attributeModeUpdateVertexElement(a,i,s,n),t[n]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<r;u++){var d=t[u];d<o&&(o=d,n=u)}}}},e}();aE._blendShapeMacro=nH.getByName("RENDERER_HAS_BLENDSHAPE"),aE._blendShapeTextureMacro=nH.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),aE._blendShapeNormalMacro=nH.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),aE._blendShapeTangentMacro=nH.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),aE._blendShapeWeightsProperty=nY.getByName("renderer_BlendShapeWeights"),aE._blendShapeTextureProperty=nY.getByName("renderer_BlendShapeTexture"),aE._blendShapeTextureInfoProperty=nY.getByName("renderer_BlendShapeTextureInfo");var aR=((em={}).Position="POSITION",em.Normal="NORMAL",em.Color="COLOR_0",em.Tangent="TANGENT",em.BoneWeight="WEIGHTS_0",em.BoneIndex="JOINTS_0",em.UV="TEXCOORD_0",em.UV1="TEXCOORD_1",em.UV2="TEXCOORD_2",em.UV3="TEXCOORD_3",em.UV4="TEXCOORD_4",em.UV5="TEXCOORD_5",em.UV6="TEXCOORD_6",em.UV7="TEXCOORD_7",em),aM=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._internalVertexBufferIndex=-1,r._vertexCount=0,r._vertexCountDirty=!1,r._dataVersionCounter=0,r._positions=null,r._normals=null,r._colors=null,r._tangents=null,r._uv=null,r._uv1=null,r._uv2=null,r._uv3=null,r._uv4=null,r._uv5=null,r._uv6=null,r._uv7=null,r._boneWeights=null,r._boneIndices=null,r._advancedElementUpdateFlag=0,r._advancedDataUpdateFlag=0,r._advancedVertexDataVersions=Array(14),r._advancedDataSyncToBuffer=!1,r._internalVertexBufferStride=0,r._internalVertexBufferCreatedInfo=new tT(0,0,-1),r._internalVertexElementsOffset=0,r._internalVertexElementsFlags=0,r._vertexBufferInfos=[],r._indices=null,r._indicesFormat=null,r._indicesChangeFlag=!1,r._accessible=!0,r.name=n,r._blendShapeManager=new aE(t,r),r}tW(t,e);var n=t.prototype;return n.setPositions=function(e){var t;(this._positions||e)&&(this._updateAdvancedVertexDataMarks(1,0),this._positions=e,this._vertexCount=null!=(t=null==e?void 0:e.length)?t:0,this._vertexCountDirty=!1)},n.getPositions=function(){var e=this._getVertexElementData(this._positions,aR.Position,0,this._readVector3VertexData);return this._positions=e,e},n.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},n.getNormals=function(){var e=this._getVertexElementData(this._normals,aR.Normal,1,this._readVector3VertexData);return this._normals=e,e},n.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},n.getColors=function(){var e=this._getVertexElementData(this._colors,aR.Color,2,this._readColorVertexData);return this._colors=e,e},n.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},n.getBoneWeights=function(){var e=this._getVertexElementData(this._boneWeights,aR.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=e,e},n.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},n.getBoneIndices=function(){var e=this._getVertexElementData(this._boneIndices,aR.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=e,e},n.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},n.getTangents=function(){var e=this._getVertexElementData(this._tangents,aR.Tangent,3,this._readVector4VertexData);return this._tangents=e,e},n.setUVs=function(e,t){switch(t=null!=t?t:0){case 0:this._beforeSetAdvancedVertexData(e,64,6),this._uv=e;break;case 1:this._beforeSetAdvancedVertexData(e,128,7),this._uv1=e;break;case 2:this._beforeSetAdvancedVertexData(e,256,8),this._uv2=e;break;case 3:this._beforeSetAdvancedVertexData(e,512,9),this._uv3=e;break;case 4:this._beforeSetAdvancedVertexData(e,1024,10),this._uv4=e;break;case 5:this._beforeSetAdvancedVertexData(e,2048,11),this._uv5=e;break;case 6:this._beforeSetAdvancedVertexData(e,4096,12),this._uv6=e;break;case 7:this._beforeSetAdvancedVertexData(e,8192,13),this._uv7=e;break;default:throw"The index of channel needs to be in range [0 - 7]."}},n.getUVs=function(e){switch(e=null!=e?e:0){case 0:var t=this._getVertexElementData(this._uv,aR.UV,6,this._readVector2VertexData);return this._uv=t,t;case 1:var n=this._getVertexElementData(this._uv1,aR.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var r=this._getVertexElementData(this._uv2,aR.UV2,8,this._readVector2VertexData);return this._uv2=r,r;case 3:var a=this._getVertexElementData(this._uv3,aR.UV3,9,this._readVector2VertexData);return this._uv3=a,a;case 4:var i=this._getVertexElementData(this._uv4,aR.UV4,10,this._readVector2VertexData);return this._uv4=i,i;case 5:var o=this._getVertexElementData(this._uv5,aR.UV5,11,this._readVector2VertexData);return this._uv5=o,o;case 6:var s=this._getVertexElementData(this._uv6,aR.UV6,12,this._readVector2VertexData);return this._uv6=s,s;case 7:var l=this._getVertexElementData(this._uv7,aR.UV7,13,this._readVector2VertexData);return this._uv7=l,l}throw"The index of channel needs to be in range [0 - 7]."},n.setIndices=function(e){this._indices!==e&&(this._indices=e,tK(e,Uint8Array)?this._indicesFormat=r6.UInt8:tK(e,Uint16Array)?this._indicesFormat=r6.UInt16:tK(e,Uint32Array)&&(this._indicesFormat=r6.UInt32)),this._indicesChangeFlag=!0},n.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},n.setVertexElements=function(e){this._clearVertexElements();for(var t,n=e.length,r=0;r<n;r++)this._addVertexElement(e[r]);var a=this._primitive._vertexElementMap;a[aR.Position]||this.setPositions(null),a[aR.Normal]||this.setNormals(null),a[aR.Color]||this.setColors(null),a[aR.BoneWeight]||this.setBoneWeights(null),a[aR.BoneIndex]||this.setBoneIndices(null),a[aR.Tangent]||this.setTangents(null),a[aR.UV]||this.setUVs(null,0),a[aR.UV1]||this.setUVs(null,1),a[aR.UV2]||this.setUVs(null,2),a[aR.UV3]||this.setUVs(null,3),a[aR.UV4]||this.setUVs(null,4),a[aR.UV5]||this.setUVs(null,5),a[aR.UV6]||this.setUVs(null,6),a[aR.UV7]||this.setUVs(null,7);var i=this._internalVertexBufferCreatedInfo.z;-1!==i&&(null==(t=this._primitive.vertexBufferBindings[i])||t.buffer.destroy(),this._setVertexBufferBinding(i,null),this._internalVertexBufferCreatedInfo.z=-1),this._internalVertexBufferStride=0,this._internalVertexElementsOffset=n,this._advancedElementUpdateFlag=0,this._vertexCountDirty=!0,this._blendShapeManager._bufferBindingOffset=-1,this._blendShapeManager._vertexElementOffset=n},n.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,a=void 0!==r.buffer;a||(r=new aS(e,t));var i=a?t:n,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=i+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(i,r),i===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),i===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=e.length,r=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=t+n;r.length<i&&(r.length=i,a.length=i);for(var o=0;o<n;o++){var s=t+o;this._setVertexBufferBinding(s,e[o]),s===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),s===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1)}this._vertexCountDirty=!0},n.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},n.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},n.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},n.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},n.uploadData=function(e){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(e),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var t=this._vertexBufferInfos,n=this._primitive.vertexBufferBindings,r=0,a=n.length;r<a;r++){var i=t[r];if(null==i?void 0:i.uploadAdvancedData){var o,s=null==(o=n[r])?void 0:o.buffer;s.setData(s.data),i.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var l,c=this._indices,u=null==(l=this._primitive.indexBufferBinding)?void 0:l._buffer;if(c){if(u&&c.byteLength==u.byteLength)u.setData(c),this._primitive.indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new ag(u,this._indicesFormat));else{null==u||u.destroy();var d=new r9(this._engine,an.IndexBuffer,c);this._setIndexBufferBinding(new ag(d,this._indicesFormat))}}else u&&(u.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var h=this._blendShapeManager;h._blendShapeCount>0&&h._update(e),e&&(this._accessible=!1,this._releaseCache(!1))},n.calculateTangents=function(){var e=this.getPositions(),n=this.getNormals(),r=this.getUVs();if(!n||!r)throw"Set normal and uv before calculation.";for(var a=this._indices,i=this.vertexCount,o=t._tempVec0,s=t._tempVec1,l=t._tempVec2,c=t._tempVec3,u=t._tempVec4,d=a?a.length/3:e.length/3,h=Array(i),_=Array(i),f=0;f<i;f++)h[f]=new tI,_[f]=new tT;for(var p=0;p<d;p++){var m=3*p,g=3*p+1,v=3*p+2;a&&(m=a[m],g=a[g],v=a[v]);var y=e[m],x=e[g],b=e[v],C=r[m],S=r[g],T=r[v];tT.subtract(x,y,o),tT.subtract(b,y,s);var A=S.x-C.x,E=T.x-C.x,R=S.y-C.y,M=T.y-C.y,w=1/(A*M-E*R);tT.scale(o,M*w,l),tT.scale(s,R*w,u),tT.subtract(l,u,l),tT.scale(s,A*w,c),tT.scale(o,E*w,u),tT.subtract(c,u,c);var P=h[m];P.set(P.x+l.x,P.y+l.y,P.z+l.z,1),(P=h[g]).set(P.x+l.x,P.y+l.y,P.z+l.z,1),(P=h[v]).set(P.x+l.x,P.y+l.y,P.z+l.z,1),_[m].add(c),_[g].add(c),_[v].add(c)}for(var F=0;F<i;F++){var L=n[F],D=_[F],B=h[F];l.set(B.x,B.y,B.z),tT.cross(l,D,u);var I=tT.dot(u,L)>0?1:-1;tT.scale(L,tT.dot(l,L),u),tT.subtract(l,u,l),l.normalize(),B.set(l.x,l.y,l.z,I)}this.setTangents(h)},n._setVertexBufferBinding=function(t,n){var r=this,a=this._primitive.vertexBufferBindings,i=this._vertexBufferInfos,o=function(){r._advancedDataSyncToBuffer||(i[t].dataVersion=r._dataVersionCounter++)},s=a[t];s&&s.buffer._dataUpdateManager.removeListener(o),e.prototype._setVertexBufferBinding.call(this,t,n),n?(n.buffer._dataUpdateManager.addListener(o),(i[t]||(i[t]=new aw)).reset(),o()):t+1==a.length&&a.length--},n._getVertexTypedArray=function(e,t){switch(t){case nQ.BYTE:return new Int8Array(e);case nQ.UNSIGNED_BYTE:return new Uint8Array(e);case nQ.SHORT:return new Int16Array(e);case nQ.UNSIGNED_SHORT:return new Uint16Array(e);case nQ.FLOAT:return new Float32Array(e)}},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._releaseCache(!0)},n._getVertexElementData=function(e,t,n,r){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[n])?a:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[n]=l,r.call(this,t))},n._beforeSetAdvancedVertexData=function(e,t,n){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";this._updateAdvancedVertexDataMarks(t,n)},n._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},n._updateInternalVertexBuffer=function(e){var t=this._internalVertexBufferStride,n=this.vertexCount,r=this._internalVertexBufferCreatedInfo,a=t*n;if(r.x*r.y!==a){var i,o=r.z;-1!==o&&(null==(i=this._primitive.vertexBufferBindings[o])||i.buffer.destroy(),this._setVertexBufferBinding(o,null));var s=this._internalVertexBufferIndex,l=t*this.vertexCount>0;if(l){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var c=e?r8.Static:r8.Dynamic,u=new r9(this._engine,an.VertexBuffer,a,c,!0);this._setVertexBufferBinding(s,new aS(u,t))}r.set(t,n,l?s:-1)}},n._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new tB(e[t],e[t+1])})},n._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new tT(e[t],e[t+1],e[t+2])})},n._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new tI(e[t],e[t+1],e[t+2],e[t+3])})},n._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new tO(e[t],e[t+1],e[t+2],e[t+3])})},n._readVertexData=function(e,t){var n=this._primitive,r=n._vertexElementMap[e];if(!r)return null;var a=n.vertexBufferBindings[r.bindingIndex],i=null==a?void 0:a.buffer;if(!i)return null;if(!i.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var o=this.vertexCount,s=r._formatMetaInfo,l=Array(o),c=this._getVertexTypedArray(i.data.buffer,s.type),u=r.offset,d=a.stride,h=0;h<o;h++){var _=(h*d+u)/c.BYTES_PER_ELEMENT,f=t(c,_);s.normalized&&f.scale(s.normalizedScaleFactor),l[h]=f}return l},n._updateAdvancedVertexElement=function(e,t,n){var r=this._primitive._vertexElementMap;if(e){if(!r[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new at(t,i,a,o)),this._internalVertexBufferStride+=this._getAttributeByteLength(t),this._internalVertexElementsFlags|=n,this._blendShapeManager._vertexElementOffset++}}else{var s=r[t];if(s){var l=this._primitive.vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~n):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},n._updateAdvancedVertexElements=function(){var e=this._advancedElementUpdateFlag;1&e&&this._updateAdvancedVertexElement(this._positions,aR.Position,1),2&e&&this._updateAdvancedVertexElement(this._normals,aR.Normal,2),4&e&&this._updateAdvancedVertexElement(this._colors,aR.Color,4),16&e&&this._updateAdvancedVertexElement(this._boneWeights,aR.BoneWeight,16),32&e&&this._updateAdvancedVertexElement(this._boneIndices,aR.BoneIndex,32),8&e&&this._updateAdvancedVertexElement(this._tangents,aR.Tangent,8),64&e&&this._updateAdvancedVertexElement(this._uv,aR.UV,64),128&e&&this._updateAdvancedVertexElement(this._uv1,aR.UV1,128),256&e&&this._updateAdvancedVertexElement(this._uv2,aR.UV2,256),512&e&&this._updateAdvancedVertexElement(this._uv3,aR.UV3,512),1024&e&&this._updateAdvancedVertexElement(this._uv4,aR.UV4,1024),2048&e&&this._updateAdvancedVertexElement(this._uv5,aR.UV5,2048),4096&e&&this._updateAdvancedVertexElement(this._uv6,aR.UV6,4096),8192&e&&this._updateAdvancedVertexElement(this._uv7,aR.UV7,8192)},n._updateVertexElements=function(){var e=this._primitive.vertexElements,t=this._blendShapeManager,n=e.length,r=t._vertexElementOffset;65535&this._advancedElementUpdateFlag&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var a=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(r!==t._vertexElementOffset||a&&t._blendShapeCount>0){var i=t._addVertexElements(this);i<n&&this._setVertexElementsLength(i)}},n._writeVector2AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y)})},n._writeVector3AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z)})},n._writeVector4AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z,e[t+3]=a.w)})},n._writeColorAdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.r,e[t+1]=a.g,e[t+2]=a.b,e[t+3]=a.a)})},n._writeAdvancedVertexData=function(e,t,n){var r,a=this._primitive,i=a._vertexElementMap[e],o=i.bindingIndex,s=a.vertexBufferBindings[o],l=null==s?void 0:s.buffer;if(l){if(!l.readable)throw"Vertex buffer is not readable, can't write vertex data.";var c=null!=(r=this._advancedVertexDataVersions[t])?r:-1,u=this._vertexBufferInfos[o];if(c>u.dataVersion){for(var d=i._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,d.type),_=i.offset,f=s.stride,p=h.BYTES_PER_ELEMENT,m=d.normalized,g=d.size,v=d.normalizedScaleFactor,y=0,x=this._vertexCount;y<x;y++){var b=(y*f+_)/p;if(n(h,b,y),m)for(var C=0;C<g;C++)h[b+C]/=v}u.uploadAdvancedData=!0}}},n._updateAdvancedVertices=function(){var e=this._positions,t=this._normals,n=this._colors,r=this._advancedDataUpdateFlag,a=this._boneWeights,i=this._boneIndices,o=this._tangents,s=this._uv,l=this._uv1,c=this._uv2,u=this._uv3,d=this._uv4,h=this._uv5,_=this._uv6,f=this._uv7;1&r&&this._writeVector3AdvancedVertexData(aR.Position,0,e),t&&2&r&&this._writeVector3AdvancedVertexData(aR.Normal,1,t),n&&4&r&&this._writeColorAdvancedVertexData(aR.Color,2,n),a&&16&r&&this._writeVector4AdvancedVertexData(aR.BoneWeight,4,a),i&&32&r&&this._writeVector4AdvancedVertexData(aR.BoneIndex,5,i),o&&8&r&&this._writeVector4AdvancedVertexData(aR.Tangent,3,o),s&&64&r&&this._writeVector2AdvancedVertexData(aR.UV,6,s),l&&128&r&&this._writeVector2AdvancedVertexData(aR.UV1,7,l),c&&256&r&&this._writeVector2AdvancedVertexData(aR.UV2,8,c),u&&512&r&&this._writeVector2AdvancedVertexData(aR.UV3,9,u),d&&1024&r&&this._writeVector2AdvancedVertexData(aR.UV4,10,d),h&&2048&r&&this._writeVector2AdvancedVertexData(aR.UV5,11,h),_&&4096&r&&this._writeVector2AdvancedVertexData(aR.UV6,12,_),f&&8192&r&&this._writeVector2AdvancedVertexData(aR.UV7,13,f),this._advancedDataUpdateFlag=0},n._getInternalVertexBufferIndex=function(){var e=this._internalVertexBufferIndex;if(-1!==e)return e;for(var t=0,n=this._primitive.vertexBufferBindings,r=n.length;t<r&&n[t];t++);return this._internalVertexBufferIndex=t,t},n._getAttributeFormat=function(e){switch(e){case aR.Position:case aR.Normal:return r7.Vector3;case aR.Color:case aR.BoneWeight:case aR.Tangent:return r7.Vector4;case aR.BoneIndex:return r7.UByte4;case aR.UV:case aR.UV1:case aR.UV2:case aR.UV3:case aR.UV4:case aR.UV5:case aR.UV6:case aR.UV7:return r7.Vector2}},n._getAttributeByteLength=function(e){switch(e){case aR.Position:case aR.Normal:return 12;case aR.Color:case aR.BoneWeight:case aR.Tangent:return 16;case aR.BoneIndex:return 4;case aR.UV:case aR.UV1:case aR.UV2:case aR.UV3:case aR.UV4:case aR.UV5:case aR.UV6:case aR.UV7:return 8}},n._releaseCache=function(e){if(this._positions=null,this._tangents=null,this._normals=null,this._colors=null,this._boneIndices=null,this._boneWeights=null,this._uv=null,this._uv1=null,this._uv2=null,this._uv3=null,this._uv4=null,this._uv5=null,this._uv6=null,this._uv7=null,this._indices=null,this._blendShapeManager._releaseMemoryCache(),!e){null==(t=this._primitive.vertexBufferBindings[this._internalVertexBufferIndex])||t.buffer.markAsUnreadable();for(var t,n=this._dataVersionCounter++,r=this._vertexBufferInfos,a=0,i=r.length;a<i;a++){var o=r[a];o&&(o.dataVersion=n)}}},tG(t,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var e=0,t=this._primitive._vertexElementMap[aR.Position];if(t){var n=this._primitive.vertexBufferBindings[t.bindingIndex];n&&(e=n.buffer.byteLength/n.stride)}this._vertexCount=e,this._vertexCountDirty=!1}return this._vertexCount}},{key:"vertexElements",get:function(){return this._updateVertexElements(),this._primitive.vertexElements}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"blendShapes",get:function(){return this._blendShapeManager._blendShapes}},{key:"blendShapeCount",get:function(){return this._blendShapeManager._blendShapeCount}},{key:"accessible",get:function(){return this._accessible}}]),t}(ab);aM._tempVec0=new tT,aM._tempVec1=new tT,aM._tempVec2=new tT,aM._tempVec3=new tT,aM._tempVec4=new tT;var aw=/*#__PURE__*/function(){function e(){this.dataVersion=-1,this.uploadAdvancedData=!1}return e.prototype.reset=function(){this.uploadAdvancedData=!1},e}(),aP=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).primitiveInfo=n,r}return tW(t,e),t.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:az._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:az._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:az._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:az._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:az._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:az._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:az._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:az._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t}(t2),aF=function(e,t,n){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=n},aL=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return(i=e.call(this,0,r,a)||this).radius=t,i.segments=n,i}return tW(t,e),t}(aF),aD=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return(i=e.call(this,7,r,a)||this).radius=t,i.step=n,i}return tW(t,e),t}(aF),aB=/*#__PURE__*/function(e){function t(t,n,r,a,i){var o;return(o=e.call(this,1,a,i)||this).width=t,o.height=n,o.depth=r,o}return tW(t,e),t}(aF),aI=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,2,i,o)||this).width=t,s.height=n,s.horizontalSegments=r,s.verticalSegments=a,s}return tW(t,e),t}(aF),aO=/*#__PURE__*/function(e){function t(t,n,r,a,i,o,s){var l;return(l=e.call(this,3,o,s)||this).radiusTop=t,l.radiusBottom=n,l.height=r,l.radialSegments=a,l.heightSegments=i,l}return tW(t,e),t}(aF),aN=/*#__PURE__*/function(e){function t(t,n,r,a,i,o,s){var l;return(l=e.call(this,4,o,s)||this).radius=t,l.tubeRadius=n,l.radialSegments=r,l.tubularSegments=a,l.arc=i,l}return tW(t,e),t}(aF),aV=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,5,i,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=a,s}return tW(t,e),t}(aF),ak=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,6,i,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=a,s}return tW(t,e),t}(aF),az=/*#__PURE__*/function(){function e(){}return e.createSphere=function(t,n,r,a){void 0===n&&(n=.5),void 0===r&&(r=18),void 0===a&&(a=!0);var i=new aM(t);e._setSphereData(i,n,r,a,!1);var o=i.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(i,new aL(n,r,o,a))),i},e.createSubdivisionSurfaceSphere=function(t,n,r,a){void 0===n&&(n=.5),void 0===r&&(r=3),void 0===a&&(a=!0);var i=new aM(t);e._setSubdivisionSurfaceSphereData(i,n,r,a,!1);var o=i.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(i,new aD(n,r,o,a))),i},e.createCuboid=function(t,n,r,a,i){void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new aM(t);e._setCuboidData(o,n,r,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(o,new aB(n,r,a,s,i))),o},e.createPlane=function(t,n,r,a,i,o){void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setPlaneData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new aI(n,r,a,i,l,o))),s},e.createCylinder=function(t,n,r,a,i,o,s){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===a&&(a=2),void 0===i&&(i=20),void 0===o&&(o=1),void 0===s&&(s=!0);var l=new aM(t);e._setCylinderData(l,n,r,a,i,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(l,new aO(n,r,a,i,o,c,s))),l},e.createTorus=function(t,n,r,a,i,o,s){void 0===n&&(n=.5),void 0===r&&(r=.1),void 0===a&&(a=30),void 0===i&&(i=30),void 0===o&&(o=360),void 0===s&&(s=!0);var l=new aM(t);e._setTorusData(l,n,r,a,i,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(l,new aN(n,r,a,i,o,c,s))),l},e.createCone=function(t,n,r,a,i,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===a&&(a=20),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setConeData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new aV(n,r,a,i,l,o))),s},e.createCapsule=function(t,n,r,a,i,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===a&&(a=6),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setCapsuleData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new ak(n,r,a,i,l,o))),s},e._setSubdivisionSurfaceSphereData=function(t,n,r,a,i,o){var s=new Float32Array(3*(6*Math.pow(4,r=tS.clamp(Math.floor(r),1,6))+2)),l=new Float32Array(24*Math.pow(4,r));e._subdiveCatmullClark(r,s,l);for(var c=s.length/3,u=l.length/4,d=c+Math.pow(2,r+1)-1,h=new Float32Array(8*(d+16)),_=e._generateIndices(t.engine,c,6*u),f=0,p={},m=0;m<c;m++){var g=3*m,v=s[g],y=s[g+1],x=s[g+2],b=1/Math.sqrt(v*v+y*y+x*x);if(v*=b,y*=b,x*=b,h[g=8*m]=v*n,h[g+1]=y*n,h[g+2]=x*n,h[g+3]=v,h[g+4]=y,h[g+5]=x,h[g+6]=(Math.PI-Math.atan2(x,v))/(2*Math.PI),h[g+7]=Math.acos(y)/Math.PI,0===h[g+6]){var C=8*(c+f++);h.set(h.subarray(g,g+8),C),h[C+6]=1,p[g/8]=C/8}}var S=0;this._spherePoleIdx=0;for(var T=0;T<u;T++){var A=4*T,E=l[A],R=l[A+1],M=l[A+2],w=l[A+3],P=8*E,F=8*R,L=8*M,D=8*w;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(E=p[E]),0===h[F+6]&&(R=p[R]),0===h[L+6]&&(M=p[M]),0===h[D+6]&&(w=p[w])),_[S]=E,_[S+1]=R,_[S+2]=M,this._generateAndReplacePoleUV(_,h,S,d),_[S+3]=E,_[S+4]=M,_[S+5]=w,this._generateAndReplacePoleUV(_,h,S+3,d),S+=6}if(!i){var B=t.bounds;B.min.set(-n,-n,-n),B.max.set(n,n,n)}e._initialize(t,h,_,a,i,o)},e._setSphereData=function(t,n,r,a,i,o){for(var s=(r=Math.max(2,Math.floor(r)))+1,l=s*s,c=r*r,u=e._generateIndices(t.engine,l,6*c),d=Math.PI,h=2*d,_=1/s,f=1/r,p=new Float32Array(8*l),m=0;m<l;++m){var g=m%s*f,v=(m*_|0)*f,y=g*h,x=v*d,b=Math.sin(x),C=-n*Math.cos(y)*b,S=n*Math.cos(x),T=n*Math.sin(y)*b,A=8*m;p[A++]=C,p[A++]=S,p[A++]=T,p[A++]=C,p[A++]=S,p[A++]=T,p[A++]=g,p[A++]=v}for(var E=0,R=0;R<c;++R){var M=R%r,w=(R*f|0)*s+M,P=w+1,F=w+s,L=F+1;u[E++]=P,u[E++]=w,u[E++]=L,u[E++]=w,u[E++]=F,u[E++]=L}if(!i){var D=t.bounds;D.min.set(-n,-n,-n),D.max.set(n,n,n)}e._initialize(t,p,u,a,i,o)},e._subdiveCatmullClark=function(t,n,r){var a=new Map,i=[];n.set(e._sphereSeedPositions),r.set(e._sphereSeedCells);for(var o=0;o<t;o++){var s=6*Math.pow(4,o),l=4*s+2;a.clear(),i.length=0;for(var c=0;c<s;c++){for(var u=i[c]={facePoint:new tT,adjacentEdges:[,,,,]},d=0;d<4;d++){var h=3*r[4*c+d];u.facePoint.x+=.25*n[h],u.facePoint.y+=.25*n[h+1],u.facePoint.z+=.25*n[h+2]}for(var _=0;_<4;_++){var f=r[4*c+_],p=r[4*c+(_+1)%4],m=Math.min(f,p)*l+Math.max(f,p);if(!a.has(m)){var g={edgePoint:new tT,edgePointIndex:void 0},v=3*f,y=3*p;g.edgePoint.set(.25*(n[v]+n[y]),.25*(n[v+1]+n[y+1]),.25*(n[v+2]+n[y+2])),a.set(m,g)}var x=a.get(m);u.adjacentEdges[_]=x;var b=x.edgePoint,C=u.facePoint;b.x+=.25*C.x,b.y+=.25*C.y,b.z+=.25*C.z}}var S=s+2,T=S+s,A=0;this._sphereEdgeIdx=0;for(var E=r.slice(0,4*s),R=0;R<s;R++){var M=i[R];M.facePoint.copyToArray(n,3*(S+R));for(var w=S+R,P=void 0,F=void 0,L=void 0,D=0;D<4;D++){var B=E[A++];switch(D){case 0:var I=M.adjacentEdges[D%4],O=M.adjacentEdges[(D+3)%4];F=this._calculateEdgeIndex(n,I,T),L=P=this._calculateEdgeIndex(n,O,T);break;case 1:case 2:var N=M.adjacentEdges[D%4];P=F,F=this._calculateEdgeIndex(n,N,T);break;case 3:P=F,F=L}var V=4*(4*R+D);r[V]=B,r[V+1]=F,r[V+2]=w,r[V+3]=P}}}},e._generateAndReplacePoleUV=function(e,t,n,r){var a=t[8*e[n]+7];if(0===a||1===a){var i=8*e[n],o=8*(r+this._spherePoleIdx);t.set(t.subarray(i,i+8),o),t[o+6]=.5*(t[i+6]+t[8*e[n+1]+6]+t[8*e[n+2]+6]-.5),e[n]=r+this._spherePoleIdx++}},e._calculateEdgeIndex=function(t,n,r){if(void 0!==n.edgePointIndex)return n.edgePointIndex;n.edgePoint.copyToArray(t,3*(r+e._sphereEdgeIdx));var a=r+e._sphereEdgeIdx++;return n.edgePointIndex=a,a},e._setCuboidData=function(t,n,r,a,i,o,s){var l=n/2,c=r/2,u=a/2,d=new Float32Array(192);d[0]=-l,d[1]=c,d[2]=-u,d[6]=0,d[7]=0,d[8]=l,d[9]=c,d[10]=-u,d[14]=1,d[15]=0,d[16]=l,d[17]=c,d[18]=u,d[22]=1,d[23]=1,d[24]=-l,d[25]=c,d[26]=u,d[30]=0,d[31]=1;for(var h=0;h<4;h++){var _=8*h+3;d[_++]=0,d[_++]=1,d[_++]=0}d[32]=-l,d[33]=-c,d[34]=-u,d[38]=0,d[39]=1,d[40]=l,d[41]=-c,d[42]=-u,d[46]=1,d[47]=1,d[48]=l,d[49]=-c,d[50]=u,d[54]=1,d[55]=0,d[56]=-l,d[57]=-c,d[58]=u,d[62]=0,d[63]=0;for(var f=0;f<4;f++){var p=8*f+35;d[p++]=0,d[p++]=-1,d[p++]=0}d[64]=-l,d[65]=c,d[66]=-u,d[70]=0,d[71]=0,d[72]=-l,d[73]=c,d[74]=u,d[78]=1,d[79]=0,d[80]=-l,d[81]=-c,d[82]=u,d[86]=1,d[87]=1,d[88]=-l,d[89]=-c,d[90]=-u,d[94]=0,d[95]=1;for(var m=0;m<4;m++){var g=8*m+67;d[g++]=-1,d[g++]=0,d[g++]=0}d[96]=l,d[97]=c,d[98]=-u,d[102]=1,d[103]=0,d[104]=l,d[105]=c,d[106]=u,d[110]=0,d[111]=0,d[112]=l,d[113]=-c,d[114]=u,d[118]=0,d[119]=1,d[120]=l,d[121]=-c,d[122]=-u,d[126]=1,d[127]=1;for(var v=0;v<4;v++){var y=8*v+99;d[y++]=1,d[y++]=0,d[y++]=0}d[128]=-l,d[129]=c,d[130]=u,d[134]=0,d[135]=0,d[136]=l,d[137]=c,d[138]=u,d[142]=1,d[143]=0,d[144]=l,d[145]=-c,d[146]=u,d[150]=1,d[151]=1,d[152]=-l,d[153]=-c,d[154]=u,d[158]=0,d[159]=1;for(var x=0;x<4;x++){var b=8*x+131;d[b++]=0,d[b++]=0,d[b++]=1}d[160]=-l,d[161]=c,d[162]=-u,d[166]=1,d[167]=0,d[168]=l,d[169]=c,d[170]=-u,d[174]=0,d[175]=0,d[176]=l,d[177]=-c,d[178]=-u,d[182]=0,d[183]=1,d[184]=-l,d[185]=-c,d[186]=-u,d[190]=1,d[191]=1;for(var C=0;C<4;C++){var S=8*C+163;d[S++]=0,d[S++]=0,d[S++]=-1}var T=new Uint16Array(36);if(T[0]=0,T[1]=2,T[2]=1,T[3]=2,T[4]=0,T[5]=3,T[6]=4,T[7]=6,T[8]=7,T[9]=6,T[10]=4,T[11]=5,T[12]=8,T[13]=10,T[14]=9,T[15]=10,T[16]=8,T[17]=11,T[18]=12,T[19]=14,T[20]=15,T[21]=14,T[22]=12,T[23]=13,T[24]=16,T[25]=18,T[26]=17,T[27]=18,T[28]=16,T[29]=19,T[30]=20,T[31]=22,T[32]=23,T[33]=22,T[34]=20,T[35]=21,!o){var A=t.bounds;A.min.set(-l,-c,-u),A.max.set(l,c,u)}e._initialize(t,d,T,i,o,s)},e._setPlaneData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.max(1,Math.floor(a)))+1,u=(i=Math.max(1,Math.floor(i)))+1,d=n/2,h=r/2,_=n/a,f=r/i,p=c*u,m=i*a,g=e._generateIndices(t.engine,p,6*m),v=1/c,y=1/a,x=1/i,b=new Float32Array(8*p),C=0;C<p;++C){var S=C%c,T=C*v|0,A=8*C;b[A++]=S*_-d,b[A++]=0,b[A++]=T*f-h,b[A++]=0,b[A++]=1,b[A++]=0,b[A++]=S*y,b[A++]=T*x}for(var E=0,R=0;R<m;++R){var M=R%a,w=(R*y|0)*c+M,P=w+1,F=w+c,L=F+1;g[E++]=w,g[E++]=F,g[E++]=P,g[E++]=F,g[E++]=L,g[E++]=P}if(!s){var D=t.bounds;D.min.set(-d,0,-h),D.max.set(d,0,h)}e._initialize(t,b,g,o,s,l)},e._setCylinderData=function(t,n,r,a,i,o,s,l,c){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===a&&(a=2),void 0===i&&(i=20),void 0===o&&(o=1);for(var u=(i=Math.floor(i))+1,d=(o=Math.floor(o))+1,h=.5*a,_=a/o,f=u*d,p=i*o,m=2*i,g=f+2+m,v=e._generateIndices(t.engine,g,6*p+3*m),y=1/u,x=1/i,b=1/o,C=new Float32Array(8*g),S=0,T=Math.PI,A=2*Math.PI,E=r-n,R=E/a,M=E/o,w=0;w<f;++w){var P=w%u,F=w*y|0,L=P*x,D=F*b,B=T+L*A,I=Math.sin(B),O=Math.cos(B),N=r-F*M,V=N*I,k=F*_-h,z=N*O,U=8*w;C[U++]=V,C[U++]=k,C[U++]=z,C[U++]=I,C[U++]=R,C[U++]=O,C[U++]=L,C[U++]=1-D}for(var G=0;G<p;++G){var H=G%i,W=(G*x|0)*u+H,j=W+1,X=W+u,K=X+1;v[S++]=j,v[S++]=X,v[S++]=W,v[S++]=j,v[S++]=K,v[S++]=X}var Y=8*f;C[Y++]=0,C[Y++]=-h,C[Y++]=0,C[Y++]=0,C[Y++]=-1,C[Y++]=0,C[Y++]=.5,C[Y++]=.5,C[Y++]=0,C[Y++]=h,C[Y++]=0,C[Y++]=0,C[Y++]=1,C[Y++]=0,C[Y++]=.5,C[Y++]=.5,Y=(f+2)*8;for(var q=1/(2*n),Q=1/(2*r),J=u*o,Z=0;Z<i;++Z){var $=8*Z,ee=C[$],et=C[$+2];C[Y++]=ee,C[Y++]=-h,C[Y++]=et,C[Y++]=0,C[Y++]=-1,C[Y++]=0,C[Y++]=ee*Q+.5,C[Y++]=.5-et*Q;var en=(Z+J)*8;ee=C[en],et=C[en+2],C[Y++]=ee,C[Y++]=h,C[Y++]=et,C[Y++]=0,C[Y++]=1,C[Y++]=0,C[Y++]=ee*q+.5,C[Y++]=.5-et*q}for(var er=f+1,ea=f+2,ei=ea+1,eo=0;eo<i;++eo){var es=2*eo,el=eo===i-1?0:es+2;v[S++]=f,v[S++]=ea+el,v[S++]=ea+es,v[S++]=er,v[S++]=ei+es,v[S++]=ei+el}if(!l){var ec=t.bounds,eu=Math.max(n,r);ec.min.set(-eu,-h,-eu),ec.max.set(eu,h,eu)}e._initialize(t,C,v,s,l,c)},e._setTorusData=function(t,n,r,a,i,o,s,l,c){var u=((a=Math.floor(a))+1)*((i=Math.floor(i))+1),d=a*i,h=e._generateIndices(t.engine,u,6*d),_=new Float32Array(8*u);o=o/180*Math.PI;for(var f=0,p=e._tempVec30,m=0;m<=a;m++)for(var g=0;g<=i;g++){var v=g/i*o,y=m/a*Math.PI*2,x=Math.cos(y),b=Math.cos(v),C=Math.sin(v),S=(n+r*x)*b,T=(n+r*x)*C,A=r*Math.sin(y);_[f++]=S,_[f++]=T,_[f++]=A;var E=n*b,R=n*C;p.set(S-E,T-R,A).normalize(),_[f++]=p.x,_[f++]=p.y,_[f++]=p.z,_[f++]=g/i,_[f++]=m/a}f=0;for(var M=1;M<=a;M++)for(var w=1;w<=i;w++){var P=(i+1)*M+w-1,F=(i+1)*(M-1)+w-1,L=(i+1)*(M-1)+w,D=(i+1)*M+w;h[f++]=P,h[f++]=F,h[f++]=D,h[f++]=F,h[f++]=L,h[f++]=D}if(!l){var B=t.bounds,I=n+r;B.min.set(-I,-I,-r),B.max.set(I,I,r)}e._initialize(t,_,h,s,l,c)},e._setConeData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.floor(a))+1,u=(i=Math.floor(i))+1,d=.5*r,h=r/i,_=c*u,f=a*i,p=_+1+a,m=e._generateIndices(t.engine,p,6*f+3*a),g=1/c,v=1/a,y=1/i,x=new Float32Array(8*p),b=0,C=Math.PI,S=2*Math.PI,T=n/r,A=0;A<_;++A){var E=A%c,R=A*g|0,M=E*v,w=R*y,P=C+M*S,F=Math.sin(P),L=Math.cos(P),D=n-w*n,B=D*F,I=R*h-d,O=D*L,N=8*A;x[N++]=B,x[N++]=I,x[N++]=O,x[N++]=F,x[N++]=T,x[N++]=L,x[N++]=M,x[N++]=1-w}for(var V=0;V<f;++V){var k=V%a,z=(V*v|0)*c+k,U=z+1,G=z+c,H=G+1;m[b++]=U,m[b++]=G,m[b++]=z,m[b++]=U,m[b++]=H,m[b++]=G}var W=8*_;x[W++]=0,x[W++]=-d,x[W++]=0,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=.5,x[W++]=.5,W=(_+1)*8;for(var j=1/(2*n),X=0;X<a;++X){var K=x[8*X],Y=x[8*X+2];x[W++]=K,x[W++]=-d,x[W++]=Y,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=K*j+.5,x[W++]=.5-Y*j}for(var q=_+1,Q=0;Q<a;++Q){var J=Q,Z=Q===a-1?0:J+1;m[b++]=_,m[b++]=q+Z,m[b++]=q+J}if(!s){var $=t.bounds;$.min.set(-n,-d,-n),$.max.set(n,d,n)}e._initialize(t,x,m,o,s,l)},e._setCapsuleData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.max(2,Math.floor(a)))+1,u=(i=Math.floor(i))+1,d=.5*r,h=r/i,_=c*u,f=a*i,p=c*c,m=a*a,g=_+2*p,v=e._generateIndices(t.engine,g,(f+2*m)*6),y=1/c,x=1/a,b=1/i,C=Math.PI,S=2*Math.PI,T=new Float32Array(8*g),A=0,E=0;E<_;++E){var R=E%c,M=E*y|0,w=R*x,P=M*b,F=C+w*S,L=Math.sin(F),D=Math.cos(F),B=8*E;T[B++]=n*L,T[B++]=M*h-d,T[B++]=n*D,T[B++]=L,T[B++]=0,T[B++]=D,T[B++]=w,T[B++]=1-P}for(var I=0;I<f;++I){var O=I%a,N=(I*x|0)*c+O,V=N+1,k=N+c,z=k+1;v[A++]=V,v[A++]=k,v[A++]=N,v[A++]=V,v[A++]=z,v[A++]=k}if(e._createCapsuleCap(n,r,a,C,S,_,1,T,v,A),e._createCapsuleCap(n,r,a,C,-S,_+p,-1,T,v,A+6*m),!s){var U=t.bounds;U.min.set(-n,-n-d,-n),U.max.set(n,n+d,n)}e._initialize(t,T,v,o,s,l)},e._initialize=function(e,t,n,r,a,i){if(a)i.setData(t),e.setIndices(n),e.uploadData(r);else{var o=[new at(aR.Position,0,r7.Vector3,0),new at(aR.Normal,12,r7.Vector3,0),new at(aR.UV,24,r7.Vector2,0)];e.setVertexElements(o);var s=new r9(e.engine,an.VertexBuffer,t,r8.Static,!0);e.setVertexBufferBinding(s,32,0),e.setIndices(n),e.calculateTangents(),e.uploadData(r),e.addSubMesh(0,n.length)}},e._generateIndices=function(e,t,n){var r=null;if(t>65535){if(e._hardwareRenderer.canIUse(nJ.elementIndexUint))r=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else r=new Uint16Array(n);return r},e._createCapsuleCap=function(e,t,n,r,a,i,o,s,l,c){for(var u=n+1,d=.5*t*o,h=u*u,_=n*n,f=1/u,p=1/n,m=0;m<h;++m){var g=m%u*p,v=(m*f|0)*p,y=r+g*a,x=v*Math.PI*.5,b=Math.sin(x),C=e*Math.sin(y)*b,S=e*Math.cos(x)*o+d,T=e*Math.cos(y)*b,A=(m+i)*8;s[A++]=C,s[A++]=S,s[A++]=T,s[A++]=C,s[A++]=S-d,s[A++]=T,s[A++]=g,s[A++]=v}for(var E=0;E<_;++E){var R=E%n,M=(E*p|0)*u+R+i,w=M+1,P=M+u,F=P+1;l[c++]=w,l[c++]=M,l[c++]=F,l[c++]=M,l[c++]=P,l[c++]=F}},e}();function aU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(aU=function(){return!!e})()}function aG(e,t,n){return(aG=aU()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&tH(a,n.prototype),a}).apply(null,arguments)}az._tempVec30=new tT,az._sphereSeedPositions=new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1]),az._sphereSeedCells=new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1]),az._sphereEdgeIdx=0,az._spherePoleIdx=0;var aH=/*#__PURE__*/function(){function e(){}return e.cloneComponent=function(e,t,n,r,a){var i=t$.getCloneMode(e.constructor);for(var o in e)t$.cloneProperty(e,t,o,i[o],n,r,a);e._cloneTo&&e._cloneTo(t,n,r)},e}(),aW=/*#__PURE__*/function(e){function t(t,n){for(var r,a=arguments.length,i=Array(a>2?a-2:0),o=2;o<a;o++)i[o-2]=arguments[o];(r=e.call(this,t)||this).layer=rE.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new rC,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._isTemplate=!1,r._updateFlagManager=new nM,r._parent=null,r._invModelMatrix=new tL,r.name=n;for(var s=0,l=i.length;s<l;s++)r.addComponent(i[s]);return r._transform||r.addComponent(rp),r._inverseWorldMatFlag=r.registerWorldChangeFlag(),r}tW(t,e);var n=t.prototype;return n.addComponent=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];rd._addCheck(this,e);var a=aG(e,[].concat([this],n));if(this._components.push(a),tK(a,rp)){var i=this._transform;this._transform=a,null==i||i.destroy()}return a._setActive(!0,rc.All),a},n.getComponent=function(e){for(var t=this._components,n=0,r=t.length;n<r;n++){var a=t[n];if(tK(a,e))return a}return null},n.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];tK(i,e)&&t.push(i)}return t},n.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},n.addChild=function(e,n){var r;if("number"==typeof e?r=e:(r=void 0,n=e),n._isRoot){n._scene._removeFromEntityList(n),n._isRoot=!1,this._addToChildrenList(r,n),n._parent=this;var a=n._scene,i=this._scene,o=rc.None;!this._isActiveInHierarchy&&n._isActiveInHierarchy&&(o|=rc.Hierarchy),n._isActiveInScene&&(this._isActiveInScene?a!==i&&(o|=rc.Scene):o|=rc.Scene),o&&n._processInActive(o),n._scene!==i&&t._traverseSetOwnerScene(n,i);var s=rc.None;n._isActive&&(this._isActiveInHierarchy&&(n._isActiveInHierarchy||(s|=rc.Hierarchy)),this._isActiveInScene&&(n._isActiveInScene&&a===i||(s|=rc.Scene))),s&&n._processActive(s),n._setTransformDirty()}else n._setParent(this,r)},n.removeChild=function(e){e._setParent(null)},n.getChild=function(e){return this._children[e]},n.findByName=function(e){if(e===this.name)return this;for(var t=this._children,n=0,r=t.length;n<r;n++){var a=t[n].findByName(e);if(a)return a}return null},n.findByPath=function(e){for(var n=e.split("/"),r=this,a=0,i=n.length;a<i;++a){var o=n[a];if(o&&!(r=t._findChildByName(r,o)))return null}return r},n.createChild=function(e){var n=this._transform,r=n?new t(this.engine,e,n.constructor):new t(this.engine,e);return r.layer=this.layer,r.parent=this,r},n.clearChildren=function(){for(var e=this._children,n=e.length-1;n>=0;n--){var r=e[n];r._parent=null;var a=rc.None;r._isActiveInHierarchy&&(a|=rc.Hierarchy),r._isActiveInScene&&(a|=rc.Scene),a&&r._processInActive(a),t._traverseSetOwnerScene(r,null)}e.length=0},n.clone=function(){var e=this._createCloneEntity();return this._parseCloneEntity(this,e,this,e,new Map),e},n.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(rf)},n._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},n._createCloneEntity=function(){var e=this._transform,n=e?new t(this.engine,this.name,e.constructor):new t(this.engine,this.name),r=this._templateResource;r&&(n._templateResource=r,r._addReferCount(1)),n.layer=this.layer,n._isActive=this._isActive,n.transform._copyFrom(this.transform);for(var a=this._children,i=0,o=a.length;i<o;i++)n.addChild(a[i]._createCloneEntity());return n},n._parseCloneEntity=function(e,t,n,r,a){for(var i=e._children,o=t._children,s=0,l=i.length;s<l;s++)this._parseCloneEntity(i[s],o[s],n,r,a);for(var c=e._components,u=0,d=c.length;u<d;u++){var h=c[u];if(!tK(h,rp)){var _=t.addComponent(h.constructor);aH.cloneComponent(h,_,n,r,a)}}},n.destroy=function(){if(!this._destroyed){e.prototype.destroy.call(this),this._templateResource&&(this._isTemplate||this._templateResource._addReferCount(-1),this._templateResource=null);for(var t=this._components,n=t.length-1;n>=0;n--)t[n].destroy();this._components.length=0;for(var r=this._children;r.length>0;)r[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},n._removeComponent=function(e){rd._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},n._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},n._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},n._removeFromParent=function(){var e=this._parent;if(null!=e){var t=e._children,n=this._siblingIndex;t.splice(n,1);for(var r=t.length;n<r;n++)t[n]._siblingIndex--;this._parent=null,this._siblingIndex=-1}},n._processActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!0,e)},n._processInActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setInActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!1,e)},n._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},n._addToChildrenList=function(e,t){var n=this._children,r=n.length;if(void 0===e)t._siblingIndex=r,n.push(t);else{if(e<0||e>r)throw"The index "+e+" is out of child list bounds "+r;t._siblingIndex=e,n.splice(e,0,t);for(var a=e+1,i=r+1;a<i;a++)n[a]._siblingIndex++}},n._setParent=function(e,n){var r=this._parent;if(e!==r){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(n,this);var a=this._scene,i=e._scene,o=rc.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(o|=rc.Hierarchy),e._isActiveInScene?this._isActiveInScene&&a!==i&&(o|=rc.Scene):this._isActiveInScene&&(o|=rc.Scene),o&&this._processInActive(o),a!==i&&t._traverseSetOwnerScene(this,i);var s=rc.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(s|=rc.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&a===i||(s|=rc.Scene))),s&&this._processActive(s)}else{var l=rc.None;this._isActiveInHierarchy&&(l|=rc.Hierarchy),this._isActiveInScene&&(l|=rc.Scene),l&&this._processInActive(l),r&&t._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},n._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];tK(r,e)&&t.push(r)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},n._setActiveComponents=function(e,t){for(var n=this._activeChangedComponents,r=0,a=n.length;r<a;++r)n[r]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(n),this._activeChangedComponents=null},n._setActiveInHierarchy=function(e,t){t&rc.Hierarchy&&(this._isActiveInHierarchy=!0),t&rc.Scene&&(this._isActiveInScene=!0);for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];(i.enabled||!i._awoken)&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setActiveInHierarchy(e,t)}},n._setInActiveInHierarchy=function(e,t){t&rc.Hierarchy&&(this._isActiveInHierarchy=!1),t&rc.Scene&&(this._isActiveInScene=!1);for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];i.enabled&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setInActiveInHierarchy(e,t)}},n._setSiblingIndex=function(e,t){if((t=Math.min(t,e.length-1))<0)throw"Sibling index "+t+" should large than 0";if(this._siblingIndex!==t){var n=this._siblingIndex;if(t<n)for(var r=n;r>=t;r--){var a=r==t?this:e[r-1];e[r]=a,a._siblingIndex=r}else for(var i=n;i<=t;i++){var o=i==t?this:e[i+1];e[i]=o,o._siblingIndex=i}}},n.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(tL.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t._findChildByName=function(e,t){for(var n=e._children,r=n.length-1;r>=0;r--){var a=n[r];if(a.name===t)return a}return null},t._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=n.length-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},t._getEntityHierarchyPath=function(e,t,n){for(n.length=0;t!==e;){var r=t.parent;if(!r)return!1;n.push(t.siblingIndex),t=r}return!0},t._getEntityByHierarchyPath=function(e,t){for(var n=e,r=t.length-1;r>=0;r--)n=n.children[t[r]];return n},tG(t,[{key:"transform",get:function(){return this._transform}},{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,n=rc.None;this._isRoot&&this._scene._isActiveInEngine?n|=rc.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=rc.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=rc.Scene)),n&&this._processActive(n)}else{var r=rc.None;this._isActiveInHierarchy&&(r|=rc.Hierarchy),this._isActiveInScene&&(r|=rc.Scene),r&&this._processInActive(r)}}}},{key:"isActiveInHierarchy",get:function(){return this._isActiveInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this._setParent(e)}},{key:"children",get:function(){return this._children}},{key:"childCount",get:function(){return this._children.length}},{key:"scene",get:function(){return this._scene}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(e){if(-1===this._siblingIndex)throw"The entity "+this.name+" is not in the hierarchy";this._setSiblingIndex(this._isRoot?this._scene._rootEntities:this._parent._children,e)}}]),t}(t0),aj=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n.inverseBindMatrices=[],n._updatedManager=new nM,n._bones=[],n._updateMark=-1,n.joints=[],n}tW(t,e);var n=t.prototype;return n._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,n=this.bones,r=this.inverseBindMatrices,a=this._skinMatrices,i=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=n.length-1;o>=0;o--){var s=n[o],l=16*o;s?nT._floatMatrixMultiply(s.transform.worldMatrix,r[o].elements,0,a,l):a.set(r[o].elements,l),nT._floatMatrixMultiply(i,a,l,a,l)}this._updateMark=e.engine.time.frameCount}},n._cloneTo=function(e,t,n){var r=[],a=this.rootBone;if(a){var i=aW._getEntityHierarchyPath(t,a,r);e.rootBone=i?aW._getEntityByHierarchyPath(n,r):a}var o=this.bones;if(o.length>0){for(var s=o.length,l=Array(s),c=0;c<s;c++){var u=o[c],d=aW._getEntityHierarchyPath(t,u,r);l[c]=d?aW._getEntityByHierarchyPath(n,r):u}e.bones=l}},tG(t,[{key:"rootBone",get:function(){return this._rootBone},set:function(e){this._rootBone!==e&&(this._updatedManager.dispatch(1,e),this._rootBone=e)}},{key:"bones",get:function(){return this._bones},set:function(e){var t,n=this._bones,r=null!=(t=null==e?void 0:e.length)?t:0,a=n.length;n.length=r;for(var i=0;i<r;i++)n[i]=e[i];a!==r&&(this._skinMatrices=new Float32Array(16*r),this._updatedManager.dispatch(0,r))}},{key:"skeleton",get:function(){var e;return null==(e=this.rootBone)?void 0:e.name},set:function(e){var t=this._rootBone;t&&(t.name=e)}}]),t}(t0);tX([tZ],aj.prototype,"inverseBindMatrices",void 0),tX([tq],aj.prototype,"_skinMatrices",void 0),tX([tq],aj.prototype,"_updatedManager",void 0),tX([tq],aj.prototype,"_rootBone",void 0),tX([tq],aj.prototype,"_bones",void 0),tX([tq],aj.prototype,"_updateMark",void 0);var aX=((eg={})[eg.BoneCountChanged=0]="BoneCountChanged",eg[eg.RootBoneChanged=1]="RootBoneChanged",eg),aK=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._localBounds=new tE,n._jointDataCreateCache=new tB(-1,-1),n._skin=null;var n,r=n.entity.engine._hardwareRenderer,a=r.renderStates.getParameter(r.gl.MAX_VERTEX_UNIFORM_VECTORS);a=Math.min(a,r._options._maxAllowSkinUniformVectorCount),n._maxVertexUniformVectors=a,n._onLocalBoundsChanged=n._onLocalBoundsChanged.bind(n),n._onSkinUpdated=n._onSkinUpdated.bind(n);var i=n._localBounds;return i.min._onValueChanged=n._onLocalBoundsChanged,i.max._onValueChanged=n._onLocalBoundsChanged,n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){var t;e.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(t=this._jointTexture)||t.destroy(),this._jointTexture=null},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),this.skin&&t._applySkin(null,t.skin),this._blendShapeWeights&&(t._blendShapeWeights=this._blendShapeWeights.slice())},n._update=function(n){var r=this.skin;(null==r?void 0:r.bones.length)>0&&r._updateSkinMatrices(this);var a=this.shaderData,i=this.mesh._blendShapeManager;i._updateShaderData(a,this);var o=null==r?void 0:r.bones;if(o){var s=i._uniformOccupiesCount,l=o.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var d,h=Math.ceil((this._maxVertexUniformVectors-(44+s))/4);if(l>h){var _,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(_=this._jointTexture)||_.destroy(),this._jointTexture=new nc(f,4,l,t9.R32G32B32A32,!1),this._jointTexture.filterMode=t5.Point,this._jointTexture.isGCIgnored=!0),a.disableMacro("RENDERER_JOINTS_NUM"),a.enableMacro("RENDERER_USE_JOINT_TEXTURE"),a.setTexture(t._jointSamplerProperty,this._jointTexture)):no.error("component's joints count("+l+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+h+".",this)}else null==(d=this._jointTexture)||d.destroy(),a.disableMacro("RENDERER_USE_JOINT_TEXTURE"),a.enableMacro("RENDERER_JOINTS_NUM",h.toString()),a.setFloatArray(t._jointMatrixProperty,r._skinMatrices);c.set(l,s)}this._jointTexture&&this._jointTexture.setPixelBuffer(r._skinMatrices)}e.prototype._update.call(this,n)},n._updateBounds=function(t){var n;(null==(n=this.skin)?void 0:n.rootBone)?tE.transform(this._localBounds,this._transformEntity.transform.worldMatrix,t):e.prototype._updateBounds.call(this,t)},n._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,n=this._blendShapeWeights;if(n){var r=n.length;if(r!==t){var a=new Float32Array(t);if(t>r)a.set(n);else for(var i=0;i<t;i++)a[i]=n[i];this._blendShapeWeights=a}}else this._blendShapeWeights=new Float32Array(t)},n._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=rv.WorldVolume},n._onSkinUpdated=function(e,n){switch(e){case aX.BoneCountChanged:var r=this.shaderData;n>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(t._jointCountProperty,n)):r.disableMacro("RENDERER_HAS_SKIN");break;case aX.RootBoneChanged:this._setTransformEntity(n),this._dirtyUpdateFlag|=rv.WorldVolume}},n._applySkin=function(e,t){var n,r,a,i,o,s,l=null!=(a=null==e?void 0:null==(n=e.bones)?void 0:n.length)?a:0,c=null!=(i=null==e?void 0:e.rootBone)?i:this.entity;null==e||e._updatedManager.removeListener(this._onSkinUpdated);var u=null!=(o=null==t?void 0:null==(r=t.bones)?void 0:r.length)?o:0,d=null!=(s=null==t?void 0:t.rootBone)?s:this.entity;null==t||t._updatedManager.addListener(this._onSkinUpdated),l!==u&&this._onSkinUpdated(aX.BoneCountChanged,u),c!==d&&this._onSkinUpdated(aX.RootBoneChanged,d)},tG(t,[{key:"skin",get:function(){return this._skin},set:function(e){var t=this._skin;t!==e&&(this._applySkin(t,e),this._skin=e)}},{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var t=this._blendShapeWeights;if(e.length<=t.length)t.set(e);else for(var n=0,r=t.length;n<r;n++)t[n]=e[n]}},{key:"localBounds",get:function(){return this._localBounds},set:function(e){this._localBounds!==e&&this._localBounds.copyFrom(e)}},{key:"rootBone",get:function(){return this.skin.rootBone},set:function(e){this.skin.rootBone=e}},{key:"bones",get:function(){return this.skin.bones},set:function(e){this.skin.bones=e}}]),t}(aA);aK._jointCountProperty=nY.getByName("renderer_JointCount"),aK._jointSamplerProperty=nY.getByName("renderer_JointSampler"),aK._jointMatrixProperty=nY.getByName("renderer_JointMatrix"),tX([tq],aK.prototype,"_condensedBlendShapeWeights",void 0),tX([tZ],aK.prototype,"_localBounds",void 0),tX([tq],aK.prototype,"_jointDataCreateCache",void 0),tX([tq],aK.prototype,"_blendShapeWeights",void 0),tX([tq],aK.prototype,"_maxVertexUniformVectors",void 0),tX([tq],aK.prototype,"_jointTexture",void 0),tX([tZ],aK.prototype,"_skin",void 0),tX([tq],aK.prototype,"_onLocalBoundsChanged",null),tX([tq],aK.prototype,"_onSkinUpdated",null);var aY=/*#__PURE__*/function(){function e(e){var t=new Float32Array([-1,-1,0,1,3,-1,2,1,-1,3,0,-1]),n=new Float32Array([3,-1,2,0,-1,-1,0,0,-1,3,0,2]),r=new ao(e,ro.find("blit"));r._addReferCount(1),r.renderState.depthState.enabled=!1,r.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(e,t),this.flipYBlitMesh=this._createBlitMesh(e,n),this.blitMaterial=r;var a=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(e,0,t9.R8G8B8A8,a),this.whiteTextureCube=this._create1x1Texture(e,1,t9.R8G8B8A8,a),e._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(e,2,t9.R8G8B8A8,a);var i=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(e,0,t9.R32G32B32A32_UInt,i)}this.spriteDefaultMaterial=this._create2DMaterial(e,ro.find("Sprite")),this.textDefaultMaterial=this._create2DMaterial(e,ro.find("Text")),this.spriteMaskDefaultMaterial=this._createSpriteMaskMaterial(e)}var t=e.prototype;return t._createBlitMesh=function(e,t){var n=new aM(e);n._addReferCount(1),n.setVertexElements([new at("POSITION_UV",0,r7.Vector4,0)]);var r=new r9(e,an.VertexBuffer,t,r8.Static,!0);return n.setVertexBufferBinding(r,16),n.addSubMesh(0,3,ar.Triangles),e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tW(t,e),t.prototype.restoreContent=function(){r.setData(r.data)},t}(t2))),n},t._create1x1Texture=function(e,t,n,r){var a;switch(t){case 0:var i=new nc(e,1,1,n,!1);i.setPixelBuffer(r),a=i;break;case 2:var o=new nu(e,1,1,1,n,!1);o.setPixelBuffer(0,r),a=o;break;case 1:for(var s=new nd(e,1,n,!1),l=0;l<6;l++)s.setPixelBuffer(t4.PositiveX+l,r);a=s;break;default:throw"Invalid texture type"}return a.isGCIgnored=!0,e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,a)||this}return tW(n,e),n.prototype.restoreContent=function(){switch(t){case 0:this.resource.setPixelBuffer(r);break;case 2:this.resource.setPixelBuffer(0,r);break;case 1:for(var e=0;e<6;e++)this.resource.setPixelBuffer(t4.PositiveX+e,r)}},n}(t2))),a},t._create2DMaterial=function(e,t){var n=new ao(e,t),r=n.renderState,a=r.blendState.targetBlendState;return a.enabled=!0,a.sourceColorBlendFactor=nF.SourceAlpha,a.destinationColorBlendFactor=nF.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=nF.One,a.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=nL.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=nI.Off,r.renderQueueType=nN.Transparent,n.isGCIgnored=!0,n},t._createSpriteMaskMaterial=function(e){var t=new ao(e,ro.find("SpriteMask"));return t.isGCIgnored=!0,t},e.getMaskInteractionRenderStates=function(t){var n,r;if(t===nv.VisibleInsideMask){if(n=e._maskReadInsideRenderStates)return n;e._maskReadInsideRenderStates=n={},r=nB.LessEqual}else{if(n=e._maskReadOutsideRenderStates)return n;e._maskReadOutsideRenderStates=n={},r=nB.Greater}return n[nO.StencilStateEnabled]=!0,n[nO.StencilStateWriteMask]=0,n[nO.StencilStateReferenceValue]=1,n[nO.StencilStateCompareFunctionFront]=r,n[nO.StencilStateCompareFunctionBack]=r,n},e.getMaskTypeRenderStates=function(t){if(t===rU.Increment){if(n=e._maskWriteIncrementRenderStates)return n;e._maskWriteIncrementRenderStates=n={},r=nk.IncrementSaturate}else{if(n=e._maskWriteDecrementRenderStates)return n;e._maskWriteDecrementRenderStates=n={},r=nk.DecrementSaturate}n[nO.StencilStateEnabled]=!0,n[nO.StencilStatePassOperationFront]=r,n[nO.StencilStatePassOperationBack]=r,n[nO.StencilStateCompareFunctionFront]=nB.Always,n[nO.StencilStateCompareFunctionBack]=nB.Always;var n,r,a=nk.Keep;return n[nO.StencilStateFailOperationFront]=a,n[nO.StencilStateFailOperationBack]=a,n[nO.StencilStateZFailOperationFront]=a,n[nO.StencilStateZFailOperationBack]=a,n[nO.BlendStateColorWriteMask0]=nD.None,n[nO.DepthStateEnabled]=!1,n[nO.RasterStateCullMode]=nI.Off,n},e}();aY._maskReadInsideRenderStates=null,aY._maskReadOutsideRenderStates=null,aY._maskWriteIncrementRenderStates=null,aY._maskWriteDecrementRenderStates=null;var aq=/*#__PURE__*/function(){function e(e){this._type=e}return e.prototype.garbageCollection=function(){for(var e=this._elements,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose();e.length=0},e}(),aQ=/*#__PURE__*/function(e){function t(t,n){void 0===n&&(n=1),(r=e.call(this,t)||this)._lastElementIndex=n-1;for(var r,a=r._elements=Array(n),i=0;i<n;++i)a[i]=new t;return r}tW(t,e);var n=t.prototype;return n.get=function(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]},n.return=function(e){this._elements[++this._lastElementIndex]=e},t}(aq),aJ=/*#__PURE__*/function(){function e(){}return e.prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},e}(),aZ=/*#__PURE__*/function(){function e(e,t){this.start=e,this.size=t}return e.prototype.dispose=function(){},e}(),a$=/*#__PURE__*/function(){function e(e,t){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new ax(e);n.addVertexElement(new at("POSITION",0,r7.Vector3,0)),n.addVertexElement(new at("TEXCOORD_0",12,r7.Vector2,0)),n.addVertexElement(new at("COLOR_0",20,r7.Vector4,0)),n._addReferCount(1);var r=new r9(e,an.VertexBuffer,36*t,r8.Dynamic,!0);n.setVertexBufferBinding(0,new aS(r,36));var a=new r9(e,an.IndexBuffer,8*t,r8.Dynamic,!0);n.setIndexBufferBinding(new ag(a,r6.UInt16)),this.primitive=n,this.vertices=new Float32Array(r.data.buffer),this.indices=new Uint16Array(a.data.buffer),this.vertexFreeAreas=[new aZ(0,9*t)]}var t=e.prototype;return t.allocateSubChunk=function(t){var n=this._allocateArea(9*t);if(n){var r=e.subChunkPool.get();r.chunk=this,r.vertexArea=n;var a=e.subMeshPool.get();return a.topology=ar.Triangles,r.subMesh=a,r}return null},t.freeSubChunk=function(t){this._freeArea(t.vertexArea),e.subMeshPool.return(t.subMesh),e.subChunkPool.return(t)},t.uploadBuffer=function(){var e=this.primitive,t=this.updateVertexStart,n=this.updateVertexEnd;t!==Number.MAX_SAFE_INTEGER&&n!==Number.MIN_SAFE_INTEGER&&(e.vertexBufferBindings[0].buffer.setData(this.vertices,4*t,t,n-t,r5.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER),e.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,r5.Discard),this.updateIndexLength=0},t.destroy=function(){this.primitive._addReferCount(-1),this.primitive.destroy(),this.primitive=null,this.vertices=null,this.indices=null},t._allocateArea=function(t){for(var n=this.vertexFreeAreas,r=e.areaPool,a=0,i=n.length;a<i;++a){var o=n[a],s=o.size;if(s>t){var l=r.get();return l.start=o.start,l.size=t,o.start+=t,o.size-=t,l}if(s===t)return n.splice(a,1),o}return null},t._freeArea=function(t){for(var n=t.start,r=t.size,a=this.vertexFreeAreas,i=n+r,o=e.areaPool,s=0,l=a.length;s<l;++s){var c=a[s],u=c.start,d=u+c.size;if(i<u){a.splice(s,0,t);return}if(i===u){c.start=n,c.size+=r,o.return(t);return}if(n===d){c.size+=r,o.return(t);var h=s+1;if(h<l){var _=a[h];i===_.start&&(c.size+=_.size,a.splice(h,1),o.return(_))}return}}a.push(t)},e}();a$.areaPool=new aQ(aZ,10),a$.subChunkPool=new aQ(aJ,10),a$.subMeshPool=new aQ(ay,10);var a0=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t=4096),this.engine=e,this.maxVertexCount=t,this.primitiveChunks=[]}var t=e.prototype;return t.allocateSubChunk=function(e){for(var t=this.primitiveChunks,n=t.length,r=null,a=0;a<n;++a)if(r=t[a].allocateSubChunk(e))return r;return(t[n]||(t[n]=new a$(this.engine,this.maxVertexCount))).allocateSubChunk(e)},t.freeSubChunk=function(e){e.chunk.freeSubChunk(e)},t.uploadBuffer=function(){for(var e=this.primitiveChunks,t=0,n=e.length;t<n;++t)e[t].uploadBuffer()},t.destroy=function(){for(var e=this.primitiveChunks,t=0,n=e.length;t<n;++t)e[t].destroy();e.length=0,this.primitiveChunks=null,this.engine=null},e}(),a1=/*#__PURE__*/function(){function e(e){this.primitiveChunkManager2D=new a0(e),this.primitiveChunkManagerMask=new a0(e,128)}var t=e.prototype;return t.destroy=function(){this.primitiveChunkManager2D.destroy(),this.primitiveChunkManagerMask.destroy(),this.primitiveChunkManager2D=null,this.primitiveChunkManagerMask=null},t.batch=function(e){for(var t,n,r,a=e.elements,i=e.batchedSubElements,o=e.renderQueueType,s=0,l=a.length;s<l;++s)for(var c=a[s].subRenderElements,u=0,d=c.length;u<d;++u){var h=c[u];if(h.renderQueueFlags&1<<o){var _=h.component,f=_.constructor;t?r===f&&n._canBatch(t,h)?(n._batch(t,h),t.batched=!0):(i.push(t),t=h,n=_,r=f,_._batch(h),h.batched=!1):(t=h,n=_,r=f,_._batch(h),h.batched=!1)}}t&&i.push(t)},t.uploadBuffer=function(){this.primitiveChunkManager2D.uploadBuffer(),this.primitiveChunkManagerMask.uploadBuffer()},e}(),a2=((ev={}).Text="Text",ev.JSON="JSON",ev.Buffer="Buffer",ev.Texture2D="Texture2D",ev.TextureCube="TextureCube",ev.Material="Material",ev.Shader="Shader",ev.Mesh="Mesh",ev.AnimationClip="AnimationClip",ev.AnimatorController="AnimatorController",ev.Prefab="Prefab",ev.GLTF="GLTF",ev.KTX="KTX",ev.KTXCube="KTXCube",ev.KTX2="KTX2",ev.Sprite="Sprite",ev.PrimitiveMesh="PrimitiveMesh",ev.SpriteAtlas="SpriteAtlas",ev.Env="Environment",ev.Scene="Scene",ev.HDR="HDR",ev.Font="Font",ev.SourceFont="SourceFont",ev.Audio="Audio",ev.Project="project",ev),a3=/*#__PURE__*/function(){function e(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}var t=e.prototype;return t.push=function(e){this._array.push(e),this._loopArrayDirty=!0},t.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},t.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},t.findAndRemove=function(e){for(var t=this._array,n=t.length-1;n>=0;n--)e(t[n])&&this.removeByIndex(n)},t.indexOf=function(e){return this._array.indexOf(e)},t.getArray=function(){return this._array},t.getLoopArray=function(){var e=this._loopArray;if(this._loopArrayDirty){var t=this._array,n=t.length;e.length=n;for(var r=0;r<n;r++)e[r]=t[r];this._loopArrayDirty=!1}return e},tG(e,[{key:"length",get:function(){return this._array.length}}]),e}(),a4=/*#__PURE__*/function(){function e(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new a3}var t=e.prototype;return t.addScene=function(e,t){var n,r=this._scenes;if("number"==typeof e){if(e<0||e>r.length)throw"The index is out of range.";n=e}else n=r.length,t=e;if(t.engine!==this.engine)throw"The scene is not belong to this engine.";if(t._sceneManager){var a=r.indexOf(t);a!==n&&(r.removeByIndex(a),r.add(n,t))}else t._sceneManager=this,r.add(n,t),t.isActive&&t._processActive(!0)},t.removeScene=function(e){var t=this._scenes,n=t.indexOf(e);if(-1!==n){var r=t.getArray()[n];t.removeByIndex(n),e._sceneManager=null,r.isActive&&r._processActive(!1)}},t.loadScene=function(e,t){var n=this;void 0===t&&(t=!0);var r=this.engine.resourceManager.load({url:e,type:a2.Scene});return r.then(function(e){if(t)for(var r=n._scenes.getArray(),a=0,i=r.length;a<i;a++)r[a].destroy();n.addScene(e)}),r},t.mergeScenes=function(e,t){for(var n=e.rootEntities;n.length>0;)t.addRootEntity(n[0])},t._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},tG(e,[{key:"scenes",get:function(){return this._scenes.getArray()}},{key:"activeScene",get:function(){return this._scenes.getArray()[0]},set:function(e){var t=this.scenes[0];t&&this.removeScene(t),e&&this.addScene(0,e)}}]),e}(),a8=/*#__PURE__*/function(){function e(e){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(n,r){t._reject=r,e(function(e){"pending"===t._state&&(n(e),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e){"pending"===t._state&&(r(e),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e,n){if("pending"===t._state){var r=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:e,total:n});r.loaded=e,r.total=n,t._onTaskCompleteCallbacks.forEach(function(t){return t(e,n)})}},function(e,n,r){if("pending"===t._state){t._taskDetailProgress||(t._taskDetailProgress={});var a,i=(a=t._taskDetailProgress)[e]||(a[e]={loaded:n,total:r});i.loaded=n,i.total=r,t._onTaskDetailCallbacks.forEach(function(t){return t(e,n,r)})}},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}var t=e.prototype;return t.onProgress=function(e,t){var n=this._taskCompleteProgress,r=this._taskDetailProgress;if(n&&e(n.loaded,n.total),r)for(var a in r){var i=r[a];t(a,i.loaded,i.total)}return"pending"===this._state&&(e&&this._onTaskCompleteCallbacks.push(e),t&&this._onTaskDetailCallbacks.push(t)),this},t.then=function(t,n){var r=this;return new e(function(e,a){r._promise.then(t,n).then(e).catch(a)})},t.catch=function(t){var n=this;return new e(function(e,r){n._promise.catch(t).then(e).catch(r)})},t.finally=function(e){return this._promise.finally(e)},t.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},e.all=function(t){return new e(function(n,r,a){var i=function(e,t){c++,l[e]=t,a(c,s),c===s&&n(l)},o=function(t,n){tK(t,Promise)||tK(t,e)?t.then(function(e){i(n,e)},r):Promise.resolve().then(function(){i(n,t)})},s=t.length,l=Array(s),c=0;if(0===s)return n(l);for(var u=0;u<s;u++)o(t[u],u)})},tG(e,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),e}(),a5={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},a9=1/0;function a6(e,t){return void 0===t&&(t={}),new a8(function(n,r,a,i){var o,s,l,c,u=null!=(o=t.retryCount)?o:1,d=null!=(s=t.retryInterval)?s:500;t.timeout=null!=(l=t.timeout)?l:a9,t.type=null!=(c=t.type)?c:a5[e.substring(e.lastIndexOf(".")+1)],new a7(function(){var n;return(n=t,new a8(function(t,r,a,i){var o,s=new XMLHttpRequest,l="image"===n.type;s.timeout=n.timeout,n.method=null!=(o=n.method)?o:"get",s.onload=function(){if(s.status<200||s.status>=300){r(Error("request failed from: "+e));return}var n,i=null!=(n=s.response)?n:s.responseText;if(l){var o=new Image;o.onload=function(){requestAnimationFrame(function(){a(1,1),t(o),o.onload=null,o.onerror=null,o.onabort=null,URL.revokeObjectURL(o.src)})},o.onerror=o.onabort=function(){r(Error("request "+o.src+" fail")),URL.revokeObjectURL(o.src)},o.crossOrigin="anonymous",o.src=URL.createObjectURL(i)}else a(1,1),t(i)},s.onerror=function(){r(Error("request failed from: "+e))},s.ontimeout=function(){r(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&i(e,t.loaded,t.total)},s.open(n.method,e,!0),s.withCredentials="include"===n.credentials,s.responseType=l?"blob":n.type;var c=n.headers;c&&Object.keys(c).forEach(function(e){s.setRequestHeader(e,c[e])}),s.send(n.body)})).onProgress(a,i)},u,d).start().onError(r).onComplete(n)})}var a7=/*#__PURE__*/function(){function e(e,t,n){this.execFunc=e,this.totalCount=t,this.interval=n,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}var t=e.prototype;return t.start=function(){return this.exec(),this},t.onComplete=function(e){return this._onComplete=e,this},t.onError=function(e){return this._onError=e,this},t.cancel=function(){window.clearTimeout(this._timeoutId)},t.exec=function(){var e=this;if(this._currentCount>=this.totalCount){this._onError&&this._onError(this._error);return}this._currentCount++,this.execFunc(this._currentCount).then(function(t){return e._onComplete&&e._onComplete(t)}).catch(function(t){e._error=t,e._timeoutId=window.setTimeout(e.exec,e.interval)})},e}(),ie=/*#__PURE__*/function(){function e(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this.baseUrl=null,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._subAssetPromiseCallbacks={},this._objectPool=Object.create(null),this._editorResourceConfig=Object.create(null),this._virtualPathMap=Object.create(null)}var t=e.prototype;return t.load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var n=e.map(function(e){return t._loadSingleItem(e)});return a8.all(n)},t.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},t.findResourcesByType=function(e){var t=[],n=this._referResourcePool;for(var r in n){var a=n[r];tK(a,e)&&t.push(a)}return t},t.getAssetPath=function(e){return this._assetPool[e]},t.cancelNotLoaded=function(e){var t,n=this;e?"string"==typeof e?null==(t=this._loadingPromises[e])||t.cancel():e.forEach(function(e){var t;null==(t=n._loadingPromises[e])||t.cancel()}):nT.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},t.gc=function(){this._gc(!1),this.engine._pendingGC()},t.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},t._getRemoteUrl=function(e){var t;return null!=(t=this._virtualPathMap[e])?t:e},t._requestByRemoteUrl=function(e,t){return a6(e,t)},t._request=function(e,t){var n=this._getRemoteUrl(e);return this._requestByRemoteUrl(n,t)},t._onSubAssetSuccess=function(e,t,n){var r,a,i,o=null!=(a=this._virtualPathMap[e])?a:e,s=null==(r=this._subAssetPromiseCallbacks[o])?void 0:r[t];s?s.resolve(n):((i=this._subAssetPromiseCallbacks)[o]||(i[o]={}))[t]={resolvedValue:n}},t._onSubAssetFail=function(e,t,n){var r,a,i=null==(r=this._subAssetPromiseCallbacks[e])?void 0:r[t];i?i.reject(n):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={rejectedValue:n}},t._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},t._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},t._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},t._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},t._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},t._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},t._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},t._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},t._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},t._restoreResourcesContent=function(){var e=this._contentRestorerPool,t=[];for(var n in e){var r=e[n].restoreContent();r&&t.push(r)}return Promise.all(t)},t._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._referResourcePool=null,this._graphicResourcePool=null,this._contentRestorerPool=null,this._loadingPromises=null},t._assignDefaultOptions=function(t){var n,r,a,i,o;if(t.type=null!=(n=t.type)?n:e._getTypeByUrl(t.url),void 0===t.type)throw"asset type should be specified: "+t.url;return t.retryCount=null!=(r=t.retryCount)?r:this.retryCount,t.timeout=null!=(a=t.timeout)?a:this.timeout,t.retryInterval=null!=(i=t.retryInterval)?i:this.retryInterval,t.url=null!=(o=t.url)?o:t.urls.join(","),t},t._loadSingleItem=function(t){var n,r,a=this,i=this._assignDefaultOptions("string"==typeof t?{url:t}:t),o=i.url;!nT.isAbsoluteUrl(o)&&this.baseUrl&&(o=nT.resolveAbsoluteUrl(this.baseUrl,o));var s=this._parseURL(o),l=s.assetBaseURL,c=s.queryPath,u=c?this._parseQueryPath(c):[],d=null!=(n=this._virtualPathMap[l])?n:l,h=this._assetUrlPool[d];if(h)return new a8(function(e){e(a._getResolveResource(h,u))});var _=d;if(c)for(_+="?q="+u.shift();r=u.shift();)_+="["+r+"]";var f=this._loadingPromises,p=f[_];if(p)return new a8(function(e,t,n,r){p.onProgress(n,r).then(function(t){e(t)}).catch(function(e){t(e)})});var m=e._loaders[i.type];if(!m)throw"loader not found: "+i.type;return c?((f[d]||this._loadMainAsset(m,i,d,l)).catch(function(e){a._onSubAssetFail(d,c,e)}),this._createSubAssetPromiseCallback(d,_,c)):this._loadMainAsset(m,i,d,l)},t._loadMainAsset=function(e,t,n,r){var a=this;t.url=r;var i=this._loadingPromises,o=e.load(t,this);return i[n]=o,o.then(function(t){e.useCache&&a._addAsset(n,t),delete i[n],a._releaseSubAssetPromiseCallback(n)},function(){delete i[n],a._releaseSubAssetPromiseCallback(n)}),o},t._createSubAssetPromiseCallback=function(e,t,n){var r,a=this,i=this._loadingPromises,o=null==(r=this._subAssetPromiseCallbacks[e])?void 0:r[n],s=null==o?void 0:o.resolvedValue,l=null==o?void 0:o.rejectedValue;if(s||l)return new a8(function(e,t){s?e(s):l&&t(l)});var c=new a8(function(t,r){var i;((i=a._subAssetPromiseCallbacks)[e]||(i[e]={}))[n]={resolve:t,reject:r}});return i[t]=c,c.then(function(){delete i[t]},function(){return delete i[t]}),c},t._gc=function(e){for(var t=nT.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++){var a=t[n];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},t._getResolveResource=function(e,t){var n=e;if(t)for(var r=0,a=t.length;r<a;r++)n=n[t[r]];return n},t._parseURL=function(e){var t=e.split("?"),n=t[0],r=t[1],a=void 0,i=n;if(r){for(var o=r.split("&"),s=o.length-1;s>=0;s--){var l=o[s];if(l.startsWith("q=")){a=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}i=o.length>0?n+"?"+o.join("&"):n}return{assetBaseURL:i,queryPath:a}},t._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===ir&&t.push(""),e.replace(ii,function(e,n,r,a){var i=e;r?i=a.replace(ia,"$1"):n&&(i=n.trim()),t.push(i)}),t},t._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},t.getResourceByRef=function(e){var t,n=e.refId,r=e.key,a=e.isClone,i=this._objectPool[n];if(i)t=Promise.resolve(i);else{var o=this._editorResourceConfig[n];if(!o)return no.warn("refId:"+n+" is not find in this._editorResourceConfig."),Promise.resolve(null);var s=o.virtualPath;r&&(s+="?q="+r),t=this.load({url:s,type:o.type})}return t.then(function(e){return a?e.clone():e})},t.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},e._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,a=n.length;r<a;r++)this._extTypeMapping[n[r].toLowerCase()]=e},e._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},e}();function it(e,t,n){return void 0===n&&(n=!0),function(r){var a=new r(n);ie._addLoader(e,a,t)}}ie._loaders={},ie._extTypeMapping={};var ir=46,ia=/\\(\\)?/g,ii=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),io=((ey={})[ey.Down=0]="Down",ey[ey.Move=1]="Move",ey[ey.Stationary=2]="Stationary",ey[ey.Up=3]="Up",ey[ey.Leave=4]="Leave",ey),is=/*#__PURE__*/function(){function e(e){this.phase=io.Leave,this.position=new tB,this.deltaPosition=new tB,this._events=[],this._upMap=[],this._downMap=[],this._upList=new rC,this._downList=new rC,this.id=e}var t=e.prototype;return t._firePointerExitAndEnter=function(e){var t=this;this._currentEnteredEntity!==e&&(this._currentEnteredEntity&&this._currentEnteredEntity._scripts.forEach(function(e){e.onPointerExit(t)},function(e,t){e._entityScriptsIndex=t}),e&&e._scripts.forEach(function(e){e.onPointerEnter(t)},function(e,t){e._entityScriptsIndex=t}),this._currentEnteredEntity=e)},t._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},t._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},t._firePointerUpAndClick=function(e){var t=this,n=this._currentPressedEntity;if(n){var r=n===e;n._scripts.forEach(function(e){r&&e.onPointerClick(t),e.onPointerUp(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=null}},e}(),il=((ex={})[ex.None=0]="None",ex[ex.Primary=1]="Primary",ex[ex.Secondary=2]="Secondary",ex[ex.Auxiliary=4]="Auxiliary",ex[ex.XButton1=8]="XButton1",ex[ex.XButton2=16]="XButton2",ex[ex.XButton3=32]="XButton3",ex[ex.XButton4=64]="XButton4",ex[ex.XButton5=128]="XButton5",ex[ex.XButton6=256]="XButton6",ex[ex.XButton7=512]="XButton7",ex[ex.XButton8=1024]="XButton8",ex),ic=[1,4,2,8,16,32,64,128,256,512,1024],iu={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},id=/*#__PURE__*/function(){function e(){}return e._initialize=function(){if("undefined"==typeof navigator){e._isBrowser=!1;return}var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?e.platform=tz.IPhone:/iPad/i.test(n)?e.platform=tz.IPad:/Android/i.test(n)?e.platform=tz.Android:/Macintosh/i.test(n)&&(e.platform=tz.Mac),e.platform){case tz.IPhone:t=n.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPhone OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPhone OS";break;case tz.IPad:t=n.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPad OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPad OS";break;case tz.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case tz.Mac:t=n.match(/Mac OS X (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"Mac OS X "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Mac OS X"}},e._detectSIMDSupported=function(){return null===this._simdSupported&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},tG(e,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),e}();id.platform=tz.Unknown,id.operatingSystem="",id._isBrowser=!0,id._simdSupported=null,id._initialize();var ih=((eb={})[eb.Backquote=0]="Backquote",eb[eb.Backslash=1]="Backslash",eb[eb.Backspace=2]="Backspace",eb[eb.BracketLeft=3]="BracketLeft",eb[eb.BracketRight=4]="BracketRight",eb[eb.Comma=5]="Comma",eb[eb.Digit0=6]="Digit0",eb[eb.Digit1=7]="Digit1",eb[eb.Digit2=8]="Digit2",eb[eb.Digit3=9]="Digit3",eb[eb.Digit4=10]="Digit4",eb[eb.Digit5=11]="Digit5",eb[eb.Digit6=12]="Digit6",eb[eb.Digit7=13]="Digit7",eb[eb.Digit8=14]="Digit8",eb[eb.Digit9=15]="Digit9",eb[eb.Equal=16]="Equal",eb[eb.IntlBackslash=17]="IntlBackslash",eb[eb.IntlRo=18]="IntlRo",eb[eb.IntlYen=19]="IntlYen",eb[eb.KeyA=20]="KeyA",eb[eb.KeyB=21]="KeyB",eb[eb.KeyC=22]="KeyC",eb[eb.KeyD=23]="KeyD",eb[eb.KeyE=24]="KeyE",eb[eb.KeyF=25]="KeyF",eb[eb.KeyG=26]="KeyG",eb[eb.KeyH=27]="KeyH",eb[eb.KeyI=28]="KeyI",eb[eb.KeyJ=29]="KeyJ",eb[eb.KeyK=30]="KeyK",eb[eb.KeyL=31]="KeyL",eb[eb.KeyM=32]="KeyM",eb[eb.KeyN=33]="KeyN",eb[eb.KeyO=34]="KeyO",eb[eb.KeyP=35]="KeyP",eb[eb.KeyQ=36]="KeyQ",eb[eb.KeyR=37]="KeyR",eb[eb.KeyS=38]="KeyS",eb[eb.KeyT=39]="KeyT",eb[eb.KeyU=40]="KeyU",eb[eb.KeyV=41]="KeyV",eb[eb.KeyW=42]="KeyW",eb[eb.KeyX=43]="KeyX",eb[eb.KeyY=44]="KeyY",eb[eb.KeyZ=45]="KeyZ",eb[eb.Minus=46]="Minus",eb[eb.Period=47]="Period",eb[eb.Quote=48]="Quote",eb[eb.Semicolon=49]="Semicolon",eb[eb.Slash=50]="Slash",eb[eb.AltLeft=51]="AltLeft",eb[eb.AltRight=52]="AltRight",eb[eb.CapsLock=53]="CapsLock",eb[eb.ContextMenu=54]="ContextMenu",eb[eb.ControlLeft=55]="ControlLeft",eb[eb.ControlRight=56]="ControlRight",eb[eb.Enter=57]="Enter",eb[eb.MetaLeft=58]="MetaLeft",eb[eb.MetaRight=59]="MetaRight",eb[eb.ShiftLeft=60]="ShiftLeft",eb[eb.ShiftRight=61]="ShiftRight",eb[eb.Space=62]="Space",eb[eb.Tab=63]="Tab",eb[eb.Convert=64]="Convert",eb[eb.KanaMode=65]="KanaMode",eb[eb.Lang1=66]="Lang1",eb[eb.Lang2=67]="Lang2",eb[eb.Lang3=68]="Lang3",eb[eb.Lang4=69]="Lang4",eb[eb.Lang5=70]="Lang5",eb[eb.NonConvert=71]="NonConvert",eb[eb.Delete=72]="Delete",eb[eb.End=73]="End",eb[eb.Help=74]="Help",eb[eb.Home=75]="Home",eb[eb.Insert=76]="Insert",eb[eb.PageDown=77]="PageDown",eb[eb.PageUp=78]="PageUp",eb[eb.ArrowDown=79]="ArrowDown",eb[eb.ArrowLeft=80]="ArrowLeft",eb[eb.ArrowRight=81]="ArrowRight",eb[eb.ArrowUp=82]="ArrowUp",eb[eb.NumLock=83]="NumLock",eb[eb.Numpad0=84]="Numpad0",eb[eb.Numpad1=85]="Numpad1",eb[eb.Numpad2=86]="Numpad2",eb[eb.Numpad3=87]="Numpad3",eb[eb.Numpad4=88]="Numpad4",eb[eb.Numpad5=89]="Numpad5",eb[eb.Numpad6=90]="Numpad6",eb[eb.Numpad7=91]="Numpad7",eb[eb.Numpad8=92]="Numpad8",eb[eb.Numpad9=93]="Numpad9",eb[eb.NumpadAdd=94]="NumpadAdd",eb[eb.NumpadBackspace=95]="NumpadBackspace",eb[eb.NumpadClear=96]="NumpadClear",eb[eb.NumpadClearEntry=97]="NumpadClearEntry",eb[eb.NumpadComma=98]="NumpadComma",eb[eb.NumpadDecimal=99]="NumpadDecimal",eb[eb.NumpadDivide=100]="NumpadDivide",eb[eb.NumpadEnter=101]="NumpadEnter",eb[eb.NumpadEqual=102]="NumpadEqual",eb[eb.NumpadHash=103]="NumpadHash",eb[eb.NumpadMemoryAdd=104]="NumpadMemoryAdd",eb[eb.NumpadMemoryClear=105]="NumpadMemoryClear",eb[eb.NumpadMemoryRecall=106]="NumpadMemoryRecall",eb[eb.NumpadMemoryStore=107]="NumpadMemoryStore",eb[eb.NumpadMemorySubtract=108]="NumpadMemorySubtract",eb[eb.NumpadMultiply=109]="NumpadMultiply",eb[eb.NumpadParenLeft=110]="NumpadParenLeft",eb[eb.NumpadParenRight=111]="NumpadParenRight",eb[eb.NumpadStar=112]="NumpadStar",eb[eb.NumpadSubtract=113]="NumpadSubtract",eb[eb.Escape=114]="Escape",eb[eb.F1=115]="F1",eb[eb.F2=116]="F2",eb[eb.F3=117]="F3",eb[eb.F4=118]="F4",eb[eb.F5=119]="F5",eb[eb.F6=120]="F6",eb[eb.F7=121]="F7",eb[eb.F8=122]="F8",eb[eb.F9=123]="F9",eb[eb.F10=124]="F10",eb[eb.F11=125]="F11",eb[eb.F12=126]="F12",eb[eb.F13=127]="F13",eb[eb.F14=128]="F14",eb[eb.F15=129]="F15",eb[eb.Fn=130]="Fn",eb[eb.FnLock=131]="FnLock",eb[eb.PrintScreen=132]="PrintScreen",eb[eb.ScrollLock=133]="ScrollLock",eb[eb.Pause=134]="Pause",eb[eb.BrowserBack=135]="BrowserBack",eb[eb.BrowserFavorites=136]="BrowserFavorites",eb[eb.BrowserForward=137]="BrowserForward",eb[eb.BrowserHome=138]="BrowserHome",eb[eb.BrowserRefresh=139]="BrowserRefresh",eb[eb.BrowserSearch=140]="BrowserSearch",eb[eb.BrowserStop=141]="BrowserStop",eb[eb.Eject=142]="Eject",eb[eb.LaunchApp1=143]="LaunchApp1",eb[eb.LaunchApp2=144]="LaunchApp2",eb[eb.LaunchMail=145]="LaunchMail",eb[eb.MediaPlayPause=146]="MediaPlayPause",eb[eb.MediaSelect=147]="MediaSelect",eb[eb.MediaStop=148]="MediaStop",eb[eb.MediaTrackNext=149]="MediaTrackNext",eb[eb.MediaTrackPrevious=150]="MediaTrackPrevious",eb[eb.Power=151]="Power",eb[eb.Sleep=152]="Sleep",eb[eb.AudioVolumeDown=153]="AudioVolumeDown",eb[eb.AudioVolumeMute=154]="AudioVolumeMute",eb[eb.AudioVolumeUp=155]="AudioVolumeUp",eb[eb.WakeUp=156]="WakeUp",eb[eb.Hyper=157]="Hyper",eb[eb.Super=158]="Super",eb[eb.Turbo=159]="Turbo",eb[eb.Abort=160]="Abort",eb[eb.Resume=161]="Resume",eb[eb.Suspend=162]="Suspend",eb[eb.Again=163]="Again",eb[eb.Copy=164]="Copy",eb[eb.Cut=165]="Cut",eb[eb.Find=166]="Find",eb[eb.Open=167]="Open",eb[eb.Paste=168]="Paste",eb[eb.Props=169]="Props",eb[eb.Select=170]="Select",eb[eb.Undo=171]="Undo",eb[eb.Hiragana=172]="Hiragana",eb[eb.Katakana=173]="Katakana",eb[eb.Unidentified=174]="Unidentified",eb),i_=/*#__PURE__*/function(){function e(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new rC,this._curFrameDownList=new rC,this._curFrameUpList=new rC,this._nativeEvents=[],this._engine=e,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}var t=e.prototype;return t._update=function(){var e=this._nativeEvents,t=this._curFrameDownList,n=this._curFrameUpList;if(t.length=0,n.length=0,e.length>0){for(var r=this._engine.time.frameCount,a=this._curHeldDownKeyToIndexMap,i=this._curFrameHeldDownList,o=this._downKeyToFrameCountMap,s=this._upKeyToFrameCountMap,l=0,c=e.length;l<c;l++){var u=e[l],d=ih[u.code];switch(u.type){case"keydown":null==a[d]&&(t.add(d),i.add(d),a[d]=i.length-1,o[d]=r);break;case"keyup":var h=a[d];if(null!=h){a[d]=null;var _=i.deleteByIndex(h);_&&(a[_]=h)}if(n.add(d),s[d]=r,id.platform===tz.Mac&&(d===ih.MetaLeft||d===ih.MetaRight)){for(var f=0,p=i.length;f<p;f++)a[i.get(f)]=null;i.length=0}}}e.length=0}},t._destroy=function(){this._removeEventListener(),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._engine=null},t._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},t._onKeyEvent=function(e){this._nativeEvents.push(e)},t._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},t._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},e}();e.Collider=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._index=-1,n._shapes=[],n._updateFlag=t.registerWorldChangeFlag(),n}tW(t,e);var n=t.prototype;return n.addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),this._addNativeShape(e),this._handleShapesChanged())},n.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this._removeNativeShape(e),this._handleShapesChanged())},n.clearShapes=function(){for(var e=this._shapes,t=0,n=e.length;t<n;t++)this._removeNativeShape(e[t]);e.length=0,this._handleShapesChanged()},n._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform;this._nativeCollider.setWorldTransform(e.worldPosition,e.worldRotationQuaternion);for(var t=e.lossyWorldScale,n=0,r=this.shapes.length;n<r;n++)this.shapes[n]._nativeShape.setWorldScale(t);this._updateFlag.flag=!1}},n._onLateUpdate=function(){},n._onEnableInScene=function(){this.scene.physics._addCollider(this)},n._onDisableInScene=function(){this.scene.physics._removeCollider(this)},n._cloneTo=function(e){e._syncNative()},n._handleShapesChanged=function(){},n._syncNative=function(){for(var e=0,t=this.shapes.length;e<t;e++)this._addNativeShape(this.shapes[e])},n._onDestroy=function(){e.prototype._onDestroy.call(this);for(var t=this._shapes,n=0,r=t.length;n<r;n++){var a=t[n];this._removeNativeShape(a),a._destroy()}t.length=0,this._nativeCollider.destroy()},n._addNativeShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape)},n._removeNativeShape=function(e){e._collider=null,this._nativeCollider.removeShape(e._nativeShape)},tG(t,[{key:"shapes",get:function(){return this._shapes}}]),t}(ru),tX([tq],e.Collider.prototype,"_index",void 0),tX([tq],e.Collider.prototype,"_nativeCollider",void 0),tX([tq],e.Collider.prototype,"_updateFlag",void 0),tX([tZ],e.Collider.prototype,"_shapes",void 0),e.Collider=tX([rh(rp,r_.CheckOnly)],e.Collider);var ip=/*#__PURE__*/function(){function e(t){this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new rC,this._gravity=new tT(0,-9.81,0),this._onContactEnter=function(t,n){var r=iJ._physicalObjectsMap,a=r[t],i=r[n];a.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionEnter(n)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=a,t.onCollisionEnter(n)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(t,n){var r=iJ._physicalObjectsMap,a=r[t],i=r[n];a.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionExit(n)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=a,t.onCollisionExit(n)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(t,n){var r=iJ._physicalObjectsMap,a=r[t],i=r[n];a.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionStay(n)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=a,t.onCollisionStay(n)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=iJ._physicalObjectsMap,r=n[e],a=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=iJ._physicalObjectsMap,r=n[e],a=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=iJ._physicalObjectsMap,r=n[e],a=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(r)},function(e,t){e._entityScriptsIndex=t})},this._scene=t,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var n=t.engine;n._physicsInitialized&&(this._nativePhysicsScene=e._nativePhysics.createPhysicsScene(n._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var t=e.prototype;return t.raycast=function(e,t,n,r){var a,i=Number.MAX_VALUE;"number"==typeof t?i=t:void 0!=t&&(a=t);var o=rE.Everything;"number"==typeof n?o=n:void 0!=n&&(a=n),r&&(a=r);var s=function(e){var t=iJ._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&o&&t.isSceneQuery};return void 0==a?this._nativePhysicsScene.raycast(e,i,s):!!this._nativePhysicsScene.raycast(e,i,s,function(e,t,n,r){var i=iJ._physicalObjectsMap[e];a.entity=i._collider.entity,a.shape=i,a.distance=t,a.normal.copyFrom(r),a.point.copyFrom(n)})||(a.entity=null,a.shape=null,a.distance=0,a.point.set(0,0,0),a.normal.set(0,0,0),!1)},t._update=function(e){var t=this._fixedTimeStep,n=this._nativePhysicsScene,r=this._scene._componentsManager,a=this._restTime+e,i=Math.floor(a/t);this._restTime=a-i*t;for(var o=0;o<i;o++)r.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),n.update(t),this._callColliderOnLateUpdate()},t._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},t._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},t._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},t._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},t._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},t._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},t._gc=function(){this._colliders.garbageCollection()},t._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},tG(e,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(e){this._fixedTimeStep=Math.max(e,tS.zeroTolerance)}}]),e}();ip._collision=new function(){};var im=((eC={})[eC.PreventClimbing=0]="PreventClimbing",eC[eC.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding",eC),ig=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=im.PreventClimbing,n._upDirection=new tT(0,1,0),n._slopeLimit=.707,n._nativeCollider=ip._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(n),n._upDirection._onValueChanged=n._setUpDirection,n._onUpdate(),n}tW(t,e);var n=t.prototype;return n.move=function(e,t,n){var r=this._nativeCollider.move(e,t,n);return this._syncWorldPositionFromPhysicalSpace(),r},n.addShape=function(t){if(this._shapes.length>0)throw"only allow single shape on controller!";e.prototype.addShape.call(this,t),this._updateFlag.flag=!0},n._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,t=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var n=e.lossyWorldScale,r=0,a=t.length;r<a;r++)t[r]._nativeShape.setWorldScale(n);this._updateFlag.flag=!1}},n._onLateUpdate=function(){this._syncWorldPositionFromPhysicalSpace(),this._updateFlag.flag=!1},n._onEnableInScene=function(){this.scene.physics._addCharacterController(this)},n._onDisableInScene=function(){this.scene.physics._removeCharacterController(this)},n._syncNative=function(){e.prototype._syncNative.call(this),this._nativeCollider.setStepOffset(this._stepOffset),this._nativeCollider.setNonWalkableMode(this._nonWalkableMode),this._nativeCollider.setUpDirection(this._upDirection),this._nativeCollider.setSlopeLimit(this._slopeLimit)},n._syncWorldPositionFromPhysicalSpace=function(){this._nativeCollider.getWorldPosition(this.entity.transform.worldPosition)},n._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},tG(t,[{key:"stepOffset",get:function(){return this._stepOffset},set:function(e){e=Math.max(0,e),this._stepOffset!==e&&(this._stepOffset=e,this._nativeCollider.setStepOffset(e))}},{key:"nonWalkableMode",get:function(){return this._nonWalkableMode},set:function(e){this._nonWalkableMode!==e&&(this._nonWalkableMode=e,this._nativeCollider.setNonWalkableMode(e))}},{key:"upDirection",get:function(){return this._upDirection},set:function(e){this._upDirection!==e&&this._upDirection.copyFrom(e)}},{key:"slopeLimit",get:function(){return this._slopeLimit},set:function(e){this._slopeLimit!==e&&(this._slopeLimit=e,this._nativeCollider.setSlopeLimit(e))}}]),t}(e.Collider);tX([tZ],ig.prototype,"_upDirection",void 0);var iv=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._linearDamping=0,n._angularDamping=.05,n._linearVelocity=new tT,n._angularVelocity=new tT,n._mass=1,n._centerOfMass=new tT,n._inertiaTensor=new tT(1,1,1),n._maxAngularVelocity=100,n._maxDepenetrationVelocity=10000000331813535e16,n._solverIterations=4,n._isKinematic=!1,n._constraints=0,n._collisionDetectionMode=0,n._sleepThreshold=.005,n._automaticCenterOfMass=!0,n._automaticInertiaTensor=!0;var n,r=n.entity.transform;return n._nativeCollider=ip._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),n._setLinearVelocity=n._setLinearVelocity.bind(n),n._setAngularVelocity=n._setAngularVelocity.bind(n),n._handleCenterOfMassChanged=n._handleCenterOfMassChanged.bind(n),n._handleInertiaTensorChanged=n._handleInertiaTensorChanged.bind(n),n._linearVelocity._onValueChanged=n._setLinearVelocity,n._angularVelocity._onValueChanged=n._setAngularVelocity,n._centerOfMass._onValueChanged=n._handleCenterOfMassChanged,n._inertiaTensor._onValueChanged=n._handleInertiaTensorChanged,n}tW(t,e);var n=t.prototype;return n.applyForce=function(e){this._phasedActiveInScene&&this._nativeCollider.addForce(e)},n.applyTorque=function(e){this._phasedActiveInScene&&this._nativeCollider.addTorque(e)},n.move=function(e,t){this._phasedActiveInScene&&this._nativeCollider.move(e,t)},n.sleep=function(){this._nativeCollider.sleep()},n.isSleeping=function(){return this._nativeCollider.isSleeping()},n.wakeUp=function(){this._nativeCollider.wakeUp()},n._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},n._cloneTo=function(t){t._linearVelocity.copyFrom(this.linearVelocity),t._angularVelocity.copyFrom(this.angularVelocity),t._centerOfMass.copyFrom(this.centerOfMass),t._inertiaTensor.copyFrom(this.inertiaTensor),e.prototype._cloneTo.call(this,t)},n._handleShapesChanged=function(){(this._automaticCenterOfMass||this._automaticInertiaTensor)&&this._setMassAndUpdateInertia()},n._syncNative=function(){e.prototype._syncNative.call(this),this._nativeCollider.setLinearDamping(this._linearDamping),this._nativeCollider.setAngularDamping(this._angularDamping),this._nativeCollider.setLinearVelocity(this._linearVelocity),this._nativeCollider.setAngularVelocity(this._angularVelocity),this._automaticCenterOfMass||this._automaticInertiaTensor?this._setMassAndUpdateInertia():(this._nativeCollider.setMass(this._mass),this._nativeCollider.setCenterOfMass(this._centerOfMass),this._nativeCollider.setInertiaTensor(this._inertiaTensor)),this._nativeCollider.setMaxAngularVelocity(this._maxAngularVelocity),this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity),this._nativeCollider.setSleepThreshold(this._sleepThreshold),this._nativeCollider.setSolverIterations(this._solverIterations),this._nativeCollider.setIsKinematic(this._isKinematic),this._nativeCollider.setConstraints(this._constraints),this._nativeCollider.setCollisionDetectionMode(this._collisionDetectionMode)},n._setMassAndUpdateInertia=function(){this._nativeCollider.setMassAndUpdateInertia(this._mass),this._automaticCenterOfMass||this._nativeCollider.setCenterOfMass(this._centerOfMass),this._automaticInertiaTensor||this._nativeCollider.setInertiaTensor(this._inertiaTensor)},n._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},n._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},n._handleCenterOfMassChanged=function(){this._automaticCenterOfMass?console.warn("The center of mass is automatically calculated, please set automaticCenterOfMass to false if you want to set it manually."):this._nativeCollider.setCenterOfMass(this._centerOfMass)},n._handleInertiaTensorChanged=function(){this._automaticInertiaTensor?console.warn("The inertia tensor is automatically calculated, please set automaticInertiaTensor to false if you want to set it manually."):this._nativeCollider.setInertiaTensor(this._inertiaTensor)},tG(t,[{key:"linearDamping",get:function(){return this._linearDamping},set:function(e){this._linearDamping!==e&&(this._linearDamping=e,this._nativeCollider.setLinearDamping(e))}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(e){this._angularDamping!==e&&(this._angularDamping=e,this._nativeCollider.setAngularDamping(e))}},{key:"linearVelocity",get:function(){return this._linearVelocity._onValueChanged=null,this._nativeCollider.getLinearVelocity(this._linearVelocity),this._linearVelocity._onValueChanged=this._setLinearVelocity,this._linearVelocity},set:function(e){this._linearVelocity!==e&&this._linearVelocity.copyFrom(e)}},{key:"angularVelocity",get:function(){return this._angularVelocity._onValueChanged=null,this._nativeCollider.getAngularVelocity(this._angularVelocity),this._angularVelocity._onValueChanged=this._setAngularVelocity,this._angularVelocity},set:function(e){this._angularVelocity!==e&&this._angularVelocity.copyFrom(e)}},{key:"mass",get:function(){return this._mass},set:function(e){this._mass!==e&&(this._mass=e,this._automaticInertiaTensor||this._automaticCenterOfMass?this._setMassAndUpdateInertia():this._nativeCollider.setMass(e))}},{key:"automaticCenterOfMass",get:function(){return this._automaticCenterOfMass},set:function(e){this._automaticCenterOfMass!==e&&(this._automaticCenterOfMass=e,e&&this._setMassAndUpdateInertia())}},{key:"centerOfMass",get:function(){return this._centerOfMass._onValueChanged=null,this._nativeCollider.getCenterOfMass(this._centerOfMass),this._centerOfMass._onValueChanged=this._handleCenterOfMassChanged,this._centerOfMass},set:function(e){this._centerOfMass!==e&&this._centerOfMass.copyFrom(e)}},{key:"automaticInertiaTensor",get:function(){return this._automaticInertiaTensor},set:function(e){this._automaticInertiaTensor!==e&&(this._automaticInertiaTensor=e,e&&this._setMassAndUpdateInertia())}},{key:"inertiaTensor",get:function(){return this._inertiaTensor._onValueChanged=null,this._nativeCollider.getInertiaTensor(this._inertiaTensor),this._inertiaTensor._onValueChanged=this._handleInertiaTensorChanged,this._inertiaTensor},set:function(e){this._inertiaTensor!==e&&this._inertiaTensor.copyFrom(e)}},{key:"maxAngularVelocity",get:function(){return this._maxAngularVelocity},set:function(e){this._maxAngularVelocity!==e&&(this._maxAngularVelocity=e,this._nativeCollider.setMaxAngularVelocity(e))}},{key:"maxDepenetrationVelocity",get:function(){return this._maxDepenetrationVelocity},set:function(e){this._maxDepenetrationVelocity!==e&&(this._maxDepenetrationVelocity=e,this._nativeCollider.setMaxDepenetrationVelocity(e))}},{key:"sleepThreshold",get:function(){return this._sleepThreshold},set:function(e){e!==this._sleepThreshold&&(this._sleepThreshold=e,this._nativeCollider.setSleepThreshold(e))}},{key:"solverIterations",get:function(){return this._solverIterations},set:function(e){this._solverIterations!==e&&(this._solverIterations=e,this._nativeCollider.setSolverIterations(e))}},{key:"isKinematic",get:function(){return this._isKinematic},set:function(e){this._isKinematic!==e&&(this._isKinematic=e,this._nativeCollider.setIsKinematic(e))}},{key:"constraints",get:function(){return this._constraints},set:function(e){this._constraints!==e&&(this._constraints=e,this._nativeCollider.setConstraints(e))}},{key:"collisionDetectionMode",get:function(){return this._collisionDetectionMode},set:function(e){this._collisionDetectionMode!==e&&(this._collisionDetectionMode=e,this._nativeCollider.setCollisionDetectionMode(e))}}]),t}(e.Collider);tX([tq],iv.prototype,"_linearVelocity",void 0),tX([tq],iv.prototype,"_angularVelocity",void 0),tX([tq],iv.prototype,"_centerOfMass",void 0),tX([tq],iv.prototype,"_inertiaTensor",void 0),tX([tq],iv.prototype,"_setLinearVelocity",null),tX([tq],iv.prototype,"_setAngularVelocity",null),tX([tq],iv.prototype,"_handleCenterOfMassChanged",null),tX([tq],iv.prototype,"_handleInertiaTensorChanged",null);var iy=((eS={})[eS.Discrete=0]="Discrete",eS[eS.Continuous=1]="Continuous",eS[eS.ContinuousDynamic=2]="ContinuousDynamic",eS[eS.ContinuousSpeculative=3]="ContinuousSpeculative",eS),ix=((eT={})[eT.None=0]="None",eT[eT.FreezePositionX=1]="FreezePositionX",eT[eT.FreezePositionY=2]="FreezePositionY",eT[eT.FreezePositionZ=4]="FreezePositionZ",eT[eT.FreezeRotationX=8]="FreezeRotationX",eT[eT.FreezeRotationY=16]="FreezeRotationY",eT[eT.FreezeRotationZ=32]="FreezeRotationZ",eT),ib=function(){this.entity=null,this.distance=0,this.point=new tT,this.normal=new tT,this.shape=null},iC=((eA={})[eA.Average=0]="Average",eA[eA.Minimum=1]="Minimum",eA[eA.Multiply=2]="Multiply",eA[eA.Maximum=3]="Maximum",eA),iS=/*#__PURE__*/function(){function e(){this._bounciness=0,this._dynamicFriction=.6,this._staticFriction=.6,this._bounceCombine=iC.Average,this._frictionCombine=iC.Average,this._nativeMaterial=ip._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}return e.prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},tG(e,[{key:"bounciness",get:function(){return this._bounciness},set:function(e){this._bounciness!==e&&(this._bounciness=e,this._nativeMaterial.setBounciness(e))}},{key:"dynamicFriction",get:function(){return this._dynamicFriction},set:function(e){this._dynamicFriction!==e&&(this._dynamicFriction=e,this._nativeMaterial.setDynamicFriction(e))}},{key:"staticFriction",get:function(){return this._staticFriction},set:function(e){this._staticFriction!==e&&(this._staticFriction=e,this._nativeMaterial.setStaticFriction(e))}},{key:"bounceCombine",get:function(){return this._bounceCombine},set:function(e){this._bounceCombine!==e&&(this._bounceCombine=e,this._nativeMaterial.setBounceCombine(e))}},{key:"frictionCombine",get:function(){return this._frictionCombine},set:function(e){this._frictionCombine!==e&&(this._frictionCombine=e,this._nativeMaterial.setFrictionCombine(e))}}]),e}(),iT=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t)||this).entity.transform;return n._nativeCollider=ip._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),n}return tW(t,e),t}(e.Collider),iA=((eE={})[eE.X=0]="X",eE[eE.Y=1]="Y",eE[eE.Z=2]="Z",eE),iE=((eR={})[eR.Sides=1]="Sides",eR[eR.Up=2]="Up",eR[eR.Down=4]="Down",eR);e.Joint=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._colliderInfo=new iR,n._connectedColliderInfo=new iR,n._force=1/0,n._torque=1/0,n._automaticConnectedAnchor=!0,n._colliderInfo.anchor._onValueChanged=n._updateActualAnchor.bind(n,1),n._connectedColliderInfo.anchor._onValueChanged=n._updateActualAnchor.bind(n,2),n._onSelfTransformChanged=n._onSelfTransformChanged.bind(n),n._onConnectedTransformChanged=n._onConnectedTransformChanged.bind(n),t._updateFlagManager.addListener(n._onSelfTransformChanged),n}tW(t,e);var n=t.prototype;return n._onEnableInScene=function(){this._createJoint(),this._syncNative()},n._onDisableInScene=function(){this._nativeJoint.destroy(),this._nativeJoint=null},n._syncNative=function(){if(this._nativeJoint){var e;this._nativeJoint.setConnectedCollider((null==(e=this._connectedColliderInfo.collider)?void 0:e._nativeCollider)||null),this._updateActualAnchor(1),this._automaticConnectedAnchor?this._calculateConnectedAnchor():this._updateActualAnchor(2),this._nativeJoint.setConnectedMassScale(this._connectedColliderInfo.massScale),this._nativeJoint.setConnectedInertiaScale(this._connectedColliderInfo.inertiaScale),this._nativeJoint.setMassScale(this._colliderInfo.massScale),this._nativeJoint.setInertiaScale(this._colliderInfo.inertiaScale),this._nativeJoint.setBreakForce(this._force),this._nativeJoint.setBreakTorque(this._torque)}},n._calculateConnectedAnchor=function(){var e=this._colliderInfo,n=this._connectedColliderInfo,r=this.entity.transform.worldPosition,a=e.actualAnchor,i=n.anchor,o=n.actualAnchor,s=n.collider;if(s){var l=s.entity.transform,c=l.worldPosition,u=l.lossyWorldScale;tT.subtract(r,c,t._tempVector3),tT.add(t._tempVector3,a,o),tT.divide(o,u,i)}else tT.add(r,a,o),i.copyFrom(o)},n._onSelfTransformChanged=function(e){e&rm.WorldScale&&this._updateActualAnchor(1)},n._onConnectedTransformChanged=function(e){e&rm.WorldScale&&this._updateActualAnchor(2)},n._updateActualAnchor=function(e){if(1&e){var t,n=this.entity.transform.lossyWorldScale,r=this._colliderInfo;tT.multiply(r.anchor,n,r.actualAnchor),null==(t=this._nativeJoint)||t.setAnchor(r.actualAnchor)}if(2&e){var a,i=this._connectedColliderInfo,o=i.collider;if(o){var s=o.entity.transform.lossyWorldScale;tT.multiply(i.anchor,s,i.actualAnchor)}else i.actualAnchor.copyFrom(i.anchor);null==(a=this._nativeJoint)||a.setConnectedAnchor(i.actualAnchor)}},tG(t,[{key:"connectedCollider",get:function(){return this._connectedColliderInfo.collider},set:function(e){if(this._connectedColliderInfo.collider!==e){var t,n;null==(t=this._connectedColliderInfo.collider)||t.entity._updateFlagManager.removeListener(this._onConnectedTransformChanged),null==e||e.entity._updateFlagManager.addListener(this._onConnectedTransformChanged),this._connectedColliderInfo.collider=e,null==(n=this._nativeJoint)||n.setConnectedCollider(e._nativeCollider),this._automaticConnectedAnchor?this._calculateConnectedAnchor():this._updateActualAnchor(2)}}},{key:"anchor",get:function(){return this._colliderInfo.anchor},set:function(e){var t=this._colliderInfo.anchor;e!==t&&(t.copyFrom(e),this._updateActualAnchor(1),this._automaticConnectedAnchor&&this._calculateConnectedAnchor())}},{key:"connectedAnchor",get:function(){return this._connectedColliderInfo.anchor},set:function(e){if(this.automaticConnectedAnchor){console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true.");return}var t=this._connectedColliderInfo.anchor;e!==t&&(t.copyFrom(e),this._updateActualAnchor(2))}},{key:"automaticConnectedAnchor",get:function(){return this._automaticConnectedAnchor},set:function(e){this._automaticConnectedAnchor=e,e&&this._calculateConnectedAnchor()}},{key:"connectedMassScale",get:function(){return this._connectedColliderInfo.massScale},set:function(e){if(e!==this._connectedColliderInfo.massScale){var t;this._connectedColliderInfo.massScale=e,null==(t=this._nativeJoint)||t.setConnectedMassScale(e)}}},{key:"massScale",get:function(){return this._colliderInfo.massScale},set:function(e){if(e!==this._colliderInfo.massScale){var t;this._colliderInfo.massScale=e,null==(t=this._nativeJoint)||t.setMassScale(e)}}},{key:"connectedInertiaScale",get:function(){return this._connectedColliderInfo.inertiaScale},set:function(e){if(e!==this._connectedColliderInfo.inertiaScale){var t;this._connectedColliderInfo.inertiaScale=e,null==(t=this._nativeJoint)||t.setConnectedInertiaScale(e)}}},{key:"inertiaScale",get:function(){return this._colliderInfo.inertiaScale},set:function(e){if(e!==this._colliderInfo.inertiaScale){var t;this._colliderInfo.inertiaScale=e,null==(t=this._nativeJoint)||t.setInertiaScale(e)}}},{key:"breakForce",get:function(){return this._force},set:function(e){if(e!==this._force){var t;this._force=e,null==(t=this._nativeJoint)||t.setBreakForce(e)}}},{key:"breakTorque",get:function(){return this._torque},set:function(e){if(e!==this._torque){var t;this._torque=e,null==(t=this._nativeJoint)||t.setBreakTorque(e)}}}]),t}(ru),e.Joint._tempVector3=new tT,tX([tZ],e.Joint.prototype,"_colliderInfo",void 0),tX([tZ],e.Joint.prototype,"_connectedColliderInfo",void 0),tX([tq],e.Joint.prototype,"_nativeJoint",void 0),tX([tq],e.Joint.prototype,"_onSelfTransformChanged",null),tX([tq],e.Joint.prototype,"_onConnectedTransformChanged",null),tX([tq],e.Joint.prototype,"_updateActualAnchor",null),e.Joint=tX([rh(e.Collider,r_.CheckOnly)],e.Joint);var iR=function(){this.collider=null,this.anchor=new tT,this.actualAnchor=new tT,this.massScale=1,this.inertiaScale=1};tX([tZ],iR.prototype,"anchor",void 0),tX([tZ],iR.prototype,"actualAnchor",void 0);var iM=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return tW(n,t),n.prototype._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n}(e.Joint),iw=((eM={})[eM.None=0]="None",eM[eM.LimitEnabled=1]="LimitEnabled",eM[eM.DriveEnabled=2]="DriveEnabled",eM[eM.DriveFreeSpin=4]="DriveFreeSpin",eM),iP=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._axis=new tT(1,0,0),n._hingeFlags=iw.None,n._useSpring=!1,n._angle=0,n._velocity=0,n._onMotorChanged=n._onMotorChanged.bind(n),n._onLimitsChanged=n._onLimitsChanged.bind(n),n}tW(n,t);var r=n.prototype;return r._onDisableInScene=function(){var e=this._nativeJoint;this._angle=e.getAngle(),this._velocity=e.getVelocity(),t.prototype._onDisableInScene.call(this)},r._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createHingeJoint(t.collider._nativeCollider)},r._syncNative=function(){t.prototype._syncNative.call(this);var e=this._jointMotor;this._nativeJoint.setAxis(this._axis),this._nativeJoint.setHingeJointFlag(iw.LimitEnabled,this.useLimits),this._nativeJoint.setHingeJointFlag(iw.DriveEnabled,this.useMotor),e&&(this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRatio),this._nativeJoint.setHingeJointFlag(iw.DriveFreeSpin,e.freeSpin))},r._onMotorChanged=function(){var e=this._jointMotor;this._nativeJoint&&(this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRatio),this._nativeJoint.setHingeJointFlag(iw.DriveFreeSpin,e.freeSpin))},r._onLimitsChanged=function(){var e=this._limits;e&&this._nativeJoint&&(this.useSpring?this._nativeJoint.setSoftLimit(e.min,e.max,e.stiffness,e.damping):this._nativeJoint.setHardLimit(e.min,e.max,e.contactDistance))},tG(n,[{key:"axis",get:function(){return this._axis},set:function(e){var t,n=this._axis;e!==n&&(n.copyFrom(e),null==(t=this._nativeJoint)||t.setAxis(n))}},{key:"angle",get:function(){var e=this._nativeJoint;return e&&(this._angle=e.getAngle()),this._angle}},{key:"velocity",get:function(){var e=this._nativeJoint;return e&&(this._velocity=e.getVelocity()),this._velocity}},{key:"useLimits",get:function(){return(this._hingeFlags&iw.LimitEnabled)==iw.LimitEnabled},set:function(e){if(e!==this.useLimits){var t;e?this._hingeFlags|=iw.LimitEnabled:this._hingeFlags&=~iw.LimitEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iw.LimitEnabled,e)}}},{key:"useMotor",get:function(){return(this._hingeFlags&iw.DriveEnabled)==iw.DriveEnabled},set:function(e){if(e!==this.useMotor){var t;e?this._hingeFlags|=iw.DriveEnabled:this._hingeFlags&=~iw.DriveEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iw.DriveEnabled,e)}}},{key:"useSpring",get:function(){return this._useSpring},set:function(e){this._useSpring!==e&&(this._useSpring=e,this._onLimitsChanged())}},{key:"motor",get:function(){return this._jointMotor},set:function(e){if(this._jointMotor!==e){var t;null==(t=this._jointMotor)||t._updateFlagManager.removeListener(this._onMotorChanged),this._jointMotor=e,null==e||e._updateFlagManager.addListener(this._onMotorChanged),this._onMotorChanged()}}},{key:"limits",get:function(){return this._limits},set:function(e){if(this._limits!==e){var t;null==(t=this._limits)||t._updateFlagManager.removeListener(this._onLimitsChanged),this._limits=e,null==e||e._updateFlagManager.addListener(this._onLimitsChanged),this._onLimitsChanged()}}}]),n}(e.Joint);tX([tZ],iP.prototype,"_axis",void 0),tX([tZ],iP.prototype,"_jointMotor",void 0),tX([tZ],iP.prototype,"_limits",void 0),tX([tq],iP.prototype,"_onMotorChanged",null),tX([tq],iP.prototype,"_onLimitsChanged",null);var iF=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e}tW(n,t);var r=n.prototype;return r._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createSpringJoint(t.collider._nativeCollider)},r._syncNative=function(){t.prototype._syncNative.call(this),this._nativeJoint.setMinDistance(this._minDistance),this._nativeJoint.setMaxDistance(this._maxDistance),this._nativeJoint.setTolerance(this._tolerance),this._nativeJoint.setStiffness(this._stiffness),this._nativeJoint.setDamping(this._damping)},tG(n,[{key:"minDistance",get:function(){return this._minDistance},set:function(e){if(this._minDistance!==e){var t;this._minDistance=e,null==(t=this._nativeJoint)||t.setMinDistance(e)}}},{key:"maxDistance",get:function(){return this._maxDistance},set:function(e){if(this._maxDistance!==e){var t;this._maxDistance=e,null==(t=this._nativeJoint)||t.setMaxDistance(e)}}},{key:"tolerance",get:function(){return this._tolerance},set:function(e){if(this._tolerance!==e){var t;this._tolerance=e,null==(t=this._nativeJoint)||t.setTolerance(e)}}},{key:"stiffness",get:function(){return this._stiffness},set:function(e){if(this._stiffness!==e){var t;this._stiffness=e,null==(t=this._nativeJoint)||t.setStiffness(e)}}},{key:"damping",get:function(){return this._damping},set:function(e){if(this._damping!==e){var t;this._damping=e,null==(t=this._nativeJoint)||t.setDamping(e)}}}]),n}(e.Joint),iL=/*#__PURE__*/function(){function e(){this._updateFlagManager=new nM,this._max=0,this._min=0,this._contactDistance=-1,this._stiffness=0,this._damping=0}return tG(e,[{key:"max",get:function(){return this._max},set:function(e){if(e<this._min)throw Error("Max limit must be greater than min limit");this._max!==e&&(this._max=e,this._updateFlagManager.dispatch())}},{key:"min",get:function(){return this._min},set:function(e){if(e>this._max)throw Error("Min limit must be less than max limit");this._min!==e&&(this._min=e,this._updateFlagManager.dispatch())}},{key:"contactDistance",get:function(){return -1===this._contactDistance?Math.min(.1,.49*(this._max-this._min)):this._contactDistance},set:function(e){this._contactDistance!==e&&(this._contactDistance=e,this._updateFlagManager.dispatch())}},{key:"stiffness",get:function(){return this._stiffness},set:function(e){this._stiffness!==e&&(this._stiffness=e,this._updateFlagManager.dispatch())}},{key:"damping",get:function(){return this._damping},set:function(e){this._damping!==e&&(this._damping=e,this._updateFlagManager.dispatch())}}]),e}();tX([tZ],iL.prototype,"_updateFlagManager",void 0);var iD=/*#__PURE__*/function(){function e(){this._updateFlagManager=new nM,this._targetVelocity=0,this._forceLimit=Number.MAX_VALUE,this._gearRatio=1,this._freeSpin=!1}return tG(e,[{key:"targetVelocity",get:function(){return this._targetVelocity},set:function(e){this._targetVelocity=e,this._updateFlagManager.dispatch()}},{key:"forceLimit",get:function(){return this._forceLimit},set:function(e){this._forceLimit=e,this._updateFlagManager.dispatch()}},{key:"gearRatio",get:function(){return this._gearRatio},set:function(e){this._gearRatio=e,this._updateFlagManager.dispatch()}},{key:"freeSpin",get:function(){return this._freeSpin},set:function(e){this._freeSpin=e,this._updateFlagManager.dispatch()}}]),e}();tX([tZ],iD.prototype,"_updateFlagManager",void 0);var iB=/*#__PURE__*/function(){function e(){this._isTrigger=!1,this._rotation=new tT,this._position=new tT,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new iS,this._id=e._idGenerator++,this._setRotation=this._setRotation.bind(this),this._setPosition=this._setPosition.bind(this),this._rotation._onValueChanged=this._setRotation,this._position._onValueChanged=this._setPosition,iJ._physicalObjectsMap[this._id]=this}var t=e.prototype;return t._cloneTo=function(e){e._syncNative()},t._destroy=function(){this._nativeShape.destroy(),this._nativeShape=null,delete iJ._physicalObjectsMap[this._id]},t._syncNative=function(){var e;this._nativeShape.setPosition(this._position),this._nativeShape.setRotation(this._rotation),this._nativeShape.setContactOffset(this._contactOffset),this._nativeShape.setIsTrigger(this._isTrigger),this._nativeShape.setMaterial(this._material._nativeMaterial),null==(e=this._collider)||e._handleShapesChanged()},t._setPosition=function(){var e;this._nativeShape.setPosition(this._position),null==(e=this._collider)||e._handleShapesChanged()},t._setRotation=function(){var e;this._nativeShape.setRotation(this._rotation),null==(e=this._collider)||e._handleShapesChanged()},tG(e,[{key:"collider",get:function(){return this._collider}},{key:"id",get:function(){return this._id}},{key:"contactOffset",get:function(){return this._contactOffset},set:function(e){e=Math.max(0,e),this._contactOffset!==e&&(this._contactOffset=e,this._nativeShape.setContactOffset(e))}},{key:"material",get:function(){return this._material},set:function(e){this._material!==e&&(this._material=e,this._nativeShape.setMaterial(e._nativeMaterial))}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation!=e&&this._rotation.copyFrom(e)}},{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"isTrigger",get:function(){return this._isTrigger},set:function(e){this._isTrigger!==e&&(this._isTrigger=e,this._nativeShape.setIsTrigger(e))}}]),e}();iB._idGenerator=0,tX([tq],iB.prototype,"_collider",void 0),tX([tq],iB.prototype,"_nativeShape",void 0),tX([tq],iB.prototype,"_id",void 0),tX([tZ],iB.prototype,"_rotation",void 0),tX([tZ],iB.prototype,"_position",void 0),tX([tq],iB.prototype,"_setPosition",null),tX([tq],iB.prototype,"_setRotation",null);var iI=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._size=new tT(1,1,1),t._nativeShape=ip._nativePhysics.createBoxColliderShape(t._id,t._size,t._material._nativeMaterial),t._size._onValueChanged=t._setSize.bind(t),t}tW(t,e);var n=t.prototype;return n._syncNative=function(){e.prototype._syncNative.call(this),this._setSize()},n._setSize=function(){this._nativeShape.setSize(this._size)},tG(t,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),t}(iB);tX([tZ],iI.prototype,"_size",void 0),tX([tq],iI.prototype,"_setSize",null);var iO=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._nativeShape=ip._nativePhysics.createSphereColliderShape(t._id,t._radius,t._material._nativeMaterial),t}return tW(t,e),t.prototype._syncNative=function(){e.prototype._syncNative.call(this),this._nativeShape.setRadius(this._radius)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),t}(iB),iN=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._nativeShape=ip._nativePhysics.createPlaneColliderShape(t._id,t._material._nativeMaterial),t}return tW(t,e),t}(iB),iV=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._height=2,t._upAxis=iA.Y,t._nativeShape=ip._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t}return tW(t,e),t.prototype._syncNative=function(){e.prototype._syncNative.call(this),this._nativeShape.setRadius(this._radius),this._nativeShape.setHeight(this._height),this._nativeShape.setUpAxis(this._upAxis)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._nativeShape.setHeight(e))}},{key:"upAxis",get:function(){return this._upAxis},set:function(e){this._upAxis!==e&&(this._upAxis=e,this._nativeShape.setUpAxis(e))}}]),t}(iB),ik=/*#__PURE__*/function(){function e(e,t){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=il.None,this._upMap=[],this._downMap=[],this._upList=new rC,this._downList=new rC,this._nativeEvents=[],"undefined"!=typeof Window&&tK(t,Window))throw"Do not set window as target because window cannot listen to pointer leave event.";this._engine=e,this._target=t,this._canvas=e.canvas,this._htmlCanvas=e._canvas._webCanvas,this._pointerPool=Array(11),this._onPointerEvent=this._onPointerEvent.bind(this),this._addEventListener()}var t=e.prototype;return t._update=function(){for(var e=this._pointers,t=this._nativeEvents,n=this._htmlCanvas,r=this._canvas,a=r.width,i=r.height,o=n.clientWidth,s=n.clientHeight,l=n.getBoundingClientRect(),c=l.left,u=l.top,d=a/o,h=i/s,_=e.length-1;_>=0;_--)e[_].phase===io.Leave&&e.splice(_,1);for(var f=0,p=t.length;f<p;f++){var m=t[f],g=m.pointerId,v=this._getPointerByID(g);if(v)v._events.push(m);else{var y=e.length;if(0===y||this._multiPointerEnabled){for(var x,b=this._pointerPool,C=0;C<y&&!(e[C].id>C);C++);(v=b[x=C]||(b[x]=new is(C)))._uniqueID=g,v._events.push(m),v.position.set((m.clientX-c)*d,(m.clientY-u)*h),e.splice(C,0,v)}}}t.length=0,this._upList.length=this._downList.length=0,this._buttons=il.None;for(var S=this._engine.time.frameCount,T=0,A=e.length;T<A;T++){var E=e[T];E._upList.length=E._downList.length=0,this._updatePointerInfo(S,E,c,u,d,h),this._buttons|=E.pressedButtons}},t._firePointerScript=function(e){for(var t=this._pointers,n=this._canvas,r=0,a=t.length;r<a;r++){var i=t[r],o=i._events,s=i.position;i._firePointerDrag();var l=this._pointerRayCast(e,s.x/n.width,s.y/n.height);i._firePointerExitAndEnter(l);var c=o.length;if(c>0){for(var u=0;u<c;u++)switch(o[u].type){case"pointerdown":i.phase=io.Down,i._firePointerDown(l);break;case"pointerup":i.phase=io.Up,i._firePointerUpAndClick(l);break;case"pointerleave":case"pointercancel":i.phase=io.Leave,i._firePointerExitAndEnter(null)}o.length=0}}},t._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},t._onPointerEvent=function(e){this._nativeEvents.push(e)},t._getPointerByID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return t[n];return null},t._updatePointerInfo=function(e,t,n,r,a,i){var o=t._events,s=t.position,l=o.length;if(l>0){var c=this._upList,u=this._upMap,d=this._downList,h=this._downMap,_=o[l-1],f=(_.clientX-n)*a,p=(_.clientY-r)*i;t.deltaPosition.set(f-s.x,p-s.y),s.set(f,p);for(var m=0;m<l;m++){var g=o[m],v=g.button;switch(t.button=ic[v]||il.None,t.pressedButtons=g.buttons,g.type){case"pointerdown":d.add(v),h[v]=e,t._downList.add(v),t._downMap[v]=e,t.phase=io.Down;break;case"pointerup":c.add(v),u[v]=e,t._upList.add(v),t._upMap[v]=e,t.phase=io.Up;break;case"pointermove":t.phase=io.Move;break;case"pointerleave":case"pointercancel":t.phase=io.Leave}}this._engine._physicsInitialized||(o.length=0)}else t.deltaPosition.set(0,0),t.phase=io.Stationary},t._pointerRayCast=function(t,n,r){for(var a=e._tempPoint,i=e._tempRay,o=e._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(l.isActive&&!l.destroyed)for(var c=l._componentsManager._activeCameras,u=c._elements,d=c.length-1;d>=0;d--){var h=u[d];if(!h.renderTarget){var _=h.viewport,f=_.x,p=_.y,m=_.z,g=_.w;if(n>=f&&r>=p&&n-f<=m&&r-p<=g){if(a.set((n-f)/m,(r-p)/g),l.physics.raycast(h.viewportPointToRay(a,i),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&rw.Color)return null}}}}return null},t._addEventListener=function(){var e=this._target,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t)},t._removeEventListener=function(){var e=this._target,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},e}();ik._tempRay=new tD,ik._tempPoint=new tB,ik._tempHitResult=new ib;var iz=/*#__PURE__*/function(){function e(e,t){this._delta=new tT,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}var t=e.prototype;return t._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var n=t.length-1;n>=0;n--){var r=t[n];e.x+=r.deltaX,e.y+=r.deltaY,e.z+=r.deltaZ}t.length=0}},t._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},t._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},t._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},t._onWheelEvent=function(e){this._nativeEvents.push(e)},e}(),iU=/*#__PURE__*/function(){function e(e,t){this._initialized=!1,this._engine=e;var n,r,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&tK(i,OffscreenCanvas)||(this._wheelManager=new iz(e,null!=(n=null==t?void 0:t.wheelTarget)?n:i),this._pointerManager=new ik(e,null!=(r=null==t?void 0:t.pointerTarget)?r:i),this._keyboardManager=new i_(e,null!=(a=null==t?void 0:t.keyboardTarget)?a:window),this._initialized=!0)}var t=e.prototype;return t.isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},t.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},t.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},t.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},t.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[iu[e]]===this._engine.time.frameCount)},t.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[iu[e]]===this._engine.time.frameCount)},t._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},t._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},t._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},tG(e,[{key:"pointers",get:function(){return this._initialized?this._pointerManager._pointers:[]}},{key:"multiPointerEnabled",get:function(){return!!this._initialized&&this._pointerManager._multiPointerEnabled},set:function(e){this._initialized&&(this._pointerManager._multiPointerEnabled=e)}},{key:"wheelDelta",get:function(){return this._initialized?this._wheelManager._delta:null}}]),e}(),iG=((ew={}).cornerTextureCoordinate="a_CornerTextureCoordinate",ew),iH=((eP={}).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",eP.DirectionTime="a_DirectionTime",eP.StartColor="a_StartColor",eP.StartSize="a_StartSize",eP.StartRotation0="a_StartRotation0",eP.StartSpeed="a_StartSpeed",eP.Random0="a_Random0",eP.Random1="a_Random1",eP.SimulationWorldPosition="a_SimulationWorldPosition",eP.SimulationWorldRotation="a_SimulationWorldRotation",eP.SimulationUV="a_SimulationUV",eP),iW=function e(t){this.billboardVertexElement=new at(iG.cornerTextureCoordinate,0,r7.Vector4,0),this.instanceVertexElements=[new at(iH.ShapePositionStartLifeTime,0,r7.Vector4,1,1),new at(iH.DirectionTime,16,r7.Vector4,1,1),new at(iH.StartColor,32,r7.Vector4,1,1),new at(iH.StartSize,48,r7.Vector3,1,1),new at(iH.StartRotation0,60,r7.Vector3,1,1),new at(iH.StartSpeed,72,r7.Float,1,1),new at(iH.Random0,76,r7.Vector4,1,1),new at(iH.Random1,92,r7.Vector4,1,1),new at(iH.SimulationWorldPosition,108,r7.Vector3,1,1),new at(iH.SimulationWorldRotation,120,r7.Vector4,1,1),new at(iH.SimulationUV,136,r7.Vector4,1,1)];var n=new r9(t,an.VertexBuffer,64,r8.Static,!1);n.isGCIgnored=!0,this.billboardVertexBufferBinding=new aS(n,16);var r=new r9(t,an.IndexBuffer,e.billboardIndexCount,r8.Static,!1);r.isGCIgnored=!0,this.billboardIndexBufferBinding=new ag(r,r6.UInt8);var a=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),i=new Uint8Array([0,2,3,0,1,2]);n.setData(a),r.setData(i),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tW(t,e),t.prototype.restoreContent=function(){n.setData(a)},t}(t2))),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,r)||this}return tW(t,e),t.prototype.restoreContent=function(){},t}(t2)))};iW.instanceVertexStride=152,iW.instanceVertexFloatStride=iW.instanceVertexStride/4,iW.startLifeTimeOffset=3,iW.timeOffset=7,iW.simulationUVOffset=34,iW.billboardIndexCount=6,iW.boundsFloatStride=8,iW.boundsTimeOffset=6,iW.boundsMaxLifetimeOffset=7;var ij="#define GLSLIFY 1\nattribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}",iX="#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}",iK=/*#__PURE__*/function(){function e(){}return e.init=function(){var e=new n6("ShadowCaster","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\n#include <uv_share>\nuniform mat4 camera_VPMat;uniform vec2 scene_ShadowBias;uniform vec3 scene_LightDirection;vec3 applyShadowBias(vec3 positionWS){positionWS-=scene_LightDirection*scene_ShadowBias.x;return positionWS;}vec3 applyShadowNormalBias(vec3 positionWS,vec3 normalWS){float invNdotL=1.0-clamp(dot(-scene_LightDirection,normalWS),0.0,1.0);float scale=invNdotL*scene_ShadowBias.y;positionWS+=normalWS*vec3(scale);return positionWS;}void main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\nvec4 positionWS=renderer_ModelMat*position;positionWS.xyz=applyShadowBias(positionWS.xyz);\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS=normalize(mat3(renderer_NormalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS);\n#endif\n#endif\nvec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}","#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nvec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;}\n#endif\nuniform vec4 material_BaseColor;uniform sampler2D material_BaseTexture;uniform float material_AlphaCutoff;varying vec2 v_uv;void main(){\n#if defined(MATERIAL_IS_ALPHA_CUTOFF) || (defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT))\nfloat alpha=material_BaseColor.a;\n#ifdef MATERIAL_HAS_BASETEXTURE\nalpha*=texture2D(material_BaseTexture,v_uv).a;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(alpha<material_AlphaCutoff){discard;}\n#endif\n#if defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT)\nfloat noise=fract(52.982919*fract(dot(vec2(0.06711,0.00584),gl_FragCoord.xy)));if(alpha<=noise){discard;};\n#endif\n#endif\n#ifdef ENGINE_NO_DEPTH_TEXTURE\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\n#endif\n}",{pipelineStage:nX.ShadowCaster});e._renderState=new ri,e._renderStateDataMap[nO.RenderQueueType]=as._shadowCasterRenderQueueProp;var t=[e,new n6("DepthOnly","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;void main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <position_vert>\n}","#define GLSLIFY 1\nvoid main(){}",{pipelineStage:nX.DepthOnly})],n={pipelineStage:nX.Forward};ro.create("blinn-phong",[].concat([new n6("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("pbr",[].concat([new n6("Forward",iX,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("pbr-specular",[].concat([new n6("Forward",iX,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("unlit",[].concat([new n6("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <position_vert>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\nuniform vec4 material_BaseColor;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\nvoid main(){vec4 baseColor=material_BaseColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\nbaseColor*=textureColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\ngl_FragColor=baseColor;\n#ifndef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)],t)),ro.create("blit",[new n6("Forward",ij,"#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){vec2 uv=v_uv;\n#ifdef renderer_FlipYBlitTexture\nuv.y=1.0-uv.y;\n#endif\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,uv);\n#endif\n}",n)]),ro.create("skybox",[new n6("Forward","#define GLSLIFY 1\n#include <common_vert>\nuniform mat4 camera_VPMat;varying vec3 v_cubeUV;uniform float material_Rotation;vec4 rotateY(vec4 v,float angle){const float deg2rad=3.1415926/180.0;float radian=angle*deg2rad;float sina=sin(radian);float cosa=cos(radian);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*v.xz,v.yw).xzyw;}void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=camera_VPMat*rotateY(vec4(POSITION,1.0),material_Rotation);}","#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;varying vec3 v_cubeUV;uniform float material_Exposure;uniform vec4 material_TintColor;void main(){vec4 textureColor=textureCube(material_CubeTexture,v_cubeUV);\n#ifdef MATERIAL_IS_DECODE_SKY_RGBM\ntextureColor=RGBMToLinear(textureColor,5.0);\n#elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\ntextureColor=gammaToLinear(textureColor);\n#endif\ntextureColor.rgb*=material_Exposure*material_TintColor.rgb;gl_FragColor=textureColor;\n#if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)]),ro.create("SkyProcedural",[new n6("Forward","#define GLSLIFY 1\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);attribute vec4 POSITION;uniform mat4 camera_VPMat;uniform vec3 material_SkyTint;uniform vec3 material_GroundTint;uniform float material_Exposure;uniform float material_AtmosphereThickness;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define COLOR_2_GAMMA(color) color\n#define COLOR_2_LINEAR(color) color*color\n#else\n#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=camera_VPMat*vec4(POSITION.xyz,1.0);vec3 skyTintInGammaSpace=COLOR_2_GAMMA(material_SkyTint);vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(POSITION.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-scene_SunlightDirection,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_Vertex=-POSITION.xyz;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=material_Exposure*(cIn+COLOR_2_LINEAR(material_GroundTint)*cOut);v_SkyColor=material_Exposure*(cIn*getRayleighPhase(-scene_SunlightDirection,-eyeRay));float lightColorIntensity=clamp(length(scene_SunlightColor.xyz),0.25,1.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#endif\n}","#define GLSLIFY 1\n#include <common>\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(material_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),material_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,material_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-scene_SunlightDirection,-ray);\n#endif\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\ncol=LINEAR_2_OUTPUT(col);\n#endif\ngl_FragColor=vec4(col,1.0);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)]),ro.create("particle-shader",[new n6("Forward","#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERER_MODE_MESH\nattribute vec3 a_MeshPosition;attribute vec4 a_MeshColor;attribute vec2 a_MeshTextureCoordinate;varying vec4 v_MeshColor;\n#endif\nattribute vec4 a_ShapePositionStartLifeTime;attribute vec4 a_DirectionTime;attribute vec4 a_StartColor;attribute vec3 a_StartSize;attribute vec3 a_StartRotation0;attribute float a_StartSpeed;attribute vec4 a_Random0;\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nattribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPosition;attribute vec4 a_SimulationWorldRotation;varying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\nattribute vec4 a_SimulationUV;varying vec2 v_TextureCoordinate;\n#endif\nuniform float renderer_CurrentTime;uniform vec3 renderer_Gravity;uniform vec2 u_DragConstant;uniform vec3 renderer_WorldPosition;uniform vec4 renderer_WorldRotation;uniform bool renderer_ThreeDStartRotation;uniform int renderer_ScalingMode;uniform vec3 renderer_PositionScale;uniform vec3 renderer_SizeScale;uniform vec3 renderer_PivotOffset;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nuniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward;uniform vec3 camera_Up;uniform float renderer_StretchedBillboardLengthScale;uniform float renderer_StretchedBillboardSpeedScale;uniform int renderer_SimulationSpace;\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\nvoid main(){float age=renderer_CurrentTime-a_DirectionTime.w;float normalizedAge=age/a_ShapePositionStartLifeTime.w;vec3 lifeVelocity;if(normalizedAge<1.0){vec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifeVelocity=computeParticleLifeVelocity(normalizedAge);\n#endif\nvec3 gravityVelocity=renderer_Gravity*a_Random0.x*age;vec4 worldRotation;if(renderer_SimulationSpace==0){worldRotation=renderer_WorldRotation;}else{worldRotation=a_SimulationWorldRotation;}vec3 dragData=a_DirectionTime.xyz*mix(u_DragConstant.x,u_DragConstant.y,a_Random0.x);vec3 center=computeParticlePosition(startVelocity,lifeVelocity,age,normalizedAge,gravityVelocity,worldRotation,dragData);\n#include <sphere_billboard>\n#include <stretched_billboard>\n#include <horizontal_billboard>\n#include <vertical_billboard>\n#include <particle_mesh>\ngl_Position=camera_ProjMat*camera_ViewMat*vec4(center,1.0);v_Color=computeParticleColor(a_StartColor,normalizedAge);\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec2 simulateUV;\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nsimulateUV=a_CornerTextureCoordinate.zw*a_SimulationUV.xy+a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#ifdef RENDERER_MODE_MESH\nsimulateUV=a_SimulationUV.xy+a_MeshTextureCoordinate*a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#endif\n}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}","#define GLSLIFY 1\n#include <common>\nvarying vec4 v_Color;varying vec2 v_TextureCoordinate;uniform sampler2D material_BaseTexture;uniform vec4 material_BaseColor;\n#ifdef RENDERER_MODE_MESH\nvarying vec4 v_MeshColor;\n#endif\nvoid main(){vec4 color=material_BaseColor*v_Color;\n#ifdef RENDERER_MODE_MESH\ncolor*=v_MeshColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_TextureCoordinate);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\ncolor*=textureColor;\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",n)]),ro.create("SpriteMask",[new n6("Forward","#define GLSLIFY 1\nuniform mat4 camera_VPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=camera_VPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;uniform float renderer_MaskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(renderer_MaskTexture,v_uv);if(color.a<renderer_MaskAlphaCutoff){discard;}gl_FragColor=color;}",n)]),ro.create("Sprite",[new n6("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderer_SpriteTexture,v_uv);gl_FragColor=baseColor*v_color;}",n)]),ro.create("Text",[new n6("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderElement_TextTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderElement_TextTexture,v_uv);gl_FragColor=baseColor*v_color;}",n)]),ro.create("background-texture",[new n6("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform vec4 camera_ProjectionParams;void main(){gl_Position=vec4(POSITION,1.0);gl_Position.y*=camera_ProjectionParams.x;v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",n)])},e}(),iY=/*#__PURE__*/function(){function e(e){this.engine=e,this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}var t=e.prototype;return t.get=function(e){var t=this._cacheMap,n=e._length,r=this._cacheHierarchyDepth;n>r&&(this._resizeCacheMapHierarchy(t,0,r,n-r),this._cacheHierarchyDepth=n);for(var a=e._mask,i=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=i<s?0:a[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var u=i<o?0:a[o],d=t[u];return d||(this._lastQueryKey=u,this._lastQueryMap=t),d},t.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},t._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},t._recursiveDestroy=function(e,t){if(e===this._cacheHierarchyDepth-1){for(var n in t)t[n].destroy();return}for(var r in++e,t)this._recursiveDestroy(e,t[r])},t._resizeCacheMapHierarchy=function(e,t,n,r){if(t==n-1)for(var a in e){for(var i=e[a],o=e,s=0;s<r;s++)o[0==s?a:0]=o=Object.create(null);o[0]=i}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,n,r)},e}(),iq=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._usedElementCount=0,n._elements=[],n}tW(t,e);var n=t.prototype;return n.get=function(){var e=this._usedElementCount,t=this._elements;if(this._usedElementCount++,t.length!==e)return t[e];var n=new this._type;return t.push(n),n},n.clear=function(){this._usedElementCount=0},t}(aq),iQ=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t._initialize=function(e,t){},t._update=function(){},t._destroy=function(){},t._getRequestAnimationFrame=function(){return null},t._getCancelAnimationFrame=function(){return null},t._getCameraIgnoreClearFlags=function(e){return rw.None},e}();iK.init();var iJ=/*#__PURE__*/function(e){function t(n,r,a){(i=e.call(this)||this)._physicsInitialized=!1,i._lastRenderState=new ri,i._renderElementPool=new iq(r0),i._subRenderElementPool=new iq(r1),i._textSubRenderElementPool=new iq(r1),i._charRenderInfoPool=new aQ(tj,50),i._renderContext=new rk,i._renderCount=0,i._shaderProgramPools=[],i._fontMap={},i._macroCollection=new nW,i._settings={},i._resourceManager=new ie(i),i._sceneManager=new a4(i),i._vSyncCount=1,i._targetFrameRate=60,i._time=new nq,i._isPaused=!0,i._vSyncCounter=1,i._targetFrameInterval=1e3/60,i._destroyed=!1,i._frameInProcess=!1,i._waitingDestroy=!1,i._isDeviceLost=!1,i._waitingGC=!1,i._animate=function(){if(i._vSyncCount){var e,t=(null==(e=i.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;i._requestId=t(i._animate),i._vSyncCounter++%i._vSyncCount==0&&(i.update(),i._vSyncCounter=1)}else i._timeoutId=window.setTimeout(i._animate,i._targetFrameInterval),i.update()},i._hardwareRenderer=r,i._hardwareRenderer.init(n,i._onDeviceLost.bind(i),i._onDeviceRestored.bind(i)),i._canvas=n,i._textDefaultFont=ng.createFromOS(i,"Arial"),i._textDefaultFont.isGCIgnored=!0,i._batcherManager=new a1(i),i.inputManager=new iU(i,a.input);var i,o=a.xrDevice;if(o&&(i.xrManager=new iQ,i.xrManager._initialize(i,o)),r.canIUse(nJ.depthTexture)){var s=new nc(i,1,1,t9.Depth16,!1);s.isGCIgnored=!0,i._depthTexture2D=s}else i._macroCollection.enable(t._noDepthTextureMacro);var l=new ao(i,ro.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new tO(1,0,1.01,1)),i._meshMagentaMaterial=l;var c=new ao(i,ro.find("particle-shader"));c.isGCIgnored=!0,c.shaderData.setColor("material_BaseColor",new tO(1,0,1.01,1)),i._particleMagentaMaterial=c;var u=i._settings,d=a.colorSpace||n2.Linear;return d===n2.Gamma&&i._macroCollection.enable(t._gammaMacro),u.colorSpace=d,i._basicResources=new aY(i),i._particleBufferUtils=new iW(i),i}tW(t,e);var n=t.prototype;return n.createEntity=function(e){return new aW(this,e)},n.pause=function(){var e;this._isPaused=!0,((null==(e=this.xrManager)?void 0:e._getCancelAnimationFrame())||cancelAnimationFrame)(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){if(this._isPaused){if(this._isPaused=!1,this.time._reset(),this._vSyncCount){var e,t=(null==(e=this.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;this._requestId=t(this._animate)}else this._timeoutId=window.setTimeout(this._animate,this._targetFrameInterval)}},n.update=function(){var e,t=this._time;t._update();var n=t.deltaTime;this._frameInProcess=!0,this._subRenderElementPool.clear(),this._textSubRenderElementPool.clear(),this._renderElementPool.clear(),null==(e=this.xrManager)||e._update();var r=this.inputManager,a=this._physicsInitialized;r._update();for(var i=this._sceneManager._scenes.getLoopArray(),o=i.length,s=0;s<o;s++){var l=i[s];if(l.isActive&&!l.destroyed){var c=l._componentsManager;c.sortCameras(),c.callScriptOnStart()}}if(a)for(var u=0;u<o;u++){var d=i[u];d.isActive&&!d.destroyed&&d.physics._update(n)}a&&r._firePointerScript(i);for(var h=0;h<o;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(n)}for(var f=0;f<o;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(n)}for(var m=0;m<o;m++){var g=i[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(n)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var v=0;v<o;v++){var y=i[v];y.isActive&&!y.destroyed&&y._componentsManager.handlingInvalidScripts()}this._waitingGC&&(this._gc(),this._waitingGC=!1),this._frameInProcess=!1},n.run=function(){this.resume(),this.dispatch("run",this)},n.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},n.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},n._destroy=function(){var e;this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),this._batcherManager.destroy(),null==(e=this.xrManager)||e._destroy(),this.dispatch("shutdown",this),this.pause(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e){var t=e._shaderPassId,n=this._shaderProgramPools,r=n[t];if(!r){var a=t+1;a>n.length&&(n.length=a),n[t]=r=new iY(this),e._shaderProgramPools.push(r)}return r},n._render=function(e){for(var t=this,n=this.time.deltaTime,r=0,a=e.length;r<a;r++){var i=e[r];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(n),i._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(n,r){var a=e[n];if(a.isActive&&!a.destroyed){var i=a._componentsManager._activeCameras;if(0===i.length)return no.debug("No active camera in scene.");i.forEach(function(e){var n=a._componentsManager;n.callCameraOnBeginRender(e),e.render(),n.callCameraOnEndRender(e),t._hardwareRenderer._options._forceFlush&&t._hardwareRenderer.flush()},function(e,t){e._cameraIndex=t})}}(o)},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,n=e.shaderLab,r=e.physics;n&&!ro._shaderLab&&(ro._shaderLab=n);var a=[];r&&a.push(r.initialize().then(function(){return ip._nativePhysics=r,t._nativePhysicsManager=r.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=ie._loaders;for(var o in i){var s=i[o];s.initialize&&a.push(s.initialize(this,e))}return Promise.all(a).then(function(){return t})},n._onDeviceLost=function(){this._isDeviceLost=!0,this.resourceManager._lostGraphicResources(),console.log("Device lost."),this.dispatch("devicelost",this)},n._onDeviceRestored=function(){var e=this;this._hardwareRenderer.resetState(),this._lastRenderState=new ri,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),t._restoreResourcesContent().then(function(){console.log("Graphic resource content restored.\n\nDevice restored."),e.dispatch("devicerestored",e),e._isDeviceLost=!1}).catch(function(e){console.error(e)})},n._gc=function(){this._subRenderElementPool.garbageCollection(),this._textSubRenderElementPool.garbageCollection(),this._renderElementPool.garbageCollection(),this._renderContext.garbageCollection()},tG(t,[{key:"settings",get:function(){return this._settings}},{key:"canvas",get:function(){return this._canvas}},{key:"resourceManager",get:function(){return this._resourceManager}},{key:"sceneManager",get:function(){return this._sceneManager}},{key:"time",get:function(){return this._time}},{key:"isPaused",get:function(){return this._isPaused}},{key:"vSyncCount",get:function(){return this._vSyncCount},set:function(e){this._vSyncCount=Math.max(0,Math.floor(e))}},{key:"targetFrameRate",get:function(){return this._targetFrameRate},set:function(e){e=Math.max(1e-6,e),this._targetFrameRate=e,this._targetFrameInterval=1e3/e}},{key:"destroyed",get:function(){return this._destroyed}},{key:"physicsManager",get:function(){var e;return null==(e=this.sceneManager.scenes[0])?void 0:e.physics}}]),t}(nK);iJ._gammaMacro=nH.getByName("ENGINE_IS_COLORSPACE_GAMMA"),iJ._noDepthTextureMacro=nH.getByName("ENGINE_NO_DEPTH_TEXTURE"),iJ._pixelsPerUnit=100,iJ._physicalObjectsMap={};var iZ=/*#__PURE__*/function(){function e(){this._sizeUpdateFlagManager=new nM}return tG(e,[{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._onWidthChanged(e),this._sizeUpdateFlagManager.dispatch())}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._onHeightChange(e),this._sizeUpdateFlagManager.dispatch())}}]),e}(),i$=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.destroy=function(){this.mesh=null,this.material=null},t._render=function(t){var n=this.material,r=this.mesh;if(!n){no.warn("The material of sky is not defined.");return}if(n.destroyed){no.warn("The material of sky is destroyed.");return}if(!r){no.warn("The mesh of sky is not defined.");return}if(r.destroyed){no.warn("The mesh of sky is destroyed.");return}var a=t.camera,i=a.engine,o=a.scene,s=a.aspectRatio,l=a.fieldOfView,c=a.viewMatrix,u=a.shaderData,d=o.shaderData,h=e._viewProjMatrix,_=e._projectionMatrix,f=i._hardwareRenderer,p=n.shaderData,m=n.shader,g=n.renderState;h.copyFrom(c);var v=h.elements;v[12]=v[13]=v[14]=0;var y=1/Math.tan(tS.degreeToRadian(l)/2);_.elements[0]=y/s,_.elements[5]=y,tL.multiply(_,h,h);var x=u.getMatrix(rk.vpMatrixProperty);t.flipProjection&&tL.multiply(rk._flipYMatrix,h,h),u.setMatrix(rk.vpMatrixProperty,h);var b=ro._compileMacros;nW.unionCollection(t.camera._globalShaderMacro,p._macroCollection,b);var C=m.subShaders[0].passes[0],S=C._getShaderProgram(i,b);S.bind(),S.groupingOtherUniformBlock(),S.uploadAll(S.sceneUniformBlock,d),S.uploadAll(S.cameraUniformBlock,u),S.uploadAll(S.materialUniformBlock,p),S.uploadUnGroupTextures(),g._applyStates(i,!1,C._renderStateDataMap,p),f.drawPrimitive(r._primitive,r.subMesh,S),u.setMatrix(rk.vpMatrixProperty,x)},tG(e,[{key:"material",get:function(){return this._material},set:function(e){if(this._material!==e){var t;null==e||e._addReferCount(1),null==(t=this._material)||t._addReferCount(-1),this._material=e}}},{key:"mesh",get:function(){return this._mesh},set:function(e){if(this._mesh!==e){var t;null==e||e._addReferCount(1),null==(t=this._mesh)||t._addReferCount(-1),this._mesh=e}}}]),e}();i$._epsilon=1e-6,i$._viewProjMatrix=new tL,i$._projectionMatrix=new tL(1,0,0,0,0,1,0,0,0,0,i$._epsilon-1,-1,0,0,0,0);var i0=/*#__PURE__*/function(){function e(e){this._engine=e,this.mode=rO.SolidColor,this.solidColor=new tO(.25,.25,.25,1),this.sky=new i$,this._textureFillMode=rN.AspectFitHeight,this._texture=null,this._initMesh(e),this._initMaterial(e)}var t=e.prototype;return t.destroy=function(){this.texture=null,this._mesh._addReferCount(-1),this._mesh=null,this._material._addReferCount(-1),this._material=null,this.solidColor=null,this.sky.destroy()},t._resizeBackgroundTexture=function(){var e=this._texture,t=this._mesh;if(this._texture){var n=this._engine.canvas,r=n.width,a=n.height,i=t.getPositions();switch(this._textureFillMode){case rN.Fill:i[0].set(-1,-1,1),i[1].set(1,-1,1),i[2].set(-1,1,1),i[3].set(1,1,1);break;case rN.AspectFitWidth:var o=e.height*r/e.width/a;i[0].set(-1,-o,1),i[1].set(1,-o,1),i[2].set(-1,o,1),i[3].set(1,o,1);break;case rN.AspectFitHeight:var s=e.width*a/e.height/r;i[0].set(-s,-1,1),i[1].set(s,-1,1),i[2].set(-s,1,1),i[3].set(s,1,1)}t.setPositions(i),t.uploadData(!1)}},t._initMesh=function(e){var t=this._mesh=this._createPlane(e);e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,t)||this}return tW(n,e),n.prototype.restoreContent=function(){t.setPositions(t.getPositions()),t.setUVs(t.getUVs()),t.setIndices(t.getIndices()),t.uploadData(!1)},n}(t2))),this._mesh._addReferCount(1)},t._initMaterial=function(e){var t=this._material=new ao(e,ro.find("background-texture"));t.renderState.depthState.compareFunction=nB.LessEqual,t._addReferCount(1)},t._createPlane=function(e){for(var t=new aM(e),n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],a=[,,,,],i=0;i<4;++i)r[i]=new tT,a[i]=new tB(i%2,1-(.5*i|0));return t.setPositions(r),t.setUVs(a),t.setIndices(n),t.uploadData(!1),t.addSubMesh(0,n.length),t},tG(e,[{key:"texture",get:function(){return this._texture},set:function(e){if(this._texture!==e){var t;null==e||e._addReferCount(1),null==(t=this._texture)||t._addReferCount(-1),this._texture=e,this._material.shaderData.setTexture("material_BaseTexture",e),this._resizeBackgroundTexture()}}},{key:"textureFillMode",get:function(){return this._textureFillMode},set:function(e){e!==this._textureFillMode&&(this._textureFillMode=e,this._resizeBackgroundTexture())}}]),e}(),i1=/*#__PURE__*/function(){function e(){this._cameraNeedSorting=!1,this._activeCameras=new rC,this._renderers=new rC,this._onStartScripts=new rC,this._onUpdateScripts=new rC,this._onLateUpdateScripts=new rC,this._onPhysicsUpdateScripts=new rC,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new rC,this._onUpdateRenderers=new rC,this._componentsContainerPool=[]}var t=e.prototype;return t.addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},t.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},t.sortCameras=function(){if(this._cameraNeedSorting){var e=this._activeCameras;e.sort(function(e,t){return e.priority-t.priority});for(var t=0,n=e.length;t<n;t++)e.get(t)._cameraIndex=t;this._cameraNeedSorting=!1}},t.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},t.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},t.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},t.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},t.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},t.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},t.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},t.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},t.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},t.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},t.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},t.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},t.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()},function(e,t){e._onStartIndex=t})},t.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},t.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},t.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},t.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},t.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},t.handlingInvalidScripts=function(){var e=this._disposeDestroyScripts,t=this._pendingDestroyScripts;this._disposeDestroyScripts=t,this._pendingDestroyScripts=e;var n=t.length;if(n>0){for(var r=n-1;r>=0;r--)t[r].onDestroy();t.length=0}},t.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},t.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},t.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},t.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},t._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},e}(),i2=/*#__PURE__*/function(){function e(){this.hasStencilWritten=!1,this._preMaskLayer=rg.Nothing,this._allSpriteMasks=new rC}var t=e.prototype;return t.addSpriteMask=function(e){e._maskIndex=this._allSpriteMasks.length,this._allSpriteMasks.add(e)},t.removeSpriteMask=function(e){var t=this._allSpriteMasks.deleteByIndex(e._maskIndex);t&&(t._maskIndex=e._maskIndex),e._maskIndex=-1},t.drawMask=function(t,n,r){var a=e.getMaskIncrementRenderQueue();a.clear();var i=e.getMaskDecrementRenderQueue();i.clear(),this._buildMaskRenderElement(r,a,i);var o=t.camera.engine._batcherManager;a.batch(o),o.uploadBuffer(),a.render(t,n,rU.Increment),i.batch(o),o.uploadBuffer(),i.render(t,n,rU.Decrement)},t.clearMask=function(t,n){var r=this._preMaskLayer;if(r!==rg.Nothing){if(this.hasStencilWritten){var a=e.getMaskDecrementRenderQueue();a.clear();for(var i=this._allSpriteMasks,o=0,s=i.length;o<s;o++){var l=i.get(o);l.influenceLayers&r&&a.pushRenderElement(l._renderElement)}var c=t.camera.engine._batcherManager;a.batch(c),c.uploadBuffer(),a.render(t,n,rU.Decrement)}else{var u=t.camera.engine;u._hardwareRenderer.clearRenderTarget(u,rw.Stencil,null)}this._preMaskLayer=rg.Nothing}},t.isStencilWritten=function(e){var t=e.renderState.stencilState,n=nk.Keep;return!!t.enabled&&0!==t.writeMask&&(t.passOperationFront!==n||t.passOperationBack!==n||t.failOperationFront!==n||t.failOperationBack!==n||t.zFailOperationFront!==n||t.zFailOperationBack!==n)},t.isReadStencil=function(e){var t=e.renderState.stencilState,n=t.enabled,r=t.mask,a=t.compareFunctionFront,i=t.compareFunctionBack;return!!n&&0!==r&&(a!==nB.Always&&a!==nB.Never||i!==nB.Always&&i!==nB.Never)},t.destroy=function(){var e=this._allSpriteMasks;e.length=0,e.garbageCollection()},t._buildMaskRenderElement=function(e,t,n){var r=this._preMaskLayer;if(r!==e){for(var a=this._allSpriteMasks,i=r&e,o=r&~e,s=a._elements,l=0,c=a.length;l<c;l++){var u=s[l],d=u.influenceLayers;!(d&i)&&(d&e?t.pushRenderElement(u._renderElement):d&o&&n.pushRenderElement(u._renderElement))}this._preMaskLayer=e}},e.getMaskIncrementRenderQueue=function(){return e._maskIncrementRenderQueue||(e._maskIncrementRenderQueue=new rG(nN.Transparent))},e.getMaskDecrementRenderQueue=function(){return e._maskDecrementRenderQueue||(e._maskDecrementRenderQueue=new rG(nN.Transparent))},e}(),i3=((eF={})[eF.None=0]="None",eF[eF.Linear=1]="Linear",eF[eF.Exponential=2]="Exponential",eF[eF.ExponentialSquared=3]="ExponentialSquared",eF),i4=((eL={})[eL.SolidColor=0]="SolidColor",eL[eL.SphericalHarmonics=1]="SphericalHarmonics",eL),i8=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._diffuseSolidColor=new tO(.212,.227,.259),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=i4.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n._specularTextureDecodeRGBM=!1,n}tW(t,e);var n=t.prototype;return n._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var n=e.shaderData;n.setColor(t._diffuseColorProperty,this._diffuseSolidColor),n.setFloat(t._diffuseIntensityProperty,this._diffuseIntensity),n.setFloat(t._specularIntensityProperty,this._specularIntensity),n.setFloatArray(t._diffuseSHProperty,this._shArray),this._setDiffuseMode(n),this._setSpecularTextureDecodeRGBM(n),this._setSpecularTexture(n)},n._removeFromScene=function(e){this._addReferCount(-1);var n=this._scenes,r=n.indexOf(e);n.splice(r,1);var a=e.shaderData;a.setTexture(t._specularTextureProperty,null),a.disableMacro(t._specularMacro)},n._setDiffuseMode=function(e){this._diffuseMode===i4.SphericalHarmonics?e.enableMacro(t._shMacro):e.disableMacro(t._shMacro)},n._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(t._specularTextureProperty,this._specularTexture),e.setFloat(t._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(t._specularMacro)):e.disableMacro(t._specularMacro)},n._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(t._decodeRGBMMacro):e.disableMacro(t._decodeRGBMMacro)},n._preComputeSH=function(e,t){var n=e.coefficients;t[0]=.886227*n[0],t[1]=.886227*n[1],t[2]=.886227*n[2],t[3]=-1.023327*n[3],t[4]=-1.023327*n[4],t[5]=-1.023327*n[5],t[6]=1.023327*n[6],t[7]=1.023327*n[7],t[8]=1.023327*n[8],t[9]=-1.023327*n[9],t[10]=-1.023327*n[10],t[11]=-1.023327*n[11],t[12]=.858086*n[12],t[13]=.858086*n[13],t[14]=.858086*n[14],t[15]=-.858086*n[15],t[16]=-.858086*n[16],t[17]=-.858086*n[17],t[18]=.247708*n[18],t[19]=.247708*n[19],t[20]=.247708*n[20],t[21]=-.858086*n[21],t[22]=-.858086*n[22],t[23]=-.858086*n[23],t[24]=.429042*n[24],t[25]=.429042*n[25],t[26]=.429042*n[26]},tG(t,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTextureDecodeRGBM(t[n].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setDiffuseMode(t[n].shaderData)}},{key:"diffuseSolidColor",get:function(){return this._diffuseSolidColor},set:function(e){e!==this._diffuseSolidColor&&this._diffuseSolidColor.copyFrom(e)}},{key:"diffuseSphericalHarmonics",get:function(){return this._diffuseSphericalHarmonics},set:function(e){if(this._diffuseSphericalHarmonics=e,e){this._preComputeSH(e,this._shArray);for(var n=this._scenes,r=0,a=n.length;r<a;r++)n[r].shaderData.setFloatArray(t._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var n=this._scenes,r=0,a=n.length;r<a;r++)n[r].shaderData.setFloat(t._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTexture(t[n].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var n=0,r=this._scenes.length;n<r;n++)this._scenes[n].shaderData.setFloat(t._specularIntensityProperty,e)}}]),t}(t1);i8._shMacro=nH.getByName("SCENE_USE_SH"),i8._specularMacro=nH.getByName("SCENE_USE_SPECULAR_ENV"),i8._decodeRGBMMacro=nH.getByName("SCENE_IS_DECODE_ENV_RGBM"),i8._diffuseColorProperty=nY.getByName("scene_EnvMapLight.diffuse"),i8._diffuseSHProperty=nY.getByName("scene_EnvSH"),i8._diffuseIntensityProperty=nY.getByName("scene_EnvMapLight.diffuseIntensity"),i8._specularTextureProperty=nY.getByName("scene_EnvSpecularSampler"),i8._specularIntensityProperty=nY.getByName("scene_EnvMapLight.specularIntensity"),i8._mipLevelProperty=nY.getByName("scene_EnvMapLight.mipMapLevel");var i5=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.intensity=1,t.cullingMask=rE.Everything,t.shadowType=rj.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t._lightIndex=-1,t._lightColor=new tO,t._shadowStrength=1,t._color=new tO(1,1,1,1),t}return tW(t,e),t.prototype._getLightIntensityColor=function(){return this._lightColor.r=this.color.r*this.intensity,this._lightColor.g=this.color.g*this.intensity,this._lightColor.b=this.color.b*this.intensity,this._lightColor.a=this.color.a*this.intensity,this._lightColor},tG(t,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=tS.clamp(e,0,1)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"viewMatrix",get:function(){return this._viewMat||(this._viewMat=new tL),tL.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new tL),tL.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),t}(ru);tX([tq],i5.prototype,"_lightIndex",void 0);var i9=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shadowNearPlaneOffset=.1,t._reverseDirection=new tT,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=this._getLightIntensityColor(),o=this.direction,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(i.r),t.color[r+1]=tO.gammaToLinearSpace(i.g),t.color[r+2]=tO.gammaToLinearSpace(i.b)):(t.color[r]=i.r,t.color[r+1]=i.g,t.color[r+2]=i.b),t.direction[a]=o.x,t.direction[a+1]=o.y,t.direction[a+2]=o.z},n._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._directionProperty,n.direction)},tG(t,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tT.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}}]),t}(i5);i9._cullingMaskProperty=nY.getByName("scene_DirectLightCullingMask"),i9._colorProperty=nY.getByName("scene_DirectLightColor"),i9._directionProperty=nY.getByName("scene_DirectLightDirection");var i6=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=this._getLightIntensityColor(),o=this.position,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(i.r),t.color[r+1]=tO.gammaToLinearSpace(i.g),t.color[r+2]=tO.gammaToLinearSpace(i.b)):(t.color[r]=i.r,t.color[r+1]=i.g,t.color[r+2]=i.b),t.position[a]=o.x,t.position[a+1]=o.y,t.position[a+2]=o.z,t.distance[e]=this.distance},n._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._positionProperty,n.position),e.setFloatArray(t._distanceProperty,n.distance)},tG(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}}]),t}(i5);i6._cullingMaskProperty=nY.getByName("scene_PointLightCullingMask"),i6._colorProperty=nY.getByName("scene_PointLightColor"),i6._positionProperty=nY.getByName("scene_PointLightPosition"),i6._distanceProperty=nY.getByName("scene_PointLightDistance");var i7=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t.angle=Math.PI/6,t.penumbra=Math.PI/12,t._inverseDirection=new tT,t._projectMatrix=new tL,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=3*e,o=this._getLightIntensityColor(),s=this.position,l=this.direction,c=this.cullingMask;t.cullingMask[n]=65535&c,t.cullingMask[n+1]=c>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(o.r),t.color[r+1]=tO.gammaToLinearSpace(o.g),t.color[r+2]=tO.gammaToLinearSpace(o.b)):(t.color[r]=o.r,t.color[r+1]=o.g,t.color[r+2]=o.b),t.position[a]=s.x,t.position[a+1]=s.y,t.position[a+2]=s.z,t.direction[i]=l.x,t.direction[i+1]=l.y,t.direction[i+2]=l.z,t.distance[e]=this.distance,t.angleCos[e]=Math.cos(this.angle),t.penumbraCos[e]=Math.cos(this.angle+this.penumbra)},n._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._positionProperty,n.position),e.setFloatArray(t._directionProperty,n.direction),e.setFloatArray(t._distanceProperty,n.distance),e.setFloatArray(t._angleCosProperty,n.angleCos),e.setFloatArray(t._penumbraCosProperty,n.penumbraCos)},tG(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tT.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}}]),t}(i5);i7._cullingMaskProperty=nY.getByName("scene_SpotLightCullingMask"),i7._colorProperty=nY.getByName("scene_SpotLightColor"),i7._positionProperty=nY.getByName("scene_SpotLightPosition"),i7._directionProperty=nY.getByName("scene_SpotLightDirection"),i7._distanceProperty=nY.getByName("scene_SpotLightDistance"),i7._angleCosProperty=nY.getByName("scene_SpotLightAngleCos"),i7._penumbraCosProperty=nY.getByName("scene_SpotLightPenumbraCos");var oe=/*#__PURE__*/function(){function e(){this._spotLights=new rC,this._pointLights=new rC,this._directLights=new rC,this._directData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),direction:new Float32Array(3*e._maxLight)},this._pointData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),position:new Float32Array(3*e._maxLight),distance:new Float32Array(e._maxLight)},this._spotData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),position:new Float32Array(3*e._maxLight),direction:new Float32Array(3*e._maxLight),distance:new Float32Array(e._maxLight),angleCos:new Float32Array(e._maxLight),penumbraCos:new Float32Array(e._maxLight)}}var t=e.prototype;return t._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},t._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},t._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},t._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._updateShaderData=function(t){for(var n=this._spotLights,r=this._pointLights,a=this._directLights,i=this._spotData,o=this._pointData,s=this._directData,l=e._maxLight,c=Math.min(n.length,l),u=Math.min(r.length,l),d=Math.min(a.length,l),h=0;h<c;h++)n.get(h)._appendData(h,i);for(var _=0;_<u;_++)r.get(_)._appendData(_,o);for(var f=0;f<d;f++)a.get(f)._appendData(f,s);d?(i9._updateShaderData(t,s),t.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):t.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(i6._updateShaderData(t,o),t.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):t.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(i7._updateShaderData(t,i),t.enableMacro("SCENE_SPOT_LIGHT_COUNT",c.toString())):t.disableMacro("SCENE_SPOT_LIGHT_COUNT")},t._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},t._updateSunlightIndex=function(e){var t=this._directLights,n=e._lightIndex;if(n>0){var r=t.get(0),a=t.get(n);t.set(0,a),t.set(n,r),a._lightIndex=0,r._lightIndex=n}},t._getMaxBrightestSunlight=function(){for(var e=this._directLights,t=null,n=Number.NEGATIVE_INFINITY,r=!1,a=0,i=e.length;a<i;a++){var o=e.get(a);o.shadowType===rj.None||r||(n=Number.NEGATIVE_INFINITY,r=!0);var s=o.intensity*o.color.getBrightness();r?o.shadowType!==rj.None&&n<s&&(n=s,t=o):n<s&&(n=s,t=o)}return t},e}();oe._sunlightColorProperty=nY.getByName("scene_SunlightColor"),oe._sunlightDirectionProperty=nY.getByName("scene_SunlightDirection"),oe._maxLight=10;var ot=((eD={})[eD.Half=0]="Half",eD[eD.Quarter=1]="Quarter",eD),on=/*#__PURE__*/function(){function e(t){this._uberMaterial=t,this._highQualityFiltering=!1,this._mipDownRT=[],this._mipUpRT=[],this._maxIterations=6,this._enabled=!1,this.downScale=0;var n=new ao(t.engine,ro.find(e.SHADER_NAME)),r=n.renderState.depthState;r.enabled=!1,r.writeEnabled=!1;var a=n.shaderData,i=t.shaderData;a.setVector4(e._bloomParams,new tI),a.setVector4(e._lowMipTexelSizeProp,new tI),i.setVector4(e._bloomIntensityParams,new tI(1,1,0,0)),i.setVector4(e._dirtTilingOffsetProp,new tI),i.setColor(e._tintProp,new tO(1,1,1,1)),this._bloomMaterial=n,this.threshold=.9,this.scatter=.7,this.intensity=1,this.dirtIntensity=1}var t=e.prototype;return t.onRender=function(e,t){var n=e.camera,r=0===this.downScale?1:2,a=n.pixelViewport,i=a.width>>r,o=a.height>>r,s=this._calculateMipCount(i,o);this._prefilter(n,t,i,o,s),this._downsample(s),this._upsample(s),this._setupUber(n)},t._calculateMipCount=function(e,t){return Math.min(Math.max(Math.floor(Math.log2(Math.max(e,t))-1),1),this._maxIterations)},t._prefilter=function(e,t,n,r,a){for(var i=this._uberMaterial.engine,o=e._getInternalColorTextureFormat(),s=n,l=r,c=0;c<a;c++)this._mipUpRT[c]=rR.recreateRenderTargetIfNeeded(i,this._mipUpRT[c],s,l,o,null,!1,!1,1,t7.Clamp,t5.Bilinear),this._mipDownRT[c]=rR.recreateRenderTargetIfNeeded(i,this._mipDownRT[c],s,l,o,null,!1,!1,1,t7.Clamp,t5.Bilinear),s=Math.max(1,Math.floor(s/2)),l=Math.max(1,Math.floor(l/2));rR.blitTexture(i,t,this._mipDownRT[0],void 0,void 0,this._bloomMaterial,0)},t._downsample=function(e){for(var t=this._bloomMaterial,n=t.engine,r=this._mipDownRT[0],a=1;a<e;a++)rR.blitTexture(n,r.getColorTexture(0),this._mipUpRT[a],void 0,void 0,t,1),rR.blitTexture(n,this._mipUpRT[a].getColorTexture(0),this._mipDownRT[a],void 0,void 0,t,2),r=this._mipDownRT[a]},t._upsample=function(t){for(var n=this._bloomMaterial,r=n.engine,a=n.shaderData,i=t-2;i>=0;i--){var o=i==t-2?this._mipDownRT[i+1]:this._mipUpRT[i+1],s=this._mipDownRT[i],l=this._mipUpRT[i];a.setTexture(e._lowMipTextureProp,o.getColorTexture(0)),this.highQualityFiltering&&a.getVector4(e._lowMipTexelSizeProp).set(1/o.width,1/o.height,o.width,o.height),rR.blitTexture(r,s.getColorTexture(0),l,void 0,void 0,n,3)}},t._setupUber=function(t){var n=this._uberMaterial.shaderData,r=this.dirtTexture;if(r){var a=n.getVector4(e._dirtTilingOffsetProp),i=r.width/r.height,o=t.aspectRatio;i>o?a.set(o/i,1,(1-a.x)*.5,0):i<o?a.set(1,i/o,0,(1-a.y)*.5):a.set(1,1,0,0)}n.setTexture(e._bloomTextureProp,this._mipUpRT[0].getColorTexture(0))},t._releaseRenderTargets=function(){for(var e=this._mipDownRT.length,t=0;t<e;t++){var n=this._mipDownRT[t],r=this._mipUpRT[t];n&&(n.getColorTexture(0).destroy(!0),n.destroy(!0)),r&&(r.getColorTexture(0).destroy(!0),r.destroy(!0))}this._mipDownRT.length=0,this._mipUpRT.length=0},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){t!==this._enabled&&(this._enabled=t,t?this._uberMaterial.shaderData.enableMacro(e._enableMacro):(this._uberMaterial.shaderData.disableMacro(e._enableMacro),this._releaseRenderTargets()))}},{key:"threshold",get:function(){return this._threshold},set:function(t){if((t=Math.max(0,t))!==this._threshold){this._threshold=t;var n=tO.gammaToLinearSpace(t),r=.5*n,a=this._bloomMaterial.shaderData.getVector4(e._bloomParams);a.x=n,a.y=r}}},{key:"scatter",get:function(){return this._scatter},set:function(t){if((t=tS.clamp(t,0,1))!==this._scatter){this._scatter=t;var n=this._bloomMaterial.shaderData.getVector4(e._bloomParams),r=tS.lerp(.05,.95,t);n.z=r}}},{key:"intensity",get:function(){return this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).x},set:function(t){t=Math.max(0,t),this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).x=t}},{key:"tint",get:function(){return this._uberMaterial.shaderData.getColor(e._tintProp)},set:function(t){var n=this._uberMaterial.shaderData.getColor(e._tintProp);t!==n&&n.copyFrom(t)}},{key:"highQualityFiltering",get:function(){return this._highQualityFiltering},set:function(t){t!==this._highQualityFiltering&&(this._highQualityFiltering=t,t?(this._bloomMaterial.shaderData.enableMacro(e._hqMacro),this._uberMaterial.shaderData.enableMacro(e._hqMacro)):(this._bloomMaterial.shaderData.disableMacro(e._hqMacro),this._uberMaterial.shaderData.disableMacro(e._hqMacro)))}},{key:"dirtTexture",get:function(){return this._uberMaterial.shaderData.getTexture(e._dirtTextureProp)},set:function(t){this._uberMaterial.shaderData.setTexture(e._dirtTextureProp,t),t?this._uberMaterial.shaderData.enableMacro(e._dirtMacro):this._uberMaterial.shaderData.disableMacro(e._dirtMacro)}},{key:"dirtIntensity",get:function(){return this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).y},set:function(t){t=Math.max(0,t),this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).y=t}}]),e}();on.SHADER_NAME="PostProcessEffect Bloom",on._hqMacro=nH.getByName("BLOOM_HQ"),on._dirtMacro=nH.getByName("BLOOM_DIRT"),on._bloomParams=nY.getByName("material_BloomParams"),on._lowMipTextureProp=nY.getByName("material_lowMipTexture"),on._lowMipTexelSizeProp=nY.getByName("material_lowMipTexelSize"),on._enableMacro=nH.getByName("ENABLE_EFFECT_BLOOM"),on._bloomTextureProp=nY.getByName("material_BloomTexture"),on._dirtTextureProp=nY.getByName("material_BloomDirtTexture"),on._tintProp=nY.getByName("material_BloomTint"),on._bloomIntensityParams=nY.getByName("material_BloomIntensityParams"),on._dirtTilingOffsetProp=nY.getByName("material_BloomDirtTilingOffset"),ro.create(on.SHADER_NAME,[new n6("Bloom Prefilter",ij,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 material_BloomParams;uniform vec4 renderer_texelSize;void main(){\n#ifdef BLOOM_HQ\nvec2 texelSize=renderer_texelSize.xy;mediump vec4 A=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,-1.0));mediump vec4 B=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,-1.0));mediump vec4 C=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,-1.0));mediump vec4 D=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,-0.5));mediump vec4 E=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,-0.5));mediump vec4 F=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,0.0));mediump vec4 G=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 H=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,0.0));mediump vec4 I=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,0.5));mediump vec4 J=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,0.5));mediump vec4 K=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,1.0));mediump vec4 L=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,1.0));mediump vec4 M=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,1.0));mediump vec2 scale=vec2(0.5,0.125);mediump vec2 div=(1.0/4.0)*scale;mediump vec4 samplerColor=(D+E+I+J)*div.x;samplerColor+=(A+B+G+F)*div.y;samplerColor+=(B+C+H+G)*div.y;samplerColor+=(F+G+L+K)*div.y;samplerColor+=(G+H+M+L)*div.y;\n#else\nmediump vec4 samplerColor=sampleTexture(renderer_BlitTexture,v_uv);\n#endif\nmediump vec3 color=samplerColor.rgb;color=min(color,HALF_MAX);mediump float brightness=max3(color);float threshold=material_BloomParams.x;float thresholdKnee=material_BloomParams.y;mediump float softness=clamp(brightness-threshold+thresholdKnee,0.0,2.0*thresholdKnee);softness=(softness*softness)/(4.0*thresholdKnee+1e-4);mediump float multiplier=max(brightness-threshold,softness)/max(brightness,1e-4);color*=multiplier;color=max(color,0.0);gl_FragColor=vec4(color,samplerColor.a);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new n6("Bloom Blur Horizontal",ij,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy*2.0;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*4.0,0.0));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*3.0,0.0));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*2.0,0.0));mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*1.0,0.0));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c5=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*1.0,0.0));mediump vec4 c6=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*2.0,0.0));mediump vec4 c7=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*3.0,0.0));mediump vec4 c8=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*4.0,0.0));gl_FragColor=c0*0.01621622+c1*0.05405405+c2*0.12162162+c3*0.19459459+c4*0.22702703+c5*0.19459459+c6*0.12162162+c7*0.05405405+c8*0.01621622;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new n6("Bloom Blur Vertical",ij,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*3.23076923));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*1.38461538));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*1.38461538));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*3.23076923));gl_FragColor=c0*0.07027027+c1*0.31621622+c2*0.22702703+c3*0.31621622+c4*0.07027027;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new n6("Bloom Upsample",ij,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform sampler2D material_lowMipTexture;uniform vec4 material_BloomParams;uniform vec4 material_lowMipTexelSize;void main(){mediump vec4 highMip=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef BLOOM_HQ\nmediump vec4 lowMip=sampleTexture2DBicubic(material_lowMipTexture,v_uv,material_lowMipTexelSize);\n#else\nmediump vec4 lowMip=sampleTexture(material_lowMipTexture,v_uv);\n#endif\ngl_FragColor=mix(highMip,lowMip,material_BloomParams.z);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}")]);var or=((eB={})[eB.Neutral=0]="Neutral",eB[eB.ACES=1]="ACES",eB),oa=/*#__PURE__*/function(){function e(e){this._uberMaterial=e,this._enabled=!1,this.mode=0}return tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){t!==this._enabled&&(this._enabled=t,t?this._uberMaterial.shaderData.enableMacro(e._enableMacro):this._uberMaterial.shaderData.disableMacro(e._enableMacro))}},{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE",e.toString()))}}]),e}();oa._enableMacro=nH.getByName("ENABLE_EFFECT_TONEMAPPING");var oi=/*#__PURE__*/function(){function e(t){this.scene=t,this.isActive=!0;var n=ro.find(e.UBER_SHADER_NAME),r=new ao(t.engine,n),a=r.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=new on(r),o=new oa(r);this._uberMaterial=r,this._bloomEffect=i,this._tonemappingEffect=o}return e.prototype._render=function(e,t,n){var r=e.camera,a=r.engine;t._blitRenderTarget();var i=t.getColorTexture(),o=this._bloomEffect;o.enabled&&o.onRender(e,i),rR.blitTexture(a,i,n,0,r.viewport,this._uberMaterial)},tG(e,[{key:"hasActiveEffect",get:function(){return this.isActive&&(this._bloomEffect.enabled||this._tonemappingEffect.enabled)}}]),e}();oi.UBER_SHADER_NAME="UberPost",Object.assign(nZ,{PostCommon:"#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n#include <common>\n#define FLT_MIN 1.175494351e-38\n#define HALF_MIN 6.103515625e-5\n#define HALF_MAX 65504.0\nfloat min3(vec3 val){return min(min(val.x,val.y),val.z);}float max3(vec3 val){return max(max(val.x,val.y),val.z);}const float INVERT_LOG10=0.43429448190325176;float log10(float x){return log(x)*INVERT_LOG10;}vec4 sampleTexture(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ncolor=gammaToLinear(color);\n#endif\nreturn color;}\n#endif\n",Filtering:"#define GLSLIFY 1\n#ifndef FILTERING\n#define FILTERING\nvec2 bSpline3MiddleLeft(vec2 x){return 0.16666667+x*(0.5+x*(0.5-x*0.5));}vec2 bSpline3MiddleRight(vec2 x){return 0.66666667+x*(-1.0+0.5*x)*x;}vec2 bSpline3Rightmost(vec2 x){return 0.16666667+x*(-0.5+x*(0.5-x*0.16666667));}void bicubicFilter(vec2 fracCoord,out vec2 weights[2],out vec2 offsets[2]){vec2 r=bSpline3Rightmost(fracCoord);vec2 mr=bSpline3MiddleRight(fracCoord);vec2 ml=bSpline3MiddleLeft(fracCoord);vec2 l=1.0-mr-ml-r;weights[0]=r+mr;weights[1]=ml+l;offsets[0]=-1.0+mr/weights[0];offsets[1]=1.0+l/weights[1];}vec4 sampleTexture2DBicubic(sampler2D tex,vec2 coord,vec4 texSize){vec2 xy=coord*texSize.zw+0.5;vec2 ic=floor(xy);vec2 fc=fract(xy);vec2 weights[2],offsets[2];bicubicFilter(fc,weights,offsets);return weights[0].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[0].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[0].y)-0.5)*texSize.xy))+weights[1].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[1].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[1].y)-0.5)*texSize.xy));}\n#endif\n",ODT:"#define GLSLIFY 1\n#include <Tonescale>\nconst float CINEMA_WHITE=48.0;const float CINEMA_BLACK=0.02;const float ODT_SAT_FACTOR=0.93;mediump vec3 Y_2_linCV(mediump vec3 Y,mediump float Ymax,mediump float Ymin){return(Y-Ymin)/(Ymax-Ymin);}mediump vec3 XYZ_2_xyY(mediump vec3 XYZ){mediump float divisor=max(dot(XYZ,vec3(1.0)),1e-4);return vec3(XYZ.xy/divisor,XYZ.y);}mediump vec3 xyY_2_XYZ(mediump vec3 xyY){mediump float m=xyY.z/max(xyY.y,1e-4);mediump vec3 XYZ=vec3(xyY.xz,(1.0-xyY.x-xyY.y));XYZ.xz*=m;return XYZ;}const mediump float DIM_SURROUND_GAMMA=0.9811;mediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;mediump vec3 xyY=XYZ_2_xyY(XYZ);xyY.z=clamp(xyY.z,0.0,HALF_MAX);xyY.z=pow(xyY.z,DIM_SURROUND_GAMMA);XYZ=xyY_2_XYZ(xyY);return XYZ_2_AP1_MAT*XYZ;}mediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){mediump vec3 rgbPre=AP0_2_AP1_MAT*oces;mediump vec3 rgbPost;rgbPost.r=segmented_spline_c9_fwd(rgbPre.r);rgbPost.g=segmented_spline_c9_fwd(rgbPre.g);rgbPost.b=segmented_spline_c9_fwd(rgbPre.b);mediump vec3 linearCV=Y_2_linCV(rgbPost,CINEMA_WHITE,CINEMA_BLACK);linearCV=darkSurround_to_dimSurround(linearCV);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;linearCV=clamp(linearCV,vec3(0),vec3(1));return linearCV;}",RRT:"#define GLSLIFY 1\n#include <Tonescale>\nmediump float sigmoid_shaper(mediump float x){mediump float t=max(1.0-abs(x/2.0),0.0);mediump float y=1.0+sign(x)*(1.0-t*t);return y*0.5;}mediump float glow_fwd(mediump float ycIn,mediump float glowGainIn,mediump float glowMid){mediump float glowGainOut;if(ycIn<=2.0/3.0*glowMid){glowGainOut=glowGainIn;}else if(ycIn>=2.0*glowMid){glowGainOut=0.0;}else{glowGainOut=glowGainIn*(glowMid/ycIn-1.0/2.0);}return glowGainOut;}const mediump float RRT_GLOW_GAIN=0.05;const mediump float RRT_GLOW_MID=0.08;const mediump float RRT_RED_SCALE=0.82;const mediump float RRT_RED_PIVOT=0.03;const mediump float RRT_RED_HUE=0.0;const mediump float RRT_RED_WIDTH=135.0;const mediump float RRT_SAT_FACTOR=0.96;mediump vec3 RRT(mediump vec3 aces){mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);mediump float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(aces);mediump float centeredHue=center_hue(hue,RRT_RED_HUE);mediump float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);aces=clamp(aces,0.0,HALF_MAX);mediump vec3 rgbPre=AP0_2_AP1_MAT*aces;rgbPre=clamp(rgbPre,0.0,HALF_MAX);rgbPre=mix(vec3(dot(rgbPre,AP1_RGB2Y)),rgbPre,RRT_SAT_FACTOR);mediump vec3 rgbPost;rgbPost.x=segmented_spline_c5_fwd(rgbPre.x);rgbPost.y=segmented_spline_c5_fwd(rgbPre.y);rgbPost.z=segmented_spline_c5_fwd(rgbPre.z);mediump vec3 outputVal=AP1_2_AP0_MAT*rgbPost;return outputVal;}",Tonescale:"#define GLSLIFY 1\n#ifndef TONE_SCALE\n#define TONE_SCALE\nconst mediump mat3 M=mat3(vec3(0.5,-1.0,0.5),vec3(-1.0,1.0,0.5),vec3(0.5,0.0,0.0));mediump float segmented_spline_c5_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[6]=float[6](-4.0000000000,-4.0000000000,-3.1573765773,-0.4852499958,1.8477324706,1.8477324706);const mediump float coefsHigh[6]=float[6](-0.7185482425,2.0810307172,3.6681241237,4.0000000000,4.0000000000,4.0000000000);\n#else\nconst mediump float coefsLow_0=-4.0000000000;const mediump float coefsLow_1=-4.0000000000;const mediump float coefsLow_2=-3.1573765773;const mediump float coefsLow_3=-0.4852499958;const mediump float coefsLow_4=1.8477324706;const mediump float coefsLow_5=1.8477324706;const mediump float coefsHigh_0=-0.7185482425;const mediump float coefsHigh_1=2.0810307172;const mediump float coefsHigh_2=3.6681241237;const mediump float coefsHigh_3=4.0000000000;const mediump float coefsHigh_4=4.0000000000;const mediump float coefsHigh_5=4.0000000000;\n#endif\nconst mediump vec2 minPoint=vec2(0.0000054931640625,0.0001);const mediump vec2 midPoint=vec2(0.18,0.48);const mediump vec2 maxPoint=vec2(47185.92,10000.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.0;const int N_KNOTS_LOW=4;const int N_KNOTS_HIGH=4;mediump float logx=log10(max(x,HALF_MIN));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else{cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else{cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}mediump float segmented_spline_c9_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[10]=float[10](-1.6989700043,-1.6989700043,-1.4779000000,-1.2291000000,-0.8648000000,-0.4480000000,0.0051800000,0.4511080334,0.9113744414,0.9113744414);const mediump float coefsHigh[10]=float[10](0.5154386965,0.8470437783,1.1358000000,1.3802000000,1.5197000000,1.5985000000,1.6467000000,1.6746091357,1.6878733390,1.6878733390);\n#else\nconst mediump float coefsLow_0=-1.6989700043;const mediump float coefsLow_1=-1.6989700043;const mediump float coefsLow_2=-1.4779000000;const mediump float coefsLow_3=-1.2291000000;const mediump float coefsLow_4=-0.8648000000;const mediump float coefsLow_5=-0.4480000000;const mediump float coefsLow_6=0.0051800000;const mediump float coefsLow_7=0.4511080334;const mediump float coefsLow_8=0.9113744414;const mediump float coefsLow_9=0.9113744414;const mediump float coefsHigh_0=0.5154386965;const mediump float coefsHigh_1=0.8470437783;const mediump float coefsHigh_2=1.1358000000;const mediump float coefsHigh_3=1.3802000000;const mediump float coefsHigh_4=1.5197000000;const mediump float coefsHigh_5=1.5985000000;const mediump float coefsHigh_6=1.6467000000;const mediump float coefsHigh_7=1.6746091357;const mediump float coefsHigh_8=1.6878733390;const mediump float coefsHigh_9=1.6878733390;\n#endif\nconst mediump vec2 minPoint=vec2(0.0028799,0.02);const mediump vec2 midPoint=vec2(4.799999,4.8);const mediump vec2 maxPoint=vec2(1005.719,48.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.04;const int N_KNOTS_LOW=8;const int N_KNOTS_HIGH=8;mediump float logx=log10(max(x,1e-4));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else if(j==3){cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}else if(j==4){cf=vec3(coefsLow_4,coefsLow_5,coefsLow_6);}else if(j==5){cf=vec3(coefsLow_5,coefsLow_6,coefsLow_7);}else if(j==6){cf=vec3(coefsLow_6,coefsLow_7,coefsLow_8);}else{cf=vec3(coefsLow_7,coefsLow_8,coefsLow_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else if(j==3){cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}else if(j==4){cf=vec3(coefsHigh_4,coefsHigh_5,coefsHigh_6);}else if(j==5){cf=vec3(coefsHigh_5,coefsHigh_6,coefsHigh_7);}else if(j==6){cf=vec3(coefsHigh_6,coefsHigh_7,coefsHigh_8);}else{cf=vec3(coefsHigh_7,coefsHigh_8,coefsHigh_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}\n#endif\n",ColorTransform:"#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\nconst mediump mat3 sRGB_2_AP0=mat3(0.4397010,0.0897923,0.0175440,0.3829780,0.8134230,0.1115440,0.1773350,0.0967616,0.8707040);const mediump mat3 AP1_2_AP0_MAT=mat3(vec3(0.6954522414,0.0447945634,-0.0055258826),vec3(0.1406786965,0.8596711185,0.0040252103),vec3(0.1638690622,0.0955343182,1.0015006723));const mediump mat3 AP0_2_AP1_MAT=mat3(vec3(1.4514393161,-0.0765537734,0.0083161484),vec3(-0.2365107469,1.1762296998,-0.0060324498),vec3(-0.2149285693,-0.0996759264,0.9977163014));const mediump mat3 AP1_2_XYZ_MAT=mat3(vec3(0.6624541811,0.2722287168,-0.0055746495),vec3(0.1340042065,0.6740817658,0.0040607335),vec3(0.1561876870,0.0536895174,1.0103391003));const mediump mat3 XYZ_2_AP1_MAT=mat3(vec3(1.6410233797,-0.6636628587,0.0117218943),vec3(-0.3248032942,1.6153315917,-0.0082844420),vec3(-0.2364246952,0.0167563477,0.9883948585));const mediump mat3 D60_2_D65_CAT=mat3(vec3(0.987224,-0.00759836,0.00307257),vec3(-0.00611327,1.00186,-0.00509595),vec3(0.0159533,0.00533002,1.08168));const mediump mat3 XYZ_2_REC709_MAT=mat3(vec3(3.2409699419,-0.9692436363,0.0556300797),vec3(-1.5373831776,1.8759675015,-0.2039769589),vec3(-0.498610760,0.0415550574,1.0569715142));const mediump vec3 AP1_RGB2Y=vec3(0.2722287168,0.6740817658,0.0536895174);mediump float rgb_2_saturation(mediump vec3 rgb){const mediump float TINY=1e-4;mediump float mi=min3(rgb);mediump float ma=max3(rgb);return(max(ma,TINY)-max(mi,TINY))/max(ma,1e-2);}mediump float rgb_2_yc(mediump vec3 rgb){const mediump float ycRadiusWeight=1.75;mediump float r=rgb.x;mediump float g=rgb.y;mediump float b=rgb.z;mediump float k=b*(b-g)+g*(g-r)+r*(r-b);k=max(k,0.0);float chroma=k==0.0 ? 0.0 : sqrt(k);return(b+g+r+ycRadiusWeight*chroma)/3.0;}mediump float rgb_2_hue(mediump vec3 rgb){mediump float hue;if(rgb.x==rgb.y&&rgb.y==rgb.z){hue=0.0;}else{hue=(180.0/PI)*atan(sqrt(3.0)*(rgb.y-rgb.z),2.0*rgb.x-rgb.y-rgb.z);}if(hue<0.0){hue=hue+360.0;}return hue;}mediump float center_hue(mediump float hue,mediump float centerH){mediump float hueCentered=hue-centerH;if(hueCentered<-180.0){hueCentered=hueCentered+360.0;}else if(hueCentered>180.0){hueCentered=hueCentered-360.0;}return hueCentered;}\n#endif\n",NeutralTonemapping:"#define GLSLIFY 1\nvec3 neutralCurve(vec3 x,float a,float b,float c,float d,float e,float f){return vec3(((x*(a*x+c*b)+d*e)/(x*(a*x+b)+d*f))-e/f);}\n#define TONEMAPPING_CLAMP_MAX 435.18712\nvec3 neutralTonemap(vec3 color){const float a=0.2;const float b=0.29;const float c=0.24;const float d=0.272;const float e=0.02;const float f=0.3;\n#ifndef GL_FRAGMENT_PRECISION_HIGH\ncolor=min(color,TONEMAPPING_CLAMP_MAX);\n#endif\nconst float whiteScale=1.31338;color=neutralCurve(color*whiteScale,a,b,c,d,e,f);color*=whiteScale;return color;}",ACESTonemapping:"#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\nvec3 ACESTonemap(vec3 color){vec3 aces=sRGB_2_AP0*color;mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(vec3(aces));mediump float centeredHue=center_hue(hue,RRT_RED_HUE);float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);vec3 acescg=max(AP0_2_AP1_MAT*aces,0.0);acescg=mix(vec3(dot(acescg,AP1_RGB2Y)),acescg,RRT_SAT_FACTOR);const float a=0.0245786;const float b=0.000090537;const float c=0.983729;const float d=0.4329510;const float e=0.238081;vec3 rcpAcesCG=1.0/(acescg+FLT_MIN);mediump vec3 rgbPost=(acescg+a-b*rcpAcesCG)/(acescg*c+d+e*rcpAcesCG);vec3 linearCV=darkSurround_to_dimSurround(rgbPost);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;return linearCV;}"}),ro.create(oi.UBER_SHADER_NAME,ij,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;\n#ifdef ENABLE_EFFECT_BLOOM\nuniform sampler2D material_BloomTexture;uniform sampler2D material_BloomDirtTexture;uniform vec4 material_BloomTint;uniform vec4 material_BloomDirtTilingOffset;uniform vec4 material_BloomIntensityParams;\n#endif\nvoid main(){mediump vec4 color=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef ENABLE_EFFECT_BLOOM\n#ifdef BLOOM_HQ\nmediump vec4 bloom=sampleTexture2DBicubic(material_BloomTexture,v_uv,renderer_texelSize);\n#else\nmediump vec4 bloom=sampleTexture(material_BloomTexture,v_uv);\n#endif\nbloom*=material_BloomIntensityParams.x;color+=bloom*material_BloomTint;\n#ifdef BLOOM_DIRT\nmediump vec4 dirt=sampleTexture(material_BloomDirtTexture,v_uv*material_BloomDirtTilingOffset.xy+material_BloomDirtTilingOffset.zw);dirt*=material_BloomIntensityParams.y;color+=dirt*bloom;\n#endif\n#endif\n#ifdef ENABLE_EFFECT_TONEMAPPING\n#if TONEMAPPING_MODE == 0\ncolor.rgb=neutralTonemap(color.rgb);\n#elif TONEMAPPING_MODE == 1\ncolor.rgb=ACESTonemap(color.rgb);\n#endif\ncolor.rgb=clamp(color.rgb,vec3(0),vec3(1));\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}");var oo=/*#__PURE__*/function(e){function t(n,r){(a=e.call(this,n)||this).physics=new ip(a),a.castShadows=!0,a.shadowResolution=rW.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new tT(1/15,.2,7/15),a.shadowDistance=50,a.shadowFadeBorder=.1,a._lightManager=new oe,a._componentsManager=new i1,a._maskManager=new i2,a._isActiveInEngine=!1,a._globalShaderMacro=new nW,a._rootEntities=[],a._postProcessManager=new oi(a),a._background=new i0(a._engine),a._shaderData=new rs(n8.Scene),a._shadowCascades=rK.NoCascades,a._fogMode=i3.None,a._fogColor=new tO(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new tI,a._isActive=!0,a._enableTransparentShadow=!1,a.name=r||"";var a,i=a.shaderData;return i._addReferCount(1),a.ambientLight=new i8(n),n.sceneManager._allCreatedScenes.push(a),i.enableMacro("SCENE_FOG_MODE",a._fogMode.toString()),i.enableMacro("SCENE_SHADOW_CASCADED_COUNT",a.shadowCascades.toString()),i.setColor(t._fogColorProperty,a._fogColor),i.setVector4(t._fogParamsProperty,a._fogParams),a._computeLinearFogParams(a._fogStart,a._fogEnd),a._computeExponentialFogParams(a._fogDensity),a}tW(t,e);var n=t.prototype;return n.createRootEntity=function(e){var t=new aW(this._engine,e);return this.addRootEntity(t),t},n.addRootEntity=function(e,t){"number"==typeof e?n=e:(n=void 0,t=e);var n,r=t._isRoot;r||(t._isRoot=!0,t._removeFromParent(),t._setTransformDirty());var a=t._scene;a!==this?(a&&r&&a._removeFromEntityList(t),this._addToRootEntityList(n,t)):r||this._addToRootEntityList(n,t);var i=rc.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=rc.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=rc.Scene),i&&t._processInActive(i),a!==this&&aW._traverseSetOwnerScene(t,this);var o=rc.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=rc.Hierarchy)),t._isActiveInScene&&a===this||(o|=rc.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=rc.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=rc.Hierarchy),e._isActiveInScene&&(t|=rc.Scene),t&&e._processInActive(t),aW._traverseSetOwnerScene(e,null)}},n.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},n.findEntityByName=function(e){for(var t=this._rootEntities,n=0,r=t.length;n<r;n++){var a=t[n].findByName(e);if(a)return a}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),n=0,r=this.rootEntitiesCount;n<r;n++){var a=this.getRootEntity(n);if(a.name==t[0]){for(var i=1,o=t.length;i<o&&(a=aW._findChildByName(a,t[i]));++i);return a}}return null},n._processActive=function(e){this._isActiveInEngine=e;for(var t=this._rootEntities,n=t.length-1;n>=0;n--){var r=t[n];r._isActive&&(e?r._processActive(rc.Hierarchy):r._processInActive(rc.Hierarchy))}},n._updateShaderData=function(){var e=this.shaderData,t=this._engine,n=this._lightManager;t.time._updateSceneShaderData(e),n._updateShaderData(this.shaderData);var r=this._lightManager._sunlight=this._getSunlight();r?(n._updateSunlightIndex(r),e.setColor(oe._sunlightColorProperty,r._lightColor),e.setVector3(oe._sunlightDirectionProperty,r.direction)):e.setVector3(oe._sunlightDirectionProperty,tT._zero),this.castShadows&&r&&r.shadowType!==rj.None?e.enableMacro("SCENE_SHADOW_TYPE",r.shadowType.toString()):e.disableMacro("SCENE_SHADOW_TYPE"),nW.unionCollection(this.engine._macroCollection,e._macroCollection,this._globalShaderMacro)},n._removeFromEntityList=function(e){var t=this._rootEntities,n=e._siblingIndex;t.splice(n,1);for(var r=t.length;n<r;n++)t[n]._siblingIndex--;e._siblingIndex=-1},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._engine.sceneManager;for(t.removeScene(this);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts(),this._maskManager.destroy();var n=t._allCreatedScenes;n.splice(n.indexOf(this),1)},n._addToRootEntityList=function(e,t){var n=this._rootEntities,r=n.length;if(void 0===e)t._siblingIndex=r,n.push(t);else{if(e<0||e>r)throw"The index "+e+" is out of child list bounds "+r;t._siblingIndex=e,n.splice(e,0,t);for(var a=e+1,i=r+1;a<i;a++)n[a]._siblingIndex++}},n._computeLinearFogParams=function(e,t){var n=t-e,r=this._fogParams;r.x=-1/n,r.y=t/n},n._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},n._getSunlight=function(){return this._sun?this._sun.enabled?this._sun:null:this._lightManager._getMaxBrightestSunlight()},tG(t,[{key:"isActive",get:function(){return this._isActive},set:function(e){this._isActive!==e&&(this._isActive=e,e?this._sceneManager&&this._processActive(!0):this._sceneManager&&this._processActive(!1))}},{key:"shaderData",get:function(){return this._shaderData}},{key:"background",get:function(){return this._background}},{key:"shadowCascades",get:function(){return this._shadowCascades},set:function(e){this._shadowCascades!==e&&(this.shaderData.enableMacro("SCENE_SHADOW_CASCADED_COUNT",e.toString()),this._shadowCascades=e)}},{key:"ambientLight",get:function(){return this._ambientLight},set:function(e){if(!e){no.warn("The scene must have one ambient light");return}var t=this._ambientLight;t!==e&&(t&&t._removeFromScene(this),e._addToScene(this),this._ambientLight=e)}},{key:"fogMode",get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this.shaderData.enableMacro("SCENE_FOG_MODE",e.toString()),this._fogMode=e)}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor!==e&&this._fogColor.copyFrom(e)}},{key:"fogStart",get:function(){return this._fogStart},set:function(e){this._fogStart!==e&&(this._computeLinearFogParams(e,this._fogEnd),this._fogStart=e)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(e){this._fogEnd!==e&&(this._computeLinearFogParams(this._fogStart,e),this._fogEnd=e)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(e){this._fogDensity!==e&&(this._computeExponentialFogParams(e),this._fogDensity=e)}},{key:"rootEntitiesCount",get:function(){return this._rootEntities.length}},{key:"rootEntities",get:function(){return this._rootEntities}},{key:"sun",get:function(){return this._sun},set:function(e){this._sun=e}},{key:"enableTransparentShadow",get:function(){return this._enableTransparentShadow},set:function(e){e!==this._enableTransparentShadow&&(this._enableTransparentShadow=e,e?this.shaderData.enableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"):this.shaderData.disableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"))}}]),t}(t0);oo._fogColorProperty=nY.getByName("scene_FogColor"),oo._fogParamsProperty=nY.getByName("scene_FogParams");var os=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._started=!1,t._onStartIndex=-1,t._onUpdateIndex=-1,t._onLateUpdateIndex=-1,t._onPhysicsUpdateIndex=-1,t._onPreRenderIndex=-1,t._onPostRenderIndex=-1,t._entityScriptsIndex=-1,t}tW(t,e);var n=t.prototype;return n.onAwake=function(){},n.onEnable=function(){},n.onStart=function(){},n.onUpdate=function(e){},n.onLateUpdate=function(e){},n.onBeginRender=function(e){},n.onEndRender=function(e){},n.onPhysicsUpdate=function(){},n.onTriggerEnter=function(e){},n.onTriggerExit=function(e){},n.onTriggerStay=function(e){},n.onCollisionEnter=function(e){},n.onCollisionExit=function(e){},n.onCollisionStay=function(e){},n.onPointerDown=function(e){},n.onPointerUp=function(e){},n.onPointerClick=function(e){},n.onPointerEnter=function(e){},n.onPointerExit=function(e){},n.onPointerDrag=function(e){},n.onDisable=function(){},n.onDestroy=function(){},n._onAwake=function(){this.onAwake()},n._onEnable=function(){this.onEnable()},n._onDisable=function(){this.onDisable()},n._onEnableInScene=function(){var e=this.scene._componentsManager,n=t.prototype;this._started||e.addOnStartScript(this),this.onUpdate!==n.onUpdate&&e.addOnUpdateScript(this),this.onLateUpdate!==n.onLateUpdate&&e.addOnLateUpdateScript(this),this.onPhysicsUpdate!==n.onPhysicsUpdate&&e.addOnPhysicsUpdateScript(this),this._entity._addScript(this)},n._onDisableInScene=function(){var e=this.scene._componentsManager,n=t.prototype;this._started||e.removeOnStartScript(this),this.onUpdate!==n.onUpdate&&e.removeOnUpdateScript(this),this.onLateUpdate!==n.onLateUpdate&&e.removeOnLateUpdateScript(this),this.onPhysicsUpdate!==n.onPhysicsUpdate&&e.removeOnPhysicsUpdateScript(this),this._entity._removeScript(this)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},t}(ru);tX([tq],os.prototype,"_started",void 0),tX([tq],os.prototype,"_onStartIndex",void 0),tX([tq],os.prototype,"_onUpdateIndex",void 0),tX([tq],os.prototype,"_onLateUpdateIndex",void 0),tX([tq],os.prototype,"_onPhysicsUpdateIndex",void 0),tX([tq],os.prototype,"_onPreRenderIndex",void 0),tX([tq],os.prototype,"_onPostRenderIndex",void 0),tX([tq],os.prototype,"_entityScriptsIndex",void 0);var ol=/*#__PURE__*/function(){function e(e){this.useCache=e}return e.registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},e.getClass=function(e){return this._engineObjects[e]},e.getClassName=function(e){return this._classNameMap.get(e)},e}();ol._engineObjects={},ol._classNameMap=new Map;var oc=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){var t=e.component,n=e.property.split(".");if(e.getProperty){var r=e.getProperty.split(".");this._initializeMounted(t,r,1),this._initializeMounted(t,n,2)}else this._initializeMounted(t,n,3)},t.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},t.setTargetValue=function(e){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=e;break;case 1:var t=this._setArgs;t[this._replaceValueIndex]=e,this._setMounted[this._setValueName].apply(this._setMounted,t);break;case 0:this._setMounted[this._setValueName]=e}},t._initializeMounted=function(e,t,n){for(var r,a,i,o,s=t.length-1,l=0;l<s;l++){var c=t[l];if(c.indexOf("[")>-1){var u=c.indexOf("[");e=(e=e[c.slice(0,u)])[parseInt(c.slice(u+1,-1))]}else if(c.endsWith(")")){var d=c.slice(0,c.indexOf("(")),h=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e});e=e[d].apply(e,h)}else e=e[c]}var _=t[s];if(_.indexOf("[")>-1){var f=_.indexOf("[");r=2,e=e[_.slice(0,f)],a=parseInt(_.slice(f+1,-1))}else if(_.endsWith(")")){if(i=_.slice(0,_.indexOf("(")),o=_.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e}),r=1,2&n){var p=o.indexOf("$value");this._replaceValueIndex=p>-1?p:o.length}}else r=0;2&n&&(this._setMounted=e,this._setType=r,this._setArrayIndex=a,this._setValueName=_,i&&(this._setValueName=i),this._setArgs=o),1&n&&(this._getMounted=e,this._getType=r,this._getArrayIndex=a,this._getValueName=_,i&&(this._getValueName=i),this._getArgs=o)},e}(),ou=/*#__PURE__*/function(){function e(t,n,r,a,i,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=a,this.getProperty=i,this.component=r,this.cureType=o;var s=e.getAssemblerType(n,a);this._assembler=new s,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateValue=function(e,t,n){return n?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,n,r,a,i){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,r,!1);var o=e&&e.keys.length?i?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):i?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?i?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):i?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,a)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var a=r?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,i=e&&e.keys.length?r?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):r?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(a,i,n)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.getEvaluateValue=function(e){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,e),e):this.baseEvaluateData.value},t.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},t.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t.applyValue=function(e,t,n){var r=this.cureType;if(n){var a=this._assembler;if(r._isCopyMode)r._additiveValue(e,t,this.referenceTargetValue);else{var i=a.getTargetValue(),o=r._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)r._isCopyMode?r._setValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(r._isCopyMode){var s=this.referenceTargetValue;r._lerpValue(s,e,t,s)}else{var l=this._assembler.getTargetValue(),c=r._lerpValue(l,e,t);this._assembler.setTargetValue(c)}},t._lerpValue=function(e,t,n){return this.cureType._isCopyMode?this.cureType._lerpValue(e,t,n,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(e,t,n),this.baseEvaluateData.value)},e.registerAssembler=function(t,n,r){var a=e._assemblerMap.get(t);a||(a={},e._assemblerMap.set(t,a)),a[n]=r},e.getAssemblerType=function(t,n){var r=e._assemblerMap.get(t),a=r?r[n]:void 0;return null!=a?a:oc},e}();ou._components=[],ou._assemblerMap=new Map;var od=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.position},t.setTargetValue=function(e){this._transform.position=e},e}();ou.registerAssembler(rp,"position",od);var oh=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.rotationQuaternion},t.setTargetValue=function(e){this._transform.rotationQuaternion=e},e}();ou.registerAssembler(rp,"rotationQuaternion",oh);var o_=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.scale},t.setTargetValue=function(e){this._transform.scale=e},e}();ou.registerAssembler(rp,"scale",o_);var of=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._skinnedMeshRenderer=e.component},t.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},t.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},e}();ou.registerAssembler(aK,"blendShapeWeights",of);var op=/*#__PURE__*/function(){function e(){this.crossCurveMark=0,this.isActive=!0}var t=e.prototype;return t.initFinalValue=function(){var e=this.curveOwner,t=e.cureType,n=e.defaultValue;t._isCopyMode?t._setValue(n,this.finalValue):this.finalValue=n},t.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},e}(),om=/*#__PURE__*/function(){function e(){this.typeIndex=0,this._tempCurveOwner={}}var t=e.prototype;return t._createCurveOwner=function(e,t){var n=this.curve.constructor,r=new ou(e,this.type,t,this.property,this.getProperty,n);return n._initializeOwner(r),r.saveDefaultValue(),r},t._createCurveLayerOwner=function(e){var t=this.curve.constructor,n=new op;return n.curveOwner=e,t._initializeLayerOwner(n),n.initFinalValue(),n},t._getTempCurveOwner=function(e,t){var n=e.instanceId;return this._tempCurveOwner[n]||(this._tempCurveOwner[n]=this._createCurveOwner(e,t)),this._tempCurveOwner[n]},e}(),og=function(){},ov=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n._curveBindings=[],n._updateFlagManager=new nM,n._length=0,n._events=[],n}tW(t,e);var n=t.prototype;return n.addEvent=function(e,t,n){if("string"==typeof e){var r,a=new og;a.functionName=e,a.time=t,a.parameter=n,r=a}else r=e;var i=this._events,o=i.length,s=r.time;if(s>=(o?i[o-1].time:0))i.push(r);else{for(var l=o;--l>=0&&s<i[l].time;);i.splice(l+1,0,r)}this._updateFlagManager.dispatch()},n.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},n.addCurveBinding=function(e,t,n,r,a,i){var o=new om;o.relativePath=e,o.type=t,"number"==typeof n?(o.typeIndex=n,o.property=r,"string"==typeof a?(o.getProperty=a,o.curve=i):o.curve=a):(o.property=n,"string"==typeof r?(o.getProperty=r,o.curve=a):o.curve=r),this._length=Math.max(this._length,o.curve.length),this._curveBindings.push(o)},n.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},n._sampleAnimation=function(e,t){for(var n=this._curveBindings,r=n.length-1;r>=0;r--){var a=n[r],i=e.findByPath(a.relativePath);if(i){var o=a.typeIndex>0?i.getComponents(a.type,ou._components)[a.typeIndex]:i.getComponent(a.type);if(!o)continue;var s=a._getTempCurveOwner(i,o);if(s&&a.curve.keys.length){var l=s.evaluateValue(a.curve,t,!1);s.applyValue(l,1,!1)}}}},tG(t,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),t}(t0),oy=((eI={})[eI.Linear=0]="Linear",eI[eI.CubicSpine=1]="CubicSpine",eI[eI.Step=2]="Step",eI[eI.Hermite=3]="Hermite",eI),ox=/*#__PURE__*/function(){function e(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var e=this.constructor;this._interpolation=e._supportInterpolationMode?oy.Linear:oy.Step,this._type=e}var t=e.prototype;return t.addKey=function(e){var t=e.time,n=this.keys;if(t>=this._length)n.push(e),this._length=t;else{for(var r=n.length;--r>=0&&t<n[r].time;);n.splice(r+1,0,e)}},t.evaluate=function(e){return this._evaluate(e,this._evaluateData)},t.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,n=0,r=t.length-1;r>=0;r--){var a=t[r];a.time>this._length&&(n=a.time)}this._length=n},t._evaluate=function(e,t){var n,r=this.keys.length;if(!r){console.warn("This curve don't have any keyframes: ",this);return}var a=this.keys,i=this.interpolation,o=t.curKeyframeIndex;-1!==o&&(o>=r||e<a[o].time)&&(o=-1);for(var s=o+1;s<r&&!(e<a[s].time);)o++,s++;if(t.curKeyframeIndex=o,-1===o)n=this._type._setValue(a[0].value,t.value);else if(s===r)n=this._type._setValue(a[o].value,t.value);else{var l=a[o],c=a[s],u=l.time,d=c.time-u,h=(e-u)/d;switch(i){case oy.Linear:n=this._type._lerpValue(l.value,c.value,h,t.value);break;case oy.Step:n=this._type._setValue(l.value,t.value);break;case oy.CubicSpine:case oy.Hermite:n=this._type._hermiteInterpolationValue(l,c,h,d,t.value)}}return t.value=n,n},t._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},tG(e,[{key:"interpolation",get:function(){return this._interpolation},set:function(e){this._type._supportInterpolationMode||e===oy.Step?this._interpolation=e:(this._interpolation=oy.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),e}();e.AnimationArrayCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=[],t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},t._initializeLayerOwner=function(e){e.finalValue=[]},t._lerpValue=function(e,t,n,r){for(var a=0,i=r.length;a<i;++a){var o=e[a];r[a]=o+(t[a]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},t._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},t._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},t._setValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},t._hermiteInterpolationValue=function(e,t,n,r,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},t}(ox),e.AnimationArrayCurve._isCopyMode=!0,e.AnimationArrayCurve._supportInterpolationMode=!0,e.AnimationArrayCurve=tX([ry()],e.AnimationArrayCurve),e.AnimationBoolCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=!1,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},t._initializeLayerOwner=function(e){e.finalValue=!1},t._lerpValue=function(e,t){return e},t._subtractValue=function(e,t,n){return e},t._getZeroValue=function(){return!1},t._additiveValue=function(e,t,n){return e},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e){return e.value},t}(ox),e.AnimationBoolCurve._isCopyMode=!1,e.AnimationBoolCurve._supportInterpolationMode=!1,e.AnimationBoolCurve=tX([ry()],e.AnimationBoolCurve),e.AnimationColorCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tO,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tO,e.fixedPoseValue=new tO,e.baseEvaluateData.value=new tO,e.crossEvaluateData.value=new tO},t._initializeLayerOwner=function(e){e.finalValue=new tO},t._lerpValue=function(e,t,n,r){return tO.lerp(e,t,n,r),r},t._subtractValue=function(e,t,n){return tO.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._additiveValue=function(e,t,n){return tO.scale(e,t,e),tO.add(n,e,n),n},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.r=d*i.r+h*p*r+_*m*r+f*s.r:a.r=i.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.g=d*i.g+h*p*r+_*m*r+f*s.g:a.g=i.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.b=d*i.b+h*p*r+_*m*r+f*s.b:a.b=i.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.a=d*i.a+h*p*r+_*m*r+f*s.a:a.a=i.a,a},t}(ox),e.AnimationColorCurve._isCopyMode=!0,e.AnimationColorCurve._supportInterpolationMode=!0,e.AnimationColorCurve=tX([ry()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tW(t,e),t.prototype.addKey=function(t){e.prototype.addKey.call(this,t);var n=this._evaluateData;if(!n.value||n.value.length!==t.value.length){var r=t.value.length;n.value=new Float32Array(r)}},t._initializeOwner=function(e){var t=e.referenceTargetValue.length;e.defaultValue=new Float32Array(t),e.fixedPoseValue=new Float32Array(t),e.baseEvaluateData.value=new Float32Array(t),e.crossEvaluateData.value=new Float32Array(t)},t._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},t._lerpValue=function(e,t,n,r){for(var a=0,i=r.length;a<i;++a){var o=e[a];r[a]=o+(t[a]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},t._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},t._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},t._setValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},t._hermiteInterpolationValue=function(e,t,n,r,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},t}(ox),e.AnimationFloatArrayCurve._isCopyMode=!0,e.AnimationFloatArrayCurve._supportInterpolationMode=!0,e.AnimationFloatArrayCurve=tX([ry()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=0,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},t._initializeLayerOwner=function(e){e.finalValue=0},t._lerpValue=function(e,t,n){return e+(t-e)*n},t._additiveValue=function(e,t,n){return n+e*t},t._subtractValue=function(e,t){return e-t},t._getZeroValue=function(){return 0},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e,t,n,r){var a=e.outTangent,i=t.inTangent;if(!(Number.isFinite(a)&&Number.isFinite(i)))return e.value;var o=n*n,s=o*n;return(2*s-3*o+1)*e.value+(s-2*o+n)*a*r+(s-o)*i*r+(-2*s+3*o)*t.value},t}(ox),e.AnimationFloatCurve._isCopyMode=!1,e.AnimationFloatCurve._supportInterpolationMode=!0,e.AnimationFloatCurve=tX([ry()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tF,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tF,e.fixedPoseValue=new tF,e.baseEvaluateData.value=new tF,e.crossEvaluateData.value=new tF},t._initializeLayerOwner=function(e){e.finalValue=new tF},t._lerpValue=function(e,t,n,r){return tF.slerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return e.x=e.x*t,e.y=e.y*t,e.z=e.z*t,e.normalize(),n.multiply(e),n},t._subtractValue=function(e,n,r){var a=t._tempConjugateQuat;return tF.conjugate(n,a),tF.multiply(a,e,r),r},t._getZeroValue=function(e){return e.set(0,0,0,1),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*r+_*m*r+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*r+_*m*r+f*s.w:a.w=i.w,a},t}(ox),e.AnimationQuaternionCurve._supportInterpolationMode=!0,e.AnimationQuaternionCurve._isCopyMode=!0,e.AnimationQuaternionCurve._tempConjugateQuat=new tF,e.AnimationQuaternionCurve=tX([ry()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tB,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tB,e.fixedPoseValue=new tB,e.baseEvaluateData.value=new tB,e.crossEvaluateData.value=new tB},t._initializeLayerOwner=function(e){e.finalValue=new tB},t._lerpValue=function(e,t,n,r){return tB.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tB.scale(e,t,e),tB.add(n,e,n),n},t._subtractValue=function(e,t,n){return tB.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,a},t}(ox),e.AnimationVector2Curve._isCopyMode=!0,e.AnimationVector2Curve._supportInterpolationMode=!0,e.AnimationVector2Curve=tX([ry()],e.AnimationVector2Curve),e.AnimationVector3Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tT,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tT,e.fixedPoseValue=new tT,e.baseEvaluateData.value=new tT,e.crossEvaluateData.value=new tT},t._initializeLayerOwner=function(e){e.finalValue=new tT},t._lerpValue=function(e,t,n,r){return tT.lerp(e,t,n,r),r},t._relativeBaseValue=function(e,t){return tT.subtract(t,e,t),t},t._additiveValue=function(e,t,n){return tT.scale(e,t,e),tT.add(n,e,n),n},t._subtractValue=function(e,t,n){return tT.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*r+_*m*r+f*s.z:a.z=i.z,a},t}(ox),e.AnimationVector3Curve._isCopyMode=!0,e.AnimationVector3Curve._supportInterpolationMode=!0,e.AnimationVector3Curve=tX([ry()],e.AnimationVector3Curve),e.AnimationVector4Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tI,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tI,e.fixedPoseValue=new tI,e.baseEvaluateData.value=new tI,e.crossEvaluateData.value=new tI},t._initializeLayerOwner=function(e){e.finalValue=new tI},t._lerpValue=function(e,t,n,r){return tI.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tI.scale(e,t,e),tI.add(n,e,n),n},t._subtractValue=function(e,t,n){return tI.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=d*i.x+h*p*r+_*m*r+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*r+_*m*r+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*r+_*m*r+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*r+_*m*r+f*s.w:a.w=i.w,a},t}(ox),e.AnimationVector4Curve._isCopyMode=!0,e.AnimationVector4Curve._supportInterpolationMode=!0,e.AnimationVector4Curve=tX([ry()],e.AnimationVector4Curve),e.AnimationRefCurve=/*#__PURE__*/function(e){function t(){return e.call(this)||this}return tW(t,e),t._initializeOwner=function(e){},t._initializeLayerOwner=function(e){},t._setValue=function(e){return e},t}(ox),e.AnimationRefCurve._isCopyMode=!1,e.AnimationRefCurve._supportInterpolationMode=!1,e.AnimationRefCurve=tX([ry()],e.AnimationRefCurve),e.AnimationRectCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tN,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tN,e.fixedPoseValue=new tN,e.baseEvaluateData.value=new tN,e.crossEvaluateData.value=new tN},t._initializeLayerOwner=function(e){e.finalValue=new tN},t._setValue=function(e,t){return t.copyFrom(e),t},t}(ox),e.AnimationRectCurve._isCopyMode=!0,e.AnimationRectCurve._supportInterpolationMode=!1,e.AnimationRectCurve=tX([ry()],e.AnimationRectCurve),e.AnimationStringCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value="",t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},t._initializeLayerOwner=function(e){e.finalValue=""},t._lerpValue=function(e,t){return e},t._subtractValue=function(e,t,n){return e},t._getZeroValue=function(){return""},t._additiveValue=function(e,t,n){return e},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e){return e.value},t}(ox),e.AnimationStringCurve._isCopyMode=!1,e.AnimationStringCurve._supportInterpolationMode=!1,e.AnimationStringCurve=tX([ry()],e.AnimationStringCurve);var ob=((eO={})[eO.If=0]="If",eO[eO.IfNot=1]="IfNot",eO[eO.Greater=2]="Greater",eO[eO.Less=3]="Less",eO[eO.Equals=4]="Equals",eO[eO.NotEquals=5]="NotEquals",eO),oC=((eN={})[eN.None=0]="None",eN[eN.Complete=1]="Complete",eN),oS=((eV={})[eV.Override=0]="Override",eV[eV.Additive=1]="Additive",eV),oT=((ek={})[ek.UnStarted=0]="UnStarted",ek[ek.Playing=1]="Playing",ek[ek.Finished=2]="Finished",ek),oA=((ez={})[ez.Standby=0]="Standby",ez[ez.Playing=1]="Playing",ez[ez.CrossFading=2]="CrossFading",ez[ez.FixedCrossFading=3]="FixedCrossFading",ez[ez.Finished=4]="Finished",ez),oE=/*#__PURE__*/function(){function e(){this.handlers=[]}return e.prototype.dispose=function(){},e}(),oR=function(){},oM=/*#__PURE__*/function(){function e(){this.duration=0,this.offset=0,this.exitTime=1,this.mute=!1,this.isFixedDuration=!1,this._isExit=!1,this._conditions=[],this._solo=!1,this._hasExitTime=!0}var t=e.prototype;return t.addCondition=function(e,t,n){if((void 0===e?"undefined":e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object")return this._conditions.push(e),e;var r=new oR;return r.parameterName=e,r.mode=null!=t?t:ob.If,r.threshold=n,this._conditions.push(r),r},t.removeCondition=function(e){var t=this._conditions.indexOf(e);-1!==t&&this._conditions.splice(t,1)},t._getFixedDuration=function(){return this.isFixedDuration?this.duration:this.duration*this.destinationState._getDuration()},tG(e,[{key:"isExit",get:function(){return this._isExit}},{key:"solo",get:function(){return this._solo},set:function(e){var t;this._solo!==e&&(this._solo=e,null==(t=this._collection)||t.updateTransitionSolo(e))}},{key:"conditions",get:function(){return this._conditions}},{key:"hasExitTime",get:function(){return this._hasExitTime},set:function(e){var t;this._hasExitTime!==e&&(this._hasExitTime=e,null==(t=this._collection)||t.updateTransitionsIndex(this,e))}}]),e}(),ow=((eU={})[eU.Once=0]="Once",eU[eU.Loop=1]="Loop",eU),oP=/*#__PURE__*/function(){function e(){this.isForward=!0,this._changedOrientation=!1}var t=e.prototype;return t.reset=function(e,t,n){this.state=e,this.playedTime=0,this.offsetFrameTime=n,this.stateData=t,this.playState=oT.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.isForward=!0,this.state._transitionCollection.needResetCurrentCheckIndex=!0},t.updateOrientation=function(e){if(0!==e){var t=this.isForward;this.isForward=e>0,this.isForward!==t&&(this._changedOrientation=!0,this.isForward||this._correctTime())}},t.update=function(e){this.playedTime+=e;var t=this.state,n=this.playedTime+this.offsetFrameTime,r=t._getDuration();this.playState=oT.Playing,t.wrapMode===ow.Loop?n=r?n%r:0:Math.abs(n)>=r&&(n=n<0?-r:r,this.playState=oT.Finished),n<0&&(n+=r),this.clipTime=n+t.clipStartTime*t.clip.length,this._changedOrientation&&(this.isForward||this._correctTime(),this._changedOrientation=!1)},t._correctTime=function(){var e=this.state;0===this.clipTime&&(this.clipTime=e.clipEndTime*e.clip.length)},e}(),oF=/*#__PURE__*/function(){function e(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new oP,this.destPlayData=new oP,this.layerState=oA.Standby,this.crossCurveMark=0,this.manuallyTransition=new oM,this.crossLayerOwnerCollection=[]}var t=e.prototype;return t.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},t.resetCurrentCheckIndex=function(){this.layer.stateMachine._entryTransitionCollection.needResetCurrentCheckIndex=!0,this.layer.stateMachine._anyStateTransitionCollection.needResetCurrentCheckIndex=!0},e}(),oL=function(){this.curveLayerOwner=[],this.eventHandlers=[]},oD=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this).cullingMode=oC.None,n.speed=1,n._playFrameCount=-1,n._onUpdateIndex=-1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new iq(oE),n._parametersValueMap=Object.create(null),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n}tW(n,t);var r=n.prototype;return r.play=function(e,t,n){void 0===t&&(t=-1),void 0===n&&(n=0),(null==(r=this._controllerUpdateFlag)?void 0:r.flag)&&this._reset();var r,a=this._getAnimatorStateInfo(e,t),i=a.state;i&&this._preparePlay(i,a.layerIndex,n)&&(this._playFrameCount=this.engine.time.frameCount)},r.crossFade=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!1)},r.crossFadeInFixedDuration=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!0)},r.update=function(e){if(this._playFrameCount===this.engine.time.frameCount&&(e=0),this.cullingMode===oC.Complete){n=!1;for(var t,n,r=this._controlledRenderers,a=0,i=r.length;a<i;a++)if(!r[a].isCulled){n=!0;break}}else n=!0;var o=this._animatorController;if(o){(null==(t=this._controllerUpdateFlag)?void 0:t.flag)&&this._reset(),this._updateMark++;for(var s=o.layers,l=0,c=s.length;l<c;l++){var u=this._getAnimatorLayerData(l);this._updateState(u,e,n)}}},r.getCurrentAnimatorState=function(e){var t,n;return null==(n=this._animatorLayersData[e])?void 0:null==(t=n.srcPlayData)?void 0:t.state},r.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},r.findLayerByName=function(e){var t;return null==(t=this._animatorController)?void 0:t._layersMap[e]},r.getParameter=function(e){var t,n;return null!=(n=null==(t=this._animatorController)?void 0:t._parametersMap[e])?n:null},r.getParameterValue=function(e){var t,n,r=null==(t=this._animatorController)?void 0:t._parametersMap[e];if(r)return null!=(n=this._parametersValueMap[e])?n:r.defaultValue},r.setParameterValue=function(e,t){var n;(null==(n=this._animatorController)?void 0:n._parametersMap[e])&&(this._parametersValueMap[e]=t)},r.activateTriggerParameter=function(e){var t,n=null==(t=this._animatorController)?void 0:t._parametersMap[e];(null==n?void 0:n._isTrigger)&&(this._parametersValueMap[e]=!0)},r.deactivateTriggerParameter=function(e){var t,n=null==(t=this._animatorController)?void 0:t._parametersMap[e];(null==n?void 0:n._isTrigger)&&(this._parametersValueMap[e]=!1)},r._onEnable=function(){this._reset(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},r._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},r._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},r._reset=function(){var e=this._curveOwnerPool;for(var t in e){var n=e[t];for(var r in n)n[r].revertDefaultValue()}this._animatorLayersData.length=0,this._curveOwnerPool=Object.create(null),this._parametersValueMap=Object.create(null),this._animationEventHandlerPool.clear(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},r._crossFade=function(e,t,n,r,a){(null==(i=this._controllerUpdateFlag)?void 0:i.flag)&&this._reset();var i,o=this._getAnimatorStateInfo(e,n),s=o.state,l=o.layerIndex,c=this._getAnimatorLayerData(l).manuallyTransition;c.duration=t,c.offset=r,c.isFixedDuration=a,c.destinationState=s,this._prepareCrossFadeByTransition(c,l)&&(this._playFrameCount=this.engine.time.frameCount)},r._getAnimatorStateInfo=function(e,t){var n=this._animatorController,r=this._tempAnimatorStateInfo,a=null;if(n){var i=n.layers;if(-1===t){for(var o=0,s=i.length;o<s;o++)if(a=i[o].stateMachine.findStateByName(e)){t=o;break}}else a=i[t].stateMachine.findStateByName(e)}return r.layerIndex=t,r.state=a,r},r._getAnimatorStateData=function(e,t,n,r){var a=n.animatorStateDataMap,i=a[e];return i||(i=new oL,a[e]=i,this._saveAnimatorStateData(t,i,n,r),this._saveAnimatorEventHandlers(t,i)),i},r._saveAnimatorStateData=function(e,t,n,r){for(var a=this.entity,i=this._curveOwnerPool,o=this._animatorController.layers[r].mask,s=t.curveLayerOwner,l=e.clip._curveBindings,c=n.curveOwnerPool,u=l.length-1;u>=0;u--){var d=l[u],h=d.relativePath,_=""===d.relativePath?a:a.findByPath(d.relativePath);if(_){var f,p,m=d.typeIndex>0?_.getComponents(d.type,ou._components)[d.typeIndex]:_.getComponent(d.type);if(!m)continue;var g=d.property,v=m.instanceId,y=i[v]||(i[v]=Object.create(null)),x=y[g]||(y[g]=d._createCurveOwner(_,m)),b=c[v]||(c[v]=Object.create(null)),C=b[g]||(b[g]=d._createCurveLayerOwner(x));o&&o.pathMasks.length&&(C.isActive=null==(p=null==(f=o.getPathMask(h))?void 0:f.active)||p),s[u]=C}else s[u]=null,no.warn("The entity don't have the child entity which path is "+d.relativePath+".")}},r._saveAnimatorEventHandlers=function(e,t){var n=this,r=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){n._entity.getComponents(os,a);var t=a.length,o=e.clip.events;i.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=r.get(),d=c.functionName,h=u.handlers;u.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f,p=a[_],m=null==(f=p[d])?void 0:f.bind(p);m&&h.push(m)}i.push(u)}};o(),e._updateFlagManager.addListener(o)},r._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},r._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},r._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},r._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},r._prepareFixedPoseCrossFading=function(e){for(var t=e.crossLayerOwnerCollection,n=t.length-1;n>=0;n--){var r=t[n];r&&(r.curveOwner.saveFixedPoseValue(),r.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},r._prepareSrcCrossData=function(e,t){for(var n=e.srcPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var a=n[r];a&&(a.crossCurveMark=e.crossCurveMark,t&&a.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,a,r,-1))}},r._prepareDestCrossData=function(e,t){for(var n=e.destPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var a=n[r];if(a){if(a.crossCurveMark===e.crossCurveMark)a.crossDestCurveIndex=r;else{var i=a.curveOwner;t&&i.saveFixedPoseValue(),a.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,a,-1,r)}}}},r._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||((t=new oF).layerIndex=e,t.layer=this._animatorController.layers[e],this._animatorLayersData[e]=t),t},r._updateState=function(e,t,n){var r=e.layer,a=r.weight,i=r.blendingMode===oS.Additive;switch(0===e.layerIndex&&(a=1),e.layerState){case oA.Standby:this._checkAnyAndEntryState(e,t,n);break;case oA.Playing:this._updatePlayingState(e,a,i,t,n);break;case oA.Finished:this._updateFinishedState(e,a,i,t,n);break;case oA.CrossFading:this._updateCrossFadeState(e,a,i,t,n);break;case oA.FixedCrossFading:this._updateCrossFadeFromPoseState(e,a,i,t,n)}},r._updatePlayingState=function(e,t,n,r,a){var i,o=e.srcPlayData,s=o.state,l=s.speed*this.speed,c=l*r;o.updateOrientation(c);var u=o.clipTime,d=o.playState;o.update(c);var h=o.clipTime,_=o.isForward,f=s._transitionCollection,p=e.layer.stateMachine._anyStateTransitionCollection,m=p.count&&this._applyStateTransitions(e,_,o,p,u,h,c,a)||f.count&&this._applyStateTransitions(e,_,o,f,u,h,c,a);if(m){var g=s._getClipActualEndTime();if(m.hasExitTime){var v=m.exitTime*s._getDuration()+s._getClipActualStartTime();if(_)i=v<u?v+g-u:v-u;else{var y=s._getClipActualStartTime();i=-(i=u<v?g-v+u-y:u-v)}}else i=0;o.update(i-c)}else i=c,o.playState===oT.Finished&&(e.layerState=oA.Finished);if(this._evaluatePlayingState(o,t,n,a),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,u,d,i),m){var x=r-i/l;x>0&&this._updateState(e,x,a)}},r._evaluatePlayingState=function(e,t,n,r){var a=e.state.clip._curveBindings,i=e.playState===oT.Finished;if(r||i)for(var o=e.stateData.curveLayerOwner,s=a.length-1;s>=0;s--){var l=o[s],c=null==l?void 0:l.curveOwner;if(c&&l.isActive){var u=a[s].curve;if(u.keys.length){this._checkRevertOwner(c,n);var d=c.evaluateValue(u,e.clipTime,n);r&&c.applyValue(d,t,n),i&&l.saveFinalValue()}}}},r._updateCrossFadeState=function(e,t,n,r,a){var i,o=e.srcPlayData,s=e.destPlayData,l=e.layerIndex,c=this.speed,u=o.state,d=s.state,h=e.crossFadeTransition._getFixedDuration(),_=u.speed*c,f=d.speed*c,p=f*r;o&&o.updateOrientation(_*r),s&&s.updateOrientation(p);var m=o.clipTime,g=o.playState,v=s.clipTime,y=s.playState;if(s.isForward){var x=s.playedTime;i=x+p>h?h-x:p}else{var b=s.playedTime;i=b-p>h?b-h:p}var C=0===f?r:i/f,S=C*_;o.update(S),s.update(i);var T=Math.abs(s.playedTime)/h;(T>=1-tS.zeroTolerance||0===h)&&(T=1);var A=1===T;if(A?(o.playState=oT.Finished,this._preparePlayOwner(e,d),this._evaluatePlayingState(s,t,n,a)):this._evaluateCrossFadeState(e,o,s,t,T,n,a),this._fireAnimationEventsAndCallScripts(l,o,u,m,g,S),this._fireAnimationEventsAndCallScripts(l,s,d,v,y,i),A){this._updateCrossFadeData(e);var E=r-C;E>0&&this._updateState(e,E,a)}},r._evaluateCrossFadeState=function(e,t,n,r,a,i,o){var s=e.crossLayerOwnerCollection,l=t.state.clip._curveBindings,c=n.state.clip._curveBindings,u=n.playState===oT.Finished;if(o||u)for(var d=s.length-1;d>=0;d--){var h=s[d],_=null==h?void 0:h.curveOwner;if(_){var f=h.crossSrcCurveIndex,p=h.crossDestCurveIndex;this._checkRevertOwner(_,i);var m=_.evaluateCrossFadeValue(f>=0?l[f].curve:null,p>=0?c[p].curve:null,t.clipTime,n.clipTime,a,i);o&&_.applyValue(m,r,i),u&&h.saveFinalValue()}}},r._updateCrossFadeFromPoseState=function(e,t,n,r,a){var i,o=e.destPlayData,s=o.state,l=e.crossFadeTransition._getFixedDuration(),c=s.speed*this.speed,u=c*r;o.updateOrientation(u);var d=o.clipTime,h=o.playState;if(o.isForward){var _=o.playedTime;i=_+u>l?l-_:u}else{var f=o.playedTime;i=f-u>l?f-l:u}var p=0===c?r:i/c;o.update(i);var m=Math.abs(o.playedTime)/l;(m>=1-tS.zeroTolerance||0===l)&&(m=1);var g=1===m;if(g?(this._preparePlayOwner(e,s),this._evaluatePlayingState(o,t,n,a)):this._evaluateCrossFadeFromPoseState(e,o,t,m,n,a),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,d,h,i),g){this._updateCrossFadeData(e);var v=r-p;v>0&&this._updateState(e,v,a)}},r._evaluateCrossFadeFromPoseState=function(e,t,n,r,a,i){var o=e.crossLayerOwnerCollection,s=t.state.clip._curveBindings,l=t.clipTime,c=t.playState===oT.Finished;if(i||c)for(var u=o.length-1;u>=0;u--){var d=o[u],h=null==d?void 0:d.curveOwner;if(h){var _=d.crossDestCurveIndex;this._checkRevertOwner(h,a);var f=d.curveOwner.crossFadeFromPoseAndApplyValue(_>=0?s[_].curve:null,l,r,a);i&&h.applyValue(f,n,a),c&&d.saveFinalValue()}}},r._updateFinishedState=function(e,t,n,r,a){var i=e.srcPlayData,o=i.state,s=o.speed*this.speed*r;i.updateOrientation(s);var l=i.clipTime,c=i.isForward,u=o._transitionCollection,d=e.layer.stateMachine._anyStateTransitionCollection;d.count&&this._applyTransitionsByCondition(e,d,a)||u.count&&this._applyStateTransitions(e,c,i,u,l,l,s,a)?this._updateState(e,r,a):this._evaluateFinishedState(i,t,n,a)},r._evaluateFinishedState=function(e,t,n,r){if(r)for(var a=e.stateData.curveLayerOwner,i=e.state.clip._curveBindings,o=i.length-1;o>=0;o--){var s=a[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,n),l.applyValue(s.finalValue,t,n))}},r._updateCrossFadeData=function(e){e.destPlayData.playState===oT.Finished?e.layerState=oA.Finished:e.layerState=oA.Playing,e.switchPlayData(),e.crossFadeTransition=null},r._preparePlayOwner=function(e,t){if(e.layerState===oA.Playing){var n=e.srcPlayData;if(n.state!==t)for(var r,a=n.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(r=a[i])||r.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},r._applyStateTransitions=function(e,t,n,r,a,i,o,s){var l=n.state,c=l.clip.length,u=null,d=l.clipStartTime*c,h=l.clipEndTime*c;return r.noExitTimeCount&&(u=this._checkNoExitTimeTransition(e,r,s))||(t?a+o>=h?(u=this._checkSubTransition(e,l,r,a,h,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkSubTransition(e,l,r,d,i,s)):u=this._checkSubTransition(e,l,r,a,i,s):a+o<=d?(u=this._checkBackwardsSubTransition(e,l,r,a,d,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkBackwardsSubTransition(e,l,r,i,h,s)):u=this._checkBackwardsSubTransition(e,l,r,a,i,s)),u},r._checkNoExitTimeTransition=function(e,t,n){for(var r=0,a=t.count;r<a;++r){var i=t.get(r);if(!i.mute&&(!t.isSoloMode||i.solo)&&this._checkConditions(i))return this._applyTransition(e,i,n)}return null},r._checkSubTransition=function(e,t,n,r,a,i){n.needResetCurrentCheckIndex&&n.resetCurrentCheckIndex(!0);for(var o=n.transitions,s=n.noExitTimeCount+n.currentCheckIndex,l=o.length;s<l;s++){var c=o[s],u=c.exitTime*t._getDuration()+t._getClipActualStartTime();if(u>a)break;if(!(u<r)){if(n.updateCurrentCheckIndex(!0),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,i)}}return null},r._checkBackwardsSubTransition=function(e,t,n,r,a,i){n.needResetCurrentCheckIndex&&n.resetCurrentCheckIndex(!1);for(var o=n.transitions,s=n.noExitTimeCount,l=n.currentCheckIndex+s;l>=s;l--){var c=o[l],u=c.exitTime*t._getDuration()+t._getClipActualStartTime();if(u<a)break;if(!(u>r)){if(n.updateCurrentCheckIndex(!1),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,i)}}return null},r._applyTransitionsByCondition=function(e,t,n){for(var r=0,a=t.count;r<a;r++){var i=t.get(r);if(!i.mute&&(!t.isSoloMode||i.solo)&&this._checkConditions(i)){if(this._applyTransition(e,i,n))return i;return null}}},r._preparePlay=function(e,t,n){void 0===n&&(n=0);var r=e.name;if(!e.clip)return no.warn("The state named "+r+" has no AnimationClip data."),!1;var a=this._getAnimatorLayerData(t),i=this._getAnimatorStateData(r,e,a,t);return this._preparePlayOwner(a,e),a.layerState=oA.Playing,a.srcPlayData.reset(e,i,e._getClipActualEndTime()*n),a.resetCurrentCheckIndex(),!0},r._applyTransition=function(e,t,n){var r=this._prepareCrossFadeByTransition(t,e.layerIndex);return t.isExit?(this._checkAnyAndEntryState(e,0,n),t):r?t:null},r._checkConditions=function(e){for(var t=e.conditions,r=!0,a=0,i=t.length;a<i;++a){var o=!1,s=t[a],l=s.mode,c=s.parameterName,u=s.threshold,d=this.getParameterValue(c);if(void 0===d)return!1;if(!0===d){var h=this.getParameter(c);(null==h?void 0:h._isTrigger)&&(n._passedTriggerParameterNames.push(c),o=!0)}if(!o)switch(l){case ob.Equals:d===u&&(o=!0);break;case ob.Greater:d>u&&(o=!0);break;case ob.Less:d<u&&(o=!0);break;case ob.NotEquals:d!==u&&(o=!0);break;case ob.If:!0===d&&(o=!0);break;case ob.IfNot:!1===d&&(o=!0)}if(!o){r=!1;break}}return r&&this._deactivateTriggeredParameters(),n._passedTriggerParameterNames.length=0,r},r._prepareCrossFadeByTransition=function(e,t){var n=e.destinationState;if(!n)return!1;if(!n.clip)return no.warn("The state named "+n.name+" has no AnimationClip data."),!1;var r=this._getAnimatorLayerData(t),a=this._getAnimatorStateData(n.name,n,r,t);switch(r.destPlayData.reset(n,a,e.offset*n._getClipActualEndTime()),r.resetCurrentCheckIndex(),r.layerState){case oA.Standby:case oA.Finished:r.layerState=oA.FixedCrossFading,this._clearCrossData(r),this._prepareStandbyCrossFading(r);break;case oA.Playing:r.layerState=oA.CrossFading,this._clearCrossData(r),this._prepareCrossFading(r);break;case oA.CrossFading:r.layerState=oA.FixedCrossFading,this._prepareFixedPoseCrossFading(r);break;case oA.FixedCrossFading:this._prepareFixedPoseCrossFading(r)}return r.crossFadeTransition=e,!0},r._fireAnimationEvents=function(e,t,n,r){var a=e.state,i=e.isForward,o=e.clipTime,s=a._getClipActualStartTime(),l=a._getClipActualEndTime();i?n+r>=l?(this._fireSubAnimationEvents(e,t,n,l),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,s,o)):this._fireSubAnimationEvents(e,t,n,o):n+r<=s?(this._fireBackwardSubAnimationEvents(e,t,n,s),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,l,o)):this._fireBackwardSubAnimationEvents(e,t,n,o)},r._fireSubAnimationEvents=function(e,t,n,r){for(var a=e.currentEventIndex,i=t.length;a<i;a++){var o=t[a],s=o.event,l=s.time,c=s.parameter;if(l>r)break;var u=o.handlers;if(l>=n){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(a+1,i-1)}}},r._fireBackwardSubAnimationEvents=function(e,t,n,r){for(var a=e.currentEventIndex;a>=0;a--){var i=t[a],o=i.event,s=o.time,l=o.parameter;if(s<r)break;if(s<=n){for(var c=i.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(a-1,0)}}},r._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,a=n.length;r<a;r++)n[r].onStateEnter(this,e,t)},r._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,a=n.length;r<a;r++)n[r].onStateUpdate(this,e,t)},r._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,a=n.length;r<a;r++)n[r].onStateExit(this,e,t)},r._checkAnyAndEntryState=function(e,t,n){var r,a=e.layer.stateMachine,i=a._anyStateTransitionCollection,o=a._entryTransitionCollection;if((r=i.count&&this._applyTransitionsByCondition(e,i,n))||(r=o.count&&this._applyTransitionsByCondition(e,o,n)),r)this._updateState(e,t,n);else{var s=a.defaultState;s&&(this._preparePlay(s,e.layerIndex),this._updateState(e,t,n))}},r._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},r._fireAnimationEventsAndCallScripts=function(e,t,n,r,a,i){var o=t.stateData.eventHandlers;o.length&&this._fireAnimationEvents(t,o,r,i),a===oT.UnStarted&&this._callAnimatorScriptOnEnter(n,e),a!==oT.Finished&&t.playState===oT.Finished?this._callAnimatorScriptOnExit(n,e):this._callAnimatorScriptOnUpdate(n,e)},r._deactivateTriggeredParameters=function(){for(var e=n._passedTriggerParameterNames,t=0,r=e.length;t<r;t++)this._parametersValueMap[e[t]]=!1},tG(n,[{key:"animatorController",get:function(){return this._animatorController},set:function(e){e!==this._animatorController&&(this._reset(),this._controllerUpdateFlag&&this._controllerUpdateFlag.destroy(),this._controllerUpdateFlag=e&&e._registerChangeFlag(),this._animatorController=e)}},{key:"layers",get:function(){var e;return null==(e=this._animatorController)?void 0:e._layers}},{key:"parameters",get:function(){var e;return null==(e=this._animatorController)?void 0:e._parameters}}]),n}(ru);oD._passedTriggerParameterNames=[],tX([tQ],oD.prototype,"speed",void 0),tX([tq],oD.prototype,"_controllerUpdateFlag",void 0),tX([tq],oD.prototype,"_updateMark",void 0),tX([tq],oD.prototype,"_animatorLayersData",void 0),tX([tq],oD.prototype,"_curveOwnerPool",void 0),tX([tq],oD.prototype,"_animationEventHandlerPool",void 0),tX([tq],oD.prototype,"_parametersValueMap",void 0),tX([tq],oD.prototype,"_tempAnimatorStateInfo",void 0),tX([tq],oD.prototype,"_controlledRenderers",void 0);var oB=/*#__PURE__*/function(){function e(){this._onNameChanged=null,this._isTrigger=!1}return tG(e,[{key:"name",get:function(){return this._name},set:function(e){if(this._name!==e){var t=this._name;this._name=e,null==this._onNameChanged||this._onNameChanged.call(this,t,e)}}}]),e}(),oI=/*#__PURE__*/function(e){function t(t){var n;return t&&((n=e.call(this,t)||this)._parameters=[],n._parametersMap={},n._layers=[],n._layersMap={},n._updateFlagManager=new nM),function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}tW(t,e);var n=t.prototype;return n.addParameter=function(e,t){return this._addParameter(e,t,!1)},n.addTriggerParameter=function(e){return this._addParameter(e,!1,!0)},n.removeParameter=function(e){var t=this._parametersMap[e],n=this._parameters.indexOf(t);-1!==n&&(this._parameters.splice(n,1),delete this._parametersMap[t.name])},n.clearParameters=function(){for(var e in this._parameters.length=0,this._parametersMap)delete this._parametersMap[e]},n.getParameter=function(e){return this._parametersMap[e]||null},n.findLayerByName=function(e){return this._layersMap[e]},n.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},n.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},n.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},n._registerChangeFlag=function(){return this._updateFlagManager.createFlag(rf)},n._addParameter=function(e,t,n){var r=this;if(void 0===n&&(n=!1),this._parametersMap[e])return console.warn("Parameter "+e+" already exists."),null;var a=new oB;return a.name=e,a.defaultValue=t,a._isTrigger=n,a._onNameChanged=function(e,t){delete r._parametersMap[e],r._parametersMap[t]=a},this._parametersMap[e]=a,this._parameters.push(a),a},tG(t,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),t}(t1),oO=/*#__PURE__*/function(){function e(){this.transitions=[],this.noExitTimeCount=0,this.needResetCurrentCheckIndex=!0,this._soloCount=0}var t=e.prototype;return t.get=function(e){return this.transitions[e]},t.add=function(e){var t;return tK(e,oV)?((t=new oM).hasExitTime=!1,t.destinationState=e):t=e,this._addTransition(t),t._collection=this,t.solo&&this._soloCount++,t},t.remove=function(e){var t=this.transitions,n=t.indexOf(e);-1!==n&&(t.splice(n,1),!e.hasExitTime&&this.noExitTimeCount--),e._collection=null,e.solo&&this._soloCount--},t.clear=function(){for(var e=this.transitions,t=0,n=e.length;t<n;t++)e[t]._collection=null;e.length=0,this._soloCount=0,this.noExitTimeCount=0},t.updateTransitionSolo=function(e){this._soloCount+=e?1:-1},t.updateTransitionsIndex=function(e,t){var n=this.transitions;n.splice(n.indexOf(e),1),this._addTransition(e)},t.updateCurrentCheckIndex=function(e){this.currentCheckIndex=e?Math.min(this.currentCheckIndex+1,this.count-this.noExitTimeCount-1):Math.max(this.currentCheckIndex-1,0)},t.resetCurrentCheckIndex=function(e){this.currentCheckIndex=e?0:this.count-this.noExitTimeCount-1,this.needResetCurrentCheckIndex=!1},t._addTransition=function(e){var t=this.transitions;if(!e.hasExitTime){t.unshift(e),this.noExitTimeCount++;return}var n=e.exitTime,r=t.length;if(n>=(r?t[r-1].exitTime:0))t.push(e);else{for(var a=r;--a>=0&&n<t[a].exitTime;);t.splice(a+1,0,e)}},tG(e,[{key:"isSoloMode",get:function(){return this._soloCount>0}},{key:"count",get:function(){return this.transitions.length}}]),e}(),oN=/*#__PURE__*/function(){function e(){this._destroyed=!1}var t=e.prototype;return t.onStateEnter=function(e,t,n){},t.onStateUpdate=function(e,t,n){},t.onStateExit=function(e,t,n){},t.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},e}(),oV=/*#__PURE__*/function(){function e(e){this.name=e,this.speed=1,this.wrapMode=ow.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new nM,this._transitionCollection=new oO,this._clipStartTime=0,this._clipEndTime=1,this._onClipChanged=this._onClipChanged.bind(this)}var t=e.prototype;return t.addTransition=function(e){return this._transitionCollection.add(e)},t.addExitTransition=function(e){void 0===e&&(e=1);var t=new oM;return t._isExit=!0,t.exitTime=e,this._transitionCollection.add(t)},t.removeTransition=function(e){this._transitionCollection.remove(e),e._isExit&&(e._isExit=!1)},t.addStateMachineScript=function(e){var t=new e;t._state=this;var n=oN.prototype;return t.onStateEnter!==n.onStateEnter&&this._onStateEnterScripts.push(t),t.onStateUpdate!==n.onStateUpdate&&this._onStateUpdateScripts.push(t),t.onStateExit!==n.onStateExit&&this._onStateExitScripts.push(t),t},t.clearTransitions=function(){this._transitionCollection.clear()},t._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},t._removeStateMachineScript=function(e){var t=oN.prototype;if(e.onStateEnter!==t.onStateEnter){var n=this._onStateEnterScripts.indexOf(e);-1!==n&&this._onStateEnterScripts.splice(n,1)}if(e.onStateUpdate!==t.onStateUpdate){var r=this._onStateUpdateScripts.indexOf(e);-1!==r&&this._onStateUpdateScripts.splice(r,1)}if(e.onStateExit!==t.onStateExit){var a=this._onStateExitScripts.indexOf(e);-1!==a&&this._onStateExitScripts.splice(a,1)}},t._onClipChanged=function(){this._updateFlagManager.dispatch()},t._getClipActualStartTime=function(){return this._clipStartTime*this.clip.length},t._getClipActualEndTime=function(){return this._clipEndTime*this.clip.length},tG(e,[{key:"transitions",get:function(){return this._transitionCollection.transitions}},{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._updateFlagManager.removeListener(this._onClipChanged),this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1),this._onClipChanged(),e&&e._updateFlagManager.addListener(this._onClipChanged))}},{key:"clipStartTime",get:function(){return this._clipStartTime},set:function(e){this._clipStartTime=Math.max(e,0)}},{key:"clipEndTime",get:function(){return this._clipEndTime},set:function(e){this._clipEndTime=Math.min(e,1)}}]),e}(),ok=/*#__PURE__*/function(){function e(){this.states=[],this._entryTransitionCollection=new oO,this._anyStateTransitionCollection=new oO,this._statesMap={}}var t=e.prototype;return t.addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new oV(e),this.states.push(t),this._statesMap[e]=t),t},t.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},t.findStateByName=function(e){return this._statesMap[e]},t.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},t.addEntryStateTransition=function(e){return this._entryTransitionCollection.add(e)},t.removeEntryStateTransition=function(e){this._entryTransitionCollection.remove(e)},t.addAnyStateTransition=function(e){return this._anyStateTransitionCollection.add(e)},t.removeAnyStateTransition=function(e){this._anyStateTransitionCollection.remove(e)},t.clearEntryStateTransitions=function(){this._entryTransitionCollection.clear()},t.clearAnyStateTransitions=function(){this._anyStateTransitionCollection.clear()},tG(e,[{key:"entryTransitions",get:function(){return this._entryTransitionCollection.transitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitionCollection.transitions}}]),e}(),oz=function(e){this.name=e,this.weight=1,this.blendingMode=oS.Override,this.stateMachine=new ok},oU=function(){},oG=function(){},oH=/*#__PURE__*/function(){function e(){this._pathMasks=[],this._pathMaskMap={}}var t=e.prototype;return t.addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var n=new oG;return n.path=e,n.active=!0,this._pathMasks.push(n),this._pathMaskMap[e]=n,n},t.removePathMask=function(e){for(var t=this._pathMasks,n=0,r=this._pathMasks.length;n<r;++n)if(t[n].path===e){t.splice(n,1),delete this._pathMaskMap[e];break}},t.getPathMask=function(e){return this._pathMaskMap[e]},t.setPathMaskActive=function(e,t,n){void 0===n&&(n=!1);var r=this._pathMaskMap[e];if(r&&(r.active=t),n)for(var a in this._pathMaskMap)a.startsWith(e)&&(this._pathMaskMap[a].active=t)},e.createByEntity=function(t){var n=new e;return n.addPathMask(""),e._addPathMaskWithChildren(n,t,""),n},e._addPathMaskWithChildren=function(t,n,r){for(var a=n.children,i=0,o=a.length;i<o;++i){var s=a[i],l=r?r+"/"+s.name:s.name;t.addPathMask(l),e._addPathMaskWithChildren(t,s,l)}},tG(e,[{key:"pathMasks",get:function(){return this._pathMasks}}]),e}(),oW=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,ro.find("skybox"))||this)._textureDecodeRGBM=!1,r._tintColor=new tO(1,1,1,1),r.renderState.rasterState.cullMode=nI.Off,r.renderState.depthState.compareFunction=nB.LessEqual,r.shaderData.setFloat(t._rotationProp,0),r.shaderData.setFloat(t._exposureProp,1),r.shaderData.setColor(t._tintColorProp,r._tintColor),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(t._decodeSkyRGBMMacro):this.shaderData.disableMacro(t._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(t._textureCubeProp)},set:function(e){this.shaderData.setTexture(t._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(t._rotationProp)},set:function(e){this.shaderData.setFloat(t._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(t._exposureProp)},set:function(e){this.shaderData.setFloat(t._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),t}(ao);oW._tintColorProp=nY.getByName("material_TintColor"),oW._textureCubeProp=nY.getByName("material_CubeTexture"),oW._rotationProp=nY.getByName("material_Rotation"),oW._exposureProp=nY.getByName("material_Exposure"),oW._decodeSkyRGBMMacro=nH.getByName("MATERIAL_IS_DECODE_SKY_RGBM");var oj=((eG={})[eG.None=0]="None",eG[eG.Simple=1]="Simple",eG[eG.HighQuality=2]="HighQuality",eG),oX=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,ro.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new tO(.5,.5,.5,1),n.groundTint=new tO(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=nI.Off,n.renderState.depthState.compareFunction=nB.LessEqual,n}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var n=this.shaderData;switch(e){case 2:n.disableMacro(t._sunSimpleMacro),n.enableMacro(t._sunHighQualityMacro);break;case 1:n.disableMacro(t._sunHighQualityMacro),n.enableMacro(t._sunSimpleMacro);break;case 0:n.disableMacro(t._sunHighQualityMacro),n.disableMacro(t._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(t._sunSizeProp)},set:function(e){this.shaderData.setFloat(t._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(t._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(t._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(t._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(t._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(t._skyTintProp)},set:function(e){this.shaderData.setColor(t._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(t._groundTintProp)},set:function(e){this.shaderData.setColor(t._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(t._exposureProp)},set:function(e){this.shaderData.setFloat(t._exposureProp,Math.min(Math.max(0,e),8))}}]),t}(ao);oX._sunSizeProp=nY.getByName("material_SunSize"),oX._sunSizeConvergenceProp=nY.getByName("material_SunSizeConvergence"),oX._atmosphereThicknessProp=nY.getByName("material_AtmosphereThickness"),oX._skyTintProp=nY.getByName("material_SkyTint"),oX._groundTintProp=nY.getByName("material_GroundTint"),oX._exposureProp=nY.getByName("material_Exposure"),oX._sunHighQualityMacro=nH.getByName("MATERIAL_SUN_HIGH_QUALITY"),oX._sunSimpleMacro=nH.getByName("MATERIAL_SUN_SIMPLE");var oK=((eH={})[eH.Billboard=0]="Billboard",eH[eH.StretchBillboard=1]="StretchBillboard",eH[eH.HorizontalBillboard=2]="HorizontalBillboard",eH[eH.VerticalBillboard=3]="VerticalBillboard",eH[eH.Mesh=4]="Mesh",eH[eH.None=5]="None",eH),oY=((eW={})[eW.Local=0]="Local",eW[eW.World=1]="World",eW),oq=((ej={})[ej.StopEmittingAndClear=0]="StopEmittingAndClear",ej[ej.StopEmitting=1]="StopEmitting",ej),oQ=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).velocityScale=0,r.lengthScale=2,r.pivot=new tT,r._generatorBounds=new tE,r._transformedBounds=new tE,r._onGeneratorParamsChanged=r._onGeneratorParamsChanged.bind(r),r.generator=new ss(r),r._currentRenderModeMacro=t._billboardModeMacro,r.shaderData.enableMacro(t._billboardModeMacro),r._supportInstancedArrays=r.engine._hardwareRenderer.canIUse(nJ.instancedArrays),r._onGeneratorParamsChanged(),r}tW(t,e);var n=t.prototype;return n._onEnable=function(){this.generator.main.playOnEnabled&&this.generator.play(!1)},n._onDisable=function(){this.generator.stop(!1,oq.StopEmittingAndClear)},n._prepareRender=function(t){this._supportInstancedArrays&&e.prototype._prepareRender.call(this,t)},n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._updateBounds=function(e){var t=this.generator;if(!t.isAlive){var n=this.entity.transform.worldPosition;e.min.copyFrom(n),e.max.copyFrom(n);return}t.main.simulationSpace===oY.Local?t._updateBoundsSimulationLocal(e):(this._isContainDirtyFlag(2)&&(t._generateTransformedBounds(),this._setDirtyFlagFalse(2)),t._updateBoundsSimulationWorld(e))},n._update=function(e){var n=this.generator;if(n._update(this.engine.time.deltaTime),n._firstActiveElement!==n._firstFreeElement){var r=this.shaderData;r.setFloat(t._lengthScale,this.lengthScale),r.setFloat(t._speedScale,this.velocityScale),r.setFloat(t._currentTime,this.generator._playTime),r.setVector3(t._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(r)}},n._render=function(e){var t=this.generator,n=t._getAliveParticleCount();if(n){t._primitive.instanceCount=n;var r=this.getMaterial();if(r){(r.destroyed||r.shader.destroyed)&&(r=this.engine._particleMagentaMaterial);var a=this._engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get();o.set(this,r,t._primitive,t._subPrimitive),i.addSubRenderElement(o),e.camera._renderPipeline.pushRenderElement(e,i)}}},n._onDestroy=function(){var t=this._mesh;t&&(t.destroyed||this._addResourceReferCount(t,-1)),e.prototype._onDestroy.call(this),this.generator._destroy()},n._isContainDirtyFlag=function(e){return(this._dirtyUpdateFlag&e)!=0},n._setDirtyFlagFalse=function(e){this._dirtyUpdateFlag&=~e},n._onWorldVolumeChanged=function(){this._dirtyUpdateFlag|=rv.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|rv.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|rv.WorldVolume},tG(t,[{key:"renderMode",get:function(){return this._renderMode},set:function(e){if(this._renderMode!==e){var n=this._renderMode;this._renderMode=e;var r=null,a=this.shaderData;switch(e){case oK.Billboard:r=t._billboardModeMacro;break;case oK.StretchBillboard:r=t._stretchedBillboardModeMacro;break;case oK.HorizontalBillboard:case oK.VerticalBillboard:case oK.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==r&&(this._currentRenderModeMacro&&a.disableMacro(this._currentRenderModeMacro),r&&a.enableMacro(r),this._currentRenderModeMacro=r),n!==oK.Mesh!=(e===oK.Mesh)&&this.generator._reorganizeGeometryBuffers()}}},{key:"mesh",get:function(){return this._mesh},set:function(e){var t=this._mesh;t!==e&&(this._mesh=e,t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this.renderMode===oK.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),t}(e.Renderer);oQ._billboardModeMacro=nH.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),oQ._stretchedBillboardModeMacro=nH.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),oQ._horizontalBillboardModeMacro=nH.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),oQ._verticalBillboardModeMacro=nH.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),oQ._renderModeMeshMacro=nH.getByName("RENDERER_MODE_MESH"),oQ._pivotOffsetProperty=nY.getByName("renderer_PivotOffset"),oQ._lengthScale=nY.getByName("renderer_StretchedBillboardLengthScale"),oQ._speedScale=nY.getByName("renderer_StretchedBillboardSpeedScale"),oQ._currentTime=nY.getByName("renderer_CurrentTime"),tX([tZ],oQ.prototype,"generator",void 0),tX([tJ],oQ.prototype,"pivot",void 0),tX([tq],oQ.prototype,"_generatorBounds",void 0),tX([tq],oQ.prototype,"_transformedBounds",void 0),tX([tq],oQ.prototype,"_onGeneratorParamsChanged",null);var oJ=((eX={})[eX.TransformVolume=2]="TransformVolume",eX[eX.GeneratorVolume=4]="GeneratorVolume",eX),oZ=((eK={})[eK.Constant=0]="Constant",eK[eK.TwoConstants=1]="TwoConstants",eK[eK.Curve=2]="Curve",eK[eK.TwoCurves=3]="TwoCurves",eK),o$=((eY={})[eY.Constant=0]="Constant",eY[eY.TwoConstants=1]="TwoConstants",eY[eY.Gradient=2]="Gradient",eY[eY.TwoGradients=3]="TwoGradients",eY),o0=((eq={})[eq.Burst=0x23571a3e]="Burst",eq[eq.StartDelay=0x13371337]="StartDelay",eq[eq.StartColor=0x12460f3b]="StartColor",eq[eq.StartSize=0x6aed452e]="StartSize",eq[eq.StartRotation=0xdec4aea1]="StartRotation",eq[eq.randomizeRotationDirection=0x96aa4de3]="randomizeRotationDirection",eq[eq.StartLifetime=0x8d2c8431]="StartLifetime",eq[eq.StartSpeed=0xf3857f6f]="StartSpeed",eq[eq.VelocityOverLifetime=0xe0fbd834]="VelocityOverLifetime",eq[eq.ColorOverLifetime=0x13740583]="ColorOverLifetime",eq[eq.SizeOverLifetime=0x591bc05c]="SizeOverLifetime",eq[eq.RotationOverLifetime=0x40eb95e4]="RotationOverLifetime",eq[eq.TextureSheetAnimation=0xbc524e5]="TextureSheetAnimation",eq[eq.Shape=0xaf502044]="Shape",eq[eq.GravityModifier=0xa47b8c4d]="GravityModifier",eq),o1=/*#__PURE__*/function(){function e(e,t){if(void 0===e&&(e=null),void 0===t&&(t=null),this._colorKeys=[],this._alphaKeys=[],this._colorTypeArrayDirty=!1,this._alphaTypeArrayDirty=!1,e)for(var n=0,r=e.length;n<r;n++){var a=e[n];this.addColorKey(a)}if(t)for(var i=0,o=t.length;i<o;i++){var s=t[i];this.addAlphaKey(s)}}var t=e.prototype;return t.addColorKey=function(e,t){var n=this._colorKeys;if(4===n.length)throw Error("Gradient can only have 4 color keys");var r="number"==typeof e?new o2(e,t):e;r._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(n,r),this._colorTypeArrayDirty=!0},t.addAlphaKey=function(e,t){var n=this._alphaKeys;if(4===n.length)throw Error("Gradient can only have 4 alpha keys");var r="number"==typeof e?new o3(e,t):e;r._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(n,r),this._alphaTypeArrayDirty=!0},t.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},t.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},t.setKeys=function(e,t){for(var n=this._colorKeys,r=this._alphaKeys,a=0,i=n.length;a<i;a++)n[a]._onValueChanged=null;for(var o=0,s=r.length;o<s;o++)r[o]._onValueChanged=null;n.length=0,r.length=0;for(var l=0,c=e.length;l<c;l++)this._addKey(n,e[l]);for(var u=0,d=t.length;u<d;u++)this._addKey(r,t[u]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},t._getColorTypeArray=function(e){var t=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,r=0,a=Math.min(n.length,4);r<a;r++){var i=4*r,o=n[r];t[i]=o.time;var s=o.color;e===n2.Linear?(t[i+1]=tO.gammaToLinearSpace(s.r),t[i+2]=tO.gammaToLinearSpace(s.g),t[i+3]=tO.gammaToLinearSpace(s.b)):(t[i+1]=s.r,t[i+2]=s.g,t[i+3]=s.b)}this._colorTypeArrayDirty=!1}return t},t._getAlphaTypeArray=function(){var e=this._alphaTypeArray||(this._alphaTypeArray=new Float32Array(8));if(this._alphaTypeArrayDirty){for(var t=this._alphaKeys,n=0,r=Math.min(t.length,4);n<r;n++){var a=2*n,i=t[n];e[a]=i.time,e[a+1]=i.alpha}this._alphaTypeArrayDirty=!1}return e},t._addKey=function(e,t){var n=t.time,r=e.length;if(n>=(r?e[r-1].time:0))e.push(t);else{for(var a=r;--a>=0&&n<e[a].time;);e.splice(a+1,0,t)}},t._removeKey=function(e,t){e.splice(t,1)},t._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},t._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},tG(e,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),e}();tX([tZ],o1.prototype,"_colorKeys",void 0),tX([tZ],o1.prototype,"_alphaKeys",void 0),tX([tq],o1.prototype,"_colorTypeArray",void 0),tX([tq],o1.prototype,"_alphaTypeArray",void 0),tX([tq],o1.prototype,"_setColorTypeArrayDirty",null),tX([tq],o1.prototype,"_setAlphaTypeArrayDirty",null);var o2=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._color=new tO,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged}return tG(e,[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}}]),e}(),o3=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._time=e,this._alpha=t}return tG(e,[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"alpha",get:function(){return this._alpha},set:function(e){this._alpha=e,this._onValueChanged&&this._onValueChanged()}}]),e}(),o4=/*#__PURE__*/function(){function e(e,t){this.mode=o$.Constant,this.constantMin=new tO,this.constantMax=new tO,this.gradientMin=new o1,this.gradientMax=new o1,e.constructor===tO?t?(this.constantMin.copyFrom(e),this.constantMax.copyFrom(t),this.mode=o$.TwoConstants):(this.constant.copyFrom(e),this.mode=o$.Constant):t?(this.gradientMin=e,this.gradientMax=t,this.mode=o$.TwoGradients):(this.gradient=e,this.mode=o$.Gradient)}return e.prototype.evaluate=function(e,t,n){switch(this.mode){case o$.Constant:n.copyFrom(this.constant);break;case o$.TwoConstants:tO.lerp(this.constantMin,this.constantMax,t,n)}},tG(e,[{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"gradient",get:function(){return this.gradientMax},set:function(e){this.gradientMax=e}}]),e}();tX([tZ],o4.prototype,"constantMin",void 0),tX([tZ],o4.prototype,"constantMax",void 0),tX([tZ],o4.prototype,"gradientMin",void 0),tX([tZ],o4.prototype,"gradientMax",void 0);var o8=/*#__PURE__*/function(){function e(e){this._enabled=!1,this._generator=e}return e.prototype._enableMacro=function(e,t,n){return t!==n&&(t&&e.disableMacro(t),n&&e.enableMacro(n)),n},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),e}();tX([tq],o8.prototype,"_generator",void 0);var o5=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.color=new o4(new o1([new o2(0,new tO(1,1,1)),new o2(1,new tO(1,1,1))],[new o3(0,1),new o3(1,1)])),t._colorGradientRand=new tk(0,o0.ColorOverLifetime),t._gradientKeysCount=new tI(0,0,0,0),t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.color.mode;if(r!==o$.Gradient&&r!==o$.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var a=this.color,i=this._generator._renderer.engine.settings.colorSpace;e.setFloatArray(t._maxGradientColor,a.gradientMax._getColorTypeArray(i)),e.setFloatArray(t._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),r===o$.Gradient?n=t._gradientMacro:(e.setFloatArray(t._minGradientColor,a.gradientMin._getColorTypeArray(i)),e.setFloatArray(t._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),n=t._randomGradientsMacro);var o=a.gradientMin.colorKeys,s=a.gradientMin.alphaKeys,l=a.gradientMax.colorKeys,c=a.gradientMax.alphaKeys;this._gradientKeysCount.set(o.length?o[o.length-1].time:0,s.length?s[s.length-1].time:0,l.length?l[l.length-1].time:0,c.length?c[c.length-1].time:0),e.setVector4(t._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(e,this._colorMacro,n)},n._resetRandomSeed=function(e){this._colorGradientRand.reset(e,o0.ColorOverLifetime)},t}(o8);o5._gradientMacro=nH.getByName("RENDERER_COL_GRADIENT"),o5._randomGradientsMacro=nH.getByName("RENDERER_COL_RANDOM_GRADIENTS"),o5._minGradientColor=nY.getByName("renderer_COLMinGradientColor"),o5._minGradientAlpha=nY.getByName("renderer_COLMinGradientAlpha"),o5._maxGradientColor=nY.getByName("renderer_COLMaxGradientColor"),o5._maxGradientAlpha=nY.getByName("renderer_COLMaxGradientAlpha"),o5._gradientKeysCount=nY.getByName("renderer_COLGradientKeysMaxTime"),tX([tZ],o5.prototype,"color",void 0),tX([tq],o5.prototype,"_colorGradientRand",void 0),tX([tq],o5.prototype,"_gradientKeysCount",void 0),tX([tq],o5.prototype,"_colorMacro",void 0);var o9=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nM,this._mode=oZ.Constant,this._constantMin=0,this._constantMax=0,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager),"number"==typeof e?t?(this.constantMin=e,this.constantMax=t,this.mode=oZ.TwoConstants):(this.constant=e,this.mode=oZ.Constant):t?(this.curveMin=e,this.curveMax=t,this.mode=oZ.TwoCurves):(this.curve=e,this.mode=oZ.Curve)}var t=e.prototype;return t.evaluate=function(e,t){switch(this.mode){case oZ.Constant:return this.constant;case oZ.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*t}},t._getMax=function(){switch(this.mode){case oZ.Constant:return this.constantMax;case oZ.TwoConstants:return Math.max(this.constantMin,this.constantMax);case oZ.Curve:var e;return this._getMaxKeyValue(null==(e=this.curveMax)?void 0:e.keys);case oZ.TwoCurves:var t,n,r=this._getMaxKeyValue(null==(t=this.curveMin)?void 0:t.keys),a=this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys);return r>a?r:a}},t._getMinMax=function(e){switch(this.mode){case oZ.Constant:e.x=e.y=this.constantMax;break;case oZ.TwoConstants:e.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case oZ.Curve:var t,n;e.set(this._getMinKeyValue(null==(t=this.curveMax)?void 0:t.keys),this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys));break;case oZ.TwoCurves:var r,a,i,o,s=this._getMinKeyValue(null==(r=this.curveMax)?void 0:r.keys),l=this._getMinKeyValue(null==(a=this.curveMin)?void 0:a.keys),c=this._getMaxKeyValue(null==(i=this.curveMax)?void 0:i.keys),u=this._getMaxKeyValue(null==(o=this.curveMin)?void 0:o.keys);e.set(s<l?s:l,c>u?c:u)}},t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},t._getMaxKeyValue=function(e){var t,n=void 0,r=null!=(t=null==e?void 0:e.length)?t:0;if(r>0){n=e[0].value;for(var a=1;a<r;a++)n=Math.max(n,e[a].value)}return n},t._getMinKeyValue=function(e){var t,n=void 0,r=null!=(t=null==e?void 0:e.length)?t:0;if(r>0){n=e[0].value;for(var a=1;a<r;a++)n=Math.min(n,e[a].value)}return n},t._onCurveChange=function(e,t){var n=this._updateDispatch;null==e||e._unRegisterOnValueChanged(n),null==t||t._registerOnValueChanged(n),n()},tG(e,[{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._updateDispatch())}},{key:"constantMin",get:function(){return this._constantMin},set:function(e){e!==this._constantMin&&(this._constantMin=e,this._updateDispatch())}},{key:"constantMax",get:function(){return this._constantMax},set:function(e){e!==this._constantMax&&(this._constantMax=e,this._updateDispatch())}},{key:"curveMin",get:function(){return this._curveMin},set:function(e){var t=this._curveMin;e!==t&&(this._curveMin=e,this._onCurveChange(t,e))}},{key:"curveMax",get:function(){return this._curveMax},set:function(e){var t=this._curveMax;e!==t&&(this._curveMax=e,this._onCurveChange(t,e))}},{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"curve",get:function(){return this.curveMax},set:function(e){this.curveMax=e}}]),e}();tX([tq],o9.prototype,"_updateManager",void 0),tX([tZ],o9.prototype,"_curveMin",void 0),tX([tZ],o9.prototype,"_curveMax",void 0),tX([tq],o9.prototype,"_updateDispatch",void 0);var o6=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.rateOverTime=new o9(10),t.rateOverDistance=new o9(0),t._shapeRand=new tk(0,o0.Shape),t._frameRateTime=0,t._bursts=[],t._currentBurstIndex=0,t._burstRand=new tk(0,o0.Burst),t}tW(t,e);var n=t.prototype;return n.addBurst=function(e){for(var t=this._bursts,n=t.length;--n>=0&&e.time<t[n].time;);t.splice(n+1,0,e)},n.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},n.removeBurstByIndex=function(e){this._bursts.splice(e,1)},n.clearBurst=function(){this._bursts.length=0},n._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},n._resetRandomSeed=function(e){this._burstRand.reset(e,o0.Burst),this._shapeRand.reset(e,o0.Shape)},n._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},n._destroy=function(){var e;null==(e=this._shape)||e._unRegisterOnValueChanged(this._generator._renderer._onGeneratorParamsChanged)},n._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var n=this._generator,r=1/t,a=e-this._frameRateTime;a>=r;)a-=r,this._frameRateTime+=r,n._emit(this._frameRateTime,1)},n._emitByBurst=function(e,t){var n=this._generator.main,r=n.duration,a=Math.floor((t-e)/r);if(n.isLoop&&(a>0||t%r<e%r)){var i=Math.ceil(e/r)*r;this._emitBySubBurst(e,i,r),this._currentBurstIndex=0;for(var o=0;o<a;o++){var s=i;i+=r,this._emitBySubBurst(s,i,r),this._currentBurstIndex=0}this._emitBySubBurst(i,t,r)}else this._emitBySubBurst(e,t,r)},n._emitBySubBurst=function(e,t,n){for(var r=this._generator,a=this._burstRand,i=this.bursts,o=Math.floor(e/n)*n,s=e%n,l=s+(t-e),c=this._currentBurstIndex,u=i.length;c<u;c++){var d=i[c],h=d.time;if(h>l)break;if(h>=s){var _=d.count.evaluate(void 0,a.random());r._emit(o+h,_)}}this._currentBurstIndex=c},tG(t,[{key:"shape",get:function(){return this._shape},set:function(e){var t=this._shape;if(e!==t){this._shape=e;var n=this._generator._renderer;null==t||t._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==e||e._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()}}},{key:"bursts",get:function(){return this._bursts}}]),t}(o8);tX([tZ],o6.prototype,"rateOverTime",void 0),tX([tZ],o6.prototype,"rateOverDistance",void 0),tX([tZ],o6.prototype,"_shape",void 0),tX([tq],o6.prototype,"_shapeRand",void 0),tX([tZ],o6.prototype,"_bursts",void 0),tX([tq],o6.prototype,"_burstRand",void 0);var o7=((eQ={})[eQ.Hierarchy=0]="Hierarchy",eQ[eQ.Local=1]="Local",eQ[eQ.World=2]="World",eQ),se=/*#__PURE__*/function(){function e(e){this._tempVector40=new tI,this.duration=5,this.isLoop=!0,this.startDelay=new o9(0),this.startRotation3D=!1,this.startRotationX=new o9(0),this.startRotationY=new o9(0),this.startRotationZ=new o9(0),this.flipRotation=0,this.startColor=new o4(new tO(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=o7.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startDelayRand=new tk(0,o0.StartDelay),this._startSpeedRand=new tk(0,o0.StartSpeed),this._startLifeTimeRand=new tk(0,o0.StartLifetime),this._startColorRand=new tk(0,o0.StartColor),this._startSizeRand=new tk(0,o0.StartSize),this._startRotationRand=new tk(0,o0.StartRotation),this._gravityModifierRand=new tk(0,o0.GravityModifier),this._startSize3D=!1,this._simulationSpace=oY.Local,this._generator=e,this.startLifetime=new o9(5),this.startSpeed=new o9(5),this.startSizeX=new o9(1),this.startSizeY=new o9(1),this.startSizeZ=new o9(1),this.gravityModifier=new o9(0)}var t=e.prototype;return t._resetRandomSeed=function(e){this._startSpeedRand.reset(e,o0.StartSpeed),this._startLifeTimeRand.reset(e,o0.StartLifetime),this._startColorRand.reset(e,o0.StartColor),this._startSizeRand.reset(e,o0.StartSize),this._startRotationRand.reset(e,o0.StartRotation)},t._getPositionScale=function(){var e=this._generator._renderer.entity.transform;switch(this.scalingMode){case o7.Hierarchy:case o7.World:return e.lossyWorldScale;case o7.Local:return e.scale}},t._updateShaderData=function(t){var n=this._generator._renderer,r=n.entity.transform;switch(this.simulationSpace){case oY.Local:t.setVector3(e._worldPosition,r.worldPosition);var a=r.worldRotationQuaternion,i=this._tempVector40.copyFrom(a);t.setVector4(e._worldRotation,i);break;case oY.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case o7.Hierarchy:var o=r.lossyWorldScale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case o7.Local:var o=r.scale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case o7.World:t.setVector3(e._positionScale,r.lossyWorldScale),t.setVector3(e._sizeScale,e._vector3One)}t.setVector3(e._gravity,n.scene.physics.gravity),t.setInt(e._simulationSpace,this.simulationSpace),t.setFloat(e._startRotation3D,+this.startRotation3D),t.setInt(e._scaleMode,this.scalingMode)},t._cloneTo=function(e){e.maxParticles=this.maxParticles,e._simulationSpace===oY.World&&e._generator._generateTransformedBounds()},t._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(e,[{key:"startLifetime",get:function(){return this._startLifetime},set:function(e){var t=this._startLifetime;e!==t&&(this._startLifetime=e,this._onCompositeCurveChange(t,e))}},{key:"startSpeed",get:function(){return this._startSpeed},set:function(e){var t=this._startSpeed;e!==t&&(this._startSpeed=e,this._onCompositeCurveChange(t,e))}},{key:"startSize3D",get:function(){return this._startSize3D},set:function(e){e!==this._startSize3D&&(this._startSize3D=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"startSizeX",get:function(){return this._startSizeX},set:function(e){var t=this._startSizeX;e!==t&&(this._startSizeX=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeY",get:function(){return this._startSizeY},set:function(e){var t=this._startSizeY;e!==t&&(this._startSizeY=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeZ",get:function(){return this._startSizeZ},set:function(e){var t=this._startSizeZ;e!==t&&(this._startSizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"gravityModifier",get:function(){return this._gravityModifier},set:function(e){var t=this._gravityModifier;e!==t&&(this._gravityModifier=e,this._onCompositeCurveChange(t,e))}},{key:"simulationSpace",get:function(){return this._simulationSpace},set:function(e){if(e!==this._simulationSpace){this._simulationSpace=e;var t=this._generator;t._renderer._onTransformChanged(rm.WorldMatrix),e===oY.Local&&t._freeBoundsArray()}}},{key:"maxParticles",get:function(){return this._maxParticleBuffer-1},set:function(e){this._maxParticleBuffer=e+1}},{key:"startSize",get:function(){return this.startSizeX},set:function(e){this.startSizeX=e}}]),e}();se._vector3One=new tT(1,1,1),se._positionScale=nY.getByName("renderer_PositionScale"),se._sizeScale=nY.getByName("renderer_SizeScale"),se._worldPosition=nY.getByName("renderer_WorldPosition"),se._worldRotation=nY.getByName("renderer_WorldRotation"),se._gravity=nY.getByName("renderer_Gravity"),se._simulationSpace=nY.getByName("renderer_SimulationSpace"),se._startRotation3D=nY.getByName("renderer_ThreeDStartRotation"),se._scaleMode=nY.getByName("renderer_ScalingMode"),tX([tZ],se.prototype,"startDelay",void 0),tX([tZ],se.prototype,"startRotationX",void 0),tX([tZ],se.prototype,"startRotationY",void 0),tX([tZ],se.prototype,"startRotationZ",void 0),tX([tZ],se.prototype,"startColor",void 0),tX([tq],se.prototype,"_maxParticleBuffer",void 0),tX([tq],se.prototype,"_startDelayRand",void 0),tX([tq],se.prototype,"_startSpeedRand",void 0),tX([tq],se.prototype,"_startLifeTimeRand",void 0),tX([tq],se.prototype,"_startColorRand",void 0),tX([tq],se.prototype,"_startSizeRand",void 0),tX([tq],se.prototype,"_startRotationRand",void 0),tX([tq],se.prototype,"_gravityModifierRand",void 0),tX([tZ],se.prototype,"_startLifetime",void 0),tX([tZ],se.prototype,"_startSpeed",void 0),tX([tZ],se.prototype,"_startSizeX",void 0),tX([tZ],se.prototype,"_startSizeY",void 0),tX([tZ],se.prototype,"_startSizeZ",void 0),tX([tZ],se.prototype,"_gravityModifier",void 0),tX([tq],se.prototype,"_generator",void 0);var st=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new o9(0),t.rotationY=new o9(0),t.rotationZ=new o9(45),t._rotationRand=new tk(0,o0.RotationOverLifetime),t._rotationMinConstant=new tT,t._rotationMaxConstant=new tT,t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,a=null;if(this.enabled){var i=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?i.mode===oZ.TwoCurves&&o.mode===oZ.TwoCurves&&s.mode===oZ.TwoCurves:s.mode===oZ.TwoCurves;if(c||l?i.mode===oZ.Curve&&o.mode===oZ.Curve&&s.mode===oZ.Curve:s.mode===oZ.Curve)e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveXProperty,i.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveXProperty,i.curveMin._getTypeArray()),e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray())),a=t._isRandomTwoMacro),r=t._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(tS.degreeToRadian(i.constantMax),tS.degreeToRadian(o.constantMax),tS.degreeToRadian(s.constantMax)),e.setVector3(t._maxConstantProperty,u),l?i.mode===oZ.TwoConstants&&o.mode===oZ.TwoConstants&&s.mode===oZ.TwoConstants:s.mode===oZ.TwoConstants){var d=this._rotationMinConstant;d.set(tS.degreeToRadian(i.constantMin),tS.degreeToRadian(o.constantMin),tS.degreeToRadian(s.constantMin)),e.setVector3(t._minConstantProperty,d),a=t._isRandomTwoMacro}r=t._constantModeMacro}l&&(n=t._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,n),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,a)},n._resetRandomSeed=function(e){this._rotationRand.reset(e,o0.RotationOverLifetime)},t}(o8);st._constantModeMacro=nH.getByName("RENDERER_ROL_CONSTANT_MODE"),st._curveModeMacro=nH.getByName("RENDERER_ROL_CURVE_MODE"),st._isSeparateMacro=nH.getByName("RENDERER_ROL_IS_SEPARATE"),st._isRandomTwoMacro=nH.getByName("RENDERER_ROL_IS_RANDOM_TWO"),st._minConstantProperty=nY.getByName("renderer_ROLMinConst"),st._minCurveXProperty=nY.getByName("renderer_ROLMinCurveX"),st._minCurveYProperty=nY.getByName("renderer_ROLMinCurveY"),st._minCurveZProperty=nY.getByName("renderer_ROLMinCurveZ"),st._maxConstantProperty=nY.getByName("renderer_ROLMaxConst"),st._maxCurveXProperty=nY.getByName("renderer_ROLMaxCurveX"),st._maxCurveYProperty=nY.getByName("renderer_ROLMaxCurveY"),st._maxCurveZProperty=nY.getByName("renderer_ROLMaxCurveZ"),tX([tZ],st.prototype,"rotationX",void 0),tX([tZ],st.prototype,"rotationY",void 0),tX([tZ],st.prototype,"rotationZ",void 0),tX([tq],st.prototype,"_rotationRand",void 0),tX([tq],st.prototype,"_rotationMinConstant",void 0),tX([tq],st.prototype,"_rotationMaxConstant",void 0),tX([tq],st.prototype,"_enableSeparateMacro",void 0),tX([tq],st.prototype,"_isCurveMacro",void 0),tX([tq],st.prototype,"_isRandomTwoMacro",void 0);var sn=/*#__PURE__*/function(){function e(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._updateManager=new nM,this._keys=[],this._typeArrayDirty=!1,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager);for(var r=0,a=t.length;r<a;r++){var i=t[r];this.addKey(i)}}var t=e.prototype;return t.addKey=function(e,t){var n=this._keys;if(4===n.length)throw Error("Curve can only have 4 keys");var r="number"==typeof e?new sr(e,t):e;this._addKey(n,r),r._registerOnValueChanged(this._updateDispatch),this._updateDispatch(),this._typeArrayDirty=!0},t.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0,this._keys[e]._unRegisterOnValueChanged(this._updateDispatch),this._updateDispatch()},t.setKeys=function(e){this._keys.length=0;for(var t=0,n=e.length;t<n;t++)this.addKey(e[t]);this._typeArrayDirty=!0},t._getTypeArray=function(){var e=this._typeArray||(this._typeArray=new Float32Array(8));if(this._typeArrayDirty){for(var t=this._keys,n=0,r=Math.min(t.length,4);n<r;n++){var a=2*n,i=t[n];e[a]=i.time,e[a+1]=i.value}this._typeArrayDirty=!1}return e},t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},t._addKey=function(e,t){var n=e.length,r=t.time;if(r>=(n?e[n-1].time:0))e.push(t);else{for(var a=n;--a>=0&&r<e[a].time;);e.splice(a+1,0,t)}},tG(e,[{key:"keys",get:function(){return this._keys}}]),e}();tX([tq],sn.prototype,"_updateManager",void 0),tX([tZ],sn.prototype,"_keys",void 0),tX([tq],sn.prototype,"_typeArray",void 0),tX([tq],sn.prototype,"_updateDispatch",void 0);var sr=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nM,this._time=e,this._value=t}var t=e.prototype;return t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},tG(e,[{key:"time",get:function(){return this._time},set:function(e){e!==this._time&&(this._time=e,this._updateManager.dispatch())}},{key:"value",get:function(){return this._value},set:function(e){e!==this._value&&(this._value=e,this._updateManager.dispatch())}}]),e}();tX([tq],sr.prototype,"_updateManager",void 0);var sa=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._separateAxes=!1,n.sizeX=new o9(new sn(new sr(0,0),new sr(1,1))),n.sizeY=new o9(new sn(new sr(0,0),new sr(1,1))),n.sizeZ=new o9(new sn(new sr(0,0),new sr(1,1))),n}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,a=null;if(this.enabled){var i=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?i.mode===oZ.TwoCurves&&o.mode===oZ.TwoCurves&&s.mode===oZ.TwoCurves:i.mode===oZ.TwoCurves;(c||l?i.mode===oZ.Curve&&o.mode===oZ.Curve&&s.mode===oZ.Curve:i.mode===oZ.Curve)&&(e.setFloatArray(t._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveXProperty,i.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray()),e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray())),a=t._isRandomTwoMacro),r=t._curveModeMacro),l&&(n=t._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,n),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,a)},n._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(t,[{key:"separateAxes",get:function(){return this._separateAxes},set:function(e){e!==this._separateAxes&&(this._separateAxes=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"sizeX",get:function(){return this._sizeX},set:function(e){var t=this._sizeX;e!==t&&(this._sizeX=e,this._onCompositeCurveChange(t,e))}},{key:"sizeY",get:function(){return this._sizeY},set:function(e){var t=this._sizeY;e!==t&&(this._sizeY=e,this._onCompositeCurveChange(t,e))}},{key:"sizeZ",get:function(){return this._sizeZ},set:function(e){var t=this._sizeZ;e!==t&&(this._sizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),t}(o8);sa._curveModeMacro=nH.getByName("RENDERER_SOL_CURVE_MODE"),sa._isSeparateMacro=nH.getByName("RENDERER_SOL_IS_SEPARATE"),sa._isRandomTwoMacro=nH.getByName("RENDERER_SOL_IS_RANDOM_TWO"),sa._minCurveXProperty=nY.getByName("renderer_SOLMinCurveX"),sa._minCurveYProperty=nY.getByName("renderer_SOLMinCurveY"),sa._minCurveZProperty=nY.getByName("renderer_SOLMinCurveZ"),sa._maxCurveXProperty=nY.getByName("renderer_SOLMaxCurveX"),sa._maxCurveYProperty=nY.getByName("renderer_SOLMaxCurveY"),sa._maxCurveZProperty=nY.getByName("renderer_SOLMaxCurveZ"),tX([tZ],sa.prototype,"_sizeX",void 0),tX([tZ],sa.prototype,"_sizeY",void 0),tX([tZ],sa.prototype,"_sizeZ",void 0),tX([tq],sa.prototype,"_enableSeparateMacro",void 0),tX([tq],sa.prototype,"_isCurveMacro",void 0),tX([tq],sa.prototype,"_isRandomTwoMacro",void 0);var si=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.frameOverTime=new o9(new sn(new sr(0,0),new sr(1,1))),t.type=0,t.cycleCount=1,t._tillingInfo=new tT(1,1,1),t._frameOverTimeRand=new tk(0,o0.TextureSheetAnimation),t._tiling=new tB(1,1),t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.frameOverTime.mode;if(r===oZ.Curve||r===oZ.TwoCurves){var a=this.frameOverTime;e.setFloatArray(t._frameMaxCurveProperty,a.curveMax._getTypeArray()),r===oZ.Curve?n=t._frameCurveMacro:(e.setFloatArray(t._frameMinCurveProperty,a.curveMin._getTypeArray()),n=t._frameRandomCurvesMacro),e.setFloat(t._cycleCountProperty,this.cycleCount),e.setVector3(t._tillingParamsProperty,this._tillingInfo)}}this._frameCurveMacro=this._enableMacro(e,this._frameCurveMacro,n)},n._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,o0.TextureSheetAnimation)},tG(t,[{key:"tiling",get:function(){return this._tiling},set:function(e){this._tiling=e,this._tillingInfo.set(1/e.x,1/e.y,e.x*e.y)}}]),t}(o8);si._frameCurveMacro=nH.getByName("RENDERER_TSA_FRAME_CURVE"),si._frameRandomCurvesMacro=nH.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),si._frameMinCurveProperty=nY.getByName("renderer_TSAFrameMinCurve"),si._frameMaxCurveProperty=nY.getByName("renderer_TSAFrameMaxCurve"),si._cycleCountProperty=nY.getByName("renderer_TSACycles"),si._tillingParamsProperty=nY.getByName("renderer_TSATillingParams"),tX([tZ],si.prototype,"frameOverTime",void 0),tX([tJ],si.prototype,"_tillingInfo",void 0),tX([tq],si.prototype,"_frameOverTimeRand",void 0),tX([tZ],si.prototype,"_tiling",void 0),tX([tq],si.prototype,"_frameCurveMacro",void 0);var so=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._velocityRand=new tk(0,o0.VelocityOverLifetime),n._velocityMinConstant=new tT,n._velocityMaxConstant=new tT,n._space=oY.Local,n.velocityX=new o9(0),n.velocityY=new o9(0),n.velocityZ=new o9(0),n}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.velocityX,a=this.velocityY,i=this.velocityZ,o=r.mode===oZ.TwoCurves&&a.mode===oZ.TwoCurves&&i.mode===oZ.TwoCurves;if(o||r.mode===oZ.Curve&&a.mode===oZ.Curve&&i.mode===oZ.Curve)e.setFloatArray(t._maxGradientXProperty,r.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientYProperty,a.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientZProperty,i.curveMax._getTypeArray()),o?(e.setFloatArray(t._minGradientXProperty,r.curveMin._getTypeArray()),e.setFloatArray(t._minGradientYProperty,a.curveMin._getTypeArray()),e.setFloatArray(t._minGradientZProperty,i.curveMin._getTypeArray()),n=t._randomCurveMacro):n=t._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(r.constantMax,a.constantMax,i.constantMax),e.setVector3(t._maxConstantProperty,s),r.mode===oZ.TwoConstants&&a.mode===oZ.TwoConstants&&i.mode===oZ.TwoConstants){var l=this._velocityMinConstant;l.set(r.constantMin,a.constantMin,i.constantMin),e.setVector3(t._minConstantProperty,l),n=t._randomConstantMacro}else n=t._constantMacro}e.setInt(t._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(e,this._velocityMacro,n)},n._resetRandomSeed=function(e){this._velocityRand.reset(e,o0.VelocityOverLifetime)},n._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(t,[{key:"velocityX",get:function(){return this._velocityX},set:function(e){var t=this._velocityX;e!==t&&(this._velocityX=e,this._onCompositeCurveChange(t,e))}},{key:"velocityY",get:function(){return this._velocityY},set:function(e){var t=this._velocityY;e!==t&&(this._velocityY=e,this._onCompositeCurveChange(t,e))}},{key:"velocityZ",get:function(){return this._velocityZ},set:function(e){var t=this._velocityZ;e!==t&&(this._velocityZ=e,this._onCompositeCurveChange(t,e))}},{key:"space",get:function(){return this._space},set:function(e){e!==this._space&&(this._space=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._generator._renderer._onGeneratorParamsChanged())}}]),t}(o8);so._constantMacro=nH.getByName("RENDERER_VOL_CONSTANT"),so._curveMacro=nH.getByName("RENDERER_VOL_CURVE"),so._randomConstantMacro=nH.getByName("RENDERER_VOL_RANDOM_CONSTANT"),so._randomCurveMacro=nH.getByName("RENDERER_VOL_RANDOM_CURVE"),so._minConstantProperty=nY.getByName("renderer_VOLMinConst"),so._maxConstantProperty=nY.getByName("renderer_VOLMaxConst"),so._minGradientXProperty=nY.getByName("renderer_VOLMinGradientX"),so._minGradientYProperty=nY.getByName("renderer_VOLMinGradientY"),so._minGradientZProperty=nY.getByName("renderer_VOLMinGradientZ"),so._maxGradientXProperty=nY.getByName("renderer_VOLMaxGradientX"),so._maxGradientYProperty=nY.getByName("renderer_VOLMaxGradientY"),so._maxGradientZProperty=nY.getByName("renderer_VOLMaxGradientZ"),so._spaceProperty=nY.getByName("renderer_VOLSpace"),tX([tq],so.prototype,"_velocityRand",void 0),tX([tq],so.prototype,"_velocityMinConstant",void 0),tX([tq],so.prototype,"_velocityMaxConstant",void 0),tX([tq],so.prototype,"_velocityMacro",void 0),tX([tZ],so.prototype,"_velocityX",void 0),tX([tZ],so.prototype,"_velocityY",void 0),tX([tZ],so.prototype,"_velocityZ",void 0);var ss=/*#__PURE__*/function(){function e(t){this.useAutoRandomSeed=!0,this.emission=new o6(this),this.rotationOverLifetime=new st(this),this.colorOverLifetime=new o5(this),this.textureSheetAnimation=new si(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new ay(0,0,ar.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0,this._playStartDelay=0,this._renderer=t,new av().start=0,this._primitive=new ax(t.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,e._particleIncreaseCount),this.main=new se(this),this.velocityOverLifetime=new so(this),this.sizeOverLifetime=new sa(this),this.emission.enabled=!0}var t=e.prototype;return t.play=function(t){if(void 0===t&&(t=!0),t)for(var n=this._renderer.entity.getComponentsIncludeChildren(oQ,e._tempParticleRenderers),r=0,a=n.length;r<a;r++)n[r].generator.play(!1);else this._isPlaying=!0,this.useAutoRandomSeed&&this._resetGlobalRandSeed(Math.floor(0xffffffff*Math.random())),this._playStartDelay=this.main.startDelay.evaluate(void 0,this.main._startDelayRand.random())},t.stop=function(t,n){if(void 0===t&&(t=!0),void 0===n&&(n=oq.StopEmitting),t)for(var r=this._renderer.entity.getComponentsIncludeChildren(oQ,e._tempParticleRenderers),a=0,i=r.length;a<i;a++)r[a].generator.stop(!1,n);else if(this._isPlaying=!1,n===oq.StopEmittingAndClear){var o=this._firstFreeElement;this._firstRetiredElement=o,this._firstActiveElement=o,this._firstNewElement=o,this._playTime=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox,this.emission._reset()}},t.emit=function(e){this._emit(this._playTime,e)},t._emit=function(t,n){if(this.emission.enabled&&!(this._getNotRetiredParticleCount()>=this.main.maxParticles))for(var r=e._tempVector30,a=e._tempVector31,i=this._renderer.entity.transform,o=this.emission.shape,s=0;s<n;s++){if(null==o?void 0:o.enabled){o._generatePositionAndDirection(this.emission._shapeRand,t,r,a);var l=this.main._getPositionScale();r.multiply(l),a.normalize().multiply(l)}else r.set(0,0,0),a.set(0,0,-1);this._addNewParticle(r,a,i,t)}},t._update=function(e){var t=this.isAlive,n=this.main,r=this.emission,a=n.duration,i=this._playTime,o=e*n.simulationSpeed;if(this._playStartDelay>0){var s=this._playStartDelay-=o;if(!(s<0))return;this._playTime-=s,this._playStartDelay=0}if(this._playTime+=o,this._retireActiveParticles(),this._freeRetiredParticles(),n.simulationSpace===oY.World&&this._retireTransformedBounds(),r.enabled&&this._isPlaying&&(this._currentParticleCount>n._maxParticleBuffer&&this._getNotRetiredParticleCount()<n._maxParticleBuffer&&this._resizeInstanceBuffer(!1),r._emit(i,this._playTime),!n.isLoop&&this._playTime>a&&(this._isPlaying=!1)),this.isAlive)n.simulationSpace===oY.World&&this._generateTransformedBounds();else{var l=Math.min(r._frameRateTime,Math.floor(this._playTime/a)*a);this._playTime-=l,r._frameRateTime-=l}this.isAlive!==t&&this._renderer._onWorldVolumeChanged(),(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},t._reorganizeGeometryBuffers=function(){var e=this._renderer,t=e.engine._particleBufferUtils,n=this._primitive,r=this._vertexBufferBindings;if(n.clearVertexElements(),r.length=0,e.renderMode===oK.Mesh){var a=e.mesh;if(!a)return;var i=a.getVertexElement(aR.Position),o=a.getVertexElement(aR.Color),s=a.getVertexElement(aR.UV),l=i?a.vertexBufferBindings[i.bindingIndex]:null,c=o?a.vertexBufferBindings[o.bindingIndex]:null,u=s?a.vertexBufferBindings[s.bindingIndex]:null;if(l){var d=this._addVertexBufferBindingsFilterDuplicate(l,r);n.addVertexElement(new at(aR.Position,i.offset,i.format,d))}if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,r);n.addVertexElement(new at(aR.Color,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,r);n.addVertexElement(new at(aR.UV,s.offset,s.format,_))}var f=a._primitive.indexBufferBinding;n.setIndexBufferBinding(f),this._subPrimitive.count=f.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(t.billboardVertexElement),r.push(t.billboardVertexBufferBinding),n.setIndexBufferBinding(t.billboardIndexBufferBinding),this._subPrimitive.count=iW.billboardIndexCount;n.setVertexBufferBindings(r);for(var p=t.instanceVertexElements,m=r.length,g=0,v=p.length;g<v;g++){var y=p[g];n.addVertexElement(new at(y.attribute,y.offset,y.format,m,y.instanceStepRate))}},t._resizeInstanceBuffer=function(e,t){null==(u=this._instanceVertexBufferBinding)||u.buffer.destroy();var n=iW.instanceVertexStride,r=e?this._currentParticleCount+t:this.main._maxParticleBuffer,a=n*r,i=new r9(this._renderer.engine,an.VertexBuffer,a,r8.Dynamic,!1);i.isGCIgnored=!0;var o=this._primitive.vertexBufferBindings,s=new aS(i,n),l=new Float32Array(a/4),c=this._instanceVertices;if(c){var u,d,h,_=iW.instanceVertexFloatStride,f=this._firstFreeElement,p=this._firstRetiredElement;if(e){l.set(new Float32Array(c.buffer,0,f*_));var m=f+1;l.set(new Float32Array(c.buffer,m*_*4),(m+t)*_),this._firstNewElement>f&&(this._firstNewElement+=t),this._firstActiveElement>f&&(this._firstActiveElement+=t),p>f&&(this._firstRetiredElement+=t)}else p<=f?(d=f-p,h=0,this._firstFreeElement-=p,this._firstNewElement-=p,this._firstActiveElement-=p,this._firstRetiredElement=0):(d=this._currentParticleCount-p,h=f,this._firstNewElement>f&&(this._firstNewElement-=f),this._firstActiveElement>f&&(this._firstActiveElement-=f),p>f&&(this._firstRetiredElement-=f)),l.set(new Float32Array(c.buffer,p*_*4,d*_),h*_);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(c?o.length-1:o.length,s),this._instanceVertices=l,this._instanceVertexBufferBinding=s,this._currentParticleCount=r},t._updateShaderData=function(e){this.main._updateShaderData(e),this.velocityOverLifetime._updateShaderData(e),this.textureSheetAnimation._updateShaderData(e),this.sizeOverLifetime._updateShaderData(e),this.rotationOverLifetime._updateShaderData(e),this.colorOverLifetime._updateShaderData(e)},t._resetGlobalRandSeed=function(e){this._randomSeed=e,this.main._resetRandomSeed(e),this.emission._resetRandomSeed(e),this.textureSheetAnimation._resetRandomSeed(e),this.velocityOverLifetime._resetRandomSeed(e),this.rotationOverLifetime._resetRandomSeed(e),this.colorOverLifetime._resetRandomSeed(e)},t._getAliveParticleCount=function(){if(this._firstActiveElement<=this._firstFreeElement)return this._firstFreeElement-this._firstActiveElement;var e=this._currentParticleCount-this._firstActiveElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},t._getNotRetiredParticleCount=function(){if(this._firstRetiredElement<=this._firstFreeElement)return this._firstFreeElement-this._firstRetiredElement;var e=this._currentParticleCount-this._firstRetiredElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},t._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy(),this.emission._destroy()},t._updateBoundsSimulationLocal=function(e){var t=this._renderer,n=this.main.startLifetime._getMax(),r=t._generatorBounds,a=t._transformedBounds;t._isContainDirtyFlag(oJ.GeneratorVolume)&&(this._calculateGeneratorBounds(n,r),t._setDirtyFlagFalse(oJ.GeneratorVolume)),t._isContainDirtyFlag(oJ.TransformVolume)&&(this._calculateTransformedBounds(n,r,a),t._setDirtyFlagFalse(oJ.TransformVolume)),this._addGravityToBounds(n,a,e)},t._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,n=this._firstActiveTransformedBoundingBox,r=this._firstFreeTransformedBoundingBox,a=n*iW.boundsFloatStride;if(e.min.copyFromArray(t,a),e.max.copyFromArray(t,a+3),n<r)for(var i=n+1;i<r;i++)this._mergeTransformedBounds(i,e);else{for(var o=n+1,s=this._transformedBoundsCount;o<s;o++)this._mergeTransformedBounds(o,e);if(r>0)for(var l=0;l<r;l++)this._mergeTransformedBounds(l,e)}var c=this.main.startLifetime._getMax();this._addGravityToBounds(c,e,e)},t._freeBoundsArray=function(){this._transformedBoundsArray=null,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0},t._generateTransformedBounds=function(){var e=this._renderer,t=this.main.startLifetime._getMax(),n=e._generatorBounds;e._isContainDirtyFlag(oJ.GeneratorVolume)&&(this._calculateGeneratorBounds(t,n),e._setDirtyFlagFalse(oJ.GeneratorVolume));var r=iW.boundsFloatStride,a=iW.boundsTimeOffset,i=iW.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(oJ.TransformVolume)){var s=o+1;s>=this._transformedBoundsCount&&(s=0),s===this._firstActiveTransformedBoundingBox&&(this._resizeTransformedBoundsArray(),s=o+1);var l=e._transformedBounds;this._calculateTransformedBounds(t,n,l);var c=o*r,u=this._transformedBoundsArray;l.min.copyToArray(u,c),l.max.copyToArray(u,c+3),u[c+a]=this._playTime,u[c+i]=t,this._firstFreeTransformedBoundingBox=s,e._setDirtyFlagFalse(oJ.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*iW.boundsFloatStride+a]=this._playTime}},t._addNewParticle=function(t,n,r,a){var i,o,s=this._firstFreeElement,l=s+1;l>=this._currentParticleCount&&(l=0);var c=this.main;if(l===this._firstRetiredElement){var u=Math.min(e._particleIncreaseCount,c._maxParticleBuffer-this._currentParticleCount);if(0===u)return;this._resizeInstanceBuffer(!0,u),l=s+1}c.simulationSpace===oY.World&&(i=r.worldPosition,o=r.worldRotationQuaternion);var d=c.startSpeed.evaluate(void 0,c._startSpeedRand.random()),h=this._instanceVertices,_=s*iW.instanceVertexFloatStride;h[_]=t.x,h[_+1]=t.y,h[_+2]=t.z,h[_+iW.startLifeTimeOffset]=c.startLifetime.evaluate(void 0,c._startLifeTimeRand.random()),h[_+4]=n.x,h[_+5]=n.y,h[_+6]=n.z,h[_+iW.timeOffset]=a;var f=e._tempColor0;c.startColor.evaluate(void 0,c._startColorRand.random(),f),this._renderer.engine.settings.colorSpace===n2.Linear&&f.toLinear(f),h[_+8]=f.r,h[_+9]=f.g,h[_+10]=f.b,h[_+11]=f.a;var p=c._startSizeRand;if(c.startSize3D)h[_+12]=c.startSizeX.evaluate(void 0,p.random()),h[_+13]=c.startSizeY.evaluate(void 0,p.random()),h[_+14]=c.startSizeZ.evaluate(void 0,p.random());else{var m=c.startSize.evaluate(void 0,p.random());h[_+12]=m,h[_+13]=m,h[_+14]=m}var g=c._startRotationRand;switch(c.startRotation3D?(h[_+15]=tS.degreeToRadian(c.startRotationX.evaluate(void 0,g.random())),h[_+16]=tS.degreeToRadian(c.startRotationY.evaluate(void 0,g.random())),h[_+17]=tS.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random()))):h[_+15]=tS.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random())),h[_+18]=d,c.gravityModifier.mode){case oZ.Constant:h[_+19]=c.gravityModifier.constant;break;case oZ.TwoConstants:h[_+19]=c.gravityModifier.evaluate(void 0,c._gravityModifierRand.random())}var v=this.colorOverLifetime;v.enabled&&v.color.mode===o$.TwoGradients&&(h[_+20]=v._colorGradientRand.random());var y=this.rotationOverLifetime;y.enabled&&y.rotationZ.mode===oZ.TwoConstants&&(h[_+22]=y._rotationRand.random());var x=this.textureSheetAnimation;x.enabled&&x.frameOverTime.mode===oZ.TwoCurves&&(h[_+23]=x._frameOverTimeRand.random());var b=this.velocityOverLifetime;if(b.enabled&&b.velocityX.mode===oZ.TwoConstants&&b.velocityY.mode===oZ.TwoConstants&&b.velocityZ.mode===oZ.TwoConstants){var C=b._velocityRand;h[_+24]=C.random(),h[_+25]=C.random(),h[_+26]=C.random()}if(this.main.simulationSpace===oY.World&&(h[_+27]=i.x,h[_+28]=i.y,h[_+29]=i.z,h[_+30]=o.x,h[_+31]=o.y,h[_+32]=o.z,h[_+33]=o.w),x.enabled){var S=x.frameOverTime,T=x._tillingInfo,A=T.x,E=T.y,R=T.z,M=0;(S.mode===oZ.Constant||S.mode===oZ.TwoConstants)&&(M=Math.floor(S.evaluate(void 0,x._frameOverTimeRand.random())*R)*A);var w=Math.floor(M);h[_+iW.simulationUVOffset]=A,h[_+35]=E,h[_+36]=M-w,h[_+37]=w*E}else h[_+iW.simulationUVOffset]=1,h[_+35]=1,h[_+36]=0,h[_+37]=0;this._firstFreeElement=l},t._retireActiveParticles=function(){for(var e=this._renderer.engine.time.frameCount,t=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var n=this._firstActiveElement*iW.instanceVertexFloatStride,r=n+iW.timeOffset;if(Math.fround(this._playTime-t[r])<t[n+iW.startLifeTimeOffset])break;t[r]=e,++this._firstActiveElement>=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},t._freeRetiredParticles=function(){for(var e=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var t=this._firstRetiredElement*iW.instanceVertexFloatStride+iW.startLifeTimeOffset;if(e-this._instanceVertices[t]<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},t._addActiveParticlesToVertexBuffer=function(){var e=this._firstActiveElement,t=this._firstFreeElement;if(e!==t){var n=iW.instanceVertexStride,r=e*n,a=this._instanceVertexBufferBinding.buffer,i=this._instanceVertices.buffer;if(e<t)a.setData(i,0,r,(t-e)*n,r5.Discard);else{var o=(this._currentParticleCount-e)*n;a.setData(i,0,r,o,r5.Discard),t>0&&a.setData(i,o,0,t*n)}this._firstNewElement=t,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},t._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return t.push(e),n},t._resizeTransformedBoundsArray=function(){var t=iW.boundsFloatStride,n=e._transformedBoundsIncreaseCount;this._transformedBoundsCount+=n;var r=this._transformedBoundsArray,a=new Float32Array(this._transformedBoundsCount*t);if(r){var i=this._firstFreeTransformedBoundingBox;a.set(new Float32Array(r.buffer,0,i*t));var o=i+1;a.set(new Float32Array(r.buffer,o*t*4),(o+n)*t),this._firstActiveTransformedBoundingBox>i&&(this._firstActiveTransformedBoundingBox+=n)}this._transformedBoundsArray=a},t._retireTransformedBounds=function(){for(var e=iW.boundsFloatStride,t=iW.boundsTimeOffset,n=iW.boundsMaxLifetimeOffset,r=this._transformedBoundsArray,a=this._firstFreeTransformedBoundingBox,i=this._transformedBoundsCount;this._firstActiveTransformedBoundingBox!==a;){var o=this._firstActiveTransformedBoundingBox*e;if(this._playTime-r[o+t]<=r[o+n])break;++this._firstActiveTransformedBoundingBox>=i&&(this._firstActiveTransformedBoundingBox=0),this._renderer._onWorldVolumeChanged()}},t._calculateGeneratorBounds=function(t,n){var r=e._tempVector30,a=e._tempVector31,i=e._tempVector20,o=n.min,s=n.max,l=this.main,c=this.emission.shape;(null==c?void 0:c.enabled)?(c._getPositionRange(o,s),c._getDirectionRange(a,r)):(o.set(0,0,0),s.set(0,0,0),a.set(0,0,-1),r.set(0,0,0)),this._getExtremeValueFromZero(l.startSpeed,i);var u=i.x,d=i.y,h=a.x,_=a.y,f=a.z,p=r.x,m=r.y,g=r.z;o.set(o.x+Math.min(h*d,p*u)*t,o.y+Math.min(_*d,m*u)*t,o.z+Math.min(f*d,g*u)*t),s.set(s.x+Math.max(h*u,p*d)*t,s.y+Math.max(_*u,m*d)*t,s.z+Math.max(f*u,g*d)*t);var v=l.startSize._getMax();if(l.startSize3D){var y=l.startSizeY._getMax();v=this._renderer.renderMode===oK.Billboard||oK.StretchBillboard||oK.HorizontalBillboard?Math.max(v,y):Math.max(v,y,l.startSizeZ._getMax())}v*=1.414;var x=this.sizeOverLifetime;if(x.enabled){var b=x.size._getMax();x.separateAxes&&(b=Math.max(b,x.sizeY._getMax(),x.sizeZ._getMax())),v*=b}o.set(o.x-v,o.y-v,o.z-v),s.set(s.x+v,s.y+v,s.z+v)},t._mergeTransformedBounds=function(e,t){var n=t.min,r=t.max,a=this._transformedBoundsArray,i=e*iW.boundsFloatStride;n.set(Math.min(n.x,a[i]),Math.min(n.y,a[i+1]),Math.min(n.z,a[i+2])),r.set(Math.max(r.x,a[i+3]),Math.max(r.y,a[i+4]),Math.max(r.z,a[i+5]))},t._calculateTransformedBounds=function(t,n,r){var a=e._tempVector20,i=e._tempVector21,o=e._tempVector22,s=e._tempMat,l=this._renderer.entity.transform,c=l.worldPosition;tL.rotationQuaternion(l.worldRotationQuaternion,s);var u=n.min,d=n.max,h=r.min,_=r.max,f=this.velocityOverLifetime;f.enabled?(this._getExtremeValueFromZero(f.velocityX,a),this._getExtremeValueFromZero(f.velocityY,i),this._getExtremeValueFromZero(f.velocityZ,o),f.space===oY.Local?(h.set(u.x+a.x*t,u.y+i.x*t,u.z+o.x*t),_.set(d.x+a.y*t,d.y+i.y*t,d.z+o.y*t),r.transform(s)):(r.transform(s),h.set(u.x+a.x*t,u.y+i.x*t,u.z+o.x*t),_.set(d.x+a.y*t,d.y+i.y*t,d.z+o.y*t))):tE.transform(n,s,r),h.add(c),_.add(c)},t._addGravityToBounds=function(t,n,r){var a=n.min,i=n.max,o=e._tempVector20;this._getExtremeValueFromZero(this.main.gravityModifier,o);var s=this._renderer.scene.physics.gravity,l=s.x,c=s.y,u=s.z,d=.5*t*t,h=o.x*d,_=o.y*d,f=l*h,p=l*_,m=c*h,g=c*_,v=u*h,y=u*_;r.min.set(Math.min(f,p)+a.x,Math.min(m,g)+a.y,Math.min(v,y)+a.z),r.max.set(Math.max(f,p)+i.x,Math.max(m,g)+i.y,Math.max(v,y)+i.z)},t._getExtremeValueFromZero=function(e,t){e._getMinMax(t),t.x=Math.min(0,t.x),t.y=Math.max(0,t.y)},tG(e,[{key:"isAlive",get:function(){return!!this._isPlaying||this._firstActiveElement!==this._firstFreeElement}},{key:"randomSeed",get:function(){return this._randomSeed},set:function(e){this._resetGlobalRandSeed(e),this.useAutoRandomSeed=!1}}]),e}();ss._tempVector20=new tB,ss._tempVector21=new tB,ss._tempVector22=new tB,ss._tempVector30=new tT,ss._tempVector31=new tT,ss._tempMat=new tL,ss._tempColor0=new tO,ss._tempParticleRenderers=[],ss._particleIncreaseCount=128,ss._transformedBoundsIncreaseCount=16,tX([tZ],ss.prototype,"main",void 0),tX([tZ],ss.prototype,"emission",void 0),tX([tZ],ss.prototype,"velocityOverLifetime",void 0),tX([tZ],ss.prototype,"sizeOverLifetime",void 0),tX([tZ],ss.prototype,"rotationOverLifetime",void 0),tX([tZ],ss.prototype,"colorOverLifetime",void 0),tX([tZ],ss.prototype,"textureSheetAnimation",void 0),tX([tq],ss.prototype,"_playTime",void 0),tX([tq],ss.prototype,"_firstNewElement",void 0),tX([tq],ss.prototype,"_firstActiveElement",void 0),tX([tq],ss.prototype,"_firstFreeElement",void 0),tX([tq],ss.prototype,"_firstRetiredElement",void 0),tX([tq],ss.prototype,"_primitive",void 0),tX([tq],ss.prototype,"_vertexBufferBindings",void 0),tX([tq],ss.prototype,"_subPrimitive",void 0),tX([tq],ss.prototype,"_renderer",void 0),tX([tq],ss.prototype,"_isPlaying",void 0),tX([tq],ss.prototype,"_instanceBufferResized",void 0),tX([tq],ss.prototype,"_waitProcessRetiredElementCount",void 0),tX([tq],ss.prototype,"_instanceVertexBufferBinding",void 0),tX([tq],ss.prototype,"_instanceVertices",void 0),tX([tq],ss.prototype,"_transformedBoundsArray",void 0),tX([tq],ss.prototype,"_transformedBoundsCount",void 0),tX([tq],ss.prototype,"_firstActiveTransformedBoundingBox",void 0),tX([tq],ss.prototype,"_firstFreeTransformedBoundingBox",void 0),tX([tq],ss.prototype,"_playStartDelay",void 0);var sl=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,ro.find("particle-shader"))||this).shaderData.setColor(as._baseColorProp,new tO(1,1,1,1)),n.isTransparent=!0,n}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(as._baseColorProp)},set:function(e){var t=this.shaderData.getColor(as._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(as._baseTextureProp)},set:function(e){this.shaderData.setTexture(as._baseTextureProp,e),e?this.shaderData.enableMacro(as._baseTextureMacro):this.shaderData.disableMacro(as._baseTextureMacro)}}]),t}(as),sc=function(e,t){this.time=e,this.count=t};tX([tZ],sc.prototype,"count",void 0);var su=/*#__PURE__*/function(){function e(){this._updateManager=new nM,this._enabled=!0,this._randomDirectionAmount=0}var t=e.prototype;return t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._updateManager.dispatch())}},{key:"randomDirectionAmount",get:function(){return this._randomDirectionAmount},set:function(e){e!==this._randomDirectionAmount&&(this._randomDirectionAmount=e,this._updateManager.dispatch())}}]),e}();tX([tq],su.prototype,"_updateManager",void 0);var sd=/*#__PURE__*/function(){function e(){}return e.randomPointUnitArcCircle=function(e,t,n){var r=n.random()*e;t.x=Math.cos(r),t.y=Math.sin(r)},e.randomPointInsideUnitArcCircle=function(t,n,r){e.randomPointUnitArcCircle(t,n,r);var a=Math.sqrt(r.random());n.x=n.x*a,n.y=n.y*a},e.randomPointUnitCircle=function(e,t){var n=t.random()*Math.PI*2;e.x=Math.cos(n),e.y=Math.sin(n)},e.randomPointInsideUnitCircle=function(t,n){e.randomPointUnitCircle(t,n);var r=Math.sqrt(n.random());t.x=t.x*r,t.y=t.y*r},e._randomPointUnitSphere=function(e,t){var n=2*t.random()-1,r=t.random()*Math.PI*2,a=Math.sqrt(1-n*n);e.x=a*Math.cos(r),e.y=a*Math.sin(r),e.z=n},e._randomPointInsideUnitSphere=function(t,n){e._randomPointUnitSphere(t,n);var r=Math.pow(n.random(),1/3);t.x=t.x*r,t.y=t.y*r,t.z=t.z*r},e._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},e}(),sh=((eJ={})[eJ.Box=0]="Box",eJ[eJ.Circle=1]="Circle",eJ[eJ.Cone=2]="Cone",eJ[eJ.Hemisphere=3]="Hemisphere",eJ[eJ.Sphere=4]="Sphere",eJ),s_=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).shapeType=sh.Box,t._size=new tT(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){sd._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var i=t._tempVector30;i.set(0,0,-1),sd._randomPointUnitSphere(a,e),tT.lerp(i,a,this.randomDirectionAmount,a)},n._getDirectionRange=function(e,t){var n=Math.PI*this.randomDirectionAmount;if(this.randomDirectionAmount<.5){var r=Math.sin(n);e.set(-r,-r,-1),t.set(r,r,0)}else{var a=Math.cos(n);e.set(-1,-1,-1),t.set(1,1,-a)}},n._getPositionRange=function(e,t){var n=this._size,r=n.x,a=n.y,i=n.z;e.set(-(.5*r),-(.5*a),-(.5*i)),t.set(.5*r,.5*a,.5*i)},tG(t,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),t}(su);s_._tempVector30=new tT,tX([tZ],s_.prototype,"_size",void 0);var sf=((eZ={})[eZ.Random=0]="Random",eZ[eZ.Loop=1]="Loop",eZ),sp=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Circle,t._radius=1,t._arc=360,t._arcMode=sf.Random,t._arcSpeed=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){var i=t._tempPositionPoint;switch(this.arcMode){case sf.Loop:var o=n*this.arcSpeed*(360/this.arc)%1,s=tS.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(e.random());break;case sf.Random:sd.randomPointInsideUnitArcCircle(tS.degreeToRadian(this.arc),i,e)}r.set(i.x,i.y,0),r.scale(this.radius),sd._randomPointUnitSphere(a,e),tT.lerp(r,a,this.randomDirectionAmount,a)},n._getDirectionRange=function(e,t){var n=this.randomDirectionAmount>.5?1:Math.sin(this.randomDirectionAmount*Math.PI),r=.5*(360-this._arc)*this.randomDirectionAmount,a=r>90?-1:-Math.sin(r);this._getUnitArcRange(this._arc+r,e,t,a,n)},n._getPositionRange=function(e,t){this._getUnitArcRange(this._arc,e,t,0,0),e.scale(this._radius),t.scale(this._radius)},n._getUnitArcRange=function(e,t,n,r,a){var i=tS.degreeToRadian(e),o=Math.sin(i),s=Math.cos(i);e<90?(t.set(0,r,-a),n.set(1,o,a)):(e<180?t.set(s,r,-a):e<270?t.set(-1,Math.min(o,r),-a):t.set(-1,-1,-a),n.set(1,1,a))},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"arc",get:function(){return this._arc},set:function(e){e!==this._arc&&(this._arc=e,this._updateManager.dispatch())}},{key:"arcMode",get:function(){return this._arcMode},set:function(e){e!==this._arcMode&&(this._arcMode=e,this._updateManager.dispatch())}},{key:"arcSpeed",get:function(){return this._arcSpeed},set:function(e){e!==this._arcSpeed&&(this._arcSpeed=e,this._updateManager.dispatch())}}]),t}(su);sp._tempPositionPoint=new tB;var sm=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){var i=t._tempVector20,o=tS.degreeToRadian(this.angle),s=Math.sin(o),l=Math.cos(o);switch(this.emitType){case 0:sd.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0);var c=t._tempVector21;sd.randomPointInsideUnitCircle(c,e),tB.lerp(i,c,this.randomDirectionAmount,c),a.set(c.x*s,c.y*s,-l);break;case 1:sd.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0),a.set(i.x*s,i.y*s,-l),a.normalize();var u=t._tempVector30;tT.scale(a,this.length*e.random(),u),r.add(u);var d=t._tempVector31;sd._randomPointUnitSphere(d,e),tT.lerp(a,d,this.randomDirectionAmount,a)}},n._getDirectionRange=function(e,t){var n=0;switch(this.emitType){case 0:n=tS.degreeToRadian(this._angle);break;case 1:n=Math.sin(tS.degreeToRadian((180-this._angle)*this.randomDirectionAmount+this._angle))}var r=Math.sin(n);e.set(-r,-r,-1),t.set(r,r,0)},n._getPositionRange=function(e,t){var n=this.radius;switch(this.emitType){case 0:e.set(-n,-n,0),t.set(n,n,0);break;case 1:var r=this.length,a=Math.sin(tS.degreeToRadian(this._angle));e.set(-n-a*r,-n-a*r,-r),t.set(n+a*r,n+a*r,0)}},tG(t,[{key:"angle",get:function(){return this._angle},set:function(e){e!==this._angle&&(this._angle=e,this._updateManager.dispatch())}},{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"length",get:function(){return this._length},set:function(e){e!==this._length&&(this._length=e,this._updateManager.dispatch())}},{key:"emitType",get:function(){return this._emitType},set:function(e){e!==this._emitType&&(this._emitType=e,this._updateManager.dispatch())}}]),t}(su);sm._tempVector20=new tB,sm._tempVector21=new tB,sm._tempVector30=new tT,sm._tempVector31=new tT;var sg=((e$={})[e$.Base=0]="Base",e$[e$.Volume=1]="Volume",e$),sv=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Hemisphere,t._radius=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sd._randomPointInsideUnitSphere(n,e),n.scale(this.radius);var a=n.z;a>0&&(n.z=-a),sd._randomPointUnitSphere(r,e),tT.lerp(n,r,this.randomDirectionAmount,r)},n._getDirectionRange=function(e,t){var n=Math.sin(.5*this.randomDirectionAmount*Math.PI);e.set(-1,-1,-1),t.set(1,1,n)},n._getPositionRange=function(e,t){var n=this._radius;e.set(-n,-n,-n),t.set(n,n,0)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(su),sy=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Sphere,t._radius=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sd._randomPointInsideUnitSphere(n,e),n.scale(this.radius),sd._randomPointUnitSphere(r,e),tT.lerp(n,r,this.randomDirectionAmount,r)},n._getDirectionRange=function(e,t){e.set(-1,-1,-1),t.set(1,1,1)},n._getPositionRange=function(e,t){var n=this._radius;e.set(-n,-n,-n),t.set(n,n,n)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(su);ro.create("trail","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;void main(){gl_Position=camera_ProjMat*camera_ViewMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nvarying vec2 v_uv;uniform sampler2D u_texture;void main(void){gl_FragColor=texture2D(u_texture,v_uv);}");var sx=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t,ro.find("trail"))||this).renderState.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=r.sourceAlphaBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=r.destinationAlphaBlendFactor=nF.One,n.renderState.depthState.writeEnabled=!1,n}return tW(t,e),t}(ao),sb=new tT,sC=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._stroke=n.stroke||.2,r._minSeg=n.minSeg||.02,r._lifetime=n.lifetime||1e3,r._maxPointNum=r._lifetime/1e3*t.engine.targetFrameRate,r._points=[],r._pointStates=[],r._strapPoints=[];for(var r,a=0;a<r._maxPointNum;a++)r._points.push(new tT),r._pointStates.push(r._lifetime),r._strapPoints.push(new tT),r._strapPoints.push(new tT);r._curPointNum=0;var i=n.material||new sx(r.engine);return r.setMaterial(i),r.setTexture(n.texture),r._initGeometry(),r}tW(t,e);var n=t.prototype;return n.update=function(e){for(var t=0,n=0,r=0;r<this._curPointNum;r++)this._pointStates[r]-=e,this._pointStates[r]<0?t++:t>0&&(n=r-t,this._pointStates[n]=this._pointStates[r],this._points[n].copyFrom(this._points[r]));this._curPointNum-=t;var a=!0;if(this._curPointNum===this._maxPointNum)a=!1;else if(this._curPointNum>0){var i=this._points[this._points.length-1];tT.distance(this.entity.transform.worldPosition,i)<this._minSeg&&(a=!1)}a&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},n.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},n._render=function(t){this._updateStrapVertices(t.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),e.prototype._render.call(this,t)},n._initGeometry=function(){var e=new aT(this._entity.engine),t=2*this._maxPointNum,n=20*t,r=new Float32Array(n),a=[new at("POSITION",0,r7.Vector3,0),new at("TEXCOORD_0",12,r7.Vector2,0)],i=new r9(this.engine,4*n,r8.Dynamic);e.setVertexBufferBinding(i,20),e.setVertexElements(a),e.addSubMesh(0,t,ar.TriangleStrip),this._vertexBuffer=i,this._vertexStride=20,this._vertices=r,this.mesh=e},n._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new tT(n[0],n[4],n[8]),a=new tT(n[1],n[5],n[9]),i=new tT(n[2],n[6],n[10]),o=this._stroke;a.scale(o);var s=new tT,l=new tT,c=new tF;tT.transformByQuat(r,c,r),tT.transformByQuat(a,c,a);var u=new tT,d=new tT,h=new tT;r.normalize();for(var _=this._vertices,f=0;f<this._maxPointNum;f++){if(f<this._curPointNum){var p=t[f];f===this._curPointNum-1&&0!==f?tT.subtract(p,t[f-1],h):tT.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(tT.dot(r,h));tT.cross(r,h,d),0>=tT.dot(d,i)&&(m=2*Math.PI-m),tF.rotationAxisAngle(i,m,c),tT.transformByQuat(a,c,u),tT.add(p,u,s),tT.subtract(p,u,l)}var g=2*f*this._vertexStride/4,v=(2*f+1)*this._vertexStride/4;_[g]=s.x,_[g+1]=s.y,_[g+2]=s.z,_[v]=l.x,_[v+1]=l.y,_[v+2]=l.z}},n._updateStrapCoords=function(){if(this._prePointsNum!==this._curPointNum){this._prePointsNum=this._curPointNum;for(var e=this._curPointNum,t=1/e,n=this._vertices,r=0;r<e;r++){var a=1-r*t,i=2*r*this._vertexStride/4,o=(2*r+1)*this._vertexStride/4;n[i]=0,n[i+1]=a,n[o]=1,n[o+1]=a}}},n._projectOnVector=function(e,t,n){var r=t.clone();tT.normalize(r,r);var a=tT.dot(e,r);n.x=r.x*a,n.y=r.y*a,n.z=r.z*a},n._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,sb),tT.subtract(e,sb,n)},t}(aA),sS=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.probeLayer=rE.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t}tW(t,e);var n=t.prototype;return n.onTextureChange=function(e){},n.onBeginRender=function(e){this.enabled&&(this._camera=e,this._oriCameraCullingMask=e.cullingMask,e.cullingMask=this.probeLayer,this._activeRenderTarget&&this._activeRenderTarget.width===this.width&&this._activeRenderTarget.height===this.height&&this._activeRenderTarget.antiAliasing===this.antiAliasing||(this._renderTarget=new nl(this.engine,this.width,this.height,this._isCube?new nd(this.engine,this.width):new nc(this.engine,this.width,this.height),t3.Depth,this.antiAliasing),this._renderTargetSwap=new nl(this.engine,this.width,this.height,this._isCube?new nd(this.engine,this.width):new nc(this.engine,this.width,this.height),t3.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=e.renderTarget,e.renderTarget=this._activeRenderTarget)},n.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},n._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},tG(t,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),t}(os),sT=new tT,sA=new tT,sE=new tT,sR=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.position=new tT(0,0,0),t._isCube=!0,t.oriViewMatrix=new tL,t}tW(t,e);var n=t.prototype;return n.onBeginRender=function(t){if(this.enabled){e.prototype.onBeginRender.call(this,t),this._storeCamera(t);for(var n=0;n<6;n++)this._setCamera(n,t),t.render(t4.PositiveX+n);this._restoreCamera(t),e.prototype._reset.call(this)}},n._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},n._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},n._setCamera=function(e,t){switch(e){case 0:sA.set(0,-1,0),sE.set(1,0,0);break;case 1:sA.set(0,-1,0),sE.set(-1,0,0);break;case 2:sA.set(0,0,1),sE.set(0,1,0);break;case 3:sA.set(0,0,-1),sE.set(0,-1,0);break;case 4:sA.set(0,-1,0),sE.set(0,0,1);break;case 5:sA.set(0,-1,0),sE.set(0,0,-1)}tT.add(this.position,sE,sT),tL.lookAt(this.position,sT,sA,t.viewMatrix),t.fieldOfView=90},t}(sS),sM=/*#__PURE__*/function(e){function t(t,n){var r;return void 0===n&&(n=""),(r=e.call(this,t)||this)._audioBuffer=null,r.name=n,r}tW(t,e);var n=t.prototype;return n._getAudioSource=function(){return this._audioBuffer},n._setAudioSource=function(e){this._audioBuffer=e},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._audioBuffer=null,this.name=null},tG(t,[{key:"channels",get:function(){return this._audioBuffer.numberOfChannels}},{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"duration",get:function(){return this._audioBuffer.duration}}]),t}(t1),sw=/*#__PURE__*/function(){function e(){}return e.getContext=function(){var t=e._context;return t||(e._context=t=new window.AudioContext,document.addEventListener("pointerdown",e._tryResume,!0),document.addEventListener("touchend",e._tryResume,!0),document.addEventListener("touchstart",e._tryResume,!0)),t},e.getGainNode=function(){var t=e._gainNode;return e._gainNode||(e._gainNode=t=e.getContext().createGain(),t.connect(e.getContext().destination)),t},e.isAudioContextRunning=function(){return"running"===e.getContext().state||(console.warn("The AudioContext is not running and requires user interaction, such as a click or touch."),!1)},e._tryResume=function(){"running"===e._context.state||e._isResuming||(e._isResuming=!0,e._context.resume().then(function(){e._isResuming=!1}))},e}();sw._isResuming=!1;var sP=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).playOnEnabled=!0,n._isPlaying=!1,n._sourceNode=null,n._pausedTime=-1,n._playTime=-1,n._volume=1,n._lastVolume=1,n._playbackRate=1,n._loop=!1,n._onPlayEnd=n._onPlayEnd.bind(n),n._gainNode=sw.getContext().createGain(),n._gainNode.connect(sw.getGainNode()),n}tW(t,e);var n=t.prototype;return n.play=function(){if(this._canPlay()&&!this._isPlaying){var e=this._pausedTime>0?this._pausedTime-this._playTime:0;this._initSourceNode(e),this._playTime=sw.getContext().currentTime-e,this._pausedTime=-1,this._isPlaying=!0}},n.stop=function(){this._isPlaying&&(this._clearSourceNode(),this._isPlaying=!1,this._pausedTime=-1,this._playTime=-1)},n.pause=function(){this._isPlaying&&(this._clearSourceNode(),this._pausedTime=sw.getContext().currentTime,this._isPlaying=!1)},n._onEnable=function(){this.playOnEnabled&&this.play()},n._onDisable=function(){this.pause()},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.stop(),this.clip=null},n._onPlayEnd=function(){this.stop()},n._initSourceNode=function(e){var t=sw.getContext().createBufferSource();t.buffer=this._clip._getAudioSource(),t.playbackRate.value=this._playbackRate,t.loop=this._loop,t.onended=this._onPlayEnd,this._sourceNode=t,t.connect(this._gainNode),this._sourceNode.start(0,e)},n._clearSourceNode=function(){this._sourceNode.stop(),this._sourceNode.disconnect(),this._sourceNode.onended=null,this._sourceNode=null},n._canPlay=function(){var e;return null!=(e=this._clip)&&!!e._getAudioSource()&&sw.isAudioContextRunning()},tG(t,[{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._addReferCount(-1),e&&e._addReferCount(1),this._clip=e,this.stop())}},{key:"isPlaying",get:function(){return this._isPlaying}},{key:"volume",get:function(){return this._volume},set:function(e){e=Math.min(Math.max(0,e),1),this._volume=e,this._gainNode.gain.setValueAtTime(e,sw.getContext().currentTime)}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(e){this._playbackRate=e,this._isPlaying&&(this._sourceNode.playbackRate.value=this._playbackRate)}},{key:"mute",get:function(){return 0===this.volume},set:function(e){e?(this._lastVolume=this.volume,this.volume=0):this.volume=this._lastVolume}},{key:"loop",get:function(){return this._loop},set:function(e){e!==this._loop&&(this._loop=e,this._isPlaying&&(this._sourceNode.loop=this._loop))}},{key:"time",get:function(){return this._isPlaying?sw.getContext().currentTime-this._playTime:this._pausedTime>0?this._pausedTime-this._playTime:0}}]),t}(ru);tX([tq],sP.prototype,"_isPlaying",void 0),tX([tq],sP.prototype,"_clip",void 0),tX([tZ],sP.prototype,"_gainNode",void 0),tX([tq],sP.prototype,"_sourceNode",void 0),tX([tZ],sP.prototype,"_pausedTime",void 0),tX([tq],sP.prototype,"_playTime",void 0),tX([tZ],sP.prototype,"_volume",void 0),tX([tZ],sP.prototype,"_lastVolume",void 0),tX([tZ],sP.prototype,"_playbackRate",void 0),tX([tZ],sP.prototype,"_loop",void 0),/*#__PURE__*/(function(){function e(){}return e.registerPolyfill=function(){e._registerMatchAll()},e._registerMatchAll=function(){String.prototype.matchAll||(no.info("polyfill String.prototype.matchAll"),String.prototype.matchAll=function(e){var t=e.flags;if(-1===t.indexOf("g"))throw TypeError("String.prototype.matchAll called with a non-global RegExp argument");var n=this;return function(){var r,a,i,o,s,l;return function(e,t){var n,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,function(c){switch(c.label){case 0:if(null==(r=n.match(e)))return[2,null];for(s in a=t.split("g").join(""),i=new RegExp(e.source,a),o=[],r)o.push(s);l=0,c.label=1;case 1:if(!(l<o.length))return[3,4];return[4,r[o[l]].match(i)];case 2:c.sent(),c.label=3;case 3:return l++,[3,1];case 4:return[2]}})}()})},e})().registerPolyfill();var sF=/*#__PURE__*/Object.freeze({__proto__:null,AmbientLight:i8,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:ov,AnimationClipCurveBinding:om,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:ox,AnimationEvent:og,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationRectCurve(){return e.AnimationRectCurve},get AnimationRefCurve(){return e.AnimationRefCurve},get AnimationStringCurve(){return e.AnimationStringCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:oD,AnimatorCondition:oR,AnimatorConditionMode:ob,AnimatorController:oI,AnimatorControllerLayer:oz,AnimatorControllerParameter:oB,AnimatorCullingMode:oC,AnimatorLayerBlendingMode:oS,AnimatorLayerMask:oH,AnimatorState:oV,AnimatorStateMachine:ok,AnimatorStateTransition:oM,AssetPromise:a8,AssetType:a2,AudioClip:sM,AudioManager:sw,AudioSource:sP,Background:i0,BackgroundMode:rO,BackgroundTextureFillMode:rN,BaseMaterial:as,BasicRenderPipeline:rZ,BlendFactor:nF,BlendMode:aa,BlendOperation:nL,BlendShape:am,BlendShapeFrame:af,BlendState:rt,BlinnPhongMaterial:al,BloomDownScaleMode:ot,BloomEffect:on,BoolUpdateFlag:rf,BoxColliderShape:iI,BoxShape:s_,Buffer:r9,BufferBindFlag:an,BufferMesh:aT,BufferUsage:r8,BufferUtil:ae,Burst:sc,get Camera(){return e.Camera},CameraClearFlags:rw,CameraType:rP,Canvas:iZ,CapsuleColliderShape:iV,CharacterController:ig,CircleShape:sp,ClearableObjectPool:iq,CloneManager:t$,get Collider(){return e.Collider},ColliderShape:iB,ColliderShapeUpAxis:iA,CollisionDetectionMode:iy,ColorOverLifetimeModule:o5,ColorSpace:n2,ColorWriteMask:nD,CompareFunction:nB,Component:ru,ConeEmitType:sg,ConeShape:sm,ContentRestorer:t2,ControllerCollisionFlag:iE,ControllerNonWalkableMode:im,CubeProbe:sR,CullMode:nI,CurveKey:sr,DataType:nQ,DependentMode:r_,DepthState:rn,DepthTextureMode:rF,DiffuseMode:i4,DirectLight:i9,DisorderedArray:rC,Downsampling:rL,DynamicCollider:iv,DynamicColliderConstraints:ix,EmissionModule:o6,Engine:iJ,EngineObject:t0,Entity:aW,EventDispatcher:nK,FixedJoint:iM,FogMode:i3,Font:ng,FontStyle:n_,GLCapabilityType:nJ,GradientAlphaKey:o3,GradientColorKey:o2,HemisphereShape:sv,HingeJoint:iP,HitResult:ib,IndexBufferBinding:ag,IndexFormat:r6,InputManager:iU,InterpolationType:oy,get Joint(){return e.Joint},JointLimits:iL,JointMotor:iD,Keyframe:oU,Keys:ih,Layer:rE,LayerPathMask:oG,Light:i5,Loader:ol,Logger:no,MSAASamples:rD,MainModule:se,Material:ao,Mesh:ab,MeshRenderer:aA,MeshTopology:ar,ModelMesh:aM,OverflowMode:nf,PBRBaseMaterial:au,PBRMaterial:ad,PBRSpecularMaterial:ah,ParticleCompositeCurve:o9,ParticleCompositeGradient:o4,ParticleCurve:sn,ParticleCurveMode:oZ,ParticleGenerator:ss,ParticleGradient:o1,ParticleGradientMode:o$,ParticleMaterial:sl,ParticleRenderMode:oK,ParticleRenderer:oQ,ParticleScaleMode:o7,ParticleShapeArcMode:sf,ParticleShapeType:sh,ParticleSimulationSpace:oY,ParticleStopMode:oq,PhysicsMaterial:iS,PhysicsMaterialCombineMode:iC,PhysicsScene:ip,PipelineStage:nX,PlaneColliderShape:iN,Platform:tz,PointLight:i6,Pointer:is,PointerButton:il,PointerPhase:io,Primitive:ax,PrimitiveMesh:az,Probe:sS,RasterState:rr,ReferResource:t1,RenderBufferDepthFormat:t3,RenderFace:ai,RenderQueue:rG,RenderQueueType:nN,RenderState:ri,RenderStateDataKey:nO,RenderTarget:nl,RenderTargetBlendState:re,get Renderer(){return e.Renderer},ReplacementFailureStrategy:rB,ResourceManager:ie,ReturnableObjectPool:aQ,RotationOverLifetimeModule:st,SafeLoopArray:a3,Scene:oo,SceneManager:a4,Script:os,SetDataOptions:r5,Shader:ro,ShaderData:rs,ShaderFactory:n$,ShaderLib:nZ,ShaderMacro:nH,ShaderMacroCollection:nW,ShaderPass:n6,ShaderPlatformTarget:nz,ShaderProperty:nY,ShaderPropertyType:nV,ShaderTagKey:n0,ShadowCascadesMode:rK,ShadowResolution:rW,ShadowType:rj,SizeOverLifetimeModule:sa,Skin:aj,SkinnedMeshRenderer:aK,Sky:i$,SkyBoxMaterial:oW,SkyProceduralMaterial:oX,SphereColliderShape:iO,SphereShape:sy,SpotLight:i7,SpringJoint:iF,Sprite:nP,SpriteAtlas:nb,SpriteDrawMode:nC,SpriteMask:r2,SpriteMaskInteraction:nv,SpriteMaskLayer:rg,SpriteRenderer:rT,SpriteTileMode:nS,StateMachineScript:oN,StaticCollider:iT,StencilOperation:nk,StencilState:ra,SubMesh:ay,SubPrimitive:av,SubShader:n7,SunMode:oj,SystemInfo:id,TextHorizontalAlignment:ny,TextRenderer:r3,TextUtils:np,TextVerticalAlignment:nx,Texture:ns,Texture2D:nc,Texture2DArray:nu,TextureCoordinate:ac,TextureCube:nd,TextureCubeFace:t4,TextureDepthCompareFunction:t8,TextureFilterMode:t5,TextureFormat:t9,TextureSheetAnimationModule:si,TextureUsage:t6,TextureWrapMode:t7,Time:nq,TonemappingEffect:oa,TonemappingMode:or,TrailMaterial:sx,TrailRenderer:sC,Transform:rp,UnlitMaterial:a_,Utils:nT,VelocityOverLifetimeModule:so,VertexAttribute:aR,VertexBufferBinding:aS,VertexElement:at,VertexElementFormat:r7,WrapMode:ow,XRManager:iQ,_PostProcessManager:oi,assignmentClone:tQ,deepClone:tZ,dependentComponents:rh,ignoreClone:tq,request:a6,resourceLoader:it,shallowClone:tJ}),sL=((e0={})[e0.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",e0[e0.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",e0[e0.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",e0[e0.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",e0[e0.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",e0[e0.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",e0[e0.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",e0[e0.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",e0[e0.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",e0[e0.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",e0[e0.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",e0[e0.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",e0[e0.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",e0[e0.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",e0[e0.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",e0[e0.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",e0[e0.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",e0[e0.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",e0[e0.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",e0[e0.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",e0[e0.R11_EAC=37488]="R11_EAC",e0[e0.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",e0[e0.RG11_EAC=37490]="RG11_EAC",e0[e0.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",e0[e0.RGB8_ETC2=37492]="RGB8_ETC2",e0[e0.SRGB8_ETC2=37493]="SRGB8_ETC2",e0[e0.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e0[e0.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e0[e0.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",e0[e0.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",e0[e0.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",e0[e0.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",e0[e0.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",e0[e0.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",e0[e0.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",e0[e0.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",e0[e0.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",e0[e0.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",e0[e0.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",e0[e0.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",e0[e0.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",e0[e0.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT",e0);function sD(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function sB(e,t,n){return t&&sD(e.prototype,t),n&&sD(e,n),e}function sI(e,t){return(sI=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sO(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&sI(e,t)}function sN(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var sV=/*#__PURE__*/function(e){function t(t){(n=e.call(this)||this)._scale=new tB;var n,r=t.width,a=t.height;return n._webCanvas=t,n.width=r,n.height=a,n}sO(t,e);var n=t.prototype;return n.resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!sN(t,OffscreenCanvas)){var n=t.clientWidth*e,r=t.clientHeight*e;this.width=n,this.height=r}},n.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},n._onWidthChanged=function(e){this._webCanvas.width=e},n._onHeightChange=function(e){this._webCanvas.height=e},sB(t,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&sN(e,OffscreenCanvas)||this._scale.set(e.clientWidth*devicePixelRatio/e.width,e.clientHeight*devicePixelRatio/e.height),this._scale},set:function(e){var t=this._webCanvas;"undefined"!=typeof OffscreenCanvas&&sN(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),t}(iZ),sk=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sO(t,e),t.create=function(e){var n=e.canvas,r=new t(new sV("string"==typeof n?document.getElementById(n):n),new sZ(e.graphicDeviceOptions),e);return r._initialize(e).then(function(){return r.sceneManager.addScene(new oo(r,"DefaultScene")),r})},sB(t,[{key:"canvas",get:function(){return this._canvas}}]),t}(iJ);function sz(){return(sz=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var sU=/*#__PURE__*/function(){function e(e,t,n,r,a){void 0===r&&(r=r8.Static);var i=e.gl,o=i.createBuffer(),s=this._getGLBufferUsage(i,r),l=t===an.VertexBuffer?i.ARRAY_BUFFER:i.ELEMENT_ARRAY_BUFFER;this._gl=i,this._glBuffer=o,this._glBufferUsage=s,this._glBindTarget=l,this._isWebGL2=e.isWebGL2,this.bind(),a?i.bufferData(l,a,s):i.bufferData(l,n,s),i.bindBuffer(l,null)}var t=e.prototype;return t.bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},t.setData=function(e,t,n,r,a,i){var o=this._gl,s=this._glBindTarget;this.bind(),i===r5.Discard&&o.bufferData(s,e,this._glBufferUsage);var l=t.BYTES_PER_ELEMENT||1,c=a?l*a:t.byteLength;if(0!==r||c<t.byteLength){var u=void 0!==t.byteOffset;if(this._isWebGL2&&u)o.bufferSubData(s,n,t,r,c/l);else{var d=new Uint8Array(u?t.buffer:t,r*l,c);o.bufferSubData(s,n,d)}}else o.bufferSubData(s,n,t);o.bindBuffer(s,null)},t.getData=function(e,t,n,r){if(this._isWebGL2){var a=this._gl;this.bind(),a.getBufferSubData(this._glBindTarget,t,e,n,r)}else throw"Buffer is write-only on WebGL1.0 platforms."},t.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},t._getGLBufferUsage=function(e,t){switch(t){case r8.Static:return e.STATIC_DRAW;case r8.Dynamic:return e.DYNAMIC_DRAW;case r8.Stream:return e.STREAM_DRAW}},e}(),sG=/*#__PURE__*/function(){function e(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}var t=e.prototype;return t.canIUse=function(e){return this.capabilityList.get(e)},t.canIUseCompressedTextureInternalFormat=function(e){var t=sL.RGBA_ASTC_4X4_KHR,n=sL.RGBA_ASTC_12X12_KHR,r=sL.SRGB8_ALPHA8_ASTC_4X4_KHR,a=sL.SRGB8_ALPHA8_ASTC_12X12_KHR,i=sL.RGB_ETC1_WEBGL,o=sL.R11_EAC,s=sL.SRGB8_ALPHA8_ETC2_EAC,l=sL.RGB_PVRTC_4BPPV1_IMG,c=sL.RGBA_PVRTC_2BPPV1_IMG,u=sL.RGB_S3TC_DXT1_EXT,d=sL.RGBA_S3TC_DXT5_EXT,h=sL.RGBA_BPTC_UNORM_EXT,_=sL.RGB_BPTC_UNSIGNED_FLOAT_EXT;return e>=t&&n<=n||e>=r&&e<=a?this.canIUse(nJ.astc):e===i?this.canIUse(nJ.etc1):e>=o&&e<=s?this.canIUse(nJ.etc):e>=l&&e<=c?this.canIUse(nJ.pvrtc):e>=u&&e<=d?this.canIUse(nJ.s3tc):!!(e>=h)&&!!(e<=_)&&this.canIUse(nJ.bptc)},t._init=function(){var e=this.capabilityList,t=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),r=nJ.shaderVertexID,a=nJ.standardDerivatives,i=nJ.shaderTextureLod,o=nJ.elementIndexUint,s=nJ.depthTexture,l=nJ.vertexArrayObject,c=nJ.instancedArrays,u=nJ.multipleSample,d=nJ.drawBuffers,h=nJ.blendMinMax,_=nJ.astc,f=nJ.astc_webkit,p=nJ.etc,m=nJ.etc_webkit,g=nJ.etc1,v=nJ.etc1_webkit,y=nJ.pvrtc,x=nJ.pvrtc_webkit,b=nJ.s3tc,C=nJ.s3tc_webkit,S=nJ.bptc,T=nJ.textureFloat,A=nJ.textureHalfFloat,E=nJ.textureFloatLinear,R=nJ.textureHalfFloatLinear,M=nJ.WEBGL_colorBufferFloat,w=nJ.colorBufferFloat,P=nJ.colorBufferHalfFloat,F=nJ.textureFilterAnisotropic,L=nJ.fragDepth;e.set(r,t),e.set(a,t||!!n(a)),e.set(i,t||!!n(i)),e.set(o,t||!!n(o)),e.set(s,t||!!n(s)),e.set(l,t||!!n(l)),e.set(c,t||!!n(c)),e.set(u,t),e.set(d,t||!!n(d)),e.set(h,t||!!n(h)),e.set(T,t||!!n(T)),e.set(A,t||!!n(A)),e.set(E,!!n(E)),e.set(R,t||!!n(R)),e.set(w,t&&!!n(w)||!!n(M)),e.set(P,t&&!!n(w)||!!n(P)),e.set(F,!!n(F)),e.set(L,t||!!n(L)),e.set(_,!!(n(_)||n(f))),e.set(p,!!(n(p)||n(m))),e.set(g,!!(n(g)||n(v))),e.set(y,!!(n(y)||n(x))),e.set(b,!!(n(b)||n(C))),e.set(S,!!n(S))},t._compatibleInterface=function(e,t){var n=this.rhi,r=n.gl,a=null;if(a=n.requireExtension(e))for(var i in t){var o=a[t[i]];(null==o?void 0:o.bind)?r[i]=o.bind(a):r[i]=o}},t._compatibleAllInterface=function(){var e=nJ.depthTexture,t=nJ.vertexArrayObject,n=nJ.instancedArrays,r=nJ.drawBuffers,a=nJ.textureFilterAnisotropic,i=nJ.textureHalfFloat,o=nJ.colorBufferHalfFloat,s=nJ.WEBGL_colorBufferFloat,l=nJ.blendMinMax;if(!this.rhi.isWebGL2){this._compatibleInterface(l,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(e,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(t,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(n,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(r,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var c={};if(this.canIUse(nJ.drawBuffers)){for(var u=this.maxDrawBuffers,d=0;d<u;d++)0!=d&&(c["COLOR_ATTACHMENT"+d]="COLOR_ATTACHMENT"+d+"_WEBGL"),c["DRAW_BUFFER"+d]="DRAW_BUFFER"+d+"_WEBGL";this._compatibleInterface(r,sz({drawBuffers:"drawBuffersWEBGL"},c))}this._compatibleInterface(i,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(o,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(s,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(a,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},sB(e,[{key:"maxTextureSize",get:function(){return this.rhi.renderStates.getParameter(this.rhi.gl.MAX_TEXTURE_SIZE)}},{key:"canUseFloatTextureBlendShape",get:function(){return this.canIUse(nJ.shaderVertexID)&&this.canIUse(nJ.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(nJ.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(nJ.drawBuffers)?this._maxDrawBuffers=this._rhi.gl.getParameter(this._rhi.gl.MAX_DRAW_BUFFERS):this._maxDrawBuffers=1),this._maxDrawBuffers}},{key:"maxAnisoLevel",get:function(){if(!this._maxAnisoLevel){var e=this._rhi.requireExtension(nJ.textureFilterAnisotropic);this._maxAnisoLevel=e?this._rhi.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1}return this._maxAnisoLevel}},{key:"maxAntiAliasing",get:function(){if(!this._maxAntiAliasing){var e=this._rhi.gl,t=this.canIUse(nJ.multipleSample);this._maxAntiAliasing=t?e.getParameter(e.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),e}(),sH=/*#__PURE__*/function(){function e(e){this.rhi=e,this._requireResult={}}return e.prototype.requireExtension=function(e){return void 0!==this._requireResult[e]||(this._requireResult[e]=this.rhi.gl.getExtension(e)),this._requireResult[e]},e}(),sW=/*#__PURE__*/function(){function e(e,t){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=t,this._canUseInstancedArrays=e.canIUse(nJ.instancedArrays),this._isSupportVAO=e.canIUse(nJ.vertexArrayObject),this._gl=e.gl}var t=e.prototype;return t.draw=function(e,t){var n=this._gl,r=this._primitive,a=this._isSupportVAO&&r.enableVAO;if(a){r._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var i=this._vaoMap.get(e.id);n.bindVertexArray(i)}else this._bindBufferAndAttrib(e);var o=r.indexBufferBinding,s=r.instanceCount,l=r._glIndexType,c=r._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)n.drawElementsInstanced(u,h,l,d*c,s);else{var _=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,_),n.drawElementsInstanced(u,h,l,d*c,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArraysInstanced(u,d,h,s)}else no.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)n.drawElements(u,h,l,d*c);else{var f=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.drawElements(u,h,l,d*c),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArrays(u,d,h);a?n.bindVertexArray(null):this._disableAttrib()},t.destroy=function(){this._isSupportVAO&&this._clearVAO()},t._bindBufferAndAttrib=function(e){var t,n,r=this._gl,a=this._primitive,i=a.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=a._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var d=i[u.bindingIndex],h=d.buffer,_=d.stride;n!==(t=h._platformBuffer._glBuffer)&&(n=t,r.bindBuffer(r.ARRAY_BUFFER,t)),r.enableVertexAttribArray(c);var f=u._formatMetaInfo;r.vertexAttribPointer(c,f.size,f.type,f.normalized,_,u.offset),this._canUseInstancedArrays&&r.vertexAttribDivisor(c,u.instanceStepRate),this._attribLocArray.push(c)}else no.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},t._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},t._registerVAO=function(e){var t=this._gl,n=t.createVertexArray();t.bindVertexArray(n);var r=this._primitive.indexBufferBinding;r&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.buffer._platformBuffer._glBuffer),this._bindBufferAndAttrib(e),t.bindVertexArray(null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this._disableAttrib(),this._vaoMap.set(e.id,n)},t._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},e}(),sj=/*#__PURE__*/function(){function e(e){this._parameters={},this._gl=e,this._parameters={},this._parameters[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_VERTEX_UNIFORM_VECTORS]=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this._parameters[e.MAX_VERTEX_ATTRIBS]=e.getParameter(e.MAX_VERTEX_ATTRIBS),this._parameters[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_TEXTURE_SIZE]=e.getParameter(e.MAX_TEXTURE_SIZE),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.colorMask(!0,!0,!0,!0),e.blendColor(0,0,0,0),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.enable(e.DEPTH_TEST),e.depthFunc(e.LESS),e.depthMask(!0),e.disable(e.STENCIL_TEST),e.stencilFuncSeparate(e.FRONT,e.ALWAYS,0,255),e.stencilFuncSeparate(e.BACK,e.ALWAYS,0,255),e.stencilOpSeparate(e.FRONT,e.KEEP,e.KEEP,e.KEEP),e.stencilOpSeparate(e.BACK,e.KEEP,e.KEEP,e.KEEP),e.stencilMask(255),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.disable(e.POLYGON_OFFSET_FILL),e.polygonOffset(0,0)}return e.prototype.getParameter=function(e){return this._parameters[e]},e}(),sX=/*#__PURE__*/function(){function e(e,t,n){this._texture=t,this._rhi=e,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=n,this._glTexture=this._gl.createTexture()}var t=e.prototype;return t.destroy=function(){this._gl.deleteTexture(this._glTexture),this._texture=null,this._glTexture=null,this._formatDetail=null},t.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},t.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},t._bind=function(){this._rhi.bindTexture(this)},t._init=function(e){var t=this._gl,n=this._isWebGL2,r=this._formatDetail,a=r.internalFormat,i=r.baseFormat,o=r.dataType,s=this._texture,l=s.mipmapCount,c=s.width,u=s.height,d=s.usage,h=s._isDepthTexture;if(this._bind(),n&&!(i===t.LUMINANCE_ALPHA||i===t.ALPHA)&&d!==t6.Dynamic)t.texStorage2D(this._target,l,a,c,u);else if(e)for(var _=0;_<l;_++)for(var f=Math.max(1,c>>_),p=0;p<6;p++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,_,a,f,f,0,i,o,null);else if(h)t.texImage2D(this._target,0,a,c,u,0,i,o,null);else for(var m=0;m<l;m++){var g=Math.max(1,c>>m),v=Math.max(1,u>>m);t.texImage2D(this._target,m,a,g,v,0,i,o,null)}},t._getPixelBuffer=function(e,t,n,r,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),i>0&&!this._isWebGL2&&(i=0,no.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,i):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,i),s.readPixels(t,n,r,a,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t._setWrapMode=function(t,n){var r=this._gl,a=this._isWebGL2,i=this._target,o=this._texture,s=o.width,l=o.height;switch(a||t===t7.Clamp||e._isPowerOf2(s)&&e._isPowerOf2(l)||(no.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=t7.Clamp),t){case t7.Clamp:r.texParameteri(i,n,r.CLAMP_TO_EDGE);break;case t7.Repeat:r.texParameteri(i,n,r.REPEAT);break;case t7.Mirror:r.texParameteri(i,n,r.MIRRORED_REPEAT)}},t._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},e._isPowerOf2=function(e){return(e&e-1)==0},e._getFormatDetail=function(e,t,n){switch(e){case t9.R8G8B8:return{internalFormat:n?t.RGB8:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R8G8B8A8:return{internalFormat:n?t.RGBA8:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R4G4B4A4:return{internalFormat:n?t.RGBA4:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case t9.R5G5B5A1:return{internalFormat:n?t.RGB5_A1:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case t9.R5G6B5:return{internalFormat:n?t.RGB565:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case t9.Alpha8:return{internalFormat:t.ALPHA,baseFormat:t.ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.LuminanceAlpha:return{internalFormat:t.LUMINANCE_ALPHA,baseFormat:t.LUMINANCE_ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R11G11B10_UFloat:return{internalFormat:n?t.R11F_G11F_B10F:t.NONE,baseFormat:t.RGB,dataType:t.FLOAT,isCompressed:!1};case t9.R16G16B16A16:return{internalFormat:n?t.RGBA16F:t.RGBA,baseFormat:t.RGBA,dataType:t.HALF_FLOAT,isCompressed:!1};case t9.R32G32B32A32:return{internalFormat:n?t.RGBA32F:t.RGBA,baseFormat:t.RGBA,dataType:t.FLOAT,isCompressed:!1};case t9.R32G32B32A32_UInt:return{internalFormat:n?t.RGBA32UI:t.NONE,baseFormat:t.RGBA_INTEGER,dataType:t.UNSIGNED_INT,isCompressed:!1};case t9.BC1:return{internalFormat:sL.RGB_S3TC_DXT1_EXT,isCompressed:!0};case t9.BC3:return{internalFormat:sL.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case t9.BC7:return{internalFormat:sL.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case t9.ETC1_RGB:return{internalFormat:sL.RGB_ETC1_WEBGL,isCompressed:!0};case t9.ETC2_RGB:return{internalFormat:sL.RGB8_ETC2,isCompressed:!0};case t9.ETC2_RGBA5:return{internalFormat:sL.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case t9.ETC2_RGBA8:return{internalFormat:sL.RGBA8_ETC2_EAC,isCompressed:!0};case t9.PVRTC_RGB2:return{internalFormat:sL.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGBA2:return{internalFormat:sL.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGB4:return{internalFormat:sL.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGBA4:return{internalFormat:sL.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case t9.ASTC_4x4:return{internalFormat:sL.RGBA_ASTC_4X4_KHR,isCompressed:!0};case t9.ASTC_5x5:return{internalFormat:sL.RGBA_ASTC_5X5_KHR,isCompressed:!0};case t9.ASTC_6x6:return{internalFormat:sL.RGBA_ASTC_6X6_KHR,isCompressed:!0};case t9.ASTC_8x8:return{internalFormat:sL.RGBA_ASTC_8X8_KHR,isCompressed:!0};case t9.ASTC_10x10:return{internalFormat:sL.RGBA_ASTC_10X10_KHR,isCompressed:!0};case t9.ASTC_12x12:return{internalFormat:sL.RGBA_ASTC_12X12_KHR,isCompressed:!0};case t9.Depth:return{internalFormat:n?t.DEPTH_COMPONENT32F:t.DEPTH_COMPONENT,baseFormat:t.DEPTH_COMPONENT,dataType:n?t.FLOAT:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.DepthStencil:return{internalFormat:n?t.DEPTH32F_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:n?t.FLOAT_32_UNSIGNED_INT_24_8_REV:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth16:return{internalFormat:n?t.DEPTH_COMPONENT16:t.DEPTH_COMPONENT,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth24Stencil8:return{internalFormat:n?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32Stencil8:return{internalFormat:t.DEPTH32F_STENCIL8,baseFormat:t.DEPTH_STENCIL,dataType:t.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+e)}},e._getRenderBufferDepthFormatDetail=function(e,t,n){switch(e){case t9.Depth:return{internalFormat:n?t.DEPTH_COMPONENT32F:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:n?t.FLOAT:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.DepthStencil:return{internalFormat:n?t.DEPTH32F_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:n?t.FLOAT_32_UNSIGNED_INT_24_8_REV:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Stencil:return{internalFormat:t.STENCIL_INDEX8,baseFormat:t.STENCIL_ATTACHMENT,dataType:t.UNSIGNED_BYTE,isCompressed:!1,attachment:t.STENCIL_ATTACHMENT};case t9.Depth16:return{internalFormat:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth24Stencil8:return{internalFormat:n?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32Stencil8:return{internalFormat:t.DEPTH32F_STENCIL8,baseFormat:t.DEPTH_STENCIL,dataType:t.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+e)}},e._supportTextureFormat=function(e,t){switch(e){case t9.R16G16B16A16:if(!t.canIUse(nJ.textureHalfFloat))return!1;break;case t9.R32G32B32A32:if(!t.canIUse(nJ.textureFloat))return!1;break;case t9.Depth16:case t9.Depth24Stencil8:case t9.Depth:case t9.DepthStencil:if(!t.canIUse(nJ.depthTexture))return!1;break;case t9.R11G11B10_UFloat:case t9.R32G32B32A32_UInt:case t9.Depth24:case t9.Depth32:case t9.Depth32Stencil8:return t.isWebGL2}return!0},e._supportRenderBufferColorFormat=function(e,t){var n=!0;switch(e){case t9.R16G16B16A16:t.canIUse(nJ.colorBufferHalfFloat)&&t.canIUse(nJ.textureHalfFloat)||(n=!1);break;case t9.R32G32B32A32:t.canIUse(nJ.colorBufferFloat)&&t.canIUse(nJ.textureFloat)||(n=!1);break;case t9.R11G11B10_UFloat:n=t.isWebGL2}return n},e._supportRenderBufferDepthFormat=function(e,t){if(!t.isWebGL2)switch(e){case t9.Depth24:case t9.Depth32:case t9.Depth32Stencil8:return!1}return!0},sB(e,[{key:"wrapModeU",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(e){var t=this._gl,n=this._target,r=this._texture._mipmap;switch(this._bind(),e){case t5.Point:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.NEAREST_MIPMAP_NEAREST:t.NEAREST);break;case t5.Bilinear:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.LINEAR_MIPMAP_NEAREST:t.LINEAR);break;case t5.Trilinear:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.LINEAR_MIPMAP_LINEAR:t.LINEAR)}}},{key:"anisoLevel",set:function(e){var t=this._gl;this._bind(),t.texParameterf(this._target,t.TEXTURE_MAX_ANISOTROPY_EXT,e)}},{key:"depthCompareFunction",set:function(e){this._bind();var t=this._gl;switch(e){case t8.Never:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NEVER);break;case t8.Less:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LESS);break;case t8.Equal:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.EQUAL);break;case t8.LessEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LEQUAL);break;case t8.Greater:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GREATER);break;case t8.NotEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NOTEQUAL);break;case t8.GreaterEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GEQUAL);break;case t8.Always:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.ALWAYS)}}}]),e}(),sK=/*#__PURE__*/function(){function e(e,t){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=t;for(var n=t._colorTextures,r=t._depth,a=t.width,i=t.height,o=sN(r,ns),s=0,l=n.length;s<l;s++){var c=n[s]._format;if(!sX._supportRenderBufferColorFormat(c,e))throw Error("TextureFormat is not supported:"+t9[c]+" in RenderTarget")}if(!o&&!sX._supportRenderBufferDepthFormat(r,e))throw Error("TextureFormat is not supported:"+t9[r]+" in RenderTarget");if(n.length>1&&!e.canIUse(nJ.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==a||e.height!==i}))throw Error("ColorTexture's size must as same as RenderTarget");if(o&&(r.width!==a||r.height!==i))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return sN(e,nd)}))throw Error("MRT+Cube+[,MSAA] is not supported");var u=e.capability.maxAntiAliasing;t.antiAliasing>u&&(no.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+u),t._antiAliasing=u),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),t.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}var t=e.prototype;return t.activeRenderTarget=function(e,t){var n=this._gl,r=this._target;n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer);var a=e!==this._curMipLevel,i=t!==this._curFaceIndex,o=r.getColorTexture(0);if(o){var s=sN(o,nd);(a||s&&i)&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,s?n.TEXTURE_CUBE_MAP_POSITIVE_X+t:n.TEXTURE_2D,o._platformTexture._glTexture,e)}var l=r.depthTexture;if(l){var c=sN(l,nd);if(a||c){var u=l._platformTexture;n.framebufferTexture2D(n.FRAMEBUFFER,u._formatDetail.attachment,c?n.TEXTURE_CUBE_MAP_POSITIVE_X+t:n.TEXTURE_2D,u._glTexture,e)}}else if(a){var d=sX._getRenderBufferDepthFormatDetail(r._depth,n,this._isWebGL2).internalFormat;n.bindRenderbuffer(n.RENDERBUFFER,this._depthRenderBuffer),n.renderbufferStorage(n.RENDERBUFFER,d,r.width>>e,r.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&n.bindFramebuffer(n.FRAMEBUFFER,this._MSAAFrameBuffer)},t.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),n=this._target,r=n.colorTextureCount,a=n.width,i=n.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<r;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,a,i,0,0,a,i,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},t.destroy=function(){var e=this._gl;this._frameBuffer&&e.deleteFramebuffer(this._frameBuffer),this._depthRenderBuffer&&e.deleteRenderbuffer(this._depthRenderBuffer),this._MSAAFrameBuffer&&e.deleteFramebuffer(this._MSAAFrameBuffer),this._MSAADepthRenderBuffer&&e.deleteRenderbuffer(this._MSAADepthRenderBuffer);for(var t=0;t<this._MSAAColorRenderBuffers.length;t++)e.deleteRenderbuffer(this._MSAAColorRenderBuffers[t]);this._frameBuffer=null,this._depthRenderBuffer=null,this._MSAAFrameBuffer=null,this._MSAAColorRenderBuffers.length=0,this._MSAADepthRenderBuffer=null},t._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,n=this._target,r=n._depth,a=n.colorTextureCount,i=n.width,o=n.height,s=Array(a);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<a;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,sN(c,nd)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(sN(r,ns)&&!sN(r,nd)){var d=r._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,d._formatDetail.attachment,e.TEXTURE_2D,d._glTexture,0)}else if(this._target.antiAliasing<=1){var h=sX._getRenderBufferDepthFormatDetail(r,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,i,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,n=e.createRenderbuffer(),r=this._target,a=r._depth,i=r.colorTextureCount,o=r.antiAliasing,s=r.width,l=r.height;this._blitDrawBuffers=Array(i),this._MSAADepthRenderBuffer=n,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<i;c++){var u=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=u,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,u),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,u)}if(e.drawBuffers(this._oriDrawBuffers),null!==a){var d=sN(a,ns)?a._platformTexture._formatDetail:sX._getRenderBufferDepthFormatDetail(a,e,t),h=d.internalFormat,_=d.attachment;e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,h,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,n)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._checkFrameBuffer=function(){var e=this._gl,t=this._isWebGL2,n=e.checkFramebufferStatus(e.FRAMEBUFFER);switch(n){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw Error("The attachment types are mismatched or not all framebuffer attachment points are framebuffer attachment complete");case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw Error("There is no attachment");case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw Error(" Height and width of the attachment are not the same.");case e.FRAMEBUFFER_UNSUPPORTED:throw Error("The format of the attachment is not supported or if depth and stencil attachments are not the same renderbuffer")}if(t&&n===e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE)throw Error("The values of gl.RENDERBUFFER_SAMPLES are different among attached renderbuffers, or are non-zero if the attached images are a mix of renderbuffers and textures.")},e}(),sY=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var r,a=n.format,i=n._mipmap,o=n.width,s=n.height,l=r._isWebGL2;if(!sX._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return!i||l||sX._isPowerOf2(o)&&sX._isPowerOf2(s)||(no.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),n._mipmap=!1,n._mipmapCount=n._getMipmapCount()),r._formatDetail=sX._getFormatDetail(a,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r}sO(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,d=l.dataType,h=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(a=a||_-n,i=i||f-r,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),h){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,n,r,a,i,c,e):(o.compressedTexImage2D(this._target,t,c,a,i,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,n,r,a,i,u,d,e)},n.setImageSource=function(e,t,n,r,a,i){var o=this._gl,s=this._formatDetail,l=s.internalFormat,c=s.baseFormat,u=s.dataType;this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,+n),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+r),this._texture.usage===t6.Dynamic?o.texImage2D(this._target,t,l,c,u,e):o.texSubImage2D(this._target,t,a||0,i||0,c,u,e)},n.getPixelBuffer=function(t,n,r,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,null,t,n,r,a,i,o)},t}(sX),sq=/*#__PURE__*/function(e){function t(t,n){r=e.call(this,t,n,t.gl.TEXTURE_2D_ARRAY)||this;var r,a=n.format,i=n.width,o=n.height,s=n.length,l=n.mipmapCount;if(!r._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!sX._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return r._bind(),r._formatDetail=sX._getFormatDetail(a,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,i,o,s),r}sO(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;i=i||Math.max(1,this._texture.width>>n)-r,o=o||Math.max(1,this._texture.height>>n)-a,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,n,r,a,e,i,o,s,d,t):c.texSubImage3D(l,n,r,a,e,i,o,s,h,_,t)},n.setImageSource=function(e,t,n,r,a,i,o){var s,l,c=this._gl,u=this._formatDetail,d=u.baseFormat,h=u.dataType;this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,+r),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),c.texSubImage3D(this._target,n,i,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},n.getPixelBuffer=function(e,t,n,r,a,i,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,i,e),s.readPixels(t,n,r,a,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t}(sX),sQ=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var r,a=n.format,i=n._mipmap,o=n.width,s=r._isWebGL2;if(!sX._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return!i||s||sX._isPowerOf2(o)||(no.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),n._mipmap=!1,n._mipmapCount=n._getMipmapCount()),r._formatDetail=sX._getFormatDetail(a,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r}sO(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,u=c.internalFormat,d=c.baseFormat,h=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>n);if(i=i||f-r,o=o||f-a,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<n;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,a,i,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,u,i,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,a,i,o,d,h,t)},n.setImageSource=function(e,t,n,r,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,i||0,o||0,c,u,t)},n.getPixelBuffer=function(t,n,r,a,i,o,s){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,t,n,r,a,i,o,s)},t}(sX),sJ=((e1={})[e1.Auto=0]="Auto",e1[e1.WebGL2=1]="WebGL2",e1[e1.WebGL1=2]="WebGL1",e1),sZ=/*#__PURE__*/function(){function e(e){void 0===e&&(e={}),this._readFrameBuffer=null,this._mainFrameBuffer=null,this._mainFrameWidth=0,this._mainFrameHeight=0,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new tI(null,null,null,null),this._lastScissor=new tI(null,null,null,null),this._lastClearColor=new tO(null,null,null,null),this._scissorEnable=!1;var t=sz({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},e);if(id.platform===tz.IPhone||id.platform===tz.IPad){var n=id.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var r=parseInt(n[1]),a=parseInt(n[2]);15===r&&a>=0&&a<=4&&(t._forceFlush=!0)}}this._options=t,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}var t=e.prototype;return t.init=function(e,t,n){var r,a=this._options,i=e._webCanvas,o=a.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=n,i.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),i.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),i.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=i,(0==o||1==o)&&((r=i.getContext("webgl2",a))||"undefined"!=typeof OffscreenCanvas&&sN(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl2",a)),this._isWebGL2=!0,r&&!r.deleteQuery&&(this._isWebGL2=!1)),r||0!=o&&2!=o||((r=i.getContext("webgl",a))||"undefined"!=typeof OffscreenCanvas&&sN(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},t.createPlatformPrimitive=function(e){return new sW(this,e)},t.createPlatformTexture2D=function(e){return new sY(this,e)},t.createPlatformTexture2DArray=function(e){return new sq(this,e)},t.createPlatformTextureCube=function(e){return new sQ(this,e)},t.createPlatformRenderTarget=function(e){return new sK(this,e)},t.createPlatformBuffer=function(e,t,n,r){return void 0===n&&(n=r8.Static),new sU(this,e,t,n,r)},t.requireExtension=function(e){return this._extensions.requireExtension(e)},t.canIUse=function(e){return this.capability.canIUse(e)},t.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},t.viewport=function(e,t,n,r){var a=this._gl,i=this._lastViewport;(e!==i.x||t!==i.y||n!==i.z||r!==i.w)&&(a.viewport(e,t,n,r),i.set(e,t,n,r))},t.scissor=function(e,t,n,r){var a=this._gl,i=this._lastScissor;if(e!==i.x||t!==i.y||n!==i.z||r!==i.w){var o=this._webCanvas;0===e&&0===t&&n===o.width&&r===o.height?this._scissorEnable&&(a.disable(a.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(a.enable(a.SCISSOR_TEST),this._scissorEnable=!0),a.scissor(e,t,n,r)),i.set(e,t,n,r)}},t.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},t.clearRenderTarget=function(e,t,n){var r=this._gl,a=e._lastRenderState,i=a.blendState.targetBlendState,o=a.depthState,s=a.stencilState,l=0;if(t&rw.Color&&n){l|=r.COLOR_BUFFER_BIT;var c=this._lastClearColor,u=n.r,d=n.g,h=n.b,_=n.a;n&&(u!==c.r||d!==c.g||h!==c.b||_!==c.a)&&(r.clearColor(u,d,h,_),c.set(u,d,h,_)),i.colorWriteMask!==nD.All&&(r.colorMask(!0,!0,!0,!0),i.colorWriteMask=nD.All)}t&rw.Depth&&(l|=r.DEPTH_BUFFER_BIT,!0!==o.writeEnabled&&(r.depthMask(!0),o.writeEnabled=!0)),t&rw.Stencil&&(l|=r.STENCIL_BUFFER_BIT,255!==s.writeMask&&(r.stencilMask(255),s.writeMask=255)),r.clear(l)},t.drawPrimitive=function(e,t,n){e?e.draw(n,t):no.error("draw primitive failed.")},t.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},t.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},t.activeRenderTarget=function(e,t,n,r,a){if(e){var i,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(r,a),i=e.width>>r,o=e.height>>r}else{var s=this._gl;s.bindFramebuffer(s.FRAMEBUFFER,this._mainFrameBuffer),i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight()}var l=i*t.z,c=o*t.w,u=t.x*i,d=n?t.y*o:o-t.y*o-c;this.viewport(u,d,l,c),this.scissor(u,d,l,c)},t.blitInternalRTByBlitFrameBuffer=function(e,t,n,r){if(!this._isWebGL2){no.warn("WebGL1.0 not support blit frame buffer.");return}var a=this._gl,i=e?e._platformRenderTarget._frameBuffer:null,o=t?t._platformRenderTarget._frameBuffer:null,s=this.getMainFrameBufferWidth(),l=this.getMainFrameBufferHeight(),c=e?e.width:s,u=e?e.height:l,d=t.width,h=t.height,_=!e,f=(n&rw.Color)==0,p=(n&rw.Depth)==0,m=(n&rw.Stencil)==0;a.bindFramebuffer(a.READ_FRAMEBUFFER,i),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,o);var g=f?a.COLOR_BUFFER_BIT:0;if(p||m){var v=t._depthFormat;p&&(v===t9.Depth||v>=t9.DepthStencil&&v<=t9.Depth32Stencil8?g|=a.DEPTH_BUFFER_BIT:no.warn("Do not clear depth, or set depth format of target which is "+t9[v]+" now.")),m&&(v===t9.Stencil||v===t9.DepthStencil||v>=t9.Depth24Stencil8||v>=t9.Depth32Stencil8?g|=a.STENCIL_BUFFER_BIT:no.warn("Do not clear stencil, or set stencil format of target which is "+t9[v]+" now."))}var y=r.x*c,x=_?u-r.y*u:u-r.y*u-h;a.blitFramebuffer(y,x,y+d,_?x-h:x+h,0,0,d,h,g,a.NEAREST)},t.copyRenderTargetToSubTexture=function(e,t,n){var r,a=this._gl,i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight(),s=e?e.width:i,l=e?e.height:o,c=t.width,u=t.height,d=!e,h=n.x*s,_=d?l-n.y*l-u:n.y*l,f=null!=(r=null==e?void 0:e._platformRenderTarget._frameBuffer)?r:null;a.bindFramebuffer(a.FRAMEBUFFER,f);var p=t._platformTexture;p._bind(),a.copyTexSubImage2D(p._target,0,0,0,h,_,c,u)},t.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},t.bindTexture=function(e){var t=this._activeTextureID-this._gl.TEXTURE0;this._activeTextures[t]!==e&&(this._gl.bindTexture(e._target,e._glTexture),this._activeTextures[t]=e)},t.setGlobalDepthBias=function(e,t){var n=this._gl,r=0!==e||0!==t;r?(n.enable(n.POLYGON_OFFSET_FILL),n.polygonOffset(t,e)):n.disable(n.POLYGON_OFFSET_FILL),this._enableGlobalDepthBias=r},t.flush=function(){this._gl.flush()},t.forceLoseDevice=function(){this.requireExtension(nJ.WEBGL_lose_context).loseContext()},t.forceRestoreDevice=function(){this.requireExtension(nJ.WEBGL_lose_context).restoreContext()},t.resetState=function(){this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._currentBindShaderProgram=null;for(var e=this._activeTextures,t=0,n=e.length;t<n;t++)e[t]=null;this._lastViewport.set(null,null,null,null),this._lastScissor.set(null,null,null,null),this._lastClearColor.set(null,null,null,null),this._scissorEnable=!1,this._initGLState(this._gl)},t._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new sj(e),this._extensions=new sH(this),this._capability=new sG(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),this._contextAttributes=e.getContextAttributes()},t.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},t._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},t._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},t._onWebGLContextRestored=function(e){this._onDeviceRestored()},sB(e,[{key:"isWebGL2",get:function(){return this._isWebGL2}},{key:"renderer",get:function(){return this._renderer}},{key:"gl",get:function(){return this._gl}},{key:"renderStates",get:function(){return this._renderStates}},{key:"capability",get:function(){return this._capability}},{key:"canIUseMoreJoints",get:function(){return this.capability.canIUseMoreJoints}},{key:"context",get:function(){return this._contextAttributes}}]),e}();function s$(){return(s$=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s0(e,t){return(s0=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s1(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s0(e,t)}function s2(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function s3(e,t,r,a){var i,o=arguments.length,s=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function s4(e,t){var n,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function s8(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s5(e,t,n){return t&&s8(e.prototype,t),n&&s8(e,n),e}"function"==typeof SuppressedError&&SuppressedError;var s9=/*#__PURE__*/function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===r&&(r=!0),this.data=e,this._dataView=new DataView(e.buffer,e.byteOffset+t,null!=n?n:e.byteLength-t),this._littleEndian=r,this._position=0,this._baseOffset=t}var t=e.prototype;return t.nextUint8=function(){var e=this._dataView.getUint8(this._position);return this._position+=1,e},t.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},t.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},t.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},t.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},t.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},t.nextUint64=function(){var e=this._dataView.getUint32(this._position,this._littleEndian),t=this._dataView.getUint32(this._position+4,this._littleEndian);return this._position+=8,e+0x100000000*t},t.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,nT.decodeText(t)},t.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},t.nextImagesData=function(e){for(var t=Array(e),n=0;n<e;n++){var r=this._dataView.getUint32(this._position,this._littleEndian);t[n]=r,this._position+=4}for(var a=[],i=0;i<e;i++){var o=t[i],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,a.push(s)}return a},t.skip=function(e){return this._position+=e,this},t.scan=function(e,t){void 0===t&&(t=0);for(var n=this._position,r=0;this._dataView.getUint8(this._position)!==t&&r<e;)r++,this._position++;return r<e&&this._position++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,r)},s5(e,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),e}(),s6={};function s7(e){return function(t){s6[e]=t}}var le=/*#__PURE__*/function(){function e(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}return e.decode=function(t){var n=new DataView(t),r=n.getUint32(0,!0),a=n.getUint8(4),i=n.getUint16(5,!0),o=new Uint8Array(t,7,i),s=n.getUint16(7+i,!0),l=new Uint8Array(t,9+i,s),c=nT.decodeText(l),u=nT.decodeText(o),d=new e;return d.totalLength=r,d.name=c,d.type=u,d.version=a,d.headerLength=l.byteLength+o.byteLength+9,d},s5(e,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),e}();function lt(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tI(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function ln(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tT(e[3*r],e[3*r+1],e[3*r+2]);return n}function lr(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tB(e[2*r],e[2*r+1]);return n}function la(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(la=function(){return!!e})()}function li(e,t,n){return(li=la()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&s0(a,n.prototype),a}).apply(null,arguments)}e.MeshDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n){var r=new aM(e),a=JSON.parse(t.nextStr());a.bounds&&r.bounds.copyFrom(a.bounds);var i=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,a.positions.start+i,(a.positions.end-a.positions.start)/4),l=s.length/3,c=ln(s,l);if(r.setPositions(c),a.normals){var u=ln(new Float32Array(o,a.normals.start+i,(a.normals.end-a.normals.start)/4),l);r.setNormals(u)}if(a.uvs){var d=new Float32Array(o,a.uvs.start+i,(a.uvs.end-a.uvs.start)/4);r.setUVs(lr(d,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);r.setUVs(lr(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);r.setUVs(lr(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);r.setUVs(lr(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);r.setUVs(lr(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);r.setUVs(lr(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);r.setUVs(lr(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);r.setUVs(lr(v,l),7)}if(a.colors){var y=new Float32Array(o,a.colors.start+i,(a.colors.end-a.colors.start)/4);r.setColors(function(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tO(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}(y,l))}if(a.boneWeights){var x=new Float32Array(o,a.boneWeights.start+i,(a.boneWeights.end-a.boneWeights.start)/4);r.setBoneWeights(lt(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);r.setBoneIndices(lt(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new am(e.name);e.frames.forEach(function(e){var n=new Float32Array(o,e.deltaPosition.start+i,(e.deltaPosition.end-e.deltaPosition.start)/4),r=n.length/3,a=ln(n,r);e.deltaNormals&&ln(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),r),e.deltaTangents&&lt(new Float32Array(o,e.deltaTangents.start+i,(e.deltaTangents.end-e.deltaTangents.start)/4),r),t.addFrame(e.weight,a)}),r.addBlendShape(t)}),a.indices){var C=null;C=0===a.indices.type?new Uint16Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/2):new Uint32Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/4),r.setIndices(C)}a.subMeshes.forEach(function(e){return r.addSubMesh(e)}),r.uploadData(!1),n(r)})},e}(),e.MeshDecoder=s3([s7("Mesh")],e.MeshDecoder),e.Texture2DDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n,r){var a=t.nextStr(),i=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new nc(e,d,h,u,i);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),i){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[a]=m,n(m)}else{var x=new window.Blob([p[0]]),b=new Image;b.onload=function(){m.setImageSource(b);var e=0,t=function(){++e>=f&&n(m)};if(t(),i){var r=function(e){var n=new window.Blob([p[e]]),r=new Image;r.onload=function(){m.setImageSource(r,e),t()},r.src=URL.createObjectURL(n)};m.generateMipmaps();for(var a=1;a<f;a++)r(a)}},b.src=URL.createObjectURL(x)}})},e}(),e.Texture2DDecoder=s3([s7("Texture2D")],e.Texture2DDecoder);var lo=((e2={})[e2.Prefab=0]="Prefab",e2[e2.Scene=1]="Scene",e2),ls=/*#__PURE__*/function(){function e(e,t,n){void 0===t&&(t=1),this.engine=e,this.type=t,this.resource=n,this.entityMap=new Map,this.entityConfigMap=new Map,this.components=new Map,this.rootIds=[],this.strippedIds=[],this.resourceManager=e.resourceManager}return e.prototype.clear=function(){this.entityMap.clear(),this.components.clear(),this.entityConfigMap.clear(),this.rootIds.length=0,this.strippedIds.length=0},e}(),ll=/*#__PURE__*/function(){function e(e){this._context=e}var t=e.prototype;return t.parseEntity=function(e){var t=this;return this._getEntityByConfig(e).then(function(n){n.isActive=null==(r=e.isActive)||r;var r,a,i=e.position,o=e.rotation,s=e.scale;return i&&n.transform.position.copyFrom(i),o&&n.transform.rotation.copyFrom(o),s&&n.transform.scale.copyFrom(s),n.layer=null!=(a=e.layer)?a:n.layer,t._context.type===lo.Prefab&&n._markAsTemplate(t._context.resource),n})},t.parseClassObject=function(e){var t,n=this,r=ol.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return n.parseBasicType(e)})).then(function(e){return li(r,[].concat(e))}).then(function(t){return n.parsePropsAndMethods(t,e)})},t.parsePropsAndMethods=function(t,n){var r=[];if(n.methods)for(var a in n.methods)for(var i=n.methods[a],o=0,s=i.length;o<s;o++)r.push(this.parseMethod(t,a,i[o]));if(n.props){var l,c=function(e){var a=n.props[e],i=l.parseBasicType(a,t[e]).then(function(n){return t[e]=n});r.push(i)};for(var u in n.props)l=this,c(u)}return Promise.all(r).then(function(){var r=e.customParseComponentHandles[t.constructor.name];return r?r(t,n):t})},t.parseMethod=function(e,t,n){var r=this;return Promise.all(n.map(function(e){return r.parseBasicType(e)})).then(function(n){return e[t].apply(e,[].concat(n))})},t.parseBasicType=function(t,n){var r=this;if(Array.isArray(t))return Promise.all(t.map(function(e){return r.parseBasicType(e)}));if((void 0===t?"undefined":s2(t))==="object"&&null!=t){if(e._isClass(t))return this.parseClassObject(t);if(e._isAssetRef(t)){var a=this._context;return a.resourceManager.getResourceByRef(t).then(function(e){return a.type===lo.Prefab&&a.resource._addDependenceAsset(e),e})}if(e._isEntityRef(t))return Promise.resolve(this._context.entityMap.get(t.entityId));if(n){var i,o=function(e){if("methods"===e){var r=t[e];for(var a in r)for(var o=r[a],l=0,c=o.length;l<c;l++){var u=o[l];s.push(i.parseMethod(n,a,u))}}else s.push(i.parseBasicType(t[e],n[e]).then(function(t){return n[e]=t}))},s=[];for(var l in t)i=this,o(l);return Promise.all(s).then(function(){return n})}}return Promise.resolve(t)},t._getEntityByConfig=function(e){var t=this,n=e.assetRefId,r=this._context.engine;return n?r.resourceManager.getResourceByRef({refId:n,key:e.key,isClone:e.isClone}).then(function(a){var i=r.resourceManager._objectPool[n];return t._context.type===lo.Prefab&&t._context.resource._addDependenceAsset(i),a.name=e.name,a}):Promise.resolve(new aW(r,e.name))},e.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},e._isClass=function(e){return void 0!=e.class},e._isAssetRef=function(e){return void 0!=e.refId},e._isEntityRef=function(e){return void 0!=e.entityId},e}();ll.customParseComponentHandles=new Map;var lc=((e3={})[e3.Float=0]="Float",e3[e3.FloatArray=1]="FloatArray",e3[e3.Vector2=2]="Vector2",e3[e3.Vector3=3]="Vector3",e3[e3.Vector4=4]="Vector4",e3[e3.Quaternion=5]="Quaternion",e3[e3.Color=6]="Color",e3[e3.Array=7]="Array",e3[e3.Boolean=8]="Boolean",e3[e3.Rect=9]="Rect",e3[e3.ReferResource=10]="ReferResource",e3);e.AnimationClipDecoder=/*#__PURE__*/function(){function t(){}return t.decode=function(t,n){return new Promise(function(t){for(var r=new ov(n.nextStr()),a=n.nextUint16(),i=0;i<a;++i){var o=new og;o.time=n.nextFloat32(),o.functionName=n.nextStr(),o.parameter=JSON.parse(n.nextStr()).val,r.addEvent(o)}for(var s=n.nextUint16(),l=0;l<s;++l){var c=n.nextStr(),u=n.nextStr(),d=ol.getClass(u),h=n.nextStr(),_=n.nextStr(),f=void 0,p=n.nextUint8(),m=n.nextUint16();switch(n.nextStr()){case"AnimationFloatCurve":(f=new e.AnimationFloatCurve).interpolation=p;for(var g=0;g<m;++g){var v=new oU;v.time=n.nextFloat32(),v.value=n.nextFloat32(),v.inTangent=n.nextFloat32(),v.outTangent=n.nextFloat32(),f.addKey(v)}break;case"AnimationArrayCurve":(f=new e.AnimationArrayCurve).interpolation=p;for(var y=0;y<m;++y){var x=new oU;x.time=n.nextFloat32();var b=n.nextUint16();x.value=Array.from(n.nextFloat32Array(b)),x.inTangent=Array.from(n.nextFloat32Array(b)),x.outTangent=Array.from(n.nextFloat32Array(b)),f.addKey(x)}break;case"AnimationFloatArrayCurve":(f=new e.AnimationFloatArrayCurve).interpolation=p;for(var C=0;C<m;++C){var S=new oU;S.time=n.nextFloat32();var T=n.nextUint16();S.value=n.nextFloat32Array(T),S.inTangent=Array.from(n.nextFloat32Array(T)),S.outTangent=Array.from(n.nextFloat32Array(T)),f.addKey(S)}break;case"AnimationVector2Curve":(f=new e.AnimationVector2Curve).interpolation=p;for(var A=0;A<m;++A){var E=new oU;E.time=n.nextFloat32(),E.value=new tB(n.nextFloat32(),n.nextFloat32()),E.inTangent=new tB(n.nextFloat32(),n.nextFloat32()),E.outTangent=new tB(n.nextFloat32(),n.nextFloat32()),f.addKey(E)}break;case"AnimationVector3Curve":(f=new e.AnimationVector3Curve).interpolation=p;for(var R=0;R<m;++R){var M=new oU;M.time=n.nextFloat32(),M.value=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(M)}break;case"AnimationVector4Curve":(f=new e.AnimationVector4Curve).interpolation=p;var w=new oU;w.time=n.nextFloat32(),w.value=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(w);break;case"AnimationColorCurve":(f=new e.AnimationColorCurve).interpolation=p;for(var P=0;P<m;++P){var F=new oU;F.time=n.nextFloat32(),F.value=new tO(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(F)}break;case"AnimationQuaternionCurve":(f=new e.AnimationQuaternionCurve).interpolation=p;for(var L=0;L<m;++L){var D=new oU;D.time=n.nextFloat32(),D.value=new tF(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(D)}break;case"AnimationRefCurve":(f=new e.AnimationRefCurve).interpolation=p;for(var B=0;B<m;++B){var I=new oU;I.time=n.nextFloat32();var O=n.nextStr();O?I.value=JSON.parse(O):I.value=null,f.addKey(I)}break;case"AnimationBoolCurve":(f=new e.AnimationBoolCurve).interpolation=p;for(var N=0;N<m;++N){var V=new oU;V.time=n.nextFloat32(),V.value=1===n.nextUint8(),f.addKey(V)}break;case"AnimationStringCurve":(f=new e.AnimationStringCurve).interpolation=p;for(var k=0;k<m;++k){var z=new oU;z.time=n.nextFloat32(),z.value=n.nextStr(),f.addKey(z)}}r.addCurveBinding(c,d,h,_,f)}t(r)})},t}(),e.AnimationClipDecoder=s3([s7("AnimationClip")],e.AnimationClipDecoder);var lu=((e4={}).Vector2="Vector2",e4.Vector3="Vector3",e4.Vector4="Vector4",e4.Color="Color",e4.Float="Float",e4.Texture="Texture",e4.Boolean="Boolean",e4.Integer="Integer",e4),ld=((e8={}).Sky="Sky",e8.Custom="Custom",e8);function lh(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function l_(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function lf(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l_(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l_(e,void 0)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var lp=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r._dependenceAssets=new Set,r}s1(t,e);var n=t.prototype;return n.instantiate=function(){var e;return null==(e=this._root)?void 0:e.clone()},n._addDependenceAsset=function(e){this._dependenceAssets.add(e),e._associationSuperResource(this)},n._onDestroy=function(){var t=this;e.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(e){e._disassociationSuperResource(t)})},t}(t1),lm=/*#__PURE__*/function(){function e(e,t){var n=this;this.data=e,this.context=t,this._prefabContextMap=new WeakMap,this._prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,t){n._reject=t,n._resolve=e}),this._reflectionParser=new ll(t)}var t=e.prototype;return t.start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},t._parseEntities=function(){var e=this,t=this.data.entities,n=this.context.entityConfigMap,r=this.context.entityMap,a=this._engine;return Promise.all(t.map(function(t){var r,i=null!=(r=t.strippedId)?r:t.id;return t.id=i,n.set(i,t),e._getEntityByConfig(t,a)})).then(function(e){for(var n=0,a=e.length;n<a;n++)r.set(t[n].id,e[n]);return e})},t._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,n=this.context.components,r=[],a=0,i=e.length;a<i;a++)for(var o=e[a],s=t.get(o.id),l=0;l<o.components.length;l++){var c=o.components[l],u=c.refId?c.refId:c.class,d=s.addComponent(ol.getClass(u));n.set(c.id,d);var h=this._reflectionParser.parsePropsAndMethods(d,c);r.push(h)}return Promise.all(r)},t._parsePrefabModification=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.modifications;if(null==l?void 0:l.length){var c=n.get(s);r.push.apply(r,[].concat(l.map(function(t){var n=t.target,r=t.props,a=t.methods,i=n.entityId,o=n.componentId,s=e._prefabContextMap.get(c),l=s.entityMap.get(i),u=s.components.get(o);return u?e._reflectionParser.parsePropsAndMethods(u,{props:r,methods:a}):l?Promise.resolve(e._applyEntityData(l,r)):void 0})))}}(a);return Promise.all(r)},t._parsePrefabRemovedEntities=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedEntities;if(null==l?void 0:l.length){var c=n.get(s);r.push.apply(r,[].concat(l.map(function(t){var n=t.entityId,r=e._prefabContextMap.get(c).entityMap.get(n);r&&r.destroy()})))}}(a);return Promise.all(r)},t._parsePrefabRemovedComponents=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedComponents;if(null==l?void 0:l.length){var c=n.get(s);r.concat.apply(r,[].concat(l.map(function(t){var n=t.componentId,r=e._prefabContextMap.get(c).components.get(n);r&&r.destroy()})))}}(a);return Promise.all(r)},t._organizeEntities=function(){for(var e,t=this.context,n=t.rootIds,r=t.strippedIds,a=n.concat(r),i=lf(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<n.length;s++)this._handleRootEntity(n[s])},t._getEntityByConfig=function(e,t){var n=this;return(e.assetRefId?this._parsePrefab(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return n._applyEntityData(t,e)})},t._parseEntity=function(e,t){var n=new aW(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(n)},t._parsePrefab=function(e,t){var n=this,r=e.assetRefId;return t.resourceManager.getResourceByRef({refId:r}).then(function(r){var a=lh(r,lp)?r.instantiate():r.instantiateSceneRoot(),i=new ls(t,lo.Prefab,null);e.parent||n.context.rootIds.push(e.id),n._generateInstanceContext(a,i,""),n._prefabContextMap.set(a,i);var o=n._prefabPromiseMap.get(e.id);if(o)for(var s=0,l=o.length;s<l;s++)o[s].resolve(i);return a})},t._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(n,r){var a,i=null!=(a=t._prefabPromiseMap.get(e.prefabInstanceId))?a:[];i.push({resolve:n,reject:r}),t._prefabPromiseMap.set(e.prefabInstanceId,i)}).then(function(t){var n=e.prefabSource.entityId;return t.entityMap.get(n)})},t._parseChildren=function(e){var t=this.context,n=t.entityConfigMap,r=t.entityMap,a=n.get(e).children;if(a&&a.length>0)for(var i=r.get(e),o=0;o<a.length;o++){var s=a[o],l=r.get(s);i.addChild(l),this._parseChildren(s)}},t._applyEntityData=function(e,t){void 0===t&&(t={}),e.isActive=null!=(n=t.isActive)?n:e.isActive,e.name=null!=(r=t.name)?r:e.name;var n,r,a=t.position,i=t.rotation,o=t.scale,s=t.layer;return a&&e.transform.position.copyFrom(a),i&&e.transform.rotation.copyFrom(i),o&&e.transform.scale.copyFrom(o),s&&(e.layer=s),e},t._generateInstanceContext=function(e,t,n){var r=t.entityMap,a=t.components,i={},o={};r.set(n,e),e._components.forEach(function(t){var r=ol.getClassName(t.constructor);i[r]||(i[r]=e.getComponents(t.constructor,[]),o[r]=0),a.set(n+":"+r+"/"+o[r]++,t)});for(var s=0,l=e.children.length;s<l;s++){var c=e.children[s],u=n?n+"/"+s:""+s;this._generateInstanceContext(c,t,u)}},e}(),lg=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).scene=r,a}s1(t,e);var n=t.prototype;return n._handleRootEntity=function(e){var t=this.context.entityMap;this.scene.addRootEntity(t.get(e))},n._clearAndResolve=function(){return this.context.clear(),this.scene},t.parse=function(e,n){var r=new oo(e),a=new t(n,new ls(e,lo.Scene,r),r);return a.start(),a.promise.then(function(){return r})},t}(lm);function lv(e,t){var n=le.decode(e),r=new s9(new Uint8Array(e),n.headerLength,n.dataLength);return s6[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.EditorTextureLoader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){lv(e,t.engine).then(function(e){n(e)})}).catch(r)})},t}(ol),e.EditorTextureLoader=s3([it("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var ly=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){return lv(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){return n._parseKeyframeValue(e,t).then(function(t){e.value=t})}))})).then(function(){r(e)})}).catch(a)}).catch(a)})},n._parseKeyframeValue=function(e,t){var n=e.value;return(void 0===n?"undefined":s2(n))==="object"&&(null==n?void 0:n.refId)?new Promise(function(r){t.getResourceByRef(n).then(function(t){e.value=t,r(e.value)})}):Promise.resolve(e.value)},t}(ol);ly=s3([it(a2.AnimationClip,["ani"])],ly);var lx=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){var a=new oI(t.engine),i=e.layers,o=e.parameters,s=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,l=e.weight,c=e.stateMachine,u=new oz(i);if(u.blendingMode=o,u.weight=l,c){var d=c.states,h=c.transitions,_=c.entryTransitions,f=c.anyTransitions,p=u.stateMachine,m={},g={};d.forEach(function(e,n){var a=e.id,i=e.name,o=e.speed,l=e.wrapMode,c=e.clipStartNormalizedTime,u=e.clipEndNormalizedTime,d=e.clip,h=e.scripts,_=p.addState(i);_.speed=o,_.wrapMode=l,_.clipStartTime=c,_.clipEndTime=u,h.forEach(function(e){_.addStateMachineScript(ol.getClass(e))}),m[a]=_,d&&s.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:r,stateIndex:n,clip:t})})}))}),h.forEach(function(e){var t=n._createTransition(e,m[e.destinationStateId]);g[e.id]=t}),d.forEach(function(e){var t=e.id;e.transitions.forEach(function(e){var n=g[e];n&&m[t].addTransition(n)})}),_.forEach(function(e){p.addEntryStateTransition(n._createTransition(e,m[e.destinationStateId]))}),f.forEach(function(e){p.addAnyStateTransition(n._createTransition(e,m[e.destinationStateId]))})}a.addLayer(u)}),o.forEach(function(e){e.isTrigger?a.addTriggerParameter(e.name):a.addParameter(e.name,e.defaultValue)}),Promise.all(s).then(function(e){e.forEach(function(e){var t=e.layerIndex,n=e.stateIndex,r=e.clip;a.layers[t].stateMachine.states[n].clip=r}),r(a)})}).catch(a)})},n._createTransition=function(e,t){var n=new oM;return n.hasExitTime=e.hasExitTime,n.isFixedDuration=e.isFixedDuration,n.duration=e.duration,n.offset=e.offset,n.exitTime=e.exitTime,n.solo=e.solo,n.mute=e.mute,n._isExit=e.isExit,n.destinationState=t,e.conditions.forEach(function(e){n.addCondition(e.parameterName,e.mode,e.threshold)}),n},t}(ol);lx=s3([it(a2.AnimatorController,["json"],!1)],lx);var lb=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=e.url;return/^data:(.+?);base64,/.test(n)?new a8(function(e){var t=n.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(t),function(e){return e.charCodeAt(0)}).buffer)}):t._request(n,s$({},e,{type:"arraybuffer"}))},t}(ol);lb=s3([it(a2.Buffer,["bin","r3bin"],!1)],lb);var lC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,n){return new a8(function(r,a){var i=s$({},e,{type:"arraybuffer"}),o=n.engine;n._request(e.url,i).then(function(n){var a=t._setTextureByBuffer(o,n);o.resourceManager.addContentRestorer(new lS(a,e.url,i));var s=new i8(o),l=new tV;s.diffuseMode=i4.SphericalHarmonics,l.copyFromArray(new Float32Array(n,0,27)),s.diffuseSphericalHarmonics=l,s.specularTexture=a,s.specularTextureDecodeRGBM=!0,r(s)}).catch(function(e){a(e)})})},t._setTextureByBuffer=function(e,t,n){var r=new Uint16Array(t,108,1)[0];n||(n=new nd(e,r)),n.filterMode=t5.Trilinear;for(var a=n.mipmapCount,i=110,o=0;o<a;o++)for(var s=r>>o,l=0;l<6;l++){var c=s*s*4,u=new Uint8Array(t,i,c);i+=c,n.setPixelBuffer(t4.PositiveX+l,u,o)}return n},t}(ol);lC=s3([it(a2.Env,["env"])],lC);var lS=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){a6(e.url,e.requestConfig).then(function(n){lC._setTextureByBuffer(e.resource.engine,n,e.resource),t(e.resource)}).catch(n)})},t}(t2);function lT(e,t,n,r,a,i,o){try{var s=e[i](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,a)}function lA(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function o(e){lT(i,r,a,o,s,"next",e)}function s(e){lT(i,r,a,o,s,"throw",e)}o(void 0)})}}var lE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){var i=e.fontName,o=e.fontUrl;o?n._registerFont(i,o).then(function(){r(new ng(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):r(new ng(t.engine,i))}).catch(function(e){a(e)})})},n._registerFont=function(e,t){return lA(function(){var n;return s4(this,function(r){switch(r.label){case 0:return[4,(n=new FontFace(e,"url("+t+")")).load()];case 1:return r.sent(),document.fonts.add(n),[2]}})})()},t}(ol);lE=s3([it(a2.Font,["font"],!1)],lE);var lR=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r}s1(t,e);var n=t.prototype;return n.instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this.textures,n=this.materials,r=this.meshes;if(t&&this._disassociationSuperResource(t),n&&this._disassociationSuperResource(n),r)for(var a=0,i=r.length;a<i;a++)this._disassociationSuperResource(r[a])},n._disassociationSuperResource=function(e){for(var t=0,n=e.length;t<n;t++)e[t]._disassociationSuperResource(this)},s5(t,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),t}(t1),lM=((e5={})[e5.BYTE=5120]="BYTE",e5[e5.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e5[e5.SHORT=5122]="SHORT",e5[e5.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e5[e5.UNSIGNED_INT=5125]="UNSIGNED_INT",e5[e5.FLOAT=5126]="FLOAT",e5),lw=((e9={}).SCALAR="SCALAR",e9.VEC2="VEC2",e9.VEC3="VEC3",e9.VEC4="VEC4",e9.MAT2="MAT2",e9.MAT3="MAT3",e9.MAT4="MAT4",e9),lP=((e6={}).TRANSLATION="translation",e6.ROTATION="rotation",e6.SCALE="scale",e6.WEIGHTS="weights",e6),lF=((e7={}).Linear="LINEAR",e7.Step="STEP",e7.CubicSpine="CUBICSPLINE",e7),lL=((te={}).PERSPECTIVE="perspective",te.ORTHOGRAPHIC="orthographic",te),lD=((tt={}).OPAQUE="OPAQUE",tt.MASK="MASK",tt.BLEND="BLEND",tt),lB=((tn={})[tn.NEAREST=9728]="NEAREST",tn[tn.LINEAR=9729]="LINEAR",tn),lI=((tr={})[tr.NEAREST=9728]="NEAREST",tr[tr.LINEAR=9729]="LINEAR",tr[tr.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",tr[tr.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",tr[tr.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",tr[tr.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",tr),lO=((ta={})[ta.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",ta[ta.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",ta[ta.REPEAT=10497]="REPEAT",ta),lN=/*#__PURE__*/function(){function e(e,t,n){var r=this;this.glTFResource=e,this.resourceManager=t,this.params=n,this.accessorBufferCache={},this.needAnimatorController=!1,this._resourceCache=new Map,this._progress={taskDetail:{},taskComplete:{loaded:0,total:0}},this._onTaskDetail=function(e,t,n){var a,i=(a=r._progress.taskDetail)[e]||(a[e]={});i.loaded=t,i.total=n,r._setTaskDetailProgress(e,t,n)},this.contentRestorer=new l2(e)}var t=e.prototype;return t.get=function(t,n){var r=this,a=e._parsers[t];if(!a)return Promise.resolve(null);var i=this._resourceCache,o=void 0===n?""+t:t+":"+n,s=i.get(o);if(s)return s;var l=lz[t],c=!!lU[t];if(l){var u=this.glTF[l];u&&(void 0===n||u[n])?void 0===n?s=8===t?u.map(function(e,n){return r.get(t,n)}):Promise.all(u.map(function(e,n){return r.get(t,n)})):(s=a.parse(this,n),c&&this._handleSubAsset(s,t,n)):s=Promise.resolve(null)}else s=a.parse(this,n),c&&this._handleSubAsset(s,t,n);return i.set(o,s),s},t.parse=function(){var e=this,t=this.get(0).then(function(t){return e.glTF=t,e.needAnimatorController=!!(t.skins||t.animations),Promise.all([e.get(1),e.get(5),e.get(6),e.get(7),e.get(9),e.get(10),e.get(11),e.get(2)]).then(function(){var t=e.glTFResource,n=t.animatorController;return n&&(t._defaultSceneRoot.addComponent(oD).animatorController=n),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},t._addTaskCompletePromise=function(e){var t=this,n=this._progress.taskComplete;n.total+=1,e.then(function(){t._setTaskCompleteProgress(++n.loaded,n.total)},function(){})},t._handleSubAsset=function(e,t,n){var r,a=this,i=lU[t];if(8===t)((r=this.glTFResource)[i]||(r[i]=[]))[n]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==n?a.glTFResource[i]=e:((r=a.glTFResource)[i]||(r[i]=[]))[n]=e,7===t)for(var r,s,l=0,c=e.length;l<c;l++){var u=e[l];a.resourceManager._onSubAssetSuccess(o,i+"["+n+"]["+l+"]",u)}else a.resourceManager._onSubAssetSuccess(o,""+i+(void 0===n?"":"["+n+"]"),e),2===t&&(null!=(s=a.glTF.scene)?s:0)===n&&a.resourceManager._onSubAssetSuccess(o,"defaultSceneRoot",e)})}},e.addParser=function(e,t){this._parsers[e]=t},e}();lN._parsers={};var lV=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},lk=((ti={})[ti.Schema=0]="Schema",ti[ti.Validator=1]="Validator",ti[ti.Scene=2]="Scene",ti[ti.Buffer=3]="Buffer",ti[ti.BufferView=4]="BufferView",ti[ti.Texture=5]="Texture",ti[ti.Material=6]="Material",ti[ti.Mesh=7]="Mesh",ti[ti.Entity=8]="Entity",ti[ti.Skin=9]="Skin",ti[ti.Animation=10]="Animation",ti[ti.AnimatorController=11]="AnimatorController",ti),lz=((th={})[2]="scenes",th[3]="buffers",th[5]="textures",th[6]="materials",th[7]="meshes",th[8]="nodes",th[9]="skins",th[10]="animations",th[4]="bufferViews",th),lU=((t_={})[2]="_sceneRoots",t_[5]="textures",t_[6]="materials",t_[7]="meshes",t_[8]="entities",t_[9]="skins",t_[10]="animations",t_[11]="animatorController",t_);function lG(e){return function(t){var n=new t;lN.addParser(e,n)}}var lH=/*#__PURE__*/function(){function t(){}return t.floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new tB(e[r],e[r+1]);return n},t.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new tT(e[r],e[r+1],e[r+2]);return n},t.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new tI(e[r],e[r+1],e[r+2],e[r+3]);return n},t.floatBufferToColorArray=function(e,t){var n=e.length,r=Array(n/(t?3:4));if(t)for(var a=0;a<n;a+=3)r[a/3]=new tO(e[a],e[a+1],e[a+2],1);else for(var i=0;i<n;i+=4)r[i/4]=new tO(e[i],e[i+1],e[i+2],e[i+3]);return r},t.getAccessorTypeSize=function(e){switch(e){case lw.SCALAR:return 1;case lw.VEC2:return 2;case lw.VEC3:return 3;case lw.VEC4:case lw.MAT2:return 4;case lw.MAT3:return 9;case lw.MAT4:return 16}},t.getComponentType=function(e){switch(e){case lM.BYTE:return Int8Array;case lM.UNSIGNED_BYTE:return Uint8Array;case lM.SHORT:return Int16Array;case lM.UNSIGNED_SHORT:return Uint16Array;case lM.UNSIGNED_INT:return Uint32Array;case lM.FLOAT:return Float32Array}},t.getNormalizedComponentScale=function(e){switch(e){case lM.BYTE:return 1/127;case lM.UNSIGNED_BYTE:return 1/255;case lM.SHORT:return 1/32767;case lM.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},t.getAccessorBuffer=function(e,n,r){var a,i=r.componentType,o=t.getComponentType(i),s=t.getAccessorTypeSize(r.type),l=o.BYTES_PER_ELEMENT,c=s*l,u=r.count;if(void 0!==r.bufferView){var d=r.bufferView,h=n[d];a=e.get(lk.BufferView,r.bufferView).then(function(t){var n,a,_,f=h.buffer,p=null!=(n=t.byteOffset)?n:0,m=null!=(a=r.byteOffset)?a:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=d+":"+i+":"+v+":"+u,x=e.accessorBufferCache;if(!(_=x[y])){var b=p+v*g,C=g/l*u,S=new o(t.buffer,b,C);x[y]=_=new lV(S,!0,g),_.restoreInfo=new l9(new l6(f,o,b,C))}}else{var T=p+m,A=u*s;(_=new lV(new o(t.buffer,T,A),!1,c)).restoreInfo=new l9(new l6(f,o,T,A))}return _})}else{var _=u*s,f=new lV(new o(_),!1,c);f.restoreInfo=new l9(new l6(void 0,o,void 0,_)),a=Promise.resolve(f)}return r.sparse?a.then(function(n){return t.processingSparseData(e,r,n).then(function(){return n})}):a},t.bufferToVector3Array=function(e,n,r,a,i){for(var o=n/e.BYTES_PER_ELEMENT,s=e.length/r,l=Array(r),c=a?t.getNormalizedComponentScale(i):1,u=0;u<r;u++){var d=o+u*s;l[u]=new tT(e[d]*c,e[d+1]*c,e[d+2]*c)}return l},t.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},t.processingSparseData=function(e,n,r){var a=r.restoreInfo,i=e.glTF.bufferViews,o=t.getAccessorTypeSize(n.type),s=t.getComponentType(n.componentType),l=r.data.slice(),c=n.sparse,u=c.count,d=c.indices,h=c.values,_=i[d.bufferView],f=i[h.bufferView];return Promise.all([e.get(lk.BufferView,d.bufferView),e.get(lk.BufferView,h.bufferView)]).then(function(e){var n,i,c,p,m=e[0],g=e[1],v=(null!=(n=d.byteOffset)?n:0)+(null!=(i=m.byteOffset)?i:0),y=m.byteLength,x=(null!=(c=h.byteOffset)?c:0)+(null!=(p=g.byteOffset)?p:0),b=g.byteLength;a.typeSize=o,a.sparseCount=u;var C=t.getComponentType(d.componentType),S=y/C.BYTES_PER_ELEMENT,T=new C(m.buffer,v,S);a.sparseIndices=new l6(_.buffer,C,v,S);var A=b/s.BYTES_PER_ELEMENT,E=new s(g.buffer,x,A);a.sparseValues=new l6(f.buffer,s,x,A);for(var R=0;R<u;R++)for(var M=T[R],w=0;w<o;w++)l[M*o+w]=E[R*o+w];r.data=l})},t.getIndexFormat=function(e){switch(e){case lM.UNSIGNED_BYTE:return r6.UInt8;case lM.UNSIGNED_SHORT:return r6.UInt16;case lM.UNSIGNED_INT:return r6.UInt32}},t.getElementFormat=function(e,t,n){if(void 0===n&&(n=!1),e==lM.FLOAT)switch(t){case 1:return r7.Float;case 2:return r7.Vector2;case 3:return r7.Vector3;case 4:return r7.Vector4}if(e==lM.SHORT)switch(t){case 2:return n?r7.NormalizedShort2:r7.Short2;case 3:case 4:return n?r7.NormalizedShort4:r7.Short4}if(e==lM.UNSIGNED_SHORT)switch(t){case 2:return n?r7.NormalizedUShort2:r7.UShort2;case 3:case 4:return n?r7.NormalizedUShort4:r7.UShort4}if(e==lM.BYTE)switch(t){case 2:case 3:case 4:return n?r7.NormalizedByte4:r7.Byte4}if(e==lM.UNSIGNED_BYTE)switch(t){case 2:case 3:case 4:return n?r7.NormalizedUByte4:r7.UByte4}},t.loadImageBuffer=function(e,t){return new Promise(function(n,r){var a=new window.Blob([e],{type:t}),i=new Image;i.onerror=function(){r(Error("Failed to load image buffer"))},i.onload=function(){requestAnimationFrame(function(){n(i),i.onload=null,i.onerror=null,i.onabort=null})},i.crossOrigin="anonymous",i.src=URL.createObjectURL(a)})},t.parseGLB=function(e,t){var n={JSON:0x4e4f534a,BIN:5130562},r=new DataView(t),a={magic:r.getUint32(0,!0),version:r.getUint32(4,!0),length:r.getUint32(8,!0)};if(0x46546c67!==a.magic)return{originBuffer:t};var i=r.getUint32(12,!0),o=r.getUint32(16,!0);if(o!==n.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+o.toString(16)),null;for(var s=new Uint8Array(t,20,i),l=JSON.parse(nT.decodeText(s)),c=[],u=20+i,d=e.contentRestorer.glbBufferSlices;u<a.length;){if(i=r.getUint32(u,!0),(o=r.getUint32(u+4,!0))!==n.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+o.toString(16)),null;var h=u+8,_=t.slice(h,h+i);c.push(_),d.push(new tB(h,i)),u+=i+8}return{glTF:l,buffers:c}},t.parseSampler=function(e,t){var n=t.filterMode,r=t.wrapModeU,a=t.wrapModeV;void 0!==n&&(e.filterMode=n),void 0!==r&&(e.wrapModeU=r),void 0!==a&&(e.wrapModeV=a)},t.getSamplerInfo=function(t){var n=t.minFilter,r=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(n||r)&&(o.mipmap=n>=lI.NEAREST_MIPMAP_NEAREST,r===lB.NEAREST?o.filterMode=t5.Point:n<=lI.LINEAR_MIPMAP_NEAREST?o.filterMode=t5.Bilinear:o.filterMode=t5.Trilinear),a&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[a]),i&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[i]),o},t}(),lW=((to={})[to.None=0]="None",to[to.BasisLZ=1]="BasisLZ",to[to.Zstd=2]="Zstd",to[to.ZLib=3]="ZLib",to),lj=/*#__PURE__*/function(){function e(e){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.keyValue={},this.globalData=null,this.parse(e)}return e.prototype.parse=function(e){var t=e.buffer,n=e.byteOffset,r=new s9(e,12);this.vkFormat=r.nextUint32(),this.typeSize=r.nextUint32(),this.pixelWidth=r.nextUint32(),this.pixelHeight=r.nextUint32(),this.pixelDepth=r.nextUint32(),this.layerCount=r.nextUint32(),this.faceCount=r.nextUint32();var a=Math.max(1,r.nextUint32());this.supercompressionScheme=r.nextUint32();var i=r.nextUint32(),o=r.nextUint32(),s=r.nextUint32(),l=r.nextUint32(),c=r.nextUint64(),u=r.nextUint64(),d=Array(a),h=24*a,_=new s9(e,r.offset,h);this.levels=d;for(var f=0;f<a;f++)d[f]={levelData:new Uint8Array(t,n+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new s9(e,i,o),m={vendorId:p.skip(4).nextUint16(),descriptorType:p.nextUint16(),versionNumber:p.nextUint16(),descriptorBlockSize:p.nextUint16(),colorModel:p.nextUint8(),colorPrimaries:p.nextUint8(),transferFunction:p.nextUint8(),flags:p.nextUint8(),texelBlockDimension:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],bytesPlane:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],samples:[]};this.dataFormatDescriptor=m;for(var g=(m.descriptorBlockSize/4-6)/4,v=0;v<g;v++){var y={bitOffset:p.nextUint16(),bitLength:p.nextUint8(),channelType:p.nextUint8(),samplePosition:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&y.channelType?(y.sampleLower=p.nextInt32(),y.sampleUpper=p.nextInt32()):(y.sampleLower=p.nextUint32(),y.sampleUpper=p.nextUint32()),m.samples[v]=y}for(var x=new s9(e,s,l,!0);x.position<l;){var b=x.nextUint32(),C=x.scan(b),S=nT.decodeText(C),T=x.nextUint8Array(b-C.byteLength-1);this.keyValue[S]=S.match(/^ktx/i)?nT.decodeText(T).replace(/^(.*)\x00$/,"$1"):T;var A=b%4?4-b%4:0;x.skip(A)}if(u<=0)return this;for(var E=new s9(e,c,u,!0),R=E.nextUint16(),M=E.nextUint16(),w=E.nextUint32(),P=E.nextUint32(),F=E.nextUint32(),L=E.nextUint32(),D=Array(a),B=0;B<a;B++)D[B]={imageFlags:E.nextUint32(),rgbSliceByteOffset:E.nextUint32(),rgbSliceByteLength:E.nextUint32(),alphaSliceByteOffset:E.nextUint32(),alphaSliceByteLength:E.nextUint32()};var I=c+E.position,O=I+w,N=O+P,V=N+F,k=new Uint8Array(t,n+I,w),z=new Uint8Array(t,n+O,P),U=new Uint8Array(t,n+N,F),G=new Uint8Array(t,n+V,L);this.globalData={endpointCount:R,selectorCount:M,imageDescs:D,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},s5(e,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),e}(),lX=((ts={})[ts.ASTC=0]="ASTC",ts[ts.BC7=1]="BC7",ts[ts.BC1_BC3=2]="BC1_BC3",ts[ts.PVRTC=3]="PVRTC",ts[ts.ETC=4]="ETC",ts[ts.R8=5]="R8",ts[ts.R8G8=6]="R8G8",ts[ts.R8G8B8A8=7]="R8G8B8A8",ts),lK=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=4),this.limitedCount=e,this._workerCreator=t,this._taskQueue=[],this._workerStatus=0,this._workerItems=Array(e)}var t=e.prototype;return t.prepareWorker=function(){for(var e=this.limitedCount,t=Array(e),n=0;n<e;n++)t.push(this._initWorker(n));return Promise.all(t)},t.postMessage=function(e){var t=this;return new Promise(function(n,r){var a=t._getIdleWorkerId();if(-1!==a){t._workerStatus|=1<<a;var i,o=t._workerItems;Promise.resolve(null!=(i=o[a])?i:t._initWorker(a)).then(function(){var t=o[a];t.resolve=n,t.reject=r,t.worker.postMessage(e)}).catch(r)}else t._taskQueue.push({resolve:n,reject:r,message:e})})},t.destroy=function(){for(var e=this._workerItems,t=0,n=e.length;t<n;t++){var r=e[t];r.worker.terminate(),r.reject=null,r.resolve=null}e.length=0,this._taskQueue.length=0,this._workerStatus=0},t._initWorker=function(e){var t=this;return Promise.resolve(this._workerCreator()).then(function(n){return n.addEventListener("message",t._onMessage.bind(t,e)),t._workerItems[e]={worker:n,resolve:null,reject:null},n})},t._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},t._onMessage=function(e,t){var n=t.data.error;n?this._workerItems[e].reject(n):this._workerItems[e].resolve(t.data),this._nextTask(e)},t._nextTask=function(e){if(this._taskQueue.length){var t=this._taskQueue.shift(),n=this._workerItems[e];n.resolve=t.resolve,n.reject=t.reject,n.worker.postMessage(t.message)}else this._workerStatus^=1<<e},e}(),lY=/*#__PURE__*/function(){function e(e){this.workerLimitCount=e}var t=e.prototype;return t.init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},t.destroy=function(){this._transcodeWorkerPool.destroy()},t._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new lK(this.workerLimitCount,function(){return new Promise(function(n,r){var a=new Worker(e);a.addEventListener("message",function(e){e.data.error?r(e.data.error):n(a)}),a.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},e}();function lq(){var e,t=function(t){return e||(e=new Promise(function(e,n){var r={wasmBinary:t,onRuntimeInitialized:function(){return e(r)},onAbort:n};self.BASIS(r)}).then(function(e){return e.initializeBasis(),e.KTX2File})),e};self.onmessage=function(e){var n=e.data;switch(n.type){case"init":t(n.transcoderWasm).then(function(){self.postMessage("init-completed")}).catch(function(e){return self.postMessage({error:e})});break;case"transcode":t().then(function(e){var t=lJ(n.buffer,n.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var lQ=function(e){return tl||(tl=new Promise(function(t,n){var r={wasmBinary:e,onRuntimeInitialized:function(){return t(r)},onAbort:n};self.BASIS(r)}).then(function(e){return e.initializeBasis(),e.KTX2File})),tl};function lJ(e,t,n){var r=new n(new Uint8Array(e));function a(){r.close(),r.delete()}if(!r.isValid())throw a(),Error("Invalid or unsupported .ktx2 file");if(!r.startTranscoding())throw a(),Error("KTX2 startTranscoding failed");for(var i=r.getWidth(),o=r.getHeight(),s=r.getLayers()||1,l=r.getLevels(),c=r.getHasAlpha(),u=r.getFaces(),d=function(e,t){switch(e){case 2:return t?3:2;case 4:return t?1:0;case 3:return t?9:8;case 7:return 13;case 0:return 10;case 1:return 7}}(t,c),h=Array(u),_=2===d||3===d||7===d,f=0;f<u;f++){for(var p=Array(l),m=0;m<l;m++){for(var g=Array(s),v=void 0,y=void 0,x=0;x<s;x++){var b=r.getImageLevelInfo(m,x,f);_&&0===m&&(i!==b.width||o!==b.height)?console.warn("KTX2 transcode to BC will resize to width: "+(i=v=b.width)+", height: "+(o=y=b.height)+". You'd better use an image whose size if multiple of 4."):(v=b.origWidth,y=b.origHeight);var C=new Uint8Array(r.getImageTranscodedSizeInBytes(m,x,0,d));if(!r.transcodeImage(C,m,x,f,d,0,-1,-1))throw a(),Error("transcodeImage failed.");g[x]=C}p[m]={data:function(e){if(1===e.length)return e[0];for(var t=0,n=0;n<e.length;n++)t+=e[n].byteLength;for(var r=new Uint8Array(t),a=0,i=0;i<e.length;i++)r.set(e[i],a),a+=e[i].byteLength;return r}(g),width:v,height:y}}h[f]=p}return a(),{faces:h,width:i,height:o,hasAlpha:c,faceCount:u,format:d}}var lZ=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}s1(t,e);var n=t.prototype;return n._initTranscodeWorkerPool=function(){var e=this;return Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*nG8SR6vCgXgAAAAAAAAAAAAAARQnAQ/basis_transcoder.js").then(function(e){return e.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qEUfQ7317KsAAAAAAAAAAAAAARQnAQ/basis_transcoder.wasm").then(function(e){return e.arrayBuffer()})]).then(function(t){var n=t[0],r=t[1];if(0===e.workerLimitCount)return new Promise(function(e,t){var a=document.createElement("script");a.src=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),document.body.appendChild(a),a.onload=function(){lQ(r).then(function(){e(null)})},a.onerror=function(){t()}});var a=lq.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+n+"\n "+lJ.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,r)})},n.transcode=function(e,t){return 0===this.workerLimitCount?lQ().then(function(n){return lJ(e,t,n)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},t}(lY);function l$(){var e,t=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.init=function(){return this._initPromise||(this._initPromise=fetch(e.WasmModuleURL).then(function(e){if(e.ok)return e.arrayBuffer();throw Error("Could not fetch the wasm component for the Zstandard decompression lib: "+e.status+" - "+e.statusText)}).then(function(t){return WebAssembly.instantiate(t,e.IMPORT_OBJECT)}).then(this._init)),this._initPromise},t._init=function(t){e.instance=t.instance,e.IMPORT_OBJECT.env.emscripten_notify_memory_growth()},t.decode=function(t,n){if(void 0===n&&(n=0),!e.instance)throw Error("ZSTDDecoder: Await .init() before decoding.");var r=e.instance.exports,a=t.byteLength,i=r.malloc(a);e.heap.set(t,i),n=n||Number(r.ZSTD_findDecompressedSize(i,a));var o=r.malloc(n),s=r.ZSTD_decompress(o,n,i,a),l=e.heap.slice(o,o+s);return r.free(i),r.free(o),l},e}();t.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){t.heap=new Uint8Array(t.instance.exports.memory.buffer)}}},t.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var n=new t;self.onmessage=function(t){var r,a=t.data;switch(a.type){case"init":(r=a.transcoderWasm,e=WebAssembly.instantiate(r,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(e){return e.instance.exports})).then(function(){self.postMessage("init-completed")}).catch(function(e){self.postMessage({error:e})});break;case"transcode":e.then(function(e){var t,r,i,o,s;(t=a.data,r=a.needZstd,o=Array(i=t.length),s=Promise.resolve(),r&&(n.init(),s=n._initPromise),s.then(function(){for(var a=0;a<i;a++){for(var s=t[a].length,l=Array(s),c=0;c<s;c++){var u=t[a][c],d=u.buffer,h=u.levelHeight,_=u.levelWidth,f=u.uncompressedByteLength;r&&(d=n.decode(d.slice(),f));var p=d.byteLength/i,m=d.byteOffset,g=function(e,t,n,r){var a=(n+3>>2)*(r+3>>2),i=16*a+65535>>16,o=e.memory,s=i+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*a);return l.set(t),0===e.transcode(a)?l:null}(e,new Uint8Array(d.buffer,m+a*p,p),_,h);if(g)l[c]={data:g.slice(),width:_,height:h};else throw"buffer decoded error"}o[a]=l}return o})).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var l0=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).type=n,r}s1(t,e);var n=t.prototype;return n._initTranscodeWorkerPool=function(){var e=this;return fetch(t.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var n=l$.toString(),r=URL.createObjectURL(new Blob([n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(r,t)})},n.transcode=function(e){for(var t=e.supercompressionScheme===lW.Zstd,n=e.levels.length,r=e.faceCount,a={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},i={type:"transcode",format:0,needZstd:t,data:Array(r)},o=i.data,s=0;s<r;s++){for(var l=Array(n),c=0;c<n;c++){var u=e.levels[c],d=Math.floor(e.pixelWidth/(1<<c))||1,h=Math.floor(e.pixelHeight/(1<<c))||1,_=u.levelData.buffer,f=u.levelData.byteOffset,p=u.levelData.byteLength;l[c]={buffer:new Uint8Array(_,f,p),levelWidth:d,levelHeight:h,uncompressedByteLength:u.uncompressedByteLength}}o[s]=l}return this._transcodeWorkerPool.postMessage(i).then(function(e){return a.faces=e,a.hasAlpha=!0,a})},t}(lY);l0.transcoderMap=((tf={})[lX.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",tf),e.KTX2Loader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.initialize=function(e,n){if(n.ktx2Loader){var r=n.ktx2Loader;return(r.priorityFormats&&(t._priorityFormats.etc1s=r.priorityFormats,t._priorityFormats.uastc=r.priorityFormats),1===r.transcoder)?t._getKhronosTranscoder(r.workerCount).init():t._getBinomialLLCTranscoder(r.workerCount).init()}},n.load=function(e,n){return new a8(function(r,a,i,o){n._request(e.url,{type:"arraybuffer"}).onProgress(i,o).then(function(r){return t._parseBuffer(new Uint8Array(r),n.engine,e.params).then(function(e){var n=e.engine,r=e.result,a=e.targetFormat,i=e.params;return t._createTextureByBuffer(n,r,a,i)})}).then(r).catch(a)})},t.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},t._parseBuffer=function(e,n,r){var a,i,o=new lj(e),s=null!=(a=null==r?void 0:r.priorityFormats)?a:t._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=t._decideTargetFormat(n,o,s);if(!t._isBinomialInit&&l0.transcoderMap[l]&&o.isUASTC){var c=t._getKhronosTranscoder();i=c.init().then(function(){return c.transcode(o)})}else{var u=t._getBinomialLLCTranscoder();i=u.init().then(function(){return u.transcode(e,l)})}return i.then(function(e){return{engine:n,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},t._createTextureByBuffer=function(e,t,n,r){var a,i=t.width,o=t.height,s=t.faces,l=s.length,c=s[0],u=c.length>1,d=this._getEngineTextureFormat(n,t);if(6!==l){a=new nc(e,i,o,d,u);for(var h=0;h<c.length;h++){var _=c[h].data;a.setPixelBuffer(_,h)}}else{a=new nd(e,o,d,u);for(var f=0;f<s.length;f++)for(var p=s[f],m=0;m<c.length;m++)a.setPixelBuffer(t4.PositiveX+f,p[m].data,m)}return r&&(a.wrapModeU=r[0],a.wrapModeV=r[1],a.filterMode=r[2],a.anisoLevel=r[3]),a},t._decideTargetFormat=function(e,t,n){var r=e._hardwareRenderer,a=this._detectSupportedFormat(r,n);return a!==lX.PVRTC||tS.isPowerOf2(t.pixelWidth)&&tS.isPowerOf2(t.pixelHeight)&&t.pixelWidth===t.pixelHeight?null===a?(no.warn("Can't support any compressed texture, downgrade to RGBA8"),lX.R8G8B8A8):a:(no.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),lX.R8G8B8A8)},t._detectSupportedFormat=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],a=this._supportedMap[r];if(a){for(var i=0;i<a.length;i++)if(e.canIUse(a[i]))return r}else switch(t[n]){case lX.R8G8B8A8:return r;case lX.R8:case lX.R8G8:if(e.isWebGL2)return r}}return null},t._getBinomialLLCTranscoder=function(e){var n;return void 0===e&&(e=4),t._isBinomialInit=!0,null!=(n=this._binomialLLCTranscoder)?n:this._binomialLLCTranscoder=new lZ(e)},t._getKhronosTranscoder=function(e){var t;return void 0===e&&(e=4),null!=(t=this._khronosTranscoder)?t:this._khronosTranscoder=new l0(e,lX.ASTC)},t._getEngineTextureFormat=function(e,t){var n=t.hasAlpha;switch(e){case lX.ASTC:return t9.ASTC_4x4;case lX.ETC:return n?t9.ETC2_RGBA8:t9.ETC2_RGB;case lX.BC7:return t9.BC7;case lX.BC1_BC3:return n?t9.BC3:t9.BC1;case lX.PVRTC:return n?t9.PVRTC_RGBA4:t9.PVRTC_RGB4;case lX.R8G8B8A8:return t9.R8G8B8A8}},t}(ol),e.KTX2Loader._isBinomialInit=!1,e.KTX2Loader._priorityFormats={etc1s:[lX.ETC,lX.BC7,lX.ASTC,lX.BC1_BC3,lX.PVRTC],uastc:[lX.ASTC,lX.BC7,lX.ETC,lX.BC1_BC3,lX.PVRTC]},e.KTX2Loader._supportedMap=((tp={})[lX.ASTC]=[nJ.astc],tp[lX.ETC]=[nJ.etc],tp[lX.BC7]=[nJ.bptc],tp[lX.BC1_BC3]=[nJ.s3tc],tp[lX.PVRTC]=[nJ.pvrtc,nJ.pvrtc_webkit],tp),e.KTX2Loader=s3([it(a2.KTX2,["ktx2"])],e.KTX2Loader);var l1=((tc={})[tc.BinomialLLC=0]="BinomialLLC",tc[tc.Khronos=1]="Khronos",tc),l2=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e}s1(n,t);var r=n.prototype;return r.restoreContent=function(){var t=this;return new a8(function(n,r){Promise.all(t.bufferRequests.map(function(e){return a6(e.url,e.config)})).then(function(a){if(t.isGLB){var i=t.glbBufferSlices,o=a[0],s=i.length;a.length=s;for(var l=0;l<s;l++){var c=i[l];a[l]=o.slice(c.x,c.x+c.y)}}a8.all(t.bufferTextures.map(function(t){var n,r=t.bufferView,i=new Uint8Array(a[r.buffer],null!=(n=r.byteOffset)?n:0,r.byteLength),o=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(i,o.engine).then(function(e){for(var t=e.result.faces[0],n=0;n<t.length;n++)o.setPixelBuffer(t[n].data,n)}):lH.loadImageBuffer(i,t.mimeType).then(function(e){o.setImageSource(e),o.generateMipmaps()})})).then(function(){for(var e,r=lf(t.meshes);!(e=r()).done;){for(var i,o=e.value,s=o.mesh,l=lf(o.vertexBuffers);!(i=l()).done;){var c=i.value,u=t._getBufferData(a,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=t._getBufferData(a,o.indexBuffer);s.setIndices(d)}for(var h,_=lf(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(a,m.buffer);if(p.deltaPositions=lH.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=lH.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,b=t._getBufferData(a,x.buffer);p.deltaTangents=lH.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}n(t.resource)}).catch(r)}).catch(r)})},r._getBufferData=function(e,t){var n,r=t.main;if(r){var a=e[r.bufferIndex];n=new r.TypedArray(a,r.byteOffset,r.length)}else n=new r.TypedArray(r.length);var i=t.sparseCount;if(i)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],d=new c.TypedArray(u,c.byteOffset,c.length),h=t.typeSize,_=0;_<i;_++)for(var f=l[_],p=0;p<h;p++)n[f*h+p]=d[_*h+p];return n},n}(t2),l3=function(e,t){this.url=e,this.config=t},l4=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},l8=function(){this.vertexBuffers=[],this.blendShapes=[]},l5=function(e,t){this.buffer=e,this.data=t},l9=function(e,t,n,r,a){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=a},l6=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},l7=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},ce=function(e,t,n,r,a){this.buffer=e,this.byteOffset=t,this.count=n,this.normalized=r,this.componentType=a},ct=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.createAndParse=function(e,t,n){for(var r=arguments.length,a=Array(r>3?r-3:0),i=3;i<r;i++)a[i-3]=arguments[i];throw"Not implemented."},t.additiveParse=function(e,t,n,r){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];throw"Not implemented."},e}(),cn=((tu={})[tu.CreateAndParse=0]="CreateAndParse",tu[tu.AdditiveParse=1]="AdditiveParse",tu),cr=/*#__PURE__*/function(){function e(){}return e.executeExtensionsCreateAndParse=function(t,n,r){void 0===t&&(t={});for(var a=arguments.length,i=Array(a>3?a-3:0),o=3;o<a;o++)i[o-3]=arguments[o];for(var s=null,l=Object.keys(t),c=l.length-1;c>=0;--c){var u=l[c],d=t[u];if(s=e._createAndParse.apply(e,[].concat([u,n,d,r],i)))return s}},e.executeExtensionsAdditiveAndParse=function(t,n,r,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];for(var l in t){var c=t[l];e._additiveParse.apply(e,[].concat([l,n,r,c,a],o))}},e.hasExtensionParser=function(t){var n;return!!(null==(n=e._extensionParsers[t])?void 0:n.length)},e.getExtensionParser=function(t,n){var r=e._extensionParsers[t],a=null==r?void 0:r.length;if(a)for(var i=a-1;i>=0;--i){var o=r[i];if(o._mode===n)return o}},e._addExtensionParser=function(t,n){e._extensionParsers[t]||(e._extensionParsers[t]=[]),e._extensionParsers[t].push(n)},e._createAndParse=function(t,n,r,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];var l=e.getExtensionParser(t,cn.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat([n,r,a],o))},e._additiveParse=function(t,n,r,a,i){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=e.getExtensionParser(t,cn.AdditiveParse);c&&c.additiveParse.apply(c,[].concat([n,r,a,i],s))},e}();function ca(e,t){return function(n){var r=new n;r._mode=t,cr._addExtensionParser(e,r)}}function ci(){if(tg)return tg;var e,t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),n=id._detectSIMDSupported()?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";function r(e){for(var n=new Uint8Array(e.length),r=0;r<e.length;++r){var a=e.charCodeAt(r);n[r]=a>96?a-97:a>64?a-39:a+4}for(var i=0,o=0;o<e.length;++o)n[i++]=n[o]<60?t[n[o]]:(n[o]-60)*64+n[++o];return n.buffer.slice(0,i)}tg=WebAssembly.instantiate(r(n)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:tg,useWorkers:function(e){this.workerCount=null!=e?e:this.workerCount,function(e){for(var t=new Blob(["var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r(n))+']), {}).then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\nself.onmessage = workerProcess;\nfunction decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\nfunction workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }'],{type:"text/javascript"}),a=URL.createObjectURL(t),i=0;i<e;++i)o[i]=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}(a);URL.revokeObjectURL(a)}(this.workerCount)},decodeGltfBuffer:function(t,n,r,l,c){return(this.workerCount>0&&0===o.length&&this.useWorkers(),o.length>0)?function(e,t,n,r,a){for(var i=o[0],l=1;l<o.length;++l)o[l].pending<i.pending&&(i=o[l]);return new Promise(function(o,l){var c=new Uint8Array(n),u=s++;i.pending+=e,i.requests[u]={resolve:o,reject:l},i.object.postMessage({id:u,count:e,size:t,source:c,mode:r,filter:a},[c.buffer])})}(t,n,r,i[l],a[c]):tg.then(function(){var o=new Uint8Array(t*n);return function(t,n,r,a,i,o){var s=e.exports.sbrk,l=r+3&-4,c=s(l*a),u=s(i.length),d=new Uint8Array(e.exports.memory.buffer);d.set(i,u);var h=t(c,r,a,u,i.length);if(0==h&&o&&o(c,l,a),n.set(d.subarray(c,c+r*a)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)}(e.exports[i[l]],o,t,n,r,e.exports[a[c]]),o})},release:function(){for(var e=0;e<o.length;e++)o[e].object.terminate()}}});var a={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},o=[],s=0;return tg}cr._extensionParsers={},e.GLTFSchemaParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e){var t=e.glTFResource,n=e.contentRestorer,r=e.resourceManager,a=t.url,i=n.bufferRequests,o={type:"arraybuffer"},s=r._getRemoteUrl(a);return r._requestByRemoteUrl(s,o).onProgress(void 0,e._onTaskDetail).then(function(t){var n=lH.parseGLB(e,t);return(null==n?void 0:n.glTF)&&i.push(new l3(s,o)),n}).then(function(t){return(null==t?void 0:t.glTF)?(n.isGLB=!0,e.buffers=t.buffers,t.glTF):(n.isGLB=!1,JSON.parse(nT.decodeText(new Uint8Array(t.originBuffer))))})},t}(cr),e.GLTFSchemaParser=s3([lG(lk.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.parse=function(e,t){var r=e.glTF.animations[t],a=r.name;return Promise.resolve(cr.executeExtensionsCreateAndParse(r.extensions,e,r)||n._parseStandardProperty(e,new ov(void 0===a?"AnimationClip"+t:a),r)).then(function(t){return cr.executeExtensionsAdditiveAndParse(r.extensions,e,t,r),t})},n._parseStandardProperty=function(e,t,n){for(var r=function(t,n){var r=c[t],a=o[r.input],i=o[r.output];_.push(Promise.all([lH.getAccessorBuffer(e,s,a),lH.getAccessorBuffer(e,s,i)]).then(function(e){var n,a,o=e[0].data,s=e[1].data;if(i.normalized){for(var l=lH.getNormalizedComponentScale(i.componentType),c=new Float32Array(s.length),u=0,h=s.length;u<h;u++)c[u]=s[u]*l;s=c}var _=s.length/o.length;switch(null!=(n=r.interpolation)?n:lF.Linear){case lF.CubicSpine:a=oy.CubicSpine;break;case lF.Step:a=oy.Step;break;case lF.Linear:a=oy.Linear}o[o.length-1],d[t]={type:i.type,interpolation:a,input:o,output:s,outputSize:_}}))},a=this,i=e.glTF,o=i.accessors,s=i.bufferViews,l=n.channels,c=n.samplers,u=c.length,d=Array(u),h=e.get(lk.Entity),_=[],f=0;f<u;f++)r(f);return _.push(e.get(lk.Scene)),Promise.all(_).then(function(){for(var n=0,r=l.length;n<r;n++){for(var o=l[n],s=o.target,c=h[s.node],u="",_=c;_.parent;)u=""===u?""+_.name:_.name+"/"+u,_=_.parent;if(-1!==e.glTFResource.sceneRoots.indexOf(_)){var f=void 0,p=void 0;switch(s.path){case lP.TRANSLATION:f=rp,p="position";break;case lP.ROTATION:f=rp,p="rotationQuaternion";break;case lP.SCALE:f=rp,p="scale";break;case lP.WEIGHTS:f=aK,p="blendShapeWeights"}var m=a._addCurve(s.path,o,d);if(s.path===lP.WEIGHTS)for(var g=i.nodes[s.node].mesh,v=0,y=i.meshes[g].primitives.length;v<y;v++)t.addCurveBinding(u,f,v,p,m);else t.addCurveBinding(u,f,p,m)}}return t})},n._addCurve=function(t,n,r){var a=r[n.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case lP.TRANSLATION:case lP.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,u=0,d=0,h=i.length;d<h;d++){var _=new oU;_.time=i[d],c===oy.CubicSpine?(_.inTangent=new tT(o[u++],o[u++],o[u++]),_.value=new tT(o[u++],o[u++],o[u++]),_.outTangent=new tT(o[u++],o[u++],o[u++])):_.value=new tT(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case lP.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=a.interpolation,m=0,g=0,v=i.length;g<v;g++){var y=new oU;y.time=i[g],p===oy.CubicSpine?(y.inTangent=new tI(o[m++],o[m++],o[m++],o[m++]),y.value=new tF(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new tI(o[m++],o[m++],o[m++],o[m++])):y.value=new tF(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case lP.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var b=0,C=0,S=i.length;C<S;C++){var T=new oU;T.time=i[C],x.interpolation===oy.CubicSpine?(T.inTangent=Array.from(o.subarray(b,b+s)),b+=s,T.value=o.slice(b,b+s),b+=s,T.outTangent=Array.from(o.subarray(b,b+s))):T.value=o.slice(b,b+s),b+=s,x.addKey(T)}return x}},n}(cr),e.GLTFAnimationParser=s3([lG(lk.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.parse=function(e,t){var n=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,n[t])},n._parseSingleBuffer=function(e,t){var n=e.glTFResource,r=e.contentRestorer,a=e.resourceManager,i=n.url,o=a._getRemoteUrl(i),s=r.bufferRequests,l={type:"arraybuffer"},c=nT.resolveAbsoluteUrl(o,t.uri);s.push(new l3(c,l));var u=a._requestByRemoteUrl(c,l).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(u),u},t}(cr),e.GLTFBufferParser=s3([lG(lk.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,t){var n=e.glTFResource,r=e.glTF.nodes[t],a=n.engine,i=r.matrix,o=r.translation,s=r.rotation,l=r.scale,c=r.extensions,u=new aW(a,r.name||"_GLTF_ENTITY_"+t);u._markAsTemplate(n);var d=u.transform;if(i){var h=d.localMatrix;h.copyFromArray(i),d.localMatrix=h}else o&&d.setPosition(o[0],o[1],o[2]),s&&d.setRotationQuaternion(s[0],s[1],s[2],s[3]),l&&d.setScale(l[0],l[1],l[2]);var _=r.children;if(_)for(var f=0;f<_.length;f++){var p=_[f],m=e.get(lk.Entity,p);u.addChild(m)}return cr.executeExtensionsAdditiveAndParse(c,e,u,r),u},t}(cr),e.GLTFEntityParser=s3([lG(lk.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,n){var r=e.glTF.materials[n],a=e.glTFResource,i=a.engine,o=cr.executeExtensionsCreateAndParse(r.extensions,e,r);return o||((o=new ad(i)).name=r.name,t._parseStandardProperty(e,o,r)),Promise.resolve(o).then(function(n){return n||(n=t._getDefaultMaterial(i)),cr.executeExtensionsAdditiveAndParse(r.extensions,e,n,r),n._associationSuperResource(a),n})},t._getDefaultMaterial=function(e){return t._defaultMaterial||(t._defaultMaterial=new al(e))},t._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&no.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},t._parseStandardProperty=function(e,n,r){var a=r.pbrMetallicRoughness,i=r.normalTexture,o=r.occlusionTexture,s=r.emissiveTexture,l=r.emissiveFactor,c=r.alphaMode,u=r.alphaCutoff,d=r.doubleSided;if(a){var h=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,m=a.metallicRoughnessTexture;h&&(n.baseColor=new tO(tO.linearToGammaSpace(h[0]),tO.linearToGammaSpace(h[1]),tO.linearToGammaSpace(h[2]),h[3])),_&&e.get(lk.Texture,_.index).then(function(t){n.baseTexture=t,cr.executeExtensionsAdditiveAndParse(_.extensions,e,n,_)}),n.constructor===ad&&(n.metallic=null!=f?f:1,n.roughness=null!=p?p:1,m&&(t._checkOtherTextureTransform(m,"Roughness metallic"),e.get(lk.Texture,m.index).then(function(e){n.roughnessMetallicTexture=e})))}if(n.constructor===ad||n.constructor===ah){if(s&&(t._checkOtherTextureTransform(s,"Emissive"),e.get(lk.Texture,s.index).then(function(e){n.emissiveTexture=e})),l&&(n.emissiveColor=new tO(tO.linearToGammaSpace(l[0]),tO.linearToGammaSpace(l[1]),tO.linearToGammaSpace(l[2]))),i){var g=i.index,v=i.scale;t._checkOtherTextureTransform(i,"Normal"),e.get(lk.Texture,g).then(function(e){n.normalTexture=e}),void 0!==v&&(n.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,b=o.texCoord;t._checkOtherTextureTransform(o,"Occlusion"),e.get(lk.Texture,y).then(function(e){n.occlusionTexture=e}),void 0!==x&&(n.occlusionTextureIntensity=x),b===ac.UV1?n.occlusionTextureCoord=ac.UV1:b>ac.UV1&&no.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=ai.Double:n.renderFace=ai.Front,c){case lD.OPAQUE:n.isTransparent=!1;break;case lD.BLEND:n.isTransparent=!0;break;case lD.MASK:n.alphaCutoff=null!=u?u:.5}},t}(cr),e.GLTFMaterialParser=s3([lG(lk.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,n){for(var r=function(n,r){var c=a.primitives[n];l[n]=new Promise(function(r){var l=cr.executeExtensionsCreateAndParse(c.extensions,e,c,a);if(l)lh(l,aM)?(l._associationSuperResource(o),r(l)):l.then(function(e){e._associationSuperResource(o),r(e)});else{var u=new aM(s,a.name||n+"");u._associationSuperResource(o);var d=new l8;d.mesh=u,e.contentRestorer.meshes.push(d),t._parseMeshFromGLTFPrimitive(e,u,d,a,c,i,e.params.keepMeshData).then(r)}})},a=e.glTF.meshes[n],i=e.glTF,o=e.glTFResource,s=o.engine,l=[],c=0,u=a.primitives.length;c<u;c++)r(c);return Promise.all(l)},t._parseMeshFromGLTFPrimitive=function(e,n,r,a,i,o,s){var l,c=function(a){var i=u[d[a]],c=lH.getAccessorBuffer(e,o.bufferViews,i).then(function(e){var o,c,u,d=lH.getAccessorTypeSize(i.type),h=i.count,_=e.data,f=n.instanceId,v=e.vertexBindingInfos,y=i.normalized,x=lH.getElementFormat(i.componentType,d,y);if(y&&(c=lH.getNormalizedComponentScale(i.componentType)),e.interleaved){var b=i.byteOffset||0,C=e.stride;if(u=b%C,void 0===v[f]){o=new at(a,u,x,g);var S=e.vertexBuffer;S||(S=new r9(p,an.VertexBuffer,_,r8.Static,s),e.vertexBuffer=S,r.vertexBuffers.push(new l5(S,e.restoreInfo))),n.setVertexBufferBinding(S,C,g),v[f]=g++}else o=new at(a,u,x,v[f])}else{o=new at(a,u=0,x,g);var T=e.vertexBuffer;T||(T=new r9(p,an.VertexBuffer,_,r8.Static,s),r.vertexBuffers.push(new l5(T,e.restoreInfo))),n.setVertexBufferBinding(T,e.stride,g),v[f]=g++}if(m.push(o),"POSITION"===a){l=h;var A=n.bounds,E=A.min,R=A.max;if(i.min&&i.max)E.copyFromArray(i.min),R.copyFromArray(i.max);else{var M=t._tempVector3;E.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),R.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var w=u/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=w+F*P;M.copyFromArray(_,L),tT.min(E,M,E),tT.max(R,M,R)}}y&&(E.scale(c),R.scale(c))}});v.push(c)},u=o.accessors,d=i.attributes,h=i.targets,_=i.indices,f=i.mode,p=n.engine,m=[],g=0,v=[];for(var y in d)c(y);return Promise.all(v).then(function(){if(n.setVertexElements(m),void 0!==_){var c=o.accessors[_],u=lH.getAccessorBuffer(e,o.bufferViews,c).then(function(e){n.setIndices(e.data),n.addSubMesh(0,c.count,f),r.indexBuffer=e.restoreInfo});v.push(u)}else n.addSubMesh(0,l,f);return h&&v.push(t._createBlendShape(e,n,r,a,i,h)),Promise.all(v).then(function(){return n.uploadData(!s),n})})},t._getBlendShapeData=function(e,t,n){return lH.getAccessorBuffer(e,t.bufferViews,n).then(function(e){var t,r=e.data,a=e.interleaved?(null!=(t=n.byteOffset)?t:0)%e.stride:0,i=n.count,o=n.normalized,s=n.componentType;return{vertices:lH.bufferToVector3Array(r,a,i,o,s),restoreInfo:new ce(e.restoreInfo,a,i,o,s)}})},t._createBlendShape=function(e,t,n,r,a,i){for(var o,s=e.glTF,l=s.accessors,c=r.extras?r.extras.targetNames:null,u=[],d=i.length,h=Array(d),_=0;_<d;_++)o=this,function(t){var n={};h[t]=n;var r=c?c[t]:"blendShape"+t,i=a.targets[t],d=i.NORMAL,_=i.TANGENT,f=void 0!==d,p=void 0!==_;u.push(Promise.all([o._getBlendShapeData(e,s,l[i.POSITION]),f?o._getBlendShapeData(e,s,l[d]):null,p?o._getBlendShapeData(e,s,l[_]):null]).then(function(e){var t=e[0],a=e[1],i=e[2],o=new am(r);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),n.blendShape=o,n.restoreInfo=new l7(o,t.restoreInfo,f?a.restoreInfo:null,p?null==i?void 0:i.restoreInfo:null)}))}(_);return Promise.all(u).then(function(){for(var e,r=lf(h);!(e=r()).done;){var a=e.value;t.addBlendShape(a.blendShape),n.blendShapes.push(a.restoreInfo)}})},t}(cr),e.GLTFMeshParser._tempVector3=new tT,e.GLTFMeshParser=s3([lG(lk.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}s1(n,t);var r=n.prototype;return r.parse=function(e,t){var n,r=e.glTF,a=r.scenes,i=r.scene,o=e.glTFResource,s=a[t],l=s.extensions,c=o.engine,u=s.nodes||[];if(1===u.length)n=e.get(lk.Entity,u[0]);else{(n=new aW(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=e.get(lk.Entity,u[d]);n.addChild(h)}}(void 0===i?0:i)===t&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(e,u[f]));return Promise.all(_).then(function(){return cr.executeExtensionsAdditiveAndParse(l,e,n,s),n})},r._parseEntityComponent=function(e,t){var n,r=this,a=e.glTF,i=e.glTFResource,o=a.nodes[t],s=o.camera,l=o.mesh,c=e.get(lk.Entity,t);return void 0!==s&&this._createCamera(i,a.cameras[s],c),void 0!==l&&(n=this._createRenderer(e,o,c)),Promise.resolve(n).then(function(){var t=[],n=o.children;if(n)for(var a=0;a<n.length;a++)t.push(r._parseEntityComponent(e,n[a]));return Promise.all(t)})},r._createCamera=function(t,n,r){var a=n.orthographic,i=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===lL.ORTHOGRAPHIC){var l=a.xmag,c=a.ymag,u=a.zfar,d=a.znear;s.isOrthographic=!0,void 0!==d&&(s.nearClipPlane=d),void 0!==u&&(s.farClipPlane=u),s.orthographicSize=Math.max(null!=c?c:0,null!=l?l:0)/2}else if(o===lL.PERSPECTIVE){var h=i.aspectRatio,_=i.yfov,f=i.zfar,p=i.znear;void 0!==h&&(s.aspectRatio=h),void 0!==_&&(s.fieldOfView=180*_/Math.PI),void 0!==f&&(s.farClipPlane=f),void 0!==p&&(s.nearClipPlane=p)}t.cameras||(t.cameras=[]),t.cameras.push(s),s.enabled=!1},r._createRenderer=function(t,n,r){for(var a,i=this,o=n.mesh,s=n.skin,l=t.glTF.meshes[o],c=l.primitives,u=c.length,d=n.weights||l.weights,h=Array(u),_=0;_<u;_++)h[_]=t.get(lk.Material,null!=(a=c[_].material)?a:-1);return Promise.all([t.get(lk.Mesh,o),void 0!==s&&t.get(lk.Skin,s),Promise.all(h)]).then(function(n){for(var a=n[0],o=n[1],s=n[2],l=0;l<u;l++)!function(n){var l=s[n]||e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine),u=c[n],h=a[n],_=void 0;if(o||d){var f=r.addComponent(aK);f.mesh=h,o&&(i._computeLocalBounds(f,h,o.bones,o.rootBone,o.inverseBindMatrices),f.skin=o),d&&(f.blendShapeWeights=new Float32Array(d)),_=f}else(_=r.addComponent(aA)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),cr.executeExtensionsAdditiveAndParse(u.extensions,t,_,u)}(l)})},r._computeLocalBounds=function(e,t,n,r,a){var i=n.indexOf(r);if(-1!==i)tE.transform(t.bounds,a[i],e.localBounds);else{var o=new tL(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(n,a,r,o);0!==s?(tL.multiplyScalar(o,1/s,o),tE.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},r._computeApproximateBindMatrix=function(e,t,n,r){for(var a=0,i=n.children,o=0,s=i.length;o<s;o++){var l=i[o],c=e.indexOf(l);-1!==c?(tL.add(r,t[c],r),a++):a+=this._computeApproximateBindMatrix(e,t,l,r)}return a},n}(cr),e.GLTFSceneParser=s3([lG(lk.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.parse=function(e,t){var n=this,r=e.glTF,a=r.skins[t],i=a.inverseBindMatrices,o=a.skeleton,s=a.joints,l=a.name,c=s.length,u=new aj(void 0===l?"SKIN_"+t:l);u.inverseBindMatrices.length=c;var d=Array(c),h=r.accessors[i];return Promise.resolve(lH.getAccessorBuffer(e,r.bufferViews,h).then(function(t){for(var r=e.get(lk.Entity),a=t.data,i=0;i<c;i++){var l=new tL;l.copyFromArray(a,16*i),u.inverseBindMatrices[i]=l;var h=r[s[i]];d[i]=h,u.joints[i]=h.name}if(u.bones=d,void 0!==o){var _=r[o];u.rootBone=_}else{var f=n._findSkeletonRootBone(s,r);if(f)u.rootBone=f;else throw"Failed to find skeleton root bone."}return u}))},n._findSkeletonRootBone=function(e,t){for(var n,r={},a=lf(e);!(n=a()).done;){for(var i=n.value,o=[],s=t[i];s;)o.unshift(s),s=s.parent;r[i]=o}for(var l=null,c=0;;c++){var u=r[e[0]];if(c>=u.length)return l;for(var d=u[c],h=1,_=e.length;h<_;h++)if(c>=(u=r[e[h]]).length||d!==u[c])return l;l=d}},t}(cr),e.GLTFSkinParser=s3([lG(lk.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,n){var r=e.glTF.textures[n],a=e.glTFResource,i=r.sampler,o=r.source,s=r.name,l=r.extensions,c=cr.executeExtensionsCreateAndParse(l,e,r,n);return c||(c=t._parseTexture(e,void 0===o?0:o,n,i,s)),Promise.resolve(c).then(function(t){return cr.executeExtensionsAdditiveAndParse(l,e,t,r),t._associationSuperResource(a),t})},t._parseTexture=function(e,t,n,r,a){var i,o=e.glTFResource,s=e.glTF,l=o.engine,c=o.url,u=s.images[t],d=u.uri,h=u.bufferView,_=u.mimeType,f=u.name,p=void 0!==r,m=p&&lH.getSamplerInfo(s.samplers[r]);if(d){var g=d.lastIndexOf("."),v=d.substring(g+1).startsWith("ktx")?a2.KTX:a2.Texture2D;i=l.resourceManager.load({url:nT.resolveAbsoluteUrl(c,d),type:v,params:{mipmap:null==m?void 0:m.mipmap}}).onProgress(void 0,e._onTaskDetail).then(function(e){return e.name=a||f||e.name||"texture_"+n,p&&lH.parseSampler(e,m),e}),e._addTaskCompletePromise(i)}else{var y=s.bufferViews[h];i=e.get(lk.Buffer).then(function(t){var r=new Uint8Array(t[y.buffer],y.byteOffset,y.byteLength);return lH.loadImageBuffer(r,_).then(function(t){var r=new nc(l,t.width,t.height,void 0,null==m?void 0:m.mipmap);r.setImageSource(t),r.generateMipmaps(),r.name=a||f||"texture_"+n,p&&lH.parseSampler(r,m);var i=new l4(r,y,_);return e.contentRestorer.bufferTextures.push(i),r})})}return i},t}(cr),e.GLTFTextureParser._wrapMap=((tm={})[lO.CLAMP_TO_EDGE]=t7.Clamp,tm[lO.MIRRORED_REPEAT]=t7.Mirror,tm[lO.REPEAT]=t7.Repeat,tm),e.GLTFTextureParser=s3([lG(lk.Texture)],e.GLTFTextureParser),e.GLTFValidator=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e){var t=e.glTF,n=t.asset.version,r=t.extensionsUsed,a=t.extensionsRequired,i=Number(n);if(!(i>=2&&i<3))throw"Only support glTF 2.x.";if(r){no.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++){var s=r[o];cr.hasExtensionParser(s)||no.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){no.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];cr.hasExtensionParser(c)||no.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},t}(cr),e.GLTFValidator=s3([lG(lk.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,t){var n=e.glTF.bufferViews[t],r=n.extensions,a=n.byteOffset,i=void 0===a?0:a,o=n.byteLength,s=n.buffer;return r?cr.executeExtensionsCreateAndParse(r,e,n):e.get(lk.Buffer,s).then(function(e){return new Uint8Array(e,i,o)})},t}(cr),e.GLTFBufferViewParser=s3([lG(lk.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.parse=function(e){var t=this;return e.needAnimatorController?e.get(lk.Animation).then(function(n){return Promise.resolve(t._createAnimatorController(e,n))}):Promise.resolve(null)},n._createAnimatorController=function(e,t){var n=new oI(e.glTFResource.engine),r=new oz("layer"),a=new ok;if(n.addLayer(r),r.stateMachine=a,t)for(var i=0;i<t.length;i++){var o=t[i],s=o.name,l=a.makeUniqueStateName(s);l!==s&&console.warn("AnimatorState name is existed, name: "+s+" reset to "+l),a.addState(l).clip=o}return n},t}(cr),e.GLTFAnimatorControllerParser=s3([lG(lk.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.initialize=function(e,t){var n,r,a,i=null!=(a=null==(n=t.glTFLoader)?void 0:n.meshOpt)?a:null==(r=t.glTF)?void 0:r.meshOpt;return i?ci().then(function(e){e.useWorkers(i.workerCount)}):Promise.resolve()},n.load=function(e,t){var n=e.params,r=new lN(new lR(t.engine,e.url),t,s$({keepMeshData:!1},n));return new a8(function(e,t,n,a){r._setTaskCompleteProgress=n,r._setTaskDetailProgress=a,r.parse().then(e).catch(t)})},t.release=function(){tg&&ci().then(function(e){e.release()})},t}(ol),e.GLTFLoader=s3([it(a2.GLTF,["gltf","glb"])],e.GLTFLoader);var co=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).prefabResource=r,a}s1(t,e);var n=t.prototype;return n._handleRootEntity=function(e){this.prefabResource._root=this.context.entityMap.get(e)},n._clearAndResolve=function(){return this.context.clear(),this.prefabResource},t.parse=function(e,n,r){var a=new lp(e,n),i=new t(r,new ls(e,lo.Prefab,a),a);return i.start(),i.promise.then(function(){return a})},t}(lm),cs=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(t){co.parse(n,e.url,t).then(r).catch(a)})})},t}(ol);cs=s3([it(a2.Prefab,["prefab"])],cs);var cl=Math.PI,cc=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,n){return new a8(function(r,a){var i=n.engine,o=s$({},e,{type:"arraybuffer"});n._request(e.url,o).then(function(n){var a=t._setTextureByBuffer(i,n);i.resourceManager.addContentRestorer(new cu(a,e.url,o)),r(a)}).catch(a)})},t._setTextureByBuffer=function(e,n,r){var a=new Uint8Array(n),i=t._parseHeader(a),o=i.width,s=i.height,l=i.dataPosition,c=s>>1;r||(r=new nd(e,c));for(var u=t._readPixels(a.subarray(l),o,s),d=t._convertToCubemap(u,o,s,c),h=0;h<6;h++)r.setPixelBuffer(t4.PositiveX+h,d[h],0);return r.generateMipmaps(),r},t._convertToCubemap=function(e,t,n,r){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*n*4)throw"ConvertPanoramaToCubemap: input size is wrong";return[this._createCubemapData(r,this._faceRight,e,t,n),this._createCubemapData(r,this._faceLeft,e,t,n),this._createCubemapData(r,this._faceUp,e,t,n),this._createCubemapData(r,this._faceBottom,e,t,n),this._createCubemapData(r,this._faceFront,e,t,n),this._createCubemapData(r,this._faceBack,e,t,n)]},t._createCubemapData=function(e,t,n,r,a){for(var i=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,u=0;u<e;u++){for(var d=this._temp3Vector3.set(0,0,0).add(t[0]),h=this._temp4Vector3.set(0,0,0).add(t[2]),_=0;_<e;_++){var f=this._temp5Vector3.set(0,0,0).add(h).subtract(d).scale(c).add(d);f.normalize();var p=this._calcProjectionSpherical(f,n,r,a);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;i[m]=p.r,i[m+1]=p.g,i[m+2]=p.b,i[m+3]=p.a,d.add(o),h.add(s)}c+=l}return i},t._calcProjectionSpherical=function(e,t,n,r){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-cl;)a+=2*cl;for(;a>cl;)a-=2*cl;var o=a/cl,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(i/cl*r);l<0?l=0:l>=r&&(l=r-1);var c=(r-l-1)*n*4+4*s;return new tO(t[c],t[c+1],t[c+2],t[c+3])},t._readStringLine=function(e,t){for(var n="",r="",a=t;a<e.length-t&&"\n"!=(r=String.fromCharCode(e[a]));a++)n+=r;return n},t._parseHeader=function(e){var t=0,n=0,r=this._readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var a=!1,i=!1,o=0;do o+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this._readStringLine(e,o))?i=!0:0==r.length&&(a=!0);while(!a);if(!i)throw"HDR Bad header format, unsupported FORMAT";o+=r.length+1,r=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!s||s.length<3)throw"HDR Bad header format, no size";if(n=parseInt(s[2]),t=parseInt(s[1]),n<8||n>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:o+=r.length+1}},t._readPixels=function(e,t,n){for(var r=e.byteLength,a=new Uint8Array(4*t*n),i=0,o=0,s=4*t,l=new Uint8Array(s),c=n;c>0&&o<r;){var u=e[o++],d=e[o++],h=e[o++],_=e[o++];if(2!=u||2!=d||128&h||t<8||t>32767)return e;if((h<<8|_)!=t)throw"HDR Bad header format, wrong scan line width";for(var f=0,p=void 0;f<s&&o<r;){var m=(p=e[o++])>128;if(m&&(p-=128),0===p||f+p>s)throw"HDR Bad Format, bad scanline data (run)";if(m)for(var g=e[o++],v=0;v<p;v++)l[f++]=g;else l.set(e.subarray(o,o+p),f),f+=p,o+=p}for(var y=0;y<t;y++){var x=0;a[i]=l[y+x],x+=t,a[i+1]=l[y+x],x+=t,a[i+2]=l[y+x],x+=t,a[i+3]=l[y+x],i+=4}c--}return a},t._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},t._linearToRGBM=function(e,t){var n=Math.min(Math.max(e.r,Math.max(e.g,e.b))/t,1),r=65025/((n=Math.ceil(255*n))*t);e.r*=r,e.g*=r,e.b*=r,e.a*=n},t}(ol);cc._rightBottomBack=new tT(1,-1,-1),cc._rightBottomFront=new tT(1,-1,1),cc._rightUpBack=new tT(1,1,-1),cc._rightUpFront=new tT(1,1,1),cc._leftBottomBack=new tT(-1,-1,-1),cc._leftBottomFront=new tT(-1,-1,1),cc._leftUpBack=new tT(-1,1,-1),cc._leftUpFront=new tT(-1,1,1),cc._faceRight=[cc._rightBottomBack,cc._rightBottomFront,cc._rightUpBack,cc._rightUpFront],cc._faceLeft=[cc._leftBottomFront,cc._leftBottomBack,cc._leftUpFront,cc._leftUpBack],cc._faceUp=[cc._leftBottomFront,cc._rightBottomFront,cc._leftBottomBack,cc._rightBottomBack],cc._faceBottom=[cc._leftUpBack,cc._rightUpBack,cc._leftUpFront,cc._rightUpFront],cc._faceFront=[cc._leftBottomBack,cc._rightBottomBack,cc._leftUpBack,cc._rightUpBack],cc._faceBack=[cc._rightBottomFront,cc._leftBottomFront,cc._rightUpFront,cc._leftUpFront],cc._tempVector3=new tT,cc._temp2Vector3=new tT,cc._temp3Vector3=new tT,cc._temp4Vector3=new tT,cc._temp5Vector3=new tT,cc=s3([it(a2.HDR,["hdr"])],cc);var cu=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){a6(e.url,e.requestConfig).then(function(n){cc._setTextureByBuffer(e.resource.engine,n,e.resource),t(e.resource)}).catch(n)})},t}(t2),cd=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return t._request(e.url,s$({},e,{type:"json"}))},t}(ol);cd=s3([it(a2.JSON,["json"],!1)],cd);var ch={parse:function(e,t,n,r){if(void 0===r&&(r=!1),!function(e){if(e.byteLength>=12){var t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}(e))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var a=Uint32Array.BYTES_PER_ELEMENT,i=new DataView(e,12,13*a),o=0x4030201===i.getUint32(0,!0),s={buffer:e,glType:i.getUint32(1*a,o),glTypeSize:i.getUint32(2*a,o),glFormat:i.getUint32(3*a,o),glInternalFormat:i.getUint32(4*a,o),glBaseInternalFormat:i.getUint32(5*a,o),pixelWidth:i.getUint32(6*a,o),pixelHeight:i.getUint32(7*a,o),pixelDepth:i.getUint32(8*a,o),numberOfArrayElements:i.getUint32(9*a,o),numberOfFaces:i.getUint32(10*a,o),numberOfMipmapLevels:i.getUint32(11*a,o),bytesOfKeyValueData:i.getUint32(12*a,o),loadType:0};if(0!==s.glType)throw Error("only compressed formats currently supported");if(s.numberOfMipmapLevels=Math.max(1,s.numberOfMipmapLevels),0===s.pixelHeight||0!==s.pixelDepth)throw Error("only 2D textures currently supported");if(0!==s.numberOfArrayElements)throw Error("texture arrays not currently supported");if(s.numberOfFaces!==t)throw Error("number of faces expected"+t+", but found "+s.numberOfFaces);return n&&(s.mipmaps=function(e,t){for(var n=[],r=64+e.bytesOfKeyValueData,a=e.pixelWidth,i=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,r,1)[0];r+=4;for(var c=0;c<e.numberOfFaces;c++){var u=new Uint8Array(e.buffer,r,l);n.push({data:u,width:a,height:i}),r+=l,r+=3-(l+3)%4}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return n}(s,!0)),r&&(s.engineFormat=function(e){switch(e){case sL.RGB_S3TC_DXT1_EXT:return t9.BC1;case sL.RGBA_S3TC_DXT5_EXT:return t9.BC3;case sL.RGBA_BPTC_UNORM_EXT:return t9.BC7;case sL.RGB_ETC1_WEBGL:return t9.ETC1_RGB;case sL.RGB8_ETC2:return t9.ETC2_RGB;case sL.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return t9.ETC2_RGBA5;case sL.RGBA8_ETC2_EAC:return t9.ETC2_RGBA8;case sL.RGB_PVRTC_2BPPV1_IMG:return t9.PVRTC_RGB2;case sL.RGBA_PVRTC_2BPPV1_IMG:return t9.PVRTC_RGBA2;case sL.RGB_PVRTC_4BPPV1_IMG:return t9.PVRTC_RGB4;case sL.RGBA_PVRTC_4BPPV1_IMG:return t9.PVRTC_RGBA4;case sL.RGBA_ASTC_4X4_KHR:return t9.ASTC_4x4;case sL.RGBA_ASTC_5X5_KHR:return t9.ASTC_5x5;case sL.RGBA_ASTC_6X6_KHR:return t9.ASTC_6x6;case sL.RGBA_ASTC_8X8_KHR:return t9.ASTC_8x8;case sL.RGBA_ASTC_10X10_KHR:return t9.ASTC_10x10;case sL.RGBA_ASTC_12X12_KHR:return t9.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+sL[e])}}(s.glInternalFormat)),s}};function c_(e){var t=ch.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var cf=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){Promise.all(e.urls.map(function(n){return t._request(n,s$({},e,{type:"arraybuffer"}))})).then(function(e){for(var r=function(e){for(var t,n,r,a,i=[],o=0;o<e.length;o++){var s=ch.parse(e[o],1,!0,!0);i.push(s.mipmaps),0===o&&(r=s.pixelWidth,a=s.pixelHeight,t=s.glInternalFormat,n=s.engineFormat)}return{mipmapsFaces:i,engineFormat:n,internalFormat:t,width:r,height:a}}(e),a=r.width,i=r.mipmapsFaces,o=r.engineFormat,s=i[0].length>1,l=new nd(t.engine,a,o,s),c=0;c<6;c++)for(var u=i[c].length,d=0;d<u;d++){var h=i[c][d],_=h.data,f=h.width,p=h.height;l.setPixelBuffer(t4.PositiveX+c,_,d,0,0,f,p)}n(l)}).catch(function(e){r(e)})})},t}(ol);cf=s3([it(a2.KTXCube,[])],cf);var cp=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){for(var r=c_(e),a=r.width,i=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new nc(t.engine,a,i,s,l),u=0;u<o.length;u++){var d=o[u],h=d.width,_=d.height,f=d.data;c.setPixelBuffer(f,u,0,0,h,_)}n(c)}).catch(function(e){r(e)})})},t}(ol);cp=s3([it(a2.KTX,["ktx"])],cp);var cm=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){var a=t.engine,i=e.shaderRef,o=e.shader,s=ro.find(o);s?r(n._getMaterialByShader(e,s,a)):i&&r(t.getResourceByRef(i).then(function(t){return n._getMaterialByShader(e,t,a)}))}).catch(a)})},n._getMaterialByShader=function(e,t,n){var r=function(e){var t=i[e],r=t.type,a=t.value;switch(r){case lu.Vector2:u.setVector2(e,new tB(a.x,a.y));break;case lu.Vector3:u.setVector3(e,new tT(a.x,a.y,a.z));break;case lu.Vector4:u.setVector4(e,new tI(a.x,a.y,a.z,a.w));break;case lu.Color:u.setColor(e,new tO(a.r,a.g,a.b,a.a));break;case lu.Float:u.setFloat(e,a);break;case lu.Texture:c.push(n.resourceManager.getResourceByRef(a).then(function(t){u.setTexture(e,t)}));break;case lu.Boolean:u.setInt(e,a?1:0);break;case lu.Integer:u.setInt(e,Number(a))}},a=e.name,i=e.shaderData,o=e.macros,s=e.renderState,l=new ao(n,t);l.name=a;var c=[],u=l.shaderData;for(var d in i)r(d);for(var h=0,_=o.length;h<_;h++){var f=o[h],p=f.name,m=f.value;void 0==m?u.enableMacro(p):u.enableMacro(p,m)}return function e(t,n,r){if((void 0===r?"undefined":s2(r))==="object")for(var a in r)e(t[n],a,r[a]);else t[n]=r}(l,"renderState",s),Promise.all(c).then(function(){return l})},t}(ol);cm=s3([it(a2.Material,["json"])],cm);var cg=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){return lv(e,t.engine)}).then(function(e){n(e)}).catch(r)})},t}(ol);cg=s3([it(a2.Mesh,["mesh"])],cg);var cv=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return t._request(e.url,s$({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return az.createSubdivisionSurfaceSphere(n,e.sphereRadius,e.sphereStep);case"capsule":return az.createCapsule(n,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return az.createCone(n,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return az.createCuboid(n,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return az.createCylinder(n,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return az.createPlane(n,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return az.createTorus(n,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},t}(ol);cv=s3([it(a2.PrimitiveMesh,["mesh"],!1)],cv);var cy=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){return n.resourceManager.initVirtualResources(e.files),t.load({type:a2.Scene,url:e.scene}).then(function(e){n.sceneManager.activeScene=e,r()})}).catch(a)})},t}(ol);cy=s3([it(a2.Project,["proj"],!1)],cy);var cx=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){var i=t._getRemoteUrl(e.url);n._registerFont(i,i).then(function(){r(new ng(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},n._registerFont=function(e,t){return lA(function(){var n;return s4(this,function(r){switch(r.label){case 0:return[4,(n=new FontFace(e,"url("+t+")")).load()];case 1:return r.sent(),document.fonts.add(n),[2]}})})()},t}(ol);cx=s3([it(a2.SourceFont,["ttf","otf","woff"],!1)],cx);var cb=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._tempRect=new tN,t._tempVec2=new tB,t._tempVec4=new tI,t}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a,i,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=t._request(e.url,s$({},e,{type:"json"}));l.push(c),c.then(function(i){var o=i.atlasItems,s=i.mipmap,c=i.anisoLevel,u=i.filterMode,d=i.wrapModeU,h=i.wrapModeV,_=i.format,f=o?o.length:0,p=t.engine,m=new nb(p);if(f<=0){r(m);return}l.length=0;for(var g=0;g<f;g++)!function(r){var i,f=o[r];if(f.img)l.push(t.load({url:nT.resolveAbsoluteUrl(e.url,f.img),type:null!=(i=f.type)?i:a2.Texture2D,params:{format:_,mipmap:s}}).then(function(e){c&&(e.anisoLevel=c),void 0!==u&&(e.filterMode=u),void 0!==d&&(e.wrapModeU=d),void 0!==h&&(e.wrapModeV=h);for(var t=0;t<f.sprites.length;t++)m._addSprite(n._makeSprite(p,f.sprites[t],e))}).catch(a));else for(var g=0;g<f.sprites.length;g++)m._addSprite(n._makeSprite(p,f.sprites[g]))}(g);a8.all(l).then(function(){r(m)}).catch(a)}).catch(a)})},n._makeSprite=function(e,t,n){var r=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new nP(e,n,r?this._tempRect.set(r.x,r.y,r.w,r.h):void 0,o?this._tempVec2.set(o.x,o.y):void 0,s?this._tempVec4.set(s.x,s.y,s.z,s.w):void 0,t.name);if(n){var d=1/n.width,h=1/n.height;if(u.atlasRegion.set(i.x*d,i.y*h,i.w*d,i.h*h),a){var _=a.x,f=a.y,p=a.z,m=a.w;u.atlasRegionOffset.set(_*d,f*h,p*d,m*h)}t.atlasRotated&&(u.atlasRotated=!0)}return isNaN(l)||(u.width=l),isNaN(c)||(u.height=c),u},t}(ol);cb=s3([it(a2.SpriteAtlas,["atlas"],!1)],cb);var cC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return t._request(e.url,s$({},e,{type:"json"})).then(function(e){return e.belongToAtlas?n._loadFromAtlas(t,e):n._loadFromTexture(t,e)})},n._loadFromAtlas=function(e,t){var n=this;return e.getResourceByRef(t.belongToAtlas).then(function(r){return r.getSprite(t.fullPath)||n._loadFromTexture(e,t)})},n._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(n){var r=new nP(e.engine,n,t.region,t.pivot,t.border),a=t.width,i=t.height;return isNaN(a)||(r.width=a),isNaN(i)||(r.height=i),r}):new a8(function(n){var r=new nP(e.engine,null,t.region,t.pivot,t.border),a=t.width,i=t.height;isNaN(a)||(r.width=a),isNaN(i)||(r.height=i),n(r)})},t}(ol);cC=s3([it(a2.Sprite,["sprite"],!1)],cC);var cS=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return a6(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},t}(t2),cT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r,a,i){var o=e.url,s=s$({},e,{type:"image"});t._request(o,s).onProgress(a,i).then(function(r){var a,i=null!=(a=e.params)?a:{},l=i.format,c=i.mipmap,u=i.anisoLevel,d=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new nc(t.engine,r.width,r.height,l,c);if(f.anisoLevel=null!=u?u:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=d?d:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(r),f.generateMipmaps(),0!==o.indexOf("data:")){var p=o.lastIndexOf("/");f.name=o.substring(p+1)}t.addContentRestorer(new cS(f,o,s)),n(f)}).catch(function(e){r(e)})})},t}(ol);cT=s3([it(a2.Texture2D,["png","jpg","webp","jpeg"])],cT);var cA=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).urls=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){Promise.all(e.urls.map(function(t){return a6(t,e.requestConfig)})).then(function(n){for(var r=e.resource,a=0;a<6;a++)r.setImageSource(t4.PositiveX+a,n[a],0);r.generateMipmaps(),t(r)}).catch(function(e){n(e)})})},t}(t2),cE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){var a=e.urls,i=s$({},e,{type:"image"});Promise.all(a.map(function(e){return t._request(e,i)})).then(function(e){var r=e[0],o=r.width;if(o!==r.height){console.error("The cube texture must have the same width and height");return}for(var s=new nd(t.engine,o),l=0;l<6;l++)s.setImageSource(t4.PositiveX+l,e[l],0);s.generateMipmaps(),t.addContentRestorer(new cA(s,a,i)),n(s)}).catch(function(e){r(e)})})},t}(ol);cE=s3([it(a2.TextureCube,[""])],cE);var cR=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){var a=e.url,i=s$({},e,{type:"arraybuffer"});t._request(a,i).then(function(e){var i=new sM(t.engine);sw.getContext().decodeAudioData(e).then(function(e){if(i._setAudioSource(e),0!==a.indexOf("data:")){var t=a.lastIndexOf("/");i.name=a.substring(t+1)}n(i)}).catch(function(e){r(e)})})})},t}(ol);cR=s3([it(a2.Audio,["mp3","ogg","wav"])],cR);var cM=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,n){var r=e.url;return n._request(r,s$({},e,{type:"text"})).then(function(e){return n$.registerInclude(r.substring(1),e),t._loadChunksInCode(e,r,n)})},t._loadChunksInCode=function(e,n,r){for(var a,i=[],o=e.matchAll(t._shaderIncludeRegex),s=lf(o);!(a=s()).done;){var l=a.value,c=nT.resolveAbsoluteUrl(n,l[1]);nZ[c.substring(1)]||i.push(c)}return Promise.all(i.map(function(e){return r.load({type:"ShaderChunk",url:e})}))},t}(ol);cM._shaderIncludeRegex=/#include\s+"([./][^\\"]+)"/gm,cM=s3([it("ShaderChunk",["glsl"])],cM);var cw=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this,r=e.url;return t._request(r,s$({},e,{type:"text"})).then(function(e){var a=n._getBuiltinShader(e);return a?ro.find(a):cM._loadChunksInCode(e,r,t).then(function(){var t=ro.create(e);return t._registerPath(r),t})})},n._getBuiltinShader=function(e){var n=e.match(t._builtinRegex);if(n&&n[1])return n[1]},t}(ol);cw._builtinRegex=/^\s*\/\/\s*@builtin\s+(\w+)/,cw=s3([it(a2.Shader,["gs","gsl"])],cw);var cP=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){return lg.parse(n,e).then(function(n){var a,i,o=[],s=e.scene.ambient;if(s){var l=s.specularMode===ld.Custom,c=s.diffuseMode===i4.SphericalHarmonics;n.ambientLight.diffuseIntensity=s.diffuseIntensity,n.ambientLight.specularIntensity=s.specularIntensity,n.ambientLight.diffuseMode=s.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(s.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,l&&s.customAmbientLight&&o.push(t.getResourceByRef(s.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),s.ambientLight&&(!l||c)&&o.push(t.getResourceByRef(s.ambientLight).then(function(e){l||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),c&&(n.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var u=e.scene.background;switch(n.background.mode=u.mode,n.background.mode){case rO.SolidColor:n.background.solidColor.copyFrom(u.color);break;case rO.Sky:if(u.skyMesh&&u.skyMaterial){var d=t.getResourceByRef(u.skyMesh).then(function(e){n.background.sky.mesh=e}),h=t.getResourceByRef(u.skyMaterial).then(function(e){n.background.sky.material=e});o.push(d,h)}else no.warn("Sky background mode requires skyMesh and skyMaterial");break;case rO.Texture:if(u.texture){var _,f=t.getResourceByRef(u.texture).then(function(e){n.background.texture=e});o.push(f),n.background.textureFillMode=null!=(_=u.textureFillMode)?_:n.background.textureFillMode}}var p=e.scene.shadow;p&&(void 0!=p.castShadows&&(n.castShadows=p.castShadows),void 0!=p.shadowResolution&&(n.shadowResolution=p.shadowResolution),void 0!=p.shadowDistance&&(n.shadowDistance=p.shadowDistance),void 0!=p.shadowCascades&&(n.shadowCascades=p.shadowCascades),void 0!=p.enableTransparentShadow&&(n.enableTransparentShadow=p.enableTransparentShadow),n.shadowTwoCascadeSplits=null!=(a=p.shadowTwoCascadeSplits)?a:n.shadowTwoCascadeSplits,p.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(p.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(i=p.shadowFadeBorder)?i:n.shadowFadeBorder);var m=e.scene.fog;m&&(void 0!=m.fogMode&&(n.fogMode=m.fogMode),void 0!=m.fogStart&&(n.fogStart=m.fogStart),void 0!=m.fogEnd&&(n.fogEnd=m.fogEnd),void 0!=m.fogDensity&&(n.fogDensity=m.fogDensity),void 0!=m.fogColor&&n.fogColor.copyFrom(m.fogColor));var g=e.scene.postProcess;if(g){var v=n._postProcessManager,y=v._bloomEffect,x=v._tonemappingEffect;if(v.isActive=g.isActive,y.enabled=g.bloom.enabled,y.downScale=g.bloom.downScale,y.threshold=g.bloom.threshold,y.scatter=g.bloom.scatter,y.intensity=g.bloom.intensity,y.tint.copyFrom(g.bloom.tint),y.dirtIntensity=g.bloom.dirtIntensity,x.enabled=g.tonemapping.enabled,x.mode=g.tonemapping.mode,g.bloom.dirtTexture){var b=t.getResourceByRef(g.bloom.dirtTexture).then(function(e){y.dirtTexture=e});o.push(b)}}return Promise.all(o).then(function(){r(n)})})}).catch(a)})},t}(ol);cP=s3([it(a2.Scene,["scene"],!0)],cP),ll.registerCustomParseComponent("TextRenderer",/*#__PURE__*/lA(function(e,t){var n;return s4(this,function(r){return(n=t.props).font||(e.font=ng.createFromOS(e.engine,n.fontFamily||"Arial")),[2,e]})}));var cF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r,a=e.glTF.extensions.KHR_lights_punctual.lights[n.light],i=a.color,o=a.intensity,s=a.type,l=a.range,c=a.spot,u=e.glTFResource;if("directional"===s?r=t.addComponent(i9):"point"===s?r=t.addComponent(i6):"spot"===s&&(r=t.addComponent(i7)),i&&r.color.set(i[0],i[1],i[2],1),r.intensity=void 0===o?1:o,l&&!lh(r,i9)&&(r.distance=l),c&&lh(r,i7)){var d=c.innerConeAngle,h=void 0===d?0:d,_=c.outerConeAngle,f=void 0===_?Math.PI/4:_;r.angle=h,r.penumbra=f-h}u.lights||(u.lights=[]),u.lights.push(r)},t}(ct);cF=s3([ca("KHR_lights_punctual",cn.AdditiveParse)],cF);var cL=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.clearcoatFactor,i=r.clearcoatTexture,o=r.clearcoatRoughnessFactor,s=r.clearcoatRoughnessTexture,l=r.clearcoatNormalTexture;n.clearCoat=void 0===a?0:a,n.clearCoatRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Clear coat"),t.get(lk.Texture,i.index).then(function(e){n.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(lk.Texture,s.index).then(function(e){n.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(lk.Texture,l.index).then(function(e){n.clearCoatNormalTexture=e}))},n}(ct);cL=s3([ca("KHR_materials_clearcoat",cn.AdditiveParse)],cL);var cD=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},t}(ct);cD=s3([ca("KHR_materials_ior",cn.AdditiveParse)],cD);var cB=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.createAndParse=function(t,n,r){var a=new ah(t.glTFResource.engine),i=n.diffuseFactor,o=n.diffuseTexture,s=n.specularFactor,l=n.glossinessFactor,c=n.specularGlossinessTexture;return i&&(a.baseColor=new tO(tO.linearToGammaSpace(i[0]),tO.linearToGammaSpace(i[1]),tO.linearToGammaSpace(i[2]),i[3])),o&&t.get(lk.Texture,o.index).then(function(e){a.baseTexture=e,cr.executeExtensionsAdditiveAndParse(o.extensions,t,a,o)}),s&&(a.specularColor=new tO(tO.linearToGammaSpace(s[0]),tO.linearToGammaSpace(s[1]),tO.linearToGammaSpace(s[2]))),void 0!==l&&(a.glossiness=l),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"Specular glossiness"),t.get(lk.Texture,c.index).then(function(e){a.specularGlossinessTexture=e})),a.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,a,r),a},n}(ct);cB=s3([ca("KHR_materials_pbrSpecularGlossiness",cn.CreateAndParse)],cB);var cI=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.sheenColorFactor,i=r.sheenColorTexture,o=r.sheenRoughnessFactor,s=r.sheenRoughnessTexture;a&&n.sheenColor.set(tO.linearToGammaSpace(a[0]),tO.linearToGammaSpace(a[1]),tO.linearToGammaSpace(a[2]),void 0),n.sheenRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Sheen texture"),t.get(lk.Texture,i.index).then(function(e){n.sheenColorTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"SheenRoughness texture"),t.get(lk.Texture,s.index).then(function(e){n.sheenRoughnessTexture=e}))},n}(ct);cI=s3([ca("KHR_materials_sheen",cn.AdditiveParse)],cI);var cO=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.createAndParse=function(t,n,r){var a=new a_(t.glTFResource.engine);return a.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,a,r),a},n}(ct);cO=s3([ca("KHR_materials_unlit",cn.CreateAndParse)],cO);var cN=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r=e.glTF.extensions.KHR_materials_variants.variants,a=e.glTFResource,i=n.mappings;a._extensionsData||(a._extensionsData={});var o=[];a.extensionsData.variants=o;for(var s=0;s<i.length;s++)!function(n){var a=i[n],s=a.material,l=a.variants;e.get(lk.Material,s).then(function(e){o.push({renderer:t,material:e,variants:l.map(function(e){return r[e].name})})})}(s)},t}(ct);cN=s3([ca("KHR_materials_variants",cn.AdditiveParse)],cN);var cV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t}(ct);cV=s3([ca("KHR_mesh_quantization",cn.AdditiveParse)],cV);var ck=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.createAndParse=function(t,n,r){return lA(function(){var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y;return s4(this,function(x){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=r.sampler,c=r.name,u=n.source,h=(d=a.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&lH.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:nT.resolveAbsoluteUrl(s,h),type:a2.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&lH.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=a.bufferViews[_],[2,t.get(lk.Buffer,y.buffer).then(function(n){var r=new Uint8Array(n,y.byteOffset,y.byteLength);return e.KTX2Loader._parseBuffer(r,o).then(function(t){var n=t.engine,r=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(n,r,a,i)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&lH.parseSampler(e,m);var n=new l4(e,y,f);return t.contentRestorer.bufferTextures.push(n),e})})])})})()},n}(ct);ck=s3([ca("KHR_texture_basisu",cn.CreateAndParse)],ck);var cz=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.offset,a=n.rotation,i=n.scale,o=n.texCoord;r&&(t.tilingOffset.z=r[0],t.tilingOffset.w=r[1]),i&&(t.tilingOffset.x=i[0],t.tilingOffset.y=i[1]),a&&no.warn("rotation in KHR_texture_transform is not supported now"),o&&no.warn("texCoord in KHR_texture_transform is not supported now")},t}(ct);cz=s3([ca("KHR_texture_transform",cn.AdditiveParse)],cz);var cU=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.createAndParse=function(e,t){var n=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(n),n},t}(ct);cU=s3([ca("GALACEAN_materials_remap",cn.CreateAndParse)],cU);var cG=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new og;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},t}(ct);cG=s3([ca("GALACEAN_animation_event",cn.AdditiveParse)],cG);var cH=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.createAndParse=function(e,t){return e.get(lk.Buffer,t.buffer).then(function(e){return ci().then(function(n){return n.decodeGltfBuffer(t.count,t.byteStride,new Uint8Array(e,t.byteOffset,t.byteLength),t.mode,t.filter)})})},t}(ct);cH=s3([ca("EXT_meshopt_compression",cn.CreateAndParse)],cH);var cW=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.anisotropyStrength,i=r.anisotropyRotation,o=r.anisotropyTexture;n.anisotropy=void 0===a?0:a,n.anisotropyRotation=void 0===i?0:i,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(lk.Texture,o.index).then(function(e){n.anisotropyTexture=e}))},n}(ct);cW=s3([ca("KHR_materials_anisotropy",cn.AdditiveParse)],cW);var cj=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.iridescenceFactor,i=r.iridescenceTexture,o=r.iridescenceIor,s=r.iridescenceThicknessMinimum,l=r.iridescenceThicknessMaximum,c=r.iridescenceThicknessTexture;n.iridescence=void 0===a?0:a,n.iridescenceIOR=void 0===o?1.3:o,n.iridescenceThicknessRange.set(void 0===s?100:s,void 0===l?400:l),i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Iridescence texture"),t.get(lk.Texture,i.index).then(function(e){n.iridescenceTexture=e})),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"IridescenceThickness texture"),t.get(lk.Texture,c.index).then(function(e){n.iridescenceThicknessTexture=e}))},n}(ct);cj=s3([ca("KHR_materials_iridescence",cn.AdditiveParse)],cj);var cX=/*#__PURE__*/function(t){function n(){var e;if((e=t.call(this)||this)._supportWebP=!1,id._isBrowser){var n=document.createElement("canvas");n.width=n.height=1,e._supportWebP=0==n.toDataURL("image/webp").indexOf("data:image/webp")}else e._supportWebP=!1;return e}return s1(n,t),n.prototype.createAndParse=function(t,n,r,a){var i=this;return lA(function(){var o,s,l,c,u;return s4(this,function(d){return o=n.source,s=r.sampler,c=void 0===(l=r.source)?0:l,u=r.name,[2,e.GLTFTextureParser._parseTexture(t,i._supportWebP?o:c,a,s,u)]})})()},n}(ct);cX=s3([ca("EXT_texture_webp",cn.CreateAndParse)],cX);var cK="1.4.0-alpha.1";for(var cY in console.log("Galacean engine version: "+cK),sF)ol.registerClass(cY,sF[cY]);e.AccessorType=lw,e.AmbientLight=i8,e.AnimationClip=ov,e.AnimationClipCurveBinding=om,e.AnimationCurve=ox,e.AnimationEvent=og,e.Animator=oD,e.AnimatorCondition=oR,e.AnimatorConditionMode=ob,e.AnimatorController=oI,e.AnimatorControllerLayer=oz,e.AnimatorControllerParameter=oB,e.AnimatorCullingMode=oC,e.AnimatorLayerBlendingMode=oS,e.AnimatorLayerMask=oH,e.AnimatorState=oV,e.AnimatorStateMachine=ok,e.AnimatorStateTransition=oM,e.AssetPromise=a8,e.AssetType=a2,e.AudioClip=sM,e.AudioManager=sw,e.AudioSource=sP,e.Background=i0,e.BackgroundMode=rO,e.BackgroundTextureFillMode=rN,e.BaseMaterial=as,e.BasicRenderPipeline=rZ,e.BlendFactor=nF,e.BlendMode=aa,e.BlendOperation=nL,e.BlendShape=am,e.BlendShapeFrame=af,e.BlendState=rt,e.BlinnPhongMaterial=al,e.BloomDownScaleMode=ot,e.BloomEffect=on,e.BoolUpdateFlag=rf,e.BoundingBox=tE,e.BoundingFrustum=tw,e.BoundingSphere=tA,e.BoxColliderShape=iI,e.BoxShape=s_,e.Buffer=r9,e.BufferBindFlag=an,e.BufferInfo=lV,e.BufferMesh=aT,e.BufferReader=s9,e.BufferUsage=r8,e.BufferUtil=ae,e.Burst=sc,e.CameraClearFlags=rw,e.CameraType=rP,e.Canvas=iZ,e.CapsuleColliderShape=iV,e.CharacterController=ig,e.CircleShape=sp,e.ClearableObjectPool=iq,e.CloneManager=t$,e.ColliderShape=iB,e.ColliderShapeUpAxis=iA,e.CollisionDetectionMode=iy,e.CollisionUtil=tR,e.Color=tO,e.ColorOverLifetimeModule=o5,e.ColorSpace=n2,e.ColorWriteMask=nD,e.CompareFunction=nB,e.Component=ru,e.ConeEmitType=sg,e.ConeShape=sm,e.ContainmentType=tv,e.ContentRestorer=t2,e.ControllerCollisionFlag=iE,e.ControllerNonWalkableMode=im,e.CubeProbe=sR,e.CullMode=nI,e.CurveKey=sr,e.DataType=nQ,e.DependentMode=r_,e.DepthState=rn,e.DepthTextureMode=rF,e.DiffuseMode=i4,e.DirectLight=i9,e.DisorderedArray=rC,e.Downsampling=rL,e.DynamicCollider=iv,e.DynamicColliderConstraints=ix,e.EmissionModule=o6,e.Engine=iJ,e.EngineObject=t0,e.Entity=aW,e.EventDispatcher=nK,e.FileHeader=le,e.FixedJoint=iM,e.FogMode=i3,e.Font=ng,e.FontStyle=n_,e.FrustumFace=tx,e.GLCapabilityType=nJ,e.GLCompressedTextureInternalFormat=sL,e.GLTFExtensionMode=cn,e.GLTFExtensionParser=ct,e.GLTFParser=cr,e.GLTFParserContext=lN,e.GLTFParserType=lk,e.GLTFResource=lR,e.GLTFUtils=lH,e.GradientAlphaKey=o3,e.GradientColorKey=o2,e.HemisphereShape=sv,e.HingeJoint=iP,e.HitResult=ib,e.IndexBufferBinding=ag,e.IndexFormat=r6,e.InputManager=iU,e.InterpolableValueType=lc,e.InterpolationType=oy,e.JointLimits=iL,e.JointMotor=iD,e.KTX2TargetFormat=lX,e.KTX2Transcoder=l1,e.Keyframe=oU,e.Keys=ih,e.Layer=rE,e.LayerPathMask=oG,e.Light=i5,e.Loader=ol,e.Logger=no,e.MSAASamples=rD,e.MainModule=se,e.Material=ao,e.MaterialLoaderType=lu,e.MathUtil=tS,e.Matrix=tL,e.Matrix3x3=tP,e.Mesh=ab,e.MeshRenderer=aA,e.MeshTopology=ar,e.ModelMesh=aM,e.OverflowMode=nf,e.PBRBaseMaterial=au,e.PBRMaterial=ad,e.PBRSpecularMaterial=ah,e.ParserContext=ls,e.ParserType=lo,e.ParticleCompositeCurve=o9,e.ParticleCompositeGradient=o4,e.ParticleCurve=sn,e.ParticleCurveMode=oZ,e.ParticleGenerator=ss,e.ParticleGradient=o1,e.ParticleGradientMode=o$,e.ParticleMaterial=sl,e.ParticleRenderMode=oK,e.ParticleRenderer=oQ,e.ParticleScaleMode=o7,e.ParticleShapeArcMode=sf,e.ParticleShapeType=sh,e.ParticleSimulationSpace=oY,e.ParticleStopMode=oq,e.PhysicsMaterial=iS,e.PhysicsMaterialCombineMode=iC,e.PhysicsScene=ip,e.PipelineStage=nX,e.Plane=tM,e.PlaneColliderShape=iN,e.PlaneIntersectionType=ty,e.Platform=tz,e.PointLight=i6,e.Pointer=is,e.PointerButton=il,e.PointerPhase=io,e.PrefabResource=lp,e.Primitive=ax,e.PrimitiveMesh=az,e.Probe=sS,e.Quaternion=tF,e.Rand=tk,e.RasterState=rr,e.Ray=tD,e.Rect=tN,e.ReferResource=t1,e.ReflectionParser=ll,e.RenderBufferDepthFormat=t3,e.RenderFace=ai,e.RenderQueue=rG,e.RenderQueueType=nN,e.RenderState=ri,e.RenderStateDataKey=nO,e.RenderTarget=nl,e.RenderTargetBlendState=re,e.ReplacementFailureStrategy=rB,e.ResourceManager=ie,e.ReturnableObjectPool=aQ,e.RotationOverLifetimeModule=st,e.SafeLoopArray=a3,e.Scene=oo,e.SceneManager=a4,e.SceneParser=lg,e.Script=os,e.SetDataOptions=r5,e.Shader=ro,e.ShaderData=rs,e.ShaderFactory=n$,e.ShaderLib=nZ,e.ShaderMacro=nH,e.ShaderMacroCollection=nW,e.ShaderPass=n6,e.ShaderPlatformTarget=nz,e.ShaderProperty=nY,e.ShaderPropertyType=nV,e.ShaderTagKey=n0,e.ShadowCascadesMode=rK,e.ShadowResolution=rW,e.ShadowType=rj,e.SizeOverLifetimeModule=sa,e.Skin=aj,e.SkinnedMeshRenderer=aK,e.Sky=i$,e.SkyBoxMaterial=oW,e.SkyProceduralMaterial=oX,e.SpecularMode=ld,e.SphereColliderShape=iO,e.SphereShape=sy,e.SphericalHarmonics3=tV,e.SpotLight=i7,e.SpringJoint=iF,e.Sprite=nP,e.SpriteAtlas=nb,e.SpriteDrawMode=nC,e.SpriteMask=r2,e.SpriteMaskInteraction=nv,e.SpriteMaskLayer=rg,e.SpriteRenderer=rT,e.SpriteTileMode=nS,e.StateMachineScript=oN,e.StaticCollider=iT,e.StencilOperation=nk,e.StencilState=ra,e.SubMesh=ay,e.SubPrimitive=av,e.SubShader=n7,e.SunMode=oj,e.SystemInfo=id,e.TextHorizontalAlignment=ny,e.TextRenderer=r3,e.TextUtils=np,e.TextVerticalAlignment=nx,e.Texture=ns,e.Texture2D=nc,e.Texture2DArray=nu,e.TextureCoordinate=ac,e.TextureCube=nd,e.TextureCubeFace=t4,e.TextureDepthCompareFunction=t8,e.TextureFilterMode=t5,e.TextureFormat=t9,e.TextureSheetAnimationModule=si,e.TextureUsage=t6,e.TextureWrapMode=t7,e.Time=nq,e.TonemappingEffect=oa,e.TonemappingMode=or,e.TrailMaterial=sx,e.TrailRenderer=sC,e.Transform=rp,e.UnlitMaterial=a_,e.Utils=nT,e.Vector2=tB,e.Vector3=tT,e.Vector4=tI,e.VelocityOverLifetimeModule=so,e.VertexAttribute=aR,e.VertexBufferBinding=aS,e.VertexElement=at,e.VertexElementFormat=r7,e.WebCanvas=sV,e.WebGLEngine=sk,e.WebGLGraphicDevice=sZ,e.WebGLMode=sJ,e.WrapMode=ow,e.XRManager=iQ,e._PostProcessManager=oi,e.assignmentClone=tQ,e.decode=lv,e.decoder=s7,e.decoderMap=s6,e.deepClone=tZ,e.dependentComponents=rh,e.ignoreClone=tq,e.parseSingleKTX=c_,e.registerGLTFExtension=ca,e.registerGLTFParser=lG,e.request=a6,e.resourceLoader=it,e.shallowClone=tJ,e.version=cK,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=browser.min.js.map