@galacean/engine 2.0.0-alpha.2 → 2.0.0-alpha.21

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.
@@ -0,0 +1,2 @@
1
+ function e(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function t(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var n,r,i,a,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,A,b,S,C,T,R,E,M,P,w,F,L,D,B,I,N,O,V,k,U,z,G,H,W,X,j,Y,K,Q,q,Z,J,$,ee,et,en,er,ei,ea,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eA,eb,eS,eC,eT,eR,eE,eM,eP,ew,eF,eL,eD,eB,eI,eN,eO,eV,ek,eU,ez,eG,eH,eW,eX,ej,eY,eK,eQ,eq,eZ,eJ,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,tA,tb,tS,tC,tT,tR,tE,tM,tP,tw,tF,tL,tD,tB=((ty={})[ty.Disjoint=0]="Disjoint",ty[ty.Contains=1]="Contains",ty[ty.Intersects=2]="Intersects",ty),tI=((n={})[n.Back=0]="Back",n[n.Front=1]="Front",n[n.Intersecting=2]="Intersecting",n),tN=((r={})[r.Near=0]="Near",r[r.Far=1]="Far",r[r.Left=2]="Left",r[r.Right=3]="Right",r[r.Bottom=4]="Bottom",r[r.Top=5]="Top",r);function tO(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 tV(e,t,n){return t&&tO(e.prototype,t),n&&tO(e,n),e}var tk=/*#__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}();tk.zeroTolerance=1e-6,tk.radToDegreeFactor=180/Math.PI,tk.degreeToRadFactor=Math.PI/180;var tU=/*#__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,null==this._onValueChanged||this._onValueChanged.call(this),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,null==this._onValueChanged||this._onValueChanged.call(this),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,null==this._onValueChanged||this._onValueChanged.call(this),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,null==this._onValueChanged||this._onValueChanged.call(this),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),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],null==this._onValueChanged||this._onValueChanged.call(this),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,null==n._onValueChanged||n._onValueChanged.call(n)},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._z=e._z-t._z,null==n._onValueChanged||n._onValueChanged.call(n)},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._z=e._z*t._z,null==n._onValueChanged||n._onValueChanged.call(n)},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._z=e._z/t._z,null==n._onValueChanged||n._onValueChanged.call(n)},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 tk.equals(e._x,t._x)&&tk.equals(e._y,t._y)&&tk.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,null==r._onValueChanged||r._onValueChanged.call(r)},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),null==n._onValueChanged||n._onValueChanged.call(n)},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),null==n._onValueChanged||n._onValueChanged.call(n)},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,null==t._onValueChanged||t._onValueChanged.call(t)},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>tk.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,null==n._onValueChanged||n._onValueChanged.call(n)},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],null==n._onValueChanged||n._onValueChanged.call(n)},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],null==n._onValueChanged||n._onValueChanged.call(n)},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],null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},tV(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}();tU._zero=new tU(0,0,0),tU._one=new tU(1,1,1);var tz=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new tU,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)tU.add(t[a],i,i);tU.scale(i,1/r,n.center);for(var o=0,s=0;s<r;++s){var l=tU.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=tU.distance(n,i)},e}();tz._tempVec30=new tU;var tG=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new tU,this.max=new tU,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(Number.isNaN(r)?0:.5*r,Number.isNaN(i)?0:.5*i,Number.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(Number.isNaN(r)?0:.5*r,Number.isNaN(i)?0:.5*i,Number.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 tU;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},t.toJSON=function(){var e=this.min,t=this.max;return{min:{x:e._x,y:e._y,z:e._z},max:{x:t._x,y:t._y,z:t._z}}},e.fromCenterAndExtent=function(e,t,n){tU.subtract(e,t,n.min),tU.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];tU.min(n,o,n),tU.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),tU.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))),tU.subtract(i,a,r.min),tU.add(i,a,r.max)},e.merge=function(e,t,n){return tU.min(e.min,t.min,n.min),tU.max(e.max,t.max,n.max),n},e}();tG._tempVec30=new tU,tG._tempVec31=new tU;var tH=/*#__PURE__*/function(){function e(){}return e.intersectionPointThreePlanes=function(t,n,r,i){var a=t.normal,o=n.normal,s=r.normal;tU.cross(o,s,e._tempVec30),tU.cross(s,a,e._tempVec31),tU.cross(a,o,e._tempVec32);var l=-tU.dot(a,e._tempVec30),c=-tU.dot(o,e._tempVec31),u=-tU.dot(s,e._tempVec32);tU.scale(e._tempVec30,t.distance/l,e._tempVec30),tU.scale(e._tempVec31,n.distance/c,e._tempVec31),tU.scale(e._tempVec32,r.distance/u,e._tempVec32),tU.add(e._tempVec30,e._tempVec31,i),tU.add(i,e._tempVec32,i)},e.distancePlaneAndPoint=function(e,t){return tU.dot(e.normal,t)+e.distance},e.intersectsPlaneAndPoint=function(t,n){var r=e.distancePlaneAndPoint(t,n);return r>0?tI.Front:r<0?tI.Back:tI.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))?tI.Back:e.distancePlaneAndPoint(t,s)>0?tI.Front:tI.Intersecting},e.intersectsPlaneAndSphere=function(t,n){var r=n.center,i=n.radius,a=e.distancePlaneAndPoint(t,r);return a>i?tI.Front:a<-i?tI.Back:tI.Intersecting},e.intersectsRayAndPlane=function(e,t){var n=t.normal,r=tk.zeroTolerance,i=tU.dot(n,e.direction),a=tU.dot(n,e.origin);if(Math.abs(i)<r)return Math.abs(a+t.distance)<r?0:-1;var o=(-t.distance-a)/i;if(o<0){if(o<-r)return -1;o=0}return o},e.intersectsRayAndBox=function(e,t){var n=tk.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,A=(o.y-d)*y;if(x>A){var b=x;x=A,A=b}if((_=Math.max(x,_))>(f=Math.min(A,f)))return -1}if(Math.abs(c)<n){if(h<a.z||h>o.z)return -1}else{var S=1/c,C=(a.z-h)*S,T=(o.z-h)*S;if(C>T){var R=C;C=T,T=R}if((_=Math.max(C,_))>(f=Math.min(T,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;tU.subtract(r,a,s);var l=tU.dot(s,i),c=tU.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 tU.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))),tU.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),tU.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)<tk.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.far,n))<tk.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.left,n))<tk.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.right,n))<tk.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.top,n))<tk.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.bottom,n))<tk.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:tB.Contains},e.frustumContainsBox=function(t,n){for(var r=n.min,i=n.max,a=e._tempVec30,o=e._tempVec31,s=tB.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)===tI.Back)return tB.Disjoint;e.intersectsPlaneAndPoint(c,o)===tI.Back&&(s=tB.Intersects)}return s},e.frustumContainsSphere=function(t,n){for(var r=tB.Contains,i=0;i<6;++i){var a=t.getPlane(i),o=e.intersectsPlaneAndSphere(a,n);if(o===tI.Back)return tB.Disjoint;if(o===tI.Intersecting){r=tB.Intersects;break}}return r},e}();tH._tempVec30=new tU,tH._tempVec31=new tU,tH._tempVec32=new tU;var tW=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new tU,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();tU.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}(),tX=/*#__PURE__*/function(){function e(e){void 0===e&&(e=null),this.near=new tW,this.far=new tW,this.left=new tW,this.right=new tW,this.top=new tW,this.bottom=new tW,e&&this.calculateFromMatrix(e)}var t=e.prototype;return t.getPlane=function(e){switch(e){case tN.Near:return this.near;case tN.Far:return this.far;case tN.Left:return this.left;case tN.Right:return this.right;case tN.Bottom:return this.bottom;case tN.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 tH.intersectsFrustumAndBox(this,e)},t.intersectsSphere=function(e){return tH.frustumContainsSphere(this,e)!==tB.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}(),tj=/*#__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],A=i[6],b=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*A+c*b+h*S,a[7]=s*A+u*b+_*S,a[8]=l*A+d*b+f*S},e.equals=function(e,t){var n=e.elements,r=t.elements;return tk.equals(n[0],r[0])&&tk.equals(n[1],r[1])&&tk.equals(n[2],r[2])&&tk.equals(n[3],r[3])&&tk.equals(n[4],r[4])&&tk.equals(n[5],r[5])&&tk.equals(n[6],r[6])&&tk.equals(n[7],r[7])&&tk.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,A=i*u-o*l,b=i*d-s*l,S=a*u-o*c,C=a*d-s*c,T=o*d-s*u,R=h*g-_*m,E=h*v-f*m,M=h*y-p*m,P=_*v-f*g,w=_*y-p*g,F=f*y-p*v,L=x*F-A*w+b*P+S*M-C*E+T*R;if(!L)return null;L=1/L,r[0]=(c*F-u*w+d*P)*L,r[1]=(u*M-l*F-d*E)*L,r[2]=(l*w-c*M+d*R)*L,r[3]=(o*w-a*F-s*P)*L,r[4]=(i*F-o*M+s*E)*L,r[5]=(a*M-i*w-s*R)*L,r[6]=(g*T-v*C+y*S)*L,r[7]=(v*b-m*T-y*A)*L,r[8]=(m*C-g*b+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}(),tY=/*#__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,null==this._onValueChanged||this._onValueChanged.call(this),this},t.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,null==this._onValueChanged||this._onValueChanged.call(this),this},t.getAxisAngle=function(e){var t=this._x,n=this._y,r=this._z,i=t*t+n*n+r*r;if(i<tk.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,null==this._onValueChanged||this._onValueChanged.call(this),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,null==e._onValueChanged||e._onValueChanged.call(e),e},t.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),null==e._onValueChanged||e._onValueChanged.call(e),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,null==this._onValueChanged||this._onValueChanged.call(this),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],null==this._onValueChanged||this._onValueChanged.call(this),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-tk.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-tk.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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},e.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,null==t._onValueChanged||t._onValueChanged.call(t)},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 tk.equals(e._x,t._x)&&tk.equals(e._y,t._y)&&tk.equals(e._z,t._z)&&tk.equals(e._w,t._w)},e.rotationAxisAngle=function(t,n,r){var i=e._tempVector3;tU.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),null==r._onValueChanged||r._onValueChanged.call(r)},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,null==r._onValueChanged||r._onValueChanged.call(r)},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),null==t._onValueChanged||t._onValueChanged.call(t)},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>tk.zeroTolerance){var s=1/o;t._x=-n*s,t._y=-r*s,t._z=-i*s,t._w=a*s,null==t._onValueChanged||t._onValueChanged.call(t)}},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-tk.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,null==i._onValueChanged||i._onValueChanged.call(i)},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>tk.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*o,null==t._onValueChanged||t._onValueChanged.call(t))},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,null==t._onValueChanged||t._onValueChanged.call(t)},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,null==t._onValueChanged||t._onValueChanged.call(t)},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,null==t._onValueChanged||t._onValueChanged.call(t)},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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},tV(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<tk.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}();tY._tempVector3=new tU,tY._tempQuat1=new tY;var tK=/*#__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)<tk.zeroTolerance||Math.abs(g)<tk.zeroTolerance||Math.abs(v)<tk.zeroTolerance)return n.identity(),!1;var y=1/m,x=1/g,A=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]=_*A,o[7]=f*A,o[8]=p*A,tY.rotationMatrix3x3(i,n),!0},t.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>tk.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 null==e._onValueChanged||e._onValueChanged.call(e),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],A=r[15],b=i[0],S=i[1],C=i[2],T=i[3],R=i[4],E=i[5],M=i[6],P=i[7],w=i[8],F=i[9],L=i[10],D=i[11],B=i[12],I=i[13],N=i[14],O=i[15];a[0]=o*b+u*S+f*C+v*T,a[1]=s*b+d*S+p*C+y*T,a[2]=l*b+h*S+m*C+x*T,a[3]=c*b+_*S+g*C+A*T,a[4]=o*R+u*E+f*M+v*P,a[5]=s*R+d*E+p*M+y*P,a[6]=l*R+h*E+m*M+x*P,a[7]=c*R+_*E+g*M+A*P,a[8]=o*w+u*F+f*L+v*D,a[9]=s*w+d*F+p*L+y*D,a[10]=l*w+h*F+m*L+x*D,a[11]=c*w+_*F+g*L+A*D,a[12]=o*B+u*I+f*N+v*O,a[13]=s*B+d*I+p*N+y*O,a[14]=l*B+h*I+m*N+x*O,a[15]=c*B+_*I+g*N+A*O},e.equals=function(e,t){var n=e.elements,r=t.elements;return tk.equals(n[0],r[0])&&tk.equals(n[1],r[1])&&tk.equals(n[2],r[2])&&tk.equals(n[3],r[3])&&tk.equals(n[4],r[4])&&tk.equals(n[5],r[5])&&tk.equals(n[6],r[6])&&tk.equals(n[7],r[7])&&tk.equals(n[8],r[8])&&tk.equals(n[9],r[9])&&tk.equals(n[10],r[10])&&tk.equals(n[11],r[11])&&tk.equals(n[12],r[12])&&tk.equals(n[13],r[13])&&tk.equals(n[14],r[14])&&tk.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)<tk.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,A=e._x,b=e._y,S=e._z;i[0]=(1-(p+g))*A,i[1]=(_+x)*A,i[2]=(f-y)*A,i[3]=0,i[4]=(_-x)*b,i[5]=(1-(h+g))*b,i[6]=(m+v)*b,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,A=i*u-o*l,b=i*d-s*l,S=a*u-o*c,C=a*d-s*c,T=o*d-s*u,R=h*g-_*m,E=h*v-f*m,M=h*y-p*m,P=_*v-f*g,w=_*y-p*g,F=f*y-p*v,L=x*F-A*w+b*P+S*M-C*E+T*R;if(!L)return null;L=1/L,r[0]=(c*F-u*w+d*P)*L,r[1]=(o*w-a*F-s*P)*L,r[2]=(g*T-v*C+y*S)*L,r[3]=(f*C-_*T-p*S)*L,r[4]=(u*M-l*F-d*E)*L,r[5]=(i*F-o*M+s*E)*L,r[6]=(v*b-m*T-y*A)*L,r[7]=(h*T-f*b+p*A)*L,r[8]=(l*w-c*M+d*R)*L,r[9]=(a*M-i*w-s*R)*L,r[10]=(m*C-g*b+y*x)*L,r[11]=(_*b-h*C-p*x)*L,r[12]=(c*E-l*P-u*R)*L,r[13]=(i*P-a*E+o*R)*L,r[14]=(g*A-m*S-v*x)*L,r[15]=(h*S-_*A+f*x)*L},e.lookAt=function(t,n,r,i){var a=i.elements,o=e._tempVec30,s=e._tempVec31,l=e._tempVec32;tU.subtract(t,n,l),l.normalize(),tU.cross(r,l,o),o.normalize(),tU.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]=-tU.dot(o,t),a[13]=-tU.dot(s,t),a[14]=-tU.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)<tk.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],A=d[8],b=d[9],S=d[10],C=d[11],T=s*s*o+a,R=l*s*o+c*i,E=c*s*o-l*i,M=s*l*o-c*i,P=l*l*o+a,w=c*l*o+s*i,F=s*c*o+l*i,L=l*c*o-s*i,D=c*c*o+a;h[0]=_*T+g*R+A*E,h[1]=f*T+v*R+b*E,h[2]=p*T+y*R+S*E,h[3]=m*T+x*R+C*E,h[4]=_*M+g*P+A*w,h[5]=f*M+v*P+b*w,h[6]=p*M+y*P+S*w,h[7]=m*M+x*P+C*w,h[8]=_*F+g*L+A*D,h[9]=f*F+v*L+b*D,h[10]=p*F+y*L+S*D,h[11]=m*F+x*L+C*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}();tK._tempVec30=new tU,tK._tempVec31=new tU,tK._tempVec32=new tU,tK._tempMat30=new tj,tK._identity=new tK(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var tQ=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new tU,this.direction=new tU,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}var t=e.prototype;return t.intersectPlane=function(e){return tH.intersectsRayAndPlane(this,e)},t.intersectSphere=function(e){return tH.intersectsRayAndSphere(this,e)},t.intersectBox=function(e){return tH.intersectsRayAndBox(this,e)},t.getPoint=function(e,t){return tU.scale(this.direction,e,t),t.add(this.origin)},e}(),tq=/*#__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,null==this._onValueChanged||this._onValueChanged.call(this),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,null==this._onValueChanged||this._onValueChanged.call(this),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,null==this._onValueChanged||this._onValueChanged.call(this),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,null==this._onValueChanged||this._onValueChanged.call(this),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,null==this._onValueChanged||this._onValueChanged.call(this),this},t.clone=function(){return new e(this._x,this._y)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,null==this._onValueChanged||this._onValueChanged.call(this),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],null==this._onValueChanged||this._onValueChanged.call(this),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,null==n._onValueChanged||n._onValueChanged.call(n)},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,null==n._onValueChanged||n._onValueChanged.call(n)},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,null==n._onValueChanged||n._onValueChanged.call(n)},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,null==n._onValueChanged||n._onValueChanged.call(n)},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 tk.equals(e._x,t._x)&&tk.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,null==r._onValueChanged||r._onValueChanged.call(r)},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),null==n._onValueChanged||n._onValueChanged.call(n)},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),null==n._onValueChanged||n._onValueChanged.call(n)},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,null==t._onValueChanged||t._onValueChanged.call(t)},e.normalize=function(e,t){var n=e._x,r=e._y,i=Math.sqrt(n*n+r*r);i>tk.zeroTolerance&&(i=1/i,t._x=n*i,t._y=r*i,null==t._onValueChanged||t._onValueChanged.call(t))},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,null==n._onValueChanged||n._onValueChanged.call(n)},tV(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}();tq._zero=new tq(0,0),tq._one=new tq(1,1);var tZ=/*#__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,null==this._onValueChanged||this._onValueChanged.call(this),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,null==this._onValueChanged||this._onValueChanged.call(this),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,null==this._onValueChanged||this._onValueChanged.call(this),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,null==this._onValueChanged||this._onValueChanged.call(this),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),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],null==this._onValueChanged||this._onValueChanged.call(this),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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},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 tk.equals(e._x,t._x)&&tk.equals(e._y,t._y)&&tk.equals(e._z,t._z)&&tk.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,null==r._onValueChanged||r._onValueChanged.call(r)},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),null==n._onValueChanged||n._onValueChanged.call(n)},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),null==n._onValueChanged||n._onValueChanged.call(n)},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,null==t._onValueChanged||t._onValueChanged.call(t)},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>tk.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*o,null==t._onValueChanged||t._onValueChanged.call(t))},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,null==n._onValueChanged||n._onValueChanged.call(n)},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],null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n)},tV(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}();tZ._zero=new tZ(0,0,0,0),tZ._one=new tZ(1,1,1,1);var tJ=/*#__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,null==this._onValueChanged||this._onValueChanged.call(this),this},t.add=function(e){return this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,null==this._onValueChanged||this._onValueChanged.call(this),this},t.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),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],null==this._onValueChanged||this._onValueChanged.call(this),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.sRGBToLinearSpace(this._r),t._g=e.sRGBToLinearSpace(this._g),t._b=e.sRGBToLinearSpace(this._b),t._a=this._a,null==t._onValueChanged||t._onValueChanged.call(t),t},t.toSRGB=function(t){return t._r=e.linearToSRGBSpace(this._r),t._g=e.linearToSRGBSpace(this._g),t._b=e.linearToSRGBSpace(this._b),t._a=this._a,null==t._onValueChanged||t._onValueChanged.call(t),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}},t.toGamma=function(e){return this.toSRGB(e)},e.sRGBToLinearSpace=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.linearToSRGBSpace=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 tk.equals(e._r,t._r)&&tk.equals(e._g,t._g)&&tk.equals(e._b,t._b)&&tk.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,null==n._onValueChanged||n._onValueChanged.call(n),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,null==n._onValueChanged||n._onValueChanged.call(n)},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,null==n._onValueChanged||n._onValueChanged.call(n),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,null==r._onValueChanged||r._onValueChanged.call(r),r},e.gammaToLinearSpace=function(t){return e.sRGBToLinearSpace(t)},e.linearToGammaSpace=function(t){return e.linearToSRGBSpace(t)},tV(e,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}(),t$=/*#__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,null==this._onValueChanged||this._onValueChanged.call(this),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,null==this._onValueChanged||this._onValueChanged.call(this),this},tV(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}(),t0=/*#__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}(),t1=/*#__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}(),t2=((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 t3(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 t4(e,t,n){return t&&t3(e.prototype,t),n&&t3(e,n),e}function t8(e,t){return(t8=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function t5(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&&t8(e,t)}var t9=/*#__PURE__*/function(){function e(){this.localPositions=new tZ}return e.prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},e}();function t6(e,n,r,i){var a,o=arguments.length,s=o<3?n:null===i?i=Object.getOwnPropertyDescriptor(n,r):i;if(("undefined"==typeof Reflect?"undefined":t(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,n,r,i);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(s=(o<3?a(s):o>3?a(n,r,s):a(n,r))||s);return o>3&&s&&Object.defineProperty(n,r,s),s}function t7(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):e(t,n)}t9.triangles=[0,2,1,2,0,3],"function"==typeof SuppressedError&&SuppressedError;var ne=((a={})[a.Ignore=0]="Ignore",a[a.Assignment=1]="Assignment",a[a.Shallow=2]="Shallow",a[a.Deep=3]="Deep",a);function nt(e,t){na.registerCloneMode(e,t,ne.Ignore)}function nn(e,t){na.registerCloneMode(e,t,ne.Assignment)}function nr(e,t){na.registerCloneMode(e,t,ne.Shallow)}function ni(e,t){na.registerCloneMode(e,t,ne.Deep)}var na=/*#__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){var l=t[r];if(t7(l,Object)&&l._remap){n[r]=l._remap(a,o);return}if(i!==ne.Ignore){if(!t7(l,Object)||void 0===i||i===ne.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);null==l._cloneTo||l._cloneTo.call(l,_,a,o)}}}},e.deepCloneObject=function(t,n,r){for(var i in t)e.cloneProperty(t,n,i,ne.Deep,null,null,r)},e}();na._subCloneModeMap=new Map,na._cloneModeMap=new Map,na._objectType=Object.getPrototypeOf(Object);var no=/*#__PURE__*/function(){function e(t){this.instanceId=++e._instanceIdCounter,this._pendingDestroy=!1,this._destroyed=!1,this._engine=t}var t=e.prototype;return t.destroy=function(){if(!this._destroyed){var e=this._engine;(null==e?void 0:e._frameInProcess)&&!e._processingPendingDestroys?this._pendingDestroy||(this._pendingDestroy=!0,e._pendingDestroyObjects.push(this)):(this._pendingDestroy=!1,this._destroyed=!0,this._onDestroy())}},t._onDestroy=function(){var e=this._engine;if(e){var t=e.resourceManager;t._deleteAsset(this),t._deleteContentRestorer(this)}},t4(e,[{key:"engine",get:function(){return this._engine}},{key:"pendingDestroy",get:function(){return this._pendingDestroy}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();no._instanceIdCounter=0,t6([nt],no.prototype,"instanceId",void 0),t6([nt],no.prototype,"_engine",void 0);var ns=/*#__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}t5(t,e);var n=t.prototype;return n.destroy=function(t,n){if(void 0===t&&(t=!1),!this._pendingDestroy&&!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)},t4(t,[{key:"refCount",get:function(){return this._refCount}}]),t}(no),nl=function(e){this.resource=e},nc=((o={})[o.Depth=27]="Depth",o[o.Stencil=28]="Stencil",o[o.DepthStencil=29]="DepthStencil",o[o.Depth16=30]="Depth16",o[o.Depth24=31]="Depth24",o[o.Depth32=32]="Depth32",o[o.Depth24Stencil8=33]="Depth24Stencil8",o[o.Depth32Stencil8=34]="Depth32Stencil8",o),nu=((s={})[s.PositiveX=0]="PositiveX",s[s.NegativeX=1]="NegativeX",s[s.PositiveY=2]="PositiveY",s[s.NegativeY=3]="NegativeY",s[s.PositiveZ=4]="PositiveZ",s[s.NegativeZ=5]="NegativeZ",s),nd=((l={})[l.Never=0]="Never",l[l.Less=1]="Less",l[l.Equal=2]="Equal",l[l.LessEqual=3]="LessEqual",l[l.Greater=4]="Greater",l[l.NotEqual=5]="NotEqual",l[l.GreaterEqual=6]="GreaterEqual",l[l.Always=7]="Always",l),nh=((c={})[c.Point=0]="Point",c[c.Bilinear=1]="Bilinear",c[c.Trilinear=2]="Trilinear",c),n_=((u={})[u.R8G8B8=0]="R8G8B8",u[u.R8G8B8A8=1]="R8G8B8A8",u[u.R4G4B4A4=2]="R4G4B4A4",u[u.R5G5B5A1=3]="R5G5B5A1",u[u.R5G6B5=4]="R5G6B5",u[u.R16G16B16A16=7]="R16G16B16A16",u[u.R32G32B32A32=8]="R32G32B32A32",u[u.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",u[u.R11G11B10_UFloat=35]="R11G11B10_UFloat",u[u.R8=36]="R8",u[u.R8G8=37]="R8G8",u[u.BC1=10]="BC1",u[u.BC3=11]="BC3",u[u.BC7=12]="BC7",u[u.BC6H=100]="BC6H",u[u.ETC1_RGB=13]="ETC1_RGB",u[u.ETC2_RGB=14]="ETC2_RGB",u[u.ETC2_RGBA5=15]="ETC2_RGBA5",u[u.ETC2_RGBA8=16]="ETC2_RGBA8",u[u.PVRTC_RGB2=17]="PVRTC_RGB2",u[u.PVRTC_RGBA2=18]="PVRTC_RGBA2",u[u.PVRTC_RGB4=19]="PVRTC_RGB4",u[u.PVRTC_RGBA4=20]="PVRTC_RGBA4",u[u.ASTC_4x4=21]="ASTC_4x4",u[u.ASTC_5x5=22]="ASTC_5x5",u[u.ASTC_6x6=23]="ASTC_6x6",u[u.ASTC_8x8=24]="ASTC_8x8",u[u.ASTC_10x10=25]="ASTC_10x10",u[u.ASTC_12x12=26]="ASTC_12x12",u[u.Depth=27]="Depth",u[u.Stencil=28]="Stencil",u[u.DepthStencil=29]="DepthStencil",u[u.Depth16=30]="Depth16",u[u.Depth24=31]="Depth24",u[u.Depth32=32]="Depth32",u[u.Depth24Stencil8=33]="Depth24Stencil8",u[u.Depth32Stencil8=34]="Depth32Stencil8",u[u.Alpha8=5]="Alpha8",u[u.LuminanceAlpha=6]="LuminanceAlpha",u[u.DXT1=10]="DXT1",u[u.DXT5=11]="DXT5",u),nf=((d={})[d.Static=0]="Static",d[d.Dynamic=1]="Dynamic",d),np=((h={})[h.Clamp=0]="Clamp",h[h.Repeat=1]="Repeat",h[h.Mirror=2]="Mirror",h),nm=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._isContentLost=!1,t.resourceManager._addGraphicResource(n),n._isContentLost=t._isDeviceLost,n}return t5(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},t4(t,[{key:"isContentLost",get:function(){return this._isContentLost}}]),t}(ns),ng=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},nv=console.log.bind(console),ny=console.info.bind(console),nx=console.warn.bind(console),nA=console.error.bind(console),nb={debug:ng,info:ng,warn:ng,error:ng,isEnabled:!1,enable:function(){this.debug=nv,this.info=ny,this.warn=nx,this.error=nA,this.isEnabled=!0},disable:function(){this.debug=ng,this.info=ng,this.warn=ng,this.error=ng,this.isEnabled=!1}},nS=/*#__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.then(function(t){return null==e||e(),t},function(t){throw null==e||e(),t})},t.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},e.resolve=function(t){return new e(void 0===t?function(e){return e()}:t7(t,e)||t7(t,Promise)?function(e,n){t.then(function(t){return e(t)},n)}:function(e){return e(t)})},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){t7(t,e)||t7(t,Promise)?t.then(function(e){a(n,e)},r):Promise.resolve().then(function(){a(n,t)})},s=Array.from(t).length,l=Array(s),c=0;if(0===s)return n(l);for(var u=0;u<s;u++)o(t[u],u)})},t4(e,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),e}(),nC=((_={})[_.FLOAT=5126]="FLOAT",_[_.FLOAT_VEC2=35664]="FLOAT_VEC2",_[_.FLOAT_VEC3=35665]="FLOAT_VEC3",_[_.FLOAT_VEC4=35666]="FLOAT_VEC4",_[_.INT=5124]="INT",_[_.INT_VEC2=35667]="INT_VEC2",_[_.INT_VEC3=35668]="INT_VEC3",_[_.INT_VEC4=35669]="INT_VEC4",_[_.BOOL=35670]="BOOL",_[_.BOOL_VEC2=35671]="BOOL_VEC2",_[_.BOOL_VEC3=35672]="BOOL_VEC3",_[_.BOOL_VEC4=35673]="BOOL_VEC4",_[_.FLOAT_MAT2=35674]="FLOAT_MAT2",_[_.FLOAT_MAT3=35675]="FLOAT_MAT3",_[_.FLOAT_MAT4=35676]="FLOAT_MAT4",_[_.FLOAT_ARRAY=35677]="FLOAT_ARRAY",_[_.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",_[_.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",_[_.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",_[_.INT_ARRAY=100003]="INT_ARRAY",_[_.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",_[_.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",_[_.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",_[_.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",_[_.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",_[_.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",_[_.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",_[_.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",_[_.SAMPLER_2D=35678]="SAMPLER_2D",_[_.SAMPLER_CUBE=35680]="SAMPLER_CUBE",_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_),nT=((f={}).shaderVertexID="shaderVertexID",f.standardDerivatives="OES_standard_derivatives",f.shaderTextureLod="EXT_shader_texture_lod",f.elementIndexUint="OES_element_index_uint",f.depthTexture="WEBGL_depth_texture",f.drawBuffers="WEBGL_draw_buffers",f.vertexArrayObject="OES_vertex_array_object",f.instancedArrays="ANGLE_instanced_arrays",f.multipleSample="multipleSampleOnlySupportedInWebGL2",f.textureFloat="OES_texture_float",f.textureFloatLinear="OES_texture_float_linear",f.textureHalfFloat="OES_texture_half_float",f.textureHalfFloatLinear="OES_texture_half_float_linear",f.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",f.colorBufferFloat="EXT_color_buffer_float",f.colorBufferHalfFloat="EXT_color_buffer_half_float",f.textureFilterAnisotropic="EXT_texture_filter_anisotropic",f.blendMinMax="EXT_blend_minmax",f.fragDepth="EXT_frag_depth",f.astc="WEBGL_compressed_texture_astc",f.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",f.astc_hdr="WEBGL_compressed_texture_astc_hdr",f.etc="WEBGL_compressed_texture_etc",f.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",f.etc1="WEBGL_compressed_texture_etc1",f.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",f.pvrtc="WEBGL_compressed_texture_pvrtc",f.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",f.s3tc="WEBGL_compressed_texture_s3tc",f.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",f.s3tc_srgb="WEBGL_compressed_texture_s3tc_srgb",f.bptc="EXT_texture_compression_bptc",f.WEBGL_lose_context="WEBGL_lose_context",f.sRGB="EXT_sRGB",f),nR=/*#__PURE__*/function(){function e(){}return e._parseAppleMobileOSVersion=function(e,t){var n=e.match(/Version\/(\d+)(?:\.(\d+))?(?:\.(\d+))?/);return n?t+" "+n[1]+"."+(n[2]||0)+"."+(n[3]||0):(n=e.match(/OS (\d+)_(\d+)(?:_(\d+))?/))?t+" "+n[1]+"."+n[2]+"."+(n[3]||0):t},e._initialize=function(){if("undefined"==typeof navigator){e._isBrowser=!1;return}var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?e.platform=t2.IPhone:/iPad/i.test(n)?e.platform=t2.IPad:/Android/i.test(n)?e.platform=t2.Android:/Macintosh/i.test(n)&&(e.platform=t2.Mac),e.platform){case t2.IPhone:this.operatingSystem=this._parseAppleMobileOSVersion(n,"iPhone OS");break;case t2.IPad:this.operatingSystem=this._parseAppleMobileOSVersion(n,"iPad OS");break;case t2.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case t2.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},e._checkWebpSupported=function(){var e=this;return this._webpSupported||(this._webpSupported=new nS(function(t){if(e._isBrowser){var n=new Image;n.onload=function(){t(n.width>0&&n.height>0)},n.onerror=function(){t(!1)},n.src="data:image/webp;base64,UklGRhACAABXRUJQVlA4WAoAAAAwAAAAAAAAAAAASUNDUMgBAAAAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABtbHVjAAAAAAAAAAEAAAAMZW5VUwAAACAAAAAcAEcAbwBvAGcAbABlACAASQBuAGMALgAgADIAMAAxADZBTFBIAgAAAAAAVlA4IBgAAAAwAQCdASoBAAEAAUAmJaQAA3AA/v02aAA="}else t(!1)})),this._webpSupported},e.supportsTextureFormat=function(e,t){var n=e._hardwareRenderer;switch(n.canIUse(nT.depthTexture),t){case n_.R16G16B16A16:if(!n.canIUse(nT.textureHalfFloat))return!1;break;case n_.R32G32B32A32:if(!n.canIUse(nT.textureFloat))return!1;break;case n_.Depth16:case n_.Depth24Stencil8:case n_.Depth:case n_.DepthStencil:if(!n.canIUse(nT.depthTexture))return!1;break;case n_.R11G11B10_UFloat:case n_.R32G32B32A32_UInt:case n_.Depth24:case n_.Depth32:case n_.Depth32Stencil8:case n_.R8:case n_.R8G8:return n.isWebGL2}return!0},t4(e,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),e}();nR.platform=t2.Unknown,nR.operatingSystem="",nR._isBrowser=!0,nR._simdSupported=null,nR._webpSupported=null,nR._initialize();var nE=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;if(!nR.supportsTextureFormat(t,i))throw Error("Texture format is not supported:"+n_[i]);return(s=e.call(this,t)||this)._isDepthTexture=!1,s._memorySize=0,s._anisoLevel=1,s._useDepthCompareMode=!1,s._width=n,s._height=r,s._format=i,s._mipmap=a,s._isSRGBColorSpace=o,s._mipmapCount=s._getMipmapCount(),s}t5(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._engine._isDeviceLost||(this._engine._renderingStatistics._textureMemory-=this._memorySize),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 n_.R32G32B32A32_UInt===this._format},t4(t,[{key:"isSRGBColorSpace",get:function(){return this._isSRGBColorSpace}},{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!==nh.Point&&this._isIntFormat()){e=nh.Point,nb.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&&(nb.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(nb.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}(nm),nM=/*#__PURE__*/function(){function e(){}return e.supportGenerateMipmapsWithCorrection=function(t,n,r,i,a,o){var s=t._hardwareRenderer._isWebGL2;return!!a&&(o&&!e.supportSRGB(i)&&(o=!1),e.supportMipmaps(n,r,s)||(a=!1),e.supportGenerateMipmaps(i,a,o,s))},e.supportSRGB=function(e){switch(e){case n_.R8G8B8:case n_.R8G8B8A8:case n_.BC1:case n_.BC3:case n_.BC7:case n_.ETC2_RGB:case n_.ETC2_RGBA8:case n_.ASTC_4x4:return!0;default:return!1}},e.supportMipmaps=function(e,t,n){return n||tk.isPowerOf2(e)&&tk.isPowerOf2(t)},e.supportGenerateMipmaps=function(e,t,n,r){return!t||!n||!!(r&&e===n_.R8G8B8A8)},e.getTextureByteCount=function(t,n,r,i,a){for(var o=0,s=0;s<i;s++){var l=Math.max(1,n>>s),c=Math.max(1,r>>s);o+=e.getMipLevelByteCount(t,l,c)}return o*a},e.getMipLevelByteCount=function(e,t,n){switch(e){case n_.R8:case n_.Alpha8:return t*n;case n_.R8G8:case n_.LuminanceAlpha:return t*n*2;case n_.R8G8B8:return t*n*3;case n_.R8G8B8A8:case n_.R11G11B10_UFloat:return t*n*4;case n_.R4G4B4A4:case n_.R5G5B5A1:case n_.R5G6B5:return t*n*2;case n_.R16G16B16A16:return t*n*8;case n_.R32G32B32A32:case n_.R32G32B32A32_UInt:return t*n*16;case n_.BC1:return Math.ceil(t/4)*Math.ceil(n/4)*8;case n_.BC3:case n_.BC7:case n_.BC6H:return Math.ceil(t/4)*Math.ceil(n/4)*16;case n_.ETC1_RGB:case n_.ETC2_RGB:case n_.ETC2_RGBA5:return Math.ceil(t/4)*Math.ceil(n/4)*8;case n_.ETC2_RGBA8:return Math.ceil(t/4)*Math.ceil(n/4)*16;case n_.PVRTC_RGB2:case n_.PVRTC_RGBA2:return Math.max(t,16)*Math.max(n,8)*2/8;case n_.PVRTC_RGB4:case n_.PVRTC_RGBA4:return Math.max(t,8)*Math.max(n,8)*4/8;case n_.ASTC_4x4:return Math.ceil(t/4)*Math.ceil(n/4)*16;case n_.ASTC_5x5:return Math.ceil(t/5)*Math.ceil(n/5)*16;case n_.ASTC_6x6:return Math.ceil(t/6)*Math.ceil(n/6)*16;case n_.ASTC_8x8:return Math.ceil(t/8)*Math.ceil(n/8)*16;case n_.ASTC_10x10:return Math.ceil(t/10)*Math.ceil(n/10)*16;case n_.ASTC_12x12:return Math.ceil(t/12)*Math.ceil(n/12)*16;case n_.Depth16:return t*n*2;case n_.Depth24:case n_.Depth24Stencil8:case n_.Depth32:return t*n*4;case n_.Depth32Stencil8:return t*n*8;case n_.Stencil:return t*n;case n_.Depth:case n_.DepthStencil:default:return t*n*4}},e}(),nP=/*#__PURE__*/function(e){function t(t,n,r,i,a){var o;return void 0===r&&(r=n_.R8G8B8A8),void 0===i&&(i=!0),void 0===a&&(a=!0),(o=e.call(this,t,n,n,r,i,a)||this)._platformTexture=t._hardwareRenderer.createPlatformTextureCube(o),o.filterMode=nh.Bilinear,o.wrapModeU=o.wrapModeV=np.Clamp,o._memorySize=nM.getTextureByteCount(r,n,n,o._mipmapCount,6),t._isDeviceLost||(t._renderingStatistics._textureMemory+=o._memorySize),o}t5(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),this._engine._renderingStatistics._textureMemory+=this._memorySize,e.prototype._rebuild.call(this)},t}(nE),nw=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){void 0===a&&(a=n_.Depth),void 0===o&&(o=1),(s=e.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._memorySize=0,s._width=n,s._height=r,s._depth=a;var s,l=t._hardwareRenderer.capability.maxAntiAliasing;o>l&&(nb.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+l),o=l),s._antiAliasing=o;var c=0;if(i){for(var u=t7(i,Array)?i.slice():[i],d=0,h=u.length;d<h;d++){var _=u[d];if(_._isDepthTexture)throw"Render texture can't use depth format.";_._addReferCount(1),o>1&&(c+=nM.getMipLevelByteCount(_.format,n,r))}s._colorTextures=u}else s._colorTextures=[];if(t7(a,nE)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1),s._depthFormat=a.format,(o>1||t7(a,nP))&&(c+=nM.getMipLevelByteCount(a.format,n,r))}else"number"==typeof a&&(s._depthFormat=a,c+=nM.getMipLevelByteCount(a,n,r));return o>1&&(c*=o),s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(s),s._memorySize=c,t._isDeviceLost||(t._renderingStatistics._textureMemory+=c),s}t5(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._engine._isDeviceLost||(this._engine._renderingStatistics._textureMemory-=this._memorySize),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),this._engine._renderingStatistics._textureMemory+=this._memorySize},t4(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:"colorTextures",get:function(){return this._colorTextures}},{key:"colorTextureCount",get:function(){return this._colorTextures.length}},{key:"depthTexture",get:function(){return this._depthTexture}},{key:"antiAliasing",get:function(){return this._antiAliasing}}]),t}(nm),nF=/*#__PURE__*/function(e){function t(t,n,r,i,a,o,s){var l;return void 0===i&&(i=n_.R8G8B8A8),void 0===a&&(a=!0),void 0===o&&(o=!0),void 0===s&&(s=nf.Static),(l=e.call(this,t,n,r,i,a,o)||this)._usage=s,l._isDepthTexture=i>=n_.Depth&&i<=n_.Depth32Stencil8,l._platformTexture=t._hardwareRenderer.createPlatformTexture2D(l),l.filterMode=l._isIntFormat()?nh.Point:nh.Bilinear,l.wrapModeU=l.wrapModeV=np.Repeat,l._memorySize=nM.getTextureByteCount(i,n,r,l._mipmapCount,1),t._isDeviceLost||(t._renderingStatistics._textureMemory+=l._memorySize),l}t5(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),this._engine._renderingStatistics._textureMemory+=this._memorySize,e.prototype._rebuild.call(this)},t}(nE),nL=/*#__PURE__*/function(e){function t(t,n,r,i,a,o,s){var l;if(void 0===a&&(a=n_.R8G8B8A8),void 0===o&&(o=!0),void 0===s&&(s=!0),!t._hardwareRenderer.isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");return(l=e.call(this,t,n,r,a,o,s)||this)._length=i,l._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(l),l.filterMode=nh.Bilinear,l.wrapModeU=l.wrapModeV=np.Repeat,l._memorySize=nM.getTextureByteCount(a,n,r,l._mipmapCount,i),t._isDeviceLost||(t._renderingStatistics._textureMemory+=l._memorySize),l}t5(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),this._engine._renderingStatistics._textureMemory+=this._memorySize,e.prototype._rebuild.call(this)},t4(t,[{key:"length",get:function(){return this._length}}]),t}(nE),nD=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._charInfoMap={},n._space=1,n._curX=1,n._curY=1,n._nextY=1,n.isGCIgnored=!0;var n,r=t._hardwareRenderer.isWebGL2?n_.R8:n_.Alpha8,i=new nF(t,512,512,r,!1);return i.filterMode=nh.Bilinear,i.isGCIgnored=!0,n.texture=i,n}t5(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 tq(this._curX,this._curY),a.setPixelBuffer(r,0,this._curX,this._curY,t,n));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}(ns),nB=((p={})[p.None=0]="None",p[p.Bold=1]="Bold",p[p.Italic=2]="Italic",p),nI=((m={})[m.Overflow=0]="Overflow",m[m.Truncate=1]="Truncate",m),nN=/*#__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&nB.Bold?"bold ":"";return r&nB.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,n,r,i,a){var o=t._getSubFont(),s=o.nativeFontString,l=e.measureFont(s),c=t.text.split(/(?:\r\n|\r|\n)/),u=[],d=[],h=[],_=l.size+i,f=0;o.nativeFontString=s;for(var p=0,m=c.length;p<m;p++){var g=c[p];if(0===g.length){this._pushLine(u,d,h,"",0,0,0);continue}for(var v="",y=0,x=0,A=0,b="",S=0,C=0,T=0,R=!1,E=0,M=g.length;E<M;++E){var P=g[E],w=e._getCharInfo(P,s,o),F=P.charCodeAt(0),L=32===F;if(!L||!R||0!==b.length||0!==v.length){var D=L||F>=19968&&F<=40959,B=w.w,I=w.offsetY,N=.5*w.h,O=N+I,V=N-I;D?(v.length>0&&(S+y>n?(S>0&&(S-=a,this._pushLine(u,d,h,b,S,C,T)),f=Math.max(f,S),R=!0,b=v,S=y,C=x,T=A):(b+=v,S+=y,C=Math.max(C,x),T=Math.max(T,A)),v="",y=x=A=0),S+B>n&&S>0?(S-=a,this._pushLine(u,d,h,b,S,C,T),f=Math.max(f,S),R=!0,L?(b="",S=C=T=0):(b=P,S=w.xAdvance+a,C=O,T=V)):(b+=P,S+=w.xAdvance+a,C=Math.max(C,O),T=Math.max(T,V))):y+w.w>n?(S>0&&(S-=a,this._pushLine(u,d,h,b,S,C,T),f=Math.max(f,S),b="",S=C=T=0),y>0&&(y-=a,this._pushLine(u,d,h,v,y,x,A)),f=Math.max(f,y),R=!0,v=P,y=w.xAdvance+a,x=O,A=V):(v+=P,y+=w.xAdvance+a,x=Math.max(x,O),A=Math.max(A,V))}}y>0&&(S+y>n?(S>0&&(S-=a,this._pushLine(u,d,h,b,S,C,T)),f=Math.max(f,S),S=0,y>0&&(y-=a,this._pushLine(u,d,h,v,y,x,A)),f=Math.max(f,y)):(b+=v,S+=y,C=Math.max(C,x),T=Math.max(T,A))),S>0&&(S-=a,this._pushLine(u,d,h,b,S,C,T),f=Math.max(f,S))}var k=r;return t.overflowMode===nI.Overflow&&(k=_*u.length),{width:f,height:k,lines:u,lineWidths:d,lineHeight:_,lineMaxSizes:h}},e.measureTextWithoutWrap=function(t,n,r,i){var a=t._getSubFont(),o=a.nativeFontString,s=e.measureFont(o),l=t.text.split(/(?:\r\n|\r|\n)/),c=l.length,u=[],d=[],h=[],_=s.size+r,f=0;a.nativeFontString=o;for(var p=0;p<c;++p){for(var m=l[p],g=m.length,v=g>1?i*(g-1):0,y=0,x=0,A=0;A<g;++A){var b=e._getCharInfo(m[A],o,a);v+=b.xAdvance;var S=b.offsetY,C=.5*b.h,T=C+S,R=C-S;y<T&&(y=T),x<R&&(x=R)}v>0&&(this._pushLine(u,d,h,m,v,y,x),f=Math.max(f,v))}var E=n;return t.overflowMode===nI.Overflow&&(E=_*u.length),{width:f,height:E,lines:u,lineWidths:d,lineHeight:_,lineMaxSizes:h}},e.getNativeFontHash=function(t,n,r){var i=r&nB.Bold?"bold":"";return r&nB.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,A=0,b=0,S=o.width,C=1/S,T=0;T<g;T+=4)0!==m[T+3]&&(i=~~(.25*T*C),-1===v&&(v=i),i>y&&(y=i));if(-1!==v&&-1!==y&&(b=(x=_-v)+(A=y-_+1)),!r)return{ascent:x,descent:A,size:b};var R=null;if(b>0){var E=b*S;R=new Uint8Array(E);for(var M=v*S*4+3,P=0;P<E;P++,M+=4)R[P]=m[M]}return{char:n,x:0,y:0,w:h,h:b,offsetX:c>0?c:0,offsetY:(x-A)*.5,xAdvance:Math.round(d),uvs:[new tq,new tq,new tq,new tq],ascent:x,descent:A,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}();nN._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],nN._extendHeight=0,nN._measureString="|\xc9q\xc5",nN._measureBaseline="M",nN._heightMultiplier=2,nN._baselineMultiplier=1.4,nN._fontSizeInfoCache={},nN._textContext=null;var nO=/*#__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 nD(e);this._fontAtlases.push(t);var n=this.nativeFontString;return e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function r(){return e.call(this,t)||this}return t5(r,e),r.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var i in t){var a=t[i],o=nN.measureChar(a.char,n).data;if(a.w>0&&a.h>0&&o){var s=a.bufferOffset;r.setPixelBuffer(o,0,s.x,s.y,a.w,a.h)}}},r}(nl))),t},e}(),nV=/*#__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}t5(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 nO(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},t4(t,[{key:"name",get:function(){return this._name}}]),t}(ns);function nk(){return function(e){}}var nU=/*#__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,n,r,i,a,o,s){var l=t.sprite,c=a.x,u=a.y,d=e._matrix,h=d.elements,_=n.elements,f=o?-r:r,p=s?-i:i;h[0]=_[0]*f,h[1]=_[1]*f,h[2]=_[2]*f,h[4]=_[4]*p,h[5]=_[5]*p,h[6]=_[6]*p,h[8]=_[8],h[9]=_[9],h[10]=_[10],h[12]=_[12]-c*h[0]-u*h[4],h[13]=_[13]-c*h[1]-u*h[5],h[14]=_[14]-c*h[2]-u*h[6];for(var m=l._getPositions(),g=t._subChunk,v=g.chunk.vertices,y=0,x=g.vertexArea.start;y<4;++y,x+=9){var A=m[y],b=A.x,S=A.y;v[x]=h[0]*b+h[4]*S+h[12],v[x+1]=h[1]*b+h[5]*S+h[13],v[x+2]=h[2]*b+h[6]*S+h[14]}tG.transform(l._getBounds(),d,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,t){for(var n=e._subChunk,r=e.color,i=r.r,a=r.g,o=r.b,s=r.a*t,l=n.chunk.vertices,c=0,u=n.vertexArea.start+5;c<4;++c,u+=9)l[u]=i,l[u+1]=a,l[u+2]=o,l[u+3]=s},e}();nU._rectangleTriangles=[0,1,2,2,1,3],nU._matrix=new tK,nU=t6([nk()],nU);var nz=/*#__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,n,r,i,a,o,s,l){void 0===l&&(l=1);var c=t.sprite,u=c.border,d=c._getPositions(),h=d[0],_=h.x,f=h.y,p=d[3],m=p.x,g=p.y,v=c.width*l,y=c.height*l,x=v*u.x,A=y*u.y,b=v*u.z,S=y*u.w,C=e._row,T=e._column;if(x+b>r){var R=r/(x+b);C[0]=v*_*R,C[1]=C[2]=x*R,C[3]=r-v*(1-m)*R}else C[0]=v*_,C[1]=x,C[2]=r-b,C[3]=r-v*(1-m);if(S+A>i){var E=i/(S+A);T[0]=y*f*E,T[1]=T[2]=A*E,T[3]=i-y*(1-g)*E}else T[0]=y*f,T[1]=A,T[2]=i-S,T[3]=i-y*(1-g);var M=a.x,P=a.y,w=r*M,F=i*P,L=e._matrix,D=L.elements,B=n.elements,I=o?-1:1,N=s?-1:1;D[0]=B[0]*I,D[1]=B[1]*I,D[2]=B[2]*I,D[4]=B[4]*N,D[5]=B[5]*N,D[6]=B[6]*N,D[8]=B[8],D[9]=B[9],D[10]=B[10],D[12]=B[12]-w*D[0]-F*D[4],D[13]=B[13]-w*D[1]-F*D[5],D[14]=B[14]-w*D[2]-F*D[6];for(var O=t._subChunk,V=O.chunk.vertices,k=0,U=O.vertexArea.start;k<4;k++)for(var z=C[k],G=0;G<4;G++,U+=9){var H=T[G];V[U]=D[0]*z+D[4]*H+D[12],V[U+1]=D[1]*z+D[5]*H+D[13],V[U+2]=D[2]*z+D[6]*H+D[14]}var W=t._bounds;W.min.set(C[0],T[0],0),W.max.set(C[3],T[3],0),W.transform(L)},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,t){for(var n=e._subChunk,r=e.color,i=r.r,a=r.g,o=r.b,s=r.a*t,l=n.chunk.vertices,c=0,u=n.vertexArea.start+5;c<16;++c,u+=9)l[u]=i,l[u+1]=a,l[u+2]=o,l[u+3]=s},e}();nz._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],nz._matrix=new tK,nz._row=[,,,,],nz._column=[,,,,],nz=t6([nk()],nz);var nG=/*#__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}();nG._dispatchingListenersPool=[];var nH=/*#__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},t4(e,[{key:"type",get:function(){return this._type}}]),e}();nH._propertyIdMap=Object.create(null),nH._propertyNameCounter=0,nH._propertyNameMap=Object.create(null);var nW=/*#__PURE__*/function(){function e(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new tZ,this._deltaTimeValue=new tZ,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)},t4(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}();nW._elapsedTimeProperty=nH.getByName("scene_ElapsedTime"),nW._deltaTimeProperty=nH.getByName("scene_DeltaTime");var nX=/*#__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(e.isAbsoluteUrl(t))return n?new URL(n,t).href:t;var r="file://",i=r+this._encodePathComponents(t);return decodeURIComponent(new URL(this._encodePathComponents(n),i).href.slice(r.length))},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],A=a[15],b=t[n],S=t[n+1],C=t[n+2],T=t[n+3],R=t[n+4],E=t[n+5],M=t[n+6],P=t[n+7],w=t[n+8],F=t[n+9],L=t[n+10],D=t[n+11],B=t[n+12],I=t[n+13],N=t[n+14],O=t[n+15];r[i]=o*b+u*S+f*C+v*T,r[i+1]=s*b+d*S+p*C+y*T,r[i+2]=l*b+h*S+m*C+x*T,r[i+3]=c*b+_*S+g*C+A*T,r[i+4]=o*R+u*E+f*M+v*P,r[i+5]=s*R+d*E+p*M+y*P,r[i+6]=l*R+h*E+m*M+x*P,r[i+7]=c*R+_*E+g*M+A*P,r[i+8]=o*w+u*F+f*L+v*D,r[i+9]=s*w+d*F+p*L+y*D,r[i+10]=l*w+h*F+m*L+x*D,r[i+11]=c*w+_*F+g*L+A*D,r[i+12]=o*B+u*I+f*N+v*O,r[i+13]=s*B+d*I+p*N+y*O,r[i+14]=l*B+h*I+m*N+x*O,r[i+15]=c*B+_*I+g*N+A*O},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)===nj&&t.push(""),e.replace(nK,function(e,n,r,i){var a=e;r?a=i.replace(nY,"$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._encodePathComponents=function(e){return e.split("/").map(encodeURIComponent).join("/")},e}(),nj=46,nY=/\\(\\)?/g,nK=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),nQ=/*#__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){nX._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}},t4(e,[{key:"isLopping",get:function(){return this._loopCounter>0}}]),e}(),nq=((g={})[g.Continuous=0]="Continuous",g[g.Adaptive=1]="Adaptive",g),nZ=/*#__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,n,r,i,a,o,s,l){void 0===l&&(l=1);var c,u,d,h,_,f,p=e._posRow,m=e._posColumn,g=e._uvRow,v=e._uvColumn;e.resetData(t,e._calculateDividing(t,r,i,p,m,g,v,l));var y=a.x,x=a.y,A=r*y,b=i*x,S=e._matrix,C=S.elements,T=n.elements,R=o?-1:1,E=s?-1:1;c=C[0]=T[0]*R,u=C[1]=T[1]*R,d=C[2]=T[2]*R,h=C[4]=T[4]*E,_=C[5]=T[5]*E,f=C[6]=T[6]*E,C[8]=T[8],C[9]=T[9],C[10]=T[10];for(var M=C[12]=T[12]-A*c-b*h,P=C[13]=T[13]-A*u-b*_,w=C[14]=T[14]-A*d-b*f,F=p.length-1,L=m.length-1,D=t._subChunk,B=D.chunk.vertices,I=D.indices,N=0,O=0,V=0,k=D.vertexArea.start;V<L;V++){var U=V<<1;if(!(Number.isNaN(v.get(U))||Number.isNaN(v.get(U+1))))for(var z=0;z<F;z++){var G=z<<1;if(!(Number.isNaN(g.get(G))||Number.isNaN(g.get(G+1)))){I[O++]=N,I[O++]=N+1,I[O++]=N+2,I[O++]=N+2,I[O++]=N+1,I[O++]=N+3,N+=4;var H=p.get(z),W=m.get(V),X=p.get(z+1),j=m.get(V+1);B[k]=c*H+h*W+M,B[k+1]=u*H+_*W+P,B[k+2]=d*H+f*W+w,B[k+9]=c*X+h*W+M,B[k+10]=u*X+_*W+P,B[k+11]=d*X+f*W+w,B[k+18]=c*H+h*j+M,B[k+19]=u*H+_*j+P,B[k+20]=d*H+f*j+w,B[k+27]=c*X+h*j+M,B[k+28]=u*X+_*j+P,B[k+29]=d*X+f*j+w,k+=36}}}var Y=t._bounds;Y.min.set(p.get(0),m.get(0),0),Y.max.set(p.get(F),m.get(L),0),Y.transform(S)},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);Number.isNaN(f)||Number.isNaN(p)||Number.isNaN(m)||Number.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,t){for(var n=e._subChunk,r=e.color,i=r.r,a=r.g,o=r.b,s=r.a*t,l=n.chunk.vertices,c=n.vertexArea,u=0,d=c.start+5,h=c.size/9;u<h;++u,d+=9)l[d]=i,l[d+1]=a,l[d+2]=o,l[d+3]=s},e._calculateDividing=function(e,t,n,r,i,a,o,s){var l,c,u,d,h,_,f=e.sprite,p=e.tiledAdaptiveThreshold,m=f.border,g=f._getPositions(),v=g[0],y=v.x,x=v.y,A=g[3],b=A.x,S=A.y,C=f._getUVs(),T=C[0],R=C[1],E=C[2],M=C[3],P=f.width*s,w=f.height*s,F=P*m.x,L=P*m.z,D=F+L,B=P-D,I=w*m.w,N=w*m.y,O=I+N,V=w-O,k=e.tileMode===nq.Adaptive;D>=t?(c=2,l=0):B>tk.zeroTolerance?(u=(t-D)/B,c=k?2+(u=u%1>=p?Math.ceil(u):Math.floor(u)):2+Math.ceil(u),l=2):(c=2,l=1),O>=n?(h=2,d=0):V>tk.zeroTolerance?(_=(n-O)/V,h=k?2+(_=_%1>=p?Math.ceil(_):Math.floor(_)):2+Math.ceil(_),d=2):(h=2,d=1),r.length=i.length=a.length=o.length=0;var U=c*h*4,z=e._getChunkManager().maxVertexCount;if(U>z)return r.add(t*y),r.add(t*b),i.add(n*x),i.add(n*S),a.add(T.x),a.add(M.x),o.add(T.y),o.add(M.y),nb.warn("The number of vertices exceeds the upper limit("+z+")."),4;switch(l){case 0:var G=t/D;r.add(P*y*G),r.add(F*G),r.add(t-P*(1-b)*G),a.add(T.x),a.add(R.x),a.add(E.x),a.add(M.x);break;case 1:r.add(P*y),r.add(F),r.add(t-L),r.add(t-P*(1-b)),a.add(T.x),a.add(R.x),a.add(NaN),a.add(NaN),a.add(E.x),a.add(M.x);break;case 2:var H=R.x,W=E.x,X=(t-D)/u;r.add(P*y),r.add(F),a.add(T.x),a.add(H),a.add(H);for(var j=1,Y=c-2;j<Y;j++)r.add(F+j*X),a.add(W),a.add(H);r.add(t-L),r.add(t-P*(1-b)),k?a.add(W):a.add((u-(Math.ceil(u)-1))*(W-H)+H),a.add(W),a.add(M.x)}switch(d){case 0:var K=n/O;i.add(w*x*K),i.add(N*K),i.add(n-w*(1-S)*K),o.add(T.y),o.add(R.y),o.add(E.y),o.add(M.y);break;case 1:i.add(w*x),i.add(N),i.add(n-I),i.add(n-w*(1-S)),o.add(T.y),o.add(R.y),o.add(NaN),o.add(NaN),o.add(E.y),o.add(M.y);break;case 2:var Q=R.y,q=E.y,Z=(n-O)/_;i.add(w*x),i.add(N),o.add(T.y),o.add(Q),o.add(Q);for(var J=1,$=h-2;J<$;J++)i.add(N+J*Z),o.add(q),o.add(Q);i.add(n-I),i.add(n-w*(1-S)),k?o.add(q):o.add((_-(Math.ceil(_)-1))*(q-Q)+Q),o.add(q),o.add(M.y)}return U},e}();nZ._matrix=new tK,nZ._posRow=new nQ,nZ._posColumn=new nQ,nZ._uvRow=new nQ,nZ._uvColumn=new nQ,nZ=t6([nk()],nZ);var nJ=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._sprites=[],n._spriteNamesToIndex={},n}t5(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},t4(t,[{key:"sprites",get:function(){return this._sprites}}]),t}(ns),n$=((v={})[v.Simple=0]="Simple",v[v.Sliced=1]="Sliced",v[v.Tiled=2]="Tiled",v),n0=((y={})[y.None=0]="None",y[y.VisibleInsideMask=1]="VisibleInsideMask",y[y.VisibleOutsideMask=2]="VisibleOutsideMask",y),n1=((x={})[x.texture=1]="texture",x[x.size=2]="size",x[x.atlasRotate=4]="atlasRotate",x[x.atlasRegion=8]="atlasRegion",x[x.atlasRegionOffset=16]="atlasRegionOffset",x[x.region=32]="region",x[x.pivot=64]="pivot",x[x.border=128]="border",x[x.destroy=256]="destroy",x),n2=((A={})[A.Left=0]="Left",A[A.Center=1]="Center",A[A.Right=2]="Right",A),n3=((b={})[b.Top=0]="Top",b[b.Center=1]="Center",b[b.Bottom=2]="Bottom",b),n4=/*#__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){nX.removeFromArray(this._updateFlags,e)&&nX.removeFromArray(e._flagManagers,this)},t.addListener=function(e){this._listeners.push(e)},t.removeListener=function(e){nX.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}(),n8=/*#__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 tq,new tq,new tq,new tq],s._uvs=[new tq,new tq,new tq,new tq],s._bounds=new tG,s._texture=null,s._atlasRotated=!1,s._atlasRegion=new t$(0,0,1,1),s._atlasRegionOffset=new tZ(0,0,0,0),s._region=new t$(0,0,1,1),s._pivot=new tq(.5,.5),s._border=new tZ(0,0,0,0),s._dirtyUpdateFlag=7,s._updateFlagManager=new n4,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}t5(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(n1.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},n._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/oK._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;d.min.set(o,s,0),d.max.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,A=Math.max(l-p,0)*y+d,b=h+u-Math.max(s-m,0)*v,S=_+d-Math.max(i-g,0)*y,C=this._border,T=C.x,R=C.y,E=C.z,M=C.w;e[0].set(x,S),e[1].set((r-f+T*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(b,A),this._dirtyUpdateFlag&=-3},n._dispatchSpriteChange=function(e){switch(e){case n1.texture:this._dirtyUpdateFlag|=4;break;case n1.atlasRegionOffset:case n1.region:this._dirtyUpdateFlag|=7;break;case n1.atlasRegion:this._dirtyUpdateFlag|=6;break;case n1.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},n._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=tk.clamp(e.x,0,1),n=tk.clamp(e.y,0,1);e.set(t,n,tk.clamp(e.width,0,1-t),tk.clamp(e.height,0,1-n)),this._dispatchSpriteChange(n1.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n1.size),e._onValueChanged=this._onRegionChange},n._onPivotChange=function(){this._dispatchSpriteChange(n1.pivot)},n._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=tk.clamp(e.x,0,1),n=tk.clamp(e.y,0,1);e.set(t,n,tk.clamp(e.z,0,1-t),tk.clamp(e.w,0,1-n)),this._dispatchSpriteChange(n1.border),e._onValueChanged=this._onBorderChange},t4(t,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(n1.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n1.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(n1.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(n1.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=tk.clamp(e.x,0,1),n=tk.clamp(e.y,0,1);this._atlasRegion.set(t,n,tk.clamp(e.width,0,1-t),tk.clamp(e.height,0,1-n)),this._dispatchSpriteChange(n1.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n1.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=tk.clamp(e.x,0,1),n=tk.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,tk.clamp(e.z,0,1-t),tk.clamp(e.w,0,1-n)),this._dispatchSpriteChange(n1.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n1.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}(ns);t6([nt],n8.prototype,"_onRegionChange",null),t6([nt],n8.prototype,"_onPivotChange",null),t6([nt],n8.prototype,"_onBorderChange",null);var n5=((S={})[S.SolidColor=0]="SolidColor",S[S.Sky=1]="Sky",S[S.Texture=2]="Texture",S),n9=((C={})[C.AspectFitWidth=0]="AspectFitWidth",C[C.AspectFitHeight=1]="AspectFitHeight",C[C.Fill=2]="Fill",C),n6=((T={})[T.Zero=0]="Zero",T[T.One=1]="One",T[T.SourceColor=2]="SourceColor",T[T.OneMinusSourceColor=3]="OneMinusSourceColor",T[T.DestinationColor=4]="DestinationColor",T[T.OneMinusDestinationColor=5]="OneMinusDestinationColor",T[T.SourceAlpha=6]="SourceAlpha",T[T.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",T[T.DestinationAlpha=8]="DestinationAlpha",T[T.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",T[T.SourceAlphaSaturate=10]="SourceAlphaSaturate",T[T.BlendColor=11]="BlendColor",T[T.OneMinusBlendColor=12]="OneMinusBlendColor",T),n7=((R={})[R.Add=0]="Add",R[R.Subtract=1]="Subtract",R[R.ReverseSubtract=2]="ReverseSubtract",R[R.Min=3]="Min",R[R.Max=4]="Max",R),re=((E={})[E.None=0]="None",E[E.Red=1]="Red",E[E.Green=2]="Green",E[E.Blue=4]="Blue",E[E.Alpha=8]="Alpha",E[E.All=15]="All",E),rt=((M={})[M.Never=0]="Never",M[M.Less=1]="Less",M[M.Equal=2]="Equal",M[M.LessEqual=3]="LessEqual",M[M.Greater=4]="Greater",M[M.NotEqual=5]="NotEqual",M[M.GreaterEqual=6]="GreaterEqual",M[M.Always=7]="Always",M),rn=((P={})[P.Off=0]="Off",P[P.Front=1]="Front",P[P.Back=2]="Back",P),rr=((w={})[w.Opaque=0]="Opaque",w[w.AlphaTest=1]="AlphaTest",w[w.Transparent=2]="Transparent",w),ri=((F={})[F.BlendStateEnabled0=0]="BlendStateEnabled0",F[F.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",F[F.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",F[F.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",F[F.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",F[F.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",F[F.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",F[F.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",F[F.BlendStateBlendColor=8]="BlendStateBlendColor",F[F.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",F[F.DepthStateEnabled=10]="DepthStateEnabled",F[F.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",F[F.DepthStateCompareFunction=12]="DepthStateCompareFunction",F[F.StencilStateEnabled=13]="StencilStateEnabled",F[F.StencilStateReferenceValue=14]="StencilStateReferenceValue",F[F.StencilStateMask=15]="StencilStateMask",F[F.StencilStateWriteMask=16]="StencilStateWriteMask",F[F.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",F[F.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",F[F.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",F[F.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",F[F.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",F[F.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",F[F.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",F[F.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",F[F.RasterStateCullMode=25]="RasterStateCullMode",F[F.RasterStateDepthBias=26]="RasterStateDepthBias",F[F.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",F[F.RenderQueueType=28]="RenderQueueType",F),ra=((L={})[L.Scene=0]="Scene",L[L.Camera=1]="Camera",L[L.Renderer=2]="Renderer",L[L.Material=3]="Material",L[L.RenderElement=4]="RenderElement",L),ro=((D={})[D.GLSLES100=0]="GLSLES100",D[D.GLSLES300=1]="GLSLES300",D),rs=((B={})[B.Float=0]="Float",B[B.Int=1]="Int",B[B.Vector2=2]="Vector2",B[B.Vector3=3]="Vector3",B[B.Vector4=4]="Vector4",B[B.Matrix=5]="Matrix",B[B.Color=6]="Color",B[B.Texture=7]="Texture",B[B.FloatArray=8]="FloatArray",B[B.IntArray=9]="IntArray",B[B.TextureArray=10]="TextureArray",B),rl=((I={})[I.Keep=0]="Keep",I[I.Zero=1]="Zero",I[I.Replace=2]="Replace",I[I.IncrementSaturate=3]="IncrementSaturate",I[I.DecrementSaturate=4]="DecrementSaturate",I[I.Invert=5]="Invert",I[I.IncrementWrap=6]="IncrementWrap",I[I.DecrementWrap=7]="DecrementWrap",I),rc=/*#__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}();rc._macroMaskMap=[],rc._macroNameIdMap=Object.create(null),rc._macroNameCounter=0,rc._macroCounter=0,rc._macroMap=Object.create(null);var ru=/*#__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 rd(){return(rd=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 rh=((N={}).DepthOnly="DepthOnly",N.ShadowCaster="ShadowCaster",N.Forward="Forward",N),r_=rd({common:"#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\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_EPS 4.8828125e-4 // 2^-11, machine epsilon: 1 + EPS = 1 (half of the ULP for 1.0f)\n\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n\nfloat pow2(float x ) {\n return x * x;\n}\n\nvec4 gammaToLinear(vec4 value){\n return vec4( pow(value.rgb, vec3(2.2)), value.a);\n}\n\nvec4 linearToGamma(vec4 value){\n value = max(value, 0.0);\n return vec4( pow(value.rgb, vec3(1.0 / 2.2)), value.a);\n}\n\n\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt\nfloat sRGBToLinear(float value){\n float linearRGBLo = value / 12.92;\n float linearRGBHi = pow((value + 0.055) / 1.055, 2.4);\n float linearRGB = (value <= 0.04045) ? linearRGBLo : linearRGBHi;\n return linearRGB;\n}\n\nvec4 sRGBToLinear(vec4 value){\n return vec4(sRGBToLinear(value.r), sRGBToLinear(value.g), sRGBToLinear(value.b), value.a);\n}\n\nfloat linearToSRGB(float value){\n value = max(value, 0.0);\n return (value <= 0.0031308) ? (value * 12.9232102) : 1.055 * pow(value, 1.0 / 2.4) - 0.055;\n}\n\nvec4 linearToSRGB(vec4 value){\n return vec4(linearToSRGB(value.r), linearToSRGB(value.g), linearToSRGB(value.b), value.a);\n}\n\n// Compatible with devices that do not even support EXT_sRGB in WebGL1.0.\nvec4 texture2DSRGB(sampler2D tex, vec2 uv) {\n vec4 color = texture2D(tex, uv);\n #ifdef ENGINE_NO_SRGB\n color = sRGBToLinear(color);\n #endif\n return color;\n}\n\nvec4 outputSRGBCorrection(vec4 linearIn){\n #ifdef ENGINE_OUTPUT_SRGB_CORRECT\n return linearToSRGB(linearIn);\n #else \n return linearIn;\n #endif\n}\n\n\nuniform vec4 camera_DepthBufferParams;\nuniform vec4 camera_ProjectionParams;\n\nfloat remapDepthBufferLinear01(float depth){\n return 1.0 / (camera_DepthBufferParams.x * depth + camera_DepthBufferParams.y);\n}\n\nfloat remapDepthBufferEyeDepth(float depth){\n #ifdef CAMERA_ORTHOGRAPHIC\n return camera_ProjectionParams.y + (camera_ProjectionParams.z - camera_ProjectionParams.y) * depth;\n #else\n return 1.0 / (camera_DepthBufferParams.z * depth + camera_DepthBufferParams.w);\n #endif\n}\n\n// From Next Generation Post Processing in Call of Duty: Advanced Warfare [Jimenez 2014]\n// http://advances.realtimerendering.com/s2014/index.html\n// sampleCoord must not be normalized (e.g. window coordinates)\nfloat interleavedGradientNoise(vec2 sampleCoord)\n{\n const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\n return fract(magic.z * fract(dot(sampleCoord, magic.xy)));\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\n\nvec3 safeNormalize(vec3 inVec) {\n float dp3 = max(float(HALF_MIN), dot(inVec, inVec));\n return inVec * inversesqrt(dp3);\n}\n",common_vert:"attribute 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\n#include <transform_declare>\n#include <camera_declare>\n\nuniform vec4 material_TilingOffset;\n\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:"uniform 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:"uniform vec3 camera_Position;\nuniform vec3 camera_Forward; ",color_share:"#ifdef RENDERER_ENABLE_VERTEXCOLOR\n\nvarying vec4 v_color;\n\n#endif\n",normal_share:"#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:"varying vec2 v_uv;\n\n#ifdef RENDERER_HAS_UV1\n varying vec2 v_uv1;\n#endif",worldpos_share:"#ifdef MATERIAL_NEED_WORLD_POS\n varying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#if SCENE_FOG_MODE != 0\n varying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#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",PositionClipSpaceDeclaration:"#ifdef SCENE_ENABLE_AMBIENT_OCCLUSION\n varying vec4 v_PositionCS;\n#endif",begin_normal_vert:"#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:" vec4 position = vec4( POSITION , 1.0 );\n",position_vert:" gl_Position = renderer_MVPMat * position;",color_vert:" #ifdef RENDERER_ENABLE_VERTEXCOLOR\n\n v_color = COLOR_0;\n\n #endif\n",normal_vert:"#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:"#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:"#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:"#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\n",uv_vert:"#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:"#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:"#if SCENE_FOG_MODE != 0\n vec4 positionVS = renderer_MVMat * position;\n v_positionVS = positionVS.xyz / positionVS.w;\n#endif\n",light_frag_define:"// 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\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\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\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:"uniform 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:"#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",PositionClipSpaceVertex:"#ifdef SCENE_ENABLE_AMBIENT_OCCLUSION\n v_PositionCS = gl_Position;\n#endif\n",begin_mobile_frag:" 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 emission *= texture2DSRGB(material_EmissiveTexture, v_uv);\n #endif\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n diffuse *= texture2DSRGB(material_BaseTexture, v_uv);\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n diffuse *= v_color;\n #endif\n\n #ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n specular *= texture2DSRGB(material_SpecularTexture, v_uv);\n #endif\n\n ambient = vec4(scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity, 1.0) * diffuse;",begin_viewdir_frag:"#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:" #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:"// 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:'\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:'\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:'\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:'\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:"#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:'//\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:'//\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:'//\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:"#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:'// 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:"//\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:"//\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:"//\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:"//\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:"#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"\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:"#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\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:'// ------------------------------------------------------------------\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:"#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:"#ifdef SCENE_IS_CALCULATE_SHADOWS\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n v_shadowCoord = getShadowCoord();\n #endif\n#endif"},{pbr_frag_define:"#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_EmissiveColor;\nuniform float material_NormalIntensity;\nuniform float material_OcclusionIntensity;\nuniform float material_OcclusionTextureCoord;\nuniform float material_SpecularIntensity;\nuniform vec3 material_SpecularColor;\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_TEXTURE\n uniform sampler2D material_SpecularIntensityTexture;\n#endif\n\n#ifdef MATERIAL_HAS_SPECULAR_COLOR_TEXTURE\n uniform sampler2D material_SpecularColorTexture;\n#endif\n\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n uniform sampler2D material_OcclusionTexture;\n#endif\n\n\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform float material_SheenRoughness;\n uniform vec3 material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n uniform sampler2D material_SheenTexture;\n #endif\n\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n uniform sampler2D material_SheenRoughnessTexture;\n #endif\n#endif\n\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n uniform vec4 material_IridescenceInfo;\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n uniform sampler2D material_IridescenceThicknessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n uniform sampler2D material_IridescenceTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION\n uniform float material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n uniform sampler2D material_TransmissionTexture;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n uniform vec3 material_AttenuationColor;\n uniform float material_AttenuationDistance;\n uniform float material_Thickness;\n\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n uniform sampler2D material_ThicknessTexture;\n #endif\n #endif\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 specularF0;\n vec3 resolvedSpecularF0;\n float specularF90;\n float specularIntensity;\n vec3 specularColor;\n float opacity;\n float diffuseAO;\n float specularAO;\n vec3 envSpecularDFG;\n vec3 energyCompensation; // Multi-scattering energy compensation factor\n float IOR;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoat;\n float clearCoatRoughness;\n #endif\n\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float iridescenceIOR;\n float iridescenceFactor;\n float iridescenceThickness;\n vec3 iridescenceSpecularColor;\n #endif\n\n #ifdef MATERIAL_ENABLE_SHEEN\n float sheenRoughness;\n vec3 sheenColor;\n float sheenScaling;\n float approxIBLSheenDG;\n #endif\n\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 absorptionCoefficient;\n float transmission;\n float thickness;\n #endif\n};\n",pbr_helper:'#include <normal_get>\n#include <brdf>\n#include <btdf>\n\n// direct + indirect\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n\nuniform sampler2D camera_AOTexture;\n\nfloat evaluateAmbientOcclusion(vec2 uv)\n{\n #ifdef MATERIAL_IS_TRANSPARENT\n return 1.0;\n #else\n return texture2D(camera_AOTexture, uv).r;\n #endif\n}\n\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\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 float alphaCutoff = material_AlphaCutoff;\n material.IOR = material_IOR;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n baseColor *= texture2DSRGB(material_BaseTexture, v_uv);\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n baseColor *= v_color;\n #endif\n\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 // Specular\n material.specularIntensity = material_SpecularIntensity;\n material.specularColor = material_SpecularColor;\n #ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n material.specularIntensity *= texture2D( material_SpecularIntensityTexture, v_uv ).a;\n #endif\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\n material.roughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(roughness + getAARoughnessFactor(geometry.normal), 1.0));\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n geometry.anisotropicN = getAnisotropicBentNormal(geometry, geometry.normal, material.roughness);\n #endif\n\n vec3 dielectricBaseF0 = vec3(pow2( (material.IOR - 1.0) / (material.IOR + 1.0) ));\n vec3 dielectricF0 = min(dielectricBaseF0 * material.specularColor , vec3(1.0)) * material.specularIntensity;\n float dielectricF90 = material.specularIntensity; \n\n material.specularF0 = mix(dielectricF0, baseColor.rgb, metal);\n material.specularF90 = mix(dielectricF90, 1.0, metal);\n material.resolvedSpecularF0 = material.specularF0;\n\n // Simplify: albedoColor * mix((1.0 - max(max(dielectricF0.r,dielectricF0.g),dielectricF0.b)), 0.0, metallic);\n material.diffuseColor = baseColor.rgb * (1.0 - metal) * (1.0 - max(max(dielectricF0.r,dielectricF0.g),dielectricF0.b));\n // Environment BRDF\n vec2 dfg = envDFGApprox(material.roughness, geometry.dotNV);\n\n // AO\n float diffuseAO = 1.0;\n float specularAO = 1.0;\n\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 diffuseAO = ((texture2D(material_OcclusionTexture, aoUV)).r - 1.0) * material_OcclusionIntensity + 1.0;\n #endif\n\n #ifdef SCENE_ENABLE_AMBIENT_OCCLUSION\n float ambientAO = evaluateAmbientOcclusion((v_PositionCS.xy / v_PositionCS.w) * 0.5 + 0.5);\n diffuseAO = min(diffuseAO, ambientAO);\n #endif\n\n #if (defined(MATERIAL_HAS_OCCLUSION_TEXTURE) || defined(SCENE_ENABLE_AMBIENT_OCCLUSION))&& defined(SCENE_USE_SPECULAR_ENV) \n specularAO = saturate( pow( geometry.dotNV + diffuseAO, exp2( - 16.0 * material.roughness - 1.0 ) ) - 1.0 + diffuseAO );\n #endif\n\n material.diffuseAO = diffuseAO;\n material.specularAO = specularAO;\n\n // Sheen\n #ifdef MATERIAL_ENABLE_SHEEN\n vec3 sheenColor = material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n sheenColor *= texture2DSRGB(material_SheenTexture, v_uv).rgb;\n #endif\n material.sheenColor = sheenColor;\n\n material.sheenRoughness = material_SheenRoughness;\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n material.sheenRoughness *= texture2D(material_SheenRoughnessTexture, v_uv).a;\n #endif\n\n material.sheenRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.sheenRoughness + getAARoughnessFactor(geometry.normal), 1.0));\n material.approxIBLSheenDG = prefilteredSheenDFG(geometry.dotNV, material.sheenRoughness);\n material.sheenScaling = 1.0 - material.approxIBLSheenDG * max(max(material.sheenColor.r, material.sheenColor.g), material.sheenColor.b);\n #endif\n\n // Iridescence\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n material.iridescenceFactor = material_IridescenceInfo.x;\n material.iridescenceIOR = material_IridescenceInfo.y;\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n float iridescenceThicknessWeight = texture2D( material_IridescenceThicknessTexture, v_uv).g;\n material.iridescenceThickness = mix(material_IridescenceInfo.z, material_IridescenceInfo.w, iridescenceThicknessWeight);\n #else\n material.iridescenceThickness = material_IridescenceInfo.w;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n material.iridescenceFactor *= texture2D( material_IridescenceTexture, v_uv).r;\n #endif\n \n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float topIOR = 1.0;\n material.iridescenceSpecularColor = evalIridescenceSpecular(topIOR, geometry.dotNV, material.iridescenceIOR, material.specularF0, material.specularF90, material.iridescenceThickness);\n material.resolvedSpecularF0 = mix(material.resolvedSpecularF0, material.iridescenceSpecularColor, material.iridescenceFactor);\n #endif\n #endif\n\n material.envSpecularDFG = material.resolvedSpecularF0 * dfg.x + material.specularF90 * dfg.y;\n\n // Multi-scattering energy compensation\n // Ref: Kulla & Conty 2017, "Revisiting Physically Based Shading at Imageworks"\n // Ref: Lagarde & Golubev 2018, simplified multiplier approach\n material.energyCompensation = 1.0 + material.resolvedSpecularF0 * (1.0 / max(dfg.x + dfg.y, EPSILON) - 1.0);\n\n // Transmission\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n material.transmission = material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n material.transmission *= texture2D(material_TransmissionTexture, v_uv).r;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n material.absorptionCoefficient = -log(material_AttenuationColor + HALF_EPS) / max(HALF_EPS, material_AttenuationDistance);\n material.thickness = max(material_Thickness, 0.0001);\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n material.thickness *= texture2D( material_ThicknessTexture, v_uv).g;\n #endif\n #endif \n #endif\n}\n\n',brdf:'\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform sampler2D scene_PrefilteredDFG;\n#endif\n\nfloat F_Schlick(float f0, float f90, float dotLH) {\n return f0 + (f90 - f0) * (pow(1.0 - dotLH, 5.0));\n}\n\nvec3 F_Schlick(vec3 f0, float f90, 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 (f90 - f0 ) * fresnel + f0;\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_SHEEN\n // http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf\n float D_Charlie(float roughness, float dotNH) {\n float invAlpha = 1.0 / roughness;\n float cos2h = dotNH * dotNH;\n float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n }\n\n // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886".\n float V_Neubelt(float NoV, float NoL) {\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n }\n\n vec3 sheenBRDF(vec3 incidentDirection, Geometry geometry, vec3 sheenColor, float sheenRoughness) {\n vec3 halfDir = normalize(incidentDirection + geometry.viewDir);\n float dotNL = saturate(dot(geometry.normal, incidentDirection));\n float dotNH = saturate(dot(geometry.normal, halfDir));\n float D = D_Charlie(sheenRoughness, dotNH);\n float V = V_Neubelt(geometry.dotNV, dotNL);\n vec3 F = sheenColor;\n return D * V * F;\n }\n\n float prefilteredSheenDFG(float dotNV, float sheenRoughness) {\n #ifdef HAS_TEX_LOD\n return texture2DLodEXT(scene_PrefilteredDFG, vec2(dotNV, sheenRoughness), 0.0).b;\n #else\n return texture2D(scene_PrefilteredDFG, vec2(dotNV, sheenRoughness),0.0).b;\n #endif \n }\n#endif\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\nfloat DG_GGX(float alpha, float dotNV, float dotNL, float dotNH) {\n float D = D_GGX( alpha, dotNH );\n float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n return G * D;\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n float DG_GGX_anisotropic(vec3 h, vec3 l, Geometry geometry, float alpha, float dotNV, float dotNL, float dotNH) {\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 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 G * D;\n }\n#endif\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n vec3 iorToFresnel0(vec3 transmittedIOR, float incidentIOR) {\n return pow((transmittedIOR - incidentIOR) / (transmittedIOR + incidentIOR),vec3(2.0));\n } \n\n float iorToFresnel0(float transmittedIOR, float incidentIOR) {\n return pow((transmittedIOR - incidentIOR) / (transmittedIOR + incidentIOR),2.0);\n } \n\n // Assume air interface for top\n // Note: We don\'t handle the case fresnel0 == 1\n vec3 fresnelToIOR(vec3 f0){\n vec3 sqrtF0 = sqrt(f0);\n return (vec3(1.0) + sqrtF0) / (vec3(1.0) - sqrtF0);\n }\n\n // Fresnel equations for dielectric/dielectric interfaces.\n // Ref: https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html\n // Evaluation XYZ sensitivity curves in Fourier space\n vec3 evalSensitivity(float opd, vec3 shift){\n // Use Gaussian fits, given by 3 parameters: val, pos and var\n float phase = 2.0 * PI * opd * 1.0e-9;\n const vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n const vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06);\n const vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09);\n vec3 xyz = val * sqrt(2.0 * PI * var) * cos(pos * phase + shift) * exp(-var * pow2(phase));\n xyz.x += 9.7470e-14 * sqrt(2.0 * PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift[0]) * exp(-4.5282e+09 * pow2(phase));\n xyz /= 1.0685e-7;\n // XYZ to RGB color space\n const mat3 XYZ_TO_RGB = mat3( 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252);\n vec3 rgb = XYZ_TO_RGB * xyz;\n return rgb;\n }\n\n vec3 evalIridescenceSpecular(float outsideIOR, float dotNV, float thinIOR, vec3 baseF0, float baseF90, float iridescenceThickness){ \n vec3 iridescence = vec3(1.0);\n // Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0\n float iridescenceIOR = mix( outsideIOR, thinIOR, smoothstep( 0.0, 0.03, iridescenceThickness ) );\n // Evaluate the cosTheta on the base layer (Snell law)\n float sinTheta2Sq = pow( outsideIOR / iridescenceIOR, 2.0) * (1.0 - pow( dotNV, 2.0));\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n // Handle total internal reflection\n if (cosTheta2Sq < 0.0) {\n return iridescence;\n }\n float cosTheta2 = sqrt(cosTheta2Sq);\n \n // First interface\n float f0 = iorToFresnel0(iridescenceIOR, outsideIOR);\n float reflectance = F_Schlick(f0, baseF90, dotNV);\n float t121 = 1.0 - reflectance;\n float phi12 = 0.0;\n // iridescenceIOR has limited greater than 1.0\n // if (iridescenceIOR < outsideIOR) {phi12 = PI;} \n float phi21 = PI - phi12;\n \n // Second interface\n vec3 baseIOR = fresnelToIOR(clamp(baseF0, 0.0, 0.9999)); // guard against 1.0\n vec3 r1 = iorToFresnel0(baseIOR, iridescenceIOR);\n vec3 r23 = F_Schlick(r1, baseF90, cosTheta2);\n vec3 phi23 =vec3(0.0);\n if (baseIOR[0] < iridescenceIOR) {phi23[0] = PI;}\n if (baseIOR[1] < iridescenceIOR) {phi23[1] = PI;}\n if (baseIOR[2] < iridescenceIOR) {phi23[2] = PI;}\n \n // Phase shift\n float opd = 2.0 * iridescenceIOR * iridescenceThickness * cosTheta2;\n vec3 phi = vec3(phi21) + phi23;\n \n // Compound terms\n vec3 r123 = clamp(reflectance * r23, 1e-5, 0.9999);\n vec3 sr123 = sqrt(r123);\n vec3 rs = pow2(t121) * r23 / (vec3(1.0) - r123);\n // Reflectance term for m = 0 (DC term amplitude)\n vec3 c0 = reflectance + rs;\n iridescence = c0;\n // Reflectance term for m > 0 (pairs of diracs)\n vec3 cm = rs - t121;\n for (int m = 1; m <= 2; ++m) {\n cm *= sr123;\n vec3 sm = 2.0 * evalSensitivity(float(m) * opd, float(m) * phi);\n iridescence += cm * sm;\n }\n return iridescence = max(iridescence, vec3(0.0)); \n }\n#endif\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX(vec3 incidentDirection, Geometry geometry, Material material, 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 vec3 F = F_Schlick( specularColor, material.specularF90, dotLH );\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n F = mix(F, material.iridescenceSpecularColor, material.iridescenceFactor);\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n float GD = DG_GGX_anisotropic(halfDir, incidentDirection, geometry, alpha, dotNV, dotNL, dotNH);\n #else\n float GD = DG_GGX(alpha, dotNV, dotNL, dotNH);\n #endif\n\n return F * GD;\n}\n\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\n',direct_irradiance_frag_define:"#include <ShadowFragmentDeclaration>\n\nvoid sheenLobe(Geometry geometry, Material material, vec3 incidentDirection, vec3 attenuationIrradiance, inout vec3 diffuseColor, inout vec3 specularColor){\n #ifdef MATERIAL_ENABLE_SHEEN\n diffuseColor *= material.sheenScaling;\n specularColor *= material.sheenScaling;\n\n specularColor += attenuationIrradiance * sheenBRDF(incidentDirection, geometry, material.sheenColor, material.sheenRoughness);\n #endif\n}\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, material, geometry.clearCoatNormal, vec3( 0.04 ), material.clearCoatRoughness );\n attenuation -= material.clearCoat * F_Schlick(0.04, 1.0, 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, material, geometry.normal, material.specularF0, material.roughness) * material.energyCompensation;\n reflectedLight.directDiffuse += attenuation * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n // Sheen Lobe\n sheenLobe(geometry, material, incidentDirection, attenuation * irradiance, reflectedLight.directDiffuse, reflectedLight.directSpecular);\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\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:"// ------------------------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// Returns raw DFG approximation coefficients (split-sum LUT approximation)\nvec2 envDFGApprox(float roughness, float dotNV) {\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n return vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 envBRDFApprox(vec3 f0, float f90, float roughness, float dotNV ) {\n vec2 AB = envDFGApprox(roughness, dotNV);\n return f0 * AB.x + f90 * AB.y;\n}\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 ENGINE_NO_SRGB\n envMapColor = sRGBToLinear(envMapColor);\n #endif\n \n return envMapColor.rgb * specularIntensity;\n\n #endif\n\n}\n\n\nvoid evaluateSheenIBL(Geometry geometry, Material material, float radianceAttenuation, inout vec3 diffuseColor, inout vec3 specularColor){\n #ifdef MATERIAL_ENABLE_SHEEN\n diffuseColor *= material.sheenScaling;\n specularColor *= material.sheenScaling;\n\n vec3 reflectance = material.specularAO * radianceAttenuation * material.approxIBLSheenDG * material.sheenColor;\n specularColor += reflectance;\n #endif\n}",pbr_frag:"Geometry 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 irradiance *= scene_EnvMapLight.diffuseIntensity;\n#else\n vec3 irradiance = scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity;\n irradiance *= PI;\n#endif\n\nreflectedLight.indirectDiffuse += material.diffuseAO * 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// IBL Clear Coat\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 += material.specularAO * clearCoatRadiance * material.clearCoat * envBRDFApprox(vec3( 0.04 ), 1.0, material.clearCoatRoughness, geometry.clearCoatDotNV);\n radianceAttenuation -= material.clearCoat * F_Schlick(0.04, 1.0, geometry.clearCoatDotNV);\n#endif\n\nreflectedLight.indirectSpecular += material.specularAO * radianceAttenuation * radiance * envBRDFApprox(material.resolvedSpecularF0, material.specularF90, material.roughness, geometry.dotNV) * material.energyCompensation;\n\n\n// IBL Sheen\nevaluateSheenIBL(geometry, material, radianceAttenuation, reflectedLight.indirectDiffuse, reflectedLight.indirectSpecular);\n\n\n// Final color\nvec3 totalDiffuseColor = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nvec3 totalSpecularColor = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 refractionTransmitted = evaluateTransmission(geometry, material);\n totalDiffuseColor = mix(totalDiffuseColor, refractionTransmitted, material.transmission);\n#endif\n\nvec4 finalColor = vec4(totalDiffuseColor + totalSpecularColor, material.opacity);\n\n\n// Emissive\nvec3 emissiveRadiance = material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n emissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_uv).rgb;\n#endif\n\nfinalColor.rgb += emissiveRadiance;\n\n\ngl_FragColor = finalColor;\n",btdf:"#include <refraction>\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION \n uniform sampler2D camera_OpaqueTexture;\n vec3 evaluateTransmission(Geometry geometry, Material material) {\n RefractionModelResult ray;\n #if REFRACTION_MODE == 0 \n // RefractionMode.Sphere\n refractionModelSphere(-geometry.viewDir, geometry.position, geometry.normal, material.IOR, material.thickness, ray);\n #elif REFRACTION_MODE == 1\n // RefractionMode.Planar\n refractionModelPlanar(-geometry.viewDir, geometry.position, geometry.normal, material.IOR, material.thickness, ray);\n #endif\n\n vec3 refractedRayExit = ray.positionExit;\n\n // We calculate the screen space position of the refracted point\n vec4 samplingPositionNDC = camera_ProjMat * camera_ViewMat * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = (samplingPositionNDC.xy / samplingPositionNDC.w) * 0.5 + 0.5;\n\n // Sample the opaque texture to get the transmitted light\n vec3 refractionTransmitted = texture2DSRGB(camera_OpaqueTexture, refractionCoords).rgb;\n refractionTransmitted *= material.diffuseColor;\n \n // Use specularFGD as an approximation of the fresnel effect\n // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf\n refractionTransmitted *= (1.0 - material.envSpecularDFG);\n\n #ifdef MATERIAL_HAS_THICKNESS\n // Absorption coefficient from Disney: http://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf\n vec3 transmittance = min(vec3(1.0), exp(-material.absorptionCoefficient * ray.transmissionLength));\n refractionTransmitted *= transmittance;\n #endif\n \n return refractionTransmitted;\n }\n#endif",refraction:"#ifdef MATERIAL_ENABLE_TRANSMISSION \n struct RefractionModelResult {\n float transmissionLength; // length of the transmission during refraction through the shape\n vec3 positionExit; // out ray position\n // vec3 directionExit; // out ray direction\n };\n\n //https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@15.0/manual/refraction-models.html\n void refractionModelSphere(vec3 V, vec3 positionWS, vec3 normalWS, float ior, float thickness, out RefractionModelResult ray) {\n // Refracted ray\n vec3 R1 = refract(V, normalWS, 1.0 / ior);\n // Center of the tangent sphere\n // vec3 C = positionWS - normalWS * thickness * 0.5;\n\n // Second refraction (tangent sphere out)\n float dist = dot(-normalWS, R1) * thickness;\n // Out hit point in the tangent sphere\n vec3 P1 = positionWS + R1 * dist;\n // Out normal\n // vec3 N1 = safeNormalize(C - P1);\n // Out refracted ray\n // vec3 R2 = refract(R1, N1, ior);\n\n ray.transmissionLength = dist;\n ray.positionExit = P1;\n // ray.directionExit = R2; \n }\n\n void refractionModelPlanar(vec3 V, vec3 positionWS, vec3 normalWS, float ior, float thickness, out RefractionModelResult ray) {\n // Refracted ray\n vec3 R = refract(V, normalWS, 1.0 / ior);\n // Optical depth within the thin plane\n float dist = thickness / max(dot(-normalWS, R), 1e-5f);\n\n ray.transmissionLength = dist;\n ray.positionExit = vec3(positionWS + R * dist);\n // ray.directionExit = V;\n }\n\n#endif"},{normal_get:"// 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:"vec3 rotationByQuaternions(in vec3 v, in vec4 q) {\n return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\nvec4 quaternionConjugate(in vec4 q) {\n return vec4(-q.xyz, q.w);\n}\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 cosYawPitch = cosYaw * cosPitch;\n float sinYawPitch = sinYaw * sinPitch;\n\n float quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n float quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n float quaZ = (cosYawPitch * sinRoll) - (sinYawPitch * cosRoll);\n float quaW = (cosYawPitch * cosRoll) + (sinYawPitch * sinRoll);\n\n return rotationByQuaternions(vector, vec4(quaX, quaY, quaZ, quaW));\n}\n\n// Assume axis is normalized\nvec3 rotationByAxis(in vec3 vector, in vec3 axis, in float angle) {\n float halfAngle = angle * 0.5;\n float s = sin(halfAngle);\n\n return rotationByQuaternions(vector, vec4(axis * s, cos(halfAngle)));\n}\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, out float currentValue){\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 currentValue = mix(lastValue, key.y, age);\n cumulativeValue += (lastValue + currentValue) * 0.5 * offsetTime;\n break;\n }\n else{\n cumulativeValue += (lastValue + key.y) * 0.5 * (time - lastKey.x);\n }\n }\n return cumulativeValue;\n}\n\nvec4 evaluateParticleGradient(in vec4 colorKeys[4], in float colorMaxTime, in vec2 alphaKeys[4], in float alphaMaxTime, in float t) {\n vec4 value;\n\n float alphaT = min(t, alphaMaxTime);\n for (int i = 0; i < 4; i++) {\n vec2 key = alphaKeys[i];\n if (alphaT <= key.x) {\n if (i == 0) {\n value.a = alphaKeys[0].y;\n } else {\n vec2 lastKey = alphaKeys[i - 1];\n float age = (alphaT - lastKey.x) / (key.x - lastKey.x);\n value.a = mix(lastKey.y, key.y, age);\n }\n break;\n }\n }\n\n float colorT = min(t, colorMaxTime);\n for (int i = 0; i < 4; i++) {\n vec4 key = colorKeys[i];\n if (colorT <= key.x) {\n if (i == 0) {\n value.rgb = colorKeys[0].yzw;\n } else {\n vec4 lastKey = colorKeys[i - 1];\n float age = (colorT - lastKey.x) / (key.x - lastKey.x);\n value.rgb = mix(lastKey.yzw, key.yzw, age);\n }\n break;\n }\n }\n\n return value;\n}",velocity_over_lifetime_module:"#if defined(RENDERER_VOL_CONSTANT_MODE) || defined(RENDERER_VOL_CURVE_MODE)\n #define _VOL_MODULE_ENABLED\n#endif\n\n#ifdef _VOL_MODULE_ENABLED\n uniform int renderer_VOLSpace;\n\n #ifdef RENDERER_VOL_CONSTANT_MODE\n uniform vec3 renderer_VOLMaxConst;\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n uniform vec3 renderer_VOLMinConst;\n #endif\n #endif\n\n #ifdef RENDERER_VOL_CURVE_MODE\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_IS_RANDOM_TWO\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\n\n vec3 computeVelocityPositionOffset(in float normalizedAge, in float age, out vec3 currentVelocity) {\n vec3 velocityPosition;\n\n #ifdef RENDERER_VOL_CONSTANT_MODE\n currentVelocity = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n currentVelocity = mix(renderer_VOLMinConst, currentVelocity, a_Random1.yzw);\n #endif\n\n velocityPosition = currentVelocity * age;\n #endif\n\n #ifdef RENDERER_VOL_CURVE_MODE\n velocityPosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientX, normalizedAge, currentVelocity.x),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientY, normalizedAge, currentVelocity.y),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ, normalizedAge, currentVelocity.z));\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minCurrentVelocity;\n vec3 minVelocityPosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMinGradientX, normalizedAge, minCurrentVelocity.x),\n evaluateParticleCurveCumulative(renderer_VOLMinGradientY, normalizedAge, minCurrentVelocity.y),\n evaluateParticleCurveCumulative(renderer_VOLMinGradientZ, normalizedAge, minCurrentVelocity.z));\n\n currentVelocity = mix(minCurrentVelocity, currentVelocity, a_Random1.yzw);\n velocityPosition = mix(minVelocityPosition, velocityPosition, a_Random1.yzw);\n #endif\n\n velocityPosition *= vec3(a_ShapePositionStartLifeTime.w);\n #endif\n return velocityPosition;\n }\n#endif\n",rotation_over_lifetime_module:"#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 currentValue;\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue), 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\n#if defined(RENDERER_MODE_MESH) && (defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE))\nvec3 computeParticleRotationVec3(in vec3 rotation, in float age, in float normalizedAge) {\n #ifdef RENDERER_ROL_IS_SEPARATE\n #ifdef RENDERER_ROL_CONSTANT_MODE\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n vec3 ageRot = mix(renderer_ROLMinConst, renderer_ROLMaxConst, a_Random0.w) * age;\n #else\n vec3 ageRot = renderer_ROLMaxConst * age;\n #endif\n rotation += ageRot;\n #endif\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifetime = a_ShapePositionStartLifeTime.w;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n rotation += vec3(\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveX, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveX, normalizedAge, currentValue), a_Random0.w),\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveY, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveY, normalizedAge, currentValue), a_Random0.w),\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue), a_Random0.w)) * lifetime;\n #else\n rotation += vec3(\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveX, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveY, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue)) * lifetime;\n #endif\n #endif\n #else\n #ifdef RENDERER_ROL_CONSTANT_MODE\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n float ageRot = mix(renderer_ROLMinConst.z, renderer_ROLMaxConst.z, a_Random0.w) * age;\n #else\n float ageRot = renderer_ROLMaxConst.z * age;\n #endif\n rotation += ageRot;\n #endif\n\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue), lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * a_ShapePositionStartLifeTime.w;\n #endif\n #endif\n return rotation;\n}\n#endif\n",size_over_lifetime_module:"#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:"#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\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:"#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",force_over_lifetime_module:"#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE)\n #define _FOL_MODULE_ENABLED\n#endif\n\n#ifdef _FOL_MODULE_ENABLED\n uniform int renderer_FOLSpace;\n\n #ifdef RENDERER_FOL_CONSTANT_MODE\n uniform vec3 renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec3 renderer_FOLMinConst;\n #endif\n\n #endif\n\n #ifdef RENDERER_FOL_CURVE_MODE\n uniform vec2 renderer_FOLMaxGradientX[4];\n uniform vec2 renderer_FOLMaxGradientY[4];\n uniform vec2 renderer_FOLMaxGradientZ[4];\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec2 renderer_FOLMinGradientX[4];\n uniform vec2 renderer_FOLMinGradientY[4];\n uniform vec2 renderer_FOLMinGradientZ[4];\n #endif\n #endif\n\n // (tHat - t1) * (tHat - t1) * (tHat - t1) * (a2 - a1) / ((t2 - t1) * 6.0) + a1 * (tHat - t1) * (tHat - t1) * 0.5 + v1 * (tHat - t1);\n // to = tHat - t1; tr = t2 - t1\n float computeDisplacementIntegral(in float to, in float tr, in float a1, in float a2, in float v1) {\n return to * to * to * (a2 - a1) / (tr * 6.0) + a1 * to * to * 0.5 + v1 * to;\n }\n\n float evaluateForceParticleCurveCumulative(in vec2 keys[4], in float normalizedAge, out float velocityCumulative) {\n float cumulativeValue = 0.0;\n velocityCumulative = 0.0;\n\n for (int i = 1; i < 4; i++){\n vec2 key = keys[i];\n vec2 lastKey = keys[i - 1];\n float timeRange = (key.x - lastKey.x) * a_ShapePositionStartLifeTime.w;\n\n if (key.x >= normalizedAge){\n float timeOffset = (normalizedAge - lastKey.x) * a_ShapePositionStartLifeTime.w;\n cumulativeValue += computeDisplacementIntegral(timeOffset, timeRange, lastKey.y, key.y, velocityCumulative);\n\n float finalAcceleration = mix(lastKey.y, key.y, timeOffset / timeRange);\n velocityCumulative += 0.5 * timeOffset * (finalAcceleration + lastKey.y);\n break;\n } else { \n cumulativeValue += computeDisplacementIntegral(timeRange, timeRange, lastKey.y, key.y, velocityCumulative);\n velocityCumulative += 0.5 * timeRange * (lastKey.y + key.y);\n }\n }\n return cumulativeValue;\n }\n\n vec3 computeForcePositionOffset(in float normalizedAge, in float age, out vec3 velocityOffset) {\n vec3 forcePosition;\n\n #if defined(RENDERER_FOL_CONSTANT_MODE)\n vec3 forceAcceleration = renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n forceAcceleration = mix(renderer_FOLMinConst, forceAcceleration, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n\n velocityOffset = forceAcceleration * age;\n\n forcePosition = 0.5 * forceAcceleration * age * age;\n #elif defined(RENDERER_FOL_CURVE_MODE)\n forcePosition = vec3(\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientX, normalizedAge, velocityOffset.x),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientY, normalizedAge, velocityOffset.y),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientZ, normalizedAge, velocityOffset.z)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minVelocityOffset;\n\n forcePosition = vec3(\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientX, normalizedAge, minVelocityOffset.x), forcePosition.x, a_Random2.x),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientY, normalizedAge, minVelocityOffset.y), forcePosition.y, a_Random2.y),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientZ, normalizedAge, minVelocityOffset.z), forcePosition.z, a_Random2.z)\n );\n\n velocityOffset = mix(minVelocityOffset, velocityOffset, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n return forcePosition;\n }\n#endif",limit_velocity_over_lifetime_module:"#ifdef RENDERER_LVL_MODULE_ENABLED\n uniform int renderer_LVLSpace;\n uniform float renderer_LVLDampen;\n\n // Scalar limit\n #ifndef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform float renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform float renderer_LVLSpeedMinConst;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedMinCurve[4];\n #endif\n #endif\n #endif\n\n // Per-axis limit\n #ifdef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform vec3 renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec3 renderer_LVLSpeedMinConstVector;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedXMaxCurve[4];\n uniform vec2 renderer_LVLSpeedYMaxCurve[4];\n uniform vec2 renderer_LVLSpeedZMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedXMinCurve[4];\n uniform vec2 renderer_LVLSpeedYMinCurve[4];\n uniform vec2 renderer_LVLSpeedZMinCurve[4];\n #endif\n #endif\n #endif\n\n // Drag curve\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n uniform vec2 renderer_LVLDragMaxCurve[4];\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n uniform vec2 renderer_LVLDragMinCurve[4];\n #endif\n #endif\n\n float evaluateLVLDrag(float normalizedAge, float dragRand) {\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n float dragMax = evaluateParticleCurve(renderer_LVLDragMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n float dragMin = evaluateParticleCurve(renderer_LVLDragMinCurve, normalizedAge);\n return mix(dragMin, dragMax, dragRand);\n #else\n return dragMax;\n #endif\n #else\n return mix(renderer_LVLDragConstant.x, renderer_LVLDragConstant.y, dragRand);\n #endif\n }\n\n vec3 applyLVLSpeedLimitTF(vec3 velocity, float normalizedAge, float limitRand, float effectiveDampen) {\n #ifdef RENDERER_LVL_SEPARATE_AXES\n vec3 limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConstVector, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMaxCurve, normalizedAge)\n );\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n vec3 minLimitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMinCurve, normalizedAge)\n );\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n vec3 absVel = abs(velocity);\n vec3 excess = max(absVel - limitSpeed, vec3(0.0));\n velocity = sign(velocity) * (absVel - excess * effectiveDampen);\n #else\n float limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConst, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = evaluateParticleCurve(renderer_LVLSpeedMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n float minLimitSpeed = evaluateParticleCurve(renderer_LVLSpeedMinCurve, normalizedAge);\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n float speed = length(velocity);\n if (speed > limitSpeed && speed > 0.0) {\n float excess = speed - limitSpeed;\n velocity = velocity * ((speed - excess * effectiveDampen) / speed);\n }\n #endif\n return velocity;\n }\n\n#endif\n",particle_feedback_simulation:"// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // Only VOL overlay needs to be added here.\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n // Local: integrate in local space\n totalVelocity = localVelocity + volLocal\n + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n // World: integrate in world space\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n",sphere_billboard:"#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 = radians(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 = radians(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, radians(a_StartRotation0));\n } else {\n float c = cos(radians(a_StartRotation0.x));\n float s = sin(radians(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:"#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n vec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n vec3 velocity = rotationByQuaternions(renderer_SizeScale * localVelocity, worldRotation) + worldVelocity;\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:"#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 = radians(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:"#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 = radians(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:"// Only support local alignment mode\n#ifdef RENDERER_MODE_MESH\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n #define RENDERER_ROL_ENABLED\n #endif\n\n vec3 size = computeParticleSizeMesh(a_StartSize, normalizedAge);\n\n bool is3DRotation = renderer_ThreeDStartRotation;\n #if defined(RENDERER_ROL_ENABLED) && defined(RENDERER_ROL_IS_SEPARATE)\n is3DRotation = true;\n #endif\n\n if (is3DRotation) {\n #ifdef RENDERER_ROL_ENABLED\n vec3 startRotation = renderer_ThreeDStartRotation ? a_StartRotation0 : vec3(0.0, 0.0, a_StartRotation0.x);\n vec3 rotation = radians(computeParticleRotationVec3(startRotation, age, normalizedAge));\n #else\n vec3 rotation = radians(a_StartRotation0);\n #endif\n // 3D Start Rotation is same in local and world simulation space\n center += rotationByQuaternions(renderer_SizeScale * rotationByEuler(POSITION * size, rotation), worldRotation);\n } else {\n #ifdef RENDERER_ROL_ENABLED\n float angle = radians(computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge));\n #else\n float angle = radians(a_StartRotation0.x);\n #endif\n #ifdef RENDERER_EMISSION_SHAPE\n // Axis is side vector of emit position look at zero\n vec3 axis = vec3(a_ShapePositionStartLifeTime.xy, 0.0);\n if (renderer_SimulationSpace == 1){\n axis = rotationByQuaternions(axis, worldRotation);\n }\n vec3 crossResult = cross(axis, vec3(0.0, 0.0, -1.0));\n float crossLen = length(crossResult);\n vec3 rotateAxis = crossLen > 0.0001 ? crossResult / crossLen : vec3(0.0, 1.0, 0.0);\n #else\n // Axis is negative z\n vec3 rotateAxis = vec3(0.0, 0.0, -1.0);\n #endif\n center += rotationByQuaternions(renderer_SizeScale *rotationByAxis(POSITION * size, rotateAxis, angle), worldRotation);\n }\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n v_MeshColor = COLOR_0;\n #endif\n#endif"}),rf=/*#__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.compilePlatformSource=function(t,n,r,i){var a=t._hardwareRenderer.isWebGL2,o=[];rc._getMacrosElements(n,o),o.push(rc.getByName(a?"GRAPHICS_API_WEBGL2":"GRAPHICS_API_WEBGL1")),t._hardwareRenderer.canIUse(nT.shaderTextureLod)&&o.push(rc.getByName("HAS_TEX_LOD")),t._hardwareRenderer.canIUse(nT.standardDerivatives)&&o.push(rc.getByName("HAS_DERIVATIVES"));var s=e.parseIncludes(r),l=e.parseIncludes(i),c=e.parseCustomMacros(o);s=c+s,l=c+l,a&&(s=e.convertTo300(s),l=e.convertTo300(l,!0));var u=a?"#version 300 es":"#version 100";return{vertexSource:u+"\nprecision highp float;\n"+s,fragmentSource:u+"\n"+(a?"":e._shaderExtension)+"\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"+l}},e.registerInclude=function(e,t){if(r_[e])throw'The "'+e+'" shader include already exist';r_[e]=t},e.unRegisterInclude=function(e){delete r_[e]},e.parseIncludes=function(t,n){return void 0===n&&(n=/^[ \t]*#include +<([\w\d.]+)>/gm),t.replace(n,function(t,r){var i=r_[r];return void 0===i?(nb.error('Shader slice "'+t.trim()+'" not founded.'),""):e.parseIncludes(i,n)})},e.convertTo300=function(t,n){if(t=(t=(t=(t=(t=(t=(t=t.replace(/\bvarying\b/g,n?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj")).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"),n){if(t=t.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="out vec4 glFragColor;\n"+t).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}();rf._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(""),rf._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var rp=/*#__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}();rp._nameCounter=0,rp._nameMap=Object.create(null);var rm=/*#__PURE__*/function(){function e(){this._tagsMap=Object.create(null)}var t=e.prototype;return t.setTag=function(e,t){var n="string"==typeof e?rp.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&nb.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?rp.getByName(e):e)._uniqueId]},t.getTagValue=function(e){return this._tagsMap["string"==typeof e?rp.getByName(e)._uniqueId:e._uniqueId]},t4(e,[{key:"name",get:function(){return this._name}}]),e}(),rg=/*#__PURE__*/function(){function e(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl}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._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._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._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}(),rv=function(){this.constUniforms=[],this.textureUniforms=[]},ry=/*#__PURE__*/function(){function e(t,n,r,i){this.sceneUniformBlock=new rv,this.cameraUniformBlock=new rv,this.rendererUniformBlock=new rv,this.materialUniformBlock=new rv,this.renderElementUniformBlock=new rv,this.otherUniformBlock=new rv,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,i),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=nH._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 ra.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case ra.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case ra.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case ra.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case ra.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,n){var r=this._gl,i=this._createShader(r.VERTEX_SHADER,e);if(!i)return null;var a=this._createShader(r.FRAGMENT_SHADER,t);if(!a)return null;var o=r.createProgram();return o?(r.attachShader(o,i),r.attachShader(o,a),(null==n?void 0:n.length)&&r.transformFeedbackVaryings(o,n,r.INTERLEAVED_ATTRIBS),r.linkProgram(o),r.validateProgram(o),r.deleteShader(i),r.deleteShader(a),!nb.isEnabled||r.getProgramParameter(o,r.LINK_STATUS)||r.isContextLost())?o:(nb.error("Could not link WebGL program\n\nShader error: "+r.getError()+"\n\nValidate status: "+r.getProgramParameter(o,r.VALIDATE_STATUS)+"\n\nProgram information log: "+r.getProgramInfoLog(o)),r.deleteProgram(o),null):null},t._createShader=function(t,n){var r=this._gl,i=r.createShader(t);return i?(r.shaderSource(i,n),r.compileShader(i),!nb.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):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 rg(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=nH.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 tq(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new tU(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new tZ(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 tq(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new tU(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new tZ(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=nH._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,t=this._gl,n=this._glProgram,r=null!=(e=t.getProgramParameter(n,t.ACTIVE_UNIFORMS))?e:0,i=Array(r),a=0;a<r;++a){var o=t.getActiveUniform(n,a);i[a]=o}return i},t._getAttributeInfos=function(){for(var e,t=this._gl,n=this._glProgram,r=[],i=null!=(e=t.getProgramParameter(n,t.ACTIVE_ATTRIBUTES))?e:0,a=0;a<i;++a){var o=t.getActiveAttrib(n,a);r[a]=o}return r},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")},t4(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();ry._counter=0;var rx=/*#__PURE__*/function(e){function t(n,r,i,a){var o;for(var s in(o=e.call(this)||this)._shaderPassId=0,o._renderStateDataMap={},o._shaderProgramPools=[],o._shaderPassId=t._shaderPassCounter++,"string"==typeof i?(o._name=n,o._vertexSource=r,o._fragmentSource=i,a=rd({pipelineStage:rh.Forward},a)):(o._name="Default",o._vertexSource=n,o._fragmentSource=r,a=rd({pipelineStage:rh.Forward},i)),a)o.setTag(s,a[s]);return o}t5(t,e);var n=t.prototype;return n._getShaderProgram=function(e,t){var n=e._getShaderProgramPool(this._shaderPassId,this._shaderProgramPools),r=n.get(t);return r||(r=this._getCanonicalShaderProgram(e,t),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._getCanonicalShaderProgram=function(e,t){if(void 0!=this._platformTarget)return this._getShaderLabProgram(e,t);var n=rf.compilePlatformSource(e,t,this._vertexSource,this._fragmentSource);return new ry(e,n.vertexSource,n.fragmentSource)},n._getShaderLabProgram=function(e,t){var n=e._hardwareRenderer.isWebGL2,r=[];rc._getMacrosElements(t,r),r.push(rc.getByName(n?"GRAPHICS_API_WEBGL2":"GRAPHICS_API_WEBGL1")),e._hardwareRenderer.canIUse(nT.shaderTextureLod)&&r.push(rc.getByName("HAS_TEX_LOD")),e._hardwareRenderer.canIUse(nT.standardDerivatives)&&r.push(rc.getByName("HAS_DERIVATIVES"));var i=rf.parseIncludes(this._vertexSource),a=rf.parseIncludes(this._fragmentSource);i=rM._shaderLab._parseMacros(i,r),a=rM._shaderLab._parseMacros(a,r),n&&this._platformTarget===ro.GLSLES100&&(i=rf.convertTo300(i),a=rf.convertTo300(a,!0));var o=n?"#version 300 es":"#version 100";return new ry(e," "+o+"\n "+i+"\n "," "+o+"\n "+(n?"":rf._shaderExtension)+"\n \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 \n "+a+"\n ")},t}(rm);rx._shaderPassCounter=0,rx._shaderRootPath="shaders://root/";var rA=/*#__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 t5(t,e),t4(t,[{key:"passes",get:function(){return this._passes}}]),t}(rm),rb=function(){this.enabled=!1,this.colorBlendOperation=n7.Add,this.alphaBlendOperation=n7.Add,this.sourceColorBlendFactor=n6.One,this.sourceAlphaBlendFactor=n6.One,this.destinationColorBlendFactor=n6.Zero,this.destinationAlphaBlendFactor=n6.Zero,this.colorWriteMask=re.All},rS=/*#__PURE__*/function(){function e(){this.targetBlendState=new rb,this.blendColor=new tJ(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[ri.BlendStateEnabled0];if(void 0!==u){var d=t.getFloat(u);c.enabled=void 0!==d&&!!d}var h=e[ri.BlendStateColorBlendOperation0];void 0!==h&&(c.colorBlendOperation=null!=(n=t.getFloat(h))?n:n7.Add);var _=e[ri.BlendStateAlphaBlendOperation0];void 0!==_&&(c.alphaBlendOperation=null!=(r=t.getFloat(_))?r:n7.Add);var f=e[ri.BlendStateSourceColorBlendFactor0];void 0!==f&&(c.sourceColorBlendFactor=null!=(i=t.getFloat(f))?i:n6.One);var p=e[ri.BlendStateSourceAlphaBlendFactor0];void 0!==p&&(c.sourceAlphaBlendFactor=null!=(a=t.getFloat(p))?a:n6.One);var m=e[ri.BlendStateDestinationColorBlendFactor0];void 0!==m&&(c.destinationColorBlendFactor=null!=(o=t.getFloat(m))?o:n6.Zero);var g=e[ri.BlendStateDestinationAlphaBlendFactor0];void 0!==g&&(c.destinationAlphaBlendFactor=null!=(s=t.getFloat(g))?s:n6.Zero);var v=e[ri.BlendStateColorWriteMask0];void 0!==v&&(c.colorWriteMask=null!=(l=t.getFloat(v))?l:re.All);var y=e[ri.BlendStateBlendColor];if(void 0!==y){var x=t.getColor(y);void 0!==x&&this.blendColor.copyFrom(x)}var A=e[ri.BlendStateAlphaToCoverage];if(void 0!==A){var b=t.getFloat(A);this.alphaToCoverage=void 0!==b&&!!b}},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[ri.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;tJ.equals(n.blendColor,m)||(i.blendColor(m.r,m.g,m.b,m.a),n.blendColor.copyFrom(m))}f!==a.colorWriteMask&&(i.colorMask((f&re.Red)!=0,(f&re.Green)!=0,(f&re.Blue)!=0,(f&re.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 n6.Zero:return n.ZERO;case n6.One:return n.ONE;case n6.SourceColor:return n.SRC_COLOR;case n6.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case n6.DestinationColor:return n.DST_COLOR;case n6.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case n6.SourceAlpha:return n.SRC_ALPHA;case n6.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case n6.DestinationAlpha:return n.DST_ALPHA;case n6.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case n6.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case n6.BlendColor:return n.CONSTANT_COLOR;case n6.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},e._getGLBlendOperation=function(e,t){var n=e.gl;switch(t){case n7.Add:return n.FUNC_ADD;case n7.Subtract:return n.FUNC_SUBTRACT;case n7.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case n7.Min:if(!e.canIUse(nT.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case n7.Max:if(!e.canIUse(nT.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},e}();t6([ni],rS.prototype,"targetBlendState",void 0),t6([ni],rS.prototype,"blendColor",void 0);var rC=/*#__PURE__*/function(){function e(){this.enabled=!0,this.compareFunction=rt.Less,this.writeEnabled=!0}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r=e[ri.DepthStateEnabled];if(void 0!==r){var i=t.getFloat(r);this.enabled=void 0!==i&&!!i}var a=e[ri.DepthStateWriteEnabled];if(void 0!==a){var o=t.getFloat(a);this.writeEnabled=void 0!==o&&!!o}var s=e[ri.DepthStateCompareFunction];void 0!==s&&(this.compareFunction=null!=(n=t.getFloat(s))?n:rt.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[ri.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 rt.Never:return n.NEVER;case rt.Less:return n.LESS;case rt.Equal:return n.EQUAL;case rt.LessEqual:return n.LEQUAL;case rt.Greater:return n.GREATER;case rt.NotEqual:return n.NOTEQUAL;case rt.GreaterEqual:return n.GEQUAL;case rt.Always:return n.ALWAYS}},e}(),rT=/*#__PURE__*/function(){function e(){this.cullMode=rn.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[ri.RasterStateCullMode];void 0!==a&&(this.cullMode=null!=(n=t.getFloat(a))?n:rn.Back);var o=e[ri.RasterStateDepthBias];void 0!==o&&(this.depthBias=null!=(r=t.getFloat(o))?r:0);var s=e[ri.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[ri.RasterStateCullMode];void 0!==l&&(a=l)}var c=a!==rn.Off;c!==t._cullFaceEnable&&(c?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),t._cullFaceEnable=c),c&&a!==t.cullMode&&(a==rn.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}(),rR=/*#__PURE__*/function(){function e(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=rt.Always,this.compareFunctionBack=rt.Always,this.passOperationFront=rl.Keep,this.passOperationBack=rl.Keep,this.failOperationFront=rl.Keep,this.failOperationBack=rl.Keep,this.zFailOperationFront=rl.Keep,this.zFailOperationBack=rl.Keep}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,i,a,o,s,l,c,u,d,h,_=e[ri.StencilStateEnabled];if(void 0!==_){var f=t.getFloat(_);this.enabled=void 0!==f&&!!f}var p=e[ri.StencilStateReferenceValue];void 0!==p&&(this.referenceValue=null!=(n=t.getFloat(p))?n:0);var m=e[ri.StencilStateMask];void 0!==m&&(this.mask=null!=(r=t.getFloat(m))?r:255);var g=e[ri.StencilStateWriteMask];void 0!==g&&(this.writeMask=null!=(i=t.getFloat(g))?i:255);var v=e[ri.StencilStateCompareFunctionFront];void 0!==v&&(this.compareFunctionFront=null!=(a=t.getFloat(v))?a:rt.Always);var y=e[ri.StencilStateCompareFunctionBack];void 0!==y&&(this.compareFunctionBack=null!=(o=t.getFloat(y))?o:rt.Always);var x=e[ri.StencilStatePassOperationFront];void 0!==x&&(this.passOperationFront=null!=(s=t.getFloat(x))?s:rl.Keep);var A=e[ri.StencilStatePassOperationBack];void 0!==A&&(this.passOperationBack=null!=(l=t.getFloat(A))?l:rl.Keep);var b=e[ri.StencilStateFailOperationFront];void 0!==b&&(this.failOperationFront=null!=(c=t.getFloat(b))?c:rl.Keep);var S=e[ri.StencilStateFailOperationBack];void 0!==S&&(this.failOperationBack=null!=(u=t.getFloat(S))?u:rl.Keep);var C=e[ri.StencilStateZFailOperationFront];void 0!==C&&(this.zFailOperationFront=null!=(d=t.getFloat(C))?d:rl.Keep);var T=e[ri.StencilStateZFailOperationBack];void 0!==T&&(this.zFailOperationBack=null!=(h=t.getFloat(T))?h:rl.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[ri.StencilStateEnabled];void 0!==g&&(a=g);var v=r[ri.StencilStateWriteMask];void 0!==v&&(m=v);var y=r[ri.StencilStateReferenceValue];void 0!==y&&(o=y);var x=r[ri.StencilStateCompareFunctionFront];void 0!==x&&(l=x);var A=r[ri.StencilStateCompareFunctionBack];void 0!==A&&(c=A);var b=r[ri.StencilStatePassOperationFront];void 0!==b&&(h=b);var S=r[ri.StencilStatePassOperationBack];void 0!==S&&(p=S);var C=r[ri.StencilStateFailOperationFront];void 0!==C&&(u=C);var T=r[ri.StencilStateFailOperationBack];void 0!==T&&(_=T);var R=r[ri.StencilStateZFailOperationFront];void 0!==R&&(d=R);var E=r[ri.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 rt.Never:return n.NEVER;case rt.Less:return n.LESS;case rt.Equal:return n.EQUAL;case rt.LessEqual:return n.LEQUAL;case rt.Greater:return n.GREATER;case rt.NotEqual:return n.NOTEQUAL;case rt.GreaterEqual:return n.GEQUAL;case rt.Always:return n.ALWAYS}},e._getGLStencilOperation=function(e,t){var n=e.gl;switch(t){case rl.Keep:return n.KEEP;case rl.Zero:return n.ZERO;case rl.Replace:return n.REPLACE;case rl.IncrementSaturate:return n.INCR;case rl.DecrementSaturate:return n.DECR;case rl.Invert:return n.INVERT;case rl.IncrementWrap:return n.INCR_WRAP;case rl.DecrementWrap:return n.DECR_WRAP}},e}(),rE=/*#__PURE__*/function(){function e(){this.blendState=new rS,this.depthState=new rC,this.stencilState=new rR,this.rasterState=new rT,this.renderQueueType=rr.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[ri.RenderQueueType];return void 0===r?this.renderQueueType:null!=(n=t.getFloat(r))?n:rr.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}();t6([ni],rE.prototype,"blendState",void 0),t6([ni],rE.prototype,"depthState",void 0),t6([ni],rE.prototype,"stencilState",void 0),t6([ni],rE.prototype,"rasterState",void 0);var rM=/*#__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.compileVariant=function(t,n){var r=e._compileMacros;r.clear();for(var i=0,a=n.length;i<a;i++)r.enable(rc.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(void 0==n&&(n=ro.GLSLES100),"number"==typeof n){var o=e._shaderLab;if(!o)throw"ShaderLab has not been set up yet.";var s=o._parseShaderSource(t);if(a[s.name]){console.error('Shader named "'+s.name+'" already exists.');return}var l=s.subShaders.map(function(t){var i=t.passes.map(function(i){if(i.isUsePass){var a,o,l=i.name.split("/"),c=l[0],u=l[1],d=l[2];return null==(o=e.find(c))?void 0:null==(a=o.subShaders.find(function(e){return e.name===u}))?void 0:a.passes.find(function(e){return e.name===d})}var h=e._shaderLab._parseShaderPass(i.contents,i.vertexEntry,i.fragmentEntry,n,new URL(null!=r?r:"",rx._shaderRootPath).href);if(!h)throw'Shader pass "'+s.name+"."+t.name+"."+i.name+'" parse failed, please check the shader source code.';var _=new rx(i.name,h.vertex,h.fragment,i.tags);_._platformTarget=n;var f=i.renderStates,p=f.constantMap,m=f.variableMap;if(Object.keys(p).length>0||Object.keys(m).length>0){var g=new rE;for(var v in p)e._applyConstRenderStates(g,+v,p[v]);_._renderState=g;var y={};for(var x in m)y[x]=nH.getByName(m[x]);_._renderStateDataMap=y}return _});return new rA(t.name,i,t.tags)});return i=new e(s.name,l),a[s.name]=i,i}if(a[t]){console.error('Shader named "'+t+'" already exists.');return}if("string"==typeof n)i=new e(t,[new rA("Default",[new rx(n,r)])]);else if(n.length>0)i=n[0].constructor===rx?new e(t,[new rA("Default",n)]):new e(t,n.slice());else throw"SubShader or ShaderPass count must large than 0.";return a[t]=i,i},e.find=function(t){return e._shaderMap[t]},e._clear=function(t){var n=e._shaderMap;for(var r in n)for(var i=n[r]._subShaders,a=0,o=i.length;a<o;a++)for(var s=i[a].passes,l=0,c=s.length;l<c;l++)for(var u=s[l]._shaderProgramPools,d=u.length-1;d>=0;d--){var h=u[d];h.engine===t&&(h._destroy(),u.splice(d,1))}},e._applyConstRenderStates=function(e,t,n){switch(t){case ri.BlendStateEnabled0:e.blendState.targetBlendState.enabled=n;break;case ri.BlendStateColorBlendOperation0:e.blendState.targetBlendState.colorBlendOperation=n;break;case ri.BlendStateAlphaBlendOperation0:e.blendState.targetBlendState.alphaBlendOperation=n;break;case ri.BlendStateSourceColorBlendFactor0:e.blendState.targetBlendState.sourceColorBlendFactor=n;break;case ri.BlendStateDestinationColorBlendFactor0:e.blendState.targetBlendState.destinationColorBlendFactor=n;break;case ri.BlendStateSourceAlphaBlendFactor0:e.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case ri.BlendStateDestinationAlphaBlendFactor0:e.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case ri.BlendStateColorWriteMask0:e.blendState.targetBlendState.colorWriteMask=n;break;case ri.DepthStateEnabled:e.depthState.enabled=n;break;case ri.DepthStateWriteEnabled:e.depthState.writeEnabled=n;break;case ri.DepthStateCompareFunction:e.depthState.compareFunction=n;break;case ri.StencilStateEnabled:e.stencilState.enabled=n;break;case ri.StencilStateReferenceValue:e.stencilState.referenceValue=n;break;case ri.StencilStateMask:e.stencilState.mask=n;break;case ri.StencilStateWriteMask:e.stencilState.writeMask=n;break;case ri.StencilStateCompareFunctionFront:e.stencilState.compareFunctionFront=n;break;case ri.StencilStateCompareFunctionBack:e.stencilState.compareFunctionBack=n;break;case ri.StencilStatePassOperationFront:e.stencilState.passOperationFront=n;break;case ri.StencilStatePassOperationBack:e.stencilState.passOperationBack=n;break;case ri.StencilStateFailOperationFront:e.stencilState.failOperationFront=n;break;case ri.StencilStateFailOperationBack:e.stencilState.failOperationBack=n;break;case ri.StencilStateZFailOperationFront:e.stencilState.zFailOperationFront=n;break;case ri.StencilStateZFailOperationBack:e.stencilState.zFailOperationBack=n;break;case ri.RasterStateCullMode:e.rasterState.cullMode=n;break;case ri.RasterStateDepthBias:e.rasterState.depthBias=n;break;case ri.RasterStateSlopeScaledDepthBias:e.rasterState.slopeScaledDepthBias=n;break;case ri.RenderQueueType:e.renderQueueType=n}},e.getMacroByName=function(e,t){return rc.getByName(e,t)},e.getPropertyByName=function(e){return nH.getByName(e)},t4(e,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();rM._compileMacros=new ru,rM._shaderMap=Object.create(null);var rP=/*#__PURE__*/function(){function e(e){this._propertyValueMap=Object.create(null),this._macroCollection=new ru,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,rs.Float,t)},t.getInt=function(e){return this.getPropertyValue(e)},t.setInt=function(e,t){this._setPropertyValue(e,rs.Int,t)},t.getFloatArray=function(e){return this.getPropertyValue(e)},t.setFloatArray=function(e,t){this._setPropertyValue(e,rs.FloatArray,t)},t.getIntArray=function(e){return this.getPropertyValue(e)},t.setIntArray=function(e,t){this._setPropertyValue(e,rs.IntArray,t)},t.getVector2=function(e){return this.getPropertyValue(e)},t.setVector2=function(e,t){this._setPropertyValue(e,rs.Vector2,t)},t.getVector3=function(e){return this.getPropertyValue(e)},t.setVector3=function(e,t){this._setPropertyValue(e,rs.Vector3,t)},t.getVector4=function(e){return this.getPropertyValue(e)},t.setVector4=function(e,t){this._setPropertyValue(e,rs.Vector4,t)},t.getMatrix=function(e){return this.getPropertyValue(e)},t.setMatrix=function(e,t){this._setPropertyValue(e,rs.Matrix,t)},t.getColor=function(e){return this.getPropertyValue(e)},t.setColor=function(e,t){this._setPropertyValue(e,rs.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,rs.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,rs.TextureArray,t)},t.getPropertyValue=function(e){return"string"==typeof e&&(e=nH.getByName(e)),this._propertyValueMap[e._uniqueId]},t.enableMacro=function(e,t){"string"==typeof e&&(e=rc.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=rc._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=nH._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){na.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(t7(l,nE))r[s]=l,t>0&&l._addReferCount(t);else if(t7(l,Array)||t7(l,Float32Array)||t7(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=nH.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 "+ra[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 "+rs[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&&t7(r,nE)&&r._addReferCount(e)}},e}();t6([nt],rP.prototype,"_group",void 0),t6([nt],rP.prototype,"_propertyValueMap",void 0),t6([nt],rP.prototype,"_macroCollection",void 0),t6([nt],rP.prototype,"_macroMap",void 0),t6([nt],rP.prototype,"_refCount",void 0);var rw=/*#__PURE__*/function(){function e(){this._projectionParams=new tZ,this.flipProjection=!1}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&&(tK.multiply(e._flipYMatrix,a,e._flipYProjectionMatrix),tK.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.setRenderTarget=function(e,t,n,r){var i=this.camera.engine;i._hardwareRenderer.activeRenderTarget(e,t,this.flipProjection,n,r),e?i._macroCollection.disable(oK._outputSRGBCorrectMacro):i._macroCollection.enable(oK._outputSRGBCorrectMacro)},t.garbageCollection=function(){this.camera=null},e}();rw.vpMatrixProperty=nH.getByName("camera_VPMat"),rw.pipelineStageKey=rp.getByName("pipelineStage"),rw._flipYMatrix=new tK(1,0,0,0,0,-1),rw._cameraProjectionProperty=nH.getByName("camera_ProjectionParams"),rw._viewMatrixProperty=nH.getByName("camera_ViewMat"),rw._projectionMatrixProperty=nH.getByName("camera_ProjMat"),rw._flipYProjectionMatrix=new tK,rw._flipYViewProjectionMatrix=new tK;var rF=((O={})[O.None=0]="None",O[O.WorldMatrix=1]="WorldMatrix",O[O.viewMatrix=2]="viewMatrix",O[O.ProjectionMatrix=4]="ProjectionMatrix",O[O.WorldViewMatrix=3]="WorldViewMatrix",O[O.viewProjectionMatrix=6]="viewProjectionMatrix",O[O.All=7]="All",O),rL=/*#__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){nb.warn("The material of sky is not defined.");return}if(n.destroyed){nb.warn("The material of sky is destroyed.");return}if(!r){nb.warn("The mesh of sky is not defined.");return}if(r.destroyed){nb.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(tk.degreeToRadian(l)/2);_.elements[0]=y/s,_.elements[5]=y,tK.multiply(_,h,h);var x=u.getMatrix(rw.vpMatrixProperty);t.flipProjection&&tK.multiply(rw._flipYMatrix,h,h),u.setMatrix(rw.vpMatrixProperty,h);var A=rM._compileMacros;ru.unionCollection(t.camera._globalShaderMacro,p._macroCollection,A),ru.unionCollection(A,a._macroCollection,A);var b=m.subShaders[0].passes[0],S=b._getShaderProgram(a,A);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,b._renderStateDataMap,p),f.drawPrimitive(r._primitive,r.subMesh,S),u.setMatrix(rw.vpMatrixProperty,x)},t4(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}();rL._epsilon=1e-6,rL._viewProjMatrix=new tK,rL._projectionMatrix=new tK(1,0,0,0,0,1,0,0,0,0,rL._epsilon-1,-1,0,0,0,0);var rD=/*#__PURE__*/function(){function e(e){this._engine=e,this.mode=n5.SolidColor,this.sky=new rL,this._textureFillMode=n9.AspectFitHeight,this._solidColor=new tJ(.05087608817155679,.05087608817155679,.05087608817155679,1),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.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 n9.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 n9.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 n9.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 t5(n,e),n.prototype.restoreContent=function(){t.setPositions(t.getPositions()),t.setUVs(t.getUVs()),t.setIndices(t.getIndices()),t.uploadData(!1)},n}(nl))),this._mesh._addReferCount(1)},t._initMaterial=function(e){var t=this._material=new r3(e,rM.find("background-texture"));t.renderState.depthState.compareFunction=rt.LessEqual,t._addReferCount(1)},t._createPlane=function(e){for(var t=new aG(e),n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],i=[,,,,],a=0;a<4;++a)r[a]=new tU,i[a]=new tq(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},t4(e,[{key:"solidColor",get:function(){return this._solidColor},set:function(e){e!==this._solidColor&&this._solidColor.copyFrom(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}();rD._premultiplySolidColor=new tJ;var rB=/*#__PURE__*/function(){function e(){}return e.remapEntity=function(t,n,r){var i=e._tempRemapPath;return e._getEntityHierarchyPath(t,r,i)?e._getEntityByHierarchyPath(n,i):r},e.remapComponent=function(t,n,r){var i=e._tempRemapPath,a=r.entity;return e._getEntityHierarchyPath(t,a,i)?e._getEntityByHierarchyPath(n,i)._components[a._components.indexOf(r)]:r},e._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},e._getEntityByHierarchyPath=function(e,t){for(var n=e,r=t.length-1;r>=0;r--)n=n.children[t[r]];return n},e}();rB._tempRemapPath=[];var rI=((V={})[V.None=0]="None",V[V.Scene=1]="Scene",V[V.Hierarchy=2]="Hierarchy",V[V.All=3]="All",V),rN=/*#__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}t5(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&rI.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&rI.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._remap=function(e,t){return rB.remapComponent(e,t,this)},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())},t4(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}(no);t6([nt],rN.prototype,"_awoken",void 0),t6([nt],rN.prototype,"_phasedActiveInScene",void 0),t6([nt],rN.prototype,"_phasedActive",void 0),t6([nn],rN.prototype,"_enabled",void 0);var rO=/*#__PURE__*/function(){function e(){}return e._addCheck=function(t,n){for(;n!==rN;){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!==rN;){for(var a=0,o=0;o<i;o++)if(t7(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 rV(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){rO._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return rO._addInvDependency(t,e)})}}rO._invDependenciesMap=new Map,rO._dependenciesMap=new Map;var rk=((k={})[k.CheckOnly=0]="CheckOnly",k[k.AutoAdd=1]="AutoAdd",k),rU=((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),rz=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.flag=!0,t}return t5(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++)nX.removeFromArray(e[t]._updateFlags,this)},e}()),rG=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._position=new tU,n._rotation=new tU,n._rotationQuaternion=new tY,n._scale=new tU(1,1,1),n._localUniformScaling=!0,n._worldPosition=new tU,n._worldRotation=new tU,n._worldRotationQuaternion=new tY,n._worldUniformScaling=!0,n._lossyWorldScale=new tU(1,1,1),n._localMatrix=new tK,n._worldMatrix=new tK,n._worldForward=null,n._worldRight=null,n._worldUp=null,n._isParentDirty=!0,n._parentTransformCache=null,n._dirtyFlag=510,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}t5(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*tk.degreeToRadFactor;tY.rotationAxisAngle(e,i,t._tempQuat0),this._rotateByQuat(t._tempQuat0,r)},n.lookAt=function(e,n){var r=t._tempVec30;tU.subtract(this.worldPosition,e,r);var i=r.length();if(!(i<=tk.zeroTolerance)){r.scale(1/i);var a=t._tempVec31;if(n?tU.cross(n,r,a):a.set(r.z,0,-r.x),!((i=a.length())<=tk.zeroTolerance)){a.scale(1/i);var o=t._tempVec32;tU.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._cloneTo=function(e){var t=e._position,n=e._rotation,r=e._scale;t._onValueChanged=n._onValueChanged=r._onValueChanged=null,t.copyFrom(this.position),n.copyFrom(this.rotation),r.copyFrom(this.scale),t._onValueChanged=e._onPositionChanged,n._onValueChanged=e._onRotationChanged,r._onValueChanged=e._onScaleChanged,e._setDirtyFlagTrue(66)},n._onLocalMatrixChanging=function(){this._setDirtyFlagFalse(64)},n._onWorldMatrixChanging=function(){this._setDirtyFlagFalse(128)},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){var t=e&~this._dirtyFlag;this._dirtyFlag|=e,this._entity._updateFlagManager.dispatch(t)},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._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},n._onWorldPositionChanged=function(){var e=this._worldPosition,n=this._getParentTransform();n?(tK.invert(n.worldMatrix,t._tempMat41),tU.transformCoordinate(e,t._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},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._getScaleMatrix=function(){var e=t._tempQuat0,n=t._tempMat30,r=t._tempMat31,i=t._tempMat32;return r.copyFromMatrix(this.worldMatrix),tY.invert(this.worldRotationQuaternion,e),tj.rotationQuaternion(e,n),tj.multiply(n,r,i),i},n._rotateByQuat=function(e,t){t?tY.multiply(this.rotationQuaternion,e,this._rotationQuaternion):tY.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},n._translate=function(e,n){if(void 0===n&&(n=!0),n){var r=t._tempVec30;tU.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=tk.degreeToRadFactor,o=t._tempQuat0;tY.rotationEuler(e*a,n*a,r*a,o),this._rotateByQuat(o,i)},n._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},n._onWorldRotationChanged=function(){var e=this._worldRotation;tY.rotationEuler(tk.degreeToRadian(e.x),tk.degreeToRadian(e.y),tk.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;tY.invert(n.worldRotationQuaternion,r),tY.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(rz)},t4(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(tk.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(tk.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,tY.rotationEuler(tk.degreeToRadian(this._rotation.x),tk.degreeToRadian(this._rotation.y),tk.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):tY.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?tY.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):tY.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)&&(tK.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,e.decompose(t,n,r),this._onLocalMatrixChanging(),this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(2),t._onValueChanged=this._onPositionChanged,n._onValueChanged=this._onRotationQuaternionChanged,r._onValueChanged=this._onScaleChanged;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?tK.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?(tK.invert(n.worldMatrix,t._tempMat42),tK.multiply(t._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._onWorldMatrixChanging()}},{key:"worldForward",get:function(){var e=this._worldForward||(this._worldForward=new tU),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 tU),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 tU),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),t}(rN);rG._tempQuat0=new tY,rG._tempVec30=new tU,rG._tempVec31=new tU,rG._tempVec32=new tU,rG._tempMat30=new tj,rG._tempMat31=new tj,rG._tempMat32=new tj,rG._tempMat41=new tK,rG._tempMat42=new tK,t6([nt],rG.prototype,"_position",void 0),t6([nt],rG.prototype,"_rotation",void 0),t6([nt],rG.prototype,"_rotationQuaternion",void 0),t6([nt],rG.prototype,"_scale",void 0),t6([nn],rG.prototype,"_localUniformScaling",void 0),t6([nt],rG.prototype,"_worldPosition",void 0),t6([nt],rG.prototype,"_worldRotation",void 0),t6([nt],rG.prototype,"_worldRotationQuaternion",void 0),t6([nt],rG.prototype,"_worldUniformScaling",void 0),t6([nt],rG.prototype,"_lossyWorldScale",void 0),t6([nt],rG.prototype,"_localMatrix",void 0),t6([nt],rG.prototype,"_worldMatrix",void 0),t6([nt],rG.prototype,"_worldForward",void 0),t6([nt],rG.prototype,"_worldRight",void 0),t6([nt],rG.prototype,"_worldUp",void 0),t6([nt],rG.prototype,"_isParentDirty",void 0),t6([nt],rG.prototype,"_dirtyFlag",void 0),t6([nt],rG.prototype,"_onPositionChanged",null),t6([nt],rG.prototype,"_onWorldPositionChanged",null),t6([nt],rG.prototype,"_onRotationChanged",null),t6([nt],rG.prototype,"_onWorldRotationChanged",null),t6([nt],rG.prototype,"_onRotationQuaternionChanged",null),t6([nt],rG.prototype,"_onWorldRotationQuaternionChanged",null),t6([nt],rG.prototype,"_onScaleChanged",null);var rH=((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[z.LqLmWmWpWeWqWsWus=510]="LqLmWmWpWeWqWsWus",z),rW=function(){this.isOrthographic=!1,this.nearClipPlane=.1,this.farClipPlane=100,this.position=new tU,this.viewMatrix=new tK,this.projectionMatrix=new tK,this.viewProjectionMatrix=new tK,this.forward=new tU};t6([nt],rW.prototype,"position",void 0),t6([nt],rW.prototype,"viewMatrix",void 0),t6([nt],rW.prototype,"projectionMatrix",void 0),t6([nt],rW.prototype,"viewProjectionMatrix",void 0),t6([nt],rW.prototype,"forward",void 0);var rX=((G={})[G.None=0]="None",G[G.FXAA=1]="FXAA",G),rj=((H={})[H.None=0]="None",H[H.Color=1]="Color",H[H.Depth=2]="Depth",H[H.Stencil=4]="Stencil",H[H.ColorDepth=3]="ColorDepth",H[H.ColorStencil=5]="ColorStencil",H[H.DepthStencil=6]="DepthStencil",H[H.All=7]="All",H),rY=((W={})[W.ProjectionType=1]="ProjectionType",W[W.AspectRatio=2]="AspectRatio",W[W.FieldOfView=4]="FieldOfView",W[W.OrthographicSize=8]="OrthographicSize",W[W.EnableInScene=16]="EnableInScene",W[W.DisableInScene=32]="DisableInScene",W),rK=((X={})[X.Normal=0]="Normal",X[X.XRCenterCamera=1]="XRCenterCamera",X[X.XRLeftCamera=2]="XRLeftCamera",X[X.XRRightCamera=4]="XRRightCamera",X),rQ=((j={})[j.None=0]="None",j[j.PrePass=1]="PrePass",j),rq=((Y={})[Y.None=1]="None",Y[Y.TwoX=2]="TwoX",Y[Y.FourX=4]="FourX",Y),rZ=((K={})[K.None=1]="None",K[K.TwoX=2]="TwoX",K[K.FourX=4]="FourX",K[K.EightX=8]="EightX",K),rJ=((Q={})[Q.KeepOriginalShader=0]="KeepOriginalShader",Q[Q.DoNotRender=1]="DoNotRender",Q),r$=function(){};r$.tempVec4=new tZ,r$.tempVec3=new tU,r$.tempVec2=new tq;var r0=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableFrustumCulling=!0,n.clearFlags=rj.All,n.cullingMask=rU.Everything,n.postProcessMask=rU.Everything,n.depthTextureMode=rQ.None,n.opaqueTextureDownsampling=rq.TwoX,n.antiAliasing=rX.None,n.isAlphaOutputRequired=!1,n._cameraType=rK.Normal,n._globalShaderMacro=new ru,n._frustum=new tX,n._virtualCamera=new rW,n._replacementShader=null,n._replacementSubShaderTag=null,n._replacementFailureStrategy=null,n._cameraIndex=-1,n._priority=0,n._isCustomViewMatrix=!1,n._isCustomProjectionMatrix=!1,n._fieldOfView=45,n._orthographicSize=10,n._isProjectionDirty=!0,n._isInvProjMatDirty=!0,n._customAspectRatio=void 0,n._opaqueTextureEnabled=!1,n._enableHDR=!1,n._enablePostProcess=!1,n._renderTarget=null,n._shaderData=new rP(ra.Camera),n._depthBufferParams=new tZ,n._viewport=new tZ(0,0,1,1),n._pixelViewport=new t$(0,0,0,0),n._inverseProjectionMatrix=new tK,n._invViewProjMat=new tK,n.msaaSamples=rZ.FourX,n._isViewMatrixDirty=t.registerWorldChangeFlag(),n._isInvViewProjDirty=t.registerWorldChangeFlag(),n._frustumChangeFlag=t.registerWorldChangeFlag(),n._renderPipeline=new as(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}t5(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(),this._dispatchModify(rY.AspectRatio)},n.worldToViewportPoint=function(e,t){var n=r$.tempVec3,r=r$.tempVec4;tU.transformCoordinate(e,this.viewMatrix,n),tU.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-tk.zeroTolerance,n,t.direction);return tU.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=r$.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;tK.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(),ru.unionCollection(this.scene.shaderData._macroCollection,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!r._hardwareRenderer.isWebGL2&&(t=0,nb.error("mipLevel only take effect in WebGL2.0")),this._cameraType===rK.Normal||this._renderTarget||(n=r.xrManager._getCameraIgnoreClearFlags(this._cameraType)),this._renderPipeline.render(i,e,t,n),r._renderCount++,i.camera=null},n.setReplacementShader=function(e,t,n){void 0===n&&(n=rJ.KeepOriginalShader),this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?rp.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),this._dispatchModify(rY.EnableInScene)},n._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this),this._dispatchModify(rY.DisableInScene)},n._isIndependentCanvasEnabled=function(){if(this.enablePostProcess&&this.scene.postProcessManager._isValid()||this._needFinalPass())return!0;var e=this._renderTarget;return(!!this.enableHDR||!!this.opaqueTextureEnabled)&&(!e||this._getInternalColorTextureFormat()!==e.getColorTexture(0).format)},n._getInternalColorTextureFormat=function(){return this._enableHDR?this.engine._hardwareRenderer.isWebGL2&&!this.isAlphaOutputRequired?n_.R11G11B10_UFloat:n_.R16G16B16A16:n_.R8G8B8A8},n._needFinalPass=function(){return this.antiAliasing===rX.FXAA||!this._renderTarget},n._getTargetColorTextureFormat=function(){var e=this._renderTarget;return e?e.getColorTexture(0).format:n_.R8G8B8A8},n._isTargetFormatHDR=function(){var e=this._getTargetColorTextureFormat();return e===n_.R16G16B16A16||e===n_.R32G32B32A32||e===n_.R11G11B10_UFloat},n._registerModifyListener=function(e){(this._updateFlagManager||(this._updateFlagManager=new n4)).addListener(e)},n._unRegisterModifyListener=function(e){var t;null==(t=this._updateFlagManager)||t.removeListener(e)},n._cloneTo=function(e){var t;null==(t=this._renderTarget)||t._addReferCount(1)},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._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),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}this._adjustPixelViewport(e,t)},n._adjustPixelViewport=function(e,t){var n=this._viewport;this._pixelViewport.set(n.x*e,n.y*t,n.z*e,n.w*t),this._customAspectRatio||this._dispatchModify(rY.AspectRatio)},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=r$.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),tU.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,a=i/this.nearClipPlane,o=1-a;r.set(o,a,o/i,a/i),e.setVector4(t._cameraDepthBufferParamsProperty,r)},n._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,tK.multiply(this._entity.transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},n._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,tK.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},n._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange()},n._dispatchModify=function(e){var t;null==(t=this._updateFlagManager)||t.dispatch(e)},t4(t,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled=e}},{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._fieldOfView=e,this._projectionMatrixChange(),this._dispatchModify(rY.FieldOfView))}},{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(),this._dispatchModify(rY.AspectRatio)}},{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){var t=this._virtualCamera;t.isOrthographic!==e&&(t.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC"),this._dispatchModify(rY.ProjectionType))}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize!==e&&(this._orthographicSize=e,this._projectionMatrixChange(),this._dispatchModify(rY.OrthographicSize))}},{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 tK.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;tK.ortho(-r,r,-i,i,this.nearClipPlane,this.farClipPlane,t)}else tK.perspective(tk.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(nT.textureHalfFloat);if(e&&!n){nb.warn("Can't enable HDR in this device.");return}this._enableHDR=e}}},{key:"enablePostProcess",get:function(){return this._enablePostProcess},set:function(e){this._enablePostProcess!==e&&(this._enablePostProcess=e)}},{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())}},{key:"msaaSamples",get:function(){return this._msaaSamples},set:function(e){if(this._msaaSamples!==e){var t=this._engine._hardwareRenderer.capability.maxAntiAliasing;e>t?(nb.warn("MSAA samples exceeds the limit and is automatically downgraded to:"+t),this._msaaSamples=t):this._msaaSamples=e}}}]),t}(rN);r0._cameraDepthTextureProperty=nH.getByName("camera_DepthTexture"),r0._cameraOpaqueTextureProperty=nH.getByName("camera_OpaqueTexture"),r0._cameraAOTextureProperty=nH.getByName("camera_AOTexture"),r0._inverseViewMatrixProperty=nH.getByName("camera_ViewInvMat"),r0._cameraPositionProperty=nH.getByName("camera_Position"),r0._cameraForwardProperty=nH.getByName("camera_Forward"),r0._cameraUpProperty=nH.getByName("camera_Up"),r0._cameraDepthBufferParamsProperty=nH.getByName("camera_DepthBufferParams"),t6([nt],r0.prototype,"_cameraType",void 0),t6([nt],r0.prototype,"_globalShaderMacro",void 0),t6([ni],r0.prototype,"_frustum",void 0),t6([nt],r0.prototype,"_renderPipeline",void 0),t6([ni],r0.prototype,"_virtualCamera",void 0),t6([nt],r0.prototype,"_cameraIndex",void 0),t6([nt],r0.prototype,"_updateFlagManager",void 0),t6([nt],r0.prototype,"_frustumChangeFlag",void 0),t6([nt],r0.prototype,"_isViewMatrixDirty",void 0),t6([nt],r0.prototype,"_isInvViewProjDirty",void 0),t6([ni],r0.prototype,"_shaderData",void 0),t6([nt],r0.prototype,"_depthBufferParams",void 0),t6([ni],r0.prototype,"_viewport",void 0),t6([ni],r0.prototype,"_pixelViewport",void 0),t6([ni],r0.prototype,"_inverseProjectionMatrix",void 0),t6([ni],r0.prototype,"_invViewProjMat",void 0),t6([nt],r0.prototype,"_onPixelViewportChanged",null),r0=t6([rV(rG,rk.CheckOnly)],r0);var r1=((q={})[q.Normal=0]="Normal",q[q.Additive=1]="Additive",q),r2=((Z={})[Z.Front=0]="Front",Z[Z.Back=1]="Back",Z[Z.Double=2]="Double",Z),r3=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._renderStates=[],r._shaderData=new rP(ra.Material),r.shader=n,r.name=n.name,r}t5(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine,this.shader);return this._cloneToAndModifyName(e),e},n.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),na.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._cloneToAndModifyName=function(e){this.cloneTo(e),e.name=this.name+"(Clone)"},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},t4(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 rE);else r.length=a}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t}(ns),r4=/*#__PURE__*/function(e){function t(n,r){(i=e.call(this,n,r)||this)._renderFace=r2.Front,i._isTransparent=!1,i._blendMode=r1.Normal;var i,a=i.shaderData;return a.setFloat(t._alphaCutoffProp,0),a.setFloat(t._shadowCasterRenderQueueProp,rr.Opaque),a.setFloat(t._depthOnlyRenderQueueProp,rr.Opaque),i}t5(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=rr.Transparent,a.enableMacro(t._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=a.getFloat(t._alphaCutoffProp)?rr.AlphaTest:rr.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 r1.Normal:r.sourceColorBlendFactor=n6.SourceAlpha,r.destinationColorBlendFactor=n6.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=n6.One,r.destinationAlphaBlendFactor=n6.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=n7.Add;break;case r1.Additive:r.sourceColorBlendFactor=n6.SourceAlpha,r.destinationColorBlendFactor=n6.One,r.sourceAlphaBlendFactor=n6.Zero,r.destinationAlphaBlendFactor=n6.One,r.colorBlendOperation=r.alphaBlendOperation=n7.Add}},n.setRenderFace=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";switch(t){case r2.Front:n[e].rasterState.cullMode=rn.Back;break;case r2.Back:n[e].rasterState.cullMode=rn.Front;break;case r2.Double:n[e].rasterState.cullMode=rn.Off}},n.clone=function(){var e=new t(this._engine,this.shader);return this._cloneToAndModifyName(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;if(e)n.setFloat(t._shadowCasterRenderQueueProp,rr.AlphaTest),n.setFloat(t._depthOnlyRenderQueueProp,rr.Transparent);else{var r=n.getFloat(t._alphaCutoffProp)?rr.AlphaTest:rr.Opaque;n.setFloat(t._shadowCasterRenderQueueProp,r),n.setFloat(t._depthOnlyRenderQueueProp,r)}this._isTransparent=e}},n._setAlphaCutoff=function(e){var n=this.shaderData,r=this._isTransparent;if(n.getFloat(t._alphaCutoffProp)!==e){if(e){n.enableMacro(t._alphaCutoffMacro);var i=r?rr.Transparent:rr.AlphaTest;this.renderStates[0].renderQueueType=i,n.setFloat(t._shadowCasterRenderQueueProp,rr.AlphaTest),n.setFloat(t._depthOnlyRenderQueueProp,i)}else{n.disableMacro(t._alphaCutoffMacro);var a=r?rr.Transparent:rr.Opaque;this.renderStates[0].renderQueueType=a;var o=r?rr.AlphaTest:rr.Opaque;n.setFloat(t._shadowCasterRenderQueueProp,o),n.setFloat(t._depthOnlyRenderQueueProp,a)}n.setFloat(t._alphaCutoffProp,e)}},t4(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 rE),this.setBlendMode(l,r1.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}(r3);r4._shadowCasterRenderQueueProp=nH.getByName("material_ShadowCasterRenderQueue"),r4._depthOnlyRenderQueueProp=nH.getByName("material_DepthOnlyRenderQueue"),r4._baseTextureMacro=rc.getByName("MATERIAL_HAS_BASETEXTURE"),r4._normalTextureMacro=rc.getByName("MATERIAL_HAS_NORMALTEXTURE"),r4._emissiveTextureMacro=rc.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),r4._transparentMacro=rc.getByName("MATERIAL_IS_TRANSPARENT"),r4._baseColorProp=nH.getByName("material_BaseColor"),r4._baseTextureProp=nH.getByName("material_BaseTexture"),r4._tilingOffsetProp=nH.getByName("material_TilingOffset"),r4._normalTextureProp=nH.getByName("material_NormalTexture"),r4._normalIntensityProp=nH.getByName("material_NormalIntensity"),r4._emissiveColorProp=nH.getByName("material_EmissiveColor"),r4._emissiveTextureProp=nH.getByName("material_EmissiveTexture"),r4._alphaCutoffProp=nH.getByName("material_AlphaCutoff"),r4._alphaCutoffMacro=rc.getByName("MATERIAL_IS_ALPHA_CUTOFF");var r8=/*#__PURE__*/function(e){function t(n){var r,i=(r=e.call(this,n,rM.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tJ(1,1,1,1)),i.setColor(t._specularColorProp,new tJ(1,1,1,1)),i.setColor(t._emissiveColorProp,new tJ(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tZ(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return t5(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t4(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}(r4);r8._specularColorProp=nH.getByName("material_SpecularColor"),r8._shininessProp=nH.getByName("material_Shininess"),r8._specularTextureProp=nH.getByName("material_SpecularTexture");var r5=((J={})[J.UV0=0]="UV0",J[J.UV1=1]="UV1",J[J.UV2=2]="UV2",J[J.UV3=3]="UV3",J[J.UV4=4]="UV4",J[J.UV5=5]="UV5",J[J.UV6=6]="UV6",J[J.UV7=7]="UV7",J),r9=(($={})[$.Sphere=0]="Sphere",$[$.Planar=1]="Planar",$),r6=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n,rM.find("pbr"))||this)._anisotropyRotation=0,r._iridescenceRange=new tq(100,400),r._sheenEnabled=!1;var r,i=r.shaderData;i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tJ(1,1,1,1)),i.setColor(t._emissiveColorProp,new tJ(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tZ(1,1,0,0)),i.setFloat(t._normalIntensityProp,1),i.setFloat(t._occlusionTextureIntensityProp,1),i.setFloat(t._occlusionTextureCoordProp,r5.UV0),i.setFloat(t._clearCoatProp,0),i.setFloat(t._clearCoatRoughnessProp,0),i.setFloat(t._metallicProp,1),i.setFloat(t._roughnessProp,1),i.setFloat(t._iorProp,1.5),i.setVector3(t._anisotropyInfoProp,new tU(1,0,0)),i.setVector4(t._iridescenceInfoProp,new tZ(0,1.3,100,400));var a=new tJ(0,0,0);return i.setColor(t._sheenColorProp,a),r.refractionMode=r9.Planar,i.setFloat(t._transmissionProp,0),i.setFloat(t._thicknessProp,0),i.setFloat(t._attenuationDistanceProp,1/0),i.setColor(t._attenuationColorProp,new tJ(1,1,1)),i.setFloat(t._specularIntensityProp,1),i.setColor(t._specularColorProp,new tJ(1,1,1)),r._iridescenceRange._onValueChanged=r._onIridescenceRangeChanged.bind(r),a._onValueChanged=r._onSheenColorChanged.bind(r),r}t5(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(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"))},t4(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>r5.UV1&&nb.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")}},{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.min(Math.max(e,0),5))}},{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=tk.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=rr.Transparent)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(r4._alphaCutoffProp)},set:function(e){this._setAlphaCutoff(e),this.transmission>0&&(this.renderState.renderQueueType=rr.Transparent)}},{key:"transmission",get:function(){return this.shaderData.getFloat(t._transmissionProp)},set:function(e){e=tk.clamp(e,0,1),!!this.shaderData.getFloat(t._transmissionProp)!=!!e&&(e>0?(this.shaderData.enableMacro(t._transmissionMacro),this.renderState.renderQueueType=rr.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)}},{key:"specularIntensity",get:function(){return this.shaderData.getFloat(t._specularIntensityProp)},set:function(e){this.shaderData.setFloat(t._specularIntensityProp,Math.min(Math.max(e,0),2))}},{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:"specularIntensityTexture",get:function(){return this.shaderData.getTexture(t._specularIntensityTextureProp)},set:function(e){this.shaderData.setTexture(t._specularIntensityTextureProp,e),e?this.shaderData.enableMacro(t._specularTextureMacro):this.shaderData.disableMacro(t._specularTextureMacro)}},{key:"specularColorTexture",get:function(){return this.shaderData.getTexture(t._specularColorTextureProp)},set:function(e){this.shaderData.setTexture(t._specularColorTextureProp,e),e?this.shaderData.enableMacro(t._specularColorTextureMacro):this.shaderData.disableMacro(t._specularColorTextureMacro)}}]),t}(r4);r6._occlusionTextureIntensityProp=nH.getByName("material_OcclusionIntensity"),r6._occlusionTextureCoordProp=nH.getByName("material_OcclusionTextureCoord"),r6._occlusionTextureProp=nH.getByName("material_OcclusionTexture"),r6._clearCoatProp=nH.getByName("material_ClearCoat"),r6._clearCoatTextureProp=nH.getByName("material_ClearCoatTexture"),r6._clearCoatRoughnessProp=nH.getByName("material_ClearCoatRoughness"),r6._clearCoatRoughnessTextureProp=nH.getByName("material_ClearCoatRoughnessTexture"),r6._clearCoatNormalTextureProp=nH.getByName("material_ClearCoatNormalTexture"),r6._metallicProp=nH.getByName("material_Metal"),r6._roughnessProp=nH.getByName("material_Roughness"),r6._roughnessMetallicTextureProp=nH.getByName("material_RoughnessMetallicTexture"),r6._iorProp=nH.getByName("material_IOR"),r6._anisotropyInfoProp=nH.getByName("material_AnisotropyInfo"),r6._anisotropyTextureProp=nH.getByName("material_AnisotropyTexture"),r6._iridescenceInfoProp=nH.getByName("material_IridescenceInfo"),r6._iridescenceThicknessTextureProp=nH.getByName("material_IridescenceThicknessTexture"),r6._iridescenceTextureProp=nH.getByName("material_IridescenceTexture"),r6._sheenColorProp=nH.getByName("material_SheenColor"),r6._sheenRoughnessProp=nH.getByName("material_SheenRoughness"),r6._sheenTextureProp=nH.getByName("material_SheenTexture"),r6._sheenRoughnessTextureProp=nH.getByName("material_SheenRoughnessTexture"),r6._transmissionMacro=rc.getByName("MATERIAL_ENABLE_TRANSMISSION"),r6._thicknessMacro=rc.getByName("MATERIAL_HAS_THICKNESS"),r6._thicknessTextureMacro=rc.getByName("MATERIAL_HAS_THICKNESS_TEXTURE"),r6._transmissionTextureMacro=rc.getByName("MATERIAL_HAS_TRANSMISSION_TEXTURE"),r6._transmissionProp=nH.getByName("material_Transmission"),r6._transmissionTextureProp=nH.getByName("material_TransmissionTexture"),r6._attenuationColorProp=nH.getByName("material_AttenuationColor"),r6._attenuationDistanceProp=nH.getByName("material_AttenuationDistance"),r6._thicknessProp=nH.getByName("material_Thickness"),r6._thicknessTextureProp=nH.getByName("material_ThicknessTexture"),r6._specularTextureMacro=rc.getByName("MATERIAL_HAS_SPECULAR_TEXTURE"),r6._specularColorTextureMacro=rc.getByName("MATERIAL_HAS_SPECULAR_COLOR_TEXTURE"),r6._specularIntensityProp=nH.getByName("material_SpecularIntensity"),r6._specularColorProp=nH.getByName("material_SpecularColor"),r6._specularIntensityTextureProp=nH.getByName("material_SpecularIntensityTexture"),r6._specularColorTextureProp=nH.getByName("material_SpecularColorTexture");var r7=/*#__PURE__*/function(e){function t(n){var r,i=(r=e.call(this,n,rM.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tJ(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new tZ(1,1,0,0)),r}return t5(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t4(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}(r4),ie=/*#__PURE__*/function(){function e(){}return e.recreateTextureIfNeeded=function(e,t,n,r,i,a,o,s,l){if(t&&t.width===n&&t.height===r&&t.format===i&&t.isSRGBColorSpace===o&&t.mipmapCount>1===a)return t.wrapModeU=t.wrapModeV=s,t.filterMode=l,t;var c=e._renderTargetPool;return t&&c.freeTexture(t),c.allocateTexture(n,r,i,a,o,s,l)},e.recreateRenderTargetIfNeeded=function(e,t,n,r,i,a,o,s,l,c,u,d){if(t){var h=t.getColorTexture(0),_=t.depthTexture,f=!0;if(null!=i?h&&h.width===n&&h.height===r&&h.format===i&&h.isSRGBColorSpace===l&&h.mipmapCount>1===s||(f=!1):h&&(f=!1),f&&t.antiAliasing!==c&&(f=!1),f&&(o?a?_&&_.width===n&&_.height===r&&_.format===a||(f=!1):_&&(f=!1):t._depthFormat!==a&&(f=!1)),f)return t;e._renderTargetPool.freeRenderTarget(t)}return e._renderTargetPool.allocateRenderTarget(n,r,i,a,o,s,l,c,u,d)},e}();ie.defaultViewport=new tZ(0,0,1,1);var it=/*#__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=ie.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,f=_.camera;_.flipProjection=!!r,_.setRenderTarget(r,a,0);var p=e._rendererShaderData;p.setTexture(e._blitTextureProperty,n),p.setFloat(e._blitMipLevelProperty,i),e._texelSize.set(1/n.width,1/n.height,n.width,n.height),p.setVector4(e._blitTexelSizeProperty,e._texelSize),p.setVector4(e._sourceScaleOffsetProperty,null!=l?l:e._defaultScaleOffset);var m=d.shader.subShaders[0].passes[s],g=rM._compileMacros;ru.unionCollection(f._globalShaderMacro,d.shaderData._macroCollection,g),ru.unionCollection(g,t._macroCollection,g);var v=m._getShaderProgram(t,g);v.bind(),v.groupingOtherUniformBlock(),v.uploadAll(v.sceneUniformBlock,f.scene.shaderData),v.uploadAll(v.cameraUniformBlock,f.shaderData),v.uploadAll(v.rendererUniformBlock,p),v.uploadAll(v.materialUniformBlock,d.shaderData),v.uploadUnGroupTextures(),(m._renderState||d.renderState)._applyStates(t,!1,m._renderStateDataMap,d.shaderData),h.drawPrimitive(u._primitive,u.subMesh,v),p.setTexture(e._blitTextureProperty,null)},e}();it._blitTextureProperty=nH.getByName("renderer_BlitTexture"),it._blitMipLevelProperty=nH.getByName("renderer_BlitMipLevel"),it._blitTexelSizeProperty=nH.getByName("renderer_texelSize"),it._sourceScaleOffsetProperty=nH.getByName("renderer_SourceScaleOffset"),it._rendererShaderData=new rP(ra.Renderer),it._texelSize=new tZ,it._defaultScaleOffset=new tZ(1,1,0,0);var ir=function(e){this.engine=e},ii="attribute 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}",ia=((ee={})[ee.Low=0]="Low",ee[ee.Medium=1]="Medium",ee[ee.High=2]="High",ee),io=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._invProjScaleXY=new tq,r._offsetX=new tZ,r._offsetY=new tZ;var r,i=new r3(n,rM.find(t.SHADER_NAME));return i._addReferCount(1),r._material=i,r.isSupported=r.engine._hardwareRenderer.capability.isFragmentHighPrecision,r}t5(t,e);var n=t.prototype;return n.onConfig=function(e,t){var n=this.engine,r=e.pixelViewport,i=r.width,a=r.height;this._depthRenderTarget=t;var o=n_.R8G8B8;this._saoRenderTarget=ie.recreateRenderTargetIfNeeded(n,this._saoRenderTarget,i,a,o,null,!1,!1,!1,1,np.Clamp,nh.Bilinear),this._blurRenderTarget=ie.recreateRenderTargetIfNeeded(n,this._blurRenderTarget,i,a,o,null,!1,!1,!1,1,np.Clamp,nh.Bilinear)},n.onRender=function(e){var n=this.engine,r=e.camera;r.viewport;var i=r.scene,a=r.pixelViewport,o=i.ambientOcclusion,s=this._material.shaderData,l=e.projectionMatrix,c=l.elements[0],u=e.flipProjection?-l.elements[5]:l.elements[5],d=this._invProjScaleXY.set(1/c*2,1/u*2);s.setVector2(t._invProjScaleXYProp,d);var h=o.quality,_=o.radius;this._updateBlurKernel(s,h),s.enableMacro("SSAO_QUALITY",h.toString());var f=.1*_,p=2*Math.PI*f*o.intensity/this._aoSpiralSampleCount;s.setFloat(t._invRadiusSquaredProp,1/(_*_)),s.setFloat(t._intensityProp,p),s.setFloat(t._powerProp,2*o.power),s.setFloat(t._biasProp,o.bias),s.setFloat(t._peak2Prop,f*f),s.setFloat(t._minHorizonAngleSineSquaredProp,Math.pow(Math.sin(o.minHorizonAngle),2));var m=Math.min(.5*c*a.width,.5*u*a.height),g=-r.farClipPlane/o.bilateralThreshold;s.setFloat(t._projectionScaleRadiusProp,_*m),s.setFloat(t._farPlaneOverEdgeDistanceProp,g);var v=this._saoRenderTarget,y=this._material,x=this._depthRenderTarget.depthTexture;it.blitTexture(n,x,v,0,void 0,y,0);var A=v.getColorTexture(),b=this._offsetX.set(1,1,this._blurStepPixels/A.width,0);it.blitTexture(n,A,this._blurRenderTarget,0,void 0,y,1,b);var S=this._blurRenderTarget.getColorTexture(),C=this._offsetY.set(1,1,0,this._blurStepPixels/A.height);it.blitTexture(n,S,v,0,void 0,y,1,C),r.shaderData.setTexture(r0._cameraAOTextureProperty,A)},n.release=function(){var e=this.engine._renderTargetPool;this._saoRenderTarget&&(e.freeRenderTarget(this._saoRenderTarget),this._saoRenderTarget=null),this._blurRenderTarget&&(e.freeRenderTarget(this._blurRenderTarget),this._blurRenderTarget=null),this._depthRenderTarget=null},n._updateBlurKernel=function(e,n){if(n!==this._quality){switch(n){case ia.Low:r=7,a=8/(i=4),o=24/i-1;break;case ia.Medium:r=11,a=8/(i=2),o=24/i-1;break;case ia.High:r=16,a=6/(i=1),o=24/i-1}this._aoSpiralSampleCount=r,this._blurStepPixels=i;for(var r,i,a,o,s=new Float32Array(12),l=2*a*a,c=0,u=(o+1)/2;c<u;c++)s[c]=Math.exp(-(c*c)/l);for(var d=r;d<12;d++)s[d]=0;e.setFloatArray(t._kernelProp,s),this._quality=n}},t}(ir);io.SHADER_NAME="ScalableAmbientOcclusion",io._invRadiusSquaredProp=nH.getByName("material_invRadiusSquared"),io._intensityProp=nH.getByName("material_intensity"),io._projectionScaleRadiusProp=nH.getByName("material_projectionScaleRadius"),io._biasProp=nH.getByName("material_bias"),io._minHorizonAngleSineSquaredProp=nH.getByName("material_minHorizonAngleSineSquared"),io._peak2Prop=nH.getByName("material_peak2"),io._powerProp=nH.getByName("material_power"),io._invProjScaleXYProp=nH.getByName("material_invProjScaleXY"),io._farPlaneOverEdgeDistanceProp=nH.getByName("material_farPlaneOverEdgeDistance"),io._kernelProp=nH.getByName("material_kernel"),rM.create(io.SHADER_NAME,[new rx("ScalableAmbientOcclusion",ii,"// Ambient Occlusion, largely inspired from:\n// \"The Alchemy Screen-Space Ambient Obscurance Algorithm\" by Morgan McGuire\n// \"Scalable Ambient Obscurance\" by Morgan McGuire, Michael Mara and David Luebke\n// https://research.nvidia.com/sites/default/files/pubs/2012-06_Scalable-Ambient-Obscurance/McGuire12SAO.pdf\n\n#include <common>\n\nvarying vec2 v_uv;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\nuniform highp sampler2D renderer_BlitTexture; // Camera_DepthTexture\n\n// float inc = (1.0f / (SAMPLE_COUNT - 0.5f)) * SPIRAL_TURNS * 2.0 * PI\n// const vec2 angleIncCosSin = vec2(cos(inc), sin(inc))\n#if SSAO_QUALITY == 0\n #define SAMPLE_COUNT 7.0\n #define SPIRAL_TURNS 3.0\n const vec2 angleIncCosSin = vec2(-0.971148, 0.238227);\n#elif SSAO_QUALITY == 1\n #define SAMPLE_COUNT 11.0\n #define SPIRAL_TURNS 6.0\n const vec2 angleIncCosSin = vec2(-0.896127, -0.443780);\n#elif SSAO_QUALITY == 2\n #define SAMPLE_COUNT 16.0\n #define SPIRAL_TURNS 7.0\n const vec2 angleIncCosSin = vec2(-0.966846, 0.255311);\n#endif\n\nuniform float material_invRadiusSquared; // Inverse of the squared radius\nuniform float material_minHorizonAngleSineSquared; // Minimum horizon angle sine squared\nuniform float material_intensity; // Intensity of the ambient occlusion\nuniform float material_projectionScaleRadius;\nuniform float material_bias; // Bias to avoid self-occlusion\nuniform float material_peak2; // Peak value to avoid singularities\nuniform float material_power; // Exponent to convert occlusion to visibility\nuniform vec2 material_invProjScaleXY; //invProjection[0][0] * 2, invProjection[1][1] * 2\n\n\nvec3 computeViewSpacePosition(vec2 uv, float linearDepth, vec2 invProjScaleXY) {\n #ifdef CAMERA_ORTHOGRAPHIC\n return vec3((vec2(0.5) - uv) * invProjScaleXY , linearDepth);\n #else\n return vec3((vec2(0.5) - uv) * invProjScaleXY * linearDepth, linearDepth);\n #endif\n}\n\nfloat depthToViewZ(float depth) {\n return -remapDepthBufferEyeDepth(depth);\n}\n\n// reconstructing normal from depth buffer\n// https://atyuwen.github.io/posts/normal-reconstruction\n// https://wickedengine.net/2019/09/22/improved-normal-reconstruction-from-depth/\nvec3 computeViewSpaceNormal(vec2 uv, highp sampler2D depthTexture, float depth, vec3 viewPos, vec2 texel, vec2 invProjScaleXY) {\n vec3 normal = vec3(0.0);\n#if SSAO_QUALITY == 0 || SSAO_QUALITY == 1\n vec2 uvdx = uv + vec2(texel.x, 0.0);\n vec2 uvdy = uv + vec2(0.0, texel.y);\n\n float depthX = texture2D(depthTexture, uvdx).r;\n float depthY = texture2D(depthTexture, uvdy).r;\n\n vec3 px = computeViewSpacePosition(uvdx, depthToViewZ(depthX), invProjScaleXY);\n vec3 py = computeViewSpacePosition(uvdy, depthToViewZ(depthY), invProjScaleXY);\n\n vec3 dpdx = px - viewPos;\n vec3 dpdy = py - viewPos;\n\n normal = normalize(cross(dpdx, dpdy));\n\n#elif SSAO_QUALITY == 2\n vec2 dx = vec2(texel.x, 0.0);\n vec2 dy = vec2(0.0, texel.y);\n \n vec4 H;\n H.x = texture2D(depthTexture, uv - dx).r; // left\n H.y = texture2D(depthTexture, uv + dx).r; // right\n H.z = texture2D(depthTexture, uv - dx * 2.0).r; // left2\n H.w = texture2D(depthTexture, uv + dx * 2.0).r; // right2\n \n // Calculate horizontal edge weights\n vec2 horizontalEdgeWeights = abs((2.0 * H.xy - H.zw) - depth);\n\n vec3 pos_l = computeViewSpacePosition(uv - dx, depthToViewZ(H.x), invProjScaleXY);\n vec3 pos_r = computeViewSpacePosition(uv + dx, depthToViewZ(H.y), invProjScaleXY);\n vec3 dpdx = (horizontalEdgeWeights.x < horizontalEdgeWeights.y) ? (viewPos - pos_l) : (pos_r - viewPos);\n\n // Sample depths for vertical edge detection\n vec4 V;\n V.x = texture2D(depthTexture, uv - dy).r; // down\n V.y = texture2D(depthTexture, uv + dy).r; // up\n V.z = texture2D(depthTexture, uv - dy * 2.0).r; // down2\n V.w = texture2D(depthTexture, uv + dy * 2.0).r; // up2\n\n // Calculate vertical edge weights\n vec2 verticalEdgeWeights = abs((2.0 * V.xy - V.zw) - depth);\n vec3 pos_d = computeViewSpacePosition(uv - dy, depthToViewZ(V.x), invProjScaleXY);\n vec3 pos_u = computeViewSpacePosition(uv + dy, depthToViewZ(V.y), invProjScaleXY);\n vec3 dpdy = (verticalEdgeWeights.x < verticalEdgeWeights.y) ? (viewPos - pos_d) : (pos_u - viewPos);\n normal = normalize(cross(dpdx, dpdy));\n #endif\n return normal;\n\n}\n\nvec3 tapLocation(float i, const float noise) {\n float offset = ((2.0 * PI) * 2.4) * noise;\n float angle = ((i / SAMPLE_COUNT) * SPIRAL_TURNS) * (2.0 * PI) + offset;\n float radius = (i + noise + 0.5) / SAMPLE_COUNT;\n return vec3(cos(angle), sin(angle), radius * radius);\n}\n\nvec2 startPosition(const float noise) {\n float angle = ((2.0 * PI) * 2.4) * noise;\n return vec2(cos(angle), sin(angle));\n}\n\nmat2 tapAngleStep() {\n vec2 t = angleIncCosSin;\n return mat2(t.x, t.y, -t.y, t.x);\n}\n\nvec3 tapLocationFast(float i, vec2 p, const float noise) {\n float radius = (i + noise + 0.5) / SAMPLE_COUNT;\n return vec3(p, radius * radius);\n}\n\nvoid computeAmbientOcclusionSAO(inout float occlusion, float i, float ssDiskRadius, vec2 uv, vec3 originPosition, vec3 normal,\n vec2 tapPosition, float noise) {\n\n vec3 tap = tapLocationFast(i, tapPosition, noise);\n\n float ssRadius = max(1.0, tap.z * ssDiskRadius); // at least 1 pixel screen-space radius\n\n vec2 uvSamplePos = uv + vec2(ssRadius * tap.xy) * renderer_texelSize.xy;\n\n float occlusionDepth = texture2D(renderer_BlitTexture, uvSamplePos).r;\n float linearOcclusionDepth = depthToViewZ(occlusionDepth);\n // “p” is the position after spiral sampling\n vec3 p = computeViewSpacePosition(uvSamplePos, linearOcclusionDepth, material_invProjScaleXY);\n\n // now we have the sample, compute AO\n vec3 v = p - originPosition; // sample vector\n float vv = dot(v, v); // squared distance\n float vn = dot(v, normal); // distance * cos(v, normal)\n\n // discard samples that are outside of the radius, preventing distant geometry to\n // cast shadows -- there are many functions that work and choosing one is an artistic\n // decision.\n float weight = pow(max(0.0, 1.0 - vv * material_invRadiusSquared), 2.0);\n\n // discard samples that are too close to the horizon to reduce shadows cast by geometry\n // not sufficently tessellated. The goal is to discard samples that form an angle 'beta'\n // smaller than 'epsilon' with the horizon. We already have dot(v,n) which is equal to the\n // sin(beta) * |v|. So the test simplifies to vn^2 < vv * sin(epsilon)^2.\n weight *= step(vv * material_minHorizonAngleSineSquared, vn * vn);\n\n // Calculate the contribution of a single sampling point to Ambient Occlusion\n float sampleOcclusion = max(0.0, vn + (originPosition.z * material_bias)) / (vv + material_peak2);\n occlusion += weight * sampleOcclusion;\n}\n\nvoid scalableAmbientObscurance(vec2 uv, vec3 origin, vec3 normal, out float obscurance) {\n float noise = interleavedGradientNoise(gl_FragCoord.xy);\n vec2 tapPosition = startPosition(noise);\n mat2 angleStep = tapAngleStep();\n\n // Choose the screen-space sample radius\n // proportional to the projected area of the sphere\n float ssDiskRadius = -(material_projectionScaleRadius / origin.z);\n\n // Accumulate the occlusion amount of all sampling points\n obscurance = 0.0;\n for (float i = 0.0; i < SAMPLE_COUNT; i += 1.0) {\n computeAmbientOcclusionSAO(obscurance, i, ssDiskRadius, uv, origin, normal, tapPosition, noise);\n tapPosition = angleStep * tapPosition;\n }\n obscurance = sqrt(obscurance * material_intensity);\n}\n\nvec2 pack(highp float normalizedDepth) {\n highp float z = clamp(normalizedDepth, 0.0, 1.0);\n highp float t = floor(256.0 * z);\n mediump float hi = t * (1.0 / 256.0);\n mediump float lo = (256.0 * z) - t;\n return vec2(hi, lo);\n}\n\n\nvoid main(){\n float depth = texture2D(renderer_BlitTexture, v_uv).r;\n float z = depthToViewZ(depth);\n\n // Reconstruct view space position from depth\n vec3 positionVS = computeViewSpacePosition(v_uv, z, material_invProjScaleXY);\n\n // Compute normal\n vec3 normal = computeViewSpaceNormal(v_uv, renderer_BlitTexture, depth, positionVS, renderer_texelSize.xy, material_invProjScaleXY);\n\n float occlusion = 0.0;\n scalableAmbientObscurance(v_uv, positionVS, normal, occlusion);\n\n // Occlusion to visibility\n float aoVisibility = pow(clamp(1.0 - occlusion, 0.0, 1.0), material_power);\n\n gl_FragColor = vec4(aoVisibility, pack(-positionVS.z/camera_ProjectionParams.z), 1.0);\n}\n\n"),new rx("BilateralBlur",ii,"#include <common>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_SourceScaleOffset; \nuniform float material_farPlaneOverEdgeDistance;\n#if SSAO_QUALITY == 0\n #define BLUR_SAMPLE_COUNT 3\n#elif SSAO_QUALITY == 1\n #define BLUR_SAMPLE_COUNT 6\n#elif SSAO_QUALITY == 2\n #define BLUR_SAMPLE_COUNT 12\n#endif\n\nuniform float material_kernel[12]; // Sample weights for bilateral blur\n\nfloat bilateralWeight(float depth, float sampleDepth) {\n float diff = (sampleDepth - depth) * material_farPlaneOverEdgeDistance;\n return max(0.0, 1.0 - diff * diff);\n}\n\nhighp float unpack(highp vec2 depth) {\n // depth here only has 8-bits of precision, but the unpacked depth is highp\n // this is equivalent to (x8 * 256 + y8) / 65535, which gives a value between 0 and 1\n return (depth.x * (256.0 / 257.0) + depth.y * (1.0 / 257.0));\n}\n\nvoid tap(const sampler2D saoTexture,\n inout float sum, inout float totalWeight, float weight, float depth, vec2 position) {\n vec4 data = texture2D(saoTexture, position);\n // bilateral sample\n float bilateral = weight * bilateralWeight(depth, unpack(data.gb));\n sum += data.r * bilateral;\n totalWeight += bilateral;\n}\n\nvoid main(){\n mediump vec4 data = texture2D(renderer_BlitTexture, v_uv);\n float depth = unpack(data.gb);\n\n // Weight of the center pixel from the Gaussian kernel (typically 1.0)\n float totalWeight = material_kernel[0];\n float sum = data.r * totalWeight;\n \n vec2 offset = renderer_SourceScaleOffset.zw;\n for (int i = 1; i < BLUR_SAMPLE_COUNT; i++) {\n float weight = material_kernel[i];\n tap(renderer_BlitTexture, sum, totalWeight, weight, depth, v_uv + offset);\n tap(renderer_BlitTexture, sum, totalWeight, weight, depth, v_uv - offset);\n offset += renderer_SourceScaleOffset.zw;\n }\n\n float ao = sum * (1.0 / totalWeight);\n\n // simple dithering helps a lot (assumes 8 bits target)\n // this is most useful with high quality/large blurs\n ao += ((interleavedGradientNoise(gl_FragCoord.xy) - 0.5) / 255.0);\n gl_FragColor = vec4(ao, data.gb, 1.0);\n\n}\n\n")]);var is=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t=!1),this.enabled=!0,this._needLerp=!1,this._needLerp=t,this._value=e}return e.prototype._lerp=function(e,t){t>0&&(this.value=e)},t4(e,[{key:"value",get:function(){return this._value},set:function(e){this._value=e}}]),e}(),il=/*#__PURE__*/function(e){function t(t,n,r,i){var a;return void 0===n&&(n=Number.NEGATIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY),void 0===i&&(i=!0),(a=e.call(this,t,i)||this).min=n,a.max=r,a.value=t,a}return t5(t,e),t.prototype._lerp=function(t,n){this._needLerp?this.value=tk.lerp(this.value,t,n):e.prototype._lerp.call(this,t,n)},t4(t,[{key:"value",get:function(){return this._value},set:function(e){this._value=tk.clamp(e,this.min,this.max)}}]),t}(is),ic=/*#__PURE__*/function(e){function t(t){return e.call(this,t,!1)||this}return t5(t,e),t}(is),iu=/*#__PURE__*/function(e){function t(t){return e.call(this,t,!1)||this}return t5(t,e),t}(is),id=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t5(t,e),t.prototype._lerp=function(t,n){this._needLerp?tJ.lerp(this.value,t,n,this.value):e.prototype._lerp.call(this,t,n)},t}(is),ih=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t5(t,e),t.prototype._lerp=function(t,n){this._needLerp?tq.lerp(this.value,t,n,this.value):e.prototype._lerp.call(this,t,n)},t}(is),i_=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t5(t,e),t.prototype._lerp=function(t,n){this._needLerp?tU.lerp(this.value,t,n,this.value):e.prototype._lerp.call(this,t,n)},t}(is),ip=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t5(t,e),t.prototype._lerp=function(t,n){this._needLerp?tZ.lerp(this.value,t,n,this.value):e.prototype._lerp.call(this,t,n)},t}(is),im=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,n,!1)||this).enumType=t,r}return t5(t,e),t}(is),ig=/*#__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];t7(t,is)&&this._parameters.push(t)}return this._parameters},t4(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e)}}]),e}(),iv=((et={})[et.Half=0]="Half",et[et.Quarter=1]="Quarter",et),iy=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.highQualityFiltering=new ic(!1),t.downScale=new im(iv,0),t.dirtTexture=new iu(null),t.threshold=new il(.8,0),t.scatter=new il(.7,0,1),t.intensity=new il(0,0),t.dirtIntensity=new il(0,0),t.tint=new id(new tJ(1,1,1,1)),t}return t5(t,e),t.prototype.isValid=function(){return this.enabled&&this.intensity.value>0},t}(ig);iy.SHADER_NAME="PostProcessEffect Bloom",iy._maxIterations=6,iy._hqMacro=rc.getByName("BLOOM_HQ"),iy._dirtMacro=rc.getByName("BLOOM_DIRT"),iy._bloomParams=nH.getByName("material_BloomParams"),iy._lowMipTextureProp=nH.getByName("material_lowMipTexture"),iy._lowMipTexelSizeProp=nH.getByName("material_lowMipTexelSize"),iy._enableMacro=rc.getByName("ENABLE_EFFECT_BLOOM"),iy._bloomTextureProp=nH.getByName("material_BloomTexture"),iy._dirtTextureProp=nH.getByName("material_BloomDirtTexture"),iy._tintProp=nH.getByName("material_BloomTint"),iy._bloomIntensityParams=nH.getByName("material_BloomIntensityParams"),iy._dirtTilingOffsetProp=nH.getByName("material_BloomDirtTilingOffset"),rM.create(iy.SHADER_NAME,[new rx("Bloom Prefilter",ii,"#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 = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, -1.0));\n mediump vec4 B = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, -1.0));\n mediump vec4 C = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, -1.0));\n mediump vec4 D = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, -0.5));\n mediump vec4 E = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, -0.5));\n mediump vec4 F = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 0.0));\n mediump vec4 G = texture2DSRGB(renderer_BlitTexture, v_uv);\n mediump vec4 H = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 0.0));\n mediump vec4 I = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, 0.5));\n mediump vec4 J = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, 0.5));\n mediump vec4 K = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 1.0));\n mediump vec4 L = texture2DSRGB(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, 1.0));\n mediump vec4 M = texture2DSRGB(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 = texture2DSRGB(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 // Bloom is addtive blend mode, we should set alpha 0 to avoid browser background color dark when canvas alpha and premultiplyAlpha is true\n gl_FragColor = vec4(color, 0.0);\n}\n"),new rx("Bloom Blur Horizontal",ii,"#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 = texture2DSRGB(renderer_BlitTexture, v_uv - vec2(texelSize.x * 4.0, 0.0));\n mediump vec4 c1 = texture2DSRGB(renderer_BlitTexture, v_uv - vec2(texelSize.x * 3.0, 0.0));\n mediump vec4 c2 = texture2DSRGB(renderer_BlitTexture, v_uv - vec2(texelSize.x * 2.0, 0.0));\n mediump vec4 c3 = texture2DSRGB(renderer_BlitTexture, v_uv - vec2(texelSize.x * 1.0, 0.0));\n mediump vec4 c4 = texture2DSRGB(renderer_BlitTexture, v_uv);\n mediump vec4 c5 = texture2DSRGB(renderer_BlitTexture, v_uv + vec2(texelSize.x * 1.0, 0.0));\n mediump vec4 c6 = texture2DSRGB(renderer_BlitTexture, v_uv + vec2(texelSize.x * 2.0, 0.0));\n mediump vec4 c7 = texture2DSRGB(renderer_BlitTexture, v_uv + vec2(texelSize.x * 3.0, 0.0));\n mediump vec4 c8 = texture2DSRGB(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}"),new rx("Bloom Blur Vertical",ii,"#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 = texture2DSRGB(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 3.23076923));\n mediump vec4 c1 = texture2DSRGB(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c2 = texture2DSRGB(renderer_BlitTexture, v_uv);\n mediump vec4 c3 = texture2DSRGB(renderer_BlitTexture, v_uv + vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c4 = texture2DSRGB(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}"),new rx("Bloom Upsample",ii,"#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 = texture2DSRGB(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 = texture2DSRGB(material_lowMipTexture, v_uv);\n #endif\n \n gl_FragColor = mix(highMip, lowMip, material_BloomParams.z);\n}")]);var ix=((en={})[en.Neutral=0]="Neutral",en[en.ACES=1]="ACES",en),iA=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.mode=new im(ix,0),t}return t5(t,e),t}(ig);iA._enableMacro=rc.getByName("ENABLE_EFFECT_TONEMAPPING");var ib=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.layer=rU.Layer0,t.blendDistance=0,t._effects=[],t._priority=0,t._isGlobal=!0,t}t5(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(t7(i,e))return i}},n.addEffect=function(e){if(this.getEffect(e)){nb.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(t7(i,e))return t.splice(r,1),i}},n._onEnableInScene=function(){this.scene.postProcessManager._addPostProcess(this)},n._onDisableInScene=function(){this.scene.postProcessManager._removePostProcess(this)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._effects.length=0},t4(t,[{key:"isGlobal",get:function(){return this._isGlobal},set:function(e){if(e!==this._isGlobal){if(!e&&!this.engine._physicsInitialized){nb.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}(rN);t6([ni],ib.prototype,"_effects",void 0);var iS=((er={})[er.Property=1]="Property",er[er.Count=2]="Count",er[er.Both=3]="Both",er),iC=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._index=-1,n._shapes=[],n._collisionLayerIndex=0,n._updateFlag=t.registerWorldChangeFlag(),n}t5(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(iS.Count))},n.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this._removeNativeShape(e),this._handleShapesChanged(iS.Count))},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(iS.Count)},n._onUpdate=function(){if(this._updateFlag.flag){var e,t=this.entity.transform;this._nativeCollider.setWorldTransform(t.worldPosition,t.worldRotationQuaternion);for(var n=t.lossyWorldScale,r=this._shapes,i=0,a=r.length;i<a;i++)null==(e=r[i]._nativeShape)||e.setWorldScale(n);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(e){e&iS.Count&&this._setCollisionLayer()},n._syncNative=function(){for(var e=0,t=this.shapes.length;e<t;e++)this._addNativeShape(this.shapes[e]);this._setCollisionLayer()},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,e._nativeShape&&(e._nativeShape.setWorldScale(this.entity.transform.lossyWorldScale),this._nativeCollider.addShape(e._nativeShape))},n._removeNativeShape=function(e){e._collider=null,e._nativeShape&&this._nativeCollider.removeShape(e._nativeShape)},n._setCollisionLayer=function(){this._nativeCollider.setCollisionLayer(this._collisionLayerIndex)},t4(t,[{key:"shapes",get:function(){return this._shapes}},{key:"collisionLayer",get:function(){return 1<<this._collisionLayerIndex},set:function(e){var t=Math.log2(e);if(!Number.isInteger(t))throw Error("Collision layer must be a single layer (Layer.Layer0 to Layer.Layer31)");this._collisionLayerIndex=t,this._nativeCollider.setCollisionLayer(t)}}]),t}(rN);t6([nt],iC.prototype,"_index",void 0),t6([nt],iC.prototype,"_nativeCollider",void 0),t6([nt],iC.prototype,"_updateFlag",void 0),t6([ni],iC.prototype,"_shapes",void 0),iC=t6([rV(rG,rk.CheckOnly)],iC);var iT=((ei={})[ei.PreventClimbing=0]="PreventClimbing",ei[ei.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding",ei),iR=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=iT.PreventClimbing,n._upDirection=new tU(0,1,0),n._slopeLimit=45,n._nativeCollider=oK._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(n),n._upDirection._onValueChanged=n._setUpDirection,n._nativeCollider.setWorldPosition(n.entity.transform.worldPosition),n}t5(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)},t4(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}(iC);t6([ni],iR.prototype,"_upDirection",void 0),t6([nt],iR.prototype,"_setUpDirection",null);var iE=((ea={})[ea.Cleaning=1]="Cleaning",ea[ea.VertexWelding=2]="VertexWelding",ea),iM=((eo={})[eo.Average=0]="Average",eo[eo.Minimum=1]="Minimum",eo[eo.Multiply=2]="Multiply",eo[eo.Maximum=3]="Maximum",eo),iP=/*#__PURE__*/function(){function e(){this._bounciness=0,this._dynamicFriction=.6,this._staticFriction=.6,this._bounceCombine=iM.Average,this._frictionCombine=iM.Average,this._nativeMaterial=oK._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},t4(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}(),iw=/*#__PURE__*/function(){function e(){this._isTrigger=!1,this._rotation=new tU,this._position=new tU,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new iP,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,oK._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&&(this._nativeShape.destroy(),this._nativeShape=null),delete oK._physicalObjectsMap[this._id]},t._syncNative=function(){var e;this._nativeShape&&(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(iS.Property))},t._setPosition=function(){var e,t;null==(e=this._nativeShape)||e.setPosition(this._position),null==(t=this._collider)||t._handleShapesChanged(iS.Property)},t._setRotation=function(){var e,t;null==(e=this._nativeShape)||e.setRotation(this._rotation),null==(t=this._collider)||t._handleShapesChanged(iS.Property)},t4(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){if(e=Math.max(0,e),this._contactOffset!==e){var t;this._contactOffset=e,null==(t=this._nativeShape)||t.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.");if(this._material!==e){var t;this._material=e,null==(t=this._nativeShape)||t.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){if(this._isTrigger!==e){var t;this._isTrigger=e,null==(t=this._nativeShape)||t.setIsTrigger(e)}}}]),e}();iw._idGenerator=0,t6([nt],iw.prototype,"_nativeShape",void 0),t6([nt],iw.prototype,"_id",void 0),t6([ni],iw.prototype,"_rotation",void 0),t6([ni],iw.prototype,"_position",void 0),t6([nt],iw.prototype,"_setPosition",null),t6([nt],iw.prototype,"_setRotation",null);var iF=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._mesh=null,t._isConvex=!1,t._positions=null,t._indices=null,t._cookingFlags=iE.Cleaning|iE.VertexWelding,t._isShapeAttached=!1,t}t5(t,e);var n=t.prototype;return n.getClosestPoint=function(t,n){return this._nativeShape?e.prototype.getClosestPoint.call(this,t,n):(console.warn("MeshColliderShape: Cannot get closest point. Ensure mesh has been set with valid data."),-1)},n._destroy=function(){e.prototype._destroy.call(this),this._mesh&&(this._mesh._addReferCount(-1),this._mesh=null),this._clearMeshData()},n._clearMeshData=function(){this._positions=null,this._indices=null},n._destroyNativeShape=function(){this._nativeShape&&(this._isShapeAttached&&this._detachFromCollider(),this._nativeShape.destroy(),this._nativeShape=null)},n._extractMeshData=function(e){if(!e.accessible)return console.warn("MeshColliderShape: Mesh data is not accessible. Set 'keepMeshData' before uploading."),!1;var t=e.getPositions();if(!t||0===t.length)return console.warn("MeshColliderShape: Mesh has no position data."),!1;if(this._positions=t,this._indices=null,!this._isConvex){var n=e.getIndices();if(!n)return console.warn("MeshColliderShape: Non-convex mesh requires indices."),!1;this._indices=n}return!0},n._updateNativeShapeData=function(){this._nativeShape.setMeshData(this._positions,this._indices,this._isConvex,this._cookingFlags)?this._collider&&!this._isShapeAttached&&this._attachToCollider():this._isShapeAttached&&this._detachFromCollider()},n._detachFromCollider=function(){this._collider._nativeCollider.removeShape(this._nativeShape),this._isShapeAttached=!1},n._attachToCollider=function(){this._collider._nativeCollider.addShape(this._nativeShape),this._isShapeAttached=!0},n._createNativeShape=function(){if(!this._isConvex&&t7(this._collider,iL)&&!this._collider.isKinematic){console.error("MeshColliderShape: Non-convex mesh is not supported on non-kinematic DynamicCollider.");return}var t=oK._nativePhysics.createMeshColliderShape(this._id,this._positions,this._indices,this._isConvex,this._material._nativeMaterial,this._cookingFlags);t&&(this._nativeShape=t,e.prototype._syncNative.call(this),this._collider&&(t.setWorldScale(this._collider.entity.transform.lossyWorldScale),this._attachToCollider()))},t4(t,[{key:"cookingFlags",get:function(){return this._cookingFlags},set:function(e){this._cookingFlags!==e&&(this._cookingFlags=e,this._nativeShape?this._updateNativeShapeData():this._mesh&&this._extractMeshData(this._mesh)&&this._createNativeShape())}},{key:"isConvex",get:function(){return this._isConvex},set:function(e){if(this._isConvex!==e){this._isConvex=e;var t=this._mesh;t&&(this._destroyNativeShape(),this._extractMeshData(t)?this._createNativeShape():this._clearMeshData())}}},{key:"mesh",get:function(){return this._mesh},set:function(e){if(this._mesh!==e){var t;null==(t=this._mesh)||t._addReferCount(-1),null==e||e._addReferCount(1),this._mesh=e,e&&this._extractMeshData(e)?this._nativeShape?this._updateNativeShapeData():this._createNativeShape():(this._destroyNativeShape(),this._clearMeshData())}}}]),t}(iw),iL=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._linearDamping=0,n._angularDamping=.05,n._linearVelocity=new tU,n._angularVelocity=new tU,n._mass=1,n._centerOfMass=new tU,n._inertiaTensor=new tU(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=oK._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}t5(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){if(!this._isKinematic){console.warn("DynamicCollider: move() is only supported when isKinematic is true.");return}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.addShape=function(t){if(t7(t,iF)&&!t.isConvex&&!this._isKinematic){console.error("DynamicCollider: Non-convex MeshColliderShape is not supported on non-kinematic DynamicCollider.");return}e.prototype.addShape.call(this,t)},n._onLateUpdate=function(){var e=this.entity.transform,n=e.worldPosition,r=e.worldRotationQuaternion,i=t._tempVector3,a=t._tempQuat;this._nativeCollider.getWorldTransform(i,a),tU.equals(i,n)||n.copyFrom(i),tY.equals(a,r)||r.copyFrom(a),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(t){e.prototype._handleShapesChanged.call(this,t),(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.setUseGravity(this._useGravity),this._nativeCollider.setIsKinematic(this._isKinematic),this._nativeCollider.setConstraints(this._constraints),this._nativeCollider.setCollisionDetectionMode(this._collisionDetectionMode)},n._setMassAndUpdateInertia=function(){!this._isKinematic&&(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)},t4(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){if(this._isKinematic!==e){if(!e)for(var t=this._shapes,n=0,r=t.length;n<r;n++){var i=t[n];if(t7(i,iF)&&!i.isConvex){console.error("DynamicCollider: Cannot set isKinematic=false when non-convex MeshColliderShape is attached.");return}}this._isKinematic=e,this._nativeCollider.setIsKinematic(e),!e&&(this._nativeCollider.setCollisionDetectionMode(this._collisionDetectionMode),(this._automaticCenterOfMass||this._automaticInertiaTensor)&&this._setMassAndUpdateInertia())}}},{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}(iC);iL._tempVector3=new tU,iL._tempQuat=new tY,t6([nt],iL.prototype,"_linearVelocity",void 0),t6([nt],iL.prototype,"_angularVelocity",void 0),t6([nt],iL.prototype,"_centerOfMass",void 0),t6([nt],iL.prototype,"_inertiaTensor",void 0),t6([nt],iL.prototype,"_setLinearVelocity",null),t6([nt],iL.prototype,"_setAngularVelocity",null),t6([nt],iL.prototype,"_handleCenterOfMassChanged",null),t6([nt],iL.prototype,"_handleInertiaTensorChanged",null);var iD=((es={})[es.Discrete=0]="Discrete",es[es.Continuous=1]="Continuous",es[es.ContinuousDynamic=2]="ContinuousDynamic",es[es.ContinuousSpeculative=3]="ContinuousSpeculative",es),iB=((el={})[el.None=0]="None",el[el.FreezePositionX=1]="FreezePositionX",el[el.FreezePositionY=2]="FreezePositionY",el[el.FreezePositionZ=4]="FreezePositionZ",el[el.FreezeRotationX=8]="FreezeRotationX",el[el.FreezeRotationY=16]="FreezeRotationY",el[el.FreezeRotationZ=32]="FreezeRotationZ",el),iI=function(){this.entity=null,this.distance=0,this.point=new tU,this.normal=new tU,this.shape=null},iN=function(){this.position=new tU,this.normal=new tU,this.impulse=new tU},iO=/*#__PURE__*/function(){function e(){}return e.prototype.getContacts=function(e){for(var t=this._nativeCollision,n=Math.min(t.shape0Id,t.shape1Id),r=this.shape.id===n?1:-1,i=t.getContacts(),a=i.size(),o=0;o<a;o++){var s,l=i.get(o),c=e[s=o]||(e[s]=new iN);c.position.copyFrom(l.position),c.normal.copyFrom(l.normal).scale(r),c.impulse.copyFrom(l.impulse).scale(r),c.separation=l.separation}return a},t4(e,[{key:"contactCount",get:function(){return this._nativeCollision.contactCount}}]),e}(),iV=/*#__PURE__*/function(){function e(e){this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new nQ,this._gravity=new tU(0,-9.81,0),this._scene=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var t=e.engine;t._physicsInitialized&&(this._nativePhysicsScene=oK._nativePhysics.createPhysicsScene(t._nativePhysicsManager))}var t=e.prototype;return t.getColliderLayerCollision=function(e,t){var n=Math.log2(e),r=Math.log2(t);if(!Number.isInteger(n)||!Number.isInteger(n))throw Error("Collision layer must be a single layer (Layer.Layer0 to Layer.Layer31)");return oK._nativePhysics.getColliderLayerCollision(n,r)},t.setColliderLayerCollision=function(e,t,n){var r=Math.log2(e),i=Math.log2(t);if(!Number.isInteger(r)||!Number.isInteger(r))throw Error("Collision layer must be a single layer (Layer.Layer0 to Layer.Layer31)");oK._nativePhysics.setColliderLayerCollision(r,i,n)},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=rU.Everything;"number"==typeof n?o=n:void 0!=n&&(i=n),r&&(i=r);var s=this._createPreFilter(o),l=this._nativePhysicsScene.raycast(e,a,s,i?this._createHitCallback(i):void 0);return!l&&i&&this._clearHitResult(i),l},t.boxCast=function(t,n,r,i,a,o,s){var l,c=e._identityQuaternion,u=Number.MAX_VALUE,d=rU.Everything;"number"==typeof i?(u=i,(null==a?void 0:a.constructor)===iI&&(l=a)):(null==i?void 0:i.constructor)===iI?l=i:(null==i?void 0:i.constructor)===tY&&(c=i,"number"==typeof a&&(u=a,"number"==typeof o&&(d=o))),s&&(l=s);var h=this._createPreFilter(d),_=this._nativePhysicsScene.boxCast(t,c,n,r,u,h,l?this._createHitCallback(l):void 0);return!_&&l&&this._clearHitResult(l),_},t.sphereCast=function(e,t,n,r,i,a){var o,s=Number.MAX_VALUE,l=rU.Everything;"number"==typeof r?(s=r,(null==i?void 0:i.constructor)===iI?o=i:"number"==typeof i&&(l=i)):(null==r?void 0:r.constructor)===iI&&(o=r),a&&(o=a);var c=this._createPreFilter(l),u=this._nativePhysicsScene.sphereCast(e,t,n,s,c,o?this._createHitCallback(o):void 0);return!u&&o&&this._clearHitResult(o),u},t.capsuleCast=function(t,n,r,i,a,o,s,l){var c,u=e._identityQuaternion,d=Number.MAX_VALUE,h=rU.Everything;"number"==typeof a?(d=a,(null==o?void 0:o.constructor)===iI&&(c=o)):(null==a?void 0:a.constructor)===iI?c=a:(null==a?void 0:a.constructor)===tY&&(u=a,"number"==typeof o&&(d=o,"number"==typeof s&&(h=s))),l&&(c=l);var _=this._createPreFilter(h),f=this._nativePhysicsScene.capsuleCast(t,n,r,u,i,d,_,c?this._createHitCallback(c):void 0);return!f&&c&&this._clearHitResult(c),f},t.overlapBoxAll=function(t,n,r,i,a){void 0===r&&(r=e._identityQuaternion),void 0===i&&(i=rU.Everything),void 0===a&&(a=[]);var o=this._nativePhysicsScene.overlapBoxAll(t,r,n,this._createPreFilter(i));a.length=0;for(var s=0,l=o.length;s<l;s++)a.push(oK._physicalObjectsMap[o[s]]);return a},t.overlapSphereAll=function(e,t,n,r){void 0===n&&(n=rU.Everything),void 0===r&&(r=[]);var i=this._nativePhysicsScene.overlapSphereAll(e,t,this._createPreFilter(n));r.length=0;for(var a=0;a<i.length;a++)r.push(oK._physicalObjectsMap[i[a]]);return r},t.overlapCapsuleAll=function(t,n,r,i,a,o){void 0===i&&(i=e._identityQuaternion),void 0===a&&(a=rU.Everything),void 0===o&&(o=[]);var s=this._nativePhysicsScene.overlapCapsuleAll(t,n,r,i,this._createPreFilter(a));o.length=0;for(var l=0;l<s.length;l++)o.push(oK._physicalObjectsMap[s[l]]);return o},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(),this._dispatchEvents(n.updateEvents())},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(){var e;this._colliders.garbageCollection(),null==(e=this._nativePhysicsScene)||e.gc()},t._destroy=function(){var e;null==(e=this._nativePhysicsScene)||e.destroy()},t._dispatchEvents=function(t){for(var n=oK._physicalObjectsMap,r=e._collision,i=e._scriptIndexSetter,a=t.contactEvents,o=t.contactEventCount,s=t.triggerEvents,l=0;l<o;l++)!function(e,t){var o,s,l=a[e],c=n[l.shape0Id],u=n[l.shape1Id];if((null==c?void 0:null==(o=c.collider)?void 0:o.entity)&&(null==u?void 0:null==(s=u.collider)?void 0:s.entity))switch(r._nativeCollision=l,l.state){case 0:c.collider.entity._scripts.forEach(function(e){r.shape=u,e.onCollisionEnter(r)},i),u.collider.entity._scripts.forEach(function(e){r.shape=c,e.onCollisionEnter(r)},i);break;case 1:c.collider.entity._scripts.forEach(function(e){r.shape=u,e.onCollisionStay(r)},i),u.collider.entity._scripts.forEach(function(e){r.shape=c,e.onCollisionStay(r)},i);break;case 2:c.collider.entity._scripts.forEach(function(e){r.shape=u,e.onCollisionExit(r)},i),u.collider.entity._scripts.forEach(function(e){r.shape=c,e.onCollisionExit(r)},i)}}(l);for(var c=0,u=s.length;c<u;c++)!function(e,t){var r,a,o=s[e],l=n[o.index1],c=n[o.index2];if((null==l?void 0:null==(r=l.collider)?void 0:r.entity)&&(null==c?void 0:null==(a=c.collider)?void 0:a.entity))switch(o.dispatchState){case 0:l.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(c)},i),c.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(l)},i);break;case 1:l.collider.entity._scripts.forEach(function(e){e.onTriggerStay(c)},i),c.collider.entity._scripts.forEach(function(e){e.onTriggerStay(l)},i);break;case 2:l.collider.entity._scripts.forEach(function(e){e.onTriggerExit(c)},i),c.collider.entity._scripts.forEach(function(e){e.onTriggerExit(l)},i)}}(c)},t._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},t._createPreFilter=function(e){return function(t){var n=oK._physicalObjectsMap[t];return!!n&&n.collider.entity.layer&e&&n.isSceneQuery}},t._createHitCallback=function(e){return function(t,n,r,i){e.entity=oK._physicalObjectsMap[t].collider.entity,e.shape=oK._physicalObjectsMap[t],e.distance=n,e.point.copyFrom(r),e.normal.copyFrom(i)}},t._clearHitResult=function(e){e.entity=null,e.shape=null,e.distance=0,e.point.set(0,0,0),e.normal.set(0,0,0)},t4(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,tk.zeroTolerance)}}]),e}();iV._collision=new iO,iV._identityQuaternion=new tY(0,0,0,1),iV._scriptIndexSetter=function(e,t){e._entityScriptsIndex=t};var ik=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t)||this).entity.transform;return n._nativeCollider=oK._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),n}return t5(t,e),t}(iC),iU=((ec={})[ec.X=0]="X",ec[ec.Y=1]="Y",ec[ec.Z=2]="Z",ec),iz=((eu={})[eu.Sides=1]="Sides",eu[eu.Up=2]="Up",eu[eu.Down=4]="Down",eu),iG=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._colliderInfo=new iH,n._connectedColliderInfo=new iH,n._force=1/0,n._torque=1/0,n._automaticConnectedAnchor=!0,n._colliderInfo.anchor._onValueChanged=n._updateActualAnchor.bind(n,1),n._handleConnectedAnchorChanged=n._handleConnectedAnchorChanged.bind(n),n._connectedColliderInfo.anchor._onValueChanged=n._handleConnectedAnchorChanged.bind(n),n._onSelfTransformChanged=n._onSelfTransformChanged.bind(n),n._onConnectedTransformChanged=n._onConnectedTransformChanged.bind(n),t._updateFlagManager.addListener(n._onSelfTransformChanged),n}t5(t,e);var n=t.prototype;return n._onEnableInScene=function(){this._createJoint(),this._syncNative(),this._updateRotation()},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=n.anchor,i=n.actualAnchor,a=n.collider;if(r._onValueChanged=null,a){var o=t._tempVector3,s=t._tempMatrix;tU.transformCoordinate(e.anchor,this.entity.transform.worldMatrix,o),tK.invert(a.entity.transform.worldMatrix,s),tU.transformCoordinate(o,s,r)}else tU.transformCoordinate(e.anchor,this.entity.transform.worldMatrix,i),r.copyFrom(i);r._onValueChanged=this._handleConnectedAnchorChanged,this._updateActualAnchor(2)},n._handleConnectedAnchorChanged=function(){this._automaticConnectedAnchor?console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true."):this._updateActualAnchor(2)},n._onSelfTransformChanged=function(e){e&rH.WorldScale&&this._updateActualAnchor(1)},n._onConnectedTransformChanged=function(e){e&rH.WorldScale&&this._updateActualAnchor(2)},n._updateRotation=function(){var e,n=t._tempQuat,r=this._connectedColliderInfo.collider;r&&tY.invert(r.entity.transform.worldRotationQuaternion,n),tY.multiply(n,this.entity.transform.worldRotationQuaternion,n),null==(e=this._nativeJoint)||e.setRotation(n)},n._updateActualAnchor=function(e){if(1&e){var t,n=this.entity.transform.lossyWorldScale,r=this._colliderInfo;tU.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;tU.multiply(a.anchor,s,a.actualAnchor)}else a.actualAnchor.copyFrom(a.anchor);null==(i=this._nativeJoint)||i.setConnectedAnchor(a.actualAnchor)}},t4(t,[{key:"connectedCollider",get:function(){return this._connectedColliderInfo.collider},set:function(e){var t,n=this._connectedColliderInfo.collider;n!==e&&(null==n||n.entity._updateFlagManager.removeListener(this._onConnectedTransformChanged),null==e||e.entity._updateFlagManager.addListener(this._onConnectedTransformChanged),this._connectedColliderInfo.collider=e,null==(t=this._nativeJoint)||t.setConnectedCollider(null==e?void 0:e._nativeCollider),this._updateRotation(),this._automaticConnectedAnchor?this._calculateConnectedAnchor():this._updateActualAnchor(2))}},{key:"anchor",get:function(){return this._colliderInfo.anchor},set:function(e){var t=this._colliderInfo.anchor;e!==t&&(t.copyFrom(e),this._updateActualAnchor(1),this._automaticConnectedAnchor&&this._calculateConnectedAnchor())}},{key:"connectedAnchor",get:function(){return this._connectedColliderInfo.anchor},set:function(e){var t=this._connectedColliderInfo.anchor;e!==t&&t.copyFrom(e)}},{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}(rN);iG._tempVector3=new tU,iG._tempQuat=new tY,iG._tempMatrix=new tK,t6([ni],iG.prototype,"_colliderInfo",void 0),t6([ni],iG.prototype,"_connectedColliderInfo",void 0),t6([nt],iG.prototype,"_nativeJoint",void 0),t6([nt],iG.prototype,"_handleConnectedAnchorChanged",null),t6([nt],iG.prototype,"_onSelfTransformChanged",null),t6([nt],iG.prototype,"_onConnectedTransformChanged",null),iG=t6([rV(iL,rk.AutoAdd)],iG);var iH=function(){this.collider=null,this.anchor=new tU,this.actualAnchor=new tU,this.massScale=1,this.inertiaScale=1};t6([ni],iH.prototype,"anchor",void 0),t6([ni],iH.prototype,"actualAnchor",void 0);var iW=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t5(t,e),t.prototype._createJoint=function(){var e=this._colliderInfo;e.collider=this.entity.getComponent(iC),this._nativeJoint=oK._nativePhysics.createFixedJoint(e.collider._nativeCollider)},t}(iG),iX=((ed={})[ed.None=0]="None",ed[ed.LimitEnabled=1]="LimitEnabled",ed[ed.DriveEnabled=2]="DriveEnabled",ed[ed.DriveFreeSpin=4]="DriveFreeSpin",ed),ij=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._axis=new tU(1,0,0),n._hingeFlags=iX.None,n._useSpring=!1,n._angle=0,n._velocity=0,n._onMotorChanged=n._onMotorChanged.bind(n),n._onLimitsChanged=n._onLimitsChanged.bind(n),n._onAxisChanged=n._onAxisChanged.bind(n),n._axis._onValueChanged=n._onAxisChanged,n}t5(t,e);var n=t.prototype;return n._onDisableInScene=function(){var t=this._nativeJoint;this._angle=t.getAngle(),this._velocity=t.getVelocity(),e.prototype._onDisableInScene.call(this)},n._createJoint=function(){var e=this._colliderInfo;e.collider=this.entity.getComponent(iC),this._nativeJoint=oK._nativePhysics.createHingeJoint(e.collider._nativeCollider)},n._syncNative=function(){e.prototype._syncNative.call(this);var t=this._jointMotor;this._nativeJoint.setAxis(this._axis),this._nativeJoint.setHingeJointFlag(iX.LimitEnabled,this.useLimits),this._nativeJoint.setHingeJointFlag(iX.DriveEnabled,this.useMotor),t&&(this._nativeJoint.setDriveVelocity(t.targetVelocity),this._nativeJoint.setDriveForceLimit(t.forceLimit),this._nativeJoint.setDriveGearRatio(t.gearRatio),this._nativeJoint.setHingeJointFlag(iX.DriveFreeSpin,t.freeSpin))},n._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(iX.DriveFreeSpin,e.freeSpin))},n._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))},n._onAxisChanged=function(){var e;this._axis._onValueChanged=null,this._axis.normalize(),null==(e=this._nativeJoint)||e.setAxis(this._axis),this._axis._onValueChanged=this._onAxisChanged},t4(t,[{key:"axis",get:function(){return this._axis},set:function(e){var t=this._axis;e!==t&&t.copyFrom(e)}},{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&iX.LimitEnabled)==iX.LimitEnabled},set:function(e){if(e!==this.useLimits){var t;e?this._hingeFlags|=iX.LimitEnabled:this._hingeFlags&=~iX.LimitEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iX.LimitEnabled,e)}}},{key:"useMotor",get:function(){return(this._hingeFlags&iX.DriveEnabled)==iX.DriveEnabled},set:function(e){if(e!==this.useMotor){var t;e?this._hingeFlags|=iX.DriveEnabled:this._hingeFlags&=~iX.DriveEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iX.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()}}}]),t}(iG);t6([ni],ij.prototype,"_axis",void 0),t6([ni],ij.prototype,"_jointMotor",void 0),t6([ni],ij.prototype,"_limits",void 0),t6([nt],ij.prototype,"_onMotorChanged",null),t6([nt],ij.prototype,"_onLimitsChanged",null),t6([nt],ij.prototype,"_onAxisChanged",null);var iY=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._minDistance=0,t._maxDistance=0,t._tolerance=.25,t._stiffness=0,t._damping=0,t}t5(t,e);var n=t.prototype;return n._createJoint=function(){var e=this._colliderInfo;e.collider=this.entity.getComponent(iC),this._nativeJoint=oK._nativePhysics.createSpringJoint(e.collider._nativeCollider)},n._syncNative=function(){e.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)},t4(t,[{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)}}}]),t}(iG),iK=/*#__PURE__*/function(){function e(){this._updateFlagManager=new n4,this._max=0,this._min=0,this._contactDistance=-1,this._stiffness=0,this._damping=0}return t4(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}();t6([ni],iK.prototype,"_updateFlagManager",void 0);var iQ=/*#__PURE__*/function(){function e(){this._updateFlagManager=new n4,this._targetVelocity=0,this._forceLimit=Number.MAX_VALUE,this._gearRatio=1,this._freeSpin=!1}return t4(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}();t6([ni],iQ.prototype,"_updateFlagManager",void 0);var iq=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._size=new tU(1,1,1),t._nativeShape=oK._nativePhysics.createBoxColliderShape(t._id,t._size,t._material._nativeMaterial),t._size._onValueChanged=t._setSize.bind(t),t}t5(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)},t4(t,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),t}(iw);t6([ni],iq.prototype,"_size",void 0),t6([nt],iq.prototype,"_setSize",null);var iZ=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._nativeShape=oK._nativePhysics.createSphereColliderShape(t._id,t._radius,t._material._nativeMaterial),t}return t5(t,e),t.prototype._syncNative=function(){e.prototype._syncNative.call(this),this._nativeShape.setRadius(this._radius)},t4(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),t}(iw),iJ=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._nativeShape=oK._nativePhysics.createPlaneColliderShape(t._id,t._material._nativeMaterial),t}return t5(t,e),t.prototype.getClosestPoint=function(e,t){return console.error("PlaneColliderShape is not support getClosestPoint"),-1},t}(iw),i$=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._height=2,t._upAxis=iU.Y,t._nativeShape=oK._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t}return t5(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)},t4(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}(iw),i0=/*#__PURE__*/function(){function e(e){this.scene=e,this._postProcessNeedSorting=!1,this._postProcessPassNeedSorting=!1,this._activePostProcesses=[],this._blendEffectMap=new Map,this._defaultEffectMap=new Map,this._remainActivePassCount=0}var t=e.prototype;return t._isValid=function(){var e=this.scene;return e.engine._getActivePostProcessPasses().some(function(t){return t.isValid(e.postProcessManager)})},t._update=function(t){this._resetDefaultValue(),this._sortActivePostProcess();for(var n=this._activePostProcesses,r=0,i=n.length;r<i;r++){var a=n[r];if(t.postProcessMask&a.layer){var o=a.isGlobal,s=1;if(!o){var l=e._tempColliders,c=t.entity.transform.worldPosition,u=a.blendDistance,d=!1,h=Number.POSITIVE_INFINITY;a.entity.getComponents(iC,l);for(var _=0;_<l.length;_++){var f=l[_];if(f.enabled)for(var p=f.shapes,m=0;m<p.length;m++){var g=p[m];d=!0;var v=g.getClosestPoint(c,e._tempVector3);v<h&&(h=v)}}if(!d){nb.warn('No collider shape found in the entity:"'+a.entity.name+'", the local mode of post process will not take effect.');continue}if(h>u)continue;u>0&&(s=1-h/u)}for(var y=a._effects,x=0;x<y.length;x++){var A=y[x];if(A.enabled){var b=A.constructor,S=this._blendEffectMap.get(b);S||(S=new b,this._blendEffectMap.set(b,S)),S._lerp(A,s),S.enabled=!0}}}}},t._addPostProcess=function(e){this._activePostProcesses.push(e),this._postProcessNeedSorting=!0},t._removePostProcess=function(e){var t=this._activePostProcesses.indexOf(e);t>=0&&(this._activePostProcesses.splice(t,1),this._postProcessNeedSorting=!0)},t.getBlendEffect=function(e){return this._blendEffectMap.get(e)},t._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()},t._releaseSwapRenderTarget=function(){var e=this._swapRenderTarget;e&&(this.scene.engine._renderTargetPool.freeRenderTarget(e),this._swapRenderTarget=null)},t._releaseOutputRenderTarget=function(){var e=this._outputRenderTarget;e&&(this.scene.engine._renderTargetPool.freeRenderTarget(e),this._outputRenderTarget=null)},t._getOutputRenderTarget=function(e){var t=e.pixelViewport;return this._outputRenderTarget=ie.recreateRenderTargetIfNeeded(e.engine,this._outputRenderTarget,t.width,t.height,e._getTargetColorTextureFormat(),null,!1,!1,!e._isTargetFormatHDR(),1,np.Clamp,nh.Bilinear),this._outputRenderTarget},t._sortActivePostProcess=function(){if(this._postProcessNeedSorting){var e=this._activePostProcesses;e.length&&e.sort(function(e,t){return e.priority-t.priority}),this._postProcessNeedSorting=!1}},t._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})},t._initSwapRenderTarget=function(e){if(this._remainActivePassCount>1){var t=e.pixelViewport,n=ie.recreateRenderTargetIfNeeded(this.scene.engine,this._swapRenderTarget,t.width,t.height,e._getInternalColorTextureFormat(),n_.Depth24Stencil8,!1,!1,!e.enableHDR,1,np.Clamp,nh.Bilinear);this._swapRenderTarget=n,this._currentDestRenderTarget=this._swapRenderTarget}else this._currentDestRenderTarget=this._destRenderTarget;this._currentSourceRenderTarget=this._srcRenderTarget},t._swapRT=function(){var e=this._currentSourceRenderTarget,t=this._currentDestRenderTarget;this._currentSourceRenderTarget=t,this._remainActivePassCount>1?this._currentDestRenderTarget=e:this._currentDestRenderTarget=this._destRenderTarget},t._getCurrentSourceTexture=function(){return this._currentSourceRenderTarget.getColorTexture(0)},e}();i0._tempColliders=[],i0._tempVector3=new tU;var i1=((eh={})[eh.BeforeUber=0]="BeforeUber",eh[eh.AfterUber=100]="AfterUber",eh),i2=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._event=100,t._isActive=!0,t}t5(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)},t4(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}(no),i3=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._mipDownRT=[],r._mipUpRT=[],r.event=i1.AfterUber-1;var r,i=new r3(n,rM.find(t.UBER_SHADER_NAME)),a=i.renderState.depthState;a.enabled=!1,a.writeEnabled=!1,r._uberMaterial=i;var o=new r3(n,rM.find(iy.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(iy._bloomParams,new tZ),l.setVector4(iy._lowMipTexelSizeProp,new tZ),c.setVector4(iy._bloomIntensityParams,new tZ),c.setVector4(iy._dirtTilingOffsetProp,new tZ),c.setColor(iy._tintProp,new tJ),r}t5(t,e);var n=t.prototype;return n.isValid=function(e){if(!this.isActive)return!1;var t=e.getBlendEffect(iy),n=e.getBlendEffect(iA);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(iy),o=r.getBlendEffect(iA);(null==a?void 0:a.isValid())?(this._setupBloom(a,e,t),i.enableMacro(iy._enableMacro)):(i.disableMacro(iy._enableMacro),this._releaseBloomRenderTargets()),(null==o?void 0:o.isValid())?(i.enableMacro("TONEMAPPING_MODE",o.mode.value.toString()),i.enableMacro(iA._enableMacro)):i.disableMacro(iA._enableMacro);var s=n===e.renderTarget?e.viewport:void 0;it.blitTexture(e.engine,t,n,0,s,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=l.value,m=.5*p,g=a.getVector4(iy._bloomParams),v=tk.lerp(.05,.95,c.value);g.x=p,g.y=m,g.z=v;var y=o.getVector4(iy._bloomIntensityParams);y.x=u.value,y.y=f.value,o.getColor(iy._tintProp).copyFrom(d.value),h.value?(a.enableMacro(iy._hqMacro),o.enableMacro(iy._hqMacro)):(a.disableMacro(iy._hqMacro),o.disableMacro(iy._hqMacro)),o.setTexture(iy._dirtTextureProp,_.value),_.value?o.enableMacro(iy._dirtMacro):o.disableMacro(iy._dirtMacro);for(var x=s.value===iv.Half?1:2,A=t.pixelViewport,b=A.width>>x,S=A.height>>x,C=Math.min(Math.max(Math.floor(Math.log2(Math.max(b,S))-1),1),iy._maxIterations),T=t._getInternalColorTextureFormat(),R=b,E=S,M=0;M<C;M++)this._mipUpRT[M]=ie.recreateRenderTargetIfNeeded(r,this._mipUpRT[M],R,E,T,null,!1,!1,!t.enableHDR,1,np.Clamp,nh.Bilinear),this._mipDownRT[M]=ie.recreateRenderTargetIfNeeded(r,this._mipDownRT[M],R,E,T,null,!1,!1,!t.enableHDR,1,np.Clamp,nh.Bilinear),R=Math.max(1,Math.floor(R/2)),E=Math.max(1,Math.floor(E/2));it.blitTexture(r,n,this._mipDownRT[0],void 0,void 0,i,0);for(var P=this._mipDownRT[0],w=1;w<C;w++)it.blitTexture(r,P.getColorTexture(0),this._mipUpRT[w],void 0,void 0,i,1),it.blitTexture(r,this._mipUpRT[w].getColorTexture(0),this._mipDownRT[w],void 0,void 0,i,2),P=this._mipDownRT[w];for(var F=C-2;F>=0;F--){var L=F==C-2?this._mipDownRT[F+1]:this._mipUpRT[F+1],D=this._mipDownRT[F],B=this._mipUpRT[F];a.setTexture(iy._lowMipTextureProp,L.getColorTexture(0)),h&&a.getVector4(iy._lowMipTexelSizeProp).set(1/L.width,1/L.height,L.width,L.height),it.blitTexture(r,D.getColorTexture(0),B,void 0,void 0,i,3)}if(_.value){var I=o.getVector4(iy._dirtTilingOffsetProp),N=_.value.width/_.value.height,O=t.aspectRatio;N>O?I.set(O/N,1,(1-I.x)*.5,0):N<O?I.set(1,N/O,0,(1-I.y)*.5):I.set(1,1,0,0)}o.setTexture(iy._bloomTextureProp,this._mipUpRT[0].getColorTexture(0))},n._releaseBloomRenderTargets=function(){for(var e=this.engine._renderTargetPool,t=this._mipDownRT.length,n=0;n<t;n++){var r=this._mipDownRT[n],i=this._mipUpRT[n];r&&e.freeRenderTarget(r),i&&e.freeRenderTarget(i)}this._mipDownRT.length=0,this._mipUpRT.length=0},t}(i2);i3.UBER_SHADER_NAME="UberPost",Object.assign(r_,{PostCommon:"#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\n#endif",Filtering:"#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\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 * texture2DSRGB(tex, (ic + vec2(offsets[0].x, offsets[0].y) - 0.5) * texSize.xy) +\n weights[1].x * texture2DSRGB(tex, (ic + vec2(offsets[1].x, offsets[0].y) - 0.5) * texSize.xy)) +\n weights[1].y * (weights[0].x * texture2DSRGB(tex, (ic + vec2(offsets[0].x, offsets[1].y) - 0.5) * texSize.xy) +\n weights[1].x * texture2DSRGB(tex, (ic + vec2(offsets[1].x, offsets[1].y) - 0.5) * texSize.xy));\n}\n\n\n#endif",ODT:'#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:'#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\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\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:" #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\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\n#endif",ColorTransform:"#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\n\n#endif",NeutralTonemapping:"// 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:"#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}"}),rM.create(i3.UBER_SHADER_NAME,ii,"#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\n\nvoid main(){\n mediump vec4 color = texture2DSRGB(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 = texture2DSRGB(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 = texture2DSRGB(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}");var i4=/*#__PURE__*/function(e){function t(t){n=e.call(this,t)||this;var n,r=new r3(t,rM.find("FinalSRGB")),i=r.renderState.depthState;i.enabled=!1,i.writeEnabled=!1,r._addReferCount(1),n._sRGBmaterial=r;var a=new r3(t,rM.find("FinalAntiAliasing")),o=a.renderState.depthState;return o.enabled=!1,o.writeEnabled=!1,a._addReferCount(1),n._antiAliasingMaterial=a,n}t5(t,e);var n=t.prototype;return n.onConfig=function(e,t){if(this._inputRenderTarget=t,e.antiAliasing===rX.FXAA){var n=e.pixelViewport;this._srgbRenderTarget=ie.recreateRenderTargetIfNeeded(this.engine,this._srgbRenderTarget,n.width,n.height,n_.R8G8B8A8,null,!1,!1,!1,1,np.Clamp,nh.Bilinear)}},n.onRender=function(e){var t=this.engine,n=e.camera,r=n.viewport,i=n.renderTarget,a=n.antiAliasing===rX.FXAA,o=this._inputRenderTarget.getColorTexture();if(a){it.blitTexture(t,o,this._srgbRenderTarget,0,void 0,this._sRGBmaterial);var s=this._srgbRenderTarget.getColorTexture();it.blitTexture(t,s,i,0,r,this._antiAliasingMaterial)}else it.blitTexture(t,o,i,0,r,this._sRGBmaterial)},n.release=function(){var e=this._srgbRenderTarget;e&&(this.engine._renderTargetPool.freeRenderTarget(e),this._srgbRenderTarget=null),this._inputRenderTarget=null},t}(ir);Object.assign(r_,{FXAA3_11:"//----------------------------------------------------------------------------------\n// This file was obatined from: https://github.com/hghdev/NVIDIAGameWorks-GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h\n// NVIDIA paper: https://www.iryoku.com/aacourse/downloads/09-FXAA-3.11-in-15-Slides.pdf\n// Modifications to this file done by Galacean:\n// * Deleted HLSL-related macros\n// * Deleted the macros and function except for 'FXAA_PC == 1' \n// * Deleted the useless parameters in 'FxaaPixelShader' \n// * Webgl does not compile the double underline, so we remove the double underline for macros\n// * Changed the 'FXAA_GREEN_AS_LUMA == 0' code-path to compute luminance since we don't precompute luminance into the alpha channel\n// * Change the alpha value of the `ret` finally returned by the function from brightness to transparency when `FXAA_DISCARD == 1` code path\n//----------------------------------------------------------------------------------\n\n//----------------------------------------------------------------------------------\n// File: es3-kepler\\FXAA/FXAA3_11.h\n// SDK Version: v3.00\n// Email: gameworks@nvidia.com\n// Site: http://developer.nvidia.com/\n//\n// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions\n// are met:\n// * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// * Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n// * Neither the name of NVIDIA CORPORATION nor the names of its\n// contributors may be used to endorse or promote products derived\n// from this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY\n// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n//----------------------------------------------------------------------------------\n/*============================================================================\n\n\n NVIDIA FXAA 3.11 by TIMOTHY LOTTES\n\n------------------------------------------------------------------------------\n INTEGRATION CHECKLIST\n------------------------------------------------------------------------------\n(1.)\nIn the shader source, setup defines for the desired configuration.\nWhen providing multiple shaders (for different presets),\nsimply setup the defines differently in multiple files.\nExample,\n\n #define FXAA_PC 1\n #define FXAA_HLSL_5 1\n #define FXAA_QUALITY_PRESET 12\n\nOr,\n\n #define FXAA_360 1\n\nOr,\n\n #define FXAA_PS3 1\n\nEtc.\n\n(2.)\nThen include this file,\n\n #include \"Fxaa3_11.h\"\n\n(3.)\nThen call the FXAA pixel shader from within your desired shader.\nLook at the FXAA Quality FxaaPixelShader() for docs on inputs.\nAs for FXAA 3.11 all inputs for all shaders are the same\nto enable easy porting between platforms.\n\n return FxaaPixelShader(...);\n\n(4.)\nInsure pass prior to FXAA outputs RGBL (see next section).\nOr use,\n\n #define FXAA_GREEN_AS_LUMA 1\n\n(5.)\nSetup engine to provide the following constants\nwhich are used in the FxaaPixelShader() inputs,\n\n FxaaFloat2 fxaaQualityRcpFrame,\n FxaaFloat4 fxaaConsoleRcpFrameOpt,\n FxaaFloat4 fxaaConsoleRcpFrameOpt2,\n FxaaFloat4 fxaaConsole360RcpFrameOpt2,\n FxaaFloat fxaaQualitySubpix,\n FxaaFloat fxaaQualityEdgeThreshold,\n FxaaFloat fxaaQualityEdgeThresholdMin,\n FxaaFloat fxaaConsoleEdgeSharpness,\n FxaaFloat fxaaConsoleEdgeThreshold,\n FxaaFloat fxaaConsoleEdgeThresholdMin,\n FxaaFloat4 fxaaConsole360ConstDir\n\nLook at the FXAA Quality FxaaPixelShader() for docs on inputs.\n\n(6.)\nHave FXAA vertex shader run as a full screen triangle,\nand output \"pos\" and \"fxaaConsolePosPos\"\nsuch that inputs in the pixel shader provide,\n\n // {xy} = center of pixel\n FxaaFloat2 pos,\n\n // {xy_} = upper left of pixel\n // {_zw} = lower right of pixel\n FxaaFloat4 fxaaConsolePosPos,\n\n(7.)\nInsure the texture sampler(s) used by FXAA are set to bilinear filtering.\n\n\n------------------------------------------------------------------------------\n INTEGRATION - RGBL AND COLORSPACE\n------------------------------------------------------------------------------\nFXAA3 requires RGBL as input unless the following is set,\n\n #define FXAA_GREEN_AS_LUMA 1\n\nIn which case the engine uses green in place of luma,\nand requires RGB input is in a non-linear colorspace.\n\nRGB should be LDR (low dynamic range).\nSpecifically do FXAA after tonemapping.\n\nRGB data as returned by a texture fetch can be non-linear,\nor linear when FXAA_GREEN_AS_LUMA is not set.\nNote an \"sRGB format\" texture counts as linear,\nbecause the result of a texture fetch is linear data.\nRegular \"RGBA8\" textures in the sRGB colorspace are non-linear.\n\nIf FXAA_GREEN_AS_LUMA is not set,\nluma must be stored in the alpha channel prior to running FXAA.\nThis luma should be in a perceptual space (could be gamma 2.0).\nExample pass before FXAA where output is gamma 2.0 encoded,\n\n color.rgb = ToneMap(color.rgb); // linear color output\n color.rgb = sqrt(color.rgb); // gamma 2.0 color output\n return color;\n\nTo use FXAA,\n\n color.rgb = ToneMap(color.rgb); // linear color output\n color.rgb = sqrt(color.rgb); // gamma 2.0 color output\n color.a = dot(color.rgb, FxaaFloat3(0.299, 0.587, 0.114)); // compute luma\n return color;\n\nAnother example where output is linear encoded,\nsay for instance writing to an sRGB formated render target,\nwhere the render target does the conversion back to sRGB after blending,\n\n color.rgb = ToneMap(color.rgb); // linear color output\n return color;\n\nTo use FXAA,\n\n color.rgb = ToneMap(color.rgb); // linear color output\n color.a = sqrt(dot(color.rgb, FxaaFloat3(0.299, 0.587, 0.114))); // compute luma\n return color;\n\nGetting luma correct is required for the algorithm to work correctly.\n\n\n------------------------------------------------------------------------------\n BEING LINEARLY CORRECT?\n------------------------------------------------------------------------------\nApplying FXAA to a framebuffer with linear RGB color will look worse.\nThis is very counter intuitive, but happends to be true in this case.\nThe reason is because dithering artifacts will be more visiable\nin a linear colorspace.\n\n\n------------------------------------------------------------------------------\n COMPLEX INTEGRATION\n------------------------------------------------------------------------------\nQ. What if the engine is blending into RGB before wanting to run FXAA?\n\nA. In the last opaque pass prior to FXAA,\n have the pass write out luma into alpha.\n Then blend into RGB only.\n FXAA should be able to run ok\n assuming the blending pass did not any add aliasing.\n This should be the common case for particles and common blending passes.\n\nA. Or use FXAA_GREEN_AS_LUMA.\n\n============================================================================*/\n\n/*============================================================================\n\n INTEGRATION KNOBS\n\n============================================================================*/\n/*==========================================================================*/\n#ifndef FXAA_PC\n //\n // FXAA Quality\n // The high quality PC algorithm.\n //\n #define FXAA_PC 0\n#endif\n/*--------------------------------------------------------------------------*/\n#ifndef FXAA_GLSL_120\n #define FXAA_GLSL_120 0\n#endif\n/*--------------------------------------------------------------------------*/\n#ifndef FXAA_GLSL_130\n #define FXAA_GLSL_130 0\n#endif\n/*--------------------------------------------------------------------------*/\n/*==========================================================================*/\n#ifndef FXAA_GREEN_AS_LUMA\n //\n // For those using non-linear color,\n // and either not able to get luma in alpha, or not wanting to,\n // this enables FXAA to run using green as a proxy for luma.\n // So with this enabled, no need to pack luma in alpha.\n //\n // This will turn off AA on anything which lacks some amount of green.\n // Pure red and blue or combination of only R and B, will get no AA.\n //\n // Might want to lower the settings for both,\n // fxaaConsoleEdgeThresholdMin\n // fxaaQualityEdgeThresholdMin\n // In order to insure AA does not get turned off on colors \n // which contain a minor amount of green.\n //\n // 1 = On.\n // 0 = Off.\n //\n #define FXAA_GREEN_AS_LUMA 0\n#endif\n/*--------------------------------------------------------------------------*/\n#ifndef FXAA_EARLY_EXIT\n //\n // Controls algorithm's early exit path.\n // On PS3 turning this ON adds 2 cycles to the shader.\n // On 360 turning this OFF adds 10ths of a millisecond to the shader.\n // Turning this off on console will result in a more blurry image.\n // So this defaults to on.\n //\n // 1 = On.\n // 0 = Off.\n //\n #define FXAA_EARLY_EXIT 1\n#endif\n/*--------------------------------------------------------------------------*/\n#ifndef FXAA_DISCARD\n //\n // Only valid for PC OpenGL currently.\n // Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n //\n // 1 = Use discard on pixels which don't need AA.\n // For APIs which enable concurrent TEX+ROP from same surface.\n // 0 = Return unchanged color on pixels which don't need AA.\n //\n #define FXAA_DISCARD 0\n#endif\n/*--------------------------------------------------------------------------*/\n#ifndef FXAA_FAST_PIXEL_OFFSET\n //\n // Used for GLSL 120 only.\n //\n // 1 = GL API supports fast pixel offsets\n // 0 = do not use fast pixel offsets\n //\n #ifdef GL_EXT_gpu_shader4\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifndef FXAA_FAST_PIXEL_OFFSET\n #define FXAA_FAST_PIXEL_OFFSET 0\n #endif\n#endif\n/*--------------------------------------------------------------------------*/\n#ifndef FXAA_GATHER4_ALPHA\n //\n // 1 = API supports gather4 on alpha channel.\n // 0 = API does not support gather4 on alpha channel.\n //\n #ifdef gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifndef FXAA_GATHER4_ALPHA\n #define FXAA_GATHER4_ALPHA 0\n #endif\n#endif\n\n/*============================================================================\n FXAA QUALITY - TUNING KNOBS\n------------------------------------------------------------------------------\nNOTE the other tuning knobs are now in the shader function inputs!\n============================================================================*/\n#ifndef FXAA_QUALITY_PRESET\n //\n // Choose the quality preset.\n // This needs to be compiled into the shader as it affects code.\n // Best option to include multiple presets is to \n // in each shader define the preset, then include this file.\n // \n // OPTIONS\n // -----------------------------------------------------------------------\n // 10 to 15 - default medium dither (10=fastest, 15=highest quality)\n // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)\n // 39 - no dither, very expensive \n //\n // NOTES\n // -----------------------------------------------------------------------\n // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)\n // 13 = about same speed as FXAA 3.9 and better than 12\n // 23 = closest to FXAA 3.9 visually and performance wise\n // _ = the lowest digit is directly related to performance\n // _ = the highest digit is directly related to style\n // \n #define FXAA_QUALITY_PRESET 12\n#endif\n\n/*============================================================================\n\n FXAA QUALITY - PRESETS\n\n============================================================================*/\n\n/*============================================================================\n FXAA QUALITY - MEDIUM DITHER PRESETS\n============================================================================*/\n#if (FXAA_QUALITY_PRESET == 10)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 3.0\n #define FXAA_QUALITY_P2 12.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 11)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 3.0\n #define FXAA_QUALITY_P3 12.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 12)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 4.0\n #define FXAA_QUALITY_P4 12.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 13)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 4.0\n #define FXAA_QUALITY_P5 12.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 14)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 4.0\n #define FXAA_QUALITY_P6 12.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 15)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 12.0\n#endif\n\n/*============================================================================\n FXAA QUALITY - LOW DITHER PRESETS\n============================================================================*/\n#if (FXAA_QUALITY_PRESET == 20)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 2.0\n #define FXAA_QUALITY_P2 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 21)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 22)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 23)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 24)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 3.0\n #define FXAA_QUALITY_P6 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 25)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 26)\n #define FXAA_QUALITY_PS 9\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 4.0\n #define FXAA_QUALITY_P8 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 27)\n #define FXAA_QUALITY_PS 10\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 4.0\n #define FXAA_QUALITY_P9 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 28)\n #define FXAA_QUALITY_PS 11\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 4.0\n #define FXAA_QUALITY_P10 8.0\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_QUALITY_PRESET == 29)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n\n/*============================================================================\n FXAA QUALITY - EXTREME QUALITY\n============================================================================*/\n#if (FXAA_QUALITY_PRESET == 39)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.0\n #define FXAA_QUALITY_P2 1.0\n #define FXAA_QUALITY_P3 1.0\n #define FXAA_QUALITY_P4 1.0\n #define FXAA_QUALITY_P5 1.5\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n\n\n/*============================================================================\n\n API PORTING\n\n============================================================================*/\n#if (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)\n #define FxaaBool bool\n #define FxaaDiscard discard\n #define FxaaFloat float\n #define FxaaFloat2 vec2\n #define FxaaFloat3 vec3\n #define FxaaFloat4 vec4\n #define FxaaHalf float\n #define FxaaHalf2 vec2\n #define FxaaHalf3 vec3\n #define FxaaHalf4 vec4\n #define FxaaInt2 ivec2\n #define FxaaSat(x) clamp(x, 0.0, 1.0)\n #define FxaaTex sampler2D\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_GLSL_120 == 1)\n // Requires,\n // #version 120\n // And at least,\n // #extension GL_EXT_gpu_shader4 : enable\n // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)\n #define FxaaTexTop(t, p) texture2DLodEXT(t, p, 0.0)\n #if (FXAA_FAST_PIXEL_OFFSET == 1)\n #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n #else\n #define FxaaTexOff(t, p, o, r) texture2DLodEXT(t, p + (o * r), 0.0)\n #endif\n #if (FXAA_GATHER4_ALPHA == 1)\n // use #extension gpu_shader5 : enable\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n#endif\n/*--------------------------------------------------------------------------*/\n#if (FXAA_GLSL_130 == 1)\n // Requires \"#version 130\" or better\n #define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n #if (FXAA_GATHER4_ALPHA == 1)\n // use #extension gpu_shader5 : enable\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n#endif\n/*--------------------------------------------------------------------------*/\n\n\n/*============================================================================\n GREEN AS LUMA OPTION SUPPORT FUNCTION\n============================================================================*/\n#if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return dot(rgba.xyz, FxaaFloat3(0.299, 0.587, 0.114));}\n#else\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n#endif \n\n\n/*============================================================================\n\n FXAA3 QUALITY - PC\n\n============================================================================*/\n#if (FXAA_PC == 1)\n/*--------------------------------------------------------------------------*/\nFxaaFloat4 FxaaPixelShader(\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy} = center of pixel\n FxaaFloat2 pos,\n //\n // Reuse the center sample as it's already available\n // {rgb_} = the color of the center pixel (alpha won't be used)\n FxaaFloat4 rgbyM,\n //\n // Input color texture.\n // {rgb_} = color in linear or perceptual color space\n // if (FXAA_GREEN_AS_LUMA == 0)\n // {__a} = luma in perceptual color space (not linear)\n FxaaTex tex,\n //\n // Only used on FXAA Quality.\n // This must be from a constant/uniform.\n // {x_} = 1.0/screenWidthInPixels\n // {_y} = 1.0/screenHeightInPixels\n FxaaFloat2 fxaaQualityRcpFrame,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_SUBPIX define.\n // It is here now to allow easier tuning.\n // Choose the amount of sub-pixel aliasing removal.\n // This can effect sharpness.\n // 1.00 - upper limit (softer)\n // 0.75 - default amount of filtering\n // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)\n // 0.25 - almost off\n // 0.00 - completely off\n FxaaFloat fxaaQualitySubpix,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.\n // It is here now to allow easier tuning.\n // The minimum amount of local contrast required to apply algorithm.\n // 0.333 - too little (faster)\n // 0.250 - low quality\n // 0.166 - default\n // 0.125 - high quality\n // 0.063 - overkill (slower)\n FxaaFloat fxaaQualityEdgeThreshold,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.\n // It is here now to allow easier tuning.\n // Trims the algorithm from processing darks.\n // 0.0833 - upper limit (default, the start of visible unfiltered edges)\n // 0.0625 - high quality (faster)\n // 0.0312 - visible limit (slower)\n // Special notes when using FXAA_GREEN_AS_LUMA,\n // Likely want to set this to zero.\n // As colors that are mostly not-green\n // will appear very dark in the green channel!\n // Tune by looking at mostly non-green content,\n // then start at zero and increase until aliasing is a problem.\n FxaaFloat fxaaQualityEdgeThresholdMin\n) {\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n #if (FXAA_GATHER4_ALPHA == 1)\n #if (FXAA_DISCARD == 0)\n FxaaFloat lumaM = FxaaLuma(rgbyM);\n #endif\n #if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n #else\n FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));\n #endif\n #if (FXAA_DISCARD == 1)\n FxaaFloat lumaM = luma4A.w;\n #endif\n #define lumaE luma4A.z\n #define lumaS luma4A.x\n #define lumaSE luma4A.y\n #define lumaNW luma4B.w\n #define lumaN luma4B.z\n #define lumaW luma4B.x\n #else\n FxaaFloat lumaM = FxaaLuma(rgbyM);\n FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n #endif\n/*--------------------------------------------------------------------------*/\n FxaaFloat maxSM = max(lumaS, lumaM);\n FxaaFloat minSM = min(lumaS, lumaM);\n FxaaFloat maxESM = max(lumaE, maxSM);\n FxaaFloat minESM = min(lumaE, minSM);\n FxaaFloat maxWN = max(lumaN, lumaW);\n FxaaFloat minWN = min(lumaN, lumaW);\n FxaaFloat rangeMax = max(maxWN, maxESM);\n FxaaFloat rangeMin = min(minWN, minESM);\n FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n FxaaFloat range = rangeMax - rangeMin;\n FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n FxaaBool earlyExit = range < rangeMaxClamped;\n/*--------------------------------------------------------------------------*/\n if(earlyExit)\n #if (FXAA_DISCARD == 1)\n FxaaDiscard;\n #else\n return rgbyM;\n #endif\n/*--------------------------------------------------------------------------*/\n #if (FXAA_GATHER4_ALPHA == 0)\n FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n #else\n FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n #endif\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNS = lumaN + lumaS;\n FxaaFloat lumaWE = lumaW + lumaE;\n FxaaFloat subpixRcpRange = 1.0/range;\n FxaaFloat subpixNSWE = lumaNS + lumaWE;\n FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNESE = lumaNE + lumaSE;\n FxaaFloat lumaNWNE = lumaNW + lumaNE;\n FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNWSW = lumaNW + lumaSW;\n FxaaFloat lumaSWSE = lumaSW + lumaSE;\n FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n/*--------------------------------------------------------------------------*/\n FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n FxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n FxaaBool horzSpan = edgeHorz >= edgeVert;\n FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n/*--------------------------------------------------------------------------*/\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat gradientN = lumaN - lumaM;\n FxaaFloat gradientS = lumaS - lumaM;\n FxaaFloat lumaNN = lumaN + lumaM;\n FxaaFloat lumaSS = lumaS + lumaM;\n FxaaBool pairN = abs(gradientN) >= abs(gradientS);\n FxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n FxaaFloat2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posN;\n posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n FxaaFloat2 posP;\n posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));\n FxaaFloat subpixE = subpixC * subpixC;\n FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));\n/*--------------------------------------------------------------------------*/\n if(!pairN) lumaNN = lumaSS;\n FxaaFloat gradientScaled = gradient * 1.0/4.0;\n FxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n FxaaFloat subpixF = subpixD * subpixE;\n FxaaBool lumaMLTZero = lumaMM < 0.0;\n/*--------------------------------------------------------------------------*/\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n FxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n FxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n FxaaBool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n/*--------------------------------------------------------------------------*/\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 3)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 4)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 5)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 6)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 7)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 8)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 9)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 10)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 11)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 12)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n/*--------------------------------------------------------------------------*/\n FxaaFloat dstN = posM.x - posN.x;\n FxaaFloat dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n/*--------------------------------------------------------------------------*/\n FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n FxaaFloat spanLength = (dstP + dstN);\n FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n FxaaFloat spanLengthRcp = 1.0/spanLength;\n/*--------------------------------------------------------------------------*/\n FxaaBool directionN = dstN < dstP;\n FxaaFloat dst = min(dstN, dstP);\n FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n FxaaFloat subpixG = subpixF * subpixF;\n FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n FxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n/*--------------------------------------------------------------------------*/\n FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n\n #if (FXAA_DISCARD == 1)\n return FxaaTexTop(tex, posM);\n #else\n return FxaaTexTop(tex, posM);\n #endif\n}\n/*==========================================================================*/\n#endif"}),rM.create("FinalSRGB",ii,"#include <common>\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\n\nvoid main(){\n mediump vec4 color = texture2DSRGB(renderer_BlitTexture, v_uv);\n\n // This is final output, maybe has alpha\n // If we use premultiplied color to convert to sRGB. Since we ignored the background color, the greater the transparency, the greater the final composite color\n // But the actual transparent canvas can be composited with any color of the browser background\n\n // So we assume non-transparent SRGB conversion. Then use the Alpha value and the background canvas to do SRGB blending \n // Although it is non-linear blending, it is more scientific\n color.rgb = color.rgb / color.a;\n color = linearToSRGB(color);\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"),rM.create("FinalAntiAliasing",ii,"#define FXAA_PC 1\n#define FXAA_QUALITY_PRESET 12\n#define FXAA_GREEN_AS_LUMA 0\n#if defined(GRAPHICS_API_WEBGL2)\n #define FXAA_GLSL_130 1\n#elif defined(GRAPHICS_API_WEBGL1)\n #define FXAA_GLSL_120 1\n#endif\n\n#include <common>\n#include <FXAA3_11>\n\nconst FxaaFloat FXAA_SUBPIXEL_BLEND_AMOUNT = 0.75;\nconst FxaaFloat FXAA_RELATIVE_CONTRAST_THRESHOLD = 0.166;\nconst FxaaFloat FXAA_ABSOLUTE_CONTRAST_THRESHOLD = 0.0833;\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvec4 applyFXAA(vec4 color, vec2 positionNDC, vec4 sourceSize, sampler2D blitTexture)\n{\n return FxaaPixelShader(\n positionNDC,\n color,\n blitTexture,\n sourceSize.xy,\n FXAA_SUBPIXEL_BLEND_AMOUNT,\n FXAA_RELATIVE_CONTRAST_THRESHOLD,\n FXAA_ABSOLUTE_CONTRAST_THRESHOLD\n );\n}\n\nvoid main(){\n mediump vec4 color = texture2D(renderer_BlitTexture, v_uv);\n\n color = applyFXAA(color, v_uv, renderer_texelSize, renderer_BlitTexture);\n\n // We have convert the color to sRGB space in sRGB pass\n // So we need to convert it back to linear space when output to render target.\n #ifndef ENGINE_OUTPUT_SRGB_CORRECT\n color.rgb /= color.a;\n color = sRGBToLinear(color);\n color.rgb *= color.a;\n #endif\n\n gl_FragColor = color;\n}");var i8=((e_={})[e_.No=0]="No",e_[e_.Increment=1]="Increment",e_[e_.Decrement=2]="Decrement",e_),i5=/*#__PURE__*/function(){function e(e){this.renderQueueType=e,this.elements=[],this.batchedSubElements=[],this.rendererUpdateFlag=rF.None}var t=e.prototype;return t.pushRenderElement=function(e){this.elements.push(e)},t.sortBatch=function(e,t){nX._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=i8.No);var r=this.batchedSubElements,i=r.length;if(0!==i){for(var a=e.camera,o=a.engine,s=a.scene,l=a.instanceId,c=a.shaderData,u=s.instanceId,d=s.shaderData,h=s._maskManager,_=o._renderCount,f=o._hardwareRenderer,p=rw.pipelineStageKey,m=this.renderQueueType,g=0;g<i;g++){var v=r[g],y=v.component,x=v.batched,A=v.material;this.rendererUpdateFlag&rF.WorldViewMatrix||y._batchedTransformShaderData!=x?(y._updateTransformShaderData(e,!1,x),y._batchedTransformShaderData=x):this.rendererUpdateFlag&rF.ProjectionMatrix&&y._updateTransformShaderData(e,!0,x);var b=y._maskInteraction,S=b!==n0.None,C=n!==i8.No,T=null;C?T=a4.getMaskTypeRenderStates(n):(S?(h.drawMask(e,t,v.component._maskLayer),T=a4.getMaskInteractionRenderStates(b)):h.isReadStencil(A)&&h.clearMask(e,t),h.isStencilWritten(A)&&(h.hasStencilWritten=!0));var R=rM._compileMacros,E=v.primitive,M=v.shaderPasses,P=v.shaderData,w=y.shaderData,F=y.instanceId,L=A.shaderData,D=A.instanceId,B=A.renderStates;ru.unionCollection(y._globalShaderMacro,L._macroCollection,R),ru.unionCollection(R,o._macroCollection,R);for(var I=0,N=M.length;I<N;I++){var O=M[I];if(O.getTagValue(p)===t){var V=O._renderState;if(C)V||(V=B[I]);else if((V?V._getRenderQueueByShaderData(O._renderStateDataMap,L):(V=B[I]).renderQueueType)!==m)continue;var k=O._getShaderProgram(o,R);if(k.isValid){var U=k.bind();_!==k._uploadRenderCount?(k.groupingOtherUniformBlock(),k.uploadAll(k.sceneUniformBlock,d),k.uploadAll(k.cameraUniformBlock,c),k.uploadAll(k.rendererUniformBlock,w),k.uploadAll(k.materialUniformBlock,L),P&&k.uploadAll(k.renderElementUniformBlock,P),k.uploadUnGroupTextures(),k._uploadSceneId=u,k._uploadCameraId=l,k._uploadRendererId=F,k._uploadMaterialId=D,k._uploadRenderCount=_):(k._uploadSceneId!==u?(k.uploadAll(k.sceneUniformBlock,d),k._uploadSceneId=u):U&&k.uploadTextures(k.sceneUniformBlock,d),k._uploadCameraId!==l?(k.uploadAll(k.cameraUniformBlock,c),k._uploadCameraId=l):U&&k.uploadTextures(k.cameraUniformBlock,c),k._uploadRendererId!==F?(k.uploadAll(k.rendererUniformBlock,w),k._uploadRendererId=F):U&&k.uploadTextures(k.rendererUniformBlock,w),k._uploadMaterialId!==D?(k.uploadAll(k.materialUniformBlock,L),k._uploadMaterialId=D):U&&k.uploadTextures(k.materialUniformBlock,L),P&&k.uploadAll(k.renderElementUniformBlock,P),U&&k.uploadUnGroupTextures()),V._applyStates(o,y._isFrontFaceInvert(),O._renderStateDataMap,A.shaderData,T),f.drawPrimitive(E,v.subPrimitive,k)}}}}this.rendererUpdateFlag=rF.None}},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}(),i9=/*#__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===n0.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=af._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}();i9._disableBatchTag=rp.getByName("spriteDisableBatching");var i6=function(){this.virtualCamera=new rW,this.cullPlanes=[new tW(new tU),new tW(new tU),new tW(new tU),new tW(new tU),new tW(new tU),new tW(new tU),new tW(new tU),new tW(new tU),new tW(new tU),new tW(new tU)],this.splitBoundSphere=new tz(new tU,0)},i7=((ef={})[ef.Low=0]="Low",ef[ef.Medium=1]="Medium",ef[ef.High=2]="High",ef[ef.VeryHigh=3]="VeryHigh",ef),ae=((ep={})[ep.None=0]="None",ep[ep.Hard=1]="Hard",ep[ep.SoftLow=2]="SoftLow",ep[ep.SoftHigh=3]="SoftHigh",ep),at=/*#__PURE__*/function(){function e(){}return e.shadowResolution=function(e){switch(e){case i7.Low:return 512;case i7.Medium:return 1024;case i7.High:return 2048;case i7.VeryHigh:return 4096}},e.shadowDepthFormat=function(e,t){return t?n_.Depth16:n_.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(tk.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,tU.scale(r,a,_),tU.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(tN.Near),_=t.getPlane(tN.Far),f=t.getPlane(tN.Left),p=t.getPlane(tN.Right),m=t.getPlane(tN.Bottom),g=t.getPlane(tN.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),tH.intersectionPointThreePlanes(v,m,p,o[7]),tH.intersectionPointThreePlanes(v,g,p,o[6]),tH.intersectionPointThreePlanes(v,g,f,o[5]),tH.intersectionPointThreePlanes(v,m,f,o[4]),tH.intersectionPointThreePlanes(y,m,p,o[3]),tH.intersectionPointThreePlanes(y,g,p,o[2]),tH.intersectionPointThreePlanes(y,g,f,o[1]),tH.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,A=0;A<6;A++){var b=void 0;switch(A){case tN.Near:b=v;break;case tN.Far:b=y;break;default:b=t.getPlane(A)}0>tU.dot(b.normal,i)&&(d[x].copyFrom(b),s[x]=A,x++)}for(var S=x,C=0;C<x;C++)for(var T=s[C],R=l[T],E=0;E<4;E++){for(var M=R[E],P=!0,w=0;w<x;w++)if(M==s[w]){P=!1;break}if(P){var F=c[T][M],L=o[F[0]],D=o[F[1]];tU.add(L,i,u),tW.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(tU.dot(u,t)*p)*m,v=Math.ceil(tU.dot(u,n)*p)*m,y=tU.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,A=x.position,b=x.viewMatrix,S=x.projectionMatrix;tU.scale(r,d+a,A),tU.subtract(u,A,A),tK.lookAt(A,u,t,b),tK.ortho(-_,_,-_,_,0,2*d+a,S);var C=x.viewProjectionMatrix;tK.multiply(S,b,C),nX._floatMatrixMultiply(e._shadowMapCoordMatrix,C.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==ae.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;nX._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}();at._tempMatrix0=new tK,at._shadowMapCoordMatrix=new tK(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),at._frustumCorners=[new tU,new tU,new tU,new tU,new tU,new tU,new tU,new tU],at._adjustNearPlane=new tW(new tU),at._adjustFarPlane=new tW(new tU),at._backPlaneFaces=[,,,,,],at._edgePlanePoint2=new tU,at._frustumPlaneNeighbors=[[tN.Left,tN.Right,tN.Top,tN.Bottom],[tN.Left,tN.Right,tN.Top,tN.Bottom],[tN.Near,tN.Far,tN.Top,tN.Bottom],[tN.Near,tN.Far,tN.Top,tN.Bottom],[tN.Near,tN.Far,tN.Left,tN.Right],[tN.Near,tN.Far,tN.Left,tN.Right]],at._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]]],at.atlasBorderSize=4;var an=((em={})[em.NoCascades=1]="NoCascades",em[em.TwoCascades=2]="TwoCascades",em[em.FourCascades=4]="FourCascades",em),ar=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n.engine)||this)._shadowMapSize=new tZ,r._shadowBias=new tq,r._shadowSliceData=new i6,r._lightUp=new tU,r._lightSide=new tU,r._splitBoundSpheres=new Float32Array(4*t._maxCascades),r._shadowMatrices=new Float32Array((t._maxCascades+1)*16),r._shadowInfos=new tZ,r._viewportOffsets=[new tq,new tq,new tq,new tq],r._camera=n,r._supportDepthTexture=n.engine._hardwareRenderer.canIUse(nT.depthTexture),r._shadowSliceData.virtualCamera.isOrthographic=!0,r}t5(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,A=x.elements,b=this._lightUp,S=this._lightSide,C=l.virtualCamera.forward,T=this._shadowMapSize,R=T.z,E=T.w,M=this._shadowMapFormat;i=this._supportDepthTexture?(r=ie.recreateRenderTargetIfNeeded(a,this._renderTarget,R,E,null,M,!0,!1,!1,1,np.Clamp,nh.Bilinear)).depthTexture:(r=ie.recreateRenderTargetIfNeeded(a,this._renderTarget,R,E,M,null,!1,!1,!1,1,np.Clamp,nh.Bilinear)).getColorTexture(0),a._hardwareRenderer._isWebGL2&&(i.depthCompareFunction=nd.Less),this._renderTarget=r,this._depthTexture=i,e.setRenderTarget(r,t._viewport,0),this._supportDepthTexture?m.clearRenderTarget(a,rj.Depth,null):m.clearRenderTarget(a,rj.All,t._clearColor),tK.rotationQuaternion(n.entity.transform.worldRotationQuaternion,x),S.set(A[0],A[1],A[2]),b.set(A[4],A[5],A[6]),C.set(-A[8],-A[9],-A[10]);var P=t._tempVector;P.copyFrom(o.entity.transform.worldForward);for(var w=this._shadowTileResolution,F=0;F<g;F++){at.getBoundSphereByFrustum(v[F],v[F+1],o,P,l),at.getDirectionLightShadowCullPlanes(o._frustum,v[F],o.nearClipPlane,C,l),at.getDirectionalLightMatrices(b,S,C,F,n.shadowNearPlaneOffset,w,l,u),g>1&&at.applySliceTransform(w,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,N=I._elements,O=I.length-1;O>=0;--O)at.shadowCullFrustum(e,n,N[O],l);if(h.elements.length||_.elements.length){a._renderCount++;var V=a._batcherManager;h.sortBatch(i5.compareForOpaque,V),_.sortBatch(i5.compareForOpaque,V);var k=s[F],U=k.x,z=k.y;m.setGlobalDepthBias(1,1),m.viewport(U,z,w,w),m.scissor(U+1,z+1,w-2,w-2),h.render(e,rh.ShadowCaster),_.render(e,rh.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(at.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*tk.degreeToRadian(u)),_=1+h*h*(c*c+1);switch(o){case an.NoCascades:n[1]=this._getFarWithRadius(e,_);break;case an.TwoCascades:n[1]=this._getFarWithRadius(l+d*i,_),n[2]=this._getFarWithRadius(e,_);break;case an.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=at.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=at.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==an.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var o=at.getMaxTileResolutionInAtlas(r,r,i);this._shadowTileResolution=o;var s=2*o,l=i==an.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 an.NoCascades:c[0].set(0,0);break;case an.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case an.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;at.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);var o=r.camera._renderPipeline._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue;s.rendererUpdateFlag|=rF.viewProjectionMatrix,l.rendererUpdateFlag|=rF.viewProjectionMatrix,r.applyVirtualCamera(i,!0)},t}(ir);ar._lightShadowBiasProperty=nH.getByName("scene_ShadowBias"),ar._lightDirectionProperty=nH.getByName("scene_LightDirection"),ar._shadowMatricesProperty=nH.getByName("scene_ShadowMatrices"),ar._shadowMapSize=nH.getByName("scene_ShadowMapSize"),ar._shadowInfosProperty=nH.getByName("scene_ShadowInfo"),ar._shadowMapsProperty=nH.getByName("scene_ShadowMap"),ar._shadowSplitSpheresProperty=nH.getByName("scene_ShadowSplitSpheres"),ar._maxCascades=4,ar._cascadesSplitDistance=Array(ar._maxCascades+1),ar._viewport=new tZ(0,0,1,1),ar._clearColor=new tJ(1,1,1,1),ar._tempVector=new tU,ar._tempMatrix0=new tK;var ai=/*#__PURE__*/function(){function e(){this.opaqueQueue=new i5(rr.Opaque),this.transparentQueue=new i5(rr.Transparent),this.alphaTestQueue=new i5(rr.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(i5.compareForOpaque,e),this.alphaTestQueue.sortBatch(i5.compareForOpaque,e),this.transparentQueue.sortBatch(i5.compareForTransparent,e)},t.setRenderUpdateFlagTrue=function(e){this.opaqueQueue.rendererUpdateFlag|=e,this.transparentQueue.rendererUpdateFlag|=e,this.alphaTestQueue.rendererUpdateFlag|=e},t.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},e}(),aa=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).supportDepthTexture=t._hardwareRenderer.canIUse(nT.depthTexture),n}t5(t,e);var n=t.prototype;return n.onConfig=function(e){var t=this.engine,n=e.pixelViewport,r=n.width,i=n.height,a=ie.recreateRenderTargetIfNeeded(t,this.renderTarget,r,i,null,t._hardwareRenderer.isWebGL2?n_.Depth24:n_.Depth24Stencil8,!0,!1,!1,1,np.Clamp,nh.Point);this.renderTarget=a},n.onRender=function(e,t){var n=this.engine,r=this.renderTarget,i=e.camera,a=n._hardwareRenderer;e.setRenderTarget(r,ie.defaultViewport,0),a.clearRenderTarget(n,rj.Depth,null),n._renderCount++,t.opaqueQueue.render(e,rh.DepthOnly),t.alphaTestQueue.render(e,rh.DepthOnly),i.shaderData.setTexture(r0._cameraDepthTextureProperty,this.renderTarget.depthTexture)},n.release=function(){var e=this.renderTarget;e&&(this.engine._renderTargetPool.freeRenderTarget(e),this.renderTarget=null)},t}(ir),ao=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}t5(t,e);var n=t.prototype;return n.onConfig=function(e,t){this._cameraColorTexture=t;var n=e.opaqueTextureDownsampling,r=n===rq.None,i=e.pixelViewport,a=r?1:n===rq.TwoX?.5:.25,o=ie.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,i.width*a,i.height*a,e._getInternalColorTextureFormat(),null,!1,!1,!e.enableHDR,1,np.Clamp,r?nh.Point:nh.Bilinear);this._renderTarget=o},n.onRender=function(e){it.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),e.camera.shaderData.setTexture(r0._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},t}(ir),as=/*#__PURE__*/function(){function e(e){this._lastCanvasSize=new tq,this._internalColorTarget=null,this._canUseBlitFrameBuffer=!1,this._shouldCopyBackgroundColor=!1,this._camera=e;var t=e.engine;this._cullingResults=new ai,this._cascadedShadowCasterPass=new ar(e),this._depthOnlyPass=new aa(t),this._saoPass=new io(t),this._opaqueTexturePass=new ao(t),this._finalPass=new i4(t)}var t=e.prototype;return t.destroy=function(){this._cullingResults.destroy();var e=this._camera.engine._renderTargetPool;this._internalColorTarget&&(e.freeRenderTarget(this._internalColorTarget),this._internalColorTarget=null),this._copyBackgroundTexture&&(e.freeTexture(this._copyBackgroundTexture),this._copyBackgroundTexture=null),this._camera=null},t.render=function(e,t,n,r){this._cullingResults.setRenderUpdateFlagTrue(rF.All);var i=this._camera,a=i.scene,o=i.engine,s=i.renderTarget,l=i._isIndependentCanvasEnabled(),c=o._hardwareRenderer,u=this._cullingResults,d=a._lightManager._sunlight,h=this._depthOnlyPass,_=a.ambientOcclusion._isValid(),f=h.supportDepthTexture,p=(i.depthTextureMode===rQ.PrePass||_)&&f,m=i.clearFlags&~(null!=r?r:rj.None),g=s?s.antiAliasing:i.msaaSamples;this._canUseBlitFrameBuffer=c.isWebGL2&&1===g;var v=!s||s.getColorTexture(0).isSRGBColorSpace;this._shouldCopyBackgroundColor=l&&!(m&rj.Color)&&(!this._canUseBlitFrameBuffer||v),a.castShadows&&d&&d.shadowType!==ae.None&&this._cascadedShadowCasterPass.onRender(e);var y=o._batcherManager;if(u.reset(),this._cullingResults.setRenderUpdateFlagTrue(rF.viewProjectionMatrix),e.applyVirtualCamera(i._virtualCamera,p),this._prepareRender(e),u.sortBatch(y),y.uploadBuffer(),p?(h.onConfig(i),h.onRender(e,u)):(h.release(),i.shaderData.setTexture(r0._cameraDepthTextureProperty,o._basicResources.whiteTexture2D)),l){b=i.renderTarget?i.renderTarget._depthFormat:c._options.depth&&c._options.stencil?n_.Depth24Stencil8:c._options.depth?n_.Depth24:c._options.stencil?n_.Stencil:null;var x=i.pixelViewport,A=ie.recreateRenderTargetIfNeeded(o,this._internalColorTarget,x.width,x.height,i._getInternalColorTextureFormat(),b,!1,!1,!i.enableHDR,g,np.Clamp,nh.Bilinear);if(this._shouldCopyBackgroundColor){var b,S,C,T,R=null==(S=i.renderTarget)?void 0:S.getColorTexture(0),E=ie.recreateTextureIfNeeded(o,this._copyBackgroundTexture,x.width,x.height,null!=(C=null==R?void 0:R.format)?C:n_.R8G8B8A8,!1,null!=(T=null==R?void 0:R.isSRGBColorSpace)&&T,np.Clamp,nh.Bilinear);this._copyBackgroundTexture=E}this._internalColorTarget=A}else{var M=this._internalColorTarget,P=this._copyBackgroundTexture,w=o._renderTargetPool;M&&(w.freeRenderTarget(M),this._internalColorTarget=null),P&&(w.freeTexture(P),this._copyBackgroundTexture=null)}var F=this._saoPass;_&&f&&F.isSupported?(F.onConfig(i,this._depthOnlyPass.renderTarget),F.onRender(e)):this._saoPass.release(),this._drawRenderPass(e,i,m,t,n)},t._drawRenderPass=function(e,t,n,r,i){var a=this._cullingResults,o=a.opaqueQueue,s=a.alphaTestQueue,l=a.transparentQueue,c=t.engine,u=t.scene,d=t.renderTarget,h=u.background,_=c._hardwareRenderer,f=this._internalColorTarget,p=f||t.renderTarget,m=f?ie.defaultViewport:t.viewport,g=!!f||t.renderTarget&&void 0==r;if(e.flipProjection!==g&&(a.setRenderUpdateFlagTrue(rF.ProjectionMatrix),e.applyVirtualCamera(t._virtualCamera,g)),e.setRenderTarget(p,m,i,r),n!==rj.None){var v=rD._premultiplySolidColor,y=h.solidColor,x=y.a;v.set(y.r*x,y.g*x,y.b*x,x),_.clearRenderTarget(c,n,v)}if(f){var A=~n&rj.DepthStencil;if(A&&_.clearRenderTarget(c,A),~n&rj.Color){if(this._shouldCopyBackgroundColor)_.copyRenderTargetToSubTexture(t.renderTarget,this._copyBackgroundTexture,t.viewport),it.blitTexture(c,this._copyBackgroundTexture,f,0,void 0,t.renderTarget?void 0:c._basicResources.blitScreenMaterial);else{var b=rj.DepthStencil;_.blitInternalRTByBlitFrameBuffer(t.renderTarget,f,b,t.viewport)}}e.setRenderTarget(p,m,i,r)}var S=u._maskManager;if(n&rj.Stencil&&(S.hasStencilWritten=!1),o.render(e,rh.Forward),s.render(e,rh.Forward),n&rj.Color&&(h.mode===n5.Sky?h.sky._render(e):h.mode===n5.Texture&&h.texture&&this._drawBackgroundTexture(t,h)),t.opaqueTextureEnabled){p._blitRenderTarget();var C=this._opaqueTexturePass;C.onConfig(t,p.getColorTexture(0)),C.onRender(e),e.setRenderTarget(p,m,i,r)}else t.shaderData.setTexture(r0._cameraOpaqueTextureProperty,null);l.render(e,rh.Forward),S.clearMask(e,rh.Forward);var T=null,R=t._needFinalPass(),E=u.postProcessManager;t.enablePostProcess&&E._isValid()?(T=R?E._getOutputRenderTarget(t):t.renderTarget,E._render(t,f,T)):(T=p,f&&f._blitRenderTarget(),E._releaseSwapRenderTarget(),E._releaseOutputRenderTarget());var M=this._finalPass;R?(M.onConfig(t,T),M.onRender(e),T=d):M.release(),T!==d&&it.blitTexture(c,T.getColorTexture(0),d,0,t.viewport),null==d||d._blitRenderTarget(),null==d||d.generateMipmaps()},t.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!==rJ.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)}},t.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 rr.Opaque:i.opaqueQueue.pushRenderElement(e);break;case rr.AlphaTest:i.alphaTestQueue.pushRenderElement(e);break;case rr.Transparent:i.transparentQueue.pushRenderElement(e)}e.renderQueueFlags|=u}}},t._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!==n9.Fill&&(this._lastCanvasSize.set(i.width,i.height),t._resizeBackgroundTexture());var s=a.shader.subShaders[0].passes[0],l=rM._compileMacros;ru.unionCollection(l,n._macroCollection,l);var c=s._getShaderProgram(n,l);c.bind(),c.uploadAll(c.materialUniformBlock,a.shaderData),c.uploadAll(c.cameraUniformBlock,e.shaderData),c.uploadUnGroupTextures(),(s._renderState||a.renderState)._applyStates(n,!1,s._renderStateDataMap,a.shaderData),r.drawPrimitive(o._primitive,o.subMesh,c)},t._prepareRender=function(e){for(var t=e.camera,n=t.engine,r=t.enableFrustumCulling,i=t.cullingMask,a=t._frustum,o=t.scene._componentsManager,s=o._renderers,l=o._canvases,c=s._elements,u=s.length-1;u>=0;--u){var d=c[u];i&d._entity.layer&&(!r||a.intersectsBox(d.bounds))&&(d._prepareRender(e),d._renderFrameCount=n.time.frameCount)}for(var h=l._elements,_=l.length-1;_>=0;_--){var f=h[_];i&f.entity.layer&&f._canRender(t)&&(f._prepareRender(e),this.pushRenderElement(e,f._renderElement))}},e}(),al=((eg={})[eg.None=0]="None",eg[eg.Opaque=1]="Opaque",eg[eg.AlphaTest=2]="AlphaTest",eg[eg.Transparent=4]="Transparent",eg[eg.All=7]="All",eg),ac=/*#__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}(),au=/*#__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}(),ad=((ev={})[ev.Layer0=1]="Layer0",ev[ev.Layer1=2]="Layer1",ev[ev.Layer2=4]="Layer2",ev[ev.Layer3=8]="Layer3",ev[ev.Layer4=16]="Layer4",ev[ev.Layer5=32]="Layer5",ev[ev.Layer6=64]="Layer6",ev[ev.Layer7=128]="Layer7",ev[ev.Layer8=256]="Layer8",ev[ev.Layer9=512]="Layer9",ev[ev.Layer10=1024]="Layer10",ev[ev.Layer11=2048]="Layer11",ev[ev.Layer12=4096]="Layer12",ev[ev.Layer13=8192]="Layer13",ev[ev.Layer14=16384]="Layer14",ev[ev.Layer15=32768]="Layer15",ev[ev.Layer16=65536]="Layer16",ev[ev.Layer17=131072]="Layer17",ev[ev.Layer18=262144]="Layer18",ev[ev.Layer19=524288]="Layer19",ev[ev.Layer20=1048576]="Layer20",ev[ev.Layer21=2097152]="Layer21",ev[ev.Layer22=4194304]="Layer22",ev[ev.Layer23=8388608]="Layer23",ev[ev.Layer24=0x1000000]="Layer24",ev[ev.Layer25=0x2000000]="Layer25",ev[ev.Layer26=0x4000000]="Layer26",ev[ev.Layer27=0x8000000]="Layer27",ev[ev.Layer28=0x10000000]="Layer28",ev[ev.Layer29=0x20000000]="Layer29",ev[ev.Layer30=0x40000000]="Layer30",ev[ev.Layer31=0x80000000]="Layer31",ev[ev.Everything=0xffffffff]="Everything",ev[ev.Nothing=0]="Nothing",ev),ah=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new ru,r._maskInteraction=n0.None,r._batchedTransformShaderData=!1,r._maskLayer=ad.Layer0,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new tZ,r._bounds=new tG,r._shaderData=new rP(ra.Renderer),r._mvMatrix=new tK,r._mvpMatrix=new tK,r._mvInvMatrix=new tK,r._normalMatrix=new tK,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}t5(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?(tU.subtract(i,r,i),this._distanceForSort=tU.dot(i,n.forward)):this._distanceForSort=tU.distanceSquared(i,r),this._render(e),ru.unionCollection(e.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},n._cloneTo=function(e){for(var t=this._materials,n=0,r=t.length;n<r;n++)e._setMaterial(n,t[n])},n._isFrontFaceInvert=function(){return this._transformEntity.transform._isFrontFaceInvert()},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._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=tK._identity;tK.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;tK.multiply(e.viewMatrix,n,s),tK.invert(s,a),tK.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;tK.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=e.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},t4(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}(rN);ah._tempVector0=new tU,ah._receiveShadowMacro=rc.getByName("RENDERER_IS_RECEIVE_SHADOWS"),ah._localMatrixProperty=nH.getByName("renderer_LocalMat"),ah._worldMatrixProperty=nH.getByName("renderer_ModelMat"),ah._mvMatrixProperty=nH.getByName("renderer_MVMat"),ah._mvpMatrixProperty=nH.getByName("renderer_MVPMat"),ah._mvInvMatrixProperty=nH.getByName("renderer_MVInvMat"),ah._normalMatrixProperty=nH.getByName("renderer_NormalMat"),ah._rendererLayerProperty=nH.getByName("renderer_Layer"),t6([nt],ah.prototype,"_distanceForSort",void 0),t6([nt],ah.prototype,"_onUpdateIndex",void 0),t6([nt],ah.prototype,"_rendererIndex",void 0),t6([nt],ah.prototype,"_globalShaderMacro",void 0),t6([nt],ah.prototype,"_renderFrameCount",void 0),t6([nn],ah.prototype,"_maskInteraction",void 0),t6([nt],ah.prototype,"_batchedTransformShaderData",void 0),t6([nn],ah.prototype,"_maskLayer",void 0),t6([nt],ah.prototype,"_overrideUpdate",void 0),t6([nt],ah.prototype,"_materials",void 0),t6([nt],ah.prototype,"_dirtyUpdateFlag",void 0),t6([nt],ah.prototype,"_rendererLayer",void 0),t6([nt],ah.prototype,"_bounds",void 0),t6([ni],ah.prototype,"_shaderData",void 0),t6([nt],ah.prototype,"_mvMatrix",void 0),t6([nt],ah.prototype,"_mvpMatrix",void 0),t6([nt],ah.prototype,"_mvInvMatrix",void 0),t6([nt],ah.prototype,"_normalMatrix",void 0),t6([nt],ah.prototype,"_materialsInstanced",void 0),t6([nn],ah.prototype,"_priority",void 0),t6([nn],ah.prototype,"_receiveShadows",void 0),t6([nt],ah.prototype,"_onTransformChanged",null),ah=t6([rV(rG,rk.CheckOnly)],ah);var a_=((ey={})[ey.WorldVolume=1]="WorldVolume",ey),af=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).influenceLayers=ad.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,nU.resetData(r),r.setMaterial(r._engine._basicResources.spriteMaskDefaultMaterial),r.shaderData.setFloat(t._alphaCutoffProperty,r._alphaCutoff),r._renderElement=new ac,r._renderElement.addSubRenderElement(new au),r._onSpriteChange=r._onSpriteChange.bind(r),r}t5(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){e.prototype._cloneTo.call(this,t),t.sprite=this._sprite},n._canBatch=function(e,t){return i9.canBatchSpriteMask(e,t)},n._batch=function(e,t){i9.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){var t=this._sprite;if(t)nU.updatePositions(this,this._transformEntity.transform.worldMatrix,this.width,this.height,t.pivot,this._flipX,this._flipY);else{var n=this._transformEntity.transform.worldPosition;e.min.copyFrom(n),e.max.copyFrom(n)}},n._render=function(e){var t=this._sprite;if((null==t?void 0:t.texture)&&this.width&&this.height){var n=this.getMaterial();if(n){var r=this._engine;n.destroyed&&(n=r._basicResources.spriteMaskDefaultMaterial),this._dirtyUpdateFlag&a_.WorldVolume&&(nU.updatePositions(this,this._transformEntity.transform.worldMatrix,this.width,this.height,t.pivot,this._flipX,this._flipY),this._dirtyUpdateFlag&=~a_.WorldVolume),2&this._dirtyUpdateFlag&&(nU.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=al.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 n1.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case n1.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=a_.WorldVolume);break;case n1.region:case n1.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case n1.atlasRegion:this._dirtyUpdateFlag|=2;break;case n1.pivot:this._dirtyUpdateFlag|=a_.WorldVolume;break;case n1.destroy:this.sprite=null}},t4(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|=a_.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|=a_.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=a_.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=a_.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}(ah);af._textureProperty=nH.getByName("renderer_MaskTexture"),af._alphaCutoffProperty=nH.getByName("renderer_MaskAlphaCutoff"),t6([nn],af.prototype,"influenceLayers",void 0),t6([nt],af.prototype,"_renderElement",void 0),t6([nt],af.prototype,"_subChunk",void 0),t6([nt],af.prototype,"_maskIndex",void 0),t6([nt],af.prototype,"_sprite",void 0),t6([nt],af.prototype,"_automaticWidth",void 0),t6([nt],af.prototype,"_automaticHeight",void 0),t6([nn],af.prototype,"_customWidth",void 0),t6([nn],af.prototype,"_customHeight",void 0),t6([nn],af.prototype,"_flipX",void 0),t6([nn],af.prototype,"_flipY",void 0),t6([nn],af.prototype,"_alphaCutoff",void 0),t6([nt],af.prototype,"_onSpriteChange",null);var ap=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._tileMode=nq.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new tJ(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=n$.Simple,n._dirtyUpdateFlag|=4,n.setMaterial(n._engine._basicResources.spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(n),n._color._onValueChanged=n._onColorChanged.bind(n),n}t5(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){e.prototype._cloneTo.call(this,t),t.sprite=this._sprite,t.drawMode=this._drawMode},n._canBatch=function(e,t){return i9.canBatchSprite(e,t)},n._batch=function(e,t){i9.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){var t=this._sprite;if(t)this._assembler.updatePositions(this,this._transformEntity.transform.worldMatrix,this.width,this.height,t.pivot,this._flipX,this._flipY);else{var n=this._transformEntity.transform.worldPosition;e.min.copyFrom(n),e.max.copyFrom(n)}},n._render=function(e){var t=this._sprite;if((null==t?void 0:t.texture)&&this.width&&this.height){var n=this.getMaterial();if(n){n.destroyed&&(n=this._engine._basicResources.spriteDefaultMaterial),this._dirtyUpdateFlag&a_.WorldVolume&&(this._assembler.updatePositions(this,this._transformEntity.transform.worldMatrix,this.width,this.height,t.pivot,this._flipX,this._flipY),this._dirtyUpdateFlag&=~a_.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3),4&this._dirtyUpdateFlag&&(this._assembler.updateColor(this,1),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 n1.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case n1.size:switch(this._dirtyUpdateFlag|=8,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=a_.WorldVolume),this._drawMode){case n$.Simple:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=a_.WorldVolume);break;case n$.Sliced:this._dirtyUpdateFlag|=a_.WorldVolume;break;case n$.Tiled:this._dirtyUpdateFlag|=7}break;case n1.border:switch(this._drawMode){case n$.Sliced:this._dirtyUpdateFlag|=3;break;case n$.Tiled:this._dirtyUpdateFlag|=7}break;case n1.region:case n1.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case n1.atlasRegion:this._dirtyUpdateFlag|=2;break;case n1.pivot:this._dirtyUpdateFlag|=a_.WorldVolume;break;case n1.destroy:this.sprite=null}},n._onColorChanged=function(){this._dirtyUpdateFlag|=4},t4(t,[{key:"drawMode",get:function(){return this._drawMode},set:function(e){if(this._drawMode!==e){switch(this._drawMode=e,e){case n$.Simple:this._assembler=nU;break;case n$.Sliced:this._assembler=nz;break;case n$.Tiled:this._assembler=nZ}this._assembler.resetData(this),this._dirtyUpdateFlag|=7}}},{key:"tileMode",get:function(){return this._tileMode},set:function(e){this._tileMode!==e&&(this._tileMode=e,this.drawMode===n$.Tiled&&(this._dirtyUpdateFlag|=7))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(e){e!==this._tiledAdaptiveThreshold&&(e=tk.clamp(e,0,1),this._tiledAdaptiveThreshold=e,this.drawMode===n$.Tiled&&(this._dirtyUpdateFlag|=7))}},{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===n$.Tiled?7:a_.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===n$.Tiled?7:a_.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=a_.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=a_.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}(ah);ap._textureProperty=nH.getByName("renderer_SpriteTexture"),t6([nt],ap.prototype,"_subChunk",void 0),t6([nt],ap.prototype,"_drawMode",void 0),t6([nt],ap.prototype,"_assembler",void 0),t6([nn],ap.prototype,"_tileMode",void 0),t6([nn],ap.prototype,"_tiledAdaptiveThreshold",void 0),t6([ni],ap.prototype,"_color",void 0),t6([nt],ap.prototype,"_sprite",void 0),t6([nt],ap.prototype,"_automaticWidth",void 0),t6([nt],ap.prototype,"_automaticHeight",void 0),t6([nn],ap.prototype,"_customWidth",void 0),t6([nn],ap.prototype,"_customHeight",void 0),t6([nn],ap.prototype,"_flipX",void 0),t6([nn],ap.prototype,"_flipY",void 0),t6([nt],ap.prototype,"_onSpriteChange",null),t6([nt],ap.prototype,"_onColorChanged",null);var am=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._textChunks=[],n._subFont=null,n._dirtyFlag=15,n._color=new tJ(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new tG,n._font=null,n._fontSize=24,n._fontStyle=nB.None,n._lineSpacing=0,n._characterSpacing=0,n._horizontalAlignment=n2.Center,n._verticalAlignment=n3.Center,n._enableWrapping=!1,n._overflowMode=nI.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}t5(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){e.prototype._cloneTo.call(this,t),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 i9.canBatchSprite(e,t)},n._batch=function(e,t){i9.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){tG.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 rP(ra.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=nN.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 A=v[y],b=A.subChunk,S=A.charRenderInfos,C=0,T=S.length;C<T;++C){var R=S[C],E=R.localPositions,M=E.x,P=E.y;f.set(M*n+P*a+l,M*r+P*o+c,M*i+P*s+u),tU.scale(h,E.z-M,p),tU.add(f,p,p),tU.scale(d,E.w-P,m),tU.add(f,m,g),tU.add(p,m,m);for(var w=b.chunk.vertices,F=0,L=b.vertexArea.start+36*R.indexInChunk;F<4;++F,L+=9)_[F].copyToArray(w,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=oK._pixelsPerUnit,n=this._localBounds,r=n.min,i=n.max,a=t._charRenderInfos,o=this._getSubFont(),s=this._characterSpacing*this._fontSize,l=this.enableWrapping?nN.measureTextWithWrap(this,this.width*e,this.height*e,this._lineSpacing*this._fontSize,s):nN.measureTextWithoutWrap(this,this.height*e,this._lineSpacing*this._fontSize,s),c=l.height,u=l.lines,d=l.lineWidths,h=l.lineHeight,_=l.lineMaxSizes,f=this.engine._charRenderInfoPool,p=u.length,m=0;if(p>0){var g=this.horizontalAlignment,v=1/e,y=.5*(this._width*e),x=this._height*e,A=.5*h,b=0,S=.5*h-_[0].ascent,C=.5*h-_[p-1].descent-1;switch(this.verticalAlignment){case n3.Top:b=.5*x-A+S;break;case n3.Center:b=.5*c-A-(C-S)*.5;break;case n3.Bottom:b=c-.5*x-A-C}for(var T=-1,R=Number.MAX_SAFE_INTEGER,E=Number.MAX_SAFE_INTEGER,M=Number.MIN_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER,w=0;w<p;++w){var F=d[w];if(F>0){var L=u[w],D=0,B=-1;switch(T<0&&(T=w),g){case n2.Left:D=-y;break;case n2.Center:D=-(.5*F);break;case n2.Right:D=y-F}for(var I=0,N=L.length;I<N;++I){var O=L[I],V=o._getCharInfo(O);if(V.h>0){B<0&&(B=I);var k=a[m++]=f.get(),U=k.localPositions;k.texture=o._getTextureByIndex(V.index),k.uvs=V.uvs;var z=V.w,G=V.ascent,H=V.descent,W=D*v,X=(D+z)*v,j=(b+G)*v,Y=(b-H)*v;U.set(W,j,X,Y),w===T&&(P=Math.max(P,j)),E=Math.min(E,Y),I===B&&(R=Math.min(R,W)),M=Math.max(M,X)}D+=V.xAdvance+s}}b-=h}T<0?(r.set(0,0,0),i.set(0,0,0)):(r.set(R,E,0),i.set(M,P,0))}else r.set(0,0,0),i.set(0,0,0);if(o._getLastIndex()>0&&a.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId}),this._freeTextChunks(),0!==m){var K=this._textChunks,Q=new ag;K.push(Q);var q=this._getChunkManager().maxVertexCount,Z=a[0],J=Z.texture;Q.texture=J;var $=Q.charRenderInfos;$.push(Z);for(var ee=1;ee<m;++ee){var et=a[ee],en=et.texture;(J!==en||4*$.length+4>q)&&(this._buildChunk(Q,$.length),Q=new ag,K.push(Q),J=en,Q.texture=en,$=Q.charRenderInfos),$.push(et)}var er=$.length;er>0&&this._buildChunk(Q,er),a.length=0}},n._onTransformChanged=function(t){e.prototype._onTransformChanged.call(this,t),this._setDirtyFlagTrue(12)},n._isTextNoVisible=function(){return!this._font||""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===nI.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=t9.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)},t4(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:"characterSpacing",get:function(){return this._characterSpacing},set:function(e){this._characterSpacing!==e&&(this._characterSpacing=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}(ah);am._textureProperty=nH.getByName("renderElement_TextTexture"),am._tempVec30=new tU,am._tempVec31=new tU,am._worldPositions=[new tU,new tU,new tU,new tU],am._charRenderInfos=[],t6([nt],am.prototype,"_textChunks",void 0),t6([nn],am.prototype,"_subFont",void 0),t6([nt],am.prototype,"_dirtyFlag",void 0),t6([ni],am.prototype,"_color",void 0),t6([nn],am.prototype,"_text",void 0),t6([nn],am.prototype,"_width",void 0),t6([nn],am.prototype,"_height",void 0),t6([nt],am.prototype,"_localBounds",void 0),t6([nn],am.prototype,"_font",void 0),t6([nn],am.prototype,"_fontSize",void 0),t6([nn],am.prototype,"_fontStyle",void 0),t6([nn],am.prototype,"_lineSpacing",void 0),t6([nn],am.prototype,"_characterSpacing",void 0),t6([nn],am.prototype,"_horizontalAlignment",void 0),t6([nn],am.prototype,"_verticalAlignment",void 0),t6([nn],am.prototype,"_enableWrapping",void 0),t6([nn],am.prototype,"_overflowMode",void 0),t6([nt],am.prototype,"_onTransformChanged",null),t6([nt],am.prototype,"_onColorChanged",null);var ag=function(){this.charRenderInfos=[]},av=((ex={})[ex.Static=0]="Static",ex[ex.Dynamic=1]="Dynamic",ex[ex.Stream=2]="Stream",ex),ay=((eA={})[eA.None=0]="None",eA[eA.Discard=1]="Discard",eA),ax=/*#__PURE__*/function(e){function t(t,n,r,i,a){if(void 0===i&&(i=av.Static),void 0===a&&(a=!1),(o=e.call(this,t)||this)._dataUpdateManager=new n4,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 t._isDeviceLost||(t._renderingStatistics._bufferMemory+=o._byteLength),o}t5(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=ay.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.copyFromBuffer=function(e,t,n,r){this._platformBuffer.copyFromBuffer(e._platformBuffer,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,this._engine._renderingStatistics._bufferMemory+=this._byteLength},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._engine._isDeviceLost||(this._engine._renderingStatistics._bufferMemory-=this._byteLength),this._platformBuffer.destroy()},t4(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}(nm),aA=((eb={})[eb.UInt8=0]="UInt8",eb[eb.UInt16=1]="UInt16",eb[eb.UInt32=2]="UInt32",eb),ab=((eS={})[eS.Float=0]="Float",eS[eS.Vector2=1]="Vector2",eS[eS.Vector3=2]="Vector3",eS[eS.Vector4=3]="Vector4",eS[eS.Byte4=4]="Byte4",eS[eS.UByte4=5]="UByte4",eS[eS.NormalizedByte4=6]="NormalizedByte4",eS[eS.NormalizedUByte4=7]="NormalizedUByte4",eS[eS.Short2=8]="Short2",eS[eS.UShort2=9]="UShort2",eS[eS.NormalizedShort2=10]="NormalizedShort2",eS[eS.NormalizedUShort2=11]="NormalizedUShort2",eS[eS.Short4=12]="Short4",eS[eS.UShort4=13]="UShort4",eS[eS.NormalizedShort4=14]="NormalizedShort4",eS[eS.NormalizedUShort4=15]="NormalizedUShort4",eS),aS=/*#__PURE__*/function(){function e(){}return e._getGLIndexType=function(e){switch(e){case aA.UInt8:return nC.UNSIGNED_BYTE;case aA.UInt16:return nC.UNSIGNED_SHORT;case aA.UInt32:return nC.UNSIGNED_INT}},e._getGLIndexByteCount=function(e){switch(e){case aA.UInt8:return 1;case aA.UInt16:return 2;case aA.UInt32:return 4}},e._getElementInfo=function(e){var t,n,r,i=!1;switch(e){case ab.Float:t=1,n=nC.FLOAT;break;case ab.Vector2:t=2,n=nC.FLOAT;break;case ab.Vector3:t=3,n=nC.FLOAT;break;case ab.Vector4:t=4,n=nC.FLOAT;break;case ab.Byte4:t=4,n=nC.BYTE;break;case ab.UByte4:t=4,n=nC.UNSIGNED_BYTE;break;case ab.NormalizedByte4:t=4,n=nC.BYTE,i=!0,r=1/127;break;case ab.NormalizedUByte4:t=4,n=nC.UNSIGNED_BYTE,i=!0,r=1/255;break;case ab.Short2:t=2,n=nC.SHORT;break;case ab.UShort2:t=2,n=nC.UNSIGNED_SHORT;break;case ab.NormalizedShort2:t=2,n=nC.SHORT,i=!0,r=1/32767;break;case ab.NormalizedUShort2:t=2,n=nC.UNSIGNED_SHORT,i=!0,r=1/65535;break;case ab.Short4:t=4,n=nC.SHORT;break;case ab.UShort4:t=4,n=nC.UNSIGNED_SHORT;break;case ab.NormalizedShort4:t=4,n=nC.SHORT,i=!0,r=1/32767;break;case ab.NormalizedUShort4:t=4,n=nC.UNSIGNED_SHORT,i=!0,r=1/65535}return{size:t,type:n,normalized:i,normalizedScaleFactor:r}},e}(),aC=/*#__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=aS._getElementInfo(this.format),this._instanceStepRate=Math.floor(i)}return t4(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}(),aT=((eC={})[eC.VertexBuffer=0]="VertexBuffer",eC[eC.IndexBuffer=1]="IndexBuffer",eC),aR=((eT={})[eT.Points=0]="Points",eT[eT.Lines=1]="Lines",eT[eT.LineLoop=2]="LineLoop",eT[eT.LineStrip=3]="LineStrip",eT[eT.Triangles=4]="Triangles",eT[eT.TriangleStrip=5]="TriangleStrip",eT[eT.TriangleFan=6]="TriangleFan",eT),aE=/*#__PURE__*/function(){function e(){}return e.create=function(t){return new Promise(function(n,r){var i=new nF(t,e._size,e._size,n_.R8G8B8,!1,!1);i.wrapModeU=i.wrapModeV=np.Clamp,i.isGCIgnored=!0;var a=new Image;return a.onload=function(){i.setImageSource(a),n(i)},a.onerror=a.onabort=function(){var e="Failed to load prefiltered LUT image.";nb.error(e),r(e)},a.src=e._base64,t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,i)||this}return t5(t,e),t.prototype.restoreContent=function(){i.setImageSource(a)},t}(nl))),i})},e}();aE._size=256,aE._base64="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAABGdBTUEAALGPC/xhBQAACjVpQ0NQc1JHQiBJRUM2MTk2Ni0yLjEAAEjHnZZ3VFTXFofPvXd6oc0w0hl6ky4wgPQuIB0EURhmBhjKAMMMTWyIqEBEEREBRZCggAGjoUisiGIhKKhgD0gQUGIwiqioZEbWSnx5ee/l5ffHvd/aZ+9z99l7n7UuACRPHy4vBZYCIJkn4Ad6ONNXhUfQsf0ABniAAaYAMFnpqb5B7sFAJC83F3q6yAn8i94MAUj8vmXo6U+ng/9P0qxUvgAAyF/E5mxOOkvE+SJOyhSkiu0zIqbGJIoZRomZL0pQxHJijlvkpZ99FtlRzOxkHlvE4pxT2clsMfeIeHuGkCNixEfEBRlcTqaIb4tYM0mYzBXxW3FsMoeZDgCKJLYLOKx4EZuImMQPDnQR8XIAcKS4LzjmCxZwsgTiQ7mkpGbzuXHxArouS49uam3NoHtyMpM4AoGhP5OVyOSz6S4pyalMXjYAi2f+LBlxbemiIluaWltaGpoZmX5RqP+6+Dcl7u0ivQr43DOI1veH7a/8UuoAYMyKarPrD1vMfgA6tgIgd/8Pm+YhACRFfWu/8cV5aOJ5iRcIUm2MjTMzM424HJaRuKC/6386/A198T0j8Xa/l4fuyollCpMEdHHdWClJKUI+PT2VyeLQDf88xP848K/zWBrIieXwOTxRRKhoyri8OFG7eWyugJvCo3N5/6mJ/zDsT1qca5Eo9Z8ANcoISN2gAuTnPoCiEAESeVDc9d/75oMPBeKbF6Y6sTj3nwX9+65wifiRzo37HOcSGExnCfkZi2viawnQgAAkARXIAxWgAXSBITADVsAWOAI3sAL4gWAQDtYCFogHyYAPMkEu2AwKQBHYBfaCSlAD6kEjaAEnQAc4DS6Ay+A6uAnugAdgBIyD52AGvAHzEARhITJEgeQhVUgLMoDMIAZkD7lBPlAgFA5FQ3EQDxJCudAWqAgqhSqhWqgR+hY6BV2ArkID0D1oFJqCfoXewwhMgqmwMqwNG8MM2An2hoPhNXAcnAbnwPnwTrgCroOPwe3wBfg6fAcegZ/DswhAiAgNUUMMEQbigvghEUgswkc2IIVIOVKHtCBdSC9yCxlBppF3KAyKgqKjDFG2KE9UCIqFSkNtQBWjKlFHUe2oHtQt1ChqBvUJTUYroQ3QNmgv9Cp0HDoTXYAuRzeg29CX0HfQ4+g3GAyGhtHBWGE8MeGYBMw6TDHmAKYVcx4zgBnDzGKxWHmsAdYO64dlYgXYAux+7DHsOewgdhz7FkfEqeLMcO64CBwPl4crxzXhzuIGcRO4ebwUXgtvg/fDs/HZ+BJ8Pb4LfwM/jp8nSBN0CHaEYEICYTOhgtBCuER4SHhFJBLVidbEACKXuIlYQTxOvEIcJb4jyZD0SS6kSJKQtJN0hHSedI/0ikwma5MdyRFkAXknuZF8kfyY/FaCImEk4SXBltgoUSXRLjEo8UISL6kl6SS5VjJHslzypOQNyWkpvJS2lIsUU2qDVJXUKalhqVlpirSptJ90snSxdJP0VelJGayMtoybDFsmX+awzEWZMQpC0aC4UFiULZR6yiXKOBVD1aF6UROoRdRvqP3UGVkZ2WWyobJZslWyZ2RHaAhNm+ZFS6KV0E7QhmjvlygvcVrCWbJjScuSwSVzcopyjnIcuUK5Vrk7cu/l6fJu8onyu+U75B8poBT0FQIUMhUOKlxSmFakKtoqshQLFU8o3leClfSVApXWKR1W6lOaVVZR9lBOVd6vfFF5WoWm4qiSoFKmclZlSpWiaq/KVS1TPaf6jC5Ld6In0SvoPfQZNSU1TzWhWq1av9q8uo56iHqeeqv6Iw2CBkMjVqNMo1tjRlNV01czV7NZ874WXouhFa+1T6tXa05bRztMe5t2h/akjpyOl06OTrPOQ12yroNumm6d7m09jB5DL1HvgN5NfVjfQj9ev0r/hgFsYGnANThgMLAUvdR6KW9p3dJhQ5Khk2GGYbPhqBHNyMcoz6jD6IWxpnGE8W7jXuNPJhYmSSb1Jg9MZUxXmOaZdpn+aqZvxjKrMrttTjZ3N99o3mn+cpnBMs6yg8vuWlAsfC22WXRbfLS0suRbtlhOWWlaRVtVWw0zqAx/RjHjijXa2tl6o/Vp63c2ljYCmxM2v9ga2ibaNtlOLtdZzllev3zMTt2OaVdrN2JPt4+2P2Q/4qDmwHSoc3jiqOHIdmxwnHDSc0pwOub0wtnEme/c5jznYuOy3uW8K+Lq4Vro2u8m4xbiVun22F3dPc692X3Gw8Jjncd5T7Snt+duz2EvZS+WV6PXzAqrFetX9HiTvIO8K72f+Oj78H26fGHfFb57fB+u1FrJW9nhB/y8/Pb4PfLX8U/z/z4AE+AfUBXwNNA0MDewN4gSFBXUFPQm2Dm4JPhBiG6IMKQ7VDI0MrQxdC7MNaw0bGSV8ar1q66HK4RzwzsjsBGhEQ0Rs6vdVu9dPR5pEVkQObRGZ03WmqtrFdYmrT0TJRnFjDoZjY4Oi26K/sD0Y9YxZ2O8YqpjZlgurH2s52xHdhl7imPHKeVMxNrFlsZOxtnF7YmbineIL4+f5rpwK7kvEzwTahLmEv0SjyQuJIUltSbjkqOTT/FkeIm8nhSVlKyUgVSD1ILUkTSbtL1pM3xvfkM6lL4mvVNAFf1M9Ql1hVuFoxn2GVUZbzNDM09mSWfxsvqy9bN3ZE/kuOd8vQ61jrWuO1ctd3Pu6Hqn9bUboA0xG7o3amzM3zi+yWPT0c2EzYmbf8gzySvNe70lbEtXvnL+pvyxrR5bmwskCvgFw9tst9VsR23nbu/fYb5j/45PhezCa0UmReVFH4pZxde+Mv2q4quFnbE7+0ssSw7uwuzi7Rra7bD7aKl0aU7p2B7fPe1l9LLCstd7o/ZeLV9WXrOPsE+4b6TCp6Jzv+b+Xfs/VMZX3qlyrmqtVqreUT13gH1g8KDjwZYa5ZqimveHuIfu1nrUttdp15UfxhzOOPy0PrS+92vG140NCg1FDR+P8I6MHA082tNo1djYpNRU0gw3C5unjkUeu/mN6zedLYYtta201qLj4Ljw+LNvo78dOuF9ovsk42TLd1rfVbdR2grbofbs9pmO+I6RzvDOgVMrTnV32Xa1fW/0/ZHTaqerzsieKTlLOJt/duFczrnZ86nnpy/EXRjrjup+cHHVxds9AT39l7wvXbnsfvlir1PvuSt2V05ftbl66hrjWsd1y+vtfRZ9bT9Y/NDWb9nffsPqRudN65tdA8sHzg46DF645Xrr8m2v29fvrLwzMBQydHc4cnjkLvvu5L2key/vZ9yff7DpIfph4SOpR+WPlR7X/aj3Y+uI5ciZUdfRvidBTx6Mscae/5T+04fx/Kfkp+UTqhONk2aTp6fcp24+W/1s/Hnq8/npgp+lf65+ofviu18cf+mbWTUz/pL/cuHX4lfyr468Xva6e9Z/9vGb5Dfzc4Vv5d8efcd41/s+7P3EfOYH7IeKj3ofuz55f3q4kLyw8Bv3hPP7Ori+UwAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAAsTAAALEwEAmpwYAAAF1GlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuYTZhNjM5NjhhLCAyMDI0LzAzLzA2LTExOjUyOjA1ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuMTIgKE1hY2ludG9zaCkiIHhtcDpDcmVhdGVEYXRlPSIyMDI0LTEyLTEyVDE4OjIwOjQwKzA4OjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAyNC0xMi0xM1QxMzoxNjozMSswODowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAyNC0xMi0xM1QxMzoxNjozMSswODowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTBhZWJkMjMtOGJlMi00OTBlLWEzOGItZmEwMDQwODNmMTJmIiB4bXBNTTpEb2N1bWVudElEPSJhZG9iZTpkb2NpZDpwaG90b3Nob3A6NDNhMDNiNmEtYWIyYi02ODQ1LThhOWEtY2JmNDg0YzVjOWIxIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ODkwMGQxMjktYTQ2MS00NTE2LWFmNWItMjRkM2ZjOGE4NGJhIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo4OTAwZDEyOS1hNDYxLTQ1MTYtYWY1Yi0yNGQzZmM4YTg0YmEiIHN0RXZ0OndoZW49IjIwMjQtMTItMTJUMTg6MjA6NDArMDg6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyNS4xMiAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NTBhZWJkMjMtOGJlMi00OTBlLWEzOGItZmEwMDQwODNmMTJmIiBzdEV2dDp3aGVuPSIyMDI0LTEyLTEzVDEzOjE2OjMxKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjUuMTIgKE1hY2ludG9zaCkiIHN0RXZ0OmNoYW5nZWQ9Ii8iLz4gPC9yZGY6U2VxPiA8L3htcE1NOkhpc3Rvcnk+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+pKcSgwAAFRNJREFUeNrtnQeSG9cRhp+O5OuZSlYgZSpQiaKSywdwle8ll11yYNwFBoYIYTg7sV/nftNTW1sAdgYK+3/df4fBvlXKH8tvx6ksHqea14EvCr1i8pT+I8Rpoo95T+Z6keWn49PeugJQK/Q9A4A7k6hyc6GbiJ5T67MPQgNgxUN7IZ83/AfKA6chAHIMQE5zBYAVDBKXK4f5AKIfnj8CoCqu8wJA17eO4umSDRfyQxgejPpHFkjO8JgEeAXF65gc0TBvToJCDbB2/hQAtSTg1uI36fjbq3EZ1D9rgfxUvQ5r3KB1bYb8xQezAJgYHkMARP2PFRi7Dfl1kFQB0GqX07zJs8N611L0mxZIJwkYzrky5O835E8t0D1y1euk7ZMhfz8unyT6kQW6twPTr1bXZshXkDWb+nEAhDD93ka5kLdKly8q+sUa4J5RvOcFYA+j3GZCvrHopzUA3d8X69WGiCG/5MaOgPqRNYAH09/qLoPnJc02SltSG/SeVpPHCgD/Xc6ge/lRRb9igYruhrMrAHJhU83nGIt+xQJJJwFzABzCkCFfW/TrFig9T4b8xkW/boE0PU9xs7+w29LWj8/RE/3IAr0dZLtBbYEn6L2I8Ku87+hrPlgCoIQa7ua9iMV9X9+R6EcW6G3WwtdknyeXdpT7+obbOyIWyGfIL02388PtabYj+qkFYgSgWO8w72SC2+rKGtd7Vlsgh4pvuLeT96Po5Io6C9QeAK4+WjBFr2yQqi2QN8WXXFvY4XqmMgYSABT57n44o7+3Ow+91btQC6Tf6qEDEGtvp72dZP/dnjoLpOyCfFa9rsJ/il7WAr3j9fMahLKBoefJbQWPFugdDsWjjU3zRj9F790CvZOVrorR38+Kjkb7ktcCKdueJu9KyS6+QRef/iYrAJQWZ7q8F+7hw6Rcl7D0a4cAqNkeZQCypRPd+itZoBKwwR9ijJV9TCsMtk8YAVC8bvLsYXabLR1t9U8zANEFNQ9AruBrNnAo7w894QzAuxn1d9nJabClU6v+iwVqG4AGPkinmerWnfr7DFDcLPPs3N833MnRwaD6BDoAJce32cDxU9TWntADsM+on58g0kxRu3nm4hzg3Xop7yTqR/pbV3FsjCP1rwNQJAdb+4n6aettqlvghSMASqi+vv7UNmdVyrZeTv3zGSDbmqG1ruZenBgbqvovGeA965t0zQFIq+PZ3wuq/5IB3rNu+ITrYDbs5qMYGx719wDYWn8TANLNl4hte1719xbI1voznpDNnGYal5wqX3m9B8Cw3s2on41LG/UPM0DZwRA33Icep8MRf30IAGNjpyiupmmSkK0b8dGspvrhADix+GlssofD/PoZgPeDu50mPxREyAXtMcZvFsHv08ZbmgBksM8Yz6n+PgM4DPa2zr7h2wVbq2Ip6u8zQDgA2vyDbRnjldU/BKA4G9822cbJaZQv9Q8tUJa2uXFgVebqXL5WBBMDfPE0tMrVA58qV5U1ogg21HpxOY7d1d58POtCOG2cAf7UusvPsrU1486l/nUAvLn8vXxgd3BLE0j9bzJAkdlckL6/hPhWWb+2oX7SVVMAivvB7d68TVoawat6AHB+pklzH++zPRru0ugUwTs097afUKmm2ohOHW/oEVcNAbDSvRwAed+ToYM3vKriTRgBUC5hy25GTnu05nzq394F+iBUMyeK3J0PUGOHbcZ/xAWAtns4DUf3ZoK9vvrvZIB96j7lXqLEabmnUwCC6r691d92Oi2e/4k9ANK6d+vmm1wNMKgmg8IwC0Bxv4ngp9G+E1tiLnfBNugHWN0XfwPXJpfXU9+CT88AfBhnSuXcxhja8dQ3fhv0Q/fLCLHiegbsSE8vADTWptxnuzCfItugCAB0CtkGdJ9PvT/tAYhrbERXuNrDIP9V5zOAH4fjwbhb6X5XbHjJAB85W5r3Y1H2rN29ZJ51AIqDUZS3iO5fyqn+ujboR6GsvJVX8fCGUWCI9LtYAqCNSB80mobmJ1j26AGQa88rhHaHGHg7xy1jxmZpCoBPb2Oiaa63jQhMG2YJ1Ab9WPgTB+QA8INB9AvdphTxNxwC4NDNG0rcyYVxKYqRH2YBiKV4z0q1+ke0mkOKxCDs42g2xr/UWmLJDyGMb3inDfqxruKjx++VF/cJWOz80APgqhujJm7n77wfy2Rmh84A3A8S3U0kFVf3bRcMnIOw+w46MCEU7/OtJN7Z3EepAbMGwE4Cuf8fKWeJEFUEcwbw7GSi/CgcEnErBOZB2H2x/yr/WheVdfMJROhCNULeFMFRIrqHE6ze3JCWlgviMwAP9qpyP+/j2Vk5L4ipT6cA6JgZZfH5PM1VMnGChGDDZ2kQ9kBA+ib6dnKyc3JcVcn2CeECgFUAk5asziXe+AldJVMuwbzzLABqQY54if6FcpdESQtBS4KysgrxwM4fM17o50182qqgpkgchjMAn/iQvuhb+YFE4pK4tbIcIdDT1gFoUrWNoWKufs2hGD8MFwDiqtPtv6QTB4U7waosFi95Zwdhn7Qu+hA4hUgO5kgw+59LEfxJij4UPFGskceSd7YN+mcHgkjFh2iqum0K4U8zBKBh3jy8bWYAjxkgU0fozinxfDkk8K9fAPCv1N0yY2KTQmeAuteXAGDUjeaFzXAifblJeWBo+tcGYQ/rf98SJwdiQ+5tnRTKsTIA+vXfLdBDYckqE5KFhFsGKEhwwTAzCHtop29v8LRBBdfJbktezj9WdAGAolR9NtSwab50ZuwFSbsgNtM/LYIfiomS8Xz2q5rnIYQLMjD90zbop3O/URYVyqHih4d0QbZtH2oq6AEoYAyivKhgpTyT4JMBe9M/bYN+uvW7hPy+0WLlvZAdkv2Q4Lz1ySn6URH8KUxhdI1q4mFLQjKAO0eq0t20QLO/PGnF+8SDDkkyYJsB6s48A/BZje5xT5VzizQecs2lBhjQnHYxpIIegCXJ6iveed4IzYDOIpBoBmCwPaMi+DOCgokASKQXXjCUC+iIDLjqdWKK4M8A4Z8LAA/AOCwYcJebMMCeFrTbPuXN8cYCoXVPP4GXEFdgmIyZeS9xUvjKZYDfAPgcHP4RutdHJUpykDZLQRnQsD2jDKAMgFxWUW490ZODTqngnwGK1rdNzmYR/PmCenjlbpIlpJGINTSgnEavhs0zwGIR/Pmq6J08QJ9pyIDbBpEaAwoZgIrBCABGEsyl77CV5K09Gsv2UN3O7PlnAL5Y1a6V7nlpYWGDiIRaeeCWAbUMUPHTTQBqlW3OiVD9ID1QM28HCTHg0faMLNAXleEfIWhvrmmfpkhu+mvb8cSrvwdgU/3hqGB3TeadIkPrH6LeRWJwBuDRQGpo0ROp8AlDkVk68lMKEx2RZr3L4HaWLNAjbPjnhcG5TVK2Q8o7EWoM6NS7my/esUCP5kSmBoOcd5JrIqFhMCwG9BnwUuYCLdCK+iVgcMuAcm2gb4REGZCGAf5T6AkXAODqBwpaxzWxgyEBA6/6TSYAQjsOZrZnZIG+XJU7XNnEJKBTRiunAg9dUQnzo2P9GW3P4uMRAFP1wxVP58FPwSBRIpsbIScMuAj8wxrgS7D6GZ8W3d5r6FRgSIJJ+asR+KcWCKL+TYmLMhCiPGBJBVxgsJgfrr6nTocHaYFm1Q/Rdy0SCr0mRh6UjVAGfgUMxk/PAHwFVj8OCdu0IGeNqqjg1b3C2KvJwD/fBv0KJn04EnJOCXKaToXgpzFqXvW6DfygH40AWJJ+LRh0KhBZQq1QZndE0haIKxsg2p0OA/+4BvgKIH1EZmB3R8pFgm0SwIGhsO/Abn5YMECq/wLA1wDpb+YH0eQgigGOhxBJQKgMwMFgUuOuk/D7HIAFAIXKwaEpoieBKP2f1gL/sAb4mkP9uBQhOnqTLpHdJgHpwK+5x8ZCwkYNwAiAaBkt5IvMk4BJ+FcwP8btHSAMZwC+uaukjgaAtFmC947cYiCUBHhJ0Pc8Sycw+JyVV6YAzGJQpf5wCUGnL6ScBMwZ0PQ8GOn3RfA3WHEzksA4eBbqEaEx0EkCHho+Vp4Hp/7TegYwhEGiXGbvkOpg4NP3Ox1pVQX+TQsUCwbG5SKFjhBj+Pfp+82a+rXqvwDw7Wrtu1kecLWPWIbNok1SCQysln94GZD2PIjAD+WhBwAo7k6rJCBWyQgSdIoBw/Av7XnQN6dztjVreJgBYF3inakjYoGhamZchQQvBjptH2+ep1brcKHPq//SBfoWLPTOU4UgtEwh1BJtNfwL2X3xwN//6AzA44myO5r6O0lfJGGKlHtBas0fCQbYu/v8jR24+nsATgAGOpXagKVTBJ8W61TD+qNfxjY/bwZgt/t46Y8AGIm4E/NFHVPLqFjnAXYMTMK/mvmR6GmeIBLfXIV4PKfOjqz+zl8qYFmXcDUC4w3/jE0exkqXK/AvtkEfL6i2Q1UFHV+dQMkGLDAwdoFYXJBV+A9h9+sC/xCA7xa0XuuI9HtHRaAqsO0CyYV/oQmXf+lv/PQCwKzuVwBg6Rp1Wm0iXE3MshPBjgEiCaT0Cy8AuH6R1RANPSarIgG9BLF+AlfhC2HAQ39TW/1DAHqNMqYCtRKZfTig3AZVcD4sjc6mpN8D8GRB+lWpwGqMwDgqlm4EUWCgrDnsSvpV6j+NABhJH2eKhIbKRcAOSTeC5PyPVaOzGenfmQQ/WZD+CgBcJGiOC3DFAL0AMGn5p/Sh58MBWG+VwgcI0iUyrh5AlMJqBUBKn1H6M6sQ6wBA8sDmGEEtIRRse9RbAaDpfIJKnxT4hwB8P1E8JA+wYMDbKUKrXxkAuT0fBemz3JCuL/2yckMMBAAEBh1Ht7QKA1cACFl/Cekr35LrRfoIABgx6LBCx31ulwIAjHlA1PQbSv9EkzVC+ttXXQAY6b6rqQo6rVRA+dyuzb6QEAC1GLiqdxuX/hSAXv0rCaGqUEZ0S3GpgBcAtdoX7X+kZ1sKNa699HsAfpiE/6pUsO6L5BigJ4GqOYBy7YuQvsIeG4vRF5V+9YUIACTsUOceAK69N7T/YZF+q0Yff20PwFD9HaoqQA/RGHeHKKVwbRngs+qtDf/R3Q712gsAI/UD6wEECVxJoGO6bZLiglgAiCV9b26HeO0aACtJgJEBHAAd60ygGAEg0fBRNvqGumeQfg/Aj3PqXy8JgLVBVXeIfVei0JKAHADS0m/b7bBJfxOAKgboSYB3j5r3rgCulj+x4YMO/7XrDEK6N3Y7CACADGwmBKIdou/J8fZAEQBwrTlID7baD/m1ACwxgEsFLDdeSjAgBwCl2a/pdhyGfFnpwwFgxKA2FSCqYXQXiGh+pj9il77OLkPjIX8KwE+vlXRUwYAyMOZqBAmZH64Rr630bXWvKv1NAI4L7VH41IwyMxatgxEM0KWvsNSQVgcPwIiBI0D3iBIZ2COiLMkRawBgElCL/bjwnyGfBMCx0gvhBmfAPIBLBbX+p4D/CMCS7zexPWl1NAA4LosePTVDfAwR132SxMkXpeSttT2809zUfR0AwLK4tjJGu6DOzv+wd/r9hPyd6n4IwM93FX9cTQLrLmipPkZ7IXQpXGj+B1EBA2O/UJMndS8FADwPQBpE+kmAJfYL3b1OD/8Sug/c0uEC4AhrClUxUFUPUJIApPyV6HsW1rFu4dtiAIpyF/EeAQAOA/qomKUIxoV/LunrzLNS9wwA9LrfZIA4MwbOidEZoNBGv7iWv0KlW2q2GFL3JACWjBAxFSAYINYARaDtgwYAaHWEbkJP3dcBcNwqiHGVMXxRYmUoVpsBarv+lF4nl+3xpvvWRD8C4C9z6j9u9UZnGYCsD9XePsbu/gt52YHL7heZbc3UPRsAR1gSONKKATgDiDvi0c6nCoAqBkR1nyaHBMABlgSOhJp4pRioKoJxBQDc9LPYfZamvoLu9yX6JQAO9V4ISAJiTw5tgURNv1qHR0H3+xX9LAAHQh5AN0ZX9qWJDdD1sVchz3cNdZ/BXhaAw4SBbu4Bwg7R6+Ba/7PZ8qcAgLP7pX6YlcFeD4DDHANdTUkA2ZwjDoOB/ofX85joPkWvCsBhIQOw1ANVt00iCgDebg9Xe0dZ9yl6KgCHuzD0pqijMVB1u0zVh0FsWv9NBhAAFO6NnQz2jgA43AVgthioXZfgBQBu/VmK3YJd2MxgHwaAwzIDh2UXVLUuUVUD0K3/pu9He/0iv6GZojcA4FADACQJqAFQCKudcM9DaWtS5JuiVwXgtj4JwCcDwDkA7qOvisBSw6b1Fwr2KXobAG6XGZhi0MF25oAMVIX/spUE6LqnBPtTKj4iALdz32c7QlMAjoAPlYCH/45jxxPR5FHWfYreHQC3A+nfLrig9TywmQSqRmA6gb/Ur+an6FsD4PYuA7dgIwRckai9GwZxVzuluVm4F/FT9PEAmP2Cd4TWe0HK6kfrPkW/awBuJg9mAThU3jvWkdUPHHLx6v6Uit8VADdX3Q+/r7RED5UASKh/0+gXcFM/Rb9rAIbqvxk8HXZFIR2hTQAgte9SsVtgtkcu2KfiGweg/3o1AWC9JQrPAMCu/7rLp0yyUvR5jAH4eSL9y4PadtD6JLjqfhdEf7OQVxVS9LsG4NVV/a8GGNzOZYCR9A8LbdDRp6Sc6vv9ZfkW9VkA0KJPxe8dgFdzXzfL/dDNDDBdh978rE9IewcS+FP0eVQD8PIq+uGDm7mZwFIzdNP/nLC2h1LdpuLz2Abgp6viX14BeHkFYDYJHLcAmP5VJfhWc5XJSdHnwQPARfEvBhi8mPRDDws1wBGw/1N1F8t6S6fI3GuSx34B+PGq+BeDBy+ujaCb1d24I2D0W7vBXxXpU/F5UAH4YSD689fzAQz9aGwpA4z6P0trz/BpLlDZqfs8OAF4fv16MXj8ctIM3VT/0sCr1E9wU+55KAHwfSnPrqJ/dn38bADAzWQSPN19WBn0nir7Oan4PFQBeHLV/dPB92eDOrjPAMcBALMffDJqd5a5jn6pNzx55CEIwHevRX/5+t/g+wiA4+TmL2CfJ71NHq4BePxa8Zev/w6+P7/bBRranhOgzC2VPfs88jAD4Kz4/1y/91/PJzPglZBfVdTmkYevIvjfpfz6+qt/8OtrAIaN/6Wmfhr6PGID8NdS/jX4+uf1+7PJX79Lb5NHgwD8vZR/lPLL9fsv18dPwbVsHnkEBuBvA+kPGXia/3fy2AMAfxjcCjP8fsz/O3k0f/wfg5rUWhyQPr4AAAAASUVORK5CYII=";var aM=/*#__PURE__*/function(){function e(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new n4,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},t4(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=((eR={})[eR.Position=1]="Position",eR[eR.Normal=2]="Normal",eR[eR.Tangent=4]="Tangent",eR[eR.All=7]="All",eR),aw=/*#__PURE__*/function(){function e(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new n4,this._dataChangeManager=new n4,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 aM(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(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()},t4(e,[{key:"frames",get:function(){return this._frames}}]),e}(),aF=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._format=t}return t4(e,[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),e}(),aL=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},aD=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t5(t,e),t.prototype.dispose=function(){},t}(aL),aB=/*#__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}t5(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=aS._getGLIndexType(e.format),this._glIndexByteCount=aS._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},t4(t,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t}(nm),aI=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._updateFlagManager=new n4,r._bounds=new tG,r._subMeshes=[],r.name=n,r._primitive=new aB(t),r._onBoundsChanged=r._onBoundsChanged.bind(r);var r,i=r._bounds;return i.min._onValueChanged=r._onBoundsChanged,i.max._onValueChanged=r._onBoundsChanged,r}t5(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 aD(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)},t4(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}(ns),aN=((eE={})[eE.Bounds=1]="Bounds",eE[eE.VertexElements=2]="VertexElements",eE),aO=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._stride=t}return t4(e,[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),e}(),aV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}t5(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 aO(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 aF(e,t))),this._setIndexBufferBinding(n)},t4(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}(aI),ak=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._enableVertexColor=!1,n._onMeshChanged=n._onMeshChanged.bind(n),n}t5(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){e.prototype._cloneTo.call(this,t),t.mesh=this._mesh},n._prepareRender=function(t){if(!this._mesh){nb.error("mesh is null.");return}if(this._mesh.destroyed){nb.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;tG.transform(n,this._transformEntity.transform.worldMatrix,e)}else{var r=this._transformEntity.transform.worldPosition;e.min.copyFrom(r),e.max.copyFrom(r)}},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._basicResources.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&aN.Bounds&&(this._dirtyUpdateFlag|=a_.WorldVolume),e&aN.VertexElements&&(this._dirtyUpdateFlag|=2)},t4(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}(ah);ak._enableVertexColorMacro=rc.getByName("RENDERER_ENABLE_VERTEXCOLOR"),ak._uvMacro=rc.getByName("RENDERER_HAS_UV"),ak._uv1Macro=rc.getByName("RENDERER_HAS_UV1"),ak._normalMacro=rc.getByName("RENDERER_HAS_NORMAL"),ak._tangentMacro=rc.getByName("RENDERER_HAS_TANGENT"),t6([nt],ak.prototype,"_mesh",void 0),t6([nt],ak.prototype,"_onMeshChanged",null);var aU=/*#__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 tZ,this._canUseTextureStoreData=!0,this._dataTextureInfo=new tU,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(rz))},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 aC("POSITION_BS"+i,r,ab.Vector3,n)),r+=12,this._useBlendNormal&&(e._setVertexElement(t++,new aC("NORMAL_BS"+i,r,ab.Vector3,n)),r+=12),this._useBlendTangent&&(e._setVertexElement(t++,new aC("TANGENT_BS"+i,r,ab.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?av.Static:av.Dynamic,g=new ax(n,aT.VertexBuffer,p,m);r._setVertexBufferBinding(d+h,new aO(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 nL(this._engine,r,i,o,n_.R32G32B32A32,!1,!1)).filterMode=nh.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),A=v*l,b=o[d];b||(o[d]=b=new tq),b.set(u+g,v*c);for(var S=m.deltaPositions,C=0;C<e;C++){var T=A+x*C,R=S[C];R&&(i[T]=R.x,i[T+1]=R.y,i[T+2]=R.z)}if(A+=3,this._useBlendNormal){var E=m.deltaNormals;if(E)for(var M=0;M<e;M++){var P=A+x*M,w=E[M];w&&(i[P]=w.x,i[P+1]=w.y,i[P+2]=w.z)}A+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=A+x*L,B=F[L];B&&(i[D]=B.x,i[D+1]=B.y,i[D+2]=B.z)}A+=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}();aU._blendShapeMacro=rc.getByName("RENDERER_HAS_BLENDSHAPE"),aU._blendShapeTextureMacro=rc.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),aU._blendShapeNormalMacro=rc.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),aU._blendShapeTangentMacro=rc.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),aU._blendShapeWeightsProperty=nH.getByName("renderer_BlendShapeWeights"),aU._blendShapeTextureProperty=nH.getByName("renderer_BlendShapeTexture"),aU._blendShapeTextureInfoProperty=nH.getByName("renderer_BlendShapeTextureInfo");var az=((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),aG=/*#__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 tU(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 aU(t,r),r}t5(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,az.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,az.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,az.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,az.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,az.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,az.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,az.UV,6,this._readVector2VertexData);return this._uv=t,t;case 1:var n=this._getVertexElementData(this._uv1,az.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var r=this._getVertexElementData(this._uv2,az.UV2,8,this._readVector2VertexData);return this._uv2=r,r;case 3:var i=this._getVertexElementData(this._uv3,az.UV3,9,this._readVector2VertexData);return this._uv3=i,i;case 4:var a=this._getVertexElementData(this._uv4,az.UV4,10,this._readVector2VertexData);return this._uv4=a,a;case 5:var o=this._getVertexElementData(this._uv5,az.UV5,11,this._readVector2VertexData);return this._uv5=o,o;case 6:var s=this._getVertexElementData(this._uv6,az.UV6,12,this._readVector2VertexData);return this._uv6=s,s;case 7:var l=this._getVertexElementData(this._uv7,az.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,t7(e,Uint8Array)?this._indicesFormat=aA.UInt8:t7(e,Uint16Array)?this._indicesFormat=aA.UInt16:t7(e,Uint32Array)&&(this._indicesFormat=aA.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[az.Position]||this.setPositions(null),i[az.Normal]||this.setNormals(null),i[az.Color]||this.setColors(null),i[az.BoneWeight]||this.setBoneWeights(null),i[az.BoneIndex]||this.setBoneIndices(null),i[az.Tangent]||this.setTangents(null),i[az.UV]||this.setUVs(null,0),i[az.UV1]||this.setUVs(null,1),i[az.UV2]||this.setUVs(null,2),i[az.UV3]||this.setUVs(null,3),i[az.UV4]||this.setUVs(null,4),i[az.UV5]||this.setUVs(null,5),i[az.UV6]||this.setUVs(null,6),i[az.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 aO(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 aF(u,this._indicesFormat));else{null==u||u.destroy();var d=new ax(this._engine,aT.IndexBuffer,c);this._setIndexBufferBinding(new aF(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 tZ,_[f]=new tU;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],A=e[v],b=r[m],S=r[g],C=r[v];tU.subtract(x,y,o),tU.subtract(A,y,s);var T=S.x-b.x,R=C.x-b.x,E=S.y-b.y,M=C.y-b.y,P=1/(T*M-R*E);tU.scale(o,M*P,l),tU.scale(s,E*P,u),tU.subtract(l,u,l),tU.scale(s,T*P,c),tU.scale(o,R*P,u),tU.subtract(c,u,c);var w=h[m];w.set(w.x+l.x,w.y+l.y,w.z+l.z,1),(w=h[g]).set(w.x+l.x,w.y+l.y,w.z+l.z,1),(w=h[v]).set(w.x+l.x,w.y+l.y,w.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),tU.cross(l,D,u);var I=tU.dot(u,L)>0?1:-1;tU.scale(L,tU.dot(l,L),u),tU.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 aH)).reset(),o()):t+1==i.length&&i.length--},n._getVertexTypedArray=function(e,t){switch(t){case nC.BYTE:return new Int8Array(e);case nC.UNSIGNED_BYTE:return new Uint8Array(e);case nC.SHORT:return new Int16Array(e);case nC.UNSIGNED_SHORT:return new Uint16Array(e);case nC.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?av.Static:av.Dynamic,u=new ax(this._engine,aT.VertexBuffer,i,c,!0);this._setVertexBufferBinding(s,new aO(u,t))}r.set(t,n,l?s:-1)}},n._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new tq(e[t],e[t+1])})},n._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new tU(e[t],e[t+1],e[t+2])})},n._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new tZ(e[t],e[t+1],e[t+2],e[t+3])})},n._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new tJ(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 aC(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,az.Position,1),2&e&&this._updateAdvancedVertexElement(this._normals,az.Normal,2),4&e&&this._updateAdvancedVertexElement(this._colors,az.Color,4),16&e&&this._updateAdvancedVertexElement(this._boneWeights,az.BoneWeight,16),32&e&&this._updateAdvancedVertexElement(this._boneIndices,az.BoneIndex,32),8&e&&this._updateAdvancedVertexElement(this._tangents,az.Tangent,8),64&e&&this._updateAdvancedVertexElement(this._uv,az.UV,64),128&e&&this._updateAdvancedVertexElement(this._uv1,az.UV1,128),256&e&&this._updateAdvancedVertexElement(this._uv2,az.UV2,256),512&e&&this._updateAdvancedVertexElement(this._uv3,az.UV3,512),1024&e&&this._updateAdvancedVertexElement(this._uv4,az.UV4,1024),2048&e&&this._updateAdvancedVertexElement(this._uv5,az.UV5,2048),4096&e&&this._updateAdvancedVertexElement(this._uv6,az.UV6,4096),8192&e&&this._updateAdvancedVertexElement(this._uv7,az.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 A=(y*f+_)/p;if(n(h,A,y),m)for(var b=0;b<g;b++)h[A+b]/=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(az.Position,0,e),t&&2&r&&this._writeVector3AdvancedVertexData(az.Normal,1,t),n&&4&r&&this._writeColorAdvancedVertexData(az.Color,2,n),i&&16&r&&this._writeVector4AdvancedVertexData(az.BoneWeight,4,i),a&&32&r&&this._writeVector4AdvancedVertexData(az.BoneIndex,5,a),o&&8&r&&this._writeVector4AdvancedVertexData(az.Tangent,3,o),s&&64&r&&this._writeVector2AdvancedVertexData(az.UV,6,s),l&&128&r&&this._writeVector2AdvancedVertexData(az.UV1,7,l),c&&256&r&&this._writeVector2AdvancedVertexData(az.UV2,8,c),u&&512&r&&this._writeVector2AdvancedVertexData(az.UV3,9,u),d&&1024&r&&this._writeVector2AdvancedVertexData(az.UV4,10,d),h&&2048&r&&this._writeVector2AdvancedVertexData(az.UV5,11,h),_&&4096&r&&this._writeVector2AdvancedVertexData(az.UV6,12,_),f&&8192&r&&this._writeVector2AdvancedVertexData(az.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 az.Position:case az.Normal:return ab.Vector3;case az.Color:case az.BoneWeight:case az.Tangent:return ab.Vector4;case az.BoneIndex:return ab.UByte4;case az.UV:case az.UV1:case az.UV2:case az.UV3:case az.UV4:case az.UV5:case az.UV6:case az.UV7:return ab.Vector2}},n._getAttributeByteLength=function(e){switch(e){case az.Position:case az.Normal:return 12;case az.Color:case az.BoneWeight:case az.Tangent:return 16;case az.BoneIndex:return 4;case az.UV:case az.UV1:case az.UV2:case az.UV3:case az.UV4:case az.UV5:case az.UV6:case az.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)}}},t4(t,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var e=0,t=this._primitive._vertexElementMap[az.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}(aI);aG._tempVec0=new tU,aG._tempVec1=new tU,aG._tempVec2=new tU,aG._tempVec3=new tU,aG._tempVec4=new tU;var aH=/*#__PURE__*/function(){function e(){this.dataVersion=-1,this.uploadAdvancedData=!1}return e.prototype.reset=function(){this.uploadAdvancedData=!1},e}(),aW=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).primitiveInfo=n,r}return t5(t,e),t.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:a0._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:a0._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:a0._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:a0._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:a0._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:a0._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:a0._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:a0._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t}(nl),aX=function(e,t,n){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=n},aj=/*#__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 t5(t,e),t}(aX),aY=/*#__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 t5(t,e),t}(aX),aK=/*#__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 t5(t,e),t}(aX),aQ=/*#__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 t5(t,e),t}(aX),aq=/*#__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 t5(t,e),t}(aX),aZ=/*#__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 t5(t,e),t}(aX),aJ=/*#__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 t5(t,e),t}(aX),a$=/*#__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 t5(t,e),t}(aX),a0=/*#__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 aG(t);e._setSphereData(a,n,r,i,!1);var o=a.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(a,new aj(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 aG(t);e._setSubdivisionSurfaceSphereData(a,n,r,i,!1);var o=a.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(a,new aY(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 aG(t);e._setCuboidData(o,n,r,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(o,new aK(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 aG(t);e._setPlaneData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(s,new aQ(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 aG(t);e._setCylinderData(l,n,r,i,a,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(l,new aq(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 aG(t);e._setTorusData(l,n,r,i,a,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(l,new aZ(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 aG(t);e._setConeData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(s,new aJ(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 aG(t);e._setCapsuleData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aW(s,new a$(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=tk.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],A=1/Math.sqrt(v*v+y*y+x*x);if(v*=A,y*=A,x*=A,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 b=8*(c+f++);h.set(h.subarray(g,g+8),b),h[b+6]=1,p[g/8]=b/8}}var S=0;this._spherePoleIdx=0;for(var C=0;C<u;C++){var T=4*C,R=l[T],E=l[T+1],M=l[T+2],P=l[T+3],w=8*R,F=8*E,L=8*M,D=8*P;h[w+2]+h[F+2]+h[L+2]<0&&(0===h[w+6]&&(R=p[R]),0===h[F+6]&&(E=p[E]),0===h[L+6]&&(M=p[M]),0===h[D+6]&&(P=p[P])),_[S]=R,_[S+1]=E,_[S+2]=M,this._generateAndReplacePoleUV(_,h,S,d),_[S+3]=R,_[S+4]=M,_[S+5]=P,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,A=Math.sin(x),b=-n*Math.cos(y)*A,S=n*Math.cos(x),C=n*Math.sin(y)*A,T=8*m;p[T++]=b,p[T++]=S,p[T++]=C,p[T++]=b,p[T++]=S,p[T++]=C,p[T++]=g,p[T++]=v}for(var R=0,E=0;E<c;++E){var M=E%r,P=(E*f|0)*s+M,w=P+1,F=P+s,L=F+1;u[R++]=w,u[R++]=P,u[R++]=L,u[R++]=P,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 tU,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 tU,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 A=x.edgePoint,b=u.facePoint;A.x+=.25*b.x,A.y+=.25*b.y,A.z+=.25*b.z}}var S=s+2,C=S+s,T=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 P=S+E,w=void 0,F=void 0,L=void 0,D=0;D<4;D++){var B=R[T++];switch(D){case 0:var I=M.adjacentEdges[D%4],N=M.adjacentEdges[(D+3)%4];F=this._calculateEdgeIndex(n,I,C),L=w=this._calculateEdgeIndex(n,N,C);break;case 1:case 2:var O=M.adjacentEdges[D%4];w=F,F=this._calculateEdgeIndex(n,O,C);break;case 3:w=F,F=L}var V=4*(4*E+D);r[V]=B,r[V+1]=F,r[V+2]=P,r[V+3]=w}}}},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 A=8*x+131;d[A++]=0,d[A++]=0,d[A++]=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 b=0;b<4;b++){var S=8*b+163;d[S++]=0,d[S++]=0,d[S++]=-1}var C=new Uint16Array(36);if(C[0]=0,C[1]=2,C[2]=1,C[3]=2,C[4]=0,C[5]=3,C[6]=4,C[7]=6,C[8]=7,C[9]=6,C[10]=4,C[11]=5,C[12]=8,C[13]=10,C[14]=9,C[15]=10,C[16]=8,C[17]=11,C[18]=12,C[19]=14,C[20]=15,C[21]=14,C[22]=12,C[23]=13,C[24]=16,C[25]=18,C[26]=17,C[27]=18,C[28]=16,C[29]=19,C[30]=20,C[31]=22,C[32]=23,C[33]=22,C[34]=20,C[35]=21,!o){var T=t.bounds;T.min.set(-l,-c,-u),T.max.set(l,c,u)}e._initialize(t,d,C,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,A=new Float32Array(8*p),b=0;b<p;++b){var S=b%c,C=b*v|0,T=8*b;A[T++]=S*_-d,A[T++]=0,A[T++]=C*f-h,A[T++]=0,A[T++]=1,A[T++]=0,A[T++]=S*y,A[T++]=C*x}for(var R=0,E=0;E<m;++E){var M=E%i,P=(E*y|0)*c+M,w=P+1,F=P+c,L=F+1;g[R++]=P,g[R++]=F,g[R++]=w,g[R++]=F,g[R++]=L,g[R++]=w}if(!s){var D=t.bounds;D.min.set(-d,0,-h),D.max.set(d,0,h)}e._initialize(t,A,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,A=1/o,b=new Float32Array(8*g),S=0,C=Math.PI,T=2*Math.PI,R=r-n,E=R/i,M=R/o,P=0;P<f;++P){var w=P%u,F=P*y|0,L=w*x,D=F*A,B=C+L*T,I=Math.sin(B),N=Math.cos(B),O=r-F*M,V=O*I,k=F*_-h,U=O*N,z=8*P;b[z++]=V,b[z++]=k,b[z++]=U,b[z++]=I,b[z++]=E,b[z++]=N,b[z++]=L,b[z++]=1-D}for(var G=0;G<p;++G){var H=G%a,W=(G*x|0)*u+H,X=W+1,j=W+u,Y=j+1;v[S++]=X,v[S++]=j,v[S++]=W,v[S++]=X,v[S++]=Y,v[S++]=j}var K=8*f;b[K++]=0,b[K++]=-h,b[K++]=0,b[K++]=0,b[K++]=-1,b[K++]=0,b[K++]=.5,b[K++]=.5,b[K++]=0,b[K++]=h,b[K++]=0,b[K++]=0,b[K++]=1,b[K++]=0,b[K++]=.5,b[K++]=.5,K=(f+2)*8;for(var Q=1/(2*n),q=1/(2*r),Z=u*o,J=0;J<a;++J){var $=8*J,ee=b[$],et=b[$+2];b[K++]=ee,b[K++]=-h,b[K++]=et,b[K++]=0,b[K++]=-1,b[K++]=0,b[K++]=ee*q+.5,b[K++]=.5-et*q;var en=(J+Z)*8;ee=b[en],et=b[en+2],b[K++]=ee,b[K++]=h,b[K++]=et,b[K++]=0,b[K++]=1,b[K++]=0,b[K++]=ee*Q+.5,b[K++]=.5-et*Q}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,b,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),A=Math.cos(v),b=Math.sin(v),S=(n+r*x)*A,C=(n+r*x)*b,T=r*Math.sin(y);_[f++]=S,_[f++]=C,_[f++]=T;var R=n*A,E=n*b;p.set(S-R,C-E,T).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 P=1;P<=a;P++){var w=(a+1)*M+P-1,F=(a+1)*(M-1)+P-1,L=(a+1)*(M-1)+P,D=(a+1)*M+P;h[f++]=w,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),A=0,b=Math.PI,S=2*Math.PI,C=n/r,T=0;T<_;++T){var R=T%c,E=T*g|0,M=R*v,P=E*y,w=b+M*S,F=Math.sin(w),L=Math.cos(w),D=n-P*n,B=D*F,I=E*h-d,N=D*L,O=8*T;x[O++]=B,x[O++]=I,x[O++]=N,x[O++]=F,x[O++]=C,x[O++]=L,x[O++]=M,x[O++]=1-P}for(var V=0;V<f;++V){var k=V%i,U=(V*v|0)*c+k,z=U+1,G=U+c,H=G+1;m[A++]=z,m[A++]=G,m[A++]=U,m[A++]=z,m[A++]=H,m[A++]=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 X=1/(2*n),j=0;j<i;++j){var Y=x[8*j],K=x[8*j+2];x[W++]=Y,x[W++]=-d,x[W++]=K,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=Y*X+.5,x[W++]=.5-K*X}for(var Q=_+1,q=0;q<i;++q){var Z=q,J=q===i-1?0:Z+1;m[A++]=_,m[A++]=Q+J,m[A++]=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,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,A=1/a,b=Math.PI,S=2*Math.PI,C=new Float32Array(8*g),T=0,R=0;R<_;++R){var E=R%c,M=R*y|0,P=E*x,w=M*A,F=b+P*S,L=Math.sin(F),D=Math.cos(F),B=8*R;C[B++]=n*L,C[B++]=M*h-d,C[B++]=n*D,C[B++]=L,C[B++]=0,C[B++]=D,C[B++]=P,C[B++]=1-w}for(var I=0;I<f;++I){var N=I%i,O=(I*x|0)*c+N,V=O+1,k=O+c,U=k+1;v[T++]=V,v[T++]=k,v[T++]=O,v[T++]=V,v[T++]=U,v[T++]=k}if(e._createCapsuleCap(n,r,i,b,S,_,1,C,v,T),e._createCapsuleCap(n,r,i,b,-S,_+p,-1,C,v,T+6*m),!s){var z=t.bounds;z.min.set(-n,-n-d,-n),z.max.set(n,n+d,n)}e._initialize(t,C,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 aC(az.Position,0,ab.Vector3,0),new aC(az.Normal,12,ab.Vector3,0),new aC(az.UV,24,ab.Vector2,0)];e.setVertexElements(o);var s=new ax(e.engine,aT.VertexBuffer,t,av.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(nT.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,A=Math.sin(x),b=e*Math.sin(y)*A,S=e*Math.cos(x)*o+d,C=e*Math.cos(y)*A,T=(m+a)*8;s[T++]=b,s[T++]=S,s[T++]=C,s[T++]=b,s[T++]=S-d,s[T++]=C,s[T++]=g,s[T++]=v}for(var R=0;R<_;++R){var E=R%n,M=(R*p|0)*u+E+a,P=M+1,w=M+u,F=w+1;l[c++]=P,l[c++]=M,l[c++]=F,l[c++]=M,l[c++]=w,l[c++]=F}},e}();a0._tempVec30=new tU,a0._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]),a0._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]),a0._sphereEdgeIdx=0,a0._spherePoleIdx=0;var a1=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n.inverseBindMatrices=[],n._updatedManager=new n4,n._bones=[],n._updateMark=-1,n.joints=[],n}return t5(t,e),t.prototype._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?nX._floatMatrixMultiply(s.transform.worldMatrix,r[o].elements,0,i,l):i.set(r[o].elements,l),nX._floatMatrixMultiply(a,i,l,i,l)}this._updateMark=e.engine.time.frameCount}},t4(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}(no);t6([ni],a1.prototype,"inverseBindMatrices",void 0),t6([nt],a1.prototype,"_skinMatrices",void 0),t6([nt],a1.prototype,"_updatedManager",void 0),t6([ni],a1.prototype,"_bones",void 0),t6([nt],a1.prototype,"_updateMark",void 0);var a2=((eP={})[eP.BoneCountChanged=0]="BoneCountChanged",eP[eP.RootBoneChanged=1]="RootBoneChanged",eP),a3=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._localBounds=new tG,n._jointDataCreateCache=new tq(-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}t5(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){e.prototype._cloneTo.call(this,t),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-(t._baseVertexUniformVectorCount+s))/4);if(l>h){var _,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(_=this._jointTexture)||_.destroy(),this._jointTexture=new nF(f,4,l,n_.R32G32B32A32,!1,!1),this._jointTexture.filterMode=nh.Point,this._jointTexture.isGCIgnored=!0),i.disableMacro("RENDERER_JOINTS_NUM"),i.enableMacro("RENDERER_USE_JOINT_TEXTURE"),i.setTexture(t._jointSamplerProperty,this._jointTexture)):nb.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)?tG.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|=a_.WorldVolume},n._onSkinUpdated=function(e,n){switch(e){case a2.BoneCountChanged:var r=this.shaderData;n>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(t._jointCountProperty,n)):r.disableMacro("RENDERER_HAS_SKIN");break;case a2.RootBoneChanged:this._setTransformEntity(n),this._dirtyUpdateFlag|=a_.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(a2.BoneCountChanged,u),c!==d&&this._onSkinUpdated(a2.RootBoneChanged,d)},t4(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}(ak);a3._baseVertexUniformVectorCount=48,a3._jointCountProperty=nH.getByName("renderer_JointCount"),a3._jointSamplerProperty=nH.getByName("renderer_JointSampler"),a3._jointMatrixProperty=nH.getByName("renderer_JointMatrix"),t6([nt],a3.prototype,"_condensedBlendShapeWeights",void 0),t6([ni],a3.prototype,"_localBounds",void 0),t6([nt],a3.prototype,"_jointDataCreateCache",void 0),t6([nt],a3.prototype,"_blendShapeWeights",void 0),t6([nt],a3.prototype,"_maxVertexUniformVectors",void 0),t6([nt],a3.prototype,"_jointTexture",void 0),t6([ni],a3.prototype,"_skin",void 0),t6([nt],a3.prototype,"_onLocalBoundsChanged",null),t6([nt],a3.prototype,"_onSkinUpdated",null);var a4=/*#__PURE__*/function(){function e(e){this.engine=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 r3(e,rM.find("blit"));r._addReferCount(1),r.renderState.depthState.enabled=!1,r.renderState.depthState.writeEnabled=!1;var i=new r3(e,rM.find("blit-screen"));i._addReferCount(1),i.renderState.depthState.enabled=!1,i.renderState.depthState.writeEnabled=!1,this.blitMaterial=r,this.blitScreenMaterial=i,this.blitMesh=this._createBlitMesh(e,t),this.flipYBlitMesh=this._createBlitMesh(e,n);var a=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(e,0,n_.R8G8B8A8,a,!0),this.whiteTextureCube=this._create1x1Texture(e,1,n_.R8G8B8A8,a,!0),e._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(e,2,n_.R8G8B8A8,a,!0);var o=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(e,0,n_.R32G32B32A32_UInt,o,!1)}this.spriteDefaultMaterial=this._create2DMaterial(e,rM.find("Sprite")),this.textDefaultMaterial=this._create2DMaterial(e,rM.find("Text")),this.spriteMaskDefaultMaterial=this._createSpriteMaskMaterial(e),this.meshMagentaMaterial=this._createMagentaMaterial(e,"unlit"),this.particleMagentaMaterial=this._createMagentaMaterial(e,"particle-shader")}var t=e.prototype;return t._getBlinnPhongMaterial=function(){return this._blinnPhongMaterial||(this._blinnPhongMaterial=new r8(this.engine))},t._initialize=function(){var e=this;return new Promise(function(t,n){aE.create(e.engine).then(function(n){e._prefilteredDFGTexture=n,t(e)}).catch(n)})},t._createBlitMesh=function(e,t){var n=new aG(e);n._addReferCount(1),n.setVertexElements([new aC("POSITION_UV",0,ab.Vector4,0)]);var r=new ax(e,aT.VertexBuffer,t,av.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 t5(t,e),t.prototype.restoreContent=function(){r.setData(r.data)},t}(nl))),n},t._create1x1Texture=function(e,t,n,r,i){var a;switch(t){case 0:var o=new nF(e,1,1,n,!1,i);o.setPixelBuffer(r),a=o;break;case 2:var s=new nL(e,1,1,1,n,!1,i);s.setPixelBuffer(0,r),a=s;break;case 1:for(var l=new nP(e,1,n,!1,i),c=0;c<6;c++)l.setPixelBuffer(nu.PositiveX+c,r);a=l;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 t5(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(nu.PositiveX+e,r)}},n}(nl))),a},t._create2DMaterial=function(e,t){var n=new r3(e,t),r=n.renderState,i=r.blendState.targetBlendState;return i.enabled=!0,i.sourceColorBlendFactor=n6.SourceAlpha,i.destinationColorBlendFactor=n6.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=n6.One,i.destinationAlphaBlendFactor=n6.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=n7.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=rn.Off,r.renderQueueType=rr.Transparent,n.isGCIgnored=!0,n},t._createMagentaMaterial=function(e,t){var n=new r3(e,rM.find(t));return n.isGCIgnored=!0,n.shaderData.setColor("material_BaseColor",new tJ(1,0,1.01,1)),n},t._createSpriteMaskMaterial=function(e){var t=new r3(e,rM.find("SpriteMask"));return t.isGCIgnored=!0,t},e.getMaskInteractionRenderStates=function(t){var n,r;if(t===n0.VisibleInsideMask){if(n=e._maskReadInsideRenderStates)return n;e._maskReadInsideRenderStates=n={},r=rt.LessEqual}else{if(n=e._maskReadOutsideRenderStates)return n;e._maskReadOutsideRenderStates=n={},r=rt.Greater}return n[ri.StencilStateEnabled]=!0,n[ri.StencilStateWriteMask]=0,n[ri.StencilStateReferenceValue]=1,n[ri.StencilStateCompareFunctionFront]=r,n[ri.StencilStateCompareFunctionBack]=r,n},e.getMaskTypeRenderStates=function(t){if(t===i8.Increment){if(n=e._maskWriteIncrementRenderStates)return n;e._maskWriteIncrementRenderStates=n={},r=rl.IncrementSaturate}else{if(n=e._maskWriteDecrementRenderStates)return n;e._maskWriteDecrementRenderStates=n={},r=rl.DecrementSaturate}n[ri.StencilStateEnabled]=!0,n[ri.StencilStatePassOperationFront]=r,n[ri.StencilStatePassOperationBack]=r,n[ri.StencilStateCompareFunctionFront]=rt.Always,n[ri.StencilStateCompareFunctionBack]=rt.Always;var n,r,i=rl.Keep;return n[ri.StencilStateFailOperationFront]=i,n[ri.StencilStateFailOperationBack]=i,n[ri.StencilStateZFailOperationFront]=i,n[ri.StencilStateZFailOperationBack]=i,n[ri.BlendStateColorWriteMask0]=re.None,n[ri.DepthStateEnabled]=!1,n[ri.RasterStateCullMode]=rn.Off,n},t4(e,[{key:"prefilteredDFGTexture",get:function(){return this._prefilteredDFGTexture}}]),e}();function a8(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a8=function(){return!!e})()}function a5(e,t,n){return(a5=a8()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&t8(i,n.prototype),i}).apply(null,arguments)}a4._maskReadInsideRenderStates=null,a4._maskReadOutsideRenderStates=null,a4._maskWriteIncrementRenderStates=null,a4._maskWriteDecrementRenderStates=null;var a9=/*#__PURE__*/function(){function e(){}return e.cloneComponent=function(e,t,n,r,i){var a=na.getCloneMode(e.constructor);for(var o in e)na.cloneProperty(e,t,o,a[o],n,r,i);null==e._cloneTo||e._cloneTo.call(e,t,n,r)},e}(),a6=((ew={})[ew.Parent=1]="Parent",ew[ew.Child=2]="Child",ew),a7=/*#__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=rU.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new nQ,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._isTemplate=!1,r._updateFlagManager=new n4,r._parent=null,r._invModelMatrix=new tK,r.name=null!=n?n:"Entity";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}t5(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];rO._addCheck(this,e);var i=a5(e,[].concat([this],n));return this._components.push(i),t7(i,rG)&&this._setTransform(i),i._setActive(!0,rI.All),i},n.getComponent=function(e){for(var t=this._components,n=0,r=t.length;n<r;n++){var i=t[n];if(t7(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];t7(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,t){var n;"number"==typeof e?n=e:(n=void 0,t=e),t._setParent(this,n)},n.removeChild=function(e){e._parent===this&&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){var n=e.split("/").filter(Boolean);return n.length?t._findChildByName(this,0,n,0):this},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=rI.None;r._isActiveInHierarchy&&(i|=rI.Hierarchy),r._isActiveInScene&&(i|=rI.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(rz)},n._remap=function(e,t){return rB.remapEntity(e,t,this)},n._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},n._createCloneEntity=function(){for(var e=t._tempComponentConstructors,n=this._components,r=0,i=n.length;r<i;r++)e[r]=n[r].constructor;var a=a5(t,[].concat([this.engine,this.name],e));e.length=0;var o=this._templateResource;o&&(a._templateResource=o,o._addReferCount(1)),a.layer=this.layer,a._isActive=this._isActive;for(var s=this._children,l=0,c=s.length;l<c;l++)a.addChild(s[l]._createCloneEntity());return a},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++)a9.cloneComponent(c[u],t._components[u],n,r,i)},n.destroy=function(){if(e.prototype.destroy.call(this),this._destroyed){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){rO._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;null!=e&&(t._removeFromChildren(e._children,this),this._parent=null,e._dispatchModify(a6.Child,e))},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._setParentChange=function(){this._transform._parentChange(),this._dispatchModify(a6.Parent,this)},n._registerModifyListener=function(e){(this._modifyFlagManager||(this._modifyFlagManager=new n4)).addListener(e)},n._unRegisterModifyListener=function(e){var t;null==(t=this._modifyFlagManager)||t.removeListener(e)},n._dispatchModify=function(e,t){var n;null==(n=this._modifyFlagManager)||n.dispatch(e,t)},n._addToChildrenList=function(e,n){t._addToChildren(this._children,n,e),this._dispatchModify(a6.Child,this)},n._setParent=function(e,n){var r=this._parent;if(e!==r){if(this._isRoot?(t._removeFromChildren(this._scene._rootEntities,this),this._isRoot=!1):this._removeFromParent(),this._parent=e,e){this._isRoot=!1,e._addToChildrenList(n,this);var i=this._scene,a=e._scene,o=rI.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(o|=rI.Hierarchy),e._isActiveInScene?this._isActiveInScene&&i!==a&&(o|=rI.Scene):this._isActiveInScene&&(o|=rI.Scene),o&&this._processInActive(o),i!==a&&t._traverseSetOwnerScene(this,a);var s=rI.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(s|=rI.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&i===a||(s|=rI.Scene))),s&&this._processActive(s)}else{var l=rI.None;this._isActiveInHierarchy&&(l|=rI.Hierarchy),this._isActiveInScene&&(l|=rI.Scene),l&&this._processInActive(l),r&&t._traverseSetOwnerScene(this,null)}this._setParentChange()}else e&&void 0!==n&&(this.siblingIndex=n)},n._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];t7(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&rI.Hierarchy&&(this._isActiveInHierarchy=!0),t&rI.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&rI.Hierarchy&&(this._isActiveInHierarchy=!1),t&rI.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._setTransform=function(e){null==(t=this._transform)||t.destroy(),this._transform=e;for(var t,n,r=this._children,i=0,a=r.length;i<a;i++)null==(n=r[i].transform)||n._parentChange()},n.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(tK.invert(this._transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t._findChildByName=function(e,n,r,i){for(var a=r[i],o=i===r.length-1,s=e._children,l=s.length;n<l;n++){var c=s[n];if(c.name===a)return o?c:t._findChildByName(c,0,r,i+1)}return 0===i?null:t._findChildByName(e.parent,e.siblingIndex+1,r,i-1)},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._removeFromChildren=function(e,t){for(var n=e.length-1,r=t._siblingIndex;r<n;r++){var i=e[r+1];e[r]=i,i._siblingIndex=r}e.length=n,t._siblingIndex=-1},t._addToChildren=function(e,t,n){var r=e.length;if(e.length=r+1,void 0===n)e[r]=t,t._siblingIndex=r;else{if(n<0||n>r)throw"The index "+n+" is out of child list bounds "+r;for(var i=r;i>n;i--){var a=e[i-1];a._siblingIndex=i,e[i]=a}t._siblingIndex=n,e[n]=t}},t4(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=rI.None;this._isRoot&&this._scene._isActiveInEngine?n|=rI.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=rI.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=rI.Scene)),n&&this._processActive(n)}else{var r=rI.None;this._isActiveInHierarchy&&(r|=rI.Hierarchy),this._isActiveInScene&&(r|=rI.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";if(this._isRoot)this._setSiblingIndex(this._scene._rootEntities,e);else{var t=this._parent;this._setSiblingIndex(t._children,e),t._dispatchModify(a6.Child,t)}}}]),t}(no);a7._tempComponentConstructors=[];var oe=/*#__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}(),ot=/*#__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}t5(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}(oe),on=/*#__PURE__*/function(){function e(){}return e.prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},e}(),or=/*#__PURE__*/function(){function e(e,t){this.start=e,this.size=t}return e.prototype.dispose=function(){},e}(),oi=/*#__PURE__*/function(){function e(e,t){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new aB(e);n.addVertexElement(new aC("POSITION",0,ab.Vector3,0)),n.addVertexElement(new aC("TEXCOORD_0",12,ab.Vector2,0)),n.addVertexElement(new aC("COLOR_0",20,ab.Vector4,0)),n._addReferCount(1);var r=new ax(e,aT.VertexBuffer,36*t,av.Dynamic,!0);n.setVertexBufferBinding(0,new aO(r,36));var i=new ax(e,aT.IndexBuffer,8*t,av.Dynamic,!0);n.setIndexBufferBinding(new aF(i,aA.UInt16)),this.primitive=n,this.vertices=new Float32Array(r.data.buffer),this.indices=new Uint16Array(i.data.buffer),this.vertexFreeAreas=[new or(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=aR.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,ay.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER),e.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,ay.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}();oi.areaPool=new ot(or,10),oi.subChunkPool=new ot(on,10),oi.subMeshPool=new ot(aD,10);var oa=/*#__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 oi(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}(),oo=/*#__PURE__*/function(){function e(e){this.engine=e}var t=e.prototype;return t.destroy=function(){this._primitiveChunkManager2D&&(this._primitiveChunkManager2D.destroy(),this._primitiveChunkManager2D=null),this._primitiveChunkManagerMask&&(this._primitiveChunkManagerMask.destroy(),this._primitiveChunkManagerMask=null),this._primitiveChunkManagerUI&&(this._primitiveChunkManagerUI.destroy(),this._primitiveChunkManagerUI=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(){var e,t,n;null==(e=this._primitiveChunkManager2D)||e.uploadBuffer(),null==(t=this._primitiveChunkManagerMask)||t.uploadBuffer(),null==(n=this._primitiveChunkManagerUI)||n.uploadBuffer()},t4(e,[{key:"primitiveChunkManager2D",get:function(){return this._primitiveChunkManager2D||(this._primitiveChunkManager2D=new oa(this.engine))}},{key:"primitiveChunkManagerMask",get:function(){return this._primitiveChunkManagerMask||(this._primitiveChunkManagerMask=new oa(this.engine,128))}},{key:"primitiveChunkManagerUI",get:function(){return this._primitiveChunkManagerUI||(this._primitiveChunkManagerUI=new oa(this.engine))}}]),e}(),os=/*#__PURE__*/function(){function e(e){this._freeRenderTargets=[],this._freeTextures=[],this._engine=e}var t=e.prototype;return t.allocateRenderTarget=function(t,n,r,i,a,o,s,l,c,u){for(var d,h=this._freeRenderTargets,_=h.length-1;_>=0;_--){var f=h[_];if(e._matchRenderTarget(f,t,n,r,i,a,o,s,l)){h[_]=h[h.length-1],h.length--;var p=f.getColorTexture(0);p&&(p.wrapModeU=p.wrapModeV=c,p.filterMode=u);var m=f.depthTexture;return m&&(m.wrapModeU=m.wrapModeV=c,m.filterMode=u),f}}var g=this._engine,v=null;if(null!=r&&((v=new nF(g,t,n,r,o,s)).isGCIgnored=!0,v.wrapModeU=v.wrapModeV=c,v.filterMode=u),a){var y=null;i&&((y=new nF(g,t,n,i,o,s)).isGCIgnored=!0,y.wrapModeU=y.wrapModeV=c,y.filterMode=u),d=new nw(g,t,n,v,y,l)}else d=new nw(g,t,n,v,i,l);return d.isGCIgnored=!0,d},t.allocateTexture=function(e,t,n,r,i,a,o){for(var s=this._freeTextures,l=s.length-1;l>=0;l--){var c=s[l];if(c.width===e&&c.height===t&&c.format===n&&c.mipmapCount>1===r&&c.isSRGBColorSpace===i)return s[l]=s[s.length-1],s.length--,c.wrapModeU=c.wrapModeV=a,c.filterMode=o,c}var u=new nF(this._engine,e,t,n,r,i);return u.isGCIgnored=!0,u.wrapModeU=u.wrapModeV=a,u.filterMode=o,u},t.freeRenderTarget=function(e){e&&!e.destroyed&&this._freeRenderTargets.push(e)},t.freeTexture=function(e){e&&!e.destroyed&&this._freeTextures.push(e)},t.gc=function(){for(var e=this._freeRenderTargets,t=0,n=e.length;t<n;t++){var r=e[t],i=r.getColorTexture(0),a=r.depthTexture;r.destroy(!0),null==i||i.destroy(!0),a&&a!==i&&a.destroy(!0)}e.length=0;for(var o=this._freeTextures,s=0,l=o.length;s<l;s++)o[s].destroy(!0);o.length=0},e._matchRenderTarget=function(e,t,n,r,i,a,o,s,l){if(e.width!==t||e.height!==n||e.antiAliasing!==l)return!1;var c=e.getColorTexture(0);if(null!=r){if(!c||c.format!==r||c.mipmapCount>1!==o||c.isSRGBColorSpace!==s)return!1}else if(c)return!1;var u=e.depthTexture;if(a){if(i){if(!u||u.format!==i)return!1}else if(u)return!1}else if(e._depthFormat!==i)return!1;return!0},e}(),ol=((eF={}).Text="Text",eF.JSON="JSON",eF.Buffer="Buffer",eF.Texture2D="Texture2D",eF.TextureCube="TextureCube",eF.Material="Material",eF.Shader="Shader",eF.Mesh="Mesh",eF.AnimationClip="AnimationClip",eF.AnimatorController="AnimatorController",eF.Prefab="Prefab",eF.GLTF="GLTF",eF.KTX="KTX",eF.KTXCube="KTXCube",eF.KTX2="KTX2",eF.Sprite="Sprite",eF.PrimitiveMesh="PrimitiveMesh",eF.SpriteAtlas="SpriteAtlas",eF.AmbientLight="AmbientLight",eF.Scene="Scene",eF.Font="Font",eF.SourceFont="SourceFont",eF.Audio="Audio",eF.Project="project",eF.PhysicsMaterial="PhysicsMaterial",eF.RenderTarget="RenderTarget",eF),oc=/*#__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},t4(e,[{key:"length",get:function(){return this._array.length}}]),e}(),ou=/*#__PURE__*/function(){function e(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new oc}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:ol.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()},t4(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}(),od=/*#__PURE__*/function(){function e(){this._textureMemory=0,this._bufferMemory=0}return e.prototype._reset=function(){this._textureMemory=0,this._bufferMemory=0},t4(e,[{key:"textureMemory",get:function(){return this._textureMemory}},{key:"bufferMemory",get:function(){return this._bufferMemory}},{key:"totalMemory",get:function(){return this._textureMemory+this._bufferMemory}}]),e}(),oh={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},o_=1/0;function of(e,t){return void 0===t&&(t={}),new nS(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:o_,t.type=null!=(c=t.type)?c:oh[e.substring(e.lastIndexOf(".")+1)],new op(function(){var n;return(n=t,new nS(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.withCredentials="include"===n.credentials,s.responseType=l?"blob":n.type,s.onload=function(){if(s.status<200||s.status>=300){r(Error("Request failed from: "+e));return}var n=s.response;if(!n){r(Error("Request "+e+" response is empty, please check the config."));return}if(l){var a=new Image;a.onload=function(){requestAnimationFrame(function(){i(1,1),t(a),a.onload=null,a.onerror=null,a.onabort=null,URL.revokeObjectURL(a.src)})},a.onerror=a.onabort=function(){r(Error("request "+a.src+" fail")),URL.revokeObjectURL(a.src)},a.crossOrigin="anonymous",a.src=URL.createObjectURL(n)}else i(1,1),t(n)},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);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 op=/*#__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}(),om=/*#__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._virtualPathResourceMap=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 nS.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];t7(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()}):nX.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},t.gc=function(){this._gc(!1),this.engine._renderTargetPool.gc(),this.engine._pendingGC()},t.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},t._getRemoteUrl=function(e){var t,n;return null!=(n=null==(t=this._virtualPathResourceMap[e])?void 0:t.path)?n:e},t._requestByRemoteUrl=function(e,t){return of(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,s=null!=(a=null==(r=this._virtualPathResourceMap[e])?void 0:r.path)?a:e,l=null==(i=this._subAssetPromiseCallbacks[s])?void 0:i[t];l?l.resolve(n):((o=this._subAssetPromiseCallbacks)[s]||(o[s]={}))[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;!nX.isAbsoluteUrl(o)&&this.baseUrl&&(o=nX.resolveAbsoluteUrl(this.baseUrl,o));var s=this._parseURL(o),l=s.assetBaseURL,c=s.queryPath,u=c?this._parseQueryPath(c):[],d=this._virtualPathResourceMap[l],h=null!=(n=null==d?void 0:d.path)?n:l,_=this._assetUrlPool[h];if(_)return new nS(function(e){e(i._getResolveResource(_,u))});var f=h;if(c)for(f+="?q="+u.shift();r=u.shift();)f+="["+r+"]";var p=this._loadingPromises,m=p[f];if(m)return new nS(function(e,t,n,r){m.onProgress(n,r).then(function(t){e(t)}).catch(function(e){t(e)})});var g=e._loaders[a.type];if(!g)throw"loader not found: "+a.type;var v=null==d?void 0:d.subpackageName;return c?((p[h]||this._loadSubpackageAndMainAsset(g,a,h,l,v)).catch(function(e){i._onSubAssetFail(h,c,e)}),this._createSubAssetPromiseCallback(h,f,c)):this._loadSubpackageAndMainAsset(g,a,h,l,v)},t._loadSubpackageAndMainAsset=function(e,t,n,r,i){return this._loadMainAsset(e,t,n,r)},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 nS(function(e,t){s?e(s):l&&t(l)});var c=new nS(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=nX.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)===ov&&t.push(""),e.replace(ox,function(e,n,r,i){var a=e;r?a=i.replace(oy,"$1"):n&&(a=n.trim()),t.push(a)}),t},t._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},t.getResourceByRef=function(e){var t=e.url,n=e.key,r=e.isClone;if(!t)return nb.warn("ResourceManager.getResourceByRef: url is empty."),nS.resolve(null);var i=this._objectPool[t];if(i)return nS.resolve(r?i.clone():i);var a=this._virtualPathResourceMap[t];if(!a)return nb.warn('ResourceManager.getResourceByRef: url "'+t+'" not found in virtualPathResourceMap.'),nS.resolve(null);var o=this.load({url:n?t+"?q="+n:t,type:a.type,params:a.params});return r?o.then(function(e){return e.clone()}):o},t.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathResourceMap[e.virtualPath]=e,e.dependentAssetMap&&(t._virtualPathResourceMap[e.virtualPath].dependentAssetMap=e.dependentAssetMap)})},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 og(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);om._addLoader(e,i,t)}}om._loaders={},om._extTypeMapping={};var ov=46,oy=/\\(\\)?/g,ox=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),oA=((eL={})[eL.None=0]="None",eL[eL.Primary=1]="Primary",eL[eL.Secondary=2]="Secondary",eL[eL.Auxiliary=4]="Auxiliary",eL[eL.XButton1=8]="XButton1",eL[eL.XButton2=16]="XButton2",eL[eL.XButton3=32]="XButton3",eL[eL.XButton4=64]="XButton4",eL[eL.XButton5=128]="XButton5",eL[eL.XButton6=256]="XButton6",eL[eL.XButton7=512]="XButton7",eL[eL.XButton8=1024]="XButton8",eL),ob=[1,4,2,8,16,32,64,128,256,512,1024],oS={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},oC=((eD={})[eD.Backquote=0]="Backquote",eD[eD.Backslash=1]="Backslash",eD[eD.Backspace=2]="Backspace",eD[eD.BracketLeft=3]="BracketLeft",eD[eD.BracketRight=4]="BracketRight",eD[eD.Comma=5]="Comma",eD[eD.Digit0=6]="Digit0",eD[eD.Digit1=7]="Digit1",eD[eD.Digit2=8]="Digit2",eD[eD.Digit3=9]="Digit3",eD[eD.Digit4=10]="Digit4",eD[eD.Digit5=11]="Digit5",eD[eD.Digit6=12]="Digit6",eD[eD.Digit7=13]="Digit7",eD[eD.Digit8=14]="Digit8",eD[eD.Digit9=15]="Digit9",eD[eD.Equal=16]="Equal",eD[eD.IntlBackslash=17]="IntlBackslash",eD[eD.IntlRo=18]="IntlRo",eD[eD.IntlYen=19]="IntlYen",eD[eD.KeyA=20]="KeyA",eD[eD.KeyB=21]="KeyB",eD[eD.KeyC=22]="KeyC",eD[eD.KeyD=23]="KeyD",eD[eD.KeyE=24]="KeyE",eD[eD.KeyF=25]="KeyF",eD[eD.KeyG=26]="KeyG",eD[eD.KeyH=27]="KeyH",eD[eD.KeyI=28]="KeyI",eD[eD.KeyJ=29]="KeyJ",eD[eD.KeyK=30]="KeyK",eD[eD.KeyL=31]="KeyL",eD[eD.KeyM=32]="KeyM",eD[eD.KeyN=33]="KeyN",eD[eD.KeyO=34]="KeyO",eD[eD.KeyP=35]="KeyP",eD[eD.KeyQ=36]="KeyQ",eD[eD.KeyR=37]="KeyR",eD[eD.KeyS=38]="KeyS",eD[eD.KeyT=39]="KeyT",eD[eD.KeyU=40]="KeyU",eD[eD.KeyV=41]="KeyV",eD[eD.KeyW=42]="KeyW",eD[eD.KeyX=43]="KeyX",eD[eD.KeyY=44]="KeyY",eD[eD.KeyZ=45]="KeyZ",eD[eD.Minus=46]="Minus",eD[eD.Period=47]="Period",eD[eD.Quote=48]="Quote",eD[eD.Semicolon=49]="Semicolon",eD[eD.Slash=50]="Slash",eD[eD.AltLeft=51]="AltLeft",eD[eD.AltRight=52]="AltRight",eD[eD.CapsLock=53]="CapsLock",eD[eD.ContextMenu=54]="ContextMenu",eD[eD.ControlLeft=55]="ControlLeft",eD[eD.ControlRight=56]="ControlRight",eD[eD.Enter=57]="Enter",eD[eD.MetaLeft=58]="MetaLeft",eD[eD.MetaRight=59]="MetaRight",eD[eD.ShiftLeft=60]="ShiftLeft",eD[eD.ShiftRight=61]="ShiftRight",eD[eD.Space=62]="Space",eD[eD.Tab=63]="Tab",eD[eD.Convert=64]="Convert",eD[eD.KanaMode=65]="KanaMode",eD[eD.Lang1=66]="Lang1",eD[eD.Lang2=67]="Lang2",eD[eD.Lang3=68]="Lang3",eD[eD.Lang4=69]="Lang4",eD[eD.Lang5=70]="Lang5",eD[eD.NonConvert=71]="NonConvert",eD[eD.Delete=72]="Delete",eD[eD.End=73]="End",eD[eD.Help=74]="Help",eD[eD.Home=75]="Home",eD[eD.Insert=76]="Insert",eD[eD.PageDown=77]="PageDown",eD[eD.PageUp=78]="PageUp",eD[eD.ArrowDown=79]="ArrowDown",eD[eD.ArrowLeft=80]="ArrowLeft",eD[eD.ArrowRight=81]="ArrowRight",eD[eD.ArrowUp=82]="ArrowUp",eD[eD.NumLock=83]="NumLock",eD[eD.Numpad0=84]="Numpad0",eD[eD.Numpad1=85]="Numpad1",eD[eD.Numpad2=86]="Numpad2",eD[eD.Numpad3=87]="Numpad3",eD[eD.Numpad4=88]="Numpad4",eD[eD.Numpad5=89]="Numpad5",eD[eD.Numpad6=90]="Numpad6",eD[eD.Numpad7=91]="Numpad7",eD[eD.Numpad8=92]="Numpad8",eD[eD.Numpad9=93]="Numpad9",eD[eD.NumpadAdd=94]="NumpadAdd",eD[eD.NumpadBackspace=95]="NumpadBackspace",eD[eD.NumpadClear=96]="NumpadClear",eD[eD.NumpadClearEntry=97]="NumpadClearEntry",eD[eD.NumpadComma=98]="NumpadComma",eD[eD.NumpadDecimal=99]="NumpadDecimal",eD[eD.NumpadDivide=100]="NumpadDivide",eD[eD.NumpadEnter=101]="NumpadEnter",eD[eD.NumpadEqual=102]="NumpadEqual",eD[eD.NumpadHash=103]="NumpadHash",eD[eD.NumpadMemoryAdd=104]="NumpadMemoryAdd",eD[eD.NumpadMemoryClear=105]="NumpadMemoryClear",eD[eD.NumpadMemoryRecall=106]="NumpadMemoryRecall",eD[eD.NumpadMemoryStore=107]="NumpadMemoryStore",eD[eD.NumpadMemorySubtract=108]="NumpadMemorySubtract",eD[eD.NumpadMultiply=109]="NumpadMultiply",eD[eD.NumpadParenLeft=110]="NumpadParenLeft",eD[eD.NumpadParenRight=111]="NumpadParenRight",eD[eD.NumpadStar=112]="NumpadStar",eD[eD.NumpadSubtract=113]="NumpadSubtract",eD[eD.Escape=114]="Escape",eD[eD.F1=115]="F1",eD[eD.F2=116]="F2",eD[eD.F3=117]="F3",eD[eD.F4=118]="F4",eD[eD.F5=119]="F5",eD[eD.F6=120]="F6",eD[eD.F7=121]="F7",eD[eD.F8=122]="F8",eD[eD.F9=123]="F9",eD[eD.F10=124]="F10",eD[eD.F11=125]="F11",eD[eD.F12=126]="F12",eD[eD.F13=127]="F13",eD[eD.F14=128]="F14",eD[eD.F15=129]="F15",eD[eD.Fn=130]="Fn",eD[eD.FnLock=131]="FnLock",eD[eD.PrintScreen=132]="PrintScreen",eD[eD.ScrollLock=133]="ScrollLock",eD[eD.Pause=134]="Pause",eD[eD.BrowserBack=135]="BrowserBack",eD[eD.BrowserFavorites=136]="BrowserFavorites",eD[eD.BrowserForward=137]="BrowserForward",eD[eD.BrowserHome=138]="BrowserHome",eD[eD.BrowserRefresh=139]="BrowserRefresh",eD[eD.BrowserSearch=140]="BrowserSearch",eD[eD.BrowserStop=141]="BrowserStop",eD[eD.Eject=142]="Eject",eD[eD.LaunchApp1=143]="LaunchApp1",eD[eD.LaunchApp2=144]="LaunchApp2",eD[eD.LaunchMail=145]="LaunchMail",eD[eD.MediaPlayPause=146]="MediaPlayPause",eD[eD.MediaSelect=147]="MediaSelect",eD[eD.MediaStop=148]="MediaStop",eD[eD.MediaTrackNext=149]="MediaTrackNext",eD[eD.MediaTrackPrevious=150]="MediaTrackPrevious",eD[eD.Power=151]="Power",eD[eD.Sleep=152]="Sleep",eD[eD.AudioVolumeDown=153]="AudioVolumeDown",eD[eD.AudioVolumeMute=154]="AudioVolumeMute",eD[eD.AudioVolumeUp=155]="AudioVolumeUp",eD[eD.WakeUp=156]="WakeUp",eD[eD.Hyper=157]="Hyper",eD[eD.Super=158]="Super",eD[eD.Turbo=159]="Turbo",eD[eD.Abort=160]="Abort",eD[eD.Resume=161]="Resume",eD[eD.Suspend=162]="Suspend",eD[eD.Again=163]="Again",eD[eD.Copy=164]="Copy",eD[eD.Cut=165]="Cut",eD[eD.Find=166]="Find",eD[eD.Open=167]="Open",eD[eD.Paste=168]="Paste",eD[eD.Props=169]="Props",eD[eD.Select=170]="Select",eD[eD.Undo=171]="Undo",eD[eD.Hiragana=172]="Hiragana",eD[eD.Katakana=173]="Katakana",eD[eD.Unidentified=174]="Unidentified",eD),oT=/*#__PURE__*/function(){function e(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new nQ,this._curFrameDownList=new nQ,this._curFrameUpList=new nQ,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=oC[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,nR.platform===t2.Mac&&(d===oC.MetaLeft||d===oC.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}(),oR=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._usedElementCount=0,n._elements=[],n}t5(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}(oe),oE=((eB={})[eB.Down=0]="Down",eB[eB.Move=1]="Move",eB[eB.Stationary=2]="Stationary",eB[eB.Up=3]="Up",eB[eB.Leave=4]="Leave",eB),oM=/*#__PURE__*/function(){function e(e){this.phase=oE.Leave,this.position=new tq,this.deltaPosition=new tq,this._events=[],this._upMap=[],this._downMap=[],this._upList=new nQ,this._downList=new nQ,this._frameEvents=0,this._emitters=[],this.id=e}var t=e.prototype;return t._addEmitters=function(e,t){this._emitters.push(new e(t))},t._resetOnFrameBegin=function(){this._frameEvents=0,this._events.length=this._upList.length=this._downList.length=0},t._dispose=function(){for(var e=this._emitters,t=0,n=e.length;t<n;t++)e[t].dispose();this._events.length=this._upList.length=this._downList.length=0},e}(),oP=((eI={})[eI.None=0]="None",eI[eI.Down=1]="Down",eI[eI.Up=2]="Up",eI[eI.Leave=4]="Leave",eI[eI.Move=8]="Move",eI[eI.Cancel=16]="Cancel",eI),ow=/*#__PURE__*/function(){function e(){this.worldPosition=new tU}return e.prototype.dispose=function(){this.pointer=null},e}(),oF=/*#__PURE__*/function(){function e(e){this._pool=e,this._init()}var t=e.prototype;return t._createEventData=function(e){var t=this._pool.get();return t.pointer=e,t.worldPosition.copyFrom(this._hitResult.point),t},t._fireDown=function(e,t){e._scripts.forEach(function(e){null==e.onPointerDown||e.onPointerDown.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireUp=function(e,t){e._scripts.forEach(function(e){null==e.onPointerUp||e.onPointerUp.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireClick=function(e,t){e._scripts.forEach(function(e){null==e.onPointerClick||e.onPointerClick.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireEnter=function(e,t){e._scripts.forEach(function(e){null==e.onPointerEnter||e.onPointerEnter.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireExit=function(e,t){e._scripts.forEach(function(e){null==e.onPointerExit||e.onPointerExit.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireBeginDrag=function(e,t){e._scripts.forEach(function(e){null==e.onPointerBeginDrag||e.onPointerBeginDrag.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireDrag=function(e,t){e._scripts.forEach(function(e){null==e.onPointerDrag||e.onPointerDrag.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireEndDrag=function(e,t){e._scripts.forEach(function(e){null==e.onPointerEndDrag||e.onPointerEndDrag.call(e,t)},function(e,t){e._entityScriptsIndex=t})},t._fireDrop=function(e,t){e._scripts.forEach(function(e){null==e.onPointerDrop||e.onPointerDrop.call(e,t)},function(e,t){e._entityScriptsIndex=t})},e}();oF._tempRay=new tQ;var oL=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}t5(t,e);var n=t.prototype;return n.processRaycast=function(e,t){for(var n=oF._tempRay,r=t.position,i=r.x,a=r.y,o=this._hitResult,s=e.length-1;s>=0;s--){var l=e[s];if(l.isActive&&!l.destroyed)for(var c=l._componentsManager._activeCameras,u=l.physics,d=c.length-1;d>=0;d--){var h=c.get(d);if(!h.renderTarget){var _=h.pixelViewport;if(i<_.x||a<_.y||i>_.x+_.width||a>_.y+_.height)continue;if(h.screenPointToRay(t.position,n),u.raycast(n,h.farClipPlane,h.cullingMask,o)){this._updateRaycast(o.entity,t);return}if(h.clearFlags&rj.Color){this._updateRaycast(null,t);return}}}}this._updateRaycast(null,t)},n.processDrag=function(e){var t=this._draggedEntity;t&&this._fireDrag(t,this._createEventData(e))},n.processDown=function(e){var t=this._pressedEntity=this._draggedEntity=this._enteredEntity;if(t){var n=this._createEventData(e);this._fireDown(t,n),this._fireBeginDrag(t,n)}},n.processUp=function(e){var t=this._enteredEntity,n=this._draggedEntity;if(t){var r=this._pressedEntity===t,i=this._createEventData(e);this._fireUp(t,i),r&&this._fireClick(t,i),this._fireDrop(t,i)}this._pressedEntity=null,n&&(this._fireEndDrag(n,this._createEventData(e)),this._draggedEntity=null)},n.processLeave=function(e){var t=this._enteredEntity;t&&(this._fireExit(t,this._createEventData(e)),this._enteredEntity=null);var n=this._draggedEntity;n&&(this._fireEndDrag(n,this._createEventData(e)),this._draggedEntity=null),this._pressedEntity=null},n.dispose=function(){this._enteredEntity=this._pressedEntity=this._draggedEntity=null},n._init=function(){this._hitResult=new iI},n._updateRaycast=function(e,t){var n=this._enteredEntity;e!==n&&(n&&this._fireExit(n,this._createEventData(t)),e&&this._fireEnter(e,this._createEventData(t)),this._enteredEntity=e)},t}(oF),oD=/*#__PURE__*/function(){function e(e,t){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=oA.None,this._upMap=[],this._downMap=[],this._upList=new nQ,this._downList=new nQ,this._nativeEvents=[],this._eventPool=new oR(ow),"undefined"!=typeof Window&&t7(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(){var t,n=this._pointers,r=this._nativeEvents,i=this._htmlCanvas,a=this._engine,o=this._eventPool,s=this._canvas,l=s.width,c=s.height,u=i.clientWidth,d=i.clientHeight,h=i.getBoundingClientRect(),_=h.left,f=h.top,p=l/u,m=c/d;o.clear();for(var g=n.length-1;g>=0;g--){var v=n[g];v.phase===oE.Leave?(v._dispose(),n.splice(g,1)):v._resetOnFrameBegin()}for(var y=0,x=r.length;y<x;y++)t=this,function(i,s){var l=r[i],c=l.pointerId,u=t._getPointerByID(c);if(u)u._events.push(l);else{var d=n.length;if(0===d||t._multiPointerEnabled){for(var h=t._pointerPool,g=0;g<d&&!(n[g].id>g);g++);(u=h[g])||(u=h[g]=new oM(g),a._physicsInitialized&&u._addEmitters(oL,o),e._pointerEventEmitters.forEach(function(e){u._addEmitters(e,o)})),u._uniqueID=c,u._events.push(l),u.position.set((l.clientX-_)*p,(l.clientY-f)*m),n.splice(g,0,u)}}}(y);r.length=0,this._upList.length=this._downList.length=0,this._buttons=oA.None;for(var A=a.time.frameCount,b=0,S=n.length;b<S;b++){var C=n[b];this._updatePointerInfo(A,C,_,f,p,m),this._buttons|=C.pressedButtons}},t._firePointerScript=function(e){for(var t=this._pointers,n=0,r=t.length;n<r;n++){for(var i=t[n],a=i._events,o=i._emitters,s=o.length,l=0;l<s;l++)o[l].processRaycast(e,i);var c=a.length;if(c>0){if(i._frameEvents&oP.Move){i.phase=oE.Move;for(var u=0;u<s;u++)o[u].processDrag(i)}for(var d=0;d<c;d++){var h=a[d];switch(i.button=ob[h.button]||oA.None,i.pressedButtons=h.buttons,h.type){case"pointerdown":i.phase=oE.Down;for(var _=0;_<s;_++)o[_].processDown(i);break;case"pointerup":i.phase=oE.Up;for(var f=0;f<s;f++)o[f].processUp(i);break;case"pointerleave":case"pointercancel":i.phase=oE.Leave;for(var p=0;p<s;p++)o[p].processLeave(i)}}a.length=0}}},t._destroy=function(){this._removeEventListener(),this._pointerPool.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),t.button=ob[_.button]||oA.None,t.pressedButtons=_.buttons;for(var m=0;m<l;m++){var g=o[m];switch(g.type){case"pointerdown":var v=g.button;d.add(v),h[v]=e,t._downList.add(v),t._downMap[v]=e,t._frameEvents|=oP.Down,t.phase=oE.Down;break;case"pointerup":var y=g.button;c.add(y),u[y]=e,t._upList.add(y),t._upMap[y]=e,t._frameEvents|=oP.Up,t.phase=oE.Up;break;case"pointermove":t._frameEvents|=oP.Move,t.phase=oE.Move;break;case"pointerleave":t._frameEvents|=oP.Leave,t.phase=oE.Leave;break;case"pointercancel":t._frameEvents|=oP.Cancel,t.phase=oE.Leave}}}else t.deltaPosition.set(0,0),t.phase=oE.Stationary},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._eventPool.garbageCollection(),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._downMap.length=0,this._upList.length=0,this._upMap.length=0},e}();function oB(){return function(e){oD._pointerEventEmitters.push(e)}}oD._pointerEventEmitters=[];var oI=/*#__PURE__*/function(){function e(e,t){this._delta=new tU,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}(),oN=/*#__PURE__*/function(){function e(e,t){this._initialized=!1,this._engine=e;var n,r,i,a=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&t7(a,OffscreenCanvas)||(this._wheelManager=new oI(e,null!=(n=null==t?void 0:t.wheelTarget)?n:a),this._pointerManager=new oD(e,null!=(r=null==t?void 0:t.pointerTarget)?r:a),this._keyboardManager=new oT(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[oS[e]]===this._engine.time.frameCount)},t.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[oS[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)},t4(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}(),oO=((eN={}).cornerTextureCoordinate="a_CornerTextureCoordinate",eN),oV=((eO={}).Position="a_FeedbackPosition",eO.Velocity="a_FeedbackVelocity",eO),ok=((eV={}).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",eV.DirectionTime="a_DirectionTime",eV.StartColor="a_StartColor",eV.StartSize="a_StartSize",eV.StartRotation0="a_StartRotation0",eV.StartSpeed="a_StartSpeed",eV.Random0="a_Random0",eV.Random1="a_Random1",eV.SimulationWorldPosition="a_SimulationWorldPosition",eV.SimulationWorldRotation="a_SimulationWorldRotation",eV.SimulationUV="a_SimulationUV",eV.Random2="a_Random2",eV),oU=function e(t){this.billboardVertexElement=new aC(oO.cornerTextureCoordinate,0,ab.Vector4,0),this.instanceVertexElements=[new aC(ok.ShapePositionStartLifeTime,0,ab.Vector4,1,1),new aC(ok.DirectionTime,16,ab.Vector4,1,1),new aC(ok.StartColor,32,ab.Vector4,1,1),new aC(ok.StartSize,48,ab.Vector3,1,1),new aC(ok.StartRotation0,60,ab.Vector3,1,1),new aC(ok.StartSpeed,72,ab.Float,1,1),new aC(ok.Random0,76,ab.Vector4,1,1),new aC(ok.Random1,92,ab.Vector4,1,1),new aC(ok.SimulationWorldPosition,108,ab.Vector3,1,1),new aC(ok.SimulationWorldRotation,120,ab.Vector4,1,1),new aC(ok.SimulationUV,136,ab.Vector4,1,1),new aC(ok.Random2,152,ab.Vector4,1,1)];var n=new ax(t,aT.VertexBuffer,64,av.Static,!1);n.isGCIgnored=!0,this.billboardVertexBufferBinding=new aO(n,16);var r=new ax(t,aT.IndexBuffer,e.billboardIndexCount,av.Static,!1);r.isGCIgnored=!0,this.billboardIndexBufferBinding=new aF(r,aA.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 t5(t,e),t.prototype.restoreContent=function(){n.setData(i)},t}(nl))),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,r)||this}return t5(t,e),t.prototype.restoreContent=function(){},t}(nl)))};oU.feedbackVertexStride=24,oU.feedbackVertexElements=[new aC(oV.Position,0,ab.Vector3,0),new aC(oV.Velocity,12,ab.Vector3,0)],oU.feedbackInstanceElements=[new aC(ok.ShapePositionStartLifeTime,0,ab.Vector4,0),new aC(ok.DirectionTime,16,ab.Vector4,0),new aC(ok.StartSize,48,ab.Vector3,0),new aC(ok.StartSpeed,72,ab.Float,0),new aC(ok.Random0,76,ab.Vector4,0),new aC(ok.Random1,92,ab.Vector4,0),new aC(ok.SimulationWorldPosition,108,ab.Vector3,0),new aC(ok.SimulationWorldRotation,120,ab.Vector4,0),new aC(ok.Random2,152,ab.Vector4,0)],oU.instanceVertexStride=168,oU.instanceVertexFloatStride=oU.instanceVertexStride/4,oU.startLifeTimeOffset=3,oU.timeOffset=7,oU.simulationUVOffset=34,oU.billboardIndexCount=6,oU.boundsFloatStride=8,oU.boundsTimeOffset=6,oU.boundsMaxLifetimeOffset=7;var oz="#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#include <PositionClipSpaceDeclaration>\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 #include <PositionClipSpaceVertex>\n}\n",oG=/*#__PURE__*/function(){function e(e,t,n){this._id=rx._shaderPassCounter++,this.vertexSource=e,this.fragmentSource=t,this.feedbackVaryings=n}return e.prototype.getProgram=function(e,t){var n=e._getShaderProgramPool(this._id),r=n.get(t);if(r)return r;var i=rf.compilePlatformSource(e,t,this.vertexSource,this.fragmentSource);return(r=new ry(e,i.vertexSource,i.fragmentSource,this.feedbackVaryings)).isValid?(n.cache(r),r):(nb.error("TransformFeedbackShader: Failed to compile shader program."),null)},e}(),oH=/*#__PURE__*/function(){function e(){}return e.init=function(){e.particleFeedbackShader=new oG("#include <particle_feedback_simulation>","void main() { discard; }",["v_FeedbackPosition","v_FeedbackVelocity"]);var t=new rx("ShadowCaster","#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\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","#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\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:rh.ShadowCaster});t._renderState=new rE,t._renderStateDataMap[ri.RenderQueueType]=r4._shadowCasterRenderQueueProp;var n=new rx("DepthOnly","#define MATERIAL_OMIT_NORMAL\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;\n\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <position_vert>\n\n}\n","void main() {\n}",{pipelineStage:rh.DepthOnly});n._renderState=new rE,n._renderStateDataMap[ri.RenderQueueType]=r4._depthOnlyRenderQueueProp;var r=[t,n],i={pipelineStage:rh.Forward};rM.create("blinn-phong",[].concat([new rx("Forward","#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","#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",i)],r)),rM.create("pbr",[].concat([new rx("Forward",oz,"#include <common>\n#include <camera_declare>\n#include <transform_declare>\n\n#include <FogFragmentDeclaration>\n#include <PositionClipSpaceDeclaration>\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",i)],r)),rM.create("pbr-specular",[].concat([new rx("Forward",oz,"#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\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n}\n",i)],r)),rM.create("unlit",[].concat([new rx("Forward","#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","#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 baseColor *= texture2DSRGB(material_BaseTexture, v_uv);\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",i)],r)),rM.create("blit",[new rx("Forward",ii,"#include <common>\n\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\n#ifdef HAS_TEX_LOD\n vec4 texture2DLodSRGB(sampler2D tex, vec2 uv, float lod) {\n vec4 color = texture2DLodEXT(tex, uv, lod);\n #ifdef ENGINE_NO_SRGB\n color = sRGBToLinear(color);\n #endif\n return color;\n }\n#endif\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 = texture2DLodSRGB( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n #else\n gl_FragColor = texture2DSRGB( renderer_BlitTexture, uv );\n #endif\n}\n\n",i)]),rM.create("blit-screen",[new rx("Forward",ii,"#include <common>\n\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\n uniform float renderer_BlitMipLevel;\n#endif\n\nvarying vec2 v_uv;\n\n#ifdef HAS_TEX_LOD\n vec4 texture2DLodSRGB(sampler2D tex, vec2 uv, float lod) {\n vec4 color = texture2DLodEXT(tex, uv, lod);\n #ifdef ENGINE_NO_SRGB\n color = sRGBToLinear(color);\n #endif\n return color;\n }\n#endif\n\nvoid main() {\n vec2 uv = v_uv;\n // Screen uv is flipped\n uv.y = 1.0 - uv.y;\n\n #ifdef HAS_TEX_LOD\n gl_FragColor = texture2DLodSRGB( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n #else\n gl_FragColor = texture2D( renderer_BlitTexture, uv );\n #endif\n\n // Color space in screen is in gamma space but without sRGB texture, so we need to convert it to linear space manually\n gl_FragColor = sRGBToLinear(gl_FragColor);\n}\n\n",i)]),rM.create("skybox",[new rx("Forward","#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","#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 ENGINE_NO_SRGB\n textureColor = sRGBToLinear(textureColor);\n #endif\n\n textureColor.rgb *= material_Exposure * material_TintColor.rgb;\n \n gl_FragColor = textureColor;\n}\n",i)]),rM.create("SkyProcedural",[new rx("Forward","// 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#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\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","// 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// 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\n gl_FragColor = vec4(col, 1.0);\n}\n\n",i)]),rM.create("particle-shader",[new rx("Forward","#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 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\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_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\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 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 <force_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\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = startVelocity * age;\n\n vec3 finalPosition;\n vec3 localPositionOffset = startPosition;\n vec3 worldPositionOffset;\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 lifeVelocity; \n vec3 velocityPositionOffset = computeVelocityPositionOffset(normalizedAge, age, lifeVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += lifeVelocity;\n localPositionOffset += velocityPositionOffset;\n } else {\n worldVelocity += lifeVelocity;\n worldPositionOffset += velocityPositionOffset;\n }\n #endif\n\n #ifdef _FOL_MODULE_ENABLED\n vec3 forceVelocity;\n vec3 forcePositionOffset = computeForcePositionOffset(normalizedAge, age, forceVelocity);\n if (renderer_FOLSpace == 0) {\n localVelocity += forceVelocity;\n localPositionOffset += forcePositionOffset;\n } else {\n worldVelocity += forceVelocity;\n worldPositionOffset += forcePositionOffset;\n }\n #endif\n\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + localPositionOffset, worldRotation) + worldPositionOffset;\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\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n // normalizedAge >= 0.0: skip stale TF slots whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 0.0 && normalizedAge < 1.0) {\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity;\n vec3 worldVelocity;\n\n #ifdef RENDERER_TRANSFORM_FEEDBACK\n // Transform Feedback mode: position in simulation space (local or world).\n // Local: transform to world; World: use directly.\n vec3 center;\n if (renderer_SimulationSpace == 0) {\n center = rotationByQuaternions(a_FeedbackPosition, worldRotation) + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n center = a_FeedbackPosition;\n }\n localVelocity = a_FeedbackVelocity;\n worldVelocity = vec3(0.0);\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 instantVOLVelocity;\n computeVelocityPositionOffset(normalizedAge, age, instantVOLVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += instantVOLVelocity;\n } else {\n worldVelocity += instantVOLVelocity;\n }\n #endif\n #else\n // Original analytical path\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n localVelocity = startVelocity;\n worldVelocity = gravityVelocity;\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, localVelocity, worldVelocity);\n #endif\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.zw + TEXCOORD_0 * a_SimulationUV.xy;\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}","#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n \nuniform mediump vec3 material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\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 #if defined(RENDERER_MODE_MESH) && defined(RENDERER_ENABLE_VERTEXCOLOR)\n color *= v_MeshColor;\n #endif\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n color *= texture2DSRGB(material_BaseTexture, v_TextureCoordinate);\n #endif\n \n // Emissive\n vec3 emissiveRadiance = material_EmissiveColor;\n #ifdef MATERIAL_HAS_EMISSIVETEXTURE\n emissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_TextureCoordinate).rgb;\n #endif\n\n color.rgb += emissiveRadiance;\n\n gl_FragColor = color;\n}",i)]),rM.create("trail",[new rx("Forward","attribute vec4 a_PositionBirthTime; // xyz: World position, w: Birth time (used by CPU only)\nattribute vec4 a_CornerTangent; // x: Corner (-1 or 1), yzw: Tangent direction\nattribute float a_Distance; // Absolute cumulative distance (written once per point)\n\nuniform vec4 renderer_TrailParams; // x: TextureMode (0: Stretch, 1: Tile), y: TextureScaleX, z: TextureScaleY\nuniform vec2 renderer_DistanceParams; // x: HeadDistance, y: TailDistance\nuniform vec3 camera_Position;\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\nuniform vec2 renderer_WidthCurve[4]; // Width curve (4 keyframes max: x=time, y=value)\nuniform vec4 renderer_ColorKeys[4]; // Color gradient (x=time, yzw=rgb)\nuniform vec2 renderer_AlphaKeys[4]; // Alpha gradient (x=time, y=alpha)\nuniform vec4 renderer_CurveMaxTime; // x: colorMaxTime, y: alphaMaxTime, z: widthMaxTime\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\n#include <particle_common>\n\nvoid main() {\n vec3 position = a_PositionBirthTime.xyz;\n float corner = a_CornerTangent.x;\n vec3 tangent = a_CornerTangent.yzw;\n\n // Distance-based relative position: 0=head(newest), 1=tail(oldest)\n float distFromHead = renderer_DistanceParams.x - a_Distance;\n float totalDist = renderer_DistanceParams.x - renderer_DistanceParams.y;\n float relativePos = totalDist > 0.0 ? distFromHead / totalDist : 0.0;\n\n // Billboard: expand perpendicular to tangent and view direction\n vec3 toCamera = normalize(camera_Position - position);\n vec3 right = cross(tangent, toCamera);\n float rightLenSq = dot(right, right);\n if (rightLenSq < 0.000001) {\n right = cross(tangent, vec3(0.0, 1.0, 0.0));\n rightLenSq = dot(right, right);\n if (rightLenSq < 0.000001) {\n right = cross(tangent, vec3(1.0, 0.0, 0.0));\n rightLenSq = dot(right, right);\n }\n }\n right = right * inversesqrt(rightLenSq);\n\n float width = evaluateParticleCurve(renderer_WidthCurve, min(relativePos, renderer_CurveMaxTime.z));\n vec3 worldPosition = position + right * width * 0.5 * corner;\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(worldPosition, 1.0);\n\n // u = position along trail (affected by textureMode), v = corner side.\n float u = renderer_TrailParams.x == 0.0 ? relativePos : distFromHead;\n float v = corner * 0.5 + 0.5;\n v_uv = vec2(u * renderer_TrailParams.y, v * renderer_TrailParams.z);\n\n v_color = evaluateParticleGradient(renderer_ColorKeys, renderer_CurveMaxTime.x, renderer_AlphaKeys, renderer_CurveMaxTime.y, relativePos);\n}\n","#include <common>\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nuniform vec4 material_BaseColor;\n\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\nuniform mediump vec3 material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\nvoid main() {\n vec4 color = material_BaseColor * v_color;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n color *= texture2DSRGB(material_BaseTexture, v_uv);\n #endif\n\n // Emissive\n vec3 emissiveRadiance = material_EmissiveColor;\n #ifdef MATERIAL_HAS_EMISSIVETEXTURE\n emissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_uv).rgb;\n #endif\n\n color.rgb += emissiveRadiance;\n\n gl_FragColor = color;\n}\n\n",i)]),rM.create("SpriteMask",[new rx("Forward","uniform 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","uniform 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",i)]),rM.create("Sprite",[new rx("Forward","uniform 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","#include <common>\nuniform sampler2D renderer_SpriteTexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 baseColor = texture2DSRGB(renderer_SpriteTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n}\n",i)]),rM.create("Text",[new rx("Forward","uniform 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","uniform sampler2D renderElement_TextTexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 texColor = texture2D(renderElement_TextTexture, v_uv);\n #ifdef GRAPHICS_API_WEBGL2\n float coverage = texColor.r;\n #else\n float coverage = texColor.a;\n #endif\n gl_FragColor = vec4(v_color.rgb, v_color.a * coverage);\n}\n",i)]),rM.create("background-texture",[new rx("Forward","attribute 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}","#include <common>\nuniform sampler2D material_BaseTexture;\n\nvarying vec2 v_uv;\n\nvoid main() {\n gl_FragColor = texture2DSRGB(material_BaseTexture, v_uv);\n}",i)])},e}(),oW=/*#__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}(),oX=/*#__PURE__*/function(){function e(){}return e.renderOverlay=function(t,n,r){t._macroCollection.enable(e._shouldSRGBCorrect);var i=t.canvas;t._hardwareRenderer;var a=t._renderContext,o=t._batcherManager,s=this._renderQueue||(this._renderQueue=new i5(rr.Transparent)),l=this._virtualCamera||(this._virtualCamera=new rW),c=this._viewport||(this._viewport=new tZ(0,0,1,1)),u=this._overlayCamera||(this._overlayCamera=new oj);u.engine=t,u.scene=n,a.camera=u;var d=l.projectionMatrix.elements,h=l.viewMatrix.elements;d[0]=2/i.width,d[5]=2/i.height,d[10]=0,a.setRenderTarget(null,c,0);for(var _=0,f=r.length;_<f;_++){var p=r.get(_);if(p){var m=p.entity.transform.position;h[12]=-m.x,h[13]=-m.y,tK.multiply(l.projectionMatrix,l.viewMatrix,l.viewProjectionMatrix),a.applyVirtualCamera(l,!1),s.rendererUpdateFlag|=rF.ProjectionMatrix,p._prepareRender(a),s.pushRenderElement(p._renderElement),s.batch(o),o.uploadBuffer(),s.render(a,"Forward"),s.clear(),t._renderCount++}}a.camera=null,t._macroCollection.disable(e._shouldSRGBCorrect)},e}();oX._shouldSRGBCorrect=rc.getByName("ENGINE_SHOULD_SRGB_CORRECT");var oj=function(){this.instanceId=++no._instanceIdCounter,this.shaderData=new rP(ra.Camera),this.enableFrustumCulling=!0,this.cullingMask=rU.Everything,this._globalShaderMacro=new ru},oY=/*#__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 rj.None},e}();oH.init();var oK=/*#__PURE__*/function(e){function t(n,r,i){(a=e.call(this)||this)._renderingStatistics=new od,a._isDeviceLost=!1,a._frameInProcess=!1,a._pendingDestroyObjects=[],a._processingPendingDestroys=!1,a._physicsInitialized=!1,a._lastRenderState=new rE,a._renderElementPool=new oR(ac),a._subRenderElementPool=new oR(au),a._textSubRenderElementPool=new oR(au),a._charRenderInfoPool=new ot(t9,50),a._renderContext=new rw,a._renderCount=0,a._shaderProgramPools=[],a._fontMap={},a._macroCollection=new ru,a._postProcessPassNeedRefresh=!1,a._settings={},a._resourceManager=new om(a),a._sceneManager=new ou(a),a._vSyncCount=1,a._targetFrameRate=60,a._time=new nW,a._isPaused=!0,a._vSyncCounter=1,a._targetFrameInterval=1e3/60,a._destroyed=!1,a._waitingDestroy=!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=nV.createFromOS(a,"Arial"),a._textDefaultFont.isGCIgnored=!0,a._batcherManager=new oo(a),a._renderTargetPool=new os(a),a.inputManager=new oN(a,i.input);var a,o=i.xrDevice;if(o&&(a.xrManager=new oY,a.xrManager._initialize(a,o)),r.canIUse(nT.depthTexture)){var s=new nF(a,1,1,n_.Depth16,!1,!1);s.isGCIgnored=!0,a._depthTexture2D=s}else a._macroCollection.enable(t._noDepthTextureMacro);r.canIUse(nT.sRGB)||a._macroCollection.enable(t._noSRGBSupportMacro),a._basicResources=new a4(a),a._particleBufferUtils=new oU(a);var l=new i3(a);return a.addPostProcessPass(l),a}t5(t,e);var n=t.prototype;return n.createEntity=function(e){return new a7(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)}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)}this._hardwareRenderer.isContextLost()||this._render(a),this._processPendingDestroyObjects(),this._frameInProcess=!1,this._waitingDestroy&&this._destroy(),this._waitingGC&&(this._gc(),this._waitingGC=!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._processPendingDestroyObjects=function(){var e=this._pendingDestroyObjects;this._processingPendingDestroys=!0;for(var t=0,n=e.length;t<n;t++)e[t].destroy();e.length=0,this._processingPendingDestroys=!1},n._destroy=function(){var e;this._destroyed=!0,this._waitingDestroy=!1,this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this.inputManager._destroy(),this._batcherManager.destroy(),this._renderTargetPool.gc(),null==(e=this.xrManager)||e._destroy(),this.dispatch("shutdown",this),this.pause(),rM._clear(this),this._hardwareRenderer.destroy(),this.removeAllEventListeners()},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e,t){var n=this._shaderProgramPools,r=n[e];if(!r){var i=e+1;i>n.length&&(n.length=i),n[e]=r=new oW(this),null==t||t.push(r)}return r},n._render=function(e){for(var t,n=this,r=this.time.deltaTime,i=0,a=e.length;i<a;i++){var o=e[i];o.isActive&&!o.destroyed&&(o._componentsManager.callRendererOnUpdate(r),o._updateShaderData())}for(var s=0,l=e.length;s<l;s++)t=this,function(r,i){var a=e[r];if(a.isActive&&!a.destroyed){var o=a._componentsManager,s=o._activeCameras;0===s.length?nb.debug("No active camera in scene."):s.forEach(function(e){o.callCameraOnBeginRender(e);var t=e.pixelViewport;0!==t.width&&0!==t.height?(a.postProcessManager._update(e),e.render()):nb.warn("Camera pixelViewport width or height is 0."),o.callCameraOnEndRender(e),n._hardwareRenderer._options._forceFlush&&n._hardwareRenderer.flush()},function(e,t){e._cameraIndex=t});var l=o._overlayCanvases;l.length>0&&(o.sortOverlayUICanvases(),oX.renderOverlay(t,a,l))}}(s)},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var n=this,r=e.shaderLab,i=e.physics;r&&!rM._shaderLab&&(rM._shaderLab=r);var a=[];i&&a.push(i.initialize().then(function(){return t._nativePhysics&&console.warn("A physics engine has already been configured. All physics operations will now be handled by the newly specified physics engine."),t._nativePhysics=i,n._nativePhysicsManager=i.createPhysicsManager(),n._physicsInitialized=!0,n}));var o=om._loaders;for(var s in o){var l=o[s];l.initialize&&a.push(l.initialize(this,e))}return a.push(this._basicResources._initialize()),Promise.all(a).then(function(){return n})},n._onDeviceLost=function(){this._isDeviceLost=!0,this.resourceManager._lostGraphicResources(),this._renderingStatistics._reset(),console.log("Device lost."),this.dispatch("devicelost",this)},n._onDeviceRestored=function(){var e=this;this._hardwareRenderer.resetState(),this._lastRenderState=new rE,rM._clear(this),this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),this._isDeviceLost=!1,console.log("Graphic resource restored."),t._restoreResourcesContent().then(function(){console.log("Graphic resource content restored.\n\nDevice restored."),e.dispatch("devicerestored",e)}).catch(function(e){console.error(e)})},n._gc=function(){this._subRenderElementPool.garbageCollection(),this._textSubRenderElementPool.garbageCollection(),this._renderElementPool.garbageCollection(),this._renderContext.garbageCollection();for(var e,t,n=this._sceneManager._scenes.getLoopArray(),r=0,i=n.length;r<i;r++)null==(t=n[r])||null==(e=t.physics)||e._gc()},t4(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:"renderingStatistics",get:function(){return this._renderingStatistics}},{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}(nG);oK._noDepthTextureMacro=rc.getByName("ENGINE_NO_DEPTH_TEXTURE"),oK._noSRGBSupportMacro=rc.getByName("ENGINE_NO_SRGB"),oK._outputSRGBCorrectMacro=rc.getByName("ENGINE_OUTPUT_SRGB_CORRECT"),oK._pixelsPerUnit=100,oK._physicalObjectsMap={};var oQ=/*#__PURE__*/function(){function e(){this._sizeUpdateFlagManager=new n4}return t4(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}(),oq=/*#__PURE__*/function(){function e(){this._cameraNeedSorting=!1,this._activeCameras=new nQ,this._renderers=new nQ,this._overlayCanvases=new nQ,this._overlayCanvasesSortingDirty=!1,this._canvases=new nQ,this._onStartScripts=new nQ,this._onUpdateScripts=new nQ,this._onLateUpdateScripts=new nQ,this._onPhysicsUpdateScripts=new nQ,this._onUpdateAnimations=new nQ,this._onUpdateRenderers=new nQ,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.addUICanvas=function(e,t){var n;t?(n=this._overlayCanvases,this._overlayCanvasesSortingDirty=!0):n=this._canvases,e._canvasIndex=n.length,n.add(e)},t.removeUICanvas=function(e,t){t?(n=this._overlayCanvases,this._overlayCanvasesSortingDirty=!0):n=this._canvases;var n,r=n.deleteByIndex(e._canvasIndex);r&&(r._canvasIndex=e._canvasIndex),e._canvasIndex=-1},t.sortOverlayUICanvases=function(){if(this._overlayCanvasesSortingDirty){var e=this._overlayCanvases;e.sort(function(e,t){return e.sortOrder-t.sortOrder});for(var t=0,n=e.length;t<n;t++)e.get(t)._canvasIndex=t;this._overlayCanvasesSortingDirty=!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.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.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(),this._overlayCanvases.garbageCollection(),this._canvases.garbageCollection()},e}(),oZ=/*#__PURE__*/function(){function e(){this.hasStencilWritten=!1,this._preMaskLayer=ad.Nothing,this._allSpriteMasks=new nQ}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(),a=e.getMaskDecrementRenderQueue();this._buildMaskRenderElement(r,i,a);var o=t.camera.engine._batcherManager;i.batch(o),o.uploadBuffer(),i.render(t,n,i8.Increment),i.clear(),a.batch(o),o.uploadBuffer(),a.render(t,n,i8.Decrement),a.clear()},t.clearMask=function(t,n){var r=this._preMaskLayer;if(r!==ad.Nothing){if(this.hasStencilWritten){for(var i=e.getMaskDecrementRenderQueue(),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,i8.Decrement),i.clear()}else{var u=t.camera.engine;u._hardwareRenderer.clearRenderTarget(u,rj.Stencil,null)}this._preMaskLayer=ad.Nothing}},t.isStencilWritten=function(e){var t=e.renderState.stencilState,n=rl.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!==rt.Always&&i!==rt.Never||a!==rt.Always&&a!==rt.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 i5(rr.Transparent))},e.getMaskDecrementRenderQueue=function(){return e._maskDecrementRenderQueue||(e._maskDecrementRenderQueue=new i5(rr.Transparent))},e}(),oJ=((ek={})[ek.None=0]="None",ek[ek.Linear=1]="Linear",ek[ek.Exponential=2]="Exponential",ek[ek.ExponentialSquared=3]="ExponentialSquared",ek),o$=((eU={})[eU.SolidColor=0]="SolidColor",eU[eU.SphericalHarmonics=1]="SphericalHarmonics",eU),o0=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._diffuseSolidColor=new tJ(.03696758874771872,.0421494543549785,.05455383078270364),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=o$.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n}t5(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._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===o$.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._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]},t4(t,[{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}(ns);o0._shMacro=rc.getByName("SCENE_USE_SH"),o0._specularMacro=rc.getByName("SCENE_USE_SPECULAR_ENV"),o0._diffuseColorProperty=nH.getByName("scene_EnvMapLight.diffuse"),o0._diffuseSHProperty=nH.getByName("scene_EnvSH"),o0._diffuseIntensityProperty=nH.getByName("scene_EnvMapLight.diffuseIntensity"),o0._specularTextureProperty=nH.getByName("scene_EnvSpecularSampler"),o0._specularIntensityProperty=nH.getByName("scene_EnvMapLight.specularIntensity"),o0._mipLevelProperty=nH.getByName("scene_EnvMapLight.mipMapLevel");var o1=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.cullingMask=rU.Everything,t.shadowType=ae.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t._lightIndex=-1,t._shadowStrength=1,t._color=new tJ(1,1,1,1),t}return t5(t,e),t4(t,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=tk.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 tK),tK.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new tK),tK.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),t}(rN);t6([nt],o1.prototype,"_lightIndex",void 0),t6([ni],o1.prototype,"_color",void 0),t6([nt],o1.prototype,"_viewMat",void 0),t6([nt],o1.prototype,"_inverseViewMat",void 0);var o2=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shadowNearPlaneOffset=.1,t._reverseDirection=new tU,t}t5(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,i=3*e,a=this.color,o=this.direction,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,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)},t4(t,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tU.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}}]),t}(o1);o2._cullingMaskProperty=nH.getByName("scene_DirectLightCullingMask"),o2._colorProperty=nH.getByName("scene_DirectLightColor"),o2._directionProperty=nH.getByName("scene_DirectLightDirection"),t6([nt],o2.prototype,"_reverseDirection",void 0);var o3=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t}t5(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,i=3*e,a=this.color,o=this.position,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,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)},t4(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}}]),t}(o1);o3._cullingMaskProperty=nH.getByName("scene_PointLightCullingMask"),o3._colorProperty=nH.getByName("scene_PointLightColor"),o3._positionProperty=nH.getByName("scene_PointLightPosition"),o3._distanceProperty=nH.getByName("scene_PointLightDistance");var o4=/*#__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 tU,t}t5(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.color,s=this.position,l=this.direction,c=this.cullingMask;t.cullingMask[n]=65535&c,t.cullingMask[n+1]=c>>>16&65535,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)},t4(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tU.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}}]),t}(o1);o4._cullingMaskProperty=nH.getByName("scene_SpotLightCullingMask"),o4._colorProperty=nH.getByName("scene_SpotLightColor"),o4._positionProperty=nH.getByName("scene_SpotLightPosition"),o4._directionProperty=nH.getByName("scene_SpotLightDirection"),o4._distanceProperty=nH.getByName("scene_SpotLightDistance"),o4._angleCosProperty=nH.getByName("scene_SpotLightAngleCos"),o4._penumbraCosProperty=nH.getByName("scene_SpotLightPenumbraCos"),t6([nt],o4.prototype,"_inverseDirection",void 0);var o8=/*#__PURE__*/function(){function e(e){this.quality=ia.Low,this._enabled=!1,this._power=1,this._bilateralThreshold=.05,this._radius=.3,this._intensity=1,this._bias=5e-4,this._minHorizonAngle=0,this._scene=e}var t=e.prototype;return t._isValid=function(){return this._enabled&&this.intensity>0},t._toggleAmbientOcclusionMacro=function(){this._isValid()?this._scene.shaderData.enableMacro(e._enableMacro):this._scene.shaderData.disableMacro(e._enableMacro)},t4(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this._toggleAmbientOcclusionMacro())}},{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=Math.max(.1,Math.min(10,e)))}},{key:"intensity",get:function(){return this._intensity},set:function(e){this._intensity!==e&&(this._intensity=Math.max(0,e),this._toggleAmbientOcclusionMacro())}},{key:"power",get:function(){return this._power},set:function(e){this._power=Math.max(1,Math.min(8,e))}},{key:"bilateralThreshold",get:function(){return this._bilateralThreshold},set:function(e){this._bilateralThreshold=Math.max(1e-6,Math.min(.1,e))}},{key:"bias",get:function(){return this._bias},set:function(e){this._bias=Math.max(0,Math.min(.5,e))}},{key:"minHorizonAngle",get:function(){return this._minHorizonAngle},set:function(e){this._minHorizonAngle=Math.max(0,Math.min(Math.PI/4,e))}}]),e}();o8._enableMacro=rc.getByName("SCENE_ENABLE_AMBIENT_OCCLUSION");var o5=/*#__PURE__*/function(){function e(){this._spotLights=new nQ,this._pointLights=new nQ,this._directLights=new nQ,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?(o2._updateShaderData(t,s),t.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):t.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(o3._updateShaderData(t,o),t.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):t.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(o4._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===ae.None||r||(n=Number.NEGATIVE_INFINITY,r=!0);var s=o.color.getBrightness();r?o.shadowType!==ae.None&&n<s&&(n=s,t=o):n<s&&(n=s,t=o)}return t},e}();o5._sunlightColorProperty=nH.getByName("scene_SunlightColor"),o5._sunlightDirectionProperty=nH.getByName("scene_SunlightDirection"),o5._maxLight=10;var o9=/*#__PURE__*/function(e){function t(n,r){(i=e.call(this,n)||this).physics=new iV(i),i.castShadows=!0,i.shadowResolution=i7.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new tU(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i.postProcessManager=new i0(i),i.ambientOcclusion=new o8(i),i._lightManager=new o5,i._componentsManager=new oq,i._maskManager=new oZ,i._isActiveInEngine=!1,i._rootEntities=[],i._background=new rD(i._engine),i._shaderData=new rP(ra.Scene),i._shadowCascades=an.NoCascades,i._fogMode=oJ.None,i._fogColor=new tJ(.21404114048223255,.21404114048223255,.21404114048223255,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new tZ,i._isActive=!0,i._enableTransparentShadow=!1,i.name=r||"";var i,a=i.shaderData;return a._addReferCount(1),i.ambientLight=new o0(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),a.setTexture(t._prefilterdDFGProperty,n._basicResources.prefilteredDFGTexture),i._computeLinearFogParams(i._fogStart,i._fogEnd),i._computeExponentialFogParams(i._fogDensity),i}t5(t,e);var n=t.prototype;return n.createRootEntity=function(e){var t=new a7(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._setParentChange());var i=t._scene;i!==this?(i&&r&&a7._removeFromChildren(i._rootEntities,t),a7._addToChildren(this._rootEntities,t,n)):r||a7._addToChildren(this._rootEntities,t,n);var a=rI.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(a|=rI.Hierarchy)),t._isActiveInScene&&i!==this&&(a|=rI.Scene),a&&t._processInActive(a),i!==this&&a7._traverseSetOwnerScene(t,this);var o=rI.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=rI.Hierarchy)),t._isActiveInScene&&i===this||(o|=rI.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){a7._removeFromChildren(this._rootEntities,e),e._isRoot=!1;var t=rI.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=rI.Hierarchy),e._isActiveInScene&&(t|=rI.Scene),t&&e._processInActive(t),a7._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){var t=e.split("/").filter(Boolean);if(!t.length)return null;for(var n=t.shift(),r=0,i=this.rootEntitiesCount;r<i;r++){var a=this.getRootEntity(r);if(a.name===n&&(!t.length||(a=a7._findChildByName(a,0,t,0))))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(rI.Hierarchy):r._processInActive(rI.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(o5._sunlightColorProperty,r.color),e.setVector3(o5._sunlightDirectionProperty,r.direction)):e.setVector3(o5._sunlightDirectionProperty,tU._zero),this.castShadows&&r&&r.shadowType!==ae.None?e.enableMacro("SCENE_SHADOW_TYPE",r.shadowType.toString()):e.disableMacro("SCENE_SHADOW_TYPE")},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._maskManager.destroy();var n=t._allCreatedScenes;n.splice(n.indexOf(this),1),this.physics._destroy()},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()},t4(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){nb.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}(no);function o6(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}o9._fogColorProperty=nH.getByName("scene_FogColor"),o9._fogParamsProperty=nH.getByName("scene_FogParams"),o9._prefilterdDFGProperty=nH.getByName("scene_PrefilteredDFG");var o7=/*#__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}t5(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.onPointerBeginDrag=function(e){},n.onPointerDrag=function(e){},n.onPointerEndDrag=function(e){},n.onPointerDrop=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);for(var r,i=function(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 o6(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 o6(e,void 0)}}(e))){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.")}(Object.values(se));!(r=i()).done;){var a=r.value;this[a]===n[a]&&(this[a]=null)}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.onDestroy()},t}(rN);t6([nt],o7.prototype,"_started",void 0),t6([nt],o7.prototype,"_onStartIndex",void 0),t6([nt],o7.prototype,"_onUpdateIndex",void 0),t6([nt],o7.prototype,"_onLateUpdateIndex",void 0),t6([nt],o7.prototype,"_onPhysicsUpdateIndex",void 0),t6([nt],o7.prototype,"_onPreRenderIndex",void 0),t6([nt],o7.prototype,"_onPostRenderIndex",void 0),t6([nt],o7.prototype,"_entityScriptsIndex",void 0);var se=((ez={}).onPointerDown="onPointerDown",ez.onPointerUp="onPointerUp",ez.onPointerClick="onPointerClick",ez.onPointerEnter="onPointerEnter",ez.onPointerExit="onPointerExit",ez.onPointerBeginDrag="onPointerBeginDrag",ez.onPointerDrag="onPointerDrag",ez.onPointerEndDrag="onPointerEndDrag",ez.onPointerDrop="onPointerDrop",ez),st=/*#__PURE__*/function(){function e(){this._listeners=new oc}var t=e.prototype;return t.on=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];this._addListener.apply(this,[].concat([e,t,!1],r))},t.once=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];this._addListener.apply(this,[].concat([e,t,!0],r))},t.off=function(e,t){if("function"==typeof e){var n=null!=t?t:null;this._listeners.findAndRemove(function(t){return t.fn===e&&t.target===n&&(t.destroyed=!0,!0)})}else this._listeners.findAndRemove(function(n){return n.target===e&&n.methodName===t&&(n.destroyed=!0,!0)})},t.removeAll=function(e){void 0!==e?this._listeners.findAndRemove(function(t){return t.target===e&&(t.destroyed=!0)}):this._listeners.findAndRemove(function(e){return e.destroyed=!0})},t.invoke=function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var i=this._listeners.getLoopArray(),a=0,o=i.length;a<o;a++)e=this,function(t,r){var a=i[t];a.destroyed||(a.methodName&&a.target.destroyed?(a.destroyed=!0,e._listeners.findAndRemove(function(e){return e===a})):(a.fn.apply(a.target,n),a.once&&(a.destroyed=!0,e._listeners.findAndRemove(function(e){return e===a}))))}(a)},t._cloneTo=function(e,t,n){for(var r=this._listeners.getLoopArray(),i=0,a=r.length;i<a;i++){var o=r[i];if(!o.destroyed&&o.methodName){var s=rB.remapComponent(t,n,o.target);if(s){var l=this._cloneArguments(o.arguments,t,n);o.once?e.once.apply(e,[].concat([s,o.methodName],l)):e.on.apply(e,[].concat([s,o.methodName],l))}}}},t._cloneArguments=function(e,t,n){if(!e||0===e.length)return[];for(var r=e.length,i=Array(r),a=0;a<r;a++){var o=e[a];t7(o,a7)?i[a]=rB.remapEntity(t,n,o):t7(o,rN)?i[a]=rB.remapComponent(t,n,o):i[a]=o}return i},t._addListener=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];if("function"==typeof e)this._listeners.push({fn:e,target:null!=t?t:null,once:n});else{var o,s,l=i.length>0?function(){for(var n=arguments.length,r=Array(n),a=0;a<n;a++)r[a]=arguments[a];return(o=e)[t].apply(o,[].concat(i,r))}:function(){for(var n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];return(s=e)[t].apply(s,[].concat(r))};this._listeners.push({fn:l,target:e,once:n,methodName:t,arguments:i})}},e}();t6([nt],st.prototype,"_listeners",void 0);var sn=/*#__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}();sn._engineObjects={},sn._classNameMap=new Map;var sr=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t5(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.text=null},t}(no),si=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t5(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.data=null},t}(no),sa=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t5(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.buffer=null},t}(no),so=/*#__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}(),ss=/*#__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:so},e}();ss._components=[],ss._assemblerMap=new Map;var sl=/*#__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}();ss.registerAssembler(rG,"position",sl);var sc=/*#__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}();ss.registerAssembler(rG,"rotationQuaternion",sc);var su=/*#__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}();ss.registerAssembler(rG,"scale",su);var sd=/*#__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}();ss.registerAssembler(a3,"blendShapeWeights",sd);var sh=/*#__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}(),s_=/*#__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 ss(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 sh;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}(),sf=function(){},sp=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n._curveBindings=[],n._updateFlagManager=new n4,n._length=0,n._events=[],n}t5(t,e);var n=t.prototype;return n.addEvent=function(e,t,n){if("string"==typeof e){var r,i=new sf;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 s_;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=ss._components,i=n.length-1;i>=0;i--){var a=n[i],o=e.findByPath(a.relativePath);if(o){var s=a.typeIndex>0?o.getComponents(a.type,r)[a.typeIndex]:o.getComponent(a.type);if(r.length=0,!s)continue;var l=a._getTempCurveOwner(o,s);if(l&&a.curve.keys.length){var c=l.evaluateValue(a.curve,t,!1);l.applyValue(c,1,!1)}}}},t4(t,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),t}(no),sm=((eG={})[eG.Linear=0]="Linear",eG[eG.CubicSpine=1]="CubicSpine",eG[eG.Step=2]="Step",eG[eG.Hermite=3]="Hermite",eG),sg=/*#__PURE__*/function(){function e(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var e=this.constructor;this._interpolation=e._supportInterpolationMode?sm.Linear:sm.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 sm.Linear:n=this._type._lerpValue(l.value,c.value,h,t.value);break;case sm.Step:n=this._type._setValue(l.value,t.value);break;case sm.CubicSpine:case sm.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)},t4(e,[{key:"interpolation",get:function(){return this._interpolation},set:function(e){this._type._supportInterpolationMode||e===sm.Step?this._interpolation=e:(this._interpolation=sm.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),e}(),sv=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=[],t}return t5(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}(sg);sv._isCopyMode=!0,sv._supportInterpolationMode=!0,sv=t6([nk()],sv);var sy=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=!1,t}return t5(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}(sg);sy._isCopyMode=!1,sy._supportInterpolationMode=!1,sy=t6([nk()],sy);var sx=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tJ,t}return t5(t,e),t._initializeOwner=function(e){e.defaultValue=new tJ,e.fixedPoseValue=new tJ,e.baseEvaluateData.value=new tJ,e.crossEvaluateData.value=new tJ},t._initializeLayerOwner=function(e){e.finalValue=new tJ},t._lerpValue=function(e,t,n,r){return tJ.lerp(e,t,n,r),r},t._subtractValue=function(e,t,n){return tJ.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._additiveValue=function(e,t,n){return tJ.scale(e,t,e),tJ.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}(sg);sx._isCopyMode=!0,sx._supportInterpolationMode=!0,sx=t6([nk()],sx);var sA=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t5(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}(sg);sA._isCopyMode=!0,sA._supportInterpolationMode=!0,sA=t6([nk()],sA);var sb=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=0,t}return t5(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}(sg);sb._isCopyMode=!1,sb._supportInterpolationMode=!0,sb=t6([nk()],sb);var sS=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tY,t}return t5(t,e),t._initializeOwner=function(e){e.defaultValue=new tY,e.fixedPoseValue=new tY,e.baseEvaluateData.value=new tY,e.crossEvaluateData.value=new tY},t._initializeLayerOwner=function(e){e.finalValue=new tY},t._lerpValue=function(e,t,n,r){return tY.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 tY.conjugate(n,i),tY.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}(sg);sS._supportInterpolationMode=!0,sS._isCopyMode=!0,sS._tempConjugateQuat=new tY,sS=t6([nk()],sS);var sC=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tq,t}return t5(t,e),t._initializeOwner=function(e){e.defaultValue=new tq,e.fixedPoseValue=new tq,e.baseEvaluateData.value=new tq,e.crossEvaluateData.value=new tq},t._initializeLayerOwner=function(e){e.finalValue=new tq},t._lerpValue=function(e,t,n,r){return tq.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tq.scale(e,t,e),tq.add(n,e,n),n},t._subtractValue=function(e,t,n){return tq.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}(sg);sC._isCopyMode=!0,sC._supportInterpolationMode=!0,sC=t6([nk()],sC);var sT=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tU,t}return t5(t,e),t._initializeOwner=function(e){e.defaultValue=new tU,e.fixedPoseValue=new tU,e.baseEvaluateData.value=new tU,e.crossEvaluateData.value=new tU},t._initializeLayerOwner=function(e){e.finalValue=new tU},t._lerpValue=function(e,t,n,r){return tU.lerp(e,t,n,r),r},t._relativeBaseValue=function(e,t){return tU.subtract(t,e,t),t},t._additiveValue=function(e,t,n){return tU.scale(e,t,e),tU.add(n,e,n),n},t._subtractValue=function(e,t,n){return tU.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}(sg);sT._isCopyMode=!0,sT._supportInterpolationMode=!0,sT=t6([nk()],sT);var sR=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tZ,t}return t5(t,e),t._initializeOwner=function(e){e.defaultValue=new tZ,e.fixedPoseValue=new tZ,e.baseEvaluateData.value=new tZ,e.crossEvaluateData.value=new tZ},t._initializeLayerOwner=function(e){e.finalValue=new tZ},t._lerpValue=function(e,t,n,r){return tZ.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tZ.scale(e,t,e),tZ.add(n,e,n),n},t._subtractValue=function(e,t,n){return tZ.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}(sg);sR._isCopyMode=!0,sR._supportInterpolationMode=!0,sR=t6([nk()],sR);var sE=/*#__PURE__*/function(e){function t(){return e.call(this)||this}return t5(t,e),t._initializeOwner=function(e){},t._initializeLayerOwner=function(e){},t._setValue=function(e){return e},t}(sg);sE._isCopyMode=!1,sE._supportInterpolationMode=!1,sE=t6([nk()],sE);var sM=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new t$,t}return t5(t,e),t._initializeOwner=function(e){e.defaultValue=new t$,e.fixedPoseValue=new t$,e.baseEvaluateData.value=new t$,e.crossEvaluateData.value=new t$},t._initializeLayerOwner=function(e){e.finalValue=new t$},t._setValue=function(e,t){return t.copyFrom(e),t},t}(sg);sM._isCopyMode=!0,sM._supportInterpolationMode=!1,sM=t6([nk()],sM);var sP=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value="",t}return t5(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}(sg);sP._isCopyMode=!1,sP._supportInterpolationMode=!1,sP=t6([nk()],sP);var sw=((eH={})[eH.If=0]="If",eH[eH.IfNot=1]="IfNot",eH[eH.Greater=2]="Greater",eH[eH.Less=3]="Less",eH[eH.Equals=4]="Equals",eH[eH.NotEquals=5]="NotEquals",eH),sF=((eW={})[eW.None=0]="None",eW[eW.Complete=1]="Complete",eW),sL=((eX={})[eX.Override=0]="Override",eX[eX.Additive=1]="Additive",eX),sD=((ej={})[ej.UnStarted=0]="UnStarted",ej[ej.Playing=1]="Playing",ej[ej.Finished=2]="Finished",ej),sB=((eY={})[eY.Standby=0]="Standby",eY[eY.Playing=1]="Playing",eY[eY.CrossFading=2]="CrossFading",eY[eY.FixedCrossFading=3]="FixedCrossFading",eY[eY.Finished=4]="Finished",eY),sI=/*#__PURE__*/function(){function e(){this.handlers=[]}return e.prototype.dispose=function(){},e}(),sN=function(){},sO=/*#__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 sN;return r.parameterName=e,r.mode=null!=t?t:sw.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()},t4(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}(),sV=((eK={})[eK.Once=0]="Once",eK[eK.Loop=1]="Loop",eK),sk=/*#__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=sD.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=sD.Playing,t.wrapMode===sV.Loop?n=r?n%r:0:Math.abs(n)>=r&&(n=n<0?-r:r,this.playState=sD.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}(),sU=/*#__PURE__*/function(){function e(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new sk,this.destPlayData=new sk,this.layerState=sB.Standby,this.crossCurveMark=0,this.manuallyTransition=new sO,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}(),sz=function(){this.curveLayerOwner=[],this.eventHandlers=[]},sG=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).cullingMode=sF.None,n.speed=1,n._playFrameCount=-1,n._onUpdateIndex=-1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new oR(sI),n._parametersValueMap=Object.create(null),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n}t5(t,e);var n=t.prototype;return n.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)},n.crossFade=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!1)},n.crossFadeInFixedDuration=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!0)},n.update=function(e){if(this._playFrameCount===this.engine.time.frameCount&&(e=0),this.cullingMode===sF.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)}}},n.getCurrentAnimatorState=function(e){var t,n;return null==(n=this._animatorLayersData[e])?void 0:null==(t=n.srcPlayData)?void 0:t.state},n.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},n.findLayerByName=function(e){var t;return null==(t=this._animatorController)?void 0:t._layersMap[e]},n.getParameter=function(e){var t,n;return null!=(n=null==(t=this._animatorController)?void 0:t._parametersMap[e])?n:null},n.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},n.setParameterValue=function(e,t){var n;(null==(n=this._animatorController)?void 0:n._parametersMap[e])&&(this._parametersValueMap[e]=t)},n.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)},n.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)},n._onEnable=function(){this._reset(),this._entity.getComponentsIncludeChildren(ah,this._controlledRenderers)},n._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},n._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},n._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)},n._cloneTo=function(e){var t=e._animatorController;t&&(e._addResourceReferCount(t,1),e._controllerUpdateFlag=t._registerChangeFlag())},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t,n=this._animatorController;n&&(this._addResourceReferCount(n,-1),null==(t=this._controllerUpdateFlag)||t.destroy())},n._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)},n._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},n._getAnimatorStateData=function(e,t,n,r){var i=n.animatorStateDataMap,a=i[e];return a||(a=new sz,i[e]=a,this._saveAnimatorStateData(t,a,n,r),this._saveAnimatorEventHandlers(t,a)),a},n._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=ss._components,d=l.length-1;d>=0;d--){var h=l[d],_=h.relativePath,f=""===h.relativePath?i:i.findByPath(h.relativePath);if(f){var p,m,g=h.typeIndex>0?f.getComponents(h.type,u)[h.typeIndex]:f.getComponent(h.type);if(u.length=0,!g)continue;var v=h.property,y=g.instanceId,x=a[y]||(a[y]=Object.create(null)),A=x[v]||(x[v]=h._createCurveOwner(f,g)),b=c[y]||(c[y]=Object.create(null)),S=b[v]||(b[v]=h._createCurveLayerOwner(A));o&&o.pathMasks.length&&(S.isActive=null==(m=null==(p=o.getPathMask(_))?void 0:p.active)||m),s[d]=S}else s[d]=null,nb.warn("The entity don't have the child entity which path is "+h.relativePath+".")}},n._saveAnimatorEventHandlers=function(e,t){var n=this,r=this._animationEventHandlerPool,i=[],a=t.eventHandlers,o=function(){n._entity.getComponents(o7,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)},n._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},n._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},n._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},n._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},n._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)},n._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))}},n._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)}}}},n._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||((t=new sU).layerIndex=e,t.layer=this._animatorController.layers[e],this._animatorLayersData[e]=t),t},n._updateState=function(e,t,n){var r=e.layer,i=r.weight,a=r.blendingMode===sL.Additive;switch(0===e.layerIndex&&(i=1),e.layerState){case sB.Standby:this._checkAnyAndEntryState(e,t,n);break;case sB.Playing:this._updatePlayingState(e,i,a,t,n);break;case sB.Finished:this._updateFinishedState(e,i,a,t,n);break;case sB.CrossFading:this._updateCrossFadeState(e,i,a,t,n);break;case sB.FixedCrossFading:this._updateCrossFadeFromPoseState(e,i,a,t,n)}},n._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===sD.Finished&&(e.layerState=sB.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)}},n._evaluatePlayingState=function(e,t,n,r){var i=e.state.clip._curveBindings,a=e.playState===sD.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()}}}},n._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();if(!this._tryCrossFadeInterrupt(e,h,d,r,i)){var _=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 A=s.playedTime;a=A-p>h?A-h:p}var b=0===f?r:a/f,S=b*_;o.update(S),s.update(a);var C=Math.abs(s.playedTime)/h;(C>=1-tk.zeroTolerance||0===h)&&(C=1);var T=1===C;if(T?(o.playState=sD.Finished,this._preparePlayOwner(e,d),this._evaluatePlayingState(s,t,n,i)):this._evaluateCrossFadeState(e,o,s,t,C,n,i),this._fireAnimationEventsAndCallScripts(l,o,u,m,g,S),this._fireAnimationEventsAndCallScripts(l,s,d,v,y,a),T){this._updateCrossFadeData(e);var R=r-b;R>0&&this._updateState(e,R,i)}}},n._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===sD.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()}}},n._updateCrossFadeFromPoseState=function(e,t,n,r,i){var a,o=e.destPlayData,s=o.state,l=e.crossFadeTransition._getFixedDuration();if(!this._tryCrossFadeInterrupt(e,l,s,r,i)){var 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-tk.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)}}},n._evaluateCrossFadeFromPoseState=function(e,t,n,r,i,a){var o=e.crossLayerOwnerCollection,s=t.state.clip._curveBindings,l=t.clipTime,c=t.playState===sD.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()}}},n._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)},n._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))}},n._updateCrossFadeData=function(e){e.destPlayData.playState===sD.Finished?e.layerState=sB.Finished:e.layerState=sB.Playing,e.switchPlayData(),e.crossFadeTransition=null},n._preparePlayOwner=function(e,t){if(e.layerState===sB.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()},n._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._checkNoExitTimeTransitions(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},n._tryCrossFadeInterrupt=function(e,t,n,r,i){if(t>0){var a=e.layer.stateMachine._anyStateTransitionCollection;if(a.noExitTimeCount&&this._checkNoExitTimeTransitions(e,a,i,n))return this._updateState(e,r,i),!0}return!1},n._checkNoExitTimeTransitions=function(e,t,n,r){for(var i=0,a=t.noExitTimeCount;i<a;++i){var o=t.get(i);if((!r||o.destinationState!==r)&&!o.mute&&(!t.isSoloMode||o.solo)&&this._checkConditions(o))return this._applyTransition(e,o,n)}return null},n._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},n._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},n._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))return this._applyTransition(e,a,n)}},n._preparePlay=function(e,t,n){void 0===n&&(n=0);var r=e.name;if(!e.clip)return nb.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=sB.Playing,i.srcPlayData.reset(e,a,e._getClipActualEndTime()*n),i.resetCurrentCheckIndex(),!0},n._applyTransition=function(e,t,n){return t.isExit?(this._checkAnyAndEntryState(e,0,n),null):this._prepareCrossFadeByTransition(t,e.layerIndex)?t:null},n._checkConditions=function(e){for(var n=e.conditions,r=!0,i=0,a=n.length;i<a;++i){var o=!1,s=n[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)&&(t._passedTriggerParameterNames.push(c),o=!0)}if(!o)switch(l){case sw.Equals:d===u&&(o=!0);break;case sw.Greater:d>u&&(o=!0);break;case sw.Less:d<u&&(o=!0);break;case sw.NotEquals:d!==u&&(o=!0);break;case sw.If:!0===d&&(o=!0);break;case sw.IfNot:!1===d&&(o=!0)}if(!o){r=!1;break}}return r&&this._deactivateTriggeredParameters(),t._passedTriggerParameterNames.length=0,r},n._prepareCrossFadeByTransition=function(e,t){var n=e.destinationState;if(!n)return!1;if(!n.clip)return nb.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 sB.Standby:case sB.Finished:r.layerState=sB.FixedCrossFading,this._clearCrossData(r),this._prepareStandbyCrossFading(r);break;case sB.Playing:r.layerState=sB.CrossFading,this._clearCrossData(r),this._prepareCrossFading(r);break;case sB.CrossFading:r.layerState=sB.FixedCrossFading,this._prepareFixedPoseCrossFading(r);break;case sB.FixedCrossFading:this._prepareFixedPoseCrossFading(r)}return r.crossFadeTransition=e,!0},n._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)},n._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)}}},n._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)}}},n._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))}},n._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},n._fireAnimationEventsAndCallScripts=function(e,t,n,r,i,a){var o=t.stateData.eventHandlers;o.length&&this._fireAnimationEvents(t,o,r,a),i===sD.UnStarted&&n._callOnEnter(this,e),i!==sD.Finished&&t.playState===sD.Finished?n._callOnExit(this,e):n._callOnUpdate(this,e)},n._deactivateTriggeredParameters=function(){for(var e=t._passedTriggerParameterNames,n=0,r=e.length;n<r;n++)this._parametersValueMap[e[n]]=!1},t4(t,[{key:"animatorController",get:function(){return this._animatorController},set:function(e){var t=this._animatorController;e!==t&&(t&&this._addResourceReferCount(t,-1),this._controllerUpdateFlag&&this._controllerUpdateFlag.destroy(),this._reset(),e&&(this._addResourceReferCount(e,1),this._controllerUpdateFlag=e._registerChangeFlag(),e._setEngine(this.engine)),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}}]),t}(rN);sG._passedTriggerParameterNames=[],t6([nn],sG.prototype,"speed",void 0),t6([nn],sG.prototype,"_animatorController",void 0),t6([nt],sG.prototype,"_controllerUpdateFlag",void 0),t6([nt],sG.prototype,"_updateMark",void 0),t6([nt],sG.prototype,"_animatorLayersData",void 0),t6([nt],sG.prototype,"_curveOwnerPool",void 0),t6([nt],sG.prototype,"_animationEventHandlerPool",void 0),t6([nt],sG.prototype,"_parametersValueMap",void 0),t6([nt],sG.prototype,"_tempAnimatorStateInfo",void 0),t6([nt],sG.prototype,"_controlledRenderers",void 0);var sH=/*#__PURE__*/function(){function e(){this._onNameChanged=null,this._isTrigger=!1}return t4(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}(),sW=/*#__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 n4),function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}t5(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,e._setEngine(this._engine),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(rz)},n._setEngine=function(e){for(var t=this._layers,n=0,r=t.length;n<r;n++)t[n]._setEngine(e)},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 sH;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},t4(t,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),t}(ns),sX=/*#__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 t7(e,sY)?((t=new sO).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),t&&this.noExitTimeCount--,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=this.noExitTimeCount,i=t.length;if(n>=(i>r?t[i-1].exitTime:0))t.push(e);else{for(var a=i;--a>=r&&n<t[a].exitTime;);t.splice(a+1,0,e)}},t4(e,[{key:"isSoloMode",get:function(){return this._soloCount>0}},{key:"count",get:function(){return this.transitions.length}}]),e}(),sj=/*#__PURE__*/function(e){function t(){return e.call(this,null)||this}t5(t,e);var n=t.prototype;return n.onStateEnter=function(e,t,n){},n.onStateUpdate=function(e,t,n){},n.onStateExit=function(e,t,n){},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._state._removeStateMachineScript(this)},t}(no),sY=/*#__PURE__*/function(){function e(e){this.name=e,this.speed=1,this.wrapMode=sV.Loop,this._updateFlagManager=new n4,this._transitionCollection=new sX,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],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 sO;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._engine=this._engine,t._state=this;var n=sj.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._callOnEnter=function(e,t){for(var n=this._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(e,this,t)},t._callOnUpdate=function(e,t){for(var n=this._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(e,this,t)},t._callOnExit=function(e,t){for(var n=this._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(e,this,t)},t._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},t._removeStateMachineScript=function(e){var t=sj.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},t._setEngine=function(e){this._engine=e;for(var t=this._onStateEnterScripts,n=this._onStateUpdateScripts,r=this._onStateExitScripts,i=0,a=t.length;i<a;i++)t[i]._engine=e;for(var o=0,s=n.length;o<s;o++)n[o]._engine=e;for(var l=0,c=r.length;l<c;l++)r[l]._engine=e},t4(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}(),sK=/*#__PURE__*/function(){function e(){this.states=[],this._entryTransitionCollection=new sX,this._anyStateTransitionCollection=new sX,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 sY(e))._setEngine(this._engine),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()},t._setEngine=function(e){this._engine=e;for(var t=this.states,n=0,r=t.length;n<r;n++)t[n]._setEngine(e)},t4(e,[{key:"entryTransitions",get:function(){return this._entryTransitionCollection.transitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitionCollection.transitions}}]),e}(),sQ=/*#__PURE__*/function(){function e(e){this.name=e,this.weight=1,this.blendingMode=sL.Override,this.stateMachine=new sK}return e.prototype._setEngine=function(e){this.stateMachine._setEngine(e)},e}(),sq=function(){},sZ=function(){},sJ=/*#__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 sZ;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)}},t4(e,[{key:"pathMasks",get:function(){return this._pathMasks}}]),e}(),s$=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,rM.find("skybox"))||this)._tintColor=new tJ(1,1,1,1),r.renderState.rasterState.cullMode=rn.Off,r.renderState.depthState.compareFunction=rt.LessEqual,r.shaderData.setFloat(t._rotationProp,0),r.shaderData.setFloat(t._exposureProp,1),r.shaderData.setColor(t._tintColorProp,r._tintColor),r}return t5(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t4(t,[{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}(r3);s$._tintColorProp=nH.getByName("material_TintColor"),s$._textureCubeProp=nH.getByName("material_CubeTexture"),s$._rotationProp=nH.getByName("material_Rotation"),s$._exposureProp=nH.getByName("material_Exposure");var s0=((eQ={})[eQ.None=0]="None",eQ[eQ.Simple=1]="Simple",eQ[eQ.HighQuality=2]="HighQuality",eQ),s1=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,rM.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new tJ(.21404114048223255,.21404114048223255,.21404114048223255,1),n.groundTint=new tJ(.11216882039252905,.09988709277986121,.09520561068319185,1),n.exposure=1.3,n.renderState.rasterState.cullMode=rn.Off,n.renderState.depthState.compareFunction=rt.LessEqual,n}return t5(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t4(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}(r3);s1._sunSizeProp=nH.getByName("material_SunSize"),s1._sunSizeConvergenceProp=nH.getByName("material_SunSizeConvergence"),s1._atmosphereThicknessProp=nH.getByName("material_AtmosphereThickness"),s1._skyTintProp=nH.getByName("material_SkyTint"),s1._groundTintProp=nH.getByName("material_GroundTint"),s1._exposureProp=nH.getByName("material_Exposure"),s1._sunHighQualityMacro=rc.getByName("MATERIAL_SUN_HIGH_QUALITY"),s1._sunSimpleMacro=rc.getByName("MATERIAL_SUN_SIMPLE");var s2=((eq={})[eq.Billboard=0]="Billboard",eq[eq.StretchBillboard=1]="StretchBillboard",eq[eq.HorizontalBillboard=2]="HorizontalBillboard",eq[eq.VerticalBillboard=3]="VerticalBillboard",eq[eq.Mesh=4]="Mesh",eq[eq.None=5]="None",eq),s3=((eZ={})[eZ.Local=0]="Local",eZ[eZ.World=1]="World",eZ),s4=((eJ={})[eJ.StopEmittingAndClear=0]="StopEmittingAndClear",eJ[eJ.StopEmitting=1]="StopEmitting",eJ),s8=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).velocityScale=0,r.lengthScale=2,r.pivot=new tU,r._generatorBounds=new tG,r._transformedBounds=new tG,r._onGeneratorParamsChanged=r._onGeneratorParamsChanged.bind(r),r.generator=new lb(r),r._currentRenderModeMacro=t._billboardModeMacro,r.shaderData.enableMacro(t._billboardModeMacro),r._supportInstancedArrays=r.engine._hardwareRenderer.canIUse(nT.instancedArrays),r._onGeneratorParamsChanged(),r}t5(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,s4.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===s3.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._useTransformFeedback&&n._updateFeedback(r,this.engine.time.deltaTime*n.main.simulationSpeed)}},n._render=function(e){var t=this.generator,n=t._getAliveParticleCount();if(n){t._primitive.instanceCount=t._useTransformFeedback?t._firstActiveElement<=t._firstFreeElement?t._firstFreeElement:t._currentParticleCount:n;var r=this.getMaterial();if(r&&(this._renderMode!==s2.Mesh||this._mesh)){(r.destroyed||r.shader.destroyed)&&(r=this.engine._basicResources.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|=a_.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|a_.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|a_.WorldVolume},t4(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;switch(e){case s2.Billboard:r=t._billboardModeMacro;break;case s2.StretchBillboard:r=t._stretchedBillboardModeMacro;break;case s2.HorizontalBillboard:case s2.VerticalBillboard:throw"Not implemented";case s2.Mesh:r=t._meshModeMacro}if(this._currentRenderModeMacro!==r){var i=this.shaderData;this._currentRenderModeMacro&&i.disableMacro(this._currentRenderModeMacro),r&&i.enableMacro(r),this._currentRenderModeMacro=r}var a=n===s2.Mesh,o=e===s2.Mesh;a!==o&&(!o||this.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&&(1!==e.subMeshes.length&&nb.error("Particle emit mesh must have only one sub mesh."),this._addResourceReferCount(e,1),this.renderMode===s2.Mesh&&this.generator._reorganizeGeometryBuffers()))}}]),t}(ah);s8._billboardModeMacro=rc.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),s8._stretchedBillboardModeMacro=rc.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),s8._horizontalBillboardModeMacro=rc.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),s8._verticalBillboardModeMacro=rc.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),s8._meshModeMacro=rc.getByName("RENDERER_MODE_MESH"),s8._pivotOffsetProperty=nH.getByName("renderer_PivotOffset"),s8._lengthScale=nH.getByName("renderer_StretchedBillboardLengthScale"),s8._speedScale=nH.getByName("renderer_StretchedBillboardSpeedScale"),s8._currentTime=nH.getByName("renderer_CurrentTime"),t6([ni],s8.prototype,"generator",void 0),t6([nr],s8.prototype,"pivot",void 0),t6([nt],s8.prototype,"_generatorBounds",void 0),t6([nt],s8.prototype,"_transformedBounds",void 0),t6([nt],s8.prototype,"_onGeneratorParamsChanged",null),t6([nt],s8.prototype,"_onTransformChanged",null);var s5=((e$={})[e$.TransformVolume=2]="TransformVolume",e$[e$.GeneratorVolume=4]="GeneratorVolume",e$),s9=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._platformTransformFeedback=t._hardwareRenderer.createPlatformTransformFeedback(),n}t5(t,e);var n=t.prototype;return n.bind=function(){this._platformTransformFeedback.bind()},n.bindBufferRange=function(e,t,n,r){this._platformTransformFeedback.bindBufferRange(e,t._platformBuffer,n,r)},n.begin=function(e){this._platformTransformFeedback.begin(e)},n.end=function(){this._platformTransformFeedback.end()},n.unbindBuffer=function(e){this._platformTransformFeedback.unbindBuffer(e)},n.unbind=function(){this._platformTransformFeedback.unbind()},n._rebuild=function(){this._platformTransformFeedback=this._engine._hardwareRenderer.createPlatformTransformFeedback()},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformTransformFeedback.destroy()},t}(nm),s6=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._readIsA=!0,r._byteStride=n,r._transformFeedback=new s9(t),r._transformFeedback.isGCIgnored=!0,r._platformPrimitive=t._hardwareRenderer.createPlatformTransformFeedbackPrimitive(),r.isGCIgnored=!0,r}t5(t,e);var n=t.prototype;return n.resize=function(e){var t=this._byteStride*e,n=new ax(this._engine,aT.VertexBuffer,t,av.Dynamic,!1);n.isGCIgnored=!0;var r=new ax(this._engine,aT.VertexBuffer,t,av.Dynamic,!1);r.isGCIgnored=!0,this._bindingA=new aO(n,this._byteStride),this._bindingB=new aO(r,this._byteStride),this._readIsA=!0,this._platformPrimitive.invalidate()},n.updateVertexLayout=function(e,t,n,r){this._platformPrimitive.updateVertexLayout(e,this._bindingA,this._bindingB,t,n,r)},n.beginDraw=function(){this._engine._hardwareRenderer.enableRasterizerDiscard(),this._transformFeedback.bind(),this._platformPrimitive.bind(this._readIsA)},n.draw=function(e,t,n){var r=this._transformFeedback;r.bindBufferRange(0,this.writeBinding.buffer,t*this._byteStride,n*this._byteStride),r.begin(e),this._platformPrimitive.draw(e,t,n),r.end()},n.endDraw=function(){this._platformPrimitive.unbind(),this._transformFeedback.unbindBuffer(0),this._transformFeedback.unbind(),this._engine._hardwareRenderer.disableRasterizerDiscard(),this._engine._hardwareRenderer.invalidateShaderProgramState()},n.swap=function(){this._readIsA=!this._readIsA},n._rebuild=function(){this._platformPrimitive=this._engine._hardwareRenderer.createPlatformTransformFeedbackPrimitive()},n._onDestroy=function(){var t,n,r,i;e.prototype._onDestroy.call(this),null==(t=this._platformPrimitive)||t.destroy(),null==(n=this._bindingA)||n.buffer.destroy(),null==(r=this._bindingB)||r.buffer.destroy(),null==(i=this._transformFeedback)||i.destroy()},t4(t,[{key:"readBinding",get:function(){return this._readIsA?this._bindingA:this._bindingB}},{key:"writeBinding",get:function(){return this._readIsA?this._bindingB:this._bindingA}}]),t}(nm),s7=/*#__PURE__*/function(){function e(e,t,n){this._engine=e,this._primitive=new s6(e,t),this._shader=n}var t=e.prototype;return t.resize=function(e){this._primitive.resize(e)},t.beginUpdate=function(e,t,n,r){var i=this._shader.getProgram(this._engine,e._macroCollection);return!!i&&(i.bind(),i.uploadUniforms(i.rendererUniformBlock,e),i.uploadUniforms(i.otherUniformBlock,e),this._primitive.updateVertexLayout(i,t,n,r),this._primitive.beginDraw(),!0)},t.draw=function(e,t,n){this._primitive.draw(e,t,n)},t.endUpdate=function(){this._primitive.endDraw(),this._primitive.swap()},t.destroy=function(){var e;null==(e=this._primitive)||e.destroy()},t4(e,[{key:"readBinding",get:function(){return this._primitive.readBinding}},{key:"writeBinding",get:function(){return this._primitive.writeBinding}}]),e}(),le=/*#__PURE__*/function(){function e(e){this._particleInitData=new Float32Array(6),this._simulator=new s7(e,oU.feedbackVertexStride,oH.particleFeedbackShader)}var t=e.prototype;return t.resize=function(e,t){var n,r;this._oldReadBuffer=null==(n=this._simulator.readBinding)?void 0:n.buffer,this._oldWriteBuffer=null==(r=this._simulator.writeBinding)?void 0:r.buffer,this._simulator.resize(e),this._instanceBinding=t},t.writeParticleData=function(e,t,n,r,i){var a=this._particleInitData;a[0]=t.x,a[1]=t.y,a[2]=t.z,a[3]=n,a[4]=r,a[5]=i;var o=this._simulator,s=e*oU.feedbackVertexStride;o.readBinding.buffer.setData(a,s),o.writeBinding.buffer.setData(a,s)},t.copyOldBufferData=function(e,t,n){this._simulator.readBinding.buffer.copyFromBuffer(this._oldReadBuffer,e,t,n),this._simulator.writeBinding.buffer.copyFromBuffer(this._oldWriteBuffer,e,t,n)},t.destroyOldBuffers=function(){var e,t;null==(e=this._oldReadBuffer)||e.destroy(),null==(t=this._oldWriteBuffer)||t.destroy(),this._oldReadBuffer=null,this._oldWriteBuffer=null},t.update=function(t,n,r,i,a){r!==i&&(t.setFloat(e._deltaTimeProperty,a),this._simulator.beginUpdate(t,oU.feedbackVertexElements,this._instanceBinding,oU.feedbackInstanceElements)&&(r<i?this._simulator.draw(aR.Points,r,i-r):(this._simulator.draw(aR.Points,r,n-r),i>0&&this._simulator.draw(aR.Points,0,i)),this._simulator.endUpdate()))},t.destroy=function(){var e;null==(e=this._simulator)||e.destroy()},t4(e,[{key:"readBinding",get:function(){return this._simulator.readBinding}}]),e}();le._deltaTimeProperty=nH.getByName("renderer_DeltaTime");var lt=((e0={})[e0.Constant=0]="Constant",e0[e0.TwoConstants=1]="TwoConstants",e0[e0.Curve=2]="Curve",e0[e0.TwoCurves=3]="TwoCurves",e0),ln=((e1={})[e1.Constant=0]="Constant",e1[e1.TwoConstants=1]="TwoConstants",e1[e1.Gradient=2]="Gradient",e1[e1.TwoGradients=3]="TwoGradients",e1),lr=((e2={})[e2.Burst=0x23571a3e]="Burst",e2[e2.StartDelay=0x13371337]="StartDelay",e2[e2.StartColor=0x12460f3b]="StartColor",e2[e2.StartSize=0x6aed452e]="StartSize",e2[e2.StartRotation=0xdec4aea1]="StartRotation",e2[e2.randomizeRotationDirection=0x96aa4de3]="randomizeRotationDirection",e2[e2.StartLifetime=0x8d2c8431]="StartLifetime",e2[e2.StartSpeed=0xf3857f6f]="StartSpeed",e2[e2.VelocityOverLifetime=0xe0fbd834]="VelocityOverLifetime",e2[e2.ColorOverLifetime=0x13740583]="ColorOverLifetime",e2[e2.SizeOverLifetime=0x591bc05c]="SizeOverLifetime",e2[e2.RotationOverLifetime=0x40eb95e4]="RotationOverLifetime",e2[e2.TextureSheetAnimation=0xbc524e5]="TextureSheetAnimation",e2[e2.Shape=0xaf502044]="Shape",e2[e2.GravityModifier=0xa47b8c4d]="GravityModifier",e2[e2.ForceOverLifetime=0xe6fb937c]="ForceOverLifetime",e2[e2.LimitVelocityOverLifetime=0xb5a21f7e]="LimitVelocityOverLifetime",e2),li=/*#__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 la(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 lo(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(){var e=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var t=this._colorKeys,n=0,r=Math.min(t.length,4);n<r;n++){var i=4*n,a=t[n];e[i]=a.time;var o=a.color;e[i+1]=o.r,e[i+2]=o.g,e[i+3]=o.b}this._colorTypeArrayDirty=!1}return e},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},t4(e,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),e}();t6([ni],li.prototype,"_colorKeys",void 0),t6([ni],li.prototype,"_alphaKeys",void 0),t6([nt],li.prototype,"_colorTypeArray",void 0),t6([nt],li.prototype,"_alphaTypeArray",void 0),t6([nt],li.prototype,"_setColorTypeArrayDirty",null),t6([nt],li.prototype,"_setAlphaTypeArrayDirty",null);var la=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._color=new tJ,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged}return t4(e,[{key:"time",get:function(){return this._time},set:function(e){this._time=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}}]),e}(),lo=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._time=e,this._alpha=t}return t4(e,[{key:"time",get:function(){return this._time},set:function(e){this._time=e,null==this._onValueChanged||this._onValueChanged.call(this)}},{key:"alpha",get:function(){return this._alpha},set:function(e){this._alpha=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}(),ls=/*#__PURE__*/function(){function e(e,t){this.mode=ln.Constant,this.constantMin=new tJ,this.constantMax=new tJ,this.gradientMin=new li,this.gradientMax=new li,e.constructor===tJ?t?(this.constantMin.copyFrom(e),this.constantMax.copyFrom(t),this.mode=ln.TwoConstants):(this.constant.copyFrom(e),this.mode=ln.Constant):t?(this.gradientMin=e,this.gradientMax=t,this.mode=ln.TwoGradients):(this.gradient=e,this.mode=ln.Gradient)}return e.prototype.evaluate=function(e,t,n){switch(this.mode){case ln.Constant:n.copyFrom(this.constant);break;case ln.TwoConstants:tJ.lerp(this.constantMin,this.constantMax,t,n)}},t4(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}();t6([ni],ls.prototype,"constantMin",void 0),t6([ni],ls.prototype,"constantMax",void 0),t6([ni],ls.prototype,"gradientMin",void 0),t6([ni],ls.prototype,"gradientMax",void 0);var ll=/*#__PURE__*/function(){function e(e){this._enabled=!1,this._generator=e}var t=e.prototype;return t._enableMacro=function(e,t,n){return t!==n&&(t&&e.disableMacro(t),n&&e.enableMacro(n)),n},t._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},t4(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),e}();t6([nt],ll.prototype,"_generator",void 0);var lc=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.color=new ls(new li([new la(0,new tJ(1,1,1)),new la(1,new tJ(1,1,1))],[new lo(0,1),new lo(1,1)])),t._colorGradientRand=new t1(0,lr.ColorOverLifetime),t._gradientKeysCount=new tZ(0,0,0,0),t}t5(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.color.mode;if(r!==ln.Gradient&&r!==ln.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var i=this.color;e.setFloatArray(t._maxGradientColor,i.gradientMax._getColorTypeArray()),e.setFloatArray(t._maxGradientAlpha,i.gradientMax._getAlphaTypeArray()),r===ln.Gradient?n=t._gradientMacro:(e.setFloatArray(t._minGradientColor,i.gradientMin._getColorTypeArray()),e.setFloatArray(t._minGradientAlpha,i.gradientMin._getAlphaTypeArray()),n=t._randomGradientsMacro);var a=i.gradientMin.colorKeys,o=i.gradientMin.alphaKeys,s=i.gradientMax.colorKeys,l=i.gradientMax.alphaKeys;this._gradientKeysCount.set(a.length?a[a.length-1].time:0,o.length?o[o.length-1].time:0,s.length?s[s.length-1].time:0,l.length?l[l.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,lr.ColorOverLifetime)},t}(ll);lc._gradientMacro=rc.getByName("RENDERER_COL_GRADIENT"),lc._randomGradientsMacro=rc.getByName("RENDERER_COL_RANDOM_GRADIENTS"),lc._minGradientColor=nH.getByName("renderer_COLMinGradientColor"),lc._minGradientAlpha=nH.getByName("renderer_COLMinGradientAlpha"),lc._maxGradientColor=nH.getByName("renderer_COLMaxGradientColor"),lc._maxGradientAlpha=nH.getByName("renderer_COLMaxGradientAlpha"),lc._gradientKeysCount=nH.getByName("renderer_COLGradientKeysMaxTime"),t6([ni],lc.prototype,"color",void 0),t6([nt],lc.prototype,"_colorGradientRand",void 0),t6([nt],lc.prototype,"_gradientKeysCount",void 0),t6([nt],lc.prototype,"_colorMacro",void 0);var lu=/*#__PURE__*/function(){function e(e,t){this._updateManager=new n4,this._mode=lt.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=lt.TwoConstants):(this.constant=e,this.mode=lt.Constant):t?(this.curveMin=e,this.curveMax=t,this.mode=lt.TwoCurves):(this.curve=e,this.mode=lt.Curve)}var t=e.prototype;return t.evaluate=function(e,t){switch(this.mode){case lt.Constant:return this.constant;case lt.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*t;case lt.Curve:var n;return null==(n=this.curve)?void 0:n._evaluate(e);case lt.TwoCurves:var r,i,a=null==(r=this.curveMin)?void 0:r._evaluate(e);return a+((null==(i=this.curveMax)?void 0:i._evaluate(e))-a)*t}},t._getMax=function(){switch(this.mode){case lt.Constant:return this.constantMax;case lt.TwoConstants:return Math.max(this.constantMin,this.constantMax);case lt.Curve:var e;return this._getMaxKeyValue(null==(e=this.curveMax)?void 0:e.keys);case lt.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 lt.Constant:e.x=e.y=this.constantMax;break;case lt.TwoConstants:e.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case lt.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 lt.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()},t4(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}();t6([nt],lu.prototype,"_updateManager",void 0),t6([ni],lu.prototype,"_curveMin",void 0),t6([ni],lu.prototype,"_curveMax",void 0),t6([nt],lu.prototype,"_updateDispatch",void 0);var ld=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.rateOverTime=new lu(10),t.rateOverDistance=new lu(0),t._shapeRand=new t1(0,lr.Shape),t._frameRateTime=0,t._bursts=[],t._currentBurstIndex=0,t._burstRand=new t1(0,lr.Burst),t}t5(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,lr.Burst),this._shapeRand.reset(e,lr.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},t4(t,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,e&&this._shape?this._generator._renderer.shaderData.enableMacro(t._emissionShapeMacro):this._generator._renderer.shaderData.disableMacro(t._emissionShapeMacro))}},{key:"shape",get:function(){return this._shape},set:function(e){var n=this._shape;if(e!==n){this._shape=e;var r=this._generator._renderer;null==n||n._unRegisterOnValueChanged(r._onGeneratorParamsChanged),e?(e._registerOnValueChanged(r._onGeneratorParamsChanged),this.enabled&&r.shaderData.enableMacro(t._emissionShapeMacro)):r.shaderData.disableMacro(t._emissionShapeMacro),r._onGeneratorParamsChanged()}}},{key:"bursts",get:function(){return this._bursts}}]),t}(ll);ld._emissionShapeMacro=rc.getByName("RENDERER_EMISSION_SHAPE"),t6([ni],ld.prototype,"rateOverTime",void 0),t6([ni],ld.prototype,"rateOverDistance",void 0),t6([ni],ld.prototype,"_shape",void 0),t6([nt],ld.prototype,"_shapeRand",void 0),t6([ni],ld.prototype,"_bursts",void 0),t6([nt],ld.prototype,"_burstRand",void 0);var lh=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._forceRand=new t1(0,lr.ForceOverLifetime),n._forceMinConstant=new tU,n._forceMaxConstant=new tU,n._space=s3.Local,n.forceX=new lu(0),n.forceY=new lu(0),n.forceZ=new lu(0),n}t5(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null;if(this.enabled){var i=this._forceX,a=this._forceY,o=this._forceZ,s=i.mode===lt.TwoCurves&&a.mode===lt.TwoCurves&&o.mode===lt.TwoCurves;if(s||i.mode===lt.Curve&&a.mode===lt.Curve&&o.mode===lt.Curve)e.setFloatArray(t._maxGradientXProperty,i.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientYProperty,a.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientZProperty,o.curveMax._getTypeArray()),n=t._curveModeMacro,s&&(e.setFloatArray(t._minGradientXProperty,i.curveMin._getTypeArray()),e.setFloatArray(t._minGradientYProperty,a.curveMin._getTypeArray()),e.setFloatArray(t._minGradientZProperty,o.curveMin._getTypeArray()),r=t._isRandomMacro);else{var l=this._forceMaxConstant;if(l.set(i.constantMax,a.constantMax,o.constantMax),e.setVector3(t._maxConstantProperty,l),n=t._constantModeMacro,i.mode===lt.TwoConstants&&a.mode===lt.TwoConstants&&o.mode===lt.TwoConstants){var c=this._forceMinConstant;c.set(i.constantMin,a.constantMin,o.constantMin),e.setVector3(t._minConstantProperty,c),r=t._isRandomMacro}}e.setInt(t._spaceProperty,this._space)}this._forceMacro=this._enableMacro(e,this._forceMacro,n),this._randomModeMacro=this._enableMacro(e,this._randomModeMacro,r)},n._resetRandomSeed=function(e){this._forceRand.reset(e,lr.ForceOverLifetime)},n._isRandomMode=function(){var e=this.forceX.mode,t=this.forceY.mode,n=this.forceZ.mode;return e===lt.TwoCurves&&t===lt.TwoCurves&&n===lt.TwoCurves||e===lt.TwoConstants&&t===lt.TwoConstants&&n===lt.TwoConstants},t4(t,[{key:"forceX",get:function(){return this._forceX},set:function(e){var t=this._forceX;e!==t&&(this._forceX=e,this._onCompositeCurveChange(t,e))}},{key:"forceY",get:function(){return this._forceY},set:function(e){var t=this._forceY;e!==t&&(this._forceY=e,this._onCompositeCurveChange(t,e))}},{key:"forceZ",get:function(){return this._forceZ},set:function(e){var t=this._forceZ;e!==t&&(this._forceZ=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())}}]),t}(ll);lh._constantModeMacro=rc.getByName("RENDERER_FOL_CONSTANT_MODE"),lh._curveModeMacro=rc.getByName("RENDERER_FOL_CURVE_MODE"),lh._isRandomMacro=rc.getByName("RENDERER_FOL_IS_RANDOM_TWO"),lh._minConstantProperty=nH.getByName("renderer_FOLMinConst"),lh._maxConstantProperty=nH.getByName("renderer_FOLMaxConst"),lh._minGradientXProperty=nH.getByName("renderer_FOLMinGradientX"),lh._minGradientYProperty=nH.getByName("renderer_FOLMinGradientY"),lh._minGradientZProperty=nH.getByName("renderer_FOLMinGradientZ"),lh._maxGradientXProperty=nH.getByName("renderer_FOLMaxGradientX"),lh._maxGradientYProperty=nH.getByName("renderer_FOLMaxGradientY"),lh._maxGradientZProperty=nH.getByName("renderer_FOLMaxGradientZ"),lh._spaceProperty=nH.getByName("renderer_FOLSpace"),t6([nt],lh.prototype,"_forceRand",void 0),t6([nt],lh.prototype,"_forceMinConstant",void 0),t6([nt],lh.prototype,"_forceMaxConstant",void 0),t6([nt],lh.prototype,"_forceMacro",void 0),t6([nt],lh.prototype,"_randomModeMacro",void 0),t6([ni],lh.prototype,"_forceX",void 0),t6([ni],lh.prototype,"_forceY",void 0),t6([ni],lh.prototype,"_forceZ",void 0);var l_=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._speedRand=new t1(0,lr.LimitVelocityOverLifetime),n._speedMinConstantVec=new tU,n._speedMaxConstantVec=new tU,n._dragConstantVec=new tq,n._separateAxes=!1,n._dampen=0,n._multiplyDragByParticleSize=!1,n._multiplyDragByParticleVelocity=!1,n._space=s3.Local,n.speedX=new lu(1),n.speedY=new lu(1),n.speedZ=new lu(1),n.drag=new lu(0),n}t5(t,e);var n=t.prototype;return n._isDragRandomMode=function(){return this._drag.mode===lt.TwoConstants||this._drag.mode===lt.TwoCurves},n._isSpeedRandomMode=function(){return this._separateAxes?(this._speedX.mode===lt.TwoConstants||this._speedX.mode===lt.TwoCurves)&&(this._speedY.mode===lt.TwoConstants||this._speedY.mode===lt.TwoCurves)&&(this._speedZ.mode===lt.TwoConstants||this._speedZ.mode===lt.TwoCurves):this._speedX.mode===lt.TwoConstants||this._speedX.mode===lt.TwoCurves},n._updateShaderData=function(e){var n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null;if(this.enabled){if(n=t._enabledMacro,e.setFloat(t._dampenProperty,this._dampen),e.setInt(t._spaceProperty,this._space),this._separateAxes){r=t._separateAxesMacro;var u=this._uploadSeparateAxisSpeeds(e);i=u.modeMacro,a=u.randomMacro}else{var d=this._uploadScalarSpeed(e);i=d.modeMacro,a=d.randomMacro}var h=this._uploadDrag(e);o=h.curveMacro,s=h.randomMacro,this._multiplyDragByParticleSize&&(l=t._multiplyDragBySizeMacro),this._multiplyDragByParticleVelocity&&(c=t._multiplyDragByVelocityMacro)}this._enabledModuleMacro=this._enableMacro(e,this._enabledModuleMacro,n),this._separateAxesCachedMacro=this._enableMacro(e,this._separateAxesCachedMacro,r),this._speedModeMacro=this._enableMacro(e,this._speedModeMacro,i),this._speedRandomMacro=this._enableMacro(e,this._speedRandomMacro,a),this._dragCurveCachedMacro=this._enableMacro(e,this._dragCurveCachedMacro,o),this._dragRandomCachedMacro=this._enableMacro(e,this._dragRandomCachedMacro,s),this._dragSizeMacro=this._enableMacro(e,this._dragSizeMacro,l),this._dragVelocityMacro=this._enableMacro(e,this._dragVelocityMacro,c)},n._resetRandomSeed=function(e){this._speedRand.reset(e,lr.LimitVelocityOverLifetime)},n._uploadScalarSpeed=function(e){var n=this._speedX,r=null,i=null,a=n.mode===lt.TwoCurves;return a||n.mode===lt.Curve?(e.setFloatArray(t._speedMaxCurveProperty,n.curveMax._getTypeArray()),r=t._speedCurveModeMacro,a&&(e.setFloatArray(t._speedMinCurveProperty,n.curveMin._getTypeArray()),i=t._speedIsRandomMacro)):(e.setFloat(t._speedMaxConstProperty,n.constantMax),r=t._speedConstantModeMacro,n.mode===lt.TwoConstants&&(e.setFloat(t._speedMinConstProperty,n.constantMin),i=t._speedIsRandomMacro)),{modeMacro:r,randomMacro:i}},n._uploadSeparateAxisSpeeds=function(e){var n=this._speedX,r=this._speedY,i=this._speedZ,a=null,o=null,s=n.mode===lt.TwoCurves&&r.mode===lt.TwoCurves&&i.mode===lt.TwoCurves;if(s||n.mode===lt.Curve&&r.mode===lt.Curve&&i.mode===lt.Curve)e.setFloatArray(t._speedXMaxCurveProperty,n.curveMax._getTypeArray()),e.setFloatArray(t._speedYMaxCurveProperty,r.curveMax._getTypeArray()),e.setFloatArray(t._speedZMaxCurveProperty,i.curveMax._getTypeArray()),a=t._speedCurveModeMacro,s&&(e.setFloatArray(t._speedXMinCurveProperty,n.curveMin._getTypeArray()),e.setFloatArray(t._speedYMinCurveProperty,r.curveMin._getTypeArray()),e.setFloatArray(t._speedZMinCurveProperty,i.curveMin._getTypeArray()),o=t._speedIsRandomMacro);else{var l=this._speedMaxConstantVec;if(l.set(n.constantMax,r.constantMax,i.constantMax),e.setVector3(t._speedMaxConstVecProperty,l),a=t._speedConstantModeMacro,n.mode===lt.TwoConstants&&r.mode===lt.TwoConstants&&i.mode===lt.TwoConstants){var c=this._speedMinConstantVec;c.set(n.constantMin,r.constantMin,i.constantMin),e.setVector3(t._speedMinConstVecProperty,c),o=t._speedIsRandomMacro}}return{modeMacro:a,randomMacro:o}},n._uploadDrag=function(e){var n=this._drag,r=null,i=null,a=n.mode===lt.TwoCurves;if(a||n.mode===lt.Curve)e.setFloatArray(t._dragMaxCurveProperty,n.curveMax._getTypeArray()),r=t._dragCurveModeMacro,a&&(e.setFloatArray(t._dragMinCurveProperty,n.curveMin._getTypeArray()),i=t._dragIsRandomMacro);else{var o=this._dragConstantVec;n.mode===lt.TwoConstants?o.set(n.constantMin,n.constantMax):o.set(n.constantMax,n.constantMax),e.setVector2(t._dragConstantProperty,o)}return{curveMacro:r,randomMacro:i}},t4(t,[{key:"separateAxes",get:function(){return this._separateAxes},set:function(e){e!==this._separateAxes&&(this._separateAxes=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"speed",get:function(){return this._speedX},set:function(e){this.speedX=e}},{key:"speedX",get:function(){return this._speedX},set:function(e){var t=this._speedX;e!==t&&(this._speedX=e,this._onCompositeCurveChange(t,e))}},{key:"speedY",get:function(){return this._speedY},set:function(e){var t=this._speedY;e!==t&&(this._speedY=e,this._onCompositeCurveChange(t,e))}},{key:"speedZ",get:function(){return this._speedZ},set:function(e){var t=this._speedZ;e!==t&&(this._speedZ=e,this._onCompositeCurveChange(t,e))}},{key:"dampen",get:function(){return this._dampen},set:function(e){(e=Math.max(0,Math.min(1,e)))!==this._dampen&&(this._dampen=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"drag",get:function(){return this._drag},set:function(e){var t=this._drag;e!==t&&(this._drag=e,this._onCompositeCurveChange(t,e))}},{key:"multiplyDragByParticleSize",get:function(){return this._multiplyDragByParticleSize},set:function(e){e!==this._multiplyDragByParticleSize&&(this._multiplyDragByParticleSize=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"multiplyDragByParticleVelocity",get:function(){return this._multiplyDragByParticleVelocity},set:function(e){e!==this._multiplyDragByParticleVelocity&&(this._multiplyDragByParticleVelocity=e,this._generator._renderer._onGeneratorParamsChanged())}},{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&&(!e||this._generator._renderer.engine._hardwareRenderer.isWebGL2)&&(this._enabled=e,this._generator._setTransformFeedback(e),this._generator._renderer._onGeneratorParamsChanged())}}]),t}(ll);l_._enabledMacro=rc.getByName("RENDERER_LVL_MODULE_ENABLED"),l_._separateAxesMacro=rc.getByName("RENDERER_LVL_SEPARATE_AXES"),l_._speedConstantModeMacro=rc.getByName("RENDERER_LVL_SPEED_CONSTANT_MODE"),l_._speedCurveModeMacro=rc.getByName("RENDERER_LVL_SPEED_CURVE_MODE"),l_._speedIsRandomMacro=rc.getByName("RENDERER_LVL_SPEED_IS_RANDOM_TWO"),l_._dragCurveModeMacro=rc.getByName("RENDERER_LVL_DRAG_CURVE_MODE"),l_._dragIsRandomMacro=rc.getByName("RENDERER_LVL_DRAG_IS_RANDOM_TWO"),l_._multiplyDragBySizeMacro=rc.getByName("RENDERER_LVL_DRAG_MULTIPLY_SIZE"),l_._multiplyDragByVelocityMacro=rc.getByName("RENDERER_LVL_DRAG_MULTIPLY_VELOCITY"),l_._speedMaxConstProperty=nH.getByName("renderer_LVLSpeedMaxConst"),l_._speedMinConstProperty=nH.getByName("renderer_LVLSpeedMinConst"),l_._speedMaxCurveProperty=nH.getByName("renderer_LVLSpeedMaxCurve"),l_._speedMinCurveProperty=nH.getByName("renderer_LVLSpeedMinCurve"),l_._speedMaxConstVecProperty=nH.getByName("renderer_LVLSpeedMaxConstVector"),l_._speedMinConstVecProperty=nH.getByName("renderer_LVLSpeedMinConstVector"),l_._speedXMaxCurveProperty=nH.getByName("renderer_LVLSpeedXMaxCurve"),l_._speedXMinCurveProperty=nH.getByName("renderer_LVLSpeedXMinCurve"),l_._speedYMaxCurveProperty=nH.getByName("renderer_LVLSpeedYMaxCurve"),l_._speedYMinCurveProperty=nH.getByName("renderer_LVLSpeedYMinCurve"),l_._speedZMaxCurveProperty=nH.getByName("renderer_LVLSpeedZMaxCurve"),l_._speedZMinCurveProperty=nH.getByName("renderer_LVLSpeedZMinCurve"),l_._dampenProperty=nH.getByName("renderer_LVLDampen"),l_._dragConstantProperty=nH.getByName("renderer_LVLDragConstant"),l_._dragMaxCurveProperty=nH.getByName("renderer_LVLDragMaxCurve"),l_._dragMinCurveProperty=nH.getByName("renderer_LVLDragMinCurve"),l_._spaceProperty=nH.getByName("renderer_LVLSpace"),t6([nt],l_.prototype,"_speedRand",void 0),t6([nt],l_.prototype,"_speedMinConstantVec",void 0),t6([nt],l_.prototype,"_speedMaxConstantVec",void 0),t6([nt],l_.prototype,"_dragConstantVec",void 0),t6([nt],l_.prototype,"_enabledModuleMacro",void 0),t6([nt],l_.prototype,"_separateAxesCachedMacro",void 0),t6([nt],l_.prototype,"_speedModeMacro",void 0),t6([nt],l_.prototype,"_speedRandomMacro",void 0),t6([nt],l_.prototype,"_dragCurveCachedMacro",void 0),t6([nt],l_.prototype,"_dragRandomCachedMacro",void 0),t6([nt],l_.prototype,"_dragSizeMacro",void 0),t6([nt],l_.prototype,"_dragVelocityMacro",void 0),t6([ni],l_.prototype,"_speedX",void 0),t6([ni],l_.prototype,"_speedY",void 0),t6([ni],l_.prototype,"_speedZ",void 0),t6([ni],l_.prototype,"_drag",void 0);var lf=((e3={})[e3.Hierarchy=0]="Hierarchy",e3[e3.Local=1]="Local",e3[e3.World=2]="World",e3),lp=/*#__PURE__*/function(){function e(e){this._tempVector40=new tZ,this.duration=5,this.isLoop=!0,this.startDelay=new lu(0),this.startRotation3D=!1,this.startRotationX=new lu(0),this.startRotationY=new lu(0),this.startRotationZ=new lu(0),this.flipRotation=0,this.startColor=new ls(new tJ(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=lf.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startDelayRand=new t1(0,lr.StartDelay),this._startSpeedRand=new t1(0,lr.StartSpeed),this._startLifeTimeRand=new t1(0,lr.StartLifetime),this._startColorRand=new t1(0,lr.StartColor),this._startSizeRand=new t1(0,lr.StartSize),this._startRotationRand=new t1(0,lr.StartRotation),this._gravityModifierRand=new t1(0,lr.GravityModifier),this._startSize3D=!1,this._simulationSpace=s3.Local,this._generator=e,this.startLifetime=new lu(5),this.startSpeed=new lu(5),this.startSizeX=new lu(1),this.startSizeY=new lu(1),this.startSizeZ=new lu(1),this.gravityModifier=new lu(0)}var t=e.prototype;return t._resetRandomSeed=function(e){this._startSpeedRand.reset(e,lr.StartSpeed),this._startLifeTimeRand.reset(e,lr.StartLifetime),this._startColorRand.reset(e,lr.StartColor),this._startSizeRand.reset(e,lr.StartSize),this._startRotationRand.reset(e,lr.StartRotation)},t._getPositionScale=function(){var e=this._generator._renderer.entity.transform;switch(this.scalingMode){case lf.Hierarchy:case lf.World:return e.lossyWorldScale;case lf.Local:return e.scale}},t._updateShaderData=function(t){var n=this._generator._renderer,r=n.entity.transform;switch(this.simulationSpace){case s3.Local:t.setVector3(e._worldPosition,r.worldPosition);var i=r.worldRotationQuaternion,a=this._tempVector40.copyFrom(i);t.setVector4(e._worldRotation,a);break;case s3.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case lf.Hierarchy:var o=r.lossyWorldScale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case lf.Local:var o=r.scale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case lf.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===s3.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()},t4(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(rH.WorldMatrix),e===s3.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}();lp._vector3One=new tU(1,1,1),lp._positionScale=nH.getByName("renderer_PositionScale"),lp._sizeScale=nH.getByName("renderer_SizeScale"),lp._worldPosition=nH.getByName("renderer_WorldPosition"),lp._worldRotation=nH.getByName("renderer_WorldRotation"),lp._gravity=nH.getByName("renderer_Gravity"),lp._simulationSpace=nH.getByName("renderer_SimulationSpace"),lp._startRotation3D=nH.getByName("renderer_ThreeDStartRotation"),lp._scaleMode=nH.getByName("renderer_ScalingMode"),t6([ni],lp.prototype,"startDelay",void 0),t6([ni],lp.prototype,"startRotationX",void 0),t6([ni],lp.prototype,"startRotationY",void 0),t6([ni],lp.prototype,"startRotationZ",void 0),t6([ni],lp.prototype,"startColor",void 0),t6([nt],lp.prototype,"_maxParticleBuffer",void 0),t6([nt],lp.prototype,"_startDelayRand",void 0),t6([nt],lp.prototype,"_startSpeedRand",void 0),t6([nt],lp.prototype,"_startLifeTimeRand",void 0),t6([nt],lp.prototype,"_startColorRand",void 0),t6([nt],lp.prototype,"_startSizeRand",void 0),t6([nt],lp.prototype,"_startRotationRand",void 0),t6([nt],lp.prototype,"_gravityModifierRand",void 0),t6([ni],lp.prototype,"_startLifetime",void 0),t6([ni],lp.prototype,"_startSpeed",void 0),t6([ni],lp.prototype,"_startSizeX",void 0),t6([ni],lp.prototype,"_startSizeY",void 0),t6([ni],lp.prototype,"_startSizeZ",void 0),t6([ni],lp.prototype,"_gravityModifier",void 0),t6([nt],lp.prototype,"_generator",void 0);var lm=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new lu(0),t.rotationY=new lu(0),t.rotationZ=new lu(45),t._rotationRand=new t1(0,lr.RotationOverLifetime),t._rotationMinConstant=new tU,t._rotationMaxConstant=new tU,t}t5(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===lt.TwoCurves&&o.mode===lt.TwoCurves&&s.mode===lt.TwoCurves:s.mode===lt.TwoCurves;if(c||l?a.mode===lt.Curve&&o.mode===lt.Curve&&s.mode===lt.Curve:s.mode===lt.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(a.constantMax,o.constantMax,s.constantMax),e.setVector3(t._maxConstantProperty,u),l?a.mode===lt.TwoConstants&&o.mode===lt.TwoConstants&&s.mode===lt.TwoConstants:s.mode===lt.TwoConstants){var d=this._rotationMinConstant;d.set(a.constantMin,o.constantMin,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._modeMacro=this._enableMacro(e,this._modeMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,i)},n._resetRandomSeed=function(e){this._rotationRand.reset(e,lr.RotationOverLifetime)},t}(ll);lm._constantModeMacro=rc.getByName("RENDERER_ROL_CONSTANT_MODE"),lm._curveModeMacro=rc.getByName("RENDERER_ROL_CURVE_MODE"),lm._isSeparateMacro=rc.getByName("RENDERER_ROL_IS_SEPARATE"),lm._isRandomTwoMacro=rc.getByName("RENDERER_ROL_IS_RANDOM_TWO"),lm._minConstantProperty=nH.getByName("renderer_ROLMinConst"),lm._minCurveXProperty=nH.getByName("renderer_ROLMinCurveX"),lm._minCurveYProperty=nH.getByName("renderer_ROLMinCurveY"),lm._minCurveZProperty=nH.getByName("renderer_ROLMinCurveZ"),lm._maxConstantProperty=nH.getByName("renderer_ROLMaxConst"),lm._maxCurveXProperty=nH.getByName("renderer_ROLMaxCurveX"),lm._maxCurveYProperty=nH.getByName("renderer_ROLMaxCurveY"),lm._maxCurveZProperty=nH.getByName("renderer_ROLMaxCurveZ"),t6([ni],lm.prototype,"rotationX",void 0),t6([ni],lm.prototype,"rotationY",void 0),t6([ni],lm.prototype,"rotationZ",void 0),t6([nt],lm.prototype,"_rotationRand",void 0),t6([nt],lm.prototype,"_rotationMinConstant",void 0),t6([nt],lm.prototype,"_rotationMaxConstant",void 0),t6([nt],lm.prototype,"_enableSeparateMacro",void 0),t6([nt],lm.prototype,"_modeMacro",void 0),t6([nt],lm.prototype,"_isRandomTwoMacro",void 0);var lg=/*#__PURE__*/function(){function e(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._updateManager=new n4,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 lv(e,t):e;this._addKey(n,r),r._registerOnValueChanged(this._updateDispatch),this._updateDispatch(),this._typeArrayDirty=!0},t.removeKey=function(e){var t=this._keys,n=t[e];t.splice(e,1),this._typeArrayDirty=!0,n._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._evaluate=function(e){for(var t=this.keys,n=t.length,r=0;r<n;r++){var i=t[r],a=i.time;if(e<=a){if(0===r)return i.value;var o=t[r-1],s=o.time,l=o.value,c=(e-s)/(a-s);return l+(i.value-l)*c}}return t[n-1].value},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)}},t4(e,[{key:"keys",get:function(){return this._keys}}]),e}();t6([nt],lg.prototype,"_updateManager",void 0),t6([ni],lg.prototype,"_keys",void 0),t6([nt],lg.prototype,"_typeArray",void 0),t6([nt],lg.prototype,"_updateDispatch",void 0);var lv=/*#__PURE__*/function(){function e(e,t){this._updateManager=new n4,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)},t4(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}();t6([nt],lv.prototype,"_updateManager",void 0);var ly=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._separateAxes=!1,n.sizeX=new lu(new lg(new lv(0,0),new lv(1,1))),n.sizeY=new lu(new lg(new lv(0,0),new lv(1,1))),n.sizeZ=new lu(new lg(new lv(0,0),new lv(1,1))),n}return t5(t,e),t.prototype._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===lt.TwoCurves&&o.mode===lt.TwoCurves&&s.mode===lt.TwoCurves:a.mode===lt.TwoCurves;(c||l?a.mode===lt.Curve&&o.mode===lt.Curve&&s.mode===lt.Curve:a.mode===lt.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)},t4(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}(ll);ly._curveModeMacro=rc.getByName("RENDERER_SOL_CURVE_MODE"),ly._isSeparateMacro=rc.getByName("RENDERER_SOL_IS_SEPARATE"),ly._isRandomTwoMacro=rc.getByName("RENDERER_SOL_IS_RANDOM_TWO"),ly._minCurveXProperty=nH.getByName("renderer_SOLMinCurveX"),ly._minCurveYProperty=nH.getByName("renderer_SOLMinCurveY"),ly._minCurveZProperty=nH.getByName("renderer_SOLMinCurveZ"),ly._maxCurveXProperty=nH.getByName("renderer_SOLMaxCurveX"),ly._maxCurveYProperty=nH.getByName("renderer_SOLMaxCurveY"),ly._maxCurveZProperty=nH.getByName("renderer_SOLMaxCurveZ"),t6([ni],ly.prototype,"_sizeX",void 0),t6([ni],ly.prototype,"_sizeY",void 0),t6([ni],ly.prototype,"_sizeZ",void 0),t6([nt],ly.prototype,"_enableSeparateMacro",void 0),t6([nt],ly.prototype,"_isCurveMacro",void 0),t6([nt],ly.prototype,"_isRandomTwoMacro",void 0);var lx=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).frameOverTime=new lu(new lg(new lv(0,0),new lv(1,1))),n.type=0,n.cycleCount=1,n._tillingInfo=new tU(1,1,1),n._frameOverTimeRand=new t1(0,lr.TextureSheetAnimation),n._tiling=new tq(1,1),n._tiling._onValueChanged=n._onTilingChanged.bind(n),n}t5(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.frameOverTime.mode;if(r===lt.Curve||r===lt.TwoCurves){var i=this.frameOverTime;e.setFloatArray(t._frameMaxCurveProperty,i.curveMax._getTypeArray()),r===lt.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,lr.TextureSheetAnimation)},n._onTilingChanged=function(){var e=this.tiling;this._tillingInfo.set(1/e.x,1/e.y,e.x*e.y)},t4(t,[{key:"tiling",get:function(){return this._tiling},set:function(e){e!==this._tiling&&this._tiling.copyFrom(e)}}]),t}(ll);lx._frameCurveMacro=rc.getByName("RENDERER_TSA_FRAME_CURVE"),lx._frameRandomCurvesMacro=rc.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),lx._frameMinCurveProperty=nH.getByName("renderer_TSAFrameMinCurve"),lx._frameMaxCurveProperty=nH.getByName("renderer_TSAFrameMaxCurve"),lx._cycleCountProperty=nH.getByName("renderer_TSACycles"),lx._tillingParamsProperty=nH.getByName("renderer_TSATillingParams"),t6([ni],lx.prototype,"frameOverTime",void 0),t6([nr],lx.prototype,"_tillingInfo",void 0),t6([nt],lx.prototype,"_frameOverTimeRand",void 0),t6([ni],lx.prototype,"_tiling",void 0),t6([nt],lx.prototype,"_frameCurveMacro",void 0),t6([nt],lx.prototype,"_onTilingChanged",null);var lA=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._velocityRand=new t1(0,lr.VelocityOverLifetime),n._velocityMinConstant=new tU,n._velocityMaxConstant=new tU,n._space=s3.Local,n.velocityX=new lu(0),n.velocityY=new lu(0),n.velocityZ=new lu(0),n}t5(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null;if(this.enabled){var i=this.velocityX,a=this.velocityY,o=this.velocityZ,s=i.mode===lt.TwoCurves&&a.mode===lt.TwoCurves&&o.mode===lt.TwoCurves;if(s||i.mode===lt.Curve&&a.mode===lt.Curve&&o.mode===lt.Curve)e.setFloatArray(t._maxGradientXProperty,i.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientYProperty,a.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientZProperty,o.curveMax._getTypeArray()),n=t._curveModeMacro,s&&(e.setFloatArray(t._minGradientXProperty,i.curveMin._getTypeArray()),e.setFloatArray(t._minGradientYProperty,a.curveMin._getTypeArray()),e.setFloatArray(t._minGradientZProperty,o.curveMin._getTypeArray()),r=t._isRandomMacro);else{var l=this._velocityMaxConstant;if(l.set(i.constantMax,a.constantMax,o.constantMax),e.setVector3(t._maxConstantProperty,l),n=t._constantModeMacro,i.mode===lt.TwoConstants&&a.mode===lt.TwoConstants&&o.mode===lt.TwoConstants){var c=this._velocityMinConstant;c.set(i.constantMin,a.constantMin,o.constantMin),e.setVector3(t._minConstantProperty,c),r=t._isRandomMacro}}e.setInt(t._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(e,this._velocityMacro,n),this._randomModeMacro=this._enableMacro(e,this._randomModeMacro,r)},n._resetRandomSeed=function(e){this._velocityRand.reset(e,lr.VelocityOverLifetime)},t4(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}(ll);lA._constantModeMacro=rc.getByName("RENDERER_VOL_CONSTANT_MODE"),lA._curveModeMacro=rc.getByName("RENDERER_VOL_CURVE_MODE"),lA._isRandomMacro=rc.getByName("RENDERER_VOL_IS_RANDOM_TWO"),lA._minConstantProperty=nH.getByName("renderer_VOLMinConst"),lA._maxConstantProperty=nH.getByName("renderer_VOLMaxConst"),lA._minGradientXProperty=nH.getByName("renderer_VOLMinGradientX"),lA._minGradientYProperty=nH.getByName("renderer_VOLMinGradientY"),lA._minGradientZProperty=nH.getByName("renderer_VOLMinGradientZ"),lA._maxGradientXProperty=nH.getByName("renderer_VOLMaxGradientX"),lA._maxGradientYProperty=nH.getByName("renderer_VOLMaxGradientY"),lA._maxGradientZProperty=nH.getByName("renderer_VOLMaxGradientZ"),lA._spaceProperty=nH.getByName("renderer_VOLSpace"),t6([nt],lA.prototype,"_velocityRand",void 0),t6([nt],lA.prototype,"_velocityMinConstant",void 0),t6([nt],lA.prototype,"_velocityMaxConstant",void 0),t6([nt],lA.prototype,"_velocityMacro",void 0),t6([nt],lA.prototype,"_randomModeMacro",void 0),t6([ni],lA.prototype,"_velocityX",void 0),t6([ni],lA.prototype,"_velocityY",void 0),t6([ni],lA.prototype,"_velocityZ",void 0);var lb=/*#__PURE__*/function(){function e(t){this.useAutoRandomSeed=!0,this.emission=new ld(this),this.rotationOverLifetime=new lm(this),this.colorOverLifetime=new lc(this),this.textureSheetAnimation=new lx(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new aD(0,0,aR.Triangles),this._useTransformFeedback=!1,this._feedbackBindingIndex=-1,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 aL().start=0,this._primitive=new aB(t.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,e._particleIncreaseCount),this.main=new lp(this),this.velocityOverLifetime=new lA(this),this.forceOverLifetime=new lh(this),this.sizeOverLifetime=new ly(this),this.limitVelocityOverLifetime=new l_(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(s8,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=s4.StopEmitting),t)for(var r=this._renderer.entity.getComponentsIncludeChildren(s8,e._tempParticleRenderers),i=0,a=r.length;i<a;i++)r[i].generator.stop(!1,n);else this._isPlaying=!1,n===s4.StopEmittingAndClear&&(this._clearActiveParticles(),this._playTime=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox,this.emission._reset())},t.emit=function(e){this._emit(this._playTime,e)},t._emit=function(t,n){var r=this.emission;if(r.enabled){var i=this.main;if(this._getNotRetiredParticleCount()>=i.maxParticles)return;for(var a=e._tempVector30,o=e._tempVector31,s=this._renderer.entity.transform,l=r.shape,c=i._getPositionScale(),u=0;u<n;u++)(null==l?void 0:l.enabled)?(l._generatePositionAndDirection(r._shapeRand,t,a,o),a.multiply(c),o.normalize().multiply(c)):(a.set(0,0,0),o.set(0,0,-1),i.simulationSpace===s3.Local&&o.multiply(c)),this._addNewParticle(a,o,s,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===s3.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._instanceVertexBufferBinding._buffer.isContentLost&&(this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._waitProcessRetiredElementCount=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox),this.isAlive)n.simulationSpace===s3.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._addActiveParticlesToVertexBuffer()},t._updateFeedback=function(e,t){this._feedbackSimulator.update(e,this._currentParticleCount,this._firstActiveElement,this._firstFreeElement,t),this._primitive.vertexBufferBindings[this._feedbackBindingIndex]=this._feedbackSimulator.readBinding},t._reorganizeGeometryBuffers=function(){var e=this._renderer,t=this._primitive,n=this._vertexBufferBindings,r=e.engine._particleBufferUtils;if(t.clearVertexElements(),n.length=0,e.renderMode===s2.Mesh){var i=e.mesh,a=i.getVertexElement(az.Position),o=i.getVertexElement(az.Color),s=i.getVertexElement(az.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,n);t.addVertexElement(new aC(az.Position,a.offset,a.format,d))}if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,n);t.addVertexElement(new aC(az.Color,o.offset,o.format,h)),e.shaderData.enableMacro(ak._enableVertexColorMacro)}else e.shaderData.disableMacro(ak._enableVertexColorMacro);if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,n);t.addVertexElement(new aC(az.UV,s.offset,s.format,_))}t.setIndexBufferBinding(i._primitive.indexBufferBinding);var f=i.subMesh,p=this._subPrimitive;p.start=f.start,p.topology=f.topology,p.count=f.count}else e.shaderData.disableMacro(ak._enableVertexColorMacro),t.addVertexElement(r.billboardVertexElement),n.push(r.billboardVertexBufferBinding),t.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=oU.billboardIndexCount;for(var m=r.instanceVertexElements,g=n.length,v=0,y=m.length;v<y;v++){var x=m[v];t.addVertexElement(new aC(x.attribute,x.offset,x.format,g,x.instanceStepRate))}this._instanceVertexBufferBinding&&n.push(this._instanceVertexBufferBinding),this._useTransformFeedback?(this._feedbackBindingIndex=n.length,t.addVertexElement(new aC(oV.Position,0,ab.Vector3,this._feedbackBindingIndex,1)),t.addVertexElement(new aC(oV.Velocity,12,ab.Vector3,this._feedbackBindingIndex,1)),n.push(this._feedbackSimulator.readBinding)):this._feedbackBindingIndex=-1,t.setVertexBufferBindings(n)},t._resizeInstanceBuffer=function(e,t){null==(d=this._instanceVertexBufferBinding)||d.buffer.destroy();var n=oU.instanceVertexStride,r=e?this._currentParticleCount+t:this.main._maxParticleBuffer,i=n*r,a=new ax(this._renderer.engine,aT.VertexBuffer,i,av.Dynamic,!1);a.isGCIgnored=!0;var o=this._primitive.vertexBufferBindings,s=new aO(a,n),l=this._instanceVertices,c=this._useTransformFeedback,u=new Float32Array(i/4);if(c&&this._feedbackSimulator.resize(r,s),l){var d,h,_,f=oU.instanceVertexFloatStride,p=oU.feedbackVertexStride,m=this._firstFreeElement,g=this._firstRetiredElement;if(e){u.set(new Float32Array(l.buffer,0,m*f));var v=m+1,y=this._currentParticleCount-v,x=v+t;u.set(new Float32Array(l.buffer,v*f*4),x*f),c&&(this._feedbackSimulator.copyOldBufferData(0,0,m*p),this._feedbackSimulator.copyOldBufferData(v*p,x*p,y*p)),this._firstNewElement>m&&(this._firstNewElement+=t),this._firstActiveElement>m&&(this._firstActiveElement+=t),g>m&&(this._firstRetiredElement+=t)}else g<=m?(h=m-g,_=0,this._firstFreeElement-=g,this._firstNewElement-=g,this._firstActiveElement-=g,this._firstRetiredElement=0):(h=this._currentParticleCount-g,_=m,this._firstNewElement>m&&(this._firstNewElement-=m),this._firstActiveElement>m&&(this._firstActiveElement-=m),g>m&&(this._firstRetiredElement-=m)),u.set(new Float32Array(l.buffer,g*f*4,h*f),_*f),c&&this._feedbackSimulator.copyOldBufferData(g*p,_*p,h*p);c&&this._feedbackSimulator.destroyOldBuffers(),this._instanceBufferResized=!0}var A=l?o.length-1-(c?1:0):o.length;this._primitive.setVertexBufferBinding(A,s),this._instanceVertices=u,this._instanceVertexBufferBinding=s,this._currentParticleCount=r,c&&this._primitive.setVertexBufferBinding(this._feedbackBindingIndex,this._feedbackSimulator.readBinding)},t._updateShaderData=function(e){this.main._updateShaderData(e),this.velocityOverLifetime._updateShaderData(e),this.forceOverLifetime._updateShaderData(e),this.limitVelocityOverLifetime._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.forceOverLifetime._resetRandomSeed(e),this.limitVelocityOverLifetime._resetRandomSeed(e),this.rotationOverLifetime._resetRandomSeed(e),this.colorOverLifetime._resetRandomSeed(e)},t._setTransformFeedback=function(t){if(this._useTransformFeedback=t,this._clearActiveParticles(),t){this._feedbackSimulator||(this._feedbackSimulator=new le(this._renderer.engine));var n=this._feedbackSimulator,r=n.readBinding;r&&r.buffer.byteLength===this._currentParticleCount*oU.feedbackVertexStride?n._instanceBinding=this._instanceVertexBufferBinding:(n.resize(this._currentParticleCount,this._instanceVertexBufferBinding),n.destroyOldBuffers()),this._renderer.shaderData.enableMacro(e._transformFeedbackMacro),this._primitive.enableVAO=!1}else this._renderer.shaderData.disableMacro(e._transformFeedbackMacro),this._primitive.enableVAO=!0;this._reorganizeGeometryBuffers()},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._cloneTo=function(e){e.limitVelocityOverLifetime.enabled&&e._setTransformFeedback(!0)},t._destroy=function(){var e;this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy(),this.emission._destroy(),null==(e=this._feedbackSimulator)||e.destroy()},t._updateBoundsSimulationLocal=function(e){var t=this._renderer,n=this.main.startLifetime._getMax(),r=t._generatorBounds,i=t._transformedBounds;t._isContainDirtyFlag(s5.GeneratorVolume)&&(this._calculateGeneratorBounds(n,r),t._setDirtyFlagFalse(s5.GeneratorVolume)),t._isContainDirtyFlag(s5.TransformVolume)&&(this._calculateTransformedBounds(n,r,i),t._setDirtyFlagFalse(s5.TransformVolume)),this._addGravityToBounds(n,i,e)},t._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,n=this._firstActiveTransformedBoundingBox,r=this._firstFreeTransformedBoundingBox,i=n*oU.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(s5.GeneratorVolume)&&(this._calculateGeneratorBounds(t,n),e._setDirtyFlagFalse(s5.GeneratorVolume));var r=oU.boundsFloatStride,i=oU.boundsTimeOffset,a=oU.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(s5.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(s5.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*oU.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===s3.World&&(a=r.worldPosition,o=r.worldRotationQuaternion);var d=c.startSpeed.evaluate(void 0,c._startSpeedRand.random()),h=this._instanceVertices,_=s*oU.instanceVertexFloatStride;t.copyToArray(h,_),h[_+oU.startLifeTimeOffset]=c.startLifetime.evaluate(void 0,c._startLifeTimeRand.random()),n.copyToArray(h,_+4),h[_+oU.timeOffset]=i;var f=e._tempColor0;c.startColor.evaluate(void 0,c._startColorRand.random(),f),f.copyToArray(h,_+8);var p=this.main.duration,m=i%p/p,g=c._startSizeRand;if(c.startSize3D)h[_+12]=c.startSizeX.evaluate(m,g.random()),h[_+13]=c.startSizeY.evaluate(m,g.random()),h[_+14]=c.startSizeZ.evaluate(m,g.random());else{var v=c.startSize.evaluate(m,g.random());h[_+12]=v,h[_+13]=v,h[_+14]=v}var y=c._startRotationRand,x=c.flipRotation>y.random();this._renderer.renderMode!==s2.Mesh&&(x=!x);var A=c.startRotationZ.evaluate(void 0,y.random());if(c.startRotation3D){var b=c.startRotationX.evaluate(void 0,y.random()),S=c.startRotationY.evaluate(void 0,y.random());h[_+15]=x?-b:b,h[_+16]=x?-S:S,h[_+17]=x?-A:A}else h[_+15]=x?-A:A;switch(h[_+18]=d,c.gravityModifier.mode){case lt.Constant:h[_+19]=c.gravityModifier.constant;break;case lt.TwoConstants:h[_+19]=c.gravityModifier.evaluate(void 0,c._gravityModifierRand.random())}var C=this.colorOverLifetime;C.enabled&&C.color.mode===ln.TwoGradients&&(h[_+20]=C._colorGradientRand.random());var T=this.rotationOverLifetime;T.enabled&&T.rotationZ.mode===lt.TwoConstants&&(h[_+22]=T._rotationRand.random());var R=this.textureSheetAnimation;R.enabled&&R.frameOverTime.mode===lt.TwoCurves&&(h[_+23]=R._frameOverTimeRand.random());var E=this.velocityOverLifetime;if(E.enabled&&E.velocityX.mode===lt.TwoConstants&&E.velocityY.mode===lt.TwoConstants&&E.velocityZ.mode===lt.TwoConstants){var M=E._velocityRand;h[_+24]=M.random(),h[_+25]=M.random(),h[_+26]=M.random()}if(this.main.simulationSpace===s3.World&&(a.copyToArray(h,_+27),o.copyToArray(h,_+30)),R.enabled){var P=R.frameOverTime,w=R._tillingInfo,F=w.x,L=w.y,D=w.z,B=0;(P.mode===lt.Constant||P.mode===lt.TwoConstants)&&(B=Math.floor(P.evaluate(void 0,R._frameOverTimeRand.random())*D)*F);var I=Math.floor(B);h[_+oU.simulationUVOffset]=F,h[_+35]=L,h[_+36]=B-I,h[_+37]=I*L}else h[_+oU.simulationUVOffset]=1,h[_+35]=1,h[_+36]=0,h[_+37]=0;var N=this.forceOverLifetime;if(N.enabled&&N._isRandomMode()){var O=N._forceRand;h[_+38]=O.random(),h[_+39]=O.random(),h[_+40]=O.random()}var V=this.limitVelocityOverLifetime;V.enabled&&(V._isSpeedRandomMode()||V._isDragRandomMode())&&(h[_+41]=V._speedRand.random()),this._useTransformFeedback&&this._addFeedbackParticle(s,t,n,d,r),this._firstFreeElement=l},t._addFeedbackParticle=function(t,n,r,i,a){var o;this.main.simulationSpace===s3.Local?o=n:(o=e._tempVector32,tU.transformByQuat(n,a.worldRotationQuaternion,o),o.add(a.worldPosition)),this._feedbackSimulator.writeParticleData(t,o,r.x*i,r.y*i,r.z*i)},t._clearActiveParticles=function(){var e=this._firstFreeElement;this._firstRetiredElement=e,this._firstActiveElement=e,this._firstNewElement=e,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox},t._retireActiveParticles=function(){for(var e=this._renderer.engine.time.frameCount,t=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var n=this._firstActiveElement*oU.instanceVertexFloatStride,r=n+oU.timeOffset;if(Math.fround(this._playTime-t[r])<t[n+oU.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*oU.instanceVertexFloatStride+oU.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=oU.instanceVertexStride,r=this._instanceVertexBufferBinding.buffer,i=this._instanceVertices.buffer,a=!this._useTransformFeedback,o=e*n;if(e<t)r.setData(i,a?0:o,o,(t-e)*n,ay.Discard);else{var s=(this._currentParticleCount-e)*n;r.setData(i,a?0:o,o,s,ay.Discard),t>0&&r.setData(i,a?s:0,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=oU.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=oU.boundsFloatStride,t=oU.boundsTimeOffset,n=oU.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===s2.Billboard||s2.StretchBillboard||s2.HorizontalBillboard?Math.max(v,y):Math.max(v,y,l.startSizeZ._getMax())}v*=1.414;var x=this.sizeOverLifetime;if(x.enabled){var A=x.size._getMax();x.separateAxes&&(A=Math.max(A,x.sizeY._getMax(),x.sizeZ._getMax())),v*=A}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*oU.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._tempVector30,l=e._tempVector31,c=e._tempMat;s.set(0,0,0),l.set(0,0,0);var u=this._renderer.entity.transform,d=u.worldPosition;tK.rotationQuaternion(u.worldRotationQuaternion,c);var h=r.min,_=r.max;h.copyFrom(n.min),_.copyFrom(n.max);var f=this.velocityOverLifetime;f.enabled&&(this._getExtremeValueFromZero(f.velocityX,i),this._getExtremeValueFromZero(f.velocityY,a),this._getExtremeValueFromZero(f.velocityZ,o),i.scale(t),a.scale(t),o.scale(t),f.space===s3.Local?(h.set(h.x+i.x,h.y+a.x,h.z+o.x),_.set(_.x+i.y,_.y+a.y,_.z+o.y)):(s.set(s.x+i.x,s.y+a.x,s.z+o.x),l.set(l.x+i.y,l.y+a.y,l.z+o.y)));var p=this.forceOverLifetime;if(p.enabled){var m=e._tempVector20,g=e._tempVector21,v=e._tempVector22;this._getExtremeValueFromZero(p.forceX,m),this._getExtremeValueFromZero(p.forceY,g),this._getExtremeValueFromZero(p.forceZ,v);var y=.5*t*t;m.scale(y),g.scale(y),v.scale(y),p.space===s3.Local?(h.set(h.x+m.x,h.y+g.x,h.z+v.x),_.set(_.x+m.y,_.y+g.y,_.z+v.y)):(s.set(s.x+m.x,s.y+g.x,s.z+v.x),l.set(l.x+m.y,l.y+g.y,l.z+v.y))}r.transform(c),h.add(s),_.add(l),h.add(d),_.add(d)},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)},t4(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}();lb._tempVector20=new tq,lb._tempVector21=new tq,lb._tempVector22=new tq,lb._tempVector30=new tU,lb._tempVector31=new tU,lb._tempVector32=new tU,lb._tempMat=new tK,lb._tempColor0=new tJ,lb._tempParticleRenderers=[],lb._particleIncreaseCount=128,lb._transformedBoundsIncreaseCount=16,lb._transformFeedbackMacro=rc.getByName("RENDERER_TRANSFORM_FEEDBACK"),t6([ni],lb.prototype,"main",void 0),t6([ni],lb.prototype,"emission",void 0),t6([ni],lb.prototype,"velocityOverLifetime",void 0),t6([ni],lb.prototype,"forceOverLifetime",void 0),t6([ni],lb.prototype,"limitVelocityOverLifetime",void 0),t6([ni],lb.prototype,"sizeOverLifetime",void 0),t6([ni],lb.prototype,"rotationOverLifetime",void 0),t6([ni],lb.prototype,"colorOverLifetime",void 0),t6([ni],lb.prototype,"textureSheetAnimation",void 0),t6([nt],lb.prototype,"_playTime",void 0),t6([nt],lb.prototype,"_firstNewElement",void 0),t6([nt],lb.prototype,"_firstActiveElement",void 0),t6([nt],lb.prototype,"_firstFreeElement",void 0),t6([nt],lb.prototype,"_firstRetiredElement",void 0),t6([nt],lb.prototype,"_primitive",void 0),t6([nt],lb.prototype,"_vertexBufferBindings",void 0),t6([nt],lb.prototype,"_subPrimitive",void 0),t6([nt],lb.prototype,"_feedbackSimulator",void 0),t6([nt],lb.prototype,"_useTransformFeedback",void 0),t6([nt],lb.prototype,"_feedbackBindingIndex",void 0),t6([nt],lb.prototype,"_isPlaying",void 0),t6([nt],lb.prototype,"_instanceBufferResized",void 0),t6([nt],lb.prototype,"_waitProcessRetiredElementCount",void 0),t6([nt],lb.prototype,"_instanceVertexBufferBinding",void 0),t6([nt],lb.prototype,"_instanceVertices",void 0),t6([nt],lb.prototype,"_transformedBoundsArray",void 0),t6([nt],lb.prototype,"_transformedBoundsCount",void 0),t6([nt],lb.prototype,"_firstActiveTransformedBoundingBox",void 0),t6([nt],lb.prototype,"_firstFreeTransformedBoundingBox",void 0),t6([nt],lb.prototype,"_playStartDelay",void 0);var lS=/*#__PURE__*/function(e){function t(t,n){var r,i=(r=e.call(this,t,n)||this).shaderData;return i.setColor(r4._baseColorProp,new tJ(1,1,1,1)),i.setColor(r4._emissiveColorProp,new tJ(0,0,0,1)),r.isTransparent=!0,r}return t5(t,e),t4(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(r4._baseColorProp)},set:function(e){var t=this.shaderData.getColor(r4._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(r4._baseTextureProp)},set:function(e){this.shaderData.setTexture(r4._baseTextureProp,e),e?this.shaderData.enableMacro(r4._baseTextureMacro):this.shaderData.disableMacro(r4._baseTextureMacro)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(r4._emissiveColorProp)},set:function(e){var t=this.shaderData.getColor(r4._emissiveColorProp);e!==t&&t.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(r4._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(r4._emissiveTextureProp,e),e?this.shaderData.enableMacro(r4._emissiveTextureMacro):this.shaderData.disableMacro(r4._emissiveTextureMacro)}}]),t}(r4),lC=/*#__PURE__*/function(e){function t(t){return e.call(this,t,rM.find("particle-shader"))||this}return t5(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t}(lS),lT=function(e,t){this.time=e,this.count=t};t6([ni],lT.prototype,"count",void 0);var lR=/*#__PURE__*/function(){function e(){this._updateManager=new n4,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)},t4(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}();t6([nt],lR.prototype,"_updateManager",void 0);var lE=/*#__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}(),lM=((e4={})[e4.Box=0]="Box",e4[e4.Circle=1]="Circle",e4[e4.Cone=2]="Cone",e4[e4.Hemisphere=3]="Hemisphere",e4[e4.Sphere=4]="Sphere",e4[e4.Mesh=5]="Mesh",e4),lP=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).shapeType=lM.Box,t._size=new tU(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t}t5(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){lE._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=t._tempVector30;a.set(0,0,-1),lE._randomPointUnitSphere(i,e),tU.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)},t4(t,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),t}(lR);lP._tempVector30=new tU,t6([ni],lP.prototype,"_size",void 0);var lw=((e8={})[e8.Random=0]="Random",e8[e8.Loop=1]="Loop",e8),lF=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lM.Circle,t._radius=1,t._arc=360,t._arcMode=lw.Random,t._arcSpeed=1,t}t5(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){var a=t._tempPositionPoint;switch(this.arcMode){case lw.Loop:var o=n*this.arcSpeed*(360/this.arc)%1,s=tk.degreeToRadian(this.arc*o);a.set(Math.cos(s),Math.sin(s)),a.scale(e.random());break;case lw.Random:lE.randomPointInsideUnitArcCircle(tk.degreeToRadian(this.arc),a,e)}r.set(a.x,a.y,0),r.scale(this.radius),lE._randomPointUnitSphere(i,e),tU.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=tk.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))},t4(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}(lR);lF._tempPositionPoint=new tq;var lL=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lM.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t}t5(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){var a=t._tempVector20,o=tk.degreeToRadian(this.angle),s=Math.sin(o),l=Math.cos(o);switch(this.emitType){case 0:lE.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var c=t._tempVector21;lE.randomPointInsideUnitCircle(c,e),tq.lerp(a,c,this.randomDirectionAmount,c),i.set(c.x*s,c.y*s,-l);break;case 1:lE.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;tU.scale(i,this.length*e.random(),u),r.add(u);var d=t._tempVector31;lE._randomPointUnitSphere(d,e),tU.lerp(i,d,this.randomDirectionAmount,i)}},n._getDirectionRange=function(e,t){var n=0;switch(this.emitType){case 0:n=tk.degreeToRadian(this._angle);break;case 1:n=Math.sin(tk.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(tk.degreeToRadian(this._angle));e.set(-n-i*r,-n-i*r,-r),t.set(n+i*r,n+i*r,0)}},t4(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}(lR);lL._tempVector20=new tq,lL._tempVector21=new tq,lL._tempVector30=new tU,lL._tempVector31=new tU;var lD=((e5={})[e5.Base=0]="Base",e5[e5.Volume=1]="Volume",e5),lB=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lM.Hemisphere,t._radius=1,t}t5(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){lE._randomPointInsideUnitSphere(n,e),n.scale(this.radius);var i=n.z;i>0&&(n.z=-i),lE._randomPointUnitSphere(r,e),tU.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)},t4(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(lR),lI=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lM.Mesh,t._positionElementInfo=new tZ,t._normalElementInfo=new tZ,t}t5(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){var i=this._positionBuffer,a=this._positionElementInfo,o=this._normalBuffer,s=this._normalElementInfo,l=Math.floor(e.random()*this._mesh.vertexCount),c=l*a.y+a.x,u=l*s.y+s.x;n.set(i[c],i[c+1],i[c+2]),a.z&&n.scale(a.w),r.set(o[u],o[u+1],o[u+2]),s.z&&r.scale(s.w)},n._getPositionRange=function(e,t){var n=this._mesh.bounds;n.min.copyTo(e),n.max.copyTo(t)},n._getDirectionRange=function(e,t){var n=this._mesh.bounds;n.min.copyTo(e),n.max.copyTo(t)},n._getAttributeBuffer=function(e,t,n,r){var i,a=e.vertexBufferBindings[t.bindingIndex],o=t._formatMetaInfo;if(n)i=this._positionBuffer;else{var s=null==a?void 0:a.buffer;if(!s)throw""+t.attribute+" buffer not found.";if(s.readable)i=e._getVertexTypedArray(s.data.buffer,o.type);else{var l=new Uint8Array(s.byteLength);i=e._getVertexTypedArray(l.buffer,o.type),s.getData(i)}}return r.set(t.offset/i.BYTES_PER_ELEMENT,a.stride/i.BYTES_PER_ELEMENT,o.normalized?1:0,o.normalizedScaleFactor),i},n._onMeshChanged=function(e){if(e&aN.VertexElements){var t=this._mesh;if(t){var n=t.getVertexElement(az.Position),r=t.getVertexElement(az.Normal);if(!n||!r)throw"Mesh must have both "+az.Position+" and "+az.Normal+" attribute.";this._positionBuffer=this._getAttributeBuffer(t,n,!1,this._positionElementInfo);var i=n.bindingIndex===r.bindingIndex;this._normalBuffer=this._getAttributeBuffer(t,r,i,this._normalElementInfo)}else this._positionElementInfo.set(-1,-1,-1,-1),this._positionBuffer=null,this._normalElementInfo.set(-1,-1,-1,-1),this._normalBuffer=null}},n._cloneTo=function(e){e.mesh=this._mesh},t4(t,[{key:"mesh",get:function(){return this._mesh},set:function(e){var t=this._mesh;t!==e&&(this._mesh=e,t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(e._addReferCount(1),e._updateFlagManager.addListener(this._onMeshChanged)),this._onMeshChanged(aN.VertexElements),this._updateManager.dispatch())}}]),t}(lR);t6([nt],lI.prototype,"_mesh",void 0),t6([nt],lI.prototype,"_positionBuffer",void 0),t6([nt],lI.prototype,"_normalBuffer",void 0),t6([nt],lI.prototype,"_positionElementInfo",void 0),t6([nt],lI.prototype,"_normalElementInfo",void 0),t6([nt],lI.prototype,"_onMeshChanged",null);var lN=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lM.Sphere,t._radius=1,t}t5(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){lE._randomPointInsideUnitSphere(n,e),n.scale(this.radius),lE._randomPointUnitSphere(r,e),tU.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)},t4(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(lR),lO=((e9={})[e9.Stretch=0]="Stretch",e9[e9.Tile=1]="Tile",e9),lV=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).emitting=!0,n.minVertexDistance=.1,n.widthCurve=new lg(new lv(0,1),new lv(1,1)),n.colorGradient=new li([new la(0,new tJ(1,1,1,1)),new la(1,new tJ(1,1,1,1))],[new lo(0,1),new lo(1,1)]),n._trailParams=new tZ(lO.Stretch,1,1,0),n._textureScale=new tq(1,1),n._distanceParams=new tq,n._curveMaxTime=new tZ,n._time=5,n._firstActiveElement=0,n._firstNewElement=0,n._firstFreeElement=0,n._firstRetiredElement=0,n._currentPointCapacity=0,n._bufferResized=!1,n._lastPosition=new tU,n._hasLastPosition=!1,n._cumulativeDistance=0,n._playTime=0,n._lastPlayTimeUpdateFrameCount=-1,n._textureScale._onValueChanged=n._onTextureScaleChanged.bind(n),n._onTextureScaleChanged(),n._initGeometry(),n}t5(t,e);var n=t.prototype;return n.clear=function(){this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._hasLastPosition=!1,this._cumulativeDistance=0,this._playTime=0},n._update=function(n){e.prototype._update.call(this,n);var r=this.engine.time,i=this._updateAndGetPlayTime(),a=r.frameCount;this._freeRetiredPoints(a),this._retireActivePoints(i,a),this.emitting&&this._emitNewPoint(i),(this._firstNewElement!==this._firstFreeElement||this._bufferResized||this._vertexBuffer.isContentLost)&&this._addActivePointsToVertexBuffer();var o=this.shaderData,s=this._distanceParams,l=this._vertices,c=this._currentPointCapacity;if(this._getActivePointCount()>0){var u=(this._firstFreeElement-1+c)%c;s.x=l[u*t.POINT_FLOAT_STRIDE+t.DISTANCE_OFFSET],s.y=l[this._firstActiveElement*t.POINT_FLOAT_STRIDE+t.DISTANCE_OFFSET]}else s.x=s.y=0;o.setVector4(t._trailParamsProp,this._trailParams),o.setVector2(t._distanceParamsProp,s);var d=this.colorGradient;o.setFloatArray(t._widthCurveProp,this.widthCurve._getTypeArray()),o.setFloatArray(t._colorKeysProp,d._getColorTypeArray()),o.setFloatArray(t._alphaKeysProp,d._getAlphaTypeArray());var h=d.colorKeys,_=d.alphaKeys,f=this.widthCurve.keys;this._curveMaxTime.set(h.length?h[h.length-1].time:0,_.length?_[_.length-1].time:0,f.length?f[f.length-1].time:0,0),o.setVector4(t._curveMaxTimeProp,this._curveMaxTime)},n._render=function(e){if(!(2>this._getActivePointCount())){var t=this.getMaterial();if(t&&!t.destroyed&&!t.shader.destroyed){var n=this._firstActiveElement,r=this._firstFreeElement,i=this._engine._renderElementPool.get();i.set(this.priority,this._distanceForSort);var a=n>r,o=a&&r>0,s=(a?this._currentPointCapacity-n+(o?1:0):r-n)*2;this._addSubRenderElement(i,t,this._mainSubPrimitive,2*n,s),o&&this._addSubRenderElement(i,t,this._wrapSubPrimitive,0,2*r),e.camera._renderPipeline.pushRenderElement(e,i)}}},n._updateBounds=function(e){var n=this._firstActiveElement,r=this._firstFreeElement,i=e.min,a=e.max,o=n!==r;if(o){var s=this._vertices,l=t.POINT_FLOAT_STRIDE;i.set(1/0,1/0,1/0),a.set(-1/0,-1/0,-1/0);for(var c=n>r,u=n,d=c?this._currentPointCapacity:r;u<d;u++)this._mergePointPosition(s,u*l,i,a);if(c&&r>0)for(var h=0;h<r;h++)this._mergePointPosition(s,h*l,i,a)}else{var _=this._hasLastPosition?this._lastPosition:this.entity.transform.worldPosition;i.copyFrom(_),a.copyFrom(_)}if(this.emitting&&this._hasLastPosition){var f=this.entity.transform.worldPosition;tU.distance(f,this._lastPosition)>=this.minVertexDistance&&(tU.min(i,f,i),tU.max(a,f,a),o=!0)}if(o){for(var p=0,m=this.widthCurve.keys,g=0,v=m.length;g<v;g++){var y=m[g].value;y>p&&(p=y)}var x=.5*p;i.set(i.x-x,i.y-x,i.z-x),a.set(a.x+x,a.y+x,a.z+x)}},n._mergePointPosition=function(e,t,n,r){var i=e[t],a=e[t+1],o=e[t+2];n.set(Math.min(n.x,i),Math.min(n.y,a),Math.min(n.z,o)),r.set(Math.max(r.x,i),Math.max(r.y,a),Math.max(r.z,o))},n._onDestroy=function(){var t,n;e.prototype._onDestroy.call(this),null==(t=this._vertexBuffer)||t.destroy(),null==(n=this._primitive)||n.destroy()},n._updateAndGetPlayTime=function(){var e=this.engine.time,t=e.frameCount;return t!==this._lastPlayTimeUpdateFrameCount&&(this._playTime+=e.deltaTime,this._lastPlayTimeUpdateFrameCount=t),this._playTime},n._initGeometry=function(){var e=new aB(this.engine);this._primitive=e,e.addVertexElement(new aC("a_PositionBirthTime",0,ab.Vector4,0)),e.addVertexElement(new aC("a_CornerTangent",16,ab.Vector4,0)),e.addVertexElement(new aC("a_Distance",32,ab.Float,0)),this._mainSubPrimitive=new aL(0,0,aR.TriangleStrip),this._wrapSubPrimitive=new aL(0,0,aR.TriangleStrip),this._resizeBuffer(t.POINT_INCREASE_COUNT)},n._resizeBuffer=function(e){var n,r=this.engine,i=t.POINT_FLOAT_STRIDE,a=t.POINT_BYTE_STRIDE,o=this._currentPointCapacity+e,s=o+1,l=new ax(r,aT.VertexBuffer,s*a,av.Dynamic,!1),c=new Float32Array(s*i),u=this._vertices;if(u){var d=this._firstFreeElement;c.set(new Float32Array(u.buffer,0,d*i));var h=d+1;c.set(new Float32Array(u.buffer,h*i*4),(h+e)*i),this._firstNewElement>d&&(this._firstNewElement+=e),this._firstActiveElement>d&&(this._firstActiveElement+=e),this._firstRetiredElement>d&&(this._firstRetiredElement+=e),this._bufferResized=!0}null==(n=this._vertexBuffer)||n.destroy(),this._vertexBuffer=l,this._vertices=c,this._currentPointCapacity=o,this._primitive.setVertexBufferBinding(0,new aO(l,t.VERTEX_STRIDE))},n._retireActivePoints=function(e,n){for(var r=this.time,i=this._vertices,a=this._currentPointCapacity,o=t.POINT_FLOAT_STRIDE,s=this._firstActiveElement;this._firstActiveElement!==this._firstFreeElement;){var l=this._firstActiveElement*o+3;if(Math.fround(e-i[l])<r)break;i[l]=n,this._firstActiveElement=(this._firstActiveElement+1)%a}this._firstActiveElement!==s&&(this._dirtyUpdateFlag|=a_.WorldVolume)},n._freeRetiredPoints=function(e){for(var n=this._currentPointCapacity,r=t.POINT_FLOAT_STRIDE,i=this._vertices;this._firstRetiredElement!==this._firstActiveElement&&!(e-i[this._firstRetiredElement*r+3]<0);)this._firstRetiredElement=(this._firstRetiredElement+1)%n},n._emitNewPoint=function(e){var n=this.entity.transform.worldPosition;this._hasLastPosition&&tU.distance(n,this._lastPosition)<this.minVertexDistance||((this._firstFreeElement+1)%this._currentPointCapacity===this._firstRetiredElement&&this._resizeBuffer(t.POINT_INCREASE_COUNT),this._addPoint(n,e),this._lastPosition.copyFrom(n),this._hasLastPosition=!0)},n._addPoint=function(e,n){var r=this._firstFreeElement,i=t.VERTEX_FLOAT_STRIDE,a=t.POINT_FLOAT_STRIDE,o=this._vertices,s=this._currentPointCapacity,l=t._tempVector3;if(this._hasLastPosition){tU.subtract(e,this._lastPosition,l);var c=l.length();if(l.normalize(),1===this._getActivePointCount()){var u=this._firstActiveElement*a;l.copyToArray(o,u+5),l.copyToArray(o,u+i+5),this._firstNewElement=this._firstActiveElement}this._cumulativeDistance+=c}else l.set(0,0,1);var d=t.DISTANCE_OFFSET,h=this._cumulativeDistance,_=r*a;e.copyToArray(o,_),o[_+3]=n,o[_+4]=-1,l.copyToArray(o,_+5),o[_+d]=h;var f=_+i;if(e.copyToArray(o,f),o[f+3]=n,o[f+4]=1,l.copyToArray(o,f+5),o[f+d]=h,0===r){var p=s*a,m=p+i;e.copyToArray(o,p),o[p+3]=n,o[p+4]=-1,l.copyToArray(o,p+5),o[p+d]=h,e.copyToArray(o,m),o[m+3]=n,o[m+4]=1,l.copyToArray(o,m+5),o[m+d]=h}this._firstFreeElement=(this._firstFreeElement+1)%s},n._getActivePointCount=function(){var e=this._firstActiveElement,t=this._firstFreeElement,n=this._currentPointCapacity;return t>=e?t-e:n-e+t},n._addActivePointsToVertexBuffer=function(){var e=this._firstActiveElement,n=this._firstFreeElement,r=this._vertexBuffer;if(e!==n){var i=t.POINT_FLOAT_STRIDE,a=t.POINT_BYTE_STRIDE,o=this._currentPointCapacity,s=e>n;s?(r.setData(new Float32Array(this._vertices.buffer,e*i*4,(o-e+(s&&n>0?1:0))*i),e*a,0,void 0,ay.Discard),n>0&&r.setData(new Float32Array(this._vertices.buffer,0,n*i),0)):(r.setData(new Float32Array(this._vertices.buffer,e*i*4,(n-e)*i),e*a,0,void 0,ay.Discard),0===e&&r.setData(new Float32Array(this._vertices.buffer,o*i*4,i),o*a)),this._firstNewElement=n,this._bufferResized=!1}},n._addSubRenderElement=function(e,t,n,r,i){n.start=r,n.count=i;var a=this._engine._subRenderElementPool.get();a.set(this,t,this._primitive,n),e.addSubRenderElement(a)},n._onTextureScaleChanged=function(){this._trailParams.y=this._textureScale.x,this._trailParams.z=this._textureScale.y},t4(t,[{key:"time",get:function(){return this._time},set:function(e){this._time=e}},{key:"textureMode",get:function(){return this._trailParams.x},set:function(e){this._trailParams.x=e}},{key:"textureScale",get:function(){return this._textureScale},set:function(e){e!==this._textureScale&&this._textureScale.copyFrom(e)}}]),t}(ah);lV.VERTEX_STRIDE=36,lV.VERTEX_FLOAT_STRIDE=9,lV.DISTANCE_OFFSET=8,lV.POINT_FLOAT_STRIDE=18,lV.POINT_BYTE_STRIDE=72,lV.POINT_INCREASE_COUNT=128,lV._trailParamsProp=nH.getByName("renderer_TrailParams"),lV._distanceParamsProp=nH.getByName("renderer_DistanceParams"),lV._widthCurveProp=nH.getByName("renderer_WidthCurve"),lV._colorKeysProp=nH.getByName("renderer_ColorKeys"),lV._alphaKeysProp=nH.getByName("renderer_AlphaKeys"),lV._curveMaxTimeProp=nH.getByName("renderer_CurveMaxTime"),lV._tempVector3=new tU,t6([ni],lV.prototype,"widthCurve",void 0),t6([ni],lV.prototype,"colorGradient",void 0),t6([ni],lV.prototype,"_trailParams",void 0),t6([ni],lV.prototype,"_textureScale",void 0),t6([nt],lV.prototype,"_distanceParams",void 0),t6([nt],lV.prototype,"_curveMaxTime",void 0),t6([nt],lV.prototype,"_primitive",void 0),t6([nt],lV.prototype,"_mainSubPrimitive",void 0),t6([nt],lV.prototype,"_wrapSubPrimitive",void 0),t6([nt],lV.prototype,"_vertexBuffer",void 0),t6([nt],lV.prototype,"_vertices",void 0),t6([nt],lV.prototype,"_firstActiveElement",void 0),t6([nt],lV.prototype,"_firstNewElement",void 0),t6([nt],lV.prototype,"_firstFreeElement",void 0),t6([nt],lV.prototype,"_firstRetiredElement",void 0),t6([nt],lV.prototype,"_currentPointCapacity",void 0),t6([nt],lV.prototype,"_bufferResized",void 0),t6([nt],lV.prototype,"_lastPosition",void 0),t6([nt],lV.prototype,"_hasLastPosition",void 0),t6([nt],lV.prototype,"_cumulativeDistance",void 0),t6([nt],lV.prototype,"_playTime",void 0),t6([nt],lV.prototype,"_lastPlayTimeUpdateFrameCount",void 0),t6([nt],lV.prototype,"_onTextureScaleChanged",null);var lk=/*#__PURE__*/function(e){function t(t){return e.call(this,t,rM.find("trail"))||this}return t5(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t}(lS),lU=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.probeLayer=rU.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t}t5(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 nw(this.engine,this.width,this.height,this._isCube?new nP(this.engine,this.width):new nF(this.engine,this.width,this.height),nc.Depth,this.antiAliasing),this._renderTargetSwap=new nw(this.engine,this.width,this.height,this._isCube?new nP(this.engine,this.width):new nF(this.engine,this.width,this.height),nc.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)},t4(t,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),t}(o7),lz=new tU,lG=new tU,lH=new tU,lW=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.position=new tU(0,0,0),t._isCube=!0,t.oriViewMatrix=new tK,t}t5(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(nu.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:lG.set(0,-1,0),lH.set(1,0,0);break;case 1:lG.set(0,-1,0),lH.set(-1,0,0);break;case 2:lG.set(0,0,1),lH.set(0,1,0);break;case 3:lG.set(0,0,-1),lH.set(0,-1,0);break;case 4:lG.set(0,-1,0),lH.set(0,0,1);break;case 5:lG.set(0,-1,0),lH.set(0,0,-1)}tU.add(this.position,lH,lz),tK.lookAt(this.position,lz,lG,t.viewMatrix),t.fieldOfView=90},t}(lU),lX=/*#__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}t5(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},t4(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}(ns),lj=/*#__PURE__*/function(){function e(){}return e.suspend=function(){return e._context.suspend()},e.resume=function(){var t;return null!=(t=e._resumePromise)?t:e._resumePromise=e._context.resume().then(function(){e._needsUserGestureResume=!1}).finally(function(){e._resumePromise=null})},e.getContext=function(){var t=e._context;return t||(e._context=t=new window.AudioContext,document.addEventListener("visibilitychange",e._onVisibilityChange),document.addEventListener("touchstart",e._resumeAfterInterruption,{passive:!0}),document.addEventListener("touchend",e._resumeAfterInterruption,{passive:!0}),document.addEventListener("click",e._resumeAfterInterruption)),t},e.getGainNode=function(){var t=e._gainNode;if(!t){var n=e.getContext();e._gainNode=t=n.createGain(),t.connect(n.destination)}return t},e.isAudioContextRunning=function(){return"running"===e.getContext().state},e._onVisibilityChange=function(){document.hidden||!(e._playingCount>0)||e.isAudioContextRunning()||(e.suspend(),e._needsUserGestureResume=!0)},e._resumeAfterInterruption=function(){e._needsUserGestureResume&&e.resume().catch(function(e){console.warn("Failed to resume AudioContext:",e)})},e}();lj._playingCount=0,lj._resumePromise=null,lj._needsUserGestureResume=!1;var lY=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).playOnEnabled=!0,n._isPlaying=!1,n._pendingPlay=!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=lj.getContext().createGain(),n._gainNode.connect(lj.getGainNode()),n}t5(t,e);var n=t.prototype;return n.play=function(){var e,t=this;(null==(e=this._clip)?void 0:e._getAudioSource())&&!this._isPlaying&&!this._pendingPlay&&(lj.isAudioContextRunning()?this._startPlayback():(this._pendingPlay=!0,lj.resume().then(function(){t._pendingPlay&&(t._pendingPlay=!1,!t._destroyed&&t.enabled&&t._clip&&t._startPlayback())},function(e){t._pendingPlay=!1,console.warn("Failed to resume AudioContext:",e)})))},n.stop=function(){this._pendingPlay=!1,this._isPlaying&&(this._clearSourceNode(),this._isPlaying=!1,this._pausedTime=-1,this._playTime=-1,lj._playingCount--)},n.pause=function(){this._pendingPlay=!1,this._isPlaying&&(this._clearSourceNode(),this._pausedTime=lj.getContext().currentTime,this._isPlaying=!1,lj._playingCount--)},n._cloneTo=function(e){var t;null==(t=e._clip)||t._addReferCount(1),e._gainNode.gain.setValueAtTime(e._volume,lj.getContext().currentTime)},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._startPlayback=function(){var e=this._pausedTime>0?this._pausedTime-this._playTime:0;this._initSourceNode(e),this._playTime=lj.getContext().currentTime-e,this._pausedTime=-1,this._isPlaying=!0,lj._playingCount++},n._initSourceNode=function(e){var t=lj.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),t.start(0,e)},n._clearSourceNode=function(){this._sourceNode.stop(),this._sourceNode.disconnect(),this._sourceNode.onended=null,this._sourceNode=null},t4(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,lj.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?lj.getContext().currentTime-this._playTime:this._pausedTime>0?this._pausedTime-this._playTime:0}}]),t}(rN);t6([nt],lY.prototype,"_isPlaying",void 0),t6([nt],lY.prototype,"_pendingPlay",void 0),t6([nn],lY.prototype,"_clip",void 0),t6([nt],lY.prototype,"_gainNode",void 0),t6([nt],lY.prototype,"_sourceNode",void 0),t6([nt],lY.prototype,"_pausedTime",void 0),t6([nt],lY.prototype,"_playTime",void 0),t6([nn],lY.prototype,"_volume",void 0),t6([nn],lY.prototype,"_lastVolume",void 0),t6([nn],lY.prototype,"_playbackRate",void 0),t6([nn],lY.prototype,"_loop",void 0),t6([nt],lY.prototype,"_onPlayEnd",null),/*#__PURE__*/(function(){function e(){}return e.registerPolyfill=function(){e._registerMatchAll(),e._registerAudioContext(),e._registerTextMetrics(),e._registerPromiseFinally()},e._registerMatchAll=function(){String.prototype.matchAll||(nb.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._registerAudioContext=function(){if(!window.AudioContext&&window.webkitAudioContext){nb.info("Polyfill window.AudioContext"),window.AudioContext=window.webkitAudioContext;var e=AudioContext.prototype.decodeAudioData;AudioContext.prototype.decodeAudioData=function(t,n,r){var i=this;return new Promise(function(a,o){e.call(i,t,function(e){null==n||n(e),a(e)},function(e){null==r||r(e),o(e)})})}}},e._registerTextMetrics=function(){!window.TextMetrics||"actualBoundingBoxLeft"in TextMetrics.prototype||Object.defineProperties(TextMetrics.prototype,{actualBoundingBoxLeft:{get:function(){return 0}},actualBoundingBoxRight:{get:function(){return this.width}}})},e._registerPromiseFinally=function(){Promise.prototype.finally||(nb.info("Polyfill Promise.prototype.finally"),Promise.prototype.finally=function(e){return this.then(function(t){return Promise.resolve(null==e?void 0:e()).then(function(){return t})},function(t){return Promise.resolve(null==e?void 0:e()).then(function(){throw t})})})},e})().registerPolyfill();var lK=/*#__PURE__*/Object.freeze({__proto__:null,AmbientLight:o0,AmbientOcclusion:o8,AmbientOcclusionQuality:ia,get AnimationArrayCurve(){return sv},get AnimationBoolCurve(){return sy},AnimationClip:sp,AnimationClipCurveBinding:s_,get AnimationColorCurve(){return sx},AnimationCurve:sg,AnimationEvent:sf,get AnimationFloatArrayCurve(){return sA},get AnimationFloatCurve(){return sb},get AnimationQuaternionCurve(){return sS},get AnimationRectCurve(){return sM},get AnimationRefCurve(){return sE},get AnimationStringCurve(){return sP},get AnimationVector2Curve(){return sC},get AnimationVector3Curve(){return sT},get AnimationVector4Curve(){return sR},Animator:sG,AnimatorCondition:sN,AnimatorConditionMode:sw,AnimatorController:sW,AnimatorControllerLayer:sQ,AnimatorControllerParameter:sH,AnimatorCullingMode:sF,AnimatorLayerBlendingMode:sL,AnimatorLayerMask:sJ,AnimatorState:sY,AnimatorStateMachine:sK,AnimatorStateTransition:sO,AntiAliasing:rX,AssetPromise:nS,AssetType:ol,AudioClip:lX,AudioManager:lj,AudioSource:lY,Background:rD,BackgroundMode:n5,BackgroundTextureFillMode:n9,BaseMaterial:r4,BasicRenderPipeline:as,BatchUtils:i9,BlendFactor:n6,BlendMode:r1,BlendOperation:n7,BlendShape:aw,BlendShapeFrame:aM,BlendState:rS,BlinnPhongMaterial:r8,Blitter:it,BloomDownScaleMode:iv,BloomEffect:iy,BoolUpdateFlag:rz,BoxColliderShape:iq,BoxShape:lP,Buffer:ax,BufferAsset:sa,BufferBindFlag:aT,BufferMesh:aV,BufferUsage:av,BufferUtil:aS,Burst:lT,get Camera(){return r0},CameraClearFlags:rj,CameraModifyFlags:rY,CameraType:rK,Canvas:oQ,CapsuleColliderShape:i$,CharRenderInfo:t9,CharacterController:iR,CircleShape:lF,ClearableObjectPool:oR,CloneManager:na,CloneUtils:rB,get Collider(){return iC},ColliderShape:iw,ColliderShapeUpAxis:iU,Collision:iO,CollisionDetectionMode:iD,ColorOverLifetimeModule:lc,ColorWriteMask:re,CompareFunction:rt,Component:rN,ConeEmitType:lD,ConeShape:lL,ContactPoint:iN,ContentRestorer:nl,ControllerCollisionFlag:iz,ControllerNonWalkableMode:iT,CubeProbe:lW,CullMode:rn,CurveKey:lv,DataType:nC,DependentMode:rk,DepthState:rC,DepthTextureMode:rQ,DiffuseMode:o$,DirectLight:o2,DisorderedArray:nQ,Downsampling:rq,DynamicCollider:iL,DynamicColliderConstraints:iB,EmissionModule:ld,Engine:oK,EngineObject:no,Entity:a7,EntityModifyFlags:a6,EventDispatcher:nG,FinalPass:i4,FixedJoint:iW,FogMode:oJ,Font:nV,FontStyle:nB,GLCapabilityType:nT,GradientAlphaKey:lo,GradientColorKey:la,HemisphereShape:lB,HingeJoint:ij,HitResult:iI,IndexBufferBinding:aF,IndexFormat:aA,InputManager:oN,InterpolationType:sm,JSONAsset:si,get Joint(){return iG},JointLimits:iK,JointMotor:iQ,Keyframe:sq,Keys:oC,Layer:rU,LayerPathMask:sZ,Light:o1,LimitVelocityOverLifetimeModule:l_,Loader:sn,Logger:nb,MSAASamples:rZ,MainModule:lp,Material:r3,Mesh:aI,MeshColliderShape:iF,MeshColliderShapeCookingFlag:iE,MeshRenderer:ak,MeshShape:lI,MeshTopology:aR,ModelMesh:aG,OverflowMode:nI,PBRMaterial:r6,ParticleCompositeCurve:lu,ParticleCompositeGradient:ls,ParticleCurve:lg,ParticleCurveMode:lt,ParticleGenerator:lb,ParticleGradient:li,ParticleGradientMode:ln,ParticleMaterial:lC,ParticleRenderMode:s2,ParticleRenderer:s8,ParticleScaleMode:lf,ParticleShapeArcMode:lw,ParticleShapeType:lM,ParticleSimulationSpace:s3,ParticleStopMode:s4,PhysicsMaterial:iP,PhysicsMaterialCombineMode:iM,PhysicsScene:iV,PipelineStage:rh,PlaneColliderShape:iJ,Platform:t2,PointLight:o3,Pointer:oM,PointerButton:oA,PointerEventData:ow,PointerEventEmitter:oF,PointerPhase:oE,PostProcess:ib,PostProcessEffect:ig,PostProcessEffectBoolParameter:ic,PostProcessEffectColorParameter:id,PostProcessEffectEnumParameter:im,PostProcessEffectFloatParameter:il,PostProcessEffectParameter:is,PostProcessEffectTextureParameter:iu,PostProcessEffectVector2Parameter:ih,PostProcessEffectVector3Parameter:i_,PostProcessEffectVector4Parameter:ip,PostProcessManager:i0,PostProcessPass:i2,PostProcessPassEvent:i1,PostProcessUberPass:i3,Primitive:aB,PrimitiveMesh:a0,Probe:lU,RasterState:rT,ReferResource:ns,RefractionMode:r9,RenderBufferDepthFormat:nc,RenderFace:r2,RenderQueue:i5,RenderQueueFlags:al,RenderQueueType:rr,RenderState:rE,RenderStateElementKey:ri,RenderTarget:nw,RenderTargetBlendState:rb,get Renderer(){return ah},RendererUpdateFlags:a_,RenderingStatistics:od,ReplacementFailureStrategy:rJ,ResourceManager:om,ReturnableObjectPool:ot,RotationOverLifetimeModule:lm,SafeLoopArray:oc,Scene:o9,SceneManager:ou,Script:o7,SetDataOptions:ay,Shader:rM,ShaderData:rP,ShaderDataGroup:ra,ShaderFactory:rf,ShaderLanguage:ro,ShaderLib:r_,ShaderMacro:rc,ShaderMacroCollection:ru,ShaderPass:rx,ShaderProperty:nH,ShaderPropertyType:rs,ShaderTagKey:rp,ShadowCascadesMode:an,ShadowResolution:i7,ShadowType:ae,Signal:st,get SimpleSpriteAssembler(){return nU},SizeOverLifetimeModule:ly,Skin:a1,SkinnedMeshRenderer:a3,Sky:rL,SkyBoxMaterial:s$,SkyProceduralMaterial:s1,get SlicedSpriteAssembler(){return nz},SphereColliderShape:iZ,SphereShape:lN,SpotLight:o4,SpringJoint:iY,Sprite:n8,SpriteAtlas:nJ,SpriteDrawMode:n$,SpriteMask:af,SpriteMaskInteraction:n0,SpriteMaskLayer:ad,SpriteModifyFlags:n1,SpriteRenderer:ap,SpriteTileMode:nq,StateMachineScript:sj,StaticCollider:ik,StencilOperation:rl,StencilState:rR,SubFont:nO,SubMesh:aD,SubPrimitive:aL,SubShader:rA,SunMode:s0,SystemInfo:nR,TextAsset:sr,TextHorizontalAlignment:n2,TextRenderer:am,TextUtils:nN,TextVerticalAlignment:n3,Texture:nE,Texture2D:nF,Texture2DArray:nL,TextureCoordinate:r5,TextureCube:nP,TextureCubeFace:nu,TextureDepthCompareFunction:nd,TextureFilterMode:nh,TextureFormat:n_,TextureSheetAnimationModule:lx,TextureUsage:nf,TextureUtils:nM,TextureWrapMode:np,get TiledSpriteAssembler(){return nZ},Time:nW,TonemappingEffect:iA,TonemappingMode:ix,TrailMaterial:lk,TrailRenderer:lV,TrailTextureMode:lO,Transform:rG,TransformModifyFlags:rH,UnlitMaterial:r7,Utils:nX,VelocityOverLifetimeModule:lA,VertexAttribute:az,VertexBufferBinding:aO,VertexElement:aC,VertexElementFormat:ab,WrapMode:sV,XRManager:oY,assignmentClone:nn,deepClone:ni,dependentComponents:rV,ignoreClone:nt,registerPointerEventEmitter:oB,request:of,resourceLoader:og,shallowClone:nr}),lQ=((e6={})[e6.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",e6[e6.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",e6[e6.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",e6[e6.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",e6[e6.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",e6[e6.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",e6[e6.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",e6[e6.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",e6[e6.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",e6[e6.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",e6[e6.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",e6[e6.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",e6[e6.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",e6[e6.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",e6[e6.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",e6[e6.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",e6[e6.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",e6[e6.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",e6[e6.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",e6[e6.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",e6[e6.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",e6[e6.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",e6[e6.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",e6[e6.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",e6[e6.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",e6[e6.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",e6[e6.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",e6[e6.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",e6[e6.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",e6[e6.R11_EAC=37488]="R11_EAC",e6[e6.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",e6[e6.RG11_EAC=37490]="RG11_EAC",e6[e6.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",e6[e6.RGB8_ETC2=37492]="RGB8_ETC2",e6[e6.SRGB8_ETC2=37493]="SRGB8_ETC2",e6[e6.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e6[e6.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e6[e6.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",e6[e6.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",e6[e6.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",e6[e6.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",e6[e6.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",e6[e6.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",e6[e6.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",e6[e6.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",e6[e6.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",e6[e6.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",e6[e6.SRGB_S3TC_DXT1_EXT=35916]="SRGB_S3TC_DXT1_EXT",e6[e6.SRGB_ALPHA_S3TC_DXT1_EXT=35917]="SRGB_ALPHA_S3TC_DXT1_EXT",e6[e6.SRGB_ALPHA_S3TC_DXT3_EXT=35918]="SRGB_ALPHA_S3TC_DXT3_EXT",e6[e6.SRGB_ALPHA_S3TC_DXT5_EXT=35919]="SRGB_ALPHA_S3TC_DXT5_EXT",e6[e6.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",e6[e6.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",e6[e6.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",e6[e6.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT",e6);function lq(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 lZ(e,t,n){return t&&lq(e.prototype,t),n&&lq(e,n),e}function lJ(e,t){return(lJ=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l$(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&&lJ(e,t)}function l0(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):e(t,n)}var l1=/*#__PURE__*/function(e){function t(t){(n=e.call(this)||this)._scale=new tq;var n,r=t.width,i=t.height;return n._webCanvas=t,n.width=r,n.height=i,n}l$(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||!l0(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},lZ(t,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&l0(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&&l0(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),t}(oQ),l2=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l$(t,e),t.create=function(e){var n=e.canvas,r=new t(new l1("string"==typeof n?document.getElementById(n):n),new cl(e.graphicDeviceOptions),e);return r._initialize(e).then(function(){return r.sceneManager.addScene(new o9(r,"DefaultScene")),r})},lZ(t,[{key:"canvas",get:function(){return this._canvas}}]),t}(oK);function l3(){return(l3=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 l4=/*#__PURE__*/function(){function e(e,t,n,r,i){void 0===r&&(r=av.Static);var a=e.gl,o=a.createBuffer(),s=this._getGLBufferUsage(a,r),l=t===aT.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===ay.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.copyFromBuffer=function(e,t,n,r){var i=this._gl;i.bindBuffer(i.COPY_READ_BUFFER,e._glBuffer),i.bindBuffer(i.COPY_WRITE_BUFFER,this._glBuffer),i.copyBufferSubData(i.COPY_READ_BUFFER,i.COPY_WRITE_BUFFER,t,n,r),i.bindBuffer(i.COPY_READ_BUFFER,null),i.bindBuffer(i.COPY_WRITE_BUFFER,null)},t.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},t._getGLBufferUsage=function(e,t){switch(t){case av.Static:return e.STATIC_DRAW;case av.Dynamic:return e.DYNAMIC_DRAW;case av.Stream:return e.STREAM_DRAW}},e}(),l8=/*#__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=lQ.RGBA_ASTC_4X4_KHR,n=lQ.RGBA_ASTC_12X12_KHR,r=lQ.SRGB8_ALPHA8_ASTC_4X4_KHR,i=lQ.SRGB8_ALPHA8_ASTC_12X12_KHR,a=lQ.RGB_ETC1_WEBGL,o=lQ.R11_EAC,s=lQ.SRGB8_ALPHA8_ETC2_EAC,l=lQ.RGB_PVRTC_4BPPV1_IMG,c=lQ.RGBA_PVRTC_2BPPV1_IMG,u=lQ.RGB_S3TC_DXT1_EXT,d=lQ.RGBA_S3TC_DXT5_EXT,h=lQ.RGBA_BPTC_UNORM_EXT,_=lQ.RGB_BPTC_UNSIGNED_FLOAT_EXT;return e>=t&&n<=n||e>=r&&e<=i?this.canIUse(nT.astc):e===a?this.canIUse(nT.etc1):e>=o&&e<=s?this.canIUse(nT.etc):e>=l&&e<=c?this.canIUse(nT.pvrtc):e>=u&&e<=d?this.canIUse(nT.s3tc):!!(e>=h)&&!!(e<=_)&&this.canIUse(nT.bptc)},t._init=function(){var e=this.capabilityList,t=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),r=nT.shaderVertexID,i=nT.standardDerivatives,a=nT.shaderTextureLod,o=nT.elementIndexUint,s=nT.depthTexture,l=nT.vertexArrayObject,c=nT.instancedArrays,u=nT.multipleSample,d=nT.drawBuffers,h=nT.blendMinMax,_=nT.astc,f=nT.astc_webkit,p=nT.astc_hdr,m=nT.etc,g=nT.etc_webkit,v=nT.etc1,y=nT.etc1_webkit,x=nT.pvrtc,A=nT.pvrtc_webkit,b=nT.s3tc,S=nT.s3tc_webkit,C=nT.bptc,T=nT.s3tc_srgb,R=nT.textureFloat,E=nT.textureHalfFloat,M=nT.textureFloatLinear,P=nT.textureHalfFloatLinear,w=nT.WEBGL_colorBufferFloat,F=nT.colorBufferFloat,L=nT.colorBufferHalfFloat,D=nT.textureFilterAnisotropic,B=nT.fragDepth,I=nT.sRGB;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(R,t||!!n(R)),e.set(E,t||!!n(E)),e.set(M,!!n(M)),e.set(P,t||!!n(P)),e.set(F,t&&!!n(F)||!!n(w)),e.set(L,t&&!!n(F)||!!n(L)),e.set(D,!!n(D)),e.set(B,t||!!n(B)),e.set(m,!!(n(m)||n(g))),e.set(v,!!(n(v)||n(y))),e.set(x,!!(n(x)||n(A))),e.set(b,!!(n(b)||n(S))),e.set(T,!!n(T)),e.set(C,!!n(C));var N=n(_)||n(f);e.set(_,!!N),e.set(p,!!(null==N?void 0:N.getSupportedProfiles().includes("hdr"))),e.set(I,t||!!n(I))},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=nT.depthTexture,t=nT.vertexArrayObject,n=nT.instancedArrays,r=nT.drawBuffers,i=nT.textureFilterAnisotropic,a=nT.textureHalfFloat,o=nT.colorBufferHalfFloat,s=nT.WEBGL_colorBufferFloat,l=nT.blendMinMax,c=nT.sRGB;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 u={};if(this.canIUse(nT.drawBuffers)){for(var d=this.maxDrawBuffers,h=0;h<d;h++)0!=h&&(u["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),u["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(r,l3({drawBuffers:"drawBuffersWEBGL"},u))}this._compatibleInterface(a,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(o,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(s,{RGBA32F:"RBGA32F_EXT"}),this._compatibleInterface(c,{SRGB8:"SRGB_EXT",SRGB8_ALPHA8:"SRGB_ALPHA_EXT"})}this._compatibleInterface(i,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},lZ(e,[{key:"maxTextureSize",get:function(){return this.rhi.renderStates.getParameter(this.rhi.gl.MAX_TEXTURE_SIZE)}},{key:"canUseFloatTextureBlendShape",get:function(){return this.canIUse(nT.shaderVertexID)&&this.canIUse(nT.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(nT.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(nT.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(nT.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(nT.multipleSample);this._maxAntiAliasing=t?e.getParameter(e.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"isFragmentHighPrecision",get:function(){var e=this._rhi.gl;return 0!==e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision}},{key:"rhi",get:function(){return this._rhi}}]),e}(),l5=/*#__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}(),l9=/*#__PURE__*/function(){function e(e,t){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=t,this._canUseInstancedArrays=e.canIUse(nT.instancedArrays),this._isSupportVAO=e.canIUse(nT.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 nb.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 nb.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}(),l6=/*#__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}(),l7=/*#__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(){var e=this._texture,t=e._mipmap;if(!nM.supportGenerateMipmaps(e.format,t,e.isSRGBColorSpace,this._isWebGL2)){nb.warn("Auto-generating mipmaps for sRGB textures is only supported in [WebGL2 + R8G8B8A8], you must generate mipmaps manually.");return}(1!==e.width||1!==e.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!==nf.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,d=l.readFormat,h=l.alignment;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),a>0&&!this._isWebGL2&&(a=0,nb.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.pixelStorei(s.PACK_ALIGNMENT,h),s.readPixels(t,n,r,i,null!=d?d:c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},t._validate=function(e,t){var n=e.format,r=e.width,i=e.height;e._isSRGBColorSpace&&!nM.supportSRGB(n)&&(nb.warn("Only support sRGB color space in RGB8 or RGBA8 or some compressed texture format"),e._isSRGBColorSpace=!1);var a=t.isWebGL2;e._mipmap&&!nM.supportMipmaps(r,i,a)&&(nb.warn("Non-power-2 texture is not supported for mipmap in WebGL1, and has automatically downgraded to non-mipmap"),e._mipmap=!1,e._mipmapCount=e._getMipmapCount())},t._setWrapMode=function(e,t){var n=this._gl,r=this._isWebGL2,i=this._target,a=this._texture,o=a.width,s=a.height;switch(r||e===np.Clamp||tk.isPowerOf2(o)&&tk.isPowerOf2(s)||(nb.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),e=np.Clamp),e){case np.Clamp:n.texParameteri(i,t,n.CLAMP_TO_EDGE);break;case np.Repeat:n.texParameteri(i,t,n.REPEAT);break;case np.Mirror:n.texParameteri(i,t,n.MIRRORED_REPEAT)}},e._getFormatDetail=function(e,t,n,r){switch(e){case n_.R8G8B8:return{internalFormat:t?n.SRGB8:r?n.RGB8:n.RGB,baseFormat:t?r?n.RGB:n.SRGB8:n.RGB,readFormat:r?n.RGBA:n.RGB,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:1};case n_.R8G8B8A8:return{internalFormat:t?n.SRGB8_ALPHA8:r?n.RGBA8:n.RGBA,baseFormat:t?r?n.RGBA:n.SRGB8_ALPHA8:n.RGBA,readFormat:n.RGBA,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:4};case n_.R4G4B4A4:return{internalFormat:r?n.RGBA4:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1,alignment:2};case n_.R5G5B5A1:return{internalFormat:r?n.RGB5_A1:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1,alignment:2};case n_.R5G6B5:return{internalFormat:r?n.RGB565:n.RGB,baseFormat:n.RGB,dataType:n.UNSIGNED_SHORT_5_6_5,isCompressed:!1,alignment:2};case n_.Alpha8:return{internalFormat:n.ALPHA,baseFormat:n.ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:1};case n_.LuminanceAlpha:return{internalFormat:n.LUMINANCE_ALPHA,baseFormat:n.LUMINANCE_ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:2};case n_.R16G16B16A16:return{internalFormat:r?n.RGBA16F:n.RGBA,baseFormat:n.RGBA,dataType:n.HALF_FLOAT,isCompressed:!1,alignment:8};case n_.R32G32B32A32:return{internalFormat:r?n.RGBA32F:n.RGBA,baseFormat:n.RGBA,dataType:n.FLOAT,isCompressed:!1,alignment:8};case n_.R11G11B10_UFloat:return{internalFormat:n.R11F_G11F_B10F,baseFormat:n.RGB,readFormat:n.RGBA,dataType:n.FLOAT,isCompressed:!1,alignment:4};case n_.R32G32B32A32_UInt:return{internalFormat:n.RGBA32UI,baseFormat:n.RGBA_INTEGER,dataType:n.UNSIGNED_INT,isCompressed:!1,alignment:8};case n_.R8:return{internalFormat:n.R8,baseFormat:n.RED,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:1};case n_.R8G8:return{internalFormat:n.RG8,baseFormat:n.RG,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:2};case n_.BC1:return{internalFormat:t?lQ.SRGB_S3TC_DXT1_EXT:lQ.RGB_S3TC_DXT1_EXT,isCompressed:!0};case n_.BC3:return{internalFormat:t?lQ.SRGB_ALPHA_S3TC_DXT5_EXT:lQ.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case n_.BC7:return{internalFormat:t?lQ.SRGB_ALPHA_BPTC_UNORM_EXT:lQ.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case n_.BC6H:return{internalFormat:lQ.RGB_BPTC_UNSIGNED_FLOAT_EXT,isCompressed:!0};case n_.ETC1_RGB:return{internalFormat:lQ.RGB_ETC1_WEBGL,isCompressed:!0};case n_.ETC2_RGB:return{internalFormat:t?lQ.SRGB8_ETC2:lQ.RGB8_ETC2,isCompressed:!0};case n_.ETC2_RGBA5:return{internalFormat:lQ.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case n_.ETC2_RGBA8:return{internalFormat:t?lQ.SRGB8_ALPHA8_ETC2_EAC:lQ.RGBA8_ETC2_EAC,isCompressed:!0};case n_.PVRTC_RGB2:return{internalFormat:lQ.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case n_.PVRTC_RGBA2:return{internalFormat:lQ.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case n_.PVRTC_RGB4:return{internalFormat:lQ.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case n_.PVRTC_RGBA4:return{internalFormat:lQ.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case n_.ASTC_4x4:return{internalFormat:t?lQ.SRGB8_ALPHA8_ASTC_4X4_KHR:lQ.RGBA_ASTC_4X4_KHR,isCompressed:!0};case n_.ASTC_5x5:return{internalFormat:lQ.RGBA_ASTC_5X5_KHR,isCompressed:!0};case n_.ASTC_6x6:return{internalFormat:lQ.RGBA_ASTC_6X6_KHR,isCompressed:!0};case n_.ASTC_8x8:return{internalFormat:lQ.RGBA_ASTC_8X8_KHR,isCompressed:!0};case n_.ASTC_10x10:return{internalFormat:lQ.RGBA_ASTC_10X10_KHR,isCompressed:!0};case n_.ASTC_12x12:return{internalFormat:lQ.RGBA_ASTC_12X12_KHR,isCompressed:!0};case n_.Depth:return{internalFormat:r?n.DEPTH_COMPONENT32F:n.DEPTH_COMPONENT,baseFormat:n.DEPTH_COMPONENT,dataType:r?n.FLOAT:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case n_.DepthStencil:return{internalFormat:r?n.DEPTH32F_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:r?n.FLOAT_32_UNSIGNED_INT_24_8_REV:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case n_.Depth16:return{internalFormat:r?n.DEPTH_COMPONENT16:n.DEPTH_COMPONENT,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case n_.Depth24Stencil8:return{internalFormat:r?n.DEPTH24_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case n_.Depth24:return{internalFormat:n.DEPTH_COMPONENT24,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_INT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case n_.Depth32:return{internalFormat:n.DEPTH_COMPONENT32F,baseFormat:n.DEPTH_COMPONENT,dataType:n.FLOAT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case n_.Depth32Stencil8:return{internalFormat:n.DEPTH32F_STENCIL8,baseFormat:n.DEPTH_STENCIL,dataType:n.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+e)}},e._getRenderBufferDepthFormatDetail=function(e,t,n){switch(e){case n_.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 n_.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 n_.Stencil:return{internalFormat:t.STENCIL_INDEX8,baseFormat:t.STENCIL_ATTACHMENT,dataType:t.UNSIGNED_BYTE,isCompressed:!1,attachment:t.STENCIL_ATTACHMENT};case n_.Depth16:return{internalFormat:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case n_.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 n_.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case n_.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case n_.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._supportRenderBufferColorFormat=function(e,t){var n=!0;switch(e){case n_.R16G16B16A16:t.canIUse(nT.colorBufferHalfFloat)&&t.canIUse(nT.textureHalfFloat)||(n=!1);break;case n_.R32G32B32A32:t.canIUse(nT.colorBufferFloat)&&t.canIUse(nT.textureFloat)||(n=!1);break;case n_.R11G11B10_UFloat:n=t.isWebGL2}return n},e._supportRenderBufferDepthFormat=function(e,t){if(!t.isWebGL2)switch(e){case n_.Depth24:case n_.Depth32:case n_.Depth32Stencil8:return!1}return!0},lZ(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 nh.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 nh.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 nh.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 nd.Never:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NEVER);break;case nd.Less:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LESS);break;case nd.Equal:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.EQUAL);break;case nd.LessEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LEQUAL);break;case nd.Greater:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GREATER);break;case nd.NotEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NOTEQUAL);break;case nd.GreaterEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GEQUAL);break;case nd.Always:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.ALWAYS)}}}]),e}(),ce=/*#__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=l0(r,nE),s=0,l=n.length;s<l;s++){var c=n[s],u=c.format,d=c.isSRGBColorSpace;if(!l7._supportRenderBufferColorFormat(u,e))throw Error("TextureFormat is not supported:"+n_[u]+" in RenderTarget");if(d&&u===n_.R8G8B8)throw Error("If you want to use sRGB color space, only R8G8B8A8 format is supported in RenderTarget")}if(!o&&!l7._supportRenderBufferDepthFormat(r,e))throw Error("TextureFormat is not supported:"+n_[r]+" in RenderTarget");if(n.length>1&&!e.canIUse(nT.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 l0(e,nP)}))throw Error("MRT+Cube+[,MSAA] is not supported");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=l0(o,nP);(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=l0(l,nP);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=l7._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;n.width,n.height;var a=Array(i);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var o=0;o<i;o++){var s=this._target.getColorTexture(o),l=e.COLOR_ATTACHMENT0+o;a[o]=l,l0(s,nP)||e.framebufferTexture2D(e.FRAMEBUFFER,l,e.TEXTURE_2D,s._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(a),this._oriDrawBuffers=a,null!==r){if(l0(r,nE)&&!l0(r,nP)){var c=r._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,c._formatDetail.attachment,e.TEXTURE_2D,c._glTexture,0)}else if(this._target.antiAliasing<=1){var u=l7._getRenderBufferDepthFormatDetail(r,e,t),d=u.internalFormat,h=u.attachment;this._depthRenderBuffer=this._createRenderBuffer(d,h)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,n=this._target,r=n._depth,i=n.colorTextureCount;this._blitDrawBuffers=Array(i),e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var a=0;a<i;a++){this._blitDrawBuffers[a]=e.NONE;var o=this._target.getColorTexture(a)._platformTexture._formatDetail.internalFormat;this._MSAAColorRenderBuffers[a]=this._createRenderBuffer(o,e.COLOR_ATTACHMENT0+a)}if(e.drawBuffers(this._oriDrawBuffers),null!==r){var s=l0(r,nE)?r._platformTexture._formatDetail:l7._getRenderBufferDepthFormatDetail(r,e,t),l=s.internalFormat,c=s.attachment;this._MSAADepthRenderBuffer=this._createRenderBuffer(l,c)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._createRenderBuffer=function(e,t){var n=this._gl,r=this._target,i=r.width,a=r.height,o=r.antiAliasing,s=n.createRenderbuffer();return n.bindRenderbuffer(n.RENDERBUFFER,s),o>1?n.renderbufferStorageMultisample(n.RENDERBUFFER,o,e,i,a):n.renderbufferStorage(n.RENDERBUFFER,e,i,a),n.framebufferRenderbuffer(n.FRAMEBUFFER,t,n.RENDERBUFFER,s),s},t._checkFrameBuffer=function(){var e=this._gl;switch(e.checkFramebufferStatus(e.FRAMEBUFFER)){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:if(!e.isContextLost())throw Error("The format of the attachment is not supported or if depth and stencil attachments are not the same renderbuffer");break;case 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}(),ct=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0,r._validate(n,t);var r,i=n.format,a=n.isSRGBColorSpace,o=r._isWebGL2;return r._formatDetail=l7._getFormatDetail(i,a,r._gl,o),r._formatDetail.isCompressed&&!o||r._init(!1),r}l$(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._formatDetail,l=Math.max(1,this._texture.width>>t),c=Math.max(1,this._texture.height>>t);if(i=i||l-n,a=a||c-r,this._bind(),s.isCompressed){var u=this._isWebGL2,d=s.internalFormat,h=1<<t;u||this._compressedMipFilled&h?o.compressedTexSubImage2D(this._target,t,n,r,i,a,d,e):(o.compressedTexImage2D(this._target,t,d,i,a,0,e),this._compressedMipFilled|=h)}else{var _=s.baseFormat,f=s.dataType;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),o.pixelStorei(o.UNPACK_ALIGNMENT,s.alignment),o.texSubImage2D(this._target,t,n,r,i,a,_,f,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===nf.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}(l7),cn=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_2D_ARRAY)||this)._validate(n,t);var r,i=n.format,a=n.width,o=n.height,s=n.length,l=n.mipmapCount,c=n.isSRGBColorSpace;return r._bind(),r._formatDetail=l7._getFormatDetail(i,c,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r}l$(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(),f?c.compressedTexSubImage3D(l,n,r,i,e,a,o,s,d,t):(c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),c.pixelStorei(c.UNPACK_ALIGNMENT,u.alignment),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.pixelStorei(s.PACK_ALIGNMENT,l.alignment),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)},n._validate=function(e,t){var n=e.format;e._isSRGBColorSpace&&!nM.supportSRGB(n)&&(nb.warn("Only support sRGB color space in RGB8 or RGBA8 or some compressed texture format"),e._isSRGBColorSpace=!1)},t}(l7),cr=/*#__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],r._validate(n,t);var r,i=n.format,a=n.isSRGBColorSpace,o=r._isWebGL2;return r._formatDetail=l7._getFormatDetail(i,a,r._gl,o),r._formatDetail.isCompressed&&!o||r._init(!0),r}l$(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(),_){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.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),s.pixelStorei(s.UNPACK_ALIGNMENT,c.alignment),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}(l7),ci=/*#__PURE__*/function(){function e(e){var t=e.gl;this._gl=t,this._glTransformFeedback=t.createTransformFeedback()}var t=e.prototype;return t.bindBufferRange=function(e,t,n,r){var i=this._gl;i.bindBufferRange(i.TRANSFORM_FEEDBACK_BUFFER,e,t._glBuffer,n,r)},t.unbindBuffer=function(e){var t=this._gl;t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,e,null)},t.begin=function(e){this._gl.beginTransformFeedback(e)},t.end=function(){this._gl.endTransformFeedback()},t.bind=function(){var e=this._gl;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,this._glTransformFeedback)},t.unbind=function(){var e=this._gl;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)},t.destroy=function(){this._glTransformFeedback&&(this._gl.deleteTransformFeedback(this._glTransformFeedback),this._glTransformFeedback=null)},e}();function ca(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}var co=/*#__PURE__*/function(){function e(e){this._lastProgramId=-1,this._gl=e}var t=e.prototype;return t.updateVertexLayout=function(e,t,n,r,i,a){if(e.id!==this._lastProgramId){this._deleteVAOs();var o=e.attributeLocation;this._vaoA=this._createVAO(o,t,r,i,a),this._vaoB=this._createVAO(o,n,r,i,a),this._lastProgramId=e.id,this._gl.bindVertexArray(null)}},t.bind=function(e){this._gl.bindVertexArray(e?this._vaoA:this._vaoB)},t.unbind=function(){this._gl.bindVertexArray(null)},t.draw=function(e,t,n){this._gl.drawArrays(e,t,n)},t.invalidate=function(){this._deleteVAOs()},t.destroy=function(){this._deleteVAOs()},t._deleteVAOs=function(){var e=this._gl;this._vaoA&&(e.deleteVertexArray(this._vaoA),this._vaoA=null),this._vaoB&&(e.deleteVertexArray(this._vaoB),this._vaoB=null),this._lastProgramId=-1},t._createVAO=function(e,t,n,r,i){var a=this._gl,o=a.createVertexArray();return a.bindVertexArray(o),a.bindBuffer(a.ARRAY_BUFFER,t.buffer._platformBuffer._glBuffer),this._bindElements(a,e,n,t.stride),a.bindBuffer(a.ARRAY_BUFFER,r.buffer._platformBuffer._glBuffer),this._bindElements(a,e,i,r.stride),a.bindBuffer(a.ARRAY_BUFFER,null),o},t._bindElements=function(e,t,n,r){for(var i,a=function(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 ca(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 ca(e,void 0)}}(e))){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.")}(n);!(i=a()).done;){var o=i.value,s=t[o.attribute];if(void 0!==s&&-1!==s){var l=o._formatMetaInfo;e.enableVertexAttribArray(s),e.vertexAttribPointer(s,l.size,l.type,l.normalized,r,o.offset)}}},e}(),cs=((e7={})[e7.Auto=0]="Auto",e7[e7.WebGL2=1]="WebGL2",e7[e7.WebGL1=2]="WebGL1",e7),cl=/*#__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 tZ(null,null,null,null),this._lastScissor=new tZ(null,null,null,null),this._lastClearColor=new tJ(null,null,null,null),this._scissorEnable=!1;var t=l3({webGLMode:0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256,alpha:!0,depth:!0,stencil:!0,failIfMajorPerformanceCaveat:!1,powerPreference:"default",premultipliedAlpha:!0,preserveDrawingBuffer:!1,desynchronized:!1,xrCompatible:!1},e);if(nR.platform===t2.IPhone||nR.platform===t2.IPad){var n=nR.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._webGLOptions={antialias:!1,depth:!1,stencil:!1,alpha:t.alpha,failIfMajorPerformanceCaveat:t.failIfMajorPerformanceCaveat,powerPreference:t.powerPreference,premultipliedAlpha:t.premultipliedAlpha,preserveDrawingBuffer:t.preserveDrawingBuffer,desynchronized:t.desynchronized,xrCompatible:t.xrCompatible},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=e._webCanvas,a=this._options.webGLMode;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;var o=this._webGLOptions;if((0==a||1==a)&&((r=i.getContext("webgl2",o))||"undefined"!=typeof OffscreenCanvas&&l0(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl2",o)),this._isWebGL2=!0,r&&!r.deleteQuery&&(this._isWebGL2=!1)),r||0!=a&&2!=a||((r=i.getContext("webgl",o))||"undefined"!=typeof OffscreenCanvas&&l0(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl",o)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},t.createPlatformPrimitive=function(e){return new l9(this,e)},t.createPlatformTexture2D=function(e){return new ct(this,e)},t.createPlatformTexture2DArray=function(e){return new cn(this,e)},t.createPlatformTextureCube=function(e){return new cr(this,e)},t.createPlatformRenderTarget=function(e){return new ce(this,e)},t.createPlatformBuffer=function(e,t,n,r){return void 0===n&&(n=av.Static),new l4(this,e,t,n,r)},t.createPlatformTransformFeedback=function(){return new ci(this)},t.createPlatformTransformFeedbackPrimitive=function(){return new co(this._gl)},t.enableRasterizerDiscard=function(){if(this._isWebGL2){var e=this._gl;e.enable(e.RASTERIZER_DISCARD)}},t.disableRasterizerDiscard=function(){if(this._isWebGL2){var e=this._gl;e.disable(e.RASTERIZER_DISCARD)}},t.invalidateShaderProgramState=function(){this._currentBindShaderProgram&&(this._gl.useProgram(null),this._currentBindShaderProgram=null)},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&rj.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!==re.All&&(r.colorMask(!0,!0,!0,!0),a.colorWriteMask=re.All)}t&rj.Depth&&(l|=r.DEPTH_BUFFER_BIT,!0!==o.writeEnabled&&(r.depthMask(!0),o.writeEnabled=!0)),t&rj.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):nb.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){nb.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&rj.Color)==0,p=(n&rj.Depth)==0,m=(n&rj.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===n_.Depth||v>=n_.DepthStencil&&v<=n_.Depth32Stencil8?g|=i.DEPTH_BUFFER_BIT:nb.warn("Do not clear depth, or set depth format of target which is "+n_[v]+" now.")),m&&(v===n_.Stencil||v===n_.DepthStencil||v>=n_.Depth24Stencil8||v>=n_.Depth32Stencil8?g|=i.STENCIL_BUFFER_BIT:nb.warn("Do not clear stencil, or set stencil format of target which is "+n_[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:this._mainFrameBuffer;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(nT.WEBGL_lose_context).loseContext()},t.forceRestoreDevice=function(){this.requireExtension(nT.WEBGL_lose_context).restoreContext()},t.isContextLost=function(){return this.gl.isContextLost()},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 l6(e),this._extensions=new l5(this),this._capability=new l8(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()},lZ(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 cc(){return(cc=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 cu(e,t){return(cu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cd(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&&cu(e,t)}function ch(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function c_(e,n,r,i){var a,o=arguments.length,s=o<3?n:null===i?i=Object.getOwnPropertyDescriptor(n,r):i;if(("undefined"==typeof Reflect?"undefined":t(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,n,r,i);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(s=(o<3?a(s):o>3?a(n,r,s):a(n,r))||s);return o>3&&s&&Object.defineProperty(n,r,s),s}function cf(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 cp(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 cm(e,t,n){return t&&cp(e.prototype,t),n&&cp(e,n),e}"function"==typeof SuppressedError&&SuppressedError;var cg=/*#__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,nX.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)},cm(e,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),e}(),cv={};function cy(e){return function(t){cv[e]=t}}var cx=/*#__PURE__*/function(){function e(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}return e.checkMagic=function(t){return!(t.byteLength<4)&&new DataView(t).getUint32(0,!0)===e.MAGIC},e.decode=function(t){var n=new DataView(t);if(!e.checkMagic(t))throw Error("Invalid Galacean binary file: missing GLCN magic header.");var r=n.getUint32(4,!0),i=n.getUint8(8),a=n.getUint16(9,!0),o=new Uint8Array(t,11,a),s=n.getUint16(11+a,!0),l=new Uint8Array(t,13+a,s),c=nX.decodeText(l),u=nX.decodeText(o),d=new e;d.totalLength=r,d.name=c,d.type=u,d.version=i;var h=4+l.byteLength+o.byteLength+9;return d.headerLength=h+3&-4,d},cm(e,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),e}();cx.MAGIC=0x4e434c47;var cA=((te={})[te.Float=0]="Float",te[te.FloatArray=1]="FloatArray",te[te.Vector2=2]="Vector2",te[te.Vector3=3]="Vector3",te[te.Vector4=4]="Vector4",te[te.Quaternion=5]="Quaternion",te[te.Color=6]="Color",te[te.Array=7]="Array",te[te.Boolean=8]="Boolean",te[te.Rect=9]="Rect",te[te.ReferResource=10]="ReferResource",te),cb=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new nS(function(e){for(var n=new sp(t.nextStr()),r=t.nextUint16(),i=0;i<r;++i){var a=new sf;a.time=t.nextFloat32(),a.functionName=t.nextStr(),a.parameter=JSON.parse(t.nextStr()).val,n.addEvent(a)}for(var o=t.nextUint16(),s=0;s<o;++s){var l=t.nextStr(),c=t.nextStr(),u=sn.getClass(c),d=t.nextStr(),h=t.nextStr(),_=void 0,f=t.nextUint8(),p=t.nextUint16();switch(t.nextStr()){case"AnimationFloatCurve":(_=new sb).interpolation=f;for(var m=0;m<p;++m){var g=new sq;g.time=t.nextFloat32(),g.value=t.nextFloat32(),g.inTangent=t.nextFloat32(),g.outTangent=t.nextFloat32(),_.addKey(g)}break;case"AnimationArrayCurve":(_=new sv).interpolation=f;for(var v=0;v<p;++v){var y=new sq;y.time=t.nextFloat32();var x=t.nextUint16();y.value=Array.from(t.nextFloat32Array(x)),y.inTangent=Array.from(t.nextFloat32Array(x)),y.outTangent=Array.from(t.nextFloat32Array(x)),_.addKey(y)}break;case"AnimationFloatArrayCurve":(_=new sA).interpolation=f;for(var A=0;A<p;++A){var b=new sq;b.time=t.nextFloat32();var S=t.nextUint16();b.value=t.nextFloat32Array(S),b.inTangent=Array.from(t.nextFloat32Array(S)),b.outTangent=Array.from(t.nextFloat32Array(S)),_.addKey(b)}break;case"AnimationVector2Curve":(_=new sC).interpolation=f;for(var C=0;C<p;++C){var T=new sq;T.time=t.nextFloat32(),T.value=new tq(t.nextFloat32(),t.nextFloat32()),T.inTangent=new tq(t.nextFloat32(),t.nextFloat32()),T.outTangent=new tq(t.nextFloat32(),t.nextFloat32()),_.addKey(T)}break;case"AnimationVector3Curve":(_=new sT).interpolation=f;for(var R=0;R<p;++R){var E=new sq;E.time=t.nextFloat32(),E.value=new tU(t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),E.inTangent=new tU(t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),E.outTangent=new tU(t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(E)}break;case"AnimationVector4Curve":(_=new sR).interpolation=f;var M=new sq;M.time=t.nextFloat32(),M.value=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),M.inTangent=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),M.outTangent=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(M);break;case"AnimationColorCurve":(_=new sx).interpolation=f;for(var P=0;P<p;++P){var w=new sq;w.time=t.nextFloat32(),w.value=new tJ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),w.inTangent=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),w.outTangent=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(w)}break;case"AnimationQuaternionCurve":(_=new sS).interpolation=f;for(var F=0;F<p;++F){var L=new sq;L.time=t.nextFloat32(),L.value=new tY(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),L.inTangent=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),L.outTangent=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(L)}break;case"AnimationRefCurve":(_=new sE).interpolation=f;for(var D=0;D<p;++D){var B=new sq;B.time=t.nextFloat32();var I=t.nextStr();I?B.value=JSON.parse(I):B.value=null,_.addKey(B)}break;case"AnimationBoolCurve":(_=new sy).interpolation=f;for(var N=0;N<p;++N){var O=new sq;O.time=t.nextFloat32(),O.value=1===t.nextUint8(),_.addKey(O)}break;case"AnimationStringCurve":(_=new sP).interpolation=f;for(var V=0;V<p;++V){var k=new sq;k.time=t.nextFloat32(),k.value=t.nextStr(),_.addKey(k)}}n.addCurveBinding(l,u,d,h,_)}e(n)})},e}();cb=c_([cy("AnimationClip")],cb);var cS=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t,n){return new nS(function(r){var i=n||new aG(e),a=JSON.parse(t.nextStr());a.bounds&&i.bounds.copyFrom(a.bounds);var o=4*Math.ceil(t.offset/4)+t.data.byteOffset,s=t.data.buffer,l=new Float32Array(s,a.positions.start+o,(a.positions.end-a.positions.start)/4),c=l.length/3,u=cT(l,c);if(i.setPositions(u),a.normals){var d=cT(new Float32Array(s,a.normals.start+o,(a.normals.end-a.normals.start)/4),c);i.setNormals(d)}if(a.uvs){var h=new Float32Array(s,a.uvs.start+o,(a.uvs.end-a.uvs.start)/4);i.setUVs(cR(h,c))}if(a.uv1){var _=new Float32Array(s,a.uv1.start+o,(a.uv1.end-a.uv1.start)/4);i.setUVs(cR(_,c),1)}if(a.uv2){var f=new Float32Array(s,a.uv2.start+o,(a.uv2.end-a.uv2.start)/4);i.setUVs(cR(f,c),2)}if(a.uv3){var p=new Float32Array(s,a.uv3.start+o,(a.uv3.end-a.uv3.start)/4);i.setUVs(cR(p,c),3)}if(a.uv4){var m=new Float32Array(s,a.uv4.start+o,(a.uv4.end-a.uv4.start)/4);i.setUVs(cR(m,c),4)}if(a.uv5){var g=new Float32Array(s,a.uv5.start+o,(a.uv5.end-a.uv5.start)/4);i.setUVs(cR(g,c),5)}if(a.uv6){var v=new Float32Array(s,a.uv6.start+o,(a.uv6.end-a.uv6.start)/4);i.setUVs(cR(v,c),6)}if(a.uv7){var y=new Float32Array(s,a.uv7.start+o,(a.uv7.end-a.uv7.start)/4);i.setUVs(cR(y,c),7)}if(a.colors){var x=new Float32Array(s,a.colors.start+o,(a.colors.end-a.colors.start)/4);i.setColors(function(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tJ(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}(x,c))}if(a.boneWeights){var A=new Float32Array(s,a.boneWeights.start+o,(a.boneWeights.end-a.boneWeights.start)/4);i.setBoneWeights(cC(A,c))}if(a.boneIndices){var b=new Float32Array(s,a.boneIndices.start+o,(a.boneIndices.end-a.boneIndices.start)/4);i.setBoneIndices(cC(b,c))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new aw(e.name);e.frames.forEach(function(e){var n=new Float32Array(s,e.deltaPosition.start+o,(e.deltaPosition.end-e.deltaPosition.start)/4),r=n.length/3,i=cT(n,r);e.deltaNormals&&cT(new Float32Array(s,e.deltaNormals.start+o,(e.deltaNormals.end-e.deltaNormals.start)/4),r),e.deltaTangents&&cC(new Float32Array(s,e.deltaTangents.start+o,(e.deltaTangents.end-e.deltaTangents.start)/4),r),t.addFrame(e.weight,i)}),i.addBlendShape(t)}),a.indices){var S=null;S=0===a.indices.type?new Uint16Array(s,a.indices.start+o,(a.indices.end-a.indices.start)/2):new Uint32Array(s,a.indices.start+o,(a.indices.end-a.indices.start)/4),i.setIndices(S)}a.subMeshes.forEach(function(e){return i.addSubMesh(e)}),i.uploadData(!1),r(i)})},e}();function cC(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tZ(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function cT(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tU(e[3*r],e[3*r+1],e[3*r+2]);return n}function cR(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tq(e[2*r],e[2*r+1]);return n}function cE(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(cE=function(){return!!e})()}function cM(e,t,n){return(cM=cE()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&cu(i,n.prototype),i}).apply(null,arguments)}cS=c_([cy("Mesh")],cS);var cP=((tt={})[tt.Prefab=0]="Prefab",tt[tt.Scene=1]="Scene",tt),cw=/*#__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.componentConfigMap=new Map,this.rootIds=[],this.strippedIds=[],this._tasks=new Set,this._loaded=0,this._total=0,this.resourceManager=e.resourceManager}var t=e.prototype;return t.clear=function(){this.entityMap.clear(),this.components.clear(),this.componentConfigMap.clear(),this.entityConfigMap.clear(),this.rootIds.length=0,this.strippedIds.length=0},t._addDependentAsset=function(e,t){var n=this,r=this._tasks;r.has(e)||(++this._total,r.add(e),t.finally(function(){++n._loaded,n._setTaskCompleteProgress(n._loaded,n._total)}))},e}(),cF=/*#__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=n.transform,o=e.transform;if(o)t.parsePropsAndMethods(a,o);else{var s=e.position,l=e.rotation,c=e.scale;s&&a.position.copyFrom(s),l&&a.rotation.copyFrom(l),c&&a.scale.copyFrom(c)}return n.layer=null!=(i=e.layer)?i:n.layer,t._context.type===cP.Prefab&&n._markAsTemplate(t._context.resource),n})},t.parseClassObject=function(e){var t,n=this,r=sn.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return n.parseBasicType(e)})).then(function(e){return cM(r,[].concat(e))}).then(function(t){return n.parsePropsAndMethods(t,e)})},t.parsePropsAndMethods=function(e,t){var n=[];if(t.methods)for(var r in t.methods)for(var i=t.methods[r],a=0,o=i.length;a<o;a++)n.push(this.parseMethod(e,r,i[a]));if(t.props){var s,l=function(r){var i=t.props[r],a=s.parseBasicType(i,e[r]).then(function(t){return e[r]=t});n.push(a)};for(var c in t.props)s=this,l(c)}return Promise.all(n).then(function(){return e})},t.parseMethod=function(t,n,r){var i=this,a=e._isMethodObject(r);return Promise.all((a?r.params:r).map(function(e){return i.parseBasicType(e)})).then(function(e){var o=t[n].apply(t,[].concat(e));return a&&r.result?i.parsePropsAndMethods(o,r.result):o})},t.parseSignal=function(e){var t=this,n=new st;return Promise.all(e.listeners.map(function(e){return Promise.all([t.parseBasicType(e.target),e.arguments?Promise.all(e.arguments.map(function(e){return t.parseBasicType(e)})):Promise.resolve([])]).then(function(t){var r=t[0],i=t[1];r&&n.on.apply(n,[].concat([r,e.methodName],i))})})).then(function(){return 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":ch(t))==="object"&&null!=t){if(e._isClassType(t))return Promise.resolve(sn.getClass(t.classType));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 e&&i.type===cP.Prefab&&i.resource._addDependenceAsset(e),e})}if(e._isComponentRef(t)){var a,o=this._resolveEntityByPath(t.entityPath);if(!o)return Promise.resolve(null);var s=sn.getClass(t.componentType);return s?Promise.resolve(null!=(a=o.getComponents(s,[])[t.componentIndex])?a:null):Promise.resolve(null)}else if(e._isEntityRef(t))return Promise.resolve(this._resolveEntityByPath(t.entityPath));else if(e._isSignalRef(t))return this.parseSignal(t);else if(n){var l,c=function(e){if("methods"===e){var r=t[e];for(var i in r)for(var a=r[i],o=0,s=a.length;o<s;o++){var c=a[o];u.push(l.parseMethod(n,i,c))}}else u.push(l.parseBasicType(t[e],n[e]).then(function(t){return n[e]=t}))},u=[];for(var d in t)l=this,c(d);return Promise.all(u).then(function(){return n})}}return Promise.resolve(t)},t._getEntityByConfig=function(e){var t=this,n=e.assetUrl,r=this._context.engine;if(n)return r.resourceManager.getResourceByRef({url:n,key:e.key,isClone:e.isClone}).then(function(i){var a=r.resourceManager._objectPool[n];return a&&t._context.type===cP.Prefab&&t._context.resource._addDependenceAsset(a),i.name=e.name,i});var i=e.transform;return Promise.resolve(new a7(r,e.name,i?sn.getClass(i.class):rG))},t._resolveEntityByPath=function(e){var t=this._context,n=t.rootIds,r=t.entityMap;if(!e.length||e[0]>=n.length)return null;for(var i=r.get(n[e[0]]),a=1;a<e.length;a++){if(!i||e[a]>=i.children.length)return null;i=i.children[e[a]]}return i},e._isClass=function(e){return void 0!==e.class},e._isClassType=function(e){return void 0!==e.classType},e._isAssetRef=function(e){return void 0!==e.url},e._isEntityRef=function(e){return Array.isArray(e.entityPath)&&void 0===e.componentType},e._isComponentRef=function(e){return Array.isArray(e.entityPath)&&void 0!==e.componentType},e._isSignalRef=function(e){return void 0!==e.listeners},e._isMethodObject=function(e){return Array.isArray(null==e?void 0:e.params)},e}(),cL=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t,n){return new nS(function(r,i){var a=t.nextStr(),o=!!t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint8(),h=t.nextUint16(),_=t.nextUint16(),f=t.nextUint8(),p=!!t.nextUint8(),m=t.nextUint8(),g=t.nextImagesData(m),v=n||new nF(e,h,_,d,o,p);if(v.filterMode=s,v.anisoLevel=l,v.wrapModeU=c,v.wrapModeV=u,f){var y=g[0];if(v.setPixelBuffer(y),o){v.generateMipmaps();for(var x=1;x<m;x++){var A=g[x];v.setPixelBuffer(A,x)}}e.resourceManager._objectPool[a]=v,r(v)}else{var b=new window.Blob([g[0]]),S=new Image;S.onload=function(){v.setImageSource(S);var e=0,t=function(){++e>=m&&r(v)};if(t(),o){var n=function(e){var n=new window.Blob([g[e]]),r=new Image;r.onload=function(){v.setImageSource(r,e),t()},r.src=URL.createObjectURL(n)};v.generateMipmaps();for(var i=1;i<m;i++)n(i)}},S.src=URL.createObjectURL(b)}})},e}();function cD(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):e(t,n)}function cB(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 cI(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 cB(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 cB(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.")}cL=c_([cy("Texture2D")],cL);var cN=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r._dependenceAssets=new Set,r}cd(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),cD(e,ns)&&e._associationSuperResource(this)},n._onDestroy=function(){var t=this;e.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(e){cD(e,ns)&&e._disassociationSuperResource(t)})},t}(ns),cO=/*#__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._parseAddedComponents=this._parseAddedComponents.bind(this),this._parseComponentsPropsAndMethods=this._parseComponentsPropsAndMethods.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 cF(t)}var t=e.prototype;return t.start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parseAddedComponents).then(this._parseComponentsPropsAndMethods).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},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=e.transform,a=t.transform;if(a)this._reflectionParser.parsePropsAndMethods(i,a);else{var o=t.position,s=t.rotation,l=t.scale;o&&i.position.copyFrom(o),s&&i.rotation.copyFrom(s),l&&i.scale.copyFrom(l)}return t.layer&&(e.layer=t.layer),e},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(n){for(var i=0,a=n.length;i<a;i++)r.set(t[i].id,n[i]);for(var o=e.context.rootIds,s=0,l=t.length;s<l;s++)t[s].parent||t[s].strippedId||o.push(t[s].id);return n})},t._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,n=0,r=e.length;n<r;n++){var i=e[n];if(!i.strippedId){var a=t.get(i.id);this._addComponents(a,i.components)}}},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._parseAddedComponents=function(){for(var e=this.context.entityMap,t=this.context.entityConfigMap,n=this.context.strippedIds,r=0,i=n.length;r<i;r++){var a=t.get(n[r]),o=this._prefabContextMap.get(e.get(a.prefabInstanceId)).entityMap.get(a.prefabSource.entityId);this._addComponents(o,a.components)}},t._parsePrefabRemovedEntities=function(){for(var e=this.data.entities,t=this.context.entityMap,n=0,r=e.length;n<r;n++){var i=e[n],a=i.id,o=i.removedEntities;if(null==o?void 0:o.length)for(var s=t.get(a),l=0,c=o.length;l<c;l++){var u=o[l].entityId,d=this._prefabContextMap.get(s).entityMap.get(u);d&&d.destroy()}}},t._parsePrefabRemovedComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,n=this._prefabContextMap,r=0,i=e.length;r<i;r++){var a=e[r],o=a.id,s=a.removedComponents;if(null==s?void 0:s.length)for(var l=t.get(o),c=0,u=s.length;c<u;c++){var d=s[c].componentId,h=n.get(l).components.get(d);h&&h.destroy()}}},t._organizeEntities=function(){for(var e=this.context,t=e.rootIds,n=e.strippedIds,r=t.concat(n),i=0,a=r.length;i<a;i++)this._parseChildren(r[i]);for(var o=0;o<t.length;o++)this._handleRootEntity(t[o])},t._getEntityByConfig=function(e,t){var n=this;return(e.assetUrl?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=e.transform,r=new a7(t,e.name,n?sn.getClass(n.class):rG);return this._addEntityPlugin(e.id,r),Promise.resolve(r)},t._parsePrefab=function(e,t){var n=this,r=e.assetUrl;return t.resourceManager.getResourceByRef({url:r}).then(function(r){var i=cD(r,cN)?r.instantiate():r.instantiateSceneRoot(),a=new cw(t,cP.Prefab,null);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._addComponents=function(e,t){for(var n=this.context,r=n.components,i=n.componentConfigMap,a=0,o=t.length;a<o;a++){var s=t[a],l=s.url?s.url:s.class,c=s.id,u=e.addComponent(sn.getClass(l));r.set(c,u),i.set(c,s),this._addComponentPlugin(c,u)}},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=sn.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)}},t._parseComponentsPropsAndMethods=function(){for(var e,t=this.context,n=t.componentConfigMap,r=this._reflectionParser,i=[],a=cI(t.components);!(e=a()).done;){var o=e.value,s=o[0],l=o[1],c=n.get(s);c&&i.push(r.parsePropsAndMethods(l,c))}return Promise.all(i)},t._addComponentPlugin=function(e,t){},t._addEntityPlugin=function(e,t){},e}(),cV=((tn={}).Vector2="Vector2",tn.Vector3="Vector3",tn.Vector4="Vector4",tn.Color="Color",tn.Float="Float",tn.Texture="Texture",tn.Boolean="Boolean",tn.Integer="Integer",tn),ck=((tr={}).Sky="Sky",tr.Custom="Custom",tr),cU=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t,n)||this).scene=r,i}cd(t,e);var n=t.prototype;return n._collectDependentAssets=function(e){var t=this.context,n=t.resourceManager;this._parseDependentAssets(e);var r=e.scene,i=r.ambient;if(i){var a=i.specularMode===ck.Custom,o=i.diffuseMode===o$.SphericalHarmonics,s=i.customAmbientLight,l=i.ambientLight;a&&s&&t._addDependentAsset(s.url,n.getResourceByRef(s)),l&&(!a||o)&&t._addDependentAsset(l.url,n.getResourceByRef(l))}var c=r.background,u=c.mode;if(u===n5.Texture){var d=c.texture;d&&t._addDependentAsset(d.url,n.getResourceByRef(d))}else if(u===n5.Sky){var h=c.skyMesh,_=c.skyMaterial;h&&_&&(t._addDependentAsset(h.url,n.getResourceByRef(h)),t._addDependentAsset(_.url,n.getResourceByRef(_)))}},n._handleRootEntity=function(e){var t=this.context.entityMap;this.scene.addRootEntity(t.get(e))},n._clearAndResolve=function(){return this.context.clear(),this.scene},n._parseDependentAssets=function(e){for(var t=e.entities,n=0,r=t.length;n<r;n++){var i=t[n];if(i.assetUrl){var a=this.context,o=i.assetUrl,s=i.key;a._addDependentAsset(o,a.resourceManager.getResourceByRef({url:o,key:s}))}else{if(i.strippedId)continue;for(var l=i.components,c=0,u=l.length;c<u;c++){var d=l[c];this._searchDependentAssets(d.methods),this._searchDependentAssets(d.props)}}}},n._searchDependentAssets=function(e){if(Array.isArray(e))for(var t=0,n=e.length;t<n;t++)this._searchDependentAssets(e[t]);else if(e&&(void 0===e?"undefined":ch(e))==="object"){if(cF._isAssetRef(e)){var r=this.context;r._addDependentAsset(e.url,r.resourceManager.getResourceByRef(e))}else for(var i in e)this._searchDependentAssets(e[i])}},t}(cO);function cz(e,t){for(var n,r=arguments.length,i=Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];var o=cx.decode(e),s=new cg(new Uint8Array(e),o.headerLength,o.dataLength);return(n=cv[o.type]).decode.apply(n,[].concat([t,s],i)).then(function(e){return e.name=o.name,e})}var cG=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nS(function(r,i){t._request(e.url,cc({},e,{type:"arraybuffer"})).then(function(e){return cz(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":ch(n))==="object"&&(null==n?void 0:n.url)?new Promise(function(r){t.getResourceByRef(n).then(function(t){e.value=t,r(e.value)})}):Promise.resolve(e.value)},t}(sn);cG=c_([og(ol.AnimationClip,["anim"])],cG);var cH=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nS(function(r,i){t._request(e.url,cc({},e,{type:"json"})).then(function(e){var i=new sW(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 sQ(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(sn.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 sO;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}(sn);cH=c_([og(ol.AnimatorController,["animCtrl"])],cH);var cW=/^data:(.+?);base64,/,cX=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=e.url,r=cW.exec(n),i=r?Promise.resolve(Uint8Array.from(atob(n.slice(13+r[1].length)),function(e){return e.charCodeAt(0)}).buffer):t._request(n,cc({},e,{type:"arraybuffer"}));return nS.resolve(i).then(function(e){var n=new sa(t.engine);return n.buffer=e,n})},t}(sn);cX=c_([og(ol.Buffer,["bin"])],cX);var cj=((ti={})[ti.linear=1]="linear",ti[ti.sRGB=2]="sRGB",ti),cY=((ta={})[ta.ETC1S=163]="ETC1S",ta[ta.UASTC_LDR_4X4=166]="UASTC_LDR_4X4",ta[ta.UASTC_HDR_4X4=167]="UASTC_HDR_4X4",ta),cK=/*#__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 cg(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 cg(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 cg(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 cg(e,s,l,!0);x.position<l;){var A=x.nextUint32(),b=x.scan(A),S=nX.decodeText(b),C=x.nextUint8Array(A-b.byteLength-1);this.keyValue[S]=S.match(/^ktx/i)?nX.decodeText(C).replace(/^(.*)\x00$/,"$1"):C;var T=A%4?4-A%4:0;x.skip(T)}if(u<=0)return this;for(var R=new cg(e,c,u,!0),E=R.nextUint16(),M=R.nextUint16(),P=R.nextUint32(),w=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,N=I+P,O=N+w,V=O+F,k=new Uint8Array(t,n+I,P),U=new Uint8Array(t,n+N,w),z=new Uint8Array(t,n+O,F),G=new Uint8Array(t,n+V,L);this.globalData={endpointCount:E,selectorCount:M,imageDescs:D,endpointsData:k,selectorsData:U,tablesData:z,extendedData:G}},e.checkMagic=function(e,t){if(void 0===t&&(t=0),e.byteLength<t+4)return!1;var n=new Uint8Array(e,t,4);return 171===n[0]&&75===n[1]&&84===n[2]&&88===n[3]},cm(e,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"colorModel",get:function(){return this.dataFormatDescriptor.colorModel}}]),e}(),cQ=((to={})[to.ASTC=0]="ASTC",to[to.BC7=1]="BC7",to[to.BC1_BC3=2]="BC1_BC3",to[to.PVRTC=3]="PVRTC",to[to.ETC=4]="ETC",to[to.R8=5]="R8",to[to.R8G8=6]="R8G8",to[to.R8G8B8A8=7]="R8G8B8A8",to[to.BC6H=8]="BC6H",to[to.ASTC_HDR_4x4=9]="ASTC_HDR_4x4",to[to.R16G16B16A16=10]="R16G16B16A16",to),cq=/*#__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}(),cZ=/*#__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 cq(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 cJ(){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=c0(n.buffer,n.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var c$=function(e){return ts||(ts=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})),ts};function c0(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;case 8:return 22;case 9:return 23;case 10:return 25}}(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 A=r.getImageLevelInfo(m,x,f);_&&0===m&&(a!==A.width||o!==A.height)?console.warn("KTX2 transcode to BC will resize to width: "+(a=v=A.width)+", height: "+(o=y=A.height)+". You'd better use an image whose size if multiple of 4."):(v=A.origWidth,y=A.origHeight);var b=new Uint8Array(r.getImageTranscodedSizeInBytes(m,x,0,d)),S=r.transcodeImage(b,m,x,f,d,0,-1,-1);if(10===t&&(b=new Uint16Array(b.buffer,b.byteOffset,b.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!S)throw i(),Error("transcodeImage failed.");g[x]=b}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 c1=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}cd(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*J8IrSL8WE8EAAAAAQ6AAAAgAehQnAQ/basis_transcoder.js").then(function(e){return e.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*F3duSLqOP2sAAAAAXjAAAAgAehQnAQ/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(){c$(r).then(function(){e(null)})},i.onerror=function(){t()}});var i=cJ.toString(),a=i.substring(i.indexOf("{"),i.lastIndexOf("}")+1),o="\n "+n+"\n "+c0.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?c$().then(function(n){return c0(e,t,n)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},t}(cZ),c2=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(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),t._getBinomialLLCTranscoder(r.workerCount).init()}},n.load=function(e,n){return new nS(function(r,i,a,o){var s=cc({},e,{type:"arraybuffer"}),l=e.url;n._request(l,s).onProgress(a,o).then(function(i){return t._parseBuffer(new Uint8Array(i),n.engine,e.params).then(function(e){var n=e.ktx2Container,r=e.engine,i=e.result,a=e.targetFormat,o=e.params;return t._createTextureByBuffer(r,n.isSRGB,i,a,o)}).then(function(e){n.addContentRestorer(new c3(e,l,s)),r(e)})}).catch(i)})},t.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._binomialLLCTranscoder=null},t._parseBuffer=function(e,n,r){var i,a=new cK(e),o=null!=(i=null==r?void 0:r.priorityFormats)?i:t._priorityFormats[a.colorModel],s=t._decideTargetFormat(n,a,o),l=t._getBinomialLLCTranscoder();return l.init().then(function(){return l.transcode(e,s)}).then(function(e){return{ktx2Container:a,engine:n,result:e,targetFormat:s,params:a.keyValue.GalaceanTextureParams}})},t._createTextureByBuffer=function(e,t,n,r,i,a){var o,s=n.width,l=n.height,c=n.faces,u=c.length,d=c[0],h=d.length>1,_=this._getEngineTextureFormat(r,n);if(6!==u){o=a||new nF(e,s,l,_,h,t);for(var f=0;f<d.length;f++){var p=d[f].data;o.setPixelBuffer(p,f)}}else{o=a||new nP(e,l,_,h,t);for(var m=0;m<c.length;m++)for(var g=c[m],v=0;v<d.length;v++)o.setPixelBuffer(nu.PositiveX+m,g[v].data,v)}return i&&(o.wrapModeU=i[0],o.wrapModeV=i[1],o.filterMode=i[2],o.anisoLevel=i[3]),o},t._decideTargetFormat=function(e,t,n){var r=e._hardwareRenderer,i=t.isSRGB,a=t.pixelWidth,o=t.pixelHeight,s=this._detectSupportedFormat(r,n,i);return s!==cQ.PVRTC||tk.isPowerOf2(a)&&tk.isPowerOf2(o)&&a===o?null===s?(nb.warn("Can't support any compressed texture, downgrade to RGBA8"),cQ.R8G8B8A8):s:(nb.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),cQ.R8G8B8A8)},t._detectSupportedFormat=function(e,t,n){for(var r=0;r<t.length;r++){var i,a=t[r],o=null==(i=this._capabilityMap[a])?void 0:i[n?cj.sRGB:cj.linear];if(o){for(var s=0;s<o.length;s++)if(e.canIUse(o[s]))return a}else switch(t[r]){case cQ.R8G8B8A8:return a;case cQ.R8:case cQ.R8G8:if(e.isWebGL2)return a}}return null},t._getBinomialLLCTranscoder=function(e){var t;return void 0===e&&(e=4),null!=(t=this._binomialLLCTranscoder)?t:this._binomialLLCTranscoder=new c1(e)},t._getEngineTextureFormat=function(e,t){var n=t.hasAlpha;switch(e){case cQ.ASTC:return n_.ASTC_4x4;case cQ.ETC:return n?n_.ETC2_RGBA8:n_.ETC2_RGB;case cQ.BC7:return n_.BC7;case cQ.BC1_BC3:return n?n_.BC3:n_.BC1;case cQ.PVRTC:return n?n_.PVRTC_RGBA4:n_.PVRTC_RGB4;case cQ.R8G8B8A8:return n_.R8G8B8A8;case cQ.BC6H:return n_.BC6H;case cQ.ASTC_HDR_4x4:return n_.ASTC_4x4;case cQ.R16G16B16A16:return n_.R16G16B16A16}},t}(sn);c2._priorityFormats=((tx={})[cY.ETC1S]=[cQ.ETC,cQ.BC7,cQ.ASTC,cQ.BC1_BC3,cQ.PVRTC],tx[cY.UASTC_LDR_4X4]=[cQ.ASTC,cQ.BC7,cQ.ETC,cQ.BC1_BC3,cQ.PVRTC],tx[cY.UASTC_HDR_4X4]=[cQ.ASTC_HDR_4x4,cQ.BC6H,cQ.R16G16B16A16],tx),c2._capabilityMap=((tP={})[cQ.ASTC]=((tA={})[cj.linear]=[nT.astc,nT.astc_webkit],tA[cj.sRGB]=[nT.astc,nT.astc_webkit],tA),tP[cQ.ETC]=((tb={})[cj.linear]=[nT.etc,nT.etc_webkit],tb[cj.sRGB]=[nT.etc,nT.etc_webkit],tb),tP[cQ.BC7]=((tS={})[cj.linear]=[nT.bptc],tS[cj.sRGB]=[nT.bptc],tS),tP[cQ.BC1_BC3]=((tC={})[cj.linear]=[nT.s3tc],tC[cj.sRGB]=[nT.s3tc_srgb],tC),tP[cQ.BC6H]=((tT={})[cj.linear]=[nT.bptc],tT),tP[cQ.ASTC_HDR_4x4]=((tR={})[cj.linear]=[nT.astc_hdr],tR),tP[cQ.R16G16B16A16]=((tE={})[cj.linear]=[nT.textureHalfFloat],tE),tP[cQ.PVRTC]=((tM={})[cj.linear]=[nT.pvrtc,nT.pvrtc_webkit],tM),tP),c2=c_([og(ol.KTX2,["ktx2"])],c2);var c3=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return cd(t,e),t.prototype.restoreContent=function(){var e=this,t=this.resource,n=this.requestConfig,r=t.engine;return new nS(function(i,a){r.resourceManager._request(e.url,n).then(function(e){return c2._parseBuffer(new Uint8Array(e),r,n.params).then(function(e){var n=e.ktx2Container,r=e.engine,i=e.result,a=e.targetFormat,o=e.params;return c2._createTextureByBuffer(r,n.isSRGB,i,a,o,t)})}).then(i).catch(a)})},t}(nl),c4=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,n){return new nS(function(r,i){var a=cc({},e,{type:"arraybuffer"}),o=n.engine,s=e.url;n._request(s,a).then(function(e){var n=cx.decode(e),i=n.headerLength,l=new t0;l.copyFromArray(new Float32Array(e,i,27));var c=i+t._shByteLength;return t._parseTexture(o,e,c,n.dataLength-t._shByteLength).then(function(e){o.resourceManager.addContentRestorer(new c8(e,s,a));var t=new o0(o);t.diffuseMode=o$.SphericalHarmonics,t.diffuseSphericalHarmonics=l,t.specularTexture=e,r(t)})}).catch(i)})},t._parseTexture=function(e,t,n,r,i){if(cK.checkMagic(t,n)){var a=new Uint8Array(t,n,r);return c2._parseBuffer(a,e).then(function(e){var t=e.ktx2Container,n=e.engine,r=e.result,a=e.targetFormat,o=e.params,s=c2._createTextureByBuffer(n,t.isSRGB,r,a,o,i);return s.filterMode=nh.Trilinear,s})}var o=new Uint16Array(t,n,1)[0];i||(i=new nP(e,o,n_.R16G16B16A16,!0,!1)),i.filterMode=nh.Trilinear;for(var s=i.mipmapCount,l=n+2,c=0;c<s;c++)for(var u=o>>c,d=0;d<6;d++){var h=u*u*4,_=new Uint16Array(t,l,h);l+=2*h,i.setPixelBuffer(nu.PositiveX+d,_,c)}return Promise.resolve(i)},t}(sn);c4._shByteLength=108,c4=c_([og(ol.AmbientLight,["ambLight"])],c4);var c8=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return cd(t,e),t.prototype.restoreContent=function(){var e=this;return new nS(function(t,n){var r=e.resource,i=r.engine;i.resourceManager._request(e.url,e.requestConfig).then(function(e){var t=cx.decode(e),n=t.headerLength+c4._shByteLength;return c4._parseTexture(i,e,n,t.dataLength-c4._shByteLength,r)}).then(t).catch(n)})},t}(nl);function c5(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 c9(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){c5(a,r,i,o,s,"next",e)}function s(e){c5(a,r,i,o,s,"throw",e)}o(void 0)})}}var c6=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nS(function(r,i){t._request(e.url,cc({},e,{type:"json"})).then(function(e){var a=e.fontName,o=e.fontUrl;o?n._registerFont(a,o).then(function(){r(new nV(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new nV(t.engine,a))}).catch(function(e){i(e)})})},n._registerFont=function(e,t){return c9(function(){var n;return cf(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}(sn);function c7(){if(tw)return tw;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=nR._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)}tw=WebAssembly.instantiate(r(n)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:tw,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]):tw.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 tw}c6=c_([og(ol.Font,["font"])],c6);var ue=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r}cd(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++){var o=r[i];o&&this._disassociationSuperResource(o)}},n._disassociationSuperResource=function(e){for(var t,n=0,r=e.length;n<r;n++)null==(t=e[n])||t._disassociationSuperResource(this)},cm(t,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),t}(ns),ut=((tl={})[tl.BYTE=5120]="BYTE",tl[tl.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",tl[tl.SHORT=5122]="SHORT",tl[tl.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",tl[tl.UNSIGNED_INT=5125]="UNSIGNED_INT",tl[tl.FLOAT=5126]="FLOAT",tl),un=((tc={}).SCALAR="SCALAR",tc.VEC2="VEC2",tc.VEC3="VEC3",tc.VEC4="VEC4",tc.MAT2="MAT2",tc.MAT3="MAT3",tc.MAT4="MAT4",tc),ur=((tu={}).TRANSLATION="translation",tu.ROTATION="rotation",tu.SCALE="scale",tu.WEIGHTS="weights",tu),ui=((td={}).Linear="LINEAR",td.Step="STEP",td.CubicSpine="CUBICSPLINE",td),ua=((th={}).PERSPECTIVE="perspective",th.ORTHOGRAPHIC="orthographic",th),uo=((t_={}).OPAQUE="OPAQUE",t_.MASK="MASK",t_.BLEND="BLEND",t_),us=((tf={})[tf.NEAREST=9728]="NEAREST",tf[tf.LINEAR=9729]="LINEAR",tf),ul=((tp={})[tp.NEAREST=9728]="NEAREST",tp[tp.LINEAR=9729]="LINEAR",tp[tp.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",tp[tp.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",tp[tp.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",tp[tp.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",tp),uc=((tm={})[tm.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",tm[tm.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",tm[tm.REPEAT=10497]="REPEAT",tm),uu=/*#__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._getPromises=[],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 ug(e)}var t=e.prototype;return t.get=function(t,n){var r=this,i=e._parsers[t];if(!i)return nS.resolve(null);var a=this._resourceCache,o=void 0===n?""+t:t+":"+n,s=a.get(o);if(s)return s;var l=u_[t],c=!!uf[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)}):nS.all(u.map(function(e,n){return r.get(t,n)})):(s=i.parse(this,n),c&&this._handleSubAsset(s,t,n)):s=nS.resolve(null)}else s=i.parse(this,n),c&&this._handleSubAsset(s,t,n);return cD(s,nS)&&this._getPromises.push(s),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),nS.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(sG).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.finally(function(){t._setTaskCompleteProgress(++n.loaded,n.total)}).catch(function(e){})},t._handleSubAsset=function(e,t,n){var r,i=this,a=uf[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)}).catch(function(e){nb.error("GLTFParserContext","Failed to load "+a+" "+n+": "+e)})}},e.addParser=function(e,t){this._parsers[e]=t},e}();uu._parsers={};var ud=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},uh=((tg={})[tg.Schema=0]="Schema",tg[tg.Validator=1]="Validator",tg[tg.Scene=2]="Scene",tg[tg.Buffer=3]="Buffer",tg[tg.BufferView=4]="BufferView",tg[tg.Texture=5]="Texture",tg[tg.Material=6]="Material",tg[tg.Mesh=7]="Mesh",tg[tg.Entity=8]="Entity",tg[tg.Skin=9]="Skin",tg[tg.Animation=10]="Animation",tg[tg.AnimatorController=11]="AnimatorController",tg),u_=((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),uf=((tL={})[2]="_sceneRoots",tL[5]="textures",tL[6]="materials",tL[7]="meshes",tL[8]="entities",tL[9]="skins",tL[10]="animations",tL[11]="animatorController",tL);function up(e){return function(t){var n=new t;uu.addParser(e,n)}}var um=/*#__PURE__*/function(){function e(){}return e.floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new tq(e[r],e[r+1]);return n},e.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new tU(e[r],e[r+1],e[r+2]);return n},e.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new tZ(e[r],e[r+1],e[r+2],e[r+3]);return n},e.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 tJ(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new tJ(e[a],e[a+1],e[a+2],e[a+3]);return r},e.getAccessorTypeSize=function(e){switch(e){case un.SCALAR:return 1;case un.VEC2:return 2;case un.VEC3:return 3;case un.VEC4:case un.MAT2:return 4;case un.MAT3:return 9;case un.MAT4:return 16}},e.getComponentType=function(e){switch(e){case ut.BYTE:return Int8Array;case ut.UNSIGNED_BYTE:return Uint8Array;case ut.SHORT:return Int16Array;case ut.UNSIGNED_SHORT:return Uint16Array;case ut.UNSIGNED_INT:return Uint32Array;case ut.FLOAT:return Float32Array}},e.getNormalizedComponentScale=function(e){switch(e){case ut.BYTE:return 1/127;case ut.UNSIGNED_BYTE:return 1/255;case ut.SHORT:return 1/32767;case ut.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},e.getAccessorBuffer=function(t,n,r){var i,a=r.componentType,o=e.getComponentType(a),s=e.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=t.get(uh.BufferView,r.bufferView).then(function(e){var n,i,_,f=h.buffer,p=null!=(n=e.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=t.accessorBufferCache;if(!(_=x[y])){var A=p+v*g,b=g/l*u,S=new o(e.buffer,A,b);x[y]=_=new ud(S,!0,g),_.restoreInfo=new ub(new uS(f,o,A,b))}}else{var C=p+m,T=u*s;(_=new ud(new o(e.buffer,C,T),!1,c)).restoreInfo=new ub(new uS(f,o,C,T))}return _}).catch(function(e){nb.error("GLTFUtil getAccessorBuffer error",e)})}else{var _=u*s,f=new ud(new o(_),!1,c);f.restoreInfo=new ub(new uS(void 0,o,void 0,_)),i=nS.resolve(f)}return r.sparse?i.then(function(n){return e.processingSparseData(t,r,n).then(function(){return n})}):i},e.bufferToVector3Array=function(t,n,r,i,a){for(var o=n/t.BYTES_PER_ELEMENT,s=t.length/r,l=Array(r),c=i?e.getNormalizedComponentScale(a):1,u=0;u<r;u++){var d=o+u*s;l[u]=new tU(t[d]*c,t[d+1]*c,t[d+2]*c)}return l},e.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},e.processingSparseData=function(t,n,r){var i=r.restoreInfo,a=t.glTF.bufferViews,o=e.getAccessorTypeSize(n.type),s=e.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 nS.all([t.get(uh.BufferView,d.bufferView),t.get(uh.BufferView,h.bufferView)]).then(function(t){var n,a,c,p,m=t[0],g=t[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),A=g.byteLength;i.typeSize=o,i.sparseCount=u;var b=e.getComponentType(d.componentType),S=y/b.BYTES_PER_ELEMENT,C=new b(m.buffer,v,S);i.sparseIndices=new uS(_.buffer,b,v,S);var T=A/s.BYTES_PER_ELEMENT,R=new s(g.buffer,x,T);i.sparseValues=new uS(f.buffer,s,x,T);for(var E=0;E<u;E++)for(var M=C[E],P=0;P<o;P++)l[M*o+P]=R[E*o+P];r.data=l}).catch(function(e){nb.error("GLTFUtil processingSparseData error",e)})},e.getIndexFormat=function(e){switch(e){case ut.UNSIGNED_BYTE:return aA.UInt8;case ut.UNSIGNED_SHORT:return aA.UInt16;case ut.UNSIGNED_INT:return aA.UInt32}},e.getElementFormat=function(e,t,n){if(void 0===n&&(n=!1),e==ut.FLOAT)switch(t){case 1:return ab.Float;case 2:return ab.Vector2;case 3:return ab.Vector3;case 4:return ab.Vector4}if(e==ut.SHORT)switch(t){case 2:return n?ab.NormalizedShort2:ab.Short2;case 3:case 4:return n?ab.NormalizedShort4:ab.Short4}if(e==ut.UNSIGNED_SHORT)switch(t){case 2:return n?ab.NormalizedUShort2:ab.UShort2;case 3:case 4:return n?ab.NormalizedUShort4:ab.UShort4}if(e==ut.BYTE)switch(t){case 2:case 3:case 4:return n?ab.NormalizedByte4:ab.Byte4}if(e==ut.UNSIGNED_BYTE)switch(t){case 2:case 3:case 4:return n?ab.NormalizedUByte4:ab.UByte4}},e.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)})},e.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(nX.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 tq(h,a)),u+=a+8}return{glTF:l,buffers:c}},e.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)},e.getSamplerInfo=function(e){var t=e.minFilter,n=e.magFilter,r=e.wrapS,i=e.wrapT,a={};return(t||n)&&(a.mipmap=t>=ul.NEAREST_MIPMAP_NEAREST,n===us.NEAREST?a.filterMode=nh.Point:t<=ul.LINEAR_MIPMAP_NEAREST?a.filterMode=nh.Bilinear:a.filterMode=nh.Trilinear),r&&(a.wrapModeU=uk._wrapMap[r]),i&&(a.wrapModeV=uk._wrapMap[i]),a},e}(),ug=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.bufferRequests=[],t.glbBufferSlices=[],t.bufferTextures=[],t.meshes=[],t}cd(t,e);var n=t.prototype;return n.restoreContent=function(){var e=this;return new nS(function(t,n){Promise.all(e.bufferRequests.map(function(e){return of(e.url,e.config)})).then(function(r){if(e.isGLB){var i=e.glbBufferSlices,a=r[0],o=i.length;r.length=o;for(var s=0;s<o;s++){var l=i[s];r[s]=a.slice(l.x,l.x+l.y)}}nS.all(e.bufferTextures.map(function(e){var t,n=e.bufferView,i=new Uint8Array(r[n.buffer],null!=(t=n.byteOffset)?t:0,n.byteLength),a=e.texture;return"image/ktx2"===e.mimeType?c2._parseBuffer(i,a.engine).then(function(e){for(var t=e.result.faces[0],n=0;n<t.length;n++)a.setPixelBuffer(t[n].data,n)}):um.loadImageBuffer(i,e.mimeType).then(function(e){a.setImageSource(e),a.generateMipmaps()})})).then(function(){for(var n,i=cI(e.meshes);!(n=i()).done;){for(var a,o=n.value,s=o.mesh,l=cI(o.vertexBuffers);!(a=l()).done;){var c=a.value,u=e._getBufferData(r,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=e._getBufferData(r,o.indexBuffer);s.setIndices(d)}for(var h,_=cI(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=e._getBufferData(r,m.buffer);if(p.deltaPositions=um.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=e._getBufferData(r,v.buffer);p.deltaNormals=um.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,A=e._getBufferData(r,x.buffer);p.deltaTangents=um.bufferToVector3Array(A,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}t(e.resource)}).catch(n)}).catch(n)})},n._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},t}(nl),uv=function(e,t){this.url=e,this.config=t},uy=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},ux=function(){this.vertexBuffers=[],this.blendShapes=[]},uA=function(e,t){this.buffer=e,this.data=t},ub=function(e,t,n,r,i){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=i},uS=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},uC=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},uT=function(e,t,n,r,i){this.buffer=e,this.byteOffset=t,this.count=n,this.normalized=r,this.componentType=i},uR=/*#__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}(),uE=((tv={})[tv.CreateAndParse=0]="CreateAndParse",tv[tv.AdditiveParse=1]="AdditiveParse",tv),uM=/*#__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,uE.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,uE.AdditiveParse);null==c||c.additiveParse.apply(c,[].concat([n,r,i,a],s))},e}();function uP(e,t){return function(n){var r=new n;r._mode=t,uM._addExtensionParser(e,r)}}uM._extensionParsers={};var uw=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(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=um.parseGLB(e,t);return(null==n?void 0:n.glTF)&&a.push(new uv(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(nX.decodeText(new Uint8Array(t.originBuffer))))})},t}(uM);uw=c_([up(uh.Schema)],uw);var uF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.parse=function(e,n){var r=e.glTF.animations[n],i=r.name,a=uM.executeExtensionsCreateAndParse(r.extensions,e,r)||t._parseStandardProperty(e,new sp(void 0===i?"AnimationClip"+n:i),r);return nS.resolve(a).then(function(t){return uM.executeExtensionsAdditiveAndParse(r.extensions,e,t,r),t})},t._parseStandardProperty=function(e,t,n){for(var r=function(t,n){var r=c[t],i=o[r.input],a=o[r.output],l=nS.all([um.getAccessorBuffer(e,s,i),um.getAccessorBuffer(e,s,a)]).then(function(e){var n,i,o=e[0].data,s=e[1].data;if(a.normalized){for(var l=um.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:ui.Linear){case ui.CubicSpine:i=sm.CubicSpine;break;case ui.Step:i=sm.Step;break;case ui.Linear:i=sm.Linear}o[o.length-1],d[t]={type:a.type,interpolation:i,input:o,output:s,outputSize:_}});_.push(l)},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(uh.Entity),_=[],f=0;f<u;f++)r(f);return _.push(e.get(uh.Scene)),nS.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 ur.TRANSLATION:f=rG,p="position";break;case ur.ROTATION:f=rG,p="rotationQuaternion";break;case ur.SCALE:f=rG,p="scale";break;case ur.WEIGHTS:f=a3,p="blendShapeWeights"}var m=i._addCurve(s.path,o,d);if(s.path===ur.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})},t._addCurve=function(e,t,n){var r=n[t.sampler],i=r.input,a=r.output,o=r.outputSize;switch(e){case ur.TRANSLATION:case ur.SCALE:for(var s=new sT,l=s.interpolation=r.interpolation,c=0,u=0,d=i.length;u<d;u++){var h=new sq;h.time=i[u],l===sm.CubicSpine?(h.inTangent=new tU(a[c++],a[c++],a[c++]),h.value=new tU(a[c++],a[c++],a[c++]),h.outTangent=new tU(a[c++],a[c++],a[c++])):h.value=new tU(a[c++],a[c++],a[c++]),s.addKey(h)}return s;case ur.ROTATION:for(var _=new sS,f=_.interpolation=r.interpolation,p=0,m=0,g=i.length;m<g;m++){var v=new sq;v.time=i[m],f===sm.CubicSpine?(v.inTangent=new tZ(a[p++],a[p++],a[p++],a[p++]),v.value=new tY(a[p++],a[p++],a[p++],a[p++]),v.outTangent=new tZ(a[p++],a[p++],a[p++],a[p++])):v.value=new tY(a[p++],a[p++],a[p++],a[p++]),_.addKey(v)}return _;case ur.WEIGHTS:var y=new sA;y.interpolation=r.interpolation;for(var x=0,A=0,b=i.length;A<b;A++){var S=new sq;S.time=i[A],y.interpolation===sm.CubicSpine?(S.inTangent=Array.from(a.subarray(x,x+o)),x+=o,S.value=a.slice(x,x+o),x+=o,S.outTangent=Array.from(a.subarray(x,x+o))):S.value=a.slice(x,x+o),x+=o,y.addKey(S)}return y}},t}(uM);uF=c_([up(uh.Animation)],uF);var uL=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.parse=function(e,t){var n=e.glTF.buffers;return e.buffers?nS.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=nX.resolveAbsoluteUrl(o,t.uri);s.push(new uv(c,l));var u=i._requestByRemoteUrl(c,l).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(u),u},t}(uM);uL=c_([up(uh.Buffer)],uL);var uD=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(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 a7(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(uh.Entity,p);u.addChild(m)}return uM.executeExtensionsAdditiveAndParse(c,e,u,r),u},t}(uM);uD=c_([up(uh.Entity)],uD);var uB="GALACEAN_materials_remap",uI=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.parse=function(e,n){var r,i=e.glTF.materials[n],a=e.glTFResource,o=a.engine,s=i.extensions||{};s[uB]&&((r={})[uB]=s[uB],s=r);var l=uM.executeExtensionsCreateAndParse(s,e,i);return l||((l=new r6(o)).name=i.name,t._parseStandardProperty(e,l,i)),nS.resolve(l).then(function(t){return t||(t=o._basicResources._getBlinnPhongMaterial()),uM.executeExtensionsAdditiveAndParse(s,e,t,i),t._associationSuperResource(a),t})},t._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&nb.warn(""+t+" texture ignore KHR_texture_transform extension.")},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.copyFromArray(h),_&&e.get(uh.Texture,_.index).then(function(t){n.baseTexture=t,uM.executeExtensionsAdditiveAndParse(_.extensions,e,n,_)}).catch(function(e){nb.error("GLTFMaterialParser: baseColorTexture error",e)}),n.constructor===r6&&(n.metallic=null!=f?f:1,n.roughness=null!=p?p:1,m&&(t._checkOtherTextureTransform(m,"Roughness metallic"),e.get(uh.Texture,m.index).then(function(e){n.roughnessMetallicTexture=e}).catch(function(e){nb.error("GLTFMaterialParser: metallicRoughnessTexture error",e)})))}if(n.constructor===r6){if(s&&(t._checkOtherTextureTransform(s,"Emissive"),e.get(uh.Texture,s.index).then(function(e){n.emissiveTexture=e}).catch(function(e){nb.error("GLTFMaterialParser: emissiveTexture error",e)})),l&&n.emissiveColor.set(l[0],l[1],l[2],1),a){var g=a.index,v=a.scale;t._checkOtherTextureTransform(a,"Normal"),e.get(uh.Texture,g).then(function(e){n.normalTexture=e}).catch(function(e){nb.error("GLTFMaterialParser: emissiveTexture error",e)}),void 0!==v&&(n.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,A=o.texCoord;t._checkOtherTextureTransform(o,"Occlusion"),e.get(uh.Texture,y).then(function(e){n.occlusionTexture=e}).catch(function(e){nb.error("GLTFMaterialParser: occlusionTexture error",e)}),void 0!==x&&(n.occlusionTextureIntensity=x),A===r5.UV1?n.occlusionTextureCoord=r5.UV1:A>r5.UV1&&nb.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=r2.Double:n.renderFace=r2.Front,c){case uo.OPAQUE:n.isTransparent=!1;break;case uo.BLEND:n.isTransparent=!0;break;case uo.MASK:n.alphaCutoff=null!=u?u:.5}},t}(uM);uI=c_([up(uh.Material)],uI);var uN=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.parse=function(e,n){for(var r=function(n,r){var c=i.primitives[n];l[n]=new nS(function(r,l){var u=uM.executeExtensionsCreateAndParse(c.extensions,e,c,i);if(u)cD(u,aG)?(u._associationSuperResource(o),r(u)):u.then(function(e){e._associationSuperResource(o),r(e)});else{var d=new aG(s,i.name||n+"");d._associationSuperResource(o);var h=new ux;h.mesh=d,e.contentRestorer.meshes.push(h),t._parseMeshFromGLTFPrimitive(e,d,h,i,c,a,e.params.keepMeshData).then(r,l)}})},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 nS.all(l)},t._parseMeshFromGLTFPrimitive=function(e,n,r,i,a,o,s){var l,c=function(i){var a=u[d[i]],c=um.getAccessorBuffer(e,o.bufferViews,a).then(function(e){var o,c,u,d=um.getAccessorTypeSize(a.type),h=a.count,_=e.data,f=n.instanceId,v=e.vertexBindingInfos,y=a.normalized,x=um.getElementFormat(a.componentType,d,y);if(y&&(c=um.getNormalizedComponentScale(a.componentType)),e.interleaved){var A=a.byteOffset||0,b=e.stride;if(u=A%b,void 0===v[f]){o=new aC(i,u,x,g);var S=e.vertexBuffer;S||(S=new ax(p,aT.VertexBuffer,_,av.Static,s),e.vertexBuffer=S,r.vertexBuffers.push(new uA(S,e.restoreInfo))),n.setVertexBufferBinding(S,b,g),v[f]=g++}else o=new aC(i,u,x,v[f])}else{o=new aC(i,u=0,x,g);var C=e.vertexBuffer;C||(C=new ax(p,aT.VertexBuffer,_,av.Static,s),r.vertexBuffers.push(new uA(C,e.restoreInfo))),n.setVertexBufferBinding(C,e.stride,g),v[f]=g++}if(m.push(o),"POSITION"===i){l=h;var T=n.bounds,R=T.min,E=T.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 P=u/_.BYTES_PER_ELEMENT,w=_.length/h,F=0;F<h;F++){var L=P+F*w;M.copyFromArray(_,L),tU.min(R,M,R),tU.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 nS.all(v).then(function(){if(n.setVertexElements(m),void 0!==_){var c=o.accessors[_],u=um.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 um.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:um.bufferToVector3Array(r,i,a,o,s),restoreInfo:new uT(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!==_,m=nS.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 aw(r);o.addFrame(1,t.vertices,f?i.vertices:null,p?a.vertices:null),n.blendShape=o,n.restoreInfo=new uC(o,t.restoreInfo,f?i.restoreInfo:null,p?null==a?void 0:a.restoreInfo:null)});u.push(m)}(_);return nS.all(u).then(function(){for(var e,r=cI(h);!(e=r()).done;){var i=e.value;t.addBlendShape(i.blendShape),n.blendShapes.push(i.restoreInfo)}})},t}(uM);uN._tempVector3=new tU,uN=c_([up(uh.Mesh)],uN);var uO=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.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(uh.Entity,u[0]);else{(n=new a7(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=e.get(uh.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 nS.all(_).then(function(){return uM.executeExtensionsAdditiveAndParse(l,e,n,s),n})},n._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(uh.Entity,t);return void 0!==s&&this._createCamera(a,i.cameras[s],c),void 0!==l&&(n=this._createRenderer(e,o,c)),nS.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 nS.all(t)})},n._createCamera=function(e,t,n){var r=t.orthographic,i=t.perspective,a=t.type,o=n.addComponent(r0);if(a===ua.ORTHOGRAPHIC){var s=r.xmag,l=r.ymag,c=r.zfar,u=r.znear;o.isOrthographic=!0,void 0!==u&&(o.nearClipPlane=u),void 0!==c&&(o.farClipPlane=c),o.orthographicSize=Math.max(null!=l?l:0,null!=s?s:0)/2}else if(a===ua.PERSPECTIVE){var d=i.aspectRatio,h=i.yfov,_=i.zfar,f=i.znear;void 0!==d&&(o.aspectRatio=d),void 0!==h&&(o.fieldOfView=180*h/Math.PI),void 0!==_&&(o.farClipPlane=_),void 0!==f&&(o.nearClipPlane=f)}e.cameras||(e.cameras=[]),e.cameras.push(o),o.enabled=!1},n._createRenderer=function(e,t,n){for(var r,i=this,a=t.mesh,o=t.skin,s=e.glTF.meshes[a],l=s.primitives,c=l.length,u=t.weights||s.weights,d=Array(c),h=0;h<c;h++)d[h]=e.get(uh.Material,null!=(r=l[h].material)?r:-1);return nS.all([e.get(uh.Mesh,a),void 0!==o&&e.get(uh.Skin,o),nS.all(d)]).then(function(t){for(var r=t[0],a=t[1],o=t[2],s=e.glTFResource.engine._basicResources,d=0;d<c;d++)!function(t){var c=o[t]||s._getBlinnPhongMaterial(),d=l[t],h=r[t],_=void 0;if(a||u){var f=n.addComponent(a3);f.mesh=h,a&&(i._computeLocalBounds(f,h,a.bones,a.rootBone,a.inverseBindMatrices),f.skin=a),u&&(f.blendShapeWeights=new Float32Array(u)),_=f}else(_=n.addComponent(ak)).mesh=h;_.setMaterial(c),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),uM.executeExtensionsAdditiveAndParse(d.extensions,e,_,d)}(d)}).catch(function(e){nb.error("GLTFSceneParser: create renderer error",e)})},n._computeLocalBounds=function(e,t,n,r,i){var a=n.indexOf(r);if(-1!==a)tG.transform(t.bounds,i[a],e.localBounds);else{var o=new tK(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?(tK.multiplyScalar(o,1/s,o),tG.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},n._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?(tK.add(r,t[c],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},t}(uM);uO=c_([up(uh.Scene)],uO);var uV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(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 a1(void 0===l?"SKIN_"+t:l);u.inverseBindMatrices.length=c;var d=Array(c),h=r.accessors[a],_=um.getAccessorBuffer(e,r.bufferViews,h).then(function(t){for(var r=e.get(uh.Entity),i=t.data,a=0;a<c;a++){var l=new tK;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});return nS.resolve(_)},n._findSkeletonRootBone=function(e,t){for(var n,r={},i=cI(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}(uM);uV=c_([up(uh.Skin)],uV);var uk=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.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=this._isSRGBColorSpace(n,e.glTF.materials),u=uM.executeExtensionsCreateAndParse(l,e,r,n,c);return u||(u=t._parseTexture(e,void 0===o?0:o,n,a,s,c)),nS.resolve(u).then(function(t){return uM.executeExtensionsAdditiveAndParse(l,e,t,r),t._associationSuperResource(i),t})},n._isSRGBColorSpace=function(e,t){return null==t?void 0:t.some(function(t){var n,r,i,a,o,s,l,c,u;if((null==(n=t.emissiveTexture)?void 0:n.index)===e||(null==(i=t.pbrMetallicRoughness)?void 0:null==(r=i.baseColorTexture)?void 0:r.index)===e||(null==(s=t.extensions)?void 0:null==(o=s.KHR_materials_sheen)?void 0:null==(a=o.sheenColorTexture)?void 0:a.index)===e||(null==(u=t.extensions)?void 0:null==(c=u.KHR_materials_specular)?void 0:null==(l=c.specularColorTexture)?void 0:l.index)===e)return!0})},t._parseTexture=function(e,t,n,r,i,a){var o,s=e.glTFResource,l=e.glTF,c=s.engine,u=s.url,d=l.images[t],h=d.uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==r,g=m&&um.getSamplerInfo(l.samplers[r]);if(h){var v=h.lastIndexOf("."),y=h.substring(v+1).startsWith("ktx")?ol.KTX:ol.Texture2D;o=c.resourceManager.load({url:nX.resolveAbsoluteUrl(u,h),type:y,params:{mipmap:null==g?void 0:g.mipmap,isSRGBColorSpace:a}}).onProgress(void 0,e._onTaskDetail).then(function(e){return e.name=i||p||e.name||"texture_"+n,m&&um.parseSampler(e,g),e}),e._addTaskCompletePromise(o)}else{var x=l.bufferViews[_];o=e.get(uh.Buffer).then(function(t){var r=new Uint8Array(t[x.buffer],x.byteOffset,x.byteLength);return um.loadImageBuffer(r,f).then(function(t){var r,o=t.width,s=t.height,l=n_.R8G8B8A8,u=nM.supportGenerateMipmapsWithCorrection(c,o,s,l,null==(r=null==g?void 0:g.mipmap)||r,a),d=new nF(c,o,s,l,u,a);d.setImageSource(t),d.generateMipmaps(),d.name=i||p||"texture_"+n,m&&um.parseSampler(d,g);var h=new uy(d,x,f);return e.contentRestorer.bufferTextures.push(h),d})}).catch(function(e){nb.error("GLTFTextureParser: image buffer error",e)})}return o},t}(uM);uk._wrapMap=((tD={})[uc.CLAMP_TO_EDGE]=np.Clamp,tD[uc.MIRRORED_REPEAT]=np.Mirror,tD[uc.REPEAT]=np.Repeat,tD),uk=c_([up(uh.Texture)],uk);var uU=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(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){nb.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++){var s=r[o];uM.hasExtensionParser(s)||nb.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(i){nb.info("extensionsRequired: "+i);for(var l=0;l<i.length;l++){var c=i[l];uM.hasExtensionParser(c)||nb.error("GLTF parser has not supported required extension "+c+".")}}return nS.resolve(null)},t}(uM);uU=c_([up(uh.Validator)],uU);var uz=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(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?uM.executeExtensionsCreateAndParse(r,e,n):e.get(uh.Buffer,s).then(function(e){return new Uint8Array(e,a,o)}).catch(function(e){nb.error("GLTFBufferViewParser: buffer error",e)})},t}(uM);uz=c_([up(uh.BufferView)],uz);var uG=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.parse=function(e){var t=this;return e.needAnimatorController?e.get(uh.Animation).then(function(n){var r=t._createAnimatorController(e,n);return nS.resolve(r)}).catch(function(e){nb.error("GLTFAnimatorControllerParser: animator controller error",e)}):nS.resolve(null)},n._createAnimatorController=function(e,t){var n=new sW(e.glTFResource.engine),r=new sQ("layer"),i=new sK;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}(uM);uG=c_([up(uh.AnimatorController)],uG);var uH=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(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?c7().then(function(e){e.useWorkers(a.workerCount)}):Promise.resolve()},n.load=function(e,t){var n=e.params,r=new ue(t.engine,e.url),i=new uu(r,t,cc({keepMeshData:!1},n));return new nS(function(e,t,n,a,o){i._setTaskCompleteProgress=n,i._setTaskDetailProgress=a,o(function(){for(var e=i._getPromises,t=0,n=e.length;t<n;t++)e[t].cancel()}),i.parse().then(e).catch(function(e){r.destroy(),t(e)})})},t.release=function(){tw&&c7().then(function(e){e.release()})},t}(sn);uH=c_([og(ol.GLTF,["gltf","glb"])],uH);var uW=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t,n)||this).prefabResource=r,i}cd(t,e);var n=t.prototype;return n._applyEntityData=function(t,n){return void 0===n&&(n={}),e.prototype._applyEntityData.call(this,t,n),t._markAsTemplate(this.context.resource),t},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 cN(e,n),a=new t(r,new cw(e,cP.Prefab,i),i);return a.start(),a.promise.then(function(){return i})},t}(cO),uX=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=t.engine;return new nS(function(r,i){t._request(e.url,cc({},e,{type:"json"})).then(function(t){uW.parse(n,e.url,t).then(r).catch(i)},i)})},t}(sn);uX=c_([og(ol.Prefab,["prefab"])],uX);var uj=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){return t._request(e.url,cc({},e,{type:"json"})).then(function(e){var n=new si(t.engine);return n.data=e,n})},t}(sn);uj=c_([og(ol.JSON,["json"])],uj);var uY={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 lQ.RGB_S3TC_DXT1_EXT:return n_.BC1;case lQ.RGBA_S3TC_DXT5_EXT:return n_.BC3;case lQ.RGBA_BPTC_UNORM_EXT:return n_.BC7;case lQ.RGB_ETC1_WEBGL:return n_.ETC1_RGB;case lQ.RGB8_ETC2:return n_.ETC2_RGB;case lQ.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return n_.ETC2_RGBA5;case lQ.RGBA8_ETC2_EAC:return n_.ETC2_RGBA8;case lQ.RGB_PVRTC_2BPPV1_IMG:return n_.PVRTC_RGB2;case lQ.RGBA_PVRTC_2BPPV1_IMG:return n_.PVRTC_RGBA2;case lQ.RGB_PVRTC_4BPPV1_IMG:return n_.PVRTC_RGB4;case lQ.RGBA_PVRTC_4BPPV1_IMG:return n_.PVRTC_RGBA4;case lQ.RGBA_ASTC_4X4_KHR:return n_.ASTC_4x4;case lQ.RGBA_ASTC_5X5_KHR:return n_.ASTC_5x5;case lQ.RGBA_ASTC_6X6_KHR:return n_.ASTC_6x6;case lQ.RGBA_ASTC_8X8_KHR:return n_.ASTC_8x8;case lQ.RGBA_ASTC_10X10_KHR:return n_.ASTC_10x10;case lQ.RGBA_ASTC_12X12_KHR:return n_.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+lQ[e])}}(s.glInternalFormat)),s}};function uK(e){var t=uY.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var uQ=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){return new nS(function(n,r){Promise.all(e.urls.map(function(n){return t._request(n,cc({},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=uY.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 nP(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(nu.PositiveX+c,_,d,0,0,f,p)}n(l)}).catch(function(e){r(e)})})},t}(sn);uQ=c_([og(ol.KTXCube,[])],uQ);var uq=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=cc({},e,{type:"arraybuffer"});return new nS(function(r,i){t._request(e.url,n).then(function(i){for(var a=uK(i),o=a.width,s=a.height,l=a.mipmaps,c=a.engineFormat,u=l.length>1,d=new nF(t.engine,o,s,c,u,!1),h=0;h<l.length;h++){var _=l[h],f=_.width,p=_.height,m=_.data;d.setPixelBuffer(m,h,0,0,f,p)}t.addContentRestorer(new uZ(d,e.url,n)),r(d)}).catch(function(e){i(e)})})},t}(sn);uq=c_([og(ol.KTX,["ktx"])],uq);var uZ=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return cd(t,e),t.prototype.restoreContent=function(){var e=this,t=this.resource,n=t.engine;return new nS(function(r,i){n.resourceManager._request(e.url,e.requestConfig).then(function(e){for(var n=uK(e).mipmaps,i=0;i<n.length;i++){var a=n[i],o=a.width,s=a.height,l=a.data;t.setPixelBuffer(l,i,0,0,o,s)}r(t)}).catch(function(e){i(e)})})},t}(nl),uJ=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nS(function(r,i){t._request(e.url,cc({},e,{type:"json"})).then(function(e){var i=t.engine,a=e.shaderRef,o=e.shader,s=rM.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 cV.Vector2:u.setVector2(e,new tq(i.x,i.y));break;case cV.Vector3:u.setVector3(e,new tU(i.x,i.y,i.z));break;case cV.Vector4:u.setVector4(e,new tZ(i.x,i.y,i.z,i.w));break;case cV.Color:u.setColor(e,new tJ(i.r,i.g,i.b,i.a));break;case cV.Float:u.setFloat(e,i);break;case cV.Texture:c.push(n.resourceManager.getResourceByRef(i).then(function(t){u.setTexture(e,t)}));break;case cV.Boolean:u.setInt(e,i?1:0);break;case cV.Integer:u.setInt(e,Number(i))}},i=e.name,a=e.shaderData,o=e.macros,s=e.renderState,l=new r3(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":ch(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}(sn);uJ=c_([og(ol.Material,["mat"])],uJ);var u$=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=cc({},e,{type:"arraybuffer"}),r=e.url;return new nS(function(e,i){t._request(r,n).then(function(e){return cz(e,t.engine)}).then(function(i){t.addContentRestorer(new u0(i,r,n)),e(i)}).catch(i)})},t}(sn);u$=c_([og(ol.Mesh,["mesh"])],u$);var u0=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return cd(t,e),t.prototype.restoreContent=function(){var e=this,t=this.resource,n=t.engine;return new nS(function(r,i){n.resourceManager._request(e.url,e.requestConfig).then(function(e){return cz(e,n,t)}).then(function(e){r(e)}).catch(i)})},t}(nl),u1=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=t.engine;return t._request(e.url,cc({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return a0.createSubdivisionSurfaceSphere(n,e.sphereRadius,e.sphereStep);case"capsule":return a0.createCapsule(n,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return a0.createCone(n,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return a0.createCuboid(n,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return a0.createCylinder(n,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return a0.createPlane(n,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return a0.createTorus(n,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},t}(sn);u1=c_([og(ol.PrimitiveMesh,["mesh"],!1)],u1);var u2=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=t.engine;return new nS(function(r,i,a){t._request(e.url,cc({},e,{type:"json"})).then(function(e){return n.resourceManager.initVirtualResources(e.files),t.load({type:ol.Scene,url:e.scene}).onProgress(a).then(function(e){n.sceneManager.activeScene=e,r()})}).catch(i)})},t}(sn);u2=c_([og(ol.Project,["project"],!1)],u2);var u3=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nS(function(r,i){var a=t._getRemoteUrl(e.url);n._registerFont(a,a).then(function(){r(new nV(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},n._registerFont=function(e,t){return c9(function(){var n;return cf(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}(sn);u3=c_([og(ol.SourceFont,["ttf","otf","woff"])],u3);var u4=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._tempRect=new t$,t._tempVec2=new tq,t._tempVec4=new tZ,t}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nS(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,cc({},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 nJ(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:nX.resolveAbsoluteUrl(e.url,f.img),type:null!=(a=f.type)?a:ol.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);nS.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 n8(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 void 0===l||(u.width=l),void 0===c||(u.height=c),u},t}(sn);u4=c_([og(ol.SpriteAtlas,["atlas"])],u4);var u8=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return t._request(e.url,cc({},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 n8(e.engine,n,t.region,t.pivot,t.border),i=t.width,a=t.height;return void 0===i||(r.width=i),void 0===a||(r.height=a),r}):new nS(function(n){var r=new n8(e.engine,null,t.region,t.pivot,t.border),i=t.width,a=t.height;void 0===i||(r.width=i),void 0===a||(r.height=a),n(r)})},t}(sn);u8=c_([og(ol.Sprite,["sprite"])],u8);var u5=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){return t._request(e.url,cc({},e,{type:"text"})).then(function(e){var n=new sr(t.engine);return n.text=e,n})},t}(sn);function u9(e){return new nS(function(t,n){var r=new Blob([e]),i=new Image;i.onload=function(){URL.revokeObjectURL(i.src),t(i)},i.onerror=n,i.src=URL.createObjectURL(r)})}u5=c_([og(ol.Text,["txt"])],u5);var u6=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this,r=e.url,i=cc({},e,{type:"arraybuffer"});return new nS(function(a,o,s,l){t._request(r,i).onProgress(s,l).then(function(s){cx.checkMagic(s)?cz(s,t.engine).then(function(e){t.addContentRestorer(new u7(e,r,i)),a(e)},o):u9(s).then(function(o){var s=n._createTexture(o,e,t);t.addContentRestorer(new u7(s,r,i)),a(s)},o)}).catch(o)})},n._createTexture=function(e,t,n){var r,i=null!=(r=t.params)?r:{},a=i.format,o=void 0===a?n_.R8G8B8A8:a,s=i.anisoLevel,l=i.wrapModeU,c=i.wrapModeV,u=i.filterMode,d=i.isSRGBColorSpace,h=void 0===d||d,_=i.mipmap,f=e.width,p=e.height,m=n.engine,g=nM.supportGenerateMipmapsWithCorrection(m,f,p,o,void 0===_||_,h),v=new nF(m,f,p,o,g,h);v.anisoLevel=null!=s?s:v.anisoLevel,v.filterMode=null!=u?u:v.filterMode,v.wrapModeU=null!=l?l:v.wrapModeU,v.wrapModeV=null!=c?c:v.wrapModeV,v.setImageSource(e),g&&v.generateMipmaps();var y=t.url;return 0!==y.indexOf("data:")&&(v.name=y.substring(y.lastIndexOf("/")+1)),v},t}(sn);u6=c_([og(ol.Texture2D,["png","jpg","webp","jpeg","tex"])],u6);var u7=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return cd(t,e),t.prototype.restoreContent=function(){var e=this.resource,t=e.engine;return t.resourceManager._request(this.url,this.requestConfig).then(function(n){return cx.checkMagic(n)?cz(n,t,e):u9(n).then(function(t){return e.setImageSource(t),e.generateMipmaps(),e})})},t}(nl),de=/*#__PURE__*/function(){function e(){}return e.parseHeader=function(e){var t=this._readStringLine(e,0);if("#"!==t[0]||"?"!==t[1])throw"HDRDecoder: invalid file header";var n=!1,r=!1,i=0;do i+=t.length+1,"FORMAT=32-bit_rle_rgbe"===(t=this._readStringLine(e,i))?r=!0:0===t.length&&(n=!0);while(!n);if(!r)throw"HDRDecoder: unsupported format, expected 32-bit_rle_rgbe";i+=t.length+1,t=this._readStringLine(e,i);var a=/^\-Y (.*) \+X (.*)$/g.exec(t);if(!a||a.length<3)throw"HDRDecoder: missing image size, only -Y +X layout is supported";var o=parseInt(a[2]),s=parseInt(a[1]);if(o<8||o>32767)throw"HDRDecoder: unsupported image width, must be between 8 and 32767";return{height:s,width:o,dataPosition:i+t.length+1}},e.decodeFaces=function(t,n,r){for(var i=n.width,a=n.height,o=n.dataPosition,s=a>>1,l=e._readPixels(t.subarray(o),i,a),c=e._faces,u=new Uint16Array(s*s*4),d=0;d<6;d++)e._createCubemapData(s,c[d],l,i,a,u),r(d,u)},e._generateFloat2HalfTables=function(){for(var e=new Uint32Array(512),t=new Uint32Array(512),n=0;n<256;++n){var r=n-127;r<-27?(e[n]=0,e[256|n]=32768,t[n]=24,t[256|n]=24):r<-14?(e[n]=1024>>-r-14,e[256|n]=1024>>-r-14|32768,t[n]=-r-1,t[256|n]=-r-1):r<=15?(e[n]=r+15<<10,e[256|n]=r+15<<10|32768,t[n]=13,t[256|n]=13):r<128?(e[n]=31744,e[256|n]=64512,t[n]=24,t[256|n]=24):(e[n]=31744,e[256|n]=64512,t[n]=13,t[256|n]=13)}return{baseTable:e,shiftTable:t}},e._createCubemapData=function(t,n,r,i,a,o){for(var s=1/t,l=(n[3]-n[0])*s,c=(n[4]-n[1])*s,u=(n[5]-n[2])*s,d=(n[9]-n[6])*s,h=(n[10]-n[7])*s,_=(n[11]-n[8])*s,f=e._floatView,p=e._uint32View,m=e._float2HalfTables,g=m.baseTable,v=m.shiftTable,y=e._one,x=0,A=0;A<t;A++){for(var b=n[0],S=n[1],C=n[2],T=n[6],R=n[7],E=n[8],M=0;M<t;M++){var P=b+(T-b)*x,w=S+(R-S)*x,F=C+(E-C)*x,L=1/Math.sqrt(P*P+w*w+F*F);P*=L,w*=L;var D=Math.round((Math.atan2(F*=L,P)/Math.PI*.5+.5)*i);D<0?D=0:D>=i&&(D=i-1);var B=Math.round(Math.acos(w)/Math.PI*a);B<0?B=0:B>=a&&(B=a-1);for(var I=(a-B-1)*i*4+4*D,N=Math.pow(2,r[I+3]-128)/255,O=A*t*4+4*M,V=0;V<3;V++){f[0]=Math.min(r[I+V]*N,65504);var k=p[0],U=k>>23&511;o[O+V]=g[U]+((8388607&k)>>v[U])}o[O+3]=y,b+=l,S+=c,C+=u,T+=d,R+=h,E+=_}x+=s}},e._readStringLine=function(e,t){for(var n="",r=t,i=e.length;r<i;r++){var a=String.fromCharCode(e[r]);if("\n"===a)break;n+=a}return n},e._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"HDRDecoder: wrong scanline width";for(var f=0;f<s&&o<r;){var p=e[o++],m=p>128;if(m&&(p-=128),0===p||f+p>s)throw"HDRDecoder: bad scanline data";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++,a+=4)i[a]=l[y],i[a+1]=l[y+t],i[a+2]=l[y+2*t],i[a+3]=l[y+3*t];c--}return i},e}();de._float2HalfTables=de._generateFloat2HalfTables(),de._floatView=new Float32Array(1),de._uint32View=new Uint32Array(de._floatView.buffer),de._one=15360,de._faces=[[1,-1,-1,1,-1,1,1,1,-1,1,1,1],[-1,-1,1,-1,-1,-1,-1,1,1,-1,1,-1],[-1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1],[-1,1,-1,1,1,-1,-1,1,1,1,1,1],[-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1],[1,-1,1,-1,-1,1,1,1,1,-1,1,1]];var dt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){return new nS(function(n,r){var i=t.engine,a=e.url,o=cc({},e,{type:"arraybuffer"});t._request(a,o).then(function(s){if(!nR.supportsTextureFormat(i,n_.R16G16B16A16)){r(Error("TextureCubeLoader: HDR texture requires half float support."));return}var l,c=null!=(l=e.params)?l:{},u=c.mipmap,d=c.anisoLevel,h=c.wrapModeU,_=c.wrapModeV,f=c.filterMode,p=new Uint8Array(s),m=de.parseHeader(p),g=new nP(i,m.height>>1,n_.R16G16B16A16,void 0===u||u,!1);de.decodeFaces(p,m,function(e,t){g.setPixelBuffer(nu.PositiveX+e,t,0)}),g.generateMipmaps(),g.anisoLevel=null!=d?d:g.anisoLevel,g.filterMode=null!=f?f:g.filterMode,g.wrapModeU=null!=h?h:g.wrapModeU,g.wrapModeV=null!=_?_:g.wrapModeV,t.addContentRestorer(new dn(g,a,o)),n(g)}).catch(r)})},t}(sn);dt=c_([og(ol.TextureCube,["texCube","hdr"])],dt);var dn=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return cd(t,e),t.prototype.restoreContent=function(){var e=this;return new nS(function(t,n){var r=e.resource;r.engine.resourceManager._request(e.url,e.requestConfig).then(function(e){var n=new Uint8Array(e);de.decodeFaces(n,de.parseHeader(n),function(e,t){r.setPixelBuffer(nu.PositiveX+e,t,0)}),r.generateMipmaps(),t(r)}).catch(n)})},t}(nl),dr=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){return new nS(function(n,r){var i=e.url,a=cc({},e,{type:"arraybuffer"});t._request(i,a).then(function(e){var a=new lX(t.engine);lj.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)})}).catch(function(e){r(e)})})},t}(sn);dr=c_([og(ol.Audio,["mp3","ogg","wav"])],dr);var di=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,n){var r=e.url;return n._request(r,cc({},e,{type:"text"})).then(function(e){return rf.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=cI(o);!(i=s()).done;){var l=i.value,c=nX.resolveAbsoluteUrl(n,l[1]);r_[c.substring(1)]||a.push(c)}return Promise.all(a.map(function(e){return r.load({type:"ShaderChunk",url:e})}))},t}(sn);di._shaderIncludeRegex=/#include\s+"([./][^\\"]+)"/gm,di=c_([og("ShaderChunk",["glsl"])],di);var da=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}cd(t,e);var n=t.prototype;return n.load=function(e,t){var n=this,r=e.url;return t._request(r,cc({},e,{type:"text"})).then(function(e){var i=n._getBuiltinShader(e);return i?rM.find(i):di._loadChunksInCode(e,r,t).then(function(){return rM.create(e,void 0,r)})})},n._getBuiltinShader=function(e){var n=e.match(t._builtinRegex);if(n&&n[1])return n[1]},t}(sn);da._builtinRegex=/^\s*\/\/\s*@builtin\s+(\w+)/,da=c_([og(ol.Shader,["gs","gsl"])],da);var ds=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){return t._request(e.url,cc({},e,{type:"json"})).then(function(e){var t=new iP;return t.bounciness=e.bounciness,t.dynamicFriction=e.dynamicFriction,t.staticFriction=e.staticFriction,t.bounceCombine=e.bounceCombine,t.frictionCombine=e.frictionCombine,t})},t}(sn);ds=c_([og(ol.PhysicsMaterial,["physMat"])],ds);var dl=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=t.engine;return t._request(e.url,cc({},e,{type:"json"})).then(function(r){var i=r.width,a=r.height,o=r.colorFormats,s=r.depthFormat,l=r.antiAliasing,c=r.autoGenerateMipmaps,u=r.colorTextures,d=o.map(function(e,t){var r,o,s=null==u?void 0:u[t],l=null==(r=null==s?void 0:s.mipmap)||r,c=null!=(o=null==s?void 0:s.isSRGBColorSpace)?o:e===n_.R8G8B8A8,d=new nF(n,i,a,e,l,c);return s&&(null!=s.filterMode&&(d.filterMode=s.filterMode),null!=s.wrapModeU&&(d.wrapModeU=s.wrapModeU),null!=s.wrapModeV&&(d.wrapModeV=s.wrapModeV),null!=s.anisoLevel&&(d.anisoLevel=s.anisoLevel)),d}),h=new nw(n,i,a,d,-1===s?null:s,l);null!=c&&(h.autoGenerateMipmaps=c);for(var _=0,f=d.length;_<f;_++)t._onSubAssetSuccess(e.url,"colorTextures["+_+"]",d[_]);return h})},t}(sn);dl=c_([og(ol.RenderTarget,["renderTarget"])],dl);var dc=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.load=function(e,t){var n=t.engine;return new nS(function(r,i,a){t._request(e.url,cc({},e,{type:"json"})).then(function(e){var i,o=new o9(n,null!=(i=e.name)?i:""),s=new cw(n,cP.Scene,o),l=new cU(e,s,o);return l._collectDependentAssets(e),s._setTaskCompleteProgress=a,l.start(),l.promise.then(function(){var n,i,a=[],s=e.scene.ambient;if(s){var l=s.specularMode===ck.Custom,c=s.diffuseMode===o$.SphericalHarmonics;o.ambientLight.diffuseIntensity=s.diffuseIntensity,o.ambientLight.specularIntensity=s.specularIntensity,o.ambientLight.diffuseMode=s.diffuseMode,o.ambientLight.diffuseSolidColor.copyFrom(s.diffuseSolidColor),l&&s.customAmbientLight&&a.push(t.getResourceByRef(s.customAmbientLight).then(function(e){o.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),s.ambientLight&&(!l||c)&&a.push(t.getResourceByRef(s.ambientLight).then(function(e){l||(o.ambientLight.specularTexture=null==e?void 0:e.specularTexture),c&&(o.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var u=e.scene.background;switch(o.background.mode=u.mode,o.background.mode){case n5.SolidColor:o.background.solidColor.copyFrom(u.color);break;case n5.Sky:if(u.skyMesh&&u.skyMaterial){var d=t.getResourceByRef(u.skyMesh).then(function(e){o.background.sky.mesh=e}),h=t.getResourceByRef(u.skyMaterial).then(function(e){o.background.sky.material=e});a.push(d,h)}else nb.warn("Sky background mode requires skyMesh and skyMaterial");break;case n5.Texture:if(u.texture){var _,f=t.getResourceByRef(u.texture).then(function(e){o.background.texture=e});a.push(f),o.background.textureFillMode=null!=(_=u.textureFillMode)?_:o.background.textureFillMode}}var p=e.scene.shadow;p&&(void 0!=p.castShadows&&(o.castShadows=p.castShadows),void 0!=p.shadowResolution&&(o.shadowResolution=p.shadowResolution),void 0!=p.shadowDistance&&(o.shadowDistance=p.shadowDistance),void 0!=p.shadowCascades&&(o.shadowCascades=p.shadowCascades),void 0!=p.enableTransparentShadow&&(o.enableTransparentShadow=p.enableTransparentShadow),o.shadowTwoCascadeSplits=null!=(n=p.shadowTwoCascadeSplits)?n:o.shadowTwoCascadeSplits,p.shadowFourCascadeSplits&&o.shadowFourCascadeSplits.copyFrom(p.shadowFourCascadeSplits),o.shadowFadeBorder=null!=(i=p.shadowFadeBorder)?i:o.shadowFadeBorder);var m=e.scene.fog;m&&(void 0!=m.fogMode&&(o.fogMode=m.fogMode),void 0!=m.fogStart&&(o.fogStart=m.fogStart),void 0!=m.fogEnd&&(o.fogEnd=m.fogEnd),void 0!=m.fogDensity&&(o.fogDensity=m.fogDensity),void 0!=m.fogColor&&o.fogColor.copyFrom(m.fogColor)),e.scene.postProcess&&nb.warn("Post Process is not supported in scene yet, please add PostProcess component in entity instead.");var g=e.scene.ambientOcclusion;if(g){var v=o.ambientOcclusion;v.enabled=g.enabledAmbientOcclusion,v.intensity=g.intensity,v.radius=g.radius,v.bias=g.bias,v.power=g.power,v.quality=g.quality,v.bilateralThreshold=g.bilateralThreshold,v.minHorizonAngle=g.minHorizonAngle}return Promise.all(a).then(function(){r(o)})})}).catch(i)})},t}(sn);dc=c_([og(ol.Scene,["scene"],!0)],dc);var du=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(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=void 0===o?1:o,l=i.type,c=i.range,u=i.spot,d=e.glTFResource;if("directional"===l?r=t.addComponent(o2):"point"===l?r=t.addComponent(o3):"spot"===l&&(r=t.addComponent(o4)),a&&r.color.set(a[0]*s,a[1]*s,a[2]*s,1),c&&!cD(r,o2)&&(r.distance=c),u&&cD(r,o4)){var h=u.innerConeAngle,_=void 0===h?0:h,f=u.outerConeAngle,p=void 0===f?Math.PI/4:f;r.angle=_,r.penumbra=p-_}d.lights||(d.lights=[]),d.lights.push(r)},t}(uR);du=c_([uP("KHR_lights_punctual",uE.AdditiveParse)],du);var dd=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.clearcoatFactor,i=n.clearcoatTexture,a=n.clearcoatRoughnessFactor,o=n.clearcoatRoughnessTexture,s=n.clearcoatNormalTexture;t.clearCoat=void 0===r?0:r,t.clearCoatRoughness=void 0===a?0:a,i&&(uI._checkOtherTextureTransform(i,"Clear coat"),e.get(uh.Texture,i.index).then(function(e){t.clearCoatTexture=e}).catch(function(e){nb.error("KHR_materials_clearcoat: clearcoat texture error",e)})),o&&(uI._checkOtherTextureTransform(o,"Clear coat roughness"),e.get(uh.Texture,o.index).then(function(e){t.clearCoatRoughnessTexture=e}).catch(function(e){nb.error("KHR_materials_clearcoat: clearcoat roughness texture error",e)})),s&&(uI._checkOtherTextureTransform(s,"Clear coat normal"),e.get(uh.Texture,s.index).then(function(e){t.clearCoatNormalTexture=e}).catch(function(e){nb.error("KHR_materials_clearcoat: clearcoat normal texture error",e)}))},t}(uR);dd=c_([uP("KHR_materials_clearcoat",uE.AdditiveParse)],dd);var dh=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},t}(uR);dh=c_([uP("KHR_materials_ior",uE.AdditiveParse)],dh);var d_=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.sheenColorFactor,i=n.sheenColorTexture,a=n.sheenRoughnessFactor,o=n.sheenRoughnessTexture;r&&t.sheenColor.set(r[0],r[1],r[2],void 0),t.sheenRoughness=void 0===a?0:a,i&&(uI._checkOtherTextureTransform(i,"Sheen texture"),e.get(uh.Texture,i.index).then(function(e){t.sheenColorTexture=e}).catch(function(e){nb.error("KHR_materials_sheen: sheenColorTexture error",e)})),o&&(uI._checkOtherTextureTransform(o,"SheenRoughness texture"),e.get(uh.Texture,o.index).then(function(e){t.sheenRoughnessTexture=e}).catch(function(e){nb.error("KHR_materials_sheen: sheenRoughnessTexture error",e)}))},t}(uR);d_=c_([uP("KHR_materials_sheen",uE.AdditiveParse)],d_);var df=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.transmissionFactor,i=n.transmissionTexture;t.transmission=void 0===r?0:r,i&&(uI._checkOtherTextureTransform(i,"Transmission texture"),e.get(uh.Texture,i.index).then(function(e){t.transmissionTexture=e}).catch(function(e){nb.error("KHR_materials_transmission: transmission texture error",e)}))},t}(uR);df=c_([uP("KHR_materials_transmission",uE.AdditiveParse)],df);var dp=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.createAndParse=function(e,t,n){var r=new r7(e.glTFResource.engine);return r.name=n.name,uI._parseStandardProperty(e,r,n),r},t}(uR);dp=c_([uP("KHR_materials_unlit",uE.CreateAndParse)],dp);var dm=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(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(uh.Material,s).then(function(e){o.push({renderer:t,material:e,variants:l.map(function(e){return r[e].name})})}).catch(function(e){nb.error("KHR_materials_variants: material error",e)})}(s)},t}(uR);dm=c_([uP("KHR_materials_variants",uE.AdditiveParse)],dm);var dg=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.thicknessFactor,i=n.thicknessTexture,a=n.attenuationDistance,o=n.attenuationColor;t.thickness=void 0===r?0:r,t.attenuationDistance=void 0===a?1/0:a,o&&t.attenuationColor.set(o[0],o[1],o[2],void 0),i&&(uI._checkOtherTextureTransform(i,"Thickness texture"),e.get(uh.Texture,i.index).then(function(e){t.thicknessTexture=e}).catch(function(e){nb.error("KHR_materials_volume: thickness texture error",e)}))},t}(uR);dg=c_([uP("KHR_materials_volume",uE.AdditiveParse)],dg);var dv=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t}(uR);dv=c_([uP("KHR_mesh_quantization",uE.AdditiveParse)],dv);var dy=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.createAndParse=function(e,t,n){var r=e.glTF,i=e.glTFResource,a=i.engine,o=i.url,s=n.sampler,l=n.name,c=t.source,u=r.images[c],d=u.uri,h=u.bufferView,_=u.mimeType,f=u.name,p=void 0!==s&&um.getSamplerInfo(r.samplers[s]);if(d){var m=d.lastIndexOf("."),g=a.resourceManager.load({url:nX.resolveAbsoluteUrl(o,d),type:ol.KTX2}).onProgress(void 0,e._onTaskDetail).then(function(e){return e.name||(e.name=l||f||"texture_"+m),void 0!==s&&um.parseSampler(e,p),e});return e._addTaskCompletePromise(g),g}var v=r.bufferViews[h];return e.get(uh.Buffer,v.buffer).then(function(t){var n=new Uint8Array(t,v.byteOffset,v.byteLength);return c2._parseBuffer(n,a).then(function(e){var t=e.ktx2Container,n=e.engine,r=e.result,i=e.targetFormat,a=e.params;return c2._createTextureByBuffer(n,t.isSRGB,r,i,a)}).then(function(t){t.name=l||f||"texture_"+h,void 0!==s&&um.parseSampler(t,p);var n=new uy(t,v,_);return e.contentRestorer.bufferTextures.push(n),t})}).catch(function(e){nb.error("KHR_texture_basisu: buffer error",e)})},t}(uR);dy=c_([uP("KHR_texture_basisu",uE.CreateAndParse)],dy);var dx=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(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&&nb.warn("rotation in KHR_texture_transform is not supported now"),o&&nb.warn("texCoord in KHR_texture_transform is not supported now")},t}(uR);dx=c_([uP("KHR_texture_transform",uE.AdditiveParse)],dx);var dA=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.createAndParse=function(e,t){var n=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(n),n},t}(uR);dA=c_([uP("GALACEAN_materials_remap",uE.CreateAndParse)],dA);var db=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new sf;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},t}(uR);db=c_([uP("GALACEAN_animation_event",uE.AdditiveParse)],db);var dS=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.createAndParse=function(e,t){return e.get(uh.Buffer,t.buffer).then(function(e){return c7().then(function(n){return n.decodeGltfBuffer(t.count,t.byteStride,new Uint8Array(e,t.byteOffset,t.byteLength),t.mode,t.filter)})}).catch(function(e){nb.error("EXT_meshopt_compression: buffer error",e)})},t}(uR);dS=c_([uP("EXT_meshopt_compression",uE.CreateAndParse)],dS);var dC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.anisotropyStrength,i=n.anisotropyRotation,a=n.anisotropyTexture;t.anisotropy=void 0===r?0:r,t.anisotropyRotation=void 0===i?0:i,a&&(uI._checkOtherTextureTransform(a,"Anisotropy texture"),e.get(uh.Texture,a.index).then(function(e){t.anisotropyTexture=e}).catch(function(e){nb.error("KHR_materials_anisotropy: anisotropy texture error",e)}))},t}(uR);dC=c_([uP("KHR_materials_anisotropy",uE.AdditiveParse)],dC);var dT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.iridescenceFactor,i=n.iridescenceTexture,a=n.iridescenceIor,o=n.iridescenceThicknessMinimum,s=n.iridescenceThicknessMaximum,l=n.iridescenceThicknessTexture;t.iridescence=void 0===r?0:r,t.iridescenceIOR=void 0===a?1.3:a,t.iridescenceThicknessRange.set(void 0===o?100:o,void 0===s?400:s),i&&(uI._checkOtherTextureTransform(i,"Iridescence texture"),e.get(uh.Texture,i.index).then(function(e){t.iridescenceTexture=e}).catch(function(e){nb.error("KHR_materials_iridescence: iridescence texture error",e)})),l&&(uI._checkOtherTextureTransform(l,"IridescenceThickness texture"),e.get(uh.Texture,l.index).then(function(e){t.iridescenceThicknessTexture=e}).catch(function(e){nb.error("KHR_materials_iridescence: iridescence thickness error",e)}))},t}(uR);dT=c_([uP("KHR_materials_iridescence",uE.AdditiveParse)],dT);var dR=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.specularFactor,i=n.specularTexture,a=n.specularColorFactor,o=n.specularColorTexture;t.specularIntensity=void 0===r?1:r,a&&t.specularColor.set(a[0],a[1],a[2],void 0),i&&(uI._checkOtherTextureTransform(i,"Specular intensity texture"),e.get(uh.Texture,i.index).then(function(e){t.specularIntensityTexture=e}).catch(function(e){nb.error("KHR_materials_specular: specularTexture error",e)})),o&&(uI._checkOtherTextureTransform(o,"Specular color texture"),e.get(uh.Texture,o.index).then(function(e){t.specularColorTexture=e}).catch(function(e){nb.error("KHR_materials_specular: SpecularColorTexture error",e)}))},t}(uR);dR=c_([uP("KHR_materials_specular",uE.AdditiveParse)],dR);var dE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return cd(t,e),t.prototype.createAndParse=function(e,t,n,r,i){var a=t.source,o=n.sampler,s=n.source,l=void 0===s?0:s,c=n.name;return nR._checkWebpSupported().then(function(t){return uk._parseTexture(e,t?a:l,r,o,c,i)})},t}(uR);dE=c_([uP("EXT_texture_webp",uE.CreateAndParse)],dE);var dM="2.0.0-alpha.21";for(var dP in console.log("Galacean Engine Version: "+dM),lK)sn.registerClass(dP,lK[dP]);export{un as AccessorType,o0 as AmbientLight,o8 as AmbientOcclusion,ia as AmbientOcclusionQuality,sv as AnimationArrayCurve,sy as AnimationBoolCurve,sp as AnimationClip,s_ as AnimationClipCurveBinding,cb as AnimationClipDecoder,sx as AnimationColorCurve,sg as AnimationCurve,sf as AnimationEvent,sA as AnimationFloatArrayCurve,sb as AnimationFloatCurve,sS as AnimationQuaternionCurve,sM as AnimationRectCurve,sE as AnimationRefCurve,sP as AnimationStringCurve,sC as AnimationVector2Curve,sT as AnimationVector3Curve,sR as AnimationVector4Curve,sG as Animator,sN as AnimatorCondition,sw as AnimatorConditionMode,sW as AnimatorController,sQ as AnimatorControllerLayer,sH as AnimatorControllerParameter,sF as AnimatorCullingMode,sL as AnimatorLayerBlendingMode,sJ as AnimatorLayerMask,sY as AnimatorState,sK as AnimatorStateMachine,sO as AnimatorStateTransition,rX as AntiAliasing,nS as AssetPromise,ol as AssetType,lX as AudioClip,lj as AudioManager,lY as AudioSource,rD as Background,n5 as BackgroundMode,n9 as BackgroundTextureFillMode,r4 as BaseMaterial,as as BasicRenderPipeline,i9 as BatchUtils,n6 as BlendFactor,r1 as BlendMode,n7 as BlendOperation,aw as BlendShape,aM as BlendShapeFrame,rS as BlendState,r8 as BlinnPhongMaterial,it as Blitter,iv as BloomDownScaleMode,iy as BloomEffect,rz as BoolUpdateFlag,tG as BoundingBox,tX as BoundingFrustum,tz as BoundingSphere,iq as BoxColliderShape,lP as BoxShape,ax as Buffer,sa as BufferAsset,aT as BufferBindFlag,ud as BufferInfo,aV as BufferMesh,cg as BufferReader,av as BufferUsage,aS as BufferUtil,lT as Burst,r0 as Camera,rj as CameraClearFlags,rY as CameraModifyFlags,rK as CameraType,oQ as Canvas,i$ as CapsuleColliderShape,t9 as CharRenderInfo,iR as CharacterController,lF as CircleShape,oR as ClearableObjectPool,na as CloneManager,rB as CloneUtils,iC as Collider,iw as ColliderShape,iU as ColliderShapeUpAxis,iO as Collision,iD as CollisionDetectionMode,tH as CollisionUtil,tJ as Color,lc as ColorOverLifetimeModule,re as ColorWriteMask,rt as CompareFunction,rN as Component,lD as ConeEmitType,lL as ConeShape,iN as ContactPoint,tB as ContainmentType,nl as ContentRestorer,iz as ControllerCollisionFlag,iT as ControllerNonWalkableMode,lW as CubeProbe,rn as CullMode,lv as CurveKey,nC as DataType,rk as DependentMode,rC as DepthState,rQ as DepthTextureMode,o$ as DiffuseMode,o2 as DirectLight,nQ as DisorderedArray,rq as Downsampling,iL as DynamicCollider,iB as DynamicColliderConstraints,ld as EmissionModule,oK as Engine,no as EngineObject,a7 as Entity,a6 as EntityModifyFlags,nG as EventDispatcher,cx as FileHeader,i4 as FinalPass,iW as FixedJoint,oJ as FogMode,nV as Font,nB as FontStyle,tN as FrustumFace,nT as GLCapabilityType,lQ as GLCompressedTextureInternalFormat,uF as GLTFAnimationParser,uG as GLTFAnimatorControllerParser,uL as GLTFBufferParser,uz as GLTFBufferViewParser,uD as GLTFEntityParser,uE as GLTFExtensionMode,uR as GLTFExtensionParser,uH as GLTFLoader,uI as GLTFMaterialParser,uN as GLTFMeshParser,uM as GLTFParser,uu as GLTFParserContext,uh as GLTFParserType,ue as GLTFResource,uO as GLTFSceneParser,uw as GLTFSchemaParser,uV as GLTFSkinParser,uk as GLTFTextureParser,um as GLTFUtils,uU as GLTFValidator,lo as GradientAlphaKey,la as GradientColorKey,de as HDRDecoder,lB as HemisphereShape,cO as HierarchyParser,ij as HingeJoint,iI as HitResult,aF as IndexBufferBinding,aA as IndexFormat,oN as InputManager,cA as InterpolableValueType,sm as InterpolationType,si as JSONAsset,iG as Joint,iK as JointLimits,iQ as JointMotor,c2 as KTX2Loader,cQ as KTX2TargetFormat,sq as Keyframe,oC as Keys,rU as Layer,sZ as LayerPathMask,o1 as Light,l_ as LimitVelocityOverLifetimeModule,sn as Loader,nb as Logger,rZ as MSAASamples,lp as MainModule,r3 as Material,cV as MaterialLoaderType,tk as MathUtil,tK as Matrix,tj as Matrix3x3,aI as Mesh,iF as MeshColliderShape,iE as MeshColliderShapeCookingFlag,cS as MeshDecoder,ak as MeshRenderer,lI as MeshShape,aR as MeshTopology,aG as ModelMesh,nI as OverflowMode,r6 as PBRMaterial,cw as ParserContext,cP as ParserType,lu as ParticleCompositeCurve,ls as ParticleCompositeGradient,lg as ParticleCurve,lt as ParticleCurveMode,lb as ParticleGenerator,li as ParticleGradient,ln as ParticleGradientMode,lC as ParticleMaterial,s2 as ParticleRenderMode,s8 as ParticleRenderer,lf as ParticleScaleMode,lw as ParticleShapeArcMode,lM as ParticleShapeType,s3 as ParticleSimulationSpace,s4 as ParticleStopMode,iP as PhysicsMaterial,iM as PhysicsMaterialCombineMode,iV as PhysicsScene,rh as PipelineStage,tW as Plane,iJ as PlaneColliderShape,tI as PlaneIntersectionType,t2 as Platform,o3 as PointLight,oM as Pointer,oA as PointerButton,ow as PointerEventData,oF as PointerEventEmitter,oE as PointerPhase,ib as PostProcess,ig as PostProcessEffect,ic as PostProcessEffectBoolParameter,id as PostProcessEffectColorParameter,im as PostProcessEffectEnumParameter,il as PostProcessEffectFloatParameter,is as PostProcessEffectParameter,iu as PostProcessEffectTextureParameter,ih as PostProcessEffectVector2Parameter,i_ as PostProcessEffectVector3Parameter,ip as PostProcessEffectVector4Parameter,i0 as PostProcessManager,i2 as PostProcessPass,i1 as PostProcessPassEvent,i3 as PostProcessUberPass,cN as PrefabResource,aB as Primitive,a0 as PrimitiveMesh,lU as Probe,tY as Quaternion,t1 as Rand,rT as RasterState,tQ as Ray,t$ as Rect,ns as ReferResource,cF as ReflectionParser,r9 as RefractionMode,nc as RenderBufferDepthFormat,r2 as RenderFace,i5 as RenderQueue,al as RenderQueueFlags,rr as RenderQueueType,rE as RenderState,ri as RenderStateElementKey,nw as RenderTarget,rb as RenderTargetBlendState,ah as Renderer,a_ as RendererUpdateFlags,od as RenderingStatistics,rJ as ReplacementFailureStrategy,om as ResourceManager,ot as ReturnableObjectPool,lm as RotationOverLifetimeModule,oc as SafeLoopArray,o9 as Scene,ou as SceneManager,cU as SceneParser,o7 as Script,ay as SetDataOptions,rM as Shader,rP as ShaderData,ra as ShaderDataGroup,rf as ShaderFactory,ro as ShaderLanguage,r_ as ShaderLib,rc as ShaderMacro,ru as ShaderMacroCollection,rx as ShaderPass,nH as ShaderProperty,rs as ShaderPropertyType,rp as ShaderTagKey,an as ShadowCascadesMode,i7 as ShadowResolution,ae as ShadowType,st as Signal,nU as SimpleSpriteAssembler,ly as SizeOverLifetimeModule,a1 as Skin,a3 as SkinnedMeshRenderer,rL as Sky,s$ as SkyBoxMaterial,s1 as SkyProceduralMaterial,nz as SlicedSpriteAssembler,ck as SpecularMode,iZ as SphereColliderShape,lN as SphereShape,t0 as SphericalHarmonics3,o4 as SpotLight,iY as SpringJoint,n8 as Sprite,nJ as SpriteAtlas,n$ as SpriteDrawMode,af as SpriteMask,n0 as SpriteMaskInteraction,ad as SpriteMaskLayer,n1 as SpriteModifyFlags,ap as SpriteRenderer,nq as SpriteTileMode,sj as StateMachineScript,ik as StaticCollider,rl as StencilOperation,rR as StencilState,nO as SubFont,aD as SubMesh,aL as SubPrimitive,rA as SubShader,s0 as SunMode,nR as SystemInfo,sr as TextAsset,n2 as TextHorizontalAlignment,am as TextRenderer,nN as TextUtils,n3 as TextVerticalAlignment,nE as Texture,nF as Texture2D,nL as Texture2DArray,cL as Texture2DDecoder,r5 as TextureCoordinate,nP as TextureCube,nu as TextureCubeFace,nd as TextureDepthCompareFunction,nh as TextureFilterMode,n_ as TextureFormat,lx as TextureSheetAnimationModule,nf as TextureUsage,nM as TextureUtils,np as TextureWrapMode,nZ as TiledSpriteAssembler,nW as Time,iA as TonemappingEffect,ix as TonemappingMode,lk as TrailMaterial,lV as TrailRenderer,lO as TrailTextureMode,rG as Transform,rH as TransformModifyFlags,r7 as UnlitMaterial,nX as Utils,tq as Vector2,tU as Vector3,tZ as Vector4,lA as VelocityOverLifetimeModule,az as VertexAttribute,aO as VertexBufferBinding,aC as VertexElement,ab as VertexElementFormat,l1 as WebCanvas,l2 as WebGLEngine,cl as WebGLGraphicDevice,cs as WebGLMode,sV as WrapMode,oY as XRManager,nn as assignmentClone,cz as decode,cy as decoder,cv as decoderMap,ni as deepClone,rV as dependentComponents,nt as ignoreClone,uK as parseSingleKTX,uP as registerGLTFExtension,up as registerGLTFParser,oB as registerPointerEventEmitter,of as request,og as resourceLoader,nr as shallowClone,dM as version};
2
+ //# sourceMappingURL=bundled.module.min.js.map