!function(e,t){"use strict";class r{constructor(){}static isZero(e){return Math.abs(e)0&&(a=1/Math.sqrt(a),t.x=r*a,t.y=i*a)}static scalarLength(e){var t=e.x,r=e.y;return Math.sqrt(t*t+r*r)}clone(){var e=new i;return this.cloneTo(e),e}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y):this.elements=new Float32Array([this.x,this.y]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1)}static rewriteNumProperty(e,t,r){Object.defineProperty(e,t,{get:function(){return this.elements[r]},set:function(e){this.elements[r]=e}})}}i.ZERO=new i(0,0),i.ONE=new i(1,1);class a{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.z=r,this.w=i}setValue(e,t,r,i){this.x=e,this.y=t,this.z=r,this.w=i}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]}cloneTo(e){var t=e;t.x=this.x,t.y=this.y,t.z=this.z,t.w=this.w}clone(){var e=new a;return this.cloneTo(e),e}static lerp(e,t,r,i){var a=e.x,n=e.y,s=e.z,o=e.w;i.x=a+r*(t.x-a),i.y=n+r*(t.y-n),i.z=s+r*(t.z-s),i.w=o+r*(t.w-o)}static transformByM4x4(e,t,r){var i=e.x,a=e.y,n=e.z,s=e.w,o=t.elements;r.x=i*o[0]+a*o[4]+n*o[8]+s*o[12],r.y=i*o[1]+a*o[5]+n*o[9]+s*o[13],r.z=i*o[2]+a*o[6]+n*o[10]+s*o[14],r.w=i*o[3]+a*o[7]+n*o[11]+s*o[15]}static equals(e,t){return r.nearEqual(Math.abs(e.x),Math.abs(t.x))&&r.nearEqual(Math.abs(e.y),Math.abs(t.y))&&r.nearEqual(Math.abs(e.z),Math.abs(t.z))&&r.nearEqual(Math.abs(e.w),Math.abs(t.w))}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static normalize(e,t){var r=e.length();if(r>0){var i=1/r;t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i}}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z,r.w=e.w-t.w}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z,r.w=e.w*t.w}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w*t}static Clamp(e,t,r,i){var a=e.x,n=e.y,s=e.z,o=e.w,l=t.x,_=t.y,h=t.z,c=t.w,d=r.x,u=r.y,m=r.z,f=r.w;a=(a=a>d?d:a)u?u:n)<_?_:n,s=(s=s>m?m:s)f?f:o)0&&(n=1/Math.sqrt(n),t.x=r*n,t.y=i*n,t.z=a*n)}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t}static lerp(e,t,r,i){var a=e.x,n=e.y,s=e.z;i.x=a+r*(t.x-a),i.y=n+r*(t.y-n),i.z=s+r*(t.z-s)}static transformV3ToV3(e,t,r){var i=n._tempVector4;n.transformV3ToV4(e,t,i),r.x=i.x,r.y=i.y,r.z=i.z}static transformV3ToV4(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.elements;r.x=i*s[0]+a*s[4]+n*s[8]+s[12],r.y=i*s[1]+a*s[5]+n*s[9]+s[13],r.z=i*s[2]+a*s[6]+n*s[10]+s[14],r.w=i*s[3]+a*s[7]+n*s[11]+s[15]}static TransformNormal(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.elements;r.x=i*s[0]+a*s[4]+n*s[8],r.y=i*s[1]+a*s[5]+n*s[9],r.z=i*s[2]+a*s[6]+n*s[10]}static transformCoordinate(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.elements,o=i*s[3]+a*s[7]+n*s[11]+s[15];r.x=(i*s[0]+a*s[4]+n*s[8]+s[12])/o,r.y=(i*s[1]+a*s[5]+n*s[9]+s[13])/o,r.z=(i*s[2]+a*s[6]+n*s[10]+s[14])/o}static Clamp(e,t,r,i){var a=e.x,n=e.y,s=e.z,o=t.x,l=t.y,_=t.z,h=r.x,c=r.y,d=r.z;a=(a=a>h?h:a)c?c:n)d?d:s)<_?_:s,i.x=a,i.y=n,i.z=s}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z}static cross(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.x,o=t.y,l=t.z;r.x=a*l-n*o,r.y=n*s-i*l,r.z=i*o-a*s}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}static equals(e,t){return r.nearEqual(e.x,t.x)&&r.nearEqual(e.y,t.y)&&r.nearEqual(e.z,t.z)}setValue(e,t,r){this.x=e,this.y=t,this.z=r}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2]}cloneTo(e){var t=e;t.x=this.x,t.y=this.y,t.z=this.z}clone(){var e=new n;return this.cloneTo(e),e}toDefault(){this.x=0,this.y=0,this.z=0}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y,this.elements[2]=this.z):this.elements=new Float32Array([this.x,this.y,this.z]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1),i.rewriteNumProperty(this,"z",2)}}var s,o;n._tempVector4=new a,n._ZERO=new n(0,0,0),n._ONE=new n(1,1,1),n._NegativeUnitX=new n(-1,0,0),n._UnitX=new n(1,0,0),n._UnitY=new n(0,1,0),n._UnitZ=new n(0,0,1),n._ForwardRH=new n(0,0,-1),n._ForwardLH=new n(0,0,1),n._Up=new n(0,1,0),(s=e.PBRRenderQuality||(e.PBRRenderQuality={}))[s.High=0]="High",s[s.Low=1]="Low";class l{constructor(){this._defaultPhysicsMemory=16,this._maxLightCount=32,this._lightClusterCount=new n(12,12,12),this._editerEnvironment=!1,this.isAntialias=!0,this.isAlpha=!1,this.premultipliedAlpha=!0,this.isStencil=!0,this.enableMultiLight=!0,this.octreeCulling=!1,this.octreeInitialSize=64,this.octreeInitialCenter=new n(0,0,0),this.octreeMinNodeSize=2,this.octreeLooseness=1.25,this.debugFrustumCulling=!1,this.pbrRenderQuality=e.PBRRenderQuality.High,this._maxAreaLightCountPerClusterAverage=Math.min(4*Math.floor(2048/this._lightClusterCount.z-1),this._maxLightCount)}get defaultPhysicsMemory(){return this._defaultPhysicsMemory}set defaultPhysicsMemory(e){if(e<16)throw"defaultPhysicsMemory must large than 16M";this._defaultPhysicsMemory=e}get maxLightCount(){return this._maxLightCount}set maxLightCount(e){e>2048?(this._maxLightCount=2048,console.warn("Config3D: maxLightCount must less equal 2048.")):this._maxLightCount=e}get lightClusterCount(){return this._lightClusterCount}set lightClusterCount(e){e.x>128||e.y>128||e.z>128?(this._lightClusterCount.setValue(Math.min(e.x,128),Math.min(e.y,128),Math.min(e.z,128)),console.warn("Config3D: lightClusterCount X and Y、Z must less equal 128.")):e.cloneTo(this._lightClusterCount);var t=4*Math.floor(2048/this._lightClusterCount.z-1);t0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){n.subtract(t,e,f.TEMPVector30),n.normalize(f.TEMPVector30,f.TEMPVector30),r.x=Math.asin(f.TEMPVector30.y),r.y=f.arcTanAngle(-f.TEMPVector30.z,-f.TEMPVector30.x)}static createFromAxisAngle(e,t,r){t*=.5;var i=Math.sin(t);r.x=i*e.x,r.y=i*e.y,r.z=i*e.z,r.w=Math.cos(t)}static createFromMatrix4x4(e,t){var r,i,a=e.elements,n=a[0]+a[5]+a[10];n>0?(r=Math.sqrt(n+1),t.w=.5*r,r=.5/r,t.x=(a[6]-a[9])*r,t.y=(a[8]-a[2])*r,t.z=(a[1]-a[4])*r):a[0]>=a[5]&&a[0]>=a[10]?(i=.5/(r=Math.sqrt(1+a[0]-a[5]-a[10])),t.x=.5*r,t.y=(a[1]+a[4])*i,t.z=(a[2]+a[8])*i,t.w=(a[6]-a[9])*i):a[5]>a[10]?(i=.5/(r=Math.sqrt(1+a[5]-a[0]-a[10])),t.x=(a[4]+a[1])*i,t.y=.5*r,t.z=(a[9]+a[6])*i,t.w=(a[8]-a[2])*i):(i=.5/(r=Math.sqrt(1+a[10]-a[0]-a[5])),t.x=(a[8]+a[2])*i,t.y=(a[9]+a[6])*i,t.z=.5*r,t.w=(a[1]-a[4])*i)}static slerp(e,t,r,i){var a,n,s,o,l,_=e.x,h=e.y,c=e.z,d=e.w,u=t.x,m=t.y,f=t.z,E=t.w;return(n=_*u+h*m+c*f+d*E)<0&&(n=-n,u=-u,m=-m,f=-f,E=-E),1-n>1e-6?(a=Math.acos(n),s=Math.sin(a),o=Math.sin((1-r)*a)/s,l=Math.sin(r*a)/s):(o=1-r,l=r),i.x=o*_+l*u,i.y=o*h+l*m,i.z=o*c+l*f,i.w=o*d+l*E,i}static lerp(e,t,r,i){var a=1-r;f.dot(e,t)>=0?(i.x=a*e.x+r*t.x,i.y=a*e.y+r*t.y,i.z=a*e.z+r*t.z,i.w=a*e.w+r*t.w):(i.x=a*e.x-r*t.x,i.y=a*e.y-r*t.y,i.z=a*e.z-r*t.z,i.w=a*e.w-r*t.w),i.normalize(i)}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}scaling(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e}normalize(e){var t=this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w;t>0&&(t=1/Math.sqrt(t),e.x=this.x*t,e.y=this.y*t,e.z=this.z*t,e.w=this.w*t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}rotateX(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.w*r,t.y=this.y*i+this.z*r,t.z=this.z*i-this.y*r,t.w=this.w*i-this.x*r}rotateY(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i-this.z*r,t.y=this.y*i+this.w*r,t.z=this.z*i+this.x*r,t.w=this.w*i-this.y*r}rotateZ(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.y*r,t.y=this.y*i-this.x*r,t.z=this.z*i+this.w*r,t.w=this.w*i-this.z*r}getYawPitchRoll(e){n.transformQuat(n._ForwardRH,this,f.TEMPVector31),n.transformQuat(n._Up,this,f.TEMPVector32);var t=f.TEMPVector32;f.angleTo(n._ZERO,f.TEMPVector31,f.TEMPVector33);var r=f.TEMPVector33;r.x==Math.PI/2?(r.y=f.arcTanAngle(t.z,t.x),r.z=0):r.x==-Math.PI/2?(r.y=f.arcTanAngle(-t.z,-t.x),r.z=0):(_.Matrix4x4.createRotationY(-r.y,_.Matrix4x4.TEMPMatrix0),_.Matrix4x4.createRotationX(-r.x,_.Matrix4x4.TEMPMatrix1),n.transformCoordinate(f.TEMPVector32,_.Matrix4x4.TEMPMatrix0,f.TEMPVector32),n.transformCoordinate(f.TEMPVector32,_.Matrix4x4.TEMPMatrix1,f.TEMPVector32),r.z=f.arcTanAngle(t.y,-t.x)),r.y<=-Math.PI&&(r.y=Math.PI),r.z<=-Math.PI&&(r.z=Math.PI),r.y>=Math.PI&&r.z>=Math.PI&&(r.y=0,r.z=0,r.x=Math.PI-r.x);var i=e;i.x=r.y,i.y=r.x,i.z=r.z}invert(e){var t=this.x,r=this.y,i=this.z,a=this.w,n=t*t+r*r+i*i+a*a,s=n?1/n:0;e.x=-t*s,e.y=-r*s,e.z=-i*s,e.w=a*s}identity(){this.x=0,this.y=0,this.z=0,this.w=1}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]}cloneTo(e){this!==e&&(e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w)}clone(){var e=new f;return this.cloneTo(e),e}equals(e){return r.nearEqual(this.x,e.x)&&r.nearEqual(this.y,e.y)&&r.nearEqual(this.z,e.z)&&r.nearEqual(this.w,e.w)}static rotationLookAt(e,t,r){f.lookAt(n._ZERO,e,t,r)}static lookAt(e,t,r,i){m.lookAt(e,t,r,f._tempMatrix3x3),f.rotationMatrix(f._tempMatrix3x3,i)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static invert(e,t){var i=e.lengthSquared();r.isZero(i)||(i=1/i,t.x=-e.x*i,t.y=-e.y*i,t.z=-e.z*i,t.w=e.w*i)}static rotationMatrix(e,t){var r,i,a=e.elements,n=a[0],s=a[1],o=a[2],l=a[3],_=a[4],h=a[5],c=a[6],d=a[7],u=a[8],m=n+_+u;m>0?(r=Math.sqrt(m+1),t.w=.5*r,r=.5/r,t.x=(h-d)*r,t.y=(c-o)*r,t.z=(s-l)*r):n>=_&&n>=u?(i=.5/(r=Math.sqrt(1+n-_-u)),t.x=.5*r,t.y=(s+l)*i,t.z=(o+c)*i,t.w=(h-d)*i):_>u?(i=.5/(r=Math.sqrt(1+_-n-u)),t.x=(l+s)*i,t.y=.5*r,t.z=(d+h)*i,t.w=(c-o)*i):(i=.5/(r=Math.sqrt(1+u-n-_)),t.x=(c+o)*i,t.y=(d+h)*i,t.z=.5*r,t.w=(s-l)*i)}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y,this.elements[2]=this.z,this.elements[3]=this.w):this.elements=new Float32Array([this.x,this.y,this.z,this.w]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1),i.rewriteNumProperty(this,"z",2),i.rewriteNumProperty(this,"w",3)}}f.TEMPVector30=new n,f.TEMPVector31=new n,f.TEMPVector32=new n,f.TEMPVector33=new n,f._tempMatrix3x3=new m,f.DEFAULT=new f,f.NAN=new f(NaN,NaN,NaN,NaN);class E extends d{constructor(){super(),this.inTangent=new a,this.outTangent=new a,this.value=new f}cloneTo(e){super.cloneTo(e);var t=e;this.inTangent.cloneTo(t.inTangent),this.outTangent.cloneTo(t.outTangent),this.value.cloneTo(t.value)}}class T extends d{constructor(){super(),this.inTangent=new n,this.outTangent=new n,this.value=new n}cloneTo(e){super.cloneTo(e);var t=e;this.inTangent.cloneTo(t.inTangent),this.outTangent.cloneTo(t.outTangent),this.value.cloneTo(t.value)}}class p{static READ_DATA(){p._DATA.offset=p._reader.getUint32(),p._DATA.size=p._reader.getUint32()}static READ_BLOCK(){for(var e=p._BLOCK.count=p._reader.getUint16(),t=p._BLOCK.blockStarts=[],r=p._BLOCK.blockLengths=[],i=0;i0&&(U.params=F=[]),r=0;r>-t-14,g._baseTable[256|e]=1024>>-t-14|32768,g._shiftTable[0|e]=-t-1,g._shiftTable[256|e]=-t-1):t<=15?(g._baseTable[0|e]=t+15<<10,g._baseTable[256|e]=t+15<<10|32768,g._shiftTable[0|e]=13,g._shiftTable[256|e]=13):t<128?(g._baseTable[0|e]=31744,g._baseTable[256|e]=64512,g._shiftTable[0|e]=24,g._shiftTable[256|e]=24):(g._baseTable[0|e]=31744,g._baseTable[256|e]=64512,g._shiftTable[0|e]=13,g._shiftTable[256|e]=13)}for(g._mantissaTable[0]=0,e=1;e<1024;++e){var r=e<<13;for(t=0;0==(8388608&r);)t-=8388608,r<<=1;r&=-8388609,t+=947912704,g._mantissaTable[e]=r|t}for(e=1024;e<2048;++e)g._mantissaTable[e]=939524096+(e-1024<<13);for(g._exponentTable[0]=0,e=1;e<31;++e)g._exponentTable[e]=e<<23;for(g._exponentTable[31]=1199570944,g._exponentTable[32]=2147483648,e=33;e<63;++e)g._exponentTable[e]=2147483648+(e-32<<23);for(g._exponentTable[63]=3347054592,g._offsetTable[0]=0,e=1;e<64;++e)g._offsetTable[e]=32===e?0:1024}static roundToFloat16Bits(e){g._floatView[0]=e;var t=g._uint32View[0],r=t>>23&511;return g._baseTable[r]+((8388607&t)>>g._shiftTable[r])}static convertToNumber(e){var t=e>>10;return g._uint32View[0]=g._mantissaTable[g._offsetTable[t]+(1023&e)]+g._exponentTable[t],g._floatView[0]}}g._buffer=new ArrayBuffer(4),g._floatView=new Float32Array(g._buffer),g._uint32View=new Uint32Array(g._buffer),g._baseTable=new Uint32Array(512),g._shiftTable=new Uint32Array(512),g._mantissaTable=new Uint32Array(2048),g._exponentTable=new Uint32Array(64),g._offsetTable=new Uint32Array(64);class S{static READ_DATA(){S._DATA.offset=S._reader.getUint32(),S._DATA.size=S._reader.getUint32()}static READ_BLOCK(){for(var e=S._BLOCK.count=S._reader.getUint16(),t=S._BLOCK.blockStarts=[],r=S._BLOCK.blockLengths=[],i=0;i0&&(G.params=U=[]),r=0;r=.64&&(s>1?o=0:o*=1-(s-.64)/.36),n[a]=Math.floor(255*o+.5)}static haloTexture(e,t,r,i,a,n){var s=(e-(r>>=1))/r,o=(t-(i>>=1))/i,l=s*s+o*o;l>1&&(l=1),n[a]=Math.floor(255*(1-l)+.5)}static _generateTexture2D(e,r,i,a){var n=0,s=0;switch(e.format){case t.TextureFormat.R8G8B8:s=3;break;case t.TextureFormat.R8G8B8A8:s=4;break;case t.TextureFormat.Alpha8:s=1;break;default:throw"GeneratedTexture._generateTexture: unkonw texture format."}for(var o=new Uint8Array(r*i*s),l=0;l=0?e.substr(t):null}static _createAffineTransformationArray(e,t,r,i){var a=t.x,n=t.y,s=t.z,o=t.w,l=a+a,_=n+n,h=s+s,c=a*l,d=a*_,u=a*h,m=n*_,f=n*h,E=s*h,T=o*l,p=o*_,g=o*h,S=r.x,R=r.y,v=r.z;i[0]=(1-(m+E))*S,i[1]=(d+g)*S,i[2]=(u-p)*S,i[3]=0,i[4]=(d-g)*R,i[5]=(1-(c+E))*R,i[6]=(f+T)*R,i[7]=0,i[8]=(u+p)*v,i[9]=(f-T)*v,i[10]=(1-(c+m))*v,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1}static _mulMatrixArray(e,t,r,i,a){var n=t,s=e,o=i,l=n[r],_=n[r+1],h=n[r+2],c=n[r+3],d=n[r+4],u=n[r+5],m=n[r+6],f=n[r+7],E=n[r+8],T=n[r+9],p=n[r+10],g=n[r+11],S=n[r+12],R=n[r+13],v=n[r+14],x=n[r+15],I=s[0],A=s[1],L=s[2],C=s[3],D=s[4],M=s[5],y=s[6],O=s[7],N=s[8],b=s[9],P=s[10],w=s[11],V=s[12],B=s[13],F=s[14],U=s[15];o[a]=l*I+_*D+h*N+c*V,o[a+1]=l*A+_*M+h*b+c*B,o[a+2]=l*L+_*y+h*P+c*F,o[a+3]=l*C+_*O+h*w+c*U,o[a+4]=d*I+u*D+m*N+f*V,o[a+5]=d*A+u*M+m*b+f*B,o[a+6]=d*L+u*y+m*P+f*F,o[a+7]=d*C+u*O+m*w+f*U,o[a+8]=E*I+T*D+p*N+g*V,o[a+9]=E*A+T*M+p*b+g*B,o[a+10]=E*L+T*y+p*P+g*F,o[a+11]=E*C+T*O+p*w+g*U,o[a+12]=S*I+R*D+v*N+x*V,o[a+13]=S*A+R*M+v*b+x*B,o[a+14]=S*L+R*y+v*P+x*F,o[a+15]=S*C+R*O+v*w+x*U}static arcTanAngle(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){n.subtract(t,e,f.TEMPVector30),n.normalize(f.TEMPVector30,f.TEMPVector30),r.x=Math.asin(f.TEMPVector30.y),r.y=I.arcTanAngle(-f.TEMPVector30.z,-f.TEMPVector30.x)}static transformQuat(e,t,r){var i=t,a=e.x,n=e.y,s=e.z,o=i[0],l=i[1],_=i[2],h=i[3],c=h*a+l*s-_*n,d=h*n+_*a-o*s,u=h*s+o*n-l*a,m=-o*a-l*n-_*s;r.x=c*h+m*-o+d*-_-u*-l,r.y=d*h+m*-l+u*-o-c*-_,r.z=u*h+m*-_+c*-l-d*-o}static quaternionWeight(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w}static quaternionConjugate(e,t){t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w}static scaleWeight(e,t,r){var i=e.x,a=e.y,n=e.z;r.x=i>0?Math.pow(Math.abs(i),t):-Math.pow(Math.abs(i),t),r.y=a>0?Math.pow(Math.abs(a),t):-Math.pow(Math.abs(a),t),r.z=n>0?Math.pow(Math.abs(n),t):-Math.pow(Math.abs(n),t)}static scaleBlend(e,t,r,i){var a=I._tempVector3_0,n=I._tempVector3_1;I.scaleWeight(e,1-r,a),I.scaleWeight(t,r,n);var s=r>.5?t:e;i.x=s.x>0?Math.abs(a.x*n.x):-Math.abs(a.x*n.x),i.y=s.y>0?Math.abs(a.y*n.y):-Math.abs(a.y*n.y),i.z=s.z>0?Math.abs(a.z*n.z):-Math.abs(a.z*n.z)}static matrix4x4MultiplyFFF(e,t,r){var i,a,n,s,o;if(r===t)for(t=new Float32Array(16),i=0;i<16;++i)t[i]=r[i];var l=t[0],_=t[1],h=t[2],c=t[3],d=t[4],u=t[5],m=t[6],f=t[7],E=t[8],T=t[9],p=t[10],g=t[11],S=t[12],R=t[13],v=t[14],x=t[15];for(i=0;i<4;i++)a=e[i],n=e[i+4],s=e[i+8],o=e[i+12],r[i]=a*l+n*_+s*h+o*c,r[i+4]=a*d+n*u+s*m+o*f,r[i+8]=a*E+n*T+s*p+o*g,r[i+12]=a*S+n*R+s*v+o*x}static matrix4x4MultiplyFFFForNative(e,r,i){t.LayaGL.instance.matrix4x4Multiply(e,r,i)}static matrix4x4MultiplyMFM(e,t,r){I.matrix4x4MultiplyFFF(e.elements,t,r.elements)}static _buildTexture2D(e,r,i,a,n=!1){var s=new t.Texture2D(e,r,i,n,!0);return s.anisoLevel=1,s.filterMode=t.FilterMode.Point,x._generateTexture2D(s,e,r,a),s}static _drawBound(e,t,r){e.lineCount+12>e.maxLineCount&&(e.maxLineCount+=12);var i=I._tempVector3_0,a=I._tempVector3_1,n=t.min,s=t.max;i.setValue(n.x,n.y,n.z),a.setValue(s.x,n.y,n.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,n.z),a.setValue(n.x,n.y,s.z),e.addLine(i,a,r,r),i.setValue(s.x,n.y,n.z),a.setValue(s.x,n.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,s.z),a.setValue(s.x,n.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,n.z),a.setValue(n.x,s.y,n.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,s.z),a.setValue(n.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(s.x,n.y,n.z),a.setValue(s.x,s.y,n.z),e.addLine(i,a,r,r),i.setValue(s.x,n.y,s.z),a.setValue(s.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,s.y,n.z),a.setValue(s.x,s.y,n.z),e.addLine(i,a,r,r),i.setValue(n.x,s.y,n.z),a.setValue(n.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(s.x,s.y,n.z),a.setValue(s.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,s.y,s.z),a.setValue(s.x,s.y,s.z),e.addLine(i,a,r,r)}static _getHierarchyPath(e,t,r){r.length=0;for(var i=t;i!==e;){var a=i._parent;if(!a)return null;r.push(a.getChildIndex(i)),i=a}return r}static _getNodeByHierarchyPath(e,t){for(var r=e,i=t.length-1;i>=0;i--)r=r.getChildAt(t[i]);return r}}I._tempVector3_0=new n,I._tempVector3_1=new n,I._tempArray16_0=new Float32Array(16),I._tempArray16_1=new Float32Array(16),I._tempArray16_2=new Float32Array(16),I._tempArray16_3=new Float32Array(16),I._compIdToNode=new Object;class A extends t.Resource{constructor(){super(),this._nodes=new R,this._animationEvents=[]}static _parse(e,r=null,i=null){var a=new A,n=new t.Byte(e),s=n.readUTFString();switch(s){case"LAYAANIMATION:03":p.parse(a,n);break;case"LAYAANIMATION:04":case"LAYAANIMATION:COMPRESSION_04":S.parse(a,n,s);break;default:throw"unknown animationClip version."}return a}static load(e,r){t.ILaya.loader.create(e,r,null,A.ANIMATIONCLIP)}duration(){return this._duration}_hermiteInterpolate(e,t,r,i){var a=e.outTangent,n=t.inTangent;if(Number.isFinite(a)&&Number.isFinite(n)){var s=r*r,o=s*r,l=o-2*s+r,_=o-s,h=-2*o+3*s;return(2*o-3*s+1)*e.value+l*a*i+_*n*i+h*t.value}return e.value}_hermiteInterpolateVector3(e,t,r,i,a){var n=e.value,s=e.outTangent,o=t.value,l=t.inTangent,_=r*r,h=_*r,c=2*h-3*_+1,d=h-2*_+r,u=h-_,m=-2*h+3*_,f=s.x,E=l.x;Number.isFinite(f)&&Number.isFinite(E)?a.x=c*n.x+d*f*i+u*E*i+m*o.x:a.x=n.x,f=s.y,E=l.y,Number.isFinite(f)&&Number.isFinite(E)?a.y=c*n.y+d*f*i+u*E*i+m*o.y:a.y=n.y,f=s.z,E=l.z,Number.isFinite(f)&&Number.isFinite(E)?a.z=c*n.z+d*f*i+u*E*i+m*o.z:a.z=n.z}_hermiteInterpolateQuaternion(e,t,r,i,a){var n=e.value,s=e.outTangent,o=t.value,l=t.inTangent,_=r*r,h=_*r,c=2*h-3*_+1,d=h-2*_+r,u=h-_,m=-2*h+3*_,f=s.x,E=l.x;Number.isFinite(f)&&Number.isFinite(E)?a.x=c*n.x+d*f*i+u*E*i+m*o.x:a.x=n.x,f=s.y,E=l.y,Number.isFinite(f)&&Number.isFinite(E)?a.y=c*n.y+d*f*i+u*E*i+m*o.y:a.y=n.y,f=s.z,E=l.z,Number.isFinite(f)&&Number.isFinite(E)?a.z=c*n.z+d*f*i+u*E*i+m*o.z:a.z=n.z,f=s.w,E=l.w,Number.isFinite(f)&&Number.isFinite(E)?a.w=c*n.w+d*f*i+u*E*i+m*o.w:a.w=n.w}_evaluateClipDatasRealTime(e,t,r,i,a,n){for(var s=0,o=e.count;st);)u++,l++,r[s]=u;else for((l=u+1)!==d&&t>c[l].time&&(u=d-1,r[s]=u),l=u+1;u>-1&&!(c[u].timee?i=t-1:r=t+1}return r}addEvent(e){var t=this._binarySearchEventIndex(e.time);this._animationEvents.splice(t,0,e)}_disposeResource(){this._nodes=null,this._nodesMap=null}}A.ANIMATIONCLIP="ANIMATIONCLIP",A._tempQuaternion0=new f;class L{constructor(){this._currentState=null}get normalizedTime(){return this._normalizedTime}get duration(){return this._duration}get animatorState(){return this._currentState}_resetPlayState(e){this._finish=!1,this._startPlayTime=e,this._elapsedTime=e,this._playEventIndex=0,this._lastIsFront=!0}_cloneTo(e){e._finish=this._finish,e._startPlayTime=this._startPlayTime,e._elapsedTime=this._elapsedTime,e._normalizedTime=this._normalizedTime,e._normalizedPlayTime=this._normalizedPlayTime,e._playEventIndex=this._playEventIndex,e._lastIsFront=this._lastIsFront}}class C{constructor(e){this._defaultState=null,this._referenceCount=0,this._playType=-1,this._crossDuration=-1,this._crossMark=0,this._crossNodesOwnersCount=0,this._crossNodesOwners=[],this._crossNodesOwnersIndicesMap={},this._srcCrossClipNodeIndices=[],this._destCrossClipNodeIndices=[],this._statesMap={},this._states=[],this._playStateInfo=new L,this._crossPlayStateInfo=new L,this.blendingMode=C.BLENDINGMODE_OVERRIDE,this.defaultWeight=1,this.playOnWake=!0,this.name=e}get defaultState(){return this._defaultState}set defaultState(e){this._defaultState=e,this._statesMap[e.name]=e}_removeClip(e,t,r,i){var a=i._clip,n=e[r];if(e.splice(r,1),delete t[i.name],this._animator){var s=a._nodes,o=n._nodeOwners;a._removeReference();for(var l=0,_=s.count;l<_;l++)this._animator._removeKeyframeNodeOwner(o,s.getNodeByIndex(l))}}_getReferenceCount(){return this._referenceCount}_addReference(e=1){for(var t=0,r=this._states.length;t0&&(i[0]=r[0]*a,i[1]=r[1]*a,i[2]=r[2]*a,i[3]=r[3]*a)}static add(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]+n[0],i[1]=a[1]+n[1],i[2]=a[2]+n[2],i[3]=a[3]+n[3]}static subtract(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]-n[0],i[1]=a[1]-n[1],i[2]=a[2]-n[2],i[3]=a[3]-n[3]}static multiply(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]*n[0],i[1]=a[1]*n[1],i[2]=a[2]*n[2],i[3]=a[3]*n[3]}static scale(e,t,r){var i=r.elements,a=e.elements;i[0]=a[0]*t,i[1]=a[1]*t,i[2]=a[2]*t,i[3]=a[3]*t}static Clamp(e,t,r,i){var a=e.elements,n=a[0],s=a[1],o=a[2],l=a[3],_=t.elements,h=_[0],c=_[1],d=_[2],u=_[3],m=r.elements,f=m[0],E=m[1],T=m[2],p=m[3],g=i.elements;n=(n=n>f?f:n)E?E:s)T?T:o)p?p:l)0&&(o=1/Math.sqrt(o),i[0]=r[0]*o,i[1]=r[1]*o,i[2]=r[2]*o)}static multiply(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]*n[0],i[1]=a[1]*n[1],i[2]=a[2]*n[2]}static scale(e,t,r){var i=r.elements,a=e.elements;i[0]=a[0]*t,i[1]=a[1]*t,i[2]=a[2]*t}static lerp(e,t,r,i){var a=i.elements,n=e.elements,s=t.elements,o=n[0],l=n[1],_=n[2];a[0]=o+r*(s[0]-o),a[1]=l+r*(s[1]-l),a[2]=_+r*(s[2]-_)}static transformV3ToV3(e,t,r){var i=M._tempVector4;M.transformV3ToV4(e,t,i);var a=i.elements,n=r.elements;n[0]=a[0],n[1]=a[1],n[2]=a[2]}static transformV3ToV4(e,t,r){var i=e.elements,a=i[0],n=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=a*o[0]+n*o[4]+s*o[8]+o[12],l[1]=a*o[1]+n*o[5]+s*o[9]+o[13],l[2]=a*o[2]+n*o[6]+s*o[10]+o[14],l[3]=a*o[3]+n*o[7]+s*o[11]+o[15]}static TransformNormal(e,t,r){var i=e.elements,a=i[0],n=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=a*o[0]+n*o[4]+s*o[8],l[1]=a*o[1]+n*o[5]+s*o[9],l[2]=a*o[2]+n*o[6]+s*o[10]}static transformCoordinate(e,t,r){var i=e.elements,a=i[0],n=i[1],s=i[2],o=t.elements,l=a*o[3]+n*o[7]+s*o[11]+o[15],_=r.elements;_[0]=a*o[0]+n*o[4]+s*o[8]+o[12]/l,_[1]=a*o[1]+n*o[5]+s*o[9]+o[13]/l,_[2]=a*o[2]+n*o[6]+s*o[10]+o[14]/l}static Clamp(e,t,r,i){var a=e.elements,n=a[0],s=a[1],o=a[2],l=t.elements,_=l[0],h=l[1],c=l[2],d=r.elements,u=d[0],m=d[1],f=d[2],E=i.elements;n=(n=n>u?u:n)<_?_:n,s=(s=s>m?m:s)f?f:o)3)throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");return this.elements[4*e+t]}setElementByRowColumn(e,t,r){if(e<0||e>3)throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");this.elements[4*e+t]=r}equalsOtherMatrix(e){var t=this.elements,i=e.elements;return r.nearEqual(t[0],i[0])&&r.nearEqual(t[1],i[1])&&r.nearEqual(t[2],i[2])&&r.nearEqual(t[3],i[3])&&r.nearEqual(t[4],i[4])&&r.nearEqual(t[5],i[5])&&r.nearEqual(t[6],i[6])&&r.nearEqual(t[7],i[7])&&r.nearEqual(t[8],i[8])&&r.nearEqual(t[9],i[9])&&r.nearEqual(t[10],i[10])&&r.nearEqual(t[11],i[11])&&r.nearEqual(t[12],i[12])&&r.nearEqual(t[13],i[13])&&r.nearEqual(t[14],i[14])&&r.nearEqual(t[15],i[15])}decomposeTransRotScale(e,t,r){var i=y._tempMatrix4x4;return this.decomposeTransRotMatScale(e,i,r)?(f.createFromMatrix4x4(i,t),!0):(t.identity(),!1)}decomposeTransRotMatScale(e,t,i){var a=this.elements,s=e,o=t.elements,l=i;s.x=a[12],s.y=a[13],s.z=a[14];var _=a[0],h=a[1],c=a[2],d=a[4],u=a[5],m=a[6],f=a[8],E=a[9],T=a[10],p=l.x=Math.sqrt(_*_+h*h+c*c),g=l.y=Math.sqrt(d*d+u*u+m*m),S=l.z=Math.sqrt(f*f+E*E+T*T);if(r.isZero(p)||r.isZero(g)||r.isZero(S))return o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[8]=o[9]=o[11]=o[12]=o[13]=o[14]=0,o[0]=o[5]=o[10]=o[15]=1,!1;var R=y._tempVector0;R.x=f/S,R.y=E/S,R.z=T/S;var v=y._tempVector1;v.x=_/p,v.y=h/p,v.z=c/p;var x=y._tempVector2;n.cross(R,v,x);var I=y._tempVector1;return n.cross(x,R,I),o[3]=o[7]=o[11]=o[12]=o[13]=o[14]=0,o[15]=1,o[0]=I.x,o[1]=I.y,o[2]=I.z,o[4]=x.x,o[5]=x.y,o[6]=x.z,o[8]=R.x,o[9]=R.y,o[10]=R.z,o[0]*_+o[1]*h+o[2]*c<0&&(l.x=-p),o[4]*d+o[5]*u+o[6]*m<0&&(l.y=-g),o[8]*f+o[9]*E+o[10]*T<0&&(l.z=-S),!0}decomposeYawPitchRoll(e){var t=Math.asin(-this.elements[9]);e.y=t,Math.cos(t)>r.zeroTolerance?(e.z=Math.atan2(this.elements[1],this.elements[5]),e.x=Math.atan2(this.elements[8],this.elements[10])):(e.z=Math.atan2(-this.elements[4],this.elements[0]),e.x=0)}normalize(){var e=this.elements,t=e[0],r=e[1],i=e[2],a=Math.sqrt(t*t+r*r+i*i);if(!a)return e[0]=0,e[1]=0,void(e[2]=0);1!=a&&(a=1/a,e[0]=t*a,e[1]=r*a,e[2]=i*a)}transpose(){var e,t;return t=(e=this.elements)[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}invert(e){var t=this.elements,r=e.elements,i=t[0],a=t[1],n=t[2],s=t[3],o=t[4],l=t[5],_=t[6],h=t[7],c=t[8],d=t[9],u=t[10],m=t[11],f=t[12],E=t[13],T=t[14],p=t[15],g=i*l-a*o,S=i*_-n*o,R=i*h-s*o,v=a*_-n*l,x=a*h-s*l,I=n*h-s*_,A=c*E-d*f,L=c*T-u*f,C=c*p-m*f,D=d*T-u*E,M=d*p-m*E,y=u*p-m*T,O=g*y-S*M+R*D+v*C-x*L+I*A;0!==Math.abs(O)&&(O=1/O,r[0]=(l*y-_*M+h*D)*O,r[1]=(n*M-a*y-s*D)*O,r[2]=(E*I-T*x+p*v)*O,r[3]=(u*x-d*I-m*v)*O,r[4]=(_*C-o*y-h*L)*O,r[5]=(i*y-n*C+s*L)*O,r[6]=(T*R-f*I-p*S)*O,r[7]=(c*I-u*R+m*S)*O,r[8]=(o*M-l*C+h*A)*O,r[9]=(a*C-i*M-s*A)*O,r[10]=(f*x-E*R+p*g)*O,r[11]=(d*R-c*x-m*g)*O,r[12]=(l*L-o*D-_*A)*O,r[13]=(i*D-a*L+n*A)*O,r[14]=(E*S-f*v-T*g)*O,r[15]=(c*v-d*S+u*g)*O)}static billboard(e,t,i,a,s,o){n.subtract(e,t,y._tempVector0);var l=n.scalarLengthSquared(y._tempVector0);r.isZero(l)?(n.scale(s,-1,y._tempVector1),y._tempVector1.cloneTo(y._tempVector0)):n.scale(y._tempVector0,1/Math.sqrt(l),y._tempVector0),n.cross(a,y._tempVector0,y._tempVector2),n.normalize(y._tempVector2,y._tempVector2),n.cross(y._tempVector0,y._tempVector2,y._tempVector3);var _=y._tempVector2,h=y._tempVector3,c=y._tempVector0,d=e,u=o.elements;u[0]=_.x,u[1]=_.y,u[2]=_.z,u[3]=0,u[4]=h.x,u[5]=h.y,u[6]=h.z,u[7]=0,u[8]=c.x,u[9]=c.y,u[10]=c.z,u[11]=0,u[12]=d.x,u[13]=d.y,u[14]=d.z,u[15]=1}identity(){var e=this.elements;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1}cloneTo(e){var t,r,i;if((r=this.elements)!==(i=e.elements))for(t=0;t<16;++t)i[t]=r[t]}clone(){var e=new y;return this.cloneTo(e),e}static translation(e,t){var r=t.elements;r[0]=r[5]=r[10]=r[15]=1,r[12]=e.x,r[13]=e.y,r[14]=e.z}getTranslationVector(e){var t=this.elements;e.x=t[12],e.y=t[13],e.z=t[14]}setTranslationVector(e){var t=this.elements,r=e;t[12]=r.x,t[13]=r.y,t[14]=r.z}getForward(e){var t=this.elements;e.x=-t[8],e.y=-t[9],e.z=-t[10]}setForward(e){var t=this.elements;t[8]=-e.x,t[9]=-e.y,t[10]=-e.z}}y._tempMatrix4x4=new y,y.TEMPMatrix0=new y,y.TEMPMatrix1=new y,y._tempVector0=new n,y._tempVector1=new n,y._tempVector2=new n,y._tempVector3=new n,y._tempQuaternion=new f,y.DEFAULT=new y,y.ZERO=new y(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);class O{constructor(e=0,t=0,r=0,i=1,a=null){var n;(n=a||new Float32Array(4))[0]=e,n[1]=t,n[2]=r,n[3]=i,this.elements=n}static _dotArray(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}static _normalizeArray(e,t){var r=e[0],i=e[1],a=e[2],n=e[3],s=r*r+i*i+a*a+n*n;s>0&&(s=1/Math.sqrt(s),t[0]=r*s,t[1]=i*s,t[2]=a*s,t[3]=n*s)}static _lerpArray(e,t,r,i){var a=1-r;O._dotArray(e,t)>=0?(i[0]=a*e[0]+r*t[0],i[1]=a*e[1]+r*t[1],i[2]=a*e[2]+r*t[2],i[3]=a*e[3]+r*t[3]):(i[0]=a*e[0]-r*t[0],i[1]=a*e[1]-r*t[1],i[2]=a*e[2]-r*t[2],i[3]=a*e[3]-r*t[3]),O._normalizeArray(i,i)}static createFromYawPitchRoll(e,t,r,i){var a=.5*r,n=.5*t,s=.5*e,o=Math.sin(a),l=Math.cos(a),_=Math.sin(n),h=Math.cos(n),c=Math.sin(s),d=Math.cos(s),u=i.elements;u[0]=d*_*l+c*h*o,u[1]=c*h*l-d*_*o,u[2]=d*h*o-c*_*l,u[3]=d*h*l+c*_*o}static multiply(e,t,r){var i=e.elements,a=t.elements,n=r.elements,s=i[0],o=i[1],l=i[2],_=i[3],h=a[0],c=a[1],d=a[2],u=a[3],m=o*d-l*c,f=l*h-s*d,E=s*c-o*h,T=s*h+o*c+l*d;n[0]=s*u+h*_+m,n[1]=o*u+c*_+f,n[2]=l*u+d*_+E,n[3]=_*u-T}static arcTanAngle(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){M.subtract(t,e,O.TEMPVector30),M.normalize(O.TEMPVector30,O.TEMPVector30),r.elements[0]=Math.asin(O.TEMPVector30.y),r.elements[1]=O.arcTanAngle(-O.TEMPVector30.z,-O.TEMPVector30.x)}static createFromAxisAngle(e,t,r){var i=r.elements,a=e.elements;t*=.5;var n=Math.sin(t);i[0]=n*a[0],i[1]=n*a[1],i[2]=n*a[2],i[3]=Math.cos(t)}static createFromMatrix3x3(e,t){var r,i=t.elements,a=e.elements,n=a[0]+a[4]+a[8];if(n>0)r=Math.sqrt(n+1),i[3]=.5*r,r=.5/r,i[0]=(a[5]-a[7])*r,i[1]=(a[6]-a[2])*r,i[2]=(a[1]-a[3])*r;else{var s=0;a[4]>a[0]&&(s=1),a[8]>a[3*s+s]&&(s=2);var o=(s+1)%3,l=(s+2)%3;r=Math.sqrt(a[3*s+s]-a[3*o+o]-a[3*l+l]+1),i[s]=.5*r,r=.5/r,i[3]=(a[3*o+l]-a[3*l+o])*r,i[o]=(a[3*o+s]+a[3*s+o])*r,i[l]=(a[3*l+s]+a[3*s+l])*r}}static createFromMatrix4x4(e,t){var r,i,a=e.elements,n=t.elements,s=a[0]+a[5]+a[10];s>0?(r=Math.sqrt(s+1),n[3]=.5*r,r=.5/r,n[0]=(a[6]-a[9])*r,n[1]=(a[8]-a[2])*r,n[2]=(a[1]-a[4])*r):a[0]>=a[5]&&a[0]>=a[10]?(i=.5/(r=Math.sqrt(1+a[0]-a[5]-a[10])),n[0]=.5*r,n[1]=(a[1]+a[4])*i,n[2]=(a[2]+a[8])*i,n[3]=(a[6]-a[9])*i):a[5]>a[10]?(i=.5/(r=Math.sqrt(1+a[5]-a[0]-a[10])),n[0]=(a[4]+a[1])*i,n[1]=.5*r,n[2]=(a[9]+a[6])*i,n[3]=(a[8]-a[2])*i):(i=.5/(r=Math.sqrt(1+a[10]-a[0]-a[5])),n[0]=(a[8]+a[2])*i,n[1]=(a[9]+a[6])*i,n[2]=.5*r,n[3]=(a[1]-a[4])*i)}static slerp(e,t,r,i){var a,n,s,o,l,_=e.elements,h=t.elements,c=i.elements,d=_[0],u=_[1],m=_[2],f=_[3],E=h[0],T=h[1],p=h[2],g=h[3];return(n=d*E+u*T+m*p+f*g)<0&&(n=-n,E=-E,T=-T,p=-p,g=-g),1-n>1e-6?(a=Math.acos(n),s=Math.sin(a),o=Math.sin((1-r)*a)/s,l=Math.sin(r*a)/s):(o=1-r,l=r),c[0]=o*d+l*E,c[1]=o*u+l*T,c[2]=o*m+l*p,c[3]=o*f+l*g,c}static lerp(e,t,r,i){O._lerpArray(e.elements,t.elements,r,i.elements)}static add(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]+n[0],i[1]=a[1]+n[1],i[2]=a[2]+n[2],i[3]=a[3]+n[3]}static dot(e,t){return O._dotArray(e.elements,t.elements)}get x(){return this.elements[0]}set x(e){this.elements[0]=e}get y(){return this.elements[1]}set y(e){this.elements[1]=e}get z(){return this.elements[2]}set z(e){this.elements[2]=e}get w(){return this.elements[3]}set w(e){this.elements[3]=e}scaling(e,t){var r=t.elements,i=this.elements;r[0]=i[0]*e,r[1]=i[1]*e,r[2]=i[2]*e,r[3]=i[3]*e}normalize(e){O._normalizeArray(this.elements,e.elements)}length(){var e=this.elements,t=e[0],r=e[1],i=e[2],a=e[3];return Math.sqrt(t*t+r*r+i*i+a*a)}rotateX(e,t){var r=t.elements,i=this.elements;e*=.5;var a=i[0],n=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=a*_+o*l,r[1]=n*_+s*l,r[2]=s*_-n*l,r[3]=o*_-a*l}rotateY(e,t){var r=t.elements,i=this.elements;e*=.5;var a=i[0],n=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=a*_-s*l,r[1]=n*_+o*l,r[2]=s*_+a*l,r[3]=o*_-n*l}rotateZ(e,t){var r=t.elements,i=this.elements;e*=.5;var a=i[0],n=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=a*_+n*l,r[1]=n*_-a*l,r[2]=s*_+o*l,r[3]=o*_-s*l}getYawPitchRoll(e){M.transformQuat(M.ForwardRH,this,O.TEMPVector31),M.transformQuat(M.Up,this,O.TEMPVector32);var t=O.TEMPVector32.elements;O.angleTo(M.ZERO,O.TEMPVector31,O.TEMPVector33);var r=O.TEMPVector33.elements;r[0]==Math.PI/2?(r[1]=O.arcTanAngle(t[2],t[0]),r[2]=0):r[0]==-Math.PI/2?(r[1]=O.arcTanAngle(-t[2],-t[0]),r[2]=0):(y.createRotationY(-r[1],O.TEMPMatrix0),y.createRotationX(-r[0],O.TEMPMatrix1),M.transformCoordinate(O.TEMPVector32,O.TEMPMatrix0,O.TEMPVector32),M.transformCoordinate(O.TEMPVector32,O.TEMPMatrix1,O.TEMPVector32),r[2]=O.arcTanAngle(t[1],-t[0])),r[1]<=-Math.PI&&(r[1]=Math.PI),r[2]<=-Math.PI&&(r[2]=Math.PI),r[1]>=Math.PI&&r[2]>=Math.PI&&(r[1]=0,r[2]=0,r[0]=Math.PI-r[0]);var i=e.elements;i[0]=r[1],i[1]=r[0],i[2]=r[2]}invert(e){var t=e.elements,r=this.elements,i=r[0],a=r[1],n=r[2],s=r[3],o=i*i+a*a+n*n+s*s,l=o?1/o:0;t[0]=-i*l,t[1]=-a*l,t[2]=-n*l,t[3]=s*l}identity(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1}fromArray(e,t=0){this.elements[0]=e[t+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2],this.elements[3]=e[t+3]}cloneTo(e){var t,r,i;if((r=this.elements)!==(i=e.elements))for(t=0;t<4;++t)i[t]=r[t]}clone(){var e=new O;return this.cloneTo(e),e}equals(e){var t=this.elements,i=e.elements;return r.nearEqual(t[0],i[0])&&r.nearEqual(t[1],i[1])&&r.nearEqual(t[2],i[2])&&r.nearEqual(t[3],i[3])}static rotationLookAt(e,t,r){O.lookAt(M.ZERO,e,t,r)}static lookAt(e,t,r,i){m.lookAt(e,t,r,O._tempMatrix3x3),O.rotationMatrix(O._tempMatrix3x3,i)}lengthSquared(){var e=this.elements[0],t=this.elements[1],r=this.elements[2],i=this.elements[3];return e*e+t*t+r*r+i*i}static invert(e,t){var i=e.elements,a=t.elements,n=e.lengthSquared();r.isZero(n)||(n=1/n,a[0]=-i[0]*n,a[1]=-i[1]*n,a[2]=-i[2]*n,a[3]=i[3]*n)}static rotationMatrix(e,t){var r,i,a=e.elements,n=a[0],s=a[1],o=a[2],l=a[3],_=a[4],h=a[5],c=a[6],d=a[7],u=a[8],m=t.elements,f=n+_+u;f>0?(r=Math.sqrt(f+1),m[3]=.5*r,r=.5/r,m[0]=(h-d)*r,m[1]=(c-o)*r,m[2]=(s-l)*r):n>=_&&n>=u?(i=.5/(r=Math.sqrt(1+n-_-u)),m[0]=.5*r,m[1]=(s+l)*i,m[2]=(o+c)*i,m[3]=(h-d)*i):_>u?(i=.5/(r=Math.sqrt(1+_-n-u)),m[0]=(l+s)*i,m[1]=.5*r,m[2]=(d+h)*i,m[3]=(c-o)*i):(i=.5/(r=Math.sqrt(1+u-n-_)),m[0]=(c+o)*i,m[1]=(d+h)*i,m[2]=.5*r,m[3]=(s-l)*i)}}O.TEMPVector30=new M,O.TEMPVector31=new M,O.TEMPVector32=new M,O.TEMPVector33=new M,O.TEMPMatrix0=new y,O.TEMPMatrix1=new y,O._tempMatrix3x3=new m,O.DEFAULT=new O,O.NAN=new O(NaN,NaN,NaN,NaN);class N{constructor(){this._referenceCount=0,this._clip=null,this._nodeOwners=[],this._currentFrameIndices=null,this._realtimeDatas=[],this._scripts=null,this.speed=1,this.clipStart=0,this.clipEnd=1}get clip(){return this._clip}set clip(e){if(this._clip!==e){if(this._clip&&this._referenceCount>0&&this._clip._removeReference(this._referenceCount),e){var r=this._realtimeDatas,i=e._nodes,a=i.count;this._currentFrameIndices=new Int16Array(a),this._resetFrameIndices(),this._referenceCount>0&&e._addReference(this._referenceCount),this._realtimeDatas.length=a;for(var s=0;s=a){if(t._finish=!0,t._elapsedTime=a,t._normalizedPlayTime=1,_)for(var h=0,c=_.length;h=0&&(s=t[r]).time>=i;r--)for(o=0,l=e.length;o=t._lastElapsedTime;if(t._lastIsFront!==_&&(_?t._playEventIndex++:t._playEventIndex--,t._lastIsFront=_),_){t._playEventIndex=this._eventScript(r,a,t._playEventIndex,l>0?n:o,!0);for(var h=0,c=l-1;h0&&o>0&&(t._playEventIndex=this._eventScript(r,a,0,o,!0))}else{t._playEventIndex=this._eventScript(r,a,t._playEventIndex,l>0?0:o,!1);var d=a.length-1;for(h=0,c=l-1;h0&&o>0&&(t._playEventIndex=this._eventScript(r,a,d,o,!1))}}}_updateClipDatas(e,t,r,i){var a=e._clip,n=a._duration,s=e.clipStart*n+r._normalizedPlayTime*r._duration,o=e._currentFrameIndices,l=r._elapsedTime>r._lastElapsedTime;a._evaluateClipDatasRealTime(a._nodes,s,o,t,l,e._realtimeDatas)}_applyFloat(e,t,r,i,a,n,s){if(r.updateMark===this._updateMark)if(i)e[t]+=a*s;else{var o=e[t];e[t]=o+a*(s-o)}else if(n)e[t]=i?r.defaultValue+s:s;else if(i)e[t]=r.defaultValue+a*s;else{var l=r.defaultValue;e[t]=l+a*(s-l)}}_applyPositionAndRotationEuler(e,t,r,i,a,n){if(e.updateMark===this._updateMark)if(t)n.x+=r*a.x,n.y+=r*a.y,n.z+=r*a.z;else{var s=n.x,o=n.y,l=n.z;n.x=s+r*(a.x-s),n.y=o+r*(a.y-o),n.z=l+r*(a.z-l)}else if(i)if(t){var _=e.defaultValue;n.x=_.x+a.x,n.y=_.y+a.y,n.z=_.z+a.z}else n.x=a.x,n.y=a.y,n.z=a.z;else if(_=e.defaultValue,t)n.x=_.x+r*a.x,n.y=_.y+r*a.y,n.z=_.z+r*a.z;else{var h=_.x,c=_.y,d=_.z;n.x=h+r*(a.x-h),n.y=c+r*(a.y-c),n.z=d+r*(a.z-d)}}_applyRotation(e,t,r,i,a,n){if(e.updateMark===this._updateMark)if(t){var s=P._tempQuaternion1;I.quaternionWeight(a,r,s),s.normalize(s),f.multiply(n,s,n)}else f.lerp(n,a,r,n);else if(i)if(t){var o=e.defaultValue;f.multiply(o,a,n)}else n.x=a.x,n.y=a.y,n.z=a.z,n.w=a.w;else o=e.defaultValue,t?(s=P._tempQuaternion1,I.quaternionWeight(a,r,s),s.normalize(s),f.multiply(o,s,n)):f.lerp(o,a,r,n)}_applyScale(e,t,r,i,a,n){if(e.updateMark===this._updateMark)if(t){var s=P._tempVector31;I.scaleWeight(a,r,s),n.x=n.x*s.x,n.y=n.y*s.y,n.z=n.z*s.z}else I.scaleBlend(n,a,r,n);else if(i)if(t){var o=e.defaultValue;n.x=o.x*a.x,n.y=o.y*a.y,n.z=o.z*a.z}else n.x=a.x,n.y=a.y,n.z=a.z;else o=e.defaultValue,t?(s=P._tempVector31,I.scaleWeight(a,r,s),n.x=o.x*s.x,n.y=o.y*s.y,n.z=o.z*s.z):I.scaleBlend(o,a,r,n)}_applyCrossData(e,t,r,i,a,n,s){var o=e.propertyOwner;if(o){switch(e.type){case 0:for(var l=e.property,_=l.length-1,h=0;h<_&&(o=o[l[h]]);h++);var c=a+s*(n-a);e.value=c,this._applyFloat(o,l[_],e,t,r,i,c);break;case 1:var d=o.localPosition,u=e.value,m=a.x,E=a.y,T=a.z;u.x=m+s*(n.x-m),u.y=E+s*(n.y-E),u.z=T+s*(n.z-T),this._applyPositionAndRotationEuler(e,t,r,i,u,d),o.localPosition=d;break;case 2:var p=o.localRotation,g=e.value;f.lerp(a,n,s,g),this._applyRotation(e,t,r,i,g,p),o.localRotation=p;break;case 3:var S=o.localScale,R=e.value;I.scaleBlend(a,n,s,R),this._applyScale(e,t,r,i,R,S),o.localScale=S;break;case 4:var v=o.localRotationEuler,x=e.value;m=a.x,E=a.y,T=a.z,x.x=m+s*(n.x-m),x.y=E+s*(n.y-E),x.z=T+s*(n.z-T),this._applyPositionAndRotationEuler(e,t,r,i,x,v),o.localRotationEuler=v}e.updateMark=this._updateMark}}_setClipDatasToNode(e,t,r,i){for(var a=e._realtimeDatas,n=e._clip._nodes,s=e._nodeOwners,o=0,l=n.count;og?g/T:1,R=this._speed*f.speed;this._updatePlayer(f,_,r*S*R,E.islooping);var v=(_._elapsedTime-p)/S/T;v>=1?i&&(this._updateClipDatas(f,m,_,s*R),this._setClipDatasToNode(f,m,o.defaultWeight,0===a),o._playType=0,l._currentState=f,_._cloneTo(l)):(l._finish||(d=this._speed*h.speed,this._updatePlayer(h,l,r*d,c.islooping),i&&this._updateClipDatas(h,m,l,s*d)),i&&(this._updateClipDatas(f,m,_,s*S*R),this._setCrossClipDatasToNode(o,h,f,v,0===a))),i&&(this._updateEventScript(h,l),this._updateEventScript(f,_));break;case 2:E=(f=o._crossPlayState)._clip,T=o._crossDuration,p=_._startPlayTime,S=T>(g=E._duration-p)?g/T:1,R=this._speed*f.speed,this._updatePlayer(f,_,r*S*R,E.islooping),i&&((v=(_._elapsedTime-p)/S/T)>=1?(this._updateClipDatas(f,m,_,s*R),this._setClipDatasToNode(f,m,1,0===a),o._playType=0,l._currentState=f,_._cloneTo(l)):(this._updateClipDatas(f,m,_,s*S*R),this._setFixedCrossClipDatasToNode(o,f,v,0===a)),this._updateEventScript(f,_))}}i&&this._avatar&&(t.Render.supportWebGLPlusAnimation&&this._updateAnimationNodeWorldMatix(this._animationNodeLocalPositions,this._animationNodeLocalRotations,this._animationNodeLocalScales,this._animationNodeWorldMatrixs,this._animationNodeParentIndices),this._updateAvatarNodesToSprite())}}_cloneTo(e){var t=e;t.avatar=this.avatar,t.cullingMode=this.cullingMode;for(var r=0,i=this._controllerLayers.length;r=0;i--){var a=r[i]&t[i];0==a&&i==this._length-1?this._length--:r[i]=a}}add(e){var t=e._index,r=t+1,i=this._mask,a=this._length;if(athis._length?(i[t]=e._value,this._length=r):i[t]|=e._value}remove(e){var t=e._index,r=this._mask,i=this._length-1;if(!(t>i)){var a=r[t]&~e._value;t==i&&0===a?this._length--:r[t]=a}}addDefineDatas(e){var t=e._mask,r=e._length,i=this._mask,a=i.length;if(a=0;a--)if(!(a>i)){var n=r[a]&~t[a];a==i&&0===n?(i--,this._length--):r[a]=n}}has(e){var t=e._index;return!(t>=this._length)&&0!=(this._mask[t]&e._value)}clear(){this._length=0}cloneTo(e){var t=e,r=t._mask,i=this._mask,a=this._length;r.length=a;for(var n=0;n0&&_>o)break;o&_&&t.push(s[_])}}static getDefineByName(e){var t=H._defineMap[e];if(!t){var r=H._maskMap,i=H._defineCounter,a=Math.floor(i/32),n=1<0&&(r&&r._removeReference(),t&&t._addReference())}getTexture(e){return this._data[e]}setAttribute(e,t){this._data[e]=t}getAttribute(e){return this._data[e]}getLength(){return this._data.length}setLength(e){this._data.length=e}cloneTo(e){var r=e,s=r._data;for(var o in this._data){var l=this._data[o];if(null!=l)if("number"==typeof l)s[o]=l;else if("number"==typeof l)s[o]=l;else if("boolean"==typeof l)s[o]=l;else if(l instanceof i){var _=s[o]||(s[o]=new i);l.cloneTo(_),s[o]=_}else if(l instanceof n){var h=s[o]||(s[o]=new n);l.cloneTo(h),s[o]=h}else if(l instanceof a){var c=s[o]||(s[o]=new a);l.cloneTo(c),s[o]=c}else if(l instanceof y){var d=s[o]||(s[o]=new y);l.cloneTo(d),s[o]=d}else l instanceof t.BaseTexture&&(s[o]=l)}this._defineDatas.cloneTo(r._defineDatas)}clone(){var e=new W;return this.cloneTo(e),e}cloneToForNative(e){var r=e;this._int32Data.length-r._int32Data.length>0&&r.needRenewArrayBufferForNative(this._int32Data.length),r._int32Data.set(this._int32Data,0);var s=r._nativeArray,o=this._nativeArray.length;s.length=o;for(var l=0;l=this._int32Data.length){var r=4*(e+1),i=this._int32Data,a=this._data.conchRef,n=this._data._ptrID;this._data=new ArrayBuffer(r),this._int32Data=new Int32Array(this._data),this._float32Data=new Float32Array(this._data),this._data.conchRef=a,this._data._ptrID=n,i&&this._int32Data.set(i,0);var s=t.LayaGL.instance;s.updateArrayBufferRef?s.updateArrayBufferRef(this._data._ptrID,a.isSyncToRender(),this._data):window.conch.updateArrayBufferRef(this._data._ptrID,a.isSyncToRender(),this._data)}}getDataForNative(){return this._nativeArray}getIntForNative(e){return this._int32Data[e]}setIntForNative(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t,this._nativeArray[e]=t}getBoolForNative(e){return 1==this._int32Data[e]}setBoolForNative(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t?1:0,this._nativeArray[e]=t}getNumberForNative(e){return this._float32Data[e]}setNumberForNative(e,t){this.needRenewArrayBufferForNative(e),this._float32Data[e]=t,this._nativeArray[e]=t}getMatrix4x4ForNative(e){return this._nativeArray[e]}setMatrix4x4ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVectorForNative(e){return this._nativeArray[e]}setVectorForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVector2ForNative(e){return this._nativeArray[e]}setVector2ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVector3ForNative(e){return this._nativeArray[e]}setVector3ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getQuaternionForNative(e){return this._nativeArray[e]}setQuaternionForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getBufferForNative(e){return this._nativeArray[e]}setBufferForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var r=this.setReferenceForNative(t);this._int32Data[e]=r}getAttributeForNative(e){return this._nativeArray[e]}setAttributeForNative(e,r){this._nativeArray[e]=r,r._ptrID||t.LayaGL.instance.createArrayBufferRef(r,t.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0),t.LayaGL.instance.syncBufferToRenderThread(r),this._int32Data[e]=r._ptrID}getTextureForNative(e){return this._nativeArray[e]}setTextureForNative(e,t){if(t){this.needRenewArrayBufferForNative(e);var r=this._nativeArray[e];this._nativeArray[e]=t;var i=t._getSource()||t.defaulteTexture._getSource();this._int32Data[e]=i.id,this._ownerResource&&this._ownerResource.referenceCount>0&&(r&&r._removeReference(),t&&t._addReference())}}setReferenceForNative(e){this.clearRuntimeCopyArray();var r=0,i=0;return W._SET_RUNTIME_VALUE_MODE_REFERENCE_?(t.LayaGL.instance.createArrayBufferRefs(e,t.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0,t.LayaGL.ARRAY_BUFFER_REF_REFERENCE),r=0,i=e.getPtrID(r)):(t.LayaGL.instance.createArrayBufferRefs(e,t.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0,t.LayaGL.ARRAY_BUFFER_REF_COPY),r=e.getRefNum()-1,i=e.getPtrID(r),this._runtimeCopyValues.push({obj:e,refID:r,ptrID:i})),t.LayaGL.instance.syncBufferToRenderThread(e,r),i}static setRuntimeValueMode(e){W._SET_RUNTIME_VALUE_MODE_REFERENCE_=e}clearRuntimeCopyArray(){var e=t.Stat.loopCount;if(this._frameCount!=e){this._frameCount=e;for(var r=0,i=this._runtimeCopyValues.length;r0&&this._removeTetxureReference(),this._shaderValues=null}_addReference(e=1){super._addReference(e);var r=this._shaderValues.getData();for(var i in r){var a=r[i];a&&a instanceof t.BaseTexture&&a._addReference()}}_removeReference(e=1){super._removeReference(e),this._removeTetxureReference()}setShaderName(e){if(this._shader=H.find(e),!this._shader)throw new Error("BaseMaterial: unknown shader name.")}cloneTo(e){var t=e;t.name=this.name,t.renderQueue=this.renderQueue,this._shaderValues.cloneTo(t._shaderValues)}clone(){var e=new Z;return this.cloneTo(e),e}get _defineDatas(){return this._shaderValues._defineDatas}}Z.MATERIAL="MATERIAL",Z.RENDERQUEUE_OPAQUE=2e3,Z.RENDERQUEUE_ALPHATEST=2450,Z.RENDERQUEUE_TRANSPARENT=3e3,Z.ALPHATESTVALUE=H.propertyNameToID("u_AlphaTestValue"),Z.SHADERDEFINE_ALPHATEST=null;class q{static load(e,r){t.Laya.loader.create(e,r,null,Z.MATERIAL)}static __initDefine__(){q.SHADERDEFINE_ALPHATEST=Z.SHADERDEFINE_ALPHATEST}}q.MATERIAL="MATERIAL",q.RENDERQUEUE_OPAQUE=2e3,q.RENDERQUEUE_ALPHATEST=2450,q.RENDERQUEUE_TRANSPARENT=3e3,q.ALPHATESTVALUE=H.propertyNameToID("u_AlphaTestValue"),q.SHADERDEFINE_ALPHATEST=null;class Q{constructor(){this.cull=Q.CULL_BACK,this.blend=Q.BLEND_DISABLE,this.srcBlend=Q.BLENDPARAM_ONE,this.dstBlend=Q.BLENDPARAM_ZERO,this.srcBlendRGB=Q.BLENDPARAM_ONE,this.dstBlendRGB=Q.BLENDPARAM_ZERO,this.srcBlendAlpha=Q.BLENDPARAM_ONE,this.dstBlendAlpha=Q.BLENDPARAM_ZERO,this.blendConstColor=new a(1,1,1,1),this.blendEquation=Q.BLENDEQUATION_ADD,this.blendEquationRGB=Q.BLENDEQUATION_ADD,this.blendEquationAlpha=Q.BLENDEQUATION_ADD,this.depthTest=Q.DEPTHTEST_LEQUAL,this.depthWrite=!0}cloneTo(e){var t=e;t.cull=this.cull,t.blend=this.blend,t.srcBlend=this.srcBlend,t.dstBlend=this.dstBlend,t.srcBlendRGB=this.srcBlendRGB,t.dstBlendRGB=this.dstBlendRGB,t.srcBlendAlpha=this.srcBlendAlpha,t.dstBlendAlpha=this.dstBlendAlpha,this.blendConstColor.cloneTo(t.blendConstColor),t.blendEquation=this.blendEquation,t.blendEquationRGB=this.blendEquationRGB,t.blendEquationAlpha=this.blendEquationAlpha,t.depthTest=this.depthTest,t.depthWrite=this.depthWrite}clone(){var e=new Q;return this.cloneTo(e),e}}Q.CULL_NONE=0,Q.CULL_FRONT=1,Q.CULL_BACK=2,Q.BLEND_DISABLE=0,Q.BLEND_ENABLE_ALL=1,Q.BLEND_ENABLE_SEPERATE=2,Q.BLENDPARAM_ZERO=0,Q.BLENDPARAM_ONE=1,Q.BLENDPARAM_SRC_COLOR=768,Q.BLENDPARAM_ONE_MINUS_SRC_COLOR=769,Q.BLENDPARAM_DST_COLOR=774,Q.BLENDPARAM_ONE_MINUS_DST_COLOR=775,Q.BLENDPARAM_SRC_ALPHA=770,Q.BLENDPARAM_ONE_MINUS_SRC_ALPHA=771,Q.BLENDPARAM_DST_ALPHA=772,Q.BLENDPARAM_ONE_MINUS_DST_ALPHA=773,Q.BLENDPARAM_SRC_ALPHA_SATURATE=776,Q.BLENDEQUATION_ADD=32774,Q.BLENDEQUATION_SUBTRACT=32778,Q.BLENDEQUATION_REVERSE_SUBTRACT=32779,Q.DEPTHTEST_OFF=0,Q.DEPTHTEST_NEVER=512,Q.DEPTHTEST_LESS=513,Q.DEPTHTEST_EQUAL=514,Q.DEPTHTEST_LEQUAL=515,Q.DEPTHTEST_GREATER=516,Q.DEPTHTEST_NOTEQUAL=517,Q.DEPTHTEST_GEQUAL=518,Q.DEPTHTEST_ALWAYS=519;class K extends Z{constructor(){super(),this._enableVertexColor=!1,this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new a(1,1,1,1);var e=this._shaderValues;e.setVector(K.ALBEDOCOLOR,new a(1,1,1,1)),e.setVector(K.MATERIALSPECULAR,new a(1,1,1,1)),e.setNumber(K.SHININESS,.078125),e.setNumber(Z.ALPHATESTVALUE,.5),e.setVector(K.TILINGOFFSET,new a(1,1,0,0)),this._enableLighting=!0,this.renderMode=K.RENDERMODE_OPAQUE}static __initDefine__(){K.SHADERDEFINE_DIFFUSEMAP=H.getDefineByName("DIFFUSEMAP"),K.SHADERDEFINE_NORMALMAP=H.getDefineByName("NORMALMAP"),K.SHADERDEFINE_SPECULARMAP=H.getDefineByName("SPECULARMAP"),K.SHADERDEFINE_TILINGOFFSET=H.getDefineByName("TILINGOFFSET"),K.SHADERDEFINE_ENABLEVERTEXCOLOR=H.getDefineByName("ENABLEVERTEXCOLOR")}get _ColorR(){return this._albedoColor.x}set _ColorR(e){this._albedoColor.x=e,this.albedoColor=this._albedoColor}get _ColorG(){return this._albedoColor.y}set _ColorG(e){this._albedoColor.y=e,this.albedoColor=this._albedoColor}get _ColorB(){return this._albedoColor.z}set _ColorB(e){this._albedoColor.z=e,this.albedoColor=this._albedoColor}get _ColorA(){return this._albedoColor.w}set _ColorA(e){this._albedoColor.w=e,this.albedoColor=this._albedoColor}get _SpecColorR(){return this._shaderValues.getVector(K.MATERIALSPECULAR).x}set _SpecColorR(e){this._shaderValues.getVector(K.MATERIALSPECULAR).x=e}get _SpecColorG(){return this._shaderValues.getVector(K.MATERIALSPECULAR).y}set _SpecColorG(e){this._shaderValues.getVector(K.MATERIALSPECULAR).y=e}get _SpecColorB(){return this._shaderValues.getVector(K.MATERIALSPECULAR).z}set _SpecColorB(e){this._shaderValues.getVector(K.MATERIALSPECULAR).z=e}get _SpecColorA(){return this._shaderValues.getVector(K.MATERIALSPECULAR).w}set _SpecColorA(e){this._shaderValues.getVector(K.MATERIALSPECULAR).w=e}get _AlbedoIntensity(){return this._albedoIntensity}set _AlbedoIntensity(e){if(this._albedoIntensity!==e){var t=this._shaderValues.getVector(K.ALBEDOCOLOR);a.scale(this._albedoColor,e,t),this._albedoIntensity=e,this._shaderValues.setVector(K.ALBEDOCOLOR,t)}}get _Shininess(){return this._shaderValues.getNumber(K.SHININESS)}set _Shininess(e){e=Math.max(0,Math.min(1,e)),this._shaderValues.setNumber(K.SHININESS,e)}get _MainTex_STX(){return this._shaderValues.getVector(K.TILINGOFFSET).x}set _MainTex_STX(e){var t=this._shaderValues.getVector(K.TILINGOFFSET);t.x=e,this.tilingOffset=t}get _MainTex_STY(){return this._shaderValues.getVector(K.TILINGOFFSET).y}set _MainTex_STY(e){var t=this._shaderValues.getVector(K.TILINGOFFSET);t.y=e,this.tilingOffset=t}get _MainTex_STZ(){return this._shaderValues.getVector(K.TILINGOFFSET).z}set _MainTex_STZ(e){var t=this._shaderValues.getVector(K.TILINGOFFSET);t.z=e,this.tilingOffset=t}get _MainTex_STW(){return this._shaderValues.getVector(K.TILINGOFFSET).w}set _MainTex_STW(e){var t=this._shaderValues.getVector(K.TILINGOFFSET);t.w=e,this.tilingOffset=t}get _Cutoff(){return this.alphaTestValue}set _Cutoff(e){this.alphaTestValue=e}set renderMode(e){switch(e){case K.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=Z.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_DISABLE,this.depthTest=Q.DEPTHTEST_LESS;break;case K.RENDERMODE_CUTOUT:this.renderQueue=Z.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_DISABLE,this.depthTest=Q.DEPTHTEST_LESS;break;case K.RENDERMODE_TRANSPARENT:this.renderQueue=Z.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_ENABLE_ALL,this.blendSrc=Q.BLENDPARAM_SRC_ALPHA,this.blendDst=Q.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=Q.DEPTHTEST_LESS;break;default:throw new Error("Material:renderMode value error.")}}get enableVertexColor(){return this._enableVertexColor}set enableVertexColor(e){this._enableVertexColor=e,e?this._shaderValues.addDefine(K.SHADERDEFINE_ENABLEVERTEXCOLOR):this._shaderValues.removeDefine(K.SHADERDEFINE_ENABLEVERTEXCOLOR)}get tilingOffsetX(){return this._MainTex_STX}set tilingOffsetX(e){this._MainTex_STX=e}get tilingOffsetY(){return this._MainTex_STY}set tilingOffsetY(e){this._MainTex_STY=e}get tilingOffsetZ(){return this._MainTex_STZ}set tilingOffsetZ(e){this._MainTex_STZ=e}get tilingOffsetW(){return this._MainTex_STW}set tilingOffsetW(e){this._MainTex_STW=e}get tilingOffset(){return this._shaderValues.getVector(K.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(K.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(K.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(K.TILINGOFFSET,e)}get albedoColorR(){return this._ColorR}set albedoColorR(e){this._ColorR=e}get albedoColorG(){return this._ColorG}set albedoColorG(e){this._ColorG=e}get albedoColorB(){return this._ColorB}set albedoColorB(e){this._ColorB=e}get albedoColorA(){return this._ColorA}set albedoColorA(e){this._ColorA=e}get albedoColor(){return this._albedoColor}set albedoColor(e){var t=this._shaderValues.getVector(K.ALBEDOCOLOR);a.scale(e,this._albedoIntensity,t),this._albedoColor=e,this._shaderValues.setVector(K.ALBEDOCOLOR,t)}get albedoIntensity(){return this._albedoIntensity}set albedoIntensity(e){this._AlbedoIntensity=e}get specularColorR(){return this._SpecColorR}set specularColorR(e){this._SpecColorR=e}get specularColorG(){return this._SpecColorG}set specularColorG(e){this._SpecColorG=e}get specularColorB(){return this._SpecColorB}set specularColorB(e){this._SpecColorB=e}get specularColorA(){return this._SpecColorA}set specularColorA(e){this._SpecColorA=e}get specularColor(){return this._shaderValues.getVector(K.MATERIALSPECULAR)}set specularColor(e){this._shaderValues.setVector(K.MATERIALSPECULAR,e)}get shininess(){return this._Shininess}set shininess(e){this._Shininess=e}get albedoTexture(){return this._shaderValues.getTexture(K.ALBEDOTEXTURE)}set albedoTexture(e){e?this._shaderValues.addDefine(K.SHADERDEFINE_DIFFUSEMAP):this._shaderValues.removeDefine(K.SHADERDEFINE_DIFFUSEMAP),this._shaderValues.setTexture(K.ALBEDOTEXTURE,e)}get normalTexture(){return this._shaderValues.getTexture(K.NORMALTEXTURE)}set normalTexture(e){e?this._shaderValues.addDefine(K.SHADERDEFINE_NORMALMAP):this._shaderValues.removeDefine(K.SHADERDEFINE_NORMALMAP),this._shaderValues.setTexture(K.NORMALTEXTURE,e)}get specularTexture(){return this._shaderValues.getTexture(K.SPECULARTEXTURE)}set specularTexture(e){e?this._shaderValues.addDefine(K.SHADERDEFINE_SPECULARMAP):this._shaderValues.removeDefine(K.SHADERDEFINE_SPECULARMAP),this._shaderValues.setTexture(K.SPECULARTEXTURE,e)}get depthWrite(){return this._shaderValues.getBool(K.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(K.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(K.CULL)}set cull(e){this._shaderValues.setInt(K.CULL,e)}get blend(){return this._shaderValues.getInt(K.BLEND)}set blend(e){this._shaderValues.setInt(K.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(K.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(K.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(K.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(K.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt(K.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(K.DEPTH_TEST,e)}clone(){var e=new K;return this.cloneTo(e),e}cloneTo(e){super.cloneTo(e);var t=e;t._enableLighting=this._enableLighting,t._albedoIntensity=this._albedoIntensity,t._enableVertexColor=this._enableVertexColor,this._albedoColor.cloneTo(t._albedoColor)}}K.RENDERMODE_OPAQUE=0,K.RENDERMODE_CUTOUT=1,K.RENDERMODE_TRANSPARENT=2,K.ALBEDOTEXTURE=H.propertyNameToID("u_DiffuseTexture"),K.NORMALTEXTURE=H.propertyNameToID("u_NormalTexture"),K.SPECULARTEXTURE=H.propertyNameToID("u_SpecularTexture"),K.ALBEDOCOLOR=H.propertyNameToID("u_DiffuseColor"),K.MATERIALSPECULAR=H.propertyNameToID("u_MaterialSpecular"),K.SHININESS=H.propertyNameToID("u_Shininess"),K.TILINGOFFSET=H.propertyNameToID("u_TilingOffset"),K.CULL=H.propertyNameToID("s_Cull"),K.BLEND=H.propertyNameToID("s_Blend"),K.BLEND_SRC=H.propertyNameToID("s_BlendSrc"),K.BLEND_DST=H.propertyNameToID("s_BlendDst"),K.DEPTH_TEST=H.propertyNameToID("s_DepthTest"),K.DEPTH_WRITE=H.propertyNameToID("s_DepthWrite");class J extends Z{constructor(){super(),this.setShaderName("Effect"),this._color=new a(1,1,1,1),this._shaderValues.setVector(J.TINTCOLOR,new a(1,1,1,1)),this.renderMode=J.RENDERMODE_ADDTIVE}static __initDefine__(){J.SHADERDEFINE_MAINTEXTURE=H.getDefineByName("MAINTEXTURE"),J.SHADERDEFINE_TILINGOFFSET=H.getDefineByName("TILINGOFFSET"),J.SHADERDEFINE_ADDTIVEFOG=H.getDefineByName("ADDTIVEFOG")}get _TintColorR(){return this._color.x}set _TintColorR(e){this._color.x=e,this.color=this._color}get _TintColorG(){return this._color.y}set _TintColorG(e){this._color.y=e,this.color=this._color}get _TintColorB(){return this._color.z}set _TintColorB(e){this._color.z=e,this.color=this._color}get _TintColorA(){return this._color.w}set _TintColorA(e){this._color.w=e,this.color=this._color}get _MainTex_STX(){return this._shaderValues.getVector(J.TILINGOFFSET).x}set _MainTex_STX(e){var t=this._shaderValues.getVector(J.TILINGOFFSET);t.x=e,this.tilingOffset=t}get _MainTex_STY(){return this._shaderValues.getVector(J.TILINGOFFSET).y}set _MainTex_STY(e){var t=this._shaderValues.getVector(J.TILINGOFFSET);t.y=e,this.tilingOffset=t}get _MainTex_STZ(){return this._shaderValues.getVector(J.TILINGOFFSET).z}set _MainTex_STZ(e){var t=this._shaderValues.getVector(J.TILINGOFFSET);t.z=e,this.tilingOffset=t}get _MainTex_STW(){return this._shaderValues.getVector(J.TILINGOFFSET).w}set _MainTex_STW(e){var t=this._shaderValues.getVector(J.TILINGOFFSET);t.w=e,this.tilingOffset=t}set renderMode(e){switch(e){case J.RENDERMODE_ADDTIVE:this.renderQueue=Z.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=Q.CULL_NONE,this.blend=Q.BLEND_ENABLE_ALL,this.blendSrc=Q.BLENDPARAM_SRC_ALPHA,this.blendDst=Q.BLENDPARAM_ONE,this.depthTest=Q.DEPTHTEST_LESS,this._shaderValues.addDefine(J.SHADERDEFINE_ADDTIVEFOG);break;case J.RENDERMODE_ALPHABLENDED:this.renderQueue=Z.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=Q.CULL_NONE,this.blend=Q.BLEND_ENABLE_ALL,this.blendSrc=Q.BLENDPARAM_SRC_ALPHA,this.blendDst=Q.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=Q.DEPTHTEST_LESS,this._shaderValues.removeDefine(J.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("MeshEffectMaterial : renderMode value error.")}}get colorR(){return this._TintColorR}set colorR(e){this._TintColorR=e}get colorG(){return this._TintColorG}set colorG(e){this._TintColorG=e}get colorB(){return this._TintColorB}set colorB(e){this._TintColorB=e}get colorA(){return this._TintColorA}set colorA(e){this._TintColorA=e}get color(){return this._shaderValues.getVector(J.TINTCOLOR)}set color(e){this._shaderValues.setVector(J.TINTCOLOR,e)}get texture(){return this._shaderValues.getTexture(J.MAINTEXTURE)}set texture(e){e?this._shaderValues.addDefine(J.SHADERDEFINE_MAINTEXTURE):this._shaderValues.removeDefine(J.SHADERDEFINE_MAINTEXTURE),this._shaderValues.setTexture(J.MAINTEXTURE,e)}get tilingOffsetX(){return this._MainTex_STX}set tilingOffsetX(e){this._MainTex_STX=e}get tilingOffsetY(){return this._MainTex_STY}set tilingOffsetY(e){this._MainTex_STY=e}get tilingOffsetZ(){return this._MainTex_STZ}set tilingOffsetZ(e){this._MainTex_STZ=e}get tilingOffsetW(){return this._MainTex_STW}set tilingOffsetW(e){this._MainTex_STW=e}get tilingOffset(){return this._shaderValues.getVector(J.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(J.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(J.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(J.TILINGOFFSET,e)}get depthWrite(){return this._shaderValues.getBool(J.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(J.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(J.CULL)}set cull(e){this._shaderValues.setInt(J.CULL,e)}get blend(){return this._shaderValues.getInt(J.BLEND)}set blend(e){this._shaderValues.setInt(J.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(J.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(J.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(J.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(J.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt(J.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(J.DEPTH_TEST,e)}clone(){var e=new J;return this.cloneTo(e),e}}J.RENDERMODE_ADDTIVE=0,J.RENDERMODE_ALPHABLENDED=1,J.MAINTEXTURE=H.propertyNameToID("u_AlbedoTexture"),J.TINTCOLOR=H.propertyNameToID("u_AlbedoColor"),J.TILINGOFFSET=H.propertyNameToID("u_TilingOffset"),J.CULL=H.propertyNameToID("s_Cull"),J.BLEND=H.propertyNameToID("s_Blend"),J.BLEND_SRC=H.propertyNameToID("s_BlendSrc"),J.BLEND_DST=H.propertyNameToID("s_BlendDst"),J.DEPTH_TEST=H.propertyNameToID("s_DepthTest"),J.DEPTH_WRITE=H.propertyNameToID("s_DepthWrite");class $ extends Z{constructor(){super(),this._enableLighting=!0,this.setShaderName("ExtendTerrain"),this.renderMode=$.RENDERMODE_OPAQUE}static __initDefine__(){$.SHADERDEFINE_DETAIL_NUM1=H.getDefineByName("ExtendTerrain_DETAIL_NUM1"),$.SHADERDEFINE_DETAIL_NUM2=H.getDefineByName("ExtendTerrain_DETAIL_NUM2"),$.SHADERDEFINE_DETAIL_NUM3=H.getDefineByName("ExtendTerrain_DETAIL_NUM3"),$.SHADERDEFINE_DETAIL_NUM4=H.getDefineByName("ExtendTerrain_DETAIL_NUM4"),$.SHADERDEFINE_DETAIL_NUM5=H.getDefineByName("ExtendTerrain_DETAIL_NUM5")}get splatAlphaTexture(){return this._shaderValues.getTexture($.SPLATALPHATEXTURE)}set splatAlphaTexture(e){this._shaderValues.setTexture($.SPLATALPHATEXTURE,e)}get diffuseTexture1(){return this._shaderValues.getTexture($.DIFFUSETEXTURE1)}set diffuseTexture1(e){this._shaderValues.setTexture($.DIFFUSETEXTURE1,e),this._setDetailNum(1)}get diffuseTexture2(){return this._shaderValues.getTexture($.DIFFUSETEXTURE2)}set diffuseTexture2(e){this._shaderValues.setTexture($.DIFFUSETEXTURE2,e),this._setDetailNum(2)}get diffuseTexture3(){return this._shaderValues.getTexture($.DIFFUSETEXTURE3)}set diffuseTexture3(e){this._shaderValues.setTexture($.DIFFUSETEXTURE3,e),this._setDetailNum(3)}get diffuseTexture4(){return this._shaderValues.getTexture($.DIFFUSETEXTURE4)}set diffuseTexture4(e){this._shaderValues.setTexture($.DIFFUSETEXTURE4,e),this._setDetailNum(4)}get diffuseTexture5(){return this._shaderValues.getTexture($.DIFFUSETEXTURE5)}set diffuseTexture5(e){this._shaderValues.setTexture($.DIFFUSETEXTURE5,e),this._setDetailNum(5)}set diffuseScaleOffset1(e){this._shaderValues.setVector($.DIFFUSESCALEOFFSET1,e)}set diffuseScaleOffset2(e){this._shaderValues.setVector($.DIFFUSESCALEOFFSET2,e)}set diffuseScaleOffset3(e){this._shaderValues.setVector($.DIFFUSESCALEOFFSET3,e)}set diffuseScaleOffset4(e){this._shaderValues.setVector($.DIFFUSESCALEOFFSET4,e)}set diffuseScaleOffset5(e){this._shaderValues.setVector($.DIFFUSESCALEOFFSET5,e)}set renderMode(e){switch(e){case $.RENDERMODE_OPAQUE:this.renderQueue=Z.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_DISABLE,this.depthTest=Q.DEPTHTEST_LESS;break;case $.RENDERMODE_TRANSPARENT:this.renderQueue=Z.RENDERQUEUE_OPAQUE,this.depthWrite=!1,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_ENABLE_ALL,this.blendSrc=Q.BLENDPARAM_SRC_ALPHA,this.blendDst=Q.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=Q.DEPTHTEST_LEQUAL;break;default:throw new Error("ExtendTerrainMaterial:renderMode value error.")}}get depthWrite(){return this._shaderValues.getBool($.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool($.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt($.CULL)}set cull(e){this._shaderValues.setInt($.CULL,e)}get blend(){return this._shaderValues.getInt($.BLEND)}set blend(e){this._shaderValues.setInt($.BLEND,e)}get blendSrc(){return this._shaderValues.getInt($.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt($.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt($.BLEND_DST)}set blendDst(e){this._shaderValues.setInt($.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt($.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt($.DEPTH_TEST,e)}_setDetailNum(e){switch(e){case 1:this._shaderValues.addDefine($.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM5);break;case 2:this._shaderValues.addDefine($.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM5);break;case 3:this._shaderValues.addDefine($.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM5);break;case 4:this._shaderValues.addDefine($.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM5);break;case 5:this._shaderValues.addDefine($.SHADERDEFINE_DETAIL_NUM5),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine($.SHADERDEFINE_DETAIL_NUM4)}}clone(){var e=new $;return this.cloneTo(e),e}}$.RENDERMODE_OPAQUE=1,$.RENDERMODE_TRANSPARENT=2,$.SPLATALPHATEXTURE=H.propertyNameToID("u_SplatAlphaTexture"),$.DIFFUSETEXTURE1=H.propertyNameToID("u_DiffuseTexture1"),$.DIFFUSETEXTURE2=H.propertyNameToID("u_DiffuseTexture2"),$.DIFFUSETEXTURE3=H.propertyNameToID("u_DiffuseTexture3"),$.DIFFUSETEXTURE4=H.propertyNameToID("u_DiffuseTexture4"),$.DIFFUSETEXTURE5=H.propertyNameToID("u_DiffuseTexture5"),$.DIFFUSESCALEOFFSET1=H.propertyNameToID("u_DiffuseScaleOffset1"),$.DIFFUSESCALEOFFSET2=H.propertyNameToID("u_DiffuseScaleOffset2"),$.DIFFUSESCALEOFFSET3=H.propertyNameToID("u_DiffuseScaleOffset3"),$.DIFFUSESCALEOFFSET4=H.propertyNameToID("u_DiffuseScaleOffset4"),$.DIFFUSESCALEOFFSET5=H.propertyNameToID("u_DiffuseScaleOffset5"),$.CULL=H.propertyNameToID("s_Cull"),$.BLEND=H.propertyNameToID("s_Blend"),$.BLEND_SRC=H.propertyNameToID("s_BlendSrc"),$.BLEND_DST=H.propertyNameToID("s_BlendDst"),$.DEPTH_TEST=H.propertyNameToID("s_DepthTest"),$.DEPTH_WRITE=H.propertyNameToID("s_DepthWrite"),(o=e.PBRRenderMode||(e.PBRRenderMode={}))[o.Opaque=0]="Opaque",o[o.Cutout=1]="Cutout",o[o.Fade=2]="Fade",o[o.Transparent=3]="Transparent";class ee extends Z{constructor(){super(),this._enableEmission=!1,this._shaderValues.setVector(ee.ALBEDOCOLOR,new a(1,1,1,1)),this._shaderValues.setVector(ee.EMISSIONCOLOR,new a(1,1,1,1)),this._shaderValues.setNumber(ee.SMOOTHNESS,.5),this._shaderValues.setNumber(ee.SMOOTHNESSSCALE,1),this._shaderValues.setNumber(ee.OCCLUSIONSTRENGTH,1),this._shaderValues.setNumber(ee.NORMALSCALE,1),this._shaderValues.setNumber(ee.PARALLAXSCALE,.001),this._shaderValues.setNumber(Z.ALPHATESTVALUE,.5),this.renderMode=e.PBRRenderMode.Opaque}static __init__(){ee.SHADERDEFINE_ALBEDOTEXTURE=H.getDefineByName("ALBEDOTEXTURE"),ee.SHADERDEFINE_NORMALTEXTURE=H.getDefineByName("NORMALTEXTURE"),ee.SHADERDEFINE_PARALLAXTEXTURE=H.getDefineByName("PARALLAXTEXTURE"),ee.SHADERDEFINE_OCCLUSIONTEXTURE=H.getDefineByName("OCCLUSIONTEXTURE"),ee.SHADERDEFINE_EMISSION=H.getDefineByName("EMISSION"),ee.SHADERDEFINE_EMISSIONTEXTURE=H.getDefineByName("EMISSIONTEXTURE"),ee.SHADERDEFINE_TILINGOFFSET=H.getDefineByName("TILINGOFFSET"),ee.SHADERDEFINE_TRANSPARENTBLEND=H.getDefineByName("TRANSPARENTBLEND"),ee.SHADERDEFINE_LAYA_PBR_BRDF_HIGH=H.getDefineByName("LAYA_PBR_BRDF_HIGH"),ee.SHADERDEFINE_LAYA_PBR_BRDF_LOW=H.getDefineByName("LAYA_PBR_BRDF_LOW")}get albedoColor(){return this._shaderValues.getVector(ee.ALBEDOCOLOR)}set albedoColor(e){this._shaderValues.setVector(ee.ALBEDOCOLOR,e)}get albedoTexture(){return this._shaderValues.getTexture(ee.ALBEDOTEXTURE)}set albedoTexture(e){e?this._shaderValues.addDefine(ee.SHADERDEFINE_ALBEDOTEXTURE):this._shaderValues.removeDefine(ee.SHADERDEFINE_ALBEDOTEXTURE),this._shaderValues.setTexture(ee.ALBEDOTEXTURE,e)}get normalTexture(){return this._shaderValues.getTexture(ee.NORMALTEXTURE)}set normalTexture(e){e?this._shaderValues.addDefine(ee.SHADERDEFINE_NORMALTEXTURE):this._shaderValues.removeDefine(ee.SHADERDEFINE_NORMALTEXTURE),this._shaderValues.setTexture(ee.NORMALTEXTURE,e)}get normalTextureScale(){return this._shaderValues.getNumber(ee.NORMALSCALE)}set normalTextureScale(e){this._shaderValues.setNumber(ee.NORMALSCALE,e)}get parallaxTexture(){return this._shaderValues.getTexture(ee.PARALLAXTEXTURE)}set parallaxTexture(e){e?this._shaderValues.addDefine(ee.SHADERDEFINE_PARALLAXTEXTURE):this._shaderValues.removeDefine(ee.SHADERDEFINE_PARALLAXTEXTURE),this._shaderValues.setTexture(ee.PARALLAXTEXTURE,e)}get parallaxTextureScale(){return this._shaderValues.getNumber(ee.PARALLAXSCALE)}set parallaxTextureScale(e){this._shaderValues.setNumber(ee.PARALLAXSCALE,Math.max(.005,Math.min(.08,e)))}get occlusionTexture(){return this._shaderValues.getTexture(ee.OCCLUSIONTEXTURE)}set occlusionTexture(e){e?this._shaderValues.addDefine(ee.SHADERDEFINE_OCCLUSIONTEXTURE):this._shaderValues.removeDefine(ee.SHADERDEFINE_OCCLUSIONTEXTURE),this._shaderValues.setTexture(ee.OCCLUSIONTEXTURE,e)}get occlusionTextureStrength(){return this._shaderValues.getNumber(ee.OCCLUSIONSTRENGTH)}set occlusionTextureStrength(e){this._shaderValues.setNumber(ee.OCCLUSIONSTRENGTH,Math.max(0,Math.min(1,e)))}get smoothness(){return this._shaderValues.getNumber(ee.SMOOTHNESS)}set smoothness(e){this._shaderValues.setNumber(ee.SMOOTHNESS,Math.max(0,Math.min(1,e)))}get smoothnessTextureScale(){return this._shaderValues.getNumber(ee.SMOOTHNESSSCALE)}set smoothnessTextureScale(e){this._shaderValues.setNumber(ee.SMOOTHNESSSCALE,Math.max(0,Math.min(1,e)))}get enableEmission(){return this._enableEmission}set enableEmission(e){e?this._shaderValues.addDefine(ee.SHADERDEFINE_EMISSION):this._shaderValues.removeDefine(ee.SHADERDEFINE_EMISSION),this._enableEmission=e}get emissionColor(){return this._shaderValues.getVector(ee.EMISSIONCOLOR)}set emissionColor(e){this._shaderValues.setVector(ee.EMISSIONCOLOR,e)}get emissionTexture(){return this._shaderValues.getTexture(ee.EMISSIONTEXTURE)}set emissionTexture(e){e?this._shaderValues.addDefine(ee.SHADERDEFINE_EMISSIONTEXTURE):this._shaderValues.removeDefine(ee.SHADERDEFINE_EMISSIONTEXTURE),this._shaderValues.setTexture(ee.EMISSIONTEXTURE,e)}get tilingOffset(){return this._shaderValues.getVector(ee.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(ee.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(ee.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(ee.TILINGOFFSET,e)}get depthWrite(){return this._shaderValues.getBool(ee.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(ee.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(ee.CULL)}set cull(e){this._shaderValues.setInt(ee.CULL,e)}get blend(){return this._shaderValues.getInt(ee.BLEND)}set blend(e){this._shaderValues.setInt(ee.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(ee.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(ee.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(ee.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(ee.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt(ee.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(ee.DEPTH_TEST,e)}set renderMode(t){switch(t){case e.PBRRenderMode.Opaque:this.alphaTest=!1,this.renderQueue=Z.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_DISABLE,this.depthTest=Q.DEPTHTEST_LESS,this._shaderValues.removeDefine(ee.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Cutout:this.renderQueue=Z.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_DISABLE,this.depthTest=Q.DEPTHTEST_LESS,this._shaderValues.removeDefine(ee.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Fade:this.renderQueue=Z.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_ENABLE_ALL,this.blendSrc=Q.BLENDPARAM_SRC_ALPHA,this.blendDst=Q.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=Q.DEPTHTEST_LESS,this._shaderValues.removeDefine(ee.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Transparent:this.renderQueue=Z.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=Q.CULL_BACK,this.blend=Q.BLEND_ENABLE_ALL,this.blendSrc=Q.BLENDPARAM_ONE,this.blendDst=Q.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=Q.DEPTHTEST_LESS,this._shaderValues.addDefine(ee.SHADERDEFINE_TRANSPARENTBLEND);break;default:throw new Error("PBRMaterial:unknown renderMode value.")}}get enableReflection(){return!0}set enableReflection(e){}}ee.ALBEDOTEXTURE=H.propertyNameToID("u_AlbedoTexture"),ee.ALBEDOCOLOR=H.propertyNameToID("u_AlbedoColor"),ee.TILINGOFFSET=H.propertyNameToID("u_TilingOffset"),ee.NORMALTEXTURE=H.propertyNameToID("u_NormalTexture"),ee.NORMALSCALE=H.propertyNameToID("u_NormalScale"),ee.SMOOTHNESS=H.propertyNameToID("u_Smoothness"),ee.SMOOTHNESSSCALE=H.propertyNameToID("u_SmoothnessScale"),ee.OCCLUSIONTEXTURE=H.propertyNameToID("u_OcclusionTexture"),ee.OCCLUSIONSTRENGTH=H.propertyNameToID("u_occlusionStrength"),ee.PARALLAXTEXTURE=H.propertyNameToID("u_ParallaxTexture"),ee.PARALLAXSCALE=H.propertyNameToID("u_ParallaxScale"),ee.EMISSIONTEXTURE=H.propertyNameToID("u_EmissionTexture"),ee.EMISSIONCOLOR=H.propertyNameToID("u_EmissionColor"),ee.CULL=H.propertyNameToID("s_Cull"),ee.BLEND=H.propertyNameToID("s_Blend"),ee.BLEND_SRC=H.propertyNameToID("s_BlendSrc"),ee.BLEND_DST=H.propertyNameToID("s_BlendDst"),ee.DEPTH_TEST=H.propertyNameToID("s_DepthTest"),ee.DEPTH_WRITE=H.propertyNameToID("s_DepthWrite"),ee.renderQuality=e.PBRRenderQuality.High;var te,re,ie,ae,ne,se,oe,le,_e,he,ce='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#define SETUP_BRDF_INPUT specularSetup\r\n\r\n#include "Lighting.glsl";\r\n#include "PBRFSInput.glsl";\r\n#include "LayaPBRBRDF.glsl";\r\n#include "GlobalIllumination.glsl";\r\n#include "Shadow.glsl"\r\n#include "PBRCore.glsl";\r\n\r\nvoid main()\r\n{\r\n\tfragmentForward();\r\n}',de='#include "PBRVSInput.glsl";\r\n#include "Lighting.glsl";\r\n#include "PBRVertex.glsl";\r\n\r\nvoid main()\r\n{\r\n\tvertexForward();\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',ue='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#include "ShadowCasterFS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tgl_FragColor=shadowCasterFragment();\r\n}',me='#include "ShadowCasterVS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionCS = shadowCasterVertex();\r\n\tgl_Position=remapGLPositionZ(positionCS);\r\n}';class fe{constructor(){this.textureID=-1}}class Ee extends t.Resource{constructor(e,t,r,i,a){super(),this._stateParamsMap=[],this._uploadMark=-1,this._uploadRenderType=-1,this._vs=e,this._ps=t,this._attributeMap=r,this._uniformMap=i,this._shaderPass=a,this._create(),this.lock=!0}_create(){var e=t.LayaGL.instance;for(var r in this._program=e.createProgram(),this._vshader=this._createShader(e,this._vs,e.VERTEX_SHADER),this._pshader=this._createShader(e,this._ps,e.FRAGMENT_SHADER),e.attachShader(this._program,this._vshader),e.attachShader(this._program,this._pshader),this._attributeMap)e.bindAttribLocation(this._program,this._attributeMap[r],r);if(e.linkProgram(this._program),!t.Render.isConchApp&&H.debugMode&&!e.getProgramParameter(this._program,e.LINK_STATUS))throw e.getProgramInfoLog(this._program);var i=[],a=[],n=[],s=[],o=[];this._customUniformParamsMap=[];var l,_,h,c=e.getProgramParameter(this._program,e.ACTIVE_UNIFORMS);for(t.WebGLContext.useProgram(e,this._program),this._curActTexIndex=0,_=0;_0?(l.name=u=u.substr(0,u.length-3),l.isArray=!0):(l.name=u,l.isArray=!1),l.type=d.type,this._addShaderUnifiormFun(l);var m=this._uniformMap[u];if(null!=m)switch(l.dataOffset=H.propertyNameToID(u),m){case H.PERIOD_CUSTOM:o.push(l);break;case H.PERIOD_MATERIAL:s.push(l);break;case H.PERIOD_SPRITE:n.push(l);break;case H.PERIOD_CAMERA:a.push(l);break;case H.PERIOD_SCENE:i.push(l);break;default:throw new Error("Shader3D: period is unkonw.")}}for(this._sceneUniformParamsMap=t.LayaGL.instance.createCommandEncoder(4*i.length*5+4,64,!0),_=0,h=i.length;_=0&&e<=30))throw new Error("Layer value must be 0-30.");this._layer=e}}get url(){return this._url}get isStatic(){return this._isStatic}get transform(){return this._transform}_setCreateURL(e){this._url=t.URL.formatURL(e)}_changeAnimatorsToLinkSprite3D(e,t,r){var i=this.getComponent(P);if(i&&(i.avatar||e._changeAnimatorToLinkSprite3DNoAvatar(i,t,r)),this._parent&&this._parent instanceof ve){r.unshift(this._parent.name);var a=this._parent;a._hierarchyAnimator&&a._changeAnimatorsToLinkSprite3D(e,t,r)}}_setHierarchyAnimator(e,t){this._changeHierarchyAnimator(e),this._changeAnimatorAvatar(e.avatar);for(var r=0,i=this._children.length;r0){for(var i=0;i0;)r--;if(t1){var i=this._partition(e,t,r),a=i-1;t0&&l._quickSort(0,f-1),(f=_.elements.length)>0&&_._quickSort(0,f-1)}static cullingShadow(e,r,i){var a=r._opaqueQueue,s=r._transparentQueue,o=r._renders;a.clear(),s.clear();for(var l=Ie._managers,_=0,h=l.length;_0}static renderObjectCullingNative(e,r,i,a,s,o){var l,_,h,c,d=r._opaqueQueue,u=r._transparentQueue;d.clear(),u.clear();var m=Ie._managers;for(l=0,_=m.length;l<_;l++)m[l]._clear();var f=Se._managers;for(l=0,_=f.length;l<_;l++)f[l]._clear();var E=a.length,T=a.elements;for(l=0;l0&&d._quickSort(0,v-1),(v=u.elements.length)>0&&u._quickSort(0,v-1)}static cullingNative(e,r,i,a,n){return t.LayaGL.instance.culling(e,r,i,a,n)}}Ce._tempColor0=new ge,Ce._tempVector0=new n,Ce._cameraCullInfo=new Ae,Ce._shadowCullInfo=new Le,Ce.debugFrustumCulling=!1;class De{constructor(){this.updateMark=-1,this.pointLightCount=0,this.spotLightCount=0,this.indices=[]}}class Me{constructor(e,t,r,a){this._updateMark=0,this._depthSliceParam=new i,this._xSlices=e,this._ySlices=t,this._zSlices=r;var n=e*t,s=r*(1+Math.ceil(a/4));this._clusterTexture=I._createFloatTextureBuffer(n,s),this._clusterTexture.lock=!0,this._clusterPixels=new Float32Array(n*s*4);for(var o=new Array(this._zSlices),l=0;ll*l))return!1;var _=n.dot(s,t);return!(Math.cos(i)*Math.sqrt(o-_*_)-_*Math.sin(i)>l||_>l+r||_<-l)}_placePointLightToClusters(e,t){for(var r=this._clusterDatas,i=this._updateMark,a=t.zMin,n=t.zMax;at||o<=e)return!1;var l=this._depthSliceParam;return a.zMin=Math.floor(Math.log2(Math.max(s,e))*l.x-l.y),a.zMax=Math.min(Math.ceil(Math.log2(o)*l.x-l.y),this._zSlices),!0}_shrinkSpotLightZPerspective(e,t,r,i,a,n,s){var o=i.x,l=i.y,_=i.z,h=Math.tan(n)*a,c=r.x,d=r.y,u=r.z,m=o-c,f=l-d,E=_-u,T=m*m+f*f+E*E,p=Math.sqrt(1-E*E/T),g=Math.max(Math.min(u,_-p*h),r.z-a),S=Math.min(Math.max(u,_+p*h),r.z+a);if(g>t||S<=e)return!1;var R=this._depthSliceParam;return s.zMin=Math.floor(Math.log2(Math.max(g,e))*R.x-R.y),s.zMax=Math.min(Math.ceil(Math.log2(S)*R.x-R.y),this._zSlices),!0}_shrinkSphereLightByBoundOrth(e,t,r,i,a,n,s){var o=a.z,l=o-n,_=o+n;if(l>i||_<=r)return!1;var h=a.x,c=h-n,d=h+n;if(c>e||d<=-e)return!1;var u=a.y,m=u-n,f=u+n;if(m>t||f<=-t)return!1;var E=this._xSlices,T=this._ySlices,p=this._depthSliceParam,g=2*e/E,S=2*t/T;return s.xMin=Math.max(Math.floor((c+e)/g),0),s.xMax=Math.min(Math.ceil((d+e)/g),E),s.yMin=Math.max(Math.floor((t-f)/S),0),s.yMax=Math.min(Math.ceil((t-m)/S),T),s.zMin=Math.floor(Math.log2(Math.max(l,r))*p.x-p.y),s.zMax=Math.min(Math.ceil(Math.log2(_)*p.x-p.y),this._zSlices),!0}_shrinkSpotLightByBoundOrth(e,t,r,i,a,n,s,o,l){var _=n.x,h=n.y,c=n.z,d=Math.tan(o)*s,u=a.x,m=a.y,f=a.z,E=_-u,T=h-m,p=c-f,g=E*E+T*T+p*p,S=Math.sqrt(1-p*p/g),R=Math.max(Math.min(f,c-S*d),a.z-s),v=Math.min(Math.max(f,c+S*d),a.z+s);if(R>i||v<=r)return!1;var x=Math.sqrt(1-E*E/g),I=Math.max(Math.min(u,_-x*d),a.x-s),A=Math.min(Math.max(u,_+x*d),a.x+s);if(I>e||A<=-e)return!1;var L=Math.sqrt(1-T*T/g),C=Math.max(Math.min(m,h-L*d),a.y-s),D=Math.min(Math.max(m,h+L*d),a.y+s);if(C>t||D<=-t)return!1;var M=this._xSlices,y=this._ySlices,O=this._depthSliceParam,N=2*e/M,b=2*t/y;return l.xMin=Math.max(Math.floor((I+e)/N),0),l.xMax=Math.min(Math.ceil((A+e)/N),M),l.yMin=Math.max(Math.floor((t-D)/b),0),l.yMax=Math.min(Math.ceil((t-C)/b),y),l.zMin=Math.floor(Math.log2(Math.max(R,r))*O.x-O.y),l.zMax=Math.min(Math.ceil(Math.log2(v)*O.x-O.y),this._zSlices),!0}_shrinkXYByRadiusPerspective(e,t,r,i,a){var n,s,o,l,_,h=e.x,c=e.y,d=e.z,u=this._ySlices+1;for(_=0;_0){for(var g=this._xSlices,S=this._ySlices,R=this._zSlices,v=g*S*4,x=v*R,I=this._clusterPixels,A=I.length,L=this._clusterDatas,C=this._updateMark,D=!0,M=0;Mo&&(u+=(o-h)*(o-h)),cl&&(u+=(l-c)*(l-c)),d_&&(u+=(_-d)*(_-d)),Math.sqrt(u)}static distanceBoxToBox(e,t){var r,i=e.min,a=i.x,n=i.y,s=i.z,o=e.max,l=o.x,_=o.y,h=o.z,c=t.min,d=c.x,u=c.y,m=c.z,f=t.max,E=f.x,T=f.y,p=f.z,g=0;return a>E?g+=(r=a-E)*r:d>l&&(g+=(r=d-l)*r),n>T?g+=(r=n-T)*r:u>_&&(g+=(r=u-_)*r),s>p?g+=(r=s-p)*r:m>h&&(g+=(r=m-h)*r),Math.sqrt(g)}static distanceSphereToPoint(e,t){var r=Math.sqrt(n.distanceSquared(e.center,t));return r-=e.radius,Math.max(r,0)}static distanceSphereToSphere(e,t){var r=Math.sqrt(n.distanceSquared(e.center,t.center));return r-=e.radius+t.radius,Math.max(r,0)}static intersectsRayAndTriangleRD(e,t,i,a,n){var s=e.origin,o=s.x,l=s.y,_=s.z,h=e.direction,c=h.x,d=h.y,u=h.z,m=t.x,f=t.y,E=t.z,T=i.x,p=i.y,g=i.z,S=a.x,R=a.y,v=a.z,x=Ve._tempV30.x,I=Ve._tempV30.y,A=Ve._tempV30.z;x=T-m,I=p-f,A=g-E;var L=Ve._tempV31.x,C=Ve._tempV31.y,D=Ve._tempV31.z;L=S-m,C=R-f,D=v-E;var M=Ve._tempV32.x,y=Ve._tempV32.y,O=Ve._tempV32.z,N=x*(M=d*D-u*C)+I*(y=u*L-c*D)+A*(O=c*C-d*L);if(r.isZero(N))return!1;var b=1/N,P=Ve._tempV33.x,w=Ve._tempV33.y,V=Ve._tempV33.z,B=(P=o-m)*M+(w=l-f)*y+(V=_-E)*O;if((B*=b)<0||B>1)return!1;var F=Ve._tempV34.x,U=Ve._tempV34.y,G=Ve._tempV34.z,z=c*(F=w*A-V*I)+d*(U=V*x-P*A)+u*(G=P*I-w*x);if((z*=b)<0||B+z>1)return!1;var H=L*F+C*U+D*G;return!((H*=b)<0)}static intersectsRayAndTriangleRP(e,t,r,i,a){return Ve.intersectsRayAndTriangleRD(e,t,r,i,void 0)?(n.scale(e.direction,void 0,Ve._tempV30),n.add(e.origin,Ve._tempV30,a),!0):(a=n._ZERO,!1)}static intersectsRayAndPoint(e,t){n.subtract(e.origin,t,Ve._tempV30);var i=n.dot(Ve._tempV30,e.direction),a=n.dot(Ve._tempV30,Ve._tempV30)-r.zeroTolerance;return!(a>0&&i>0)&&!(i*i-a<0)}static intersectsRayAndRay(e,t,i){var a=e.origin,s=a.x,o=a.y,l=a.z,_=e.direction,h=_.x,c=_.y,d=_.z,u=t.origin,m=u.x,f=u.y,E=u.z,T=t.direction,p=T.x,g=T.y,S=T.z;n.cross(_,T,Ve._tempV30);var R=Ve._tempV30,v=n.scalarLength(Ve._tempV30);if(r.isZero(v)&&r.nearEqual(m,s)&&r.nearEqual(f,o)&&r.nearEqual(E,l))return!0;v*=v;var x=m-s,I=f-o,A=E-l,L=p,C=g,D=S,M=R.x,y=R.y,O=R.z,N=x*C*O+I*D*M+A*L*y-x*D*y-I*L*O-A*C*M;L=h,C=c,D=d;var b=N/v;n.scale(_,b,Ve._tempV30),n.scale(T,b,Ve._tempV31),n.add(a,Ve._tempV30,Ve._tempV32),n.add(u,Ve._tempV31,Ve._tempV33);var P=Ve._tempV32,w=Ve._tempV33;return!!(r.nearEqual(w.x,P.x)&&r.nearEqual(w.y,P.y)&&r.nearEqual(w.z,P.z))}static intersectsPlaneAndTriangle(e,t,r,i){var a=Ve.intersectsPlaneAndPoint(e,t),n=Ve.intersectsPlaneAndPoint(e,r),s=Ve.intersectsPlaneAndPoint(e,i);return a==be.PlaneIntersectionType_Front&&n==be.PlaneIntersectionType_Front&&s==be.PlaneIntersectionType_Front?be.PlaneIntersectionType_Front:a==be.PlaneIntersectionType_Back&&n==be.PlaneIntersectionType_Back&&s==be.PlaneIntersectionType_Back?be.PlaneIntersectionType_Back:be.PlaneIntersectionType_Intersecting}static intersectsRayAndPlaneRD(e,t){var i=t.normal,a=n.dot(i,e.direction);if(Math.abs(a)E)return-1}else{var R=1/l,v=(d-a)*R,x=(E-a)*R;if(v>x){var I=v;v=x,x=I}if((g=Math.max(v,g))>(S=Math.min(x,S)))return-1}if(r.isZero(_)){if(nT)return-1}else{var A=1/_,L=(u-n)*A,C=(T-n)*A;if(L>C){var D=L;L=C,C=D}if((g=Math.max(L,g))>(S=Math.min(C,S)))return-1}if(r.isZero(h)){if(sp)return-1}else{var M=1/h,y=(m-s)*M,O=(p-s)*M;if(y>O){var N=y;y=O,O=N}if((g=Math.max(y,g))>(S=Math.min(O,S)))return-1}return g}static intersectsRayAndBoxRP(e,t,r){var i=Ve.intersectsRayAndBoxRD(e,t);return-1===i?(n._ZERO.cloneTo(r),i):(n.scale(e.direction,i,Ve._tempV30),n.add(e.origin,Ve._tempV30,Ve._tempV31),Ve._tempV31.cloneTo(r),i)}static intersectsRayAndSphereRD(e,t){var r=t.radius;n.subtract(e.origin,t.center,Ve._tempV30);var i=n.dot(Ve._tempV30,e.direction),a=n.dot(Ve._tempV30,Ve._tempV30)-r*r;if(a>0&&i>0)return-1;var s=i*i-a;if(s<0)return-1;var o=-i-Math.sqrt(s);return o<0&&(o=0),o}static intersectsRayAndSphereRP(e,t,r){var i=Ve.intersectsRayAndSphereRD(e,t);return-1===i?(n._ZERO.cloneTo(r),i):(n.scale(e.direction,i,Ve._tempV30),n.add(e.origin,Ve._tempV30,Ve._tempV31),Ve._tempV31.cloneTo(r),i)}static intersectsSphereAndTriangle(e,t,r,i){var a=e.center,s=e.radius;return Ve.closestPointPointTriangle(a,t,r,i,Ve._tempV30),n.subtract(Ve._tempV30,a,Ve._tempV31),n.dot(Ve._tempV31,Ve._tempV31)<=s*s}static intersectsPlaneAndPoint(e,t){var r=n.dot(e.normal,t)+e.distance;return r>0?be.PlaneIntersectionType_Front:r<0?be.PlaneIntersectionType_Back:be.PlaneIntersectionType_Intersecting}static intersectsPlaneAndPlane(e,t){n.cross(e.normal,t.normal,Ve._tempV30);var i=n.dot(Ve._tempV30,Ve._tempV30);return!r.isZero(i)}static intersectsPlaneAndPlaneRL(e,t,i){var a=e.normal,s=t.normal;n.cross(a,s,Ve._tempV34);var o=n.dot(Ve._tempV34,Ve._tempV34);return!r.isZero(o)&&(n.scale(s,e.distance,Ve._tempV30),n.scale(a,t.distance,Ve._tempV31),n.subtract(Ve._tempV30,Ve._tempV31,Ve._tempV32),n.cross(Ve._tempV32,Ve._tempV34,Ve._tempV33),n.normalize(Ve._tempV34,Ve._tempV34),!0)}static intersectsPlaneAndBox(e,t){var r=e.distance,i=e.normal,a=i.x,s=i.y,o=i.z,l=t.min,_=l.x,h=l.y,c=l.z,d=t.max,u=d.x,m=d.y,f=d.z;Ve._tempV30.x=a>0?_:u,Ve._tempV30.y=s>0?h:m,Ve._tempV30.z=o>0?c:f,Ve._tempV31.x=a>0?u:_,Ve._tempV31.y=s>0?m:h,Ve._tempV31.z=o>0?f:c;var E=n.dot(i,Ve._tempV30);return E+r>0?be.PlaneIntersectionType_Front:(E=n.dot(i,Ve._tempV31))+r<0?be.PlaneIntersectionType_Back:be.PlaneIntersectionType_Intersecting}static intersectsPlaneAndSphere(e,t){var r=t.radius,i=n.dot(e.normal,t.center)+e.distance;return i>r?be.PlaneIntersectionType_Front:i<-r?be.PlaneIntersectionType_Back:be.PlaneIntersectionType_Intersecting}static intersectsBoxAndBox(e,t){var r=e.min,i=e.max,a=t.min,n=t.max;return!(r.x>n.x||a.x>i.x)&&(!(r.y>n.y||a.y>i.y)&&!(r.z>n.z||a.z>i.z))}static intersectsBoxAndSphere(e,t){var r=t.center,i=t.radius,a=Ve._tempV30;return n.Clamp(r,e.min,e.max,a),n.distanceSquared(r,a)<=i*i}static intersectsSphereAndSphere(e,t){var r=e.radius+t.radius;return n.distanceSquared(e.center,t.center)<=r*r}static boxContainsPoint(e,t){var r=e.min,i=e.max;return r.x<=t.x&&i.x>=t.x&&r.y<=t.y&&i.y>=t.y&&r.z<=t.z&&i.z>=t.z?we.Contains:we.Disjoint}static boxContainsBox(e,t){var r=e.min,i=r.x,a=r.y,n=r.z,s=e.max,o=s.x,l=s.y,_=s.z,h=t.min,c=h.x,d=h.y,u=h.z,m=t.max,f=m.x,E=m.y,T=m.z;return of?we.Disjoint:lE?we.Disjoint:_T?we.Disjoint:i<=c&&f<=o&&a<=d&&E<=l&&n<=u&&T<=_?we.Contains:we.Intersects}static boxContainsSphere(e,t){var r=e.min,i=r.x,a=r.y,s=r.z,o=e.max,l=o.x,_=o.y,h=o.z,c=t.center,d=c.x,u=c.y,m=c.z,f=t.radius;return n.Clamp(c,r,o,Ve._tempV30),n.distanceSquared(c,Ve._tempV30)>f*f?we.Disjoint:i+f<=d&&d<=l-f&&l-i>f&&a+f<=u&&u<=_-f&&_-a>f&&s+f<=m&&m<=h-f&&h-s>f?we.Contains:we.Intersects}static sphereContainsPoint(e,t){return n.distanceSquared(t,e.center)<=e.radius*e.radius?we.Contains:we.Disjoint}static sphereContainsTriangle(e,t,r,i){var a=Ve.sphereContainsPoint(e,t),n=Ve.sphereContainsPoint(e,r),s=Ve.sphereContainsPoint(e,i);return a==we.Contains&&n==we.Contains&&s==we.Contains?we.Contains:Ve.intersectsSphereAndTriangle(e,t,r,i)?we.Intersects:we.Disjoint}static sphereContainsBox(e,t){var r=e.center,i=r.x,a=r.y,s=r.z,o=e.radius,l=t.min,_=l.x,h=l.y,c=l.z,d=t.max,u=d.x,m=d.y,f=d.z,E=Ve._tempV30;E.x,E.y,E.z;if(!Ve.intersectsBoxAndSphere(t,e))return we.Disjoint;var T=o*o;return i-_,a-m,s-f,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:(i-u,a-m,s-f,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:(i-u,a-h,s-f,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:(i-_,a-h,s-f,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:(i-_,a-m,s-c,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:(i-u,a-m,s-c,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:(i-u,a-h,s-c,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:(i-_,a-h,s-c,n.scalarLengthSquared(Ve._tempV30)>T?we.Intersects:we.Contains)))))))}static sphereContainsSphere(e,t){var r=e.radius,i=t.radius,a=n.distance(e.center,t.center);return r+i=0&&_<=l)r.cloneTo(a);else{var d=s*_-l*o;if(d<=0&&s>=0&&l<=0){var u=s/(s-l);return n.scale(Ve._tempV30,u,a),void n.add(t,a,a)}if(c>=0&&h<=c)i.cloneTo(a);else{var m=h*o-s*c;if(m<=0&&o>=0&&c<=0){var f=o/(o-c);return n.scale(Ve._tempV31,f,a),void n.add(t,a,a)}var E=l*c-h*_;if(E<=0&&_-l>=0&&h-c>=0){var T=(_-l)/(_-l+(h-c));return n.subtract(i,r,a),n.scale(a,T,a),void n.add(r,a,a)}var p=1/(E+m+d),g=m*p,S=d*p;n.scale(Ve._tempV30,g,Ve._tempV35),n.scale(Ve._tempV31,S,Ve._tempV36),n.add(Ve._tempV35,Ve._tempV36,a),n.add(t,a,a)}}}static closestPointPlanePoint(e,t,r){var i=e.normal,a=n.dot(i,t)-e.distance;n.scale(i,a,Ve._tempV30),n.subtract(t,Ve._tempV30,r)}static closestPointBoxPoint(e,t,r){n.max(t,e.min,Ve._tempV30),n.min(Ve._tempV30,e.max,r)}static closestPointSpherePoint(e,t,r){var i=e.center;n.subtract(t,i,r),n.normalize(r,r),n.scale(r,e.radius,r),n.add(r,i,r)}static closestPointSphereSphere(e,t,r){var i=e.center;n.subtract(t.center,i,r),n.normalize(r,r),n.scale(r,e.radius,r),n.add(r,i,r)}}Ve._tempV30=new n,Ve._tempV31=new n,Ve._tempV32=new n,Ve._tempV33=new n,Ve._tempV34=new n,Ve._tempV35=new n,Ve._tempV36=new n,(te=e.FrustumCorner||(e.FrustumCorner={}))[te.FarBottomLeft=0]="FarBottomLeft",te[te.FarTopLeft=1]="FarTopLeft",te[te.FarTopRight=2]="FarTopRight",te[te.FarBottomRight=3]="FarBottomRight",te[te.nearBottomLeft=4]="nearBottomLeft",te[te.nearTopLeft=5]="nearTopLeft",te[te.nearTopRight=6]="nearTopRight",te[te.nearBottomRight=7]="nearBottomRight",te[te.unknown=8]="unknown";class Be{constructor(e){this._matrix=e,this._near=new be(new n),this._far=new be(new n),this._left=new be(new n),this._right=new be(new n),this._top=new be(new n),this._bottom=new be(new n),Be.getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}static getPlanesFromMatrix(e,t,r,i,a,n,s){var o=e.elements,l=o[0],_=o[1],h=o[2],c=o[3],d=o[4],u=o[5],m=o[6],f=o[7],E=o[8],T=o[9],p=o[10],g=o[11],S=o[12],R=o[13],v=o[14],x=o[15],I=t.normal;I.x=h,I.y=m,I.z=p,t.distance=v,t.normalize();var A=r.normal;A.x=c-h,A.y=f-m,A.z=g-p,r.distance=x-v,r.normalize();var L=i.normal;L.x=c+l,L.y=f+d,L.z=g+E,i.distance=x+S,i.normalize();var C=a.normal;C.x=c-l,C.y=f-d,C.z=g-E,a.distance=x-S,a.normalize();var D=n.normal;D.x=c-_,D.y=f-u,D.z=g-T,n.distance=x-R,n.normalize();var M=s.normal;M.x=c+_,M.y=f+u,M.z=g+T,s.distance=x+R,s.normalize()}get matrix(){return this._matrix}set matrix(e){e.cloneTo(this._matrix),Be.getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get near(){return this._near}get far(){return this._far}get left(){return this._left}get right(){return this._right}get top(){return this._top}get bottom(){return this._bottom}equalsBoundFrustum(e){return this._matrix.equalsOtherMatrix(e.matrix)}equalsObj(e){if(e instanceof Be){var t=e;return this.equalsBoundFrustum(t)}return!1}getPlane(e){switch(e){case 0:return this._near;case 1:return this._far;case 2:return this._left;case 3:return this._right;case 4:return this._top;case 5:return this._bottom;default:return null}}static get3PlaneInterPoint(e,t,r,i){var a=e.normal,s=t.normal,o=r.normal;n.cross(s,o,Be._tempV30),n.cross(o,a,Be._tempV31),n.cross(a,s,Be._tempV32);var l=n.dot(a,Be._tempV30),_=n.dot(s,Be._tempV31),h=n.dot(o,Be._tempV32);n.scale(Be._tempV30,-e.distance/l,Be._tempV33),n.scale(Be._tempV31,-t.distance/_,Be._tempV34),n.scale(Be._tempV32,-r.distance/h,Be._tempV35),n.add(Be._tempV33,Be._tempV34,Be._tempV36),n.add(Be._tempV35,Be._tempV36,i)}getCorners(t){Be.get3PlaneInterPoint(this._near,this._bottom,this._right,t[e.FrustumCorner.nearBottomRight]),Be.get3PlaneInterPoint(this._near,this._top,this._right,t[e.FrustumCorner.nearTopRight]),Be.get3PlaneInterPoint(this._near,this._top,this._left,t[e.FrustumCorner.nearTopLeft]),Be.get3PlaneInterPoint(this._near,this._bottom,this._left,t[e.FrustumCorner.nearBottomLeft]),Be.get3PlaneInterPoint(this._far,this._bottom,this._right,t[e.FrustumCorner.FarBottomRight]),Be.get3PlaneInterPoint(this._far,this._top,this._right,t[e.FrustumCorner.FarTopRight]),Be.get3PlaneInterPoint(this._far,this._top,this._left,t[e.FrustumCorner.FarTopLeft]),Be.get3PlaneInterPoint(this._far,this._bottom,this._left,t[e.FrustumCorner.FarBottomLeft])}containsPoint(e){for(var t=be.PlaneIntersectionType_Front,r=be.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=Ve.intersectsPlaneAndPoint(this._near,e);break;case 1:r=Ve.intersectsPlaneAndPoint(this._far,e);break;case 2:r=Ve.intersectsPlaneAndPoint(this._left,e);break;case 3:r=Ve.intersectsPlaneAndPoint(this._right,e);break;case 4:r=Ve.intersectsPlaneAndPoint(this._top,e);break;case 5:r=Ve.intersectsPlaneAndPoint(this._bottom,e)}switch(r){case be.PlaneIntersectionType_Back:return we.Disjoint;case be.PlaneIntersectionType_Intersecting:t=be.PlaneIntersectionType_Intersecting}}switch(t){case be.PlaneIntersectionType_Intersecting:return we.Intersects;default:return we.Contains}}intersects(e){var t=e.min,r=e.max,i=t.x,a=t.y,n=t.z,s=r.x,o=r.y,l=r.z,_=this._near.normal;if(this._near.distance+_.x*(_.x<0?i:s)+_.y*(_.y<0?a:o)+_.z*(_.z<0?n:l)<0)return!1;var h=this._left.normal;if(this._left.distance+h.x*(h.x<0?i:s)+h.y*(h.y<0?a:o)+h.z*(h.z<0?n:l)<0)return!1;var c=this._right.normal;if(this._right.distance+c.x*(c.x<0?i:s)+c.y*(c.y<0?a:o)+c.z*(c.z<0?n:l)<0)return!1;var d=this._bottom.normal;if(this._bottom.distance+d.x*(d.x<0?i:s)+d.y*(d.y<0?a:o)+d.z*(d.z<0?n:l)<0)return!1;var u=this._top.normal;if(this._top.distance+u.x*(u.x<0?i:s)+u.y*(u.y<0?a:o)+u.z*(u.z<0?n:l)<0)return!1;var m=this._far.normal;return!(this._far.distance+m.x*(m.x<0?i:s)+m.y*(m.y<0?a:o)+m.z*(m.z<0?n:l)<0)}containsBoundBox(e){for(var t=Be._tempV30,r=Be._tempV31,i=e.min,a=e.max,n=we.Contains,s=0;s<6;s++){var o=this.getPlane(s),l=o.normal;if(l.x>=0?(t.x=a.x,r.x=i.x):(t.x=i.x,r.x=a.x),l.y>=0?(t.y=a.y,r.y=i.y):(t.y=i.y,r.y=a.y),l.z>=0?(t.z=a.z,r.z=i.z):(t.z=i.z,r.z=a.z),Ve.intersectsPlaneAndPoint(o,t)===be.PlaneIntersectionType_Back)return we.Disjoint;Ve.intersectsPlaneAndPoint(o,r)===be.PlaneIntersectionType_Back&&(n=we.Intersects)}return n}containsBoundSphere(e){for(var t=be.PlaneIntersectionType_Front,r=be.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=Ve.intersectsPlaneAndSphere(this._near,e);break;case 1:r=Ve.intersectsPlaneAndSphere(this._far,e);break;case 2:r=Ve.intersectsPlaneAndSphere(this._left,e);break;case 3:r=Ve.intersectsPlaneAndSphere(this._right,e);break;case 4:r=Ve.intersectsPlaneAndSphere(this._top,e);break;case 5:r=Ve.intersectsPlaneAndSphere(this._bottom,e)}switch(r){case be.PlaneIntersectionType_Back:return we.Disjoint;case be.PlaneIntersectionType_Intersecting:t=be.PlaneIntersectionType_Intersecting}}switch(t){case be.PlaneIntersectionType_Intersecting:return we.Intersects;default:return we.Contains}}}Be._tempV30=new n,Be._tempV31=new n,Be._tempV32=new n,Be._tempV33=new n,Be._tempV34=new n,Be._tempV35=new n,Be._tempV36=new n;class Fe{constructor(e,t,r,i){this.minDepth=0,this.maxDepth=1,this.x=e,this.y=t,this.width=r,this.height=i}project(e,t,r){n.transformV3ToV4(e,t,r);var i=r.x,a=r.y,s=r.z,o=r.w;1!==o&&(i/=o,a/=o,s/=o),r.x=.5*(i+1)*this.width+this.x,r.y=.5*(1-a)*this.height+this.y,r.z=s*(this.maxDepth-this.minDepth)+this.minDepth}unprojectFromMat(e,t,r){var i=t.elements;r.x=(e.x-this.x)/this.width*2-1,r.y=-((e.y-this.y)/this.height*2-1),r.z=(e.z-this.minDepth)/(this.maxDepth-this.minDepth);var a=r.x*i[3]+r.y*i[7]+r.z*i[11]+i[15];n.transformV3ToV3(r,t,r),1!==a&&(r.x=r.x/a,r.y=r.y/a,r.z=r.z/a)}unprojectFromWVP(e,t,r,i,a){y.multiply(t,r,Fe._tempMatrix4x4),i&&y.multiply(Fe._tempMatrix4x4,i,Fe._tempMatrix4x4),Fe._tempMatrix4x4.invert(Fe._tempMatrix4x4),this.unprojectFromMat(e,Fe._tempMatrix4x4,a)}cloneTo(e){e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e.minDepth=this.minDepth,e.maxDepth=this.maxDepth}}Fe._tempMatrix4x4=new y;class Ue{constructor(){}static calculateCursorRay(e,t,r,i,a,s){var o=e.x,l=e.y,_=Ue._tempVector30,h=_;h.x=o,h.y=l,h.z=t.minDepth;var c=Ue._tempVector31,d=c;d.x=o,d.y=l,d.z=t.maxDepth;var u=s.origin,m=Ue._tempVector32;t.unprojectFromWVP(_,r,i,a,u),t.unprojectFromWVP(c,r,i,a,m);var f=s.direction;f.x=m.x-u.x,f.y=m.y-u.y,f.z=m.z-u.z,n.normalize(s.direction,s.direction)}static rayIntersectsTriangle(e,t,r,i){var a=Ue._tempVector30,s=Ue._tempVector31;n.subtract(r,t,a),n.subtract(i,t,s);var o,l=Ue._tempVector32;if(n.cross(e.direction,s,l),(o=n.dot(a,l))>-Number.MIN_VALUE&&o1)return Number.NaN;var d,u,m=Ue._tempVector34;return n.cross(c,a,m),d=n.dot(e.direction,m),(d*=h)<0||_+d>1?Number.NaN:(u=n.dot(s,m),(u*=h)<0?Number.NaN:u)}}Ue._tempVector30=new n,Ue._tempVector31=new n,Ue._tempVector32=new n,Ue._tempVector33=new n,Ue._tempVector34=new n;class Ge extends t.BufferStateBase{constructor(){super()}applyVertexBuffer(e){if(t.BufferStateBase._curBindedBufferState!==this)throw"BufferState: must call bind() function first.";var r=t.LayaGL.instance,i=e.vertexDeclaration,a=i._shaderValues.getData();for(var n in this.vertexDeclaration=i,e.bind(),a){var s=parseInt(n),o=a[n];r.enableVertexAttribArray(s),r.vertexAttribPointer(s,o[0],o[1],!!o[2],o[3],o[4])}}applyVertexBuffers(e){if(t.BufferStateBase._curBindedBufferState!==this)throw"BufferState: must call bind() function first.";for(var r=t.LayaGL.instance,i=0,a=e.length;il&&(n=l);for(var _=0;_e[t].renderingOrder){var i=e[r];e[r]=e[t],e[t]=i}}_calculateProjectionMatrix(){}_onScreenSizeChanged(){this._calculateProjectionMatrix()}_prepareCameraToRender(){var e=this._shaderValues;this.transform.getForward(this._forward),this.transform.getUp(this._up),e.setVector3(Qe.CAMERAPOS,this.transform.position),e.setVector3(Qe.CAMERADIRECTION,this._forward),e.setVector3(Qe.CAMERAUP,this._up)}render(e=null,t=null){}addLayer(e){this.cullingMask|=Math.pow(2,e)}removeLayer(e){this.cullingMask&=~Math.pow(2,e)}addAllLayers(){this.cullingMask=2147483647}removeAllLayers(){this.cullingMask=0}resetProjectionMatrix(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()}_onActive(){this._scene._addCamera(this),super._onActive()}_onInActive(){this._scene._removeCamera(this),super._onInActive()}_parse(e,r){super._parse(e,r),this.orthographic=e.orthographic,void 0!==e.orthographicVerticalSize&&(this.orthographicVerticalSize=e.orthographicVerticalSize),void 0!==e.fieldOfView&&(this.fieldOfView=e.fieldOfView),this.nearPlane=e.nearPlane,this.farPlane=e.farPlane;var i=e.clearColor;this.clearColor=new a(i[0],i[1],i[2],i[3]);var n=e.skyboxMaterial;n&&(this._skyRenderer.material=t.Loader.getRes(n.path))}destroy(e=!0){this._skyRenderer.destroy(),this._skyRenderer=null,t.Laya.stage.off(t.Event.RESIZE,this,this._onScreenSizeChanged),super.destroy(e)}_create(){return new Qe}}Qe._tempMatrix4x40=new y,Qe.CAMERAPOS=H.propertyNameToID("u_CameraPos"),Qe.VIEWMATRIX=H.propertyNameToID("u_View"),Qe.PROJECTMATRIX=H.propertyNameToID("u_Projection"),Qe.VIEWPROJECTMATRIX=H.propertyNameToID("u_ViewProjection"),Qe.CAMERADIRECTION=H.propertyNameToID("u_CameraDirection"),Qe.CAMERAUP=H.propertyNameToID("u_CameraUp"),Qe.VIEWPORT=H.propertyNameToID("u_Viewport"),Qe.PROJECTION_PARAMS=H.propertyNameToID("u_ProjectionParams"),Qe.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",Qe.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",Qe._invertYScaleMatrix=new y(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1),Qe._invertYProjectionMatrix=new y,Qe._invertYProjectionViewMatrix=new y,Qe.CLEARFLAG_SOLIDCOLOR=0,Qe.CLEARFLAG_SKY=1,Qe.CLEARFLAG_DEPTHONLY=2,Qe.CLEARFLAG_NONE=3,(ie=e.ShadowMode||(e.ShadowMode={}))[ie.None=0]="None",ie[ie.Hard=1]="Hard",ie[ie.SoftLow=2]="SoftLow",ie[ie.SoftHigh=3]="SoftHigh";class Ke extends t.Resource{constructor(){super(),this._bufferState=new Ge,this._bufferStateInvertUV=new Ge;var e=t.LayaGL.instance;this._vertexBuffer=new Ye(64,e.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=Ke._vertexDeclaration,this._vertexBuffer.setData(Ke._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new Ye(64,e.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=Ke._vertexDeclaration,this._vertexBufferInvertUV.setData(Ke._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){Ke._vertexDeclaration=new We(16,[new ke(0,He.Vector4,Ke.SCREENQUAD_POSITION_UV)]),Ke.instance=new Ke,Ke.instance.lock=!0}render(){var e=t.LayaGL.instance;this._bufferState.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4),t.Stat.renderBatches++}renderInvertUV(){var e=t.LayaGL.instance;this._bufferStateInvertUV.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4),t.Stat.renderBatches++}destroy(){super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferStateInvertUV.destroy(),this._vertexBufferInvertUV.destroy(),this._setGPUMemory(0)}}Ke.SCREENQUAD_POSITION_UV=0,Ke._vertices=new Float32Array([1,1,1,1,1,-1,1,0,-1,1,0,1,-1,-1,0,0]),Ke._verticesInvertUV=new Float32Array([1,1,1,0,1,-1,1,1,-1,1,0,0,-1,-1,0,1]);class Je extends t.Resource{constructor(){super(),this._bufferState=new Ge,this._bufferStateInvertUV=new Ge;var e=t.LayaGL.instance;this._vertexBuffer=new Ye(48,e.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=Je._vertexDeclaration,this._vertexBuffer.setData(Je._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new Ye(48,e.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=Je._vertexDeclaration,this._vertexBufferInvertUV.setData(Je._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){Je._vertexDeclaration=new We(16,[new ke(0,He.Vector4,Je.SCREENTRIANGLE_POSITION_UV)]),Je.instance=new Je,Je.instance.lock=!0}render(){var e=t.LayaGL.instance;this._bufferState.bind(),e.drawArrays(e.TRIANGLES,0,3),t.Stat.renderBatches++}renderInvertUV(){var e=t.LayaGL.instance;this._bufferStateInvertUV.bind(),e.drawArrays(e.TRIANGLES,0,3),t.Stat.renderBatches++}destroy(){super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferStateInvertUV.destroy(),this._vertexBufferInvertUV.destroy(),this._setGPUMemory(0)}}Je.SCREENTRIANGLE_POSITION_UV=0,Je._vertices=new Float32Array([-1,-1,0,0,-1,3,0,2,3,-1,2,0]),Je._verticesInvertUV=new Float32Array([-1,-1,0,1,-1,3,0,-1,3,-1,2,1]);class $e{constructor(){this._commandBuffer=null}static __init__(){$e._screenShaderData=new W,$e._screenShader=H.find("BlitScreen")}run(){}recover(){this._commandBuffer=null}}$e.SCREENTEXTURE_NAME="u_MainTex",$e.SCREENTEXTUREOFFSETSCALE_NAME="u_OffsetScale",$e.MAINTEXTURE_TEXELSIZE_NAME="u_MainTex_TexelSize",$e.SCREENTEXTURE_ID=H.propertyNameToID($e.SCREENTEXTURE_NAME),$e.SCREENTEXTUREOFFSETSCALE_ID=H.propertyNameToID($e.SCREENTEXTUREOFFSETSCALE_NAME),$e.MAINTEXTURE_TEXELSIZE_ID=H.propertyNameToID($e.MAINTEXTURE_TEXELSIZE_NAME);class et extends $e{constructor(){super(...arguments),this._source=null,this._dest=null,this._offsetScale=null,this._shader=null,this._shaderData=null,this._subShader=0,this._sourceTexelSize=new a,this._screenType=0}static create(e,t,r=null,i=null,a=null,n=0,s=et._SCREENTYPE_QUAD){var o;return(o=et._pool.length>0?et._pool.pop():new et)._source=e,o._dest=t,o._offsetScale=r,o._shader=i,o._shaderData=a,o._subShader=n,o._screenType=s,o}run(){var e=this._shader||$e._screenShader,r=this._shaderData||$e._screenShaderData,i=this._dest;t.LayaGL.instance.viewport(0,0,i?i.width:V.clientWidth,i?i.height:V.clientHeight),r.setTexture($e.SCREENTEXTURE_ID,this._source),r.setVector($e.SCREENTEXTUREOFFSETSCALE_ID,this._offsetScale||et._defaultOffsetScale),this._sourceTexelSize.setValue(1/this._source.width,1/this._source.height,this._source.width,this._source.height),r.setVector($e.MAINTEXTURE_TEXELSIZE_ID,this._sourceTexelSize),i&&i._start();for(var a=e.getSubShaderAt(this._subShader)._passes,n=0,s=a.length;n0?tt._pool.pop():new tt)._renderTexture=e,t}run(){this._renderTexture._start()}recover(){tt._pool.push(this),this._renderTexture=null}}tt._pool=[];class rt extends $e{constructor(){super(...arguments),this._shaderData=null,this._nameID=0,this._texture=null}static create(e,t,r){var i;return(i=rt._pool.length>0?rt._pool.pop():new rt)._shaderData=e,i._nameID=t,i._texture=r,i}run(){this._shaderData.setTexture(this._nameID,this._texture)}recover(){rt._pool.push(this),this._shaderData=null,this._nameID=0,this._texture=null}}rt._pool=[];class it{constructor(){this._camera=null,this._commands=[]}_apply(){for(var e=0,t=this._commands.length;e0){var t=e._alternateLights.shift();t._addToLightQueue(),t._isAlternate=!1,e._lightCount++}}_addToLightQueue(){}_removeFromLightQueue(){}_onActive(){super._onActive(),this.lightmapBakedType!==nt.LIGHTMAPBAKEDTYPE_BAKED&&this._addToScene()}_onInActive(){super._onInActive(),this.lightmapBakedType!==nt.LIGHTMAPBAKEDTYPE_BAKED&&this._removeFromScene()}_create(){return new nt}get diffuseColor(){return console.log("LightSprite: discard property,please use color property instead."),this.color}set diffuseColor(e){console.log("LightSprite: discard property,please use color property instead."),this.color=e}}nt.LIGHTMAPBAKEDTYPE_REALTIME=0,nt.LIGHTMAPBAKEDTYPE_MIXED=1,nt.LIGHTMAPBAKEDTYPE_BAKED=2,(ne=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[ne.NoCascades=0]="NoCascades",ne[ne.TwoCascades=1]="TwoCascades",ne[ne.FourCascades=2]="FourCascades",function(e){e[e.Near=0]="Near",e[e.Far=1]="Far",e[e.Left=2]="Left",e[e.Right=3]="Right",e[e.Bottom=4]="Bottom",e[e.Top=5]="Top"}(se||(se={}));class st{static supportShadow(){return t.LayaGL.layaGPUInstance._isWebGL2||t.SystemUtils.supportRenderTextureFormat(t.RenderTextureFormat.Depth)}static init(){t.LayaGL.layaGPUInstance._isWebGL2?st._shadowTextureFormat=t.RenderTextureFormat.ShadowMap:st._shadowTextureFormat=t.RenderTextureFormat.Depth}static getTemporaryShadowTexture(e,r,i){var a=B.createFromPool(e,r,st._shadowTextureFormat,i);return a.filterMode=t.FilterMode.Bilinear,a.wrapModeU=t.WarpMode.Clamp,a.wrapModeV=t.WarpMode.Clamp,a}static getShadowBias(t,i,a,n){var s;t._lightType==e.LightType.Directional?s=2/i.elements[0]:t._lightType==e.LightType.Spot?s=Math.tan(.5*t.spotAngle*r.Deg2Rad)*t.range:(console.warn("ShadowUtils:Only spot and directional shadow casters are supported now."),s=0);var o=s/a,l=-t._shadowDepthBias*o,_=-t._shadowNormalBias*o;if(t.shadowMode==e.ShadowMode.SoftHigh){const e=2.5;l*=e,_*=e}n.setValue(l,_,0,0)}static getCameraFrustumPlanes(e,t){Be.getPlanesFromMatrix(e,t[se.Near],t[se.Far],t[se.Left],t[se.Right],t[se.Top],t[se.Bottom])}static getFarWithRadius(e,t){return Math.sqrt(e*e/t)}static getCascadesSplitDistance(t,r,i,a,n,s,o,l){l[0]=i;var _=a-i,h=Math.tan(.5*n),c=1+h*h*(s*s+1);switch(o){case e.ShadowCascadesMode.NoCascades:l[1]=st.getFarWithRadius(a,c);break;case e.ShadowCascadesMode.TwoCascades:l[1]=st.getFarWithRadius(i+_*t,c),l[2]=st.getFarWithRadius(a,c);break;case e.ShadowCascadesMode.FourCascades:l[1]=st.getFarWithRadius(i+_*r.x,c),l[2]=st.getFarWithRadius(i+_*r.y,c),l[3]=st.getFarWithRadius(i+_*r.z,c),l[4]=st.getFarWithRadius(a,c)}}static applySliceTransform(e,t,r,i,a){var n=st._tempMatrix0.elements,s=1/t,o=1/r;n[0]=e.resolution*s,n[5]=e.resolution*o,n[12]=e.offsetX*s,n[13]=e.offsetY*o,n[1]=n[2]=n[2]=n[4]=n[6]=n[7]=n[8]=n[9]=n[11]=n[14]=0,n[10]=n[15]=1;var l=16*i;I._mulMatrixArray(n,a,l,a,l)}static getDirectionLightShadowCullPlanes(t,r,i,a,s,o){var l=st._frustumCorners,_=st._backPlaneFaces,h=st._frustumPlaneNeighbors,c=st._frustumTwoPlaneCorners,d=st._edgePlanePoint2,u=o.cullPlanes,m=t[se.Near],f=t[se.Far],E=t[se.Left],T=t[se.Right],p=t[se.Bottom],g=t[se.Top],S=i[r]-a,R=st._adjustNearPlane,v=st._adjustFarPlane;m.normal.cloneTo(R.normal),f.normal.cloneTo(v.normal),R.distance=m.distance-S,v.distance=Math.min(-m.distance+o.sphereCenterZ+o.splitBoundSphere.radius,f.distance),Be.get3PlaneInterPoint(R,p,T,l[e.FrustumCorner.nearBottomRight]),Be.get3PlaneInterPoint(R,g,T,l[e.FrustumCorner.nearTopRight]),Be.get3PlaneInterPoint(R,g,E,l[e.FrustumCorner.nearTopLeft]),Be.get3PlaneInterPoint(R,p,E,l[e.FrustumCorner.nearBottomLeft]),Be.get3PlaneInterPoint(v,p,T,l[e.FrustumCorner.FarBottomRight]),Be.get3PlaneInterPoint(v,g,T,l[e.FrustumCorner.FarTopRight]),Be.get3PlaneInterPoint(v,g,E,l[e.FrustumCorner.FarTopLeft]),Be.get3PlaneInterPoint(v,p,E,l[e.FrustumCorner.FarBottomLeft]);for(var x=0,I=0;I<6;I++){var A;switch(I){case se.Near:A=R;break;case se.Far:A=v;break;default:A=t[I]}n.dot(A.normal,s)<0&&(A.cloneTo(u[x]),_[x]=I,x++)}var L=x;for(I=0;Id/u?(l=t,_=t*h):(l=.5*u*(1+c),_=.5*Math.sqrt(d*d+2*(t*t+e*e)*c+u*u*c*c));var m=o.center;return o.radius=_,n.scale(s,l,m),n.add(a,m,m),l}static getMaxTileResolutionInAtlas(e,t,r){for(var i=Math.min(e,t),a=Math.floor(e/i)*Math.floor(t/i);a>1),a=Math.floor(e/i)*Math.floor(t/i);return i}static getDirectionalLightMatrices(e,t,r,i,a,s,o,l){var _=o.splitBoundSphere,h=_.center,c=_.radius,d=s/2,u=c*d/(d-st.atlasBorderSize),m=2*u,f=s/m,E=m/s,T=Math.ceil(n.dot(h,e)*f)*E,p=Math.ceil(n.dot(h,t)*f)*E,g=n.dot(h,r);h.x=e.x*T+t.x*p+r.x*g,h.y=e.y*T+t.y*p+r.y*g,h.z=e.z*T+t.z*p+r.z*g;var S=o.position,R=o.viewMatrix,v=o.projectionMatrix,x=o.viewProjectMatrix;o.resolution=s,o.offsetX=i%2*s,o.offsetY=Math.floor(i/2)*s,n.scale(r,c+a,S),n.subtract(h,S,S),y.createLookAt(S,h,e,R),y.createOrthoOffCenter(-u,u,-u,u,0,2*c+a,v),y.multiply(v,R,x),I._mulMatrixArray(st._shadowMapScaleOffsetMatrix.elements,x.elements,0,l,16*i)}static prepareShadowReceiverShaderValues(e,t,r,i,a,n,s,o,l){if(n.setValue(1/t,1/r,t,r),s.setValue(e._shadowStrength,0,0,0),a>1){const e=16;for(var _=a*e,h=4*e;_=.5?Math.floor(i):o,d=l-a>=.5?Math.floor(a):l,u=n-_>=.5?Math.ceil(n):_,m=s-h>=.5?Math.ceil(s):h;this._viewport.x=c,this._viewport.y=d,this._viewport.width=u-c,this._viewport.height=m-d}_calculateProjectionMatrix(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=.5*this.orthographicVerticalSize,t=e*this.aspectRatio;y.createOrthoOffCenter(-t,t,-e,e,this.nearPlane,this.farPlane,this._projectionMatrix)}else y.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix)}_isLayerVisible(e){return 0!=(Math.pow(2,e)&this.cullingMask)}_onTransformChanged(e){(e&=Re.TRANSFORM_WORLDMATRIX)&&(this._updateViewMatrix=!0)}_parse(e,t){super._parse(e,t);var r=e.clearFlag;void 0!==r&&(this.clearFlag=r);var i=e.viewport;this.normalizedViewport=new Fe(i[0],i[1],i[2],i[3]);var a=e.enableHDR;void 0!==a&&(this.enableHDR=a)}_getCanvasWidth(){return this._offScreenRenderTexture?this._offScreenRenderTexture.width:V.clientWidth}_getCanvasHeight(){return this._offScreenRenderTexture?this._offScreenRenderTexture.height:V.clientHeight}_getRenderTexture(){return this._internalRenderTexture||this._offScreenRenderTexture}_needInternalRenderTexture(){return!(!this._postProcess&&!this._enableHDR)}_applyPostProcessCommandBuffers(){for(var e=0,t=this._postProcessCommandBuffers.length;e0&&r.btCollisionObject_setCollisionFlags(t,i^vt.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK)}_onAdded(){this.enabled=this._enabled,this.restitution=this._restitution,this.friction=this._friction,this.rollingFriction=this._rollingFriction,this.ccdMotionThreshold=this._ccdMotionThreshold,this.ccdSweptSphereRadius=this._ccdSweptSphereRadius,this.owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onTransformChanged)}_onTransformChanged(e){!vt._addUpdateList&&this._controlBySimulation||(e&=Re.TRANSFORM_WORLDPOSITION|Re.TRANSFORM_WORLDQUATERNION|Re.TRANSFORM_WORLDSCALE)&&(this._transformFlag|=e,this._isValid()&&-1===this._inPhysicUpdateListIndex&&this._simulation._physicsUpdateList.add(this))}_cloneTo(e){var t=e;t.restitution=this._restitution,t.friction=this._friction,t.rollingFriction=this._rollingFriction,t.ccdMotionThreshold=this._ccdMotionThreshold,t.ccdSweptSphereRadius=this._ccdSweptSphereRadius,t.collisionGroup=this._collisionGroup,t.canCollideWith=this._canCollideWith,t.canScaleShape=this.canScaleShape,this._colliderShape&&(t.colliderShape=this._colliderShape.clone())}}vt.ACTIVATIONSTATE_ACTIVE_TAG=1,vt.ACTIVATIONSTATE_ISLAND_SLEEPING=2,vt.ACTIVATIONSTATE_WANTS_DEACTIVATION=3,vt.ACTIVATIONSTATE_DISABLE_DEACTIVATION=4,vt.ACTIVATIONSTATE_DISABLE_SIMULATION=5,vt.COLLISIONFLAGS_STATIC_OBJECT=1,vt.COLLISIONFLAGS_KINEMATIC_OBJECT=2,vt.COLLISIONFLAGS_NO_CONTACT_RESPONSE=4,vt.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK=8,vt.COLLISIONFLAGS_CHARACTER_OBJECT=16,vt.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT=32,vt.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING=64,vt._tempVector30=new n,vt._tempQuaternion0=new f,vt._tempQuaternion1=new f,vt._tempMatrix4x40=new y,vt._physicObjectsMap={},vt._addUpdateList=!0;class xt{constructor(e,t=0){this._gravity=new n(0,-10,0),this._btVector3Zero=v._bullet.btVector3_create(0,0,0),this._btDefaultQuaternion=v._bullet.btQuaternion_create(0,0,0,-1),this._collisionsUtils=new ut,this._previousFrameCollisions=[],this._currentFrameCollisions=[],this._physicsUpdateList=new ht,this._characters=[],this._updatedRigidbodies=0,this.maxSubSteps=1,this.fixedTimeStep=1/60,this.maxSubSteps=e.maxSubSteps,this.fixedTimeStep=e.fixedTimeStep;var r=v._bullet;this._btCollisionConfiguration=r.btDefaultCollisionConfiguration_create(),this._btDispatcher=r.btCollisionDispatcher_create(this._btCollisionConfiguration),this._btBroadphase=r.btDbvtBroadphase_create(),r.btOverlappingPairCache_setInternalGhostPairCallback(r.btDbvtBroadphase_getOverlappingPairCache(this._btBroadphase),r.btGhostPairCallback_create());var i=e.flags;if(i&xt.PHYSICSENGINEFLAGS_COLLISIONSONLY)this._btCollisionWorld=new r.btCollisionWorld(this._btDispatcher,this._btBroadphase,this._btCollisionConfiguration);else{if(i&xt.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT)throw"PhysicsSimulation:SoftBody processing is not yet available";var a=r.btSequentialImpulseConstraintSolver_create();this._btDiscreteDynamicsWorld=r.btDiscreteDynamicsWorld_create(this._btDispatcher,this._btBroadphase,a,this._btCollisionConfiguration),this._btCollisionWorld=this._btDiscreteDynamicsWorld}this._btDiscreteDynamicsWorld&&(this._btSolverInfo=r.btDynamicsWorld_getSolverInfo(this._btDiscreteDynamicsWorld),this._btDispatchInfo=r.btCollisionWorld_getDispatchInfo(this._btDiscreteDynamicsWorld)),this._btClosestRayResultCallback=r.ClosestRayResultCallback_create(this._btVector3Zero,this._btVector3Zero),this._btAllHitsRayResultCallback=r.AllHitsRayResultCallback_create(this._btVector3Zero,this._btVector3Zero),this._btClosestConvexResultCallback=r.ClosestConvexResultCallback_create(this._btVector3Zero,this._btVector3Zero),this._btAllConvexResultCallback=r.AllConvexResultCallback_create(this._btVector3Zero,this._btVector3Zero),r.btGImpactCollisionAlgorithm_RegisterAlgorithm(this._btDispatcher)}static __init__(){var e=v._bullet;xt._btTempVector30=e.btVector3_create(0,0,0),xt._btTempVector31=e.btVector3_create(0,0,0),xt._btTempQuaternion0=e.btQuaternion_create(0,0,0,1),xt._btTempQuaternion1=e.btQuaternion_create(0,0,0,1),xt._btTempTransform0=e.btTransform_create(),xt._btTempTransform1=e.btTransform_create()}static createConstraint(){}get continuousCollisionDetection(){return v._bullet.btCollisionWorld_get_m_useContinuous(this._btDispatchInfo)}set continuousCollisionDetection(e){v._bullet.btCollisionWorld_set_m_useContinuous(this._btDispatchInfo,e)}get gravity(){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";return this._gravity}set gravity(e){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._gravity=e;var t=v._bullet,r=xt._btTempVector30;t.btVector3_setValue(r,-e.x,e.y,e.z),t.btDiscreteDynamicsWorld_setGravity(this._btDiscreteDynamicsWorld,r)}get speculativeContactRestitution(){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";return v._bullet.btDiscreteDynamicsWorld_getApplySpeculativeContactRestitution(this._btDiscreteDynamicsWorld)}set speculativeContactRestitution(e){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";v._bullet.btDiscreteDynamicsWorld_setApplySpeculativeContactRestitution(this._btDiscreteDynamicsWorld,e)}_simulate(e){this._updatedRigidbodies=0;var t=v._bullet;this._btDiscreteDynamicsWorld?t.btDiscreteDynamicsWorld_stepSimulation(this._btDiscreteDynamicsWorld,e,this.maxSubSteps,this.fixedTimeStep):t.PerformDiscreteCollisionDetection(this._btCollisionWorld)}_destroy(){var e=v._bullet;this._btDiscreteDynamicsWorld?(e.btCollisionWorld_destroy(this._btDiscreteDynamicsWorld),this._btDiscreteDynamicsWorld=null):(e.btCollisionWorld_destroy(this._btCollisionWorld),this._btCollisionWorld=null),e.btDbvtBroadphase_destroy(this._btBroadphase),this._btBroadphase=null,e.btCollisionDispatcher_destroy(this._btDispatcher),this._btDispatcher=null,e.btDefaultCollisionConfiguration_destroy(this._btCollisionConfiguration),this._btCollisionConfiguration=null}_addPhysicsCollider(e,t,r){v._bullet.btCollisionWorld_addCollisionObject(this._btCollisionWorld,e._btColliderObject,t,r)}_removePhysicsCollider(e){v._bullet.btCollisionWorld_removeCollisionObject(this._btCollisionWorld,e._btColliderObject)}_addRigidBody(e,t,r){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";v._bullet.btDiscreteDynamicsWorld_addRigidBody(this._btCollisionWorld,e._btColliderObject,t,r)}_removeRigidBody(e){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";v._bullet.btDiscreteDynamicsWorld_removeRigidBody(this._btCollisionWorld,e._btColliderObject)}_addCharacter(e,t,r){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";var i=v._bullet;i.btCollisionWorld_addCollisionObject(this._btCollisionWorld,e._btColliderObject,t,r),i.btDynamicsWorld_addAction(this._btCollisionWorld,e._btKinematicCharacter)}_removeCharacter(e){if(!this._btDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";var t=v._bullet;t.btCollisionWorld_removeCollisionObject(this._btCollisionWorld,e._btColliderObject),t.btDynamicsWorld_removeAction(this._btCollisionWorld,e._btKinematicCharacter)}raycastFromTo(e,t,r=null,i=_t.COLLISIONFILTERGROUP_ALLFILTER,a=_t.COLLISIONFILTERGROUP_ALLFILTER){var n=v._bullet,s=this._btClosestRayResultCallback,o=xt._btTempVector30,l=xt._btTempVector31;if(n.btVector3_setValue(o,-e.x,e.y,e.z),n.btVector3_setValue(l,-t.x,t.y,t.z),n.ClosestRayResultCallback_set_m_rayFromWorld(s,o),n.ClosestRayResultCallback_set_m_rayToWorld(s,l),n.RayResultCallback_set_m_collisionFilterGroup(s,i),n.RayResultCallback_set_m_collisionFilterMask(s,a),n.RayResultCallback_set_m_collisionObject(s,null),n.RayResultCallback_set_m_closestHitFraction(s,1),n.btCollisionWorld_rayTest(this._btCollisionWorld,o,l,s),n.RayResultCallback_hasHit(s)){if(r){r.succeeded=!0,r.collider=vt._physicObjectsMap[n.btCollisionObject_getUserIndex(n.RayResultCallback_get_m_collisionObject(s))],r.hitFraction=n.RayResultCallback_get_m_closestHitFraction(s);var _=n.ClosestRayResultCallback_get_m_hitPointWorld(s),h=r.point;h.x=-n.btVector3_x(_),h.y=n.btVector3_y(_),h.z=n.btVector3_z(_);var c=n.ClosestRayResultCallback_get_m_hitNormalWorld(s),d=r.normal;d.x=-n.btVector3_x(c),d.y=n.btVector3_y(c),d.z=n.btVector3_z(c)}return!0}return r&&(r.succeeded=!1),!1}raycastAllFromTo(e,t,r,i=_t.COLLISIONFILTERGROUP_ALLFILTER,a=_t.COLLISIONFILTERGROUP_ALLFILTER){var n=v._bullet,s=this._btAllHitsRayResultCallback,o=xt._btTempVector30,l=xt._btTempVector31;r.length=0,n.btVector3_setValue(o,-e.x,e.y,e.z),n.btVector3_setValue(l,-t.x,t.y,t.z),n.AllHitsRayResultCallback_set_m_rayFromWorld(s,o),n.AllHitsRayResultCallback_set_m_rayToWorld(s,l),n.RayResultCallback_set_m_collisionFilterGroup(s,i),n.RayResultCallback_set_m_collisionFilterMask(s,a);var _=n.AllHitsRayResultCallback_get_m_collisionObjects(s),h=n.AllHitsRayResultCallback_get_m_hitPointWorld(s),c=n.AllHitsRayResultCallback_get_m_hitNormalWorld(s),d=n.AllHitsRayResultCallback_get_m_hitFractions(s);n.tBtCollisionObjectArray_clear(_),n.tVector3Array_clear(h),n.tVector3Array_clear(c),n.tScalarArray_clear(d),n.btCollisionWorld_rayTest(this._btCollisionWorld,o,l,s);var u=n.tBtCollisionObjectArray_size(_);if(u>0){this._collisionsUtils.recoverAllHitResultsPool();for(var m=0;m0){for(var S=_.AllConvexResultCallback_get_m_hitPointWorld(h),R=_.AllConvexResultCallback_get_m_hitNormalWorld(h),x=_.AllConvexResultCallback_get_m_hitFractions(h),I=0;I{e.cancelable&&e.preventDefault(),this._eventList.push(e)}).bind(this)}__init__(e,t){this._scene=t,e.oncontextmenu=function(e){return!1}}_onCanvasEvent(e){e.addEventListener("mousedown",this._pushEventList),e.addEventListener("mouseup",this._pushEventList,!0),e.addEventListener("mousemove",this._pushEventList,!0),e.addEventListener("touchstart",this._pushEventList),e.addEventListener("touchend",this._pushEventList,!0),e.addEventListener("touchmove",this._pushEventList,!0),e.addEventListener("touchcancel",this._pushEventList,!0)}_offCanvasEvent(e){e.removeEventListener("mousedown",this._pushEventList),e.removeEventListener("mouseup",this._pushEventList,!0),e.removeEventListener("mousemove",this._pushEventList,!0),e.removeEventListener("touchstart",this._pushEventList),e.removeEventListener("touchend",this._pushEventList,!0),e.removeEventListener("touchmove",this._pushEventList,!0),e.removeEventListener("touchcancel",this._pushEventList,!0),this._eventList.length=0,this._touches.clear()}touchCount(){return this._touches.length}get multiTouchEnabled(){return this._multiTouchEnabled}set multiTouchEnabled(e){this._multiTouchEnabled=e}_getTouch(e){var t=this._touchPool[e];return t||(t=new Ne,this._touchPool[e]=t,t._identifier=e),t}_mouseTouchDown(){var e=this._mouseTouch,r=e.sprite;if(e._pressedSprite=r,e._pressedLoopCount=t.Stat.loopCount,r){var i=r._scripts;if(i)for(var a=0,n=i.length;a=0;o--){var l=t[o],_=l.viewport;if(i.x>=_.x&&i.y>=_.y&&i.x<=_.width&&i.y<=_.height)if(l.viewportPointToRay(i,a),this._scene._physicsSimulation.rayCast(a,r)||l.clearFlag===e.CameraClearFlags.SolidColor||l.clearFlag===e.CameraClearFlags.Sky)break}var h=this._mouseTouch,c=h.sprite;if(r.succeeded){var d=r.collider.owner;h.sprite=d;var u=d._scripts;if(c!==d&&u)for(var m=0,f=u.length;m0){var o=!1;for(e=0;ec._pressedLoopCount){var u=d._scripts;if(u)for(i=0,a=u.length;i>n,1),Math.max(e>>n,1));this._setGPUMemory(e*e*4*(1+1/3)*6)}else this._mipmapCount=1,this._setGPUMemory(e*e*4*6)}static get blackTexture(){return Dt._blackTexture}static get grayTexture(){return Dt._grayTexture}static __init__(){var e=new Dt(1,t.TextureFormat.R8G8B8,!1),r=new Dt(1,t.TextureFormat.R8G8B8,!1),i=new Uint8Array(3);i[0]=0,i[1]=0,i[2]=0,e.setSixSidePixels([i,i,i,i,i,i]),e.lock=!0,i[0]=128,i[1]=128,i[2]=128,r.setSixSidePixels([i,i,i,i,i,i]),r.lock=!0,Dt._grayTexture=r,Dt._blackTexture=e}static _parse(e,t=null,r=null){var i=r?new Dt(0,r[0],r[1]):new Dt(0);return i.setSixSideImageSources(e),i}static _parseBin(e,t=null,r=null){var i=r?new Dt(0,r[0],r[1]):new Dt(0);return i.setSixSideImageSources(e),i}static load(e,r){t.ILaya.loader.create(e,r,null,Dt.TEXTURECUBE)}get defaulteTexture(){return Dt.grayTexture}_setPixels(e,r,i,a){var n=t.LayaGL.instance,s=this._getGLFormat();t.WebGLContext.bindTexture(n,this._glTextureType,this._glTexture),this.format===t.TextureFormat.R8G8B8?(n.pixelStorei(n.UNPACK_ALIGNMENT,1),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[0]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[1]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[2]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[3]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[4]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[5]),n.pixelStorei(n.UNPACK_ALIGNMENT,4)):(n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[0]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[1]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[2]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[3]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[4]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[5]))}setSixSideImageSources(e,r=!1){for(var i,a,n=0;n<6;n++){var s=e[n];if(!s)return void console.log("TextureCube: image Source can't be null.");var o=s.width,l=s.height;if(n>0&&i!==o)return void console.log("TextureCube: each side image's width and height must same.");if((i=o)!==(a=l))return void console.log("TextureCube: each side image's width and height must same.")}this._width=i,this._height=a;var _=t.LayaGL.instance;t.WebGLContext.bindTexture(_,this._glTextureType,this._glTexture);var h=this._getGLFormat();if(t.Render.isConchApp){if(1==r)for(var c=0;c<6;c++)e[c].setPremultiplyAlpha(r);_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[0]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[1]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[2]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[3]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[4]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[5])}else r&&_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z,0,h,h,_.UNSIGNED_BYTE,e[0]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,h,h,_.UNSIGNED_BYTE,e[1]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X,0,h,h,_.UNSIGNED_BYTE,e[2]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X,0,h,h,_.UNSIGNED_BYTE,e[3]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y,0,h,h,_.UNSIGNED_BYTE,e[4]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,h,h,_.UNSIGNED_BYTE,e[5]),r&&_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);this._mipmap&&this._isPot(i)&&this._isPot(a)?(_.generateMipmap(this._glTextureType),this._setGPUMemory(i*a*4*(1+1/3)*6)):this._setGPUMemory(i*a*4*6),this._setWarpMode(_.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(_.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),this._readyed=!0,this._activeResource()}setSixSidePixels(e,r=0){if(!e)throw new Error("TextureCube:pixels can't be null.");var i=Math.max(this._width>>r,1),a=Math.max(this._height>>r,1),n=i*a*this._getFormatByteCount();if(e[0].length0){this._bufferState.bind();var r=t.LayaGL.instance;r.drawArrays(r.LINES,0,2*this._lineCount),t.Stat.renderBatches++}}destroy(){this._destroyed||(super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferState=null,this._vertexBuffer=null,this._vertices=null)}}Bt._tempVector0=new n,Bt._tempVector1=new n,Bt._type=wt._typeCounter++;class Ft{constructor(){this.updateMark=-1,this.indexInList=-1,this.batched=!1}}class Ut extends wt{constructor(){super(),this.maxInstanceCount=1024,this.instanceWorldMatrixData=new Float32Array(16*this.maxInstanceCount),this.instanceMVPMatrixData=new Float32Array(16*this.maxInstanceCount);var e=t.LayaGL.instance;this.instanceWorldMatrixBuffer=new Ye(4*this.instanceWorldMatrixData.length,e.DYNAMIC_DRAW),this.instanceMVPMatrixBuffer=new Ye(4*this.instanceMVPMatrixData.length,e.DYNAMIC_DRAW),this.instanceWorldMatrixBuffer.vertexDeclaration=Xe.instanceWorldMatrixDeclaration,this.instanceMVPMatrixBuffer.vertexDeclaration=Xe.instanceMVPMatrixDeclaration}static __init__(){Ut.instance=new Ut}_render(e){var r=t.LayaGL.instance,i=e.renderElement,a=i.instanceSubMesh,n=i.instanceBatchElementList.length,s=a._indexCount;a._mesh._instanceBufferState.bind(),t.LayaGL.layaGPUInstance.drawElementsInstanced(r.TRIANGLES,s,r.UNSIGNED_SHORT,2*a._indexStart,n),t.Stat.renderBatches++,t.Stat.savedRenderBatches+=n-1,t.Stat.trianglesFaces+=s*n/3}}class Gt{constructor(){this.renderSubShader=null,this.renderType=Gt.RENDERTYPE_NORMAL}getInvertFront(){return this._transform._isFrontFaceInvert}setTransform(e){this._transform=e}setGeometry(e){this._geometry=e}addToOpaqueRenderQueue(e,t){t.elements.add(this)}addToTransparentRenderQueue(e,t){t.elements.add(this),t.lastTransparentBatched=!1,t.lastTransparentRenderElement=this}_update(e,t,r,i){if(this.material){var a=this.material._shader.getSubShaderAt(0);if(this.renderSubShader=null,r)if(i){var n=a.getFlag(i);if(!n)return;for(var s=r._subShaders,o=0,l=s.length;o1,a=i?t._indexCount:r._vertexCount;if(a<=_.SubMeshDynamicBatch.maxAllowVertexCount){var n=3*a;this._dynamicVertexBatch=!0,this._dynamicWorldPositions=new Float32Array(n),this._dynamicWorldNormals=new Float32Array(n),this._dynamicVertexCount=a,this._dynamicMultiSubMesh=i}else this._dynamicVertexBatch=!1}this._geometry=e}}addToOpaqueRenderQueue(e,r){var i=this.staticBatch,a=r.elements,n=a.elements;if(i){var s=_.MeshRenderStaticBatchManager.instance,o=s.getBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,i._batchID);if(s._updateCountMark===o.updateMark){var l=o.indexInList;if(o.batched)n[l].staticBatchElementList.add(this);else{var h=n[l],c=h.render,d=s._getBatchRenderElementFromPool();d.renderType=Gt.RENDERTYPE_STATICBATCH,d.setGeometry(i),d.material=h.material;var u=i.batchOwner,m=u?u._transform:null;d.setTransform(m),d.render=c,d.renderSubShader=h.renderSubShader;var f=d.staticBatchElementList;f.length=0,f.add(h),f.add(this),n[l]=d,o.batched=!0}}else o.updateMark=s._updateCountMark,o.indexInList=a.length,o.batched=!1,a.add(this)}else if(this.renderSubShader._owner._enableInstancing&&t.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0){var E=this._geometry,T=_.MeshRenderDynamicBatchManager.instance,p=T.getInstanceBatchOpaquaMark(this.render.receiveShadow,this.material.id,E._id,this._transform._isFrontFaceInvert);if(T._updateCountMark===p.updateMark){var g=p.indexInList;if(p.batched){var S=n[g].instanceBatchElementList;S.length===Ut.instance.maxInstanceCount?(p.updateMark=T._updateCountMark,p.indexInList=a.length,p.batched=!1,a.add(this)):S.add(this)}else{var R=n[g],v=R.render,x=T._getBatchRenderElementFromPool();x.renderType=Gt.RENDERTYPE_INSTANCEBATCH,x.setGeometry(Ut.instance),x.material=R.material,x.setTransform(null),x.render=v,x.instanceSubMesh=E,x.renderSubShader=R.renderSubShader;var I=x.instanceBatchElementList;I.length=0,I.add(R),I.add(this),n[g]=x,p.batched=!0}}else p.updateMark=T._updateCountMark,p.indexInList=a.length,p.batched=!1,a.add(this)}else if(this._dynamicVertexBatch){var A=this._geometry._vertexBuffer.vertexDeclaration,L=_.MeshRenderDynamicBatchManager.instance,C=L.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,A.id);if(L._updateCountMark===C.updateMark){var D=C.indexInList;if(C.batched)n[D].vertexBatchElementList.add(this);else{var M=n[D],y=M.render,O=L._getBatchRenderElementFromPool();O.renderType=Gt.RENDERTYPE_VERTEXBATCH,O.setGeometry(_.SubMeshDynamicBatch.instance),O.material=M.material,O.setTransform(null),O.render=y,O.vertexBatchVertexDeclaration=A,O.renderSubShader=M.renderSubShader;var N=O.vertexBatchElementList;N.length=0,N.add(M),N.add(this),n[D]=O,C.batched=!0}}else C.updateMark=L._updateCountMark,C.indexInList=a.length,C.batched=!1,a.add(this)}else a.add(this)}addToTransparentRenderQueue(e,r){var i=this.staticBatch,a=r.elements,n=a.elements;if(i){var s=_.MeshRenderStaticBatchManager.instance,o=r.lastTransparentRenderElement;if(o){var l=o.render;if(o._geometry._getType()!==this._geometry._getType()||o.staticBatch!==i||o.material!==this.material||l.receiveShadow!==this.render.receiveShadow||l.lightmapIndex!==this.render.lightmapIndex)a.add(this),r.lastTransparentBatched=!1;else{if(r.lastTransparentBatched)n[a.length-1].staticBatchElementList.add(this);else{var h=s._getBatchRenderElementFromPool();h.renderType=Gt.RENDERTYPE_STATICBATCH,h.setGeometry(i),h.material=o.material;var c=i.batchOwner,d=c?c._transform:null;h.setTransform(d),h.render=this.render,h.renderSubShader=o.renderSubShader;var u=h.staticBatchElementList;u.length=0,u.add(o),u.add(this),n[a.length-1]=h}r.lastTransparentBatched=!0}}else a.add(this),r.lastTransparentBatched=!1}else if(this.renderSubShader._owner._enableInstancing&&t.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0){var m=this._geometry,f=_.MeshRenderDynamicBatchManager.instance,E=r.lastTransparentRenderElement;if(E){var T=E.render;if(E._geometry._getType()!==this._geometry._getType()||E._geometry!==m||E.material!==this.material||T.receiveShadow!==this.render.receiveShadow)a.add(this),r.lastTransparentBatched=!1;else if(r.lastTransparentBatched){var p=n[a.length-1].instanceBatchElementList;p.length===Ut.instance.maxInstanceCount?(a.add(this),r.lastTransparentBatched=!1):(p.add(this),r.lastTransparentBatched=!0)}else{var g=f._getBatchRenderElementFromPool();g.renderType=Gt.RENDERTYPE_INSTANCEBATCH,g.setGeometry(Ut.instance),g.material=E.material,g.setTransform(null),g.render=this.render,g.instanceSubMesh=m,g.renderSubShader=E.renderSubShader;var S=g.instanceBatchElementList;S.length=0,S.add(E),S.add(this),n[a.length-1]=g,r.lastTransparentBatched=!0}}else a.add(this),r.lastTransparentBatched=!1}else if(this._dynamicVertexBatch){var R=this._geometry._vertexBuffer.vertexDeclaration,v=_.MeshRenderDynamicBatchManager.instance,x=r.lastTransparentRenderElement;if(x){var I=x.render;if(x._geometry._getType()!==this._geometry._getType()||x._geometry._vertexBuffer._vertexDeclaration!==R||x.material!==this.material||I.receiveShadow!==this.render.receiveShadow||I.lightmapIndex!==this.render.lightmapIndex)a.add(this),r.lastTransparentBatched=!1;else{if(r.lastTransparentBatched)n[a.length-1].vertexBatchElementList.add(this);else{var A=v._getBatchRenderElementFromPool();A.renderType=Gt.RENDERTYPE_VERTEXBATCH,A.setGeometry(_.SubMeshDynamicBatch.instance),A.material=x.material,A.setTransform(null),A.render=this.render,A.vertexBatchVertexDeclaration=R,A.renderSubShader=x.renderSubShader;var L=A.vertexBatchElementList;L.length=0,L.add(x),L.add(this),n[a.length-1]=A}r.lastTransparentBatched=!0}}else a.add(this),r.lastTransparentBatched=!1}else a.add(this);r.lastTransparentRenderElement=this}getInvertFront(){switch(this.renderType){case Gt.RENDERTYPE_NORMAL:return this._transform._isFrontFaceInvert;case Gt.RENDERTYPE_STATICBATCH:case Gt.RENDERTYPE_VERTEXBATCH:return!1;case Gt.RENDERTYPE_INSTANCEBATCH:return this.instanceBatchElementList.elements[0]._transform._isFrontFaceInvert;default:throw"SubMeshRenderElement: unknown renderType"}}destroy(){super.destroy(),this._dynamicWorldPositions=null,this._dynamicWorldNormals=null,this.staticBatch=null,this.staticBatchElementList=null,this.vertexBatchElementList=null,this.vertexBatchVertexDeclaration=null}}class Ht extends wt{constructor(e,t){super(),this._bufferState=new Ge,this._batchID=Ht._batchIDCounter++,this._batchElements=[],this._currentBatchVertexCount=0,this._currentBatchIndexCount=0,this._vertexDeclaration=t,this.batchOwner=e}_getStaticBatchBakedVertexs(e,t,r,i,a,n){var s,o=n._vertexBuffer,l=o.vertexDeclaration,_=l.getVertexElementByUsage(Xe.MESH_POSITION0)._offset/4,h=l.getVertexElementByUsage(Xe.MESH_NORMAL0),c=h?h._offset/4:-1,d=l.getVertexElementByUsage(Xe.MESH_COLOR0),u=d?d._offset/4:-1,m=l.getVertexElementByUsage(Xe.MESH_TEXTURECOORDINATE0),f=m?m._offset/4:-1,E=l.getVertexElementByUsage(Xe.MESH_TEXTURECOORDINATE1),T=E?E._offset/4:-1,p=l.getVertexElementByUsage(Xe.MESH_TANGENT0),g=p?p._offset/4:-1,S=l.vertexStride/4,R=o.getFloat32Data();r?(r.worldMatrix.invert(Ht._tempMatrix4x40),s=Ht._tempMatrix4x41,y.multiply(Ht._tempMatrix4x40,i.worldMatrix,s)):s=i.worldMatrix;var v=Ht._tempMatrix4x42;s.invert(v),v.transpose();var x=Ht._tempQuaternion0;s.decomposeTransRotScale(Ht._tempVector30,x,Ht._tempVector31);for(var A=a.lightmapScaleOffset,L=n.vertexCount,C=0;CHt.maxBatchVertexCount)}add(e){var t=e.meshFilter.sharedMesh,r=t.vertexCount;this._batchElements.push(e);var i=e._render;i._isPartOfStaticBatch=!0,i._staticBatch=this;for(var a=i._renderElements,n=0,s=a.length;n=i.length){var o=i;(i=Ce._cullingBuffer=new Float32Array(i.length+4096)).set(o,0)}i[r]=2,Ce._cullingBufferLength=s}this._renderElements=[],this._owner=e,this._enable=!0,this._materialsInstance=[],this._shaderValues=new W(null),this.lightmapIndex=-1,this.receiveShadow=!1,this.sortingFudge=0,e&&this._owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange)}get id(){return this._id}get lightmapIndex(){return this._lightmapIndex}set lightmapIndex(e){this._lightmapIndex=e}get lightmapScaleOffset(){return this._lightmapScaleOffset}set lightmapScaleOffset(e){if(!e)throw"BaseRender: lightmapScaleOffset can't be null.";this._lightmapScaleOffset=e,this._shaderValues.setVector(xe.LIGHTMAPSCALEOFFSET,e)}get enable(){return this._enable}set enable(e){this._enable=!!e}get material(){var e=this._sharedMaterials[0];if(e&&!this._materialsInstance[0]){var t=this._getInstanceMaterial(e,0),r=this._renderElements[0];r&&(r.material=t)}return this._sharedMaterials[0]}set material(e){this.sharedMaterial=e}get materials(){for(var e=0,t=this._sharedMaterials.length;e=0&&rthis.maxLineCount)throw"PixelLineSprite3D: lineCount can't large than maxLineCount";this._geometryFilter._lineCount=e}get pixelLineRenderer(){return this._render}constructor(e=2,t=null){super(t),this._geometryFilter=new Bt(this,e),this._render=new Xt(this),this._changeRenderObjects(this._render,0,Nt.defaultMaterial)}_changeRenderObjects(e,t,r){var i=this._render._renderElements;r||(r=Nt.defaultMaterial);var a=i[t];a||(a=i[t]=new Gt),a.setTransform(this._transform),a.setGeometry(this._geometryFilter),a.render=this._render,a.material=r}addLine(e,t,r,i){if(this._geometryFilter._lineCount===this._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount has equal with maxLineCount.";this._geometryFilter._updateLineData(this._geometryFilter._lineCount++,e,t,r,i)}addLines(e){var t=this._geometryFilter._lineCount,r=e.length;if(t+r>this._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount plus lines count must less than maxLineCount.";this._geometryFilter._updateLineDatas(t,e),this._geometryFilter._lineCount+=r}removeLine(e){if(!(e0;)t--;if(e1){var r=this._partitionRenderObject(e,t),i=r-1;e=0;i--){var a=r[i];this._objects.push(a),a._setOctreeNode(this)}}}this._children=null}_merge(){if(null===this._children){var e=this._parent;e&&e._shouldMerge()&&(e._mergeChildren(),e._merge())}}_checkAddNode(e){if(null==this._children){if(this._objects.length=0;t--){var r=this._objects[t],i=this._bestFitChild(r.bounds.getCenter());Zt._encapsulates(this._getChildBound(i),r.bounds._getBoundBox())&&(this._objects.splice(this._objects.indexOf(r),1),this._getChild(i)._add(r))}}var a=this._bestFitChild(e.bounds.getCenter());return Zt._encapsulates(this._getChildBound(a),e.bounds._getBoundBox())?this._getChild(a)._checkAddNode(e):this}_add(e){var t=this._checkAddNode(e);t._objects.push(e),e._setOctreeNode(t)}_remove(e){var t=this._objects.indexOf(e);this._objects.splice(t,1),e._setOctreeNode(null),this._merge()}_addUp(e){return Ve.boxContainsBox(this._bounds,e.bounds._getBoundBox())===we.Contains?(this._add(e),!0):!!this._parent&&this._parent._addUp(e)}_getCollidingWithFrustum(e,r,i,a,s,o){var l=e.boundFrustum,_=e.position,h=e.cullingMask;if(i){var c=l.containsBoundBox(this._bounds);if(t.Stat.octreeNodeCulling++,c===we.Disjoint)return;i=c===we.Intersects}this._isContaion=!i;for(var d=r.scene,u=t.Stat.loopCount,m=0,f=this._objects.length;m=this.center.y?0:4)+(e.z<=this.center.z?0:2)}_update(e){if(Ve.boxContainsBox(this._bounds,e.bounds._getBoundBox())===we.Contains){var t=this._checkAddNode(e);if(t!==e._getOctreeNode()){t._objects.push(e),e._setOctreeNode(t);var r=this._objects.indexOf(e);this._objects.splice(r,1),this._merge()}return!0}if(this._parent){var i=this._parent._addUp(e);return i&&(r=this._objects.indexOf(e),this._objects.splice(r,1),this._merge()),i}return!1}add(e){return!!Zt._encapsulates(this._bounds,e.bounds._getBoundBox())&&(this._add(e),!0)}remove(e){return e._getOctreeNode()===this&&(this._remove(e),!0)}update(e){return e._getOctreeNode()===this&&this._update(e)}shrinkIfPossible(e){if(this.baseLength<2*e)return this;for(var t=-1,r=0,i=this._objects.length;r=0&&t!=r)return this;l=!0,t=r}}if(-1!=t){var h=this._children[t];return h._parent=null,h}return this}hasAnyObjects(){if(this._objects.length>0)return!0;if(null!=this._children)for(var e=0;e<8;e++){var t=this._children[e];if(t&&t.hasAnyObjects())return!0}return!1}getCollidingWithBoundBox(e,t){this._getCollidingWithBoundBox(e,!0,t)}getCollidingWithRay(e,t,r=Number.MAX_VALUE){var i=Ve.intersectsRayAndBoxRD(e,this._bounds);if(!(-1==i||i>r)){for(var a=0,n=this._objects.length;at)return!1;for(var i=0,a=this._objects.length;ie&&(console.warn("Minimum node size must be at least as big as the initial world size. Was: "+r+" Adjusted to: "+e),r=e),this._initialSize=e,this._minSize=r,this._looseness=Math.min(Math.max(i,1),2),this._rootNode=new Zt(this,null,e,t)}_getMaxDepth(e,t){t++;var r=e._children;if(null!=r)for(var i=t,a=0,n=r.length;a=0?1:-1,r=e.y>=0?1:-1,i=e.z>=0?1:-1,a=this._rootNode,s=this._rootNode.baseLength/2,o=2*this._rootNode.baseLength,l=this._rootNode.center,_=new n(l.x+t*s,l.y+r*s,l.z+i*s);if(this._rootNode=new Zt(this,null,o,_),a.hasAnyObjects()){for(var h=this._rootNode._bestFitChild(a.center),c=[],d=0;d<8;d++)d==h&&(a._parent=this._rootNode,c[d]=a);this._rootNode._children=c}}add(e){for(var t=0;!this._rootNode.add(e);){var r=Qt._tempVector30;if(n.subtract(e.bounds.getCenter(),this._rootNode.center,r),this._grow(r),++t>20)throw"Aborted Add operation as it seemed to be going on forever ("+(t-1)+") attempts at growing the octree."}this.count++}remove(e){var t=e._getOctreeNode().remove(e);return t&&this.count--,t}update(e){var t=0,r=e._getOctreeNode();if(r){for(;!r._update(e);){var i=Qt._tempVector30;if(n.subtract(e.bounds.getCenter(),this._rootNode.center,i),this._grow(i),++t>20)throw"Aborted Add operation as it seemed to be going on forever ("+(t-1)+") attempts at growing the octree."}return!0}return!1}shrinkRootIfPossible(){this._rootNode=this._rootNode.shrinkIfPossible(this._initialSize)}addMotionObject(e){this._motionObjects.add(e)}removeMotionObject(e){this._motionObjects.remove(e)}updateMotionObjects(){for(var e=this._motionObjects.elements,t=0,r=this._motionObjects.length;t=e.length)throw new Error("start"+t+"Must be in the range [0, "+(e.length-1)+"]");if(r<0||t+r>e.length)throw new Error("count"+r+"Must be in the range <= "+e.length+"}");var a=t+r,s=Jt._tempVector3;s.x=0,s.y=0,s.z=0;for(var o=t;o_&&(_=h)}i.radius=Math.sqrt(_)}static createfromPoints(e,t){if(null==e)throw new Error("points");Jt.createFromSubPoints(e,0,e.length,t)}intersectsRayDistance(e){return Ve.intersectsRayAndSphereRD(e,this)}intersectsRayPoint(e,t){return Ve.intersectsRayAndSphereRP(e,this,t)}cloneTo(e){var t=e;this.center.cloneTo(t.center),t.radius=this.radius}clone(){var e=new Jt(new n,0);return this.cloneTo(e),e}}Jt._tempVector3=new n;class $t{constructor(){this.cameraShaderValue=new W,this.position=new n,this.viewMatrix=new y,this.projectionMatrix=new y,this.viewProjectMatrix=new y,this.cullPlanes=[new be(new n),new be(new n),new be(new n),new be(new n),new be(new n),new be(new n),new be(new n),new be(new n),new be(new n),new be(new n)],this.splitBoundSphere=new Jt(new n,0)}}class er{constructor(){this._shadowBias=new a,this._shadowParams=new a,this._shadowMapSize=new a,this._shadowMatrices=new Float32Array(16*er._maxCascades),this._splitBoundSpheres=new Float32Array(4*er._maxCascades),this._cascadeCount=0,this._shadowMapWidth=0,this._shadowMapHeight=0,this._shadowSliceDatas=[new $t,new $t,new $t,new $t],this._lightUp=new n,this._lightSide=new n,this._lightForward=new n}_setupShadowCasterShaderValues(e,t,r,i,a){t.setVector(er.SHADOW_BIAS,a),t.setVector3(er.SHADOW_LIGHT_DIRECTION,i);var n=r.cameraShaderValue;n.setMatrix4x4(Qe.VIEWMATRIX,r.viewMatrix),n.setMatrix4x4(Qe.PROJECTMATRIX,r.projectionMatrix),n.setMatrix4x4(Qe.VIEWPROJECTMATRIX,r.viewProjectMatrix),e.viewMatrix=r.viewMatrix,e.projectionMatrix=r.projectionMatrix,e.projectionViewMatrix=r.viewProjectMatrix}_setupShadowReceiverShaderValues(t){var r=this._light;switch(r.shadowCascadesMode!==e.ShadowCascadesMode.NoCascades?t.addDefine(at.SHADERDEFINE_SHADOW_CASCADE):t.removeDefine(at.SHADERDEFINE_SHADOW_CASCADE),r.shadowMode){case e.ShadowMode.Hard:t.removeDefine(at.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW),t.removeDefine(at.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftLow:t.addDefine(at.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW),t.removeDefine(at.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftHigh:t.addDefine(at.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH),t.removeDefine(at.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW)}t.setTexture(er.SHADOW_MAP,this._shadowMap),t.setBuffer(er.SHADOW_MATRICES,this._shadowMatrices),t.setVector(er.SHADOW_MAP_SIZE,this._shadowMapSize),t.setVector(er.SHADOW_PARAMS,this._shadowParams),t.setBuffer(er.SHADOW_SPLIT_SPHERES,this._splitBoundSpheres)}update(t,i){this._light=i;var a=er._tempMatrix0,s=a.elements,o=this._lightUp,l=this._lightSide,_=this._lightForward;y.createFromQuaternion(i._transform.rotation,a),l.setValue(s[0],s[1],s[2]),o.setValue(s[4],s[5],s[6]),_.setValue(-s[8],-s[9],-s[10]);var h,c,d,u,m=i._shadowResolution,f=i._shadowCascadesMode;f==e.ShadowCascadesMode.NoCascades?(h=1,c=m,d=m,u=m):(h=f==e.ShadowCascadesMode.TwoCascades?2:4,d=2*(c=st.getMaxTileResolutionInAtlas(m,m,h)),u=f==e.ShadowCascadesMode.TwoCascades?c:2*c),this._cascadeCount=h,this._shadowMapWidth=d,this._shadowMapHeight=u;var E=er._cascadesSplitDistance,T=er._frustumPlanes,p=t.nearPlane,g=Math.min(t.farPlane,i._shadowDistance),S=this._shadowMatrices,R=this._splitBoundSpheres;st.getCascadesSplitDistance(i._shadowTwoCascadeSplits,i._shadowFourCascadeSplits,p,g,t.fieldOfView*r.Deg2Rad,t.aspectRatio,f,E),st.getCameraFrustumPlanes(t.projectionViewMatrix,T);var v=er._tempVector30;t._transform.getForward(v),n.normalize(v,v);for(var x=0;x1&&st.applySliceTransform(I,d,u,x,S)}st.prepareShadowReceiverShaderValues(i,d,u,this._shadowSliceDatas,h,this._shadowMapSize,this._shadowParams,S,R)}render(e,r){var i=r._shaderValues;e.pipelineMode="ShadowCaster",W.setRuntimeValueMode(!1);var a=this._shadowMap=st.getTemporaryShadowTexture(this._shadowMapWidth,this._shadowMapHeight,t.RenderTextureDepthFormat.DEPTH_16);a._start();for(var n=this._light,s=0,o=this._cascadeCount;se._renderingOrder?i=t-1:r=t+1}return r}_allotPickColorByID(e,t){var r=Math.floor(e/65025);e-=255*r*255;var i=Math.floor(e/255),a=e-=255*i;t.x=r/255,t.y=i/255,t.z=a/255,t.w=1}_searchIDByPickColor(e){return 255*e.x*255+255*e.y+e.z}onEnable(){this._input._onCanvasEvent(t.Render.canvas)}onDisable(){this._input._offCanvasEvent(t.Render.canvas)}_setCreateURL(e){this._url=t.URL.formatURL(e)}_getGroup(){return this._group}_setGroup(e){this._group=e}_clearScript(){if(this._needClearScriptPool){for(var e=this._scriptPool,t=0,r=e.length;t0){var o=this._directionLights.getSunLight();this._mainLight=s[o];for(var _=0;_0){var m=this._pointLights._elements;for(_=0;_0){var T=this._spotLights._elements;for(_=0;_0&&t.setSubPixels(0,0,l,i,r,0),e.setTexture(tr.LIGHTBUFFER,t),e.setInt(tr.DIRECTIONLIGHTCOUNT,this._directionLights._length),e.setTexture(tr.CLUSTERBUFFER,Me.instance._clusterTexture)}else{if(this._directionLights._length>0){var g=this._directionLights._elements[0];this._mainLight=g,n.scale(g.color,g._intensity,g._intensityColor),g.transform.worldMatrix.getForward(g._direction),n.normalize(g._direction,g._direction),e.setVector3(tr.LIGHTDIRCOLOR,g._intensityColor),e.setVector3(tr.LIGHTDIRECTION,g._direction),e.setVector3(tr.SUNLIGHTDIRCOLOR,g._intensityColor),e.setVector3(tr.SUNLIGHTDIRECTION,g._direction),e.addDefine(at.SHADERDEFINE_DIRECTIONLIGHT)}else e.removeDefine(at.SHADERDEFINE_DIRECTIONLIGHT);if(this._pointLights._length>0){var S=this._pointLights._elements[0];n.scale(S.color,S._intensity,S._intensityColor),e.setVector3(tr.POINTLIGHTCOLOR,S._intensityColor),e.setVector3(tr.POINTLIGHTPOS,S.transform.position),e.setNumber(tr.POINTLIGHTRANGE,S.range),e.addDefine(at.SHADERDEFINE_POINTLIGHT)}else e.removeDefine(at.SHADERDEFINE_POINTLIGHT);if(this._spotLights._length>0){var R=this._spotLights._elements[0];n.scale(R.color,R._intensity,R._intensityColor),e.setVector3(tr.SPOTLIGHTCOLOR,R._intensityColor),e.setVector3(tr.SPOTLIGHTPOS,R.transform.position),R.transform.worldMatrix.getForward(R._direction),n.normalize(R._direction,R._direction),e.setVector3(tr.SPOTLIGHTDIRECTION,R._direction),e.setNumber(tr.SPOTLIGHTRANGE,R.range),e.setNumber(tr.SPOTLIGHTSPOTANGLE,R.spotAngle*Math.PI/180),e.addDefine(at.SHADERDEFINE_SPOTLIGHT)}else e.removeDefine(at.SHADERDEFINE_SPOTLIGHT)}}_addScript(e){var t=this._scriptPool;e._indexInPool=t.length,t.push(e)}_removeScript(e){this._scriptPool[e._indexInPool]=null,e._indexInPool=-1,this._needClearScriptPool=!0}_preRenderScript(){for(var e=this._scriptPool,t=0,r=e.length;t=i){var a=this._cullingBufferIndices,n=this._cullingBufferResult;this._cullingBufferIndices=new Int32Array(i+1024),this._cullingBufferResult=new Int32Array(i+1024),this._cullingBufferIndices.set(a,0),this._cullingBufferResult.set(n,0)}this._cullingBufferIndices[r]=e._cullingBufferIndex}}_removeRenderObject(e){var r;this._octree&&e._supportOctree?this._octree.remove(e):(t.Render.supportWebGLPlusCulling&&(r=this._renders.elements[this._renders.length-1]),this._renders.remove(e),t.Render.supportWebGLPlusCulling&&(this._cullingBufferIndices[r._getIndexInList()]=r._cullingBufferIndex))}_getRenderQueue(e){return e<=2500?this._opaqueQueue:this._transparentQueue}destroy(e=!0){this.destroyed||(super.destroy(e),this._skyRenderer.destroy(),this._skyRenderer=null,this._directionLights=null,this._pointLights=null,this._spotLights=null,this._alternateLights=null,this._lightmaps=null,this._shaderValues=null,this._renders=null,this._cameraPool=null,this._octree=null,this._physicsSimulation&&this._physicsSimulation._destroy(),t.Loader.clearRes(this.url))}render(e,r,i){e._curSubmit=t.SubmitBase.RENDERBASE,this._children.length>0&&e.addRenderObject(this)}renderSubmit(){var e,r,i;t.LayaGL.instance;for(this._prepareSceneToRender(),e=0,i=(r=this._cameraPool.length)-1;e=0&&(l=l.substr(0,c)),s=u||new t.ShaderNode(a),u=null,s.text=l,(c=l.indexOf("#"))>=0){for(_="#",E=c+1,f=l.length;E0&&t.ShaderCompile.splitToWords(l,o),u=s,o.text+="\n"+l;continue}a.length>0&&t.ShaderCompile.splitToWords(l,s)}s.setParent(e)}}_resizeCacheShaderMap(e,t,r){var i=this._cacheShaderHierarchy-1;if(t==i){for(var a in e)for(var n=e[a],s=0,o=r-i;sthis._cacheShaderHierarchy&&(this._resizeCacheShaderMap(n,0,s),this._cacheShaderHierarchy=s);for(var o=e._mask,_=e._length-1,h=this._cacheShaderHierarchy-1,c=0;cgr.maxIndicesCount&&(this._flush(n,s),o++,t.Stat.trianglesFaces+=s/3,n=s=0);var m=c._transform;this._getBatchVertices(i,this._vertices,n,m,c,d),this._getBatchIndices(this._indices,s,n,m,d,c._dynamicMultiSubMesh),n+=c._dynamicVertexCount,s+=u}this._flush(n,s),o++,t.Stat.renderBatches+=o,t.Stat.savedRenderBatches+=l-o,t.Stat.trianglesFaces+=s/3}}gr.maxAllowVertexCount=10,gr.maxAllowAttribueCount=900,gr.maxIndicesCount=32e3;class Sr extends Se{constructor(){super(),this._instanceBatchOpaqueMarks=[],this._vertexBatchOpaqueMarks=[],this._cacheBufferStates=[],this._updateCountMark=0}getInstanceBatchOpaquaMark(e,t,r,i){var a=this._instanceBatchOpaqueMarks[e?0:1]||(this._instanceBatchOpaqueMarks[e?0:1]=[]),n=a[t]||(a[t]=[]),s=n[r]||(n[r]=[]);return s[i?1:0]||(s[i?1:0]=new Ft)}getVertexBatchOpaquaMark(e,t,r,i){var a=this._vertexBatchOpaqueMarks[e]||(this._vertexBatchOpaqueMarks[e]=[]),n=a[t?0:1]||(a[t?0:1]=[]),s=n[r]||(n[r]=[]);return s[i]||(s[i]=new Ft)}_getBufferState(e){var t=this._cacheBufferStates[e.id];if(!t){var r=gr.instance;(t=new Ge).bind();var i=r._vertexBuffer;i.vertexDeclaration=e,t.applyVertexBuffer(i),t.applyIndexBuffer(r._indexBuffer),t.unBind(),this._cacheBufferStates[e.id]=t}return t}_getBatchRenderElementFromPool(){var e=this._batchRenderElementPool[this._batchRenderElementPoolIndex++];return e||(e=new zt,this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=e,e.vertexBatchElementList=new Te,e.instanceBatchElementList=new Te),e}_clear(){super._clear(),this._updateCountMark++}}Sr.instance=new Sr;class Rr extends xe{static __init__(){Er.SHADERDEFINE_UV0=H.getDefineByName("UV"),Er.SHADERDEFINE_COLOR=H.getDefineByName("COLOR"),Er.SHADERDEFINE_UV1=H.getDefineByName("UV1"),Er.SHADERDEFINE_GPU_INSTANCE=H.getDefineByName("GPU_INSTANCE"),Ie._registerManager(Wt.instance),Se._registerManager(Sr.instance)}get meshFilter(){return this._meshFilter}get meshRenderer(){return this._render}constructor(e=null,t=null){super(t),this._meshFilter=new pr(this),this._render=new Tr(this),e&&(this._meshFilter.sharedMesh=e)}_parse(e,r){super._parse(e,r);var i=this.meshRenderer,n=e.lightmapIndex;null!=n&&(i.lightmapIndex=n);var s=e.lightmapScaleOffset;s&&(i.lightmapScaleOffset=new a(s[0],s[1],s[2],s[3])),null!=e.meshPath&&(this.meshFilter.sharedMesh=t.Loader.getRes(e.meshPath)),null!=e.enableRender&&(this.meshRenderer.enable=e.enableRender);var o=e.materials;if(o){var l=i.sharedMaterials,_=o.length;l.length=_;for(var h=0;h<_;h++)l[h]=t.Loader.getRes(o[h].path);i.sharedMaterials=l}}_addToInitStaticBatchManager(){this.meshFilter.sharedMesh&&Wt.instance._addBatchSprite(this)}_cloneTo(e,t,r){var i=e;i._meshFilter.sharedMesh=this._meshFilter.sharedMesh;var a=this._render,n=i._render;n.enable=a.enable,n.sharedMaterials=a.sharedMaterials,n.castShadow=a.castShadow;var s=a.lightmapScaleOffset;s&&(n.lightmapScaleOffset=s.clone()),n.lightmapIndex=a.lightmapIndex,n.receiveShadow=a.receiveShadow,n.sortingFudge=a.sortingFudge,super._cloneTo(e,t,r)}destroy(e=!0){this.destroyed||(super.destroy(e),this._meshFilter.destroy())}_create(){return new Rr}}class vr{}vr.Blend=0,vr.Fixed=1;class xr{constructor(e,t){this._mode=0,this._maxColorRGBKeysCount=0,this._maxColorAlphaKeysCount=0,this._colorRGBKeysCount=0,this._colorAlphaKeysCount=0,this._alphaElements=null,this._rgbElements=null,this._maxColorRGBKeysCount=e,this._maxColorAlphaKeysCount=t,this._rgbElements=new Float32Array(4*e),this._alphaElements=new Float32Array(2*t)}get mode(){return this._mode}set mode(e){this._mode=e}get colorRGBKeysCount(){return this._colorRGBKeysCount}get colorAlphaKeysCount(){return this._colorAlphaKeysCount}get maxColorRGBKeysCount(){return this._maxColorRGBKeysCount}get maxColorAlphaKeysCount(){return this._maxColorAlphaKeysCount}addColorRGB(e,t){if(this._colorRGBKeysCount=0;s--){var o=4*s;if(e===(u=a[o]))return t.r=a[o+1],t.g=a[o+2],t.b=a[o+3],n;switch(this._mode){case vr.Blend:if(e>u){if(e>(d=a[o+4]))throw"Gradient:wrong startSearchIndex.";var l=d-u,_=d-e,h=e-u;return t.r=(_*a[o+1]+h*a[o+5])/l,t.g=(_*a[o+2]+h*a[o+6])/l,t.b=(_*a[o+3]+h*a[o+7])/l,n}n--;continue;case vr.Fixed:if(e>u){if(e>a[o+4])throw"Gradient:wrong startSearchIndex.";return t.r=a[o+5],t.g=a[o+6],t.b=a[o+7],n}n--;continue;default:throw"Gradient:unknown mode."}}else{s=0;for(var c=this._rgbElements.length;s=0;s--){if(e===(u=a[c=2*s]))return t.a=a[c+1],n;switch(this._mode){case vr.Blend:if(e>u){if(e>(d=a[c+2]))throw"Gradient:wrong startSearchIndex.";var o=d-u,l=d-e,_=e-u;return t.a=(l*a[c+1]+_*a[c+3])/o,n}n--;continue;case vr.Fixed:if(e>u){if(e>a[c+2])throw"Gradient:wrong startSearchIndex.";return t.a=a[c+3],n}n--;continue;default:throw"Gradient:unknown mode."}}else{s=n;for(var h=this._alphaElements.length;s>>15}get seed(){return this.seeds[0]}set seed(e){this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}getUint(){return this._temp[0]=this.seeds[0]^this.seeds[0]<<11,this.seeds[0]=this.seeds[1],this.seeds[1]=this.seeds[2],this.seeds[2]=this.seeds[3],this.seeds[3]=this.seeds[3]^this.seeds[3]>>>19^this._temp[0]^this._temp[0]>>>8,this.seeds[3]}getFloat(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)}getSignedFloat(){return 2*this.getFloat()-1}}class Jr{constructor(){this._emissionRate=10,this._destroyed=!1,this._bursts=[]}set emissionRate(e){if(e<0)throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");this._emissionRate=e}get emissionRate(){return this._emissionRate}get destroyed(){return this._destroyed}destroy(){this._bursts=null,this._destroyed=!0}getBurstsCount(){return this._bursts.length}getBurstByIndex(e){return this._bursts[e]}addBurst(e){var t=this._bursts.length;if(t>0)for(var r=0;re.time&&this._bursts.splice(r,0,e);this._bursts.push(e)}removeBurst(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)}removeBurstByIndex(e){this._bursts.splice(e,1)}clearBurst(){this._bursts.length=0}cloneTo(e){var t=e,r=t._bursts;r.length=this._bursts.length;for(var i=0,a=this._bursts.length;i=r){var s=e.getKeyByIndex(i-1),o=(r-s)/(n-s);return t.MathUtil.lerp(e.getValueByIndex(i-1),e.getValueByIndex(i),o)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")}static _randomInvertRoationArray(e,t,r,i,a){var n;i?(i.seed=a[6],n=i.getFloat(),a[6]=i.seed):n=Math.random(),n=this._firstRetiredElement?this._firstNewElement-this._firstRetiredElement:this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement}get emissionTime(){return this._emissionTime>this.duration?this.duration:this._emissionTime}get shape(){return this._shape}set shape(e){this._shape!==e&&(e&&e.enable?this._owner._render._shaderValues.addDefine(Xr.SHADERDEFINE_SHAPE):this._owner._render._shaderValues.removeDefine(Xr.SHADERDEFINE_SHAPE),this._shape=e)}get isAlive(){return!!(this._isPlaying||this.aliveParticleCount>0)}get isEmitting(){return this._isEmitting}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get startLifetimeType(){return this._startLifetimeType}set startLifetimeType(e){var t,r;switch(this.startLifetimeType){case 0:this._maxStartLifetime=this.startLifetimeConstant;break;case 1:this._maxStartLifetime=-Number.MAX_VALUE;var i=i;for(t=0,r=i.gradientCount;t=this._bufferMaxParticles&&(this._firstActiveElement=0)}}_freeRetiredParticles(){for(;this._firstRetiredElement!=this._firstActiveElement;){var e=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*this._vertexStride+this._timeIndex];if(this.isPerformanceMode&&e<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this._bufferMaxParticles&&(this._firstRetiredElement=0)}}_burst(e,r){for(var i=0,a=this._emission._bursts,n=a.length;this._burstsIndexthis.duration){if(!this.looping){for(a=Math.min(this.maxParticles-this.aliveParticleCount,a),r=0;r0){var s=1/n;for(this._frameRateTime+=s,this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)%this._maxStartLifetime;this._frameRateTime<=t&&this.emit(this._frameRateTime);)this._frameRateTime+=s;this._frameRateTime=Math.floor(t/s)*s}}_initBufferDatas(){if(this._vertexBuffer){this._vertexBuffer.destroy(),this._indexBuffer.destroy();var r=this._vertexBuffer._byteLength+2*this._indexBuffer.indexCount;t.Resource._addMemory(-r,-r)}var i=t.LayaGL.instance,a=this._ownerRender,n=a.renderMode;if(-1!==n&&this.maxParticles>0){var s,o,l,_,h,c,d,u=0,m=(r=0,a.mesh);if(4===n){if(m){d=Qr.vertexDeclaration,this._floatCountPerVertex=d.vertexStride/4,this._startLifeTimeIndex=12,this._timeIndex=16,this._vertexStride=m._vertexCount;var f=this._bufferMaxParticles*this._vertexStride,E=f%65535;if(Math.floor(f/65535)+1>1)throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");u=d.vertexStride*E,this._vertexBuffer=new Ye(u,i.DYNAMIC_DRAW),this._vertexBuffer.vertexDeclaration=d,this._vertices=new Float32Array(this._floatCountPerVertex*E),this._indexStride=m._indexBuffer.indexCount;var T=m._indexBuffer.getData(),p=this._bufferMaxParticles*this._indexStride;for(this._indexBuffer=new ze(e.IndexFormat.UInt16,p,i.STATIC_DRAW),s=new Uint16Array(p),r=u+2*p,h=0,o=0;o=this._bufferMaxParticles&&(a=0),a===this._firstRetiredElement)return!1;var s,o,l,_,h,c,d,u,m,f,E=this._owner.transform;if($r.create(this,this._ownerRender,E),this._currentTime-i>=$r.startLifeTime)return!0;switch(0==this.simulationSpace&&(s=E.position,o=E.rotation),this.startSpeedType){case 0:l=this.startSpeedConstant;break;case 2:this.autoRandomSeed?l=t.MathUtil.lerp(this.startSpeedConstantMin,this.startSpeedConstantMax,Math.random()):(this._rand.seed=this._randomSeeds[8],l=t.MathUtil.lerp(this.startSpeedConstantMin,this.startSpeedConstantMax,this._rand.getFloat()),this._randomSeeds[8]=this._rand.seed)}var T=this._velocityOverLifetime&&this._velocityOverLifetime.enable;if(T){var p=this._velocityOverLifetime.velocity.type;2===p||3===p?this.autoRandomSeed?(_=Math.random(),h=Math.random(),c=Math.random()):(this._rand.seed=this._randomSeeds[9],_=this._rand.getFloat(),h=this._rand.getFloat(),c=this._rand.getFloat(),this._randomSeeds[9]=this._rand.seed):T=!1}else T=!1;var g=this._colorOverLifetime&&this._colorOverLifetime.enable;g?3===this._colorOverLifetime.color.type?this.autoRandomSeed?d=Math.random():(this._rand.seed=this._randomSeeds[10],d=this._rand.getFloat(),this._randomSeeds[10]=this._rand.seed):g=!1:g=!1;var S=this._sizeOverLifetime&&this._sizeOverLifetime.enable;S?3===this._sizeOverLifetime.size.type?this.autoRandomSeed?u=Math.random():(this._rand.seed=this._randomSeeds[11],u=this._rand.getFloat(),this._randomSeeds[11]=this._rand.seed):S=!1:S=!1;var R=this._rotationOverLifetime&&this._rotationOverLifetime.enable;if(R){var v=this._rotationOverLifetime.angularVelocity.type;2===v||3===v?this.autoRandomSeed?m=Math.random():(this._rand.seed=this._randomSeeds[12],m=this._rand.getFloat(),this._randomSeeds[12]=this._rand.seed):R=!1}else R=!1;var x=this._textureSheetAnimation&&this._textureSheetAnimation.enable;x?3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?f=Math.random():(this._rand.seed=this._randomSeeds[15],f=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):x=!1:x=!1;var I,A,L,C,D,M,y=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,O=$r.startUVInfo[0],N=$r.startUVInfo[1],b=$r.startUVInfo[2],P=$r.startUVInfo[3],w=this._ownerRender;if(4===w.renderMode){var V=w.mesh._vertexBuffer;I=V.getFloat32Data();var B=V.vertexDeclaration;L=B.getVertexElementByUsage(Xe.MESH_POSITION0)._offset/4;var F=B.getVertexElementByUsage(Xe.MESH_COLOR0);C=F?F._offset/4:-1;var U=B.getVertexElementByUsage(Xe.MESH_TEXTURECOORDINATE0);D=U?U._offset/4:-1,A=B.vertexStride/4,M=0}else{this._vertices[y+2]=b,this._vertices[y+3]=P+N;var G=y+this._floatCountPerVertex;this._vertices[G+2]=b+O,this._vertices[G+3]=P+N;var z=G+this._floatCountPerVertex;this._vertices[z+2]=b+O,this._vertices[z+3]=P;var H=z+this._floatCountPerVertex;this._vertices[H+2]=b,this._vertices[H+3]=P}for(var W=y,k=y+this._floatCountPerVertex*this._vertexStride;W0&&this._vertexBuffer.setData(this._vertices.buffer,0,0,this._firstFreeElement*t)),this._firstNewElement=this._firstFreeElement}_getType(){return ei._type}_prepareRender(e){return this._updateEmission(),this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement}_render(e){var r;this._bufferState.bind();var i=t.LayaGL.instance;this._firstActiveElement0&&(r=this._firstFreeElement*this._indexStride,i.drawElements(i.TRIANGLES,r,i.UNSIGNED_SHORT,0),t.Stat.trianglesFaces+=r/3,t.Stat.renderBatches++))}play(){if(this._burstsIndex=0,this._isEmitting=!0,this._isPlaying=!0,this._isPaused=!1,this._emissionTime=0,this._totalDelayTime=0,!this.autoRandomSeed)for(var e=0,r=this._randomSeeds.length;e4&&(r=i-1);var n=a[r];t.addColorAlpha(n.key,n.value)}else t.addColorAlpha(0,1),t.addColorAlpha(1,1);var s=e.rgbs;if(s)for(r=0,i=s.length;r4&&(r=i-1,console.warn("GradientDataColor warning:rgb data length is large than 4, will ignore the middle data."));var o=s[r],l=o.value;t.addColorRGB(o.key,new ge(l[0],l[1],l[2],1))}else t.addColorRGB(0,new ge(1,1,1,1)),t.addColorRGB(1,new ge(1,1,1,1))}else t.addColorAlpha(0,1),t.addColorAlpha(1,1),t.addColorRGB(0,new ge(1,1,1,1)),t.addColorRGB(1,new ge(1,1,1,1));return t}_initParticleFrame(e){var t=new Mr;if(e)for(var r=e.frames,i=0,a=r.length;i=r.zeroTolerance?(this._isTempEndVertex?(_=this._endIndex-1,h=c-this._subDistance[_],this._updateVerticesByPosition(i,s,c,_),this._owner._totalLength+=h):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(i,s,c,this._endIndex),this._owner._totalLength+=c,this._endIndex++),i.cloneTo(this._lastFixedVertexPosition),this._isTempEndVertex=!1):(this._isTempEndVertex?(_=this._endIndex-1,h=c-this._subDistance[_],this._updateVerticesByPosition(i,s,c,_),this._owner._totalLength+=h):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(i,s,c,this._endIndex),this._owner._totalLength+=c,this._endIndex++),this._isTempEndVertex=!0)}_updateVerticesByPositionData(e,r,i){var a=2*this._floatCountPerVertices1*i,s=this._owner._curtime;this._vertices1[a]=e.x,this._vertices1[a+1]=e.y,this._vertices1[a+2]=e.z,this._vertices1[a+3]=-r.x,this._vertices1[a+4]=-r.y,this._vertices1[a+5]=-r.z,this._vertices1[a+6]=s,this._vertices1[a+7]=1,this._vertices1[a+8]=e.x,this._vertices1[a+9]=e.y,this._vertices1[a+10]=e.z,this._vertices1[a+11]=r.x,this._vertices1[a+12]=r.y,this._vertices1[a+13]=r.z,this._vertices1[a+14]=s,this._vertices1[a+15]=0;var o=this._owner._owner.trailRenderer.bounds,l=o.getMin(),_=o.getMax(),h=li._tempVector35,c=li._tempVector36,d=li._tempVector32;n.add(e,r,h),n.subtract(e,r,c),n.min(c,h,d),n.min(l,d,l),o.setMin(l),n.max(h,c,d),n.max(_,d,_),o.setMax(_),t.Render.supportWebGLPlusCulling&&this._calculateBoundingBoxForNative();var u=2*this._floatCountPerVertices1;this._vertexBuffer1.setData(this._vertices1.buffer,4*a,4*a,4*u)}_updateVerticesByPosition(e,t,r,i){this._updateVerticesByPositionData(e,t,i),this._subDistance[i]=r,this._subBirthTime[i]=this._owner._curtime}_updateVertexBufferUV(){var e,r,i;if(this._disappearBoundsMode){e=this._owner._owner.trailRenderer.bounds;var a=this._owner._owner.transform.position;e.setMin(a),e.setMax(a),r=e.getMin(),i=e.getMax(),t.Render.supportWebGLPlusCulling&&this._calculateBoundingBoxForNative()}for(var s=this._endIndex,o=0,l=this._owner.colorGradient,_=l.colorAlphaKeysCount-1,h=l.colorRGBKeysCount-1,c=this._owner._totalLength,d=2*this._floatCountPerVertices2,u=this._activeIndex;u=this._owner.time+r.zeroTolerance;t++){var i=t+1;if(i!==e&&(this._owner._totalLength-=this._subDistance[i]),this._isTempEndVertex&&i===e-1){this._floatCountPerVertices1;var a=this._lastFixedVertexPosition;a.x=this._vertices1[0],a.y=this._vertices1[1],a.z=this._vertices1[2],this._isTempEndVertex=!1}this._activeIndex++,this._disappearBoundsMode=!0}}_getType(){return li._type}_prepareRender(e){return this._endIndex-this._activeIndex>1}_render(e){this._bufferState.bind();var r=t.LayaGL.instance,i=2*this._activeIndex,a=2*this._endIndex-i;r.drawArrays(r.TRIANGLE_STRIP,i,a),t.Stat.renderBatches++,t.Stat.trianglesFaces+=a-2}destroy(){super.destroy();var e=this._vertexBuffer1._byteLength+this._vertexBuffer2._byteLength;t.Resource._addMemory(-e,-e),this._bufferState.destroy(),this._vertexBuffer1.destroy(),this._vertexBuffer2.destroy(),this._bufferState=null,this._vertices1=null,this._vertexBuffer1=null,this._vertices2=null,this._vertexBuffer2=null,this._subBirthTime=null,this._subDistance=null,this._lastFixedVertexPosition=null,this._disappearBoundsMode=!1}_calculateBoundingBoxForNative(){var e=this._owner._owner.trailRenderer,t=e.bounds,r=t.getMin(),i=t.getMax(),a=Ce._cullingBuffer;a[e._cullingBufferIndex+1]=r.x,a[e._cullingBufferIndex+2]=r.y,a[e._cullingBufferIndex+3]=r.z,a[e._cullingBufferIndex+4]=i.x,a[e._cullingBufferIndex+5]=i.y,a[e._cullingBufferIndex+6]=i.z}clear(){this._activeIndex=0,this._endIndex=0,this._disappearBoundsMode=!1,this._subBirthTime.fill(0),this._subDistance.fill(0),this._segementCount=0,this._isTempEndVertex=!1,this._needAddFirstVertex=!1,this._lastFixedVertexPosition.setValue(0,0,0)}}li.ALIGNMENT_VIEW=0,li.ALIGNMENT_TRANSFORM_Z=1,li._tempVector30=new n,li._tempVector31=new n,li._tempVector32=new n,li._tempVector33=new n,li._tempVector34=new n,li._tempVector35=new n,li._tempVector36=new n,li._type=wt._typeCounter++;class _i{constructor(e){this._totalLength=0,this._lastPosition=new n,this._curtime=0,this.alignment=_i.ALIGNMENT_VIEW,this._owner=e,this._initDefaultData(),this.addRenderElement()}get time(){return this._time}set time(e){this._time=e,this._owner._render._shaderValues.setNumber(_i.LIFETIME,e)}get minVertexDistance(){return this._minVertexDistance}set minVertexDistance(e){this._minVertexDistance=e}get widthMultiplier(){return this._widthMultiplier}set widthMultiplier(e){this._widthMultiplier=e}get widthCurve(){return this._widthCurve}set widthCurve(e){this._widthCurve=e;var t,r,i=new Float32Array(4*e.length),a=0;for(t=0,r=e.length;t{},setWorldTransform:(e,t)=>{var r=vt._physicObjectsMap[e];r._simulation._updatedRigidbodies++,r._updateTransformComponent(t)}};class mi extends vt{constructor(e=.1,t=null,r=_t.COLLISIONFILTERGROUP_DEFAULTFILTER,i=_t.COLLISIONFILTERGROUP_ALLFILTER){super(r,i),this._upAxis=new n(0,1,0),this._maxSlope=45,this._jumpSpeed=10,this._fallSpeed=55,this._gravity=new n(0,3*-9.8,0),this._btKinematicCharacter=null,this._stepHeight=e,t&&(this._upAxis=t),this._controlBySimulation=!0}static __init__(){mi._btTempVector30=v._bullet.btVector3_create(0,0,0)}get fallSpeed(){return this._fallSpeed}set fallSpeed(e){this._fallSpeed=e,v._bullet.btKinematicCharacterController_setFallSpeed(this._btKinematicCharacter,e)}get jumpSpeed(){return this._jumpSpeed}set jumpSpeed(e){this._jumpSpeed=e,v._bullet.btKinematicCharacterController_setJumpSpeed(this._btKinematicCharacter,e)}get gravity(){return this._gravity}set gravity(e){this._gravity=e;var t=v._bullet,r=mi._btTempVector30;t.btVector3_setValue(r,-e.x,e.y,e.z),t.btKinematicCharacterController_setGravity(this._btKinematicCharacter,r)}get maxSlope(){return this._maxSlope}set maxSlope(e){this._maxSlope=e,v._bullet.btKinematicCharacterController_setMaxSlope(this._btKinematicCharacter,e/180*Math.PI)}get isGrounded(){return v._bullet.btKinematicCharacterController_onGround(this._btKinematicCharacter)}get stepHeight(){return this._stepHeight}set stepHeight(e){this._stepHeight=e,v._bullet.btKinematicCharacterController_setStepHeight(this._btKinematicCharacter,e)}get upAxis(){return this._upAxis}set upAxis(e){this._upAxis=e;var t=mi._btTempVector30;I._convertToBulletVec3(e,t,!1),v._bullet.btKinematicCharacterController_setUp(this._btKinematicCharacter,t)}_constructCharacter(){var e=v._bullet;this._btKinematicCharacter&&e.btKinematicCharacterController_destroy(this._btKinematicCharacter);var t=mi._btTempVector30;e.btVector3_setValue(t,this._upAxis.x,this._upAxis.y,this._upAxis.z),this._btKinematicCharacter=e.btKinematicCharacterController_create(this._btColliderObject,this._colliderShape._btShape,this._stepHeight,t),this.fallSpeed=this._fallSpeed,this.maxSlope=this._maxSlope,this.jumpSpeed=this._jumpSpeed,this.gravity=this._gravity}_onShapeChange(e){super._onShapeChange(e),this._constructCharacter()}_onAdded(){var e=v._bullet,t=e.btPairCachingGhostObject_create();e.btCollisionObject_setUserIndex(t,this.id),e.btCollisionObject_setCollisionFlags(t,vt.COLLISIONFLAGS_CHARACTER_OBJECT),this._btColliderObject=t,this._colliderShape&&this._constructCharacter(),super._onAdded()}_addToSimulation(){this._simulation._characters.push(this),this._simulation._addCharacter(this,this._collisionGroup,this._canCollideWith)}_removeFromSimulation(){this._simulation._removeCharacter(this);var e=this._simulation._characters;e.splice(e.indexOf(this),1)}_cloneTo(e){super._cloneTo(e);var t=e;t.stepHeight=this._stepHeight,t.upAxis=this._upAxis,t.maxSlope=this._maxSlope,t.jumpSpeed=this._jumpSpeed,t.fallSpeed=this._fallSpeed,t.gravity=this._gravity}_onDestroy(){v._bullet.btKinematicCharacterController_destroy(this._btKinematicCharacter),super._onDestroy(),this._btKinematicCharacter=null}move(e){var t=mi._btVector30,r=v._bullet;r.btVector3_setValue(t,-e.x,e.y,e.z),r.btKinematicCharacterController_setWalkDirection(this._btKinematicCharacter,t)}jump(e=null){var t=v._bullet,r=mi._btVector30;e?(I._convertToBulletVec3(e,r,!0),t.btKinematicCharacterController_jump(this._btKinematicCharacter,r)):(t.btVector3_setValue(r,0,0,0),t.btKinematicCharacterController_jump(this._btKinematicCharacter,r))}}mi.UPAXIS_X=0,mi.UPAXIS_Y=1,mi.UPAXIS_Z=2;class fi extends vt{constructor(e,t){super(e,t),this._isTrigger=!1}get isTrigger(){return this._isTrigger}set isTrigger(e){this._isTrigger=e;var t=v._bullet;if(this._btColliderObject){var r=t.btCollisionObject_getCollisionFlags(this._btColliderObject);e?0==(r&vt.COLLISIONFLAGS_NO_CONTACT_RESPONSE)&&t.btCollisionObject_setCollisionFlags(this._btColliderObject,r|vt.COLLISIONFLAGS_NO_CONTACT_RESPONSE):0!=(r&vt.COLLISIONFLAGS_NO_CONTACT_RESPONSE)&&t.btCollisionObject_setCollisionFlags(this._btColliderObject,r^vt.COLLISIONFLAGS_NO_CONTACT_RESPONSE)}}_onAdded(){super._onAdded(),this.isTrigger=this._isTrigger}_cloneTo(e){super._cloneTo(e),e.isTrigger=this._isTrigger}}class Ei extends fi{constructor(e=_t.COLLISIONFILTERGROUP_DEFAULTFILTER,t=_t.COLLISIONFILTERGROUP_ALLFILTER){super(e,t),this._enableProcessCollisions=!1}_addToSimulation(){this._simulation._addPhysicsCollider(this,this._collisionGroup,this._canCollideWith)}_removeFromSimulation(){this._simulation._removePhysicsCollider(this)}_parse(e){null!=e.friction&&(this.friction=e.friction),null!=e.rollingFriction&&(this.rollingFriction=e.rollingFriction),null!=e.restitution&&(this.restitution=e.restitution),null!=e.isTrigger&&(this.isTrigger=e.isTrigger),super._parse(e),this._parseShape(e.shapes)}_onAdded(){var e=v._bullet,t=e.btCollisionObject_create();e.btCollisionObject_setUserIndex(t,this.id),e.btCollisionObject_forceActivationState(t,vt.ACTIVATIONSTATE_DISABLE_SIMULATION);var r=e.btCollisionObject_getCollisionFlags(t);this.owner.isStatic?((r&vt.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(r^=vt.COLLISIONFLAGS_KINEMATIC_OBJECT),r|=vt.COLLISIONFLAGS_STATIC_OBJECT):((r&vt.COLLISIONFLAGS_STATIC_OBJECT)>0&&(r^=vt.COLLISIONFLAGS_STATIC_OBJECT),r|=vt.COLLISIONFLAGS_KINEMATIC_OBJECT),e.btCollisionObject_setCollisionFlags(t,r),this._btColliderObject=t,super._onAdded()}}class Ti extends fi{constructor(e=_t.COLLISIONFILTERGROUP_DEFAULTFILTER,t=_t.COLLISIONFILTERGROUP_ALLFILTER){super(e,t),this._isKinematic=!1,this._mass=1,this._gravity=new n(0,-10,0),this._angularDamping=0,this._linearDamping=0,this._overrideGravity=!1,this._totalTorque=new n(0,0,0),this._totalForce=new n(0,0,0),this._linearVelocity=new n,this._angularVelocity=new n,this._linearFactor=new n(1,1,1),this._angularFactor=new n(1,1,1),this._detectCollisions=!0,this._controlBySimulation=!0}static __init__(){var e=v._bullet;Ti._btTempVector30=e.btVector3_create(0,0,0),Ti._btTempVector31=e.btVector3_create(0,0,0),Ti._btVector3Zero=e.btVector3_create(0,0,0),Ti._btInertia=e.btVector3_create(0,0,0),Ti._btImpulse=e.btVector3_create(0,0,0),Ti._btImpulseOffset=e.btVector3_create(0,0,0),Ti._btGravity=e.btVector3_create(0,0,0),Ti._btTransform0=e.btTransform_create()}get mass(){return this._mass}set mass(e){e=Math.max(e,1e-7),this._mass=e,this._isKinematic||this._updateMass(e)}get isKinematic(){return this._isKinematic}set isKinematic(e){this._isKinematic=e,this._controlBySimulation=!e;var t=v._bullet,r=!!(this._simulation&&this._enabled&&this._colliderShape);r&&this._removeFromSimulation();var i=this._btColliderObject,a=t.btCollisionObject_getCollisionFlags(i);e?(a|=vt.COLLISIONFLAGS_KINEMATIC_OBJECT,t.btCollisionObject_setCollisionFlags(i,a),t.btCollisionObject_forceActivationState(this._btColliderObject,vt.ACTIVATIONSTATE_DISABLE_DEACTIVATION),this._enableProcessCollisions=!1,this._updateMass(0)):((a&vt.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(a^=vt.COLLISIONFLAGS_KINEMATIC_OBJECT),t.btCollisionObject_setCollisionFlags(i,a),t.btCollisionObject_setActivationState(this._btColliderObject,vt.ACTIVATIONSTATE_ACTIVE_TAG),this._enableProcessCollisions=!0,this._updateMass(this._mass));var n=Ti._btVector3Zero;t.btCollisionObject_setInterpolationLinearVelocity(i,n),t.btRigidBody_setLinearVelocity(i,n),t.btCollisionObject_setInterpolationAngularVelocity(i,n),t.btRigidBody_setAngularVelocity(i,n),r&&this._addToSimulation()}get linearDamping(){return this._linearDamping}set linearDamping(e){this._linearDamping=e,this._btColliderObject&&v._bullet.btRigidBody_setDamping(this._btColliderObject,e,this._angularDamping)}get angularDamping(){return this._angularDamping}set angularDamping(e){this._angularDamping=e,this._btColliderObject&&v._bullet.btRigidBody_setDamping(this._btColliderObject,this._linearDamping,e)}get overrideGravity(){return this._overrideGravity}set overrideGravity(e){this._overrideGravity=e;var t=v._bullet;if(this._btColliderObject){var r=t.btRigidBody_getFlags(this._btColliderObject);e?0==(r&Ti._BT_DISABLE_WORLD_GRAVITY)&&t.btRigidBody_setFlags(this._btColliderObject,r|Ti._BT_DISABLE_WORLD_GRAVITY):(r&Ti._BT_DISABLE_WORLD_GRAVITY)>0&&t.btRigidBody_setFlags(this._btColliderObject,r^Ti._BT_DISABLE_WORLD_GRAVITY)}}get gravity(){return this._gravity}set gravity(e){this._gravity=e;var t=v._bullet;t.btVector3_setValue(Ti._btGravity,-e.x,e.y,e.z),t.btRigidBody_setGravity(this._btColliderObject,Ti._btGravity)}get totalForce(){if(this._btColliderObject){var e=v._bullet.btRigidBody_getTotalForce(this._btColliderObject);return I._convertToLayaVec3(e,this._totalForce,!0),this._totalForce}return null}get linearFactor(){return this._linearFactor}set linearFactor(e){this._linearFactor=e;var t=Ti._btTempVector30;I._convertToBulletVec3(e,t,!1),v._bullet.btRigidBody_setLinearFactor(this._btColliderObject,t)}get linearVelocity(){return this._btColliderObject&&I._convertToLayaVec3(v._bullet.btRigidBody_getLinearVelocity(this._btColliderObject),this._linearVelocity,!0),this._linearVelocity}set linearVelocity(e){if(this._linearVelocity=e,this._btColliderObject){var t=Ti._btTempVector30;I._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),v._bullet.btRigidBody_setLinearVelocity(this._btColliderObject,t)}}get angularFactor(){return this._angularFactor}set angularFactor(e){this._angularFactor=e;var t=Ti._btTempVector30;I._convertToBulletVec3(e,t,!1),v._bullet.btRigidBody_setAngularFactor(this._btColliderObject,t)}get angularVelocity(){return this._btColliderObject&&I._convertToLayaVec3(v._bullet.btRigidBody_getAngularVelocity(this._btColliderObject),this._angularVelocity,!0),this._angularVelocity}set angularVelocity(e){if(this._angularVelocity=e,this._btColliderObject){var t=Ti._btTempVector30;I._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),v._bullet.btRigidBody_setAngularVelocity(this._btColliderObject,t)}}get totalTorque(){if(this._btColliderObject){var e=v._bullet.btRigidBody_getTotalTorque(this._btColliderObject);return I._convertToLayaVec3(e,this._totalTorque,!0),this._totalTorque}return null}get detectCollisions(){return this._detectCollisions}set detectCollisions(e){this._detectCollisions!==e&&(this._detectCollisions=e,this._colliderShape&&this._enabled&&this._simulation&&(this._simulation._removeRigidBody(this),this._simulation._addRigidBody(this,this._collisionGroup,e?this._canCollideWith:0)))}get isSleeping(){return!!this._btColliderObject&&v._bullet.btCollisionObject_getActivationState(this._btColliderObject)===vt.ACTIVATIONSTATE_ISLAND_SLEEPING}get sleepLinearVelocity(){return v._bullet.btRigidBody_getLinearSleepingThreshold(this._btColliderObject)}set sleepLinearVelocity(e){var t=v._bullet;t.btRigidBody_setSleepingThresholds(this._btColliderObject,e,t.btRigidBody_getAngularSleepingThreshold(this._btColliderObject))}get sleepAngularVelocity(){return v._bullet.btRigidBody_getAngularSleepingThreshold(this._btColliderObject)}set sleepAngularVelocity(e){var t=v._bullet;t.btRigidBody_setSleepingThresholds(this._btColliderObject,t.btRigidBody_getLinearSleepingThreshold(this._btColliderObject),e)}_updateMass(e){if(this._btColliderObject&&this._colliderShape){var t=v._bullet;t.btCollisionShape_calculateLocalInertia(this._colliderShape._btShape,e,Ti._btInertia),t.btRigidBody_setMassProps(this._btColliderObject,e,Ti._btInertia),t.btRigidBody_updateInertiaTensor(this._btColliderObject)}}_onScaleChange(e){super._onScaleChange(e),this._updateMass(this._isKinematic?0:this._mass)}_derivePhysicsTransformation(e){var t=v._bullet,r=this._btColliderObject,i=t.btCollisionObject_getWorldTransform(r),a=Ti._btTransform0;t.btTransform_equal(a,i),this._innerDerivePhysicsTransformation(a,e),t.btRigidBody_setCenterOfMassTransform(r,a)}_onAdded(){var e=v._bullet,t=e.layaMotionState_create();e.layaMotionState_set_rigidBodyID(t,this._id),this._btLayaMotionState=t;var r=e.btRigidBodyConstructionInfo_create(0,t,null,Ti._btVector3Zero),i=e.btRigidBody_create(r);e.btCollisionObject_setUserIndex(i,this.id),this._btColliderObject=i,super._onAdded(),this.mass=this._mass,this.linearFactor=this._linearFactor,this.angularFactor=this._angularFactor,this.linearDamping=this._linearDamping,this.angularDamping=this._angularDamping,this.overrideGravity=this._overrideGravity,this.gravity=this._gravity,this.isKinematic=this._isKinematic,e.btRigidBodyConstructionInfo_destroy(r)}_onShapeChange(e){if(super._onShapeChange(e),this._isKinematic)this._updateMass(0);else{var t=v._bullet;t.btRigidBody_setCenterOfMassTransform(this._btColliderObject,t.btCollisionObject_getWorldTransform(this._btColliderObject)),this._updateMass(this._mass)}}_parse(e){if(null!=e.friction&&(this.friction=e.friction),null!=e.rollingFriction&&(this.rollingFriction=e.rollingFriction),null!=e.restitution&&(this.restitution=e.restitution),null!=e.isTrigger&&(this.isTrigger=e.isTrigger),null!=e.mass&&(this.mass=e.mass),null!=e.isKinematic&&(this.isKinematic=e.isKinematic),null!=e.linearDamping&&(this.linearDamping=e.linearDamping),null!=e.angularDamping&&(this.angularDamping=e.angularDamping),null!=e.overrideGravity&&(this.overrideGravity=e.overrideGravity),null!=e.linearFactor){var t=this.linearFactor;t.fromArray(e.linearFactor),this.linearFactor=t}if(null!=e.angularFactor){var r=this.angularFactor;r.fromArray(e.angularFactor),this.angularFactor=r}e.gravity&&(this.gravity.fromArray(e.gravity),this.gravity=this.gravity),super._parse(e),this._parseShape(e.shapes)}_onDestroy(){v._bullet.btMotionState_destroy(this._btLayaMotionState),super._onDestroy(),this._btLayaMotionState=null,this._gravity=null,this._totalTorque=null,this._linearVelocity=null,this._angularVelocity=null,this._linearFactor=null,this._angularFactor=null}_addToSimulation(){this._simulation._addRigidBody(this,this._collisionGroup,this._detectCollisions?this._canCollideWith:0)}_removeFromSimulation(){this._simulation._removeRigidBody(this)}_cloneTo(e){super._cloneTo(e);var t=e;t.isKinematic=this._isKinematic,t.mass=this._mass,t.gravity=this._gravity,t.angularDamping=this._angularDamping,t.linearDamping=this._linearDamping,t.overrideGravity=this._overrideGravity,t.linearVelocity=this._linearVelocity,t.angularVelocity=this._angularVelocity,t.linearFactor=this._linearFactor,t.angularFactor=this._angularFactor,t.detectCollisions=this._detectCollisions}applyForce(e,t=null){if(null==this._btColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var r=v._bullet,i=Ti._btTempVector30;if(r.btVector3_setValue(i,-e.x,e.y,e.z),t){var a=Ti._btTempVector31;r.btVector3_setValue(a,-t.x,t.y,t.z),r.btRigidBody_applyForce(this._btColliderObject,i,a)}else r.btRigidBody_applyCentralForce(this._btColliderObject,i)}applyTorque(e){if(null==this._btColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=v._bullet,r=Ti._btTempVector30;t.btVector3_setValue(r,-e.x,e.y,e.z),t.btRigidBody_applyTorque(this._btColliderObject,r)}applyImpulse(e,t=null){if(null==this._btColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var r=v._bullet;r.btVector3_setValue(Ti._btImpulse,-e.x,e.y,e.z),t?(r.btVector3_setValue(Ti._btImpulseOffset,-t.x,t.y,t.z),r.btRigidBody_applyImpulse(this._btColliderObject,Ti._btImpulse,Ti._btImpulseOffset)):r.btRigidBody_applyCentralImpulse(this._btColliderObject,Ti._btImpulse)}applyTorqueImpulse(e){if(null==this._btColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=v._bullet,r=Ti._btTempVector30;t.btVector3_setValue(r,-e.x,e.y,e.z),t.btRigidBody_applyTorqueImpulse(this._btColliderObject,r)}wakeUp(){this._btColliderObject&&v._bullet.btCollisionObject_activate(this._btColliderObject,!1)}clearForces(){var e=this._btColliderObject;if(null==e)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=v._bullet;t.btRigidBody_clearForces(e);var r=Ti._btVector3Zero;t.btCollisionObject_setInterpolationLinearVelocity(e,r),t.btRigidBody_setLinearVelocity(e,r),t.btCollisionObject_setInterpolationAngularVelocity(e,r),t.btRigidBody_setAngularVelocity(e,r)}}Ti.TYPE_STATIC=0,Ti.TYPE_DYNAMIC=1,Ti.TYPE_KINEMATIC=2,Ti._BT_DISABLE_WORLD_GRAVITY=1,Ti._BT_ENABLE_GYROPSCOPIC_FORCE=2;class pi extends mt{static __init__(){pi._btNormal=v._bullet.btVector3_create(0,0,0)}constructor(e,t){super(),this._normal=e,this._offset=t,this._type=mt.SHAPETYPES_STATICPLANE;var r=v._bullet;r.btVector3_setValue(pi._btNormal,-e.x,e.y,e.z),this._btShape=r.btStaticPlaneShape_create(pi._btNormal,t)}clone(){var e=new pi(this._normal,this._offset);return this.cloneTo(e),e}}class gi extends wt{constructor(e){super(),this._id=++gi._uniqueIDCounter,this._mesh=e,this._boneIndicesList=[],this._subIndexBufferStart=[],this._subIndexBufferCount=[]}get indexCount(){return this._indexCount}_setIndexRange(e,t){this._indexStart=e,this._indexCount=t,this._indices=new Uint16Array(this._indexBuffer.getData().buffer,2*e,t)}_getType(){return gi._type}_prepareRender(e){return this._mesh._uploadVerticesData(),!0}_render(r){var i=this._mesh;if(i.indexFormat!==e.IndexFormat.UInt32||t.LayaGL.layaGPUInstance.supportElementIndexUint32()){var a,n,s=t.LayaGL.instance,o=r.renderElement.render._skinnedData;switch(i.indexFormat){case e.IndexFormat.UInt32:a=s.UNSIGNED_INT,n=4;break;case e.IndexFormat.UInt16:a=s.UNSIGNED_SHORT,n=2;break;case e.IndexFormat.UInt8:a=s.UNSIGNED_BYTE,n=1}if(i._bufferState.bind(),o)for(var l=o[this._indexInMesh],_=0,h=this._boneIndicesList.length;_0) dH = 1/(realRoughness^2+1)\r\n\r\n // 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]\r\n // 1-x^3*(0.6-0.08*x) approximation for 1/(x^4+1)\r\n\t// #ifdef LAYA_COLORSPACE_GAMMA\r\n\t\tmediump float surfaceReduction = 0.28;\r\n\t// #else\r\n\t\t// mediump float surfaceReduction = (0.6-0.08*perceptualRoughness);\r\n\t// #endif\r\n\r\n surfaceReduction = 1.0 - roughness*perceptualRoughness*surfaceReduction;\r\n\r\n\tmediump float grazingTerm = clamp(smoothness + (1.0-oneMinusReflectivity),0.0,1.0);\r\n\tmediump vec3 color =gi.diffuse * diffColor+ surfaceReduction * gi.specular * fresnelLerpFast (specColor, vec3(grazingTerm), nv);\r\n\r\n return vec4(color, 1.0);\r\n}\r\n// BRDF2-------------------------------------------------------------------------------------',zi="struct FragmentCommonData{\r\n\tvec3 diffColor;\r\n\tvec3 specColor;\r\n\tfloat oneMinusReflectivity;\r\n\tfloat smoothness;\r\n\t//vec3 eyeVec;TODO:maybe can remove\r\n\t//float alpha;\r\n\t//vec3 reflUVW;\r\n};\r\n\r\n#ifndef SETUP_BRDF_INPUT\r\n #define SETUP_BRDF_INPUT metallicSetup//default is metallicSetup,also can be other. \r\n#endif\r\n\r\nconst mediump vec4 dielectricSpecularColor = vec4(0.220916301, 0.220916301, 0.220916301, 1.0 - 0.220916301);\r\n\r\nmediump vec3 diffuseAndSpecularFromMetallic(mediump vec3 albedo,mediump float metallic, out mediump vec3 specColor, out mediump float oneMinusReflectivity)\r\n{\r\n\tspecColor = mix(dielectricSpecularColor.rgb, albedo, metallic);\r\n\toneMinusReflectivity= dielectricSpecularColor.a*(1.0-metallic);//diffuse proportion\r\n\treturn albedo * oneMinusReflectivity;\r\n}\r\n\r\nmediump float specularStrength(mediump vec3 specular)\r\n{\r\n return max (max (specular.r, specular.g), specular.b);\r\n}\r\n\r\n// Diffuse/Spec Energy conservation\r\nmediump vec3 energyConservationBetweenDiffuseAndSpecular (mediump vec3 albedo, mediump vec3 specColor, out mediump float oneMinusReflectivity)\r\n{\r\n\toneMinusReflectivity = 1.0 - specularStrength(specColor);\r\n return albedo * (vec3(1.0) - specColor);\r\n}\r\n\r\n#ifdef TRANSPARENTBLEND\r\n\tmediump vec3 preMultiplyAlpha (mediump vec3 diffColor, mediump float alpha, mediump float oneMinusReflectivity,out mediump float modifiedAlpha)\r\n\t{\r\n\t\t// Transparency 'removes' from Diffuse component\r\n\t\tdiffColor *= alpha;\r\n\t\t// Reflectivity 'removes' from the rest of components, including Transparency\r\n\t\t// modifiedAlpha = 1.0-(1.0-alpha)*(1.0-reflectivity) = 1.0-(oneMinusReflectivity - alpha*oneMinusReflectivity) = 1.0-oneMinusReflectivity + alpha*oneMinusReflectivity\r\n\t\tmodifiedAlpha = 1.0 - oneMinusReflectivity + alpha*oneMinusReflectivity;\r\n\t\treturn diffColor;\r\n\t}\r\n#endif\r\n\r\nFragmentCommonData metallicSetup(vec2 uv)\r\n{\r\n\tmediump vec2 metallicGloss = getMetallicGloss(uv);\r\n\tmediump float metallic = metallicGloss.x;\r\n\tmediump float smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.\r\n\tmediump float oneMinusReflectivity;\r\n\tmediump vec3 specColor;\r\n\tmediump vec3 diffColor = diffuseAndSpecularFromMetallic(albedo(uv), metallic,/*out*/specColor,/*out*/oneMinusReflectivity);\r\n\r\n\tFragmentCommonData o;\r\n\to.diffColor = diffColor;\r\n\to.specColor = specColor;\r\n\to.oneMinusReflectivity = oneMinusReflectivity;\r\n\to.smoothness = smoothness;\r\n\treturn o;\r\n}\r\n\r\nFragmentCommonData specularSetup(vec2 uv)\r\n{\r\n mediump vec4 specGloss = specularGloss(uv);\r\n mediump vec3 specColor = specGloss.rgb;\r\n mediump float smoothness = specGloss.a;\r\n\r\n mediump float oneMinusReflectivity;\r\n mediump vec3 diffColor = energyConservationBetweenDiffuseAndSpecular (albedo(uv), specColor, /*out*/ oneMinusReflectivity);\r\n\r\n FragmentCommonData o;\r\n o.diffColor = diffColor;\r\n o.specColor = specColor;\r\n o.oneMinusReflectivity = oneMinusReflectivity;\r\n o.smoothness = smoothness;\r\n return o;\r\n}\r\n\r\nLayaGI fragmentGI(float smoothness,vec3 eyeVec,mediump float occlusion,mediump vec2 lightmapUV,vec3 worldnormal)\r\n{\r\n\tLayaGIInput giInput;\r\n\t#ifdef LIGHTMAP\r\n\t\tgiInput.lightmapUV=lightmapUV;\r\n\t#endif\r\n\r\n\tvec3 worldViewDir = -eyeVec;\r\n\tmediump vec4 uvwRoughness;\r\n\tuvwRoughness.rgb = reflect(worldViewDir, worldnormal);//reflectUVW\r\n\tuvwRoughness.a= smoothnessToPerceptualRoughness(smoothness);//perceptualRoughness\r\n\r\n\treturn layaGlobalIllumination(giInput,occlusion, worldnormal, uvwRoughness);\r\n}\r\n\r\n\r\nvec3 perPixelWorldNormal(vec2 uv,vec3 normal,vec3 binormal,vec3 tangent)\r\n{\r\n\t#ifdef NORMALTEXTURE\r\n\t\tmediump vec3 normalTangent=normalInTangentSpace(uv);\r\n\t\tvec3 normalWorld = normalize(tangent * normalTangent.x + binormal * normalTangent.y + normal * normalTangent.z);\r\n\t#else\r\n\t\tvec3 normalWorld = normalize(normal);\r\n\t#endif\r\n\t\treturn normalWorld;\r\n}\r\n\r\nvoid fragmentForward()\r\n{\r\n\tvec2 uv;\r\n\t#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)\r\n\t\t#ifdef PARALLAXTEXTURE\r\n\t\t\tuv = parallax(v_Texcoord0,normalize(v_ViewDirForParallax));\r\n\t\t#else\r\n\t\t\tuv = v_Texcoord0;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\tmediump float alpha = getAlpha(uv);\r\n\t#ifdef ALPHATEST\r\n\t\tif(alpha= u_DirationLightCount)\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t#ifdef CALCULATE_SHADOWS\r\n\t\t\t\t\tif(i == 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t#ifdef SHADOW_CASCADE\r\n\t\t\t\t\t\t\tvec4 shadowCoord = getShadowCoord(vec4(v_PositionWorld,1.0));\r\n\t\t\t\t\t\t#else\r\n\t\t\t\t\t\t\tvec4 shadowCoord = v_ShadowCoord;\r\n\t\t\t\t\t\t#endif\r\n\t\t\t\t\t\tshadowAttenuation *= sampleShadowmap(shadowCoord);\r\n\t\t\t\t\t}\r\n\t\t\t\t#endif\r\n\t\t\t\tDirectionLight directionLight = getDirectionLight(u_LightBuffer,i);\r\n\t\t\t\tLayaLight dirLight = layaDirectionLightToLight(directionLight,shadowAttenuation);\r\n\t\t\t \tcolor+=LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,dirLight);\r\n\t\t\t}\r\n\t \t#endif\r\n\t\t#if defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\t\tivec4 clusterInfo =getClusterInfo(u_LightClusterBuffer,u_View,u_Viewport, v_PositionWorld,gl_FragCoord,u_ProjectionParams);\r\n\t\t\t#ifdef POINTLIGHT\r\n\t\t\t\tfor (int i = 0; i < MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(i >= clusterInfo.x)//PointLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tPointLight pointLight = getPointLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\tLayaLight poiLight = layaPointLightToLight(posworld,normalWorld,pointLight,shadowAttenuation);\r\n\t\t\t\t\tcolor+= LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,poiLight);\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t\t#ifdef SPOTLIGHT\r\n\t\t\t\tfor (int i = 0; i < MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(i >= clusterInfo.y)//SpotLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tSpotLight spotLight = getSpotLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\tLayaLight spoLight = layaSpotLightToLight(posworld,normalWorld,spotLight,shadowAttenuation);\r\n\t\t\t\t\tcolor+= LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,spoLight);\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t #endif\r\n\r\n\t#ifdef EMISSION\r\n\t\tcolor.rgb += emission(uv);\r\n\t#endif\r\n\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact=clamp((1.0/gl_FragCoord.w-u_FogStart)/u_FogRange,0.0,1.0);\r\n\t\tcolor.rgb=mix(color.rgb,u_FogColor,lerpFact);\r\n\t#endif\r\n\t\r\n\tgl_FragColor=vec4(color.rgb,alpha);\r\n}\r\n\r\n\r\n",Hi="attribute vec4 a_Position;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n\tattribute mat4 a_WorldMat;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n\tuniform mat4 u_WorldMat;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nattribute vec3 a_Normal;\r\nvarying vec3 v_Normal; \r\n\r\n#if defined(NORMALTEXTURE)||defined(PARALLAXTEXTURE)\r\n\tattribute vec4 a_Tangent0;\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\r\n #ifdef PARALLAXTEXTURE\r\n\t varying vec3 v_ViewDirForParallax;\r\n #endif\r\n#endif\r\n\r\n#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)||(defined(LIGHTMAP)&&defined(UV))\r\n\tattribute vec2 a_Texcoord0;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\n#if defined(LIGHTMAP)&&defined(UV1)\r\n\tattribute vec2 a_Texcoord1;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tuniform vec4 u_LightmapScaleOffset;\r\n\tvarying vec2 v_LightMapUV;\r\n#endif\r\n\r\nuniform vec3 u_CameraPos;\r\nvarying vec3 v_EyeVec;\r\nvarying vec3 v_PositionWorld;\r\nvarying float v_posViewZ;\r\n\r\n#if defined(CALCULATE_SHADOWS)&&!defined(SHADOW_CASCADE)\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif",Wi="#ifdef ALPHATEST\r\n\tuniform float u_AlphaTestValue;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\r\n\r\n#ifdef NORMALTEXTURE\r\n\tuniform sampler2D u_NormalTexture;\r\n\tuniform float u_NormalScale;\r\n#endif\r\n\r\n#ifdef ALBEDOTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n#endif\r\n\r\n#ifdef METALLICGLOSSTEXTURE\r\n\tuniform sampler2D u_MetallicGlossTexture;\r\n#endif\r\nuniform float u_Metallic;\r\n\r\n#ifdef SPECULARGLOSSTEXTURE\r\n\tuniform sampler2D u_SpecGlossTexture;\r\n#endif\r\nuniform vec3 u_SpecularColor;\r\n\r\nuniform float u_Smoothness;\r\nuniform float u_SmoothnessScale;\r\n\r\n#ifdef PARALLAXTEXTURE\r\n\tuniform sampler2D u_ParallaxTexture;\r\n\tuniform float u_ParallaxScale;\r\n\tvarying vec3 v_ViewDirForParallax;\r\n#endif\r\n\r\n#ifdef OCCLUSIONTEXTURE\r\n\tuniform sampler2D u_OcclusionTexture;\r\n\tuniform float u_occlusionStrength;\r\n#endif\r\n\r\n#ifdef EMISSION \r\n\t#ifdef EMISSIONTEXTURE\r\n\t\tuniform sampler2D u_EmissionTexture;\r\n\t#endif\r\n\tuniform vec4 u_EmissionColor;\r\n#endif\r\n\r\n#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform sampler2D u_LightMap;\r\n\t#ifdef LIGHTMAP_DIRECTIONAL\r\n\t\tuniform sampler2D u_LightMapDirection;\r\n\t#endif\r\n#endif\r\n\r\nvarying vec3 v_Normal; \r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tuniform DirectionLight u_DirectionLight;\r\n\t\t#endif\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tuniform PointLight u_PointLight;\r\n\t\t#endif\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tuniform SpotLight u_SpotLight;\r\n\t\t#endif\r\n\t#else\r\n\t\tuniform mat4 u_View;\r\n\t\tuniform vec4 u_ProjectionParams;\r\n\t\tuniform vec4 u_Viewport;\r\n\t\tuniform int u_DirationLightCount;\r\n\t\tuniform sampler2D u_LightBuffer;\r\n\t\tuniform sampler2D u_LightClusterBuffer;\r\n\t#endif\r\n#endif\r\n\r\nvarying vec3 v_EyeVec;\r\n\r\n#ifdef NORMALTEXTURE\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\tuniform vec3 u_FogColor;\r\n#endif\r\n\r\n\r\n//后面考虑宏TODO\r\nvarying vec3 v_PositionWorld;\r\n\r\n#if defined(CALCULATE_SHADOWS)&&!defined(SHADOW_CASCADE)\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\n\r\nmediump float lerpOneTo(mediump float b, mediump float t)\r\n{\r\n mediump float oneMinusT = 1.0 - t;\r\n return oneMinusT + b * t;\r\n}\r\n\r\n#ifdef EMISSION \r\n\tvec3 emission(vec2 uv)\r\n\t{\r\n\t\t#ifdef EMISSIONTEXTURE\r\n\t\t\treturn texture2D(u_EmissionTexture, uv).rgb * u_EmissionColor.rgb;\r\n\t\t#else\r\n\t\t\treturn u_EmissionColor.rgb;\r\n\t\t#endif\r\n\t}\r\n#endif\r\n\r\nmediump float getAlpha(vec2 uv)\r\n{\r\n\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\treturn u_AlbedoColor.a;\r\n\t#else\r\n\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\treturn texture2D(u_AlbedoTexture, uv).a * u_AlbedoColor.a;\r\n\t\t#else\r\n\t\t\treturn u_AlbedoColor.a;\r\n\t\t#endif\r\n\t#endif\r\n}\r\n\r\nmediump float getOcclusion(vec2 uv)\r\n{\r\n\t#ifdef OCCLUSIONTEXTURE\r\n\t\tmediump float occ = texture2D(u_OcclusionTexture, uv).g;\r\n\t\treturn lerpOneTo(occ, u_occlusionStrength);\r\n\t#else\r\n\t\treturn 1.0;\r\n\t#endif\r\n}\r\n\r\nmediump vec3 albedo(vec2 uv)\r\n{\r\n\t#ifdef ALBEDOTEXTURE\r\n\t\treturn u_AlbedoColor.rgb * texture2D(u_AlbedoTexture, uv).rgb;\r\n\t#else\r\n\t\treturn u_AlbedoColor.rgb;\r\n\t#endif\r\n\t//TODO:Detail Texture\r\n}\r\n\r\nmediump vec2 getMetallicGloss(vec2 uv)\r\n{\r\n\tmediump vec2 ms;//x is metallic,y is smoothness\r\n\t#ifdef METALLICGLOSSTEXTURE\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\tms.x = texture2D(u_MetallicGlossTexture, uv).r;\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tms.y = texture2D(u_AlbedoTexture, uv).a*u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tms.y = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tms = texture2D(u_MetallicGlossTexture, uv).ra;\r\n\t\t\tms.y *= u_SmoothnessScale;\r\n\t\t#endif\r\n\t#else\r\n\t\tms.x = u_Metallic;\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tms.y = texture2D(u_AlbedoTexture, uv).a * u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tms.y = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tms.y = u_Smoothness;\r\n\t\t#endif\r\n\t#endif\r\n\treturn ms;\r\n}\r\n\r\nmediump vec4 specularGloss(vec2 uv)\r\n{\r\n\tmediump vec4 sg;\r\n\t#ifdef SPECULARGLOSSTEXTURE\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\tsg.rgb = texture2D(u_SpecGlossTexture, uv).rgb;\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tsg.a = texture2D(u_AlbedoTexture, uv).a*u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tsg.a = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tsg = texture2D(u_SpecGlossTexture, uv);\r\n\t\t\tsg.a *= u_SmoothnessScale;\r\n\t\t#endif\r\n\t#else\r\n\t\tsg.rgb = u_SpecularColor.rgb;\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tsg.a = texture2D(u_AlbedoTexture, uv).a * u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tsg.a = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tsg.a = u_Smoothness;\r\n\t\t#endif\r\n\t#endif\r\n\t\treturn sg;\r\n}\r\n\r\n\r\n#ifdef NORMALTEXTURE\r\n\tmediump vec3 unpackScaleNormal(mediump vec3 packednormal, mediump float bumpScale)\r\n\t{\r\n\t\tmediump vec3 normal = packednormal.xyz * 2.0 - 1.0;\r\n\t\tnormal.y=-normal.y;//NOTE:because unity to LayaAir coordSystem.\r\n\t\tnormal.xy *= bumpScale;\r\n\t\treturn normal;\r\n\t}\r\n\t\r\n\tmediump vec3 normalInTangentSpace(vec2 texcoords)\r\n\t{\r\n\t\tmediump vec3 normalTangent = unpackScaleNormal(texture2D(u_NormalTexture, texcoords).rgb,u_NormalScale);\r\n\t\treturn normalTangent;\r\n\t}\r\n#endif\r\n\r\n#ifdef PARALLAXTEXTURE\r\n\tmediump vec2 parallaxOffset1Step(mediump float h, mediump float height, mediump vec3 viewDir)\r\n\t{\r\n\t\th = h * height - height / 2.0;\r\n\t\tviewDir.z += 0.42;\r\n\t\treturn h * (viewDir.xy / viewDir.z);\r\n\t}\r\n\r\n\tvec2 parallax(vec2 texcoords, mediump vec3 viewDir)\r\n\t{\r\n\t\tmediump float h = texture2D(u_ParallaxTexture, texcoords.xy).g;\r\n\t\tvec2 offset = parallaxOffset1Step(h, u_ParallaxScale, viewDir);\r\n\t\treturn texcoords+offset;\r\n\t}\r\n#endif\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n",ki="vec2 transformLightMapUV(in vec2 texcoord,in vec4 lightmapScaleOffset)\r\n{\r\n\tvec2 lightMapUV=vec2(texcoord.x,1.0-texcoord.y)*lightmapScaleOffset.xy+lightmapScaleOffset.zw;\r\n\tlightMapUV.y=1.0-lightMapUV.y;\r\n\treturn lightMapUV; \r\n}\r\n\r\nvoid vertexForward()\r\n{\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\r\n\tmat4 worldMat;\r\n\t#ifdef GPU_INSTANCE\r\n\t\tworldMat = a_WorldMat;\r\n\t#else\r\n\t\tworldMat = u_WorldMat;\r\n\t#endif\r\n\r\n\tv_PositionWorld=(worldMat*position).xyz;\r\n\r\n\t#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)\r\n\t\t#ifdef TILINGOFFSET\r\n\t\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t\t#else\r\n\t\t\tv_Texcoord0=a_Texcoord0;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\tv_EyeVec =u_CameraPos-v_PositionWorld;//will normalize per-pixel\r\n\r\n\t#ifdef LIGHTMAP\r\n\t\tvec2 texcoord;\r\n\t\t#ifdef UV1\r\n\t\t\ttexcoord=a_Texcoord1;\r\n\t\t#else\r\n\t\t\ttexcoord=a_Texcoord0;\r\n\t\t#endif\r\n\t\tv_LightMapUV=transformLightMapUV(texcoord,u_LightmapScaleOffset);\r\n\t#endif\r\n\r\n\tmat3 worldInvMat;\r\n\t#ifdef BONE\r\n\t\tworldInvMat=INVERSE_MAT(mat3(worldMat*skinTransform));\r\n\t#else\r\n\t\tworldInvMat=INVERSE_MAT(mat3(worldMat));\r\n\t#endif\r\n\r\n\tv_Normal=normalize(a_Normal*worldInvMat);//if no normalize will cause precision problem.\r\n\r\n\t#ifdef NORMALTEXTURE\r\n\t\tv_Tangent=normalize(a_Tangent0.xyz*worldInvMat);\r\n\t\tv_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\r\n\t#endif\r\n\r\n\t#ifdef PARALLAXTEXTURE\r\n\t\tvec3 binormal = cross(a_Normal, a_Tangent0.xyz)*a_Tangent0.w;\r\n\t\tmat3 objectTBN = mat3(a_Tangent0.xyz, binormal, a_Normal);\r\n\t\tv_ViewDirForParallax=(worldInvMat*u_CameraPos-position.xyz)*objectTBN;\r\n\t#endif\r\n\r\n\t#if defined(CALCULATE_SHADOWS)&&!defined(SHADOW_CASCADE)\r\n\t\tv_ShadowCoord = getShadowCoord(vec4(v_PositionWorld,1.0));\r\n\t#endif\r\n}",Xi='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_PositionTexcoord;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\r\n\tv_Texcoord0 = a_PositionTexcoord.zw;\r\n\tgl_Position = remapGLPositionZ(gl_Position);\r\n}',Yi='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\n\r\nvoid fragDownsample13() {\r\n\tmediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = color;\r\n}\r\n\r\nvoid main() {\r\n\tfragDownsample13();\r\n}',ji='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\n\r\nvoid fragDownsample4() {\r\n\tmediump vec4 color = downsampleBox4Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = color;\r\n}\r\n\r\nvoid main() {\r\n\tfragDownsample4();\r\n}',Zi='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_AutoExposureTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\r\nuniform vec4 u_Params; // x: clamp, yzw: unused\r\n\r\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\r\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\r\n\tcolor *= autoExposure;\r\n\tcolor = min(vec4(u_Params.x), color); // clamp to max\r\n\tcolor = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\r\n\treturn color;\r\n}\r\n\r\nvoid fragPrefilter13() {\r\n\tmediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragPrefilter13();\r\n}',qi='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_AutoExposureTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\r\nuniform vec4 u_Params; // x: clamp, yzw: unused\r\n\r\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\r\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\r\n\tcolor *= autoExposure;\r\n\tcolor = min(vec4(u_Params.x), color); // clamp to max\r\n\tcolor = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\r\n\treturn color;\r\n}\r\n\r\nvoid fragPrefilter4() {\r\n\tmediump vec4 color = downsampleBox4Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragPrefilter4();\r\n}',Qi='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_BloomTex;\r\n\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform float u_SampleScale;\r\n\r\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\r\n\tmediump vec4 color = texture2D(u_BloomTex, uv);\r\n\treturn bloom + color;\r\n}\r\n\r\nvoid fragUpsampleBox() {\r\n\tmediump vec4 bloom = upsampleBox(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, vec4(u_SampleScale));\r\n\tgl_FragColor = combine(bloom, v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragUpsampleBox();\r\n}',Ki='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_BloomTex;\r\n\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform float u_SampleScale;\r\n\r\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\r\n\tmediump vec4 color = texture2D(u_BloomTex, uv);\r\n\treturn bloom + color;\r\n}\r\n\r\nvoid fragUpsampleTent() {\r\n\tmediump vec4 bloom = upsampleTent(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, vec4(u_SampleScale));\r\n\tgl_FragColor = combine(bloom, v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragUpsampleTent();\r\n}',Ji='#include "StdLib.glsl";\r\n\r\n#define EPSILON 1.0e-4\r\n\r\n// Quadratic color thresholding\r\n// curve = (threshold - knee, knee * 2, 0.25 / knee)\r\nmediump vec4 quadraticThreshold(mediump vec4 color, mediump float threshold, mediump vec3 curve) {\r\n\t// Pixel brightness\r\n\tmediump float br = max3(color.r, color.g, color.b);\r\n\r\n\t// Under-threshold part: quadratic curve\r\n\tmediump float rq = clamp(br - curve.x, 0.0, curve.y);\r\n\trq = curve.z * rq * rq;\r\n\r\n\t// Combine and apply the brightness response curve.\r\n\tcolor *= max(rq, br - threshold) / max(br, EPSILON);\r\n\r\n\treturn color;\r\n}\r\n\r\n\r\n\r\n//\r\n// sRGB transfer functions\r\n// Fast path ref: http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1\r\n//\r\nmediump vec3 sRGBToLinear(mediump vec3 c) {\r\n\t#ifdef USE_VERY_FAST_SRGB\r\n\t\treturn c * c;\r\n\t#elif defined(USE_FAST_SRGB)\r\n\t\treturn c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);\r\n\t#else\r\n\t\tmediump vec3 linearRGBLo = c / 12.92;\r\n\t\tmediump vec3 power=vec3(2.4, 2.4, 2.4);\r\n\t\tmediump vec3 linearRGBHi = positivePow((c + 0.055) / 1.055, power);\r\n\t\tmediump vec3 linearRGB =vec3((c.r<=0.04045) ? linearRGBLo.r : linearRGBHi.r,(c.g<=0.04045) ? linearRGBLo.g : linearRGBHi.g,(c.b<=0.04045) ? linearRGBLo.b : linearRGBHi.b);\r\n\t\treturn linearRGB;\r\n\t#endif\r\n}\r\n\r\nmediump vec4 sRGBToLinear(mediump vec4 c){\r\n return vec4(sRGBToLinear(c.rgb), c.a);\r\n}\r\n\r\n\r\n\r\nmediump vec3 linearToSRGB(mediump vec3 c) {\r\n\t#ifdef USE_VERY_FAST_SRGB\r\n\t\treturn sqrt(c);\r\n\t#elif defined(USE_FAST_SRGB)\r\n\t\treturn max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);\r\n\t#else\r\n\t\tmediump vec3 sRGBLo = c * 12.92;\r\n\t\tmediump vec3 power=vec3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4);\r\n\t\tmediump vec3 sRGBHi = (positivePow(c, power) * 1.055) - 0.055;\r\n\t\tmediump vec3 sRGB =vec3((c.r<=0.0031308) ? sRGBLo.r : sRGBHi.r,(c.g<=0.0031308) ? sRGBLo.g : sRGBHi.g,(c.b<=0.0031308) ? sRGBLo.b : sRGBHi.b);\r\n\t\treturn sRGB;\r\n\t#endif\r\n}\r\n\r\nmediump vec4 linearToSRGB(mediump vec4 c){\r\n return vec4(linearToSRGB(c.rgb), c.a);\r\n}',$i='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_BloomTex;\r\n\r\nuniform sampler2D u_AutoExposureTex;\r\nuniform sampler2D u_Bloom_DirtTex;\r\nuniform vec4 u_BloomTex_TexelSize;\r\nuniform vec4 u_Bloom_DirtTileOffset; // xy: tiling, zw: offset\r\nuniform mediump vec3 u_Bloom_Settings;// x: sampleScale, y: intensity, z: dirt intensity\r\nuniform mediump vec3 u_Bloom_Color;\r\n\r\nvoid main() {\r\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, v_Texcoord0).r;\r\n\tmediump vec4 color=vec4(0.0);\r\n\tcolor = texture2D(u_MainTex, v_Texcoord0);\r\n\t\r\n\tcolor = sRGBToLinear(color);\r\n\tcolor.rgb *= autoExposure;\r\n\t\r\n\t#if defined(BLOOM)||defined(BLOOM_LOW)\r\n\t\t#ifdef BLOOM\r\n\t\t\tmediump vec4 bloom = upsampleTent(u_BloomTex, v_Texcoord0, u_BloomTex_TexelSize.xy, vec4(u_Bloom_Settings.x));\r\n\t\t#else\r\n\t\t\tmediump vec4 bloom = upsampleBox(u_BloomTex, v_Texcoord0, u_BloomTex_TexelSize.xy, vec4(u_Bloom_Settings.x));\r\n\t\t#endif\r\n\r\n\t\t// UVs should be Distort(uv * u_Bloom_DirtTileOffset.xy + u_Bloom_DirtTileOffset.zw)\r\n\t\t// but considering we use a cover-style scale on the dirt texture the difference\r\n\t\t// isn\'t massive so we chose to save a few ALUs here instead in case lens distortion\r\n\t\t// is active\r\n\t\tmediump vec4 dirt =vec4(texture2D(u_Bloom_DirtTex, v_Texcoord0 * u_Bloom_DirtTileOffset.xy + u_Bloom_DirtTileOffset.zw).rgb, 0.0);\r\n\r\n\t\t// Additive bloom (artist friendly)\r\n\t\tbloom *= u_Bloom_Settings.y;\r\n\t\tdirt *= u_Bloom_Settings.z;\r\n\t\tmediump vec4 bloomColor=vec4(u_Bloom_Color, 1.0);\r\n\t\tcolor += bloom * bloomColor;\r\n\t\tcolor += dirt * bloom;\r\n\t#endif\r\n\t\r\n\tmediump vec4 finalColor = color;\r\n\tfinalColor = linearToSRGB(finalColor);\r\n\t//finalColor.rgb = Dither(finalColor.rgb, v_Texcoord0);//TODO:抖动\r\n\tgl_FragColor = finalColor;\r\n}',ea='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_PositionTexcoord;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\r\n\tv_Texcoord0 = a_PositionTexcoord.zw;\r\n\tgl_Position = remapGLPositionZ(gl_Position);\r\n}',ta="// Better, temporally stable box filtering\r\n// [Jimenez14] http://goo.gl/eomGso\r\n// . . . . . . .\r\n// . A . B . C .\r\n// . . D . E . .\r\n// . F . G . H .\r\n// . . I . J . .\r\n// . K . L . M .\r\n// . . . . . . .\r\nmediump vec4 downsampleBox13Tap(sampler2D tex, vec2 uv, vec2 texelSize)\r\n{\r\n mediump vec4 A = texture2D(tex, uv + texelSize * vec2(-1.0, -1.0));\r\n mediump vec4 B = texture2D(tex, uv + texelSize * vec2( 0.0, -1.0));\r\n mediump vec4 C = texture2D(tex, uv + texelSize * vec2( 1.0, -1.0));\r\n mediump vec4 D = texture2D(tex, uv + texelSize * vec2(-0.5, -0.5));\r\n mediump vec4 E = texture2D(tex, uv + texelSize * vec2( 0.5, -0.5));\r\n mediump vec4 F = texture2D(tex, uv + texelSize * vec2(-1.0, 0.0));\r\n mediump vec4 G = texture2D(tex, uv);\r\n mediump vec4 H = texture2D(tex, uv + texelSize * vec2( 1.0, 0.0));\r\n mediump vec4 I = texture2D(tex, uv + texelSize * vec2(-0.5, 0.5));\r\n mediump vec4 J = texture2D(tex, uv + texelSize * vec2( 0.5, 0.5));\r\n mediump vec4 K = texture2D(tex, uv + texelSize * vec2(-1.0, 1.0));\r\n mediump vec4 L = texture2D(tex, uv + texelSize * vec2( 0.0, 1.0));\r\n mediump vec4 M = texture2D(tex, uv + texelSize * vec2( 1.0, 1.0));\r\n\r\n\tmediump vec2 scale= vec2(0.5, 0.125);\r\n mediump vec2 div = (1.0 / 4.0) * scale;\r\n\r\n mediump vec4 o = (D + E + I + J) * div.x;\r\n o += (A + B + G + F) * div.y;\r\n o += (B + C + H + G) * div.y;\r\n o += (F + G + L + K) * div.y;\r\n o += (G + H + M + L) * div.y;\r\n\r\n return o;\r\n}\r\n\r\n// Standard box filtering\r\nmediump vec4 downsampleBox4Tap(sampler2D tex, vec2 uv, vec2 texelSize)\r\n{\r\n vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0);\r\n\r\n mediump vec4 s = texture2D(tex, uv + d.xy);\r\n s += texture2D(tex, uv + d.zy);\r\n s += texture2D(tex, uv + d.xw);\r\n s += texture2D(tex, uv + d.zw);\r\n\r\n return s * (1.0 / 4.0);\r\n}\r\n\r\n// 9-tap bilinear upsampler (tent filter)\r\n// . . . . . . .\r\n// . 1 . 2 . 1 .\r\n// . . . . . . .\r\n// . 2 . 4 . 2 .\r\n// . . . . . . .\r\n// . 1 . 2 . 1 .\r\n// . . . . . . .\r\nmediump vec4 upsampleTent(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\r\n{\r\n vec4 d = texelSize.xyxy * vec4(1.0, 1.0, -1.0, 0.0) * sampleScale;\r\n\r\n mediump vec4 s = texture2D(tex, uv - d.xy);\r\n s += texture2D(tex, uv - d.wy) * 2.0;\r\n s += texture2D(tex, uv - d.zy);\r\n\r\n s += texture2D(tex, uv + d.zw) * 2.0;\r\n s += texture2D(tex, uv) * 4.0;\r\n s += texture2D(tex,\tuv + d.xw) * 2.0;\r\n\r\n s += texture2D(tex, uv + d.zy);\r\n s += texture2D(tex, uv + d.wy) * 2.0;\r\n s += texture2D(tex, uv + d.xy);\r\n\r\n return s * (1.0 / 16.0);\r\n}\r\n\r\n// Standard box filtering\r\nmediump vec4 upsampleBox(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\r\n{\r\n vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0) * 0.5 * sampleScale;\r\n\r\n mediump vec4 s = texture2D(tex, uv + d.xy);\r\n s += texture2D(tex, uv + d.zy);\r\n s += texture2D(tex, uv + d.xw);\r\n s += texture2D(tex, uv + d.zw);\r\n\r\n return s * (1.0 / 4.0);\r\n}",ra="#define HALF_MAX 65504.0 // (2 - 2^-10) * 2^15\r\n\r\n#define FLT_EPSILON 1.192092896e-07 // Smallest positive number, such that 1.0 + FLT_EPSILON != 1.0\r\n\r\nmediump vec4 safeHDR(mediump vec4 c)\r\n{\r\n return min(c, HALF_MAX);\r\n}\r\n\r\nfloat max3(float a, float b, float c)\r\n{\r\n return max(max(a, b), c);\r\n}\r\n\r\nvec3 positivePow(vec3 base, vec3 power)\r\n{\r\n return pow(max(abs(base), vec3(FLT_EPSILON, FLT_EPSILON, FLT_EPSILON)), power);\r\n}",ia='#ifndef GRAPHICS_API_GLES3\r\n\t#define NO_NATIVE_SHADOWMAP\r\n#endif\r\n\r\n#ifdef NO_NATIVE_SHADOWMAP\r\n\t#define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2D textureName\r\n\t#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName,coord3.xy).r 3)// out of shadow range cascadeIndex is 4.\r\n\t\t\t\treturn vec4(0.0);\r\n\t\t\t\r\n\t\t\t#ifdef GRAPHICS_API_GLES3\r\n\t\t\t\treturn u_ShadowMatrices[cascadeIndex] * positionWS;\r\n\t\t\t#else\r\n\t\t\t\tmat4 shadowMat;\r\n\t\t\t\tif(cascadeIndex == 0)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[0];\r\n\t\t\t\telse if(cascadeIndex == 1)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[1];\r\n\t\t\t\telse if(cascadeIndex == 2)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[2];\r\n\t\t\t\telse\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[3];\r\n\t\t\t\treturn shadowMat * positionWS;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\treturn u_ShadowMatrices[0] * positionWS;\r\n\t\t#endif\r\n\t}\r\n\r\n\tfloat sampleShdowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize)\r\n\t{\r\n\t\tfloat attenuation;\r\n\t\tvec4 attenuation4;\r\n\t\tvec2 offset=shadowMapSize.xy/2.0;\r\n\t\tvec3 shadowCoord0=shadowCoord + vec3(-offset,0.0);\r\n\t\tvec3 shadowCoord1=shadowCoord + vec3(offset.x,-offset.y,0.0);\r\n\t\tvec3 shadowCoord2=shadowCoord + vec3(-offset.x,offset.y,0.0);\r\n\t\tvec3 shadowCoord3=shadowCoord + vec3(offset,0.0);\r\n\t\tattenuation4.x = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord0);\r\n\t\tattenuation4.y = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord1);\r\n\t\tattenuation4.z = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord2);\r\n\t\tattenuation4.w = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord3);\r\n\t\tattenuation = dot(attenuation4, vec4(0.25));\r\n\t\treturn attenuation;\r\n\t}\r\n\r\n\tfloat sampleShdowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize)\r\n\t{\r\n\t\tfloat attenuation;\r\n\t\tfloat fetchesWeights[9];\r\n\t\tvec2 fetchesUV[9];\r\n\t\tsampleShadowComputeSamplesTent5x5(shadowmapSize, shadowCoord.xy, fetchesWeights, fetchesUV);\r\n\t\tattenuation = fetchesWeights[0] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[0].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[1] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[1].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[2] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[2].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[3] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[3].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[4] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[4].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[5] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[5].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[6] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[6].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[7] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[7].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[8] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[8].xy, shadowCoord.z));\r\n\t\treturn attenuation;\r\n\t}\r\n\r\n\tfloat sampleShadowmap(vec4 shadowCoord)\r\n\t{\r\n\t\tshadowCoord.xyz /= shadowCoord.w;\r\n\t\tfloat attenuation = 1.0;\r\n\t\tif(shadowCoord.z > 0.0 && shadowCoord.z < 1.0)\r\n\t\t{\r\n\t\t\t#if defined(SHADOW_SOFT_SHADOW_HIGH)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered9(u_ShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#elif defined(SHADOW_SOFT_SHADOW_LOW)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered4(u_ShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#else\r\n\t\t\t\tattenuation = SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,shadowCoord.xyz);\r\n\t\t\t#endif\r\n\t\t\tattenuation = mix(1.0,attenuation,u_ShadowParams.x);//shadowParams.x:shadow strength\r\n\t\t}\r\n\t\treturn attenuation;\r\n\t}\r\n#endif\r\n\r\nvec3 applyShadowBias(vec3 positionWS, vec3 normalWS, vec3 lightDirection)\r\n{\r\n float invNdotL = 1.0 - clamp(dot(-lightDirection, normalWS),0.0,1.0);\r\n float scale = invNdotL * u_ShadowBias.y;\r\n\r\n // normal bias is negative since we want to apply an inset normal offset\r\n positionWS += -lightDirection * u_ShadowBias.xxx;\r\n positionWS += normalWS * vec3(scale);\r\n return positionWS;\r\n}\r\n',aa='#include "Lighting.glsl";\r\n#include "Shadow.glsl"\r\n\r\nattribute vec4 a_Position;\r\nattribute vec3 a_Normal;\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_WorldMat;\r\n#else\r\n\tuniform mat4 u_WorldMat;\r\n#endif\r\n\r\nuniform mat4 u_ViewProjection;\r\n\r\nuniform vec3 u_ShadowLightDirection;\r\n\r\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))||(defined(LIGHTMAP)&&defined(UV))\r\n\tattribute vec2 a_Texcoord0;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\nvec4 shadowCasterVertex()\r\n{\r\n\tmat4 worldMat;\r\n\t#ifdef GPU_INSTANCE\r\n\t\tworldMat = a_WorldMat;\r\n\t#else\r\n\t\tworldMat = u_WorldMat;\r\n\t#endif\r\n\t\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tworldMat = worldMat * skinTransform;\r\n\t#endif\r\n\r\n\tvec4 positionWS = worldMat * a_Position;\r\n\tvec3 normalWS = normalize(a_Normal*INVERSE_MAT(mat3(worldMat)));//if no normalize will cause precision problem\r\n\r\n\tpositionWS.xyz = applyShadowBias(positionWS.xyz,normalWS,u_ShadowLightDirection);\r\n\r\n\tvec4 positionCS = u_ViewProjection * positionWS;\r\n\tpositionCS.z = max(positionCS.z, 0.0);//min ndc z is 0.0\r\n\r\n\t// //TODO没考虑UV动画呢\r\n\t// #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\r\n\t// \tv_Texcoord0=a_Texcoord0;\r\n\t// #endif\r\n return positionCS;\r\n}\r\n',na="// #ifdef ALPHATEST\r\n// \tuniform float u_AlphaTestValue;\r\n// #endif\r\n\r\n// #ifdef DIFFUSEMAP\r\n// \tuniform sampler2D u_DiffuseTexture;\r\n// #endif\r\n\r\n// #if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\r\n// \tvarying vec2 v_Texcoord0;\r\n// #endif\r\n\r\nvec4 shadowCasterFragment()\r\n{\r\n return vec4(0.0);\r\n // #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\r\n\t// \tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\r\n\t// \tif( alpha < u_AlphaTestValue )\r\n\t// \t{\r\n\t// \t\tdiscard;\r\n\t// \t}\r\n\t// #endif\r\n}\r\n",sa="#ifdef GL_FRAGMENT_PRECISION_HIGH\r\nprecision highp float;\r\n#else\r\nprecision mediump float;\r\n#endif\r\n\r\nvarying vec3 v_Texcoord;\r\n\r\nuniform samplerCube u_CubeTexture;\r\nuniform float u_Exposure;\r\nuniform vec4 u_TintColor;\r\n\r\n\r\nvoid main()\r\n{\t\r\n\tvec3 color=textureCube(u_CubeTexture, v_Texcoord).rgb*u_TintColor.rgb*u_Exposure*2.0;\r\n\tgl_FragColor=vec4(color,1.0);\r\n}\r\n\r\n",oa='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nuniform mat4 u_ViewProjection;\r\nuniform float u_Rotation;\r\nvarying vec3 v_Texcoord;\r\n\r\n\r\nvec4 rotateAroundYInDegrees (vec4 vertex, float degrees)\r\n{\r\n\tfloat angle = degrees * 3.141593 / 180.0;\r\n\tfloat sina=sin(angle);\r\n\tfloat cosa=cos(angle);\r\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\r\n\treturn vec4(m*vertex.xz, vertex.yw).xzyw;\r\n}\r\n\t\t\r\nvoid main()\r\n{\r\n\tvec4 position=rotateAroundYInDegrees(a_Position,u_Rotation);\r\n\tgl_Position = u_ViewProjection*position;\r\n\tv_Texcoord=vec3(-a_Position.x,a_Position.yz);//转换坐标系\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n',la='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Lighting.glsl";\r\n\r\nconst float MIE_G = -0.990;\r\nconst float MIE_G2 = 0.9801;\r\nconst float SKY_GROUND_THRESHOLD = 0.02;\r\n\r\nuniform float u_SunSize;\r\nuniform float u_SunSizeConvergence;\r\nuniform DirectionLight u_SunLight;\r\n\r\n\r\nvarying vec3 v_GroundColor;\r\nvarying vec3 v_SkyColor;\r\n\r\n\r\n#ifdef SUN_HIGH_QUALITY\r\n\tvarying vec3 v_Vertex;\r\n#elif defined(SUN_SIMPLE)\r\n\tvarying vec3 v_RayDir;\r\n#else\r\n\tvarying float v_SkyGroundFactor;\r\n#endif\r\n\r\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\r\n\tvarying vec3 v_SunColor;\r\n#endif\r\n\r\n// Calculates the Mie phase function\r\nfloat getMiePhase(float eyeCos, float eyeCos2) {\r\n\tfloat temp = 1.0 + MIE_G2 - 2.0 * MIE_G * eyeCos;\r\n\ttemp = pow(temp, pow(u_SunSize,0.65) * 10.0);\r\n\ttemp = max(temp,1.0e-4); // prevent division by zero, esp. in half precision\r\n\ttemp = 1.5 * ((1.0 - MIE_G2) / (2.0 + MIE_G2)) * (1.0 + eyeCos2) / temp;\r\n\treturn temp;\r\n}\r\n\r\n// Calculates the sun shape\r\nfloat calcSunAttenuation(vec3 lightPos, vec3 ray) {\r\n\t#ifdef SUN_HIGH_QUALITY\r\n\t\tfloat focusedEyeCos = pow(clamp(dot(lightPos, ray),0.0,1.0), u_SunSizeConvergence);\r\n\t\treturn getMiePhase(-focusedEyeCos, focusedEyeCos * focusedEyeCos);\r\n\t#else //SUN_SIMPLE\r\n\t\tvec3 delta = lightPos - ray;\r\n\t\tfloat dist = length(delta);\r\n\t\tfloat spot = 1.0 - smoothstep(0.0, u_SunSize, dist);\r\n\t\treturn spot * spot;\r\n\t#endif\r\n}\r\n\r\nvoid main() {\r\n\t// if y > 1 [eyeRay.y < -SKY_GROUND_THRESHOLD] - ground\r\n\t// if y >= 0 and < 1 [eyeRay.y <= 0 and > -SKY_GROUND_THRESHOLD] - horizon\r\n\t// if y < 0 [eyeRay.y > 0] - sky\r\n\tvec3 col = vec3(0.0, 0.0, 0.0);\r\n\r\n\t#ifdef SUN_HIGH_QUALITY\r\n\t\tvec3 ray = normalize(v_Vertex);\r\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tvec3 ray = v_RayDir;\r\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\t\r\n\t#else\r\n\t\tfloat y = v_SkyGroundFactor;\r\n\t#endif\r\n\r\n\t// if we did precalculate color in vprog: just do lerp between them\r\n\tcol = mix(v_SkyColor, v_GroundColor, clamp(y,0.0,1.0));\r\n\r\n\t#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\r\n\t\tif (y < 0.0)\r\n\t\t\tcol += v_SunColor * calcSunAttenuation(-u_SunLight.direction, -ray);\r\n\t#endif\r\n\r\n\tcol = sqrt(col);//linear space convert to gamma space\r\n\tgl_FragColor=vec4(col,1.0);\r\n}\r\n\r\n',_a="#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include \"Lighting.glsl\";\r\n\r\n#define OUTER_RADIUS 1.025\r\n#define RAYLEIGH (mix(0.0, 0.0025, pow(u_AtmosphereThickness,2.5)))// Rayleigh constant Rayleigh为夜空光和极光亮度单位\r\n#define MIE 0.0010 // Mie constant 米氏散射\r\n#define SUN_BRIGHTNESS 20.0 // Sun brightness\r\n#define MAX_SCATTER 50.0 // Maximum scattering value, to prevent math overflows on Adrenos\r\n\r\nconst float SKY_GROUND_THRESHOLD = 0.02;\r\nconst float outerRadius = OUTER_RADIUS;\r\nconst float outerRadius2 = OUTER_RADIUS*OUTER_RADIUS;\r\nconst float innerRadius = 1.0;\r\nconst float innerRadius2 = 1.0;\r\nconst float cameraHeight = 0.0001;\r\n\r\nconst float HDSundiskIntensityFactor = 15.0;\r\nconst float simpleSundiskIntensityFactor = 27.0;\r\n\r\nconst float sunScale = 400.0 * SUN_BRIGHTNESS;\r\nconst float kmESun = MIE * SUN_BRIGHTNESS;\r\nconst float km4PI = MIE * 4.0 * 3.14159265;\r\nconst float scale = 1.0 / (OUTER_RADIUS - 1.0);\r\nconst float scaleDepth = 0.25;\r\nconst float scaleOverScaleDepth = (1.0 / (OUTER_RADIUS - 1.0)) / 0.25;\r\nconst float samples = 2.0; // THIS IS UNROLLED MANUALLY, DON'T TOUCH\r\n\r\n// RGB wavelengths .35 (.62=158), .43 (.68=174), .525 (.75=190)\r\nconst vec3 c_DefaultScatteringWavelength = vec3(0.65, 0.57, 0.475);//默认散射波长\r\nconst vec3 c_VariableRangeForScatteringWavelength = vec3(0.15, 0.15, 0.15);//散射播放的可变范围\r\n\r\nattribute vec4 a_Position;\r\n\r\nuniform mat4 u_ViewProjection;\r\nuniform vec3 u_SkyTint;\r\nuniform vec3 u_GroundTint;\r\nuniform float u_Exposure;\r\nuniform float u_AtmosphereThickness;\r\nuniform DirectionLight u_SunLight;\r\n\r\nvarying vec3 v_GroundColor;\r\nvarying vec3 v_SkyColor;\r\n\r\n#ifdef SUN_HIGH_QUALITY\r\n\tvarying vec3 v_Vertex;\r\n#elif defined(SUN_SIMPLE)\r\n\tvarying vec3 v_RayDir;\r\n#else\r\n\tvarying float v_SkyGroundFactor;\r\n#endif\r\n\r\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\r\n\tvarying vec3 v_SunColor;\r\n#endif\r\n\r\n// Calculates the Rayleigh phase function\r\nfloat getRayleighPhase(vec3 light, vec3 ray) \r\n{\r\n\tfloat eyeCos = dot(light, ray);\r\n\treturn 0.75 + 0.75*eyeCos*eyeCos;\r\n}\r\n\r\nfloat scaleAngle(float inCos)\r\n{\r\n\tfloat x = 1.0 - inCos;\r\n\treturn 0.25 * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));\r\n}\r\n\r\n\r\nvoid main () {\r\n\tgl_Position = u_ViewProjection*a_Position;\r\n\r\n\tvec3 skyTintInGammaSpace = u_SkyTint;//支持非GAMMA空间后要调整\r\n\tvec3 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\r\n\tvec3 invWavelength = 1.0 / pow(scatteringWavelength, vec3(4.0));\r\n\r\n\tfloat krESun = RAYLEIGH * SUN_BRIGHTNESS;\r\n\tfloat kr4PI = RAYLEIGH * 4.0 * 3.14159265;\r\n\r\n\tvec3 cameraPos = vec3(0.0,innerRadius + cameraHeight,0.0); // The camera's current position\r\n\r\n\t// Get the ray from the camera to the vertex and its length (which is the far point of the ray passing through the atmosphere)\r\n\tvec3 eyeRay = normalize(a_Position.xyz);\r\n\r\n\tfloat far = 0.0;\r\n\tvec3 cIn, cOut;\r\n\tif (eyeRay.y >= 0.0) {// Sky\r\n\t\t// Calculate the length of the \"atmosphere\"\r\n\t\tfar = sqrt(outerRadius2 + innerRadius2 * eyeRay.y * eyeRay.y - innerRadius2) - innerRadius * eyeRay.y;\r\n\r\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\r\n\t\tfloat height = innerRadius + cameraHeight;\r\n\t\tfloat depth = exp(scaleOverScaleDepth * -cameraHeight);\r\n\t\tfloat startAngle = dot(eyeRay, cameraPos) / height;\r\n\t\tfloat startOffset = depth*scaleAngle(startAngle);\r\n\r\n\t\t// Initialize the scattering loop variables\r\n\t\tfloat sampleLength = far / samples;\r\n\t\tfloat scaledLength = sampleLength * scale;\r\n\t\tvec3 sampleRay = eyeRay * sampleLength;\r\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\r\n\r\n\t\tvec3 frontColor = vec3(0.0);\r\n\t\t//unrolling this manually to avoid some platform for loop slow\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat lightAngle = dot(-u_SunLight.direction, samplePoint) / height;\r\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\r\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\r\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat lightAngle = dot(-u_SunLight.direction, samplePoint) / height;\r\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\r\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\r\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\r\n\t\t// Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\r\n\t\tcIn = frontColor * (invWavelength * krESun);\r\n\t\tcOut = frontColor * kmESun;\r\n\t} else {// Ground\r\n\t\tfar = (-cameraHeight) / (min(-0.001, eyeRay.y));\r\n\t\tvec3 pos = cameraPos + far * eyeRay;\r\n\r\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\r\n\t\tfloat depth = exp((-cameraHeight) * (1.0/scaleDepth));\r\n\t\tfloat cameraAngle = dot(-eyeRay, pos);\r\n\t\tfloat lightAngle = dot(-u_SunLight.direction, pos);\r\n\t\tfloat cameraScale = scaleAngle(cameraAngle);\r\n\t\tfloat lightScale = scaleAngle(lightAngle);\r\n\t\tfloat cameraOffset = depth*cameraScale;\r\n\t\tfloat temp = lightScale + cameraScale;\r\n\r\n\t\t// Initialize the scattering loop variables\r\n\t\tfloat sampleLength = far / samples;\r\n\t\tfloat scaledLength = sampleLength * scale;\r\n\t\tvec3 sampleRay = eyeRay * sampleLength;\r\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\r\n\r\n\t\t// Now loop through the sample rays\r\n\t\tvec3 frontColor = vec3(0.0, 0.0, 0.0);\r\n\t\tvec3 attenuate;\r\n\r\n\t\t// Loop removed because we kept hitting SM2.0 temp variable limits. Doesn't affect the image too much.\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat scatter = depth*temp - cameraOffset;\r\n\t\t\tattenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\r\n\t\tcIn = frontColor * (invWavelength * krESun + kmESun);\r\n\t\tcOut = clamp(attenuate, 0.0, 1.0);\r\n\t}\r\n\r\n\t#ifdef SUN_HIGH_QUALITY\r\n\t\tv_Vertex = -a_Position.xyz;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tv_RayDir = -eyeRay;\r\n\t#else\r\n\t\tv_SkyGroundFactor = -eyeRay.y / SKY_GROUND_THRESHOLD;\r\n\t#endif\r\n\r\n\t// if we want to calculate color in vprog:\r\n\t// 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)\r\n\tv_GroundColor = u_Exposure * (cIn + u_GroundTint*u_GroundTint * cOut);//u_GroundColor*u_GroundColor is gamma space convert to linear space\r\n\tv_SkyColor = u_Exposure * (cIn * getRayleighPhase(-u_SunLight.direction, -eyeRay));\r\n\r\n\t\r\n\t// The sun should have a stable intensity in its course in the sky. Moreover it should match the highlight of a purely specular material.\r\n\t// This matching was done using the Unity3D standard shader BRDF1 on the 5/31/2017\r\n\t// Finally we want the sun to be always bright even in LDR thus the normalization of the lightColor for low intensity.\r\n\tfloat lightColorIntensity = clamp(length(u_SunLight.color), 0.25, 1.0);\r\n\r\n\t#ifdef SUN_HIGH_QUALITY \r\n\t\tv_SunColor = HDSundiskIntensityFactor * clamp(cOut,0.0,1.0) * u_SunLight.color / lightColorIntensity;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tv_SunColor = simpleSundiskIntensityFactor * clamp(cOut * sunScale,0.0,1.0) * u_SunLight.color / lightColorIntensity;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n",ha="#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\nuniform sampler2D u_MainTexture;\r\nuniform vec4 u_MainColor;\r\n\r\nvarying vec2 v_Texcoord0;\r\nvarying vec4 v_Color;\r\n\r\nvoid main()\r\n{\r\n\tvec4 color = 2.0 * u_MainColor * v_Color;\r\n\t#ifdef MAINTEXTURE\r\n\t\tvec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\r\n\t\tcolor *= mainTextureColor;\r\n\t#endif\r\n\tgl_FragColor = color;\r\n}\r\n\r\n ",ca='#include "Lighting.glsl";\r\n\r\nattribute vec3 a_Position;\r\nattribute vec3 a_OffsetVector;\r\nattribute vec4 a_Color;\r\nattribute float a_Texcoord0X;\r\nattribute float a_Texcoord0Y;\r\nattribute float a_BirthTime;\r\n\r\nuniform mat4 u_View;\r\nuniform mat4 u_Projection;\r\n\r\nuniform vec4 u_TilingOffset;\r\n\r\nuniform float u_CurTime;\r\nuniform float u_LifeTime;\r\nuniform vec4 u_WidthCurve[10];\r\nuniform int u_WidthCurveKeyLength;\r\n\r\nvarying vec2 v_Texcoord0;\r\nvarying vec4 v_Color;\r\n\r\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\r\n{\r\n\tfloat t2 = t * t;\r\n\tfloat t3 = t2 * t;\r\n\tfloat a = 2.0 * t3 - 3.0 * t2 + 1.0;\r\n\tfloat b = t3 - 2.0 * t2 + t;\r\n\tfloat c = t3 - t2;\r\n\tfloat d = -2.0 * t3 + 3.0 * t2;\r\n\treturn a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\r\n}\r\n\r\nfloat getCurWidth(in float normalizeTime)\r\n{\r\n\tfloat width;\r\n\tif(normalizeTime == 0.0){\r\n\t\twidth=u_WidthCurve[0].w;\r\n\t}\r\n\telse if(normalizeTime >= 1.0){\r\n\t\twidth=u_WidthCurve[u_WidthCurveKeyLength - 1].w;\r\n\t}\r\n\telse{\r\n\t\tfor(int i = 0; i < 10; i ++ )\r\n\t\t{\r\n\t\t\tif(normalizeTime == u_WidthCurve[i].x){\r\n\t\t\t\twidth=u_WidthCurve[i].w;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvec4 lastFrame = u_WidthCurve[i];\r\n\t\t\tvec4 nextFrame = u_WidthCurve[i + 1];\r\n\t\t\tif(normalizeTime > lastFrame.x && normalizeTime < nextFrame.x)\r\n\t\t\t{\r\n\t\t\t\tfloat duration = nextFrame.x - lastFrame.x;\r\n\t\t\t\tfloat t = (normalizeTime - lastFrame.x) / duration;\r\n\t\t\t\tfloat outTangent = lastFrame.z;\r\n\t\t\t\tfloat inTangent = nextFrame.y;\r\n\t\t\t\tfloat value1 = lastFrame.w;\r\n\t\t\t\tfloat value2 = nextFrame.w;\r\n\t\t\t\twidth=hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn width;\r\n}\t\r\n\r\nvoid main()\r\n{\r\n\tfloat normalizeTime = (u_CurTime - a_BirthTime) / u_LifeTime;\r\n\t\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, 1.0 - a_Texcoord0Y) * u_TilingOffset.xy + u_TilingOffset.zw;\r\n\t#else\r\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\r\n\t#endif\r\n\t\r\n\tv_Color = a_Color;\r\n\t\r\n\tgl_Position = u_Projection * u_View * vec4(a_Position + a_OffsetVector * getCurWidth(normalizeTime),1.0);\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n',da="#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\tvarying vec4 v_Color;\r\n#endif\r\n\r\n#ifdef ALBEDOTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\r\n\r\n#ifdef ALPHATEST\r\n\tuniform float u_AlphaTestValue;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\t#ifdef ADDTIVEFOG\r\n\t#else\r\n\t\tuniform vec3 u_FogColor;\r\n\t#endif\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 color = u_AlbedoColor;\r\n\t#ifdef ALBEDOTEXTURE\r\n\t\tcolor *= texture2D(u_AlbedoTexture, v_Texcoord0);\r\n\t#endif\r\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\t\tcolor *= v_Color;\r\n\t#endif\r\n\t\r\n\t#ifdef ALPHATEST\r\n\t\tif(color.a < u_AlphaTestValue)\r\n\t\t\tdiscard;\r\n\t#endif\r\n\t\r\n\tgl_FragColor = color;\r\n\t\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\r\n\t\t#ifdef ADDTIVEFOG\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.0), lerpFact);\r\n\t\t#else\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\r\n\t\t#endif\r\n\t#endif\r\n\t\r\n}\r\n\r\n",ua='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\n\r\nattribute vec2 a_Texcoord0;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n#endif\r\n\r\nattribute vec4 a_Color;\r\nvarying vec4 v_Color;\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nvoid main() {\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t#else\r\n\t\tv_Texcoord0=a_Texcoord0;\r\n\t#endif\r\n\r\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\t\tv_Color = a_Color;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',ma='#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#ifdef MAINTEXTURE\r\n\tuniform sampler2D u_MainTexture;\r\n#endif\r\n\r\n#ifdef NORMALTEXTURE\r\n\tuniform sampler2D u_NormalTexture;\r\n#endif\r\n\r\nuniform vec4 u_HorizonColor;\r\n\r\nvarying vec3 v_Normal;\r\nvarying vec3 v_Tangent;\r\nvarying vec3 v_Binormal;\r\nvarying vec3 v_ViewDir;\r\nvarying vec2 v_Texcoord0;\r\nvarying vec2 v_Texcoord1;\r\n\r\n\r\n#include "Lighting.glsl"\r\n\r\n\r\n\r\nvec3 NormalSampleToWorldSpace(vec4 normalMapSample) {\r\n\tvec3 normalT;\r\n\tnormalT.x = 2.0 * normalMapSample.x - 1.0;\r\n\tnormalT.y = 1.0 - 2.0 * normalMapSample.y;\r\n\tnormalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\r\n\r\n\tvec3 bumpedNormal = normalize(normalT);\r\n\r\n\treturn bumpedNormal;\r\n}\r\n\r\n\r\nvoid main()\r\n{\r\n\tvec4 bumpColor1 = texture2D(u_NormalTexture, v_Texcoord0);\r\n\tvec4 bumpColor2 = texture2D(u_NormalTexture, v_Texcoord1);\r\n\r\n\tvec3 normal1 = NormalSampleToWorldSpace(bumpColor1);\r\n\tvec3 normal2 = NormalSampleToWorldSpace(bumpColor2);\r\n\t\r\n\tvec3 normal = normalize((normal1 + normal2) * 0.5);\r\n\tvec3 viewDir = normalize(v_ViewDir);\r\n\tfloat fresnel = dot(viewDir, normal);\r\n\t\r\n\tvec4 waterColor = texture2D(u_MainTexture, vec2(fresnel, fresnel));\r\n\t\r\n\tvec4 color;\r\n\tcolor.rgb = mix(waterColor.rgb, u_HorizonColor.rgb, vec3(waterColor.a));\r\n\tcolor.a = u_HorizonColor.a;\r\n\t\r\n\tgl_FragColor = color;\r\n}\r\n\r\n\r\n',fa='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec3 a_Normal;\r\nattribute vec4 a_Tangent0;\r\n\r\nuniform mat4 u_MvpMatrix;\r\nuniform mat4 u_WorldMat;\r\nuniform vec3 u_CameraPos;\r\nuniform float u_WaveScale;\r\nuniform vec4 u_WaveSpeed;\r\nuniform float u_Time;\r\n\r\nvarying vec3 v_Normal;\r\nvarying vec3 v_Tangent;\r\nvarying vec3 v_Binormal;\r\nvarying vec3 v_ViewDir;\r\nvarying vec2 v_Texcoord0;\r\nvarying vec2 v_Texcoord1;\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionWorld = u_WorldMat * a_Position;\r\n\tvec4 position = u_MvpMatrix * a_Position;\r\n\t\r\n\tvec4 temp = vec4(positionWorld.x, positionWorld.z, positionWorld.x, positionWorld.z) * u_WaveScale + u_WaveSpeed * u_WaveScale * u_Time;\r\n\t\r\n\tv_Texcoord0 = temp.xy * vec2(0.4, 0.45);\r\n\tv_Texcoord1 = temp.wz;\r\n\t\r\n\tmat3 worldMat = mat3(u_WorldMat);\r\n\tv_Normal = worldMat * a_Normal;\r\n\tv_Tangent = worldMat * a_Tangent0.xyz;\r\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\r\n\t\r\n\tv_ViewDir = u_CameraPos - positionWorld.xyz;\r\n\tgl_Position = position;\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}';class Ea{constructor(){}static __init__(){H.SHADERDEFINE_LEGACYSINGALLIGHTING=H.getDefineByName("LEGACYSINGLELIGHTING"),H.SHADERDEFINE_GRAPHICS_API_GLES2=H.getDefineByName("GRAPHICS_API_GLES2"),H.SHADERDEFINE_GRAPHICS_API_GLES3=H.getDefineByName("GRAPHICS_API_GLES3"),H.addInclude("Lighting.glsl",yi),H.addInclude("ShadowSampleTent.glsl",Oi),H.addInclude("GlobalIllumination.glsl",Mi),H.addInclude("Shadow.glsl",ia),H.addInclude("ShadowCasterVS.glsl",aa),H.addInclude("ShadowCasterFS.glsl",na),H.addInclude("Colors.glsl",Ji),H.addInclude("Sampling.glsl",ta),H.addInclude("StdLib.glsl",ra),H.addInclude("PBRVSInput.glsl",Hi),H.addInclude("PBRFSInput.glsl",Wi),H.addInclude("LayaPBRBRDF.glsl",Gi),H.addInclude("PBRCore.glsl",zi),H.addInclude("PBRVertex.glsl",ki);var e={a_Position:Xe.MESH_POSITION0,a_Color:Xe.MESH_COLOR0,a_Normal:Xe.MESH_NORMAL0,a_Texcoord0:Xe.MESH_TEXTURECOORDINATE0,a_Texcoord1:Xe.MESH_TEXTURECOORDINATE1,a_BoneWeights:Xe.MESH_BLENDWEIGHT0,a_BoneIndices:Xe.MESH_BLENDINDICES0,a_Tangent0:Xe.MESH_TANGENT0,a_MvpMatrix:Xe.MESH_MVPMATRIX_ROW0,a_WorldMat:Xe.MESH_WORLDMATRIX_ROW0},t={u_Bones:H.PERIOD_CUSTOM,u_DiffuseTexture:H.PERIOD_MATERIAL,u_SpecularTexture:H.PERIOD_MATERIAL,u_NormalTexture:H.PERIOD_MATERIAL,u_AlphaTestValue:H.PERIOD_MATERIAL,u_DiffuseColor:H.PERIOD_MATERIAL,u_MaterialSpecular:H.PERIOD_MATERIAL,u_Shininess:H.PERIOD_MATERIAL,u_TilingOffset:H.PERIOD_MATERIAL,u_WorldMat:H.PERIOD_SPRITE,u_MvpMatrix:H.PERIOD_SPRITE,u_LightmapScaleOffset:H.PERIOD_SPRITE,u_LightMap:H.PERIOD_SPRITE,u_LightMapDirection:H.PERIOD_SPRITE,u_CameraPos:H.PERIOD_CAMERA,u_Viewport:H.PERIOD_CAMERA,u_ProjectionParams:H.PERIOD_CAMERA,u_View:H.PERIOD_CAMERA,u_ViewProjection:H.PERIOD_CAMERA,u_ReflectTexture:H.PERIOD_SCENE,u_ReflectIntensity:H.PERIOD_SCENE,u_FogStart:H.PERIOD_SCENE,u_FogRange:H.PERIOD_SCENE,u_FogColor:H.PERIOD_SCENE,u_DirationLightCount:H.PERIOD_SCENE,u_LightBuffer:H.PERIOD_SCENE,u_LightClusterBuffer:H.PERIOD_SCENE,u_AmbientColor:H.PERIOD_SCENE,u_ShadowBias:H.PERIOD_SCENE,u_ShadowLightDirection:H.PERIOD_SCENE,u_ShadowMap:H.PERIOD_SCENE,u_ShadowParams:H.PERIOD_SCENE,u_ShadowSplitSpheres:H.PERIOD_SCENE,u_ShadowMatrices:H.PERIOD_SCENE,u_ShadowMapSize:H.PERIOD_SCENE,u_AmbientSHAr:H.PERIOD_SCENE,u_AmbientSHAg:H.PERIOD_SCENE,u_AmbientSHAb:H.PERIOD_SCENE,u_AmbientSHBr:H.PERIOD_SCENE,u_AmbientSHBg:H.PERIOD_SCENE,u_AmbientSHBb:H.PERIOD_SCENE,u_AmbientSHC:H.PERIOD_SCENE,"u_DirectionLight.color":H.PERIOD_SCENE,"u_DirectionLight.direction":H.PERIOD_SCENE,"u_PointLight.position":H.PERIOD_SCENE,"u_PointLight.range":H.PERIOD_SCENE,"u_PointLight.color":H.PERIOD_SCENE,"u_SpotLight.position":H.PERIOD_SCENE,"u_SpotLight.direction":H.PERIOD_SCENE,"u_SpotLight.range":H.PERIOD_SCENE,"u_SpotLight.spot":H.PERIOD_SCENE,"u_SpotLight.color":H.PERIOD_SCENE},r={s_Cull:H.RENDER_STATE_CULL,s_Blend:H.RENDER_STATE_BLEND,s_BlendSrc:H.RENDER_STATE_BLEND_SRC,s_BlendDst:H.RENDER_STATE_BLEND_DST,s_DepthTest:H.RENDER_STATE_DEPTH_TEST,s_DepthWrite:H.RENDER_STATE_DEPTH_WRITE},i=H.add("BLINNPHONG",null,null,!0),a=new ir(e,t);i.addSubShader(a),a.addShaderPass(wi,Pi,r,"Forward");a.addShaderPass(Bi,Vi,r,"ShadowCaster");e={a_Position:Xe.MESH_POSITION0,a_Color:Xe.MESH_COLOR0},t={u_MvpMatrix:H.PERIOD_SPRITE,u_Color:H.PERIOD_MATERIAL},r={s_Cull:H.RENDER_STATE_CULL,s_Blend:H.RENDER_STATE_BLEND,s_BlendSrc:H.RENDER_STATE_BLEND_SRC,s_BlendDst:H.RENDER_STATE_BLEND_DST,s_DepthTest:H.RENDER_STATE_DEPTH_TEST,s_DepthWrite:H.RENDER_STATE_DEPTH_WRITE},i=H.add("LineShader"),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(bi,Ni,r),e={a_Position:Xe.MESH_POSITION0,a_Color:Xe.MESH_COLOR0,a_Texcoord0:Xe.MESH_TEXTURECOORDINATE0,a_BoneWeights:Xe.MESH_BLENDWEIGHT0,a_BoneIndices:Xe.MESH_BLENDINDICES0,a_MvpMatrix:Xe.MESH_MVPMATRIX_ROW0},t={u_Bones:H.PERIOD_CUSTOM,u_AlbedoTexture:H.PERIOD_MATERIAL,u_AlbedoColor:H.PERIOD_MATERIAL,u_TilingOffset:H.PERIOD_MATERIAL,u_AlphaTestValue:H.PERIOD_MATERIAL,u_MvpMatrix:H.PERIOD_SPRITE,u_FogStart:H.PERIOD_SCENE,u_FogRange:H.PERIOD_SCENE,u_FogColor:H.PERIOD_SCENE},r={s_Cull:H.RENDER_STATE_CULL,s_Blend:H.RENDER_STATE_BLEND,s_BlendSrc:H.RENDER_STATE_BLEND_SRC,s_BlendDst:H.RENDER_STATE_BLEND_DST,s_DepthTest:H.RENDER_STATE_DEPTH_TEST,s_DepthWrite:H.RENDER_STATE_DEPTH_WRITE},i=H.add("Unlit",null,null,!0),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(ua,da,r),e={a_Position:Xe.MESH_POSITION0,a_Texcoord0:Xe.MESH_TEXTURECOORDINATE0,a_BoneWeights:Xe.MESH_BLENDWEIGHT0,a_BoneIndices:Xe.MESH_BLENDINDICES0,a_MvpMatrix:Xe.MESH_MVPMATRIX_ROW0},t={u_Bones:H.PERIOD_CUSTOM,u_AlbedoTexture:H.PERIOD_MATERIAL,u_AlbedoColor:H.PERIOD_MATERIAL,u_TilingOffset:H.PERIOD_MATERIAL,u_AlphaTestValue:H.PERIOD_MATERIAL,u_MvpMatrix:H.PERIOD_SPRITE,u_FogStart:H.PERIOD_SCENE,u_FogRange:H.PERIOD_SCENE,u_FogColor:H.PERIOD_SCENE},r={s_Cull:H.RENDER_STATE_CULL,s_Blend:H.RENDER_STATE_BLEND,s_BlendSrc:H.RENDER_STATE_BLEND_SRC,s_BlendDst:H.RENDER_STATE_BLEND_DST,s_DepthTest:H.RENDER_STATE_DEPTH_TEST,s_DepthWrite:H.RENDER_STATE_DEPTH_WRITE},i=H.add("Effect",null,null,!0),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(Li,Ai,r),e={a_CornerTextureCoordinate:Zr.PARTICLE_CORNERTEXTURECOORDINATE0,a_MeshPosition:Zr.PARTICLE_POSITION0,a_MeshColor:Zr.PARTICLE_COLOR0,a_MeshTextureCoordinate:Zr.PARTICLE_TEXTURECOORDINATE0,a_ShapePositionStartLifeTime:Zr.PARTICLE_SHAPEPOSITIONSTARTLIFETIME,a_DirectionTime:Zr.PARTICLE_DIRECTIONTIME,a_StartColor:Zr.PARTICLE_STARTCOLOR0,a_EndColor:Zr.PARTICLE_ENDCOLOR0,a_StartSize:Zr.PARTICLE_STARTSIZE,a_StartRotation0:Zr.PARTICLE_STARTROTATION,a_StartSpeed:Zr.PARTICLE_STARTSPEED,a_Random0:Zr.PARTICLE_RANDOM0,a_Random1:Zr.PARTICLE_RANDOM1,a_SimulationWorldPostion:Zr.PARTICLE_SIMULATIONWORLDPOSTION,a_SimulationWorldRotation:Zr.PARTICLE_SIMULATIONWORLDROTATION},t={u_Tintcolor:H.PERIOD_MATERIAL,u_TilingOffset:H.PERIOD_MATERIAL,u_texture:H.PERIOD_MATERIAL,u_WorldPosition:H.PERIOD_SPRITE,u_WorldRotation:H.PERIOD_SPRITE,u_PositionScale:H.PERIOD_SPRITE,u_SizeScale:H.PERIOD_SPRITE,u_ScalingMode:H.PERIOD_SPRITE,u_Gravity:H.PERIOD_SPRITE,u_ThreeDStartRotation:H.PERIOD_SPRITE,u_StretchedBillboardLengthScale:H.PERIOD_SPRITE,u_StretchedBillboardSpeedScale:H.PERIOD_SPRITE,u_SimulationSpace:H.PERIOD_SPRITE,u_CurrentTime:H.PERIOD_SPRITE,u_ColorOverLifeGradientAlphas:H.PERIOD_SPRITE,u_ColorOverLifeGradientColors:H.PERIOD_SPRITE,u_MaxColorOverLifeGradientAlphas:H.PERIOD_SPRITE,u_MaxColorOverLifeGradientColors:H.PERIOD_SPRITE,u_VOLVelocityConst:H.PERIOD_SPRITE,u_VOLVelocityGradientX:H.PERIOD_SPRITE,u_VOLVelocityGradientY:H.PERIOD_SPRITE,u_VOLVelocityGradientZ:H.PERIOD_SPRITE,u_VOLVelocityConstMax:H.PERIOD_SPRITE,u_VOLVelocityGradientMaxX:H.PERIOD_SPRITE,u_VOLVelocityGradientMaxY:H.PERIOD_SPRITE,u_VOLVelocityGradientMaxZ:H.PERIOD_SPRITE,u_VOLSpaceType:H.PERIOD_SPRITE,u_SOLSizeGradient:H.PERIOD_SPRITE,u_SOLSizeGradientX:H.PERIOD_SPRITE,u_SOLSizeGradientY:H.PERIOD_SPRITE,u_SOLSizeGradientZ:H.PERIOD_SPRITE,u_SOLSizeGradientMax:H.PERIOD_SPRITE,u_SOLSizeGradientMaxX:H.PERIOD_SPRITE,u_SOLSizeGradientMaxY:H.PERIOD_SPRITE,u_SOLSizeGradientMaxZ:H.PERIOD_SPRITE,u_ROLAngularVelocityConst:H.PERIOD_SPRITE,u_ROLAngularVelocityConstSeprarate:H.PERIOD_SPRITE,u_ROLAngularVelocityGradient:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientX:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientY:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientZ:H.PERIOD_SPRITE,u_ROLAngularVelocityConstMax:H.PERIOD_SPRITE,u_ROLAngularVelocityConstMaxSeprarate:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientMax:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxX:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxY:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxZ:H.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxW:H.PERIOD_SPRITE,u_TSACycles:H.PERIOD_SPRITE,u_TSASubUVLength:H.PERIOD_SPRITE,u_TSAGradientUVs:H.PERIOD_SPRITE,u_TSAMaxGradientUVs:H.PERIOD_SPRITE,u_CameraPos:H.PERIOD_CAMERA,u_CameraDirection:H.PERIOD_CAMERA,u_CameraUp:H.PERIOD_CAMERA,u_View:H.PERIOD_CAMERA,u_Projection:H.PERIOD_CAMERA,u_FogStart:H.PERIOD_SCENE,u_FogRange:H.PERIOD_SCENE,u_FogColor:H.PERIOD_SCENE},r={s_Cull:H.RENDER_STATE_CULL,s_Blend:H.RENDER_STATE_BLEND,s_BlendSrc:H.RENDER_STATE_BLEND_SRC,s_BlendDst:H.RENDER_STATE_BLEND_DST,s_DepthTest:H.RENDER_STATE_DEPTH_TEST,s_DepthWrite:H.RENDER_STATE_DEPTH_WRITE},i=H.add("PARTICLESHURIKEN"),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(Ui,Fi,r),e={a_Position:Xe.MESH_POSITION0},t={u_TintColor:H.PERIOD_MATERIAL,u_Exposure:H.PERIOD_MATERIAL,u_Rotation:H.PERIOD_MATERIAL,u_CubeTexture:H.PERIOD_MATERIAL,u_ViewProjection:H.PERIOD_CAMERA},i=H.add("SkyBox"),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(oa,sa),e={a_Position:Xe.MESH_POSITION0},t={u_SunSize:H.PERIOD_MATERIAL,u_SunSizeConvergence:H.PERIOD_MATERIAL,u_AtmosphereThickness:H.PERIOD_MATERIAL,u_SkyTint:H.PERIOD_MATERIAL,u_GroundTint:H.PERIOD_MATERIAL,u_Exposure:H.PERIOD_MATERIAL,u_ViewProjection:H.PERIOD_CAMERA,"u_SunLight.direction":H.PERIOD_SCENE,"u_SunLight.color":H.PERIOD_SCENE},i=H.add("SkyBoxProcedural"),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(_a,la),e={a_Position:Xe.MESH_POSITION0,a_Normal:Xe.MESH_NORMAL0,a_Texcoord0:Xe.MESH_TEXTURECOORDINATE0},t={u_MvpMatrix:H.PERIOD_SPRITE,u_WorldMat:H.PERIOD_SPRITE,u_CameraPos:H.PERIOD_CAMERA,u_Viewport:H.PERIOD_CAMERA,u_ProjectionParams:H.PERIOD_CAMERA,u_View:H.PERIOD_CAMERA,u_LightmapScaleOffset:H.PERIOD_SPRITE,u_LightMap:H.PERIOD_SPRITE,u_SplatAlphaTexture:H.PERIOD_MATERIAL,u_DiffuseTexture1:H.PERIOD_MATERIAL,u_DiffuseTexture2:H.PERIOD_MATERIAL,u_DiffuseTexture3:H.PERIOD_MATERIAL,u_DiffuseTexture4:H.PERIOD_MATERIAL,u_DiffuseTexture5:H.PERIOD_MATERIAL,u_DiffuseScaleOffset1:H.PERIOD_MATERIAL,u_DiffuseScaleOffset2:H.PERIOD_MATERIAL,u_DiffuseScaleOffset3:H.PERIOD_MATERIAL,u_DiffuseScaleOffset4:H.PERIOD_MATERIAL,u_DiffuseScaleOffset5:H.PERIOD_MATERIAL,u_FogStart:H.PERIOD_SCENE,u_FogRange:H.PERIOD_SCENE,u_FogColor:H.PERIOD_SCENE,u_DirationLightCount:H.PERIOD_SCENE,u_LightBuffer:H.PERIOD_SCENE,u_LightClusterBuffer:H.PERIOD_SCENE,u_AmbientColor:H.PERIOD_SCENE,u_ShadowMap:H.PERIOD_SCENE,u_shadowMap2:H.PERIOD_SCENE,u_shadowMap3:H.PERIOD_SCENE,u_ShadowSplitSpheres:H.PERIOD_SCENE,u_ShadowMatrices:H.PERIOD_SCENE,u_ShadowMapSize:H.PERIOD_SCENE,"u_DirectionLight.color":H.PERIOD_SCENE,"u_DirectionLight.direction":H.PERIOD_SCENE,"u_PointLight.position":H.PERIOD_SCENE,"u_PointLight.range":H.PERIOD_SCENE,"u_PointLight.color":H.PERIOD_SCENE,"u_SpotLight.position":H.PERIOD_SCENE,"u_SpotLight.direction":H.PERIOD_SCENE,"u_SpotLight.range":H.PERIOD_SCENE,"u_SpotLight.spot":H.PERIOD_SCENE,"u_SpotLight.color":H.PERIOD_SCENE},r={s_Cull:H.RENDER_STATE_CULL,s_Blend:H.RENDER_STATE_BLEND,s_BlendSrc:H.RENDER_STATE_BLEND_SRC,s_BlendDst:H.RENDER_STATE_BLEND_DST,s_DepthTest:H.RENDER_STATE_DEPTH_TEST,s_DepthWrite:H.RENDER_STATE_DEPTH_WRITE},i=H.add("ExtendTerrain"),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(Di,Ci,r),e={a_Position:oi.TRAIL_POSITION0,a_OffsetVector:oi.TRAIL_OFFSETVECTOR,a_Texcoord0X:oi.TRAIL_TEXTURECOORDINATE0X,a_Texcoord0Y:oi.TRAIL_TEXTURECOORDINATE0Y,a_BirthTime:oi.TRAIL_TIME0,a_Color:oi.TRAIL_COLOR},t={u_MvpMatrix:H.PERIOD_SPRITE,u_View:H.PERIOD_CAMERA,u_Projection:H.PERIOD_CAMERA,u_TilingOffset:H.PERIOD_MATERIAL,u_MainTexture:H.PERIOD_MATERIAL,u_MainColor:H.PERIOD_MATERIAL,u_CurTime:H.PERIOD_SPRITE,u_LifeTime:H.PERIOD_SPRITE,u_WidthCurve:H.PERIOD_SPRITE,u_WidthCurveKeyLength:H.PERIOD_SPRITE,u_GradientColorkey:H.PERIOD_SPRITE,u_GradientAlphakey:H.PERIOD_SPRITE},r={s_Cull:H.RENDER_STATE_CULL,s_Blend:H.RENDER_STATE_BLEND,s_BlendSrc:H.RENDER_STATE_BLEND_SRC,s_BlendDst:H.RENDER_STATE_BLEND_DST,s_DepthTest:H.RENDER_STATE_DEPTH_TEST,s_DepthWrite:H.RENDER_STATE_DEPTH_WRITE},i=H.add("Trail"),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(ca,ha,r),e={a_Position:Xe.MESH_POSITION0,a_Normal:Xe.MESH_NORMAL0,a_Tangent0:Xe.MESH_TANGENT0},t={u_MvpMatrix:H.PERIOD_SPRITE,u_WorldMat:H.PERIOD_SPRITE,u_CameraPos:H.PERIOD_CAMERA,u_Time:H.PERIOD_SCENE,u_MainTexture:H.PERIOD_MATERIAL,u_NormalTexture:H.PERIOD_MATERIAL,u_HorizonColor:H.PERIOD_MATERIAL,u_WaveScale:H.PERIOD_MATERIAL,u_WaveSpeed:H.PERIOD_MATERIAL},i=H.add("WaterPrimary"),a=new ir(e,t),i.addSubShader(a),a.addShaderPass(fa,ma),e={a_PositionTexcoord:Xe.MESH_POSITION0},t={u_MainTex:H.PERIOD_MATERIAL,u_OffsetScale:H.PERIOD_MATERIAL},i=H.add("BlitScreen"),a=new ir(e,t),i.addSubShader(a);var n=a.addShaderPass(Ii,xi).renderState;n.depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE,e={a_PositionTexcoord:Xe.MESH_POSITION0},t={u_MainTex:H.PERIOD_MATERIAL,u_BloomTex:H.PERIOD_MATERIAL,u_AutoExposureTex:H.PERIOD_MATERIAL,u_MainTex_TexelSize:H.PERIOD_MATERIAL,u_SampleScale:H.PERIOD_MATERIAL,u_Threshold:H.PERIOD_MATERIAL,u_Params:H.PERIOD_MATERIAL},i=H.add("PostProcessBloom"),a=new ir(e,t),i.addSubShader(a),(n=a.addShaderPass(Xi,Zi).renderState).depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE,a=new ir(e,t),i.addSubShader(a),(n=a.addShaderPass(Xi,qi).renderState).depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE,a=new ir(e,t),i.addSubShader(a),(n=a.addShaderPass(Xi,Yi).renderState).depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE,a=new ir(e,t),i.addSubShader(a),(n=a.addShaderPass(Xi,ji).renderState).depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE,a=new ir(e,t),i.addSubShader(a),(n=a.addShaderPass(Xi,Ki).renderState).depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE,a=new ir(e,t),i.addSubShader(a),(n=a.addShaderPass(Xi,Qi).renderState).depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE,e={a_PositionTexcoord:Xe.MESH_POSITION0},t={u_MainTex:H.PERIOD_MATERIAL,u_BloomTex:H.PERIOD_MATERIAL,u_AutoExposureTex:H.PERIOD_MATERIAL,u_Bloom_DirtTileOffset:H.PERIOD_MATERIAL,u_Bloom_DirtTex:H.PERIOD_MATERIAL,u_BloomTex_TexelSize:H.PERIOD_MATERIAL,u_Bloom_Settings:H.PERIOD_MATERIAL,u_Bloom_Color:H.PERIOD_MATERIAL},i=H.add("PostProcessComposite"),a=new ir(e,t),i.addSubShader(a),(n=a.addShaderPass(ea,$i).renderState).depthTest=Q.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=Q.CULL_NONE,n.blend=Q.BLEND_DISABLE}}class Ta extends nt{constructor(){super(),this._direction=new n,this._shadowCascadesMode=e.ShadowCascadesMode.NoCascades,this._shadowTwoCascadeSplits=1/3,this._shadowFourCascadeSplits=new n(1/15,.2,7/15),this._lightType=e.LightType.Directional}get shadowCascadesMode(){return this._shadowCascadesMode}set shadowCascadesMode(e){this._shadowCascadesMode=e}get shadowTwoCascadeSplits(){return this._shadowTwoCascadeSplits}set shadowTwoCascadeSplits(e){this._shadowTwoCascadeSplits=e}get shadowFourCascadeSplits(){return this._shadowFourCascadeSplits}set shadowFourCascadeSplits(e){if(e.x>e.y||e.y>e.z||e.z>1)throw"DiretionLight:Invalid value.";e.cloneTo(this._shadowFourCascadeSplits)}_addToLightQueue(){this._scene._directionLights.add(this)}_removeFromLightQueue(){this._scene._directionLights.remove(this)}}class pa extends nt{get range(){return this._range}set range(e){this._range=e}constructor(){super(),this._range=6,this._lightType=e.LightType.Point}_addToLightQueue(){this._scene._pointLights.add(this)}_removeFromLightQueue(){this._scene._pointLights.remove(this)}_parse(e,t){super._parse(e,t),this.range=e.range}}class ga extends nt{get spotAngle(){return this._spotAngle}set spotAngle(e){this._spotAngle=Math.max(Math.min(e,179),0)}get range(){return this._range}set range(e){this._range=e}constructor(){super(),this._spotAngle=30,this._range=10,this._direction=new n,this._lightType=e.LightType.Spot}_addToLightQueue(){this._scene._spotLights.add(this)}_removeFromLightQueue(){this._scene._spotLights.remove(this)}_parse(e,t){super._parse(e,t),this.range=e.range,this.spotAngle=e.spotAngle}}class Sa{static _createSprite3DInstance(e,t,r){var i;switch(e.type){case"Scene3D":i=new tr;break;case"Sprite3D":i=new ve;break;case"MeshSprite3D":i=new Rr,r&&e.props.isStatic&&r.push(i);break;case"SkinnedMeshSprite3D":i=new ai;break;case"ShuriKenParticle3D":i=new ti;break;case"Camera":i=new ot;break;case"DirectionLight":i=new Ta;break;case"PointLight":i=new pa;break;case"SpotLight":i=new ga;break;case"TrailSprite3D":i=new ci;break;default:throw new Error("Utils3D:unidentified class type in (.lh) file.")}var a=e.child;if(a)for(var n=0,s=a.length;n65535?e.IndexFormat.UInt32:e.IndexFormat.UInt16,S._vertexBuffer=L,S._vertexCount+=u,a+=4*h.length}var C,D=l+n.getUint32(),M=n.getUint32();C=S.indexFormat==e.IndexFormat.UInt32?new Uint32Array(s.slice(D,D+M)):new Uint16Array(s.slice(D,D+M));var O=new ze(S.indexFormat,C.length,i.STATIC_DRAW,!0);if(O.setData(C),S._indexBuffer=O,S._setBuffer(S._vertexBuffer,O),a+=2*O.indexCount,S._setCPUMemory(a),S._setGPUMemory(a),"LAYAMODEL:0501"==va._version||"LAYAMODEL:COMPRESSION_0501"==va._version){var N=S.bounds,b=N.getMin(),P=N.getMax();b.setValue(n.getFloat32(),n.getFloat32(),n.getFloat32()),P.setValue(n.getFloat32(),n.getFloat32(),n.getFloat32()),N.setMin(b),N.setMax(P),S.bounds=N}var w=S._boneNames=[],V=n.getUint16();for(w.length=V,r=0;r0&&".."!==i[s]&&(i.splice(s,2),a-=2)}r=i.join("/")}return r}static _endLoad(e,r=null,i=null){if(i)for(var a=0,n=i.length;a0){var m=c/d,f=t.Handler.create(null,Ca._onProcessChange,[e,u,m],!1);Ca._innerFourthLevelLoaderManager._create(_,!1,t.Handler.create(null,Ca._onHierarchyInnerForthLevResouLoaded,[e,f,r,h,s,o,l,u+m*_.length,m]),f,null,null,null,1,!0)}else Ca._onHierarchyInnerForthLevResouLoaded(e,null,r,h,s,o,l,u,m)}static _onHierarchyInnerForthLevResouLoaded(e,r,i,a,n,s,o,l,_){if(r&&r.recover(),o.length>0){var h=t.Handler.create(null,Ca._onProcessChange,[e,l,_],!1);Ca._innerThirdLevelLoaderManager._create(o,!1,t.Handler.create(null,Ca._onHierarchyInnerThirdLevResouLoaded,[e,h,i,a,n,s,l+_*s.length,_]),r,null,null,null,1,!0)}else Ca._onHierarchyInnerThirdLevResouLoaded(e,null,i,a,n,s,l,_)}static _onHierarchyInnerThirdLevResouLoaded(e,r,i,a,n,s,o,l){if(r&&r.recover(),s.length>0){var _=t.Handler.create(null,Ca._onProcessChange,[e,o,l],!1);Ca._innerSecondLevelLoaderManager._create(s,!1,t.Handler.create(null,Ca._onHierarchyInnerSecondLevResouLoaded,[e,_,i,a,n,o+l*s.length,l]),r,null,null,null,1,!0)}else Ca._onHierarchyInnerSecondLevResouLoaded(e,null,i,a,n,o,l)}static _onHierarchyInnerSecondLevResouLoaded(e,r,i,a,n,s,o){if(r&&r.recover(),n.length>0){var l=t.Handler.create(null,Ca._onProcessChange,[e,s,o],!1);Ca._innerFirstLevelLoaderManager._create(n,!1,t.Handler.create(null,Ca._onHierarchyInnerFirstLevResouLoaded,[e,l,i,a]),r,null,null,null,1,!0)}else Ca._onHierarchyInnerFirstLevResouLoaded(e,null,i,a)}static _onHierarchyInnerFirstLevResouLoaded(e,t,r,i){t&&t.recover(),e._cache=e._createCache;var a="Scene3D"===r.data.type?Sa._parseScene(r,e._propertyParams,e._constructParams):Sa._parse(r,e._propertyParams,e._constructParams);Ca._endLoad(e,a,i)}static _loadMesh(e){e.on(t.Event.LOADED,null,Ca._onMeshLmLoaded,[e]),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _onMeshLmLoaded(e,t){e._cache=e._createCache;var r=xa._parse(t,e._propertyParams,e._constructParams);Ca._endLoad(e,r)}static _loadMaterial(e){e.on(t.Event.LOADED,null,Ca._onMaterilLmatLoaded,[e]),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _onMaterilLmatLoaded(e,r){var i,a=e.url,n=I.getURLVerion(a),s=t.URL.getPath(a),o=[],l=[];r.customProps;switch(r.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":var _,h,c=r.props.textures;if(c)for(_=0,h=c.length;_0){var T=t.Handler.create(null,Ca._onProcessChange,[e,E,m/f],!1);Ca._innerFourthLevelLoaderManager._create(o,!1,t.Handler.create(null,Ca._onMateialTexturesLoaded,[e,T,r,l]),T,null,null,null,1,!0)}else Ca._onMateialTexturesLoaded(e,null,r,null)}static _onMateialTexturesLoaded(e,t,r,i){e._cache=e._createCache;var a=Z._parse(r,e._propertyParams,e._constructParams);Ca._endLoad(e,a,i),t&&t.recover()}static _loadAvatar(e){e.on(t.Event.LOADED,null,function(t){e._cache=e._createCache;var r=j._parse(t,e._propertyParams,e._constructParams);Ca._endLoad(e,r)}),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _loadAnimationClip(e){e.on(t.Event.LOADED,null,function(t){e._cache=e._createCache;var r=A._parse(t,e._propertyParams,e._constructParams);Ca._endLoad(e,r)}),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _loadTexture2D(e){var r,i=e.url,a=i.lastIndexOf(".")+1,n=i.indexOf("?"),s=-1==n?i.length:n;switch(i.substr(a,s-a)){case"jpg":case"jpeg":case"bmp":case"gif":case"png":r="nativeimage";break;case"dds":case"ktx":case"pvr":r=t.Loader.BUFFER}e.on(t.Event.LOADED,null,function(r){e._cache=e._createCache;var i=t.Texture2D._parse(r,e._propertyParams,e._constructParams);Ca._endLoad(e,i)}),e.load(e.url,r,!1,null,!0)}static _loadTextureCube(e){e.on(t.Event.LOADED,null,Ca._onTextureCubeLtcLoaded,[e]),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _loadTextureCubeBin(e){e.on(t.Event.LOADED,null,r=>{e._cache=e._createCache;var i=new t.Byte(r);if("LAYATEXTURECUBE:0000"!==i.readUTFString())throw"Laya3D:unknow version.";var a=i.readUint8(),n=i.getUint8(),s=i.readUint16(),o=i.getUint8(),l=i.getUint8(),_=i.getUint8(),h=i.getUint8(),c=new Dt(s,a,n>1);c.filterMode=o,c.wrapModeU=l,c.wrapModeV=_,c.anisoLevel=h;for(var d=i.pos,u=s,m=0;m=0&&e=0&&t0?s:0,_=Math.floor(i.width/(2-o)),h=Math.floor(i.height/(2-l)),c=Math.max(_,h);n=Math.log2(c)+this._diffusion-10;var d=Math.floor(n),u=Math.min(Math.max(d,1),ba.MAXPYRAMIDSIZE),m=.5+n-d;this._shaderData.setNumber(ba.SHADERVALUE_SAMPLESCALE,m);var f=ge.gammaToLinearSpace(this.threshold),E=f*this._softKnee+1e-5;this._shaderThreshold.setValue(f,f-E,2*E,.25/E),this._shaderData.setVector(ba.SHADERVALUE_THRESHOLD,this._shaderThreshold);var T=ge.gammaToLinearSpace(this.clamp);this._shaderParams.setValue(T,0,0,0),this._shaderData.setVector(ba.SHADERVALUE_PARAMS,this._shaderParams);for(var p=this.fastMode?1:0,g=e.source,S=0;S=0;S--)v=(R=2*S)+1,I=this._pyramid[R],A=this._pyramid[v],r.setShaderDataTexture(this._shaderData,ba.SHADERVALUE_BLOOMTEX,I),r.blitScreenTriangle(L,A,null,this._shader,this._shaderData,ba.SUBSHADER_UPSAMPLETENT+p),L=A;var C=this._linearColor;this.color.toLinear(C);var D=Math.pow(2,this._intensity/10)-1,M=this._shaderSetting;this._shaderSetting.setValue(m,D,this._dirtIntensity,u);var y=this.dirtTexture?this.dirtTexture:t.Texture2D.blackTexture,O=y.width/y.height,N=i.width/i.height,b=this._dirtTileOffset;O>N?b.setValue(N/O,1,.5*(1-b.x),0):O>>0)+(t>>>0),n=r+e+(a/2>>>31)>>>0,s=a>>>0;this._state0U=r,this._state0L=i;var o=0,l=0;o=(e^=o=e<<23|(-512&t)>>>9)^r,l=(t^=l=t<<23)^i;o^=e>>>18,l^=t>>>18|(262143&e)<<14;return o^=r>>>5,l^=i>>>5|(31&r)<<27,this._state1U=o,this._state1L=l,[n,s]}random(){var e=this.randomint(),t=e[0],r=1023<<20|t>>>12,i=0|(e[1]>>>12|(4095&t)<<20);return Pa._CONVERTION_BUFFER.setUint32(0,r,!1),Pa._CONVERTION_BUFFER.setUint32(4,i,!1),Pa._CONVERTION_BUFFER.getFloat64(0,!1)-1}}Pa._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8)),Pa.defaultRand=new Pa([0,Date.now()/65536,0,Date.now()%65536]);class wa{constructor(e,t){this._width=0,this._height=0,this._width=e,this._height=t}static get fullScreen(){return new wa(-1,-1)}get width(){return-1===this._width?V.clientWidth:this._width}get height(){return-1===this._height?V.clientHeight:this._height}}e.AlternateLightQueue=Ot,e.AnimationClip=A,e.AnimationClipParser03=p,e.AnimationClipParser04=S,e.AnimationEvent=c,e.AnimationNode=Y,e.AnimationTransform3D=X,e.Animator=P,e.AnimatorControllerLayer=C,e.AnimatorPlayState=L,e.AnimatorState=N,e.AnimatorStateScript=class{constructor(){}onStateEnter(){}onStateUpdate(){}onStateExit(){}},e.Avatar=j,e.BaseCamera=Qe,e.BaseMaterial=q,e.BaseRender=kt,e.BaseShape=Pr,e.BatchMark=Ft,e.BlinnPhongMaterial=K,e.BlitScreenQuadCMD=et,e.BloomEffect=ba,e.BoundBox=bt,e.BoundFrustum=Be,e.BoundSphere=Jt,e.Bounds=Pt,e.BoundsOctree=Qt,e.BoundsOctreeNode=Zt,e.BoxColliderShape=ft,e.BoxShape=Vr,e.BufferState=Ge,e.BulletInteractive=ui,e.Burst=Ir,e.Camera=ot,e.CameraCullInfo=Ae,e.CapsuleColliderShape=Et,e.CastShadowList=class extends Te{constructor(){super()}add(e){if(-1!==e._indexInCastShadowList)throw"CastShadowList:element has in CastShadowList.";this._add(e),e._indexInCastShadowList=this.length++}remove(e){var t=e._indexInCastShadowList;if(this.length--,t!==this.length){var r=this.elements[this.length];this.elements[t]=r,r._indexInCastShadowList=t}e._indexInCastShadowList=-1}},e.CharacterController=mi,e.CircleShape=Br,e.Cluster=Me,e.ColliderShape=mt,e.Collision=dt,e.CollisionTool=ut,e.CollisionUtils=Ve,e.Color=ge,e.ColorOverLifetime=Lr,e.Command=$e,e.CommandBuffer=it,e.CompoundColliderShape=Tt,e.ConchQuaternion=O,e.ConchVector3=M,e.ConchVector4=D,e.ConeColliderShape=pt,e.ConeShape=Fr,e.Config3D=l,e.Constraint3D=class{constructor(){}},e.ConstraintComponent=class extends t.Component{constructor(){super(),this._feedbackEnabled=!1}get enabled(){return super.enabled}set enabled(e){this._btConstraint.IsEnabled=e,super.enabled=e}get breakingImpulseThreshold(){return this._breakingImpulseThreshold}set breakingImpulseThreshold(e){this._btConstraint.BreakingImpulseThreshold=e,this._breakingImpulseThreshold=e}get appliedImpulse(){return this._feedbackEnabled||(this._btConstraint.EnableFeedback(!0),this._feedbackEnabled=!0),this._btConstraint.AppliedImpulse}get connectedBody(){return this._connectedBody}set connectedBody(e){this._connectedBody=e}_onDestroy(){v._bullet.destroy(this._btConstraint),this._btConstraint=null}},e.ContactPoint=ct,e.ContainmentType=we,e.CylinderColliderShape=gt,e.DefineDatas=F,e.DirectionLight=Ta,e.DirectionLightQueue=yt,e.DynamicBatchManager=Se,e.EffectMaterial=J,e.Emission=Jr,e.ExtendTerrainMaterial=$,e.FloatKeyframe=u,e.FrameOverTime=Cr,e.FrustumCulling=Ce,e.GeometryElement=wt,e.Gradient=xr,e.GradientAngularVelocity=Dr,e.GradientColor=Ar,e.GradientDataInt=Mr,e.GradientDataNumber=yr,e.GradientDataVector2=Oa,e.GradientMode=vr,e.GradientSize=Or,e.GradientVelocity=Nr,e.HalfFloatUtils=g,e.HeightMap=Ma,e.HeightfieldColliderShape=class{constructor(){}},e.HemisphereShape=Ur,e.HitResult=lt,e.ILaya3D=_,e.IndexBuffer3D=ze,e.Input3D=It,e.Keyframe=d,e.KeyframeNode=h,e.KeyframeNodeList=R,e.KeyframeNodeOwner=b,e.Laya3D=Ca,e.LightQueue=Mt,e.LightSprite=nt,e.Lightmap=Kt,e.LoadModelV04=Ra,e.LoadModelV05=va,e.Material=Z,e.MathUtils3D=r,e.Matrix3x3=m,e.Matrix4x4=y,e.Mesh=Ri,e.MeshColliderShape=St,e.MeshFilter=pr,e.MeshReader=xa,e.MeshRenderDynamicBatchManager=Sr,e.MeshRenderStaticBatchManager=Wt,e.MeshRenderer=Tr,e.MeshSprite3D=Rr,e.MeshSprite3DShaderDeclaration=Er,e.MeshTerrainSprite3D=ya,e.MouseTouch=Oe,e.OctreeMotionList=qt,e.PBRMaterial=ee,e.PBRSpecularMaterial=ar,e.PBRStandardMaterial=cr,e.Physics3D=v,e.Physics3DUtils=_t,e.PhysicsCollider=Ei,e.PhysicsComponent=vt,e.PhysicsSettings=At,e.PhysicsSimulation=xt,e.PhysicsTriggerComponent=fi,e.PhysicsUpdateList=ht,e.Picker=Ue,e.PixelLineData=class{constructor(){this.startPosition=new n,this.endPosition=new n,this.startColor=new ge,this.endColor=new ge}cloneTo(e){this.startPosition.cloneTo(e.startPosition),this.endPosition.cloneTo(e.endPosition),this.startColor.cloneTo(e.startColor),this.endColor.cloneTo(e.endColor)}},e.PixelLineFilter=Bt,e.PixelLineMaterial=Nt,e.PixelLineRenderer=Xt,e.PixelLineSprite3D=Yt,e.PixelLineVertex=Vt,e.Plane=be,e.Point2PointConstraint=class{constructor(){this._pivotInA=new n,this._pivotInB=new n}get pivotInA(){return this._pivotInA}set pivotInA(e){this._pivotInA=e}get pivotInB(){return this._pivotInB}set pivotInB(e){this._pivotInB=e}get damping(){return this._damping}set damping(e){this._damping=e}get impulseClamp(){return this._impulseClamp}set impulseClamp(e){this._impulseClamp=e}get tau(){return this._tau}set tau(e){this._tau=e}},e.PointLight=pa,e.PostProcess=k,e.PostProcessEffect=Na,e.PostProcessRenderContext=w,e.PrimitiveMesh=vi,e.Quaternion=f,e.QuaternionKeyframe=E,e.Rand=Kr,e.RandX=Pa,e.Ray=Pe,e.RenderContext3D=V,e.RenderElement=Gt,e.RenderQueue=jt,e.RenderState=Q,e.RenderTexture=B,e.RenderableSprite3D=xe,e.Rigidbody3D=Ti,e.RotationOverLifetime=br,e.Scene3D=tr,e.Scene3DShaderDeclaration=at,e.Scene3DUtils=Sa,e.SceneManager=class{constructor(){}},e.ScreenQuad=Ke,e.ScreenTriangle=Je,e.Script3D=Da,e.SetRenderTargetCMD=tt,e.SetShaderDataTextureCMD=rt,e.Shader3D=H,e.ShaderData=W,e.ShaderDefine=U,e.ShaderInit3D=Ea,e.ShaderInstance=Ee,e.ShaderPass=rr,e.ShaderVariable=fe,e.ShaderVariant=G,e.ShaderVariantCollection=z,e.ShadowCasterPass=er,e.ShadowCullInfo=Le,e.ShadowSliceData=$t,e.ShadowUtils=st,e.ShapeUtils=wr,e.ShuriKenParticle3D=ti,e.ShuriKenParticle3DShaderDeclaration=Xr,e.ShurikenParticleData=$r,e.ShurikenParticleMaterial=Yr,e.ShurikenParticleRenderer=jr,e.ShurikenParticleSystem=ei,e.SimpleSingletonList=pe,e.SingletonList=Te,e.Size=wa,e.SizeOverLifetime=zr,e.SkinnedMeshRenderer=ii,e.SkinnedMeshSprite3D=ai,e.SkinnedMeshSprite3DShaderDeclaration=ri,e.SkyBox=Ze,e.SkyBoxMaterial=dr,e.SkyDome=Ct,e.SkyMesh=je,e.SkyPanoramicMaterial=La,e.SkyProceduralMaterial=ur,e.SkyRenderer=qe,e.SphereColliderShape=Rt,e.SphereShape=Gr,e.SphericalHarmonicsL2=ye,e.SpotLight=ga,e.Sprite3D=ve,e.StartFrame=Hr,e.StaticBatchManager=Ie,e.StaticPlaneColliderShape=pi,e.SubMesh=gi,e.SubMeshDynamicBatch=gr,e.SubMeshInstanceBatch=Ut,e.SubMeshRenderElement=zt,e.SubMeshStaticBatch=Ht,e.SubShader=ir,e.TextMesh=class{get text(){return this._text}set text(e){this._text=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e}get color(){return this._color}set color(e){this._color=e}constructor(){}_createVertexBuffer(e){}_resizeVertexBuffer(e){}_addChar(){}},e.TextureCube=Dt,e.TextureGenerator=x,e.TextureMode=si,e.TextureSheetAnimation=Wr,e.Touch=Ne,e.TrailFilter=_i,e.TrailGeometry=li,e.TrailMaterial=ni,e.TrailRenderer=hi,e.TrailSprite3D=ci,e.Transform3D=Re,e.UnlitMaterial=mr,e.Utils3D=I,e.Vector2=i,e.Vector3=n,e.Vector3Keyframe=T,e.Vector4=a,e.VelocityOverLifetime=kr,e.VertexBuffer3D=Ye,e.VertexDeclaration=We,e.VertexElement=ke,e.VertexElementFormat=He,e.VertexMesh=Xe,e.VertexPositionTerrain=di,e.VertexPositionTexture0=Lt,e.VertexShuriKenParticle=Zr,e.VertexShurikenParticleBillboard=qr,e.VertexShurikenParticleMesh=Qr,e.VertexTrail=oi,e.Viewport=Fe,e.WaterPrimaryMaterial=fr,e.skinnedMatrixCache=Si}(window.Laya=window.Laya||{},Laya);