@galacean/engine 2.0.0-alpha.1 → 2.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +8691 -8294
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/bundled.module.js +52761 -0
- package/dist/bundled.module.js.map +1 -0
- package/dist/bundled.module.min.js +2 -0
- package/dist/bundled.module.min.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +7 -5
|
@@ -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,T,C,R,E,M,P,w,F,D,B,L,I,N,O,V,k,U,z,G,H,X,W,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,eT,eC,eR,eE,eM,eP,ew,eF,eD,eB,eL,eI,eN,eO,eV,ek,eU,ez,eG,eH,eX,eW,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,tT,tC,tR,tE,tM,tP,tw,tF,tD,tB=((tv={})[tv.Disjoint=0]="Disjoint",tv[tv.Contains=1]="Contains",tv[tv.Intersects=2]="Intersects",tv),tL=((n={})[n.Back=0]="Back",n[n.Front=1]="Front",n[n.Intersecting=2]="Intersecting",n),tI=((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 tN(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 tO(e,t,n){return t&&tN(e.prototype,t),n&&tN(e,n),e}var tV=/*#__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}();tV.zeroTolerance=1e-6,tV.radToDegreeFactor=180/Math.PI,tV.degreeToRadFactor=Math.PI/180;var tk=/*#__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 tV.equals(e._x,t._x)&&tV.equals(e._y,t._y)&&tV.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>tV.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)},tO(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}();tk._zero=new tk(0,0,0),tk._one=new tk(1,1,1);var tU=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new tk,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)tk.add(t[a],i,i);tk.scale(i,1/r,n.center);for(var o=0,s=0;s<r;++s){var l=tk.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=tk.distance(n,i)},e}();tU._tempVec30=new tk;var tz=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new tk,this.max=new tk,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 tk;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){tk.subtract(e,t,n.min),tk.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];tk.min(n,o,n),tk.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),tk.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))),tk.subtract(i,a,r.min),tk.add(i,a,r.max)},e.merge=function(e,t,n){return tk.min(e.min,t.min,n.min),tk.max(e.max,t.max,n.max),n},e}();tz._tempVec30=new tk,tz._tempVec31=new tk;var tG=/*#__PURE__*/function(){function e(){}return e.intersectionPointThreePlanes=function(t,n,r,i){var a=t.normal,o=n.normal,s=r.normal;tk.cross(o,s,e._tempVec30),tk.cross(s,a,e._tempVec31),tk.cross(a,o,e._tempVec32);var l=-tk.dot(a,e._tempVec30),c=-tk.dot(o,e._tempVec31),u=-tk.dot(s,e._tempVec32);tk.scale(e._tempVec30,t.distance/l,e._tempVec30),tk.scale(e._tempVec31,n.distance/c,e._tempVec31),tk.scale(e._tempVec32,r.distance/u,e._tempVec32),tk.add(e._tempVec30,e._tempVec31,i),tk.add(i,e._tempVec32,i)},e.distancePlaneAndPoint=function(e,t){return tk.dot(e.normal,t)+e.distance},e.intersectsPlaneAndPoint=function(t,n){var r=e.distancePlaneAndPoint(t,n);return r>0?tL.Front:r<0?tL.Back:tL.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))?tL.Back:e.distancePlaneAndPoint(t,s)>0?tL.Front:tL.Intersecting},e.intersectsPlaneAndSphere=function(t,n){var r=n.center,i=n.radius,a=e.distancePlaneAndPoint(t,r);return a>i?tL.Front:a<-i?tL.Back:tL.Intersecting},e.intersectsRayAndPlane=function(e,t){var n=t.normal,r=tV.zeroTolerance,i=tk.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=tk.dot(n,e.origin),o=(-t.distance-a)/i;if(o<0){if(o<-r)return -1;o=0}return o},e.intersectsRayAndBox=function(e,t){var n=tV.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,T=(a.z-h)*S,C=(o.z-h)*S;if(T>C){var R=T;T=C,C=R}if((_=Math.max(T,_))>(f=Math.min(C,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;tk.subtract(r,a,s);var l=tk.dot(s,i),c=tk.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 tk.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))),tk.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),tk.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)<tV.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.far,n))<tV.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.left,n))<tV.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.right,n))<tV.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.top,n))<tV.zeroTolerance?tB.Intersects:r<0?tB.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.bottom,n))<tV.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)===tL.Back)return tB.Disjoint;e.intersectsPlaneAndPoint(c,o)===tL.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===tL.Back)return tB.Disjoint;if(o===tL.Intersecting){r=tB.Intersects;break}}return r},e}();tG._tempVec30=new tk,tG._tempVec31=new tk,tG._tempVec32=new tk;var tH=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new tk,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();tk.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 tH,this.far=new tH,this.left=new tH,this.right=new tH,this.top=new tH,this.bottom=new tH,e&&this.calculateFromMatrix(e)}var t=e.prototype;return t.getPlane=function(e){switch(e){case tI.Near:return this.near;case tI.Far:return this.far;case tI.Left:return this.left;case tI.Right:return this.right;case tI.Bottom:return this.bottom;case tI.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 tG.intersectsFrustumAndBox(this,e)},t.intersectsSphere=function(e){return tG.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}(),tW=/*#__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 tV.equals(n[0],r[0])&&tV.equals(n[1],r[1])&&tV.equals(n[2],r[2])&&tV.equals(n[3],r[3])&&tV.equals(n[4],r[4])&&tV.equals(n[5],r[5])&&tV.equals(n[6],r[6])&&tV.equals(n[7],r[7])&&tV.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,T=a*d-s*c,C=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,D=x*F-A*w+b*P+S*M-T*E+C*R;if(!D)return null;D=1/D,r[0]=(c*F-u*w+d*P)*D,r[1]=(u*M-l*F-d*E)*D,r[2]=(l*w-c*M+d*R)*D,r[3]=(o*w-a*F-s*P)*D,r[4]=(i*F-o*M+s*E)*D,r[5]=(a*M-i*w-s*R)*D,r[6]=(g*C-v*T+y*S)*D,r[7]=(v*b-m*C-y*A)*D,r[8]=(m*T-g*b+y*x)*D},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}(),tj=/*#__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<tV.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-tV.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-tV.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 tV.equals(e._x,t._x)&&tV.equals(e._y,t._y)&&tV.equals(e._z,t._z)&&tV.equals(e._w,t._w)},e.rotationAxisAngle=function(t,n,r){var i=e._tempVector3;tk.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>tV.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-tV.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>tV.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)},tO(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)<tV.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,null==this._onValueChanged||this._onValueChanged.call(this)}}]),e}();tj._tempVector3=new tk,tj._tempQuat1=new tj;var tY=/*#__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)<tV.zeroTolerance||Math.abs(g)<tV.zeroTolerance||Math.abs(v)<tV.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,tj.rotationMatrix3x3(i,n),!0},t.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>tV.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],T=i[2],C=i[3],R=i[4],E=i[5],M=i[6],P=i[7],w=i[8],F=i[9],D=i[10],B=i[11],L=i[12],I=i[13],N=i[14],O=i[15];a[0]=o*b+u*S+f*T+v*C,a[1]=s*b+d*S+p*T+y*C,a[2]=l*b+h*S+m*T+x*C,a[3]=c*b+_*S+g*T+A*C,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*D+v*B,a[9]=s*w+d*F+p*D+y*B,a[10]=l*w+h*F+m*D+x*B,a[11]=c*w+_*F+g*D+A*B,a[12]=o*L+u*I+f*N+v*O,a[13]=s*L+d*I+p*N+y*O,a[14]=l*L+h*I+m*N+x*O,a[15]=c*L+_*I+g*N+A*O},e.equals=function(e,t){var n=e.elements,r=t.elements;return tV.equals(n[0],r[0])&&tV.equals(n[1],r[1])&&tV.equals(n[2],r[2])&&tV.equals(n[3],r[3])&&tV.equals(n[4],r[4])&&tV.equals(n[5],r[5])&&tV.equals(n[6],r[6])&&tV.equals(n[7],r[7])&&tV.equals(n[8],r[8])&&tV.equals(n[9],r[9])&&tV.equals(n[10],r[10])&&tV.equals(n[11],r[11])&&tV.equals(n[12],r[12])&&tV.equals(n[13],r[13])&&tV.equals(n[14],r[14])&&tV.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)<tV.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,T=a*d-s*c,C=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,D=x*F-A*w+b*P+S*M-T*E+C*R;if(!D)return null;D=1/D,r[0]=(c*F-u*w+d*P)*D,r[1]=(o*w-a*F-s*P)*D,r[2]=(g*C-v*T+y*S)*D,r[3]=(f*T-_*C-p*S)*D,r[4]=(u*M-l*F-d*E)*D,r[5]=(i*F-o*M+s*E)*D,r[6]=(v*b-m*C-y*A)*D,r[7]=(h*C-f*b+p*A)*D,r[8]=(l*w-c*M+d*R)*D,r[9]=(a*M-i*w-s*R)*D,r[10]=(m*T-g*b+y*x)*D,r[11]=(_*b-h*T-p*x)*D,r[12]=(c*E-l*P-u*R)*D,r[13]=(i*P-a*E+o*R)*D,r[14]=(g*A-m*S-v*x)*D,r[15]=(h*S-_*A+f*x)*D},e.lookAt=function(t,n,r,i){var a=i.elements,o=e._tempVec30,s=e._tempVec31,l=e._tempVec32;tk.subtract(t,n,l),l.normalize(),tk.cross(r,l,o),o.normalize(),tk.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]=-tk.dot(o,t),a[13]=-tk.dot(s,t),a[14]=-tk.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)<tV.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],T=d[11],C=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,D=l*c*o-s*i,B=c*c*o+a;h[0]=_*C+g*R+A*E,h[1]=f*C+v*R+b*E,h[2]=p*C+y*R+S*E,h[3]=m*C+x*R+T*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+T*w,h[8]=_*F+g*D+A*B,h[9]=f*F+v*D+b*B,h[10]=p*F+y*D+S*B,h[11]=m*F+x*D+T*B,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}();tY._tempVec30=new tk,tY._tempVec31=new tk,tY._tempVec32=new tk,tY._tempMat30=new tW,tY._identity=new tY(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var tK=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new tk,this.direction=new tk,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}var t=e.prototype;return t.intersectPlane=function(e){return tG.intersectsRayAndPlane(this,e)},t.intersectSphere=function(e){return tG.intersectsRayAndSphere(this,e)},t.intersectBox=function(e){return tG.intersectsRayAndBox(this,e)},t.getPoint=function(e,t){return tk.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 tV.equals(e._x,t._x)&&tV.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>tV.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)},tO(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 tq=/*#__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 tV.equals(e._x,t._x)&&tV.equals(e._y,t._y)&&tV.equals(e._z,t._z)&&tV.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>tV.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)},tO(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}();tq._zero=new tq(0,0,0,0),tq._one=new tq(1,1,1,1);var tZ=/*#__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 tV.equals(e._r,t._r)&&tV.equals(e._g,t._g)&&tV.equals(e._b,t._b)&&tV.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)},tO(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}(),tJ=/*#__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},tO(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}(),t$=/*#__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}(),t0=/*#__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}(),t1=((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 t2(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 t3(e,t,n){return t&&t2(e.prototype,t),n&&t2(e,n),e}function t4(e,t){return(t4=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function t8(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&&t4(e,t)}var t5=/*#__PURE__*/function(){function e(){this.localPositions=new tq}return e.prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},e}();function t9(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 t6(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):e(t,n)}t5.triangles=[0,2,1,2,0,3],"function"==typeof SuppressedError&&SuppressedError;var t7=((a={})[a.Ignore=0]="Ignore",a[a.Assignment=1]="Assignment",a[a.Shallow=2]="Shallow",a[a.Deep=3]="Deep",a);function ne(e,t){ni.registerCloneMode(e,t,t7.Ignore)}function nt(e,t){ni.registerCloneMode(e,t,t7.Assignment)}function nn(e,t){ni.registerCloneMode(e,t,t7.Shallow)}function nr(e,t){ni.registerCloneMode(e,t,t7.Deep)}var ni=/*#__PURE__*/function(){function e(){}return e.registerCloneMode=function(t,n,r){var i=e._subCloneModeMap.get(t.constructor);i||(i=Object.create(null),e._subCloneModeMap.set(t.constructor,i)),i[n]=r},e.getCloneMode=function(t){var n=e._cloneModeMap.get(t);if(!n){n=Object.create(null),e._cloneModeMap.set(t,n);for(var r=e._objectType,i=e._subCloneModeMap;t!==r;){var a=i.get(t);a&&Object.assign(n,a),t=Object.getPrototypeOf(t)}}return n},e.cloneProperty=function(t,n,r,i,a,o,s){if(i!==t7.Ignore){var l=t[r];if(t6(l,Object)){if(void 0===i||i===t7.Assignment){n[r]=l;return}switch(l.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var c=n[r];null==c||c.length!==l.length?n[r]=l.slice():c.set(l);break;case Array:var u=n[r],d=l.length;null==u?n[r]=u=Array(d):u.length=d;for(var h=0;h<d;h++)e.cloneProperty(l,u,h,i,a,o,s);break;default:var _=n[r];if(_||((_=s.get(l))||(_=new l.constructor,s.set(l,_)),n[r]=_),l.copyFrom)_.copyFrom(l);else{var f=e.getCloneMode(l.constructor);for(var p in l)e.cloneProperty(l,_,p,f[p],a,o,s);l._cloneTo&&l._cloneTo(_,a,o)}}}else n[r]=l}},e.deepCloneObject=function(t,n,r){for(var i in t)e.cloneProperty(t,n,i,t7.Deep,null,null,r)},e}();ni._subCloneModeMap=new Map,ni._cloneModeMap=new Map,ni._objectType=Object.getPrototypeOf(Object);var na=/*#__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)}},t3(e,[{key:"engine",get:function(){return this._engine}},{key:"pendingDestroy",get:function(){return this._pendingDestroy}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();na._instanceIdCounter=0,t9([ne],na.prototype,"instanceId",void 0),t9([ne],na.prototype,"_engine",void 0);var no=/*#__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}t8(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)},t3(t,[{key:"refCount",get:function(){return this._refCount}}]),t}(na),ns=function(e){this.resource=e},nl=((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),nc=((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),nu=((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),nd=((c={})[c.Point=0]="Point",c[c.Bilinear=1]="Bilinear",c[c.Trilinear=2]="Trilinear",c),nh=((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),n_=((d={})[d.Static=0]="Static",d[d.Dynamic=1]="Dynamic",d),nf=((h={})[h.Clamp=0]="Clamp",h[h.Repeat=1]="Repeat",h[h.Mirror=2]="Mirror",h),np=/*#__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 t8(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},t3(t,[{key:"isContentLost",get:function(){return this._isContentLost}}]),t}(no),nm=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},ng=console.log.bind(console),nv=console.info.bind(console),ny=console.warn.bind(console),nx=console.error.bind(console),nA={debug:nm,info:nm,warn:nm,error:nm,isEnabled:!1,enable:function(){this.debug=ng,this.info=nv,this.warn=ny,this.error=nx,this.isEnabled=!0},disable:function(){this.debug=nm,this.info=nm,this.warn=nm,this.error=nm,this.isEnabled=!1}},nb=/*#__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()}:t6(t,e)||t6(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){t6(t,e)||t6(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)})},t3(e,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),e}(),nS=((_={})[_.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),nC=/*#__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=t1.IPhone:/iPad/i.test(n)?e.platform=t1.IPad:/Android/i.test(n)?e.platform=t1.Android:/Macintosh/i.test(n)&&(e.platform=t1.Mac),e.platform){case t1.IPhone:this.operatingSystem=this._parseAppleMobileOSVersion(n,"iPhone OS");break;case t1.IPad:this.operatingSystem=this._parseAppleMobileOSVersion(n,"iPad OS");break;case t1.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case t1.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 nb(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 nh.R16G16B16A16:if(!n.canIUse(nT.textureHalfFloat))return!1;break;case nh.R32G32B32A32:if(!n.canIUse(nT.textureFloat))return!1;break;case nh.Depth16:case nh.Depth24Stencil8:case nh.Depth:case nh.DepthStencil:if(!n.canIUse(nT.depthTexture))return!1;break;case nh.R11G11B10_UFloat:case nh.R32G32B32A32_UInt:case nh.Depth24:case nh.Depth32:case nh.Depth32Stencil8:case nh.R8:case nh.R8G8:return n.isWebGL2}return!0},t3(e,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),e}();nC.platform=t1.Unknown,nC.operatingSystem="",nC._isBrowser=!0,nC._simdSupported=null,nC._webpSupported=null,nC._initialize();var nR=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){var s;if(!nC.supportsTextureFormat(t,i))throw Error("Texture format is not supported:"+nh[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}t8(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 nh.R32G32B32A32_UInt===this._format},t3(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!==nd.Point&&this._isIntFormat()){e=nd.Point,nA.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&&(nA.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(nA.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}(np),nE=/*#__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 nh.R8G8B8:case nh.R8G8B8A8:case nh.BC1:case nh.BC3:case nh.BC7:case nh.ETC2_RGB:case nh.ETC2_RGBA8:case nh.ASTC_4x4:return!0;default:return!1}},e.supportMipmaps=function(e,t,n){return n||tV.isPowerOf2(e)&&tV.isPowerOf2(t)},e.supportGenerateMipmaps=function(e,t,n,r){return!t||!n||!!(r&&e===nh.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 nh.R8:case nh.Alpha8:return t*n;case nh.R8G8:case nh.LuminanceAlpha:return t*n*2;case nh.R8G8B8:return t*n*3;case nh.R8G8B8A8:case nh.R11G11B10_UFloat:return t*n*4;case nh.R4G4B4A4:case nh.R5G5B5A1:case nh.R5G6B5:return t*n*2;case nh.R16G16B16A16:return t*n*8;case nh.R32G32B32A32:case nh.R32G32B32A32_UInt:return t*n*16;case nh.BC1:return Math.ceil(t/4)*Math.ceil(n/4)*8;case nh.BC3:case nh.BC7:case nh.BC6H:return Math.ceil(t/4)*Math.ceil(n/4)*16;case nh.ETC1_RGB:case nh.ETC2_RGB:case nh.ETC2_RGBA5:return Math.ceil(t/4)*Math.ceil(n/4)*8;case nh.ETC2_RGBA8:return Math.ceil(t/4)*Math.ceil(n/4)*16;case nh.PVRTC_RGB2:case nh.PVRTC_RGBA2:return Math.max(t,16)*Math.max(n,8)*2/8;case nh.PVRTC_RGB4:case nh.PVRTC_RGBA4:return Math.max(t,8)*Math.max(n,8)*4/8;case nh.ASTC_4x4:return Math.ceil(t/4)*Math.ceil(n/4)*16;case nh.ASTC_5x5:return Math.ceil(t/5)*Math.ceil(n/5)*16;case nh.ASTC_6x6:return Math.ceil(t/6)*Math.ceil(n/6)*16;case nh.ASTC_8x8:return Math.ceil(t/8)*Math.ceil(n/8)*16;case nh.ASTC_10x10:return Math.ceil(t/10)*Math.ceil(n/10)*16;case nh.ASTC_12x12:return Math.ceil(t/12)*Math.ceil(n/12)*16;case nh.Depth16:return t*n*2;case nh.Depth24:case nh.Depth24Stencil8:case nh.Depth32:return t*n*4;case nh.Depth32Stencil8:return t*n*8;case nh.Stencil:return t*n;case nh.Depth:case nh.DepthStencil:default:return t*n*4}},e}(),nM=/*#__PURE__*/function(e){function t(t,n,r,i,a){var o;return void 0===r&&(r=nh.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=nd.Bilinear,o.wrapModeU=o.wrapModeV=nf.Clamp,o._memorySize=nE.getTextureByteCount(r,n,n,o._mipmapCount,6),t._isDeviceLost||(t._renderingStatistics._textureMemory+=o._memorySize),o}t8(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}(nR),nP=/*#__PURE__*/function(e){function t(t,n,r,i,a,o){void 0===a&&(a=nh.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&&(nA.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=t6(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+=nE.getMipLevelByteCount(_.format,n,r))}s._colorTextures=u}else s._colorTextures=[];if(t6(a,nR)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1),s._depthFormat=a.format,(o>1||t6(a,nM))&&(c+=nE.getMipLevelByteCount(a.format,n,r))}else"number"==typeof a&&(s._depthFormat=a,c+=nE.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}t8(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},t3(t,[{key:"autoGenerateMipmaps",get:function(){return this._autoGenerateMipmaps},set:function(e){this._autoGenerateMipmaps=e}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"colorTextureCount",get:function(){return this._colorTextures.length}},{key:"depthTexture",get:function(){return this._depthTexture}},{key:"antiAliasing",get:function(){return this._antiAliasing}}]),t}(np),nw=/*#__PURE__*/function(e){function t(t,n,r,i,a,o,s){var l;return void 0===i&&(i=nh.R8G8B8A8),void 0===a&&(a=!0),void 0===o&&(o=!0),void 0===s&&(s=n_.Static),(l=e.call(this,t,n,r,i,a,o)||this)._usage=s,l._isDepthTexture=i>=nh.Depth&&i<=nh.Depth32Stencil8,l._platformTexture=t._hardwareRenderer.createPlatformTexture2D(l),l.filterMode=l._isIntFormat()?nd.Point:nd.Bilinear,l.wrapModeU=l.wrapModeV=nf.Repeat,l._memorySize=nE.getTextureByteCount(i,n,r,l._mipmapCount,1),t._isDeviceLost||(t._renderingStatistics._textureMemory+=l._memorySize),l}t8(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}(nR),nF=/*#__PURE__*/function(e){function t(t,n,r,i,a,o,s){var l;if(void 0===a&&(a=nh.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=nd.Bilinear,l.wrapModeU=l.wrapModeV=nf.Repeat,l._memorySize=nE.getTextureByteCount(a,n,r,l._mipmapCount,i),t._isDeviceLost||(t._renderingStatistics._textureMemory+=l._memorySize),l}t8(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)},t3(t,[{key:"length",get:function(){return this._length}}]),t}(nR),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?nh.R8:nh.Alpha8,i=new nw(t,512,512,r,!1);return i.filterMode=nd.Bilinear,i.isGCIgnored=!0,n.texture=i,n}t8(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}(no),nB=((p={})[p.None=0]="None",p[p.Bold=1]="Bold",p[p.Italic=2]="Italic",p),nL=((m={})[m.Overflow=0]="Overflow",m[m.Truncate=1]="Truncate",m),nI=/*#__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,T=0,C=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),D=32===F;if(!D||!R||0!==b.length||0!==v.length){var B=D||F>=19968&&F<=40959,L=w.w,I=w.offsetY,N=.5*w.h,O=N+I,V=N-I;B?(v.length>0&&(S+y>n?(S>0&&(S-=a,this._pushLine(u,d,h,b,S,T,C)),f=Math.max(f,S),R=!0,b=v,S=y,T=x,C=A):(b+=v,S+=y,T=Math.max(T,x),C=Math.max(C,A)),v="",y=x=A=0),S+L>n&&S>0?(S-=a,this._pushLine(u,d,h,b,S,T,C),f=Math.max(f,S),R=!0,D?(b="",S=T=C=0):(b=P,S=w.xAdvance+a,T=O,C=V)):(b+=P,S+=w.xAdvance+a,T=Math.max(T,O),C=Math.max(C,V))):y+w.w>n?(S>0&&(S-=a,this._pushLine(u,d,h,b,S,T,C),f=Math.max(f,S),b="",S=T=C=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,T,C)),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,T=Math.max(T,x),C=Math.max(C,A))),S>0&&(S-=a,this._pushLine(u,d,h,b,S,T,C),f=Math.max(f,S))}var k=r;return t.overflowMode===nL.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,T=.5*b.h,C=T+S,R=T-S;y<C&&(y=C),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===nL.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,T=1/S,C=0;C<g;C+=4)0!==m[C+3]&&(i=~~(.25*C*T),-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}();nI._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],nI._extendHeight=0,nI._measureString="|\xc9q\xc5",nI._measureBaseline="M",nI._heightMultiplier=2,nI._baselineMultiplier=1.4,nI._fontSizeInfoCache={},nI._textContext=null;var nN=/*#__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 t8(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=nI.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}(ns))),t},e}(),nO=/*#__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}t8(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 nN(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},t3(t,[{key:"name",get:function(){return this._name}}]),t}(no);function nV(){return function(e){}}var nk=/*#__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]}tz.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}();nk._rectangleTriangles=[0,1,2,2,1,3],nk._matrix=new tY,nk=t9([nV()],nk);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(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,T=e._row,C=e._column;if(x+b>r){var R=r/(x+b);T[0]=v*_*R,T[1]=T[2]=x*R,T[3]=r-v*(1-m)*R}else T[0]=v*_,T[1]=x,T[2]=r-b,T[3]=r-v*(1-m);if(S+A>i){var E=i/(S+A);C[0]=y*f*E,C[1]=C[2]=A*E,C[3]=i-y*(1-g)*E}else C[0]=y*f,C[1]=A,C[2]=i-S,C[3]=i-y*(1-g);var M=a.x,P=a.y,w=r*M,F=i*P,D=e._matrix,B=D.elements,L=n.elements,I=o?-1:1,N=s?-1:1;B[0]=L[0]*I,B[1]=L[1]*I,B[2]=L[2]*I,B[4]=L[4]*N,B[5]=L[5]*N,B[6]=L[6]*N,B[8]=L[8],B[9]=L[9],B[10]=L[10],B[12]=L[12]-w*B[0]-F*B[4],B[13]=L[13]-w*B[1]-F*B[5],B[14]=L[14]-w*B[2]-F*B[6];for(var O=t._subChunk,V=O.chunk.vertices,k=0,U=O.vertexArea.start;k<4;k++)for(var z=T[k],G=0;G<4;G++,U+=9){var H=C[G];V[U]=B[0]*z+B[4]*H+B[12],V[U+1]=B[1]*z+B[5]*H+B[13],V[U+2]=B[2]*z+B[6]*H+B[14]}var X=t._bounds;X.min.set(T[0],C[0],0),X.max.set(T[3],C[3],0),X.transform(D)},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}();nU._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],nU._matrix=new tY,nU._row=[,,,,],nU._column=[,,,,],nU=t9([nV()],nU);var nz=/*#__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}();nz._dispatchingListenersPool=[];var nG=/*#__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},t3(e,[{key:"type",get:function(){return this._type}}]),e}();nG._propertyIdMap=Object.create(null),nG._propertyNameCounter=0,nG._propertyNameMap=Object.create(null);var nH=/*#__PURE__*/function(){function e(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new tq,this._deltaTimeValue=new tq,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)},t3(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}();nH._elapsedTimeProperty=nG.getByName("scene_ElapsedTime"),nH._deltaTimeProperty=nG.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],T=t[n+2],C=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],D=t[n+10],B=t[n+11],L=t[n+12],I=t[n+13],N=t[n+14],O=t[n+15];r[i]=o*b+u*S+f*T+v*C,r[i+1]=s*b+d*S+p*T+y*C,r[i+2]=l*b+h*S+m*T+x*C,r[i+3]=c*b+_*S+g*T+A*C,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*D+v*B,r[i+9]=s*w+d*F+p*D+y*B,r[i+10]=l*w+h*F+m*D+x*B,r[i+11]=c*w+_*F+g*D+A*B,r[i+12]=o*L+u*I+f*N+v*O,r[i+13]=s*L+d*I+p*N+y*O,r[i+14]=l*L+h*I+m*N+x*O,r[i+15]=c*L+_*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)===nW&&t.push(""),e.replace(nY,function(e,n,r,i){var a=e;r?a=i.replace(nj,"$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}(),nW=46,nj=/\\(\\)?/g,nY=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),nK=/*#__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}},t3(e,[{key:"isLopping",get:function(){return this._loopCounter>0}}]),e}(),nQ=((g={})[g.Continuous=0]="Continuous",g[g.Adaptive=1]="Adaptive",g),nq=/*#__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,T=S.elements,C=n.elements,R=o?-1:1,E=s?-1:1;c=T[0]=C[0]*R,u=T[1]=C[1]*R,d=T[2]=C[2]*R,h=T[4]=C[4]*E,_=T[5]=C[5]*E,f=T[6]=C[6]*E,T[8]=C[8],T[9]=C[9],T[10]=C[10];for(var M=T[12]=C[12]-A*c-b*h,P=T[13]=C[13]-A*u-b*_,w=T[14]=C[14]-A*d-b*f,F=p.length-1,D=m.length-1,B=t._subChunk,L=B.chunk.vertices,I=B.indices,N=0,O=0,V=0,k=B.vertexArea.start;V<D;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),X=m.get(V),W=p.get(z+1),j=m.get(V+1);L[k]=c*H+h*X+M,L[k+1]=u*H+_*X+P,L[k+2]=d*H+f*X+w,L[k+9]=c*W+h*X+M,L[k+10]=u*W+_*X+P,L[k+11]=d*W+f*X+w,L[k+18]=c*H+h*j+M,L[k+19]=u*H+_*j+P,L[k+20]=d*H+f*j+w,L[k+27]=c*W+h*j+M,L[k+28]=u*W+_*j+P,L[k+29]=d*W+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(D),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,T=f._getUVs(),C=T[0],R=T[1],E=T[2],M=T[3],P=f.width*s,w=f.height*s,F=P*m.x,D=P*m.z,B=F+D,L=P-B,I=w*m.w,N=w*m.y,O=I+N,V=w-O,k=e.tileMode===nQ.Adaptive;B>=t?(c=2,l=0):L>tV.zeroTolerance?(u=(t-B)/L,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>tV.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(C.x),a.add(M.x),o.add(C.y),o.add(M.y),nA.warn("The number of vertices exceeds the upper limit("+z+")."),4;switch(l){case 0:var G=t/B;r.add(P*y*G),r.add(F*G),r.add(t-P*(1-b)*G),a.add(C.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-D),r.add(t-P*(1-b)),a.add(C.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,X=E.x,W=(t-B)/u;r.add(P*y),r.add(F),a.add(C.x),a.add(H),a.add(H);for(var j=1,Y=c-2;j<Y;j++)r.add(F+j*W),a.add(X),a.add(H);r.add(t-D),r.add(t-P*(1-b)),k?a.add(X):a.add((u-(Math.ceil(u)-1))*(X-H)+H),a.add(X),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(C.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(C.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(C.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}();nq._matrix=new tY,nq._posRow=new nK,nq._posColumn=new nK,nq._uvRow=new nK,nq._uvColumn=new nK,nq=t9([nV()],nq);var nZ=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._sprites=[],n._spriteNamesToIndex={},n}t8(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},t3(t,[{key:"sprites",get:function(){return this._sprites}}]),t}(no),nJ=((v={})[v.Simple=0]="Simple",v[v.Sliced=1]="Sliced",v[v.Tiled=2]="Tiled",v),n$=((y={})[y.None=0]="None",y[y.VisibleInsideMask=1]="VisibleInsideMask",y[y.VisibleOutsideMask=2]="VisibleOutsideMask",y),n0=((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),n1=((A={})[A.Left=0]="Left",A[A.Center=1]="Center",A[A.Right=2]="Right",A),n2=((b={})[b.Top=0]="Top",b[b.Center=1]="Center",b[b.Bottom=2]="Bottom",b),n3=/*#__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}(),n4=/*#__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 tz,s._texture=null,s._atlasRotated=!1,s._atlasRegion=new tJ(0,0,1,1),s._atlasRegionOffset=new tq(0,0,0,0),s._region=new tJ(0,0,1,1),s._pivot=new tQ(.5,.5),s._border=new tq(0,0,0,0),s._dirtyUpdateFlag=7,s._updateFlagManager=new n3,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}t8(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(n0.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/oX._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,T=this._border,C=T.x,R=T.y,E=T.z,M=T.w;e[0].set(x,S),e[1].set((r-f+C*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 n0.texture:this._dirtyUpdateFlag|=4;break;case n0.atlasRegionOffset:case n0.region:this._dirtyUpdateFlag|=7;break;case n0.atlasRegion:this._dirtyUpdateFlag|=6;break;case n0.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},n._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=tV.clamp(e.x,0,1),n=tV.clamp(e.y,0,1);e.set(t,n,tV.clamp(e.width,0,1-t),tV.clamp(e.height,0,1-n)),this._dispatchSpriteChange(n0.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n0.size),e._onValueChanged=this._onRegionChange},n._onPivotChange=function(){this._dispatchSpriteChange(n0.pivot)},n._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=tV.clamp(e.x,0,1),n=tV.clamp(e.y,0,1);e.set(t,n,tV.clamp(e.z,0,1-t),tV.clamp(e.w,0,1-n)),this._dispatchSpriteChange(n0.border),e._onValueChanged=this._onBorderChange},t3(t,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(n0.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n0.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(n0.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(n0.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=tV.clamp(e.x,0,1),n=tV.clamp(e.y,0,1);this._atlasRegion.set(t,n,tV.clamp(e.width,0,1-t),tV.clamp(e.height,0,1-n)),this._dispatchSpriteChange(n0.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n0.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=tV.clamp(e.x,0,1),n=tV.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,tV.clamp(e.z,0,1-t),tV.clamp(e.w,0,1-n)),this._dispatchSpriteChange(n0.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(n0.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}(no);t9([ne],n4.prototype,"_onRegionChange",null),t9([ne],n4.prototype,"_onPivotChange",null),t9([ne],n4.prototype,"_onBorderChange",null);var n8=((S={})[S.SolidColor=0]="SolidColor",S[S.Sky=1]="Sky",S[S.Texture=2]="Texture",S),n5=((T={})[T.AspectFitWidth=0]="AspectFitWidth",T[T.AspectFitHeight=1]="AspectFitHeight",T[T.Fill=2]="Fill",T),n9=((C={})[C.Zero=0]="Zero",C[C.One=1]="One",C[C.SourceColor=2]="SourceColor",C[C.OneMinusSourceColor=3]="OneMinusSourceColor",C[C.DestinationColor=4]="DestinationColor",C[C.OneMinusDestinationColor=5]="OneMinusDestinationColor",C[C.SourceAlpha=6]="SourceAlpha",C[C.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",C[C.DestinationAlpha=8]="DestinationAlpha",C[C.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",C[C.SourceAlphaSaturate=10]="SourceAlphaSaturate",C[C.BlendColor=11]="BlendColor",C[C.OneMinusBlendColor=12]="OneMinusBlendColor",C),n6=((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),n7=((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),re=((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),rt=((P={})[P.Off=0]="Off",P[P.Front=1]="Front",P[P.Back=2]="Back",P),rn=((w={})[w.Opaque=0]="Opaque",w[w.AlphaTest=1]="AlphaTest",w[w.Transparent=2]="Transparent",w),rr=((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),ri=((D={})[D.Scene=0]="Scene",D[D.Camera=1]="Camera",D[D.Renderer=2]="Renderer",D[D.Material=3]="Material",D[D.RenderElement=4]="RenderElement",D),ra=((B={})[B.GLSLES100=0]="GLSLES100",B[B.GLSLES300=1]="GLSLES300",B),ro=((L={})[L.Float=0]="Float",L[L.Int=1]="Int",L[L.Vector2=2]="Vector2",L[L.Vector3=3]="Vector3",L[L.Vector4=4]="Vector4",L[L.Matrix=5]="Matrix",L[L.Color=6]="Color",L[L.Texture=7]="Texture",L[L.FloatArray=8]="FloatArray",L[L.IntArray=9]="IntArray",L[L.TextureArray=10]="TextureArray",L),rs=((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),rl=/*#__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}();rl._macroMaskMap=[],rl._macroNameIdMap=Object.create(null),rl._macroNameCounter=0,rl._macroCounter=0,rl._macroMap=Object.create(null);var rc=/*#__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 ru(){return(ru=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 rd=((N={}).DepthOnly="DepthOnly",N.ShadowCaster="ShadowCaster",N.Forward="Forward",N),rh=ru({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 RGBMToLinear(vec4 value, float maxRange ) {\n return vec4( value.rgb * value.a * maxRange, 1.0 );\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 SCENE_IS_DECODE_ENV_RGBM\n envMapColor.rgb = RGBMToLinear(envMapColor, 5.0).rgb;\n #elif defined(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\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 #ifdef RENDERER_ROL_IS_RANDOM_TWO\n rotation += vec3(\n mix(getTotalValueFromGradientFloat(renderer_ROLMinCurveX, normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveX, normalizedAge), a_Random0.w),\n mix(getTotalValueFromGradientFloat(renderer_ROLMinCurveY, normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveY, normalizedAge), a_Random0.w),\n mix(getTotalValueFromGradientFloat(renderer_ROLMinCurveZ, normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ, normalizedAge), a_Random0.w));\n #else\n rotation += vec3(getTotalValueFromGradientFloat(renderer_ROLMaxCurveX, normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveY, normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ, normalizedAge));\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 #ifdef RENDERER_ROL_IS_RANDOM_TWO\n rotation += mix(\n getTotalValueFromGradientFloat(renderer_ROLMinCurveZ, normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ, normalizedAge),\n a_Random0.w);\n #else\n rotation += getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ, normalizedAge);\n #endif\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 attribute vec4 a_Random2;\n\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",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 = vec3(a_StartRotation0.xy, computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge));\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, rotation);\n } else {\n float rot = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, a_StartRotation0);\n } else {\n float c = cos(a_StartRotation0.x);\n float s = sin(a_StartRotation0.x);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #endif\n#endif",stretched_billboard:"#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 = 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 = 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 = computeParticleRotationVec3(startRotation, age, normalizedAge);\n #else\n vec3 rotation = 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 = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n #else\n float angle = 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"}),r_=/*#__PURE__*/function(){function e(){}return e.parseCustomMacros=function(e){return e.map(function(e){return"#define "+(e.value?e.name+" "+e.value:e.name)+"\n"}).join("")},e.registerInclude=function(e,t){if(rh[e])throw'The "'+e+'" shader include already exist';rh[e]=t},e.unRegisterInclude=function(e){delete rh[e]},e.parseIncludes=function(t,n){return void 0===n&&(n=/^[ \t]*#include +<([\w\d.]+)>/gm),t.replace(n,function(t,r){var i=rh[r];return void 0===i?(nA.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}();r_._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(""),r_._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var rf=/*#__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}();rf._nameCounter=0,rf._nameMap=Object.create(null);var rp=/*#__PURE__*/function(){function e(){this._tagsMap=Object.create(null)}var t=e.prototype;return t.setTag=function(e,t){var n="string"==typeof e?rf.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&nA.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?rf.getByName(e):e)._uniqueId]},t.getTagValue=function(e){return this._tagsMap["string"==typeof e?rf.getByName(e)._uniqueId:e._uniqueId]},t3(e,[{key:"name",get:function(){return this._name}}]),e}(),rm=/*#__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}(),rg=function(){this.constUniforms=[],this.textureUniforms=[]},rv=/*#__PURE__*/function(){function e(t,n,r){this.sceneUniformBlock=new rg,this.cameraUniformBlock=new rg,this.rendererUniformBlock=new rg,this.materialUniformBlock=new rg,this.renderElementUniformBlock=new rg,this.otherUniformBlock=new rg,this._uploadRenderCount=-1,this._uploadSceneId=-1,this._uploadCameraId=-1,this._uploadRendererId=-1,this._uploadMaterialId=-1,this.attributeLocation=Object.create(null),this._activeTextureUint=0,this._engine=t,this._gl=t._hardwareRenderer.gl,this._glProgram=this._createProgram(n,r),this._glProgram?(this._isValid=!0,this._recordLocation()):this._isValid=!1,this.id=e._counter++}var t=e.prototype;return t.uploadAll=function(e,t){this.uploadUniforms(e,t),this.uploadTextures(e,t)},t.uploadUniforms=function(e,t){for(var n=t._propertyValueMap,r=e.constUniforms,i=0,a=r.length;i<a;i++){var o=r[i],s=n[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var n=t._propertyValueMap,r=e.textureUniforms;if(r)for(var i=0,a=r.length;i<a;i++){var o=r[i],s=n[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,n=e.length;t<n;t++){var r=e[t];r.applyFunc(r,r.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,n=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),n.length>0&&this._groupingSubOtherUniforms(n,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n],i=nG._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 ri.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case ri.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case ri.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case ri.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case ri.RenderElement:n?this.renderElementUniformBlock.textureUniforms.push(e):this.renderElementUniformBlock.constUniforms.push(e);break;default:n?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var n=this._gl,r=this._createShader(n.VERTEX_SHADER,e);if(!r)return null;var i=this._createShader(n.FRAGMENT_SHADER,t);if(!i)return null;var a=n.createProgram();return a?(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),n.validateProgram(a),n.deleteShader(r),n.deleteShader(i),!nA.isEnabled||n.getProgramParameter(a,n.LINK_STATUS)||n.isContextLost())?a:(nA.error("Could not link WebGL program\n\nShader error: "+n.getError()+"\n\nValidate status: "+n.getProgramParameter(a,n.VALIDATE_STATUS)+"\n\nProgram information log: "+n.getProgramInfoLog(a)),n.deleteProgram(a),null):null},t._createShader=function(t,n){var r=this._gl,i=r.createShader(t);return i?(r.shaderSource(i,n),r.compileShader(i),!nA.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 rm(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=nG.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 tk(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new tq(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 tk(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new tq(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=nG._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")},t3(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();rv._counter=0;var ry=/*#__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=ru({pipelineStage:rd.Forward},a)):(o._name="Default",o._vertexSource=n,o._fragmentSource=r,a=ru({pipelineStage:rd.Forward},i)),a)o.setTag(s,a[s]);return o}t8(t,e);var n=t.prototype;return n._getShaderProgram=function(e,t){var n=e._getShaderProgramPool(this),r=n.get(t);return r||(r=this._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){var n=e._hardwareRenderer.isWebGL2,r=[];rl._getMacrosElements(t,r),r.push(rl.getByName(n?"GRAPHICS_API_WEBGL2":"GRAPHICS_API_WEBGL1")),e._hardwareRenderer.canIUse(nT.shaderTextureLod)&&r.push(rl.getByName("HAS_TEX_LOD")),e._hardwareRenderer.canIUse(nT.standardDerivatives)&&r.push(rl.getByName("HAS_DERIVATIVES"));var i=r_.parseIncludes(this._vertexSource),a=r_.parseIncludes(this._fragmentSource);if(void 0!=this._platformTarget)i=rE._shaderLab._parseMacros(i,r),a=rE._shaderLab._parseMacros(a,r);else{var o=r_.parseCustomMacros(r);i=o+i,a=o+a}n&&(void 0==this._platformTarget||this._platformTarget===ra.GLSLES100)&&(i=r_.convertTo300(i),a=r_.convertTo300(a,!0));var s=n?"#version 300 es":"#version 100";return new rv(e," "+s+" \n "+i+"\n "," "+s+"\n "+(n?"":r_._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}(rp);ry._shaderPassCounter=0,ry._shaderRootPath="shaders://root/";var rx=/*#__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 t8(t,e),t3(t,[{key:"passes",get:function(){return this._passes}}]),t}(rp),rA=function(){this.enabled=!1,this.colorBlendOperation=n6.Add,this.alphaBlendOperation=n6.Add,this.sourceColorBlendFactor=n9.One,this.sourceAlphaBlendFactor=n9.One,this.destinationColorBlendFactor=n9.Zero,this.destinationAlphaBlendFactor=n9.Zero,this.colorWriteMask=n7.All},rb=/*#__PURE__*/function(){function e(){this.targetBlendState=new rA,this.blendColor=new tZ(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[rr.BlendStateEnabled0];if(void 0!==u){var d=t.getFloat(u);c.enabled=void 0!==d&&!!d}var h=e[rr.BlendStateColorBlendOperation0];void 0!==h&&(c.colorBlendOperation=null!=(n=t.getFloat(h))?n:n6.Add);var _=e[rr.BlendStateAlphaBlendOperation0];void 0!==_&&(c.alphaBlendOperation=null!=(r=t.getFloat(_))?r:n6.Add);var f=e[rr.BlendStateSourceColorBlendFactor0];void 0!==f&&(c.sourceColorBlendFactor=null!=(i=t.getFloat(f))?i:n9.One);var p=e[rr.BlendStateSourceAlphaBlendFactor0];void 0!==p&&(c.sourceAlphaBlendFactor=null!=(a=t.getFloat(p))?a:n9.One);var m=e[rr.BlendStateDestinationColorBlendFactor0];void 0!==m&&(c.destinationColorBlendFactor=null!=(o=t.getFloat(m))?o:n9.Zero);var g=e[rr.BlendStateDestinationAlphaBlendFactor0];void 0!==g&&(c.destinationAlphaBlendFactor=null!=(s=t.getFloat(g))?s:n9.Zero);var v=e[rr.BlendStateColorWriteMask0];void 0!==v&&(c.colorWriteMask=null!=(l=t.getFloat(v))?l:n7.All);var y=e[rr.BlendStateBlendColor];if(void 0!==y){var x=t.getColor(y);void 0!==x&&this.blendColor.copyFrom(x)}var A=e[rr.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[rr.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;tZ.equals(n.blendColor,m)||(i.blendColor(m.r,m.g,m.b,m.a),n.blendColor.copyFrom(m))}f!==a.colorWriteMask&&(i.colorMask((f&n7.Red)!=0,(f&n7.Green)!=0,(f&n7.Blue)!=0,(f&n7.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 n9.Zero:return n.ZERO;case n9.One:return n.ONE;case n9.SourceColor:return n.SRC_COLOR;case n9.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case n9.DestinationColor:return n.DST_COLOR;case n9.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case n9.SourceAlpha:return n.SRC_ALPHA;case n9.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case n9.DestinationAlpha:return n.DST_ALPHA;case n9.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case n9.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case n9.BlendColor:return n.CONSTANT_COLOR;case n9.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},e._getGLBlendOperation=function(e,t){var n=e.gl;switch(t){case n6.Add:return n.FUNC_ADD;case n6.Subtract:return n.FUNC_SUBTRACT;case n6.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case n6.Min:if(!e.canIUse(nT.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case n6.Max:if(!e.canIUse(nT.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},e}();t9([nr],rb.prototype,"targetBlendState",void 0),t9([nr],rb.prototype,"blendColor",void 0);var rS=/*#__PURE__*/function(){function e(){this.enabled=!0,this.compareFunction=re.Less,this.writeEnabled=!0}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r=e[rr.DepthStateEnabled];if(void 0!==r){var i=t.getFloat(r);this.enabled=void 0!==i&&!!i}var a=e[rr.DepthStateWriteEnabled];if(void 0!==a){var o=t.getFloat(a);this.writeEnabled=void 0!==o&&!!o}var s=e[rr.DepthStateCompareFunction];void 0!==s&&(this.compareFunction=null!=(n=t.getFloat(s))?n:re.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[rr.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 re.Never:return n.NEVER;case re.Less:return n.LESS;case re.Equal:return n.EQUAL;case re.LessEqual:return n.LEQUAL;case re.Greater:return n.GREATER;case re.NotEqual:return n.NOTEQUAL;case re.GreaterEqual:return n.GEQUAL;case re.Always:return n.ALWAYS}},e}(),rT=/*#__PURE__*/function(){function e(){this.cullMode=rt.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[rr.RasterStateCullMode];void 0!==a&&(this.cullMode=null!=(n=t.getFloat(a))?n:rt.Back);var o=e[rr.RasterStateDepthBias];void 0!==o&&(this.depthBias=null!=(r=t.getFloat(o))?r:0);var s=e[rr.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[rr.RasterStateCullMode];void 0!==l&&(a=l)}var c=a!==rt.Off;c!==t._cullFaceEnable&&(c?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),t._cullFaceEnable=c),c&&a!==t.cullMode&&(a==rt.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}(),rC=/*#__PURE__*/function(){function e(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=re.Always,this.compareFunctionBack=re.Always,this.passOperationFront=rs.Keep,this.passOperationBack=rs.Keep,this.failOperationFront=rs.Keep,this.failOperationBack=rs.Keep,this.zFailOperationFront=rs.Keep,this.zFailOperationBack=rs.Keep}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,i,a,o,s,l,c,u,d,h,_=e[rr.StencilStateEnabled];if(void 0!==_){var f=t.getFloat(_);this.enabled=void 0!==f&&!!f}var p=e[rr.StencilStateReferenceValue];void 0!==p&&(this.referenceValue=null!=(n=t.getFloat(p))?n:0);var m=e[rr.StencilStateMask];void 0!==m&&(this.mask=null!=(r=t.getFloat(m))?r:255);var g=e[rr.StencilStateWriteMask];void 0!==g&&(this.writeMask=null!=(i=t.getFloat(g))?i:255);var v=e[rr.StencilStateCompareFunctionFront];void 0!==v&&(this.compareFunctionFront=null!=(a=t.getFloat(v))?a:re.Always);var y=e[rr.StencilStateCompareFunctionBack];void 0!==y&&(this.compareFunctionBack=null!=(o=t.getFloat(y))?o:re.Always);var x=e[rr.StencilStatePassOperationFront];void 0!==x&&(this.passOperationFront=null!=(s=t.getFloat(x))?s:rs.Keep);var A=e[rr.StencilStatePassOperationBack];void 0!==A&&(this.passOperationBack=null!=(l=t.getFloat(A))?l:rs.Keep);var b=e[rr.StencilStateFailOperationFront];void 0!==b&&(this.failOperationFront=null!=(c=t.getFloat(b))?c:rs.Keep);var S=e[rr.StencilStateFailOperationBack];void 0!==S&&(this.failOperationBack=null!=(u=t.getFloat(S))?u:rs.Keep);var T=e[rr.StencilStateZFailOperationFront];void 0!==T&&(this.zFailOperationFront=null!=(d=t.getFloat(T))?d:rs.Keep);var C=e[rr.StencilStateZFailOperationBack];void 0!==C&&(this.zFailOperationBack=null!=(h=t.getFloat(C))?h:rs.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[rr.StencilStateEnabled];void 0!==g&&(a=g);var v=r[rr.StencilStateWriteMask];void 0!==v&&(m=v);var y=r[rr.StencilStateReferenceValue];void 0!==y&&(o=y);var x=r[rr.StencilStateCompareFunctionFront];void 0!==x&&(l=x);var A=r[rr.StencilStateCompareFunctionBack];void 0!==A&&(c=A);var b=r[rr.StencilStatePassOperationFront];void 0!==b&&(h=b);var S=r[rr.StencilStatePassOperationBack];void 0!==S&&(p=S);var T=r[rr.StencilStateFailOperationFront];void 0!==T&&(u=T);var C=r[rr.StencilStateFailOperationBack];void 0!==C&&(_=C);var R=r[rr.StencilStateZFailOperationFront];void 0!==R&&(d=R);var E=r[rr.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 re.Never:return n.NEVER;case re.Less:return n.LESS;case re.Equal:return n.EQUAL;case re.LessEqual:return n.LEQUAL;case re.Greater:return n.GREATER;case re.NotEqual:return n.NOTEQUAL;case re.GreaterEqual:return n.GEQUAL;case re.Always:return n.ALWAYS}},e._getGLStencilOperation=function(e,t){var n=e.gl;switch(t){case rs.Keep:return n.KEEP;case rs.Zero:return n.ZERO;case rs.Replace:return n.REPLACE;case rs.IncrementSaturate:return n.INCR;case rs.DecrementSaturate:return n.DECR;case rs.Invert:return n.INVERT;case rs.IncrementWrap:return n.INCR_WRAP;case rs.DecrementWrap:return n.DECR_WRAP}},e}(),rR=/*#__PURE__*/function(){function e(){this.blendState=new rb,this.depthState=new rS,this.stencilState=new rC,this.rasterState=new rT,this.renderQueueType=rn.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[rr.RenderQueueType];return void 0===r?this.renderQueueType:null!=(n=t.getFloat(r))?n:rn.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}();t9([nr],rR.prototype,"blendState",void 0),t9([nr],rR.prototype,"depthState",void 0),t9([nr],rR.prototype,"stencilState",void 0),t9([nr],rR.prototype,"rasterState",void 0);var rE=/*#__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(rl.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=ra.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:"",ry._shaderRootPath).href);if(!h)throw'Shader pass "'+s.name+"."+t.name+"."+i.name+'" parse failed, please check the shader source code.';var _=new ry(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 rR;for(var v in p)e._applyConstRenderStates(g,+v,p[v]);_._renderState=g;var y={};for(var x in m)y[x]=nG.getByName(m[x]);_._renderStateDataMap=y}return _});return new rx(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 rx("Default",[new ry(n,r)])]);else if(n.length>0)i=n[0].constructor===ry?new e(t,[new rx("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 rr.BlendStateEnabled0:e.blendState.targetBlendState.enabled=n;break;case rr.BlendStateColorBlendOperation0:e.blendState.targetBlendState.colorBlendOperation=n;break;case rr.BlendStateAlphaBlendOperation0:e.blendState.targetBlendState.alphaBlendOperation=n;break;case rr.BlendStateSourceColorBlendFactor0:e.blendState.targetBlendState.sourceColorBlendFactor=n;break;case rr.BlendStateDestinationColorBlendFactor0:e.blendState.targetBlendState.destinationColorBlendFactor=n;break;case rr.BlendStateSourceAlphaBlendFactor0:e.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case rr.BlendStateDestinationAlphaBlendFactor0:e.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case rr.BlendStateColorWriteMask0:e.blendState.targetBlendState.colorWriteMask=n;break;case rr.DepthStateEnabled:e.depthState.enabled=n;break;case rr.DepthStateWriteEnabled:e.depthState.writeEnabled=n;break;case rr.DepthStateCompareFunction:e.depthState.compareFunction=n;break;case rr.StencilStateEnabled:e.stencilState.enabled=n;break;case rr.StencilStateReferenceValue:e.stencilState.referenceValue=n;break;case rr.StencilStateMask:e.stencilState.mask=n;break;case rr.StencilStateWriteMask:e.stencilState.writeMask=n;break;case rr.StencilStateCompareFunctionFront:e.stencilState.compareFunctionFront=n;break;case rr.StencilStateCompareFunctionBack:e.stencilState.compareFunctionBack=n;break;case rr.StencilStatePassOperationFront:e.stencilState.passOperationFront=n;break;case rr.StencilStatePassOperationBack:e.stencilState.passOperationBack=n;break;case rr.StencilStateFailOperationFront:e.stencilState.failOperationFront=n;break;case rr.StencilStateFailOperationBack:e.stencilState.failOperationBack=n;break;case rr.StencilStateZFailOperationFront:e.stencilState.zFailOperationFront=n;break;case rr.StencilStateZFailOperationBack:e.stencilState.zFailOperationBack=n;break;case rr.RasterStateCullMode:e.rasterState.cullMode=n;break;case rr.RasterStateDepthBias:e.rasterState.depthBias=n;break;case rr.RasterStateSlopeScaledDepthBias:e.rasterState.slopeScaledDepthBias=n;break;case rr.RenderQueueType:e.renderQueueType=n}},e.getMacroByName=function(e,t){return rl.getByName(e,t)},e.getPropertyByName=function(e){return nG.getByName(e)},t3(e,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();rE._compileMacros=new rc,rE._shaderMap=Object.create(null);var rM=/*#__PURE__*/function(){function e(e){this._propertyValueMap=Object.create(null),this._macroCollection=new rc,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,ro.Float,t)},t.getInt=function(e){return this.getPropertyValue(e)},t.setInt=function(e,t){this._setPropertyValue(e,ro.Int,t)},t.getFloatArray=function(e){return this.getPropertyValue(e)},t.setFloatArray=function(e,t){this._setPropertyValue(e,ro.FloatArray,t)},t.getIntArray=function(e){return this.getPropertyValue(e)},t.setIntArray=function(e,t){this._setPropertyValue(e,ro.IntArray,t)},t.getVector2=function(e){return this.getPropertyValue(e)},t.setVector2=function(e,t){this._setPropertyValue(e,ro.Vector2,t)},t.getVector3=function(e){return this.getPropertyValue(e)},t.setVector3=function(e,t){this._setPropertyValue(e,ro.Vector3,t)},t.getVector4=function(e){return this.getPropertyValue(e)},t.setVector4=function(e,t){this._setPropertyValue(e,ro.Vector4,t)},t.getMatrix=function(e){return this.getPropertyValue(e)},t.setMatrix=function(e,t){this._setPropertyValue(e,ro.Matrix,t)},t.getColor=function(e){return this.getPropertyValue(e)},t.setColor=function(e,t){this._setPropertyValue(e,ro.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,ro.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,ro.TextureArray,t)},t.getPropertyValue=function(e){return"string"==typeof e&&(e=nG.getByName(e)),this._propertyValueMap[e._uniqueId]},t.enableMacro=function(e,t){"string"==typeof e&&(e=rl.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=rl._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=nG._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){ni.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(t6(l,nR))r[s]=l,t>0&&l._addReferCount(t);else if(t6(l,Array)||t6(l,Float32Array)||t6(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=nG.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 "+ri[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 "+ro[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&&t6(r,nR)&&r._addReferCount(e)}},e}();t9([ne],rM.prototype,"_group",void 0),t9([ne],rM.prototype,"_propertyValueMap",void 0),t9([ne],rM.prototype,"_macroCollection",void 0),t9([ne],rM.prototype,"_macroMap",void 0),t9([ne],rM.prototype,"_refCount",void 0);var rP=/*#__PURE__*/function(){function e(){this._projectionParams=new tq,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&&(tY.multiply(e._flipYMatrix,a,e._flipYProjectionMatrix),tY.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(oX._outputSRGBCorrectMacro):i._macroCollection.enable(oX._outputSRGBCorrectMacro)},t.garbageCollection=function(){this.camera=null},e}();rP.vpMatrixProperty=nG.getByName("camera_VPMat"),rP.pipelineStageKey=rf.getByName("pipelineStage"),rP._flipYMatrix=new tY(1,0,0,0,0,-1),rP._cameraProjectionProperty=nG.getByName("camera_ProjectionParams"),rP._viewMatrixProperty=nG.getByName("camera_ViewMat"),rP._projectionMatrixProperty=nG.getByName("camera_ProjMat"),rP._flipYProjectionMatrix=new tY,rP._flipYViewProjectionMatrix=new tY;var rw=((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),rF=/*#__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){nA.warn("The material of sky is not defined.");return}if(n.destroyed){nA.warn("The material of sky is destroyed.");return}if(!r){nA.warn("The mesh of sky is not defined.");return}if(r.destroyed){nA.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(tV.degreeToRadian(l)/2);_.elements[0]=y/s,_.elements[5]=y,tY.multiply(_,h,h);var x=u.getMatrix(rP.vpMatrixProperty);t.flipProjection&&tY.multiply(rP._flipYMatrix,h,h),u.setMatrix(rP.vpMatrixProperty,h);var A=rE._compileMacros;rc.unionCollection(t.camera._globalShaderMacro,p._macroCollection,A),rc.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(rP.vpMatrixProperty,x)},t3(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}();rF._epsilon=1e-6,rF._viewProjMatrix=new tY,rF._projectionMatrix=new tY(1,0,0,0,0,1,0,0,0,0,rF._epsilon-1,-1,0,0,0,0);var rD=/*#__PURE__*/function(){function e(e){this._engine=e,this.mode=n8.SolidColor,this.sky=new rF,this._textureFillMode=n5.AspectFitHeight,this._solidColor=new tZ(.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 n5.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 n5.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 n5.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 t8(n,e),n.prototype.restoreContent=function(){t.setPositions(t.getPositions()),t.setUVs(t.getUVs()),t.setIndices(t.getIndices()),t.uploadData(!1)},n}(ns))),this._mesh._addReferCount(1)},t._initMaterial=function(e){var t=this._material=new r1(e,rE.find("background-texture"));t.renderState.depthState.compareFunction=re.LessEqual,t._addReferCount(1)},t._createPlane=function(e){for(var t=new aU(e),n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],i=[,,,,],a=0;a<4;++a)r[a]=new tk,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},t3(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 tZ;var rB=((V={})[V.None=0]="None",V[V.Scene=1]="Scene",V[V.Hierarchy=2]="Hierarchy",V[V.All=3]="All",V),rL=/*#__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}t8(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&rB.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&rB.Hierarchy&&(e?(!this._awoken&&n._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&n._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(n._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable()))},n._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._entity;t._removeComponent(this),this._enabled&&(t._isActiveInScene&&this._onDisableInScene(),t._isActiveInHierarchy&&this._onDisable())},t3(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}(na);t9([ne],rL.prototype,"_entity",void 0),t9([ne],rL.prototype,"_awoken",void 0),t9([ne],rL.prototype,"_phasedActiveInScene",void 0),t9([ne],rL.prototype,"_phasedActive",void 0),t9([nt],rL.prototype,"_enabled",void 0);var rI=/*#__PURE__*/function(){function e(){}return e._addCheck=function(t,n){for(;n!==rL;){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!==rL;){for(var a=0,o=0;o<i;o++)if(t6(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 rN(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){rI._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return rI._addInvDependency(t,e)})}}rI._invDependenciesMap=new Map,rI._dependenciesMap=new Map;var rO=((k={})[k.CheckOnly=0]="CheckOnly",k[k.AutoAdd=1]="AutoAdd",k),rV=((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),rk=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.flag=!0,t}return t8(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}()),rU=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._position=new tk,n._rotation=new tk,n._rotationQuaternion=new tj,n._scale=new tk(1,1,1),n._localUniformScaling=!0,n._worldPosition=new tk,n._worldRotation=new tk,n._worldRotationQuaternion=new tj,n._worldUniformScaling=!0,n._lossyWorldScale=new tk(1,1,1),n._localMatrix=new tY,n._worldMatrix=new tY,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}t8(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*tV.degreeToRadFactor;tj.rotationAxisAngle(e,i,t._tempQuat0),this._rotateByQuat(t._tempQuat0,r)},n.lookAt=function(e,n){var r=t._tempVec30;tk.subtract(this.worldPosition,e,r);var i=r.length();if(!(i<=tV.zeroTolerance)){r.scale(1/i);var a=t._tempVec31;if(n?tk.cross(n,r,a):a.set(r.z,0,-r.x),!((i=a.length())<=tV.zeroTolerance)){a.scale(1/i);var o=t._tempVec32;tk.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,t,n){var r=e._position,i=e._rotation,a=e._scale;r._onValueChanged=i._onValueChanged=a._onValueChanged=null,r.copyFrom(this.position),i.copyFrom(this.rotation),a.copyFrom(this.scale),r._onValueChanged=e._onPositionChanged,i._onValueChanged=e._onRotationChanged,a._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?(tY.invert(n.worldMatrix,t._tempMat41),tk.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),tj.invert(this.worldRotationQuaternion,e),tW.rotationQuaternion(e,n),tW.multiply(n,r,i),i},n._rotateByQuat=function(e,t){t?tj.multiply(this.rotationQuaternion,e,this._rotationQuaternion):tj.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},n._translate=function(e,n){if(void 0===n&&(n=!0),n){var r=t._tempVec30;tk.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=tV.degreeToRadFactor,o=t._tempQuat0;tj.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;tj.rotationEuler(tV.degreeToRadian(e.x),tV.degreeToRadian(e.y),tV.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;tj.invert(n.worldRotationQuaternion,r),tj.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(rk)},t3(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(tV.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(tV.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,tj.rotationEuler(tV.degreeToRadian(this._rotation.x),tV.degreeToRadian(this._rotation.y),tV.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):tj.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?tj.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):tj.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)&&(tY.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?tY.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?(tY.invert(n.worldMatrix,t._tempMat42),tY.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 tk),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 tk),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 tk),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),t}(rL);rU._tempQuat0=new tj,rU._tempVec30=new tk,rU._tempVec31=new tk,rU._tempVec32=new tk,rU._tempMat30=new tW,rU._tempMat31=new tW,rU._tempMat32=new tW,rU._tempMat41=new tY,rU._tempMat42=new tY,t9([ne],rU.prototype,"_position",void 0),t9([ne],rU.prototype,"_rotation",void 0),t9([ne],rU.prototype,"_rotationQuaternion",void 0),t9([ne],rU.prototype,"_scale",void 0),t9([nt],rU.prototype,"_localUniformScaling",void 0),t9([ne],rU.prototype,"_worldPosition",void 0),t9([ne],rU.prototype,"_worldRotation",void 0),t9([ne],rU.prototype,"_worldRotationQuaternion",void 0),t9([ne],rU.prototype,"_worldUniformScaling",void 0),t9([ne],rU.prototype,"_lossyWorldScale",void 0),t9([ne],rU.prototype,"_localMatrix",void 0),t9([ne],rU.prototype,"_worldMatrix",void 0),t9([ne],rU.prototype,"_worldForward",void 0),t9([ne],rU.prototype,"_worldRight",void 0),t9([ne],rU.prototype,"_worldUp",void 0),t9([ne],rU.prototype,"_isParentDirty",void 0),t9([ne],rU.prototype,"_parentTransformCache",void 0),t9([ne],rU.prototype,"_dirtyFlag",void 0),t9([ne],rU.prototype,"_onPositionChanged",null),t9([ne],rU.prototype,"_onWorldPositionChanged",null),t9([ne],rU.prototype,"_onRotationChanged",null),t9([ne],rU.prototype,"_onWorldRotationChanged",null),t9([ne],rU.prototype,"_onRotationQuaternionChanged",null),t9([ne],rU.prototype,"_onWorldRotationQuaternionChanged",null),t9([ne],rU.prototype,"_onScaleChanged",null);var rz=((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),rG=function(){this.isOrthographic=!1,this.nearClipPlane=.1,this.farClipPlane=100,this.position=new tk,this.viewMatrix=new tY,this.projectionMatrix=new tY,this.viewProjectionMatrix=new tY,this.forward=new tk};t9([ne],rG.prototype,"position",void 0),t9([ne],rG.prototype,"viewMatrix",void 0),t9([ne],rG.prototype,"projectionMatrix",void 0),t9([ne],rG.prototype,"viewProjectionMatrix",void 0),t9([ne],rG.prototype,"forward",void 0);var rH=((G={})[G.None=0]="None",G[G.FXAA=1]="FXAA",G),rX=((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),rW=((X={})[X.ProjectionType=1]="ProjectionType",X[X.AspectRatio=2]="AspectRatio",X[X.FieldOfView=4]="FieldOfView",X[X.OrthographicSize=8]="OrthographicSize",X[X.EnableInScene=16]="EnableInScene",X[X.DisableInScene=32]="DisableInScene",X),rj=((W={})[W.Normal=0]="Normal",W[W.XRCenterCamera=1]="XRCenterCamera",W[W.XRLeftCamera=2]="XRLeftCamera",W[W.XRRightCamera=4]="XRRightCamera",W),rY=((j={})[j.None=0]="None",j[j.PrePass=1]="PrePass",j),rK=((Y={})[Y.None=1]="None",Y[Y.TwoX=2]="TwoX",Y[Y.FourX=4]="FourX",Y),rQ=((K={})[K.None=1]="None",K[K.TwoX=2]="TwoX",K[K.FourX=4]="FourX",K[K.EightX=8]="EightX",K),rq=((Q={})[Q.KeepOriginalShader=0]="KeepOriginalShader",Q[Q.DoNotRender=1]="DoNotRender",Q),rZ=function(){};rZ.tempVec4=new tq,rZ.tempVec3=new tk,rZ.tempVec2=new tQ;var rJ=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableFrustumCulling=!0,n.clearFlags=rX.All,n.cullingMask=rV.Everything,n.postProcessMask=rV.Everything,n.depthTextureMode=rY.None,n.opaqueTextureDownsampling=rK.TwoX,n.antiAliasing=rH.None,n.isAlphaOutputRequired=!1,n._cameraType=rj.Normal,n._globalShaderMacro=new rc,n._frustum=new tX,n._virtualCamera=new rG,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 rM(ri.Camera),n._depthBufferParams=new tq,n._viewport=new tq(0,0,1,1),n._pixelViewport=new tJ(0,0,0,0),n._inverseProjectionMatrix=new tY,n._invViewProjMat=new tY,n.msaaSamples=rQ.FourX,n._isViewMatrixDirty=t.registerWorldChangeFlag(),n._isInvViewProjDirty=t.registerWorldChangeFlag(),n._frustumChangeFlag=t.registerWorldChangeFlag(),n._renderPipeline=new aa(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}t8(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(rW.AspectRatio)},n.worldToViewportPoint=function(e,t){var n=rZ.tempVec3,r=rZ.tempVec4;tk.transformCoordinate(e,this.viewMatrix,n),tk.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-tV.zeroTolerance,n,t.direction);return tk.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=rZ.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;tY.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(),rc.unionCollection(this.scene.shaderData._macroCollection,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!r._hardwareRenderer.isWebGL2&&(t=0,nA.error("mipLevel only take effect in WebGL2.0")),this._cameraType===rj.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=rq.KeepOriginalShader),this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?rf.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(rW.EnableInScene)},n._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this),this._dispatchModify(rW.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?nh.R11G11B10_UFloat:nh.R16G16B16A16:nh.R8G8B8A8},n._needFinalPass=function(){return this.antiAliasing===rH.FXAA||!this._renderTarget},n._getTargetColorTextureFormat=function(){var e=this._renderTarget;return e?e.getColorTexture(0).format:nh.R8G8B8A8},n._isTargetFormatHDR=function(){var e=this._getTargetColorTextureFormat();return e===nh.R16G16B16A16||e===nh.R32G32B32A32||e===nh.R11G11B10_UFloat},n._registerModifyListener=function(e){(this._updateFlagManager||(this._updateFlagManager=new n3)).addListener(e)},n._unRegisterModifyListener=function(e){var t;null==(t=this._updateFlagManager)||t.removeListener(e)},n._cloneTo=function(e,t,n){var r;null==(r=this._renderTarget)||r._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(rW.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=rZ.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),tk.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,tY.multiply(this._entity.transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},n._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,tY.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)},t3(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(rW.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(rW.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(rW.ProjectionType))}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize!==e&&(this._orthographicSize=e,this._projectionMatrixChange(),this._dispatchModify(rW.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 tY.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;tY.ortho(-r,r,-i,i,this.nearClipPlane,this.farClipPlane,t)}else tY.perspective(tV.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){nA.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?(nA.warn("MSAA samples exceeds the limit and is automatically downgraded to:"+t),this._msaaSamples=t):this._msaaSamples=e}}}]),t}(rL);rJ._cameraDepthTextureProperty=nG.getByName("camera_DepthTexture"),rJ._cameraOpaqueTextureProperty=nG.getByName("camera_OpaqueTexture"),rJ._cameraAOTextureProperty=nG.getByName("camera_AOTexture"),rJ._inverseViewMatrixProperty=nG.getByName("camera_ViewInvMat"),rJ._cameraPositionProperty=nG.getByName("camera_Position"),rJ._cameraForwardProperty=nG.getByName("camera_Forward"),rJ._cameraUpProperty=nG.getByName("camera_Up"),rJ._cameraDepthBufferParamsProperty=nG.getByName("camera_DepthBufferParams"),t9([ne],rJ.prototype,"_cameraType",void 0),t9([ne],rJ.prototype,"_globalShaderMacro",void 0),t9([nr],rJ.prototype,"_frustum",void 0),t9([ne],rJ.prototype,"_renderPipeline",void 0),t9([nr],rJ.prototype,"_virtualCamera",void 0),t9([ne],rJ.prototype,"_cameraIndex",void 0),t9([ne],rJ.prototype,"_updateFlagManager",void 0),t9([ne],rJ.prototype,"_frustumChangeFlag",void 0),t9([ne],rJ.prototype,"_isViewMatrixDirty",void 0),t9([ne],rJ.prototype,"_isInvViewProjDirty",void 0),t9([nr],rJ.prototype,"_shaderData",void 0),t9([ne],rJ.prototype,"_depthBufferParams",void 0),t9([nr],rJ.prototype,"_viewport",void 0),t9([nr],rJ.prototype,"_pixelViewport",void 0),t9([nr],rJ.prototype,"_inverseProjectionMatrix",void 0),t9([nr],rJ.prototype,"_invViewProjMat",void 0),t9([ne],rJ.prototype,"_onPixelViewportChanged",null),rJ=t9([rN(rU,rO.CheckOnly)],rJ);var r$=((q={})[q.Normal=0]="Normal",q[q.Additive=1]="Additive",q),r0=((Z={})[Z.Front=0]="Front",Z[Z.Back=1]="Back",Z[Z.Double=2]="Double",Z),r1=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._renderStates=[],r._shaderData=new rM(ri.Material),r.shader=n,r.name=n.name,r}t8(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),ni.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},t3(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 rR);else r.length=a}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t}(no),r2=/*#__PURE__*/function(e){function t(n,r){(i=e.call(this,n,r)||this)._renderFace=r0.Front,i._isTransparent=!1,i._blendMode=r$.Normal;var i,a=i.shaderData;return a.setFloat(t._alphaCutoffProp,0),a.setFloat(t._shadowCasterRenderQueueProp,rn.Opaque),a.setFloat(t._depthOnlyRenderQueueProp,rn.Opaque),i}t8(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=rn.Transparent,a.enableMacro(t._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=a.getFloat(t._alphaCutoffProp)?rn.AlphaTest:rn.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 r$.Normal:r.sourceColorBlendFactor=n9.SourceAlpha,r.destinationColorBlendFactor=n9.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=n9.One,r.destinationAlphaBlendFactor=n9.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=n6.Add;break;case r$.Additive:r.sourceColorBlendFactor=n9.SourceAlpha,r.destinationColorBlendFactor=n9.One,r.sourceAlphaBlendFactor=n9.Zero,r.destinationAlphaBlendFactor=n9.One,r.colorBlendOperation=r.alphaBlendOperation=n6.Add}},n.setRenderFace=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";switch(t){case r0.Front:n[e].rasterState.cullMode=rt.Back;break;case r0.Back:n[e].rasterState.cullMode=rt.Front;break;case r0.Double:n[e].rasterState.cullMode=rt.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,rn.AlphaTest),n.setFloat(t._depthOnlyRenderQueueProp,rn.Transparent);else{var r=n.getFloat(t._alphaCutoffProp)?rn.AlphaTest:rn.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?rn.Transparent:rn.AlphaTest;this.renderStates[0].renderQueueType=i,n.setFloat(t._shadowCasterRenderQueueProp,rn.AlphaTest),n.setFloat(t._depthOnlyRenderQueueProp,i)}else{n.disableMacro(t._alphaCutoffMacro);var a=r?rn.Transparent:rn.Opaque;this.renderStates[0].renderQueueType=a;var o=r?rn.AlphaTest:rn.Opaque;n.setFloat(t._shadowCasterRenderQueueProp,o),n.setFloat(t._depthOnlyRenderQueueProp,a)}n.setFloat(t._alphaCutoffProp,e)}},t3(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 rR),this.setBlendMode(l,r$.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}(r1);r2._shadowCasterRenderQueueProp=nG.getByName("material_ShadowCasterRenderQueue"),r2._depthOnlyRenderQueueProp=nG.getByName("material_DepthOnlyRenderQueue"),r2._baseTextureMacro=rl.getByName("MATERIAL_HAS_BASETEXTURE"),r2._normalTextureMacro=rl.getByName("MATERIAL_HAS_NORMALTEXTURE"),r2._emissiveTextureMacro=rl.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),r2._transparentMacro=rl.getByName("MATERIAL_IS_TRANSPARENT"),r2._baseColorProp=nG.getByName("material_BaseColor"),r2._baseTextureProp=nG.getByName("material_BaseTexture"),r2._tilingOffsetProp=nG.getByName("material_TilingOffset"),r2._normalTextureProp=nG.getByName("material_NormalTexture"),r2._normalIntensityProp=nG.getByName("material_NormalIntensity"),r2._emissiveColorProp=nG.getByName("material_EmissiveColor"),r2._emissiveTextureProp=nG.getByName("material_EmissiveTexture"),r2._alphaCutoffProp=nG.getByName("material_AlphaCutoff"),r2._alphaCutoffMacro=rl.getByName("MATERIAL_IS_ALPHA_CUTOFF");var r3=/*#__PURE__*/function(e){function t(n){var r,i=(r=e.call(this,n,rE.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tZ(1,1,1,1)),i.setColor(t._specularColorProp,new tZ(1,1,1,1)),i.setColor(t._emissiveColorProp,new tZ(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tq(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return t8(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t3(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}(r2);r3._specularColorProp=nG.getByName("material_SpecularColor"),r3._shininessProp=nG.getByName("material_Shininess"),r3._specularTextureProp=nG.getByName("material_SpecularTexture");var r4=((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),r8=(($={})[$.Sphere=0]="Sphere",$[$.Planar=1]="Planar",$),r5=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n,rE.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 tZ(1,1,1,1)),i.setColor(t._emissiveColorProp,new tZ(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tq(1,1,0,0)),i.setFloat(t._normalIntensityProp,1),i.setFloat(t._occlusionTextureIntensityProp,1),i.setFloat(t._occlusionTextureCoordProp,r4.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 tk(1,0,0)),i.setVector4(t._iridescenceInfoProp,new tq(0,1.3,100,400));var a=new tZ(0,0,0);return i.setColor(t._sheenColorProp,a),r.refractionMode=r8.Planar,i.setFloat(t._transmissionProp,0),i.setFloat(t._thicknessProp,0),i.setFloat(t._attenuationDistanceProp,1/0),i.setColor(t._attenuationColorProp,new tZ(1,1,1)),i.setFloat(t._specularIntensityProp,1),i.setColor(t._specularColorProp,new tZ(1,1,1)),r._iridescenceRange._onValueChanged=r._onIridescenceRangeChanged.bind(r),a._onValueChanged=r._onSheenColorChanged.bind(r),r}t8(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"))},t3(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>r4.UV1&&nA.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=tV.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=rn.Transparent)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(r2._alphaCutoffProp)},set:function(e){this._setAlphaCutoff(e),this.transmission>0&&(this.renderState.renderQueueType=rn.Transparent)}},{key:"transmission",get:function(){return this.shaderData.getFloat(t._transmissionProp)},set:function(e){e=tV.clamp(e,0,1),!!this.shaderData.getFloat(t._transmissionProp)!=!!e&&(e>0?(this.shaderData.enableMacro(t._transmissionMacro),this.renderState.renderQueueType=rn.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}(r2);r5._occlusionTextureIntensityProp=nG.getByName("material_OcclusionIntensity"),r5._occlusionTextureCoordProp=nG.getByName("material_OcclusionTextureCoord"),r5._occlusionTextureProp=nG.getByName("material_OcclusionTexture"),r5._clearCoatProp=nG.getByName("material_ClearCoat"),r5._clearCoatTextureProp=nG.getByName("material_ClearCoatTexture"),r5._clearCoatRoughnessProp=nG.getByName("material_ClearCoatRoughness"),r5._clearCoatRoughnessTextureProp=nG.getByName("material_ClearCoatRoughnessTexture"),r5._clearCoatNormalTextureProp=nG.getByName("material_ClearCoatNormalTexture"),r5._metallicProp=nG.getByName("material_Metal"),r5._roughnessProp=nG.getByName("material_Roughness"),r5._roughnessMetallicTextureProp=nG.getByName("material_RoughnessMetallicTexture"),r5._iorProp=nG.getByName("material_IOR"),r5._anisotropyInfoProp=nG.getByName("material_AnisotropyInfo"),r5._anisotropyTextureProp=nG.getByName("material_AnisotropyTexture"),r5._iridescenceInfoProp=nG.getByName("material_IridescenceInfo"),r5._iridescenceThicknessTextureProp=nG.getByName("material_IridescenceThicknessTexture"),r5._iridescenceTextureProp=nG.getByName("material_IridescenceTexture"),r5._sheenColorProp=nG.getByName("material_SheenColor"),r5._sheenRoughnessProp=nG.getByName("material_SheenRoughness"),r5._sheenTextureProp=nG.getByName("material_SheenTexture"),r5._sheenRoughnessTextureProp=nG.getByName("material_SheenRoughnessTexture"),r5._transmissionMacro=rl.getByName("MATERIAL_ENABLE_TRANSMISSION"),r5._thicknessMacro=rl.getByName("MATERIAL_HAS_THICKNESS"),r5._thicknessTextureMacro=rl.getByName("MATERIAL_HAS_THICKNESS_TEXTURE"),r5._transmissionTextureMacro=rl.getByName("MATERIAL_HAS_TRANSMISSION_TEXTURE"),r5._transmissionProp=nG.getByName("material_Transmission"),r5._transmissionTextureProp=nG.getByName("material_TransmissionTexture"),r5._attenuationColorProp=nG.getByName("material_AttenuationColor"),r5._attenuationDistanceProp=nG.getByName("material_AttenuationDistance"),r5._thicknessProp=nG.getByName("material_Thickness"),r5._thicknessTextureProp=nG.getByName("material_ThicknessTexture"),r5._specularTextureMacro=rl.getByName("MATERIAL_HAS_SPECULAR_TEXTURE"),r5._specularColorTextureMacro=rl.getByName("MATERIAL_HAS_SPECULAR_COLOR_TEXTURE"),r5._specularIntensityProp=nG.getByName("material_SpecularIntensity"),r5._specularColorProp=nG.getByName("material_SpecularColor"),r5._specularIntensityTextureProp=nG.getByName("material_SpecularIntensityTexture"),r5._specularColorTextureProp=nG.getByName("material_SpecularColorTexture");var r9=/*#__PURE__*/function(e){function t(n){var r,i=(r=e.call(this,n,rE.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tZ(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new tq(1,1,0,0)),r}return t8(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t3(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}(r2),r6=/*#__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}();r6.defaultViewport=new tq(0,0,1,1);var r7=/*#__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=r6.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=rE._compileMacros;rc.unionCollection(f._globalShaderMacro,d.shaderData._macroCollection,g),rc.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}();r7._blitTextureProperty=nG.getByName("renderer_BlitTexture"),r7._blitMipLevelProperty=nG.getByName("renderer_BlitMipLevel"),r7._blitTexelSizeProperty=nG.getByName("renderer_texelSize"),r7._sourceScaleOffsetProperty=nG.getByName("renderer_SourceScaleOffset"),r7._rendererShaderData=new rM(ri.Renderer),r7._texelSize=new tq,r7._defaultScaleOffset=new tq(1,1,0,0);var ie=function(e){this.engine=e},it="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}",ir=((ee={})[ee.Low=0]="Low",ee[ee.Medium=1]="Medium",ee[ee.High=2]="High",ee),ii=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._invProjScaleXY=new tQ,r._offsetX=new tq,r._offsetY=new tq;var r,i=new r1(n,rE.find(t.SHADER_NAME));return i._addReferCount(1),r._material=i,r.isSupported=r.engine._hardwareRenderer.capability.isFragmentHighPrecision,r}t8(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=nh.R8G8B8;this._saoRenderTarget=r6.recreateRenderTargetIfNeeded(n,this._saoRenderTarget,i,a,o,null,!1,!1,!1,1,nf.Clamp,nd.Bilinear),this._blurRenderTarget=r6.recreateRenderTargetIfNeeded(n,this._blurRenderTarget,i,a,o,null,!1,!1,!1,1,nf.Clamp,nd.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;r7.blitTexture(n,x,v,0,void 0,y,0);var A=v.getColorTexture(),b=this._offsetX.set(1,1,this._blurStepPixels/A.width,0);r7.blitTexture(n,A,this._blurRenderTarget,0,void 0,y,1,b);var S=this._blurRenderTarget.getColorTexture(),T=this._offsetY.set(1,1,0,this._blurStepPixels/A.height);r7.blitTexture(n,S,v,0,void 0,y,1,T),r.shaderData.setTexture(rJ._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 ir.Low:r=7,a=8/(i=4),o=24/i-1;break;case ir.Medium:r=11,a=8/(i=2),o=24/i-1;break;case ir.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}(ie);ii.SHADER_NAME="ScalableAmbientOcclusion",ii._invRadiusSquaredProp=nG.getByName("material_invRadiusSquared"),ii._intensityProp=nG.getByName("material_intensity"),ii._projectionScaleRadiusProp=nG.getByName("material_projectionScaleRadius"),ii._biasProp=nG.getByName("material_bias"),ii._minHorizonAngleSineSquaredProp=nG.getByName("material_minHorizonAngleSineSquared"),ii._peak2Prop=nG.getByName("material_peak2"),ii._powerProp=nG.getByName("material_power"),ii._invProjScaleXYProp=nG.getByName("material_invProjScaleXY"),ii._farPlaneOverEdgeDistanceProp=nG.getByName("material_farPlaneOverEdgeDistance"),ii._kernelProp=nG.getByName("material_kernel"),rE.create(ii.SHADER_NAME,[new ry("ScalableAmbientOcclusion",it,"// 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 ry("BilateralBlur",it,"#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 ia=/*#__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)},t3(e,[{key:"value",get:function(){return this._value},set:function(e){this._value=e}}]),e}(),io=/*#__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 t8(t,e),t.prototype._lerp=function(t,n){this._needLerp?this.value=tV.lerp(this.value,t,n):e.prototype._lerp.call(this,t,n)},t3(t,[{key:"value",get:function(){return this._value},set:function(e){this._value=tV.clamp(e,this.min,this.max)}}]),t}(ia),is=/*#__PURE__*/function(e){function t(t){return e.call(this,t,!1)||this}return t8(t,e),t}(ia),il=/*#__PURE__*/function(e){function t(t){return e.call(this,t,!1)||this}return t8(t,e),t}(ia),ic=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t8(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}(ia),iu=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t8(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}(ia),id=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t8(t,e),t.prototype._lerp=function(t,n){this._needLerp?tk.lerp(this.value,t,n,this.value):e.prototype._lerp.call(this,t,n)},t}(ia),ih=/*#__PURE__*/function(e){function t(t,n){return void 0===n&&(n=!0),e.call(this,t,n)||this}return t8(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}(ia),i_=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,n,!1)||this).enumType=t,r}return t8(t,e),t}(ia),ip=/*#__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];t6(t,ia)&&this._parameters.push(t)}return this._parameters},t3(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e)}}]),e}(),im=((et={})[et.Half=0]="Half",et[et.Quarter=1]="Quarter",et),ig=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.highQualityFiltering=new is(!1),t.downScale=new i_(im,0),t.dirtTexture=new il(null),t.threshold=new io(.8,0),t.scatter=new io(.7,0,1),t.intensity=new io(0,0),t.dirtIntensity=new io(0,0),t.tint=new ic(new tZ(1,1,1,1)),t}return t8(t,e),t.prototype.isValid=function(){return this.enabled&&this.intensity.value>0},t}(ip);ig.SHADER_NAME="PostProcessEffect Bloom",ig._maxIterations=6,ig._hqMacro=rl.getByName("BLOOM_HQ"),ig._dirtMacro=rl.getByName("BLOOM_DIRT"),ig._bloomParams=nG.getByName("material_BloomParams"),ig._lowMipTextureProp=nG.getByName("material_lowMipTexture"),ig._lowMipTexelSizeProp=nG.getByName("material_lowMipTexelSize"),ig._enableMacro=rl.getByName("ENABLE_EFFECT_BLOOM"),ig._bloomTextureProp=nG.getByName("material_BloomTexture"),ig._dirtTextureProp=nG.getByName("material_BloomDirtTexture"),ig._tintProp=nG.getByName("material_BloomTint"),ig._bloomIntensityParams=nG.getByName("material_BloomIntensityParams"),ig._dirtTilingOffsetProp=nG.getByName("material_BloomDirtTilingOffset"),rE.create(ig.SHADER_NAME,[new ry("Bloom Prefilter",it,"#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 ry("Bloom Blur Horizontal",it,"#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 ry("Bloom Blur Vertical",it,"#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 ry("Bloom Upsample",it,"#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 iv=((en={})[en.Neutral=0]="Neutral",en[en.ACES=1]="ACES",en),iy=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.mode=new i_(iv,0),t}return t8(t,e),t}(ip);iy._enableMacro=rl.getByName("ENABLE_EFFECT_TONEMAPPING");var ix=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.layer=rV.Layer0,t.blendDistance=0,t._effects=[],t._priority=0,t._isGlobal=!0,t}t8(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(t6(i,e))return i}},n.addEffect=function(e){if(this.getEffect(e)){nA.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(t6(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},t3(t,[{key:"isGlobal",get:function(){return this._isGlobal},set:function(e){if(e!==this._isGlobal){if(!e&&!this.engine._physicsInitialized){nA.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}(rL);t9([nr],ix.prototype,"_effects",void 0);var iA=((er={})[er.Property=1]="Property",er[er.Count=2]="Count",er[er.Both=3]="Both",er),ib=/*#__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}t8(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(iA.Count))},n.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this._removeNativeShape(e),this._handleShapesChanged(iA.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(iA.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&iA.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)},t3(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}(rL);t9([ne],ib.prototype,"_index",void 0),t9([ne],ib.prototype,"_nativeCollider",void 0),t9([ne],ib.prototype,"_updateFlag",void 0),t9([nr],ib.prototype,"_shapes",void 0),ib=t9([rN(rU,rO.CheckOnly)],ib);var iS=((ei={})[ei.PreventClimbing=0]="PreventClimbing",ei[ei.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding",ei),iT=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=iS.PreventClimbing,n._upDirection=new tk(0,1,0),n._slopeLimit=45,n._nativeCollider=oX._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(n),n._upDirection._onValueChanged=n._setUpDirection,n._nativeCollider.setWorldPosition(n.entity.transform.worldPosition),n}t8(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)},t3(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}(ib);t9([nr],iT.prototype,"_upDirection",void 0),t9([ne],iT.prototype,"_setUpDirection",null);var iC=((ea={})[ea.Cleaning=1]="Cleaning",ea[ea.VertexWelding=2]="VertexWelding",ea),iR=((eo={})[eo.Average=0]="Average",eo[eo.Minimum=1]="Minimum",eo[eo.Multiply=2]="Multiply",eo[eo.Maximum=3]="Maximum",eo),iE=/*#__PURE__*/function(){function e(){this._bounciness=0,this._dynamicFriction=.6,this._staticFriction=.6,this._bounceCombine=iR.Average,this._frictionCombine=iR.Average,this._nativeMaterial=oX._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},t3(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}(),iM=/*#__PURE__*/function(){function e(){this._isTrigger=!1,this._rotation=new tk,this._position=new tk,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new iE,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,oX._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 oX._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(iA.Property))},t._setPosition=function(){var e,t;null==(e=this._nativeShape)||e.setPosition(this._position),null==(t=this._collider)||t._handleShapesChanged(iA.Property)},t._setRotation=function(){var e,t;null==(e=this._nativeShape)||e.setRotation(this._rotation),null==(t=this._collider)||t._handleShapesChanged(iA.Property)},t3(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}();iM._idGenerator=0,t9([ne],iM.prototype,"_collider",void 0),t9([ne],iM.prototype,"_nativeShape",void 0),t9([ne],iM.prototype,"_id",void 0),t9([nr],iM.prototype,"_rotation",void 0),t9([nr],iM.prototype,"_position",void 0),t9([ne],iM.prototype,"_setPosition",null),t9([ne],iM.prototype,"_setRotation",null);var iP=/*#__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=iC.Cleaning|iC.VertexWelding,t._isShapeAttached=!1,t}t8(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&&t6(this._collider,iw)&&!this._collider.isKinematic){console.error("MeshColliderShape: Non-convex mesh is not supported on non-kinematic DynamicCollider.");return}var t=oX._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()))},t3(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}(iM),iw=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._linearDamping=0,n._angularDamping=.05,n._linearVelocity=new tk,n._angularVelocity=new tk,n._mass=1,n._centerOfMass=new tk,n._inertiaTensor=new tk(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=oX._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}t8(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(t6(t,iP)&&!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),tk.equals(i,n)||n.copyFrom(i),tj.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)},t3(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(t6(i,iP)&&!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}(ib);iw._tempVector3=new tk,iw._tempQuat=new tj,t9([ne],iw.prototype,"_linearVelocity",void 0),t9([ne],iw.prototype,"_angularVelocity",void 0),t9([ne],iw.prototype,"_centerOfMass",void 0),t9([ne],iw.prototype,"_inertiaTensor",void 0),t9([ne],iw.prototype,"_setLinearVelocity",null),t9([ne],iw.prototype,"_setAngularVelocity",null),t9([ne],iw.prototype,"_handleCenterOfMassChanged",null),t9([ne],iw.prototype,"_handleInertiaTensorChanged",null);var iF=((es={})[es.Discrete=0]="Discrete",es[es.Continuous=1]="Continuous",es[es.ContinuousDynamic=2]="ContinuousDynamic",es[es.ContinuousSpeculative=3]="ContinuousSpeculative",es),iD=((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),iB=function(){this.entity=null,this.distance=0,this.point=new tk,this.normal=new tk,this.shape=null},iL=function(){this.position=new tk,this.normal=new tk,this.impulse=new tk},iI=/*#__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 iL);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},t3(e,[{key:"contactCount",get:function(){return this._nativeCollision.contactCount}}]),e}(),iN=/*#__PURE__*/function(){function e(t){this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new nK,this._gravity=new tk(0,-9.81,0),this._onContactEnter=function(t){var n=oX._physicalObjectsMap,r=t.shape0Id,i=t.shape1Id,a=n[r],o=n[i],s=e._collision;s._nativeCollision=t,a.collider.entity._scripts.forEach(function(e){s.shape=o,e.onCollisionEnter(s)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){s.shape=a,e.onCollisionEnter(s)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(t){var n=oX._physicalObjectsMap,r=t.shape0Id,i=t.shape1Id,a=n[r],o=n[i],s=e._collision;s._nativeCollision=t,a.collider.entity._scripts.forEach(function(e){s.shape=o,e.onCollisionExit(s)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){s.shape=a,e.onCollisionExit(s)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(t){var n=oX._physicalObjectsMap,r=t.shape0Id,i=t.shape1Id,a=n[r],o=n[i],s=e._collision;s._nativeCollision=t,a.collider.entity._scripts.forEach(function(e){s.shape=o,e.onCollisionStay(s)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){s.shape=a,e.onCollisionStay(s)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=oX._physicalObjectsMap,r=n[e],i=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=oX._physicalObjectsMap,r=n[e],i=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=oX._physicalObjectsMap,r=n[e],i=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(r)},function(e,t){e._entityScriptsIndex=t})},this._scene=t,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var n=t.engine;n._physicsInitialized&&(this._nativePhysicsScene=oX._nativePhysics.createPhysicsScene(n._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}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 oX._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)");oX._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=rV.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=rV.Everything;"number"==typeof i?(u=i,(null==a?void 0:a.constructor)===iB&&(l=a)):(null==i?void 0:i.constructor)===iB?l=i:(null==i?void 0:i.constructor)===tj&&(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=rV.Everything;"number"==typeof r?(s=r,(null==i?void 0:i.constructor)===iB?o=i:"number"==typeof i&&(l=i)):(null==r?void 0:r.constructor)===iB&&(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=rV.Everything;"number"==typeof a?(d=a,(null==o?void 0:o.constructor)===iB&&(c=o)):(null==a?void 0:a.constructor)===iB?c=a:(null==a?void 0:a.constructor)===tj&&(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=rV.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(oX._physicalObjectsMap[o[s]]);return a},t.overlapSphereAll=function(e,t,n,r){void 0===n&&(n=rV.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(oX._physicalObjectsMap[i[a]]);return r},t.overlapCapsuleAll=function(t,n,r,i,a,o){void 0===i&&(i=e._identityQuaternion),void 0===a&&(a=rV.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(oX._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()},t._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},t._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},t._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},t._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},t._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},t._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},t._gc=function(){this._colliders.garbageCollection()},t._destroy=function(){var e;null==(e=this._nativePhysicsScene)||e.destroy()},t._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},t._createPreFilter=function(e){return function(t){var n=oX._physicalObjectsMap[t];return!!n&&n.collider.entity.layer&e&&n.isSceneQuery}},t._createHitCallback=function(e){return function(t,n,r,i){e.entity=oX._physicalObjectsMap[t].collider.entity,e.shape=oX._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)},t3(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,tV.zeroTolerance)}}]),e}();iN._collision=new iI,iN._identityQuaternion=new tj(0,0,0,1);var iO=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t)||this).entity.transform;return n._nativeCollider=oX._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),n}return t8(t,e),t}(ib),iV=((ec={})[ec.X=0]="X",ec[ec.Y=1]="Y",ec[ec.Z=2]="Z",ec),ik=((eu={})[eu.Sides=1]="Sides",eu[eu.Up=2]="Up",eu[eu.Down=4]="Down",eu),iU=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._colliderInfo=new iz,n._connectedColliderInfo=new iz,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}t8(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;tk.transformCoordinate(e.anchor,this.entity.transform.worldMatrix,o),tY.invert(a.entity.transform.worldMatrix,s),tk.transformCoordinate(o,s,r)}else tk.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&rz.WorldScale&&this._updateActualAnchor(1)},n._onConnectedTransformChanged=function(e){e&rz.WorldScale&&this._updateActualAnchor(2)},n._updateRotation=function(){var e,n=t._tempQuat,r=this._connectedColliderInfo.collider;r&&tj.invert(r.entity.transform.worldRotationQuaternion,n),tj.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;tk.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;tk.multiply(a.anchor,s,a.actualAnchor)}else a.actualAnchor.copyFrom(a.anchor);null==(i=this._nativeJoint)||i.setConnectedAnchor(a.actualAnchor)}},t3(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}(rL);iU._tempVector3=new tk,iU._tempQuat=new tj,iU._tempMatrix=new tY,t9([nr],iU.prototype,"_colliderInfo",void 0),t9([nr],iU.prototype,"_connectedColliderInfo",void 0),t9([ne],iU.prototype,"_nativeJoint",void 0),t9([ne],iU.prototype,"_handleConnectedAnchorChanged",null),t9([ne],iU.prototype,"_onSelfTransformChanged",null),t9([ne],iU.prototype,"_onConnectedTransformChanged",null),iU=t9([rN(iw,rO.AutoAdd)],iU);var iz=function(){this.collider=null,this.anchor=new tk,this.actualAnchor=new tk,this.massScale=1,this.inertiaScale=1};t9([nr],iz.prototype,"anchor",void 0),t9([nr],iz.prototype,"actualAnchor",void 0);var iG=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t8(t,e),t.prototype._createJoint=function(){var e=this._colliderInfo;e.collider=this.entity.getComponent(ib),this._nativeJoint=oX._nativePhysics.createFixedJoint(e.collider._nativeCollider)},t}(iU),iH=((ed={})[ed.None=0]="None",ed[ed.LimitEnabled=1]="LimitEnabled",ed[ed.DriveEnabled=2]="DriveEnabled",ed[ed.DriveFreeSpin=4]="DriveFreeSpin",ed),iX=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._axis=new tk(1,0,0),n._hingeFlags=iH.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}t8(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(ib),this._nativeJoint=oX._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(iH.LimitEnabled,this.useLimits),this._nativeJoint.setHingeJointFlag(iH.DriveEnabled,this.useMotor),t&&(this._nativeJoint.setDriveVelocity(t.targetVelocity),this._nativeJoint.setDriveForceLimit(t.forceLimit),this._nativeJoint.setDriveGearRatio(t.gearRatio),this._nativeJoint.setHingeJointFlag(iH.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(iH.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},t3(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&iH.LimitEnabled)==iH.LimitEnabled},set:function(e){if(e!==this.useLimits){var t;e?this._hingeFlags|=iH.LimitEnabled:this._hingeFlags&=~iH.LimitEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iH.LimitEnabled,e)}}},{key:"useMotor",get:function(){return(this._hingeFlags&iH.DriveEnabled)==iH.DriveEnabled},set:function(e){if(e!==this.useMotor){var t;e?this._hingeFlags|=iH.DriveEnabled:this._hingeFlags&=~iH.DriveEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iH.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}(iU);t9([nr],iX.prototype,"_axis",void 0),t9([nr],iX.prototype,"_jointMotor",void 0),t9([nr],iX.prototype,"_limits",void 0),t9([ne],iX.prototype,"_onMotorChanged",null),t9([ne],iX.prototype,"_onLimitsChanged",null),t9([ne],iX.prototype,"_onAxisChanged",null);var iW=/*#__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}t8(t,e);var n=t.prototype;return n._createJoint=function(){var e=this._colliderInfo;e.collider=this.entity.getComponent(ib),this._nativeJoint=oX._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)},t3(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}(iU),ij=/*#__PURE__*/function(){function e(){this._updateFlagManager=new n3,this._max=0,this._min=0,this._contactDistance=-1,this._stiffness=0,this._damping=0}return t3(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}();t9([nr],ij.prototype,"_updateFlagManager",void 0);var iY=/*#__PURE__*/function(){function e(){this._updateFlagManager=new n3,this._targetVelocity=0,this._forceLimit=Number.MAX_VALUE,this._gearRatio=1,this._freeSpin=!1}return t3(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}();t9([nr],iY.prototype,"_updateFlagManager",void 0);var iK=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._size=new tk(1,1,1),t._nativeShape=oX._nativePhysics.createBoxColliderShape(t._id,t._size,t._material._nativeMaterial),t._size._onValueChanged=t._setSize.bind(t),t}t8(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)},t3(t,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),t}(iM);t9([nr],iK.prototype,"_size",void 0),t9([ne],iK.prototype,"_setSize",null);var iQ=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._nativeShape=oX._nativePhysics.createSphereColliderShape(t._id,t._radius,t._material._nativeMaterial),t}return t8(t,e),t.prototype._syncNative=function(){e.prototype._syncNative.call(this),this._nativeShape.setRadius(this._radius)},t3(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),t}(iM),iq=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._nativeShape=oX._nativePhysics.createPlaneColliderShape(t._id,t._material._nativeMaterial),t}return t8(t,e),t.prototype.getClosestPoint=function(e,t){return console.error("PlaneColliderShape is not support getClosestPoint"),-1},t}(iM),iZ=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._height=2,t._upAxis=iV.Y,t._nativeShape=oX._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t}return t8(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)},t3(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}(iM),iJ=/*#__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(ib,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){nA.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=r6.recreateRenderTargetIfNeeded(e.engine,this._outputRenderTarget,t.width,t.height,e._getTargetColorTextureFormat(),null,!1,!1,!e._isTargetFormatHDR(),1,nf.Clamp,nd.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=r6.recreateRenderTargetIfNeeded(this.scene.engine,this._swapRenderTarget,t.width,t.height,e._getInternalColorTextureFormat(),nh.Depth24Stencil8,!1,!1,!e.enableHDR,1,nf.Clamp,nd.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}();iJ._tempColliders=[],iJ._tempVector3=new tk;var i$=((eh={})[eh.BeforeUber=0]="BeforeUber",eh[eh.AfterUber=100]="AfterUber",eh),i0=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._event=100,t._isActive=!0,t}t8(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)},t3(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}(na),i1=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._mipDownRT=[],r._mipUpRT=[],r.event=i$.AfterUber-1;var r,i=new r1(n,rE.find(t.UBER_SHADER_NAME)),a=i.renderState.depthState;a.enabled=!1,a.writeEnabled=!1,r._uberMaterial=i;var o=new r1(n,rE.find(ig.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(ig._bloomParams,new tq),l.setVector4(ig._lowMipTexelSizeProp,new tq),c.setVector4(ig._bloomIntensityParams,new tq),c.setVector4(ig._dirtTilingOffsetProp,new tq),c.setColor(ig._tintProp,new tZ),r}t8(t,e);var n=t.prototype;return n.isValid=function(e){if(!this.isActive)return!1;var t=e.getBlendEffect(ig),n=e.getBlendEffect(iy);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(ig),o=r.getBlendEffect(iy);(null==a?void 0:a.isValid())?(this._setupBloom(a,e,t),i.enableMacro(ig._enableMacro)):(i.disableMacro(ig._enableMacro),this._releaseBloomRenderTargets()),(null==o?void 0:o.isValid())?(i.enableMacro("TONEMAPPING_MODE",o.mode.value.toString()),i.enableMacro(iy._enableMacro)):i.disableMacro(iy._enableMacro);var s=n===e.renderTarget?e.viewport:void 0;r7.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(ig._bloomParams),v=tV.lerp(.05,.95,c.value);g.x=p,g.y=m,g.z=v;var y=o.getVector4(ig._bloomIntensityParams);y.x=u.value,y.y=f.value,o.getColor(ig._tintProp).copyFrom(d.value),h.value?(a.enableMacro(ig._hqMacro),o.enableMacro(ig._hqMacro)):(a.disableMacro(ig._hqMacro),o.disableMacro(ig._hqMacro)),o.setTexture(ig._dirtTextureProp,_.value),_.value?o.enableMacro(ig._dirtMacro):o.disableMacro(ig._dirtMacro);for(var x=s.value===im.Half?1:2,A=t.pixelViewport,b=A.width>>x,S=A.height>>x,T=Math.min(Math.max(Math.floor(Math.log2(Math.max(b,S))-1),1),ig._maxIterations),C=t._getInternalColorTextureFormat(),R=b,E=S,M=0;M<T;M++)this._mipUpRT[M]=r6.recreateRenderTargetIfNeeded(r,this._mipUpRT[M],R,E,C,null,!1,!1,!t.enableHDR,1,nf.Clamp,nd.Bilinear),this._mipDownRT[M]=r6.recreateRenderTargetIfNeeded(r,this._mipDownRT[M],R,E,C,null,!1,!1,!t.enableHDR,1,nf.Clamp,nd.Bilinear),R=Math.max(1,Math.floor(R/2)),E=Math.max(1,Math.floor(E/2));r7.blitTexture(r,n,this._mipDownRT[0],void 0,void 0,i,0);for(var P=this._mipDownRT[0],w=1;w<T;w++)r7.blitTexture(r,P.getColorTexture(0),this._mipUpRT[w],void 0,void 0,i,1),r7.blitTexture(r,this._mipUpRT[w].getColorTexture(0),this._mipDownRT[w],void 0,void 0,i,2),P=this._mipDownRT[w];for(var F=T-2;F>=0;F--){var D=F==T-2?this._mipDownRT[F+1]:this._mipUpRT[F+1],B=this._mipDownRT[F],L=this._mipUpRT[F];a.setTexture(ig._lowMipTextureProp,D.getColorTexture(0)),h&&a.getVector4(ig._lowMipTexelSizeProp).set(1/D.width,1/D.height,D.width,D.height),r7.blitTexture(r,B.getColorTexture(0),L,void 0,void 0,i,3)}if(_.value){var I=o.getVector4(ig._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(ig._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}(i0);i1.UBER_SHADER_NAME="UberPost",Object.assign(rh,{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}"}),rE.create(i1.UBER_SHADER_NAME,it,"#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 i2=/*#__PURE__*/function(e){function t(t){n=e.call(this,t)||this;var n,r=new r1(t,rE.find("FinalSRGB")),i=r.renderState.depthState;i.enabled=!1,i.writeEnabled=!1,r._addReferCount(1),n._sRGBmaterial=r;var a=new r1(t,rE.find("FinalAntiAliasing")),o=a.renderState.depthState;return o.enabled=!1,o.writeEnabled=!1,a._addReferCount(1),n._antiAliasingMaterial=a,n}t8(t,e);var n=t.prototype;return n.onConfig=function(e,t){if(this._inputRenderTarget=t,e.antiAliasing===rH.FXAA){var n=e.pixelViewport;this._srgbRenderTarget=r6.recreateRenderTargetIfNeeded(this.engine,this._srgbRenderTarget,n.width,n.height,nh.R8G8B8A8,null,!1,!1,!1,1,nf.Clamp,nd.Bilinear)}},n.onRender=function(e){var t=this.engine,n=e.camera,r=n.viewport,i=n.renderTarget,a=n.antiAliasing===rH.FXAA,o=this._inputRenderTarget.getColorTexture();if(a){r7.blitTexture(t,o,this._srgbRenderTarget,0,void 0,this._sRGBmaterial);var s=this._srgbRenderTarget.getColorTexture();r7.blitTexture(t,s,i,0,r,this._antiAliasingMaterial)}else r7.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}(ie);Object.assign(rh,{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"}),rE.create("FinalSRGB",it,"#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"),rE.create("FinalAntiAliasing",it,"#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 i3=((e_={})[e_.No=0]="No",e_[e_.Increment=1]="Increment",e_[e_.Decrement=2]="Decrement",e_),i4=/*#__PURE__*/function(){function e(e){this.renderQueueType=e,this.elements=[],this.batchedSubElements=[],this.rendererUpdateFlag=rw.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=i3.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=rP.pipelineStageKey,m=this.renderQueueType,g=0;g<i;g++){var v=r[g],y=v.component,x=v.batched,A=v.material;this.rendererUpdateFlag&rw.WorldViewMatrix||y._batchedTransformShaderData!=x?(y._updateTransformShaderData(e,!1,x),y._batchedTransformShaderData=x):this.rendererUpdateFlag&rw.ProjectionMatrix&&y._updateTransformShaderData(e,!0,x);var b=y._maskInteraction,S=b!==n$.None,T=n!==i3.No,C=null;T?C=a9.getMaskTypeRenderStates(n):(S?(h.drawMask(e,t,v.component._maskLayer),C=a9.getMaskInteractionRenderStates(b)):h.isReadStencil(A)&&h.clearMask(e,t),h.isStencilWritten(A)&&(h.hasStencilWritten=!0));var R=rE._compileMacros,E=v.primitive,M=v.shaderPasses,P=v.shaderData,w=y.shaderData,F=y.instanceId,D=A.shaderData,B=A.instanceId,L=A.renderStates;rc.unionCollection(y._globalShaderMacro,D._macroCollection,R),rc.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(T)V||(V=L[I]);else if((V?V._getRenderQueueByShaderData(O._renderStateDataMap,D):(V=L[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,D),P&&k.uploadAll(k.renderElementUniformBlock,P),k.uploadUnGroupTextures(),k._uploadSceneId=u,k._uploadCameraId=l,k._uploadRendererId=F,k._uploadMaterialId=B,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!==B?(k.uploadAll(k.materialUniformBlock,D),k._uploadMaterialId=B):U&&k.uploadTextures(k.materialUniformBlock,D),P&&k.uploadAll(k.renderElementUniformBlock,P),U&&k.uploadUnGroupTextures()),V._applyStates(o,y._isFrontFaceInvert(),O._renderStateDataMap,A.shaderData,C),f.drawPrimitive(E,v.subPrimitive,k)}}}}this.rendererUpdateFlag=rw.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}(),i8=/*#__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===n$.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=ah._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}();i8._disableBatchTag=rf.getByName("spriteDisableBatching");var i5=function(){this.virtualCamera=new rG,this.cullPlanes=[new tH(new tk),new tH(new tk),new tH(new tk),new tH(new tk),new tH(new tk),new tH(new tk),new tH(new tk),new tH(new tk),new tH(new tk),new tH(new tk)],this.splitBoundSphere=new tU(new tk,0)},i9=((ef={})[ef.Low=0]="Low",ef[ef.Medium=1]="Medium",ef[ef.High=2]="High",ef[ef.VeryHigh=3]="VeryHigh",ef),i6=((ep={})[ep.None=0]="None",ep[ep.Hard=1]="Hard",ep[ep.SoftLow=2]="SoftLow",ep[ep.SoftHigh=3]="SoftHigh",ep),i7=/*#__PURE__*/function(){function e(){}return e.shadowResolution=function(e){switch(e){case i9.Low:return 512;case i9.Medium:return 1024;case i9.High:return 2048;case i9.VeryHigh:return 4096}},e.shadowDepthFormat=function(e,t){return t?nh.Depth16:nh.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(tV.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,tk.scale(r,a,_),tk.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(tI.Near),_=t.getPlane(tI.Far),f=t.getPlane(tI.Left),p=t.getPlane(tI.Right),m=t.getPlane(tI.Bottom),g=t.getPlane(tI.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),tG.intersectionPointThreePlanes(v,m,p,o[7]),tG.intersectionPointThreePlanes(v,g,p,o[6]),tG.intersectionPointThreePlanes(v,g,f,o[5]),tG.intersectionPointThreePlanes(v,m,f,o[4]),tG.intersectionPointThreePlanes(y,m,p,o[3]),tG.intersectionPointThreePlanes(y,g,p,o[2]),tG.intersectionPointThreePlanes(y,g,f,o[1]),tG.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,A=0;A<6;A++){var b=void 0;switch(A){case tI.Near:b=v;break;case tI.Far:b=y;break;default:b=t.getPlane(A)}0>tk.dot(b.normal,i)&&(d[x].copyFrom(b),s[x]=A,x++)}for(var S=x,T=0;T<x;T++)for(var C=s[T],R=l[C],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[C][M],D=o[F[0]],B=o[F[1]];tk.add(D,i,u),tH.fromPoints(D,B,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(tk.dot(u,t)*p)*m,v=Math.ceil(tk.dot(u,n)*p)*m,y=tk.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;tk.scale(r,d+a,A),tk.subtract(u,A,A),tY.lookAt(A,u,t,b),tY.ortho(-_,_,-_,_,0,2*d+a,S);var T=x.viewProjectionMatrix;tY.multiply(S,b,T),nX._floatMatrixMultiply(e._shadowMapCoordMatrix,T.elements,0,l,16*i)},e.getMaxTileResolutionInAtlas=function(e,t,n){for(var r=Math.min(e,t),i=Math.floor(e/r)*Math.floor(t/r);i<n;)i=Math.floor(e/(r=Math.floor(r>>1)))*Math.floor(t/r);return r},e.getShadowBias=function(e,t,n,r){var i=2/t.elements[0]/n,a=-e.shadowBias*i,o=-e.shadowNormalBias*i;e.shadowType==i6.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}();i7._tempMatrix0=new tY,i7._shadowMapCoordMatrix=new tY(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),i7._frustumCorners=[new tk,new tk,new tk,new tk,new tk,new tk,new tk,new tk],i7._adjustNearPlane=new tH(new tk),i7._adjustFarPlane=new tH(new tk),i7._backPlaneFaces=[,,,,,],i7._edgePlanePoint2=new tk,i7._frustumPlaneNeighbors=[[tI.Left,tI.Right,tI.Top,tI.Bottom],[tI.Left,tI.Right,tI.Top,tI.Bottom],[tI.Near,tI.Far,tI.Top,tI.Bottom],[tI.Near,tI.Far,tI.Top,tI.Bottom],[tI.Near,tI.Far,tI.Left,tI.Right],[tI.Near,tI.Far,tI.Left,tI.Right]],i7._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]]],i7.atlasBorderSize=4;var ae=((em={})[em.NoCascades=1]="NoCascades",em[em.TwoCascades=2]="TwoCascades",em[em.FourCascades=4]="FourCascades",em),at=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n.engine)||this)._shadowMapSize=new tq,r._shadowBias=new tQ,r._shadowSliceData=new i5,r._lightUp=new tk,r._lightSide=new tk,r._splitBoundSpheres=new Float32Array(4*t._maxCascades),r._shadowMatrices=new Float32Array((t._maxCascades+1)*16),r._shadowInfos=new tq,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}t8(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,T=l.virtualCamera.forward,C=this._shadowMapSize,R=C.z,E=C.w,M=this._shadowMapFormat;i=this._supportDepthTexture?(r=r6.recreateRenderTargetIfNeeded(a,this._renderTarget,R,E,null,M,!0,!1,!1,1,nf.Clamp,nd.Bilinear)).depthTexture:(r=r6.recreateRenderTargetIfNeeded(a,this._renderTarget,R,E,M,null,!1,!1,!1,1,nf.Clamp,nd.Bilinear)).getColorTexture(0),a._hardwareRenderer._isWebGL2&&(i.depthCompareFunction=nu.Less),this._renderTarget=r,this._depthTexture=i,e.setRenderTarget(r,t._viewport,0),this._supportDepthTexture?m.clearRenderTarget(a,rX.Depth,null):m.clearRenderTarget(a,rX.All,t._clearColor),tY.rotationQuaternion(n.entity.transform.worldRotationQuaternion,x),S.set(A[0],A[1],A[2]),b.set(A[4],A[5],A[6]),T.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++){i7.getBoundSphereByFrustum(v[F],v[F+1],o,P,l),i7.getDirectionLightShadowCullPlanes(o._frustum,v[F],o.nearClipPlane,T,l),i7.getDirectionalLightMatrices(b,S,T,F,n.shadowNearPlaneOffset,w,l,u),g>1&&i7.applySliceTransform(w,R,E,F,this._viewportOffsets[F],u),this._updateSingleShadowCasterShaderData(n,l,e);var D=y.center,B=y.radius,L=4*F;c[L]=D.x,c[L+1]=D.y,c[L+2]=D.z,c[L+3]=B*B,h.clear(),_.clear();for(var I=p._renderers,N=I._elements,O=I.length-1;O>=0;--O)i7.shadowCullFrustum(e,n,N[O],l);if(h.elements.length||_.elements.length){a._renderCount++;var V=a._batcherManager;h.sortBatch(i4.compareForOpaque,V),_.sortBatch(i4.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,rd.ShadowCaster),_.render(e,rd.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(i7.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*tV.degreeToRadian(u)),_=1+h*h*(c*c+1);switch(o){case ae.NoCascades:n[1]=this._getFarWithRadius(e,_);break;case ae.TwoCascades:n[1]=this._getFarWithRadius(l+d*i,_),n[2]=this._getFarWithRadius(e,_);break;case ae.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=i7.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=i7.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==ae.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var o=i7.getMaxTileResolutionInAtlas(r,r,i);this._shadowTileResolution=o;var s=2*o,l=i==ae.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 ae.NoCascades:c[0].set(0,0);break;case ae.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case ae.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;i7.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|=rw.viewProjectionMatrix,l.rendererUpdateFlag|=rw.viewProjectionMatrix,r.applyVirtualCamera(i,!0)},t}(ie);at._lightShadowBiasProperty=nG.getByName("scene_ShadowBias"),at._lightDirectionProperty=nG.getByName("scene_LightDirection"),at._shadowMatricesProperty=nG.getByName("scene_ShadowMatrices"),at._shadowMapSize=nG.getByName("scene_ShadowMapSize"),at._shadowInfosProperty=nG.getByName("scene_ShadowInfo"),at._shadowMapsProperty=nG.getByName("scene_ShadowMap"),at._shadowSplitSpheresProperty=nG.getByName("scene_ShadowSplitSpheres"),at._maxCascades=4,at._cascadesSplitDistance=Array(at._maxCascades+1),at._viewport=new tq(0,0,1,1),at._clearColor=new tZ(1,1,1,1),at._tempVector=new tk,at._tempMatrix0=new tY;var an=/*#__PURE__*/function(){function e(){this.opaqueQueue=new i4(rn.Opaque),this.transparentQueue=new i4(rn.Transparent),this.alphaTestQueue=new i4(rn.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(i4.compareForOpaque,e),this.alphaTestQueue.sortBatch(i4.compareForOpaque,e),this.transparentQueue.sortBatch(i4.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}(),ar=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).supportDepthTexture=t._hardwareRenderer.canIUse(nT.depthTexture),n}t8(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=r6.recreateRenderTargetIfNeeded(t,this.renderTarget,r,i,null,t._hardwareRenderer.isWebGL2?nh.Depth24:nh.Depth24Stencil8,!0,!1,!1,1,nf.Clamp,nd.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,r6.defaultViewport,0),a.clearRenderTarget(n,rX.Depth,null),n._renderCount++,t.opaqueQueue.render(e,rd.DepthOnly),t.alphaTestQueue.render(e,rd.DepthOnly),i.shaderData.setTexture(rJ._cameraDepthTextureProperty,this.renderTarget.depthTexture)},n.release=function(){var e=this.renderTarget;e&&(this.engine._renderTargetPool.freeRenderTarget(e),this.renderTarget=null)},t}(ie),ai=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}t8(t,e);var n=t.prototype;return n.onConfig=function(e,t){this._cameraColorTexture=t;var n=e.opaqueTextureDownsampling,r=n===rK.None,i=e.pixelViewport,a=r?1:n===rK.TwoX?.5:.25,o=r6.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,i.width*a,i.height*a,e._getInternalColorTextureFormat(),null,!1,!1,!e.enableHDR,1,nf.Clamp,r?nd.Point:nd.Bilinear);this._renderTarget=o},n.onRender=function(e){r7.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),e.camera.shaderData.setTexture(rJ._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},t}(ie),aa=/*#__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 an,this._cascadedShadowCasterPass=new at(e),this._depthOnlyPass=new ar(t),this._saoPass=new ii(t),this._opaqueTexturePass=new ai(t),this._finalPass=new i2(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(rw.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===rY.PrePass||_)&&f,m=i.clearFlags&~(null!=r?r:rX.None),g=s?s.antiAliasing:i.msaaSamples;this._canUseBlitFrameBuffer=c.isWebGL2&&1===g;var v=!s||s.getColorTexture(0).isSRGBColorSpace;this._shouldCopyBackgroundColor=l&&!(m&rX.Color)&&(!this._canUseBlitFrameBuffer||v),a.castShadows&&d&&d.shadowType!==i6.None&&this._cascadedShadowCasterPass.onRender(e);var y=o._batcherManager;if(u.reset(),this._cullingResults.setRenderUpdateFlagTrue(rw.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(rJ._cameraDepthTextureProperty,o._basicResources.whiteTexture2D)),l){b=i.renderTarget?i.renderTarget._depthFormat:c._options.depth&&c._options.stencil?nh.Depth24Stencil8:c._options.depth?nh.Depth24:c._options.stencil?nh.Stencil:null;var x=i.pixelViewport,A=r6.recreateRenderTargetIfNeeded(o,this._internalColorTarget,x.width,x.height,i._getInternalColorTextureFormat(),b,!1,!1,!i.enableHDR,g,nf.Clamp,nd.Bilinear);if(this._shouldCopyBackgroundColor){var b,S,T,C,R=null==(S=i.renderTarget)?void 0:S.getColorTexture(0),E=r6.recreateTextureIfNeeded(o,this._copyBackgroundTexture,x.width,x.height,null!=(T=null==R?void 0:R.format)?T:nh.R8G8B8A8,!1,null!=(C=null==R?void 0:R.isSRGBColorSpace)&&C,nf.Clamp,nd.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?r6.defaultViewport:t.viewport,g=!!f||t.renderTarget&&void 0==r;if(e.flipProjection!==g&&(a.setRenderUpdateFlagTrue(rw.ProjectionMatrix),e.applyVirtualCamera(t._virtualCamera,g)),e.setRenderTarget(p,m,i,r),n!==rX.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&rX.DepthStencil;if(A&&_.clearRenderTarget(c,A),~n&rX.Color){if(this._shouldCopyBackgroundColor)_.copyRenderTargetToSubTexture(t.renderTarget,this._copyBackgroundTexture,t.viewport),r7.blitTexture(c,this._copyBackgroundTexture,f,0,void 0,t.renderTarget?void 0:c._basicResources.blitScreenMaterial);else{var b=rX.DepthStencil;_.blitInternalRTByBlitFrameBuffer(t.renderTarget,f,b,t.viewport)}}e.setRenderTarget(p,m,i,r)}var S=u._maskManager;if(n&rX.Stencil&&(S.hasStencilWritten=!1),o.render(e,rd.Forward),s.render(e,rd.Forward),n&rX.Color&&(h.mode===n8.Sky?h.sky._render(e):h.mode===n8.Texture&&h.texture&&this._drawBackgroundTexture(t,h)),t.opaqueTextureEnabled){p._blitRenderTarget();var T=this._opaqueTexturePass;T.onConfig(t,p.getColorTexture(0)),T.onRender(e),e.setRenderTarget(p,m,i,r)}else t.shaderData.setTexture(rJ._cameraOpaqueTextureProperty,null);l.render(e,rd.Forward),S.clearMask(e,rd.Forward);var C=null,R=t._needFinalPass(),E=u.postProcessManager;t.enablePostProcess&&E._isValid()?(C=R?E._getOutputRenderTarget(t):t.renderTarget,E._render(t,f,C)):(C=p,f&&f._blitRenderTarget(),E._releaseSwapRenderTarget(),E._releaseOutputRenderTarget());var M=this._finalPass;R?(M.onConfig(t,C),M.onRender(e),C=d):M.release(),C!==d&&r7.blitTexture(c,C.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!==rq.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 rn.Opaque:i.opaqueQueue.pushRenderElement(e);break;case rn.AlphaTest:i.alphaTestQueue.pushRenderElement(e);break;case rn.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!==n5.Fill&&(this._lastCanvasSize.set(i.width,i.height),t._resizeBackgroundTexture());var s=a.shader.subShaders[0].passes[0],l=rE._compileMacros;rc.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}(),ao=((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),as=/*#__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}(),al=/*#__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}(),ac=((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),au=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new rc,r._maskInteraction=n$.None,r._batchedTransformShaderData=!1,r._maskLayer=ac.Layer0,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new tq,r._bounds=new tz,r._shaderData=new rM(ri.Renderer),r._mvMatrix=new tY,r._mvpMatrix=new tY,r._mvInvMatrix=new tY,r._normalMatrix=new tY,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}t8(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?(tk.subtract(i,r,i),this._distanceForSort=tk.dot(i,n.forward)):this._distanceForSort=tk.distanceSquared(i,r),this._render(e),rc.unionCollection(e.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},n._cloneTo=function(e,t,n){for(var r=this._materials,i=0,a=r.length;i<a;i++)e._setMaterial(i,r[i])},n._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=tY._identity;tY.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;tY.multiply(e.viewMatrix,n,s),tY.invert(s,a),tY.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;tY.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},t3(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}(rL);au._tempVector0=new tk,au._receiveShadowMacro=rl.getByName("RENDERER_IS_RECEIVE_SHADOWS"),au._localMatrixProperty=nG.getByName("renderer_LocalMat"),au._worldMatrixProperty=nG.getByName("renderer_ModelMat"),au._mvMatrixProperty=nG.getByName("renderer_MVMat"),au._mvpMatrixProperty=nG.getByName("renderer_MVPMat"),au._mvInvMatrixProperty=nG.getByName("renderer_MVInvMat"),au._normalMatrixProperty=nG.getByName("renderer_NormalMat"),au._rendererLayerProperty=nG.getByName("renderer_Layer"),t9([ne],au.prototype,"_distanceForSort",void 0),t9([ne],au.prototype,"_onUpdateIndex",void 0),t9([ne],au.prototype,"_rendererIndex",void 0),t9([ne],au.prototype,"_globalShaderMacro",void 0),t9([ne],au.prototype,"_renderFrameCount",void 0),t9([nt],au.prototype,"_maskInteraction",void 0),t9([ne],au.prototype,"_batchedTransformShaderData",void 0),t9([nt],au.prototype,"_maskLayer",void 0),t9([ne],au.prototype,"_overrideUpdate",void 0),t9([ne],au.prototype,"_materials",void 0),t9([ne],au.prototype,"_dirtyUpdateFlag",void 0),t9([ne],au.prototype,"_rendererLayer",void 0),t9([ne],au.prototype,"_bounds",void 0),t9([ne],au.prototype,"_transformEntity",void 0),t9([nr],au.prototype,"_shaderData",void 0),t9([ne],au.prototype,"_mvMatrix",void 0),t9([ne],au.prototype,"_mvpMatrix",void 0),t9([ne],au.prototype,"_mvInvMatrix",void 0),t9([ne],au.prototype,"_normalMatrix",void 0),t9([ne],au.prototype,"_materialsInstanced",void 0),t9([nt],au.prototype,"_priority",void 0),t9([nt],au.prototype,"_receiveShadows",void 0),t9([ne],au.prototype,"_onTransformChanged",null),au=t9([rN(rU,rO.CheckOnly)],au);var ad=((ey={})[ey.WorldVolume=1]="WorldVolume",ey),ah=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).influenceLayers=ac.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,nk.resetData(r),r.setMaterial(r._engine._basicResources.spriteMaskDefaultMaterial),r.shaderData.setFloat(t._alphaCutoffProperty,r._alphaCutoff),r._renderElement=new as,r._renderElement.addSubRenderElement(new al),r._onSpriteChange=r._onSpriteChange.bind(r),r}t8(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.sprite=this._sprite},n._canBatch=function(e,t){return i8.canBatchSpriteMask(e,t)},n._batch=function(e,t){i8.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)nk.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&ad.WorldVolume&&(nk.updatePositions(this,this._transformEntity.transform.worldMatrix,this.width,this.height,t.pivot,this._flipX,this._flipY),this._dirtyUpdateFlag&=~ad.WorldVolume),2&this._dirtyUpdateFlag&&(nk.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=ao.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 n0.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case n0.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=ad.WorldVolume);break;case n0.region:case n0.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case n0.atlasRegion:this._dirtyUpdateFlag|=2;break;case n0.pivot:this._dirtyUpdateFlag|=ad.WorldVolume;break;case n0.destroy:this.sprite=null}},t3(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|=ad.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|=ad.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=ad.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=ad.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}(au);ah._textureProperty=nG.getByName("renderer_MaskTexture"),ah._alphaCutoffProperty=nG.getByName("renderer_MaskAlphaCutoff"),t9([nt],ah.prototype,"influenceLayers",void 0),t9([ne],ah.prototype,"_renderElement",void 0),t9([ne],ah.prototype,"_subChunk",void 0),t9([ne],ah.prototype,"_maskIndex",void 0),t9([ne],ah.prototype,"_sprite",void 0),t9([ne],ah.prototype,"_automaticWidth",void 0),t9([ne],ah.prototype,"_automaticHeight",void 0),t9([nt],ah.prototype,"_customWidth",void 0),t9([nt],ah.prototype,"_customHeight",void 0),t9([nt],ah.prototype,"_flipX",void 0),t9([nt],ah.prototype,"_flipY",void 0),t9([nt],ah.prototype,"_alphaCutoff",void 0),t9([ne],ah.prototype,"_onSpriteChange",null);var a_=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._tileMode=nQ.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new tZ(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=nJ.Simple,n._dirtyUpdateFlag|=4,n.setMaterial(n._engine._basicResources.spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(n),n._color._onValueChanged=n._onColorChanged.bind(n),n}t8(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.sprite=this._sprite,t.drawMode=this._drawMode},n._canBatch=function(e,t){return i8.canBatchSprite(e,t)},n._batch=function(e,t){i8.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&ad.WorldVolume&&(this._assembler.updatePositions(this,this._transformEntity.transform.worldMatrix,this.width,this.height,t.pivot,this._flipX,this._flipY),this._dirtyUpdateFlag&=~ad.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 n0.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case n0.size:switch(this._dirtyUpdateFlag|=8,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=ad.WorldVolume),this._drawMode){case nJ.Simple:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=ad.WorldVolume);break;case nJ.Sliced:this._dirtyUpdateFlag|=ad.WorldVolume;break;case nJ.Tiled:this._dirtyUpdateFlag|=7}break;case n0.border:switch(this._drawMode){case nJ.Sliced:this._dirtyUpdateFlag|=3;break;case nJ.Tiled:this._dirtyUpdateFlag|=7}break;case n0.region:case n0.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case n0.atlasRegion:this._dirtyUpdateFlag|=2;break;case n0.pivot:this._dirtyUpdateFlag|=ad.WorldVolume;break;case n0.destroy:this.sprite=null}},n._onColorChanged=function(){this._dirtyUpdateFlag|=4},t3(t,[{key:"drawMode",get:function(){return this._drawMode},set:function(e){if(this._drawMode!==e){switch(this._drawMode=e,e){case nJ.Simple:this._assembler=nk;break;case nJ.Sliced:this._assembler=nU;break;case nJ.Tiled:this._assembler=nq}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===nJ.Tiled&&(this._dirtyUpdateFlag|=7))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(e){e!==this._tiledAdaptiveThreshold&&(e=tV.clamp(e,0,1),this._tiledAdaptiveThreshold=e,this.drawMode===nJ.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===nJ.Tiled?7:ad.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===nJ.Tiled?7:ad.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=ad.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=ad.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}(au);a_._textureProperty=nG.getByName("renderer_SpriteTexture"),t9([ne],a_.prototype,"_subChunk",void 0),t9([ne],a_.prototype,"_drawMode",void 0),t9([ne],a_.prototype,"_assembler",void 0),t9([nt],a_.prototype,"_tileMode",void 0),t9([nt],a_.prototype,"_tiledAdaptiveThreshold",void 0),t9([nr],a_.prototype,"_color",void 0),t9([ne],a_.prototype,"_sprite",void 0),t9([ne],a_.prototype,"_automaticWidth",void 0),t9([ne],a_.prototype,"_automaticHeight",void 0),t9([nt],a_.prototype,"_customWidth",void 0),t9([nt],a_.prototype,"_customHeight",void 0),t9([nt],a_.prototype,"_flipX",void 0),t9([nt],a_.prototype,"_flipY",void 0),t9([ne],a_.prototype,"_onSpriteChange",null),t9([ne],a_.prototype,"_onColorChanged",null);var af=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._textChunks=[],n._subFont=null,n._dirtyFlag=15,n._color=new tZ(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new tz,n._font=null,n._fontSize=24,n._fontStyle=nB.None,n._lineSpacing=0,n._characterSpacing=0,n._horizontalAlignment=n1.Center,n._verticalAlignment=n2.Center,n._enableWrapping=!1,n._overflowMode=nL.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}t8(t,e);var n=t.prototype;return n._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),e.prototype._onDestroy.call(this),this._freeTextChunks(),this._textChunks=null,this._subFont&&(this._subFont=null)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.font=this._font,t._subFont=this._subFont},n._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},n._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},n._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},n._getSubFont=function(){return this._subFont||this._resetSubFont(),this._subFont},n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._canBatch=function(e,t){return i8.canBatchSprite(e,t)},n._batch=function(e,t){i8.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){tz.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 rM(ri.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=nI.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,T=0,C=S.length;T<C;++T){var R=S[T],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),tk.scale(h,E.z-M,p),tk.add(f,p,p),tk.scale(d,E.w-P,m),tk.add(f,m,g),tk.add(p,m,m);for(var w=b.chunk.vertices,F=0,D=b.vertexArea.start+36*R.indexInChunk;F<4;++F,D+=9)_[F].copyToArray(w,D)}},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=oX._pixelsPerUnit,n=this._localBounds,r=n.min,i=n.max,a=t._charRenderInfos,o=this._getSubFont(),s=this._characterSpacing*this._fontSize,l=this.enableWrapping?nI.measureTextWithWrap(this,this.width*e,this.height*e,this._lineSpacing*this._fontSize,s):nI.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,T=.5*h-_[p-1].descent-1;switch(this.verticalAlignment){case n2.Top:b=.5*x-A+S;break;case n2.Center:b=.5*c-A-(T-S)*.5;break;case n2.Bottom:b=c-.5*x-A-T}for(var C=-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 D=u[w],B=0,L=-1;switch(C<0&&(C=w),g){case n1.Left:B=-y;break;case n1.Center:B=-(.5*F);break;case n1.Right:B=y-F}for(var I=0,N=D.length;I<N;++I){var O=D[I],V=o._getCharInfo(O);if(V.h>0){L<0&&(L=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,X=B*v,W=(B+z)*v,j=(b+G)*v,Y=(b-H)*v;U.set(X,j,W,Y),w===C&&(P=Math.max(P,j)),E=Math.min(E,Y),I===L&&(R=Math.min(R,X)),M=Math.max(M,W)}B+=V.xAdvance+s}}b-=h}C<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 ap;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 ap,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._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===nL.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=t5.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)},t3(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}(au);af._textureProperty=nG.getByName("renderElement_TextTexture"),af._tempVec30=new tk,af._tempVec31=new tk,af._worldPositions=[new tk,new tk,new tk,new tk],af._charRenderInfos=[],t9([ne],af.prototype,"_textChunks",void 0),t9([nt],af.prototype,"_subFont",void 0),t9([ne],af.prototype,"_dirtyFlag",void 0),t9([nr],af.prototype,"_color",void 0),t9([nt],af.prototype,"_text",void 0),t9([nt],af.prototype,"_width",void 0),t9([nt],af.prototype,"_height",void 0),t9([ne],af.prototype,"_localBounds",void 0),t9([nt],af.prototype,"_font",void 0),t9([nt],af.prototype,"_fontSize",void 0),t9([nt],af.prototype,"_fontStyle",void 0),t9([nt],af.prototype,"_lineSpacing",void 0),t9([nt],af.prototype,"_characterSpacing",void 0),t9([nt],af.prototype,"_horizontalAlignment",void 0),t9([nt],af.prototype,"_verticalAlignment",void 0),t9([nt],af.prototype,"_enableWrapping",void 0),t9([nt],af.prototype,"_overflowMode",void 0),t9([ne],af.prototype,"_onTransformChanged",null),t9([ne],af.prototype,"_onColorChanged",null);var ap=function(){this.charRenderInfos=[]},am=((ex={})[ex.Static=0]="Static",ex[ex.Dynamic=1]="Dynamic",ex[ex.Stream=2]="Stream",ex),ag=((eA={})[eA.None=0]="None",eA[eA.Discard=1]="Discard",eA),av=/*#__PURE__*/function(e){function t(t,n,r,i,a){if(void 0===i&&(i=am.Static),void 0===a&&(a=!1),(o=e.call(this,t)||this)._dataUpdateManager=new n3,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}t8(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=ag.None),this._platformBuffer.setData(this._byteLength,e,t,n,r,i),this._readable){var a=e.constructor===ArrayBuffer?e:e.buffer;if(this._data.buffer!==a){var o=e.BYTES_PER_ELEMENT||1,s=r?o*r:e.byteLength,l=new Uint8Array(a,void 0!==e.byteOffset?e.byteOffset+n*o:n,s);this._data.set(l,t)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},n.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},n.markAsUnreadable=function(){this._data=null,this._readable=!1},n._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e,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()},t3(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}(np),ay=((eb={})[eb.UInt8=0]="UInt8",eb[eb.UInt16=1]="UInt16",eb[eb.UInt32=2]="UInt32",eb),ax=((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),aA=/*#__PURE__*/function(){function e(){}return e._getGLIndexType=function(e){switch(e){case ay.UInt8:return nS.UNSIGNED_BYTE;case ay.UInt16:return nS.UNSIGNED_SHORT;case ay.UInt32:return nS.UNSIGNED_INT}},e._getGLIndexByteCount=function(e){switch(e){case ay.UInt8:return 1;case ay.UInt16:return 2;case ay.UInt32:return 4}},e._getElementInfo=function(e){var t,n,r,i=!1;switch(e){case ax.Float:t=1,n=nS.FLOAT;break;case ax.Vector2:t=2,n=nS.FLOAT;break;case ax.Vector3:t=3,n=nS.FLOAT;break;case ax.Vector4:t=4,n=nS.FLOAT;break;case ax.Byte4:t=4,n=nS.BYTE;break;case ax.UByte4:t=4,n=nS.UNSIGNED_BYTE;break;case ax.NormalizedByte4:t=4,n=nS.BYTE,i=!0,r=1/127;break;case ax.NormalizedUByte4:t=4,n=nS.UNSIGNED_BYTE,i=!0,r=1/255;break;case ax.Short2:t=2,n=nS.SHORT;break;case ax.UShort2:t=2,n=nS.UNSIGNED_SHORT;break;case ax.NormalizedShort2:t=2,n=nS.SHORT,i=!0,r=1/32767;break;case ax.NormalizedUShort2:t=2,n=nS.UNSIGNED_SHORT,i=!0,r=1/65535;break;case ax.Short4:t=4,n=nS.SHORT;break;case ax.UShort4:t=4,n=nS.UNSIGNED_SHORT;break;case ax.NormalizedShort4:t=4,n=nS.SHORT,i=!0,r=1/32767;break;case ax.NormalizedUShort4:t=4,n=nS.UNSIGNED_SHORT,i=!0,r=1/65535}return{size:t,type:n,normalized:i,normalizedScaleFactor:r}},e}(),ab=/*#__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=aA._getElementInfo(this.format),this._instanceStepRate=Math.floor(i)}return t3(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}(),aS=((eT={})[eT.VertexBuffer=0]="VertexBuffer",eT[eT.IndexBuffer=1]="IndexBuffer",eT),aT=((eC={})[eC.Points=0]="Points",eC[eC.Lines=1]="Lines",eC[eC.LineLoop=2]="LineLoop",eC[eC.LineStrip=3]="LineStrip",eC[eC.Triangles=4]="Triangles",eC[eC.TriangleStrip=5]="TriangleStrip",eC[eC.TriangleFan=6]="TriangleFan",eC),aC=/*#__PURE__*/function(){function e(){}return e.create=function(t){return new Promise(function(n,r){var i=new nw(t,e._size,e._size,nh.R8G8B8,!1,!1);i.wrapModeU=i.wrapModeV=nf.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.";nA.error(e),r(e)},a.src=e._base64,t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,i)||this}return t8(t,e),t.prototype.restoreContent=function(){i.setImageSource(a)},t}(ns))),i})},e}();aC._size=256,aC._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 aR=/*#__PURE__*/function(){function e(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new n3,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},t3(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}(),aE=((eR={})[eR.Position=1]="Position",eR[eR.Normal=2]="Normal",eR[eR.Tangent=4]="Tangent",eR[eR.All=7]="All",eR),aM=/*#__PURE__*/function(){function e(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new n3,this._dataChangeManager=new n3,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 aR(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(aE.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()},t3(e,[{key:"frames",get:function(){return this._frames}}]),e}(),aP=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._format=t}return t3(e,[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),e}(),aw=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=aT.Triangles),this.start=e,this.count=t,this.topology=n},aF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t8(t,e),t.prototype.dispose=function(){},t}(aw),aD=/*#__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}t8(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=aA._getGLIndexType(e.format),this._glIndexByteCount=aA._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},t3(t,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t}(np),aB=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._updateFlagManager=new n3,r._bounds=new tz,r._subMeshes=[],r.name=n,r._primitive=new aD(t),r._onBoundsChanged=r._onBoundsChanged.bind(r);var r,i=r._bounds;return i.min._onValueChanged=r._onBoundsChanged,i.max._onValueChanged=r._onBoundsChanged,r}t8(t,e);var n=t.prototype;return n.addSubMesh=function(e,t,n){return void 0===n&&(n=aT.Triangles),"number"==typeof e&&(e=new aF(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)},t3(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}(no),aL=((eE={})[eE.Bounds=1]="Bounds",eE[eE.VertexElements=2]="VertexElements",eE),aI=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._stride=t}return t3(e,[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),e}(),aN=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}t8(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 aI(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 aP(e,t))),this._setIndexBufferBinding(n)},t3(t,[{key:"instanceCount",get:function(){return this._primitive.instanceCount},set:function(e){this._primitive.instanceCount=e}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"indexBufferBinding",get:function(){return this._primitive.indexBufferBinding}},{key:"vertexElements",get:function(){return this._primitive.vertexElements}}]),t}(aB),aO=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._enableVertexColor=!1,n._onMeshChanged=n._onMeshChanged.bind(n),n}t8(t,e);var n=t.prototype;return n._onDestroy=function(){var t=this._mesh;t&&(t.destroyed||this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),e.prototype._onDestroy.call(this)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.mesh=this._mesh},n._prepareRender=function(t){if(!this._mesh){nA.error("mesh is null.");return}if(this._mesh.destroyed){nA.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;tz.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&aL.Bounds&&(this._dirtyUpdateFlag|=ad.WorldVolume),e&aL.VertexElements&&(this._dirtyUpdateFlag|=2)},t3(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}(au);aO._enableVertexColorMacro=rl.getByName("RENDERER_ENABLE_VERTEXCOLOR"),aO._uvMacro=rl.getByName("RENDERER_HAS_UV"),aO._uv1Macro=rl.getByName("RENDERER_HAS_UV1"),aO._normalMacro=rl.getByName("RENDERER_HAS_NORMAL"),aO._tangentMacro=rl.getByName("RENDERER_HAS_TANGENT"),t9([ne],aO.prototype,"_mesh",void 0),t9([ne],aO.prototype,"_onMeshChanged",null);var aV=/*#__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 tq,this._canUseTextureStoreData=!0,this._dataTextureInfo=new tk,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(rk))},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 ab("POSITION_BS"+i,r,ax.Vector3,n)),r+=12,this._useBlendNormal&&(e._setVertexElement(t++,new ab("NORMAL_BS"+i,r,ax.Vector3,n)),r+=12),this._useBlendTangent&&(e._setVertexElement(t++,new ab("TANGENT_BS"+i,r,ax.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?am.Static:am.Dynamic,g=new av(n,aS.VertexBuffer,p,m);r._setVertexBufferBinding(d+h,new aI(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 nF(this._engine,r,i,o,nh.R32G32B32A32,!1,!1)).filterMode=nd.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,T=0;T<e;T++){var C=A+x*T,R=S[T];R&&(i[C]=R.x,i[C+1]=R.y,i[C+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 D=0;D<e;D++){var B=A+x*D,L=F[D];L&&(i[B]=L.x,i[B+1]=L.y,i[B+2]=L.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}();aV._blendShapeMacro=rl.getByName("RENDERER_HAS_BLENDSHAPE"),aV._blendShapeTextureMacro=rl.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),aV._blendShapeNormalMacro=rl.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),aV._blendShapeTangentMacro=rl.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),aV._blendShapeWeightsProperty=nG.getByName("renderer_BlendShapeWeights"),aV._blendShapeTextureProperty=nG.getByName("renderer_BlendShapeTexture"),aV._blendShapeTextureInfoProperty=nG.getByName("renderer_BlendShapeTextureInfo");var ak=((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),aU=/*#__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 tk(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 aV(t,r),r}t8(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,ak.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,ak.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,ak.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,ak.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,ak.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,ak.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,ak.UV,6,this._readVector2VertexData);return this._uv=t,t;case 1:var n=this._getVertexElementData(this._uv1,ak.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var r=this._getVertexElementData(this._uv2,ak.UV2,8,this._readVector2VertexData);return this._uv2=r,r;case 3:var i=this._getVertexElementData(this._uv3,ak.UV3,9,this._readVector2VertexData);return this._uv3=i,i;case 4:var a=this._getVertexElementData(this._uv4,ak.UV4,10,this._readVector2VertexData);return this._uv4=a,a;case 5:var o=this._getVertexElementData(this._uv5,ak.UV5,11,this._readVector2VertexData);return this._uv5=o,o;case 6:var s=this._getVertexElementData(this._uv6,ak.UV6,12,this._readVector2VertexData);return this._uv6=s,s;case 7:var l=this._getVertexElementData(this._uv7,ak.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,t6(e,Uint8Array)?this._indicesFormat=ay.UInt8:t6(e,Uint16Array)?this._indicesFormat=ay.UInt16:t6(e,Uint32Array)&&(this._indicesFormat=ay.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[ak.Position]||this.setPositions(null),i[ak.Normal]||this.setNormals(null),i[ak.Color]||this.setColors(null),i[ak.BoneWeight]||this.setBoneWeights(null),i[ak.BoneIndex]||this.setBoneIndices(null),i[ak.Tangent]||this.setTangents(null),i[ak.UV]||this.setUVs(null,0),i[ak.UV1]||this.setUVs(null,1),i[ak.UV2]||this.setUVs(null,2),i[ak.UV3]||this.setUVs(null,3),i[ak.UV4]||this.setUVs(null,4),i[ak.UV5]||this.setUVs(null,5),i[ak.UV6]||this.setUVs(null,6),i[ak.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 aI(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 aP(u,this._indicesFormat));else{null==u||u.destroy();var d=new av(this._engine,aS.IndexBuffer,c);this._setIndexBufferBinding(new aP(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 tq,_[f]=new tk;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],T=r[v];tk.subtract(x,y,o),tk.subtract(A,y,s);var C=S.x-b.x,R=T.x-b.x,E=S.y-b.y,M=T.y-b.y,P=1/(C*M-R*E);tk.scale(o,M*P,l),tk.scale(s,E*P,u),tk.subtract(l,u,l),tk.scale(s,C*P,c),tk.scale(o,R*P,u),tk.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 D=n[F],B=_[F],L=h[F];l.set(L.x,L.y,L.z),tk.cross(l,B,u);var I=tk.dot(u,D)>0?1:-1;tk.scale(D,tk.dot(l,D),u),tk.subtract(l,u,l),l.normalize(),L.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 az)).reset(),o()):t+1==i.length&&i.length--},n._getVertexTypedArray=function(e,t){switch(t){case nS.BYTE:return new Int8Array(e);case nS.UNSIGNED_BYTE:return new Uint8Array(e);case nS.SHORT:return new Int16Array(e);case nS.UNSIGNED_SHORT:return new Uint16Array(e);case nS.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?am.Static:am.Dynamic,u=new av(this._engine,aS.VertexBuffer,i,c,!0);this._setVertexBufferBinding(s,new aI(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 tk(e[t],e[t+1],e[t+2])})},n._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new tq(e[t],e[t+1],e[t+2],e[t+3])})},n._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new tZ(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 ab(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,ak.Position,1),2&e&&this._updateAdvancedVertexElement(this._normals,ak.Normal,2),4&e&&this._updateAdvancedVertexElement(this._colors,ak.Color,4),16&e&&this._updateAdvancedVertexElement(this._boneWeights,ak.BoneWeight,16),32&e&&this._updateAdvancedVertexElement(this._boneIndices,ak.BoneIndex,32),8&e&&this._updateAdvancedVertexElement(this._tangents,ak.Tangent,8),64&e&&this._updateAdvancedVertexElement(this._uv,ak.UV,64),128&e&&this._updateAdvancedVertexElement(this._uv1,ak.UV1,128),256&e&&this._updateAdvancedVertexElement(this._uv2,ak.UV2,256),512&e&&this._updateAdvancedVertexElement(this._uv3,ak.UV3,512),1024&e&&this._updateAdvancedVertexElement(this._uv4,ak.UV4,1024),2048&e&&this._updateAdvancedVertexElement(this._uv5,ak.UV5,2048),4096&e&&this._updateAdvancedVertexElement(this._uv6,ak.UV6,4096),8192&e&&this._updateAdvancedVertexElement(this._uv7,ak.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(ak.Position,0,e),t&&2&r&&this._writeVector3AdvancedVertexData(ak.Normal,1,t),n&&4&r&&this._writeColorAdvancedVertexData(ak.Color,2,n),i&&16&r&&this._writeVector4AdvancedVertexData(ak.BoneWeight,4,i),a&&32&r&&this._writeVector4AdvancedVertexData(ak.BoneIndex,5,a),o&&8&r&&this._writeVector4AdvancedVertexData(ak.Tangent,3,o),s&&64&r&&this._writeVector2AdvancedVertexData(ak.UV,6,s),l&&128&r&&this._writeVector2AdvancedVertexData(ak.UV1,7,l),c&&256&r&&this._writeVector2AdvancedVertexData(ak.UV2,8,c),u&&512&r&&this._writeVector2AdvancedVertexData(ak.UV3,9,u),d&&1024&r&&this._writeVector2AdvancedVertexData(ak.UV4,10,d),h&&2048&r&&this._writeVector2AdvancedVertexData(ak.UV5,11,h),_&&4096&r&&this._writeVector2AdvancedVertexData(ak.UV6,12,_),f&&8192&r&&this._writeVector2AdvancedVertexData(ak.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 ak.Position:case ak.Normal:return ax.Vector3;case ak.Color:case ak.BoneWeight:case ak.Tangent:return ax.Vector4;case ak.BoneIndex:return ax.UByte4;case ak.UV:case ak.UV1:case ak.UV2:case ak.UV3:case ak.UV4:case ak.UV5:case ak.UV6:case ak.UV7:return ax.Vector2}},n._getAttributeByteLength=function(e){switch(e){case ak.Position:case ak.Normal:return 12;case ak.Color:case ak.BoneWeight:case ak.Tangent:return 16;case ak.BoneIndex:return 4;case ak.UV:case ak.UV1:case ak.UV2:case ak.UV3:case ak.UV4:case ak.UV5:case ak.UV6:case ak.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)}}},t3(t,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var e=0,t=this._primitive._vertexElementMap[ak.Position];if(t){var n=this._primitive.vertexBufferBindings[t.bindingIndex];n&&(e=n.buffer.byteLength/n.stride)}this._vertexCount=e,this._vertexCountDirty=!1}return this._vertexCount}},{key:"vertexElements",get:function(){return this._updateVertexElements(),this._primitive.vertexElements}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"blendShapes",get:function(){return this._blendShapeManager._blendShapes}},{key:"blendShapeCount",get:function(){return this._blendShapeManager._blendShapeCount}},{key:"accessible",get:function(){return this._accessible}}]),t}(aB);aU._tempVec0=new tk,aU._tempVec1=new tk,aU._tempVec2=new tk,aU._tempVec3=new tk,aU._tempVec4=new tk;var az=/*#__PURE__*/function(){function e(){this.dataVersion=-1,this.uploadAdvancedData=!1}return e.prototype.reset=function(){this.uploadAdvancedData=!1},e}(),aG=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).primitiveInfo=n,r}return t8(t,e),t.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:aJ._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:aJ._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:aJ._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:aJ._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:aJ._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:aJ._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:aJ._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:aJ._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t}(ns),aH=function(e,t,n){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=n},aX=/*#__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 t8(t,e),t}(aH),aW=/*#__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 t8(t,e),t}(aH),aj=/*#__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 t8(t,e),t}(aH),aY=/*#__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 t8(t,e),t}(aH),aK=/*#__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 t8(t,e),t}(aH),aQ=/*#__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 t8(t,e),t}(aH),aq=/*#__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 t8(t,e),t}(aH),aZ=/*#__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 t8(t,e),t}(aH),aJ=/*#__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 aU(t);e._setSphereData(a,n,r,i,!1);var o=a.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(a,new aX(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 aU(t);e._setSubdivisionSurfaceSphereData(a,n,r,i,!1);var o=a.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(a,new aW(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 aU(t);e._setCuboidData(o,n,r,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(o,new aj(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 aU(t);e._setPlaneData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(s,new aY(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 aU(t);e._setCylinderData(l,n,r,i,a,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(l,new aK(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 aU(t);e._setTorusData(l,n,r,i,a,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(l,new aQ(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 aU(t);e._setConeData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(s,new aq(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 aU(t);e._setCapsuleData(s,n,r,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aG(s,new aZ(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=tV.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 T=0;T<u;T++){var C=4*T,R=l[C],E=l[C+1],M=l[C+2],P=l[C+3],w=8*R,F=8*E,D=8*M,B=8*P;h[w+2]+h[F+2]+h[D+2]<0&&(0===h[w+6]&&(R=p[R]),0===h[F+6]&&(E=p[E]),0===h[D+6]&&(M=p[M]),0===h[B+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 L=t.bounds;L.min.set(-n,-n,-n),L.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),T=n*Math.sin(y)*A,C=8*m;p[C++]=b,p[C++]=S,p[C++]=T,p[C++]=b,p[C++]=S,p[C++]=T,p[C++]=g,p[C++]=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,D=F+1;u[R++]=w,u[R++]=P,u[R++]=D,u[R++]=P,u[R++]=F,u[R++]=D}if(!a){var B=t.bounds;B.min.set(-n,-n,-n),B.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 tk,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 tk,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,T=S+s,C=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,D=void 0,B=0;B<4;B++){var L=R[C++];switch(B){case 0:var I=M.adjacentEdges[B%4],N=M.adjacentEdges[(B+3)%4];F=this._calculateEdgeIndex(n,I,T),D=w=this._calculateEdgeIndex(n,N,T);break;case 1:case 2:var O=M.adjacentEdges[B%4];w=F,F=this._calculateEdgeIndex(n,O,T);break;case 3:w=F,F=D}var V=4*(4*E+B);r[V]=L,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 T=new Uint16Array(36);if(T[0]=0,T[1]=2,T[2]=1,T[3]=2,T[4]=0,T[5]=3,T[6]=4,T[7]=6,T[8]=7,T[9]=6,T[10]=4,T[11]=5,T[12]=8,T[13]=10,T[14]=9,T[15]=10,T[16]=8,T[17]=11,T[18]=12,T[19]=14,T[20]=15,T[21]=14,T[22]=12,T[23]=13,T[24]=16,T[25]=18,T[26]=17,T[27]=18,T[28]=16,T[29]=19,T[30]=20,T[31]=22,T[32]=23,T[33]=22,T[34]=20,T[35]=21,!o){var C=t.bounds;C.min.set(-l,-c,-u),C.max.set(l,c,u)}e._initialize(t,d,T,a,o,s)},e._setPlaneData=function(t,n,r,i,a,o,s,l){for(var c=(i=Math.max(1,Math.floor(i)))+1,u=(a=Math.max(1,Math.floor(a)))+1,d=n/2,h=r/2,_=n/i,f=r/a,p=c*u,m=a*i,g=e._generateIndices(t.engine,p,6*m),v=1/c,y=1/i,x=1/a,A=new Float32Array(8*p),b=0;b<p;++b){var S=b%c,T=b*v|0,C=8*b;A[C++]=S*_-d,A[C++]=0,A[C++]=T*f-h,A[C++]=0,A[C++]=1,A[C++]=0,A[C++]=S*y,A[C++]=T*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,D=F+1;g[R++]=P,g[R++]=F,g[R++]=w,g[R++]=F,g[R++]=D,g[R++]=w}if(!s){var B=t.bounds;B.min.set(-d,0,-h),B.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,T=Math.PI,C=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,D=w*x,B=F*A,L=T+D*C,I=Math.sin(L),N=Math.cos(L),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++]=D,b[z++]=1-B}for(var G=0;G<p;++G){var H=G%a,X=(G*x|0)*u+H,W=X+1,j=X+u,Y=j+1;v[S++]=W,v[S++]=j,v[S++]=X,v[S++]=W,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,T=(n+r*x)*b,C=r*Math.sin(y);_[f++]=S,_[f++]=T,_[f++]=C;var R=n*A,E=n*b;p.set(S-R,T-E,C).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,D=(a+1)*(M-1)+P,B=(a+1)*M+P;h[f++]=w,h[f++]=F,h[f++]=B,h[f++]=F,h[f++]=D,h[f++]=B}if(!l){var L=t.bounds,I=n+r;L.min.set(-I,-I,-r),L.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,T=n/r,C=0;C<_;++C){var R=C%c,E=C*g|0,M=R*v,P=E*y,w=b+M*S,F=Math.sin(w),D=Math.cos(w),B=n-P*n,L=B*F,I=E*h-d,N=B*D,O=8*C;x[O++]=L,x[O++]=I,x[O++]=N,x[O++]=F,x[O++]=T,x[O++]=D,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 X=8*_;x[X++]=0,x[X++]=-d,x[X++]=0,x[X++]=0,x[X++]=-1,x[X++]=0,x[X++]=.5,x[X++]=.5,X=(_+1)*8;for(var W=1/(2*n),j=0;j<i;++j){var Y=x[8*j],K=x[8*j+2];x[X++]=Y,x[X++]=-d,x[X++]=K,x[X++]=0,x[X++]=-1,x[X++]=0,x[X++]=Y*W+.5,x[X++]=.5-K*W}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,T=new Float32Array(8*g),C=0,R=0;R<_;++R){var E=R%c,M=R*y|0,P=E*x,w=M*A,F=b+P*S,D=Math.sin(F),B=Math.cos(F),L=8*R;T[L++]=n*D,T[L++]=M*h-d,T[L++]=n*B,T[L++]=D,T[L++]=0,T[L++]=B,T[L++]=P,T[L++]=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[C++]=V,v[C++]=k,v[C++]=O,v[C++]=V,v[C++]=U,v[C++]=k}if(e._createCapsuleCap(n,r,i,b,S,_,1,T,v,C),e._createCapsuleCap(n,r,i,b,-S,_+p,-1,T,v,C+6*m),!s){var z=t.bounds;z.min.set(-n,-n-d,-n),z.max.set(n,n+d,n)}e._initialize(t,T,v,o,s,l)},e._initialize=function(e,t,n,r,i,a){if(i)a.setData(t),e.setIndices(n),e.uploadData(r);else{var o=[new ab(ak.Position,0,ax.Vector3,0),new ab(ak.Normal,12,ax.Vector3,0),new ab(ak.UV,24,ax.Vector2,0)];e.setVertexElements(o);var s=new av(e.engine,aS.VertexBuffer,t,am.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,T=e*Math.cos(y)*A,C=(m+a)*8;s[C++]=b,s[C++]=S,s[C++]=T,s[C++]=b,s[C++]=S-d,s[C++]=T,s[C++]=g,s[C++]=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}();function a$(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a$=function(){return!!e})()}function a0(e,t,n){return(a0=a$()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&t4(i,n.prototype),i}).apply(null,arguments)}aJ._tempVec30=new tk,aJ._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]),aJ._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]),aJ._sphereEdgeIdx=0,aJ._spherePoleIdx=0;var a1=/*#__PURE__*/function(){function e(){}return e.cloneComponent=function(e,t,n,r,i){var a=ni.getCloneMode(e.constructor);for(var o in e)ni.cloneProperty(e,t,o,a[o],n,r,i);e._cloneTo&&e._cloneTo(t,n,r)},e}(),a2=((eP={})[eP.Parent=1]="Parent",eP[eP.Child=2]="Child",eP),a3=/*#__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=rV.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new nK,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._isTemplate=!1,r._updateFlagManager=new n3,r._parent=null,r._invModelMatrix=new tY,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(rU),r._inverseWorldMatFlag=r.registerWorldChangeFlag(),r}t8(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];rI._addCheck(this,e);var i=a0(e,[].concat([this],n));return this._components.push(i),t6(i,rU)&&this._setTransform(i),i._setActive(!0,rB.All),i},n.getComponent=function(e){for(var t=this._components,n=0,r=t.length;n<r;n++){var i=t[n];if(t6(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];t6(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=rB.None;r._isActiveInHierarchy&&(i|=rB.Hierarchy),r._isActiveInScene&&(i|=rB.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(rk)},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=a0(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++)a1.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){rI._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(a2.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(a2.Parent,this)},n._registerModifyListener=function(e){(this._modifyFlagManager||(this._modifyFlagManager=new n3)).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(a2.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=rB.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(o|=rB.Hierarchy),e._isActiveInScene?this._isActiveInScene&&i!==a&&(o|=rB.Scene):this._isActiveInScene&&(o|=rB.Scene),o&&this._processInActive(o),i!==a&&t._traverseSetOwnerScene(this,a);var s=rB.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(s|=rB.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&i===a||(s|=rB.Scene))),s&&this._processActive(s)}else{var l=rB.None;this._isActiveInHierarchy&&(l|=rB.Hierarchy),this._isActiveInScene&&(l|=rB.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];t6(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&rB.Hierarchy&&(this._isActiveInHierarchy=!0),t&rB.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&rB.Hierarchy&&(this._isActiveInHierarchy=!1),t&rB.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&&(tY.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._getEntityHierarchyPath=function(e,t,n){for(n.length=0;t!==e;){var r=t.parent;if(!r)return!1;n.push(t.siblingIndex),t=r}return!0},t._getEntityByHierarchyPath=function(e,t){for(var n=e,r=t.length-1;r>=0;r--)n=n.children[t[r]];return n},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}},t3(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=rB.None;this._isRoot&&this._scene._isActiveInEngine?n|=rB.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=rB.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=rB.Scene)),n&&this._processActive(n)}else{var r=rB.None;this._isActiveInHierarchy&&(r|=rB.Hierarchy),this._isActiveInScene&&(r|=rB.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(a2.Child,t)}}}]),t}(na);a3._tempComponentConstructors=[];var a4=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n.inverseBindMatrices=[],n._updatedManager=new n3,n._bones=[],n._updateMark=-1,n.joints=[],n}t8(t,e);var n=t.prototype;return n._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,n=this.bones,r=this.inverseBindMatrices,i=this._skinMatrices,a=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=n.length-1;o>=0;o--){var s=n[o],l=16*o;s?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}},n._cloneTo=function(e,t,n){var r=[],i=this.rootBone;if(i){var a=a3._getEntityHierarchyPath(t,i,r);e.rootBone=a?a3._getEntityByHierarchyPath(n,r):i}var o=this.bones;if(o.length>0){for(var s=o.length,l=Array(s),c=0;c<s;c++){var u=o[c],d=a3._getEntityHierarchyPath(t,u,r);l[c]=d?a3._getEntityByHierarchyPath(n,r):u}e.bones=l}},t3(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}(na);t9([nr],a4.prototype,"inverseBindMatrices",void 0),t9([ne],a4.prototype,"_skinMatrices",void 0),t9([ne],a4.prototype,"_updatedManager",void 0),t9([ne],a4.prototype,"_rootBone",void 0),t9([ne],a4.prototype,"_bones",void 0),t9([ne],a4.prototype,"_updateMark",void 0);var a8=((ew={})[ew.BoneCountChanged=0]="BoneCountChanged",ew[ew.RootBoneChanged=1]="RootBoneChanged",ew),a5=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._localBounds=new tz,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}t8(t,e);var n=t.prototype;return n._onDestroy=function(){var t;e.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(t=this._jointTexture)||t.destroy(),this._jointTexture=null},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),this.skin&&t._applySkin(null,t.skin),this._blendShapeWeights&&(t._blendShapeWeights=this._blendShapeWeights.slice())},n._update=function(n){var r=this.skin;(null==r?void 0:r.bones.length)>0&&r._updateSkinMatrices(this);var i=this.shaderData,a=this.mesh._blendShapeManager;a._updateShaderData(i,this);var o=null==r?void 0:r.bones;if(o){var s=a._uniformOccupiesCount,l=o.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var d,h=Math.ceil((this._maxVertexUniformVectors-(t._baseVertexUniformVectorCount+s))/4);if(l>h){var _,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(_=this._jointTexture)||_.destroy(),this._jointTexture=new nw(f,4,l,nh.R32G32B32A32,!1,!1),this._jointTexture.filterMode=nd.Point,this._jointTexture.isGCIgnored=!0),i.disableMacro("RENDERER_JOINTS_NUM"),i.enableMacro("RENDERER_USE_JOINT_TEXTURE"),i.setTexture(t._jointSamplerProperty,this._jointTexture)):nA.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)?tz.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|=ad.WorldVolume},n._onSkinUpdated=function(e,n){switch(e){case a8.BoneCountChanged:var r=this.shaderData;n>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(t._jointCountProperty,n)):r.disableMacro("RENDERER_HAS_SKIN");break;case a8.RootBoneChanged:this._setTransformEntity(n),this._dirtyUpdateFlag|=ad.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(a8.BoneCountChanged,u),c!==d&&this._onSkinUpdated(a8.RootBoneChanged,d)},t3(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}(aO);a5._baseVertexUniformVectorCount=48,a5._jointCountProperty=nG.getByName("renderer_JointCount"),a5._jointSamplerProperty=nG.getByName("renderer_JointSampler"),a5._jointMatrixProperty=nG.getByName("renderer_JointMatrix"),t9([ne],a5.prototype,"_condensedBlendShapeWeights",void 0),t9([nr],a5.prototype,"_localBounds",void 0),t9([ne],a5.prototype,"_jointDataCreateCache",void 0),t9([ne],a5.prototype,"_blendShapeWeights",void 0),t9([ne],a5.prototype,"_maxVertexUniformVectors",void 0),t9([ne],a5.prototype,"_jointTexture",void 0),t9([nr],a5.prototype,"_skin",void 0),t9([ne],a5.prototype,"_onLocalBoundsChanged",null),t9([ne],a5.prototype,"_onSkinUpdated",null);var a9=/*#__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 r1(e,rE.find("blit"));r._addReferCount(1),r.renderState.depthState.enabled=!1,r.renderState.depthState.writeEnabled=!1;var i=new r1(e,rE.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,nh.R8G8B8A8,a,!0),this.whiteTextureCube=this._create1x1Texture(e,1,nh.R8G8B8A8,a,!0),e._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(e,2,nh.R8G8B8A8,a,!0);var o=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(e,0,nh.R32G32B32A32_UInt,o,!1)}this.spriteDefaultMaterial=this._create2DMaterial(e,rE.find("Sprite")),this.textDefaultMaterial=this._create2DMaterial(e,rE.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 r3(this.engine))},t._initialize=function(){var e=this;return new Promise(function(t,n){aC.create(e.engine).then(function(n){e._prefilteredDFGTexture=n,t(e)}).catch(n)})},t._createBlitMesh=function(e,t){var n=new aU(e);n._addReferCount(1),n.setVertexElements([new ab("POSITION_UV",0,ax.Vector4,0)]);var r=new av(e,aS.VertexBuffer,t,am.Static,!0);return n.setVertexBufferBinding(r,16),n.addSubMesh(0,3,aT.Triangles),e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return t8(t,e),t.prototype.restoreContent=function(){r.setData(r.data)},t}(ns))),n},t._create1x1Texture=function(e,t,n,r,i){var a;switch(t){case 0:var o=new nw(e,1,1,n,!1,i);o.setPixelBuffer(r),a=o;break;case 2:var s=new nF(e,1,1,1,n,!1,i);s.setPixelBuffer(0,r),a=s;break;case 1:for(var l=new nM(e,1,n,!1,i),c=0;c<6;c++)l.setPixelBuffer(nc.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 t8(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(nc.PositiveX+e,r)}},n}(ns))),a},t._create2DMaterial=function(e,t){var n=new r1(e,t),r=n.renderState,i=r.blendState.targetBlendState;return i.enabled=!0,i.sourceColorBlendFactor=n9.SourceAlpha,i.destinationColorBlendFactor=n9.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=n9.One,i.destinationAlphaBlendFactor=n9.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=n6.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=rt.Off,r.renderQueueType=rn.Transparent,n.isGCIgnored=!0,n},t._createMagentaMaterial=function(e,t){var n=new r1(e,rE.find(t));return n.isGCIgnored=!0,n.shaderData.setColor("material_BaseColor",new tZ(1,0,1.01,1)),n},t._createSpriteMaskMaterial=function(e){var t=new r1(e,rE.find("SpriteMask"));return t.isGCIgnored=!0,t},e.getMaskInteractionRenderStates=function(t){var n,r;if(t===n$.VisibleInsideMask){if(n=e._maskReadInsideRenderStates)return n;e._maskReadInsideRenderStates=n={},r=re.LessEqual}else{if(n=e._maskReadOutsideRenderStates)return n;e._maskReadOutsideRenderStates=n={},r=re.Greater}return n[rr.StencilStateEnabled]=!0,n[rr.StencilStateWriteMask]=0,n[rr.StencilStateReferenceValue]=1,n[rr.StencilStateCompareFunctionFront]=r,n[rr.StencilStateCompareFunctionBack]=r,n},e.getMaskTypeRenderStates=function(t){if(t===i3.Increment){if(n=e._maskWriteIncrementRenderStates)return n;e._maskWriteIncrementRenderStates=n={},r=rs.IncrementSaturate}else{if(n=e._maskWriteDecrementRenderStates)return n;e._maskWriteDecrementRenderStates=n={},r=rs.DecrementSaturate}n[rr.StencilStateEnabled]=!0,n[rr.StencilStatePassOperationFront]=r,n[rr.StencilStatePassOperationBack]=r,n[rr.StencilStateCompareFunctionFront]=re.Always,n[rr.StencilStateCompareFunctionBack]=re.Always;var n,r,i=rs.Keep;return n[rr.StencilStateFailOperationFront]=i,n[rr.StencilStateFailOperationBack]=i,n[rr.StencilStateZFailOperationFront]=i,n[rr.StencilStateZFailOperationBack]=i,n[rr.BlendStateColorWriteMask0]=n7.None,n[rr.DepthStateEnabled]=!1,n[rr.RasterStateCullMode]=rt.Off,n},t3(e,[{key:"prefilteredDFGTexture",get:function(){return this._prefilteredDFGTexture}}]),e}();a9._maskReadInsideRenderStates=null,a9._maskReadOutsideRenderStates=null,a9._maskWriteIncrementRenderStates=null,a9._maskWriteDecrementRenderStates=null;var a6=/*#__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}(),a7=/*#__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}t8(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}(a6),oe=/*#__PURE__*/function(){function e(){}return e.prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},e}(),ot=/*#__PURE__*/function(){function e(e,t){this.start=e,this.size=t}return e.prototype.dispose=function(){},e}(),on=/*#__PURE__*/function(){function e(e,t){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new aD(e);n.addVertexElement(new ab("POSITION",0,ax.Vector3,0)),n.addVertexElement(new ab("TEXCOORD_0",12,ax.Vector2,0)),n.addVertexElement(new ab("COLOR_0",20,ax.Vector4,0)),n._addReferCount(1);var r=new av(e,aS.VertexBuffer,36*t,am.Dynamic,!0);n.setVertexBufferBinding(0,new aI(r,36));var i=new av(e,aS.IndexBuffer,8*t,am.Dynamic,!0);n.setIndexBufferBinding(new aP(i,ay.UInt16)),this.primitive=n,this.vertices=new Float32Array(r.data.buffer),this.indices=new Uint16Array(i.data.buffer),this.vertexFreeAreas=[new ot(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=aT.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,ag.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER),e.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,ag.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}();on.areaPool=new a7(ot,10),on.subChunkPool=new a7(oe,10),on.subMeshPool=new a7(aF,10);var or=/*#__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 on(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}(),oi=/*#__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()},t3(e,[{key:"primitiveChunkManager2D",get:function(){return this._primitiveChunkManager2D||(this._primitiveChunkManager2D=new or(this.engine))}},{key:"primitiveChunkManagerMask",get:function(){return this._primitiveChunkManagerMask||(this._primitiveChunkManagerMask=new or(this.engine,128))}},{key:"primitiveChunkManagerUI",get:function(){return this._primitiveChunkManagerUI||(this._primitiveChunkManagerUI=new or(this.engine))}}]),e}(),oa=/*#__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 nw(g,t,n,r,o,s)).isGCIgnored=!0,v.wrapModeU=v.wrapModeV=c,v.filterMode=u),a){var y=null;i&&((y=new nw(g,t,n,i,o,s)).isGCIgnored=!0,y.wrapModeU=y.wrapModeV=c,y.filterMode=u),d=new nP(g,t,n,v,y,l)}else d=new nP(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 nw(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}(),oo=((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.Env="Environment",eF.Scene="Scene",eF.HDR="HDR",eF.Font="Font",eF.SourceFont="SourceFont",eF.Audio="Audio",eF.Project="project",eF.PhysicsMaterial="PhysicsMaterial",eF),os=/*#__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},t3(e,[{key:"length",get:function(){return this._array.length}}]),e}(),ol=/*#__PURE__*/function(){function e(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new os}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:oo.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()},t3(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}(),oc=/*#__PURE__*/function(){function e(){this._textureMemory=0,this._bufferMemory=0}return e.prototype._reset=function(){this._textureMemory=0,this._bufferMemory=0},t3(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}(),ou={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},od=1/0;function oh(e,t){return void 0===t&&(t={}),new nb(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:od,t.type=null!=(c=t.type)?c:ou[e.substring(e.lastIndexOf(".")+1)],new o_(function(){var n;return(n=t,new nb(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 o_=/*#__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}(),of=/*#__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._idResourceMap=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 nb.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];t6(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 oh(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 nb(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 nb(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 nb(function(e,t){s?e(s):l&&t(l)});var c=new nb(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)===om&&t.push(""),e.replace(ov,function(e,n,r,i){var a=e;r?a=i.replace(og,"$1"):n&&(a=n.trim()),t.push(a)}),t},t._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},t.getResourceByRef=function(e){var t,n=e.refId,r=e.key,i=e.isClone,a=this._objectPool[n];if(a)t=nb.resolve(a);else{var o=this._idResourceMap[n];if(!o)return nA.warn("refId:"+n+" is not find in this._idResourceMap."),nb.resolve(null);var s=o.virtualPath;r&&(s+="?q="+r),t=this.load({url:s,type:o.type,params:o.params})}return t.then(function(e){return i?e.clone():e})},t.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathResourceMap[e.virtualPath]=e,t._idResourceMap[e.id]=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 op(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);of._addLoader(e,i,t)}}of._loaders={},of._extTypeMapping={};var om=46,og=/\\(\\)?/g,ov=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),oy=((eD={})[eD.None=0]="None",eD[eD.Primary=1]="Primary",eD[eD.Secondary=2]="Secondary",eD[eD.Auxiliary=4]="Auxiliary",eD[eD.XButton1=8]="XButton1",eD[eD.XButton2=16]="XButton2",eD[eD.XButton3=32]="XButton3",eD[eD.XButton4=64]="XButton4",eD[eD.XButton5=128]="XButton5",eD[eD.XButton6=256]="XButton6",eD[eD.XButton7=512]="XButton7",eD[eD.XButton8=1024]="XButton8",eD),ox=[1,4,2,8,16,32,64,128,256,512,1024],oA={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},ob=((eB={})[eB.Backquote=0]="Backquote",eB[eB.Backslash=1]="Backslash",eB[eB.Backspace=2]="Backspace",eB[eB.BracketLeft=3]="BracketLeft",eB[eB.BracketRight=4]="BracketRight",eB[eB.Comma=5]="Comma",eB[eB.Digit0=6]="Digit0",eB[eB.Digit1=7]="Digit1",eB[eB.Digit2=8]="Digit2",eB[eB.Digit3=9]="Digit3",eB[eB.Digit4=10]="Digit4",eB[eB.Digit5=11]="Digit5",eB[eB.Digit6=12]="Digit6",eB[eB.Digit7=13]="Digit7",eB[eB.Digit8=14]="Digit8",eB[eB.Digit9=15]="Digit9",eB[eB.Equal=16]="Equal",eB[eB.IntlBackslash=17]="IntlBackslash",eB[eB.IntlRo=18]="IntlRo",eB[eB.IntlYen=19]="IntlYen",eB[eB.KeyA=20]="KeyA",eB[eB.KeyB=21]="KeyB",eB[eB.KeyC=22]="KeyC",eB[eB.KeyD=23]="KeyD",eB[eB.KeyE=24]="KeyE",eB[eB.KeyF=25]="KeyF",eB[eB.KeyG=26]="KeyG",eB[eB.KeyH=27]="KeyH",eB[eB.KeyI=28]="KeyI",eB[eB.KeyJ=29]="KeyJ",eB[eB.KeyK=30]="KeyK",eB[eB.KeyL=31]="KeyL",eB[eB.KeyM=32]="KeyM",eB[eB.KeyN=33]="KeyN",eB[eB.KeyO=34]="KeyO",eB[eB.KeyP=35]="KeyP",eB[eB.KeyQ=36]="KeyQ",eB[eB.KeyR=37]="KeyR",eB[eB.KeyS=38]="KeyS",eB[eB.KeyT=39]="KeyT",eB[eB.KeyU=40]="KeyU",eB[eB.KeyV=41]="KeyV",eB[eB.KeyW=42]="KeyW",eB[eB.KeyX=43]="KeyX",eB[eB.KeyY=44]="KeyY",eB[eB.KeyZ=45]="KeyZ",eB[eB.Minus=46]="Minus",eB[eB.Period=47]="Period",eB[eB.Quote=48]="Quote",eB[eB.Semicolon=49]="Semicolon",eB[eB.Slash=50]="Slash",eB[eB.AltLeft=51]="AltLeft",eB[eB.AltRight=52]="AltRight",eB[eB.CapsLock=53]="CapsLock",eB[eB.ContextMenu=54]="ContextMenu",eB[eB.ControlLeft=55]="ControlLeft",eB[eB.ControlRight=56]="ControlRight",eB[eB.Enter=57]="Enter",eB[eB.MetaLeft=58]="MetaLeft",eB[eB.MetaRight=59]="MetaRight",eB[eB.ShiftLeft=60]="ShiftLeft",eB[eB.ShiftRight=61]="ShiftRight",eB[eB.Space=62]="Space",eB[eB.Tab=63]="Tab",eB[eB.Convert=64]="Convert",eB[eB.KanaMode=65]="KanaMode",eB[eB.Lang1=66]="Lang1",eB[eB.Lang2=67]="Lang2",eB[eB.Lang3=68]="Lang3",eB[eB.Lang4=69]="Lang4",eB[eB.Lang5=70]="Lang5",eB[eB.NonConvert=71]="NonConvert",eB[eB.Delete=72]="Delete",eB[eB.End=73]="End",eB[eB.Help=74]="Help",eB[eB.Home=75]="Home",eB[eB.Insert=76]="Insert",eB[eB.PageDown=77]="PageDown",eB[eB.PageUp=78]="PageUp",eB[eB.ArrowDown=79]="ArrowDown",eB[eB.ArrowLeft=80]="ArrowLeft",eB[eB.ArrowRight=81]="ArrowRight",eB[eB.ArrowUp=82]="ArrowUp",eB[eB.NumLock=83]="NumLock",eB[eB.Numpad0=84]="Numpad0",eB[eB.Numpad1=85]="Numpad1",eB[eB.Numpad2=86]="Numpad2",eB[eB.Numpad3=87]="Numpad3",eB[eB.Numpad4=88]="Numpad4",eB[eB.Numpad5=89]="Numpad5",eB[eB.Numpad6=90]="Numpad6",eB[eB.Numpad7=91]="Numpad7",eB[eB.Numpad8=92]="Numpad8",eB[eB.Numpad9=93]="Numpad9",eB[eB.NumpadAdd=94]="NumpadAdd",eB[eB.NumpadBackspace=95]="NumpadBackspace",eB[eB.NumpadClear=96]="NumpadClear",eB[eB.NumpadClearEntry=97]="NumpadClearEntry",eB[eB.NumpadComma=98]="NumpadComma",eB[eB.NumpadDecimal=99]="NumpadDecimal",eB[eB.NumpadDivide=100]="NumpadDivide",eB[eB.NumpadEnter=101]="NumpadEnter",eB[eB.NumpadEqual=102]="NumpadEqual",eB[eB.NumpadHash=103]="NumpadHash",eB[eB.NumpadMemoryAdd=104]="NumpadMemoryAdd",eB[eB.NumpadMemoryClear=105]="NumpadMemoryClear",eB[eB.NumpadMemoryRecall=106]="NumpadMemoryRecall",eB[eB.NumpadMemoryStore=107]="NumpadMemoryStore",eB[eB.NumpadMemorySubtract=108]="NumpadMemorySubtract",eB[eB.NumpadMultiply=109]="NumpadMultiply",eB[eB.NumpadParenLeft=110]="NumpadParenLeft",eB[eB.NumpadParenRight=111]="NumpadParenRight",eB[eB.NumpadStar=112]="NumpadStar",eB[eB.NumpadSubtract=113]="NumpadSubtract",eB[eB.Escape=114]="Escape",eB[eB.F1=115]="F1",eB[eB.F2=116]="F2",eB[eB.F3=117]="F3",eB[eB.F4=118]="F4",eB[eB.F5=119]="F5",eB[eB.F6=120]="F6",eB[eB.F7=121]="F7",eB[eB.F8=122]="F8",eB[eB.F9=123]="F9",eB[eB.F10=124]="F10",eB[eB.F11=125]="F11",eB[eB.F12=126]="F12",eB[eB.F13=127]="F13",eB[eB.F14=128]="F14",eB[eB.F15=129]="F15",eB[eB.Fn=130]="Fn",eB[eB.FnLock=131]="FnLock",eB[eB.PrintScreen=132]="PrintScreen",eB[eB.ScrollLock=133]="ScrollLock",eB[eB.Pause=134]="Pause",eB[eB.BrowserBack=135]="BrowserBack",eB[eB.BrowserFavorites=136]="BrowserFavorites",eB[eB.BrowserForward=137]="BrowserForward",eB[eB.BrowserHome=138]="BrowserHome",eB[eB.BrowserRefresh=139]="BrowserRefresh",eB[eB.BrowserSearch=140]="BrowserSearch",eB[eB.BrowserStop=141]="BrowserStop",eB[eB.Eject=142]="Eject",eB[eB.LaunchApp1=143]="LaunchApp1",eB[eB.LaunchApp2=144]="LaunchApp2",eB[eB.LaunchMail=145]="LaunchMail",eB[eB.MediaPlayPause=146]="MediaPlayPause",eB[eB.MediaSelect=147]="MediaSelect",eB[eB.MediaStop=148]="MediaStop",eB[eB.MediaTrackNext=149]="MediaTrackNext",eB[eB.MediaTrackPrevious=150]="MediaTrackPrevious",eB[eB.Power=151]="Power",eB[eB.Sleep=152]="Sleep",eB[eB.AudioVolumeDown=153]="AudioVolumeDown",eB[eB.AudioVolumeMute=154]="AudioVolumeMute",eB[eB.AudioVolumeUp=155]="AudioVolumeUp",eB[eB.WakeUp=156]="WakeUp",eB[eB.Hyper=157]="Hyper",eB[eB.Super=158]="Super",eB[eB.Turbo=159]="Turbo",eB[eB.Abort=160]="Abort",eB[eB.Resume=161]="Resume",eB[eB.Suspend=162]="Suspend",eB[eB.Again=163]="Again",eB[eB.Copy=164]="Copy",eB[eB.Cut=165]="Cut",eB[eB.Find=166]="Find",eB[eB.Open=167]="Open",eB[eB.Paste=168]="Paste",eB[eB.Props=169]="Props",eB[eB.Select=170]="Select",eB[eB.Undo=171]="Undo",eB[eB.Hiragana=172]="Hiragana",eB[eB.Katakana=173]="Katakana",eB[eB.Unidentified=174]="Unidentified",eB),oS=/*#__PURE__*/function(){function e(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new nK,this._curFrameDownList=new nK,this._curFrameUpList=new nK,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=ob[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,nC.platform===t1.Mac&&(d===ob.MetaLeft||d===ob.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}(),oT=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._usedElementCount=0,n._elements=[],n}t8(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}(a6),oC=((eL={})[eL.Down=0]="Down",eL[eL.Move=1]="Move",eL[eL.Stationary=2]="Stationary",eL[eL.Up=3]="Up",eL[eL.Leave=4]="Leave",eL),oR=/*#__PURE__*/function(){function e(e){this.phase=oC.Leave,this.position=new tQ,this.deltaPosition=new tQ,this._events=[],this._upMap=[],this._downMap=[],this._upList=new nK,this._downList=new nK,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}(),oE=((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),oM=/*#__PURE__*/function(){function e(){this.worldPosition=new tk}return e.prototype.dispose=function(){this.pointer=null},e}(),oP=/*#__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}();oP._tempRay=new tK;var ow=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}t8(t,e);var n=t.prototype;return n.processRaycast=function(e,t){for(var n=oP._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&rX.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 iB},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}(oP),oF=/*#__PURE__*/function(){function e(e,t){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=oy.None,this._upMap=[],this._downMap=[],this._upList=new nK,this._downList=new nK,this._nativeEvents=[],this._eventPool=new oT(oM),"undefined"!=typeof Window&&t6(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===oC.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 oR(g),a._physicsInitialized&&u._addEmitters(ow,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=oy.None;for(var A=a.time.frameCount,b=0,S=n.length;b<S;b++){var T=n[b];this._updatePointerInfo(A,T,_,f,p,m),this._buttons|=T.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&oE.Move){i.phase=oC.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=ox[h.button]||oy.None,i.pressedButtons=h.buttons,h.type){case"pointerdown":i.phase=oC.Down;for(var _=0;_<s;_++)o[_].processDown(i);break;case"pointerup":i.phase=oC.Up;for(var f=0;f<s;f++)o[f].processUp(i);break;case"pointerleave":case"pointercancel":i.phase=oC.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=ox[_.button]||oy.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|=oE.Down,t.phase=oC.Down;break;case"pointerup":var y=g.button;c.add(y),u[y]=e,t._upList.add(y),t._upMap[y]=e,t._frameEvents|=oE.Up,t.phase=oC.Up;break;case"pointermove":t._frameEvents|=oE.Move,t.phase=oC.Move;break;case"pointerleave":t._frameEvents|=oE.Leave,t.phase=oC.Leave;break;case"pointercancel":t._frameEvents|=oE.Cancel,t.phase=oC.Leave}}}else t.deltaPosition.set(0,0),t.phase=oC.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 oD(){return function(e){oF._pointerEventEmitters.push(e)}}oF._pointerEventEmitters=[];var oB=/*#__PURE__*/function(){function e(e,t){this._delta=new tk,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}(),oL=/*#__PURE__*/function(){function e(e,t){this._initialized=!1,this._engine=e;var n,r,i,a=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&t6(a,OffscreenCanvas)||(this._wheelManager=new oB(e,null!=(n=null==t?void 0:t.wheelTarget)?n:a),this._pointerManager=new oF(e,null!=(r=null==t?void 0:t.pointerTarget)?r:a),this._keyboardManager=new oS(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[oA[e]]===this._engine.time.frameCount)},t.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[oA[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)},t3(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}(),oI=((eN={}).cornerTextureCoordinate="a_CornerTextureCoordinate",eN),oN=((eO={}).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",eO.DirectionTime="a_DirectionTime",eO.StartColor="a_StartColor",eO.StartSize="a_StartSize",eO.StartRotation0="a_StartRotation0",eO.StartSpeed="a_StartSpeed",eO.Random0="a_Random0",eO.Random1="a_Random1",eO.SimulationWorldPosition="a_SimulationWorldPosition",eO.SimulationWorldRotation="a_SimulationWorldRotation",eO.SimulationUV="a_SimulationUV",eO.Random2="a_Random2",eO),oO=function e(t){this.billboardVertexElement=new ab(oI.cornerTextureCoordinate,0,ax.Vector4,0),this.instanceVertexElements=[new ab(oN.ShapePositionStartLifeTime,0,ax.Vector4,1,1),new ab(oN.DirectionTime,16,ax.Vector4,1,1),new ab(oN.StartColor,32,ax.Vector4,1,1),new ab(oN.StartSize,48,ax.Vector3,1,1),new ab(oN.StartRotation0,60,ax.Vector3,1,1),new ab(oN.StartSpeed,72,ax.Float,1,1),new ab(oN.Random0,76,ax.Vector4,1,1),new ab(oN.Random1,92,ax.Vector4,1,1),new ab(oN.SimulationWorldPosition,108,ax.Vector3,1,1),new ab(oN.SimulationWorldRotation,120,ax.Vector4,1,1),new ab(oN.SimulationUV,136,ax.Vector4,1,1),new ab(oN.Random2,152,ax.Vector4,1,1)];var n=new av(t,aS.VertexBuffer,64,am.Static,!1);n.isGCIgnored=!0,this.billboardVertexBufferBinding=new aI(n,16);var r=new av(t,aS.IndexBuffer,e.billboardIndexCount,am.Static,!1);r.isGCIgnored=!0,this.billboardIndexBufferBinding=new aP(r,ay.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 t8(t,e),t.prototype.restoreContent=function(){n.setData(i)},t}(ns))),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,r)||this}return t8(t,e),t.prototype.restoreContent=function(){},t}(ns)))};oO.instanceVertexStride=168,oO.instanceVertexFloatStride=oO.instanceVertexStride/4,oO.startLifeTimeOffset=3,oO.timeOffset=7,oO.simulationUVOffset=34,oO.billboardIndexCount=6,oO.boundsFloatStride=8,oO.boundsTimeOffset=6,oO.boundsMaxLifetimeOffset=7;var oV="#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",ok=/*#__PURE__*/function(){function e(){}return e.init=function(){var e=new ry("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:rd.ShadowCaster});e._renderState=new rR,e._renderStateDataMap[rr.RenderQueueType]=r2._shadowCasterRenderQueueProp;var t=new ry("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:rd.DepthOnly});t._renderState=new rR,t._renderStateDataMap[rr.RenderQueueType]=r2._depthOnlyRenderQueueProp;var n=[e,t],r={pipelineStage:rd.Forward};rE.create("blinn-phong",[].concat([new ry("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",r)],n)),rE.create("pbr",[].concat([new ry("Forward",oV,"#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",r)],n)),rE.create("pbr-specular",[].concat([new ry("Forward",oV,"#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",r)],n)),rE.create("unlit",[].concat([new ry("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",r)],n)),rE.create("blit",[new ry("Forward",it,"#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",r)]),rE.create("blit-screen",[new ry("Forward",it,"#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",r)]),rE.create("skybox",[new ry("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 MATERIAL_IS_DECODE_SKY_RGBM\n textureColor = RGBMToLinear(textureColor, 5.0);\n #elif defined(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",r)]),rE.create("SkyProcedural",[new ry("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",r)]),rE.create("particle-shader",[new ry("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\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 u_DragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <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 getStartPosition(vec3 startVelocity, float age, vec3 dragData) {\n vec3 startPosition;\n float lastTime = min(startVelocity.x / dragData.x, age); // todo 0/0\n startPosition = lastTime * (startVelocity - 0.5 * dragData * lastTime);\n return startPosition;\n}\n\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, vec3 dragData, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = getStartPosition(startVelocity, age, dragData);\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 if (normalizedAge < 1.0) {\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity = startVelocity;\n vec3 worldVelocity = gravityVelocity;\n\n //drag\n vec3 dragData = a_DirectionTime.xyz * mix(u_DragConstant.x, u_DragConstant.y, a_Random0.x);\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, dragData, localVelocity, worldVelocity);\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}",r)]),rE.create("trail",[new ry("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",r)]),rE.create("SpriteMask",[new ry("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",r)]),rE.create("Sprite",[new ry("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",r)]),rE.create("Text",[new ry("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",r)]),rE.create("background-texture",[new ry("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}",r)])},e}(),oU=/*#__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}(),oz=/*#__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 i4(rn.Transparent)),l=this._virtualCamera||(this._virtualCamera=new rG),c=this._viewport||(this._viewport=new tq(0,0,1,1)),u=this._overlayCamera||(this._overlayCamera=new oG);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,tY.multiply(l.projectionMatrix,l.viewMatrix,l.viewProjectionMatrix),a.applyVirtualCamera(l,!1),s.rendererUpdateFlag|=rw.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}();oz._shouldSRGBCorrect=rl.getByName("ENGINE_SHOULD_SRGB_CORRECT");var oG=function(){this.instanceId=++na._instanceIdCounter,this.shaderData=new rM(ri.Camera),this.enableFrustumCulling=!0,this.cullingMask=rV.Everything,this._globalShaderMacro=new rc},oH=/*#__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 rX.None},e}();ok.init();var oX=/*#__PURE__*/function(e){function t(n,r,i){(a=e.call(this)||this)._renderingStatistics=new oc,a._isDeviceLost=!1,a._frameInProcess=!1,a._pendingDestroyObjects=[],a._processingPendingDestroys=!1,a._physicsInitialized=!1,a._lastRenderState=new rR,a._renderElementPool=new oT(as),a._subRenderElementPool=new oT(al),a._textSubRenderElementPool=new oT(al),a._charRenderInfoPool=new a7(t5,50),a._renderContext=new rP,a._renderCount=0,a._shaderProgramPools=[],a._fontMap={},a._macroCollection=new rc,a._postProcessPassNeedRefresh=!1,a._settings={},a._resourceManager=new of(a),a._sceneManager=new ol(a),a._vSyncCount=1,a._targetFrameRate=60,a._time=new nH,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=nO.createFromOS(a,"Arial"),a._textDefaultFont.isGCIgnored=!0,a._batcherManager=new oi(a),a._renderTargetPool=new oa(a),a.inputManager=new oL(a,i.input);var a,o=i.xrDevice;if(o&&(a.xrManager=new oH,a.xrManager._initialize(a,o)),r.canIUse(nT.depthTexture)){var s=new nw(a,1,1,nh.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 a9(a),a._particleBufferUtils=new oO(a);var l=new i1(a);return a.addPostProcessPass(l),a}t8(t,e);var n=t.prototype;return n.createEntity=function(e){return new a3(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(),rE._clear(this),this._hardwareRenderer.destroy(),this.removeAllEventListeners()},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e){var t=e._shaderPassId,n=this._shaderProgramPools,r=n[t];if(!r){var i=t+1;i>n.length&&(n.length=i),n[t]=r=new oU(this),e._shaderProgramPools.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?nA.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()):nA.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(),oz.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&&!rE._shaderLab&&(rE._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=of._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 rR,rE._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()},t3(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}(nz);oX._noDepthTextureMacro=rl.getByName("ENGINE_NO_DEPTH_TEXTURE"),oX._noSRGBSupportMacro=rl.getByName("ENGINE_NO_SRGB"),oX._outputSRGBCorrectMacro=rl.getByName("ENGINE_OUTPUT_SRGB_CORRECT"),oX._pixelsPerUnit=100,oX._physicalObjectsMap={};var oW=/*#__PURE__*/function(){function e(){this._sizeUpdateFlagManager=new n3}return t3(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}(),oj=/*#__PURE__*/function(){function e(){this._cameraNeedSorting=!1,this._activeCameras=new nK,this._renderers=new nK,this._overlayCanvases=new nK,this._overlayCanvasesSortingDirty=!1,this._canvases=new nK,this._onStartScripts=new nK,this._onUpdateScripts=new nK,this._onLateUpdateScripts=new nK,this._onPhysicsUpdateScripts=new nK,this._onUpdateAnimations=new nK,this._onUpdateRenderers=new nK,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}(),oY=/*#__PURE__*/function(){function e(){this.hasStencilWritten=!1,this._preMaskLayer=ac.Nothing,this._allSpriteMasks=new nK}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,i3.Increment),i.clear(),a.batch(o),o.uploadBuffer(),a.render(t,n,i3.Decrement),a.clear()},t.clearMask=function(t,n){var r=this._preMaskLayer;if(r!==ac.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,i3.Decrement),i.clear()}else{var u=t.camera.engine;u._hardwareRenderer.clearRenderTarget(u,rX.Stencil,null)}this._preMaskLayer=ac.Nothing}},t.isStencilWritten=function(e){var t=e.renderState.stencilState,n=rs.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!==re.Always&&i!==re.Never||a!==re.Always&&a!==re.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 i4(rn.Transparent))},e.getMaskDecrementRenderQueue=function(){return e._maskDecrementRenderQueue||(e._maskDecrementRenderQueue=new i4(rn.Transparent))},e}(),oK=((eV={})[eV.None=0]="None",eV[eV.Linear=1]="Linear",eV[eV.Exponential=2]="Exponential",eV[eV.ExponentialSquared=3]="ExponentialSquared",eV),oQ=((ek={})[ek.SolidColor=0]="SolidColor",ek[ek.SphericalHarmonics=1]="SphericalHarmonics",ek),oq=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._diffuseSolidColor=new tZ(.03696758874771872,.0421494543549785,.05455383078270364),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=oQ.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n._specularTextureDecodeRGBM=!1,n}t8(t,e);var n=t.prototype;return n._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var n=e.shaderData;n.setColor(t._diffuseColorProperty,this._diffuseSolidColor),n.setFloat(t._diffuseIntensityProperty,this._diffuseIntensity),n.setFloat(t._specularIntensityProperty,this._specularIntensity),n.setFloatArray(t._diffuseSHProperty,this._shArray),this._setDiffuseMode(n),this._setSpecularTextureDecodeRGBM(n),this._setSpecularTexture(n)},n._removeFromScene=function(e){this._addReferCount(-1);var n=this._scenes,r=n.indexOf(e);n.splice(r,1);var i=e.shaderData;i.setTexture(t._specularTextureProperty,null),i.disableMacro(t._specularMacro)},n._setDiffuseMode=function(e){this._diffuseMode===oQ.SphericalHarmonics?e.enableMacro(t._shMacro):e.disableMacro(t._shMacro)},n._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(t._specularTextureProperty,this._specularTexture),e.setFloat(t._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(t._specularMacro)):e.disableMacro(t._specularMacro)},n._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(t._decodeRGBMMacro):e.disableMacro(t._decodeRGBMMacro)},n._preComputeSH=function(e,t){var n=e.coefficients;t[0]=.886227*n[0],t[1]=.886227*n[1],t[2]=.886227*n[2],t[3]=-1.023327*n[3],t[4]=-1.023327*n[4],t[5]=-1.023327*n[5],t[6]=1.023327*n[6],t[7]=1.023327*n[7],t[8]=1.023327*n[8],t[9]=-1.023327*n[9],t[10]=-1.023327*n[10],t[11]=-1.023327*n[11],t[12]=.858086*n[12],t[13]=.858086*n[13],t[14]=.858086*n[14],t[15]=-.858086*n[15],t[16]=-.858086*n[16],t[17]=-.858086*n[17],t[18]=.247708*n[18],t[19]=.247708*n[19],t[20]=.247708*n[20],t[21]=-.858086*n[21],t[22]=-.858086*n[22],t[23]=-.858086*n[23],t[24]=.429042*n[24],t[25]=.429042*n[25],t[26]=.429042*n[26]},t3(t,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTextureDecodeRGBM(t[n].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setDiffuseMode(t[n].shaderData)}},{key:"diffuseSolidColor",get:function(){return this._diffuseSolidColor},set:function(e){e!==this._diffuseSolidColor&&this._diffuseSolidColor.copyFrom(e)}},{key:"diffuseSphericalHarmonics",get:function(){return this._diffuseSphericalHarmonics},set:function(e){if(this._diffuseSphericalHarmonics=e,e){this._preComputeSH(e,this._shArray);for(var n=this._scenes,r=0,i=n.length;r<i;r++)n[r].shaderData.setFloatArray(t._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var n=this._scenes,r=0,i=n.length;r<i;r++)n[r].shaderData.setFloat(t._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTexture(t[n].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var n=0,r=this._scenes.length;n<r;n++)this._scenes[n].shaderData.setFloat(t._specularIntensityProperty,e)}}]),t}(no);oq._shMacro=rl.getByName("SCENE_USE_SH"),oq._specularMacro=rl.getByName("SCENE_USE_SPECULAR_ENV"),oq._decodeRGBMMacro=rl.getByName("SCENE_IS_DECODE_ENV_RGBM"),oq._diffuseColorProperty=nG.getByName("scene_EnvMapLight.diffuse"),oq._diffuseSHProperty=nG.getByName("scene_EnvSH"),oq._diffuseIntensityProperty=nG.getByName("scene_EnvMapLight.diffuseIntensity"),oq._specularTextureProperty=nG.getByName("scene_EnvSpecularSampler"),oq._specularIntensityProperty=nG.getByName("scene_EnvMapLight.specularIntensity"),oq._mipLevelProperty=nG.getByName("scene_EnvMapLight.mipMapLevel");var oZ=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.cullingMask=rV.Everything,t.shadowType=i6.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t._lightIndex=-1,t._shadowStrength=1,t._color=new tZ(1,1,1,1),t}return t8(t,e),t3(t,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=tV.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 tY),tY.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new tY),tY.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),t}(rL);t9([ne],oZ.prototype,"_lightIndex",void 0),t9([nr],oZ.prototype,"_color",void 0),t9([ne],oZ.prototype,"_viewMat",void 0),t9([ne],oZ.prototype,"_inverseViewMat",void 0);var oJ=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shadowNearPlaneOffset=.1,t._reverseDirection=new tk,t}t8(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)},t3(t,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tk.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}}]),t}(oZ);oJ._cullingMaskProperty=nG.getByName("scene_DirectLightCullingMask"),oJ._colorProperty=nG.getByName("scene_DirectLightColor"),oJ._directionProperty=nG.getByName("scene_DirectLightDirection"),t9([ne],oJ.prototype,"_reverseDirection",void 0);var o$=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t}t8(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)},t3(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}}]),t}(oZ);o$._cullingMaskProperty=nG.getByName("scene_PointLightCullingMask"),o$._colorProperty=nG.getByName("scene_PointLightColor"),o$._positionProperty=nG.getByName("scene_PointLightPosition"),o$._distanceProperty=nG.getByName("scene_PointLightDistance");var o0=/*#__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 tk,t}t8(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)},t3(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tk.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}}]),t}(oZ);o0._cullingMaskProperty=nG.getByName("scene_SpotLightCullingMask"),o0._colorProperty=nG.getByName("scene_SpotLightColor"),o0._positionProperty=nG.getByName("scene_SpotLightPosition"),o0._directionProperty=nG.getByName("scene_SpotLightDirection"),o0._distanceProperty=nG.getByName("scene_SpotLightDistance"),o0._angleCosProperty=nG.getByName("scene_SpotLightAngleCos"),o0._penumbraCosProperty=nG.getByName("scene_SpotLightPenumbraCos"),t9([ne],o0.prototype,"_inverseDirection",void 0);var o1=/*#__PURE__*/function(){function e(e){this.quality=ir.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)},t3(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}();o1._enableMacro=rl.getByName("SCENE_ENABLE_AMBIENT_OCCLUSION");var o2=/*#__PURE__*/function(){function e(){this._spotLights=new nK,this._pointLights=new nK,this._directLights=new nK,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?(oJ._updateShaderData(t,s),t.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):t.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(o$._updateShaderData(t,o),t.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):t.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(o0._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===i6.None||r||(n=Number.NEGATIVE_INFINITY,r=!0);var s=o.color.getBrightness();r?o.shadowType!==i6.None&&n<s&&(n=s,t=o):n<s&&(n=s,t=o)}return t},e}();o2._sunlightColorProperty=nG.getByName("scene_SunlightColor"),o2._sunlightDirectionProperty=nG.getByName("scene_SunlightDirection"),o2._maxLight=10;var o3=/*#__PURE__*/function(e){function t(n,r){(i=e.call(this,n)||this).physics=new iN(i),i.castShadows=!0,i.shadowResolution=i9.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new tk(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i.postProcessManager=new iJ(i),i.ambientOcclusion=new o1(i),i._lightManager=new o2,i._componentsManager=new oj,i._maskManager=new oY,i._isActiveInEngine=!1,i._rootEntities=[],i._background=new rD(i._engine),i._shaderData=new rM(ri.Scene),i._shadowCascades=ae.NoCascades,i._fogMode=oK.None,i._fogColor=new tZ(.21404114048223255,.21404114048223255,.21404114048223255,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new tq,i._isActive=!0,i._enableTransparentShadow=!1,i.name=r||"";var i,a=i.shaderData;return a._addReferCount(1),i.ambientLight=new oq(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}t8(t,e);var n=t.prototype;return n.createRootEntity=function(e){var t=new a3(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&&a3._removeFromChildren(i._rootEntities,t),a3._addToChildren(this._rootEntities,t,n)):r||a3._addToChildren(this._rootEntities,t,n);var a=rB.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(a|=rB.Hierarchy)),t._isActiveInScene&&i!==this&&(a|=rB.Scene),a&&t._processInActive(a),i!==this&&a3._traverseSetOwnerScene(t,this);var o=rB.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=rB.Hierarchy)),t._isActiveInScene&&i===this||(o|=rB.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){a3._removeFromChildren(this._rootEntities,e),e._isRoot=!1;var t=rB.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=rB.Hierarchy),e._isActiveInScene&&(t|=rB.Scene),t&&e._processInActive(t),a3._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=a3._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(rB.Hierarchy):r._processInActive(rB.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(o2._sunlightColorProperty,r.color),e.setVector3(o2._sunlightDirectionProperty,r.direction)):e.setVector3(o2._sunlightDirectionProperty,tk._zero),this.castShadows&&r&&r.shadowType!==i6.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()},t3(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){nA.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}(na);function o4(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}o3._fogColorProperty=nG.getByName("scene_FogColor"),o3._fogParamsProperty=nG.getByName("scene_FogParams"),o3._prefilterdDFGProperty=nG.getByName("scene_PrefilteredDFG");var o8=/*#__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}t8(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 o4(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 o4(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(o5));!(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}(rL);t9([ne],o8.prototype,"_started",void 0),t9([ne],o8.prototype,"_onStartIndex",void 0),t9([ne],o8.prototype,"_onUpdateIndex",void 0),t9([ne],o8.prototype,"_onLateUpdateIndex",void 0),t9([ne],o8.prototype,"_onPhysicsUpdateIndex",void 0),t9([ne],o8.prototype,"_onPreRenderIndex",void 0),t9([ne],o8.prototype,"_onPostRenderIndex",void 0),t9([ne],o8.prototype,"_entityScriptsIndex",void 0);var o5=((eU={}).onPointerDown="onPointerDown",eU.onPointerUp="onPointerUp",eU.onPointerClick="onPointerClick",eU.onPointerEnter="onPointerEnter",eU.onPointerExit="onPointerExit",eU.onPointerBeginDrag="onPointerBeginDrag",eU.onPointerDrag="onPointerDrag",eU.onPointerEndDrag="onPointerEndDrag",eU.onPointerDrop="onPointerDrop",eU),o9=/*#__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}();o9._engineObjects={},o9._classNameMap=new Map;var o6=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t8(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.text=null},t}(na),o7=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t8(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.data=null},t}(na),se=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t8(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.buffer=null},t}(na),st=/*#__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}(),sn=/*#__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:st},e}();sn._components=[],sn._assemblerMap=new Map;var sr=/*#__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}();sn.registerAssembler(rU,"position",sr);var si=/*#__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}();sn.registerAssembler(rU,"rotationQuaternion",si);var sa=/*#__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}();sn.registerAssembler(rU,"scale",sa);var so=/*#__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}();sn.registerAssembler(a5,"blendShapeWeights",so);var ss=/*#__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}(),sl=/*#__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 sn(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 ss;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}(),sc=function(){},su=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n._curveBindings=[],n._updateFlagManager=new n3,n._length=0,n._events=[],n}t8(t,e);var n=t.prototype;return n.addEvent=function(e,t,n){if("string"==typeof e){var r,i=new sc;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 sl;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=sn._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)}}}},t3(t,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),t}(na),sd=((ez={})[ez.Linear=0]="Linear",ez[ez.CubicSpine=1]="CubicSpine",ez[ez.Step=2]="Step",ez[ez.Hermite=3]="Hermite",ez),sh=/*#__PURE__*/function(){function e(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var e=this.constructor;this._interpolation=e._supportInterpolationMode?sd.Linear:sd.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 sd.Linear:n=this._type._lerpValue(l.value,c.value,h,t.value);break;case sd.Step:n=this._type._setValue(l.value,t.value);break;case sd.CubicSpine:case sd.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)},t3(e,[{key:"interpolation",get:function(){return this._interpolation},set:function(e){this._type._supportInterpolationMode||e===sd.Step?this._interpolation=e:(this._interpolation=sd.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),e}(),s_=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=[],t}return t8(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}(sh);s_._isCopyMode=!0,s_._supportInterpolationMode=!0,s_=t9([nV()],s_);var sf=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=!1,t}return t8(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}(sh);sf._isCopyMode=!1,sf._supportInterpolationMode=!1,sf=t9([nV()],sf);var sp=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tZ,t}return t8(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._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._additiveValue=function(e,t,n){return tZ.scale(e,t,e),tZ.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}(sh);sp._isCopyMode=!0,sp._supportInterpolationMode=!0,sp=t9([nV()],sp);var sm=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return t8(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}(sh);sm._isCopyMode=!0,sm._supportInterpolationMode=!0,sm=t9([nV()],sm);var sg=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=0,t}return t8(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}(sh);sg._isCopyMode=!1,sg._supportInterpolationMode=!0,sg=t9([nV()],sg);var sv=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tj,t}return t8(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.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 tj.conjugate(n,i),tj.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}(sh);sv._supportInterpolationMode=!0,sv._isCopyMode=!0,sv._tempConjugateQuat=new tj,sv=t9([nV()],sv);var sy=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tQ,t}return t8(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}(sh);sy._isCopyMode=!0,sy._supportInterpolationMode=!0,sy=t9([nV()],sy);var sx=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tk,t}return t8(t,e),t._initializeOwner=function(e){e.defaultValue=new tk,e.fixedPoseValue=new tk,e.baseEvaluateData.value=new tk,e.crossEvaluateData.value=new tk},t._initializeLayerOwner=function(e){e.finalValue=new tk},t._lerpValue=function(e,t,n,r){return tk.lerp(e,t,n,r),r},t._relativeBaseValue=function(e,t){return tk.subtract(t,e,t),t},t._additiveValue=function(e,t,n){return tk.scale(e,t,e),tk.add(n,e,n),n},t._subtractValue=function(e,t,n){return tk.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}(sh);sx._isCopyMode=!0,sx._supportInterpolationMode=!0,sx=t9([nV()],sx);var sA=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tq,t}return t8(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,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}(sh);sA._isCopyMode=!0,sA._supportInterpolationMode=!0,sA=t9([nV()],sA);var sb=/*#__PURE__*/function(e){function t(){return e.call(this)||this}return t8(t,e),t._initializeOwner=function(e){},t._initializeLayerOwner=function(e){},t._setValue=function(e){return e},t}(sh);sb._isCopyMode=!1,sb._supportInterpolationMode=!1,sb=t9([nV()],sb);var sS=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tJ,t}return t8(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._setValue=function(e,t){return t.copyFrom(e),t},t}(sh);sS._isCopyMode=!0,sS._supportInterpolationMode=!1,sS=t9([nV()],sS);var sT=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value="",t}return t8(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}(sh);sT._isCopyMode=!1,sT._supportInterpolationMode=!1,sT=t9([nV()],sT);var sC=((eG={})[eG.If=0]="If",eG[eG.IfNot=1]="IfNot",eG[eG.Greater=2]="Greater",eG[eG.Less=3]="Less",eG[eG.Equals=4]="Equals",eG[eG.NotEquals=5]="NotEquals",eG),sR=((eH={})[eH.None=0]="None",eH[eH.Complete=1]="Complete",eH),sE=((eX={})[eX.Override=0]="Override",eX[eX.Additive=1]="Additive",eX),sM=((eW={})[eW.UnStarted=0]="UnStarted",eW[eW.Playing=1]="Playing",eW[eW.Finished=2]="Finished",eW),sP=((ej={})[ej.Standby=0]="Standby",ej[ej.Playing=1]="Playing",ej[ej.CrossFading=2]="CrossFading",ej[ej.FixedCrossFading=3]="FixedCrossFading",ej[ej.Finished=4]="Finished",ej),sw=/*#__PURE__*/function(){function e(){this.handlers=[]}return e.prototype.dispose=function(){},e}(),sF=function(){},sD=/*#__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 sF;return r.parameterName=e,r.mode=null!=t?t:sC.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()},t3(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}(),sB=((eY={})[eY.Once=0]="Once",eY[eY.Loop=1]="Loop",eY),sL=/*#__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=sM.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=sM.Playing,t.wrapMode===sB.Loop?n=r?n%r:0:Math.abs(n)>=r&&(n=n<0?-r:r,this.playState=sM.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}(),sI=/*#__PURE__*/function(){function e(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new sL,this.destPlayData=new sL,this.layerState=sP.Standby,this.crossCurveMark=0,this.manuallyTransition=new sD,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}(),sN=function(){this.curveLayerOwner=[],this.eventHandlers=[]},sO=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).cullingMode=sR.None,n.speed=1,n._playFrameCount=-1,n._onUpdateIndex=-1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new oT(sw),n._parametersValueMap=Object.create(null),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n}t8(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===sR.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(au,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,t,n){var r=e._animatorController;r&&(e._addResourceReferCount(r,1),e._controllerUpdateFlag=r._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 sN,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=sn._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,nA.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(o8,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 sI).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===sE.Additive;switch(0===e.layerIndex&&(i=1),e.layerState){case sP.Standby:this._checkAnyAndEntryState(e,t,n);break;case sP.Playing:this._updatePlayingState(e,i,a,t,n);break;case sP.Finished:this._updateFinishedState(e,i,a,t,n);break;case sP.CrossFading:this._updateCrossFadeState(e,i,a,t,n);break;case sP.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===sM.Finished&&(e.layerState=sP.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===sM.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 T=Math.abs(s.playedTime)/h;(T>=1-tV.zeroTolerance||0===h)&&(T=1);var C=1===T;if(C?(o.playState=sM.Finished,this._preparePlayOwner(e,d),this._evaluatePlayingState(s,t,n,i)):this._evaluateCrossFadeState(e,o,s,t,T,n,i),this._fireAnimationEventsAndCallScripts(l,o,u,m,g,S),this._fireAnimationEventsAndCallScripts(l,s,d,v,y,a),C){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===sM.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-tV.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===sM.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===sM.Finished?e.layerState=sP.Finished:e.layerState=sP.Playing,e.switchPlayData(),e.crossFadeTransition=null},n._preparePlayOwner=function(e,t){if(e.layerState===sP.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 nA.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=sP.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 sC.Equals:d===u&&(o=!0);break;case sC.Greater:d>u&&(o=!0);break;case sC.Less:d<u&&(o=!0);break;case sC.NotEquals:d!==u&&(o=!0);break;case sC.If:!0===d&&(o=!0);break;case sC.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 nA.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 sP.Standby:case sP.Finished:r.layerState=sP.FixedCrossFading,this._clearCrossData(r),this._prepareStandbyCrossFading(r);break;case sP.Playing:r.layerState=sP.CrossFading,this._clearCrossData(r),this._prepareCrossFading(r);break;case sP.CrossFading:r.layerState=sP.FixedCrossFading,this._prepareFixedPoseCrossFading(r);break;case sP.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===sM.UnStarted&&n._callOnEnter(this,e),i!==sM.Finished&&t.playState===sM.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},t3(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}(rL);sO._passedTriggerParameterNames=[],t9([nt],sO.prototype,"speed",void 0),t9([nt],sO.prototype,"_animatorController",void 0),t9([ne],sO.prototype,"_controllerUpdateFlag",void 0),t9([ne],sO.prototype,"_updateMark",void 0),t9([ne],sO.prototype,"_animatorLayersData",void 0),t9([ne],sO.prototype,"_curveOwnerPool",void 0),t9([ne],sO.prototype,"_animationEventHandlerPool",void 0),t9([ne],sO.prototype,"_parametersValueMap",void 0),t9([ne],sO.prototype,"_tempAnimatorStateInfo",void 0),t9([ne],sO.prototype,"_controlledRenderers",void 0);var sV=/*#__PURE__*/function(){function e(){this._onNameChanged=null,this._isTrigger=!1}return t3(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}(),sk=/*#__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 n3),function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}t8(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(rk)},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 sV;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},t3(t,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),t}(no),sU=/*#__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 t6(e,sG)?((t=new sD).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)}},t3(e,[{key:"isSoloMode",get:function(){return this._soloCount>0}},{key:"count",get:function(){return this.transitions.length}}]),e}(),sz=/*#__PURE__*/function(e){function t(){return e.call(this,null)||this}t8(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}(na),sG=/*#__PURE__*/function(){function e(e){this.name=e,this.speed=1,this.wrapMode=sB.Loop,this._updateFlagManager=new n3,this._transitionCollection=new sU,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 sD;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=sz.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=sz.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},t3(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}(),sH=/*#__PURE__*/function(){function e(){this.states=[],this._entryTransitionCollection=new sU,this._anyStateTransitionCollection=new sU,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 sG(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)},t3(e,[{key:"entryTransitions",get:function(){return this._entryTransitionCollection.transitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitionCollection.transitions}}]),e}(),sX=/*#__PURE__*/function(){function e(e){this.name=e,this.weight=1,this.blendingMode=sE.Override,this.stateMachine=new sH}return e.prototype._setEngine=function(e){this.stateMachine._setEngine(e)},e}(),sW=function(){},sj=function(){},sY=/*#__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 sj;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)}},t3(e,[{key:"pathMasks",get:function(){return this._pathMasks}}]),e}(),sK=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,rE.find("skybox"))||this)._textureDecodeRGBM=!1,r._tintColor=new tZ(1,1,1,1),r.renderState.rasterState.cullMode=rt.Off,r.renderState.depthState.compareFunction=re.LessEqual,r.shaderData.setFloat(t._rotationProp,0),r.shaderData.setFloat(t._exposureProp,1),r.shaderData.setColor(t._tintColorProp,r._tintColor),r}return t8(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t3(t,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(t._decodeSkyRGBMMacro):this.shaderData.disableMacro(t._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(t._textureCubeProp)},set:function(e){this.shaderData.setTexture(t._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(t._rotationProp)},set:function(e){this.shaderData.setFloat(t._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(t._exposureProp)},set:function(e){this.shaderData.setFloat(t._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),t}(r1);sK._tintColorProp=nG.getByName("material_TintColor"),sK._textureCubeProp=nG.getByName("material_CubeTexture"),sK._rotationProp=nG.getByName("material_Rotation"),sK._exposureProp=nG.getByName("material_Exposure"),sK._decodeSkyRGBMMacro=rl.getByName("MATERIAL_IS_DECODE_SKY_RGBM");var sQ=((eK={})[eK.None=0]="None",eK[eK.Simple=1]="Simple",eK[eK.HighQuality=2]="HighQuality",eK),sq=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,rE.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new tZ(.21404114048223255,.21404114048223255,.21404114048223255,1),n.groundTint=new tZ(.11216882039252905,.09988709277986121,.09520561068319185,1),n.exposure=1.3,n.renderState.rasterState.cullMode=rt.Off,n.renderState.depthState.compareFunction=re.LessEqual,n}return t8(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t3(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}(r1);sq._sunSizeProp=nG.getByName("material_SunSize"),sq._sunSizeConvergenceProp=nG.getByName("material_SunSizeConvergence"),sq._atmosphereThicknessProp=nG.getByName("material_AtmosphereThickness"),sq._skyTintProp=nG.getByName("material_SkyTint"),sq._groundTintProp=nG.getByName("material_GroundTint"),sq._exposureProp=nG.getByName("material_Exposure"),sq._sunHighQualityMacro=rl.getByName("MATERIAL_SUN_HIGH_QUALITY"),sq._sunSimpleMacro=rl.getByName("MATERIAL_SUN_SIMPLE");var sZ=((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),sJ=((eq={})[eq.Local=0]="Local",eq[eq.World=1]="World",eq),s$=((eZ={})[eZ.StopEmittingAndClear=0]="StopEmittingAndClear",eZ[eZ.StopEmitting=1]="StopEmitting",eZ),s0=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).velocityScale=0,r.lengthScale=2,r.pivot=new tk,r._generatorBounds=new tz,r._transformedBounds=new tz,r._onGeneratorParamsChanged=r._onGeneratorParamsChanged.bind(r),r.generator=new lh(r),r._currentRenderModeMacro=t._billboardModeMacro,r.shaderData.enableMacro(t._billboardModeMacro),r._supportInstancedArrays=r.engine._hardwareRenderer.canIUse(nT.instancedArrays),r._onGeneratorParamsChanged(),r}t8(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,s$.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===sJ.Local?t._updateBoundsSimulationLocal(e):(this._isContainDirtyFlag(2)&&(t._generateTransformedBounds(),this._setDirtyFlagFalse(2)),t._updateBoundsSimulationWorld(e))},n._update=function(e){var n=this.generator;if(n._update(this.engine.time.deltaTime),n._firstActiveElement!==n._firstFreeElement){var r=this.shaderData;r.setFloat(t._lengthScale,this.lengthScale),r.setFloat(t._speedScale,this.velocityScale),r.setFloat(t._currentTime,this.generator._playTime),r.setVector3(t._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(r)}},n._render=function(e){var t=this.generator,n=t._getAliveParticleCount();if(n){t._primitive.instanceCount=n;var r=this.getMaterial();if(r&&(this._renderMode!==sZ.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|=ad.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|ad.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|ad.WorldVolume},t3(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 sZ.Billboard:r=t._billboardModeMacro;break;case sZ.StretchBillboard:r=t._stretchedBillboardModeMacro;break;case sZ.HorizontalBillboard:case sZ.VerticalBillboard:throw"Not implemented";case sZ.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===sZ.Mesh,o=e===sZ.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&&nA.error("Particle emit mesh must have only one sub mesh."),this._addResourceReferCount(e,1),this.renderMode===sZ.Mesh&&this.generator._reorganizeGeometryBuffers()))}}]),t}(au);s0._billboardModeMacro=rl.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),s0._stretchedBillboardModeMacro=rl.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),s0._horizontalBillboardModeMacro=rl.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),s0._verticalBillboardModeMacro=rl.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),s0._meshModeMacro=rl.getByName("RENDERER_MODE_MESH"),s0._pivotOffsetProperty=nG.getByName("renderer_PivotOffset"),s0._lengthScale=nG.getByName("renderer_StretchedBillboardLengthScale"),s0._speedScale=nG.getByName("renderer_StretchedBillboardSpeedScale"),s0._currentTime=nG.getByName("renderer_CurrentTime"),t9([nr],s0.prototype,"generator",void 0),t9([nn],s0.prototype,"pivot",void 0),t9([ne],s0.prototype,"_generatorBounds",void 0),t9([ne],s0.prototype,"_transformedBounds",void 0),t9([ne],s0.prototype,"_onGeneratorParamsChanged",null),t9([ne],s0.prototype,"_onTransformChanged",null);var s1=((eJ={})[eJ.TransformVolume=2]="TransformVolume",eJ[eJ.GeneratorVolume=4]="GeneratorVolume",eJ),s2=((e$={})[e$.Constant=0]="Constant",e$[e$.TwoConstants=1]="TwoConstants",e$[e$.Curve=2]="Curve",e$[e$.TwoCurves=3]="TwoCurves",e$),s3=((e0={})[e0.Constant=0]="Constant",e0[e0.TwoConstants=1]="TwoConstants",e0[e0.Gradient=2]="Gradient",e0[e0.TwoGradients=3]="TwoGradients",e0),s4=((e1={})[e1.Burst=0x23571a3e]="Burst",e1[e1.StartDelay=0x13371337]="StartDelay",e1[e1.StartColor=0x12460f3b]="StartColor",e1[e1.StartSize=0x6aed452e]="StartSize",e1[e1.StartRotation=0xdec4aea1]="StartRotation",e1[e1.randomizeRotationDirection=0x96aa4de3]="randomizeRotationDirection",e1[e1.StartLifetime=0x8d2c8431]="StartLifetime",e1[e1.StartSpeed=0xf3857f6f]="StartSpeed",e1[e1.VelocityOverLifetime=0xe0fbd834]="VelocityOverLifetime",e1[e1.ColorOverLifetime=0x13740583]="ColorOverLifetime",e1[e1.SizeOverLifetime=0x591bc05c]="SizeOverLifetime",e1[e1.RotationOverLifetime=0x40eb95e4]="RotationOverLifetime",e1[e1.TextureSheetAnimation=0xbc524e5]="TextureSheetAnimation",e1[e1.Shape=0xaf502044]="Shape",e1[e1.GravityModifier=0xa47b8c4d]="GravityModifier",e1[e1.ForceOverLifetime=0xe6fb937c]="ForceOverLifetime",e1),s8=/*#__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 s5(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 s9(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},t3(e,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),e}();t9([nr],s8.prototype,"_colorKeys",void 0),t9([nr],s8.prototype,"_alphaKeys",void 0),t9([ne],s8.prototype,"_colorTypeArray",void 0),t9([ne],s8.prototype,"_alphaTypeArray",void 0),t9([ne],s8.prototype,"_setColorTypeArrayDirty",null),t9([ne],s8.prototype,"_setAlphaTypeArrayDirty",null);var s5=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._color=new tZ,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged}return t3(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}(),s9=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._time=e,this._alpha=t}return t3(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}(),s6=/*#__PURE__*/function(){function e(e,t){this.mode=s3.Constant,this.constantMin=new tZ,this.constantMax=new tZ,this.gradientMin=new s8,this.gradientMax=new s8,e.constructor===tZ?t?(this.constantMin.copyFrom(e),this.constantMax.copyFrom(t),this.mode=s3.TwoConstants):(this.constant.copyFrom(e),this.mode=s3.Constant):t?(this.gradientMin=e,this.gradientMax=t,this.mode=s3.TwoGradients):(this.gradient=e,this.mode=s3.Gradient)}return e.prototype.evaluate=function(e,t,n){switch(this.mode){case s3.Constant:n.copyFrom(this.constant);break;case s3.TwoConstants:tZ.lerp(this.constantMin,this.constantMax,t,n)}},t3(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}();t9([nr],s6.prototype,"constantMin",void 0),t9([nr],s6.prototype,"constantMax",void 0),t9([nr],s6.prototype,"gradientMin",void 0),t9([nr],s6.prototype,"gradientMax",void 0);var s7=/*#__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()},t3(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),e}();t9([ne],s7.prototype,"_generator",void 0);var le=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.color=new s6(new s8([new s5(0,new tZ(1,1,1)),new s5(1,new tZ(1,1,1))],[new s9(0,1),new s9(1,1)])),t._colorGradientRand=new t0(0,s4.ColorOverLifetime),t._gradientKeysCount=new tq(0,0,0,0),t}t8(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.color.mode;if(r!==s3.Gradient&&r!==s3.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===s3.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,s4.ColorOverLifetime)},t}(s7);le._gradientMacro=rl.getByName("RENDERER_COL_GRADIENT"),le._randomGradientsMacro=rl.getByName("RENDERER_COL_RANDOM_GRADIENTS"),le._minGradientColor=nG.getByName("renderer_COLMinGradientColor"),le._minGradientAlpha=nG.getByName("renderer_COLMinGradientAlpha"),le._maxGradientColor=nG.getByName("renderer_COLMaxGradientColor"),le._maxGradientAlpha=nG.getByName("renderer_COLMaxGradientAlpha"),le._gradientKeysCount=nG.getByName("renderer_COLGradientKeysMaxTime"),t9([nr],le.prototype,"color",void 0),t9([ne],le.prototype,"_colorGradientRand",void 0),t9([ne],le.prototype,"_gradientKeysCount",void 0),t9([ne],le.prototype,"_colorMacro",void 0);var lt=/*#__PURE__*/function(){function e(e,t){this._updateManager=new n3,this._mode=s2.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=s2.TwoConstants):(this.constant=e,this.mode=s2.Constant):t?(this.curveMin=e,this.curveMax=t,this.mode=s2.TwoCurves):(this.curve=e,this.mode=s2.Curve)}var t=e.prototype;return t.evaluate=function(e,t){switch(this.mode){case s2.Constant:return this.constant;case s2.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*t;case s2.Curve:var n;return null==(n=this.curve)?void 0:n._evaluate(e);case s2.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 s2.Constant:return this.constantMax;case s2.TwoConstants:return Math.max(this.constantMin,this.constantMax);case s2.Curve:var e;return this._getMaxKeyValue(null==(e=this.curveMax)?void 0:e.keys);case s2.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 s2.Constant:e.x=e.y=this.constantMax;break;case s2.TwoConstants:e.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case s2.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 s2.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()},t3(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}();t9([ne],lt.prototype,"_updateManager",void 0),t9([nr],lt.prototype,"_curveMin",void 0),t9([nr],lt.prototype,"_curveMax",void 0),t9([ne],lt.prototype,"_updateDispatch",void 0);var ln=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.rateOverTime=new lt(10),t.rateOverDistance=new lt(0),t._shapeRand=new t0(0,s4.Shape),t._frameRateTime=0,t._bursts=[],t._currentBurstIndex=0,t._burstRand=new t0(0,s4.Burst),t}t8(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,s4.Burst),this._shapeRand.reset(e,s4.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},t3(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}(s7);ln._emissionShapeMacro=rl.getByName("RENDERER_EMISSION_SHAPE"),t9([nr],ln.prototype,"rateOverTime",void 0),t9([nr],ln.prototype,"rateOverDistance",void 0),t9([nr],ln.prototype,"_shape",void 0),t9([ne],ln.prototype,"_shapeRand",void 0),t9([nr],ln.prototype,"_bursts",void 0),t9([ne],ln.prototype,"_burstRand",void 0);var lr=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._forceRand=new t0(0,s4.ForceOverLifetime),n._forceMinConstant=new tk,n._forceMaxConstant=new tk,n._space=sJ.Local,n.forceX=new lt(0),n.forceY=new lt(0),n.forceZ=new lt(0),n}t8(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===s2.TwoCurves&&a.mode===s2.TwoCurves&&o.mode===s2.TwoCurves;if(s||i.mode===s2.Curve&&a.mode===s2.Curve&&o.mode===s2.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===s2.TwoConstants&&a.mode===s2.TwoConstants&&o.mode===s2.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,s4.ForceOverLifetime)},n._isRandomMode=function(){var e=this.forceX.mode,t=this.forceY.mode,n=this.forceZ.mode;return e===s2.TwoCurves&&t===s2.TwoCurves&&n===s2.TwoCurves||e===s2.TwoConstants&&t===s2.TwoConstants&&n===s2.TwoConstants},t3(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}(s7);lr._constantModeMacro=rl.getByName("RENDERER_FOL_CONSTANT_MODE"),lr._curveModeMacro=rl.getByName("RENDERER_FOL_CURVE_MODE"),lr._isRandomMacro=rl.getByName("RENDERER_FOL_IS_RANDOM_TWO"),lr._minConstantProperty=nG.getByName("renderer_FOLMinConst"),lr._maxConstantProperty=nG.getByName("renderer_FOLMaxConst"),lr._minGradientXProperty=nG.getByName("renderer_FOLMinGradientX"),lr._minGradientYProperty=nG.getByName("renderer_FOLMinGradientY"),lr._minGradientZProperty=nG.getByName("renderer_FOLMinGradientZ"),lr._maxGradientXProperty=nG.getByName("renderer_FOLMaxGradientX"),lr._maxGradientYProperty=nG.getByName("renderer_FOLMaxGradientY"),lr._maxGradientZProperty=nG.getByName("renderer_FOLMaxGradientZ"),lr._spaceProperty=nG.getByName("renderer_FOLSpace"),t9([ne],lr.prototype,"_forceRand",void 0),t9([ne],lr.prototype,"_forceMinConstant",void 0),t9([ne],lr.prototype,"_forceMaxConstant",void 0),t9([ne],lr.prototype,"_forceMacro",void 0),t9([ne],lr.prototype,"_randomModeMacro",void 0),t9([nr],lr.prototype,"_forceX",void 0),t9([nr],lr.prototype,"_forceY",void 0),t9([nr],lr.prototype,"_forceZ",void 0);var li=((e2={})[e2.Hierarchy=0]="Hierarchy",e2[e2.Local=1]="Local",e2[e2.World=2]="World",e2),la=/*#__PURE__*/function(){function e(e){this._tempVector40=new tq,this.duration=5,this.isLoop=!0,this.startDelay=new lt(0),this.startRotation3D=!1,this.startRotationX=new lt(0),this.startRotationY=new lt(0),this.startRotationZ=new lt(0),this.flipRotation=0,this.startColor=new s6(new tZ(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=li.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startDelayRand=new t0(0,s4.StartDelay),this._startSpeedRand=new t0(0,s4.StartSpeed),this._startLifeTimeRand=new t0(0,s4.StartLifetime),this._startColorRand=new t0(0,s4.StartColor),this._startSizeRand=new t0(0,s4.StartSize),this._startRotationRand=new t0(0,s4.StartRotation),this._gravityModifierRand=new t0(0,s4.GravityModifier),this._startSize3D=!1,this._simulationSpace=sJ.Local,this._generator=e,this.startLifetime=new lt(5),this.startSpeed=new lt(5),this.startSizeX=new lt(1),this.startSizeY=new lt(1),this.startSizeZ=new lt(1),this.gravityModifier=new lt(0)}var t=e.prototype;return t._resetRandomSeed=function(e){this._startSpeedRand.reset(e,s4.StartSpeed),this._startLifeTimeRand.reset(e,s4.StartLifetime),this._startColorRand.reset(e,s4.StartColor),this._startSizeRand.reset(e,s4.StartSize),this._startRotationRand.reset(e,s4.StartRotation)},t._getPositionScale=function(){var e=this._generator._renderer.entity.transform;switch(this.scalingMode){case li.Hierarchy:case li.World:return e.lossyWorldScale;case li.Local:return e.scale}},t._updateShaderData=function(t){var n=this._generator._renderer,r=n.entity.transform;switch(this.simulationSpace){case sJ.Local:t.setVector3(e._worldPosition,r.worldPosition);var i=r.worldRotationQuaternion,a=this._tempVector40.copyFrom(i);t.setVector4(e._worldRotation,a);break;case sJ.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case li.Hierarchy:var o=r.lossyWorldScale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case li.Local:var o=r.scale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case li.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===sJ.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()},t3(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(rz.WorldMatrix),e===sJ.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}();la._vector3One=new tk(1,1,1),la._positionScale=nG.getByName("renderer_PositionScale"),la._sizeScale=nG.getByName("renderer_SizeScale"),la._worldPosition=nG.getByName("renderer_WorldPosition"),la._worldRotation=nG.getByName("renderer_WorldRotation"),la._gravity=nG.getByName("renderer_Gravity"),la._simulationSpace=nG.getByName("renderer_SimulationSpace"),la._startRotation3D=nG.getByName("renderer_ThreeDStartRotation"),la._scaleMode=nG.getByName("renderer_ScalingMode"),t9([nr],la.prototype,"startDelay",void 0),t9([nr],la.prototype,"startRotationX",void 0),t9([nr],la.prototype,"startRotationY",void 0),t9([nr],la.prototype,"startRotationZ",void 0),t9([nr],la.prototype,"startColor",void 0),t9([ne],la.prototype,"_maxParticleBuffer",void 0),t9([ne],la.prototype,"_startDelayRand",void 0),t9([ne],la.prototype,"_startSpeedRand",void 0),t9([ne],la.prototype,"_startLifeTimeRand",void 0),t9([ne],la.prototype,"_startColorRand",void 0),t9([ne],la.prototype,"_startSizeRand",void 0),t9([ne],la.prototype,"_startRotationRand",void 0),t9([ne],la.prototype,"_gravityModifierRand",void 0),t9([nr],la.prototype,"_startLifetime",void 0),t9([nr],la.prototype,"_startSpeed",void 0),t9([nr],la.prototype,"_startSizeX",void 0),t9([nr],la.prototype,"_startSizeY",void 0),t9([nr],la.prototype,"_startSizeZ",void 0),t9([nr],la.prototype,"_gravityModifier",void 0),t9([ne],la.prototype,"_generator",void 0);var lo=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new lt(0),t.rotationY=new lt(0),t.rotationZ=new lt(45),t._rotationRand=new t0(0,s4.RotationOverLifetime),t._rotationMinConstant=new tk,t._rotationMaxConstant=new tk,t}t8(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===s2.TwoCurves&&o.mode===s2.TwoCurves&&s.mode===s2.TwoCurves:s.mode===s2.TwoCurves;if(c||l?a.mode===s2.Curve&&o.mode===s2.Curve&&s.mode===s2.Curve:s.mode===s2.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(tV.degreeToRadian(a.constantMax),tV.degreeToRadian(o.constantMax),tV.degreeToRadian(s.constantMax)),e.setVector3(t._maxConstantProperty,u),l?a.mode===s2.TwoConstants&&o.mode===s2.TwoConstants&&s.mode===s2.TwoConstants:s.mode===s2.TwoConstants){var d=this._rotationMinConstant;d.set(tV.degreeToRadian(a.constantMin),tV.degreeToRadian(o.constantMin),tV.degreeToRadian(s.constantMin)),e.setVector3(t._minConstantProperty,d),i=t._isRandomTwoMacro}r=t._constantModeMacro}l&&(n=t._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,n),this._modeMacro=this._enableMacro(e,this._modeMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,i)},n._resetRandomSeed=function(e){this._rotationRand.reset(e,s4.RotationOverLifetime)},t}(s7);lo._constantModeMacro=rl.getByName("RENDERER_ROL_CONSTANT_MODE"),lo._curveModeMacro=rl.getByName("RENDERER_ROL_CURVE_MODE"),lo._isSeparateMacro=rl.getByName("RENDERER_ROL_IS_SEPARATE"),lo._isRandomTwoMacro=rl.getByName("RENDERER_ROL_IS_RANDOM_TWO"),lo._minConstantProperty=nG.getByName("renderer_ROLMinConst"),lo._minCurveXProperty=nG.getByName("renderer_ROLMinCurveX"),lo._minCurveYProperty=nG.getByName("renderer_ROLMinCurveY"),lo._minCurveZProperty=nG.getByName("renderer_ROLMinCurveZ"),lo._maxConstantProperty=nG.getByName("renderer_ROLMaxConst"),lo._maxCurveXProperty=nG.getByName("renderer_ROLMaxCurveX"),lo._maxCurveYProperty=nG.getByName("renderer_ROLMaxCurveY"),lo._maxCurveZProperty=nG.getByName("renderer_ROLMaxCurveZ"),t9([nr],lo.prototype,"rotationX",void 0),t9([nr],lo.prototype,"rotationY",void 0),t9([nr],lo.prototype,"rotationZ",void 0),t9([ne],lo.prototype,"_rotationRand",void 0),t9([ne],lo.prototype,"_rotationMinConstant",void 0),t9([ne],lo.prototype,"_rotationMaxConstant",void 0),t9([ne],lo.prototype,"_enableSeparateMacro",void 0),t9([ne],lo.prototype,"_modeMacro",void 0),t9([ne],lo.prototype,"_isRandomTwoMacro",void 0);var ls=/*#__PURE__*/function(){function e(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._updateManager=new n3,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 ll(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)}},t3(e,[{key:"keys",get:function(){return this._keys}}]),e}();t9([ne],ls.prototype,"_updateManager",void 0),t9([nr],ls.prototype,"_keys",void 0),t9([ne],ls.prototype,"_typeArray",void 0),t9([ne],ls.prototype,"_updateDispatch",void 0);var ll=/*#__PURE__*/function(){function e(e,t){this._updateManager=new n3,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)},t3(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}();t9([ne],ll.prototype,"_updateManager",void 0);var lc=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._separateAxes=!1,n.sizeX=new lt(new ls(new ll(0,0),new ll(1,1))),n.sizeY=new lt(new ls(new ll(0,0),new ll(1,1))),n.sizeZ=new lt(new ls(new ll(0,0),new ll(1,1))),n}return t8(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===s2.TwoCurves&&o.mode===s2.TwoCurves&&s.mode===s2.TwoCurves:a.mode===s2.TwoCurves;(c||l?a.mode===s2.Curve&&o.mode===s2.Curve&&s.mode===s2.Curve:a.mode===s2.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)},t3(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}(s7);lc._curveModeMacro=rl.getByName("RENDERER_SOL_CURVE_MODE"),lc._isSeparateMacro=rl.getByName("RENDERER_SOL_IS_SEPARATE"),lc._isRandomTwoMacro=rl.getByName("RENDERER_SOL_IS_RANDOM_TWO"),lc._minCurveXProperty=nG.getByName("renderer_SOLMinCurveX"),lc._minCurveYProperty=nG.getByName("renderer_SOLMinCurveY"),lc._minCurveZProperty=nG.getByName("renderer_SOLMinCurveZ"),lc._maxCurveXProperty=nG.getByName("renderer_SOLMaxCurveX"),lc._maxCurveYProperty=nG.getByName("renderer_SOLMaxCurveY"),lc._maxCurveZProperty=nG.getByName("renderer_SOLMaxCurveZ"),t9([nr],lc.prototype,"_sizeX",void 0),t9([nr],lc.prototype,"_sizeY",void 0),t9([nr],lc.prototype,"_sizeZ",void 0),t9([ne],lc.prototype,"_enableSeparateMacro",void 0),t9([ne],lc.prototype,"_isCurveMacro",void 0),t9([ne],lc.prototype,"_isRandomTwoMacro",void 0);var lu=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).frameOverTime=new lt(new ls(new ll(0,0),new ll(1,1))),n.type=0,n.cycleCount=1,n._tillingInfo=new tk(1,1,1),n._frameOverTimeRand=new t0(0,s4.TextureSheetAnimation),n._tiling=new tQ(1,1),n._tiling._onValueChanged=n._onTilingChanged.bind(n),n}t8(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.frameOverTime.mode;if(r===s2.Curve||r===s2.TwoCurves){var i=this.frameOverTime;e.setFloatArray(t._frameMaxCurveProperty,i.curveMax._getTypeArray()),r===s2.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,s4.TextureSheetAnimation)},n._onTilingChanged=function(){var e=this.tiling;this._tillingInfo.set(1/e.x,1/e.y,e.x*e.y)},t3(t,[{key:"tiling",get:function(){return this._tiling},set:function(e){e!==this._tiling&&this._tiling.copyFrom(e)}}]),t}(s7);lu._frameCurveMacro=rl.getByName("RENDERER_TSA_FRAME_CURVE"),lu._frameRandomCurvesMacro=rl.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),lu._frameMinCurveProperty=nG.getByName("renderer_TSAFrameMinCurve"),lu._frameMaxCurveProperty=nG.getByName("renderer_TSAFrameMaxCurve"),lu._cycleCountProperty=nG.getByName("renderer_TSACycles"),lu._tillingParamsProperty=nG.getByName("renderer_TSATillingParams"),t9([nr],lu.prototype,"frameOverTime",void 0),t9([nn],lu.prototype,"_tillingInfo",void 0),t9([ne],lu.prototype,"_frameOverTimeRand",void 0),t9([nr],lu.prototype,"_tiling",void 0),t9([ne],lu.prototype,"_frameCurveMacro",void 0),t9([ne],lu.prototype,"_onTilingChanged",null);var ld=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._velocityRand=new t0(0,s4.VelocityOverLifetime),n._velocityMinConstant=new tk,n._velocityMaxConstant=new tk,n._space=sJ.Local,n.velocityX=new lt(0),n.velocityY=new lt(0),n.velocityZ=new lt(0),n}t8(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===s2.TwoCurves&&a.mode===s2.TwoCurves&&o.mode===s2.TwoCurves;if(s||i.mode===s2.Curve&&a.mode===s2.Curve&&o.mode===s2.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===s2.TwoConstants&&a.mode===s2.TwoConstants&&o.mode===s2.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,s4.VelocityOverLifetime)},t3(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}(s7);ld._constantModeMacro=rl.getByName("RENDERER_VOL_CONSTANT_MODE"),ld._curveModeMacro=rl.getByName("RENDERER_VOL_CURVE_MODE"),ld._isRandomMacro=rl.getByName("RENDERER_VOL_IS_RANDOM_TWO"),ld._minConstantProperty=nG.getByName("renderer_VOLMinConst"),ld._maxConstantProperty=nG.getByName("renderer_VOLMaxConst"),ld._minGradientXProperty=nG.getByName("renderer_VOLMinGradientX"),ld._minGradientYProperty=nG.getByName("renderer_VOLMinGradientY"),ld._minGradientZProperty=nG.getByName("renderer_VOLMinGradientZ"),ld._maxGradientXProperty=nG.getByName("renderer_VOLMaxGradientX"),ld._maxGradientYProperty=nG.getByName("renderer_VOLMaxGradientY"),ld._maxGradientZProperty=nG.getByName("renderer_VOLMaxGradientZ"),ld._spaceProperty=nG.getByName("renderer_VOLSpace"),t9([ne],ld.prototype,"_velocityRand",void 0),t9([ne],ld.prototype,"_velocityMinConstant",void 0),t9([ne],ld.prototype,"_velocityMaxConstant",void 0),t9([ne],ld.prototype,"_velocityMacro",void 0),t9([ne],ld.prototype,"_randomModeMacro",void 0),t9([nr],ld.prototype,"_velocityX",void 0),t9([nr],ld.prototype,"_velocityY",void 0),t9([nr],ld.prototype,"_velocityZ",void 0);var lh=/*#__PURE__*/function(){function e(t){this.useAutoRandomSeed=!0,this.emission=new ln(this),this.rotationOverLifetime=new lo(this),this.colorOverLifetime=new le(this),this.textureSheetAnimation=new lu(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new aF(0,0,aT.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0,this._playStartDelay=0,this._renderer=t,new aw().start=0,this._primitive=new aD(t.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,e._particleIncreaseCount),this.main=new la(this),this.velocityOverLifetime=new ld(this),this.forceOverLifetime=new lr(this),this.sizeOverLifetime=new lc(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(s0,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=s$.StopEmitting),t)for(var r=this._renderer.entity.getComponentsIncludeChildren(s0,e._tempParticleRenderers),i=0,a=r.length;i<a;i++)r[i].generator.stop(!1,n);else if(this._isPlaying=!1,n===s$.StopEmittingAndClear){var o=this._firstFreeElement;this._firstRetiredElement=o,this._firstActiveElement=o,this._firstNewElement=o,this._playTime=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox,this.emission._reset()}},t.emit=function(e){this._emit(this._playTime,e)},t._emit=function(t,n){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===sJ.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===sJ.World&&this._retireTransformedBounds(),r.enabled&&this._isPlaying&&(this._currentParticleCount>n._maxParticleBuffer&&this._getNotRetiredParticleCount()<n._maxParticleBuffer&&this._resizeInstanceBuffer(!1),r._emit(a,this._playTime),!n.isLoop&&this._playTime>i&&(this._isPlaying=!1)),this.isAlive)n.simulationSpace===sJ.World&&this._generateTransformedBounds();else{var l=Math.min(r._frameRateTime,Math.floor(this._playTime/i)*i);this._playTime-=l,r._frameRateTime-=l}this.isAlive!==t&&this._renderer._onWorldVolumeChanged(),(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},t._reorganizeGeometryBuffers=function(){var e=this._renderer,t=this._primitive,n=this._vertexBufferBindings,r=e.engine._particleBufferUtils;if(t.clearVertexElements(),n.length=0,e.renderMode===sZ.Mesh){var i=e.mesh,a=i.getVertexElement(ak.Position),o=i.getVertexElement(ak.Color),s=i.getVertexElement(ak.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 ab(ak.Position,a.offset,a.format,d))}if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,n);t.addVertexElement(new ab(ak.Color,o.offset,o.format,h)),e.shaderData.enableMacro(aO._enableVertexColorMacro)}else e.shaderData.disableMacro(aO._enableVertexColorMacro);if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,n);t.addVertexElement(new ab(ak.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(aO._enableVertexColorMacro),t.addVertexElement(r.billboardVertexElement),n.push(r.billboardVertexBufferBinding),t.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=oO.billboardIndexCount;for(var m=r.instanceVertexElements,g=n.length,v=0,y=m.length;v<y;v++){var x=m[v];t.addVertexElement(new ab(x.attribute,x.offset,x.format,g,x.instanceStepRate))}this._instanceVertexBufferBinding&&n.push(this._instanceVertexBufferBinding),t.setVertexBufferBindings(n)},t._resizeInstanceBuffer=function(e,t){null==(u=this._instanceVertexBufferBinding)||u.buffer.destroy();var n=oO.instanceVertexStride,r=e?this._currentParticleCount+t:this.main._maxParticleBuffer,i=n*r,a=new av(this._renderer.engine,aS.VertexBuffer,i,am.Dynamic,!1);a.isGCIgnored=!0;var o=this._primitive.vertexBufferBindings,s=new aI(a,n),l=new Float32Array(i/4),c=this._instanceVertices;if(c){var u,d,h,_=oO.instanceVertexFloatStride,f=this._firstFreeElement,p=this._firstRetiredElement;if(e){l.set(new Float32Array(c.buffer,0,f*_));var m=f+1;l.set(new Float32Array(c.buffer,m*_*4),(m+t)*_),this._firstNewElement>f&&(this._firstNewElement+=t),this._firstActiveElement>f&&(this._firstActiveElement+=t),p>f&&(this._firstRetiredElement+=t)}else p<=f?(d=f-p,h=0,this._firstFreeElement-=p,this._firstNewElement-=p,this._firstActiveElement-=p,this._firstRetiredElement=0):(d=this._currentParticleCount-p,h=f,this._firstNewElement>f&&(this._firstNewElement-=f),this._firstActiveElement>f&&(this._firstActiveElement-=f),p>f&&(this._firstRetiredElement-=f)),l.set(new Float32Array(c.buffer,p*_*4,d*_),h*_);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(c?o.length-1:o.length,s),this._instanceVertices=l,this._instanceVertexBufferBinding=s,this._currentParticleCount=r},t._updateShaderData=function(e){this.main._updateShaderData(e),this.velocityOverLifetime._updateShaderData(e),this.forceOverLifetime._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.rotationOverLifetime._resetRandomSeed(e),this.colorOverLifetime._resetRandomSeed(e)},t._getAliveParticleCount=function(){if(this._firstActiveElement<=this._firstFreeElement)return this._firstFreeElement-this._firstActiveElement;var e=this._currentParticleCount-this._firstActiveElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},t._getNotRetiredParticleCount=function(){if(this._firstRetiredElement<=this._firstFreeElement)return this._firstFreeElement-this._firstRetiredElement;var e=this._currentParticleCount-this._firstRetiredElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},t._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy(),this.emission._destroy()},t._updateBoundsSimulationLocal=function(e){var t=this._renderer,n=this.main.startLifetime._getMax(),r=t._generatorBounds,i=t._transformedBounds;t._isContainDirtyFlag(s1.GeneratorVolume)&&(this._calculateGeneratorBounds(n,r),t._setDirtyFlagFalse(s1.GeneratorVolume)),t._isContainDirtyFlag(s1.TransformVolume)&&(this._calculateTransformedBounds(n,r,i),t._setDirtyFlagFalse(s1.TransformVolume)),this._addGravityToBounds(n,i,e)},t._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,n=this._firstActiveTransformedBoundingBox,r=this._firstFreeTransformedBoundingBox,i=n*oO.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(s1.GeneratorVolume)&&(this._calculateGeneratorBounds(t,n),e._setDirtyFlagFalse(s1.GeneratorVolume));var r=oO.boundsFloatStride,i=oO.boundsTimeOffset,a=oO.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(s1.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(s1.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*oO.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===sJ.World&&(a=r.worldPosition,o=r.worldRotationQuaternion);var d=c.startSpeed.evaluate(void 0,c._startSpeedRand.random()),h=this._instanceVertices,_=s*oO.instanceVertexFloatStride;t.copyToArray(h,_),h[_+oO.startLifeTimeOffset]=c.startLifetime.evaluate(void 0,c._startLifeTimeRand.random()),n.copyToArray(h,_+4),h[_+oO.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!==sZ.Mesh&&(x=!x);var A=tV.degreeToRadian(c.startRotationZ.evaluate(void 0,y.random()));if(c.startRotation3D){var b=tV.degreeToRadian(c.startRotationX.evaluate(void 0,y.random())),S=tV.degreeToRadian(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 s2.Constant:h[_+19]=c.gravityModifier.constant;break;case s2.TwoConstants:h[_+19]=c.gravityModifier.evaluate(void 0,c._gravityModifierRand.random())}var T=this.colorOverLifetime;T.enabled&&T.color.mode===s3.TwoGradients&&(h[_+20]=T._colorGradientRand.random());var C=this.rotationOverLifetime;C.enabled&&C.rotationZ.mode===s2.TwoConstants&&(h[_+22]=C._rotationRand.random());var R=this.textureSheetAnimation;R.enabled&&R.frameOverTime.mode===s2.TwoCurves&&(h[_+23]=R._frameOverTimeRand.random());var E=this.velocityOverLifetime;if(E.enabled&&E.velocityX.mode===s2.TwoConstants&&E.velocityY.mode===s2.TwoConstants&&E.velocityZ.mode===s2.TwoConstants){var M=E._velocityRand;h[_+24]=M.random(),h[_+25]=M.random(),h[_+26]=M.random()}if(this.main.simulationSpace===sJ.World&&(a.copyToArray(h,_+27),o.copyToArray(h,_+30)),R.enabled){var P=R.frameOverTime,w=R._tillingInfo,F=w.x,D=w.y,B=w.z,L=0;(P.mode===s2.Constant||P.mode===s2.TwoConstants)&&(L=Math.floor(P.evaluate(void 0,R._frameOverTimeRand.random())*B)*F);var I=Math.floor(L);h[_+oO.simulationUVOffset]=F,h[_+35]=D,h[_+36]=L-I,h[_+37]=I*D}else h[_+oO.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()}this._firstFreeElement=l},t._retireActiveParticles=function(){for(var e=this._renderer.engine.time.frameCount,t=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var n=this._firstActiveElement*oO.instanceVertexFloatStride,r=n+oO.timeOffset;if(Math.fround(this._playTime-t[r])<t[n+oO.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*oO.instanceVertexFloatStride+oO.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=oO.instanceVertexStride,r=e*n,i=this._instanceVertexBufferBinding.buffer,a=this._instanceVertices.buffer;if(e<t)i.setData(a,0,r,(t-e)*n,ag.Discard);else{var o=(this._currentParticleCount-e)*n;i.setData(a,0,r,o,ag.Discard),t>0&&i.setData(a,o,0,t*n)}this._firstNewElement=t,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},t._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return t.push(e),n},t._resizeTransformedBoundsArray=function(){var t=oO.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=oO.boundsFloatStride,t=oO.boundsTimeOffset,n=oO.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===sZ.Billboard||sZ.StretchBillboard||sZ.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*oO.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;tY.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===sJ.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===sJ.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)},t3(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}();lh._tempVector20=new tQ,lh._tempVector21=new tQ,lh._tempVector22=new tQ,lh._tempVector30=new tk,lh._tempVector31=new tk,lh._tempMat=new tY,lh._tempColor0=new tZ,lh._tempParticleRenderers=[],lh._particleIncreaseCount=128,lh._transformedBoundsIncreaseCount=16,t9([nr],lh.prototype,"main",void 0),t9([nr],lh.prototype,"emission",void 0),t9([nr],lh.prototype,"velocityOverLifetime",void 0),t9([nr],lh.prototype,"forceOverLifetime",void 0),t9([nr],lh.prototype,"sizeOverLifetime",void 0),t9([nr],lh.prototype,"rotationOverLifetime",void 0),t9([nr],lh.prototype,"colorOverLifetime",void 0),t9([nr],lh.prototype,"textureSheetAnimation",void 0),t9([ne],lh.prototype,"_playTime",void 0),t9([ne],lh.prototype,"_firstNewElement",void 0),t9([ne],lh.prototype,"_firstActiveElement",void 0),t9([ne],lh.prototype,"_firstFreeElement",void 0),t9([ne],lh.prototype,"_firstRetiredElement",void 0),t9([ne],lh.prototype,"_primitive",void 0),t9([ne],lh.prototype,"_vertexBufferBindings",void 0),t9([ne],lh.prototype,"_subPrimitive",void 0),t9([ne],lh.prototype,"_renderer",void 0),t9([ne],lh.prototype,"_isPlaying",void 0),t9([ne],lh.prototype,"_instanceBufferResized",void 0),t9([ne],lh.prototype,"_waitProcessRetiredElementCount",void 0),t9([ne],lh.prototype,"_instanceVertexBufferBinding",void 0),t9([ne],lh.prototype,"_instanceVertices",void 0),t9([ne],lh.prototype,"_transformedBoundsArray",void 0),t9([ne],lh.prototype,"_transformedBoundsCount",void 0),t9([ne],lh.prototype,"_firstActiveTransformedBoundingBox",void 0),t9([ne],lh.prototype,"_firstFreeTransformedBoundingBox",void 0),t9([ne],lh.prototype,"_playStartDelay",void 0);var l_=/*#__PURE__*/function(e){function t(t,n){var r,i=(r=e.call(this,t,n)||this).shaderData;return i.setColor(r2._baseColorProp,new tZ(1,1,1,1)),i.setColor(r2._emissiveColorProp,new tZ(0,0,0,1)),r.isTransparent=!0,r}return t8(t,e),t3(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(r2._baseColorProp)},set:function(e){var t=this.shaderData.getColor(r2._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(r2._baseTextureProp)},set:function(e){this.shaderData.setTexture(r2._baseTextureProp,e),e?this.shaderData.enableMacro(r2._baseTextureMacro):this.shaderData.disableMacro(r2._baseTextureMacro)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(r2._emissiveColorProp)},set:function(e){var t=this.shaderData.getColor(r2._emissiveColorProp);e!==t&&t.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(r2._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(r2._emissiveTextureProp,e),e?this.shaderData.enableMacro(r2._emissiveTextureMacro):this.shaderData.disableMacro(r2._emissiveTextureMacro)}}]),t}(r2),lf=/*#__PURE__*/function(e){function t(t){return e.call(this,t,rE.find("particle-shader"))||this}return t8(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t}(l_),lp=function(e,t){this.time=e,this.count=t};t9([nr],lp.prototype,"count",void 0);var lm=/*#__PURE__*/function(){function e(){this._updateManager=new n3,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)},t3(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}();t9([ne],lm.prototype,"_updateManager",void 0);var lg=/*#__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}(),lv=((e3={})[e3.Box=0]="Box",e3[e3.Circle=1]="Circle",e3[e3.Cone=2]="Cone",e3[e3.Hemisphere=3]="Hemisphere",e3[e3.Sphere=4]="Sphere",e3[e3.Mesh=5]="Mesh",e3),ly=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).shapeType=lv.Box,t._size=new tk(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t}t8(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){lg._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=t._tempVector30;a.set(0,0,-1),lg._randomPointUnitSphere(i,e),tk.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)},t3(t,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),t}(lm);ly._tempVector30=new tk,t9([nr],ly.prototype,"_size",void 0);var lx=((e4={})[e4.Random=0]="Random",e4[e4.Loop=1]="Loop",e4),lA=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lv.Circle,t._radius=1,t._arc=360,t._arcMode=lx.Random,t._arcSpeed=1,t}t8(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){var a=t._tempPositionPoint;switch(this.arcMode){case lx.Loop:var o=n*this.arcSpeed*(360/this.arc)%1,s=tV.degreeToRadian(this.arc*o);a.set(Math.cos(s),Math.sin(s)),a.scale(e.random());break;case lx.Random:lg.randomPointInsideUnitArcCircle(tV.degreeToRadian(this.arc),a,e)}r.set(a.x,a.y,0),r.scale(this.radius),lg._randomPointUnitSphere(i,e),tk.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=tV.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))},t3(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}(lm);lA._tempPositionPoint=new tQ;var lb=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lv.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t}t8(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,i){var a=t._tempVector20,o=tV.degreeToRadian(this.angle),s=Math.sin(o),l=Math.cos(o);switch(this.emitType){case 0:lg.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var c=t._tempVector21;lg.randomPointInsideUnitCircle(c,e),tQ.lerp(a,c,this.randomDirectionAmount,c),i.set(c.x*s,c.y*s,-l);break;case 1:lg.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;tk.scale(i,this.length*e.random(),u),r.add(u);var d=t._tempVector31;lg._randomPointUnitSphere(d,e),tk.lerp(i,d,this.randomDirectionAmount,i)}},n._getDirectionRange=function(e,t){var n=0;switch(this.emitType){case 0:n=tV.degreeToRadian(this._angle);break;case 1:n=Math.sin(tV.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(tV.degreeToRadian(this._angle));e.set(-n-i*r,-n-i*r,-r),t.set(n+i*r,n+i*r,0)}},t3(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}(lm);lb._tempVector20=new tQ,lb._tempVector21=new tQ,lb._tempVector30=new tk,lb._tempVector31=new tk;var lS=((e8={})[e8.Base=0]="Base",e8[e8.Volume=1]="Volume",e8),lT=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lv.Hemisphere,t._radius=1,t}t8(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){lg._randomPointInsideUnitSphere(n,e),n.scale(this.radius);var i=n.z;i>0&&(n.z=-i),lg._randomPointUnitSphere(r,e),tk.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)},t3(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(lm),lC=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lv.Mesh,t._positionElementInfo=new tq,t._normalElementInfo=new tq,t}t8(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&aL.VertexElements){var t=this._mesh;if(t){var n=t.getVertexElement(ak.Position),r=t.getVertexElement(ak.Normal);if(!n||!r)throw"Mesh must have both "+ak.Position+" and "+ak.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,t,n){e.mesh=this._mesh},t3(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(aL.VertexElements),this._updateManager.dispatch())}}]),t}(lm);t9([ne],lC.prototype,"_mesh",void 0),t9([ne],lC.prototype,"_positionBuffer",void 0),t9([ne],lC.prototype,"_normalBuffer",void 0),t9([ne],lC.prototype,"_positionElementInfo",void 0),t9([ne],lC.prototype,"_normalElementInfo",void 0),t9([ne],lC.prototype,"_onMeshChanged",null);var lR=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=lv.Sphere,t._radius=1,t}t8(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){lg._randomPointInsideUnitSphere(n,e),n.scale(this.radius),lg._randomPointUnitSphere(r,e),tk.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)},t3(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(lm),lE=((e5={})[e5.Stretch=0]="Stretch",e5[e5.Tile=1]="Tile",e5),lM=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).emitting=!0,n.minVertexDistance=.1,n.widthCurve=new ls(new ll(0,1),new ll(1,1)),n.colorGradient=new s8([new s5(0,new tZ(1,1,1,1)),new s5(1,new tZ(1,1,1,1))],[new s9(0,1),new s9(1,1)]),n._trailParams=new tq(lE.Stretch,1,1,0),n._textureScale=new tQ(1,1),n._distanceParams=new tQ,n._curveMaxTime=new tq,n._time=5,n._firstActiveElement=0,n._firstNewElement=0,n._firstFreeElement=0,n._firstRetiredElement=0,n._currentPointCapacity=0,n._bufferResized=!1,n._lastPosition=new tk,n._hasLastPosition=!1,n._cumulativeDistance=0,n._playTime=0,n._lastPlayTimeUpdateFrameCount=-1,n._textureScale._onValueChanged=n._onTextureScaleChanged.bind(n),n._onTextureScaleChanged(),n._initGeometry(),n}t8(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;tk.distance(f,this._lastPosition)>=this.minVertexDistance&&(tk.min(i,f,i),tk.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 aD(this.engine);this._primitive=e,e.addVertexElement(new ab("a_PositionBirthTime",0,ax.Vector4,0)),e.addVertexElement(new ab("a_CornerTangent",16,ax.Vector4,0)),e.addVertexElement(new ab("a_Distance",32,ax.Float,0)),this._mainSubPrimitive=new aw(0,0,aT.TriangleStrip),this._wrapSubPrimitive=new aw(0,0,aT.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 av(r,aS.VertexBuffer,s*a,am.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 aI(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|=ad.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&&tk.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){tk.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,ag.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,ag.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},t3(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}(au);lM.VERTEX_STRIDE=36,lM.VERTEX_FLOAT_STRIDE=9,lM.DISTANCE_OFFSET=8,lM.POINT_FLOAT_STRIDE=18,lM.POINT_BYTE_STRIDE=72,lM.POINT_INCREASE_COUNT=128,lM._trailParamsProp=nG.getByName("renderer_TrailParams"),lM._distanceParamsProp=nG.getByName("renderer_DistanceParams"),lM._widthCurveProp=nG.getByName("renderer_WidthCurve"),lM._colorKeysProp=nG.getByName("renderer_ColorKeys"),lM._alphaKeysProp=nG.getByName("renderer_AlphaKeys"),lM._curveMaxTimeProp=nG.getByName("renderer_CurveMaxTime"),lM._tempVector3=new tk,t9([nr],lM.prototype,"widthCurve",void 0),t9([nr],lM.prototype,"colorGradient",void 0),t9([nr],lM.prototype,"_trailParams",void 0),t9([nr],lM.prototype,"_textureScale",void 0),t9([ne],lM.prototype,"_distanceParams",void 0),t9([ne],lM.prototype,"_curveMaxTime",void 0),t9([ne],lM.prototype,"_primitive",void 0),t9([ne],lM.prototype,"_mainSubPrimitive",void 0),t9([ne],lM.prototype,"_wrapSubPrimitive",void 0),t9([ne],lM.prototype,"_vertexBuffer",void 0),t9([ne],lM.prototype,"_vertices",void 0),t9([ne],lM.prototype,"_firstActiveElement",void 0),t9([ne],lM.prototype,"_firstNewElement",void 0),t9([ne],lM.prototype,"_firstFreeElement",void 0),t9([ne],lM.prototype,"_firstRetiredElement",void 0),t9([ne],lM.prototype,"_currentPointCapacity",void 0),t9([ne],lM.prototype,"_bufferResized",void 0),t9([ne],lM.prototype,"_lastPosition",void 0),t9([ne],lM.prototype,"_hasLastPosition",void 0),t9([ne],lM.prototype,"_cumulativeDistance",void 0),t9([ne],lM.prototype,"_playTime",void 0),t9([ne],lM.prototype,"_lastPlayTimeUpdateFrameCount",void 0),t9([ne],lM.prototype,"_onTextureScaleChanged",null);var lP=/*#__PURE__*/function(e){function t(t){return e.call(this,t,rE.find("trail"))||this}return t8(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this._cloneToAndModifyName(e),e},t}(l_),lw=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.probeLayer=rV.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t}t8(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 nP(this.engine,this.width,this.height,this._isCube?new nM(this.engine,this.width):new nw(this.engine,this.width,this.height),nl.Depth,this.antiAliasing),this._renderTargetSwap=new nP(this.engine,this.width,this.height,this._isCube?new nM(this.engine,this.width):new nw(this.engine,this.width,this.height),nl.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)},t3(t,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),t}(o8),lF=new tk,lD=new tk,lB=new tk,lL=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.position=new tk(0,0,0),t._isCube=!0,t.oriViewMatrix=new tY,t}t8(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(nc.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:lD.set(0,-1,0),lB.set(1,0,0);break;case 1:lD.set(0,-1,0),lB.set(-1,0,0);break;case 2:lD.set(0,0,1),lB.set(0,1,0);break;case 3:lD.set(0,0,-1),lB.set(0,-1,0);break;case 4:lD.set(0,-1,0),lB.set(0,0,1);break;case 5:lD.set(0,-1,0),lB.set(0,0,-1)}tk.add(this.position,lB,lF),tY.lookAt(this.position,lF,lD,t.viewMatrix),t.fieldOfView=90},t}(lw),lI=/*#__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}t8(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},t3(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}(no),lN=/*#__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}();lN._playingCount=0,lN._resumePromise=null,lN._needsUserGestureResume=!1;var lO=/*#__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=lN.getContext().createGain(),n._gainNode.connect(lN.getGainNode()),n}t8(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&&(lN.isAudioContextRunning()?this._startPlayback():(this._pendingPlay=!0,lN.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,lN._playingCount--)},n.pause=function(){this._pendingPlay=!1,this._isPlaying&&(this._clearSourceNode(),this._pausedTime=lN.getContext().currentTime,this._isPlaying=!1,lN._playingCount--)},n._cloneTo=function(e,t,n){var r;null==(r=e._clip)||r._addReferCount(1),e._gainNode.gain.setValueAtTime(e._volume,lN.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=lN.getContext().currentTime-e,this._pausedTime=-1,this._isPlaying=!0,lN._playingCount++},n._initSourceNode=function(e){var t=lN.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},t3(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,lN.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?lN.getContext().currentTime-this._playTime:this._pausedTime>0?this._pausedTime-this._playTime:0}}]),t}(rL);t9([ne],lO.prototype,"_isPlaying",void 0),t9([ne],lO.prototype,"_pendingPlay",void 0),t9([nt],lO.prototype,"_clip",void 0),t9([ne],lO.prototype,"_gainNode",void 0),t9([ne],lO.prototype,"_sourceNode",void 0),t9([ne],lO.prototype,"_pausedTime",void 0),t9([ne],lO.prototype,"_playTime",void 0),t9([nt],lO.prototype,"_volume",void 0),t9([nt],lO.prototype,"_lastVolume",void 0),t9([nt],lO.prototype,"_playbackRate",void 0),t9([nt],lO.prototype,"_loop",void 0),t9([ne],lO.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||(nA.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){nA.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||(nA.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 lV=/*#__PURE__*/Object.freeze({__proto__:null,AmbientLight:oq,AmbientOcclusion:o1,AmbientOcclusionQuality:ir,get AnimationArrayCurve(){return s_},get AnimationBoolCurve(){return sf},AnimationClip:su,AnimationClipCurveBinding:sl,get AnimationColorCurve(){return sp},AnimationCurve:sh,AnimationEvent:sc,get AnimationFloatArrayCurve(){return sm},get AnimationFloatCurve(){return sg},get AnimationQuaternionCurve(){return sv},get AnimationRectCurve(){return sS},get AnimationRefCurve(){return sb},get AnimationStringCurve(){return sT},get AnimationVector2Curve(){return sy},get AnimationVector3Curve(){return sx},get AnimationVector4Curve(){return sA},Animator:sO,AnimatorCondition:sF,AnimatorConditionMode:sC,AnimatorController:sk,AnimatorControllerLayer:sX,AnimatorControllerParameter:sV,AnimatorCullingMode:sR,AnimatorLayerBlendingMode:sE,AnimatorLayerMask:sY,AnimatorState:sG,AnimatorStateMachine:sH,AnimatorStateTransition:sD,AntiAliasing:rH,AssetPromise:nb,AssetType:oo,AudioClip:lI,AudioManager:lN,AudioSource:lO,Background:rD,BackgroundMode:n8,BackgroundTextureFillMode:n5,BaseMaterial:r2,BasicRenderPipeline:aa,BatchUtils:i8,BlendFactor:n9,BlendMode:r$,BlendOperation:n6,BlendShape:aM,BlendShapeFrame:aR,BlendState:rb,BlinnPhongMaterial:r3,Blitter:r7,BloomDownScaleMode:im,BloomEffect:ig,BoolUpdateFlag:rk,BoxColliderShape:iK,BoxShape:ly,Buffer:av,BufferAsset:se,BufferBindFlag:aS,BufferMesh:aN,BufferUsage:am,BufferUtil:aA,Burst:lp,get Camera(){return rJ},CameraClearFlags:rX,CameraModifyFlags:rW,CameraType:rj,Canvas:oW,CapsuleColliderShape:iZ,CharRenderInfo:t5,CharacterController:iT,CircleShape:lA,ClearableObjectPool:oT,CloneManager:ni,get Collider(){return ib},ColliderShape:iM,ColliderShapeUpAxis:iV,Collision:iI,CollisionDetectionMode:iF,ColorOverLifetimeModule:le,ColorWriteMask:n7,CompareFunction:re,Component:rL,ConeEmitType:lS,ConeShape:lb,ContactPoint:iL,ContentRestorer:ns,ControllerCollisionFlag:ik,ControllerNonWalkableMode:iS,CubeProbe:lL,CullMode:rt,CurveKey:ll,DataType:nS,DependentMode:rO,DepthState:rS,DepthTextureMode:rY,DiffuseMode:oQ,DirectLight:oJ,DisorderedArray:nK,Downsampling:rK,DynamicCollider:iw,DynamicColliderConstraints:iD,EmissionModule:ln,Engine:oX,EngineObject:na,Entity:a3,EntityModifyFlags:a2,EventDispatcher:nz,FinalPass:i2,FixedJoint:iG,FogMode:oK,Font:nO,FontStyle:nB,GLCapabilityType:nT,GradientAlphaKey:s9,GradientColorKey:s5,HemisphereShape:lT,HingeJoint:iX,HitResult:iB,IndexBufferBinding:aP,IndexFormat:ay,InputManager:oL,InterpolationType:sd,JSONAsset:o7,get Joint(){return iU},JointLimits:ij,JointMotor:iY,Keyframe:sW,Keys:ob,Layer:rV,LayerPathMask:sj,Light:oZ,Loader:o9,Logger:nA,MSAASamples:rQ,MainModule:la,Material:r1,Mesh:aB,MeshColliderShape:iP,MeshColliderShapeCookingFlag:iC,MeshRenderer:aO,MeshShape:lC,MeshTopology:aT,ModelMesh:aU,OverflowMode:nL,PBRMaterial:r5,ParticleCompositeCurve:lt,ParticleCompositeGradient:s6,ParticleCurve:ls,ParticleCurveMode:s2,ParticleGenerator:lh,ParticleGradient:s8,ParticleGradientMode:s3,ParticleMaterial:lf,ParticleRenderMode:sZ,ParticleRenderer:s0,ParticleScaleMode:li,ParticleShapeArcMode:lx,ParticleShapeType:lv,ParticleSimulationSpace:sJ,ParticleStopMode:s$,PhysicsMaterial:iE,PhysicsMaterialCombineMode:iR,PhysicsScene:iN,PipelineStage:rd,PlaneColliderShape:iq,Platform:t1,PointLight:o$,Pointer:oR,PointerButton:oy,PointerEventData:oM,PointerEventEmitter:oP,PointerPhase:oC,PostProcess:ix,PostProcessEffect:ip,PostProcessEffectBoolParameter:is,PostProcessEffectColorParameter:ic,PostProcessEffectEnumParameter:i_,PostProcessEffectFloatParameter:io,PostProcessEffectParameter:ia,PostProcessEffectTextureParameter:il,PostProcessEffectVector2Parameter:iu,PostProcessEffectVector3Parameter:id,PostProcessEffectVector4Parameter:ih,PostProcessManager:iJ,PostProcessPass:i0,PostProcessPassEvent:i$,PostProcessUberPass:i1,Primitive:aD,PrimitiveMesh:aJ,Probe:lw,RasterState:rT,ReferResource:no,RefractionMode:r8,RenderBufferDepthFormat:nl,RenderFace:r0,RenderQueue:i4,RenderQueueFlags:ao,RenderQueueType:rn,RenderState:rR,RenderStateElementKey:rr,RenderTarget:nP,RenderTargetBlendState:rA,get Renderer(){return au},RendererUpdateFlags:ad,RenderingStatistics:oc,ReplacementFailureStrategy:rq,ResourceManager:of,ReturnableObjectPool:a7,RotationOverLifetimeModule:lo,SafeLoopArray:os,Scene:o3,SceneManager:ol,Script:o8,SetDataOptions:ag,Shader:rE,ShaderData:rM,ShaderDataGroup:ri,ShaderFactory:r_,ShaderLanguage:ra,ShaderLib:rh,ShaderMacro:rl,ShaderMacroCollection:rc,ShaderPass:ry,ShaderProperty:nG,ShaderPropertyType:ro,ShaderTagKey:rf,ShadowCascadesMode:ae,ShadowResolution:i9,ShadowType:i6,get SimpleSpriteAssembler(){return nk},SizeOverLifetimeModule:lc,Skin:a4,SkinnedMeshRenderer:a5,Sky:rF,SkyBoxMaterial:sK,SkyProceduralMaterial:sq,get SlicedSpriteAssembler(){return nU},SphereColliderShape:iQ,SphereShape:lR,SpotLight:o0,SpringJoint:iW,Sprite:n4,SpriteAtlas:nZ,SpriteDrawMode:nJ,SpriteMask:ah,SpriteMaskInteraction:n$,SpriteMaskLayer:ac,SpriteModifyFlags:n0,SpriteRenderer:a_,SpriteTileMode:nQ,StateMachineScript:sz,StaticCollider:iO,StencilOperation:rs,StencilState:rC,SubFont:nN,SubMesh:aF,SubPrimitive:aw,SubShader:rx,SunMode:sQ,SystemInfo:nC,TextAsset:o6,TextHorizontalAlignment:n1,TextRenderer:af,TextUtils:nI,TextVerticalAlignment:n2,Texture:nR,Texture2D:nw,Texture2DArray:nF,TextureCoordinate:r4,TextureCube:nM,TextureCubeFace:nc,TextureDepthCompareFunction:nu,TextureFilterMode:nd,TextureFormat:nh,TextureSheetAnimationModule:lu,TextureUsage:n_,TextureUtils:nE,TextureWrapMode:nf,get TiledSpriteAssembler(){return nq},Time:nH,TonemappingEffect:iy,TonemappingMode:iv,TrailMaterial:lP,TrailRenderer:lM,TrailTextureMode:lE,Transform:rU,TransformModifyFlags:rz,UnlitMaterial:r9,Utils:nX,VelocityOverLifetimeModule:ld,VertexAttribute:ak,VertexBufferBinding:aI,VertexElement:ab,VertexElementFormat:ax,WrapMode:sB,XRManager:oH,assignmentClone:nt,deepClone:nr,dependentComponents:rN,ignoreClone:ne,registerPointerEventEmitter:oD,request:oh,resourceLoader:op,shallowClone:nn}),lk=((e9={})[e9.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",e9[e9.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",e9[e9.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",e9[e9.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",e9[e9.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",e9[e9.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",e9[e9.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",e9[e9.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",e9[e9.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",e9[e9.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",e9[e9.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",e9[e9.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",e9[e9.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",e9[e9.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",e9[e9.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",e9[e9.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",e9[e9.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",e9[e9.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",e9[e9.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",e9[e9.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",e9[e9.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",e9[e9.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",e9[e9.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",e9[e9.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",e9[e9.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",e9[e9.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",e9[e9.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",e9[e9.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",e9[e9.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",e9[e9.R11_EAC=37488]="R11_EAC",e9[e9.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",e9[e9.RG11_EAC=37490]="RG11_EAC",e9[e9.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",e9[e9.RGB8_ETC2=37492]="RGB8_ETC2",e9[e9.SRGB8_ETC2=37493]="SRGB8_ETC2",e9[e9.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e9[e9.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e9[e9.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",e9[e9.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",e9[e9.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",e9[e9.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",e9[e9.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",e9[e9.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",e9[e9.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",e9[e9.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",e9[e9.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",e9[e9.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",e9[e9.SRGB_S3TC_DXT1_EXT=35916]="SRGB_S3TC_DXT1_EXT",e9[e9.SRGB_ALPHA_S3TC_DXT1_EXT=35917]="SRGB_ALPHA_S3TC_DXT1_EXT",e9[e9.SRGB_ALPHA_S3TC_DXT3_EXT=35918]="SRGB_ALPHA_S3TC_DXT3_EXT",e9[e9.SRGB_ALPHA_S3TC_DXT5_EXT=35919]="SRGB_ALPHA_S3TC_DXT5_EXT",e9[e9.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",e9[e9.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",e9[e9.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",e9[e9.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT",e9);function lU(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&&lU(e.prototype,t),n&&lU(e,n),e}function lG(e,t){return(lG=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function lH(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&&lG(e,t)}function lX(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):e(t,n)}var lW=/*#__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}lH(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||!lX(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&&lX(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&&lX(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),t}(oW),lj=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return lH(t,e),t.create=function(e){var n=e.canvas,r=new t(new lW("string"==typeof n?document.getElementById(n):n),new l8(e.graphicDeviceOptions),e);return r._initialize(e).then(function(){return r.sceneManager.addScene(new o3(r,"DefaultScene")),r})},lz(t,[{key:"canvas",get:function(){return this._canvas}}]),t}(oX);function lY(){return(lY=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 lK=/*#__PURE__*/function(){function e(e,t,n,r,i){void 0===r&&(r=am.Static);var a=e.gl,o=a.createBuffer(),s=this._getGLBufferUsage(a,r),l=t===aS.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===ag.Discard&&o.bufferData(s,e,this._glBufferUsage);var l=t.BYTES_PER_ELEMENT||1,c=i?l*i:t.byteLength;if(0!==r||c<t.byteLength){var u=void 0!==t.byteOffset;if(this._isWebGL2&&u)o.bufferSubData(s,n,t,r,c/l);else{var d=new Uint8Array(u?t.buffer:t,r*l,c);o.bufferSubData(s,n,d)}}else o.bufferSubData(s,n,t);o.bindBuffer(s,null)},t.getData=function(e,t,n,r){if(this._isWebGL2){var i=this._gl;this.bind(),i.getBufferSubData(this._glBindTarget,t,e,n,r)}else throw"Buffer is write-only on WebGL1.0 platforms."},t.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},t._getGLBufferUsage=function(e,t){switch(t){case am.Static:return e.STATIC_DRAW;case am.Dynamic:return e.DYNAMIC_DRAW;case am.Stream:return e.STREAM_DRAW}},e}(),lQ=/*#__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=lk.RGBA_ASTC_4X4_KHR,n=lk.RGBA_ASTC_12X12_KHR,r=lk.SRGB8_ALPHA8_ASTC_4X4_KHR,i=lk.SRGB8_ALPHA8_ASTC_12X12_KHR,a=lk.RGB_ETC1_WEBGL,o=lk.R11_EAC,s=lk.SRGB8_ALPHA8_ETC2_EAC,l=lk.RGB_PVRTC_4BPPV1_IMG,c=lk.RGBA_PVRTC_2BPPV1_IMG,u=lk.RGB_S3TC_DXT1_EXT,d=lk.RGBA_S3TC_DXT5_EXT,h=lk.RGBA_BPTC_UNORM_EXT,_=lk.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,T=nT.bptc,C=nT.s3tc_srgb,R=nT.textureFloat,E=nT.textureHalfFloat,M=nT.textureFloatLinear,P=nT.textureHalfFloatLinear,w=nT.WEBGL_colorBufferFloat,F=nT.colorBufferFloat,D=nT.colorBufferHalfFloat,B=nT.textureFilterAnisotropic,L=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(D,t&&!!n(F)||!!n(D)),e.set(B,!!n(B)),e.set(L,t||!!n(L)),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(C,!!n(C)),e.set(T,!!n(T));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,lY({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}(),lq=/*#__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}(),lZ=/*#__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 nA.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 nA.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}(),lJ=/*#__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}(),l$=/*#__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(!nE.supportGenerateMipmaps(e.format,t,e.isSRGBColorSpace,this._isWebGL2)){nA.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!==n_.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,nA.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&&!nE.supportSRGB(n)&&(nA.warn("Only support sRGB color space in RGB8 or RGBA8 or some compressed texture format"),e._isSRGBColorSpace=!1);var a=t.isWebGL2;e._mipmap&&!nE.supportMipmaps(r,i,a)&&(nA.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===nf.Clamp||tV.isPowerOf2(o)&&tV.isPowerOf2(s)||(nA.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),e=nf.Clamp),e){case nf.Clamp:n.texParameteri(i,t,n.CLAMP_TO_EDGE);break;case nf.Repeat:n.texParameteri(i,t,n.REPEAT);break;case nf.Mirror:n.texParameteri(i,t,n.MIRRORED_REPEAT)}},e._getFormatDetail=function(e,t,n,r){switch(e){case nh.R8G8B8:return{internalFormat:t?n.SRGB8:r?n.RGB8:n.RGB,baseFormat:t?r?n.RGB:n.SRGB8:n.RGB,readFormat:n.RGB,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:1};case nh.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 nh.R4G4B4A4:return{internalFormat:r?n.RGBA4:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1,alignment:2};case nh.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 nh.R5G6B5:return{internalFormat:r?n.RGB565:n.RGB,baseFormat:n.RGB,dataType:n.UNSIGNED_SHORT_5_6_5,isCompressed:!1,alignment:2};case nh.Alpha8:return{internalFormat:n.ALPHA,baseFormat:n.ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:1};case nh.LuminanceAlpha:return{internalFormat:n.LUMINANCE_ALPHA,baseFormat:n.LUMINANCE_ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:2};case nh.R16G16B16A16:return{internalFormat:r?n.RGBA16F:n.RGBA,baseFormat:n.RGBA,dataType:n.HALF_FLOAT,isCompressed:!1,alignment:8};case nh.R32G32B32A32:return{internalFormat:r?n.RGBA32F:n.RGBA,baseFormat:n.RGBA,dataType:n.FLOAT,isCompressed:!1,alignment:8};case nh.R11G11B10_UFloat:return{internalFormat:n.R11F_G11F_B10F,baseFormat:n.RGB,dataType:n.FLOAT,isCompressed:!1,alignment:4};case nh.R32G32B32A32_UInt:return{internalFormat:n.RGBA32UI,baseFormat:n.RGBA_INTEGER,dataType:n.UNSIGNED_INT,isCompressed:!1,alignment:8};case nh.R8:return{internalFormat:n.R8,baseFormat:n.RED,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:1};case nh.R8G8:return{internalFormat:n.RG8,baseFormat:n.RG,dataType:n.UNSIGNED_BYTE,isCompressed:!1,alignment:2};case nh.BC1:return{internalFormat:t?lk.SRGB_S3TC_DXT1_EXT:lk.RGB_S3TC_DXT1_EXT,isCompressed:!0};case nh.BC3:return{internalFormat:t?lk.SRGB_ALPHA_S3TC_DXT5_EXT:lk.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case nh.BC7:return{internalFormat:t?lk.SRGB_ALPHA_BPTC_UNORM_EXT:lk.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case nh.BC6H:return{internalFormat:lk.RGB_BPTC_UNSIGNED_FLOAT_EXT,isCompressed:!0};case nh.ETC1_RGB:return{internalFormat:lk.RGB_ETC1_WEBGL,isCompressed:!0};case nh.ETC2_RGB:return{internalFormat:t?lk.SRGB8_ETC2:lk.RGB8_ETC2,isCompressed:!0};case nh.ETC2_RGBA5:return{internalFormat:lk.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case nh.ETC2_RGBA8:return{internalFormat:t?lk.SRGB8_ALPHA8_ETC2_EAC:lk.RGBA8_ETC2_EAC,isCompressed:!0};case nh.PVRTC_RGB2:return{internalFormat:lk.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case nh.PVRTC_RGBA2:return{internalFormat:lk.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case nh.PVRTC_RGB4:return{internalFormat:lk.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case nh.PVRTC_RGBA4:return{internalFormat:lk.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case nh.ASTC_4x4:return{internalFormat:t?lk.SRGB8_ALPHA8_ASTC_4X4_KHR:lk.RGBA_ASTC_4X4_KHR,isCompressed:!0};case nh.ASTC_5x5:return{internalFormat:lk.RGBA_ASTC_5X5_KHR,isCompressed:!0};case nh.ASTC_6x6:return{internalFormat:lk.RGBA_ASTC_6X6_KHR,isCompressed:!0};case nh.ASTC_8x8:return{internalFormat:lk.RGBA_ASTC_8X8_KHR,isCompressed:!0};case nh.ASTC_10x10:return{internalFormat:lk.RGBA_ASTC_10X10_KHR,isCompressed:!0};case nh.ASTC_12x12:return{internalFormat:lk.RGBA_ASTC_12X12_KHR,isCompressed:!0};case nh.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 nh.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 nh.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 nh.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 nh.Depth24:return{internalFormat:n.DEPTH_COMPONENT24,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_INT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case nh.Depth32:return{internalFormat:n.DEPTH_COMPONENT32F,baseFormat:n.DEPTH_COMPONENT,dataType:n.FLOAT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case nh.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 nh.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 nh.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 nh.Stencil:return{internalFormat:t.STENCIL_INDEX8,baseFormat:t.STENCIL_ATTACHMENT,dataType:t.UNSIGNED_BYTE,isCompressed:!1,attachment:t.STENCIL_ATTACHMENT};case nh.Depth16:return{internalFormat:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case nh.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 nh.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case nh.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case nh.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 nh.R16G16B16A16:t.canIUse(nT.colorBufferHalfFloat)&&t.canIUse(nT.textureHalfFloat)||(n=!1);break;case nh.R32G32B32A32:t.canIUse(nT.colorBufferFloat)&&t.canIUse(nT.textureFloat)||(n=!1);break;case nh.R11G11B10_UFloat:n=t.isWebGL2}return n},e._supportRenderBufferDepthFormat=function(e,t){if(!t.isWebGL2)switch(e){case nh.Depth24:case nh.Depth32:case nh.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 nd.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 nd.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 nd.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 nu.Never:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NEVER);break;case nu.Less:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LESS);break;case nu.Equal:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.EQUAL);break;case nu.LessEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LEQUAL);break;case nu.Greater:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GREATER);break;case nu.NotEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NOTEQUAL);break;case nu.GreaterEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GEQUAL);break;case nu.Always:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.ALWAYS)}}}]),e}(),l0=/*#__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=lX(r,nR),s=0,l=n.length;s<l;s++){var c=n[s],u=c.format,d=c.isSRGBColorSpace;if(!l$._supportRenderBufferColorFormat(u,e))throw Error("TextureFormat is not supported:"+nh[u]+" in RenderTarget");if(d&&u===nh.R8G8B8)throw Error("If you want to use sRGB color space, only R8G8B8A8 format is supported in RenderTarget")}if(!o&&!l$._supportRenderBufferDepthFormat(r,e))throw Error("TextureFormat is not supported:"+nh[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 lX(e,nM)}))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=lX(o,nM);(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=lX(l,nM);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=l$._getRenderBufferDepthFormatDetail(r._depth,n,this._isWebGL2).internalFormat;n.bindRenderbuffer(n.RENDERBUFFER,this._depthRenderBuffer),n.renderbufferStorage(n.RENDERBUFFER,d,r.width>>e,r.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&n.bindFramebuffer(n.FRAMEBUFFER,this._MSAAFrameBuffer)},t.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),n=this._target,r=n.colorTextureCount,i=n.width,a=n.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<r;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,i,a,0,0,i,a,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},t.destroy=function(){var e=this._gl;this._frameBuffer&&e.deleteFramebuffer(this._frameBuffer),this._depthRenderBuffer&&e.deleteRenderbuffer(this._depthRenderBuffer),this._MSAAFrameBuffer&&e.deleteFramebuffer(this._MSAAFrameBuffer),this._MSAADepthRenderBuffer&&e.deleteRenderbuffer(this._MSAADepthRenderBuffer);for(var t=0;t<this._MSAAColorRenderBuffers.length;t++)e.deleteRenderbuffer(this._MSAAColorRenderBuffers[t]);this._frameBuffer=null,this._depthRenderBuffer=null,this._MSAAFrameBuffer=null,this._MSAAColorRenderBuffers.length=0,this._MSAADepthRenderBuffer=null},t._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,n=this._target,r=n._depth,i=n.colorTextureCount,a=n.width,o=n.height,s=Array(i);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<i;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,lX(c,nM)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(lX(r,nR)&&!lX(r,nM)){var d=r._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,d._formatDetail.attachment,e.TEXTURE_2D,d._glTexture,0)}else if(this._target.antiAliasing<=1){var h=l$._getRenderBufferDepthFormatDetail(r,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,a,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,n=e.createRenderbuffer(),r=this._target,i=r._depth,a=r.colorTextureCount,o=r.antiAliasing,s=r.width,l=r.height;this._blitDrawBuffers=Array(a),this._MSAADepthRenderBuffer=n,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<a;c++){var u=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=u,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,u),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,u)}if(e.drawBuffers(this._oriDrawBuffers),null!==i){var d=lX(i,nR)?i._platformTexture._formatDetail:l$._getRenderBufferDepthFormatDetail(i,e,t),h=d.internalFormat,_=d.attachment;e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,h,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,n)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._checkFrameBuffer=function(){var e=this._gl;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}(),l1=/*#__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=l$._getFormatDetail(i,a,r._gl,o),r._formatDetail.isCompressed&&!o||r._init(!1),r}lH(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===n_.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}(l$),l2=/*#__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=l$._getFormatDetail(i,c,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r}lH(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;a=a||Math.max(1,this._texture.width>>n)-r,o=o||Math.max(1,this._texture.height>>n)-i,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),c.pixelStorei(c.UNPACK_ALIGNMENT,u.alignment),f?c.compressedTexSubImage3D(l,n,r,i,e,a,o,s,d,t):c.texSubImage3D(l,n,r,i,e,a,o,s,h,_,t)},n.setImageSource=function(e,t,n,r,i,a,o){var s,l,c=this._gl,u=this._formatDetail,d=u.baseFormat,h=u.dataType;this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,+r),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),c.texSubImage3D(this._target,n,a,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},n.getPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.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&&!nE.supportSRGB(n)&&(nA.warn("Only support sRGB color space in RGB8 or RGBA8 or some compressed texture format"),e._isSRGBColorSpace=!1)},t}(l$),l3=/*#__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=l$._getFormatDetail(i,a,r._gl,o),r._formatDetail.isCompressed&&!o||r._init(!0),r}lH(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,u=c.internalFormat,d=c.baseFormat,h=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>n);if(a=a||f-r,o=o||f-i,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),s.pixelStorei(s.UNPACK_ALIGNMENT,c.alignment),_){var p=1<<n;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,i,a,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,u,a,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,i,a,o,d,h,t)},n.setImageSource=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,a||0,o||0,c,u,t)},n.getPixelBuffer=function(t,n,r,i,a,o,s){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,t,n,r,i,a,o,s)},t}(l$),l4=((e6={})[e6.Auto=0]="Auto",e6[e6.WebGL2=1]="WebGL2",e6[e6.WebGL1=2]="WebGL1",e6),l8=/*#__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 tq(null,null,null,null),this._lastScissor=new tq(null,null,null,null),this._lastClearColor=new tZ(null,null,null,null),this._scissorEnable=!1;var t=lY({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(nC.platform===t1.IPhone||nC.platform===t1.IPad){var n=nC.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&&lX(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&&lX(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 lZ(this,e)},t.createPlatformTexture2D=function(e){return new l1(this,e)},t.createPlatformTexture2DArray=function(e){return new l2(this,e)},t.createPlatformTextureCube=function(e){return new l3(this,e)},t.createPlatformRenderTarget=function(e){return new l0(this,e)},t.createPlatformBuffer=function(e,t,n,r){return void 0===n&&(n=am.Static),new lK(this,e,t,n,r)},t.requireExtension=function(e){return this._extensions.requireExtension(e)},t.canIUse=function(e){return this.capability.canIUse(e)},t.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},t.viewport=function(e,t,n,r){var i=this._gl,a=this._lastViewport;(e!==a.x||t!==a.y||n!==a.z||r!==a.w)&&(i.viewport(e,t,n,r),a.set(e,t,n,r))},t.scissor=function(e,t,n,r){var i=this._gl,a=this._lastScissor;if(e!==a.x||t!==a.y||n!==a.z||r!==a.w){var o=this._webCanvas;0===e&&0===t&&n===o.width&&r===o.height?this._scissorEnable&&(i.disable(i.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(i.enable(i.SCISSOR_TEST),this._scissorEnable=!0),i.scissor(e,t,n,r)),a.set(e,t,n,r)}},t.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},t.clearRenderTarget=function(e,t,n){var r=this._gl,i=e._lastRenderState,a=i.blendState.targetBlendState,o=i.depthState,s=i.stencilState,l=0;if(t&rX.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!==n7.All&&(r.colorMask(!0,!0,!0,!0),a.colorWriteMask=n7.All)}t&rX.Depth&&(l|=r.DEPTH_BUFFER_BIT,!0!==o.writeEnabled&&(r.depthMask(!0),o.writeEnabled=!0)),t&rX.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):nA.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){nA.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&rX.Color)==0,p=(n&rX.Depth)==0,m=(n&rX.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===nh.Depth||v>=nh.DepthStencil&&v<=nh.Depth32Stencil8?g|=i.DEPTH_BUFFER_BIT:nA.warn("Do not clear depth, or set depth format of target which is "+nh[v]+" now.")),m&&(v===nh.Stencil||v===nh.DepthStencil||v>=nh.Depth24Stencil8||v>=nh.Depth32Stencil8?g|=i.STENCIL_BUFFER_BIT:nA.warn("Do not clear stencil, or set stencil format of target which is "+nh[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 lJ(e),this._extensions=new lq(this),this._capability=new lQ(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 l5(){return(l5=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 l9(e,t){return(l9=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l6(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&&l9(e,t)}function l7(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function ce(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 ct(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 cn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function cr(e,t,n){return t&&cn(e.prototype,t),n&&cn(e,n),e}"function"==typeof SuppressedError&&SuppressedError;var ci=/*#__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)},cr(e,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),e}(),ca={};function co(e){return function(t){ca[e]=t}}var cs=/*#__PURE__*/function(){function e(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}return e.decode=function(t){var n=new DataView(t),r=n.getUint32(0,!0),i=n.getUint8(4),a=n.getUint16(5,!0),o=new Uint8Array(t,7,a),s=n.getUint16(7+a,!0),l=new Uint8Array(t,9+a,s),c=nX.decodeText(l),u=nX.decodeText(o),d=new e;return d.totalLength=r,d.name=c,d.type=u,d.version=i,d.headerLength=l.byteLength+o.byteLength+9,d},cr(e,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),e}(),cl=((e7={})[e7.Float=0]="Float",e7[e7.FloatArray=1]="FloatArray",e7[e7.Vector2=2]="Vector2",e7[e7.Vector3=3]="Vector3",e7[e7.Vector4=4]="Vector4",e7[e7.Quaternion=5]="Quaternion",e7[e7.Color=6]="Color",e7[e7.Array=7]="Array",e7[e7.Boolean=8]="Boolean",e7[e7.Rect=9]="Rect",e7[e7.ReferResource=10]="ReferResource",e7),cc=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new nb(function(e){for(var n=new su(t.nextStr()),r=t.nextUint16(),i=0;i<r;++i){var a=new sc;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=o9.getClass(c),d=t.nextStr(),h=t.nextStr(),_=void 0,f=t.nextUint8(),p=t.nextUint16();switch(t.nextStr()){case"AnimationFloatCurve":(_=new sg).interpolation=f;for(var m=0;m<p;++m){var g=new sW;g.time=t.nextFloat32(),g.value=t.nextFloat32(),g.inTangent=t.nextFloat32(),g.outTangent=t.nextFloat32(),_.addKey(g)}break;case"AnimationArrayCurve":(_=new s_).interpolation=f;for(var v=0;v<p;++v){var y=new sW;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 sm).interpolation=f;for(var A=0;A<p;++A){var b=new sW;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 sy).interpolation=f;for(var T=0;T<p;++T){var C=new sW;C.time=t.nextFloat32(),C.value=new tQ(t.nextFloat32(),t.nextFloat32()),C.inTangent=new tQ(t.nextFloat32(),t.nextFloat32()),C.outTangent=new tQ(t.nextFloat32(),t.nextFloat32()),_.addKey(C)}break;case"AnimationVector3Curve":(_=new sx).interpolation=f;for(var R=0;R<p;++R){var E=new sW;E.time=t.nextFloat32(),E.value=new tk(t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),E.inTangent=new tk(t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),E.outTangent=new tk(t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(E)}break;case"AnimationVector4Curve":(_=new sA).interpolation=f;var M=new sW;M.time=t.nextFloat32(),M.value=new tq(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),M.inTangent=new tq(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),M.outTangent=new tq(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(M);break;case"AnimationColorCurve":(_=new sp).interpolation=f;for(var P=0;P<p;++P){var w=new sW;w.time=t.nextFloat32(),w.value=new tZ(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),w.inTangent=new tq(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),w.outTangent=new tq(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(w)}break;case"AnimationQuaternionCurve":(_=new sv).interpolation=f;for(var F=0;F<p;++F){var D=new sW;D.time=t.nextFloat32(),D.value=new tj(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),D.inTangent=new tq(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),D.outTangent=new tq(t.nextFloat32(),t.nextFloat32(),t.nextFloat32(),t.nextFloat32()),_.addKey(D)}break;case"AnimationRefCurve":(_=new sb).interpolation=f;for(var B=0;B<p;++B){var L=new sW;L.time=t.nextFloat32();var I=t.nextStr();I?L.value=JSON.parse(I):L.value=null,_.addKey(L)}break;case"AnimationBoolCurve":(_=new sf).interpolation=f;for(var N=0;N<p;++N){var O=new sW;O.time=t.nextFloat32(),O.value=1===t.nextUint8(),_.addKey(O)}break;case"AnimationStringCurve":(_=new sT).interpolation=f;for(var V=0;V<p;++V){var k=new sW;k.time=t.nextFloat32(),k.value=t.nextStr(),_.addKey(k)}}n.addCurveBinding(l,u,d,h,_)}e(n)})},e}();cc=ce([co("AnimationClip")],cc);var cu=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t,n){return new nb(function(r){var i=n||new aU(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=ch(l,c);if(i.setPositions(u),a.normals){var d=ch(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(c_(h,c))}if(a.uv1){var _=new Float32Array(s,a.uv1.start+o,(a.uv1.end-a.uv1.start)/4);i.setUVs(c_(_,c),1)}if(a.uv2){var f=new Float32Array(s,a.uv2.start+o,(a.uv2.end-a.uv2.start)/4);i.setUVs(c_(f,c),2)}if(a.uv3){var p=new Float32Array(s,a.uv3.start+o,(a.uv3.end-a.uv3.start)/4);i.setUVs(c_(p,c),3)}if(a.uv4){var m=new Float32Array(s,a.uv4.start+o,(a.uv4.end-a.uv4.start)/4);i.setUVs(c_(m,c),4)}if(a.uv5){var g=new Float32Array(s,a.uv5.start+o,(a.uv5.end-a.uv5.start)/4);i.setUVs(c_(g,c),5)}if(a.uv6){var v=new Float32Array(s,a.uv6.start+o,(a.uv6.end-a.uv6.start)/4);i.setUVs(c_(v,c),6)}if(a.uv7){var y=new Float32Array(s,a.uv7.start+o,(a.uv7.end-a.uv7.start)/4);i.setUVs(c_(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 tZ(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(cd(A,c))}if(a.boneIndices){var b=new Float32Array(s,a.boneIndices.start+o,(a.boneIndices.end-a.boneIndices.start)/4);i.setBoneIndices(cd(b,c))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new aM(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=ch(n,r);e.deltaNormals&&ch(new Float32Array(s,e.deltaNormals.start+o,(e.deltaNormals.end-e.deltaNormals.start)/4),r),e.deltaTangents&&cd(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 cd(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tq(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function ch(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tk(e[3*r],e[3*r+1],e[3*r+2]);return n}function c_(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 cf(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(cf=function(){return!!e})()}function cp(e,t,n){return(cp=cf()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&l9(i,n.prototype),i}).apply(null,arguments)}cu=ce([co("Mesh")],cu);var cm=((te={})[te.Prefab=0]="Prefab",te[te.Scene=1]="Scene",te),cg=/*#__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}(),cv=/*#__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===cm.Prefab&&n._markAsTemplate(t._context.resource),n})},t.parseClassObject=function(e){var t,n=this,r=o9.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return n.parseBasicType(e)})).then(function(e){return cp(r,[].concat(e))}).then(function(t){return n.parsePropsAndMethods(t,e)})},t.parsePropsAndMethods=function(t,n){var r=[];if(n.methods)for(var i in n.methods)for(var a=n.methods[i],o=0,s=a.length;o<s;o++)r.push(this.parseMethod(t,i,a[o]));if(n.props){var l,c=function(e){var i=n.props[e],a=l.parseBasicType(i,t[e]).then(function(n){return t[e]=n});r.push(a)};for(var u in n.props)l=this,c(u)}return Promise.all(r).then(function(){var r=e.customParseComponentHandles[t.constructor.name];return r?r(t,n):t})},t.parseMethod=function(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.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":l7(t))==="object"&&null!=t){if(e._isClassType(t))return Promise.resolve(o9.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 i.type===cm.Prefab&&i.resource._addDependenceAsset(e),e})}if(e._isComponentRef(t))return Promise.resolve(null!=(a=this._context.components.get(t.componentId))?a:null);else if(e._isEntityRef(t))return Promise.resolve(this._context.entityMap.get(t.entityId));else if(n){var a,o,s=function(e){if("methods"===e){var r=t[e];for(var i in r)for(var a=r[i],s=0,c=a.length;s<c;s++){var u=a[s];l.push(o.parseMethod(n,i,u))}}else l.push(o.parseBasicType(t[e],n[e]).then(function(t){return n[e]=t}))},l=[];for(var c in t)o=this,s(c);return Promise.all(l).then(function(){return n})}}return Promise.resolve(t)},t._getEntityByConfig=function(e){var t=this,n=e.assetRefId,r=this._context.engine;if(n)return r.resourceManager.getResourceByRef({refId:n,key:e.key,isClone:e.isClone}).then(function(i){var a=r.resourceManager._objectPool[n];return t._context.type===cm.Prefab&&t._context.resource._addDependenceAsset(a),i.name=e.name,i});var i=e.transform;return Promise.resolve(new a3(r,e.name,i?o9.getClass(i.class):rU))},e.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},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.refId},e._isEntityRef=function(e){return void 0!==e.entityId},e._isComponentRef=function(e){return void 0!==e.ownerId&&void 0!==e.componentId},e._isMethodObject=function(e){return Array.isArray(null==e?void 0:e.params)},e}();cv.customParseComponentHandles=new Map;var cy=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t,n){return new nb(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 nw(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 cx(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):e(t,n)}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}function cb(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))||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.")}cy=ce([co("Texture2D")],cy);var cS=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r._dependenceAssets=new Set,r}l6(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),cx(e,no)&&e._associationSuperResource(this)},n._onDestroy=function(){var t=this;e.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(e){cx(e,no)&&e._disassociationSuperResource(t)})},t}(no),cT=/*#__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 cv(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(e){for(var n=0,i=e.length;n<i;n++)r.set(t[n].id,e[n]);return e})},t._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,n=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.assetRefId?this._parsePrefab(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return n._applyEntityData(t,e)})},t._parseEntity=function(e,t){var n=e.transform,r=new a3(t,e.name,n?o9.getClass(n.class):rU);return e.parent||this.context.rootIds.push(e.id),this._addEntityPlugin(e.id,r),Promise.resolve(r)},t._parsePrefab=function(e,t){var n=this,r=e.assetRefId;return t.resourceManager.getResourceByRef({refId:r}).then(function(r){var i=cx(r,cS)?r.instantiate():r.instantiateSceneRoot(),a=new cg(t,cm.Prefab,null);e.parent||n.context.rootIds.push(e.id),n._generateInstanceContext(i,a,""),n._prefabContextMap.set(i,a);var o=n._prefabPromiseMap.get(e.id);if(o)for(var s=0,l=o.length;s<l;s++)o[s].resolve(a);return i})},t._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(n,r){var i,a=null!=(i=t._prefabPromiseMap.get(e.prefabInstanceId))?i:[];a.push({resolve:n,reject:r}),t._prefabPromiseMap.set(e.prefabInstanceId,a)}).then(function(t){var n=e.prefabSource.entityId;return t.entityMap.get(n)})},t._parseChildren=function(e){var t=this.context,n=t.entityConfigMap,r=t.entityMap,i=n.get(e).children;if(i&&i.length>0)for(var a=r.get(e),o=0;o<i.length;o++){var s=i[o],l=r.get(s);a.addChild(l),this._parseChildren(s)}},t._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.refId?s.refId:s.class,c=s.id,u=e.addComponent(o9.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=o9.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=cb(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}(),cC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=l5({},e,{type:"arraybuffer"}),r=e.url;return new nb(function(e,i){t._request(r,n).then(function(i){cw(i,t.engine).then(function(i){t.addContentRestorer(new cR(i,r,n)),e(i)})}).catch(i)})},t}(o9);cC=ce([op("EditorTexture2D",["prefab"],!0)],cC);var cR=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return l6(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 cw(n,t,e)})},t}(ns),cE=((tt={}).Vector2="Vector2",tt.Vector3="Vector3",tt.Vector4="Vector4",tt.Color="Color",tt.Float="Float",tt.Texture="Texture",tt.Boolean="Boolean",tt.Integer="Integer",tt),cM=((tn={}).Sky="Sky",tn.Custom="Custom",tn),cP=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t,n)||this).scene=r,i}l6(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===cM.Custom,o=i.diffuseMode===oQ.SphericalHarmonics,s=i.customAmbientLight,l=i.ambientLight;a&&s&&t._addDependentAsset(s.refId,n.getResourceByRef(s)),l&&(!a||o)&&t._addDependentAsset(l.refId,n.getResourceByRef(l))}var c=r.background,u=c.mode;if(u===n8.Texture){var d=c.texture;d&&t._addDependentAsset(d.refId,n.getResourceByRef(d))}else if(u===n8.Sky){var h=c.skyMesh,_=c.skyMaterial;h&&_&&(t._addDependentAsset(h.refId,n.getResourceByRef(h)),t._addDependentAsset(_.refId,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.assetRefId){var a=this.context,o=i.assetRefId,s=i.key;a._addDependentAsset(o,a.resourceManager.getResourceByRef({refId: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":l7(e))==="object"){if(cv._isAssetRef(e)){var r=this.context;r._addDependentAsset(e.refId,r.resourceManager.getResourceByRef(e))}else for(var i in e)this._searchDependentAssets(e[i])}},t}(cT);function cw(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=cs.decode(e),s=new ci(new Uint8Array(e),o.headerLength,o.dataLength);return(n=ca[o.type]).decode.apply(n,[].concat([t,s],i)).then(function(e){return e.name=o.name,e})}var cF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nb(function(r,i){t._request(e.url,l5({},e,{type:"arraybuffer"})).then(function(e){return cw(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":l7(n))==="object"&&(null==n?void 0:n.refId)?new Promise(function(r){t.getResourceByRef(n).then(function(t){e.value=t,r(e.value)})}):Promise.resolve(e.value)},t}(o9);cF=ce([op(oo.AnimationClip,["ani"])],cF);var cD=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nb(function(r,i){t._request(e.url,l5({},e,{type:"json"})).then(function(e){var i=new sk(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 sX(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(o9.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 sD;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}(o9);cD=ce([op(oo.AnimatorController,["json"],!1)],cD);var cB=/^data:(.+?);base64,/,cL=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=e.url,r=cB.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,l5({},e,{type:"arraybuffer"}));return nb.resolve(i).then(function(e){var n=new se(t.engine);return n.buffer=e,n})},t}(o9);cL=ce([op(oo.Buffer,["bin","r3bin"])],cL);var cI=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,n){return new nb(function(r,i){var a=l5({},e,{type:"arraybuffer"}),o=n.engine,s=e.url;n._request(s,a).then(function(e){var n=t._setTextureByBuffer(o,e);o.resourceManager.addContentRestorer(new cN(n,s,a));var i=new oq(o),l=new t$;i.diffuseMode=oQ.SphericalHarmonics,l.copyFromArray(new Float32Array(e,0,27)),i.diffuseSphericalHarmonics=l,i.specularTexture=n,i.specularTextureDecodeRGBM=!0,r(i)}).catch(function(e){i(e)})})},t._setTextureByBuffer=function(e,t,n){var r=new Uint16Array(t,108,1)[0];n||(n=new nM(e,r,void 0,void 0,!1)),n.filterMode=nd.Trilinear;for(var i=n.mipmapCount,a=110,o=0;o<i;o++)for(var s=r>>o,l=0;l<6;l++){var c=s*s*4,u=new Uint8Array(t,a,c);a+=c,n.setPixelBuffer(nc.PositiveX+l,u,o)}return n},t}(o9);cI=ce([op(oo.Env,["env"])],cI);var cN=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return l6(t,e),t.prototype.restoreContent=function(){var e=this;return new nb(function(t,n){var r=e.resource,i=r.engine;i.resourceManager._request(e.url,e.requestConfig).then(function(e){cI._setTextureByBuffer(i,e,r),t(r)}).catch(n)})},t}(ns);function cO(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 cV(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){cO(a,r,i,o,s,"next",e)}function s(e){cO(a,r,i,o,s,"throw",e)}o(void 0)})}}var ck=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nb(function(r,i){t._request(e.url,l5({},e,{type:"json"})).then(function(e){var a=e.fontName,o=e.fontUrl;o?n._registerFont(a,o).then(function(){r(new nO(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new nO(t.engine,a))}).catch(function(e){i(e)})})},n._registerFont=function(e,t){return cV(function(){var n;return ct(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}(o9);function cU(){if(ty)return ty;var e,t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),n=nC._detectSIMDSupported()?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";function r(e){for(var n=new Uint8Array(e.length),r=0;r<e.length;++r){var i=e.charCodeAt(r);n[r]=i>96?i-97:i>64?i-39:i+4}for(var a=0,o=0;o<e.length;++o)n[a++]=n[o]<60?t[n[o]]:(n[o]-60)*64+n[++o];return n.buffer.slice(0,a)}ty=WebAssembly.instantiate(r(n)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:ty,useWorkers:function(e){this.workerCount=null!=e?e:this.workerCount,function(e){for(var t=new Blob(["var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r(n))+']), {}).then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\nself.onmessage = workerProcess;\nfunction decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\nfunction workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }'],{type:"text/javascript"}),i=URL.createObjectURL(t),a=0;a<e;++a)o[a]=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}(i);URL.revokeObjectURL(i)}(this.workerCount)},decodeGltfBuffer:function(t,n,r,l,c){return(this.workerCount>0&&0===o.length&&this.useWorkers(),o.length>0)?function(e,t,n,r,i){for(var a=o[0],l=1;l<o.length;++l)o[l].pending<a.pending&&(a=o[l]);return new Promise(function(o,l){var c=new Uint8Array(n),u=s++;a.pending+=e,a.requests[u]={resolve:o,reject:l},a.object.postMessage({id:u,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}(t,n,r,a[l],i[c]):ty.then(function(){var o=new Uint8Array(t*n);return function(t,n,r,i,a,o){var s=e.exports.sbrk,l=r+3&-4,c=s(l*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var h=t(c,r,i,u,a.length);if(0==h&&o&&o(c,l,i),n.set(d.subarray(c,c+r*i)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)}(e.exports[a[l]],o,t,n,r,e.exports[i[c]]),o})},release:function(){for(var e=0;e<o.length;e++)o[e].object.terminate()}}});var i={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},a={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},o=[],s=0;return ty}ck=ce([op(oo.Font,["font"])],ck);var cz=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r}l6(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)},cr(t,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),t}(no),cG=((tr={})[tr.BYTE=5120]="BYTE",tr[tr.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",tr[tr.SHORT=5122]="SHORT",tr[tr.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",tr[tr.UNSIGNED_INT=5125]="UNSIGNED_INT",tr[tr.FLOAT=5126]="FLOAT",tr),cH=((ti={}).SCALAR="SCALAR",ti.VEC2="VEC2",ti.VEC3="VEC3",ti.VEC4="VEC4",ti.MAT2="MAT2",ti.MAT3="MAT3",ti.MAT4="MAT4",ti),cX=((ta={}).TRANSLATION="translation",ta.ROTATION="rotation",ta.SCALE="scale",ta.WEIGHTS="weights",ta),cW=((to={}).Linear="LINEAR",to.Step="STEP",to.CubicSpine="CUBICSPLINE",to),cj=((ts={}).PERSPECTIVE="perspective",ts.ORTHOGRAPHIC="orthographic",ts),cY=((tl={}).OPAQUE="OPAQUE",tl.MASK="MASK",tl.BLEND="BLEND",tl),cK=((tc={})[tc.NEAREST=9728]="NEAREST",tc[tc.LINEAR=9729]="LINEAR",tc),cQ=((tu={})[tu.NEAREST=9728]="NEAREST",tu[tu.LINEAR=9729]="LINEAR",tu[tu.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",tu[tu.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",tu[tu.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",tu[tu.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",tu),cq=((td={})[td.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",td[td.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",td[td.REPEAT=10497]="REPEAT",td),cZ=/*#__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 uo(e)}var t=e.prototype;return t.get=function(t,n){var r=this,i=e._parsers[t];if(!i)return nb.resolve(null);var a=this._resourceCache,o=void 0===n?""+t:t+":"+n,s=a.get(o);if(s)return s;var l=c0[t],c=!!c1[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)}):nb.all(u.map(function(e,n){return r.get(t,n)})):(s=i.parse(this,n),c&&this._handleSubAsset(s,t,n)):s=nb.resolve(null)}else s=i.parse(this,n),c&&this._handleSubAsset(s,t,n);return cx(s,nb)&&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),nb.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(sO).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=c1[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){nA.error("GLTFParserContext","Failed to load "+a+" "+n+": "+e)})}},e.addParser=function(e,t){this._parsers[e]=t},e}();cZ._parsers={};var cJ=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},c$=((th={})[th.Schema=0]="Schema",th[th.Validator=1]="Validator",th[th.Scene=2]="Scene",th[th.Buffer=3]="Buffer",th[th.BufferView=4]="BufferView",th[th.Texture=5]="Texture",th[th.Material=6]="Material",th[th.Mesh=7]="Mesh",th[th.Entity=8]="Entity",th[th.Skin=9]="Skin",th[th.Animation=10]="Animation",th[th.AnimatorController=11]="AnimatorController",th),c0=((tx={})[2]="scenes",tx[3]="buffers",tx[5]="textures",tx[6]="materials",tx[7]="meshes",tx[8]="nodes",tx[9]="skins",tx[10]="animations",tx[4]="bufferViews",tx),c1=((tA={})[2]="_sceneRoots",tA[5]="textures",tA[6]="materials",tA[7]="meshes",tA[8]="entities",tA[9]="skins",tA[10]="animations",tA[11]="animatorController",tA);function c2(e){return function(t){var n=new t;cZ.addParser(e,n)}}var c3=/*#__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 tk(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 tq(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 tZ(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new tZ(e[a],e[a+1],e[a+2],e[a+3]);return r},e.getAccessorTypeSize=function(e){switch(e){case cH.SCALAR:return 1;case cH.VEC2:return 2;case cH.VEC3:return 3;case cH.VEC4:case cH.MAT2:return 4;case cH.MAT3:return 9;case cH.MAT4:return 16}},e.getComponentType=function(e){switch(e){case cG.BYTE:return Int8Array;case cG.UNSIGNED_BYTE:return Uint8Array;case cG.SHORT:return Int16Array;case cG.UNSIGNED_SHORT:return Uint16Array;case cG.UNSIGNED_INT:return Uint32Array;case cG.FLOAT:return Float32Array}},e.getNormalizedComponentScale=function(e){switch(e){case cG.BYTE:return 1/127;case cG.UNSIGNED_BYTE:return 1/255;case cG.SHORT:return 1/32767;case cG.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(c$.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 cJ(S,!0,g),_.restoreInfo=new ud(new uh(f,o,A,b))}}else{var T=p+m,C=u*s;(_=new cJ(new o(e.buffer,T,C),!1,c)).restoreInfo=new ud(new uh(f,o,T,C))}return _}).catch(function(e){nA.error("GLTFUtil getAccessorBuffer error",e)})}else{var _=u*s,f=new cJ(new o(_),!1,c);f.restoreInfo=new ud(new uh(void 0,o,void 0,_)),i=nb.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 tk(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 nb.all([t.get(c$.BufferView,d.bufferView),t.get(c$.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,T=new b(m.buffer,v,S);i.sparseIndices=new uh(_.buffer,b,v,S);var C=A/s.BYTES_PER_ELEMENT,R=new s(g.buffer,x,C);i.sparseValues=new uh(f.buffer,s,x,C);for(var E=0;E<u;E++)for(var M=T[E],P=0;P<o;P++)l[M*o+P]=R[E*o+P];r.data=l}).catch(function(e){nA.error("GLTFUtil processingSparseData error",e)})},e.getIndexFormat=function(e){switch(e){case cG.UNSIGNED_BYTE:return ay.UInt8;case cG.UNSIGNED_SHORT:return ay.UInt16;case cG.UNSIGNED_INT:return ay.UInt32}},e.getElementFormat=function(e,t,n){if(void 0===n&&(n=!1),e==cG.FLOAT)switch(t){case 1:return ax.Float;case 2:return ax.Vector2;case 3:return ax.Vector3;case 4:return ax.Vector4}if(e==cG.SHORT)switch(t){case 2:return n?ax.NormalizedShort2:ax.Short2;case 3:case 4:return n?ax.NormalizedShort4:ax.Short4}if(e==cG.UNSIGNED_SHORT)switch(t){case 2:return n?ax.NormalizedUShort2:ax.UShort2;case 3:case 4:return n?ax.NormalizedUShort4:ax.UShort4}if(e==cG.BYTE)switch(t){case 2:case 3:case 4:return n?ax.NormalizedByte4:ax.Byte4}if(e==cG.UNSIGNED_BYTE)switch(t){case 2:case 3:case 4:return n?ax.NormalizedUByte4:ax.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>=cQ.NEAREST_MIPMAP_NEAREST,n===cK.NEAREST?a.filterMode=nd.Point:t<=cQ.LINEAR_MIPMAP_NEAREST?a.filterMode=nd.Bilinear:a.filterMode=nd.Trilinear),r&&(a.wrapModeU=uM._wrapMap[r]),i&&(a.wrapModeV=uM._wrapMap[i]),a},e}(),c4=((t_={})[t_.linear=1]="linear",t_[t_.sRGB=2]="sRGB",t_),c8=((tf={})[tf.ETC1S=163]="ETC1S",tf[tf.UASTC_LDR_4X4=166]="UASTC_LDR_4X4",tf[tf.UASTC_HDR_4X4=167]="UASTC_HDR_4X4",tf),c5=/*#__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 ci(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 ci(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 ci(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 ci(e,s,l,!0);x.position<l;){var A=x.nextUint32(),b=x.scan(A),S=nX.decodeText(b),T=x.nextUint8Array(A-b.byteLength-1);this.keyValue[S]=S.match(/^ktx/i)?nX.decodeText(T).replace(/^(.*)\x00$/,"$1"):T;var C=A%4?4-A%4:0;x.skip(C)}if(u<=0)return this;for(var R=new ci(e,c,u,!0),E=R.nextUint16(),M=R.nextUint16(),P=R.nextUint32(),w=R.nextUint32(),F=R.nextUint32(),D=R.nextUint32(),B=Array(i),L=0;L<i;L++)B[L]={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,D);this.globalData={endpointCount:E,selectorCount:M,imageDescs:B,endpointsData:k,selectorsData:U,tablesData:z,extendedData:G}},cr(e,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"colorModel",get:function(){return this.dataFormatDescriptor.colorModel}}]),e}(),c9=((tp={})[tp.ASTC=0]="ASTC",tp[tp.BC7=1]="BC7",tp[tp.BC1_BC3=2]="BC1_BC3",tp[tp.PVRTC=3]="PVRTC",tp[tp.ETC=4]="ETC",tp[tp.R8=5]="R8",tp[tp.R8G8=6]="R8G8",tp[tp.R8G8B8A8=7]="R8G8B8A8",tp[tp.BC6H=8]="BC6H",tp[tp.ASTC_HDR_4x4=9]="ASTC_HDR_4x4",tp[tp.R16G16B16A16=10]="R16G16B16A16",tp),c6=/*#__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}(),c7=/*#__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 c6(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 ue(){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=un(n.buffer,n.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var ut=function(e){return tm||(tm=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})),tm};function un(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 ur=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}l6(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(){ut(r).then(function(){e(null)})},i.onerror=function(){t()}});var i=ue.toString(),a=i.substring(i.indexOf("{"),i.lastIndexOf("}")+1),o="\n "+n+"\n "+un.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?ut().then(function(n){return un(e,t,n)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},t}(c7),ui=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(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 nb(function(r,i,a,o){var s=l5({},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 ua(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 c5(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 nw(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 nM(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(nc.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!==c9.PVRTC||tV.isPowerOf2(a)&&tV.isPowerOf2(o)&&a===o?null===s?(nA.warn("Can't support any compressed texture, downgrade to RGBA8"),c9.R8G8B8A8):s:(nA.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),c9.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?c4.sRGB:c4.linear];if(o){for(var s=0;s<o.length;s++)if(e.canIUse(o[s]))return a}else switch(t[r]){case c9.R8G8B8A8:return a;case c9.R8:case c9.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 ur(e)},t._getEngineTextureFormat=function(e,t){var n=t.hasAlpha;switch(e){case c9.ASTC:return nh.ASTC_4x4;case c9.ETC:return n?nh.ETC2_RGBA8:nh.ETC2_RGB;case c9.BC7:return nh.BC7;case c9.BC1_BC3:return n?nh.BC3:nh.BC1;case c9.PVRTC:return n?nh.PVRTC_RGBA4:nh.PVRTC_RGB4;case c9.R8G8B8A8:return nh.R8G8B8A8;case c9.BC6H:return nh.BC6H;case c9.ASTC_HDR_4x4:return nh.ASTC_4x4;case c9.R16G16B16A16:return nh.R16G16B16A16}},t}(o9);ui._priorityFormats=((tb={})[c8.ETC1S]=[c9.ETC,c9.BC7,c9.ASTC,c9.BC1_BC3,c9.PVRTC],tb[c8.UASTC_LDR_4X4]=[c9.ASTC,c9.BC7,c9.ETC,c9.BC1_BC3,c9.PVRTC],tb[c8.UASTC_HDR_4X4]=[c9.ASTC_HDR_4x4,c9.BC6H,c9.R16G16B16A16],tb),ui._capabilityMap=((tF={})[c9.ASTC]=((tS={})[c4.linear]=[nT.astc,nT.astc_webkit],tS[c4.sRGB]=[nT.astc,nT.astc_webkit],tS),tF[c9.ETC]=((tT={})[c4.linear]=[nT.etc,nT.etc_webkit],tT[c4.sRGB]=[nT.etc,nT.etc_webkit],tT),tF[c9.BC7]=((tC={})[c4.linear]=[nT.bptc],tC[c4.sRGB]=[nT.bptc],tC),tF[c9.BC1_BC3]=((tR={})[c4.linear]=[nT.s3tc],tR[c4.sRGB]=[nT.s3tc_srgb],tR),tF[c9.BC6H]=((tE={})[c4.linear]=[nT.bptc],tE),tF[c9.ASTC_HDR_4x4]=((tM={})[c4.linear]=[nT.astc_hdr],tM),tF[c9.R16G16B16A16]=((tP={})[c4.linear]=[nT.textureHalfFloat],tP),tF[c9.PVRTC]=((tw={})[c4.linear]=[nT.pvrtc,nT.pvrtc_webkit],tw),tF),ui=ce([op(oo.KTX2,["ktx2"])],ui);var ua=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return l6(t,e),t.prototype.restoreContent=function(){var e=this,t=this.resource,n=this.requestConfig,r=t.engine;return new nb(function(i,a){r.resourceManager._request(e.url,n).then(function(e){return ui._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 ui._createTextureByBuffer(r,n.isSRGB,i,a,o,t)})}).then(i).catch(a)})},t}(ns),uo=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.bufferRequests=[],t.glbBufferSlices=[],t.bufferTextures=[],t.meshes=[],t}l6(t,e);var n=t.prototype;return n.restoreContent=function(){var e=this;return new nb(function(t,n){Promise.all(e.bufferRequests.map(function(e){return oh(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)}}nb.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?ui._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)}):c3.loadImageBuffer(i,e.mimeType).then(function(e){a.setImageSource(e),a.generateMipmaps()})})).then(function(){for(var n,i=cb(e.meshes);!(n=i()).done;){for(var a,o=n.value,s=o.mesh,l=cb(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,_=cb(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=c3.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=e._getBufferData(r,v.buffer);p.deltaNormals=c3.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=c3.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}(ns),us=function(e,t){this.url=e,this.config=t},ul=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},uc=function(){this.vertexBuffers=[],this.blendShapes=[]},uu=function(e,t){this.buffer=e,this.data=t},ud=function(e,t,n,r,i){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=i},uh=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},u_=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},uf=function(e,t,n,r,i){this.buffer=e,this.byteOffset=t,this.count=n,this.normalized=r,this.componentType=i},up=/*#__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}(),um=((tg={})[tg.CreateAndParse=0]="CreateAndParse",tg[tg.AdditiveParse=1]="AdditiveParse",tg),ug=/*#__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,um.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,um.AdditiveParse);null==c||c.additiveParse.apply(c,[].concat([n,r,i,a],s))},e}();function uv(e,t){return function(n){var r=new n;r._mode=t,ug._addExtensionParser(e,r)}}ug._extensionParsers={};var uy=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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=c3.parseGLB(e,t);return(null==n?void 0:n.glTF)&&a.push(new us(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}(ug);uy=ce([c2(c$.Schema)],uy);var ux=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.parse=function(e,n){var r=e.glTF.animations[n],i=r.name,a=ug.executeExtensionsCreateAndParse(r.extensions,e,r)||t._parseStandardProperty(e,new su(void 0===i?"AnimationClip"+n:i),r);return nb.resolve(a).then(function(t){return ug.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=nb.all([c3.getAccessorBuffer(e,s,i),c3.getAccessorBuffer(e,s,a)]).then(function(e){var n,i,o=e[0].data,s=e[1].data;if(a.normalized){for(var l=c3.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:cW.Linear){case cW.CubicSpine:i=sd.CubicSpine;break;case cW.Step:i=sd.Step;break;case cW.Linear:i=sd.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(c$.Entity),_=[],f=0;f<u;f++)r(f);return _.push(e.get(c$.Scene)),nb.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 cX.TRANSLATION:f=rU,p="position";break;case cX.ROTATION:f=rU,p="rotationQuaternion";break;case cX.SCALE:f=rU,p="scale";break;case cX.WEIGHTS:f=a5,p="blendShapeWeights"}var m=i._addCurve(s.path,o,d);if(s.path===cX.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 cX.TRANSLATION:case cX.SCALE:for(var s=new sx,l=s.interpolation=r.interpolation,c=0,u=0,d=i.length;u<d;u++){var h=new sW;h.time=i[u],l===sd.CubicSpine?(h.inTangent=new tk(a[c++],a[c++],a[c++]),h.value=new tk(a[c++],a[c++],a[c++]),h.outTangent=new tk(a[c++],a[c++],a[c++])):h.value=new tk(a[c++],a[c++],a[c++]),s.addKey(h)}return s;case cX.ROTATION:for(var _=new sv,f=_.interpolation=r.interpolation,p=0,m=0,g=i.length;m<g;m++){var v=new sW;v.time=i[m],f===sd.CubicSpine?(v.inTangent=new tq(a[p++],a[p++],a[p++],a[p++]),v.value=new tj(a[p++],a[p++],a[p++],a[p++]),v.outTangent=new tq(a[p++],a[p++],a[p++],a[p++])):v.value=new tj(a[p++],a[p++],a[p++],a[p++]),_.addKey(v)}return _;case cX.WEIGHTS:var y=new sm;y.interpolation=r.interpolation;for(var x=0,A=0,b=i.length;A<b;A++){var S=new sW;S.time=i[A],y.interpolation===sd.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}(ug);ux=ce([c2(c$.Animation)],ux);var uA=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.parse=function(e,t){var n=e.glTF.buffers;return e.buffers?nb.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 us(c,l));var u=i._requestByRemoteUrl(c,l).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(u),u},t}(ug);uA=ce([c2(c$.Buffer)],uA);var ub=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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 a3(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(c$.Entity,p);u.addChild(m)}return ug.executeExtensionsAdditiveAndParse(c,e,u,r),u},t}(ug);ub=ce([c2(c$.Entity)],ub);var uS="GALACEAN_materials_remap",uT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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[uS]&&((r={})[uS]=s[uS],s=r);var l=ug.executeExtensionsCreateAndParse(s,e,i);return l||((l=new r5(o)).name=i.name,t._parseStandardProperty(e,l,i)),nb.resolve(l).then(function(t){return t||(t=o._basicResources._getBlinnPhongMaterial()),ug.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)&&nA.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(c$.Texture,_.index).then(function(t){n.baseTexture=t,ug.executeExtensionsAdditiveAndParse(_.extensions,e,n,_)}).catch(function(e){nA.error("GLTFMaterialParser: baseColorTexture error",e)}),n.constructor===r5&&(n.metallic=null!=f?f:1,n.roughness=null!=p?p:1,m&&(t._checkOtherTextureTransform(m,"Roughness metallic"),e.get(c$.Texture,m.index).then(function(e){n.roughnessMetallicTexture=e}).catch(function(e){nA.error("GLTFMaterialParser: metallicRoughnessTexture error",e)})))}if(n.constructor===r5){if(s&&(t._checkOtherTextureTransform(s,"Emissive"),e.get(c$.Texture,s.index).then(function(e){n.emissiveTexture=e}).catch(function(e){nA.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(c$.Texture,g).then(function(e){n.normalTexture=e}).catch(function(e){nA.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(c$.Texture,y).then(function(e){n.occlusionTexture=e}).catch(function(e){nA.error("GLTFMaterialParser: occlusionTexture error",e)}),void 0!==x&&(n.occlusionTextureIntensity=x),A===r4.UV1?n.occlusionTextureCoord=r4.UV1:A>r4.UV1&&nA.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=r0.Double:n.renderFace=r0.Front,c){case cY.OPAQUE:n.isTransparent=!1;break;case cY.BLEND:n.isTransparent=!0;break;case cY.MASK:n.alphaCutoff=null!=u?u:.5}},t}(ug);uT=ce([c2(c$.Material)],uT);var uC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.parse=function(e,n){for(var r=function(n,r){var c=i.primitives[n];l[n]=new nb(function(r,l){var u=ug.executeExtensionsCreateAndParse(c.extensions,e,c,i);if(u)cx(u,aU)?(u._associationSuperResource(o),r(u)):u.then(function(e){e._associationSuperResource(o),r(e)});else{var d=new aU(s,i.name||n+"");d._associationSuperResource(o);var h=new uc;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 nb.all(l)},t._parseMeshFromGLTFPrimitive=function(e,n,r,i,a,o,s){var l,c=function(i){var a=u[d[i]],c=c3.getAccessorBuffer(e,o.bufferViews,a).then(function(e){var o,c,u,d=c3.getAccessorTypeSize(a.type),h=a.count,_=e.data,f=n.instanceId,v=e.vertexBindingInfos,y=a.normalized,x=c3.getElementFormat(a.componentType,d,y);if(y&&(c=c3.getNormalizedComponentScale(a.componentType)),e.interleaved){var A=a.byteOffset||0,b=e.stride;if(u=A%b,void 0===v[f]){o=new ab(i,u,x,g);var S=e.vertexBuffer;S||(S=new av(p,aS.VertexBuffer,_,am.Static,s),e.vertexBuffer=S,r.vertexBuffers.push(new uu(S,e.restoreInfo))),n.setVertexBufferBinding(S,b,g),v[f]=g++}else o=new ab(i,u,x,v[f])}else{o=new ab(i,u=0,x,g);var T=e.vertexBuffer;T||(T=new av(p,aS.VertexBuffer,_,am.Static,s),r.vertexBuffers.push(new uu(T,e.restoreInfo))),n.setVertexBufferBinding(T,e.stride,g),v[f]=g++}if(m.push(o),"POSITION"===i){l=h;var C=n.bounds,R=C.min,E=C.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 D=P+F*w;M.copyFromArray(_,D),tk.min(R,M,R),tk.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 nb.all(v).then(function(){if(n.setVertexElements(m),void 0!==_){var c=o.accessors[_],u=c3.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 c3.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:c3.bufferToVector3Array(r,i,a,o,s),restoreInfo:new uf(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=nb.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 aM(r);o.addFrame(1,t.vertices,f?i.vertices:null,p?a.vertices:null),n.blendShape=o,n.restoreInfo=new u_(o,t.restoreInfo,f?i.restoreInfo:null,p?null==a?void 0:a.restoreInfo:null)});u.push(m)}(_);return nb.all(u).then(function(){for(var e,r=cb(h);!(e=r()).done;){var i=e.value;t.addBlendShape(i.blendShape),n.blendShapes.push(i.restoreInfo)}})},t}(ug);uC._tempVector3=new tk,uC=ce([c2(c$.Mesh)],uC);var uR=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(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(c$.Entity,u[0]);else{(n=new a3(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=e.get(c$.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 nb.all(_).then(function(){return ug.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(c$.Entity,t);return void 0!==s&&this._createCamera(a,i.cameras[s],c),void 0!==l&&(n=this._createRenderer(e,o,c)),nb.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 nb.all(t)})},n._createCamera=function(e,t,n){var r=t.orthographic,i=t.perspective,a=t.type,o=n.addComponent(rJ);if(a===cj.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===cj.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(c$.Material,null!=(r=l[h].material)?r:-1);return nb.all([e.get(c$.Mesh,a),void 0!==o&&e.get(c$.Skin,o),nb.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(a5);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(aO)).mesh=h;_.setMaterial(c),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),ug.executeExtensionsAdditiveAndParse(d.extensions,e,_,d)}(d)}).catch(function(e){nA.error("GLTFSceneParser: create renderer error",e)})},n._computeLocalBounds=function(e,t,n,r,i){var a=n.indexOf(r);if(-1!==a)tz.transform(t.bounds,i[a],e.localBounds);else{var o=new tY(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?(tY.multiplyScalar(o,1/s,o),tz.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?(tY.add(r,t[c],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},t}(ug);uR=ce([c2(c$.Scene)],uR);var uE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(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 a4(void 0===l?"SKIN_"+t:l);u.inverseBindMatrices.length=c;var d=Array(c),h=r.accessors[a],_=c3.getAccessorBuffer(e,r.bufferViews,h).then(function(t){for(var r=e.get(c$.Entity),i=t.data,a=0;a<c;a++){var l=new tY;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 nb.resolve(_)},n._findSkeletonRootBone=function(e,t){for(var n,r={},i=cb(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}(ug);uE=ce([c2(c$.Skin)],uE);var uM=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(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=ug.executeExtensionsCreateAndParse(l,e,r,n,c);return u||(u=t._parseTexture(e,void 0===o?0:o,n,a,s,c)),nb.resolve(u).then(function(t){return ug.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&&c3.getSamplerInfo(l.samplers[r]);if(h){var v=h.lastIndexOf("."),y=h.substring(v+1).startsWith("ktx")?oo.KTX:oo.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&&c3.parseSampler(e,g),e}),e._addTaskCompletePromise(o)}else{var x=l.bufferViews[_];o=e.get(c$.Buffer).then(function(t){var r=new Uint8Array(t[x.buffer],x.byteOffset,x.byteLength);return c3.loadImageBuffer(r,f).then(function(t){var r,o=t.width,s=t.height,l=nh.R8G8B8A8,u=nE.supportGenerateMipmapsWithCorrection(c,o,s,l,null==(r=null==g?void 0:g.mipmap)||r,a),d=new nw(c,o,s,l,u,a);d.setImageSource(t),d.generateMipmaps(),d.name=i||p||"texture_"+n,m&&c3.parseSampler(d,g);var h=new ul(d,x,f);return e.contentRestorer.bufferTextures.push(h),d})}).catch(function(e){nA.error("GLTFTextureParser: image buffer error",e)})}return o},t}(ug);uM._wrapMap=((tD={})[cq.CLAMP_TO_EDGE]=nf.Clamp,tD[cq.MIRRORED_REPEAT]=nf.Mirror,tD[cq.REPEAT]=nf.Repeat,tD),uM=ce([c2(c$.Texture)],uM);var uP=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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){nA.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++){var s=r[o];ug.hasExtensionParser(s)||nA.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(i){nA.info("extensionsRequired: "+i);for(var l=0;l<i.length;l++){var c=i[l];ug.hasExtensionParser(c)||nA.error("GLTF parser has not supported required extension "+c+".")}}return nb.resolve(null)},t}(ug);uP=ce([c2(c$.Validator)],uP);var uw=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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?ug.executeExtensionsCreateAndParse(r,e,n):e.get(c$.Buffer,s).then(function(e){return new Uint8Array(e,a,o)}).catch(function(e){nA.error("GLTFBufferViewParser: buffer error",e)})},t}(ug);uw=ce([c2(c$.BufferView)],uw);var uF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.parse=function(e){var t=this;return e.needAnimatorController?e.get(c$.Animation).then(function(n){var r=t._createAnimatorController(e,n);return nb.resolve(r)}).catch(function(e){nA.error("GLTFAnimatorControllerParser: animator controller error",e)}):nb.resolve(null)},n._createAnimatorController=function(e,t){var n=new sk(e.glTFResource.engine),r=new sX("layer"),i=new sH;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}(ug);uF=ce([c2(c$.AnimatorController)],uF);var uD=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(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?cU().then(function(e){e.useWorkers(a.workerCount)}):Promise.resolve()},n.load=function(e,t){var n=e.params,r=new cz(t.engine,e.url),i=new cZ(r,t,l5({keepMeshData:!1},n));return new nb(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(){ty&&cU().then(function(e){e.release()})},t}(o9);uD=ce([op(oo.GLTF,["gltf","glb"])],uD);var uB=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t,n)||this).prefabResource=r,i}l6(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 cS(e,n),a=new t(r,new cg(e,cm.Prefab,i),i);return a.start(),a.promise.then(function(){return i})},t}(cT),uL=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=t.engine;return new nb(function(r,i){t._request(e.url,l5({},e,{type:"json"})).then(function(t){uB.parse(n,e.url,t).then(r).catch(i)},i)})},t}(o9);uL=ce([op(oo.Prefab,["prefab"])],uL);var uI=Math.PI,uN=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,n){return new nb(function(r,i){var a=n.engine,o=l5({},e,{type:"arraybuffer"}),s=e.url;n._request(s,o).then(function(e){var n=t._setTextureByBuffer(a,e);a.resourceManager.addContentRestorer(new uO(n,s,o)),r(n)}).catch(i)})},t._setTextureByBuffer=function(e,n,r){var i=new Uint8Array(n),a=t._parseHeader(i),o=a.width,s=a.height,l=a.dataPosition,c=s>>1;r||(r=new nM(e,c,void 0,void 0,!1));for(var u=t._readPixels(i.subarray(l),o,s),d=t._convertToCubemap(u,o,s,c),h=0;h<6;h++)r.setPixelBuffer(nc.PositiveX+h,d[h],0);return r.generateMipmaps(),r},t._convertToCubemap=function(e,t,n,r){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*n*4)throw"ConvertPanoramaToCubemap: input size is wrong";return[this._createCubemapData(r,this._faceRight,e,t,n),this._createCubemapData(r,this._faceLeft,e,t,n),this._createCubemapData(r,this._faceUp,e,t,n),this._createCubemapData(r,this._faceBottom,e,t,n),this._createCubemapData(r,this._faceFront,e,t,n),this._createCubemapData(r,this._faceBack,e,t,n)]},t._createCubemapData=function(e,t,n,r,i){for(var a=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,u=0;u<e;u++){for(var d=this._temp3Vector3.set(0,0,0).add(t[0]),h=this._temp4Vector3.set(0,0,0).add(t[2]),_=0;_<e;_++){var f=this._temp5Vector3.set(0,0,0).add(h).subtract(d).scale(c).add(d);f.normalize();var p=this._calcProjectionSpherical(f,n,r,i);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;a[m]=p.r,a[m+1]=p.g,a[m+2]=p.b,a[m+3]=p.a,d.add(o),h.add(s)}c+=l}return a},t._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-uI;)i+=2*uI;for(;i>uI;)i-=2*uI;var o=i/uI,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/uI*r);l<0?l=0:l>=r&&(l=r-1);var c=(r-l-1)*n*4+4*s;return new tZ(t[c],t[c+1],t[c+2],t[c+3])},t._readStringLine=function(e,t){for(var n="",r="",i=t;i<e.length-t&&"\n"!=(r=String.fromCharCode(e[i]));i++)n+=r;return n},t._parseHeader=function(e){var t=0,n=0,r=this._readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var i=!1,a=!1,o=0;do o+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this._readStringLine(e,o))?a=!0:0==r.length&&(i=!0);while(!i);if(!a)throw"HDR Bad header format, unsupported FORMAT";o+=r.length+1,r=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!s||s.length<3)throw"HDR Bad header format, no size";if(n=parseInt(s[2]),t=parseInt(s[1]),n<8||n>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:o+=r.length+1}},t._readPixels=function(e,t,n){for(var r=e.byteLength,i=new Uint8Array(4*t*n),a=0,o=0,s=4*t,l=new Uint8Array(s),c=n;c>0&&o<r;){var u=e[o++],d=e[o++],h=e[o++],_=e[o++];if(2!=u||2!=d||128&h||t<8||t>32767)return e;if((h<<8|_)!=t)throw"HDR Bad header format, wrong scan line width";for(var f=0,p=void 0;f<s&&o<r;){var m=(p=e[o++])>128;if(m&&(p-=128),0===p||f+p>s)throw"HDR Bad Format, bad scanline data (run)";if(m)for(var g=e[o++],v=0;v<p;v++)l[f++]=g;else l.set(e.subarray(o,o+p),f),f+=p,o+=p}for(var y=0;y<t;y++){var x=0;i[a]=l[y+x],x+=t,i[a+1]=l[y+x],x+=t,i[a+2]=l[y+x],x+=t,i[a+3]=l[y+x],a+=4}c--}return i},t._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},t._linearToRGBM=function(e,t){var n=Math.min(Math.max(e.r,Math.max(e.g,e.b))/t,1),r=65025/((n=Math.ceil(255*n))*t);e.r*=r,e.g*=r,e.b*=r,e.a*=n},t}(o9);uN._rightBottomBack=new tk(1,-1,-1),uN._rightBottomFront=new tk(1,-1,1),uN._rightUpBack=new tk(1,1,-1),uN._rightUpFront=new tk(1,1,1),uN._leftBottomBack=new tk(-1,-1,-1),uN._leftBottomFront=new tk(-1,-1,1),uN._leftUpBack=new tk(-1,1,-1),uN._leftUpFront=new tk(-1,1,1),uN._faceRight=[uN._rightBottomBack,uN._rightBottomFront,uN._rightUpBack,uN._rightUpFront],uN._faceLeft=[uN._leftBottomFront,uN._leftBottomBack,uN._leftUpFront,uN._leftUpBack],uN._faceUp=[uN._leftBottomFront,uN._rightBottomFront,uN._leftBottomBack,uN._rightBottomBack],uN._faceBottom=[uN._leftUpBack,uN._rightUpBack,uN._leftUpFront,uN._rightUpFront],uN._faceFront=[uN._leftBottomBack,uN._rightBottomBack,uN._leftUpBack,uN._rightUpBack],uN._faceBack=[uN._rightBottomFront,uN._leftBottomFront,uN._rightUpFront,uN._leftUpFront],uN._tempVector3=new tk,uN._temp2Vector3=new tk,uN._temp3Vector3=new tk,uN._temp4Vector3=new tk,uN._temp5Vector3=new tk,uN=ce([op(oo.HDR,["hdr"])],uN);var uO=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return l6(t,e),t.prototype.restoreContent=function(){var e=this;return new nb(function(t,n){var r=e.resource,i=r.engine;i.resourceManager._request(e.url,e.requestConfig).then(function(e){uN._setTextureByBuffer(i,e,r),t(r)}).catch(n)})},t}(ns),uV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){return t._request(e.url,l5({},e,{type:"json"})).then(function(e){var n=new o7(t.engine);return n.data=e,n})},t}(o9);uV=ce([op(oo.JSON,["json"])],uV);var uk={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 lk.RGB_S3TC_DXT1_EXT:return nh.BC1;case lk.RGBA_S3TC_DXT5_EXT:return nh.BC3;case lk.RGBA_BPTC_UNORM_EXT:return nh.BC7;case lk.RGB_ETC1_WEBGL:return nh.ETC1_RGB;case lk.RGB8_ETC2:return nh.ETC2_RGB;case lk.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return nh.ETC2_RGBA5;case lk.RGBA8_ETC2_EAC:return nh.ETC2_RGBA8;case lk.RGB_PVRTC_2BPPV1_IMG:return nh.PVRTC_RGB2;case lk.RGBA_PVRTC_2BPPV1_IMG:return nh.PVRTC_RGBA2;case lk.RGB_PVRTC_4BPPV1_IMG:return nh.PVRTC_RGB4;case lk.RGBA_PVRTC_4BPPV1_IMG:return nh.PVRTC_RGBA4;case lk.RGBA_ASTC_4X4_KHR:return nh.ASTC_4x4;case lk.RGBA_ASTC_5X5_KHR:return nh.ASTC_5x5;case lk.RGBA_ASTC_6X6_KHR:return nh.ASTC_6x6;case lk.RGBA_ASTC_8X8_KHR:return nh.ASTC_8x8;case lk.RGBA_ASTC_10X10_KHR:return nh.ASTC_10x10;case lk.RGBA_ASTC_12X12_KHR:return nh.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+lk[e])}}(s.glInternalFormat)),s}};function uU(e){var t=uk.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var uz=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){return new nb(function(n,r){Promise.all(e.urls.map(function(n){return t._request(n,l5({},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=uk.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 nM(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(nc.PositiveX+c,_,d,0,0,f,p)}n(l)}).catch(function(e){r(e)})})},t}(o9);uz=ce([op(oo.KTXCube,[])],uz);var uG=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=l5({},e,{type:"arraybuffer"});return new nb(function(r,i){t._request(e.url,n).then(function(i){for(var a=uU(i),o=a.width,s=a.height,l=a.mipmaps,c=a.engineFormat,u=l.length>1,d=new nw(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 uH(d,e.url,n)),r(d)}).catch(function(e){i(e)})})},t}(o9);uG=ce([op(oo.KTX,["ktx"])],uG);var uH=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return l6(t,e),t.prototype.restoreContent=function(){var e=this,t=this.resource,n=t.engine;return new nb(function(r,i){n.resourceManager._request(e.url,e.requestConfig).then(function(e){for(var n=uU(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}(ns),uX=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nb(function(r,i){t._request(e.url,l5({},e,{type:"json"})).then(function(e){var i=t.engine,a=e.shaderRef,o=e.shader,s=rE.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 cE.Vector2:u.setVector2(e,new tQ(i.x,i.y));break;case cE.Vector3:u.setVector3(e,new tk(i.x,i.y,i.z));break;case cE.Vector4:u.setVector4(e,new tq(i.x,i.y,i.z,i.w));break;case cE.Color:u.setColor(e,new tZ(i.r,i.g,i.b,i.a));break;case cE.Float:u.setFloat(e,i);break;case cE.Texture:c.push(n.resourceManager.getResourceByRef(i).then(function(t){u.setTexture(e,t)}));break;case cE.Boolean:u.setInt(e,i?1:0);break;case cE.Integer:u.setInt(e,Number(i))}},i=e.name,a=e.shaderData,o=e.macros,s=e.renderState,l=new r1(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":l7(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}(o9);uX=ce([op(oo.Material,["json"])],uX);var uW=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=l5({},e,{type:"arraybuffer"}),r=e.url;return new nb(function(e,i){t._request(r,n).then(function(e){return cw(e,t.engine)}).then(function(i){t.addContentRestorer(new uj(i,r,n)),e(i)}).catch(i)})},t}(o9);uW=ce([op(oo.Mesh,["mesh"])],uW);var uj=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return l6(t,e),t.prototype.restoreContent=function(){var e=this,t=this.resource,n=t.engine;return new nb(function(r,i){n.resourceManager._request(e.url,e.requestConfig).then(function(e){return cw(e,n,t)}).then(function(e){r(e)}).catch(i)})},t}(ns),uY=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=t.engine;return t._request(e.url,l5({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return aJ.createSubdivisionSurfaceSphere(n,e.sphereRadius,e.sphereStep);case"capsule":return aJ.createCapsule(n,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return aJ.createCone(n,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return aJ.createCuboid(n,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return aJ.createCylinder(n,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return aJ.createPlane(n,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return aJ.createTorus(n,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},t}(o9);uY=ce([op(oo.PrimitiveMesh,["mesh"],!1)],uY);var uK=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=t.engine;return new nb(function(r,i,a){t._request(e.url,l5({},e,{type:"json"})).then(function(e){return n.resourceManager.initVirtualResources(e.files),t.load({type:oo.Scene,url:e.scene}).onProgress(a).then(function(e){n.sceneManager.activeScene=e,r()})}).catch(i)})},t}(o9);uK=ce([op(oo.Project,["proj"],!1)],uK);var uQ=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nb(function(r,i){var a=t._getRemoteUrl(e.url);n._registerFont(a,a).then(function(){r(new nO(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},n._registerFont=function(e,t){return cV(function(){var n;return ct(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}(o9);uQ=ce([op(oo.SourceFont,["ttf","otf","woff"])],uQ);var uq=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._tempRect=new tJ,t._tempVec2=new tQ,t._tempVec4=new tq,t}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new nb(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,l5({},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 nZ(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:oo.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);nb.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 n4(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}(o9);uq=ce([op(oo.SpriteAtlas,["atlas"])],uq);var uZ=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return t._request(e.url,l5({},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 n4(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 nb(function(n){var r=new n4(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}(o9);uZ=ce([op(oo.Sprite,["sprite"])],uZ);var uJ=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){return t._request(e.url,l5({},e,{type:"text"})).then(function(e){var n=new o6(t.engine);return n.text=e,n})},t}(o9);uJ=ce([op(oo.Text,["txt"])],uJ);var u$=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).url=n,i.requestConfig=r,i}return l6(t,e),t.prototype.restoreContent=function(){var e=this;return oh(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},t}(ns),u0=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){return new nb(function(n,r,i,a){var o=e.url,s=l5({},e,{type:"image"});t._request(o,s).onProgress(i,a).then(function(r){var i,a=null!=(i=e.params)?i:{},l=a.format,c=void 0===l?nh.R8G8B8A8:l,u=a.anisoLevel,d=a.wrapModeU,h=a.wrapModeV,_=a.filterMode,f=a.isSRGBColorSpace,p=void 0===f||f,m=a.mipmap,g=r.width,v=r.height,y=t.engine,x=nE.supportGenerateMipmapsWithCorrection(y,g,v,c,void 0===m||m,p),A=new nw(y,g,v,c,x,p);if(A.anisoLevel=null!=u?u:A.anisoLevel,A.filterMode=null!=_?_:A.filterMode,A.wrapModeU=null!=d?d:A.wrapModeU,A.wrapModeV=null!=h?h:A.wrapModeV,A.setImageSource(r),x&&A.generateMipmaps(),0!==o.indexOf("data:")){var b=o.lastIndexOf("/");A.name=o.substring(b+1)}t.addContentRestorer(new u$(A,o,s)),n(A)}).catch(function(e){r(e)})})},t}(o9);u0=ce([op(oo.Texture2D,["png","jpg","webp","jpeg"])],u0);var u1=/*#__PURE__*/function(e){function t(t,n,r){var i;return(i=e.call(this,t)||this).urls=n,i.requestConfig=r,i}return l6(t,e),t.prototype.restoreContent=function(){var e=this;return new nb(function(t,n){Promise.all(e.urls.map(function(t){return oh(t,e.requestConfig)})).then(function(n){for(var r=e.resource,i=0;i<6;i++)r.setImageSource(nc.PositiveX+i,n[i],0);r.generateMipmaps(),t(r)}).catch(function(e){n(e)})})},t}(ns),u2=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){return new nb(function(n,r){var i=e.urls,a=l5({},e,{type:"image"});Promise.all(i.map(function(e){return t._request(e,a)})).then(function(r){var o,s=null!=(o=e.params)?o:{},l=s.format,c=void 0===l?nh.R8G8B8A8:l,u=s.anisoLevel,d=s.wrapModeU,h=s.wrapModeV,_=s.filterMode,f=s.isSRGBColorSpace,p=void 0===f||f,m=s.mipmap,g=r[0],v=g.width,y=g.height;if(v!==y){console.error("The cube texture must have the same width and height");return}var x=t.engine,A=nE.supportGenerateMipmapsWithCorrection(x,v,y,c,void 0===m||m,p),b=new nM(x,v,c,A,p);b.anisoLevel=null!=u?u:b.anisoLevel,b.filterMode=null!=_?_:b.filterMode,b.wrapModeU=null!=d?d:b.wrapModeU,b.wrapModeV=null!=h?h:b.wrapModeV;for(var S=0;S<6;S++)b.setImageSource(nc.PositiveX+S,r[S],0);A&&b.generateMipmaps(),t.addContentRestorer(new u1(b,i,a)),n(b)}).catch(function(e){r(e)})})},t}(o9);u2=ce([op(oo.TextureCube,[""])],u2);var u3=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){return new nb(function(n,r){var i=e.url,a=l5({},e,{type:"arraybuffer"});t._request(i,a).then(function(e){var a=new lI(t.engine);lN.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}(o9);u3=ce([op(oo.Audio,["mp3","ogg","wav"])],u3);var u4=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,n){var r=e.url;return n._request(r,l5({},e,{type:"text"})).then(function(e){return r_.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=cb(o);!(i=s()).done;){var l=i.value,c=nX.resolveAbsoluteUrl(n,l[1]);rh[c.substring(1)]||a.push(c)}return Promise.all(a.map(function(e){return r.load({type:"ShaderChunk",url:e})}))},t}(o9);u4._shaderIncludeRegex=/#include\s+"([./][^\\"]+)"/gm,u4=ce([op("ShaderChunk",["glsl"])],u4);var u8=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}l6(t,e);var n=t.prototype;return n.load=function(e,t){var n=this,r=e.url;return t._request(r,l5({},e,{type:"text"})).then(function(e){var i=n._getBuiltinShader(e);return i?rE.find(i):u4._loadChunksInCode(e,r,t).then(function(){return rE.create(e,void 0,r)})})},n._getBuiltinShader=function(e){var n=e.match(t._builtinRegex);if(n&&n[1])return n[1]},t}(o9);u8._builtinRegex=/^\s*\/\/\s*@builtin\s+(\w+)/,u8=ce([op(oo.Shader,["gs","gsl"])],u8);var u5=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){return t._request(e.url,l5({},e,{type:"json"})).then(function(e){var t=new iE;return t.bounciness=e.bounciness,t.dynamicFriction=e.dynamicFriction,t.staticFriction=e.staticFriction,t.bounceCombine=e.bounceCombine,t.frictionCombine=e.frictionCombine,t})},t}(o9);u5=ce([op(oo.PhysicsMaterial,["mesh"])],u5);var u9=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.load=function(e,t){var n=t.engine;return new nb(function(r,i,a){t._request(e.url,l5({},e,{type:"json"})).then(function(e){var i,o=new o3(n,null!=(i=e.name)?i:""),s=new cg(n,cm.Scene,o),l=new cP(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===cM.Custom,c=s.diffuseMode===oQ.SphericalHarmonics;o.ambientLight.diffuseIntensity=s.diffuseIntensity,o.ambientLight.specularIntensity=s.specularIntensity,o.ambientLight.diffuseMode=s.diffuseMode,o.ambientLight.diffuseSolidColor.copyFrom(s.diffuseSolidColor),o.ambientLight.specularTextureDecodeRGBM=!0,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 n8.SolidColor:o.background.solidColor.copyFrom(u.color);break;case n8.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 nA.warn("Sky background mode requires skyMesh and skyMaterial");break;case n8.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&&nA.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}(o9);u9=ce([op(oo.Scene,["scene"],!0)],u9),cv.registerCustomParseComponent("TextRenderer",/*#__PURE__*/cV(function(e,t){var n;return ct(this,function(r){return(n=t.props).font||(e.font=nO.createFromOS(e.engine,n.fontFamily||"Arial")),[2,e]})}));var u6=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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(oJ):"point"===l?r=t.addComponent(o$):"spot"===l&&(r=t.addComponent(o0)),a&&r.color.set(a[0]*s,a[1]*s,a[2]*s,1),c&&!cx(r,oJ)&&(r.distance=c),u&&cx(r,o0)){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}(up);u6=ce([uv("KHR_lights_punctual",um.AdditiveParse)],u6);var u7=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&(uT._checkOtherTextureTransform(i,"Clear coat"),e.get(c$.Texture,i.index).then(function(e){t.clearCoatTexture=e}).catch(function(e){nA.error("KHR_materials_clearcoat: clearcoat texture error",e)})),o&&(uT._checkOtherTextureTransform(o,"Clear coat roughness"),e.get(c$.Texture,o.index).then(function(e){t.clearCoatRoughnessTexture=e}).catch(function(e){nA.error("KHR_materials_clearcoat: clearcoat roughness texture error",e)})),s&&(uT._checkOtherTextureTransform(s,"Clear coat normal"),e.get(c$.Texture,s.index).then(function(e){t.clearCoatNormalTexture=e}).catch(function(e){nA.error("KHR_materials_clearcoat: clearcoat normal texture error",e)}))},t}(up);u7=ce([uv("KHR_materials_clearcoat",um.AdditiveParse)],u7);var de=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},t}(up);de=ce([uv("KHR_materials_ior",um.AdditiveParse)],de);var dt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&(uT._checkOtherTextureTransform(i,"Sheen texture"),e.get(c$.Texture,i.index).then(function(e){t.sheenColorTexture=e}).catch(function(e){nA.error("KHR_materials_sheen: sheenColorTexture error",e)})),o&&(uT._checkOtherTextureTransform(o,"SheenRoughness texture"),e.get(c$.Texture,o.index).then(function(e){t.sheenRoughnessTexture=e}).catch(function(e){nA.error("KHR_materials_sheen: sheenRoughnessTexture error",e)}))},t}(up);dt=ce([uv("KHR_materials_sheen",um.AdditiveParse)],dt);var dn=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.transmissionFactor,i=n.transmissionTexture;t.transmission=void 0===r?0:r,i&&(uT._checkOtherTextureTransform(i,"Transmission texture"),e.get(c$.Texture,i.index).then(function(e){t.transmissionTexture=e}).catch(function(e){nA.error("KHR_materials_transmission: transmission texture error",e)}))},t}(up);dn=ce([uv("KHR_materials_transmission",um.AdditiveParse)],dn);var dr=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.createAndParse=function(e,t,n){var r=new r9(e.glTFResource.engine);return r.name=n.name,uT._parseStandardProperty(e,r,n),r},t}(up);dr=ce([uv("KHR_materials_unlit",um.CreateAndParse)],dr);var di=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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(c$.Material,s).then(function(e){o.push({renderer:t,material:e,variants:l.map(function(e){return r[e].name})})}).catch(function(e){nA.error("KHR_materials_variants: material error",e)})}(s)},t}(up);di=ce([uv("KHR_materials_variants",um.AdditiveParse)],di);var da=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&(uT._checkOtherTextureTransform(i,"Thickness texture"),e.get(c$.Texture,i.index).then(function(e){t.thicknessTexture=e}).catch(function(e){nA.error("KHR_materials_volume: thickness texture error",e)}))},t}(up);da=ce([uv("KHR_materials_volume",um.AdditiveParse)],da);var ds=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t}(up);ds=ce([uv("KHR_mesh_quantization",um.AdditiveParse)],ds);var dl=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&c3.getSamplerInfo(r.samplers[s]);if(d){var m=d.lastIndexOf("."),g=a.resourceManager.load({url:nX.resolveAbsoluteUrl(o,d),type:oo.KTX2}).onProgress(void 0,e._onTaskDetail).then(function(e){return e.name||(e.name=l||f||"texture_"+m),void 0!==s&&c3.parseSampler(e,p),e});return e._addTaskCompletePromise(g),g}var v=r.bufferViews[h];return e.get(c$.Buffer,v.buffer).then(function(t){var n=new Uint8Array(t,v.byteOffset,v.byteLength);return ui._parseBuffer(n,a).then(function(e){var t=e.ktx2Container,n=e.engine,r=e.result,i=e.targetFormat,a=e.params;return ui._createTextureByBuffer(n,t.isSRGB,r,i,a)}).then(function(t){t.name=l||f||"texture_"+h,void 0!==s&&c3.parseSampler(t,p);var n=new ul(t,v,_);return e.contentRestorer.bufferTextures.push(n),t})}).catch(function(e){nA.error("KHR_texture_basisu: buffer error",e)})},t}(up);dl=ce([uv("KHR_texture_basisu",um.CreateAndParse)],dl);var dc=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&nA.warn("rotation in KHR_texture_transform is not supported now"),o&&nA.warn("texCoord in KHR_texture_transform is not supported now")},t}(up);dc=ce([uv("KHR_texture_transform",um.AdditiveParse)],dc);var du=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.createAndParse=function(e,t){var n=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(n),n},t}(up);du=ce([uv("GALACEAN_materials_remap",um.CreateAndParse)],du);var dd=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new sc;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},t}(up);dd=ce([uv("GALACEAN_animation_event",um.AdditiveParse)],dd);var dh=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(t,e),t.prototype.createAndParse=function(e,t){return e.get(c$.Buffer,t.buffer).then(function(e){return cU().then(function(n){return n.decodeGltfBuffer(t.count,t.byteStride,new Uint8Array(e,t.byteOffset,t.byteLength),t.mode,t.filter)})}).catch(function(e){nA.error("EXT_meshopt_compression: buffer error",e)})},t}(up);dh=ce([uv("EXT_meshopt_compression",um.CreateAndParse)],dh);var d_=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&(uT._checkOtherTextureTransform(a,"Anisotropy texture"),e.get(c$.Texture,a.index).then(function(e){t.anisotropyTexture=e}).catch(function(e){nA.error("KHR_materials_anisotropy: anisotropy texture error",e)}))},t}(up);d_=ce([uv("KHR_materials_anisotropy",um.AdditiveParse)],d_);var df=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&(uT._checkOtherTextureTransform(i,"Iridescence texture"),e.get(c$.Texture,i.index).then(function(e){t.iridescenceTexture=e}).catch(function(e){nA.error("KHR_materials_iridescence: iridescence texture error",e)})),l&&(uT._checkOtherTextureTransform(l,"IridescenceThickness texture"),e.get(c$.Texture,l.index).then(function(e){t.iridescenceThicknessTexture=e}).catch(function(e){nA.error("KHR_materials_iridescence: iridescence thickness error",e)}))},t}(up);df=ce([uv("KHR_materials_iridescence",um.AdditiveParse)],df);var dp=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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&&(uT._checkOtherTextureTransform(i,"Specular intensity texture"),e.get(c$.Texture,i.index).then(function(e){t.specularIntensityTexture=e}).catch(function(e){nA.error("KHR_materials_specular: specularTexture error",e)})),o&&(uT._checkOtherTextureTransform(o,"Specular color texture"),e.get(c$.Texture,o.index).then(function(e){t.specularColorTexture=e}).catch(function(e){nA.error("KHR_materials_specular: SpecularColorTexture error",e)}))},t}(up);dp=ce([uv("KHR_materials_specular",um.AdditiveParse)],dp);var dm=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return l6(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 nC._checkWebpSupported().then(function(t){return uM._parseTexture(e,t?a:l,r,o,c,i)})},t}(up);dm=ce([uv("EXT_texture_webp",um.CreateAndParse)],dm);var dg="2.0.0-alpha.5";for(var dv in console.log("Galacean Engine Version: "+dg),lV)o9.registerClass(dv,lV[dv]);export{cH as AccessorType,oq as AmbientLight,o1 as AmbientOcclusion,ir as AmbientOcclusionQuality,s_ as AnimationArrayCurve,sf as AnimationBoolCurve,su as AnimationClip,sl as AnimationClipCurveBinding,cc as AnimationClipDecoder,sp as AnimationColorCurve,sh as AnimationCurve,sc as AnimationEvent,sm as AnimationFloatArrayCurve,sg as AnimationFloatCurve,sv as AnimationQuaternionCurve,sS as AnimationRectCurve,sb as AnimationRefCurve,sT as AnimationStringCurve,sy as AnimationVector2Curve,sx as AnimationVector3Curve,sA as AnimationVector4Curve,sO as Animator,sF as AnimatorCondition,sC as AnimatorConditionMode,sk as AnimatorController,sX as AnimatorControllerLayer,sV as AnimatorControllerParameter,sR as AnimatorCullingMode,sE as AnimatorLayerBlendingMode,sY as AnimatorLayerMask,sG as AnimatorState,sH as AnimatorStateMachine,sD as AnimatorStateTransition,rH as AntiAliasing,nb as AssetPromise,oo as AssetType,lI as AudioClip,lN as AudioManager,lO as AudioSource,rD as Background,n8 as BackgroundMode,n5 as BackgroundTextureFillMode,r2 as BaseMaterial,aa as BasicRenderPipeline,i8 as BatchUtils,n9 as BlendFactor,r$ as BlendMode,n6 as BlendOperation,aM as BlendShape,aR as BlendShapeFrame,rb as BlendState,r3 as BlinnPhongMaterial,r7 as Blitter,im as BloomDownScaleMode,ig as BloomEffect,rk as BoolUpdateFlag,tz as BoundingBox,tX as BoundingFrustum,tU as BoundingSphere,iK as BoxColliderShape,ly as BoxShape,av as Buffer,se as BufferAsset,aS as BufferBindFlag,cJ as BufferInfo,aN as BufferMesh,ci as BufferReader,am as BufferUsage,aA as BufferUtil,lp as Burst,rJ as Camera,rX as CameraClearFlags,rW as CameraModifyFlags,rj as CameraType,oW as Canvas,iZ as CapsuleColliderShape,t5 as CharRenderInfo,iT as CharacterController,lA as CircleShape,oT as ClearableObjectPool,ni as CloneManager,ib as Collider,iM as ColliderShape,iV as ColliderShapeUpAxis,iI as Collision,iF as CollisionDetectionMode,tG as CollisionUtil,tZ as Color,le as ColorOverLifetimeModule,n7 as ColorWriteMask,re as CompareFunction,rL as Component,lS as ConeEmitType,lb as ConeShape,iL as ContactPoint,tB as ContainmentType,ns as ContentRestorer,ik as ControllerCollisionFlag,iS as ControllerNonWalkableMode,lL as CubeProbe,rt as CullMode,ll as CurveKey,nS as DataType,rO as DependentMode,rS as DepthState,rY as DepthTextureMode,oQ as DiffuseMode,oJ as DirectLight,nK as DisorderedArray,rK as Downsampling,iw as DynamicCollider,iD as DynamicColliderConstraints,cC as EditorTextureLoader,ln as EmissionModule,oX as Engine,na as EngineObject,a3 as Entity,a2 as EntityModifyFlags,nz as EventDispatcher,cs as FileHeader,i2 as FinalPass,iG as FixedJoint,oK as FogMode,nO as Font,nB as FontStyle,tI as FrustumFace,nT as GLCapabilityType,lk as GLCompressedTextureInternalFormat,ux as GLTFAnimationParser,uF as GLTFAnimatorControllerParser,uA as GLTFBufferParser,uw as GLTFBufferViewParser,ub as GLTFEntityParser,um as GLTFExtensionMode,up as GLTFExtensionParser,uD as GLTFLoader,uT as GLTFMaterialParser,uC as GLTFMeshParser,ug as GLTFParser,cZ as GLTFParserContext,c$ as GLTFParserType,cz as GLTFResource,uR as GLTFSceneParser,uy as GLTFSchemaParser,uE as GLTFSkinParser,uM as GLTFTextureParser,c3 as GLTFUtils,uP as GLTFValidator,s9 as GradientAlphaKey,s5 as GradientColorKey,lT as HemisphereShape,cT as HierarchyParser,iX as HingeJoint,iB as HitResult,aP as IndexBufferBinding,ay as IndexFormat,oL as InputManager,cl as InterpolableValueType,sd as InterpolationType,o7 as JSONAsset,iU as Joint,ij as JointLimits,iY as JointMotor,ui as KTX2Loader,c9 as KTX2TargetFormat,sW as Keyframe,ob as Keys,rV as Layer,sj as LayerPathMask,oZ as Light,o9 as Loader,nA as Logger,rQ as MSAASamples,la as MainModule,r1 as Material,cE as MaterialLoaderType,tV as MathUtil,tY as Matrix,tW as Matrix3x3,aB as Mesh,iP as MeshColliderShape,iC as MeshColliderShapeCookingFlag,cu as MeshDecoder,aO as MeshRenderer,lC as MeshShape,aT as MeshTopology,aU as ModelMesh,nL as OverflowMode,r5 as PBRMaterial,cg as ParserContext,cm as ParserType,lt as ParticleCompositeCurve,s6 as ParticleCompositeGradient,ls as ParticleCurve,s2 as ParticleCurveMode,lh as ParticleGenerator,s8 as ParticleGradient,s3 as ParticleGradientMode,lf as ParticleMaterial,sZ as ParticleRenderMode,s0 as ParticleRenderer,li as ParticleScaleMode,lx as ParticleShapeArcMode,lv as ParticleShapeType,sJ as ParticleSimulationSpace,s$ as ParticleStopMode,iE as PhysicsMaterial,iR as PhysicsMaterialCombineMode,iN as PhysicsScene,rd as PipelineStage,tH as Plane,iq as PlaneColliderShape,tL as PlaneIntersectionType,t1 as Platform,o$ as PointLight,oR as Pointer,oy as PointerButton,oM as PointerEventData,oP as PointerEventEmitter,oC as PointerPhase,ix as PostProcess,ip as PostProcessEffect,is as PostProcessEffectBoolParameter,ic as PostProcessEffectColorParameter,i_ as PostProcessEffectEnumParameter,io as PostProcessEffectFloatParameter,ia as PostProcessEffectParameter,il as PostProcessEffectTextureParameter,iu as PostProcessEffectVector2Parameter,id as PostProcessEffectVector3Parameter,ih as PostProcessEffectVector4Parameter,iJ as PostProcessManager,i0 as PostProcessPass,i$ as PostProcessPassEvent,i1 as PostProcessUberPass,cS as PrefabResource,aD as Primitive,aJ as PrimitiveMesh,lw as Probe,tj as Quaternion,t0 as Rand,rT as RasterState,tK as Ray,tJ as Rect,no as ReferResource,cv as ReflectionParser,r8 as RefractionMode,nl as RenderBufferDepthFormat,r0 as RenderFace,i4 as RenderQueue,ao as RenderQueueFlags,rn as RenderQueueType,rR as RenderState,rr as RenderStateElementKey,nP as RenderTarget,rA as RenderTargetBlendState,au as Renderer,ad as RendererUpdateFlags,oc as RenderingStatistics,rq as ReplacementFailureStrategy,of as ResourceManager,a7 as ReturnableObjectPool,lo as RotationOverLifetimeModule,os as SafeLoopArray,o3 as Scene,ol as SceneManager,cP as SceneParser,o8 as Script,ag as SetDataOptions,rE as Shader,rM as ShaderData,ri as ShaderDataGroup,r_ as ShaderFactory,ra as ShaderLanguage,rh as ShaderLib,rl as ShaderMacro,rc as ShaderMacroCollection,ry as ShaderPass,nG as ShaderProperty,ro as ShaderPropertyType,rf as ShaderTagKey,ae as ShadowCascadesMode,i9 as ShadowResolution,i6 as ShadowType,nk as SimpleSpriteAssembler,lc as SizeOverLifetimeModule,a4 as Skin,a5 as SkinnedMeshRenderer,rF as Sky,sK as SkyBoxMaterial,sq as SkyProceduralMaterial,nU as SlicedSpriteAssembler,cM as SpecularMode,iQ as SphereColliderShape,lR as SphereShape,t$ as SphericalHarmonics3,o0 as SpotLight,iW as SpringJoint,n4 as Sprite,nZ as SpriteAtlas,nJ as SpriteDrawMode,ah as SpriteMask,n$ as SpriteMaskInteraction,ac as SpriteMaskLayer,n0 as SpriteModifyFlags,a_ as SpriteRenderer,nQ as SpriteTileMode,sz as StateMachineScript,iO as StaticCollider,rs as StencilOperation,rC as StencilState,nN as SubFont,aF as SubMesh,aw as SubPrimitive,rx as SubShader,sQ as SunMode,nC as SystemInfo,o6 as TextAsset,n1 as TextHorizontalAlignment,af as TextRenderer,nI as TextUtils,n2 as TextVerticalAlignment,nR as Texture,nw as Texture2D,nF as Texture2DArray,cy as Texture2DDecoder,r4 as TextureCoordinate,nM as TextureCube,nc as TextureCubeFace,nu as TextureDepthCompareFunction,nd as TextureFilterMode,nh as TextureFormat,lu as TextureSheetAnimationModule,n_ as TextureUsage,nE as TextureUtils,nf as TextureWrapMode,nq as TiledSpriteAssembler,nH as Time,iy as TonemappingEffect,iv as TonemappingMode,lP as TrailMaterial,lM as TrailRenderer,lE as TrailTextureMode,rU as Transform,rz as TransformModifyFlags,r9 as UnlitMaterial,nX as Utils,tQ as Vector2,tk as Vector3,tq as Vector4,ld as VelocityOverLifetimeModule,ak as VertexAttribute,aI as VertexBufferBinding,ab as VertexElement,ax as VertexElementFormat,lW as WebCanvas,lj as WebGLEngine,l8 as WebGLGraphicDevice,l4 as WebGLMode,sB as WrapMode,oH as XRManager,nt as assignmentClone,cw as decode,co as decoder,ca as decoderMap,nr as deepClone,rN as dependentComponents,ne as ignoreClone,uU as parseSingleKTX,uv as registerGLTFExtension,c2 as registerGLTFParser,oD as registerPointerEventEmitter,oh as request,op as resourceLoader,nn as shallowClone,dg as version};
|
|
2
|
+
//# sourceMappingURL=bundled.module.min.js.map
|