!function(e,t){"use strict";class r{constructor(){}static isZero(e){return Math.abs(e)0&&(a=1/Math.sqrt(a),t.x=r*a,t.y=i*a)}static scalarLength(e){var t=e.x,r=e.y;return Math.sqrt(t*t+r*r)}clone(){var e=new i;return this.cloneTo(e),e}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y):this.elements=new Float32Array([this.x,this.y]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1)}static rewriteNumProperty(e,t,r){Object.defineProperty(e,t,{get:function(){return this.elements[r]},set:function(e){this.elements[r]=e}})}}i.ZERO=new i(0,0),i.ONE=new i(1,1);class a{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.z=r,this.w=i}setValue(e,t,r,i){this.x=e,this.y=t,this.z=r,this.w=i}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]}cloneTo(e){var t=e;t.x=this.x,t.y=this.y,t.z=this.z,t.w=this.w}clone(){var e=new a;return this.cloneTo(e),e}static lerp(e,t,r,i){var a=e.x,n=e.y,s=e.z,o=e.w;i.x=a+r*(t.x-a),i.y=n+r*(t.y-n),i.z=s+r*(t.z-s),i.w=o+r*(t.w-o)}static transformByM4x4(e,t,r){var i=e.x,a=e.y,n=e.z,s=e.w,o=t.elements;r.x=i*o[0]+a*o[4]+n*o[8]+s*o[12],r.y=i*o[1]+a*o[5]+n*o[9]+s*o[13],r.z=i*o[2]+a*o[6]+n*o[10]+s*o[14],r.w=i*o[3]+a*o[7]+n*o[11]+s*o[15]}static equals(e,t){return r.nearEqual(Math.abs(e.x),Math.abs(t.x))&&r.nearEqual(Math.abs(e.y),Math.abs(t.y))&&r.nearEqual(Math.abs(e.z),Math.abs(t.z))&&r.nearEqual(Math.abs(e.w),Math.abs(t.w))}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static normalize(e,t){var r=e.length();if(r>0){var i=1/r;t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i}}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z,r.w=e.w-t.w}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z,r.w=e.w*t.w}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w*t}static Clamp(e,t,r,i){var a=e.x,n=e.y,s=e.z,o=e.w,l=t.x,_=t.y,h=t.z,c=t.w,d=r.x,u=r.y,m=r.z,f=r.w;a=(a=a>d?d:a)u?u:n)<_?_:n,s=(s=s>m?m:s)f?f:o)0&&(n=1/Math.sqrt(n),t.x=r*n,t.y=i*n,t.z=a*n)}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t}static lerp(e,t,r,i){var a=e.x,n=e.y,s=e.z;i.x=a+r*(t.x-a),i.y=n+r*(t.y-n),i.z=s+r*(t.z-s)}static transformV3ToV3(e,t,r){var i=n._tempVector4;n.transformV3ToV4(e,t,i),r.x=i.x,r.y=i.y,r.z=i.z}static transformV3ToV4(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.elements;r.x=i*s[0]+a*s[4]+n*s[8]+s[12],r.y=i*s[1]+a*s[5]+n*s[9]+s[13],r.z=i*s[2]+a*s[6]+n*s[10]+s[14],r.w=i*s[3]+a*s[7]+n*s[11]+s[15]}static TransformNormal(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.elements;r.x=i*s[0]+a*s[4]+n*s[8],r.y=i*s[1]+a*s[5]+n*s[9],r.z=i*s[2]+a*s[6]+n*s[10]}static transformCoordinate(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.elements,o=i*s[3]+a*s[7]+n*s[11]+s[15];r.x=(i*s[0]+a*s[4]+n*s[8]+s[12])/o,r.y=(i*s[1]+a*s[5]+n*s[9]+s[13])/o,r.z=(i*s[2]+a*s[6]+n*s[10]+s[14])/o}static Clamp(e,t,r,i){var a=e.x,n=e.y,s=e.z,o=t.x,l=t.y,_=t.z,h=r.x,c=r.y,d=r.z;a=(a=a>h?h:a)c?c:n)d?d:s)<_?_:s,i.x=a,i.y=n,i.z=s}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z}static cross(e,t,r){var i=e.x,a=e.y,n=e.z,s=t.x,o=t.y,l=t.z;r.x=a*l-n*o,r.y=n*s-i*l,r.z=i*o-a*s}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}static equals(e,t){return r.nearEqual(e.x,t.x)&&r.nearEqual(e.y,t.y)&&r.nearEqual(e.z,t.z)}setValue(e,t,r){this.x=e,this.y=t,this.z=r}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2]}cloneTo(e){var t=e;t.x=this.x,t.y=this.y,t.z=this.z}clone(){var e=new n;return this.cloneTo(e),e}toDefault(){this.x=0,this.y=0,this.z=0}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y,this.elements[2]=this.z):this.elements=new Float32Array([this.x,this.y,this.z]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1),i.rewriteNumProperty(this,"z",2)}}var s,o,l,_,h,c,d,u,m,f,T,E;n._tempVector4=new a,n._ZERO=new n(0,0,0),n._ONE=new n(1,1,1),n._NegativeUnitX=new n(-1,0,0),n._UnitX=new n(1,0,0),n._UnitY=new n(0,1,0),n._UnitZ=new n(0,0,1),n._ForwardRH=new n(0,0,-1),n._ForwardLH=new n(0,0,1),n._Up=new n(0,1,0),(s=e.PBRRenderQuality||(e.PBRRenderQuality={}))[s.High=0]="High",s[s.Low=1]="Low";class p{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,a=e.z,n=e.w,s=r*r,o=i*i,l=a*a,_=r*i,h=a*n,c=a*r,d=i*n,u=i*a,m=r*n,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),a=Math.cos(e);r[0]=a,r[1]=i,r[2]=0,r[3]=-i,r[4]=a,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,a=t.elements,n=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=a[0],T=a[1],E=a[2],p=a[3],g=a[4],S=a[5],R=a[6],v=a[7],x=a[8];n[0]=f*s+T*_+E*d,n[1]=f*o+T*h+E*v,n[2]=f*l+T*c+E*m,n[3]=p*s+g*_+S*d,n[4]=p*o+g*h+S*u,n[5]=p*l+g*c+S*m,n[6]=R*s+v*_+x*d,n[7]=R*o+v*h+x*u,n[8]=R*l+v*c+x*m}determinant(){var e=this.elements,t=e[0],r=e[1],i=e[2],a=e[3],n=e[4],s=e[5],o=e[6],l=e[7],_=e[8];return t*(_*n-s*l)+r*(-_*a+s*o)+i*(l*a-n*o)}translate(e,t){var r=t.elements,i=this.elements,a=i[0],n=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]=a,r[1]=n,r[2]=s,r[3]=o,r[4]=l,r[5]=_,r[6]=u*a+m*o+h,r[7]=u*n+m*l+c,r[8]=u*s+m*_+d}rotate(e,t){var r=t.elements,i=this.elements,a=i[0],n=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*a+u*o,r[1]=m*n+u*l,r[2]=m*s+u*_,r[3]=m*o-u*a,r[4]=m*l-u*n,r[5]=m*_-u*s,r[6]=h,r[7]=c,r[8]=d}scale(e,t){var r=t.elements,i=this.elements,a=e.x,n=e.y;r[0]=a*i[0],r[1]=a*i[1],r[2]=a*i[2],r[3]=n*i[3],r[4]=n*i[4],r[5]=n*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],a=r[1],n=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+a*u+n*m;f&&(f=1/f,t[0]=d*f,t[1]=(-c*a+n*h)*f,t[2]=(l*a-n*o)*f,t[3]=u*f,t[4]=(c*i-n*_)*f,t[5]=(-l*i+n*s)*f,t[6]=m*f,t[7]=(-h*i+a*_)*f,t[8]=(o*i-a*s)*f)}transpose(e){var t=e.elements,r=this.elements;if(e===this){var i=r[1],a=r[2],n=r[5];t[1]=r[3],t[2]=r[6],t[3]=i,t[5]=r[7],t[6]=a,t[7]=n}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 p;return this.cloneTo(e),e}static lookAt(e,t,r,i){n.subtract(e,t,p._tempV30),n.normalize(p._tempV30,p._tempV30),n.cross(r,p._tempV30,p._tempV31),n.normalize(p._tempV31,p._tempV31),n.cross(p._tempV30,p._tempV31,p._tempV32);var a=p._tempV30,s=p._tempV31,o=p._tempV32,l=i.elements;l[0]=s.x,l[3]=s.y,l[6]=s.z,l[1]=o.x,l[4]=o.y,l[7]=o.z,l[2]=a.x,l[5]=a.y,l[8]=a.z}}p.DEFAULT=new p,p._tempV30=new n,p._tempV31=new n,p._tempV32=new n;class g{}g.Shader3D=null,g.Scene3D=null,g.MeshRenderStaticBatchManager=null,g.MeshRenderDynamicBatchManager=null,g.SubMeshDynamicBatch=null,g.Laya3D=null,g.Matrix4x4=null,g.Physics3D=null,g.ShadowLightType=null;class S{constructor(e=0,t=0,r=0,i=1,a=null){this.x=e,this.y=t,this.z=r,this.w=i}static createFromYawPitchRoll(e,t,r,i){var a=.5*r,n=.5*t,s=.5*e,o=Math.sin(a),l=Math.cos(a),_=Math.sin(n),h=Math.cos(n),c=Math.sin(s),d=Math.cos(s);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,a=e.y,n=e.z,s=e.w,o=t.x,l=t.y,_=t.z,h=t.w,c=a*_-n*l,d=n*o-i*_,u=i*l-a*o,m=i*o+a*l+n*_;r.x=i*h+o*s+c,r.y=a*h+l*s+d,r.z=n*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){n.subtract(t,e,S.TEMPVector30),n.normalize(S.TEMPVector30,S.TEMPVector30),r.x=Math.asin(S.TEMPVector30.y),r.y=S.arcTanAngle(-S.TEMPVector30.z,-S.TEMPVector30.x)}static createFromAxisAngle(e,t,r){t*=.5;var i=Math.sin(t);r.x=i*e.x,r.y=i*e.y,r.z=i*e.z,r.w=Math.cos(t)}static createFromMatrix4x4(e,t){var r,i,a=e.elements,n=a[0]+a[5]+a[10];n>0?(r=Math.sqrt(n+1),t.w=.5*r,r=.5/r,t.x=(a[6]-a[9])*r,t.y=(a[8]-a[2])*r,t.z=(a[1]-a[4])*r):a[0]>=a[5]&&a[0]>=a[10]?(i=.5/(r=Math.sqrt(1+a[0]-a[5]-a[10])),t.x=.5*r,t.y=(a[1]+a[4])*i,t.z=(a[2]+a[8])*i,t.w=(a[6]-a[9])*i):a[5]>a[10]?(i=.5/(r=Math.sqrt(1+a[5]-a[0]-a[10])),t.x=(a[4]+a[1])*i,t.y=.5*r,t.z=(a[9]+a[6])*i,t.w=(a[8]-a[2])*i):(i=.5/(r=Math.sqrt(1+a[10]-a[0]-a[5])),t.x=(a[8]+a[2])*i,t.y=(a[9]+a[6])*i,t.z=.5*r,t.w=(a[1]-a[4])*i)}static slerp(e,t,r,i){var a,n,s,o,l,_=e.x,h=e.y,c=e.z,d=e.w,u=t.x,m=t.y,f=t.z,T=t.w;return(n=_*u+h*m+c*f+d*T)<0&&(n=-n,u=-u,m=-m,f=-f,T=-T),1-n>1e-6?(a=Math.acos(n),s=Math.sin(a),o=Math.sin((1-r)*a)/s,l=Math.sin(r*a)/s):(o=1-r,l=r),i.x=o*_+l*u,i.y=o*h+l*m,i.z=o*c+l*f,i.w=o*d+l*T,i}static lerp(e,t,r,i){var a=1-r;S.dot(e,t)>=0?(i.x=a*e.x+r*t.x,i.y=a*e.y+r*t.y,i.z=a*e.z+r*t.z,i.w=a*e.w+r*t.w):(i.x=a*e.x-r*t.x,i.y=a*e.y-r*t.y,i.z=a*e.z-r*t.z,i.w=a*e.w-r*t.w),i.normalize(i)}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}scaling(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e}normalize(e){var t=this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w;t>0&&(t=1/Math.sqrt(t),e.x=this.x*t,e.y=this.y*t,e.z=this.z*t,e.w=this.w*t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}rotateX(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.w*r,t.y=this.y*i+this.z*r,t.z=this.z*i-this.y*r,t.w=this.w*i-this.x*r}rotateY(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i-this.z*r,t.y=this.y*i+this.w*r,t.z=this.z*i+this.x*r,t.w=this.w*i-this.y*r}rotateZ(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.y*r,t.y=this.y*i-this.x*r,t.z=this.z*i+this.w*r,t.w=this.w*i-this.z*r}getYawPitchRoll(e){n.transformQuat(n._ForwardRH,this,S.TEMPVector31),n.transformQuat(n._Up,this,S.TEMPVector32);var t=S.TEMPVector32;S.angleTo(n._ZERO,S.TEMPVector31,S.TEMPVector33);var r=S.TEMPVector33;r.x==Math.PI/2?(r.y=S.arcTanAngle(t.z,t.x),r.z=0):r.x==-Math.PI/2?(r.y=S.arcTanAngle(-t.z,-t.x),r.z=0):(g.Matrix4x4.createRotationY(-r.y,g.Matrix4x4.TEMPMatrix0),g.Matrix4x4.createRotationX(-r.x,g.Matrix4x4.TEMPMatrix1),n.transformCoordinate(S.TEMPVector32,g.Matrix4x4.TEMPMatrix0,S.TEMPVector32),n.transformCoordinate(S.TEMPVector32,g.Matrix4x4.TEMPMatrix1,S.TEMPVector32),r.z=S.arcTanAngle(t.y,-t.x)),r.y<=-Math.PI&&(r.y=Math.PI),r.z<=-Math.PI&&(r.z=Math.PI),r.y>=Math.PI&&r.z>=Math.PI&&(r.y=0,r.z=0,r.x=Math.PI-r.x);var i=e;i.x=r.y,i.y=r.x,i.z=r.z}invert(e){var t=this.x,r=this.y,i=this.z,a=this.w,n=t*t+r*r+i*i+a*a,s=n?1/n:0;e.x=-t*s,e.y=-r*s,e.z=-i*s,e.w=a*s}identity(){this.x=0,this.y=0,this.z=0,this.w=1}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]}cloneTo(e){this!==e&&(e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w)}clone(){var e=new S;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){S.lookAt(n._ZERO,e,t,r)}static lookAt(e,t,r,i){p.lookAt(e,t,r,S._tempMatrix3x3),S.rotationMatrix(S._tempMatrix3x3,i)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static invert(e,t){var i=e.lengthSquared();r.isZero(i)||(i=1/i,t.x=-e.x*i,t.y=-e.y*i,t.z=-e.z*i,t.w=e.w*i)}static rotationMatrix(e,t){var r,i,a=e.elements,n=a[0],s=a[1],o=a[2],l=a[3],_=a[4],h=a[5],c=a[6],d=a[7],u=a[8],m=n+_+u;m>0?(r=Math.sqrt(m+1),t.w=.5*r,r=.5/r,t.x=(h-d)*r,t.y=(c-o)*r,t.z=(s-l)*r):n>=_&&n>=u?(i=.5/(r=Math.sqrt(1+n-_-u)),t.x=.5*r,t.y=(s+l)*i,t.z=(o+c)*i,t.w=(h-d)*i):_>u?(i=.5/(r=Math.sqrt(1+_-n-u)),t.x=(l+s)*i,t.y=.5*r,t.z=(d+h)*i,t.w=(c-o)*i):(i=.5/(r=Math.sqrt(1+u-n-_)),t.x=(c+o)*i,t.y=(d+h)*i,t.z=.5*r,t.w=(s-l)*i)}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y,this.elements[2]=this.z,this.elements[3]=this.w):this.elements=new Float32Array([this.x,this.y,this.z,this.w]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1),i.rewriteNumProperty(this,"z",2),i.rewriteNumProperty(this,"w",3)}}S.TEMPVector30=new n,S.TEMPVector31=new n,S.TEMPVector32=new n,S.TEMPVector33=new n,S._tempMatrix3x3=new p,S.DEFAULT=new S,S.NAN=new S(NaN,NaN,NaN,NaN);class R{constructor(e=1,t=0,r=0,i=0,a=0,n=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]=a,E[5]=n,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),a=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]=a,r[6]=i,r[9]=-i}static createRotationY(e,t){var r=t.elements,i=Math.sin(e),a=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]=a,r[2]=-i,r[8]=i}static createRotationZ(e,t){var r=t.elements,i=Math.sin(e),a=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]=a,r[1]=i,r[4]=-i}static createRotationYawPitchRoll(e,t,r,i){S.createFromYawPitchRoll(e,t,r,R._tempQuaternion),R.createRotationQuaternion(R._tempQuaternion,i)}static createRotationAxis(e,t,r){var i=e.x,a=e.y,n=e.z,s=Math.cos(t),o=Math.sin(t),l=i*i,_=a*a,h=n*n,c=i*a,d=i*n,u=a*n,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*n,m[2]=d-s*d-o*a,m[4]=c-s*c-o*n,m[5]=_+s*(1-_),m[6]=u-s*u+o*i,m[8]=d-s*d+o*a,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,a=e.w,n=t*t,s=r*r,o=i*i,l=t*r,_=i*a,h=i*t,c=r*a,d=r*i,u=t*a,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+n),m[6]=2*(d+u),m[8]=2*(h+c),m[9]=2*(d-u),m[10]=1-2*(s+n)}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,a=e.y,n=e.z,s=e.w,o=i*i,l=a*a,_=n*n,h=i*a,c=n*s,d=n*i,u=a*s,m=a*n,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,a=e.elements,n=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=a[0],x=a[1],A=a[2],I=a[3],D=a[4],M=a[5],C=a[6],y=a[7],L=a[8],O=a[9],N=a[10],P=a[11],b=a[12],w=a[13],V=a[14],B=a[15];n[0]=s*v+o*D+l*L+_*b,n[1]=s*x+o*M+l*O+_*w,n[2]=s*A+o*C+l*N+_*V,n[3]=s*I+o*y+l*P+_*B,n[4]=h*v+c*D+d*L+u*b,n[5]=h*x+c*M+d*O+u*w,n[6]=h*A+c*C+d*N+u*V,n[7]=h*I+c*y+d*P+u*B,n[8]=m*v+f*D+T*L+E*b,n[9]=m*x+f*M+T*O+E*w,n[10]=m*A+f*C+T*N+E*V,n[11]=m*I+f*y+T*P+E*B,n[12]=p*v+g*D+S*L+R*b,n[13]=p*x+g*M+S*O+R*w,n[14]=p*A+g*C+S*N+R*V,n[15]=p*I+g*y+S*P+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,a=e.y,n=e.z,s=e.w,o=i+i,l=a+a,_=n+n,h=i*o,c=a*o,d=a*l,u=n*o,m=n*l,f=n*_,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 a=i.elements,n=t.x,s=t.y,o=t.z,l=t.w,_=n+n,h=s+s,c=o+o,d=n*_,u=n*h,m=n*c,f=s*h,T=s*c,E=o*c,p=l*_,g=l*h,S=l*c,R=r.x,v=r.y,x=r.z;a[0]=(1-(f+E))*R,a[1]=(u+S)*R,a[2]=(m-g)*R,a[3]=0,a[4]=(u-S)*v,a[5]=(1-(d+E))*v,a[6]=(T+p)*v,a[7]=0,a[8]=(m+g)*x,a[9]=(T-p)*x,a[10]=(1-(d+f))*x,a[11]=0,a[12]=e.x,a[13]=e.y,a[14]=e.z,a[15]=1}static createLookAt(e,t,r,i){var a=i.elements,s=R._tempVector0,o=R._tempVector1,l=R._tempVector2;n.subtract(e,t,l),n.normalize(l,l),n.cross(r,l,s),n.normalize(s,s),n.cross(l,s,o),a[3]=a[7]=a[11]=0,a[15]=1,a[0]=s.x,a[4]=s.y,a[8]=s.z,a[1]=o.x,a[5]=o.y,a[9]=o.z,a[2]=l.x,a[6]=l.y,a[10]=l.z,a[12]=-n.dot(s,e),a[13]=-n.dot(o,e),a[14]=-n.dot(l,e)}static createPerspective(e,t,r,i,a){var n=1/Math.tan(.5*e),s=r/(n/t),o=r/n;R.createPerspectiveOffCenter(-s,s,-o,o,r,i,a)}static createPerspectiveOffCenter(e,t,r,i,a,n,s){var o=s.elements,l=n/(n-a);o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[12]=o[13]=o[15]=0,o[0]=2*a/(t-e),o[5]=2*a/(i-r),o[8]=(e+t)/(t-e),o[9]=(i+r)/(i-r),o[10]=-l,o[11]=-1,o[14]=-a*l}static createOrthoOffCenter(e,t,r,i,a,n,s){var o=s.elements,l=1/(n-a);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]=-a*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=R._tempMatrix4x4;return this.decomposeTransRotMatScale(e,i,r)?(S.createFromMatrix4x4(i,t),!0):(t.identity(),!1)}decomposeTransRotMatScale(e,t,i){var a=this.elements,s=e,o=t.elements,l=i;s.x=a[12],s.y=a[13],s.z=a[14];var _=a[0],h=a[1],c=a[2],d=a[4],u=a[5],m=a[6],f=a[8],T=a[9],E=a[10],p=l.x=Math.sqrt(_*_+h*h+c*c),g=l.y=Math.sqrt(d*d+u*u+m*m),S=l.z=Math.sqrt(f*f+T*T+E*E);if(r.isZero(p)||r.isZero(g)||r.isZero(S))return o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[8]=o[9]=o[11]=o[12]=o[13]=o[14]=0,o[0]=o[5]=o[10]=o[15]=1,!1;var v=R._tempVector0;v.x=f/S,v.y=T/S,v.z=E/S;var x=R._tempVector1;x.x=_/p,x.y=h/p,x.z=c/p;var A=R._tempVector2;n.cross(v,x,A);var I=R._tempVector1;return n.cross(A,v,I),o[3]=o[7]=o[11]=o[12]=o[13]=o[14]=0,o[15]=1,o[0]=I.x,o[1]=I.y,o[2]=I.z,o[4]=A.x,o[5]=A.y,o[6]=A.z,o[8]=v.x,o[9]=v.y,o[10]=v.z,o[0]*_+o[1]*h+o[2]*c<0&&(l.x=-p),o[4]*d+o[5]*u+o[6]*m<0&&(l.y=-g),o[8]*f+o[9]*T+o[10]*E<0&&(l.z=-S),!0}decomposeYawPitchRoll(e){var t=Math.asin(-this.elements[9]);e.y=t,Math.cos(t)>r.zeroTolerance?(e.z=Math.atan2(this.elements[1],this.elements[5]),e.x=Math.atan2(this.elements[8],this.elements[10])):(e.z=Math.atan2(-this.elements[4],this.elements[0]),e.x=0)}normalize(){var e=this.elements,t=e[0],r=e[1],i=e[2],a=Math.sqrt(t*t+r*r+i*i);if(!a)return e[0]=0,e[1]=0,void(e[2]=0);1!=a&&(a=1/a,e[0]=t*a,e[1]=r*a,e[2]=i*a)}transpose(){var e,t;return t=(e=this.elements)[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}invert(e){var t=this.elements,r=e.elements,i=t[0],a=t[1],n=t[2],s=t[3],o=t[4],l=t[5],_=t[6],h=t[7],c=t[8],d=t[9],u=t[10],m=t[11],f=t[12],T=t[13],E=t[14],p=t[15],g=i*l-a*o,S=i*_-n*o,R=i*h-s*o,v=a*_-n*l,x=a*h-s*l,A=n*h-s*_,I=c*T-d*f,D=c*E-u*f,M=c*p-m*f,C=d*E-u*T,y=d*p-m*T,L=u*p-m*E,O=g*L-S*y+R*C+v*M-x*D+A*I;0!==Math.abs(O)&&(O=1/O,r[0]=(l*L-_*y+h*C)*O,r[1]=(n*y-a*L-s*C)*O,r[2]=(T*A-E*x+p*v)*O,r[3]=(u*x-d*A-m*v)*O,r[4]=(_*M-o*L-h*D)*O,r[5]=(i*L-n*M+s*D)*O,r[6]=(E*R-f*A-p*S)*O,r[7]=(c*A-u*R+m*S)*O,r[8]=(o*y-l*M+h*I)*O,r[9]=(a*M-i*y-s*I)*O,r[10]=(f*x-T*R+p*g)*O,r[11]=(d*R-c*x-m*g)*O,r[12]=(l*D-o*C-_*I)*O,r[13]=(i*C-a*D+n*I)*O,r[14]=(T*S-f*v-E*g)*O,r[15]=(c*v-d*S+u*g)*O)}static billboard(e,t,i,a,s,o){n.subtract(e,t,R._tempVector0);var l=n.scalarLengthSquared(R._tempVector0);r.isZero(l)?(n.scale(s,-1,R._tempVector1),R._tempVector1.cloneTo(R._tempVector0)):n.scale(R._tempVector0,1/Math.sqrt(l),R._tempVector0),n.cross(a,R._tempVector0,R._tempVector2),n.normalize(R._tempVector2,R._tempVector2),n.cross(R._tempVector0,R._tempVector2,R._tempVector3);var _=R._tempVector2,h=R._tempVector3,c=R._tempVector0,d=e,u=o.elements;u[0]=_.x,u[1]=_.y,u[2]=_.z,u[3]=0,u[4]=h.x,u[5]=h.y,u[6]=h.z,u[7]=0,u[8]=c.x,u[9]=c.y,u[10]=c.z,u[11]=0,u[12]=d.x,u[13]=d.y,u[14]=d.z,u[15]=1}identity(){var e=this.elements;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1}cloneTo(e){var t,r,i;if((r=this.elements)!==(i=e.elements))for(t=0;t<16;++t)i[t]=r[t]}clone(){var e=new R;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}getInvertFront(){this.decomposeTransRotScale(R._tempVector0,R._tempQuaternion,R._tempVector1);var e=R._tempVector1,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t}}R._tempMatrix4x4=new R,R.TEMPMatrix0=new R,R.TEMPMatrix1=new R,R._tempVector0=new n,R._tempVector1=new n,R._tempVector2=new n,R._tempVector3=new n,R._tempQuaternion=new S,R.DEFAULT=new R,R.ZERO=new R(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);class v{constructor(){this._scale=new n(1,1,1),this._centerMatrix=new R,this._attatched=!1,this._indexInCompound=-1,this._compoundParent=null,this._attatchedCollisionObject=null,this._referenceCount=0,this._localOffset=new n(0,0,0),this._localRotation=new S(0,0,0,1),this.needsCustomCollisionCallback=!1}static __init__(){var e=g.Physics3D._bullet;v._btScale=e.btVector3_create(1,1,1),v._btVector30=e.btVector3_create(0,0,0),v._btQuaternion0=e.btQuaternion_create(0,0,0,1),v._btTransform0=e.btTransform_create()}static _createAffineTransformation(e,t,r){var i=t.x,a=t.y,n=t.z,s=t.w,o=i+i,l=a+a,_=n+n,h=i*o,c=i*l,d=i*_,u=a*l,m=a*_,f=n*_,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=g.Physics3D._bullet;t.btVector3_setValue(v._btScale,e.x,e.y,e.z),t.btCollisionShape_setLocalScaling(this._btShape,v._btScale)}}_addReference(){this._referenceCount++}_removeReference(){this._referenceCount--}updateLocalTransformations(){if(this._compoundParent){var e=v._tempVector30;n.multiply(this.localOffset,this._scale,e),v._createAffineTransformation(e,this.localRotation,this._centerMatrix.elements)}else v._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&&(g.Physics3D._bullet.btCollisionShape_destroy(this._btShape),this._btShape=null)}}v.SHAPEORIENTATION_UPX=0,v.SHAPEORIENTATION_UPY=1,v.SHAPEORIENTATION_UPZ=2,v.SHAPETYPES_BOX=0,v.SHAPETYPES_SPHERE=1,v.SHAPETYPES_CYLINDER=2,v.SHAPETYPES_CAPSULE=3,v.SHAPETYPES_CONVEXHULL=4,v.SHAPETYPES_COMPOUND=5,v.SHAPETYPES_STATICPLANE=6,v.SHAPETYPES_CONE=7,v._tempVector30=new n;class x extends v{constructor(e,t){super(),this._normal=e,this._offset=t,this._type=v.SHAPETYPES_STATICPLANE;var r=g.Physics3D._bullet;r.btVector3_setValue(x._btNormal,-e.x,e.y,e.z),this._btShape=r.btStaticPlaneShape_create(x._btNormal,t)}static __init__(){x._btNormal=g.Physics3D._bullet.btVector3_create(0,0,0)}clone(){var e=new x(this._normal,this._offset);return this.cloneTo(e),e}}class A extends v{constructor(){super(),this._childColliderShapes=[],this._type=v.SHAPETYPES_COMPOUND,this._btShape=g.Physics3D._bullet.btCompoundShape_create()}static __init__(){var e=g.Physics3D._bullet;A._btVector3One=e.btVector3_create(1,1,1),A._btTransform=e.btTransform_create(),A._btOffset=e.btVector3_create(0,0,0),A._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=g.Physics3D._bullet,r=e.localOffset,i=e.localRotation,a=v._btVector30,n=v._btQuaternion0,s=v._btTransform0;t.btVector3_setValue(a,-r.x,r.y,r.z),t.btQuaternion_setValue(n,-i.x,i.y,i.z,-i.w),t.btTransform_setOrigin(s,a),t.btTransform_setRotation(s,n),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=g.Physics3D._bullet;i.btVector3_setValue(A._btOffset,-t.x,t.y,t.z),i.btQuaternion_setValue(A._btRotation,-r.x,r.y,r.z,-r.w),i.btTransform_setOrigin(A._btTransform,A._btOffset),i.btTransform_setRotation(A._btTransform,A._btRotation);var a=i.btCollisionShape_getLocalScaling(this._btShape);i.btCollisionShape_setLocalScaling(this._btShape,A._btVector3One),i.btCompoundShape_addChildShape(this._btShape,A._btTransform,e._btShape),i.btCollisionShape_setLocalScaling(this._btShape,a),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(),g.Physics3D._bullet.btCompoundShape_removeChildShapeByIndex(this._btShape,t)}}clearChildShape(){for(var e=0,t=this._childColliderShapes.length;e0&&r.btCollisionObject_setCollisionFlags(t,i^P.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){!P._addUpdateList&&this._controlBySimulation||(e&=I.TRANSFORM_WORLDPOSITION|I.TRANSFORM_WORLDQUATERNION|I.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())}}P.ACTIVATIONSTATE_ACTIVE_TAG=1,P.ACTIVATIONSTATE_ISLAND_SLEEPING=2,P.ACTIVATIONSTATE_WANTS_DEACTIVATION=3,P.ACTIVATIONSTATE_DISABLE_DEACTIVATION=4,P.ACTIVATIONSTATE_DISABLE_SIMULATION=5,P.COLLISIONFLAGS_STATIC_OBJECT=1,P.COLLISIONFLAGS_KINEMATIC_OBJECT=2,P.COLLISIONFLAGS_NO_CONTACT_RESPONSE=4,P.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK=8,P.COLLISIONFLAGS_CHARACTER_OBJECT=16,P.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT=32,P.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING=64,P._tempVector30=new n,P._tempQuaternion0=new S,P._tempQuaternion1=new S,P._tempMatrix4x40=new R,P._physicObjectsMap={},P._addUpdateList=!0;class b{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 w extends b{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 V{constructor(){this._idCounter=0,this.colliderA=null,this.colliderB=null,this.distance=0,this.normal=new n,this.positionOnA=new n,this.positionOnB=new n,this._id=++this._idCounter}}class B{constructor(){this.succeeded=!1,this.collider=null,this.point=new n,this.normal=new n,this.hitFraction=0}}class F{constructor(){this._lastUpdateFrame=-2147483648,this._updateFrame=-2147483648,this._isTrigger=!1,this.contacts=[]}_setUpdateFrame(e){this._lastUpdateFrame=this._updateFrame,this._updateFrame=e}}class U{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 B,this._hitResultsPool.push(e)),e}recoverAllHitResultsPool(){this._hitResultsPoolIndex=0}getContactPoints(){var e=this._contactPointsPool[this._contactPonintsPoolIndex++];return e||(e=new V,this._contactPointsPool.push(e)),e}recoverAllContactPointsPool(){this._contactPonintsPoolIndex=0}getCollision(e,t){var r,i=e.id,a=t.id,n=this._collisions[i];return n&&(r=n[a]),r||(n||(n={},this._collisions[i]=n),(r=0===this._collisionsPool.length?new F:this._collisionsPool.pop())._colliderA=e,r._colliderB=t,n[a]=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 G{constructor(e,t=0){this._gravity=new n(0,-10,0),this._btVector3Zero=g.Physics3D._bullet.btVector3_create(0,0,0),this._btDefaultQuaternion=g.Physics3D._bullet.btQuaternion_create(0,0,0,-1),this._collisionsUtils=new U,this._previousFrameCollisions=[],this._currentFrameCollisions=[],this._currentConstraint={},this._physicsUpdateList=new w,this._characters=[],this._updatedRigidbodies=0,this.maxSubSteps=1,this.fixedTimeStep=1/60,this.maxSubSteps=e.maxSubSteps,this.fixedTimeStep=e.fixedTimeStep;var r=g.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&G.PHYSICSENGINEFLAGS_COLLISIONSONLY)this._btCollisionWorld=new r.btCollisionWorld(this._btDispatcher,this._btBroadphase,this._btCollisionConfiguration);else{if(i&G.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT)throw"PhysicsSimulation:SoftBody processing is not yet available";var a=r.btSequentialImpulseConstraintSolver_create();this._btDiscreteDynamicsWorld=r.btDiscreteDynamicsWorld_create(this._btDispatcher,this._btBroadphase,a,this._btCollisionConfiguration),this._btCollisionWorld=this._btDiscreteDynamicsWorld}this._btDiscreteDynamicsWorld&&(this._btSolverInfo=r.btDynamicsWorld_getSolverInfo(this._btDiscreteDynamicsWorld),this._btDispatchInfo=r.btCollisionWorld_getDispatchInfo(this._btDiscreteDynamicsWorld)),this._btClosestRayResultCallback=r.ClosestRayResultCallback_create(this._btVector3Zero,this._btVector3Zero),this._btAllHitsRayResultCallback=r.AllHitsRayResultCallback_create(this._btVector3Zero,this._btVector3Zero),this._btClosestConvexResultCallback=r.ClosestConvexResultCallback_create(this._btVector3Zero,this._btVector3Zero),this._btAllConvexResultCallback=r.AllConvexResultCallback_create(this._btVector3Zero,this._btVector3Zero),this.setHitsRayResultCallbackFlag(),r.btGImpactCollisionAlgorithm_RegisterAlgorithm(this._btDispatcher)}static __init__(){var e=g.Physics3D._bullet;G._btTempVector30=e.btVector3_create(0,0,0),G._btTempVector31=e.btVector3_create(0,0,0),G._btTempQuaternion0=e.btQuaternion_create(0,0,0,1),G._btTempQuaternion1=e.btQuaternion_create(0,0,0,1),G._btTempTransform0=e.btTransform_create(),G._btTempTransform1=e.btTransform_create()}static createConstraint(){}get continuousCollisionDetection(){return g.Physics3D._bullet.btCollisionWorld_get_m_useContinuous(this._btDispatchInfo)}set continuousCollisionDetection(e){g.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=g.Physics3D._bullet,r=G._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 g.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";g.Physics3D._bullet.btDiscreteDynamicsWorld_setApplySpeculativeContactRestitution(this._btDiscreteDynamicsWorld,e)}_simulate(e){this._updatedRigidbodies=0;var t=g.Physics3D._bullet;this._btDiscreteDynamicsWorld?t.btDiscreteDynamicsWorld_stepSimulation(this._btDiscreteDynamicsWorld,e,this.maxSubSteps,this.fixedTimeStep):t.PerformDiscreteCollisionDetection(this._btCollisionWorld)}_destroy(){var e=g.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){g.Physics3D._bullet.btCollisionWorld_addCollisionObject(this._btCollisionWorld,e._btColliderObject,t,r)}_removePhysicsCollider(e){g.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";g.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";g.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=g.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=g.Physics3D._bullet;t.btCollisionWorld_removeCollisionObject(this._btCollisionWorld,e._btColliderObject),t.btDynamicsWorld_removeAction(this._btCollisionWorld,e._btKinematicCharacter)}raycastFromTo(e,t,r=null,i=D.COLLISIONFILTERGROUP_ALLFILTER,a=D.COLLISIONFILTERGROUP_ALLFILTER){var n=g.Physics3D._bullet,s=this._btClosestRayResultCallback,o=G._btTempVector30,l=G._btTempVector31;if(n.btVector3_setValue(o,-e.x,e.y,e.z),n.btVector3_setValue(l,-t.x,t.y,t.z),n.ClosestRayResultCallback_set_m_rayFromWorld(s,o),n.ClosestRayResultCallback_set_m_rayToWorld(s,l),n.RayResultCallback_set_m_collisionFilterGroup(s,i),n.RayResultCallback_set_m_collisionFilterMask(s,a),n.RayResultCallback_set_m_collisionObject(s,null),n.RayResultCallback_set_m_closestHitFraction(s,1),n.btCollisionWorld_rayTest(this._btCollisionWorld,o,l,s),n.RayResultCallback_hasHit(s)){if(r){r.succeeded=!0,r.collider=P._physicObjectsMap[n.btCollisionObject_getUserIndex(n.RayResultCallback_get_m_collisionObject(s))],r.hitFraction=n.RayResultCallback_get_m_closestHitFraction(s);var _=n.ClosestRayResultCallback_get_m_hitPointWorld(s),h=r.point;h.x=-n.btVector3_x(_),h.y=n.btVector3_y(_),h.z=n.btVector3_z(_);var c=n.ClosestRayResultCallback_get_m_hitNormalWorld(s),d=r.normal;d.x=-n.btVector3_x(c),d.y=n.btVector3_y(c),d.z=n.btVector3_z(c)}return!0}return r&&(r.succeeded=!1),!1}raycastAllFromTo(e,t,r,i=D.COLLISIONFILTERGROUP_ALLFILTER,a=D.COLLISIONFILTERGROUP_ALLFILTER){var n=g.Physics3D._bullet,s=this._btAllHitsRayResultCallback,o=G._btTempVector30,l=G._btTempVector31;r.length=0,n.btVector3_setValue(o,-e.x,e.y,e.z),n.btVector3_setValue(l,-t.x,t.y,t.z),n.AllHitsRayResultCallback_set_m_rayFromWorld(s,o),n.AllHitsRayResultCallback_set_m_rayToWorld(s,l),n.RayResultCallback_set_m_collisionFilterGroup(s,i),n.RayResultCallback_set_m_collisionFilterMask(s,a);var _=n.AllHitsRayResultCallback_get_m_collisionObjects(s),h=n.AllHitsRayResultCallback_get_m_hitPointWorld(s),c=n.AllHitsRayResultCallback_get_m_hitNormalWorld(s),d=n.AllHitsRayResultCallback_get_m_hitFractions(s);n.tBtCollisionObjectArray_clear(_),n.tVector3Array_clear(h),n.tVector3Array_clear(c),n.tScalarArray_clear(d),n.btCollisionWorld_rayTest(this._btCollisionWorld,o,l,s);var u=n.tBtCollisionObjectArray_size(_);if(u>0){this._collisionsUtils.recoverAllHitResultsPool();for(var m=0;m0){this._collisionsUtils.recoverAllHitResultsPool();for(var A=0;A=.64&&(s>1?o=0:o*=1-(s-.64)/.36),n[a]=Math.floor(255*o+.5)}static haloTexture(e,t,r,i,a,n){var s=(e-(r>>=1))/r,o=(t-(i>>=1))/i,l=s*s+o*o;l>1&&(l=1),n[a]=Math.floor(255*(1-l)+.5)}static _generateTexture2D(e,r,i,a){var n=0,s=0;switch(e.format){case t.TextureFormat.R8G8B8:s=3;break;case t.TextureFormat.R8G8B8A8:s=4;break;case t.TextureFormat.Alpha8:s=1;break;default:throw"GeneratedTexture._generateTexture: unkonw texture format."}for(var o=new Uint8Array(r*i*s),l=0;l=0?e.substr(t):null}static _createAffineTransformationArray(e,t,r,i){var a=t.x,n=t.y,s=t.z,o=t.w,l=a+a,_=n+n,h=s+s,c=a*l,d=a*_,u=a*h,m=n*_,f=n*h,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,a){var n=t,s=e,o=i,l=n[r],_=n[r+1],h=n[r+2],c=n[r+3],d=n[r+4],u=n[r+5],m=n[r+6],f=n[r+7],T=n[r+8],E=n[r+9],p=n[r+10],g=n[r+11],S=n[r+12],R=n[r+13],v=n[r+14],x=n[r+15],A=s[0],I=s[1],D=s[2],M=s[3],C=s[4],y=s[5],L=s[6],O=s[7],N=s[8],P=s[9],b=s[10],w=s[11],V=s[12],B=s[13],F=s[14],U=s[15];o[a]=l*A+_*C+h*N+c*V,o[a+1]=l*I+_*y+h*P+c*B,o[a+2]=l*D+_*L+h*b+c*F,o[a+3]=l*M+_*O+h*w+c*U,o[a+4]=d*A+u*C+m*N+f*V,o[a+5]=d*I+u*y+m*P+f*B,o[a+6]=d*D+u*L+m*b+f*F,o[a+7]=d*M+u*O+m*w+f*U,o[a+8]=T*A+E*C+p*N+g*V,o[a+9]=T*I+E*y+p*P+g*B,o[a+10]=T*D+E*L+p*b+g*F,o[a+11]=T*M+E*O+p*w+g*U,o[a+12]=S*A+R*C+v*N+x*V,o[a+13]=S*I+R*y+v*P+x*B,o[a+14]=S*D+R*L+v*b+x*F,o[a+15]=S*M+R*O+v*w+x*U}static arcTanAngle(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){n.subtract(t,e,S.TEMPVector30),n.normalize(S.TEMPVector30,S.TEMPVector30),r.x=Math.asin(S.TEMPVector30.y),r.y=H.arcTanAngle(-S.TEMPVector30.z,-S.TEMPVector30.x)}static transformQuat(e,t,r){var i=t,a=e.x,n=e.y,s=e.z,o=i[0],l=i[1],_=i[2],h=i[3],c=h*a+l*s-_*n,d=h*n+_*a-o*s,u=h*s+o*n-l*a,m=-o*a-l*n-_*s;r.x=c*h+m*-o+d*-_-u*-l,r.y=d*h+m*-l+u*-o-c*-_,r.z=u*h+m*-_+c*-l-d*-o}static quaternionWeight(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w}static quaternionConjugate(e,t){t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w}static scaleWeight(e,t,r){var i=e.x,a=e.y,n=e.z;r.x=i>0?Math.pow(Math.abs(i),t):-Math.pow(Math.abs(i),t),r.y=a>0?Math.pow(Math.abs(a),t):-Math.pow(Math.abs(a),t),r.z=n>0?Math.pow(Math.abs(n),t):-Math.pow(Math.abs(n),t)}static scaleBlend(e,t,r,i){var a=H._tempVector3_0,n=H._tempVector3_1;H.scaleWeight(e,1-r,a),H.scaleWeight(t,r,n);var s=r>.5?t:e;i.x=s.x>0?Math.abs(a.x*n.x):-Math.abs(a.x*n.x),i.y=s.y>0?Math.abs(a.y*n.y):-Math.abs(a.y*n.y),i.z=s.z>0?Math.abs(a.z*n.z):-Math.abs(a.z*n.z)}static matrix4x4MultiplyFFF(e,t,r){var i,a,n,s,o;if(r===t)for(t=new Float32Array(16),i=0;i<16;++i)t[i]=r[i];var l=t[0],_=t[1],h=t[2],c=t[3],d=t[4],u=t[5],m=t[6],f=t[7],T=t[8],E=t[9],p=t[10],g=t[11],S=t[12],R=t[13],v=t[14],x=t[15];for(i=0;i<4;i++)a=e[i],n=e[i+4],s=e[i+8],o=e[i+12],r[i]=a*l+n*_+s*h+o*c,r[i+4]=a*d+n*u+s*m+o*f,r[i+8]=a*T+n*E+s*p+o*g,r[i+12]=a*S+n*R+s*v+o*x}static matrix4x4MultiplyFFFForNative(e,r,i){t.LayaGL.instance.matrix4x4Multiply(e,r,i)}static matrix4x4MultiplyMFM(e,t,r){H.matrix4x4MultiplyFFF(e.elements,t,r.elements)}static _buildTexture2D(e,r,i,a,n=!1){var s=new t.Texture2D(e,r,i,n,!0);return s.anisoLevel=1,s.filterMode=t.FilterMode.Point,z._generateTexture2D(s,e,r,a),s}static _drawBound(e,t,r){e.lineCount+12>e.maxLineCount&&(e.maxLineCount+=12);var i=H._tempVector3_0,a=H._tempVector3_1,n=t.min,s=t.max;i.setValue(n.x,n.y,n.z),a.setValue(s.x,n.y,n.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,n.z),a.setValue(n.x,n.y,s.z),e.addLine(i,a,r,r),i.setValue(s.x,n.y,n.z),a.setValue(s.x,n.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,s.z),a.setValue(s.x,n.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,n.z),a.setValue(n.x,s.y,n.z),e.addLine(i,a,r,r),i.setValue(n.x,n.y,s.z),a.setValue(n.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(s.x,n.y,n.z),a.setValue(s.x,s.y,n.z),e.addLine(i,a,r,r),i.setValue(s.x,n.y,s.z),a.setValue(s.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,s.y,n.z),a.setValue(s.x,s.y,n.z),e.addLine(i,a,r,r),i.setValue(n.x,s.y,n.z),a.setValue(n.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(s.x,s.y,n.z),a.setValue(s.x,s.y,s.z),e.addLine(i,a,r,r),i.setValue(n.x,s.y,s.z),a.setValue(s.x,s.y,s.z),e.addLine(i,a,r,r)}static _getHierarchyPath(e,t,r){r.length=0;for(var i=t;i!==e;){var a=i._parent;if(!a)return null;r.push(a.getChildIndex(i)),i=a}return r}static _getNodeByHierarchyPath(e,t){for(var r=e,i=t.length-1;i>=0;i--)r=r.getChildAt(t[i]);return r}}H._tempVector3_0=new n,H._tempVector3_1=new n,H._tempArray16_0=new Float32Array(16),H._tempArray16_1=new Float32Array(16),H._tempArray16_2=new Float32Array(16),H._tempArray16_3=new Float32Array(16),H._compIdToNode=new Object;class k extends P{constructor(e=.1,t=null,r=D.COLLISIONFILTERGROUP_DEFAULTFILTER,i=D.COLLISIONFILTERGROUP_ALLFILTER){super(r,i),this._upAxis=new n(0,1,0),this._maxSlope=45,this._jumpSpeed=10,this._fallSpeed=55,this._gravity=new n(0,3*-9.8,0),this._btKinematicCharacter=null,this._stepHeight=e,t&&(this._upAxis=t),this._controlBySimulation=!0}static __init__(){k._btTempVector30=g.Physics3D._bullet.btVector3_create(0,0,0)}get fallSpeed(){return this._fallSpeed}set fallSpeed(e){this._fallSpeed=e,g.Physics3D._bullet.btKinematicCharacterController_setFallSpeed(this._btKinematicCharacter,e)}get jumpSpeed(){return this._jumpSpeed}set jumpSpeed(e){this._jumpSpeed=e,g.Physics3D._bullet.btKinematicCharacterController_setJumpSpeed(this._btKinematicCharacter,e)}get gravity(){return this._gravity}set gravity(e){this._gravity=e;var t=g.Physics3D._bullet,r=k._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,g.Physics3D._bullet.btKinematicCharacterController_setMaxSlope(this._btKinematicCharacter,e/180*Math.PI)}get isGrounded(){return g.Physics3D._bullet.btKinematicCharacterController_onGround(this._btKinematicCharacter)}get stepHeight(){return this._stepHeight}set stepHeight(e){this._stepHeight=e,g.Physics3D._bullet.btKinematicCharacterController_setStepHeight(this._btKinematicCharacter,e)}get upAxis(){return this._upAxis}set upAxis(e){this._upAxis=e;var t=k._btTempVector30;H._convertToBulletVec3(e,t,!1),g.Physics3D._bullet.btKinematicCharacterController_setUp(this._btKinematicCharacter,t)}_constructCharacter(){var e=g.Physics3D._bullet;this._btKinematicCharacter&&e.btKinematicCharacterController_destroy(this._btKinematicCharacter);var t=k._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=g.Physics3D._bullet,t=e.btPairCachingGhostObject_create();e.btCollisionObject_setUserIndex(t,this.id),e.btCollisionObject_setCollisionFlags(t,P.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(){g.Physics3D._bullet.btKinematicCharacterController_destroy(this._btKinematicCharacter),super._onDestroy(),this._btKinematicCharacter=null}move(e){var t=k._btVector30,r=g.Physics3D._bullet;r.btVector3_setValue(t,-e.x,e.y,e.z),r.btKinematicCharacterController_setWalkDirection(this._btKinematicCharacter,t)}jump(e=null){var t=g.Physics3D._bullet,r=k._btVector30;e?(H._convertToBulletVec3(e,r,!0),t.btKinematicCharacterController_jump(this._btKinematicCharacter,r)):(t.btVector3_setValue(r,0,0,0),t.btKinematicCharacterController_jump(this._btKinematicCharacter,r))}}k.UPAXIS_X=0,k.UPAXIS_Y=1,k.UPAXIS_Z=2;class W extends P{constructor(e,t){super(e,t),this._isTrigger=!1}get isTrigger(){return this._isTrigger}set isTrigger(e){this._isTrigger=e;var t=g.Physics3D._bullet;if(this._btColliderObject){var r=t.btCollisionObject_getCollisionFlags(this._btColliderObject);e?0==(r&P.COLLISIONFLAGS_NO_CONTACT_RESPONSE)&&t.btCollisionObject_setCollisionFlags(this._btColliderObject,r|P.COLLISIONFLAGS_NO_CONTACT_RESPONSE):0!=(r&P.COLLISIONFLAGS_NO_CONTACT_RESPONSE)&&t.btCollisionObject_setCollisionFlags(this._btColliderObject,r^P.COLLISIONFLAGS_NO_CONTACT_RESPONSE)}}_onAdded(){super._onAdded(),this.isTrigger=this._isTrigger}_cloneTo(e){super._cloneTo(e),e.isTrigger=this._isTrigger}}class X extends W{constructor(e=D.COLLISIONFILTERGROUP_DEFAULTFILTER,t=D.COLLISIONFILTERGROUP_ALLFILTER){super(e,t),this._isKinematic=!1,this._mass=1,this._gravity=new n(0,-10,0),this._angularDamping=0,this._linearDamping=0,this._overrideGravity=!1,this._totalTorque=new n(0,0,0),this._totalForce=new n(0,0,0),this._linearVelocity=new n,this._angularVelocity=new n,this._linearFactor=new n(1,1,1),this._angularFactor=new n(1,1,1),this._detectCollisions=!0,this._controlBySimulation=!0}static __init__(){var e=g.Physics3D._bullet;X._btTempVector30=e.btVector3_create(0,0,0),X._btTempVector31=e.btVector3_create(0,0,0),X._btVector3Zero=e.btVector3_create(0,0,0),X._btInertia=e.btVector3_create(0,0,0),X._btImpulse=e.btVector3_create(0,0,0),X._btImpulseOffset=e.btVector3_create(0,0,0),X._btGravity=e.btVector3_create(0,0,0),X._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=g.Physics3D._bullet,r=!!(this._simulation&&this._enabled&&this._colliderShape);r&&this._removeFromSimulation();var i=this._btColliderObject,a=t.btCollisionObject_getCollisionFlags(i);e?(a|=P.COLLISIONFLAGS_KINEMATIC_OBJECT,t.btCollisionObject_setCollisionFlags(i,a),t.btCollisionObject_forceActivationState(this._btColliderObject,P.ACTIVATIONSTATE_DISABLE_DEACTIVATION),this._enableProcessCollisions=!1,this._updateMass(0)):((a&P.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(a^=P.COLLISIONFLAGS_KINEMATIC_OBJECT),t.btCollisionObject_setCollisionFlags(i,a),t.btCollisionObject_setActivationState(this._btColliderObject,P.ACTIVATIONSTATE_ACTIVE_TAG),this._enableProcessCollisions=!0,this._updateMass(this._mass));var n=X._btVector3Zero;t.btCollisionObject_setInterpolationLinearVelocity(i,n),t.btRigidBody_setLinearVelocity(i,n),t.btCollisionObject_setInterpolationAngularVelocity(i,n),t.btRigidBody_setAngularVelocity(i,n),r&&this._addToSimulation()}get linearDamping(){return this._linearDamping}set linearDamping(e){this._linearDamping=e,this._btColliderObject&&g.Physics3D._bullet.btRigidBody_setDamping(this._btColliderObject,e,this._angularDamping)}get angularDamping(){return this._angularDamping}set angularDamping(e){this._angularDamping=e,this._btColliderObject&&g.Physics3D._bullet.btRigidBody_setDamping(this._btColliderObject,this._linearDamping,e)}get overrideGravity(){return this._overrideGravity}set overrideGravity(e){this._overrideGravity=e;var t=g.Physics3D._bullet;if(this._btColliderObject){var r=t.btRigidBody_getFlags(this._btColliderObject);e?0==(r&X._BT_DISABLE_WORLD_GRAVITY)&&t.btRigidBody_setFlags(this._btColliderObject,r|X._BT_DISABLE_WORLD_GRAVITY):(r&X._BT_DISABLE_WORLD_GRAVITY)>0&&t.btRigidBody_setFlags(this._btColliderObject,r^X._BT_DISABLE_WORLD_GRAVITY)}}get gravity(){var e=g.Physics3D._bullet;return X._btGravity=e.btRigidBody_getGravity(this._btColliderObject),H._convertToLayaVec3(X._btGravity,this._gravity,!0),this._gravity}set gravity(e){this._gravity=e;var t=g.Physics3D._bullet;t.btVector3_setValue(X._btGravity,-e.x,e.y,e.z),t.btRigidBody_setGravity(this._btColliderObject,X._btGravity)}get totalForce(){if(this._btColliderObject){var e=g.Physics3D._bullet.btRigidBody_getTotalForce(this._btColliderObject);return H._convertToLayaVec3(e,this._totalForce,!0),this._totalForce}return null}get linearFactor(){return this._linearFactor}set linearFactor(e){this._linearFactor=e;var t=X._btTempVector30;H._convertToBulletVec3(e,t,!1),g.Physics3D._bullet.btRigidBody_setLinearFactor(this._btColliderObject,t)}get linearVelocity(){return this._btColliderObject&&H._convertToLayaVec3(g.Physics3D._bullet.btRigidBody_getLinearVelocity(this._btColliderObject),this._linearVelocity,!0),this._linearVelocity}set linearVelocity(e){if(this._linearVelocity=e,this._btColliderObject){var t=X._btTempVector30;H._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),g.Physics3D._bullet.btRigidBody_setLinearVelocity(this._btColliderObject,t)}}get angularFactor(){return this._angularFactor}set angularFactor(e){this._angularFactor=e;var t=X._btTempVector30;H._convertToBulletVec3(e,t,!1),g.Physics3D._bullet.btRigidBody_setAngularFactor(this._btColliderObject,t)}get angularVelocity(){return this._btColliderObject&&H._convertToLayaVec3(g.Physics3D._bullet.btRigidBody_getAngularVelocity(this._btColliderObject),this._angularVelocity,!0),this._angularVelocity}set angularVelocity(e){if(this._angularVelocity=e,this._btColliderObject){var t=X._btTempVector30;H._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),g.Physics3D._bullet.btRigidBody_setAngularVelocity(this._btColliderObject,t)}}get totalTorque(){if(this._btColliderObject){var e=g.Physics3D._bullet.btRigidBody_getTotalTorque(this._btColliderObject);return H._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&&g.Physics3D._bullet.btCollisionObject_getActivationState(this._btColliderObject)===P.ACTIVATIONSTATE_ISLAND_SLEEPING}get sleepLinearVelocity(){return g.Physics3D._bullet.btRigidBody_getLinearSleepingThreshold(this._btColliderObject)}set sleepLinearVelocity(e){var t=g.Physics3D._bullet;t.btRigidBody_setSleepingThresholds(this._btColliderObject,e,t.btRigidBody_getAngularSleepingThreshold(this._btColliderObject))}get sleepAngularVelocity(){return g.Physics3D._bullet.btRigidBody_getAngularSleepingThreshold(this._btColliderObject)}set sleepAngularVelocity(e){var t=g.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=g.Physics3D._bullet;t.btCollisionShape_calculateLocalInertia(this._colliderShape._btShape,e,X._btInertia),t.btRigidBody_setMassProps(this._btColliderObject,e,X._btInertia),t.btRigidBody_updateInertiaTensor(this._btColliderObject)}}_onScaleChange(e){super._onScaleChange(e),this._updateMass(this._isKinematic?0:this._mass)}_derivePhysicsTransformation(e){var t=g.Physics3D._bullet,r=this._btColliderObject,i=t.btCollisionObject_getWorldTransform(r),a=X._btTransform0;t.btTransform_equal(a,i),this._innerDerivePhysicsTransformation(a,e),t.btRigidBody_setCenterOfMassTransform(r,a)}_onAdded(){var e=g.Physics3D._bullet,t=e.layaMotionState_create();e.layaMotionState_set_rigidBodyID(t,this._id),this._btLayaMotionState=t;var r=e.btRigidBodyConstructionInfo_create(0,t,null,X._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=g.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(){g.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=g.Physics3D._bullet,i=X._btTempVector30;if(r.btVector3_setValue(i,-e.x,e.y,e.z),t){var a=X._btTempVector31;r.btVector3_setValue(a,-t.x,t.y,t.z),r.btRigidBody_applyForce(this._btColliderObject,i,a)}else r.btRigidBody_applyCentralForce(this._btColliderObject,i)}applyTorque(e){if(null==this._btColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=g.Physics3D._bullet,r=X._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=g.Physics3D._bullet;r.btVector3_setValue(X._btImpulse,-e.x,e.y,e.z),t?(r.btVector3_setValue(X._btImpulseOffset,-t.x,t.y,t.z),r.btRigidBody_applyImpulse(this._btColliderObject,X._btImpulse,X._btImpulseOffset)):r.btRigidBody_applyCentralImpulse(this._btColliderObject,X._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=g.Physics3D._bullet,r=X._btTempVector30;t.btVector3_setValue(r,-e.x,e.y,e.z),t.btRigidBody_applyTorqueImpulse(this._btColliderObject,r)}wakeUp(){this._btColliderObject&&g.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=g.Physics3D._bullet;t.btRigidBody_clearForces(e);var r=X._btVector3Zero;t.btCollisionObject_setInterpolationLinearVelocity(e,r),t.btRigidBody_setLinearVelocity(e,r),t.btCollisionObject_setInterpolationAngularVelocity(e,r),t.btRigidBody_setAngularVelocity(e,r)}}X.TYPE_STATIC=0,X.TYPE_DYNAMIC=1,X.TYPE_KINEMATIC=2,X._BT_DISABLE_WORLD_GRAVITY=1,X._BT_ENABLE_GYROPSCOPIC_FORCE=2;class Y{static __bulletinit__(){this._bullet=window.Physics3D,this._bullet&&(x.__init__(),v.__init__(),A.__init__(),P.__init__(),G.__init__(),M.__init__(),L.__init__(),k.__init__(),X.__init__())}static __cannoninit__(){this._cannon=window.CANNON,this._cannon&&(t.CannonColliderShape.__init__(),t.CannonPhysicsComponent.__init__(),t.CannonPhysicsSimulation.__init__(),t.CannonBoxColliderShape.__init__(),t.CannonRigidbody3D.__init__())}}Y._bullet=null,Y._cannon=null,Y._enablePhysics=!1;class j{constructor(){this._defaultPhysicsMemory=16,this._maxLightCount=32,this._lightClusterCount=new n(12,12,12),this._editerEnvironment=!1,this.isAntialias=!0,this.isAlpha=!1,this.premultipliedAlpha=!0,this.isStencil=!0,this.enableMultiLight=!0,this.octreeCulling=!1,this.octreeInitialSize=64,this.octreeInitialCenter=new n(0,0,0),this.octreeMinNodeSize=2,this.octreeLooseness=1.25,this.debugFrustumCulling=!1,this.pbrRenderQuality=e.PBRRenderQuality.High,this.isUseCannonPhysicsEngine=!1,this._maxAreaLightCountPerClusterAverage=Math.min(4*Math.floor(2048/this._lightClusterCount.z-1),this._maxLightCount)}static get useCannonPhysics(){return j._config.isUseCannonPhysicsEngine}static set useCannonPhysics(e){j._config.isUseCannonPhysicsEngine=e,e&&(Y.__cannoninit__(),g.Scene3D.cannonPhysicsSettings||(g.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&&(y.params=L=[]),t=0;t0&&(L.params=O=[]),r=0;rt);)u++,l++,r[s]=u;else for((l=u+1)!==d&&t>c[l].time&&(u=d-1,r[s]=u),l=u+1;u>-1&&!(c[u].timee?i=t-1:r=t+1}return r}addEvent(e){var t=this._binarySearchEventIndex(e.time);this._animationEvents.splice(t,0,e)}_disposeResource(){this._nodes=null,this._nodesMap=null}}ie.ANIMATIONCLIP="ANIMATIONCLIP",ie._tempQuaternion0=new S;class ae{constructor(){this._currentState=null}get normalizedTime(){return this._normalizedTime}get duration(){return this._duration}get animatorState(){return this._currentState}_resetPlayState(e,t){this._finish=!1,this._startPlayTime=e,this._elapsedTime=e,this._playEventIndex=0,this._lastIsFront=!0,this._normalizedTime=this._elapsedTime/t;var r=this._normalizedTime%1;this._normalizedPlayTime=r<0?r+1:r}_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 ne{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 ae,this._crossPlayStateInfo=new ae,this.blendingMode=ne.BLENDINGMODE_OVERRIDE,this.defaultWeight=1,this.playOnWake=!0,this.name=e}get defaultState(){return this._defaultState}set defaultState(e){this._defaultState=e,this._statesMap[e.name]=e}_removeClip(e,t,r,i){var a=i._clip,n=e[r];if(e.splice(r,1),delete t[i.name],this._animator){var s=a._nodes,o=n._nodeOwners;a._removeReference();for(var l=0,_=s.count;l<_;l++)this._animator._removeKeyframeNodeOwner(o,s.getNodeByIndex(l))}}_getReferenceCount(){return this._referenceCount}_addReference(e=1){for(var t=0,r=this._states.length;t0&&this._clip._removeReference(this._referenceCount),e){var t=this._realtimeDatas,r=e._nodes,i=r.count;this._currentFrameIndices=new Int16Array(i),this._resetFrameIndices(),this._referenceCount>0&&e._addReference(this._referenceCount),this._realtimeDatas.length=i;for(var a=0;a=a){if(t._finish=!0,t._elapsedTime=a,t._normalizedPlayTime=1,_)for(var h=0,c=_.length;h=0&&(s=t[r]).time>=i;r--)for(o=0,l=e.length;o=t._lastElapsedTime;t._lastIsFront!==_&&(_?t._playEventIndex++:t._playEventIndex--,t._lastIsFront=_);var h=t._playEventIndex;if(_){var c=this._eventScript(r,a,t._playEventIndex,l>0?n:o,!0);h===t._playEventIndex&&(t._playEventIndex=c);for(var d=0,u=l-1;d0&&o>0&&(t._playEventIndex=this._eventScript(r,a,0,o,!0))}else{c=this._eventScript(r,a,t._playEventIndex,l>0?0:o,!1);h===t._playEventIndex&&(t._playEventIndex=c);var m=a.length-1;for(d=0,u=l-1;d0&&o>0&&(t._playEventIndex=this._eventScript(r,a,m,o,!1))}}}_updateClipDatas(e,t,r,i){var a=e._clip,n=a._duration,s=e.clipStart*n+r._normalizedPlayTime*r._duration,o=e._currentFrameIndices,l=r._elapsedTime>r._lastElapsedTime;a._evaluateClipDatasRealTime(a._nodes,s,o,t,l,e._realtimeDatas)}_applyFloat(e,t,r,i,a,n,s){if(r.updateMark===this._updateMark)if(i)e[t]+=a*s;else{var o=e[t];e[t]=o+a*(s-o)}else if(n)e[t]=i?r.defaultValue+s:s;else if(i)e[t]=r.defaultValue+a*s;else{var l=r.defaultValue;e[t]=l+a*(s-l)}}_applyPositionAndRotationEuler(e,t,r,i,a,n){if(e.updateMark===this._updateMark)if(t)n.x+=r*a.x,n.y+=r*a.y,n.z+=r*a.z;else{var s=n.x,o=n.y,l=n.z;n.x=s+r*(a.x-s),n.y=o+r*(a.y-o),n.z=l+r*(a.z-l)}else if(i)if(t){var _=e.defaultValue;n.x=_.x+a.x,n.y=_.y+a.y,n.z=_.z+a.z}else n.x=a.x,n.y=a.y,n.z=a.z;else if(_=e.defaultValue,t)n.x=_.x+r*a.x,n.y=_.y+r*a.y,n.z=_.z+r*a.z;else{var h=_.x,c=_.y,d=_.z;n.x=h+r*(a.x-h),n.y=c+r*(a.y-c),n.z=d+r*(a.z-d)}}_applyRotation(e,t,r,i,a,n){if(e.updateMark===this._updateMark)if(t){var s=le._tempQuaternion1;H.quaternionWeight(a,r,s),s.normalize(s),S.multiply(n,s,n)}else S.lerp(n,a,r,n);else if(i)if(t){var o=e.defaultValue;S.multiply(o,a,n)}else n.x=a.x,n.y=a.y,n.z=a.z,n.w=a.w;else o=e.defaultValue,t?(s=le._tempQuaternion1,H.quaternionWeight(a,r,s),s.normalize(s),S.multiply(o,s,n)):S.lerp(o,a,r,n)}_applyScale(e,t,r,i,a,n){if(e.updateMark===this._updateMark)if(t){var s=le._tempVector31;H.scaleWeight(a,r,s),n.x=n.x*s.x,n.y=n.y*s.y,n.z=n.z*s.z}else H.scaleBlend(n,a,r,n);else if(i)if(t){var o=e.defaultValue;n.x=o.x*a.x,n.y=o.y*a.y,n.z=o.z*a.z}else n.x=a.x,n.y=a.y,n.z=a.z;else o=e.defaultValue,t?(s=le._tempVector31,H.scaleWeight(a,r,s),n.x=o.x*s.x,n.y=o.y*s.y,n.z=o.z*s.z):H.scaleBlend(o,a,r,n)}_applyCrossData(e,t,r,i,a,n,s){var o=e.propertyOwner;if(o){switch(e.type){case 0:for(var l=e.property,_=l.length-1,h=0;h<_&&(o=o[l[h]]);h++);var c=a+s*(n-a);e.value=c,o&&this._applyFloat(o,l[_],e,t,r,i,c);break;case 1:var d=o.localPosition,u=e.value,m=a.x,f=a.y,T=a.z;u.x=m+s*(n.x-m),u.y=f+s*(n.y-f),u.z=T+s*(n.z-T),this._applyPositionAndRotationEuler(e,t,r,i,u,d),o.localPosition=d;break;case 2:var E=o.localRotation,p=e.value;S.lerp(a,n,s,p),this._applyRotation(e,t,r,i,p,E),o.localRotation=E;break;case 3:var g=o.localScale,R=e.value;H.scaleBlend(a,n,s,R),this._applyScale(e,t,r,i,R,g),o.localScale=g;break;case 4:var v=o.localRotationEuler,x=e.value;m=a.x,f=a.y,T=a.z,x.x=m+s*(n.x-m),x.y=f+s*(n.y-f),x.z=T+s*(n.z-T),this._applyPositionAndRotationEuler(e,t,r,i,x,v),o.localRotationEuler=v}e.updateMark=this._updateMark}}_setClipDatasToNode(e,t,r,i){for(var a=e._realtimeDatas,n=e._clip._nodes,s=e._nodeOwners,o=0,l=n.count;op?p/T:1,S=this._speed*m.speed;this._updatePlayer(m,l,t*g*S,f.islooping);var R=(l._elapsedTime-E)/g/T;R>=1?r&&(this._updateClipDatas(m,u,l,n*S),this._setClipDatasToNode(m,u,s.defaultWeight,0===i),s._playType=0,o._currentState=m,l._cloneTo(o)):(o._finish||(c=this._speed*_.speed,this._updatePlayer(_,o,t*c,h.islooping),r&&this._updateClipDatas(_,u,o,n*c)),r&&(this._updateClipDatas(m,u,l,n*g*S),this._setCrossClipDatasToNode(s,_,m,R,0===i))),r&&(this._updateEventScript(_,o),this._updateEventScript(m,l));break;case 2:f=(m=s._crossPlayState)._clip,T=s._crossDuration,E=l._startPlayTime,g=T>(p=f._duration-E)?p/T:1,S=this._speed*m.speed,this._updatePlayer(m,l,t*g*S,f.islooping),r&&((R=(l._elapsedTime-E)/g/T)>=1?(this._updateClipDatas(m,u,l,n*S),this._setClipDatasToNode(m,u,1,0===i),s._playType=0,o._currentState=m,l._cloneTo(o)):(this._updateClipDatas(m,u,l,n*g*S),this._setFixedCrossClipDatasToNode(s,m,R,0===i)),this._updateEventScript(m,l))}}r&&this._avatar&&this._updateAvatarNodesToSprite()}}_cloneTo(e){var t=e;t.avatar=this.avatar,t.cullingMode=this.cullingMode;for(var r=0,i=this._controllerLayers.length;r=0;i--){var a=r[i]&t[i];0==a&&i==this._length-1?this._length--:r[i]=a}}add(e){var t=e._index,r=t+1,i=this._mask,a=this._length;if(ai)){var a=r[t]&~e._value;t==i&&0===a?this._length--:r[t]=a}}addDefineDatas(e){var t=e._mask,r=e._length,i=this._mask,a=this._length;if(a=0;a--){var n=r[a]&~t[a];a==i&&0===n?(i--,this._length--):r[a]=n}}has(e){var t=e._index;return!(t>=this._length)&&0!=(this._mask[t]&e._value)}clear(){this._length=0}cloneTo(e){var t=e,r=t._mask,i=this._mask,a=this._length;r.length=a;for(var n=0;n0&&(r&&r._removeReference(),t&&t._addReference())}getTexture(e){return this._data[e]}setAttribute(e,t){this._data[e]=t}getAttribute(e){return this._data[e]}getLength(){return this._data.length}setLength(e){this._data.length=e}cloneTo(e){var r=e,s=r._data;for(var o in this._data){var l=this._data[o];if(null!=l)if("number"==typeof l)s[o]=l;else if("number"==typeof l)s[o]=l;else if("boolean"==typeof l)s[o]=l;else if(l instanceof i){var _=s[o]||(s[o]=new i);l.cloneTo(_),s[o]=_}else if(l instanceof n){var h=s[o]||(s[o]=new n);l.cloneTo(h),s[o]=h}else if(l instanceof a){var c=s[o]||(s[o]=new a);l.cloneTo(c),s[o]=c}else if(l instanceof R){var d=s[o]||(s[o]=new R);l.cloneTo(d),s[o]=d}else l instanceof t.BaseTexture&&(s[o]=l)}this._defineDatas.cloneTo(r._defineDatas)}clone(){var e=new me;return this.cloneTo(e),e}cloneToForNative(e){var r=e;this._int32Data.length-r._int32Data.length>0&&r.needRenewArrayBufferForNative(this._int32Data.length),r._int32Data.set(this._int32Data,0);var s=r._nativeArray,o=this._nativeArray.length;s.length=o;for(var l=0;l=this._int32Data.length){var r=4*(e+1),i=this._int32Data,a=this._data.conchRef,n=this._data._ptrID;this._data=new ArrayBuffer(r),this._int32Data=new Int32Array(this._data),this._float32Data=new Float32Array(this._data),this._data.conchRef=a,this._data._ptrID=n,i&&this._int32Data.set(i,0);var s=t.LayaGL.instance;s.updateArrayBufferRef?s.updateArrayBufferRef(this._data._ptrID,a.isSyncToRender(),this._data):window.conch.updateArrayBufferRef(this._data._ptrID,a.isSyncToRender(),this._data)}}getDataForNative(){return this._nativeArray}getIntForNative(e){return this._int32Data[e]}setIntForNative(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t,this._nativeArray[e]=t}getBoolForNative(e){return 1==this._int32Data[e]}setBoolForNative(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t?1:0,this._nativeArray[e]=t}getNumberForNative(e){return this._float32Data[e]}setNumberForNative(e,t){this.needRenewArrayBufferForNative(e),this._float32Data[e]=t,this._nativeArray[e]=t}getMatrix4x4ForNative(e){return this._nativeArray[e]}setMatrix4x4ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVectorForNative(e){return this._nativeArray[e]}setVectorForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVector2ForNative(e){return this._nativeArray[e]}setVector2ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVector3ForNative(e){return this._nativeArray[e]}setVector3ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getQuaternionForNative(e){return this._nativeArray[e]}setQuaternionForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getBufferForNative(e){return this._nativeArray[e]}setBufferForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var r=this.setReferenceForNative(t);this._int32Data[e]=r}getAttributeForNative(e){return this._nativeArray[e]}setAttributeForNative(e,r){this._nativeArray[e]=r,r._ptrID||t.LayaGL.instance.createArrayBufferRef(r,t.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0),t.LayaGL.instance.syncBufferToRenderThread(r),this._int32Data[e]=r._ptrID}getTextureForNative(e){return this._nativeArray[e]}setTextureForNative(e,t){if(t){this.needRenewArrayBufferForNative(e);var r=this._nativeArray[e];this._nativeArray[e]=t;var i=t._getSource()||t.defaulteTexture._getSource();this._int32Data[e]=i.id,this._ownerResource&&this._ownerResource.referenceCount>0&&(r&&r._removeReference(),t&&t._addReference())}}setReferenceForNative(e){this.clearRuntimeCopyArray();var r=0,i=0;return me._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){me._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&&_>o)break;o&_&&t.push(s[_])}}static getDefineByName(e){var t=xe._defineMap[e];if(!t){var r=xe._maskMap,i=xe._defineCounter,a=Math.floor(i/32),n=1<0?Ie._pool.pop():new Ie)._source=e,_._dest=t,_._offsetScale=r,_._shader=i,_._shaderData=a,_._subShader=n,_._screenType=s,_._commandBuffer=o,_._drawDefineCavans=l,_}run(){var e;if(this._source)e=this._source;else{if(!this._commandBuffer._camera._internalRenderTexture)throw"camera internalRenderTexture is null,please set camera enableBuiltInRenderTexture";e=this._commandBuffer._camera._internalRenderTexture}var r=this._shader||Ae._screenShader,i=this._shaderData||Ae._screenShaderData,a=this._dest?this._dest:this._drawDefineCavans?this._dest:this._commandBuffer._camera._internalRenderTexture;t.LayaGL.instance.viewport(0,0,a?a.width:_e.clientWidth,a?a.height:_e.clientHeight),i.setTexture(Ae.SCREENTEXTURE_ID,e),i.setVector(Ae.SCREENTEXTUREOFFSETSCALE_ID,this._offsetScale||Ie._defaultOffsetScale),this._sourceTexelSize.setValue(1/e.width,1/e.height,e.width,e.height),i.setVector(Ae.MAINTEXTURE_TEXELSIZE_ID,this._sourceTexelSize),he.currentActive&&he.currentActive._end(),a&&a._start();for(var n=r.getSubShaderAt(this._subShader)._passes,s=0,o=n.length;s0?De._pool.pop():new De)._renderTexture=e,t}run(){he.currentActive&&he.currentActive._end(),t.LayaGL.instance.viewport(0,0,this._renderTexture.width,this._renderTexture.height),this._renderTexture._start()}recover(){De._pool.push(this),this._renderTexture=null}}De._pool=[],(o=e.ShaderDataType||(e.ShaderDataType={}))[o.Int=0]="Int",o[o.Bool=1]="Bool",o[o.Number=2]="Number",o[o.Vector2=3]="Vector2",o[o.Vector3=4]="Vector3",o[o.Vector4=5]="Vector4",o[o.Quaternion=6]="Quaternion",o[o.Matrix4x4=7]="Matrix4x4",o[o.Buffer=8]="Buffer",o[o.Texture=9]="Texture";class Me extends Ae{constructor(){super(...arguments),this._shaderData=null,this._nameID=0,this._value=null,this._dataType=-1}static create(e,t,r,i,a){var n;return(n=Me._pool.length>0?Me._pool.pop():new Me)._shaderData=e,n._nameID=t,n._value=r,n._dataType=i,n._commandBuffer=a,n}run(){switch(this._dataType){case e.ShaderDataType.Int:this._shaderData.setInt(this._nameID,this._value);break;case e.ShaderDataType.Number:this._shaderData.setNumber(this._nameID,this._value);break;case e.ShaderDataType.Bool:this._shaderData.setBool(this._nameID,this._value);break;case e.ShaderDataType.Matrix4x4:this._shaderData.setMatrix4x4(this._nameID,this._value);break;case e.ShaderDataType.Quaternion:this._shaderData.setQuaternion(this._nameID,this._value);break;case e.ShaderDataType.Texture:this._shaderData.setTexture(this._nameID,this._value);break;case e.ShaderDataType.Vector4:this._shaderData.setVector(this._nameID,this._value);break;case e.ShaderDataType.Vector2:this._shaderData.setVector2(this._nameID,this._value);break;case e.ShaderDataType.Vector3:this._shaderData.setVector3(this._nameID,this._value);break;case e.ShaderDataType.Buffer:this._shaderData.setBuffer(this._nameID,this._value);break;default:throw"no type shaderValue on this CommendBuffer"}}recover(){Me._pool.push(this),this._shaderData=null,this._nameID=0,this._value=null,this._dataType=-1}}Me._pool=[];class Ce extends t.Node{constructor(e=null,t=!1){super(),this._needProcessCollisions=!1,this._needProcessTriggers=!1,this._id=++Ce._uniqueIDCounter,this._transform=new I(this),this._isStatic=t,this.layer=0,this.name=e||"New Sprite3D"}static __init__(){}static instantiate(e,t=null,r=!0,i=null,a=null){var n=e.clone();t&&t.addChild(n);var s=n.transform;if(r){var o=s.worldMatrix;e.transform.worldMatrix.cloneTo(o),s.worldMatrix=o}else i&&(s.position=i),a&&(s.rotation=a);return n}static load(e,r){t.Laya.loader.create(e,r,null,Ce.HIERARCHY)}get id(){return this._id}get layer(){return this._layer}set layer(e){if(this._layer!==e){if(!(e>=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(le);if(i&&(i.avatar||e._changeAnimatorToLinkSprite3DNoAvatar(i,t,r)),this._parent&&this._parent instanceof Ce){r.unshift(this._parent.name);var a=this._parent;a._hierarchyAnimator&&a._changeAnimatorsToLinkSprite3D(e,t,r)}}_setHierarchyAnimator(e,t){this._changeHierarchyAnimator(e),this._changeAnimatorAvatar(e.avatar);for(var r=0,i=this._children.length;r0?ye._pool.pop():new ye)._mesh=e,s._matrix=t,s._material=r,s._subMeshIndex=i,s._subShaderIndex=a,s._commandBuffer=n,s}run(){var e=this._material._shader.getSubShaderAt(this._subShaderIndex);this.setContext(this._commandBuffer._context);var t=this._context,r=t.invertY,i=t.scene,a=t.cameraShaderValue,n=t.projectionViewMatrix;R.multiply(n,this._matrix,this._projectionViewWorldMatrix),this._renderShaderValue.setMatrix4x4(Ce.WORLDMATRIX,this._matrix),this._renderShaderValue.setMatrix4x4(Ce.MVPMATRIX,this._projectionViewWorldMatrix);for(var s=t.pipelineMode,o=e._passes,l=0,_=o.length;l<_;l++){var h=o[l];if(h._pipelineMode===s){var c=ye._compileDefine;i._shaderValues._defineDatas.cloneTo(c),c.addDefineDatas(this._renderShaderValue._defineDatas),c.addDefineDatas(this._material._shaderValues._defineDatas);var d=t.shader=h.withCompile(c);d.bind(),d.uploadUniforms(d._sceneUniformParamsMap,i._shaderValues,!0),d.uploadUniforms(d._spriteUniformParamsMap,this._renderShaderValue,!0),d.uploadUniforms(d._cameraUniformParamsMap,a,!0);var u=this._material._shaderValues;d.uploadUniforms(d._materialUniformParamsMap,u,!0),d.uploadRenderStateBlendDepth(u),d.uploadRenderStateFrontFace(u,r,this._matrix.getInvertFront())}}var m,f=this._mesh._subMeshes;if(-1==this._subMeshIndex)for(var T=0,E=f.length;T0?Le._pool.pop():new Le)._clearColor=e,n._clearDepth=t,r.cloneTo(n._backgroundColor),n._depth=i,n._commandBuffer=a,n}run(){var e,r=t.LayaGL.instance,i=this._backgroundColor;this._clearColor&&(r.clearColor(i.x,i.y,i.z,i.w),e|=r.COLOR_BUFFER_BIT),this._clearDepth&&(r.clearDepth(this._depth),e|=r.DEPTH_BUFFER_BIT),(this._clearColor||this._clearDepth)&&r.clear(e)}recover(){}}Le._pool=[];class Oe{constructor(){this.updateMark=-1,this.pointLightCount=0,this.spotLightCount=0,this.indices=[]}}class Ne{constructor(e,t,r,a){this._updateMark=0,this._depthSliceParam=new i,this._xSlices=e,this._ySlices=t,this._zSlices=r;var n=e*t,s=r*(1+Math.ceil(a/4));this._clusterTexture=H._createFloatTextureBuffer(n,s),this._clusterTexture.lock=!0,this._clusterPixels=new Float32Array(n*s*4);for(var o=new Array(this._zSlices),l=0;ll*l))return!1;var _=n.dot(s,t);return!(Math.cos(i)*Math.sqrt(o-_*_)-_*Math.sin(i)>l||_>l+r||_<-l)}_placePointLightToClusters(e,t){for(var r=this._clusterDatas,i=this._updateMark,a=t.zMin,n=t.zMax;at||o<=e)return!1;var l=this._depthSliceParam;return a.zMin=Math.floor(Math.log2(Math.max(s,e))*l.x-l.y),a.zMax=Math.min(Math.ceil(Math.log2(o)*l.x-l.y),this._zSlices),!0}_shrinkSpotLightZPerspective(e,t,r,i,a,n,s){var o=i.x,l=i.y,_=i.z,h=Math.tan(n)*a,c=r.x,d=r.y,u=r.z,m=o-c,f=l-d,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-a),S=Math.min(Math.max(u,_+p*h),r.z+a);if(g>t||S<=e)return!1;var R=this._depthSliceParam;return s.zMin=Math.floor(Math.log2(Math.max(g,e))*R.x-R.y),s.zMax=Math.min(Math.ceil(Math.log2(S)*R.x-R.y),this._zSlices),!0}_shrinkSphereLightByBoundOrth(e,t,r,i,a,n,s){var o=a.z,l=o-n,_=o+n;if(l>i||_<=r)return!1;var h=a.x,c=h-n,d=h+n;if(c>e||d<=-e)return!1;var u=a.y,m=u-n,f=u+n;if(m>t||f<=-t)return!1;var 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,a,n,s,o,l){var _=n.x,h=n.y,c=n.z,d=Math.tan(o)*s,u=a.x,m=a.y,f=a.z,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),a.z-s),v=Math.min(Math.max(f,c+S*d),a.z+s);if(R>i||v<=r)return!1;var x=Math.sqrt(1-T*T/g),A=Math.max(Math.min(u,_-x*d),a.x-s),I=Math.min(Math.max(u,_+x*d),a.x+s);if(A>e||I<=-e)return!1;var D=Math.sqrt(1-E*E/g),M=Math.max(Math.min(m,h-D*d),a.y-s),C=Math.min(Math.max(m,h+D*d),a.y+s);if(M>t||C<=-t)return!1;var y=this._xSlices,L=this._ySlices,O=this._depthSliceParam,N=2*e/y,P=2*t/L;return l.xMin=Math.max(Math.floor((A+e)/N),0),l.xMax=Math.min(Math.ceil((I+e)/N),y),l.yMin=Math.max(Math.floor((t-C)/P),0),l.yMax=Math.min(Math.ceil((t-M)/P),L),l.zMin=Math.floor(Math.log2(Math.max(R,r))*O.x-O.y),l.zMax=Math.min(Math.ceil(Math.log2(v)*O.x-O.y),this._zSlices),!0}_shrinkXYByRadiusPerspective(e,t,r,i,a){var n,s,o,l,_,h=e.x,c=e.y,d=e.z,u=this._ySlices+1;for(_=0;_0){for(var p=this._xSlices,g=this._ySlices,S=this._zSlices,R=p*g*4,v=R*S,x=this._clusterPixels,A=x.length,I=this._clusterDatas,D=this._updateMark,M=!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,a=i.x,n=i.y,s=i.z,o=e.max,l=o.x,_=o.y,h=o.z,c=t.min,d=c.x,u=c.y,m=c.z,f=t.max,T=f.x,E=f.y,p=f.z,g=0;return a>T?g+=(r=a-T)*r:d>l&&(g+=(r=d-l)*r),n>E?g+=(r=n-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(n.distanceSquared(e.center,t));return r-=e.radius,Math.max(r,0)}static distanceSphereToSphere(e,t){var r=Math.sqrt(n.distanceSquared(e.center,t.center));return r-=e.radius+t.radius,Math.max(r,0)}static intersectsRayAndTriangleRD(e,t,i,a,n){var s=e.origin,o=s.x,l=s.y,_=s.z,h=e.direction,c=h.x,d=h.y,u=h.z,m=t.x,f=t.y,T=t.z,E=i.x,p=i.y,g=i.z,S=a.x,R=a.y,v=a.z,x=Ve._tempV30.x,A=Ve._tempV30.y,I=Ve._tempV30.z;x=E-m,A=p-f,I=g-T;var D=Ve._tempV31.x,M=Ve._tempV31.y,C=Ve._tempV31.z;D=S-m,M=R-f,C=v-T;var y=Ve._tempV32.x,L=Ve._tempV32.y,O=Ve._tempV32.z,N=x*(y=d*C-u*M)+A*(L=u*D-c*C)+I*(O=c*M-d*D);if(r.isZero(N))return!1;var P=1/N,b=Ve._tempV33.x,w=Ve._tempV33.y,V=Ve._tempV33.z,B=(b=o-m)*y+(w=l-f)*L+(V=_-T)*O;if((B*=P)<0||B>1)return!1;var F=Ve._tempV34.x,U=Ve._tempV34.y,G=Ve._tempV34.z,z=c*(F=w*I-V*A)+d*(U=V*x-b*I)+u*(G=b*A-w*x);if((z*=P)<0||B+z>1)return!1;var H=D*F+M*U+C*G;return!((H*=P)<0)}static intersectsRayAndTriangleRP(e,t,r,i,a){return Ve.intersectsRayAndTriangleRD(e,t,r,i,void 0)?(n.scale(e.direction,void 0,Ve._tempV30),n.add(e.origin,Ve._tempV30,a),!0):(a=n._ZERO,!1)}static intersectsRayAndPoint(e,t){n.subtract(e.origin,t,Ve._tempV30);var i=n.dot(Ve._tempV30,e.direction),a=n.dot(Ve._tempV30,Ve._tempV30)-r.zeroTolerance;return!(a>0&&i>0)&&!(i*i-a<0)}static intersectsRayAndRay(e,t,i){var a=e.origin,s=a.x,o=a.y,l=a.z,_=e.direction,h=_.x,c=_.y,d=_.z,u=t.origin,m=u.x,f=u.y,T=u.z,E=t.direction,p=E.x,g=E.y,S=E.z;n.cross(_,E,Ve._tempV30);var R=Ve._tempV30,v=n.scalarLength(Ve._tempV30);if(r.isZero(v)&&r.nearEqual(m,s)&&r.nearEqual(f,o)&&r.nearEqual(T,l))return!0;v*=v;var x=m-s,A=f-o,I=T-l,D=p,M=g,C=S,y=R.x,L=R.y,O=R.z,N=x*M*O+A*C*y+I*D*L-x*C*L-A*D*O-I*M*y;D=h,M=c,C=d;var P=N/v;n.scale(_,P,Ve._tempV30),n.scale(E,P,Ve._tempV31),n.add(a,Ve._tempV30,Ve._tempV32),n.add(u,Ve._tempV31,Ve._tempV33);var b=Ve._tempV32,w=Ve._tempV33;return!!(r.nearEqual(w.x,b.x)&&r.nearEqual(w.y,b.y)&&r.nearEqual(w.z,b.z))}static intersectsPlaneAndTriangle(e,t,r,i){var a=Ve.intersectsPlaneAndPoint(e,t),n=Ve.intersectsPlaneAndPoint(e,r),s=Ve.intersectsPlaneAndPoint(e,i);return a==Pe.PlaneIntersectionType_Front&&n==Pe.PlaneIntersectionType_Front&&s==Pe.PlaneIntersectionType_Front?Pe.PlaneIntersectionType_Front:a==Pe.PlaneIntersectionType_Back&&n==Pe.PlaneIntersectionType_Back&&s==Pe.PlaneIntersectionType_Back?Pe.PlaneIntersectionType_Back:Pe.PlaneIntersectionType_Intersecting}static intersectsRayAndPlaneRD(e,t){var i=t.normal,a=n.dot(i,e.direction);if(Math.abs(a)T)return-1}else{var R=1/l,v=(d-a)*R,x=(T-a)*R;if(v>x){var A=v;v=x,x=A}if((g=Math.max(v,g))>(S=Math.min(x,S)))return-1}if(r.isZero(_)){if(nE)return-1}else{var I=1/_,D=(u-n)*I,M=(E-n)*I;if(D>M){var C=D;D=M,M=C}if((g=Math.max(D,g))>(S=Math.min(M,S)))return-1}if(r.isZero(h)){if(sp)return-1}else{var y=1/h,L=(m-s)*y,O=(p-s)*y;if(L>O){var N=L;L=O,O=N}if((g=Math.max(L,g))>(S=Math.min(O,S)))return-1}return g}static intersectsRayAndBoxRP(e,t,r){var i=Ve.intersectsRayAndBoxRD(e,t);return-1===i?(n._ZERO.cloneTo(r),i):(n.scale(e.direction,i,Ve._tempV30),n.add(e.origin,Ve._tempV30,Ve._tempV31),Ve._tempV31.cloneTo(r),i)}static intersectsRayAndSphereRD(e,t){var r=t.radius;n.subtract(e.origin,t.center,Ve._tempV30);var i=n.dot(Ve._tempV30,e.direction),a=n.dot(Ve._tempV30,Ve._tempV30)-r*r;if(a>0&&i>0)return-1;var s=i*i-a;if(s<0)return-1;var o=-i-Math.sqrt(s);return o<0&&(o=0),o}static intersectsRayAndSphereRP(e,t,r){var i=Ve.intersectsRayAndSphereRD(e,t);return-1===i?(n._ZERO.cloneTo(r),i):(n.scale(e.direction,i,Ve._tempV30),n.add(e.origin,Ve._tempV30,Ve._tempV31),Ve._tempV31.cloneTo(r),i)}static intersectsSphereAndTriangle(e,t,r,i){var a=e.center,s=e.radius;return Ve.closestPointPointTriangle(a,t,r,i,Ve._tempV30),n.subtract(Ve._tempV30,a,Ve._tempV31),n.dot(Ve._tempV31,Ve._tempV31)<=s*s}static intersectsPlaneAndPoint(e,t){var r=n.dot(e.normal,t)+e.distance;return r>0?Pe.PlaneIntersectionType_Front:r<0?Pe.PlaneIntersectionType_Back:Pe.PlaneIntersectionType_Intersecting}static intersectsPlaneAndPlane(e,t){n.cross(e.normal,t.normal,Ve._tempV30);var i=n.dot(Ve._tempV30,Ve._tempV30);return!r.isZero(i)}static intersectsPlaneAndPlaneRL(e,t,i){var a=e.normal,s=t.normal;n.cross(a,s,Ve._tempV34);var o=n.dot(Ve._tempV34,Ve._tempV34);return!r.isZero(o)&&(n.scale(s,e.distance,Ve._tempV30),n.scale(a,t.distance,Ve._tempV31),n.subtract(Ve._tempV30,Ve._tempV31,Ve._tempV32),n.cross(Ve._tempV32,Ve._tempV34,Ve._tempV33),n.normalize(Ve._tempV34,Ve._tempV34),!0)}static intersectsPlaneAndBox(e,t){var r=e.distance,i=e.normal,a=i.x,s=i.y,o=i.z,l=t.min,_=l.x,h=l.y,c=l.z,d=t.max,u=d.x,m=d.y,f=d.z;Ve._tempV30.x=a>0?_:u,Ve._tempV30.y=s>0?h:m,Ve._tempV30.z=o>0?c:f,Ve._tempV31.x=a>0?u:_,Ve._tempV31.y=s>0?m:h,Ve._tempV31.z=o>0?f:c;var T=n.dot(i,Ve._tempV30);return T+r>0?Pe.PlaneIntersectionType_Front:(T=n.dot(i,Ve._tempV31))+r<0?Pe.PlaneIntersectionType_Back:Pe.PlaneIntersectionType_Intersecting}static intersectsPlaneAndSphere(e,t){var r=t.radius,i=n.dot(e.normal,t.center)+e.distance;return i>r?Pe.PlaneIntersectionType_Front:i<-r?Pe.PlaneIntersectionType_Back:Pe.PlaneIntersectionType_Intersecting}static intersectsBoxAndBox(e,t){var r=e.min,i=e.max,a=t.min,n=t.max;return!(r.x>n.x||a.x>i.x)&&(!(r.y>n.y||a.y>i.y)&&!(r.z>n.z||a.z>i.z))}static intersectsBoxAndSphere(e,t){var r=t.center,i=t.radius,a=Ve._tempV30;return n.Clamp(r,e.min,e.max,a),n.distanceSquared(r,a)<=i*i}static intersectsSphereAndSphere(e,t){var r=e.radius+t.radius;return n.distanceSquared(e.center,t.center)<=r*r}static boxContainsPoint(e,t){var r=e.min,i=e.max;return r.x<=t.x&&i.x>=t.x&&r.y<=t.y&&i.y>=t.y&&r.z<=t.z&&i.z>=t.z?we.Contains:we.Disjoint}static boxContainsBox(e,t){var r=e.min,i=r.x,a=r.y,n=r.z,s=e.max,o=s.x,l=s.y,_=s.z,h=t.min,c=h.x,d=h.y,u=h.z,m=t.max,f=m.x,T=m.y,E=m.z;return of?we.Disjoint:lT?we.Disjoint:_E?we.Disjoint:i<=c&&f<=o&&a<=d&&T<=l&&n<=u&&E<=_?we.Contains:we.Intersects}static boxContainsSphere(e,t){var r=e.min,i=r.x,a=r.y,s=r.z,o=e.max,l=o.x,_=o.y,h=o.z,c=t.center,d=c.x,u=c.y,m=c.z,f=t.radius;return n.Clamp(c,r,o,Ve._tempV30),n.distanceSquared(c,Ve._tempV30)>f*f?we.Disjoint:i+f<=d&&d<=l-f&&l-i>f&&a+f<=u&&u<=_-f&&_-a>f&&s+f<=m&&m<=h-f&&h-s>f?we.Contains:we.Intersects}static sphereContainsPoint(e,t){return n.distanceSquared(t,e.center)<=e.radius*e.radius?we.Contains:we.Disjoint}static sphereContainsTriangle(e,t,r,i){var a=Ve.sphereContainsPoint(e,t),n=Ve.sphereContainsPoint(e,r),s=Ve.sphereContainsPoint(e,i);return a==we.Contains&&n==we.Contains&&s==we.Contains?we.Contains:Ve.intersectsSphereAndTriangle(e,t,r,i)?we.Intersects:we.Disjoint}static sphereContainsBox(e,t){var r=e.center,i=r.x,a=r.y,s=r.z,o=e.radius,l=t.min,_=l.x,h=l.y,c=l.z,d=t.max,u=d.x,m=d.y,f=d.z,T=Ve._tempV30;T.x,T.y,T.z;if(!Ve.intersectsBoxAndSphere(t,e))return we.Disjoint;var E=o*o;return i-_,a-m,s-f,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:(i-u,a-m,s-f,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:(i-u,a-h,s-f,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:(i-_,a-h,s-f,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:(i-_,a-m,s-c,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:(i-u,a-m,s-c,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:(i-u,a-h,s-c,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:(i-_,a-h,s-c,n.scalarLengthSquared(Ve._tempV30)>E?we.Intersects:we.Contains)))))))}static sphereContainsSphere(e,t){var r=e.radius,i=t.radius,a=n.distance(e.center,t.center);return r+i=0&&_<=l)r.cloneTo(a);else{var d=s*_-l*o;if(d<=0&&s>=0&&l<=0){var u=s/(s-l);return n.scale(Ve._tempV30,u,a),void n.add(t,a,a)}if(c>=0&&h<=c)i.cloneTo(a);else{var m=h*o-s*c;if(m<=0&&o>=0&&c<=0){var f=o/(o-c);return n.scale(Ve._tempV31,f,a),void n.add(t,a,a)}var T=l*c-h*_;if(T<=0&&_-l>=0&&h-c>=0){var E=(_-l)/(_-l+(h-c));return n.subtract(i,r,a),n.scale(a,E,a),void n.add(r,a,a)}var p=1/(T+m+d),g=m*p,S=d*p;n.scale(Ve._tempV30,g,Ve._tempV35),n.scale(Ve._tempV31,S,Ve._tempV36),n.add(Ve._tempV35,Ve._tempV36,a),n.add(t,a,a)}}}static closestPointPlanePoint(e,t,r){var i=e.normal,a=n.dot(i,t)-e.distance;n.scale(i,a,Ve._tempV30),n.subtract(t,Ve._tempV30,r)}static closestPointBoxPoint(e,t,r){n.max(t,e.min,Ve._tempV30),n.min(Ve._tempV30,e.max,r)}static closestPointSpherePoint(e,t,r){var i=e.center;n.subtract(t,i,r),n.normalize(r,r),n.scale(r,e.radius,r),n.add(r,i,r)}static closestPointSphereSphere(e,t,r){var i=e.center;n.subtract(t.center,i,r),n.normalize(r,r),n.scale(r,e.radius,r),n.add(r,i,r)}}Ve._tempV30=new n,Ve._tempV31=new n,Ve._tempV32=new n,Ve._tempV33=new n,Ve._tempV34=new n,Ve._tempV35=new n,Ve._tempV36=new n,(l=e.FrustumCorner||(e.FrustumCorner={}))[l.FarBottomLeft=0]="FarBottomLeft",l[l.FarTopLeft=1]="FarTopLeft",l[l.FarTopRight=2]="FarTopRight",l[l.FarBottomRight=3]="FarBottomRight",l[l.nearBottomLeft=4]="nearBottomLeft",l[l.nearTopLeft=5]="nearTopLeft",l[l.nearTopRight=6]="nearTopRight",l[l.nearBottomRight=7]="nearBottomRight",l[l.unknown=8]="unknown";class Be{constructor(e){this._matrix=e,this._near=new Pe(new n),this._far=new Pe(new n),this._left=new Pe(new n),this._right=new Pe(new n),this._top=new Pe(new n),this._bottom=new Pe(new n),Be.getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}static getPlanesFromMatrix(e,t,r,i,a,n,s){var o=e.elements,l=o[0],_=o[1],h=o[2],c=o[3],d=o[4],u=o[5],m=o[6],f=o[7],T=o[8],E=o[9],p=o[10],g=o[11],S=o[12],R=o[13],v=o[14],x=o[15],A=t.normal;A.x=h,A.y=m,A.z=p,t.distance=v,t.normalize();var I=r.normal;I.x=c-h,I.y=f-m,I.z=g-p,r.distance=x-v,r.normalize();var D=i.normal;D.x=c+l,D.y=f+d,D.z=g+T,i.distance=x+S,i.normalize();var M=a.normal;M.x=c-l,M.y=f-d,M.z=g-T,a.distance=x-S,a.normalize();var C=n.normal;C.x=c-_,C.y=f-u,C.z=g-E,n.distance=x-R,n.normalize();var y=s.normal;y.x=c+_,y.y=f+u,y.z=g+E,s.distance=x+R,s.normalize()}get matrix(){return this._matrix}set matrix(e){e.cloneTo(this._matrix),Be.getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get near(){return this._near}get far(){return this._far}get left(){return this._left}get right(){return this._right}get top(){return this._top}get bottom(){return this._bottom}equalsBoundFrustum(e){return this._matrix.equalsOtherMatrix(e.matrix)}equalsObj(e){if(e instanceof Be){var t=e;return this.equalsBoundFrustum(t)}return!1}getPlane(e){switch(e){case 0:return this._near;case 1:return this._far;case 2:return this._left;case 3:return this._right;case 4:return this._top;case 5:return this._bottom;default:return null}}static get3PlaneInterPoint(e,t,r,i){var a=e.normal,s=t.normal,o=r.normal;n.cross(s,o,Be._tempV30),n.cross(o,a,Be._tempV31),n.cross(a,s,Be._tempV32);var l=n.dot(a,Be._tempV30),_=n.dot(s,Be._tempV31),h=n.dot(o,Be._tempV32);n.scale(Be._tempV30,-e.distance/l,Be._tempV33),n.scale(Be._tempV31,-t.distance/_,Be._tempV34),n.scale(Be._tempV32,-r.distance/h,Be._tempV35),n.add(Be._tempV33,Be._tempV34,Be._tempV36),n.add(Be._tempV35,Be._tempV36,i)}getCorners(t){Be.get3PlaneInterPoint(this._near,this._bottom,this._right,t[e.FrustumCorner.nearBottomRight]),Be.get3PlaneInterPoint(this._near,this._top,this._right,t[e.FrustumCorner.nearTopRight]),Be.get3PlaneInterPoint(this._near,this._top,this._left,t[e.FrustumCorner.nearTopLeft]),Be.get3PlaneInterPoint(this._near,this._bottom,this._left,t[e.FrustumCorner.nearBottomLeft]),Be.get3PlaneInterPoint(this._far,this._bottom,this._right,t[e.FrustumCorner.FarBottomRight]),Be.get3PlaneInterPoint(this._far,this._top,this._right,t[e.FrustumCorner.FarTopRight]),Be.get3PlaneInterPoint(this._far,this._top,this._left,t[e.FrustumCorner.FarTopLeft]),Be.get3PlaneInterPoint(this._far,this._bottom,this._left,t[e.FrustumCorner.FarBottomLeft])}containsPoint(e){for(var t=Pe.PlaneIntersectionType_Front,r=Pe.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=Ve.intersectsPlaneAndPoint(this._near,e);break;case 1:r=Ve.intersectsPlaneAndPoint(this._far,e);break;case 2:r=Ve.intersectsPlaneAndPoint(this._left,e);break;case 3:r=Ve.intersectsPlaneAndPoint(this._right,e);break;case 4:r=Ve.intersectsPlaneAndPoint(this._top,e);break;case 5:r=Ve.intersectsPlaneAndPoint(this._bottom,e)}switch(r){case Pe.PlaneIntersectionType_Back:return we.Disjoint;case Pe.PlaneIntersectionType_Intersecting:t=Pe.PlaneIntersectionType_Intersecting}}switch(t){case Pe.PlaneIntersectionType_Intersecting:return we.Intersects;default:return we.Contains}}intersects(e){var t=e.min,r=e.max,i=t.x,a=t.y,n=t.z,s=r.x,o=r.y,l=r.z,_=this._near.normal;if(this._near.distance+_.x*(_.x<0?i:s)+_.y*(_.y<0?a:o)+_.z*(_.z<0?n:l)<0)return!1;var h=this._left.normal;if(this._left.distance+h.x*(h.x<0?i:s)+h.y*(h.y<0?a:o)+h.z*(h.z<0?n:l)<0)return!1;var c=this._right.normal;if(this._right.distance+c.x*(c.x<0?i:s)+c.y*(c.y<0?a:o)+c.z*(c.z<0?n:l)<0)return!1;var d=this._bottom.normal;if(this._bottom.distance+d.x*(d.x<0?i:s)+d.y*(d.y<0?a:o)+d.z*(d.z<0?n:l)<0)return!1;var u=this._top.normal;if(this._top.distance+u.x*(u.x<0?i:s)+u.y*(u.y<0?a:o)+u.z*(u.z<0?n:l)<0)return!1;var m=this._far.normal;return!(this._far.distance+m.x*(m.x<0?i:s)+m.y*(m.y<0?a:o)+m.z*(m.z<0?n:l)<0)}containsBoundBox(e){for(var t=Be._tempV30,r=Be._tempV31,i=e.min,a=e.max,n=we.Contains,s=0;s<6;s++){var o=this.getPlane(s),l=o.normal;if(l.x>=0?(t.x=a.x,r.x=i.x):(t.x=i.x,r.x=a.x),l.y>=0?(t.y=a.y,r.y=i.y):(t.y=i.y,r.y=a.y),l.z>=0?(t.z=a.z,r.z=i.z):(t.z=i.z,r.z=a.z),Ve.intersectsPlaneAndPoint(o,t)===Pe.PlaneIntersectionType_Back)return we.Disjoint;Ve.intersectsPlaneAndPoint(o,r)===Pe.PlaneIntersectionType_Back&&(n=we.Intersects)}return n}containsBoundSphere(e){for(var t=Pe.PlaneIntersectionType_Front,r=Pe.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=Ve.intersectsPlaneAndSphere(this._near,e);break;case 1:r=Ve.intersectsPlaneAndSphere(this._far,e);break;case 2:r=Ve.intersectsPlaneAndSphere(this._left,e);break;case 3:r=Ve.intersectsPlaneAndSphere(this._right,e);break;case 4:r=Ve.intersectsPlaneAndSphere(this._top,e);break;case 5:r=Ve.intersectsPlaneAndSphere(this._bottom,e)}switch(r){case Pe.PlaneIntersectionType_Back:return we.Disjoint;case Pe.PlaneIntersectionType_Intersecting:t=Pe.PlaneIntersectionType_Intersecting}}switch(t){case Pe.PlaneIntersectionType_Intersecting:return we.Intersects;default:return we.Contains}}}Be._tempV30=new n,Be._tempV31=new n,Be._tempV32=new n,Be._tempV33=new n,Be._tempV34=new n,Be._tempV35=new n,Be._tempV36=new n;class Fe{constructor(e,t,r,i){this.minDepth=0,this.maxDepth=1,this.x=e,this.y=t,this.width=r,this.height=i}project(e,t,r){n.transformV3ToV4(e,t,r);var i=r.x,a=r.y,s=r.z,o=r.w;1!==o&&(i/=o,a/=o,s/=o),r.x=.5*(i+1)*this.width+this.x,r.y=.5*(1-a)*this.height+this.y,r.z=s*(this.maxDepth-this.minDepth)+this.minDepth}unprojectFromMat(e,t,r){var i=t.elements;r.x=(e.x-this.x)/this.width*2-1,r.y=-((e.y-this.y)/this.height*2-1),r.z=(e.z-this.minDepth)/(this.maxDepth-this.minDepth);var a=r.x*i[3]+r.y*i[7]+r.z*i[11]+i[15];n.transformV3ToV3(r,t,r),1!==a&&(r.x=r.x/a,r.y=r.y/a,r.z=r.z/a)}unprojectFromWVP(e,t,r,i,a){R.multiply(t,r,Fe._tempMatrix4x4),i&&R.multiply(Fe._tempMatrix4x4,i,Fe._tempMatrix4x4),Fe._tempMatrix4x4.invert(Fe._tempMatrix4x4),this.unprojectFromMat(e,Fe._tempMatrix4x4,a)}cloneTo(e){e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e.minDepth=this.minDepth,e.maxDepth=this.maxDepth}}Fe._tempMatrix4x4=new R;class Ue{constructor(){}static calculateCursorRay(e,t,r,i,a,s){var o=e.x,l=e.y,_=Ue._tempVector30,h=_;h.x=o,h.y=l,h.z=t.minDepth;var c=Ue._tempVector31,d=c;d.x=o,d.y=l,d.z=t.maxDepth;var u=s.origin,m=Ue._tempVector32;t.unprojectFromWVP(_,r,i,a,u),t.unprojectFromWVP(c,r,i,a,m);var f=s.direction;f.x=m.x-u.x,f.y=m.y-u.y,f.z=m.z-u.z,n.normalize(s.direction,s.direction)}static rayIntersectsTriangle(e,t,r,i){var a=Ue._tempVector30,s=Ue._tempVector31;n.subtract(r,t,a),n.subtract(i,t,s);var o,l=Ue._tempVector32;if(n.cross(e.direction,s,l),(o=n.dot(a,l))>-Number.MIN_VALUE&&o1)return Number.NaN;var d,u,m=Ue._tempVector34;return n.cross(c,a,m),d=n.dot(e.direction,m),(d*=h)<0||_+d>1?Number.NaN:(u=n.dot(s,m),(u*=h)<0?Number.NaN:u)}}Ue._tempVector30=new n,Ue._tempVector31=new n,Ue._tempVector32=new n,Ue._tempVector33=new n,Ue._tempVector34=new n,(_=e.IndexFormat||(e.IndexFormat={}))[_.UInt8=0]="UInt8",_[_.UInt16=1]="UInt16",_[_.UInt32=2]="UInt32";class Ge extends t.Buffer{constructor(r,i,a=35044,n=!1){switch(super(),this._indexType=r,this._indexCount=i,this._bufferUsage=a,this._bufferType=t.LayaGL.instance.ELEMENT_ARRAY_BUFFER,this._canRead=n,r){case e.IndexFormat.UInt32:this._indexTypeByteCount=4;break;case e.IndexFormat.UInt16:this._indexTypeByteCount=2;break;case e.IndexFormat.UInt8:this._indexTypeByteCount=1;break;default:throw new Error("unidentification index type.")}var s=this._indexTypeByteCount*i,o=t.BufferStateBase._curBindedBufferState;if(this._byteLength=s,o?o._bindedIndexBuffer===this?t.LayaGL.instance.bufferData(this._bufferType,s,this._bufferUsage):(o.unBind(),this.bind(),t.LayaGL.instance.bufferData(this._bufferType,s,this._bufferUsage),o.bind()):(this.bind(),t.LayaGL.instance.bufferData(this._bufferType,s,this._bufferUsage)),n)switch(r){case e.IndexFormat.UInt32:this._buffer=new Uint32Array(i);break;case e.IndexFormat.UInt16:this._buffer=new Uint16Array(i);break;case e.IndexFormat.UInt8:this._buffer=new Uint8Array(i)}}get indexType(){return this._indexType}get indexTypeByteCount(){return this._indexTypeByteCount}get indexCount(){return this._indexCount}get canRead(){return this._canRead}_bindForVAO(){if(!t.BufferStateBase._curBindedBufferState)throw"IndexBuffer3D: must bind current BufferState.";var e=t.LayaGL.instance;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._glBuffer)}bind(){if(t.BufferStateBase._curBindedBufferState)throw"IndexBuffer3D: must unbind current BufferState.";if(t.Buffer._bindedIndexBuffer!==this._glBuffer){var e=t.LayaGL.instance;return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._glBuffer),t.Buffer._bindedIndexBuffer=this._glBuffer,!0}return!1}setData(r,i=0,a=0,n=4294967295){var s=this._indexTypeByteCount;if(0!==a||4294967295!==n)switch(this._indexType){case e.IndexFormat.UInt32:r=new Uint32Array(r.buffer,a*s,n);break;case e.IndexFormat.UInt16:r=new Uint16Array(r.buffer,a*s,n);break;case e.IndexFormat.UInt8:r=new Uint8Array(r.buffer,a*s,n)}var o=t.BufferStateBase._curBindedBufferState;if(o?o._bindedIndexBuffer===this?t.LayaGL.instance.bufferSubData(this._bufferType,i*s,r):(o.unBind(),this.bind(),t.LayaGL.instance.bufferSubData(this._bufferType,i*s,r),o.bind()):(this.bind(),t.LayaGL.instance.bufferSubData(this._bufferType,i*s,r)),this._canRead)if(0!==i||0!==a||4294967295!==n){var l=this._buffer.length-i;n>l&&(n=l);for(var _=0;_e[t].renderingOrder){var i=e[r];e[r]=e[t],e[t]=i}}_calculateProjectionMatrix(){}_onScreenSizeChanged(){this._calculateProjectionMatrix()}_prepareCameraToRender(){var e=this._shaderValues;this.transform.getForward(this._forward),this.transform.getUp(this._up),e.setVector3(Xe.CAMERAPOS,this.transform.position),e.setVector3(Xe.CAMERADIRECTION,this._forward),e.setVector3(Xe.CAMERAUP,this._up)}render(e=null,t=null){}addLayer(e){this.cullingMask|=Math.pow(2,e)}removeLayer(e){this.cullingMask&=~Math.pow(2,e)}addAllLayers(){this.cullingMask=2147483647}removeAllLayers(){this.cullingMask=0}resetProjectionMatrix(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()}_onActive(){this._scene._addCamera(this),super._onActive()}_onInActive(){this._scene._removeCamera(this),super._onInActive()}_parse(e,r){super._parse(e,r),this.orthographic=e.orthographic,void 0!==e.orthographicVerticalSize&&(this.orthographicVerticalSize=e.orthographicVerticalSize),void 0!==e.fieldOfView&&(this.fieldOfView=e.fieldOfView),this.nearPlane=e.nearPlane,this.farPlane=e.farPlane;var i=e.clearColor;this.clearColor=new a(i[0],i[1],i[2],i[3]);var n=e.skyboxMaterial;n&&(this._skyRenderer.material=t.Loader.getRes(n.path))}destroy(e=!0){this._skyRenderer.destroy(),this._skyRenderer=null,t.Laya.stage.off(t.Event.RESIZE,this,this._onScreenSizeChanged),super.destroy(e)}_create(){return new Xe}}Xe._tempMatrix4x40=new R,Xe.CAMERAPOS=xe.propertyNameToID("u_CameraPos"),Xe.VIEWMATRIX=xe.propertyNameToID("u_View"),Xe.PROJECTMATRIX=xe.propertyNameToID("u_Projection"),Xe.VIEWPROJECTMATRIX=xe.propertyNameToID("u_ViewProjection"),Xe.CAMERADIRECTION=xe.propertyNameToID("u_CameraDirection"),Xe.CAMERAUP=xe.propertyNameToID("u_CameraUp"),Xe.VIEWPORT=xe.propertyNameToID("u_Viewport"),Xe.PROJECTION_PARAMS=xe.propertyNameToID("u_ProjectionParams"),Xe.DEPTHTEXTURE=xe.propertyNameToID("u_CameraDepthTexture"),Xe.DEPTHNORMALSTEXTURE=xe.propertyNameToID("u_CameraDepthNormalsTexture"),Xe.DEPTHZBUFFERPARAMS=xe.propertyNameToID("u_ZBufferParams"),Xe.SHADERDEFINE_DEPTH=xe.getDefineByName("DEPTHMAP"),Xe.SHADERDEFINE_DEPTHNORMALS=xe.getDefineByName("DEPTHNORMALSMAP"),Xe.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",Xe.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",Xe._invertYScaleMatrix=new R(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1),Xe._invertYProjectionMatrix=new R,Xe._invertYProjectionViewMatrix=new R,Xe.CLEARFLAG_SOLIDCOLOR=0,Xe.CLEARFLAG_SKY=1,Xe.CLEARFLAG_DEPTHONLY=2,Xe.CLEARFLAG_NONE=3,(h=e.ShadowMode||(e.ShadowMode={}))[h.None=0]="None",h[h.Hard=1]="Hard",h[h.SoftLow=2]="SoftLow",h[h.SoftHigh=3]="SoftHigh";class Ye{}(c=e.LightType||(e.LightType={}))[c.Directional=0]="Directional",c[c.Spot=1]="Spot",c[c.Point=2]="Point";class je extends Ce{constructor(){super(),this._shadowMode=e.ShadowMode.None,this._isAlternate=!1,this._shadowResolution=2048,this._shadowDistance=50,this._shadowDepthBias=1,this._shadowNormalBias=1,this._shadowNearPlane=.1,this._shadowStrength=1,this._lightWoldMatrix=new R,this._intensity=1,this._intensityColor=new n,this.color=new n(1,1,1),this._lightmapBakedType=je.LIGHTMAPBAKEDTYPE_REALTIME}get intensity(){return this._intensity}set intensity(e){this._intensity=e}get shadowMode(){return this._shadowMode}set shadowMode(e){this._shadowMode=e}get shadowDistance(){return this._shadowDistance}set shadowDistance(e){this._shadowDistance=e}get shadowResolution(){return this._shadowResolution}set shadowResolution(e){this._shadowResolution=e}get shadowDepthBias(){return this._shadowDepthBias}set shadowDepthBias(e){this._shadowDepthBias=e}get shadowNormalBias(){return this._shadowNormalBias}set shadowNormalBias(e){this._shadowNormalBias=e}get shadowStrength(){return this._shadowStrength}set shadowStrength(e){this._shadowStrength=e}get shadowNearPlane(){return this._shadowNearPlane}set shadowNearPlane(e){this._shadowNearPlane=e}get lightmapBakedType(){return this._lightmapBakedType}set lightmapBakedType(e){this._lightmapBakedType!==e&&(this._lightmapBakedType=e,this.activeInHierarchy&&(e!==je.LIGHTMAPBAKEDTYPE_BAKED?this._addToScene():this._removeFromScene()))}get lightWorldMatrix(){var e=this.transform.position,t=this.transform.rotation;return R.createAffineTransformation(e,t,n._ONE,this._lightWoldMatrix),this._lightWoldMatrix}_parse(e,t){super._parse(e,t);var r=e.color;this.color.fromArray(r),this.intensity=e.intensity,this.lightmapBakedType=e.lightmapBakedType}_cloneTo(e,t,r){super._cloneTo(e,t,r);var i=e;i.color=this.color.clone(),i.intensity=this.intensity,i.lightmapBakedType=this.lightmapBakedType}_addToScene(){var e=this._scene,t=j._config.maxLightCount;e._lightCount0){var t=e._alternateLights.shift();t._addToLightQueue(),t._isAlternate=!1,e._lightCount++}}_addToLightQueue(){}_removeFromLightQueue(){}_onActive(){super._onActive(),this.lightmapBakedType!==je.LIGHTMAPBAKEDTYPE_BAKED&&this._addToScene()}_onInActive(){super._onInActive(),this.lightmapBakedType!==je.LIGHTMAPBAKEDTYPE_BAKED&&this._removeFromScene()}_create(){return new je}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}}je.LIGHTMAPBAKEDTYPE_REALTIME=0,je.LIGHTMAPBAKEDTYPE_MIXED=1,je.LIGHTMAPBAKEDTYPE_BAKED=2,(d=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[d.NoCascades=0]="NoCascades",d[d.TwoCascades=1]="TwoCascades",d[d.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"}(u||(u={}));class Ze{static supportShadow(){return t.LayaGL.layaGPUInstance._isWebGL2||t.SystemUtils.supportRenderTextureFormat(t.RenderTextureFormat.Depth)}static init(){t.LayaGL.layaGPUInstance._isWebGL2?Ze._shadowTextureFormat=t.RenderTextureFormat.ShadowMap:Ze._shadowTextureFormat=t.RenderTextureFormat.Depth}static getTemporaryShadowTexture(e,r,i){var a=he.createFromPool(e,r,Ze._shadowTextureFormat,i);return a.filterMode=t.FilterMode.Bilinear,a.wrapModeU=t.WarpMode.Clamp,a.wrapModeV=t.WarpMode.Clamp,a}static getShadowBias(t,i,a,n){var s;t._lightType==e.LightType.Directional?s=2/i.elements[0]:t._lightType==e.LightType.Spot?s=Math.tan(.5*t.spotAngle*r.Deg2Rad)*t.range:(console.warn("ShadowUtils:Only spot and directional shadow casters are supported now."),s=0);var o=s/a,l=-t._shadowDepthBias*o,_=-t._shadowNormalBias*o;if(t.shadowMode==e.ShadowMode.SoftHigh){const e=2.5;l*=e,_*=e}n.setValue(l,_,0,0)}static getCameraFrustumPlanes(e,t){Be.getPlanesFromMatrix(e,t[u.Near],t[u.Far],t[u.Left],t[u.Right],t[u.Top],t[u.Bottom])}static getFarWithRadius(e,t){return Math.sqrt(e*e/t)}static getCascadesSplitDistance(t,r,i,a,n,s,o,l){l[0]=i;var _=a-i,h=Math.tan(.5*n),c=1+h*h*(s*s+1);switch(o){case e.ShadowCascadesMode.NoCascades:l[1]=Ze.getFarWithRadius(a,c);break;case e.ShadowCascadesMode.TwoCascades:l[1]=Ze.getFarWithRadius(i+_*t,c),l[2]=Ze.getFarWithRadius(a,c);break;case e.ShadowCascadesMode.FourCascades:l[1]=Ze.getFarWithRadius(i+_*r.x,c),l[2]=Ze.getFarWithRadius(i+_*r.y,c),l[3]=Ze.getFarWithRadius(i+_*r.z,c),l[4]=Ze.getFarWithRadius(a,c)}}static applySliceTransform(e,t,r,i,a){var n=Ze._tempMatrix0.elements,s=1/t,o=1/r;n[0]=e.resolution*s,n[5]=e.resolution*o,n[12]=e.offsetX*s,n[13]=e.offsetY*o,n[1]=n[2]=n[2]=n[4]=n[6]=n[7]=n[8]=n[9]=n[11]=n[14]=0,n[10]=n[15]=1;var l=16*i;H._mulMatrixArray(n,a,l,a,l)}static getDirectionLightShadowCullPlanes(t,r,i,a,s,o){var l=Ze._frustumCorners,_=Ze._backPlaneFaces,h=Ze._frustumPlaneNeighbors,c=Ze._frustumTwoPlaneCorners,d=Ze._edgePlanePoint2,m=o.cullPlanes,f=t[u.Near],T=t[u.Far],E=t[u.Left],p=t[u.Right],g=t[u.Bottom],S=t[u.Top],R=i[r]-a,v=Ze._adjustNearPlane,x=Ze._adjustFarPlane;f.normal.cloneTo(v.normal),T.normal.cloneTo(x.normal),v.distance=f.distance-R,x.distance=Math.min(-f.distance+o.sphereCenterZ+o.splitBoundSphere.radius,T.distance),Be.get3PlaneInterPoint(v,g,p,l[e.FrustumCorner.nearBottomRight]),Be.get3PlaneInterPoint(v,S,p,l[e.FrustumCorner.nearTopRight]),Be.get3PlaneInterPoint(v,S,E,l[e.FrustumCorner.nearTopLeft]),Be.get3PlaneInterPoint(v,g,E,l[e.FrustumCorner.nearBottomLeft]),Be.get3PlaneInterPoint(x,g,p,l[e.FrustumCorner.FarBottomRight]),Be.get3PlaneInterPoint(x,S,p,l[e.FrustumCorner.FarTopRight]),Be.get3PlaneInterPoint(x,S,E,l[e.FrustumCorner.FarTopLeft]),Be.get3PlaneInterPoint(x,g,E,l[e.FrustumCorner.FarBottomLeft]);for(var A=0,I=0;I<6;I++){var D;switch(I){case u.Near:D=v;break;case u.Far:D=x;break;default:D=t[I]}n.dot(D.normal,s)<0&&(D.cloneTo(m[A]),_[A]=I,A++)}var M=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=_,n.scale(s,l,m),n.add(a,m,m),l}static getMaxTileResolutionInAtlas(e,t,r){for(var i=Math.min(e,t),a=Math.floor(e/i)*Math.floor(t/i);a>1),a=Math.floor(e/i)*Math.floor(t/i);return i}static getDirectionalLightMatrices(e,t,r,i,a,s,o,l){var _=o.splitBoundSphere,h=_.center,c=_.radius,d=s/2,u=c*d/(d-Ze.atlasBorderSize),m=2*u,f=s/m,T=m/s,E=Math.ceil(n.dot(h,e)*f)*T,p=Math.ceil(n.dot(h,t)*f)*T,g=n.dot(h,r);h.x=e.x*E+t.x*p+r.x*g,h.y=e.y*E+t.y*p+r.y*g,h.z=e.z*E+t.z*p+r.z*g;var S=o.position,v=o.viewMatrix,x=o.projectionMatrix,A=o.viewProjectMatrix;o.resolution=s,o.offsetX=i%2*s,o.offsetY=Math.floor(i/2)*s,n.scale(r,c+a,S),n.subtract(h,S,S),R.createLookAt(S,h,e,v),R.createOrthoOffCenter(-u,u,-u,u,0,2*c+a,x),R.multiply(x,v,A),H._mulMatrixArray(Ze._shadowMapScaleOffsetMatrix.elements,A.elements,0,l,16*i)}static getSpotLightShadowData(e,t,r,i,a,n){var s=e.position=t.transform.position;e.resolution=r,n.setValue(1/r,1/r,r,r),e.offsetX=0,e.offsetY=0;var o=t.lightWorldMatrix,l=e.viewMatrix,_=e.projectionMatrix,h=e.viewProjectMatrix,c=e.cameraCullInfo.boundFrustum;o.invert(l),R.createPerspective(3.1416*t.spotAngle/180,1,.1,t.range,_),i.y=t.shadowStrength,R.multiply(_,l,h),c.matrix=h,h.cloneTo(a),e.cameraCullInfo.position=s}static prepareShadowReceiverShaderValues(e,t,r,i,a,n,s,o,l){if(n.setValue(1/t,1/r,t,r),s.setValue(e._shadowStrength,0,0,0),a>1){const e=16;for(var _=a*e,h=4*e;_=.5?Math.floor(i):o,d=l-a>=.5?Math.floor(a):l,u=n-_>=.5?Math.ceil(n):_,m=s-h>=.5?Math.ceil(s):h;this._viewport.x=c,this._viewport.y=d,this._viewport.width=u-c,this._viewport.height=m-d}_calculateProjectionMatrix(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=.5*this.orthographicVerticalSize,t=e*this.aspectRatio;R.createOrthoOffCenter(-t,t,-e,e,this.nearPlane,this.farPlane,this._projectionMatrix)}else R.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&=I.TRANSFORM_WORLDMATRIX)&&(this._updateViewMatrix=!0)}_parse(e,t){super._parse(e,t);var r=e.clearFlag;void 0!==r&&(this.clearFlag=r);var i=e.viewport;this.normalizedViewport=new Fe(i[0],i[1],i[2],i[3]);var a=e.enableHDR;void 0!==a&&(this.enableHDR=a)}_getCanvasWidth(){return this._offScreenRenderTexture?this._offScreenRenderTexture.width:_e.clientWidth}_getCanvasHeight(){return this._offScreenRenderTexture?this._offScreenRenderTexture.height:_e.clientHeight}_getRenderTexture(){return this._internalRenderTexture||this._offScreenRenderTexture}_needInternalRenderTexture(){return!!(this._postProcess&&this._postProcess.enable||this._enableHDR||this._needBuiltInRenderTexture)}_getRenderTextureFormat(){return this._enableHDR?t.RenderTextureFormat.R16G16B16A16:t.RenderTextureFormat.R8G8B8}_prepareCameraToRender(){super._prepareCameraToRender();var e=this.viewport;this._viewportParams.setValue(e.x,e.y,e.width,e.height),this._projectionParams.setValue(this._nearPlane,this._farPlane,_e._instance.invertY?-1:1,1/this.farPlane),this._shaderValues.setVector(Xe.VIEWPORT,this._viewportParams),this._shaderValues.setVector(Xe.PROJECTION_PARAMS,this._projectionParams)}_applyViewProject(e,t,r){var i,a=this._shaderValues;e.invertY?(R.multiply(Xe._invertYScaleMatrix,r,Xe._invertYProjectionMatrix),R.multiply(Xe._invertYProjectionMatrix,t,Xe._invertYProjectionViewMatrix),r=Xe._invertYProjectionMatrix,i=Xe._invertYProjectionViewMatrix):(R.multiply(r,t,this._projectionViewMatrix),i=this._projectionViewMatrix),e.viewMatrix=t,e.projectionMatrix=r,e.projectionViewMatrix=i,a.setMatrix4x4(Xe.VIEWMATRIX,t),a.setMatrix4x4(Xe.PROJECTMATRIX,r),a.setMatrix4x4(Xe.VIEWPROJECTMATRIX,i)}_updateClusterPlaneXY(){var e=this.fieldOfView,t=this.aspectRatio;if(this._clusterPlaneCacheFlag.x!==e||this._clusterPlaneCacheFlag.y!==t){var r=j._config.lightClusterCount,i=r.x,a=r.y,s=i+1,o=a+1,l=this._clusterXPlanes,_=this._clusterYPlanes;if(!l){l=this._clusterXPlanes=new Array(s),_=this._clusterYPlanes=new Array(o);for(var h=0;h0?Je._pool.pop():new Je)._render=e,a._material=t,a._subShaderIndex=r,a._commandBuffer=i,a}_elementRender(e,t){var r,i,a,n=t.invertY,s=Qe._updateMark,o=t.scene;this._render._scene=t.scene;var l=t.cameraShaderValue,_=e._transform,h=e._geometry;t.renderElement=e,s!==e.render._updateMark||e.renderType!==e.render._updateRenderType?(e.render._renderUpdate(t,_),e.render._renderUpdateWithCamera(t,_),e.render._updateMark=s,e.render._updateRenderType=e.renderType):e.renderType==Ke.RENDERTYPE_INSTANCEBATCH&&(e.render._renderUpdate(t,_),e.render._renderUpdateWithCamera(t,_));var c=t.pipelineMode;if(h._prepareRender(t))for(var d=e.renderSubShader._passes,u=0,m=d.length;u0?$e._pool.pop():new $e)._nameID=e,a._value=t,a._dataType=r,a._commandBuffer=i,a}run(){var t=this._commandBuffer._camera.scene._shaderValues;switch(this._dataType){case e.ShaderDataType.Int:t.setInt(this._nameID,this._value);break;case e.ShaderDataType.Number:t.setNumber(this._nameID,this._value);break;case e.ShaderDataType.Bool:t.setBool(this._nameID,this._value);break;case e.ShaderDataType.Matrix4x4:t.setMatrix4x4(this._nameID,this._value);break;case e.ShaderDataType.Quaternion:t.setQuaternion(this._nameID,this._value);break;case e.ShaderDataType.Texture:t.setTexture(this._nameID,this._value);break;case e.ShaderDataType.Vector4:t.setVector(this._nameID,this._value);break;case e.ShaderDataType.Vector2:t.setVector2(this._nameID,this._value);break;case e.ShaderDataType.Vector3:t.setVector3(this._nameID,this._value);break;case e.ShaderDataType.Buffer:t.setBuffer(this._nameID,this._value);break;default:throw"no type shaderValue on this CommendBuffer"}}recover(){$e._pool.push(this),this._nameID=0,this._value=null,this._dataType=-1}}$e._pool=[];class et{constructor(){this._camera=null,this._commands=[]}_apply(){for(var e=0,t=this._commands.length;e0&&this._removeTetxureReference(),this._shaderValues=null}_addReference(e=1){super._addReference(e);var r=this._shaderValues.getData();for(var i in r){var a=r[i];a&&a instanceof t.BaseTexture&&a._addReference()}}_removeReference(e=1){super._removeReference(e),this._removeTetxureReference()}setShaderName(e){if(this._shader=xe.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 st;return this.cloneTo(e),e}get _defineDatas(){return this._shaderValues._defineDatas}}st.MATERIAL="MATERIAL",st.RENDERQUEUE_OPAQUE=2e3,st.RENDERQUEUE_ALPHATEST=2450,st.RENDERQUEUE_TRANSPARENT=3e3,st.ALPHATESTVALUE=xe.propertyNameToID("u_AlphaTestValue"),st.CULL=xe.propertyNameToID("s_Cull"),st.BLEND=xe.propertyNameToID("s_Blend"),st.BLEND_SRC=xe.propertyNameToID("s_BlendSrc"),st.BLEND_DST=xe.propertyNameToID("s_BlendDst"),st.DEPTH_TEST=xe.propertyNameToID("s_DepthTest"),st.DEPTH_WRITE=xe.propertyNameToID("s_DepthWrite"),st.SHADERDEFINE_ALPHATEST=null;class ot{static load(e,r){t.Laya.loader.create(e,r,null,st.MATERIAL)}static __initDefine__(){ot.SHADERDEFINE_ALPHATEST=st.SHADERDEFINE_ALPHATEST}}ot.MATERIAL="MATERIAL",ot.RENDERQUEUE_OPAQUE=2e3,ot.RENDERQUEUE_ALPHATEST=2450,ot.RENDERQUEUE_TRANSPARENT=3e3,ot.ALPHATESTVALUE=xe.propertyNameToID("u_AlphaTestValue"),ot.SHADERDEFINE_ALPHATEST=null;class lt{constructor(){this.cull=lt.CULL_BACK,this.blend=lt.BLEND_DISABLE,this.srcBlend=lt.BLENDPARAM_ONE,this.dstBlend=lt.BLENDPARAM_ZERO,this.srcBlendRGB=lt.BLENDPARAM_ONE,this.dstBlendRGB=lt.BLENDPARAM_ZERO,this.srcBlendAlpha=lt.BLENDPARAM_ONE,this.dstBlendAlpha=lt.BLENDPARAM_ZERO,this.blendConstColor=new a(1,1,1,1),this.blendEquation=lt.BLENDEQUATION_ADD,this.blendEquationRGB=lt.BLENDEQUATION_ADD,this.blendEquationAlpha=lt.BLENDEQUATION_ADD,this.depthTest=lt.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 lt;return this.cloneTo(e),e}}lt.CULL_NONE=0,lt.CULL_FRONT=1,lt.CULL_BACK=2,lt.BLEND_DISABLE=0,lt.BLEND_ENABLE_ALL=1,lt.BLEND_ENABLE_SEPERATE=2,lt.BLENDPARAM_ZERO=0,lt.BLENDPARAM_ONE=1,lt.BLENDPARAM_SRC_COLOR=768,lt.BLENDPARAM_ONE_MINUS_SRC_COLOR=769,lt.BLENDPARAM_DST_COLOR=774,lt.BLENDPARAM_ONE_MINUS_DST_COLOR=775,lt.BLENDPARAM_SRC_ALPHA=770,lt.BLENDPARAM_ONE_MINUS_SRC_ALPHA=771,lt.BLENDPARAM_DST_ALPHA=772,lt.BLENDPARAM_ONE_MINUS_DST_ALPHA=773,lt.BLENDPARAM_SRC_ALPHA_SATURATE=776,lt.BLENDEQUATION_ADD=32774,lt.BLENDEQUATION_SUBTRACT=32778,lt.BLENDEQUATION_REVERSE_SUBTRACT=32779,lt.DEPTHTEST_OFF=0,lt.DEPTHTEST_NEVER=512,lt.DEPTHTEST_LESS=513,lt.DEPTHTEST_EQUAL=514,lt.DEPTHTEST_LEQUAL=515,lt.DEPTHTEST_GREATER=516,lt.DEPTHTEST_NOTEQUAL=517,lt.DEPTHTEST_GEQUAL=518,lt.DEPTHTEST_ALWAYS=519;class _t extends st{constructor(){super(),this._enableVertexColor=!1,this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new a(1,1,1,1);var e=this._shaderValues;e.setVector(_t.ALBEDOCOLOR,new a(1,1,1,1)),e.setVector(_t.MATERIALSPECULAR,new a(1,1,1,1)),e.setNumber(_t.SHININESS,.078125),e.setNumber(st.ALPHATESTVALUE,.5),e.setVector(_t.TILINGOFFSET,new a(1,1,0,0)),this._enableLighting=!0,this.renderMode=_t.RENDERMODE_OPAQUE}static __initDefine__(){_t.SHADERDEFINE_DIFFUSEMAP=xe.getDefineByName("DIFFUSEMAP"),_t.SHADERDEFINE_NORMALMAP=xe.getDefineByName("NORMALMAP"),_t.SHADERDEFINE_SPECULARMAP=xe.getDefineByName("SPECULARMAP"),_t.SHADERDEFINE_TILINGOFFSET=xe.getDefineByName("TILINGOFFSET"),_t.SHADERDEFINE_ENABLEVERTEXCOLOR=xe.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(_t.ALBEDOCOLOR)}set _Color(e){this.albedoColor=e}get _SpecColorR(){return this._shaderValues.getVector(_t.MATERIALSPECULAR).x}set _SpecColorR(e){this._shaderValues.getVector(_t.MATERIALSPECULAR).x=e}get _SpecColorG(){return this._shaderValues.getVector(_t.MATERIALSPECULAR).y}set _SpecColorG(e){this._shaderValues.getVector(_t.MATERIALSPECULAR).y=e}get _SpecColorB(){return this._shaderValues.getVector(_t.MATERIALSPECULAR).z}set _SpecColorB(e){this._shaderValues.getVector(_t.MATERIALSPECULAR).z=e}get _SpecColorA(){return this._shaderValues.getVector(_t.MATERIALSPECULAR).w}set _SpecColorA(e){this._shaderValues.getVector(_t.MATERIALSPECULAR).w=e}get _SpecColor(){return this._shaderValues.getVector(_t.MATERIALSPECULAR)}set _SpecColor(e){this.specularColor=e}get _AlbedoIntensity(){return this._albedoIntensity}set _AlbedoIntensity(e){if(this._albedoIntensity!==e){var t=this._shaderValues.getVector(_t.ALBEDOCOLOR);a.scale(this._albedoColor,e,t),this._albedoIntensity=e,this._shaderValues.setVector(_t.ALBEDOCOLOR,t)}}get _Shininess(){return this._shaderValues.getNumber(_t.SHININESS)}set _Shininess(e){e=Math.max(0,Math.min(1,e)),this._shaderValues.setNumber(_t.SHININESS,e)}get _MainTex_STX(){return this._shaderValues.getVector(_t.TILINGOFFSET).x}set _MainTex_STX(e){var t=this._shaderValues.getVector(_t.TILINGOFFSET);t.x=e,this.tilingOffset=t}get _MainTex_STY(){return this._shaderValues.getVector(_t.TILINGOFFSET).y}set _MainTex_STY(e){var t=this._shaderValues.getVector(_t.TILINGOFFSET);t.y=e,this.tilingOffset=t}get _MainTex_STZ(){return this._shaderValues.getVector(_t.TILINGOFFSET).z}set _MainTex_STZ(e){var t=this._shaderValues.getVector(_t.TILINGOFFSET);t.z=e,this.tilingOffset=t}get _MainTex_STW(){return this._shaderValues.getVector(_t.TILINGOFFSET).w}set _MainTex_STW(e){var t=this._shaderValues.getVector(_t.TILINGOFFSET);t.w=e,this.tilingOffset=t}get _MainTex_ST(){return this._shaderValues.getVector(_t.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 _t.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=st.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_DISABLE,this.depthTest=lt.DEPTHTEST_LESS;break;case _t.RENDERMODE_CUTOUT:this.renderQueue=st.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_DISABLE,this.depthTest=lt.DEPTHTEST_LESS;break;case _t.RENDERMODE_TRANSPARENT:this.renderQueue=st.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_ENABLE_ALL,this.blendSrc=lt.BLENDPARAM_SRC_ALPHA,this.blendDst=lt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=lt.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(_t.SHADERDEFINE_ENABLEVERTEXCOLOR):this._shaderValues.removeDefine(_t.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(_t.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(_t.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(_t.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(_t.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(_t.ALBEDOCOLOR);a.scale(e,this._albedoIntensity,t),this._albedoColor=e,this._shaderValues.setVector(_t.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(_t.MATERIALSPECULAR)}set specularColor(e){this._shaderValues.setVector(_t.MATERIALSPECULAR,e)}get shininess(){return this._Shininess}set shininess(e){this._Shininess=e}get albedoTexture(){return this._shaderValues.getTexture(_t.ALBEDOTEXTURE)}set albedoTexture(e){e?this._shaderValues.addDefine(_t.SHADERDEFINE_DIFFUSEMAP):this._shaderValues.removeDefine(_t.SHADERDEFINE_DIFFUSEMAP),this._shaderValues.setTexture(_t.ALBEDOTEXTURE,e)}get normalTexture(){return this._shaderValues.getTexture(_t.NORMALTEXTURE)}set normalTexture(e){e?this._shaderValues.addDefine(_t.SHADERDEFINE_NORMALMAP):this._shaderValues.removeDefine(_t.SHADERDEFINE_NORMALMAP),this._shaderValues.setTexture(_t.NORMALTEXTURE,e)}get specularTexture(){return this._shaderValues.getTexture(_t.SPECULARTEXTURE)}set specularTexture(e){e?this._shaderValues.addDefine(_t.SHADERDEFINE_SPECULARMAP):this._shaderValues.removeDefine(_t.SHADERDEFINE_SPECULARMAP),this._shaderValues.setTexture(_t.SPECULARTEXTURE,e)}clone(){var e=new _t;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)}}_t.RENDERMODE_OPAQUE=0,_t.RENDERMODE_CUTOUT=1,_t.RENDERMODE_TRANSPARENT=2,_t.ALBEDOTEXTURE=xe.propertyNameToID("u_DiffuseTexture"),_t.NORMALTEXTURE=xe.propertyNameToID("u_NormalTexture"),_t.SPECULARTEXTURE=xe.propertyNameToID("u_SpecularTexture"),_t.ALBEDOCOLOR=xe.propertyNameToID("u_DiffuseColor"),_t.MATERIALSPECULAR=xe.propertyNameToID("u_MaterialSpecular"),_t.SHININESS=xe.propertyNameToID("u_Shininess"),_t.TILINGOFFSET=xe.propertyNameToID("u_TilingOffset");class ht extends st{constructor(){super(),this.setShaderName("Effect"),this._color=new a(1,1,1,1),this._shaderValues.setVector(ht.TINTCOLOR,new a(1,1,1,1)),this.renderMode=ht.RENDERMODE_ADDTIVE}static __initDefine__(){ht.SHADERDEFINE_MAINTEXTURE=xe.getDefineByName("MAINTEXTURE"),ht.SHADERDEFINE_TILINGOFFSET=xe.getDefineByName("TILINGOFFSET"),ht.SHADERDEFINE_ADDTIVEFOG=xe.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 _TintColor(){return this._shaderValues.getVector(ht.TINTCOLOR)}set _TintColor(e){this.color=e}get _MainTex_STX(){return this._shaderValues.getVector(ht.TILINGOFFSET).x}set _MainTex_STX(e){var t=this._shaderValues.getVector(ht.TILINGOFFSET);t.x=e,this.tilingOffset=t}get _MainTex_STY(){return this._shaderValues.getVector(ht.TILINGOFFSET).y}set _MainTex_STY(e){var t=this._shaderValues.getVector(ht.TILINGOFFSET);t.y=e,this.tilingOffset=t}get _MainTex_STZ(){return this._shaderValues.getVector(ht.TILINGOFFSET).z}set _MainTex_STZ(e){var t=this._shaderValues.getVector(ht.TILINGOFFSET);t.z=e,this.tilingOffset=t}get _MainTex_STW(){return this._shaderValues.getVector(ht.TILINGOFFSET).w}set _MainTex_STW(e){var t=this._shaderValues.getVector(ht.TILINGOFFSET);t.w=e,this.tilingOffset=t}get _MainTex_ST(){return this._shaderValues.getVector(ht.TILINGOFFSET)}set _MainTex_ST(e){this.tilingOffset=e}set renderMode(e){switch(e){case ht.RENDERMODE_ADDTIVE:this.renderQueue=st.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=lt.CULL_NONE,this.blend=lt.BLEND_ENABLE_ALL,this.blendSrc=lt.BLENDPARAM_SRC_ALPHA,this.blendDst=lt.BLENDPARAM_ONE,this.depthTest=lt.DEPTHTEST_LESS,this._shaderValues.addDefine(ht.SHADERDEFINE_ADDTIVEFOG);break;case ht.RENDERMODE_ALPHABLENDED:this.renderQueue=st.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=lt.CULL_NONE,this.blend=lt.BLEND_ENABLE_ALL,this.blendSrc=lt.BLENDPARAM_SRC_ALPHA,this.blendDst=lt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=lt.DEPTHTEST_LESS,this._shaderValues.removeDefine(ht.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(ht.TINTCOLOR)}set color(e){this._shaderValues.setVector(ht.TINTCOLOR,e)}get texture(){return this._shaderValues.getTexture(ht.MAINTEXTURE)}set texture(e){e?this._shaderValues.addDefine(ht.SHADERDEFINE_MAINTEXTURE):this._shaderValues.removeDefine(ht.SHADERDEFINE_MAINTEXTURE),this._shaderValues.setTexture(ht.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(ht.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(ht.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(ht.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(ht.TILINGOFFSET,e)}clone(){var e=new ht;return this.cloneTo(e),e}}ht.RENDERMODE_ADDTIVE=0,ht.RENDERMODE_ALPHABLENDED=1,ht.MAINTEXTURE=xe.propertyNameToID("u_AlbedoTexture"),ht.TINTCOLOR=xe.propertyNameToID("u_AlbedoColor"),ht.TILINGOFFSET=xe.propertyNameToID("u_TilingOffset");class ct extends st{constructor(){super(),this._enableLighting=!0,this.setShaderName("ExtendTerrain"),this.renderMode=ct.RENDERMODE_OPAQUE}static __initDefine__(){ct.SHADERDEFINE_DETAIL_NUM1=xe.getDefineByName("ExtendTerrain_DETAIL_NUM1"),ct.SHADERDEFINE_DETAIL_NUM2=xe.getDefineByName("ExtendTerrain_DETAIL_NUM2"),ct.SHADERDEFINE_DETAIL_NUM3=xe.getDefineByName("ExtendTerrain_DETAIL_NUM3"),ct.SHADERDEFINE_DETAIL_NUM4=xe.getDefineByName("ExtendTerrain_DETAIL_NUM4"),ct.SHADERDEFINE_DETAIL_NUM5=xe.getDefineByName("ExtendTerrain_DETAIL_NUM5")}get splatAlphaTexture(){return this._shaderValues.getTexture(ct.SPLATALPHATEXTURE)}set splatAlphaTexture(e){this._shaderValues.setTexture(ct.SPLATALPHATEXTURE,e)}get diffuseTexture1(){return this._shaderValues.getTexture(ct.DIFFUSETEXTURE1)}set diffuseTexture1(e){this._shaderValues.setTexture(ct.DIFFUSETEXTURE1,e),this._setDetailNum(1)}get diffuseTexture2(){return this._shaderValues.getTexture(ct.DIFFUSETEXTURE2)}set diffuseTexture2(e){this._shaderValues.setTexture(ct.DIFFUSETEXTURE2,e),this._setDetailNum(2)}get diffuseTexture3(){return this._shaderValues.getTexture(ct.DIFFUSETEXTURE3)}set diffuseTexture3(e){this._shaderValues.setTexture(ct.DIFFUSETEXTURE3,e),this._setDetailNum(3)}get diffuseTexture4(){return this._shaderValues.getTexture(ct.DIFFUSETEXTURE4)}set diffuseTexture4(e){this._shaderValues.setTexture(ct.DIFFUSETEXTURE4,e),this._setDetailNum(4)}get diffuseTexture5(){return this._shaderValues.getTexture(ct.DIFFUSETEXTURE5)}set diffuseTexture5(e){this._shaderValues.setTexture(ct.DIFFUSETEXTURE5,e),this._setDetailNum(5)}set diffuseScaleOffset1(e){this._shaderValues.setVector(ct.DIFFUSESCALEOFFSET1,e)}set diffuseScaleOffset2(e){this._shaderValues.setVector(ct.DIFFUSESCALEOFFSET2,e)}set diffuseScaleOffset3(e){this._shaderValues.setVector(ct.DIFFUSESCALEOFFSET3,e)}set diffuseScaleOffset4(e){this._shaderValues.setVector(ct.DIFFUSESCALEOFFSET4,e)}set diffuseScaleOffset5(e){this._shaderValues.setVector(ct.DIFFUSESCALEOFFSET5,e)}set renderMode(e){switch(e){case ct.RENDERMODE_OPAQUE:this.renderQueue=st.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_DISABLE,this.depthTest=lt.DEPTHTEST_LESS;break;case ct.RENDERMODE_TRANSPARENT:this.renderQueue=st.RENDERQUEUE_OPAQUE,this.depthWrite=!1,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_ENABLE_ALL,this.blendSrc=lt.BLENDPARAM_SRC_ALPHA,this.blendDst=lt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=lt.DEPTHTEST_LEQUAL;break;default:throw new Error("ExtendTerrainMaterial:renderMode value error.")}}_setDetailNum(e){switch(e){case 1:this._shaderValues.addDefine(ct.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM5);break;case 2:this._shaderValues.addDefine(ct.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM5);break;case 3:this._shaderValues.addDefine(ct.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM5);break;case 4:this._shaderValues.addDefine(ct.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM5);break;case 5:this._shaderValues.addDefine(ct.SHADERDEFINE_DETAIL_NUM5),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(ct.SHADERDEFINE_DETAIL_NUM4)}}clone(){var e=new ct;return this.cloneTo(e),e}}ct.RENDERMODE_OPAQUE=1,ct.RENDERMODE_TRANSPARENT=2,ct.SPLATALPHATEXTURE=xe.propertyNameToID("u_SplatAlphaTexture"),ct.DIFFUSETEXTURE1=xe.propertyNameToID("u_DiffuseTexture1"),ct.DIFFUSETEXTURE2=xe.propertyNameToID("u_DiffuseTexture2"),ct.DIFFUSETEXTURE3=xe.propertyNameToID("u_DiffuseTexture3"),ct.DIFFUSETEXTURE4=xe.propertyNameToID("u_DiffuseTexture4"),ct.DIFFUSETEXTURE5=xe.propertyNameToID("u_DiffuseTexture5"),ct.DIFFUSESCALEOFFSET1=xe.propertyNameToID("u_DiffuseScaleOffset1"),ct.DIFFUSESCALEOFFSET2=xe.propertyNameToID("u_DiffuseScaleOffset2"),ct.DIFFUSESCALEOFFSET3=xe.propertyNameToID("u_DiffuseScaleOffset3"),ct.DIFFUSESCALEOFFSET4=xe.propertyNameToID("u_DiffuseScaleOffset4"),ct.DIFFUSESCALEOFFSET5=xe.propertyNameToID("u_DiffuseScaleOffset5"),(E=e.PBRRenderMode||(e.PBRRenderMode={}))[E.Opaque=0]="Opaque",E[E.Cutout=1]="Cutout",E[E.Fade=2]="Fade",E[E.Transparent=3]="Transparent";class dt extends st{constructor(){super(),this._enableEmission=!1,this._shaderValues.setVector(dt.ALBEDOCOLOR,new a(1,1,1,1)),this._shaderValues.setVector(dt.EMISSIONCOLOR,new a(1,1,1,1)),this._shaderValues.setNumber(dt.SMOOTHNESS,.5),this._shaderValues.setNumber(dt.SMOOTHNESSSCALE,1),this._shaderValues.setNumber(dt.OCCLUSIONSTRENGTH,1),this._shaderValues.setNumber(dt.NORMALSCALE,1),this._shaderValues.setNumber(dt.PARALLAXSCALE,.001),this._shaderValues.setNumber(st.ALPHATESTVALUE,.5),this.renderMode=e.PBRRenderMode.Opaque}static __init__(){dt.SHADERDEFINE_ALBEDOTEXTURE=xe.getDefineByName("ALBEDOTEXTURE"),dt.SHADERDEFINE_NORMALTEXTURE=xe.getDefineByName("NORMALTEXTURE"),dt.SHADERDEFINE_PARALLAXTEXTURE=xe.getDefineByName("PARALLAXTEXTURE"),dt.SHADERDEFINE_OCCLUSIONTEXTURE=xe.getDefineByName("OCCLUSIONTEXTURE"),dt.SHADERDEFINE_EMISSION=xe.getDefineByName("EMISSION"),dt.SHADERDEFINE_EMISSIONTEXTURE=xe.getDefineByName("EMISSIONTEXTURE"),dt.SHADERDEFINE_TILINGOFFSET=xe.getDefineByName("TILINGOFFSET"),dt.SHADERDEFINE_TRANSPARENTBLEND=xe.getDefineByName("TRANSPARENTBLEND"),dt.SHADERDEFINE_LAYA_PBR_BRDF_HIGH=xe.getDefineByName("LAYA_PBR_BRDF_HIGH"),dt.SHADERDEFINE_LAYA_PBR_BRDF_LOW=xe.getDefineByName("LAYA_PBR_BRDF_LOW")}get albedoColor(){return this._shaderValues.getVector(dt.ALBEDOCOLOR)}set albedoColor(e){this._shaderValues.setVector(dt.ALBEDOCOLOR,e)}get albedoTexture(){return this._shaderValues.getTexture(dt.ALBEDOTEXTURE)}set albedoTexture(e){e?this._shaderValues.addDefine(dt.SHADERDEFINE_ALBEDOTEXTURE):this._shaderValues.removeDefine(dt.SHADERDEFINE_ALBEDOTEXTURE),this._shaderValues.setTexture(dt.ALBEDOTEXTURE,e)}get normalTexture(){return this._shaderValues.getTexture(dt.NORMALTEXTURE)}set normalTexture(e){e?this._shaderValues.addDefine(dt.SHADERDEFINE_NORMALTEXTURE):this._shaderValues.removeDefine(dt.SHADERDEFINE_NORMALTEXTURE),this._shaderValues.setTexture(dt.NORMALTEXTURE,e)}get normalTextureScale(){return this._shaderValues.getNumber(dt.NORMALSCALE)}set normalTextureScale(e){this._shaderValues.setNumber(dt.NORMALSCALE,e)}get parallaxTexture(){return this._shaderValues.getTexture(dt.PARALLAXTEXTURE)}set parallaxTexture(e){e?this._shaderValues.addDefine(dt.SHADERDEFINE_PARALLAXTEXTURE):this._shaderValues.removeDefine(dt.SHADERDEFINE_PARALLAXTEXTURE),this._shaderValues.setTexture(dt.PARALLAXTEXTURE,e)}get parallaxTextureScale(){return this._shaderValues.getNumber(dt.PARALLAXSCALE)}set parallaxTextureScale(e){this._shaderValues.setNumber(dt.PARALLAXSCALE,Math.max(.005,Math.min(.08,e)))}get occlusionTexture(){return this._shaderValues.getTexture(dt.OCCLUSIONTEXTURE)}set occlusionTexture(e){e?this._shaderValues.addDefine(dt.SHADERDEFINE_OCCLUSIONTEXTURE):this._shaderValues.removeDefine(dt.SHADERDEFINE_OCCLUSIONTEXTURE),this._shaderValues.setTexture(dt.OCCLUSIONTEXTURE,e)}get occlusionTextureStrength(){return this._shaderValues.getNumber(dt.OCCLUSIONSTRENGTH)}set occlusionTextureStrength(e){this._shaderValues.setNumber(dt.OCCLUSIONSTRENGTH,Math.max(0,Math.min(1,e)))}get smoothness(){return this._shaderValues.getNumber(dt.SMOOTHNESS)}set smoothness(e){this._shaderValues.setNumber(dt.SMOOTHNESS,Math.max(0,Math.min(1,e)))}get smoothnessTextureScale(){return this._shaderValues.getNumber(dt.SMOOTHNESSSCALE)}set smoothnessTextureScale(e){this._shaderValues.setNumber(dt.SMOOTHNESSSCALE,Math.max(0,Math.min(1,e)))}get enableEmission(){return this._enableEmission}set enableEmission(e){e?this._shaderValues.addDefine(dt.SHADERDEFINE_EMISSION):this._shaderValues.removeDefine(dt.SHADERDEFINE_EMISSION),this._enableEmission=e}get emissionColor(){return this._shaderValues.getVector(dt.EMISSIONCOLOR)}set emissionColor(e){this._shaderValues.setVector(dt.EMISSIONCOLOR,e)}get emissionTexture(){return this._shaderValues.getTexture(dt.EMISSIONTEXTURE)}set emissionTexture(e){e?this._shaderValues.addDefine(dt.SHADERDEFINE_EMISSIONTEXTURE):this._shaderValues.removeDefine(dt.SHADERDEFINE_EMISSIONTEXTURE),this._shaderValues.setTexture(dt.EMISSIONTEXTURE,e)}get tilingOffset(){return this._shaderValues.getVector(dt.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(dt.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(dt.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(dt.TILINGOFFSET,e)}set renderMode(t){switch(t){case e.PBRRenderMode.Opaque:this.alphaTest=!1,this.renderQueue=st.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_DISABLE,this.depthTest=lt.DEPTHTEST_LESS,this._shaderValues.removeDefine(dt.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Cutout:this.renderQueue=st.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_DISABLE,this.depthTest=lt.DEPTHTEST_LESS,this._shaderValues.removeDefine(dt.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Fade:this.renderQueue=st.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_ENABLE_ALL,this.blendSrc=lt.BLENDPARAM_SRC_ALPHA,this.blendDst=lt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=lt.DEPTHTEST_LESS,this._shaderValues.removeDefine(dt.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Transparent:this.renderQueue=st.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=lt.CULL_BACK,this.blend=lt.BLEND_ENABLE_ALL,this.blendSrc=lt.BLENDPARAM_ONE,this.blendDst=lt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=lt.DEPTHTEST_LESS,this._shaderValues.addDefine(dt.SHADERDEFINE_TRANSPARENTBLEND);break;default:throw new Error("PBRMaterial:unknown renderMode value.")}}get enableReflection(){return!0}set enableReflection(e){}}dt.ALBEDOTEXTURE=xe.propertyNameToID("u_AlbedoTexture"),dt.ALBEDOCOLOR=xe.propertyNameToID("u_AlbedoColor"),dt.TILINGOFFSET=xe.propertyNameToID("u_TilingOffset"),dt.NORMALTEXTURE=xe.propertyNameToID("u_NormalTexture"),dt.NORMALSCALE=xe.propertyNameToID("u_NormalScale"),dt.SMOOTHNESS=xe.propertyNameToID("u_Smoothness"),dt.SMOOTHNESSSCALE=xe.propertyNameToID("u_SmoothnessScale"),dt.OCCLUSIONTEXTURE=xe.propertyNameToID("u_OcclusionTexture"),dt.OCCLUSIONSTRENGTH=xe.propertyNameToID("u_occlusionStrength"),dt.PARALLAXTEXTURE=xe.propertyNameToID("u_ParallaxTexture"),dt.PARALLAXSCALE=xe.propertyNameToID("u_ParallaxScale"),dt.EMISSIONTEXTURE=xe.propertyNameToID("u_EmissionTexture"),dt.EMISSIONCOLOR=xe.propertyNameToID("u_EmissionColor"),dt.renderQuality=e.PBRRenderQuality.High;var ut,mt,ft,Tt,Et,pt='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#define SETUP_BRDF_INPUT specularSetup\r\n\r\n#include "Lighting.glsl";\r\n#include "PBRFSInput.glsl";\r\n#include "LayaPBRBRDF.glsl";\r\n#include "GlobalIllumination.glsl";\r\n#include "Shadow.glsl"\r\n#include "PBRCore.glsl";\r\n\r\nvoid main()\r\n{\r\n\tfragmentForward();\r\n}',gt='#include "PBRVSInput.glsl";\r\n#include "Lighting.glsl";\r\n#include "PBRVertex.glsl";\r\n\r\nvoid main()\r\n{\r\n\tvertexForward();\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',St='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',Rt='#include "ShadowCasterVS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionCS = shadowCasterVertex();\r\n\tgl_Position=remapGLPositionZ(positionCS);\r\n}',vt='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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\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\nuniform vec4 u_ProjectionParams;\r\n\r\n//传入法线\r\nvarying vec4 depthNormals;\r\n\r\n\r\nvec4 depthNormalsVertex()\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;\r\n\t \t#ifdef SIMPLEBONE\r\n\t\t\tfloat currentPixelPos;\r\n\t\t\t#ifdef GPU_INSTANCE\r\n\t\t\t\tcurrentPixelPos = a_SimpleTextureParams.x+a_SimpleTextureParams.y;\r\n\t\t\t#else\r\n\t\t\t\tcurrentPixelPos = u_SimpleAnimatorParams.x+u_SimpleAnimatorParams.y;\r\n\t\t\t#endif\r\n\t\t\tfloat offset = 1.0/u_SimpleAnimatorTextureSize;\r\n\t\t\tskinTransform = loadMatFromTexture(currentPixelPos,int(a_BoneIndices.x),offset) * a_BoneWeights.x;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.y),offset) * a_BoneWeights.y;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.z),offset) * a_BoneWeights.z;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.w),offset) * a_BoneWeights.w;\r\n\t\t#else\r\n\t\t\tskinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\t#endif\r\n\t\tworldMat = worldMat * skinTransform;\r\n\t#endif\r\n\r\n\tvec4 positionWS = worldMat * a_Position;\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\tvec3 normalWS = normalize(a_Normal*worldInvMat);//if no normalize will cause precision problem\r\n\r\n\tdepthNormals.xyz = normalWS;\r\n\tvec4 positionCS = u_ViewProjection * positionWS;\r\n\tdepthNormals.w = (positionCS.z * 2.0 - positionCS.w)*u_ProjectionParams.w;\r\n\t\r\n return positionCS;\r\n}\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionCS = depthNormalsVertex();\r\n\tgl_Position=remapGLPositionZ(positionCS);\r\n}',xt='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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#include "DepthNormalUtil.glsl";\r\n\r\nvarying vec4 depthNormals;\r\n\r\nvoid main()\r\n{\r\n\tgl_FragColor=depthNormalsFragment(depthNormals);\r\n}';class At{constructor(){this.textureID=-1}}class It extends t.Resource{constructor(e,t,r,i,a){super(),this._stateParamsMap=[],this._uploadMark=-1,this._uploadRenderType=-1,this._vs=e,this._ps=t,this._attributeMap=r,this._uniformMap=i,this._shaderPass=a,this._globaluniformMap=[],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&&xe.debugMode&&!e.getProgramParameter(this._program,e.LINK_STATUS))throw e.getProgramInfoLog(this._program);var i=[],a=[],n=[],s=[],o=[];this._customUniformParamsMap=[];var l,_,h,c=e.getProgramParameter(this._program,e.ACTIVE_UNIFORMS);for(t.WebGLContext.useProgram(e,this._program),this._curActTexIndex=0,_=0;_0?(l.name=u=u.substr(0,u.length-3),l.isArray=!0):(l.name=u,l.isArray=!1),l.type=d.type,this._addShaderUnifiormFun(l);var m=this._uniformMap[u];if(null!=m)switch(l.dataOffset=xe.propertyNameToID(u),m){case xe.PERIOD_CUSTOM:o.push(l);break;case xe.PERIOD_MATERIAL:s.push(l);break;case xe.PERIOD_SPRITE:n.push(l);break;case xe.PERIOD_CAMERA:a.push(l);break;case xe.PERIOD_SCENE:i.push(l);break;default:throw new Error("Shader3D: period is unkonw.")}else l.dataOffset=xe.propertyNameToID(u),this._globaluniformMap[u]=xe.PERIOD_SCENE,i.push(l)}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 a=r._renders;r._clearRenderQueue();for(var s=r._opaqueQueue,o=e.position,l=e.cullPlaneCount,_=e.cullPlanes,h=(e.cullSphere,e.direction,a.elements),c=t.Stat.loopCount,d=0,u=a.length;d0}static cullingSpotShadow(e,r,i){var a=r._renders;r._clearRenderQueue();for(var s=r._opaqueQueue,o=a.elements,l=t.Stat.loopCount,_=0,h=a.length;_0}static renderObjectCullingNative(e,r,i,a,s,o){var l,_,h,c=r._opaqueQueue,d=r._transparentQueue;r._clearRenderQueue();var u=a.length,m=a.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,a,n){return t.LayaGL.instance.culling(e,r,i,a,n)}}Lt._tempColor0=new Mt,Lt._tempVector0=new n,Lt._cameraCullInfo=new Ct,Lt._shadowCullInfo=new yt,Lt.debugFrustumCulling=!1;class Ot{constructor(){this._coefficients=new Float32Array(27)}getCoefficient(e,t){return this._coefficients[9*e+t]}setCoefficient(e,t,r){this._coefficients[9*e+t]=r}setCoefficients(e,t,r,i,a,n,s,o,l,_){var h=9*e;this._coefficients[h]=t,this._coefficients[++h]=r,this._coefficients[++h]=i,this._coefficients[++h]=a,this._coefficients[++h]=n,this._coefficients[++h]=s,this._coefficients[++h]=o,this._coefficients[++h]=l,this._coefficients[++h]=_}cloneTo(e){if(this!==e)for(var t=this._coefficients,r=e._coefficients,i=0;i<27;i++)r[i]=t[i]}}Ot._default=new Ot;class Nt{constructor(){this._pressedSprite=null,this._pressedLoopCount=-1,this.sprite=null,this.mousePositionX=0,this.mousePositionY=0}}class Pt{constructor(){this._indexInList=-1,this._identifier=-1,this._position=new i}get identifier(){return this._identifier}get position(){return this._position}_getIndexInList(){return this._indexInList}_setIndexInList(e){this._indexInList=e}}class bt{constructor(){this._eventList=[],this._mouseTouch=new Nt,this._touchPool=[],this._touches=new Dt,this._multiTouchEnabled=!0,this._pushEventList=(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()?null:1==t&&r&&-1==r._getIndexInList()?null:(r||(r=new Pt,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 a=0,n=i.length;a=0;o--){var l=t[o],_=l.viewport;if(i.x>=_.x&&i.y>=_.y&&i.x<=_.width&&i.y<=_.height)if(l.viewportPointToRay(i,a),this._scene._physicsSimulation.rayCast(a,r)||l.clearFlag===e.CameraClearFlags.SolidColor||l.clearFlag===e.CameraClearFlags.Sky)break}var h=this._mouseTouch,c=h.sprite;if(r.succeeded){var d=r.collider.owner;h.sprite=d;var u=d._scripts;if(c!==d&&u)for(var m=0,f=u.length;m0){var o=!1;for(e=0;ec._pressedLoopCount){var u=d._scripts;if(u)for(i=0,a=u.length;i>n,1),Math.max(e>>n,1));this._setGPUMemory(e*e*4*(1+1/3)*6)}else this._mipmapCount=1,this._setGPUMemory(e*e*4*6)}static get blackTexture(){return Ft._blackTexture}static get grayTexture(){return Ft._grayTexture}static __init__(){var e=new Ft(1,t.TextureFormat.R8G8B8,!1),r=new Ft(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,Ft._grayTexture=r,Ft._blackTexture=e}static _parse(e,t=null,r=null){var i=r?new Ft(0,r[0],r[1]):new Ft(0);return i.setSixSideImageSources(e),i}static _parseBin(e,t=null,r=null){var i=r?new Ft(0,r[0],r[1]):new Ft(0);return i.setSixSideImageSources(e),i}static load(e,r){var i=t.LoaderManager.createMap[t.Utils.getFilecompatibleExtension(e)]?t.Utils.getFilecompatibleExtension(e):t.Utils.getFileExtension(e),a=t.LoaderManager.createMap[i]?t.LoaderManager.createMap[i][0]:null;t.ILaya.loader.create(e,r,null,a)}get defaulteTexture(){return Ft.grayTexture}_setPixels(e,r,i,a){var n=t.LayaGL.instance,s=this._getGLFormat();t.WebGLContext.bindTexture(n,this._glTextureType,this._glTexture),this.format===t.TextureFormat.R8G8B8?(n.pixelStorei(n.UNPACK_ALIGNMENT,1),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[0]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[1]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[2]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[3]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[4]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[5]),n.pixelStorei(n.UNPACK_ALIGNMENT,4)):(n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[0]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[1]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[2]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[3]),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[4]),n.texImage2D(n.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,a,0,s,n.UNSIGNED_BYTE,e[5]))}setSixSideImageSources(e,r=!1){for(var i,a,n=0;n<6;n++){var s=e[n];if(!s)return void console.log("TextureCube: image Source can't be null.");var o=s.width,l=s.height;if(n>0&&i!==o)return void console.log("TextureCube: each side image's width and height must same.");if((i=o)!==(a=l))return void console.log("TextureCube: each side image's width and height must same.")}this._width=i,this._height=a;var _=t.LayaGL.instance;t.WebGLContext.bindTexture(_,this._glTextureType,this._glTexture);var h=this._getGLFormat();if(t.Render.isConchApp){if(1==r)for(var c=0;c<6;c++)e[c].setPremultiplyAlpha(r);_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[0]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[1]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[2]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[3]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[4]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[5])}else r&&_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z,0,h,h,_.UNSIGNED_BYTE,e[0]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,h,h,_.UNSIGNED_BYTE,e[1]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X,0,h,h,_.UNSIGNED_BYTE,e[2]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X,0,h,h,_.UNSIGNED_BYTE,e[3]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y,0,h,h,_.UNSIGNED_BYTE,e[4]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,h,h,_.UNSIGNED_BYTE,e[5]),r&&_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);this._mipmap&&this._isPot(i)&&this._isPot(a)?(_.generateMipmap(this._glTextureType),this._setGPUMemory(i*a*4*(1+1/3)*6)):this._setGPUMemory(i*a*4*6),this._setWarpMode(_.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(_.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),this._readyed=!0,this._activeResource()}setSixSidePixels(e,r=0){if(!e)throw new Error("TextureCube:pixels can't be null.");var i=Math.max(this._width>>r,1),a=Math.max(this._height>>r,1),n=i*a*this._getFormatByteCount();if(e[0].lengths.x?-1:n.y>s.y?-1:n.z>s.z?-1:(s.x-n.x)*(s.y-n.y)*(s.z-n.z)}cloneTo(e){var t=e;this.getMin().cloneTo(t._boundBox.min),this.getMax().cloneTo(t._boundBox.max),this.getCenter().cloneTo(t._center),this.getExtent().cloneTo(t._extent),t._updateFlag=0}clone(){var e=new kt(new n,new n);return this.cloneTo(e),e}}kt._UPDATE_MIN=1,kt._UPDATE_MAX=2,kt._UPDATE_CENTER=4,kt._UPDATE_EXTENT=8,kt.TEMP_VECTOR3_MAX0=new n,kt.TEMP_VECTOR3_MAX1=new n;class Wt{constructor(){this._destroyed=!1}get destroyed(){return this._destroyed}_getType(){throw"GeometryElement:must override it."}_prepareRender(e){return!0}_render(e){throw"GeometryElement:must override it."}destroy(){this._destroyed||(this._destroyed=!0)}}Wt._typeCounter=0;class Xt{constructor(){}static get vertexDeclaration(){return Xt._vertexDeclaration}static __init__(){Xt._vertexDeclaration=new fe(28,[new Te(0,ue.Vector3,ze.MESH_POSITION0),new Te(12,ue.Vector4,ze.MESH_COLOR0)])}get vertexDeclaration(){return Xt._vertexDeclaration}}class Yt extends Wt{constructor(e,r){super(),this._floatCountPerVertices=7,this._minUpdate=Number.MAX_VALUE,this._maxUpdate=Number.MIN_VALUE,this._bufferState=new Ee,this._floatBound=new Float32Array(6),this._calculateBound=!1,this._maxLineCount=0,this._lineCount=0;var i=2*r;this._owner=e,this._maxLineCount=r,this._vertices=new Float32Array(i*this._floatCountPerVertices),this._vertexBuffer=new de(Xt.vertexDeclaration.vertexStride*i,t.LayaGL.instance.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=Xt.vertexDeclaration,this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind();var a=Yt._tempVector0,n=Yt._tempVector1;a.setValue(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n.setValue(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._bounds=new kt(a,n)}_getType(){return Yt._type}_resizeLineData(e){var r=2*e,i=this._vertices;this._vertexBuffer.destroy(),this._maxLineCount=e;var a=r*this._floatCountPerVertices;this._vertices=new Float32Array(a),this._vertexBuffer=new de(Xt.vertexDeclaration.vertexStride*r,t.LayaGL.instance.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=Xt.vertexDeclaration,a0){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)}}Yt._tempVector0=new n,Yt._tempVector1=new n,Yt._type=Wt._typeCounter++;class jt extends Ce{constructor(e){super(e)}static __init__(){jt.SHADERDEFINE_RECEIVE_SHADOW=xe.getDefineByName("RECEIVESHADOW"),jt.SAHDERDEFINE_LIGHTMAP=xe.getDefineByName("LIGHTMAP"),jt.SHADERDEFINE_LIGHTMAP_DIRECTIONAL=xe.getDefineByName("LIGHTMAP_DIRECTIONAL")}_onInActive(){super._onInActive(),this._scene._removeRenderObject(this._render)}_onActive(){super._onActive(),this._scene._addRenderObject(this._render)}_onActiveInScene(){if(super._onActiveInScene(),g.Laya3D._editerEnvironment){var e=this._scene,t=new a;e._allotPickColorByID(this.id,t),e._pickIdToSprite[this.id]=this,this._render._shaderValues.setVector(jt.PICKCOLOR,t)}}_addToInitStaticBatchManager(){}_setBelongScene(e){super._setBelongScene(e),this._render._setBelongScene(e)}_setUnBelongScene(){this._render._shaderValues.removeDefine(jt.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 jt(this.name)}}jt.LIGHTMAPSCALEOFFSET=xe.propertyNameToID("u_LightmapScaleOffset"),jt.LIGHTMAP=xe.propertyNameToID("u_LightMap"),jt.LIGHTMAP_DIRECTION=xe.propertyNameToID("u_LightMapDirection"),jt.PICKCOLOR=xe.propertyNameToID("u_PickColor"),jt.REFLECTIONTEXTURE=xe.propertyNameToID("u_ReflectTexture"),jt.REFLECTIONCUBE_HDR_PARAMS=xe.propertyNameToID("u_ReflectCubeHDRParams"),jt.REFLECTIONCUBE_PROBEPOSITION=xe.propertyNameToID("u_SpecCubeProbePosition"),jt.REFLECTIONCUBE_PROBEBOXMAX=xe.propertyNameToID("u_SpecCubeBoxMax"),jt.REFLECTIONCUBE_PROBEBOXMIN=xe.propertyNameToID("u_SpecCubeBoxMin");class Zt{constructor(){this.updateMark=-1,this.indexInList=-1,this.batched=!1}}class qt extends Wt{constructor(){super(),this.maxInstanceCount=1024,this.instanceWorldMatrixData=new Float32Array(16*this.maxInstanceCount),this.instanceMVPMatrixData=new Float32Array(16*this.maxInstanceCount),this.instanceSimpleAnimatorData=new Float32Array(4*this.maxInstanceCount);var e=t.LayaGL.instance;this.instanceWorldMatrixBuffer=new de(4*this.instanceWorldMatrixData.length,e.DYNAMIC_DRAW),this.instanceMVPMatrixBuffer=new de(4*this.instanceMVPMatrixData.length,e.DYNAMIC_DRAW),this.instanceWorldMatrixBuffer.vertexDeclaration=ze.instanceWorldMatrixDeclaration,this.instanceMVPMatrixBuffer.vertexDeclaration=ze.instanceMVPMatrixDeclaration,this.instanceSimpleAnimatorBuffer=new de(4*this.instanceSimpleAnimatorData.length,e.DYNAMIC_DRAW),this.instanceSimpleAnimatorBuffer.vertexDeclaration=ze.instanceSimpleAnimatorDeclaration}static __init__(){qt.instance=new qt}_render(e){var r=t.LayaGL.instance,i=e.renderElement,a=i.instanceSubMesh,n=i.instanceBatchElementList.length,s=a._indexCount;a._mesh._instanceBufferState.bind(),t.LayaGL.layaGPUInstance.drawElementsInstanced(r.TRIANGLES,s,r.UNSIGNED_SHORT,2*a._indexStart,n),t.Stat.renderBatches++,t.Stat.savedRenderBatches+=n-1,t.Stat.trianglesFaces+=s*n/3}}class Qt extends Ke{constructor(){super(),this._dynamicWorldPositionNormalNeedUpdate=!0}_onWorldMatrixChanged(){this._dynamicWorldPositionNormalNeedUpdate=!0}_computeWorldPositionsAndNormals(e,t,r,i){if(this._dynamicWorldPositionNormalNeedUpdate){for(var a=this._geometry,n=a._vertexBuffer,s=n.vertexDeclaration.vertexStride/4,o=n.getFloat32Data(),l=this._transform.worldMatrix,_=this._transform.rotation,h=a._indices,c=0;c1,a=i?t._indexCount:r._vertexCount;if(a<=g.SubMeshDynamicBatch.maxAllowVertexCount){var n=3*a;this._dynamicVertexBatch=!0,this._dynamicWorldPositions=new Float32Array(n),this._dynamicWorldNormals=new Float32Array(n),this._dynamicVertexCount=a,this._dynamicMultiSubMesh=i}else this._dynamicVertexBatch=!1}this._geometry=e}}addToOpaqueRenderQueue(e,r){var i=this.staticBatch,a=r.elements,n=a.elements;if(!i||this.render._probReflection&&!this.render._probReflection._isScene)if(this.renderSubShader._owner._enableInstancing&&t.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0&&(!this.render._probReflection||this.render._probReflection._isScene)){var s=this._geometry,o=g.MeshRenderDynamicBatchManager.instance,l=o.getInstanceBatchOpaquaMark(this.render.receiveShadow,this.material.id,s._id,this._transform._isFrontFaceInvert);if(o._updateCountMark===l.updateMark){var _=l.indexInList;if(l.batched){var h=n[_].instanceBatchElementList;h.length===qt.instance.maxInstanceCount?(l.updateMark=o._updateCountMark,l.indexInList=a.length,l.batched=!1,a.add(this)):h.add(this)}else{var c=n[_],d=c.render,u=o._getBatchRenderElementFromPool();u.renderType=Ke.RENDERTYPE_INSTANCEBATCH,u.setGeometry(qt.instance),u.material=c.material,u.setTransform(null),u.render=d,u.instanceSubMesh=s,u.renderSubShader=c.renderSubShader;var m=u.instanceBatchElementList;m.length=0,m.add(c),m.add(this),n[_]=u,l.batched=!0}}else l.updateMark=o._updateCountMark,l.indexInList=a.length,l.batched=!1,a.add(this)}else if(this._dynamicVertexBatch){var f=this._geometry._vertexBuffer.vertexDeclaration,T=g.MeshRenderDynamicBatchManager.instance,E=T.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,f.id);if(T._updateCountMark===E.updateMark){var p=E.indexInList;if(E.batched)n[p].vertexBatchElementList.add(this);else{var S=n[p],R=S.render,v=T._getBatchRenderElementFromPool();v.renderType=Ke.RENDERTYPE_VERTEXBATCH,v.setGeometry(g.SubMeshDynamicBatch.instance),v.material=S.material,v.setTransform(null),v.render=R,v.vertexBatchVertexDeclaration=f,v.renderSubShader=S.renderSubShader;var x=v.vertexBatchElementList;x.length=0,x.add(S),x.add(this),n[p]=v,E.batched=!0}}else E.updateMark=T._updateCountMark,E.indexInList=a.length,E.batched=!1,a.add(this)}else a.add(this);else{var A=g.MeshRenderStaticBatchManager.instance,I=A.getBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,i._batchID);if(A._updateCountMark===I.updateMark){var D=I.indexInList;if(I.batched)n[D].staticBatchElementList.add(this);else{var M=n[D],C=M.render,y=A._getBatchRenderElementFromPool();y.renderType=Ke.RENDERTYPE_STATICBATCH,y.setGeometry(i),y.material=M.material;var L=i.batchOwner,O=L?L._transform:null;y.setTransform(O),y.render=C,y.renderSubShader=M.renderSubShader;var N=y.staticBatchElementList;N.length=0,N.add(M),N.add(this),n[D]=y,I.batched=!0}}else I.updateMark=A._updateCountMark,I.indexInList=a.length,I.batched=!1,a.add(this)}}addToTransparentRenderQueue(e,r){var i=this.staticBatch,a=r.elements,n=a.elements;if(i){var s=g.MeshRenderStaticBatchManager.instance,o=r.lastTransparentRenderElement;if(o){var l=o.render;if(o._geometry._getType()!==this._geometry._getType()||o.staticBatch!==i||o.material!==this.material||l.receiveShadow!==this.render.receiveShadow||l.lightmapIndex!==this.render.lightmapIndex)a.add(this),r.lastTransparentBatched=!1;else{if(r.lastTransparentBatched)n[a.length-1].staticBatchElementList.add(this);else{var _=s._getBatchRenderElementFromPool();_.renderType=Ke.RENDERTYPE_STATICBATCH,_.setGeometry(i),_.material=o.material;var h=i.batchOwner,c=h?h._transform:null;_.setTransform(c),_.render=this.render,_.renderSubShader=o.renderSubShader;var d=_.staticBatchElementList;d.length=0,d.add(o),d.add(this),n[a.length-1]=_}r.lastTransparentBatched=!0}}else a.add(this),r.lastTransparentBatched=!1}else if(this.renderSubShader._owner._enableInstancing&&t.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0&&(!this.render._probReflection||this.render._probReflection._isScene)){var u=this._geometry,m=g.MeshRenderDynamicBatchManager.instance,f=r.lastTransparentRenderElement;if(f){var T=f.render;if(f._geometry._getType()!==this._geometry._getType()||f._geometry!==u||f.material!==this.material||T.receiveShadow!==this.render.receiveShadow)a.add(this),r.lastTransparentBatched=!1;else if(r.lastTransparentBatched){var E=n[a.length-1].instanceBatchElementList;E.length===qt.instance.maxInstanceCount?(a.add(this),r.lastTransparentBatched=!1):(E.add(this),r.lastTransparentBatched=!0)}else{var p=m._getBatchRenderElementFromPool();p.renderType=Ke.RENDERTYPE_INSTANCEBATCH,p.setGeometry(qt.instance),p.material=f.material,p.setTransform(null),p.render=this.render,p.instanceSubMesh=u,p.renderSubShader=f.renderSubShader;var S=p.instanceBatchElementList;S.length=0,S.add(f),S.add(this),n[a.length-1]=p,r.lastTransparentBatched=!0}}else a.add(this),r.lastTransparentBatched=!1}else if(this._dynamicVertexBatch){var R=this._geometry._vertexBuffer.vertexDeclaration,v=g.MeshRenderDynamicBatchManager.instance,x=r.lastTransparentRenderElement;if(x){var A=x.render;if(x._dynamicVertexBatch&&x._geometry._getType()===this._geometry._getType()&&x._geometry._vertexBuffer._vertexDeclaration===R&&x.material===this.material&&A.receiveShadow===this.render.receiveShadow&&A.lightmapIndex===this.render.lightmapIndex){if(r.lastTransparentBatched)n[a.length-1].vertexBatchElementList.add(this);else{var I=v._getBatchRenderElementFromPool();I.renderType=Ke.RENDERTYPE_VERTEXBATCH,I.setGeometry(g.SubMeshDynamicBatch.instance),I.material=x.material,I.setTransform(null),I.render=this.render,I.vertexBatchVertexDeclaration=R,I.renderSubShader=x.renderSubShader;var D=I.vertexBatchElementList;D.length=0,D.add(x),D.add(this),n[a.length-1]=I}r.lastTransparentBatched=!0}else a.add(this),r.lastTransparentBatched=!1}else a.add(this),r.lastTransparentBatched=!1}else a.add(this);r.lastTransparentRenderElement=this}getInvertFront(){switch(this.renderType){case Ke.RENDERTYPE_NORMAL:return this._transform._isFrontFaceInvert;case Ke.RENDERTYPE_STATICBATCH:case Ke.RENDERTYPE_VERTEXBATCH:return!1;case Ke.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 Kt{constructor(){this._initBatchSprites=[],this._staticBatches={},this._batchRenderElementPoolIndex=0,this._batchRenderElementPool=[]}static _addToStaticBatchQueue(e,t){e instanceof jt&&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),a=i-1;tJt.maxBatchVertexCount)}add(e){var t=e.meshFilter.sharedMesh,r=t.vertexCount;this._batchElements.push(e);var i=e._render;i._isPartOfStaticBatch=!0,i._staticBatch=this;for(var a=i._renderElements,n=0,s=a.length;n=0&&rthis.maxLineCount)throw"PixelLineSprite3D: lineCount can't large than maxLineCount";this._geometryFilter._lineCount=e}get pixelLineRenderer(){return this._render}_onInActive(){t.Stat.spriteCount--,0!=this._geometryFilter._lineCount&&this._isRenderActive&&(this._scene._removeRenderObject(this._render),this._isInRenders=!1),this._isRenderActive=!1}_onActive(){t.Stat.spriteCount++,this._isRenderActive=!0,0!=this._geometryFilter._lineCount&&(this._scene._addRenderObject(this._render),this._isInRenders=!0)}_changeRenderObjects(e,t,r){var i=this._render._renderElements;r||(r=zt.defaultMaterial);var a=i[t];a||(a=i[t]=new Ke),a.setTransform(this._transform),a.setGeometry(this._geometryFilter),a.render=this._render,a.material=r}addLine(e,t,r,i){if(this._geometryFilter._lineCount===this._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount has equal with maxLineCount.";this._geometryFilter._updateLineData(this._geometryFilter._lineCount++,e,t,r,i),this._isRenderActive&&!this._isInRenders&&this._geometryFilter._lineCount>0&&(this._scene._addRenderObject(this._render),this._isInRenders=!0)}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,this._isRenderActive&&!this._isInRenders&&this._geometryFilter._lineCount>0&&(this._scene._addRenderObject(this._render),this._isInRenders=!0)}removeLine(e){if(!(e0;)t--;if(e1){var r=this._partitionRenderObject(e,t),i=r-1;e=0;i--){var a=r[i];this._objects.push(a),a._setOctreeNode(this)}}}this._children=null}_merge(){if(null===this._children){var e=this._parent;e&&e._shouldMerge()&&(e._mergeChildren(),e._merge())}}_checkAddNode(e){if(null==this._children){if(this._objects.length=0;t--){var r=this._objects[t],i=this._bestFitChild(r.bounds.getCenter());nr._encapsulates(this._getChildBound(i),r.bounds._getBoundBox())&&(this._objects.splice(this._objects.indexOf(r),1),this._getChild(i)._add(r))}}var a=this._bestFitChild(e.bounds.getCenter());return nr._encapsulates(this._getChildBound(a),e.bounds._getBoundBox())?this._getChild(a)._checkAddNode(e):this}_add(e){var t=this._checkAddNode(e);t._objects.push(e),e._setOctreeNode(t)}_remove(e){var t=this._objects.indexOf(e);this._objects.splice(t,1),e._setOctreeNode(null),this._merge()}_addUp(e){return Ve.boxContainsBox(this._bounds,e.bounds._getBoundBox())===we.Contains?(this._add(e),!0):!!this._parent&&this._parent._addUp(e)}_getCollidingWithFrustum(e,r,i,a,s,o){var l=e.boundFrustum,_=e.position,h=e.cullingMask;if(i){var c=l.containsBoundBox(this._bounds);if(t.Stat.octreeNodeCulling++,c===we.Disjoint)return;i=c===we.Intersects}this._isContaion=!i;for(var d=r.scene,u=t.Stat.loopCount,m=0,f=this._objects.length;m=this.center.y?0:4)+(e.z<=this.center.z?0:2)}_update(e){if(Ve.boxContainsBox(this._bounds,e.bounds._getBoundBox())===we.Contains){var t=this._checkAddNode(e);if(t!==e._getOctreeNode()){t._objects.push(e),e._setOctreeNode(t);var r=this._objects.indexOf(e);this._objects.splice(r,1),this._merge()}return!0}if(this._parent){var i=this._parent._addUp(e);return i&&(r=this._objects.indexOf(e),this._objects.splice(r,1),this._merge()),i}return!1}add(e){return!!nr._encapsulates(this._bounds,e.bounds._getBoundBox())&&(this._add(e),!0)}remove(e){return e._getOctreeNode()===this&&(this._remove(e),!0)}update(e){return e._getOctreeNode()===this&&this._update(e)}shrinkIfPossible(e){if(this.baseLength<2*e)return this;for(var t=-1,r=0,i=this._objects.length;r=0&&t!=r)return this;l=!0,t=r}}if(-1!=t){var h=this._children[t];return h._parent=null,h}return this}hasAnyObjects(){if(this._objects.length>0)return!0;if(null!=this._children)for(var e=0;e<8;e++){var t=this._children[e];if(t&&t.hasAnyObjects())return!0}return!1}getCollidingWithBoundBox(e,t){this._getCollidingWithBoundBox(e,!0,t)}getCollidingWithRay(e,t,r=Number.MAX_VALUE){var i=Ve.intersectsRayAndBoxRD(e,this._bounds);if(!(-1==i||i>r)){for(var a=0,n=this._objects.length;at)return!1;for(var i=0,a=this._objects.length;ie&&(console.warn("Minimum node size must be at least as big as the initial world size. Was: "+r+" Adjusted to: "+e),r=e),this._initialSize=e,this._minSize=r,this._looseness=Math.min(Math.max(i,1),2),this._rootNode=new nr(this,null,e,t)}_getMaxDepth(e,t){t++;var r=e._children;if(null!=r)for(var i=t,a=0,n=r.length;a=0?1:-1,r=e.y>=0?1:-1,i=e.z>=0?1:-1,a=this._rootNode,s=this._rootNode.baseLength/2,o=2*this._rootNode.baseLength,l=this._rootNode.center,_=new n(l.x+t*s,l.y+r*s,l.z+i*s);if(this._rootNode=new nr(this,null,o,_),a.hasAnyObjects()){for(var h=this._rootNode._bestFitChild(a.center),c=[],d=0;d<8;d++)d==h&&(a._parent=this._rootNode,c[d]=a);this._rootNode._children=c}}add(e){for(var t=0;!this._rootNode.add(e);){var r=or._tempVector30;if(n.subtract(e.bounds.getCenter(),this._rootNode.center,r),this._grow(r),++t>20)throw"Aborted Add operation as it seemed to be going on forever ("+(t-1)+") attempts at growing the octree."}this.count++}remove(e){var t=e._getOctreeNode().remove(e);return t&&this.count--,t}update(e){var t=0,r=e._getOctreeNode();if(r){for(;!r._update(e);){var i=or._tempVector30;if(n.subtract(e.bounds.getCenter(),this._rootNode.center,i),this._grow(i),++t>20)throw"Aborted Add operation as it seemed to be going on forever ("+(t-1)+") attempts at growing the octree."}return!0}return!1}shrinkRootIfPossible(){this._rootNode=this._rootNode.shrinkIfPossible(this._initialSize)}addMotionObject(e){this._motionObjects.add(e)}removeMotionObject(e){this._motionObjects.remove(e)}updateMotionObjects(){for(var e=this._motionObjects.elements,t=0,r=this._motionObjects.length;t=e.length)throw new Error("start"+t+"Must be in the range [0, "+(e.length-1)+"]");if(r<0||t+r>e.length)throw new Error("count"+r+"Must be in the range <= "+e.length+"}");var a=t+r,s=_r._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");_r.createFromSubPoints(e,0,e.length,t)}intersectsRayDistance(e){return Ve.intersectsRayAndSphereRD(e,this)}intersectsRayPoint(e,t){return Ve.intersectsRayAndSphereRP(e,this,t)}cloneTo(e){var t=e;this.center.cloneTo(t.center),t.radius=this.radius}clone(){var e=new _r(new n,0);return this.cloneTo(e),e}}_r._tempVector3=new n;class hr{constructor(){this.cameraShaderValue=new me,this.position=new n,this.viewMatrix=new R,this.projectionMatrix=new R,this.viewProjectMatrix=new R,this.cullPlanes=[new Pe(new n),new Pe(new n),new Pe(new n),new Pe(new n),new Pe(new n),new Pe(new n),new Pe(new n),new Pe(new n),new Pe(new n),new Pe(new n)],this.splitBoundSphere=new _r(new n,0)}}class cr{constructor(){this.cameraShaderValue=new me,this.position=new n,this.viewMatrix=new R,this.projectionMatrix=new R,this.viewProjectMatrix=new R,this.cameraCullInfo=new Ct}}(ft=e.ShadowLightType||(e.ShadowLightType={}))[ft.DirectionLight=0]="DirectionLight",ft[ft.SpotLight=1]="SpotLight",ft[ft.PointLight=2]="PointLight";class dr{constructor(){this._shadowBias=new a,this._shadowParams=new a,this._shadowMapSize=new a,this._shadowSpotMapSize=new a,this._shadowMatrices=new Float32Array(16*dr._maxCascades),this._shadowSpotMatrices=new R,this._splitBoundSpheres=new Float32Array(4*dr._maxCascades),this._cascadeCount=0,this._shadowMapWidth=0,this._shadowMapHeight=0,this._shadowSliceDatas=[new hr,new hr,new hr,new hr],this._shadowSpotData=new cr,this._lightUp=new n,this._lightSide=new n,this._lightForward=new n,this._shadowSpotData.cameraCullInfo.boundFrustum=new Be(new R)}_setupShadowCasterShaderValues(t,r,i,a,n,s,o){switch(r.setVector(dr.SHADOW_BIAS,s),o){case e.LightType.Directional:r.setVector3(dr.SHADOW_LIGHT_DIRECTION,a);break;case e.LightType.Spot:r.setVector(dr.SHADOW_PARAMS,n);break;case e.LightType.Point:}var l=i.cameraShaderValue;l.setMatrix4x4(Xe.VIEWMATRIX,i.viewMatrix),l.setMatrix4x4(Xe.PROJECTMATRIX,i.projectionMatrix),l.setMatrix4x4(Xe.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(Ye.SHADERDEFINE_SHADOW_CASCADE):t.removeDefine(Ye.SHADERDEFINE_SHADOW_CASCADE),r.shadowMode){case e.ShadowMode.Hard:t.removeDefine(Ye.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW),t.removeDefine(Ye.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftLow:t.addDefine(Ye.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW),t.removeDefine(Ye.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftHigh:t.addDefine(Ye.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH),t.removeDefine(Ye.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW)}t.setTexture(dr.SHADOW_MAP,this._shadowDirectLightMap),t.setBuffer(dr.SHADOW_MATRICES,this._shadowMatrices),t.setVector(dr.SHADOW_MAP_SIZE,this._shadowMapSize),t.setVector(dr.SHADOW_PARAMS,this._shadowParams),t.setBuffer(dr.SHADOW_SPLIT_SPHERES,this._splitBoundSpheres)}_setupSpotShadowReceiverShaderValues(t){switch(this._light.shadowMode){case e.ShadowMode.Hard:t.removeDefine(Ye.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH),t.removeDefine(Ye.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW);break;case e.ShadowMode.SoftLow:t.addDefine(Ye.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW),t.removeDefine(Ye.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH);break;case e.ShadowMode.SoftHigh:t.addDefine(Ye.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH),t.removeDefine(Ye.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW)}t.setTexture(dr.SHADOW_SPOTMAP,this._shadowSpotLightMap),t.setMatrix4x4(dr.SHADOW_SPOTMATRICES,this._shadowSpotMatrices),t.setVector(dr.SHADOW_SPOTMAP_SIZE,this._shadowSpotMapSize),t.setVector(dr.SHADOW_PARAMS,this._shadowParams)}update(t,i,a){switch(a){case e.ShadowLightType.DirectionLight:this._light=i;var s=(D=dr._tempMatrix0).elements,o=this._lightUp,l=this._lightSide,_=this._lightForward;R.createFromQuaternion(i._transform.rotation,D),l.setValue(s[0],s[1],s[2]),o.setValue(s[4],s[5],s[6]),_.setValue(-s[8],-s[9],-s[10]);var h,c,d,u,m=i._shadowResolution,f=i._shadowCascadesMode;f==e.ShadowCascadesMode.NoCascades?(h=1,c=m,d=m,u=m):(h=f==e.ShadowCascadesMode.TwoCascades?2:4,d=2*(c=Ze.getMaxTileResolutionInAtlas(m,m,h)),u=f==e.ShadowCascadesMode.TwoCascades?c:2*c),this._cascadeCount=h,this._shadowMapWidth=d,this._shadowMapHeight=u;var T=dr._cascadesSplitDistance,E=dr._frustumPlanes,p=t.nearPlane,g=Math.min(t.farPlane,i._shadowDistance),S=this._shadowMatrices,v=this._splitBoundSpheres;Ze.getCascadesSplitDistance(i._shadowTwoCascadeSplits,i._shadowFourCascadeSplits,p,g,t.fieldOfView*r.Deg2Rad,t.aspectRatio,f,T),Ze.getCameraFrustumPlanes(t.projectionViewMatrix,E);var x=dr._tempVector30;t._transform.getForward(x),n.normalize(x,x);for(var A=0;A1&&Ze.applySliceTransform(I,d,u,A,S)}Ze.prepareShadowReceiverShaderValues(i,d,u,this._shadowSliceDatas,h,this._shadowMapSize,this._shadowParams,S,v);break;case e.ShadowLightType.SpotLight:this._light=i;var D=dr._tempMatrix0,M=(_=this._lightForward,this._light._shadowResolution);this._shadowMapWidth=M,this._shadowMapHeight=M;var C=this._shadowSpotData;Ze.getSpotLightShadowData(C,this._light,M,this._shadowParams,this._shadowSpotMatrices,this._shadowSpotMapSize);break;case e.ShadowLightType.PointLight:break;default:throw"There is no shadow of this type"}}render(r,i,a){switch(a){case e.ShadowLightType.DirectionLight:var n=i._shaderValues;r.pipelineMode="ShadowCaster",me.setRuntimeValueMode(!1),(T=this._shadowDirectLightMap=Ze.getTemporaryShadowTexture(this._shadowMapWidth,this._shadowMapHeight,t.RenderTextureDepthFormat.DEPTH_16))._start();for(var s=this._light,o=0,l=this._cascadeCount;ol.importance)continue;if((r=n.calculateBoundsintersection(l.bounds))e._renderingOrder?i=t-1:r=t+1}return r}_allotPickColorByID(e,t){var r=Math.floor(e/65025);e-=255*r*255;var i=Math.floor(e/255),a=e-=255*i;t.x=r/255,t.y=i/255,t.z=a/255,t.w=1}_searchIDByPickColor(e){return 255*e.x*255+255*e.y+e.z}onEnable(){this._input._onCanvasEvent(t.Render.canvas)}onDisable(){this._input._offCanvasEvent(t.Render.canvas)}_setCreateURL(e){this._url=t.URL.formatURL(e)}_getGroup(){return this._group}_setGroup(e){this._group=e}_clearScript(){if(this._needClearScriptPool){for(var e=this._scriptPool,t=0,r=e.length;t0){var o=this._directionLights.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(Tr.LIGHTBUFFER,t),e.setInt(Tr.DIRECTIONLIGHTCOUNT,this._directionLights._length),e.setTexture(Tr.CLUSTERBUFFER,Ne.instance._clusterTexture)}else{if(this._directionLights._length>0){var S=this._directionLights._elements[0];this._mainDirectionLight=S,n.scale(S.color,S._intensity,S._intensityColor),S.transform.worldMatrix.getForward(S._direction),n.normalize(S._direction,S._direction),e.setVector3(Tr.LIGHTDIRCOLOR,S._intensityColor),e.setVector3(Tr.LIGHTDIRECTION,S._direction),e.setVector3(Tr.SUNLIGHTDIRCOLOR,S._intensityColor),e.setVector3(Tr.SUNLIGHTDIRECTION,S._direction),e.addDefine(Ye.SHADERDEFINE_DIRECTIONLIGHT)}else e.removeDefine(Ye.SHADERDEFINE_DIRECTIONLIGHT);if(this._pointLights._length>0){var R=this._pointLights._elements[0];this._mainPointLight=R,n.scale(R.color,R._intensity,R._intensityColor),e.setVector3(Tr.POINTLIGHTCOLOR,R._intensityColor),e.setVector3(Tr.POINTLIGHTPOS,R.transform.position),e.setNumber(Tr.POINTLIGHTRANGE,R.range),e.addDefine(Ye.SHADERDEFINE_POINTLIGHT)}else e.removeDefine(Ye.SHADERDEFINE_POINTLIGHT);if(this._spotLights._length>0){var v=this._spotLights._elements[0];this._mainSpotLight=v,n.scale(v.color,v._intensity,v._intensityColor),e.setVector3(Tr.SPOTLIGHTCOLOR,v._intensityColor),e.setVector3(Tr.SPOTLIGHTPOS,v.transform.position),v.transform.worldMatrix.getForward(v._direction),n.normalize(v._direction,v._direction),e.setVector3(Tr.SPOTLIGHTDIRECTION,v._direction),e.setNumber(Tr.SPOTLIGHTRANGE,v.range),e.setNumber(Tr.SPOTLIGHTSPOTANGLE,v.spotAngle*Math.PI/180),e.addDefine(Ye.SHADERDEFINE_SPOTLIGHT)}else e.removeDefine(Ye.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;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(a),u=null,s.text=l,s.noCompile=!0,(c=l.indexOf("#"))>=0){for(_="#",T=c+1,f=l.length;T]/),s.noCompile?console.log("function():Boolean{return "+l.substr(c+s.name.length)+"}"):(d=l.replace(/^\s*/,"").split(/\s+/),s.setCondition(d[1],"#ifdef"===_?t.ShaderCompile.IFDEF_YES:t.ShaderCompile.IFDEF_ELSE),s.text="//"+s.text),s.setParent(e),e=s,n)for(d=l.substr(T).split(t.ShaderCompile._splitToWordExps3),T=0;T0&&t.ShaderCompile.splitToWords(l,o),u=s,o.text+="\n"+l;continue}a.length>0&&t.ShaderCompile.splitToWords(l,s)}s.setParent(e)}}_resizeCacheShaderMap(e,t,r){var i=this._cacheShaderHierarchy-1;if(t==i){for(var a in e)for(var n=e[a],s=0,o=r-i;sthis._cacheShaderHierarchy&&(this._resizeCacheShaderMap(n,0,s),this._cacheShaderHierarchy=s);for(var o=e._mask,l=e._length-1,_=this._cacheShaderHierarchy-1,h=0;h<_;h++){var c=lwr.maxIndicesCount&&(this._flush(n,s),o++,t.Stat.trianglesFaces+=s/3,n=s=0);var m=c._transform;this._getBatchVertices(i,this._vertices,n,m,c,d),this._getBatchIndices(this._indices,s,n,m,d,c._dynamicMultiSubMesh),n+=c._dynamicVertexCount,s+=u}this._flush(n,s),o++,t.Stat.renderBatches+=o,t.Stat.savedRenderBatches+=l-o,t.Stat.trianglesFaces+=s/3}}wr.maxAllowVertexCount=10,wr.maxAllowAttribueCount=900,wr.maxIndicesCount=32e3;class Vr extends ur{constructor(){super(),this._instanceBatchOpaqueMarks=[],this._vertexBatchOpaqueMarks=[],this._cacheBufferStates=[],this._updateCountMark=0}getInstanceBatchOpaquaMark(e,t,r,i){var a=this._instanceBatchOpaqueMarks[e?0:1]||(this._instanceBatchOpaqueMarks[e?0:1]=[]),n=a[t]||(a[t]=[]),s=n[r]||(n[r]=[]);return s[i?1:0]||(s[i?1:0]=new Zt)}getVertexBatchOpaquaMark(e,t,r,i){var a=this._vertexBatchOpaqueMarks[e]||(this._vertexBatchOpaqueMarks[e]=[]),n=a[t?0:1]||(a[t?0:1]=[]),s=n[r]||(n[r]=[]);return s[i]||(s[i]=new Zt)}_getBufferState(e){var t=this._cacheBufferStates[e.id];if(!t){var r=wr.instance;(t=new Ee).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 Qt,this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=e,e.vertexBatchElementList=new b,e.instanceBatchElementList=new b),e}_clear(){super._clear(),this._updateCountMark++}}Vr.instance=new Vr;class Br extends jt{constructor(e=null,t=null){super(t),this._meshFilter=new br(this),this._render=new Pr(this),e&&(this._meshFilter.sharedMesh=e)}static __init__(){Nr.SHADERDEFINE_UV0=xe.getDefineByName("UV"),Nr.SHADERDEFINE_COLOR=xe.getDefineByName("COLOR"),Nr.SHADERDEFINE_UV1=xe.getDefineByName("UV1"),Nr.SHADERDEFINE_GPU_INSTANCE=xe.getDefineByName("GPU_INSTANCE"),Nr.SHADERDEFINE_SPECCUBE_BOX_PROJECTION=xe.getDefineByName("SPECCUBE_BOX_PROJECTION"),Kt._registerManager($t.instance),ur._registerManager(Vr.instance)}get meshFilter(){return this._meshFilter}get meshRenderer(){return this._render}_parse(e,r){super._parse(e,r);var i=this.meshRenderer,n=e.lightmapIndex;null!=n&&(i.lightmapIndex=n);var s=e.lightmapScaleOffset;s&&(i.lightmapScaleOffset=new a(s[0],s[1],s[2],s[3])),null!=e.meshPath&&(this.meshFilter.sharedMesh=t.Loader.getRes(e.meshPath)),null!=e.enableRender&&(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&&$t.instance._addBatchSprite(this)}_cloneTo(e,t,r){var i=e;i._meshFilter.sharedMesh=this._meshFilter.sharedMesh;var a=this._render,n=i._render;n.enable=a.enable,n.sharedMaterials=a.sharedMaterials,n.castShadow=a.castShadow;var s=a.lightmapScaleOffset;s&&(n.lightmapScaleOffset=s.clone()),n.lightmapIndex=a.lightmapIndex,n.receiveShadow=a.receiveShadow,n.sortingFudge=a.sortingFudge,super._cloneTo(e,t,r)}destroy(e=!0){this.destroyed||(super.destroy(e),this._meshFilter.destroy())}_create(){return new Br}}class Fr{}Fr.Blend=0,Fr.Fixed=1;class Ur{constructor(e,t){this._mode=0,this._maxColorRGBKeysCount=0,this._maxColorAlphaKeysCount=0,this._colorRGBKeysCount=0,this._colorAlphaKeysCount=0,this._alphaElements=null,this._rgbElements=null,this._maxColorRGBKeysCount=e,this._maxColorAlphaKeysCount=t,this._rgbElements=new Float32Array(4*e),this._alphaElements=new Float32Array(2*t)}get mode(){return this._mode}set mode(e){this._mode=e}get colorRGBKeysCount(){return this._colorRGBKeysCount}get colorAlphaKeysCount(){return this._colorAlphaKeysCount}get maxColorRGBKeysCount(){return this._maxColorRGBKeysCount}get maxColorAlphaKeysCount(){return this._maxColorAlphaKeysCount}addColorRGB(e,t){if(this._colorRGBKeysCount=0;s--){var o=4*s;if(e===(u=a[o]))return t.r=a[o+1],t.g=a[o+2],t.b=a[o+3],n;switch(this._mode){case Fr.Blend:if(e>u){if(e>(d=a[o+4]))throw"Gradient:wrong startSearchIndex.";var l=d-u,_=d-e,h=e-u;return t.r=(_*a[o+1]+h*a[o+5])/l,t.g=(_*a[o+2]+h*a[o+6])/l,t.b=(_*a[o+3]+h*a[o+7])/l,n}n--;continue;case Fr.Fixed:if(e>u){if(e>a[o+4])throw"Gradient:wrong startSearchIndex.";return t.r=a[o+5],t.g=a[o+6],t.b=a[o+7],n}n--;continue;default:throw"Gradient:unknown mode."}}else{s=0;for(var c=this._rgbElements.length;s=0;s--){if(e===(u=a[c=2*s]))return t.a=a[c+1],n;switch(this._mode){case Fr.Blend:if(e>u){if(e>(d=a[c+2]))throw"Gradient:wrong startSearchIndex.";var o=d-u,l=d-e,_=e-u;return t.a=(l*a[c+1]+_*a[c+3])/o,n}n--;continue;case Fr.Fixed:if(e>u){if(e>a[c+2])throw"Gradient:wrong startSearchIndex.";return t.a=a[c+3],n}n--;continue;default:throw"Gradient:unknown mode."}}else{s=n;for(var h=this._alphaElements.length;s>>15}get seed(){return this.seeds[0]}set seed(e){this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}getUint(){return this._temp[0]=this.seeds[0]^this.seeds[0]<<11,this.seeds[0]=this.seeds[1],this.seeds[1]=this.seeds[2],this.seeds[2]=this.seeds[3],this.seeds[3]=this.seeds[3]^this.seeds[3]>>>19^this._temp[0]^this._temp[0]>>>8,this.seeds[3]}getFloat(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)}getSignedFloat(){return 2*this.getFloat()-1}}class mi{constructor(){this._emissionRate=10,this._destroyed=!1,this._bursts=[]}set emissionRate(e){if(e<0)throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");this._emissionRate=e}get emissionRate(){return this._emissionRate}get destroyed(){return this._destroyed}destroy(){this._bursts=null,this._destroyed=!0}getBurstsCount(){return this._bursts.length}getBurstByIndex(e){return this._bursts[e]}addBurst(e){var t=this._bursts.length;if(t>0)for(var r=0;re.time&&this._bursts.splice(r,0,e);this._bursts.push(e)}removeBurst(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)}removeBurstByIndex(e){this._bursts.splice(e,1)}clearBurst(){this._bursts.length=0}cloneTo(e){var t=e,r=t._bursts;r.length=this._bursts.length;for(var i=0,a=this._bursts.length;i=r){var s=e.getKeyByIndex(i-1),o=(r-s)/(n-s);return t.MathUtil.lerp(e.getValueByIndex(i-1),e.getValueByIndex(i),o)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")}static _randomInvertRoationArray(e,t,r,i,a){var n;i?(i.seed=a[6],n=i.getFloat(),a[6]=i.seed):n=Math.random(),n=this._firstRetiredElement?this._firstNewElement-this._firstRetiredElement:this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement}get emissionTime(){return this._emissionTime>this.duration?this.duration:this._emissionTime}get shape(){return this._shape}set shape(e){this._shape!==e&&(e&&e.enable?this._owner._render._shaderValues.addDefine(oi.SHADERDEFINE_SHAPE):this._owner._render._shaderValues.removeDefine(oi.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;t0?(n.scale(l,s,C),n.scale(_,s,y)):(n.scale(l,-s,y),n.scale(_,-s,C)),this.velocityOverLifetime&&this.velocityOverLifetime.enable){var L=this.velocityOverLifetime.velocity,O=Ti._tempVector37;switch(O.setValue(0,0,0),L.type){case 0:L.constant.cloneTo(O);break;case 2:L.constantMax.cloneTo(O);break;case 1:var N=L.gradientX.getAverageValue(),P=L.gradientY.getAverageValue(),b=L.gradientZ.getAverageValue();O.setValue(N,P,b);break;case 3:var w=L.gradientXMax.getAverageValue(),V=L.gradientYMax.getAverageValue(),B=L.gradientZMax.getAverageValue();O.setValue(w,V,B)}1==this.velocityOverLifetime.space&&n.transformV3ToV3(O,this._owner.transform.worldMatrix,O),n.add(C,O,C),n.subtract(y,O,y),n.max(C,n._ZERO,C),n.max(y,n._ZERO,y)}n.scale(C,a,C),n.scale(y,a,y);var F=this.gravityModifier;if(0!=F){var U=.5*Ti.g*F*a*a,G=C.y-U,z=y.y+U;G=G>0?G:0,z=z>0?z:0,this._gravityOffset.setValue(C.y-G,z-y.y)}n.add(C,I,i),n.add(i,h,i),n.add(y,I,r),n.add(r,c,r),n.scale(r,-1,r),this._bounds.setMin(r),this._bounds.setMax(i)}get customBounds(){return this._customBounds}set customBounds(e){this._useCustomBounds=!!e,this._customBounds=e}_simulationSupported(){return 0!=this.simulationSpace}_updateEmission(){if(this.isAlive)if(this._simulateUpdate)this._simulateUpdate=!1;else{var e=this._startUpdateLoopCount===t.Stat.loopCount||this._isPaused?0:this._owner._scene.timer._delta/1e3;e=Math.min(Ti._maxElapsedTime,e*this.simulationSpeed),this._updateParticles(e)}}_updateParticles(e){(4!==this._ownerRender.renderMode||this._ownerRender.mesh)&&(this._currentTime+=e,this._retireActiveParticles(),this._freeRetiredParticles(),this._totalDelayTime+=e,this._totalDelayTime=this._bufferMaxParticles&&(this._firstActiveElement=0)}}_freeRetiredParticles(){for(;this._firstRetiredElement!=this._firstActiveElement;){this._drawCounter,this._vertices[this._firstRetiredElement*this._floatCountPerVertex*this._vertexStride+this._timeIndex];this._firstRetiredElement++,this._firstRetiredElement>=this._bufferMaxParticles&&(this._firstRetiredElement=0)}}_burst(e,r){for(var i=0,a=this._emission._bursts,n=a.length;this._burstsIndexthis.duration){if(!this.looping){for(a=Math.min(this.maxParticles-this.aliveParticleCount,a),r=0;r0){var s=1/n;for(this._frameRateTime+=s,this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)%this._maxStartLifetime;this._frameRateTime<=t&&this.emit(this._frameRateTime);)this._frameRateTime+=s;this._frameRateTime=Math.floor(t/s)*s}}_initBufferDatas(){if(this._vertexBuffer){var r=this._vertexBuffer._byteLength+2*this._indexBuffer.indexCount;this._vertexBuffer.destroy(),this._indexBuffer.destroy(),t.Resource._addMemory(-r,-r)}var i=t.LayaGL.instance,a=this._ownerRender,n=a.renderMode;if(-1!==n&&this.maxParticles>0){var s,o,l,_,h,c,d,u=0,m=(r=0,a.mesh);if(4===n){if(m){d=di.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 de(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 Ge(e.IndexFormat.UInt16,p,i.STATIC_DRAW),s=new Uint16Array(p),r=u+2*p,h=0,o=0;o=this._bufferMaxParticles&&(a=0),a===this._firstRetiredElement)return!1;var s,o,l,_,h,c,d,u,m,f,T=this._owner.transform;if(fi.create(this,this._ownerRender,T),this._currentTime-i>=fi.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 x=this._textureSheetAnimation&&this._textureSheetAnimation.enable;x?3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?f=Math.random():(this._rand.seed=this._randomSeeds[15],f=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):x=!1:x=!1;var A,I,D,M,C,y,L=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,O=fi.startUVInfo[0],N=fi.startUVInfo[1],P=fi.startUVInfo[2],b=fi.startUVInfo[3],w=this._ownerRender;if(4===w.renderMode){var V=w.mesh._vertexBuffer;A=V.getFloat32Data();var B=V.vertexDeclaration;D=B.getVertexElementByUsage(ze.MESH_POSITION0)._offset/4;var F=B.getVertexElementByUsage(ze.MESH_COLOR0);M=F?F._offset/4:-1;var U=B.getVertexElementByUsage(ze.MESH_TEXTURECOORDINATE0);C=U?U._offset/4:-1,I=B.vertexStride/4,y=0}else{this._vertices[L+2]=P,this._vertices[L+3]=b+N;var G=L+this._floatCountPerVertex;this._vertices[G+2]=P+O,this._vertices[G+3]=b+N;var z=G+this._floatCountPerVertex;this._vertices[z+2]=P+O,this._vertices[z+3]=b;var H=z+this._floatCountPerVertex;this._vertices[H+2]=P,this._vertices[H+3]=b}for(var k=L,W=L+this._floatCountPerVertex*this._vertexStride;k0&&this._vertexBuffer.setData(this._vertices.buffer,0,0,this._firstFreeElement*t)),this._firstNewElement=this._firstFreeElement}_getType(){return Ti._type}_prepareRender(e){return this._updateMask!=t.Stat.loopCount&&(this._updateMask=t.Stat.loopCount,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 n=a[r];t.addColorAlpha(n.key,n.value)}else t.addColorAlpha(0,1),t.addColorAlpha(1,1);var s=e.rgbs;if(s)for(r=0,i=s.length;r4&&(r=i-1,console.warn("GradientDataColor warning:rgb data length is large than 4, will ignore the middle data."));var o=s[r],l=o.value;t.addColorRGB(o.key,new Mt(l[0],l[1],l[2],1))}else t.addColorRGB(0,new Mt(1,1,1,1)),t.addColorRGB(1,new Mt(1,1,1,1))}else t.addColorAlpha(0,1),t.addColorAlpha(1,1),t.addColorRGB(0,new Mt(1,1,1,1)),t.addColorRGB(1,new Mt(1,1,1,1));return t}_initParticleFrame(e){var t=new Xr;if(e)for(var r=e.frames,i=0,a=r.length;i=r.zeroTolerance?(this._isTempEndVertex?(_=this._endIndex-1,h=c-this._subDistance[_],this._updateVerticesByPosition(i,s,c,_),this._owner._totalLength+=h):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(i,s,c,this._endIndex),this._owner._totalLength+=c,this._endIndex++),i.cloneTo(this._lastFixedVertexPosition),this._isTempEndVertex=!1):(this._isTempEndVertex?(_=this._endIndex-1,h=c-this._subDistance[_],this._updateVerticesByPosition(i,s,c,_),this._owner._totalLength+=h):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(i,s,c,this._endIndex),this._owner._totalLength+=c,this._endIndex++),this._isTempEndVertex=!0)}_updateVerticesByPositionData(e,t,r){var i=2*this._floatCountPerVertices1*r,a=this._owner._curtime;this._vertices1[i]=e.x,this._vertices1[i+1]=e.y,this._vertices1[i+2]=e.z,this._vertices1[i+3]=-t.x,this._vertices1[i+4]=-t.y,this._vertices1[i+5]=-t.z,this._vertices1[i+6]=a,this._vertices1[i+7]=1,this._vertices1[i+8]=e.x,this._vertices1[i+9]=e.y,this._vertices1[i+10]=e.z,this._vertices1[i+11]=t.x,this._vertices1[i+12]=t.y,this._vertices1[i+13]=t.z,this._vertices1[i+14]=a,this._vertices1[i+15]=0;var s=this._owner._owner.trailRenderer.bounds,o=s.getMin(),l=s.getMax(),_=Ai._tempVector35,h=Ai._tempVector36,c=Ai._tempVector32;n.add(e,t,_),n.subtract(e,t,h),n.min(h,_,c),n.min(o,c,o),s.setMin(o),n.max(_,h,c),n.max(l,c,l),s.setMax(l);var d=2*this._floatCountPerVertices1;this._vertexBuffer1.setData(this._vertices1.buffer,4*i,4*i,4*d)}_updateVerticesByPosition(e,t,r,i){this._updateVerticesByPositionData(e,t,i),this._subDistance[i]=r,this._subBirthTime[i]=this._owner._curtime}_updateVertexBufferUV(){var e,t,r;if(this._disappearBoundsMode){e=this._owner._owner.trailRenderer.bounds;var i=this._owner._owner.transform.position;e.setMin(i),e.setMax(i),t=e.getMin(),r=e.getMax()}for(var a=this._endIndex,s=0,o=this._owner.colorGradient,l=o.colorAlphaKeysCount-1,_=o.colorRGBKeysCount-1,h=this._owner._totalLength,c=2*this._floatCountPerVertices2,d=this._activeIndex;d=this._owner.time+r.zeroTolerance;t++){var i=t+1;if(i!==e&&(this._owner._totalLength-=this._subDistance[i]),this._isTempEndVertex&&i===e-1){this._floatCountPerVertices1;var a=this._lastFixedVertexPosition;a.x=this._vertices1[0],a.y=this._vertices1[1],a.z=this._vertices1[2],this._isTempEndVertex=!1}this._activeIndex++,this._disappearBoundsMode=!0}}_getType(){return Ai._type}_prepareRender(e){return this._endIndex-this._activeIndex>1}_render(e){this._bufferState.bind();var r=t.LayaGL.instance,i=2*this._activeIndex,a=2*this._endIndex-i;r.drawArrays(r.TRIANGLE_STRIP,i,a),t.Stat.renderBatches++,t.Stat.trianglesFaces+=a-2}destroy(){super.destroy();var e=this._vertexBuffer1._byteLength+this._vertexBuffer2._byteLength;t.Resource._addMemory(-e,-e),this._bufferState.destroy(),this._vertexBuffer1.destroy(),this._vertexBuffer2.destroy(),this._bufferState=null,this._vertices1=null,this._vertexBuffer1=null,this._vertices2=null,this._vertexBuffer2=null,this._subBirthTime=null,this._subDistance=null,this._lastFixedVertexPosition=null,this._disappearBoundsMode=!1}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 n,Ai._tempVector31=new n,Ai._tempVector32=new n,Ai._tempVector33=new n,Ai._tempVector34=new n,Ai._tempVector35=new n,Ai._tempVector36=new n,Ai._type=Wt._typeCounter++;class Ii{constructor(e){this._totalLength=0,this._lastPosition=new n,this._curtime=0,this.alignment=Ii.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(Ii.LIFETIME,e)}get minVertexDistance(){return this._minVertexDistance}set minVertexDistance(e){this._minVertexDistance=e}get widthMultiplier(){return this._widthMultiplier}set widthMultiplier(e){this._widthMultiplier=e}get widthCurve(){return this._widthCurve}set widthCurve(e){this._widthCurve=e;var t,r,i=new Float32Array(4*e.length),a=0;for(t=0,r=e.length;t{},setWorldTransform:(e,t)=>{var r=P._physicObjectsMap[e];r._simulation._updatedRigidbodies++,r._updateTransformComponent(t)}};class Li extends W{constructor(e=D.COLLISIONFILTERGROUP_DEFAULTFILTER,t=D.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=Y._bullet,t=e.btCollisionObject_create();e.btCollisionObject_setUserIndex(t,this.id),e.btCollisionObject_forceActivationState(t,P.ACTIVATIONSTATE_DISABLE_SIMULATION);var r=e.btCollisionObject_getCollisionFlags(t);this.owner.isStatic?((r&P.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(r^=P.COLLISIONFLAGS_KINEMATIC_OBJECT),r|=P.COLLISIONFLAGS_STATIC_OBJECT):((r&P.COLLISIONFLAGS_STATIC_OBJECT)>0&&(r^=P.COLLISIONFLAGS_STATIC_OBJECT),r|=P.COLLISIONFLAGS_KINEMATIC_OBJECT),e.btCollisionObject_setCollisionFlags(t,r),this._btColliderObject=t,super._onAdded()}}class Oi extends Wt{constructor(e){super(),this._id=++Oi._uniqueIDCounter,this._mesh=e,this._boneIndicesList=[],this._subIndexBufferStart=[],this._subIndexBufferCount=[]}get indexCount(){return this._indexCount}_setIndexRange(t,r,i=e.IndexFormat.UInt16){this._indexStart=t,this._indexCount=r,i==e.IndexFormat.UInt16?this._indices=new Uint16Array(this._indexBuffer.getData().buffer,2*t,r):this._indices=new Uint32Array(this._indexBuffer.getData().buffer,4*t,r)}_getType(){return Oi._type}_prepareRender(e){return this._mesh._uploadVerticesData(),!0}_render(r){var i=this._mesh;if(i.indexFormat!==e.IndexFormat.UInt32||t.LayaGL.layaGPUInstance.supportElementIndexUint32()){var a,n,s=t.LayaGL.instance,o=r.renderElement.render._skinnedData;switch(i.indexFormat){case e.IndexFormat.UInt32:a=s.UNSIGNED_INT,n=4;break;case e.IndexFormat.UInt16:a=s.UNSIGNED_SHORT,n=2;break;case e.IndexFormat.UInt8:a=s.UNSIGNED_BYTE,n=1}if(i._bufferState.bind(),o)for(var l=o[this._indexInMesh],_=0,h=this._boneIndicesList.length;_0) dH = 1/(realRoughness^2+1)\r\n\r\n // 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]\r\n // 1-x^3*(0.6-0.08*x) approximation for 1/(x^4+1)\r\n\t// #ifdef LAYA_COLORSPACE_GAMMA\r\n\t\tmediump float surfaceReduction = 0.28;\r\n\t// #else\r\n\t\t// mediump float surfaceReduction = (0.6-0.08*perceptualRoughness);\r\n\t// #endif\r\n\r\n surfaceReduction = 1.0 - roughness*perceptualRoughness*surfaceReduction;\r\n\r\n\tmediump float grazingTerm = clamp(smoothness + (1.0-oneMinusReflectivity),0.0,1.0);\r\n\tmediump vec3 color =gi.diffuse * diffColor+ surfaceReduction * gi.specular * fresnelLerpFast (specColor, vec3(grazingTerm), nv);\r\n\r\n return vec4(color, 1.0);\r\n}\r\n// BRDF2-------------------------------------------------------------------------------------',ea="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#if !defined(SETUP_BRDF_INPUT)//shader内部的宏需要将改成#ifdef改成#if类型 不然会被Laya的shader分析器优化掉\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,vec3 worldPos)\r\n{\r\n\tLayaGIInput giInput;\r\n\t#ifdef LIGHTMAP\r\n\t\tgiInput.lightmapUV=lightmapUV;\r\n\t#endif\r\n\tgiInput.worldPos = worldPos;\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#if defined(CALCULATE_SHADOWS)//shader中自定义的宏不可用ifdef 必须改成if defined\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#if defined(CALCULATE_SPOTSHADOWS)//shader中自定义的宏不可用ifdef 必须改成if defined\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\r\n",ta="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#if defined(CALCULATE_SPOTSHADOWS)//shader中自定义的宏不可用ifdef 必须改成if defined\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif",ra="#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#if defined(CALCULATE_SPOTSHADOWS)//shader中自定义的宏不可用ifdef 必须改成if defined\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",ia="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;\r\n\t \t#ifdef SIMPLEBONE\r\n\t\t\tfloat currentPixelPos;\r\n\t\t\t#ifdef GPU_INSTANCE\r\n\t\t\t\tcurrentPixelPos = a_SimpleTextureParams.x+a_SimpleTextureParams.y;\r\n\t\t\t#else\r\n\t\t\t\tcurrentPixelPos = u_SimpleAnimatorParams.x+u_SimpleAnimatorParams.y;\r\n\t\t\t#endif\r\n\t\t\tfloat offset = 1.0/u_SimpleAnimatorTextureSize;\r\n\t\t\tskinTransform = loadMatFromTexture(currentPixelPos,int(a_BoneIndices.x),offset) * a_BoneWeights.x;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.y),offset) * a_BoneWeights.y;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.z),offset) * a_BoneWeights.z;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.w),offset) * a_BoneWeights.w;\r\n\t\t#else\r\n\t\t\tskinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\t#endif\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 =(u_CameraPos*worldInvMat-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#if defined(CALCULATE_SPOTSHADOWS)//shader中自定义的宏不可用ifdef 必须改成if defined\r\n\t\tv_SpotShadowCoord = u_SpotViewProjectMatrix*vec4(v_PositionWorld,1.0);\r\n\t#endif\r\n}",aa='#include "Lighting.glsl";\r\n#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\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}',na='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',sa='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',oa='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',la='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',_a='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',ha='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',ca='#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}',da='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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}',ua='#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}',ma="// 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}",fa="#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}",Ta='#ifndef GRAPHICS_API_GLES3\r\n\t#define NO_NATIVE_SHADOWMAP\r\n#endif\r\n\r\n#if defined(NO_NATIVE_SHADOWMAP)\r\n\t#define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2D textureName\r\n\t#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName,coord3.xy).r 3)// out of shadow range cascadeIndex is 4.\r\n\t\t\t\treturn vec4(0.0);\r\n\t\t\t\r\n\t\t\t#ifdef GRAPHICS_API_GLES3\r\n\t\t\t\treturn u_ShadowMatrices[cascadeIndex] * positionWS;\r\n\t\t\t#else\r\n\t\t\t\tmat4 shadowMat;\r\n\t\t\t\tif(cascadeIndex == 0)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[0];\r\n\t\t\t\telse if(cascadeIndex == 1)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[1];\r\n\t\t\t\telse if(cascadeIndex == 2)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[2];\r\n\t\t\t\telse\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[3];\r\n\t\t\t\treturn shadowMat * positionWS;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\treturn u_ShadowMatrices[0] * positionWS;\r\n\t\t#endif\r\n\t}\r\n\r\n\tfloat 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#if defined(CALCULATE_SPOTSHADOWS)//shader���Զ���ĺ겻����ifdef ����ij�if defined\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_SpotShadowMapSize);\r\n\t\t\t#elif defined(SHADOW_SPOT_SOFT_SHADOW_LOW)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered4(u_SpotShadowMap,shadowCoord.xyz,u_SpotShadowMapSize);\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',Ea='#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\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;\r\n\t \t#ifdef SIMPLEBONE\r\n\t\t\tfloat currentPixelPos;\r\n\t\t\t#ifdef GPU_INSTANCE\r\n\t\t\t\tcurrentPixelPos = a_SimpleTextureParams.x+a_SimpleTextureParams.y;\r\n\t\t\t#else\r\n\t\t\t\tcurrentPixelPos = u_SimpleAnimatorParams.x+u_SimpleAnimatorParams.y;\r\n\t\t\t#endif\r\n\t\t\tfloat offset = 1.0/u_SimpleAnimatorTextureSize;\r\n\t\t\tskinTransform = loadMatFromTexture(currentPixelPos,int(a_BoneIndices.x),offset) * a_BoneWeights.x;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.y),offset) * a_BoneWeights.y;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.z),offset) * a_BoneWeights.z;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.w),offset) * a_BoneWeights.w;\r\n\t\t#else\r\n\t\t\tskinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\t#endif\r\n\t\tworldMat = worldMat * skinTransform;\r\n\t#endif\r\n\r\n\tvec4 positionWS = worldMat * a_Position;\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\tvec3 normalWS = normalize(a_Normal*worldInvMat);//if no normalize will cause precision problem\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',pa="vec4 shadowCasterFragment()\r\n{\r\n return vec4(0.0);\r\n}\r\n",ga="#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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",Sa='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\r\nprecision highp float;\r\n#else\r\nprecision mediump float;\r\n#endif\r\n#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',Ra='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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',va="#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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",xa="#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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 ",Aa='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n#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\tvec3 cameraPos = (u_View*vec4(a_Position,1.0)).rgb;\r\n\tgl_Position = u_Projection * vec4(cameraPos+a_OffsetVector * getCurWidth(normalizeTime),1.0);\r\n\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n',Ia="#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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",Da='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n#include "Lighting.glsl";\r\n#include "LayaUtile.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;\r\n\t \t#ifdef SIMPLEBONE\r\n\t\t\tfloat currentPixelPos;\r\n\t\t\t#ifdef GPU_INSTANCE\r\n\t\t\t\tcurrentPixelPos = a_SimpleTextureParams.x+a_SimpleTextureParams.y;\r\n\t\t\t#else\r\n\t\t\t\tcurrentPixelPos = u_SimpleAnimatorParams.x+u_SimpleAnimatorParams.y;\r\n\t\t\t#endif\r\n\t\t\tfloat offset = 1.0/u_SimpleAnimatorTextureSize;\r\n\t\t\tskinTransform = loadMatFromTexture(currentPixelPos,int(a_BoneIndices.x),offset) * a_BoneWeights.x;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.y),offset) * a_BoneWeights.y;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.z),offset) * a_BoneWeights.z;\r\n\t\t\tskinTransform += loadMatFromTexture(currentPixelPos,int(a_BoneIndices.w),offset) * a_BoneWeights.w;\r\n\t\t#else\r\n\t\t\tskinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\t#endif\r\n\t\tposition=skinTransform*a_Position;\r\n\t #else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t#else\r\n\t\tv_Texcoord0=a_Texcoord0;\r\n\t#endif\r\n\r\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\t\tv_Color = a_Color;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',Ma='#if defined(GL_FRAGMENT_PRECISION_HIGH)// 原来的写法会被我们自己的解析流程处理,而我们的解析是不认内置宏的,导致被删掉,所以改成 if defined 了\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',Ca='#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}',ya="#define SAMPLE_DEPTH_TEXTURE(textureName,coord2) (texture2D(textureName,coord2).r)\r\n//此方法库用来压缩解析深度贴图,法线深度贴图\r\n\r\n/*camera 传入的Texture以及*/\r\nuniform sampler2D u_CameraDepthTexture;\r\nuniform vec4 u_ZBufferParams;\r\nuniform sampler2D u_CameraDepthNormalsTexture;\r\n\r\n// Encoding/decoding view space normals into 2D 0..1 vector\r\nvec2 EncodeViewNormalStereo( vec3 n )\r\n{\r\n n.z = abs(n.z);\r\n float kScale = 1.7777;\r\n vec2 enc;\r\n enc = n.xy / (n.z+1.0);\r\n enc /= kScale;\r\n enc = enc*0.5+0.5;\r\n return enc;\r\n}\r\n\r\nvec3 DecodeViewNormalStereo( vec4 enc4 )\r\n{\r\n float kScale = 1.7777;\r\n vec3 nn = enc4.xyz*vec3(2.0*kScale,2.0*kScale,0.0) + vec3(-kScale,-kScale,1.0);\r\n float g = 2.0 / dot(nn.xyz,nn.xyz);\r\n vec3 n;\r\n n.xy = g*nn.xy;\r\n n.z = g-1.0;\r\n return n;\r\n}\r\n\r\n\r\n// Encoding/decoding [0..1) floats into 8 bit/channel RG. Note that 1.0 will not be encoded properly.\r\nvec2 EncodeFloatRG( float v )\r\n{\r\n vec2 kEncodeMul = vec2(1.0, 255.0);\r\n float kEncodeBit = 1.0/255.0;\r\n vec2 enc = kEncodeMul * v;\r\n enc = fract(enc);\r\n enc.x -= enc.y * kEncodeBit;\r\n return enc;\r\n}\r\n\r\n\r\n\r\nfloat DecodeFloatRG( vec2 enc )\r\n{\r\n vec2 kDecodeDot = vec2(1.0, 1.0/255.0);\r\n return dot( enc, kDecodeDot );\r\n}\r\n\r\nvec4 EncodeDepthNormal(float depth,vec3 normals){\r\n\tvec4 encode;\r\n\tencode.xy = EncodeViewNormalStereo(normals);\r\n\tencode.zw = EncodeFloatRG(depth);\r\n return encode;\r\n}\r\n\r\nvoid DecodeDepthNormal( vec4 enc, out float depth, out vec3 normal )\r\n{\r\n depth = DecodeFloatRG (enc.zw);\r\n normal = DecodeViewNormalStereo (enc);\r\n}\r\n\r\n\r\n\r\nvec4 depthNormalsFragment(vec4 depthNormal)\r\n{\r\n return EncodeDepthNormal(depthNormal.w,depthNormal.xyz);\r\n}\r\n\r\n\r\n// Z buffer to linear 0..1 depth\r\nfloat Linear01Depth(float z,vec4 zbufferParams)\r\n{\r\n return 1.0 / (zbufferParams.x * z + zbufferParams.y);\r\n}\r\n// Z buffer to linear depth\r\nfloat LinearEyeDepth(float z,vec4 zbufferParams)\r\n{\r\n return 1.0 / (zbufferParams.z * z + zbufferParams.w);\r\n}\r\n";class La{constructor(){}static __init__(){xe.SHADERDEFINE_LEGACYSINGALLIGHTING=xe.getDefineByName("LEGACYSINGLELIGHTING"),xe.SHADERDEFINE_GRAPHICS_API_GLES2=xe.getDefineByName("GRAPHICS_API_GLES2"),xe.SHADERDEFINE_GRAPHICS_API_GLES3=xe.getDefineByName("GRAPHICS_API_GLES3"),xe.addInclude("Lighting.glsl",Hi),xe.addInclude("ShadowSampleTent.glsl",ki),xe.addInclude("GlobalIllumination.glsl",zi),xe.addInclude("Shadow.glsl",Ta),xe.addInclude("ShadowCasterVS.glsl",Ea),xe.addInclude("ShadowCasterFS.glsl",pa),xe.addInclude("Colors.glsl",ca),xe.addInclude("Sampling.glsl",ma),xe.addInclude("StdLib.glsl",fa),xe.addInclude("PBRVSInput.glsl",ta),xe.addInclude("PBRFSInput.glsl",ra),xe.addInclude("LayaPBRBRDF.glsl",$i),xe.addInclude("PBRCore.glsl",ea),xe.addInclude("PBRVertex.glsl",ia),xe.addInclude("LayaUtile.glsl",Wi),xe.addInclude("DepthNormalUtil.glsl",ya);var e={a_Position:ze.MESH_POSITION0,a_Color:ze.MESH_COLOR0,a_Normal:ze.MESH_NORMAL0,a_Texcoord0:ze.MESH_TEXTURECOORDINATE0,a_Texcoord1:ze.MESH_TEXTURECOORDINATE1,a_BoneWeights:ze.MESH_BLENDWEIGHT0,a_BoneIndices:ze.MESH_BLENDINDICES0,a_Tangent0:ze.MESH_TANGENT0,a_MvpMatrix:ze.MESH_MVPMATRIX_ROW0,a_WorldMat:ze.MESH_WORLDMATRIX_ROW0},t={u_Bones:xe.PERIOD_CUSTOM,u_DiffuseTexture:xe.PERIOD_MATERIAL,u_SpecularTexture:xe.PERIOD_MATERIAL,u_NormalTexture:xe.PERIOD_MATERIAL,u_AlphaTestValue:xe.PERIOD_MATERIAL,u_DiffuseColor:xe.PERIOD_MATERIAL,u_MaterialSpecular:xe.PERIOD_MATERIAL,u_Shininess:xe.PERIOD_MATERIAL,u_TilingOffset:xe.PERIOD_MATERIAL,u_WorldMat:xe.PERIOD_SPRITE,u_MvpMatrix:xe.PERIOD_SPRITE,u_LightmapScaleOffset:xe.PERIOD_SPRITE,u_LightMap:xe.PERIOD_SPRITE,u_LightMapDirection:xe.PERIOD_SPRITE,u_SimpleAnimatorTexture:xe.PERIOD_SPRITE,u_SimpleAnimatorParams:xe.PERIOD_SPRITE,u_SimpleAnimatorTextureSize:xe.PERIOD_SPRITE,u_CameraPos:xe.PERIOD_CAMERA,u_Viewport:xe.PERIOD_CAMERA,u_ProjectionParams:xe.PERIOD_CAMERA,u_View:xe.PERIOD_CAMERA,u_ViewProjection:xe.PERIOD_CAMERA,u_ReflectTexture:xe.PERIOD_SCENE,u_FogStart:xe.PERIOD_SCENE,u_FogRange:xe.PERIOD_SCENE,u_FogColor:xe.PERIOD_SCENE,u_DirationLightCount:xe.PERIOD_SCENE,u_LightBuffer:xe.PERIOD_SCENE,u_LightClusterBuffer:xe.PERIOD_SCENE,u_AmbientColor:xe.PERIOD_SCENE,u_ShadowBias:xe.PERIOD_SCENE,u_ShadowLightDirection:xe.PERIOD_SCENE,u_ShadowMap:xe.PERIOD_SCENE,u_ShadowParams:xe.PERIOD_SCENE,u_ShadowSplitSpheres:xe.PERIOD_SCENE,u_ShadowMatrices:xe.PERIOD_SCENE,u_ShadowMapSize:xe.PERIOD_SCENE,u_SpotShadowMap:xe.PERIOD_SCENE,u_SpotViewProjectMatrix:xe.PERIOD_SCENE,u_ShadowLightPosition:xe.PERIOD_SCENE,u_AmbientSHAr:xe.PERIOD_SCENE,u_AmbientSHAg:xe.PERIOD_SCENE,u_AmbientSHAb:xe.PERIOD_SCENE,u_AmbientSHBr:xe.PERIOD_SCENE,u_AmbientSHBg:xe.PERIOD_SCENE,u_AmbientSHBb:xe.PERIOD_SCENE,u_AmbientSHC:xe.PERIOD_SCENE,"u_DirectionLight.color":xe.PERIOD_SCENE,"u_DirectionLight.direction":xe.PERIOD_SCENE,"u_PointLight.position":xe.PERIOD_SCENE,"u_PointLight.range":xe.PERIOD_SCENE,"u_PointLight.color":xe.PERIOD_SCENE,"u_SpotLight.position":xe.PERIOD_SCENE,"u_SpotLight.direction":xe.PERIOD_SCENE,"u_SpotLight.range":xe.PERIOD_SCENE,"u_SpotLight.spot":xe.PERIOD_SCENE,"u_SpotLight.color":xe.PERIOD_SCENE},r={s_Cull:xe.RENDER_STATE_CULL,s_Blend:xe.RENDER_STATE_BLEND,s_BlendSrc:xe.RENDER_STATE_BLEND_SRC,s_BlendDst:xe.RENDER_STATE_BLEND_DST,s_DepthTest:xe.RENDER_STATE_DEPTH_TEST,s_DepthWrite:xe.RENDER_STATE_DEPTH_WRITE},i=xe.add("BLINNPHONG",null,null,!0),a=new pr(e,t);i.addSubShader(a),a.addShaderPass(Zi,ji,r,"Forward");a.addShaderPass(Qi,qi,r,"ShadowCaster");a.addShaderPass(vt,xt,r,"DepthNormal"),e={a_Position:ze.MESH_POSITION0,a_Color:ze.MESH_COLOR0},t={u_MvpMatrix:xe.PERIOD_SPRITE,u_Color:xe.PERIOD_MATERIAL},r={s_Cull:xe.RENDER_STATE_CULL,s_Blend:xe.RENDER_STATE_BLEND,s_BlendSrc:xe.RENDER_STATE_BLEND_SRC,s_BlendDst:xe.RENDER_STATE_BLEND_DST,s_DepthTest:xe.RENDER_STATE_DEPTH_TEST,s_DepthWrite:xe.RENDER_STATE_DEPTH_WRITE},i=xe.add("LineShader"),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Yi,Xi,r),e={a_Position:ze.MESH_POSITION0,a_Color:ze.MESH_COLOR0,a_Texcoord0:ze.MESH_TEXTURECOORDINATE0,a_BoneWeights:ze.MESH_BLENDWEIGHT0,a_BoneIndices:ze.MESH_BLENDINDICES0,a_MvpMatrix:ze.MESH_MVPMATRIX_ROW0},t={u_Bones:xe.PERIOD_CUSTOM,u_AlbedoTexture:xe.PERIOD_MATERIAL,u_AlbedoColor:xe.PERIOD_MATERIAL,u_TilingOffset:xe.PERIOD_MATERIAL,u_AlphaTestValue:xe.PERIOD_MATERIAL,u_MvpMatrix:xe.PERIOD_SPRITE,u_SimpleAnimatorTexture:xe.PERIOD_SPRITE,u_SimpleAnimatorParams:xe.PERIOD_SPRITE,u_SimpleAnimatorTextureSize:xe.PERIOD_SPRITE,u_FogStart:xe.PERIOD_SCENE,u_FogRange:xe.PERIOD_SCENE,u_FogColor:xe.PERIOD_SCENE},r={s_Cull:xe.RENDER_STATE_CULL,s_Blend:xe.RENDER_STATE_BLEND,s_BlendSrc:xe.RENDER_STATE_BLEND_SRC,s_BlendDst:xe.RENDER_STATE_BLEND_DST,s_DepthTest:xe.RENDER_STATE_DEPTH_TEST,s_DepthWrite:xe.RENDER_STATE_DEPTH_WRITE},i=xe.add("Unlit",null,null,!0),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Da,Ia,r),e={a_Position:ze.MESH_POSITION0,a_Texcoord0:ze.MESH_TEXTURECOORDINATE0,a_BoneWeights:ze.MESH_BLENDWEIGHT0,a_BoneIndices:ze.MESH_BLENDINDICES0,a_MvpMatrix:ze.MESH_MVPMATRIX_ROW0},t={u_Bones:xe.PERIOD_CUSTOM,u_AlbedoTexture:xe.PERIOD_MATERIAL,u_AlbedoColor:xe.PERIOD_MATERIAL,u_TilingOffset:xe.PERIOD_MATERIAL,u_AlphaTestValue:xe.PERIOD_MATERIAL,u_MvpMatrix:xe.PERIOD_SPRITE,u_SimpleAnimatorTexture:xe.PERIOD_SPRITE,u_SimpleAnimatorParams:xe.PERIOD_SPRITE,u_SimpleAnimatorTextureSize:xe.PERIOD_SPRITE,u_FogStart:xe.PERIOD_SCENE,u_FogRange:xe.PERIOD_SCENE,u_FogColor:xe.PERIOD_SCENE},r={s_Cull:xe.RENDER_STATE_CULL,s_Blend:xe.RENDER_STATE_BLEND,s_BlendSrc:xe.RENDER_STATE_BLEND_SRC,s_BlendDst:xe.RENDER_STATE_BLEND_DST,s_DepthTest:xe.RENDER_STATE_DEPTH_TEST,s_DepthWrite:xe.RENDER_STATE_DEPTH_WRITE},i=xe.add("Effect",null,null,!0),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Fi,Bi,r),e={a_CornerTextureCoordinate:hi.PARTICLE_CORNERTEXTURECOORDINATE0,a_MeshPosition:hi.PARTICLE_POSITION0,a_MeshColor:hi.PARTICLE_COLOR0,a_MeshTextureCoordinate:hi.PARTICLE_TEXTURECOORDINATE0,a_ShapePositionStartLifeTime:hi.PARTICLE_SHAPEPOSITIONSTARTLIFETIME,a_DirectionTime:hi.PARTICLE_DIRECTIONTIME,a_StartColor:hi.PARTICLE_STARTCOLOR0,a_EndColor:hi.PARTICLE_ENDCOLOR0,a_StartSize:hi.PARTICLE_STARTSIZE,a_StartRotation0:hi.PARTICLE_STARTROTATION,a_StartSpeed:hi.PARTICLE_STARTSPEED,a_Random0:hi.PARTICLE_RANDOM0,a_Random1:hi.PARTICLE_RANDOM1,a_SimulationWorldPostion:hi.PARTICLE_SIMULATIONWORLDPOSTION,a_SimulationWorldRotation:hi.PARTICLE_SIMULATIONWORLDROTATION},t={u_Tintcolor:xe.PERIOD_MATERIAL,u_TilingOffset:xe.PERIOD_MATERIAL,u_texture:xe.PERIOD_MATERIAL,u_WorldPosition:xe.PERIOD_SPRITE,u_WorldRotation:xe.PERIOD_SPRITE,u_PositionScale:xe.PERIOD_SPRITE,u_SizeScale:xe.PERIOD_SPRITE,u_ScalingMode:xe.PERIOD_SPRITE,u_Gravity:xe.PERIOD_SPRITE,u_ThreeDStartRotation:xe.PERIOD_SPRITE,u_StretchedBillboardLengthScale:xe.PERIOD_SPRITE,u_StretchedBillboardSpeedScale:xe.PERIOD_SPRITE,u_SimulationSpace:xe.PERIOD_SPRITE,u_CurrentTime:xe.PERIOD_SPRITE,u_ColorOverLifeGradientAlphas:xe.PERIOD_SPRITE,u_ColorOverLifeGradientColors:xe.PERIOD_SPRITE,u_MaxColorOverLifeGradientAlphas:xe.PERIOD_SPRITE,u_MaxColorOverLifeGradientColors:xe.PERIOD_SPRITE,u_VOLVelocityConst:xe.PERIOD_SPRITE,u_VOLVelocityGradientX:xe.PERIOD_SPRITE,u_VOLVelocityGradientY:xe.PERIOD_SPRITE,u_VOLVelocityGradientZ:xe.PERIOD_SPRITE,u_VOLVelocityConstMax:xe.PERIOD_SPRITE,u_VOLVelocityGradientMaxX:xe.PERIOD_SPRITE,u_VOLVelocityGradientMaxY:xe.PERIOD_SPRITE,u_VOLVelocityGradientMaxZ:xe.PERIOD_SPRITE,u_VOLSpaceType:xe.PERIOD_SPRITE,u_SOLSizeGradient:xe.PERIOD_SPRITE,u_SOLSizeGradientX:xe.PERIOD_SPRITE,u_SOLSizeGradientY:xe.PERIOD_SPRITE,u_SOLSizeGradientZ:xe.PERIOD_SPRITE,u_SOLSizeGradientMax:xe.PERIOD_SPRITE,u_SOLSizeGradientMaxX:xe.PERIOD_SPRITE,u_SOLSizeGradientMaxY:xe.PERIOD_SPRITE,u_SOLSizeGradientMaxZ:xe.PERIOD_SPRITE,u_ROLAngularVelocityConst:xe.PERIOD_SPRITE,u_ROLAngularVelocityConstSeprarate:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradient:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientX:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientY:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientZ:xe.PERIOD_SPRITE,u_ROLAngularVelocityConstMax:xe.PERIOD_SPRITE,u_ROLAngularVelocityConstMaxSeprarate:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientMax:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxX:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxY:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxZ:xe.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxW:xe.PERIOD_SPRITE,u_TSACycles:xe.PERIOD_SPRITE,u_TSASubUVLength:xe.PERIOD_SPRITE,u_TSAGradientUVs:xe.PERIOD_SPRITE,u_TSAMaxGradientUVs:xe.PERIOD_SPRITE,u_CameraPos:xe.PERIOD_CAMERA,u_CameraDirection:xe.PERIOD_CAMERA,u_CameraUp:xe.PERIOD_CAMERA,u_View:xe.PERIOD_CAMERA,u_Projection:xe.PERIOD_CAMERA,u_FogStart:xe.PERIOD_SCENE,u_FogRange:xe.PERIOD_SCENE,u_FogColor:xe.PERIOD_SCENE},r={s_Cull:xe.RENDER_STATE_CULL,s_Blend:xe.RENDER_STATE_BLEND,s_BlendSrc:xe.RENDER_STATE_BLEND_SRC,s_BlendDst:xe.RENDER_STATE_BLEND_DST,s_DepthTest:xe.RENDER_STATE_DEPTH_TEST,s_DepthWrite:xe.RENDER_STATE_DEPTH_WRITE},i=xe.add("PARTICLESHURIKEN"),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Ji,Ki,r),e={a_Position:ze.MESH_POSITION0},t={u_TintColor:xe.PERIOD_MATERIAL,u_Exposure:xe.PERIOD_MATERIAL,u_Rotation:xe.PERIOD_MATERIAL,u_CubeTexture:xe.PERIOD_MATERIAL,u_ViewProjection:xe.PERIOD_CAMERA},i=xe.add("SkyBox"),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Sa,ga),e={a_Position:ze.MESH_POSITION0},t={u_SunSize:xe.PERIOD_MATERIAL,u_SunSizeConvergence:xe.PERIOD_MATERIAL,u_AtmosphereThickness:xe.PERIOD_MATERIAL,u_SkyTint:xe.PERIOD_MATERIAL,u_GroundTint:xe.PERIOD_MATERIAL,u_Exposure:xe.PERIOD_MATERIAL,u_ViewProjection:xe.PERIOD_CAMERA,"u_SunLight.direction":xe.PERIOD_SCENE,"u_SunLight.color":xe.PERIOD_SCENE},i=xe.add("SkyBoxProcedural"),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(va,Ra),e={a_Position:ze.MESH_POSITION0,a_Normal:ze.MESH_NORMAL0,a_Texcoord0:ze.MESH_TEXTURECOORDINATE0},t={u_MvpMatrix:xe.PERIOD_SPRITE,u_WorldMat:xe.PERIOD_SPRITE,u_CameraPos:xe.PERIOD_CAMERA,u_Viewport:xe.PERIOD_CAMERA,u_ProjectionParams:xe.PERIOD_CAMERA,u_View:xe.PERIOD_CAMERA,u_LightmapScaleOffset:xe.PERIOD_SPRITE,u_LightMap:xe.PERIOD_SPRITE,u_SplatAlphaTexture:xe.PERIOD_MATERIAL,u_DiffuseTexture1:xe.PERIOD_MATERIAL,u_DiffuseTexture2:xe.PERIOD_MATERIAL,u_DiffuseTexture3:xe.PERIOD_MATERIAL,u_DiffuseTexture4:xe.PERIOD_MATERIAL,u_DiffuseTexture5:xe.PERIOD_MATERIAL,u_DiffuseScaleOffset1:xe.PERIOD_MATERIAL,u_DiffuseScaleOffset2:xe.PERIOD_MATERIAL,u_DiffuseScaleOffset3:xe.PERIOD_MATERIAL,u_DiffuseScaleOffset4:xe.PERIOD_MATERIAL,u_DiffuseScaleOffset5:xe.PERIOD_MATERIAL,u_FogStart:xe.PERIOD_SCENE,u_FogRange:xe.PERIOD_SCENE,u_FogColor:xe.PERIOD_SCENE,u_DirationLightCount:xe.PERIOD_SCENE,u_LightBuffer:xe.PERIOD_SCENE,u_LightClusterBuffer:xe.PERIOD_SCENE,u_AmbientColor:xe.PERIOD_SCENE,u_ShadowMap:xe.PERIOD_SCENE,u_shadowMap2:xe.PERIOD_SCENE,u_shadowMap3:xe.PERIOD_SCENE,u_ShadowSplitSpheres:xe.PERIOD_SCENE,u_ShadowMatrices:xe.PERIOD_SCENE,u_ShadowMapSize:xe.PERIOD_SCENE,"u_DirectionLight.color":xe.PERIOD_SCENE,"u_DirectionLight.direction":xe.PERIOD_SCENE,"u_PointLight.position":xe.PERIOD_SCENE,"u_PointLight.range":xe.PERIOD_SCENE,"u_PointLight.color":xe.PERIOD_SCENE,"u_SpotLight.position":xe.PERIOD_SCENE,"u_SpotLight.direction":xe.PERIOD_SCENE,"u_SpotLight.range":xe.PERIOD_SCENE,"u_SpotLight.spot":xe.PERIOD_SCENE,"u_SpotLight.color":xe.PERIOD_SCENE},r={s_Cull:xe.RENDER_STATE_CULL,s_Blend:xe.RENDER_STATE_BLEND,s_BlendSrc:xe.RENDER_STATE_BLEND_SRC,s_BlendDst:xe.RENDER_STATE_BLEND_DST,s_DepthTest:xe.RENDER_STATE_DEPTH_TEST,s_DepthWrite:xe.RENDER_STATE_DEPTH_WRITE},i=xe.add("ExtendTerrain"),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Gi,Ui,r),e={a_Position:xi.TRAIL_POSITION0,a_OffsetVector:xi.TRAIL_OFFSETVECTOR,a_Texcoord0X:xi.TRAIL_TEXTURECOORDINATE0X,a_Texcoord0Y:xi.TRAIL_TEXTURECOORDINATE0Y,a_BirthTime:xi.TRAIL_TIME0,a_Color:xi.TRAIL_COLOR},t={u_MvpMatrix:xe.PERIOD_SPRITE,u_View:xe.PERIOD_CAMERA,u_Projection:xe.PERIOD_CAMERA,u_TilingOffset:xe.PERIOD_MATERIAL,u_MainTexture:xe.PERIOD_MATERIAL,u_MainColor:xe.PERIOD_MATERIAL,u_CurTime:xe.PERIOD_SPRITE,u_LifeTime:xe.PERIOD_SPRITE,u_WidthCurve:xe.PERIOD_SPRITE,u_WidthCurveKeyLength:xe.PERIOD_SPRITE,u_GradientColorkey:xe.PERIOD_SPRITE,u_GradientAlphakey:xe.PERIOD_SPRITE},r={s_Cull:xe.RENDER_STATE_CULL,s_Blend:xe.RENDER_STATE_BLEND,s_BlendSrc:xe.RENDER_STATE_BLEND_SRC,s_BlendDst:xe.RENDER_STATE_BLEND_DST,s_DepthTest:xe.RENDER_STATE_DEPTH_TEST,s_DepthWrite:xe.RENDER_STATE_DEPTH_WRITE},i=xe.add("Trail"),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Aa,xa,r),e={a_Position:ze.MESH_POSITION0,a_Normal:ze.MESH_NORMAL0,a_Tangent0:ze.MESH_TANGENT0},t={u_MvpMatrix:xe.PERIOD_SPRITE,u_WorldMat:xe.PERIOD_SPRITE,u_CameraPos:xe.PERIOD_CAMERA,u_Time:xe.PERIOD_SCENE,u_MainTexture:xe.PERIOD_MATERIAL,u_NormalTexture:xe.PERIOD_MATERIAL,u_HorizonColor:xe.PERIOD_MATERIAL,u_WaveScale:xe.PERIOD_MATERIAL,u_WaveSpeed:xe.PERIOD_MATERIAL},i=xe.add("WaterPrimary"),a=new pr(e,t),i.addSubShader(a),a.addShaderPass(Ca,Ma),e={a_PositionTexcoord:ze.MESH_POSITION0},t={u_MainTex:xe.PERIOD_MATERIAL,u_OffsetScale:xe.PERIOD_MATERIAL},i=xe.add("BlitScreen"),a=new pr(e,t),i.addSubShader(a);var n=a.addShaderPass(Vi,wi).renderState;n.depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE,e={a_PositionTexcoord:ze.MESH_POSITION0},t={u_MainTex:xe.PERIOD_MATERIAL,u_BloomTex:xe.PERIOD_MATERIAL,u_AutoExposureTex:xe.PERIOD_MATERIAL,u_MainTex_TexelSize:xe.PERIOD_MATERIAL,u_SampleScale:xe.PERIOD_MATERIAL,u_Threshold:xe.PERIOD_MATERIAL,u_Params:xe.PERIOD_MATERIAL},i=xe.add("PostProcessBloom"),a=new pr(e,t),i.addSubShader(a),(n=a.addShaderPass(aa,oa).renderState).depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE,a=new pr(e,t),i.addSubShader(a),(n=a.addShaderPass(aa,la).renderState).depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE,a=new pr(e,t),i.addSubShader(a),(n=a.addShaderPass(aa,na).renderState).depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE,a=new pr(e,t),i.addSubShader(a),(n=a.addShaderPass(aa,sa).renderState).depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE,a=new pr(e,t),i.addSubShader(a),(n=a.addShaderPass(aa,ha).renderState).depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE,a=new pr(e,t),i.addSubShader(a),(n=a.addShaderPass(aa,_a).renderState).depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE,e={a_PositionTexcoord:ze.MESH_POSITION0},t={u_MainTex:xe.PERIOD_MATERIAL,u_BloomTex:xe.PERIOD_MATERIAL,u_AutoExposureTex:xe.PERIOD_MATERIAL,u_Bloom_DirtTileOffset:xe.PERIOD_MATERIAL,u_Bloom_DirtTex:xe.PERIOD_MATERIAL,u_BloomTex_TexelSize:xe.PERIOD_MATERIAL,u_Bloom_Settings:xe.PERIOD_MATERIAL,u_Bloom_Color:xe.PERIOD_MATERIAL},i=xe.add("PostProcessComposite"),a=new pr(e,t),i.addSubShader(a),(n=a.addShaderPass(ua,da).renderState).depthTest=lt.DEPTHTEST_ALWAYS,n.depthWrite=!1,n.cull=lt.CULL_NONE,n.blend=lt.BLEND_DISABLE}}class Oa extends je{constructor(){super(),this._direction=new n,this._shadowCascadesMode=e.ShadowCascadesMode.NoCascades,this._shadowTwoCascadeSplits=1/3,this._shadowFourCascadeSplits=new n(1/15,.2,7/15),this._lightType=e.LightType.Directional}get shadowCascadesMode(){return this._shadowCascadesMode}set shadowCascadesMode(e){this._shadowCascadesMode=e}get shadowTwoCascadeSplits(){return this._shadowTwoCascadeSplits}set shadowTwoCascadeSplits(e){this._shadowTwoCascadeSplits=e}get shadowFourCascadeSplits(){return this._shadowFourCascadeSplits}set shadowFourCascadeSplits(e){if(e.x>e.y||e.y>e.z||e.z>1)throw"DiretionLight:Invalid value.";e.cloneTo(this._shadowFourCascadeSplits)}_addToLightQueue(){this._scene._directionLights.add(this)}_removeFromLightQueue(){this._scene._directionLights.remove(this)}_create(){return new Oa}}class Na extends je{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}_cloneTo(t,r,i){super._cloneTo(t,r,i);var a=t;a.range=this.range,a._lightType=e.LightType.Point}_create(){return new Na}}class Pa extends je{constructor(){super(),this._spotAngle=30,this._range=10,this._direction=new n,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}_cloneTo(e,t,r){super._cloneTo(e,t,r);var i=e;i.range=this.range,i.spotAngle=this.spotAngle}_create(){return new Pa}}class ba extends gi{constructor(e){super(e),this._simpleAnimatorParams=new a,this._simpleAnimatorOffset=new i,this._shaderValues.addDefine(pi.SHADERDEFINE_SIMPLEBONE),this._shaderValues.addDefine(pi.SHADERDEFINE_BONE)}get simpleAnimatorTexture(){return this._simpleAnimatorTexture}set simpleAnimatorTexture(e){this._simpleAnimatorTexture=e,this._simpleAnimatorTextureSize=e.width,this._shaderValues.setTexture(ba.SIMPLE_SIMPLEANIMATORTEXTURE,e),e._addReference(),this._shaderValues.setNumber(ba.SIMPLE_SIMPLEANIMATORTEXTURESIZE,this._simpleAnimatorTextureSize)}get simpleAnimatorOffset(){return this._simpleAnimatorOffset}set simpleAnimatorOffset(e){e.cloneTo(this._simpleAnimatorOffset)}_computeAnimatorParamsData(){this._cacheMesh&&(this._simpleAnimatorParams.x=this._simpleAnimatorOffset.x,this._simpleAnimatorParams.y=Math.round(this._simpleAnimatorOffset.y)*this._bonesNums*4)}_createRenderElement(){return new Qt}_setCacheAnimator(e){this._cacheAnimator=e,this._shaderValues.addDefine(pi.SHADERDEFINE_SIMPLEBONE)}_onMeshChange(e){super._onMeshChange(e),this._cacheMesh=e}_renderUpdate(e,t){var r=e.renderElement;switch(r.renderType){case Ke.RENDERTYPE_NORMAL:if(this._cacheAnimator){var i=this._cacheAnimator.owner.transform.worldMatrix;this._shaderValues.setMatrix4x4(Ce.WORLDMATRIX,i)}else this._shaderValues.setMatrix4x4(Ce.WORLDMATRIX,t.worldMatrix);this._computeAnimatorParamsData(),this._shaderValues.setVector(ba.SIMPLE_SIMPLEANIMATORPARAMS,this._simpleAnimatorParams);break;case Ke.RENDERTYPE_INSTANCEBATCH:var a=qt.instance.instanceWorldMatrixData,n=r.instanceBatchElementList,s=n.elements,o=n.length;if(this._cacheAnimator)for(var l=0;l65535?e.IndexFormat.UInt32:e.IndexFormat.UInt16,g._vertexBuffer=D,g._vertexCount+=u,a+=4*h.length}var M,C=l+n.getUint32(),y=n.getUint32();M=g.indexFormat==e.IndexFormat.UInt32?new Uint32Array(s.slice(C,C+y)):new Uint16Array(s.slice(C,C+y));var L=new Ge(g.indexFormat,M.length,i.STATIC_DRAW,!0);if(L.setData(M),g._indexBuffer=L,g._setBuffer(g._vertexBuffer,L),a+=2*L.indexCount,g._setCPUMemory(a),g._setGPUMemory(a),"LAYAMODEL:0501"==Fa._version||"LAYAMODEL:COMPRESSION_0501"==Fa._version){var O=g.bounds,N=O.getMin(),P=O.getMax();N.setValue(n.getFloat32(),n.getFloat32(),n.getFloat32()),P.setValue(n.getFloat32(),n.getFloat32(),n.getFloat32()),O.setMin(N),O.setMax(P),g.bounds=O}var b=g._boneNames=[],w=n.getUint16();for(b.length=w,r=0;rthis._breakForce,t=-1!=this._breakTorque&&n.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=Y._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&&(this.connectedBody.constaintRigidbodyB=null),this.destroy()}}ka.CONSTRAINT_POINT2POINT_CONSTRAINT_TYPE=3,ka.CONSTRAINT_HINGE_CONSTRAINT_TYPE=4,ka.CONSTRAINT_CONETWIST_CONSTRAINT_TYPE=5,ka.CONSTRAINT_D6_CONSTRAINT_TYPE=6,ka.CONSTRAINT_SLIDER_CONSTRAINT_TYPE=7,ka.CONSTRAINT_CONTACT_CONSTRAINT_TYPE=8,ka.CONSTRAINT_D6_SPRING_CONSTRAINT_TYPE=9,ka.CONSTRAINT_GEAR_CONSTRAINT_TYPE=10,ka.CONSTRAINT_FIXED_CONSTRAINT_TYPE=11,ka.CONSTRAINT_MAX_CONSTRAINT_TYPE=12,ka.CONSTRAINT_CONSTRAINT_ERP=1,ka.CONSTRAINT_CONSTRAINT_STOP_ERP=2,ka.CONSTRAINT_CONSTRAINT_CFM=3,ka.CONSTRAINT_CONSTRAINT_STOP_CFM=4,ka.tempForceV3=new n;class Wa extends ka{constructor(){super(ka.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=Y._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(),Y._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0)}}_onAdded(){super._onAdded()}_onEnable(){this._btConstraint&&(super._onEnable(),this._btConstraint&&Y._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0))}_onDisable(){super._onDisable(),this.connectedBody||this._removeFromSimulation(),this._btConstraint&&Y._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(X),i=t[e.connectRigidbodyID].getComponent(X);this.ownBody=r,this.connectedBody=i}_cloneTo(e){}}class Xa extends ka{constructor(){super(ka.CONSTRAINT_D6_SPRING_CONSTRAINT_TYPE),this._axis=new n,this._secondaryAxis=new n,this._minLinearLimit=new n,this._maxLinearLimit=new n,this._minAngularLimit=new n,this._maxAngularLimit=new n,this._linearLimitSpring=new n,this._angularLimitSpring=new n,this._linearBounce=new n,this._angularBounce=new n,this._linearDamp=new n,this._angularDamp=new n,this._xMotion=0,this._yMotion=0,this._zMotion=0,this._angularXMotion=0,this._angularYMotion=0,this._angularZMotion=0;var e=Y._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(Xa.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(Xa.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(Xa.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(Xa.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(Xa.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(Xa.MOTION_ANGULAR_INDEX_Z,e,this._minAngularLimit.z,this._maxAngularLimit.z))}get angularZMotion(){return this._angularZMotion}set linearLimitSpring(e){n.equals(this._linearLimitSpring,e)||(e.cloneTo(this._linearLimitSpring),this.setSpring(Xa.MOTION_LINEAR_INDEX_X,e.x),this.setSpring(Xa.MOTION_LINEAR_INDEX_Y,e.y),this.setSpring(Xa.MOTION_LINEAR_INDEX_Z,e.z))}get linearLimitSpring(){return this._linearLimitSpring}set angularLimitSpring(e){n.equals(this._angularLimitSpring,e)||(e.cloneTo(this._angularLimitSpring),this.setSpring(Xa.MOTION_ANGULAR_INDEX_X,e.x),this.setSpring(Xa.MOTION_ANGULAR_INDEX_Y,e.y),this.setSpring(Xa.MOTION_ANGULAR_INDEX_Z,e.z))}get angularLimitSpring(){return this._angularLimitSpring}set linearBounce(e){n.equals(this._linearBounce,e)||(e.cloneTo(this._linearBounce),this.setBounce(Xa.MOTION_LINEAR_INDEX_X,e.x),this.setBounce(Xa.MOTION_LINEAR_INDEX_Y,e.y),this.setBounce(Xa.MOTION_LINEAR_INDEX_Z,e.z))}get linearBounce(){return this._linearBounce}set angularBounce(e){n.equals(this._angularBounce,e)||(e.cloneTo(this._angularBounce),this.setBounce(Xa.MOTION_ANGULAR_INDEX_X,e.x),this.setBounce(Xa.MOTION_ANGULAR_INDEX_Y,e.y),this.setBounce(Xa.MOTION_ANGULAR_INDEX_Z,e.z))}get angularBounce(){return this._angularBounce}set linearDamp(e){n.equals(this._linearDamp,e)||(e.cloneTo(this._linearDamp),this.setDamping(Xa.MOTION_LINEAR_INDEX_X,e.x),this.setDamping(Xa.MOTION_LINEAR_INDEX_Y,e.y),this.setDamping(Xa.MOTION_LINEAR_INDEX_Z,e.z))}get linearDamp(){return this._linearDamp}set angularDamp(e){n.equals(this._angularDamp,e)||(e.cloneTo(this._angularDamp),this.setDamping(Xa.MOTION_ANGULAR_INDEX_X,e.x),this.setDamping(Xa.MOTION_ANGULAR_INDEX_Y,e.y),this.setDamping(Xa.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=Y._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 a=Y._bullet;switch(t){case Xa.CONFIG_MOTION_TYPE_LOCKED:a.btGeneric6DofSpring2Constraint_setLimit(this._btConstraint,e,0,0);break;case Xa.CONFIG_MOTION_TYPE_LIMITED:r0;i.btGeneric6DofSpring2Constraint_enableSpring(this._btConstraint,e,a),a&&i.btGeneric6DofSpring2Constraint_setStiffness(this._btConstraint,e,t,r)}}setBounce(e,t){this._btConstraint&&(t=t<=0?0:t,Y._bullet.btGeneric6DofSpring2Constraint_setBounce(this._btConstraint,e,t))}setDamping(e,t,r=!0){this._btConstraint&&(t=t<=0?0:t,Y._bullet.btGeneric6DofSpring2Constraint_setDamping(this._btConstraint,e,t,r))}setEquilibriumPoint(e,t){Y._bullet.btGeneric6DofSpring2Constraint_setEquilibriumPoint(this._btConstraint,e,t)}enableMotor(e,t){Y._bullet.btGeneric6DofSpring2Constraint_enableMotor(this._btConstraint,e,t)}setServo(e,t){Y._bullet.btGeneric6DofSpring2Constraint_setServo(this._btConstraint,e,t)}setTargetVelocity(e,t){Y._bullet.btGeneric6DofSpring2Constraint_setTargetVelocity(this._btConstraint,e,t)}setTargetPosition(e,t){Y._bullet.btGeneric6DofSpring2Constraint_setServoTarget(this._btConstraint,e,t)}setMaxMotorForce(e,t){Y._bullet.btGeneric6DofSpring2Constraint_setMaxMotorForce(this._btConstraint,e,t)}setParam(e,t,r){Y._bullet.btTypedConstraint_setParam(this._btConstraint,e,t,r)}setFrames(){super.setFrames();var e=Y._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=Y._bullet;this._btConstraint=e.btGeneric6DofSpring2Constraint_create(this.ownBody.btColliderObject,this._btframAPos,this.connectedBody.btColliderObject,this._btframBPos,Xa.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(),Y._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0)}_initAllConstraintInfo(){this.setLimit(Xa.MOTION_LINEAR_INDEX_X,this._xMotion,-this._maxLinearLimit.x,-this._minLinearLimit.x),this.setLimit(Xa.MOTION_LINEAR_INDEX_Y,this._yMotion,this._minLinearLimit.y,this._maxLinearLimit.y),this.setLimit(Xa.MOTION_LINEAR_INDEX_Z,this._zMotion,this._minLinearLimit.z,this._maxLinearLimit.z),this.setLimit(Xa.MOTION_ANGULAR_INDEX_X,this._angularXMotion,-this._maxAngularLimit.x,-this._minAngularLimit.x),this.setLimit(Xa.MOTION_ANGULAR_INDEX_Y,this._angularYMotion,this._minAngularLimit.y,this._maxAngularLimit.y),this.setLimit(Xa.MOTION_ANGULAR_INDEX_Z,this._angularZMotion,this._minAngularLimit.z,this._maxAngularLimit.z),this.setSpring(Xa.MOTION_LINEAR_INDEX_X,this._linearLimitSpring.x),this.setSpring(Xa.MOTION_LINEAR_INDEX_Y,this._linearLimitSpring.y),this.setSpring(Xa.MOTION_LINEAR_INDEX_Z,this._linearLimitSpring.z),this.setSpring(Xa.MOTION_ANGULAR_INDEX_X,this._angularLimitSpring.x),this.setSpring(Xa.MOTION_ANGULAR_INDEX_Y,this._angularLimitSpring.y),this.setSpring(Xa.MOTION_ANGULAR_INDEX_Z,this._angularLimitSpring.z),this.setBounce(Xa.MOTION_LINEAR_INDEX_X,this._linearBounce.x),this.setBounce(Xa.MOTION_LINEAR_INDEX_Y,this._linearBounce.y),this.setBounce(Xa.MOTION_LINEAR_INDEX_Z,this._linearBounce.z),this.setBounce(Xa.MOTION_ANGULAR_INDEX_X,this._angularBounce.x),this.setBounce(Xa.MOTION_ANGULAR_INDEX_Y,this._angularBounce.y),this.setBounce(Xa.MOTION_ANGULAR_INDEX_Z,this._angularBounce.z),this.setDamping(Xa.MOTION_LINEAR_INDEX_X,this._linearDamp.x),this.setDamping(Xa.MOTION_LINEAR_INDEX_Y,this._linearDamp.y),this.setDamping(Xa.MOTION_LINEAR_INDEX_Z,this._linearDamp.z),this.setDamping(Xa.MOTION_ANGULAR_INDEX_X,this._angularDamp.x),this.setDamping(Xa.MOTION_ANGULAR_INDEX_Y,this._angularDamp.y),this.setDamping(Xa.MOTION_ANGULAR_INDEX_Z,this._angularDamp.z),this.setFrames(),this.setEquilibriumPoint(0,0)}_onAdded(){super._onAdded()}_onEnable(){this._btConstraint&&(super._onEnable(),this._btConstraint&&Y._bullet.btTypedConstraint_setEnabled(this._btConstraint,!0))}_onDisable(){super._onDisable(),!this.connectedBody&&this._simulation&&this._removeFromSimulation(),this._btConstraint&&Y._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 a=e.linearLimitDamper;this._linearDamp.setValue(a,a,a);var n=e.linearLimitBounciness;this._linearBounce.setValue(n,n,n);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(X),i=t[e.connectRigidbodyID].getComponent(X);this.ownBody=r,this.connectedBody=i}_onDestroy(){super._onDestroy()}_cloneTo(e){}}Xa.CONFIG_MOTION_TYPE_LOCKED=0,Xa.CONFIG_MOTION_TYPE_LIMITED=1,Xa.CONFIG_MOTION_TYPE_FREE=2,Xa.MOTION_LINEAR_INDEX_X=0,Xa.MOTION_LINEAR_INDEX_Y=1,Xa.MOTION_LINEAR_INDEX_Z=2,Xa.MOTION_ANGULAR_INDEX_X=3,Xa.MOTION_ANGULAR_INDEX_Y=4,Xa.MOTION_ANGULAR_INDEX_Z=5,Xa.RO_XYZ=0,Xa.RO_XZY=1,Xa.RO_YXZ=2,Xa.RO_YZX=3,Xa.RO_ZXY=4,Xa.RO_ZYX=5;class Ya{constructor(){}static get enablePhysics(){return Y._enablePhysics}static _cancelLoadByUrl(e){t.Laya.loader.cancelLoadByUrl(e),Ya._innerFirstLevelLoaderManager.cancelLoadByUrl(e),Ya._innerSecondLevelLoaderManager.cancelLoadByUrl(e),Ya._innerThirdLevelLoaderManager.cancelLoadByUrl(e),Ya._innerFourthLevelLoaderManager.cancelLoadByUrl(e)}static _changeWebGLSize(e,r){t.WebGL.onStageResize(e,r),_e.clientWidth=e,_e.clientHeight=r}static __init__(r,i,a){if(t.Config.isAntialias=a.isAntialias,t.Config.isAlpha=a.isAlpha,t.Config.premultipliedAlpha=a.premultipliedAlpha,t.Config.isStencil=a.isStencil,t.WebGL.enable()){t.RunDriver.changeWebGLSize=Ya._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)}),a._multiLighting=a.enableMultiLight&&t.SystemUtils.supportTextureFormat(t.TextureFormat.R32G32B32A32),g.Shader3D=xe,g.Scene3D=Tr,g.MeshRenderStaticBatchManager=$t,g.MeshRenderDynamicBatchManager=Vr,g.SubMeshDynamicBatch=wr,g.Laya3D=Ya,g.Matrix4x4=R,g.Physics3D=Y,g.ShadowLightType=e.ShadowLightType,Ya.enableNative3D(),a.isUseCannonPhysicsEngine&&Y.__cannoninit__(),Y.__bulletinit__(),ue.__init__(),ze.__init__(),ci.__init__(),di.__init__(),Vt.__init__(),xi.__init__(),Ci.__init__(),Xt.__init__(),qt.__init__(),wr.__init__(),La.__init__(),Ze.init(),dt.__init__(),Mr.__init__(),gr.__init__(),Ha.__init__(),Pi.__init__(),bi.__init__(),Ce.__init__(),jt.__init__(),Br.__init__(),Si.__init__(),wa.__init__(),Ei.__init__(),Mi.__init__(),rt.__init__(),Tr.__init__(),$t.__init__(),st.__initDefine__(),ot.__initDefine__(),_t.__initDefine__(),yr.__initDefine__(),Lr.__initDefine__(),Ri.__initDefine__(),ht.__initDefine__(),Or.__initDefine__(),li.__initDefine__(),ct.__initDefine__(),zt.__initDefine__(),Cr.__initDefine__(),Ae.__init__(),t.ClassUtils.regClass("Laya.SkyPanoramicMaterial",Ha),t.ClassUtils.regClass("Laya.EffectMaterial",ht),t.ClassUtils.regClass("Laya.UnlitMaterial",Lr),t.ClassUtils.regClass("Laya.BlinnPhongMaterial",_t),t.ClassUtils.regClass("Laya.SkyProceduralMaterial",yr),t.ClassUtils.regClass("Laya.PBRStandardMaterial",Mr),t.ClassUtils.regClass("Laya.PBRSpecularMaterial",gr),t.ClassUtils.regClass("Laya.SkyBoxMaterial",Cr),t.ClassUtils.regClass("Laya.WaterPrimaryMaterial",Or),t.ClassUtils.regClass("Laya.ExtendTerrainMaterial",ct),t.ClassUtils.regClass("Laya.ShurikenParticleMaterial",li),t.ClassUtils.regClass("Laya.TrailMaterial",Ri),t.ClassUtils.regClass("Laya.PhysicsCollider",Li),t.ClassUtils.regClass("Laya.Rigidbody3D",X),t.ClassUtils.regClass("Laya.CharacterController",k),t.ClassUtils.regClass("Laya.Animator",le),t.ClassUtils.regClass("PhysicsCollider",Li),t.ClassUtils.regClass("CharacterController",k),t.ClassUtils.regClass("Animator",le),t.ClassUtils.regClass("Rigidbody3D",X),t.ClassUtils.regClass("FixedConstraint",Wa),t.ClassUtils.regClass("ConfigurableConstraint",Xa),zt.defaultMaterial=new zt,_t.defaultMaterial=new _t,ht.defaultMaterial=new ht,Lr.defaultMaterial=new Lr,li.defaultMaterial=new li,Ri.defaultMaterial=new Ri,yr.defaultMaterial=new yr,Cr.defaultMaterial=new Cr,Or.defaultMaterial=new Or,zt.defaultMaterial.lock=!0,_t.defaultMaterial.lock=!0,ht.defaultMaterial.lock=!0,Lr.defaultMaterial.lock=!0,li.defaultMaterial.lock=!0,Ri.defaultMaterial.lock=!0,yr.defaultMaterial.lock=!0,Cr.defaultMaterial.lock=!0,Or.defaultMaterial.lock=!0,t.Texture2D.__init__(),Ft.__init__(),ke.__init__(),Bt.__init__(),pe.__init__(),ge.__init__(),Lt.__init__(),t.HalfFloatUtils.__init__();var n=t.LoaderManager.createMap;n.lh=[Ya.HIERARCHY,Va._parse],n.ls=[Ya.HIERARCHY,Va._parseScene],n.lm=[Ya.MESH,Ua._parse],n.lmat=[Ya.MATERIAL,st._parse],n.jpg=[Ya.TEXTURE2D,t.Texture2D._parse],n.jpeg=[Ya.TEXTURE2D,t.Texture2D._parse],n.bmp=[Ya.TEXTURE2D,t.Texture2D._parse],n.gif=[Ya.TEXTURE2D,t.Texture2D._parse],n.png=[Ya.TEXTURE2D,t.Texture2D._parse],n.dds=[Ya.TEXTURE2D,t.Texture2D._parse],n.ktx=[Ya.TEXTURE2D,t.Texture2D._parse],n.pvr=[Ya.TEXTURE2D,t.Texture2D._parse],n.lani=[Ya.ANIMATIONCLIP,ie._parse],n.lav=[Ya.AVATAR,nt._parse],n.ltc=[Ya.TEXTURECUBE,Ft._parse],n.ltcb=[Ya.TEXTURECUBEBIN,Ft._parseBin],n["ltcb.ls"]=[Ya.TEXTURECUBEBIN,Ft._parseBin],n["lanit.ls"]=[Ya.TEXTURE2D,t.Texture2D._SimpleAnimatorTextureParse];var s=t.Loader.parserMap;s[Ya.HIERARCHY]=Ya._loadHierarchy,s[Ya.MESH]=Ya._loadMesh,s[Ya.MATERIAL]=Ya._loadMaterial,s[Ya.TEXTURECUBE]=Ya._loadTextureCube,s[Ya.TEXTURECUBEBIN]=Ya._loadTextureCubeBin,s[Ya.TEXTURE2D]=Ya._loadTexture2D,s[Ya.ANIMATIONCLIP]=Ya._loadAnimationClip,s[Ya.AVATAR]=Ya._loadAvatar,s[Ya.SIMPLEANIMATORBIN]=Ya._loadSimpleAnimator,Ya._innerFirstLevelLoaderManager.on(t.Event.ERROR,null,Ya._eventLoadManagerError),Ya._innerSecondLevelLoaderManager.on(t.Event.ERROR,null,Ya._eventLoadManagerError),Ya._innerThirdLevelLoaderManager.on(t.Event.ERROR,null,Ya._eventLoadManagerError),Ya._innerFourthLevelLoaderManager.on(t.Event.ERROR,null,Ya._eventLoadManagerError)}else alert("Laya3D init error,must support webGL!")}static enableNative3D(){var e=me,r=It;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)}static formatRelativePath(e,t){var r;if(r=e+t,"."===t.charAt(0)){for(var i=r.split("/"),a=0,n=i.length;a0&&".."!==i[s]&&(i.splice(s,2),a-=2)}r=i.join("/")}return r}static _endLoad(e,r=null,i=null){if(i)for(var a=0,n=i.length;a0){var m=c/d,f=t.Handler.create(null,Ya._onProcessChange,[e,u,m],!1);Ya._innerFourthLevelLoaderManager._create(_,!1,t.Handler.create(null,Ya._onHierarchyInnerForthLevResouLoaded,[e,f,r,h,s,o,l,u+m*_.length,m]),f,null,null,null,1,!0)}else Ya._onHierarchyInnerForthLevResouLoaded(e,null,r,h,s,o,l,u,m)}static _onHierarchyInnerForthLevResouLoaded(e,r,i,a,n,s,o,l,_){if(r&&r.recover(),o.length>0){var h=t.Handler.create(null,Ya._onProcessChange,[e,l,_],!1);Ya._innerThirdLevelLoaderManager._create(o,!1,t.Handler.create(null,Ya._onHierarchyInnerThirdLevResouLoaded,[e,h,i,a,n,s,l+_*s.length,_]),r,null,null,null,1,!0)}else Ya._onHierarchyInnerThirdLevResouLoaded(e,null,i,a,n,s,l,_)}static _onHierarchyInnerThirdLevResouLoaded(e,r,i,a,n,s,o,l){if(r&&r.recover(),s.length>0){var _=t.Handler.create(null,Ya._onProcessChange,[e,o,l],!1);Ya._innerSecondLevelLoaderManager._create(s,!1,t.Handler.create(null,Ya._onHierarchyInnerSecondLevResouLoaded,[e,_,i,a,n,o+l*s.length,l]),r,null,null,null,1,!0)}else Ya._onHierarchyInnerSecondLevResouLoaded(e,null,i,a,n,o,l)}static _onHierarchyInnerSecondLevResouLoaded(e,r,i,a,n,s,o){if(r&&r.recover(),n.length>0){var l=t.Handler.create(null,Ya._onProcessChange,[e,s,o],!1);Ya._innerFirstLevelLoaderManager._create(n,!1,t.Handler.create(null,Ya._onHierarchyInnerFirstLevResouLoaded,[e,l,i,a]),r,null,null,null,1,!0)}else Ya._onHierarchyInnerFirstLevResouLoaded(e,null,i,a)}static _onHierarchyInnerFirstLevResouLoaded(e,t,r,i){t&&t.recover(),e._cache=e._createCache;var a="Scene3D"===r.data.type?Va._parseScene(r,e._propertyParams,e._constructParams):Va._parse(r,e._propertyParams,e._constructParams);Ya._endLoad(e,a,i)}static _loadMesh(e){e.on(t.Event.LOADED,null,Ya._onMeshLmLoaded,[e]),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _onMeshLmLoaded(e,t){e._cache=e._createCache;var r=Ua._parse(t,e._propertyParams,e._constructParams);Ya._endLoad(e,r)}static _loadMaterial(e){e.on(t.Event.LOADED,null,Ya._onMaterilLmatLoaded,[e]),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _onMaterilLmatLoaded(e,r){var i,a=e.url,n=H.getURLVerion(a),s=t.URL.getPath(a),o=[],l=[];r.customProps;switch(r.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":var _,h,c=r.props.textures;if(c)for(_=0,h=c.length;_0){var E=t.Handler.create(null,Ya._onProcessChange,[e,T,m/f],!1);Ya._innerFourthLevelLoaderManager._create(o,!1,t.Handler.create(null,Ya._onMateialTexturesLoaded,[e,E,r,l]),E,null,null,null,1,!0)}else Ya._onMateialTexturesLoaded(e,null,r,null)}static _onMateialTexturesLoaded(e,t,r,i){e._cache=e._createCache;var a=st._parse(r,e._propertyParams,e._constructParams);Ya._endLoad(e,a,i),t&&t.recover()}static _loadAvatar(e){e.on(t.Event.LOADED,null,function(t){e._cache=e._createCache;var r=nt._parse(t,e._propertyParams,e._constructParams);Ya._endLoad(e,r)}),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _loadSimpleAnimator(e){e.on(t.Event.LOADED,null,function(r){e._cache=e._createCache;var i=t.Texture2D._SimpleAnimatorTextureParse(r,e._propertyParams,e._constructParams);Ya._endLoad(e,i)}),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _loadAnimationClip(e){e.on(t.Event.LOADED,null,function(t){e._cache=e._createCache;var r=ie._parse(t);Ya._endLoad(e,r)}),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _loadTexture2D(e){var r,i=e.url,a=i.lastIndexOf(".")+1,n=i.indexOf("?"),s=-1==n?i.length:n;switch(i.substr(a,s-a)){case"jpg":case"jpeg":case"bmp":case"gif":case"png":r="nativeimage";break;case"dds":case"ktx":case"pvr":r=t.Loader.BUFFER}e.on(t.Event.LOADED,null,function(r){e._cache=e._createCache;var i=t.Texture2D._parse(r,e._propertyParams,e._constructParams);Ya._endLoad(e,i)}),e.load(e.url,r,!1,null,!0)}static _loadTextureCube(e){e.on(t.Event.LOADED,null,Ya._onTextureCubeLtcLoaded,[e]),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _loadTextureCubeBin(e){e.on(t.Event.LOADED,null,r=>{e._cache=e._createCache;var i=new t.Byte(r);if("LAYATEXTURECUBE:0000"!==i.readUTFString())throw"Laya3D:unknow version.";var a=i.readUint8(),n=i.getUint8(),s=i.readUint16(),o=i.getUint8(),l=i.getUint8(),_=i.getUint8(),h=i.getUint8(),c=new Ft(s,a,n>1);c.filterMode=o,c.wrapModeU=l,c.wrapModeV=_,c.anisoLevel=h;for(var d=i.pos,u=s,m=0;m=0&&e=0&&t0?s:0,_=Math.floor(i.width/(2-o)),h=Math.floor(i.height/(2-l)),c=Math.max(_,h);n=Math.log2(c)+this._diffusion-10;var d=Math.floor(n),u=Math.min(Math.max(d,1),Ja.MAXPYRAMIDSIZE),m=.5+n-d;this._shaderData.setNumber(Ja.SHADERVALUE_SAMPLESCALE,m);var f=Mt.gammaToLinearSpace(this.threshold),T=f*this._softKnee+1e-5;this._shaderThreshold.setValue(f,f-T,2*T,.25/T),this._shaderData.setVector(Ja.SHADERVALUE_THRESHOLD,this._shaderThreshold);var E=Mt.gammaToLinearSpace(this.clamp);this._shaderParams.setValue(E,0,0,0),this._shaderData.setVector(Ja.SHADERVALUE_PARAMS,this._shaderParams);for(var p=this.fastMode?1:0,g=e.source,S=0;S=0;S--)v=(R=2*S)+1,A=this._pyramid[R],I=this._pyramid[v],r.setShaderDataTexture(this._shaderData,Ja.SHADERVALUE_BLOOMTEX,A),r.blitScreenTriangle(D,I,null,this._shader,this._shaderData,Ja.SUBSHADER_UPSAMPLETENT+p),D=I;var M=this._linearColor;this.color.toLinear(M);var C=Math.pow(2,this._intensity/10)-1,y=this._shaderSetting;this._shaderSetting.setValue(m,C,this._dirtIntensity,u);var L=this.dirtTexture?this.dirtTexture:t.Texture2D.blackTexture,O=L.width/L.height,N=i.width/i.height,P=this._dirtTileOffset;O>N?P.setValue(N/O,1,.5*(1-P.x),0):O0&&(i[0]=r[0]*a,i[1]=r[1]*a,i[2]=r[2]*a,i[3]=r[3]*a)}static add(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]+n[0],i[1]=a[1]+n[1],i[2]=a[2]+n[2],i[3]=a[3]+n[3]}static subtract(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]-n[0],i[1]=a[1]-n[1],i[2]=a[2]-n[2],i[3]=a[3]-n[3]}static multiply(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]*n[0],i[1]=a[1]*n[1],i[2]=a[2]*n[2],i[3]=a[3]*n[3]}static scale(e,t,r){var i=r.elements,a=e.elements;i[0]=a[0]*t,i[1]=a[1]*t,i[2]=a[2]*t,i[3]=a[3]*t}static Clamp(e,t,r,i){var a=e.elements,n=a[0],s=a[1],o=a[2],l=a[3],_=t.elements,h=_[0],c=_[1],d=_[2],u=_[3],m=r.elements,f=m[0],T=m[1],E=m[2],p=m[3],g=i.elements;n=(n=n>f?f:n)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,a=e.elements,n=t.elements;i[0]=a[0]*n[0],i[1]=a[1]*n[1],i[2]=a[2]*n[2]}static scale(e,t,r){var i=r.elements,a=e.elements;i[0]=a[0]*t,i[1]=a[1]*t,i[2]=a[2]*t}static lerp(e,t,r,i){var a=i.elements,n=e.elements,s=t.elements,o=n[0],l=n[1],_=n[2];a[0]=o+r*(s[0]-o),a[1]=l+r*(s[1]-l),a[2]=_+r*(s[2]-_)}static transformV3ToV3(e,t,r){var i=en._tempVector4;en.transformV3ToV4(e,t,i);var a=i.elements,n=r.elements;n[0]=a[0],n[1]=a[1],n[2]=a[2]}static transformV3ToV4(e,t,r){var i=e.elements,a=i[0],n=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=a*o[0]+n*o[4]+s*o[8]+o[12],l[1]=a*o[1]+n*o[5]+s*o[9]+o[13],l[2]=a*o[2]+n*o[6]+s*o[10]+o[14],l[3]=a*o[3]+n*o[7]+s*o[11]+o[15]}static TransformNormal(e,t,r){var i=e.elements,a=i[0],n=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=a*o[0]+n*o[4]+s*o[8],l[1]=a*o[1]+n*o[5]+s*o[9],l[2]=a*o[2]+n*o[6]+s*o[10]}static transformCoordinate(e,t,r){var i=e.elements,a=i[0],n=i[1],s=i[2],o=t.elements,l=a*o[3]+n*o[7]+s*o[11]+o[15],_=r.elements;_[0]=a*o[0]+n*o[4]+s*o[8]+o[12]/l,_[1]=a*o[1]+n*o[5]+s*o[9]+o[13]/l,_[2]=a*o[2]+n*o[6]+s*o[10]+o[14]/l}static Clamp(e,t,r,i){var a=e.elements,n=a[0],s=a[1],o=a[2],l=t.elements,_=l[0],h=l[1],c=l[2],d=r.elements,u=d[0],m=d[1],f=d[2],T=i.elements;n=(n=n>u?u:n)<_?_:n,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]=a*s,t[3]=n*s)}static _lerpArray(e,t,r,i){var a=1-r;tn._dotArray(e,t)>=0?(i[0]=a*e[0]+r*t[0],i[1]=a*e[1]+r*t[1],i[2]=a*e[2]+r*t[2],i[3]=a*e[3]+r*t[3]):(i[0]=a*e[0]-r*t[0],i[1]=a*e[1]-r*t[1],i[2]=a*e[2]-r*t[2],i[3]=a*e[3]-r*t[3]),tn._normalizeArray(i,i)}static createFromYawPitchRoll(e,t,r,i){var a=.5*r,n=.5*t,s=.5*e,o=Math.sin(a),l=Math.cos(a),_=Math.sin(n),h=Math.cos(n),c=Math.sin(s),d=Math.cos(s),u=i.elements;u[0]=d*_*l+c*h*o,u[1]=c*h*l-d*_*o,u[2]=d*h*o-c*_*l,u[3]=d*h*l+c*_*o}static multiply(e,t,r){var i=e.elements,a=t.elements,n=r.elements,s=i[0],o=i[1],l=i[2],_=i[3],h=a[0],c=a[1],d=a[2],u=a[3],m=o*d-l*c,f=l*h-s*d,T=s*c-o*h,E=s*h+o*c+l*d;n[0]=s*u+h*_+m,n[1]=o*u+c*_+f,n[2]=l*u+d*_+T,n[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){en.subtract(t,e,tn.TEMPVector30),en.normalize(tn.TEMPVector30,tn.TEMPVector30),r.elements[0]=Math.asin(tn.TEMPVector30.y),r.elements[1]=tn.arcTanAngle(-tn.TEMPVector30.z,-tn.TEMPVector30.x)}static createFromAxisAngle(e,t,r){var i=r.elements,a=e.elements;t*=.5;var n=Math.sin(t);i[0]=n*a[0],i[1]=n*a[1],i[2]=n*a[2],i[3]=Math.cos(t)}static createFromMatrix3x3(e,t){var r,i=t.elements,a=e.elements,n=a[0]+a[4]+a[8];if(n>0)r=Math.sqrt(n+1),i[3]=.5*r,r=.5/r,i[0]=(a[5]-a[7])*r,i[1]=(a[6]-a[2])*r,i[2]=(a[1]-a[3])*r;else{var s=0;a[4]>a[0]&&(s=1),a[8]>a[3*s+s]&&(s=2);var o=(s+1)%3,l=(s+2)%3;r=Math.sqrt(a[3*s+s]-a[3*o+o]-a[3*l+l]+1),i[s]=.5*r,r=.5/r,i[3]=(a[3*o+l]-a[3*l+o])*r,i[o]=(a[3*o+s]+a[3*s+o])*r,i[l]=(a[3*l+s]+a[3*s+l])*r}}static createFromMatrix4x4(e,t){var r,i,a=e.elements,n=t.elements,s=a[0]+a[5]+a[10];s>0?(r=Math.sqrt(s+1),n[3]=.5*r,r=.5/r,n[0]=(a[6]-a[9])*r,n[1]=(a[8]-a[2])*r,n[2]=(a[1]-a[4])*r):a[0]>=a[5]&&a[0]>=a[10]?(i=.5/(r=Math.sqrt(1+a[0]-a[5]-a[10])),n[0]=.5*r,n[1]=(a[1]+a[4])*i,n[2]=(a[2]+a[8])*i,n[3]=(a[6]-a[9])*i):a[5]>a[10]?(i=.5/(r=Math.sqrt(1+a[5]-a[0]-a[10])),n[0]=(a[4]+a[1])*i,n[1]=.5*r,n[2]=(a[9]+a[6])*i,n[3]=(a[8]-a[2])*i):(i=.5/(r=Math.sqrt(1+a[10]-a[0]-a[5])),n[0]=(a[8]+a[2])*i,n[1]=(a[9]+a[6])*i,n[2]=.5*r,n[3]=(a[1]-a[4])*i)}static slerp(e,t,r,i){var a,n,s,o,l,_=e.elements,h=t.elements,c=i.elements,d=_[0],u=_[1],m=_[2],f=_[3],T=h[0],E=h[1],p=h[2],g=h[3];return(n=d*T+u*E+m*p+f*g)<0&&(n=-n,T=-T,E=-E,p=-p,g=-g),1-n>1e-6?(a=Math.acos(n),s=Math.sin(a),o=Math.sin((1-r)*a)/s,l=Math.sin(r*a)/s):(o=1-r,l=r),c[0]=o*d+l*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){tn._lerpArray(e.elements,t.elements,r,i.elements)}static add(e,t,r){var i=r.elements,a=e.elements,n=t.elements;i[0]=a[0]+n[0],i[1]=a[1]+n[1],i[2]=a[2]+n[2],i[3]=a[3]+n[3]}static dot(e,t){return tn._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){tn._normalizeArray(this.elements,e.elements)}length(){var e=this.elements,t=e[0],r=e[1],i=e[2],a=e[3];return Math.sqrt(t*t+r*r+i*i+a*a)}rotateX(e,t){var r=t.elements,i=this.elements;e*=.5;var a=i[0],n=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=a*_+o*l,r[1]=n*_+s*l,r[2]=s*_-n*l,r[3]=o*_-a*l}rotateY(e,t){var r=t.elements,i=this.elements;e*=.5;var a=i[0],n=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=a*_-s*l,r[1]=n*_+o*l,r[2]=s*_+a*l,r[3]=o*_-n*l}rotateZ(e,t){var r=t.elements,i=this.elements;e*=.5;var a=i[0],n=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=a*_+n*l,r[1]=n*_-a*l,r[2]=s*_+o*l,r[3]=o*_-s*l}getYawPitchRoll(e){en.transformQuat(en.ForwardRH,this,tn.TEMPVector31),en.transformQuat(en.Up,this,tn.TEMPVector32);var t=tn.TEMPVector32.elements;tn.angleTo(en.ZERO,tn.TEMPVector31,tn.TEMPVector33);var r=tn.TEMPVector33.elements;r[0]==Math.PI/2?(r[1]=tn.arcTanAngle(t[2],t[0]),r[2]=0):r[0]==-Math.PI/2?(r[1]=tn.arcTanAngle(-t[2],-t[0]),r[2]=0):(R.createRotationY(-r[1],tn.TEMPMatrix0),R.createRotationX(-r[0],tn.TEMPMatrix1),en.transformCoordinate(tn.TEMPVector32,tn.TEMPMatrix0,tn.TEMPVector32),en.transformCoordinate(tn.TEMPVector32,tn.TEMPMatrix1,tn.TEMPVector32),r[2]=tn.arcTanAngle(t[1],-t[0])),r[1]<=-Math.PI&&(r[1]=Math.PI),r[2]<=-Math.PI&&(r[2]=Math.PI),r[1]>=Math.PI&&r[2]>=Math.PI&&(r[1]=0,r[2]=0,r[0]=Math.PI-r[0]);var i=e.elements;i[0]=r[1],i[1]=r[0],i[2]=r[2]}invert(e){var t=e.elements,r=this.elements,i=r[0],a=r[1],n=r[2],s=r[3],o=i*i+a*a+n*n+s*s,l=o?1/o:0;t[0]=-i*l,t[1]=-a*l,t[2]=-n*l,t[3]=s*l}identity(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1}fromArray(e,t=0){this.elements[0]=e[t+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2],this.elements[3]=e[t+3]}cloneTo(e){var t,r,i;if((r=this.elements)!==(i=e.elements))for(t=0;t<4;++t)i[t]=r[t]}clone(){var e=new tn;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){tn.lookAt(en.ZERO,e,t,r)}static lookAt(e,t,r,i){p.lookAt(e,t,r,tn._tempMatrix3x3),tn.rotationMatrix(tn._tempMatrix3x3,i)}lengthSquared(){var e=this.elements[0],t=this.elements[1],r=this.elements[2],i=this.elements[3];return e*e+t*t+r*r+i*i}static invert(e,t){var i=e.elements,a=t.elements,n=e.lengthSquared();r.isZero(n)||(n=1/n,a[0]=-i[0]*n,a[1]=-i[1]*n,a[2]=-i[2]*n,a[3]=i[3]*n)}static rotationMatrix(e,t){var r,i,a=e.elements,n=a[0],s=a[1],o=a[2],l=a[3],_=a[4],h=a[5],c=a[6],d=a[7],u=a[8],m=t.elements,f=n+_+u;f>0?(r=Math.sqrt(f+1),m[3]=.5*r,r=.5/r,m[0]=(h-d)*r,m[1]=(c-o)*r,m[2]=(s-l)*r):n>=_&&n>=u?(i=.5/(r=Math.sqrt(1+n-_-u)),m[0]=.5*r,m[1]=(s+l)*i,m[2]=(o+c)*i,m[3]=(h-d)*i):_>u?(i=.5/(r=Math.sqrt(1+_-n-u)),m[0]=(l+s)*i,m[1]=.5*r,m[2]=(d+h)*i,m[3]=(c-o)*i):(i=.5/(r=Math.sqrt(1+u-n-_)),m[0]=(c+o)*i,m[1]=(d+h)*i,m[2]=.5*r,m[3]=(s-l)*i)}}tn.TEMPVector30=new en,tn.TEMPVector31=new en,tn.TEMPVector32=new en,tn.TEMPVector33=new en,tn.TEMPMatrix0=new R,tn.TEMPMatrix1=new R,tn._tempMatrix3x3=new p,tn.DEFAULT=new tn,tn.NAN=new tn(NaN,NaN,NaN,NaN);class rn{constructor(e){if(!(e instanceof Array)||4!==e.length)throw new Error("Rand:Seed must be an array with 4 numbers");this._state0U=0|e[0],this._state0L=0|e[1],this._state1U=0|e[2],this._state1L=0|e[3]}randomint(){var e=this._state0U,t=this._state0L,r=this._state1U,i=this._state1L,a=(i>>>0)+(t>>>0),n=r+e+(a/2>>>31)>>>0,s=a>>>0;this._state0U=r,this._state0L=i;var o=0,l=0;o=(e^=o=e<<23|(-512&t)>>>9)^r,l=(t^=l=t<<23)^i;o^=e>>>18,l^=t>>>18|(262143&e)<<14;return o^=r>>>5,l^=i>>>5|(31&r)<<27,this._state1U=o,this._state1L=l,[n,s]}random(){var e=this.randomint(),t=e[0],r=1023<<20|t>>>12,i=0|(e[1]>>>12|(4095&t)<<20);return rn._CONVERTION_BUFFER.setUint32(0,r,!1),rn._CONVERTION_BUFFER.setUint32(4,i,!1),rn._CONVERTION_BUFFER.getFloat64(0,!1)-1}}rn._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8)),rn.defaultRand=new rn([0,Date.now()/65536,0,Date.now()%65536]);class an{constructor(e,t){this._width=0,this._height=0,this._width=e,this._height=t}static get fullScreen(){return new an(-1,-1)}get width(){return-1===this._width?_e.clientWidth:this._width}get height(){return-1===this._height?_e.clientHeight:this._height}}e.AlternateLightQueue=Gt,e.AnimationClip=ie,e.AnimationClipParser03=ee,e.AnimationClipParser04=te,e.AnimationEvent=q,e.AnimationNode=at,e.AnimationTransform3D=it,e.Animator=le,e.AnimatorControllerLayer=ne,e.AnimatorPlayState=ae,e.AnimatorState=se,e.AnimatorStateScript=class{constructor(){}onStateEnter(){}onStateUpdate(){}onStateExit(){}},e.Avatar=nt,e.BaseCamera=Xe,e.BaseMaterial=ot,e.BaseRender=tr,e.BaseShape=Qr,e.BatchMark=Zt,e.BlinnPhongMaterial=_t,e.BlitScreenQuadCMD=Ie,e.BloomEffect=Ja,e.BoundBox=Ht,e.BoundFrustum=Be,e.BoundSphere=_r,e.Bounds=kt,e.BoundsOctree=or,e.BoundsOctreeNode=nr,e.BoxColliderShape=M,e.BoxShape=Jr,e.BufferState=Ee,e.BulletInteractive=yi,e.Burst=Gr,e.Camera=Qe,e.CameraCullInfo=Ct,e.CapsuleColliderShape=C,e.CastShadowList=class extends b{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=k,e.CircleShape=$r,e.ClearRenderTextureCMD=Le,e.Cluster=Ne,e.ColliderShape=v,e.Collision=F,e.CollisionTool=U,e.CollisionUtils=Ve,e.Color=Mt,e.ColorOverLifetime=Hr,e.Command=Ae,e.CommandBuffer=et,e.CompoundColliderShape=A,e.ConchQuaternion=tn,e.ConchVector3=en,e.ConchVector4=$a,e.ConeColliderShape=y,e.ConeShape=ei,e.Config3D=j,e.ConfigurableConstraint=Xa,e.Constraint3D=class{constructor(){}},e.ConstraintComponent=ka,e.ContactPoint=V,e.ContainmentType=we,e.CylinderColliderShape=L,e.DefineDatas=ce,e.DepthPass=qe,e.DirectionLight=Oa,e.DrawMeshCMD=ye,e.DrawRenderCMD=Je,e.DynamicBatchManager=ur,e.EffectMaterial=ht,e.Emission=mi,e.ExtendTerrainMaterial=ct,e.FixedConstraint=Wa,e.FloatKeyframe=K,e.FrameOverTime=kr,e.FrustumCulling=Lt,e.GeometryElement=Wt,e.Gradient=Ur,e.GradientAngularVelocity=Wr,e.GradientColor=zr,e.GradientDataInt=Xr,e.GradientDataNumber=Yr,e.GradientDataVector2=Qa,e.GradientMode=Fr,e.GradientSize=jr,e.GradientVelocity=Zr,e.HeightMap=Za,e.HemisphereShape=ti,e.HitResult=B,e.ILaya3D=g,e.IndexBuffer3D=Ge,e.Input3D=bt,e.Keyframe=Q,e.KeyframeNode=Z,e.KeyframeNodeList=re,e.KeyframeNodeOwner=oe,e.Laya3D=Ya,e.LightQueue=Ut,e.LightSprite=je,e.Lightmap=lr,e.LoadModelV04=Ba,e.LoadModelV05=Fa,e.Material=st,e.MathUtils3D=r,e.Matrix3x3=p,e.Matrix4x4=R,e.Mesh=Pi,e.MeshColliderShape=O,e.MeshFilter=br,e.MeshReader=Ua,e.MeshRenderDynamicBatchManager=Vr,e.MeshRenderStaticBatchManager=$t,e.MeshRenderer=Pr,e.MeshSprite3D=Br,e.MeshSprite3DShaderDeclaration=Nr,e.MeshTerrainSprite3D=qa,e.MouseTouch=Nt,e.OctreeMotionList=sr,e.PBRMaterial=dt,e.PBRSpecularMaterial=gr,e.PBRStandardMaterial=Mr,e.Physics3D=Y,e.Physics3DUtils=D,e.PhysicsCollider=Li,e.PhysicsComponent=P,e.PhysicsSettings=wt,e.PhysicsSimulation=G,e.PhysicsTriggerComponent=W,e.PhysicsUpdateList=w,e.Picker=Ue,e.PixelLineData=class{constructor(){this.startPosition=new n,this.endPosition=new n,this.startColor=new Mt,this.endColor=new Mt}cloneTo(e){this.startPosition.cloneTo(e.startPosition),this.endPosition.cloneTo(e.endPosition),this.startColor.cloneTo(e.startColor),this.endColor.cloneTo(e.endColor)}},e.PixelLineFilter=Yt,e.PixelLineMaterial=zt,e.PixelLineRenderer=rr,e.PixelLineSprite3D=ir,e.PixelLineVertex=Xt,e.Plane=Pe,e.PointLight=Na,e.PostProcess=rt,e.PostProcessEffect=Ka,e.PostProcessRenderContext=tt,e.PrimitiveMesh=bi,e.Quaternion=S,e.QuaternionKeyframe=J,e.Rand=ui,e.RandX=rn,e.Ray=be,e.ReflectionProbe=er,e.ReflectionProbeList=mr,e.ReflectionProbeManager=fr,e.RenderContext3D=_e,e.RenderElement=Ke,e.RenderQueue=ar,e.RenderState=lt,e.RenderTexture=he,e.RenderableSprite3D=jt,e.Rigidbody3D=X,e.RotationOverLifetime=qr,e.Scene3D=Tr,e.Scene3DShaderDeclaration=Ye,e.Scene3DUtils=Va,e.ScreenQuad=pe,e.ScreenTriangle=ge,e.Script3D=ja,e.SetGlobalShaderDataCMD=$e,e.SetRenderTargetCMD=De,e.SetShaderDataCMD=Me,e.Shader3D=xe,e.ShaderData=me,e.ShaderDefine=Se,e.ShaderInit3D=La,e.ShaderInstance=It,e.ShaderPass=Er,e.ShaderVariable=At,e.ShaderVariant=Re,e.ShaderVariantCollection=ve,e.ShadowCasterPass=dr,e.ShadowCullInfo=yt,e.ShadowSliceData=hr,e.ShadowSpotData=cr,e.ShadowUtils=Ze,e.ShapeUtils=Kr,e.ShuriKenParticle3D=Ei,e.ShuriKenParticle3DShaderDeclaration=oi,e.ShurikenParticleData=fi,e.ShurikenParticleMaterial=li,e.ShurikenParticleRenderer=_i,e.ShurikenParticleSystem=Ti,e.SimpleSingletonList=Dt,e.SimpleSkinnedMeshRenderer=ba,e.SimpleSkinnedMeshSprite3D=wa,e.SingletonList=b,e.Size=an,e.SizeOverLifetime=ii,e.SkinnedMeshRenderer=gi,e.SkinnedMeshSprite3D=Si,e.SkinnedMeshSprite3DShaderDeclaration=pi,e.SkyBox=ke,e.SkyBoxMaterial=Cr,e.SkyDome=Bt,e.SkyMesh=He,e.SkyPanoramicMaterial=Ha,e.SkyProceduralMaterial=yr,e.SkyRenderer=We,e.SphereColliderShape=N,e.SphereShape=ri,e.SphericalHarmonicsL2=Ot,e.SpotLight=Pa,e.Sprite3D=Ce,e.StartFrame=ai,e.StaticBatchManager=Kt,e.StaticPlaneColliderShape=x,e.SubMesh=Oi,e.SubMeshDynamicBatch=wr,e.SubMeshInstanceBatch=qt,e.SubMeshRenderElement=Qt,e.SubMeshStaticBatch=Jt,e.SubShader=pr,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=Ft,e.TextureGenerator=z,e.TextureMode=vi,e.TextureSheetAnimation=ni,e.Touch=Pt,e.TrailFilter=Ii,e.TrailGeometry=Ai,e.TrailMaterial=Ri,e.TrailRenderer=Di,e.TrailSprite3D=Mi,e.Transform3D=I,e.UnlitMaterial=Lr,e.Utils3D=H,e.Vector2=i,e.Vector3=n,e.Vector3Keyframe=$,e.Vector4=a,e.VelocityOverLifetime=si,e.VertexBuffer3D=de,e.VertexDeclaration=fe,e.VertexElement=Te,e.VertexElementFormat=ue,e.VertexMesh=ze,e.VertexPositionTerrain=Ci,e.VertexPositionTexture0=Vt,e.VertexShuriKenParticle=hi,e.VertexShurikenParticleBillboard=ci,e.VertexShurikenParticleMesh=di,e.VertexTrail=xi,e.Viewport=Fe,e.WaterPrimaryMaterial=Or,e.skinnedMatrixCache=Ni}(window.Laya=window.Laya||{},Laya);