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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,i,a,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,b,C,S,T,A,R,E,M,w,P,F,L,D,B,I,O,N,V,k,z,U,G,H,W,j,X,K,q,Y,Q,J,Z,$,ee,et,en,er,ei,ea,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eC,eS,eT,eA,eR,eE,eM,ew,eP,eF,eL,eD,eB,eI,eO,eN,eV,ek,ez,eU,eG,eH,eW,ej,eX,eK,eq,eY,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tn,tr,ti,ta,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv,ty,tx=((t_={})[t_.Disjoint=0]="Disjoint",t_[t_.Contains=1]="Contains",t_[t_.Intersects=2]="Intersects",t_),tb=((r={})[r.Back=0]="Back",r[r.Front=1]="Front",r[r.Intersecting=2]="Intersecting",r),tC=((i={})[i.Near=0]="Near",i[i.Far=1]="Far",i[i.Left=2]="Left",i[i.Right=3]="Right",i[i.Bottom=4]="Bottom",i[i.Top=5]="Top",i);function tS(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 tT(e,t,n){return t&&tS(e.prototype,t),n&&tS(e,n),e}var tA=/*#__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}();tA.zeroTolerance=1e-6,tA.radToDegreeFactor=180/Math.PI,tA.degreeToRadFactor=Math.PI/180;var tR=/*#__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,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z;n.set(i*l-a*s,a*o-r*l,r*s-i*o)},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,i=t._z-e._z;return Math.sqrt(n*n+r*r+i*i)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,i=t._z-e._z;return n*n+r*r+i*i},e.equals=function(e,t){return tA.equals(e._x,t._x)&&tA.equals(e._y,t._y)&&tA.equals(e._z,t._z)},e.lerp=function(e,t,n,r){var i=e._x,a=e._y,o=e._z;r._x=i+(t._x-i)*n,r._y=a+(t._y-a)*n,r._z=o+(t._z-o)*n,r._onValueChanged&&r._onValueChanged()},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,i=e._z,a=Math.sqrt(n*n+r*r+i*i);a>tA.zeroTolerance&&(a=1/a,t.set(n*a,r*a,i*a))},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,i=e._y,a=e._z,o=t.elements;n._x=r*o[0]+i*o[4]+a*o[8],n._y=r*o[1]+i*o[5]+a*o[9],n._z=r*o[2]+i*o[6]+a*o[10],n._onValueChanged&&n._onValueChanged()},e.transformToVec3=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t.elements;n._x=r*o[0]+i*o[4]+a*o[8]+o[12],n._y=r*o[1]+i*o[5]+a*o[9]+o[13],n._z=r*o[2]+i*o[6]+a*o[10]+o[14],n._onValueChanged&&n._onValueChanged()},e.transformToVec4=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t.elements;n._x=r*o[0]+i*o[4]+a*o[8]+o[12],n._y=r*o[1]+i*o[5]+a*o[9]+o[13],n._z=r*o[2]+i*o[6]+a*o[10]+o[14],n._w=r*o[3]+i*o[7]+a*o[11]+o[15],n._onValueChanged&&n._onValueChanged()},e.transformCoordinate=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t.elements,s=r*o[3]+i*o[7]+a*o[11]+o[15];s=1/s,n._x=(r*o[0]+i*o[4]+a*o[8]+o[12])*s,n._y=(r*o[1]+i*o[5]+a*o[9]+o[13])*s,n._z=(r*o[2]+i*o[6]+a*o[10]+o[14])*s,n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*r+s*a-l*i,d=c*i+l*r-o*a,h=c*a+o*i-s*r,_=-o*r-s*i-l*a;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()},tT(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}();tR._zero=new tR(0,0,0),tR._one=new tR(1,1,1);var tE=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new tR,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,i=e._tempVec30;i.x=i.y=i.z=0;for(var a=0;a<r;++a)tR.add(t[a],i,i);tR.scale(i,1/r,n.center);for(var o=0,s=0;s<r;++s){var l=tR.distanceSquared(i,t[s]);l>o&&(o=l)}n.radius=Math.sqrt(o)},e.fromBox=function(e,t){var n=t.center,r=e.min,i=e.max;n.x=(r.x+i.x)*.5,n.y=(r.y+i.y)*.5,n.z=(r.z+i.z)*.5,t.radius=tR.distance(n,i)},e}();tE._tempVec30=new tR;var tM=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new tR,this.max=new tR,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,i=n._y+t._y,a=n._z+t._z;return e.set(isNaN(r)?0:.5*r,isNaN(i)?0:.5*i,isNaN(a)?0:.5*a),e},t.getExtent=function(e){var t=this.min,n=this.max,r=n._x-t._x,i=n._y-t._y,a=n._z-t._z;return e.set(isNaN(r)?0:.5*r,isNaN(i)?0:.5*i,isNaN(a)?0:.5*a),e},t.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,n=this.max,r=t.x,i=t.y,a=t.z,o=n.x,s=n.y,l=n.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new tR;return e[0].set(r,s,l),e[1].set(o,s,l),e[2].set(o,i,l),e[3].set(r,i,l),e[4].set(r,s,a),e[5].set(o,s,a),e[6].set(o,i,a),e[7].set(r,i,a),e},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){tR.subtract(e,t,n.min),tR.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 i=0,a=e.length;i<a;++i){var o=e[i];tR.min(n,o,n),tR.max(r,o,r)}},e.fromSphere=function(e,t){var n=e.center,r=e.radius,i=t.min,a=t.max;i.x=n.x-r,i.y=n.y-r,i.z=n.z-r,a.x=n.x+r,a.y=n.y+r,a.z=n.z+r},e.transform=function(t,n,r){var i=e._tempVec30,a=e._tempVec31;t.getCenter(i),t.getExtent(a),tR.transformCoordinate(i,n,i);var o=a.x,s=a.y,l=a.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];a.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))),tR.subtract(i,a,r.min),tR.add(i,a,r.max)},e.merge=function(e,t,n){return tR.min(e.min,t.min,n.min),tR.max(e.max,t.max,n.max),n},e}();tM._tempVec30=new tR,tM._tempVec31=new tR;var tw=/*#__PURE__*/function(){function e(){}return e.intersectionPointThreePlanes=function(t,n,r,i){var a=t.normal,o=n.normal,s=r.normal;tR.cross(o,s,e._tempVec30),tR.cross(s,a,e._tempVec31),tR.cross(a,o,e._tempVec32);var l=-tR.dot(a,e._tempVec30),c=-tR.dot(o,e._tempVec31),u=-tR.dot(s,e._tempVec32);tR.scale(e._tempVec30,t.distance/l,e._tempVec30),tR.scale(e._tempVec31,n.distance/c,e._tempVec31),tR.scale(e._tempVec32,r.distance/u,e._tempVec32),tR.add(e._tempVec30,e._tempVec31,i),tR.add(i,e._tempVec32,i)},e.distancePlaneAndPoint=function(e,t){return tR.dot(e.normal,t)+e.distance},e.intersectsPlaneAndPoint=function(t,n){var r=e.distancePlaneAndPoint(t,n);return r>0?tb.Front:r<0?tb.Back:tb.Intersecting},e.intersectsPlaneAndBox=function(t,n){var r=n.min,i=n.max,a=t.normal,o=e._tempVec30,s=e._tempVec31;return(a.x>=0?(o.x=i.x,s.x=r.x):(o.x=r.x,s.x=i.x),a.y>=0?(o.y=i.y,s.y=r.y):(o.y=r.y,s.y=i.y),a.z>=0?(o.z=i.z,s.z=r.z):(o.z=r.z,s.z=i.z),0>e.distancePlaneAndPoint(t,o))?tb.Back:e.distancePlaneAndPoint(t,s)>0?tb.Front:tb.Intersecting},e.intersectsPlaneAndSphere=function(t,n){var r=n.center,i=n.radius,a=e.distancePlaneAndPoint(t,r);return a>i?tb.Front:a<-i?tb.Back:tb.Intersecting},e.intersectsRayAndPlane=function(e,t){var n=t.normal,r=tA.zeroTolerance,i=tR.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=tR.dot(n,e.origin),o=(-t.distance-a)/i;if(o<0){if(o<-r)return -1;o=0}return o},e.intersectsRayAndBox=function(e,t){var n=tA.zeroTolerance,r=e.origin,i=e.direction,a=t.min,o=t.max,s=i.x,l=i.y,c=i.z,u=r.x,d=r.y,h=r.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<n){if(u<a.x||u>o.x)return -1}else{var p=1/s,m=(a.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<a.y||d>o.y)return -1}else{var y=1/l,x=(a.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<a.z||h>o.z)return -1}else{var S=1/c,T=(a.z-h)*S,A=(o.z-h)*S;if(T>A){var R=T;T=A,A=R}if((_=Math.max(T,_))>(f=Math.min(A,f)))return -1}return _},e.intersectsRayAndSphere=function(t,n){var r=t.origin,i=t.direction,a=n.center,o=n.radius,s=e._tempVec30;tR.subtract(r,a,s);var l=tR.dot(s,i),c=tR.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 tR.distanceSquared(e.center,t.center)<n*n},e.intersectsSphereAndBox=function(t,n){var r=t.center,i=n.max,a=n.min,o=e._tempVec30;return o.set(Math.max(a.x,Math.min(r.x,i.x)),Math.max(a.y,Math.min(r.y,i.y)),Math.max(a.z,Math.min(r.z,i.z))),tR.distanceSquared(r,o)<=t.radius*t.radius},e.intersectsFrustumAndBox=function(t,n){for(var r=n.min,i=n.max,a=e._tempVec30,o=0;o<6;++o){var s=t.getPlane(o),l=s.normal;if(a.set(l.x>=0?i.x:r.x,l.y>=0?i.y:r.y,l.z>=0?i.z:r.z),tR.dot(l,a)<-s.distance)return!1}return!0},e.frustumContainsPoint=function(t,n){var r=e.distancePlaneAndPoint(t.near,n);return Math.abs(r)<tA.zeroTolerance?tx.Intersects:r<0?tx.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.far,n))<tA.zeroTolerance?tx.Intersects:r<0?tx.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.left,n))<tA.zeroTolerance?tx.Intersects:r<0?tx.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.right,n))<tA.zeroTolerance?tx.Intersects:r<0?tx.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.top,n))<tA.zeroTolerance?tx.Intersects:r<0?tx.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.bottom,n))<tA.zeroTolerance?tx.Intersects:r<0?tx.Disjoint:tx.Contains},e.frustumContainsBox=function(t,n){for(var r=n.min,i=n.max,a=e._tempVec30,o=e._tempVec31,s=tx.Contains,l=0;l<6;++l){var c=t.getPlane(l),u=c.normal;if(u.x>=0?(a.x=i.x,o.x=r.x):(a.x=r.x,o.x=i.x),u.y>=0?(a.y=i.y,o.y=r.y):(a.y=r.y,o.y=i.y),u.z>=0?(a.z=i.z,o.z=r.z):(a.z=r.z,o.z=i.z),e.intersectsPlaneAndPoint(c,a)===tb.Back)return tx.Disjoint;e.intersectsPlaneAndPoint(c,o)===tb.Back&&(s=tx.Intersects)}return s},e.frustumContainsSphere=function(t,n){for(var r=tx.Contains,i=0;i<6;++i){var a=t.getPlane(i),o=e.intersectsPlaneAndSphere(a,n);if(o===tb.Back)return tx.Disjoint;if(o===tb.Intersecting){r=tx.Intersects;break}}return r},e}();tw._tempVec30=new tR,tw._tempVec31=new tR,tw._tempVec32=new tR;var tP=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new tR,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();tR.scale(n,r,t.normal),t.distance=e.distance*r},e.fromPoints=function(e,t,n,r){var i=e.x,a=e.y,o=e.z,s=t.x-i,l=t.y-a,c=t.z-o,u=n.x-i,d=n.y-a,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*i+v*a+y*o)},e}(),tF=/*#__PURE__*/function(){function e(e){void 0===e&&(e=null),this.near=new tP,this.far=new tP,this.left=new tP,this.right=new tP,this.top=new tP,this.bottom=new tP,e&&this.calculateFromMatrix(e)}var t=e.prototype;return t.getPlane=function(e){switch(e){case tC.Near:return this.near;case tC.Far:return this.far;case tC.Left:return this.left;case tC.Right:return this.right;case tC.Bottom:return this.bottom;case tC.Top:return this.top;default:return null}},t.calculateFromMatrix=function(e){var t=e.elements,n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],_=t[11],f=t[12],p=t[13],m=t[14],g=t[15];this.near.normal.set(a+i,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(a-i,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(a+n,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(a-n,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(a+r,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(a-r,c-s,_-d),this.top.distance=g-p,this.top.normalize()},t.intersectsBox=function(e){return tw.intersectsFrustumAndBox(this,e)},t.intersectsSphere=function(e){return tw.frustumContainsSphere(this,e)!==tx.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}(),tL=/*#__PURE__*/function(){function e(e,t,n,r,i,a,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=1),void 0===a&&(a=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=i,c[5]=a,c[6]=o,c[7]=s,c[8]=l}var t=e.prototype;return t.set=function(e,t,n,r,i,a,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=i,c[5]=a,c[6]=o,c[7]=s,c[8]=l,this},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],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*a-o*l)+n*(-c*i+o*s)+r*(l*i-a*s)},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,i=t.elements,a=n.elements;a[0]=r[0]+i[0],a[1]=r[1]+i[1],a[2]=r[2]+i[2],a[3]=r[3]+i[3],a[4]=r[4]+i[4],a[5]=r[5]+i[5],a[6]=r[6]+i[6],a[7]=r[7]+i[7],a[8]=r[8]+i[8]},e.subtract=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements;a[0]=r[0]-i[0],a[1]=r[1]-i[1],a[2]=r[2]-i[2],a[3]=r[3]-i[3],a[4]=r[4]-i[4],a[5]=r[5]-i[5],a[6]=r[6]-i[6],a[7]=r[7]-i[7],a[8]=r[8]-i[8]},e.multiply=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],_=r[7],f=r[8],p=i[0],m=i[1],g=i[2],v=i[3],y=i[4],x=i[5],b=i[6],C=i[7],S=i[8];a[0]=o*p+c*m+h*g,a[1]=s*p+u*m+_*g,a[2]=l*p+d*m+f*g,a[3]=o*v+c*y+h*x,a[4]=s*v+u*y+_*x,a[5]=l*v+d*y+f*x,a[6]=o*b+c*C+h*S,a[7]=s*b+u*C+_*S,a[8]=l*b+d*C+f*S},e.equals=function(e,t){var n=e.elements,r=t.elements;return tA.equals(n[0],r[0])&&tA.equals(n[1],r[1])&&tA.equals(n[2],r[2])&&tA.equals(n[3],r[3])&&tA.equals(n[4],r[4])&&tA.equals(n[5],r[5])&&tA.equals(n[6],r[6])&&tA.equals(n[7],r[7])&&tA.equals(n[8],r[8])},e.lerp=function(e,t,n,r){var i=e.elements,a=t.elements,o=r.elements,s=1-n;o[0]=i[0]*s+a[0]*n,o[1]=i[1]*s+a[1]*n,o[2]=i[2]*s+a[2]*n,o[3]=i[3]*s+a[3]*n,o[4]=i[4]*s+a[4]*n,o[5]=i[5]*s+a[5]*n,o[6]=i[6]*s+a[6]*n,o[7]=i[7]*s+a[7]*n,o[8]=i[8]*s+a[8]*n},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,i=e._y,a=e._z,o=e._w,s=r+r,l=i+i,c=a+a,u=r*s,d=i*s,h=i*l,_=a*s,f=a*l,p=a*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,i=n[0],a=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=i*_+a*f+o*p;m&&(m=1/m,r[0]=_*m,r[1]=(-h*a+o*d)*m,r[2]=(c*a-o*l)*m,r[3]=f*m,r[4]=(h*i-o*u)*m,r[5]=(-c*i+o*s)*m,r[6]=p*m,r[7]=(-d*i+a*u)*m,r[8]=(l*i-a*s)*m)},e.normalMatrix=function(e,t){var n=e.elements,r=t.elements,i=n[0],a=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],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=i*c-a*l,b=i*u-o*l,C=i*d-s*l,S=a*u-o*c,T=a*d-s*c,A=o*d-s*u,R=h*g-_*m,E=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*E+A*R;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(u*M-l*F-d*E)*L,r[2]=(l*P-c*M+d*R)*L,r[3]=(o*P-a*F-s*w)*L,r[4]=(i*F-o*M+s*E)*L,r[5]=(a*M-i*P-s*R)*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,i=n.elements,a=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];i[0]=o*s+a*u,i[1]=o*l+a*d,i[2]=o*c+a*h,i[3]=o*u-a*s,i[4]=o*d-a*l,i[5]=o*h-a*c,i[6]=_,i[7]=f,i[8]=p},e.scale=function(e,t,n){var r=t._x,i=t._y,a=e.elements,o=n.elements;o[0]=r*a[0],o[1]=r*a[1],o[2]=r*a[2],o[3]=i*a[3],o[4]=i*a[4],o[5]=i*a[5],o[6]=a[6],o[7]=a[7],o[8]=a[8]},e.translate=function(e,t,n){var r=t._x,i=t._y,a=e.elements,o=n.elements,s=a[0],l=a[1],c=a[2],u=a[3],d=a[4],h=a[5],_=a[6],f=a[7],p=a[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=d,o[5]=h,o[6]=r*s+i*u+_,o[7]=r*l+i*d+f,o[8]=r*c+i*h+p},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var i=n[1],a=n[2],o=n[5];r[1]=n[3],r[2]=n[6],r[3]=i,r[5]=n[7],r[6]=a,r[7]=o}else r[0]=n[0],r[1]=n[3],r[2]=n[6],r[3]=n[1],r[4]=n[4],r[5]=n[7],r[6]=n[2],r[7]=n[5],r[8]=n[8]},e}(),tD=/*#__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,i=t*t+n*n+r*r;if(i<tA.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var a=1/i;return e._x=this._x*a,e._y=this._y*a,e._z=this._z*a,2*Math.acos(this._w)},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,i=this._w,a=t*t,o=n*n,s=r*r,l=i*i,c=a+o+s+l,u=2*(t*i-n*r);u>(1-tA.zeroTolerance)*c?(e._x=Math.atan2(2*(i*n-t*r),a+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-tA.zeroTolerance)*c?(e._x=Math.atan2(2*(i*n-t*r),a+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(r*t+n*i),s+l-o-a),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*n+r*i),o+l-s-a))},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,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;n._x=r*u+o*s+i*c-a*l,n._y=i*u+o*l+a*s-r*c,n._z=a*u+o*c+r*l-i*s,n._w=o*u-r*s-i*l-a*c,n._onValueChanged&&n._onValueChanged()},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 tA.equals(e._x,t._x)&&tA.equals(e._y,t._y)&&tA.equals(e._z,t._z)&&tA.equals(e._w,t._w)},e.rotationAxisAngle=function(t,n,r){var i=e._tempVector3;tR.normalize(t,i);var a=Math.sin(n*=.5);r._x=i._x*a,r._y=i._y*a,r._z=i._z*a,r._w=Math.cos(n),r._onValueChanged&&r._onValueChanged()},e.rotationEuler=function(t,n,r,i){e.rotationYawPitchRoll(n,t,r,i)},e.rotationYawPitchRoll=function(e,t,n,r){var i=.5*n,a=.5*t,o=.5*e,s=Math.sin(i),l=Math.cos(i),c=Math.sin(a),u=Math.cos(a),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,i=e.elements,a=i[0],o=i[1],s=i[2],l=i[3],c=i[4],u=i[5],d=i[6],h=i[7],_=i[8],f=a+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):a>=c&&a>=_?(r=.5/(n=Math.sqrt(1+a-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-a-_)),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+_-a-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,i=e._z,a=e._w,o=n*n+r*r+i*i+a*a;if(o>tA.zeroTolerance){var s=1/o;t._x=-n*s,t._y=-r*s,t._z=-i*s,t._w=a*s,t._onValueChanged&&t._onValueChanged()}},e.lerp=function(t,n,r,i){var a=1-r;e.dot(t,n)>=0?(i._x=t._x*a+n._x*r,i._y=t._y*a+n._y*r,i._z=t._z*a+n._z*r,i._w=t._w*a+n._w*r):(i._x=t._x*a-n._x*r,i._y=t._y*a-n._y*r,i._z=t._z*a-n._z*r,i._w=t._w*a-n._w*r),i.normalize()},e.slerp=function(t,n,r,i){var a,o,s=e.dot(t,n);if(Math.abs(s)>1-tA.zeroTolerance)o=1-r,a=r*Math.sign(s);else{var l=Math.acos(Math.abs(s)),c=1/Math.sin(l);o=Math.sin((1-r)*l)*c,a=Math.sin(r*l)*c*Math.sign(s)}i.x=o*t.x+a*n.x,i.y=o*t.y+a*n.y,i.z=o*t.z+a*n.z,i.w=o*t.w+a*n.w,i._onValueChanged&&i._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=Math.sqrt(n*n+r*r+i*i+a*a);o>tA.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*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,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+o*s,n._y=i*l+a*s,n._z=a*l-i*s,n._w=o*l-r*s,n._onValueChanged&&n._onValueChanged()},e.rotateY=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l-a*s,n._y=i*l+o*s,n._z=a*l+r*s,n._w=o*l-i*s,n._onValueChanged&&n._onValueChanged()},e.rotateZ=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+i*s,n._y=i*l-r*s,n._z=a*l+o*s,n._w=o*l-a*s,n._onValueChanged&&n._onValueChanged()},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()},tT(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)<tA.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tD._tempVector3=new tR,tD._tempQuat1=new tD;var tB=/*#__PURE__*/function(){function e(e,t,n,r,i,a,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===i&&(i=0),void 0===a&&(a=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===u&&(u=1),void 0===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]=i,m[5]=a,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,i,a,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]=i,m[5]=a,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],i=e[3],a=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*a)*(d*m-h*p)-(t*s-r*a)*(u*m-h*f)+(t*l-i*a)*(u*p-d*f)+(n*s-r*o)*(c*m-h*_)-(n*l-i*o)*(c*p-d*_)+(r*l-i*s)*(c*f-u*_)},t.decompose=function(t,n,r){var i=e._tempMat30,a=this.elements,o=i.elements,s=a[0],l=a[1],c=a[2],u=a[4],d=a[5],h=a[6],_=a[8],f=a[9],p=a[10];t.set(a[12],a[13],a[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)<tA.zeroTolerance||Math.abs(g)<tA.zeroTolerance||Math.abs(v)<tA.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,tD.rotationMatrix3x3(i,n),!0},t.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>tA.zeroTolerance){var r=2*Math.sqrt(n+1);e._w=.25*r,e._x=(t[6]-t[9])/r,e._y=(t[8]-t[2])/r,e._z=(t[1]-t[4])/r}else if(t[0]>t[5]&&t[0]>t[10]){var i=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/i,e._x=.25*i,e._y=(t[1]+t[4])/i,e._z=(t[8]+t[2])/i}else if(t[5]>t[10]){var a=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/a,e._x=(t[1]+t[4])/a,e._y=.25*a,e._z=(t[6]+t[9])/a}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},t.getScaling=function(e){var t=this.elements,n=t[0],r=t[1],i=t[2],a=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(n*n+r*r+i*i),Math.sqrt(a*a+o*o+s*s),Math.sqrt(l*l+c*c+u*u)),e},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,i=t.elements,a=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=i[0],S=i[1],T=i[2],A=i[3],R=i[4],E=i[5],M=i[6],w=i[7],P=i[8],F=i[9],L=i[10],D=i[11],B=i[12],I=i[13],O=i[14],N=i[15];a[0]=o*C+u*S+f*T+v*A,a[1]=s*C+d*S+p*T+y*A,a[2]=l*C+h*S+m*T+x*A,a[3]=c*C+_*S+g*T+b*A,a[4]=o*R+u*E+f*M+v*w,a[5]=s*R+d*E+p*M+y*w,a[6]=l*R+h*E+m*M+x*w,a[7]=c*R+_*E+g*M+b*w,a[8]=o*P+u*F+f*L+v*D,a[9]=s*P+d*F+p*L+y*D,a[10]=l*P+h*F+m*L+x*D,a[11]=c*P+_*F+g*L+b*D,a[12]=o*B+u*I+f*O+v*N,a[13]=s*B+d*I+p*O+y*N,a[14]=l*B+h*I+m*O+x*N,a[15]=c*B+_*I+g*O+b*N},e.equals=function(e,t){var n=e.elements,r=t.elements;return tA.equals(n[0],r[0])&&tA.equals(n[1],r[1])&&tA.equals(n[2],r[2])&&tA.equals(n[3],r[3])&&tA.equals(n[4],r[4])&&tA.equals(n[5],r[5])&&tA.equals(n[6],r[6])&&tA.equals(n[7],r[7])&&tA.equals(n[8],r[8])&&tA.equals(n[9],r[9])&&tA.equals(n[10],r[10])&&tA.equals(n[11],r[11])&&tA.equals(n[12],r[12])&&tA.equals(n[13],r[13])&&tA.equals(n[14],r[14])&&tA.equals(n[15],r[15])},e.lerp=function(e,t,n,r){var i=e.elements,a=t.elements,o=r.elements,s=1-n;o[0]=i[0]*s+a[0]*n,o[1]=i[1]*s+a[1]*n,o[2]=i[2]*s+a[2]*n,o[3]=i[3]*s+a[3]*n,o[4]=i[4]*s+a[4]*n,o[5]=i[5]*s+a[5]*n,o[6]=i[6]*s+a[6]*n,o[7]=i[7]*s+a[7]*n,o[8]=i[8]*s+a[8]*n,o[9]=i[9]*s+a[9]*n,o[10]=i[10]*s+a[10]*n,o[11]=i[11]*s+a[11]*n,o[12]=i[12]*s+a[12]*n,o[13]=i[13]*s+a[13]*n,o[14]=i[14]*s+a[14]*n,o[15]=i[15]*s+a[15]*n},e.add=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements;a[0]=r[0]+i[0],a[1]=r[1]+i[1],a[2]=r[2]+i[2],a[3]=r[3]+i[3],a[4]=r[4]+i[4],a[5]=r[5]+i[5],a[6]=r[6]+i[6],a[7]=r[7]+i[7],a[8]=r[8]+i[8],a[9]=r[9]+i[9],a[10]=r[10]+i[10],a[11]=r[11]+i[11],a[12]=r[12]+i[12],a[13]=r[13]+i[13],a[14]=r[14]+i[14],a[15]=r[15]+i[15]},e.multiplyScalar=function(e,t,n){var r=e.elements,i=n.elements;i[0]=r[0]*t,i[1]=r[1]*t,i[2]=r[2]*t,i[3]=r[3]*t,i[4]=r[4]*t,i[5]=r[5]*t,i[6]=r[6]*t,i[7]=r[7]*t,i[8]=r[8]*t,i[9]=r[9]*t,i[10]=r[10]*t,i[11]=r[11]*t,i[12]=r[12]*t,i[13]=r[13]*t,i[14]=r[14]*t,i[15]=r[15]*t},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,i=e._y,a=e._z,o=e._w,s=r+r,l=i+i,c=a+a,u=r*s,d=i*s,h=i*l,_=a*s,f=a*l,p=a*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,i,a,o=n.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<tA.zeroTolerance||(s*=u=1/u,l*=u,c*=u,r=Math.sin(t),a=1-(i=Math.cos(t)),o[0]=s*s*a+i,o[1]=l*s*a+c*r,o[2]=c*s*a-l*r,o[3]=0,o[4]=s*l*a-c*r,o[5]=l*l*a+i,o[6]=c*l*a+s*r,o[7]=0,o[8]=s*c*a+l*r,o[9]=l*c*a-s*r,o[10]=c*c*a+i,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},e.rotationTranslation=function(t,n,r){e.rotationQuaternion(t,r);var i=r.elements;i[12]=n._x,i[13]=n._y,i[14]=n._z},e.affineTransformation=function(e,t,n,r){var i=r.elements,a=t._x,o=t._y,s=t._z,l=t._w,c=a+a,u=o+o,d=s+s,h=a*c,_=a*u,f=a*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;i[0]=(1-(p+g))*b,i[1]=(_+x)*b,i[2]=(f-y)*b,i[3]=0,i[4]=(_-x)*C,i[5]=(1-(h+g))*C,i[6]=(m+v)*C,i[7]=0,i[8]=(f+y)*S,i[9]=(m-v)*S,i[10]=(1-(h+p))*S,i[11]=0,i[12]=n._x,i[13]=n._y,i[14]=n._z,i[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,i=n[0],a=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=i*c-a*l,b=i*u-o*l,C=i*d-s*l,S=a*u-o*c,T=a*d-s*c,A=o*d-s*u,R=h*g-_*m,E=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*E+A*R;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(o*P-a*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*E)*L,r[5]=(i*F-o*M+s*E)*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*R)*L,r[9]=(a*M-i*P-s*R)*L,r[10]=(m*T-g*C+y*x)*L,r[11]=(_*C-h*T-p*x)*L,r[12]=(c*E-l*w-u*R)*L,r[13]=(i*w-a*E+o*R)*L,r[14]=(g*b-m*S-v*x)*L,r[15]=(h*S-_*b+f*x)*L},e.lookAt=function(t,n,r,i){var a=i.elements,o=e._tempVec30,s=e._tempVec31,l=e._tempVec32;tR.subtract(t,n,l),l.normalize(),tR.cross(r,l,o),o.normalize(),tR.cross(l,o,s),a[0]=o._x,a[1]=s._x,a[2]=l._x,a[3]=0,a[4]=o._y,a[5]=s._y,a[6]=l._y,a[7]=0,a[8]=o._z,a[9]=s._z,a[10]=l._z,a[11]=0,a[12]=-tR.dot(o,t),a[13]=-tR.dot(s,t),a[14]=-tR.dot(l,t),a[15]=1},e.ortho=function(e,t,n,r,i,a,o){var s=o.elements,l=1/(e-t),c=1/(n-r),u=1/(i-a);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*u,s[11]=0,s[12]=(e+t)*l,s[13]=(r+n)*c,s[14]=(a+i)*u,s[15]=1},e.perspective=function(e,t,n,r,i){var a=i.elements,o=1/Math.tan(e/2),s=1/(n-r);a[0]=o/t,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=o,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(r+n)*s,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*r*n*s,a[15]=0},e.rotateAxisAngle=function(e,t,n,r){var i,a,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<tA.zeroTolerance)){var d=e.elements,h=r.elements;s*=u=1/u,l*=u,c*=u,i=Math.sin(n),o=1-(a=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+a,R=l*s*o+c*i,E=c*s*o-l*i,M=s*l*o-c*i,w=l*l*o+a,P=c*l*o+s*i,F=s*c*o+l*i,L=l*c*o-s*i,D=c*c*o+a;h[0]=_*A+g*R+b*E,h[1]=f*A+v*R+C*E,h[2]=p*A+y*R+S*E,h[3]=m*A+x*R+T*E,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,i=n.elements,a=t._x,o=t._y,s=t._z;i[0]=r[0]*a,i[1]=r[1]*a,i[2]=r[2]*a,i[3]=r[3]*a,i[4]=r[4]*o,i[5]=r[5]*o,i[6]=r[6]*o,i[7]=r[7]*o,i[8]=r[8]*s,i[9]=r[9]*s,i[10]=r[10]*s,i[11]=r[11]*s,i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15]},e.translate=function(e,t,n){var r=e.elements,i=n.elements,a=t._x,o=t._y,s=t._z;if(e===n)i[12]=r[0]*a+r[4]*o+r[8]*s+r[12],i[13]=r[1]*a+r[5]*o+r[9]*s+r[13],i[14]=r[2]*a+r[6]*o+r[10]*s+r[14],i[15]=r[3]*a+r[7]*o+r[11]*s+r[15];else{var l=r[0],c=r[1],u=r[2],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];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]=m,i[9]=g,i[10]=v,i[11]=y,i[12]=l*a+h*o+m*s+r[12],i[13]=c*a+_*o+g*s+r[13],i[14]=u*a+f*o+v*s+r[14],i[15]=d*a+p*o+y*s+r[15]}},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var i=n[1],a=n[2],o=n[3],s=n[6],l=n[7],c=n[11];r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=i,r[6]=n[9],r[7]=n[13],r[8]=a,r[9]=s,r[11]=n[14],r[12]=o,r[13]=l,r[14]=c}else r[0]=n[0],r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=n[1],r[5]=n[5],r[6]=n[9],r[7]=n[13],r[8]=n[2],r[9]=n[6],r[10]=n[10],r[11]=n[14],r[12]=n[3],r[13]=n[7],r[14]=n[11],r[15]=n[15]},e}();tB._tempVec30=new tR,tB._tempVec31=new tR,tB._tempVec32=new tR,tB._tempMat30=new tL,tB._identity=new tB(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var tI=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new tR,this.direction=new tR,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}var t=e.prototype;return t.intersectPlane=function(e){return tw.intersectsRayAndPlane(this,e)},t.intersectSphere=function(e){return tw.intersectsRayAndSphere(this,e)},t.intersectBox=function(e){return tw.intersectsRayAndBox(this,e)},t.getPoint=function(e,t){return tR.scale(this.direction,e,t),t.add(this.origin)},e}(),tO=/*#__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 tA.equals(e._x,t._x)&&tA.equals(e._y,t._y)},e.lerp=function(e,t,n,r){var i=e._x,a=e._y;r._x=i+(t._x-i)*n,r._y=a+(t._y-a)*n,r._onValueChanged&&r._onValueChanged()},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,i=Math.sqrt(n*n+r*r);i>tA.zeroTolerance&&(i=1/i,t._x=n*i,t._y=r*i,t._onValueChanged&&t._onValueChanged())},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._onValueChanged&&n._onValueChanged()},tT(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}();tO._zero=new tO(0,0),tO._one=new tO(1,1);var 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._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,i=t._z-e._z,a=t._w-e._w;return Math.sqrt(n*n+r*r+i*i+a*a)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,i=t._z-e._z,a=t._w-e._w;return n*n+r*r+i*i+a*a},e.equals=function(e,t){return tA.equals(e._x,t._x)&&tA.equals(e._y,t._y)&&tA.equals(e._z,t._z)&&tA.equals(e._w,t._w)},e.lerp=function(e,t,n,r){var i=e._x,a=e._y,o=e._z,s=e._w;r._x=i+(t._x-i)*n,r._y=a+(t._y-a)*n,r._z=o+(t._z-o)*n,r._w=s+(t._w-s)*n,r._onValueChanged&&r._onValueChanged()},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,i=e._z,a=e._w,o=Math.sqrt(n*n+r*r+i*i+a*a);o>tA.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*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,i=e._y,a=e._z,o=e._w,s=t.elements;n._x=r*s[0]+i*s[4]+a*s[8]+o*s[12],n._y=r*s[1]+i*s[5]+a*s[9]+o*s[13],n._z=r*s[2]+i*s[6]+a*s[10]+o*s[14],n._w=r*s[3]+i*s[7]+a*s[11]+o*s[15],n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,d=u*r+l*a-c*i,h=u*i+c*r-s*a,_=u*a+s*i-l*r,f=-s*r-l*i-c*a;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()},tT(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}();tN._zero=new tN(0,0,0,0),tN._one=new tN(1,1,1,1);var tV=/*#__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,i=e;return t>r&&(r=t),n>r&&(r=n),t<i&&(i=t),n<i&&(i=n),(r+i)/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 tA.equals(e._r,t._r)&&tA.equals(e._g,t._g)&&tA.equals(e._b,t._b)&&tA.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 i=e._r,a=e._g,o=e._b,s=e._a;return r._r=i+(t._r-i)*n,r._g=a+(t._g-a)*n,r._b=o+(t._b-o)*n,r._a=s+(t._a-s)*n,r._onValueChanged&&r._onValueChanged(),r},tT(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}(),tk=/*#__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},tT(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}(),tz=/*#__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,i=e._x,a=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*a,d=.488603*o,h=-.488603*i,_=i*a*1.092548,f=-(a*o*1.092548),p=.315392*(3*o*o-1),m=-(i*o*1.092548),g=.546274*(i*i-a*a);r[0]+=.282095*s,r[1]+=.282095*l,r[2]+=.282095*c,r[3]+=s*u,r[4]+=l*u,r[5]+=c*u,r[6]+=s*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,i=e._y,a=e._z,o=-1.023327*i,s=1.023327*a,l=-1.023327*r,c=.858086*i*r,u=-.858086*i*a,d=.247708*(3*a*a-1),h=-.858086*a*r,_=.429042*(r*r-i*i),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}(),tU=/*#__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}(),tG=((a={})[a.Android=0]="Android",a[a.IPhone=1]="IPhone",a[a.IPad=2]="IPad",a[a.Mac=3]="Mac",a[a.Unknown=4]="Unknown",a);function tH(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 tW(e,t,n){return t&&tH(e.prototype,t),n&&tH(e,n),e}function tj(e,t){return(tj=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tX(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&&tj(e,t)}var tK=/*#__PURE__*/function(){function e(){this.localPositions=new tN}return e.prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},e}();function tq(e,t,r,i){var a,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(s=(o<3?a(s):o>3?a(t,r,s):a(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function tY(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}tK.triangles=[0,2,1,2,0,3],"function"==typeof SuppressedError&&SuppressedError;var tQ=((o={})[o.Ignore=0]="Ignore",o[o.Assignment=1]="Assignment",o[o.Shallow=2]="Shallow",o[o.Deep=3]="Deep",o);function tJ(e,t){t1.registerCloneMode(e,t,tQ.Ignore)}function tZ(e,t){t1.registerCloneMode(e,t,tQ.Assignment)}function t$(e,t){t1.registerCloneMode(e,t,tQ.Shallow)}function t0(e,t){t1.registerCloneMode(e,t,tQ.Deep)}var t1=/*#__PURE__*/function(){function e(){}return e.registerCloneMode=function(t,n,r){var i=e._subCloneModeMap.get(t.constructor);i||(i=Object.create(null),e._subCloneModeMap.set(t.constructor,i)),i[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,i=e._subCloneModeMap;t!==r;){var a=i.get(t);a&&Object.assign(n,a),t=Object.getPrototypeOf(t)}}return n},e.cloneProperty=function(t,n,r,i,a,o,s){if(i!==tQ.Ignore){var l=t[r];if(tY(l,Object)){if(void 0===i||i===tQ.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,i,a,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],a,o,s);l._cloneTo&&l._cloneTo(_,a,o)}}}else n[r]=l}},e.deepCloneObject=function(t,n,r){for(var i in t)e.cloneProperty(t,n,i,tQ.Deep,null,null,r)},e}();t1._subCloneModeMap=new Map,t1._cloneModeMap=new Map,t1._objectType=Object.getPrototypeOf(Object);var t2=/*#__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)},tW(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();t2._instanceIdCounter=0,tq([tJ],t2.prototype,"instanceId",void 0),tq([tJ],t2.prototype,"_engine",void 0);var t3=/*#__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}tX(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 i=0,a=r.length;i<a;i++)if(r[i].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)},tW(t,[{key:"refCount",get:function(){return this._refCount}}]),t}(t2),t4=function(e){this.resource=e},t8=((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),t5=((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),t9=((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),t6=((u={})[u.Point=0]="Point",u[u.Bilinear=1]="Bilinear",u[u.Trilinear=2]="Trilinear",u),t7=((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),ne=((h={})[h.Static=0]="Static",h[h.Dynamic=1]="Dynamic",h),nt=((_={})[_.Clamp=0]="Clamp",_[_.Repeat=1]="Repeat",_[_.Mirror=2]="Mirror",_),nn=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._isContentLost=!1,t.resourceManager._addGraphicResource(n),n}return tX(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},tW(t,[{key:"isContentLost",get:function(){return this._isContentLost}}]),t}(t3),nr=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},ni=console.log.bind(console),na=console.info.bind(console),no=console.warn.bind(console),ns=console.error.bind(console),nl={debug:nr,info:nr,warn:nr,error:nr,isEnabled:!1,enable:function(){this.debug=ni,this.info=na,this.warn=no,this.error=ns,this.isEnabled=!0},disable:function(){this.debug=nr,this.info=nr,this.warn=nr,this.error=nr,this.isEnabled=!1}},nc=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._isDepthTexture=!1,t._anisoLevel=1,t._useDepthCompareMode=!1,t}tX(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 t7.R32G32B32A32_UInt===this._format},tW(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!==t6.Point&&this._isIntFormat()){e=t6.Point,nl.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&&(nl.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(nl.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}(nn),nu=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){if(void 0===a&&(a=t7.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=a,i){for(var s,l=tY(i,Array)?i.slice():[i],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(tY(a,nc)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1),s._depthFormat=a.format}else"number"==typeof a&&(s._depthFormat=a);return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(s),s}tX(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,i=n.length;r<i;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)},tW(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}(nn),nd=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;return void 0===i&&(i=t7.R8G8B8A8),void 0===a&&(a=!0),void 0===o&&(o=ne.Static),(s=e.call(this,t)||this)._mipmap=a,s._width=n,s._height=r,s._usage=o,s._format=i,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=i==t7.Depth||i==t7.DepthStencil||i==t7.Depth16||i==t7.Depth24||i==t7.Depth32||i==t7.Depth24Stencil8||i==t7.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(s),s.filterMode=s._isIntFormat()?t6.Point:t6.Bilinear,s.wrapModeU=s.wrapModeV=nt.Repeat,s}tX(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._platformTexture.setPixelBuffer(e,t,n,r,i,a),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,i,a){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=0),void 0===a&&(a=0),this._platformTexture.setImageSource(e,t,n,r,i,a),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,i,a){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,n,r,0,i):6===o&&this._platformTexture.getPixelBuffer(e,t,n,r,i,a)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),e.prototype._rebuild.call(this)},t}(nc),nh=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;return void 0===a&&(a=t7.R8G8B8A8),void 0===o&&(o=!0),(s=e.call(this,t)||this)._mipmap=o,s._width=n,s._height=r,s._length=i,s._format=a,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(s),s.filterMode=t6.Bilinear,s.wrapModeU=s.wrapModeV=nt.Repeat,s}tX(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a,o,s){void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,n,r,i,a,o,s),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,i,a,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,i,a,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,i,a,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):5===s?this._platformTexture.getPixelBuffer(e,t,n,r,i,0,a):6===s&&this._platformTexture.getPixelBuffer(e,t,n,r,i,a,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),e.prototype._rebuild.call(this)},tW(t,[{key:"length",get:function(){return this._length}}]),t}(nc),n_=/*#__PURE__*/function(e){function t(t,n,r,i){var a;return void 0===r&&(r=t7.R8G8B8A8),void 0===i&&(i=!0),(a=e.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(a),a.filterMode=t6.Bilinear,a.wrapModeU=a.wrapModeV=nt.Clamp,a}tX(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a,o){void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,n,r,i,a,o),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,i,a,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,i,a,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,i,a,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):6===s?this._platformTexture.getPixelBuffer(e,t,n,r,i,0,a):7===s&&this._platformTexture.getPixelBuffer(e,t,n,r,i,a,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),e.prototype._rebuild.call(this)},t}(nc),nf=/*#__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}tX(t,e);var n=t.prototype;return n.uploadCharTexture=function(e){var t=e.w,n=e.h,r=e.data,i=this._space,a=this.texture,o=a.width,s=t+i,l=n+i;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=i,this._curY=this._nextY+i);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&n>0&&r&&(e.bufferOffset=new tO(this._curX,this._curY),a.setPixelBuffer(r,0,this._curX,this._curY,t,n),a.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+i,!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}(t3),np=((f={})[f.None=0]="None",f[f.Bold=1]="Bold",f[f.Italic=2]="Italic",f),nm=((p={})[p.Overflow=0]="Overflow",p[p.Truncate=1]="Truncate",p),ng=/*#__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 i=r&np.Bold?"bold ":"";return r&np.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=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,i=e.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=on._pixelsPerUnit,u=i.size+t.lineSpacing*c,d=t.width*c,h=0;n.nativeFontString=r;for(var _=0,f=a.length;_<f;_++){var p=a[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",b=0,C=0,S=0,T=!1,A=0,R=p.length;A<R;++A){var E=p[A],M=e._getCharInfo(E,r,n),w=E.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=E,b=M.xAdvance,C=I,S=O)):(x+=E,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=E,g=M.xAdvance,v=I,y=O):(m+=E,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===nm.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,i=e.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=a.length,s=[],l=[],c=[],u=on._pixelsPerUnit,d=i.size+t.lineSpacing*u,h=0;n.nativeFontString=r;for(var _=0;_<o;++_){for(var f=a[_],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===nm.Overflow&&(A=d*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},e.getNativeFontHash=function(t,n,r){var i=r&np.Bold?"bold":"";return r&np.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t=""+t),i+=n+"px"+t},e._measureFontOrChar=function(t,n,r){var i,a=e.textContext(),o=a.canvas,s=a.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]?(i=~~(.25*A*T),-1===v&&(v=i),i>y&&(y=i)):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 R=null;if(C>0){var E=4*S;R=new Uint8Array(m.buffer,v*E,C*E)}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 tO,new tO,new tO,new tO],ascent:x,descent:b,index:0,data:R}},e._getCharInfo=function(t,n,r){var i=r._getCharInfo(t);return i||(i=e.measureChar(t,n),r._uploadCharTexture(i),r._addCharInfo(t,i)),i},e._pushLine=function(e,t,n,r,i,a,o){e.push(r),t.push(i),n.push({ascent:a,descent:o,size:a+o})},e}();ng._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],ng._extendHeight=0,ng._measureString="|\xc9q\xc5",ng._measureBaseline="M",ng._heightMultiplier=2,ng._baselineMultiplier=1.4,ng._fontSizeInfoCache={},ng._textContext=null;var nv=/*#__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 i=t[n].getCharInfo(e);if(i)return i}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 nf(e),n=new nd(e,256,256,t7.R8G8B8A8,!1);n.filterMode=t6.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 tX(n,e),n.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var i in t){var a=t[i],o=ng.measureChar(a.char,r).data;if(a.w>0&&a.h>0&&o){var s=a.bufferOffset;n.setPixelBuffer(o,0,s.x,s.y,a.w,a.h)}}n.generateMipmaps()},n}(t4))),t},e}(),ny=/*#__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}tX(t,e);var n=t.prototype;return n._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new nv(this.engine),r[n]=i),i},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,i=r[n];return i||(i=new t(e,n),r[n]=i),i}return null},tW(t,[{key:"name",get:function(){return this._name}}]),t}(t3),nx=((m={})[m.None=0]="None",m[m.VisibleInsideMask=1]="VisibleInsideMask",m[m.VisibleOutsideMask=2]="VisibleOutsideMask",m),nb=((g={})[g.Left=0]="Left",g[g.Center=1]="Center",g[g.Right=2]="Right",g),nC=((v={})[v.Top=0]="Top",v[v.Center=1]="Center",v[v.Bottom=2]="Bottom",v),nS=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._sprites=[],n._spriteNamesToIndex={},n}tX(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 i=r[n];i.name===e&&t.push(i)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},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},tW(t,[{key:"sprites",get:function(){return this._sprites}}]),t}(t3),nT=((y={})[y.Simple=0]="Simple",y[y.Sliced=1]="Sliced",y[y.Tiled=2]="Tiled",y),nA=((x={})[x.Continuous=0]="Continuous",x[x.Adaptive=1]="Adaptive",x),nR=/*#__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 i=e[r];e[n]=i}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,i){var a=e.elements,o=a[0],s=a[1],l=a[2],c=a[3],u=a[4],d=a[5],h=a[6],_=a[7],f=a[8],p=a[9],m=a[10],g=a[11],v=a[12],y=a[13],x=a[14],b=a[15],C=t[n],S=t[n+1],T=t[n+2],A=t[n+3],R=t[n+4],E=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[i]=o*C+u*S+f*T+v*A,r[i+1]=s*C+d*S+p*T+y*A,r[i+2]=l*C+h*S+m*T+x*A,r[i+3]=c*C+_*S+g*T+b*A,r[i+4]=o*R+u*E+f*M+v*w,r[i+5]=s*R+d*E+p*M+y*w,r[i+6]=l*R+h*E+m*M+x*w,r[i+7]=c*R+_*E+g*M+b*w,r[i+8]=o*P+u*F+f*L+v*D,r[i+9]=s*P+d*F+p*L+y*D,r[i+10]=l*P+h*F+m*L+x*D,r[i+11]=c*P+_*F+g*L+b*D,r[i+12]=o*B+u*I+f*O+v*N,r[i+13]=s*B+d*I+p*O+y*N,r[i+14]=l*B+h*I+m*O+x*N,r[i+15]=c*B+_*I+g*O+b*N},e._reflectGet=function(e,t){for(var n=this._stringToPath(t),r=e,i=0,a=n.length;null!=r&&i<a;)r=r[n[i++]];return i&&i==a?r:void 0},e._quickSort=function(e,t,n,r){for(;;){if(n-t<=10){this._insertionSort(e,t,n,r);return}var i=t+n>>1,a=e[t],o=e[n-1],s=e[i];if(r(a,o)>0){var l=a;a=o,o=l}if(r(a,s)>=0){var c=a;a=s,s=o,o=c}else if(r(o,s)>0){var u=o;o=s,s=u}e[t]=a,e[n-1]=s;var d=o,h=t+1,_=n-1;e[i]=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)===nE&&t.push(""),e.replace(nw,function(e,n,r,i){var a=e;r?a=i.replace(nM,"$1"):n&&(a=n.trim()),t.push(a)}),t},e._insertionSort=function(e,t,n,r){for(var i=t+1;i<n;i++){var a=void 0,o=e[i];for(a=i-1;a>=t;a--){var s=e[a];if(r(s,o)>0)e[a+1]=s;else break}e[a+1]=o}},e}(),nE=46,nM=/\\(\\)?/g,nw=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),nP=/*#__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){nR.removeFromArray(this._updateFlags,e)&&nR.removeFromArray(e._flagManagers,this)},t.addListener=function(e){this._listeners.push(e)},t.removeListener=function(e){nR.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 i=this._listeners,a=i.length-1;a>=0;a--)i[a](e,t)},e}(),nF=((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),nL=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;return void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===a&&(a=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 tO,new tO,new tO,new tO],s._uvs=[new tO,new tO,new tO,new tO],s._bounds=new tM,s._texture=null,s._atlasRotated=!1,s._atlasRegion=new tk(0,0,1,1),s._atlasRegionOffset=new tN(0,0,0,0),s._region=new tk(0,0,1,1),s._pivot=new tO(.5,.5),s._border=new tN(0,0,0,0),s._dirtyUpdateFlag=7,s._updateFlagManager=new nP,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),i&&s._pivot.copyFrom(i),a&&s._border.copyFrom(a),s.name=o,s}tX(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(nF.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,i=1/on._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-n.x-n.z)*r.width*i,this._automaticHeight=e.height*t.height/(1-n.y-n.w)*r.height*i}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},n._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,n=t.x,r=t.y,i=t.width,a=t.height,o=Math.max(e.x-n,0)/i,s=Math.max(e.w-r,0)/a,l=1-Math.max(e.z-(1-n-i),0)/i,c=1-Math.max(e.y-(1-r-a),0)/a,u=this._positions;u[0].set(o,s),u[1].set(l,s),u[2].set(o,c),u[3].set(l,c);var 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,i=n.y,a=n.width,o=n.height,s=1-r-a,l=1-i-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(i-g,0)*y,T=this._border,A=T.x,R=T.y,E=T.z,M=T.w;e[0].set(x,S),e[1].set((r-f+A*a)*v+u,_+d-(i-g+R*o)*y),e[2].set(h+u-(s-m+E*a)*v,(l-p+M*o)*y+d),e[3].set(C,b),this._dirtyUpdateFlag&=-3},n._dispatchSpriteChange=function(e){switch(e){case nF.texture:this._dirtyUpdateFlag|=4;break;case nF.atlasRegionOffset:case nF.region:this._dirtyUpdateFlag|=7;break;case nF.atlasRegion:this._dirtyUpdateFlag|=6;break;case nF.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},n._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=tA.clamp(e.x,0,1),n=tA.clamp(e.y,0,1);e.set(t,n,tA.clamp(e.width,0,1-t),tA.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nF.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nF.size),e._onValueChanged=this._onRegionChange},n._onPivotChange=function(){this._dispatchSpriteChange(nF.pivot)},n._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=tA.clamp(e.x,0,1),n=tA.clamp(e.y,0,1);e.set(t,n,tA.clamp(e.z,0,1-t),tA.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nF.border),e._onValueChanged=this._onBorderChange},tW(t,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(nF.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nF.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(nF.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(nF.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=tA.clamp(e.x,0,1),n=tA.clamp(e.y,0,1);this._atlasRegion.set(t,n,tA.clamp(e.width,0,1-t),tA.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nF.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nF.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=tA.clamp(e.x,0,1),n=tA.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,tA.clamp(e.z,0,1-t),tA.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nF.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nF.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}(t3),nD=((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),nB=((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),nI=((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),nO=((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),nN=((R={})[R.Off=0]="Off",R[R.Front=1]="Front",R[R.Back=2]="Back",R),nV=((E={})[E.BlendStateEnabled0=0]="BlendStateEnabled0",E[E.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",E[E.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",E[E.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",E[E.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",E[E.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",E[E.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",E[E.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",E[E.BlendStateBlendColor=8]="BlendStateBlendColor",E[E.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",E[E.DepthStateEnabled=10]="DepthStateEnabled",E[E.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",E[E.DepthStateCompareFunction=12]="DepthStateCompareFunction",E[E.StencilStateEnabled=13]="StencilStateEnabled",E[E.StencilStateReferenceValue=14]="StencilStateReferenceValue",E[E.StencilStateMask=15]="StencilStateMask",E[E.StencilStateWriteMask=16]="StencilStateWriteMask",E[E.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",E[E.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",E[E.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",E[E.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",E[E.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",E[E.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",E[E.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",E[E.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",E[E.RasterStateCullMode=25]="RasterStateCullMode",E[E.RasterStateDepthBias=26]="RasterStateDepthBias",E[E.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",E[E.RenderQueueType=28]="RenderQueueType",E),nk=((M={})[M.Opaque=0]="Opaque",M[M.AlphaTest=1]="AlphaTest",M[M.Transparent=2]="Transparent",M),nz=((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),nU=((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),nG=((F={})[F.GLES100=0]="GLES100",F[F.GLES300=1]="GLES300",F);function nH(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 nW(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 nH(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 nH(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 nj=/*#__PURE__*/function(){function e(t,n,r,i){this.name=t,this._maskIndex=r,this._maskValue=i,this.value=n;var a=e._macroNameIdMap,o=a[t];void 0===a[t]&&(a[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,n){var r=n?t+" "+n:t,i=e._macroMap[r];if(!i){var a=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;i=new e(t,n,s,1<<l),e._macroMap[r]=i,s==a.length&&(a.length++,a[s]=Array(32)),a[s][l]=i,e._macroCounter++}return i},e._getMacrosElements=function(t,n){var r=e._macroMaskMap,i=t._mask;n.length=0;for(var a=0,o=t._length;a<o;a++)for(var s=r[a],l=i[a],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&n.push(s[u])},e}();nj._macroMaskMap=[],nj._macroNameIdMap=Object.create(null),nj._macroNameCounter=0,nj._macroCounter=0,nj._macroMap=Object.create(null);var nX=/*#__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,i=this._length;if(i<n){for(r.length<n&&(r.length=n);i<t;i++)r[i]=0;r[t]=e._maskValue,this._length=n}else r[t]|=e._maskValue},t.disable=function(e){var t=e._maskIndex,n=this._mask,r=this._length-1;if(!(t>r)){var i=n[t]&~e._maskValue;t==r&&0===i?this._length--:n[t]=i}},t.unionCollection=function(e){var t=e._mask,n=e._length,r=this._mask,i=this._length;if(i<n){r.length<n&&(r.length=n);for(var a=0;a<i;a++)r[a]|=t[a];for(;a<n;a++)r[a]=t[a];this._length=n}else for(var o=0;o<n;o++)r[o]|=t[o]},t.complementaryCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1,i=Math.min(e._length-1,r);i>=0;i--){var a=n[i]&~t[i];i==r&&0===a?(r--,this._length--):n[i]=a}},t.intersectionCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1;r>=0;r--){var i=n[r]&t[r];0==i&&r==this._length-1?this._length--:n[r]=i}},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,i,a,o,s=n._mask;e._length<t._length?(r=e._length,i=t._length,a=e._mask,o=t._mask):(r=t._length,i=e._length,a=t._mask,o=e._mask);var l=0;for(s.length<i&&(s.length=i);l<r;l++)s[l]=a[l]|o[l];for(;l<i;l++)s[l]=o[l];n._length=i},e}();function nK(){return(nK=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 nq=((L={}).DepthOnly="DepthOnly",L.ShadowCaster="ShadowCaster",L.Forward="Forward",L),nY=/*#__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 i=r.length,a=e._dispatchingListenersPool,o=a.length>0?a.pop():[];o.length=i;for(var s=0;s<i;s++)o[s]=r[s];for(var l=0;l<i;l++){var c=o[l];c.destroyed||(c.once&&this.off(t,c.fn),c.fn(n))}o.length=0,a.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 i=n.length-1;i>=0;i--)n[i].fn===t&&(n[i].destroyed=!0,n.splice(i,1));0===n.length?this._clearEvent(e):1===n.length&&(this._events[e]=n[0])}}else this._clearEvent(e);return this},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},i=this._events,a=i[e];return a?Array.isArray(a)?a.push(r):i[e]=[a,r]:(i[e]=r,this._eventCount++),this},t._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},e}();nY._dispatchingListenersPool=[];var nQ=/*#__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},tW(e,[{key:"type",get:function(){return this._type}}]),e}();nQ._propertyIdMap=Object.create(null),nQ._propertyNameCounter=0,nQ._propertyNameMap=Object.create(null);var nJ=/*#__PURE__*/function(){function e(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new tN,this._deltaTimeValue=new tN,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,i=this._elapsedTime;n.set(i,Math.sin(i),Math.cos(i),0),t.setVector4(e._elapsedTimeProperty,n),r.set(this._deltaTime,0,0,0),t.setVector4(e._deltaTimeProperty,r)},tW(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}();nJ._elapsedTimeProperty=nQ.getByName("scene_ElapsedTime"),nJ._deltaTimeProperty=nQ.getByName("scene_DeltaTime");var nZ=((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),n$=((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),n0=nK({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\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n\nfloat pow2(float x ) {\n return x * x;\n}\n\nvec4 RGBMToLinear(vec4 value, float maxRange ) {\n return vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 gammaToLinear(vec4 srgbIn){\n return vec4( pow(srgbIn.rgb, vec3(2.2)), srgbIn.a);\n}\n\nvec4 linearToGamma(vec4 linearIn){\n linearIn = max(linearIn, 0.0);\n return vec4( pow(linearIn.rgb, vec3(1.0 / 2.2)), linearIn.a);\n}\n\nuniform vec4 camera_DepthBufferParams;\n\nfloat remapDepthBufferLinear01(float z){\n return 1.0/ (camera_DepthBufferParams.x * z + camera_DepthBufferParams.y);\n}\n\n#ifdef GRAPHICS_API_WEBGL2\n #define INVERSE_MAT(mat) inverse(mat)\n#else\n mat2 inverseMat(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n }\n mat3 inverseMat(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n }\n mat4 inverseMat(mat4 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n }\n\n #define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n\n#ifdef RENDERER_HAS_UV\n attribute vec2 TEXCOORD_0;\n#endif\n\n#ifdef RENDERER_HAS_UV1\n attribute vec2 TEXCOORD_1;\n#endif\n\n#ifdef RENDERER_HAS_SKIN\n attribute vec4 JOINTS_0;\n attribute vec4 WEIGHTS_0;\n\n #ifdef RENDERER_USE_JOINT_TEXTURE\n uniform sampler2D renderer_JointSampler;\n uniform float renderer_JointCount;\n\n mat4 getJointMatrix(sampler2D smp, float index)\n {\n float base = index / renderer_JointCount;\n float hf = 0.5 / renderer_JointCount;\n float v = base + hf;\n\n vec4 m0 = texture2D(smp, vec2(0.125, v ));\n vec4 m1 = texture2D(smp, vec2(0.375, v ));\n vec4 m2 = texture2D(smp, vec2(0.625, v ));\n vec4 m3 = texture2D(smp, vec2(0.875, v ));\n\n return mat4(m0, m1, m2, m3);\n\n }\n\n #else\n uniform mat4 renderer_JointMatrix[ RENDERER_JOINTS_NUM ];\n #endif\n#endif\n\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n#endif\n\n#include <transform_declare>\n#include <camera_declare>\n\nuniform vec4 material_TilingOffset;\n\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n attribute vec3 NORMAL;\n #endif\n\n #ifdef RENDERER_HAS_TANGENT\n attribute vec4 TANGENT;\n #endif\n#endif",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;\nuniform mat4 renderer_ModelMat;\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\nuniform mat4 renderer_MVMat;\nuniform mat4 renderer_MVPMat;\nuniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;\nuniform vec3 camera_Forward; \nuniform vec4 camera_ProjectionParams;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\n\nvarying vec4 v_color;\n\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n varying vec3 v_normal;\n #if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\n varying mat3 v_TBN;\n #endif\n #endif\n#endif",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n\n#ifdef RENDERER_HAS_UV1\n varying vec2 v_uv1;\n#endif",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\n varying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n varying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n varying vec3 v_positionVS;\n\n uniform vec4 scene_FogColor;\n uniform vec4 scene_FogParams;// (-1/(end-start), end/(end-start), density/ln(2),density/sprt(ln(2)));\n\n float ComputeFogIntensity(float fogDepth){\n #if SCENE_FOG_MODE == 1\n // (end-z) / (end-start) = z * (-1/(end-start)) + (end/(end-start))\n return clamp(fogDepth * scene_FogParams.x + scene_FogParams.y, 0.0, 1.0);\n #elif SCENE_FOG_MODE == 2\n // exp(-z * density) = exp2((-z * density)/ln(2)) = exp2(-z * density/ln(2))\n return clamp(exp2(-fogDepth * scene_FogParams.z), 0.0, 1.0);\n #elif SCENE_FOG_MODE == 3\n // exp(-(z * density)^2) = exp2(-(z * density)^2/ln(2)) = exp2(-(z * density/sprt(ln(2)))^2)\n float factor = fogDepth * scene_FogParams.w;\n 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\n vec3 normal = vec3( NORMAL );\n #endif\n\n #ifdef RENDERER_HAS_TANGENT\n vec4 tangent = vec4( TANGENT );\n #endif\n#endif",begin_position_vert:"#define GLSLIFY 1\n vec4 position = vec4( POSITION , 1.0 );\n",position_vert:"#define GLSLIFY 1\n gl_Position = renderer_MVPMat * position;",color_vert:"#define GLSLIFY 1\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n\n v_color = COLOR_0;\n\n #endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n v_normal = normalize( mat3(renderer_NormalMat) * normal );\n\n #if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\n vec3 tangentW = normalize( mat3(renderer_NormalMat) * tangent.xyz );\n vec3 bitangentW = cross( v_normal, tangentW ) * tangent.w;\n\n v_TBN = mat3( tangentW, bitangentW, v_normal );\n #endif\n #endif\n#endif",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n\n #ifdef RENDERER_USE_JOINT_TEXTURE\n mat4 skinMatrix =\n WEIGHTS_0.x * getJointMatrix(renderer_JointSampler, JOINTS_0.x ) +\n WEIGHTS_0.y * getJointMatrix(renderer_JointSampler, JOINTS_0.y ) +\n WEIGHTS_0.z * getJointMatrix(renderer_JointSampler, JOINTS_0.z ) +\n WEIGHTS_0.w * getJointMatrix(renderer_JointSampler, JOINTS_0.w );\n\n #else\n mat4 skinMatrix =\n WEIGHTS_0.x * renderer_JointMatrix[ int( JOINTS_0.x ) ] +\n WEIGHTS_0.y * renderer_JointMatrix[ int( JOINTS_0.y ) ] +\n WEIGHTS_0.z * renderer_JointMatrix[ int( JOINTS_0.z ) ] +\n WEIGHTS_0.w * renderer_JointMatrix[ int( JOINTS_0.w ) ];\n #endif\n\n position = skinMatrix * position;\n\n #if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\n mat3 skinNormalMatrix = INVERSE_MAT(mat3(skinMatrix));\n normal = normal * skinNormalMatrix;\n #if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\n tangent.xyz = tangent.xyz * skinNormalMatrix;\n #endif\n\n #endif\n\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n #ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\n uniform mediump sampler2DArray renderer_BlendShapeTexture;\n uniform ivec3 renderer_BlendShapeTextureInfo;\n uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n #else\n attribute vec3 POSITION_BS0;\n attribute vec3 POSITION_BS1;\n #if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n attribute vec3 NORMAL_BS0;\n attribute vec3 NORMAL_BS1;\n attribute vec3 TANGENT_BS0;\n attribute vec3 TANGENT_BS1;\n uniform float renderer_BlendShapeWeights[2];\n #else\n #if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n attribute vec3 POSITION_BS2;\n attribute vec3 POSITION_BS3;\n #ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\n attribute vec3 NORMAL_BS0;\n attribute vec3 NORMAL_BS1;\n attribute vec3 NORMAL_BS2;\n attribute vec3 NORMAL_BS3;\n #endif\n\n #ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\n attribute vec3 TANGENT_BS0;\n attribute vec3 TANGENT_BS1;\n attribute vec3 TANGENT_BS2;\n attribute vec3 TANGENT_BS3;\n #endif\n\n uniform float renderer_BlendShapeWeights[4];\n #else\n attribute vec3 POSITION_BS2;\n attribute vec3 POSITION_BS3;\n attribute vec3 POSITION_BS4;\n attribute vec3 POSITION_BS5;\n attribute vec3 POSITION_BS6;\n attribute vec3 POSITION_BS7;\n uniform float renderer_BlendShapeWeights[8];\n #endif\n #endif\n #endif\n\n #ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\n vec3 getBlendShapeVertexElement(int blendShapeIndex, int vertexElementIndex)\n { \n int y = vertexElementIndex / renderer_BlendShapeTextureInfo.y;\n int x = vertexElementIndex - y * renderer_BlendShapeTextureInfo.y;\n ivec3 uv = ivec3(x, y , blendShapeIndex);\n return texelFetch(renderer_BlendShapeTexture, uv, 0).xyz;\n }\n #endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n #ifdef RENDERER_BLENDSHAPE_USE_TEXTURE \n int vertexOffset = gl_VertexID * renderer_BlendShapeTextureInfo.x;\n for(int i = 0; i < RENDERER_BLENDSHAPE_COUNT; i++){\n int vertexElementOffset = vertexOffset;\n float weight = renderer_BlendShapeWeights[i];\n // Warnning: Multiplying by 0 creates weird precision issues, causing rendering anomalies in Ace2 Android13\n if(weight != 0.0){\n position.xyz += getBlendShapeVertexElement(i, vertexElementOffset) * weight;\n \n #ifndef MATERIAL_OMIT_NORMAL\n #if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\n vertexElementOffset += 1;\n normal += getBlendShapeVertexElement(i, vertexElementOffset) * weight;\n #endif\n \n #if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\n vertexElementOffset += 1;\n tangent.xyz += getBlendShapeVertexElement(i, vertexElementOffset) * weight;\n #endif\n #endif\n }\n \n }\n #else\n position.xyz += POSITION_BS0 * renderer_BlendShapeWeights[0];\n position.xyz += POSITION_BS1 * renderer_BlendShapeWeights[1];\n\n #if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n #ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n normal += NORMAL_BS0 * renderer_BlendShapeWeights[0];\n 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) )\n tangent.xyz += TANGENT_BS0 * renderer_BlendShapeWeights[0];\n 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\n position.xyz += POSITION_BS2 * renderer_BlendShapeWeights[2];\n position.xyz += POSITION_BS3 * renderer_BlendShapeWeights[3];\n\n #if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\n normal += NORMAL_BS0 * renderer_BlendShapeWeights[0];\n normal += NORMAL_BS1 * renderer_BlendShapeWeights[1];\n normal += NORMAL_BS2 * renderer_BlendShapeWeights[2];\n normal += NORMAL_BS3 * renderer_BlendShapeWeights[3];\n #endif\n\n #if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\n tangent.xyz += TANGENT_BS0 * renderer_BlendShapeWeights[0];\n tangent.xyz += TANGENT_BS1 * renderer_BlendShapeWeights[1];\n tangent.xyz += TANGENT_BS2 * renderer_BlendShapeWeights[2];\n tangent.xyz += TANGENT_BS3 * renderer_BlendShapeWeights[3];\n #endif\n #endif\n #else\n position.xyz += POSITION_BS2 * renderer_BlendShapeWeights[2];\n position.xyz += POSITION_BS3 * renderer_BlendShapeWeights[3];\n position.xyz += POSITION_BS4 * renderer_BlendShapeWeights[4];\n position.xyz += POSITION_BS5 * renderer_BlendShapeWeights[5];\n position.xyz += POSITION_BS6 * renderer_BlendShapeWeights[6];\n position.xyz += POSITION_BS7 * renderer_BlendShapeWeights[7];\n #endif\n #endif\n #endif\n#endif\n\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\n v_uv = TEXCOORD_0;\n#else\n // may need this calculate normal\n v_uv = vec2( 0., 0. );\n#endif\n\n#ifdef RENDERER_HAS_UV1\n v_uv1 = TEXCOORD_1;\n#endif\n\n#ifdef MATERIAL_NEED_TILING_OFFSET\n v_uv = v_uv * material_TilingOffset.xy + material_TilingOffset.zw;\n#endif",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\n vec4 temp_pos = renderer_ModelMat * position;\n v_pos = temp_pos.xyz / temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n vec4 positionVS = renderer_MVMat * position;\n v_positionVS = positionVS.xyz / positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n// Directional light\n#ifdef SCENE_DIRECT_LIGHT_COUNT\n\n struct DirectLight {\n vec3 color;\n vec3 direction;\n };\n\n uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];\n uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];\n uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n\n#endif\n\n// Point light\n#ifdef SCENE_POINT_LIGHT_COUNT\n\n struct PointLight {\n vec3 color;\n vec3 position;\n float distance;\n };\n\n uniform ivec2 scene_PointLightCullingMask[ SCENE_POINT_LIGHT_COUNT ];\n uniform vec3 scene_PointLightColor[ SCENE_POINT_LIGHT_COUNT ];\n uniform vec3 scene_PointLightPosition[ SCENE_POINT_LIGHT_COUNT ];\n uniform float scene_PointLightDistance[ SCENE_POINT_LIGHT_COUNT ];\n\n#endif\n\n// Spot light\n#ifdef SCENE_SPOT_LIGHT_COUNT\n\n struct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n float distance;\n float angleCos;\n float penumbraCos;\n };\n\n uniform ivec2 scene_SpotLightCullingMask[ SCENE_SPOT_LIGHT_COUNT ];\n uniform vec3 scene_SpotLightColor[ SCENE_SPOT_LIGHT_COUNT ];\n uniform vec3 scene_SpotLightPosition[ SCENE_SPOT_LIGHT_COUNT ];\n uniform vec3 scene_SpotLightDirection[ SCENE_SPOT_LIGHT_COUNT ];\n uniform float scene_SpotLightDistance[ SCENE_SPOT_LIGHT_COUNT ];\n uniform float scene_SpotLightAngleCos[ SCENE_SPOT_LIGHT_COUNT ];\n uniform float scene_SpotLightPenumbraCos[ SCENE_SPOT_LIGHT_COUNT ];\n\n#endif\n\n// Ambient light\nstruct EnvMapLight {\n vec3 diffuse;\n float mipMapLevel;\n float diffuseIntensity;\n float specularIntensity;\n};\n\nuniform EnvMapLight scene_EnvMapLight;\nuniform ivec4 renderer_Layer;\n\n#ifdef SCENE_USE_SH\n uniform vec3 scene_EnvSH[9];\n#endif\n\n#ifdef SCENE_USE_SPECULAR_ENV\n uniform samplerCube scene_EnvSpecularSampler;\n#endif\n\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value, float mask, float bitIndex)\n{\n return mod(floor(value / pow(2.0, bitIndex)), 2.0) == 1.0 && mod(floor(mask / pow(2.0, bitIndex)), 2.0) == 1.0;\n}\n#endif\n\nbool isRendererCulledByLight(ivec2 rendererLayer, ivec2 lightCullingMask)\n{\n #ifdef GRAPHICS_API_WEBGL2\n return !((rendererLayer.x & lightCullingMask.x) != 0 || (rendererLayer.y & lightCullingMask.y) != 0);\n #else\n for (int i = 0; i < 16; i++) {\n if (isBitSet( float(rendererLayer.x), float(lightCullingMask.x), float(i)) || isBitSet( float(rendererLayer.y), float(lightCullingMask.y), float(i))) {\n return false;\n }\n }\n return true;\n #endif\n}\n",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;\nuniform vec4 material_BaseColor;\nuniform vec4 material_SpecularColor;\nuniform float material_Shininess;\nuniform float material_NormalIntensity;\nuniform float material_AlphaCutoff;\n\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n uniform sampler2D material_SpecularTexture;\n#endif\n\n#ifdef MATERIAL_HAS_NORMALTEXTURE\n uniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n float fogIntensity = ComputeFogIntensity(length(v_positionVS));\n gl_FragColor.rgb = mix(scene_FogColor.rgb, gl_FragColor.rgb, fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\n vec4 ambient = vec4(0.0);\n vec4 emission = material_EmissiveColor;\n vec4 diffuse = material_BaseColor;\n vec4 specular = material_SpecularColor;\n\n \n\n #ifdef MATERIAL_HAS_EMISSIVETEXTURE\n vec4 emissiveTextureColor = texture2D(material_EmissiveTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n emissiveTextureColor = gammaToLinear(emissiveTextureColor);\n #endif\n emission *= emissiveTextureColor;\n\n #endif\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec4 diffuseTextureColor = texture2D(material_BaseTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n diffuseTextureColor = gammaToLinear(diffuseTextureColor);\n #endif\n diffuse *= diffuseTextureColor;\n\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n\n diffuse *= v_color;\n\n #endif\n\n #ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n vec4 specularTextureColor = texture2D(material_SpecularTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n specularTextureColor = gammaToLinear(specularTextureColor);\n #endif\n specular *= specularTextureColor;\n\n #endif\n\n ambient = vec4(scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity, 1.0) * diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\n vec3 V = -camera_Forward;\n#else\n #ifdef MATERIAL_NEED_WORLD_POS\n vec3 V = normalize( camera_Position - v_pos );\n #endif\n#endif",mobile_blinnphong_frag:"#define GLSLIFY 1\n #ifdef MATERIAL_HAS_NORMALTEXTURE\n mat3 tbn = getTBN(gl_FrontFacing);\n vec3 N = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v_uv, gl_FrontFacing);\n #else\n vec3 N = getNormal(gl_FrontFacing);\n #endif\n\n vec3 lightDiffuse = vec3( 0.0, 0.0, 0.0 );\n vec3 lightSpecular = vec3( 0.0, 0.0, 0.0 );\n float shadowAttenuation = 1.0;\n\n #ifdef SCENE_DIRECT_LIGHT_COUNT\n shadowAttenuation = 1.0;\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n shadowAttenuation *= sampleShadowMap();\n #endif\n\n DirectLight directionalLight;\n for( int i = 0; i < SCENE_DIRECT_LIGHT_COUNT; i++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_DirectLightCullingMask[i])){\n directionalLight.color = scene_DirectLightColor[i];\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n if (i == 0) { // Sun light index is always 0\n directionalLight.color *= shadowAttenuation;\n }\n #endif\n directionalLight.direction = scene_DirectLightDirection[i];\n \n float d = max(dot(N, -directionalLight.direction), 0.0);\n lightDiffuse += directionalLight.color * d;\n \n vec3 halfDir = normalize( V - directionalLight.direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess );\n lightSpecular += directionalLight.color * s;\n }\n }\n\n #endif\n\n #ifdef SCENE_POINT_LIGHT_COUNT\n PointLight pointLight;\n for( int i = 0; i < SCENE_POINT_LIGHT_COUNT; i++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_PointLightCullingMask[i])){\n pointLight.color = scene_PointLightColor[i];\n pointLight.position = scene_PointLightPosition[i];\n pointLight.distance = scene_PointLightDistance[i];\n\n vec3 direction = v_pos - pointLight.position;\n float dist = length( direction );\n direction /= dist;\n float decay = clamp(1.0 - pow(dist / pointLight.distance, 4.0), 0.0, 1.0);\n\n float d = max( dot( N, -direction ), 0.0 ) * decay;\n lightDiffuse += pointLight.color * d;\n\n vec3 halfDir = normalize( V - direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess ) * decay;\n lightSpecular += pointLight.color * s;\n }\n }\n\n #endif\n\n #ifdef SCENE_SPOT_LIGHT_COUNT\n SpotLight spotLight;\n for( int i = 0; i < SCENE_SPOT_LIGHT_COUNT; i++) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_SpotLightCullingMask[i])){\n spotLight.color = scene_SpotLightColor[i];\n spotLight.position = scene_SpotLightPosition[i];\n spotLight.direction = scene_SpotLightDirection[i];\n spotLight.distance = scene_SpotLightDistance[i];\n spotLight.angleCos = scene_SpotLightAngleCos[i];\n spotLight.penumbraCos = scene_SpotLightPenumbraCos[i];\n\n vec3 direction = spotLight.position - v_pos;\n float lightDistance = length( direction );\n direction /= lightDistance;\n float angleCos = dot( direction, -spotLight.direction );\n float decay = clamp(1.0 - pow(lightDistance/spotLight.distance, 4.0), 0.0, 1.0);\n float spotEffect = smoothstep( spotLight.penumbraCos, spotLight.angleCos, angleCos );\n float decayTotal = decay * spotEffect;\n float d = max( dot( N, direction ), 0.0 ) * decayTotal;\n lightDiffuse += spotLight.color * d;\n\n vec3 halfDir = normalize( V + direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess ) * decayTotal;\n lightSpecular += spotLight.color * s;\n }\n }\n\n #endif\n\n diffuse *= vec4( lightDiffuse, 1.0 );\n specular *= vec4( lightSpecular, 1.0 );\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( diffuse.a < material_AlphaCutoff ) {\n discard;\n }\n #endif\n",noise_common:"#define GLSLIFY 1\n// Modulo 289 without a division (only multiplications)\nvec4 mod289( vec4 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nvec3 mod289( vec3 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nvec2 mod289( vec2 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nfloat mod289( float x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\n// Modulo 7 without a division\nvec4 mod7( vec4 x ) {\n\n return x - floor( x * ( 1.0 / 7.0 ) ) * 7.0;\n\n}\n\nvec3 mod7( vec3 x ) {\n\n return x - floor( x * ( 1.0 / 7.0 ) ) * 7.0;\n\n}\n\n// Permutation polynomial: (34x^2 + x) mod 289\nvec4 permute( vec4 x ) {\n\n return mod289( ( 34.0 * x + 1.0 ) * x);\n\n}\n\nvec3 permute( vec3 x ) {\n\n return mod289( ( 34.0 * x + 1.0 ) * x );\n\n}\n\nfloat permute( float x ) {\n\n return mod289( ( ( x * 34.0 ) + 1.0 ) * x );\n\n}\n\nvec4 taylorInvSqrt( vec4 r ) {\n\n return 1.79284291400159 - 0.85373472095314 * r;\n\n}\n\nfloat taylorInvSqrt( float r ) {\n\n return 1.79284291400159 - 0.85373472095314 * r;\n\n}\n\nvec4 fade( vec4 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\nvec3 fade( vec3 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\nvec2 fade( vec2 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\n#define K 0.142857142857 // 1/7\n#define Ko 0.428571428571 // 1/2-K/2\n#define K2 0.020408163265306 // 1/(7*7)\n#define Kd2 0.0714285714285 // K/2\n#define Kz 0.166666666667 // 1/6\n#define Kzo 0.416666666667 // 1/2-1/6*2\n#define jitter 1.0 // smaller jitter gives more regular pattern\n#define jitter1 0.8 // smaller jitter gives less errors in F1 F2\n",noise_cellular_2D:'#define GLSLIFY 1\n// Cellular noise ("Worley noise") in 2D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Standard 3x3 search window for good F1 and F2 values\nvec2 cellular( vec2 P ) {\n\n vec2 Pi = mod289( floor( P ) );\n vec2 Pf = fract( P );\n vec3 oi = vec3( -1.0, 0.0, 1.0);\n vec3 of = vec3( -0.5, 0.5, 1.5);\n vec3 px = permute( Pi.x + oi );\n vec3 p = permute( px.x + Pi.y + oi ); // p11, p12, p13\n vec3 ox = fract( p * K ) - Ko;\n vec3 oy = mod7( floor( p * K ) ) * K - Ko;\n vec3 dx = Pf.x + 0.5 + jitter * ox;\n vec3 dy = Pf.y - of + jitter * oy;\n vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared\n p = permute( px.y + Pi.y + oi ); // p21, p22, p23\n ox = fract( p * K ) - Ko;\n oy = mod7( floor( p * K ) ) * K - Ko;\n dx = Pf.x - 0.5 + jitter * ox;\n dy = Pf.y - of + jitter * oy;\n vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared\n p = permute( px.z + Pi.y + oi ); // p31, p32, p33\n ox = fract( p * K ) - Ko;\n oy = mod7( floor( p * K ) ) * K - Ko;\n dx = Pf.x - 1.5 + jitter * ox;\n dy = Pf.y - of + jitter * oy;\n vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared\n // Sort out the two smallest distances (F1, F2)\n vec3 d1a = min( d1, d2 );\n d2 = max( d1, d2 ); // Swap to keep candidates for F2\n d2 = min( d2, d3 ); // neither F1 nor F2 are now in d3\n d1 = min( d1a, d2 ); // F1 is now in d1\n d2 = max( d1a, d2 ); // Swap to keep candidates for F2\n d1.xy = ( d1.x < d1.y ) ? d1.xy : d1.yx; // Swap if smaller\n d1.xz = ( d1.x < d1.z ) ? d1.xz : d1.zx; // F1 is in d1.x\n d1.yz = min( d1.yz, d2.yz ); // F2 is now not in d2.yz\n d1.y = min( d1.y, d1.z ); // nor in d1.z\n d1.y = min( d1.y, d2.x ); // F2 is in d1.y, we\'re done.\n return sqrt( d1.xy );\n\n}\n',noise_cellular_2x2:'#define GLSLIFY 1\n// Cellular noise ("Worley noise") in 2D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Speeded up by using 2x2 search window instead of 3x3,\n// at the expense of some strong pattern artifacts.\n// F2 is often wrong and has sharp discontinuities.\n// If you need a smooth F2, use the slower 3x3 version.\n// F1 is sometimes wrong, too, but OK for most purposes.\nvec2 cellular2x2( vec2 P ) {\n\n vec2 Pi = mod289( floor( P ) );\n vec2 Pf = fract( P );\n vec4 Pfx = Pf.x + vec4( -0.5, -1.5, -0.5, -1.5 );\n vec4 Pfy = Pf.y + vec4( -0.5, -0.5, -1.5, -1.5 );\n vec4 p = permute( Pi.x + vec4( 0.0, 1.0, 0.0, 1.0 ) );\n p = permute( p + Pi.y + vec4( 0.0, 0.0, 1.0, 1.0 ) );\n vec4 ox = mod7( p ) * K + Kd2;\n vec4 oy = mod7( floor( p * K ) ) * K + Kd2;\n vec4 dx = Pfx + jitter1 * ox;\n vec4 dy = Pfy + jitter1 * oy;\n vec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared\n\n // Do it right and find both F1 and F2\n d.xy = ( d.x < d.y ) ? d.xy : d.yx; // Swap if smaller\n d.xz = ( d.x < d.z ) ? d.xz : d.zx;\n d.xw = ( d.x < d.w ) ? d.xw : d.wx;\n d.y = min( d.y, d.z );\n d.y = min( d.y, d.w );\n return sqrt( d.xy );\n\n}\n',noise_cellular_2x2x2:'#define GLSLIFY 1\n// Cellular noise ("Worley noise") in 3D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Speeded up by using 2x2x2 search window instead of 3x3x3,\n// at the expense of some pattern artifacts.\n// F2 is often wrong and has sharp discontinuities.\n// If you need a good F2, use the slower 3x3x3 version.\nvec2 cellular2x2x2(vec3 P) {\n\n vec3 Pi = mod289( floor( P ) );\n vec3 Pf = fract( P );\n vec4 Pfx = Pf.x + vec4( 0.0, -1.0, 0.0, -1.0 );\n vec4 Pfy = Pf.y + vec4( 0.0, 0.0, -1.0, -1.0 );\n vec4 p = permute( Pi.x + vec4( 0.0, 1.0, 0.0, 1.0 ) );\n p = permute( p + Pi.y + vec4( 0.0, 0.0, 1.0, 1.0 ) );\n vec4 p1 = permute( p + Pi.z ); // z+0\n vec4 p2 = permute( p + Pi.z + vec4( 1.0 ) ); // z+1\n vec4 ox1 = fract( p1 * K ) - Ko;\n vec4 oy1 = mod7( floor( p1 * K ) ) * K - Ko;\n vec4 oz1 = floor( p1 * K2 ) * Kz - Kzo; // p1 < 289 guaranteed\n vec4 ox2 = fract( p2 * K ) - Ko;\n vec4 oy2 = mod7( floor( p2 * K ) ) * K - Ko;\n vec4 oz2 = floor( p2 * K2 ) * Kz - Kzo;\n vec4 dx1 = Pfx + jitter1 * ox1;\n vec4 dy1 = Pfy + jitter1 * oy1;\n vec4 dz1 = Pf.z + jitter1 * oz1;\n vec4 dx2 = Pfx + jitter1 * ox2;\n vec4 dy2 = Pfy + jitter1 * oy2;\n vec4 dz2 = Pf.z - 1.0 + jitter1 * oz2;\n vec4 d1 = dx1 * dx1 + dy1 * dy1 + dz1 * dz1; // z+0\n vec4 d2 = dx2 * dx2 + dy2 * dy2 + dz2 * dz2; // z+1\n\n // Do it right and sort out both F1 and F2\n vec4 d = min( d1, d2 ); // F1 is now in d\n d2 = max( d1, d2 ); // Make sure we keep all candidates for F2\n d.xy = ( d.x < d.y ) ? d.xy : d.yx; // Swap smallest to d.x\n d.xz = ( d.x < d.z ) ? d.xz : d.zx;\n d.xw = ( d.x < d.w ) ? d.xw : d.wx; // F1 is now in d.x\n d.yzw = min( d.yzw, d2.yzw ); // F2 now not in d2.yzw\n d.y = min( d.y, d.z ); // nor in d.z\n d.y = min( d.y, d.w ); // nor in d.w\n d.y = min( d.y, d2.x ); // F2 is now in d.y\n return sqrt( d.xy ); // F1 and F2\n\n}\n',noise_cellular_3D:'#define GLSLIFY 1\n// Cellular noise ("Worley noise") in 3D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// 3x3x3 search region for good F2 everywhere, but a lot\n// slower than the 2x2x2 version.\n// The code below is a bit scary even to its author,\n// but it has at least half decent performance on a\n// modern GPU. In any case, it beats any software\n// implementation of Worley noise hands down.\n\nvec2 cellular( vec3 P ) {\n\n vec3 Pi = mod289( floor( P ) );\n vec3 Pf = fract( P ) - 0.5;\n\n vec3 Pfx = Pf.x + vec3( 1.0, 0.0, -1.0 );\n vec3 Pfy = Pf.y + vec3( 1.0, 0.0, -1.0 );\n vec3 Pfz = Pf.z + vec3( 1.0, 0.0, -1.0 );\n\n vec3 p = permute( Pi.x + vec3( -1.0, 0.0, 1.0 ) );\n vec3 p1 = permute( p + Pi.y - 1.0 );\n vec3 p2 = permute( p + Pi.y );\n vec3 p3 = permute( p + Pi.y + 1.0 );\n\n vec3 p11 = permute( p1 + Pi.z - 1.0 );\n vec3 p12 = permute( p1 + Pi.z );\n vec3 p13 = permute( p1 + Pi.z + 1.0 );\n\n vec3 p21 = permute( p2 + Pi.z - 1.0 );\n vec3 p22 = permute( p2 + Pi.z );\n vec3 p23 = permute( p2 + Pi.z + 1.0 );\n\n vec3 p31 = permute( p3 + Pi.z - 1.0 );\n vec3 p32 = permute( p3 + Pi.z );\n vec3 p33 = permute( p3 + Pi.z + 1.0 );\n\n vec3 ox11 = fract( p11 * K ) - Ko;\n vec3 oy11 = mod7( floor( p11 * K ) ) * K - Ko;\n vec3 oz11 = floor( p11 * K2 ) * Kz - Kzo; // p11 < 289 guaranteed\n\n vec3 ox12 = fract( p12 * K ) - Ko;\n vec3 oy12 = mod7( floor( p12 * K ) ) * K - Ko;\n vec3 oz12 = floor( p12 * K2 ) * Kz - Kzo;\n\n vec3 ox13 = fract( p13 * K ) - Ko;\n vec3 oy13 = mod7( floor( p13 * K ) ) * K - Ko;\n vec3 oz13 = floor( p13 * K2 ) * Kz - Kzo;\n\n vec3 ox21 = fract( p21 * K ) - Ko;\n vec3 oy21 = mod7( floor( p21 * K ) ) * K - Ko;\n vec3 oz21 = floor( p21 * K2 ) * Kz - Kzo;\n\n vec3 ox22 = fract( p22 * K ) - Ko;\n vec3 oy22 = mod7( floor( p22 * K ) ) * K - Ko;\n vec3 oz22 = floor( p22 * K2 ) * Kz - Kzo;\n\n vec3 ox23 = fract( p23 * K ) - Ko;\n vec3 oy23 = mod7( floor( p23 * K ) ) * K - Ko;\n vec3 oz23 = floor( p23 * K2 ) * Kz - Kzo;\n\n vec3 ox31 = fract( p31 * K ) - Ko;\n vec3 oy31 = mod7( floor( p31 * K ) ) * K - Ko;\n vec3 oz31 = floor( p31 * K2 ) * Kz - Kzo;\n\n vec3 ox32 = fract( p32 * K ) - Ko;\n vec3 oy32 = mod7( floor( p32 * K ) ) * K - Ko;\n vec3 oz32 = floor( p32 * K2 ) * Kz - Kzo;\n\n vec3 ox33 = fract( p33 * K ) - Ko;\n vec3 oy33 = mod7( floor( p33 * K ) ) * K - Ko;\n vec3 oz33 = floor( p33 * K2 ) * Kz - Kzo;\n\n vec3 dx11 = Pfx + jitter * ox11;\n vec3 dy11 = Pfy.x + jitter * oy11;\n vec3 dz11 = Pfz.x + jitter * oz11;\n\n vec3 dx12 = Pfx + jitter * ox12;\n vec3 dy12 = Pfy.x + jitter * oy12;\n vec3 dz12 = Pfz.y + jitter * oz12;\n\n vec3 dx13 = Pfx + jitter * ox13;\n vec3 dy13 = Pfy.x + jitter * oy13;\n vec3 dz13 = Pfz.z + jitter * oz13;\n\n vec3 dx21 = Pfx + jitter * ox21;\n vec3 dy21 = Pfy.y + jitter * oy21;\n vec3 dz21 = Pfz.x + jitter * oz21;\n\n vec3 dx22 = Pfx + jitter * ox22;\n vec3 dy22 = Pfy.y + jitter * oy22;\n vec3 dz22 = Pfz.y + jitter * oz22;\n\n vec3 dx23 = Pfx + jitter * ox23;\n vec3 dy23 = Pfy.y + jitter * oy23;\n vec3 dz23 = Pfz.z + jitter * oz23;\n\n vec3 dx31 = Pfx + jitter * ox31;\n vec3 dy31 = Pfy.z + jitter * oy31;\n vec3 dz31 = Pfz.x + jitter * oz31;\n\n vec3 dx32 = Pfx + jitter * ox32;\n vec3 dy32 = Pfy.z + jitter * oy32;\n vec3 dz32 = Pfz.y + jitter * oz32;\n\n vec3 dx33 = Pfx + jitter * ox33;\n vec3 dy33 = Pfy.z + jitter * oy33;\n vec3 dz33 = Pfz.z + jitter * oz33;\n\n vec3 d11 = dx11 * dx11 + dy11 * dy11 + dz11 * dz11;\n vec3 d12 = dx12 * dx12 + dy12 * dy12 + dz12 * dz12;\n vec3 d13 = dx13 * dx13 + dy13 * dy13 + dz13 * dz13;\n vec3 d21 = dx21 * dx21 + dy21 * dy21 + dz21 * dz21;\n vec3 d22 = dx22 * dx22 + dy22 * dy22 + dz22 * dz22;\n vec3 d23 = dx23 * dx23 + dy23 * dy23 + dz23 * dz23;\n vec3 d31 = dx31 * dx31 + dy31 * dy31 + dz31 * dz31;\n vec3 d32 = dx32 * dx32 + dy32 * dy32 + dz32 * dz32;\n vec3 d33 = dx33 * dx33 + dy33 * dy33 + dz33 * dz33;\n\n // Do it right and sort out both F1 and F2\n vec3 d1a = min( d11, d12 );\n d12 = max( d11, d12 );\n d11 = min( d1a, d13 ); // Smallest now not in d12 or d13\n d13 = max( d1a, d13 );\n d12 = min( d12, d13 ); // 2nd smallest now not in d13\n vec3 d2a = min( d21, d22 );\n d22 = max( d21, d22 );\n d21 = min( d2a, d23 ); // Smallest now not in d22 or d23\n d23 = max( d2a, d23 );\n d22 = min( d22, d23 ); // 2nd smallest now not in d23\n vec3 d3a = min( d31, d32 );\n d32 = max( d31, d32 );\n d31 = min( d3a, d33 ); // Smallest now not in d32 or d33\n d33 = max( d3a, d33 );\n d32 = min( d32, d33 ); // 2nd smallest now not in d33\n vec3 da = min( d11, d21 );\n d21 = max( d11, d21 );\n d11 = min( da, d31 ); // Smallest now in d11\n d31 = max( da, d31 ); // 2nd smallest now not in d31\n d11.xy = ( d11.x < d11.y ) ? d11.xy : d11.yx;\n d11.xz = ( d11.x < d11.z ) ? d11.xz : d11.zx; // d11.x now smallest\n d12 = min( d12, d21 ); // 2nd smallest now not in d21\n d12 = min( d12, d22 ); // nor in d22\n d12 = min( d12, d31 ); // nor in d31\n d12 = min( d12, d32 ); // nor in d32\n d11.yz = min( d11.yz, d12.xy ); // nor in d12.yz\n d11.y = min( d11.y, d12.z ); // Only two more to go\n d11.y = min( d11.y, d11.z ); // Done! (Phew! )\n return sqrt( d11.xy ); // F1, F2\n\n}\n',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\n//\n// GLSL textureless classic 2D noise "cnoise",\n// with an RSL-style periodic variant "pnoise".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec2 P ) {\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;\n vec4 gy = abs(gx) - 0.5 ;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x,gy.x);\n vec2 g10 = vec2(gx.y,gy.y);\n vec2 g01 = vec2(gx.z,gy.z);\n vec2 g11 = vec2(gx.w,gy.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return 2.3 * n_xy;\n\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin( vec2 P, vec2 rep ) {\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod(Pi, rep.xyxy); // To create noise with explicit period\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;\n vec4 gy = abs(gx) - 0.5 ;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x,gy.x);\n vec2 g10 = vec2(gx.y,gy.y);\n vec2 g01 = vec2(gx.z,gy.z);\n vec2 g11 = vec2(gx.w,gy.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return 2.3 * n_xy;\n\n}\n',noise_perlin_3D:'#define GLSLIFY 1\n//\n// GLSL textureless classic 3D noise "cnoise",\n// with an RSL-style periodic variant "pnoise".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-10-11\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec3 P ) {\n\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin( vec3 P, vec3 rep ) {\n\n vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period\n vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n\n}\n',noise_perlin_4D:'#define GLSLIFY 1\n//\n// GLSL textureless classic 4D noise "cnoise",\n// with an RSL-style periodic variant "pnoise".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec4 P ) {\n\n vec4 Pi0 = floor(P); // Integer part for indexing\n vec4 Pi1 = Pi0 + 1.0; // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec4 Pf0 = fract(P); // Fractional part for interpolation\n vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = vec4(Pi0.zzzz);\n vec4 iz1 = vec4(Pi1.zzzz);\n vec4 iw0 = vec4(Pi0.wwww);\n vec4 iw1 = vec4(Pi1.wwww);\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 ixy00 = permute(ixy0 + iw0);\n vec4 ixy01 = permute(ixy0 + iw1);\n vec4 ixy10 = permute(ixy1 + iw0);\n vec4 ixy11 = permute(ixy1 + iw1);\n\n vec4 gx00 = ixy00 * (1.0 / 7.0);\n vec4 gy00 = floor(gx00) * (1.0 / 7.0);\n vec4 gz00 = floor(gy00) * (1.0 / 6.0);\n gx00 = fract(gx00) - 0.5;\n gy00 = fract(gy00) - 0.5;\n gz00 = fract(gz00) - 0.5;\n vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);\n vec4 sw00 = step(gw00, vec4(0.0));\n gx00 -= sw00 * (step(0.0, gx00) - 0.5);\n gy00 -= sw00 * (step(0.0, gy00) - 0.5);\n\n vec4 gx01 = ixy01 * (1.0 / 7.0);\n vec4 gy01 = floor(gx01) * (1.0 / 7.0);\n vec4 gz01 = floor(gy01) * (1.0 / 6.0);\n gx01 = fract(gx01) - 0.5;\n gy01 = fract(gy01) - 0.5;\n gz01 = fract(gz01) - 0.5;\n vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);\n vec4 sw01 = step(gw01, vec4(0.0));\n gx01 -= sw01 * (step(0.0, gx01) - 0.5);\n gy01 -= sw01 * (step(0.0, gy01) - 0.5);\n\n vec4 gx10 = ixy10 * (1.0 / 7.0);\n vec4 gy10 = floor(gx10) * (1.0 / 7.0);\n vec4 gz10 = floor(gy10) * (1.0 / 6.0);\n gx10 = fract(gx10) - 0.5;\n gy10 = fract(gy10) - 0.5;\n gz10 = fract(gz10) - 0.5;\n vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);\n vec4 sw10 = step(gw10, vec4(0.0));\n gx10 -= sw10 * (step(0.0, gx10) - 0.5);\n gy10 -= sw10 * (step(0.0, gy10) - 0.5);\n\n vec4 gx11 = ixy11 * (1.0 / 7.0);\n vec4 gy11 = floor(gx11) * (1.0 / 7.0);\n vec4 gz11 = floor(gy11) * (1.0 / 6.0);\n gx11 = fract(gx11) - 0.5;\n gy11 = fract(gy11) - 0.5;\n gz11 = fract(gz11) - 0.5;\n vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);\n vec4 sw11 = step(gw11, vec4(0.0));\n gx11 -= sw11 * (step(0.0, gx11) - 0.5);\n gy11 -= sw11 * (step(0.0, gy11) - 0.5);\n\n vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x);\n vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y);\n vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z);\n vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w);\n vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x);\n vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y);\n vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z);\n vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w);\n vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x);\n vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y);\n vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z);\n vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w);\n vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x);\n vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y);\n vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z);\n vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w);\n\n vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));\n g0000 *= norm00.x;\n g0100 *= norm00.y;\n g1000 *= norm00.z;\n g1100 *= norm00.w;\n\n vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));\n g0001 *= norm01.x;\n g0101 *= norm01.y;\n g1001 *= norm01.z;\n g1101 *= norm01.w;\n\n vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));\n g0010 *= norm10.x;\n g0110 *= norm10.y;\n g1010 *= norm10.z;\n g1110 *= norm10.w;\n\n vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));\n g0011 *= norm11.x;\n g0111 *= norm11.y;\n g1011 *= norm11.z;\n g1111 *= norm11.w;\n\n float n0000 = dot(g0000, Pf0);\n float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw));\n float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw));\n float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw));\n float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w));\n float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));\n float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w));\n float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w));\n float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w));\n float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w));\n float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));\n float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w));\n float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw));\n float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw));\n float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw));\n float n1111 = dot(g1111, Pf1);\n\n vec4 fade_xyzw = fade(Pf0);\n vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);\n vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);\n vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);\n vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);\n float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);\n return 2.2 * n_xyzw;\n\n}\n\n// Classic Perlin noise, periodic version\nfloat perlin( vec4 P, vec4 rep ) {\n\n vec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep\n vec4 Pi1 = mod(Pi0 + 1.0, rep); // Integer part + 1 mod rep\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec4 Pf0 = fract(P); // Fractional part for interpolation\n vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = vec4(Pi0.zzzz);\n vec4 iz1 = vec4(Pi1.zzzz);\n vec4 iw0 = vec4(Pi0.wwww);\n vec4 iw1 = vec4(Pi1.wwww);\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 ixy00 = permute(ixy0 + iw0);\n vec4 ixy01 = permute(ixy0 + iw1);\n vec4 ixy10 = permute(ixy1 + iw0);\n vec4 ixy11 = permute(ixy1 + iw1);\n\n vec4 gx00 = ixy00 * (1.0 / 7.0);\n vec4 gy00 = floor(gx00) * (1.0 / 7.0);\n vec4 gz00 = floor(gy00) * (1.0 / 6.0);\n gx00 = fract(gx00) - 0.5;\n gy00 = fract(gy00) - 0.5;\n gz00 = fract(gz00) - 0.5;\n vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);\n vec4 sw00 = step(gw00, vec4(0.0));\n gx00 -= sw00 * (step(0.0, gx00) - 0.5);\n gy00 -= sw00 * (step(0.0, gy00) - 0.5);\n\n vec4 gx01 = ixy01 * (1.0 / 7.0);\n vec4 gy01 = floor(gx01) * (1.0 / 7.0);\n vec4 gz01 = floor(gy01) * (1.0 / 6.0);\n gx01 = fract(gx01) - 0.5;\n gy01 = fract(gy01) - 0.5;\n gz01 = fract(gz01) - 0.5;\n vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);\n vec4 sw01 = step(gw01, vec4(0.0));\n gx01 -= sw01 * (step(0.0, gx01) - 0.5);\n gy01 -= sw01 * (step(0.0, gy01) - 0.5);\n\n vec4 gx10 = ixy10 * (1.0 / 7.0);\n vec4 gy10 = floor(gx10) * (1.0 / 7.0);\n vec4 gz10 = floor(gy10) * (1.0 / 6.0);\n gx10 = fract(gx10) - 0.5;\n gy10 = fract(gy10) - 0.5;\n gz10 = fract(gz10) - 0.5;\n vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);\n vec4 sw10 = step(gw10, vec4(0.0));\n gx10 -= sw10 * (step(0.0, gx10) - 0.5);\n gy10 -= sw10 * (step(0.0, gy10) - 0.5);\n\n vec4 gx11 = ixy11 * (1.0 / 7.0);\n vec4 gy11 = floor(gx11) * (1.0 / 7.0);\n vec4 gz11 = floor(gy11) * (1.0 / 6.0);\n gx11 = fract(gx11) - 0.5;\n gy11 = fract(gy11) - 0.5;\n gz11 = fract(gz11) - 0.5;\n vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);\n vec4 sw11 = step(gw11, vec4(0.0));\n gx11 -= sw11 * (step(0.0, gx11) - 0.5);\n gy11 -= sw11 * (step(0.0, gy11) - 0.5);\n\n vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x);\n vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y);\n vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z);\n vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w);\n vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x);\n vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y);\n vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z);\n vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w);\n vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x);\n vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y);\n vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z);\n vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w);\n vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x);\n vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y);\n vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z);\n vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w);\n\n vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));\n g0000 *= norm00.x;\n g0100 *= norm00.y;\n g1000 *= norm00.z;\n g1100 *= norm00.w;\n\n vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));\n g0001 *= norm01.x;\n g0101 *= norm01.y;\n g1001 *= norm01.z;\n g1101 *= norm01.w;\n\n vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));\n g0010 *= norm10.x;\n g0110 *= norm10.y;\n g1010 *= norm10.z;\n g1110 *= norm10.w;\n\n vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));\n g0011 *= norm11.x;\n g0111 *= norm11.y;\n g1011 *= norm11.z;\n g1111 *= norm11.w;\n\n float n0000 = dot(g0000, Pf0);\n float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw));\n float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw));\n float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw));\n float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w));\n float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));\n float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w));\n float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w));\n float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w));\n float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w));\n float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));\n float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w));\n float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw));\n float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw));\n float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw));\n float n1111 = dot(g1111, Pf1);\n\n vec4 fade_xyzw = fade(Pf0);\n vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);\n vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);\n vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);\n vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);\n float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);\n return 2.2 * n_xyzw;\n\n}\n',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\n// Periodic (tiling) 2-D simplex noise (hexagonal lattice gradient noise)\n// with rotating gradients and analytic derivatives.\n// Variants also without the derivative (no "d" in the name), without\n// the tiling property (no "p" in the name) and without the rotating\n// gradients (no "r" in the name).\n//\n// This is (yet) another variation on simplex noise. It\'s similar to the\n// version presented by Ken Perlin, but the grid is axis-aligned and\n// slightly stretched in the y direction to permit rectangular tiling.\n//\n// The noise can be made to tile seamlessly to any integer period in x and\n// any even integer period in y. Odd periods may be specified for y, but\n// then the actual tiling period will be twice that number.\n//\n// The rotating gradients give the appearance of a swirling motion, and can\n// serve a similar purpose for animation as motion along z in 3-D noise.\n// The rotating gradients in conjunction with the analytic derivatives\n// can make "flow noise" effects as presented by Perlin and Neyret.\n//\n// vec3 {p}s{r}dnoise(vec2 pos {, vec2 per} {, float rot})\n// "pos" is the input (x,y) coordinate\n// "per" is the x and y period, where per.x is a positive integer\n// and per.y is a positive even integer\n// "rot" is the angle to rotate the gradients (any float value,\n// where 0.0 is no rotation and 1.0 is one full turn)\n// The first component of the 3-element return vector is the noise value.\n// The second and third components are the x and y partial derivatives.\n//\n// float {p}s{r}noise(vec2 pos {, vec2 per} {, float rot})\n// "pos" is the input (x,y) coordinate\n// "per" is the x and y period, where per.x is a positive integer\n// and per.y is a positive even integer\n// "rot" is the angle to rotate the gradients (any float value,\n// where 0.0 is no rotation and 1.0 is one full turn)\n// The return value is the noise value.\n// Partial derivatives are not computed, making these functions faster.\n//\n// Author: Stefan Gustavson (stefan.gustavson@gmail.com)\n// Version 2016-05-10.\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// idea of using a permutation polynomial.\n//\n// Copyright (c) 2016 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Hashed 2-D gradients with an extra rotation.\n// (The constant 0.0243902439 is 1/41)\nvec2 rgrad2( vec2 p, float rot ) {\n\n // For more isotropic gradients, sin/cos can be used instead.\n float u = permute( permute( p.x ) + p.y ) * 0.0243902439 + rot; // Rotate by shift\n u = fract( u ) * 6.28318530718; // 2*pi\n return vec2( cos( u ), sin( u ));\n\n}\n\n//\n// 2-D tiling simplex noise with rotating gradients and analytical derivative.\n// The first component of the 3-element return vector is the noise value,\n// and the second and third components are the x and y partial derivatives.\n//\nvec3 psrdnoise(vec2 pos, vec2 per, float rot) {\n // Hack: offset y slightly to hide some rare artifacts\n pos.y += 0.01;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);\n vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);\n vec3 iuw = xw + 0.5 * yw;\n vec3 ivw = yw;\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Partial derivatives for analytical gradient computation\n vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);\n vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n if (t.x < 0.0) {\n dtdx.x = 0.0;\n dtdy.x = 0.0;\n t.x = 0.0;\n }\n if (t.y < 0.0) {\n dtdx.y = 0.0;\n dtdy.y = 0.0;\n t.y = 0.0;\n }\n if (t.z < 0.0) {\n dtdx.z = 0.0;\n dtdy.z = 0.0;\n t.z = 0.0;\n }\n\n // Fourth power of t (and third power for derivative)\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n vec3 t3 = t2 * t;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Final analytical derivative (gradient of a sum of scalar products)\n vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;\n vec2 dn0 = t4.x * g0 + dt0 * w.x;\n vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;\n vec2 dn1 = t4.y * g1 + dt1 * w.y;\n vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;\n vec2 dn2 = t4.z * g2 + dt2 * w.z;\n\n return 11.0*vec3(n, dn0 + dn1 + dn2);\n}\n\n//\n// 2-D tiling simplex noise with fixed gradients\n// and analytical derivative.\n// This function is implemented as a wrapper to "psrdnoise",\n// at the minimal cost of three extra additions.\n//\nvec3 psdnoise(vec2 pos, vec2 per) {\n return psrdnoise(pos, per, 0.0);\n}\n\n//\n// 2-D tiling simplex noise with rotating gradients,\n// but without the analytical derivative.\n//\nfloat psrnoise(vec2 pos, vec2 per, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);\n vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);\n vec3 iuw = xw + 0.5 * yw;\n vec3 ivw = yw;\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n t = max(t, 0.0);\n\n // Fourth power of t\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Rescale to cover the range [-1,1] reasonably well\n return 11.0*n;\n}\n\n//\n// 2-D tiling simplex noise with fixed gradients,\n// without the analytical derivative.\n// This function is implemented as a wrapper to "psrnoise",\n// at the minimal cost of three extra additions.\n//\nfloat psnoise(vec2 pos, vec2 per) {\n return psrnoise(pos, per, 0.0);\n}\n\n//\n// 2-D non-tiling simplex noise with rotating gradients and analytical derivative.\n// The first component of the 3-element return vector is the noise value,\n// and the second and third components are the x and y partial derivatives.\n//\nvec3 srdnoise(vec2 pos, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n vec3 x = vec3(p0.x, p1.x, p2.x);\n vec3 y = vec3(p0.y, p1.y, p2.y);\n vec3 iuw = x + 0.5 * y;\n vec3 ivw = y;\n\n // Avoid precision issues in permutation\n iuw = mod289(iuw);\n ivw = mod289(ivw);\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Partial derivatives for analytical gradient computation\n vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);\n vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n if (t.x < 0.0) {\n dtdx.x = 0.0;\n dtdy.x = 0.0;\n t.x = 0.0;\n }\n if (t.y < 0.0) {\n dtdx.y = 0.0;\n dtdy.y = 0.0;\n t.y = 0.0;\n }\n if (t.z < 0.0) {\n dtdx.z = 0.0;\n dtdy.z = 0.0;\n t.z = 0.0;\n }\n\n // Fourth power of t (and third power for derivative)\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n vec3 t3 = t2 * t;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Final analytical derivative (gradient of a sum of scalar products)\n vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;\n vec2 dn0 = t4.x * g0 + dt0 * w.x;\n vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;\n vec2 dn1 = t4.y * g1 + dt1 * w.y;\n vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;\n vec2 dn2 = t4.z * g2 + dt2 * w.z;\n\n return 11.0*vec3(n, dn0 + dn1 + dn2);\n}\n\n//\n// 2-D non-tiling simplex noise with fixed gradients and analytical derivative.\n// This function is implemented as a wrapper to "srdnoise",\n// at the minimal cost of three extra additions.\n//\nvec3 sdnoise(vec2 pos) {\n return srdnoise(pos, 0.0);\n}\n\n//\n// 2-D non-tiling simplex noise with rotating gradients,\n// without the analytical derivative.\n//\nfloat srnoise(vec2 pos, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 x = vec3(p0.x, p1.x, p2.x);\n vec3 y = vec3(p0.y, p1.y, p2.y);\n vec3 iuw = x + 0.5 * y;\n vec3 ivw = y;\n\n // Avoid precision issues in permutation\n iuw = mod289(iuw);\n ivw = mod289(ivw);\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n t = max(t, 0.0);\n\n // Fourth power of t\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Rescale to cover the range [-1,1] reasonably well\n return 11.0*n;\n}\n\n//\n// 2-D non-tiling simplex noise with fixed gradients,\n// without the analytical derivative.\n// This function is implemented as a wrapper to "srnoise",\n// at the minimal cost of three extra additions.\n// Note: if this kind of noise is all you want, there are faster\n// GLSL implementations of non-tiling simplex noise out there.\n// This one is included mainly for completeness and compatibility\n// with the other functions in the file.\n//\nfloat snoise(vec2 pos) {\n return srnoise(pos, 0.0);\n}\n',noise_simplex_2D:"#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D simplex noise function.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec2 v ) {\n\n const vec4 C = vec4( 0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439 ); // 1.0 / 41.0\n // First corner\n vec2 i = floor( v + dot( v, C.yy ) );\n vec2 x0 = v - i + dot( i, C.xx );\n\n // Other corners\n vec2 i1;\n //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0\n //i1.y = 1.0 - i1.x;\n i1 = ( x0.x > x0.y ) ? vec2( 1.0, 0.0 ) : vec2( 0.0, 1.0 );\n // x0 = x0 - 0.0 + 0.0 * C.xx ;\n // x1 = x0 - i1 + 1.0 * C.xx ;\n // x2 = x0 - 1.0 + 2.0 * C.xx ;\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n // Permutations\n i = mod289( i ); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3( 0.0, i1.y, 1.0 ) )\n + i.x + vec3( 0.0, i1.x, 1.0 ) );\n\n vec3 m = max( 0.5 - vec3( dot( x0, x0 ), dot( x12.xy, x12.xy ), dot( x12.zw, x12.zw ) ), 0.0 );\n m = m*m ;\n m = m*m ;\n\n // Gradients: 41 points uniformly over a line, mapped onto a diamond.\n // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)\n\n vec3 x = 2.0 * fract( p * C.www ) - 1.0;\n vec3 h = abs( x ) - 0.5;\n vec3 ox = floor( x + 0.5 );\n vec3 a0 = x - ox;\n\n // Normalise gradients implicitly by scaling m\n // Approximation of: m *= inversesqrt( a0*a0 + h*h );\n m *= 1.79284291400159 - 0.85373472095314 * ( a0 * a0 + h * h );\n\n // Compute final noise value at P\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot( m, g );\n\n}\n",noise_simplex_3D_grad:"#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20150104 (JcBernack)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec3 v, out vec3 gradient ) {\n\n const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );\n const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );\n\n // First corner\n vec3 i = floor( v + dot( v, C.yyy ) );\n vec3 x0 = v - i + dot( i, C.xxx ) ;\n\n // Other corners\n vec3 g = step( x0.yzx, x0.xyz );\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289( i );\n vec4 p = permute( permute( permute(\n i.z + vec4( 0.0, i1.z, i2.z, 1.0 ) )\n + i.y + vec4( 0.0, i1.y, i2.y, 1.0 ) )\n + i.x + vec4( 0.0, i1.x, i2.x, 1.0 ) );\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs( x ) - abs( y );\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n vec4 s0 = floor( b0 ) * 2.0 + 1.0;\n vec4 s1 = floor( b1 ) * 2.0 + 1.0;\n vec4 sh = - step( h, vec4( 0.0 ) );\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww ;\n\n vec3 p0 = vec3( a0.xy, h.x );\n vec3 p1 = vec3( a0.zw, h.y );\n vec3 p2 = vec3( a1.xy, h.z );\n vec3 p3 = vec3( a1.zw, h.w );\n\n //Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );\n vec4 m2 = m * m;\n vec4 m4 = m2 * m2;\n vec4 pdotx = vec4( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 ), dot( p3, x3 ) );\n\n // Determine noise gradient\n vec4 temp = m2 * m * pdotx;\n gradient = - 8.0 * ( temp.x * x0 + temp.y * x1 + temp.z * x2 + temp.w * x3 );\n gradient += m4.x * p0 + m4.y * p1 + m4.z * p2 + m4.w * p3;\n gradient *= 42.0;\n\n return 42.0 * dot( m4, pdotx );\n\n}\n",noise_simplex_3D:"#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec3 v ) {\n\n const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );\n const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );\n\n // First corner\n vec3 i = floor( v + dot( v, C.yyy ) );\n vec3 x0 = v - i + dot( i, C.xxx );\n\n // Other corners\n vec3 g = step( x0.yzx, x0.xyz );\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289( i );\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor( p * ns.z * ns.z ); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs( x ) - abs( y );\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n vec4 s0 = floor( b0 ) * 2.0 + 1.0;\n vec4 s1 = floor( b1 ) * 2.0 + 1.0;\n vec4 sh = - step( h, vec4( 0.0 ) );\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww ;\n\n vec3 p0 = vec3( a0.xy, h.x );\n vec3 p1 = vec3( a0.zw, h.y );\n vec3 p2 = vec3( a1.xy, h.z );\n vec3 p3 = vec3( a1.zw, h.w );\n\n //Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot( p0, x0 ), dot( p1, x1 ),\n dot( p2, x2 ), dot( p3, x3 ) ) );\n\n}\n",noise_simplex_4D:"#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nvec4 grad4( float j, vec4 ip ) {\n\n const vec4 ones = vec4( 1.0, 1.0, 1.0, -1.0 );\n vec4 p, s;\n\n p.xyz = floor( fract( vec3( j ) * ip.xyz ) * 7.0 ) * ip.z - 1.0;\n p.w = 1.5 - dot( abs( p.xyz ), ones.xyz );\n s = vec4( lessThan( p, vec4( 0.0 ) ) );\n p.xyz = p.xyz + ( s.xyz * 2.0 - 1.0 ) * s.www;\n\n return p;\n\n}\n\n// (sqrt(5) - 1)/4 = F4, used once below\n#define F4 0.309016994374947451\n\nfloat simplex(vec4 v) {\n\n const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4\n 0.276393202250021, // 2 * G4\n 0.414589803375032, // 3 * G4\n -0.447213595499958); // -1 + 4 * G4\n\n // First corner\n vec4 i = floor( v + dot( v, vec4( F4 ) ) );\n vec4 x0 = v - i + dot( i, C.xxxx );\n\n // Other corners\n\n // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)\n vec4 i0;\n vec3 isX = step( x0.yzw, x0.xxx );\n vec3 isYZ = step( x0.zww, x0.yyz );\n i0.x = isX.x + isX.y + isX.z;\n i0.yzw = 1.0 - isX;\n i0.y += isYZ.x + isYZ.y;\n i0.zw += 1.0 - isYZ.xy;\n i0.z += isYZ.z;\n i0.w += 1.0 - isYZ.z;\n\n vec4 i3 = clamp( i0, 0.0, 1.0 );\n vec4 i2 = clamp( i0 - 1.0, 0.0, 1.0 );\n vec4 i1 = clamp( i0 - 2.0, 0.0, 1.0 );\n\n vec4 x1 = x0 - i1 + C.xxxx;\n vec4 x2 = x0 - i2 + C.yyyy;\n vec4 x3 = x0 - i3 + C.zzzz;\n vec4 x4 = x0 + C.wwww;\n\n // Permutations\n i = mod289( i );\n float j0 = permute( permute( permute( permute( i.w ) + i.z ) + i.y ) + i.x );\n vec4 j1 = permute( permute( permute( permute (\n i.w + vec4(i1.w, i2.w, i3.w, 1.0 ))\n + i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))\n + i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))\n + i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));\n\n // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope\n // 7*7*6 = 294, which is close to the ring size 17*17 = 289.\n vec4 ip = vec4( 1.0 / 294.0, 1.0 / 49.0, 1.0 / 7.0, 0.0 );\n\n vec4 p0 = grad4(j0, ip);\n vec4 p1 = grad4(j1.x, ip);\n vec4 p2 = grad4(j1.y, ip);\n vec4 p3 = grad4(j1.z, ip);\n vec4 p4 = grad4(j1.w, ip);\n\n // Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n p4 *= taylorInvSqrt( dot( p4, p4 ) );\n\n // Mix contributions from the five corners\n vec3 m0 = max( 0.6 - vec3( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ) ), 0.0 );\n vec2 m1 = max( 0.6 - vec2( dot( x3, x3 ), dot( x4, x4 ) ), 0.0 );\n m0 = m0 * m0;\n m1 = m1 * m1;\n return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))\n + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;\n\n}\n",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];\nuniform vec4 scene_ShadowSplitSpheres[4];\n\nmediump int computeCascadeIndex(vec3 positionWS) {\n vec3 fromCenter0 = positionWS - scene_ShadowSplitSpheres[0].xyz;\n vec3 fromCenter1 = positionWS - scene_ShadowSplitSpheres[1].xyz;\n vec3 fromCenter2 = positionWS - scene_ShadowSplitSpheres[2].xyz;\n vec3 fromCenter3 = positionWS - scene_ShadowSplitSpheres[3].xyz;\n\n mediump vec4 comparison = vec4(\n dot(fromCenter0, fromCenter0) < scene_ShadowSplitSpheres[0].w,\n dot(fromCenter1, fromCenter1) < scene_ShadowSplitSpheres[1].w,\n dot(fromCenter2, fromCenter2) < scene_ShadowSplitSpheres[2].w,\n dot(fromCenter3, fromCenter3) < scene_ShadowSplitSpheres[3].w);\n comparison.yzw = clamp(comparison.yzw - comparison.xyz,0.0,1.0);//keep the nearest\n mediump vec4 indexCoefficient = vec4(4.0,3.0,2.0,1.0);\n mediump int index = 4 - int(dot(comparison, indexCoefficient));\n return index;\n}\n\nvec3 getShadowCoord() {\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n mediump int cascadeIndex = 0;\n #else\n mediump int cascadeIndex = computeCascadeIndex(v_pos);\n #endif\n\n #ifdef GRAPHICS_API_WEBGL2\n mat4 shadowMatrix = scene_ShadowMatrices[cascadeIndex];\n #else\n mat4 shadowMatrix;\n #if SCENE_SHADOW_CASCADED_COUNT == 4\n if (cascadeIndex == 0) {\n shadowMatrix = scene_ShadowMatrices[0];\n } else if (cascadeIndex == 1) {\n shadowMatrix = scene_ShadowMatrices[1];\n } else if (cascadeIndex == 2) {\n shadowMatrix = scene_ShadowMatrices[2];\n } else if (cascadeIndex == 3) {\n shadowMatrix = scene_ShadowMatrices[3];\n } else {\n shadowMatrix = scene_ShadowMatrices[4];\n }\n #endif\n #if SCENE_SHADOW_CASCADED_COUNT == 2\n if (cascadeIndex == 0) {\n shadowMatrix = scene_ShadowMatrices[0];\n } else if (cascadeIndex == 1) {\n shadowMatrix = scene_ShadowMatrices[1];\n } else {\n shadowMatrix = scene_ShadowMatrices[2];\n } \n #endif\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n if (cascadeIndex == 0) {\n shadowMatrix = scene_ShadowMatrices[0];\n } else {\n shadowMatrix = scene_ShadowMatrices[1];\n } \n #endif\n #endif\n\n vec4 shadowCoord = shadowMatrix * vec4(v_pos, 1.0);\n return shadowCoord.xyz;\n}\n",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n #define SCENE_IS_CALCULATE_SHADOWS\n#endif\n\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n varying vec3 v_shadowCoord;\n #else\n #include <ShadowCoord>\n #endif\n \n // intensity, null, fadeScale, fadeBias\n uniform vec4 scene_ShadowInfo;\n uniform vec4 scene_ShadowMapSize;\n\n #ifdef GRAPHICS_API_WEBGL2\n uniform 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\n uniform sampler2D scene_ShadowMap;\n #ifdef ENGINE_NO_DEPTH_TEXTURE\n const vec4 bitShift = vec4(1.0, 1.0/256.0, 1.0/(256.0*256.0), 1.0/(256.0*256.0*256.0));\n /**\n * Unpack depth value.\n */\n float unpack(const in vec4 rgbaDepth) {\n return dot(rgbaDepth, bitShift);\n }\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\n #if SCENE_SHADOW_TYPE == 2\n float sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap), vec3 shadowCoord, vec4 shadowMapSize) {\n float attenuation;\n vec4 attenuation4;\n vec2 offset=shadowMapSize.xy/2.0;\n vec3 shadowCoord0=shadowCoord + vec3(-offset,0.0);\n vec3 shadowCoord1=shadowCoord + vec3(offset.x,-offset.y,0.0);\n vec3 shadowCoord2=shadowCoord + vec3(-offset.x,offset.y,0.0);\n vec3 shadowCoord3=shadowCoord + vec3(offset,0.0);\n attenuation4.x = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord0);\n attenuation4.y = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord1);\n attenuation4.z = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord2);\n attenuation4.w = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord3);\n attenuation = dot(attenuation4, vec4(0.25));\n return attenuation;\n }\n #endif\n\n #if SCENE_SHADOW_TYPE == 3\n #include <shadow_sample_tent>\n\n float sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap), vec3 shadowCoord, vec4 shadowmapSize) {\n float attenuation;\n float fetchesWeights[9];\n vec2 fetchesUV[9];\n sampleShadowComputeSamplesTent5x5(shadowmapSize, shadowCoord.xy, fetchesWeights, fetchesUV);\n attenuation = fetchesWeights[0] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[0].xy, shadowCoord.z));\n attenuation += fetchesWeights[1] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[1].xy, shadowCoord.z));\n attenuation += fetchesWeights[2] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[2].xy, shadowCoord.z));\n attenuation += fetchesWeights[3] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[3].xy, shadowCoord.z));\n attenuation += fetchesWeights[4] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[4].xy, shadowCoord.z));\n attenuation += fetchesWeights[5] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[5].xy, shadowCoord.z));\n attenuation += fetchesWeights[6] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[6].xy, shadowCoord.z));\n attenuation += fetchesWeights[7] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[7].xy, shadowCoord.z));\n attenuation += fetchesWeights[8] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[8].xy, shadowCoord.z));\n return attenuation;\n }\n #endif\n\n float getShadowFade(vec3 positionWS){\n vec3 camToPixel = positionWS - camera_Position;\n float distanceCamToPixel2 = dot(camToPixel, camToPixel);\n return saturate( distanceCamToPixel2 * scene_ShadowInfo.z + scene_ShadowInfo.w );\n }\n\n float sampleShadowMap() {\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n vec3 shadowCoord = v_shadowCoord;\n #else\n vec3 shadowCoord = getShadowCoord();\n #endif\n \n float attenuation = 1.0;\n if(shadowCoord.z > 0.0 && shadowCoord.z < 1.0) {\n #if SCENE_SHADOW_TYPE == 1\n attenuation = SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap, shadowCoord);\n #endif\n\n #if SCENE_SHADOW_TYPE == 2\n attenuation = sampleShadowMapFiltered4(scene_ShadowMap, shadowCoord, scene_ShadowMapSize);\n #endif\n\n #if SCENE_SHADOW_TYPE == 3\n attenuation = sampleShadowMapFiltered9(scene_ShadowMap, shadowCoord, scene_ShadowMapSize);\n #endif\n\n float shadowFade = getShadowFade(v_pos);\n attenuation = mix(1.0, mix(attenuation, 1.0, shadowFade), scene_ShadowInfo.x);\n }\n return attenuation;\n }\n#endif",shadow_sample_tent:'#define GLSLIFY 1\n// ------------------------------------------------------------------\n// PCF Filtering Tent Functions\n// ------------------------------------------------------------------\n\n// Assuming a isoceles right angled triangle of height "triangleHeight" (as drawn below).\n// This function return the area of the triangle above the first texel(in Y the first texel).\n//\n// |\\ <-- 45 degree slop isosceles right angled triangle\n// | \\\n// ---- <-- length of this side is "triangleHeight"\n// _ _ _ _ <-- texels\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight) {\n return triangleHeight - 0.5;\n}\n\n// Assuming a isoceles triangle of 1.5 texels height and 3 texels wide lying on 4 texels.\n// This function return the area of the triangle above each of those texels.\n// | <-- offset from -0.5 to 0.5, 0 meaning triangle is exactly in the center\n// / \\ <-- 45 degree slop isosceles triangle (ie tent projected in 2D)\n// / \\\n// _ _ _ _ <-- texels\n// X Y Z W <-- result indices (in computedArea.xyzw and computedAreaUncut.xyzw)\n// Top point at (right,top) in a texel,left bottom point at (middle,middle) in a texel,right bottom point at (middle,middle) in a texel.\nvoid sampleShadowGetTexelAreasTent3x3(float offset, out vec4 computedArea, out vec4 computedAreaUncut) {\n // Compute the exterior areas,a and h is same.\n float a = offset + 0.5;\n float offsetSquaredHalved = a * a * 0.5;\n computedAreaUncut.x = computedArea.x = offsetSquaredHalved - offset;\n computedAreaUncut.w = computedArea.w = offsetSquaredHalved;\n\n // Compute the middle areas\n // For Y : We find the area in Y of as if the left section of the isoceles triangle would\n // intersect the axis between Y and Z (ie where offset = 0).\n computedAreaUncut.y = sampleShadowGetIRTriangleTexelArea(1.5 - offset);\n // This area is superior to the one we are looking for if (offset < 0) thus we need to\n // subtract the area of the triangle defined by (0,1.5-offset), (0,1.5+offset), (-offset,1.5).\n float clampedOffsetLeft = min(offset,0.0);\n float areaOfSmallLeftTriangle = clampedOffsetLeft * clampedOffsetLeft;\n computedArea.y = computedAreaUncut.y - areaOfSmallLeftTriangle;\n\n // We do the same for the Z but with the right part of the isoceles triangle\n computedAreaUncut.z = sampleShadowGetIRTriangleTexelArea(1.5 + offset);\n float clampedOffsetRight = max(offset,0.0);\n float areaOfSmallRightTriangle = clampedOffsetRight * clampedOffsetRight;\n computedArea.z = computedAreaUncut.z - areaOfSmallRightTriangle;\n}\n\n// Assuming a isoceles triangle of 2.5 texel height and 5 texels wide lying on 6 texels.\n// This function return the weight of each texels area relative to the full triangle area.\n// / \\\n// _ _ _ _ _ _ <-- texels\n// 0 1 2 3 4 5 <-- computed area indices (in texelsWeights[])\n// Top point at (right,top) in a texel,left bottom point at (middle,middle) in a texel,right bottom point at (middle,middle) in a texel.\nvoid sampleShadowGetTexelWeightsTent5x5(float offset, out vec3 texelsWeightsA, out vec3 texelsWeightsB) {\n vec4 areaFrom3texelTriangle;\n vec4 areaUncutFrom3texelTriangle;\n sampleShadowGetTexelAreasTent3x3(offset, areaFrom3texelTriangle, areaUncutFrom3texelTriangle);\n\n // Triangle slope is 45 degree thus we can almost reuse the result of the 3 texel wide computation.\n // the 5 texel wide triangle can be seen as the 3 texel wide one but shifted up by one unit/texel.\n // 0.16 is 1/(the triangle area)\n texelsWeightsA.x = 0.16 * (areaFrom3texelTriangle.x);\n texelsWeightsA.y = 0.16 * (areaUncutFrom3texelTriangle.y);\n texelsWeightsA.z = 0.16 * (areaFrom3texelTriangle.y + 1.0);\n texelsWeightsB.x = 0.16 * (areaFrom3texelTriangle.z + 1.0);\n texelsWeightsB.y = 0.16 * (areaUncutFrom3texelTriangle.z);\n texelsWeightsB.z = 0.16 * (areaFrom3texelTriangle.w);\n}\n\n// 5x5 Tent filter (45 degree sloped triangles in U and V)\nvoid sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize, vec2 coord, out float fetchesWeights[9], out vec2 fetchesUV[9])\n{\n // tent base is 5x5 base thus covering from 25 to 36 texels, thus we need 9 bilinear PCF fetches\n vec2 tentCenterInTexelSpace = coord.xy * shadowMapTextureTexelSize.zw;\n vec2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5);\n vec2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace;\n\n // find the weight of each texel based on the area of a 45 degree slop tent above each of them.\n vec3 texelsWeightsUA, texelsWeightsUB;\n vec3 texelsWeightsVA, texelsWeightsVB;\n sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsUA, texelsWeightsUB);\n sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsVA, texelsWeightsVB);\n\n // each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels\n vec3 fetchesWeightsU = vec3(texelsWeightsUA.xz, texelsWeightsUB.y) + vec3(texelsWeightsUA.y, texelsWeightsUB.xz);\n vec3 fetchesWeightsV = vec3(texelsWeightsVA.xz, texelsWeightsVB.y) + vec3(texelsWeightsVA.y, texelsWeightsVB.xz);\n\n // move the PCF bilinear fetches to respect texels weights\n vec3 fetchesOffsetsU = vec3(texelsWeightsUA.y, texelsWeightsUB.xz) / fetchesWeightsU.xyz + vec3(-2.5,-0.5,1.5);\n vec3 fetchesOffsetsV = vec3(texelsWeightsVA.y, texelsWeightsVB.xz) / fetchesWeightsV.xyz + vec3(-2.5,-0.5,1.5);\n fetchesOffsetsU *= shadowMapTextureTexelSize.xxx;\n fetchesOffsetsV *= shadowMapTextureTexelSize.yyy;\n\n vec2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * shadowMapTextureTexelSize.xy;\n fetchesUV[0] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.x);\n fetchesUV[1] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.x);\n fetchesUV[2] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.x);\n fetchesUV[3] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.y);\n fetchesUV[4] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.y);\n fetchesUV[5] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.y);\n fetchesUV[6] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.z);\n fetchesUV[7] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.z);\n fetchesUV[8] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.z);\n\n fetchesWeights[0] = fetchesWeightsU.x * fetchesWeightsV.x;\n fetchesWeights[1] = fetchesWeightsU.y * fetchesWeightsV.x;\n fetchesWeights[2] = fetchesWeightsU.z * fetchesWeightsV.x;\n fetchesWeights[3] = fetchesWeightsU.x * fetchesWeightsV.y;\n fetchesWeights[4] = fetchesWeightsU.y * fetchesWeightsV.y;\n fetchesWeights[5] = fetchesWeightsU.z * fetchesWeightsV.y;\n fetchesWeights[6] = fetchesWeightsU.x * fetchesWeightsV.z;\n fetchesWeights[7] = fetchesWeightsU.y * fetchesWeightsV.z;\n fetchesWeights[8] = fetchesWeightsU.z * fetchesWeightsV.z;\n}',ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n #define SCENE_IS_CALCULATE_SHADOWS\n#endif\n\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n #if SCENE_SHADOW_CASCADED_COUNT==1\n #include <ShadowCoord>\n varying vec3 v_shadowCoord;\n #endif\n#endif",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n v_shadowCoord = getShadowCoord();\n #endif\n#endif"},{pbr_frag_define:"#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n\nuniform float material_AlphaCutoff;\nuniform vec4 material_BaseColor;\nuniform float material_Metal;\nuniform float material_Roughness;\nuniform float material_IOR;\nuniform vec3 material_PBRSpecularColor;\nuniform float material_Glossiness;\nuniform vec3 material_EmissiveColor;\nuniform float material_NormalIntensity;\nuniform float material_OcclusionIntensity;\nuniform float material_OcclusionTextureCoord;\n\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n uniform float material_ClearCoat;\n uniform float material_ClearCoatRoughness;\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n uniform sampler2D material_ClearCoatTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n uniform sampler2D material_ClearCoatRoughnessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n uniform sampler2D material_ClearCoatNormalTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n uniform vec3 material_AnisotropyInfo;\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n uniform sampler2D material_AnisotropyTexture;\n #endif\n#endif\n\n// Texture\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\n#ifdef MATERIAL_HAS_NORMALTEXTURE\n uniform sampler2D material_NormalTexture;\n#endif\n\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n uniform sampler2D material_RoughnessMetallicTexture;\n#endif\n\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n uniform sampler2D material_SpecularGlossinessTexture;\n#endif\n\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n uniform sampler2D material_OcclusionTexture;\n#endif\n\n// Runtime\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n\nstruct Geometry {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n float dotNV;\n \n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatNormal;\n float clearCoatDotNV;\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 anisotropicT;\n vec3 anisotropicB;\n vec3 anisotropicN;\n float anisotropy;\n #endif\n};\n\nstruct Material {\n vec3 diffuseColor;\n float roughness;\n vec3 specularColor;\n float opacity;\n float f0;\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoat;\n float clearCoatRoughness;\n #endif\n\n};",pbr_helper:'#define GLSLIFY 1\n#include <normal_get>\n\nfloat computeSpecularOcclusion(float ambientOcclusion, float roughness, float dotNV ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n\nfloat getAARoughnessFactor(vec3 normal) {\n // Kaplanyan 2016, "Stable specular highlights"\n // Tokuyoshi 2017, "Error Reduction and Simplification for Shading Anti-Aliasing"\n // Tokuyoshi and Kaplanyan 2019, "Improved Geometric Specular Antialiasing"\n #ifdef HAS_DERIVATIVES\n vec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );\n return max( max(dxy.x, dxy.y), dxy.z );\n #else\n return 0.0;\n #endif\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // Aniso Bent Normals\n // Mc Alley https://www.gdcvault.com/play/1022235/Rendering-the-World-of-Far \n vec3 getAnisotropicBentNormal(Geometry geometry, vec3 n, float roughness) {\n vec3 anisotropyDirection = geometry.anisotropy >= 0.0 ? geometry.anisotropicB : geometry.anisotropicT;\n vec3 anisotropicTangent = cross(anisotropyDirection, geometry.viewDir);\n vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);\n // reduce stretching for (roughness < 0.2), refer to https://advances.realtimerendering.com/s2018/Siggraph%202018%20HDRP%20talk_with%20notes.pdf 80\n vec3 bentNormal = normalize( mix(n, anisotropicNormal, abs(geometry.anisotropy) * saturate( 5.0 * roughness)) );\n\n return bentNormal;\n }\n#endif\n\nvoid initGeometry(out Geometry geometry, bool isFrontFacing){\n geometry.position = v_pos;\n #ifdef CAMERA_ORTHOGRAPHIC\n geometry.viewDir = -camera_Forward;\n #else\n geometry.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)\n mat3 tbn = getTBN(isFrontFacing);\n #endif\n\n #ifdef MATERIAL_HAS_NORMALTEXTURE\n geometry.normal = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.normal = getNormal(isFrontFacing);\n #endif\n\n geometry.dotNV = saturate( dot(geometry.normal, geometry.viewDir) );\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n geometry.clearCoatNormal = getNormalByNormalTexture(tbn, material_ClearCoatNormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.clearCoatNormal = getNormal(isFrontFacing);\n #endif\n geometry.clearCoatDotNV = saturate( dot(geometry.clearCoatNormal, geometry.viewDir) );\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n float anisotropy = material_AnisotropyInfo.z;\n vec3 anisotropicDirection = vec3(material_AnisotropyInfo.xy, 0.0);\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n vec3 anisotropyTextureInfo = texture2D( material_AnisotropyTexture, v_uv ).rgb;\n anisotropy *= anisotropyTextureInfo.b;\n anisotropicDirection.xy *= anisotropyTextureInfo.rg * 2.0 - 1.0;\n #endif\n\n geometry.anisotropy = anisotropy;\n geometry.anisotropicT = normalize(tbn * anisotropicDirection);\n geometry.anisotropicB = normalize(cross(geometry.normal, geometry.anisotropicT));\n #endif\n}\n\nvoid initMaterial(out Material material, inout Geometry geometry){\n vec4 baseColor = material_BaseColor;\n float metal = material_Metal;\n float roughness = material_Roughness;\n vec3 specularColor = material_PBRSpecularColor;\n float glossiness = material_Glossiness;\n float alphaCutoff = material_AlphaCutoff;\n float f0 = pow2( (material_IOR - 1.0) / (material_IOR + 1.0) );\n\n material.f0 = f0;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec4 baseTextureColor = texture2D(material_BaseTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n baseTextureColor = gammaToLinear(baseTextureColor);\n #endif\n baseColor *= baseTextureColor;\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n baseColor *= v_color;\n #endif\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( baseColor.a < alphaCutoff ) {\n discard;\n }\n #endif\n\n #ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n vec4 metalRoughMapColor = texture2D( material_RoughnessMetallicTexture, v_uv );\n roughness *= metalRoughMapColor.g;\n metal *= metalRoughMapColor.b;\n #endif\n\n #ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n vec4 specularGlossinessColor = texture2D(material_SpecularGlossinessTexture, v_uv );\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n specularGlossinessColor = gammaToLinear(specularGlossinessColor);\n #endif\n specularColor *= specularGlossinessColor.rgb;\n glossiness *= specularGlossinessColor.a;\n #endif\n\n #ifdef IS_METALLIC_WORKFLOW\n material.diffuseColor = baseColor.rgb * ( 1.0 - metal );\n material.specularColor = mix( vec3(f0), baseColor.rgb, metal );\n material.roughness = roughness;\n #else\n float specularStrength = max( max( specularColor.r, specularColor.g ), specularColor.b );\n material.diffuseColor = baseColor.rgb * ( 1.0 - specularStrength );\n material.specularColor = specularColor;\n material.roughness = 1.0 - glossiness;\n #endif\n\n material.roughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.roughness + getAARoughnessFactor(geometry.normal), 1.0));\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n material.clearCoat = material_ClearCoat;\n material.clearCoatRoughness = material_ClearCoatRoughness;\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n material.clearCoat *= texture2D( material_ClearCoatTexture, v_uv ).r;\n #endif\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n material.clearCoatRoughness *= texture2D( material_ClearCoatRoughnessTexture, v_uv ).g;\n #endif\n material.clearCoat = saturate( material.clearCoat );\n material.clearCoatRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.clearCoatRoughness + getAARoughnessFactor(geometry.clearCoatNormal), 1.0));\n #endif\n\n #ifdef MATERIAL_IS_TRANSPARENT\n material.opacity = baseColor.a;\n #else\n material.opacity = 1.0;\n #endif\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n geometry.anisotropicN = getAnisotropicBentNormal(geometry, geometry.normal, material.roughness);\n #endif\n\n}\n\n// direct + indirect\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) {\n return f0 + 0.96 * (pow(1.0 - dotLH, 5.0));\n}\n\nvec3 F_Schlick(vec3 specularColor, float dotLH ) {\n\n // Original approximation by Christophe Schlick \'94\n // float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n // Optimized variant (presented by Epic at SIGGRAPH \'13)\n // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n return ( 1.0 - specularColor ) * fresnel + specularColor;\n\n}\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated(float alpha, float dotNL, float dotNV ) {\n\n float a2 = pow2( alpha );\n\n // dotNL and dotNV are explicitly swapped. This is not a mistake.\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n return 0.5 / max( gv + gl, EPSILON );\n\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"\n // Heitz http://jcgt.org/published/0003/02/03/paper.pdf\n float G_GGX_SmithCorrelated_Anisotropic(float at, float ab, float ToV, float BoV, float ToL, float BoL, float NoV, float NoL) {\n float lambdaV = NoL * length(vec3(at * ToV, ab * BoV, NoV));\n float lambdaL = NoV * length(vec3(at * ToL, ab * BoL, NoL));\n return 0.5 / max(lambdaV + lambdaL, EPSILON);\n }\n#endif\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney’s reparameterization\nfloat D_GGX(float alpha, float dotNH ) {\n\n float a2 = pow2( alpha );\n\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n return RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // GGX Distribution Anisotropic\n // https://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf Addenda\n float D_GGX_Anisotropic(float at, float ab, float ToH, float BoH, float NoH) {\n float a2 = at * ab;\n vec3 d = vec3(ab * ToH, at * BoH, a2 * NoH);\n float d2 = dot(d, d);\n float b2 = a2 / d2;\n return a2 * b2 * b2 * RECIPROCAL_PI;\n }\n#endif\n\nvec3 isotropicLobe(vec3 specularColor, float alpha, float dotNV, float dotNL, float dotNH, float dotLH) {\n vec3 F = F_Schlick( specularColor, dotLH );\n float D = D_GGX( alpha, dotNH );\n float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n return F * ( G * D );\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 anisotropicLobe(vec3 h, vec3 l, Geometry geometry, vec3 specularColor, float alpha, float dotNV, float dotNL, float dotNH, float dotLH) {\n vec3 t = geometry.anisotropicT;\n vec3 b = geometry.anisotropicB;\n vec3 v = geometry.viewDir;\n\n float dotTV = dot(t, v);\n float dotBV = dot(b, v);\n float dotTL = dot(t, l);\n float dotBL = dot(b, l);\n float dotTH = dot(t, h);\n float dotBH = dot(b, h);\n\n // Aniso parameter remapping\n // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf page 24\n float at = max(alpha * (1.0 + geometry.anisotropy), MIN_ROUGHNESS);\n float ab = max(alpha * (1.0 - geometry.anisotropy), MIN_ROUGHNESS);\n\n // specular anisotropic BRDF\n vec3 F = F_Schlick( specularColor, dotLH );\n float D = D_GGX_Anisotropic(at, ab, dotTH, dotBH, dotNH);\n float G = G_GGX_SmithCorrelated_Anisotropic(at, ab, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL);\n\n return F * ( G * D );\n }\n#endif\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX(vec3 incidentDirection, Geometry geometry, vec3 normal, vec3 specularColor, float roughness ) {\n\n float alpha = pow2( roughness ); // UE4\'s roughness\n\n vec3 halfDir = normalize( incidentDirection + geometry.viewDir );\n\n float dotNL = saturate( dot( normal, incidentDirection ) );\n float dotNV = saturate( dot( normal, geometry.viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotLH = saturate( dot( incidentDirection, halfDir ) );\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n return anisotropicLobe(halfDir, incidentDirection, geometry, specularColor, alpha, dotNV, dotNL, dotNH, dotLH);\n #else\n return isotropicLobe(specularColor, alpha, dotNV, dotNL, dotNH, dotLH);\n #endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\n',direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\n\nvoid addDirectRadiance(vec3 incidentDirection, vec3 color, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n float attenuation = 1.0;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoatDotNL = saturate( dot( geometry.clearCoatNormal, incidentDirection ) );\n vec3 clearCoatIrradiance = clearCoatDotNL * color;\n\n reflectedLight.directSpecular += material.clearCoat * clearCoatIrradiance * BRDF_Specular_GGX( incidentDirection, geometry, geometry.clearCoatNormal, vec3( 0.04 ), material.clearCoatRoughness );\n attenuation -= material.clearCoat * F_Schlick(material.f0, geometry.clearCoatDotNV);\n #endif\n\n float dotNL = saturate( dot( geometry.normal, incidentDirection ) );\n vec3 irradiance = dotNL * color * PI;\n\n reflectedLight.directSpecular += attenuation * irradiance * BRDF_Specular_GGX( incidentDirection, geometry, geometry.normal, material.specularColor, material.roughness);\n reflectedLight.directDiffuse += attenuation * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#ifdef SCENE_DIRECT_LIGHT_COUNT\n\n void addDirectionalDirectLightRadiance(DirectLight directionalLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n vec3 color = directionalLight.color;\n vec3 direction = -directionalLight.direction;\n\n addDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n }\n\n#endif\n\n#ifdef SCENE_POINT_LIGHT_COUNT\n\n void addPointDirectLightRadiance(PointLight pointLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n vec3 lVector = pointLight.position - geometry.position;\n vec3 direction = normalize( lVector );\n\n float lightDistance = length( lVector );\n\n vec3 color = pointLight.color;\n color *= clamp(1.0 - pow(lightDistance/pointLight.distance, 4.0), 0.0, 1.0);\n\n addDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n }\n\n#endif\n\n#ifdef SCENE_SPOT_LIGHT_COUNT\n\n void addSpotDirectLightRadiance(SpotLight spotLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n vec3 lVector = spotLight.position - geometry.position;\n vec3 direction = normalize( lVector );\n\n float lightDistance = length( lVector );\n float angleCos = dot( direction, -spotLight.direction );\n\n float spotEffect = smoothstep( spotLight.penumbraCos, spotLight.angleCos, angleCos );\n float decayEffect = clamp(1.0 - pow(lightDistance/spotLight.distance, 4.0), 0.0, 1.0);\n\n vec3 color = spotLight.color;\n color *= spotEffect * decayEffect;\n\n addDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n }\n\n#endif\n\nvoid addTotalDirectRadiance(Geometry geometry, Material material, inout ReflectedLight reflectedLight){\n float shadowAttenuation = 1.0;\n\n #ifdef SCENE_DIRECT_LIGHT_COUNT\n shadowAttenuation = 1.0;\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n shadowAttenuation *= sampleShadowMap();\n #endif\n\n DirectLight directionalLight;\n for ( int i = 0; i < SCENE_DIRECT_LIGHT_COUNT; i ++ ) {\n // warning: use `continue` syntax may trigger flickering bug in safri 16.1.\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_DirectLightCullingMask[i])){\n directionalLight.color = scene_DirectLightColor[i];\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n if (i == 0) { // Sun light index is always 0\n directionalLight.color *= shadowAttenuation;\n }\n #endif\n directionalLight.direction = scene_DirectLightDirection[i];\n addDirectionalDirectLightRadiance( directionalLight, geometry, material, reflectedLight );\n }\n }\n\n #endif\n\n #ifdef SCENE_POINT_LIGHT_COUNT\n\n PointLight pointLight;\n\n for ( int i = 0; i < SCENE_POINT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_PointLightCullingMask[i])){\n pointLight.color = scene_PointLightColor[i];\n pointLight.position = scene_PointLightPosition[i];\n pointLight.distance = scene_PointLightDistance[i];\n\n addPointDirectLightRadiance( pointLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n\n #ifdef SCENE_SPOT_LIGHT_COUNT\n\n SpotLight spotLight;\n\n for ( int i = 0; i < SCENE_SPOT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_SpotLightCullingMask[i])){\n spotLight.color = scene_SpotLightColor[i];\n spotLight.position = scene_SpotLightPosition[i];\n spotLight.direction = scene_SpotLightDirection[i];\n spotLight.distance = scene_SpotLightDistance[i];\n spotLight.angleCos = scene_SpotLightAngleCos[i];\n spotLight.penumbraCos = scene_SpotLightPenumbraCos[i];\n\n addSpotDirectLightRadiance( spotLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n}",ibl_frag_define:"#define GLSLIFY 1\n// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n normal.x = -normal.x;\n vec3 result = sh[0] +\n\n sh[1] * (normal.y) +\n sh[2] * (normal.z) +\n sh[3] * (normal.x) +\n\n sh[4] * (normal.y * normal.x) +\n sh[5] * (normal.y * normal.z) +\n sh[6] * (3.0 * normal.z * normal.z - 1.0) +\n sh[7] * (normal.z * normal.x) +\n sh[8] * (normal.x * normal.x - normal.y * normal.y);\n \n return max(result, vec3(0.0));\n\n}\n\n// ------------------------Specular------------------------\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 envBRDFApprox(vec3 specularColor,float roughness, float dotNV ) {\n\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n vec4 r = roughness * c0 + c1;\n\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n return specularColor * AB.x + AB.y;\n}\n\nfloat getSpecularMIPLevel(float roughness, int maxMIPLevel ) {\n return roughness * float(maxMIPLevel);\n}\n\nvec3 getReflectedVector(Geometry geometry, vec3 n) {\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 r = reflect(-geometry.viewDir, geometry.anisotropicN);\n #else\n vec3 r = reflect(-geometry.viewDir, n);\n #endif\n\n return r;\n}\n\nvec3 getLightProbeRadiance(Geometry geometry, vec3 normal, float roughness, int maxMIPLevel, float specularIntensity) {\n\n #ifndef SCENE_USE_SPECULAR_ENV\n return vec3(0);\n #else\n vec3 reflectVec = getReflectedVector(geometry, normal);\n reflectVec.x = -reflectVec.x; // TextureCube is left-hand,so x need inverse\n \n float specularMIPLevel = getSpecularMIPLevel(roughness, maxMIPLevel );\n\n #ifdef HAS_TEX_LOD\n vec4 envMapColor = textureCubeLodEXT( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #endif\n\n #ifdef SCENE_IS_DECODE_ENV_RGBM\n envMapColor.rgb = RGBMToLinear(envMapColor, 5.0).rgb;\n #ifdef ENGINE_IS_COLORSPACE_GAMMA\n envMapColor = linearToGamma(envMapColor);\n #endif\n #else\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n envMapColor = gammaToLinear(envMapColor);\n #endif\n #endif\n \n return envMapColor.rgb * specularIntensity;\n\n #endif\n\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;\nMaterial material;\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\ninitGeometry(geometry, gl_FrontFacing);\ninitMaterial(material, geometry);\n\n// Direct Light\naddTotalDirectRadiance(geometry, material, reflectedLight);\n\n// IBL diffuse\n#ifdef SCENE_USE_SH\n vec3 irradiance = getLightProbeIrradiance(scene_EnvSH, geometry.normal);\n #ifdef ENGINE_IS_COLORSPACE_GAMMA\n irradiance = linearToGamma(vec4(irradiance, 1.0)).rgb;\n #endif\n irradiance *= scene_EnvMapLight.diffuseIntensity;\n#else\n vec3 irradiance = scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity;\n irradiance *= PI;\n#endif\n\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n// IBL specular\nvec3 radiance = getLightProbeRadiance(geometry, geometry.normal, material.roughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity);\nfloat radianceAttenuation = 1.0;\n\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatRadiance = getLightProbeRadiance( geometry, geometry.clearCoatNormal, material.clearCoatRoughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity );\n\n reflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * envBRDFApprox(vec3( 0.04 ), material.clearCoatRoughness, geometry.clearCoatDotNV);\n radianceAttenuation -= material.clearCoat * F_Schlick(material.f0, geometry.clearCoatDotNV);\n#endif\n\nreflectedLight.indirectSpecular += radianceAttenuation * radiance * envBRDFApprox(material.specularColor, material.roughness, geometry.dotNV );\n\n// Occlusion\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n vec2 aoUV = v_uv;\n #ifdef RENDERER_HAS_UV1\n if(material_OcclusionTextureCoord == 1.0){\n aoUV = v_uv1;\n }\n #endif\n float ambientOcclusion = (texture2D(material_OcclusionTexture, aoUV).r - 1.0) * material_OcclusionIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #ifdef SCENE_USE_SPECULAR_ENV\n reflectedLight.indirectSpecular *= computeSpecularOcclusion(ambientOcclusion, material.roughness, geometry.dotNV);\n #endif\n#endif\n\n// Emissive\nvec3 emissiveRadiance = material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n vec4 emissiveColor = texture2D(material_EmissiveTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n emissiveColor = gammaToLinear(emissiveColor);\n #endif\n emissiveRadiance *= emissiveColor.rgb;\n#endif\n\n// Total\nvec3 totalRadiance = reflectedLight.directDiffuse + \n reflectedLight.indirectDiffuse + \n reflectedLight.directSpecular + \n reflectedLight.indirectSpecular + \n emissiveRadiance;\n\nvec4 targetColor =vec4(totalRadiance, material.opacity);\ngl_FragColor = targetColor;\n"},{normal_get:"#define GLSLIFY 1\n// gl_FrontFacing has random value on Adreno GPUs\n// the Adreno bug is only when gl_FrontFacing is inside a function\n// https://bugs.chromium.org/p/chromium/issues/detail?id=1154842\nvec3 getNormal(bool isFrontFacing){\n #ifdef RENDERER_HAS_NORMAL\n vec3 normal = normalize(v_normal);\n #elif defined(HAS_DERIVATIVES)\n vec3 pos_dx = dFdx(v_pos);\n vec3 pos_dy = dFdy(v_pos);\n vec3 normal = normalize( cross(pos_dx, pos_dy) );\n normal *= camera_ProjectionParams.x;\n #else\n vec3 normal = vec3(0, 0, 1);\n #endif\n\n normal *= float( isFrontFacing ) * 2.0 - 1.0;\n return normal;\n}\n\nvec3 getNormalByNormalTexture(mat3 tbn, sampler2D normalTexture, float normalIntensity, vec2 uv, bool isFrontFacing){\n vec3 normal = texture2D(normalTexture, uv).rgb;\n normal = normalize(tbn * ((2.0 * normal - 1.0) * vec3(normalIntensity, normalIntensity, 1.0)));\n normal *= float( isFrontFacing ) * 2.0 - 1.0;\n\n return normal;\n}\n\nmat3 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) )\n mat3 tbn = v_TBN;\n #else\n vec3 normal = getNormal(isFrontFacing);\n vec3 position = v_pos;\n vec2 uv = isFrontFacing? v_uv: -v_uv;\n\n #ifdef HAS_DERIVATIVES\n // ref: http://www.thetenthplanet.de/archives/1180\n // get edge vectors of the pixel triangle\n vec3 dp1 = dFdx(position);\n vec3 dp2 = dFdy(position);\n vec2 duv1 = dFdx(uv);\n vec2 duv2 = dFdy(uv);\n\n // solve the linear system\n vec3 dp2perp = cross(dp2, normal);\n vec3 dp1perp = cross(normal, dp1);\n vec3 tangent = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 bitangent = dp2perp * duv1.y + dp1perp * duv2.y;\n\n // construct a scale-invariant frame \n float denom = max( dot(tangent, tangent), dot(bitangent, bitangent) );\n float invmax = (denom == 0.0) ? 0.0 : camera_ProjectionParams.x / sqrt( denom );\n mat3 tbn = mat3(tangent * invmax, bitangent * invmax, normal);\n #else\n mat3 tbn = mat3(vec3(0.0), vec3(0.0), normal);\n #endif\n #endif\n \n return tbn;\n}"},{particle_common:"#define GLSLIFY 1\n\nvec3 rotationByEuler(in vec3 vector, in vec3 rot) {\n float halfRoll = rot.z * 0.5;\n float halfPitch = rot.x * 0.5;\n float halfYaw = rot.y * 0.5;\n\n float sinRoll = sin(halfRoll);\n float cosRoll = cos(halfRoll);\n float sinPitch = sin(halfPitch);\n float cosPitch = cos(halfPitch);\n float sinYaw = sin(halfYaw);\n float cosYaw = cos(halfYaw);\n\n float quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n float quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n float quaZ = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);\n float quaW = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);\n\n // vec4 q=vec4(quaX,quaY,quaZ,quaW);\n // vec3 temp = cross(q.xyz, vector) + q.w * vector;\n // return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\n float x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n float xx = quaX * x;\n float xy = quaX * y;\n float xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n}\n\n//假定axis已经归一化\nvec3 rotationByAxis(in vec3 vector, in vec3 axis, in float angle) {\n float halfAngle = angle * 0.5;\n float sin = sin(halfAngle);\n\n float quaX = axis.x * sin;\n float quaY = axis.y * sin;\n float quaZ = axis.z * sin;\n float quaW = cos(halfAngle);\n\n // vec4 q=vec4(quaX,quaY,quaZ,quaW);\n // vec3 temp = cross(q.xyz, vector) + q.w * vector;\n // return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\n float x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n float xx = quaX * x;\n float xy = quaX * y;\n float xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n}\n\nvec3 rotationByQuaternions(in vec3 v, in vec4 q) {\n return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\nfloat evaluateParticleCurve(in vec2 keys[4], in float normalizedAge) {\n float value;\n for (int i = 1; i < 4; i++) {\n vec2 key = keys[i];\n float time = key.x;\n if (time >= normalizedAge) {\n vec2 lastKey = keys[i - 1];\n float lastTime = lastKey.x;\n float age = (normalizedAge - lastTime) / (time - lastTime);\n value = mix(lastKey.y, key.y, age);\n break;\n }\n }\n return value;\n}\n\nfloat evaluateParticleCurveCumulative(in vec2 keys[4], in float normalizedAge){\n float cumulativeValue = 0.0;\n for (int i = 1; i < 4; i++){\n vec2 key = keys[i];\n float time = key.x;\n vec2 lastKey = keys[i - 1];\n float lastValue = lastKey.y;\n\n if (time >= normalizedAge){\n float lastTime = lastKey.x;\n float offsetTime = normalizedAge - lastTime;\n float age = offsetTime / (time - lastTime);\n cumulativeValue += (lastValue + mix(lastValue, key.y, age)) * 0.5 * offsetTime;\n break;\n }\n else{\n cumulativeValue += (lastValue + key.y) * 0.5 * (time - lastKey.x);\n }\n }\n return cumulativeValue;\n}",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)\n uniform int renderer_VOLSpace;\n\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\n uniform vec3 renderer_VOLMaxConst;\n\n #ifdef RENDERER_VOL_RANDOM_CONSTANT\n uniform vec3 renderer_VOLMinConst;\n #endif\n #endif\n\n #if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\n uniform vec2 renderer_VOLMaxGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientZ[4]; // x:time y:value\n\n #ifdef RENDERER_VOL_RANDOM_CURVE\n uniform vec2 renderer_VOLMinGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientZ[4]; // x:time y:value\n #endif\n #endif\n#endif\n\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n vec3 computeParticleLifeVelocity(in float normalizedAge) {\n vec3 velocity;\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\n velocity = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_RANDOM_CONSTANT\n velocity = mix(renderer_VOLMinConst, velocity, vec3(a_Random1.y, a_Random1.z, a_Random1.w));\n #endif\n #endif\n \n #if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\n velocity = vec3(evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge), evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge), evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge));\n #endif\n \n #ifdef RENDERER_VOL_RANDOM_CURVE\n velocity = vec3(\n mix(velocity.x, evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge), a_Random1.y),\n mix(velocity.y, evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge), a_Random1.z),\n mix(velocity.z, evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge), a_Random1.w));\n #endif\n\n return velocity;\n }\n#endif\n\nvec3 getStartPosition(vec3 startVelocity, float age, vec3 dragData) {\n vec3 startPosition;\n float lastTime = min(startVelocity.x / dragData.x, age); // todo 0/0\n startPosition = lastTime * (startVelocity - 0.5 * dragData * lastTime);\n return startPosition;\n}\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, vec3 dragData) {\n vec3 startPosition = getStartPosition(startVelocity, age, dragData);\n 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)\n // @todo:just RENDERER_VOL_CONSTANT and RENDERER_VOL_RANDOM_CONSTANT need `lifeVelocity`\n lifePosition = lifeVelocity * age;\n #endif\n\n #if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\n lifePosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ, normalizedAge));\n\n #ifdef RENDERER_VOL_RANDOM_CURVE\n lifePosition = vec3(\n mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX, normalizedAge), lifePosition.x, a_Random1.y),\n mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY, normalizedAge), lifePosition.y, a_Random1.z),\n mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ, normalizedAge), lifePosition.z, a_Random1.w));\n #endif\n\n lifePosition *= vec3(a_ShapePositionStartLifeTime.w);\n #endif\n \n vec3 finalPosition;\n if (renderer_VOLSpace == 0) {\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + startPosition + lifePosition, worldRotation);\n } else {\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + startPosition, worldRotation) + lifePosition;\n }\n #else\n vec3 finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + startPosition, worldRotation);\n #endif\n\n if (renderer_SimulationSpace == 0) {\n finalPosition = finalPosition + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n finalPosition = finalPosition + a_SimulationWorldPosition;\n }\n\n finalPosition += 0.5 * gravityVelocity * age;\n\n return finalPosition;\n}\n",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\n uniform vec2 renderer_ROLMaxCurveZ[4];\n // #ifdef RENDERER_ROL_IS_SEPARATE\n // uniform vec2 renderer_ROLMaxCurveX[4];\n // uniform vec2 renderer_ROLMaxCurveY[4];\n // #endif\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec2 renderer_ROLMinCurveZ[4];\n // #ifdef RENDERER_ROL_IS_SEPARATE\n // uniform vec2 renderer_ROLMinCurveX[4];\n // uniform vec2 renderer_ROLMinCurveY[4];\n // #endif\n #endif\n #else\n uniform vec3 renderer_ROLMaxConst;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec3 renderer_ROLMinConst;\n #endif\n #endif\n#endif\n\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\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge), lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * a_ShapePositionStartLifeTime.w;\n #else\n float lifeRotation = renderer_ROLMaxConst.z;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(renderer_ROLMinConst.z, lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * age;\n #endif\n #endif\n return rotation;\n}\n\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,\n in float age,\n in float normalizedAge) {\n#ifdef ROTATION_OVER_LIFETIME\n #ifdef ROTATION_OVER_LIFETIME_CONSTANT\n float ageRot = u_ROLAngularVelocityConst * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_CURVE\n rotation += getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient, normalizedAge);\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\n float ageRot = mix(u_ROLAngularVelocityConst, u_ROLAngularVelocityConstMax, a_Random0.w) * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\n rotation += mix(\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient, normalizedAge),\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,\n normalizedAge),\n a_Random0.w);\n #endif\n#endif\n\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n #ifdef ROTATION_OVER_LIFETIME_CONSTANT\n vec3 ageRot = u_ROLAngularVelocityConstSeparate * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_CURVE\n rotation += vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,\n normalizedAge),\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,\n normalizedAge),\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,\n normalizedAge));\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\n vec3 ageRot = mix(u_ROLAngularVelocityConstSeparate,\n renderer_ROLMaxConst,\n a_Random0.w)\n * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\n rotation += vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,\n normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,\n normalizedAge),\n a_Random0.w),\n mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,\n normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,\n normalizedAge),\n a_Random0.w),\n mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,\n normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,\n normalizedAge),\n a_Random0.w));\n #endif\n#endif\n return rotation;\n}\n#endif\n",size_over_lifetime_module:"#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\n uniform vec2 renderer_SOLMaxCurveX[4]; // x:time y:value\n #ifdef RENDERER_SOL_IS_SEPARATE\n uniform vec2 renderer_SOLMaxCurveY[4]; // x:time y:value\n uniform vec2 renderer_SOLMaxCurveZ[4]; // x:time y:value\n #endif\n\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n uniform vec2 renderer_SOLMinCurveX[4]; // x:time y:value\n #ifdef RENDERER_SOL_IS_SEPARATE\n uniform vec2 renderer_SOLMinCurveY[4]; // x:time y:value\n uniform vec2 renderer_SOLMinCurveZ[4]; // x:time y:value\n #endif\n #endif\n#endif\n\nvec2 computeParticleSizeBillboard(in vec2 size, in float normalizedAge) {\n #ifdef RENDERER_SOL_CURVE_MODE\n float lifeSizeX = evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge);\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n lifeSizeX = mix(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge), lifeSizeX, a_Random0.z);\n #endif\n\n #ifdef RENDERER_SOL_IS_SEPARATE\n float lifeSizeY = evaluateParticleCurve(renderer_SOLMaxCurveY, normalizedAge);\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n lifeSizeY = mix(evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge), lifeSizeY, a_Random0.z);\n #endif\n size *= vec2(lifeSizeX, lifeSizeY);\n #else\n size *= lifeSizeX;\n #endif\n #endif\n return size;\n}\n\n#ifdef RENDERER_MODE_MESH\n vec3 computeParticleSizeMesh(in vec3 size, in float normalizedAge) {\n #ifdef RENDERER_SOL_CURVE\n size *= evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge);\n #endif\n #ifdef RENDERER_SOL_RANDOM_CURVES\n size *= mix(evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge),\n evaluateParticleCurve(u_SOLSizeGradientMax, normalizedAge),\n a_Random0.z);\n #endif\n #ifdef RENDERER_SOL_CURVE_SEPARATE\n size *= vec3(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge),\n evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge),\n evaluateParticleCurve(renderer_SOLMinCurveZ, normalizedAge));\n #endif\n #ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\n size *= vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge),\n a_Random0.z),\n mix(evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveY, normalizedAge),\n a_Random0.z),\n mix(evaluateParticleCurve(renderer_SOLMinCurveZ, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveZ, normalizedAge),\n a_Random0.z));\n #endif\n return size;\n }\n#endif",color_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n uniform vec4 renderer_COLMaxGradientColor[4]; // x:time y:r z:g w:b\n uniform vec2 renderer_COLMaxGradientAlpha[4]; // x:time y:alpha\n\n #ifdef RENDERER_COL_RANDOM_GRADIENTS\n uniform vec4 renderer_COLMinGradientColor[4]; // x:time y:r z:g w:b\n uniform vec2 renderer_COLMinGradientAlpha[4]; // x:time y:alpha\n #endif\n\n uniform vec4 renderer_COLGradientKeysMaxTime; // x: minColorKeysMaxTime, y: minAlphaKeysMaxTime, z: maxColorKeysMaxTime, w: maxAlphaKeysMaxTime\n#endif\n\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n vec4 evaluateParticleGradient(in vec4 colorKeys[4], in float colorKeysMaxTime, in vec2 alphaKeys[4], in float alphaKeysMaxTime, in float normalizedAge){\n vec4 value;\n float alphaAge = min(normalizedAge, alphaKeysMaxTime);\n for(int i = 0; i < 4; i++){\n vec2 key = alphaKeys[i];\n float time = key.x;\n if(alphaAge <= time){\n if(i == 0){\n value.a = alphaKeys[0].y;\n }\n else {\n vec2 lastKey = alphaKeys[i-1];\n float lastTime = lastKey.x;\n float age = (alphaAge - lastTime) / (time - lastTime);\n value.a = mix(lastKey.y, key.y, age);\n }\n break;\n }\n }\n \n float colorAge = min(normalizedAge, colorKeysMaxTime);\n for(int i = 0; i < 4; i++){\n vec4 key = colorKeys[i];\n float time = key.x;\n if(colorAge <= time){\n if(i == 0){\n value.rgb = colorKeys[0].yzw;\n }\n else {\n vec4 lastKey = colorKeys[i-1];\n float lastTime = lastKey.x;\n float age = (colorAge - lastTime) / (time-lastTime);\n value.rgb = mix(lastKey.yzw, key.yzw, age);\n }\n break;\n }\n }\n return value;\n }\n#endif\n\nvec4 computeParticleColor(in vec4 color, in float normalizedAge) {\n #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n vec4 gradientColor = evaluateParticleGradient(renderer_COLMaxGradientColor, renderer_COLGradientKeysMaxTime.z, renderer_COLMaxGradientAlpha, renderer_COLGradientKeysMaxTime.w, normalizedAge);\n #endif\n\n #ifdef RENDERER_COL_RANDOM_GRADIENTS\n gradientColor = mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x, renderer_COLMinGradientAlpha, renderer_COLGradientKeysMaxTime.y, normalizedAge), gradientColor, a_Random0.y);\n #endif\n\n #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n color *= gradientColor;\n #endif\n\n return color;\n}\n",texture_sheet_animation_module:"#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n uniform float renderer_TSACycles;\n uniform vec3 renderer_TSATillingParams; // x:subU y:subV z:tileCount\n uniform vec2 renderer_TSAFrameMaxCurve[4]; // x:time y:value\n\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n uniform vec2 renderer_TSAFrameMinCurve[4]; // x:time y:value\n #endif\n#endif\n\nvec2 computeParticleUV(in vec2 uv, in float normalizedAge) {\n #if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n float scaledNormalizedAge = normalizedAge * renderer_TSACycles;\n float cycleNormalizedAge = scaledNormalizedAge - floor(scaledNormalizedAge);\n float normalizedFrame = evaluateParticleCurve(renderer_TSAFrameMaxCurve, cycleNormalizedAge);\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n normalizedFrame = mix(evaluateParticleCurve(renderer_TSAFrameMinCurve, cycleNormalizedAge), normalizedFrame, a_Random1.x);\n #endif\n\n float frame = floor(normalizedFrame * renderer_TSATillingParams.z);\n\n float tileRow = frame * renderer_TSATillingParams.x;\n float tileRowIndex = floor(tileRow);\n uv.x += tileRow - tileRowIndex;\n uv.y += tileRowIndex * renderer_TSATillingParams.y;\n #endif\n \n return uv;\n}\n",sphere_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\n vec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n vec3 sideVector = normalize(cross(camera_Forward, camera_Up));\n vec3 upVector = normalize(cross(sideVector, camera_Forward));\n corner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n if (renderer_ThreeDStartRotation) {\n vec3 rotation = vec3(a_StartRotation0.xy, computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge));\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, rotation);\n } else {\n float rot = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, a_StartRotation0);\n } else {\n float c = cos(a_StartRotation0.x);\n float s = sin(a_StartRotation0.x);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #endif\n#endif",stretched_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n vec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n vec3 velocity;\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n if (renderer_VOLSpace == 0){\n velocity = rotationByQuaternions(renderer_SizeScale * (startVelocity + lifeVelocity),\n worldRotation)\n + gravityVelocity;\n }\n else{\n velocity = rotationByQuaternions(renderer_SizeScale * startVelocity, worldRotation) + lifeVelocity + gravityVelocity;\n }\n #else\n velocity = rotationByQuaternions(renderer_SizeScale * startVelocity, worldRotation) + gravityVelocity;\n #endif\n vec3 cameraUpVector = normalize(velocity);\n vec3 direction = normalize(center - camera_Position);\n vec3 sideVector = normalize(cross(direction, normalize(velocity)));\n\n sideVector = renderer_SizeScale.xzy * sideVector;\n cameraUpVector = length(vec3(renderer_SizeScale.x, 0.0, 0.0)) * cameraUpVector;\n\n vec2 size = computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n\n const mat2 rotationZHalfPI = mat2(0.0, -1.0, 1.0, 0.0);\n corner = rotationZHalfPI * corner;\n corner.y = corner.y - abs(corner.y);\n\n float speed = length(velocity); // TODO:\n center += sign(renderer_SizeScale.x) * (sign(renderer_StretchedBillboardLengthScale) * size.x * corner.x * sideVector\n + (speed * renderer_StretchedBillboardSpeedScale + size.y * renderer_StretchedBillboardLengthScale) * corner.y * cameraUpVector);\n#endif",vertical_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\n vec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy; // Billboard模式z轴无效\n const vec3 cameraUpVector = vec3(0.0, 1.0, 0.0);\n vec3 sideVector = normalize(cross(camera_Forward, cameraUpVector));\n\n float rot = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner * cos(0.78539816339744830961566084581988); // TODO:临时缩小cos45,不确定U3D原因\n corner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * cameraUpVector);\n#endif",horizontal_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD\n vec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy; // Billboard模式z轴无效\n const vec3 cameraUpVector = vec3(0.0, 0.0, 1.0);\n const vec3 sideVector = vec3(-1.0, 0.0, 0.0);\n\n float rot = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner * cos(0.78539816339744830961566084581988); // TODO:临时缩小cos45,不确定U3D原因\n corner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * cameraUpVector);\n#endif",particle_mesh:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_MESH\n vec3 size = computeParticleSizeMesh(a_StartSize, normalizedAge);\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n if (renderer_ThreeDStartRotation) {\n vec3 rotation = vec3(\n a_StartRotation0.xy,\n computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge));\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByEuler(a_MeshPosition * size, rotation),\n worldRotation);\n } else {\n #ifdef RENDERER_ROL_IS_SEPARATE\n float angle = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n if (a_ShapePositionStartLifeTime.x != 0.0 || a_ShapePositionStartLifeTime.y != 0.0) {\n center += (rotationByQuaternions(\n rotationByAxis(\n renderer_SizeScale * a_MeshPosition * size,\n normalize(cross(vec3(0.0, 0.0, 1.0),\n vec3(a_ShapePositionStartLifeTime.xy, 0.0))),\n angle),\n worldRotation)); //已验证\n } else {\n #ifdef SHAPE\n center += renderer_SizeScale.xzy * (rotationByQuaternions(rotationByAxis(a_MeshPosition * size, vec3(0.0, -1.0, 0.0), angle), worldRotation));\n #else\n if (renderer_SimulationSpace == 1)\n center += rotationByAxis(renderer_SizeScale * a_MeshPosition * size,\n vec3(0.0, 0.0, -1.0),\n angle); //已验证\n else if (renderer_SimulationSpace == 0)\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, 0.0, -1.0), angle),\n worldRotation); //已验证\n #endif\n }\n #endif\n #ifdef ROTATION_OVER_LIFETIME_SEPARATE\n // TODO:是否应合并if(renderer_ThreeDStartRotation)分支代码,待测试\n vec3 angle = computeParticleRotationVec3(\n vec3(0.0, 0.0, -a_StartRotation0.x), age, normalizedAge);\n center += (rotationByQuaternions(\n rotationByEuler(renderer_SizeScale * a_MeshPosition * size,\n vec3(angle.x, angle.y, angle.z)),\n worldRotation)); //已验证\n #endif\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByEuler(a_MeshPosition * size, a_StartRotation0),\n worldRotation); //已验证\n } else {\n if (a_ShapePositionStartLifeTime.x != 0.0 || a_ShapePositionStartLifeTime.y != 0.0) {\n if (renderer_SimulationSpace == 1)\n center += rotationByAxis(\n renderer_SizeScale * a_MeshPosition * size,\n normalize(cross(vec3(0.0, 0.0, 1.0),\n vec3(a_ShapePositionStartLifeTime.xy, 0.0))),\n a_StartRotation0.x);\n else if (renderer_SimulationSpace == 0)\n center += (rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, normalize(cross(vec3(0.0, 0.0, 1.0),\n vec3(a_ShapePositionStartLifeTime.xy, 0.0))), a_StartRotation0.x),\n worldRotation)); //已验证\n } else {\n #ifdef SHAPE\n if (renderer_SimulationSpace == 1)\n center += renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, -1.0, 0.0), a_StartRotation0.x);\n else if (renderer_SimulationSpace == 0)\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, -1.0, 0.0), a_StartRotation0.x),\n worldRotation);\n #else\n if (renderer_SimulationSpace == 1)\n center += rotationByAxis(renderer_SizeScale * a_MeshPosition * size,\n vec3(0.0, 0.0, -1.0),\n a_StartRotation0.x);\n else if (renderer_SimulationSpace == 0)\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, 0.0, -1.0), a_StartRotation0.x),\n worldRotation); //已验证\n #endif\n }\n }\n #endif\n v_MeshColor = a_MeshColor;\n#endif"}),n1=/*#__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(n0[e])throw'The "'+e+'" shader include already exist';n0[e]=t},e.unRegisterInclude=function(e){delete n0[e]},e.parseIncludes=function(t,n){return void 0===n&&(n=/^[ \t]*#include +<([\w\d.]+)>/gm),t.replace(n,function(t,r){var i=n0[r];return void 0===i?(nl.error('Shader slice "'+t.trim()+'" not founded.'),""):e.parseIncludes(i,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,i=0;i<t.length;i++){var a=t[i].match(/\bgl_FragData\[(.+?)\]/);r.add(a[1])}return r.forEach(function(e){n+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),n+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,n)},e}();n1._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(""),n1._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var n2=/*#__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}();n2._nameCounter=0,n2._nameMap=Object.create(null);var n3=/*#__PURE__*/function(){function e(){this._tagsMap=Object.create(null)}var t=e.prototype;return t.setTag=function(e,t){var n="string"==typeof e?n2.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&nl.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?n2.getByName(e):e)._uniqueId]},t.getTagValue=function(e){return this._tagsMap["string"==typeof e?n2.getByName(e)._uniqueId:e._uniqueId]},tW(e,[{key:"name",get:function(){return this._name}}]),e}(),n4=((I={})[I.Linear=0]="Linear",I[I.Gamma=1]="Gamma",I),n8=/*#__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===n4.Linear?this._gl.uniform2f(e.location,tV.gammaToLinearSpace(t.r),tV.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===n4.Linear?this._gl.uniform3f(e.location,tV.gammaToLinearSpace(t.r),tV.gammaToLinearSpace(t.g),tV.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===n4.Linear?this._gl.uniform4f(e.location,tV.gammaToLinearSpace(t.r),tV.gammaToLinearSpace(t.g),tV.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,i=0;i<t.length;i++){var a=t[i];n.activeTexture(r[i]),n.bindTexture(a._platformTexture),a._setUseDepthCompareMode(e.textureUseCompareMode)}},e}(),n5=function(){this.constUniforms=[],this.textureUniforms=[]},n9=((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),n6=/*#__PURE__*/function(){function e(t,n,r){this.sceneUniformBlock=new n5,this.cameraUniformBlock=new n5,this.rendererUniformBlock=new n5,this.materialUniformBlock=new n5,this.renderElementUniformBlock=new n5,this.otherUniformBlock=new n5,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,i=0,a=r.length;i<a;i++){var o=r[i],s=n[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var n=t._propertyValueMap,r=e.textureUniforms;if(r)for(var i=0,a=r.length;i<a;i++){var o=r[i],s=n[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,n=e.length;t<n;t++){var r=e[t];r.applyFunc(r,r.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,n=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),n.length>0&&this._groupingSubOtherUniforms(n,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n],i=nQ._getShaderPropertyGroup(r.name);void 0!==i&&(e.splice(e.indexOf(r),1),this._groupingUniform(r,i,t))}},t._groupingUniform=function(e,t,n){switch(t){case n9.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case n9.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case n9.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case n9.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case n9.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 i=this._createShader(n.FRAGMENT_SHADER,t);if(!i)return null;var a=n.createProgram();return a?(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),n.validateProgram(a),n.deleteShader(r),n.deleteShader(i),!nl.isEnabled||n.getProgramParameter(a,n.LINK_STATUS)||n.isContextLost())?a:(nl.error("Could not link WebGL program\n\nShader error: "+n.getError()+"\n\nValidate status: "+n.getProgramParameter(a,n.VALIDATE_STATUS)+"\n\nProgram information log: "+n.getProgramInfoLog(a)),n.deleteProgram(a),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,n){var r=this._gl,i=r.createShader(t);return i?(r.shaderSource(i,n),r.compileShader(i),!nl.isEnabled||r.getShaderParameter(i,r.COMPILE_STATUS)||r.isContextLost())?i:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==r.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+r.getShaderInfoLog(i)+"\nShader source:\n"+e._addLineNum(n)),r.deleteShader(i),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,n=this._glProgram,r=this._getUniformInfos(),i=this._getAttributeInfos(),a=this._engine._basicResources;r.forEach(function(r){var i,o=r.name,s=r.size,l=r.type,c=new n8(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=nQ.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 tO(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new tR(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new tN(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 tO(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new tR(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new tN(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:i=a.whiteTexture2D;break;case t.SAMPLER_CUBE:i=a.whiteTextureCube;break;case t.UNSIGNED_INT_SAMPLER_2D:i=a.uintWhiteTexture2D;break;case t.SAMPLER_2D_ARRAY:i=a.whiteTexture2DArray;break;case t.SAMPLER_2D_SHADOW:i=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]=i,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=i,c.textureIndex=g,c.applyFunc=c.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var v=nQ._getShaderPropertyGroup(o);e._groupingUniform(c,v,d)}),i.forEach(function(r){var i=r.name;e.attributeLocation[i]=t.getAttribLocation(n,i)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=Array(n),i=0;i<n;++i){var a=e.getActiveUniform(t,i);r[i]=a}return r},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,n=[],r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),i=0;i<r;++i){var a=e.getActiveAttrib(t,i);n[i]=a}return n},e._addLineNum=function(e){var t,n=e.split("\n"),r=(n.length+1).toString().length+6;return n.map(function(e,n){if((t="0:"+(n+1)).length>=r)return t.substring(0,r)+e;for(var i=0;i<r-t.length;i++)t+=" ";return t+e}).join("\n")},tW(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();n6._counter=0;var n7=((N={})[N.Canonical=0]="Canonical",N[N.ShaderLab=1]="ShaderLab",N),re=/*#__PURE__*/function(e){function t(n,r,i,a,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=n7.Canonical,"string"==typeof a?(s._name=n,s._shaderLabSource=r,s._vertexEntry=i,s._fragmentEntry=a,o=nK({pipelineStage:nq.Forward},o),s._type=n7.ShaderLab):"string"==typeof i?(s._name=n,s._vertexSource=r,s._fragmentSource=i,o=null!=a?a:{pipelineStage:nq.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=r,o=null!=i?i:{pipelineStage:nq.Forward}),o)s.setTag(l,o[l]);return s}tX(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===n7.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,i){var a=this._path,o=this._platformMacros,s=e._hardwareRenderer.isWebGL2,l=[];nj._getMacrosElements(n,l),o.length=0,e._hardwareRenderer.canIUse(n$.shaderTextureLod)&&o.push("HAS_TEX_LOD"),e._hardwareRenderer.canIUse(n$.standardDerivatives)&&o.push("HAS_DERIVATIVES"),s?o.push("GRAPHICS_API_WEBGL2"):o.push("GRAPHICS_API_WEBGL1");var c=performance.now(),u=rl._shaderLab._parseShaderPass(this._shaderLabSource,r,i,l,s?nG.GLES300:nG.GLES100,o,new URL(a,t._shaderRootPath).href);return(nl.info("[ShaderLab compilation] cost time: "+(performance.now()-c)+"ms"),u)?new n6(e,u.vertex,u.fragment):new n6(e,"","")},n._getCanonicalShaderProgram=function(e,t){var n=e._hardwareRenderer.isWebGL2,r=[];nj._getMacrosElements(t,r);var i=n1.parseCustomMacros(r),a=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(n$.shaderTextureLod)&&(s+="#define HAS_TEX_LOD\n"),e._hardwareRenderer.canIUse(n$.standardDerivatives)&&(s+="#define HAS_DERIVATIVES\n");var l=" "+a+"\n "+o+"\n "+i+"\n "+n1.parseIncludes(this._vertexSource),c=" "+a+"\n "+o+"\n "+(n?"":n1._shaderExtension)+"\n "+s+"\n "+i+"\n "+n1.parseIncludes(this._fragmentSource);return n&&(l=n1.convertTo300(l),c=n1.convertTo300(c,!0)),new n6(e,l,c)},t}(n3);re._shaderPassCounter=0,re._shaderRootPath="shaders://root/";var rt=/*#__PURE__*/function(e){function t(t,n,r){var i;if((i=e.call(this)||this)._name=t,n.length<1)throw" count must large than 0.";for(var a in i._passes=n.slice(),r)i.setTag(a,r[a]);return i}return tX(t,e),tW(t,[{key:"passes",get:function(){return this._passes}}]),t}(n3),rn=function(){this.enabled=!1,this.colorBlendOperation=nB.Add,this.alphaBlendOperation=nB.Add,this.sourceColorBlendFactor=nD.One,this.sourceAlphaBlendFactor=nD.One,this.destinationColorBlendFactor=nD.Zero,this.destinationAlphaBlendFactor=nD.Zero,this.colorWriteMask=nI.All},rr=/*#__PURE__*/function(){function e(){this.targetBlendState=new rn,this.blendColor=new tV(0,0,0,0),this.alphaToCoverage=!1}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,i,a,o,s,l,c=this.targetBlendState,u=e[nV.BlendStateEnabled0];if(void 0!==u){var d=t.getFloat(u);c.enabled=void 0!==d&&!!d}var h=e[nV.BlendStateColorBlendOperation0];void 0!==h&&(c.colorBlendOperation=null!=(n=t.getFloat(h))?n:nB.Add);var _=e[nV.BlendStateAlphaBlendOperation0];void 0!==_&&(c.alphaBlendOperation=null!=(r=t.getFloat(_))?r:nB.Add);var f=e[nV.BlendStateSourceColorBlendFactor0];void 0!==f&&(c.sourceColorBlendFactor=null!=(i=t.getFloat(f))?i:nD.One);var p=e[nV.BlendStateSourceAlphaBlendFactor0];void 0!==p&&(c.sourceAlphaBlendFactor=null!=(a=t.getFloat(p))?a:nD.One);var m=e[nV.BlendStateDestinationColorBlendFactor0];void 0!==m&&(c.destinationColorBlendFactor=null!=(o=t.getFloat(m))?o:nD.Zero);var g=e[nV.BlendStateDestinationAlphaBlendFactor0];void 0!==g&&(c.destinationAlphaBlendFactor=null!=(s=t.getFloat(g))?s:nD.Zero);var v=e[nV.BlendStateColorWriteMask0];void 0!==v&&(c.colorWriteMask=null!=(l=t.getFloat(v))?l:nI.All);var y=e[nV.BlendStateBlendColor];if(void 0!==y){var x=t.getColor(y);void 0!==x&&this.blendColor.copyFrom(x)}var b=e[nV.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 i=t.gl,a=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[nV.BlendStateColorWriteMask0];void 0!==p&&(f=p)}if(s!==a.enabled&&(s?i.enable(i.BLEND):i.disable(i.BLEND),a.enabled=s),s){(u!==a.sourceColorBlendFactor||d!==a.destinationColorBlendFactor||h!==a.sourceAlphaBlendFactor||_!==a.destinationAlphaBlendFactor)&&(i.blendFuncSeparate(e._getGLBlendFactor(t,u),e._getGLBlendFactor(t,d),e._getGLBlendFactor(t,h),e._getGLBlendFactor(t,_)),a.sourceColorBlendFactor=u,a.destinationColorBlendFactor=d,a.sourceAlphaBlendFactor=h,a.destinationAlphaBlendFactor=_),(l!==a.colorBlendOperation||c!==a.alphaBlendOperation)&&(i.blendEquationSeparate(e._getGLBlendOperation(t,l),e._getGLBlendOperation(t,c)),a.colorBlendOperation=l,a.alphaBlendOperation=c);var m=this.blendColor;tV.equals(n.blendColor,m)||(i.blendColor(m.r,m.g,m.b,m.a),n.blendColor.copyFrom(m))}f!==a.colorWriteMask&&(i.colorMask((f&nI.Red)!=0,(f&nI.Green)!=0,(f&nI.Blue)!=0,(f&nI.Alpha)!=0),a.colorWriteMask=f);var g=this.alphaToCoverage;g!==n.alphaToCoverage&&(g?i.enable(i.SAMPLE_ALPHA_TO_COVERAGE):i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),n.alphaToCoverage=g)},e._getGLBlendFactor=function(e,t){var n=e.gl;switch(t){case nD.Zero:return n.ZERO;case nD.One:return n.ONE;case nD.SourceColor:return n.SRC_COLOR;case nD.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case nD.DestinationColor:return n.DST_COLOR;case nD.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case nD.SourceAlpha:return n.SRC_ALPHA;case nD.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case nD.DestinationAlpha:return n.DST_ALPHA;case nD.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case nD.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case nD.BlendColor:return n.CONSTANT_COLOR;case nD.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},e._getGLBlendOperation=function(e,t){var n=e.gl;switch(t){case nB.Add:return n.FUNC_ADD;case nB.Subtract:return n.FUNC_SUBTRACT;case nB.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case nB.Min:if(!e.canIUse(n$.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case nB.Max:if(!e.canIUse(n$.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},e}();tq([t0],rr.prototype,"targetBlendState",void 0),tq([t0],rr.prototype,"blendColor",void 0);var ri=/*#__PURE__*/function(){function e(){this.enabled=!0,this.compareFunction=nO.Less,this.writeEnabled=!0}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r=e[nV.DepthStateEnabled];if(void 0!==r){var i=t.getFloat(r);this.enabled=void 0!==i&&!!i}var a=e[nV.DepthStateWriteEnabled];if(void 0!==a){var o=t.getFloat(a);this.writeEnabled=void 0!==o&&!!o}var s=e[nV.DepthStateCompareFunction];void 0!==s&&(this.compareFunction=null!=(n=t.getFloat(s))?n:nO.Less)},t._apply=function(e,t,n){this._platformApply(e,t.depthState,n)},t._platformApply=function(t,n,r){var i=t.gl,a=this.enabled,o=this.compareFunction,s=this.writeEnabled;if(r){var l=r[nV.DepthStateEnabled];void 0!==l&&(a=l)}a!=n.enabled&&(a?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST),n.enabled=a),a&&o!=n.compareFunction&&(i.depthFunc(e._getGLCompareFunction(t,o)),n.compareFunction=o),s!=n.writeEnabled&&(i.depthMask(s),n.writeEnabled=s)},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nO.Never:return n.NEVER;case nO.Less:return n.LESS;case nO.Equal:return n.EQUAL;case nO.LessEqual:return n.LEQUAL;case nO.Greater:return n.GREATER;case nO.NotEqual:return n.NOTEQUAL;case nO.GreaterEqual:return n.GEQUAL;case nO.Always:return n.ALWAYS}},e}(),ra=/*#__PURE__*/function(){function e(){this.cullMode=nN.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,i,a=e[nV.RasterStateCullMode];void 0!==a&&(this.cullMode=null!=(n=t.getFloat(a))?n:nN.Back);var o=e[nV.RasterStateDepthBias];void 0!==o&&(this.depthBias=null!=(r=t.getFloat(o))?r:0);var s=e[nV.RasterStateSlopeScaledDepthBias];void 0!==s&&(this.slopeScaledDepthBias=null!=(i=t.getFloat(s))?i:0)},t._apply=function(e,t,n,r){this._platformApply(e,t.rasterState,n,r)},t._platformApply=function(e,t,n,r){var i=e.gl,a=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias;if(r){var l=r[nV.RasterStateCullMode];void 0!==l&&(a=l)}var c=a!==nN.Off;c!==t._cullFaceEnable&&(c?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),t._cullFaceEnable=c),c&&a!==t.cullMode&&(a==nN.Back?i.cullFace(i.BACK):i.cullFace(i.FRONT),t.cullMode=a),n!==t._frontFaceInvert&&(n?i.frontFace(i.CW):i.frontFace(i.CCW),t._frontFaceInvert=n),e._enableGlobalDepthBias||o===t.depthBias&&s===t.slopeScaledDepthBias||(0!==o||0!==s?(i.enable(i.POLYGON_OFFSET_FILL),i.polygonOffset(s,o)):i.disable(i.POLYGON_OFFSET_FILL),t.depthBias=o,t.slopeScaledDepthBias=s)},e}(),ro=/*#__PURE__*/function(){function e(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=nO.Always,this.compareFunctionBack=nO.Always,this.passOperationFront=nU.Keep,this.passOperationBack=nU.Keep,this.failOperationFront=nU.Keep,this.failOperationBack=nU.Keep,this.zFailOperationFront=nU.Keep,this.zFailOperationBack=nU.Keep}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,i,a,o,s,l,c,u,d,h,_=e[nV.StencilStateEnabled];if(void 0!==_){var f=t.getFloat(_);this.enabled=void 0!==f&&!!f}var p=e[nV.StencilStateReferenceValue];void 0!==p&&(this.referenceValue=null!=(n=t.getFloat(p))?n:0);var m=e[nV.StencilStateMask];void 0!==m&&(this.mask=null!=(r=t.getFloat(m))?r:255);var g=e[nV.StencilStateWriteMask];void 0!==g&&(this.writeMask=null!=(i=t.getFloat(g))?i:255);var v=e[nV.StencilStateCompareFunctionFront];void 0!==v&&(this.compareFunctionFront=null!=(a=t.getFloat(v))?a:nO.Always);var y=e[nV.StencilStateCompareFunctionBack];void 0!==y&&(this.compareFunctionBack=null!=(o=t.getFloat(y))?o:nO.Always);var x=e[nV.StencilStatePassOperationFront];void 0!==x&&(this.passOperationFront=null!=(s=t.getFloat(x))?s:nU.Keep);var b=e[nV.StencilStatePassOperationBack];void 0!==b&&(this.passOperationBack=null!=(l=t.getFloat(b))?l:nU.Keep);var C=e[nV.StencilStateFailOperationFront];void 0!==C&&(this.failOperationFront=null!=(c=t.getFloat(C))?c:nU.Keep);var S=e[nV.StencilStateFailOperationBack];void 0!==S&&(this.failOperationBack=null!=(u=t.getFloat(S))?u:nU.Keep);var T=e[nV.StencilStateZFailOperationFront];void 0!==T&&(this.zFailOperationFront=null!=(d=t.getFloat(T))?d:nU.Keep);var A=e[nV.StencilStateZFailOperationBack];void 0!==A&&(this.zFailOperationBack=null!=(h=t.getFloat(A))?h:nU.Keep)},t._apply=function(e,t,n){this._platformApply(e,t.stencilState,n)},t._platformApply=function(t,n,r){var i=t.gl,a=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[nV.StencilStateEnabled];void 0!==g&&(a=g);var v=r[nV.StencilStateWriteMask];void 0!==v&&(m=v);var y=r[nV.StencilStateReferenceValue];void 0!==y&&(o=y);var x=r[nV.StencilStateCompareFunctionFront];void 0!==x&&(l=x);var b=r[nV.StencilStateCompareFunctionBack];void 0!==b&&(c=b);var C=r[nV.StencilStatePassOperationFront];void 0!==C&&(h=C);var S=r[nV.StencilStatePassOperationBack];void 0!==S&&(p=S);var T=r[nV.StencilStateFailOperationFront];void 0!==T&&(u=T);var A=r[nV.StencilStateFailOperationBack];void 0!==A&&(_=A);var R=r[nV.StencilStateZFailOperationFront];void 0!==R&&(d=R);var E=r[nV.StencilStateZFailOperationBack];void 0!==E&&(f=E)}if(a!=n.enabled&&(a?i.enable(i.STENCIL_TEST):i.disable(i.STENCIL_TEST),n.enabled=a),a){var M=o!==n.referenceValue||s!==n.mask;(M||l!==n.compareFunctionFront)&&(i.stencilFuncSeparate(i.FRONT,e._getGLCompareFunction(t,l),o,s),n.compareFunctionFront=l),(M||c!==n.compareFunctionBack)&&(i.stencilFuncSeparate(i.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)&&(i.stencilOpSeparate(i.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)&&(i.stencilOpSeparate(i.BACK,e._getGLStencilOperation(t,_),e._getGLStencilOperation(t,f),e._getGLStencilOperation(t,p)),n.failOperationBack=_,n.zFailOperationBack=f,n.passOperationBack=p),m!==n.writeMask&&(i.stencilMask(m),n.writeMask=m)}},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nO.Never:return n.NEVER;case nO.Less:return n.LESS;case nO.Equal:return n.EQUAL;case nO.LessEqual:return n.LEQUAL;case nO.Greater:return n.GREATER;case nO.NotEqual:return n.NOTEQUAL;case nO.GreaterEqual:return n.GEQUAL;case nO.Always:return n.ALWAYS}},e._getGLStencilOperation=function(e,t){var n=e.gl;switch(t){case nU.Keep:return n.KEEP;case nU.Zero:return n.ZERO;case nU.Replace:return n.REPLACE;case nU.IncrementSaturate:return n.INCR;case nU.DecrementSaturate:return n.DECR;case nU.Invert:return n.INVERT;case nU.IncrementWrap:return n.INCR_WRAP;case nU.DecrementWrap:return n.DECR_WRAP}},e}(),rs=/*#__PURE__*/function(){function e(){this.blendState=new rr,this.depthState=new ri,this.stencilState=new ro,this.rasterState=new ra,this.renderQueueType=nk.Opaque}var t=e.prototype;return t._applyStates=function(e,t,n,r,i){n&&this._applyStatesByShaderData(n,r);var a=e._hardwareRenderer,o=e._lastRenderState,s=e._renderContext;this.blendState._apply(a,o,i),this.depthState._apply(a,o,i),this.stencilState._apply(a,o,i),this.rasterState._apply(a,o,s.flipProjection?!t:t,i)},t._getRenderQueueByShaderData=function(e,t){var n,r=e[nV.RenderQueueType];return void 0===r?this.renderQueueType:null!=(n=t.getFloat(r))?n:nk.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}();tq([t0],rs.prototype,"blendState",void 0),tq([t0],rs.prototype,"depthState",void 0),tq([t0],rs.prototype,"stencilState",void 0),tq([t0],rs.prototype,"rasterState",void 0);var rl=/*#__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=nW(this._subShaders);!(t=n()).done;)for(var r,i=t.value,a=nW(i.passes);!(r=a()).done;)r.value._path=e},t.compileVariant=function(t,n){var r=e._compileMacros;r.clear();for(var i=0,a=n.length;i<a;i++)r.enable(nj.getByName(n[i]));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,i=n.length;r<i;r++)for(var a=n[r].passes,o=0,s=a.length;o<s;o++)a[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 i,a=e._shaderMap;if(n){if(a[t]){console.error('Shader named "'+t+'" already exists.');return}if("string"==typeof n)i=new e(t,[new rt("Default",[new re(n,r)])]);else if(n.length>0)i=n[0].constructor===re?new e(t,[new rt("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(a[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,i=t.name.split("/");return null==(r=e.find(i[0]))?void 0:null==(n=r.subShaders.find(function(e){return e.name===i[1]}))?void 0:n.passes.find(function(e){return e.name===i[2]})}var a=new re(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 rs;for(var u in a._renderState=c,s)e._applyConstRenderStates(c,parseInt(u),s[u]);var d={};for(var h in l)d[h]=nQ.getByName(l[h]);a._renderStateDataMap=d}return a});return new rt(t.name,n,t.tags)});return i=new e(o.name,s),a[o.name]=i,i}return a[t]=i,i},e.find=function(t){return e._shaderMap[t]},e._applyConstRenderStates=function(e,t,n){switch(t){case nV.BlendStateEnabled0:e.blendState.targetBlendState.enabled=n;break;case nV.BlendStateColorBlendOperation0:e.blendState.targetBlendState.colorBlendOperation=n;break;case nV.BlendStateAlphaBlendOperation0:e.blendState.targetBlendState.alphaBlendOperation=n;break;case nV.BlendStateSourceColorBlendFactor0:e.blendState.targetBlendState.sourceColorBlendFactor=n;break;case nV.BlendStateDestinationColorBlendFactor0:e.blendState.targetBlendState.destinationColorBlendFactor=n;break;case nV.BlendStateSourceAlphaBlendFactor0:e.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case nV.BlendStateDestinationAlphaBlendFactor0:e.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case nV.BlendStateColorWriteMask0:e.blendState.targetBlendState.colorWriteMask=n;break;case nV.DepthStateEnabled:e.depthState.enabled=n;break;case nV.DepthStateWriteEnabled:e.depthState.writeEnabled=n;break;case nV.DepthStateCompareFunction:e.depthState.compareFunction=n;break;case nV.StencilStateEnabled:e.stencilState.enabled=n;break;case nV.StencilStateReferenceValue:e.stencilState.referenceValue=n;break;case nV.StencilStateMask:e.stencilState.mask=n;break;case nV.StencilStateWriteMask:e.stencilState.writeMask=n;break;case nV.StencilStateCompareFunctionFront:e.stencilState.compareFunctionFront=n;break;case nV.StencilStateCompareFunctionBack:e.stencilState.compareFunctionBack=n;break;case nV.StencilStatePassOperationFront:e.stencilState.passOperationFront=n;break;case nV.StencilStatePassOperationBack:e.stencilState.passOperationBack=n;break;case nV.StencilStateFailOperationFront:e.stencilState.failOperationFront=n;break;case nV.StencilStateFailOperationBack:e.stencilState.failOperationBack=n;break;case nV.StencilStateZFailOperationFront:e.stencilState.zFailOperationFront=n;break;case nV.StencilStateZFailOperationBack:e.stencilState.zFailOperationBack=n;break;case nV.RasterStateCullMode:e.rasterState.cullMode=n;break;case nV.RasterStateDepthBias:e.rasterState.depthBias=n;break;case nV.RasterStateSlopeScaledDepthBias:e.rasterState.slopeScaledDepthBias=n;break;case nV.RenderQueueType:e.renderQueueType=n}},e.getMacroByName=function(e,t){return nj.getByName(e,t)},e.getPropertyByName=function(e){return nQ.getByName(e)},tW(e,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();rl._compileMacros=new nX,rl._shaderMap=Object.create(null);var rc=/*#__PURE__*/function(){function e(e){this._propertyValueMap=Object.create(null),this._macroCollection=new nX,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,nz.Float,t)},t.getInt=function(e){return this.getPropertyValue(e)},t.setInt=function(e,t){this._setPropertyValue(e,nz.Int,t)},t.getFloatArray=function(e){return this.getPropertyValue(e)},t.setFloatArray=function(e,t){this._setPropertyValue(e,nz.FloatArray,t)},t.getIntArray=function(e){return this.getPropertyValue(e)},t.setIntArray=function(e,t){this._setPropertyValue(e,nz.IntArray,t)},t.getVector2=function(e){return this.getPropertyValue(e)},t.setVector2=function(e,t){this._setPropertyValue(e,nz.Vector2,t)},t.getVector3=function(e){return this.getPropertyValue(e)},t.setVector3=function(e,t){this._setPropertyValue(e,nz.Vector3,t)},t.getVector4=function(e){return this.getPropertyValue(e)},t.setVector4=function(e,t){this._setPropertyValue(e,nz.Vector4,t)},t.getMatrix=function(e){return this.getPropertyValue(e)},t.setMatrix=function(e,t){this._setPropertyValue(e,nz.Matrix,t)},t.getColor=function(e){return this.getPropertyValue(e)},t.setColor=function(e,t){this._setPropertyValue(e,nz.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,nz.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 i=0,a=r.length;i<a;i++)r[i]._addReferCount(-n);if(t)for(var o=0,s=t.length;o<s;o++)t[o]._addReferCount(n)}this._setPropertyValue(e,nz.TextureArray,t)},t.getPropertyValue=function(e){return"string"==typeof e&&(e=nQ.getByName(e)),this._propertyValueMap[e._uniqueId]},t.enableMacro=function(e,t){"string"==typeof e&&(e=nj.getByName(e,t));var n=e._nameId,r=this._macroMap[n];if(r!==e){var i=this._macroCollection;r&&i.disable(r),i.enable(e),this._macroMap[n]=e}},t.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=nj._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=nQ._propertyIdMap;for(var i in n)t.push(r[i]);if(!e)return t},t.clone=function(){var t=new e(this._group);return this.cloneTo(t),t},t.cloneTo=function(e){t1.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),n=this._propertyValueMap,r=e._propertyValueMap,i=Object.keys(n),a=0,o=i.length;a<o;a++){var s=i[a],l=n[s];if(null!=l){if("number"==typeof l)r[s]=l;else if(tY(l,nc))r[s]=l,t>0&&l._addReferCount(t);else if(tY(l,Array)||tY(l,Float32Array)||tY(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=nQ.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 "+n9[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 "+nz[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&&tY(r,nc)&&r._addReferCount(e)}},e}();tq([tJ],rc.prototype,"_group",void 0),tq([tJ],rc.prototype,"_propertyValueMap",void 0),tq([tJ],rc.prototype,"_macroCollection",void 0),tq([tJ],rc.prototype,"_macroMap",void 0),tq([tJ],rc.prototype,"_refCount",void 0);var ru=/*#__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,i=n.component,a=r.maskInteraction;return a===i.maskInteraction&&(a===nx.None||r.maskLayer===i.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=r8._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,i=n.indices,a=i.length,o=r.updateIndexLength;if(t)e.subChunk.subMesh.count+=a;else{var s=n.subMesh;s.start=o,s.count=a}for(var l=n.vertexArea,c=l.start,u=l.size,d=c/9,h=r.indices,_=0;_<a;++_)h[o++]=d+i[_];r.updateIndexLength+=a,r.updateVertexStart=Math.min(r.updateVertexStart,c),r.updateVertexEnd=Math.max(r.updateVertexEnd,c+u)},e}();ru._disableBatchTag=n2.getByName("spriteDisableBatching");var rd=((V={})[V.None=0]="None",V[V.Scene=1]="Scene",V[V.Hierarchy=2]="Hierarchy",V[V.All=3]="All",V),rh=/*#__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}tX(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&rd.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&rd.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())},tW(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}(t2);tq([tJ],rh.prototype,"_entity",void 0),tq([tJ],rh.prototype,"_awoken",void 0),tq([tJ],rh.prototype,"_phasedActiveInScene",void 0),tq([tJ],rh.prototype,"_phasedActive",void 0),tq([tZ],rh.prototype,"_enabled",void 0);var r_=/*#__PURE__*/function(){function e(){}return e._addCheck=function(t,n){for(;n!==rh;){var r=e._dependenciesMap.get(n);if(r)for(var i=r.components,a=r.mode,o=0,s=i.length;o<s;o++){var l=i[o];if(!t.getComponent(l)){if(1===a)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,i=r.length;n!==rh;){for(var a=0,o=0;o<i;o++)if(tY(r[o],n)&&++a>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 rf(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){r_._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return r_._addInvDependency(t,e)})}}r_._invDependenciesMap=new Map,r_._dependenciesMap=new Map;var rp=((k={})[k.CheckOnly=0]="CheckOnly",k[k.AutoAdd=1]="AutoAdd",k),rm=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.flag=!0,t}return tX(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++)nR.removeFromArray(e[t]._updateFlags,this)},e}()),rg=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._position=new tR,n._rotation=new tR,n._rotationQuaternion=new tD,n._scale=new tR(1,1,1),n._localUniformScaling=!0,n._worldPosition=new tR,n._worldRotation=new tR,n._worldRotationQuaternion=new tD,n._worldUniformScaling=!0,n._lossyWorldScale=new tR(1,1,1),n._localMatrix=new tB,n._worldMatrix=new tB,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}tX(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,i){if("number"==typeof e){var a=t._tempVec30;a.set(e,n,r),this._translate(a,i)}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 i=n*tA.degreeToRadFactor;tD.rotationAxisAngle(e,i,t._tempQuat0),this._rotateByQuat(t._tempQuat0,r)},n.lookAt=function(e,n){var r=t._tempVec30;tR.subtract(this.worldPosition,e,r);var i=r.length();if(!(i<=tA.zeroTolerance)){r.scale(1/i);var a=t._tempVec31;if(n?tR.cross(n,r,a):a.set(r.z,0,-r.x),!((i=a.length())<=tA.zeroTolerance)){a.scale(1/i);var o=t._tempVec32;tR.cross(r,a,o);var s=t._tempMat41,l=s.elements;l[0]=a.x,l[1]=a.y,l[2]=a.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,i=0,a=r.length;i<a;i++)null==(n=r[i].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,i=n.length;r<i;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,i=n.length;r<i;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,i=n.length;r<i;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,i=n.length;r<i;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,i=t._tempMat32;return r.copyFromMatrix(this.worldMatrix),tD.invert(this.worldRotationQuaternion,e),tL.rotationQuaternion(e,n),tL.multiply(n,r,i),i},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?tD.multiply(this.rotationQuaternion,e,this._rotationQuaternion):tD.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},n._translate=function(e,n){if(void 0===n&&(n=!0),n){var r=t._tempVec30;tR.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},n._rotateXYZ=function(e,n,r,i){void 0===i&&(i=!0);var a=tA.degreeToRadFactor,o=t._tempQuat0;tD.rotationEuler(e*a,n*a,r*a,o),this._rotateByQuat(o,i)},n._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},n._onWorldPositionChanged=function(){var e=this._worldPosition,n=this._getParentTransform();n?(tB.invert(n.worldMatrix,t._tempMat41),tR.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;tD.rotationEuler(tA.degreeToRadian(e.x),tA.degreeToRadian(e.y),tA.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;tD.invert(n.worldRotationQuaternion,r),tD.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 i=t==n&&n==r;this._localUniformScaling!==i?(this._localUniformScaling=i,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(rm)},tW(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(tA.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(tA.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,tD.rotationEuler(tA.degreeToRadian(this._rotation.x),tA.degreeToRadian(this._rotation.y),tA.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):tD.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?tD.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):tD.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)&&(tB.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 i=r.x===r.y&&r.y===r.z;this._localUniformScaling!==i?(this._localUniformScaling=i,this._updateAllWorldFlag(444)):this._updateAllWorldFlag(188)}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var e=this._getParentTransform();e?tB.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?(tB.invert(n.worldMatrix,t._tempMat42),tB.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 tR),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 tR),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 tR),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),t}(rh);rg._tempQuat0=new tD,rg._tempVec30=new tR,rg._tempVec31=new tR,rg._tempVec32=new tR,rg._tempMat30=new tL,rg._tempMat31=new tL,rg._tempMat32=new tL,rg._tempMat41=new tB,rg._tempMat42=new tB,tq([t0],rg.prototype,"_position",void 0),tq([t0],rg.prototype,"_rotation",void 0),tq([t0],rg.prototype,"_rotationQuaternion",void 0),tq([t0],rg.prototype,"_scale",void 0),tq([tZ],rg.prototype,"_localUniformScaling",void 0),tq([t0],rg.prototype,"_worldPosition",void 0),tq([t0],rg.prototype,"_worldRotation",void 0),tq([t0],rg.prototype,"_worldRotationQuaternion",void 0),tq([tZ],rg.prototype,"_worldUniformScaling",void 0),tq([t0],rg.prototype,"_lossyWorldScale",void 0),tq([t0],rg.prototype,"_localMatrix",void 0),tq([t0],rg.prototype,"_worldMatrix",void 0),tq([tJ],rg.prototype,"_worldForward",void 0),tq([tJ],rg.prototype,"_worldRight",void 0),tq([tJ],rg.prototype,"_worldUp",void 0),tq([tJ],rg.prototype,"_isParentDirty",void 0),tq([tJ],rg.prototype,"_parentTransformCache",void 0),tq([tJ],rg.prototype,"_onPositionChanged",null),tq([tJ],rg.prototype,"_onWorldPositionChanged",null),tq([tJ],rg.prototype,"_onRotationChanged",null),tq([tJ],rg.prototype,"_onWorldRotationChanged",null),tq([tJ],rg.prototype,"_onRotationQuaternionChanged",null),tq([tJ],rg.prototype,"_onWorldRotationQuaternionChanged",null),tq([tJ],rg.prototype,"_onScaleChanged",null);var rv=((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),ry=((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 nX,r._bounds=new tM,r._maskInteraction=nx.None,r._maskLayer=ry.Layer0,r._batchedTransformShaderData=!1,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new tN,r._shaderData=new rc(n9.Renderer),r._mvMatrix=new tB,r._mvpMatrix=new tB,r._mvInvMatrix=new tB,r._normalMatrix=new tB,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r.castShadows=!0;var r,i=t.prototype,a=r.shaderData;return r._overrideUpdate=r.update!==i.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(r),r._setTransformEntity(n),a.enableMacro(t._receiveShadowMacro),a.setVector4(t._rendererLayerProperty,r._rendererLayer),r}tX(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,i=t,a=n.length;i<a;i++){var o=n[i];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,i=this.bounds.getCenter(t._tempVector0);n.isOrthographic?(tR.subtract(i,r,i),this._distanceForSort=tR.dot(i,n.forward)):this._distanceForSort=tR.distanceSquared(i,r),this._render(e),nX.unionCollection(e.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},n._cloneTo=function(e,t,n){for(var r=this._materials,i=0,a=r.length;i<a;i++)e._setMaterial(i,r[i])},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 i=t[n];i&&this._addResourceReferCount(i,-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 i=this.shaderData,a=this._mvInvMatrix;if(r){var o=tB._identity;tB.invert(e.viewMatrix,a),i.setMatrix(t._localMatrixProperty,o),i.setMatrix(t._worldMatrixProperty,o),i.setMatrix(t._mvMatrixProperty,e.viewMatrix),i.setMatrix(t._mvInvMatrixProperty,a),i.setMatrix(t._normalMatrixProperty,o)}else{var s=this._mvMatrix,l=this._normalMatrix;tB.multiply(e.viewMatrix,n,s),tB.invert(s,a),tB.invert(n,l),l.transpose(),i.setMatrix(t._localMatrixProperty,this._transformEntity.transform.localMatrix),i.setMatrix(t._worldMatrixProperty,n),i.setMatrix(t._mvMatrixProperty,s),i.setMatrix(t._mvInvMatrixProperty,a),i.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 i=this._mvpMatrix;tB.multiply(e.viewProjectionMatrix,n,i),this.shaderData.setMatrix(t._mvpMatrixProperty,i)}},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 i=this._materialsInstanced;e<i.length&&(i[e]=!1),r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),n[e]=t}},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},tW(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}(rh),e.Renderer._tempVector0=new tR,e.Renderer._receiveShadowMacro=nj.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e.Renderer._localMatrixProperty=nQ.getByName("renderer_LocalMat"),e.Renderer._worldMatrixProperty=nQ.getByName("renderer_ModelMat"),e.Renderer._mvMatrixProperty=nQ.getByName("renderer_MVMat"),e.Renderer._mvpMatrixProperty=nQ.getByName("renderer_MVPMat"),e.Renderer._mvInvMatrixProperty=nQ.getByName("renderer_MVInvMat"),e.Renderer._normalMatrixProperty=nQ.getByName("renderer_NormalMat"),e.Renderer._rendererLayerProperty=nQ.getByName("renderer_Layer"),tq([tJ],e.Renderer.prototype,"_distanceForSort",void 0),tq([tJ],e.Renderer.prototype,"_onUpdateIndex",void 0),tq([tJ],e.Renderer.prototype,"_rendererIndex",void 0),tq([tJ],e.Renderer.prototype,"_globalShaderMacro",void 0),tq([tJ],e.Renderer.prototype,"_bounds",void 0),tq([tJ],e.Renderer.prototype,"_renderFrameCount",void 0),tq([tZ],e.Renderer.prototype,"_maskInteraction",void 0),tq([tZ],e.Renderer.prototype,"_maskLayer",void 0),tq([tJ],e.Renderer.prototype,"_batchedTransformShaderData",void 0),tq([tJ],e.Renderer.prototype,"_transformEntity",void 0),tq([tJ],e.Renderer.prototype,"_overrideUpdate",void 0),tq([tJ],e.Renderer.prototype,"_materials",void 0),tq([tJ],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),tq([tJ],e.Renderer.prototype,"_rendererLayer",void 0),tq([t0],e.Renderer.prototype,"_shaderData",void 0),tq([tJ],e.Renderer.prototype,"_mvMatrix",void 0),tq([tJ],e.Renderer.prototype,"_mvpMatrix",void 0),tq([tJ],e.Renderer.prototype,"_mvInvMatrix",void 0),tq([tJ],e.Renderer.prototype,"_normalMatrix",void 0),tq([tJ],e.Renderer.prototype,"_materialsInstanced",void 0),tq([tZ],e.Renderer.prototype,"_priority",void 0),tq([tZ],e.Renderer.prototype,"_receiveShadows",void 0),tq([tJ],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=tq([rf(rg,rp.CheckOnly)],e.Renderer);var rx=((G={})[G.WorldVolume=1]="WorldVolume",G);function rb(){return function(e){}}var rC=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var i=n.allocateSubChunk(4);i.indices=e._rectangleTriangles,t._subChunk=i},e.updatePositions=function(t){var n=t.width,r=t.height,i=t.sprite,a=i.pivot,o=a.x,s=a.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 _=i._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]}tM.transform(i._getBounds(),l,t._bounds)},e.updateUVs=function(e){var t=e.sprite._getUVs(),n=t[0],r=n.x,i=n.y,a=t[3],o=a.x,s=a.y,l=e._subChunk,c=l.chunk.vertices,u=l.vertexArea.start+3;c[u]=r,c[u+1]=i,c[u+9]=o,c[u+10]=i,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,i=n.g,a=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]=i,s[c+2]=a,s[c+3]=o},e}();rC._rectangleTriangles=[0,1,2,2,1,3],rC._worldMatrix=new tB,rC=tq([rb()],rC);var rS=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var i=n.allocateSubChunk(16);i.indices=e._rectangleTriangles,t._subChunk=i},e.updatePositions=function(t){var n,r,i=t.width,a=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>i){var b=i/(g+y);n=[p*u*b,g*b,g*b,i-p*(1-_)*b]}else n=[p*u,g,i-y,i-p*(1-_)];if(x+v>a){var C=a/(x+v);r=[m*d*C,v*C,v*C,a-m*(1-f)*C]}else r=[m*d,v,a-x,a-m*(1-f)];var S=t.sprite.pivot,T=S.x,A=S.y,R=t.width*T,E=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]-R*w[0]-E*w[4],w[13]=P[13]-R*w[1]-E*w[5],w[14]=P[14]-R*w[2]-E*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(),i=0,a=t.vertexArea.start+3;i<4;i++)for(var o=r[i].x,s=0;s<4;s++,a+=9)n[a]=o,n[a+1]=r[s].y},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,i=n.g,a=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]=i,s[c+2]=a,s[c+3]=o},e}();rS._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],rS._worldMatrix=new tB,rS=tq([rb()],rS);var rT=/*#__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,i=this.length;r<i;r++){var a=n[r];a&&e(a,r)}this._endLoop(t)},t.forEachAndClean=function(e,t){this._startLoop();for(var n=this.length,r=this._elements,i=0;i<n;i++){var a=r[i];a&&e(a,i)}this._endLoopAndClean(n,r,t)},t.sort=function(e){nR._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 i=r[n];null==e||e(i,t),r[t++]=i,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,i=e,a=this.length;i<a;i++){var o=t[i];o&&(t[r]=o,null==n||n(o,r),r++)}this.length=r,this._blankCount=0}},tW(e,[{key:"isLopping",get:function(){return this._loopCounter>0}}]),e}(),rA=/*#__PURE__*/function(){function e(){}return e.resetData=function(e,t){if(t){var n=e._getChunkManager(),r=e._subChunk,i=r&&r.vertexArea.size!==9*t;if(i&&n.freeSubChunk(r),!r||i){var a=n.allocateSubChunk(t);a.indices=[],e._subChunk=a}}},e.updatePositions=function(t){var n,r,i,a,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===nA.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,R=t.entity.transform.worldMatrix.elements,E=t.flipX?-1:1,M=t.flipY?-1:1;n=A[0]=R[0]*E,r=A[1]=R[1]*E,i=A[2]=R[2]*E,a=A[4]=R[4]*M,o=A[5]=R[5]*M,s=A[6]=R[6]*M,A[8]=R[8],A[9]=R[9],A[10]=R[10];for(var w=A[12]=R[12]-C*A[0]-S*A[4],P=A[13]=R[13]-C*A[1]-S*A[5],F=A[14]=R[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),q=_.get(G+1),Y=f.get(k+1);I[z]=n*X+a*K+w,I[z+1]=r*X+o*K+P,I[z+2]=i*X+s*K+F,I[z+9]=n*q+a*K+w,I[z+10]=r*q+o*K+P,I[z+11]=i*q+s*K+F,I[z+18]=n*X+a*Y+w,I[z+19]=r*X+o*Y+P,I[z+20]=i*X+s*Y+F,I[z+27]=n*q+a*Y+w,I[z+28]=r*q+o*Y+P,I[z+29]=i*q+s*Y+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,i=e._uvRow,a=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=i.get(2*_),p=a.get(h),m=i.get(2*_+1),g=a.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,i=n.g,a=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]=i,s[u+2]=a,s[u+3]=o},e._calculateAdaptiveDividing=function(e,t,n,r,i,a,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],R=T[1],E=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>tA.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>tA.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 i.add(t*y),i.add(t*C),a.add(n*x),a.add(n*S),o.add(A.x),o.add(M.x),s.add(A.y),s.add(M.y),k+=2,z+=2,nl.warn("The number of vertices exceeds the upper limit("+l+")."),k*z;switch(u){case 0:c=t/D,i.add(w*y*c),i.add(F*c),i.add(t-w*(1-C)*c),o.add(A.x),o.add(R.x),o.add(E.x),o.add(M.x),k+=4;break;case 1:i.add(w*y),i.add(F),i.add(t-L),i.add(t-w*(1-C)),o.add(A.x),o.add(R.x),o.add(NaN),o.add(NaN),o.add(E.x),o.add(M.x),k+=4;break;case 2:c=t/(D+f*B),i.add(w*y*c),i.add(F*c),o.add(A.x),o.add(R.x),o.add(R.x),k+=3;for(var U=0,G=f-1;U<G;U++)i.add(F+(U+1)*B*c),o.add(E.x),o.add(R.x),k+=2;i.add(t-L*c),i.add(t-w*(1-C)*c),o.add(E.x),o.add(E.x),o.add(M.x),k+=3}switch(d){case 0:c=n/N,a.add(P*x*c),a.add(O*c),a.add(n-P*(1-S)*c),s.add(A.y),s.add(R.y),s.add(E.y),s.add(M.y),z+=4;break;case 1:a.add(P*x),a.add(O),a.add(n-I),a.add(n-P*(1-S)),s.add(A.y),s.add(R.y),s.add(NaN),s.add(NaN),s.add(E.y),s.add(M.y),z+=4;break;case 2:c=n/(N+p*V),a.add(P*x*c),a.add(O*c),s.add(A.y),s.add(R.y),s.add(R.y),z+=3;for(var H=0,W=p-1;H<W;H++)a.add(O+(H+1)*V*c),s.add(E.y),s.add(R.y),z+=2;a.add(n-I*c),a.add(n-P*(1-S)*c),s.add(E.y),s.add(E.y),s.add(M.y),z+=3}return k*z},e._calculateContinuousDividing=function(e,t,n,r,i,a,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],R=C[3],E=e.width,M=e.height,w=E*f.x,P=E*f.z,F=w+P,L=E-F,D=M*f.w,B=M*f.y,I=D+B,O=M-I;F>=t?(u=3,l=0):L>tA.zeroTolerance?(u=4+(0|(h=(t-F)/L)),l=2):(u=4,l=1),I>=n?(d=3,c=0):O>tA.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),i.add(n*v),i.add(n*b),a.add(S.x),a.add(R.x),o.add(S.y),o.add(R.y),N+=2,V+=2,nl.warn("The number of vertices exceeds the upper limit("+s+")."),N*V;switch(l){case 0:var k=t/F;r.add(E*g*k),r.add(w*k),r.add(t-E*(1-x)*k),a.add(S.x),a.add(T.x),a.add(A.x),a.add(R.x),N+=4;break;case 1:r.add(E*g),r.add(w),r.add(t-P),r.add(t-E*(1-x)),a.add(S.x),a.add(T.x),a.add(NaN),a.add(NaN),a.add(A.x),a.add(R.x),N+=4;break;case 2:r.add(E*g),r.add(w),a.add(S.x),a.add(T.x),a.add(T.x),N+=3;for(var z=0|h,U=0;U<z;U++)r.add(w+(U+1)*L),a.add(A.x),a.add(T.x),N+=2;r.add(t-P),r.add(t-E*(1-x)),a.add((A.x-T.x)*(h-z)+T.x),a.add(A.x),a.add(R.x),N+=3}switch(c){case 0:var G=n/I;i.add(M*v*G),i.add(B*G),i.add(n-M*(1-b)*G),o.add(S.y),o.add(T.y),o.add(A.y),o.add(R.y),V+=4;break;case 1:i.add(M*v),i.add(B),i.add(n-D),i.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(R.y),V+=4;break;case 2:i.add(M*v),i.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++)i.add(B+(W+1)*O),o.add(A.y),o.add(T.y),V+=2;i.add(n-D),i.add(n-M*(1-b)),o.add((A.y-T.y)*(_-H)+T.y),o.add(A.y),o.add(R.y),V+=3}return N*V},e}();rA._worldMatrix=new tB,rA._posRow=new rT,rA._posColumn=new rT,rA._uvRow=new rT,rA._uvColumn=new rT,rA=tq([rb()],rA);var rR=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._tileMode=nA.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new tV(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=nT.Simple,n._dirtyUpdateFlag|=4,n.setMaterial(n._engine._basicResources.spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(n),n._color._onValueChanged=n._onColorChanged.bind(n),n}tX(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 ru.canBatchSprite(e,t)},n._batch=function(e,t){ru.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&rx.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~rx.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,i=r.engine,a=i._renderElementPool.get();a.set(this.priority,this._distanceForSort);var o=i._subRenderElementPool.get(),s=this._subChunk;o.set(this,n,s.chunk.primitive,s.subMesh,this.sprite.texture,s),a.addSubRenderElement(o),r._renderPipeline.pushRenderElement(e,a)}}},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 nF.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nF.size:var n=this._drawMode;this._dirtyUpdateFlag|=8,this._drawMode===nT.Sliced?this._dirtyUpdateFlag|=rx.WorldVolume:n===nT.Tiled?this._dirtyUpdateFlag|=rE.WorldVolumeAndUV:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rx.WorldVolume);break;case nF.border:this._drawMode===nT.Sliced&&(this._dirtyUpdateFlag|=rE.WorldVolumeAndUV);break;case nF.region:case nF.atlasRegionOffset:this._dirtyUpdateFlag|=rE.WorldVolumeAndUV;break;case nF.atlasRegion:this._dirtyUpdateFlag|=2;break;case nF.pivot:this._dirtyUpdateFlag|=rx.WorldVolume;break;case nF.destroy:this.sprite=null}},n._onColorChanged=function(){this._dirtyUpdateFlag|=4},tW(t,[{key:"drawMode",get:function(){return this._drawMode},set:function(e){if(this._drawMode!==e){switch(this._drawMode=e,e){case nT.Simple:this._assembler=rC;break;case nT.Sliced:this._assembler=rS;break;case nT.Tiled:this._assembler=rA}this._assembler.resetData(this),this._dirtyUpdateFlag|=rE.VertexData}}},{key:"tileMode",get:function(){return this._tileMode},set:function(e){this._tileMode!==e&&(this._tileMode=e,this.drawMode===nT.Tiled&&(this._dirtyUpdateFlag|=rE.VertexData))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(e){e!==this._tiledAdaptiveThreshold&&(e=tA.clamp(e,0,1),this._tiledAdaptiveThreshold=e,this.drawMode===nT.Tiled&&(this._dirtyUpdateFlag|=rE.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===nT.Tiled?rE.VertexData:rx.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===nT.Tiled?rE.VertexData:rx.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rx.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rx.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);rR._textureProperty=nQ.getByName("renderer_SpriteTexture"),tq([tJ],rR.prototype,"_subChunk",void 0),tq([tJ],rR.prototype,"_drawMode",void 0),tq([tZ],rR.prototype,"_assembler",void 0),tq([tZ],rR.prototype,"_tileMode",void 0),tq([tZ],rR.prototype,"_tiledAdaptiveThreshold",void 0),tq([t0],rR.prototype,"_color",void 0),tq([tJ],rR.prototype,"_sprite",void 0),tq([tJ],rR.prototype,"_automaticWidth",void 0),tq([tJ],rR.prototype,"_automaticHeight",void 0),tq([tZ],rR.prototype,"_customWidth",void 0),tq([tZ],rR.prototype,"_customHeight",void 0),tq([tZ],rR.prototype,"_flipX",void 0),tq([tZ],rR.prototype,"_flipY",void 0),tq([tJ],rR.prototype,"_onSpriteChange",null),tq([tJ],rR.prototype,"_onColorChanged",null);var rE=((H=rE||{})[H.UV=2]="UV",H[H.Color=4]="Color",H[H.AutomaticSize=8]="AutomaticSize",H[H.WorldVolumeAndUV=2|rx.WorldVolume]="WorldVolumeAndUV",H[H.VertexData=4|H.WorldVolumeAndUV]="VertexData",H[H.All=15]="All",H),rM=((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),rw=/*#__PURE__*/function(){function e(){}return e.recreateTextureIfNeeded=function(e,t,n,r,i,a,o,s){return t?(t.width!==n||t.height!==r||t.format!==i||t.mipmapCount>1!==a)&&(t.destroy(!0),(t=new nd(e,n,r,i,a)).isGCIgnored=!0):(t=new nd(e,n,r,i,a)).isGCIgnored=!0,t.wrapModeU=t.wrapModeV=o,t.filterMode=s,t},e.recreateRenderTargetIfNeeded=function(t,n,r,i,a,o,s,l,c,u,d){var h=null==n?void 0:n.getColorTexture(0),_=a?e.recreateTextureIfNeeded(t,h,r,i,a,l,u,d):null;if(s){var f=null==n?void 0:n.depthTexture,p=o?e.recreateTextureIfNeeded(t,f,r,i,o,l,u,d):null;(h!==_||f!==p)&&(null==n||n.destroy(!0),(n=new nu(t,r,i,_,p,c)).isGCIgnored=!0)}else(h!==_||(null==n?void 0:n._depthFormat)!==o||n.antiAliasing!==c)&&(null==n||n.destroy(!0),(n=new nu(t,r,i,_,o,c)).isGCIgnored=!0);return n},e}();rw.defaultViewport=new tN(0,0,1,1);var rP=function(){this.position=new tR,this.isOrthographic=!1,this.viewMatrix=new tB,this.projectionMatrix=new tB,this.viewProjectionMatrix=new tB,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new tR},rF=((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),rL=((X={})[X.Normal=0]="Normal",X[X.XRCenterCamera=1]="XRCenterCamera",X[X.XRLeftCamera=2]="XRLeftCamera",X[X.XRRightCamera=4]="XRRightCamera",X),rD=((K={})[K.None=0]="None",K[K.PrePass=1]="PrePass",K),rB=((q={})[q.None=1]="None",q[q.TwoX=2]="TwoX",q[q.FourX=4]="FourX",q),rI=((Y={})[Y.None=1]="None",Y[Y.TwoX=2]="TwoX",Y[Y.FourX=4]="FourX",Y[Y.EightX=8]="EightX",Y),rO=((Q={})[Q.KeepOriginalShader=0]="KeepOriginalShader",Q[Q.DoNotRender=1]="DoNotRender",Q),rN=function(){};rN.tempVec4=new tN,rN.tempVec3=new tR,rN.tempVec2=new tO,e.Camera=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableFrustumCulling=!0,n.clearFlags=rF.All,n.cullingMask=rM.Everything,n.postProcessMask=rM.Everything,n.depthTextureMode=rD.None,n.opaqueTextureDownsampling=rB.TwoX,n.msaaSamples=rI.None,n._cameraType=rL.Normal,n._globalShaderMacro=new nX,n._frustum=new tF,n._virtualCamera=new rP,n._replacementShader=null,n._replacementSubShaderTag=null,n._replacementFailureStrategy=null,n._cameraIndex=-1,n._priority=0,n._shaderData=new rc(n9.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 tN,n._opaqueTextureEnabled=!1,n._enableHDR=!1,n._enablePostProcess=!1,n._viewport=new tN(0,0,1,1),n._pixelViewport=new tk(0,0,0,0),n._inverseProjectionMatrix=new tB,n._invViewProjMat=new tB,n._isViewMatrixDirty=t.registerWorldChangeFlag(),n._isInvViewProjDirty=t.registerWorldChangeFlag(),n._frustumChangeFlag=t.registerWorldChangeFlag(),n._renderPipeline=new r1(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}tX(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=rN.tempVec3,r=rN.tempVec4;tR.transformCoordinate(e,this.viewMatrix,n),tR.transformToVec4(n,this.projectionMatrix,r);var i=r.w;return t.set((r.x/i+1)*.5,(1-r.y/i)*.5,-n.z),t},n.viewportToWorldPoint=function(e,t){var n,r=this.nearClipPlane,i=this.farClipPlane,a=1/(r-i);if(this.isOrthographic)n=-(2*e.z)*a+(i+r)*a;else{var o=e.z;n=(-o*(r+i)*a+2*r*i*a)/o}return this._innerViewportToWorldPoint(e.x,e.y,(n+1)/2,this._getInvViewProjMat(),t),t},n.viewportPointToRay=function(e,t){var n=this._getInvViewProjMat(),r=this._innerViewportToWorldPoint(e.x,e.y,0,n,t.origin),i=this._innerViewportToWorldPoint(e.x,e.y,1-tA.zeroTolerance,n,t.direction);return tR.subtract(i,r,i),i.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=rN.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,i=r._renderContext,a=this._virtualCamera,o=this._entity.transform;tB.multiply(this.projectionMatrix,this.viewMatrix,a.viewProjectionMatrix),a.position.copyFrom(o.worldPosition),a.isOrthographic&&a.forward.copyFrom(o.worldForward),i.camera=this,i.virtualCamera=a,i.replacementShader=this._replacementShader,i.replacementTag=this._replacementSubShaderTag,i.replacementFailureStrategy=this._replacementFailureStrategy,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(a.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),nX.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!r._hardwareRenderer.isWebGL2&&(t=0,nl.error("mipLevel only take effect in WebGL2.0")),this._cameraType===rL.Normal||this._renderTarget||this.independentCanvasEnabled||(n=r.xrManager._getCameraIgnoreClearFlags(this._cameraType)),this._renderPipeline.render(i,e,t,n),r._renderCount++},n.setReplacementShader=function(e,t,n){void 0===n&&(n=rO.KeepOriginalShader),this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?n2.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?t7.R11G11B10_UFloat:t7.R16G16B16A16:t7.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 i=this._viewport;this._pixelViewport.set(i.x*e,i.y*t,i.z*e,i.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,i){var a=rN.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),tR.transformCoordinate(a,r,i),i},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,i=this.farClipPlane/this.nearClipPlane;r.set(1-i,i,0,0),e.setVector4(t._cameraDepthBufferParamsProperty,r)},n._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,tB.multiply(this._entity.transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},n._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,tB.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&&tN.equals(this._viewport,rw.defaultViewport)&&nl.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.")},tW(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._isValid())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 tB.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,i=this._orthographicSize;tB.ortho(-r,r,-i,i,this.nearClipPlane,this.farClipPlane,t)}else tB.perspective(tA.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(n$.textureHalfFloat);if(e&&!n){nl.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}(rh),e.Camera._cameraDepthTextureProperty=nQ.getByName("camera_DepthTexture"),e.Camera._cameraOpaqueTextureProperty=nQ.getByName("camera_OpaqueTexture"),e.Camera._inverseViewMatrixProperty=nQ.getByName("camera_ViewInvMat"),e.Camera._cameraPositionProperty=nQ.getByName("camera_Position"),e.Camera._cameraForwardProperty=nQ.getByName("camera_Forward"),e.Camera._cameraUpProperty=nQ.getByName("camera_Up"),e.Camera._cameraDepthBufferParamsProperty=nQ.getByName("camera_DepthBufferParams"),tq([t0],e.Camera.prototype,"_frustum",void 0),tq([tJ],e.Camera.prototype,"_renderPipeline",void 0),tq([tJ],e.Camera.prototype,"_virtualCamera",void 0),tq([tJ],e.Camera.prototype,"_cameraIndex",void 0),tq([tJ],e.Camera.prototype,"_frustumChangeFlag",void 0),tq([tJ],e.Camera.prototype,"_isViewMatrixDirty",void 0),tq([tJ],e.Camera.prototype,"_isInvViewProjDirty",void 0),tq([t0],e.Camera.prototype,"_viewport",void 0),tq([t0],e.Camera.prototype,"_pixelViewport",void 0),tq([t0],e.Camera.prototype,"_inverseProjectionMatrix",void 0),tq([t0],e.Camera.prototype,"_invViewProjMat",void 0),tq([tJ],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=tq([rf(rg,rp.CheckOnly)],e.Camera);var rV=((J={})[J.SolidColor=0]="SolidColor",J[J.Sky=1]="Sky",J[J.Texture=2]="Texture",J),rk=((Z={})[Z.AspectFitWidth=0]="AspectFitWidth",Z[Z.AspectFitHeight=1]="AspectFitHeight",Z[Z.Fill=2]="Fill",Z),rz=function(e){this.engine=e},rU=/*#__PURE__*/function(){function e(){this._projectionParams=new tN,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,i=t.viewMatrix,a=t.projectionMatrix,o=t.viewProjectionMatrix;n&&(tB.multiply(e._flipYMatrix,a,e._flipYProjectionMatrix),tB.multiply(e._flipYProjectionMatrix,i,e._flipYViewProjectionMatrix),a=e._flipYProjectionMatrix,o=e._flipYViewProjectionMatrix),this.viewMatrix=i,this.projectionMatrix=a,this.viewProjectionMatrix=o,r.setMatrix(e._viewMatrixProperty,i),r.setMatrix(e._projectionMatrixProperty,a),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}();rU.vpMatrixProperty=nQ.getByName("camera_VPMat"),rU.pipelineStageKey=n2.getByName("pipelineStage"),rU._flipYMatrix=new tB(1,0,0,0,0,-1),rU._cameraProjectionProperty=nQ.getByName("camera_ProjectionParams"),rU._viewMatrixProperty=nQ.getByName("camera_ViewMat"),rU._projectionMatrixProperty=nQ.getByName("camera_ProjMat"),rU._flipYProjectionMatrix=new tB,rU._flipYViewProjectionMatrix=new tB;var rG=(($={})[$.None=0]="None",$[$.WorldMatrix=1]="WorldMatrix",$[$.viewMatrix=2]="viewMatrix",$[$.ProjectionMatrix=4]="ProjectionMatrix",$[$.WorldViewMatrix=3]="WorldViewMatrix",$[$.viewProjectionMatrix=6]="viewProjectionMatrix",$[$.All=7]="All",$),rH=((ee={})[ee.No=0]="No",ee[ee.Increment=1]="Increment",ee[ee.Decrement=2]="Decrement",ee),rW=/*#__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){nR._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=rH.No);var r=this.batchedSubElements,i=r.length;if(0!==i)for(var a=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=rU.pipelineStageKey,g=this.renderQueueType,v=0;v<i;v++){var y=r[v],x=y.component,b=y.batched,C=y.material;a&rG.WorldViewMatrix||x._batchedTransformShaderData!=b?(x._updateTransformShaderData(e,!1,b),x._batchedTransformShaderData=b):a&rG.ProjectionMatrix&&x._updateTransformShaderData(e,!0,b);var S=x._maskInteraction,T=S!==nx.None,A=n!==rH.No,R=null;A?R=i0.getMaskTypeRenderStates(n):(T?(_.drawMask(e,t,y.component._maskLayer),R=i0.getMaskInteractionRenderStates(S)):_.isReadStencil(C)&&_.clearMask(e,t),_.isStencilWritten(C)&&(_.hasStencilWritten=!0));var E=rl._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;nX.unionCollection(x._globalShaderMacro,D._macroCollection,E);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,E);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,R),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}(),rj=/*#__PURE__*/function(){function e(){}return e.blitTexture=function(t,n,r,i,a,o,s,l){void 0===i&&(i=0),void 0===a&&(a=rw.defaultViewport),void 0===o&&(o=null),void 0===s&&(s=0);var c=t._basicResources,u=r?c.flipYBlitMesh:c.blitMesh,d=o||c.blitMaterial,h=t._hardwareRenderer,_=t._renderContext;_.flipProjection=!!r,h.activeRenderTarget(r,a,_.flipProjection,0);var f=e._rendererShaderData;f.setTexture(e._blitTextureProperty,n),f.setFloat(e._blitMipLevelProperty,i),e._texelSize.set(1/n.width,1/n.height,n.width,n.height),f.setVector4(e._blitTexelSizeProperty,e._texelSize),f.setVector4(e._sourceScaleOffsetProperty,null!=l?l:e._defaultScaleOffset);var p=d.shader.subShaders[0].passes[s],m=rl._compileMacros;nX.unionCollection(_.camera._globalShaderMacro,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}();rj._blitTextureProperty=nQ.getByName("renderer_BlitTexture"),rj._blitMipLevelProperty=nQ.getByName("renderer_BlitMipLevel"),rj._blitTexelSizeProperty=nQ.getByName("renderer_texelSize"),rj._sourceScaleOffsetProperty=nQ.getByName("renderer_SourceScaleOffset"),rj._rendererShaderData=new rc(n9.Renderer),rj._texelSize=new tN,rj._defaultScaleOffset=new tN(1,1,0,0);var rX=function(){this.virtualCamera=new rP,this.cullPlanes=[new tP(new tR),new tP(new tR),new tP(new tR),new tP(new tR),new tP(new tR),new tP(new tR),new tP(new tR),new tP(new tR),new tP(new tR),new tP(new tR)],this.splitBoundSphere=new tE(new tR,0)},rK=((et={})[et.Low=0]="Low",et[et.Medium=1]="Medium",et[et.High=2]="High",et[et.VeryHigh=3]="VeryHigh",et),rq=((en={})[en.None=0]="None",en[en.Hard=1]="Hard",en[en.SoftLow=2]="SoftLow",en[en.SoftHigh=3]="SoftHigh",en),rY=/*#__PURE__*/function(){function e(){}return e.shadowResolution=function(e){switch(e){case rK.Low:return 512;case rK.Medium:return 1024;case rK.High:return 2048;case rK.VeryHigh:return 4096}},e.shadowDepthFormat=function(e,t){return t?t7.Depth16:t7.R8G8B8A8},e.cullingRenderBounds=function(e,t,n){for(var r=e.min,i=e.max,a=0;a<t;a++){var o=n[a],s=o.normal;if(s.x*(s.x>=0?i.x:r.x)+s.y*(s.y>=0?i.y:r.y)+s.z*(s.z>=0?i.z:r.z)<-o.distance)return!1}return!0},e.shadowCullFrustum=function(t,n,r,i){var a=r._entity.layer;t.camera.cullingMask&a&&n.cullingMask&a&&r.castShadows&&e.cullingRenderBounds(r.bounds,i.cullPlaneCount,i.cullPlanes)&&(r._prepareRender(t),r._renderFrameCount=r.engine.time.frameCount)},e.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(tA.degreeToRadian(l)/2),u=c*c,d=t-e,h=t+e;u>d/h?(a=t,o=t*c):(a=.5*h*(1+u),o=.5*Math.sqrt(d*d+2*(t*t+e*e)*u+h*h*u*u));var _=i.splitBoundSphere.center;i.splitBoundSphere.radius=o,tR.scale(r,a,_),tR.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},e.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=e._frustumCorners,s=e._backPlaneFaces,l=e._frustumPlaneNeighbors,c=e._frustumTwoPlaneCorners,u=e._edgePlanePoint2,d=a.cullPlanes,h=t.getPlane(tC.Near),_=t.getPlane(tC.Far),f=t.getPlane(tC.Left),p=t.getPlane(tC.Right),m=t.getPlane(tC.Bottom),g=t.getPlane(tC.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+a.sphereCenterZ+a.splitBoundSphere.radius,_.distance),tw.intersectionPointThreePlanes(v,m,p,o[7]),tw.intersectionPointThreePlanes(v,g,p,o[6]),tw.intersectionPointThreePlanes(v,g,f,o[5]),tw.intersectionPointThreePlanes(v,m,f,o[4]),tw.intersectionPointThreePlanes(y,m,p,o[3]),tw.intersectionPointThreePlanes(y,g,p,o[2]),tw.intersectionPointThreePlanes(y,g,f,o[1]),tw.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var C=void 0;switch(b){case tC.Near:C=v;break;case tC.Far:C=y;break;default:C=t.getPlane(b)}0>tR.dot(C.normal,i)&&(d[x].copyFrom(C),s[x]=b,x++)}for(var S=x,T=0;T<x;T++)for(var A=s[T],R=l[A],E=0;E<4;E++){for(var M=R[E],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]];tR.add(L,i,u),tP.fromPoints(L,D,u,d[S++])}}a.cullPlaneCount=S},e.getDirectionalLightMatrices=function(t,n,r,i,a,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(tR.dot(u,t)*p)*m,v=Math.ceil(tR.dot(u,n)*p)*m,y=tR.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;tR.scale(r,d+a,b),tR.subtract(u,b,b),tB.lookAt(b,u,t,C),tB.ortho(-_,_,-_,_,0,2*d+a,S);var T=x.viewProjectionMatrix;tB.multiply(S,C,T),nR._floatMatrixMultiply(e._shadowMapCoordMatrix,T.elements,0,l,16*i)},e.getMaxTileResolutionInAtlas=function(e,t,n){for(var r=Math.min(e,t),i=Math.floor(e/r)*Math.floor(t/r);i<n;)i=Math.floor(e/(r=Math.floor(r>>1)))*Math.floor(t/r);return r},e.getShadowBias=function(e,t,n,r){var i=2/t.elements[0]/n,a=-e.shadowBias*i,o=-e.shadowNormalBias*i;e.shadowType==rq.SoftHigh&&(a*=2.5,o*=2.5),r.set(a,o)},e.applySliceTransform=function(t,n,r,i,a,o){var s=e._tempMatrix0,l=s.elements,c=1/n,u=1/r,d=a.x*c,h=a.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*i;nR._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,i=e-r;n.z=1/i,n.w=-r/i},e}();rY._tempMatrix0=new tB,rY._shadowMapCoordMatrix=new tB(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),rY._frustumCorners=[new tR,new tR,new tR,new tR,new tR,new tR,new tR,new tR],rY._adjustNearPlane=new tP(new tR),rY._adjustFarPlane=new tP(new tR),rY._backPlaneFaces=[,,,,,],rY._edgePlanePoint2=new tR,rY._frustumPlaneNeighbors=[[tC.Left,tC.Right,tC.Top,tC.Bottom],[tC.Left,tC.Right,tC.Top,tC.Bottom],[tC.Near,tC.Far,tC.Top,tC.Bottom],[tC.Near,tC.Far,tC.Top,tC.Bottom],[tC.Near,tC.Far,tC.Left,tC.Right],[tC.Near,tC.Far,tC.Left,tC.Right]],rY._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]]],rY.atlasBorderSize=4;var rQ=((er={})[er.NoCascades=1]="NoCascades",er[er.TwoCascades=2]="TwoCascades",er[er.FourCascades=4]="FourCascades",er),rJ=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n.engine)||this)._shadowMapSize=new tN,r._shadowBias=new tO,r._shadowSliceData=new rX,r._lightUp=new tR,r._lightSide=new tR,r._splitBoundSpheres=new Float32Array(4*t._maxCascades),r._shadowMatrices=new Float32Array((t._maxCascades+1)*16),r._shadowInfos=new tN,r._viewportOffsets=[new tO,new tO,new tO,new tO],r._camera=n,r._supportDepthTexture=n.engine._hardwareRenderer.canIUse(n$.depthTexture),r._shadowSliceData.virtualCamera.isOrthographic=!0,r}tX(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,i,a=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=a._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,R=A.z,E=A.w,M=this._shadowMapFormat;i=this._supportDepthTexture?(r=rw.recreateRenderTargetIfNeeded(a,this._renderTarget,R,E,null,M,!0,!1,1,nt.Clamp,t6.Bilinear)).depthTexture:(r=rw.recreateRenderTargetIfNeeded(a,this._renderTarget,R,E,M,null,!1,!1,1,nt.Clamp,t6.Bilinear)).getColorTexture(0),a._hardwareRenderer._isWebGL2&&(i.depthCompareFunction=t9.Less),this._renderTarget=r,this._depthTexture=i,m.activeRenderTarget(r,t._viewport,e.flipProjection,0),this._supportDepthTexture?m.clearRenderTarget(a,rF.Depth,null):m.clearRenderTarget(a,rF.All,t._clearColor),tB.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++){rY.getBoundSphereByFrustum(v[F],v[F+1],o,w,l),rY.getDirectionLightShadowCullPlanes(o._frustum,v[F],o.nearClipPlane,T,l),rY.getDirectionalLightMatrices(C,S,T,F,n.shadowNearPlaneOffset,P,l,u),g>1&&rY.applySliceTransform(P,R,E,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)rY.shadowCullFrustum(e,n,O[N],l);if(h.elements.length||_.elements.length){a._renderCount++;var V=a._batcherManager;h.sortBatch(rW.compareForOpaque,V),_.sortBatch(rW.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,nq.ShadowCaster),_.render(e,nq.ShadowCaster),m.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var n=this._camera,r=n.scene,i=this._splitBoundSpheres,a=this._shadowMatrices,o=r.shadowCascades,s=Math.min(r.shadowDistance,n.farClipPlane);if(rY.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),r.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,o>1)for(var l=4*o,c=i.length;l<c;l++)i[l]=0;for(var u=16*o,d=a.length;u<d;u++)a[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,i=r.shadowTwoCascadeSplits,a=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*tA.degreeToRadian(u)),_=1+h*h*(c*c+1);switch(o){case rQ.NoCascades:n[1]=this._getFarWithRadius(e,_);break;case rQ.TwoCascades:n[1]=this._getFarWithRadius(l+d*i,_),n[2]=this._getFarWithRadius(e,_);break;case rQ.FourCascades:n[1]=this._getFarWithRadius(l+d*a.x,_),n[2]=this._getFarWithRadius(l+d*a.y,_),n[3]=this._getFarWithRadius(l+d*a.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=rY.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=rY.shadowResolution(t.shadowResolution),i=t.shadowCascades,a=Math.min(t.shadowDistance,e.farClipPlane);if(this._getCascadesSplitDistance(a),n!==this._shadowMapFormat||r!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=r,this._shadowCascadeMode=i,i==rQ.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var o=rY.getMaxTileResolutionInAtlas(r,r,i);this._shadowTileResolution=o;var s=2*o,l=i==rQ.TwoCascades?o:2*o;this._shadowMapSize.set(1/s,1/l,s,l)}this._renderTarget=null;var c=this._viewportOffsets,u=this._shadowTileResolution;switch(i){case rQ.NoCascades:c[0].set(0,0);break;case rQ.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case rQ.FourCascades:c[0].set(0,0),c[1].set(u,0),c[2].set(0,u),c[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var i=n.virtualCamera;rY.getShadowBias(e,i.projectionMatrix,this._shadowTileResolution,this._shadowBias);var a=this._camera.scene.shaderData;a.setVector2(t._lightShadowBiasProperty,this._shadowBias),a.setVector3(t._lightDirectionProperty,e.direction),r.rendererUpdateFlag|=rG.viewProjectionMatrix,r.applyVirtualCamera(i,!0)},t}(rz);rJ._lightShadowBiasProperty=nQ.getByName("scene_ShadowBias"),rJ._lightDirectionProperty=nQ.getByName("scene_LightDirection"),rJ._shadowMatricesProperty=nQ.getByName("scene_ShadowMatrices"),rJ._shadowMapSize=nQ.getByName("scene_ShadowMapSize"),rJ._shadowInfosProperty=nQ.getByName("scene_ShadowInfo"),rJ._shadowMapsProperty=nQ.getByName("scene_ShadowMap"),rJ._shadowSplitSpheresProperty=nQ.getByName("scene_ShadowSplitSpheres"),rJ._maxCascades=4,rJ._cascadesSplitDistance=Array(rJ._maxCascades+1),rJ._viewport=new tN(0,0,1,1),rJ._clearColor=new tV(1,1,1,1),rJ._tempVector=new tR,rJ._tempMatrix0=new tB;var rZ=/*#__PURE__*/function(){function e(){this.opaqueQueue=new rW(nk.Opaque),this.transparentQueue=new rW(nk.Transparent),this.alphaTestQueue=new rW(nk.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(rW.compareForOpaque,e),this.alphaTestQueue.sortBatch(rW.compareForOpaque,e),this.transparentQueue.sortBatch(rW.compareForTransparent,e)},t.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},e}(),r$=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._supportDepthTexture=e._hardwareRenderer.canIUse(n$.depthTexture),n}tX(n,t);var r=n.prototype;return r.onConfig=function(e){var t=this.engine,n=e.pixelViewport,r=n.width,i=n.height,a=rw.recreateRenderTargetIfNeeded(t,this._renderTarget,r,i,null,t7.Depth16,!0,!1,1,nt.Clamp,t6.Point);this._renderTarget=a},r.onRender=function(t,n){var r=this.engine,i=this._renderTarget,a=t.camera,o=r._hardwareRenderer;o.activeRenderTarget(i,rw.defaultViewport,t.flipProjection,0),o.clearRenderTarget(r,rF.Depth,null),r._renderCount++,n.opaqueQueue.render(t,nq.DepthOnly),n.alphaTestQueue.render(t,nq.DepthOnly),a.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},n}(rz),r0=/*#__PURE__*/function(t){function n(e){return t.call(this,e)||this}tX(n,t);var r=n.prototype;return r.onConfig=function(e,t){this._cameraColorTexture=t;var n=e.opaqueTextureDownsampling,r=n===rB.None,i=e.pixelViewport,a=r?1:n===rB.TwoX?.5:.25,o=rw.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,i.width*a,i.height*a,e._getInternalColorTextureFormat(),null,!1,!1,1,nt.Clamp,r?t6.Point:t6.Bilinear);this._renderTarget=o},r.onRender=function(t){rj.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},n}(rz),r1=/*#__PURE__*/function(){function t(e){this._lastCanvasSize=new tO,this._internalColorTarget=null,this._canUseBlitFrameBuffer=!1,this._shouldGrabColor=!1,this._sourceScaleOffset=new tN(1,1,0,0),this._camera=e;var t=e.engine;this._cullingResults=new rZ,this._cascadedShadowCasterPass=new rJ(e),this._depthOnlyPass=new r$(t),this._opaqueTexturePass=new r0(t)}var n=t.prototype;return n.destroy=function(){this._cullingResults.destroy(),this._camera=null},n.render=function(t,n,r,i){t.rendererUpdateFlag=rG.All;var a=this._camera,o=a.scene,s=a.engine,l=s._hardwareRenderer,c=this._cullingResults,u=o._lightManager._sunlight,d=this._depthOnlyPass,h=a.depthTextureMode===rD.PrePass&&d._supportDepthTexture,_=a.clearFlags&~(null!=i?i:rF.None),f=a.independentCanvasEnabled,p=a.renderTarget?a.renderTarget.antiAliasing:a.msaaSamples;this._shouldGrabColor=f&&!(_&rF.Color),this._canUseBlitFrameBuffer=l.isWebGL2&&1===p&&(!!a.renderTarget||!l.context.antialias),o.castShadows&&u&&u.shadowType!==rq.None&&(this._cascadedShadowCasterPass.onRender(t),t.rendererUpdateFlag=rG.None);var m=s._batcherManager;if(c.reset(),t.rendererUpdateFlag|=rG.viewProjectionMatrix,t.applyVirtualCamera(a._virtualCamera,h),this._prepareRender(t),c.sortBatch(m),m.uploadBuffer(),h?(d.onConfig(a),d.onRender(t,c),t.rendererUpdateFlag=rG.None):a.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),f){y=a.renderTarget?a.renderTarget._depthFormat:l.context.depth&&l.context.stencil?t7.Depth24Stencil8:l.context.depth?t7.Depth24:l.context.stencil?t7.Stencil:null;var g=a.pixelViewport,v=rw.recreateRenderTargetIfNeeded(s,this._internalColorTarget,g.width,g.height,a._getInternalColorTextureFormat(),y,!1,!1,p,nt.Clamp,t6.Bilinear);if(!this._canUseBlitFrameBuffer&&this._shouldGrabColor){var y,x,b,C=rw.recreateTextureIfNeeded(s,this._grabTexture,g.width,g.height,null!=(b=null==(x=a.renderTarget)?void 0:x.getColorTexture(0).format)?b:t7.R8G8B8A8,!1,nt.Clamp,t6.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,a,_,n,r)},n._drawRenderPass=function(t,n,r,i,a){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?rw.defaultViewport:n.viewport,g=!!f||n.renderTarget&&void 0==i;t.flipProjection!==g&&(t.rendererUpdateFlag|=rG.ProjectionMatrix,t.applyVirtualCamera(n._virtualCamera,g)),_.activeRenderTarget(p,m,t.flipProjection,a,i);var v=h.solidColor;if(f&&r!==rF.All){if(this._canUseBlitFrameBuffer)r!==rF.None&&_.clearRenderTarget(u,r,v),_.blitInternalRTByBlitFrameBuffer(n.renderTarget,f,r,n.viewport);else if(r&rF.Depth&&r&rF.Stencil||nl.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,rF.DepthStencil),_.copyRenderTargetToSubTexture(n.renderTarget,this._grabTexture,n.viewport);var y=this._sourceScaleOffset;y.y=n.renderTarget?1:-1,y.w=n.renderTarget?0:1,rj.blitTexture(u,this._grabTexture,f,0,void 0,void 0,void 0,y)}else _.clearRenderTarget(u,rF.All,v);_.activeRenderTarget(p,m,t.flipProjection,a,i)}else r!==rF.None&&_.clearRenderTarget(u,r,v);var x=d._maskManager;if(r&rF.Stencil&&(x.hasStencilWritten=!1),s.render(t,nq.Forward),l.render(t,nq.Forward),r&rF.Color&&(h.mode===rV.Sky?h.sky._render(t):h.mode===rV.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,i)}else n.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);c.render(t,nq.Forward),x.clearMask(t,nq.Forward);var C=d.postProcessManager,S=n.renderTarget;n.enablePostProcess&&C._isValid()?C._render(n,f,S):(C._releaseSwapRenderTarget(),f&&(f._blitRenderTarget(),rj.blitTexture(u,f.getColorTexture(0),S,0,n.viewport))),null==S||S._blitRenderTarget(),null==S||S.generateMipmaps()},n.pushRenderElement=function(e,t){t.renderQueueFlags=0;for(var n=t.subRenderElements,r=0,i=n.length;r<i;++r){var a=n[r],o=a.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,a,p.passes,s),h=!0)}h||e.replacementFailureStrategy!==rO.KeepOriginalShader||this.pushRenderElementByType(t,a,l.passes,s)}else this.pushRenderElementByType(t,a,u[0].passes,s)}else this.pushRenderElementByType(t,a,l.passes,s)}},n.pushRenderElementByType=function(e,t,n,r){for(var i=this._cullingResults,a=0,o=n.length;a<o;a++){var s=void 0,l=n[a],c=l._renderState,u=1<<(s=c?c._getRenderQueueByShaderData(l._renderStateDataMap,t.material.shaderData):r[a].renderQueueType);if(t.shaderPasses=n,t.renderQueueFlags|=u,!(e.renderQueueFlags&u)){switch(s){case nk.Opaque:i.opaqueQueue.pushRenderElement(e);break;case nk.AlphaTest:i.alphaTestQueue.pushRenderElement(e);break;case nk.Transparent:i.transparentQueue.pushRenderElement(e)}e.renderQueueFlags|=u}}},n._drawBackgroundTexture=function(e,t){var n=e.engine,r=n._hardwareRenderer,i=n.canvas,a=t._material,o=t._mesh;(this._lastCanvasSize.x!==i.width||this._lastCanvasSize.y!==i.height)&&t._textureFillMode!==rk.Fill&&(this._lastCanvasSize.set(i.width,i.height),t._resizeBackgroundTexture());var s=a.shader.subShaders[0].passes[0],l=s._getShaderProgram(n,rl._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,a.shaderData),l.uploadAll(l.cameraUniformBlock,e.shaderData),l.uploadUnGroupTextures(),(s._renderState||a.renderState)._applyStates(n,!1,s._renderStateDataMap,a.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,i=r._elements,a=r.length-1;a>=0;--a){var o=i[a];t.cullingMask&o._entity.layer&&(!t.enableFrustumCulling||t._frustum.intersectsBox(o.bounds))&&(o._prepareRender(e),o._renderFrameCount=n.time.frameCount)}},t}(),r2=((ei={})[ei.None=0]="None",ei[ei.Opaque=1]="Opaque",ei[ei.AlphaTest=2]="AlphaTest",ei[ei.Transparent=4]="Transparent",ei[ei.All=7]="All",ei),r3=/*#__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}(),r4=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.set=function(e,t,n,r,i,a){this.component=e,this.material=t,this.primitive=n,this.subPrimitive=r,this.texture=i,this.subChunk=a},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}(),r8=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).influenceLayers=ry.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,rC.resetData(r),r.setMaterial(r._engine._basicResources.spriteMaskDefaultMaterial),r.shaderData.setFloat(t._alphaCutoffProperty,r._alphaCutoff),r._renderElement=new r3,r._renderElement.addSubRenderElement(new r4),r._onSpriteChange=r._onSpriteChange.bind(r),r}tX(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 ru.canBatchSpriteMask(e,t)},n._batch=function(e,t){ru.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?rC.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&rx.WorldVolume&&(rC.updatePositions(this),this._dirtyUpdateFlag&=~rx.WorldVolume),2&this._dirtyUpdateFlag&&(rC.updateUVs(this),this._dirtyUpdateFlag&=-3);var i=this._renderElement,a=i.subRenderElements[0];i.set(this.priority,this._distanceForSort);var o=this._subChunk;a.set(this,n,o.chunk.primitive,o.subMesh,this.sprite.texture,o),a.shaderPasses=n.shader.subShaders[0].passes,a.renderQueueFlags=r2.All,i.addSubRenderElement(a)}}},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 nF.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nF.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rx.WorldVolume);break;case nF.region:case nF.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case nF.atlasRegion:this._dirtyUpdateFlag|=2;break;case nF.pivot:this._dirtyUpdateFlag|=rx.WorldVolume;break;case nF.destroy:this.sprite=null}},tW(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|=rx.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|=rx.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rx.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rx.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);r8._textureProperty=nQ.getByName("renderer_MaskTexture"),r8._alphaCutoffProperty=nQ.getByName("renderer_MaskAlphaCutoff"),tq([tZ],r8.prototype,"influenceLayers",void 0),tq([tJ],r8.prototype,"_renderElement",void 0),tq([tJ],r8.prototype,"_subChunk",void 0),tq([tJ],r8.prototype,"_maskIndex",void 0),tq([tJ],r8.prototype,"_sprite",void 0),tq([tJ],r8.prototype,"_automaticWidth",void 0),tq([tJ],r8.prototype,"_automaticHeight",void 0),tq([tZ],r8.prototype,"_customWidth",void 0),tq([tZ],r8.prototype,"_customHeight",void 0),tq([tZ],r8.prototype,"_flipX",void 0),tq([tZ],r8.prototype,"_flipY",void 0),tq([tZ],r8.prototype,"_alphaCutoff",void 0),tq([tJ],r8.prototype,"_onSpriteChange",null);var r5=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._textChunks=[],n._subFont=null,n._dirtyFlag=15,n._color=new tV(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new tM,n._font=null,n._fontSize=24,n._fontStyle=np.None,n._lineSpacing=0,n._horizontalAlignment=nb.Center,n._verticalAlignment=nC.Center,n._enableWrapping=!1,n._overflowMode=nm.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}tX(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 ru.canBatchSprite(e,t)},n._batch=function(e,t){ru.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){tM.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,i=r._textSubRenderElementPool,a=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,_=i.get();_.set(this,a,d.chunk.primitive,d.subMesh,h,d),_.shaderData||(_.shaderData=new rc(n9.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=ng.getNativeFontString(e.name,this.fontSize,this.fontStyle)},n._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,n=e[0],r=e[1],i=e[2],a=e[4],o=e[5],s=e[6],l=e[12],c=e[13],u=e[14],d=t._tempVec31.set(a,o,s),h=t._tempVec30.set(n,r,i),_=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 R=S[T],E=R.localPositions,M=E.x,w=E.y;f.set(M*n+w*a+l,M*r+w*o+c,M*i+w*s+u),tR.scale(h,E.z-M,p),tR.add(f,p,p),tR.scale(d,E.w-w,m),tR.add(f,m,g),tR.add(p,m,m);for(var P=C.chunk.vertices,F=0,L=C.vertexArea.start+36*R.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,i=e.a,a=this._textChunks,o=0,s=a.length;o<s;++o)for(var l=a[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]=i},n._updateLocalData=function(){var e=this._localBounds,n=e.min,r=e.max,i=t._charRenderInfos,a=this._subFont,o=this.enableWrapping?ng.measureTextWithWrap(this):ng.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=on._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 nC.Top:b=.5*y-x+C;break;case nC.Center:b=.5*s-x-(S-C)*.5;break;case nC.Bottom:b=s-.5*y-x-S}for(var T=-1,A=Number.MAX_SAFE_INTEGER,R=Number.MAX_SAFE_INTEGER,E=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 nb.Left:L=-v;break;case nb.Center:L=-(.5*P);break;case nb.Right:L=v-P}for(var B=0,I=F.length;B<I;++B){var O=F[B],N=a._getCharInfo(O);if(N.h>0){D<0&&(D=B);var V=i[f++]=h.get(),k=V.localPositions;V.texture=a._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)),R=Math.min(R,X),B===D&&(A=Math.min(A,H)),E=Math.max(E,W)}L+=N.xAdvance+N.offsetX}}b-=u}T<0?(n.set(0,0,0),r.set(0,0,0)):(n.set(A,R,0),r.set(E,M,0))}else n.set(0,0,0),r.set(0,0,0);if(a._getLastIndex()>0&&i.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId}),this._freeTextChunks(),0!==f){var K=this._textChunks,q=new r9;K.push(q);var Y=this._getChunkManager().maxVertexCount,Q=i[0],J=Q.texture;q.texture=J;var Z=q.charRenderInfos;Z.push(Q);for(var $=1;$<f;++$){var ee=i[$],et=ee.texture;(J!==et||4*Z.length+4>Y)&&(this._buildChunk(q,Z.length),q=new r9,K.push(q),J=et,q.texture=et,Z=q.charRenderInfos),Z.push(ee)}var en=Z.length;en>0&&this._buildChunk(q,en),i.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===nm.Truncate&&this.height<=0},n._buildChunk=function(e,t){for(var n=this.color,r=n.r,i=n.g,a=n.b,o=n.a,s=tK.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]=i,u[m+4]=a,u[m+5]=o}return c},n._freeTextChunks=function(){for(var e=this._textChunks,t=this.engine._charRenderInfoPool,n=this._getChunkManager(),r=0,i=e.length;r<i;++r){for(var a=e[r],o=a.charRenderInfos,s=0,l=o.length;s<l;++s)t.return(o[s]);o.length=0,n.freeSubChunk(a.subChunk),a.subChunk=null,a.texture=null}e.length=0},n._onColorChanged=function(){this._setDirtyFlagTrue(16)},tW(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);r5._textureProperty=nQ.getByName("renderElement_TextTexture"),r5._tempVec30=new tR,r5._tempVec31=new tR,r5._worldPositions=[new tR,new tR,new tR,new tR],r5._charRenderInfos=[],tq([tJ],r5.prototype,"_textChunks",void 0),tq([tZ],r5.prototype,"_subFont",void 0),tq([tJ],r5.prototype,"_dirtyFlag",void 0),tq([t0],r5.prototype,"_color",void 0),tq([tZ],r5.prototype,"_text",void 0),tq([tZ],r5.prototype,"_width",void 0),tq([tZ],r5.prototype,"_height",void 0),tq([tJ],r5.prototype,"_localBounds",void 0),tq([tZ],r5.prototype,"_font",void 0),tq([tZ],r5.prototype,"_fontSize",void 0),tq([tZ],r5.prototype,"_fontStyle",void 0),tq([tZ],r5.prototype,"_lineSpacing",void 0),tq([tZ],r5.prototype,"_horizontalAlignment",void 0),tq([tZ],r5.prototype,"_verticalAlignment",void 0),tq([tZ],r5.prototype,"_enableWrapping",void 0),tq([tZ],r5.prototype,"_overflowMode",void 0),tq([tJ],r5.prototype,"_onColorChanged",null);var r9=function(){this.charRenderInfos=[]},r6=((ea={})[ea.Static=0]="Static",ea[ea.Dynamic=1]="Dynamic",ea[ea.Stream=2]="Stream",ea),r7=((eo={})[eo.None=0]="None",eo[eo.Discard=1]="Discard",eo),ie=/*#__PURE__*/function(e){function t(t,n,r,i,a){if(void 0===i&&(i=r6.Static),void 0===a&&(a=!1),(o=e.call(this,t)||this)._dataUpdateManager=new nP,o._engine=t,o._type=n,o._bufferUsage=i,o._readable=a,"number"==typeof r)o._byteLength=r,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,r,i),a&&(o._data=new Uint8Array(r));else{var o,s=r.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,s,i,r),a){var l=r.constructor===ArrayBuffer?r.slice(0):r.buffer.slice(r.byteOffset,r.byteOffset+s);o._data=new Uint8Array(l)}}return o}tX(t,e);var n=t.prototype;return n.bind=function(){this._platformBuffer.bind()},n.setData=function(e,t,n,r,i){if(void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=r7.None),this._platformBuffer.setData(this._byteLength,e,t,n,r,i),this._readable){var a=e.constructor===ArrayBuffer?e:e.buffer;if(this._data.buffer!==a){var o=e.BYTES_PER_ELEMENT||1,s=r?o*r:e.byteLength,l=new Uint8Array(a,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()},tW(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}(nn),it=((es={})[es.UInt8=0]="UInt8",es[es.UInt16=1]="UInt16",es[es.UInt32=2]="UInt32",es),ir=((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),ii=/*#__PURE__*/function(){function e(){}return e._getGLIndexType=function(e){switch(e){case it.UInt8:return nZ.UNSIGNED_BYTE;case it.UInt16:return nZ.UNSIGNED_SHORT;case it.UInt32:return nZ.UNSIGNED_INT}},e._getGLIndexByteCount=function(e){switch(e){case it.UInt8:return 1;case it.UInt16:return 2;case it.UInt32:return 4}},e._getElementInfo=function(e){var t,n,r,i=!1;switch(e){case ir.Float:t=1,n=nZ.FLOAT;break;case ir.Vector2:t=2,n=nZ.FLOAT;break;case ir.Vector3:t=3,n=nZ.FLOAT;break;case ir.Vector4:t=4,n=nZ.FLOAT;break;case ir.Byte4:t=4,n=nZ.BYTE;break;case ir.UByte4:t=4,n=nZ.UNSIGNED_BYTE;break;case ir.NormalizedByte4:t=4,n=nZ.BYTE,i=!0,r=1/127;break;case ir.NormalizedUByte4:t=4,n=nZ.UNSIGNED_BYTE,i=!0,r=1/255;break;case ir.Short2:t=2,n=nZ.SHORT;break;case ir.UShort2:t=2,n=nZ.UNSIGNED_SHORT;break;case ir.NormalizedShort2:t=2,n=nZ.SHORT,i=!0,r=1/32767;break;case ir.NormalizedUShort2:t=2,n=nZ.UNSIGNED_SHORT,i=!0,r=1/65535;break;case ir.Short4:t=4,n=nZ.SHORT;break;case ir.UShort4:t=4,n=nZ.UNSIGNED_SHORT;break;case ir.NormalizedShort4:t=4,n=nZ.SHORT,i=!0,r=1/32767;break;case ir.NormalizedUShort4:t=4,n=nZ.UNSIGNED_SHORT,i=!0,r=1/65535}return{size:t,type:n,normalized:i,normalizedScaleFactor:r}},e}(),ia=/*#__PURE__*/function(){function e(e,t,n,r,i){void 0===i&&(i=0),this._attributeName=e,this._offset=t,this._format=n,this._bindingIndex=r,this._formatMetaInfo=ii._getElementInfo(this.format),this._instanceStepRate=Math.floor(i)}return tW(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}(),io=((ec={})[ec.VertexBuffer=0]="VertexBuffer",ec[ec.IndexBuffer=1]="IndexBuffer",ec),is=((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),il=((ed={})[ed.Normal=0]="Normal",ed[ed.Additive=1]="Additive",ed),ic=((eh={})[eh.Front=0]="Front",eh[eh.Back=1]="Back",eh[eh.Double=2]="Double",eh),iu=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._renderStates=[],r._shaderData=new rc(n9.Material),r.shader=n,r}tX(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),t1.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},tW(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,i=r.length,a=0,o=e.subShaders,s=0;s<o.length;s++)a=Math.max(o[s].passes.length,a);if(i<a)for(var l=i;l<a;l++)r.push(new rs);else r.length=a}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t}(t3),id=/*#__PURE__*/function(e){function t(n,r){(i=e.call(this,n,r)||this)._renderFace=ic.Front,i._isTransparent=!1,i._blendMode=il.Normal;var i,a=i.shaderData;return a.setFloat(t._alphaCutoffProp,0),a.setFloat(t._shadowCasterRenderQueueProp,nk.Opaque),i}tX(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 i=r[e],a=this.shaderData;n?(i.blendState.targetBlendState.enabled=!0,i.depthState.writeEnabled=!1,i.renderQueueType=nk.Transparent,a.enableMacro(t._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=a.getFloat(t._alphaCutoffProp)?nk.AlphaTest:nk.Opaque,a.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 il.Normal:r.sourceColorBlendFactor=nD.SourceAlpha,r.destinationColorBlendFactor=nD.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=nD.One,r.destinationAlphaBlendFactor=nD.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nB.Add;break;case il.Additive:r.sourceColorBlendFactor=nD.SourceAlpha,r.destinationColorBlendFactor=nD.One,r.sourceAlphaBlendFactor=nD.One,r.destinationAlphaBlendFactor=nD.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nB.Add}},n.setRenderFace=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";switch(t){case ic.Front:n[e].rasterState.cullMode=nN.Back;break;case ic.Back:n[e].rasterState.cullMode=nN.Front;break;case ic.Double:n[e].rasterState.cullMode=nN.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},n._seIsTransparent=function(e){if(e!==this._isTransparent){this.setIsTransparent(0,e);var n=this.shaderData;e?n.setFloat(t._shadowCasterRenderQueueProp,nk.AlphaTest):n.getFloat(t._alphaCutoffProp)?n.setFloat(t._shadowCasterRenderQueueProp,nk.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nk.Opaque),this._isTransparent=e}},n._setAlphaCutoff=function(e){var n=this.shaderData;if(n.getFloat(t._alphaCutoffProp)!==e){e?(n.enableMacro(t._alphaCutoffMacro),n.setFloat(t._shadowCasterRenderQueueProp,nk.AlphaTest)):(n.disableMacro(t._alphaCutoffMacro),this._isTransparent?n.setFloat(t._shadowCasterRenderQueueProp,nk.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nk.Opaque));for(var r=this.renderStates,i=0,a=r.length;i<a;i++){var o=r[i];e>0?o.renderQueueType=o.blendState.targetBlendState.enabled?nk.Transparent:nk.AlphaTest:o.renderQueueType=o.blendState.targetBlendState.enabled?nk.Transparent:nk.Opaque}n.setFloat(t._alphaCutoffProp,e)}},tW(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,i=r.length,a=0,o=e.subShaders,s=0;s<o.length;s++)a=Math.max(o[s].passes.length,a);if(i<a)for(var l=i;l<a;l++)r.push(new rs),this.setBlendMode(l,il.Normal);else r.length=a}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){this._seIsTransparent(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){this._setAlphaCutoff(e)}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),t}(iu);id._shadowCasterRenderQueueProp=nQ.getByName("material_ShadowCasterRenderQueue"),id._baseTextureMacro=nj.getByName("MATERIAL_HAS_BASETEXTURE"),id._normalTextureMacro=nj.getByName("MATERIAL_HAS_NORMALTEXTURE"),id._emissiveTextureMacro=nj.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),id._transparentMacro=nj.getByName("MATERIAL_IS_TRANSPARENT"),id._baseColorProp=nQ.getByName("material_BaseColor"),id._baseTextureProp=nQ.getByName("material_BaseTexture"),id._tilingOffsetProp=nQ.getByName("material_TilingOffset"),id._normalTextureProp=nQ.getByName("material_NormalTexture"),id._normalIntensityProp=nQ.getByName("material_NormalIntensity"),id._emissiveColorProp=nQ.getByName("material_EmissiveColor"),id._emissiveTextureProp=nQ.getByName("material_EmissiveTexture"),id._alphaCutoffProp=nQ.getByName("material_AlphaCutoff"),id._alphaCutoffMacro=nj.getByName("MATERIAL_IS_ALPHA_CUTOFF");var ih=/*#__PURE__*/function(e){function t(n){var r,i=(r=e.call(this,n,rl.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tV(1,1,1,1)),i.setColor(t._specularColorProp,new tV(1,1,1,1)),i.setColor(t._emissiveColorProp,new tV(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tN(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return tX(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tW(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}(id);ih._specularColorProp=nQ.getByName("material_SpecularColor"),ih._shininessProp=nQ.getByName("material_Shininess"),ih._specularTextureProp=nQ.getByName("material_SpecularTexture");var i_=((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_),ip=/*#__PURE__*/function(e){function t(n,r){var i,a=(i=e.call(this,n,r)||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new tV(1,1,1,1)),a.setColor(t._emissiveColorProp,new tV(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new tN(1,1,0,0)),a.setFloat(t._normalIntensityProp,1),a.setFloat(t._occlusionTextureIntensityProp,1),a.setFloat(t._occlusionTextureCoordProp,i_.UV0),a.setFloat(t._clearCoatProp,0),a.setFloat(t._clearCoatRoughnessProp,0),i}return tX(t,e),tW(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>i_.UV1&&nl.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}(id);ip._occlusionTextureIntensityProp=nQ.getByName("material_OcclusionIntensity"),ip._occlusionTextureCoordProp=nQ.getByName("material_OcclusionTextureCoord"),ip._occlusionTextureProp=nQ.getByName("material_OcclusionTexture"),ip._clearCoatProp=nQ.getByName("material_ClearCoat"),ip._clearCoatTextureProp=nQ.getByName("material_ClearCoatTexture"),ip._clearCoatRoughnessProp=nQ.getByName("material_ClearCoatRoughness"),ip._clearCoatRoughnessTextureProp=nQ.getByName("material_ClearCoatRoughnessTexture"),ip._clearCoatNormalTextureProp=nQ.getByName("material_ClearCoatNormalTexture");var im=((ef={})[ef.Sphere=0]="Sphere",ef[ef.Planar=1]="Planar",ef),ig=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n,rl.find("pbr"))||this)._anisotropyRotation=0,r._iridescenceRange=new tO(100,400),r._sheenEnabled=!1;var r,i=r.shaderData;i.setFloat(t._metallicProp,1),i.setFloat(t._roughnessProp,1),i.setFloat(t._iorProp,1.5),i.setVector3(t._anisotropyInfoProp,new tR(1,0,0)),i.setVector4(t._iridescenceInfoProp,new tN(0,1.3,100,400));var a=new tV(0,0,0);i.setColor(t._sheenColorProp,a),r.refractionMode=im.Planar,i.setFloat(t._transmissionProp,0),i.setFloat(t._thicknessProp,0),i.setFloat(t._attenuationDistanceProp,1/0);var o=new tV(1,1,1);return i.setColor(t._attenuationColorProp,o),r._iridescenceRange._onValueChanged=r._onIridescenceRangeChanged.bind(r),a._onValueChanged=r._onSheenColorChanged.bind(r),r}tX(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},n._onIridescenceRangeChanged=function(){var e=this.shaderData.getVector4(t._iridescenceInfoProp);e.z=this._iridescenceRange.x,e.w=this._iridescenceRange.y},n._onSheenColorChanged=function(){var e=this.sheenColor,t=e.r+e.g+e.b>0;t!==this._sheenEnabled&&(this._sheenEnabled=t,t?this.shaderData.enableMacro("MATERIAL_ENABLE_SHEEN"):this.shaderData.disableMacro("MATERIAL_ENABLE_SHEEN"))},tW(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=tA.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")}},{key:"refractionMode",get:function(){return this._refractionMode},set:function(e){e!==this._refractionMode&&(this._refractionMode=e,this.shaderData.enableMacro("REFRACTION_MODE",e.toString()))}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){this._seIsTransparent(e),this.transmission>0&&(this.renderState.renderQueueType=nk.Transparent)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(id._alphaCutoffProp)},set:function(e){this._setAlphaCutoff(e),this.transmission>0&&(this.renderState.renderQueueType=nk.Transparent)}},{key:"transmission",get:function(){return this.shaderData.getFloat(t._transmissionProp)},set:function(e){e=tA.clamp(e,0,1),!!this.shaderData.getFloat(t._transmissionProp)!=!!e&&(e>0?(this.shaderData.enableMacro(t._transmissionMacro),this.renderState.renderQueueType=nk.Transparent):this.shaderData.disableMacro(t._transmissionMacro)),this.shaderData.setFloat(t._transmissionProp,e)}},{key:"transmissionTexture",get:function(){return this.shaderData.getTexture(t._transmissionTextureProp)},set:function(e){this.shaderData.setTexture(t._transmissionTextureProp,e),e?this.shaderData.enableMacro(t._transmissionTextureMacro):this.shaderData.disableMacro(t._transmissionTextureMacro)}},{key:"attenuationColor",get:function(){return this.shaderData.getColor(t._attenuationColorProp)},set:function(e){var n=this.shaderData.getColor(t._attenuationColorProp);e!==n&&n.copyFrom(e)}},{key:"attenuationDistance",get:function(){return this.shaderData.getFloat(t._attenuationDistanceProp)},set:function(e){e=Math.max(0,e),this.shaderData.setFloat(t._attenuationDistanceProp,e)}},{key:"thickness",get:function(){return this.shaderData.getFloat(t._thicknessProp)},set:function(e){e=Math.max(0,e),!!this.shaderData.getFloat(t._thicknessProp)!=!!e&&(e>0?this.shaderData.enableMacro(t._thicknessMacro):this.shaderData.disableMacro(t._thicknessMacro)),this.shaderData.setFloat(t._thicknessProp,e)}},{key:"thicknessTexture",get:function(){return this.shaderData.getTexture(t._thicknessTextureProp)},set:function(e){this.shaderData.setTexture(t._thicknessTextureProp,e),e?this.shaderData.enableMacro(t._thicknessTextureMacro):this.shaderData.disableMacro(t._thicknessTextureMacro)}}]),t}(ip);ig._metallicProp=nQ.getByName("material_Metal"),ig._roughnessProp=nQ.getByName("material_Roughness"),ig._roughnessMetallicTextureProp=nQ.getByName("material_RoughnessMetallicTexture"),ig._iorProp=nQ.getByName("material_IOR"),ig._anisotropyInfoProp=nQ.getByName("material_AnisotropyInfo"),ig._anisotropyTextureProp=nQ.getByName("material_AnisotropyTexture"),ig._iridescenceInfoProp=nQ.getByName("material_IridescenceInfo"),ig._iridescenceThicknessTextureProp=nQ.getByName("material_IridescenceThicknessTexture"),ig._iridescenceTextureProp=nQ.getByName("material_IridescenceTexture"),ig._sheenColorProp=nQ.getByName("material_SheenColor"),ig._sheenRoughnessProp=nQ.getByName("material_SheenRoughness"),ig._sheenTextureProp=nQ.getByName("material_SheenTexture"),ig._sheenRoughnessTextureProp=nQ.getByName("material_SheenRoughnessTexture"),ig._transmissionMacro=nj.getByName("MATERIAL_ENABLE_TRANSMISSION"),ig._thicknessMacro=nj.getByName("MATERIAL_HAS_THICKNESS"),ig._thicknessTextureMacro=nj.getByName("MATERIAL_HAS_THICKNESS_TEXTURE"),ig._transmissionTextureMacro=nj.getByName("MATERIAL_HAS_TRANSMISSION_TEXTURE"),ig._transmissionProp=nQ.getByName("material_Transmission"),ig._transmissionTextureProp=nQ.getByName("material_TransmissionTexture"),ig._attenuationColorProp=nQ.getByName("material_AttenuationColor"),ig._attenuationDistanceProp=nQ.getByName("material_AttenuationDistance"),ig._thicknessProp=nQ.getByName("material_Thickness"),ig._thicknessTextureProp=nQ.getByName("material_ThicknessTexture");var iv=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,rl.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new tV(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return tX(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tW(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}(ip);iv._specularColorProp=nQ.getByName("material_PBRSpecularColor"),iv._glossinessProp=nQ.getByName("material_Glossiness"),iv._specularGlossinessTextureProp=nQ.getByName("material_SpecularGlossinessTexture"),iv._specularGlossinessTextureMacro=nj.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var iy=/*#__PURE__*/function(e){function t(n){var r,i=(r=e.call(this,n,rl.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tV(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new tN(1,1,0,0)),r}return tX(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tW(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}(id),ix=/*#__PURE__*/function(){function e(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new nP,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},tW(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}(),ib=((ep={})[ep.Position=1]="Position",ep[ep.Normal=2]="Normal",ep[ep.Tangent=4]="Tangent",ep[ep.All=7]="All",ep),iC=/*#__PURE__*/function(){function e(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new nP,this._dataChangeManager=new nP,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 i=new ix(e,t,n,r);return this._addFrame(i),i}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(ib.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()},tW(e,[{key:"frames",get:function(){return this._frames}}]),e}(),iS=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._format=t}return tW(e,[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),e}(),iT=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=is.Triangles),this.start=e,this.count=t,this.topology=n},iA=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tX(t,e),t.prototype.dispose=function(){},t}(iT),iR=/*#__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}tX(t,e);var n=t.prototype;return n.addVertexElement=function(e){var t=this._vertexElementMap,n=this._vertexElements,r=e.attribute,i=t[r];i&&(console.warn("VertexElement "+r+" already exists."),n.splice(n.indexOf(i),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,i=r[e];i&&delete n[i.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,i=n.length;r<i;r++){var a=n[r];delete t[a.attribute]}n.length=e},n.setVertexBufferBinding=function(e,t){var n,r=this._getReferCount(),i=this.vertexBufferBindings;r>0&&(null==(n=i[e])||n.buffer._addReferCount(-r),null==t||t.buffer._addReferCount(r)),i[e]=t,this._bufferStructChanged=!0},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this.vertexBufferBindings,r=e.length,i=t+r;n.length<i&&(n.length=i);for(var a=0;a<r;a++)this.setVertexBufferBinding(t+a,e[a])},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=ii._getGLIndexType(e.format),this._glIndexByteCount=ii._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,i=this.vertexBufferBindings,a=0,o=i.length;a<o;a++)null==(r=i[a])||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},tW(t,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t}(nn),iE=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._updateFlagManager=new nP,r._bounds=new tM,r._subMeshes=[],r.name=n,r._primitive=new iR(t),r._onBoundsChanged=r._onBoundsChanged.bind(r);var r,i=r._bounds;return i.min._onValueChanged=r._onBoundsChanged,i.max._onValueChanged=r._onBoundsChanged,r}tX(t,e);var n=t.prototype;return n.addSubMesh=function(e,t,n){return void 0===n&&(n=is.Triangles),"number"==typeof e&&(e=new iA(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)},tW(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}(t3),iM=((em={})[em.Bounds=1]="Bounds",em[em.VertexElements=2]="VertexElements",em),iw=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._stride=t}return tW(e,[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),e}(),iP=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}tX(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,i=void 0!==r.buffer;i||(r=new iw(e,t));var a=this._primitive.vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this._primitive.vertexBufferBindings,r=e.length,i=t+r;n.length<i&&(n.length=i);for(var a=0;a<r;a++)this._setVertexBufferBinding(t+a,e[a])},n.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new iS(e,t))),this._setIndexBufferBinding(n)},tW(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}(iE),iF=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._enableVertexColor=!1,n._onMeshChanged=n._onMeshChanged.bind(n),n}tX(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){nl.error("mesh is null.");return}if(this._mesh.destroyed){nl.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;tM.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,i=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 a=0,o=i.length;a<o;a++)switch(i[a].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&iM.Bounds&&(this._dirtyUpdateFlag|=rx.WorldVolume),e&iM.VertexElements&&(this._dirtyUpdateFlag|=2)},tW(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);iF._uvMacro=nj.getByName("RENDERER_HAS_UV"),iF._uv1Macro=nj.getByName("RENDERER_HAS_UV1"),iF._normalMacro=nj.getByName("RENDERER_HAS_NORMAL"),iF._tangentMacro=nj.getByName("RENDERER_HAS_TANGENT"),iF._enableVertexColorMacro=nj.getByName("RENDERER_ENABLE_VERTEXCOLOR"),tq([tJ],iF.prototype,"_mesh",void 0),tq([tJ],iF.prototype,"_onMeshChanged",null);var iL=/*#__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 tN,this._canUseTextureStoreData=!0,this._dataTextureInfo=new tR,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(rm))},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,i=0,a=r.length;i<a;i++)r[i].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 i=this._getVertexBufferModeSupportCount();if(r>i){var a=n._condensedBlendShapeWeights;a||(a=new Float32Array(i),n._condensedBlendShapeWeights=a),this._filterCondensedBlendShapeWeights(n.blendShapeWeights,a),t.setFloatArray(e._blendShapeWeightsProperty,a),this._modelMesh._primitive.enableVAO=!1,r=i}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,i=Math.max(n.length,t+1);r<i&&(n[r]||r===t);r++);this._bufferBindingOffset=r}},t._addVertexElements=function(e){this._updateVertexBufferIndex();for(var t=this._vertexElementOffset,n=this._bufferBindingOffset,r=0,i=0,a=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());i<a;i++)e._setVertexElement(t++,new ia("POSITION_BS"+i,r,ir.Vector3,n)),r+=12,this._useBlendNormal&&(e._setVertexElement(t++,new ia("NORMAL_BS"+i,r,ir.Vector3,n)),r+=12),this._useBlendTangent&&(e._setVertexElement(t++,new ia("TANGENT_BS"+i,r,ir.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,i=this._blendShapeCount,a=this._vertexBuffers,o=3*this._vertexElementCount,s=4*o,l=Math.floor(255/s),c=Math.ceil(i/l),u=o*e*Math.min(l,i);a.length=c,this._vertices=new Float32Array(u),this._maxCountSingleVertexBuffer=l,this._storeInVertexBufferInfo.length=i;for(var d=this._bufferBindingOffset,h=0;h<c;h++){var _=c-1,f=(h===_?i-_*l:l)*s,p=f*e,m=t?r6.Static:r6.Dynamic,g=new ie(n,io.VertexBuffer,p,m);r._setVertexBufferBinding(d+h,new iw(g,f)),a[h]=g}},t._createTextureArray=function(e){var t=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,r=n*e,i=1;r>t&&(i=Math.ceil(r/t),r=t);var a=this._vertexTexture,o=this._blendShapes.length;a&&a.destroy(),(a=new nh(this._engine,r,i,o,t7.R32G32B32A32,!1)).filterMode=t6.Point,this._vertices=new Float32Array(o*r*i*4),this._vertexTexture=a,this._dataTextureInfo.set(n,r,i)},t._updateVertexBuffers=function(e,t){for(var n=this._blendShapes,r=this._maxCountSingleVertexBuffer,i=this._vertices,a=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,u=this._bufferBindingOffset,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=a[g],x=y.byteLength/(4*e),b=v*l,C=o[d];C||(o[d]=C=new tO),C.set(u+g,v*c);for(var S=m.deltaPositions,T=0;T<e;T++){var A=b+x*T,R=S[T];R&&(i[A]=R.x,i[A+1]=R.y,i[A+2]=R.z)}if(b+=3,this._useBlendNormal){var E=m.deltaNormals;if(E)for(var M=0;M<e;M++){var w=b+x*M,P=E[M];P&&(i[w]=P.x,i[w+1]=P.y,i[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&&(i[D]=B.x,i[D+1]=B.y,i[D+2]=B.z)}b+=3}(v===r-1||d===h-1)&&y.setData(i,0,0,y.byteLength/4),_.flag=!1}}},t._updateTextureArray=function(e,t){for(var n=this._blendShapes,r=this._vertexTexture,i=this._vertices,a=this._subDataDirtyFlags,o=0,s=n.length;o<s;o++){var l=a[o],c=r.width*r.height*4;if(t||l.flag){var u=n[o].frames,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(i[m]=v.x,i[m+1]=v.y,i[m+2]=v.z,m+=4,f){var y=f[g];i[m]=y.x,i[m+1]=y.y,i[m+2]=y.z,m+=4}if(p){var x=p[g];i[m]=x.x,i[m+1]=x.y,i[m+2]=x.z,m+=4}}l.flag=!1}}r.setPixelBuffer(0,i)},t._updateLayoutChange=function(e,t){var n=this._blendShapeCount>1,r=1,i=t._useBlendShapeNormal,a=t._useBlendShapeTangent;n&&(i&&(i=this._useBlendNormal),a&&(a=this._useBlendTangent)),i&&r++,a&&r++,this._useBlendNormal=i,this._useBlendTangent=a,this._vertexElementCount=r},t._attributeModeUpdateVertexElement=function(e,t,n,r){var i=this._vertexElementOffset+this._vertexElementCount*r,a=t[n],o=a.x,s=a.y,l=e[i];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++i];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++i];s+=12,u.bindingIndex=o,u.offset=s}},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,i=this._modelMesh._primitive.vertexElements,a=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<r)this._attributeModeUpdateVertexElement(i,a,s,s),t[s]=c,c<o&&(o=c,n=s);else if(c>o){this._attributeModeUpdateVertexElement(i,a,s,n),t[n]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<r;u++){var d=t[u];d<o&&(o=d,n=u)}}}},e}();iL._blendShapeMacro=nj.getByName("RENDERER_HAS_BLENDSHAPE"),iL._blendShapeTextureMacro=nj.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),iL._blendShapeNormalMacro=nj.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),iL._blendShapeTangentMacro=nj.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),iL._blendShapeWeightsProperty=nQ.getByName("renderer_BlendShapeWeights"),iL._blendShapeTextureProperty=nQ.getByName("renderer_BlendShapeTexture"),iL._blendShapeTextureInfoProperty=nQ.getByName("renderer_BlendShapeTextureInfo");var iD=((eg={}).Position="POSITION",eg.Normal="NORMAL",eg.Color="COLOR_0",eg.Tangent="TANGENT",eg.BoneWeight="WEIGHTS_0",eg.BoneIndex="JOINTS_0",eg.UV="TEXCOORD_0",eg.UV1="TEXCOORD_1",eg.UV2="TEXCOORD_2",eg.UV3="TEXCOORD_3",eg.UV4="TEXCOORD_4",eg.UV5="TEXCOORD_5",eg.UV6="TEXCOORD_6",eg.UV7="TEXCOORD_7",eg),iB=/*#__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 tR(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 iL(t,r),r}tX(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,iD.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,iD.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,iD.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,iD.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,iD.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,iD.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,iD.UV,6,this._readVector2VertexData);return this._uv=t,t;case 1:var n=this._getVertexElementData(this._uv1,iD.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var r=this._getVertexElementData(this._uv2,iD.UV2,8,this._readVector2VertexData);return this._uv2=r,r;case 3:var i=this._getVertexElementData(this._uv3,iD.UV3,9,this._readVector2VertexData);return this._uv3=i,i;case 4:var a=this._getVertexElementData(this._uv4,iD.UV4,10,this._readVector2VertexData);return this._uv4=a,a;case 5:var o=this._getVertexElementData(this._uv5,iD.UV5,11,this._readVector2VertexData);return this._uv5=o,o;case 6:var s=this._getVertexElementData(this._uv6,iD.UV6,12,this._readVector2VertexData);return this._uv6=s,s;case 7:var l=this._getVertexElementData(this._uv7,iD.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,tY(e,Uint8Array)?this._indicesFormat=it.UInt8:tY(e,Uint16Array)?this._indicesFormat=it.UInt16:tY(e,Uint32Array)&&(this._indicesFormat=it.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 i=this._primitive._vertexElementMap;i[iD.Position]||this.setPositions(null),i[iD.Normal]||this.setNormals(null),i[iD.Color]||this.setColors(null),i[iD.BoneWeight]||this.setBoneWeights(null),i[iD.BoneIndex]||this.setBoneIndices(null),i[iD.Tangent]||this.setTangents(null),i[iD.UV]||this.setUVs(null,0),i[iD.UV1]||this.setUVs(null,1),i[iD.UV2]||this.setUVs(null,2),i[iD.UV3]||this.setUVs(null,3),i[iD.UV4]||this.setUVs(null,4),i[iD.UV5]||this.setUVs(null,5),i[iD.UV6]||this.setUVs(null,6),i[iD.UV7]||this.setUVs(null,7);var a=this._internalVertexBufferCreatedInfo.z;-1!==a&&(null==(t=this._primitive.vertexBufferBindings[a])||t.buffer.destroy(),this._setVertexBufferBinding(a,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,i=void 0!==r.buffer;i||(r=new iw(e,t));var a=i?t:n,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=a+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(a,r),a===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),a===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,i=this._vertexBufferInfos,a=t+n;r.length<a&&(r.length=a,i.length=a);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,i=n.length;r<i;r++){var a=t[r];if(null==a?void 0:a.uploadAdvancedData){var o,s=null==(o=n[r])?void 0:o.buffer;s.setData(s.data),a.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 iS(u,this._indicesFormat));else{null==u||u.destroy();var d=new ie(this._engine,io.IndexBuffer,c);this._setIndexBufferBinding(new iS(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 i=this._indices,a=this.vertexCount,o=t._tempVec0,s=t._tempVec1,l=t._tempVec2,c=t._tempVec3,u=t._tempVec4,d=i?i.length/3:e.length/3,h=Array(a),_=Array(a),f=0;f<a;f++)h[f]=new tN,_[f]=new tR;for(var p=0;p<d;p++){var m=3*p,g=3*p+1,v=3*p+2;i&&(m=i[m],g=i[g],v=i[v]);var y=e[m],x=e[g],b=e[v],C=r[m],S=r[g],T=r[v];tR.subtract(x,y,o),tR.subtract(b,y,s);var A=S.x-C.x,R=T.x-C.x,E=S.y-C.y,M=T.y-C.y,w=1/(A*M-R*E);tR.scale(o,M*w,l),tR.scale(s,E*w,u),tR.subtract(l,u,l),tR.scale(s,A*w,c),tR.scale(o,R*w,u),tR.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<a;F++){var L=n[F],D=_[F],B=h[F];l.set(B.x,B.y,B.z),tR.cross(l,D,u);var I=tR.dot(u,L)>0?1:-1;tR.scale(L,tR.dot(l,L),u),tR.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,i=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,o=function(){r._advancedDataSyncToBuffer||(a[t].dataVersion=r._dataVersionCounter++)},s=i[t];s&&s.buffer._dataUpdateManager.removeListener(o),e.prototype._setVertexBufferBinding.call(this,t,n),n?(n.buffer._dataUpdateManager.addListener(o),(a[t]||(a[t]=new iI)).reset(),o()):t+1==i.length&&i.length--},n._getVertexTypedArray=function(e,t){switch(t){case nZ.BYTE:return new Int8Array(e);case nZ.UNSIGNED_BYTE:return new Uint8Array(e);case nZ.SHORT:return new Int16Array(e);case nZ.UNSIGNED_SHORT:return new Uint16Array(e);case nZ.FLOAT:return new Float32Array(e)}},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._releaseCache(!0)},n._getVertexElementData=function(e,t,n,r){var i,a=this._advancedVertexDataVersions,o=null!=(i=a[n])?i:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(a[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,i=t*n;if(r.x*r.y!==i){var a,o=r.z;-1!==o&&(null==(a=this._primitive.vertexBufferBindings[o])||a.buffer.destroy(),this._setVertexBufferBinding(o,null));var s=this._internalVertexBufferIndex,l=t*this.vertexCount>0;if(l){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var c=e?r6.Static:r6.Dynamic,u=new ie(this._engine,io.VertexBuffer,i,c,!0);this._setVertexBufferBinding(s,new iw(u,t))}r.set(t,n,l?s:-1)}},n._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new tO(e[t],e[t+1])})},n._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new tR(e[t],e[t+1],e[t+2])})},n._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new tN(e[t],e[t+1],e[t+2],e[t+3])})},n._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new tV(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 i=n.vertexBufferBindings[r.bindingIndex],a=null==i?void 0:i.buffer;if(!a)return null;if(!a.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(a.data.buffer,s.type),u=r.offset,d=i.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 i=this._getAttributeFormat(t),a=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new ia(t,a,i,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,iD.Position,1),2&e&&this._updateAdvancedVertexElement(this._normals,iD.Normal,2),4&e&&this._updateAdvancedVertexElement(this._colors,iD.Color,4),16&e&&this._updateAdvancedVertexElement(this._boneWeights,iD.BoneWeight,16),32&e&&this._updateAdvancedVertexElement(this._boneIndices,iD.BoneIndex,32),8&e&&this._updateAdvancedVertexElement(this._tangents,iD.Tangent,8),64&e&&this._updateAdvancedVertexElement(this._uv,iD.UV,64),128&e&&this._updateAdvancedVertexElement(this._uv1,iD.UV1,128),256&e&&this._updateAdvancedVertexElement(this._uv2,iD.UV2,256),512&e&&this._updateAdvancedVertexElement(this._uv3,iD.UV3,512),1024&e&&this._updateAdvancedVertexElement(this._uv4,iD.UV4,1024),2048&e&&this._updateAdvancedVertexElement(this._uv5,iD.UV5,2048),4096&e&&this._updateAdvancedVertexElement(this._uv6,iD.UV6,4096),8192&e&&this._updateAdvancedVertexElement(this._uv7,iD.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 i=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(r!==t._vertexElementOffset||i&&t._blendShapeCount>0){var a=t._addVertexElements(this);a<n&&this._setVertexElementsLength(a)}},n._writeVector2AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var i=n[r];i&&(e[t]=i.x,e[t+1]=i.y)})},n._writeVector3AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var i=n[r];i&&(e[t]=i.x,e[t+1]=i.y,e[t+2]=i.z)})},n._writeVector4AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var i=n[r];i&&(e[t]=i.x,e[t+1]=i.y,e[t+2]=i.z,e[t+3]=i.w)})},n._writeColorAdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var i=n[r];i&&(e[t]=i.r,e[t+1]=i.g,e[t+2]=i.b,e[t+3]=i.a)})},n._writeAdvancedVertexData=function(e,t,n){var r,i=this._primitive,a=i._vertexElementMap[e],o=a.bindingIndex,s=i.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=a._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,d.type),_=a.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,i=this._boneWeights,a=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(iD.Position,0,e),t&&2&r&&this._writeVector3AdvancedVertexData(iD.Normal,1,t),n&&4&r&&this._writeColorAdvancedVertexData(iD.Color,2,n),i&&16&r&&this._writeVector4AdvancedVertexData(iD.BoneWeight,4,i),a&&32&r&&this._writeVector4AdvancedVertexData(iD.BoneIndex,5,a),o&&8&r&&this._writeVector4AdvancedVertexData(iD.Tangent,3,o),s&&64&r&&this._writeVector2AdvancedVertexData(iD.UV,6,s),l&&128&r&&this._writeVector2AdvancedVertexData(iD.UV1,7,l),c&&256&r&&this._writeVector2AdvancedVertexData(iD.UV2,8,c),u&&512&r&&this._writeVector2AdvancedVertexData(iD.UV3,9,u),d&&1024&r&&this._writeVector2AdvancedVertexData(iD.UV4,10,d),h&&2048&r&&this._writeVector2AdvancedVertexData(iD.UV5,11,h),_&&4096&r&&this._writeVector2AdvancedVertexData(iD.UV6,12,_),f&&8192&r&&this._writeVector2AdvancedVertexData(iD.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 iD.Position:case iD.Normal:return ir.Vector3;case iD.Color:case iD.BoneWeight:case iD.Tangent:return ir.Vector4;case iD.BoneIndex:return ir.UByte4;case iD.UV:case iD.UV1:case iD.UV2:case iD.UV3:case iD.UV4:case iD.UV5:case iD.UV6:case iD.UV7:return ir.Vector2}},n._getAttributeByteLength=function(e){switch(e){case iD.Position:case iD.Normal:return 12;case iD.Color:case iD.BoneWeight:case iD.Tangent:return 16;case iD.BoneIndex:return 4;case iD.UV:case iD.UV1:case iD.UV2:case iD.UV3:case iD.UV4:case iD.UV5:case iD.UV6:case iD.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,i=0,a=r.length;i<a;i++){var o=r[i];o&&(o.dataVersion=n)}}},tW(t,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var e=0,t=this._primitive._vertexElementMap[iD.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}(iE);iB._tempVec0=new tR,iB._tempVec1=new tR,iB._tempVec2=new tR,iB._tempVec3=new tR,iB._tempVec4=new tR;var iI=/*#__PURE__*/function(){function e(){this.dataVersion=-1,this.uploadAdvancedData=!1}return e.prototype.reset=function(){this.uploadAdvancedData=!1},e}(),iO=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).primitiveInfo=n,r}return tX(t,e),t.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:iX._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:iX._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:iX._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:iX._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:iX._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:iX._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:iX._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:iX._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t}(t4),iN=function(e,t,n){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=n},iV=/*#__PURE__*/function(e){function t(t,n,r,i){var a;return(a=e.call(this,0,r,i)||this).radius=t,a.segments=n,a}return tX(t,e),t}(iN),ik=/*#__PURE__*/function(e){function t(t,n,r,i){var a;return(a=e.call(this,7,r,i)||this).radius=t,a.step=n,a}return tX(t,e),t}(iN),iz=/*#__PURE__*/function(e){function t(t,n,r,i,a){var o;return(o=e.call(this,1,i,a)||this).width=t,o.height=n,o.depth=r,o}return tX(t,e),t}(iN),iU=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;return(s=e.call(this,2,a,o)||this).width=t,s.height=n,s.horizontalSegments=r,s.verticalSegments=i,s}return tX(t,e),t}(iN),iG=/*#__PURE__*/function(e){function t(t,n,r,i,a,o,s){var l;return(l=e.call(this,3,o,s)||this).radiusTop=t,l.radiusBottom=n,l.height=r,l.radialSegments=i,l.heightSegments=a,l}return tX(t,e),t}(iN),iH=/*#__PURE__*/function(e){function t(t,n,r,i,a,o,s){var l;return(l=e.call(this,4,o,s)||this).radius=t,l.tubeRadius=n,l.radialSegments=r,l.tubularSegments=i,l.arc=a,l}return tX(t,e),t}(iN),iW=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;return(s=e.call(this,5,a,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=i,s}return tX(t,e),t}(iN),ij=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;return(s=e.call(this,6,a,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=i,s}return tX(t,e),t}(iN),iX=/*#__PURE__*/function(){function e(){}return e.createSphere=function(t,n,r,i){void 0===n&&(n=.5),void 0===r&&(r=18),void 0===i&&(i=!0);var a=new iB(t);e._setSphereData(a,n,r,i,!1);var o=a.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(a,new iV(n,r,o,i))),a},e.createSubdivisionSurfaceSphere=function(t,n,r,i){void 0===n&&(n=.5),void 0===r&&(r=3),void 0===i&&(i=!0);var a=new iB(t);e._setSubdivisionSurfaceSphereData(a,n,r,i,!1);var o=a.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(a,new ik(n,r,o,i))),a},e.createCuboid=function(t,n,r,i,a){void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new iB(t);e._setCuboidData(o,n,r,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(o,new iz(n,r,i,s,a))),o},e.createPlane=function(t,n,r,i,a,o){void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=1),void 0===a&&(a=1),void 0===o&&(o=!0);var s=new iB(t);e._setPlaneData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(s,new iU(n,r,i,a,l,o))),s},e.createCylinder=function(t,n,r,i,a,o,s){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===i&&(i=2),void 0===a&&(a=20),void 0===o&&(o=1),void 0===s&&(s=!0);var l=new iB(t);e._setCylinderData(l,n,r,i,a,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(l,new iG(n,r,i,a,o,c,s))),l},e.createTorus=function(t,n,r,i,a,o,s){void 0===n&&(n=.5),void 0===r&&(r=.1),void 0===i&&(i=30),void 0===a&&(a=30),void 0===o&&(o=360),void 0===s&&(s=!0);var l=new iB(t);e._setTorusData(l,n,r,i,a,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(l,new iH(n,r,i,a,o,c,s))),l},e.createCone=function(t,n,r,i,a,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===i&&(i=20),void 0===a&&(a=1),void 0===o&&(o=!0);var s=new iB(t);e._setConeData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(s,new iW(n,r,i,a,l,o))),s},e.createCapsule=function(t,n,r,i,a,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===i&&(i=6),void 0===a&&(a=1),void 0===o&&(o=!0);var s=new iB(t);e._setCapsuleData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new iO(s,new ij(n,r,i,a,l,o))),s},e._setSubdivisionSurfaceSphereData=function(t,n,r,i,a,o){var s=new Float32Array(3*(6*Math.pow(4,r=tA.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,R=l[A],E=l[A+1],M=l[A+2],w=l[A+3],P=8*R,F=8*E,L=8*M,D=8*w;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(R=p[R]),0===h[F+6]&&(E=p[E]),0===h[L+6]&&(M=p[M]),0===h[D+6]&&(w=p[w])),_[S]=R,_[S+1]=E,_[S+2]=M,this._generateAndReplacePoleUV(_,h,S,d),_[S+3]=R,_[S+4]=M,_[S+5]=w,this._generateAndReplacePoleUV(_,h,S+3,d),S+=6}if(!a){var B=t.bounds;B.min.set(-n,-n,-n),B.max.set(n,n,n)}e._initialize(t,h,_,i,a,o)},e._setSphereData=function(t,n,r,i,a,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 R=0,E=0;E<c;++E){var M=E%r,w=(E*f|0)*s+M,P=w+1,F=w+s,L=F+1;u[R++]=P,u[R++]=w,u[R++]=L,u[R++]=w,u[R++]=F,u[R++]=L}if(!a){var D=t.bounds;D.min.set(-n,-n,-n),D.max.set(n,n,n)}e._initialize(t,p,u,i,a,o)},e._subdiveCatmullClark=function(t,n,r){var i=new Map,a=[];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;i.clear(),a.length=0;for(var c=0;c<s;c++){for(var u=a[c]={facePoint:new tR,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(!i.has(m)){var g={edgePoint:new tR,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])),i.set(m,g)}var x=i.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 R=r.slice(0,4*s),E=0;E<s;E++){var M=a[E];M.facePoint.copyToArray(n,3*(S+E));for(var w=S+E,P=void 0,F=void 0,L=void 0,D=0;D<4;D++){var B=R[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*E+D);r[V]=B,r[V+1]=F,r[V+2]=w,r[V+3]=P}}}},e._generateAndReplacePoleUV=function(e,t,n,r){var i=t[8*e[n]+7];if(0===i||1===i){var a=8*e[n],o=8*(r+this._spherePoleIdx);t.set(t.subarray(a,a+8),o),t[o+6]=.5*(t[a+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 i=r+e._sphereEdgeIdx++;return n.edgePointIndex=i,i},e._setCuboidData=function(t,n,r,i,a,o,s){var l=n/2,c=r/2,u=i/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,a,o,s)},e._setPlaneData=function(t,n,r,i,a,o,s,l){for(var c=(i=Math.max(1,Math.floor(i)))+1,u=(a=Math.max(1,Math.floor(a)))+1,d=n/2,h=r/2,_=n/i,f=r/a,p=c*u,m=a*i,g=e._generateIndices(t.engine,p,6*m),v=1/c,y=1/i,x=1/a,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 R=0,E=0;E<m;++E){var M=E%i,w=(E*y|0)*c+M,P=w+1,F=w+c,L=F+1;g[R++]=w,g[R++]=F,g[R++]=P,g[R++]=F,g[R++]=L,g[R++]=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,i,a,o,s,l,c){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===i&&(i=2),void 0===a&&(a=20),void 0===o&&(o=1);for(var u=(a=Math.floor(a))+1,d=(o=Math.floor(o))+1,h=.5*i,_=i/o,f=u*d,p=a*o,m=2*a,g=f+2+m,v=e._generateIndices(t.engine,g,6*p+3*m),y=1/u,x=1/a,b=1/o,C=new Float32Array(8*g),S=0,T=Math.PI,A=2*Math.PI,R=r-n,E=R/i,M=R/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++]=E,C[U++]=O,C[U++]=L,C[U++]=1-D}for(var G=0;G<p;++G){var H=G%a,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 q=8*f;C[q++]=0,C[q++]=-h,C[q++]=0,C[q++]=0,C[q++]=-1,C[q++]=0,C[q++]=.5,C[q++]=.5,C[q++]=0,C[q++]=h,C[q++]=0,C[q++]=0,C[q++]=1,C[q++]=0,C[q++]=.5,C[q++]=.5,q=(f+2)*8;for(var Y=1/(2*n),Q=1/(2*r),J=u*o,Z=0;Z<a;++Z){var $=8*Z,ee=C[$],et=C[$+2];C[q++]=ee,C[q++]=-h,C[q++]=et,C[q++]=0,C[q++]=-1,C[q++]=0,C[q++]=ee*Q+.5,C[q++]=.5-et*Q;var en=(Z+J)*8;ee=C[en],et=C[en+2],C[q++]=ee,C[q++]=h,C[q++]=et,C[q++]=0,C[q++]=1,C[q++]=0,C[q++]=ee*Y+.5,C[q++]=.5-et*Y}for(var er=f+1,ei=f+2,ea=ei+1,eo=0;eo<a;++eo){var es=2*eo,el=eo===a-1?0:es+2;v[S++]=f,v[S++]=ei+el,v[S++]=ei+es,v[S++]=er,v[S++]=ea+es,v[S++]=ea+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,i,a,o,s,l,c){var u=((i=Math.floor(i))+1)*((a=Math.floor(a))+1),d=i*a,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<=i;m++)for(var g=0;g<=a;g++){var v=g/a*o,y=m/i*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 R=n*b,E=n*C;p.set(S-R,T-E,A).normalize(),_[f++]=p.x,_[f++]=p.y,_[f++]=p.z,_[f++]=g/a,_[f++]=m/i}f=0;for(var M=1;M<=i;M++)for(var w=1;w<=a;w++){var P=(a+1)*M+w-1,F=(a+1)*(M-1)+w-1,L=(a+1)*(M-1)+w,D=(a+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,i,a,o,s,l){for(var c=(i=Math.floor(i))+1,u=(a=Math.floor(a))+1,d=.5*r,h=r/a,_=c*u,f=i*a,p=_+1+i,m=e._generateIndices(t.engine,p,6*f+3*i),g=1/c,v=1/i,y=1/a,x=new Float32Array(8*p),b=0,C=Math.PI,S=2*Math.PI,T=n/r,A=0;A<_;++A){var R=A%c,E=A*g|0,M=R*v,w=E*y,P=C+M*S,F=Math.sin(P),L=Math.cos(P),D=n-w*n,B=D*F,I=E*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%i,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<i;++X){var K=x[8*X],q=x[8*X+2];x[W++]=K,x[W++]=-d,x[W++]=q,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=K*j+.5,x[W++]=.5-q*j}for(var Y=_+1,Q=0;Q<i;++Q){var J=Q,Z=Q===i-1?0:J+1;m[b++]=_,m[b++]=Y+Z,m[b++]=Y+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,i,a,o,s,l){for(var c=(i=Math.max(2,Math.floor(i)))+1,u=(a=Math.floor(a))+1,d=.5*r,h=r/a,_=c*u,f=i*a,p=c*c,m=i*i,g=_+2*p,v=e._generateIndices(t.engine,g,(f+2*m)*6),y=1/c,x=1/i,b=1/a,C=Math.PI,S=2*Math.PI,T=new Float32Array(8*g),A=0,R=0;R<_;++R){var E=R%c,M=R*y|0,w=E*x,P=M*b,F=C+w*S,L=Math.sin(F),D=Math.cos(F),B=8*R;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%i,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,i,C,S,_,1,T,v,A),e._createCapsuleCap(n,r,i,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,i,a){if(i)a.setData(t),e.setIndices(n),e.uploadData(r);else{var o=[new ia(iD.Position,0,ir.Vector3,0),new ia(iD.Normal,12,ir.Vector3,0),new ia(iD.UV,24,ir.Vector2,0)];e.setVertexElements(o);var s=new ie(e.engine,io.VertexBuffer,t,r6.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(n$.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,i,a,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*i,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+a)*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 R=0;R<_;++R){var E=R%n,M=(R*p|0)*u+E+a,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 iK(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(iK=function(){return!!e})()}function iq(e,t,n){return(iq=iK()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&tj(i,n.prototype),i}).apply(null,arguments)}iX._tempVec30=new tR,iX._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]),iX._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]),iX._sphereEdgeIdx=0,iX._spherePoleIdx=0;var iY=/*#__PURE__*/function(){function e(){}return e.cloneComponent=function(e,t,n,r,i){var a=t1.getCloneMode(e.constructor);for(var o in e)t1.cloneProperty(e,t,o,a[o],n,r,i);e._cloneTo&&e._cloneTo(t,n,r)},e}(),iQ=/*#__PURE__*/function(e){function t(t,n){for(var r,i=arguments.length,a=Array(i>2?i-2:0),o=2;o<i;o++)a[o-2]=arguments[o];(r=e.call(this,t)||this).layer=rM.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new rT,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._isTemplate=!1,r._updateFlagManager=new nP,r._parent=null,r._invModelMatrix=new tB,r.name=n;for(var s=0,l=a.length;s<l;s++)r.addComponent(a[s]);return r._transform||r.addComponent(rg),r._inverseWorldMatFlag=r.registerWorldChangeFlag(),r}tX(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];r_._addCheck(this,e);var i=iq(e,[].concat([this],n));if(this._components.push(i),tY(i,rg)){var a=this._transform;this._transform=i,null==a||a.destroy()}return i._setActive(!0,rd.All),i},n.getComponent=function(e){for(var t=this._components,n=0,r=t.length;n<r;n++){var i=t[n];if(tY(i,e))return i}return null},n.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];tY(a,e)&&t.push(a)}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 i=n._scene,a=this._scene,o=rd.None;!this._isActiveInHierarchy&&n._isActiveInHierarchy&&(o|=rd.Hierarchy),n._isActiveInScene&&(this._isActiveInScene?i!==a&&(o|=rd.Scene):o|=rd.Scene),o&&n._processInActive(o),n._scene!==a&&t._traverseSetOwnerScene(n,a);var s=rd.None;n._isActive&&(this._isActiveInHierarchy&&(n._isActiveInHierarchy||(s|=rd.Hierarchy)),this._isActiveInScene&&(n._isActiveInScene&&i===a||(s|=rd.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 i=t[n].findByName(e);if(i)return i}return null},n.findByPath=function(e){for(var n=e.split("/"),r=this,i=0,a=n.length;i<a;++i){var o=n[i];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 i=rd.None;r._isActiveInHierarchy&&(i|=rd.Hierarchy),r._isActiveInScene&&(i|=rd.Scene),i&&r._processInActive(i),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(rm)},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 i=this._children,a=0,o=i.length;a<o;a++)n.addChild(i[a]._createCloneEntity());return n},n._parseCloneEntity=function(e,t,n,r,i){for(var a=e._children,o=t._children,s=0,l=a.length;s<l;s++)this._parseCloneEntity(a[s],o[s],n,r,i);for(var c=e._components,u=0,d=c.length;u<d;u++){var h=c[u];if(!tY(h,rg)){var _=t.addComponent(h.constructor);iY.cloneComponent(h,_,n,r,i)}}},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){r_._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 i=e+1,a=r+1;i<a;i++)n[i]._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 i=this._scene,a=e._scene,o=rd.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(o|=rd.Hierarchy),e._isActiveInScene?this._isActiveInScene&&i!==a&&(o|=rd.Scene):this._isActiveInScene&&(o|=rd.Scene),o&&this._processInActive(o),i!==a&&t._traverseSetOwnerScene(this,a);var s=rd.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(s|=rd.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&i===a||(s|=rd.Scene))),s&&this._processActive(s)}else{var l=rd.None;this._isActiveInHierarchy&&(l|=rd.Hierarchy),this._isActiveInScene&&(l|=rd.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];tY(r,e)&&t.push(r)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},n._setActiveComponents=function(e,t){for(var n=this._activeChangedComponents,r=0,i=n.length;r<i;++r)n[r]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(n),this._activeChangedComponents=null},n._setActiveInHierarchy=function(e,t){t&rd.Hierarchy&&(this._isActiveInHierarchy=!0),t&rd.Scene&&(this._isActiveInScene=!0);for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];(a.enabled||!a._awoken)&&e.push(a)}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&rd.Hierarchy&&(this._isActiveInHierarchy=!1),t&rd.Scene&&(this._isActiveInScene=!1);for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];a.enabled&&e.push(a)}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 i=r==t?this:e[r-1];e[r]=i,i._siblingIndex=r}else for(var a=n;a<=t;a++){var o=a==t?this:e[a+1];e[a]=o,o._siblingIndex=a}}},n.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(tB.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 i=n[r];if(i.name===t)return i}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},tW(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=rd.None;this._isRoot&&this._scene._isActiveInEngine?n|=rd.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=rd.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=rd.Scene)),n&&this._processActive(n)}else{var r=rd.None;this._isActiveInHierarchy&&(r|=rd.Hierarchy),this._isActiveInScene&&(r|=rd.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}(t2),iJ=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n.inverseBindMatrices=[],n._updatedManager=new nP,n._bones=[],n._updateMark=-1,n.joints=[],n}tX(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,i=this._skinMatrices,a=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=n.length-1;o>=0;o--){var s=n[o],l=16*o;s?nR._floatMatrixMultiply(s.transform.worldMatrix,r[o].elements,0,i,l):i.set(r[o].elements,l),nR._floatMatrixMultiply(a,i,l,i,l)}this._updateMark=e.engine.time.frameCount}},n._cloneTo=function(e,t,n){var r=[],i=this.rootBone;if(i){var a=iQ._getEntityHierarchyPath(t,i,r);e.rootBone=a?iQ._getEntityByHierarchyPath(n,r):i}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=iQ._getEntityHierarchyPath(t,u,r);l[c]=d?iQ._getEntityByHierarchyPath(n,r):u}e.bones=l}},tW(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,i=n.length;n.length=r;for(var a=0;a<r;a++)n[a]=e[a];i!==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}(t2);tq([t0],iJ.prototype,"inverseBindMatrices",void 0),tq([tJ],iJ.prototype,"_skinMatrices",void 0),tq([tJ],iJ.prototype,"_updatedManager",void 0),tq([tJ],iJ.prototype,"_rootBone",void 0),tq([tJ],iJ.prototype,"_bones",void 0),tq([tJ],iJ.prototype,"_updateMark",void 0);var iZ=((ev={})[ev.BoneCountChanged=0]="BoneCountChanged",ev[ev.RootBoneChanged=1]="RootBoneChanged",ev),i$=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._localBounds=new tM,n._jointDataCreateCache=new tO(-1,-1),n._skin=null;var n,r=n.entity.engine._hardwareRenderer,i=r.renderStates.getParameter(r.gl.MAX_VERTEX_UNIFORM_VECTORS);i=Math.min(i,r._options._maxAllowSkinUniformVectorCount),n._maxVertexUniformVectors=i,n._onLocalBoundsChanged=n._onLocalBoundsChanged.bind(n),n._onSkinUpdated=n._onSkinUpdated.bind(n);var a=n._localBounds;return a.min._onValueChanged=n._onLocalBoundsChanged,a.max._onValueChanged=n._onLocalBoundsChanged,n}tX(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 i=this.shaderData,a=this.mesh._blendShapeManager;a._updateShaderData(i,this);var o=null==r?void 0:r.bones;if(o){var s=a._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 nd(f,4,l,t7.R32G32B32A32,!1),this._jointTexture.filterMode=t6.Point,this._jointTexture.isGCIgnored=!0),i.disableMacro("RENDERER_JOINTS_NUM"),i.enableMacro("RENDERER_USE_JOINT_TEXTURE"),i.setTexture(t._jointSamplerProperty,this._jointTexture)):nl.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(),i.disableMacro("RENDERER_USE_JOINT_TEXTURE"),i.enableMacro("RENDERER_JOINTS_NUM",h.toString()),i.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)?tM.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 i=new Float32Array(t);if(t>r)i.set(n);else for(var a=0;a<t;a++)i[a]=n[a];this._blendShapeWeights=i}}else this._blendShapeWeights=new Float32Array(t)},n._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=rx.WorldVolume},n._onSkinUpdated=function(e,n){switch(e){case iZ.BoneCountChanged:var r=this.shaderData;n>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(t._jointCountProperty,n)):r.disableMacro("RENDERER_HAS_SKIN");break;case iZ.RootBoneChanged:this._setTransformEntity(n),this._dirtyUpdateFlag|=rx.WorldVolume}},n._applySkin=function(e,t){var n,r,i,a,o,s,l=null!=(i=null==e?void 0:null==(n=e.bones)?void 0:n.length)?i:0,c=null!=(a=null==e?void 0:e.rootBone)?a: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(iZ.BoneCountChanged,u),c!==d&&this._onSkinUpdated(iZ.RootBoneChanged,d)},tW(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}(iF);i$._jointCountProperty=nQ.getByName("renderer_JointCount"),i$._jointSamplerProperty=nQ.getByName("renderer_JointSampler"),i$._jointMatrixProperty=nQ.getByName("renderer_JointMatrix"),tq([tJ],i$.prototype,"_condensedBlendShapeWeights",void 0),tq([t0],i$.prototype,"_localBounds",void 0),tq([tJ],i$.prototype,"_jointDataCreateCache",void 0),tq([tJ],i$.prototype,"_blendShapeWeights",void 0),tq([tJ],i$.prototype,"_maxVertexUniformVectors",void 0),tq([tJ],i$.prototype,"_jointTexture",void 0),tq([t0],i$.prototype,"_skin",void 0),tq([tJ],i$.prototype,"_onLocalBoundsChanged",null),tq([tJ],i$.prototype,"_onSkinUpdated",null);var i0=/*#__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 iu(e,rl.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 i=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(e,0,t7.R8G8B8A8,i),this.whiteTextureCube=this._create1x1Texture(e,1,t7.R8G8B8A8,i),e._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(e,2,t7.R8G8B8A8,i);var a=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(e,0,t7.R32G32B32A32_UInt,a)}this.spriteDefaultMaterial=this._create2DMaterial(e,rl.find("Sprite")),this.textDefaultMaterial=this._create2DMaterial(e,rl.find("Text")),this.spriteMaskDefaultMaterial=this._createSpriteMaskMaterial(e)}var t=e.prototype;return t._createBlitMesh=function(e,t){var n=new iB(e);n._addReferCount(1),n.setVertexElements([new ia("POSITION_UV",0,ir.Vector4,0)]);var r=new ie(e,io.VertexBuffer,t,r6.Static,!0);return n.setVertexBufferBinding(r,16),n.addSubMesh(0,3,is.Triangles),e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tX(t,e),t.prototype.restoreContent=function(){r.setData(r.data)},t}(t4))),n},t._create1x1Texture=function(e,t,n,r){var i;switch(t){case 0:var a=new nd(e,1,1,n,!1);a.setPixelBuffer(r),i=a;break;case 2:var o=new nh(e,1,1,1,n,!1);o.setPixelBuffer(0,r),i=o;break;case 1:for(var s=new n_(e,1,n,!1),l=0;l<6;l++)s.setPixelBuffer(t5.PositiveX+l,r);i=s;break;default:throw"Invalid texture type"}return i.isGCIgnored=!0,e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,i)||this}return tX(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(t5.PositiveX+e,r)}},n}(t4))),i},t._create2DMaterial=function(e,t){var n=new iu(e,t),r=n.renderState,i=r.blendState.targetBlendState;return i.enabled=!0,i.sourceColorBlendFactor=nD.SourceAlpha,i.destinationColorBlendFactor=nD.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=nD.One,i.destinationAlphaBlendFactor=nD.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=nB.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=nN.Off,r.renderQueueType=nk.Transparent,n.isGCIgnored=!0,n},t._createSpriteMaskMaterial=function(e){var t=new iu(e,rl.find("SpriteMask"));return t.isGCIgnored=!0,t},e.getMaskInteractionRenderStates=function(t){var n,r;if(t===nx.VisibleInsideMask){if(n=e._maskReadInsideRenderStates)return n;e._maskReadInsideRenderStates=n={},r=nO.LessEqual}else{if(n=e._maskReadOutsideRenderStates)return n;e._maskReadOutsideRenderStates=n={},r=nO.Greater}return n[nV.StencilStateEnabled]=!0,n[nV.StencilStateWriteMask]=0,n[nV.StencilStateReferenceValue]=1,n[nV.StencilStateCompareFunctionFront]=r,n[nV.StencilStateCompareFunctionBack]=r,n},e.getMaskTypeRenderStates=function(t){if(t===rH.Increment){if(n=e._maskWriteIncrementRenderStates)return n;e._maskWriteIncrementRenderStates=n={},r=nU.IncrementSaturate}else{if(n=e._maskWriteDecrementRenderStates)return n;e._maskWriteDecrementRenderStates=n={},r=nU.DecrementSaturate}n[nV.StencilStateEnabled]=!0,n[nV.StencilStatePassOperationFront]=r,n[nV.StencilStatePassOperationBack]=r,n[nV.StencilStateCompareFunctionFront]=nO.Always,n[nV.StencilStateCompareFunctionBack]=nO.Always;var n,r,i=nU.Keep;return n[nV.StencilStateFailOperationFront]=i,n[nV.StencilStateFailOperationBack]=i,n[nV.StencilStateZFailOperationFront]=i,n[nV.StencilStateZFailOperationBack]=i,n[nV.BlendStateColorWriteMask0]=nI.None,n[nV.DepthStateEnabled]=!1,n[nV.RasterStateCullMode]=nN.Off,n},e}();i0._maskReadInsideRenderStates=null,i0._maskReadOutsideRenderStates=null,i0._maskWriteIncrementRenderStates=null,i0._maskWriteDecrementRenderStates=null;var i1=/*#__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}(),i2=/*#__PURE__*/function(e){function t(t,n){void 0===n&&(n=1),(r=e.call(this,t)||this)._lastElementIndex=n-1;for(var r,i=r._elements=Array(n),a=0;a<n;++a)i[a]=new t;return r}tX(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}(i1),i3=/*#__PURE__*/function(){function e(){}return e.prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},e}(),i4=/*#__PURE__*/function(){function e(e,t){this.start=e,this.size=t}return e.prototype.dispose=function(){},e}(),i8=/*#__PURE__*/function(){function e(e,t){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new iR(e);n.addVertexElement(new ia("POSITION",0,ir.Vector3,0)),n.addVertexElement(new ia("TEXCOORD_0",12,ir.Vector2,0)),n.addVertexElement(new ia("COLOR_0",20,ir.Vector4,0)),n._addReferCount(1);var r=new ie(e,io.VertexBuffer,36*t,r6.Dynamic,!0);n.setVertexBufferBinding(0,new iw(r,36));var i=new ie(e,io.IndexBuffer,8*t,r6.Dynamic,!0);n.setIndexBufferBinding(new iS(i,it.UInt16)),this.primitive=n,this.vertices=new Float32Array(r.data.buffer),this.indices=new Uint16Array(i.data.buffer),this.vertexFreeAreas=[new i4(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 i=e.subMeshPool.get();return i.topology=is.Triangles,r.subMesh=i,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,r7.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER),e.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,r7.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,i=0,a=n.length;i<a;++i){var o=n[i],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(i,1),o}return null},t._freeArea=function(t){for(var n=t.start,r=t.size,i=this.vertexFreeAreas,a=n+r,o=e.areaPool,s=0,l=i.length;s<l;++s){var c=i[s],u=c.start,d=u+c.size;if(a<u){i.splice(s,0,t);return}if(a===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 _=i[h];a===_.start&&(c.size+=_.size,i.splice(h,1),o.return(_))}return}}i.push(t)},e}();i8.areaPool=new i2(i4,10),i8.subChunkPool=new i2(i3,10),i8.subMeshPool=new i2(iA,10);var i5=/*#__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,i=0;i<n;++i)if(r=t[i].allocateSubChunk(e))return r;return(t[n]||(t[n]=new i8(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}(),i9=/*#__PURE__*/function(){function e(e){this.primitiveChunkManager2D=new i5(e),this.primitiveChunkManagerMask=new i5(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,i=e.elements,a=e.batchedSubElements,o=e.renderQueueType,s=0,l=i.length;s<l;++s)for(var c=i[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):(a.push(t),t=h,n=_,r=f,_._batch(h),h.batched=!1):(t=h,n=_,r=f,_._batch(h),h.batched=!1)}}t&&a.push(t)},t.uploadBuffer=function(){this.primitiveChunkManager2D.uploadBuffer(),this.primitiveChunkManagerMask.uploadBuffer()},e}(),i6=((ey={}).Text="Text",ey.JSON="JSON",ey.Buffer="Buffer",ey.Texture2D="Texture2D",ey.TextureCube="TextureCube",ey.Material="Material",ey.Shader="Shader",ey.Mesh="Mesh",ey.AnimationClip="AnimationClip",ey.AnimatorController="AnimatorController",ey.Prefab="Prefab",ey.GLTF="GLTF",ey.KTX="KTX",ey.KTXCube="KTXCube",ey.KTX2="KTX2",ey.Sprite="Sprite",ey.PrimitiveMesh="PrimitiveMesh",ey.SpriteAtlas="SpriteAtlas",ey.Env="Environment",ey.Scene="Scene",ey.HDR="HDR",ey.Font="Font",ey.SourceFont="SourceFont",ey.Audio="Audio",ey.Project="project",ey.PhysicsMaterial="PhysicsMaterial",ey),i7=/*#__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},tW(e,[{key:"length",get:function(){return this._array.length}}]),e}(),ae=/*#__PURE__*/function(){function e(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new i7}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 i=r.indexOf(t);i!==n&&(r.removeByIndex(i),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:i6.Scene});return r.then(function(e){if(t)for(var r=n._scenes.getArray(),i=0,a=r.length;i<a;i++)r[i].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()},tW(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}(),at=/*#__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 i,a=(i=t._taskDetailProgress)[e]||(i[e]={loaded:n,total:r});a.loaded=n,a.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 i in r){var a=r[i];t(i,a.loaded,a.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,i){r._promise.then(t,n).then(e).catch(i)})},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,i){var a=function(e,t){c++,l[e]=t,i(c,s),c===s&&n(l)},o=function(t,n){tY(t,Promise)||tY(t,e)?t.then(function(e){a(n,e)},r):Promise.resolve().then(function(){a(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)})},tW(e,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),e}(),an={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},ar=1/0;function ai(e,t){return void 0===t&&(t={}),new at(function(n,r,i,a){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:ar,t.type=null!=(c=t.type)?c:an[e.substring(e.lastIndexOf(".")+1)],new aa(function(){var n;return(n=t,new at(function(t,r,i,a){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,a=null!=(n=s.response)?n:s.responseText;if(l){var o=new Image;o.onload=function(){requestAnimationFrame(function(){i(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(a)}else i(1,1),t(a)},s.onerror=function(){r(Error("request failed from: "+e))},s.ontimeout=function(){r(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&a(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(i,a)},u,d).start().onError(r).onComplete(n)})}var aa=/*#__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}(),ao=/*#__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 at.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 i=n[r];tY(i,e)&&t.push(i)}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()}):nR.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 ai(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,i,a,o=null!=(i=this._virtualPathMap[e])?i:e,s=null==(r=this._subAssetPromiseCallbacks[o])?void 0:r[t];s?s.resolve(n):((a=this._subAssetPromiseCallbacks)[o]||(a[o]={}))[t]={resolvedValue:n}},t._onSubAssetFail=function(e,t,n){var r,i,a=null==(r=this._subAssetPromiseCallbacks[e])?void 0:r[t];a?a.reject(n):((i=this._subAssetPromiseCallbacks)[e]||(i[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,i,a,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!=(i=t.timeout)?i:this.timeout,t.retryInterval=null!=(a=t.retryInterval)?a:this.retryInterval,t.url=null!=(o=t.url)?o:t.urls.join(","),t},t._loadSingleItem=function(t){var n,r,i=this,a=this._assignDefaultOptions("string"==typeof t?{url:t}:t),o=a.url;!nR.isAbsoluteUrl(o)&&this.baseUrl&&(o=nR.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 at(function(e){e(i._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 at(function(e,t,n,r){p.onProgress(n,r).then(function(t){e(t)}).catch(function(e){t(e)})});var m=e._loaders[a.type];if(!m)throw"loader not found: "+a.type;return c?((f[d]||this._loadMainAsset(m,a,d,l)).catch(function(e){i._onSubAssetFail(d,c,e)}),this._createSubAssetPromiseCallback(d,_,c)):this._loadMainAsset(m,a,d,l)},t._loadMainAsset=function(e,t,n,r){var i=this;t.url=r;var a=this._loadingPromises,o=e.load(t,this);return a[n]=o,o.then(function(t){e.useCache&&i._addAsset(n,t),delete a[n],i._releaseSubAssetPromiseCallback(n)},function(){delete a[n],i._releaseSubAssetPromiseCallback(n)}),o},t._createSubAssetPromiseCallback=function(e,t,n){var r,i=this,a=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 at(function(e,t){s?e(s):l&&t(l)});var c=new at(function(t,r){var a;((a=i._subAssetPromiseCallbacks)[e]||(a[e]={}))[n]={resolve:t,reject:r}});return a[t]=c,c.then(function(){delete a[t]},function(){return delete a[t]}),c},t._gc=function(e){for(var t=nR.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++){var i=t[n];(!i.isGCIgnored||e)&&i.destroy(e,!0)}},t._getResolveResource=function(e,t){var n=e;if(t)for(var r=0,i=t.length;r<i;r++)n=n[t[r]];return n},t._parseURL=function(e){var t=e.split("?"),n=t[0],r=t[1],i=void 0,a=n;if(r){for(var o=r.split("&"),s=o.length-1;s>=0;s--){var l=o[s];if(l.startsWith("q=")){i=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}a=o.length>0?n+"?"+o.join("&"):n}return{assetBaseURL:a,queryPath:i}},t._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===al&&t.push(""),e.replace(au,function(e,n,r,i){var a=e;r?a=i.replace(ac,"$1"):n&&(a=n.trim()),t.push(a)}),t},t._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},t.getResourceByRef=function(e){var t,n=e.refId,r=e.key,i=e.isClone,a=this._objectPool[n];if(a)t=Promise.resolve(a);else{var o=this._editorResourceConfig[n];if(!o)return nl.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 i?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,i=n.length;r<i;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 as(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);ao._addLoader(e,i,t)}}ao._loaders={},ao._extTypeMapping={};var al=46,ac=/\\(\\)?/g,au=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),ad=((ex={})[ex.Down=0]="Down",ex[ex.Move=1]="Move",ex[ex.Stationary=2]="Stationary",ex[ex.Up=3]="Up",ex[ex.Leave=4]="Leave",ex),ah=/*#__PURE__*/function(){function e(e){this.phase=ad.Leave,this.position=new tO,this.deltaPosition=new tO,this._events=[],this._upMap=[],this._downMap=[],this._upList=new rT,this._downList=new rT,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}(),a_=((eb={})[eb.None=0]="None",eb[eb.Primary=1]="Primary",eb[eb.Secondary=2]="Secondary",eb[eb.Auxiliary=4]="Auxiliary",eb[eb.XButton1=8]="XButton1",eb[eb.XButton2=16]="XButton2",eb[eb.XButton3=32]="XButton3",eb[eb.XButton4=64]="XButton4",eb[eb.XButton5=128]="XButton5",eb[eb.XButton6=256]="XButton6",eb[eb.XButton7=512]="XButton7",eb[eb.XButton8=1024]="XButton8",eb),af=[1,4,2,8,16,32,64,128,256,512,1024],ap={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},am=/*#__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=tG.IPhone:/iPad/i.test(n)?e.platform=tG.IPad:/Android/i.test(n)?e.platform=tG.Android:/Macintosh/i.test(n)&&(e.platform=tG.Mac),e.platform){case tG.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 tG.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 tG.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case tG.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},tW(e,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),e}();am.platform=tG.Unknown,am.operatingSystem="",am._isBrowser=!0,am._simdSupported=null,am._initialize();var ag=((eC={})[eC.Backquote=0]="Backquote",eC[eC.Backslash=1]="Backslash",eC[eC.Backspace=2]="Backspace",eC[eC.BracketLeft=3]="BracketLeft",eC[eC.BracketRight=4]="BracketRight",eC[eC.Comma=5]="Comma",eC[eC.Digit0=6]="Digit0",eC[eC.Digit1=7]="Digit1",eC[eC.Digit2=8]="Digit2",eC[eC.Digit3=9]="Digit3",eC[eC.Digit4=10]="Digit4",eC[eC.Digit5=11]="Digit5",eC[eC.Digit6=12]="Digit6",eC[eC.Digit7=13]="Digit7",eC[eC.Digit8=14]="Digit8",eC[eC.Digit9=15]="Digit9",eC[eC.Equal=16]="Equal",eC[eC.IntlBackslash=17]="IntlBackslash",eC[eC.IntlRo=18]="IntlRo",eC[eC.IntlYen=19]="IntlYen",eC[eC.KeyA=20]="KeyA",eC[eC.KeyB=21]="KeyB",eC[eC.KeyC=22]="KeyC",eC[eC.KeyD=23]="KeyD",eC[eC.KeyE=24]="KeyE",eC[eC.KeyF=25]="KeyF",eC[eC.KeyG=26]="KeyG",eC[eC.KeyH=27]="KeyH",eC[eC.KeyI=28]="KeyI",eC[eC.KeyJ=29]="KeyJ",eC[eC.KeyK=30]="KeyK",eC[eC.KeyL=31]="KeyL",eC[eC.KeyM=32]="KeyM",eC[eC.KeyN=33]="KeyN",eC[eC.KeyO=34]="KeyO",eC[eC.KeyP=35]="KeyP",eC[eC.KeyQ=36]="KeyQ",eC[eC.KeyR=37]="KeyR",eC[eC.KeyS=38]="KeyS",eC[eC.KeyT=39]="KeyT",eC[eC.KeyU=40]="KeyU",eC[eC.KeyV=41]="KeyV",eC[eC.KeyW=42]="KeyW",eC[eC.KeyX=43]="KeyX",eC[eC.KeyY=44]="KeyY",eC[eC.KeyZ=45]="KeyZ",eC[eC.Minus=46]="Minus",eC[eC.Period=47]="Period",eC[eC.Quote=48]="Quote",eC[eC.Semicolon=49]="Semicolon",eC[eC.Slash=50]="Slash",eC[eC.AltLeft=51]="AltLeft",eC[eC.AltRight=52]="AltRight",eC[eC.CapsLock=53]="CapsLock",eC[eC.ContextMenu=54]="ContextMenu",eC[eC.ControlLeft=55]="ControlLeft",eC[eC.ControlRight=56]="ControlRight",eC[eC.Enter=57]="Enter",eC[eC.MetaLeft=58]="MetaLeft",eC[eC.MetaRight=59]="MetaRight",eC[eC.ShiftLeft=60]="ShiftLeft",eC[eC.ShiftRight=61]="ShiftRight",eC[eC.Space=62]="Space",eC[eC.Tab=63]="Tab",eC[eC.Convert=64]="Convert",eC[eC.KanaMode=65]="KanaMode",eC[eC.Lang1=66]="Lang1",eC[eC.Lang2=67]="Lang2",eC[eC.Lang3=68]="Lang3",eC[eC.Lang4=69]="Lang4",eC[eC.Lang5=70]="Lang5",eC[eC.NonConvert=71]="NonConvert",eC[eC.Delete=72]="Delete",eC[eC.End=73]="End",eC[eC.Help=74]="Help",eC[eC.Home=75]="Home",eC[eC.Insert=76]="Insert",eC[eC.PageDown=77]="PageDown",eC[eC.PageUp=78]="PageUp",eC[eC.ArrowDown=79]="ArrowDown",eC[eC.ArrowLeft=80]="ArrowLeft",eC[eC.ArrowRight=81]="ArrowRight",eC[eC.ArrowUp=82]="ArrowUp",eC[eC.NumLock=83]="NumLock",eC[eC.Numpad0=84]="Numpad0",eC[eC.Numpad1=85]="Numpad1",eC[eC.Numpad2=86]="Numpad2",eC[eC.Numpad3=87]="Numpad3",eC[eC.Numpad4=88]="Numpad4",eC[eC.Numpad5=89]="Numpad5",eC[eC.Numpad6=90]="Numpad6",eC[eC.Numpad7=91]="Numpad7",eC[eC.Numpad8=92]="Numpad8",eC[eC.Numpad9=93]="Numpad9",eC[eC.NumpadAdd=94]="NumpadAdd",eC[eC.NumpadBackspace=95]="NumpadBackspace",eC[eC.NumpadClear=96]="NumpadClear",eC[eC.NumpadClearEntry=97]="NumpadClearEntry",eC[eC.NumpadComma=98]="NumpadComma",eC[eC.NumpadDecimal=99]="NumpadDecimal",eC[eC.NumpadDivide=100]="NumpadDivide",eC[eC.NumpadEnter=101]="NumpadEnter",eC[eC.NumpadEqual=102]="NumpadEqual",eC[eC.NumpadHash=103]="NumpadHash",eC[eC.NumpadMemoryAdd=104]="NumpadMemoryAdd",eC[eC.NumpadMemoryClear=105]="NumpadMemoryClear",eC[eC.NumpadMemoryRecall=106]="NumpadMemoryRecall",eC[eC.NumpadMemoryStore=107]="NumpadMemoryStore",eC[eC.NumpadMemorySubtract=108]="NumpadMemorySubtract",eC[eC.NumpadMultiply=109]="NumpadMultiply",eC[eC.NumpadParenLeft=110]="NumpadParenLeft",eC[eC.NumpadParenRight=111]="NumpadParenRight",eC[eC.NumpadStar=112]="NumpadStar",eC[eC.NumpadSubtract=113]="NumpadSubtract",eC[eC.Escape=114]="Escape",eC[eC.F1=115]="F1",eC[eC.F2=116]="F2",eC[eC.F3=117]="F3",eC[eC.F4=118]="F4",eC[eC.F5=119]="F5",eC[eC.F6=120]="F6",eC[eC.F7=121]="F7",eC[eC.F8=122]="F8",eC[eC.F9=123]="F9",eC[eC.F10=124]="F10",eC[eC.F11=125]="F11",eC[eC.F12=126]="F12",eC[eC.F13=127]="F13",eC[eC.F14=128]="F14",eC[eC.F15=129]="F15",eC[eC.Fn=130]="Fn",eC[eC.FnLock=131]="FnLock",eC[eC.PrintScreen=132]="PrintScreen",eC[eC.ScrollLock=133]="ScrollLock",eC[eC.Pause=134]="Pause",eC[eC.BrowserBack=135]="BrowserBack",eC[eC.BrowserFavorites=136]="BrowserFavorites",eC[eC.BrowserForward=137]="BrowserForward",eC[eC.BrowserHome=138]="BrowserHome",eC[eC.BrowserRefresh=139]="BrowserRefresh",eC[eC.BrowserSearch=140]="BrowserSearch",eC[eC.BrowserStop=141]="BrowserStop",eC[eC.Eject=142]="Eject",eC[eC.LaunchApp1=143]="LaunchApp1",eC[eC.LaunchApp2=144]="LaunchApp2",eC[eC.LaunchMail=145]="LaunchMail",eC[eC.MediaPlayPause=146]="MediaPlayPause",eC[eC.MediaSelect=147]="MediaSelect",eC[eC.MediaStop=148]="MediaStop",eC[eC.MediaTrackNext=149]="MediaTrackNext",eC[eC.MediaTrackPrevious=150]="MediaTrackPrevious",eC[eC.Power=151]="Power",eC[eC.Sleep=152]="Sleep",eC[eC.AudioVolumeDown=153]="AudioVolumeDown",eC[eC.AudioVolumeMute=154]="AudioVolumeMute",eC[eC.AudioVolumeUp=155]="AudioVolumeUp",eC[eC.WakeUp=156]="WakeUp",eC[eC.Hyper=157]="Hyper",eC[eC.Super=158]="Super",eC[eC.Turbo=159]="Turbo",eC[eC.Abort=160]="Abort",eC[eC.Resume=161]="Resume",eC[eC.Suspend=162]="Suspend",eC[eC.Again=163]="Again",eC[eC.Copy=164]="Copy",eC[eC.Cut=165]="Cut",eC[eC.Find=166]="Find",eC[eC.Open=167]="Open",eC[eC.Paste=168]="Paste",eC[eC.Props=169]="Props",eC[eC.Select=170]="Select",eC[eC.Undo=171]="Undo",eC[eC.Hiragana=172]="Hiragana",eC[eC.Katakana=173]="Katakana",eC[eC.Unidentified=174]="Unidentified",eC),av=/*#__PURE__*/function(){function e(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new rT,this._curFrameDownList=new rT,this._curFrameUpList=new rT,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,i=this._curHeldDownKeyToIndexMap,a=this._curFrameHeldDownList,o=this._downKeyToFrameCountMap,s=this._upKeyToFrameCountMap,l=0,c=e.length;l<c;l++){var u=e[l],d=ag[u.code];switch(u.type){case"keydown":null==i[d]&&(t.add(d),a.add(d),i[d]=a.length-1,o[d]=r);break;case"keyup":var h=i[d];if(null!=h){i[d]=null;var _=a.deleteByIndex(h);_&&(i[_]=h)}if(n.add(d),s[d]=r,am.platform===tG.Mac&&(d===ag.MetaLeft||d===ag.MetaRight)){for(var f=0,p=a.length;f<p;f++)i[a.get(f)]=null;a.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}tX(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 i=t[n];this._removeNativeShape(i),i._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)},tW(t,[{key:"shapes",get:function(){return this._shapes}}]),t}(rh),tq([tJ],e.Collider.prototype,"_index",void 0),tq([tJ],e.Collider.prototype,"_nativeCollider",void 0),tq([tJ],e.Collider.prototype,"_updateFlag",void 0),tq([t0],e.Collider.prototype,"_shapes",void 0),e.Collider=tq([rf(rg,rp.CheckOnly)],e.Collider);var ay=function(){this.position=new tR,this.normal=new tR,this.impulse=new tR},ax=/*#__PURE__*/function(){function e(){}return e.prototype.getContacts=function(e){for(var t=this._nativeCollision,n=t.shape0Id<t.shape1Id?1:-1,r=t.getContacts(),i=r.size(),a=0;a<i;a++){var o,s=r.get(a),l=e[o=a]||(e[o]=new ay);l.position.copyFrom(s.position),l.normal.copyFrom(s.normal).scale(n),l.impulse.copyFrom(s.impulse).scale(n),l.separation=s.separation}return i},tW(e,[{key:"contactCount",get:function(){return this._nativeCollision.contactCount}}]),e}(),ab=/*#__PURE__*/function(){function e(t){this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new rT,this._gravity=new tR(0,-9.81,0),this._onContactEnter=function(t){var n=on._physicalObjectsMap,r=t.shape0Id,i=t.shape1Id,a=n[r],o=n[i],s=e._collision;s._nativeCollision=t,a.collider.entity._scripts.forEach(function(e){s.shape=o,e.onCollisionEnter(s)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){s.shape=a,e.onCollisionEnter(s)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(t){var n=on._physicalObjectsMap,r=t.shape0Id,i=t.shape1Id,a=n[r],o=n[i],s=e._collision;s._nativeCollision=t,a.collider.entity._scripts.forEach(function(e){s.shape=o,e.onCollisionExit(s)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){s.shape=a,e.onCollisionExit(s)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(t){var n=on._physicalObjectsMap,r=t.shape0Id,i=t.shape1Id,a=n[r],o=n[i],s=e._collision;s._nativeCollision=t,a.collider.entity._scripts.forEach(function(e){s.shape=o,e.onCollisionStay(s)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){s.shape=a,e.onCollisionStay(s)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=on._physicalObjectsMap,r=n[e],i=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=on._physicalObjectsMap,r=n[e],i=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=on._physicalObjectsMap,r=n[e],i=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},function(e,t){e._entityScriptsIndex=t}),i.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 i,a=Number.MAX_VALUE;"number"==typeof t?a=t:void 0!=t&&(i=t);var o=rM.Everything;"number"==typeof n?o=n:void 0!=n&&(i=n),r&&(i=r);var s=function(e){var t=on._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&o&&t.isSceneQuery};return void 0==i?this._nativePhysicsScene.raycast(e,a,s):!!this._nativePhysicsScene.raycast(e,a,s,function(e,t,n,r){var a=on._physicalObjectsMap[e];i.entity=a._collider.entity,i.shape=a,i.distance=t,i.normal.copyFrom(r),i.point.copyFrom(n)})||(i.entity=null,i.shape=null,i.distance=0,i.point.set(0,0,0),i.normal.set(0,0,0),!1)},t._update=function(e){var t=this._fixedTimeStep,n=this._nativePhysicsScene,r=this._scene._componentsManager,i=this._restTime+e,a=Math.floor(i/t);this._restTime=i-a*t;for(var o=0;o<a;o++)r.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),n.update(t),this._callColliderOnLateUpdate()},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)},tW(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,tA.zeroTolerance)}}]),e}();ab._collision=new ax;var aC=((eS={})[eS.PreventClimbing=0]="PreventClimbing",eS[eS.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding",eS),aS=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=aC.PreventClimbing,n._upDirection=new tR(0,1,0),n._slopeLimit=45,n._nativeCollider=ab._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(n),n._upDirection._onValueChanged=n._setUpDirection,n._onUpdate(),n}tX(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,i=t.length;r<i;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)},tW(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);tq([t0],aS.prototype,"_upDirection",void 0),tq([tJ],aS.prototype,"_setUpDirection",null);var aT=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._linearDamping=0,n._angularDamping=.05,n._linearVelocity=new tR,n._angularVelocity=new tR,n._mass=1,n._centerOfMass=new tR,n._inertiaTensor=new tR(1,1,1),n._maxAngularVelocity=18e3/Math.PI,n._maxDepenetrationVelocity=10000000331813535e16,n._solverIterations=4,n._useGravity=!0,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=ab._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}tX(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)},tW(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:"useGravity",get:function(){return this._useGravity},set:function(e){this._useGravity!==e&&(this._useGravity=e,this._nativeCollider.setUseGravity(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);tq([tJ],aT.prototype,"_linearVelocity",void 0),tq([tJ],aT.prototype,"_angularVelocity",void 0),tq([tJ],aT.prototype,"_centerOfMass",void 0),tq([tJ],aT.prototype,"_inertiaTensor",void 0),tq([tJ],aT.prototype,"_setLinearVelocity",null),tq([tJ],aT.prototype,"_setAngularVelocity",null),tq([tJ],aT.prototype,"_handleCenterOfMassChanged",null),tq([tJ],aT.prototype,"_handleInertiaTensorChanged",null);var aA=((eT={})[eT.Discrete=0]="Discrete",eT[eT.Continuous=1]="Continuous",eT[eT.ContinuousDynamic=2]="ContinuousDynamic",eT[eT.ContinuousSpeculative=3]="ContinuousSpeculative",eT),aR=((eA={})[eA.None=0]="None",eA[eA.FreezePositionX=1]="FreezePositionX",eA[eA.FreezePositionY=2]="FreezePositionY",eA[eA.FreezePositionZ=4]="FreezePositionZ",eA[eA.FreezeRotationX=8]="FreezeRotationX",eA[eA.FreezeRotationY=16]="FreezeRotationY",eA[eA.FreezeRotationZ=32]="FreezeRotationZ",eA),aE=function(){this.entity=null,this.distance=0,this.point=new tR,this.normal=new tR,this.shape=null},aM=((eR={})[eR.Average=0]="Average",eR[eR.Minimum=1]="Minimum",eR[eR.Multiply=2]="Multiply",eR[eR.Maximum=3]="Maximum",eR),aw=/*#__PURE__*/function(){function e(){this._bounciness=0,this._dynamicFriction=.6,this._staticFriction=.6,this._bounceCombine=aM.Average,this._frictionCombine=aM.Average,this._nativeMaterial=ab._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},tW(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}(),aP=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t)||this).entity.transform;return n._nativeCollider=ab._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),n}return tX(t,e),t}(e.Collider),aF=((eE={})[eE.X=0]="X",eE[eE.Y=1]="Y",eE[eE.Z=2]="Z",eE),aL=((eM={})[eM.Sides=1]="Sides",eM[eM.Up=2]="Up",eM[eM.Down=4]="Down",eM);e.Joint=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._colliderInfo=new aD,n._connectedColliderInfo=new aD,n._force=1/0,n._torque=1/0,n._automaticConnectedAnchor=!0,n._colliderInfo.anchor._onValueChanged=n._updateActualAnchor.bind(n,1),n._updateConnectedActualAnchor=n._updateActualAnchor.bind(n,2),n._connectedColliderInfo.anchor._onValueChanged=n._updateConnectedActualAnchor,n._onSelfTransformChanged=n._onSelfTransformChanged.bind(n),n._onConnectedTransformChanged=n._onConnectedTransformChanged.bind(n),t._updateFlagManager.addListener(n._onSelfTransformChanged),n}tX(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,i=e.actualAnchor,a=n.anchor,o=n.actualAnchor,s=n.collider;if(s){var l=s.entity.transform,c=l.worldPosition,u=l.lossyWorldScale;tR.subtract(r,c,t._tempVector3),tR.add(t._tempVector3,i,o),tR.divide(o,u,a)}else tR.add(r,i,o),a.copyFrom(o)},n._onSelfTransformChanged=function(e){e&rv.WorldScale&&this._updateActualAnchor(1)},n._onConnectedTransformChanged=function(e){e&rv.WorldScale&&this._updateActualAnchor(2)},n._updateActualAnchor=function(e){if(1&e){var t,n=this.entity.transform.lossyWorldScale,r=this._colliderInfo;tR.multiply(r.anchor,n,r.actualAnchor),null==(t=this._nativeJoint)||t.setAnchor(r.actualAnchor)}if(2&e){var i,a=this._connectedColliderInfo,o=a.collider;if(o){var s=o.entity.transform.lossyWorldScale;tR.multiply(a.anchor,s,a.actualAnchor)}else a.actualAnchor.copyFrom(a.anchor);null==(i=this._nativeJoint)||i.setConnectedAnchor(a.actualAnchor)}},tW(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(null==e?void 0: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(){var e=this._connectedColliderInfo.anchor;return this._automaticConnectedAnchor&&(e._onValueChanged=null,this._calculateConnectedAnchor(),e._onValueChanged=this._updateConnectedActualAnchor),e},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}(rh),e.Joint._tempVector3=new tR,tq([t0],e.Joint.prototype,"_colliderInfo",void 0),tq([t0],e.Joint.prototype,"_connectedColliderInfo",void 0),tq([tJ],e.Joint.prototype,"_nativeJoint",void 0),tq([tJ],e.Joint.prototype,"_updateConnectedActualAnchor",void 0),tq([tJ],e.Joint.prototype,"_onSelfTransformChanged",null),tq([tJ],e.Joint.prototype,"_onConnectedTransformChanged",null),e.Joint=tq([rf(aT,rp.AutoAdd)],e.Joint);var aD=function(){this.collider=null,this.anchor=new tR,this.actualAnchor=new tR,this.massScale=1,this.inertiaScale=1};tq([t0],aD.prototype,"anchor",void 0),tq([t0],aD.prototype,"actualAnchor",void 0);var aB=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return tX(n,t),n.prototype._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ab._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n}(e.Joint),aI=((ew={})[ew.None=0]="None",ew[ew.LimitEnabled=1]="LimitEnabled",ew[ew.DriveEnabled=2]="DriveEnabled",ew[ew.DriveFreeSpin=4]="DriveFreeSpin",ew),aO=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._axis=new tR(1,0,0),n._hingeFlags=aI.None,n._useSpring=!1,n._angle=0,n._velocity=0,n._onMotorChanged=n._onMotorChanged.bind(n),n._onLimitsChanged=n._onLimitsChanged.bind(n),n}tX(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=ab._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(aI.LimitEnabled,this.useLimits),this._nativeJoint.setHingeJointFlag(aI.DriveEnabled,this.useMotor),e&&(this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRatio),this._nativeJoint.setHingeJointFlag(aI.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(aI.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))},tW(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&aI.LimitEnabled)==aI.LimitEnabled},set:function(e){if(e!==this.useLimits){var t;e?this._hingeFlags|=aI.LimitEnabled:this._hingeFlags&=~aI.LimitEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(aI.LimitEnabled,e)}}},{key:"useMotor",get:function(){return(this._hingeFlags&aI.DriveEnabled)==aI.DriveEnabled},set:function(e){if(e!==this.useMotor){var t;e?this._hingeFlags|=aI.DriveEnabled:this._hingeFlags&=~aI.DriveEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(aI.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);tq([t0],aO.prototype,"_axis",void 0),tq([t0],aO.prototype,"_jointMotor",void 0),tq([t0],aO.prototype,"_limits",void 0),tq([tJ],aO.prototype,"_onMotorChanged",null),tq([tJ],aO.prototype,"_onLimitsChanged",null);var aN=/*#__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}tX(n,t);var r=n.prototype;return r._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ab._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)},tW(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),aV=/*#__PURE__*/function(){function e(){this._updateFlagManager=new nP,this._max=0,this._min=0,this._contactDistance=-1,this._stiffness=0,this._damping=0}return tW(e,[{key:"max",get:function(){return this._max},set:function(e){this._max!==e&&(e<this._min&&(this._min=e),this._max=e,this._updateFlagManager.dispatch())}},{key:"min",get:function(){return this._min},set:function(e){this._min!==e&&(e>this._max&&(this._max=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}();tq([t0],aV.prototype,"_updateFlagManager",void 0);var ak=/*#__PURE__*/function(){function e(){this._updateFlagManager=new nP,this._targetVelocity=0,this._forceLimit=Number.MAX_VALUE,this._gearRatio=1,this._freeSpin=!1}return tW(e,[{key:"targetVelocity",get:function(){return this._targetVelocity},set:function(e){this._targetVelocity!==e&&(this._targetVelocity=e,this._updateFlagManager.dispatch())}},{key:"forceLimit",get:function(){return this._forceLimit},set:function(e){this._forceLimit!==e&&(this._forceLimit=e,this._updateFlagManager.dispatch())}},{key:"gearRatio",get:function(){return this._gearRatio},set:function(e){this._gearRatio!==e&&(this._gearRatio=e,this._updateFlagManager.dispatch())}},{key:"freeSpin",get:function(){return this._freeSpin},set:function(e){this._freeSpin!==e&&(this._freeSpin=e,this._updateFlagManager.dispatch())}}]),e}();tq([t0],ak.prototype,"_updateFlagManager",void 0);var az=/*#__PURE__*/function(){function e(){this._isTrigger=!1,this._rotation=new tR,this._position=new tR,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new aw,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,on._physicalObjectsMap[this._id]=this}var t=e.prototype;return t.getClosestPoint=function(e,t){var n=this._collider;if(!1===n.enabled||!1===n.entity._isActiveInHierarchy)return console.warn("The collider is not active in scene."),-1;var r=this._nativeShape.pointDistance(e),i=r.w;return i>0?t.set(r.x,r.y,r.z):t.copyFrom(e),Math.sqrt(i)},t._cloneTo=function(e){e._syncNative()},t._destroy=function(){this._nativeShape.destroy(),this._nativeShape=null,delete on._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()},tW(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){if(!e)throw Error("The physics material of the shape can't be null.");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}();az._idGenerator=0,tq([tJ],az.prototype,"_collider",void 0),tq([tJ],az.prototype,"_nativeShape",void 0),tq([tJ],az.prototype,"_id",void 0),tq([t0],az.prototype,"_rotation",void 0),tq([t0],az.prototype,"_position",void 0),tq([tJ],az.prototype,"_setPosition",null),tq([tJ],az.prototype,"_setRotation",null);var aU=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._size=new tR(1,1,1),t._nativeShape=ab._nativePhysics.createBoxColliderShape(t._id,t._size,t._material._nativeMaterial),t._size._onValueChanged=t._setSize.bind(t),t}tX(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)},tW(t,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),t}(az);tq([t0],aU.prototype,"_size",void 0),tq([tJ],aU.prototype,"_setSize",null);var aG=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._nativeShape=ab._nativePhysics.createSphereColliderShape(t._id,t._radius,t._material._nativeMaterial),t}return tX(t,e),t.prototype._syncNative=function(){e.prototype._syncNative.call(this),this._nativeShape.setRadius(this._radius)},tW(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),t}(az),aH=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._nativeShape=ab._nativePhysics.createPlaneColliderShape(t._id,t._material._nativeMaterial),t}return tX(t,e),t.prototype.getClosestPoint=function(e,t){return console.error("PlaneColliderShape is not support getClosestPoint"),-1},t}(az),aW=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._height=2,t._upAxis=aF.Y,t._nativeShape=ab._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t}return tX(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)},tW(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}(az),aj=/*#__PURE__*/function(){function e(e,t){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=a_.None,this._upMap=[],this._downMap=[],this._upList=new rT,this._downList=new rT,this._nativeEvents=[],"undefined"!=typeof Window&&tY(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,i=r.width,a=r.height,o=n.clientWidth,s=n.clientHeight,l=n.getBoundingClientRect(),c=l.left,u=l.top,d=i/o,h=a/s,_=e.length-1;_>=0;_--)e[_].phase===ad.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 ah(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=a_.None;for(var S=this._engine.time.frameCount,T=0,A=e.length;T<A;T++){var R=e[T];R._upList.length=R._downList.length=0,this._updatePointerInfo(S,R,c,u,d,h),this._buttons|=R.pressedButtons}},t._firePointerScript=function(e){for(var t=this._pointers,n=this._canvas,r=0,i=t.length;r<i;r++){var a=t[r],o=a._events,s=a.position;a._firePointerDrag();var l=this._pointerRayCast(e,s.x/n.width,s.y/n.height);a._firePointerExitAndEnter(l);var c=o.length;if(c>0){for(var u=0;u<c;u++)switch(o[u].type){case"pointerdown":a.phase=ad.Down,a._firePointerDown(l);break;case"pointerup":a.phase=ad.Up,a._firePointerUpAndClick(l);break;case"pointerleave":case"pointercancel":a.phase=ad.Leave,a._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,i,a){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)*i,p=(_.clientY-r)*a;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=af[v]||a_.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=ad.Down;break;case"pointerup":c.add(v),u[v]=e,t._upList.add(v),t._upMap[v]=e,t.phase=ad.Up;break;case"pointermove":t.phase=ad.Move;break;case"pointerleave":case"pointercancel":t.phase=ad.Leave}}this._engine._physicsInitialized||(o.length=0)}else t.deltaPosition.set(0,0),t.phase=ad.Stationary},t._pointerRayCast=function(t,n,r){for(var i=e._tempPoint,a=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(i.set((n-f)/m,(r-p)/g),l.physics.raycast(h.viewportPointToRay(i,a),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&rF.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}();aj._tempRay=new tI,aj._tempPoint=new tO,aj._tempHitResult=new aE;var aX=/*#__PURE__*/function(){function e(e,t){this._delta=new tR,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}(),aK=/*#__PURE__*/function(){function e(e,t){this._initialized=!1,this._engine=e;var n,r,i,a=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&tY(a,OffscreenCanvas)||(this._wheelManager=new aX(e,null!=(n=null==t?void 0:t.wheelTarget)?n:a),this._pointerManager=new aj(e,null!=(r=null==t?void 0:t.pointerTarget)?r:a),this._keyboardManager=new av(e,null!=(i=null==t?void 0:t.keyboardTarget)?i: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[ap[e]]===this._engine.time.frameCount)},t.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[ap[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)},tW(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}(),aq=((eP={}).cornerTextureCoordinate="a_CornerTextureCoordinate",eP),aY=((eF={}).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",eF.DirectionTime="a_DirectionTime",eF.StartColor="a_StartColor",eF.StartSize="a_StartSize",eF.StartRotation0="a_StartRotation0",eF.StartSpeed="a_StartSpeed",eF.Random0="a_Random0",eF.Random1="a_Random1",eF.SimulationWorldPosition="a_SimulationWorldPosition",eF.SimulationWorldRotation="a_SimulationWorldRotation",eF.SimulationUV="a_SimulationUV",eF),aQ=function e(t){this.billboardVertexElement=new ia(aq.cornerTextureCoordinate,0,ir.Vector4,0),this.instanceVertexElements=[new ia(aY.ShapePositionStartLifeTime,0,ir.Vector4,1,1),new ia(aY.DirectionTime,16,ir.Vector4,1,1),new ia(aY.StartColor,32,ir.Vector4,1,1),new ia(aY.StartSize,48,ir.Vector3,1,1),new ia(aY.StartRotation0,60,ir.Vector3,1,1),new ia(aY.StartSpeed,72,ir.Float,1,1),new ia(aY.Random0,76,ir.Vector4,1,1),new ia(aY.Random1,92,ir.Vector4,1,1),new ia(aY.SimulationWorldPosition,108,ir.Vector3,1,1),new ia(aY.SimulationWorldRotation,120,ir.Vector4,1,1),new ia(aY.SimulationUV,136,ir.Vector4,1,1)];var n=new ie(t,io.VertexBuffer,64,r6.Static,!1);n.isGCIgnored=!0,this.billboardVertexBufferBinding=new iw(n,16);var r=new ie(t,io.IndexBuffer,e.billboardIndexCount,r6.Static,!1);r.isGCIgnored=!0,this.billboardIndexBufferBinding=new iS(r,it.UInt8);var i=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),a=new Uint8Array([0,2,3,0,1,2]);n.setData(i),r.setData(a),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tX(t,e),t.prototype.restoreContent=function(){n.setData(i)},t}(t4))),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,r)||this}return tX(t,e),t.prototype.restoreContent=function(){},t}(t4)))};aQ.instanceVertexStride=152,aQ.instanceVertexFloatStride=aQ.instanceVertexStride/4,aQ.startLifeTimeOffset=3,aQ.timeOffset=7,aQ.simulationUVOffset=34,aQ.billboardIndexCount=6,aQ.boundsFloatStride=8,aQ.boundsTimeOffset=6,aQ.boundsMaxLifetimeOffset=7;var aJ="#define GLSLIFY 1\nattribute vec4 POSITION_UV;\nvarying vec2 v_uv;\n\nvoid main() { \n gl_Position = vec4(POSITION_UV.xy, 0.0, 1.0); \n v_uv = POSITION_UV.zw;\n}",aZ=/*#__PURE__*/function(){function e(e,t,n,r){this.enabled=!0,this._needLerp=!1,"number"==typeof e?"boolean"==typeof t?(this._needLerp=t,this._min=Number.NEGATIVE_INFINITY,this._max=Number.POSITIVE_INFINITY):"number"==typeof t?(this._min=t,this._max=null!=n?n:Number.POSITIVE_INFINITY,this._needLerp=null!=r&&r):void 0==t&&(this._min=Number.NEGATIVE_INFINITY,this._max=Number.POSITIVE_INFINITY):this._needLerp=null!=t&&t,this.value=e}return e.prototype._lerp=function(e,t){if(this._needLerp){var n;switch(null==(n=this.value)?void 0:n.constructor){case Number:this.value=tA.lerp(this.value,e,t);break;case tV:tV.lerp(this.value,e,t,this.value);break;case tO:tO.lerp(this.value,e,t,this.value);break;case tR:tR.lerp(this.value,e,t,this.value);break;case tN:tN.lerp(this.value,e,t,this.value);break;default:t>0&&(this.value=e)}}else t>0&&(this.value=e)},tW(e,[{key:"value",get:function(){return this._value},set:function(e){(null==e?void 0:e.constructor)===Number?this._value=tA.clamp(e,this._min,this._max):this._value=e}}]),e}(),a$=/*#__PURE__*/function(){function e(){this._enabled=!0,this._parameters=[],this._parameterInitialized=!1}var t=e.prototype;return t.isValid=function(){return this._enabled},t._lerp=function(e,t){for(var n=this._getParameters(),r=e._getParameters(),i=0,a=n.length;i<a;i++){var o=r[i];o.enabled&&n[i]._lerp(o.value,t)}},t._getParameters=function(){if(!this._parameterInitialized)for(var e in this._parameterInitialized=!0,this){var t=this[e];tY(t,aZ)&&this._parameters.push(t)}return this._parameters},tW(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e)}}]),e}(),a0=((eL={})[eL.Half=0]="Half",eL[eL.Quarter=1]="Quarter",eL),a1=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.highQualityFiltering=new aZ(!1),t.downScale=new aZ(0),t.dirtTexture=new aZ(null),t.threshold=new aZ(.9,0,Number.POSITIVE_INFINITY,!0),t.scatter=new aZ(.7,0,1,!0),t.intensity=new aZ(0,0,Number.POSITIVE_INFINITY,!0),t.dirtIntensity=new aZ(0,0,Number.POSITIVE_INFINITY,!0),t.tint=new aZ(new tV(1,1,1,1),!0),t}return tX(t,e),t.prototype.isValid=function(){return this.enabled&&this.intensity.value>0},t}(a$);a1.SHADER_NAME="PostProcessEffect Bloom",a1._maxIterations=6,a1._hqMacro=nj.getByName("BLOOM_HQ"),a1._dirtMacro=nj.getByName("BLOOM_DIRT"),a1._bloomParams=nQ.getByName("material_BloomParams"),a1._lowMipTextureProp=nQ.getByName("material_lowMipTexture"),a1._lowMipTexelSizeProp=nQ.getByName("material_lowMipTexelSize"),a1._enableMacro=nj.getByName("ENABLE_EFFECT_BLOOM"),a1._bloomTextureProp=nQ.getByName("material_BloomTexture"),a1._dirtTextureProp=nQ.getByName("material_BloomDirtTexture"),a1._tintProp=nQ.getByName("material_BloomTint"),a1._bloomIntensityParams=nQ.getByName("material_BloomIntensityParams"),a1._dirtTilingOffsetProp=nQ.getByName("material_BloomDirtTilingOffset"),rl.create(a1.SHADER_NAME,[new re("Bloom Prefilter",aJ,"#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 material_BloomParams; // x: threshold (linear), y: threshold knee, z: scatter\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n #ifdef BLOOM_HQ\n vec2 texelSize = renderer_texelSize.xy;\n mediump vec4 A = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, -1.0));\n mediump vec4 B = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, -1.0));\n mediump vec4 C = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, -1.0));\n mediump vec4 D = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, -0.5));\n mediump vec4 E = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, -0.5));\n mediump vec4 F = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 0.0));\n mediump vec4 G = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 H = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 0.0));\n mediump vec4 I = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, 0.5));\n mediump vec4 J = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, 0.5));\n mediump vec4 K = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 1.0));\n mediump vec4 L = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, 1.0));\n mediump vec4 M = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 1.0));\n\n mediump vec2 scale = vec2(0.5, 0.125);\n mediump vec2 div = (1.0 / 4.0) * scale;\n\n mediump vec4 samplerColor = (D + E + I + J) * div.x;\n samplerColor += (A + B + G + F) * div.y;\n samplerColor += (B + C + H + G) * div.y;\n samplerColor += (F + G + L + K) * div.y;\n samplerColor += (G + H + M + L) * div.y;\n #else\n mediump vec4 samplerColor = sampleTexture(renderer_BlitTexture, v_uv);\n #endif\n\n mediump vec3 color = samplerColor.rgb;\n\n // User controlled clamp to limit crazy high broken spec\n color = min(color, HALF_MAX);\n\n // Thresholding\n mediump float brightness = max3(color);\n float threshold = material_BloomParams.x;\n float thresholdKnee = material_BloomParams.y;\n mediump float softness = clamp(brightness - threshold + thresholdKnee, 0.0, 2.0 * thresholdKnee);\n softness = (softness * softness) / (4.0 * thresholdKnee + 1e-4);\n mediump float multiplier = max(brightness - threshold, softness) / max(brightness, 1e-4);\n color *= multiplier;\n\n // Clamp colors to positive once in prefilter. Encode can have a sqrt, and sqrt(-x) == NaN. Up/Downsample passes would then spread the NaN.\n color = max(color, 0.0);\n\n gl_FragColor = vec4(color, samplerColor.a);\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"),new re("Bloom Blur Horizontal",aJ,"#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n vec2 texelSize = renderer_texelSize.xy * 2.0;\n\n // 9-tap gaussian blur on the downsampled source\n mediump vec4 c0 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 4.0, 0.0));\n mediump vec4 c1 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 3.0, 0.0));\n mediump vec4 c2 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 2.0, 0.0));\n mediump vec4 c3 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 1.0, 0.0));\n mediump vec4 c4 = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 c5 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 1.0, 0.0));\n mediump vec4 c6 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 2.0, 0.0));\n mediump vec4 c7 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 3.0, 0.0));\n mediump vec4 c8 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 4.0, 0.0));\n\n gl_FragColor = c0 * 0.01621622 + c1 * 0.05405405 + c2 * 0.12162162 + c3 * 0.19459459\n + c4 * 0.22702703\n + c5 * 0.19459459 + c6 * 0.12162162 + c7 * 0.05405405 + c8 * 0.01621622;\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"),new re("Bloom Blur Vertical",aJ,"#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n vec2 texelSize = renderer_texelSize.xy;\n\n // Optimized bilinear 5-tap gaussian on the same-sized source (9-tap equivalent)\n mediump vec4 c0 = sampleTexture(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 3.23076923));\n mediump vec4 c1 = sampleTexture(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c2 = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 c3 = sampleTexture(renderer_BlitTexture, v_uv + vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c4 = sampleTexture(renderer_BlitTexture, v_uv + vec2(0.0, texelSize.y * 3.23076923));\n\n gl_FragColor = c0 * 0.07027027 + c1 * 0.31621622\n + c2 * 0.22702703\n + c3 * 0.31621622 + c4 * 0.07027027;\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"),new re("Bloom Upsample",aJ,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform sampler2D material_lowMipTexture;\nuniform vec4 material_BloomParams; // x: threshold (linear), y: threshold knee, z: scatter\nuniform vec4 material_lowMipTexelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n mediump vec4 highMip = sampleTexture(renderer_BlitTexture, v_uv);\n\n #ifdef BLOOM_HQ\n mediump vec4 lowMip = sampleTexture2DBicubic(material_lowMipTexture, v_uv, material_lowMipTexelSize);\n #else\n mediump vec4 lowMip = sampleTexture(material_lowMipTexture, v_uv);\n #endif\n \n gl_FragColor = mix(highMip, lowMip, material_BloomParams.z);\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}")]);var a2=((eD={})[eD.Neutral=0]="Neutral",eD[eD.ACES=1]="ACES",eD),a3=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.mode=new aZ(0,!1),t}return tX(t,e),t}(a$);a3._enableMacro=nj.getByName("ENABLE_EFFECT_TONEMAPPING");var a4=((eB={})[eB.BeforeUber=0]="BeforeUber",eB[eB.AfterUber=100]="AfterUber",eB),a8=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._event=100,t._isActive=!0,t}tX(t,e);var n=t.prototype;return n.isValid=function(e){return this._isActive},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.engine._removePostProcessPass(this)},tW(t,[{key:"event",get:function(){return this._event},set:function(e){e!==this._event&&(this._event=e,this._isActive&&(this.engine._postProcessPassNeedRefresh=!0))}},{key:"isActive",get:function(){return this._isActive},set:function(e){e!==this._isActive&&(this._isActive=e,this.engine._postProcessPassNeedRefresh=!0)}}]),t}(t2),a5=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._mipDownRT=[],r._mipUpRT=[],r.event=a4.AfterUber-1;var r,i=new iu(n,rl.find(t.UBER_SHADER_NAME)),a=i.renderState.depthState;a.enabled=!1,a.writeEnabled=!1,r._uberMaterial=i;var o=new iu(n,rl.find(a1.SHADER_NAME)),s=o.renderState.depthState;s.enabled=!1,s.writeEnabled=!1,r._bloomMaterial=o;var l=o.shaderData,c=i.shaderData;return l.setVector4(a1._bloomParams,new tN),l.setVector4(a1._lowMipTexelSizeProp,new tN),c.setVector4(a1._bloomIntensityParams,new tN),c.setVector4(a1._dirtTilingOffsetProp,new tN),c.setColor(a1._tintProp,new tV),r}tX(t,e);var n=t.prototype;return n.isValid=function(e){if(!this.isActive)return!1;var t=e.getBlendEffect(a1),n=e.getBlendEffect(a3);return(null==t?void 0:t.isValid())||(null==n?void 0:n.isValid())},n.onRender=function(e,t,n){var r=e.scene.postProcessManager,i=this._uberMaterial.shaderData,a=r.getBlendEffect(a1),o=r.getBlendEffect(a3);(null==a?void 0:a.isValid())?(this._setupBloom(a,e,t),i.enableMacro(a1._enableMacro)):(i.disableMacro(a1._enableMacro),this._releaseBloomRenderTargets()),(null==o?void 0:o.isValid())?(i.enableMacro("TONEMAPPING_MODE",o.mode.value.toString()),i.enableMacro(a3._enableMacro)):i.disableMacro(a3._enableMacro),rj.blitTexture(e.engine,t,n,0,e.viewport,this._uberMaterial,void 0)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._releaseBloomRenderTargets(),this._uberMaterial.destroy(),this._bloomMaterial.destroy()},n._setupBloom=function(e,t,n){var r=t.engine,i=this._bloomMaterial,a=i.shaderData,o=this._uberMaterial.shaderData,s=e.downScale,l=e.threshold,c=e.scatter,u=e.intensity,d=e.tint,h=e.highQualityFiltering,_=e.dirtTexture,f=e.dirtIntensity,p=tV.gammaToLinearSpace(l.value),m=a.getVector4(a1._bloomParams),g=tA.lerp(.05,.95,c.value);m.x=l.value,m.y=.5*p,m.z=g;var v=o.getVector4(a1._bloomIntensityParams);v.x=u.value,v.y=f.value,o.getColor(a1._tintProp).copyFrom(d.value),h.value?(a.enableMacro(a1._hqMacro),o.enableMacro(a1._hqMacro)):(a.disableMacro(a1._hqMacro),o.disableMacro(a1._hqMacro)),o.setTexture(a1._dirtTextureProp,_.value),_?o.enableMacro(a1._dirtMacro):o.disableMacro(a1._dirtMacro);for(var y=s.value===a0.Half?1:2,x=t.pixelViewport,b=x.width>>y,C=x.height>>y,S=Math.min(Math.max(Math.floor(Math.log2(Math.max(b,C))-1),1),a1._maxIterations),T=t._getInternalColorTextureFormat(),A=b,R=C,E=0;E<S;E++)this._mipUpRT[E]=rw.recreateRenderTargetIfNeeded(r,this._mipUpRT[E],A,R,T,null,!1,!1,1,nt.Clamp,t6.Bilinear),this._mipDownRT[E]=rw.recreateRenderTargetIfNeeded(r,this._mipDownRT[E],A,R,T,null,!1,!1,1,nt.Clamp,t6.Bilinear),A=Math.max(1,Math.floor(A/2)),R=Math.max(1,Math.floor(R/2));rj.blitTexture(r,n,this._mipDownRT[0],void 0,void 0,i,0);for(var M=this._mipDownRT[0],w=1;w<S;w++)rj.blitTexture(r,M.getColorTexture(0),this._mipUpRT[w],void 0,void 0,i,1),rj.blitTexture(r,this._mipUpRT[w].getColorTexture(0),this._mipDownRT[w],void 0,void 0,i,2),M=this._mipDownRT[w];for(var P=S-2;P>=0;P--){var F=P==S-2?this._mipDownRT[P+1]:this._mipUpRT[P+1],L=this._mipDownRT[P],D=this._mipUpRT[P];a.setTexture(a1._lowMipTextureProp,F.getColorTexture(0)),h&&a.getVector4(a1._lowMipTexelSizeProp).set(1/F.width,1/F.height,F.width,F.height),rj.blitTexture(r,L.getColorTexture(0),D,void 0,void 0,i,3)}if(_.value){var B=o.getVector4(a1._dirtTilingOffsetProp),I=_.value.width/_.value.height,O=t.aspectRatio;I>O?B.set(O/I,1,(1-B.x)*.5,0):I<O?B.set(1,I/O,0,(1-B.y)*.5):B.set(1,1,0,0)}o.setTexture(a1._bloomTextureProp,this._mipUpRT[0].getColorTexture(0))},n._releaseBloomRenderTargets=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},t}(a8);a5.UBER_SHADER_NAME="UberPost",Object.assign(n0,{PostCommon:"#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n\n#include <common>\n#define FLT_MIN 1.175494351e-38 // Minimum normalized positive floating-point number\n#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats\n#define HALF_MAX 65504.0 // (2 - 2^-10) * 2^15\n\nfloat min3(vec3 val) { return min(min(val.x, val.y), val.z); }\nfloat max3(vec3 val) { return max(max(val.x, val.y), val.z); }\n\nconst float INVERT_LOG10 = 0.43429448190325176;\n\nfloat log10(float x){\n return log(x) * INVERT_LOG10;\n}\n\nvec4 sampleTexture(sampler2D tex, vec2 uv){\n vec4 color = texture2D(tex, uv);\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n color = gammaToLinear(color);\n #endif \n\n return color;\n}\n\n#endif",Filtering:"#define GLSLIFY 1\n#ifndef FILTERING\n#define FILTERING\n\nvec2 bSpline3MiddleLeft(vec2 x){\n return 0.16666667 + x * (0.5 + x * (0.5 - x * 0.5));\n}\n\nvec2 bSpline3MiddleRight(vec2 x){\n return 0.66666667 + x * (-1.0 + 0.5 * x) * x;\n}\n\nvec2 bSpline3Rightmost(vec2 x){\n return 0.16666667 + x * (-0.5 + x * (0.5 - x * 0.16666667));\n}\n\n// Compute weights & offsets for 4x bilinear taps for the bicubic B-Spline filter.\n// The fractional coordinate should be in the [0, 1] range (centered on 0.5).\n// Inspired by: http://vec3.ca/bicubic-filtering-in-fewer-taps/\nvoid bicubicFilter(vec2 fracCoord, out vec2 weights[2], out vec2 offsets[2]){\n vec2 r = bSpline3Rightmost(fracCoord);\n vec2 mr = bSpline3MiddleRight(fracCoord);\n vec2 ml = bSpline3MiddleLeft(fracCoord);\n vec2 l = 1.0 - mr - ml - r;\n\n weights[0] = r + mr;\n weights[1] = ml + l;\n offsets[0] = -1.0 + mr / weights[0];\n offsets[1] = 1.0 + l / weights[1];\n}\n\n// texSize: (1/width, 1/height, width, height)\nvec4 sampleTexture2DBicubic(sampler2D tex, vec2 coord, vec4 texSize){\n vec2 xy = coord * texSize.zw + 0.5;\n vec2 ic = floor(xy);\n vec2 fc = fract(xy);\n\n vec2 weights[2], offsets[2];\n bicubicFilter(fc, weights, offsets);\n\n return weights[0].y * (weights[0].x * sampleTexture(tex, (ic + vec2(offsets[0].x, offsets[0].y) - 0.5) * texSize.xy) +\n weights[1].x * sampleTexture(tex, (ic + vec2(offsets[1].x, offsets[0].y) - 0.5) * texSize.xy)) +\n weights[1].y * (weights[0].x * sampleTexture(tex, (ic + vec2(offsets[0].x, offsets[1].y) - 0.5) * texSize.xy) +\n weights[1].x * sampleTexture(tex, (ic + vec2(offsets[1].x, offsets[1].y) - 0.5) * texSize.xy));\n}\n\n#endif",ODT:'#define GLSLIFY 1\n#include <Tonescale>\n\n// Output Device Transform - RGB computer monitor\n\nconst float CINEMA_WHITE = 48.0;\nconst float CINEMA_BLACK = 0.02; // CINEMA_WHITE / 2400.0;\nconst float ODT_SAT_FACTOR = 0.93;\n\nmediump vec3 Y_2_linCV(mediump vec3 Y, mediump float Ymax, mediump float Ymin){\n return (Y - Ymin) / (Ymax - Ymin);\n}\n\nmediump vec3 XYZ_2_xyY(mediump vec3 XYZ){\n mediump float divisor = max(dot(XYZ, vec3(1.0)), 1e-4);\n return vec3(XYZ.xy / divisor, XYZ.y);\n}\n\nmediump vec3 xyY_2_XYZ(mediump vec3 xyY){\n mediump float m = xyY.z / max(xyY.y, 1e-4);\n mediump vec3 XYZ = vec3(xyY.xz, (1.0 - xyY.x - xyY.y));\n XYZ.xz *= m;\n return XYZ;\n}\n\nconst mediump float DIM_SURROUND_GAMMA = 0.9811;\n\nmediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){\n // Extra conversions to float3/vec3 are required to avoid floating-point precision issues on some platforms.\n\n mediump vec3 XYZ = AP1_2_XYZ_MAT * linearCV;\n mediump vec3 xyY = XYZ_2_xyY(XYZ);\n xyY.z = clamp(xyY.z, 0.0, HALF_MAX);\n xyY.z = pow(xyY.z, DIM_SURROUND_GAMMA);\n XYZ = xyY_2_XYZ(xyY);\n\n return XYZ_2_AP1_MAT * XYZ;\n}\n\n//\n// Summary :\n// This transform is intended for mapping OCES onto a desktop computer monitor\n// typical of those used in motion picture visual effects production. These\n// monitors may occasionally be referred to as "sRGB" displays, however, the\n// monitor for which this transform is designed does not exactly match the\n// specifications in IEC 61966-2-1:1999.\n//\n// The assumed observer adapted white is D65, and the viewing environment is\n// that of a dim surround.\n//\n// The monitor specified is intended to be more typical of those found in\n// visual effects production.\n//\n// Device Primaries :\n// Primaries are those specified in Rec. ITU-R BT.709\n// CIE 1931 chromaticities: x y Y\n// Red: 0.64 0.33\n// Green: 0.3 0.6\n// Blue: 0.15 0.06\n// White: 0.3127 0.329 100 cd/m^2\n//\n// Display EOTF :\n// The reference electro-optical transfer function specified in\n// IEC 61966-2-1:1999.\n//\n// Signal Range:\n// This transform outputs full range code values.\n//\n// Assumed observer adapted white point:\n// CIE 1931 chromaticities: x y\n// 0.3127 0.329\n//\n\n// Viewing Environment:\n// This ODT has a compensation for viewing environment variables more typical\n// of those associated with video mastering.\n//\nmediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){\n // The metal compiler does not optimize structure access\n // const SegmentedSplineParams_c9 ODT_48nits = SegmentedSplineParams_c9(\n // // coefsLow[10]\n // float[10]( -1.6989700043, -1.6989700043, -1.4779000000, -1.2291000000, -0.8648000000, -0.4480000000, 0.0051800000, 0.4511080334, 0.9113744414, 0.9113744414),\n // // coefsHigh[10]\n // float[10]( 0.5154386965, 0.8470437783, 1.1358000000, 1.3802000000, 1.5197000000, 1.5985000000, 1.6467000000, 1.6746091357, 1.6878733390, 1.6878733390 ),\n // vec2(segmented_spline_c5_fwd(0.18*pow(2.,-6.5)), 0.02), // minPoint\n // vec2(segmented_spline_c5_fwd(0.18), 4.8), // midPoint\n // vec2(segmented_spline_c5_fwd(0.18*pow(2.,6.5)), 48.0), // maxPoint\n // 0.0, // slopeLow\n // 0.04 // slopeHigh\n // );\n\n // OCES to RGB rendering space\n mediump vec3 rgbPre = AP0_2_AP1_MAT * oces;\n\n // Apply the tonescale independently in rendering-space RGB\n mediump vec3 rgbPost;\n\n // rgbPost.r = segmented_spline_c9_fwd(rgbPre.r, ODT_48nits);\n // rgbPost.g = segmented_spline_c9_fwd(rgbPre.g, ODT_48nits);\n // rgbPost.b = segmented_spline_c9_fwd(rgbPre.b, ODT_48nits);\n\n rgbPost.r = segmented_spline_c9_fwd(rgbPre.r);\n rgbPost.g = segmented_spline_c9_fwd(rgbPre.g);\n rgbPost.b = segmented_spline_c9_fwd(rgbPre.b);\n\n // Scale luminance to linear code value\n mediump vec3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);\n\n // Apply gamma adjustment to compensate for dim surround\n linearCV = darkSurround_to_dimSurround(linearCV);\n\n // Apply desaturation to compensate for luminance difference\n linearCV = mix(vec3(dot(linearCV, AP1_RGB2Y)), linearCV, ODT_SAT_FACTOR);\n\n // Convert to display primary encoding\n // Rendering space RGB to XYZ\n mediump vec3 XYZ = AP1_2_XYZ_MAT * linearCV;\n\n // Apply CAT from ACES white point to assumed observer adapted white point\n XYZ = D60_2_D65_CAT * XYZ;\n\n // CIE XYZ to display primaries\n linearCV = XYZ_2_REC709_MAT * XYZ;\n\n // Handle out-of-gamut values\n // Clip values < 0 or > 1 (i.e. projecting outside the display primaries)\n linearCV = clamp(linearCV, vec3(0), vec3(1));\n\n // Unity already draws to a sRGB target\n return linearCV;\n}',RRT:'#define GLSLIFY 1\n#include <Tonescale>\n\n// Reference Rendering Transform (RRT)\n\n// Sigmoid function in the range 0 to 1 spanning -2 to +2.\nmediump float sigmoid_shaper(mediump float x){\n mediump float t = max(1.0 - abs(x / 2.0), 0.0);\n mediump float y = 1.0 + sign(x) * (1.0 - t * t);\n\n return y * 0.5;\n}\n\nmediump float glow_fwd(mediump float ycIn, mediump float glowGainIn, mediump float glowMid){\n mediump float glowGainOut;\n\n if (ycIn <= 2.0 / 3.0 * glowMid){\n glowGainOut = glowGainIn;\n } else if (ycIn >= 2.0 * glowMid){\n glowGainOut = 0.0;\n } else{\n glowGainOut = glowGainIn * (glowMid / ycIn - 1.0 / 2.0);\n }\n\n return glowGainOut;\n}\n\n// "Glow" module constants\nconst mediump float RRT_GLOW_GAIN = 0.05;\nconst mediump float RRT_GLOW_MID = 0.08;\n\n// Red modifier constants\nconst mediump float RRT_RED_SCALE = 0.82;\nconst mediump float RRT_RED_PIVOT = 0.03;\nconst mediump float RRT_RED_HUE = 0.0;\nconst mediump float RRT_RED_WIDTH = 135.0;\n\n// Desaturation contants\nconst mediump float RRT_SAT_FACTOR = 0.96;\n\n// ACES to OCES\nmediump vec3 RRT(mediump vec3 aces){\n // --- Glow module --- //\n mediump float saturation = rgb_2_saturation(aces);\n mediump float ycIn = rgb_2_yc(aces);\n mediump float s = sigmoid_shaper((saturation - 0.4) / 0.2);\n mediump float addedGlow = 1.0 + glow_fwd(ycIn, RRT_GLOW_GAIN * s, RRT_GLOW_MID);\n aces *= addedGlow;\n\n // --- Red modifier --- //\n mediump float hue = rgb_2_hue(aces);\n mediump float centeredHue = center_hue(hue, RRT_RED_HUE);\n\n mediump float hueWeight = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * centeredHue / RRT_RED_WIDTH));\n hueWeight *= hueWeight;\n\n aces.r += hueWeight * saturation * (RRT_RED_PIVOT - aces.r) * (1.0 - RRT_RED_SCALE);\n\n // --- ACES to RGB rendering space --- //\n aces = clamp(aces, 0.0, HALF_MAX); // avoids saturated negative colors from becoming positive in the matrix\n mediump vec3 rgbPre = AP0_2_AP1_MAT * aces;\n rgbPre = clamp(rgbPre, 0.0, HALF_MAX);\n\n // --- Global desaturation --- //\n rgbPre = mix(vec3(dot(rgbPre, AP1_RGB2Y)), rgbPre, RRT_SAT_FACTOR);\n\n // --- Apply the tonescale independently in rendering-space RGB --- //\n mediump vec3 rgbPost;\n rgbPost.x = segmented_spline_c5_fwd(rgbPre.x);\n rgbPost.y = segmented_spline_c5_fwd(rgbPre.y);\n rgbPost.z = segmented_spline_c5_fwd(rgbPre.z);\n\n // --- RGB rendering space to OCES --- //\n mediump vec3 outputVal = AP1_2_AP0_MAT * rgbPost;\n\n return outputVal;\n}',Tonescale:"#define GLSLIFY 1\n #ifndef TONE_SCALE\n #define TONE_SCALE\n \n const mediump mat3 M = mat3(\n vec3(0.5, -1.0, 0.5),\n vec3(-1.0, 1.0, 0.5),\n vec3(0.5, 0.0, 0.0)\n );\n\n mediump float segmented_spline_c5_fwd(mediump float x){\n #ifdef GRAPHICS_API_WEBGL2\n const mediump float coefsLow[6] = float[6](-4.0000000000, -4.0000000000, -3.1573765773, -0.4852499958, 1.8477324706, 1.8477324706); // coefs for B-spline between minPoint and midPoint (units of log luminance)\n const mediump float coefsHigh[6] = float[6](-0.7185482425, 2.0810307172, 3.6681241237, 4.0000000000, 4.0000000000, 4.0000000000); // coefs for B-spline between midPoint and maxPoint (units of log luminance)\n #else\n const mediump float coefsLow_0 = -4.0000000000;\n const mediump float coefsLow_1 = -4.0000000000;\n const mediump float coefsLow_2 = -3.1573765773;\n const mediump float coefsLow_3 = -0.4852499958;\n const mediump float coefsLow_4 = 1.8477324706;\n const mediump float coefsLow_5 = 1.8477324706;\n\n const mediump float coefsHigh_0 = -0.7185482425;\n const mediump float coefsHigh_1 = 2.0810307172;\n const mediump float coefsHigh_2 = 3.6681241237;\n const mediump float coefsHigh_3 = 4.0000000000;\n const mediump float coefsHigh_4 = 4.0000000000;\n const mediump float coefsHigh_5 = 4.0000000000;\n #endif\n\n // const vec2 minPoint = vec2(0.18 * exp2(-15.0), 0.0001); // {luminance, luminance} linear extension below this\n const mediump vec2 minPoint = vec2(0.0000054931640625, 0.0001); // {luminance, luminance} linear extension below this\n const mediump vec2 midPoint = vec2(0.18, 0.48); // {luminance, luminance}\n // const vec2 maxPoint = vec2(0.18 * exp2(18.0), 10000.0); // {luminance, luminance} linear extension above this\n const mediump vec2 maxPoint = vec2(47185.92, 10000.0); // {luminance, luminance} linear extension above this\n const mediump float slopeLow = 0.0; // log-log slope of low linear extension\n const mediump float slopeHigh = 0.0; // log-log slope of high linear extension\n\n const int N_KNOTS_LOW = 4;\n const int N_KNOTS_HIGH = 4;\n\n // Check for negatives or zero before taking the log. If negative or zero,\n // set to ACESMIN.1\n mediump float logx = log10(max(x, HALF_MIN));\n mediump float logy;\n\n if (logx <= log10(minPoint.x)){\n logy = logx * slopeLow + (log10(minPoint.y) - slopeLow * log10(minPoint.x));\n } else if ((logx > log10(minPoint.x)) && (logx < log10(midPoint.x))){\n mediump float knot_coord = float(N_KNOTS_LOW - 1) * (logx - log10(minPoint.x)) / (log10(midPoint.x) - log10(minPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsLow[j], coefsLow[j + 1], coefsLow[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsLow_0, coefsLow_1, coefsLow_2);\n } else if (j == 1) {\n cf = vec3(coefsLow_1, coefsLow_2, coefsLow_3);\n } else if (j == 2) {\n cf = vec3(coefsLow_2, coefsLow_3, coefsLow_4);\n } else { // if (j == 3)\n cf = vec3(coefsLow_3, coefsLow_4, coefsLow_5);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else if ((logx >= log10(midPoint.x)) && (logx < log10(maxPoint.x))){\n mediump float knot_coord = float(N_KNOTS_HIGH - 1) * (logx - log10(midPoint.x)) / (log10(maxPoint.x) - log10(midPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsHigh[j], coefsHigh[j + 1], coefsHigh[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsHigh_0, coefsHigh_1, coefsHigh_2);\n } else if (j == 1) {\n cf = vec3(coefsHigh_1, coefsHigh_2, coefsHigh_3);\n } else if (j == 2) {\n cf = vec3(coefsHigh_2, coefsHigh_3, coefsHigh_4);\n } else { // if (j == 3)\n cf = vec3(coefsHigh_3, coefsHigh_4, coefsHigh_5);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else {\n logy = logx * slopeHigh + (log10(maxPoint.y) - slopeHigh * log10(maxPoint.x));\n }\n\n return pow(10.0, logy);\n }\n\n // The metal compiler does not optimize structure access\n // struct SegmentedSplineParams_c9{\n // float coefsLow[10]; // coefs for B-spline between minPoint and midPoint (units of log luminance)\n // float coefsHigh[10]; // coefs for B-spline between midPoint and maxPoint (units of log luminance)\n // mediump vec2 minPoint; // {luminance, luminance} linear extension below this\n // mediump vec2 midPoint; // {luminance, luminance}\n // mediump vec2 maxPoint; // {luminance, luminance} linear extension above this\n // float slopeLow; // log-log slope of low linear extension\n // float slopeHigh; // log-log slope of high linear extension\n // };\n\n mediump float segmented_spline_c9_fwd(mediump float x){\n // ODT_48nits\n #ifdef GRAPHICS_API_WEBGL2\n const 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);\n 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\n const mediump float coefsLow_0 = -1.6989700043;\n const mediump float coefsLow_1 = -1.6989700043;\n const mediump float coefsLow_2 = -1.4779000000;\n const mediump float coefsLow_3 = -1.2291000000;\n const mediump float coefsLow_4 = -0.8648000000;\n const mediump float coefsLow_5 = -0.4480000000;\n const mediump float coefsLow_6 = 0.0051800000;\n const mediump float coefsLow_7 = 0.4511080334;\n const mediump float coefsLow_8 = 0.9113744414;\n const mediump float coefsLow_9 = 0.9113744414;\n\n const mediump float coefsHigh_0 = 0.5154386965;\n const mediump float coefsHigh_1 = 0.8470437783;\n const mediump float coefsHigh_2 = 1.1358000000;\n const mediump float coefsHigh_3 = 1.3802000000;\n const mediump float coefsHigh_4 = 1.5197000000;\n const mediump float coefsHigh_5 = 1.5985000000;\n const mediump float coefsHigh_6 = 1.6467000000;\n const mediump float coefsHigh_7 = 1.6746091357;\n const mediump float coefsHigh_8 = 1.6878733390;\n const mediump float coefsHigh_9 = 1.6878733390;\n #endif\n\n // mediump vec2 minPoint = vec2(segmented_spline_c5_fwd(0.18 * pow(2.0, -6.5)), 0.02);\n // mediump vec2 midPoint = vec2(segmented_spline_c5_fwd(0.18), 4.8);\n // mediump vec2 maxPoint = vec2(segmented_spline_c5_fwd(0.18 * pow(2., 6.5)), 48.0);\n\n const mediump vec2 minPoint = vec2(0.0028799, 0.02);\n const mediump vec2 midPoint = vec2(4.799999, 4.8);\n const mediump vec2 maxPoint = vec2(1005.719, 48.0);\n\n const mediump float slopeLow = 0.0;\n const mediump float slopeHigh = 0.04;\n\n const int N_KNOTS_LOW = 8;\n const int N_KNOTS_HIGH = 8;\n\n // Check for negatives or zero before taking the log. If negative or zero,\n // set to OCESMIN.\n mediump float logx = log10(max(x, 1e-4));\n mediump float logy;\n\n if (logx <= log10(minPoint.x)) {\n logy = logx * slopeLow + (log10(minPoint.y) - slopeLow * log10(minPoint.x));\n } else if ((logx > log10(minPoint.x)) && (logx < log10(midPoint.x))) {\n mediump float knot_coord = float(N_KNOTS_LOW - 1) * (logx - log10(minPoint.x)) / (log10(midPoint.x) - log10(minPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsLow[j], coefsLow[j + 1], coefsLow[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsLow_0, coefsLow_1, coefsLow_2);\n } else if (j == 1) {\n cf = vec3(coefsLow_1, coefsLow_2, coefsLow_3);\n } else if (j == 2) {\n cf = vec3(coefsLow_2, coefsLow_3, coefsLow_4);\n } else if (j == 3) {\n cf = vec3(coefsLow_3, coefsLow_4, coefsLow_5);\n } else if (j == 4) {\n cf = vec3(coefsLow_4, coefsLow_5, coefsLow_6);\n } else if (j == 5) {\n cf = vec3(coefsLow_5, coefsLow_6, coefsLow_7);\n } else if (j == 6) {\n cf = vec3(coefsLow_6, coefsLow_7, coefsLow_8);\n } else { // if (j == 7)\n cf = vec3(coefsLow_7, coefsLow_8, coefsLow_9);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else if ((logx >= log10(midPoint.x)) && (logx < log10(maxPoint.x))) {\n mediump float knot_coord = float(N_KNOTS_HIGH - 1) * (logx - log10(midPoint.x)) / (log10(maxPoint.x) - log10(midPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsHigh[j], coefsHigh[j + 1], coefsHigh[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsHigh_0, coefsHigh_1, coefsHigh_2);\n } else if (j == 1) {\n cf = vec3(coefsHigh_1, coefsHigh_2, coefsHigh_3);\n } else if (j == 2) {\n cf = vec3(coefsHigh_2, coefsHigh_3, coefsHigh_4);\n } else if (j == 3) {\n cf = vec3(coefsHigh_3, coefsHigh_4, coefsHigh_5);\n } else if (j == 4) {\n cf = vec3(coefsHigh_4, coefsHigh_5, coefsHigh_6);\n } else if (j == 5) {\n cf = vec3(coefsHigh_5, coefsHigh_6, coefsHigh_7);\n } else if (j == 6) {\n cf = vec3(coefsHigh_6, coefsHigh_7, coefsHigh_8);\n } else { // if (j == 7)\n cf = vec3(coefsHigh_7, coefsHigh_8, coefsHigh_9);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else {\n logy = logx * slopeHigh + (log10(maxPoint.y) - slopeHigh * log10(maxPoint.x));\n }\n\n return pow(10.0, logy);\n }\n\n#endif",ColorTransform:"#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\n\n// Precomputed matrices (pre-transposed)\n// See https://github.com/ampas/aces-dev/blob/master/transforms/ctl/README-MATRIX.md\n \n const mediump mat3 sRGB_2_AP0 = mat3(\n 0.4397010, 0.0897923, 0.0175440,\n 0.3829780, 0.8134230, 0.1115440,\n 0.1773350, 0.0967616, 0.8707040\n );\n\n const mediump mat3 AP1_2_AP0_MAT = mat3(\n vec3(0.6954522414, 0.0447945634, -0.0055258826),\n vec3(0.1406786965, 0.8596711185, 0.0040252103),\n vec3(0.1638690622, 0.0955343182, 1.0015006723)\n );\n\n const mediump mat3 AP0_2_AP1_MAT = mat3(\n vec3(1.4514393161, -0.0765537734, 0.0083161484),\n vec3(-0.2365107469, 1.1762296998, -0.0060324498),\n vec3(-0.2149285693, -0.0996759264, 0.9977163014)\n );\n\n const mediump mat3 AP1_2_XYZ_MAT = mat3(\n vec3(0.6624541811, 0.2722287168, -0.0055746495),\n vec3(0.1340042065, 0.6740817658, 0.0040607335),\n vec3(0.1561876870, 0.0536895174, 1.0103391003)\n );\n\n const mediump mat3 XYZ_2_AP1_MAT = mat3(\n vec3(1.6410233797, -0.6636628587, 0.0117218943),\n vec3(-0.3248032942, 1.6153315917, -0.0082844420),\n vec3(-0.2364246952, 0.0167563477, 0.9883948585)\n );\n\n const mediump mat3 D60_2_D65_CAT = mat3(\n vec3(0.987224, -0.00759836, 0.00307257),\n vec3(-0.00611327, 1.00186, -0.00509595),\n vec3(0.0159533, 0.00533002, 1.08168)\n );\n\n const mediump mat3 XYZ_2_REC709_MAT = mat3(\n vec3(3.2409699419, -0.9692436363, 0.0556300797),\n vec3(-1.5373831776, 1.8759675015, -0.2039769589),\n vec3(-0.498610760, 0.0415550574, 1.0569715142)\n );\n\n const mediump vec3 AP1_RGB2Y = vec3(0.2722287168, 0.6740817658, 0.0536895174);\n\n mediump float rgb_2_saturation(mediump vec3 rgb){\n const mediump float TINY = 1e-4;\n mediump float mi = min3(rgb);\n mediump float ma = max3(rgb);\n return (max(ma, TINY) - max(mi, TINY)) / max(ma, 1e-2);\n }\n\n mediump float rgb_2_yc(mediump vec3 rgb){\n const mediump float ycRadiusWeight = 1.75;\n\n // Converts RGB to a luminance proxy, here called YC\n // YC is ~ Y + K * Chroma\n // Constant YC is a cone-shaped surface in RGB space, with the tip on the\n // neutral axis, towards white.\n // YC is normalized: RGB 1 1 1 maps to YC = 1\n //\n // ycRadiusWeight defaults to 1.75, although can be overridden in function\n // call to rgb_2_yc\n // ycRadiusWeight = 1 -> YC for pure cyan, magenta, yellow == YC for neutral\n // of same value\n // ycRadiusWeight = 2 -> YC for pure red, green, blue == YC for neutral of\n // same value.\n\n mediump float r = rgb.x;\n mediump float g = rgb.y;\n mediump float b = rgb.z;\n mediump float k = b * (b - g) + g * (g - r) + r * (r - b);\n k = max(k, 0.0); // Clamp to avoid precision issue causing k < 0, making sqrt(k) undefined\n float chroma = k == 0.0 ? 0.0 : sqrt(k); // Avoid NaN\n\n return (b + g + r + ycRadiusWeight * chroma) / 3.0;\n }\n\n mediump float rgb_2_hue(mediump vec3 rgb){\n // Returns a geometric hue angle in degrees (0-360) based on RGB values.\n // For neutral colors, hue is undefined and the function will return a quiet NaN value.\n mediump float hue;\n if (rgb.x == rgb.y && rgb.y == rgb.z){\n hue = 0.0; // RGB triplets where RGB are equal have an undefined hue\n } else{\n hue = (180.0 / PI) * atan(sqrt(3.0) * (rgb.y - rgb.z), 2.0 * rgb.x - rgb.y - rgb.z);\n }\n\n if (hue < 0.0){\n hue = hue + 360.0;\n } \n\n return hue;\n }\n\n mediump float center_hue(mediump float hue, mediump float centerH){\n mediump float hueCentered = hue - centerH;\n if (hueCentered < -180.0){\n hueCentered = hueCentered + 360.0;\n } else if (hueCentered > 180.0){\n hueCentered = hueCentered - 360.0;\n } \n\n return hueCentered;\n }\n\n#endif",NeutralTonemapping:"#define GLSLIFY 1\n// Neutral tonemapping (Hable/Hejl/Frostbite)\n// Input is linear RGB\n// More accuracy to avoid NaN on extremely high values.\nvec3 neutralCurve(vec3 x, float a, float b, float c, float d, float e, float f){\n return vec3(((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f);\n}\n\n#define TONEMAPPING_CLAMP_MAX 435.18712 //(-b + sqrt(b * b - 4 * a * (HALF_MAX - d * f))) / (2 * a * whiteScale)\n//Extremely high values cause NaN output when using fp16, we clamp to avoid the performace hit of switching to fp32\n//The overflow happens in (x * (a * x + b) + d * f) of the NeutralCurve, highest value that avoids fp16 precision errors is ~571.56873\n//Since whiteScale is constant (~1.31338) max input is ~435.18712\n\nvec3 neutralTonemap(vec3 color){\n const float a = 0.2;\n const float b = 0.29;\n const float c = 0.24;\n const float d = 0.272;\n const float e = 0.02;\n const float f = 0.3;\n // const float whiteLevel = 5.3;\n // const float whiteClip = 1.0;\n\n #ifndef GL_FRAGMENT_PRECISION_HIGH\n color = min(color, TONEMAPPING_CLAMP_MAX);\n #endif\n\n // 1.0 / neutralCurve(whiteLevel, a, b, c, d, e, f);\n const float whiteScale = 1.31338; \n color = neutralCurve(color * whiteScale, a, b, c, d, e, f);\n color *= whiteScale;\n\n // Post-curve white point adjustment\n // color /= whiteClip;\n\n return color;\n}",ACESTonemapping:"#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\n\nvec3 ACESTonemap(vec3 color){\n vec3 aces = sRGB_2_AP0 * color;\n \n // --- Glow module --- //\n mediump float saturation = rgb_2_saturation(aces);\n mediump float ycIn = rgb_2_yc(aces);\n mediump float s = sigmoid_shaper((saturation - 0.4) / 0.2);\n float addedGlow = 1.0 + glow_fwd(ycIn, RRT_GLOW_GAIN * s, RRT_GLOW_MID);\n aces *= addedGlow;\n\n // --- Red modifier --- //\n mediump float hue = rgb_2_hue(vec3(aces));\n mediump float centeredHue = center_hue(hue, RRT_RED_HUE);\n float hueWeight = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * centeredHue / RRT_RED_WIDTH));\n hueWeight *= hueWeight;\n\n aces.r += hueWeight * saturation * (RRT_RED_PIVOT - aces.r) * (1.0 - RRT_RED_SCALE);\n\n // --- ACES to RGB rendering space --- //\n vec3 acescg = max(AP0_2_AP1_MAT * aces, 0.0);\n\n // --- Global desaturation --- //\n acescg = mix(vec3(dot(acescg, AP1_RGB2Y)), acescg, RRT_SAT_FACTOR);\n\n // Apply RRT and ODT\n // https://github.com/TheRealMJP/BakingLab/blob/master/BakingLab/ACES.hlsl\n const float a = 0.0245786;\n const float b = 0.000090537;\n const float c = 0.983729;\n const float d = 0.4329510;\n const float e = 0.238081;\n\n // To reduce the likelyhood of extremely large values, we avoid using the x^2 term and therefore\n // divide numerator and denominator by it. This will lead to the constant factors of the\n // quadratic in the numerator and denominator to be divided by x; we add a tiny epsilon to avoid divide by 0.\n vec3 rcpAcesCG = 1.0 / (acescg + FLT_MIN);\n mediump vec3 rgbPost = (acescg + a - b * rcpAcesCG) /\n (acescg * c + d + e * rcpAcesCG);\n\n // Apply gamma adjustment to compensate for dim surround\n vec3 linearCV = darkSurround_to_dimSurround(rgbPost);\n\n // Apply desaturation to compensate for luminance difference\n linearCV = mix(vec3(dot(linearCV, AP1_RGB2Y)), linearCV, ODT_SAT_FACTOR);\n\n // Convert to display primary encoding\n // Rendering space RGB to XYZ\n vec3 XYZ = AP1_2_XYZ_MAT * linearCV;\n\n // Apply CAT from ACES white point to assumed observer adapted white point\n XYZ = D60_2_D65_CAT * XYZ;\n\n // CIE XYZ to display primaries\n linearCV = XYZ_2_REC709_MAT * XYZ;\n\n return linearCV;\n\n}"}),rl.create(a5.UBER_SHADER_NAME,aJ,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n#ifdef ENABLE_EFFECT_BLOOM\n uniform sampler2D material_BloomTexture;\n uniform sampler2D material_BloomDirtTexture;\n uniform vec4 material_BloomTint;\n uniform vec4 material_BloomDirtTilingOffset;\n uniform vec4 material_BloomIntensityParams; // x: bloom intensity, y: dirt intensity\n#endif\n\nvoid main(){\n mediump vec4 color = sampleTexture(renderer_BlitTexture, v_uv);\n\n #ifdef ENABLE_EFFECT_BLOOM\n #ifdef BLOOM_HQ\n mediump vec4 bloom = sampleTexture2DBicubic(material_BloomTexture, v_uv, renderer_texelSize);\n #else\n mediump vec4 bloom = sampleTexture(material_BloomTexture, v_uv);\n #endif\n\n bloom *= material_BloomIntensityParams.x;\n color += bloom * material_BloomTint;\n\n #ifdef BLOOM_DIRT\n mediump vec4 dirt = sampleTexture(material_BloomDirtTexture, v_uv * material_BloomDirtTilingOffset.xy + material_BloomDirtTilingOffset.zw);\n dirt *= material_BloomIntensityParams.y;\n // Additive bloom (artist friendly)\n color += dirt * bloom;\n #endif\n #endif\n\n #ifdef ENABLE_EFFECT_TONEMAPPING\n #if TONEMAPPING_MODE == 0\n color.rgb = neutralTonemap(color.rgb);\n #elif TONEMAPPING_MODE == 1\n color.rgb = ACESTonemap(color.rgb);\n #endif\n\n color.rgb = clamp(color.rgb, vec3(0), vec3(1));\n #endif\n\n gl_FragColor = color;\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}");var a9="#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\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\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\n #include <ShadowVertex>\n #include <FogVertex>\n}\n",a6=/*#__PURE__*/function(){function e(){}return e.init=function(){var e=new re("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;\nuniform vec2 scene_ShadowBias; // x: depth bias, y: normal bias\nuniform vec3 scene_LightDirection;\n\nvec3 applyShadowBias(vec3 positionWS) {\n positionWS -= scene_LightDirection * scene_ShadowBias.x;\n return positionWS;\n}\n\nvec3 applyShadowNormalBias(vec3 positionWS, vec3 normalWS) {\n float invNdotL = 1.0 - clamp(dot(-scene_LightDirection, normalWS), 0.0, 1.0);\n float scale = invNdotL * scene_ShadowBias.y;\n positionWS += normalWS * vec3(scale);\n return positionWS;\n}\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <begin_normal_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n \n vec4 positionWS = renderer_ModelMat * position;\n\n positionWS.xyz = applyShadowBias(positionWS.xyz);\n #ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n vec3 normalWS = normalize( mat3(renderer_NormalMat) * normal );\n positionWS.xyz = applyShadowNormalBias(positionWS.xyz, normalWS);\n #endif\n #endif\n\n vec4 positionCS = camera_VPMat * positionWS;\n positionCS.z = max(positionCS.z, -1.0);// clamp to min ndc z\n\n gl_Position = positionCS;\n\n}\n","#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\n /**\n * Decompose and save depth value.\n */\n vec4 pack (float depth) {\n // Use rgba 4 bytes with a total of 32 bits to store the z value, and the accuracy of 1 byte is 1/256.\n const vec4 bitShift = vec4(1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0);\n const vec4 bitMask = vec4(1.0/256.0, 1.0/256.0, 1.0/256.0, 0.0);\n\n vec4 rgbaDepth = fract(depth * bitShift); // Calculate the z value of each point\n\n // Cut off the value which do not fit in 8 bits\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n\n return rgbaDepth;\n }\n#endif\n\nuniform vec4 material_BaseColor;\nuniform sampler2D material_BaseTexture;\nuniform float material_AlphaCutoff;\nvarying vec2 v_uv;\n\nvoid main() {\n #if defined(MATERIAL_IS_ALPHA_CUTOFF) || (defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT))\n float alpha = material_BaseColor.a;\n #ifdef MATERIAL_HAS_BASETEXTURE\n alpha *= texture2D(material_BaseTexture, v_uv).a;\n #endif\n \n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if(alpha < material_AlphaCutoff){\n discard;\n }\n #endif\n \n #if defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT)\n // Interleaved gradient noise\n float noise = fract(52.982919 * fract(dot(vec2(0.06711, 0.00584), gl_FragCoord.xy)));\n if (alpha <= noise) {\n discard;\n };\n #endif\n #endif\n\n #ifdef ENGINE_NO_DEPTH_TEXTURE\n gl_FragColor = pack(gl_FragCoord.z);\n #else\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n #endif\n}",{pipelineStage:nq.ShadowCaster});e._renderState=new rs,e._renderStateDataMap[nV.RenderQueueType]=id._shadowCasterRenderQueueProp;var t=[e,new re("DepthOnly","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <position_vert>\n\n}\n","#define GLSLIFY 1\nvoid main() {\n}",{pipelineStage:nq.DepthOnly})],n={pipelineStage:nq.Forward};rl.create("blinn-phong",[].concat([new re("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\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\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\n #include <ShadowVertex>\n #include <FogVertex>\n}\n","#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n\n#include <FogFragmentDeclaration>\n#include <normal_get>\n\nvoid main() {\n\n #include <begin_mobile_frag>\n #include <begin_viewdir_frag>\n #include <mobile_blinnphong_frag>\n\n gl_FragColor = emission + ambient + diffuse + specular;\n\n #ifdef MATERIAL_IS_TRANSPARENT\n gl_FragColor.a = diffuse.a;\n #else\n gl_FragColor.a = 1.0;\n #endif\n\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n",n)],t)),rl.create("pbr",[].concat([new re("Forward",a9,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n",n)],t)),rl.create("pbr-specular",[].concat([new re("Forward",a9,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n",n)],t)),rl.create("unlit",[].concat([new re("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n #include <position_vert>\n\n #include <FogVertex>\n}\n","#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\n\nuniform vec4 material_BaseColor;\nuniform float material_AlphaCutoff;\n\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\nvoid main() {\n vec4 baseColor = material_BaseColor;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec4 textureColor = texture2D(material_BaseTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n textureColor = gammaToLinear(textureColor);\n #endif\n baseColor *= textureColor;\n #endif\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( baseColor.a < material_AlphaCutoff ) {\n discard;\n }\n #endif\n\n gl_FragColor = baseColor;\n\n #ifndef MATERIAL_IS_TRANSPARENT\n gl_FragColor.a = 1.0;\n #endif\n\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n",n)],t)),rl.create("blit",[new re("Forward",aJ,"#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\n uniform float renderer_BlitMipLevel;\n#endif\n\nuniform vec4 renderer_SourceScaleOffset;\n\nvarying vec2 v_uv;\n\nvoid main() {\n vec2 uv = v_uv;\n uv = uv * renderer_SourceScaleOffset.xy + renderer_SourceScaleOffset.zw;\n\n #ifdef HAS_TEX_LOD\n gl_FragColor = texture2DLodEXT( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n #else\n gl_FragColor = texture2D( renderer_BlitTexture, uv );\n #endif\n}\n\n",n)]),rl.create("skybox",[new re("Forward","#define GLSLIFY 1\n#include <common_vert>\n\nuniform mat4 camera_VPMat;\n\nvarying vec3 v_cubeUV;\nuniform float material_Rotation;\n\nvec4 rotateY(vec4 v, float angle) {\n const float deg2rad = 3.1415926 / 180.0;\n float radian = angle * deg2rad;\n float sina = sin(radian);\n float cosa = cos(radian);\n mat2 m = mat2(cosa, -sina, sina, cosa);\n return vec4(m * v.xz, v.yw).xzyw;\n}\n\nvoid main() {\n v_cubeUV = vec3( -POSITION.x, POSITION.yz ); // TextureCube is left-hand,so x need inverse\n gl_Position = camera_VPMat * rotateY(vec4(POSITION, 1.0), material_Rotation);\n}\n","#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;\n\nvarying vec3 v_cubeUV;\nuniform float material_Exposure;\nuniform vec4 material_TintColor;\n\nvoid main() {\n vec4 textureColor = textureCube( material_CubeTexture, v_cubeUV );\n\n #ifdef MATERIAL_IS_DECODE_SKY_RGBM\n textureColor = RGBMToLinear(textureColor, 5.0);\n #elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\n textureColor = gammaToLinear(textureColor);\n #endif\n\n textureColor.rgb *= material_Exposure * material_TintColor.rgb;\n \n gl_FragColor = textureColor;\n\n #if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n",n)]),rl.create("SkyProcedural",[new re("Forward","#define GLSLIFY 1\n// This code uses the Unity skybox-Procedural shader algorithm, developed by Unity and licensed under the Unity Companion License. \n// The original implementation can be found at unity build-in shader(DefaultResourcesExtra/Skybox-Procedural.shader)\n\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5))) // Rayleigh constant\n#define MIE 0.0010 // Mie constant\n#define SUN_BRIGHTNESS 20.0 // Sun brightness\n#define MAX_SCATTER 50.0 // Maximum scattering value, to prevent math overflows on Adrenos\n\nconst float SKY_GROUND_THRESHOLD = 0.02;\nconst float outerRadius = OUTER_RADIUS;\nconst float outerRadius2 = OUTER_RADIUS*OUTER_RADIUS;\nconst float innerRadius = 1.0;\nconst float innerRadius2 = 1.0;\nconst float cameraHeight = 0.0001;\n\nconst float HDSundiskIntensityFactor = 15.0;\nconst float simpleSundiskIntensityFactor = 27.0;\n\nconst float sunScale = 400.0 * SUN_BRIGHTNESS;\nconst float kmESun = MIE * SUN_BRIGHTNESS;\nconst float km4PI = MIE * 4.0 * 3.14159265;\nconst float scale = 1.0 / (OUTER_RADIUS - 1.0);\nconst float scaleDepth = 0.25;\nconst float scaleOverScaleDepth = (1.0 / (OUTER_RADIUS - 1.0)) / 0.25;\nconst float samples = 2.0; // THIS IS UNROLLED MANUALLY, DON'T TOUCH\n\n// RGB wavelengths .35 (.62=158), .43 (.68=174), .525 (.75=190)\nconst vec3 c_DefaultScatteringWavelength = vec3(0.65, 0.57, 0.475);\nconst vec3 c_VariableRangeForScatteringWavelength = vec3(0.15, 0.15, 0.15);\n\nattribute vec4 POSITION;\n\nuniform mat4 camera_VPMat;\nuniform vec3 material_SkyTint;\nuniform vec3 material_GroundTint;\nuniform float material_Exposure;\nuniform float material_AtmosphereThickness;\nuniform vec4 scene_SunlightColor;\nuniform vec3 scene_SunlightDirection;\n\nvarying vec3 v_GroundColor;\nvarying vec3 v_SkyColor;\n\n#ifdef MATERIAL_SUN_HIGH_QUALITY\n varying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\n varying vec3 v_RayDir;\n#else\n varying float v_SkyGroundFactor;\n#endif\n\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\n varying vec3 v_SunColor;\n#endif\n\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\n\n// Calculates the Rayleigh phase function\nfloat getRayleighPhase(vec3 light, vec3 ray) \n{\n float eyeCos = dot(light, ray);\n return 0.75 + 0.75 * eyeCos * eyeCos;\n}\n\nfloat scaleAngle(float inCos)\n{\n float x = 1.0 - inCos;\n return 0.25 * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));\n}\n\nvoid main () {\n gl_Position = camera_VPMat*vec4(POSITION.xyz,1.0);\n\n vec3 skyTintInGammaSpace = COLOR_2_GAMMA(material_SkyTint);\n vec3 scatteringWavelength = mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0) - skyTintInGammaSpace); // using Tint in sRGB+ gamma allows for more visually linear interpolation and to keep (0.5) at (128, gray in sRGB) point\n vec3 invWavelength = 1.0 / pow(scatteringWavelength, vec3(4.0));\n\n float krESun = RAYLEIGH * SUN_BRIGHTNESS;\n float kr4PI = RAYLEIGH * 4.0 * 3.14159265;\n\n vec3 cameraPos = vec3(0.0,innerRadius + cameraHeight,0.0); // The camera's current position\n\n // Get the ray from the camera to the vertex and its length (which is the far point of the ray passing through the atmosphere)\n vec3 eyeRay = normalize(POSITION.xyz);\n\n float far = 0.0;\n vec3 cIn, cOut;\n if (eyeRay.y >= 0.0) {\n // Sky \n // Calculate the length of the \"atmosphere\"\n far = sqrt(outerRadius2 + innerRadius2 * eyeRay.y * eyeRay.y - innerRadius2) - innerRadius * eyeRay.y;\n\n // Calculate the ray's starting position, then calculate its scattering offset\n float height = innerRadius + cameraHeight;\n float depth = exp(scaleOverScaleDepth * -cameraHeight);\n float startAngle = dot(eyeRay, cameraPos) / height;\n float startOffset = depth*scaleAngle(startAngle);\n\n // Initialize the scattering loop variables\n float sampleLength = far / samples;\n float scaledLength = sampleLength * scale;\n vec3 sampleRay = eyeRay * sampleLength;\n vec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n vec3 frontColor = vec3(0.0);\n //unrolling this manually to avoid some platform for loop slow\n {\n float height = length(samplePoint);\n float depth = exp(scaleOverScaleDepth * (innerRadius - height));\n float lightAngle = dot(-scene_SunlightDirection, samplePoint) / height;\n float cameraAngle = dot(eyeRay, samplePoint) / height;\n float scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n vec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n frontColor += attenuate * (depth * scaledLength);\n samplePoint += sampleRay;\n }\n {\n float height = length(samplePoint);\n float depth = exp(scaleOverScaleDepth * (innerRadius - height));\n float lightAngle = dot(-scene_SunlightDirection, samplePoint) / height;\n float cameraAngle = dot(eyeRay, samplePoint) / height;\n float scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n vec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n frontColor += attenuate * (depth * scaledLength);\n samplePoint += sampleRay;\n }\n\n // Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\n cIn = frontColor * (invWavelength * krESun);\n cOut = frontColor * kmESun;\n } else {\n // Ground\n far = (-cameraHeight) / (min(-0.001, eyeRay.y));\n vec3 pos = cameraPos + far * eyeRay;\n\n // Calculate the ray's starting position, then calculate its scattering offset\n float depth = exp((-cameraHeight) * (1.0/scaleDepth));\n float cameraAngle = dot(-eyeRay, pos);\n float lightAngle = dot(-scene_SunlightDirection, pos);\n float cameraScale = scaleAngle(cameraAngle);\n float lightScale = scaleAngle(lightAngle);\n float cameraOffset = depth*cameraScale;\n float temp = lightScale + cameraScale;\n\n // Initialize the scattering loop variables\n float sampleLength = far / samples;\n float scaledLength = sampleLength * scale;\n vec3 sampleRay = eyeRay * sampleLength;\n vec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n // Now loop through the sample rays\n vec3 frontColor = vec3(0.0, 0.0, 0.0);\n vec3 attenuate;\n\n // Loop removed because we kept hitting SM2.0 temp variable limits. Doesn't affect the image too much\n {\n float height = length(samplePoint);\n float depth = exp(scaleOverScaleDepth * (innerRadius - height));\n float scatter = depth*temp - cameraOffset;\n attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n frontColor += attenuate * (depth * scaledLength);\n samplePoint += sampleRay;\n }\n\n cIn = frontColor * (invWavelength * krESun + kmESun);\n cOut = clamp(attenuate, 0.0, 1.0);\n }\n\n #ifdef MATERIAL_SUN_HIGH_QUALITY\n v_Vertex = -POSITION.xyz;\n #elif defined(MATERIAL_SUN_SIMPLE) \n v_RayDir = -eyeRay;\n #else\n v_SkyGroundFactor = -eyeRay.y / SKY_GROUND_THRESHOLD;\n #endif\n\n // if we want to calculate color in vprog:\n // 1. in case of linear: multiply by _Exposure in here (even in case of lerp it will be common multiplier, so we can skip mul in fshader)\n // 2. in case of gamma: do sqrt right away instead of doing that in fshader\n \n v_GroundColor = material_Exposure * (cIn + COLOR_2_LINEAR(material_GroundTint) * cOut);\n v_SkyColor = material_Exposure * (cIn * getRayleighPhase(-scene_SunlightDirection, -eyeRay));\n\n \n // The sun should have a stable intensity in its course in the sky. Moreover it should match the highlight of a purely specular material.\n // This matching was done using the standard shader BRDF1 on the 5/31/2017\n // Finally we want the sun to be always bright even in LDR thus the normalization of the lightColor for low intensity.\n float lightColorIntensity = clamp(length(scene_SunlightColor.xyz), 0.25, 1.0);\n\n #ifdef MATERIAL_SUN_HIGH_QUALITY \n v_SunColor = HDSundiskIntensityFactor * clamp(cOut,0.0,1.0) * scene_SunlightColor.xyz / lightColorIntensity;\n #elif defined(MATERIAL_SUN_SIMPLE) \n v_SunColor = simpleSundiskIntensityFactor * clamp(cOut * sunScale,0.0,1.0) * scene_SunlightColor.xyz / lightColorIntensity;\n #endif\n}\n","#define GLSLIFY 1\n// This code uses the Unity skybox-Procedural shader algorithm, developed by Unity and licensed under the Unity Companion License. \n// The original implementation can be found at unity build-in shader(DefaultResourcesExtra/Skybox-Procedural.shader)\n\n#include <common>\n\nconst float MIE_G = -0.990;\nconst float MIE_G2 = 0.9801;\nconst float SKY_GROUND_THRESHOLD = 0.02;\n\nuniform float material_SunSize;\nuniform float material_SunSizeConvergence;\nuniform vec4 scene_SunlightColor;\nuniform vec3 scene_SunlightDirection;\n\nvarying vec3 v_GroundColor;\nvarying vec3 v_SkyColor;\n\n#ifdef MATERIAL_SUN_HIGH_QUALITY\n varying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\n varying vec3 v_RayDir;\n#else\n varying float v_SkyGroundFactor;\n#endif\n\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\n varying vec3 v_SunColor;\n#endif\n\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n #define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\n\n// Calculates the Mie phase function\nfloat getMiePhase(float eyeCos, float eyeCos2) {\n float temp = 1.0 + MIE_G2 - 2.0 * MIE_G * eyeCos;\n temp = pow(temp, pow(material_SunSize,0.65) * 10.0);\n temp = max(temp,1.0e-4); // prevent division by zero, esp. in half precision\n temp = 1.5 * ((1.0 - MIE_G2) / (2.0 + MIE_G2)) * (1.0 + eyeCos2) / temp;\n return temp;\n}\n\n// Calculates the sun shape\nfloat calcSunAttenuation(vec3 lightPos, vec3 ray) {\n #ifdef MATERIAL_SUN_HIGH_QUALITY\n float focusedEyeCos = pow(clamp(dot(lightPos, ray),0.0,1.0), material_SunSizeConvergence);\n return getMiePhase(-focusedEyeCos, focusedEyeCos * focusedEyeCos);\n #else //MATERIAL_SUN_SIMPLE\n vec3 delta = lightPos - ray;\n float dist = length(delta);\n float spot = 1.0 - smoothstep(0.0, material_SunSize, dist);\n return spot * spot;\n #endif\n}\n\nvoid main() {\n // if y > 1 [eyeRay.y < -SKY_GROUND_THRESHOLD] - ground\n // if y >= 0 and < 1 [eyeRay.y <= 0 and > -SKY_GROUND_THRESHOLD] - horizon\n // if y < 0 [eyeRay.y > 0] - sky\n vec3 col = vec3(0.0, 0.0, 0.0);\n\n #ifdef MATERIAL_SUN_HIGH_QUALITY\n vec3 ray = normalize(v_Vertex);\n float y = ray.y / SKY_GROUND_THRESHOLD;\n #elif defined(MATERIAL_SUN_SIMPLE) \n vec3 ray = v_RayDir;\n float y = ray.y / SKY_GROUND_THRESHOLD; \n #else\n float y = v_SkyGroundFactor;\n #endif\n\n // if we did precalculate color in vprog: just do lerp between them\n col = mix(v_SkyColor, v_GroundColor, clamp(y,0.0,1.0));\n\n #if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\n if (y < 0.0)\n col += v_SunColor * calcSunAttenuation(-scene_SunlightDirection, -ray);\n #endif\n\n #ifdef ENGINE_IS_COLORSPACE_GAMMA\n col = LINEAR_2_OUTPUT(col); // linear space convert to gamma space\n #endif\n\n gl_FragColor = vec4(col,1.0);\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n\n",n)]),rl.create("particle-shader",[new re("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)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 a_MeshPosition;\n attribute vec4 a_MeshColor;\n attribute vec2 a_MeshTextureCoordinate;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 u_DragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\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>\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n vec3 lifeVelocity;\n if (normalizedAge < 1.0) {\n 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)\n lifeVelocity = computeParticleLifeVelocity(normalizedAge); \n #endif\n \n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n //drag\n vec3 dragData = a_DirectionTime.xyz * mix(u_DragConstant.x, u_DragConstant.y, a_Random0.x);\n vec3 center = computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge, gravityVelocity, worldRotation, dragData); //计算粒子位置\n\n #include <sphere_billboard>\n #include <stretched_billboard>\n #include <horizontal_billboard>\n #include <vertical_billboard>\n #include <particle_mesh>\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(center, 1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec2 simulateUV;\n #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n simulateUV = a_CornerTextureCoordinate.zw * a_SimulationUV.xy + a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #ifdef RENDERER_MODE_MESH\n simulateUV = a_SimulationUV.xy + a_MeshTextureCoordinate * a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #endif\n } else {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Discard use out of X(-1,1),Y(-1,1),Z(0,1)\n }\n}\n","#define GLSLIFY 1\n#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n\n#ifdef RENDERER_MODE_MESH\n varying vec4 v_MeshColor;\n#endif\n\nvoid main() {\n vec4 color = material_BaseColor * v_Color;\n\n #ifdef RENDERER_MODE_MESH\n color *= v_MeshColor;\n #endif\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec4 textureColor = texture2D(material_BaseTexture,v_TextureCoordinate);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n textureColor = gammaToLinear(textureColor);\n #endif\n color *= textureColor;\n #endif\n gl_FragColor = color; \n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}",n)]),rl.create("SpriteMask",[new re("Forward","#define GLSLIFY 1\nuniform mat4 camera_VPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\n\nvarying vec2 v_uv;\n\nvoid main()\n{\n gl_Position = camera_VPMat * vec4(POSITION, 1.0);\n v_uv = TEXCOORD_0;\n}\n","#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;\nuniform float renderer_MaskAlphaCutoff;\nvarying vec2 v_uv;\n\nvoid main()\n{\n vec4 color = texture2D(renderer_MaskTexture, v_uv);\n if (color.a < renderer_MaskAlphaCutoff) {\n discard;\n }\n\n gl_FragColor = color;\n}\n",n)]),rl.create("Sprite",[new re("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\nattribute vec4 COLOR_0;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n\n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n}\n","#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 baseColor = texture2D(renderer_SpriteTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n}\n",n)]),rl.create("Text",[new re("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\nattribute vec4 COLOR_0;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n\n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n}\n","#define GLSLIFY 1\nuniform sampler2D renderElement_TextTexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 baseColor = texture2D(renderElement_TextTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n}\n",n)]),rl.create("background-texture",[new re("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\nvarying vec2 v_uv;\nuniform vec4 camera_ProjectionParams;\n\nvoid main() {\n gl_Position = vec4(POSITION, 1.0);\n gl_Position.y *= camera_ProjectionParams.x;\n \n v_uv = TEXCOORD_0;\n}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;\n\nvarying vec2 v_uv;\n\nvoid main() {\n gl_FragColor = texture2D(material_BaseTexture, v_uv);\n}",n)])},e}(),a7=/*#__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 i=e._mask,a=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=a<s?0:i[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var u=a<o?0:i[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 i in e){for(var a=e[i],o=e,s=0;s<r;s++)o[0==s?i:0]=o=Object.create(null);o[0]=a}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,n,r)},e}(),oe=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._usedElementCount=0,n._elements=[],n}tX(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}(i1),ot=/*#__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 rF.None},e}();a6.init();var on=/*#__PURE__*/function(e){function t(n,r,i){(a=e.call(this)||this)._physicsInitialized=!1,a._lastRenderState=new rs,a._renderElementPool=new oe(r3),a._subRenderElementPool=new oe(r4),a._textSubRenderElementPool=new oe(r4),a._charRenderInfoPool=new i2(tK,50),a._renderContext=new rU,a._renderCount=0,a._shaderProgramPools=[],a._fontMap={},a._macroCollection=new nX,a._postProcessPassNeedRefresh=!1,a._settings={},a._resourceManager=new ao(a),a._sceneManager=new ae(a),a._vSyncCount=1,a._targetFrameRate=60,a._time=new nJ,a._isPaused=!0,a._vSyncCounter=1,a._targetFrameInterval=1e3/60,a._destroyed=!1,a._frameInProcess=!1,a._waitingDestroy=!1,a._isDeviceLost=!1,a._waitingGC=!1,a._postProcessPasses=[],a._activePostProcessPasses=[],a._animate=function(){if(a._vSyncCount){var e,t=(null==(e=a.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;a._requestId=t(a._animate),a._vSyncCounter++%a._vSyncCount==0&&(a.update(),a._vSyncCounter=1)}else a._timeoutId=window.setTimeout(a._animate,a._targetFrameInterval),a.update()},a._hardwareRenderer=r,a._hardwareRenderer.init(n,a._onDeviceLost.bind(a),a._onDeviceRestored.bind(a)),a._canvas=n,a._textDefaultFont=ny.createFromOS(a,"Arial"),a._textDefaultFont.isGCIgnored=!0,a._batcherManager=new i9(a),a.inputManager=new aK(a,i.input);var a,o=i.xrDevice;if(o&&(a.xrManager=new ot,a.xrManager._initialize(a,o)),r.canIUse(n$.depthTexture)){var s=new nd(a,1,1,t7.Depth16,!1);s.isGCIgnored=!0,a._depthTexture2D=s}else a._macroCollection.enable(t._noDepthTextureMacro);var l=new iu(a,rl.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new tV(1,0,1.01,1)),a._meshMagentaMaterial=l;var c=new iu(a,rl.find("particle-shader"));c.isGCIgnored=!0,c.shaderData.setColor("material_BaseColor",new tV(1,0,1.01,1)),a._particleMagentaMaterial=c;var u=a._settings,d=i.colorSpace||n4.Linear;d===n4.Gamma&&a._macroCollection.enable(t._gammaMacro),u.colorSpace=d,a._basicResources=new i0(a),a._particleBufferUtils=new aQ(a);var h=new a5(a);return a.addPostProcessPass(h),a}tX(t,e);var n=t.prototype;return n.createEntity=function(e){return new iQ(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,i=this._physicsInitialized;r._update(),this._refreshActivePostProcessPasses();for(var a=this._sceneManager._scenes.getLoopArray(),o=a.length,s=0;s<o;s++){var l=a[s];if(l.isActive&&!l.destroyed){var c=l._componentsManager;c.sortCameras(),c.callScriptOnStart()}}if(i)for(var u=0;u<o;u++){var d=a[u];d.isActive&&!d.destroyed&&d.physics._update(n)}i&&r._firePointerScript(a);for(var h=0;h<o;h++){var _=a[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(n)}for(var f=0;f<o;f++){var p=a[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(n)}for(var m=0;m<o;m++){var g=a[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(n)}if(this._isDeviceLost||this._render(a),this._waitingDestroy)this._destroy();else for(var v=0;v<o;v++){var y=a[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.addPostProcessPass=function(e){if(e.engine!==this)throw"The pass is not belong to this engine.";var t=this._postProcessPasses;-1===t.indexOf(e)&&(t.push(e),e.isActive&&(this._postProcessPassNeedRefresh=!0))},n._removePostProcessPass=function(e){var t=this._postProcessPasses,n=t.indexOf(e);-1!==n&&(t.splice(n,1),e.isActive&&(this._postProcessPassNeedRefresh=!0))},n._refreshActivePostProcessPasses=function(){if(this._postProcessPassNeedRefresh){this._postProcessPassNeedRefresh=!1;var e=this._postProcessPasses,t=this._activePostProcessPasses;t.length=0;for(var n=0,r=e.length;n<r;n++){var i=e[n];i.isActive&&t.push(i)}t.length&&t.sort(function(e,t){return e.event-t.event})}},n._getActivePostProcessPasses=function(){return this._refreshActivePostProcessPasses(),this._activePostProcessPasses},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 i=t+1;i>n.length&&(n.length=i),n[t]=r=new a7(this),e._shaderProgramPools.push(r)}return r},n._render=function(e){for(var t=this,n=this.time.deltaTime,r=0,i=e.length;r<i;r++){var a=e[r];a.isActive&&!a.destroyed&&(a._componentsManager.callRendererOnUpdate(n),a._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(n,r){var i=e[n];if(i.isActive&&!i.destroyed){var a=i._componentsManager._activeCameras;if(0===a.length)return nl.debug("No active camera in scene.");a.forEach(function(e){var n=i._componentsManager;n.callCameraOnBeginRender(e),i.postProcessManager._update(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&&!rl._shaderLab&&(rl._shaderLab=n);var i=[];r&&i.push(r.initialize().then(function(){return ab._nativePhysics=r,t._nativePhysicsManager=r.createPhysicsManager(),t._physicsInitialized=!0,t}));var a=ao._loaders;for(var o in a){var s=a[o];s.initialize&&i.push(s.initialize(this,e))}return Promise.all(i).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 rs,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()},tW(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:"postProcessPasses",get:function(){return this._postProcessPasses}},{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}(nY);on._gammaMacro=nj.getByName("ENGINE_IS_COLORSPACE_GAMMA"),on._noDepthTextureMacro=nj.getByName("ENGINE_NO_DEPTH_TEXTURE"),on._pixelsPerUnit=100,on._physicalObjectsMap={};var or=/*#__PURE__*/function(){function e(){this._sizeUpdateFlagManager=new nP}return tW(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}(),oi=/*#__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){nl.warn("The material of sky is not defined.");return}if(n.destroyed){nl.warn("The material of sky is destroyed.");return}if(!r){nl.warn("The mesh of sky is not defined.");return}if(r.destroyed){nl.warn("The mesh of sky is destroyed.");return}var i=t.camera,a=i.engine,o=i.scene,s=i.aspectRatio,l=i.fieldOfView,c=i.viewMatrix,u=i.shaderData,d=o.shaderData,h=e._viewProjMatrix,_=e._projectionMatrix,f=a._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(tA.degreeToRadian(l)/2);_.elements[0]=y/s,_.elements[5]=y,tB.multiply(_,h,h);var x=u.getMatrix(rU.vpMatrixProperty);t.flipProjection&&tB.multiply(rU._flipYMatrix,h,h),u.setMatrix(rU.vpMatrixProperty,h);var b=rl._compileMacros;nX.unionCollection(t.camera._globalShaderMacro,p._macroCollection,b);var C=m.subShaders[0].passes[0],S=C._getShaderProgram(a,b);S.bind(),S.groupingOtherUniformBlock(),S.uploadAll(S.sceneUniformBlock,d),S.uploadAll(S.cameraUniformBlock,u),S.uploadAll(S.materialUniformBlock,p),S.uploadUnGroupTextures(),g._applyStates(a,!1,C._renderStateDataMap,p),f.drawPrimitive(r._primitive,r.subMesh,S),u.setMatrix(rU.vpMatrixProperty,x)},tW(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}();oi._epsilon=1e-6,oi._viewProjMatrix=new tB,oi._projectionMatrix=new tB(1,0,0,0,0,1,0,0,0,0,oi._epsilon-1,-1,0,0,0,0);var oa=/*#__PURE__*/function(){function e(e){this._engine=e,this.mode=rV.SolidColor,this.solidColor=new tV(.25,.25,.25,1),this.sky=new oi,this._textureFillMode=rk.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,i=n.height,a=t.getPositions();switch(this._textureFillMode){case rk.Fill:a[0].set(-1,-1,1),a[1].set(1,-1,1),a[2].set(-1,1,1),a[3].set(1,1,1);break;case rk.AspectFitWidth:var o=e.height*r/e.width/i;a[0].set(-1,-o,1),a[1].set(1,-o,1),a[2].set(-1,o,1),a[3].set(1,o,1);break;case rk.AspectFitHeight:var s=e.width*i/e.height/r;a[0].set(-s,-1,1),a[1].set(s,-1,1),a[2].set(-s,1,1),a[3].set(s,1,1)}t.setPositions(a),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 tX(n,e),n.prototype.restoreContent=function(){t.setPositions(t.getPositions()),t.setUVs(t.getUVs()),t.setIndices(t.getIndices()),t.uploadData(!1)},n}(t4))),this._mesh._addReferCount(1)},t._initMaterial=function(e){var t=this._material=new iu(e,rl.find("background-texture"));t.renderState.depthState.compareFunction=nO.LessEqual,t._addReferCount(1)},t._createPlane=function(e){for(var t=new iB(e),n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],i=[,,,,],a=0;a<4;++a)r[a]=new tR,i[a]=new tO(a%2,1-(.5*a|0));return t.setPositions(r),t.setUVs(i),t.setIndices(n),t.uploadData(!1),t.addSubMesh(0,n.length),t},tW(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}(),oo=/*#__PURE__*/function(){function e(){this._cameraNeedSorting=!1,this._activeCameras=new rT,this._renderers=new rT,this._onStartScripts=new rT,this._onUpdateScripts=new rT,this._onLateUpdateScripts=new rT,this._onPhysicsUpdateScripts=new rT,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new rT,this._onUpdateRenderers=new rT,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}(),os=/*#__PURE__*/function(){function e(){this.hasStencilWritten=!1,this._preMaskLayer=ry.Nothing,this._allSpriteMasks=new rT}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 i=e.getMaskIncrementRenderQueue();i.clear();var a=e.getMaskDecrementRenderQueue();a.clear(),this._buildMaskRenderElement(r,i,a);var o=t.camera.engine._batcherManager;i.batch(o),o.uploadBuffer(),i.render(t,n,rH.Increment),a.batch(o),o.uploadBuffer(),a.render(t,n,rH.Decrement)},t.clearMask=function(t,n){var r=this._preMaskLayer;if(r!==ry.Nothing){if(this.hasStencilWritten){var i=e.getMaskDecrementRenderQueue();i.clear();for(var a=this._allSpriteMasks,o=0,s=a.length;o<s;o++){var l=a.get(o);l.influenceLayers&r&&i.pushRenderElement(l._renderElement)}var c=t.camera.engine._batcherManager;i.batch(c),c.uploadBuffer(),i.render(t,n,rH.Decrement)}else{var u=t.camera.engine;u._hardwareRenderer.clearRenderTarget(u,rF.Stencil,null)}this._preMaskLayer=ry.Nothing}},t.isStencilWritten=function(e){var t=e.renderState.stencilState,n=nU.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,i=t.compareFunctionFront,a=t.compareFunctionBack;return!!n&&0!==r&&(i!==nO.Always&&i!==nO.Never||a!==nO.Always&&a!==nO.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 i=this._allSpriteMasks,a=r&e,o=r&~e,s=i._elements,l=0,c=i.length;l<c;l++){var u=s[l],d=u.influenceLayers;!(d&a)&&(d&e?t.pushRenderElement(u._renderElement):d&o&&n.pushRenderElement(u._renderElement))}this._preMaskLayer=e}},e.getMaskIncrementRenderQueue=function(){return e._maskIncrementRenderQueue||(e._maskIncrementRenderQueue=new rW(nk.Transparent))},e.getMaskDecrementRenderQueue=function(){return e._maskDecrementRenderQueue||(e._maskDecrementRenderQueue=new rW(nk.Transparent))},e}(),ol=((eI={})[eI.None=0]="None",eI[eI.Linear=1]="Linear",eI[eI.Exponential=2]="Exponential",eI[eI.ExponentialSquared=3]="ExponentialSquared",eI),oc=((eO={})[eO.SolidColor=0]="SolidColor",eO[eO.SphericalHarmonics=1]="SphericalHarmonics",eO),ou=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._diffuseSolidColor=new tV(.212,.227,.259),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=oc.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n._specularTextureDecodeRGBM=!1,n}tX(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 i=e.shaderData;i.setTexture(t._specularTextureProperty,null),i.disableMacro(t._specularMacro)},n._setDiffuseMode=function(e){this._diffuseMode===oc.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]},tW(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,i=n.length;r<i;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,i=n.length;r<i;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}(t3);ou._shMacro=nj.getByName("SCENE_USE_SH"),ou._specularMacro=nj.getByName("SCENE_USE_SPECULAR_ENV"),ou._decodeRGBMMacro=nj.getByName("SCENE_IS_DECODE_ENV_RGBM"),ou._diffuseColorProperty=nQ.getByName("scene_EnvMapLight.diffuse"),ou._diffuseSHProperty=nQ.getByName("scene_EnvSH"),ou._diffuseIntensityProperty=nQ.getByName("scene_EnvMapLight.diffuseIntensity"),ou._specularTextureProperty=nQ.getByName("scene_EnvSpecularSampler"),ou._specularIntensityProperty=nQ.getByName("scene_EnvMapLight.specularIntensity"),ou._mipLevelProperty=nQ.getByName("scene_EnvMapLight.mipMapLevel");var od=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.intensity=1,t.cullingMask=rM.Everything,t.shadowType=rq.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t._lightIndex=-1,t._lightColor=new tV,t._shadowStrength=1,t._color=new tV(1,1,1,1),t}return tX(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},tW(t,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=tA.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 tB),tB.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new tB),tB.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),t}(rh);tq([tJ],od.prototype,"_lightIndex",void 0);var oh=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shadowNearPlaneOffset=.1,t._reverseDirection=new tR,t}tX(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,i=3*e,a=this._getLightIntensityColor(),o=this.direction,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n4.Linear?(t.color[r]=tV.gammaToLinearSpace(a.r),t.color[r+1]=tV.gammaToLinearSpace(a.g),t.color[r+2]=tV.gammaToLinearSpace(a.b)):(t.color[r]=a.r,t.color[r+1]=a.g,t.color[r+2]=a.b),t.direction[i]=o.x,t.direction[i+1]=o.y,t.direction[i+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)},tW(t,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tR.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}}]),t}(od);oh._cullingMaskProperty=nQ.getByName("scene_DirectLightCullingMask"),oh._colorProperty=nQ.getByName("scene_DirectLightColor"),oh._directionProperty=nQ.getByName("scene_DirectLightDirection");var o_=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t}tX(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,i=3*e,a=this._getLightIntensityColor(),o=this.position,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n4.Linear?(t.color[r]=tV.gammaToLinearSpace(a.r),t.color[r+1]=tV.gammaToLinearSpace(a.g),t.color[r+2]=tV.gammaToLinearSpace(a.b)):(t.color[r]=a.r,t.color[r+1]=a.g,t.color[r+2]=a.b),t.position[i]=o.x,t.position[i+1]=o.y,t.position[i+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)},tW(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}}]),t}(od);o_._cullingMaskProperty=nQ.getByName("scene_PointLightCullingMask"),o_._colorProperty=nQ.getByName("scene_PointLightColor"),o_._positionProperty=nQ.getByName("scene_PointLightPosition"),o_._distanceProperty=nQ.getByName("scene_PointLightDistance");var of=/*#__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 tR,t._projectMatrix=new tB,t}tX(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,i=3*e,a=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===n4.Linear?(t.color[r]=tV.gammaToLinearSpace(o.r),t.color[r+1]=tV.gammaToLinearSpace(o.g),t.color[r+2]=tV.gammaToLinearSpace(o.b)):(t.color[r]=o.r,t.color[r+1]=o.g,t.color[r+2]=o.b),t.position[i]=s.x,t.position[i+1]=s.y,t.position[i+2]=s.z,t.direction[a]=l.x,t.direction[a+1]=l.y,t.direction[a+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)},tW(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tR.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}}]),t}(od);of._cullingMaskProperty=nQ.getByName("scene_SpotLightCullingMask"),of._colorProperty=nQ.getByName("scene_SpotLightColor"),of._positionProperty=nQ.getByName("scene_SpotLightPosition"),of._directionProperty=nQ.getByName("scene_SpotLightDirection"),of._distanceProperty=nQ.getByName("scene_SpotLightDistance"),of._angleCosProperty=nQ.getByName("scene_SpotLightAngleCos"),of._penumbraCosProperty=nQ.getByName("scene_SpotLightPenumbraCos");var op=/*#__PURE__*/function(){function e(){this._spotLights=new rT,this._pointLights=new rT,this._directLights=new rT,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,i=this._directLights,a=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(i.length,l),h=0;h<c;h++)n.get(h)._appendData(h,a);for(var _=0;_<u;_++)r.get(_)._appendData(_,o);for(var f=0;f<d;f++)i.get(f)._appendData(f,s);d?(oh._updateShaderData(t,s),t.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):t.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(o_._updateShaderData(t,o),t.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):t.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(of._updateShaderData(t,a),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),i=t.get(n);t.set(0,i),t.set(n,r),i._lightIndex=0,r._lightIndex=n}},t._getMaxBrightestSunlight=function(){for(var e=this._directLights,t=null,n=Number.NEGATIVE_INFINITY,r=!1,i=0,a=e.length;i<a;i++){var o=e.get(i);o.shadowType===rq.None||r||(n=Number.NEGATIVE_INFINITY,r=!0);var s=o.intensity*o.color.getBrightness();r?o.shadowType!==rq.None&&n<s&&(n=s,t=o):n<s&&(n=s,t=o)}return t},e}();op._sunlightColorProperty=nQ.getByName("scene_SunlightColor"),op._sunlightDirectionProperty=nQ.getByName("scene_SunlightDirection"),op._maxLight=10;var om=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.layer=rM.Layer0,t.blendDistance=0,t._effects=[],t._priority=0,t._isGlobal=!0,t}tX(t,e);var n=t.prototype;return n.getEffect=function(e){for(var t=this._effects,n=t.length,r=0;r<n;r++){var i=t[r];if(tY(i,e))return i}},n.addEffect=function(e){if(this.getEffect(e)){nl.error('effect "'+e.name+'" already exists in the PostProcess.');return}var t=new e;return this._effects.push(t),t},n.removeEffect=function(e){for(var t=this._effects,n=t.length,r=0;r<n;r++){var i=t[r];if(tY(i,e))return t.splice(r,1),i}},n._onEnableInScene=function(){this.scene.postProcessManager._addPostProcess(this)},n._onDisableInScene=function(){this.scene.postProcessManager._removePostProcess(this)},tW(t,[{key:"isGlobal",get:function(){return this._isGlobal},set:function(e){if(e!==this._isGlobal){if(!e&&!this.engine._physicsInitialized){nl.warn("Only support local PostProcess in physics enabled Scenes.");return}this._isGlobal=e}}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e,this.scene&&(this.scene.postProcessManager._postProcessNeedSorting=!0)}}]),t}(rh);tq([t0],om.prototype,"_effects",void 0);var og=/*#__PURE__*/function(){function t(e){this.scene=e,this._postProcessNeedSorting=!1,this._postProcessPassNeedSorting=!1,this._activePostProcesses=[],this._blendEffectMap=new Map,this._defaultEffectMap=new Map,this._remainActivePassCount=0}var n=t.prototype;return n._isValid=function(){var e=this.scene;return e.engine._getActivePostProcessPasses().some(function(t){return t.isValid(e.postProcessManager)})},n._update=function(n){this._resetDefaultValue(),this._sortActivePostProcess();for(var r=this._activePostProcesses,i=0,a=r.length;i<a;i++){var o=r[i];if(n.postProcessMask&o.layer){var s=o.isGlobal,l=1;if(!s){var c=t._tempColliders,u=n.entity.transform.worldPosition,d=o.blendDistance,h=!1,_=Number.POSITIVE_INFINITY;o.entity.getComponents(e.Collider,c);for(var f=0;f<c.length;f++){var p=c[f];if(p.enabled)for(var m=p.shapes,g=0;g<m.length;g++){var v=m[g];h=!0;var y=v.getClosestPoint(u,t._tempVector3);y<_&&(_=y)}}if(!h){nl.warn('No collider shape found in the entity:"'+o.entity.name+'", the local mode of post process will not take effect.');continue}if(_>d)continue;d>0&&(l=1-_/d)}for(var x=o._effects,b=0;b<x.length;b++){var C=x[b];if(C.enabled){var S=C.constructor,T=this._blendEffectMap.get(S);T||(T=new S,this._blendEffectMap.set(S,T)),T._lerp(C,l),T.enabled=!0}}}}},n._addPostProcess=function(e){this._activePostProcesses.push(e),this._postProcessNeedSorting=!0},n._removePostProcess=function(e){var t=this._activePostProcesses.indexOf(e);t>=0&&(this._activePostProcesses.splice(t,1),this._postProcessNeedSorting=!0)},n.getBlendEffect=function(e){return this._blendEffectMap.get(e)},n._render=function(e,t,n){var r=this.scene.engine;this._srcRenderTarget=t,this._destRenderTarget=n,t._blitRenderTarget();var i=r._getActivePostProcessPasses();this._remainActivePassCount=i.length,this._initSwapRenderTarget(e);for(var a=0,o=i.length;a<o;a++)i[a].onRender(e,this._getCurrentSourceTexture(),this._currentDestRenderTarget),this._remainActivePassCount--,this._swapRT()},n._releaseSwapRenderTarget=function(){var e,t=this._swapRenderTarget;t&&(null==(e=t.getColorTexture(0))||e.destroy(!0),t.destroy(!0),this._swapRenderTarget=null)},n._sortActivePostProcess=function(){if(this._postProcessNeedSorting){var e=this._activePostProcesses;e.length&&e.sort(function(e,t){return e.priority-t.priority}),this._postProcessNeedSorting=!1}},n._resetDefaultValue=function(){var e=this;this._blendEffectMap.forEach(function(t,n){var r=e._defaultEffectMap.get(n);r||(r=new n,e._defaultEffectMap.set(n,r)),t._lerp(r,1),t.enabled=!1})},n._initSwapRenderTarget=function(e){if(this._remainActivePassCount>1){var t=e.pixelViewport,n=rw.recreateRenderTargetIfNeeded(this.scene.engine,this._swapRenderTarget,t.width,t.height,e._getInternalColorTextureFormat(),t7.Depth24Stencil8,!1,!1,1,nt.Clamp,t6.Bilinear);this._swapRenderTarget=n,this._currentDestRenderTarget=this._swapRenderTarget}else this._currentDestRenderTarget=this._destRenderTarget;this._currentSourceRenderTarget=this._srcRenderTarget},n._swapRT=function(){var e=this._currentSourceRenderTarget,t=this._currentDestRenderTarget;this._currentSourceRenderTarget=t,this._remainActivePassCount>1?this._currentDestRenderTarget=e:this._currentDestRenderTarget=this._destRenderTarget},n._getCurrentSourceTexture=function(){return this._currentSourceRenderTarget.getColorTexture(0)},t}();og._tempColliders=[],og._tempVector3=new tR;var ov=/*#__PURE__*/function(e){function t(n,r){(i=e.call(this,n)||this).physics=new ab(i),i.castShadows=!0,i.shadowResolution=rK.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new tR(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i.postProcessManager=new og(i),i._lightManager=new op,i._componentsManager=new oo,i._maskManager=new os,i._isActiveInEngine=!1,i._globalShaderMacro=new nX,i._rootEntities=[],i._background=new oa(i._engine),i._shaderData=new rc(n9.Scene),i._shadowCascades=rQ.NoCascades,i._fogMode=ol.None,i._fogColor=new tV(.5,.5,.5,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new tN,i._isActive=!0,i._enableTransparentShadow=!1,i.name=r||"";var i,a=i.shaderData;return a._addReferCount(1),i.ambientLight=new ou(n),n.sceneManager._allCreatedScenes.push(i),a.enableMacro("SCENE_FOG_MODE",i._fogMode.toString()),a.enableMacro("SCENE_SHADOW_CASCADED_COUNT",i.shadowCascades.toString()),a.setColor(t._fogColorProperty,i._fogColor),a.setVector4(t._fogParamsProperty,i._fogParams),i._computeLinearFogParams(i._fogStart,i._fogEnd),i._computeExponentialFogParams(i._fogDensity),i}tX(t,e);var n=t.prototype;return n.createRootEntity=function(e){var t=new iQ(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 i=t._scene;i!==this?(i&&r&&i._removeFromEntityList(t),this._addToRootEntityList(n,t)):r||this._addToRootEntityList(n,t);var a=rd.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(a|=rd.Hierarchy)),t._isActiveInScene&&i!==this&&(a|=rd.Scene),a&&t._processInActive(a),i!==this&&iQ._traverseSetOwnerScene(t,this);var o=rd.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=rd.Hierarchy)),t._isActiveInScene&&i===this||(o|=rd.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=rd.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=rd.Hierarchy),e._isActiveInScene&&(t|=rd.Scene),t&&e._processInActive(t),iQ._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 i=t[n].findByName(e);if(i)return i}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),n=0,r=this.rootEntitiesCount;n<r;n++){var i=this.getRootEntity(n);if(i.name==t[0]){for(var a=1,o=t.length;a<o&&(i=iQ._findChildByName(i,t[a]));++a);return i}}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(rd.Hierarchy):r._processInActive(rd.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(op._sunlightColorProperty,r._lightColor),e.setVector3(op._sunlightDirectionProperty,r.direction)):e.setVector3(op._sunlightDirectionProperty,tR._zero),this.castShadows&&r&&r.shadowType!==rq.None?e.enableMacro("SCENE_SHADOW_TYPE",r.shadowType.toString()):e.disableMacro("SCENE_SHADOW_TYPE"),nX.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 i=e+1,a=r+1;i<a;i++)n[i]._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()},tW(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){nl.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}(t2);ov._fogColorProperty=nQ.getByName("scene_FogColor"),ov._fogParamsProperty=nQ.getByName("scene_FogParams");var oy=/*#__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}tX(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}(rh);tq([tJ],oy.prototype,"_started",void 0),tq([tJ],oy.prototype,"_onStartIndex",void 0),tq([tJ],oy.prototype,"_onUpdateIndex",void 0),tq([tJ],oy.prototype,"_onLateUpdateIndex",void 0),tq([tJ],oy.prototype,"_onPhysicsUpdateIndex",void 0),tq([tJ],oy.prototype,"_onPreRenderIndex",void 0),tq([tJ],oy.prototype,"_onPostRenderIndex",void 0),tq([tJ],oy.prototype,"_entityScriptsIndex",void 0);var ox=/*#__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}();ox._engineObjects={},ox._classNameMap=new Map;var ob=/*#__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,i,a,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)],i=parseInt(_.slice(f+1,-1))}else if(_.endsWith(")")){if(a=_.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=i,this._setValueName=_,a&&(this._setValueName=a),this._setArgs=o),1&n&&(this._getMounted=e,this._getType=r,this._getArrayIndex=i,this._getValueName=_,a&&(this._getValueName=a),this._getArgs=o)},e}(),oC=/*#__PURE__*/function(){function e(t,n,r,i,a,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=i,this.getProperty=a,this.component=r,this.cureType=o;var s=e.getAssemblerType(n,i);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,i,a){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,r,!1);var o=e&&e.keys.length?a?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):a?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?a?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):a?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,i)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var i=r?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,a=e&&e.keys.length?r?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):r?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(i,a,n)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.getEvaluateValue=function(e){return this.cureType._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 i=this._assembler;if(r._isCopyMode)r._additiveValue(e,t,this.referenceTargetValue);else{var a=i.getTargetValue(),o=r._additiveValue(e,t,a);i.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 i=e._assemblerMap.get(t);i||(i={},e._assemblerMap.set(t,i)),i[n]=r},e.getAssemblerType=function(t,n){var r=e._assemblerMap.get(t),i=r?r[n]:void 0;return null!=i?i:ob},e}();oC._components=[],oC._assemblerMap=new Map;var oS=/*#__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}();oC.registerAssembler(rg,"position",oS);var oT=/*#__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}();oC.registerAssembler(rg,"rotationQuaternion",oT);var oA=/*#__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}();oC.registerAssembler(rg,"scale",oA);var oR=/*#__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}();oC.registerAssembler(i$,"blendShapeWeights",oR);var oE=/*#__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 oC(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 oE;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}(),ow=function(){},oP=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n._curveBindings=[],n._updateFlagManager=new nP,n._length=0,n._events=[],n}tX(t,e);var n=t.prototype;return n.addEvent=function(e,t,n){if("string"==typeof e){var r,i=new ow;i.functionName=e,i.time=t,i.parameter=n,r=i}else r=e;var a=this._events,o=a.length,s=r.time;if(s>=(o?a[o-1].time:0))a.push(r);else{for(var l=o;--l>=0&&s<a[l].time;);a.splice(l+1,0,r)}this._updateFlagManager.dispatch()},n.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},n.addCurveBinding=function(e,t,n,r,i,a){var o=new oM;o.relativePath=e,o.type=t,"number"==typeof n?(o.typeIndex=n,o.property=r,"string"==typeof i?(o.getProperty=i,o.curve=a):o.curve=i):(o.property=n,"string"==typeof r?(o.getProperty=r,o.curve=i):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 i=n[r],a=e.findByPath(i.relativePath);if(a){var o=i.typeIndex>0?a.getComponents(i.type,oC._components)[i.typeIndex]:a.getComponent(i.type);if(!o)continue;var s=i._getTempCurveOwner(a,o);if(s&&i.curve.keys.length){var l=s.evaluateValue(i.curve,t,!1);s.applyValue(l,1,!1)}}}},tW(t,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),t}(t2),oF=((eN={})[eN.Linear=0]="Linear",eN[eN.CubicSpine=1]="CubicSpine",eN[eN.Step=2]="Step",eN[eN.Hermite=3]="Hermite",eN),oL=/*#__PURE__*/function(){function e(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var e=this.constructor;this._interpolation=e._supportInterpolationMode?oF.Linear:oF.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 i=t[r];i.time>this._length&&(n=i.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 i=this.keys,a=this.interpolation,o=t.curKeyframeIndex;-1!==o&&(o>=r||e<i[o].time)&&(o=-1);for(var s=o+1;s<r&&!(e<i[s].time);)o++,s++;if(t.curKeyframeIndex=o,-1===o)n=this._type._setValue(i[0].value,t.value);else if(s===r)n=this._type._setValue(i[o].value,t.value);else{var l=i[o],c=i[s],u=l.time,d=c.time-u,h=(e-u)/d;switch(a){case oF.Linear:n=this._type._lerpValue(l.value,c.value,h,t.value);break;case oF.Step:n=this._type._setValue(l.value,t.value);break;case oF.CubicSpine:case oF.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)},tW(e,[{key:"interpolation",get:function(){return this._interpolation},set:function(e){this._type._supportInterpolationMode||e===oF.Step?this._interpolation=e:(this._interpolation=oF.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 tX(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 i=0,a=r.length;i<a;++i){var o=e[i];r[i]=o+(t[i]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;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,i=n.length;r<i;++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,i){for(var a=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(a[p])&&Number.isFinite(o[p])?i[p]=d*s[p]+h*a[p]*r+_*o[p]*r+f*l[p]:i[p]=e.value[p];return i},t}(oL),e.AnimationArrayCurve._isCopyMode=!0,e.AnimationArrayCurve._supportInterpolationMode=!0,e.AnimationArrayCurve=tq([rb()],e.AnimationArrayCurve),e.AnimationBoolCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=!1,t}return tX(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}(oL),e.AnimationBoolCurve._isCopyMode=!1,e.AnimationBoolCurve._supportInterpolationMode=!1,e.AnimationBoolCurve=tq([rb()],e.AnimationBoolCurve),e.AnimationColorCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tV,t}return tX(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._lerpValue=function(e,t,n,r){return tV.lerp(e,t,n,r),r},t._subtractValue=function(e,t,n){return tV.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._additiveValue=function(e,t,n){return tV.scale(e,t,e),tV.add(n,e,n),n},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,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)?i.r=d*a.r+h*p*r+_*m*r+f*s.r:i.r=a.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.g=d*a.g+h*p*r+_*m*r+f*s.g:i.g=a.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.b=d*a.b+h*p*r+_*m*r+f*s.b:i.b=a.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.a=d*a.a+h*p*r+_*m*r+f*s.a:i.a=a.a,i},t}(oL),e.AnimationColorCurve._isCopyMode=!0,e.AnimationColorCurve._supportInterpolationMode=!0,e.AnimationColorCurve=tq([rb()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tX(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 i=0,a=r.length;i<a;++i){var o=e[i];r[i]=o+(t[i]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;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,i=n.length;r<i;++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,i){for(var a=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(a[p])&&Number.isFinite(o[p])?i[p]=d*s[p]+h*a[p]*r+_*o[p]*r+f*l[p]:i[p]=e.value[p];return i},t}(oL),e.AnimationFloatArrayCurve._isCopyMode=!0,e.AnimationFloatArrayCurve._supportInterpolationMode=!0,e.AnimationFloatArrayCurve=tq([rb()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=0,t}return tX(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 i=e.outTangent,a=t.inTangent;if(!(Number.isFinite(i)&&Number.isFinite(a)))return e.value;var o=n*n,s=o*n;return(2*s-3*o+1)*e.value+(s-2*o+n)*i*r+(s-o)*a*r+(-2*s+3*o)*t.value},t}(oL),e.AnimationFloatCurve._isCopyMode=!1,e.AnimationFloatCurve._supportInterpolationMode=!0,e.AnimationFloatCurve=tq([rb()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tD,t}return tX(t,e),t._initializeOwner=function(e){e.defaultValue=new tD,e.fixedPoseValue=new tD,e.baseEvaluateData.value=new tD,e.crossEvaluateData.value=new tD},t._initializeLayerOwner=function(e){e.finalValue=new tD},t._lerpValue=function(e,t,n,r){return tD.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 i=t._tempConjugateQuat;return tD.conjugate(n,i),tD.multiply(i,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,i){var a=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)?i.x=d*a.x+h*p*r+_*m*r+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*r+_*m*r+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*r+_*m*r+f*s.z:i.z=a.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.w=d*a.w+h*p*r+_*m*r+f*s.w:i.w=a.w,i},t}(oL),e.AnimationQuaternionCurve._supportInterpolationMode=!0,e.AnimationQuaternionCurve._isCopyMode=!0,e.AnimationQuaternionCurve._tempConjugateQuat=new tD,e.AnimationQuaternionCurve=tq([rb()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tO,t}return tX(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._additiveValue=function(e,t,n){return tO.scale(e,t,e),tO.add(n,e,n),n},t._subtractValue=function(e,t,n){return tO.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,i){var a=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)?i.x=d*a.x+h*p*r+_*m*r+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*r+_*m*r+f*s.y:i.y=a.y,i},t}(oL),e.AnimationVector2Curve._isCopyMode=!0,e.AnimationVector2Curve._supportInterpolationMode=!0,e.AnimationVector2Curve=tq([rb()],e.AnimationVector2Curve),e.AnimationVector3Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tR,t}return tX(t,e),t._initializeOwner=function(e){e.defaultValue=new tR,e.fixedPoseValue=new tR,e.baseEvaluateData.value=new tR,e.crossEvaluateData.value=new tR},t._initializeLayerOwner=function(e){e.finalValue=new tR},t._lerpValue=function(e,t,n,r){return tR.lerp(e,t,n,r),r},t._relativeBaseValue=function(e,t){return tR.subtract(t,e,t),t},t._additiveValue=function(e,t,n){return tR.scale(e,t,e),tR.add(n,e,n),n},t._subtractValue=function(e,t,n){return tR.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,i){var a=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)?i.x=d*a.x+h*p*r+_*m*r+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*r+_*m*r+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*r+_*m*r+f*s.z:i.z=a.z,i},t}(oL),e.AnimationVector3Curve._isCopyMode=!0,e.AnimationVector3Curve._supportInterpolationMode=!0,e.AnimationVector3Curve=tq([rb()],e.AnimationVector3Curve),e.AnimationVector4Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tN,t}return tX(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._lerpValue=function(e,t,n,r){return tN.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tN.scale(e,t,e),tN.add(n,e,n),n},t._subtractValue=function(e,t,n){return tN.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,i){var a=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)?i.x=d*a.x+h*p*r+_*m*r+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*r+_*m*r+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*r+_*m*r+f*s.z:i.z=a.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.w=d*a.w+h*p*r+_*m*r+f*s.w:i.w=a.w,i},t}(oL),e.AnimationVector4Curve._isCopyMode=!0,e.AnimationVector4Curve._supportInterpolationMode=!0,e.AnimationVector4Curve=tq([rb()],e.AnimationVector4Curve),e.AnimationRefCurve=/*#__PURE__*/function(e){function t(){return e.call(this)||this}return tX(t,e),t._initializeOwner=function(e){},t._initializeLayerOwner=function(e){},t._setValue=function(e){return e},t}(oL),e.AnimationRefCurve._isCopyMode=!1,e.AnimationRefCurve._supportInterpolationMode=!1,e.AnimationRefCurve=tq([rb()],e.AnimationRefCurve),e.AnimationRectCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tk,t}return tX(t,e),t._initializeOwner=function(e){e.defaultValue=new tk,e.fixedPoseValue=new tk,e.baseEvaluateData.value=new tk,e.crossEvaluateData.value=new tk},t._initializeLayerOwner=function(e){e.finalValue=new tk},t._setValue=function(e,t){return t.copyFrom(e),t},t}(oL),e.AnimationRectCurve._isCopyMode=!0,e.AnimationRectCurve._supportInterpolationMode=!1,e.AnimationRectCurve=tq([rb()],e.AnimationRectCurve),e.AnimationStringCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value="",t}return tX(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}(oL),e.AnimationStringCurve._isCopyMode=!1,e.AnimationStringCurve._supportInterpolationMode=!1,e.AnimationStringCurve=tq([rb()],e.AnimationStringCurve);var oD=((eV={})[eV.If=0]="If",eV[eV.IfNot=1]="IfNot",eV[eV.Greater=2]="Greater",eV[eV.Less=3]="Less",eV[eV.Equals=4]="Equals",eV[eV.NotEquals=5]="NotEquals",eV),oB=((ek={})[ek.None=0]="None",ek[ek.Complete=1]="Complete",ek),oI=((ez={})[ez.Override=0]="Override",ez[ez.Additive=1]="Additive",ez),oO=((eU={})[eU.UnStarted=0]="UnStarted",eU[eU.Playing=1]="Playing",eU[eU.Finished=2]="Finished",eU),oN=((eG={})[eG.Standby=0]="Standby",eG[eG.Playing=1]="Playing",eG[eG.CrossFading=2]="CrossFading",eG[eG.FixedCrossFading=3]="FixedCrossFading",eG[eG.Finished=4]="Finished",eG),oV=/*#__PURE__*/function(){function e(){this.handlers=[]}return e.prototype.dispose=function(){},e}(),ok=function(){},oz=/*#__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 ok;return r.parameterName=e,r.mode=null!=t?t:oD.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()},tW(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}(),oU=((eH={})[eH.Once=0]="Once",eH[eH.Loop=1]="Loop",eH),oG=/*#__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=oO.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=oO.Playing,t.wrapMode===oU.Loop?n=r?n%r:0:Math.abs(n)>=r&&(n=n<0?-r:r,this.playState=oO.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}(),oH=/*#__PURE__*/function(){function e(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new oG,this.destPlayData=new oG,this.layerState=oN.Standby,this.crossCurveMark=0,this.manuallyTransition=new oz,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}(),oW=function(){this.curveLayerOwner=[],this.eventHandlers=[]},oj=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this).cullingMode=oB.None,n.speed=1,n._playFrameCount=-1,n._onUpdateIndex=-1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new oe(oV),n._parametersValueMap=Object.create(null),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n}tX(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,i=this._getAnimatorStateInfo(e,t),a=i.state;a&&this._preparePlay(a,i.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===oB.Complete){n=!1;for(var t,n,r=this._controlledRenderers,i=0,a=r.length;i<a;i++)if(!r[i].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,i){(null==(a=this._controllerUpdateFlag)?void 0:a.flag)&&this._reset();var a,o=this._getAnimatorStateInfo(e,n),s=o.state,l=o.layerIndex,c=this._getAnimatorLayerData(l).manuallyTransition;c.duration=t,c.offset=r,c.isFixedDuration=i,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,i=null;if(n){var a=n.layers;if(-1===t){for(var o=0,s=a.length;o<s;o++)if(i=a[o].stateMachine.findStateByName(e)){t=o;break}}else i=a[t].stateMachine.findStateByName(e)}return r.layerIndex=t,r.state=i,r},r._getAnimatorStateData=function(e,t,n,r){var i=n.animatorStateDataMap,a=i[e];return a||(a=new oW,i[e]=a,this._saveAnimatorStateData(t,a,n,r),this._saveAnimatorEventHandlers(t,a)),a},r._saveAnimatorStateData=function(e,t,n,r){for(var i=this.entity,a=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?i:i.findByPath(d.relativePath);if(_){var f,p,m=d.typeIndex>0?_.getComponents(d.type,oC._components)[d.typeIndex]:_.getComponent(d.type);if(!m)continue;var g=d.property,v=m.instanceId,y=a[v]||(a[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,nl.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,i=[],a=t.eventHandlers,o=function(){n._entity.getComponents(oy,i);var t=i.length,o=e.clip.events;a.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=i[_],m=null==(f=p[d])?void 0:f.bind(p);m&&h.push(m)}a.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 i=n[r];i&&(i.crossCurveMark=e.crossCurveMark,t&&i.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,i,r,-1))}},r._prepareDestCrossData=function(e,t){for(var n=e.destPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var i=n[r];if(i){if(i.crossCurveMark===e.crossCurveMark)i.crossDestCurveIndex=r;else{var a=i.curveOwner;t&&a.saveFixedPoseValue(),i.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,i,-1,r)}}}},r._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||((t=new oH).layerIndex=e,t.layer=this._animatorController.layers[e],this._animatorLayersData[e]=t),t},r._updateState=function(e,t,n){var r=e.layer,i=r.weight,a=r.blendingMode===oI.Additive;switch(0===e.layerIndex&&(i=1),e.layerState){case oN.Standby:this._checkAnyAndEntryState(e,t,n);break;case oN.Playing:this._updatePlayingState(e,i,a,t,n);break;case oN.Finished:this._updateFinishedState(e,i,a,t,n);break;case oN.CrossFading:this._updateCrossFadeState(e,i,a,t,n);break;case oN.FixedCrossFading:this._updateCrossFadeFromPoseState(e,i,a,t,n)}},r._updatePlayingState=function(e,t,n,r,i){var a,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,i)||f.count&&this._applyStateTransitions(e,_,o,f,u,h,c,i);if(m){var g=s._getClipActualEndTime();if(m.hasExitTime){var v=m.exitTime*s._getDuration()+s._getClipActualStartTime();if(_)a=v<u?v+g-u:v-u;else{var y=s._getClipActualStartTime();a=-(a=u<v?g-v+u-y:u-v)}}else a=0;o.update(a-c)}else a=c,o.playState===oO.Finished&&(e.layerState=oN.Finished);if(this._evaluatePlayingState(o,t,n,i),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,u,d,a),m){var x=r-a/l;x>0&&this._updateState(e,x,i)}},r._evaluatePlayingState=function(e,t,n,r){var i=e.state.clip._curveBindings,a=e.playState===oO.Finished;if(r||a)for(var o=e.stateData.curveLayerOwner,s=i.length-1;s>=0;s--){var l=o[s],c=null==l?void 0:l.curveOwner;if(c&&l.isActive){var u=i[s].curve;if(u.keys.length){this._checkRevertOwner(c,n);var d=c.evaluateValue(u,e.clipTime,n);r&&c.applyValue(d,t,n),a&&l.saveFinalValue()}}}},r._updateCrossFadeState=function(e,t,n,r,i){var a,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;a=x+p>h?h-x:p}else{var b=s.playedTime;a=b-p>h?b-h:p}var C=0===f?r:a/f,S=C*_;o.update(S),s.update(a);var T=Math.abs(s.playedTime)/h;(T>=1-tA.zeroTolerance||0===h)&&(T=1);var A=1===T;if(A?(o.playState=oO.Finished,this._preparePlayOwner(e,d),this._evaluatePlayingState(s,t,n,i)):this._evaluateCrossFadeState(e,o,s,t,T,n,i),this._fireAnimationEventsAndCallScripts(l,o,u,m,g,S),this._fireAnimationEventsAndCallScripts(l,s,d,v,y,a),A){this._updateCrossFadeData(e);var R=r-C;R>0&&this._updateState(e,R,i)}},r._evaluateCrossFadeState=function(e,t,n,r,i,a,o){var s=e.crossLayerOwnerCollection,l=t.state.clip._curveBindings,c=n.state.clip._curveBindings,u=n.playState===oO.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(_,a);var m=_.evaluateCrossFadeValue(f>=0?l[f].curve:null,p>=0?c[p].curve:null,t.clipTime,n.clipTime,i,a);o&&_.applyValue(m,r,a),u&&h.saveFinalValue()}}},r._updateCrossFadeFromPoseState=function(e,t,n,r,i){var a,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;a=_+u>l?l-_:u}else{var f=o.playedTime;a=f-u>l?f-l:u}var p=0===c?r:a/c;o.update(a);var m=Math.abs(o.playedTime)/l;(m>=1-tA.zeroTolerance||0===l)&&(m=1);var g=1===m;if(g?(this._preparePlayOwner(e,s),this._evaluatePlayingState(o,t,n,i)):this._evaluateCrossFadeFromPoseState(e,o,t,m,n,i),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,d,h,a),g){this._updateCrossFadeData(e);var v=r-p;v>0&&this._updateState(e,v,i)}},r._evaluateCrossFadeFromPoseState=function(e,t,n,r,i,a){var o=e.crossLayerOwnerCollection,s=t.state.clip._curveBindings,l=t.clipTime,c=t.playState===oO.Finished;if(a||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,i);var f=d.curveOwner.crossFadeFromPoseAndApplyValue(_>=0?s[_].curve:null,l,r,i);a&&h.applyValue(f,n,i),c&&d.saveFinalValue()}}},r._updateFinishedState=function(e,t,n,r,i){var a=e.srcPlayData,o=a.state,s=o.speed*this.speed*r;a.updateOrientation(s);var l=a.clipTime,c=a.isForward,u=o._transitionCollection,d=e.layer.stateMachine._anyStateTransitionCollection;d.count&&this._applyTransitionsByCondition(e,d,i)||u.count&&this._applyStateTransitions(e,c,a,u,l,l,s,i)?this._updateState(e,r,i):this._evaluateFinishedState(a,t,n,i)},r._evaluateFinishedState=function(e,t,n,r){if(r)for(var i=e.stateData.curveLayerOwner,a=e.state.clip._curveBindings,o=a.length-1;o>=0;o--){var s=i[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,n),l.applyValue(s.finalValue,t,n))}},r._updateCrossFadeData=function(e){e.destPlayData.playState===oO.Finished?e.layerState=oN.Finished:e.layerState=oN.Playing,e.switchPlayData(),e.crossFadeTransition=null},r._preparePlayOwner=function(e,t){if(e.layerState===oN.Playing){var n=e.srcPlayData;if(n.state!==t)for(var r,i=n.stateData.curveLayerOwner,a=i.length-1;a>=0;a--)null==(r=i[a])||r.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},r._applyStateTransitions=function(e,t,n,r,i,a,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?i+o>=h?(u=this._checkSubTransition(e,l,r,i,h,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkSubTransition(e,l,r,d,a,s)):u=this._checkSubTransition(e,l,r,i,a,s):i+o<=d?(u=this._checkBackwardsSubTransition(e,l,r,i,d,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkBackwardsSubTransition(e,l,r,a,h,s)):u=this._checkBackwardsSubTransition(e,l,r,i,a,s)),u},r._checkNoExitTimeTransition=function(e,t,n){for(var r=0,i=t.count;r<i;++r){var a=t.get(r);if(!a.mute&&(!t.isSoloMode||a.solo)&&this._checkConditions(a))return this._applyTransition(e,a,n)}return null},r._checkSubTransition=function(e,t,n,r,i,a){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>i)break;if(!(u<r)){if(n.updateCurrentCheckIndex(!0),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,a)}}return null},r._checkBackwardsSubTransition=function(e,t,n,r,i,a){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<i)break;if(!(u>r)){if(n.updateCurrentCheckIndex(!1),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,a)}}return null},r._applyTransitionsByCondition=function(e,t,n){for(var r=0,i=t.count;r<i;r++){var a=t.get(r);if(!a.mute&&(!t.isSoloMode||a.solo)&&this._checkConditions(a)){if(this._applyTransition(e,a,n))return a;return null}}},r._preparePlay=function(e,t,n){void 0===n&&(n=0);var r=e.name;if(!e.clip)return nl.warn("The state named "+r+" has no AnimationClip data."),!1;var i=this._getAnimatorLayerData(t),a=this._getAnimatorStateData(r,e,i,t);return this._preparePlayOwner(i,e),i.layerState=oN.Playing,i.srcPlayData.reset(e,a,e._getClipActualEndTime()*n),i.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,i=0,a=t.length;i<a;++i){var o=!1,s=t[i],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 oD.Equals:d===u&&(o=!0);break;case oD.Greater:d>u&&(o=!0);break;case oD.Less:d<u&&(o=!0);break;case oD.NotEquals:d!==u&&(o=!0);break;case oD.If:!0===d&&(o=!0);break;case oD.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 nl.warn("The state named "+n.name+" has no AnimationClip data."),!1;var r=this._getAnimatorLayerData(t),i=this._getAnimatorStateData(n.name,n,r,t);switch(r.destPlayData.reset(n,i,e.offset*n._getClipActualEndTime()),r.resetCurrentCheckIndex(),r.layerState){case oN.Standby:case oN.Finished:r.layerState=oN.FixedCrossFading,this._clearCrossData(r),this._prepareStandbyCrossFading(r);break;case oN.Playing:r.layerState=oN.CrossFading,this._clearCrossData(r),this._prepareCrossFading(r);break;case oN.CrossFading:r.layerState=oN.FixedCrossFading,this._prepareFixedPoseCrossFading(r);break;case oN.FixedCrossFading:this._prepareFixedPoseCrossFading(r)}return r.crossFadeTransition=e,!0},r._fireAnimationEvents=function(e,t,n,r){var i=e.state,a=e.isForward,o=e.clipTime,s=i._getClipActualStartTime(),l=i._getClipActualEndTime();a?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 i=e.currentEventIndex,a=t.length;i<a;i++){var o=t[i],s=o.event,l=s.time,c=s.parameter;if(l>r)break;var u=o.handlers;if(l>=n){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(i+1,a-1)}}},r._fireBackwardSubAnimationEvents=function(e,t,n,r){for(var i=e.currentEventIndex;i>=0;i--){var a=t[i],o=a.event,s=o.time,l=o.parameter;if(s<r)break;if(s<=n){for(var c=a.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(i-1,0)}}},r._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},r._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},r._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},r._checkAnyAndEntryState=function(e,t,n){var r,i=e.layer.stateMachine,a=i._anyStateTransitionCollection,o=i._entryTransitionCollection;if((r=a.count&&this._applyTransitionsByCondition(e,a,n))||(r=o.count&&this._applyTransitionsByCondition(e,o,n)),r)this._updateState(e,t,n);else{var s=i.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,i,a){var o=t.stateData.eventHandlers;o.length&&this._fireAnimationEvents(t,o,r,a),i===oO.UnStarted&&this._callAnimatorScriptOnEnter(n,e),i!==oO.Finished&&t.playState===oO.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},tW(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}(rh);oj._passedTriggerParameterNames=[],tq([tZ],oj.prototype,"speed",void 0),tq([tJ],oj.prototype,"_controllerUpdateFlag",void 0),tq([tJ],oj.prototype,"_updateMark",void 0),tq([tJ],oj.prototype,"_animatorLayersData",void 0),tq([tJ],oj.prototype,"_curveOwnerPool",void 0),tq([tJ],oj.prototype,"_animationEventHandlerPool",void 0),tq([tJ],oj.prototype,"_parametersValueMap",void 0),tq([tJ],oj.prototype,"_tempAnimatorStateInfo",void 0),tq([tJ],oj.prototype,"_controlledRenderers",void 0);var oX=/*#__PURE__*/function(){function e(){this._onNameChanged=null,this._isTrigger=!1}return tW(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}(),oK=/*#__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 nP),function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}tX(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(rm)},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 i=new oX;return i.name=e,i.defaultValue=t,i._isTrigger=n,i._onNameChanged=function(e,t){delete r._parametersMap[e],r._parametersMap[t]=i},this._parametersMap[e]=i,this._parameters.push(i),i},tW(t,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),t}(t3),oq=/*#__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 tY(e,oQ)?((t=new oz).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 i=r;--i>=0&&n<t[i].exitTime;);t.splice(i+1,0,e)}},tW(e,[{key:"isSoloMode",get:function(){return this._soloCount>0}},{key:"count",get:function(){return this.transitions.length}}]),e}(),oY=/*#__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}(),oQ=/*#__PURE__*/function(){function e(e){this.name=e,this.speed=1,this.wrapMode=oU.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new nP,this._transitionCollection=new oq,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 oz;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=oY.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=oY.prototype;if(e.onStateEnter!==t.onStateEnter){var n=this._onStateEnterScripts.indexOf(e);-1!==n&&this._onStateEnterScripts.splice(n,1)}if(e.onStateUpdate!==t.onStateUpdate){var r=this._onStateUpdateScripts.indexOf(e);-1!==r&&this._onStateUpdateScripts.splice(r,1)}if(e.onStateExit!==t.onStateExit){var i=this._onStateExitScripts.indexOf(e);-1!==i&&this._onStateExitScripts.splice(i,1)}},t._onClipChanged=function(){this._updateFlagManager.dispatch()},t._getClipActualStartTime=function(){return this._clipStartTime*this.clip.length},t._getClipActualEndTime=function(){return this._clipEndTime*this.clip.length},tW(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}(),oJ=/*#__PURE__*/function(){function e(){this.states=[],this._entryTransitionCollection=new oq,this._anyStateTransitionCollection=new oq,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 oQ(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()},tW(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=oI.Override,this.stateMachine=new oJ},o$=function(){},o0=function(){},o1=/*#__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 o0;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 i in this._pathMaskMap)i.startsWith(e)&&(this._pathMaskMap[i].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 i=n.children,a=0,o=i.length;a<o;++a){var s=i[a],l=r?r+"/"+s.name:s.name;t.addPathMask(l),e._addPathMaskWithChildren(t,s,l)}},tW(e,[{key:"pathMasks",get:function(){return this._pathMasks}}]),e}(),o2=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,rl.find("skybox"))||this)._textureDecodeRGBM=!1,r._tintColor=new tV(1,1,1,1),r.renderState.rasterState.cullMode=nN.Off,r.renderState.depthState.compareFunction=nO.LessEqual,r.shaderData.setFloat(t._rotationProp,0),r.shaderData.setFloat(t._exposureProp,1),r.shaderData.setColor(t._tintColorProp,r._tintColor),r}return tX(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tW(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}(iu);o2._tintColorProp=nQ.getByName("material_TintColor"),o2._textureCubeProp=nQ.getByName("material_CubeTexture"),o2._rotationProp=nQ.getByName("material_Rotation"),o2._exposureProp=nQ.getByName("material_Exposure"),o2._decodeSkyRGBMMacro=nj.getByName("MATERIAL_IS_DECODE_SKY_RGBM");var o3=((eW={})[eW.None=0]="None",eW[eW.Simple=1]="Simple",eW[eW.HighQuality=2]="HighQuality",eW),o4=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,rl.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new tV(.5,.5,.5,1),n.groundTint=new tV(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=nN.Off,n.renderState.depthState.compareFunction=nO.LessEqual,n}return tX(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tW(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}(iu);o4._sunSizeProp=nQ.getByName("material_SunSize"),o4._sunSizeConvergenceProp=nQ.getByName("material_SunSizeConvergence"),o4._atmosphereThicknessProp=nQ.getByName("material_AtmosphereThickness"),o4._skyTintProp=nQ.getByName("material_SkyTint"),o4._groundTintProp=nQ.getByName("material_GroundTint"),o4._exposureProp=nQ.getByName("material_Exposure"),o4._sunHighQualityMacro=nj.getByName("MATERIAL_SUN_HIGH_QUALITY"),o4._sunSimpleMacro=nj.getByName("MATERIAL_SUN_SIMPLE");var o8=((ej={})[ej.Billboard=0]="Billboard",ej[ej.StretchBillboard=1]="StretchBillboard",ej[ej.HorizontalBillboard=2]="HorizontalBillboard",ej[ej.VerticalBillboard=3]="VerticalBillboard",ej[ej.Mesh=4]="Mesh",ej[ej.None=5]="None",ej),o5=((eX={})[eX.Local=0]="Local",eX[eX.World=1]="World",eX),o9=((eK={})[eK.StopEmittingAndClear=0]="StopEmittingAndClear",eK[eK.StopEmitting=1]="StopEmitting",eK),o6=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).velocityScale=0,r.lengthScale=2,r.pivot=new tR,r._generatorBounds=new tM,r._transformedBounds=new tM,r._onGeneratorParamsChanged=r._onGeneratorParamsChanged.bind(r),r.generator=new sy(r),r._currentRenderModeMacro=t._billboardModeMacro,r.shaderData.enableMacro(t._billboardModeMacro),r._supportInstancedArrays=r.engine._hardwareRenderer.canIUse(n$.instancedArrays),r._onGeneratorParamsChanged(),r}tX(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,o9.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===o5.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 i=this._engine,a=i._renderElementPool.get();a.set(this.priority,this._distanceForSort);var o=i._subRenderElementPool.get();o.set(this,r,t._primitive,t._subPrimitive),a.addSubRenderElement(o),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|=rx.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|rx.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|rx.WorldVolume},tW(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,i=this.shaderData;switch(e){case o8.Billboard:r=t._billboardModeMacro;break;case o8.StretchBillboard:r=t._stretchedBillboardModeMacro;break;case o8.HorizontalBillboard:case o8.VerticalBillboard:case o8.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==r&&(this._currentRenderModeMacro&&i.disableMacro(this._currentRenderModeMacro),r&&i.enableMacro(r),this._currentRenderModeMacro=r),n!==o8.Mesh!=(e===o8.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===o8.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),t}(e.Renderer);o6._billboardModeMacro=nj.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),o6._stretchedBillboardModeMacro=nj.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),o6._horizontalBillboardModeMacro=nj.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),o6._verticalBillboardModeMacro=nj.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),o6._renderModeMeshMacro=nj.getByName("RENDERER_MODE_MESH"),o6._pivotOffsetProperty=nQ.getByName("renderer_PivotOffset"),o6._lengthScale=nQ.getByName("renderer_StretchedBillboardLengthScale"),o6._speedScale=nQ.getByName("renderer_StretchedBillboardSpeedScale"),o6._currentTime=nQ.getByName("renderer_CurrentTime"),tq([t0],o6.prototype,"generator",void 0),tq([t$],o6.prototype,"pivot",void 0),tq([tJ],o6.prototype,"_generatorBounds",void 0),tq([tJ],o6.prototype,"_transformedBounds",void 0),tq([tJ],o6.prototype,"_onGeneratorParamsChanged",null);var o7=((eq={})[eq.TransformVolume=2]="TransformVolume",eq[eq.GeneratorVolume=4]="GeneratorVolume",eq),se=((eY={})[eY.Constant=0]="Constant",eY[eY.TwoConstants=1]="TwoConstants",eY[eY.Curve=2]="Curve",eY[eY.TwoCurves=3]="TwoCurves",eY),st=((eQ={})[eQ.Constant=0]="Constant",eQ[eQ.TwoConstants=1]="TwoConstants",eQ[eQ.Gradient=2]="Gradient",eQ[eQ.TwoGradients=3]="TwoGradients",eQ),sn=((eJ={})[eJ.Burst=0x23571a3e]="Burst",eJ[eJ.StartDelay=0x13371337]="StartDelay",eJ[eJ.StartColor=0x12460f3b]="StartColor",eJ[eJ.StartSize=0x6aed452e]="StartSize",eJ[eJ.StartRotation=0xdec4aea1]="StartRotation",eJ[eJ.randomizeRotationDirection=0x96aa4de3]="randomizeRotationDirection",eJ[eJ.StartLifetime=0x8d2c8431]="StartLifetime",eJ[eJ.StartSpeed=0xf3857f6f]="StartSpeed",eJ[eJ.VelocityOverLifetime=0xe0fbd834]="VelocityOverLifetime",eJ[eJ.ColorOverLifetime=0x13740583]="ColorOverLifetime",eJ[eJ.SizeOverLifetime=0x591bc05c]="SizeOverLifetime",eJ[eJ.RotationOverLifetime=0x40eb95e4]="RotationOverLifetime",eJ[eJ.TextureSheetAnimation=0xbc524e5]="TextureSheetAnimation",eJ[eJ.Shape=0xaf502044]="Shape",eJ[eJ.GravityModifier=0xa47b8c4d]="GravityModifier",eJ),sr=/*#__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 i=e[n];this.addColorKey(i)}if(t)for(var a=0,o=t.length;a<o;a++){var s=t[a];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 si(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 sa(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,i=0,a=n.length;i<a;i++)n[i]._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,i=Math.min(n.length,4);r<i;r++){var a=4*r,o=n[r];t[a]=o.time;var s=o.color;e===n4.Linear?(t[a+1]=tV.gammaToLinearSpace(s.r),t[a+2]=tV.gammaToLinearSpace(s.g),t[a+3]=tV.gammaToLinearSpace(s.b)):(t[a+1]=s.r,t[a+2]=s.g,t[a+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 i=2*n,a=t[n];e[i]=a.time,e[i+1]=a.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 i=r;--i>=0&&n<e[i].time;);e.splice(i+1,0,t)}},t._removeKey=function(e,t){e.splice(t,1)},t._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},t._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},tW(e,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),e}();tq([t0],sr.prototype,"_colorKeys",void 0),tq([t0],sr.prototype,"_alphaKeys",void 0),tq([tJ],sr.prototype,"_colorTypeArray",void 0),tq([tJ],sr.prototype,"_alphaTypeArray",void 0),tq([tJ],sr.prototype,"_setColorTypeArrayDirty",null),tq([tJ],sr.prototype,"_setAlphaTypeArrayDirty",null);var si=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._color=new tV,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged}return tW(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}(),sa=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._time=e,this._alpha=t}return tW(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}(),so=/*#__PURE__*/function(){function e(e,t){this.mode=st.Constant,this.constantMin=new tV,this.constantMax=new tV,this.gradientMin=new sr,this.gradientMax=new sr,e.constructor===tV?t?(this.constantMin.copyFrom(e),this.constantMax.copyFrom(t),this.mode=st.TwoConstants):(this.constant.copyFrom(e),this.mode=st.Constant):t?(this.gradientMin=e,this.gradientMax=t,this.mode=st.TwoGradients):(this.gradient=e,this.mode=st.Gradient)}return e.prototype.evaluate=function(e,t,n){switch(this.mode){case st.Constant:n.copyFrom(this.constant);break;case st.TwoConstants:tV.lerp(this.constantMin,this.constantMax,t,n)}},tW(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}();tq([t0],so.prototype,"constantMin",void 0),tq([t0],so.prototype,"constantMax",void 0),tq([t0],so.prototype,"gradientMin",void 0),tq([t0],so.prototype,"gradientMax",void 0);var ss=/*#__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},tW(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),e}();tq([tJ],ss.prototype,"_generator",void 0);var sl=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.color=new so(new sr([new si(0,new tV(1,1,1)),new si(1,new tV(1,1,1))],[new sa(0,1),new sa(1,1)])),t._colorGradientRand=new tU(0,sn.ColorOverLifetime),t._gradientKeysCount=new tN(0,0,0,0),t}tX(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.color.mode;if(r!==st.Gradient&&r!==st.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var i=this.color,a=this._generator._renderer.engine.settings.colorSpace;e.setFloatArray(t._maxGradientColor,i.gradientMax._getColorTypeArray(a)),e.setFloatArray(t._maxGradientAlpha,i.gradientMax._getAlphaTypeArray()),r===st.Gradient?n=t._gradientMacro:(e.setFloatArray(t._minGradientColor,i.gradientMin._getColorTypeArray(a)),e.setFloatArray(t._minGradientAlpha,i.gradientMin._getAlphaTypeArray()),n=t._randomGradientsMacro);var o=i.gradientMin.colorKeys,s=i.gradientMin.alphaKeys,l=i.gradientMax.colorKeys,c=i.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,sn.ColorOverLifetime)},t}(ss);sl._gradientMacro=nj.getByName("RENDERER_COL_GRADIENT"),sl._randomGradientsMacro=nj.getByName("RENDERER_COL_RANDOM_GRADIENTS"),sl._minGradientColor=nQ.getByName("renderer_COLMinGradientColor"),sl._minGradientAlpha=nQ.getByName("renderer_COLMinGradientAlpha"),sl._maxGradientColor=nQ.getByName("renderer_COLMaxGradientColor"),sl._maxGradientAlpha=nQ.getByName("renderer_COLMaxGradientAlpha"),sl._gradientKeysCount=nQ.getByName("renderer_COLGradientKeysMaxTime"),tq([t0],sl.prototype,"color",void 0),tq([tJ],sl.prototype,"_colorGradientRand",void 0),tq([tJ],sl.prototype,"_gradientKeysCount",void 0),tq([tJ],sl.prototype,"_colorMacro",void 0);var sc=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nP,this._mode=se.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=se.TwoConstants):(this.constant=e,this.mode=se.Constant):t?(this.curveMin=e,this.curveMax=t,this.mode=se.TwoCurves):(this.curve=e,this.mode=se.Curve)}var t=e.prototype;return t.evaluate=function(e,t){switch(this.mode){case se.Constant:return this.constant;case se.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*t}},t._getMax=function(){switch(this.mode){case se.Constant:return this.constantMax;case se.TwoConstants:return Math.max(this.constantMin,this.constantMax);case se.Curve:var e;return this._getMaxKeyValue(null==(e=this.curveMax)?void 0:e.keys);case se.TwoCurves:var t,n,r=this._getMaxKeyValue(null==(t=this.curveMin)?void 0:t.keys),i=this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys);return r>i?r:i}},t._getMinMax=function(e){switch(this.mode){case se.Constant:e.x=e.y=this.constantMax;break;case se.TwoConstants:e.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case se.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 se.TwoCurves:var r,i,a,o,s=this._getMinKeyValue(null==(r=this.curveMax)?void 0:r.keys),l=this._getMinKeyValue(null==(i=this.curveMin)?void 0:i.keys),c=this._getMaxKeyValue(null==(a=this.curveMax)?void 0:a.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 i=1;i<r;i++)n=Math.max(n,e[i].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 i=1;i<r;i++)n=Math.min(n,e[i].value)}return n},t._onCurveChange=function(e,t){var n=this._updateDispatch;null==e||e._unRegisterOnValueChanged(n),null==t||t._registerOnValueChanged(n),n()},tW(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}();tq([tJ],sc.prototype,"_updateManager",void 0),tq([t0],sc.prototype,"_curveMin",void 0),tq([t0],sc.prototype,"_curveMax",void 0),tq([tJ],sc.prototype,"_updateDispatch",void 0);var su=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.rateOverTime=new sc(10),t.rateOverDistance=new sc(0),t._shapeRand=new tU(0,sn.Shape),t._frameRateTime=0,t._bursts=[],t._currentBurstIndex=0,t._burstRand=new tU(0,sn.Burst),t}tX(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,sn.Burst),this._shapeRand.reset(e,sn.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,i=e-this._frameRateTime;i>=r;)i-=r,this._frameRateTime+=r,n._emit(this._frameRateTime,1)},n._emitByBurst=function(e,t){var n=this._generator.main,r=n.duration,i=Math.floor((t-e)/r);if(n.isLoop&&(i>0||t%r<e%r)){var a=Math.ceil(e/r)*r;this._emitBySubBurst(e,a,r),this._currentBurstIndex=0;for(var o=0;o<i;o++){var s=a;a+=r,this._emitBySubBurst(s,a,r),this._currentBurstIndex=0}this._emitBySubBurst(a,t,r)}else this._emitBySubBurst(e,t,r)},n._emitBySubBurst=function(e,t,n){for(var r=this._generator,i=this._burstRand,a=this.bursts,o=Math.floor(e/n)*n,s=e%n,l=s+(t-e),c=this._currentBurstIndex,u=a.length;c<u;c++){var d=a[c],h=d.time;if(h>l)break;if(h>=s){var _=d.count.evaluate(void 0,i.random());r._emit(o+h,_)}}this._currentBurstIndex=c},tW(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}(ss);tq([t0],su.prototype,"rateOverTime",void 0),tq([t0],su.prototype,"rateOverDistance",void 0),tq([t0],su.prototype,"_shape",void 0),tq([tJ],su.prototype,"_shapeRand",void 0),tq([t0],su.prototype,"_bursts",void 0),tq([tJ],su.prototype,"_burstRand",void 0);var sd=((eZ={})[eZ.Hierarchy=0]="Hierarchy",eZ[eZ.Local=1]="Local",eZ[eZ.World=2]="World",eZ),sh=/*#__PURE__*/function(){function e(e){this._tempVector40=new tN,this.duration=5,this.isLoop=!0,this.startDelay=new sc(0),this.startRotation3D=!1,this.startRotationX=new sc(0),this.startRotationY=new sc(0),this.startRotationZ=new sc(0),this.flipRotation=0,this.startColor=new so(new tV(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=sd.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startDelayRand=new tU(0,sn.StartDelay),this._startSpeedRand=new tU(0,sn.StartSpeed),this._startLifeTimeRand=new tU(0,sn.StartLifetime),this._startColorRand=new tU(0,sn.StartColor),this._startSizeRand=new tU(0,sn.StartSize),this._startRotationRand=new tU(0,sn.StartRotation),this._gravityModifierRand=new tU(0,sn.GravityModifier),this._startSize3D=!1,this._simulationSpace=o5.Local,this._generator=e,this.startLifetime=new sc(5),this.startSpeed=new sc(5),this.startSizeX=new sc(1),this.startSizeY=new sc(1),this.startSizeZ=new sc(1),this.gravityModifier=new sc(0)}var t=e.prototype;return t._resetRandomSeed=function(e){this._startSpeedRand.reset(e,sn.StartSpeed),this._startLifeTimeRand.reset(e,sn.StartLifetime),this._startColorRand.reset(e,sn.StartColor),this._startSizeRand.reset(e,sn.StartSize),this._startRotationRand.reset(e,sn.StartRotation)},t._getPositionScale=function(){var e=this._generator._renderer.entity.transform;switch(this.scalingMode){case sd.Hierarchy:case sd.World:return e.lossyWorldScale;case sd.Local:return e.scale}},t._updateShaderData=function(t){var n=this._generator._renderer,r=n.entity.transform;switch(this.simulationSpace){case o5.Local:t.setVector3(e._worldPosition,r.worldPosition);var i=r.worldRotationQuaternion,a=this._tempVector40.copyFrom(i);t.setVector4(e._worldRotation,a);break;case o5.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case sd.Hierarchy:var o=r.lossyWorldScale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case sd.Local:var o=r.scale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case sd.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===o5.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()},tW(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(rv.WorldMatrix),e===o5.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}();sh._vector3One=new tR(1,1,1),sh._positionScale=nQ.getByName("renderer_PositionScale"),sh._sizeScale=nQ.getByName("renderer_SizeScale"),sh._worldPosition=nQ.getByName("renderer_WorldPosition"),sh._worldRotation=nQ.getByName("renderer_WorldRotation"),sh._gravity=nQ.getByName("renderer_Gravity"),sh._simulationSpace=nQ.getByName("renderer_SimulationSpace"),sh._startRotation3D=nQ.getByName("renderer_ThreeDStartRotation"),sh._scaleMode=nQ.getByName("renderer_ScalingMode"),tq([t0],sh.prototype,"startDelay",void 0),tq([t0],sh.prototype,"startRotationX",void 0),tq([t0],sh.prototype,"startRotationY",void 0),tq([t0],sh.prototype,"startRotationZ",void 0),tq([t0],sh.prototype,"startColor",void 0),tq([tJ],sh.prototype,"_maxParticleBuffer",void 0),tq([tJ],sh.prototype,"_startDelayRand",void 0),tq([tJ],sh.prototype,"_startSpeedRand",void 0),tq([tJ],sh.prototype,"_startLifeTimeRand",void 0),tq([tJ],sh.prototype,"_startColorRand",void 0),tq([tJ],sh.prototype,"_startSizeRand",void 0),tq([tJ],sh.prototype,"_startRotationRand",void 0),tq([tJ],sh.prototype,"_gravityModifierRand",void 0),tq([t0],sh.prototype,"_startLifetime",void 0),tq([t0],sh.prototype,"_startSpeed",void 0),tq([t0],sh.prototype,"_startSizeX",void 0),tq([t0],sh.prototype,"_startSizeY",void 0),tq([t0],sh.prototype,"_startSizeZ",void 0),tq([t0],sh.prototype,"_gravityModifier",void 0),tq([tJ],sh.prototype,"_generator",void 0);var s_=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new sc(0),t.rotationY=new sc(0),t.rotationZ=new sc(45),t._rotationRand=new tU(0,sn.RotationOverLifetime),t._rotationMinConstant=new tR,t._rotationMaxConstant=new tR,t}tX(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,i=null;if(this.enabled){var a=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?a.mode===se.TwoCurves&&o.mode===se.TwoCurves&&s.mode===se.TwoCurves:s.mode===se.TwoCurves;if(c||l?a.mode===se.Curve&&o.mode===se.Curve&&s.mode===se.Curve:s.mode===se.Curve)e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveXProperty,a.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveXProperty,a.curveMin._getTypeArray()),e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray())),i=t._isRandomTwoMacro),r=t._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(tA.degreeToRadian(a.constantMax),tA.degreeToRadian(o.constantMax),tA.degreeToRadian(s.constantMax)),e.setVector3(t._maxConstantProperty,u),l?a.mode===se.TwoConstants&&o.mode===se.TwoConstants&&s.mode===se.TwoConstants:s.mode===se.TwoConstants){var d=this._rotationMinConstant;d.set(tA.degreeToRadian(a.constantMin),tA.degreeToRadian(o.constantMin),tA.degreeToRadian(s.constantMin)),e.setVector3(t._minConstantProperty,d),i=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,i)},n._resetRandomSeed=function(e){this._rotationRand.reset(e,sn.RotationOverLifetime)},t}(ss);s_._constantModeMacro=nj.getByName("RENDERER_ROL_CONSTANT_MODE"),s_._curveModeMacro=nj.getByName("RENDERER_ROL_CURVE_MODE"),s_._isSeparateMacro=nj.getByName("RENDERER_ROL_IS_SEPARATE"),s_._isRandomTwoMacro=nj.getByName("RENDERER_ROL_IS_RANDOM_TWO"),s_._minConstantProperty=nQ.getByName("renderer_ROLMinConst"),s_._minCurveXProperty=nQ.getByName("renderer_ROLMinCurveX"),s_._minCurveYProperty=nQ.getByName("renderer_ROLMinCurveY"),s_._minCurveZProperty=nQ.getByName("renderer_ROLMinCurveZ"),s_._maxConstantProperty=nQ.getByName("renderer_ROLMaxConst"),s_._maxCurveXProperty=nQ.getByName("renderer_ROLMaxCurveX"),s_._maxCurveYProperty=nQ.getByName("renderer_ROLMaxCurveY"),s_._maxCurveZProperty=nQ.getByName("renderer_ROLMaxCurveZ"),tq([t0],s_.prototype,"rotationX",void 0),tq([t0],s_.prototype,"rotationY",void 0),tq([t0],s_.prototype,"rotationZ",void 0),tq([tJ],s_.prototype,"_rotationRand",void 0),tq([tJ],s_.prototype,"_rotationMinConstant",void 0),tq([tJ],s_.prototype,"_rotationMaxConstant",void 0),tq([tJ],s_.prototype,"_enableSeparateMacro",void 0),tq([tJ],s_.prototype,"_isCurveMacro",void 0),tq([tJ],s_.prototype,"_isRandomTwoMacro",void 0);var sf=/*#__PURE__*/function(){function e(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._updateManager=new nP,this._keys=[],this._typeArrayDirty=!1,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager);for(var r=0,i=t.length;r<i;r++){var a=t[r];this.addKey(a)}}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 sp(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 i=2*n,a=t[n];e[i]=a.time,e[i+1]=a.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 i=n;--i>=0&&r<e[i].time;);e.splice(i+1,0,t)}},tW(e,[{key:"keys",get:function(){return this._keys}}]),e}();tq([tJ],sf.prototype,"_updateManager",void 0),tq([t0],sf.prototype,"_keys",void 0),tq([tJ],sf.prototype,"_typeArray",void 0),tq([tJ],sf.prototype,"_updateDispatch",void 0);var sp=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nP,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)},tW(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}();tq([tJ],sp.prototype,"_updateManager",void 0);var sm=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._separateAxes=!1,n.sizeX=new sc(new sf(new sp(0,0),new sp(1,1))),n.sizeY=new sc(new sf(new sp(0,0),new sp(1,1))),n.sizeZ=new sc(new sf(new sp(0,0),new sp(1,1))),n}tX(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,i=null;if(this.enabled){var a=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?a.mode===se.TwoCurves&&o.mode===se.TwoCurves&&s.mode===se.TwoCurves:a.mode===se.TwoCurves;(c||l?a.mode===se.Curve&&o.mode===se.Curve&&s.mode===se.Curve:a.mode===se.Curve)&&(e.setFloatArray(t._maxCurveXProperty,a.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveXProperty,a.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray()),e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray())),i=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,i)},n._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tW(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}(ss);sm._curveModeMacro=nj.getByName("RENDERER_SOL_CURVE_MODE"),sm._isSeparateMacro=nj.getByName("RENDERER_SOL_IS_SEPARATE"),sm._isRandomTwoMacro=nj.getByName("RENDERER_SOL_IS_RANDOM_TWO"),sm._minCurveXProperty=nQ.getByName("renderer_SOLMinCurveX"),sm._minCurveYProperty=nQ.getByName("renderer_SOLMinCurveY"),sm._minCurveZProperty=nQ.getByName("renderer_SOLMinCurveZ"),sm._maxCurveXProperty=nQ.getByName("renderer_SOLMaxCurveX"),sm._maxCurveYProperty=nQ.getByName("renderer_SOLMaxCurveY"),sm._maxCurveZProperty=nQ.getByName("renderer_SOLMaxCurveZ"),tq([t0],sm.prototype,"_sizeX",void 0),tq([t0],sm.prototype,"_sizeY",void 0),tq([t0],sm.prototype,"_sizeZ",void 0),tq([tJ],sm.prototype,"_enableSeparateMacro",void 0),tq([tJ],sm.prototype,"_isCurveMacro",void 0),tq([tJ],sm.prototype,"_isRandomTwoMacro",void 0);var sg=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.frameOverTime=new sc(new sf(new sp(0,0),new sp(1,1))),t.type=0,t.cycleCount=1,t._tillingInfo=new tR(1,1,1),t._frameOverTimeRand=new tU(0,sn.TextureSheetAnimation),t._tiling=new tO(1,1),t}tX(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.frameOverTime.mode;if(r===se.Curve||r===se.TwoCurves){var i=this.frameOverTime;e.setFloatArray(t._frameMaxCurveProperty,i.curveMax._getTypeArray()),r===se.Curve?n=t._frameCurveMacro:(e.setFloatArray(t._frameMinCurveProperty,i.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,sn.TextureSheetAnimation)},tW(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}(ss);sg._frameCurveMacro=nj.getByName("RENDERER_TSA_FRAME_CURVE"),sg._frameRandomCurvesMacro=nj.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),sg._frameMinCurveProperty=nQ.getByName("renderer_TSAFrameMinCurve"),sg._frameMaxCurveProperty=nQ.getByName("renderer_TSAFrameMaxCurve"),sg._cycleCountProperty=nQ.getByName("renderer_TSACycles"),sg._tillingParamsProperty=nQ.getByName("renderer_TSATillingParams"),tq([t0],sg.prototype,"frameOverTime",void 0),tq([t$],sg.prototype,"_tillingInfo",void 0),tq([tJ],sg.prototype,"_frameOverTimeRand",void 0),tq([t0],sg.prototype,"_tiling",void 0),tq([tJ],sg.prototype,"_frameCurveMacro",void 0);var sv=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._velocityRand=new tU(0,sn.VelocityOverLifetime),n._velocityMinConstant=new tR,n._velocityMaxConstant=new tR,n._space=o5.Local,n.velocityX=new sc(0),n.velocityY=new sc(0),n.velocityZ=new sc(0),n}tX(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.velocityX,i=this.velocityY,a=this.velocityZ,o=r.mode===se.TwoCurves&&i.mode===se.TwoCurves&&a.mode===se.TwoCurves;if(o||r.mode===se.Curve&&i.mode===se.Curve&&a.mode===se.Curve)e.setFloatArray(t._maxGradientXProperty,r.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientYProperty,i.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientZProperty,a.curveMax._getTypeArray()),o?(e.setFloatArray(t._minGradientXProperty,r.curveMin._getTypeArray()),e.setFloatArray(t._minGradientYProperty,i.curveMin._getTypeArray()),e.setFloatArray(t._minGradientZProperty,a.curveMin._getTypeArray()),n=t._randomCurveMacro):n=t._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(r.constantMax,i.constantMax,a.constantMax),e.setVector3(t._maxConstantProperty,s),r.mode===se.TwoConstants&&i.mode===se.TwoConstants&&a.mode===se.TwoConstants){var l=this._velocityMinConstant;l.set(r.constantMin,i.constantMin,a.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,sn.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()},tW(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}(ss);sv._constantMacro=nj.getByName("RENDERER_VOL_CONSTANT"),sv._curveMacro=nj.getByName("RENDERER_VOL_CURVE"),sv._randomConstantMacro=nj.getByName("RENDERER_VOL_RANDOM_CONSTANT"),sv._randomCurveMacro=nj.getByName("RENDERER_VOL_RANDOM_CURVE"),sv._minConstantProperty=nQ.getByName("renderer_VOLMinConst"),sv._maxConstantProperty=nQ.getByName("renderer_VOLMaxConst"),sv._minGradientXProperty=nQ.getByName("renderer_VOLMinGradientX"),sv._minGradientYProperty=nQ.getByName("renderer_VOLMinGradientY"),sv._minGradientZProperty=nQ.getByName("renderer_VOLMinGradientZ"),sv._maxGradientXProperty=nQ.getByName("renderer_VOLMaxGradientX"),sv._maxGradientYProperty=nQ.getByName("renderer_VOLMaxGradientY"),sv._maxGradientZProperty=nQ.getByName("renderer_VOLMaxGradientZ"),sv._spaceProperty=nQ.getByName("renderer_VOLSpace"),tq([tJ],sv.prototype,"_velocityRand",void 0),tq([tJ],sv.prototype,"_velocityMinConstant",void 0),tq([tJ],sv.prototype,"_velocityMaxConstant",void 0),tq([tJ],sv.prototype,"_velocityMacro",void 0),tq([t0],sv.prototype,"_velocityX",void 0),tq([t0],sv.prototype,"_velocityY",void 0),tq([t0],sv.prototype,"_velocityZ",void 0);var sy=/*#__PURE__*/function(){function e(t){this.useAutoRandomSeed=!0,this.emission=new su(this),this.rotationOverLifetime=new s_(this),this.colorOverLifetime=new sl(this),this.textureSheetAnimation=new sg(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new iA(0,0,is.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 iT().start=0,this._primitive=new iR(t.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,e._particleIncreaseCount),this.main=new sh(this),this.velocityOverLifetime=new sv(this),this.sizeOverLifetime=new sm(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(o6,e._tempParticleRenderers),r=0,i=n.length;r<i;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=o9.StopEmitting),t)for(var r=this._renderer.entity.getComponentsIncludeChildren(o6,e._tempParticleRenderers),i=0,a=r.length;i<a;i++)r[i].generator.stop(!1,n);else if(this._isPlaying=!1,n===o9.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,i=e._tempVector31,a=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,i);var l=this.main._getPositionScale();r.multiply(l),i.normalize().multiply(l)}else r.set(0,0,0),i.set(0,0,-1);this._addNewParticle(r,i,a,t)}},t._update=function(e){var t=this.isAlive,n=this.main,r=this.emission,i=n.duration,a=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===o5.World&&this._retireTransformedBounds(),r.enabled&&this._isPlaying&&(this._currentParticleCount>n._maxParticleBuffer&&this._getNotRetiredParticleCount()<n._maxParticleBuffer&&this._resizeInstanceBuffer(!1),r._emit(a,this._playTime),!n.isLoop&&this._playTime>i&&(this._isPlaying=!1)),this.isAlive)n.simulationSpace===o5.World&&this._generateTransformedBounds();else{var l=Math.min(r._frameRateTime,Math.floor(this._playTime/i)*i);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===o8.Mesh){var i=e.mesh;if(!i)return;var a=i.getVertexElement(iD.Position),o=i.getVertexElement(iD.Color),s=i.getVertexElement(iD.UV),l=a?i.vertexBufferBindings[a.bindingIndex]:null,c=o?i.vertexBufferBindings[o.bindingIndex]:null,u=s?i.vertexBufferBindings[s.bindingIndex]:null;if(l){var d=this._addVertexBufferBindingsFilterDuplicate(l,r);n.addVertexElement(new ia(iD.Position,a.offset,a.format,d))}if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,r);n.addVertexElement(new ia(iD.Color,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,r);n.addVertexElement(new ia(iD.UV,s.offset,s.format,_))}var f=i._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=aQ.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 ia(y.attribute,y.offset,y.format,m,y.instanceStepRate))}},t._resizeInstanceBuffer=function(e,t){null==(u=this._instanceVertexBufferBinding)||u.buffer.destroy();var n=aQ.instanceVertexStride,r=e?this._currentParticleCount+t:this.main._maxParticleBuffer,i=n*r,a=new ie(this._renderer.engine,io.VertexBuffer,i,r6.Dynamic,!1);a.isGCIgnored=!0;var o=this._primitive.vertexBufferBindings,s=new iw(a,n),l=new Float32Array(i/4),c=this._instanceVertices;if(c){var u,d,h,_=aQ.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,i=t._transformedBounds;t._isContainDirtyFlag(o7.GeneratorVolume)&&(this._calculateGeneratorBounds(n,r),t._setDirtyFlagFalse(o7.GeneratorVolume)),t._isContainDirtyFlag(o7.TransformVolume)&&(this._calculateTransformedBounds(n,r,i),t._setDirtyFlagFalse(o7.TransformVolume)),this._addGravityToBounds(n,i,e)},t._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,n=this._firstActiveTransformedBoundingBox,r=this._firstFreeTransformedBoundingBox,i=n*aQ.boundsFloatStride;if(e.min.copyFromArray(t,i),e.max.copyFromArray(t,i+3),n<r)for(var a=n+1;a<r;a++)this._mergeTransformedBounds(a,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(o7.GeneratorVolume)&&(this._calculateGeneratorBounds(t,n),e._setDirtyFlagFalse(o7.GeneratorVolume));var r=aQ.boundsFloatStride,i=aQ.boundsTimeOffset,a=aQ.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(o7.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+i]=this._playTime,u[c+a]=t,this._firstFreeTransformedBoundingBox=s,e._setDirtyFlagFalse(o7.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*aQ.boundsFloatStride+i]=this._playTime}},t._addNewParticle=function(t,n,r,i){var a,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===o5.World&&(a=r.worldPosition,o=r.worldRotationQuaternion);var d=c.startSpeed.evaluate(void 0,c._startSpeedRand.random()),h=this._instanceVertices,_=s*aQ.instanceVertexFloatStride;h[_]=t.x,h[_+1]=t.y,h[_+2]=t.z,h[_+aQ.startLifeTimeOffset]=c.startLifetime.evaluate(void 0,c._startLifeTimeRand.random()),h[_+4]=n.x,h[_+5]=n.y,h[_+6]=n.z,h[_+aQ.timeOffset]=i;var f=e._tempColor0;c.startColor.evaluate(void 0,c._startColorRand.random(),f),this._renderer.engine.settings.colorSpace===n4.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]=tA.degreeToRadian(c.startRotationX.evaluate(void 0,g.random())),h[_+16]=tA.degreeToRadian(c.startRotationY.evaluate(void 0,g.random())),h[_+17]=tA.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random()))):h[_+15]=tA.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random())),h[_+18]=d,c.gravityModifier.mode){case se.Constant:h[_+19]=c.gravityModifier.constant;break;case se.TwoConstants:h[_+19]=c.gravityModifier.evaluate(void 0,c._gravityModifierRand.random())}var v=this.colorOverLifetime;v.enabled&&v.color.mode===st.TwoGradients&&(h[_+20]=v._colorGradientRand.random());var y=this.rotationOverLifetime;y.enabled&&y.rotationZ.mode===se.TwoConstants&&(h[_+22]=y._rotationRand.random());var x=this.textureSheetAnimation;x.enabled&&x.frameOverTime.mode===se.TwoCurves&&(h[_+23]=x._frameOverTimeRand.random());var b=this.velocityOverLifetime;if(b.enabled&&b.velocityX.mode===se.TwoConstants&&b.velocityY.mode===se.TwoConstants&&b.velocityZ.mode===se.TwoConstants){var C=b._velocityRand;h[_+24]=C.random(),h[_+25]=C.random(),h[_+26]=C.random()}if(this.main.simulationSpace===o5.World&&(h[_+27]=a.x,h[_+28]=a.y,h[_+29]=a.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,R=T.y,E=T.z,M=0;(S.mode===se.Constant||S.mode===se.TwoConstants)&&(M=Math.floor(S.evaluate(void 0,x._frameOverTimeRand.random())*E)*A);var w=Math.floor(M);h[_+aQ.simulationUVOffset]=A,h[_+35]=R,h[_+36]=M-w,h[_+37]=w*R}else h[_+aQ.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*aQ.instanceVertexFloatStride,r=n+aQ.timeOffset;if(Math.fround(this._playTime-t[r])<t[n+aQ.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*aQ.instanceVertexFloatStride+aQ.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=aQ.instanceVertexStride,r=e*n,i=this._instanceVertexBufferBinding.buffer,a=this._instanceVertices.buffer;if(e<t)i.setData(a,0,r,(t-e)*n,r7.Discard);else{var o=(this._currentParticleCount-e)*n;i.setData(a,0,r,o,r7.Discard),t>0&&i.setData(a,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=aQ.boundsFloatStride,n=e._transformedBoundsIncreaseCount;this._transformedBoundsCount+=n;var r=this._transformedBoundsArray,i=new Float32Array(this._transformedBoundsCount*t);if(r){var a=this._firstFreeTransformedBoundingBox;i.set(new Float32Array(r.buffer,0,a*t));var o=a+1;i.set(new Float32Array(r.buffer,o*t*4),(o+n)*t),this._firstActiveTransformedBoundingBox>a&&(this._firstActiveTransformedBoundingBox+=n)}this._transformedBoundsArray=i},t._retireTransformedBounds=function(){for(var e=aQ.boundsFloatStride,t=aQ.boundsTimeOffset,n=aQ.boundsMaxLifetimeOffset,r=this._transformedBoundsArray,i=this._firstFreeTransformedBoundingBox,a=this._transformedBoundsCount;this._firstActiveTransformedBoundingBox!==i;){var o=this._firstActiveTransformedBoundingBox*e;if(this._playTime-r[o+t]<=r[o+n])break;++this._firstActiveTransformedBoundingBox>=a&&(this._firstActiveTransformedBoundingBox=0),this._renderer._onWorldVolumeChanged()}},t._calculateGeneratorBounds=function(t,n){var r=e._tempVector30,i=e._tempVector31,a=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(i,r)):(o.set(0,0,0),s.set(0,0,0),i.set(0,0,-1),r.set(0,0,0)),this._getExtremeValueFromZero(l.startSpeed,a);var u=a.x,d=a.y,h=i.x,_=i.y,f=i.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===o8.Billboard||o8.StretchBillboard||o8.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,i=this._transformedBoundsArray,a=e*aQ.boundsFloatStride;n.set(Math.min(n.x,i[a]),Math.min(n.y,i[a+1]),Math.min(n.z,i[a+2])),r.set(Math.max(r.x,i[a+3]),Math.max(r.y,i[a+4]),Math.max(r.z,i[a+5]))},t._calculateTransformedBounds=function(t,n,r){var i=e._tempVector20,a=e._tempVector21,o=e._tempVector22,s=e._tempMat,l=this._renderer.entity.transform,c=l.worldPosition;tB.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,i),this._getExtremeValueFromZero(f.velocityY,a),this._getExtremeValueFromZero(f.velocityZ,o),f.space===o5.Local?(h.set(u.x+i.x*t,u.y+a.x*t,u.z+o.x*t),_.set(d.x+i.y*t,d.y+a.y*t,d.z+o.y*t),r.transform(s)):(r.transform(s),h.set(u.x+i.x*t,u.y+a.x*t,u.z+o.x*t),_.set(d.x+i.y*t,d.y+a.y*t,d.z+o.y*t))):tM.transform(n,s,r),h.add(c),_.add(c)},t._addGravityToBounds=function(t,n,r){var i=n.min,a=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)+i.x,Math.min(m,g)+i.y,Math.min(v,y)+i.z),r.max.set(Math.max(f,p)+a.x,Math.max(m,g)+a.y,Math.max(v,y)+a.z)},t._getExtremeValueFromZero=function(e,t){e._getMinMax(t),t.x=Math.min(0,t.x),t.y=Math.max(0,t.y)},tW(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}();sy._tempVector20=new tO,sy._tempVector21=new tO,sy._tempVector22=new tO,sy._tempVector30=new tR,sy._tempVector31=new tR,sy._tempMat=new tB,sy._tempColor0=new tV,sy._tempParticleRenderers=[],sy._particleIncreaseCount=128,sy._transformedBoundsIncreaseCount=16,tq([t0],sy.prototype,"main",void 0),tq([t0],sy.prototype,"emission",void 0),tq([t0],sy.prototype,"velocityOverLifetime",void 0),tq([t0],sy.prototype,"sizeOverLifetime",void 0),tq([t0],sy.prototype,"rotationOverLifetime",void 0),tq([t0],sy.prototype,"colorOverLifetime",void 0),tq([t0],sy.prototype,"textureSheetAnimation",void 0),tq([tJ],sy.prototype,"_playTime",void 0),tq([tJ],sy.prototype,"_firstNewElement",void 0),tq([tJ],sy.prototype,"_firstActiveElement",void 0),tq([tJ],sy.prototype,"_firstFreeElement",void 0),tq([tJ],sy.prototype,"_firstRetiredElement",void 0),tq([tJ],sy.prototype,"_primitive",void 0),tq([tJ],sy.prototype,"_vertexBufferBindings",void 0),tq([tJ],sy.prototype,"_subPrimitive",void 0),tq([tJ],sy.prototype,"_renderer",void 0),tq([tJ],sy.prototype,"_isPlaying",void 0),tq([tJ],sy.prototype,"_instanceBufferResized",void 0),tq([tJ],sy.prototype,"_waitProcessRetiredElementCount",void 0),tq([tJ],sy.prototype,"_instanceVertexBufferBinding",void 0),tq([tJ],sy.prototype,"_instanceVertices",void 0),tq([tJ],sy.prototype,"_transformedBoundsArray",void 0),tq([tJ],sy.prototype,"_transformedBoundsCount",void 0),tq([tJ],sy.prototype,"_firstActiveTransformedBoundingBox",void 0),tq([tJ],sy.prototype,"_firstFreeTransformedBoundingBox",void 0),tq([tJ],sy.prototype,"_playStartDelay",void 0);var sx=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,rl.find("particle-shader"))||this).shaderData.setColor(id._baseColorProp,new tV(1,1,1,1)),n.isTransparent=!0,n}return tX(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tW(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(id._baseColorProp)},set:function(e){var t=this.shaderData.getColor(id._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(id._baseTextureProp)},set:function(e){this.shaderData.setTexture(id._baseTextureProp,e),e?this.shaderData.enableMacro(id._baseTextureMacro):this.shaderData.disableMacro(id._baseTextureMacro)}}]),t}(id),sb=function(e,t){this.time=e,this.count=t};tq([t0],sb.prototype,"count",void 0);var sC=/*#__PURE__*/function(){function e(){this._updateManager=new nP,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)},tW(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}();tq([tJ],sC.prototype,"_updateManager",void 0);var sS=/*#__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 i=Math.sqrt(r.random());n.x=n.x*i,n.y=n.y*i},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,i=Math.sqrt(1-n*n);e.x=i*Math.cos(r),e.y=i*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}(),sT=((e$={})[e$.Box=0]="Box",e$[e$.Circle=1]="Circle",e$[e$.Cone=2]="Cone",e$[e$.Hemisphere=3]="Hemisphere",e$[e$.Sphere=4]="Sphere",e$),sA=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).shapeType=sT.Box,t._size=new tR(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t}tX(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){sS._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=t._tempVector30;a.set(0,0,-1),sS._randomPointUnitSphere(i,e),tR.lerp(a,i,this.randomDirectionAmount,i)},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 i=Math.cos(n);e.set(-1,-1,-1),t.set(1,1,-i)}},n._getPositionRange=function(e,t){var n=this._size,r=n.x,i=n.y,a=n.z;e.set(-(.5*r),-(.5*i),-(.5*a)),t.set(.5*r,.5*i,.5*a)},tW(t,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),t}(sC);sA._tempVector30=new tR,tq([t0],sA.prototype,"_size",void 0);var sR=((e0={})[e0.Random=0]="Random",e0[e0.Loop=1]="Loop",e0),sE=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sT.Circle,t._radius=1,t._arc=360,t._arcMode=sR.Random,t._arcSpeed=1,t}tX(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){var a=t._tempPositionPoint;switch(this.arcMode){case sR.Loop:var o=n*this.arcSpeed*(360/this.arc)%1,s=tA.degreeToRadian(this.arc*o);a.set(Math.cos(s),Math.sin(s)),a.scale(e.random());break;case sR.Random:sS.randomPointInsideUnitArcCircle(tA.degreeToRadian(this.arc),a,e)}r.set(a.x,a.y,0),r.scale(this.radius),sS._randomPointUnitSphere(i,e),tR.lerp(r,i,this.randomDirectionAmount,i)},n._getDirectionRange=function(e,t){var n=this.randomDirectionAmount>.5?1:Math.sin(this.randomDirectionAmount*Math.PI),r=.5*(360-this._arc)*this.randomDirectionAmount,i=r>90?-1:-Math.sin(r);this._getUnitArcRange(this._arc+r,e,t,i,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,i){var a=tA.degreeToRadian(e),o=Math.sin(a),s=Math.cos(a);e<90?(t.set(0,r,-i),n.set(1,o,i)):(e<180?t.set(s,r,-i):e<270?t.set(-1,Math.min(o,r),-i):t.set(-1,-1,-i),n.set(1,1,i))},tW(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}(sC);sE._tempPositionPoint=new tO;var sM=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sT.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t}tX(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){var a=t._tempVector20,o=tA.degreeToRadian(this.angle),s=Math.sin(o),l=Math.cos(o);switch(this.emitType){case 0:sS.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var c=t._tempVector21;sS.randomPointInsideUnitCircle(c,e),tO.lerp(a,c,this.randomDirectionAmount,c),i.set(c.x*s,c.y*s,-l);break;case 1:sS.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0),i.set(a.x*s,a.y*s,-l),i.normalize();var u=t._tempVector30;tR.scale(i,this.length*e.random(),u),r.add(u);var d=t._tempVector31;sS._randomPointUnitSphere(d,e),tR.lerp(i,d,this.randomDirectionAmount,i)}},n._getDirectionRange=function(e,t){var n=0;switch(this.emitType){case 0:n=tA.degreeToRadian(this._angle);break;case 1:n=Math.sin(tA.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,i=Math.sin(tA.degreeToRadian(this._angle));e.set(-n-i*r,-n-i*r,-r),t.set(n+i*r,n+i*r,0)}},tW(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}(sC);sM._tempVector20=new tO,sM._tempVector21=new tO,sM._tempVector30=new tR,sM._tempVector31=new tR;var sw=((e1={})[e1.Base=0]="Base",e1[e1.Volume=1]="Volume",e1),sP=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sT.Hemisphere,t._radius=1,t}tX(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sS._randomPointInsideUnitSphere(n,e),n.scale(this.radius);var i=n.z;i>0&&(n.z=-i),sS._randomPointUnitSphere(r,e),tR.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)},tW(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(sC),sF=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sT.Sphere,t._radius=1,t}tX(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sS._randomPointInsideUnitSphere(n,e),n.scale(this.radius),sS._randomPointUnitSphere(r,e),tR.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)},tW(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(sC);rl.create("trail","#define GLSLIFY 1\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\n\nvarying vec2 v_uv;\n\nuniform mat4 camera_ProjMat;\nuniform mat4 camera_ViewMat;\n\nvoid main() {\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4( POSITION, 1.0 );\n v_uv = TEXCOORD_0;\n\n}\n","#define GLSLIFY 1\nvarying vec2 v_uv;\n\nuniform sampler2D u_texture;\n\nvoid main(void) {\n\n gl_FragColor = texture2D(u_texture, v_uv);\n\n}\n");var sL=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t,rl.find("trail"))||this).renderState.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=r.sourceAlphaBlendFactor=nD.SourceAlpha,r.destinationColorBlendFactor=r.destinationAlphaBlendFactor=nD.One,n.renderState.depthState.writeEnabled=!1,n}return tX(t,e),t}(iu),sD=new tR,sB=/*#__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,i=0;i<r._maxPointNum;i++)r._points.push(new tR),r._pointStates.push(r._lifetime),r._strapPoints.push(new tR),r._strapPoints.push(new tR);r._curPointNum=0;var a=n.material||new sL(r.engine);return r.setMaterial(a),r.setTexture(n.texture),r._initGeometry(),r}tX(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 i=!0;if(this._curPointNum===this._maxPointNum)i=!1;else if(this._curPointNum>0){var a=this._points[this._points.length-1];tR.distance(this.entity.transform.worldPosition,a)<this._minSeg&&(i=!1)}i&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},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 iP(this._entity.engine),t=2*this._maxPointNum,n=20*t,r=new Float32Array(n),i=[new ia("POSITION",0,ir.Vector3,0),new ia("TEXCOORD_0",12,ir.Vector2,0)],a=new ie(this.engine,4*n,r6.Dynamic);e.setVertexBufferBinding(a,20),e.setVertexElements(i),e.addSubMesh(0,t,is.TriangleStrip),this._vertexBuffer=a,this._vertexStride=20,this._vertices=r,this.mesh=e},n._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new tR(n[0],n[4],n[8]),i=new tR(n[1],n[5],n[9]),a=new tR(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new tR,l=new tR,c=new tD;tR.transformByQuat(r,c,r),tR.transformByQuat(i,c,i);var u=new tR,d=new tR,h=new tR;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?tR.subtract(p,t[f-1],h):tR.subtract(t[f+1],p,h),this._projectOnPlane(h,a,h),h.normalize();var m=Math.acos(tR.dot(r,h));tR.cross(r,h,d),0>=tR.dot(d,a)&&(m=2*Math.PI-m),tD.rotationAxisAngle(a,m,c),tR.transformByQuat(i,c,u),tR.add(p,u,s),tR.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 i=1-r*t,a=2*r*this._vertexStride/4,o=(2*r+1)*this._vertexStride/4;n[a]=0,n[a+1]=i,n[o]=1,n[o+1]=i}}},n._projectOnVector=function(e,t,n){var r=t.clone();tR.normalize(r,r);var i=tR.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},n._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,sD),tR.subtract(e,sD,n)},t}(iF),sI=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.probeLayer=rM.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t}tX(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 nu(this.engine,this.width,this.height,this._isCube?new n_(this.engine,this.width):new nd(this.engine,this.width,this.height),t8.Depth,this.antiAliasing),this._renderTargetSwap=new nu(this.engine,this.width,this.height,this._isCube?new n_(this.engine,this.width):new nd(this.engine,this.width,this.height),t8.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)},tW(t,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),t}(oy),sO=new tR,sN=new tR,sV=new tR,sk=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.position=new tR(0,0,0),t._isCube=!0,t.oriViewMatrix=new tB,t}tX(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(t5.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:sN.set(0,-1,0),sV.set(1,0,0);break;case 1:sN.set(0,-1,0),sV.set(-1,0,0);break;case 2:sN.set(0,0,1),sV.set(0,1,0);break;case 3:sN.set(0,0,-1),sV.set(0,-1,0);break;case 4:sN.set(0,-1,0),sV.set(0,0,1);break;case 5:sN.set(0,-1,0),sV.set(0,0,-1)}tR.add(this.position,sV,sO),tB.lookAt(this.position,sO,sN,t.viewMatrix),t.fieldOfView=90},t}(sI),sz=/*#__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}tX(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},tW(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}(t3),sU=/*#__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}();sU._isResuming=!1;var sG=/*#__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=sU.getContext().createGain(),n._gainNode.connect(sU.getGainNode()),n}tX(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=sU.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=sU.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=sU.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()&&sU.isAudioContextRunning()},tW(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,sU.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?sU.getContext().currentTime-this._playTime:this._pausedTime>0?this._pausedTime-this._playTime:0}}]),t}(rh);tq([tJ],sG.prototype,"_isPlaying",void 0),tq([tJ],sG.prototype,"_clip",void 0),tq([t0],sG.prototype,"_gainNode",void 0),tq([tJ],sG.prototype,"_sourceNode",void 0),tq([t0],sG.prototype,"_pausedTime",void 0),tq([tJ],sG.prototype,"_playTime",void 0),tq([t0],sG.prototype,"_volume",void 0),tq([t0],sG.prototype,"_lastVolume",void 0),tq([t0],sG.prototype,"_playbackRate",void 0),tq([t0],sG.prototype,"_loop",void 0),/*#__PURE__*/(function(){function e(){}return e.registerPolyfill=function(){e._registerMatchAll()},e._registerMatchAll=function(){String.prototype.matchAll||(nl.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,i,a,o,s,l;return function(e,t){var n,r,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=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 i=t.split("g").join(""),a=new RegExp(e.source,i),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(a)];case 2:c.sent(),c.label=3;case 3:return l++,[3,1];case 4:return[2]}})}()})},e})().registerPolyfill();var sH=/*#__PURE__*/Object.freeze({__proto__:null,AmbientLight:ou,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:oP,AnimationClipCurveBinding:oM,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:oL,AnimationEvent:ow,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:oj,AnimatorCondition:ok,AnimatorConditionMode:oD,AnimatorController:oK,AnimatorControllerLayer:oZ,AnimatorControllerParameter:oX,AnimatorCullingMode:oB,AnimatorLayerBlendingMode:oI,AnimatorLayerMask:o1,AnimatorState:oQ,AnimatorStateMachine:oJ,AnimatorStateTransition:oz,AssetPromise:at,AssetType:i6,AudioClip:sz,AudioManager:sU,AudioSource:sG,Background:oa,BackgroundMode:rV,BackgroundTextureFillMode:rk,BaseMaterial:id,BasicRenderPipeline:r1,BlendFactor:nD,BlendMode:il,BlendOperation:nB,BlendShape:iC,BlendShapeFrame:ix,BlendState:rr,BlinnPhongMaterial:ih,Blitter:rj,BloomDownScaleMode:a0,BloomEffect:a1,BoolUpdateFlag:rm,BoxColliderShape:aU,BoxShape:sA,Buffer:ie,BufferBindFlag:io,BufferMesh:iP,BufferUsage:r6,BufferUtil:ii,Burst:sb,get Camera(){return e.Camera},CameraClearFlags:rF,CameraType:rL,Canvas:or,CapsuleColliderShape:aW,CharacterController:aS,CircleShape:sE,ClearableObjectPool:oe,CloneManager:t1,get Collider(){return e.Collider},ColliderShape:az,ColliderShapeUpAxis:aF,Collision:ax,CollisionDetectionMode:aA,ColorOverLifetimeModule:sl,ColorSpace:n4,ColorWriteMask:nI,CompareFunction:nO,Component:rh,ConeEmitType:sw,ConeShape:sM,ContactPoint:ay,ContentRestorer:t4,ControllerCollisionFlag:aL,ControllerNonWalkableMode:aC,CubeProbe:sk,CullMode:nN,CurveKey:sp,DataType:nZ,DependentMode:rp,DepthState:ri,DepthTextureMode:rD,DiffuseMode:oc,DirectLight:oh,DisorderedArray:rT,Downsampling:rB,DynamicCollider:aT,DynamicColliderConstraints:aR,EmissionModule:su,Engine:on,EngineObject:t2,Entity:iQ,EventDispatcher:nY,FixedJoint:aB,FogMode:ol,Font:ny,FontStyle:np,GLCapabilityType:n$,GradientAlphaKey:sa,GradientColorKey:si,HemisphereShape:sP,HingeJoint:aO,HitResult:aE,IndexBufferBinding:iS,IndexFormat:it,InputManager:aK,InterpolationType:oF,get Joint(){return e.Joint},JointLimits:aV,JointMotor:ak,Keyframe:o$,Keys:ag,Layer:rM,LayerPathMask:o0,Light:od,Loader:ox,Logger:nl,MSAASamples:rI,MainModule:sh,Material:iu,Mesh:iE,MeshRenderer:iF,MeshTopology:is,ModelMesh:iB,OverflowMode:nm,PBRBaseMaterial:ip,PBRMaterial:ig,PBRSpecularMaterial:iv,ParticleCompositeCurve:sc,ParticleCompositeGradient:so,ParticleCurve:sf,ParticleCurveMode:se,ParticleGenerator:sy,ParticleGradient:sr,ParticleGradientMode:st,ParticleMaterial:sx,ParticleRenderMode:o8,ParticleRenderer:o6,ParticleScaleMode:sd,ParticleShapeArcMode:sR,ParticleShapeType:sT,ParticleSimulationSpace:o5,ParticleStopMode:o9,PhysicsMaterial:aw,PhysicsMaterialCombineMode:aM,PhysicsScene:ab,PipelineStage:nq,PlaneColliderShape:aH,Platform:tG,PointLight:o_,Pointer:ah,PointerButton:a_,PointerPhase:ad,PostProcess:om,PostProcessEffect:a$,PostProcessEffectParameter:aZ,PostProcessManager:og,PostProcessPass:a8,PostProcessPassEvent:a4,PostProcessUberPass:a5,Primitive:iR,PrimitiveMesh:iX,Probe:sI,RasterState:ra,ReferResource:t3,RefractionMode:im,RenderBufferDepthFormat:t8,RenderFace:ic,RenderQueue:rW,RenderQueueType:nk,RenderState:rs,RenderStateDataKey:nV,RenderTarget:nu,RenderTargetBlendState:rn,get Renderer(){return e.Renderer},ReplacementFailureStrategy:rO,ResourceManager:ao,ReturnableObjectPool:i2,RotationOverLifetimeModule:s_,SafeLoopArray:i7,Scene:ov,SceneManager:ae,Script:oy,SetDataOptions:r7,Shader:rl,ShaderData:rc,ShaderFactory:n1,ShaderLib:n0,ShaderMacro:nj,ShaderMacroCollection:nX,ShaderPass:re,ShaderPlatformTarget:nG,ShaderProperty:nQ,ShaderPropertyType:nz,ShaderTagKey:n2,ShadowCascadesMode:rQ,ShadowResolution:rK,ShadowType:rq,SizeOverLifetimeModule:sm,Skin:iJ,SkinnedMeshRenderer:i$,Sky:oi,SkyBoxMaterial:o2,SkyProceduralMaterial:o4,SphereColliderShape:aG,SphereShape:sF,SpotLight:of,SpringJoint:aN,Sprite:nL,SpriteAtlas:nS,SpriteDrawMode:nT,SpriteMask:r8,SpriteMaskInteraction:nx,SpriteMaskLayer:ry,SpriteRenderer:rR,SpriteTileMode:nA,StateMachineScript:oY,StaticCollider:aP,StencilOperation:nU,StencilState:ro,SubMesh:iA,SubPrimitive:iT,SubShader:rt,SunMode:o3,SystemInfo:am,TextHorizontalAlignment:nb,TextRenderer:r5,TextUtils:ng,TextVerticalAlignment:nC,Texture:nc,Texture2D:nd,Texture2DArray:nh,TextureCoordinate:i_,TextureCube:n_,TextureCubeFace:t5,TextureDepthCompareFunction:t9,TextureFilterMode:t6,TextureFormat:t7,TextureSheetAnimationModule:sg,TextureUsage:ne,TextureWrapMode:nt,Time:nJ,TonemappingEffect:a3,TonemappingMode:a2,TrailMaterial:sL,TrailRenderer:sB,Transform:rg,UnlitMaterial:iy,Utils:nR,VelocityOverLifetimeModule:sv,VertexAttribute:iD,VertexBufferBinding:iw,VertexElement:ia,VertexElementFormat:ir,WrapMode:oU,XRManager:ot,assignmentClone:tZ,deepClone:t0,dependentComponents:rf,ignoreClone:tJ,request:ai,resourceLoader:as,shallowClone:t$}),sW=((e2={})[e2.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",e2[e2.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",e2[e2.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",e2[e2.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",e2[e2.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",e2[e2.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",e2[e2.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",e2[e2.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",e2[e2.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",e2[e2.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",e2[e2.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",e2[e2.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",e2[e2.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",e2[e2.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",e2[e2.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",e2[e2.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",e2[e2.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",e2[e2.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",e2[e2.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",e2[e2.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",e2[e2.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",e2[e2.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",e2[e2.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",e2[e2.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",e2[e2.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",e2[e2.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",e2[e2.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",e2[e2.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",e2[e2.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",e2[e2.R11_EAC=37488]="R11_EAC",e2[e2.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",e2[e2.RG11_EAC=37490]="RG11_EAC",e2[e2.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",e2[e2.RGB8_ETC2=37492]="RGB8_ETC2",e2[e2.SRGB8_ETC2=37493]="SRGB8_ETC2",e2[e2.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e2[e2.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e2[e2.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",e2[e2.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",e2[e2.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",e2[e2.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",e2[e2.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",e2[e2.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",e2[e2.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",e2[e2.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",e2[e2.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",e2[e2.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",e2[e2.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",e2[e2.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",e2[e2.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",e2[e2.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT",e2);function sj(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 sX(e,t,n){return t&&sj(e.prototype,t),n&&sj(e,n),e}function sK(e,t){return(sK=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sq(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&&sK(e,t)}function sY(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var sQ=/*#__PURE__*/function(e){function t(t){(n=e.call(this)||this)._scale=new tO;var n,r=t.width,i=t.height;return n._webCanvas=t,n.width=r,n.height=i,n}sq(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||!sY(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},sX(t,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&sY(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&&sY(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),t}(or),sJ=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sq(t,e),t.create=function(e){var n=e.canvas,r=new t(new sQ("string"==typeof n?document.getElementById(n):n),new le(e.graphicDeviceOptions),e);return r._initialize(e).then(function(){return r.sceneManager.addScene(new ov(r,"DefaultScene")),r})},sX(t,[{key:"canvas",get:function(){return this._canvas}}]),t}(on);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 s$=/*#__PURE__*/function(){function e(e,t,n,r,i){void 0===r&&(r=r6.Static);var a=e.gl,o=a.createBuffer(),s=this._getGLBufferUsage(a,r),l=t===io.VertexBuffer?a.ARRAY_BUFFER:a.ELEMENT_ARRAY_BUFFER;this._gl=a,this._glBuffer=o,this._glBufferUsage=s,this._glBindTarget=l,this._isWebGL2=e.isWebGL2,this.bind(),i?a.bufferData(l,i,s):a.bufferData(l,n,s),a.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,i,a){var o=this._gl,s=this._glBindTarget;this.bind(),a===r7.Discard&&o.bufferData(s,e,this._glBufferUsage);var l=t.BYTES_PER_ELEMENT||1,c=i?l*i: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 i=this._gl;this.bind(),i.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 r6.Static:return e.STATIC_DRAW;case r6.Dynamic:return e.DYNAMIC_DRAW;case r6.Stream:return e.STREAM_DRAW}},e}(),s0=/*#__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,i=sW.SRGB8_ALPHA8_ASTC_12X12_KHR,a=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<=i?this.canIUse(n$.astc):e===a?this.canIUse(n$.etc1):e>=o&&e<=s?this.canIUse(n$.etc):e>=l&&e<=c?this.canIUse(n$.pvrtc):e>=u&&e<=d?this.canIUse(n$.s3tc):!!(e>=h)&&!!(e<=_)&&this.canIUse(n$.bptc)},t._init=function(){var e=this.capabilityList,t=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),r=n$.shaderVertexID,i=n$.standardDerivatives,a=n$.shaderTextureLod,o=n$.elementIndexUint,s=n$.depthTexture,l=n$.vertexArrayObject,c=n$.instancedArrays,u=n$.multipleSample,d=n$.drawBuffers,h=n$.blendMinMax,_=n$.astc,f=n$.astc_webkit,p=n$.etc,m=n$.etc_webkit,g=n$.etc1,v=n$.etc1_webkit,y=n$.pvrtc,x=n$.pvrtc_webkit,b=n$.s3tc,C=n$.s3tc_webkit,S=n$.bptc,T=n$.textureFloat,A=n$.textureHalfFloat,R=n$.textureFloatLinear,E=n$.textureHalfFloatLinear,M=n$.WEBGL_colorBufferFloat,w=n$.colorBufferFloat,P=n$.colorBufferHalfFloat,F=n$.textureFilterAnisotropic,L=n$.fragDepth;e.set(r,t),e.set(i,t||!!n(i)),e.set(a,t||!!n(a)),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(R,!!n(R)),e.set(E,t||!!n(E)),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,i=null;if(i=n.requireExtension(e))for(var a in t){var o=i[t[a]];(null==o?void 0:o.bind)?r[a]=o.bind(i):r[a]=o}},t._compatibleAllInterface=function(){var e=n$.depthTexture,t=n$.vertexArrayObject,n=n$.instancedArrays,r=n$.drawBuffers,i=n$.textureFilterAnisotropic,a=n$.textureHalfFloat,o=n$.colorBufferHalfFloat,s=n$.WEBGL_colorBufferFloat,l=n$.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(n$.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(a,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(o,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(s,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(i,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},sX(e,[{key:"maxTextureSize",get:function(){return this.rhi.renderStates.getParameter(this.rhi.gl.MAX_TEXTURE_SIZE)}},{key:"canUseFloatTextureBlendShape",get:function(){return this.canIUse(n$.shaderVertexID)&&this.canIUse(n$.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(n$.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(n$.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(n$.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(n$.multipleSample);this._maxAntiAliasing=t?e.getParameter(e.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),e}(),s1=/*#__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}(),s2=/*#__PURE__*/function(){function e(e,t){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=t,this._canUseInstancedArrays=e.canIUse(n$.instancedArrays),this._isSupportVAO=e.canIUse(n$.vertexArrayObject),this._gl=e.gl}var t=e.prototype;return t.draw=function(e,t){var n=this._gl,r=this._primitive,i=this._isSupportVAO&&r.enableVAO;if(i){r._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var a=this._vaoMap.get(e.id);n.bindVertexArray(a)}else this._bindBufferAndAttrib(e);var o=r.indexBufferBinding,s=r.instanceCount,l=r._glIndexType,c=r._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(i)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 nl.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(i)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);i?n.bindVertexArray(null):this._disableAttrib()},t.destroy=function(){this._isSupportVAO&&this._clearVAO()},t._bindBufferAndAttrib=function(e){var t,n,r=this._gl,i=this._primitive,a=i.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=i._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var d=a[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 nl.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}(),s3=/*#__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}(),s4=/*#__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,i=r.internalFormat,a=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&&!(a===t.LUMINANCE_ALPHA||a===t.ALPHA)&&d!==ne.Dynamic)t.texStorage2D(this._target,l,i,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,_,i,f,f,0,a,o,null);else if(h)t.texImage2D(this._target,0,i,c,u,0,a,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,i,g,v,0,a,o,null)}},t._getPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),a>0&&!this._isWebGL2&&(a=0,nl.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,a):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,a),s.readPixels(t,n,r,i,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t._setWrapMode=function(t,n){var r=this._gl,i=this._isWebGL2,a=this._target,o=this._texture,s=o.width,l=o.height;switch(i||t===nt.Clamp||e._isPowerOf2(s)&&e._isPowerOf2(l)||(nl.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=nt.Clamp),t){case nt.Clamp:r.texParameteri(a,n,r.CLAMP_TO_EDGE);break;case nt.Repeat:r.texParameteri(a,n,r.REPEAT);break;case nt.Mirror:r.texParameteri(a,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 t7.R8G8B8:return{internalFormat:n?t.RGB8:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t7.R8G8B8A8:return{internalFormat:n?t.RGBA8:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t7.R4G4B4A4:return{internalFormat:n?t.RGBA4:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case t7.R5G5B5A1:return{internalFormat:n?t.RGB5_A1:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case t7.R5G6B5:return{internalFormat:n?t.RGB565:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case t7.Alpha8:return{internalFormat:t.ALPHA,baseFormat:t.ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t7.LuminanceAlpha:return{internalFormat:t.LUMINANCE_ALPHA,baseFormat:t.LUMINANCE_ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t7.R11G11B10_UFloat:return{internalFormat:n?t.R11F_G11F_B10F:t.NONE,baseFormat:t.RGB,dataType:t.FLOAT,isCompressed:!1};case t7.R16G16B16A16:return{internalFormat:n?t.RGBA16F:t.RGBA,baseFormat:t.RGBA,dataType:t.HALF_FLOAT,isCompressed:!1};case t7.R32G32B32A32:return{internalFormat:n?t.RGBA32F:t.RGBA,baseFormat:t.RGBA,dataType:t.FLOAT,isCompressed:!1};case t7.R32G32B32A32_UInt:return{internalFormat:n?t.RGBA32UI:t.NONE,baseFormat:t.RGBA_INTEGER,dataType:t.UNSIGNED_INT,isCompressed:!1};case t7.BC1:return{internalFormat:sW.RGB_S3TC_DXT1_EXT,isCompressed:!0};case t7.BC3:return{internalFormat:sW.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case t7.BC7:return{internalFormat:sW.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case t7.ETC1_RGB:return{internalFormat:sW.RGB_ETC1_WEBGL,isCompressed:!0};case t7.ETC2_RGB:return{internalFormat:sW.RGB8_ETC2,isCompressed:!0};case t7.ETC2_RGBA5:return{internalFormat:sW.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case t7.ETC2_RGBA8:return{internalFormat:sW.RGBA8_ETC2_EAC,isCompressed:!0};case t7.PVRTC_RGB2:return{internalFormat:sW.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case t7.PVRTC_RGBA2:return{internalFormat:sW.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case t7.PVRTC_RGB4:return{internalFormat:sW.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case t7.PVRTC_RGBA4:return{internalFormat:sW.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case t7.ASTC_4x4:return{internalFormat:sW.RGBA_ASTC_4X4_KHR,isCompressed:!0};case t7.ASTC_5x5:return{internalFormat:sW.RGBA_ASTC_5X5_KHR,isCompressed:!0};case t7.ASTC_6x6:return{internalFormat:sW.RGBA_ASTC_6X6_KHR,isCompressed:!0};case t7.ASTC_8x8:return{internalFormat:sW.RGBA_ASTC_8X8_KHR,isCompressed:!0};case t7.ASTC_10x10:return{internalFormat:sW.RGBA_ASTC_10X10_KHR,isCompressed:!0};case t7.ASTC_12x12:return{internalFormat:sW.RGBA_ASTC_12X12_KHR,isCompressed:!0};case t7.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 t7.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 t7.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 t7.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 t7.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t7.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t7.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 t7.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 t7.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 t7.Stencil:return{internalFormat:t.STENCIL_INDEX8,baseFormat:t.STENCIL_ATTACHMENT,dataType:t.UNSIGNED_BYTE,isCompressed:!1,attachment:t.STENCIL_ATTACHMENT};case t7.Depth16:return{internalFormat:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t7.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 t7.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t7.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t7.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 t7.R16G16B16A16:if(!t.canIUse(n$.textureHalfFloat))return!1;break;case t7.R32G32B32A32:if(!t.canIUse(n$.textureFloat))return!1;break;case t7.Depth16:case t7.Depth24Stencil8:case t7.Depth:case t7.DepthStencil:if(!t.canIUse(n$.depthTexture))return!1;break;case t7.R11G11B10_UFloat:case t7.R32G32B32A32_UInt:case t7.Depth24:case t7.Depth32:case t7.Depth32Stencil8:return t.isWebGL2}return!0},e._supportRenderBufferColorFormat=function(e,t){var n=!0;switch(e){case t7.R16G16B16A16:t.canIUse(n$.colorBufferHalfFloat)&&t.canIUse(n$.textureHalfFloat)||(n=!1);break;case t7.R32G32B32A32:t.canIUse(n$.colorBufferFloat)&&t.canIUse(n$.textureFloat)||(n=!1);break;case t7.R11G11B10_UFloat:n=t.isWebGL2}return n},e._supportRenderBufferDepthFormat=function(e,t){if(!t.isWebGL2)switch(e){case t7.Depth24:case t7.Depth32:case t7.Depth32Stencil8:return!1}return!0},sX(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 t6.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 t6.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 t6.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 t9.Never:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NEVER);break;case t9.Less:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LESS);break;case t9.Equal:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.EQUAL);break;case t9.LessEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LEQUAL);break;case t9.Greater:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GREATER);break;case t9.NotEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NOTEQUAL);break;case t9.GreaterEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GEQUAL);break;case t9.Always:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.ALWAYS)}}}]),e}(),s8=/*#__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,i=t.width,a=t.height,o=sY(r,nc),s=0,l=n.length;s<l;s++){var c=n[s]._format;if(!s4._supportRenderBufferColorFormat(c,e))throw Error("TextureFormat is not supported:"+t7[c]+" in RenderTarget")}if(!o&&!s4._supportRenderBufferDepthFormat(r,e))throw Error("TextureFormat is not supported:"+t7[r]+" in RenderTarget");if(n.length>1&&!e.canIUse(n$.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==i||e.height!==a}))throw Error("ColorTexture's size must as same as RenderTarget");if(o&&(r.width!==i||r.height!==a))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return sY(e,n_)}))throw Error("MRT+Cube+[,MSAA] is not supported");var u=e.capability.maxAntiAliasing;t.antiAliasing>u&&(nl.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 i=e!==this._curMipLevel,a=t!==this._curFaceIndex,o=r.getColorTexture(0);if(o){var s=sY(o,n_);(i||s&&a)&&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=sY(l,n_);if(i||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(i){var d=s4._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,i=n.width,a=n.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<r;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,i,a,0,0,i,a,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},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,i=n.colorTextureCount,a=n.width,o=n.height,s=Array(i);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<i;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,sY(c,n_)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(sY(r,nc)&&!sY(r,n_)){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=s4._getRenderBufferDepthFormatDetail(r,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,a,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,n=e.createRenderbuffer(),r=this._target,i=r._depth,a=r.colorTextureCount,o=r.antiAliasing,s=r.width,l=r.height;this._blitDrawBuffers=Array(a),this._MSAADepthRenderBuffer=n,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<a;c++){var u=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=u,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,u),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,u)}if(e.drawBuffers(this._oriDrawBuffers),null!==i){var d=sY(i,nc)?i._platformTexture._formatDetail:s4._getRenderBufferDepthFormatDetail(i,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}(),s5=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var r,i=n.format,a=n._mipmap,o=n.width,s=n.height,l=r._isWebGL2;if(!s4._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+t7[i]);return!a||l||s4._isPowerOf2(o)&&s4._isPowerOf2(s)||(nl.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=s4._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r}sq(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,d=l.dataType,h=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(i=i||_-n,a=a||f-r,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),h){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,n,r,i,a,c,e):(o.compressedTexImage2D(this._target,t,c,i,a,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,n,r,i,a,u,d,e)},n.setImageSource=function(e,t,n,r,i,a){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===ne.Dynamic?o.texImage2D(this._target,t,l,c,u,e):o.texSubImage2D(this._target,t,i||0,a||0,c,u,e)},n.getPixelBuffer=function(t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,null,t,n,r,i,a,o)},t}(s4),s9=/*#__PURE__*/function(e){function t(t,n){r=e.call(this,t,n,t.gl.TEXTURE_2D_ARRAY)||this;var r,i=n.format,a=n.width,o=n.height,s=n.length,l=n.mipmapCount;if(!r._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!s4._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+t7[i]);return r._bind(),r._formatDetail=s4._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r}sq(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;a=a||Math.max(1,this._texture.width>>n)-r,o=o||Math.max(1,this._texture.height>>n)-i,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,n,r,i,e,a,o,s,d,t):c.texSubImage3D(l,n,r,i,e,a,o,s,h,_,t)},n.setImageSource=function(e,t,n,r,i,a,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,+i),c.texSubImage3D(this._target,n,a,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,i,a,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,a,e),s.readPixels(t,n,r,i,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t}(s4),s6=/*#__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,i=n.format,a=n._mipmap,o=n.width,s=r._isWebGL2;if(!s4._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+t7[i]);return!a||s||s4._isPowerOf2(o)||(nl.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=s4._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r}sq(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a,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(a=a||f-r,o=o||f-i,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<n;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,i,a,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,u,a,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,i,a,o,d,h,t)},n.setImageSource=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,a||0,o||0,c,u,t)},n.getPixelBuffer=function(t,n,r,i,a,o,s){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,t,n,r,i,a,o,s)},t}(s4),s7=((e3={})[e3.Auto=0]="Auto",e3[e3.WebGL2=1]="WebGL2",e3[e3.WebGL1=2]="WebGL1",e3),le=/*#__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 tN(null,null,null,null),this._lastScissor=new tN(null,null,null,null),this._lastClearColor=new tV(null,null,null,null),this._scissorEnable=!1;var t=sZ({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},e);if(am.platform===tG.IPhone||am.platform===tG.IPad){var n=am.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var r=parseInt(n[1]),i=parseInt(n[2]);15===r&&i>=0&&i<=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,i=this._options,a=e._webCanvas,o=i.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=n,a.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),a.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),a.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=a,(0==o||1==o)&&((r=a.getContext("webgl2",i))||"undefined"!=typeof OffscreenCanvas&&sY(a,OffscreenCanvas)||(r=a.getContext("experimental-webgl2",i)),this._isWebGL2=!0,r&&!r.deleteQuery&&(this._isWebGL2=!1)),r||0!=o&&2!=o||((r=a.getContext("webgl",i))||"undefined"!=typeof OffscreenCanvas&&sY(a,OffscreenCanvas)||(r=a.getContext("experimental-webgl",i)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},t.createPlatformPrimitive=function(e){return new s2(this,e)},t.createPlatformTexture2D=function(e){return new s5(this,e)},t.createPlatformTexture2DArray=function(e){return new s9(this,e)},t.createPlatformTextureCube=function(e){return new s6(this,e)},t.createPlatformRenderTarget=function(e){return new s8(this,e)},t.createPlatformBuffer=function(e,t,n,r){return void 0===n&&(n=r6.Static),new s$(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 i=this._gl,a=this._lastViewport;(e!==a.x||t!==a.y||n!==a.z||r!==a.w)&&(i.viewport(e,t,n,r),a.set(e,t,n,r))},t.scissor=function(e,t,n,r){var i=this._gl,a=this._lastScissor;if(e!==a.x||t!==a.y||n!==a.z||r!==a.w){var o=this._webCanvas;0===e&&0===t&&n===o.width&&r===o.height?this._scissorEnable&&(i.disable(i.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(i.enable(i.SCISSOR_TEST),this._scissorEnable=!0),i.scissor(e,t,n,r)),a.set(e,t,n,r)}},t.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},t.clearRenderTarget=function(e,t,n){var r=this._gl,i=e._lastRenderState,a=i.blendState.targetBlendState,o=i.depthState,s=i.stencilState,l=0;if(t&rF.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,_)),a.colorWriteMask!==nI.All&&(r.colorMask(!0,!0,!0,!0),a.colorWriteMask=nI.All)}t&rF.Depth&&(l|=r.DEPTH_BUFFER_BIT,!0!==o.writeEnabled&&(r.depthMask(!0),o.writeEnabled=!0)),t&rF.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):nl.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,i){if(e){var a,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(r,i),a=e.width>>r,o=e.height>>r}else{var s=this._gl;s.bindFramebuffer(s.FRAMEBUFFER,this._mainFrameBuffer),a=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight()}var l=a*t.z,c=o*t.w,u=t.x*a,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){nl.warn("WebGL1.0 not support blit frame buffer.");return}var i=this._gl,a=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&rF.Color)==0,p=(n&rF.Depth)==0,m=(n&rF.Stencil)==0;i.bindFramebuffer(i.READ_FRAMEBUFFER,a),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,o);var g=f?i.COLOR_BUFFER_BIT:0;if(p||m){var v=t._depthFormat;p&&(v===t7.Depth||v>=t7.DepthStencil&&v<=t7.Depth32Stencil8?g|=i.DEPTH_BUFFER_BIT:nl.warn("Do not clear depth, or set depth format of target which is "+t7[v]+" now.")),m&&(v===t7.Stencil||v===t7.DepthStencil||v>=t7.Depth24Stencil8||v>=t7.Depth32Stencil8?g|=i.STENCIL_BUFFER_BIT:nl.warn("Do not clear stencil, or set stencil format of target which is "+t7[v]+" now."))}var y=r.x*c,x=_?u-r.y*u:u-r.y*u-h;i.blitFramebuffer(y,x,y+d,_?x-h:x+h,0,0,d,h,g,i.NEAREST)},t.copyRenderTargetToSubTexture=function(e,t,n){var r,i=this._gl,a=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight(),s=e?e.width:a,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;i.bindFramebuffer(i.FRAMEBUFFER,f);var p=t._platformTexture;p._bind(),i.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(n$.WEBGL_lose_context).loseContext()},t.forceRestoreDevice=function(){this.requireExtension(n$.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 s3(e),this._extensions=new s1(this),this._capability=new s0(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()},sX(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 lt(){return(lt=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 ln(e,t){return(ln=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function lr(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&&ln(e,t)}function li(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function la(e,t,r,i){var a,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(s=(o<3?a(s):o>3?a(t,r,s):a(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function lo(e,t){var n,r,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function ls(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 ll(e,t,n){return t&&ls(e.prototype,t),n&&ls(e,n),e}"function"==typeof SuppressedError&&SuppressedError;var lc=/*#__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,nR.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 i=[],a=0;a<e;a++){var o=t[a],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,i.push(s)}return i},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)},ll(e,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),e}(),lu={};function ld(e){return function(t){lu[e]=t}}var lh=/*#__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),i=n.getUint8(4),a=n.getUint16(5,!0),o=new Uint8Array(t,7,a),s=n.getUint16(7+a,!0),l=new Uint8Array(t,9+a,s),c=nR.decodeText(l),u=nR.decodeText(o),d=new e;return d.totalLength=r,d.name=c,d.type=u,d.version=i,d.headerLength=l.byteLength+o.byteLength+9,d},ll(e,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),e}();function l_(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tN(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function lf(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tR(e[3*r],e[3*r+1],e[3*r+2]);return n}function lp(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tO(e[2*r],e[2*r+1]);return n}function lm(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(lm=function(){return!!e})()}function lg(e,t,n){return(lg=lm()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&ln(i,n.prototype),i}).apply(null,arguments)}e.MeshDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n){var r=new iB(e),i=JSON.parse(t.nextStr());i.bounds&&r.bounds.copyFrom(i.bounds);var a=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,i.positions.start+a,(i.positions.end-i.positions.start)/4),l=s.length/3,c=lf(s,l);if(r.setPositions(c),i.normals){var u=lf(new Float32Array(o,i.normals.start+a,(i.normals.end-i.normals.start)/4),l);r.setNormals(u)}if(i.uvs){var d=new Float32Array(o,i.uvs.start+a,(i.uvs.end-i.uvs.start)/4);r.setUVs(lp(d,l))}if(i.uv1){var h=new Float32Array(o,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);r.setUVs(lp(h,l),1)}if(i.uv2){var _=new Float32Array(o,i.uv2.start+a,(i.uv2.end-i.uv2.start)/4);r.setUVs(lp(_,l),2)}if(i.uv3){var f=new Float32Array(o,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);r.setUVs(lp(f,l),3)}if(i.uv4){var p=new Float32Array(o,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);r.setUVs(lp(p,l),4)}if(i.uv5){var m=new Float32Array(o,i.uv5.start+a,(i.uv5.end-i.uv5.start)/4);r.setUVs(lp(m,l),5)}if(i.uv6){var g=new Float32Array(o,i.uv6.start+a,(i.uv6.end-i.uv6.start)/4);r.setUVs(lp(g,l),6)}if(i.uv7){var v=new Float32Array(o,i.uv7.start+a,(i.uv7.end-i.uv7.start)/4);r.setUVs(lp(v,l),7)}if(i.colors){var y=new Float32Array(o,i.colors.start+a,(i.colors.end-i.colors.start)/4);r.setColors(function(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tV(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}(y,l))}if(i.boneWeights){var x=new Float32Array(o,i.boneWeights.start+a,(i.boneWeights.end-i.boneWeights.start)/4);r.setBoneWeights(l_(x,l))}if(i.boneIndices){var b=new Float32Array(o,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);r.setBoneIndices(l_(b,l))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var t=new iC(e.name);e.frames.forEach(function(e){var n=new Float32Array(o,e.deltaPosition.start+a,(e.deltaPosition.end-e.deltaPosition.start)/4),r=n.length/3,i=lf(n,r);e.deltaNormals&&lf(new Float32Array(o,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),r),e.deltaTangents&&l_(new Float32Array(o,e.deltaTangents.start+a,(e.deltaTangents.end-e.deltaTangents.start)/4),r),t.addFrame(e.weight,i)}),r.addBlendShape(t)}),i.indices){var C=null;C=0===i.indices.type?new Uint16Array(o,i.indices.start+a,(i.indices.end-i.indices.start)/2):new Uint32Array(o,i.indices.start+a,(i.indices.end-i.indices.start)/4),r.setIndices(C)}i.subMeshes.forEach(function(e){return r.addSubMesh(e)}),r.uploadData(!1),n(r)})},e}(),e.MeshDecoder=la([ld("Mesh")],e.MeshDecoder),e.Texture2DDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n,r){var i=t.nextStr(),a=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new nd(e,d,h,u,a);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),a){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[i]=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(),a){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 i=1;i<f;i++)r(i)}},b.src=URL.createObjectURL(x)}})},e}(),e.Texture2DDecoder=la([ld("Texture2D")],e.Texture2DDecoder);var lv=((e4={})[e4.Prefab=0]="Prefab",e4[e4.Scene=1]="Scene",e4),ly=/*#__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.componentWaitingMap=new Map,this.resourceManager=e.resourceManager}var t=e.prototype;return t.addComponent=function(e,t){this.components.set(e,t);var n=this.componentWaitingMap.get(e);(null==n?void 0:n.length)&&(n.forEach(function(e){return e(t)}),this.componentWaitingMap.delete(e))},t.getComponentByRef=function(e){var t=this;return new Promise(function(n,r){var i=t.components.get(e.componentId);if(i)n(i);else{var a=t.componentWaitingMap.get(e.componentId);a?a.push(n):t.componentWaitingMap.set(e.componentId,[n])}})},t.clear=function(){this.entityMap.clear(),this.components.clear(),this.entityConfigMap.clear(),this.rootIds.length=0,this.strippedIds.length=0},e}(),lx=/*#__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,i,a=e.position,o=e.rotation,s=e.scale;return a&&n.transform.position.copyFrom(a),o&&n.transform.rotation.copyFrom(o),s&&n.transform.scale.copyFrom(s),n.layer=null!=(i=e.layer)?i:n.layer,t._context.type===lv.Prefab&&n._markAsTemplate(t._context.resource),n})},t.parseClassObject=function(e){var t,n=this,r=ox.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return n.parseBasicType(e)})).then(function(e){return lg(r,[].concat(e))}).then(function(t){return n.parsePropsAndMethods(t,e)})},t.parsePropsAndMethods=function(t,n){var r=[];if(n.methods)for(var i in n.methods)for(var a=n.methods[i],o=0,s=a.length;o<s;o++)r.push(this.parseMethod(t,i,a[o]));if(n.props){var l,c=function(e){var i=n.props[e],a=l.parseBasicType(i,t[e]).then(function(n){return t[e]=n});r.push(a)};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":li(t))==="object"&&null!=t){if(e._isClass(t))return this.parseClassObject(t);if(e._isAssetRef(t)){var i=this._context;return i.resourceManager.getResourceByRef(t).then(function(e){return i.type===lv.Prefab&&i.resource._addDependenceAsset(e),e})}if(e._isComponentRef(t))return this._context.getComponentByRef(t);if(e._isEntityRef(t))return Promise.resolve(this._context.entityMap.get(t.entityId));else if(n){var a,o=function(e){if("methods"===e){var r=t[e];for(var i in r)for(var o=r[i],l=0,c=o.length;l<c;l++){var u=o[l];s.push(a.parseMethod(n,i,u))}}else s.push(a.parseBasicType(t[e],n[e]).then(function(t){return n[e]=t}))},s=[];for(var l in t)a=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(i){var a=r.resourceManager._objectPool[n];return t._context.type===lv.Prefab&&t._context.resource._addDependenceAsset(a),i.name=e.name,i}):Promise.resolve(new iQ(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._isComponentRef=function(e){return void 0!==e.ownerId&&void 0!==e.componentId},e}();lx.customParseComponentHandles=new Map;var lb=((e8={})[e8.Float=0]="Float",e8[e8.FloatArray=1]="FloatArray",e8[e8.Vector2=2]="Vector2",e8[e8.Vector3=3]="Vector3",e8[e8.Vector4=4]="Vector4",e8[e8.Quaternion=5]="Quaternion",e8[e8.Color=6]="Color",e8[e8.Array=7]="Array",e8[e8.Boolean=8]="Boolean",e8[e8.Rect=9]="Rect",e8[e8.ReferResource=10]="ReferResource",e8);e.AnimationClipDecoder=/*#__PURE__*/function(){function t(){}return t.decode=function(t,n){return new Promise(function(t){for(var r=new oP(n.nextStr()),i=n.nextUint16(),a=0;a<i;++a){var o=new ow;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=ox.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 o$;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 o$;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 o$;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 R=new o$;R.time=n.nextFloat32(),R.value=new tO(n.nextFloat32(),n.nextFloat32()),R.inTangent=new tO(n.nextFloat32(),n.nextFloat32()),R.outTangent=new tO(n.nextFloat32(),n.nextFloat32()),f.addKey(R)}break;case"AnimationVector3Curve":(f=new e.AnimationVector3Curve).interpolation=p;for(var E=0;E<m;++E){var M=new o$;M.time=n.nextFloat32(),M.value=new tR(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new tR(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new tR(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(M)}break;case"AnimationVector4Curve":(f=new e.AnimationVector4Curve).interpolation=p;var w=new o$;w.time=n.nextFloat32(),w.value=new tN(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.inTangent=new tN(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.outTangent=new tN(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 o$;F.time=n.nextFloat32(),F.value=new tV(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new tN(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new tN(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 o$;D.time=n.nextFloat32(),D.value=new tD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.inTangent=new tN(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.outTangent=new tN(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 o$;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 o$;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 o$;z.time=n.nextFloat32(),z.value=n.nextStr(),f.addKey(z)}}r.addCurveBinding(c,d,h,_,f)}t(r)})},t}(),e.AnimationClipDecoder=la([ld("AnimationClip")],e.AnimationClipDecoder);var lC=((e5={}).Vector2="Vector2",e5.Vector3="Vector3",e5.Vector4="Vector4",e5.Color="Color",e5.Float="Float",e5.Texture="Texture",e5.Boolean="Boolean",e5.Integer="Integer",e5),lS=((e9={}).Sky="Sky",e9.Custom="Custom",e9);function lT(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function lA(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 lR(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 lA(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 lA(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 lE=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r._dependenceAssets=new Set,r}lr(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}(t3),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 lx(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,i=this._engine;return Promise.all(t.map(function(t){var r,a=null!=(r=t.strippedId)?r:t.id;return t.id=a,n.set(a,t),e._getEntityByConfig(t,i)})).then(function(e){for(var n=0,i=e.length;n<i;n++)r.set(t[n].id,e[n]);return e})},t._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,n=[],r=0,i=e.length;r<i;r++)for(var a=e[r],o=t.get(a.id),s=0;s<a.components.length;s++){var l=a.components[s],c=l.refId?l.refId:l.class,u=o.addComponent(ox.getClass(c));this.context.addComponent(l.id,u);var d=this._reflectionParser.parsePropsAndMethods(u,l);n.push(d)}for(var h,_=lR(this.context.componentWaitingMap.values());!(h=_()).done;)h.value.forEach(function(e){return e(null)});return Promise.all(n)},t._parsePrefabModification=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],i=0,a=t.length;i<a;i++)!function(i,a){var o=t[i],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,i=t.methods,a=n.entityId,o=n.componentId,s=e._prefabContextMap.get(c),l=s.entityMap.get(a),u=s.components.get(o);return u?e._reflectionParser.parsePropsAndMethods(u,{props:r,methods:i}):l?Promise.resolve(e._applyEntityData(l,r)):void 0})))}}(i);return Promise.all(r)},t._parsePrefabRemovedEntities=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],i=0,a=t.length;i<a;i++)!function(i,a){var o=t[i],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()})))}}(i);return Promise.all(r)},t._parsePrefabRemovedComponents=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],i=0,a=t.length;i<a;i++)!function(i,a){var o=t[i],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()})))}}(i);return Promise.all(r)},t._organizeEntities=function(){for(var e,t=this.context,n=t.rootIds,r=t.strippedIds,i=n.concat(r),a=lR(i);!(e=a()).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 iQ(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 i=lT(r,lE)?r.instantiate():r.instantiateSceneRoot(),a=new ly(t,lv.Prefab,null);e.parent||n.context.rootIds.push(e.id),n._generateInstanceContext(i,a,""),n._prefabContextMap.set(i,a);var o=n._prefabPromiseMap.get(e.id);if(o)for(var s=0,l=o.length;s<l;s++)o[s].resolve(a);return i})},t._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(n,r){var i,a=null!=(i=t._prefabPromiseMap.get(e.prefabInstanceId))?i:[];a.push({resolve:n,reject:r}),t._prefabPromiseMap.set(e.prefabInstanceId,a)}).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,i=n.get(e).children;if(i&&i.length>0)for(var a=r.get(e),o=0;o<i.length;o++){var s=i[o],l=r.get(s);a.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,i=t.position,a=t.rotation,o=t.scale,s=t.layer;return i&&e.transform.position.copyFrom(i),a&&e.transform.rotation.copyFrom(a),o&&e.transform.scale.copyFrom(o),s&&(e.layer=s),e},t._generateInstanceContext=function(e,t,n){var r=t.entityMap,i=t.components,a={},o={};r.set(n,e),e._components.forEach(function(t){var r=ox.getClassName(t.constructor);a[r]||(a[r]=e.getComponents(t.constructor,[]),o[r]=0),i.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}(),lw=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t,n)||this).scene=r,i}lr(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 ov(e),i=new t(n,new ly(e,lv.Scene,r),r);return i.start(),i.promise.then(function(){return r})},t}(lM);function lP(e,t){var n=lh.decode(e),r=new lc(new Uint8Array(e),n.headerLength,n.dataLength);return lu[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 lr(t,e),t.prototype.load=function(e,t){return new at(function(n,r){t._request(e.url,lt({},e,{type:"arraybuffer"})).then(function(e){lP(e,t.engine).then(function(e){n(e)})}).catch(r)})},t}(ox),e.EditorTextureLoader=la([as("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var lF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new at(function(r,i){t._request(e.url,lt({},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(i)}).catch(i)})},n._parseKeyframeValue=function(e,t){var n=e.value;return(void 0===n?"undefined":li(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}(ox);lF=la([as(i6.AnimationClip,["ani"])],lF);var lL=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new at(function(r,i){t._request(e.url,lt({},e,{type:"json"})).then(function(e){var i=new oK(t.engine),a=e.layers,o=e.parameters,s=[];a.forEach(function(e,r){var a=e.name,o=e.blendingMode,l=e.weight,c=e.stateMachine,u=new oZ(a);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 i=e.id,a=e.name,o=e.speed,l=e.wrapMode,c=e.clipStartNormalizedTime,u=e.clipEndNormalizedTime,d=e.clip,h=e.scripts,_=p.addState(a);_.speed=o,_.wrapMode=l,_.clipStartTime=c,_.clipEndTime=u,h.forEach(function(e){_.addStateMachineScript(ox.getClass(e))}),m[i]=_,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]))})}i.addLayer(u)}),o.forEach(function(e){e.isTrigger?i.addTriggerParameter(e.name):i.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;i.layers[t].stateMachine.states[n].clip=r}),r(i)})}).catch(i)})},n._createTransition=function(e,t){var n=new oz;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}(ox);lL=la([as(i6.AnimatorController,["json"],!1)],lL);var lD=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){var n=e.url;return/^data:(.+?);base64,/.test(n)?new at(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,lt({},e,{type:"arraybuffer"}))},t}(ox);lD=la([as(i6.Buffer,["bin","r3bin"],!1)],lD);var lB=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,n){return new at(function(r,i){var a=lt({},e,{type:"arraybuffer"}),o=n.engine;n._request(e.url,a).then(function(n){var i=t._setTextureByBuffer(o,n);o.resourceManager.addContentRestorer(new lI(i,e.url,a));var s=new ou(o),l=new tz;s.diffuseMode=oc.SphericalHarmonics,l.copyFromArray(new Float32Array(n,0,27)),s.diffuseSphericalHarmonics=l,s.specularTexture=i,s.specularTextureDecodeRGBM=!0,r(s)}).catch(function(e){i(e)})})},t._setTextureByBuffer=function(e,t,n){var r=new Uint16Array(t,108,1)[0];n||(n=new n_(e,r)),n.filterMode=t6.Trilinear;for(var i=n.mipmapCount,a=110,o=0;o<i;o++)for(var s=r>>o,l=0;l<6;l++){var c=s*s*4,u=new Uint8Array(t,a,c);a+=c,n.setPixelBuffer(t5.PositiveX+l,u,o)}return n},t}(ox);lB=la([as(i6.Env,["env"])],lB);var lI=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return lr(t,e),t.prototype.restoreContent=function(){var e=this;return new at(function(t,n){ai(e.url,e.requestConfig).then(function(n){lB._setTextureByBuffer(e.resource.engine,n,e.resource),t(e.resource)}).catch(n)})},t}(t4);function lO(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function lN(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){lO(a,r,i,o,s,"next",e)}function s(e){lO(a,r,i,o,s,"throw",e)}o(void 0)})}}var lV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new at(function(r,i){t._request(e.url,lt({},e,{type:"json"})).then(function(e){var a=e.fontName,o=e.fontUrl;o?n._registerFont(a,o).then(function(){r(new ny(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new ny(t.engine,a))}).catch(function(e){i(e)})})},n._registerFont=function(e,t){return lN(function(){var n;return lo(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}(ox);lV=la([as(i6.Font,["font"],!1)],lV);var lk=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r}lr(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 i=0,a=r.length;i<a;i++)this._disassociationSuperResource(r[i])},n._disassociationSuperResource=function(e){for(var t=0,n=e.length;t<n;t++)e[t]._disassociationSuperResource(this)},ll(t,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),t}(t3),lz=((e6={})[e6.BYTE=5120]="BYTE",e6[e6.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e6[e6.SHORT=5122]="SHORT",e6[e6.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e6[e6.UNSIGNED_INT=5125]="UNSIGNED_INT",e6[e6.FLOAT=5126]="FLOAT",e6),lU=((e7={}).SCALAR="SCALAR",e7.VEC2="VEC2",e7.VEC3="VEC3",e7.VEC4="VEC4",e7.MAT2="MAT2",e7.MAT3="MAT3",e7.MAT4="MAT4",e7),lG=((te={}).TRANSLATION="translation",te.ROTATION="rotation",te.SCALE="scale",te.WEIGHTS="weights",te),lH=((tt={}).Linear="LINEAR",tt.Step="STEP",tt.CubicSpine="CUBICSPLINE",tt),lW=((tn={}).PERSPECTIVE="perspective",tn.ORTHOGRAPHIC="orthographic",tn),lj=((tr={}).OPAQUE="OPAQUE",tr.MASK="MASK",tr.BLEND="BLEND",tr),lX=((ti={})[ti.NEAREST=9728]="NEAREST",ti[ti.LINEAR=9729]="LINEAR",ti),lK=((ta={})[ta.NEAREST=9728]="NEAREST",ta[ta.LINEAR=9729]="LINEAR",ta[ta.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",ta[ta.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",ta[ta.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",ta[ta.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",ta),lq=((to={})[to.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",to[to.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",to[to.REPEAT=10497]="REPEAT",to),lY=/*#__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 i,a=(i=r._progress.taskDetail)[e]||(i[e]={});a.loaded=t,a.total=n,r._setTaskDetailProgress(e,t,n)},this.contentRestorer=new ci(e)}var t=e.prototype;return t.get=function(t,n){var r=this,i=e._parsers[t];if(!i)return Promise.resolve(null);var a=this._resourceCache,o=void 0===n?""+t:t+":"+n,s=a.get(o);if(s)return s;var l=lZ[t],c=!!l$[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=i.parse(this,n),c&&this._handleSubAsset(s,t,n)):s=Promise.resolve(null)}else s=i.parse(this,n),c&&this._handleSubAsset(s,t,n);return a.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(oj).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,i=this,a=l$[t];if(8===t)((r=this.glTFResource)[a]||(r[a]=[]))[n]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==n?i.glTFResource[a]=e:((r=i.glTFResource)[a]||(r[a]=[]))[n]=e,7===t)for(var r,s,l=0,c=e.length;l<c;l++){var u=e[l];i.resourceManager._onSubAssetSuccess(o,a+"["+n+"]["+l+"]",u)}else i.resourceManager._onSubAssetSuccess(o,""+a+(void 0===n?"":"["+n+"]"),e),2===t&&(null!=(s=i.glTF.scene)?s:0)===n&&i.resourceManager._onSubAssetSuccess(o,"defaultSceneRoot",e)})}},e.addParser=function(e,t){this._parsers[e]=t},e}();lY._parsers={};var lQ=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},lJ=((ts={})[ts.Schema=0]="Schema",ts[ts.Validator=1]="Validator",ts[ts.Scene=2]="Scene",ts[ts.Buffer=3]="Buffer",ts[ts.BufferView=4]="BufferView",ts[ts.Texture=5]="Texture",ts[ts.Material=6]="Material",ts[ts.Mesh=7]="Mesh",ts[ts.Entity=8]="Entity",ts[ts.Skin=9]="Skin",ts[ts.Animation=10]="Animation",ts[ts.AnimatorController=11]="AnimatorController",ts),lZ=((tf={})[2]="scenes",tf[3]="buffers",tf[5]="textures",tf[6]="materials",tf[7]="meshes",tf[8]="nodes",tf[9]="skins",tf[10]="animations",tf[4]="bufferViews",tf),l$=((tp={})[2]="_sceneRoots",tp[5]="textures",tp[6]="materials",tp[7]="meshes",tp[8]="entities",tp[9]="skins",tp[10]="animations",tp[11]="animatorController",tp);function l0(e){return function(t){var n=new t;lY.addParser(e,n)}}var l1=/*#__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 tO(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 tR(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 tN(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 i=0;i<n;i+=3)r[i/3]=new tV(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new tV(e[a],e[a+1],e[a+2],e[a+3]);return r},t.getAccessorTypeSize=function(e){switch(e){case lU.SCALAR:return 1;case lU.VEC2:return 2;case lU.VEC3:return 3;case lU.VEC4:case lU.MAT2:return 4;case lU.MAT3:return 9;case lU.MAT4:return 16}},t.getComponentType=function(e){switch(e){case lz.BYTE:return Int8Array;case lz.UNSIGNED_BYTE:return Uint8Array;case lz.SHORT:return Int16Array;case lz.UNSIGNED_SHORT:return Uint16Array;case lz.UNSIGNED_INT:return Uint32Array;case lz.FLOAT:return Float32Array}},t.getNormalizedComponentScale=function(e){switch(e){case lz.BYTE:return 1/127;case lz.UNSIGNED_BYTE:return 1/255;case lz.SHORT:return 1/32767;case lz.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},t.getAccessorBuffer=function(e,n,r){var i,a=r.componentType,o=t.getComponentType(a),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];i=e.get(lJ.BufferView,r.bufferView).then(function(t){var n,i,_,f=h.buffer,p=null!=(n=t.byteOffset)?n:0,m=null!=(i=r.byteOffset)?i:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=d+":"+a+":"+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 lQ(S,!0,g),_.restoreInfo=new cc(new cu(f,o,b,C))}}else{var T=p+m,A=u*s;(_=new lQ(new o(t.buffer,T,A),!1,c)).restoreInfo=new cc(new cu(f,o,T,A))}return _})}else{var _=u*s,f=new lQ(new o(_),!1,c);f.restoreInfo=new cc(new cu(void 0,o,void 0,_)),i=Promise.resolve(f)}return r.sparse?i.then(function(n){return t.processingSparseData(e,r,n).then(function(){return n})}):i},t.bufferToVector3Array=function(e,n,r,i,a){for(var o=n/e.BYTES_PER_ELEMENT,s=e.length/r,l=Array(r),c=i?t.getNormalizedComponentScale(a):1,u=0;u<r;u++){var d=o+u*s;l[u]=new tR(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 i=r.restoreInfo,a=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,_=a[d.bufferView],f=a[h.bufferView];return Promise.all([e.get(lJ.BufferView,d.bufferView),e.get(lJ.BufferView,h.bufferView)]).then(function(e){var n,a,c,p,m=e[0],g=e[1],v=(null!=(n=d.byteOffset)?n:0)+(null!=(a=m.byteOffset)?a:0),y=m.byteLength,x=(null!=(c=h.byteOffset)?c:0)+(null!=(p=g.byteOffset)?p:0),b=g.byteLength;i.typeSize=o,i.sparseCount=u;var C=t.getComponentType(d.componentType),S=y/C.BYTES_PER_ELEMENT,T=new C(m.buffer,v,S);i.sparseIndices=new cu(_.buffer,C,v,S);var A=b/s.BYTES_PER_ELEMENT,R=new s(g.buffer,x,A);i.sparseValues=new cu(f.buffer,s,x,A);for(var E=0;E<u;E++)for(var M=T[E],w=0;w<o;w++)l[M*o+w]=R[E*o+w];r.data=l})},t.getIndexFormat=function(e){switch(e){case lz.UNSIGNED_BYTE:return it.UInt8;case lz.UNSIGNED_SHORT:return it.UInt16;case lz.UNSIGNED_INT:return it.UInt32}},t.getElementFormat=function(e,t,n){if(void 0===n&&(n=!1),e==lz.FLOAT)switch(t){case 1:return ir.Float;case 2:return ir.Vector2;case 3:return ir.Vector3;case 4:return ir.Vector4}if(e==lz.SHORT)switch(t){case 2:return n?ir.NormalizedShort2:ir.Short2;case 3:case 4:return n?ir.NormalizedShort4:ir.Short4}if(e==lz.UNSIGNED_SHORT)switch(t){case 2:return n?ir.NormalizedUShort2:ir.UShort2;case 3:case 4:return n?ir.NormalizedUShort4:ir.UShort4}if(e==lz.BYTE)switch(t){case 2:case 3:case 4:return n?ir.NormalizedByte4:ir.Byte4}if(e==lz.UNSIGNED_BYTE)switch(t){case 2:case 3:case 4:return n?ir.NormalizedUByte4:ir.UByte4}},t.loadImageBuffer=function(e,t){return new Promise(function(n,r){var i=new window.Blob([e],{type:t}),a=new Image;a.onerror=function(){r(Error("Failed to load image buffer"))},a.onload=function(){requestAnimationFrame(function(){n(a),a.onload=null,a.onerror=null,a.onabort=null})},a.crossOrigin="anonymous",a.src=URL.createObjectURL(i)})},t.parseGLB=function(e,t){var n={JSON:0x4e4f534a,BIN:5130562},r=new DataView(t),i={magic:r.getUint32(0,!0),version:r.getUint32(4,!0),length:r.getUint32(8,!0)};if(0x46546c67!==i.magic)return{originBuffer:t};var a=r.getUint32(12,!0),o=r.getUint32(16,!0);if(o!==n.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+o.toString(16)),null;for(var s=new Uint8Array(t,20,a),l=JSON.parse(nR.decodeText(s)),c=[],u=20+a,d=e.contentRestorer.glbBufferSlices;u<i.length;){if(a=r.getUint32(u,!0),(o=r.getUint32(u+4,!0))!==n.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+o.toString(16)),null;var h=u+8,_=t.slice(h,h+a);c.push(_),d.push(new tO(h,a)),u+=a+8}return{glTF:l,buffers:c}},t.parseSampler=function(e,t){var n=t.filterMode,r=t.wrapModeU,i=t.wrapModeV;void 0!==n&&(e.filterMode=n),void 0!==r&&(e.wrapModeU=r),void 0!==i&&(e.wrapModeV=i)},t.getSamplerInfo=function(t){var n=t.minFilter,r=t.magFilter,i=t.wrapS,a=t.wrapT,o={};return(n||r)&&(o.mipmap=n>=lK.NEAREST_MIPMAP_NEAREST,r===lX.NEAREST?o.filterMode=t6.Point:n<=lK.LINEAR_MIPMAP_NEAREST?o.filterMode=t6.Bilinear:o.filterMode=t6.Trilinear),i&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[i]),a&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[a]),o},t}(),l2=((tl={})[tl.None=0]="None",tl[tl.BasisLZ=1]="BasisLZ",tl[tl.Zstd=2]="Zstd",tl[tl.ZLib=3]="ZLib",tl),l3=/*#__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 lc(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 i=Math.max(1,r.nextUint32());this.supercompressionScheme=r.nextUint32();var a=r.nextUint32(),o=r.nextUint32(),s=r.nextUint32(),l=r.nextUint32(),c=r.nextUint64(),u=r.nextUint64(),d=Array(i),h=24*i,_=new lc(e,r.offset,h);this.levels=d;for(var f=0;f<i;f++)d[f]={levelData:new Uint8Array(t,n+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new lc(e,a,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 lc(e,s,l,!0);x.position<l;){var b=x.nextUint32(),C=x.scan(b),S=nR.decodeText(C),T=x.nextUint8Array(b-C.byteLength-1);this.keyValue[S]=S.match(/^ktx/i)?nR.decodeText(T).replace(/^(.*)\x00$/,"$1"):T;var A=b%4?4-b%4:0;x.skip(A)}if(u<=0)return this;for(var R=new lc(e,c,u,!0),E=R.nextUint16(),M=R.nextUint16(),w=R.nextUint32(),P=R.nextUint32(),F=R.nextUint32(),L=R.nextUint32(),D=Array(i),B=0;B<i;B++)D[B]={imageFlags:R.nextUint32(),rgbSliceByteOffset:R.nextUint32(),rgbSliceByteLength:R.nextUint32(),alphaSliceByteOffset:R.nextUint32(),alphaSliceByteLength:R.nextUint32()};var I=c+R.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:E,selectorCount:M,imageDescs:D,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},ll(e,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),e}(),l4=((tc={})[tc.ASTC=0]="ASTC",tc[tc.BC7=1]="BC7",tc[tc.BC1_BC3=2]="BC1_BC3",tc[tc.PVRTC=3]="PVRTC",tc[tc.ETC=4]="ETC",tc[tc.R8=5]="R8",tc[tc.R8G8=6]="R8G8",tc[tc.R8G8B8A8=7]="R8G8B8A8",tc),l8=/*#__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 i=t._getIdleWorkerId();if(-1!==i){t._workerStatus|=1<<i;var a,o=t._workerItems;Promise.resolve(null!=(a=o[i])?a:t._initWorker(i)).then(function(){var t=o[i];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}(),l5=/*#__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 l8(this.workerLimitCount,function(){return new Promise(function(n,r){var i=new Worker(e);i.addEventListener("message",function(e){e.data.error?r(e.data.error):n(i)}),i.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},e}();function l9(){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=l7(n.buffer,n.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var l6=function(e){return tu||(tu=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})),tu};function l7(e,t,n){var r=new n(new Uint8Array(e));function i(){r.close(),r.delete()}if(!r.isValid())throw i(),Error("Invalid or unsupported .ktx2 file");if(!r.startTranscoding())throw i(),Error("KTX2 startTranscoding failed");for(var a=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&&(a!==b.width||o!==b.height)?console.warn("KTX2 transcode to BC will resize to width: "+(a=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 i(),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),i=0,a=0;a<e.length;a++)r.set(e[a],i),i+=e[a].byteLength;return r}(g),width:v,height:y}}h[f]=p}return i(),{faces:h,width:a,height:o,hasAlpha:c,faceCount:u,format:d}}var ce=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}lr(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 i=document.createElement("script");i.src=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),document.body.appendChild(i),i.onload=function(){l6(r).then(function(){e(null)})},i.onerror=function(){t()}});var i=l9.toString(),a=i.substring(i.indexOf("{"),i.lastIndexOf("}")+1),o="\n "+n+"\n "+l7.toString()+"\n "+a+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,r)})},n.transcode=function(e,t){return 0===this.workerLimitCount?l6().then(function(n){return l7(e,t,n)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},t}(l5);function ct(){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,i=t.byteLength,a=r.malloc(i);e.heap.set(t,a),n=n||Number(r.ZSTD_findDecompressedSize(a,i));var o=r.malloc(n),s=r.ZSTD_decompress(o,n,a,i),l=e.heap.slice(o,o+s);return r.free(a),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,i=t.data;switch(i.type){case"init":(r=i.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,a,o,s;(t=i.data,r=i.needZstd,o=Array(a=t.length),s=Promise.resolve(),r&&(n.init(),s=n._initPromise),s.then(function(){for(var i=0;i<a;i++){for(var s=t[i].length,l=Array(s),c=0;c<s;c++){var u=t[i][c],d=u.buffer,h=u.levelHeight,_=u.levelWidth,f=u.uncompressedByteLength;r&&(d=n.decode(d.slice(),f));var p=d.byteLength/a,m=d.byteOffset,g=function(e,t,n,r){var i=(n+3>>2)*(r+3>>2),a=16*i+65535>>16,o=e.memory,s=a+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*i);return l.set(t),0===e.transcode(i)?l:null}(e,new Uint8Array(d.buffer,m+i*p,p),_,h);if(g)l[c]={data:g.slice(),width:_,height:h};else throw"buffer decoded error"}o[i]=l}return o})).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var cn=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).type=n,r}lr(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=ct.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===l2.Zstd,n=e.levels.length,r=e.faceCount,i={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},a={type:"transcode",format:0,needZstd:t,data:Array(r)},o=a.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(a).then(function(e){return i.faces=e,i.hasAlpha=!0,i})},t}(l5);cn.transcoderMap=((tm={})[l4.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",tm),e.KTX2Loader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(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 at(function(r,i,a,o){n._request(e.url,{type:"arraybuffer"}).onProgress(a,o).then(function(r){return t._parseBuffer(new Uint8Array(r),n.engine,e.params).then(function(e){var n=e.engine,r=e.result,i=e.targetFormat,a=e.params;return t._createTextureByBuffer(n,r,i,a)})}).then(r).catch(i)})},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 i,a,o=new l3(e),s=null!=(i=null==r?void 0:r.priorityFormats)?i:t._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=t._decideTargetFormat(n,o,s);if(!t._isBinomialInit&&cn.transcoderMap[l]&&o.isUASTC){var c=t._getKhronosTranscoder();a=c.init().then(function(){return c.transcode(o)})}else{var u=t._getBinomialLLCTranscoder();a=u.init().then(function(){return u.transcode(e,l)})}return a.then(function(e){return{engine:n,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},t._createTextureByBuffer=function(e,t,n,r){var i,a=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){i=new nd(e,a,o,d,u);for(var h=0;h<c.length;h++){var _=c[h].data;i.setPixelBuffer(_,h)}}else{i=new n_(e,o,d,u);for(var f=0;f<s.length;f++)for(var p=s[f],m=0;m<c.length;m++)i.setPixelBuffer(t5.PositiveX+f,p[m].data,m)}return r&&(i.wrapModeU=r[0],i.wrapModeV=r[1],i.filterMode=r[2],i.anisoLevel=r[3]),i},t._decideTargetFormat=function(e,t,n){var r=e._hardwareRenderer,i=this._detectSupportedFormat(r,n);return i!==l4.PVRTC||tA.isPowerOf2(t.pixelWidth)&&tA.isPowerOf2(t.pixelHeight)&&t.pixelWidth===t.pixelHeight?null===i?(nl.warn("Can't support any compressed texture, downgrade to RGBA8"),l4.R8G8B8A8):i:(nl.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),l4.R8G8B8A8)},t._detectSupportedFormat=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=this._supportedMap[r];if(i){for(var a=0;a<i.length;a++)if(e.canIUse(i[a]))return r}else switch(t[n]){case l4.R8G8B8A8:return r;case l4.R8:case l4.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 ce(e)},t._getKhronosTranscoder=function(e){var t;return void 0===e&&(e=4),null!=(t=this._khronosTranscoder)?t:this._khronosTranscoder=new cn(e,l4.ASTC)},t._getEngineTextureFormat=function(e,t){var n=t.hasAlpha;switch(e){case l4.ASTC:return t7.ASTC_4x4;case l4.ETC:return n?t7.ETC2_RGBA8:t7.ETC2_RGB;case l4.BC7:return t7.BC7;case l4.BC1_BC3:return n?t7.BC3:t7.BC1;case l4.PVRTC:return n?t7.PVRTC_RGBA4:t7.PVRTC_RGB4;case l4.R8G8B8A8:return t7.R8G8B8A8}},t}(ox),e.KTX2Loader._isBinomialInit=!1,e.KTX2Loader._priorityFormats={etc1s:[l4.ETC,l4.BC7,l4.ASTC,l4.BC1_BC3,l4.PVRTC],uastc:[l4.ASTC,l4.BC7,l4.ETC,l4.BC1_BC3,l4.PVRTC]},e.KTX2Loader._supportedMap=((tg={})[l4.ASTC]=[n$.astc],tg[l4.ETC]=[n$.etc],tg[l4.BC7]=[n$.bptc],tg[l4.BC1_BC3]=[n$.s3tc],tg[l4.PVRTC]=[n$.pvrtc,n$.pvrtc_webkit],tg),e.KTX2Loader=la([as(i6.KTX2,["ktx2"])],e.KTX2Loader);var cr=((td={})[td.BinomialLLC=0]="BinomialLLC",td[td.Khronos=1]="Khronos",td),ci=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e}lr(n,t);var r=n.prototype;return r.restoreContent=function(){var t=this;return new at(function(n,r){Promise.all(t.bufferRequests.map(function(e){return ai(e.url,e.config)})).then(function(i){if(t.isGLB){var a=t.glbBufferSlices,o=i[0],s=a.length;i.length=s;for(var l=0;l<s;l++){var c=a[l];i[l]=o.slice(c.x,c.x+c.y)}}at.all(t.bufferTextures.map(function(t){var n,r=t.bufferView,a=new Uint8Array(i[r.buffer],null!=(n=r.byteOffset)?n:0,r.byteLength),o=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(a,o.engine).then(function(e){for(var t=e.result.faces[0],n=0;n<t.length;n++)o.setPixelBuffer(t[n].data,n)}):l1.loadImageBuffer(a,t.mimeType).then(function(e){o.setImageSource(e),o.generateMipmaps()})})).then(function(){for(var e,r=lR(t.meshes);!(e=r()).done;){for(var a,o=e.value,s=o.mesh,l=lR(o.vertexBuffers);!(a=l()).done;){var c=a.value,u=t._getBufferData(i,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=t._getBufferData(i,o.indexBuffer);s.setIndices(d)}for(var h,_=lR(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(i,m.buffer);if(p.deltaPositions=l1.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(i,v.buffer);p.deltaNormals=l1.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,b=t._getBufferData(i,x.buffer);p.deltaTangents=l1.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 i=e[r.bufferIndex];n=new r.TypedArray(i,r.byteOffset,r.length)}else n=new r.TypedArray(r.length);var a=t.sparseCount;if(a)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],d=new c.TypedArray(u,c.byteOffset,c.length),h=t.typeSize,_=0;_<a;_++)for(var f=l[_],p=0;p<h;p++)n[f*h+p]=d[_*h+p];return n},n}(t4),ca=function(e,t){this.url=e,this.config=t},co=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},cs=function(){this.vertexBuffers=[],this.blendShapes=[]},cl=function(e,t){this.buffer=e,this.data=t},cc=function(e,t,n,r,i){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=i},cu=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},cd=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},ch=function(e,t,n,r,i){this.buffer=e,this.byteOffset=t,this.count=n,this.normalized=r,this.componentType=i},c_=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.createAndParse=function(e,t,n){for(var r=arguments.length,i=Array(r>3?r-3:0),a=3;a<r;a++)i[a-3]=arguments[a];throw"Not implemented."},t.additiveParse=function(e,t,n,r){for(var i=arguments.length,a=Array(i>4?i-4:0),o=4;o<i;o++)a[o-4]=arguments[o];throw"Not implemented."},e}(),cf=((th={})[th.CreateAndParse=0]="CreateAndParse",th[th.AdditiveParse=1]="AdditiveParse",th),cp=/*#__PURE__*/function(){function e(){}return e.executeExtensionsCreateAndParse=function(t,n,r){void 0===t&&(t={});for(var i=arguments.length,a=Array(i>3?i-3:0),o=3;o<i;o++)a[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],a)))return s}},e.executeExtensionsAdditiveAndParse=function(t,n,r,i){for(var a=arguments.length,o=Array(a>4?a-4:0),s=4;s<a;s++)o[s-4]=arguments[s];for(var l in t){var c=t[l];e._additiveParse.apply(e,[].concat([l,n,r,c,i],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],i=null==r?void 0:r.length;if(i)for(var a=i-1;a>=0;--a){var o=r[a];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,i){for(var a=arguments.length,o=Array(a>4?a-4:0),s=4;s<a;s++)o[s-4]=arguments[s];var l=e.getExtensionParser(t,cf.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat([n,r,i],o))},e._additiveParse=function(t,n,r,i,a){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=e.getExtensionParser(t,cf.AdditiveParse);c&&c.additiveParse.apply(c,[].concat([n,r,i,a],s))},e}();function cm(e,t){return function(n){var r=new n;r._mode=t,cp._addExtensionParser(e,r)}}function cg(){if(ty)return ty;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=am._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 i=e.charCodeAt(r);n[r]=i>96?i-97:i>64?i-39:i+4}for(var a=0,o=0;o<e.length;++o)n[a++]=n[o]<60?t[n[o]]:(n[o]-60)*64+n[++o];return n.buffer.slice(0,a)}ty=WebAssembly.instantiate(r(n)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:ty,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"}),i=URL.createObjectURL(t),a=0;a<e;++a)o[a]=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}(i);URL.revokeObjectURL(i)}(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,i){for(var a=o[0],l=1;l<o.length;++l)o[l].pending<a.pending&&(a=o[l]);return new Promise(function(o,l){var c=new Uint8Array(n),u=s++;a.pending+=e,a.requests[u]={resolve:o,reject:l},a.object.postMessage({id:u,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}(t,n,r,a[l],i[c]):ty.then(function(){var o=new Uint8Array(t*n);return function(t,n,r,i,a,o){var s=e.exports.sbrk,l=r+3&-4,c=s(l*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var h=t(c,r,i,u,a.length);if(0==h&&o&&o(c,l,i),n.set(d.subarray(c,c+r*i)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)}(e.exports[a[l]],o,t,n,r,e.exports[i[c]]),o})},release:function(){for(var e=0;e<o.length;e++)o[e].object.terminate()}}});var i={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},a={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},o=[],s=0;return ty}cp._extensionParsers={},e.GLTFSchemaParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.parse=function(e){var t=e.glTFResource,n=e.contentRestorer,r=e.resourceManager,i=t.url,a=n.bufferRequests,o={type:"arraybuffer"},s=r._getRemoteUrl(i);return r._requestByRemoteUrl(s,o).onProgress(void 0,e._onTaskDetail).then(function(t){var n=l1.parseGLB(e,t);return(null==n?void 0:n.glTF)&&a.push(new ca(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(nR.decodeText(new Uint8Array(t.originBuffer))))})},t}(cp),e.GLTFSchemaParser=la([l0(lJ.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.parse=function(e,t){var r=e.glTF.animations[t],i=r.name;return Promise.resolve(cp.executeExtensionsCreateAndParse(r.extensions,e,r)||n._parseStandardProperty(e,new oP(void 0===i?"AnimationClip"+t:i),r)).then(function(t){return cp.executeExtensionsAdditiveAndParse(r.extensions,e,t,r),t})},n._parseStandardProperty=function(e,t,n){for(var r=function(t,n){var r=c[t],i=o[r.input],a=o[r.output];_.push(Promise.all([l1.getAccessorBuffer(e,s,i),l1.getAccessorBuffer(e,s,a)]).then(function(e){var n,i,o=e[0].data,s=e[1].data;if(a.normalized){for(var l=l1.getNormalizedComponentScale(a.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:lH.Linear){case lH.CubicSpine:i=oF.CubicSpine;break;case lH.Step:i=oF.Step;break;case lH.Linear:i=oF.Linear}o[o.length-1],d[t]={type:a.type,interpolation:i,input:o,output:s,outputSize:_}}))},i=this,a=e.glTF,o=a.accessors,s=a.bufferViews,l=n.channels,c=n.samplers,u=c.length,d=Array(u),h=e.get(lJ.Entity),_=[],f=0;f<u;f++)r(f);return _.push(e.get(lJ.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 lG.TRANSLATION:f=rg,p="position";break;case lG.ROTATION:f=rg,p="rotationQuaternion";break;case lG.SCALE:f=rg,p="scale";break;case lG.WEIGHTS:f=i$,p="blendShapeWeights"}var m=i._addCurve(s.path,o,d);if(s.path===lG.WEIGHTS)for(var g=a.nodes[s.node].mesh,v=0,y=a.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 i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case lG.TRANSLATION:case lG.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=i.interpolation,u=0,d=0,h=a.length;d<h;d++){var _=new o$;_.time=a[d],c===oF.CubicSpine?(_.inTangent=new tR(o[u++],o[u++],o[u++]),_.value=new tR(o[u++],o[u++],o[u++]),_.outTangent=new tR(o[u++],o[u++],o[u++])):_.value=new tR(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case lG.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=i.interpolation,m=0,g=0,v=a.length;g<v;g++){var y=new o$;y.time=a[g],p===oF.CubicSpine?(y.inTangent=new tN(o[m++],o[m++],o[m++],o[m++]),y.value=new tD(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new tN(o[m++],o[m++],o[m++],o[m++])):y.value=new tD(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case lG.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=i.interpolation;for(var b=0,C=0,S=a.length;C<S;C++){var T=new o$;T.time=a[C],x.interpolation===oF.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}(cp),e.GLTFAnimationParser=la([l0(lJ.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(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,i=e.resourceManager,a=n.url,o=i._getRemoteUrl(a),s=r.bufferRequests,l={type:"arraybuffer"},c=nR.resolveAbsoluteUrl(o,t.uri);s.push(new ca(c,l));var u=i._requestByRemoteUrl(c,l).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(u),u},t}(cp),e.GLTFBufferParser=la([l0(lJ.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.parse=function(e,t){var n=e.glTFResource,r=e.glTF.nodes[t],i=n.engine,a=r.matrix,o=r.translation,s=r.rotation,l=r.scale,c=r.extensions,u=new iQ(i,r.name||"_GLTF_ENTITY_"+t);u._markAsTemplate(n);var d=u.transform;if(a){var h=d.localMatrix;h.copyFromArray(a),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(lJ.Entity,p);u.addChild(m)}return cp.executeExtensionsAdditiveAndParse(c,e,u,r),u},t}(cp),e.GLTFEntityParser=la([l0(lJ.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.parse=function(e,n){var r=e.glTF.materials[n],i=e.glTFResource,a=i.engine,o=cp.executeExtensionsCreateAndParse(r.extensions,e,r);return o||((o=new ig(a)).name=r.name,t._parseStandardProperty(e,o,r)),Promise.resolve(o).then(function(n){return n||(n=t._getDefaultMaterial(a)),cp.executeExtensionsAdditiveAndParse(r.extensions,e,n,r),n._associationSuperResource(i),n})},t._getDefaultMaterial=function(e){return t._defaultMaterial||(t._defaultMaterial=new ih(e))},t._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&nl.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},t._parseStandardProperty=function(e,n,r){var i=r.pbrMetallicRoughness,a=r.normalTexture,o=r.occlusionTexture,s=r.emissiveTexture,l=r.emissiveFactor,c=r.alphaMode,u=r.alphaCutoff,d=r.doubleSided;if(i){var h=i.baseColorFactor,_=i.baseColorTexture,f=i.metallicFactor,p=i.roughnessFactor,m=i.metallicRoughnessTexture;h&&(n.baseColor=new tV(tV.linearToGammaSpace(h[0]),tV.linearToGammaSpace(h[1]),tV.linearToGammaSpace(h[2]),h[3])),_&&e.get(lJ.Texture,_.index).then(function(t){n.baseTexture=t,cp.executeExtensionsAdditiveAndParse(_.extensions,e,n,_)}),n.constructor===ig&&(n.metallic=null!=f?f:1,n.roughness=null!=p?p:1,m&&(t._checkOtherTextureTransform(m,"Roughness metallic"),e.get(lJ.Texture,m.index).then(function(e){n.roughnessMetallicTexture=e})))}if(n.constructor===ig||n.constructor===iv){if(s&&(t._checkOtherTextureTransform(s,"Emissive"),e.get(lJ.Texture,s.index).then(function(e){n.emissiveTexture=e})),l&&(n.emissiveColor=new tV(tV.linearToGammaSpace(l[0]),tV.linearToGammaSpace(l[1]),tV.linearToGammaSpace(l[2]))),a){var g=a.index,v=a.scale;t._checkOtherTextureTransform(a,"Normal"),e.get(lJ.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(lJ.Texture,y).then(function(e){n.occlusionTexture=e}),void 0!==x&&(n.occlusionTextureIntensity=x),b===i_.UV1?n.occlusionTextureCoord=i_.UV1:b>i_.UV1&&nl.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=ic.Double:n.renderFace=ic.Front,c){case lj.OPAQUE:n.isTransparent=!1;break;case lj.BLEND:n.isTransparent=!0;break;case lj.MASK:n.alphaCutoff=null!=u?u:.5}},t}(cp),e.GLTFMaterialParser=la([l0(lJ.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.parse=function(e,n){for(var r=function(n,r){var c=i.primitives[n];l[n]=new Promise(function(r){var l=cp.executeExtensionsCreateAndParse(c.extensions,e,c,i);if(l)lT(l,iB)?(l._associationSuperResource(o),r(l)):l.then(function(e){e._associationSuperResource(o),r(e)});else{var u=new iB(s,i.name||n+"");u._associationSuperResource(o);var d=new cs;d.mesh=u,e.contentRestorer.meshes.push(d),t._parseMeshFromGLTFPrimitive(e,u,d,i,c,a,e.params.keepMeshData).then(r)}})},i=e.glTF.meshes[n],a=e.glTF,o=e.glTFResource,s=o.engine,l=[],c=0,u=i.primitives.length;c<u;c++)r(c);return Promise.all(l)},t._parseMeshFromGLTFPrimitive=function(e,n,r,i,a,o,s){var l,c=function(i){var a=u[d[i]],c=l1.getAccessorBuffer(e,o.bufferViews,a).then(function(e){var o,c,u,d=l1.getAccessorTypeSize(a.type),h=a.count,_=e.data,f=n.instanceId,v=e.vertexBindingInfos,y=a.normalized,x=l1.getElementFormat(a.componentType,d,y);if(y&&(c=l1.getNormalizedComponentScale(a.componentType)),e.interleaved){var b=a.byteOffset||0,C=e.stride;if(u=b%C,void 0===v[f]){o=new ia(i,u,x,g);var S=e.vertexBuffer;S||(S=new ie(p,io.VertexBuffer,_,r6.Static,s),e.vertexBuffer=S,r.vertexBuffers.push(new cl(S,e.restoreInfo))),n.setVertexBufferBinding(S,C,g),v[f]=g++}else o=new ia(i,u,x,v[f])}else{o=new ia(i,u=0,x,g);var T=e.vertexBuffer;T||(T=new ie(p,io.VertexBuffer,_,r6.Static,s),r.vertexBuffers.push(new cl(T,e.restoreInfo))),n.setVertexBufferBinding(T,e.stride,g),v[f]=g++}if(m.push(o),"POSITION"===i){l=h;var A=n.bounds,R=A.min,E=A.max;if(a.min&&a.max)R.copyFromArray(a.min),E.copyFromArray(a.max);else{var M=t._tempVector3;R.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),E.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),tR.min(R,M,R),tR.max(E,M,E)}}y&&(R.scale(c),E.scale(c))}});v.push(c)},u=o.accessors,d=a.attributes,h=a.targets,_=a.indices,f=a.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=l1.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,i,a,h)),Promise.all(v).then(function(){return n.uploadData(!s),n})})},t._getBlendShapeData=function(e,t,n){return l1.getAccessorBuffer(e,t.bufferViews,n).then(function(e){var t,r=e.data,i=e.interleaved?(null!=(t=n.byteOffset)?t:0)%e.stride:0,a=n.count,o=n.normalized,s=n.componentType;return{vertices:l1.bufferToVector3Array(r,i,a,o,s),restoreInfo:new ch(e.restoreInfo,i,a,o,s)}})},t._createBlendShape=function(e,t,n,r,i,a){for(var o,s=e.glTF,l=s.accessors,c=r.extras?r.extras.targetNames:null,u=[],d=a.length,h=Array(d),_=0;_<d;_++)o=this,function(t){var n={};h[t]=n;var r=c?c[t]:"blendShape"+t,a=i.targets[t],d=a.NORMAL,_=a.TANGENT,f=void 0!==d,p=void 0!==_;u.push(Promise.all([o._getBlendShapeData(e,s,l[a.POSITION]),f?o._getBlendShapeData(e,s,l[d]):null,p?o._getBlendShapeData(e,s,l[_]):null]).then(function(e){var t=e[0],i=e[1],a=e[2],o=new iC(r);o.addFrame(1,t.vertices,f?i.vertices:null,p?a.vertices:null),n.blendShape=o,n.restoreInfo=new cd(o,t.restoreInfo,f?i.restoreInfo:null,p?null==a?void 0:a.restoreInfo:null)}))}(_);return Promise.all(u).then(function(){for(var e,r=lR(h);!(e=r()).done;){var i=e.value;t.addBlendShape(i.blendShape),n.blendShapes.push(i.restoreInfo)}})},t}(cp),e.GLTFMeshParser._tempVector3=new tR,e.GLTFMeshParser=la([l0(lJ.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}lr(n,t);var r=n.prototype;return r.parse=function(e,t){var n,r=e.glTF,i=r.scenes,a=r.scene,o=e.glTFResource,s=i[t],l=s.extensions,c=o.engine,u=s.nodes||[];if(1===u.length)n=e.get(lJ.Entity,u[0]);else{(n=new iQ(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=e.get(lJ.Entity,u[d]);n.addChild(h)}}(void 0===a?0:a)===t&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(e,u[f]));return Promise.all(_).then(function(){return cp.executeExtensionsAdditiveAndParse(l,e,n,s),n})},r._parseEntityComponent=function(e,t){var n,r=this,i=e.glTF,a=e.glTFResource,o=i.nodes[t],s=o.camera,l=o.mesh,c=e.get(lJ.Entity,t);return void 0!==s&&this._createCamera(a,i.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 i=0;i<n.length;i++)t.push(r._parseEntityComponent(e,n[i]));return Promise.all(t)})},r._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===lW.ORTHOGRAPHIC){var l=i.xmag,c=i.ymag,u=i.zfar,d=i.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===lW.PERSPECTIVE){var h=a.aspectRatio,_=a.yfov,f=a.zfar,p=a.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 i,a=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(lJ.Material,null!=(i=c[_].material)?i:-1);return Promise.all([t.get(lJ.Mesh,o),void 0!==s&&t.get(lJ.Skin,s),Promise.all(h)]).then(function(n){for(var i=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=i[n],_=void 0;if(o||d){var f=r.addComponent(i$);f.mesh=h,o&&(a._computeLocalBounds(f,h,o.bones,o.rootBone,o.inverseBindMatrices),f.skin=o),d&&(f.blendShapeWeights=new Float32Array(d)),_=f}else(_=r.addComponent(iF)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),cp.executeExtensionsAdditiveAndParse(u.extensions,t,_,u)}(l)})},r._computeLocalBounds=function(e,t,n,r,i){var a=n.indexOf(r);if(-1!==a)tM.transform(t.bounds,i[a],e.localBounds);else{var o=new tB(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(n,i,r,o);0!==s?(tB.multiplyScalar(o,1/s,o),tM.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},r._computeApproximateBindMatrix=function(e,t,n,r){for(var i=0,a=n.children,o=0,s=a.length;o<s;o++){var l=a[o],c=e.indexOf(l);-1!==c?(tB.add(r,t[c],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},n}(cp),e.GLTFSceneParser=la([l0(lJ.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.parse=function(e,t){var n=this,r=e.glTF,i=r.skins[t],a=i.inverseBindMatrices,o=i.skeleton,s=i.joints,l=i.name,c=s.length,u=new iJ(void 0===l?"SKIN_"+t:l);u.inverseBindMatrices.length=c;var d=Array(c),h=r.accessors[a];return Promise.resolve(l1.getAccessorBuffer(e,r.bufferViews,h).then(function(t){for(var r=e.get(lJ.Entity),i=t.data,a=0;a<c;a++){var l=new tB;l.copyFromArray(i,16*a),u.inverseBindMatrices[a]=l;var h=r[s[a]];d[a]=h,u.joints[a]=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={},i=lR(e);!(n=i()).done;){for(var a=n.value,o=[],s=t[a];s;)o.unshift(s),s=s.parent;r[a]=o}for(var l=null,c=0;;c++){var u=r[e[0]];if(c>=u.length)return l;for(var d=u[c],h=1,_=e.length;h<_;h++)if(c>=(u=r[e[h]]).length||d!==u[c])return l;l=d}},t}(cp),e.GLTFSkinParser=la([l0(lJ.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.parse=function(e,n){var r=e.glTF.textures[n],i=e.glTFResource,a=r.sampler,o=r.source,s=r.name,l=r.extensions,c=cp.executeExtensionsCreateAndParse(l,e,r,n);return c||(c=t._parseTexture(e,void 0===o?0:o,n,a,s)),Promise.resolve(c).then(function(t){return cp.executeExtensionsAdditiveAndParse(l,e,t,r),t._associationSuperResource(i),t})},t._parseTexture=function(e,t,n,r,i){var a,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&&l1.getSamplerInfo(s.samplers[r]);if(d){var g=d.lastIndexOf("."),v=d.substring(g+1).startsWith("ktx")?i6.KTX:i6.Texture2D;a=l.resourceManager.load({url:nR.resolveAbsoluteUrl(c,d),type:v,params:{mipmap:null==m?void 0:m.mipmap}}).onProgress(void 0,e._onTaskDetail).then(function(e){return e.name=i||f||e.name||"texture_"+n,p&&l1.parseSampler(e,m),e}),e._addTaskCompletePromise(a)}else{var y=s.bufferViews[h];a=e.get(lJ.Buffer).then(function(t){var r=new Uint8Array(t[y.buffer],y.byteOffset,y.byteLength);return l1.loadImageBuffer(r,_).then(function(t){var r=new nd(l,t.width,t.height,void 0,null==m?void 0:m.mipmap);r.setImageSource(t),r.generateMipmaps(),r.name=i||f||"texture_"+n,p&&l1.parseSampler(r,m);var a=new co(r,y,_);return e.contentRestorer.bufferTextures.push(a),r})})}return a},t}(cp),e.GLTFTextureParser._wrapMap=((tv={})[lq.CLAMP_TO_EDGE]=nt.Clamp,tv[lq.MIRRORED_REPEAT]=nt.Mirror,tv[lq.REPEAT]=nt.Repeat,tv),e.GLTFTextureParser=la([l0(lJ.Texture)],e.GLTFTextureParser),e.GLTFValidator=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.parse=function(e){var t=e.glTF,n=t.asset.version,r=t.extensionsUsed,i=t.extensionsRequired,a=Number(n);if(!(a>=2&&a<3))throw"Only support glTF 2.x.";if(r){nl.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++){var s=r[o];cp.hasExtensionParser(s)||nl.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(i){nl.info("extensionsRequired: "+i);for(var l=0;l<i.length;l++){var c=i[l];cp.hasExtensionParser(c)||nl.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},t}(cp),e.GLTFValidator=la([l0(lJ.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.parse=function(e,t){var n=e.glTF.bufferViews[t],r=n.extensions,i=n.byteOffset,a=void 0===i?0:i,o=n.byteLength,s=n.buffer;return r?cp.executeExtensionsCreateAndParse(r,e,n):e.get(lJ.Buffer,s).then(function(e){return new Uint8Array(e,a,o)})},t}(cp),e.GLTFBufferViewParser=la([l0(lJ.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.parse=function(e){var t=this;return e.needAnimatorController?e.get(lJ.Animation).then(function(n){return Promise.resolve(t._createAnimatorController(e,n))}):Promise.resolve(null)},n._createAnimatorController=function(e,t){var n=new oK(e.glTFResource.engine),r=new oZ("layer"),i=new oJ;if(n.addLayer(r),r.stateMachine=i,t)for(var a=0;a<t.length;a++){var o=t[a],s=o.name,l=i.makeUniqueStateName(s);l!==s&&console.warn("AnimatorState name is existed, name: "+s+" reset to "+l),i.addState(l).clip=o}return n},t}(cp),e.GLTFAnimatorControllerParser=la([l0(lJ.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.initialize=function(e,t){var n,r,i,a=null!=(i=null==(n=t.glTFLoader)?void 0:n.meshOpt)?i:null==(r=t.glTF)?void 0:r.meshOpt;return a?cg().then(function(e){e.useWorkers(a.workerCount)}):Promise.resolve()},n.load=function(e,t){var n=e.params,r=new lY(new lk(t.engine,e.url),t,lt({keepMeshData:!1},n));return new at(function(e,t,n,i){r._setTaskCompleteProgress=n,r._setTaskDetailProgress=i,r.parse().then(e).catch(t)})},t.release=function(){ty&&cg().then(function(e){e.release()})},t}(ox),e.GLTFLoader=la([as(i6.GLTF,["gltf","glb"])],e.GLTFLoader);var cv=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t,n)||this).prefabResource=r,i}lr(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 i=new lE(e,n),a=new t(r,new ly(e,lv.Prefab,i),i);return a.start(),a.promise.then(function(){return i})},t}(lM),cy=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){var n=t.engine;return new at(function(r,i){t._request(e.url,lt({},e,{type:"json"})).then(function(t){cv.parse(n,e.url,t).then(r).catch(i)})})},t}(ox);cy=la([as(i6.Prefab,["prefab"])],cy);var cx=Math.PI,cb=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,n){return new at(function(r,i){var a=n.engine,o=lt({},e,{type:"arraybuffer"});n._request(e.url,o).then(function(n){var i=t._setTextureByBuffer(a,n);a.resourceManager.addContentRestorer(new cC(i,e.url,o)),r(i)}).catch(i)})},t._setTextureByBuffer=function(e,n,r){var i=new Uint8Array(n),a=t._parseHeader(i),o=a.width,s=a.height,l=a.dataPosition,c=s>>1;r||(r=new n_(e,c));for(var u=t._readPixels(i.subarray(l),o,s),d=t._convertToCubemap(u,o,s,c),h=0;h<6;h++)r.setPixelBuffer(t5.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,i){for(var a=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,u=0;u<e;u++){for(var 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,i);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;a[m]=p.r,a[m+1]=p.g,a[m+2]=p.b,a[m+3]=p.a,d.add(o),h.add(s)}c+=l}return a},t._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-cx;)i+=2*cx;for(;i>cx;)i-=2*cx;var o=i/cx,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/cx*r);l<0?l=0:l>=r&&(l=r-1);var c=(r-l-1)*n*4+4*s;return new tV(t[c],t[c+1],t[c+2],t[c+3])},t._readStringLine=function(e,t){for(var n="",r="",i=t;i<e.length-t&&"\n"!=(r=String.fromCharCode(e[i]));i++)n+=r;return n},t._parseHeader=function(e){var t=0,n=0,r=this._readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var i=!1,a=!1,o=0;do o+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this._readStringLine(e,o))?a=!0:0==r.length&&(i=!0);while(!i);if(!a)throw"HDR Bad header format, unsupported FORMAT";o+=r.length+1,r=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!s||s.length<3)throw"HDR Bad header format, no size";if(n=parseInt(s[2]),t=parseInt(s[1]),n<8||n>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:o+=r.length+1}},t._readPixels=function(e,t,n){for(var r=e.byteLength,i=new Uint8Array(4*t*n),a=0,o=0,s=4*t,l=new Uint8Array(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;i[a]=l[y+x],x+=t,i[a+1]=l[y+x],x+=t,i[a+2]=l[y+x],x+=t,i[a+3]=l[y+x],a+=4}c--}return i},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}(ox);cb._rightBottomBack=new tR(1,-1,-1),cb._rightBottomFront=new tR(1,-1,1),cb._rightUpBack=new tR(1,1,-1),cb._rightUpFront=new tR(1,1,1),cb._leftBottomBack=new tR(-1,-1,-1),cb._leftBottomFront=new tR(-1,-1,1),cb._leftUpBack=new tR(-1,1,-1),cb._leftUpFront=new tR(-1,1,1),cb._faceRight=[cb._rightBottomBack,cb._rightBottomFront,cb._rightUpBack,cb._rightUpFront],cb._faceLeft=[cb._leftBottomFront,cb._leftBottomBack,cb._leftUpFront,cb._leftUpBack],cb._faceUp=[cb._leftBottomFront,cb._rightBottomFront,cb._leftBottomBack,cb._rightBottomBack],cb._faceBottom=[cb._leftUpBack,cb._rightUpBack,cb._leftUpFront,cb._rightUpFront],cb._faceFront=[cb._leftBottomBack,cb._rightBottomBack,cb._leftUpBack,cb._rightUpBack],cb._faceBack=[cb._rightBottomFront,cb._leftBottomFront,cb._rightUpFront,cb._leftUpFront],cb._tempVector3=new tR,cb._temp2Vector3=new tR,cb._temp3Vector3=new tR,cb._temp4Vector3=new tR,cb._temp5Vector3=new tR,cb=la([as(i6.HDR,["hdr"])],cb);var cC=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return lr(t,e),t.prototype.restoreContent=function(){var e=this;return new at(function(t,n){ai(e.url,e.requestConfig).then(function(n){cb._setTextureByBuffer(e.resource.engine,n,e.resource),t(e.resource)}).catch(n)})},t}(t4),cS=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return t._request(e.url,lt({},e,{type:"json"}))},t}(ox);cS=la([as(i6.JSON,["json"],!1)],cS);var cT={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 i=Uint32Array.BYTES_PER_ELEMENT,a=new DataView(e,12,13*i),o=0x4030201===a.getUint32(0,!0),s={buffer:e,glType:a.getUint32(1*i,o),glTypeSize:a.getUint32(2*i,o),glFormat:a.getUint32(3*i,o),glInternalFormat:a.getUint32(4*i,o),glBaseInternalFormat:a.getUint32(5*i,o),pixelWidth:a.getUint32(6*i,o),pixelHeight:a.getUint32(7*i,o),pixelDepth:a.getUint32(8*i,o),numberOfArrayElements:a.getUint32(9*i,o),numberOfFaces:a.getUint32(10*i,o),numberOfMipmapLevels:a.getUint32(11*i,o),bytesOfKeyValueData:a.getUint32(12*i,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,i=e.pixelWidth,a=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,r,1)[0];r+=4;for(var c=0;c<e.numberOfFaces;c++){var u=new Uint8Array(e.buffer,r,l);n.push({data:u,width:i,height:a}),r+=l,r+=3-(l+3)%4}i=Math.max(1,.5*i),a=Math.max(1,.5*a)}return n}(s,!0)),r&&(s.engineFormat=function(e){switch(e){case sW.RGB_S3TC_DXT1_EXT:return t7.BC1;case sW.RGBA_S3TC_DXT5_EXT:return t7.BC3;case sW.RGBA_BPTC_UNORM_EXT:return t7.BC7;case sW.RGB_ETC1_WEBGL:return t7.ETC1_RGB;case sW.RGB8_ETC2:return t7.ETC2_RGB;case sW.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return t7.ETC2_RGBA5;case sW.RGBA8_ETC2_EAC:return t7.ETC2_RGBA8;case sW.RGB_PVRTC_2BPPV1_IMG:return t7.PVRTC_RGB2;case sW.RGBA_PVRTC_2BPPV1_IMG:return t7.PVRTC_RGBA2;case sW.RGB_PVRTC_4BPPV1_IMG:return t7.PVRTC_RGB4;case sW.RGBA_PVRTC_4BPPV1_IMG:return t7.PVRTC_RGBA4;case sW.RGBA_ASTC_4X4_KHR:return t7.ASTC_4x4;case sW.RGBA_ASTC_5X5_KHR:return t7.ASTC_5x5;case sW.RGBA_ASTC_6X6_KHR:return t7.ASTC_6x6;case sW.RGBA_ASTC_8X8_KHR:return t7.ASTC_8x8;case sW.RGBA_ASTC_10X10_KHR:return t7.ASTC_10x10;case sW.RGBA_ASTC_12X12_KHR:return t7.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+sW[e])}}(s.glInternalFormat)),s}};function cA(e){var t=cT.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var cR=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return new at(function(n,r){Promise.all(e.urls.map(function(n){return t._request(n,lt({},e,{type:"arraybuffer"}))})).then(function(e){for(var r=function(e){for(var t,n,r,i,a=[],o=0;o<e.length;o++){var s=cT.parse(e[o],1,!0,!0);a.push(s.mipmaps),0===o&&(r=s.pixelWidth,i=s.pixelHeight,t=s.glInternalFormat,n=s.engineFormat)}return{mipmapsFaces:a,engineFormat:n,internalFormat:t,width:r,height:i}}(e),i=r.width,a=r.mipmapsFaces,o=r.engineFormat,s=a[0].length>1,l=new n_(t.engine,i,o,s),c=0;c<6;c++)for(var u=a[c].length,d=0;d<u;d++){var h=a[c][d],_=h.data,f=h.width,p=h.height;l.setPixelBuffer(t5.PositiveX+c,_,d,0,0,f,p)}n(l)}).catch(function(e){r(e)})})},t}(ox);cR=la([as(i6.KTXCube,[])],cR);var cE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return new at(function(n,r){t._request(e.url,lt({},e,{type:"arraybuffer"})).then(function(e){for(var r=cA(e),i=r.width,a=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new nd(t.engine,i,a,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}(ox);cE=la([as(i6.KTX,["ktx"])],cE);var cM=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new at(function(r,i){t._request(e.url,lt({},e,{type:"json"})).then(function(e){var i=t.engine,a=e.shaderRef,o=e.shader,s=rl.find(o);s?r(n._getMaterialByShader(e,s,i)):a&&r(t.getResourceByRef(a).then(function(t){return n._getMaterialByShader(e,t,i)}))}).catch(i)})},n._getMaterialByShader=function(e,t,n){var r=function(e){var t=a[e],r=t.type,i=t.value;switch(r){case lC.Vector2:u.setVector2(e,new tO(i.x,i.y));break;case lC.Vector3:u.setVector3(e,new tR(i.x,i.y,i.z));break;case lC.Vector4:u.setVector4(e,new tN(i.x,i.y,i.z,i.w));break;case lC.Color:u.setColor(e,new tV(i.r,i.g,i.b,i.a));break;case lC.Float:u.setFloat(e,i);break;case lC.Texture:c.push(n.resourceManager.getResourceByRef(i).then(function(t){u.setTexture(e,t)}));break;case lC.Boolean:u.setInt(e,i?1:0);break;case lC.Integer:u.setInt(e,Number(i))}},i=e.name,a=e.shaderData,o=e.macros,s=e.renderState,l=new iu(n,t);l.name=i;var c=[],u=l.shaderData;for(var d in a)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":li(r))==="object")for(var i in r)e(t[n],i,r[i]);else t[n]=r}(l,"renderState",s),Promise.all(c).then(function(){return l})},t}(ox);cM=la([as(i6.Material,["json"])],cM);var cw=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return new at(function(n,r){t._request(e.url,lt({},e,{type:"arraybuffer"})).then(function(e){return lP(e,t.engine)}).then(function(e){n(e)}).catch(r)})},t}(ox);cw=la([as(i6.Mesh,["mesh"])],cw);var cP=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){var n=t.engine;return t._request(e.url,lt({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return iX.createSubdivisionSurfaceSphere(n,e.sphereRadius,e.sphereStep);case"capsule":return iX.createCapsule(n,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return iX.createCone(n,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return iX.createCuboid(n,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return iX.createCylinder(n,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return iX.createPlane(n,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return iX.createTorus(n,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},t}(ox);cP=la([as(i6.PrimitiveMesh,["mesh"],!1)],cP);var cF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){var n=t.engine;return new at(function(r,i){t._request(e.url,lt({},e,{type:"json"})).then(function(e){return n.resourceManager.initVirtualResources(e.files),t.load({type:i6.Scene,url:e.scene}).then(function(e){n.sceneManager.activeScene=e,r()})}).catch(i)})},t}(ox);cF=la([as(i6.Project,["proj"],!1)],cF);var cL=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new at(function(r,i){var a=t._getRemoteUrl(e.url);n._registerFont(a,a).then(function(){r(new ny(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},n._registerFont=function(e,t){return lN(function(){var n;return lo(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}(ox);cL=la([as(i6.SourceFont,["ttf","otf","woff"],!1)],cL);var cD=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._tempRect=new tk,t._tempVec2=new tO,t._tempVec4=new tN,t}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new at(function(r,i,a,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=t._request(e.url,lt({},e,{type:"json"}));l.push(c),c.then(function(a){var o=a.atlasItems,s=a.mipmap,c=a.anisoLevel,u=a.filterMode,d=a.wrapModeU,h=a.wrapModeV,_=a.format,f=o?o.length:0,p=t.engine,m=new nS(p);if(f<=0){r(m);return}l.length=0;for(var g=0;g<f;g++)!function(r){var a,f=o[r];if(f.img)l.push(t.load({url:nR.resolveAbsoluteUrl(e.url,f.img),type:null!=(a=f.type)?a:i6.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(i));else for(var g=0;g<f.sprites.length;g++)m._addSprite(n._makeSprite(p,f.sprites[g]))}(g);at.all(l).then(function(){r(m)}).catch(i)}).catch(i)})},n._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new nL(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(a.x*d,a.y*h,a.w*d,a.h*h),i){var _=i.x,f=i.y,p=i.z,m=i.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}(ox);cD=la([as(i6.SpriteAtlas,["atlas"],!1)],cD);var cB=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return t._request(e.url,lt({},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 nL(e.engine,n,t.region,t.pivot,t.border),i=t.width,a=t.height;return isNaN(i)||(r.width=i),isNaN(a)||(r.height=a),r}):new at(function(n){var r=new nL(e.engine,null,t.region,t.pivot,t.border),i=t.width,a=t.height;isNaN(i)||(r.width=i),isNaN(a)||(r.height=a),n(r)})},t}(ox);cB=la([as(i6.Sprite,["sprite"],!1)],cB);var cI=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return lr(t,e),t.prototype.restoreContent=function(){var e=this;return ai(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},t}(t4),cO=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return new at(function(n,r,i,a){var o=e.url,s=lt({},e,{type:"image"});t._request(o,s).onProgress(i,a).then(function(r){var i,a=null!=(i=e.params)?i:{},l=a.format,c=a.mipmap,u=a.anisoLevel,d=a.wrapModeU,h=a.wrapModeV,_=a.filterMode,f=new nd(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 cI(f,o,s)),n(f)}).catch(function(e){r(e)})})},t}(ox);cO=la([as(i6.Texture2D,["png","jpg","webp","jpeg"])],cO);var cN=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).urls=n,i.requestConfig=r,i}return lr(t,e),t.prototype.restoreContent=function(){var e=this;return new at(function(t,n){Promise.all(e.urls.map(function(t){return ai(t,e.requestConfig)})).then(function(n){for(var r=e.resource,i=0;i<6;i++)r.setImageSource(t5.PositiveX+i,n[i],0);r.generateMipmaps(),t(r)}).catch(function(e){n(e)})})},t}(t4),cV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return new at(function(n,r){var i=e.urls,a=lt({},e,{type:"image"});Promise.all(i.map(function(e){return t._request(e,a)})).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 n_(t.engine,o),l=0;l<6;l++)s.setImageSource(t5.PositiveX+l,e[l],0);s.generateMipmaps(),t.addContentRestorer(new cN(s,i,a)),n(s)}).catch(function(e){r(e)})})},t}(ox);cV=la([as(i6.TextureCube,[""])],cV);var ck=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return new at(function(n,r){var i=e.url,a=lt({},e,{type:"arraybuffer"});t._request(i,a).then(function(e){var a=new sz(t.engine);sU.getContext().decodeAudioData(e).then(function(e){if(a._setAudioSource(e),0!==i.indexOf("data:")){var t=i.lastIndexOf("/");a.name=i.substring(t+1)}n(a)}).catch(function(e){r(e)})})})},t}(ox);ck=la([as(i6.Audio,["mp3","ogg","wav"])],ck);var cz=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,n){var r=e.url;return n._request(r,lt({},e,{type:"text"})).then(function(e){return n1.registerInclude(r.substring(1),e),t._loadChunksInCode(e,r,n)})},t._loadChunksInCode=function(e,n,r){for(var i,a=[],o=e.matchAll(t._shaderIncludeRegex),s=lR(o);!(i=s()).done;){var l=i.value,c=nR.resolveAbsoluteUrl(n,l[1]);n0[c.substring(1)]||a.push(c)}return Promise.all(a.map(function(e){return r.load({type:"ShaderChunk",url:e})}))},t}(ox);cz._shaderIncludeRegex=/#include\s+"([./][^\\"]+)"/gm,cz=la([as("ShaderChunk",["glsl"])],cz);var cU=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}lr(t,e);var n=t.prototype;return n.load=function(e,t){var n=this,r=e.url;return t._request(r,lt({},e,{type:"text"})).then(function(e){var i=n._getBuiltinShader(e);return i?rl.find(i):cz._loadChunksInCode(e,r,t).then(function(){var t=rl.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}(ox);cU._builtinRegex=/^\s*\/\/\s*@builtin\s+(\w+)/,cU=la([as(i6.Shader,["gs","gsl"])],cU);var cG=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){return t._request(e.url,lt({},e,{type:"json"})).then(function(e){var t=new aw;return t.bounciness=e.bounciness,t.dynamicFriction=e.dynamicFriction,t.staticFriction=e.staticFriction,t.bounceCombine=e.bounceCombine,t.frictionCombine=e.frictionCombine,t})},t}(ox);cG=la([as(i6.PhysicsMaterial,["mesh"])],cG);var cH=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.load=function(e,t){var n=t.engine;return new at(function(r,i){t._request(e.url,lt({},e,{type:"json"})).then(function(e){return lw.parse(n,e).then(function(n){var i,a,o=[],s=e.scene.ambient;if(s){var l=s.specularMode===lS.Custom,c=s.diffuseMode===oc.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 rV.SolidColor:n.background.solidColor.copyFrom(u.color);break;case rV.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 nl.warn("Sky background mode requires skyMesh and skyMaterial");break;case rV.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!=(i=p.shadowTwoCascadeSplits)?i:n.shadowTwoCascadeSplits,p.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(p.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(a=p.shadowFadeBorder)?a:n.shadowFadeBorder);var m=e.scene.fog;return 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)),e.scene.postProcess&&nl.warn("Post Process is not supported in scene yet, please add PostProcess component in entity instead."),Promise.all(o).then(function(){r(n)})})}).catch(i)})},t}(ox);cH=la([as(i6.Scene,["scene"],!0)],cH),lx.registerCustomParseComponent("TextRenderer",/*#__PURE__*/lN(function(e,t){var n;return lo(this,function(r){return(n=t.props).font||(e.font=ny.createFromOS(e.engine,n.fontFamily||"Arial")),[2,e]})}));var cW=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.additiveParse=function(e,t,n){var r,i=e.glTF.extensions.KHR_lights_punctual.lights[n.light],a=i.color,o=i.intensity,s=i.type,l=i.range,c=i.spot,u=e.glTFResource;if("directional"===s?r=t.addComponent(oh):"point"===s?r=t.addComponent(o_):"spot"===s&&(r=t.addComponent(of)),a&&r.color.set(a[0],a[1],a[2],1),r.intensity=void 0===o?1:o,l&&!lT(r,oh)&&(r.distance=l),c&&lT(r,of)){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}(c_);cW=la([cm("KHR_lights_punctual",cf.AdditiveParse)],cW);var cj=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.additiveParse=function(t,n,r){var i=r.clearcoatFactor,a=r.clearcoatTexture,o=r.clearcoatRoughnessFactor,s=r.clearcoatRoughnessTexture,l=r.clearcoatNormalTexture;n.clearCoat=void 0===i?0:i,n.clearCoatRoughness=void 0===o?0:o,a&&(e.GLTFMaterialParser._checkOtherTextureTransform(a,"Clear coat"),t.get(lJ.Texture,a.index).then(function(e){n.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(lJ.Texture,s.index).then(function(e){n.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(lJ.Texture,l.index).then(function(e){n.clearCoatNormalTexture=e}))},n}(c_);cj=la([cm("KHR_materials_clearcoat",cf.AdditiveParse)],cj);var cX=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},t}(c_);cX=la([cm("KHR_materials_ior",cf.AdditiveParse)],cX);var cK=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.createAndParse=function(t,n,r){var i=new iv(t.glTFResource.engine),a=n.diffuseFactor,o=n.diffuseTexture,s=n.specularFactor,l=n.glossinessFactor,c=n.specularGlossinessTexture;return a&&(i.baseColor=new tV(tV.linearToGammaSpace(a[0]),tV.linearToGammaSpace(a[1]),tV.linearToGammaSpace(a[2]),a[3])),o&&t.get(lJ.Texture,o.index).then(function(e){i.baseTexture=e,cp.executeExtensionsAdditiveAndParse(o.extensions,t,i,o)}),s&&(i.specularColor=new tV(tV.linearToGammaSpace(s[0]),tV.linearToGammaSpace(s[1]),tV.linearToGammaSpace(s[2]))),void 0!==l&&(i.glossiness=l),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"Specular glossiness"),t.get(lJ.Texture,c.index).then(function(e){i.specularGlossinessTexture=e})),i.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,i,r),i},n}(c_);cK=la([cm("KHR_materials_pbrSpecularGlossiness",cf.CreateAndParse)],cK);var cq=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.additiveParse=function(t,n,r){var i=r.sheenColorFactor,a=r.sheenColorTexture,o=r.sheenRoughnessFactor,s=r.sheenRoughnessTexture;i&&n.sheenColor.set(tV.linearToGammaSpace(i[0]),tV.linearToGammaSpace(i[1]),tV.linearToGammaSpace(i[2]),void 0),n.sheenRoughness=void 0===o?0:o,a&&(e.GLTFMaterialParser._checkOtherTextureTransform(a,"Sheen texture"),t.get(lJ.Texture,a.index).then(function(e){n.sheenColorTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"SheenRoughness texture"),t.get(lJ.Texture,s.index).then(function(e){n.sheenRoughnessTexture=e}))},n}(c_);cq=la([cm("KHR_materials_sheen",cf.AdditiveParse)],cq);var cY=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.additiveParse=function(t,n,r){var i=r.transmissionFactor,a=r.transmissionTexture;n.transmission=void 0===i?0:i,a&&(e.GLTFMaterialParser._checkOtherTextureTransform(a,"Transmission texture"),t.get(lJ.Texture,a.index).then(function(e){n.transmissionTexture=e}))},n}(c_);cY=la([cm("KHR_materials_transmission",cf.AdditiveParse)],cY);var cQ=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.createAndParse=function(t,n,r){var i=new iy(t.glTFResource.engine);return i.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,i,r),i},n}(c_);cQ=la([cm("KHR_materials_unlit",cf.CreateAndParse)],cQ);var cJ=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.additiveParse=function(e,t,n){var r=e.glTF.extensions.KHR_materials_variants.variants,i=e.glTFResource,a=n.mappings;i._extensionsData||(i._extensionsData={});var o=[];i.extensionsData.variants=o;for(var s=0;s<a.length;s++)!function(n){var i=a[n],s=i.material,l=i.variants;e.get(lJ.Material,s).then(function(e){o.push({renderer:t,material:e,variants:l.map(function(e){return r[e].name})})})}(s)},t}(c_);cJ=la([cm("KHR_materials_variants",cf.AdditiveParse)],cJ);var cZ=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.additiveParse=function(t,n,r){var i=r.thicknessFactor,a=r.thicknessTexture,o=r.attenuationDistance,s=r.attenuationColor;n.thickness=void 0===i?0:i,n.attenuationDistance=void 0===o?1/0:o,s&&n.attenuationColor.set(tV.linearToGammaSpace(s[0]),tV.linearToGammaSpace(s[1]),tV.linearToGammaSpace(s[2]),void 0),a&&(e.GLTFMaterialParser._checkOtherTextureTransform(a,"Thickness texture"),t.get(lJ.Texture,a.index).then(function(e){n.thicknessTexture=e}))},n}(c_);cZ=la([cm("KHR_materials_volume",cf.AdditiveParse)],cZ);var c$=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t}(c_);c$=la([cm("KHR_mesh_quantization",cf.AdditiveParse)],c$);var c0=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.createAndParse=function(t,n,r){return lN(function(){var i,a,o,s,l,c,u,d,h,_,f,p,m,g,v,y;return lo(this,function(x){return(i=t.glTF,o=(a=t.glTFResource).engine,s=a.url,l=r.sampler,c=r.name,u=n.source,h=(d=i.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&l1.getSamplerInfo(i.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:nR.resolveAbsoluteUrl(s,h),type:i6.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&l1.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=i.bufferViews[_],[2,t.get(lJ.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,i=t.targetFormat,a=t.params;return e.KTX2Loader._createTextureByBuffer(n,r,i,a)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&l1.parseSampler(e,m);var n=new co(e,y,f);return t.contentRestorer.bufferTextures.push(n),e})})])})})()},n}(c_);c0=la([cm("KHR_texture_basisu",cf.CreateAndParse)],c0);var c1=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.offset,i=n.rotation,a=n.scale,o=n.texCoord;r&&(t.tilingOffset.z=r[0],t.tilingOffset.w=r[1]),a&&(t.tilingOffset.x=a[0],t.tilingOffset.y=a[1]),i&&nl.warn("rotation in KHR_texture_transform is not supported now"),o&&nl.warn("texCoord in KHR_texture_transform is not supported now")},t}(c_);c1=la([cm("KHR_texture_transform",cf.AdditiveParse)],c1);var c2=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.createAndParse=function(e,t){var n=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(n),n},t}(c_);c2=la([cm("GALACEAN_materials_remap",cf.CreateAndParse)],c2);var c3=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new ow;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},t}(c_);c3=la([cm("GALACEAN_animation_event",cf.AdditiveParse)],c3);var c4=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lr(t,e),t.prototype.createAndParse=function(e,t){return e.get(lJ.Buffer,t.buffer).then(function(e){return cg().then(function(n){return n.decodeGltfBuffer(t.count,t.byteStride,new Uint8Array(e,t.byteOffset,t.byteLength),t.mode,t.filter)})})},t}(c_);c4=la([cm("EXT_meshopt_compression",cf.CreateAndParse)],c4);var c8=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.additiveParse=function(t,n,r){var i=r.anisotropyStrength,a=r.anisotropyRotation,o=r.anisotropyTexture;n.anisotropy=void 0===i?0:i,n.anisotropyRotation=void 0===a?0:a,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(lJ.Texture,o.index).then(function(e){n.anisotropyTexture=e}))},n}(c_);c8=la([cm("KHR_materials_anisotropy",cf.AdditiveParse)],c8);var c5=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return lr(n,t),n.prototype.additiveParse=function(t,n,r){var i=r.iridescenceFactor,a=r.iridescenceTexture,o=r.iridescenceIor,s=r.iridescenceThicknessMinimum,l=r.iridescenceThicknessMaximum,c=r.iridescenceThicknessTexture;n.iridescence=void 0===i?0:i,n.iridescenceIOR=void 0===o?1.3:o,n.iridescenceThicknessRange.set(void 0===s?100:s,void 0===l?400:l),a&&(e.GLTFMaterialParser._checkOtherTextureTransform(a,"Iridescence texture"),t.get(lJ.Texture,a.index).then(function(e){n.iridescenceTexture=e})),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"IridescenceThickness texture"),t.get(lJ.Texture,c.index).then(function(e){n.iridescenceThicknessTexture=e}))},n}(c_);c5=la([cm("KHR_materials_iridescence",cf.AdditiveParse)],c5);var c9=/*#__PURE__*/function(t){function n(){var e;if((e=t.call(this)||this)._supportWebP=!1,am._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 lr(n,t),n.prototype.createAndParse=function(t,n,r,i){var a=this;return lN(function(){var o,s,l,c,u;return lo(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,a._supportWebP?o:c,i,s,u)]})})()},n}(c_);c9=la([cm("EXT_texture_webp",cf.CreateAndParse)],c9);var c6="1.4.0-alpha.2";for(var c7 in console.log("Galacean engine version: "+c6),sH)ox.registerClass(c7,sH[c7]);e.AccessorType=lU,e.AmbientLight=ou,e.AnimationClip=oP,e.AnimationClipCurveBinding=oM,e.AnimationCurve=oL,e.AnimationEvent=ow,e.Animator=oj,e.AnimatorCondition=ok,e.AnimatorConditionMode=oD,e.AnimatorController=oK,e.AnimatorControllerLayer=oZ,e.AnimatorControllerParameter=oX,e.AnimatorCullingMode=oB,e.AnimatorLayerBlendingMode=oI,e.AnimatorLayerMask=o1,e.AnimatorState=oQ,e.AnimatorStateMachine=oJ,e.AnimatorStateTransition=oz,e.AssetPromise=at,e.AssetType=i6,e.AudioClip=sz,e.AudioManager=sU,e.AudioSource=sG,e.Background=oa,e.BackgroundMode=rV,e.BackgroundTextureFillMode=rk,e.BaseMaterial=id,e.BasicRenderPipeline=r1,e.BlendFactor=nD,e.BlendMode=il,e.BlendOperation=nB,e.BlendShape=iC,e.BlendShapeFrame=ix,e.BlendState=rr,e.BlinnPhongMaterial=ih,e.Blitter=rj,e.BloomDownScaleMode=a0,e.BloomEffect=a1,e.BoolUpdateFlag=rm,e.BoundingBox=tM,e.BoundingFrustum=tF,e.BoundingSphere=tE,e.BoxColliderShape=aU,e.BoxShape=sA,e.Buffer=ie,e.BufferBindFlag=io,e.BufferInfo=lQ,e.BufferMesh=iP,e.BufferReader=lc,e.BufferUsage=r6,e.BufferUtil=ii,e.Burst=sb,e.CameraClearFlags=rF,e.CameraType=rL,e.Canvas=or,e.CapsuleColliderShape=aW,e.CharacterController=aS,e.CircleShape=sE,e.ClearableObjectPool=oe,e.CloneManager=t1,e.ColliderShape=az,e.ColliderShapeUpAxis=aF,e.Collision=ax,e.CollisionDetectionMode=aA,e.CollisionUtil=tw,e.Color=tV,e.ColorOverLifetimeModule=sl,e.ColorSpace=n4,e.ColorWriteMask=nI,e.CompareFunction=nO,e.Component=rh,e.ConeEmitType=sw,e.ConeShape=sM,e.ContactPoint=ay,e.ContainmentType=tx,e.ContentRestorer=t4,e.ControllerCollisionFlag=aL,e.ControllerNonWalkableMode=aC,e.CubeProbe=sk,e.CullMode=nN,e.CurveKey=sp,e.DataType=nZ,e.DependentMode=rp,e.DepthState=ri,e.DepthTextureMode=rD,e.DiffuseMode=oc,e.DirectLight=oh,e.DisorderedArray=rT,e.Downsampling=rB,e.DynamicCollider=aT,e.DynamicColliderConstraints=aR,e.EmissionModule=su,e.Engine=on,e.EngineObject=t2,e.Entity=iQ,e.EventDispatcher=nY,e.FileHeader=lh,e.FixedJoint=aB,e.FogMode=ol,e.Font=ny,e.FontStyle=np,e.FrustumFace=tC,e.GLCapabilityType=n$,e.GLCompressedTextureInternalFormat=sW,e.GLTFExtensionMode=cf,e.GLTFExtensionParser=c_,e.GLTFParser=cp,e.GLTFParserContext=lY,e.GLTFParserType=lJ,e.GLTFResource=lk,e.GLTFUtils=l1,e.GradientAlphaKey=sa,e.GradientColorKey=si,e.HemisphereShape=sP,e.HingeJoint=aO,e.HitResult=aE,e.IndexBufferBinding=iS,e.IndexFormat=it,e.InputManager=aK,e.InterpolableValueType=lb,e.InterpolationType=oF,e.JointLimits=aV,e.JointMotor=ak,e.KTX2TargetFormat=l4,e.KTX2Transcoder=cr,e.Keyframe=o$,e.Keys=ag,e.Layer=rM,e.LayerPathMask=o0,e.Light=od,e.Loader=ox,e.Logger=nl,e.MSAASamples=rI,e.MainModule=sh,e.Material=iu,e.MaterialLoaderType=lC,e.MathUtil=tA,e.Matrix=tB,e.Matrix3x3=tL,e.Mesh=iE,e.MeshRenderer=iF,e.MeshTopology=is,e.ModelMesh=iB,e.OverflowMode=nm,e.PBRBaseMaterial=ip,e.PBRMaterial=ig,e.PBRSpecularMaterial=iv,e.ParserContext=ly,e.ParserType=lv,e.ParticleCompositeCurve=sc,e.ParticleCompositeGradient=so,e.ParticleCurve=sf,e.ParticleCurveMode=se,e.ParticleGenerator=sy,e.ParticleGradient=sr,e.ParticleGradientMode=st,e.ParticleMaterial=sx,e.ParticleRenderMode=o8,e.ParticleRenderer=o6,e.ParticleScaleMode=sd,e.ParticleShapeArcMode=sR,e.ParticleShapeType=sT,e.ParticleSimulationSpace=o5,e.ParticleStopMode=o9,e.PhysicsMaterial=aw,e.PhysicsMaterialCombineMode=aM,e.PhysicsScene=ab,e.PipelineStage=nq,e.Plane=tP,e.PlaneColliderShape=aH,e.PlaneIntersectionType=tb,e.Platform=tG,e.PointLight=o_,e.Pointer=ah,e.PointerButton=a_,e.PointerPhase=ad,e.PostProcess=om,e.PostProcessEffect=a$,e.PostProcessEffectParameter=aZ,e.PostProcessManager=og,e.PostProcessPass=a8,e.PostProcessPassEvent=a4,e.PostProcessUberPass=a5,e.PrefabResource=lE,e.Primitive=iR,e.PrimitiveMesh=iX,e.Probe=sI,e.Quaternion=tD,e.Rand=tU,e.RasterState=ra,e.Ray=tI,e.Rect=tk,e.ReferResource=t3,e.ReflectionParser=lx,e.RefractionMode=im,e.RenderBufferDepthFormat=t8,e.RenderFace=ic,e.RenderQueue=rW,e.RenderQueueType=nk,e.RenderState=rs,e.RenderStateDataKey=nV,e.RenderTarget=nu,e.RenderTargetBlendState=rn,e.ReplacementFailureStrategy=rO,e.ResourceManager=ao,e.ReturnableObjectPool=i2,e.RotationOverLifetimeModule=s_,e.SafeLoopArray=i7,e.Scene=ov,e.SceneManager=ae,e.SceneParser=lw,e.Script=oy,e.SetDataOptions=r7,e.Shader=rl,e.ShaderData=rc,e.ShaderFactory=n1,e.ShaderLib=n0,e.ShaderMacro=nj,e.ShaderMacroCollection=nX,e.ShaderPass=re,e.ShaderPlatformTarget=nG,e.ShaderProperty=nQ,e.ShaderPropertyType=nz,e.ShaderTagKey=n2,e.ShadowCascadesMode=rQ,e.ShadowResolution=rK,e.ShadowType=rq,e.SizeOverLifetimeModule=sm,e.Skin=iJ,e.SkinnedMeshRenderer=i$,e.Sky=oi,e.SkyBoxMaterial=o2,e.SkyProceduralMaterial=o4,e.SpecularMode=lS,e.SphereColliderShape=aG,e.SphereShape=sF,e.SphericalHarmonics3=tz,e.SpotLight=of,e.SpringJoint=aN,e.Sprite=nL,e.SpriteAtlas=nS,e.SpriteDrawMode=nT,e.SpriteMask=r8,e.SpriteMaskInteraction=nx,e.SpriteMaskLayer=ry,e.SpriteRenderer=rR,e.SpriteTileMode=nA,e.StateMachineScript=oY,e.StaticCollider=aP,e.StencilOperation=nU,e.StencilState=ro,e.SubMesh=iA,e.SubPrimitive=iT,e.SubShader=rt,e.SunMode=o3,e.SystemInfo=am,e.TextHorizontalAlignment=nb,e.TextRenderer=r5,e.TextUtils=ng,e.TextVerticalAlignment=nC,e.Texture=nc,e.Texture2D=nd,e.Texture2DArray=nh,e.TextureCoordinate=i_,e.TextureCube=n_,e.TextureCubeFace=t5,e.TextureDepthCompareFunction=t9,e.TextureFilterMode=t6,e.TextureFormat=t7,e.TextureSheetAnimationModule=sg,e.TextureUsage=ne,e.TextureWrapMode=nt,e.Time=nJ,e.TonemappingEffect=a3,e.TonemappingMode=a2,e.TrailMaterial=sL,e.TrailRenderer=sB,e.Transform=rg,e.UnlitMaterial=iy,e.Utils=nR,e.Vector2=tO,e.Vector3=tR,e.Vector4=tN,e.VelocityOverLifetimeModule=sv,e.VertexAttribute=iD,e.VertexBufferBinding=iw,e.VertexElement=ia,e.VertexElementFormat=ir,e.WebCanvas=sQ,e.WebGLEngine=sJ,e.WebGLGraphicDevice=le,e.WebGLMode=s7,e.WrapMode=oU,e.XRManager=ot,e.assignmentClone=tZ,e.decode=lP,e.decoder=ld,e.decoderMap=lu,e.deepClone=t0,e.dependentComponents=rf,e.ignoreClone=tJ,e.parseSingleKTX=cA,e.registerGLTFExtension=cm,e.registerGLTFParser=l0,e.request=ai,e.resourceLoader=as,e.shallowClone=t$,e.version=c6,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=browser.min.js.map