!function(e,t){"use strict";class r{constructor(){}static isZero(e){return Math.abs(e)0&&(n=1/Math.sqrt(n),t.x=r*n,t.y=i*n)}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 n{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 n;return this.cloneTo(e),e}static lerp(e,t,r,i){var n=e.x,a=e.y,s=e.z,o=e.w;i.x=n+r*(t.x-n),i.y=a+r*(t.y-a),i.z=s+r*(t.z-s),i.w=o+r*(t.w-o)}static transformByM4x4(e,t,r){var i=e.x,n=e.y,a=e.z,s=e.w,o=t.elements;r.x=i*o[0]+n*o[4]+a*o[8]+s*o[12],r.y=i*o[1]+n*o[5]+a*o[9]+s*o[13],r.z=i*o[2]+n*o[6]+a*o[10]+s*o[14],r.w=i*o[3]+n*o[7]+a*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 n=e.x,a=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;n=(n=n>d?d:n)u?u:a)<_?_:a,s=(s=s>m?m:s)f?f:o)0&&(a=1/Math.sqrt(a),t.x=r*a,t.y=i*a,t.z=n*a)}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 n=e.x,a=e.y,s=e.z;i.x=n+r*(t.x-n),i.y=a+r*(t.y-a),i.z=s+r*(t.z-s)}static transformV3ToV3(e,t,r){var i=a._tempVector4;a.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,n=e.y,a=e.z,s=t.elements;r.x=i*s[0]+n*s[4]+a*s[8]+s[12],r.y=i*s[1]+n*s[5]+a*s[9]+s[13],r.z=i*s[2]+n*s[6]+a*s[10]+s[14],r.w=i*s[3]+n*s[7]+a*s[11]+s[15]}static TransformNormal(e,t,r){var i=e.x,n=e.y,a=e.z,s=t.elements;r.x=i*s[0]+n*s[4]+a*s[8],r.y=i*s[1]+n*s[5]+a*s[9],r.z=i*s[2]+n*s[6]+a*s[10]}static transformCoordinate(e,t,r){var i=e.x,n=e.y,a=e.z,s=t.elements,o=i*s[3]+n*s[7]+a*s[11]+s[15];r.x=(i*s[0]+n*s[4]+a*s[8]+s[12])/o,r.y=(i*s[1]+n*s[5]+a*s[9]+s[13])/o,r.z=(i*s[2]+n*s[6]+a*s[10]+s[14])/o}static Clamp(e,t,r,i){var n=e.x,a=e.y,s=e.z,o=t.x,l=t.y,_=t.z,h=r.x,c=r.y,d=r.z;n=(n=n>h?h:n)c?c:a)d?d:s)<_?_:s,i.x=n,i.y=a,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,n=e.y,a=e.z,s=t.x,o=t.y,l=t.z;r.x=n*l-a*o,r.y=a*s-i*l,r.z=i*o-n*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 a;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;a._tempVector4=new n,a._ZERO=new a(0,0,0),a._ONE=new a(1,1,1),a._NegativeUnitX=new a(-1,0,0),a._UnitX=new a(1,0,0),a._UnitY=new a(0,1,0),a._UnitZ=new a(0,0,1),a._ForwardRH=new a(0,0,-1),a._ForwardLH=new a(0,0,1),a._Up=new a(0,1,0),(s=e.PBRRenderQuality||(e.PBRRenderQuality={}))[s.High=0]="High",s[s.Low=1]="Low";class l{constructor(){var e=this.elements=new Float32Array(9);e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}static createRotationQuaternion(e,t){var r=e.x,i=e.y,n=e.z,a=e.w,s=r*r,o=i*i,l=n*n,_=r*i,h=n*a,c=n*r,d=i*a,u=i*n,m=r*a,f=t.elements;f[0]=1-2*(o+l),f[1]=2*(_+h),f[2]=2*(c-d),f[3]=2*(_-h),f[4]=1-2*(l+s),f[5]=2*(u+m),f[6]=2*(c+d),f[7]=2*(u-m),f[8]=1-2*(o+s)}static createFromTranslation(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=1,r[5]=0,r[6]=e.x,r[7]=e.y,r[8]=1}static createFromRotation(e,t){var r=t.elements,i=Math.sin(e),n=Math.cos(e);r[0]=n,r[1]=i,r[2]=0,r[3]=-i,r[4]=n,r[5]=0,r[6]=0,r[7]=0,r[8]=1}static createFromScaling(e,t){var r=t.elements;r[0]=e.x,r[1]=0,r[2]=0,r[3]=0,r[4]=e.y,r[5]=0,r[6]=0,r[7]=0,r[8]=e.z}static createFromMatrix4x4(e,t){var r=e.elements,i=t.elements;i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[4],i[4]=r[5],i[5]=r[6],i[6]=r[8],i[7]=r[9],i[8]=r[10]}static multiply(e,t,r){var i=e.elements,n=t.elements,a=r.elements,s=i[0],o=i[1],l=i[2],_=i[3],h=i[4],c=i[5],d=i[6],u=i[7],m=i[8],f=n[0],T=n[1],E=n[2],p=n[3],g=n[4],S=n[5],R=n[6],v=n[7],A=n[8];a[0]=f*s+T*_+E*d,a[1]=f*o+T*h+E*v,a[2]=f*l+T*c+E*m,a[3]=p*s+g*_+S*d,a[4]=p*o+g*h+S*u,a[5]=p*l+g*c+S*m,a[6]=R*s+v*_+A*d,a[7]=R*o+v*h+A*u,a[8]=R*l+v*c+A*m}determinant(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7],_=e[8];return t*(_*a-s*l)+r*(-_*n+s*o)+i*(l*n-a*o)}translate(e,t){var r=t.elements,i=this.elements,n=i[0],a=i[1],s=i[2],o=i[3],l=i[4],_=i[5],h=i[6],c=i[7],d=i[8],u=e.x,m=e.y;r[0]=n,r[1]=a,r[2]=s,r[3]=o,r[4]=l,r[5]=_,r[6]=u*n+m*o+h,r[7]=u*a+m*l+c,r[8]=u*s+m*_+d}rotate(e,t){var r=t.elements,i=this.elements,n=i[0],a=i[1],s=i[2],o=i[3],l=i[4],_=i[5],h=i[6],c=i[7],d=i[8],u=Math.sin(e),m=Math.cos(e);r[0]=m*n+u*o,r[1]=m*a+u*l,r[2]=m*s+u*_,r[3]=m*o-u*n,r[4]=m*l-u*a,r[5]=m*_-u*s,r[6]=h,r[7]=c,r[8]=d}scale(e,t){var r=t.elements,i=this.elements,n=e.x,a=e.y;r[0]=n*i[0],r[1]=n*i[1],r[2]=n*i[2],r[3]=a*i[3],r[4]=a*i[4],r[5]=a*i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8]}invert(e){var t=e.elements,r=this.elements,i=r[0],n=r[1],a=r[2],s=r[3],o=r[4],l=r[5],_=r[6],h=r[7],c=r[8],d=c*o-l*h,u=-c*s+l*_,m=h*s-o*_,f=i*d+n*u+a*m;f||(e=null),f=1/f,t[0]=d*f,t[1]=(-c*n+a*h)*f,t[2]=(l*n-a*o)*f,t[3]=u*f,t[4]=(c*i-a*_)*f,t[5]=(-l*i+a*s)*f,t[6]=m*f,t[7]=(-h*i+n*_)*f,t[8]=(o*i-n*s)*f}transpose(e){var t=e.elements,r=this.elements;if(e===this){var i=r[1],n=r[2],a=r[5];t[1]=r[3],t[2]=r[6],t[3]=i,t[5]=r[7],t[6]=n,t[7]=a}else t[0]=r[0],t[1]=r[3],t[2]=r[6],t[3]=r[1],t[4]=r[4],t[5]=r[7],t[6]=r[2],t[7]=r[5],t[8]=r[8]}identity(){var e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}cloneTo(e){var t,r,i;if((r=this.elements)!==(i=e.elements))for(t=0;t<9;++t)i[t]=r[t]}clone(){var e=new l;return this.cloneTo(e),e}static lookAt(e,t,r,i){a.subtract(e,t,l._tempV30),a.normalize(l._tempV30,l._tempV30),a.cross(r,l._tempV30,l._tempV31),a.normalize(l._tempV31,l._tempV31),a.cross(l._tempV30,l._tempV31,l._tempV32);var n=l._tempV30,s=l._tempV31,o=l._tempV32,_=i.elements;_[0]=s.x,_[3]=s.y,_[6]=s.z,_[1]=o.x,_[4]=o.y,_[7]=o.z,_[2]=n.x,_[5]=n.y,_[8]=n.z}}l.DEFAULT=new l,l._tempV30=new a,l._tempV31=new a,l._tempV32=new a;class _{}_.Shader3D=null,_.Scene3D=null,_.MeshRenderStaticBatchManager=null,_.MeshRenderDynamicBatchManager=null,_.SubMeshDynamicBatch=null,_.Laya3D=null,_.Matrix4x4=null,_.Physics3D=null,_.ShadowLightType=null;class h{constructor(e=0,t=0,r=0,i=1,n=null){this.x=e,this.y=t,this.z=r,this.w=i}static createFromYawPitchRoll(e,t,r,i){var n=.5*r,a=.5*t,s=.5*e,o=Math.sin(n),l=Math.cos(n),_=Math.sin(a),h=Math.cos(a),c=Math.sin(s),d=Math.cos(s);i.x=d*_*l+c*h*o,i.y=c*h*l-d*_*o,i.z=d*h*o-c*_*l,i.w=d*h*l+c*_*o}static multiply(e,t,r){var i=e.x,n=e.y,a=e.z,s=e.w,o=t.x,l=t.y,_=t.z,h=t.w,c=n*_-a*l,d=a*o-i*_,u=i*l-n*o,m=i*o+n*l+a*_;r.x=i*h+o*s+c,r.y=n*h+l*s+d,r.z=a*h+_*s+u,r.w=s*h-m}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){a.subtract(t,e,h.TEMPVector30),a.normalize(h.TEMPVector30,h.TEMPVector30),r.x=Math.asin(h.TEMPVector30.y),r.y=h.arcTanAngle(-h.TEMPVector30.z,-h.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,n=e.elements,a=n[0]+n[5]+n[10];a>0?(r=Math.sqrt(a+1),t.w=.5*r,r=.5/r,t.x=(n[6]-n[9])*r,t.y=(n[8]-n[2])*r,t.z=(n[1]-n[4])*r):n[0]>=n[5]&&n[0]>=n[10]?(i=.5/(r=Math.sqrt(1+n[0]-n[5]-n[10])),t.x=.5*r,t.y=(n[1]+n[4])*i,t.z=(n[2]+n[8])*i,t.w=(n[6]-n[9])*i):n[5]>n[10]?(i=.5/(r=Math.sqrt(1+n[5]-n[0]-n[10])),t.x=(n[4]+n[1])*i,t.y=.5*r,t.z=(n[9]+n[6])*i,t.w=(n[8]-n[2])*i):(i=.5/(r=Math.sqrt(1+n[10]-n[0]-n[5])),t.x=(n[8]+n[2])*i,t.y=(n[9]+n[6])*i,t.z=.5*r,t.w=(n[1]-n[4])*i)}static slerp(e,t,r,i){var n,a,s,o,l,_=e.x,h=e.y,c=e.z,d=e.w,u=t.x,m=t.y,f=t.z,T=t.w;return(a=_*u+h*m+c*f+d*T)<0&&(a=-a,u=-u,m=-m,f=-f,T=-T),1-a>1e-6?(n=Math.acos(a),s=Math.sin(n),o=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/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*T,i}static lerp(e,t,r,i){var n=1-r;h.dot(e,t)>=0?(i.x=n*e.x+r*t.x,i.y=n*e.y+r*t.y,i.z=n*e.z+r*t.z,i.w=n*e.w+r*t.w):(i.x=n*e.x-r*t.x,i.y=n*e.y-r*t.y,i.z=n*e.z-r*t.z,i.w=n*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){a.transformQuat(a._ForwardRH,this,h.TEMPVector31),a.transformQuat(a._Up,this,h.TEMPVector32);var t=h.TEMPVector32;h.angleTo(a._ZERO,h.TEMPVector31,h.TEMPVector33);var r=h.TEMPVector33;r.x==Math.PI/2?(r.y=h.arcTanAngle(t.z,t.x),r.z=0):r.x==-Math.PI/2?(r.y=h.arcTanAngle(-t.z,-t.x),r.z=0):(_.Matrix4x4.createRotationY(-r.y,_.Matrix4x4.TEMPMatrix0),_.Matrix4x4.createRotationX(-r.x,_.Matrix4x4.TEMPMatrix1),a.transformCoordinate(h.TEMPVector32,_.Matrix4x4.TEMPMatrix0,h.TEMPVector32),a.transformCoordinate(h.TEMPVector32,_.Matrix4x4.TEMPMatrix1,h.TEMPVector32),r.z=h.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,n=this.w,a=t*t+r*r+i*i+n*n,s=a?1/a:0;e.x=-t*s,e.y=-r*s,e.z=-i*s,e.w=n*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 h;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){h.lookAt(a._ZERO,e,t,r)}static lookAt(e,t,r,i){l.lookAt(e,t,r,h._tempMatrix3x3),h.rotationMatrix(h._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,n=e.elements,a=n[0],s=n[1],o=n[2],l=n[3],_=n[4],h=n[5],c=n[6],d=n[7],u=n[8],m=a+_+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):a>=_&&a>=u?(i=.5/(r=Math.sqrt(1+a-_-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+_-a-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-a-_)),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)}}h.TEMPVector30=new a,h.TEMPVector31=new a,h.TEMPVector32=new a,h.TEMPVector33=new a,h._tempMatrix3x3=new l,h.DEFAULT=new h,h.NAN=new h(NaN,NaN,NaN,NaN);class c{constructor(e=1,t=0,r=0,i=0,n=0,a=1,s=0,o=0,l=0,_=0,h=1,c=0,d=0,u=0,m=0,f=1,T=null){var E=this.elements=T||new Float32Array(16);E[0]=e,E[1]=t,E[2]=r,E[3]=i,E[4]=n,E[5]=a,E[6]=s,E[7]=o,E[8]=l,E[9]=_,E[10]=h,E[11]=c,E[12]=d,E[13]=u,E[14]=m,E[15]=f}static createRotationX(e,t){var r=t.elements,i=Math.sin(e),n=Math.cos(e);r[1]=r[2]=r[3]=r[4]=r[7]=r[8]=r[11]=r[12]=r[13]=r[14]=0,r[0]=r[15]=1,r[5]=r[10]=n,r[6]=i,r[9]=-i}static createRotationY(e,t){var r=t.elements,i=Math.sin(e),n=Math.cos(e);r[1]=r[3]=r[4]=r[6]=r[7]=r[9]=r[11]=r[12]=r[13]=r[14]=0,r[5]=r[15]=1,r[0]=r[10]=n,r[2]=-i,r[8]=i}static createRotationZ(e,t){var r=t.elements,i=Math.sin(e),n=Math.cos(e);r[2]=r[3]=r[6]=r[7]=r[8]=r[9]=r[11]=r[12]=r[13]=r[14]=0,r[10]=r[15]=1,r[0]=r[5]=n,r[1]=i,r[4]=-i}static createRotationYawPitchRoll(e,t,r,i){h.createFromYawPitchRoll(e,t,r,c._tempQuaternion),c.createRotationQuaternion(c._tempQuaternion,i)}static createRotationAxis(e,t,r){var i=e.x,n=e.y,a=e.z,s=Math.cos(t),o=Math.sin(t),l=i*i,_=n*n,h=a*a,c=i*n,d=i*a,u=n*a,m=r.elements;m[3]=m[7]=m[11]=m[12]=m[13]=m[14]=0,m[15]=1,m[0]=l+s*(1-l),m[1]=c-s*c+o*a,m[2]=d-s*d-o*n,m[4]=c-s*c-o*a,m[5]=_+s*(1-_),m[6]=u-s*u+o*i,m[8]=d-s*d+o*n,m[9]=u-s*u-o*i,m[10]=h+s*(1-h)}setRotation(e){var t=e.x,r=e.y,i=e.z,n=e.w,a=t*t,s=r*r,o=i*i,l=t*r,_=i*n,h=i*t,c=r*n,d=r*i,u=t*n,m=this.elements;m[0]=1-2*(s+o),m[1]=2*(l+_),m[2]=2*(h-c),m[4]=2*(l-_),m[5]=1-2*(o+a),m[6]=2*(d+u),m[8]=2*(h+c),m[9]=2*(d-u),m[10]=1-2*(s+a)}setPosition(e){var t=this.elements;t[12]=e.x,t[13]=e.y,t[14]=e.z}static createRotationQuaternion(e,t){var r=t.elements,i=e.x,n=e.y,a=e.z,s=e.w,o=i*i,l=n*n,_=a*a,h=i*n,c=a*s,d=a*i,u=n*s,m=n*a,f=i*s;r[3]=r[7]=r[11]=r[12]=r[13]=r[14]=0,r[15]=1,r[0]=1-2*(l+_),r[1]=2*(h+c),r[2]=2*(d-u),r[4]=2*(h-c),r[5]=1-2*(_+o),r[6]=2*(m+f),r[8]=2*(d+u),r[9]=2*(m-f),r[10]=1-2*(l+o)}static createTranslate(e,t){var r=t.elements;r[4]=r[8]=r[1]=r[9]=r[2]=r[6]=r[3]=r[7]=r[11]=0,r[0]=r[5]=r[10]=r[15]=1,r[12]=e.x,r[13]=e.y,r[14]=e.z}static createScaling(e,t){var r=t.elements;r[0]=e.x,r[5]=e.y,r[10]=e.z,r[1]=r[4]=r[8]=r[12]=r[9]=r[13]=r[2]=r[6]=r[14]=r[3]=r[7]=r[11]=0,r[15]=1}static multiply(e,t,r){var i=t.elements,n=e.elements,a=r.elements,s=i[0],o=i[1],l=i[2],_=i[3],h=i[4],c=i[5],d=i[6],u=i[7],m=i[8],f=i[9],T=i[10],E=i[11],p=i[12],g=i[13],S=i[14],R=i[15],v=n[0],A=n[1],I=n[2],x=n[3],L=n[4],D=n[5],C=n[6],y=n[7],M=n[8],O=n[9],N=n[10],b=n[11],P=n[12],w=n[13],V=n[14],B=n[15];a[0]=s*v+o*L+l*M+_*P,a[1]=s*A+o*D+l*O+_*w,a[2]=s*I+o*C+l*N+_*V,a[3]=s*x+o*y+l*b+_*B,a[4]=h*v+c*L+d*M+u*P,a[5]=h*A+c*D+d*O+u*w,a[6]=h*I+c*C+d*N+u*V,a[7]=h*x+c*y+d*b+u*B,a[8]=m*v+f*L+T*M+E*P,a[9]=m*A+f*D+T*O+E*w,a[10]=m*I+f*C+T*N+E*V,a[11]=m*x+f*y+T*b+E*B,a[12]=p*v+g*L+S*M+R*P,a[13]=p*A+g*D+S*O+R*w,a[14]=p*I+g*C+S*N+R*V,a[15]=p*x+g*y+S*b+R*B}static multiplyForNative(e,r,i){t.LayaGL.instance.matrix4x4Multiply(e.elements,r.elements,i.elements)}static createFromQuaternion(e,t){var r=t.elements,i=e.x,n=e.y,a=e.z,s=e.w,o=i+i,l=n+n,_=a+a,h=i*o,c=n*o,d=n*l,u=a*o,m=a*l,f=a*_,T=s*o,E=s*l,p=s*_;r[0]=1-d-f,r[1]=c+p,r[2]=u-E,r[3]=0,r[4]=c-p,r[5]=1-h-f,r[6]=m+T,r[7]=0,r[8]=u+E,r[9]=m-T,r[10]=1-h-d,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1}static createAffineTransformation(e,t,r,i){var n=i.elements,a=t.x,s=t.y,o=t.z,l=t.w,_=a+a,h=s+s,c=o+o,d=a*_,u=a*h,m=a*c,f=s*h,T=s*c,E=o*c,p=l*_,g=l*h,S=l*c,R=r.x,v=r.y,A=r.z;n[0]=(1-(f+E))*R,n[1]=(u+S)*R,n[2]=(m-g)*R,n[3]=0,n[4]=(u-S)*v,n[5]=(1-(d+E))*v,n[6]=(T+p)*v,n[7]=0,n[8]=(m+g)*A,n[9]=(T-p)*A,n[10]=(1-(d+f))*A,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1}static createLookAt(e,t,r,i){var n=i.elements,s=c._tempVector0,o=c._tempVector1,l=c._tempVector2;a.subtract(e,t,l),a.normalize(l,l),a.cross(r,l,s),a.normalize(s,s),a.cross(l,s,o),n[3]=n[7]=n[11]=0,n[15]=1,n[0]=s.x,n[4]=s.y,n[8]=s.z,n[1]=o.x,n[5]=o.y,n[9]=o.z,n[2]=l.x,n[6]=l.y,n[10]=l.z,n[12]=-a.dot(s,e),n[13]=-a.dot(o,e),n[14]=-a.dot(l,e)}static createPerspective(e,t,r,i,n){var a=1/Math.tan(.5*e),s=r/(a/t),o=r/a;c.createPerspectiveOffCenter(-s,s,-o,o,r,i,n)}static createPerspectiveOffCenter(e,t,r,i,n,a,s){var o=s.elements,l=a/(a-n);o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[12]=o[13]=o[15]=0,o[0]=2*n/(t-e),o[5]=2*n/(i-r),o[8]=(e+t)/(t-e),o[9]=(i+r)/(i-r),o[10]=-l,o[11]=-1,o[14]=-n*l}static createOrthoOffCenter(e,t,r,i,n,a,s){var o=s.elements,l=1/(a-n);o[1]=o[2]=o[3]=o[4]=o[6]=o[8]=o[7]=o[9]=o[11]=0,o[15]=1,o[0]=2/(t-e),o[5]=2/(i-r),o[10]=-l,o[12]=(e+t)/(e-t),o[13]=(i+r)/(r-i),o[14]=-n*l}getElementByRowColumn(e,t){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.");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=c._tempMatrix4x4;return this.decomposeTransRotMatScale(e,i,r)?(h.createFromMatrix4x4(i,t),!0):(t.identity(),!1)}decomposeTransRotMatScale(e,t,i){var n=this.elements,s=e,o=t.elements,l=i;s.x=n[12],s.y=n[13],s.z=n[14];var _=n[0],h=n[1],d=n[2],u=n[4],m=n[5],f=n[6],T=n[8],E=n[9],p=n[10],g=l.x=Math.sqrt(_*_+h*h+d*d),S=l.y=Math.sqrt(u*u+m*m+f*f),R=l.z=Math.sqrt(T*T+E*E+p*p);if(r.isZero(g)||r.isZero(S)||r.isZero(R))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 v=c._tempVector0;v.x=T/R,v.y=E/R,v.z=p/R;var A=c._tempVector1;A.x=_/g,A.y=h/g,A.z=d/g;var I=c._tempVector2;a.cross(v,A,I);var x=c._tempVector1;return a.cross(I,v,x),o[3]=o[7]=o[11]=o[12]=o[13]=o[14]=0,o[15]=1,o[0]=x.x,o[1]=x.y,o[2]=x.z,o[4]=I.x,o[5]=I.y,o[6]=I.z,o[8]=v.x,o[9]=v.y,o[10]=v.z,o[0]*_+o[1]*h+o[2]*d<0&&(l.x=-g),o[4]*u+o[5]*m+o[6]*f<0&&(l.y=-S),o[8]*T+o[9]*E+o[10]*p<0&&(l.z=-R),!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],n=Math.sqrt(t*t+r*r+i*i);if(!n)return e[0]=0,e[1]=0,void(e[2]=0);1!=n&&(n=1/n,e[0]=t*n,e[1]=r*n,e[2]=i*n)}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],n=t[1],a=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],T=t[13],E=t[14],p=t[15],g=i*l-n*o,S=i*_-a*o,R=i*h-s*o,v=n*_-a*l,A=n*h-s*l,I=a*h-s*_,x=c*T-d*f,L=c*E-u*f,D=c*p-m*f,C=d*E-u*T,y=d*p-m*T,M=u*p-m*E,O=g*M-S*y+R*C+v*D-A*L+I*x;0!==Math.abs(O)&&(O=1/O,r[0]=(l*M-_*y+h*C)*O,r[1]=(a*y-n*M-s*C)*O,r[2]=(T*I-E*A+p*v)*O,r[3]=(u*A-d*I-m*v)*O,r[4]=(_*D-o*M-h*L)*O,r[5]=(i*M-a*D+s*L)*O,r[6]=(E*R-f*I-p*S)*O,r[7]=(c*I-u*R+m*S)*O,r[8]=(o*y-l*D+h*x)*O,r[9]=(n*D-i*y-s*x)*O,r[10]=(f*A-T*R+p*g)*O,r[11]=(d*R-c*A-m*g)*O,r[12]=(l*L-o*C-_*x)*O,r[13]=(i*C-n*L+a*x)*O,r[14]=(T*S-f*v-E*g)*O,r[15]=(c*v-d*S+u*g)*O)}static billboard(e,t,i,n,s,o){a.subtract(e,t,c._tempVector0);var l=a.scalarLengthSquared(c._tempVector0);r.isZero(l)?(a.scale(s,-1,c._tempVector1),c._tempVector1.cloneTo(c._tempVector0)):a.scale(c._tempVector0,1/Math.sqrt(l),c._tempVector0),a.cross(n,c._tempVector0,c._tempVector2),a.normalize(c._tempVector2,c._tempVector2),a.cross(c._tempVector0,c._tempVector2,c._tempVector3);var _=c._tempVector2,h=c._tempVector3,d=c._tempVector0,u=e,m=o.elements;m[0]=_.x,m[1]=_.y,m[2]=_.z,m[3]=0,m[4]=h.x,m[5]=h.y,m[6]=h.z,m[7]=0,m[8]=d.x,m[9]=d.y,m[10]=d.z,m[11]=0,m[12]=u.x,m[13]=u.y,m[14]=u.z,m[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 c;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}}c._tempMatrix4x4=new c,c.TEMPMatrix0=new c,c.TEMPMatrix1=new c,c._tempVector0=new a,c._tempVector1=new a,c._tempVector2=new a,c._tempVector3=new a,c._tempQuaternion=new h,c.DEFAULT=new c,c.ZERO=new c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);class d{constructor(){this._scale=new a(1,1,1),this._centerMatrix=new c,this._attatched=!1,this._indexInCompound=-1,this._compoundParent=null,this._attatchedCollisionObject=null,this._referenceCount=0,this._localOffset=new a(0,0,0),this._localRotation=new h(0,0,0,1),this.needsCustomCollisionCallback=!1}static __init__(){var e=_.Physics3D._bullet;d._btScale=e.btVector3_create(1,1,1),d._btVector30=e.btVector3_create(0,0,0),d._btQuaternion0=e.btQuaternion_create(0,0,0,1),d._btTransform0=e.btTransform_create()}static _createAffineTransformation(e,t,r){var i=t.x,n=t.y,a=t.z,s=t.w,o=i+i,l=n+n,_=a+a,h=i*o,c=i*l,d=i*_,u=n*l,m=n*_,f=a*_,T=s*o,E=s*l,p=s*_;r[0]=1-(u+f),r[1]=c+p,r[2]=d-E,r[3]=0,r[4]=c-p,r[5]=1-(h+f),r[6]=m+T,r[7]=0,r[8]=d+E,r[9]=m-T,r[10]=1-(h+u),r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1}get type(){return this._type}get localOffset(){return this._localOffset}set localOffset(e){this._localOffset=e,this._compoundParent&&this._compoundParent._updateChildTransform(this)}get localRotation(){return this._localRotation}set localRotation(e){this._localRotation=e,this._compoundParent&&this._compoundParent._updateChildTransform(this)}_setScale(e){if(this._compoundParent)this.updateLocalTransformations();else{var t=_.Physics3D._bullet;t.btVector3_setValue(d._btScale,e.x,e.y,e.z),t.btCollisionShape_setLocalScaling(this._btShape,d._btScale)}}_addReference(){this._referenceCount++}_removeReference(){this._referenceCount--}updateLocalTransformations(){if(this._compoundParent){var e=d._tempVector30;a.multiply(this.localOffset,this._scale,e),d._createAffineTransformation(e,this.localRotation,this._centerMatrix.elements)}else d._createAffineTransformation(this.localOffset,this.localRotation,this._centerMatrix.elements)}cloneTo(e){var t=e;this._localOffset.cloneTo(t.localOffset),this._localRotation.cloneTo(t.localRotation),t.localOffset=t.localOffset,t.localRotation=t.localRotation}clone(){return null}destroy(){this._btShape&&(_.Physics3D._bullet.btCollisionShape_destroy(this._btShape),this._btShape=null)}}d.SHAPEORIENTATION_UPX=0,d.SHAPEORIENTATION_UPY=1,d.SHAPEORIENTATION_UPZ=2,d.SHAPETYPES_BOX=0,d.SHAPETYPES_SPHERE=1,d.SHAPETYPES_CYLINDER=2,d.SHAPETYPES_CAPSULE=3,d.SHAPETYPES_CONVEXHULL=4,d.SHAPETYPES_COMPOUND=5,d.SHAPETYPES_STATICPLANE=6,d.SHAPETYPES_CONE=7,d._tempVector30=new a;class u extends d{constructor(e,t){super(),this._normal=e,this._offset=t,this._type=d.SHAPETYPES_STATICPLANE;var r=_.Physics3D._bullet;r.btVector3_setValue(u._btNormal,-e.x,e.y,e.z),this._btShape=r.btStaticPlaneShape_create(u._btNormal,t)}static __init__(){u._btNormal=_.Physics3D._bullet.btVector3_create(0,0,0)}clone(){var e=new u(this._normal,this._offset);return this.cloneTo(e),e}}class m extends d{constructor(){super(),this._childColliderShapes=[],this._type=d.SHAPETYPES_COMPOUND,this._btShape=_.Physics3D._bullet.btCompoundShape_create()}static __init__(){var e=_.Physics3D._bullet;m._btVector3One=e.btVector3_create(1,1,1),m._btTransform=e.btTransform_create(),m._btOffset=e.btVector3_create(0,0,0),m._btRotation=e.btQuaternion_create(0,0,0,1)}_clearChildShape(e){e._attatched=!1,e._compoundParent=null,e._indexInCompound=-1}_addReference(){}_removeReference(){}_updateChildTransform(e){var t=_.Physics3D._bullet,r=e.localOffset,i=e.localRotation,n=d._btVector30,a=d._btQuaternion0,s=d._btTransform0;t.btVector3_setValue(n,-r.x,r.y,r.z),t.btQuaternion_setValue(a,-i.x,i.y,i.z,-i.w),t.btTransform_setOrigin(s,n),t.btTransform_setRotation(s,a),t.btCompoundShape_updateChildTransform(this._btShape,e._indexInCompound,s,!0)}addChildShape(e){if(e._attatched)throw"CompoundColliderShape: this shape has attatched to other entity.";e._attatched=!0,e._compoundParent=this,e._indexInCompound=this._childColliderShapes.length,this._childColliderShapes.push(e);var t=e.localOffset,r=e.localRotation,i=_.Physics3D._bullet;i.btVector3_setValue(m._btOffset,-t.x,t.y,t.z),i.btQuaternion_setValue(m._btRotation,-r.x,r.y,r.z,-r.w),i.btTransform_setOrigin(m._btTransform,m._btOffset),i.btTransform_setRotation(m._btTransform,m._btRotation);var n=i.btCollisionShape_getLocalScaling(this._btShape);i.btCollisionShape_setLocalScaling(this._btShape,m._btVector3One),i.btCompoundShape_addChildShape(this._btShape,m._btTransform,e._btShape),i.btCollisionShape_setLocalScaling(this._btShape,n),this._attatchedCollisionObject&&(this._attatchedCollisionObject.colliderShape=this)}removeChildShape(e){if(e._compoundParent===this){var t=e._indexInCompound;this._clearChildShape(e);var r=this._childColliderShapes[this._childColliderShapes.length-1];r._indexInCompound=t,this._childColliderShapes[t]=r,this._childColliderShapes.pop(),_.Physics3D._bullet.btCompoundShape_removeChildShapeByIndex(this._btShape,t)}}clearChildShape(){for(var e=0,t=this._childColliderShapes.length;e0&&r.btCollisionObject_setCollisionFlags(t,i^A.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){!A._addUpdateList&&this._controlBySimulation||(e&=f.TRANSFORM_WORLDPOSITION|f.TRANSFORM_WORLDQUATERNION|f.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())}}A.ACTIVATIONSTATE_ACTIVE_TAG=1,A.ACTIVATIONSTATE_ISLAND_SLEEPING=2,A.ACTIVATIONSTATE_WANTS_DEACTIVATION=3,A.ACTIVATIONSTATE_DISABLE_DEACTIVATION=4,A.ACTIVATIONSTATE_DISABLE_SIMULATION=5,A.COLLISIONFLAGS_STATIC_OBJECT=1,A.COLLISIONFLAGS_KINEMATIC_OBJECT=2,A.COLLISIONFLAGS_NO_CONTACT_RESPONSE=4,A.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK=8,A.COLLISIONFLAGS_CHARACTER_OBJECT=16,A.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT=32,A.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING=64,A._tempVector30=new a,A._tempQuaternion0=new h,A._tempQuaternion1=new h,A._tempMatrix4x40=new c,A._physicObjectsMap={},A._addUpdateList=!0;class I{constructor(){this.elements=[],this.length=0}_add(e){this.length===this.elements.length?this.elements.push(e):this.elements[this.length]=e}add(e){this.length===this.elements.length?this.elements.push(e):this.elements[this.length]=e,this.length++}}class x extends I{constructor(){super()}add(e){if(-1!==e._inPhysicUpdateListIndex)throw"PhysicsUpdateList:element has in PhysicsUpdateList.";this._add(e),e._inPhysicUpdateListIndex=this.length++}remove(e){var t=e._inPhysicUpdateListIndex;if(this.length--,t!==this.length){var r=this.elements[this.length];this.elements[t]=r,r._inPhysicUpdateListIndex=t}e._inPhysicUpdateListIndex=-1}}class L{constructor(){this._idCounter=0,this.colliderA=null,this.colliderB=null,this.distance=0,this.normal=new a,this.positionOnA=new a,this.positionOnB=new a,this._id=++this._idCounter}}class D{constructor(){this.succeeded=!1,this.collider=null,this.point=new a,this.normal=new a,this.hitFraction=0}}class C{constructor(){this._lastUpdateFrame=-2147483648,this._updateFrame=-2147483648,this._isTrigger=!1,this.contacts=[]}_setUpdateFrame(e){this._lastUpdateFrame=this._updateFrame,this._updateFrame=e}}class y{constructor(){this._hitResultsPoolIndex=0,this._hitResultsPool=[],this._contactPonintsPoolIndex=0,this._contactPointsPool=[],this._collisionsPool=[],this._collisions={}}getHitResult(){var e=this._hitResultsPool[this._hitResultsPoolIndex++];return e||(e=new D,this._hitResultsPool.push(e)),e}recoverAllHitResultsPool(){this._hitResultsPoolIndex=0}getContactPoints(){var e=this._contactPointsPool[this._contactPonintsPoolIndex++];return e||(e=new L,this._contactPointsPool.push(e)),e}recoverAllContactPointsPool(){this._contactPonintsPoolIndex=0}getCollision(e,t){var r,i=e.id,n=t.id,a=this._collisions[i];return a&&(r=a[n]),r||(a||(a={},this._collisions[i]=a),(r=0===this._collisionsPool.length?new C:this._collisionsPool.pop())._colliderA=e,r._colliderB=t,a[n]=r),r}recoverCollision(e){var t=e._colliderA.id,r=e._colliderB.id;this._collisions[t][r]=null,this._collisionsPool.push(e)}garbageCollection(){for(var e in this._hitResultsPoolIndex=0,this._hitResultsPool.length=0,this._contactPonintsPoolIndex=0,this._contactPointsPool.length=0,this._collisionsPool.length=0,this._collisionsPool){var t=this._collisionsPool[e],r=!0;for(var i in t)t[i]?r=!1:delete t[i];r&&delete this._collisionsPool[e]}}}class M{constructor(e,t=0){this._gravity=new a(0,-10,0),this._btVector3Zero=_.Physics3D._bullet.btVector3_create(0,0,0),this._btDefaultQuaternion=_.Physics3D._bullet.btQuaternion_create(0,0,0,-1),this._collisionsUtils=new y,this._previousFrameCollisions=[],this._currentFrameCollisions=[],this._currentConstraint={},this._physicsUpdateList=new x,this._characters=[],this._updatedRigidbodies=0,this.maxSubSteps=1,this.fixedTimeStep=1/60,this.maxSubSteps=e.maxSubSteps,this.fixedTimeStep=e.fixedTimeStep;var r=_.Physics3D._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&M.PHYSICSENGINEFLAGS_COLLISIONSONLY)this._btCollisionWorld=new r.btCollisionWorld(this._btDispatcher,this._btBroadphase,this._btCollisionConfiguration);else{if(i&M.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT)throw"PhysicsSimulation:SoftBody processing is not yet available";var n=r.btSequentialImpulseConstraintSolver_create();this._btDiscreteDynamicsWorld=r.btDiscreteDynamicsWorld_create(this._btDispatcher,this._btBroadphase,n,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=_.Physics3D._bullet;M._btTempVector30=e.btVector3_create(0,0,0),M._btTempVector31=e.btVector3_create(0,0,0),M._btTempQuaternion0=e.btQuaternion_create(0,0,0,1),M._btTempQuaternion1=e.btQuaternion_create(0,0,0,1),M._btTempTransform0=e.btTransform_create(),M._btTempTransform1=e.btTransform_create()}static createConstraint(){}get continuousCollisionDetection(){return _.Physics3D._bullet.btCollisionWorld_get_m_useContinuous(this._btDispatchInfo)}set continuousCollisionDetection(e){_.Physics3D._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=_.Physics3D._bullet,r=M._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 _.Physics3D._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";_.Physics3D._bullet.btDiscreteDynamicsWorld_setApplySpeculativeContactRestitution(this._btDiscreteDynamicsWorld,e)}_simulate(e){this._updatedRigidbodies=0;var t=_.Physics3D._bullet;this._btDiscreteDynamicsWorld?t.btDiscreteDynamicsWorld_stepSimulation(this._btDiscreteDynamicsWorld,e,this.maxSubSteps,this.fixedTimeStep):t.PerformDiscreteCollisionDetection(this._btCollisionWorld)}_destroy(){var e=_.Physics3D._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){_.Physics3D._bullet.btCollisionWorld_addCollisionObject(this._btCollisionWorld,e._btColliderObject,t,r)}_removePhysicsCollider(e){_.Physics3D._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";_.Physics3D._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";_.Physics3D._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=_.Physics3D._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=_.Physics3D._bullet;t.btCollisionWorld_removeCollisionObject(this._btCollisionWorld,e._btColliderObject),t.btDynamicsWorld_removeAction(this._btCollisionWorld,e._btKinematicCharacter)}raycastFromTo(e,t,r=null,i=T.COLLISIONFILTERGROUP_ALLFILTER,n=T.COLLISIONFILTERGROUP_ALLFILTER){var a=_.Physics3D._bullet,s=this._btClosestRayResultCallback,o=M._btTempVector30,l=M._btTempVector31;if(a.btVector3_setValue(o,-e.x,e.y,e.z),a.btVector3_setValue(l,-t.x,t.y,t.z),a.ClosestRayResultCallback_set_m_rayFromWorld(s,o),a.ClosestRayResultCallback_set_m_rayToWorld(s,l),a.RayResultCallback_set_m_collisionFilterGroup(s,i),a.RayResultCallback_set_m_collisionFilterMask(s,n),a.RayResultCallback_set_m_collisionObject(s,null),a.RayResultCallback_set_m_closestHitFraction(s,1),a.btCollisionWorld_rayTest(this._btCollisionWorld,o,l,s),a.RayResultCallback_hasHit(s)){if(r){r.succeeded=!0,r.collider=A._physicObjectsMap[a.btCollisionObject_getUserIndex(a.RayResultCallback_get_m_collisionObject(s))],r.hitFraction=a.RayResultCallback_get_m_closestHitFraction(s);var h=a.ClosestRayResultCallback_get_m_hitPointWorld(s),c=r.point;c.x=-a.btVector3_x(h),c.y=a.btVector3_y(h),c.z=a.btVector3_z(h);var d=a.ClosestRayResultCallback_get_m_hitNormalWorld(s),u=r.normal;u.x=-a.btVector3_x(d),u.y=a.btVector3_y(d),u.z=a.btVector3_z(d)}return!0}return r&&(r.succeeded=!1),!1}raycastAllFromTo(e,t,r,i=T.COLLISIONFILTERGROUP_ALLFILTER,n=T.COLLISIONFILTERGROUP_ALLFILTER){var a=_.Physics3D._bullet,s=this._btAllHitsRayResultCallback,o=M._btTempVector30,l=M._btTempVector31;r.length=0,a.btVector3_setValue(o,-e.x,e.y,e.z),a.btVector3_setValue(l,-t.x,t.y,t.z),a.AllHitsRayResultCallback_set_m_rayFromWorld(s,o),a.AllHitsRayResultCallback_set_m_rayToWorld(s,l),a.RayResultCallback_set_m_collisionFilterGroup(s,i),a.RayResultCallback_set_m_collisionFilterMask(s,n);var h=a.AllHitsRayResultCallback_get_m_collisionObjects(s),c=a.AllHitsRayResultCallback_get_m_hitPointWorld(s),d=a.AllHitsRayResultCallback_get_m_hitNormalWorld(s),u=a.AllHitsRayResultCallback_get_m_hitFractions(s);a.tBtCollisionObjectArray_clear(h),a.tVector3Array_clear(c),a.tVector3Array_clear(d),a.tScalarArray_clear(u),a.btCollisionWorld_rayTest(this._btCollisionWorld,o,l,s);var m=a.tBtCollisionObjectArray_size(h);if(m>0){this._collisionsUtils.recoverAllHitResultsPool();for(var f=0;f0){this._collisionsUtils.recoverAllHitResultsPool();for(var v=h.AllConvexResultCallback_get_m_hitPointWorld(c),I=h.AllConvexResultCallback_get_m_hitNormalWorld(c),x=h.AllConvexResultCallback_get_m_hitFractions(c),L=0;L=.64&&(s>1?o=0:o*=1-(s-.64)/.36),a[n]=Math.floor(255*o+.5)}static haloTexture(e,t,r,i,n,a){var s=(e-(r>>=1))/r,o=(t-(i>>=1))/i,l=s*s+o*o;l>1&&(l=1),a[n]=Math.floor(255*(1-l)+.5)}static _generateTexture2D(e,r,i,n){var a=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 n=t.x,a=t.y,s=t.z,o=t.w,l=n+n,_=a+a,h=s+s,c=n*l,d=n*_,u=n*h,m=a*_,f=a*h,T=s*h,E=o*l,p=o*_,g=o*h,S=r.x,R=r.y,v=r.z;i[0]=(1-(m+T))*S,i[1]=(d+g)*S,i[2]=(u-p)*S,i[3]=0,i[4]=(d-g)*R,i[5]=(1-(c+T))*R,i[6]=(f+E)*R,i[7]=0,i[8]=(u+p)*v,i[9]=(f-E)*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,n){var a=t,s=e,o=i,l=a[r],_=a[r+1],h=a[r+2],c=a[r+3],d=a[r+4],u=a[r+5],m=a[r+6],f=a[r+7],T=a[r+8],E=a[r+9],p=a[r+10],g=a[r+11],S=a[r+12],R=a[r+13],v=a[r+14],A=a[r+15],I=s[0],x=s[1],L=s[2],D=s[3],C=s[4],y=s[5],M=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[n]=l*I+_*C+h*N+c*V,o[n+1]=l*x+_*y+h*b+c*B,o[n+2]=l*L+_*M+h*P+c*F,o[n+3]=l*D+_*O+h*w+c*U,o[n+4]=d*I+u*C+m*N+f*V,o[n+5]=d*x+u*y+m*b+f*B,o[n+6]=d*L+u*M+m*P+f*F,o[n+7]=d*D+u*O+m*w+f*U,o[n+8]=T*I+E*C+p*N+g*V,o[n+9]=T*x+E*y+p*b+g*B,o[n+10]=T*L+E*M+p*P+g*F,o[n+11]=T*D+E*O+p*w+g*U,o[n+12]=S*I+R*C+v*N+A*V,o[n+13]=S*x+R*y+v*b+A*B,o[n+14]=S*L+R*M+v*P+A*F,o[n+15]=S*D+R*O+v*w+A*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){a.subtract(t,e,h.TEMPVector30),a.normalize(h.TEMPVector30,h.TEMPVector30),r.x=Math.asin(h.TEMPVector30.y),r.y=N.arcTanAngle(-h.TEMPVector30.z,-h.TEMPVector30.x)}static transformQuat(e,t,r){var i=t,n=e.x,a=e.y,s=e.z,o=i[0],l=i[1],_=i[2],h=i[3],c=h*n+l*s-_*a,d=h*a+_*n-o*s,u=h*s+o*a-l*n,m=-o*n-l*a-_*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,n=e.y,a=e.z;r.x=i>0?Math.pow(Math.abs(i),t):-Math.pow(Math.abs(i),t),r.y=n>0?Math.pow(Math.abs(n),t):-Math.pow(Math.abs(n),t),r.z=a>0?Math.pow(Math.abs(a),t):-Math.pow(Math.abs(a),t)}static scaleBlend(e,t,r,i){var n=N._tempVector3_0,a=N._tempVector3_1;N.scaleWeight(e,1-r,n),N.scaleWeight(t,r,a);var s=r>.5?t:e;i.x=s.x>0?Math.abs(n.x*a.x):-Math.abs(n.x*a.x),i.y=s.y>0?Math.abs(n.y*a.y):-Math.abs(n.y*a.y),i.z=s.z>0?Math.abs(n.z*a.z):-Math.abs(n.z*a.z)}static matrix4x4MultiplyFFF(e,t,r){var i,n,a,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],T=t[8],E=t[9],p=t[10],g=t[11],S=t[12],R=t[13],v=t[14],A=t[15];for(i=0;i<4;i++)n=e[i],a=e[i+4],s=e[i+8],o=e[i+12],r[i]=n*l+a*_+s*h+o*c,r[i+4]=n*d+a*u+s*m+o*f,r[i+8]=n*T+a*E+s*p+o*g,r[i+12]=n*S+a*R+s*v+o*A}static matrix4x4MultiplyFFFForNative(e,r,i){t.LayaGL.instance.matrix4x4Multiply(e,r,i)}static matrix4x4MultiplyMFM(e,t,r){N.matrix4x4MultiplyFFF(e.elements,t,r.elements)}static _buildTexture2D(e,r,i,n,a=!1){var s=new t.Texture2D(e,r,i,a,!0);return s.anisoLevel=1,s.filterMode=t.FilterMode.Point,O._generateTexture2D(s,e,r,n),s}static _drawBound(e,t,r){e.lineCount+12>e.maxLineCount&&(e.maxLineCount+=12);var i=N._tempVector3_0,n=N._tempVector3_1,a=t.min,s=t.max;i.setValue(a.x,a.y,a.z),n.setValue(s.x,a.y,a.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,a.z),n.setValue(a.x,a.y,s.z),e.addLine(i,n,r,r),i.setValue(s.x,a.y,a.z),n.setValue(s.x,a.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,s.z),n.setValue(s.x,a.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,a.z),n.setValue(a.x,s.y,a.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,s.z),n.setValue(a.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(s.x,a.y,a.z),n.setValue(s.x,s.y,a.z),e.addLine(i,n,r,r),i.setValue(s.x,a.y,s.z),n.setValue(s.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,s.y,a.z),n.setValue(s.x,s.y,a.z),e.addLine(i,n,r,r),i.setValue(a.x,s.y,a.z),n.setValue(a.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(s.x,s.y,a.z),n.setValue(s.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,s.y,s.z),n.setValue(s.x,s.y,s.z),e.addLine(i,n,r,r)}static _getHierarchyPath(e,t,r){r.length=0;for(var i=t;i!==e;){var n=i._parent;if(!n)return null;r.push(n.getChildIndex(i)),i=n}return r}static _getNodeByHierarchyPath(e,t){for(var r=e,i=t.length-1;i>=0;i--)r=r.getChildAt(t[i]);return r}}N._tempVector3_0=new a,N._tempVector3_1=new a,N._tempArray16_0=new Float32Array(16),N._tempArray16_1=new Float32Array(16),N._tempArray16_2=new Float32Array(16),N._tempArray16_3=new Float32Array(16),N._compIdToNode=new Object;class b extends A{constructor(e=.1,t=null,r=T.COLLISIONFILTERGROUP_DEFAULTFILTER,i=T.COLLISIONFILTERGROUP_ALLFILTER){super(r,i),this._upAxis=new a(0,1,0),this._maxSlope=45,this._jumpSpeed=10,this._fallSpeed=55,this._gravity=new a(0,3*-9.8,0),this._btKinematicCharacter=null,this._stepHeight=e,t&&(this._upAxis=t),this._controlBySimulation=!0}static __init__(){b._btTempVector30=_.Physics3D._bullet.btVector3_create(0,0,0)}get fallSpeed(){return this._fallSpeed}set fallSpeed(e){this._fallSpeed=e,_.Physics3D._bullet.btKinematicCharacterController_setFallSpeed(this._btKinematicCharacter,e)}get jumpSpeed(){return this._jumpSpeed}set jumpSpeed(e){this._jumpSpeed=e,_.Physics3D._bullet.btKinematicCharacterController_setJumpSpeed(this._btKinematicCharacter,e)}get gravity(){return this._gravity}set gravity(e){this._gravity=e;var t=_.Physics3D._bullet,r=b._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,_.Physics3D._bullet.btKinematicCharacterController_setMaxSlope(this._btKinematicCharacter,e/180*Math.PI)}get isGrounded(){return _.Physics3D._bullet.btKinematicCharacterController_onGround(this._btKinematicCharacter)}get stepHeight(){return this._stepHeight}set stepHeight(e){this._stepHeight=e,_.Physics3D._bullet.btKinematicCharacterController_setStepHeight(this._btKinematicCharacter,e)}get upAxis(){return this._upAxis}set upAxis(e){this._upAxis=e;var t=b._btTempVector30;N._convertToBulletVec3(e,t,!1),_.Physics3D._bullet.btKinematicCharacterController_setUp(this._btKinematicCharacter,t)}_constructCharacter(){var e=_.Physics3D._bullet;this._btKinematicCharacter&&e.btKinematicCharacterController_destroy(this._btKinematicCharacter);var t=b._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=_.Physics3D._bullet,t=e.btPairCachingGhostObject_create();e.btCollisionObject_setUserIndex(t,this.id),e.btCollisionObject_setCollisionFlags(t,A.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(){_.Physics3D._bullet.btKinematicCharacterController_destroy(this._btKinematicCharacter),super._onDestroy(),this._btKinematicCharacter=null}move(e){var t=b._btVector30,r=_.Physics3D._bullet;r.btVector3_setValue(t,-e.x,e.y,e.z),r.btKinematicCharacterController_setWalkDirection(this._btKinematicCharacter,t)}jump(e=null){var t=_.Physics3D._bullet,r=b._btVector30;e?(N._convertToBulletVec3(e,r,!0),t.btKinematicCharacterController_jump(this._btKinematicCharacter,r)):(t.btVector3_setValue(r,0,0,0),t.btKinematicCharacterController_jump(this._btKinematicCharacter,r))}}b.UPAXIS_X=0,b.UPAXIS_Y=1,b.UPAXIS_Z=2;class P extends A{constructor(e,t){super(e,t),this._isTrigger=!1}get isTrigger(){return this._isTrigger}set isTrigger(e){this._isTrigger=e;var t=_.Physics3D._bullet;if(this._btColliderObject){var r=t.btCollisionObject_getCollisionFlags(this._btColliderObject);e?0==(r&A.COLLISIONFLAGS_NO_CONTACT_RESPONSE)&&t.btCollisionObject_setCollisionFlags(this._btColliderObject,r|A.COLLISIONFLAGS_NO_CONTACT_RESPONSE):0!=(r&A.COLLISIONFLAGS_NO_CONTACT_RESPONSE)&&t.btCollisionObject_setCollisionFlags(this._btColliderObject,r^A.COLLISIONFLAGS_NO_CONTACT_RESPONSE)}}_onAdded(){super._onAdded(),this.isTrigger=this._isTrigger}_cloneTo(e){super._cloneTo(e),e.isTrigger=this._isTrigger}}class w extends P{constructor(e=T.COLLISIONFILTERGROUP_DEFAULTFILTER,t=T.COLLISIONFILTERGROUP_ALLFILTER){super(e,t),this._isKinematic=!1,this._mass=1,this._gravity=new a(0,-10,0),this._angularDamping=0,this._linearDamping=0,this._overrideGravity=!1,this._totalTorque=new a(0,0,0),this._totalForce=new a(0,0,0),this._linearVelocity=new a,this._angularVelocity=new a,this._linearFactor=new a(1,1,1),this._angularFactor=new a(1,1,1),this._detectCollisions=!0,this._controlBySimulation=!0}static __init__(){var e=_.Physics3D._bullet;w._btTempVector30=e.btVector3_create(0,0,0),w._btTempVector31=e.btVector3_create(0,0,0),w._btVector3Zero=e.btVector3_create(0,0,0),w._btInertia=e.btVector3_create(0,0,0),w._btImpulse=e.btVector3_create(0,0,0),w._btImpulseOffset=e.btVector3_create(0,0,0),w._btGravity=e.btVector3_create(0,0,0),w._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=_.Physics3D._bullet,r=!!(this._simulation&&this._enabled&&this._colliderShape);r&&this._removeFromSimulation();var i=this._btColliderObject,n=t.btCollisionObject_getCollisionFlags(i);e?(n|=A.COLLISIONFLAGS_KINEMATIC_OBJECT,t.btCollisionObject_setCollisionFlags(i,n),t.btCollisionObject_forceActivationState(this._btColliderObject,A.ACTIVATIONSTATE_DISABLE_DEACTIVATION),this._enableProcessCollisions=!1,this._updateMass(0)):((n&A.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(n^=A.COLLISIONFLAGS_KINEMATIC_OBJECT),t.btCollisionObject_setCollisionFlags(i,n),t.btCollisionObject_setActivationState(this._btColliderObject,A.ACTIVATIONSTATE_ACTIVE_TAG),this._enableProcessCollisions=!0,this._updateMass(this._mass));var a=w._btVector3Zero;t.btCollisionObject_setInterpolationLinearVelocity(i,a),t.btRigidBody_setLinearVelocity(i,a),t.btCollisionObject_setInterpolationAngularVelocity(i,a),t.btRigidBody_setAngularVelocity(i,a),r&&this._addToSimulation()}get linearDamping(){return this._linearDamping}set linearDamping(e){this._linearDamping=e,this._btColliderObject&&_.Physics3D._bullet.btRigidBody_setDamping(this._btColliderObject,e,this._angularDamping)}get angularDamping(){return this._angularDamping}set angularDamping(e){this._angularDamping=e,this._btColliderObject&&_.Physics3D._bullet.btRigidBody_setDamping(this._btColliderObject,this._linearDamping,e)}get overrideGravity(){return this._overrideGravity}set overrideGravity(e){this._overrideGravity=e;var t=_.Physics3D._bullet;if(this._btColliderObject){var r=t.btRigidBody_getFlags(this._btColliderObject);e?0==(r&w._BT_DISABLE_WORLD_GRAVITY)&&t.btRigidBody_setFlags(this._btColliderObject,r|w._BT_DISABLE_WORLD_GRAVITY):(r&w._BT_DISABLE_WORLD_GRAVITY)>0&&t.btRigidBody_setFlags(this._btColliderObject,r^w._BT_DISABLE_WORLD_GRAVITY)}}get gravity(){return this._gravity}set gravity(e){this._gravity=e;var t=_.Physics3D._bullet;t.btVector3_setValue(w._btGravity,-e.x,e.y,e.z),t.btRigidBody_setGravity(this._btColliderObject,w._btGravity)}get totalForce(){if(this._btColliderObject){var e=_.Physics3D._bullet.btRigidBody_getTotalForce(this._btColliderObject);return N._convertToLayaVec3(e,this._totalForce,!0),this._totalForce}return null}get linearFactor(){return this._linearFactor}set linearFactor(e){this._linearFactor=e;var t=w._btTempVector30;N._convertToBulletVec3(e,t,!1),_.Physics3D._bullet.btRigidBody_setLinearFactor(this._btColliderObject,t)}get linearVelocity(){return this._btColliderObject&&N._convertToLayaVec3(_.Physics3D._bullet.btRigidBody_getLinearVelocity(this._btColliderObject),this._linearVelocity,!0),this._linearVelocity}set linearVelocity(e){if(this._linearVelocity=e,this._btColliderObject){var t=w._btTempVector30;N._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),_.Physics3D._bullet.btRigidBody_setLinearVelocity(this._btColliderObject,t)}}get angularFactor(){return this._angularFactor}set angularFactor(e){this._angularFactor=e;var t=w._btTempVector30;N._convertToBulletVec3(e,t,!1),_.Physics3D._bullet.btRigidBody_setAngularFactor(this._btColliderObject,t)}get angularVelocity(){return this._btColliderObject&&N._convertToLayaVec3(_.Physics3D._bullet.btRigidBody_getAngularVelocity(this._btColliderObject),this._angularVelocity,!0),this._angularVelocity}set angularVelocity(e){if(this._angularVelocity=e,this._btColliderObject){var t=w._btTempVector30;N._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),_.Physics3D._bullet.btRigidBody_setAngularVelocity(this._btColliderObject,t)}}get totalTorque(){if(this._btColliderObject){var e=_.Physics3D._bullet.btRigidBody_getTotalTorque(this._btColliderObject);return N._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&&_.Physics3D._bullet.btCollisionObject_getActivationState(this._btColliderObject)===A.ACTIVATIONSTATE_ISLAND_SLEEPING}get sleepLinearVelocity(){return _.Physics3D._bullet.btRigidBody_getLinearSleepingThreshold(this._btColliderObject)}set sleepLinearVelocity(e){var t=_.Physics3D._bullet;t.btRigidBody_setSleepingThresholds(this._btColliderObject,e,t.btRigidBody_getAngularSleepingThreshold(this._btColliderObject))}get sleepAngularVelocity(){return _.Physics3D._bullet.btRigidBody_getAngularSleepingThreshold(this._btColliderObject)}set sleepAngularVelocity(e){var t=_.Physics3D._bullet;t.btRigidBody_setSleepingThresholds(this._btColliderObject,t.btRigidBody_getLinearSleepingThreshold(this._btColliderObject),e)}get btColliderObject(){return this._btColliderObject}set constaintRigidbodyA(e){this._constaintRigidbodyA=e}get constaintRigidbodyA(){return this._constaintRigidbodyA}set constaintRigidbodyB(e){this._constaintRigidbodyB=e}get constaintRigidbodyB(){return this._constaintRigidbodyB}_updateMass(e){if(this._btColliderObject&&this._colliderShape){var t=_.Physics3D._bullet;t.btCollisionShape_calculateLocalInertia(this._colliderShape._btShape,e,w._btInertia),t.btRigidBody_setMassProps(this._btColliderObject,e,w._btInertia),t.btRigidBody_updateInertiaTensor(this._btColliderObject)}}_onScaleChange(e){super._onScaleChange(e),this._updateMass(this._isKinematic?0:this._mass)}_derivePhysicsTransformation(e){var t=_.Physics3D._bullet,r=this._btColliderObject,i=t.btCollisionObject_getWorldTransform(r),n=w._btTransform0;t.btTransform_equal(n,i),this._innerDerivePhysicsTransformation(n,e),t.btRigidBody_setCenterOfMassTransform(r,n)}_onAdded(){var e=_.Physics3D._bullet,t=e.layaMotionState_create();e.layaMotionState_set_rigidBodyID(t,this._id),this._btLayaMotionState=t;var r=e.btRigidBodyConstructionInfo_create(0,t,null,w._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)}_onEnable(){super._onEnable(),this._constaintRigidbodyA&&this._constaintRigidbodyA.connectedBody._simulation&&(this._constaintRigidbodyA._createConstraint(),this._constaintRigidbodyA._onEnable()),this._constaintRigidbodyB&&this._constaintRigidbodyB.ownBody._simulation&&(this._constaintRigidbodyB._createConstraint(),this._constaintRigidbodyB._onEnable())}_onShapeChange(e){if(super._onShapeChange(e),this._isKinematic)this._updateMass(0);else{var t=_.Physics3D._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.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),null!=e.isKinematic&&(this._isKinematic=e.isKinematic)}_onDestroy(){_.Physics3D._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,this.constaintRigidbodyA&&this.constaintRigidbodyA._breakConstrained(),this.constaintRigidbodyB&&(this.constaintRigidbodyB.connectedBody=null,this.constaintRigidbodyB._onDisable())}_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=_.Physics3D._bullet,i=w._btTempVector30;if(r.btVector3_setValue(i,-e.x,e.y,e.z),t){var n=w._btTempVector31;r.btVector3_setValue(n,-t.x,t.y,t.z),r.btRigidBody_applyForce(this._btColliderObject,i,n)}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=_.Physics3D._bullet,r=w._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=_.Physics3D._bullet;r.btVector3_setValue(w._btImpulse,-e.x,e.y,e.z),t?(r.btVector3_setValue(w._btImpulseOffset,-t.x,t.y,t.z),r.btRigidBody_applyImpulse(this._btColliderObject,w._btImpulse,w._btImpulseOffset)):r.btRigidBody_applyCentralImpulse(this._btColliderObject,w._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=_.Physics3D._bullet,r=w._btTempVector30;t.btVector3_setValue(r,-e.x,e.y,e.z),t.btRigidBody_applyTorqueImpulse(this._btColliderObject,r)}wakeUp(){this._btColliderObject&&_.Physics3D._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=_.Physics3D._bullet;t.btRigidBody_clearForces(e);var r=w._btVector3Zero;t.btCollisionObject_setInterpolationLinearVelocity(e,r),t.btRigidBody_setLinearVelocity(e,r),t.btCollisionObject_setInterpolationAngularVelocity(e,r),t.btRigidBody_setAngularVelocity(e,r)}}w.TYPE_STATIC=0,w.TYPE_DYNAMIC=1,w.TYPE_KINEMATIC=2,w._BT_DISABLE_WORLD_GRAVITY=1,w._BT_ENABLE_GYROPSCOPIC_FORCE=2;class V{static __bulletinit__(){this._bullet=window.Physics3D,this._bullet&&(u.__init__(),d.__init__(),m.__init__(),A.__init__(),M.__init__(),E.__init__(),S.__init__(),b.__init__(),w.__init__())}static __cannoninit__(){this._cannon=window.CANNON,this._cannon&&(t.CannonColliderShape.__init__(),t.CannonPhysicsComponent.__init__(),t.CannonPhysicsSimulation.__init__(),t.CannonBoxColliderShape.__init__(),t.CannonRigidbody3D.__init__())}}V._bullet=null,V._cannon=null,V._enablePhysics=!1;class B{constructor(){this._defaultPhysicsMemory=16,this._maxLightCount=32,this._lightClusterCount=new a(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 a(0,0,0),this.octreeMinNodeSize=2,this.octreeLooseness=1.25,this.debugFrustumCulling=!1,this.pbrRenderQuality=e.PBRRenderQuality.High,this.isUseCannonPhysicsEngine=!1,this._maxAreaLightCountPerClusterAverage=Math.min(4*Math.floor(2048/this._lightClusterCount.z-1),this._maxLightCount)}static get useCannonPhysics(){return B._config.isUseCannonPhysicsEngine}static set useCannonPhysics(e){B._config.isUseCannonPhysicsEngine=e,e&&(V.__cannoninit__(),_.Scene3D.cannonPhysicsSettings||(_.Scene3D.cannonPhysicsSettings=new t.CannonPhysicsSettings))}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&&(b.params=N=[]),r=0;r>-t-14,X._baseTable[256|e]=1024>>-t-14|32768,X._shiftTable[0|e]=-t-1,X._shiftTable[256|e]=-t-1):t<=15?(X._baseTable[0|e]=t+15<<10,X._baseTable[256|e]=t+15<<10|32768,X._shiftTable[0|e]=13,X._shiftTable[256|e]=13):t<128?(X._baseTable[0|e]=31744,X._baseTable[256|e]=64512,X._shiftTable[0|e]=24,X._shiftTable[256|e]=24):(X._baseTable[0|e]=31744,X._baseTable[256|e]=64512,X._shiftTable[0|e]=13,X._shiftTable[256|e]=13)}for(X._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,X._mantissaTable[e]=r|t}for(e=1024;e<2048;++e)X._mantissaTable[e]=939524096+(e-1024<<13);for(X._exponentTable[0]=0,e=1;e<31;++e)X._exponentTable[e]=e<<23;for(X._exponentTable[31]=1199570944,X._exponentTable[32]=2147483648,e=33;e<63;++e)X._exponentTable[e]=2147483648+(e-32<<23);for(X._exponentTable[63]=3347054592,X._offsetTable[0]=0,e=1;e<64;++e)X._offsetTable[e]=32===e?0:1024}static roundToFloat16Bits(e){X._floatView[0]=e;var t=X._uint32View[0],r=t>>23&511;return X._baseTable[r]+((8388607&t)>>X._shiftTable[r])}static convertToNumber(e){var t=e>>10;return X._uint32View[0]=X._mantissaTable[X._offsetTable[t]+(1023&e)]+X._exponentTable[t],X._floatView[0]}}X._buffer=new ArrayBuffer(4),X._floatView=new Float32Array(X._buffer),X._uint32View=new Uint32Array(X._buffer),X._baseTable=new Uint32Array(512),X._shiftTable=new Uint32Array(512),X._mantissaTable=new Uint32Array(2048),X._exponentTable=new Uint32Array(64),X._offsetTable=new Uint32Array(64);class Y{static READ_DATA(){Y._DATA.offset=Y._reader.getUint32(),Y._DATA.size=Y._reader.getUint32()}static READ_BLOCK(){for(var e=Y._BLOCK.count=Y._reader.getUint16(),t=Y._BLOCK.blockStarts=[],r=Y._BLOCK.blockLengths=[],i=0;i0&&(b.params=N=[]),r=0;rt);)m++,l++,r[s]=m;else for((l=m+1)!==u&&t>d[l].time&&(m=u-1,r[s]=m),l=m+1;m>-1&&!(d[m].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}}Z.ANIMATIONCLIP="ANIMATIONCLIP",Z._tempQuaternion0=new h;class q{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 Q{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 q,this._crossPlayStateInfo=new q,this.blendingMode=Q.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 n=i._clip,a=e[r];if(e.splice(r,1),delete t[i.name],this._animator){var s=n._nodes,o=a._nodeOwners;n._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]*n,i[1]=r[1]*n,i[2]=r[2]*n,i[3]=r[3]*n)}static add(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3]}static subtract(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]-a[0],i[1]=n[1]-a[1],i[2]=n[2]-a[2],i[3]=n[3]-a[3]}static multiply(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]*a[0],i[1]=n[1]*a[1],i[2]=n[2]*a[2],i[3]=n[3]*a[3]}static scale(e,t,r){var i=r.elements,n=e.elements;i[0]=n[0]*t,i[1]=n[1]*t,i[2]=n[2]*t,i[3]=n[3]*t}static Clamp(e,t,r,i){var n=e.elements,a=n[0],s=n[1],o=n[2],l=n[3],_=t.elements,h=_[0],c=_[1],d=_[2],u=_[3],m=r.elements,f=m[0],T=m[1],E=m[2],p=m[3],g=i.elements;a=(a=a>f?f:a)T?T:s)E?E: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,n=e.elements,a=t.elements;i[0]=n[0]*a[0],i[1]=n[1]*a[1],i[2]=n[2]*a[2]}static scale(e,t,r){var i=r.elements,n=e.elements;i[0]=n[0]*t,i[1]=n[1]*t,i[2]=n[2]*t}static lerp(e,t,r,i){var n=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],_=a[2];n[0]=o+r*(s[0]-o),n[1]=l+r*(s[1]-l),n[2]=_+r*(s[2]-_)}static transformV3ToV3(e,t,r){var i=J._tempVector4;J.transformV3ToV4(e,t,i);var n=i.elements,a=r.elements;a[0]=n[0],a[1]=n[1],a[2]=n[2]}static transformV3ToV4(e,t,r){var i=e.elements,n=i[0],a=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=n*o[0]+a*o[4]+s*o[8]+o[12],l[1]=n*o[1]+a*o[5]+s*o[9]+o[13],l[2]=n*o[2]+a*o[6]+s*o[10]+o[14],l[3]=n*o[3]+a*o[7]+s*o[11]+o[15]}static TransformNormal(e,t,r){var i=e.elements,n=i[0],a=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=n*o[0]+a*o[4]+s*o[8],l[1]=n*o[1]+a*o[5]+s*o[9],l[2]=n*o[2]+a*o[6]+s*o[10]}static transformCoordinate(e,t,r){var i=e.elements,n=i[0],a=i[1],s=i[2],o=t.elements,l=n*o[3]+a*o[7]+s*o[11]+o[15],_=r.elements;_[0]=n*o[0]+a*o[4]+s*o[8]+o[12]/l,_[1]=n*o[1]+a*o[5]+s*o[9]+o[13]/l,_[2]=n*o[2]+a*o[6]+s*o[10]+o[14]/l}static Clamp(e,t,r,i){var n=e.elements,a=n[0],s=n[1],o=n[2],l=t.elements,_=l[0],h=l[1],c=l[2],d=r.elements,u=d[0],m=d[1],f=d[2],T=i.elements;a=(a=a>u?u:a)<_?_:a,s=(s=s>m?m:s)f?f:o)0&&(s=1/Math.sqrt(s),t[0]=r*s,t[1]=i*s,t[2]=n*s,t[3]=a*s)}static _lerpArray(e,t,r,i){var n=1-r;$._dotArray(e,t)>=0?(i[0]=n*e[0]+r*t[0],i[1]=n*e[1]+r*t[1],i[2]=n*e[2]+r*t[2],i[3]=n*e[3]+r*t[3]):(i[0]=n*e[0]-r*t[0],i[1]=n*e[1]-r*t[1],i[2]=n*e[2]-r*t[2],i[3]=n*e[3]-r*t[3]),$._normalizeArray(i,i)}static createFromYawPitchRoll(e,t,r,i){var n=.5*r,a=.5*t,s=.5*e,o=Math.sin(n),l=Math.cos(n),_=Math.sin(a),h=Math.cos(a),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,n=t.elements,a=r.elements,s=i[0],o=i[1],l=i[2],_=i[3],h=n[0],c=n[1],d=n[2],u=n[3],m=o*d-l*c,f=l*h-s*d,T=s*c-o*h,E=s*h+o*c+l*d;a[0]=s*u+h*_+m,a[1]=o*u+c*_+f,a[2]=l*u+d*_+T,a[3]=_*u-E}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){J.subtract(t,e,$.TEMPVector30),J.normalize($.TEMPVector30,$.TEMPVector30),r.elements[0]=Math.asin($.TEMPVector30.y),r.elements[1]=$.arcTanAngle(-$.TEMPVector30.z,-$.TEMPVector30.x)}static createFromAxisAngle(e,t,r){var i=r.elements,n=e.elements;t*=.5;var a=Math.sin(t);i[0]=a*n[0],i[1]=a*n[1],i[2]=a*n[2],i[3]=Math.cos(t)}static createFromMatrix3x3(e,t){var r,i=t.elements,n=e.elements,a=n[0]+n[4]+n[8];if(a>0)r=Math.sqrt(a+1),i[3]=.5*r,r=.5/r,i[0]=(n[5]-n[7])*r,i[1]=(n[6]-n[2])*r,i[2]=(n[1]-n[3])*r;else{var s=0;n[4]>n[0]&&(s=1),n[8]>n[3*s+s]&&(s=2);var o=(s+1)%3,l=(s+2)%3;r=Math.sqrt(n[3*s+s]-n[3*o+o]-n[3*l+l]+1),i[s]=.5*r,r=.5/r,i[3]=(n[3*o+l]-n[3*l+o])*r,i[o]=(n[3*o+s]+n[3*s+o])*r,i[l]=(n[3*l+s]+n[3*s+l])*r}}static createFromMatrix4x4(e,t){var r,i,n=e.elements,a=t.elements,s=n[0]+n[5]+n[10];s>0?(r=Math.sqrt(s+1),a[3]=.5*r,r=.5/r,a[0]=(n[6]-n[9])*r,a[1]=(n[8]-n[2])*r,a[2]=(n[1]-n[4])*r):n[0]>=n[5]&&n[0]>=n[10]?(i=.5/(r=Math.sqrt(1+n[0]-n[5]-n[10])),a[0]=.5*r,a[1]=(n[1]+n[4])*i,a[2]=(n[2]+n[8])*i,a[3]=(n[6]-n[9])*i):n[5]>n[10]?(i=.5/(r=Math.sqrt(1+n[5]-n[0]-n[10])),a[0]=(n[4]+n[1])*i,a[1]=.5*r,a[2]=(n[9]+n[6])*i,a[3]=(n[8]-n[2])*i):(i=.5/(r=Math.sqrt(1+n[10]-n[0]-n[5])),a[0]=(n[8]+n[2])*i,a[1]=(n[9]+n[6])*i,a[2]=.5*r,a[3]=(n[1]-n[4])*i)}static slerp(e,t,r,i){var n,a,s,o,l,_=e.elements,h=t.elements,c=i.elements,d=_[0],u=_[1],m=_[2],f=_[3],T=h[0],E=h[1],p=h[2],g=h[3];return(a=d*T+u*E+m*p+f*g)<0&&(a=-a,T=-T,E=-E,p=-p,g=-g),1-a>1e-6?(n=Math.acos(a),s=Math.sin(n),o=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(o=1-r,l=r),c[0]=o*d+l*T,c[1]=o*u+l*E,c[2]=o*m+l*p,c[3]=o*f+l*g,c}static lerp(e,t,r,i){$._lerpArray(e.elements,t.elements,r,i.elements)}static add(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3]}static dot(e,t){return $._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){$._normalizeArray(this.elements,e.elements)}length(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3];return Math.sqrt(t*t+r*r+i*i+n*n)}rotateX(e,t){var r=t.elements,i=this.elements;e*=.5;var n=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=n*_+o*l,r[1]=a*_+s*l,r[2]=s*_-a*l,r[3]=o*_-n*l}rotateY(e,t){var r=t.elements,i=this.elements;e*=.5;var n=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=n*_-s*l,r[1]=a*_+o*l,r[2]=s*_+n*l,r[3]=o*_-a*l}rotateZ(e,t){var r=t.elements,i=this.elements;e*=.5;var n=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=n*_+a*l,r[1]=a*_-n*l,r[2]=s*_+o*l,r[3]=o*_-s*l}getYawPitchRoll(e){J.transformQuat(J.ForwardRH,this,$.TEMPVector31),J.transformQuat(J.Up,this,$.TEMPVector32);var t=$.TEMPVector32.elements;$.angleTo(J.ZERO,$.TEMPVector31,$.TEMPVector33);var r=$.TEMPVector33.elements;r[0]==Math.PI/2?(r[1]=$.arcTanAngle(t[2],t[0]),r[2]=0):r[0]==-Math.PI/2?(r[1]=$.arcTanAngle(-t[2],-t[0]),r[2]=0):(c.createRotationY(-r[1],$.TEMPMatrix0),c.createRotationX(-r[0],$.TEMPMatrix1),J.transformCoordinate($.TEMPVector32,$.TEMPMatrix0,$.TEMPVector32),J.transformCoordinate($.TEMPVector32,$.TEMPMatrix1,$.TEMPVector32),r[2]=$.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],n=r[1],a=r[2],s=r[3],o=i*i+n*n+a*a+s*s,l=o?1/o:0;t[0]=-i*l,t[1]=-n*l,t[2]=-a*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 $;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){$.lookAt(J.ZERO,e,t,r)}static lookAt(e,t,r,i){l.lookAt(e,t,r,$._tempMatrix3x3),$.rotationMatrix($._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,n=t.elements,a=e.lengthSquared();r.isZero(a)||(a=1/a,n[0]=-i[0]*a,n[1]=-i[1]*a,n[2]=-i[2]*a,n[3]=i[3]*a)}static rotationMatrix(e,t){var r,i,n=e.elements,a=n[0],s=n[1],o=n[2],l=n[3],_=n[4],h=n[5],c=n[6],d=n[7],u=n[8],m=t.elements,f=a+_+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):a>=_&&a>=u?(i=.5/(r=Math.sqrt(1+a-_-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+_-a-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-a-_)),m[0]=(c+o)*i,m[1]=(d+h)*i,m[2]=.5*r,m[3]=(s-l)*i)}}$.TEMPVector30=new J,$.TEMPVector31=new J,$.TEMPVector32=new J,$.TEMPVector33=new J,$.TEMPMatrix0=new c,$.TEMPMatrix1=new c,$._tempMatrix3x3=new l,$.DEFAULT=new $,$.NAN=new $(NaN,NaN,NaN,NaN);class ee{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,n=i.count;this._currentFrameIndices=new Int16Array(n),this._resetFrameIndices(),this._referenceCount>0&&e._addReference(this._referenceCount),this._realtimeDatas.length=n;for(var s=0;s=n){if(t._finish=!0,t._elapsedTime=n,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,n,t._playEventIndex,l>0?a:o,!0);for(var h=0,c=l-1;h0&&o>0&&(t._playEventIndex=this._eventScript(r,n,0,o,!0))}else{t._playEventIndex=this._eventScript(r,n,t._playEventIndex,l>0?0:o,!1);var d=n.length-1;for(h=0,c=l-1;h0&&o>0&&(t._playEventIndex=this._eventScript(r,n,d,o,!1))}}}_updateClipDatas(e,t,r,i){var n=e._clip,a=n._duration,s=e.clipStart*a+r._normalizedPlayTime*r._duration,o=e._currentFrameIndices,l=r._elapsedTime>r._lastElapsedTime;n._evaluateClipDatasRealTime(n._nodes,s,o,t,l,e._realtimeDatas)}_applyFloat(e,t,r,i,n,a,s){if(r.updateMark===this._updateMark)if(i)e[t]+=n*s;else{var o=e[t];e[t]=o+n*(s-o)}else if(a)e[t]=i?r.defaultValue+s:s;else if(i)e[t]=r.defaultValue+n*s;else{var l=r.defaultValue;e[t]=l+n*(s-l)}}_applyPositionAndRotationEuler(e,t,r,i,n,a){if(e.updateMark===this._updateMark)if(t)a.x+=r*n.x,a.y+=r*n.y,a.z+=r*n.z;else{var s=a.x,o=a.y,l=a.z;a.x=s+r*(n.x-s),a.y=o+r*(n.y-o),a.z=l+r*(n.z-l)}else if(i)if(t){var _=e.defaultValue;a.x=_.x+n.x,a.y=_.y+n.y,a.z=_.z+n.z}else a.x=n.x,a.y=n.y,a.z=n.z;else if(_=e.defaultValue,t)a.x=_.x+r*n.x,a.y=_.y+r*n.y,a.z=_.z+r*n.z;else{var h=_.x,c=_.y,d=_.z;a.x=h+r*(n.x-h),a.y=c+r*(n.y-c),a.z=d+r*(n.z-d)}}_applyRotation(e,t,r,i,n,a){if(e.updateMark===this._updateMark)if(t){var s=re._tempQuaternion1;N.quaternionWeight(n,r,s),s.normalize(s),h.multiply(a,s,a)}else h.lerp(a,n,r,a);else if(i)if(t){var o=e.defaultValue;h.multiply(o,n,a)}else a.x=n.x,a.y=n.y,a.z=n.z,a.w=n.w;else o=e.defaultValue,t?(s=re._tempQuaternion1,N.quaternionWeight(n,r,s),s.normalize(s),h.multiply(o,s,a)):h.lerp(o,n,r,a)}_applyScale(e,t,r,i,n,a){if(e.updateMark===this._updateMark)if(t){var s=re._tempVector31;N.scaleWeight(n,r,s),a.x=a.x*s.x,a.y=a.y*s.y,a.z=a.z*s.z}else N.scaleBlend(a,n,r,a);else if(i)if(t){var o=e.defaultValue;a.x=o.x*n.x,a.y=o.y*n.y,a.z=o.z*n.z}else a.x=n.x,a.y=n.y,a.z=n.z;else o=e.defaultValue,t?(s=re._tempVector31,N.scaleWeight(n,r,s),a.x=o.x*s.x,a.y=o.y*s.y,a.z=o.z*s.z):N.scaleBlend(o,n,r,a)}_applyCrossData(e,t,r,i,n,a,s){var o=e.propertyOwner;if(o){switch(e.type){case 0:for(var l=e.property,_=l.length-1,c=0;c<_&&(o=o[l[c]]);c++);var d=n+s*(a-n);e.value=d,this._applyFloat(o,l[_],e,t,r,i,d);break;case 1:var u=o.localPosition,m=e.value,f=n.x,T=n.y,E=n.z;m.x=f+s*(a.x-f),m.y=T+s*(a.y-T),m.z=E+s*(a.z-E),this._applyPositionAndRotationEuler(e,t,r,i,m,u),o.localPosition=u;break;case 2:var p=o.localRotation,g=e.value;h.lerp(n,a,s,g),this._applyRotation(e,t,r,i,g,p),o.localRotation=p;break;case 3:var S=o.localScale,R=e.value;N.scaleBlend(n,a,s,R),this._applyScale(e,t,r,i,R,S),o.localScale=S;break;case 4:var v=o.localRotationEuler,A=e.value;f=n.x,T=n.y,E=n.z,A.x=f+s*(a.x-f),A.y=T+s*(a.y-T),A.z=E+s*(a.z-E),this._applyPositionAndRotationEuler(e,t,r,i,A,v),o.localRotationEuler=v}e.updateMark=this._updateMark}}_setClipDatasToNode(e,t,r,i){for(var n=e._realtimeDatas,a=e._clip._nodes,s=e._nodeOwners,o=0,l=a.count;og?g/E:1,R=this._speed*f.speed;this._updatePlayer(f,_,r*S*R,T.islooping);var v=(_._elapsedTime-p)/S/E;v>=1?i&&(this._updateClipDatas(f,m,_,s*R),this._setClipDatasToNode(f,m,o.defaultWeight,0===n),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===n))),i&&(this._updateEventScript(h,l),this._updateEventScript(f,_));break;case 2:T=(f=o._crossPlayState)._clip,E=o._crossDuration,p=_._startPlayTime,S=E>(g=T._duration-p)?g/E:1,R=this._speed*f.speed,this._updatePlayer(f,_,r*S*R,T.islooping),i&&((v=(_._elapsedTime-p)/S/E)>=1?(this._updateClipDatas(f,m,_,s*R),this._setClipDatasToNode(f,m,1,0===n),o._playType=0,l._currentState=f,_._cloneTo(l)):(this._updateClipDatas(f,m,_,s*S*R),this._setFixedCrossClipDatasToNode(o,f,v,0===n)),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 n=r[i]&t[i];0==n&&i==this._length-1?this._length--:r[i]=n}}add(e){var t=e._index,r=t+1,i=this._mask,n=this._length;if(nthis._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 n=r[t]&~e._value;t==i&&0===n?this._length--:r[t]=n}}addDefineDatas(e){var t=e._mask,r=e._length,i=this._mask,n=i.length;if(n=0;n--)if(!(n>i)){var a=r[n]&~t[n];n==i&&0===a?(i--,this._length--):r[n]=a}}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,n=this._length;r.length=n;for(var a=0;a0&&_>o)break;o&_&&t.push(s[_])}}static getDefineByName(e){var t=he._defineMap[e];if(!t){var r=he._maskMap,i=he._defineCounter,n=Math.floor(i/32),a=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 a){var h=s[o]||(s[o]=new a);l.cloneTo(h),s[o]=h}else if(l instanceof n){var d=s[o]||(s[o]=new n);l.cloneTo(d),s[o]=d}else if(l instanceof c){var u=s[o]||(s[o]=new c);l.cloneTo(u),s[o]=u}else l instanceof t.BaseTexture&&(s[o]=l)}this._defineDatas.cloneTo(r._defineDatas)}clone(){var e=new ce;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,n=this._data.conchRef,a=this._data._ptrID;this._data=new ArrayBuffer(r),this._int32Data=new Int32Array(this._data),this._float32Data=new Float32Array(this._data),this._data.conchRef=n,this._data._ptrID=a,i&&this._int32Data.set(i,0);var s=t.LayaGL.instance;s.updateArrayBufferRef?s.updateArrayBufferRef(this._data._ptrID,n.isSyncToRender(),this._data):window.conch.updateArrayBufferRef(this._data._ptrID,n.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 ce._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){ce._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 n=r[i];n&&n instanceof t.BaseTexture&&n._addReference()}}_removeReference(e=1){super._removeReference(e),this._removeTetxureReference()}setShaderName(e){if(this._shader=he.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 Te;return this.cloneTo(e),e}get _defineDatas(){return this._shaderValues._defineDatas}}Te.MATERIAL="MATERIAL",Te.RENDERQUEUE_OPAQUE=2e3,Te.RENDERQUEUE_ALPHATEST=2450,Te.RENDERQUEUE_TRANSPARENT=3e3,Te.ALPHATESTVALUE=he.propertyNameToID("u_AlphaTestValue"),Te.SHADERDEFINE_ALPHATEST=null;class Ee{static load(e,r){t.Laya.loader.create(e,r,null,Te.MATERIAL)}static __initDefine__(){Ee.SHADERDEFINE_ALPHATEST=Te.SHADERDEFINE_ALPHATEST}}Ee.MATERIAL="MATERIAL",Ee.RENDERQUEUE_OPAQUE=2e3,Ee.RENDERQUEUE_ALPHATEST=2450,Ee.RENDERQUEUE_TRANSPARENT=3e3,Ee.ALPHATESTVALUE=he.propertyNameToID("u_AlphaTestValue"),Ee.SHADERDEFINE_ALPHATEST=null;class pe{constructor(){this.cull=pe.CULL_BACK,this.blend=pe.BLEND_DISABLE,this.srcBlend=pe.BLENDPARAM_ONE,this.dstBlend=pe.BLENDPARAM_ZERO,this.srcBlendRGB=pe.BLENDPARAM_ONE,this.dstBlendRGB=pe.BLENDPARAM_ZERO,this.srcBlendAlpha=pe.BLENDPARAM_ONE,this.dstBlendAlpha=pe.BLENDPARAM_ZERO,this.blendConstColor=new n(1,1,1,1),this.blendEquation=pe.BLENDEQUATION_ADD,this.blendEquationRGB=pe.BLENDEQUATION_ADD,this.blendEquationAlpha=pe.BLENDEQUATION_ADD,this.depthTest=pe.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 pe;return this.cloneTo(e),e}}pe.CULL_NONE=0,pe.CULL_FRONT=1,pe.CULL_BACK=2,pe.BLEND_DISABLE=0,pe.BLEND_ENABLE_ALL=1,pe.BLEND_ENABLE_SEPERATE=2,pe.BLENDPARAM_ZERO=0,pe.BLENDPARAM_ONE=1,pe.BLENDPARAM_SRC_COLOR=768,pe.BLENDPARAM_ONE_MINUS_SRC_COLOR=769,pe.BLENDPARAM_DST_COLOR=774,pe.BLENDPARAM_ONE_MINUS_DST_COLOR=775,pe.BLENDPARAM_SRC_ALPHA=770,pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA=771,pe.BLENDPARAM_DST_ALPHA=772,pe.BLENDPARAM_ONE_MINUS_DST_ALPHA=773,pe.BLENDPARAM_SRC_ALPHA_SATURATE=776,pe.BLENDEQUATION_ADD=32774,pe.BLENDEQUATION_SUBTRACT=32778,pe.BLENDEQUATION_REVERSE_SUBTRACT=32779,pe.DEPTHTEST_OFF=0,pe.DEPTHTEST_NEVER=512,pe.DEPTHTEST_LESS=513,pe.DEPTHTEST_EQUAL=514,pe.DEPTHTEST_LEQUAL=515,pe.DEPTHTEST_GREATER=516,pe.DEPTHTEST_NOTEQUAL=517,pe.DEPTHTEST_GEQUAL=518,pe.DEPTHTEST_ALWAYS=519;class ge extends Te{constructor(){super(),this._enableVertexColor=!1,this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new n(1,1,1,1);var e=this._shaderValues;e.setVector(ge.ALBEDOCOLOR,new n(1,1,1,1)),e.setVector(ge.MATERIALSPECULAR,new n(1,1,1,1)),e.setNumber(ge.SHININESS,.078125),e.setNumber(Te.ALPHATESTVALUE,.5),e.setVector(ge.TILINGOFFSET,new n(1,1,0,0)),this._enableLighting=!0,this.renderMode=ge.RENDERMODE_OPAQUE}static __initDefine__(){ge.SHADERDEFINE_DIFFUSEMAP=he.getDefineByName("DIFFUSEMAP"),ge.SHADERDEFINE_NORMALMAP=he.getDefineByName("NORMALMAP"),ge.SHADERDEFINE_SPECULARMAP=he.getDefineByName("SPECULARMAP"),ge.SHADERDEFINE_TILINGOFFSET=he.getDefineByName("TILINGOFFSET"),ge.SHADERDEFINE_ENABLEVERTEXCOLOR=he.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 _Color(){return this._shaderValues.getVector(ge.ALBEDOCOLOR)}set _Color(e){this.albedoColor=e}get _SpecColorR(){return this._shaderValues.getVector(ge.MATERIALSPECULAR).x}set _SpecColorR(e){this._shaderValues.getVector(ge.MATERIALSPECULAR).x=e}get _SpecColorG(){return this._shaderValues.getVector(ge.MATERIALSPECULAR).y}set _SpecColorG(e){this._shaderValues.getVector(ge.MATERIALSPECULAR).y=e}get _SpecColorB(){return this._shaderValues.getVector(ge.MATERIALSPECULAR).z}set _SpecColorB(e){this._shaderValues.getVector(ge.MATERIALSPECULAR).z=e}get _SpecColorA(){return this._shaderValues.getVector(ge.MATERIALSPECULAR).w}set _SpecColorA(e){this._shaderValues.getVector(ge.MATERIALSPECULAR).w=e}get _SpecColor(){return this._shaderValues.getVector(ge.MATERIALSPECULAR)}set _SpecColor(e){this.specularColor=e}get _AlbedoIntensity(){return this._albedoIntensity}set _AlbedoIntensity(e){if(this._albedoIntensity!==e){var t=this._shaderValues.getVector(ge.ALBEDOCOLOR);n.scale(this._albedoColor,e,t),this._albedoIntensity=e,this._shaderValues.setVector(ge.ALBEDOCOLOR,t)}}get _Shininess(){return this._shaderValues.getNumber(ge.SHININESS)}set _Shininess(e){e=Math.max(0,Math.min(1,e)),this._shaderValues.setNumber(ge.SHININESS,e)}get _MainTex_STX(){return this._shaderValues.getVector(ge.TILINGOFFSET).x}set _MainTex_STX(e){var t=this._shaderValues.getVector(ge.TILINGOFFSET);t.x=e,this.tilingOffset=t}get _MainTex_STY(){return this._shaderValues.getVector(ge.TILINGOFFSET).y}set _MainTex_STY(e){var t=this._shaderValues.getVector(ge.TILINGOFFSET);t.y=e,this.tilingOffset=t}get _MainTex_STZ(){return this._shaderValues.getVector(ge.TILINGOFFSET).z}set _MainTex_STZ(e){var t=this._shaderValues.getVector(ge.TILINGOFFSET);t.z=e,this.tilingOffset=t}get _MainTex_STW(){return this._shaderValues.getVector(ge.TILINGOFFSET).w}set _MainTex_STW(e){var t=this._shaderValues.getVector(ge.TILINGOFFSET);t.w=e,this.tilingOffset=t}get _MainTex_ST(){return this._shaderValues.getVector(ge.TILINGOFFSET)}set _MainTex_ST(e){this.tilingOffset=e}get _Cutoff(){return this.alphaTestValue}set _Cutoff(e){this.alphaTestValue=e}set renderMode(e){switch(e){case ge.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=Te.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_DISABLE,this.depthTest=pe.DEPTHTEST_LESS;break;case ge.RENDERMODE_CUTOUT:this.renderQueue=Te.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_DISABLE,this.depthTest=pe.DEPTHTEST_LESS;break;case ge.RENDERMODE_TRANSPARENT:this.renderQueue=Te.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_ENABLE_ALL,this.blendSrc=pe.BLENDPARAM_SRC_ALPHA,this.blendDst=pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=pe.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(ge.SHADERDEFINE_ENABLEVERTEXCOLOR):this._shaderValues.removeDefine(ge.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(ge.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(ge.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(ge.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(ge.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(ge.ALBEDOCOLOR);n.scale(e,this._albedoIntensity,t),this._albedoColor=e,this._shaderValues.setVector(ge.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(ge.MATERIALSPECULAR)}set specularColor(e){this._shaderValues.setVector(ge.MATERIALSPECULAR,e)}get shininess(){return this._Shininess}set shininess(e){this._Shininess=e}get albedoTexture(){return this._shaderValues.getTexture(ge.ALBEDOTEXTURE)}set albedoTexture(e){e?this._shaderValues.addDefine(ge.SHADERDEFINE_DIFFUSEMAP):this._shaderValues.removeDefine(ge.SHADERDEFINE_DIFFUSEMAP),this._shaderValues.setTexture(ge.ALBEDOTEXTURE,e)}get normalTexture(){return this._shaderValues.getTexture(ge.NORMALTEXTURE)}set normalTexture(e){e?this._shaderValues.addDefine(ge.SHADERDEFINE_NORMALMAP):this._shaderValues.removeDefine(ge.SHADERDEFINE_NORMALMAP),this._shaderValues.setTexture(ge.NORMALTEXTURE,e)}get specularTexture(){return this._shaderValues.getTexture(ge.SPECULARTEXTURE)}set specularTexture(e){e?this._shaderValues.addDefine(ge.SHADERDEFINE_SPECULARMAP):this._shaderValues.removeDefine(ge.SHADERDEFINE_SPECULARMAP),this._shaderValues.setTexture(ge.SPECULARTEXTURE,e)}get depthWrite(){return this._shaderValues.getBool(ge.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(ge.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(ge.CULL)}set cull(e){this._shaderValues.setInt(ge.CULL,e)}get blend(){return this._shaderValues.getInt(ge.BLEND)}set blend(e){this._shaderValues.setInt(ge.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(ge.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(ge.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(ge.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(ge.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt(ge.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(ge.DEPTH_TEST,e)}clone(){var e=new ge;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)}}ge.RENDERMODE_OPAQUE=0,ge.RENDERMODE_CUTOUT=1,ge.RENDERMODE_TRANSPARENT=2,ge.ALBEDOTEXTURE=he.propertyNameToID("u_DiffuseTexture"),ge.NORMALTEXTURE=he.propertyNameToID("u_NormalTexture"),ge.SPECULARTEXTURE=he.propertyNameToID("u_SpecularTexture"),ge.ALBEDOCOLOR=he.propertyNameToID("u_DiffuseColor"),ge.MATERIALSPECULAR=he.propertyNameToID("u_MaterialSpecular"),ge.SHININESS=he.propertyNameToID("u_Shininess"),ge.TILINGOFFSET=he.propertyNameToID("u_TilingOffset"),ge.CULL=he.propertyNameToID("s_Cull"),ge.BLEND=he.propertyNameToID("s_Blend"),ge.BLEND_SRC=he.propertyNameToID("s_BlendSrc"),ge.BLEND_DST=he.propertyNameToID("s_BlendDst"),ge.DEPTH_TEST=he.propertyNameToID("s_DepthTest"),ge.DEPTH_WRITE=he.propertyNameToID("s_DepthWrite");class Se extends Te{constructor(){super(),this.setShaderName("Effect"),this._color=new n(1,1,1,1),this._shaderValues.setVector(Se.TINTCOLOR,new n(1,1,1,1)),this.renderMode=Se.RENDERMODE_ADDTIVE}static __initDefine__(){Se.SHADERDEFINE_MAINTEXTURE=he.getDefineByName("MAINTEXTURE"),Se.SHADERDEFINE_TILINGOFFSET=he.getDefineByName("TILINGOFFSET"),Se.SHADERDEFINE_ADDTIVEFOG=he.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(Se.TILINGOFFSET).x}set _MainTex_STX(e){var t=this._shaderValues.getVector(Se.TILINGOFFSET);t.x=e,this.tilingOffset=t}get _MainTex_STY(){return this._shaderValues.getVector(Se.TILINGOFFSET).y}set _MainTex_STY(e){var t=this._shaderValues.getVector(Se.TILINGOFFSET);t.y=e,this.tilingOffset=t}get _MainTex_STZ(){return this._shaderValues.getVector(Se.TILINGOFFSET).z}set _MainTex_STZ(e){var t=this._shaderValues.getVector(Se.TILINGOFFSET);t.z=e,this.tilingOffset=t}get _MainTex_STW(){return this._shaderValues.getVector(Se.TILINGOFFSET).w}set _MainTex_STW(e){var t=this._shaderValues.getVector(Se.TILINGOFFSET);t.w=e,this.tilingOffset=t}set renderMode(e){switch(e){case Se.RENDERMODE_ADDTIVE:this.renderQueue=Te.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=pe.CULL_NONE,this.blend=pe.BLEND_ENABLE_ALL,this.blendSrc=pe.BLENDPARAM_SRC_ALPHA,this.blendDst=pe.BLENDPARAM_ONE,this.depthTest=pe.DEPTHTEST_LESS,this._shaderValues.addDefine(Se.SHADERDEFINE_ADDTIVEFOG);break;case Se.RENDERMODE_ALPHABLENDED:this.renderQueue=Te.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=pe.CULL_NONE,this.blend=pe.BLEND_ENABLE_ALL,this.blendSrc=pe.BLENDPARAM_SRC_ALPHA,this.blendDst=pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=pe.DEPTHTEST_LESS,this._shaderValues.removeDefine(Se.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(Se.TINTCOLOR)}set color(e){this._shaderValues.setVector(Se.TINTCOLOR,e)}get texture(){return this._shaderValues.getTexture(Se.MAINTEXTURE)}set texture(e){e?this._shaderValues.addDefine(Se.SHADERDEFINE_MAINTEXTURE):this._shaderValues.removeDefine(Se.SHADERDEFINE_MAINTEXTURE),this._shaderValues.setTexture(Se.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(Se.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(Se.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(Se.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(Se.TILINGOFFSET,e)}get depthWrite(){return this._shaderValues.getBool(Se.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(Se.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(Se.CULL)}set cull(e){this._shaderValues.setInt(Se.CULL,e)}get blend(){return this._shaderValues.getInt(Se.BLEND)}set blend(e){this._shaderValues.setInt(Se.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(Se.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(Se.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(Se.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(Se.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt(Se.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(Se.DEPTH_TEST,e)}clone(){var e=new Se;return this.cloneTo(e),e}}Se.RENDERMODE_ADDTIVE=0,Se.RENDERMODE_ALPHABLENDED=1,Se.MAINTEXTURE=he.propertyNameToID("u_AlbedoTexture"),Se.TINTCOLOR=he.propertyNameToID("u_AlbedoColor"),Se.TILINGOFFSET=he.propertyNameToID("u_TilingOffset"),Se.CULL=he.propertyNameToID("s_Cull"),Se.BLEND=he.propertyNameToID("s_Blend"),Se.BLEND_SRC=he.propertyNameToID("s_BlendSrc"),Se.BLEND_DST=he.propertyNameToID("s_BlendDst"),Se.DEPTH_TEST=he.propertyNameToID("s_DepthTest"),Se.DEPTH_WRITE=he.propertyNameToID("s_DepthWrite");class Re extends Te{constructor(){super(),this._enableLighting=!0,this.setShaderName("ExtendTerrain"),this.renderMode=Re.RENDERMODE_OPAQUE}static __initDefine__(){Re.SHADERDEFINE_DETAIL_NUM1=he.getDefineByName("ExtendTerrain_DETAIL_NUM1"),Re.SHADERDEFINE_DETAIL_NUM2=he.getDefineByName("ExtendTerrain_DETAIL_NUM2"),Re.SHADERDEFINE_DETAIL_NUM3=he.getDefineByName("ExtendTerrain_DETAIL_NUM3"),Re.SHADERDEFINE_DETAIL_NUM4=he.getDefineByName("ExtendTerrain_DETAIL_NUM4"),Re.SHADERDEFINE_DETAIL_NUM5=he.getDefineByName("ExtendTerrain_DETAIL_NUM5")}get splatAlphaTexture(){return this._shaderValues.getTexture(Re.SPLATALPHATEXTURE)}set splatAlphaTexture(e){this._shaderValues.setTexture(Re.SPLATALPHATEXTURE,e)}get diffuseTexture1(){return this._shaderValues.getTexture(Re.DIFFUSETEXTURE1)}set diffuseTexture1(e){this._shaderValues.setTexture(Re.DIFFUSETEXTURE1,e),this._setDetailNum(1)}get diffuseTexture2(){return this._shaderValues.getTexture(Re.DIFFUSETEXTURE2)}set diffuseTexture2(e){this._shaderValues.setTexture(Re.DIFFUSETEXTURE2,e),this._setDetailNum(2)}get diffuseTexture3(){return this._shaderValues.getTexture(Re.DIFFUSETEXTURE3)}set diffuseTexture3(e){this._shaderValues.setTexture(Re.DIFFUSETEXTURE3,e),this._setDetailNum(3)}get diffuseTexture4(){return this._shaderValues.getTexture(Re.DIFFUSETEXTURE4)}set diffuseTexture4(e){this._shaderValues.setTexture(Re.DIFFUSETEXTURE4,e),this._setDetailNum(4)}get diffuseTexture5(){return this._shaderValues.getTexture(Re.DIFFUSETEXTURE5)}set diffuseTexture5(e){this._shaderValues.setTexture(Re.DIFFUSETEXTURE5,e),this._setDetailNum(5)}set diffuseScaleOffset1(e){this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET1,e)}set diffuseScaleOffset2(e){this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET2,e)}set diffuseScaleOffset3(e){this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET3,e)}set diffuseScaleOffset4(e){this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET4,e)}set diffuseScaleOffset5(e){this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET5,e)}set renderMode(e){switch(e){case Re.RENDERMODE_OPAQUE:this.renderQueue=Te.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_DISABLE,this.depthTest=pe.DEPTHTEST_LESS;break;case Re.RENDERMODE_TRANSPARENT:this.renderQueue=Te.RENDERQUEUE_OPAQUE,this.depthWrite=!1,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_ENABLE_ALL,this.blendSrc=pe.BLENDPARAM_SRC_ALPHA,this.blendDst=pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=pe.DEPTHTEST_LEQUAL;break;default:throw new Error("ExtendTerrainMaterial:renderMode value error.")}}get depthWrite(){return this._shaderValues.getBool(Re.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(Re.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(Re.CULL)}set cull(e){this._shaderValues.setInt(Re.CULL,e)}get blend(){return this._shaderValues.getInt(Re.BLEND)}set blend(e){this._shaderValues.setInt(Re.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(Re.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(Re.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(Re.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(Re.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt(Re.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(Re.DEPTH_TEST,e)}_setDetailNum(e){switch(e){case 1:this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);break;case 2:this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);break;case 3:this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);break;case 4:this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);break;case 5:this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM5),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4)}}clone(){var e=new Re;return this.cloneTo(e),e}}Re.RENDERMODE_OPAQUE=1,Re.RENDERMODE_TRANSPARENT=2,Re.SPLATALPHATEXTURE=he.propertyNameToID("u_SplatAlphaTexture"),Re.DIFFUSETEXTURE1=he.propertyNameToID("u_DiffuseTexture1"),Re.DIFFUSETEXTURE2=he.propertyNameToID("u_DiffuseTexture2"),Re.DIFFUSETEXTURE3=he.propertyNameToID("u_DiffuseTexture3"),Re.DIFFUSETEXTURE4=he.propertyNameToID("u_DiffuseTexture4"),Re.DIFFUSETEXTURE5=he.propertyNameToID("u_DiffuseTexture5"),Re.DIFFUSESCALEOFFSET1=he.propertyNameToID("u_DiffuseScaleOffset1"),Re.DIFFUSESCALEOFFSET2=he.propertyNameToID("u_DiffuseScaleOffset2"),Re.DIFFUSESCALEOFFSET3=he.propertyNameToID("u_DiffuseScaleOffset3"),Re.DIFFUSESCALEOFFSET4=he.propertyNameToID("u_DiffuseScaleOffset4"),Re.DIFFUSESCALEOFFSET5=he.propertyNameToID("u_DiffuseScaleOffset5"),Re.CULL=he.propertyNameToID("s_Cull"),Re.BLEND=he.propertyNameToID("s_Blend"),Re.BLEND_SRC=he.propertyNameToID("s_BlendSrc"),Re.BLEND_DST=he.propertyNameToID("s_BlendDst"),Re.DEPTH_TEST=he.propertyNameToID("s_DepthTest"),Re.DEPTH_WRITE=he.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 ve extends Te{constructor(){super(),this._enableEmission=!1,this._shaderValues.setVector(ve.ALBEDOCOLOR,new n(1,1,1,1)),this._shaderValues.setVector(ve.EMISSIONCOLOR,new n(1,1,1,1)),this._shaderValues.setNumber(ve.SMOOTHNESS,.5),this._shaderValues.setNumber(ve.SMOOTHNESSSCALE,1),this._shaderValues.setNumber(ve.OCCLUSIONSTRENGTH,1),this._shaderValues.setNumber(ve.NORMALSCALE,1),this._shaderValues.setNumber(ve.PARALLAXSCALE,.001),this._shaderValues.setNumber(Te.ALPHATESTVALUE,.5),this.renderMode=e.PBRRenderMode.Opaque}static __init__(){ve.SHADERDEFINE_ALBEDOTEXTURE=he.getDefineByName("ALBEDOTEXTURE"),ve.SHADERDEFINE_NORMALTEXTURE=he.getDefineByName("NORMALTEXTURE"),ve.SHADERDEFINE_PARALLAXTEXTURE=he.getDefineByName("PARALLAXTEXTURE"),ve.SHADERDEFINE_OCCLUSIONTEXTURE=he.getDefineByName("OCCLUSIONTEXTURE"),ve.SHADERDEFINE_EMISSION=he.getDefineByName("EMISSION"),ve.SHADERDEFINE_EMISSIONTEXTURE=he.getDefineByName("EMISSIONTEXTURE"),ve.SHADERDEFINE_TILINGOFFSET=he.getDefineByName("TILINGOFFSET"),ve.SHADERDEFINE_TRANSPARENTBLEND=he.getDefineByName("TRANSPARENTBLEND"),ve.SHADERDEFINE_LAYA_PBR_BRDF_HIGH=he.getDefineByName("LAYA_PBR_BRDF_HIGH"),ve.SHADERDEFINE_LAYA_PBR_BRDF_LOW=he.getDefineByName("LAYA_PBR_BRDF_LOW")}get albedoColor(){return this._shaderValues.getVector(ve.ALBEDOCOLOR)}set albedoColor(e){this._shaderValues.setVector(ve.ALBEDOCOLOR,e)}get albedoTexture(){return this._shaderValues.getTexture(ve.ALBEDOTEXTURE)}set albedoTexture(e){e?this._shaderValues.addDefine(ve.SHADERDEFINE_ALBEDOTEXTURE):this._shaderValues.removeDefine(ve.SHADERDEFINE_ALBEDOTEXTURE),this._shaderValues.setTexture(ve.ALBEDOTEXTURE,e)}get normalTexture(){return this._shaderValues.getTexture(ve.NORMALTEXTURE)}set normalTexture(e){e?this._shaderValues.addDefine(ve.SHADERDEFINE_NORMALTEXTURE):this._shaderValues.removeDefine(ve.SHADERDEFINE_NORMALTEXTURE),this._shaderValues.setTexture(ve.NORMALTEXTURE,e)}get normalTextureScale(){return this._shaderValues.getNumber(ve.NORMALSCALE)}set normalTextureScale(e){this._shaderValues.setNumber(ve.NORMALSCALE,e)}get parallaxTexture(){return this._shaderValues.getTexture(ve.PARALLAXTEXTURE)}set parallaxTexture(e){e?this._shaderValues.addDefine(ve.SHADERDEFINE_PARALLAXTEXTURE):this._shaderValues.removeDefine(ve.SHADERDEFINE_PARALLAXTEXTURE),this._shaderValues.setTexture(ve.PARALLAXTEXTURE,e)}get parallaxTextureScale(){return this._shaderValues.getNumber(ve.PARALLAXSCALE)}set parallaxTextureScale(e){this._shaderValues.setNumber(ve.PARALLAXSCALE,Math.max(.005,Math.min(.08,e)))}get occlusionTexture(){return this._shaderValues.getTexture(ve.OCCLUSIONTEXTURE)}set occlusionTexture(e){e?this._shaderValues.addDefine(ve.SHADERDEFINE_OCCLUSIONTEXTURE):this._shaderValues.removeDefine(ve.SHADERDEFINE_OCCLUSIONTEXTURE),this._shaderValues.setTexture(ve.OCCLUSIONTEXTURE,e)}get occlusionTextureStrength(){return this._shaderValues.getNumber(ve.OCCLUSIONSTRENGTH)}set occlusionTextureStrength(e){this._shaderValues.setNumber(ve.OCCLUSIONSTRENGTH,Math.max(0,Math.min(1,e)))}get smoothness(){return this._shaderValues.getNumber(ve.SMOOTHNESS)}set smoothness(e){this._shaderValues.setNumber(ve.SMOOTHNESS,Math.max(0,Math.min(1,e)))}get smoothnessTextureScale(){return this._shaderValues.getNumber(ve.SMOOTHNESSSCALE)}set smoothnessTextureScale(e){this._shaderValues.setNumber(ve.SMOOTHNESSSCALE,Math.max(0,Math.min(1,e)))}get enableEmission(){return this._enableEmission}set enableEmission(e){e?this._shaderValues.addDefine(ve.SHADERDEFINE_EMISSION):this._shaderValues.removeDefine(ve.SHADERDEFINE_EMISSION),this._enableEmission=e}get emissionColor(){return this._shaderValues.getVector(ve.EMISSIONCOLOR)}set emissionColor(e){this._shaderValues.setVector(ve.EMISSIONCOLOR,e)}get emissionTexture(){return this._shaderValues.getTexture(ve.EMISSIONTEXTURE)}set emissionTexture(e){e?this._shaderValues.addDefine(ve.SHADERDEFINE_EMISSIONTEXTURE):this._shaderValues.removeDefine(ve.SHADERDEFINE_EMISSIONTEXTURE),this._shaderValues.setTexture(ve.EMISSIONTEXTURE,e)}get tilingOffset(){return this._shaderValues.getVector(ve.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(ve.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(ve.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(ve.TILINGOFFSET,e)}get depthWrite(){return this._shaderValues.getBool(ve.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(ve.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(ve.CULL)}set cull(e){this._shaderValues.setInt(ve.CULL,e)}get blend(){return this._shaderValues.getInt(ve.BLEND)}set blend(e){this._shaderValues.setInt(ve.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(ve.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(ve.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(ve.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(ve.BLEND_DST,e)}get depthTest(){return this._shaderValues.getInt(ve.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(ve.DEPTH_TEST,e)}set renderMode(t){switch(t){case e.PBRRenderMode.Opaque:this.alphaTest=!1,this.renderQueue=Te.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_DISABLE,this.depthTest=pe.DEPTHTEST_LESS,this._shaderValues.removeDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Cutout:this.renderQueue=Te.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_DISABLE,this.depthTest=pe.DEPTHTEST_LESS,this._shaderValues.removeDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Fade:this.renderQueue=Te.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_ENABLE_ALL,this.blendSrc=pe.BLENDPARAM_SRC_ALPHA,this.blendDst=pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=pe.DEPTHTEST_LESS,this._shaderValues.removeDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Transparent:this.renderQueue=Te.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=pe.CULL_BACK,this.blend=pe.BLEND_ENABLE_ALL,this.blendSrc=pe.BLENDPARAM_ONE,this.blendDst=pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=pe.DEPTHTEST_LESS,this._shaderValues.addDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);break;default:throw new Error("PBRMaterial:unknown renderMode value.")}}get enableReflection(){return!0}set enableReflection(e){}}ve.ALBEDOTEXTURE=he.propertyNameToID("u_AlbedoTexture"),ve.ALBEDOCOLOR=he.propertyNameToID("u_AlbedoColor"),ve.TILINGOFFSET=he.propertyNameToID("u_TilingOffset"),ve.NORMALTEXTURE=he.propertyNameToID("u_NormalTexture"),ve.NORMALSCALE=he.propertyNameToID("u_NormalScale"),ve.SMOOTHNESS=he.propertyNameToID("u_Smoothness"),ve.SMOOTHNESSSCALE=he.propertyNameToID("u_SmoothnessScale"),ve.OCCLUSIONTEXTURE=he.propertyNameToID("u_OcclusionTexture"),ve.OCCLUSIONSTRENGTH=he.propertyNameToID("u_occlusionStrength"),ve.PARALLAXTEXTURE=he.propertyNameToID("u_ParallaxTexture"),ve.PARALLAXSCALE=he.propertyNameToID("u_ParallaxScale"),ve.EMISSIONTEXTURE=he.propertyNameToID("u_EmissionTexture"),ve.EMISSIONCOLOR=he.propertyNameToID("u_EmissionColor"),ve.CULL=he.propertyNameToID("s_Cull"),ve.BLEND=he.propertyNameToID("s_Blend"),ve.BLEND_SRC=he.propertyNameToID("s_BlendSrc"),ve.BLEND_DST=he.propertyNameToID("s_BlendDst"),ve.DEPTH_TEST=he.propertyNameToID("s_DepthTest"),ve.DEPTH_WRITE=he.propertyNameToID("s_DepthWrite"),ve.renderQuality=e.PBRRenderQuality.High;var Ae,Ie,xe,Le,De,Ce,ye,Me,Oe,Ne,be;class Pe{constructor(){this.textureID=-1}}class we extends t.Resource{constructor(e,t,r,i,n){super(),this._stateParamsMap=[],this._uploadMark=-1,this._uploadRenderType=-1,this._vs=e,this._ps=t,this._attributeMap=r,this._uniformMap=i,this._shaderPass=n,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&&he.debugMode&&!e.getProgramParameter(this._program,e.LINK_STATUS))throw e.getProgramInfoLog(this._program);var i=[],n=[],a=[],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=he.propertyNameToID(u),m){case he.PERIOD_CUSTOM:o.push(l);break;case he.PERIOD_MATERIAL:s.push(l);break;case he.PERIOD_SPRITE:a.push(l);break;case he.PERIOD_CAMERA:n.push(l);break;case he.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&&s._quickSort(0,c-1),(c=o.elements.length)>0&&o._quickSort(0,c-1)}static cullingShadow(e,r,i){var n=r._renders;r._clearRenderQueue();for(var s=r._opaqueQueue,o=e.position,l=e.cullPlaneCount,_=e.cullPlanes,h=(e.cullSphere,e.direction,n.elements),c=t.Stat.loopCount,d=0,u=n.length;d0}static cullingSpotShadow(e,r,i){var n=r._renders;r._clearRenderQueue();for(var s=r._opaqueQueue,o=n.elements,l=t.Stat.loopCount,_=0,h=n.length;_0}static renderObjectCullingNative(e,r,i,n,s,o){var l,_,h,c=r._opaqueQueue,d=r._transparentQueue;r._clearRenderQueue();var u=n.length,m=n.elements;for(l=0;l0&&c._quickSort(0,g-1),(g=d.elements.length)>0&&d._quickSort(0,g-1)}static cullingNative(e,r,i,n,a){return t.LayaGL.instance.culling(e,r,i,n,a)}}Ge._tempColor0=new Be,Ge._tempVector0=new a,Ge._cameraCullInfo=new Fe,Ge._shadowCullInfo=new Ue,Ge.debugFrustumCulling=!1;class ze{constructor(){this.updateMark=-1,this.pointLightCount=0,this.spotLightCount=0,this.indices=[]}}class He{constructor(e,t,r,n){this._updateMark=0,this._depthSliceParam=new i,this._xSlices=e,this._ySlices=t,this._zSlices=r;var a=e*t,s=r*(1+Math.ceil(n/4));this._clusterTexture=N._createFloatTextureBuffer(a,s),this._clusterTexture.lock=!0,this._clusterPixels=new Float32Array(a*s*4);for(var o=new Array(this._zSlices),l=0;ll*l))return!1;var _=a.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,n=t.zMin,a=t.zMax;nt||o<=e)return!1;var l=this._depthSliceParam;return n.zMin=Math.floor(Math.log2(Math.max(s,e))*l.x-l.y),n.zMax=Math.min(Math.ceil(Math.log2(o)*l.x-l.y),this._zSlices),!0}_shrinkSpotLightZPerspective(e,t,r,i,n,a,s){var o=i.x,l=i.y,_=i.z,h=Math.tan(a)*n,c=r.x,d=r.y,u=r.z,m=o-c,f=l-d,T=_-u,E=m*m+f*f+T*T,p=Math.sqrt(1-T*T/E),g=Math.max(Math.min(u,_-p*h),r.z-n),S=Math.min(Math.max(u,_+p*h),r.z+n);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,n,a,s){var o=n.z,l=o-a,_=o+a;if(l>i||_<=r)return!1;var h=n.x,c=h-a,d=h+a;if(c>e||d<=-e)return!1;var u=n.y,m=u-a,f=u+a;if(m>t||f<=-t)return!1;var T=this._xSlices,E=this._ySlices,p=this._depthSliceParam,g=2*e/T,S=2*t/E;return s.xMin=Math.max(Math.floor((c+e)/g),0),s.xMax=Math.min(Math.ceil((d+e)/g),T),s.yMin=Math.max(Math.floor((t-f)/S),0),s.yMax=Math.min(Math.ceil((t-m)/S),E),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,n,a,s,o,l){var _=a.x,h=a.y,c=a.z,d=Math.tan(o)*s,u=n.x,m=n.y,f=n.z,T=_-u,E=h-m,p=c-f,g=T*T+E*E+p*p,S=Math.sqrt(1-p*p/g),R=Math.max(Math.min(f,c-S*d),n.z-s),v=Math.min(Math.max(f,c+S*d),n.z+s);if(R>i||v<=r)return!1;var A=Math.sqrt(1-T*T/g),I=Math.max(Math.min(u,_-A*d),n.x-s),x=Math.min(Math.max(u,_+A*d),n.x+s);if(I>e||x<=-e)return!1;var L=Math.sqrt(1-E*E/g),D=Math.max(Math.min(m,h-L*d),n.y-s),C=Math.min(Math.max(m,h+L*d),n.y+s);if(D>t||C<=-t)return!1;var y=this._xSlices,M=this._ySlices,O=this._depthSliceParam,N=2*e/y,b=2*t/M;return l.xMin=Math.max(Math.floor((I+e)/N),0),l.xMax=Math.min(Math.ceil((x+e)/N),y),l.yMin=Math.max(Math.floor((t-C)/b),0),l.yMax=Math.min(Math.ceil((t-D)/b),M),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,n){var a,s,o,l,_,h=e.x,c=e.y,d=e.z,u=this._ySlices+1;for(_=0;_0){for(var p=this._xSlices,g=this._ySlices,S=this._zSlices,R=p*g*4,v=R*S,A=this._clusterPixels,I=A.length,x=this._clusterDatas,L=this._updateMark,D=!0,C=0;Co&&(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,n=i.x,a=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,T=f.x,E=f.y,p=f.z,g=0;return n>T?g+=(r=n-T)*r:d>l&&(g+=(r=d-l)*r),a>E?g+=(r=a-E)*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(a.distanceSquared(e.center,t));return r-=e.radius,Math.max(r,0)}static distanceSphereToSphere(e,t){var r=Math.sqrt(a.distanceSquared(e.center,t.center));return r-=e.radius+t.radius,Math.max(r,0)}static intersectsRayAndTriangleRD(e,t,i,n,a){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,T=t.z,E=i.x,p=i.y,g=i.z,S=n.x,R=n.y,v=n.z,A=qe._tempV30.x,I=qe._tempV30.y,x=qe._tempV30.z;A=E-m,I=p-f,x=g-T;var L=qe._tempV31.x,D=qe._tempV31.y,C=qe._tempV31.z;L=S-m,D=R-f,C=v-T;var y=qe._tempV32.x,M=qe._tempV32.y,O=qe._tempV32.z,N=A*(y=d*C-u*D)+I*(M=u*L-c*C)+x*(O=c*D-d*L);if(r.isZero(N))return!1;var b=1/N,P=qe._tempV33.x,w=qe._tempV33.y,V=qe._tempV33.z,B=(P=o-m)*y+(w=l-f)*M+(V=_-T)*O;if((B*=b)<0||B>1)return!1;var F=qe._tempV34.x,U=qe._tempV34.y,G=qe._tempV34.z,z=c*(F=w*x-V*I)+d*(U=V*A-P*x)+u*(G=P*I-w*A);if((z*=b)<0||B+z>1)return!1;var H=L*F+D*U+C*G;return!((H*=b)<0)}static intersectsRayAndTriangleRP(e,t,r,i,n){return qe.intersectsRayAndTriangleRD(e,t,r,i,void 0)?(a.scale(e.direction,void 0,qe._tempV30),a.add(e.origin,qe._tempV30,n),!0):(n=a._ZERO,!1)}static intersectsRayAndPoint(e,t){a.subtract(e.origin,t,qe._tempV30);var i=a.dot(qe._tempV30,e.direction),n=a.dot(qe._tempV30,qe._tempV30)-r.zeroTolerance;return!(n>0&&i>0)&&!(i*i-n<0)}static intersectsRayAndRay(e,t,i){var n=e.origin,s=n.x,o=n.y,l=n.z,_=e.direction,h=_.x,c=_.y,d=_.z,u=t.origin,m=u.x,f=u.y,T=u.z,E=t.direction,p=E.x,g=E.y,S=E.z;a.cross(_,E,qe._tempV30);var R=qe._tempV30,v=a.scalarLength(qe._tempV30);if(r.isZero(v)&&r.nearEqual(m,s)&&r.nearEqual(f,o)&&r.nearEqual(T,l))return!0;v*=v;var A=m-s,I=f-o,x=T-l,L=p,D=g,C=S,y=R.x,M=R.y,O=R.z,N=A*D*O+I*C*y+x*L*M-A*C*M-I*L*O-x*D*y;L=h,D=c,C=d;var b=N/v;a.scale(_,b,qe._tempV30),a.scale(E,b,qe._tempV31),a.add(n,qe._tempV30,qe._tempV32),a.add(u,qe._tempV31,qe._tempV33);var P=qe._tempV32,w=qe._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 n=qe.intersectsPlaneAndPoint(e,t),a=qe.intersectsPlaneAndPoint(e,r),s=qe.intersectsPlaneAndPoint(e,i);return n==Ye.PlaneIntersectionType_Front&&a==Ye.PlaneIntersectionType_Front&&s==Ye.PlaneIntersectionType_Front?Ye.PlaneIntersectionType_Front:n==Ye.PlaneIntersectionType_Back&&a==Ye.PlaneIntersectionType_Back&&s==Ye.PlaneIntersectionType_Back?Ye.PlaneIntersectionType_Back:Ye.PlaneIntersectionType_Intersecting}static intersectsRayAndPlaneRD(e,t){var i=t.normal,n=a.dot(i,e.direction);if(Math.abs(n)T)return-1}else{var R=1/l,v=(d-n)*R,A=(T-n)*R;if(v>A){var I=v;v=A,A=I}if((g=Math.max(v,g))>(S=Math.min(A,S)))return-1}if(r.isZero(_)){if(aE)return-1}else{var x=1/_,L=(u-a)*x,D=(E-a)*x;if(L>D){var C=L;L=D,D=C}if((g=Math.max(L,g))>(S=Math.min(D,S)))return-1}if(r.isZero(h)){if(sp)return-1}else{var y=1/h,M=(m-s)*y,O=(p-s)*y;if(M>O){var N=M;M=O,O=N}if((g=Math.max(M,g))>(S=Math.min(O,S)))return-1}return g}static intersectsRayAndBoxRP(e,t,r){var i=qe.intersectsRayAndBoxRD(e,t);return-1===i?(a._ZERO.cloneTo(r),i):(a.scale(e.direction,i,qe._tempV30),a.add(e.origin,qe._tempV30,qe._tempV31),qe._tempV31.cloneTo(r),i)}static intersectsRayAndSphereRD(e,t){var r=t.radius;a.subtract(e.origin,t.center,qe._tempV30);var i=a.dot(qe._tempV30,e.direction),n=a.dot(qe._tempV30,qe._tempV30)-r*r;if(n>0&&i>0)return-1;var s=i*i-n;if(s<0)return-1;var o=-i-Math.sqrt(s);return o<0&&(o=0),o}static intersectsRayAndSphereRP(e,t,r){var i=qe.intersectsRayAndSphereRD(e,t);return-1===i?(a._ZERO.cloneTo(r),i):(a.scale(e.direction,i,qe._tempV30),a.add(e.origin,qe._tempV30,qe._tempV31),qe._tempV31.cloneTo(r),i)}static intersectsSphereAndTriangle(e,t,r,i){var n=e.center,s=e.radius;return qe.closestPointPointTriangle(n,t,r,i,qe._tempV30),a.subtract(qe._tempV30,n,qe._tempV31),a.dot(qe._tempV31,qe._tempV31)<=s*s}static intersectsPlaneAndPoint(e,t){var r=a.dot(e.normal,t)+e.distance;return r>0?Ye.PlaneIntersectionType_Front:r<0?Ye.PlaneIntersectionType_Back:Ye.PlaneIntersectionType_Intersecting}static intersectsPlaneAndPlane(e,t){a.cross(e.normal,t.normal,qe._tempV30);var i=a.dot(qe._tempV30,qe._tempV30);return!r.isZero(i)}static intersectsPlaneAndPlaneRL(e,t,i){var n=e.normal,s=t.normal;a.cross(n,s,qe._tempV34);var o=a.dot(qe._tempV34,qe._tempV34);return!r.isZero(o)&&(a.scale(s,e.distance,qe._tempV30),a.scale(n,t.distance,qe._tempV31),a.subtract(qe._tempV30,qe._tempV31,qe._tempV32),a.cross(qe._tempV32,qe._tempV34,qe._tempV33),a.normalize(qe._tempV34,qe._tempV34),!0)}static intersectsPlaneAndBox(e,t){var r=e.distance,i=e.normal,n=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;qe._tempV30.x=n>0?_:u,qe._tempV30.y=s>0?h:m,qe._tempV30.z=o>0?c:f,qe._tempV31.x=n>0?u:_,qe._tempV31.y=s>0?m:h,qe._tempV31.z=o>0?f:c;var T=a.dot(i,qe._tempV30);return T+r>0?Ye.PlaneIntersectionType_Front:(T=a.dot(i,qe._tempV31))+r<0?Ye.PlaneIntersectionType_Back:Ye.PlaneIntersectionType_Intersecting}static intersectsPlaneAndSphere(e,t){var r=t.radius,i=a.dot(e.normal,t.center)+e.distance;return i>r?Ye.PlaneIntersectionType_Front:i<-r?Ye.PlaneIntersectionType_Back:Ye.PlaneIntersectionType_Intersecting}static intersectsBoxAndBox(e,t){var r=e.min,i=e.max,n=t.min,a=t.max;return!(r.x>a.x||n.x>i.x)&&(!(r.y>a.y||n.y>i.y)&&!(r.z>a.z||n.z>i.z))}static intersectsBoxAndSphere(e,t){var r=t.center,i=t.radius,n=qe._tempV30;return a.Clamp(r,e.min,e.max,n),a.distanceSquared(r,n)<=i*i}static intersectsSphereAndSphere(e,t){var r=e.radius+t.radius;return a.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?Ze.Contains:Ze.Disjoint}static boxContainsBox(e,t){var r=e.min,i=r.x,n=r.y,a=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,T=m.y,E=m.z;return of||lT||_E?Ze.Disjoint:i<=c&&f<=o&&n<=d&&T<=l&&a<=u&&E<=_?Ze.Contains:Ze.Intersects}static boxContainsSphere(e,t){var r=e.min,i=r.x,n=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 a.Clamp(c,r,o,qe._tempV30),a.distanceSquared(c,qe._tempV30)>f*f?Ze.Disjoint:i+f<=d&&d<=l-f&&l-i>f&&n+f<=u&&u<=_-f&&_-n>f&&s+f<=m&&m<=h-f&&h-s>f?Ze.Contains:Ze.Intersects}static sphereContainsPoint(e,t){return a.distanceSquared(t,e.center)<=e.radius*e.radius?Ze.Contains:Ze.Disjoint}static sphereContainsTriangle(e,t,r,i){var n=qe.sphereContainsPoint(e,t),a=qe.sphereContainsPoint(e,r),s=qe.sphereContainsPoint(e,i);return n==Ze.Contains&&a==Ze.Contains&&s==Ze.Contains?Ze.Contains:qe.intersectsSphereAndTriangle(e,t,r,i)?Ze.Intersects:Ze.Disjoint}static sphereContainsBox(e,t){var r=e.center,i=r.x,n=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,T=qe._tempV30;T.x,T.y,T.z;if(!qe.intersectsBoxAndSphere(t,e))return Ze.Disjoint;var E=o*o;return i-_,n-m,s-f,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:(i-u,n-m,s-f,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:(i-u,n-h,s-f,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:(i-_,n-h,s-f,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:(i-_,n-m,s-c,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:(i-u,n-m,s-c,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:(i-u,n-h,s-c,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:(i-_,n-h,s-c,a.scalarLengthSquared(qe._tempV30)>E?Ze.Intersects:Ze.Contains)))))))}static sphereContainsSphere(e,t){var r=e.radius,i=t.radius,n=a.distance(e.center,t.center);return r+i=0&&_<=l)r.cloneTo(n);else{var d=s*_-l*o;if(d<=0&&s>=0&&l<=0){var u=s/(s-l);return a.scale(qe._tempV30,u,n),void a.add(t,n,n)}if(c>=0&&h<=c)i.cloneTo(n);else{var m=h*o-s*c;if(m<=0&&o>=0&&c<=0){var f=o/(o-c);return a.scale(qe._tempV31,f,n),void a.add(t,n,n)}var T=l*c-h*_;if(T<=0&&_-l>=0&&h-c>=0){var E=(_-l)/(_-l+(h-c));return a.subtract(i,r,n),a.scale(n,E,n),void a.add(r,n,n)}var p=1/(T+m+d),g=m*p,S=d*p;a.scale(qe._tempV30,g,qe._tempV35),a.scale(qe._tempV31,S,qe._tempV36),a.add(qe._tempV35,qe._tempV36,n),a.add(t,n,n)}}}static closestPointPlanePoint(e,t,r){var i=e.normal,n=a.dot(i,t)-e.distance;a.scale(i,n,qe._tempV30),a.subtract(t,qe._tempV30,r)}static closestPointBoxPoint(e,t,r){a.max(t,e.min,qe._tempV30),a.min(qe._tempV30,e.max,r)}static closestPointSpherePoint(e,t,r){var i=e.center;a.subtract(t,i,r),a.normalize(r,r),a.scale(r,e.radius,r),a.add(r,i,r)}static closestPointSphereSphere(e,t,r){var i=e.center;a.subtract(t.center,i,r),a.normalize(r,r),a.scale(r,e.radius,r),a.add(r,i,r)}}qe._tempV30=new a,qe._tempV31=new a,qe._tempV32=new a,qe._tempV33=new a,qe._tempV34=new a,qe._tempV35=new a,qe._tempV36=new a,(Ae=e.FrustumCorner||(e.FrustumCorner={}))[Ae.FarBottomLeft=0]="FarBottomLeft",Ae[Ae.FarTopLeft=1]="FarTopLeft",Ae[Ae.FarTopRight=2]="FarTopRight",Ae[Ae.FarBottomRight=3]="FarBottomRight",Ae[Ae.nearBottomLeft=4]="nearBottomLeft",Ae[Ae.nearTopLeft=5]="nearTopLeft",Ae[Ae.nearTopRight=6]="nearTopRight",Ae[Ae.nearBottomRight=7]="nearBottomRight",Ae[Ae.unknown=8]="unknown";class Qe{constructor(e){this._matrix=e,this._near=new Ye(new a),this._far=new Ye(new a),this._left=new Ye(new a),this._right=new Ye(new a),this._top=new Ye(new a),this._bottom=new Ye(new a),Qe.getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}static getPlanesFromMatrix(e,t,r,i,n,a,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],T=o[8],E=o[9],p=o[10],g=o[11],S=o[12],R=o[13],v=o[14],A=o[15],I=t.normal;I.x=h,I.y=m,I.z=p,t.distance=v,t.normalize();var x=r.normal;x.x=c-h,x.y=f-m,x.z=g-p,r.distance=A-v,r.normalize();var L=i.normal;L.x=c+l,L.y=f+d,L.z=g+T,i.distance=A+S,i.normalize();var D=n.normal;D.x=c-l,D.y=f-d,D.z=g-T,n.distance=A-S,n.normalize();var C=a.normal;C.x=c-_,C.y=f-u,C.z=g-E,a.distance=A-R,a.normalize();var y=s.normal;y.x=c+_,y.y=f+u,y.z=g+E,s.distance=A+R,s.normalize()}get matrix(){return this._matrix}set matrix(e){e.cloneTo(this._matrix),Qe.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 Qe){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 n=e.normal,s=t.normal,o=r.normal;a.cross(s,o,Qe._tempV30),a.cross(o,n,Qe._tempV31),a.cross(n,s,Qe._tempV32);var l=a.dot(n,Qe._tempV30),_=a.dot(s,Qe._tempV31),h=a.dot(o,Qe._tempV32);a.scale(Qe._tempV30,-e.distance/l,Qe._tempV33),a.scale(Qe._tempV31,-t.distance/_,Qe._tempV34),a.scale(Qe._tempV32,-r.distance/h,Qe._tempV35),a.add(Qe._tempV33,Qe._tempV34,Qe._tempV36),a.add(Qe._tempV35,Qe._tempV36,i)}getCorners(t){Qe.get3PlaneInterPoint(this._near,this._bottom,this._right,t[e.FrustumCorner.nearBottomRight]),Qe.get3PlaneInterPoint(this._near,this._top,this._right,t[e.FrustumCorner.nearTopRight]),Qe.get3PlaneInterPoint(this._near,this._top,this._left,t[e.FrustumCorner.nearTopLeft]),Qe.get3PlaneInterPoint(this._near,this._bottom,this._left,t[e.FrustumCorner.nearBottomLeft]),Qe.get3PlaneInterPoint(this._far,this._bottom,this._right,t[e.FrustumCorner.FarBottomRight]),Qe.get3PlaneInterPoint(this._far,this._top,this._right,t[e.FrustumCorner.FarTopRight]),Qe.get3PlaneInterPoint(this._far,this._top,this._left,t[e.FrustumCorner.FarTopLeft]),Qe.get3PlaneInterPoint(this._far,this._bottom,this._left,t[e.FrustumCorner.FarBottomLeft])}containsPoint(e){for(var t=Ye.PlaneIntersectionType_Front,r=Ye.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=qe.intersectsPlaneAndPoint(this._near,e);break;case 1:r=qe.intersectsPlaneAndPoint(this._far,e);break;case 2:r=qe.intersectsPlaneAndPoint(this._left,e);break;case 3:r=qe.intersectsPlaneAndPoint(this._right,e);break;case 4:r=qe.intersectsPlaneAndPoint(this._top,e);break;case 5:r=qe.intersectsPlaneAndPoint(this._bottom,e)}switch(r){case Ye.PlaneIntersectionType_Back:return Ze.Disjoint;case Ye.PlaneIntersectionType_Intersecting:t=Ye.PlaneIntersectionType_Intersecting}}switch(t){case Ye.PlaneIntersectionType_Intersecting:return Ze.Intersects;default:return Ze.Contains}}intersects(e){var t=e.min,r=e.max,i=t.x,n=t.y,a=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?n:o)+_.z*(_.z<0?a: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?n:o)+h.z*(h.z<0?a: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?n:o)+c.z*(c.z<0?a: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?n:o)+d.z*(d.z<0?a: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?n:o)+u.z*(u.z<0?a: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?n:o)+m.z*(m.z<0?a:l)<0)}containsBoundBox(e){for(var t=Qe._tempV30,r=Qe._tempV31,i=e.min,n=e.max,a=Ze.Contains,s=0;s<6;s++){var o=this.getPlane(s),l=o.normal;if(l.x>=0?(t.x=n.x,r.x=i.x):(t.x=i.x,r.x=n.x),l.y>=0?(t.y=n.y,r.y=i.y):(t.y=i.y,r.y=n.y),l.z>=0?(t.z=n.z,r.z=i.z):(t.z=i.z,r.z=n.z),qe.intersectsPlaneAndPoint(o,t)===Ye.PlaneIntersectionType_Back)return Ze.Disjoint;qe.intersectsPlaneAndPoint(o,r)===Ye.PlaneIntersectionType_Back&&(a=Ze.Intersects)}return a}containsBoundSphere(e){for(var t=Ye.PlaneIntersectionType_Front,r=Ye.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=qe.intersectsPlaneAndSphere(this._near,e);break;case 1:r=qe.intersectsPlaneAndSphere(this._far,e);break;case 2:r=qe.intersectsPlaneAndSphere(this._left,e);break;case 3:r=qe.intersectsPlaneAndSphere(this._right,e);break;case 4:r=qe.intersectsPlaneAndSphere(this._top,e);break;case 5:r=qe.intersectsPlaneAndSphere(this._bottom,e)}switch(r){case Ye.PlaneIntersectionType_Back:return Ze.Disjoint;case Ye.PlaneIntersectionType_Intersecting:t=Ye.PlaneIntersectionType_Intersecting}}switch(t){case Ye.PlaneIntersectionType_Intersecting:return Ze.Intersects;default:return Ze.Contains}}}Qe._tempV30=new a,Qe._tempV31=new a,Qe._tempV32=new a,Qe._tempV33=new a,Qe._tempV34=new a,Qe._tempV35=new a,Qe._tempV36=new a;class Ke{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){a.transformV3ToV4(e,t,r);var i=r.x,n=r.y,s=r.z,o=r.w;1!==o&&(i/=o,n/=o,s/=o),r.x=.5*(i+1)*this.width+this.x,r.y=.5*(1-n)*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 n=r.x*i[3]+r.y*i[7]+r.z*i[11]+i[15];a.transformV3ToV3(r,t,r),1!==n&&(r.x=r.x/n,r.y=r.y/n,r.z=r.z/n)}unprojectFromWVP(e,t,r,i,n){c.multiply(t,r,Ke._tempMatrix4x4),i&&c.multiply(Ke._tempMatrix4x4,i,Ke._tempMatrix4x4),Ke._tempMatrix4x4.invert(Ke._tempMatrix4x4),this.unprojectFromMat(e,Ke._tempMatrix4x4,n)}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}}Ke._tempMatrix4x4=new c;class Je{constructor(){}static calculateCursorRay(e,t,r,i,n,s){var o=e.x,l=e.y,_=Je._tempVector30,h=_;h.x=o,h.y=l,h.z=t.minDepth;var c=Je._tempVector31,d=c;d.x=o,d.y=l,d.z=t.maxDepth;var u=s.origin,m=Je._tempVector32;t.unprojectFromWVP(_,r,i,n,u),t.unprojectFromWVP(c,r,i,n,m);var f=s.direction;f.x=m.x-u.x,f.y=m.y-u.y,f.z=m.z-u.z,a.normalize(s.direction,s.direction)}static rayIntersectsTriangle(e,t,r,i){var n=Je._tempVector30,s=Je._tempVector31;a.subtract(r,t,n),a.subtract(i,t,s);var o,l=Je._tempVector32;if(a.cross(e.direction,s,l),(o=a.dot(n,l))>-Number.MIN_VALUE&&o1)return Number.NaN;var d,u,m=Je._tempVector34;return a.cross(c,n,m),d=a.dot(e.direction,m),(d*=h)<0||_+d>1?Number.NaN:(u=a.dot(s,m),(u*=h)<0?Number.NaN:u)}}Je._tempVector30=new a,Je._tempVector31=new a,Je._tempVector32=new a,Je._tempVector33=new a,Je._tempVector34=new a;class $e 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,n=i._shaderValues.getData();for(var a in this.vertexDeclaration=i,e.bind(),n){var s=parseInt(a),o=n[a];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,n=e.length;il&&(a=l);for(var _=0;_=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(re);if(i&&(i.avatar||e._changeAnimatorToLinkSprite3DNoAvatar(i,t,r)),this._parent&&this._parent instanceof _t){r.unshift(this._parent.name);var n=this._parent;n._hierarchyAnimator&&n._changeAnimatorsToLinkSprite3D(e,t,r)}}_setHierarchyAnimator(e,t){this._changeHierarchyAnimator(e),this._changeAnimatorAvatar(e.avatar);for(var r=0,i=this._children.length;re[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(ht.CAMERAPOS,this.transform.position),e.setVector3(ht.CAMERADIRECTION,this._forward),e.setVector3(ht.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 n(i[0],i[1],i[2],i[3]);var a=e.skyboxMaterial;a&&(this._skyRenderer.material=t.Loader.getRes(a.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 ht}}ht._tempMatrix4x40=new c,ht.CAMERAPOS=he.propertyNameToID("u_CameraPos"),ht.VIEWMATRIX=he.propertyNameToID("u_View"),ht.PROJECTMATRIX=he.propertyNameToID("u_Projection"),ht.VIEWPROJECTMATRIX=he.propertyNameToID("u_ViewProjection"),ht.CAMERADIRECTION=he.propertyNameToID("u_CameraDirection"),ht.CAMERAUP=he.propertyNameToID("u_CameraUp"),ht.VIEWPORT=he.propertyNameToID("u_Viewport"),ht.PROJECTION_PARAMS=he.propertyNameToID("u_ProjectionParams"),ht.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",ht.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",ht._invertYScaleMatrix=new c(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1),ht._invertYProjectionMatrix=new c,ht._invertYProjectionViewMatrix=new c,ht.CLEARFLAG_SOLIDCOLOR=0,ht.CLEARFLAG_SKY=1,ht.CLEARFLAG_DEPTHONLY=2,ht.CLEARFLAG_NONE=3,(xe=e.ShadowMode||(e.ShadowMode={}))[xe.None=0]="None",xe[xe.Hard=1]="Hard",xe[xe.SoftLow=2]="SoftLow",xe[xe.SoftHigh=3]="SoftHigh";class ct extends t.Resource{constructor(){super(),this._bufferState=new $e,this._bufferStateInvertUV=new $e;var e=t.LayaGL.instance;this._vertexBuffer=new at(64,e.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=ct._vertexDeclaration,this._vertexBuffer.setData(ct._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new at(64,e.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=ct._vertexDeclaration,this._vertexBufferInvertUV.setData(ct._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){ct._vertexDeclaration=new rt(16,[new it(0,tt.Vector4,ct.SCREENQUAD_POSITION_UV)]),ct.instance=new ct,ct.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)}}ct.SCREENQUAD_POSITION_UV=0,ct._vertices=new Float32Array([1,1,1,1,1,-1,1,0,-1,1,0,1,-1,-1,0,0]),ct._verticesInvertUV=new Float32Array([1,1,1,0,1,-1,1,1,-1,1,0,0,-1,-1,0,1]);class dt extends t.Resource{constructor(){super(),this._bufferState=new $e,this._bufferStateInvertUV=new $e;var e=t.LayaGL.instance;this._vertexBuffer=new at(48,e.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=dt._vertexDeclaration,this._vertexBuffer.setData(dt._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new at(48,e.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=dt._vertexDeclaration,this._vertexBufferInvertUV.setData(dt._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){dt._vertexDeclaration=new rt(16,[new it(0,tt.Vector4,dt.SCREENTRIANGLE_POSITION_UV)]),dt.instance=new dt,dt.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)}}dt.SCREENTRIANGLE_POSITION_UV=0,dt._vertices=new Float32Array([-1,-1,0,0,-1,3,0,2,3,-1,2,0]),dt._verticesInvertUV=new Float32Array([-1,-1,0,1,-1,3,0,-1,3,-1,2,1]);class ut{constructor(){this._commandBuffer=null}static __init__(){ut._screenShaderData=new ce,ut._screenShader=he.find("BlitScreen")}run(){}recover(){this._commandBuffer=null}}ut.SCREENTEXTURE_NAME="u_MainTex",ut.SCREENTEXTUREOFFSETSCALE_NAME="u_OffsetScale",ut.MAINTEXTURE_TEXELSIZE_NAME="u_MainTex_TexelSize",ut.SCREENTEXTURE_ID=he.propertyNameToID(ut.SCREENTEXTURE_NAME),ut.SCREENTEXTUREOFFSETSCALE_ID=he.propertyNameToID(ut.SCREENTEXTUREOFFSETSCALE_NAME),ut.MAINTEXTURE_TEXELSIZE_ID=he.propertyNameToID(ut.MAINTEXTURE_TEXELSIZE_NAME);class mt extends ut{constructor(){super(...arguments),this._source=null,this._dest=null,this._offsetScale=null,this._shader=null,this._shaderData=null,this._subShader=0,this._sourceTexelSize=new n,this._screenType=0}static create(e,t,r=null,i=null,n=null,a=0,s=mt._SCREENTYPE_QUAD){var o;return(o=mt._pool.length>0?mt._pool.pop():new mt)._source=e,o._dest=t,o._offsetScale=r,o._shader=i,o._shaderData=n,o._subShader=a,o._screenType=s,o}run(){var e=this._shader||ut._screenShader,r=this._shaderData||ut._screenShaderData,i=this._dest;t.LayaGL.instance.viewport(0,0,i?i.width:ne.clientWidth,i?i.height:ne.clientHeight),r.setTexture(ut.SCREENTEXTURE_ID,this._source),r.setVector(ut.SCREENTEXTUREOFFSETSCALE_ID,this._offsetScale||mt._defaultOffsetScale),this._sourceTexelSize.setValue(1/this._source.width,1/this._source.height,this._source.width,this._source.height),r.setVector(ut.MAINTEXTURE_TEXELSIZE_ID,this._sourceTexelSize),i&&i._start();for(var n=e.getSubShaderAt(this._subShader)._passes,a=0,s=n.length;a0?ft._pool.pop():new ft)._renderTexture=e,t}run(){this._renderTexture._start()}recover(){ft._pool.push(this),this._renderTexture=null}}ft._pool=[];class Tt extends ut{constructor(){super(...arguments),this._shaderData=null,this._nameID=0,this._texture=null}static create(e,t,r){var i;return(i=Tt._pool.length>0?Tt._pool.pop():new Tt)._shaderData=e,i._nameID=t,i._texture=r,i}run(){this._shaderData.setTexture(this._nameID,this._texture)}recover(){Tt._pool.push(this),this._shaderData=null,this._nameID=0,this._texture=null}}Tt._pool=[];class Et{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!==gt.LIGHTMAPBAKEDTYPE_BAKED&&this._addToScene()}_onInActive(){super._onInActive(),this.lightmapBakedType!==gt.LIGHTMAPBAKEDTYPE_BAKED&&this._removeFromScene()}_create(){return new gt}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}}gt.LIGHTMAPBAKEDTYPE_REALTIME=0,gt.LIGHTMAPBAKEDTYPE_MIXED=1,gt.LIGHTMAPBAKEDTYPE_BAKED=2,(De=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[De.NoCascades=0]="NoCascades",De[De.TwoCascades=1]="TwoCascades",De[De.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"}(Ce||(Ce={}));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 n=ae.createFromPool(e,r,St._shadowTextureFormat,i);return n.filterMode=t.FilterMode.Bilinear,n.wrapModeU=t.WarpMode.Clamp,n.wrapModeV=t.WarpMode.Clamp,n}static getShadowBias(t,i,n,a){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/n,l=-t._shadowDepthBias*o,_=-t._shadowNormalBias*o;if(t.shadowMode==e.ShadowMode.SoftHigh){const e=2.5;l*=e,_*=e}a.setValue(l,_,0,0)}static getCameraFrustumPlanes(e,t){Qe.getPlanesFromMatrix(e,t[Ce.Near],t[Ce.Far],t[Ce.Left],t[Ce.Right],t[Ce.Top],t[Ce.Bottom])}static getFarWithRadius(e,t){return Math.sqrt(e*e/t)}static getCascadesSplitDistance(t,r,i,n,a,s,o,l){l[0]=i;var _=n-i,h=Math.tan(.5*a),c=1+h*h*(s*s+1);switch(o){case e.ShadowCascadesMode.NoCascades:l[1]=St.getFarWithRadius(n,c);break;case e.ShadowCascadesMode.TwoCascades:l[1]=St.getFarWithRadius(i+_*t,c),l[2]=St.getFarWithRadius(n,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(n,c)}}static applySliceTransform(e,t,r,i,n){var a=St._tempMatrix0.elements,s=1/t,o=1/r;a[0]=e.resolution*s,a[5]=e.resolution*o,a[12]=e.offsetX*s,a[13]=e.offsetY*o,a[1]=a[2]=a[2]=a[4]=a[6]=a[7]=a[8]=a[9]=a[11]=a[14]=0,a[10]=a[15]=1;var l=16*i;N._mulMatrixArray(a,n,l,n,l)}static getDirectionLightShadowCullPlanes(t,r,i,n,s,o){var l=St._frustumCorners,_=St._backPlaneFaces,h=St._frustumPlaneNeighbors,c=St._frustumTwoPlaneCorners,d=St._edgePlanePoint2,u=o.cullPlanes,m=t[Ce.Near],f=t[Ce.Far],T=t[Ce.Left],E=t[Ce.Right],p=t[Ce.Bottom],g=t[Ce.Top],S=i[r]-n,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),Qe.get3PlaneInterPoint(R,p,E,l[e.FrustumCorner.nearBottomRight]),Qe.get3PlaneInterPoint(R,g,E,l[e.FrustumCorner.nearTopRight]),Qe.get3PlaneInterPoint(R,g,T,l[e.FrustumCorner.nearTopLeft]),Qe.get3PlaneInterPoint(R,p,T,l[e.FrustumCorner.nearBottomLeft]),Qe.get3PlaneInterPoint(v,p,E,l[e.FrustumCorner.FarBottomRight]),Qe.get3PlaneInterPoint(v,g,E,l[e.FrustumCorner.FarTopRight]),Qe.get3PlaneInterPoint(v,g,T,l[e.FrustumCorner.FarTopLeft]),Qe.get3PlaneInterPoint(v,p,T,l[e.FrustumCorner.FarBottomLeft]);for(var A=0,I=0;I<6;I++){var x;switch(I){case Ce.Near:x=R;break;case Ce.Far:x=v;break;default:x=t[I]}a.dot(x.normal,s)<0&&(x.cloneTo(u[A]),_[A]=I,A++)}var L=A;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=_,a.scale(s,l,m),a.add(n,m,m),l}static getMaxTileResolutionInAtlas(e,t,r){for(var i=Math.min(e,t),n=Math.floor(e/i)*Math.floor(t/i);n>1),n=Math.floor(e/i)*Math.floor(t/i);return i}static getDirectionalLightMatrices(e,t,r,i,n,s,o,l){var _=o.splitBoundSphere,h=_.center,d=_.radius,u=s/2,m=d*u/(u-St.atlasBorderSize),f=2*m,T=s/f,E=f/s,p=Math.ceil(a.dot(h,e)*T)*E,g=Math.ceil(a.dot(h,t)*T)*E,S=a.dot(h,r);h.x=e.x*p+t.x*g+r.x*S,h.y=e.y*p+t.y*g+r.y*S,h.z=e.z*p+t.z*g+r.z*S;var R=o.position,v=o.viewMatrix,A=o.projectionMatrix,I=o.viewProjectMatrix;o.resolution=s,o.offsetX=i%2*s,o.offsetY=Math.floor(i/2)*s,a.scale(r,d+n,R),a.subtract(h,R,R),c.createLookAt(R,h,e,v),c.createOrthoOffCenter(-m,m,-m,m,0,2*d+n,A),c.multiply(A,v,I),N._mulMatrixArray(St._shadowMapScaleOffsetMatrix.elements,I.elements,0,l,16*i)}static getSpotLightShadowData(e,t,r,i,n,a){var s=e.position=t.transform.position;e.resolution=r,a.setValue(1/r,1/r,r,r),e.offsetX=0,e.offsetY=0;var o=t.transform.worldMatrix,l=e.viewMatrix,_=e.projectionMatrix,h=e.viewProjectMatrix,d=e.cameraCullInfo.boundFrustum;o.invert(l),c.createPerspective(3.1416*t.spotAngle/180,1,.1,t.range,_),i.y=t.shadowStrength,c.multiply(_,l,h),d.matrix=h,h.cloneTo(n),e.cameraCullInfo.position=s}static prepareShadowReceiverShaderValues(e,t,r,i,n,a,s,o,l){if(a.setValue(1/t,1/r,t,r),s.setValue(e._shadowStrength,0,0,0),n>1){const e=16;for(var _=n*e,h=4*e;_=.5?Math.floor(i):o,d=l-n>=.5?Math.floor(n):l,u=a-_>=.5?Math.ceil(a):_,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;c.createOrthoOffCenter(-t,t,-e,e,this.nearPlane,this.farPlane,this._projectionMatrix)}else c.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&=f.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 Ke(i[0],i[1],i[2],i[3]);var n=e.enableHDR;void 0!==n&&(this.enableHDR=n)}_getCanvasWidth(){return this._offScreenRenderTexture?this._offScreenRenderTexture.width:ne.clientWidth}_getCanvasHeight(){return this._offScreenRenderTexture?this._offScreenRenderTexture.height:ne.clientHeight}_getRenderTexture(){return this._internalRenderTexture||this._offScreenRenderTexture}_needInternalRenderTexture(){return!(!this._postProcess&&!this._enableHDR)}_applyPostProcessCommandBuffers(){for(var e=0,t=this._postProcessCommandBuffers.length;e{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,t){var r=this._touchPool[e];return 0==t&&r&&-1!=r._getIndexInList()||1==t&&r&&-1==r._getIndexInList()?null:(r||(r=new Xe,this._touchPool[e]=r,r._identifier=e),r)}_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 n=0,a=i.length;n=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,n),this._scene._physicsSimulation.rayCast(n,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,n=u.length;i>a,1),Math.max(e>>a,1));this._setGPUMemory(e*e*4*(1+1/3)*6)}else this._mipmapCount=1,this._setGPUMemory(e*e*4*6)}static get blackTexture(){return Lt._blackTexture}static get grayTexture(){return Lt._grayTexture}static __init__(){var e=new Lt(1,t.TextureFormat.R8G8B8,!1),r=new Lt(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,Lt._grayTexture=r,Lt._blackTexture=e}static _parse(e,t=null,r=null){var i=r?new Lt(0,r[0],r[1]):new Lt(0);return i.setSixSideImageSources(e),i}static _parseBin(e,t=null,r=null){var i=r?new Lt(0,r[0],r[1]):new Lt(0);return i.setSixSideImageSources(e),i}static load(e,r){t.ILaya.loader.create(e,r,null,Lt.TEXTURECUBE)}get defaulteTexture(){return Lt.grayTexture}_setPixels(e,r,i,n){var a=t.LayaGL.instance,s=this._getGLFormat();t.WebGLContext.bindTexture(a,this._glTextureType,this._glTexture),this.format===t.TextureFormat.R8G8B8?(a.pixelStorei(a.UNPACK_ALIGNMENT,1),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[0]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[1]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[2]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[3]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[4]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[5]),a.pixelStorei(a.UNPACK_ALIGNMENT,4)):(a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[0]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[1]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[2]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[3]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[4]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[5]))}setSixSideImageSources(e,r=!1){for(var i,n,a=0;a<6;a++){var s=e[a];if(!s)return void console.log("TextureCube: image Source can't be null.");var o=s.width,l=s.height;if(a>0&&i!==o)return void console.log("TextureCube: each side image's width and height must same.");if((i=o)!==(n=l))return void console.log("TextureCube: each side image's width and height must same.")}this._width=i,this._height=n;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(n)?(_.generateMipmap(this._glTextureType),this._setGPUMemory(i*n*4*(1+1/3)*6)):this._setGPUMemory(i*n*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),n=Math.max(this._height>>r,1),a=i*n*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)}}Pt._tempVector0=new a,Pt._tempVector1=new a,Pt._type=Nt._typeCounter++;class wt extends _t{constructor(e){super(e)}static __init__(){wt.SHADERDEFINE_RECEIVE_SHADOW=he.getDefineByName("RECEIVESHADOW"),wt.SAHDERDEFINE_LIGHTMAP=he.getDefineByName("LIGHTMAP"),wt.SHADERDEFINE_LIGHTMAP_DIRECTIONAL=he.getDefineByName("LIGHTMAP_DIRECTIONAL")}_onInActive(){super._onInActive(),this._scene._removeRenderObject(this._render)}_onActive(){super._onActive(),this._scene._addRenderObject(this._render)}_onActiveInScene(){if(super._onActiveInScene(),_.Laya3D._editerEnvironment){var e=this._scene,t=new n;e._allotPickColorByID(this.id,t),e._pickIdToSprite[this.id]=this,this._render._shaderValues.setVector(wt.PICKCOLOR,t)}}_addToInitStaticBatchManager(){}_setBelongScene(e){super._setBelongScene(e),this._render._setBelongScene(e)}_setUnBelongScene(){this._render._shaderValues.removeDefine(wt.SAHDERDEFINE_LIGHTMAP),super._setUnBelongScene()}_changeHierarchyAnimator(e){if(this._hierarchyAnimator){var t=this._hierarchyAnimator._renderableSprites;t.splice(t.indexOf(this),1)}e&&e._renderableSprites.push(this),super._changeHierarchyAnimator(e)}destroy(e=!0){super.destroy(e),this._render._destroy(),this._render=null}_create(){return new wt(this.name)}}wt.LIGHTMAPSCALEOFFSET=he.propertyNameToID("u_LightmapScaleOffset"),wt.LIGHTMAP=he.propertyNameToID("u_LightMap"),wt.LIGHTMAP_DIRECTION=he.propertyNameToID("u_LightMapDirection"),wt.PICKCOLOR=he.propertyNameToID("u_PickColor");class Vt{constructor(){this.updateMark=-1,this.indexInList=-1,this.batched=!1}}class Bt extends Nt{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 at(4*this.instanceWorldMatrixData.length,e.DYNAMIC_DRAW),this.instanceMVPMatrixBuffer=new at(4*this.instanceMVPMatrixData.length,e.DYNAMIC_DRAW),this.instanceWorldMatrixBuffer.vertexDeclaration=nt.instanceWorldMatrixDeclaration,this.instanceMVPMatrixBuffer.vertexDeclaration=nt.instanceMVPMatrixDeclaration}static __init__(){Bt.instance=new Bt}_render(e){var r=t.LayaGL.instance,i=e.renderElement,n=i.instanceSubMesh,a=i.instanceBatchElementList.length,s=n._indexCount;n._mesh._instanceBufferState.bind(),t.LayaGL.layaGPUInstance.drawElementsInstanced(r.TRIANGLES,s,r.UNSIGNED_SHORT,2*n._indexStart,a),t.Stat.renderBatches++,t.Stat.savedRenderBatches+=a-1,t.Stat.trianglesFaces+=s*a/3}}class Ft{constructor(){this.renderSubShader=null,this.renderType=Ft.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 n=this.material._shader.getSubShaderAt(0);if(this.renderSubShader=null,r)if(i){var a=n.getFlag(i);if(!a)return;for(var s=r._subShaders,o=0,l=s.length;o1,n=i?t._indexCount:r._vertexCount;if(n<=_.SubMeshDynamicBatch.maxAllowVertexCount){var a=3*n;this._dynamicVertexBatch=!0,this._dynamicWorldPositions=new Float32Array(a),this._dynamicWorldNormals=new Float32Array(a),this._dynamicVertexCount=n,this._dynamicMultiSubMesh=i}else this._dynamicVertexBatch=!1}this._geometry=e}}addToOpaqueRenderQueue(e,r){var i=this.staticBatch,n=r.elements,a=n.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)a[l].staticBatchElementList.add(this);else{var h=a[l],c=h.render,d=s._getBatchRenderElementFromPool();d.renderType=Ft.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),a[l]=d,o.batched=!0}}else o.updateMark=s._updateCountMark,o.indexInList=n.length,o.batched=!1,n.add(this)}else if(this.renderSubShader._owner._enableInstancing&&t.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0){var T=this._geometry,E=_.MeshRenderDynamicBatchManager.instance,p=E.getInstanceBatchOpaquaMark(this.render.receiveShadow,this.material.id,T._id,this._transform._isFrontFaceInvert);if(E._updateCountMark===p.updateMark){var g=p.indexInList;if(p.batched){var S=a[g].instanceBatchElementList;S.length===Bt.instance.maxInstanceCount?(p.updateMark=E._updateCountMark,p.indexInList=n.length,p.batched=!1,n.add(this)):S.add(this)}else{var R=a[g],v=R.render,A=E._getBatchRenderElementFromPool();A.renderType=Ft.RENDERTYPE_INSTANCEBATCH,A.setGeometry(Bt.instance),A.material=R.material,A.setTransform(null),A.render=v,A.instanceSubMesh=T,A.renderSubShader=R.renderSubShader;var I=A.instanceBatchElementList;I.length=0,I.add(R),I.add(this),a[g]=A,p.batched=!0}}else p.updateMark=E._updateCountMark,p.indexInList=n.length,p.batched=!1,n.add(this)}else if(this._dynamicVertexBatch){var x=this._geometry._vertexBuffer.vertexDeclaration,L=_.MeshRenderDynamicBatchManager.instance,D=L.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,x.id);if(L._updateCountMark===D.updateMark){var C=D.indexInList;if(D.batched)a[C].vertexBatchElementList.add(this);else{var y=a[C],M=y.render,O=L._getBatchRenderElementFromPool();O.renderType=Ft.RENDERTYPE_VERTEXBATCH,O.setGeometry(_.SubMeshDynamicBatch.instance),O.material=y.material,O.setTransform(null),O.render=M,O.vertexBatchVertexDeclaration=x,O.renderSubShader=y.renderSubShader;var N=O.vertexBatchElementList;N.length=0,N.add(y),N.add(this),a[C]=O,D.batched=!0}}else D.updateMark=L._updateCountMark,D.indexInList=n.length,D.batched=!1,n.add(this)}else n.add(this)}addToTransparentRenderQueue(e,r){var i=this.staticBatch,n=r.elements,a=n.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)n.add(this),r.lastTransparentBatched=!1;else{if(r.lastTransparentBatched)a[n.length-1].staticBatchElementList.add(this);else{var h=s._getBatchRenderElementFromPool();h.renderType=Ft.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),a[n.length-1]=h}r.lastTransparentBatched=!0}}else n.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,T=r.lastTransparentRenderElement;if(T){var E=T.render;if(T._geometry._getType()!==this._geometry._getType()||T._geometry!==m||T.material!==this.material||E.receiveShadow!==this.render.receiveShadow)n.add(this),r.lastTransparentBatched=!1;else if(r.lastTransparentBatched){var p=a[n.length-1].instanceBatchElementList;p.length===Bt.instance.maxInstanceCount?(n.add(this),r.lastTransparentBatched=!1):(p.add(this),r.lastTransparentBatched=!0)}else{var g=f._getBatchRenderElementFromPool();g.renderType=Ft.RENDERTYPE_INSTANCEBATCH,g.setGeometry(Bt.instance),g.material=T.material,g.setTransform(null),g.render=this.render,g.instanceSubMesh=m,g.renderSubShader=T.renderSubShader;var S=g.instanceBatchElementList;S.length=0,S.add(T),S.add(this),a[n.length-1]=g,r.lastTransparentBatched=!0}}else n.add(this),r.lastTransparentBatched=!1}else if(this._dynamicVertexBatch){var R=this._geometry._vertexBuffer.vertexDeclaration,v=_.MeshRenderDynamicBatchManager.instance,A=r.lastTransparentRenderElement;if(A){var I=A.render;if(A._dynamicVertexBatch&&A._geometry._getType()===this._geometry._getType()&&A._geometry._vertexBuffer._vertexDeclaration===R&&A.material===this.material&&I.receiveShadow===this.render.receiveShadow&&I.lightmapIndex===this.render.lightmapIndex){if(r.lastTransparentBatched)a[n.length-1].vertexBatchElementList.add(this);else{var x=v._getBatchRenderElementFromPool();x.renderType=Ft.RENDERTYPE_VERTEXBATCH,x.setGeometry(_.SubMeshDynamicBatch.instance),x.material=A.material,x.setTransform(null),x.render=this.render,x.vertexBatchVertexDeclaration=R,x.renderSubShader=A.renderSubShader;var L=x.vertexBatchElementList;L.length=0,L.add(A),L.add(this),a[n.length-1]=x}r.lastTransparentBatched=!0}else n.add(this),r.lastTransparentBatched=!1}else n.add(this),r.lastTransparentBatched=!1}else n.add(this);r.lastTransparentRenderElement=this}getInvertFront(){switch(this.renderType){case Ft.RENDERTYPE_NORMAL:return this._transform._isFrontFaceInvert;case Ft.RENDERTYPE_STATICBATCH:case Ft.RENDERTYPE_VERTEXBATCH:return!1;case Ft.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 Gt{constructor(){this._initBatchSprites=[],this._staticBatches={},this._batchRenderElementPoolIndex=0,this._batchRenderElementPool=[]}static _addToStaticBatchQueue(e,t){e instanceof wt&&t.push(e);for(var r=0,i=e.numChildren;r0){for(var i=0;i0;)r--;if(t1){var i=this._partition(e,t,r),n=i-1;tzt.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 n=i._renderElements,a=0,s=n.length;a=i.length){var o=i;(i=Ge._cullingBuffer=new Float32Array(i.length+4096)).set(o,0)}i[r]=2,Ge._cullingBufferLength=s}this._renderElements=[],this._owner=e,this._enable=!0,this._materialsInstance=[],this._shaderValues=new ce(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(wt.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}_changeRenderObjects(e,t,r){var i=this._render._renderElements;r||(r=yt.defaultMaterial);var n=i[t];n||(n=i[t]=new Ft),n.setTransform(this._transform),n.setGeometry(this._geometryFilter),n.render=this._render,n.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 n=r[i];this._objects.push(n),n._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());jt._encapsulates(this._getChildBound(i),r.bounds._getBoundBox())&&(this._objects.splice(this._objects.indexOf(r),1),this._getChild(i)._add(r))}}var n=this._bestFitChild(e.bounds.getCenter());return jt._encapsulates(this._getChildBound(n),e.bounds._getBoundBox())?this._getChild(n)._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 qe.boxContainsBox(this._bounds,e.bounds._getBoundBox())===Ze.Contains?(this._add(e),!0):!!this._parent&&this._parent._addUp(e)}_getCollidingWithFrustum(e,r,i,n,s,o){var l=e.boundFrustum,_=e.position,h=e.cullingMask;if(i){var c=l.containsBoundBox(this._bounds);if(t.Stat.octreeNodeCulling++,c===Ze.Disjoint)return;i=c===Ze.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(qe.boxContainsBox(this._bounds,e.bounds._getBoundBox())===Ze.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!!jt._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=qe.intersectsRayAndBoxRD(e,this._bounds);if(!(-1==i||i>r)){for(var n=0,a=this._objects.length;nt)return!1;for(var i=0,n=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 jt(this,null,e,t)}_getMaxDepth(e,t){t++;var r=e._children;if(null!=r)for(var i=t,n=0,a=r.length;n=0?1:-1,r=e.y>=0?1:-1,i=e.z>=0?1:-1,n=this._rootNode,s=this._rootNode.baseLength/2,o=2*this._rootNode.baseLength,l=this._rootNode.center,_=new a(l.x+t*s,l.y+r*s,l.z+i*s);if(this._rootNode=new jt(this,null,o,_),n.hasAnyObjects()){for(var h=this._rootNode._bestFitChild(n.center),c=[],d=0;d<8;d++)d==h&&(n._parent=this._rootNode,c[d]=n);this._rootNode._children=c}}add(e){for(var t=0;!this._rootNode.add(e);){var r=qt._tempVector30;if(a.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(a.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 n=t+r,s=Kt._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");Kt.createFromSubPoints(e,0,e.length,t)}intersectsRayDistance(e){return qe.intersectsRayAndSphereRD(e,this)}intersectsRayPoint(e,t){return qe.intersectsRayAndSphereRP(e,this,t)}cloneTo(e){var t=e;this.center.cloneTo(t.center),t.radius=this.radius}clone(){var e=new Kt(new a,0);return this.cloneTo(e),e}}Kt._tempVector3=new a;class Jt{constructor(){this.cameraShaderValue=new ce,this.position=new a,this.viewMatrix=new c,this.projectionMatrix=new c,this.viewProjectMatrix=new c,this.cullPlanes=[new Ye(new a),new Ye(new a),new Ye(new a),new Ye(new a),new Ye(new a),new Ye(new a),new Ye(new a),new Ye(new a),new Ye(new a),new Ye(new a)],this.splitBoundSphere=new Kt(new a,0)}}class $t{constructor(){this.cameraShaderValue=new ce,this.position=new a,this.viewMatrix=new c,this.projectionMatrix=new c,this.viewProjectMatrix=new c,this.cameraCullInfo=new Fe}}(Oe=e.ShadowLightType||(e.ShadowLightType={}))[Oe.DirectionLight=0]="DirectionLight",Oe[Oe.SpotLight=1]="SpotLight",Oe[Oe.PointLight=2]="PointLight";class er{constructor(){this._shadowBias=new n,this._shadowParams=new n,this._shadowMapSize=new n,this._shadowMatrices=new Float32Array(16*er._maxCascades),this._shadowSpotMatrices=new c,this._splitBoundSpheres=new Float32Array(4*er._maxCascades),this._cascadeCount=0,this._shadowMapWidth=0,this._shadowMapHeight=0,this._shadowSliceDatas=[new Jt,new Jt,new Jt,new Jt],this._shadowSpotData=new $t,this._lightUp=new a,this._lightSide=new a,this._lightForward=new a,this._shadowSpotData.cameraCullInfo.boundFrustum=new Qe(new c)}_setupShadowCasterShaderValues(t,r,i,n,a,s,o){switch(r.setVector(er.SHADOW_BIAS,s),o){case e.LightType.Directional:r.setVector3(er.SHADOW_LIGHT_DIRECTION,n);break;case e.LightType.Spot:r.setVector(er.SHADOW_PARAMS,a);break;case e.LightType.Point:}var l=i.cameraShaderValue;l.setMatrix4x4(ht.VIEWMATRIX,i.viewMatrix),l.setMatrix4x4(ht.PROJECTMATRIX,i.projectionMatrix),l.setMatrix4x4(ht.VIEWPROJECTMATRIX,i.viewProjectMatrix),t.viewMatrix=i.viewMatrix,t.projectionMatrix=i.projectionMatrix,t.projectionViewMatrix=i.viewProjectMatrix}_setupShadowReceiverShaderValues(t){var r=this._light;switch(r.shadowCascadesMode!==e.ShadowCascadesMode.NoCascades?t.addDefine(pt.SHADERDEFINE_SHADOW_CASCADE):t.removeDefine(pt.SHADERDEFINE_SHADOW_CASCADE),r.shadowMode){case e.ShadowMode.Hard:t.removeDefine(pt.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW),t.removeDefine(pt.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftLow:t.addDefine(pt.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW),t.removeDefine(pt.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftHigh:t.addDefine(pt.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH),t.removeDefine(pt.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW)}t.setTexture(er.SHADOW_MAP,this._shadowDirectLightMap),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)}_setupSpotShadowReceiverShaderValues(t){switch(this._light.shadowMode){case e.ShadowMode.Hard:t.removeDefine(pt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH),t.removeDefine(pt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW);break;case e.ShadowMode.SoftLow:t.addDefine(pt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW),t.removeDefine(pt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftHigh:t.addDefine(pt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH),t.removeDefine(pt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW)}t.setTexture(er.SHADOW_SPOTMAP,this._shadowSpotLightMap),t.setMatrix4x4(er.SHADOW_SPOTMATRICES,this._shadowSpotMatrices),t.setVector(er.SHADOW_MAP_SIZE,this._shadowMapSize),t.setVector(er.SHADOW_PARAMS,this._shadowParams)}update(t,i,n){switch(n){case e.ShadowLightType.DirectionLight:this._light=i;var s=(L=er._tempMatrix0).elements,o=this._lightUp,l=this._lightSide,_=this._lightForward;c.createFromQuaternion(i._transform.rotation,L),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,d,u,m,f=i._shadowResolution,T=i._shadowCascadesMode;T==e.ShadowCascadesMode.NoCascades?(h=1,d=f,u=f,m=f):(h=T==e.ShadowCascadesMode.TwoCascades?2:4,u=2*(d=St.getMaxTileResolutionInAtlas(f,f,h)),m=T==e.ShadowCascadesMode.TwoCascades?d:2*d),this._cascadeCount=h,this._shadowMapWidth=u,this._shadowMapHeight=m;var E=er._cascadesSplitDistance,p=er._frustumPlanes,g=t.nearPlane,S=Math.min(t.farPlane,i._shadowDistance),R=this._shadowMatrices,v=this._splitBoundSpheres;St.getCascadesSplitDistance(i._shadowTwoCascadeSplits,i._shadowFourCascadeSplits,g,S,t.fieldOfView*r.Deg2Rad,t.aspectRatio,T,E),St.getCameraFrustumPlanes(t.projectionViewMatrix,p);var A=er._tempVector30;t._transform.getForward(A),a.normalize(A,A);for(var I=0;I1&&St.applySliceTransform(x,u,m,I,R)}St.prepareShadowReceiverShaderValues(i,u,m,this._shadowSliceDatas,h,this._shadowMapSize,this._shadowParams,R,v);break;case e.ShadowLightType.SpotLight:this._light=i;var L=er._tempMatrix0,D=(_=this._lightForward,this._light._shadowResolution);this._shadowMapWidth=D,this._shadowMapHeight=D;var C=this._shadowSpotData;St.getSpotLightShadowData(C,this._light,D,this._shadowParams,this._shadowSpotMatrices,this._shadowMapSize);break;case e.ShadowLightType.PointLight:break;default:throw"There is no shadow of this type"}}render(r,i,n){switch(n){case e.ShadowLightType.DirectionLight:var a=i._shaderValues;r.pipelineMode="ShadowCaster",ce.setRuntimeValueMode(!1),(T=this._shadowDirectLightMap=St.getTemporaryShadowTexture(this._shadowMapWidth,this._shadowMapHeight,t.RenderTextureDepthFormat.DEPTH_16))._start();for(var s=this._light,o=0,l=this._cascadeCount;oe._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),n=e-=255*i;t.x=r/255,t.y=i/255,t.z=n/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.getBrightestLight();this._mainDirectionLight=s[o],this._directionLights.normalLightOrdering(o);for(var l=0;l0){var u=this._pointLights._elements,m=this._pointLights.getBrightestLight();this._mainPointLight=u[m],this._pointLights.normalLightOrdering(m);for(l=0;l0){var E=this._spotLights._elements,p=this._spotLights.getBrightestLight();this._mainSpotLight=E[p],this._spotLights.normalLightOrdering(p);for(l=0;l0&&t.setSubPixels(0,0,v,i,r,0),e.setTexture(rr.LIGHTBUFFER,t),e.setInt(rr.DIRECTIONLIGHTCOUNT,this._directionLights._length),e.setTexture(rr.CLUSTERBUFFER,He.instance._clusterTexture)}else{if(this._directionLights._length>0){var S=this._directionLights._elements[0];this._mainDirectionLight=S,a.scale(S.color,S._intensity,S._intensityColor),S.transform.worldMatrix.getForward(S._direction),a.normalize(S._direction,S._direction),e.setVector3(rr.LIGHTDIRCOLOR,S._intensityColor),e.setVector3(rr.LIGHTDIRECTION,S._direction),e.setVector3(rr.SUNLIGHTDIRCOLOR,S._intensityColor),e.setVector3(rr.SUNLIGHTDIRECTION,S._direction),e.addDefine(pt.SHADERDEFINE_DIRECTIONLIGHT)}else e.removeDefine(pt.SHADERDEFINE_DIRECTIONLIGHT);if(this._pointLights._length>0){var R=this._pointLights._elements[0];a.scale(R.color,R._intensity,R._intensityColor),e.setVector3(rr.POINTLIGHTCOLOR,R._intensityColor),e.setVector3(rr.POINTLIGHTPOS,R.transform.position),e.setNumber(rr.POINTLIGHTRANGE,R.range),e.addDefine(pt.SHADERDEFINE_POINTLIGHT)}else e.removeDefine(pt.SHADERDEFINE_POINTLIGHT);if(this._spotLights._length>0){var v=this._spotLights._elements[0];a.scale(v.color,v._intensity,v._intensityColor),e.setVector3(rr.SPOTLIGHTCOLOR,v._intensityColor),e.setVector3(rr.SPOTLIGHTPOS,v.transform.position),v.transform.worldMatrix.getForward(v._direction),a.normalize(v._direction,v._direction),e.setVector3(rr.SPOTLIGHTDIRECTION,v._direction),e.setNumber(rr.SPOTLIGHTRANGE,v.range),e.setNumber(rr.SPOTLIGHTSPOTANGLE,v.spotAngle*Math.PI/180),e.addDefine(pt.SHADERDEFINE_SPOTLIGHT)}else e.removeDefine(pt.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 n=this._cullingBufferIndices,a=this._cullingBufferResult;this._cullingBufferIndices=new Int32Array(i+1024),this._cullingBufferResult=new Int32Array(i+1024),this._cullingBufferIndices.set(n,0),this._cullingBufferResult.set(a,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}_clearRenderQueue(){this._opaqueQueue.clear(),this._transparentQueue.clear();for(var e=Gt._managers,t=0,r=e.length;t0&&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(n),u=null,s.text=l,(c=l.indexOf("#"))>=0){for(_="#",T=c+1,f=l.length;T0&&t.ShaderCompile.splitToWords(l,o),u=s,o.text+="\n"+l;continue}n.length>0&&t.ShaderCompile.splitToWords(l,s)}s.setParent(e)}}_resizeCacheShaderMap(e,t,r){var i=this._cacheShaderHierarchy-1;if(t==i){for(var n in e)for(var a=e[n],s=0,o=r-i;sthis._cacheShaderHierarchy&&(this._resizeCacheShaderMap(a,0,s),this._cacheShaderHierarchy=s);for(var o=e._mask,l=e._length-1,_=this._cacheShaderHierarchy-1,h=0;h<_;h++){var c=lTr.maxIndicesCount&&(this._flush(a,s),o++,t.Stat.trianglesFaces+=s/3,a=s=0);var m=c._transform;this._getBatchVertices(i,this._vertices,a,m,c,d),this._getBatchIndices(this._indices,s,a,m,d,c._dynamicMultiSubMesh),a+=c._dynamicVertexCount,s+=u}this._flush(a,s),o++,t.Stat.renderBatches+=o,t.Stat.savedRenderBatches+=l-o,t.Stat.trianglesFaces+=s/3}}Tr.maxAllowVertexCount=10,Tr.maxAllowAttribueCount=900,Tr.maxIndicesCount=32e3;class Er extends tr{constructor(){super(),this._instanceBatchOpaqueMarks=[],this._vertexBatchOpaqueMarks=[],this._cacheBufferStates=[],this._updateCountMark=0}getInstanceBatchOpaquaMark(e,t,r,i){var n=this._instanceBatchOpaqueMarks[e?0:1]||(this._instanceBatchOpaqueMarks[e?0:1]=[]),a=n[t]||(n[t]=[]),s=a[r]||(a[r]=[]);return s[i?1:0]||(s[i?1:0]=new Vt)}getVertexBatchOpaquaMark(e,t,r,i){var n=this._vertexBatchOpaqueMarks[e]||(this._vertexBatchOpaqueMarks[e]=[]),a=n[t?0:1]||(n[t?0:1]=[]),s=a[r]||(a[r]=[]);return s[i]||(s[i]=new Vt)}_getBufferState(e){var t=this._cacheBufferStates[e.id];if(!t){var r=Tr.instance;(t=new $e).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 Ut,this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=e,e.vertexBatchElementList=new I,e.instanceBatchElementList=new I),e}_clear(){super._clear(),this._updateCountMark++}}Er.instance=new Er;class pr extends wt{constructor(e=null,t=null){super(t),this._meshFilter=new fr(this),this._render=new mr(this),e&&(this._meshFilter.sharedMesh=e)}static __init__(){ur.SHADERDEFINE_UV0=he.getDefineByName("UV"),ur.SHADERDEFINE_COLOR=he.getDefineByName("COLOR"),ur.SHADERDEFINE_UV1=he.getDefineByName("UV1"),ur.SHADERDEFINE_GPU_INSTANCE=he.getDefineByName("GPU_INSTANCE"),Gt._registerManager(Ht.instance),tr._registerManager(Er.instance)}get meshFilter(){return this._meshFilter}get meshRenderer(){return this._render}_parse(e,r){super._parse(e,r);var i=this.meshRenderer,a=e.lightmapIndex;null!=a&&(i.lightmapIndex=a);var s=e.lightmapScaleOffset;s&&(i.lightmapScaleOffset=new n(s[0],s[1],s[2],s[3])),null!=e.meshPath&&(this.meshFilter.sharedMesh=t.Loader.getRes(e.meshPath)),null!=e.enableRender&&(i.enable=e.enableRender),null!=e.receiveShadows&&(i.receiveShadow=e.receiveShadows),null!=e.castShadow&&(i.castShadow=e.castShadow);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&&Ht.instance._addBatchSprite(this)}_cloneTo(e,t,r){var i=e;i._meshFilter.sharedMesh=this._meshFilter.sharedMesh;var n=this._render,a=i._render;a.enable=n.enable,a.sharedMaterials=n.sharedMaterials,a.castShadow=n.castShadow;var s=n.lightmapScaleOffset;s&&(a.lightmapScaleOffset=s.clone()),a.lightmapIndex=n.lightmapIndex,a.receiveShadow=n.receiveShadow,a.sortingFudge=n.sortingFudge,super._cloneTo(e,t,r)}destroy(e=!0){this.destroyed||(super.destroy(e),this._meshFilter.destroy())}_create(){return new pr}}class gr{}gr.Blend=0,gr.Fixed=1;class Sr{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=n[o]))return t.r=n[o+1],t.g=n[o+2],t.b=n[o+3],a;switch(this._mode){case gr.Blend:if(e>u){if(e>(d=n[o+4]))throw"Gradient:wrong startSearchIndex.";var l=d-u,_=d-e,h=e-u;return t.r=(_*n[o+1]+h*n[o+5])/l,t.g=(_*n[o+2]+h*n[o+6])/l,t.b=(_*n[o+3]+h*n[o+7])/l,a}a--;continue;case gr.Fixed:if(e>u){if(e>n[o+4])throw"Gradient:wrong startSearchIndex.";return t.r=n[o+5],t.g=n[o+6],t.b=n[o+7],a}a--;continue;default:throw"Gradient:unknown mode."}}else{s=0;for(var c=this._rgbElements.length;s=0;s--){if(e===(u=n[c=2*s]))return t.a=n[c+1],a;switch(this._mode){case gr.Blend:if(e>u){if(e>(d=n[c+2]))throw"Gradient:wrong startSearchIndex.";var o=d-u,l=d-e,_=e-u;return t.a=(l*n[c+1]+_*n[c+3])/o,a}a--;continue;case gr.Fixed:if(e>u){if(e>n[c+2])throw"Gradient:wrong startSearchIndex.";return t.a=n[c+3],a}a--;continue;default:throw"Gradient:unknown mode."}}else{s=a;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 qr{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,n=this._bursts.length;i=r){var s=e.getKeyByIndex(i-1),o=(r-s)/(a-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,n){var a;i?(i.seed=n[6],a=i.getFloat(),n[6]=i.seed):a=Math.random(),a=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(Hr.SHADERDEFINE_SHAPE):this._owner._render._shaderValues.removeDefine(Hr.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,n=this._emission._bursts,a=n.length;this._burstsIndexthis.duration){if(!this.looping){for(n=Math.min(this.maxParticles-this.aliveParticleCount,n),r=0;r0){var s=1/a;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,n=this._ownerRender,a=n.renderMode;if(-1!==a&&this.maxParticles>0){var s,o,l,_,h,c,d,u=0,m=(r=0,n.mesh);if(4===a){if(m){d=jr.vertexDeclaration,this._floatCountPerVertex=d.vertexStride/4,this._startLifeTimeIndex=12,this._timeIndex=16,this._vertexStride=m._vertexCount;var f=this._bufferMaxParticles*this._vertexStride,T=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*T,this._vertexBuffer=new at(u,i.DYNAMIC_DRAW),this._vertexBuffer.vertexDeclaration=d,this._vertices=new Float32Array(this._floatCountPerVertex*T),this._indexStride=m._indexBuffer.indexCount;var E=m._indexBuffer.getData(),p=this._bufferMaxParticles*this._indexStride;for(this._indexBuffer=new et(e.IndexFormat.UInt16,p,i.STATIC_DRAW),s=new Uint16Array(p),r=u+2*p,h=0,o=0;o=this._bufferMaxParticles&&(n=0),n===this._firstRetiredElement)return!1;var s,o,l,_,h,c,d,u,m,f,T=this._owner.transform;if(Qr.create(this,this._ownerRender,T),this._currentTime-i>=Qr.startLifeTime)return!0;switch(0==this.simulationSpace&&(s=T.position,o=T.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 E=this._velocityOverLifetime&&this._velocityOverLifetime.enable;if(E){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):E=!1}else E=!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 A=this._textureSheetAnimation&&this._textureSheetAnimation.enable;A?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):A=!1:A=!1;var I,x,L,D,C,y,M=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,O=Qr.startUVInfo[0],N=Qr.startUVInfo[1],b=Qr.startUVInfo[2],P=Qr.startUVInfo[3],w=this._ownerRender;if(4===w.renderMode){var V=w.mesh._vertexBuffer;I=V.getFloat32Data();var B=V.vertexDeclaration;L=B.getVertexElementByUsage(nt.MESH_POSITION0)._offset/4;var F=B.getVertexElementByUsage(nt.MESH_COLOR0);D=F?F._offset/4:-1;var U=B.getVertexElementByUsage(nt.MESH_TEXTURECOORDINATE0);C=U?U._offset/4:-1,x=B.vertexStride/4,y=0}else{this._vertices[M+2]=b,this._vertices[M+3]=P+N;var G=M+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=M,k=M+this._floatCountPerVertex*this._vertexStride;W0&&this._vertexBuffer.setData(this._vertices.buffer,0,0,this._firstFreeElement*t)),this._firstNewElement=this._firstFreeElement}_getType(){return Kr._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,console.warn("GradientDataColor warning:alpha data length is large than 4, will ignore the middle data."));var a=n[r];t.addColorAlpha(a.key,a.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 Be(l[0],l[1],l[2],1))}else t.addColorRGB(0,new Be(1,1,1,1)),t.addColorRGB(1,new Be(1,1,1,1))}else t.addColorAlpha(0,1),t.addColorAlpha(1,1),t.addColorRGB(0,new Be(1,1,1,1)),t.addColorRGB(1,new Be(1,1,1,1));return t}_initParticleFrame(e){var t=new Lr;if(e)for(var r=e.frames,i=0,n=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 n=2*this._floatCountPerVertices1*i,s=this._owner._curtime;this._vertices1[n]=e.x,this._vertices1[n+1]=e.y,this._vertices1[n+2]=e.z,this._vertices1[n+3]=-r.x,this._vertices1[n+4]=-r.y,this._vertices1[n+5]=-r.z,this._vertices1[n+6]=s,this._vertices1[n+7]=1,this._vertices1[n+8]=e.x,this._vertices1[n+9]=e.y,this._vertices1[n+10]=e.z,this._vertices1[n+11]=r.x,this._vertices1[n+12]=r.y,this._vertices1[n+13]=r.z,this._vertices1[n+14]=s,this._vertices1[n+15]=0;var o=this._owner._owner.trailRenderer.bounds,l=o.getMin(),_=o.getMax(),h=ai._tempVector35,c=ai._tempVector36,d=ai._tempVector32;a.add(e,r,h),a.subtract(e,r,c),a.min(c,h,d),a.min(l,d,l),o.setMin(l),a.max(h,c,d),a.max(_,d,_),o.setMax(_),t.Render.supportWebGLPlusCulling&&this._calculateBoundingBoxForNative();var u=2*this._floatCountPerVertices1;this._vertexBuffer1.setData(this._vertices1.buffer,4*n,4*n,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 n=this._owner._owner.transform.position;e.setMin(n),e.setMax(n),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 n=this._lastFixedVertexPosition;n.x=this._vertices1[0],n.y=this._vertices1[1],n.z=this._vertices1[2],this._isTempEndVertex=!1}this._activeIndex++,this._disappearBoundsMode=!0}}_getType(){return ai._type}_prepareRender(e){return this._endIndex-this._activeIndex>1}_render(e){this._bufferState.bind();var r=t.LayaGL.instance,i=2*this._activeIndex,n=2*this._endIndex-i;r.drawArrays(r.TRIANGLE_STRIP,i,n),t.Stat.renderBatches++,t.Stat.trianglesFaces+=n-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(),n=Ge._cullingBuffer;n[e._cullingBufferIndex+1]=r.x,n[e._cullingBufferIndex+2]=r.y,n[e._cullingBufferIndex+3]=r.z,n[e._cullingBufferIndex+4]=i.x,n[e._cullingBufferIndex+5]=i.y,n[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)}}ai.ALIGNMENT_VIEW=0,ai.ALIGNMENT_TRANSFORM_Z=1,ai._tempVector30=new a,ai._tempVector31=new a,ai._tempVector32=new a,ai._tempVector33=new a,ai._tempVector34=new a,ai._tempVector35=new a,ai._tempVector36=new a,ai._type=Nt._typeCounter++;class si{constructor(e){this._totalLength=0,this._lastPosition=new a,this._curtime=0,this.alignment=si.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(si.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),n=0;for(t=0,r=e.length;t{},setWorldTransform:(e,t)=>{var r=A._physicObjectsMap[e];r._simulation._updatedRigidbodies++,r._updateTransformComponent(t)}};class ci extends P{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,A.ACTIVATIONSTATE_DISABLE_SIMULATION);var r=e.btCollisionObject_getCollisionFlags(t);this.owner.isStatic?((r&A.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(r^=A.COLLISIONFLAGS_KINEMATIC_OBJECT),r|=A.COLLISIONFLAGS_STATIC_OBJECT):((r&A.COLLISIONFLAGS_STATIC_OBJECT)>0&&(r^=A.COLLISIONFLAGS_STATIC_OBJECT),r|=A.COLLISIONFLAGS_KINEMATIC_OBJECT),e.btCollisionObject_setCollisionFlags(t,r),this._btColliderObject=t,super._onAdded()}}class di extends Nt{constructor(e){super(),this._id=++di._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 di._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 n,a,s=t.LayaGL.instance,o=r.renderElement.render._skinnedData;switch(i.indexFormat){case e.IndexFormat.UInt32:n=s.UNSIGNED_INT,a=4;break;case e.IndexFormat.UInt16:n=s.UNSIGNED_SHORT,a=2;break;case e.IndexFormat.UInt8:n=s.UNSIGNED_BYTE,a=1}if(i._bufferState.bind(),o)for(var l=o[this._indexInMesh],_=0,h=this._boneIndicesList.length;_ 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 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\n#ifdef CALCULATE_SPOTSHADOWS\r\n\tTEXTURE2D_SHADOW(u_SpotShadowMap);\r\n\tuniform mat4 u_SpotViewProjectMatrix;\r\n\tfloat sampleSpotShadowmap(vec4 shadowCoord)\r\n\t{\r\n\t\tshadowCoord.xyz /= shadowCoord.w;\r\n\t\tfloat attenuation = 1.0;\r\n\t\tshadowCoord.xy +=1.0;\r\n\t\tshadowCoord.xy/=2.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_SPOT_SOFT_SHADOW_HIGH)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered9(u_SpotShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#elif defined(SHADOW_SPOT_SOFT_SHADOW_LOW)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered4(u_SpotShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#else\r\n\t\t\t\tattenuation = SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,shadowCoord.xyz);\r\n\t\t\t#endif\r\n\t\t\tattenuation = mix(1.0,attenuation,u_ShadowParams.y);//shadowParams.y: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'),he.addInclude("ShadowCasterVS.glsl",'#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\n#ifdef SHADOW\r\n\tuniform vec3 u_ShadowLightDirection;\r\n#endif\r\n\r\n\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\t#ifdef SHADOW\r\n\t\tpositionWS.xyz = applyShadowBias(positionWS.xyz,normalWS,u_ShadowLightDirection);\r\n\t#endif\r\n\r\n\tvec4 positionCS = u_ViewProjection * positionWS;\r\n\t#ifdef SHADOW_SPOT\r\n\t\tpositionCS.z = positionCS.z-u_ShadowBias.x/positionCS.w;\r\n\t#endif\r\n\tpositionCS.z = max(positionCS.z, 0.0);//min ndc z is 0.0\r\n\t\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'),he.addInclude("ShadowCasterFS.glsl","// #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"),he.addInclude("Colors.glsl",'#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}'),he.addInclude("Sampling.glsl","// 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}"),he.addInclude("StdLib.glsl","#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}"),he.addInclude("PBRVSInput.glsl","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 CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif"),he.addInclude("PBRFSInput.glsl","#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#ifdef CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\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"),he.addInclude("LayaPBRBRDF.glsl",'// allow to explicitly override LAYA_BRDF_GI and LAYA_BRDF_LIGHT in custom shader,default is layaBRDFHighGI and layaBRDFHighLight\r\n#if !defined (LAYA_BRDF_GI) \r\n\t#if defined(LAYA_PBR_BRDF_LOW)\r\n\t\t#define LAYA_BRDF_GI layaBRDFLowGI\r\n\t#elif defined(LAYA_PBR_BRDF_HIGH)\r\n\t\t#define LAYA_BRDF_GI layaBRDFHighGI\r\n\t#endif\r\n#endif\r\n#if !defined (LAYA_BRDF_LIGHT)\r\n\t#if defined(LAYA_PBR_BRDF_LOW)\r\n\t\t#define LAYA_BRDF_LIGHT layaBRDFLowLight\r\n\t#elif defined(LAYA_PBR_BRDF_HIGH)\r\n\t\t#define LAYA_BRDF_LIGHT layaBRDFHighLight\r\n\t#endif\r\n#endif\r\n\r\n#define PI 3.14159265359\r\n#define INV_PI 0.31830988618\r\n\r\nmediump float pow4(mediump float x)\r\n{\r\n\treturn x * x * x * x;\r\n}\r\n\r\nmediump float pow5(mediump float x)\r\n{\r\n\treturn x * x * x * x * x;\r\n}\r\n\r\nmediump vec3 fresnelLerp(mediump vec3 F0,mediump vec3 F90,mediump float cosA)\r\n{\r\n\tfloat t = pow5(1.0 - cosA); // ala Schlick interpoliation\r\n\treturn mix(F0, F90, t);\r\n}\r\n\r\nmediump vec3 fresnelTerm(mediump vec3 F0,mediump float cosA)\r\n{\r\n\tfloat t = pow5(1.0 - cosA); // ala Schlick interpoliation\r\n\treturn F0 + (vec3(1.0) - F0) * t;\r\n}\r\n\r\n// approximage Schlick with ^4 instead of ^5\r\nmediump vec3 fresnelLerpFast (mediump vec3 F0, mediump vec3 F90,mediump float cosA)\r\n{\r\n mediump float t = pow4 (1.0 - cosA);\r\n return mix (F0, F90, t);\r\n}\r\n\r\nfloat smoothnessToPerceptualRoughness(float smoothness)\r\n{\r\n return 1.0 - smoothness;\r\n}\r\n\r\nfloat perceptualRoughnessToRoughness(float perceptualRoughness)\r\n{\r\n return perceptualRoughness * perceptualRoughness;\r\n}\r\n\r\nvec3 safeNormalize(vec3 inVec)\r\n{\r\n\tfloat dp3 = max(0.001,dot(inVec,inVec));\r\n\treturn inVec * inversesqrt(dp3);\r\n}\r\n\r\n// Note: Disney diffuse must be multiply by diffuseAlbedo / PI. This is done outside of this function.\r\nmediump float disneyDiffuse(mediump float NdotV,mediump float NdotL,mediump float LdotH,mediump float perceptualRoughness)\r\n{\r\n\t//https://www.cnblogs.com/herenzhiming/articles/5790389.html\r\n\tmediump float fd90 = 0.5 + 2.0 * LdotH * LdotH * perceptualRoughness;\r\n\t// Two schlick fresnel term\r\n\tmediump float lightScatter = (1.0 + (fd90 - 1.0) * pow5(1.0 - NdotL));\r\n\tmediump float viewScatter = (1.0 + (fd90 - 1.0) * pow5(1.0 - NdotV));\r\n\r\n\treturn lightScatter * viewScatter;\r\n}\r\n\r\n// Ref: http://jcgt.org/published/0003/02/03/paper.pdf\r\nfloat smithJointGGXVisibilityTerm(float NdotL, float NdotV, float roughness)\r\n{\r\n\t// Original formulation:\r\n // lambda_v = (-1 + sqrt(a2 * (1 - NdotL2) / NdotL2 + 1)) * 0.5f;\r\n // lambda_l = (-1 + sqrt(a2 * (1 - NdotV2) / NdotV2 + 1)) * 0.5f;\r\n // G = 1 / (1 + lambda_v + lambda_l);\r\n\r\n\t// scientific code implement:\r\n\t// Reorder code to be more optimal\r\n // half a = roughness;\r\n // half a2 = a * a;\r\n\r\n // half lambdaV = NdotL * sqrt((-NdotV * a2 + NdotV) * NdotV + a2);\r\n // half lambdaL = NdotV * sqrt((-NdotL * a2 + NdotL) * NdotL + a2);\r\n\r\n // Simplify visibility term: (2.0f * NdotL * NdotV) / ((4.0f * NdotL * NdotV) * (lambda_v + lambda_l + 1e-5f));\r\n // return 0.5f / (lambdaV + lambdaL + 1e-5f); \r\n\t// This function is not intended to be running on Mobile,therefore epsilon is smaller than can be represented by half\r\n\r\n\t// Approximation of the above formulation (simplify the sqrt, not mathematically correct but close enough)\r\n\tfloat a = roughness;\r\n\tfloat lambdaV = NdotL * (NdotV * (1.0 - a) + a);\r\n\tfloat lambdaL = NdotV * (NdotL * (1.0 - a) + a);\r\n\treturn 0.5 / (lambdaV + lambdaL + 1e-5);\r\n}\r\n\r\nfloat ggxTerm(float NdotH, float roughness)\r\n{\r\n\tfloat a2 = roughness * roughness;\r\n\tfloat d = (NdotH * a2 - NdotH) * NdotH + 1.0; // 2 mad\r\n\treturn INV_PI * a2 / (d * d + 1e-7); // This function is not intended to be running on Mobile,therefore epsilon is smaller than what can be represented by half//返回值小用half来返回\r\n}\r\n\r\n// BRDF1-------------------------------------------------------------------------------------\r\n\r\n// Note: BRDF entry points use smoothness and oneMinusReflectivity for optimization purposes,\r\n// mostly for DX9 SM2.0 level. Most of the math is being done on these (1-x) values, and that saves a few precious ALU slots.\r\n\r\n// Main Physically Based BRDF\r\n// Derived from Disney work and based on Torrance-Sparrow micro-facet model\r\n//\r\n// BRDF = kD / pi + kS * (D * V * F) / 4\r\n// I = BRDF * NdotL\r\n//\r\n// *NDF GGX:\r\n// *Smith for Visiblity term\r\n// *Schlick approximation for Fresnel\r\nmediump vec4 layaBRDFHighLight(mediump vec3 diffColor, mediump vec3 specColor, mediump float oneMinusReflectivity, float perceptualRoughness,float roughness,mediump float nv,vec3 normal, vec3 viewDir,LayaLight light)\r\n{\r\n\tvec3 halfDir = safeNormalize(viewDir-light.dir);\r\n\r\n\tfloat nl = clamp(dot(normal, -light.dir),0.0,1.0);\r\n\tfloat nh = clamp(dot(normal, halfDir),0.0,1.0);\r\n\tmediump float lv = clamp(dot(light.dir, viewDir),0.0,1.0);\r\n\tmediump float lh = clamp(dot(light.dir, -halfDir),0.0,1.0);\r\n\r\n\t// Diffuse term\r\n\tmediump float diffuseTerm = disneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;\r\n\r\n\t// Specular term\r\n // HACK: theoretically we should divide diffuseTerm by Pi and not multiply specularTerm!\r\n // BUT that will make shader look significantly darker than Legacy ones\r\n\r\n\t// GGX with roughtness to 0 would mean no specular at all, using max(roughness, 0.002) here to match HDrenderloop roughtness remapping.\r\n\troughness = max(roughness, 0.002);\r\n\tfloat V = smithJointGGXVisibilityTerm(nl, nv, roughness);\r\n\tfloat D = ggxTerm(nh, roughness);\r\n\r\n\tfloat specularTerm = V * D * PI; // Torrance-Sparrow model, Fresnel is applied later\r\n\r\n\t//#ifdef LAYA_COLORSPACE_GAMMA\r\n\tspecularTerm = sqrt(max(1e-4, specularTerm));\r\n\t//#endif\r\n\tspecularTerm = max(0.0, specularTerm * nl);\r\n\t\t\r\n\tmediump vec3 color = diffColor * light.color * diffuseTerm + specularTerm * light.color * fresnelTerm(specColor, lh);\r\n\treturn vec4(color, 1.0);\r\n}\r\n\r\nvec4 layaBRDFHighGI(mediump vec3 diffColor,mediump vec3 specColor,mediump float oneMinusReflectivity,float smoothness ,float perceptualRoughness,float roughness,mediump float nv,vec3 normal, vec3 viewDir,LayaGI gi)\r\n{\r\n\t// surfaceReduction = Int D(NdotH) * NdotH * Id(NdotL>0) dH = 1/(roughness^2+1)\r\n\tfloat surfaceReduction;\r\n\tsurfaceReduction = 1.0 - 0.28*roughness*perceptualRoughness;// 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]\r\n\tfloat grazingTerm = clamp(smoothness + (1.0 - oneMinusReflectivity),0.0,1.0);\r\n\tmediump vec3 color =diffColor * gi.diffuse + surfaceReduction * gi.specular * fresnelLerp(specColor,vec3(grazingTerm), nv);\r\n\treturn vec4(color,1.0);\r\n}\r\n// BRDF1-------------------------------------------------------------------------------------\r\n\r\n\r\n// BRDF2-------------------------------------------------------------------------------------\r\n// Based on Minimalist CookTorrance BRDF\r\n// Implementation is slightly different from original derivation: http://www.thetenthplanet.de/archives/255\r\n//\r\n// *NDF [Modified] GGX:\r\n// *Modified Kelemen and Szirmay-​Kalos for Visibility term\r\n// *Fresnel approximated with 1/LdotH\r\nmediump vec4 layaBRDFLowLight (mediump vec3 diffColor, mediump vec3 specColor,mediump float oneMinusReflectivity,float perceptualRoughness,float roughness,mediump float nv,vec3 normal,vec3 viewDir,LayaLight light)\r\n{\r\n vec3 halfDir = safeNormalize (viewDir-light.dir);\r\n mediump float nl = clamp(dot(normal, -light.dir),0.0,1.0);\r\n float nh = clamp(dot(normal, halfDir),0.0,1.0);\r\n float lh = clamp(dot(-light.dir, halfDir),0.0,1.0);\r\n\r\n // GGX Distribution multiplied by combined approximation of Visibility and Fresnel\r\n // See "Optimizing PBR for Mobile" from Siggraph 2015 moving mobile graphics course\r\n // https://community.arm.com/events/1155\r\n mediump float a = roughness;\r\n float a2 = a*a;\r\n\r\n float d = nh * nh * (a2 - 1.0) + 1.00001;\r\n\t// #ifdef LAYA_COLORSPACE_GAMMA\r\n\t\t// Tighter approximation for Gamma only rendering mode!\r\n\t\t// DVF = sqrt(DVF);\r\n\t\t// DVF = (a * sqrt(.25)) / (max(sqrt(0.1), lh)*sqrt(roughness + .5) * d);\r\n\t\tfloat specularTerm = a / (max(0.32, lh) * (1.5 + roughness) * d);\r\n\t// #else\r\n\t// \tfloat specularTerm = a2 / (max(0.1f, lh*lh) * (roughness + 0.5f) * (d * d) * 4);\r\n\t// #endif\r\n\r\n // on mobiles (where half actually means something) denominator have risk of overflow\r\n // clamp below was added specifically to "fix" that, but dx compiler (we convert bytecode to metal/gles)\r\n // sees that specularTerm have only non-negative terms, so it skips max(0,..) in clamp (leaving only min(100,...))\r\n\r\n\t//#if defined (SHADER_API_MOBILE)\r\n specularTerm = specularTerm - 1e-4;\r\n\t//#endif\r\n\r\n\t// #else\r\n\t\t// // Legacy\r\n\t\t// half specularPower = PerceptualRoughnessToSpecPower(perceptualRoughness);\r\n\t\t// // Modified with approximate Visibility function that takes roughness into account\r\n\t\t// // Original ((n+1)*N.H^n) / (8*Pi * L.H^3) didn\'t take into account roughness\r\n\t\t// // and produced extremely bright specular at grazing angles\r\n\r\n\t\t// half invV = lh * lh * smoothness + perceptualRoughness * perceptualRoughness; // approx ModifiedKelemenVisibilityTerm(lh, perceptualRoughness);\r\n\t\t// half invF = lh;\r\n\r\n\t\t// half specularTerm = ((specularPower + 1) * pow (nh, specularPower)) / (8 * invV * invF + 1e-4h);\r\n\r\n\t\t// #ifdef LAYA_COLORSPACE_GAMMA\r\n\t\t// \tspecularTerm = sqrt(max(1e-4f, specularTerm));\r\n\t\t// #endif\r\n\t// #endif\r\n\r\n\t// #if defined (SHADER_API_MOBILE)\r\n\t\tspecularTerm = clamp(specularTerm, 0.0, 100.0); // Prevent FP16 overflow on mobiles\r\n\t// #endif\r\n \r\n mediump vec3 color = (diffColor + specularTerm * specColor) * light.color * nl;\r\n\r\n return vec4(color, 1.0);\r\n}\r\n\r\nmediump vec4 layaBRDFLowGI (mediump vec3 diffColor, mediump vec3 specColor,mediump float oneMinusReflectivity,mediump float smoothness,float perceptualRoughness,float roughness,mediump float nv,vec3 normal,vec3 viewDir,LayaGI gi)\r\n{\r\n\t// surfaceReduction = Int D(NdotH) * NdotH * Id(NdotL>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-------------------------------------------------------------------------------------'),he.addInclude("PBRCore.glsl","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\tshadowAttenuation = 1.0;\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\tshadowAttenuation = 1.0;\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\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\t\t\t\t\tif(i == 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvec4 spotShadowcoord = v_SpotShadowCoord;\r\n\t\t\t\t\t\t\tshadowAttenuation= sampleSpotShadowmap(spotShadowcoord);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t#endif\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"),he.addInclude("PBRVertex.glsl","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\r\n\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\tv_SpotShadowCoord = u_SpotViewProjectMatrix*vec4(positionWS,1.0);\r\n\t#endif\r\n}");var e={a_Position:nt.MESH_POSITION0,a_Color:nt.MESH_COLOR0,a_Normal:nt.MESH_NORMAL0,a_Texcoord0:nt.MESH_TEXTURECOORDINATE0,a_Texcoord1:nt.MESH_TEXTURECOORDINATE1,a_BoneWeights:nt.MESH_BLENDWEIGHT0,a_BoneIndices:nt.MESH_BLENDINDICES0,a_Tangent0:nt.MESH_TANGENT0,a_MvpMatrix:nt.MESH_MVPMATRIX_ROW0,a_WorldMat:nt.MESH_WORLDMATRIX_ROW0},t={u_Bones:he.PERIOD_CUSTOM,u_DiffuseTexture:he.PERIOD_MATERIAL,u_SpecularTexture:he.PERIOD_MATERIAL,u_NormalTexture:he.PERIOD_MATERIAL,u_AlphaTestValue:he.PERIOD_MATERIAL,u_DiffuseColor:he.PERIOD_MATERIAL,u_MaterialSpecular:he.PERIOD_MATERIAL,u_Shininess:he.PERIOD_MATERIAL,u_TilingOffset:he.PERIOD_MATERIAL,u_WorldMat:he.PERIOD_SPRITE,u_MvpMatrix:he.PERIOD_SPRITE,u_LightmapScaleOffset:he.PERIOD_SPRITE,u_LightMap:he.PERIOD_SPRITE,u_LightMapDirection:he.PERIOD_SPRITE,u_CameraPos:he.PERIOD_CAMERA,u_Viewport:he.PERIOD_CAMERA,u_ProjectionParams:he.PERIOD_CAMERA,u_View:he.PERIOD_CAMERA,u_ViewProjection:he.PERIOD_CAMERA,u_ReflectTexture:he.PERIOD_SCENE,u_ReflectIntensity:he.PERIOD_SCENE,u_FogStart:he.PERIOD_SCENE,u_FogRange:he.PERIOD_SCENE,u_FogColor:he.PERIOD_SCENE,u_DirationLightCount:he.PERIOD_SCENE,u_LightBuffer:he.PERIOD_SCENE,u_LightClusterBuffer:he.PERIOD_SCENE,u_AmbientColor:he.PERIOD_SCENE,u_ShadowBias:he.PERIOD_SCENE,u_ShadowLightDirection:he.PERIOD_SCENE,u_ShadowMap:he.PERIOD_SCENE,u_ShadowParams:he.PERIOD_SCENE,u_ShadowSplitSpheres:he.PERIOD_SCENE,u_ShadowMatrices:he.PERIOD_SCENE,u_ShadowMapSize:he.PERIOD_SCENE,u_SpotShadowMap:he.PERIOD_SCENE,u_SpotViewProjectMatrix:he.PERIOD_SCENE,u_ShadowLightPosition:he.PERIOD_SCENE,u_AmbientSHAr:he.PERIOD_SCENE,u_AmbientSHAg:he.PERIOD_SCENE,u_AmbientSHAb:he.PERIOD_SCENE,u_AmbientSHBr:he.PERIOD_SCENE,u_AmbientSHBg:he.PERIOD_SCENE,u_AmbientSHBb:he.PERIOD_SCENE,u_AmbientSHC:he.PERIOD_SCENE,"u_DirectionLight.color":he.PERIOD_SCENE,"u_DirectionLight.direction":he.PERIOD_SCENE,"u_PointLight.position":he.PERIOD_SCENE,"u_PointLight.range":he.PERIOD_SCENE,"u_PointLight.color":he.PERIOD_SCENE,"u_SpotLight.position":he.PERIOD_SCENE,"u_SpotLight.direction":he.PERIOD_SCENE,"u_SpotLight.range":he.PERIOD_SCENE,"u_SpotLight.spot":he.PERIOD_SCENE,"u_SpotLight.color":he.PERIOD_SCENE},r={s_Cull:he.RENDER_STATE_CULL,s_Blend:he.RENDER_STATE_BLEND,s_BlendSrc:he.RENDER_STATE_BLEND_SRC,s_BlendDst:he.RENDER_STATE_BLEND_DST,s_DepthTest:he.RENDER_STATE_DEPTH_TEST,s_DepthWrite:he.RENDER_STATE_DEPTH_WRITE},i=he.add("BLINNPHONG",null,null,!0),n=new nr(e,t);i.addSubShader(n),n.addShaderPass('#include "Lighting.glsl";\r\n#include "Shadow.glsl";\r\n\r\nattribute vec4 a_Position;\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\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\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\n#ifdef COLOR\r\n\tattribute vec4 a_Color;\r\n\tvarying vec4 v_Color;\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(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\tuniform vec3 u_CameraPos;\r\n\tvarying vec3 v_ViewDir; \r\n#endif\r\n\r\n#if defined(NORMALMAP)\r\n\tattribute vec4 a_Tangent0;\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\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\n#if defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&&defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\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 CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\nvoid main()\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\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\t\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\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\tv_Normal=normalize(a_Normal*worldInvMat);\r\n\t#if defined(NORMALMAP)\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#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&&defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\t\tvec3 positionWS=(worldMat*position).xyz;\r\n\t\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\t\tv_ViewDir = u_CameraPos-positionWS;\r\n\t\t#endif\r\n\t\t#if defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&&defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\t\t\tv_PositionWorld = positionWS;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\t#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\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\t#ifdef LIGHTMAP\r\n\t\t#ifdef UV1\r\n\t\t\tv_LightMapUV=vec2(a_Texcoord1.x,1.0-a_Texcoord1.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\r\n\t\t#else\r\n\t\t\tv_LightMapUV=vec2(a_Texcoord0.x,1.0-a_Texcoord0.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\r\n\t\t#endif \r\n\t\tv_LightMapUV.y=1.0-v_LightMapUV.y;\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\r\n\t#if defined(CALCULATE_SHADOWS)&&!defined(SHADOW_CASCADE)\r\n\t\tv_ShadowCoord =getShadowCoord(vec4(positionWS,1.0));\r\n\t#endif\r\n\r\n\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\tv_SpotShadowCoord = u_SpotViewProjectMatrix*vec4(positionWS,1.0);\r\n\t#endif\r\n\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}','#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 "Lighting.glsl";\r\n#include "Shadow.glsl"\r\n\r\nuniform vec4 u_DiffuseColor;\r\n\r\n#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\tvarying vec4 v_Color;\r\n#endif\r\n\r\n#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\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\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform sampler2D u_LightMap;\r\n#endif\r\n\r\nvarying vec3 v_Normal;\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\tvarying vec3 v_ViewDir; \r\n\r\n\tuniform vec3 u_MaterialSpecular;\r\n\tuniform float u_Shininess;\r\n\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\r\n\t#ifdef SPECULARMAP \r\n\t\tuniform sampler2D u_SpecularTexture;\r\n\t#endif\r\n#endif\r\n\r\n#ifdef NORMALMAP \r\n\tuniform sampler2D u_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#if defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&&defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n\r\n#include "GlobalIllumination.glsl";//"GlobalIllumination.glsl use uniform should at front of this\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 CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\n\r\nvoid main()\r\n{\r\n\tvec3 normal;//light and SH maybe use normal\r\n\t#if defined(NORMALMAP)\r\n\t\tvec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\r\n\t\tnormal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent,v_Binormal));\r\n\t#else\r\n\t\tnormal = normalize(v_Normal);\r\n\t#endif\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tvec3 viewDir= normalize(v_ViewDir);\r\n\t#endif\r\n\r\n\tLayaGIInput giInput;\r\n\t#ifdef LIGHTMAP\t\r\n\t\tgiInput.lightmapUV=v_LightMapUV;\r\n\t#endif\r\n\tvec3 globalDiffuse=layaGIBase(giInput,1.0,normal);\r\n\t\r\n\tvec4 mainColor=u_DiffuseColor;\r\n\t#ifdef DIFFUSEMAP\r\n\t\tvec4 difTexColor=texture2D(u_DiffuseTexture, v_Texcoord0);\r\n\t\tmainColor=mainColor*difTexColor;\r\n\t#endif \r\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\t\tmainColor=mainColor*v_Color;\r\n\t#endif \r\n \r\n\t#ifdef ALPHATEST\r\n\t\tif(mainColor.a= u_DirationLightCount)\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tDirectionLight directionLight = getDirectionLight(u_LightBuffer,i);\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\tdirectionLight.color *= sampleShadowmap(shadowCoord);\r\n\t\t\t\t\t}\r\n\t\t\t\t#endif\r\n\t\t\t\tLayaAirBlinnPhongDiectionLight(u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,directionLight,dif,spe);\r\n\t\t\t\tdiffuse+=dif;\r\n\t\t\t\tspecular+=spe;\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\tLayaAirBlinnPhongPointLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,pointLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\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\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\t\t\t\t\tif(i == 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvec4 spotShadowcoord = v_SpotShadowCoord;\r\n\t\t\t\t\t\t\tspotLight.color *= sampleSpotShadowmap(spotShadowcoord);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t#endif\r\n\t\t\t\t\tLayaAirBlinnPhongSpotLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,spotLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\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\tgl_FragColor =vec4(mainColor.rgb*(globalDiffuse + diffuse),mainColor.a);\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tgl_FragColor.rgb+=specular;\r\n\t#endif\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\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\r\n\t#endif\r\n}\r\n\r\n',r,"Forward");n.addShaderPass('#include "ShadowCasterVS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionCS = shadowCasterVertex();\r\n\tgl_Position=remapGLPositionZ(positionCS);\r\n}','#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}',r,"ShadowCaster");e={a_Position:nt.MESH_POSITION0,a_Color:nt.MESH_COLOR0},t={u_MvpMatrix:he.PERIOD_SPRITE,u_Color:he.PERIOD_MATERIAL},r={s_Cull:he.RENDER_STATE_CULL,s_Blend:he.RENDER_STATE_BLEND,s_BlendSrc:he.RENDER_STATE_BLEND_SRC,s_BlendDst:he.RENDER_STATE_BLEND_DST,s_DepthTest:he.RENDER_STATE_DEPTH_TEST,s_DepthWrite:he.RENDER_STATE_DEPTH_WRITE},i=he.add("LineShader"),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nuniform mat4 u_MvpMatrix;\r\nuniform vec4 u_Color;\r\nattribute vec4 a_Color;\r\nvarying vec4 v_Color;\r\n\r\n\r\nvoid main()\r\n{\r\n\tgl_Position = u_MvpMatrix * a_Position;\r\n\tv_Color=a_Color*u_Color;\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',"#ifdef GL_FRAGMENT_PRECISION_HIGH\r\nprecision highp float;\r\n#else\r\nprecision mediump float;\r\n#endif\r\n\r\nvarying vec4 v_Color;\r\nuniform vec4 u_Color;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = v_Color * u_Color; \r\n}\r\n\r\n",r),e={a_Position:nt.MESH_POSITION0,a_Color:nt.MESH_COLOR0,a_Texcoord0:nt.MESH_TEXTURECOORDINATE0,a_BoneWeights:nt.MESH_BLENDWEIGHT0,a_BoneIndices:nt.MESH_BLENDINDICES0,a_MvpMatrix:nt.MESH_MVPMATRIX_ROW0},t={u_Bones:he.PERIOD_CUSTOM,u_AlbedoTexture:he.PERIOD_MATERIAL,u_AlbedoColor:he.PERIOD_MATERIAL,u_TilingOffset:he.PERIOD_MATERIAL,u_AlphaTestValue:he.PERIOD_MATERIAL,u_MvpMatrix:he.PERIOD_SPRITE,u_FogStart:he.PERIOD_SCENE,u_FogRange:he.PERIOD_SCENE,u_FogColor:he.PERIOD_SCENE},r={s_Cull:he.RENDER_STATE_CULL,s_Blend:he.RENDER_STATE_BLEND,s_BlendSrc:he.RENDER_STATE_BLEND_SRC,s_BlendDst:he.RENDER_STATE_BLEND_DST,s_DepthTest:he.RENDER_STATE_DEPTH_TEST,s_DepthWrite:he.RENDER_STATE_DEPTH_WRITE},i=he.add("Unlit",null,null,!0),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#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}',"#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",r),e={a_Position:nt.MESH_POSITION0,a_Texcoord0:nt.MESH_TEXTURECOORDINATE0,a_BoneWeights:nt.MESH_BLENDWEIGHT0,a_BoneIndices:nt.MESH_BLENDINDICES0,a_MvpMatrix:nt.MESH_MVPMATRIX_ROW0},t={u_Bones:he.PERIOD_CUSTOM,u_AlbedoTexture:he.PERIOD_MATERIAL,u_AlbedoColor:he.PERIOD_MATERIAL,u_TilingOffset:he.PERIOD_MATERIAL,u_AlphaTestValue:he.PERIOD_MATERIAL,u_MvpMatrix:he.PERIOD_SPRITE,u_FogStart:he.PERIOD_SCENE,u_FogRange:he.PERIOD_SCENE,u_FogColor:he.PERIOD_SCENE},r={s_Cull:he.RENDER_STATE_CULL,s_Blend:he.RENDER_STATE_BLEND,s_BlendSrc:he.RENDER_STATE_BLEND_SRC,s_BlendDst:he.RENDER_STATE_BLEND_DST,s_DepthTest:he.RENDER_STATE_DEPTH_TEST,s_DepthWrite:he.RENDER_STATE_DEPTH_WRITE},i=he.add("Effect",null,null,!0),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec4 a_Color;\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\n#ifdef COLOR\r\n\tvarying vec4 v_Color;\r\n#endif\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{\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\t\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\t\t\r\n\t#ifdef COLOR\r\n\t\tv_Color = a_Color;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',"#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 COLOR\r\n\tvarying vec4 v_Color;\r\n#endif\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef MAINTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\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 = 2.0 * u_AlbedoColor;\r\n\t#ifdef COLOR\r\n\t\tcolor *= v_Color;\r\n\t#endif\r\n\t#ifdef MAINTEXTURE\r\n\t\tcolor *= texture2D(u_AlbedoTexture, v_Texcoord0);\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}\r\n\r\n",r),e={a_CornerTextureCoordinate:Xr.PARTICLE_CORNERTEXTURECOORDINATE0,a_MeshPosition:Xr.PARTICLE_POSITION0,a_MeshColor:Xr.PARTICLE_COLOR0,a_MeshTextureCoordinate:Xr.PARTICLE_TEXTURECOORDINATE0,a_ShapePositionStartLifeTime:Xr.PARTICLE_SHAPEPOSITIONSTARTLIFETIME,a_DirectionTime:Xr.PARTICLE_DIRECTIONTIME,a_StartColor:Xr.PARTICLE_STARTCOLOR0,a_EndColor:Xr.PARTICLE_ENDCOLOR0,a_StartSize:Xr.PARTICLE_STARTSIZE,a_StartRotation0:Xr.PARTICLE_STARTROTATION,a_StartSpeed:Xr.PARTICLE_STARTSPEED,a_Random0:Xr.PARTICLE_RANDOM0,a_Random1:Xr.PARTICLE_RANDOM1,a_SimulationWorldPostion:Xr.PARTICLE_SIMULATIONWORLDPOSTION,a_SimulationWorldRotation:Xr.PARTICLE_SIMULATIONWORLDROTATION},t={u_Tintcolor:he.PERIOD_MATERIAL,u_TilingOffset:he.PERIOD_MATERIAL,u_texture:he.PERIOD_MATERIAL,u_WorldPosition:he.PERIOD_SPRITE,u_WorldRotation:he.PERIOD_SPRITE,u_PositionScale:he.PERIOD_SPRITE,u_SizeScale:he.PERIOD_SPRITE,u_ScalingMode:he.PERIOD_SPRITE,u_Gravity:he.PERIOD_SPRITE,u_ThreeDStartRotation:he.PERIOD_SPRITE,u_StretchedBillboardLengthScale:he.PERIOD_SPRITE,u_StretchedBillboardSpeedScale:he.PERIOD_SPRITE,u_SimulationSpace:he.PERIOD_SPRITE,u_CurrentTime:he.PERIOD_SPRITE,u_ColorOverLifeGradientAlphas:he.PERIOD_SPRITE,u_ColorOverLifeGradientColors:he.PERIOD_SPRITE,u_MaxColorOverLifeGradientAlphas:he.PERIOD_SPRITE,u_MaxColorOverLifeGradientColors:he.PERIOD_SPRITE,u_VOLVelocityConst:he.PERIOD_SPRITE,u_VOLVelocityGradientX:he.PERIOD_SPRITE,u_VOLVelocityGradientY:he.PERIOD_SPRITE,u_VOLVelocityGradientZ:he.PERIOD_SPRITE,u_VOLVelocityConstMax:he.PERIOD_SPRITE,u_VOLVelocityGradientMaxX:he.PERIOD_SPRITE,u_VOLVelocityGradientMaxY:he.PERIOD_SPRITE,u_VOLVelocityGradientMaxZ:he.PERIOD_SPRITE,u_VOLSpaceType:he.PERIOD_SPRITE,u_SOLSizeGradient:he.PERIOD_SPRITE,u_SOLSizeGradientX:he.PERIOD_SPRITE,u_SOLSizeGradientY:he.PERIOD_SPRITE,u_SOLSizeGradientZ:he.PERIOD_SPRITE,u_SOLSizeGradientMax:he.PERIOD_SPRITE,u_SOLSizeGradientMaxX:he.PERIOD_SPRITE,u_SOLSizeGradientMaxY:he.PERIOD_SPRITE,u_SOLSizeGradientMaxZ:he.PERIOD_SPRITE,u_ROLAngularVelocityConst:he.PERIOD_SPRITE,u_ROLAngularVelocityConstSeprarate:he.PERIOD_SPRITE,u_ROLAngularVelocityGradient:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientX:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientY:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientZ:he.PERIOD_SPRITE,u_ROLAngularVelocityConstMax:he.PERIOD_SPRITE,u_ROLAngularVelocityConstMaxSeprarate:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientMax:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxX:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxY:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxZ:he.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxW:he.PERIOD_SPRITE,u_TSACycles:he.PERIOD_SPRITE,u_TSASubUVLength:he.PERIOD_SPRITE,u_TSAGradientUVs:he.PERIOD_SPRITE,u_TSAMaxGradientUVs:he.PERIOD_SPRITE,u_CameraPos:he.PERIOD_CAMERA,u_CameraDirection:he.PERIOD_CAMERA,u_CameraUp:he.PERIOD_CAMERA,u_View:he.PERIOD_CAMERA,u_Projection:he.PERIOD_CAMERA,u_FogStart:he.PERIOD_SCENE,u_FogRange:he.PERIOD_SCENE,u_FogColor:he.PERIOD_SCENE},r={s_Cull:he.RENDER_STATE_CULL,s_Blend:he.RENDER_STATE_BLEND,s_BlendSrc:he.RENDER_STATE_BLEND_SRC,s_BlendDst:he.RENDER_STATE_BLEND_DST,s_DepthTest:he.RENDER_STATE_DEPTH_TEST,s_DepthWrite:he.RENDER_STATE_DEPTH_WRITE},i=he.add("PARTICLESHURIKEN"),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#include "Lighting.glsl";\r\n\r\n#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n precision highp float;\r\n#else\r\n precision mediump float;\r\n#endif\r\n\r\n#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\r\n\tattribute vec4 a_CornerTextureCoordinate;\r\n#endif\r\n#ifdef RENDERMODE_MESH\r\n\tattribute vec3 a_MeshPosition;\r\n\tattribute vec4 a_MeshColor;\r\n\tattribute vec2 a_MeshTextureCoordinate;\r\n\tvarying vec4 v_MeshColor;\r\n#endif\r\n\r\nattribute vec4 a_ShapePositionStartLifeTime;\r\nattribute vec4 a_DirectionTime;\r\nattribute vec4 a_StartColor;\r\nattribute vec3 a_StartSize;\r\nattribute vec3 a_StartRotation0;\r\nattribute float a_StartSpeed;\r\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\n attribute vec4 a_Random0;\r\n#endif\r\n#if defined(TEXTURESHEETANIMATIONRANDOMCURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n attribute vec4 a_Random1;\r\n#endif\r\nattribute vec3 a_SimulationWorldPostion;\r\nattribute vec4 a_SimulationWorldRotation;\r\n\r\nvarying vec4 v_Color;\r\n#ifdef DIFFUSEMAP\r\n\tvarying vec2 v_TextureCoordinate;\r\n#endif\r\n\r\nuniform float u_CurrentTime;\r\nuniform vec3 u_Gravity;\r\n\r\nuniform vec3 u_WorldPosition;\r\nuniform vec4 u_WorldRotation;\r\nuniform bool u_ThreeDStartRotation;\r\nuniform int u_ScalingMode;\r\nuniform vec3 u_PositionScale;\r\nuniform vec3 u_SizeScale;\r\nuniform mat4 u_View;\r\nuniform mat4 u_Projection;\r\n\r\n#ifdef STRETCHEDBILLBOARD\r\n\tuniform vec3 u_CameraPos;\r\n#endif\r\nuniform vec3 u_CameraDirection;//TODO:只有几种广告牌模式需要用\r\nuniform vec3 u_CameraUp;\r\n\r\nuniform float u_StretchedBillboardLengthScale;\r\nuniform float u_StretchedBillboardSpeedScale;\r\nuniform int u_SimulationSpace;\r\n\r\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n uniform int u_VOLSpaceType;\r\n#endif\r\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)\r\n uniform vec3 u_VOLVelocityConst;\r\n#endif\r\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n uniform vec2 u_VOLVelocityGradientX[4];//x为key,y为速度\r\n uniform vec2 u_VOLVelocityGradientY[4];//x为key,y为速度\r\n uniform vec2 u_VOLVelocityGradientZ[4];//x为key,y为速度\r\n#endif\r\n#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\r\n uniform vec3 u_VOLVelocityConstMax;\r\n#endif\r\n#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\r\n uniform vec2 u_VOLVelocityGradientMaxX[4];//x为key,y为速度\r\n uniform vec2 u_VOLVelocityGradientMaxY[4];//x为key,y为速度\r\n uniform vec2 u_VOLVelocityGradientMaxZ[4];//x为key,y为速度\r\n#endif\r\n\r\n#ifdef COLOROVERLIFETIME\r\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\r\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\r\n#endif\r\n#ifdef RANDOMCOLOROVERLIFETIME\r\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\r\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\r\n uniform vec4 u_MaxColorOverLifeGradientColors[4];//x为key,yzw为Color\r\n uniform vec2 u_MaxColorOverLifeGradientAlphas[4];//x为key,y为Alpha\r\n#endif\r\n\r\n\r\n#if defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMERANDOMCURVES)\r\n uniform vec2 u_SOLSizeGradient[4];//x为key,y为尺寸\r\n#endif\r\n#ifdef SIZEOVERLIFETIMERANDOMCURVES\r\n uniform vec2 u_SOLSizeGradientMax[4];//x为key,y为尺寸\r\n#endif\r\n#if defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\r\n uniform vec2 u_SOLSizeGradientX[4];//x为key,y为尺寸\r\n uniform vec2 u_SOLSizeGradientY[4];//x为key,y为尺寸\r\n uniform vec2 u_SOLSizeGradientZ[4];//x为key,y为尺寸\r\n#endif\r\n#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\r\n uniform vec2 u_SOLSizeGradientMaxX[4];//x为key,y为尺寸\r\n uniform vec2 u_SOLSizeGradientMaxY[4];//x为key,y为尺寸\r\n uniform vec2 u_SOLSizeGradientMaxZ[4];//x为key,y为尺寸\r\n#endif\r\n\r\n\r\n#ifdef ROTATIONOVERLIFETIME\r\n #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\r\n uniform float u_ROLAngularVelocityConst;\r\n #endif\r\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n uniform float u_ROLAngularVelocityConstMax;\r\n #endif\r\n #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\n uniform vec2 u_ROLAngularVelocityGradient[4];//x为key,y为旋转\r\n #endif\r\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n uniform vec2 u_ROLAngularVelocityGradientMax[4];//x为key,y为旋转\r\n #endif\r\n#endif\r\n#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\r\n uniform vec3 u_ROLAngularVelocityConstSeprarate;\r\n #endif\r\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n uniform vec3 u_ROLAngularVelocityConstMaxSeprarate;\r\n #endif\r\n #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\n uniform vec2 u_ROLAngularVelocityGradientX[4];\r\n uniform vec2 u_ROLAngularVelocityGradientY[4];\r\n uniform vec2 u_ROLAngularVelocityGradientZ[4];\r\n #endif\r\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n uniform vec2 u_ROLAngularVelocityGradientMaxX[4];\r\n uniform vec2 u_ROLAngularVelocityGradientMaxY[4];\r\n uniform vec2 u_ROLAngularVelocityGradientMaxZ[4];\r\n\tuniform vec2 u_ROLAngularVelocityGradientMaxW[4];\r\n #endif\r\n#endif\r\n\r\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\r\n uniform float u_TSACycles;\r\n uniform vec2 u_TSASubUVLength;\r\n uniform vec2 u_TSAGradientUVs[4];//x为key,y为frame\r\n#endif\r\n#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\r\n uniform vec2 u_TSAMaxGradientUVs[4];//x为key,y为frame\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\nvec3 rotationByEuler(in vec3 vector,in vec3 rot)\r\n{\r\n\tfloat halfRoll = rot.z * 0.5;\r\n float halfPitch = rot.x * 0.5;\r\n\tfloat halfYaw = rot.y * 0.5;\r\n\r\n\tfloat sinRoll = sin(halfRoll);\r\n\tfloat cosRoll = cos(halfRoll);\r\n\tfloat sinPitch = sin(halfPitch);\r\n\tfloat cosPitch = cos(halfPitch);\r\n\tfloat sinYaw = sin(halfYaw);\r\n\tfloat cosYaw = cos(halfYaw);\r\n\r\n\tfloat quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\r\n\tfloat quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\r\n\tfloat quaZ = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);\r\n\tfloat quaW = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);\r\n\t\r\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\r\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\r\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\r\n\t\r\n\tfloat x = quaX + quaX;\r\n float y = quaY + quaY;\r\n float z = quaZ + quaZ;\r\n float wx = quaW * x;\r\n float wy = quaW * y;\r\n float wz = quaW * z;\r\n\tfloat xx = quaX * x;\r\n float xy = quaX * y;\r\n\tfloat xz = quaX * z;\r\n float yy = quaY * y;\r\n float yz = quaY * z;\r\n float zz = quaZ * z;\r\n\r\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\r\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\r\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\r\n\t\r\n}\r\n\r\n//假定axis已经归一化\r\nvec3 rotationByAxis(in vec3 vector,in vec3 axis, in float angle)\r\n{\r\n\tfloat halfAngle = angle * 0.5;\r\n\tfloat sin = sin(halfAngle);\r\n\t\r\n\tfloat quaX = axis.x * sin;\r\n\tfloat quaY = axis.y * sin;\r\n\tfloat quaZ = axis.z * sin;\r\n\tfloat quaW = cos(halfAngle);\r\n\t\r\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\r\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\r\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\r\n\t\r\n\tfloat x = quaX + quaX;\r\n float y = quaY + quaY;\r\n float z = quaZ + quaZ;\r\n float wx = quaW * x;\r\n float wy = quaW * y;\r\n float wz = quaW * z;\r\n\tfloat xx = quaX * x;\r\n float xy = quaX * y;\r\n\tfloat xz = quaX * z;\r\n float yy = quaY * y;\r\n float yz = quaY * z;\r\n float zz = quaZ * z;\r\n\r\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\r\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\r\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\r\n\t\r\n}\r\n\r\nvec3 rotationByQuaternions(in vec3 v,in vec4 q) \r\n{\r\n\treturn v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\r\n}\r\n\r\n \r\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\r\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\r\n{\r\n\tfloat curValue;\r\n\tfor(int i=1;i<4;i++)\r\n\t{\r\n\t\tvec2 gradientNumber=gradientNumbers[i];\r\n\t\tfloat key=gradientNumber.x;\r\n\t\tif(key>=normalizedAge)\r\n\t\t{\r\n\t\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\r\n\t\t\tfloat lastKey=lastGradientNumber.x;\r\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\r\n\t\t\tcurValue=mix(lastGradientNumber.y,gradientNumber.y,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn curValue;\r\n}\r\n#endif\r\n\r\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\r\n{\r\n\tfloat totalValue=0.0;\r\n\tfor(int i=1;i<4;i++)\r\n\t{\r\n\t\tvec2 gradientNumber=gradientNumbers[i];\r\n\t\tfloat key=gradientNumber.x;\r\n\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\r\n\t\tfloat lastValue=lastGradientNumber.y;\r\n\t\t\r\n\t\tif(key>=normalizedAge){\r\n\t\t\tfloat lastKey=lastGradientNumber.x;\r\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\r\n\t\t\ttotalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_ShapePositionStartLifeTime.w*(normalizedAge-lastKey);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\telse{\r\n\t\t\ttotalValue+=(lastValue+gradientNumber.y)/2.0*a_ShapePositionStartLifeTime.w*(key-lastGradientNumber.x);\r\n\t\t}\r\n\t}\r\n\treturn totalValue;\r\n}\r\n#endif\r\n\r\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)\r\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\r\n{\r\n\tvec4 overTimeColor;\r\n\tfor(int i=1;i<4;i++)\r\n\t{\r\n\t\tvec2 gradientAlpha=gradientAlphas[i];\r\n\t\tfloat alphaKey=gradientAlpha.x;\r\n\t\tif(alphaKey>=normalizedAge)\r\n\t\t{\r\n\t\t\tvec2 lastGradientAlpha=gradientAlphas[i-1];\r\n\t\t\tfloat lastAlphaKey=lastGradientAlpha.x;\r\n\t\t\tfloat age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\r\n\t\t\toverTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\r\n\tfor(int i=1;i<4;i++)\r\n\t{\r\n\t\tvec4 gradientColor=gradientColors[i];\r\n\t\tfloat colorKey=gradientColor.x;\r\n\t\tif(colorKey>=normalizedAge)\r\n\t\t{\r\n\t\t\tvec4 lastGradientColor=gradientColors[i-1];\r\n\t\t\tfloat lastColorKey=lastGradientColor.x;\r\n\t\t\tfloat age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\r\n\t\t\toverTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn overTimeColor;\r\n}\r\n#endif\r\n\r\n\r\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\r\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\r\n{\r\n\tfloat overTimeFrame;\r\n\tfor(int i=1;i<4;i++)\r\n\t{\r\n\t\tvec2 gradientFrame=gradientFrames[i];\r\n\t\tfloat key=gradientFrame.x;\r\n\t\tif(key>=normalizedAge)\r\n\t\t{\r\n\t\t\tvec2 lastGradientFrame=gradientFrames[i-1];\r\n\t\t\tfloat lastKey=lastGradientFrame.x;\r\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\r\n\t\t\toverTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn floor(overTimeFrame);\r\n}\r\n#endif\r\n\r\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\nvec3 computeParticleLifeVelocity(in float normalizedAge)\r\n{\r\n vec3 outLifeVelocity;\r\n #ifdef VELOCITYOVERLIFETIMECONSTANT\r\n\t outLifeVelocity=u_VOLVelocityConst; \r\n #endif\r\n #ifdef VELOCITYOVERLIFETIMECURVE\r\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\r\n #endif\r\n #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\r\n\t outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,vec3(a_Random1.y,a_Random1.z,a_Random1.w)); \r\n #endif\r\n #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\r\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y),\r\n\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z),\r\n\t\t\t\t\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\r\n #endif\r\n\t\t\t\t\t\r\n return outLifeVelocity;\r\n} \r\n#endif\r\n\r\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation)\r\n{\r\n vec3 startPosition;\r\n vec3 lifePosition;\r\n #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n\t#ifdef VELOCITYOVERLIFETIMECONSTANT\r\n\t\t startPosition=startVelocity*age;\r\n\t\t lifePosition=lifeVelocity*age;\r\n\t#endif\r\n\t#ifdef VELOCITYOVERLIFETIMECURVE\r\n\t\t startPosition=startVelocity*age;\r\n\t\t lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\r\n\t#endif\r\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\r\n\t\t startPosition=startVelocity*age;\r\n\t\t lifePosition=lifeVelocity*age;\r\n\t#endif\r\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\r\n\t\t startPosition=startVelocity*age;\r\n\t\t lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y)\r\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z)\r\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\r\n\t#endif\r\n\t\r\n\tvec3 finalPosition;\r\n\tif(u_VOLSpaceType==0){\r\n\t if(u_ScalingMode!=2)\r\n\t finalPosition =rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition),worldRotation);\r\n\t else\r\n\t finalPosition =rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);\r\n\t}\r\n\telse{\r\n\t if(u_ScalingMode!=2)\r\n\t finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation)+lifePosition;\r\n\t else\r\n\t finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;\r\n\t}\r\n #else\r\n\t startPosition=startVelocity*age;\r\n\t vec3 finalPosition;\r\n\t if(u_ScalingMode!=2)\r\n\t\t\tfinalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation);\r\n\t else\r\n\t \tfinalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\r\n #endif\r\n \r\n if(u_SimulationSpace==0)\r\n finalPosition=finalPosition+a_SimulationWorldPostion;\r\n else if(u_SimulationSpace==1) \r\n finalPosition=finalPosition+u_WorldPosition;\r\n \r\n finalPosition+=0.5*gravityVelocity*age;\r\n \r\n return finalPosition;\r\n}\r\n\r\n\r\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\r\n{\r\n\t#ifdef COLOROVERLIFETIME\r\n\t color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\r\n\t#endif\r\n\t\r\n\t#ifdef RANDOMCOLOROVERLIFETIME\r\n\t color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\r\n\t#endif\r\n\r\n return color;\r\n}\r\n\r\nvec2 computeParticleSizeBillbard(in vec2 size,in float normalizedAge)\r\n{\r\n\t#ifdef SIZEOVERLIFETIMECURVE\r\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\r\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\r\n\t\tsize*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\r\n\t size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\r\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\r\n\t#endif\r\n\treturn size;\r\n}\r\n\r\n#ifdef RENDERMODE_MESH\r\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge)\r\n{\r\n\t#ifdef SIZEOVERLIFETIMECURVE\r\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\r\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\r\n\t\tsize*=vec3(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge));\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\r\n\t size*=vec3(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\r\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z)\r\n\t\t,mix(getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxZ,normalizedAge),a_Random0.z));\r\n\t#endif\r\n\treturn size;\r\n}\r\n#endif\r\n\r\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge)\r\n{ \r\n\t#ifdef ROTATIONOVERLIFETIME\r\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\r\n\t rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\r\n\t rotation+=ageRot;\r\n\t #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\r\n\t\t#endif\r\n\t#endif\r\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tfloat ageRot=u_ROLAngularVelocityConstSeprarate.z*age;\r\n\t rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge);\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConstSeprarate.z,u_ROLAngularVelocityConstMaxSeprarate.z,a_Random0.w)*age;\r\n\t rotation+=ageRot;\r\n\t #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\r\n\t\t#endif\r\n\t#endif\r\n\treturn rotation;\r\n}\r\n\r\n#if defined(RENDERMODE_MESH)&&(defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE))\r\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge)\r\n{ \r\n\t#ifdef ROTATIONOVERLIFETIME\r\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\r\n\t rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\r\n\t rotation+=ageRot;\r\n\t #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\r\n\t\t#endif\r\n\t#endif\r\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tvec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\r\n\t rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tvec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\r\n\t rotation+=ageRot;\r\n\t #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\r\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\r\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\r\n\t\t#endif\r\n\t#endif\r\n\treturn rotation;\r\n}\r\n#endif\r\n\r\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\r\n{ \r\n\t#ifdef TEXTURESHEETANIMATIONCURVE\r\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\r\n\t\tfloat frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\r\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\r\n\t\tfloat floorTotalULength=floor(totalULength);\r\n\t uv.x+=totalULength-floorTotalULength;\r\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\r\n #endif\r\n\t#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\r\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\r\n\t\tfloat uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\r\n\t float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\r\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\r\n\t\tfloat floorTotalULength=floor(totalULength);\r\n\t uv.x+=totalULength-floorTotalULength;\r\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\r\n #endif\r\n\treturn uv;\r\n}\r\n\r\nvoid main()\r\n{\r\n\tfloat age = u_CurrentTime - a_DirectionTime.w;\r\n\tfloat normalizedAge = age/a_ShapePositionStartLifeTime.w;\r\n\tvec3 lifeVelocity;\r\n\tif(normalizedAge<1.0)\r\n\t{ \r\n\t\tvec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\r\n\t\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n\t\t\tlifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\r\n\t\t#endif \r\n\t\tvec3 gravityVelocity=u_Gravity*age;\r\n\t\t\r\n\t\tvec4 worldRotation;\r\n\t\tif(u_SimulationSpace==0)\r\n\t\t\tworldRotation=a_SimulationWorldRotation;\r\n\t\telse\r\n\t\t\tworldRotation=u_WorldRotation;\r\n\t\t\r\n\t\tvec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge,gravityVelocity,worldRotation);//计算粒子位置\r\n\t\r\n\t\r\n\t\t#ifdef SPHERHBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\r\n\t\t\tvec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\r\n\t\t\tvec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\r\n\t\t\tvec3 upVector = normalize(cross(sideVector,u_CameraDirection));\r\n\t\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\t\t\tfloat c = cos(rot);\r\n\t\t\t\t\tfloat s = sin(rot);\r\n\t\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\t\t\tcorner=rotation*corner;\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\r\n\t\t\t\t}\r\n\t\t\t#else\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tfloat c = cos(a_StartRotation0.x);\r\n\t\t\t\t\tfloat s = sin(a_StartRotation0.x);\r\n\t\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\t\t\tcorner=rotation*corner;\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef STRETCHEDBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\r\n\t\t\tvec3 velocity;\r\n\t\t\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n\t\t\t\tif(u_VOLSpaceType==0)\r\n\t\t\t\tvelocity=rotationByQuaternions(u_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;\r\n\t\t\t\telse\r\n\t\t\t\tvelocity=rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;\r\n\t\t\t#else\r\n\t\t\t\tvelocity= rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+gravityVelocity;\r\n\t\t\t#endif\t\r\n\t\t\tvec3 cameraUpVector = normalize(velocity);\r\n\t\t\tvec3 direction = normalize(center-u_CameraPos);\r\n\t\t\tvec3 sideVector = normalize(cross(direction,normalize(velocity)));\r\n\t\t\t\r\n\t\t\tsideVector=u_SizeScale.xzy*sideVector;\r\n\t\t\tcameraUpVector=length(vec3(u_SizeScale.x,0.0,0.0))*cameraUpVector;\r\n\t\t\t\r\n\t\t\tvec2 size=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\t\r\n\t\t\tconst mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\r\n\t\t\tcorner=rotaionZHalfPI*corner;\r\n\t\t\tcorner.y=corner.y-abs(corner.y);\r\n\t\t\t\r\n\t\t\tfloat speed=length(velocity);//TODO:\r\n\t\t\tcenter +=sign(u_SizeScale.x)*(sign(u_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*u_StretchedBillboardSpeedScale+size.y*u_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef HORIZONTALBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\r\n\t\t\tconst vec3 cameraUpVector=vec3(0.0,0.0,1.0);\r\n\t\t\tconst vec3 sideVector = vec3(-1.0,0.0,0.0);\r\n\t\t\t\r\n\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\tfloat c = cos(rot);\r\n\t\t\tfloat s = sin(rot);\r\n\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\tcorner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\r\n\t\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\tcenter +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef VERTICALBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\r\n\t\t\tconst vec3 cameraUpVector =vec3(0.0,1.0,0.0);\r\n\t\t\tvec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\r\n\t\t\t\r\n\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\tfloat c = cos(rot);\r\n\t\t\tfloat s = sin(rot);\r\n\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\tcorner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\r\n\t\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\tcenter +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef RENDERMODE_MESH\r\n\t\t\tvec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\r\n\t\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z, age,normalizedAge));\r\n\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\t#ifdef ROTATIONOVERLIFETIME\r\n\t\t\t\t\t\tfloat angle=computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\r\n\t\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));//已验证\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\t#ifdef SHAPE\r\n\t\t\t\t\t\t\t\tcenter+= u_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\r\n\t\t\t\t\t\t\t#else\r\n\t\t\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\t\t\tcenter+=rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);//已验证\r\n\t\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\t\t\tcenter+=rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);//已验证\r\n\t\t\t\t\t\t\t#endif\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t#endif\r\n\t\t\t\t\t#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n\t\t\t\t\t\t//TODO:是否应合并if(u_ThreeDStartRotation)分支代码,待测试\r\n\t\t\t\t\t\tvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x), age,normalizedAge);\r\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByEuler(u_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));//已验证\r\n\t\t\t\t\t#endif\t\t\r\n\t\t\t\t}\r\n\t\t\t#else\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);//已验证\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\r\n\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);\r\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\tcenter+= (rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));//已验证\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse{\r\n\t\t\t\t\t\t#ifdef SHAPE\r\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\t\tcenter+= u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);\r\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\t\r\n\t\t\t\t\t\t#else\r\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);\r\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);//已验证\r\n\t\t\t\t\t\t#endif\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t\tv_MeshColor=a_MeshColor;\r\n\t\t#endif\r\n\t\r\n\t\tgl_Position=u_Projection*u_View*vec4(center,1.0);\r\n\t\tv_Color = computeParticleColor(a_StartColor, normalizedAge);\r\n\t\t#ifdef DIFFUSEMAP\r\n\t\t\t#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\r\n\t\t\t\tv_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\r\n\t\t\t#endif\r\n\t\t\t#ifdef RENDERMODE_MESH\r\n\t\t\t\tv_TextureCoordinate =computeParticleUV(a_MeshTextureCoordinate, normalizedAge);\r\n\t\t\t#endif\r\n\t\t\t\r\n\t\t\t#ifdef TILINGOFFSET\r\n\t\t\t\tv_TextureCoordinate=TransformUV(v_TextureCoordinate,u_TilingOffset);\r\n\t\t\t#endif\r\n\t\t#endif\r\n \t}\r\n \telse\r\n\t{\r\n\t\tgl_Position=vec4(2.0,2.0,2.0,1.0);//Discard use out of X(-1,1),Y(-1,1),Z(0,1)\r\n\t}\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n\r\n',"#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n precision highp float;\r\n#else\r\n precision mediump float;\r\n#endif\r\n\r\nvarying vec4 v_Color;\r\nvarying vec2 v_TextureCoordinate;\r\nuniform sampler2D u_texture;\r\nuniform vec4 u_Tintcolor;\r\n\r\n#ifdef RENDERMODE_MESH\r\n\tvarying vec4 v_MeshColor;\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\n\r\nvoid main()\r\n{\t\r\n\t#ifdef RENDERMODE_MESH\r\n\t\tgl_FragColor=v_MeshColor;\r\n\t#else\r\n\t\tgl_FragColor=vec4(1.0);\t\r\n\t#endif\r\n\t\t\r\n\t#ifdef DIFFUSEMAP\r\n\t\t#ifdef TINTCOLOR\r\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*u_Tintcolor*2.0*v_Color;\r\n\t\t#else\r\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*v_Color;\r\n\t\t#endif\r\n\t#else\r\n\t\t#ifdef TINTCOLOR\r\n\t\t\tgl_FragColor*=u_Tintcolor*2.0*v_Color;\r\n\t\t#else\r\n\t\t\tgl_FragColor*=v_Color;\r\n\t\t#endif\r\n\t#endif\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,0.0,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}",r),e={a_Position:nt.MESH_POSITION0},t={u_TintColor:he.PERIOD_MATERIAL,u_Exposure:he.PERIOD_MATERIAL,u_Rotation:he.PERIOD_MATERIAL,u_CubeTexture:he.PERIOD_MATERIAL,u_ViewProjection:he.PERIOD_CAMERA},i=he.add("SkyBox"),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#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',"#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"),e={a_Position:nt.MESH_POSITION0},t={u_SunSize:he.PERIOD_MATERIAL,u_SunSizeConvergence:he.PERIOD_MATERIAL,u_AtmosphereThickness:he.PERIOD_MATERIAL,u_SkyTint:he.PERIOD_MATERIAL,u_GroundTint:he.PERIOD_MATERIAL,u_Exposure:he.PERIOD_MATERIAL,u_ViewProjection:he.PERIOD_CAMERA,"u_SunLight.direction":he.PERIOD_SCENE,"u_SunLight.color":he.PERIOD_SCENE},i=he.add("SkyBoxProcedural"),n=new nr(e,t),i.addSubShader(n),n.addShaderPass("#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",'#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'),e={a_Position:nt.MESH_POSITION0,a_Normal:nt.MESH_NORMAL0,a_Texcoord0:nt.MESH_TEXTURECOORDINATE0},t={u_MvpMatrix:he.PERIOD_SPRITE,u_WorldMat:he.PERIOD_SPRITE,u_CameraPos:he.PERIOD_CAMERA,u_Viewport:he.PERIOD_CAMERA,u_ProjectionParams:he.PERIOD_CAMERA,u_View:he.PERIOD_CAMERA,u_LightmapScaleOffset:he.PERIOD_SPRITE,u_LightMap:he.PERIOD_SPRITE,u_SplatAlphaTexture:he.PERIOD_MATERIAL,u_DiffuseTexture1:he.PERIOD_MATERIAL,u_DiffuseTexture2:he.PERIOD_MATERIAL,u_DiffuseTexture3:he.PERIOD_MATERIAL,u_DiffuseTexture4:he.PERIOD_MATERIAL,u_DiffuseTexture5:he.PERIOD_MATERIAL,u_DiffuseScaleOffset1:he.PERIOD_MATERIAL,u_DiffuseScaleOffset2:he.PERIOD_MATERIAL,u_DiffuseScaleOffset3:he.PERIOD_MATERIAL,u_DiffuseScaleOffset4:he.PERIOD_MATERIAL,u_DiffuseScaleOffset5:he.PERIOD_MATERIAL,u_FogStart:he.PERIOD_SCENE,u_FogRange:he.PERIOD_SCENE,u_FogColor:he.PERIOD_SCENE,u_DirationLightCount:he.PERIOD_SCENE,u_LightBuffer:he.PERIOD_SCENE,u_LightClusterBuffer:he.PERIOD_SCENE,u_AmbientColor:he.PERIOD_SCENE,u_ShadowMap:he.PERIOD_SCENE,u_shadowMap2:he.PERIOD_SCENE,u_shadowMap3:he.PERIOD_SCENE,u_ShadowSplitSpheres:he.PERIOD_SCENE,u_ShadowMatrices:he.PERIOD_SCENE,u_ShadowMapSize:he.PERIOD_SCENE,"u_DirectionLight.color":he.PERIOD_SCENE,"u_DirectionLight.direction":he.PERIOD_SCENE,"u_PointLight.position":he.PERIOD_SCENE,"u_PointLight.range":he.PERIOD_SCENE,"u_PointLight.color":he.PERIOD_SCENE,"u_SpotLight.position":he.PERIOD_SCENE,"u_SpotLight.direction":he.PERIOD_SCENE,"u_SpotLight.range":he.PERIOD_SCENE,"u_SpotLight.spot":he.PERIOD_SCENE,"u_SpotLight.color":he.PERIOD_SCENE},r={s_Cull:he.RENDER_STATE_CULL,s_Blend:he.RENDER_STATE_BLEND,s_BlendSrc:he.RENDER_STATE_BLEND_SRC,s_BlendDst:he.RENDER_STATE_BLEND_DST,s_DepthTest:he.RENDER_STATE_DEPTH_TEST,s_DepthWrite:he.RENDER_STATE_DEPTH_WRITE},i=he.add("ExtendTerrain"),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec2 a_Texcoord0;\r\n\r\nuniform mat4 u_MvpMatrix;\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\r\n\tattribute vec3 a_Normal;\r\n\tvarying vec3 v_Normal;\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(CALCULATE_SHADOWS)&&defined(SHADOWMAP_PSSM1))\r\n\tuniform mat4 u_WorldMat;\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform vec4 u_LightmapScaleOffset;\r\n#endif\r\n\r\n#ifdef CALCULATE_SHADOWS\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tgl_Position = u_MvpMatrix * a_Position;\r\n \r\n\tv_Texcoord0 = a_Texcoord0;\r\n \r\n\t#ifdef LIGHTMAP\r\n\t\tv_LightMapUV = vec2(a_Texcoord0.x, 1.0 - a_Texcoord0.y) * u_LightmapScaleOffset.xy + u_LightmapScaleOffset.zw;\r\n\t\tv_LightMapUV.y = 1.0 - v_LightMapUV.y;\r\n\t#endif\r\n \r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tv_Normal = a_Normal;\r\n\t#endif\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(CALCULATE_SHADOWS)&&defined(SHADOWMAP_PSSM1))\r\n\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\r\n\t#endif\r\n\r\n\t#ifdef CALCULATE_SHADOWS\r\n\t\tv_ShadowCoord = getShadowCoord(vec4(v_PositionWorld));\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}','#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#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\r\n\tuniform vec3 u_CameraPos;\r\n\tvarying vec3 v_Normal;\r\n\tvarying vec3 v_PositionWorld;\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#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\n#include "Shadow.glsl"\r\n#ifdef CALCULATE_SHADOWS\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\nvarying float v_posViewZ;\r\n\r\nuniform vec3 u_AmbientColor;\r\n\r\nuniform sampler2D u_SplatAlphaTexture;\r\n\r\nuniform sampler2D u_DiffuseTexture1;\r\nuniform sampler2D u_DiffuseTexture2;\r\nuniform sampler2D u_DiffuseTexture3;\r\nuniform sampler2D u_DiffuseTexture4;\r\nuniform sampler2D u_DiffuseTexture5;\r\n\r\nuniform vec4 u_DiffuseScaleOffset1;\r\nuniform vec4 u_DiffuseScaleOffset2;\r\nuniform vec4 u_DiffuseScaleOffset3;\r\nuniform vec4 u_DiffuseScaleOffset4;\r\nuniform vec4 u_DiffuseScaleOffset5;\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef LIGHTMAP\r\n\tuniform sampler2D u_LightMap;\r\n\tvarying vec2 v_LightMapUV;\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 splatAlpha = vec4(1.0);\r\n\t#ifdef ExtendTerrain_DETAIL_NUM1\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r;\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM2\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * (1.0 - splatAlpha.r);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM3\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * (1.0 - splatAlpha.r - splatAlpha.g);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM4\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM5\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\r\n\t\tvec4 color5 = texture2D(u_DiffuseTexture5, v_Texcoord0 * u_DiffuseScaleOffset5.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * splatAlpha.a + color5.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b - splatAlpha.a);\r\n\t#endif\r\n\t\tgl_FragColor.w = splatAlpha.a;\r\n\t\t\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tvec3 normal = v_Normal;\r\n\t\tvec3 dif, spe;\r\n\t#endif\r\n\r\n\tvec3 diffuse = vec3(0.0);\r\n\tvec3 specular= vec3(0.0);\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\r\n\t\tvec3 toEye;\r\n\t\t#ifdef FOG\r\n\t\t\ttoEye=u_CameraPos-v_PositionWorld;\r\n\t\t\tfloat toEyeLength=length(toEye);\r\n\t\t\ttoEye/=toEyeLength;\r\n\t\t#else\r\n\t\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\r\n\t\t#endif\r\n\t#endif\r\n\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tLayaAirBlinnPhongDiectionLight(vec3(0.0),1.0,normal,vec3(1.0),toEye,u_DirectionLight,dif,spe);\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tLayaAirBlinnPhongPointLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye,u_PointLight,dif,spe);\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tLayaAirBlinnPhongSpotLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye,u_SpotLight,dif,spe);\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\t#else\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tfor (int i = 0; i < MAX_LIGHT_COUNT; i++) \r\n\t\t\t{\r\n\t\t\t\tif(i >= u_DirationLightCount)\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tDirectionLight directionLight = getDirectionLight(u_LightBuffer,i);\r\n\t\t\t\tLayaAirBlinnPhongDiectionLight(vec3(0.0),1.0,normal,vec3(1.0),toEye,directionLight,dif,spe);\r\n\t\t\t\tdiffuse+=dif;\r\n\t\t\t\tspecular+=spe;\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\tLayaAirBlinnPhongPointLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye,pointLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\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\tLayaAirBlinnPhongSpotLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye\t,spotLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t#endif\r\n\r\nvec3 globalDiffuse = u_AmbientColor;\r\n#ifdef LIGHTMAP\r\n\tglobalDiffuse += decodeHDR(texture2D(u_LightMap, v_LightMapUV),5.0);\r\n#endif\r\n\r\n#ifdef CALCULATE_SHADOWS\r\n\tfloat shadowValue = shadowValue = sampleShadowmap(v_ShadowCoord);\r\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse) * shadowValue, gl_FragColor.a);\r\n#else\r\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse), gl_FragColor.a);\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t#ifdef CALCULATE_SHADOWS\r\n\t\tgl_FragColor.rgb += specular * shadowValue;\r\n\t#else\r\n\t\tgl_FragColor.rgb += specular;\r\n\t#endif\r\n#endif\r\n\r\n#ifdef FOG\r\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\r\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\r\n#endif\r\n}\r\n\r\n\r\n\r\n\r\n\r\n',r),e={a_Position:ni.TRAIL_POSITION0,a_OffsetVector:ni.TRAIL_OFFSETVECTOR,a_Texcoord0X:ni.TRAIL_TEXTURECOORDINATE0X,a_Texcoord0Y:ni.TRAIL_TEXTURECOORDINATE0Y,a_BirthTime:ni.TRAIL_TIME0,a_Color:ni.TRAIL_COLOR},t={u_MvpMatrix:he.PERIOD_SPRITE,u_View:he.PERIOD_CAMERA,u_Projection:he.PERIOD_CAMERA,u_TilingOffset:he.PERIOD_MATERIAL,u_MainTexture:he.PERIOD_MATERIAL,u_MainColor:he.PERIOD_MATERIAL,u_CurTime:he.PERIOD_SPRITE,u_LifeTime:he.PERIOD_SPRITE,u_WidthCurve:he.PERIOD_SPRITE,u_WidthCurveKeyLength:he.PERIOD_SPRITE,u_GradientColorkey:he.PERIOD_SPRITE,u_GradientAlphakey:he.PERIOD_SPRITE},r={s_Cull:he.RENDER_STATE_CULL,s_Blend:he.RENDER_STATE_BLEND,s_BlendSrc:he.RENDER_STATE_BLEND_SRC,s_BlendDst:he.RENDER_STATE_BLEND_DST,s_DepthTest:he.RENDER_STATE_DEPTH_TEST,s_DepthWrite:he.RENDER_STATE_DEPTH_WRITE},i=he.add("Trail"),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#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',"#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 ",r),e={a_Position:nt.MESH_POSITION0,a_Normal:nt.MESH_NORMAL0,a_Tangent0:nt.MESH_TANGENT0},t={u_MvpMatrix:he.PERIOD_SPRITE,u_WorldMat:he.PERIOD_SPRITE,u_CameraPos:he.PERIOD_CAMERA,u_Time:he.PERIOD_SCENE,u_MainTexture:he.PERIOD_MATERIAL,u_NormalTexture:he.PERIOD_MATERIAL,u_HorizonColor:he.PERIOD_MATERIAL,u_WaveScale:he.PERIOD_MATERIAL,u_WaveSpeed:he.PERIOD_MATERIAL},i=he.add("WaterPrimary"),n=new nr(e,t),i.addSubShader(n),n.addShaderPass('#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}','#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'),e={a_PositionTexcoord:nt.MESH_POSITION0},t={u_MainTex:he.PERIOD_MATERIAL,u_OffsetScale:he.PERIOD_MATERIAL},i=he.add("BlitScreen"),n=new nr(e,t),i.addSubShader(n);var a=n.addShaderPass('#include "Lighting.glsl";\r\n\r\nattribute vec4 a_PositionTexcoord;\r\nuniform vec4 u_OffsetScale;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\t\r\n\tgl_Position = vec4(u_OffsetScale.x*2.0-1.0+(a_PositionTexcoord.x+1.0)*u_OffsetScale.z,(1.0-((u_OffsetScale.y*2.0-1.0+(-a_PositionTexcoord.y+1.0)*u_OffsetScale.w)+1.0)/2.0)*2.0-1.0, 0.0, 1.0);\t\r\n\tv_Texcoord0 = a_PositionTexcoord.zw;\r\n\tgl_Position = remapGLPositionZ(gl_Position);\r\n}',"#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_MainTex;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_FragColor = texture2D(u_MainTex, v_Texcoord0);\r\n}\r\n\r\n").renderState;a.depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE,e={a_PositionTexcoord:nt.MESH_POSITION0},t={u_MainTex:he.PERIOD_MATERIAL,u_BloomTex:he.PERIOD_MATERIAL,u_AutoExposureTex:he.PERIOD_MATERIAL,u_MainTex_TexelSize:he.PERIOD_MATERIAL,u_SampleScale:he.PERIOD_MATERIAL,u_Threshold:he.PERIOD_MATERIAL,u_Params:he.PERIOD_MATERIAL},i=he.add("PostProcessBloom"),n=new nr(e,t),i.addSubShader(n),(a=n.addShaderPass(Ti,'#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}').renderState).depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE,n=new nr(e,t),i.addSubShader(n),(a=n.addShaderPass(Ti,'#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}').renderState).depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE,n=new nr(e,t),i.addSubShader(n),(a=n.addShaderPass(Ti,'#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}').renderState).depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE,n=new nr(e,t),i.addSubShader(n),(a=n.addShaderPass(Ti,'#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}').renderState).depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE,n=new nr(e,t),i.addSubShader(n),(a=n.addShaderPass(Ti,'#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}').renderState).depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE,n=new nr(e,t),i.addSubShader(n),(a=n.addShaderPass(Ti,'#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}').renderState).depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE,e={a_PositionTexcoord:nt.MESH_POSITION0},t={u_MainTex:he.PERIOD_MATERIAL,u_BloomTex:he.PERIOD_MATERIAL,u_AutoExposureTex:he.PERIOD_MATERIAL,u_Bloom_DirtTileOffset:he.PERIOD_MATERIAL,u_Bloom_DirtTex:he.PERIOD_MATERIAL,u_BloomTex_TexelSize:he.PERIOD_MATERIAL,u_Bloom_Settings:he.PERIOD_MATERIAL,u_Bloom_Color:he.PERIOD_MATERIAL},i=he.add("PostProcessComposite"),n=new nr(e,t),i.addSubShader(n),(a=n.addShaderPass('#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}','#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}').renderState).depthTest=pe.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=pe.CULL_NONE,a.blend=pe.BLEND_DISABLE}}class pi extends gt{constructor(){super(),this._direction=new a,this._shadowCascadesMode=e.ShadowCascadesMode.NoCascades,this._shadowTwoCascadeSplits=1/3,this._shadowFourCascadeSplits=new a(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 gi extends gt{constructor(){super(),this._range=6,this._lightType=e.LightType.Point}get range(){return this._range}set range(e){this._range=e}_addToLightQueue(){this._scene._pointLights.add(this)}_removeFromLightQueue(){this._scene._pointLights.remove(this)}_parse(e,t){super._parse(e,t),this.range=e.range}}class Si extends gt{constructor(){super(),this._spotAngle=30,this._range=10,this._direction=new a,this._lightType=e.LightType.Spot}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}_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 Ri{static _createSprite3DInstance(e,t,r){var i;switch(e.type){case"Scene3D":i=new rr;break;case"Sprite3D":i=new _t;break;case"MeshSprite3D":i=new pr,r&&e.props.isStatic&&r.push(i);break;case"SkinnedMeshSprite3D":i=new ti;break;case"ShuriKenParticle3D":i=new Jr;break;case"Camera":i=new Rt;break;case"DirectionLight":i=new pi;break;case"PointLight":i=new gi;break;case"SpotLight":i=new Si;break;case"TrailSprite3D":i=new li;break;default:throw new Error("Utils3D:unidentified class type in (.lh) file.")}var n=e.child;if(n)for(var a=0,s=n.length;a65535?e.IndexFormat.UInt32:e.IndexFormat.UInt16,S._vertexBuffer=L,S._vertexCount+=m,n+=4*h.length}var D,C=l+a.getUint32(),y=a.getUint32();D=S.indexFormat==e.IndexFormat.UInt32?new Uint32Array(s.slice(C,C+y)):new Uint16Array(s.slice(C,C+y));var M=new et(S.indexFormat,D.length,i.STATIC_DRAW,!0);if(M.setData(D),S._indexBuffer=M,S._setBuffer(S._vertexBuffer,M),n+=2*M.indexCount,S._setCPUMemory(n),S._setGPUMemory(n),"LAYAMODEL:0501"==Ai._version||"LAYAMODEL:COMPRESSION_0501"==Ai._version){var O=S.bounds,N=O.getMin(),b=O.getMax();N.setValue(a.getFloat32(),a.getFloat32(),a.getFloat32()),b.setValue(a.getFloat32(),a.getFloat32(),a.getFloat32()),O.setMin(N),O.setMax(b),S.bounds=O}var P=S._boneNames=[],w=a.getUint16();for(P.length=w,r=0;r v_Image180ScaleAndCutoff.y)\r\n\t\tgl_FragColor=vec4(0,0,0,1);\r\n\ttc.x = mod(tc.x*v_Image180ScaleAndCutoff.x, 1.0);\r\n\ttc = (tc + v_Layout3DScaleAndOffset.xy) * v_Layout3DScaleAndOffset.zw;\r\n\r\n\tmediump vec4 tex = texture2D (u_Texture, tc);\r\n\tmediump vec3 c = decodeHDR (tex, u_TextureHDRParams.x);\r\n\tc = c * u_TintColor.rgb * 2.0;//Gamma Space is 2.0,linear space is 4.59479380\r\n\tgl_FragColor=vec4(c, 1.0);\r\n}\r\n\r\n')}get tintColor(){return this._shaderValues.getVector(xi.TINTCOLOR)}set tintColor(e){this._shaderValues.setVector(xi.TINTCOLOR,e)}get exposure(){return this._exposure}set exposure(e){this._exposure!==e&&(this._exposure=e,this._textureDecodeFormat==t.TextureDecodeFormat.RGBM?this._textureHDRParams.x=e*t.BaseTexture._rgbmRange:this._textureHDRParams.x=e)}get rotation(){return this._shaderValues.getNumber(xi.ROTATION)}set rotation(e){this._shaderValues.setNumber(xi.ROTATION,e)}get panoramicTexture(){return this._shaderValues.getTexture(xi.TEXTURE)}set panoramicTexture(e){this._shaderValues.setTexture(xi.TEXTURE,e)}get panoramicTextureDecodeFormat(){return this._textureDecodeFormat}set panoramicTextureDecodeFormat(e){this._textureDecodeFormat!==e&&(this._textureDecodeFormat=e,e==t.TextureDecodeFormat.RGBM?this._textureHDRParams.x=this._exposure*t.BaseTexture._rgbmRange:this._textureHDRParams.x=this._exposure)}}xi.TINTCOLOR=he.propertyNameToID("u_TintColor"),xi.EXPOSURE=he.propertyNameToID("u_Exposure"),xi.ROTATION=he.propertyNameToID("u_Rotation"),xi.TEXTURE=he.propertyNameToID("u_Texture"),xi.TEXTURE_HDR_PARAMS=he.propertyNameToID("u_TextureHDRParams");class Li extends t.Component{constructor(e){super(),this._anchor=new a,this._connectAnchor=new a,this._feedbackEnabled=!1,this._getJointFeedBack=!1,this._currentForce=new a,this._currentTorque=new a,this._constraintType=e;var t=V._bullet;this._btframATrans=t.btTransform_create(),this._btframBTrans=t.btTransform_create(),t.btTransform_setIdentity(this._btframATrans),t.btTransform_setIdentity(this._btframBTrans),this._btframAPos=t.btVector3_create(0,0,0),this._btframBPos=t.btVector3_create(0,0,0),t.btTransform_setOrigin(this._btframATrans,this._btframAPos),t.btTransform_setOrigin(this._btframBTrans,this._btframBPos),this._breakForce=-1,this._breakTorque=-1}get enabled(){return super.enabled}set enabled(e){super.enabled=e}get appliedImpulse(){return this._feedbackEnabled||(this._btConstraint.EnableFeedback(!0),this._feedbackEnabled=!0),this._btConstraint.AppliedImpulse}set connectedBody(e){this._connectedBody=e,e.constaintRigidbodyB=this}get connectedBody(){return this._connectedBody}get ownBody(){return this._ownBody}set ownBody(e){this._ownBody=e,e.constaintRigidbodyA=this}get currentForce(){return this._getJointFeedBack||this._getFeedBackInfo(),this._currentForce}get currentTorque(){return this._getJointFeedBack||this._getFeedBackInfo(),this._currentTorque}get breakForce(){return this._breakForce}set breakForce(e){this._breakForce=e}get breakTorque(){return this._breakTorque}set breakTorque(e){this._breakTorque=e}set anchor(e){e.cloneTo(this._anchor),this.setFrames()}get anchor(){return this._anchor}set connectAnchor(e){e.cloneTo(this._connectAnchor),this.setFrames()}get connectAnchor(){return this._connectAnchor}setOverrideNumSolverIterations(e){V._bullet.btTypedConstraint_setOverrideNumSolverIterations(this._btConstraint,e)}setConstraintEnabled(e){V._bullet.btTypedConstraint_setEnabled(this._btConstraint,e)}_onEnable(){super._onEnable(),this.enabled=!0}_onDisable(){super._onDisable(),this.enabled=!1}setFrames(){var e=V._bullet;e.btVector3_setValue(this._btframAPos,-this._anchor.x,this.anchor.y,this.anchor.z),e.btVector3_setValue(this._btframBPos,-this._connectAnchor.x,this._connectAnchor.y,this._connectAnchor.z),e.btTransform_setOrigin(this._btframATrans,this._btframAPos),e.btTransform_setOrigin(this._btframBTrans,this._btframBPos)}_addToSimulation(){}_removeFromSimulation(){}_createConstraint(){}setConnectRigidBody(e,t){var r=e&&!!(e._simulation&&e._enabled&&e.colliderShape),i=t&&!!(t._simulation&&t._enabled&&t.colliderShape);if(!r||!i)throw"ownerRigid or connectRigidBody is not in Simulation";e==this._ownBody&&t==this._connectedBody||(!(!this.enabled||!this._simulation)&&this._removeFromSimulation(),this._ownBody=e,this._connectedBody=t,this._ownBody.constaintRigidbodyA=this,this._connectedBody.constaintRigidbodyB=this,this._createConstraint())}getcurrentForce(e){if(!this._btJointFeedBackObj)throw"this Constraint is not simulation";var t=V._bullet,r=t.btJointFeedback_getAppliedForceBodyA(this._btJointFeedBackObj);e.setValue(t.btVector3_x(r),t.btVector3_y(r),t.btVector3_z(r))}getcurrentTorque(e){if(!this._btJointFeedBackObj)throw"this Constraint is not simulation";var t=V._bullet,r=t.btJointFeedback_getAppliedTorqueBodyA(this._btJointFeedBackObj);e.setValue(t.btVector3_x(r),t.btVector3_y(r),t.btVector3_z(r))}_onDestroy(){var e=V._bullet;this._removeFromSimulation(),this._btConstraint&&this._btJointFeedBackObj&&this._simulation&&(e.btTypedConstraint_destroy(this._btConstraint),e.btJointFeedback_destroy(this._btJointFeedBackObj),this._btJointFeedBackObj=null,this._btConstraint=null),super._onDisable()}_isBreakConstrained(){if(this._getJointFeedBack=!1,-1==this.breakForce&&-1==this.breakTorque)return!1;this._getFeedBackInfo();var e=-1!=this._breakForce&&a.scalarLength(this._currentForce)>this._breakForce,t=-1!=this._breakTorque&&a.scalarLength(this._currentTorque)>this._breakTorque;return!(!e&&!t)&&(this._breakConstrained(),!0)}_parse(e){this._anchor.fromArray(e.anchor),this._connectAnchor.fromArray(e.connectAnchor),this.setFrames()}_getFeedBackInfo(){var e=V._bullet,t=e.btJointFeedback_getAppliedForceBodyA(this._btJointFeedBackObj),r=e.btJointFeedback_getAppliedTorqueBodyA(this._btJointFeedBackObj);this._currentTorque.setValue(e.btVector3_x(r),e.btVector3_y(r),e.btVector3_z(r)),this._currentForce.setValue(e.btVector3_x(t),e.btVector3_y(t),e.btVector3_z(t)),this._getJointFeedBack=!0}_breakConstrained(){this.ownBody.constaintRigidbodyA=null,this.connectedBody.constaintRigidbodyB=null,this.destroy()}}Li.CONSTRAINT_POINT2POINT_CONSTRAINT_TYPE=3,Li.CONSTRAINT_HINGE_CONSTRAINT_TYPE=4,Li.CONSTRAINT_CONETWIST_CONSTRAINT_TYPE=5,Li.CONSTRAINT_D6_CONSTRAINT_TYPE=6,Li.CONSTRAINT_SLIDER_CONSTRAINT_TYPE=7,Li.CONSTRAINT_CONTACT_CONSTRAINT_TYPE=8,Li.CONSTRAINT_D6_SPRING_CONSTRAINT_TYPE=9,Li.CONSTRAINT_GEAR_CONSTRAINT_TYPE=10,Li.CONSTRAINT_FIXED_CONSTRAINT_TYPE=11,Li.CONSTRAINT_MAX_CONSTRAINT_TYPE=12,Li.CONSTRAINT_CONSTRAINT_ERP=1,Li.CONSTRAINT_CONSTRAINT_STOP_ERP=2,Li.CONSTRAINT_CONSTRAINT_CFM=3,Li.CONSTRAINT_CONSTRAINT_STOP_CFM=4,Li.tempForceV3=new a;class Di extends Li{constructor(){super(Li.CONSTRAINT_FIXED_CONSTRAINT_TYPE),this.breakForce=-1,this.breakTorque=-1}_addToSimulation(){this._simulation&&this._simulation.addConstraint(this,this.enabled)}_removeFromSimulation(){this._simulation.removeConstraint(this),this._simulation=null}_createConstraint(){if(this.ownBody&&this.ownBody._simulation&&this.connectedBody&&this.connectedBody._simulation){var e=V._bullet;this._btConstraint=e.btFixedConstraint_create(this.ownBody.btColliderObject,this._btframATrans,this.connectedBody.btColliderObject,this._btframBTrans),this._btJointFeedBackObj=e.btJointFeedback_create(this._btConstraint),e.btTypedConstraint_setJointFeedback(this._btConstraint,this._btJointFeedBackObj),this._simulation=this.owner._scene.physicsSimulation,this._addToSimulation(),V._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0)}}_onAdded(){super._onAdded()}_onEnable(){this._btConstraint&&(super._onEnable(),this._btConstraint&&V._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0))}_onDisable(){super._onDisable(),this.connectedBody||this._removeFromSimulation(),this._btConstraint&&V._bullet.btTypedConstraint_setEnabled(this._btConstraint,!1)}_onDestroy(){super._onDestroy()}_parse(e,t=null){super._parse(e),-1!=e.rigidbodyID&&-1!=e.connectRigidbodyID&&(t.component.push(this),t.data.push(e)),null!=e.breakForce&&(this.breakForce=e.breakForce),null!=e.breakTorque&&(this.breakTorque=e.breakTorque)}_parseInteractive(e=null,t=null){var r=t[e.rigidbodyID].getComponent(w),i=t[e.connectRigidbodyID].getComponent(w);this.ownBody=r,this.connectedBody=i}_cloneTo(e){}}class Ci extends Li{constructor(){super(Li.CONSTRAINT_D6_SPRING_CONSTRAINT_TYPE),this._axis=new a,this._secondaryAxis=new a,this._minLinearLimit=new a,this._maxLinearLimit=new a,this._minAngularLimit=new a,this._maxAngularLimit=new a,this._linearLimitSpring=new a,this._angularLimitSpring=new a,this._linearBounce=new a,this._angularBounce=new a,this._linearDamp=new a,this._angularDamp=new a,this._xMotion=0,this._yMotion=0,this._zMotion=0,this._angularXMotion=0,this._angularYMotion=0,this._angularZMotion=0;var e=V._bullet;this._btAxis=e.btVector3_create(-1,0,0),this._btSecondaryAxis=e.btVector3_create(0,1,0)}get axis(){return this._axis}get secondaryAxis(){return this._secondaryAxis}set maxAngularLimit(e){e.cloneTo(this._maxAngularLimit)}set minAngularLimit(e){e.cloneTo(this._minAngularLimit)}get maxAngularLimit(){return this._maxAngularLimit}get minAngularLimit(){return this._minAngularLimit}set maxLinearLimit(e){e.cloneTo(this._maxLinearLimit)}set minLinearLimit(e){e.cloneTo(this._minLinearLimit)}get maxLinearLimit(){return this._maxLinearLimit}get minLinearLimit(){return this._minLinearLimit}set XMotion(e){this._xMotion!=e&&(this._xMotion=e,this.setLimit(Ci.MOTION_LINEAR_INDEX_X,e,-this._maxLinearLimit.x,-this._minLinearLimit.x))}get XMotion(){return this._xMotion}set YMotion(e){this._yMotion!=e&&(this._yMotion=e,this.setLimit(Ci.MOTION_LINEAR_INDEX_Y,e,this._minLinearLimit.y,this._maxLinearLimit.y))}get YMotion(){return this._yMotion}set ZMotion(e){this._zMotion!=e&&(this._zMotion=e,this.setLimit(Ci.MOTION_LINEAR_INDEX_Z,e,this._minLinearLimit.z,this._maxLinearLimit.z))}get ZMotion(){return this._zMotion}set angularXMotion(e){this._angularXMotion!=e&&(this._angularXMotion=e,this.setLimit(Ci.MOTION_ANGULAR_INDEX_X,e,-this._maxAngularLimit.x,-this._minAngularLimit.x))}get angularXMotion(){return this._angularXMotion}set angularYMotion(e){this._angularYMotion!=e&&(this._angularYMotion=e,this.setLimit(Ci.MOTION_ANGULAR_INDEX_Y,e,this._minAngularLimit.y,this._maxAngularLimit.y))}get angularYMotion(){return this._angularYMotion}set angularZMotion(e){this._angularZMotion!=e&&(this._angularZMotion=e,this.setLimit(Ci.MOTION_ANGULAR_INDEX_Z,e,this._minAngularLimit.z,this._maxAngularLimit.z))}get angularZMotion(){return this._angularZMotion}set linearLimitSpring(e){a.equals(this._linearLimitSpring,e)||(e.cloneTo(this._linearLimitSpring),this.setSpring(Ci.MOTION_LINEAR_INDEX_X,e.x),this.setSpring(Ci.MOTION_LINEAR_INDEX_Y,e.y),this.setSpring(Ci.MOTION_LINEAR_INDEX_Z,e.z))}get linearLimitSpring(){return this._linearLimitSpring}set angularLimitSpring(e){a.equals(this._angularLimitSpring,e)||(e.cloneTo(this._angularLimitSpring),this.setSpring(Ci.MOTION_ANGULAR_INDEX_X,e.x),this.setSpring(Ci.MOTION_ANGULAR_INDEX_Y,e.y),this.setSpring(Ci.MOTION_ANGULAR_INDEX_Z,e.z))}get angularLimitSpring(){return this._angularLimitSpring}set linearBounce(e){a.equals(this._linearBounce,e)||(e.cloneTo(this._linearBounce),this.setBounce(Ci.MOTION_LINEAR_INDEX_X,e.x),this.setBounce(Ci.MOTION_LINEAR_INDEX_Y,e.y),this.setBounce(Ci.MOTION_LINEAR_INDEX_Z,e.z))}get linearBounce(){return this._linearBounce}set angularBounce(e){a.equals(this._angularBounce,e)||(e.cloneTo(this._angularBounce),this.setBounce(Ci.MOTION_ANGULAR_INDEX_X,e.x),this.setBounce(Ci.MOTION_ANGULAR_INDEX_Y,e.y),this.setBounce(Ci.MOTION_ANGULAR_INDEX_Z,e.z))}get angularBounce(){return this._angularBounce}set linearDamp(e){a.equals(this._linearDamp,e)||(e.cloneTo(this._linearDamp),this.setDamping(Ci.MOTION_LINEAR_INDEX_X,e.x),this.setDamping(Ci.MOTION_LINEAR_INDEX_Y,e.y),this.setDamping(Ci.MOTION_LINEAR_INDEX_Z,e.z))}get linearDamp(){return this._linearDamp}set angularDamp(e){a.equals(this._angularDamp,e)||(e.cloneTo(this._angularDamp),this.setDamping(Ci.MOTION_ANGULAR_INDEX_X,e.x),this.setDamping(Ci.MOTION_ANGULAR_INDEX_Y,e.y),this.setDamping(Ci.MOTION_ANGULAR_INDEX_Z,e.z))}get angularDamp(){return this._angularDamp}set anchor(e){e.cloneTo(this._anchor),this.setFrames()}get anchor(){return this._anchor}set connectAnchor(e){e.cloneTo(this._connectAnchor),this.setFrames()}get connectAnchor(){return this._connectAnchor}setAxis(e,t){if(this._btConstraint){var r=V._bullet;this._axis.setValue(e.x,e.y,e.y),this._secondaryAxis.setValue(t.x,t.y,t.z),this._btAxis=r.btVector3_setValue(-e.x,e.y,e.z),this._btSecondaryAxis=r.btVector3_setValue(-t.x,t.y,t.z),r.btGeneric6DofSpring2Constraint_setAxis(this._btConstraint,this._btAxis,this._btSecondaryAxis)}}setLimit(e,t,r,i){if(this._btConstraint){var n=V._bullet;switch(t){case Ci.CONFIG_MOTION_TYPE_LOCKED:n.btGeneric6DofSpring2Constraint_setLimit(this._btConstraint,e,0,0);break;case Ci.CONFIG_MOTION_TYPE_LIMITED:r0;i.btGeneric6DofSpring2Constraint_enableSpring(this._btConstraint,e,n),n&&i.btGeneric6DofSpring2Constraint_setStiffness(this._btConstraint,e,t,r)}}setBounce(e,t){this._btConstraint&&(t=t<=0?0:t,V._bullet.btGeneric6DofSpring2Constraint_setBounce(this._btConstraint,e,t))}setDamping(e,t,r=!0){this._btConstraint&&(t=t<=0?0:t,V._bullet.btGeneric6DofSpring2Constraint_setDamping(this._btConstraint,e,t,r))}setEquilibriumPoint(e,t){V._bullet.btGeneric6DofSpring2Constraint_setEquilibriumPoint(this._btConstraint,e,t)}enableMotor(e,t){V._bullet.btGeneric6DofSpring2Constraint_enableMotor(this._btConstraint,e,t)}setServo(e,t){V._bullet.btGeneric6DofSpring2Constraint_setServo(this._btConstraint,e,t)}setTargetVelocity(e,t){V._bullet.btGeneric6DofSpring2Constraint_setTargetVelocity(this._btConstraint,e,t)}setTargetPosition(e,t){V._bullet.btGeneric6DofSpring2Constraint_setServoTarget(this._btConstraint,e,t)}setMaxMotorForce(e,t){V._bullet.btGeneric6DofSpring2Constraint_setMaxMotorForce(this._btConstraint,e,t)}setParam(e,t,r){V._bullet.btTypedConstraint_setParam(this._btConstraint,e,t,r)}setFrames(){super.setFrames();var e=V._bullet;this._btConstraint&&e.btGeneric6DofSpring2Constraint_setFrames(this._btConstraint,this._btframATrans,this._btframBTrans)}_addToSimulation(){this._simulation&&this._simulation.addConstraint(this,this.enabled)}_removeFromSimulation(){this._simulation.removeConstraint(this),this._simulation=null}_createConstraint(){var e=V._bullet;this._btConstraint=e.btGeneric6DofSpring2Constraint_create(this.ownBody.btColliderObject,this._btframAPos,this.connectedBody.btColliderObject,this._btframBPos,Ci.RO_XYZ),this._btJointFeedBackObj=e.btJointFeedback_create(this._btConstraint),e.btTypedConstraint_setJointFeedback(this._btConstraint,this._btJointFeedBackObj),this._simulation=this.owner._scene.physicsSimulation,this._initAllConstraintInfo(),this._addToSimulation(),V._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0)}_initAllConstraintInfo(){this.setLimit(Ci.MOTION_LINEAR_INDEX_X,this._xMotion,-this._maxLinearLimit.x,-this._minLinearLimit.x),this.setLimit(Ci.MOTION_LINEAR_INDEX_Y,this._yMotion,this._minLinearLimit.y,this._maxLinearLimit.y),this.setLimit(Ci.MOTION_LINEAR_INDEX_Z,this._zMotion,this._minLinearLimit.z,this._maxLinearLimit.z),this.setLimit(Ci.MOTION_ANGULAR_INDEX_X,this._angularXMotion,-this._maxAngularLimit.x,-this._minAngularLimit.x),this.setLimit(Ci.MOTION_ANGULAR_INDEX_Y,this._angularYMotion,this._minAngularLimit.y,this._maxAngularLimit.y),this.setLimit(Ci.MOTION_ANGULAR_INDEX_Z,this._angularZMotion,this._minAngularLimit.z,this._maxAngularLimit.z),this.setSpring(Ci.MOTION_LINEAR_INDEX_X,this._linearLimitSpring.x),this.setSpring(Ci.MOTION_LINEAR_INDEX_Y,this._linearLimitSpring.y),this.setSpring(Ci.MOTION_LINEAR_INDEX_Z,this._linearLimitSpring.z),this.setSpring(Ci.MOTION_ANGULAR_INDEX_X,this._angularLimitSpring.x),this.setSpring(Ci.MOTION_ANGULAR_INDEX_Y,this._angularLimitSpring.y),this.setSpring(Ci.MOTION_ANGULAR_INDEX_Z,this._angularLimitSpring.z),this.setBounce(Ci.MOTION_LINEAR_INDEX_X,this._linearBounce.x),this.setBounce(Ci.MOTION_LINEAR_INDEX_Y,this._linearBounce.y),this.setBounce(Ci.MOTION_LINEAR_INDEX_Z,this._linearBounce.z),this.setBounce(Ci.MOTION_ANGULAR_INDEX_X,this._angularBounce.x),this.setBounce(Ci.MOTION_ANGULAR_INDEX_Y,this._angularBounce.y),this.setBounce(Ci.MOTION_ANGULAR_INDEX_Z,this._angularBounce.z),this.setDamping(Ci.MOTION_LINEAR_INDEX_X,this._linearDamp.x),this.setDamping(Ci.MOTION_LINEAR_INDEX_Y,this._linearDamp.y),this.setDamping(Ci.MOTION_LINEAR_INDEX_Z,this._linearDamp.z),this.setDamping(Ci.MOTION_ANGULAR_INDEX_X,this._angularDamp.x),this.setDamping(Ci.MOTION_ANGULAR_INDEX_Y,this._angularDamp.y),this.setDamping(Ci.MOTION_ANGULAR_INDEX_Z,this._angularDamp.z),this.setFrames(),this.setEquilibriumPoint(0,0)}_onAdded(){super._onAdded()}_onEnable(){this._btConstraint&&(super._onEnable(),this._btConstraint&&V._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0))}_onDisable(){super._onDisable(),this.connectedBody||this._removeFromSimulation(),this._btConstraint&&V._bullet.btTypedConstraint_setEnabled(this._btConstraint,!1)}_parse(e,t=null){super._parse(e),this._axis.fromArray(e.axis),this._secondaryAxis.fromArray(e.secondaryAxis);var r=e.linearLimit;this._minLinearLimit.setValue(-r,-r,-r),this._maxLinearLimit.setValue(r,r,r);var i=e.linearLimitSpring;this._linearLimitSpring.setValue(i,i,i);var n=e.linearLimitDamper;this._linearDamp.setValue(n,n,n);var a=e.linearLimitBounciness;this._linearBounce.setValue(a,a,a);var s=e.lowAngularXLimit,o=e.highAngularXLimit,l=e.angularYLimit,_=e.angularZLimit;this._minAngularLimit.setValue(s,-l,-_),this._maxAngularLimit.setValue(o,l,_);var h=e.highAngularXLimitBounciness,c=e.angularYLimitBounciness,d=e.angularZLimitBounciness;this._angularBounce.setValue(h,c,d);var u=e.angularXLimitSpring,m=e.angularYZLimitSpring;this._angularLimitSpring.setValue(u,m,m);var f=e.angularXLimitDamper,T=e.angularYZLimitDamper;this._angularDamp.setValue(f,T,T),this.XMotion=e.xMotion,this.YMotion=e.yMotion,this.ZMotion=e.zMotion,this.angularXMotion=e.angularXMotion,this.angularYMotion=e.angularYMotion,this.angularZMotion=e.angularZMotion,-1!=e.rigidbodyID&&-1!=e.connectRigidbodyID&&(t.component.push(this),t.data.push(e)),null!=e.breakForce&&(this.breakForce=e.breakForce),null!=e.breakTorque&&(this.breakTorque=e.breakTorque)}_parseInteractive(e=null,t=null){var r=t[e.rigidbodyID].getComponent(w),i=t[e.connectRigidbodyID].getComponent(w);this.ownBody=r,this.connectedBody=i}_onDestroy(){super._onDestroy()}_cloneTo(e){}}Ci.CONFIG_MOTION_TYPE_LOCKED=0,Ci.CONFIG_MOTION_TYPE_LIMITED=1,Ci.CONFIG_MOTION_TYPE_FREE=2,Ci.MOTION_LINEAR_INDEX_X=0,Ci.MOTION_LINEAR_INDEX_Y=1,Ci.MOTION_LINEAR_INDEX_Z=2,Ci.MOTION_ANGULAR_INDEX_X=3,Ci.MOTION_ANGULAR_INDEX_Y=4,Ci.MOTION_ANGULAR_INDEX_Z=5,Ci.RO_XYZ=0,Ci.RO_XZY=1,Ci.RO_YXZ=2,Ci.RO_YZX=3,Ci.RO_ZXY=4,Ci.RO_ZYX=5;class yi{constructor(){}static get enablePhysics(){return V._enablePhysics}static _cancelLoadByUrl(e){t.Laya.loader.cancelLoadByUrl(e),yi._innerFirstLevelLoaderManager.cancelLoadByUrl(e),yi._innerSecondLevelLoaderManager.cancelLoadByUrl(e),yi._innerThirdLevelLoaderManager.cancelLoadByUrl(e),yi._innerFourthLevelLoaderManager.cancelLoadByUrl(e)}static _changeWebGLSize(e,r){t.WebGL.onStageResize(e,r),ne.clientWidth=e,ne.clientHeight=r}static __init__(r,i,n){if(t.Config.isAntialias=n.isAntialias,t.Config.isAlpha=n.isAlpha,t.Config.premultipliedAlpha=n.premultipliedAlpha,t.Config.isStencil=n.isStencil,t.WebGL.enable()){t.RunDriver.changeWebGLSize=yi._changeWebGLSize,t.Render.is3DMode=!0,t.Laya.init(r,i),t.Render.supportWebGLPlusRendering||(t.LayaGL.instance=t.WebGLContext.mainContext,t.LayaGL.instance.createCommandEncoder=function(e=128,r=64,i=!1){return new t.CommandEncoder(this,e,r,i)}),n._multiLighting=n.enableMultiLight&&t.SystemUtils.supportTextureFormat(t.TextureFormat.R32G32B32A32),_.Shader3D=he,_.Scene3D=rr,_.MeshRenderStaticBatchManager=Ht,_.MeshRenderDynamicBatchManager=Er,_.SubMeshDynamicBatch=Tr,_.Laya3D=yi,_.Matrix4x4=c,_.Physics3D=V,_.ShadowLightType=e.ShadowLightType,yi.enableNative3D(),n.isUseCannonPhysicsEngine&&V.__cannoninit__(),V.__bulletinit__(),tt.__init__(),nt.__init__(),Yr.__init__(),jr.__init__(),It.__init__(),ni.__init__(),_i.__init__(),bt.__init__(),Bt.__init__(),Tr.__init__(),Ei.__init__(),St.init(),ve.__init__(),lr.__init__(),ar.__init__(),xi.__init__(),mi.__init__(),fi.__init__(),_t.__init__(),wt.__init__(),pr.__init__(),ti.__init__(),Jr.__init__(),li.__init__(),de.__init__(),rr.__init__(),Ht.__init__(),Te.__initDefine__(),Ee.__initDefine__(),ge.__initDefine__(),hr.__initDefine__(),cr.__initDefine__(),ri.__initDefine__(),Se.__initDefine__(),dr.__initDefine__(),Wr.__initDefine__(),Re.__initDefine__(),yt.__initDefine__(),_r.__initDefine__(),ut.__init__(),t.ClassUtils.regClass("Laya.SkyPanoramicMaterial",xi),t.ClassUtils.regClass("Laya.EffectMaterial",Se),t.ClassUtils.regClass("Laya.UnlitMaterial",cr),t.ClassUtils.regClass("Laya.BlinnPhongMaterial",ge),t.ClassUtils.regClass("Laya.SkyProceduralMaterial",hr),t.ClassUtils.regClass("Laya.PBRStandardMaterial",lr),t.ClassUtils.regClass("Laya.PBRSpecularMaterial",ar),t.ClassUtils.regClass("Laya.SkyBoxMaterial",_r),t.ClassUtils.regClass("Laya.WaterPrimaryMaterial",dr),t.ClassUtils.regClass("Laya.ExtendTerrainMaterial",Re),t.ClassUtils.regClass("Laya.ShurikenParticleMaterial",Wr),t.ClassUtils.regClass("Laya.TrailMaterial",ri),t.ClassUtils.regClass("Laya.PhysicsCollider",ci),t.ClassUtils.regClass("Laya.Rigidbody3D",w),t.ClassUtils.regClass("Laya.CharacterController",b),t.ClassUtils.regClass("Laya.Animator",re),t.ClassUtils.regClass("PhysicsCollider",ci),t.ClassUtils.regClass("CharacterController",b),t.ClassUtils.regClass("Animator",re),t.ClassUtils.regClass("Rigidbody3D",w),t.ClassUtils.regClass("FixedConstraint",Di),t.ClassUtils.regClass("ConfigurableConstraint",Ci),yt.defaultMaterial=new yt,ge.defaultMaterial=new ge,Se.defaultMaterial=new Se,cr.defaultMaterial=new cr,Wr.defaultMaterial=new Wr,ri.defaultMaterial=new ri,hr.defaultMaterial=new hr,_r.defaultMaterial=new _r,dr.defaultMaterial=new dr,yt.defaultMaterial.lock=!0,ge.defaultMaterial.lock=!0,Se.defaultMaterial.lock=!0,cr.defaultMaterial.lock=!0,Wr.defaultMaterial.lock=!0,ri.defaultMaterial.lock=!0,hr.defaultMaterial.lock=!0,_r.defaultMaterial.lock=!0,dr.defaultMaterial.lock=!0,t.Texture2D.__init__(),Lt.__init__(),ot.__init__(),xt.__init__(),ct.__init__(),dt.__init__(),Ge.__init__(),X.__init__();var a=t.LoaderManager.createMap;a.lh=[yi.HIERARCHY,Ri._parse],a.ls=[yi.HIERARCHY,Ri._parseScene],a.lm=[yi.MESH,Ii._parse],a.lmat=[yi.MATERIAL,Te._parse],a.jpg=[yi.TEXTURE2D,t.Texture2D._parse],a.jpeg=[yi.TEXTURE2D,t.Texture2D._parse],a.bmp=[yi.TEXTURE2D,t.Texture2D._parse],a.gif=[yi.TEXTURE2D,t.Texture2D._parse],a.png=[yi.TEXTURE2D,t.Texture2D._parse],a.dds=[yi.TEXTURE2D,t.Texture2D._parse],a.ktx=[yi.TEXTURE2D,t.Texture2D._parse],a.pvr=[yi.TEXTURE2D,t.Texture2D._parse],a.lani=[yi.ANIMATIONCLIP,Z._parse],a.lav=[yi.AVATAR,fe._parse],a.ltc=[yi.TEXTURECUBE,Lt._parse],a.ltcb=[yi.TEXTURECUBEBIN,Lt._parseBin],a["ltcb.ls"]=[yi.TEXTURECUBEBIN,Lt._parseBin];var s=t.Loader.parserMap;s[yi.HIERARCHY]=yi._loadHierarchy,s[yi.MESH]=yi._loadMesh,s[yi.MATERIAL]=yi._loadMaterial,s[yi.TEXTURECUBE]=yi._loadTextureCube,s[yi.TEXTURECUBEBIN]=yi._loadTextureCubeBin,s[yi.TEXTURE2D]=yi._loadTexture2D,s[yi.ANIMATIONCLIP]=yi._loadAnimationClip,s[yi.AVATAR]=yi._loadAvatar,yi._innerFirstLevelLoaderManager.on(t.Event.ERROR,null,yi._eventLoadManagerError),yi._innerSecondLevelLoaderManager.on(t.Event.ERROR,null,yi._eventLoadManagerError),yi._innerThirdLevelLoaderManager.on(t.Event.ERROR,null,yi._eventLoadManagerError),yi._innerFourthLevelLoaderManager.on(t.Event.ERROR,null,yi._eventLoadManagerError)}else alert("Laya3D init error,must support webGL!")}static enableNative3D(){var e=ce,r=we,i=ei,n=fe,a=Ge;if(t.Render.supportWebGLPlusRendering&&(e.prototype._initData=e.prototype._initDataForNative,e.prototype.setBool=e.prototype.setBoolForNative,e.prototype.getBool=e.prototype.getBoolForNative,e.prototype.setInt=e.prototype.setIntForNative,e.prototype.getInt=e.prototype.getIntForNative,e.prototype.setNumber=e.prototype.setNumberForNative,e.prototype.getNumber=e.prototype.getNumberForNative,e.prototype.setVector=e.prototype.setVectorForNative,e.prototype.getVector=e.prototype.getVectorForNative,e.prototype.setVector2=e.prototype.setVector2ForNative,e.prototype.getVector2=e.prototype.getVector2ForNative,e.prototype.setVector3=e.prototype.setVector3ForNative,e.prototype.getVector3=e.prototype.getVector3ForNative,e.prototype.setQuaternion=e.prototype.setQuaternionForNative,e.prototype.getQuaternion=e.prototype.getQuaternionForNative,e.prototype.setMatrix4x4=e.prototype.setMatrix4x4ForNative,e.prototype.getMatrix4x4=e.prototype.getMatrix4x4ForNative,e.prototype.setBuffer=e.prototype.setBufferForNative,e.prototype.getBuffer=e.prototype.getBufferForNative,e.prototype.setTexture=e.prototype.setTextureForNative,e.prototype.getTexture=e.prototype.getTextureForNative,e.prototype.setAttribute=e.prototype.setAttributeForNative,e.prototype.getAttribute=e.prototype.getAttributeForNative,e.prototype.cloneTo=e.prototype.cloneToForNative,e.prototype.getData=e.prototype.getDataForNative,r.prototype._uniformMatrix2fv=r.prototype._uniformMatrix2fvForNative,r.prototype._uniformMatrix3fv=r.prototype._uniformMatrix3fvForNative,r.prototype._uniformMatrix4fv=r.prototype._uniformMatrix4fvForNative,t.LayaGLRunner.uploadShaderUniforms=t.LayaGLRunner.uploadShaderUniformsForNative),t.Render.supportWebGLPlusCulling&&(a.renderObjectCulling=Ge.renderObjectCullingNative),t.Render.supportWebGLPlusAnimation){n.prototype._cloneDatasToAnimator=n.prototype._cloneDatasToAnimatorNative;var s=Z;s.prototype._evaluateClipDatasRealTime=s.prototype._evaluateClipDatasRealTimeForNative,i.prototype._computeSkinnedData=i.prototype._computeSkinnedDataForNative}}static formatRelativePath(e,t){var r;if(r=e+t,"."===t.charAt(0)){for(var i=r.split("/"),n=0,a=i.length;n0&&".."!==i[s]&&(i.splice(s,2),n-=2)}r=i.join("/")}return r}static _endLoad(e,r=null,i=null){if(i)for(var n=0,a=i.length;n0){var m=c/d,f=t.Handler.create(null,yi._onProcessChange,[e,u,m],!1);yi._innerFourthLevelLoaderManager._create(_,!1,t.Handler.create(null,yi._onHierarchyInnerForthLevResouLoaded,[e,f,r,h,s,o,l,u+m*_.length,m]),f,null,null,null,1,!0)}else yi._onHierarchyInnerForthLevResouLoaded(e,null,r,h,s,o,l,u,m)}static _onHierarchyInnerForthLevResouLoaded(e,r,i,n,a,s,o,l,_){if(r&&r.recover(),o.length>0){var h=t.Handler.create(null,yi._onProcessChange,[e,l,_],!1);yi._innerThirdLevelLoaderManager._create(o,!1,t.Handler.create(null,yi._onHierarchyInnerThirdLevResouLoaded,[e,h,i,n,a,s,l+_*s.length,_]),r,null,null,null,1,!0)}else yi._onHierarchyInnerThirdLevResouLoaded(e,null,i,n,a,s,l,_)}static _onHierarchyInnerThirdLevResouLoaded(e,r,i,n,a,s,o,l){if(r&&r.recover(),s.length>0){var _=t.Handler.create(null,yi._onProcessChange,[e,o,l],!1);yi._innerSecondLevelLoaderManager._create(s,!1,t.Handler.create(null,yi._onHierarchyInnerSecondLevResouLoaded,[e,_,i,n,a,o+l*s.length,l]),r,null,null,null,1,!0)}else yi._onHierarchyInnerSecondLevResouLoaded(e,null,i,n,a,o,l)}static _onHierarchyInnerSecondLevResouLoaded(e,r,i,n,a,s,o){if(r&&r.recover(),a.length>0){var l=t.Handler.create(null,yi._onProcessChange,[e,s,o],!1);yi._innerFirstLevelLoaderManager._create(a,!1,t.Handler.create(null,yi._onHierarchyInnerFirstLevResouLoaded,[e,l,i,n]),r,null,null,null,1,!0)}else yi._onHierarchyInnerFirstLevResouLoaded(e,null,i,n)}static _onHierarchyInnerFirstLevResouLoaded(e,t,r,i){t&&t.recover(),e._cache=e._createCache;var n="Scene3D"===r.data.type?Ri._parseScene(r,e._propertyParams,e._constructParams):Ri._parse(r,e._propertyParams,e._constructParams);yi._endLoad(e,n,i)}static _loadMesh(e){e.on(t.Event.LOADED,null,yi._onMeshLmLoaded,[e]),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _onMeshLmLoaded(e,t){e._cache=e._createCache;var r=Ii._parse(t,e._propertyParams,e._constructParams);yi._endLoad(e,r)}static _loadMaterial(e){e.on(t.Event.LOADED,null,yi._onMaterilLmatLoaded,[e]),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _onMaterilLmatLoaded(e,r){var i,n=e.url,a=N.getURLVerion(n),s=t.URL.getPath(n),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 E=t.Handler.create(null,yi._onProcessChange,[e,T,m/f],!1);yi._innerFourthLevelLoaderManager._create(o,!1,t.Handler.create(null,yi._onMateialTexturesLoaded,[e,E,r,l]),E,null,null,null,1,!0)}else yi._onMateialTexturesLoaded(e,null,r,null)}static _onMateialTexturesLoaded(e,t,r,i){e._cache=e._createCache;var n=Te._parse(r,e._propertyParams,e._constructParams);yi._endLoad(e,n,i),t&&t.recover()}static _loadAvatar(e){e.on(t.Event.LOADED,null,(function(t){e._cache=e._createCache;var r=fe._parse(t,e._propertyParams,e._constructParams);yi._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=Z._parse(t,e._propertyParams,e._constructParams);yi._endLoad(e,r)})),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _loadTexture2D(e){var r,i=e.url,n=i.lastIndexOf(".")+1,a=i.indexOf("?"),s=-1==a?i.length:a;switch(i.substr(n,s-n)){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);yi._endLoad(e,i)})),e.load(e.url,r,!1,null,!0)}static _loadTextureCube(e){e.on(t.Event.LOADED,null,yi._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 n=i.readUint8(),a=i.getUint8(),s=i.readUint16(),o=i.getUint8(),l=i.getUint8(),_=i.getUint8(),h=i.getUint8(),c=new Lt(s,n,a>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);a=Math.log2(c)+this._diffusion-10;var d=Math.floor(a),u=Math.min(Math.max(d,1),wi.MAXPYRAMIDSIZE),m=.5+a-d;this._shaderData.setNumber(wi.SHADERVALUE_SAMPLESCALE,m);var f=Be.gammaToLinearSpace(this.threshold),T=f*this._softKnee+1e-5;this._shaderThreshold.setValue(f,f-T,2*T,.25/T),this._shaderData.setVector(wi.SHADERVALUE_THRESHOLD,this._shaderThreshold);var E=Be.gammaToLinearSpace(this.clamp);this._shaderParams.setValue(E,0,0,0),this._shaderData.setVector(wi.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],x=this._pyramid[v],r.setShaderDataTexture(this._shaderData,wi.SHADERVALUE_BLOOMTEX,I),r.blitScreenTriangle(L,x,null,this._shader,this._shaderData,wi.SUBSHADER_UPSAMPLETENT+p),L=x;var D=this._linearColor;this.color.toLinear(D);var C=Math.pow(2,this._intensity/10)-1,y=this._shaderSetting;this._shaderSetting.setValue(m,C,this._dirtIntensity,u);var M=this.dirtTexture?this.dirtTexture:t.Texture2D.blackTexture,O=M.width/M.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),a=r+e+(n/2>>>31)>>>0,s=n>>>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,[a,s]}random(){var e=this.randomint(),t=e[0],r=1023<<20|t>>>12,i=0|(e[1]>>>12|(4095&t)<<20);return Vi._CONVERTION_BUFFER.setUint32(0,r,!1),Vi._CONVERTION_BUFFER.setUint32(4,i,!1),Vi._CONVERTION_BUFFER.getFloat64(0,!1)-1}}Vi._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8)),Vi.defaultRand=new Vi([0,Date.now()/65536,0,Date.now()%65536]);class Bi{constructor(e,t){this._width=0,this._height=0,this._width=e,this._height=t}static get fullScreen(){return new Bi(-1,-1)}get width(){return-1===this._width?ne.clientWidth:this._width}get height(){return-1===this._height?ne.clientHeight:this._height}}e.AlternateLightQueue=Ct,e.AnimationClip=Z,e.AnimationClipParser03=k,e.AnimationClipParser04=Y,e.AnimationEvent=U,e.AnimationNode=me,e.AnimationTransform3D=ue,e.Animator=re,e.AnimatorControllerLayer=Q,e.AnimatorPlayState=q,e.AnimatorState=ee,e.AnimatorStateScript=class{constructor(){}onStateEnter(){}onStateUpdate(){}onStateExit(){}},e.Avatar=fe,e.BaseCamera=ht,e.BaseMaterial=Ee,e.BaseRender=Wt,e.BaseShape=Or,e.BatchMark=Vt,e.BlinnPhongMaterial=ge,e.BlitScreenQuadCMD=mt,e.BloomEffect=wi,e.BoundBox=Mt,e.BoundFrustum=Qe,e.BoundSphere=Kt,e.Bounds=Ot,e.BoundsOctree=qt,e.BoundsOctreeNode=jt,e.BoxColliderShape=E,e.BoxShape=br,e.BufferState=$e,e.BulletInteractive=hi,e.Burst=Rr,e.Camera=Rt,e.CameraCullInfo=Fe,e.CapsuleColliderShape=p,e.CastShadowList=class extends I{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=b,e.CircleShape=Pr,e.Cluster=He,e.ColliderShape=d,e.Collision=C,e.CollisionTool=y,e.CollisionUtils=qe,e.Color=Be,e.ColorOverLifetime=Ar,e.Command=ut,e.CommandBuffer=Et,e.CompoundColliderShape=m,e.ConchQuaternion=$,e.ConchVector3=J,e.ConchVector4=K,e.ConeColliderShape=g,e.ConeShape=wr,e.Config3D=B,e.ConfigurableConstraint=Ci,e.Constraint3D=class{constructor(){}},e.ConstraintComponent=Li,e.ContactPoint=L,e.ContainmentType=Ze,e.CylinderColliderShape=S,e.DefineDatas=se,e.DirectionLight=pi,e.DynamicBatchManager=tr,e.EffectMaterial=Se,e.Emission=qr,e.ExtendTerrainMaterial=Re,e.FixedConstraint=Di,e.FloatKeyframe=z,e.FrameOverTime=Ir,e.FrustumCulling=Ge,e.GeometryElement=Nt,e.Gradient=Sr,e.GradientAngularVelocity=xr,e.GradientColor=vr,e.GradientDataInt=Lr,e.GradientDataNumber=Dr,e.GradientDataVector2=bi,e.GradientMode=gr,e.GradientSize=Cr,e.GradientVelocity=yr,e.HalfFloatUtils=X,e.HeightMap=Oi,e.HeightfieldColliderShape=class{constructor(){}},e.HemisphereShape=Vr,e.HitResult=D,e.ILaya3D=_,e.IndexBuffer3D=et,e.Input3D=vt,e.Keyframe=G,e.KeyframeNode=F,e.KeyframeNodeList=j,e.KeyframeNodeOwner=te,e.Laya3D=yi,e.LightQueue=Dt,e.LightSprite=gt,e.Lightmap=Qt,e.LoadModelV04=vi,e.LoadModelV05=Ai,e.Material=Te,e.MathUtils3D=r,e.Matrix3x3=l,e.Matrix4x4=c,e.Mesh=mi,e.MeshColliderShape=R,e.MeshFilter=fr,e.MeshReader=Ii,e.MeshRenderDynamicBatchManager=Er,e.MeshRenderStaticBatchManager=Ht,e.MeshRenderer=mr,e.MeshSprite3D=pr,e.MeshSprite3DShaderDeclaration=ur,e.MeshTerrainSprite3D=Ni,e.MouseTouch=ke,e.OctreeMotionList=Zt,e.PBRMaterial=ve,e.PBRSpecularMaterial=ar,e.PBRStandardMaterial=lr,e.Physics3D=V,e.Physics3DUtils=T,e.PhysicsCollider=ci,e.PhysicsComponent=A,e.PhysicsSettings=At,e.PhysicsSimulation=M,e.PhysicsTriggerComponent=P,e.PhysicsUpdateList=x,e.Picker=Je,e.PixelLineData=class{constructor(){this.startPosition=new a,this.endPosition=new a,this.startColor=new Be,this.endColor=new Be}cloneTo(e){this.startPosition.cloneTo(e.startPosition),this.endPosition.cloneTo(e.endPosition),this.startColor.cloneTo(e.startColor),this.endColor.cloneTo(e.endColor)}},e.PixelLineFilter=Pt,e.PixelLineMaterial=yt,e.PixelLineRenderer=kt,e.PixelLineSprite3D=Xt,e.PixelLineVertex=bt,e.Plane=Ye,e.Point2PointConstraint=class{constructor(){this._pivotInA=new a,this._pivotInB=new a}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=gi,e.PostProcess=de,e.PostProcessEffect=Pi,e.PostProcessRenderContext=ie,e.PrimitiveMesh=fi,e.Quaternion=h,e.QuaternionKeyframe=H,e.Rand=Zr,e.RandX=Vi,e.Ray=je,e.RenderContext3D=ne,e.RenderElement=Ft,e.RenderQueue=Yt,e.RenderState=pe,e.RenderTexture=ae,e.RenderableSprite3D=wt,e.Rigidbody3D=w,e.RotationOverLifetime=Mr,e.Scene3D=rr,e.Scene3DShaderDeclaration=pt,e.Scene3DUtils=Ri,e.SceneManager=class{constructor(){}},e.ScreenQuad=ct,e.ScreenTriangle=dt,e.Script3D=Mi,e.SetRenderTargetCMD=ft,e.SetShaderDataTextureCMD=Tt,e.Shader3D=he,e.ShaderData=ce,e.ShaderDefine=oe,e.ShaderInit3D=Ei,e.ShaderInstance=we,e.ShaderPass=ir,e.ShaderVariable=Pe,e.ShaderVariant=le,e.ShaderVariantCollection=_e,e.ShadowCasterPass=er,e.ShadowCullInfo=Ue,e.ShadowSliceData=Jt,e.ShadowSpotData=$t,e.ShadowUtils=St,e.ShapeUtils=Nr,e.ShuriKenParticle3D=Jr,e.ShuriKenParticle3DShaderDeclaration=Hr,e.ShurikenParticleData=Qr,e.ShurikenParticleMaterial=Wr,e.ShurikenParticleRenderer=kr,e.ShurikenParticleSystem=Kr,e.SimpleSingletonList=Ve,e.SingletonList=I,e.Size=Bi,e.SizeOverLifetime=Fr,e.SkinnedMeshRenderer=ei,e.SkinnedMeshSprite3D=ti,e.SkinnedMeshSprite3DShaderDeclaration=$r,e.SkyBox=ot,e.SkyBoxMaterial=_r,e.SkyDome=xt,e.SkyMesh=st,e.SkyPanoramicMaterial=xi,e.SkyProceduralMaterial=hr,e.SkyRenderer=lt,e.SphereColliderShape=v,e.SphereShape=Br,e.SphericalHarmonicsL2=We,e.SpotLight=Si,e.Sprite3D=_t,e.StartFrame=Ur,e.StaticBatchManager=Gt,e.StaticPlaneColliderShape=u,e.SubMesh=di,e.SubMeshDynamicBatch=Tr,e.SubMeshInstanceBatch=Bt,e.SubMeshRenderElement=Ut,e.SubMeshStaticBatch=zt,e.SubShader=nr,e.TextMesh=class{constructor(){}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}_createVertexBuffer(e){}_resizeVertexBuffer(e){}_addChar(){}},e.TextureCube=Lt,e.TextureGenerator=O,e.TextureMode=ii,e.TextureSheetAnimation=Gr,e.Touch=Xe,e.TrailFilter=si,e.TrailGeometry=ai,e.TrailMaterial=ri,e.TrailRenderer=oi,e.TrailSprite3D=li,e.Transform3D=f,e.UnlitMaterial=cr,e.Utils3D=N,e.Vector2=i,e.Vector3=a,e.Vector3Keyframe=W,e.Vector4=n,e.VelocityOverLifetime=zr,e.VertexBuffer3D=at,e.VertexDeclaration=rt,e.VertexElement=it,e.VertexElementFormat=tt,e.VertexMesh=nt,e.VertexPositionTerrain=_i,e.VertexPositionTexture0=It,e.VertexShuriKenParticle=Xr,e.VertexShurikenParticleBillboard=Yr,e.VertexShurikenParticleMesh=jr,e.VertexTrail=ni,e.Viewport=Ke,e.WaterPrimaryMaterial=dr,e.skinnedMatrixCache=ui}(window.Laya=window.Laya||{},Laya);