!function(e,t,n){n.un,n.uns;var i=n.static,r=n.class,a=n.getset,o=n.__newvec,s=laya.resource.BaseTexture,l=laya.utils.Browser,h=laya.webgl.utils.Buffer,u=laya.webgl.BufferStateBase,c=laya.utils.Byte,d=laya.utils.ClassUtils,_=laya.layagl.CommandEncoder,f=laya.components.Component,m=n.Config,p=laya.resource.Context,T=(laya.events.Event,laya.events.EventDispatcher),S=laya.utils.Handler,E=(laya.webgl.utils.InlcudeFile,laya.layagl.LayaGL),v=laya.layagl.LayaGLRunner,g=laya.net.Loader,x=laya.net.LoaderManager,M=laya.maths.MathUtil,y=laya.display.Node,D=laya.maths.Point,R=laya.renders.Render,C=(laya.resource.RenderTexture2D,laya.resource.Resource),I=laya.utils.RunDriver,A=(laya.webgl.shader.Shader,laya.webgl.utils.ShaderCompile),L=laya.webgl.utils.ShaderNode,O=laya.display.Sprite,P=laya.utils.Stat,V=laya.webgl.submit.Submit,N=laya.webgl.submit.SubmitKey,B=laya.resource.Texture2D,w=(laya.utils.Timer,laya.net.URL),b=laya.webgl.WebGL,F=laya.webgl.WebGLContext;n.interface("laya.d3.core.IClone"),n.interface("laya.d3.graphics.IVertex"),n.interface("laya.d3.core.scene.IOctreeObject");var U=function(){function ConchVector4(e,t,n,i){this.elements=null,void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0);var r=this.elements=new Float32Array(4);r[0]=e,r[1]=t,r[2]=n,r[3]=i}r(ConchVector4,"laya.d3.math.Native.ConchVector4");var e=ConchVector4.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.fromArray=function(e,t){void 0===t&&(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]},e.cloneTo=function(e){var t=e.elements,n=this.elements;t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},a(0,e,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),a(0,e,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),a(0,e,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),a(0,e,"w",function(){return this.elements[3]},function(e){this.elements[3]=e}),ConchVector4.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,o=t.elements,s=a[0],l=a[1],h=a[2],u=a[3];r[0]=s+n*(o[0]-s),r[1]=l+n*(o[1]-l),r[2]=h+n*(o[2]-h),r[3]=u+n*(o[3]-u)},ConchVector4.transformByM4x4=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=t.elements,h=n.elements;h[0]=r*l[0]+a*l[4]+o*l[8]+s*l[12],h[1]=r*l[1]+a*l[5]+o*l[9]+s*l[13],h[2]=r*l[2]+a*l[6]+o*l[10]+s*l[14],h[3]=r*l[3]+a*l[7]+o*l[11]+s*l[15]},ConchVector4.equals=function(e,t){var n=e.elements,i=t.elements;return ft.nearEqual(Math.abs(n[0]),Math.abs(i[0]))&&ft.nearEqual(Math.abs(n[1]),Math.abs(i[1]))&&ft.nearEqual(Math.abs(n[2]),Math.abs(i[2]))&&ft.nearEqual(Math.abs(n[3]),Math.abs(i[3]))},ConchVector4.normalize=function(e,t){var n=e.elements,i=t.elements,r=e.length();r>0&&(i[0]=n[0]*r,i[1]=n[1]*r,i[2]=n[2]*r,i[3]=n[3]*r)},ConchVector4.add=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3]},ConchVector4.subtract=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]-a[0],i[1]=r[1]-a[1],i[2]=r[2]-a[2],i[3]=r[3]-a[3]},ConchVector4.multiply=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]*a[0],i[1]=r[1]*a[1],i[2]=r[2]*a[2],i[3]=r[3]*a[3]},ConchVector4.scale=function(e,t,n){var i=n.elements,r=e.elements;i[0]=r[0]*t,i[1]=r[1]*t,i[2]=r[2]*t,i[3]=r[3]*t},ConchVector4.Clamp=function(e,t,n,i){var r=e.elements,a=r[0],o=r[1],s=r[2],l=r[3],h=t.elements,u=h[0],c=h[1],d=h[2],_=h[3],f=n.elements,m=f[0],p=f[1],T=f[2],S=f[3],E=i.elements;a=(a=a>m?m:a)p?p:o)T?T:s)S?S:l)<_?_:l,E[0]=a,E[1]=o,E[2]=s,E[3]=l},ConchVector4.distanceSquared=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2],s=n[3]-i[3];return r*r+a*a+o*o+s*s},ConchVector4.distance=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2],s=n[3]-i[3];return Math.sqrt(r*r+a*a+o*o+s*s)},ConchVector4.dot=function(e,t){var n=e.elements,i=t.elements;return n[0]*i[0]+n[1]*i[1]+n[2]*i[2]+n[3]*i[3]},ConchVector4.min=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.min(r[0],a[0]),i[1]=Math.min(r[1],a[1]),i[2]=Math.min(r[2],a[2]),i[3]=Math.min(r[3],a[3])},ConchVector4.max=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.max(r[0],a[0]),i[1]=Math.max(r[1],a[1]),i[2]=Math.max(r[2],a[2]),i[3]=Math.max(r[3],a[3])},i(ConchVector4,["ZERO",function(){return this.ZERO=new ConchVector4},"ONE",function(){return this.ONE=new ConchVector4(1,1,1,1)},"UnitX",function(){return this.UnitX=new ConchVector4(1,0,0,0)},"UnitY",function(){return this.UnitY=new ConchVector4(0,1,0,0)},"UnitZ",function(){return this.UnitZ=new ConchVector4(0,0,1,0)},"UnitW",function(){return this.UnitW=new ConchVector4(0,0,0,1)}]),ConchVector4}(),z=function(){function ConchVector3(e,t,n,i){var r;this.elements=null,void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),r=i||new Float32Array(3),this.elements=r,r[0]=e,r[1]=t,r[2]=n}r(ConchVector3,"laya.d3.math.Native.ConchVector3");var e=ConchVector3.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.setValue=function(e,t,n){this.elements[0]=e,this.elements[1]=t,this.elements[2]=n},e.fromArray=function(e,t){void 0===t&&(t=0),this.elements[0]=e[t+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2]},e.cloneTo=function(e){var t=e.elements,n=this.elements;t[0]=n[0],t[1]=n[1],t[2]=n[2]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.toDefault=function(){this.elements[0]=0,this.elements[1]=0,this.elements[2]=0},a(0,e,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),a(0,e,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),a(0,e,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),ConchVector3.distanceSquared=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2];return r*r+a*a+o*o},ConchVector3.distance=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2];return Math.sqrt(r*r+a*a+o*o)},ConchVector3.min=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.min(r[0],a[0]),i[1]=Math.min(r[1],a[1]),i[2]=Math.min(r[2],a[2])},ConchVector3.max=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.max(r[0],a[0]),i[1]=Math.max(r[1],a[1]),i[2]=Math.max(r[2],a[2])},ConchVector3.transformQuat=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements,o=r[0],s=r[1],l=r[2],h=a[0],u=a[1],c=a[2],d=a[3],_=d*o+u*l-c*s,f=d*s+c*o-h*l,m=d*l+h*s-u*o,p=-h*o-u*s-c*l;i[0]=_*d+p*-h+f*-c-m*-u,i[1]=f*d+p*-u+m*-h-_*-c,i[2]=m*d+p*-c+_*-u-f*-h},ConchVector3.scalarLength=function(e){var t=e.elements,n=t[0],i=t[1],r=t[2];return Math.sqrt(n*n+i*i+r*r)},ConchVector3.scalarLengthSquared=function(e){var t=e.elements,n=t[0],i=t[1],r=t[2];return n*n+i*i+r*r},ConchVector3.normalize=function(e,t){var n=e.elements,i=t.elements,r=n[0],a=n[1],o=n[2],s=r*r+a*a+o*o;s>0&&(s=1/Math.sqrt(s),i[0]=n[0]*s,i[1]=n[1]*s,i[2]=n[2]*s)},ConchVector3.multiply=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]*a[0],i[1]=r[1]*a[1],i[2]=r[2]*a[2]},ConchVector3.scale=function(e,t,n){var i=n.elements,r=e.elements;i[0]=r[0]*t,i[1]=r[1]*t,i[2]=r[2]*t},ConchVector3.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,o=t.elements,s=a[0],l=a[1],h=a[2];r[0]=s+n*(o[0]-s),r[1]=l+n*(o[1]-l),r[2]=h+n*(o[2]-h)},ConchVector3.transformV3ToV3=function(e,t,n){var i=ConchVector3._tempVector4;ConchVector3.transformV3ToV4(e,t,i);var r=i.elements,a=n.elements;a[0]=r[0],a[1]=r[1],a[2]=r[2]},ConchVector3.transformV3ToV4=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=t.elements,l=n.elements;l[0]=r*s[0]+a*s[4]+o*s[8]+s[12],l[1]=r*s[1]+a*s[5]+o*s[9]+s[13],l[2]=r*s[2]+a*s[6]+o*s[10]+s[14],l[3]=r*s[3]+a*s[7]+o*s[11]+s[15]},ConchVector3.TransformNormal=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=t.elements,l=n.elements;l[0]=r*s[0]+a*s[4]+o*s[8],l[1]=r*s[1]+a*s[5]+o*s[9],l[2]=r*s[2]+a*s[6]+o*s[10]},ConchVector3.transformCoordinate=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=t.elements,l=r*s[3]+a*s[7]+o*s[11]+s[15],h=n.elements;h[0]=r*s[0]+a*s[4]+o*s[8]+s[12]/l,h[1]=r*s[1]+a*s[5]+o*s[9]+s[13]/l,h[2]=r*s[2]+a*s[6]+o*s[10]+s[14]/l},ConchVector3.Clamp=function(e,t,n,i){var r=e.elements,a=r[0],o=r[1],s=r[2],l=t.elements,h=l[0],u=l[1],c=l[2],d=n.elements,_=d[0],f=d[1],m=d[2],p=i.elements;a=(a=a>_?_:a)f?f:o)m?m:s)=Math.PI&&n[2]>=Math.PI&&(n[1]=0,n[2]=0,n[0]=Math.PI-n[0]);var i=e.elements;i[0]=n[1],i[1]=n[0],i[2]=n[2]},e.invert=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=i*i+r*r+a*a+o*o,l=s?1/s:0;t[0]=-i*l,t[1]=-r*l,t[2]=-a*l,t[3]=o*l},e.identity=function(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1},e.fromArray=function(e,t){void 0===t&&(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]},e.cloneTo=function(e){var t,n,i;if((n=this.elements)!==(i=e.elements))for(t=0;t<4;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.equals=function(e){var t=this.elements,n=e.elements;return ft.nearEqual(t[0],n[0])&&ft.nearEqual(t[1],n[1])&&ft.nearEqual(t[2],n[2])&&ft.nearEqual(t[3],n[3])},e.lengthSquared=function(){var e=this.elements[0],t=this.elements[1],n=this.elements[2],i=this.elements[3];return e*e+t*t+n*n+i*i},a(0,e,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),a(0,e,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),a(0,e,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),a(0,e,"w",function(){return this.elements[3]},function(e){this.elements[3]=e}),ConchQuaternion._dotArray=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ConchQuaternion._normalizeArray=function(e,t){var n=e[0],i=e[1],r=e[2],a=e[3],o=n*n+i*i+r*r+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=n*o,t[1]=i*o,t[2]=r*o,t[3]=a*o)},ConchQuaternion._lerpArray=function(e,t,n,i){var r=1-n;ConchQuaternion._dotArray(e,t)>=0?(i[0]=r*e[0]+n*t[0],i[1]=r*e[1]+n*t[1],i[2]=r*e[2]+n*t[2],i[3]=r*e[3]+n*t[3]):(i[0]=r*e[0]-n*t[0],i[1]=r*e[1]-n*t[1],i[2]=r*e[2]-n*t[2],i[3]=r*e[3]-n*t[3]),ConchQuaternion._normalizeArray(i,i)},ConchQuaternion.createFromYawPitchRoll=function(e,t,n,i){var r=.5*n,a=.5*t,o=.5*e,s=Math.sin(r),l=Math.cos(r),h=Math.sin(a),u=Math.cos(a),c=Math.sin(o),d=Math.cos(o),_=i.elements;_[0]=d*h*l+c*u*s,_[1]=c*u*l-d*h*s,_[2]=d*u*s-c*h*l,_[3]=d*u*l+c*h*s},ConchQuaternion.multiply=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,o=i[0],s=i[1],l=i[2],h=i[3],u=r[0],c=r[1],d=r[2],_=r[3],f=s*d-l*c,m=l*u-o*d,p=o*c-s*u,T=o*u+s*c+l*d;a[0]=o*_+u*h+f,a[1]=s*_+c*h+m,a[2]=l*_+d*h+p,a[3]=h*_-T},ConchQuaternion.arcTanAngle=function(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},ConchQuaternion.angleTo=function(e,t,n){z.subtract(t,e,ConchQuaternion.TEMPVector30),z.normalize(ConchQuaternion.TEMPVector30,ConchQuaternion.TEMPVector30),n.elements[0]=Math.asin(ConchQuaternion.TEMPVector30.y),n.elements[1]=ConchQuaternion.arcTanAngle(-ConchQuaternion.TEMPVector30.z,-ConchQuaternion.TEMPVector30.x)},ConchQuaternion.createFromAxisAngle=function(e,t,n){var i=n.elements,r=e.elements;t*=.5;var a=Math.sin(t);i[0]=a*r[0],i[1]=a*r[1],i[2]=a*r[2],i[3]=Math.cos(t)},ConchQuaternion.createFromMatrix3x3=function(e,t){var n,i=t.elements,r=e.elements,a=r[0]+r[4]+r[8];if(a>0)n=Math.sqrt(a+1),i[3]=.5*n,n=.5/n,i[0]=(r[5]-r[7])*n,i[1]=(r[6]-r[2])*n,i[2]=(r[1]-r[3])*n;else{var o=0;r[4]>r[0]&&(o=1),r[8]>r[3*o+o]&&(o=2);var s=(o+1)%3,l=(o+2)%3;n=Math.sqrt(r[3*o+o]-r[3*s+s]-r[3*l+l]+1),i[o]=.5*n,n=.5/n,i[3]=(r[3*s+l]-r[3*l+s])*n,i[s]=(r[3*s+o]+r[3*o+s])*n,i[l]=(r[3*l+o]+r[3*o+l])*n}},ConchQuaternion.createFromMatrix4x4=function(e,t){var n,i,r=e.elements,a=t.elements,o=r[0]+r[5]+r[10];o>0?(n=Math.sqrt(o+1),a[3]=.5*n,n=.5/n,a[0]=(r[6]-r[9])*n,a[1]=(r[8]-r[2])*n,a[2]=(r[1]-r[4])*n):r[0]>=r[5]&&r[0]>=r[10]?(i=.5/(n=Math.sqrt(1+r[0]-r[5]-r[10])),a[0]=.5*n,a[1]=(r[1]+r[4])*i,a[2]=(r[2]+r[8])*i,a[3]=(r[6]-r[9])*i):r[5]>r[10]?(i=.5/(n=Math.sqrt(1+r[5]-r[0]-r[10])),a[0]=(r[4]+r[1])*i,a[1]=.5*n,a[2]=(r[9]+r[6])*i,a[3]=(r[8]-r[2])*i):(i=.5/(n=Math.sqrt(1+r[10]-r[0]-r[5])),a[0]=(r[8]+r[2])*i,a[1]=(r[9]+r[6])*i,a[2]=.5*n,a[3]=(r[1]-r[4])*i)},ConchQuaternion.slerp=function(e,t,n,i){var r,a,o,s,l,h=e.elements,u=t.elements,c=i.elements,d=h[0],_=h[1],f=h[2],m=h[3],p=u[0],T=u[1],S=u[2],E=u[3];return(a=d*p+_*T+f*S+m*E)<0&&(a=-a,p=-p,T=-T,S=-S,E=-E),1-a>1e-6?(r=Math.acos(a),o=Math.sin(r),s=Math.sin((1-n)*r)/o,l=Math.sin(n*r)/o):(s=1-n,l=n),c[0]=s*d+l*p,c[1]=s*_+l*T,c[2]=s*f+l*S,c[3]=s*m+l*E,c},ConchQuaternion.lerp=function(e,t,n,i){ConchQuaternion._lerpArray(e.elements,t.elements,n,i.elements)},ConchQuaternion.add=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3]},ConchQuaternion.dot=function(e,t){return ConchQuaternion._dotArray(e.elements,t.elements)},ConchQuaternion.rotationLookAt=function(e,t,n){ConchQuaternion.lookAt(z.ZERO,e,t,n)},ConchQuaternion.lookAt=function(e,t,n,i){H.lookAt(e,t,n,ConchQuaternion._tempMatrix3x3),ConchQuaternion.rotationMatrix(ConchQuaternion._tempMatrix3x3,i)},ConchQuaternion.invert=function(e,t){var n=e.elements,i=t.elements,r=e.lengthSquared();ft.isZero(r)||(r=1/r,i[0]=-n[0]*r,i[1]=-n[1]*r,i[2]=-n[2]*r,i[3]=n[3]*r)},ConchQuaternion.rotationMatrix=function(e,t){var n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],h=n[6],u=n[7],c=n[8],d=t.elements,_=NaN,f=NaN,m=i+s+c;m>0?(_=Math.sqrt(m+1),d[3]=.5*_,_=.5/_,d[0]=(l-u)*_,d[1]=(h-a)*_,d[2]=(r-o)*_):i>=s&&i>=c?(f=.5/(_=Math.sqrt(1+i-s-c)),d[0]=.5*_,d[1]=(r+o)*f,d[2]=(a+h)*f,d[3]=(l-u)*f):s>c?(f=.5/(_=Math.sqrt(1+s-i-c)),d[0]=(o+r)*f,d[1]=.5*_,d[2]=(u+l)*f,d[3]=(h-a)*f):(f=.5/(_=Math.sqrt(1+c-i-s)),d[0]=(h+a)*f,d[1]=(u+l)*f,d[2]=.5*_,d[3]=(r-o)*f)},ConchQuaternion.DEFAULT=new ConchQuaternion,i(ConchQuaternion,["TEMPVector30",function(){return this.TEMPVector30=new z},"TEMPVector31",function(){return this.TEMPVector31=new z},"TEMPVector32",function(){return this.TEMPVector32=new z},"TEMPVector33",function(){return this.TEMPVector33=new z},"TEMPMatrix0",function(){return this.TEMPMatrix0=new Q},"TEMPMatrix1",function(){return this.TEMPMatrix1=new Q},"_tempMatrix3x3",function(){return this._tempMatrix3x3=new H},"NAN",function(){return this.NAN=new ConchQuaternion(NaN,NaN,NaN,NaN)}]),ConchQuaternion}(),H=function(){function Matrix3x3(){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}r(Matrix3x3,"laya.d3.math.Matrix3x3");var e=Matrix3x3.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.determinant=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],h=e[8];return t*(h*a-o*l)+n*(-h*r+o*s)+i*(l*r-a*s)},e.translate=function(e,t){var n=t.elements,i=this.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],_=e.x,f=e.y;n[0]=r,n[1]=a,n[2]=o,n[3]=s,n[4]=l,n[5]=h,n[6]=_*r+f*s+u,n[7]=_*a+f*l+c,n[8]=_*o+f*h+d},e.rotate=function(e,t){var n=t.elements,i=this.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],_=Math.sin(e),f=Math.cos(e);n[0]=f*r+_*s,n[1]=f*a+_*l,n[2]=f*o+_*h,n[3]=f*s-_*r,n[4]=f*l-_*a,n[5]=f*h-_*o,n[6]=u,n[7]=c,n[8]=d},e.scale=function(e,t){var n=t.elements,i=this.elements,r=e.x,a=e.y;n[0]=r*i[0],n[1]=r*i[1],n[2]=r*i[2],n[3]=a*i[3],n[4]=a*i[4],n[5]=a*i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8]},e.invert=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],h=n[6],u=n[7],c=n[8],d=c*s-l*u,_=-c*o+l*h,f=u*o-s*h,m=i*d+r*_+a*f;m||(e=null),m=1/m,t[0]=d*m,t[1]=(-c*r+a*u)*m,t[2]=(l*r-a*s)*m,t[3]=_*m,t[4]=(c*i-a*h)*m,t[5]=(-l*i+a*o)*m,t[6]=f*m,t[7]=(-u*i+r*h)*m,t[8]=(s*i-r*o)*m},e.transpose=function(e){var t=e.elements,n=this.elements;if(e===this){var i=n[1],r=n[2],a=n[5];t[1]=n[3],t[2]=n[6],t[3]=i,t[5]=n[7],t[6]=r,t[7]=a}else t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8]},e.identity=function(){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},e.cloneTo=function(e){var t,n,i;if((n=this.elements)!==(i=e.elements))for(t=0;t<9;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},Matrix3x3.createFromTranslation=function(e,t){t.elements;t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e.x,t[7]=e.y,t[8]=1},Matrix3x3.createFromRotation=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[0]=r,n[1]=i,n[2]=0,n[3]=-i,n[4]=r,n[5]=0,n[6]=0,n[7]=0,n[8]=1},Matrix3x3.createFromScaling=function(e,t){var n=t.elements;n[0]=e.x,n[1]=0,n[2]=0,n[3]=0,n[4]=e.y,n[5]=0,n[6]=0,n[7]=0,n[8]=1},Matrix3x3.createFromMatrix4x4=function(e,t){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10]},Matrix3x3.multiply=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements,o=r[0],s=r[1],l=r[2],h=r[3],u=r[4],c=r[5],d=r[6],_=r[7],f=r[8],m=a[0],p=a[1],T=a[2],S=a[3],E=a[4],v=a[5],g=a[6],x=a[7],M=a[8];i[0]=m*o+p*h+T*d,i[1]=m*s+p*u+T*_,i[2]=m*l+p*c+T*f,i[3]=S*o+E*h+v*d,i[4]=S*s+E*u+v*_,i[5]=S*l+E*c+v*f,i[6]=g*o+x*h+M*d,i[7]=g*s+x*u+M*_,i[8]=g*l+x*c+M*f},Matrix3x3.lookAt=function(e,t,n,i){Rt.subtract(e,t,Matrix3x3._tempV30),Rt.normalize(Matrix3x3._tempV30,Matrix3x3._tempV30),Rt.cross(n,Matrix3x3._tempV30,Matrix3x3._tempV31),Rt.normalize(Matrix3x3._tempV31,Matrix3x3._tempV31),Rt.cross(Matrix3x3._tempV30,Matrix3x3._tempV31,Matrix3x3._tempV32);var r=Matrix3x3._tempV30,a=Matrix3x3._tempV31,o=Matrix3x3._tempV32,s=i.elements;s[0]=a.x,s[3]=a.y,s[6]=a.z,s[1]=o.x,s[4]=o.y,s[7]=o.z,s[2]=r.x,s[5]=r.y,s[8]=r.z},Matrix3x3.DEFAULT=new Matrix3x3,i(Matrix3x3,["_tempV30",function(){return this._tempV30=new Rt},"_tempV31",function(){return this._tempV31=new Rt},"_tempV32",function(){return this._tempV32=new Rt}]),Matrix3x3}(),k=function(){function Color(e,t,n,i){this.r=NaN,this.g=NaN,this.b=NaN,this.a=NaN,void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===i&&(i=1),this.r=e,this.g=t,this.b=n,this.a=i}r(Color,"laya.d3.math.Color");var e=Color.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.toLinear=function(e){e.r=fe.gammaToLinearSpace(this.r),e.g=fe.gammaToLinearSpace(this.g),e.b=fe.gammaToLinearSpace(this.b)},e.toGamma=function(e){e.r=fe.linearToGammaSpace(this.r),e.g=fe.linearToGammaSpace(this.g),e.b=fe.linearToGammaSpace(this.b)},e.cloneTo=function(e){var t=e;t.r=this.r,t.g=this.g,t.b=this.b,t.a=this.a},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.forNativeElement=function(e){e?(this.elements=e,this.elements[0]=this.r,this.elements[1]=this.g,this.elements[2]=this.b,this.elements[3]=this.a):this.elements=new Float32Array([this.r,this.g,this.b,this.a]),Ct.rewriteNumProperty(this,"r",0),Ct.rewriteNumProperty(this,"g",1),Ct.rewriteNumProperty(this,"b",2),Ct.rewriteNumProperty(this,"a",3)},i(Color,["RED",function(){return this.RED=new Color(1,0,0,1)},"GREEN",function(){return this.GREEN=new Color(0,1,0,1)},"BLUE",function(){return this.BLUE=new Color(0,0,1,1)},"CYAN",function(){return this.CYAN=new Color(0,1,1,1)},"YELLOW",function(){return this.YELLOW=new Color(1,.92,.016,1)},"MAGENTA",function(){return this.MAGENTA=new Color(1,0,1,1)},"GRAY",function(){return this.GRAY=new Color(.5,.5,.5,1)},"WHITE",function(){return this.WHITE=new Color(1,1,1,1)},"BLACK",function(){return this.BLACK=new Color(0,0,0,1)}]),Color}(),W=function(){function SkyRenderer(){this._material=null,this._mesh=wn.instance}r(SkyRenderer,"laya.d3.resource.models.SkyRenderer");var e=SkyRenderer.prototype;return e._isAvailable=function(){return this._material&&this._mesh},e._render=function(e){if(this._material&&this._mesh){var t=E.instance,n=e.scene,i=e.camera;F.setCullFace(t,!1),F.setDepthFunc(t,515),F.setDepthMask(t,!1);var r=e.shader=this._material._shader.getSubShaderAt(0)._passes[0].withCompile(0,0,this._material._defineDatas.value),a=r.bind(),o=P.loopCount!==r._uploadMark,s=r._uploadScene!==n||o;(s||a)&&(r.uploadUniforms(r._sceneUniformParamsMap,n._shaderValues,s),r._uploadScene=n);var l=r._uploadCamera!==i||o;(l||a)&&(r.uploadUniforms(r._cameraUniformParamsMap,i._shaderValues,l),r._uploadCamera=i);var h=r._uploadMaterial!==this._material||o;(h||a)&&(r.uploadUniforms(r._materialUniformParamsMap,this._material._shaderValues,h),r._uploadMaterial=this._material),this._mesh._bufferState.bind(),this._mesh._render(e),F.setDepthFunc(t,513),F.setDepthMask(t,!0)}},e.destroy=function(){this._material&&(this._material._removeReference(),this._material=null)},a(0,e,"material",function(){return this._material},function(e){this._material!==e&&(this._material&&this._material._removeReference(),e&&e._addReference(),this._material=e)}),a(0,e,"mesh",function(){return this._mesh},function(e){this._mesh!==e&&(this._mesh=e)}),SkyRenderer}(),X=function(){function MeshFilter(e){this._owner=null,this._sharedMesh=null,this._owner=e}r(MeshFilter,"laya.d3.core.MeshFilter");var e=MeshFilter.prototype;return e._getMeshDefine=function(e){for(var t=0,n=0,i=e._subMeshCount;nm?TerrainLeaf.__VECTOR3__.y:m,TerrainLeaf.__ADAPT_MATRIX__&&Rt.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__),a[_]=TerrainLeaf.__VECTOR3__.x,a[++_]=TerrainLeaf.__VECTOR3__.y,a[++_]=TerrainLeaf.__VECTOR3__.z,_++,this.calcVertextNormlUV(this._beginGridX+E,this._beginGridZ+T,h,u,p),a[_]=p.x,a[++_]=p.y,a[++_]=p.z,a[++_]=(n+E)/TerrainLeaf.CHUNK_GRID_NUM,a[++_]=(i+T)/TerrainLeaf.CHUNK_GRID_NUM,a[++_]=this._beginGridX+E,a[++_]=this._beginGridZ+T,_++;this._sizeOfY=new Ct(f-1,m+1),this.calcLODErrors(l,h,u),this.calcOriginalBoudingBoxAndSphere()},e.calcSkirtVertextBuffer=function(e,t,n,i,r,a,o,s,l,h,u){this._gridSize=r,this._beginGridX=e*TerrainLeaf.CHUNK_GRID_NUM+n,this._beginGridZ=t*TerrainLeaf.CHUNK_GRID_NUM+i;var c=o*s,d=0,_=0,f=TerrainLeaf.LEAF_GRID_NUM+1,m=new Rt,p=0,T=0;for(d=0;d<2;d++)for(_=0;_r&&(a=this._currentLODLevel)}for(var o=a;o>=1;o--)if(hi.LOD_DISTANCE_FACTOR*this._LODError[o]/r*tTerrainLeaf._maxLODLevel&&(e=TerrainLeaf._maxLODLevel);var t=TerrainLeaf.LEAF_GRID_NUM+1,n=0,i=null,r=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,e);i=new Uint16Array(r*r*6);for(var a=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/r,o=0;oTerrainLeaf._maxLODLevel&&(e=TerrainLeaf._maxLODLevel);var t=TerrainLeaf.CHUNK_GRID_NUM/TerrainLeaf.LEAF_GRID_NUM*(TerrainLeaf.CHUNK_GRID_NUM/TerrainLeaf.LEAF_GRID_NUM)*TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT,n=TerrainLeaf.LEAF_GRID_NUM+1,i=0,r=null,a=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,e);r=new Uint16Array(4*a*6);for(var o=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/a,s=0;s<4;s++){for(var l=0;l=r?r-1:t)*i+(e=(e=e<0?0:e)>=i?i-1:e)]},TerrainLeaf.CHUNK_GRID_NUM=64,TerrainLeaf.LEAF_GRID_NUM=32,TerrainLeaf.__ADAPT_MATRIX__=null,TerrainLeaf.__ADAPT_MATRIX_INV__=null,TerrainLeaf._planeLODIndex=null,TerrainLeaf._skirtLODIndex=null,TerrainLeaf._bInit=!1,i(TerrainLeaf,["LEAF_PLANE_VERTEXT_COUNT",function(){return this.LEAF_PLANE_VERTEXT_COUNT=(TerrainLeaf.LEAF_GRID_NUM+1)*(TerrainLeaf.LEAF_GRID_NUM+1)},"LEAF_SKIRT_VERTEXT_COUNT",function(){return this.LEAF_SKIRT_VERTEXT_COUNT=2*(TerrainLeaf.LEAF_GRID_NUM+1)*4},"LEAF_VERTEXT_COUNT",function(){return this.LEAF_VERTEXT_COUNT=TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT+TerrainLeaf.LEAF_SKIRT_VERTEXT_COUNT},"LEAF_PLANE_MAX_INDEX_COUNT",function(){return this.LEAF_PLANE_MAX_INDEX_COUNT=TerrainLeaf.LEAF_GRID_NUM*TerrainLeaf.LEAF_GRID_NUM*6},"LEAF_SKIRT_MAX_INDEX_COUNT",function(){return this.LEAF_SKIRT_MAX_INDEX_COUNT=4*TerrainLeaf.LEAF_GRID_NUM*6},"LEAF_MAX_INDEX_COUNT",function(){return this.LEAF_MAX_INDEX_COUNT=TerrainLeaf.LEAF_PLANE_MAX_INDEX_COUNT+TerrainLeaf.LEAF_SKIRT_MAX_INDEX_COUNT},"__VECTOR3__",function(){return this.__VECTOR3__=new Rt},"_maxLODLevel",function(){return this._maxLODLevel=Math.log2(TerrainLeaf.LEAF_GRID_NUM)}]),TerrainLeaf}(),Q=function(){function Matrix4x4(e,t,n,i,r,a,o,s,l,h,u,c,d,_,f,m,p){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===h&&(h=0),void 0===u&&(u=1),void 0===c&&(c=0),void 0===d&&(d=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===m&&(m=1);var T=this.elements=p||new Float32Array(16);T[0]=e,T[1]=t,T[2]=n,T[3]=i,T[4]=r,T[5]=a,T[6]=o,T[7]=s,T[8]=l,T[9]=h,T[10]=u,T[11]=c,T[12]=d,T[13]=_,T[14]=f,T[15]=m}r(Matrix4x4,"laya.d3.math.Matrix4x4");var e=Matrix4x4.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.setRotation=function(e){var t=e.x,n=e.y,i=e.z,r=e.w,a=t*t,o=n*n,s=i*i,l=t*n,h=i*r,u=i*t,c=n*r,d=n*i,_=t*r,f=this.elements;f[0]=1-2*(o+s),f[1]=2*(l+h),f[2]=2*(u-c),f[4]=2*(l-h),f[5]=1-2*(s+a),f[6]=2*(d+_),f[8]=2*(u+c),f[9]=2*(d-_),f[10]=1-2*(o+a)},e.setPosition=function(e){var t=this.elements;t[12]=e.x,t[13]=e.y,t[14]=e.z},e.getElementByRowColumn=function(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]},e.setElementByRowColumn=function(e,t,n){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]=n},e.equalsOtherMatrix=function(e){var t=this.elements,n=e.elements;return ft.nearEqual(t[0],n[0])&&ft.nearEqual(t[1],n[1])&&ft.nearEqual(t[2],n[2])&&ft.nearEqual(t[3],n[3])&&ft.nearEqual(t[4],n[4])&&ft.nearEqual(t[5],n[5])&&ft.nearEqual(t[6],n[6])&&ft.nearEqual(t[7],n[7])&&ft.nearEqual(t[8],n[8])&&ft.nearEqual(t[9],n[9])&&ft.nearEqual(t[10],n[10])&&ft.nearEqual(t[11],n[11])&&ft.nearEqual(t[12],n[12])&&ft.nearEqual(t[13],n[13])&&ft.nearEqual(t[14],n[14])&&ft.nearEqual(t[15],n[15])},e.decomposeTransRotScale=function(e,t,n){var i=Matrix4x4._tempMatrix4x4;return this.decomposeTransRotMatScale(e,i,n)?(dt.createFromMatrix4x4(i,t),!0):(t.identity(),!1)},e.decomposeTransRotMatScale=function(e,t,n){var i=this.elements,r=e,a=t.elements,o=n;r.x=i[12],r.y=i[13],r.z=i[14];var s=i[0],l=i[1],h=i[2],u=i[4],c=i[5],d=i[6],_=i[8],f=i[9],m=i[10],p=o.x=Math.sqrt(s*s+l*l+h*h),T=o.y=Math.sqrt(u*u+c*c+d*d),S=o.z=Math.sqrt(_*_+f*f+m*m);if(ft.isZero(p)||ft.isZero(T)||ft.isZero(S))return a[1]=a[2]=a[3]=a[4]=a[6]=a[7]=a[8]=a[9]=a[11]=a[12]=a[13]=a[14]=0,a[0]=a[5]=a[10]=a[15]=1,!1;var E=Matrix4x4._tempVector0;E.x=_/S,E.y=f/S,E.z=m/S;var v=Matrix4x4._tempVector1;v.x=s/p,v.y=l/p,v.z=h/p;var g=Matrix4x4._tempVector2;Rt.cross(E,v,g);var x=Matrix4x4._tempVector1;return Rt.cross(g,E,x),a[3]=a[7]=a[11]=a[12]=a[13]=a[14]=0,a[15]=1,a[0]=x.x,a[1]=x.y,a[2]=x.z,a[4]=g.x,a[5]=g.y,a[6]=g.z,a[8]=E.x,a[9]=E.y,a[10]=E.z,a[0]*s+a[1]*l+a[2]*h<0&&(o[0]=-p),a[4]*u+a[5]*c+a[6]*d<0&&(o[1]=-T),a[8]*_+a[9]*f+a[10]*m<0&&(o[2]=-S),!0},e.decomposeYawPitchRoll=function(e){var t=Math.asin(-this.elements[9]);e.y=t,Math.cos(t)>ft.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)},e.normalize=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=Math.sqrt(t*t+n*n+i*i);if(!r)return e[0]=0,e[1]=0,void(e[2]=0);1!=r&&(r=1/r,e[0]=t*r,e[1]=n*r,e[2]=i*r)},e.transpose=function(){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},e.invert=function(e){var t=this.elements,n=e.elements,i=t[0],r=t[1],a=t[2],o=t[3],s=t[4],l=t[5],h=t[6],u=t[7],c=t[8],d=t[9],_=t[10],f=t[11],m=t[12],p=t[13],T=t[14],S=t[15],E=i*l-r*s,v=i*h-a*s,g=i*u-o*s,x=r*h-a*l,M=r*u-o*l,y=a*u-o*h,D=c*p-d*m,R=c*T-_*m,C=c*S-f*m,I=d*T-_*p,A=d*S-f*p,L=_*S-f*T,O=E*L-v*A+g*I+x*C-M*R+y*D;0!==Math.abs(O)&&(O=1/O,n[0]=(l*L-h*A+u*I)*O,n[1]=(a*A-r*L-o*I)*O,n[2]=(p*y-T*M+S*x)*O,n[3]=(_*M-d*y-f*x)*O,n[4]=(h*C-s*L-u*R)*O,n[5]=(i*L-a*C+o*R)*O,n[6]=(T*g-m*y-S*v)*O,n[7]=(c*y-_*g+f*v)*O,n[8]=(s*A-l*C+u*D)*O,n[9]=(r*C-i*A-o*D)*O,n[10]=(m*M-p*g+S*E)*O,n[11]=(d*g-c*M-f*E)*O,n[12]=(l*R-s*I-h*D)*O,n[13]=(i*I-r*R+a*D)*O,n[14]=(p*v-m*x-T*E)*O,n[15]=(c*x-d*v+_*E)*O)},e.identity=function(){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},e.cloneTo=function(e){var t,n,i;if((n=this.elements)!==(i=e.elements))for(t=0;t<16;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.getTranslationVector=function(e){var t=this.elements;e.x=t[12],e.y=t[13],e.z=t[14]},e.setTranslationVector=function(e){var t=this.elements,n=e;t[12]=n.x,t[13]=n.y,t[14]=n.z},e.getForward=function(e){var t=this.elements;e.x=-t[8],e.y=-t[9],e.z=-t[10]},e.setForward=function(e){var t=this.elements;t[8]=-e.x,t[9]=-e.y,t[10]=-e.z},Matrix4x4.createRotationX=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[1]=n[2]=n[3]=n[4]=n[7]=n[8]=n[11]=n[12]=n[13]=n[14]=0,n[0]=n[15]=1,n[5]=n[10]=r,n[6]=i,n[9]=-i},Matrix4x4.createRotationY=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[1]=n[3]=n[4]=n[6]=n[7]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[5]=n[15]=1,n[0]=n[10]=r,n[2]=-i,n[8]=i},Matrix4x4.createRotationZ=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[2]=n[3]=n[6]=n[7]=n[8]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[10]=n[15]=1,n[0]=n[5]=r,n[1]=i,n[4]=-i},Matrix4x4.createRotationYawPitchRoll=function(e,t,n,i){dt.createFromYawPitchRoll(e,t,n,Matrix4x4._tempQuaternion),Matrix4x4.createRotationQuaternion(Matrix4x4._tempQuaternion,i)},Matrix4x4.createRotationAxis=function(e,t,n){var i=e.x,r=e.y,a=e.z,o=Math.cos(t),s=Math.sin(t),l=i*i,h=r*r,u=a*a,c=i*r,d=i*a,_=r*a,f=n.elements;f[3]=f[7]=f[11]=f[12]=f[13]=f[14]=0,f[15]=1,f[0]=l+o*(1-l),f[1]=c-o*c+s*a,f[2]=d-o*d-s*r,f[4]=c-o*c-s*a,f[5]=h+o*(1-h),f[6]=_-o*_+s*i,f[8]=d-o*d+s*r,f[9]=_-o*_-s*i,f[10]=u+o*(1-u)},Matrix4x4.createRotationQuaternion=function(e,t){var n=t.elements,i=e.x,r=e.y,a=e.z,o=e.w,s=i*i,l=r*r,h=a*a,u=i*r,c=a*o,d=a*i,_=r*o,f=r*a,m=i*o;n[3]=n[7]=n[11]=n[12]=n[13]=n[14]=0,n[15]=1,n[0]=1-2*(l+h),n[1]=2*(u+c),n[2]=2*(d-_),n[4]=2*(u-c),n[5]=1-2*(h+s),n[6]=2*(f+m),n[8]=2*(d+_),n[9]=2*(f-m),n[10]=1-2*(l+s)},Matrix4x4.createTranslate=function(e,t){var n=t.elements;n[4]=n[8]=n[1]=n[9]=n[2]=n[6]=n[3]=n[7]=n[11]=0,n[0]=n[5]=n[10]=n[15]=1,n[12]=e.x,n[13]=e.y,n[14]=e.z},Matrix4x4.createScaling=function(e,t){var n=t.elements;n[0]=e.x,n[5]=e.y,n[10]=e.z,n[1]=n[4]=n[8]=n[12]=n[9]=n[13]=n[2]=n[6]=n[14]=n[3]=n[7]=n[11]=0,n[15]=1},Matrix4x4.multiply=function(e,t,n){var i,r,a,o,s,l,h,u;if(r=n.elements,a=e.elements,r===(o=t.elements))for(o=new Float32Array(16),i=0;i<16;++i)o[i]=r[i];var c=o[0],d=o[1],_=o[2],f=o[3],m=o[4],p=o[5],T=o[6],S=o[7],E=o[8],v=o[9],g=o[10],x=o[11],M=o[12],y=o[13],D=o[14],R=o[15];for(i=0;i<4;i++)s=a[i],l=a[i+4],h=a[i+8],u=a[i+12],r[i]=s*c+l*d+h*_+u*f,r[i+4]=s*m+l*p+h*T+u*S,r[i+8]=s*E+l*v+h*g+u*x,r[i+12]=s*M+l*y+h*D+u*R},Matrix4x4.multiplyForNative=function(e,t,n){E.instance.matrix4x4Multiply(e.elements,t.elements,n.elements)},Matrix4x4.createFromQuaternion=function(e,t){var n=t.elements,i=e.x,r=e.y,a=e.z,o=e.w,s=i+i,l=r+r,h=a+a,u=i*s,c=r*s,d=r*l,_=a*s,f=a*l,m=a*h,p=o*s,T=o*l,S=o*h;n[0]=1-d-m,n[1]=c+S,n[2]=_-T,n[3]=0,n[4]=c-S,n[5]=1-u-m,n[6]=f+p,n[7]=0,n[8]=_+T,n[9]=f-p,n[10]=1-u-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},Matrix4x4.createAffineTransformation=function(e,t,n,i){var r=i.elements,a=t.x,o=t.y,s=t.z,l=t.w,h=a+a,u=o+o,c=s+s,d=a*h,_=a*u,f=a*c,m=o*u,p=o*c,T=s*c,S=l*h,E=l*u,v=l*c,g=n.x,x=n.y,M=n.z;r[0]=(1-(m+T))*g,r[1]=(_+v)*g,r[2]=(f-E)*g,r[3]=0,r[4]=(_-v)*x,r[5]=(1-(d+T))*x,r[6]=(p+S)*x,r[7]=0,r[8]=(f+E)*M,r[9]=(p-S)*M,r[10]=(1-(d+m))*M,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1},Matrix4x4.createLookAt=function(e,t,n,i){var r=i.elements,a=Matrix4x4._tempVector0,o=Matrix4x4._tempVector1,s=Matrix4x4._tempVector2;Rt.subtract(e,t,s),Rt.normalize(s,s),Rt.cross(n,s,a),Rt.normalize(a,a),Rt.cross(s,a,o),i.identity(),r[0]=a.x,r[4]=a.y,r[8]=a.z,r[1]=o.x,r[5]=o.y,r[9]=o.z,r[2]=s.x,r[6]=s.y,r[10]=s.z,r[12]=-Rt.dot(a,e),r[13]=-Rt.dot(o,e),r[14]=-Rt.dot(s,e)},Matrix4x4.createPerspective=function(e,t,n,i,r){var a=1/Math.tan(.5*e),o=n/(a/t),s=n/a;Matrix4x4.createPerspectiveOffCenter(-o,o,-s,s,n,i,r)},Matrix4x4.createPerspectiveOffCenter=function(e,t,n,i,r,a,o){var s=o.elements,l=a/(a-r);s[1]=s[2]=s[3]=s[4]=s[6]=s[7]=s[12]=s[13]=s[15]=0,s[0]=2*r/(t-e),s[5]=2*r/(i-n),s[8]=(e+t)/(t-e),s[9]=(i+n)/(i-n),s[10]=-l,s[11]=-1,s[14]=-r*l},Matrix4x4.createOrthoOffCenter=function(e,t,n,i,r,a,o){var s=o.elements,l=1/(a-r);s[1]=s[2]=s[3]=s[4]=s[6]=s[8]=s[7]=s[9]=s[11]=0,s[15]=1,s[0]=2/(t-e),s[5]=2/(i-n),s[10]=-l,s[12]=(e+t)/(e-t),s[13]=(i+n)/(n-i),s[14]=-r*l},Matrix4x4.billboard=function(e,t,n,i,r,a){Rt.subtract(e,t,Matrix4x4._tempVector0);var o=Rt.scalarLengthSquared(Matrix4x4._tempVector0);ft.isZero(o)?(Rt.scale(r,-1,Matrix4x4._tempVector1),Matrix4x4._tempVector1.cloneTo(Matrix4x4._tempVector0)):Rt.scale(Matrix4x4._tempVector0,1/Math.sqrt(o),Matrix4x4._tempVector0),Rt.cross(i,Matrix4x4._tempVector0,Matrix4x4._tempVector2),Rt.normalize(Matrix4x4._tempVector2,Matrix4x4._tempVector2),Rt.cross(Matrix4x4._tempVector0,Matrix4x4._tempVector2,Matrix4x4._tempVector3);var s=Matrix4x4._tempVector2,l=Matrix4x4._tempVector3,h=Matrix4x4._tempVector0,u=e,c=a.elements;c[0]=s.x,c[1]=s.y,c[2]=s.z,c[3]=0,c[4]=l.x,c[5]=l.y,c[6]=l.z,c[7]=0,c[8]=h.x,c[9]=h.y,c[10]=h.z,c[11]=0,c[12]=u.x,c[13]=u.y,c[14]=u.z,c[15]=1},Matrix4x4.translation=function(e,t){var n=t.elements;n[0]=n[5]=n[10]=n[15]=1,n[12]=e.x,n[13]=e.y,n[14]=e.z},i(Matrix4x4,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new Matrix4x4},"_tempVector0",function(){return this._tempVector0=new Rt},"_tempVector1",function(){return this._tempVector1=new Rt},"_tempVector2",function(){return this._tempVector2=new Rt},"_tempVector3",function(){return this._tempVector3=new Rt},"_tempQuaternion",function(){return this._tempQuaternion=new dt},"DEFAULT",function(){return this.DEFAULT=new Matrix4x4},"ZERO",function(){return this.ZERO=new Matrix4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}]),Matrix4x4}(),j=function(){function DynamicBatchManager(){this._batchRenderElementPool=[]}r(DynamicBatchManager,"laya.d3.graphics.DynamicBatchManager");var e=DynamicBatchManager.prototype;return e._clear=function(){this._batchRenderElementPoolIndex=0},e._getBatchRenderElementFromPool=function(){throw"StaticBatch:must override this function."},e.dispose=function(){},DynamicBatchManager._registerManager=function(e){DynamicBatchManager._managers.push(e)},DynamicBatchManager._managers=[],DynamicBatchManager}(),q=function(){function Collision(){this._lastUpdateFrame=-2147483648,this._updateFrame=-2147483648,this._isTrigger=!1,this.contacts=[]}return r(Collision,"laya.d3.physics.Collision"),Collision.prototype._setUpdateFrame=function(e){this._lastUpdateFrame=this._updateFrame,this._updateFrame=e},Collision}(),J=function(){function ColliderShape(){this._attatched=!1,this._indexInCompound=-1,this._compoundParent=null,this._attatchedCollisionObject=null,this._referenceCount=0,this.needsCustomCollisionCallback=!1,this._scale=new Rt(1,1,1),this._centerMatrix=new Q,this._localOffset=new Rt(0,0,0),this._localRotation=new dt(0,0,0,1)}r(ColliderShape,"laya.d3.physics.shape.ColliderShape");var e=ColliderShape.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e._setScale=function(e){this._compoundParent?this.updateLocalTransformations():(ColliderShape._nativeScale.setValue(e.x,e.y,e.z),this._nativeShape.setLocalScaling(ColliderShape._nativeScale))},e._addReference=function(){this._referenceCount++},e._removeReference=function(){this._referenceCount--},e.updateLocalTransformations=function(){if(this._compoundParent){var e=ColliderShape._tempVector30;Rt.multiply(this.localOffset,this._scale,e),ColliderShape._createAffineTransformation(e,this.localRotation,this._centerMatrix.elements)}else ColliderShape._createAffineTransformation(this.localOffset,this.localRotation,this._centerMatrix.elements)},e.cloneTo=function(e){var t=e;this._localOffset.cloneTo(t.localOffset),this._localRotation.cloneTo(t.localRotation),t.localOffset=t.localOffset,t.localRotation=t.localRotation},e.clone=function(){return null},e.destroy=function(){this._nativeShape&&(wt._physics3D.destroy(this._nativeShape),this._nativeShape=null)},a(0,e,"type",function(){return this._type}),a(0,e,"localOffset",function(){return this._localOffset},function(e){this._localOffset=e,this._compoundParent&&this._compoundParent._updateChildTransform(this)}),a(0,e,"localRotation",function(){return this._localRotation},function(e){this._localRotation=e,this._compoundParent&&this._compoundParent._updateChildTransform(this)}),ColliderShape._creatShape=function(e){var t;switch(e.type){case"BoxColliderShape":var n=e.size;t=n?new fn(n[0],n[1],n[2]):new fn;break;case"SphereColliderShape":t=new en(e.radius);break;case"CapsuleColliderShape":t=new Mn(e.radius,e.height,e.orientation);break;case"MeshColliderShape":var i=new _n;e.mesh&&(i.mesh=g.getRes(e.mesh)),t=i;break;case"ConeColliderShape":t=new gn(e.radius,e.height,e.orientation);break;case"CylinderColliderShape":t=new Ln(e.radius,e.height,e.orientation);break;default:throw"unknown shape type."}if(e.center){var r=t.localOffset;r.fromArray(e.center),t.localOffset=r}return t},ColliderShape._createAffineTransformation=function(e,t,n){var i=t.x,r=t.y,a=t.z,o=t.w,s=i+i,l=r+r,h=a+a,u=i*s,c=i*l,d=i*h,_=r*l,f=r*h,m=a*h,p=o*s,T=o*l,S=o*h;n[0]=1-(_+m),n[1]=c+S,n[2]=d-T,n[3]=0,n[4]=c-S,n[5]=1-(u+m),n[6]=f+p,n[7]=0,n[8]=d+T,n[9]=f-p,n[10]=1-(u+_),n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1},ColliderShape.SHAPEORIENTATION_UPX=0,ColliderShape.SHAPEORIENTATION_UPY=1,ColliderShape.SHAPEORIENTATION_UPZ=2,ColliderShape.SHAPETYPES_BOX=0,ColliderShape.SHAPETYPES_SPHERE=1,ColliderShape.SHAPETYPES_CYLINDER=2,ColliderShape.SHAPETYPES_CAPSULE=3,ColliderShape.SHAPETYPES_CONVEXHULL=4,ColliderShape.SHAPETYPES_COMPOUND=5,ColliderShape.SHAPETYPES_STATICPLANE=6,ColliderShape.SHAPETYPES_CONE=7,i(ColliderShape,["_tempVector30",function(){return this._tempVector30=new Rt},"_nativeScale",function(){return this._nativeScale=new wt._physics3D.btVector3(1,1,1)},"_nativeVector30",function(){return this._nativeVector30=new wt._physics3D.btVector3(0,0,0)},"_nativQuaternion0",function(){return this._nativQuaternion0=new wt._physics3D.btQuaternion(0,0,0,1)},"_nativeTransform0",function(){return this._nativeTransform0=new wt._physics3D.btTransform}]),ColliderShape}(),$=function(){function GradientDataInt(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}r(GradientDataInt,"laya.d3.core.particleShuriKen.module.GradientDataInt");var e=GradientDataInt.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.add=function(e,t){this._currentLength<8?(6===this._currentLength&&1!==e&&(e=1,console.log("Warning:the forth key is be force set to 1.")),this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t):console.log("Warning:data count must lessEqual than 4")},e.cloneTo=function(e){var t=e;t._currentLength=this._currentLength;var n=t._elements;n.length=this._elements.length;for(var i=0,r=this._elements.length;i0;)n--;if(t1){var i=this._partition(e,t,n),r=i-1;t0){for(var i=0;i0&&(V.params=P=[]),n=0;n0&&(V.params=P=[]),n=0;n=0?e.substr(t):null},Utils3D._createAffineTransformationArray=function(e,t,n,i){var r=t.x,a=t.y,o=t.z,s=t.w,l=r+r,h=a+a,u=o+o,c=r*l,d=r*h,_=r*u,f=a*h,m=a*u,p=o*u,T=s*l,S=s*h,E=s*u,v=n.x,g=n.y,x=n.z;i[0]=(1-(f+p))*v,i[1]=(d+E)*v,i[2]=(_-S)*v,i[3]=0,i[4]=(d-E)*g,i[5]=(1-(c+p))*g,i[6]=(m+T)*g,i[7]=0,i[8]=(_+S)*x,i[9]=(m-T)*x,i[10]=(1-(c+f))*x,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1},Utils3D._mulMatrixArray=function(e,t,n,i){var r,a,o,s,l,h=t.elements,u=h[0],c=h[1],d=h[2],_=h[3],f=h[4],m=h[5],p=h[6],T=h[7],S=h[8],E=h[9],v=h[10],g=h[11],x=h[12],M=h[13],y=h[14],D=h[15],R=i,C=i+4,I=i+8,A=i+12;for(r=0;r<4;r++)a=e[r],o=e[r+4],s=e[r+8],l=e[r+12],n[R+r]=a*u+o*c+s*d+l*_,n[C+r]=a*f+o*m+s*p+l*T,n[I+r]=a*S+o*E+s*v+l*g,n[A+r]=a*x+o*M+s*y+l*D},Utils3D.arcTanAngle=function(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},Utils3D.angleTo=function(e,t,n){Rt.subtract(t,e,dt.TEMPVector30),Rt.normalize(dt.TEMPVector30,dt.TEMPVector30),n.x=Math.asin(dt.TEMPVector30.y),n.y=Utils3D.arcTanAngle(-dt.TEMPVector30.z,-dt.TEMPVector30.x)},Utils3D.transformQuat=function(e,t,n){var i=t,r=e.x,a=e.y,o=e.z,s=i[0],l=i[1],h=i[2],u=i[3],c=u*r+l*o-h*a,d=u*a+h*r-s*o,_=u*o+s*a-l*r,f=-s*r-l*a-h*o;n.x=c*u+f*-s+d*-h-_*-l,n.y=d*u+f*-l+_*-s-c*-h,n.z=_*u+f*-h+c*-l-d*-s},Utils3D.quaternionWeight=function(e,t,n){n.x=e.x*t,n.y=e.y*t,n.z=e.z*t,n.w=e.w},Utils3D.quaternionConjugate=function(e,t){t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w},Utils3D.scaleWeight=function(e,t,n){var i=e.x,r=e.y,a=e.z;n.x=i>0?Math.pow(Math.abs(i),t):-Math.pow(Math.abs(i),t),n.y=r>0?Math.pow(Math.abs(r),t):-Math.pow(Math.abs(r),t),n.z=a>0?Math.pow(Math.abs(a),t):-Math.pow(Math.abs(a),t)},Utils3D.scaleBlend=function(e,t,n,i){var r=Utils3D._tempVector3_0,a=Utils3D._tempVector3_1;Utils3D.scaleWeight(e,1-n,r),Utils3D.scaleWeight(t,n,a);var o=n>.5?t:e;i.x=o.x>0?Math.abs(r.x*a.x):-Math.abs(r.x*a.x),i.y=o.y>0?Math.abs(r.y*a.y):-Math.abs(r.y*a.y),i.z=o.z>0?Math.abs(r.z*a.z):-Math.abs(r.z*a.z)},Utils3D.gammaToLinearSpace=function(e){return e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},Utils3D.linearToGammaSpace=function(e){return e<=0?0:e<=.0031308?12.92*e:e<=1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},Utils3D.matrix4x4MultiplyFFF=function(e,t,n){var i,r,a,o,s;if(n===t)for(t=new Float32Array(16),i=0;i<16;++i)t[i]=n[i];var l=t[0],h=t[1],u=t[2],c=t[3],d=t[4],_=t[5],f=t[6],m=t[7],p=t[8],T=t[9],S=t[10],E=t[11],v=t[12],g=t[13],x=t[14],M=t[15];for(i=0;i<4;i++)r=e[i],a=e[i+4],o=e[i+8],s=e[i+12],n[i]=r*l+a*h+o*u+s*c,n[i+4]=r*d+a*_+o*f+s*m,n[i+8]=r*p+a*T+o*S+s*E,n[i+12]=r*v+a*g+o*x+s*M},Utils3D.matrix4x4MultiplyFFFForNative=function(e,t,n){E.instance.matrix4x4Multiply(e,t,n)},Utils3D.matrix4x4MultiplyMFM=function(e,t,n){Utils3D.matrix4x4MultiplyFFF(e.elements,t,n.elements)},Utils3D._buildTexture2D=function(e,t,n,i,r){void 0===r&&(r=!1);var a=new B(e,t,n,r,!0);return a.anisoLevel=1,a.filterMode=0,ht._generateTexture2D(a,e,t,i),a},Utils3D._drawBound=function(e,t,n){e.lineCount+12>e.maxLineCount&&(e.maxLineCount+=12);var i=Utils3D._tempVector3_0,r=Utils3D._tempVector3_1,a=t.min,o=t.max;i.setValue(a.x,a.y,a.z),r.setValue(o.x,a.y,a.z),e.addLine(i,r,n,n),i.setValue(a.x,a.y,a.z),r.setValue(a.x,a.y,o.z),e.addLine(i,r,n,n),i.setValue(o.x,a.y,a.z),r.setValue(o.x,a.y,o.z),e.addLine(i,r,n,n),i.setValue(a.x,a.y,o.z),r.setValue(o.x,a.y,o.z),e.addLine(i,r,n,n),i.setValue(a.x,a.y,a.z),r.setValue(a.x,o.y,a.z),e.addLine(i,r,n,n),i.setValue(a.x,a.y,o.z),r.setValue(a.x,o.y,o.z),e.addLine(i,r,n,n),i.setValue(o.x,a.y,a.z),r.setValue(o.x,o.y,a.z),e.addLine(i,r,n,n),i.setValue(o.x,a.y,o.z),r.setValue(o.x,o.y,o.z),e.addLine(i,r,n,n),i.setValue(a.x,o.y,a.z),r.setValue(o.x,o.y,a.z),e.addLine(i,r,n,n),i.setValue(a.x,o.y,a.z),r.setValue(a.x,o.y,o.z),e.addLine(i,r,n,n),i.setValue(o.x,o.y,a.z),r.setValue(o.x,o.y,o.z),e.addLine(i,r,n,n),i.setValue(a.x,o.y,o.z),r.setValue(o.x,o.y,o.z),e.addLine(i,r,n,n)},Utils3D._getHierarchyPath=function(e,t,n){n.length=0;for(var i=t;i!==e;){var r=i._parent;if(!r)return null;n.push(r.getChildIndex(i)),i=r}return n},Utils3D._getNodeByHierarchyPath=function(e,t){for(var n=e,i=t.length-1;i>=0;i--)n=n.getChildAt(t[i]);return n},Utils3D._createNodeByJson=function(e,t){var n;switch(e.type){case"Scene3D":n=new qn;break;case"Sprite3D":n=new bn;break;case"MeshSprite3D":n=new Ei,t&&t.push(n);break;case"SkinnedMeshSprite3D":n=new Mi;break;case"ShuriKenParticle3D":n=new Ri;break;case"Terrain":n=new hi;break;case"Camera":n=new Ci;break;case"DirectionLight":n=new Di;break;case"PointLight":n=new xi;break;case"SpotLight":n=new vi;break;case"TrailSprite3D":n=new gi;break;default:throw new Error("Utils3D:unidentified class type in (.lh) file.")}var i=e.child;if(i)for(var r=0,a=i.length;r>-t-14,HalfFloatUtils._baseTable[256|e]=1024>>-t-14|32768,HalfFloatUtils._shiftTable[0|e]=-t-1,HalfFloatUtils._shiftTable[256|e]=-t-1):t<=15?(HalfFloatUtils._baseTable[0|e]=t+15<<10,HalfFloatUtils._baseTable[256|e]=t+15<<10|32768,HalfFloatUtils._shiftTable[0|e]=13,HalfFloatUtils._shiftTable[256|e]=13):t<128?(HalfFloatUtils._baseTable[0|e]=31744,HalfFloatUtils._baseTable[256|e]=64512,HalfFloatUtils._shiftTable[0|e]=24,HalfFloatUtils._shiftTable[256|e]=24):(HalfFloatUtils._baseTable[0|e]=31744,HalfFloatUtils._baseTable[256|e]=64512,HalfFloatUtils._shiftTable[0|e]=13,HalfFloatUtils._shiftTable[256|e]=13)}for(HalfFloatUtils._mantissaTable[0]=0,e=1;e<1024;++e){var n=e<<13;for(t=0;0==(8388608&n);)t-=8388608,n<<=1;n&=-8388609,t+=947912704,HalfFloatUtils._mantissaTable[e]=n|t}for(e=1024;e<2048;++e)HalfFloatUtils._mantissaTable[e]=939524096+(e-1024<<13);for(HalfFloatUtils._exponentTable[0]=0,e=1;e<31;++e)HalfFloatUtils._exponentTable[e]=e<<23;for(HalfFloatUtils._exponentTable[31]=1199570944,HalfFloatUtils._exponentTable[32]=2147483648,e=33;e<63;++e)HalfFloatUtils._exponentTable[e]=2147483648+(e-32<<23);for(HalfFloatUtils._exponentTable[63]=3347054592,HalfFloatUtils._offsetTable[0]=0,e=1;e<64;++e)HalfFloatUtils._offsetTable[e]=32===e?0:1024},HalfFloatUtils.roundToFloat16Bits=function(e){HalfFloatUtils._floatView[0]=e;var t=HalfFloatUtils._uint32View[0],n=t>>23&511;return HalfFloatUtils._baseTable[n]+((8388607&t)>>HalfFloatUtils._shiftTable[n])},HalfFloatUtils.convertToNumber=function(e){var t=e>>10;return HalfFloatUtils._uint32View[0]=HalfFloatUtils._mantissaTable[HalfFloatUtils._offsetTable[t]+(1023&e)]+HalfFloatUtils._exponentTable[t],HalfFloatUtils._floatView[0]},i(HalfFloatUtils,["_buffer",function(){return this._buffer=new ArrayBuffer(4)},"_floatView",function(){return this._floatView=new Float32Array(HalfFloatUtils._buffer)},"_uint32View",function(){return this._uint32View=new Uint32Array(HalfFloatUtils._buffer)},"_baseTable",function(){return this._baseTable=new Uint32Array(512)},"_shiftTable",function(){return this._shiftTable=new Uint32Array(512)},"_mantissaTable",function(){return this._mantissaTable=new Uint32Array(2048)},"_exponentTable",function(){return this._exponentTable=new Uint32Array(64)},"_offsetTable",function(){return this._offsetTable=new Uint32Array(64)}]),HalfFloatUtils}(),ge=(function(){function SceneManager(){}r(SceneManager,"laya.d3.core.scene.SceneManager")}(),function(){function ShaderDefines(e){if(this._counter=0,this.defines={},e)for(var t in this._counter=e._counter,e.defines)this.defines[t]=e.defines[t]}return r(ShaderDefines,"laya.d3.shader.ShaderDefines"),ShaderDefines.prototype.registerDefine=function(e){var t=Math.pow(2,this._counter++);return this.defines[t]=e,t},ShaderDefines}()),xe=function(){function PhysicsSimulation(e,t){this._nativeDiscreteDynamicsWorld=null,this._nativeCollisionWorld=null,this._nativeDispatcher=null,this._nativeCollisionConfiguration=null,this._nativeBroadphase=null,this._nativeSolverInfo=null,this._nativeDispatchInfo=null,this._nativeClosestRayResultCallback=null,this._nativeAllHitsRayResultCallback=null,this._nativeClosestConvexResultCallback=null,this._nativeAllConvexResultCallback=null,this._updatedRigidbodies=0,this.maxSubSteps=1,this.fixedTimeStep=1/60,this._gravity=new Rt(0,-10,0),this._nativeVector3Zero=new wt._physics3D.btVector3(0,0,0),this._nativeDefaultQuaternion=new wt._physics3D.btQuaternion(0,0,0,-1),this._collisionsUtils=new Te,this._previousFrameCollisions=[],this._currentFrameCollisions=[],this._physicsUpdateList=new pn,this._characters=[],void 0===t&&(t=0),this.maxSubSteps=e.maxSubSteps,this.fixedTimeStep=e.fixedTimeStep;var n=wt._physics3D;this._nativeCollisionConfiguration=new n.btDefaultCollisionConfiguration,this._nativeDispatcher=new n.btCollisionDispatcher(this._nativeCollisionConfiguration),this._nativeBroadphase=new n.btDbvtBroadphase,this._nativeBroadphase.getOverlappingPairCache().setInternalGhostPairCallback(new n.btGhostPairCallback);var i=e.flags;if(1&i)this._nativeCollisionWorld=new n.btCollisionWorld(this._nativeDispatcher,this._nativeBroadphase,this._nativeCollisionConfiguration);else{if(2&i)throw"PhysicsSimulation:SoftBody processing is not yet available";var r=new n.btSequentialImpulseConstraintSolver;this._nativeDiscreteDynamicsWorld=new n.btDiscreteDynamicsWorld(this._nativeDispatcher,this._nativeBroadphase,r,this._nativeCollisionConfiguration),this._nativeCollisionWorld=this._nativeDiscreteDynamicsWorld}this._nativeDiscreteDynamicsWorld&&(this._nativeSolverInfo=this._nativeDiscreteDynamicsWorld.getSolverInfo(),this._nativeDispatchInfo=this._nativeDiscreteDynamicsWorld.getDispatchInfo()),this._nativeClosestRayResultCallback=new n.ClosestRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeAllHitsRayResultCallback=new n.AllHitsRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeClosestConvexResultCallback=new n.ClosestConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeAllConvexResultCallback=new n.AllConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),n._btGImpactCollisionAlgorithm_RegisterAlgorithm(this._nativeDispatcher.a)}r(PhysicsSimulation,"laya.d3.physics.PhysicsSimulation");var e=PhysicsSimulation.prototype;return e._simulate=function(e){this._updatedRigidbodies=0,this._nativeDiscreteDynamicsWorld?this._nativeDiscreteDynamicsWorld.stepSimulation(e,this.maxSubSteps,this.fixedTimeStep):this._nativeCollisionWorld.PerformDiscreteCollisionDetection()},e._destroy=function(){var e=wt._physics3D;this._nativeDiscreteDynamicsWorld?(e.destroy(this._nativeDiscreteDynamicsWorld),this._nativeDiscreteDynamicsWorld=null):(e.destroy(this._nativeCollisionWorld),this._nativeCollisionWorld=null),e.destroy(this._nativeBroadphase),this._nativeBroadphase=null,e.destroy(this._nativeDispatcher),this._nativeDispatcher=null,e.destroy(this._nativeCollisionConfiguration),this._nativeCollisionConfiguration=null},e._addPhysicsCollider=function(e,t,n){this._nativeCollisionWorld.addCollisionObject(e._nativeColliderObject,t,n)},e._removePhysicsCollider=function(e){this._nativeCollisionWorld.removeCollisionObject(e._nativeColliderObject)},e._addRigidBody=function(e,t,n){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.addRigidBody(e._nativeColliderObject,t,n)},e._removeRigidBody=function(e){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.removeRigidBody(e._nativeColliderObject)},e._addCharacter=function(e,t,n){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.addCollisionObject(e._nativeColliderObject,t,n),this._nativeCollisionWorld.addAction(e._nativeKinematicCharacter)},e._removeCharacter=function(e){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.removeCollisionObject(e._nativeColliderObject),this._nativeCollisionWorld.removeAction(e._nativeKinematicCharacter)},e.raycastFromTo=function(e,t,n,i,r){void 0===i&&(i=kt.COLLISIONFILTERGROUP_ALLFILTER),void 0===r&&(r=kt.COLLISIONFILTERGROUP_ALLFILTER);var a=this._nativeClosestRayResultCallback,o=PhysicsSimulation._nativeTempVector30,s=PhysicsSimulation._nativeTempVector31;if(o.setValue(-e.x,e.y,e.z),s.setValue(-t.x,t.y,t.z),a.set_m_rayFromWorld(o),a.set_m_rayToWorld(s),a.set_m_collisionFilterGroup(i),a.set_m_collisionFilterMask(r),a.set_m_collisionObject(null),a.set_m_closestHitFraction(1),this._nativeCollisionWorld.rayTest(o,s,a),a.hasHit()){if(n){n.succeeded=!0,n.collider=Kt._physicObjectsMap[a.get_m_collisionObject().getUserIndex()],n.hitFraction=a.get_m_closestHitFraction();var l=a.get_m_hitPointWorld(),h=n.point;h.x=-l.x(),h.y=l.y(),h.z=l.z();var u=a.get_m_hitNormalWorld(),c=n.normal;c.x=-u.x(),c.y=u.y(),c.z=u.z()}return!0}return n&&(n.succeeded=!1),!1},e.raycastAllFromTo=function(e,t,n,i,r){void 0===i&&(i=kt.COLLISIONFILTERGROUP_ALLFILTER),void 0===r&&(r=kt.COLLISIONFILTERGROUP_ALLFILTER);var a=this._nativeAllHitsRayResultCallback,o=PhysicsSimulation._nativeTempVector30,s=PhysicsSimulation._nativeTempVector31;n.length=0,o.setValue(-e.x,e.y,e.z),s.setValue(-t.x,t.y,t.z),a.set_m_rayFromWorld(o),a.set_m_rayToWorld(s),a.set_m_collisionFilterGroup(i),a.set_m_collisionFilterMask(r);var l=a.get_m_collisionObjects(),h=a.get_m_hitPointWorld(),u=a.get_m_hitNormalWorld(),c=a.get_m_hitFractions();l.clear(),h.clear(),u.clear(),c.clear(),this._nativeCollisionWorld.rayTest(o,s,a);var d=l.size();if(d>0){this._collisionsUtils.recoverAllHitResultsPool();for(var _=0;_0){for(var E=h.get_m_hitPointWorld(),v=h.get_m_hitNormalWorld(),g=h.get_m_hitFractions(),x=0;x light.Range )\n\t//\treturn;\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec/length(lightVec),diffuseColor,specularColor);\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.Range);\n\tdiffuseColor *= attenuate;\n\tspecularColor*= attenuate;\n}\n\nvoid LayaAirBlinnPhongSpotLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in SpotLight light,out vec3 diffuseColor,out vec3 specularColor) {\n\tvec3 lightVec = pos-light.Position;\n\t//if( length(lightVec) > light.Range)\n\t//\treturn;\n\n\tvec3 normalLightVec=lightVec/length(lightVec);\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,normalLightVec,diffuseColor,specularColor);\n\tvec2 cosAngles=cos(vec2(light.Spot,light.Spot*0.5)*0.5);//ConeAttenuation\n\tfloat dl=dot(normalize(light.Direction),normalLightVec);\n\tdl*=smoothstep(cosAngles[0],cosAngles[1],dl);\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.Range)*dl;\n\tdiffuseColor *=attenuate;\n\tspecularColor *=attenuate;\n}\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent,vec3 binormal) {\n\tvec3 normalT =vec3(2.0*normalMapSample.x - 1.0,1.0-2.0*normalMapSample.y,2.0*normalMapSample.z - 1.0);\n\n\t// Build orthonormal basis.\n\tvec3 N = normalize(unitNormal);\n\tvec3 T = normalize(tangent);\n\tvec3 B = normalize(binormal);\n\tmat3 TBN = mat3(T, B, N);\n\n\t// Transform from tangent space to world space.\n\tvec3 bumpedNormal = TBN*normalT;\n\n\treturn bumpedNormal;\n}\n\nvec3 NormalSampleToWorldSpace1(vec4 normalMapSample, vec3 tangent, vec3 binormal, vec3 unitNormal) {\n\tvec3 normalT;\n\tnormalT.x = 2.0 * normalMapSample.x - 1.0;\n\tnormalT.y = 1.0 - 2.0 * normalMapSample.y;\n\tnormalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\n\n\tvec3 T = normalize(tangent);\n\tvec3 B = normalize(binormal);\n\tvec3 N = normalize(unitNormal);\n\tmat3 TBN = mat3(T, B, N);\n\n\t// Transform from tangent space to world space.\n\tvec3 bumpedNormal = TBN * normalize(normalT);\n\n\treturn bumpedNormal;\n}\n\nvec3 DecodeLightmap(vec4 color) {\n\treturn color.rgb*color.a*5.0;\n}\n\nvec2 TransformUV(vec2 texcoord,vec4 tilingOffset) {\n\tvec2 transTexcoord=vec2(texcoord.x,texcoord.y-1.0)*tilingOffset.xy+vec2(tilingOffset.z,-tilingOffset.w);\n\ttransTexcoord.y+=1.0;\n\treturn transTexcoord;\n}\n\nvec4 remapGLPositionZ(vec4 position) {\n\tposition.z=position.z * 2.0 - position.w;\n\treturn position;\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\n"),At.addInclude("ShadowHelper.glsl","uniform sampler2D u_shadowMap1;\nuniform sampler2D u_shadowMap2;\nuniform sampler2D u_shadowMap3;\nuniform vec2\t u_shadowPCFoffset;\nuniform vec4 u_shadowPSSMDistance;\nvec4 packDepth(const in float depth)\n{\n\tconst vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n\tconst vec4 bitMask\t= vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n\tvec4 res = mod(depth*bitShift*vec4(255), vec4(256))/vec4(255);\n\tres -= res.xxyz * bitMask;\n\treturn res;\n}\nfloat unpackDepth(const in vec4 rgbaDepth)\n{\n\tconst vec4 bitShift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n\tfloat depth = dot(rgbaDepth, bitShift);\n\treturn depth;\n}\nfloat tex2DPCF( sampler2D shadowMap,vec2 texcoord,vec2 invsize,float zRef )\n{\n\tvec2 texelpos =texcoord / invsize;\n\tvec2 lerps = fract( texelpos );\n\tfloat sourcevals[4];\n\tsourcevals[0] = float( unpackDepth(texture2D(shadowMap,texcoord)) > zRef );\n\tsourcevals[1] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x,0))) > zRef );\n\tsourcevals[2] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(0,invsize.y))) > zRef );\n\tsourcevals[3] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x, invsize.y) )) > zRef );\n\treturn mix( mix(sourcevals[0],sourcevals[2],lerps.y),mix(sourcevals[1],sourcevals[3],lerps.y),lerps.x );\n}\nfloat getShadowPSSM3( sampler2D shadowMap1,sampler2D shadowMap2,sampler2D shadowMap3,mat4 lightShadowVP[4],vec4 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tint nPSNum = int(posViewZ>pssmDistance.x);\n\tnPSNum += int(posViewZ>pssmDistance.y);\n\tnPSNum += int(posViewZ>pssmDistance.z);\n\t//真SB,webgl不支持在PS中直接访问数组\n\tmat4 lightVP;\n\tif( nPSNum == 0 )\n\t{\n\t\tlightVP = lightShadowVP[1];\n\t}\n\telse if( nPSNum == 1 )\n\t{\n\t\tlightVP = lightShadowVP[2];\n\t}\n\telse if( nPSNum == 2 )\n\t{\n\t\tlightVP = lightShadowVP[3];\n\t}\n\tvec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n\t//为了效率,在CPU计算/2.0 + 0.5\n\t//vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n\tvec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n\tfloat fMyZ = vText.z - zBias;\n\t/*\n\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\tbool bInFrustum = all( bInFrustumVec );\n\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\tbool bFrustumTest = all( bFrustumTestVec );\n\tif ( bFrustumTest ) \n\t*/\n\tif( fMyZ <= 1.0 )\n\t{\n\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue = value/4.0;\n\t\t} \n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF2\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap2,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF_NO\n\t\tvec4 color;\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap1,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap2,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap3,vText.xy );\n\t\t}\n\t\tzdepth = unpackDepth(color);\n\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t}\n\treturn value;\n}\nfloat getShadowPSSM2( sampler2D shadowMap1,sampler2D shadowMap2,mat4 lightShadowVP[4],vec4 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tint nPSNum = int(posViewZ>pssmDistance.x);\n\tnPSNum += int(posViewZ>pssmDistance.y);\n\t//真SB,webgl不支持在PS中直接访问数组\n\tmat4 lightVP;\n\tif( nPSNum == 0 )\n\t{\n\t\tlightVP = lightShadowVP[1];\n\t}\n\telse if( nPSNum == 1 )\n\t{\n\t\tlightVP = lightShadowVP[2];\n\t}\n\tvec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n\t//为了效率,在CPU计算/2.0 + 0.5\n\t//vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n\tvec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n\tfloat fMyZ = vText.z - zBias;\n\t/*\n\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\tbool bInFrustum = all( bInFrustumVec );\n\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\tbool bFrustumTest = all( bFrustumTestVec );\n\tif ( bFrustumTest ) \n\t*/\n\tif( fMyZ <= 1.0 )\n\t{\n\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue = value/4.0;\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF2\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap2,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF_NO\n\t\tvec4 color;\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap1,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap2,vText.xy );\n\t\t}\n\t\tzdepth = unpackDepth(color);\n\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t}\n\treturn value;\n}\nfloat getShadowPSSM1( sampler2D shadowMap1,vec4 lightMVPPos,vec4 pssmDistance,vec2 shadowPCFOffset,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tif( posViewZ < pssmDistance.x )\n\t{\n\t\tvec3 vText = lightMVPPos.xyz / lightMVPPos.w;\n\t\tfloat fMyZ = vText.z - zBias;\n\t\t/*\n\t\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\t\tbool bInFrustum = all( bInFrustumVec );\n\t\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\t\tbool bFrustumTest = all( bFrustumTestVec );\n\t\t*/\n\t\tif ( fMyZ <= 1.0 ) \n\t\t{\n\t\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\t\tvalue = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,fMyZ );\n\t\t\tvalue = value/4.0;\n#endif\n#ifdef SHADOWMAP_PCF2\t\t\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF_NO\t\t\n\t\t\tvec4 color = texture2D( shadowMap1,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t\t}\n\t}\n\treturn value;\n}"),At.addInclude("BRDF.glsl","struct LayaGI\n{\n\tvec3 diffuse;\n\tvec3 specular;\n};\n\nvec4 LayaAirBRDF(in vec3 diffuseColor, in vec3 specularColor, in float oneMinusReflectivity, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in LayaGI gi)\n{\n\tfloat perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);\n\tvec3 halfDir = SafeNormalize(viewDir - lightDir);\n\t\n\tfloat nv = abs(dot(normal, viewDir));\n\t\n\tfloat nl = clamp(dot(normal, -lightDir), 0.0, 1.0);\n\tfloat nh = clamp(dot(normal, halfDir), 0.0, 1.0);\n\tfloat lv = clamp(dot(lightDir, viewDir), 0.0, 1.0);\n\tfloat lh = clamp(dot(lightDir, -halfDir), 0.0, 1.0);\n\t\n\tfloat diffuseTerm = DisneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;\n\t\n\tfloat roughness = PerceptualRoughnessToRoughness(perceptualRoughness);\n\t\n\t//#if UNITY_BRDF_GGX\n\tfloat V = SmithJointGGXVisibilityTerm(nl, nv, roughness);\n\tfloat D = GGXTerm(nh, roughness);\n\t\n\tfloat specularTerm = V * D * PI;\n\t\n\tspecularTerm = sqrt(max(0.0001, specularTerm));\n\tspecularTerm = max(0.0, specularTerm * nl);\n\t\n\tfloat surfaceReduction = 1.0 - 0.28 * roughness * perceptualRoughness;\n\tfloat grazingTerm = clamp(smoothness + (1.0 - oneMinusReflectivity), 0.0, 1.0);\n\t\n\tvec4 color;\n\tcolor.rgb = diffuseColor * (gi.diffuse + lightColor * diffuseTerm) \n\t\t\t + specularTerm * lightColor * FresnelTerm (specularColor, lh)\n\t\t\t + surfaceReduction * gi.specular * FresnelLerp(specularColor, vec3(grazingTerm), nv);\n\t\n\treturn color;\n}"),At.addInclude("PBRUtils.glsl","struct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\n\nstruct PointLight\n{\n\tvec3 Color;\n\tvec3 Position;\n\tfloat Range;\n};\n\nstruct SpotLight\n{\n\tvec3 Color;\n\tvec3 Position;\n\tvec3 Direction;\n\tfloat SpotAngle;\n\tfloat Range;\n};\n\nvec3 UnpackScaleNormal(in vec2 uv0)\n{\n\t#ifdef NORMALTEXTURE\n\t\tvec3 normalT;\n\t\tvec4 normalMapSample = texture2D(u_NormalTexture, uv0);\n\t\tnormalT.x = 2.0 * normalMapSample.x - 1.0;\n\t\tnormalT.y = 1.0 - 2.0 * normalMapSample.y;\n\t\tnormalT.xy *= u_normalScale;\n\t\tnormalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\n\t\t\n\t\tvec3 T = normalize(v_Tangent);\n\t\tvec3 B = normalize(v_Binormal);\n\t\tvec3 N = normalize(v_Normal);\n\t\tmat3 TBN = mat3(T, B, N);\n\t\t\n\t\tvec3 bumpedNormal = TBN * normalize(normalT);\n\t\treturn bumpedNormal;\n\t#else\n\t\treturn normalize(v_Normal);\n\t#endif\n}\n\nvec4 DielectricSpecularColor = vec4(0.220916301, 0.220916301, 0.220916301, 1.0 - 0.220916301);\n\nfloat PI = 3.14159265359;\n\nvec3 FresnelTerm (in vec3 F0, in float cosA)\n{\n\treturn F0 + (vec3(1.0) - F0) * pow(1.0 - cosA, 5.0);\n}\n\nvec3 FresnelLerp (in vec3 F0, in vec3 F90, float cosA)\n{\n float t = pow(1.0 - cosA, 5.0);\n return mix(F0, F90, t);\n}\n\nfloat PerceptualRoughnessToRoughness(in float perceptualRoughness)\n{\n\treturn perceptualRoughness * perceptualRoughness;\n}\n\nfloat PerceptualRoughnessToSpecularPower(in float perceptualRoughness)\n{\n\tfloat m = PerceptualRoughnessToRoughness(perceptualRoughness);\n\tfloat sq = max(0.0001, m * m);\n\tfloat n = (2.0 / sq) - 2.0;\n\tn = max(n, 0.0001);\n\treturn n;\n}\n\nfloat RoughnessToPerceptualRoughness(in float roughness)\n{\n\treturn sqrt(roughness);\n}\n\nfloat SmoothnessToRoughness(in float smoothness)\n{\n\treturn (1.0 - smoothness) * (1.0 - smoothness);\n}\n\nfloat SmoothnessToPerceptualRoughness(in float smoothness)\n{\n\treturn (1.0 - smoothness);\n}\n\nvec3 SafeNormalize(in vec3 inVec)\n{\n\tfloat dp3 = max(0.001,dot(inVec,inVec));\n\treturn inVec * (1.0 / sqrt(dp3));\n}\n\nfloat DisneyDiffuse(in float NdotV, in float NdotL, in float LdotH, in float perceptualRoughness)\n{\n\tfloat fd90 = 0.5 + 2.0 * LdotH * LdotH * perceptualRoughness;\n\tfloat lightScatter\t= (1.0 + (fd90 - 1.0) * pow(1.0 - NdotL,5.0));\n\tfloat viewScatter\t= (1.0 + (fd90 - 1.0) * pow(1.0 - NdotV,5.0));\n\n\treturn lightScatter * viewScatter;\n}\n\nfloat SmithJointGGXVisibilityTerm (float NdotL, float NdotV, float roughness)\n{\n\tfloat a = roughness;\n\tfloat lambdaV = NdotL * (NdotV * (1.0 - a) + a);\n\tfloat lambdaL = NdotV * (NdotL * (1.0 - a) + a);\n\n\treturn 0.5 / (lambdaV + lambdaL + 0.00001);\n}\n\nfloat GGXTerm (float NdotH, float roughness)\n{\n\tfloat a2 = roughness * roughness;\n\tfloat d = (NdotH * a2 - NdotH) * NdotH + 1.0;\n\treturn 0.31830988618 * a2 / (d * d + 0.0000001);\n}\n\nfloat OneMinusReflectivityFromMetallic(in float metallic)\n{\n\tfloat oneMinusDielectricSpec = DielectricSpecularColor.a;\n\treturn oneMinusDielectricSpec - metallic * oneMinusDielectricSpec;\n}\n\nfloat SpecularStrength(vec3 specular)\n{\n //(SHADER_TARGET < 30)return specular.r; \n return max (max (specular.r, specular.g), specular.b);\n}\n\nvec3 DiffuseAndSpecularFromMetallic(in vec3 diffuseColor, in float metallic, out vec3 specularColor, out float oneMinusReflectivity)\n{\n\tspecularColor = mix(DielectricSpecularColor.rgb, diffuseColor, metallic);\n\toneMinusReflectivity = OneMinusReflectivityFromMetallic(metallic);\n\treturn diffuseColor * oneMinusReflectivity;\n}\n\nvec3 EnergyConservationBetweenDiffuseAndSpecular(in vec3 diffuseColor, in vec3 specularColor, out float oneMinusReflectivity)\n{\n\toneMinusReflectivity = 1.0 - SpecularStrength(specularColor);\n\treturn diffuseColor * oneMinusReflectivity;\n}\n\nvec4 Occlusion(in vec2 uv0){\n\t#ifdef OCCLUSIONTEXTURE\n\t\tvec4 occlusionTextureColor = texture2D(u_OcclusionTexture, uv0);\n\t\tfloat occ = occlusionTextureColor.g;\n\t\tfloat oneMinusT = 1.0 - u_occlusionStrength;\n\t\tfloat lerpOneTo = oneMinusT + occ * u_occlusionStrength;\n\t\treturn occlusionTextureColor * lerpOneTo;\n\t#else\n\t\treturn vec4(1.0);\n\t#endif\n}\n\nvec2 ParallaxOffset(in vec3 viewDir){\n\t#ifdef PARALLAXTEXTURE\n\t\tfloat h = texture2D(u_ParallaxTexture, v_Texcoord0).g;\n\t\th = h * u_parallaxScale - u_parallaxScale / 2.0;\n\t\tvec3 v = viewDir;\n\t\tv.z += 0.42;\n\t\tvec2 offset = h * (v.xy / v.z);\n\t\treturn v_Texcoord0 + offset;\n\t#else\n\t\treturn v_Texcoord0;\n\t#endif\n}\n\nvec3 ReflectCubeMap(in vec3 viewDir, in vec3 normal){\n\t#ifdef REFLECTMAP\n\t\tvec3 incident = -viewDir;\n\t\tvec3 reflectionVector = reflect(incident, normal);\n\t\tvec3 reflectionColor = textureCube(u_ReflectTexture, vec3(-reflectionVector.x, reflectionVector.yz)).rgb;\n\t\treturn reflectionColor * u_ReflectIntensity;\n\t#else\n\t\treturn vec3(0.0);\n\t#endif\n}\n\nfloat LayaAttenuation(in vec3 L, in float invLightRadius)\n{\n\tfloat fRatio = clamp(length(L) * invLightRadius, 0.0, 1.0);\n\tfRatio *= fRatio;\n\treturn 1.0 / (1.0 + 25.0 * fRatio) * clamp(4.0*(1.0 - fRatio), 0.0, 1.0); //fade to black as if 4 pixel texture\n}\n\nvec3 LayaPreMultiplyAlpha(vec3 diffColor, float alpha, float oneMinusReflectivity, out float outModifiedAlpha)\n{\n\t#ifdef ALPHAPREMULTIPLY\n\t\tdiffColor *= alpha;\n\t\toutModifiedAlpha = 1.0 - oneMinusReflectivity + alpha * oneMinusReflectivity;\n\t#else\n\t\toutModifiedAlpha = alpha;\n\t#endif\n\treturn diffColor;\n}\n\n"),At.addInclude("PBRStandardLighting.glsl",'#include "PBRUtils.glsl"\n#include "BRDF.glsl"\n\nvec4 PBRStandardLight(in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in LayaGI gi)\n{\n\tfloat oneMinusReflectivity;\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat alpha;\n\t\n\tdiffuseColor = DiffuseAndSpecularFromMetallic (albedoColor.rgb, metallic, specularColor, oneMinusReflectivity);\n\t\n\tdiffuseColor = LayaPreMultiplyAlpha(diffuseColor, albedoColor.a, oneMinusReflectivity, alpha);\n\t\n\tvec4 color = LayaAirBRDF(diffuseColor, specularColor, oneMinusReflectivity, smoothness, normal, viewDir, lightDir, lightColor, gi);\n\tcolor.a = alpha;\n\treturn color;\n}\n\nvec4 PBRStandardDiectionLight (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in DirectionLight light, in LayaGI gi)\n{\n\tvec3 lightVec = normalize(light.Direction);\n\treturn PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi);\n}\n\nvec4 PBRStandardPointLight (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in PointLight light, in vec3 pos, in LayaGI gi)\n{\n\tvec3 lightCoord = (u_PointLightMatrix * vec4(pos, 1.0)).xyz;\n\tfloat distance = dot(lightCoord, lightCoord);\n\tfloat attenuate = texture2D(u_RangeTexture, vec2(distance)).w;\n\tvec3 lightVec = normalize(pos - light.Position);\n\treturn PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\nvec4 PBRStandardSpotLight (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n{\n\tvec3 lightVec = pos - light.Position;\n\tvec3 normalLightVec = normalize(lightVec);\n\tvec2 cosAngles = cos(vec2(light.SpotAngle, light.SpotAngle*0.5) * 0.5);//ConeAttenuation\n\tfloat dl = dot(normalize(light.Direction), normalLightVec);\n\tdl *= smoothstep(cosAngles[0], cosAngles[1], dl);\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.Range) * dl;\n\treturn PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\n//vec4 PBRStandardSpotLight1 (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n//{\n//\tvec4 lightCoord = u_SpotLightMatrix * vec4(pos, 1.0);\n//\t\n//\tfloat distance = dot(lightCoord, lightCoord);\n//\tfloat attenuate = (lightCoord.z < 0.0) ? texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n//\t//float attenuate = (lightCoord.z < 0.0) ? texture2D(u_AngleTexture, vec2(lightCoord.x / lightCoord.w + 0.5, lightCoord.y / lightCoord.w + 0.5)).r * texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n//\t//vec2 _uv = vec2(pos.x * 180.0/(2.0 * pos.z) + 0.5, pos.y * 180.0/(2.0 * pos.z) + 0.5);\n//\tvec3 lightVec = normalize(pos - light.Position);\n//\treturn PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n//}\n\nvec2 MetallicGloss(in float albedoTextureAlpha, in vec2 uv0)\n{\n\tvec2 mg;\n\t\n\t#ifdef METALLICGLOSSTEXTURE\n\t\tvec4 metallicGlossTextureColor = texture2D(u_MetallicGlossTexture, uv0);\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n\t\t\tmg.r = metallicGlossTextureColor.r;\n\t\t\tmg.g = albedoTextureAlpha;\n\t\t#else\n\t\t mg = metallicGlossTextureColor.ra;\n\t\t#endif\n\t\tmg.g *= u_smoothnessScale;\n\t#else\n\t\tmg.r = u_metallic;\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n\t\t\tmg.g = albedoTextureAlpha * u_smoothnessScale;\n\t\t#else\n\t\t\tmg.g = u_smoothness;\n\t\t#endif\n\t#endif\n\t\n\treturn mg;\n}\n\n'),At.addInclude("PBRSpecularLighting.glsl",'#include "PBRUtils.glsl"\n#include "BRDF.glsl"\n\nvec4 PBRSpecularLight(in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in LayaGI gi)\n{\n\tfloat oneMinusReflectivity;\n\tvec3 diffuseColor;\n\tfloat alpha;\n\t\n\tdiffuseColor = EnergyConservationBetweenDiffuseAndSpecular (albedoColor.rgb, specularColor, oneMinusReflectivity);\n\t\n\tdiffuseColor = LayaPreMultiplyAlpha(diffuseColor, albedoColor.a, oneMinusReflectivity, alpha);\n\t\n\tvec4 color = LayaAirBRDF(diffuseColor, specularColor, oneMinusReflectivity, smoothness, normal, viewDir, lightDir, lightColor, gi);\n\tcolor.a = alpha;\n\treturn color;\n}\n\nvec4 PBRSpecularDiectionLight (in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in DirectionLight light, in LayaGI gi)\n{\n\tvec3 lightVec = normalize(light.Direction);\n\treturn PBRSpecularLight(albedoColor, specularColor, smoothness, normal, viewDir, lightVec, light.Color, gi);\n}\n\nvec4 PBRSpecularPointLight (in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in PointLight light, in vec3 pos, in LayaGI gi)\n{\n\tvec3 lightCoord = (u_PointLightMatrix * vec4(pos, 1.0)).xyz;\n\tfloat distance = dot(lightCoord, lightCoord);\n\tfloat attenuate = texture2D(u_RangeTexture, vec2(distance)).w;\n\tvec3 lightVec = normalize(pos - light.Position);\n\treturn PBRSpecularLight(albedoColor, specularColor, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\nvec4 PBRSpecularSpotLight (in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n{\n\tvec3 lightVec = pos - light.Position;\n\tvec3 normalLightVec = normalize(lightVec);\n\tvec2 cosAngles = cos(vec2(light.SpotAngle, light.SpotAngle*0.5) * 0.5);//ConeAttenuation\n\tfloat dl = dot(normalize(light.Direction), normalLightVec);\n\tdl *= smoothstep(cosAngles[0], cosAngles[1], dl);\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.Range) * dl;\n\treturn PBRSpecularLight(albedoColor, specularColor, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\n//vec4 PBRStandardSpotLight1 (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n//{\n//\tvec4 lightCoord = u_SpotLightMatrix * vec4(pos, 1.0);\n//\t\n//\tfloat distance = dot(lightCoord, lightCoord);\n//\tfloat attenuate = (lightCoord.z < 0.0) ? texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n//\t//float attenuate = (lightCoord.z < 0.0) ? texture2D(u_AngleTexture, vec2(lightCoord.x / lightCoord.w + 0.5, lightCoord.y / lightCoord.w + 0.5)).r * texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n//\t//vec2 _uv = vec2(pos.x * 180.0/(2.0 * pos.z) + 0.5, pos.y * 180.0/(2.0 * pos.z) + 0.5);\n//\tvec3 lightVec = normalize(pos - light.Position);\n//\treturn PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n//}\n\nvec4 SpecularGloss(float albedoTextureAlpha, in vec2 uv0)\n{\n vec4 sg;\n\t\n\t#ifdef SPECULARTEXTURE\n\t\tvec4 specularTextureColor = texture2D(u_SpecularTexture, uv0);\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n\t\t\tsg.rgb = specularTextureColor.rgb;\n\t\t\tsg.a = albedoTextureAlpha;\n\t\t#else\n\t\t\tsg = specularTextureColor;\n\t\t#endif\n\t\tsg.a *= u_smoothnessScale;\n\t#else\n\t\tsg.rgb = u_SpecularColor.rgb;\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n\t\t\tsg.a = albedoTextureAlpha * u_smoothnessScale;\n\t\t#else\n\t\t\tsg.a = u_smoothness;\n\t\t#endif\n\t#endif\n\t\n return sg;\n}\n\n'),At.addInclude("Colors.glsl",'#include "StdLib.glsl";\n\n#define EPSILON 1.0e-4\n\n// Quadratic color thresholding\n// curve = (threshold - knee, knee * 2, 0.25 / knee)\nmediump vec4 quadraticThreshold(mediump vec4 color, mediump float threshold, mediump vec3 curve) {\n\t// Pixel brightness\n\tmediump float br = max3(color.r, color.g, color.b);\n\n\t// Under-threshold part: quadratic curve\n\tmediump float rq = clamp(br - curve.x, 0.0, curve.y);\n\trq = curve.z * rq * rq;\n\n\t// Combine and apply the brightness response curve.\n\tcolor *= max(rq, br - threshold) / max(br, EPSILON);\n\n\treturn color;\n}\n\n//\n// sRGB transfer functions\n// Fast path ref: http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1\n//\nmediump vec3 SRGBToLinear(mediump vec3 c) {\n\t#ifdef USE_VERY_FAST_SRGB\n\t\treturn c * c;\n\t#elif defined(USE_FAST_SRGB)\n\t\treturn c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);\n\t#else\n\t\tmediump vec3 linearRGBLo = c / 12.92;\n\t\tmediump vec3 power=vec3(2.4, 2.4, 2.4);\n\t\tmediump vec3 linearRGBHi = positivePow((c + 0.055) / 1.055, power);\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);\n\t\treturn linearRGB;\n\t#endif\n}\n\nmediump vec3 LinearToSRGB(mediump vec3 c) {\n\t#ifdef USE_VERY_FAST_SRGB\n\t\treturn sqrt(c);\n\t#elif defined(USE_FAST_SRGB)\n\t\treturn max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);\n\t#else\n\t\tmediump vec3 sRGBLo = c * 12.92;\n\t\tmediump vec3 power=vec3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4);\n\t\tmediump vec3 sRGBHi = (positivePow(c, power) * 1.055) - 0.055;\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);\n\t\treturn sRGB;\n\t#endif\n}'),At.addInclude("Sampling.glsl","// Better, temporally stable box filtering\n// [Jimenez14] http://goo.gl/eomGso\n// . . . . . . .\n// . A . B . C .\n// . . D . E . .\n// . F . G . H .\n// . . I . J . .\n// . K . L . M .\n// . . . . . . .\nmediump vec4 downsampleBox13Tap(sampler2D tex, vec2 uv, vec2 texelSize)\n{\n mediump vec4 A = texture2D(tex, uv + texelSize * vec2(-1.0, -1.0));\n mediump vec4 B = texture2D(tex, uv + texelSize * vec2( 0.0, -1.0));\n mediump vec4 C = texture2D(tex, uv + texelSize * vec2( 1.0, -1.0));\n mediump vec4 D = texture2D(tex, uv + texelSize * vec2(-0.5, -0.5));\n mediump vec4 E = texture2D(tex, uv + texelSize * vec2( 0.5, -0.5));\n mediump vec4 F = texture2D(tex, uv + texelSize * vec2(-1.0, 0.0));\n mediump vec4 G = texture2D(tex, uv);\n mediump vec4 H = texture2D(tex, uv + texelSize * vec2( 1.0, 0.0));\n mediump vec4 I = texture2D(tex, uv + texelSize * vec2(-0.5, 0.5));\n mediump vec4 J = texture2D(tex, uv + texelSize * vec2( 0.5, 0.5));\n mediump vec4 K = texture2D(tex, uv + texelSize * vec2(-1.0, 1.0));\n mediump vec4 L = texture2D(tex, uv + texelSize * vec2( 0.0, 1.0));\n mediump vec4 M = texture2D(tex, uv + texelSize * vec2( 1.0, 1.0));\n\n\tmediump vec2 scale= vec2(0.5, 0.125);\n mediump vec2 div = (1.0 / 4.0) * scale;\n\n mediump vec4 o = (D + E + I + J) * div.x;\n o += (A + B + G + F) * div.y;\n o += (B + C + H + G) * div.y;\n o += (F + G + L + K) * div.y;\n o += (G + H + M + L) * div.y;\n\n return o;\n}\n\n// Standard box filtering\nmediump vec4 downsampleBox4Tap(sampler2D tex, vec2 uv, vec2 texelSize)\n{\n vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0);\n\n mediump vec4 s = texture2D(tex, uv + d.xy);\n s += texture2D(tex, uv + d.zy);\n s += texture2D(tex, uv + d.xw);\n s += texture2D(tex, uv + d.zw);\n\n return s * (1.0 / 4.0);\n}\n\n// 9-tap bilinear upsampler (tent filter)\n// . . . . . . .\n// . 1 . 2 . 1 .\n// . . . . . . .\n// . 2 . 4 . 2 .\n// . . . . . . .\n// . 1 . 2 . 1 .\n// . . . . . . .\nmediump vec4 upsampleTent(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\n{\n vec4 d = texelSize.xyxy * vec4(1.0, 1.0, -1.0, 0.0) * sampleScale;\n\n mediump vec4 s = texture2D(tex, uv - d.xy);\n s += texture2D(tex, uv - d.wy) * 2.0;\n s += texture2D(tex, uv - d.zy);\n\n s += texture2D(tex, uv + d.zw) * 2.0;\n s += texture2D(tex, uv) * 4.0;\n s += texture2D(tex,\tuv + d.xw) * 2.0;\n\n s += texture2D(tex, uv + d.zy);\n s += texture2D(tex, uv + d.wy) * 2.0;\n s += texture2D(tex, uv + d.xy);\n\n return s * (1.0 / 16.0);\n}\n\n// Standard box filtering\nmediump vec4 upsampleBox(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\n{\n vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0) * (sampleScale * 0.5);\n\n mediump vec4 s = texture2D(tex, uv + d.xy);\n s += texture2D(tex, uv + d.zy);\n s += texture2D(tex, uv + d.xw);\n s += texture2D(tex, uv + d.zw);\n\n return s * (1.0 / 4.0);\n}"),At.addInclude("StdLib.glsl","#define HALF_MAX 65504.0 // (2 - 2^-10) * 2^15\n\n#define FLT_EPSILON 1.192092896e-07 // Smallest positive number, such that 1.0 + FLT_EPSILON != 1.0\n\nmediump vec4 safeHDR(mediump vec4 c)\n{\n return min(c, HALF_MAX);\n}\n\nfloat max3(float a, float b, float c)\n{\n return max(max(a, b), c);\n}\n\nvec3 positivePow(vec3 base, vec3 power)\n{\n return pow(max(abs(base), vec3(FLT_EPSILON, FLT_EPSILON, FLT_EPSILON)), power);\n}");var n={a_Position:0,a_Color:1,a_Normal:3,a_Texcoord0:2,a_Texcoord1:7,a_BoneWeights:6,a_BoneIndices:5,a_Tangent0:4,a_MvpMatrix:12,a_WorldMat:8},i={u_Bones:0,u_DiffuseTexture:1,u_SpecularTexture:1,u_NormalTexture:1,u_AlphaTestValue:1,u_DiffuseColor:1,u_MaterialSpecular:1,u_Shininess:1,u_TilingOffset:1,u_WorldMat:2,u_MvpMatrix:2,u_LightmapScaleOffset:2,u_LightMap:2,u_CameraPos:3,u_ReflectTexture:4,u_ReflectIntensity:4,u_FogStart:4,u_FogRange:4,u_FogColor:4,"u_DirectionLight.Color":4,"u_DirectionLight.Direction":4,"u_PointLight.Position":4,"u_PointLight.Range":4,"u_PointLight.Color":4,"u_SpotLight.Position":4,"u_SpotLight.Direction":4,"u_SpotLight.Range":4,"u_SpotLight.Spot":4,"u_SpotLight.Color":4,u_AmbientColor:4,u_shadowMap1:4,u_shadowMap2:4,u_shadowMap3:4,u_shadowPSSMDistance:4,u_lightShadowVP:4,u_shadowPCFoffset:4},r={s_Cull:0,s_Blend:1,s_BlendSrc:2,s_BlendDst:3,s_DepthTest:12,s_DepthWrite:13};e='#include "Lighting.glsl";\n\nattribute vec4 a_Position;\n\n#ifdef GPU_INSTANCE\n\tattribute mat4 a_MvpMatrix;\n#else\n\tuniform mat4 u_MvpMatrix;\n#endif\n\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))||(defined(LIGHTMAP)&&defined(UV))\n\tattribute vec2 a_Texcoord0;\n\tvarying vec2 v_Texcoord0;\n#endif\n\n#if defined(LIGHTMAP)&&defined(UV1)\n\tattribute vec2 a_Texcoord1;\n#endif\n\n#ifdef LIGHTMAP\n\tuniform vec4 u_LightmapScaleOffset;\n\tvarying vec2 v_LightMapUV;\n#endif\n\n#ifdef COLOR\n\tattribute vec4 a_Color;\n\tvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\n\tconst int c_MaxBoneCount = 24;\n\tattribute vec4 a_BoneIndices;\n\tattribute vec4 a_BoneWeights;\n\tuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tattribute vec3 a_Normal;\n\tvarying vec3 v_Normal; \n\tuniform vec3 u_CameraPos;\n\tvarying vec3 v_ViewDir; \n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\tattribute vec4 a_Tangent0;\n\tvarying vec3 v_Tangent;\n\tvarying vec3 v_Binormal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n\t#ifdef GPU_INSTANCE\n\t\tattribute mat4 a_WorldMat;\n\t#else\n\t\tuniform mat4 u_WorldMat;\n\t#endif\n\tvarying vec3 v_PositionWorld;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvoid main_castShadow()\n{\n\tvec4 position;\n\t#ifdef BONE\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tposition=skinTransform*a_Position;\n\t#else\n\t\tposition=a_Position;\n\t#endif\n\t#ifdef GPU_INSTANCE\n\t\tgl_Position = a_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * position;\n\t#endif\n\t\n\t//TODO没考虑UV动画呢\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tv_Texcoord0=a_Texcoord0;\n\t#endif\n\tgl_Position=remapGLPositionZ(gl_Position);\n\tv_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n\tvec4 position;\n\t#ifdef BONE\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tposition=skinTransform*a_Position;\n\t#else\n\t\tposition=a_Position;\n\t#endif\n\t#ifdef GPU_INSTANCE\n\t\tgl_Position = a_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * position;\n\t#endif\n\t\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n\t\tmat4 worldMat;\n\t\t#ifdef GPU_INSTANCE\n\t\t\tworldMat = a_WorldMat;\n\t\t#else\n\t\t\tworldMat = u_WorldMat;\n\t\t#endif\n\t#endif\n\t\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tmat3 worldInvMat;\n\t\t#ifdef BONE\n\t\t\tworldInvMat=inverse(mat3(worldMat*skinTransform));\n\t\t#else\n\t\t\tworldInvMat=inverse(mat3(worldMat));\n\t\t#endif \n\t\tv_Normal=a_Normal*worldInvMat;\n\t\t#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\t\t\tv_Tangent=a_Tangent0.xyz*worldInvMat;\n\t\t\tv_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\n\t\t#endif\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n\t\tv_PositionWorld=(worldMat*position).xyz;\n\t#endif\n\t\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tv_ViewDir=u_CameraPos-v_PositionWorld;\n\t#endif\n\n\t#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\n\t\t#ifdef TILINGOFFSET\n\t\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\n\t\t#else\n\t\t\tv_Texcoord0=a_Texcoord0;\n\t\t#endif\n\t#endif\n\n\t#ifdef LIGHTMAP\n\t\t#ifdef SCALEOFFSETLIGHTINGMAPUV\n\t\t\t#ifdef UV1\n\t\t\t\tv_LightMapUV=vec2(a_Texcoord1.x,1.0-a_Texcoord1.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\n\t\t\t#else\n\t\t\t\tv_LightMapUV=vec2(a_Texcoord0.x,1.0-a_Texcoord0.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\n\t\t\t#endif \n\t\t\tv_LightMapUV.y=1.0-v_LightMapUV.y;\n\t\t#else\n\t\t\t#ifdef UV1\n\t\t\t\tv_LightMapUV=a_Texcoord1;\n\t\t\t#else\n\t\t\t\tv_LightMapUV=a_Texcoord0;\n\t\t\t#endif \n\t\t#endif \n\t#endif\n\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n\t\tv_Color=a_Color;\n\t#endif\n\n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1 \n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n\tgl_Position=remapGLPositionZ(gl_Position);\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif\n}',t='#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Lighting.glsl";\n\nuniform vec4 u_DiffuseColor;\n\n#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n\tvarying vec4 v_Color;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tvarying vec3 v_ViewDir; \n#endif\n\n#ifdef ALPHATEST\n\tuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\n\tuniform sampler2D u_DiffuseTexture;\n#endif\n\n\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\n\tvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef LIGHTMAP\n\tvarying vec2 v_LightMapUV;\n\tuniform sampler2D u_LightMap;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tuniform vec3 u_MaterialSpecular;\n\tuniform float u_Shininess;\n\t#ifdef SPECULARMAP \n\t\tuniform sampler2D u_SpecularTexture;\n\t#endif\n#endif\n\n#ifdef FOG\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\tuniform vec3 u_FogColor;\n#endif\n\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tvarying vec3 v_Normal;\n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\tuniform sampler2D u_NormalTexture;\n\tvarying vec3 v_Tangent;\n\tvarying vec3 v_Binormal;\n#endif\n\n#ifdef DIRECTIONLIGHT\n\tuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n\tuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n\tuniform SpotLight u_SpotLight;\n#endif\n\nuniform vec3 u_AmbientColor;\n\n\n#if defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#include "ShadowHelper.glsl"\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\nvoid main_castShadow()\n{\n\t//gl_FragColor=vec4(v_posViewZ,0.0,0.0,1.0);\n\tgl_FragColor=packDepth(v_posViewZ);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n\t\tif( alpha < u_AlphaTestValue )\n\t\t{\n\t\t\tdiscard;\n\t\t}\n\t#endif\n}\nvoid main_normal()\n{\n\tvec3 globalDiffuse=u_AmbientColor;\n\t#ifdef LIGHTMAP\t\n\t\tglobalDiffuse += DecodeLightmap(texture2D(u_LightMap, v_LightMapUV));\n\t#endif\n\t\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tvec3 normal;\n\t\t#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\t\t\tvec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\n\t\t\tnormal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent,v_Binormal));\n\t\t#else\n\t\t\tnormal = normalize(v_Normal);\n\t\t#endif\n\t\tvec3 viewDir= normalize(v_ViewDir);\n\t#endif\n\t\n\tvec4 mainColor=u_DiffuseColor;\n\t#ifdef DIFFUSEMAP\n\t\tvec4 difTexColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n\t\tmainColor=mainColor*difTexColor;\n\t#endif \n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n\t\tmainColor=mainColor*v_Color;\n\t#endif \n \n\t#ifdef ALPHATEST\n\t\tif(mainColor.a=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\tcurValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn curValue;\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n\tfloat totalValue=0.0;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientNumber=gradientNumbers[i];\n\t\tfloat key=gradientNumber.x;\n\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\tfloat lastValue=lastGradientNumber.y;\n\t\t\n\t\tif(key>=normalizedAge){\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\ttotalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_ShapePositionStartLifeTime.w*(normalizedAge-lastKey);\n\t\t\tbreak;\n\t\t}\n\t\telse{\n\t\t\ttotalValue+=(lastValue+gradientNumber.y)/2.0*a_ShapePositionStartLifeTime.w*(key-lastGradientNumber.x);\n\t\t}\n\t}\n\treturn totalValue;\n}\n#endif\n\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n\tvec4 overTimeColor;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientAlpha=gradientAlphas[i];\n\t\tfloat alphaKey=gradientAlpha.x;\n\t\tif(alphaKey>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientAlpha=gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey=lastGradientAlpha.x;\n\t\t\tfloat age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n\t\t\toverTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec4 gradientColor=gradientColors[i];\n\t\tfloat colorKey=gradientColor.x;\n\t\tif(colorKey>=normalizedAge)\n\t\t{\n\t\t\tvec4 lastGradientColor=gradientColors[i-1];\n\t\t\tfloat lastColorKey=lastGradientColor.x;\n\t\t\tfloat age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n\t\t\toverTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn overTimeColor;\n}\n#endif\n\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n\tfloat overTimeFrame;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientFrame=gradientFrames[i];\n\t\tfloat key=gradientFrame.x;\n\t\tif(key>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientFrame=gradientFrames[i-1];\n\t\t\tfloat lastKey=lastGradientFrame.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\toverTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn floor(overTimeFrame);\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n vec3 outLifeVelocity;\n #ifdef VELOCITYOVERLIFETIMECONSTANT\n\t outLifeVelocity=u_VOLVelocityConst; \n #endif\n #ifdef VELOCITYOVERLIFETIMECURVE\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,vec3(a_Random1.y,a_Random1.z,a_Random1.w)); \n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y),\n\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z),\n\t\t\t\t\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n #endif\n\t\t\t\t\t\n return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation)\n{\n vec3 startPosition;\n vec3 lifePosition;\n #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t#ifdef VELOCITYOVERLIFETIMECONSTANT\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMECURVE\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y)\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z)\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n\t#endif\n\t\n\tvec3 finalPosition;\n\tif(u_VOLSpaceType==0){\n\t if(u_ScalingMode!=2)\n\t finalPosition =rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition),worldRotation);\n\t else\n\t finalPosition =rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);\n\t}\n\telse{\n\t if(u_ScalingMode!=2)\n\t finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation)+lifePosition;\n\t else\n\t finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;\n\t}\n #else\n\t startPosition=startVelocity*age;\n\t vec3 finalPosition;\n\t if(u_ScalingMode!=2)\n\t finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation);\n\t else\n\t finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n #endif\n \n if(u_SimulationSpace==0)\n finalPosition=finalPosition+a_SimulationWorldPostion;\n else if(u_SimulationSpace==1) \n finalPosition=finalPosition+u_WorldPosition;\n \n finalPosition+=0.5*gravityVelocity*age;\n \n return finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n\t#ifdef COLOROVERLIFETIME\n\t color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n\t#endif\n\t\n\t#ifdef RANDOMCOLOROVERLIFETIME\n\t color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n\t#endif\n\n return color;\n}\n\nvec2 computeParticleSizeBillbard(in vec2 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n\n#ifdef RENDERMODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec3(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t size*=vec3(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z)\n\t\t,mix(getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxZ,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n#endif\n\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConstSeprarate.z*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConstSeprarate.z,u_ROLAngularVelocityConstMaxSeprarate.z,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n\n#if defined(RENDERMODE_MESH)&&(defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tvec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tvec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n#endif\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n\t#ifdef TEXTURESHEETANIMATIONCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n\t#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n\t float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n\treturn uv;\n}\n\nvoid main()\n{\n\tfloat age = u_CurrentTime - a_DirectionTime.w;\n\tfloat normalizedAge = age/a_ShapePositionStartLifeTime.w;\n\tvec3 lifeVelocity;\n\tif(normalizedAge<1.0){ \n\tvec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t\tlifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n\t#endif \n\tvec3 gravityVelocity=u_Gravity*age;\n\t\n\tvec4 worldRotation;\n\tif(u_SimulationSpace==0)\n\t\tworldRotation=a_SimulationWorldRotation;\n\telse\n\t\tworldRotation=u_WorldRotation;\n\t\n\tvec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge,gravityVelocity,worldRotation);//计算粒子位置\n \n \n #ifdef SPHERHBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n\t corner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\tfloat c = cos(rot);\n\t\t\t\tfloat s = sin(rot);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat c = cos(a_StartRotation0.x);\n\t\t\t\tfloat s = sin(a_StartRotation0.x);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#endif\n #endif\n \n #ifdef STRETCHEDBILLBOARD\n\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n\tvec3 velocity;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t if(u_VOLSpaceType==0)\n\t\t velocity=rotationByQuaternions(u_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;\n\t else\n\t\t velocity=rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;\n #else\n\t velocity= rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n #endif\t\n\t\tvec3 cameraUpVector = normalize(velocity);\n\t\tvec3 direction = normalize(center-u_CameraPosition);\n vec3 sideVector = normalize(cross(direction,normalize(velocity)));\n\t\t\n\t\tsideVector=u_SizeScale.xzy*sideVector;\n\t\tcameraUpVector=length(vec3(u_SizeScale.x,0.0,0.0))*cameraUpVector;\n\t\t\n\t vec2 size=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t\n\t const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n\t corner=rotaionZHalfPI*corner;\n\t corner.y=corner.y-abs(corner.y);\n\t\t\n\t float speed=length(velocity);//TODO:\n\t center +=sign(u_SizeScale.x)*(sign(u_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*u_StretchedBillboardSpeedScale+size.y*u_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n #endif\n \n #ifdef HORIZONTALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector=vec3(0.0,0.0,1.0);\n\t const vec3 sideVector = vec3(-1.0,0.0,0.0);\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n\t corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef VERTICALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n\t corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef RENDERMODE_MESH\n\t vec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z, age,normalizedAge));\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\t#ifdef ROTATIONOVERLIFETIME\n\t\t\t\t\tfloat angle=computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));//已验证\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\t\tcenter+= u_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\t\tcenter+=rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);//已验证\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\t\tcenter+=rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);//已验证\n\t\t\t\t\t\t#endif\n\t\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t\t\t\t//TODO:是否应合并if(u_ThreeDStartRotation)分支代码,待测试\n\t\t\t\t\tvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x), age,normalizedAge);\n\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByEuler(u_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));//已验证\n\t\t\t\t#endif\t\t\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);//已验证\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);\n\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));//已验证\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\t\n\t\t\t\t\t#else\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);//已验证\n\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t}\n\t\t#endif\n\t\tv_MeshColor=a_MeshColor;\n #endif\n \n gl_Position=u_Projection*u_View*vec4(center,1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\t#ifdef DIFFUSEMAP\n\t\t#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n\t\t\tv_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n\t\t#endif\n\t\t#ifdef RENDERMODE_MESH\n\t\t\tv_TextureCoordinate =computeParticleUV(a_MeshTextureCoordinate, normalizedAge);\n\t\t#endif\n\t\t\n\t\t#ifdef TILINGOFFSET\n\t\t\tv_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset.xy+vec2(u_TilingOffset.z,-u_TilingOffset.w);//需要特殊处理\n\t\t\tv_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n\t\t#endif\n\t#endif\n v_Discard=0.0;\n\t \n\t#ifdef FOG\n\t\tv_PositionWorld=center;\n\t#endif\n }\n else\n\t{\n\t\tv_Discard=1.0;\n\t}\n\tgl_Position=remapGLPositionZ(gl_Position);\n}\n\n',t="#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\nuniform vec4 u_Tintcolor;\n\n#ifdef RENDERMODE_MESH\n varying vec4 v_MeshColor;\n#endif\n\n#ifdef FOG\n varying vec3 v_PositionWorld;\n uniform vec3 u_CameraPosition;\n uniform float u_FogStart;\n uniform float u_FogRange;\n #ifdef ADDTIVEFOG\n #else\n uniform vec3 u_FogColor;\n #endif\n#endif\n\n\nvoid main()\n{ \n #ifdef RENDERMODE_MESH\n gl_FragColor=v_MeshColor;\n #else\n gl_FragColor=vec4(1.0); \n #endif\n \n #ifdef DIFFUSEMAP\n if(v_Discard!=0.0)\n discard;\n #ifdef TINTCOLOR\n gl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*u_Tintcolor*2.0*v_Color;\n #else\n gl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n #endif\n #else\n #ifdef TINTCOLOR\n gl_FragColor*=u_Tintcolor*2.0*v_Color;\n #else\n gl_FragColor*=v_Color;\n #endif\n #endif\n \n #ifdef FOG\n vec3 toEye=u_CameraPosition-v_PositionWorld;\n float toEyeLength=length(toEye);\n toEye/=toEyeLength;\n \n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n #ifdef ADDTIVEFOG\n #else\n \n #endif\n #endif\n}",a=At.add("PARTICLESHURIKEN"),o=new de(n,i,Ri.shaderDefines,ci.shaderDefines),a.addSubShader(o),o.addShaderPass(e,t,r),n={a_Position:0},i={u_TintColor:1,u_Exposure:1,u_Rotation:1,u_CubeTexture:1,u_MvpMatrix:3},e='#include "Lighting.glsl";\n\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nuniform float u_Rotation;\nvarying vec3 v_Texcoord;\n\n\nvec4 rotateAroundYInDegrees (vec4 vertex, float degrees)\n{\n\tfloat angle = degrees * 3.141593 / 180.0;\n\tfloat sina=sin(angle);\n\tfloat cosa=cos(angle);\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\n\treturn vec4(m*vertex.xz, vertex.yw).xzyw;\n}\n\t\t\nvoid main()\n{\n\tvec4 position=rotateAroundYInDegrees(a_Position,u_Rotation);\n\tgl_Position = (u_MvpMatrix*position).xyww;\n\tv_Texcoord=vec3(-a_Position.x,a_Position.yz);//转换坐标系\n\tgl_Position=remapGLPositionZ(gl_Position);\n}\n',t="#ifdef HIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec3 v_Texcoord;\n\nuniform samplerCube u_CubeTexture;\nuniform float u_Exposure;\nuniform vec4 u_TintColor;\n\n\nvoid main()\n{\t\n\tvec3 color=textureCube(u_CubeTexture, v_Texcoord).rgb*u_TintColor.rgb*u_Exposure*2.0;\n\tgl_FragColor=vec4(color,1.0);\n}\n\n",a=At.add("SkyBox"),o=new de(n,i),a.addSubShader(o),o.addShaderPass(e,t),n={a_Position:0},i={u_SunSize:1,u_SunSizeConvergence:1,u_AtmosphereThickness:1,u_SkyTint:1,u_GroundTint:1,u_Exposure:1,u_MvpMatrix:3,"u_DirectionLight.Direction":4,"u_DirectionLight.Color":4},e="#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include \"Lighting.glsl\";\n\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(u_AtmosphereThickness,2.5)))// Rayleigh constant Rayleigh为夜空光和极光亮度单位\n#define MIE 0.0010 // Mie constant 米氏散射\n#define SUN_BRIGHTNESS 20.0 // Sun brightness\n#define MAX_SCATTER 50.0 // Maximum scattering value, to prevent math overflows on Adrenos\n\nconst float SKY_GROUND_THRESHOLD = 0.02;\nconst float outerRadius = OUTER_RADIUS;\nconst float outerRadius2 = OUTER_RADIUS*OUTER_RADIUS;\nconst float innerRadius = 1.0;\nconst float innerRadius2 = 1.0;\nconst float cameraHeight = 0.0001;\n\nconst float HDSundiskIntensityFactor = 15.0;\nconst float simpleSundiskIntensityFactor = 27.0;\n\nconst float sunScale = 400.0 * SUN_BRIGHTNESS;\nconst float kmESun = MIE * SUN_BRIGHTNESS;\nconst float km4PI = MIE * 4.0 * 3.14159265;\nconst float scale = 1.0 / (OUTER_RADIUS - 1.0);\nconst float scaleDepth = 0.25;\nconst float scaleOverScaleDepth = (1.0 / (OUTER_RADIUS - 1.0)) / 0.25;\nconst float samples = 2.0; // THIS IS UNROLLED MANUALLY, DON'T TOUCH\n\n// RGB wavelengths .35 (.62=158), .43 (.68=174), .525 (.75=190)\nconst vec3 c_DefaultScatteringWavelength = vec3(0.65, 0.57, 0.475);//默认散射波长\nconst vec3 c_VariableRangeForScatteringWavelength = vec3(0.15, 0.15, 0.15);//散射播放的可变范围\n\nattribute vec4 a_Position;\n\nuniform mat4 u_MvpMatrix;\nuniform vec3 u_SkyTint;\nuniform vec3 u_GroundTint;\nuniform float u_Exposure;\nuniform float u_AtmosphereThickness;\nuniform DirectionLight u_DirectionLight;\n\nvarying vec3 v_GroundColor;\nvarying vec3 v_SkyColor;\n\n#ifdef SUN_HIGH_QUALITY\n\tvarying vec3 v_Vertex;\n#elif defined(SUN_SIMPLE)\n\tvarying vec3 v_RayDir;\n#else\n\tvarying float v_SkyGroundFactor;\n#endif\n\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\n\tvarying vec3 v_SunColor;\n#endif\n\n// Calculates the Rayleigh phase function\nfloat getRayleighPhase(vec3 light, vec3 ray) \n{\n\tfloat eyeCos = dot(light, ray);\n\treturn 0.75 + 0.75*eyeCos*eyeCos;\n}\n\nfloat scaleAngle(float inCos)\n{\n\tfloat x = 1.0 - inCos;\n\treturn 0.25 * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));\n}\n\n\nvoid main () {\n\tgl_Position = (u_MvpMatrix*a_Position).xyww;\n\n\tvec3 skyTintInGammaSpace = u_SkyTint;//支持非GAMMA空间后要调整\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\n\tvec3 invWavelength = 1.0 / pow(scatteringWavelength, vec3(4.0));\n\n\tfloat krESun = RAYLEIGH * SUN_BRIGHTNESS;\n\tfloat kr4PI = RAYLEIGH * 4.0 * 3.14159265;\n\n\tvec3 cameraPos = vec3(0.0,innerRadius + cameraHeight,0.0); // The camera's current position\n\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)\n\tvec3 eyeRay = normalize(a_Position.xyz);\n\n\tfloat far = 0.0;\n\tvec3 cIn, cOut;\n\tif (eyeRay.y >= 0.0) {// Sky\n\t\t// Calculate the length of the \"atmosphere\"\n\t\tfar = sqrt(outerRadius2 + innerRadius2 * eyeRay.y * eyeRay.y - innerRadius2) - innerRadius * eyeRay.y;\n\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\n\t\tfloat height = innerRadius + cameraHeight;\n\t\tfloat depth = exp(scaleOverScaleDepth * -cameraHeight);\n\t\tfloat startAngle = dot(eyeRay, cameraPos) / height;\n\t\tfloat startOffset = depth*scaleAngle(startAngle);\n\n\t\t// Initialize the scattering loop variables\n\t\tfloat sampleLength = far / samples;\n\t\tfloat scaledLength = sampleLength * scale;\n\t\tvec3 sampleRay = eyeRay * sampleLength;\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n\t\tvec3 frontColor = vec3(0.0);\n\t\t//unrolling this manually to avoid some platform for loop slow\n\t\t{\n\t\t\tfloat height = length(samplePoint);\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\n\t\t\tfloat lightAngle = dot(-u_DirectionLight.Direction, samplePoint) / height;\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\n\t\t\tsamplePoint += sampleRay;\n\t\t}\n\t\t{\n\t\t\tfloat height = length(samplePoint);\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\n\t\t\tfloat lightAngle = dot(-u_DirectionLight.Direction, samplePoint) / height;\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\n\t\t\tsamplePoint += sampleRay;\n\t\t}\n\n\t\t// Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\n\t\tcIn = frontColor * (invWavelength * krESun);\n\t\tcOut = frontColor * kmESun;\n\t} else {// Ground\n\t\tfar = (-cameraHeight) / (min(-0.001, eyeRay.y));\n\t\tvec3 pos = cameraPos + far * eyeRay;\n\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\n\t\tfloat depth = exp((-cameraHeight) * (1.0/scaleDepth));\n\t\tfloat cameraAngle = dot(-eyeRay, pos);\n\t\tfloat lightAngle = dot(-u_DirectionLight.Direction, pos);\n\t\tfloat cameraScale = scaleAngle(cameraAngle);\n\t\tfloat lightScale = scaleAngle(lightAngle);\n\t\tfloat cameraOffset = depth*cameraScale;\n\t\tfloat temp = lightScale + cameraScale;\n\n\t\t// Initialize the scattering loop variables\n\t\tfloat sampleLength = far / samples;\n\t\tfloat scaledLength = sampleLength * scale;\n\t\tvec3 sampleRay = eyeRay * sampleLength;\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n\t\t// Now loop through the sample rays\n\t\tvec3 frontColor = vec3(0.0, 0.0, 0.0);\n\t\tvec3 attenuate;\n\n\t\t// Loop removed because we kept hitting SM2.0 temp variable limits. Doesn't affect the image too much.\n\t\t{\n\t\t\tfloat height = length(samplePoint);\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\n\t\t\tfloat scatter = depth*temp - cameraOffset;\n\t\t\tattenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\n\t\t\tsamplePoint += sampleRay;\n\t\t}\n\n\t\tcIn = frontColor * (invWavelength * krESun + kmESun);\n\t\tcOut = clamp(attenuate, 0.0, 1.0);\n\t}\n\n\t#ifdef SUN_HIGH_QUALITY\n\t\tv_Vertex = -a_Position.xyz;\n\t#elif defined(SUN_SIMPLE) \n\t\tv_RayDir = -eyeRay;\n\t#else\n\t\tv_SkyGroundFactor = -eyeRay.y / SKY_GROUND_THRESHOLD;\n\t#endif\n\n\t// if we want to calculate color in vprog:\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)\n\tv_GroundColor = u_Exposure * (cIn + u_GroundTint*u_GroundTint * cOut);//u_GroundColor*u_GroundColor is gamma space convert to linear space\n\tv_SkyColor = u_Exposure * (cIn * getRayleighPhase(-u_DirectionLight.Direction, -eyeRay));\n\n\t\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.\n\t// This matching was done using the Unity3D standard shader BRDF1 on the 5/31/2017\n\t// Finally we want the sun to be always bright even in LDR thus the normalization of the lightColor for low intensity.\n\tfloat lightColorIntensity = clamp(length(u_DirectionLight.Color), 0.25, 1.0);\n\n\t#ifdef SUN_HIGH_QUALITY \n\t\tv_SunColor = HDSundiskIntensityFactor * clamp(cOut,0.0,1.0) * u_DirectionLight.Color / lightColorIntensity;\n\t#elif defined(SUN_SIMPLE) \n\t\tv_SunColor = simpleSundiskIntensityFactor * clamp(cOut * sunScale,0.0,1.0) * u_DirectionLight.Color / lightColorIntensity;\n\t#endif\n\tgl_Position=remapGLPositionZ(gl_Position);\n}\n",t='#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Lighting.glsl";\n\nconst float MIE_G = -0.990;\nconst float MIE_G2 = 0.9801;\nconst float SKY_GROUND_THRESHOLD = 0.02;\n\nuniform float u_SunSize;\nuniform float u_SunSizeConvergence;\nuniform DirectionLight u_DirectionLight;\n\n\nvarying vec3 v_GroundColor;\nvarying vec3 v_SkyColor;\n\n\n#ifdef SUN_HIGH_QUALITY\n\tvarying vec3 v_Vertex;\n#elif defined(SUN_SIMPLE)\n\tvarying vec3 v_RayDir;\n#else\n\tvarying float v_SkyGroundFactor;\n#endif\n\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\n\tvarying vec3 v_SunColor;\n#endif\n\n// Calculates the Mie phase function\nfloat getMiePhase(float eyeCos, float eyeCos2) {\n\tfloat temp = 1.0 + MIE_G2 - 2.0 * MIE_G * eyeCos;\n\ttemp = pow(temp, pow(u_SunSize,0.65) * 10.0);\n\ttemp = max(temp,1.0e-4); // prevent division by zero, esp. in half precision\n\ttemp = 1.5 * ((1.0 - MIE_G2) / (2.0 + MIE_G2)) * (1.0 + eyeCos2) / temp;\n\treturn temp;\n}\n\n// Calculates the sun shape\nfloat calcSunAttenuation(vec3 lightPos, vec3 ray) {\n\t#ifdef SUN_HIGH_QUALITY\n\t\tfloat focusedEyeCos = pow(clamp(dot(lightPos, ray),0.0,1.0), u_SunSizeConvergence);\n\t\treturn getMiePhase(-focusedEyeCos, focusedEyeCos * focusedEyeCos);\n\t#else //SUN_SIMPLE\n\t\tvec3 delta = lightPos - ray;\n\t\tfloat dist = length(delta);\n\t\tfloat spot = 1.0 - smoothstep(0.0, u_SunSize, dist);\n\t\treturn spot * spot;\n\t#endif\n}\n\nvoid main() {\n\t// if y > 1 [eyeRay.y < -SKY_GROUND_THRESHOLD] - ground\n\t// if y >= 0 and < 1 [eyeRay.y <= 0 and > -SKY_GROUND_THRESHOLD] - horizon\n\t// if y < 0 [eyeRay.y > 0] - sky\n\tvec3 col = vec3(0.0, 0.0, 0.0);\n\n\t#ifdef SUN_HIGH_QUALITY\n\t\tvec3 ray = normalize(v_Vertex);\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\n\t#elif defined(SUN_SIMPLE) \n\t\tvec3 ray = v_RayDir;\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\t\n\t#else\n\t\tfloat y = v_SkyGroundFactor;\n\t#endif\n\n\t// if we did precalculate color in vprog: just do lerp between them\n\tcol = mix(v_SkyColor, v_GroundColor, clamp(y,0.0,1.0));\n\n\t#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\n\t\tif (y < 0.0)\n\t\t\tcol += v_SunColor * calcSunAttenuation(-u_DirectionLight.Direction, -ray);\n\t#endif\n\n\tcol = sqrt(col);//linear space convert to gamma space\n\tgl_FragColor=vec4(col,1.0);\n}\n\n',a=At.add("SkyBoxProcedural"),o=new de(n,i,null,ui.shaderDefines),a.addSubShader(o),o.addShaderPass(e,t),n={a_Position:0,a_Normal:3,a_Texcoord0:2},i={u_MvpMatrix:2,u_WorldMat:2,u_CameraPos:3,u_LightmapScaleOffset:2,u_LightMap:2,u_SplatAlphaTexture:1,u_DiffuseTexture1:1,u_DiffuseTexture2:1,u_DiffuseTexture3:1,u_DiffuseTexture4:1,u_DiffuseTexture5:1,u_DiffuseScaleOffset1:1,u_DiffuseScaleOffset2:1,u_DiffuseScaleOffset3:1,u_DiffuseScaleOffset4:1,u_DiffuseScaleOffset5:1,u_FogStart:4,u_FogRange:4,u_FogColor:4,"u_DirectionLight.Direction":4,"u_DirectionLight.Color":4,"u_PointLight.Position":4,"u_PointLight.Range":4,"u_PointLight.Attenuation":4,"u_PointLight.Color":4,"u_SpotLight.Position":4,"u_SpotLight.Direction":4,"u_SpotLight.Range":4,"u_SpotLight.Spot":4,"u_SpotLight.Color":4,u_AmbientColor:4,u_shadowMap1:4,u_shadowMap2:4,u_shadowMap3:4,u_shadowPSSMDistance:4,u_lightShadowVP:4,u_shadowPCFoffset:4},r={s_Cull:0,s_Blend:1,s_BlendSrc:2,s_BlendDst:3,s_DepthTest:12,s_DepthWrite:13},e='#include "Lighting.glsl";\n\nattribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\n\nvarying vec2 v_Texcoord0;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n\tattribute vec3 a_Normal;\n\tvarying vec3 v_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\tuniform mat4 u_WorldMat;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#ifdef LIGHTMAP\n\tvarying vec2 v_LightMapUV;\n\tuniform vec4 u_LightmapScaleOffset;\n#endif\n\n#ifdef RECEIVESHADOW\n\tvarying float v_posViewZ;\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n#endif\n\nvoid main()\n{\n\tgl_Position = u_MvpMatrix * a_Position;\n \n\tv_Texcoord0 = a_Texcoord0;\n \n\t#ifdef LIGHTMAP\n\t\tv_LightMapUV = vec2(a_Texcoord0.x, 1.0 - a_Texcoord0.y) * u_LightmapScaleOffset.xy + u_LightmapScaleOffset.zw;\n\t\tv_LightMapUV.y = 1.0 - v_LightMapUV.y;\n\t#endif\n \n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tv_Normal = a_Normal;\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\n\t#endif\n\n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n\tgl_Position=remapGLPositionZ(gl_Position);\n}',t='#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Lighting.glsl";\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tuniform vec3 u_CameraPos;\n\tvarying vec3 v_Normal;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#ifdef FOG\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\tuniform vec3 u_FogColor;\n#endif\n\n\n#ifdef DIRECTIONLIGHT\n\tuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n\tuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n\tuniform SpotLight u_SpotLight;\n#endif\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\nvarying float v_posViewZ;\n\nuniform vec3 u_AmbientColor;\n\nuniform sampler2D u_SplatAlphaTexture;\n\nuniform sampler2D u_DiffuseTexture1;\nuniform sampler2D u_DiffuseTexture2;\nuniform sampler2D u_DiffuseTexture3;\nuniform sampler2D u_DiffuseTexture4;\nuniform sampler2D u_DiffuseTexture5;\n\nuniform vec4 u_DiffuseScaleOffset1;\nuniform vec4 u_DiffuseScaleOffset2;\nuniform vec4 u_DiffuseScaleOffset3;\nuniform vec4 u_DiffuseScaleOffset4;\nuniform vec4 u_DiffuseScaleOffset5;\n\nvarying vec2 v_Texcoord0;\n\n#ifdef LIGHTMAP\n\tuniform sampler2D u_LightMap;\n\tvarying vec2 v_LightMapUV;\n#endif\n\nvoid main()\n{\n\tvec4 splatAlpha = vec4(1.0);\n\t#ifdef ExtendTerrain_DETAIL_NUM1\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r;\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM2\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * (1.0 - splatAlpha.r);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM3\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * (1.0 - splatAlpha.r - splatAlpha.g);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM4\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM5\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n\t\tvec4 color5 = texture2D(u_DiffuseTexture5, v_Texcoord0 * u_DiffuseScaleOffset5.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * splatAlpha.a + color5.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b - splatAlpha.a);\n\t#endif\n\t\tgl_FragColor.w = splatAlpha.a;\n\t\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n vec3 normal = v_Normal;\n\tvec3 dif, spe;\n#endif\n\nvec3 diffuse = vec3(0.0);\nvec3 specular= vec3(0.0);\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tvec3 toEye;\n\t#ifdef FOG\n\t\ttoEye=u_CameraPos-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t#else\n\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\n\t#endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n\tLayaAirBlinnPhongDiectionLight(vec3(0.0), 1.0, normal, vec3(1.0), toEye,u_DirectionLight, dif, spe);\n\tdiffuse+=dif;\n\tspecular+=spe;\n#endif\n \n#ifdef POINTLIGHT\n\tLayaAirBlinnPhongPointLight(v_PositionWorld, vec3(0.0), 1.0, normal, vec3(1.0), toEye, u_PointLight, dif, spe);\n\tdiffuse+=dif;\n\tspecular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\n\tLayaAirBlinnPhongSpotLight(v_PositionWorld, vec3(0.0), 1.0, normal, vec3(1.0), toEye, u_SpotLight, dif, spe);\n\tdiffuse+=dif;\n\tspecular+=spe;\n#endif\n\nvec3 globalDiffuse = u_AmbientColor;\n#ifdef LIGHTMAP\n\tglobalDiffuse += DecodeLightmap(texture2D(u_LightMap, v_LightMapUV));\n#endif\n\n#ifdef RECEIVESHADOW\n\tfloat shadowValue = 1.0;\n\t#ifdef SHADOWMAP_PSSM3\n\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif\n\t#ifdef SHADOWMAP_PSSM2\n\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif \n\t#ifdef SHADOWMAP_PSSM1\n\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t#endif\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse) * shadowValue, gl_FragColor.a);\n#else\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse), gl_FragColor.a);\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t#ifdef RECEIVESHADOW\n\t\tgl_FragColor.rgb += specular * shadowValue;\n\t#else\n\t\tgl_FragColor.rgb += specular;\n\t#endif\n#endif\n\n#ifdef FOG\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n#endif\n}\n\n\n\n\n\n',a=At.add("ExtendTerrain"),o=new de(n,i,Jn.shaderDefines,ri.shaderDefines),a.addSubShader(o),o.addShaderPass(e,t,r),n={a_Position:0,a_OffsetVector:1,a_Texcoord0X:4,a_Texcoord0Y:3,a_BirthTime:2},i={u_MvpMatrix:2,u_View:3,u_Projection:3,u_TilingOffset:1,u_MainTexture:1,u_MainColor:1,u_CurTime:2,u_LifeTime:2,u_WidthCurve:2,u_WidthCurveKeyLength:2,u_GradientColorkey:2,u_GradientAlphakey:2},r={s_Cull:0,s_Blend:1,s_BlendSrc:2,s_BlendDst:3,s_DepthTest:12,s_DepthWrite:13},e='#include "Lighting.glsl";\n\nattribute vec3 a_Position;\nattribute vec3 a_OffsetVector;\nattribute vec4 a_Color;\nattribute float a_Texcoord0X;\nattribute float a_Texcoord0Y;\nattribute float a_BirthTime;\n\nuniform mat4 u_View;\nuniform mat4 u_Projection;\n\nuniform vec4 u_TilingOffset;\n\nuniform float u_CurTime;\nuniform float u_LifeTime;\nuniform vec4 u_WidthCurve[10];\nuniform int u_WidthCurveKeyLength;\n\nuniform vec4 u_GradientColorkey[10];\nuniform vec2 u_GradientAlphakey[10];\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\n{\n\tfloat t2 = t * t;\n\tfloat t3 = t2 * t;\n\tfloat a = 2.0 * t3 - 3.0 * t2 + 1.0;\n\tfloat b = t3 - 2.0 * t2 + t;\n\tfloat c = t3 - t2;\n\tfloat d = -2.0 * t3 + 3.0 * t2;\n\treturn a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\n}\n\nfloat getCurWidth(in float normalizeTime)\n{\n\tfloat width;\n\tif(normalizeTime == 0.0){\n\t\twidth=u_WidthCurve[0].w;\n\t}\n\telse if(normalizeTime >= 1.0){\n\t\twidth=u_WidthCurve[u_WidthCurveKeyLength - 1].w;\n\t}\n\telse{\n\t\tfor(int i = 0; i < 10; i ++ )\n\t\t{\n\t\t\tif(normalizeTime == u_WidthCurve[i].x){\n\t\t\t\twidth=u_WidthCurve[i].w;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tvec4 lastFrame = u_WidthCurve[i];\n\t\t\tvec4 nextFrame = u_WidthCurve[i + 1];\n\t\t\tif(normalizeTime > lastFrame.x && normalizeTime < nextFrame.x)\n\t\t\t{\n\t\t\t\tfloat duration = nextFrame.x - lastFrame.x;\n\t\t\t\tfloat t = (normalizeTime - lastFrame.x) / duration;\n\t\t\t\tfloat outTangent = lastFrame.z;\n\t\t\t\tfloat inTangent = nextFrame.y;\n\t\t\t\tfloat value1 = lastFrame.w;\n\t\t\t\tfloat value2 = nextFrame.w;\n\t\t\t\twidth=hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn width;\n}\t\n\nvec4 getColorFromGradientByBlend(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tfloat colorKey = gradientColor.x;\n\t\tif(colorKey >= normalizeTime)\n\t\t{\n\t\t\tvec4 lastGradientColor = gradientColors[i-1];\n\t\t\tfloat lastColorKey = lastGradientColor.x;\n\t\t\tfloat age = (normalizeTime - lastColorKey) / (colorKey - lastColorKey);\n\t\t\tcolor.rgb = mix(gradientColors[i-1].yzw, gradientColor.yzw, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tfloat alphaKey = gradientAlpha.x;\n\t\tif(alphaKey >= normalizeTime)\n\t\t{\n\t\t\tvec2 lastGradientAlpha = gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey = lastGradientAlpha.x;\n\t\t\tfloat age = (normalizeTime - lastAlphaKey) / (alphaKey - lastAlphaKey);\n\t\t\tcolor.a = mix(lastGradientAlpha.y, gradientAlpha.y, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvec4 getColorFromGradientByFixed(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tif(gradientColor.w >= normalizeTime)\n\t\t{\n\t\t\tcolor.rgb = gradientColor.xyz;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tif(gradientAlpha.y >= normalizeTime)\n\t\t{\n\t\t\tcolor.a = gradientAlpha.x;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvoid main()\n{\n\tfloat normalizeTime = (u_CurTime - a_BirthTime) / u_LifeTime;\n\t\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, 1.0 - a_Texcoord0Y) * u_TilingOffset.xy + u_TilingOffset.zw;\n\t#else\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\n\t#endif\n\t\n\t#ifdef GRADIENTMODE_BLEND\n\t\tv_Color = getColorFromGradientByBlend(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n\t#else\n\t\tv_Color = getColorFromGradientByFixed(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n\t#endif\n\t\n\tgl_Position = u_Projection * u_View * vec4(a_Position + a_OffsetVector * getCurWidth(normalizeTime),1.0);\n\tgl_Position=remapGLPositionZ(gl_Position);\n}\n',t="#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nuniform sampler2D u_MainTexture;\nuniform vec4 u_MainColor;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nvoid main()\n{\t\n\tvec4 color = 2.0 * u_MainColor * v_Color;\n\t#ifdef MAINTEXTURE\n\t\tvec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t\tcolor *= mainTextureColor;\n\t#endif\n\tgl_FragColor = color;\n}\n\n",a=At.add("Trail"),o=new de(n,i,gi.shaderDefines,$n.shaderDefines),a.addSubShader(o),o.addShaderPass(e,t,r),n={a_Position:0,a_Normal:3,a_Tangent0:4},i={u_MvpMatrix:2,u_WorldMat:2,u_CameraPos:3,u_Time:4,u_MainTexture:1,u_NormalTexture:1,u_HorizonColor:1,u_WaveScale:1,u_WaveSpeed:1},e='#include "Lighting.glsl";\n\nattribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\nuniform float u_WaveScale;\nuniform vec4 u_WaveSpeed;\nuniform float u_Time;\n\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\nvoid main()\n{\n\tvec4 positionWorld = u_WorldMat * a_Position;\n\tvec4 position = u_MvpMatrix * a_Position;\n\t\n\tvec4 temp = vec4(positionWorld.x, positionWorld.z, positionWorld.x, positionWorld.z) * u_WaveScale + u_WaveSpeed * u_WaveScale * u_Time;\n\t\n\tv_Texcoord0 = temp.xy * vec2(0.4, 0.45);\n\tv_Texcoord1 = temp.wz;\n\t\n\tmat3 worldMat = mat3(u_WorldMat);\n\tv_Normal = worldMat * a_Normal;\n\tv_Tangent = worldMat * a_Tangent0.xyz;\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\n\t\n\tv_ViewDir = u_CameraPos - positionWorld.xyz;\n\tgl_Position = position;\n\tgl_Position=remapGLPositionZ(gl_Position);\n}',t='#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#ifdef MAINTEXTURE\n\tuniform sampler2D u_MainTexture;\n#endif\n\n#ifdef NORMALTEXTURE\n\tuniform sampler2D u_NormalTexture;\n#endif\n\nuniform vec4 u_HorizonColor;\n\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\n#include "Lighting.glsl"\n\nvoid main()\n{\n\tvec4 bumpColor1 = texture2D(u_NormalTexture, v_Texcoord0);\n\tvec4 bumpColor2 = texture2D(u_NormalTexture, v_Texcoord1);\n\t\n\tvec3 normal1 = NormalSampleToWorldSpace1(bumpColor1, v_Tangent, v_Binormal, v_Normal);\n\tvec3 normal2 = NormalSampleToWorldSpace1(bumpColor2, v_Tangent, v_Binormal, v_Normal);\n\t\n\tvec3 normal = normalize((normal1 + normal2) * 0.5);\n\tvec3 viewDir = normalize(v_ViewDir);\n\tfloat fresnel = dot(viewDir, normal);\n\t\n\tvec4 waterColor = texture2D(u_MainTexture, vec2(fresnel, fresnel));\n\t\n\tvec4 color;\n\tcolor.rgb = mix(waterColor.rgb, u_HorizonColor.rgb, vec3(waterColor.a));\n\tcolor.a = u_HorizonColor.a;\n\t\n\tgl_FragColor = color;\n}\n\n',a=At.add("WaterPrimary"),o=new de(n,i,null,ai.shaderDefines),a.addSubShader(o),o.addShaderPass(e,t),n={a_PositionTexcoord:0},i={u_ScreenTexture:1},e='#include "Lighting.glsl";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n\tv_Texcoord0 = a_PositionTexcoord.zw;\n\tgl_Position = remapGLPositionZ(gl_Position);\n}',t="#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nuniform sampler2D u_ScreenTexture;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_FragColor = texture2D(u_ScreenTexture, v_Texcoord0);\n}\n\n",a=At.add("ScreenQuad"),o=new de(n,i,null,null),a.addSubShader(o);var s=o.addShaderPass(e,t),l=s.renderState;l.depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0,n={a_PositionTexcoord:0},i={u_MainTex:1,u_BloomTex:1,u_AutoExposureTex:1,u_MainTex_TexelSize:1,u_SampleScale:1,u_Threshold:1,u_Params:1},a=At.add("PostProcessBloom",n,i),o=new de(null,null,null,null),a.addSubShader(o),(l=(s=o.addShaderPass('#include "Lighting.glsl";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n\tv_Texcoord0 = a_PositionTexcoord.zw;\n\tgl_Position = remapGLPositionZ(gl_Position);\n}','#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Colors.glsl";\n#include "Sampling.glsl";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_AutoExposureTex;\nuniform vec4 u_MainTex_TexelSize;\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\nuniform vec4 u_Params; // x: clamp, yzw: unused\n\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\n\tcolor *= autoExposure;\n\tcolor = min(vec4(u_Params.x), color); // clamp to max\n\tcolor = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\n\treturn color;\n}\n\nvoid fragPrefilter13() {\n\tmediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n\tgl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\n}\n\nvoid main() {\n\tfragPrefilter13();\n}')).renderState).depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0,o=new de(null,null,null,null),a.addSubShader(o),(l=(s=o.addShaderPass('#include "Lighting.glsl";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n\tv_Texcoord0 = a_PositionTexcoord.zw;\n\tgl_Position = remapGLPositionZ(gl_Position);\n}','#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Colors.glsl";\n#include "Sampling.glsl";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_AutoExposureTex;\nuniform vec4 u_MainTex_TexelSize;\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\nuniform vec4 u_Params; // x: clamp, yzw: unused\n\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\n\tcolor *= autoExposure;\n\tcolor = min(vec4(u_Params.x), color); // clamp to max\n\tcolor = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\n\treturn color;\n}\n\nvoid fragPrefilter4() {\n\tmediump vec4 color = downsampleBox4Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n\tgl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\n}\n\nvoid main() {\n\tfragPrefilter4();\n}')).renderState).depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0,o=new de(null,null,null,null),a.addSubShader(o),(l=(s=o.addShaderPass('#include "Lighting.glsl";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n\tv_Texcoord0 = a_PositionTexcoord.zw;\n\tgl_Position = remapGLPositionZ(gl_Position);\n}','#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Colors.glsl";\n#include "Sampling.glsl";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform vec4 u_MainTex_TexelSize;\n\nvoid fragDownsample13() {\n\tmediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n\tgl_FragColor = color;\n}\n\nvoid main() {\n\tfragDownsample13();\n}')).renderState).depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0,o=new de(null,null,null,null),a.addSubShader(o),(l=(s=o.addShaderPass('#include "Lighting.glsl";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n\tv_Texcoord0 = a_PositionTexcoord.zw;\n\tgl_Position = remapGLPositionZ(gl_Position);\n}','#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Colors.glsl";\n#include "Sampling.glsl";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_BloomTex;\n\nuniform vec4 u_MainTex_TexelSize;\nuniform float u_SampleScale;\n\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\n\tmediump vec4 color = texture2D(u_BloomTex, uv);\n\treturn bloom + color;\n}\n\nvoid fragUpsampleTent() {\n\tmediump vec4 bloom = UpsampleTent(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, u_SampleScale);\n\tgl_FragColor = combine(bloom, v_Texcoord0);\n}\n\nvoid main() {\n\tfragUpsampleTent();\n}')).renderState).depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0,o=new de(null,null,null,null),a.addSubShader(o),(l=(s=o.addShaderPass('#include "Lighting.glsl";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n\tv_Texcoord0 = a_PositionTexcoord.zw;\n\tgl_Position = remapGLPositionZ(gl_Position);\n}','#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Colors.glsl";\n#include "Sampling.glsl";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_BloomTex;\n\nuniform vec4 u_MainTex_TexelSize;\nuniform float u_SampleScale;\n\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\n\tmediump vec4 color = texture2D(u_BloomTex, uv);\n\treturn bloom + color;\n}\n\nvoid fragUpsampleBox() {\n\tmediump vec4 bloom = upsampleBox(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, vec4(u_SampleScale));\n\tgl_FragColor = combine(bloom, v_Texcoord0);\n}\n\nvoid main() {\n\tfragUpsampleBox();\n}')).renderState).depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0,o=new de(null,null,null,null),a.addSubShader(o),(l=(s=o.addShaderPass('#include "Lighting.glsl";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n\tv_Texcoord0 = a_PositionTexcoord.zw;\n\tgl_Position = remapGLPositionZ(gl_Position);\n}','#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Colors.glsl";\n#include "Sampling.glsl";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_AutoExposureTex;\nuniform vec4 u_MainTex_TexelSize;\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\nuniform vec4 u_Params; // x: clamp, yzw: unused\n\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\n\tcolor *= autoExposure;\n\tcolor = min(vec4(u_Params.x), color); // clamp to max\n\tcolor = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\n\treturn color;\n}\n\nvoid fragPrefilter13() {\n\tmediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n\tgl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\n}\n\nvoid main() {\n\tfragPrefilter13();\n}')).renderState).depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0,n={a_PositionTexcoord:0},i={u_MainTex:1,u_BloomTex:1,u_AutoExposureTex:1,u_Bloom_DirtTex:1,u_BloomTex_TexelSize:1,u_Bloom_Settings:1,u_Bloom_Color:1},a=At.add("PostProcessComposite",n,i),o=new de(null,null,null,je.shaderDefines),a.addSubShader(o),(l=(s=o.addShaderPass("attribute vec4 a_Position;\nvarying vec2 v_Texcoord0;\n\nvec2 TransformTriangleVertexToUV(vec2 vertex)\n{\n vec2 uv = (vertex + 1.0) * 0.5;\n return uv;\n}\n\nvoid main() {\n\tgl_Position =vec4(a_Position.xy, 0.0, 1.0);\n\tv_Texcoord0=TransformTriangleVertexToUV(a_Position.xy);\n\tgl_Position=remapGLPositionZ(gl_Position);\n}",'#include "Colors.glsl";\n#include "Sampling.glsl";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_BloomTex;\n\nuniform sampler2D u_AutoExposureTex;\nuniform sampler2D u_Bloom_DirtTex;\nuniform vec4 u_BloomTex_TexelSize;\nuniform vec4 u_Bloom_DirtTileOffset; // xy: tiling, zw: offset\nuniform mediump vec3 u_Bloom_Settings;// x: sampleScale, y: intensity, z: dirt intensity\nuniform mediump vec3 u_Bloom_Color;\n\nvoid main() {\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, v_Texcoord0).r;\n\tmediump vec4 color=vec4(0.0)\n\tcolor = texture2D(u_MainTex, v_Texcoord0);\n\t\n\tcolor = SRGBToLinear(color);\n\tcolor.rgb *= autoExposure;\n\t\n\t#if BLOOM || BLOOM_LOW\n\t{\n\t\t#if BLOOM\n\t\t\tmediump vec4 bloom = UpsampleTent(_BloomTex, uvDistorted, _BloomTex_TexelSize.xy, _Bloom_Settings.x);\n\t\t#else\n\t\t\tmediump vec4 bloom = UpsampleBox(_BloomTex, uvDistorted, _BloomTex_TexelSize.xy, _Bloom_Settings.x);\n\t\t#endif\n\n\t\t// UVs should be Distort(uv * _Bloom_DirtTileOffset.xy + _Bloom_DirtTileOffset.zw)\n\t\t// but considering we use a cover-style scale on the dirt texture the difference\n\t\t// isn\'t massive so we chose to save a few ALUs here instead in case lens distortion\n\t\t// is active\n\t\tmediump vec4 dirt = mediump vec4(SAMPLE_TEXTURE2D(_Bloom_DirtTex, sampler_Bloom_DirtTex, uvDistorted * _Bloom_DirtTileOffset.xy + _Bloom_DirtTileOffset.zw).rgb, 0.0);\n\n\t\t// Additive bloom (artist friendly)\n\t\tbloom *= _Bloom_Settings.y;\n\t\tdirt *= _Bloom_Settings.z;\n\t\tcolor += bloom * half4(_Bloom_Color, 1.0);\n\t\tcolor += dirt * bloom;\n\t}\n\t#endif\n\t\n\thalf4 output = color;\n\toutput = LinearToSRGB(output);\n\t//output.rgb = Dither(output.rgb, v_Texcoord0);//TODO:\n}')).renderState).depthTest=519,l.depthWrite=!1,l.cull=0,l.blend=0},ShaderInit3D._rangeAttenTex=null,ShaderInit3D}()),Ie=function(){function LoadModelV05(){}return r(LoadModelV05,"laya.d3.loaders.LoadModelV05"),LoadModelV05.parse=function(e,t,n,i){LoadModelV05._mesh=n,LoadModelV05._subMeshes=i,LoadModelV05._version=t,LoadModelV05._readData=e,LoadModelV05.READ_DATA(),LoadModelV05.READ_BLOCK(),LoadModelV05.READ_STRINGS();for(var r=0,a=LoadModelV05._BLOCK.count;r-Number.MIN_VALUE&&o1)return Number.NaN;var c,d,_=Picker._tempVector34;return Rt.cross(u,r,_),c=Rt.dot(e.direction,_),(c*=h)<0||l+c>1?Number.NaN:(d=Rt.dot(a,_),(d*=h)<0?Number.NaN:d)},i(Picker,["_tempVector30",function(){return this._tempVector30=new Rt},"_tempVector31",function(){return this._tempVector31=new Rt},"_tempVector32",function(){return this._tempVector32=new Rt},"_tempVector33",function(){return this._tempVector33=new Rt},"_tempVector34",function(){return this._tempVector34=new Rt}]),Picker}(),Oe=function(){function GradientDataNumber(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}r(GradientDataNumber,"laya.d3.core.particleShuriKen.module.GradientDataNumber");var e=GradientDataNumber.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.add=function(e,t){this._currentLength<8?(6===this._currentLength&&1!==e&&(e=1,console.log("GradientDataNumber warning:the forth key is be force set to 1.")),this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t):console.log("GradientDataNumber warning:data count must lessEqual than 4")},e.getKeyByIndex=function(e){return this._elements[2*e]},e.getValueByIndex=function(e){return this._elements[2*e+1]},e.getAverageValue=function(){for(var e=0,t=this._currentLength-2;e=0?(t.x=r.x,n.x=i.x):(t.x=i.x,n.x=r.x),l.y>=0?(t.y=r.y,n.y=i.y):(t.y=i.y,n.y=r.y),l.z>=0?(t.z=r.z,n.z=i.z):(t.z=i.z,n.z=r.z),vt.intersectsPlaneAndPoint(s,t)===Pt.PlaneIntersectionType_Back)return 0;vt.intersectsPlaneAndPoint(s,n)===Pt.PlaneIntersectionType_Back&&(a=2)}return a},e.containsBoundSphere=function(e){for(var t=Pt.PlaneIntersectionType_Front,n=Pt.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:n=vt.intersectsPlaneAndSphere(this._near,e);break;case 1:n=vt.intersectsPlaneAndSphere(this._far,e);break;case 2:n=vt.intersectsPlaneAndSphere(this._left,e);break;case 3:n=vt.intersectsPlaneAndSphere(this._right,e);break;case 4:n=vt.intersectsPlaneAndSphere(this._top,e);break;case 5:n=vt.intersectsPlaneAndSphere(this._bottom,e)}switch(n){case Pt.PlaneIntersectionType_Back:return 0;case Pt.PlaneIntersectionType_Intersecting:t=Pt.PlaneIntersectionType_Intersecting}}switch(t){case Pt.PlaneIntersectionType_Intersecting:return 2;default:return 1}},a(0,e,"top",function(){return this._top}),a(0,e,"matrix",function(){return this._matrix},function(e){this._matrix=e,BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}),a(0,e,"near",function(){return this._near}),a(0,e,"far",function(){return this._far}),a(0,e,"left",function(){return this._left}),a(0,e,"right",function(){return this._right}),a(0,e,"bottom",function(){return this._bottom}),BoundFrustum._getPlanesFromMatrix=function(e,t,n,i,r,a,o){var s=e.elements,l=s[0],h=s[1],u=s[2],c=s[3],d=s[4],_=s[5],f=s[6],m=s[7],p=s[8],T=s[9],S=s[10],E=s[11],v=s[12],g=s[13],x=s[14],M=s[15],y=t.normal;y.x=c+u,y.y=m+f,y.z=E+S,t.distance=M+x,t.normalize();var D=n.normal;D.x=c-u,D.y=m-f,D.z=E-S,n.distance=M-x,n.normalize();var R=i.normal;R.x=c+l,R.y=m+d,R.z=E+p,i.distance=M+v,i.normalize();var C=r.normal;C.x=c-l,C.y=m-d,C.z=E-p,r.distance=M-v,r.normalize();var I=a.normal;I.x=c-h,I.y=m-_,I.z=E-T,a.distance=M-g,a.normalize();var A=o.normal;A.x=c+h,A.y=m+_,A.z=E+T,o.distance=M+g,o.normalize()},BoundFrustum._get3PlaneInterPoint=function(e,t,n){var i=e.normal,r=t.normal,a=n.normal;Rt.cross(r,a,BoundFrustum._tempV30),Rt.cross(a,i,BoundFrustum._tempV31),Rt.cross(i,r,BoundFrustum._tempV32);var o=Rt.dot(i,BoundFrustum._tempV30),s=Rt.dot(r,BoundFrustum._tempV31),l=Rt.dot(a,BoundFrustum._tempV32);return Rt.scale(BoundFrustum._tempV30,-e.distance/o,BoundFrustum._tempV33),Rt.scale(BoundFrustum._tempV31,-t.distance/s,BoundFrustum._tempV34),Rt.scale(BoundFrustum._tempV32,-n.distance/l,BoundFrustum._tempV35),Rt.add(BoundFrustum._tempV33,BoundFrustum._tempV34,BoundFrustum._tempV36),Rt.add(BoundFrustum._tempV35,BoundFrustum._tempV36,BoundFrustum._tempV37),BoundFrustum._tempV37},i(BoundFrustum,["_tempV30",function(){return this._tempV30=new Rt},"_tempV31",function(){return this._tempV31=new Rt},"_tempV32",function(){return this._tempV32=new Rt},"_tempV33",function(){return this._tempV33=new Rt},"_tempV34",function(){return this._tempV34=new Rt},"_tempV35",function(){return this._tempV35=new Rt},"_tempV36",function(){return this._tempV36=new Rt},"_tempV37",function(){return this._tempV37=new Rt}]),BoundFrustum}(),Ne=function(){function RenderState(){this.cull=0,this.blend=0,this.srcBlend=0,this.dstBlend=0,this.srcBlendRGB=0,this.dstBlendRGB=0,this.srcBlendAlpha=0,this.dstBlendAlpha=0,this.blendConstColor=null,this.blendEquation=0,this.blendEquationRGB=0,this.blendEquationAlpha=0,this.depthTest=0,this.depthWrite=!1,this.cull=2,this.blend=0,this.srcBlend=1,this.dstBlend=0,this.srcBlendRGB=1,this.dstBlendRGB=0,this.srcBlendAlpha=1,this.dstBlendAlpha=0,this.blendConstColor=new Dt(1,1,1,1),this.blendEquation=0,this.blendEquationRGB=0,this.blendEquationAlpha=0,this.depthTest=515,this.depthWrite=!0}r(RenderState,"laya.d3.core.material.RenderState");var e=RenderState.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(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},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},RenderState.CULL_NONE=0,RenderState.CULL_FRONT=1,RenderState.CULL_BACK=2,RenderState.BLEND_DISABLE=0,RenderState.BLEND_ENABLE_ALL=1,RenderState.BLEND_ENABLE_SEPERATE=2,RenderState.BLENDPARAM_ZERO=0,RenderState.BLENDPARAM_ONE=1,RenderState.BLENDPARAM_SRC_COLOR=768,RenderState.BLENDPARAM_ONE_MINUS_SRC_COLOR=769,RenderState.BLENDPARAM_DST_COLOR=774,RenderState.BLENDPARAM_ONE_MINUS_DST_COLOR=775,RenderState.BLENDPARAM_SRC_ALPHA=770,RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA=771,RenderState.BLENDPARAM_DST_ALPHA=772,RenderState.BLENDPARAM_ONE_MINUS_DST_ALPHA=773,RenderState.BLENDPARAM_SRC_ALPHA_SATURATE=776,RenderState.BLENDEQUATION_ADD=0,RenderState.BLENDEQUATION_SUBTRACT=1,RenderState.BLENDEQUATION_REVERSE_SUBTRACT=2,RenderState.DEPTHTEST_OFF=0,RenderState.DEPTHTEST_NEVER=512,RenderState.DEPTHTEST_LESS=513,RenderState.DEPTHTEST_EQUAL=514,RenderState.DEPTHTEST_LEQUAL=515,RenderState.DEPTHTEST_GREATER=516,RenderState.DEPTHTEST_NOTEQUAL=517,RenderState.DEPTHTEST_GEQUAL=518,RenderState.DEPTHTEST_ALWAYS=519,RenderState}(),Be=function(){function StartFrame(){this._type=0,this._constant=NaN,this._constantMin=NaN,this._constantMax=NaN}r(StartFrame,"laya.d3.core.particleShuriKen.module.StartFrame");var e=StartFrame.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){var t=e;t._type=this._type,t._constant=this._constant,t._constantMin=this._constantMin,t._constantMax=this._constantMax},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,e,"constant",function(){return this._constant}),a(0,e,"type",function(){return this._type}),a(0,e,"constantMin",function(){return this._constantMin}),a(0,e,"constantMax",function(){return this._constantMax}),StartFrame.createByConstant=function(e){var t=new StartFrame;return t._type=0,t._constant=e,t},StartFrame.createByRandomTwoConstant=function(e,t){var n=new StartFrame;return n._type=1,n._constantMin=e,n._constantMax=t,n},StartFrame}(),we=function(){function Command(){}r(Command,"laya.d3.core.render.command.Command");var e=Command.prototype;return e.run=function(){},e.recover=function(){},Command}(),be=function(){function ChunkInfo(){this.alphaMap=null,this.detailID=null,this.normalMap=null}return r(ChunkInfo,"laya.d3.terrain.unit.ChunkInfo"),ChunkInfo}(),Fe=function(){function ParallelSplitShadowMap(){this._currentPSSM=-1,this._shadowMapCount=3,this._maxDistance=200,this._ratioOfDistance=1/this._shadowMapCount,this._statesDirty=!0,this._shadowMapTextureSize=1024,this._scene=null,this._PCFType=0,this._shaderValueLightVP=null,this._spiltDistance=new Array(4),this._globalParallelLightDir=new Rt(0,-1,0),this._boundingSphere=new Array(4),this._boundingBox=new Array(4),this._frustumPos=new Array(16),this._uniformDistance=new Array(4),this._logDistance=new Array(4),this._dimension=new Array(4),this._tempLookAt3=new Rt,this._tempLookAt4=new Dt,this._tempValue=new Dt,this._tempPos=new Rt,this._tempLightUp=new Rt,this._tempMin=new Dt,this._tempMax=new Dt,this._tempMatrix44=new Q,this._splitFrustumCulling=new Ve(Q.DEFAULT),this._tempScaleMatrix44=new Q,this._shadowPCFOffset=new Ct(1/1024,1/1024),this._shaderValueDistance=new Dt,this.cameras=[],this._shaderValueVPs=[];var e=0;for(e=0;e3&&(this._shadowMapCount=3),this._scene=e,this._maxDistance=t,this.shadowMapCount=r,this._globalParallelLightDir=n,this._ratioOfDistance=1/this._shadowMapCount;for(var o=0;othis._shadowMapCount)throw new Error("ParallelSplitShadowMap: beginSample invalid index");this._currentPSSM=e,this._update(t)},e.endSampler=function(e){this._currentPSSM=-1},e._calcAllLightCameraInfo=function(e){if(1===this._shadowMapCount)this._beginSampler(0,e),this.endSampler(e);else for(var t=0,n=this._shadowMapCount+1;t0?Q.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[this._currentPSSM-1],this._spiltDistance[this._currentPSSM],this._tempMatrix44):Q.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[0],this._spiltDistance[this._shadowMapCount],this._tempMatrix44),Q.multiply(this._tempMatrix44,e.viewMatrix,this._tempMatrix44),this._splitFrustumCulling.matrix=this._tempMatrix44},e._rebuildRenderInfo=function(){var e=this._shadowMapCount+1,t=0;for(this.cameras.length=e,t=0;tl.x?u.x:l.x,l.y=u.y>l.y?u.y:l.y,l.z=u.z>l.z?u.z:l.z}Dt.add(this._tempMax,this._tempMin,this._tempValue),u.x*=.5,u.y*=.5,u.z*=.5,u.w=1,Dt.transformByM4x4(this._tempValue,s.transform.worldMatrix,this._tempValue);var f=Math.abs(-this._tempMax.z),m=f>this._maxDistance?f:this._maxDistance;Rt.scale(this._globalParallelLightDir,m,this._tempPos);var p=this._tempPos;p.x=u.x-p.x,p.y=u.y-p.y,p.z=u.z-p.z,s.transform.position=this._tempPos,s.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1),Q.createOrthoOffCenter(h.x,l.x,h.y,l.y,1,m+.5*(l.z-h.z),s.projectionMatrix);var T=s.projectionViewMatrix;ParallelSplitShadowMap.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,T,this._shaderValueVPs[this._currentPSSM]),this._scene._shaderValues.setBuffer(qn.SHADOWLIGHTVIEWPROJECT,this._shaderValueLightVP)},e.setShadowMapTextureSize=function(e){e!==this._shadowMapTextureSize&&(this._shadowMapTextureSize=e,this._shadowPCFOffset.x=1/this._shadowMapTextureSize,this._shadowPCFOffset.y=1/this._shadowMapTextureSize,this._statesDirty=!0)},e.disposeAllRenderTarget=function(){for(var e=0,t=this._shadowMapCount+1;e0?e:1)<=3?e:3,this._shadowMapCount!=e){this._shadowMapCount=e,this._ratioOfDistance=1/this._shadowMapCount,this._statesDirty=!0,this._shaderValueLightVP=new Float32Array(16*e),this._shaderValueVPs.length=e;for(var t=0;t>>0)+(t>>>0),a=n+e+(r/2>>>31)>>>0,o=r>>>0;this._state0U=n,this._state0L=i;var s=0,l=0;s=(e^=s=e<<23|(-512&t)>>>9)^n,l=(t^=l=t<<23)^i;s^=e>>>18,l^=t>>>18|(262143&e)<<14;return s^=n>>>5,l^=i>>>5|(31&n)<<27,this._state1U=s,this._state1L=l,[a,o]},e.random=function(){var e=this.randomint(),t=e[0],n=1023<<20|t>>>12,i=0|(e[1]>>>12|(4095&t)<<20);return RandX._CONVERTION_BUFFER.setUint32(0,n,!1),RandX._CONVERTION_BUFFER.setUint32(4,i,!1),Ht._CONVERTION_BUFFER.getFloat64(0,!1)-1},i(RandX,["_CONVERTION_BUFFER",function(){return this._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8))},"defaultRand",function(){return this.defaultRand=new Ht([0,Date.now()/65536,0,Date.now()%65536])}])}(),function(){function Config3D(){this._defaultPhysicsMemory=128,this._editerEnvironment=!1,this.isAntialias=!0,this.isAlpha=!1,this.premultipliedAlpha=!0,this.isStencil=!0,this.octreeCulling=!1,this.octreeInitialSize=64,this.octreeMinNodeSize=2,this.octreeLooseness=1.25,this.debugFrustumCulling=!1,this.octreeInitialCenter=new Rt(0,0,0)}r(Config3D,"Config3D");var e=Config3D.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){var t=e;t._defaultPhysicsMemory=this._defaultPhysicsMemory,t._editerEnvironment=this._editerEnvironment,t.isAntialias=this.isAntialias,t.isAlpha=this.isAlpha,t.premultipliedAlpha=this.premultipliedAlpha,t.isStencil=this.isStencil,t.octreeCulling=this.octreeCulling,this.octreeInitialCenter.cloneTo(t.octreeInitialCenter),t.octreeMinNodeSize=this.octreeMinNodeSize,t.octreeLooseness=this.octreeLooseness,t.debugFrustumCulling=this.debugFrustumCulling},e.clone=function(){var e=new Config3D;return this.cloneTo(e),e},a(0,e,"defaultPhysicsMemory",function(){return this._defaultPhysicsMemory},function(e){if(e<16)throw"defaultPhysicsMemory must large than 16M";this._defaultPhysicsMemory=e}),i(Config3D,["_default",function(){return this._default=new Config3D}]),Config3D}()),Ze=function(){function RenderContext3D(){}return r(RenderContext3D,"laya.d3.core.render.RenderContext3D"),RenderContext3D.clientWidth=0,RenderContext3D.clientHeight=0,i(RenderContext3D,["_instance",function(){return this._instance=new RenderContext3D}]),RenderContext3D}(),Ke=function(){function Ray(e,t){this.origin=null,this.direction=null,this.origin=e,this.direction=t}return r(Ray,"laya.d3.math.Ray"),Ray}(),Qe=function(){function AnimationEvent(){this.time=NaN,this.eventName=null,this.params=null}return r(AnimationEvent,"laya.d3.animation.AnimationEvent"),AnimationEvent}(),je=function(){function PostProcess(){this._context=null,this._compositeShader=At.find("PostProcessComposite"),this._compositeShaderData=new st,this._compositeDefineData=new Bt,this._effects=[],this._context=new De,this._context.compositeShaderData=this._compositeShaderData,this._context.compositeDefineData=this._compositeDefineData}r(PostProcess,"laya.d3.component.PostProcess");var e=PostProcess.prototype;return e._init=function(e,t){this._context.camera=e,this._context.command=t},e._render=function(){var e=Ti.getTemporary(Ze.clientWidth,Ze.clientHeight,0,3),t=this._context.camera.getRenderTexture();this._context.command.clear(),this._context.source=e,this._context.destination=t;for(var n=0,i=this._effects.length;n=0&&e=0&&t=0;o--){var s=e[o],l=s.viewport;if(n.x>=l.x&&n.y>=l.y&&n.x<=l.width&&n.y<=l.height)if(s.viewportPointToRay(n,i),this._scene._physicsSimulation.rayCast(i,t)||0===s.clearFlag||1===s.clearFlag)break}var h=this._mouseTouch,u=h.sprite;if(t.succeeded){var c=t.collider.owner;h.sprite=c;var d=c._scripts;if(u!==c&&d)for(var _=0,f=d.length;_0){for(t=0;th._pressedLoopCount){var c=u._scripts;if(c)for(i=0,r=c.length;i-1e-6&&(r=1e-6),i.x/=r,i.y/=r,i.z/=r,n.x=(i.x+1)*this.width/2+this.x,n.y=(1-i.y)*this.height/2+this.y,n.z=i.w},e.unprojectFromMat=function(e,t,n){var i=t.elements;n.x=(e.x-this.x)/this.width*2-1,n.y=-((e.y-this.y)/this.height*2-1);var r=(this.maxDepth-this.minDepth)/2;n.z=(e.z-this.minDepth-r)/r;var a=n.x*i[3]+n.y*i[7]+n.z*i[11]+i[15];Rt.transformV3ToV3(n,t,n),1!==a&&(n.x=n.x/a,n.y=n.y/a,n.z=n.z/a)},e.unprojectFromWVP=function(e,t,n,i,r){Q.multiply(t,n,Viewport._tempMatrix4x4),i&&Q.multiply(Viewport._tempMatrix4x4,i,Viewport._tempMatrix4x4),Viewport._tempMatrix4x4.invert(Viewport._tempMatrix4x4),this.unprojectFromMat(e,Viewport._tempMatrix4x4,r)},e.cloneTo=function(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},i(Viewport,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new Q}]),Viewport}(),nt=function(){function BoundsOctree(e,t,n,i){this._initialSize=NaN,this._rootNode=null,this._looseness=NaN,this._minSize=NaN,this.count=0,this._motionObjects=new An,n>e&&(console.warn("Minimum node size must be at least as big as the initial world size. Was: "+n+" Adjusted to: "+e),n=e),this._initialSize=e,this._minSize=n,this._looseness=Math.min(Math.max(i,1),2),this._rootNode=new xt(this,null,e,t)}r(BoundsOctree,"laya.d3.core.scene.BoundsOctree");var e=BoundsOctree.prototype;return e._getMaxDepth=function(e,t){t++;var n=e._children;if(null!=n)for(var i=t,r=0,a=n.length;r=0?1:-1,n=e.y>=0?1:-1,i=e.z>=0?1:-1,r=this._rootNode,a=this._rootNode.baseLength/2,s=2*this._rootNode.baseLength,l=this._rootNode.center,h=new Rt(l.x+t*a,l.y+n*a,l.z+i*a);if(this._rootNode=new xt(this,null,s,h),r.hasAnyObjects()){for(var u=this._rootNode._bestFitChild(r.center),c=o(8,null),d=0;d<8;d++)d==u&&(r._parent=this._rootNode,c[d]=r);this._rootNode._children=c}},e.add=function(e){for(var t=0;!this._rootNode.add(e);){var n=BoundsOctree._tempVector30;if(Rt.subtract(e.bounds.getCenter(),this._rootNode.center,n),this._grow(n),++t>20)throw"Aborted Add operation as it seemed to be going on forever ("+(t-1)+") attempts at growing the octree."}this.count++},e.remove=function(e){var t=e._getOctreeNode().remove(e);return t&&this.count--,t},e.update=function(e){var t=0,n=e._getOctreeNode();if(n){for(;!n._update(e);)if(this._grow(e.bounds.getCenter()),++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},e.shrinkRootIfPossible=function(){this._rootNode=this._rootNode.shrinkIfPossible(this._initialSize)},e.addMotionObject=function(e){this._motionObjects.add(e)},e.removeMotionObject=function(e){this._motionObjects.remove(e)},e.updateMotionObjects=function(){for(var e=this._motionObjects.elements,t=0,n=this._motionObjects.length;to*o)return 0;var s=OrientedBoundBox._tempV30.x,l=OrientedBoundBox._tempV30.y,h=OrientedBoundBox._tempV30.z,u=OrientedBoundBox._tempV32.x,c=OrientedBoundBox._tempV32.y,d=OrientedBoundBox._tempV32.z;return u+o<=s&&s<=n-o&&n-u>o&&c+o<=l&&l<=i-o&&i-c>o&&d+o<=h&&h<=r-o&&r-d>o?1:2},e.containsOrientedBoundBox=function(e){var t=0,n=0;e.getCorners(OrientedBoundBox._corners);var i=this.containsPoints(OrientedBoundBox._corners);if(0!=i)return i;OrientedBoundBox._sizeAe[0]=this.extents.x,OrientedBoundBox._sizeAe[1]=this.extents.y,OrientedBoundBox._sizeAe[2]=this.extents.z,e.extents.cloneTo(OrientedBoundBox._tempV35),OrientedBoundBox._sizeBe[0]=OrientedBoundBox._tempV35.x,OrientedBoundBox._sizeBe[1]=OrientedBoundBox._tempV35.y,OrientedBoundBox._sizeBe[2]=OrientedBoundBox._tempV35.z,OrientedBoundBox._getRows(this.transformation,OrientedBoundBox._rows1),OrientedBoundBox._getRows(e.transformation,OrientedBoundBox._rows2);var r=NaN,a=NaN,o=NaN;for(t=0;t<4;t++)for(n=0;n<4;n++)3==t||3==n?(OrientedBoundBox._tempM0.setElementByRowColumn(t,n,0),OrientedBoundBox._tempM1.setElementByRowColumn(t,n,0)):(o=Rt.dot(OrientedBoundBox._rows1[t],OrientedBoundBox._rows2[n]),OrientedBoundBox._tempM0.setElementByRowColumn(t,n,o),OrientedBoundBox._tempM1.setElementByRowColumn(t,n,Math.abs(o)));for(e.getCenter(OrientedBoundBox._tempV34),this.getCenter(OrientedBoundBox._tempV36),Rt.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV36,OrientedBoundBox._tempV30),OrientedBoundBox._tempV31.x=Rt.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[0]),OrientedBoundBox._tempV31.y=Rt.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[1]),OrientedBoundBox._tempV31.z=Rt.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[2]),OrientedBoundBox._vsepAe[0]=OrientedBoundBox._tempV31.x,OrientedBoundBox._vsepAe[1]=OrientedBoundBox._tempV31.y,OrientedBoundBox._vsepAe[2]=OrientedBoundBox._tempV31.z,t=0;t<3;t++)if(OrientedBoundBox._tempV32.x=OrientedBoundBox._tempM1.getElementByRowColumn(t,0),OrientedBoundBox._tempV32.y=OrientedBoundBox._tempM1.getElementByRowColumn(t,1),OrientedBoundBox._tempV32.z=OrientedBoundBox._tempM1.getElementByRowColumn(t,2),r=OrientedBoundBox._sizeAe[t],a=Rt.dot(OrientedBoundBox._tempV35,OrientedBoundBox._tempV32),Math.abs(OrientedBoundBox._vsepAe[t])>r+a)return 0;for(n=0;n<3;n++)if(OrientedBoundBox._tempV32.x=OrientedBoundBox._tempM1.getElementByRowColumn(0,n),OrientedBoundBox._tempV32.y=OrientedBoundBox._tempM1.getElementByRowColumn(1,n),OrientedBoundBox._tempV32.z=OrientedBoundBox._tempM1.getElementByRowColumn(2,n),OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM0.getElementByRowColumn(0,n),OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM0.getElementByRowColumn(1,n),OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM0.getElementByRowColumn(2,n),r=Rt.dot(this.extents,OrientedBoundBox._tempV32),a=OrientedBoundBox._sizeBe[n],Math.abs(Rt.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV33))>r+a)return 0;for(t=0;t<3;t++)for(n=0;n<3;n++){var s=(t+1)%3,l=(t+2)%3,h=(n+1)%3,u=(n+2)%3;if(r=OrientedBoundBox._sizeAe[s]*OrientedBoundBox._tempM1.getElementByRowColumn(l,n)+OrientedBoundBox._sizeAe[l]*OrientedBoundBox._tempM1.getElementByRowColumn(s,n),a=OrientedBoundBox._sizeBe[h]*OrientedBoundBox._tempM1.getElementByRowColumn(t,u)+OrientedBoundBox._sizeBe[u]*OrientedBoundBox._tempM1.getElementByRowColumn(t,h),Math.abs(OrientedBoundBox._vsepAe[l]*OrientedBoundBox._tempM0.getElementByRowColumn(s,n)-OrientedBoundBox._vsepAe[s]*OrientedBoundBox._tempM0.getElementByRowColumn(l,n))>r+a)return 0}return 2},e.containsLine=function(e,t){OrientedBoundBox._corners[0]=e,OrientedBoundBox._corners[1]=t;var n=this.containsPoints(OrientedBoundBox._corners);if(0!=n)return n;var i=this.extents.x,r=this.extents.y,a=this.extents.z;this.transformation.invert(OrientedBoundBox._tempM0),Rt.transformCoordinate(e,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30),Rt.transformCoordinate(t,OrientedBoundBox._tempM0,OrientedBoundBox._tempV31),Rt.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32),Rt.scale(OrientedBoundBox._tempV32,.5,OrientedBoundBox._tempV32),Rt.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV32,OrientedBoundBox._tempV33);var o=OrientedBoundBox._tempV33.x,s=OrientedBoundBox._tempV33.y,l=OrientedBoundBox._tempV33.z,h=OrientedBoundBox._tempV34.x=Math.abs(OrientedBoundBox._tempV33.x),u=OrientedBoundBox._tempV34.y=Math.abs(OrientedBoundBox._tempV33.y),c=OrientedBoundBox._tempV34.z=Math.abs(OrientedBoundBox._tempV33.z),d=OrientedBoundBox._tempV32.x,_=OrientedBoundBox._tempV32.y,f=OrientedBoundBox._tempV32.z;return Math.abs(d)>i+h?0:Math.abs(_)>r+u?0:Math.abs(f)>a+c?0:Math.abs(_*l-f*s)>r*c+a*u?0:Math.abs(d*l-f*o)>i*c+a*h?0:Math.abs(d*s-_*o)>i*u+r*h?0:2},e.containsBoundBox=function(e){var t=0,n=0,i=e.min,r=e.max;e.getCorners(OrientedBoundBox._corners);var a=this.containsPoints(OrientedBoundBox._corners);if(0!=a)return a;Rt.subtract(r,i,OrientedBoundBox._tempV30),Rt.scale(OrientedBoundBox._tempV30,.5,OrientedBoundBox._tempV30),Rt.add(i,OrientedBoundBox._tempV30,OrientedBoundBox._tempV30),Rt.subtract(r,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31),OrientedBoundBox._sizeAe[0]=this.extents.x,OrientedBoundBox._sizeAe[1]=this.extents.y,OrientedBoundBox._sizeAe[2]=this.extents.z,OrientedBoundBox._sizeBe[0]=OrientedBoundBox._tempV31.x,OrientedBoundBox._sizeBe[1]=OrientedBoundBox._tempV31.y,OrientedBoundBox._sizeBe[2]=OrientedBoundBox._tempV31.z,OrientedBoundBox._getRows(this.transformation,OrientedBoundBox._rows1),this.transformation.invert(OrientedBoundBox._tempM0);var o=NaN,s=NaN;for(t=0;t<3;t++)for(n=0;n<3;n++)OrientedBoundBox._tempM1.setElementByRowColumn(t,n,Math.abs(OrientedBoundBox._tempM0.getElementByRowColumn(t,n)));for(this.getCenter(OrientedBoundBox._tempV35),Rt.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV35,OrientedBoundBox._tempV32),OrientedBoundBox._tempV31.x=Rt.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[0]),OrientedBoundBox._tempV31.y=Rt.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[1]),OrientedBoundBox._tempV31.z=Rt.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[2]),OrientedBoundBox._vsepAe[0]=OrientedBoundBox._tempV31.x,OrientedBoundBox._vsepAe[1]=OrientedBoundBox._tempV31.y,OrientedBoundBox._vsepAe[2]=OrientedBoundBox._tempV31.z,t=0;t<3;t++)if(OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM1.getElementByRowColumn(t,0),OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM1.getElementByRowColumn(t,1),OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM1.getElementByRowColumn(t,2),o=OrientedBoundBox._sizeAe[t],s=Rt.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV33),Math.abs(OrientedBoundBox._vsepAe[t])>o+s)return 0;for(n=0;n<3;n++)if(OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM1.getElementByRowColumn(0,n),OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM1.getElementByRowColumn(1,n),OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM1.getElementByRowColumn(2,n),OrientedBoundBox._tempV34.x=OrientedBoundBox._tempM0.getElementByRowColumn(0,n),OrientedBoundBox._tempV34.y=OrientedBoundBox._tempM0.getElementByRowColumn(1,n),OrientedBoundBox._tempV34.z=OrientedBoundBox._tempM0.getElementByRowColumn(2,n),o=Rt.dot(this.extents,OrientedBoundBox._tempV33),s=OrientedBoundBox._sizeBe[n],Math.abs(Rt.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV34))>o+s)return 0;for(t=0;t<3;t++)for(n=0;n<3;n++){var l=(t+1)%3,h=(t+2)%3,u=(n+1)%3,c=(n+2)%3;if(o=OrientedBoundBox._sizeAe[l]*OrientedBoundBox._tempM1.getElementByRowColumn(h,n)+OrientedBoundBox._sizeAe[h]*OrientedBoundBox._tempM1.getElementByRowColumn(l,n),s=OrientedBoundBox._sizeBe[u]*OrientedBoundBox._tempM1.getElementByRowColumn(t,c)+OrientedBoundBox._sizeBe[c]*OrientedBoundBox._tempM1.getElementByRowColumn(t,u),Math.abs(OrientedBoundBox._vsepAe[h]*OrientedBoundBox._tempM0.getElementByRowColumn(l,n)-OrientedBoundBox._vsepAe[l]*OrientedBoundBox._tempM0.getElementByRowColumn(h,n))>o+s)return 0}return 2},e.intersectsRay=function(e,t){Rt.scale(this.extents,-1,OrientedBoundBox._tempV30),this.transformation.invert(OrientedBoundBox._tempM0),Rt.TransformNormal(e.direction,OrientedBoundBox._tempM0,OrientedBoundBox._ray.direction),Rt.transformCoordinate(e.origin,OrientedBoundBox._tempM0,OrientedBoundBox._ray.origin),OrientedBoundBox._boxBound1.min=OrientedBoundBox._tempV30,OrientedBoundBox._boxBound1.max=this.extents;var n=vt.intersectsRayAndBoxRP(OrientedBoundBox._ray,OrientedBoundBox._boxBound1,t);return-1!==n&&Rt.transformCoordinate(t,this.transformation,t),n},e._getLocalCorners=function(e){e.length=8,OrientedBoundBox._tempV30.x=this.extents.x,OrientedBoundBox._tempV31.y=this.extents.y,OrientedBoundBox._tempV32.z=this.extents.z,Rt.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33),Rt.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,e[0]),Rt.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33),Rt.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,e[1]),Rt.subtract(OrientedBoundBox._tempV31,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33),Rt.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,e[2]),Rt.subtract(OrientedBoundBox._tempV31,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33),Rt.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,e[3]),Rt.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33),Rt.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,e[4]),Rt.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33),Rt.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,e[5]),Rt.scale(e[0],-1,e[6]),Rt.subtract(OrientedBoundBox._tempV32,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33),Rt.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV31,e[7])},e.equals=function(e){return this.extents==e.extents&&this.transformation==e.transformation},e.cloneTo=function(e){var t=e;this.extents.cloneTo(t.extents),this.transformation.cloneTo(t.transformation)},OrientedBoundBox.createByBoundBox=function(e,t){var n=e.min,i=e.max;Rt.subtract(i,n,OrientedBoundBox._tempV30),Rt.scale(OrientedBoundBox._tempV30,.5,OrientedBoundBox._tempV30),Rt.add(n,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31),Rt.subtract(i,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32),Q.translation(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0);var r=OrientedBoundBox._tempV32.clone(),a=OrientedBoundBox._tempM0.clone();t.extents=r,t.transformation=a},OrientedBoundBox.createByMinAndMaxVertex=function(e,t){return Rt.subtract(t,e,OrientedBoundBox._tempV30),Rt.scale(OrientedBoundBox._tempV30,.5,OrientedBoundBox._tempV30),Rt.add(e,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31),Rt.subtract(t,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32),Q.translation(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0),new OrientedBoundBox(OrientedBoundBox._tempV32,OrientedBoundBox._tempM0)},OrientedBoundBox._getRows=function(e,t){t.length=3;var n=e.elements;t[0].x=n[0],t[0].y=n[1],t[0].z=n[2],t[1].x=n[4],t[1].y=n[5],t[1].z=n[6],t[2].x=n[8],t[2].y=n[9],t[2].z=n[10]},OrientedBoundBox.getObbtoObbMatrix4x4=function(e,t,n,i){var r=e.transformation,a=t.transformation;if(n){OrientedBoundBox._getRows(r,OrientedBoundBox._rows1),OrientedBoundBox._getRows(a,OrientedBoundBox._rows2);for(var o=0;o<3;o++)for(var s=0;s<3;s++)i.setElementByRowColumn(o,s,Rt.dot(OrientedBoundBox._rows2[o],OrientedBoundBox._rows1[s]));t.getCenter(OrientedBoundBox._tempV30),e.getCenter(OrientedBoundBox._tempV31),Rt.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);var l=i.elements;l[12]=Rt.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[0]),l[13]=Rt.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[1]),l[14]=Rt.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[2]),l[15]=1}else r.invert(OrientedBoundBox._tempM0),Q.multiply(a,OrientedBoundBox._tempM0,i)},OrientedBoundBox.merge=function(e,t,n){var i=e.extents,r=e.transformation;OrientedBoundBox.getObbtoObbMatrix4x4(e,t,n,OrientedBoundBox._tempM0),t._getLocalCorners(OrientedBoundBox._corners),Rt.transformCoordinate(OrientedBoundBox._corners[0],OrientedBoundBox._tempM0,OrientedBoundBox._corners[0]),Rt.transformCoordinate(OrientedBoundBox._corners[1],OrientedBoundBox._tempM0,OrientedBoundBox._corners[1]),Rt.transformCoordinate(OrientedBoundBox._corners[2],OrientedBoundBox._tempM0,OrientedBoundBox._corners[2]),Rt.transformCoordinate(OrientedBoundBox._corners[3],OrientedBoundBox._tempM0,OrientedBoundBox._corners[3]),Rt.transformCoordinate(OrientedBoundBox._corners[4],OrientedBoundBox._tempM0,OrientedBoundBox._corners[4]),Rt.transformCoordinate(OrientedBoundBox._corners[5],OrientedBoundBox._tempM0,OrientedBoundBox._corners[5]),Rt.transformCoordinate(OrientedBoundBox._corners[6],OrientedBoundBox._tempM0,OrientedBoundBox._corners[6]),Rt.transformCoordinate(OrientedBoundBox._corners[7],OrientedBoundBox._tempM0,OrientedBoundBox._corners[7]),Rt.scale(i,-1,OrientedBoundBox._boxBound1.min),i.cloneTo(OrientedBoundBox._boxBound1.max),mt.createfromPoints(OrientedBoundBox._corners,OrientedBoundBox._boxBound2),mt.merge(OrientedBoundBox._boxBound2,OrientedBoundBox._boxBound1,OrientedBoundBox._boxBound3);var a=OrientedBoundBox._boxBound3.min,o=OrientedBoundBox._boxBound3.max;Rt.subtract(o,a,OrientedBoundBox._tempV30),Rt.scale(OrientedBoundBox._tempV30,.5,OrientedBoundBox._tempV30),Rt.add(a,OrientedBoundBox._tempV30,OrientedBoundBox._tempV32),Rt.subtract(o,OrientedBoundBox._tempV32,i),Rt.transformCoordinate(OrientedBoundBox._tempV32,r,OrientedBoundBox._tempV33)},i(OrientedBoundBox,["_tempV30",function(){return this._tempV30=new Rt},"_tempV31",function(){return this._tempV31=new Rt},"_tempV32",function(){return this._tempV32=new Rt},"_tempV33",function(){return this._tempV33=new Rt},"_tempV34",function(){return this._tempV34=new Rt},"_tempV35",function(){return this._tempV35=new Rt},"_tempV36",function(){return this._tempV36=new Rt},"_tempM0",function(){return this._tempM0=new Q},"_tempM1",function(){return this._tempM1=new Q},"_corners",function(){return this._corners=[new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt]},"_rows1",function(){return this._rows1=[new Rt,new Rt,new Rt]},"_rows2",function(){return this._rows2=[new Rt,new Rt,new Rt]},"_ray",function(){return this._ray=new Ke(new Rt,new Rt)},"_boxBound1",function(){return this._boxBound1=new mt(new Rt,new Rt)},"_boxBound2",function(){return this._boxBound2=new mt(new Rt,new Rt)},"_boxBound3",function(){return this._boxBound3=new mt(new Rt,new Rt)},"_vsepAe",function(){return this._vsepAe=new Float32Array},"_sizeBe",function(){return this._sizeBe=new Float32Array},"_sizeAe",function(){return this._sizeAe=new Float32Array}])}(),function(){function AnimatorPlayState(){}r(AnimatorPlayState,"laya.d3.component.AnimatorPlayState");var e=AnimatorPlayState.prototype;return e._resetPlayState=function(e){this._finish=!1,this._startPlayTime=e,this._elapsedTime=e,this._playEventIndex=0,this._lastIsFront=!0},e._cloneTo=function(e){e._finish=this._finish,e._startPlayTime=this._startPlayTime,e._elapsedTime=this._elapsedTime,e._playEventIndex=this._playEventIndex,e._lastIsFront=this._lastIsFront},a(0,e,"normalizedTime",function(){return this._normalizedTime}),a(0,e,"duration",function(){return this._duration}),AnimatorPlayState}()),at=function(){function SizeOverLifetime(e){this._size=null,this.enbale=!1,this._size=e}r(SizeOverLifetime,"laya.d3.core.particleShuriKen.module.SizeOverLifetime");var e=SizeOverLifetime.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){var t=e;this._size.cloneTo(t._size),t.enbale=this.enbale},e.clone=function(){var e;switch(this._size.type){case 0:e=this._size.separateAxes?Ut.createByGradientSeparate(this._size.gradientX.clone(),this._size.gradientY.clone(),this._size.gradientZ.clone()):Ut.createByGradient(this._size.gradient.clone());break;case 1:e=this._size.separateAxes?Ut.createByRandomTwoConstantSeparate(this._size.constantMinSeparate.clone(),this._size.constantMaxSeparate.clone()):Ut.createByRandomTwoConstant(this._size.constantMin,this._size.constantMax);break;case 2:e=this._size.separateAxes?Ut.createByRandomTwoGradientSeparate(this._size.gradientXMin.clone(),this._size.gradientYMin.clone(),this._size.gradientZMin.clone(),this._size.gradientXMax.clone(),this._size.gradientYMax.clone(),this._size.gradientZMax.clone()):Ut.createByRandomTwoGradient(this._size.gradientMin.clone(),this._size.gradientMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t},a(0,e,"size",function(){return this._size}),SizeOverLifetime}(),ot=function(){function Bounds(e,t){this._updateFlag=0,this._center=new Rt,this._extent=new Rt,this._boundBox=new mt(new Rt,new Rt),e.cloneTo(this._boundBox.min),t.cloneTo(this._boundBox.max),this._setUpdateFlag(12,!0)}r(Bounds,"laya.d3.core.Bounds");var e=Bounds.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.setMin=function(e){var t=this._boundBox.min;e!==t&&e.cloneTo(t),this._setUpdateFlag(12,!0),this._setUpdateFlag(1,!1)},e.getMin=function(){var e=this._boundBox.min;return this._getUpdateFlag(1)&&(this._getMin(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(1,!1)),e},e.setMax=function(e){var t=this._boundBox.max;e!==t&&e.cloneTo(t),this._setUpdateFlag(12,!0),this._setUpdateFlag(2,!1)},e.getMax=function(){var e=this._boundBox.max;return this._getUpdateFlag(2)&&(this._getMax(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(2,!1)),e},e.setCenter=function(e){e!==this._center&&e.cloneTo(this._center),this._setUpdateFlag(3,!0),this._setUpdateFlag(4,!1)},e.getCenter=function(){return this._getUpdateFlag(4)&&(this._getCenter(this.getMin(),this.getMax(),this._center),this._setUpdateFlag(4,!1)),this._center},e.setExtent=function(e){e!==this._extent&&e.cloneTo(this._extent),this._setUpdateFlag(3,!0),this._setUpdateFlag(8,!1)},e.getExtent=function(){return this._getUpdateFlag(8)&&(this._getExtent(this.getMin(),this.getMax(),this._extent),this._setUpdateFlag(8,!1)),this._extent},e._getUpdateFlag=function(e){return 0!=(this._updateFlag&e)},e._setUpdateFlag=function(e,t){t?this._updateFlag|=e:this._updateFlag&=~e},e._getCenter=function(e,t,n){Rt.add(e,t,n),Rt.scale(n,.5,n)},e._getExtent=function(e,t,n){Rt.subtract(t,e,n),Rt.scale(n,.5,n)},e._getMin=function(e,t,n){Rt.subtract(e,t,n)},e._getMax=function(e,t,n){Rt.add(e,t,n)},e._rotateExtents=function(e,t,n){var i=e.x,r=e.y,a=e.z,o=t.elements;n.x=Math.abs(o[0]*i)+Math.abs(o[4]*r)+Math.abs(o[8]*a),n.y=Math.abs(o[1]*i)+Math.abs(o[5]*r)+Math.abs(o[9]*a),n.z=Math.abs(o[2]*i)+Math.abs(o[6]*r)+Math.abs(o[10]*a)},e._tranform=function(e,t){var n=t._center,i=t._extent;Rt.transformCoordinate(this.getCenter(),e,n),this._rotateExtents(this.getExtent(),e,i),t._boundBox.setCenterAndExtent(n,i),t._updateFlag=0},e._getBoundBox=function(){var e=this._boundBox.min;this._getUpdateFlag(1)&&(this._getMin(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(1,!1));var t=this._boundBox.max;return this._getUpdateFlag(2)&&(this._getMax(this.getCenter(),this.getExtent(),t),this._setUpdateFlag(2,!1)),this._boundBox},e.cloneTo=function(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},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},Bounds._UPDATE_MIN=1,Bounds._UPDATE_MAX=2,Bounds._UPDATE_CENTER=4,Bounds._UPDATE_EXTENT=8,Bounds}(),st=function(){function ShaderData(e){this._ownerResource=null,this._data=null,this._int32Data=null,this._float32Data=null,this._nativeArray=null,this._frameCount=0,this._runtimeCopyValues=[],this._ownerResource=e,this._initData()}r(ShaderData,"laya.d3.shader.ShaderData");var e=ShaderData.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e._initData=function(){this._data=new Object},e.getData=function(){return this._data},e.getBool=function(e){return this._data[e]},e.setBool=function(e,t){this._data[e]=t},e.getInt=function(e){return this._data[e]},e.setInt=function(e,t){this._data[e]=t},e.getNumber=function(e){return this._data[e]},e.setNumber=function(e,t){this._data[e]=t},e.getVector2=function(e){return this._data[e]},e.setVector2=function(e,t){this._data[e]=t},e.getVector3=function(e){return this._data[e]},e.setVector3=function(e,t){this._data[e]=t},e.getVector=function(e){return this._data[e]},e.setVector=function(e,t){this._data[e]=t},e.getQuaternion=function(e){return this._data[e]},e.setQuaternion=function(e,t){this._data[e]=t},e.getMatrix4x4=function(e){return this._data[e]},e.setMatrix4x4=function(e,t){this._data[e]=t},e.getBuffer=function(e){return this._data[e]},e.setBuffer=function(e,t){this._data[e]=t},e.setTexture=function(e,t){var n=this._data[e];this._data[e]=t,this._ownerResource&&this._ownerResource.referenceCount>0&&(n&&n._removeReference(),t&&t._addReference())},e.getTexture=function(e){return this._data[e]},e.setAttribute=function(e,t){this._data[e]=t},e.getAttribute=function(e){return this._data[e]},e.getLength=function(){return this._data.length},e.setLength=function(e){this._data.length=e},e.cloneTo=function(e){var t=e._data;for(var n in this._data){var i=this._data[n];if(null!=i)if("number"==typeof i)t[n]=i;else if("number"==typeof i&&Math.floor(i)==i)t[n]=i;else if("boolean"==typeof i)t[n]=i;else if(i instanceof laya.d3.math.Vector2){var r=t[n]||(t[n]=new Ct);i.cloneTo(r),t[n]=r}else if(i instanceof laya.d3.math.Vector3){var a=t[n]||(t[n]=new Rt);i.cloneTo(a),t[n]=a}else if(i instanceof laya.d3.math.Vector4){var o=t[n]||(t[n]=new Dt);i.cloneTo(o),t[n]=o}else if(i instanceof laya.d3.math.Matrix4x4){var s=t[n]||(t[n]=new Q);i.cloneTo(s),t[n]=s}else i instanceof laya.resource.BaseTexture&&(t[n]=i)}},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.cloneToForNative=function(e){var t=e;this._int32Data.length-t._int32Data.length>0&&t.needRenewArrayBufferForNative(this._int32Data.length),t._int32Data.set(this._int32Data,0);var n=t._nativeArray,i=this._nativeArray.length;n.length=i;for(var r=0;r=this._int32Data.length){var t=4*(e+1),n=this._int32Data,i=this._data.conchRef,r=this._data._ptrID;this._data=new ArrayBuffer(t),this._int32Data=new Int32Array(this._data),this._float32Data=new Float32Array(this._data),this._data.conchRef=i,this._data._ptrID=r,n&&this._int32Data.set(n,0),conch.updateArrayBufferRef(this._data._ptrID,i.isSyncToRender(),this._data)}},e.getDataForNative=function(){return this._nativeArray},e.getIntForNative=function(e){return this._int32Data[e]},e.setIntForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t,this._nativeArray[e]=t},e.getBoolForNative=function(e){return 1==this._int32Data[e]},e.setBoolForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t,this._nativeArray[e]=t},e.getNumberForNative=function(e){return this._float32Data[e]},e.setNumberForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._float32Data[e]=t,this._nativeArray[e]=t},e.getMatrix4x4ForNative=function(e){return this._nativeArray[e]},e.setMatrix4x4ForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var n=this.setReferenceForNative(t.elements);this._int32Data[e]=n},e.getVectorForNative=function(e){return this._nativeArray[e]},e.setVectorForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var n=this.setReferenceForNative(t.elements);this._int32Data[e]=n},e.getVector2ForNative=function(e){return this._nativeArray[e]},e.setVector2ForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var n=this.setReferenceForNative(t.elements);this._int32Data[e]=n},e.getVector3ForNative=function(e){return this._nativeArray[e]},e.setVector3ForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var n=this.setReferenceForNative(t.elements);this._int32Data[e]=n},e.getQuaternionForNative=function(e){return this._nativeArray[e]},e.setQuaternionForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var n=this.setReferenceForNative(t.elements);this._int32Data[e]=n},e.getBufferForNative=function(e){return this._nativeArray[e]},e.setBufferForNative=function(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var n=this.setReferenceForNative(t);this._int32Data[e]=n},e.getAttributeForNative=function(e){return this._nativeArray[e]},e.setAttributeForNative=function(e,t){this._nativeArray[e]=t,t._ptrID||E.createArrayBufferRef(t,0,!0),E.syncBufferToRenderThread(t),this._int32Data[e]=t._ptrID},e.getTextureForNative=function(e){return this._nativeArray[e]},e.setTextureForNative=function(e,t){if(t){this.needRenewArrayBufferForNative(e);var n=this._nativeArray[e];this._nativeArray[e]=t,this._int32Data[e]=t._glTexture.id,this._ownerResource&&this._ownerResource.referenceCount>0&&(n&&n._removeReference(),t&&t._addReference())}},e.setReferenceForNative=function(e){this.clearRuntimeCopyArray();var t=0,n=0;return ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_?(E.createArrayBufferRefs(e,0,!0,0),t=0,n=e.getPtrID(t)):(E.createArrayBufferRefs(e,0,!0,1),t=e.getRefNum()-1,n=e.getPtrID(t),this._runtimeCopyValues.push({obj:e,refID:t,ptrID:n})),E.syncBufferToRenderThread(e,t),n},e.clearRuntimeCopyArray=function(){var e=E.getFrameCount();if(this._frameCount!=e){this._frameCount=e;for(var t=0,n=this._runtimeCopyValues.length;t=.64&&(o>1?s=0:s*=1-(o-.64)/.36),a[r]=Math.floor(255*s+.5)},TextureGenerator.haloTexture=function(e,t,n,i,r,a){var o=(e-(n>>=1))/n,s=(t-(i>>=1))/i,l=o*o+s*s;l>1&&(l=1),a[r]=Math.floor(255*(1-l)+.5)},TextureGenerator._generateTexture2D=function(e,t,n,i){var r=0,a=0;switch(e.format){case 0:a=3;break;case 1:a=4;break;case 2:a=1;break;default:throw"GeneratedTexture._generateTexture: unkonw texture format."}for(var o=new Uint8Array(t*n*a),s=0;s0&&(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)},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.rotateX=function(e,t){e*=.5;var n=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.w*n,t.y=this.y*i+this.z*n,t.z=this.z*i-this.y*n,t.w=this.w*i-this.x*n},e.rotateY=function(e,t){e*=.5;var n=Math.sin(e),i=Math.cos(e);t.x=this.x*i-this.z*n,t.y=this.y*i+this.w*n,t.z=this.z*i+this.x*n,t.w=this.w*i-this.y*n},e.rotateZ=function(e,t){e*=.5;var n=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.y*n,t.y=this.y*i-this.x*n,t.z=this.z*i+this.w*n,t.w=this.w*i-this.z*n},e.getYawPitchRoll=function(e){Rt.transformQuat(Rt._ForwardRH,this,Quaternion.TEMPVector31),Rt.transformQuat(Rt._Up,this,Quaternion.TEMPVector32);var t=Quaternion.TEMPVector32;Quaternion.angleTo(Rt._ZERO,Quaternion.TEMPVector31,Quaternion.TEMPVector33);var n=Quaternion.TEMPVector33;n.x==Math.PI/2?(n.y=Quaternion.arcTanAngle(t.z,t.x),n.z=0):n.x==-Math.PI/2?(n.y=Quaternion.arcTanAngle(-t.z,-t.x),n.z=0):(Q.createRotationY(-n.y,Quaternion.TEMPMatrix0),Q.createRotationX(-n.x,Quaternion.TEMPMatrix1),Rt.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix0,Quaternion.TEMPVector32),Rt.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix1,Quaternion.TEMPVector32),n.z=Quaternion.arcTanAngle(t.y,-t.x)),n.y<=-Math.PI&&(n.y=Math.PI),n.z<=-Math.PI&&(n.z=Math.PI),n.y>=Math.PI&&n.z>=Math.PI&&(n.y=0,n.z=0,n.x=Math.PI-n.x);var i=e;i.x=n.y,i.y=n.x,i.z=n.z},e.invert=function(e){var t=this.x,n=this.y,i=this.z,r=this.w,a=t*t+n*n+i*i+r*r,o=a?1/a:0;e.x=-t*o,e.y=-n*o,e.z=-i*o,e.w=r*o},e.identity=function(){this.x=0,this.y=0,this.z=0,this.w=1},e.fromArray=function(e,t){void 0===t&&(t=0),this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]},e.cloneTo=function(e){this!==e&&(e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w)},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.equals=function(e){return ft.nearEqual(this.x,e.x)&&ft.nearEqual(this.y,e.y)&&ft.nearEqual(this.z,e.z)&&ft.nearEqual(this.w,e.w)},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.forNativeElement=function(e){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]),Ct.rewriteNumProperty(this,"x",0),Ct.rewriteNumProperty(this,"y",1),Ct.rewriteNumProperty(this,"z",2),Ct.rewriteNumProperty(this,"w",3)},Quaternion.createFromYawPitchRoll=function(e,t,n,i){var r=.5*n,a=.5*t,o=.5*e,s=Math.sin(r),l=Math.cos(r),h=Math.sin(a),u=Math.cos(a),c=Math.sin(o),d=Math.cos(o);i.x=d*h*l+c*u*s,i.y=c*u*l-d*h*s,i.z=d*u*s-c*h*l,i.w=d*u*l+c*h*s},Quaternion.multiply=function(e,t,n){var i=e.x,r=e.y,a=e.z,o=e.w,s=t.x,l=t.y,h=t.z,u=t.w,c=r*h-a*l,d=a*s-i*h,_=i*l-r*s,f=i*s+r*l+a*h;n.x=i*u+s*o+c,n.y=r*u+l*o+d,n.z=a*u+h*o+_,n.w=o*u-f},Quaternion.arcTanAngle=function(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},Quaternion.angleTo=function(e,t,n){Rt.subtract(t,e,Quaternion.TEMPVector30),Rt.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30),n.x=Math.asin(Quaternion.TEMPVector30.y),n.y=Quaternion.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x)},Quaternion.createFromAxisAngle=function(e,t,n){t*=.5;var i=Math.sin(t);n.x=i*e.x,n.y=i*e.y,n.z=i*e.z,n.w=Math.cos(t)},Quaternion.createFromMatrix4x4=function(e,t){var n,i,r=e.elements,a=r[0]+r[5]+r[10];a>0?(n=Math.sqrt(a+1),t.w=.5*n,n=.5/n,t.x=(r[6]-r[9])*n,t.y=(r[8]-r[2])*n,t.z=(r[1]-r[4])*n):r[0]>=r[5]&&r[0]>=r[10]?(i=.5/(n=Math.sqrt(1+r[0]-r[5]-r[10])),t.x=.5*n,t.y=(r[1]+r[4])*i,t.z=(r[2]+r[8])*i,t.w=(r[6]-r[9])*i):r[5]>r[10]?(i=.5/(n=Math.sqrt(1+r[5]-r[0]-r[10])),t.x=(r[4]+r[1])*i,t.y=.5*n,t.z=(r[9]+r[6])*i,t.w=(r[8]-r[2])*i):(i=.5/(n=Math.sqrt(1+r[10]-r[0]-r[5])),t.x=(r[8]+r[2])*i,t.y=(r[9]+r[6])*i,t.z=.5*n,t.w=(r[1]-r[4])*i)},Quaternion.slerp=function(e,t,n,i){var r,a,o,s,l,h=e.x,u=e.y,c=e.z,d=e.w,_=t.x,f=t.y,m=t.z,p=t.w;return(a=h*_+u*f+c*m+d*p)<0&&(a=-a,_=-_,f=-f,m=-m,p=-p),1-a>1e-6?(r=Math.acos(a),o=Math.sin(r),s=Math.sin((1-n)*r)/o,l=Math.sin(n*r)/o):(s=1-n,l=n),i.x=s*h+l*_,i.y=s*u+l*f,i.z=s*c+l*m,i.w=s*d+l*p,i},Quaternion.lerp=function(e,t,n,i){var r=1-n;Quaternion.dot(e,t)>=0?(i.x=r*e.x+n*t.x,i.y=r*e.y+n*t.y,i.z=r*e.z+n*t.z,i.w=r*e.w+n*t.w):(i.x=r*e.x-n*t.x,i.y=r*e.y-n*t.y,i.z=r*e.z-n*t.z,i.w=r*e.w-n*t.w),i.normalize(i)},Quaternion.add=function(e,t,n){n.x=e.x+t.x,n.y=e.y+t.y,n.z=e.z+t.z,n.w=e.w+t.w},Quaternion.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},Quaternion.rotationLookAt=function(e,t,n){Quaternion.lookAt(Rt._ZERO,e,t,n)},Quaternion.lookAt=function(e,t,n,i){H.lookAt(e,t,n,Quaternion._tempMatrix3x3),Quaternion.rotationMatrix(Quaternion._tempMatrix3x3,i)},Quaternion.invert=function(e,t){var n=e.lengthSquared();ft.isZero(n)||(n=1/n,t.x=-e.x*n,t.y=-e.y*n,t.z=-e.z*n,t.w=e.w*n)},Quaternion.rotationMatrix=function(e,t){var n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],h=n[6],u=n[7],c=n[8],d=NaN,_=NaN,f=i+s+c;f>0?(d=Math.sqrt(f+1),t.w=.5*d,d=.5/d,t.x=(l-u)*d,t.y=(h-a)*d,t.z=(r-o)*d):i>=s&&i>=c?(_=.5/(d=Math.sqrt(1+i-s-c)),t.x=.5*d,t.y=(r+o)*_,t.z=(a+h)*_,t.w=(l-u)*_):s>c?(_=.5/(d=Math.sqrt(1+s-i-c)),t.x=(o+r)*_,t.y=.5*d,t.z=(u+l)*_,t.w=(h-a)*_):(_=.5/(d=Math.sqrt(1+c-i-s)),t.x=(h+a)*_,t.y=(u+l)*_,t.z=.5*d,t.w=(r-o)*_)},Quaternion.DEFAULT=new Quaternion,i(Quaternion,["TEMPVector30",function(){return this.TEMPVector30=new Rt},"TEMPVector31",function(){return this.TEMPVector31=new Rt},"TEMPVector32",function(){return this.TEMPVector32=new Rt},"TEMPVector33",function(){return this.TEMPVector33=new Rt},"TEMPMatrix0",function(){return this.TEMPMatrix0=new Q},"TEMPMatrix1",function(){return this.TEMPMatrix1=new Q},"_tempMatrix3x3",function(){return this._tempMatrix3x3=new H},"NAN",function(){return this.NAN=new Quaternion(NaN,NaN,NaN,NaN)}]),Quaternion}(),_t=function(){function VertexDeclaration(e,t){this._id=0,this._vertexStride=0,this._vertexElementsDic=null,this._shaderValues=null,this._defineDatas=null,this.vertexElements=null,this._id=++VertexDeclaration._uniqueIDCounter,this._defineDatas=new Bt,this._vertexElementsDic={},this._vertexStride=e,this.vertexElements=t;var n=t.length;this._shaderValues=new st(null);for(var i=0;is&&(_+=(s-u)*(s-u)),cl&&(_+=(l-c)*(l-c)),dh&&(_+=(h-d)*(h-d)),Math.sqrt(_)},CollisionUtils.distanceBoxToBox=function(e,t){var n=e.min,i=n.x,r=n.y,a=n.z,o=e.max,s=o.x,l=o.y,h=o.z,u=t.min,c=u.x,d=u.y,_=u.z,f=t.max,m=f.x,p=f.y,T=f.z,S=0,E=NaN;return i>m?S+=(E=i-m)*E:c>s&&(S+=(E=c-s)*E),r>p?S+=(E=r-p)*E:d>l&&(S+=(E=d-l)*E),a>T?S+=(E=a-T)*E:_>h&&(S+=(E=_-h)*E),Math.sqrt(S)},CollisionUtils.distanceSphereToPoint=function(e,t){var n=Math.sqrt(Rt.distanceSquared(e.center,t));return n-=e.radius,Math.max(n,0)},CollisionUtils.distanceSphereToSphere=function(e,t){var n=Math.sqrt(Rt.distanceSquared(e.center,t.center));return n-=e.radius+t.radius,Math.max(n,0)},CollisionUtils.intersectsRayAndTriangleRD=function(e,t,n,i,r){var a=e.origin,o=a.x,s=a.y,l=a.z,h=e.direction,u=h.x,c=h.y,d=h.z,_=t.x,f=t.y,m=t.z,p=n.x,T=n.y,S=n.z,E=i.x,v=i.y,g=i.z,x=CollisionUtils._tempV30.x,M=CollisionUtils._tempV30.y,y=CollisionUtils._tempV30.z;x=p-_,M=T-f,y=S-m;var D=CollisionUtils._tempV31.x,R=CollisionUtils._tempV31.y,C=CollisionUtils._tempV31.z;D=E-_,R=v-f,C=g-m;var I=CollisionUtils._tempV32.x,A=CollisionUtils._tempV32.y,L=CollisionUtils._tempV32.z,O=x*(I=c*C-d*R)+M*(A=d*D-u*C)+y*(L=u*R-c*D);if(ft.isZero(O))return 0,!1;var P=1/O,V=CollisionUtils._tempV33.x,N=CollisionUtils._tempV33.y,B=CollisionUtils._tempV33.z,w=(V=o-_)*I+(N=s-f)*A+(B=l-m)*L;if((w*=P)<0||w>1)return 0,!1;var b=CollisionUtils._tempV34.x,F=CollisionUtils._tempV34.y,U=CollisionUtils._tempV34.z,z=u*(b=N*y-B*M)+c*(F=B*x-V*y)+d*(U=V*M-N*x);if((z*=P)<0||w+z>1)return 0,!1;var G=D*b+R*F+C*U;return(G*=P)<0?(0,!1):(G,!0)},CollisionUtils.intersectsRayAndTriangleRP=function(e,t,n,i,r){return CollisionUtils.intersectsRayAndTriangleRD(e,t,n,i,NaN)?(Rt.scale(e.direction,NaN,CollisionUtils._tempV30),Rt.add(e.origin,CollisionUtils._tempV30,r),!0):(r=Rt._ZERO,!1)},CollisionUtils.intersectsRayAndPoint=function(e,t){Rt.subtract(e.origin,t,CollisionUtils._tempV30);var n=Rt.dot(CollisionUtils._tempV30,e.direction),i=Rt.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-ft.zeroTolerance;return!(i>0&&n>0)&&!(n*n-i<0)},CollisionUtils.intersectsRayAndRay=function(e,t,n){var i=e.origin,r=i.x,a=i.y,o=i.z,s=e.direction,l=s.x,h=s.y,u=s.z,c=t.origin,d=c.x,_=c.y,f=c.z,m=t.direction,p=m.x,T=m.y,S=m.z;Rt.cross(s,m,CollisionUtils._tempV30);var E=CollisionUtils._tempV30,v=Rt.scalarLength(CollisionUtils._tempV30);if(ft.isZero(v)&&ft.nearEqual(d,r)&&ft.nearEqual(_,a)&&ft.nearEqual(f,o))return Rt._ZERO,!0;v*=v;var g=d-r,x=_-a,M=f-o,y=p,D=T,R=S,C=E.x,I=E.y,A=E.z,L=(g*D*A+x*R*C+M*y*I-g*R*I-x*y*A-M*D*C)/v;D=h,R=u,y=l;Rt.scale(s,L,CollisionUtils._tempV30),Rt.scale(m,L,CollisionUtils._tempV31),Rt.add(i,CollisionUtils._tempV30,CollisionUtils._tempV32),Rt.add(c,CollisionUtils._tempV31,CollisionUtils._tempV33);var O=CollisionUtils._tempV32,P=CollisionUtils._tempV33;return ft.nearEqual(P.x,O.x)&&ft.nearEqual(P.y,O.y)&&ft.nearEqual(P.z,O.z)?(CollisionUtils._tempV32,!0):(Rt._ZERO,!1)},CollisionUtils.intersectsPlaneAndTriangle=function(e,t,n,i){var r=CollisionUtils.intersectsPlaneAndPoint(e,t),a=CollisionUtils.intersectsPlaneAndPoint(e,n),o=CollisionUtils.intersectsPlaneAndPoint(e,i);return r==Pt.PlaneIntersectionType_Front&&a==Pt.PlaneIntersectionType_Front&&o==Pt.PlaneIntersectionType_Front?Pt.PlaneIntersectionType_Front:r==Pt.PlaneIntersectionType_Back&&a==Pt.PlaneIntersectionType_Back&&o==Pt.PlaneIntersectionType_Back?Pt.PlaneIntersectionType_Back:Pt.PlaneIntersectionType_Intersecting},CollisionUtils.intersectsRayAndPlaneRD=function(e,t,n){var i=t.normal,r=Rt.dot(i,e.direction);if(ft.isZero(r))return 0,!1;var a=Rt.dot(i,e.origin);return!((-t.distance-a)/r<0)||(0,!1)},CollisionUtils.intersectsRayAndPlaneRP=function(e,t,n){return CollisionUtils.intersectsRayAndPlaneRD(e,t,NaN)?(Rt.scale(e.direction,NaN,CollisionUtils._tempV30),Rt.add(e.origin,CollisionUtils._tempV30,CollisionUtils._tempV31),CollisionUtils._tempV31,!0):(Rt._ZERO,!1)},CollisionUtils.intersectsRayAndBoxRD=function(e,t){var n=e.origin,i=n.x,r=n.y,a=n.z,o=e.direction,s=o.x,l=o.y,h=o.z,u=t.min,c=u.x,d=u.y,_=u.z,f=t.max,m=f.x,p=f.y,T=f.z,S=0,E=ft.MaxValue;if(ft.isZero(s)){if(im)return-1}else{var v=1/s,g=(c-i)*v,x=(m-i)*v;if(g>x){var M=g;g=x,x=M}if((S=Math.max(g,S))>(E=Math.min(x,E)))return-1}if(ft.isZero(l)){if(rp)return-1}else{var y=1/l,D=(d-r)*y,R=(p-r)*y;if(D>R){var C=D;D=R,R=C}if((S=Math.max(D,S))>(E=Math.min(R,E)))return-1}if(ft.isZero(h)){if(a<_||a>T)return-1}else{var I=1/h,A=(_-a)*I,L=(T-a)*I;if(A>L){var O=A;A=L,L=O}if((S=Math.max(A,S))>(E=Math.min(L,E)))return-1}return S},CollisionUtils.intersectsRayAndBoxRP=function(e,t,n){var i=CollisionUtils.intersectsRayAndBoxRD(e,t);return-1===i?(Rt._ZERO.cloneTo(n),i):(Rt.scale(e.direction,i,CollisionUtils._tempV30),Rt.add(e.origin,CollisionUtils._tempV30,CollisionUtils._tempV31),CollisionUtils._tempV31.cloneTo(n),i)},CollisionUtils.intersectsRayAndSphereRD=function(e,t){var n=t.radius;Rt.subtract(e.origin,t.center,CollisionUtils._tempV30);var i=Rt.dot(CollisionUtils._tempV30,e.direction),r=Rt.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-n*n;if(r>0&&i>0)return-1;var a=i*i-r;if(a<0)return-1;var o=-i-Math.sqrt(a);return o<0&&(o=0),o},CollisionUtils.intersectsRayAndSphereRP=function(e,t,n){var i=CollisionUtils.intersectsRayAndSphereRD(e,t);return-1===i?(Rt._ZERO.cloneTo(n),i):(Rt.scale(e.direction,i,CollisionUtils._tempV30),Rt.add(e.origin,CollisionUtils._tempV30,CollisionUtils._tempV31),CollisionUtils._tempV31.cloneTo(n),i)},CollisionUtils.intersectsSphereAndTriangle=function(e,t,n,i){var r=e.center,a=e.radius;return CollisionUtils.closestPointPointTriangle(r,t,n,i,CollisionUtils._tempV30),Rt.subtract(CollisionUtils._tempV30,r,CollisionUtils._tempV31),Rt.dot(CollisionUtils._tempV31,CollisionUtils._tempV31)<=a*a},CollisionUtils.intersectsPlaneAndPoint=function(e,t){var n=Rt.dot(e.normal,t)+e.distance;return n>0?Pt.PlaneIntersectionType_Front:n<0?Pt.PlaneIntersectionType_Back:Pt.PlaneIntersectionType_Intersecting},CollisionUtils.intersectsPlaneAndPlane=function(e,t){Rt.cross(e.normal,t.normal,CollisionUtils._tempV30);var n=Rt.dot(CollisionUtils._tempV30,CollisionUtils._tempV30);return!ft.isZero(n)},CollisionUtils.intersectsPlaneAndPlaneRL=function(e,t,n){var i=e.normal,r=t.normal;Rt.cross(i,r,CollisionUtils._tempV34);var a=Rt.dot(CollisionUtils._tempV34,CollisionUtils._tempV34);return!ft.isZero(a)&&(Rt.scale(r,e.distance,CollisionUtils._tempV30),Rt.scale(i,t.distance,CollisionUtils._tempV31),Rt.subtract(CollisionUtils._tempV30,CollisionUtils._tempV31,CollisionUtils._tempV32),Rt.cross(CollisionUtils._tempV32,CollisionUtils._tempV34,CollisionUtils._tempV33),Rt.normalize(CollisionUtils._tempV34,CollisionUtils._tempV34),new Ke(CollisionUtils._tempV33,CollisionUtils._tempV34),!0)},CollisionUtils.intersectsPlaneAndBox=function(e,t){var n=e.distance,i=e.normal,r=i.x,a=i.y,o=i.z,s=t.min,l=s.x,h=s.y,u=s.z,c=t.max,d=c.x,_=c.y,f=c.z;CollisionUtils._tempV30.x=r>0?l:d,CollisionUtils._tempV30.y=a>0?h:_,CollisionUtils._tempV30.z=o>0?u:f,CollisionUtils._tempV31.x=r>0?d:l,CollisionUtils._tempV31.y=a>0?_:h,CollisionUtils._tempV31.z=o>0?f:u;var m=Rt.dot(i,CollisionUtils._tempV30);return m+n>0?Pt.PlaneIntersectionType_Front:(m=Rt.dot(i,CollisionUtils._tempV31))+n<0?Pt.PlaneIntersectionType_Back:Pt.PlaneIntersectionType_Intersecting},CollisionUtils.intersectsPlaneAndSphere=function(e,t){var n=t.radius,i=Rt.dot(e.normal,t.center)+e.distance;return i>n?Pt.PlaneIntersectionType_Front:i<-n?Pt.PlaneIntersectionType_Back:Pt.PlaneIntersectionType_Intersecting},CollisionUtils.intersectsBoxAndBox=function(e,t){var n=e.min,i=e.max,r=t.min,a=t.max;return!(n.x>a.x||r.x>i.x)&&(!(n.y>a.y||r.y>i.y)&&!(n.z>a.z||r.z>i.z))},CollisionUtils.intersectsBoxAndSphere=function(e,t){var n=t.center,i=t.radius;return Rt.Clamp(n,e.min,e.max,CollisionUtils._tempV30),Rt.distanceSquared(n,CollisionUtils._tempV30)<=i*i},CollisionUtils.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return Rt.distanceSquared(e.center,t.center)<=n*n},CollisionUtils.boxContainsPoint=function(e,t){var n=e.min,i=e.max;return n.x<=t.x&&i.x>=t.x&&n.y<=t.y&&i.y>=t.y&&n.z<=t.z&&i.z>=t.z?1:0},CollisionUtils.boxContainsBox=function(e,t){var n=e.min,i=n.x,r=n.y,a=n.z,o=e.max,s=o.x,l=o.y,h=o.z,u=t.min,c=u.x,d=u.y,_=u.z,f=t.max,m=f.x,p=f.y,T=f.z;return sm?0:lp?0:h<_||a>T?0:i<=c&&m<=s&&r<=d&&p<=l&&a<=_&&T<=h?1:2},CollisionUtils.boxContainsSphere=function(e,t){var n=e.min,i=n.x,r=n.y,a=n.z,o=e.max,s=o.x,l=o.y,h=o.z,u=t.center,c=u.x,d=u.y,_=u.z,f=t.radius;return Rt.Clamp(u,n,o,CollisionUtils._tempV30),Rt.distanceSquared(u,CollisionUtils._tempV30)>f*f?0:i+f<=c&&c<=s-f&&s-i>f&&r+f<=d&&d<=l-f&&l-r>f&&a+f<=_&&_<=h-f&&h-a>f?1:2},CollisionUtils.sphereContainsPoint=function(e,t){return Rt.distanceSquared(t,e.center)<=e.radius*e.radius?1:0},CollisionUtils.sphereContainsTriangle=function(e,t,n,i){var r=CollisionUtils.sphereContainsPoint(e,t),a=CollisionUtils.sphereContainsPoint(e,n),o=CollisionUtils.sphereContainsPoint(e,i);return 1==r&&1==a&&1==o?1:CollisionUtils.intersectsSphereAndTriangle(e,t,n,i)?2:0},CollisionUtils.sphereContainsBox=function(e,t){var n=e.center,i=n.x,r=n.y,a=n.z,o=e.radius,s=t.min,l=s.x,h=s.y,u=s.z,c=t.max,d=c.x,_=c.y,f=c.z,m=CollisionUtils._tempV30;m.x,m.y,m.z;if(!CollisionUtils.intersectsBoxAndSphere(t,e))return 0;var p=o*o;return i-l,r-_,a-f,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:(i-d,r-_,a-f,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:(i-d,r-h,a-f,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:(i-l,r-h,a-f,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:(i-l,r-_,a-u,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:(i-d,r-_,a-u,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:(i-d,r-h,a-u,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:(i-l,r-h,a-u,Rt.scalarLengthSquared(CollisionUtils._tempV30)>p?2:1)))))))},CollisionUtils.sphereContainsSphere=function(e,t){var n=e.radius,i=t.radius,r=Rt.distance(e.center,t.center);return n+i=0&&l<=s)n.cloneTo(r);else{var c=a*l-s*o;if(c<=0&&a>=0&&s<=0){var d=a/(a-s);return Rt.scale(CollisionUtils._tempV30,d,r),void Rt.add(t,r,r)}if(u>=0&&h<=u)i.cloneTo(r);else{var _=h*o-a*u;if(_<=0&&o>=0&&u<=0){var f=o/(o-u);return Rt.scale(CollisionUtils._tempV31,f,r),void Rt.add(t,r,r)}var m=s*u-h*l;if(m<=0&&l-s>=0&&h-u>=0){var p=(l-s)/(l-s+(h-u));return Rt.subtract(i,n,r),Rt.scale(r,p,r),void Rt.add(n,r,r)}var T=1/(m+_+c),S=_*T,E=c*T;Rt.scale(CollisionUtils._tempV30,S,CollisionUtils._tempV35),Rt.scale(CollisionUtils._tempV31,E,CollisionUtils._tempV36),Rt.add(CollisionUtils._tempV35,CollisionUtils._tempV36,r),Rt.add(t,r,r)}}},CollisionUtils.closestPointPlanePoint=function(e,t,n){var i=e.normal,r=Rt.dot(i,t)-e.distance;Rt.scale(i,r,CollisionUtils._tempV30),Rt.subtract(t,CollisionUtils._tempV30,n)},CollisionUtils.closestPointBoxPoint=function(e,t,n){Rt.max(t,e.min,CollisionUtils._tempV30),Rt.min(CollisionUtils._tempV30,e.max,n)},CollisionUtils.closestPointSpherePoint=function(e,t,n){var i=e.center;Rt.subtract(t,i,n),Rt.normalize(n,n),Rt.scale(n,e.radius,n),Rt.add(n,i,n)},CollisionUtils.closestPointSphereSphere=function(e,t,n){var i=e.center;Rt.subtract(t.center,i,n),Rt.normalize(n,n),Rt.scale(n,e.radius,n),Rt.add(n,i,n)},i(CollisionUtils,["_tempV30",function(){return this._tempV30=new Rt},"_tempV31",function(){return this._tempV31=new Rt},"_tempV32",function(){return this._tempV32=new Rt},"_tempV33",function(){return this._tempV33=new Rt},"_tempV34",function(){return this._tempV34=new Rt},"_tempV35",function(){return this._tempV35=new Rt},"_tempV36",function(){return this._tempV36=new Rt}]),CollisionUtils}(),gt=function(){function ShurikenParticleData(){}return r(ShurikenParticleData,"laya.d3.core.particleShuriKen.ShurikenParticleData"),ShurikenParticleData._getStartLifetimeFromGradient=function(e,t){for(var n=1,i=e.gradientCount;n=t){var a=e.getKeyByIndex(n-1),o=(t-a)/(r-a);return M.lerp(e.getValueByIndex(n-1),e.getValueByIndex(n),o)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")},ShurikenParticleData._randomInvertRoationArray=function(e,t,n,i,r){var a=NaN;i?(i.seed=r[6],a=i.getFloat(),r[6]=i.seed):a=Math.random(),a=0;i--){var r=n[i];this._objects.push(r),r._setOctreeNode(this)}}}this._children=null},e._merge=function(){if(null===this._children){var e=this._parent;e&&e._shouldMerge()&&(e._mergeChildren(),e._merge())}},e._checkAddNode=function(e){if(null==this._children){if(this._objects.length<8||this.baseLength/2=0;t--){var n=this._objects[t],i=this._bestFitChild(n.bounds.getCenter());BoundsOctreeNode._encapsulates(this._getChildBound(i),n.bounds._getBoundBox())&&(this._objects.splice(this._objects.indexOf(n),1),this._getChild(i)._add(n))}}var r=this._bestFitChild(e.bounds.getCenter());return BoundsOctreeNode._encapsulates(this._getChildBound(r),e.bounds._getBoundBox())?this._getChild(r)._checkAddNode(e):this},e._add=function(e){var t=this._checkAddNode(e);t._objects.push(e),e._setOctreeNode(t)},e._remove=function(e){var t=this._objects.indexOf(e);this._objects.splice(t,1),e._setOctreeNode(null),this._merge()},e._addUp=function(e){return 1===vt.boxContainsBox(this._bounds,e.bounds._getBoundBox())?(this._add(e),!0):!!this._parent&&this._parent._addUp(e)},e._getCollidingWithFrustum=function(e,t,n,i){if(n){var r=t.containsBoundBox(this._bounds);if(P.octreeNodeCulling++,0===r)return;n=2===r}this._isContaion=!n;for(var a=e.camera,o=e.scene,s=0,l=this._objects.length;s=this.center.y?0:4)+(e.z<=this.center.z?0:2)},e._update=function(e){if(1===vt.boxContainsBox(this._bounds,e.bounds._getBoundBox())){var t=this._checkAddNode(e);if(t!==e._getOctreeNode()){t._objects.push(e),e._setOctreeNode(t);var n=this._objects.indexOf(e);this._objects.splice(n,1),this._merge()}return!0}if(this._parent){var i=this._parent._addUp(e);return i&&(n=this._objects.indexOf(e),this._objects.splice(n,1),this._merge()),i}return!1},e.add=function(e){return!!BoundsOctreeNode._encapsulates(this._bounds,e.bounds._getBoundBox())&&(this._add(e),!0)},e.remove=function(e){return e._getOctreeNode()===this&&(this._remove(e),!0)},e.update=function(e){return e._getOctreeNode()===this&&this._update(e)},e.shrinkIfPossible=function(e){if(this.baseLength<2*e)return this;for(var t=-1,n=0,i=this._objects.length;n=0&&t!=n)return this;l=!0,t=n}}if(-1!=t){var u=this._children[t];return u._parent=null,u}return this},e.hasAnyObjects=function(){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},e.getCollidingWithBoundBox=function(e,t){this._getCollidingWithBoundBox(e,!0,t)},e.getCollidingWithRay=function(e,t,n){void 0===n&&(n=Number.MAX_VALUE);var i=vt.intersectsRayAndBoxRD(e,this._bounds);if(!(-1==i||i>n)){for(var r=0,a=this._objects.length;rt)return!1;for(var i=0,r=this._objects.length;i0;)t--;if(e1){var n=this._partitionRenderObject(e,t),i=n-1;e0&&(t.x=e.x*n,t.y=e.y*n,t.z=e.z*n,t.w=e.w*n)},Vector4.add=function(e,t,n){n.x=e.x+t.x,n.y=e.y+t.y,n.z=e.z+t.z,n.w=e.w+t.w},Vector4.subtract=function(e,t,n){n.x=e.x-t.x,n.y=e.y-t.y,n.z=e.z-t.z,n.w=e.w-t.w},Vector4.multiply=function(e,t,n){n.x=e.x*t.x,n.y=e.y*t.y,n.z=e.z*t.z,n.w=e.w*t.w},Vector4.scale=function(e,t,n){n.x=e.x*t,n.y=e.y*t,n.z=e.z*t,n.w=e.w*t},Vector4.Clamp=function(e,t,n,i){var r=e.x,a=e.y,o=e.z,s=e.w,l=t.x,h=t.y,u=t.z,c=t.w,d=n.x,_=n.y,f=n.z,m=n.w;r=(r=r>d?d:r)_?_:a)f?f:o)m?m:s)0&&(a=1/Math.sqrt(a),t.x=e.x*a,t.y=e.y*a,t.z=e.z*a)},Vector3.multiply=function(e,t,n){n.x=e.x*t.x,n.y=e.y*t.y,n.z=e.z*t.z},Vector3.scale=function(e,t,n){n.x=e.x*t,n.y=e.y*t,n.z=e.z*t},Vector3.lerp=function(e,t,n,i){var r=e.x,a=e.y,o=e.z;i.x=r+n*(t.x-r),i.y=a+n*(t.y-a),i.z=o+n*(t.z-o)},Vector3.transformV3ToV3=function(e,t,n){var i=Vector3._tempVector4;Vector3.transformV3ToV4(e,t,i),n.x=i.x,n.y=i.y,n.z=i.z},Vector3.transformV3ToV4=function(e,t,n){var i=e.x,r=e.y,a=e.z,o=t.elements;n.x=i*o[0]+r*o[4]+a*o[8]+o[12],n.y=i*o[1]+r*o[5]+a*o[9]+o[13],n.z=i*o[2]+r*o[6]+a*o[10]+o[14],n.w=i*o[3]+r*o[7]+a*o[11]+o[15]},Vector3.TransformNormal=function(e,t,n){var i=e.x,r=e.y,a=e.z,o=t.elements;n.x=i*o[0]+r*o[4]+a*o[8],n.y=i*o[1]+r*o[5]+a*o[9],n.z=i*o[2]+r*o[6]+a*o[10]},Vector3.transformCoordinate=function(e,t,n){var i=e.x,r=e.y,a=e.z,o=t.elements,s=i*o[3]+r*o[7]+a*o[11]+o[15];n.x=i*o[0]+r*o[4]+a*o[8]+o[12]/s,n.y=i*o[1]+r*o[5]+a*o[9]+o[13]/s,n.z=i*o[2]+r*o[6]+a*o[10]+o[14]/s},Vector3.Clamp=function(e,t,n,i){var r=e.x,a=e.y,o=e.z,s=t.x,l=t.y,h=t.z,u=n.x,c=n.y,d=n.z;r=(r=r>u?u:r)c?c:a)d?d:o)0&&(r=1/Math.sqrt(r),t.x=n*r,t.y=i*r)},Vector2.scalarLength=function(e){var t=e.x,n=e.y;return Math.sqrt(t*t+n*n)},Vector2.rewriteNumProperty=function(e,t,n){Object.defineProperty(e,t,{get:function(){return this.elements[n]},set:function(e){this.elements[n]=e}})},i(Vector2,["ZERO",function(){return this.ZERO=new Vector2(0,0)},"ONE",function(){return this.ONE=new Vector2(1,1)}]),Vector2}(),It=function(){function BoundSphere(e,t){this.center=null,this.radius=NaN,this.center=e,this.radius=t}r(BoundSphere,"laya.d3.math.BoundSphere");var e=BoundSphere.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.toDefault=function(){this.center.toDefault(),this.radius=0},e.intersectsRayDistance=function(e){return vt.intersectsRayAndSphereRD(e,this)},e.intersectsRayPoint=function(e,t){return vt.intersectsRayAndSphereRP(e,this,t)},e.cloneTo=function(e){var t=e;this.center.cloneTo(t.center),t.radius=this.radius},e.clone=function(){var e=new this.constructor(new Rt,new Rt);return this.cloneTo(e),e},BoundSphere.createFromSubPoints=function(e,t,n,i){if(null==e)throw new Error("points");if(t<0||t>=e.length)throw new Error("start"+t+"Must be in the range [0, "+(e.length-1)+"]");if(n<0||t+n>e.length)throw new Error("count"+n+"Must be in the range <= "+e.length+"}");var r=t+n,a=BoundSphere._tempVector3;a.x=0,a.y=0,a.z=0;for(var o=t;ol&&(l=h)}i.radius=Math.sqrt(l)},BoundSphere.createfromPoints=function(e,t){if(null==e)throw new Error("points");BoundSphere.createFromSubPoints(e,0,e.length,t)},i(BoundSphere,["_tempVector3",function(){return this._tempVector3=new Rt}]),BoundSphere}(),At=function(){function Shader3D(e,t,n,i){this._attributeMap=null,this._uniformMap=null,this._enableInstancing=!1,this._subShaders=[],this._name=e,this._attributeMap=t,this._uniformMap=n,this._enableInstancing=i}r(Shader3D,"laya.d3.shader.Shader3D");var e=Shader3D.prototype;return e.addSubShader=function(e){this._subShaders.push(e),e._owner=this},e.getSubShaderAt=function(e){return this._subShaders[e]},Shader3D.propertyNameToID=function(e){if(null!=Shader3D._propertyNameMap[e])return Shader3D._propertyNameMap[e];var t=Shader3D._propertyNameCounter++;return Shader3D._propertyNameMap[e]=t,t},Shader3D.addInclude=function(e,t){A.addInclude(e,t)},Shader3D.registerPublicDefine=function(e){var t=Math.pow(2,Shader3D._publicCounter++);return Shader3D._globleDefines[t]=e,t},Shader3D.compileShader=function(e,t,n,i,r,a){var o=laya.d3.shader.Shader3D.find(e);if(o){var s=o.getSubShaderAt(t);if(s){var l=s._passes[n];l?b.shaderHighPrecision?l.withCompile(i,r,a):l.withCompile(i-laya.d3.shader.Shader3D.SHADERDEFINE_HIGHPRECISION,r,a):console.warn("Shader3D: unknown passIndex.")}else console.warn("Shader3D: unknown subShaderIndex.")}else console.warn("Shader3D: unknown shader name.")},Shader3D.add=function(e,t,n,i){return void 0===i&&(i=!1),laya.d3.shader.Shader3D._preCompileShader[e]=new Shader3D(e,t,n,i)},Shader3D.find=function(e){return laya.d3.shader.Shader3D._preCompileShader[e]},Shader3D.RENDER_STATE_CULL=0,Shader3D.RENDER_STATE_BLEND=1,Shader3D.RENDER_STATE_BLEND_SRC=2,Shader3D.RENDER_STATE_BLEND_DST=3,Shader3D.RENDER_STATE_BLEND_SRC_RGB=4,Shader3D.RENDER_STATE_BLEND_DST_RGB=5,Shader3D.RENDER_STATE_BLEND_SRC_ALPHA=6,Shader3D.RENDER_STATE_BLEND_DST_ALPHA=7,Shader3D.RENDER_STATE_BLEND_CONST_COLOR=8,Shader3D.RENDER_STATE_BLEND_EQUATION=9,Shader3D.RENDER_STATE_BLEND_EQUATION_RGB=10,Shader3D.RENDER_STATE_BLEND_EQUATION_ALPHA=11,Shader3D.RENDER_STATE_DEPTH_TEST=12,Shader3D.RENDER_STATE_DEPTH_WRITE=13,Shader3D.PERIOD_CUSTOM=0,Shader3D.PERIOD_MATERIAL=1,Shader3D.PERIOD_SPRITE=2,Shader3D.PERIOD_CAMERA=3,Shader3D.PERIOD_SCENE=4,Shader3D.SHADERDEFINE_HIGHPRECISION=0,Shader3D._propertyNameCounter=0,Shader3D._propertyNameMap={},Shader3D._publicCounter=0,Shader3D._globleDefines=[],Shader3D._preCompileShader={},Shader3D.debugMode=!1,Shader3D}(),Lt=function(){function Gradient(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)}r(Gradient,"laya.d3.core.Gradient");var e=Gradient.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.addColorRGB=function(e,t){if(this._colorRGBKeysCount0)for(var n=0;ne.time&&this._bursts.splice(n,0,e);this._bursts.push(e)},e.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},e.removeBurstByIndex=function(e){this._bursts.splice(e,1)},e.clearBurst=function(){this._bursts.length=0},e.cloneTo=function(e){var t=e,n=t._bursts;n.length=this._bursts.length;for(var i=0,r=this._bursts.length;i0&&o._quickSort(0,d-1),(d=s.elements.length)>0&&s._quickSort(0,d-1)},FrustumCulling.renderObjectCullingNative=function(e,t,n,i){var r=0,a=0,o=0,s=0,l=t._opaqueQueue,h=t._transparentQueue;l.clear(),h.clear();var u=ae._managers;for(r=0,a=u.length;r0&&l._quickSort(0,E-1),(E=h.elements.length)>0&&h._quickSort(0,E-1)},FrustumCulling.cullingNative=function(e,t,n,i,r){return E.instance.culling(e,t,n,i,r)},FrustumCulling._cullingBufferLength=0,FrustumCulling._cullingBuffer=null,i(FrustumCulling,["_tempVector3",function(){return this._tempVector3=new Rt},"_tempColor0",function(){return this._tempColor0=new k}]),FrustumCulling}(),Bt=function(){function DefineDatas(){this.value=0}r(DefineDatas,"laya.d3.shader.DefineDatas");var e=DefineDatas.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.add=function(e){this.value|=e},e.remove=function(e){this.value&=~e},e.has=function(e){return(this.value&e)>0},e.cloneTo=function(e){e.value=this.value},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},DefineDatas}(),wt=function(){function Laya3D(){}return r(Laya3D,"Laya3D"),a(1,Laya3D,"enbalePhysics",function(){return Laya3D._enbalePhysics}),Laya3D._cancelLoadByUrl=function(e){n.loader.cancelLoadByUrl(e),Laya3D._innerFirstLevelLoaderManager.cancelLoadByUrl(e),Laya3D._innerSecondLevelLoaderManager.cancelLoadByUrl(e),Laya3D._innerThirdLevelLoaderManager.cancelLoadByUrl(e),Laya3D._innerFourthLevelLoaderManager.cancelLoadByUrl(e)},Laya3D._changeWebGLSize=function(e,t){b.onStageResize(e,t),Ze.clientWidth=e,Ze.clientHeight=t},Laya3D.__init__=function(e,t,i){if(m.isAntialias=i.isAntialias,m.isAlpha=i.isAlpha,m.premultipliedAlpha=i.premultipliedAlpha,m.isStencil=i.isStencil,b.enable()){I.changeWebGLSize=Laya3D._changeWebGLSize,R.is3DMode=!0,n.init(e,t),R.supportWebGLPlusRendering||(E.instance=b.mainContext,E.instance.createCommandEncoder=function(e,t,n){return void 0===e&&(e=128),void 0===t&&(t=64),void 0===n&&(n=!1),new _(this,e,t,n)}),Laya3D.enableNative3D(),bn.__init__(),Jn.__init__(),Ei.__init__(),Mi.__init__(),Ri.__init__(),Fn.__init__(),_i.__init__(),si.__init__(),ei.__init__(),ui.__init__(),oi.__init__(),gi.__init__(),$n.__init__(),fi.__init__(),ai.__init__(),ci.__init__(),di.__init__(),ri.__init__(),Ce.__init__(),ni.defaultMaterial.lock=!0,_i.defaultMaterial.lock=!0,fi.defaultMaterial.lock=!0,si.defaultMaterial.lock=!0,ei.defaultMaterial.lock=!0,oi.defaultMaterial.lock=!0,ci.defaultMaterial.lock=!0,$n.defaultMaterial.lock=!0,ui.defaultMaterial.lock=!0,ii.defaultMaterial.lock=!0,ai.defaultMaterial.lock=!0,B.__init__(),pi.__init__(),wn.__init__(),On.__init__(),Wn.__init__(),je.__init__(),Nt.__init__(),ve.__init__();var r=x.createMap;r.lh=["HIERARCHY",bn._parse],r.ls=["HIERARCHY",qn._parse],r.lm=["MESH",zn._parse],r.lmat=["MATERIAL",Fn._parse],r.ltc=["TEXTURECUBE",pi._parse],r.jpg=["TEXTURE2D",B._parse],r.jpeg=["TEXTURE2D",B._parse],r.bmp=["TEXTURE2D",B._parse],r.gif=["TEXTURE2D",B._parse],r.png=["TEXTURE2D",B._parse],r.dds=["TEXTURE2D",B._parse],r.ktx=["TEXTURE2D",B._parse],r.pvr=["TEXTURE2D",B._parse],r.lani=["ANIMATIONCLIP",Gn._parse],r.lav=["AVATAR",Un._parse],r.thdata=["TERRAINHEIGHTDATA",kn._pharse];var a=g.parserMap;a.HIERARCHY=Laya3D._loadHierarchy,a.MESH=Laya3D._loadMesh,a.MATERIAL=Laya3D._loadMaterial,a.TEXTURECUBE=Laya3D._loadTextureCube,a.TEXTURE2D=Laya3D._loadTexture2D,a.ANIMATIONCLIP=Laya3D._loadAnimationClip,a.AVATAR=Laya3D._loadAvatar,Laya3D._innerFirstLevelLoaderManager.on("error",null,Laya3D._eventLoadManagerError),Laya3D._innerSecondLevelLoaderManager.on("error",null,Laya3D._eventLoadManagerError),Laya3D._innerThirdLevelLoaderManager.on("error",null,Laya3D._eventLoadManagerError),Laya3D._innerFourthLevelLoaderManager.on("error",null,Laya3D._eventLoadManagerError)}else alert("Laya3D init error,must support webGL!")},Laya3D.enableNative3D=function(){if(R.isConchApp){E=e.LayaGLContext;var t=st,n=Hn,i=Un,r=Nt,a=Xn;if(R.supportWebGLPlusRendering&&(t.prototype._initData=t.prototype._initDataForNative,t.prototype.setBool=t.prototype.setBoolForNative,t.prototype.getBool=t.prototype.getBoolForNative,t.prototype.setInt=t.prototype.setIntForNative,t.prototype.getInt=t.prototype.getIntForNative,t.prototype.setNumber=t.prototype.setNumberForNative,t.prototype.getNumber=t.prototype.getNumberForNative,t.prototype.setVector=t.prototype.setVectorForNative,t.prototype.getVector=t.prototype.getVectorForNative,t.prototype.setVector2=t.prototype.setVector2ForNative,t.prototype.getVector2=t.prototype.getVector2ForNative,t.prototype.setVector3=t.prototype.setVector3ForNative,t.prototype.getVector3=t.prototype.getVector3ForNative,t.prototype.setQuaternion=t.prototype.setQuaternionForNative,t.prototype.getQuaternion=t.prototype.getQuaternionForNative,t.prototype.setMatrix4x4=t.prototype.setMatrix4x4ForNative,t.prototype.getMatrix4x4=t.prototype.getMatrix4x4ForNative,t.prototype.setBuffer=t.prototype.setBufferForNative,t.prototype.getBuffer=t.prototype.getBufferForNative,t.prototype.setTexture=t.prototype.setTextureForNative,t.prototype.getTexture=t.prototype.getTextureForNative,t.prototype.setAttribute=t.prototype.setAttributeForNative,t.prototype.getAttribute=t.prototype.getAttributeForNative,t.prototype.cloneTo=t.prototype.cloneToForNative,t.prototype.getData=t.prototype.getDataForNative,n.prototype._uniformMatrix2fv=n.prototype._uniformMatrix2fvForNative,n.prototype._uniformMatrix3fv=n.prototype._uniformMatrix3fvForNative,n.prototype._uniformMatrix4fv=n.prototype._uniformMatrix4fvForNative,a.prototype._renderUpdateWithCamera=a.prototype._renderUpdateWithCameraForNative),R.supportWebGLPlusCulling&&(r.renderObjectCulling=Nt.renderObjectCullingNative),R.supportWebGLPlusAnimation){i.prototype._cloneDatasToAnimator=i.prototype._cloneDatasToAnimatorNative,Bn=e.conchFloatKeyframe,Vn=e.conchFloatArrayKeyframe,Nn=e.conchFloatArrayKeyframe,Ue=e.conchKeyframeNode,it=e.conchKeyframeNodeList;var o=Gn;o.prototype._evaluateClipDatasRealTime=o.prototype._evaluateClipDatasRealTimeForNative}}b.shaderHighPrecision=!1,E.instance.getShaderPrecisionFormat(35632,36338).precision?b.shaderHighPrecision=!0:b.shaderHighPrecision=!1},Laya3D.formatRelativePath=function(e,t){var n;if(n=e+t,"."===t.charAt(0)){for(var i=n.split("/"),r=0,a=i.length;r0&&".."!==i[o]&&(i.splice(o,2),r-=2)}n=i.join("/")}return n},Laya3D._endLoad=function(e,t,n){if(n)for(var i=0,r=n.length;i0){var _=u/c,f=S.create(null,Laya3D._onProcessChange,[e,d,_],!1);Laya3D._innerFourthLevelLoaderManager._create(l,!1,S.create(null,Laya3D._onHierarchyInnerForthLevResouLoaded,[e,f,t,h,a,o,s,d+_*l.length,_]),f,null,null,null,1,!0)}else Laya3D._onHierarchyInnerForthLevResouLoaded(e,null,t,h,a,o,s,d,_)},Laya3D._onHierarchyInnerForthLevResouLoaded=function(e,t,n,i,r,a,o,s,l){if(t&&t.recover(),o.length>0){var h=S.create(null,Laya3D._onProcessChange,[e,s,l],!1);Laya3D._innerThirdLevelLoaderManager._create(o,!1,S.create(null,Laya3D._onHierarchyInnerThirdLevResouLoaded,[e,h,n,i,r,a,s+l*a.length,l]),t,null,null,null,1,!0)}else Laya3D._onHierarchyInnerThirdLevResouLoaded(e,null,n,i,r,a,s,l)},Laya3D._onHierarchyInnerThirdLevResouLoaded=function(e,t,n,i,r,a,o,s){if(t&&t.recover(),a.length>0){var l=S.create(null,Laya3D._onProcessChange,[e,o,s],!1);Laya3D._innerSecondLevelLoaderManager._create(a,!1,S.create(null,Laya3D._onHierarchyInnerSecondLevResouLoaded,[e,l,n,i,r,o+s*a.length,s]),t,null,null,null,1,!0)}else Laya3D._onHierarchyInnerSecondLevResouLoaded(e,null,n,i,r,o,s)},Laya3D._onHierarchyInnerSecondLevResouLoaded=function(e,t,n,i,r,a,o){if(t&&t.recover(),r.length>0){var s=S.create(null,Laya3D._onProcessChange,[e,a,o],!1);Laya3D._innerFirstLevelLoaderManager._create(r,!1,S.create(null,Laya3D._onHierarchyInnerFirstLevResouLoaded,[e,s,n,i]),t,null,null,null,1,!0)}else Laya3D._onHierarchyInnerFirstLevResouLoaded(e,null,n,i)},Laya3D._onHierarchyInnerFirstLevResouLoaded=function(e,t,n,i){t&&t.recover(),e._cache=e._createCache;var r="Scene3D"===n.data.type?qn._parse(n,e._propertyParams,e._constructParams):bn._parse(n,e._propertyParams,e._constructParams);Laya3D._endLoad(e,r,i)},Laya3D._loadMesh=function(e){e.on("loaded",null,Laya3D._onMeshLmLoaded,[e]),e.load(e.url,"arraybuffer",!1,null,!0)},Laya3D._onMeshLmLoaded=function(e,t){e._cache=e._createCache;var n=zn._parse(t,e._propertyParams,e._constructParams);Laya3D._endLoad(e,n)},Laya3D._loadMaterial=function(e){e.on("loaded",null,Laya3D._onMaterilLmatLoaded,[e]),e.load(e.url,"json",!1,null,!0)},Laya3D._onMaterilLmatLoaded=function(e,t){var n,i=e.url,r=fe.getURLVerion(i),a=w.getPath(i),o=[],s=[];t.customProps;switch(t.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":var l=0,h=0,u=t.props.textures;if(u)for(l=0,h=u.length;l0){var p=S.create(null,Laya3D._onProcessChange,[e,m,_/f],!1);Laya3D._innerFourthLevelLoaderManager._create(o,!1,S.create(null,Laya3D._onMateialTexturesLoaded,[e,p,t,s]),p,null,null,null,1,!0)}else Laya3D._onMateialTexturesLoaded(e,null,t,null)},Laya3D._onMateialTexturesLoaded=function(e,t,n,i){e._cache=e._createCache;var r=Fn._parse(n,e._propertyParams,e._constructParams);Laya3D._endLoad(e,r,i),t&&t.recover()},Laya3D._loadAvatar=function(e){e.on("loaded",null,function(t){e._cache=e._createCache;var n=Un._parse(t,e._propertyParams,e._constructParams);Laya3D._endLoad(e,n)}),e.load(e.url,"json",!1,null,!0)},Laya3D._loadAnimationClip=function(e){e.on("loaded",null,function(t){e._cache=e._createCache;var n=Gn._parse(t,e._propertyParams,e._constructParams);Laya3D._endLoad(e,n)}),e.load(e.url,"arraybuffer",!1,null,!0)},Laya3D._loadTexture2D=function(e){var t,n=e.url,i=n.lastIndexOf(".")+1,r=n.indexOf("?"),a=-1==r?n.length:r;switch(n.substr(i,a-i)){case"jpg":case"jpeg":case"bmp":case"gif":case"png":t="nativeimage";break;case"dds":case"ktx":case"pvr":t="arraybuffer"}e.on("loaded",null,function(t){e._cache=e._createCache;var n=B._parse(t,e._propertyParams,e._constructParams);Laya3D._endLoad(e,n)}),e.load(e.url,t,!1,null,!0)},Laya3D._loadTextureCube=function(e){e.on("loaded",null,Laya3D._onTextureCubeLtcLoaded,[e]),e.load(e.url,"json",!1,null,!0)},Laya3D._onTextureCubeLtcLoaded=function(e,t){var n=w.getPath(e.url),i=[Laya3D.formatRelativePath(n,t.front),Laya3D.formatRelativePath(n,t.back),Laya3D.formatRelativePath(n,t.left),Laya3D.formatRelativePath(n,t.right),Laya3D.formatRelativePath(n,t.up),Laya3D.formatRelativePath(n,t.down)];Laya3D._onProcessChange(e,0,1/7,1);var r=S.create(null,Laya3D._onProcessChange,[e,1/7,6/7],!1);Laya3D._innerFourthLevelLoaderManager.load(i,S.create(null,Laya3D._onTextureCubeImagesLoaded,[e,i,r]),r,"nativeimage")},Laya3D._onTextureCubeImagesLoaded=function(e,t,n){for(var i=new Array(6),r=0;r<6;r++)i[r]=g.getRes(t[r]);e._cache=e._createCache;var a=pi._parse(i,e._propertyParams,e._constructParams);for(n.recover(),r=0;r<6;r++)g.clearRes(t[r]);Laya3D._endLoad(e,a)},Laya3D._onProcessChange=function(e,t,n,i){(i=t+i*n)<1&&e.event("progress",i)},Laya3D.init=function(t,n,i,r){if(!Laya3D._isInit){Laya3D._isInit=!0,(i=i||Ye._default).cloneTo(Laya3D._config),Laya3D._editerEnvironment=Laya3D._config._editerEnvironment;var a=e.Physics3D;null==a?(Laya3D._enbalePhysics=!1,Laya3D.__init__(t,n,Laya3D._config),r&&r.run()):(Laya3D._enbalePhysics=!0,a(1024*Laya3D._config.defaultPhysicsMemory*1024).then(function(){Laya3D.__init__(t,n,Laya3D._config),r&&r.run()}))}},Laya3D.HIERARCHY="HIERARCHY",Laya3D.MESH="MESH",Laya3D.MATERIAL="MATERIAL",Laya3D.TEXTURE2D="TEXTURE2D",Laya3D.TEXTURECUBE="TEXTURECUBE",Laya3D.ANIMATIONCLIP="ANIMATIONCLIP",Laya3D.AVATAR="AVATAR",Laya3D.TERRAINHEIGHTDATA="TERRAINHEIGHTDATA",Laya3D.TERRAINRES="TERRAIN",Laya3D._isInit=!1,Laya3D._enbalePhysics=!1,Laya3D._editerEnvironment=!1,i(Laya3D,["_innerFirstLevelLoaderManager",function(){return this._innerFirstLevelLoaderManager=new x},"_innerSecondLevelLoaderManager",function(){return this._innerSecondLevelLoaderManager=new x},"_innerThirdLevelLoaderManager",function(){return this._innerThirdLevelLoaderManager=new x},"_innerFourthLevelLoaderManager",function(){return this._innerFourthLevelLoaderManager=new x},"_physics3D",function(){return this._physics3D=e.Physics3D},"_config",function(){return this._config=new Ye},"physicsSettings",function(){return this.physicsSettings=new le}]),Laya3D}(),bt=function(){function AnimatorControllerLayer(e){this._defaultState=null,this._statesMap={},this.playOnWake=!0,this._playType=-1,this._crossMark=0,this._crossDuration=-1,this._crossNodesOwnersIndicesMap={},this._crossNodesOwnersCount=0,this._crossNodesOwners=[],this._currentPlayState=null,this._states=[],this._playStateInfo=new rt,this._crossPlayStateInfo=new rt,this._srcCrossClipNodeIndices=[],this._destCrossClipNodeIndices=[],this.name=e,this.defaultWeight=1,this.blendingMode=laya.d3.component.AnimatorControllerLayer.BLENDINGMODE_OVERRIDE}r(AnimatorControllerLayer,"laya.d3.component.AnimatorControllerLayer");var e=AnimatorControllerLayer.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e.getAnimatorState=function(e){var t=this._statesMap[e];return t||null},e.destroy=function(){this._statesMap=null,this._states=null,this._playStateInfo=null,this._crossPlayStateInfo=null,this._defaultState=null},e.cloneTo=function(e){var t=e;t.name=this.name,t.blendingMode=this.blendingMode,t.defaultWeight=this.defaultWeight,t.playOnWake=this.playOnWake},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,e,"defaultState",function(){return this._defaultState},function(e){this._defaultState=e,this._statesMap[e.name]=e}),AnimatorControllerLayer.BLENDINGMODE_OVERRIDE=0,AnimatorControllerLayer.BLENDINGMODE_ADDTIVE=1,AnimatorControllerLayer}(),Ft=function(){function AnimatorState(){this.speed=1,this.clipStart=0,this.clipEnd=1,this._nodeOwners=[]}r(AnimatorState,"laya.d3.component.AnimatorState");var e=AnimatorState.prototype;return n.imps(e,{"laya.d3.core.IClone":!0}),e._resetFrameIndices=function(){for(var e=0,t=this._currentFrameIndices.length;e>>19^this._temp[0]^this._temp[0]>>>8,this.seeds[3]},e.getFloat=function(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)},e.getSignedFloat=function(){return 2*this.getFloat()-1},a(0,e,"seed",function(){return this.seeds[0]},function(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}),Rand.getFloatFromInt=function(e){return 1/8388607*(8388607&e)},Rand.getByteFromInt=function(e){return(8388607&e)>>>15},Rand}(),kt=function(){function Physics3DUtils(){}return r(Physics3DUtils,"laya.d3.utils.Physics3DUtils"),Physics3DUtils.setColliderCollision=function(e,t,n){},Physics3DUtils.getIColliderCollision=function(e,t){return!1},Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER=1,Physics3DUtils.COLLISIONFILTERGROUP_STATICFILTER=2,Physics3DUtils.COLLISIONFILTERGROUP_KINEMATICFILTER=4,Physics3DUtils.COLLISIONFILTERGROUP_DEBRISFILTER=8,Physics3DUtils.COLLISIONFILTERGROUP_SENSORTRIGGER=16,Physics3DUtils.COLLISIONFILTERGROUP_CHARACTERFILTER=32,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER1=64,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER2=128,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER3=256,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER4=512,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER5=1024,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER6=2048,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER7=4096,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER8=8192,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER9=16384,Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER10=32768,Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER=-1,i(Physics3DUtils,["gravity",function(){return this.gravity=new Rt(0,-9.81,0)}]),Physics3DUtils}(),Wt=function(e){function AnimationTransform3D(e,t,n,i,r){AnimationTransform3D.__super.call(this),this._owner=e,this._children=[],this._localMatrix=new Float32Array(16),R.supportWebGLPlusAnimation?(this._localPosition=new z(0,0,0,t),this._localRotation=new G(0,0,0,1,n),this._localScale=new z(0,0,0,i),this._worldMatrix=r):(this._localPosition=new Rt,this._localRotation=new dt,this._localScale=new Rt,this._worldMatrix=new Float32Array(16)),this._localQuaternionUpdate=!1,this._locaEulerlUpdate=!1,this._localUpdate=!1,this._worldUpdate=!0}r(AnimationTransform3D,"laya.d3.animation.AnimationTransform3D",T);var t=AnimationTransform3D.prototype;return t._getlocalMatrix=function(){return this._localUpdate&&(fe._createAffineTransformationArray(this._localPosition,this._localRotation,this._localScale,this._localMatrix),this._localUpdate=!1),this._localMatrix},t._onWorldTransform=function(){if(!this._worldUpdate){this._worldUpdate=!0,this.event("transformchanged");for(var e=0,t=this._children.length;e=n.length){var r=n;(n=Nt._cullingBuffer=new Float32Array(n.length+4096)).set(r,0)}n[t]=2,Nt._cullingBufferLength=i}this._renderElements=[],this._owner=e,this._enable=!0,this._materialsInstance=[],this._shaderValues=new st(null),this._defineDatas=new Bt,this.lightmapIndex=-1,this._castShadow=!1,this.receiveShadow=!1,this.sortingFudge=0,e&&this._owner.transform.on("transformchanged",this,this._onWorldMatNeedChange)}r(BaseRender,"laya.d3.core.render.BaseRender",T);var t=BaseRender.prototype;return n.imps(t,{"laya.resource.ISingletonElement":!0,"laya.d3.core.scene.IOctreeObject":!0}),t._getOctreeNode=function(){return this._octreeNode},t._setOctreeNode=function(e){this._octreeNode=e},t._getIndexInMotionList=function(){return this._indexInOctreeMotionList},t._setIndexInMotionList=function(e){this._indexInOctreeMotionList=e},t._changeMaterialReference=function(e,t){e&&e._removeReference(),t._addReference()},t._getInstanceMaterial=function(e,t){var n=new e.constructor;return e.cloneTo(n),n.name=n.name+"(Instance)",this._materialsInstance[t]=!0,this._changeMaterialReference(this._sharedMaterials[t],n),this._sharedMaterials[t]=n,n},t._applyLightMapParams=function(){if(this._scene&&this._lightmapIndex>=0){var e=this._scene.getlightmaps();this._lightmapIndex=r){if(t._finish=!0,t._elapsedTime=r,t._normalizedPlayTime=1,h)for(var u=0,c=h.length;u=0&&(o=t[n]).time>=i;n--)for(s=0,l=e.length;s=t._lastElapsedTime;if(t._lastIsFront!==h&&(h?t._playEventIndex++:t._playEventIndex--,t._lastIsFront=h),0==l)t._playEventIndex=this._eventScript(n,r,t._playEventIndex,s,h);else if(h){this._eventScript(n,r,t._playEventIndex,a,!0);for(var u=0,c=l-1;un._lastElapsedTime;r._evaluateClipDatasRealTime(r._nodes,o,s,t,l)},t._applyFloat=function(e,t,n,i,r,a,o){if(n.updateMark===this._updateMark)if(i)e[t]+=r*o;else{var s=e[t];e[t]=s+r*(o-s)}else if(a)e[t]=i?n.defaultValue+o:o;else if(i)e[t]=n.defaultValue+r*o;else{var l=n.defaultValue;e[t]=l+r*(o-l)}},t._applyPositionAndRotationEuler=function(e,t,n,i,r,a){if(e.updateMark===this._updateMark)if(t)a.x+=n*r.x,a.y+=n*r.y,a.z+=n*r.z;else{var o=a.x,s=a.y,l=a.z;a.x=o+n*(r.x-o),a.y=s+n*(r.y-s),a.z=l+n*(r.z-l)}else if(i)if(t){var h=e.defaultValue;a.x=h.x+r.x,a.y=h.y+r.y,a.z=h.z+r.z}else a.x=r.x,a.y=r.y,a.z=r.z;else if(h=e.defaultValue,t)a.x=h.x+n*r.x,a.y=h.y+n*r.y,a.z=h.z+n*r.z;else{var u=h.x,c=h.y,d=h.z;a.x=u+n*(r.x-u),a.y=c+n*(r.y-c),a.z=d+n*(r.z-d)}},t._applyRotation=function(e,t,n,i,r,a){if(e.updateMark===this._updateMark)if(t){var o=Animator._tempQuaternion1;fe.quaternionWeight(r,n,o),o.normalize(o),dt.multiply(a,o,a)}else dt.lerp(a,r,n,a);else if(i)if(t){var s=e.defaultValue;dt.multiply(s,r,a)}else a.x=r.x,a.y=r.y,a.z=r.z,a.w=r.w;else s=e.defaultValue,t?(o=Animator._tempQuaternion1,fe.quaternionWeight(r,n,o),o.normalize(o),dt.multiply(s,o,a)):dt.lerp(s,r,n,a)},t._applyScale=function(e,t,n,i,r,a){if(e.updateMark===this._updateMark)if(t){var o=Animator._tempVector31;fe.scaleWeight(r,n,o),a.x=a.x*o.x,a.y=a.y*o.y,a.z=a.z*o.z}else fe.scaleBlend(a,r,n,a);else if(i)if(t){var s=e.defaultValue;a.x=s.x*r.x,a.y=s.y*r.y,a.z=s.z*r.z}else a.x=r.x,a.y=r.y,a.z=r.z;else s=e.defaultValue,t?(o=Animator._tempVector31,fe.scaleWeight(r,n,o),a.x=s.x*o.x,a.y=s.y*o.y,a.z=s.z*o.z):fe.scaleBlend(s,r,n,a)},t._applyCrossData=function(e,t,n,i,r,a,o){var s=e.propertyOwner;if(s){switch(e.type){case 0:for(var l=e.property,h=l.length-1,u=0;uS?S/p:1,v=this._speed*f.speed;this._updatePlayer(f,l,r*E*v,m.islooping);var g=(l._elapsedTime-T)/E/p;g>=1?e&&(this._updateClipDatas(f,_,l,a*v),this._setClipDatasToNode(f,_,o.defaultWeight,0===t),o._playType=0,o._currentPlayState=f,l._cloneTo(s)):(s._finish||(c=this._speed*h.speed,this._updatePlayer(h,s,r*c,u.islooping),e&&this._updateClipDatas(h,_,s,a*c)),e&&(this._updateClipDatas(f,_,l,a*E*v),this._setCrossClipDatasToNode(o,h,f,g,0===t))),e&&(this._updateEventScript(h,s),this._updateEventScript(f,l));break;case 2:m=(f=o._crossPlayState)._clip,p=o._crossDuration,T=l._startPlayTime,E=p>(S=m._duration-T)?S/p:1,v=this._speed*f.speed,this._updatePlayer(f,l,r*E*v,m.islooping),e&&((g=(l._elapsedTime-T)/E/p)>=1?(this._updateClipDatas(f,_,l,a*v),this._setClipDatasToNode(f,_,1,0===t),o._playType=0,o._currentPlayState=f,l._cloneTo(s)):(this._updateClipDatas(f,_,l,a*E*v),this._setFixedCrossClipDatasToNode(o,f,g,0===t)),this._updateEventScript(f,l))}}e&&this._avatar&&(R.supportWebGLPlusAnimation&&this._updateAnimationNodeWorldMatix(this._animationNodeLocalPositions,this._animationNodeLocalRotations,this._animationNodeLocalScales,this._animationNodeWorldMatrixs,this._animationNodeParentIndices),this._updateAvatarNodesToSprite())}},t._cloneTo=function(e){var t=e;t.avatar=this.avatar;for(var n=0,i=this._controllerLayers.length;n0&&t.setCollisionFlags(8^n)},t._onAdded=function(){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("transformchanged",this,this._onTransformChanged)},t._onDestroy=function(){var t=wt._physics3D;delete PhysicsComponent._physicObjectsMap[this.id],t.destroy(this._nativeColliderObject),this._colliderShape.destroy(),e.prototype._onDestroy.call(this),this._nativeColliderObject=null,this._colliderShape=null,this._simulation=null,this.owner.transform.off("transformchanged",this,this._onTransformChanged)},t._onTransformChanged=function(e){PhysicsComponent._addUpdateList&&(e&=56)&&(this._transformFlag|=e,this._isValid()&&-1===this._inPhysicUpdateListIndex&&this._simulation._physicsUpdateList.add(this))},t._cloneTo=function(e){var t=e;t.restitution=this._restitution,t.friction=this._friction,t.rollingFriction=this._rollingFriction,t.ccdMotionThreshold=this._ccdMotionThreshold,t.ccdSweptSphereRadius=this._ccdSweptSphereRadius,t.collisionGroup=this._collisionGroup,t.canCollideWith=this._canCollideWith,t.canScaleShape=this.canScaleShape,this._colliderShape&&(t.colliderShape=this._colliderShape.clone())},a(0,t,"isActive",function(){return!!this._nativeColliderObject&&this._nativeColliderObject.isActive()}),a(0,t,"restitution",function(){return this._restitution},function(e){this._restitution=e,this._nativeColliderObject&&this._nativeColliderObject.setRestitution(e)}),a(0,t,"friction",function(){return this._friction},function(e){this._friction=e,this._nativeColliderObject&&this._nativeColliderObject.setFriction(e)}),a(0,t,"rollingFriction",function(){return this._nativeColliderObject.getRollingFriction()},function(e){this._rollingFriction=e,this._nativeColliderObject&&this._nativeColliderObject.setRollingFriction(e)}),a(0,t,"ccdMotionThreshold",function(){return this._ccdMotionThreshold},function(e){this._ccdMotionThreshold=e,this._nativeColliderObject&&this._nativeColliderObject.setCcdMotionThreshold(e)}),a(0,t,"ccdSweptSphereRadius",function(){return this._ccdSweptSphereRadius},function(e){this._ccdSweptSphereRadius=e,this._nativeColliderObject&&this._nativeColliderObject.setCcdSweptSphereRadius(e)}),a(0,t,"collisionGroup",function(){return this._collisionGroup},function(e){this._collisionGroup!==e&&(this._collisionGroup=e,this._simulation&&this._colliderShape&&this._enabled&&(this._removeFromSimulation(),this._addToSimulation()))}),a(0,t,"simulation",function(){return this._simulation}),a(0,t,"colliderShape",function(){return this._colliderShape},function(e){var t=this._colliderShape;if(t&&(t._attatched=!1,t._attatchedCollisionObject=null),this._colliderShape=e,e){if(e._attatched)throw"PhysicsComponent: this shape has attatched to other entity.";if(e._attatched=!0,e._attatchedCollisionObject=this,this._nativeColliderObject){this._nativeColliderObject.setCollisionShape(e._nativeShape);var n=this._simulation&&this._enabled;n&&t&&this._removeFromSimulation(),this._onShapeChange(e),n&&(this._derivePhysicsTransformation(!0),this._addToSimulation())}}else this._simulation&&this._enabled&&t&&this._removeFromSimulation()}),a(0,t,"enabled",e.prototype._$get_enabled,function(e){this._simulation&&this._colliderShape&&(e?(this._derivePhysicsTransformation(!0),this._addToSimulation()):this._removeFromSimulation()),n.superSet(f,this,"enabled",e)}),a(0,t,"canCollideWith",function(){return this._canCollideWith},function(e){this._canCollideWith!==e&&(this._canCollideWith=e,this._simulation&&this._colliderShape&&this._enabled&&(this._removeFromSimulation(),this._addToSimulation()))}),PhysicsComponent._createAffineTransformationArray=function(e,t,n,i,r,a,o,s,l){var h=i+i,u=r+r,c=a+a,d=i*h,_=i*u,f=i*c,m=r*u,p=r*c,T=a*c,S=o*h,E=o*u,v=o*c,g=s[0],x=s[1],M=s[2];l[0]=(1-(m+T))*g,l[1]=(_+v)*g,l[2]=(f-E)*g,l[3]=0,l[4]=(_-v)*x,l[5]=(1-(d+T))*x,l[6]=(p+S)*x,l[7]=0,l[8]=(f+E)*M,l[9]=(p-S)*M,l[10]=(1-(d+m))*M,l[11]=0,l[12]=e,l[13]=t,l[14]=n,l[15]=1},PhysicsComponent.physicVector3TransformQuat=function(e,t,n,i,r,a){var o=e.x,s=e.y,l=e.z,h=r*o+n*l-i*s,u=r*s+i*o-t*l,c=r*l+t*s-n*o,d=-t*o-n*s-i*l;a.x=h*r+d*-t+u*-i-c*-n,a.y=u*r+d*-n+c*-t-h*-i,a.z=c*r+d*-i+h*-n-u*-t},PhysicsComponent.physicQuaternionMultiply=function(e,t,n,i,r,a){var o=r.x,s=r.y,l=r.z,h=r.w,u=t*l-n*s,c=n*o-e*l,d=e*s-t*o,_=e*o+t*s+n*l;a.x=e*h+o*i+u,a.y=t*h+s*i+c,a.z=n*h+l*i+d,a.w=i*h-_},PhysicsComponent.ACTIVATIONSTATE_ACTIVE_TAG=1,PhysicsComponent.ACTIVATIONSTATE_ISLAND_SLEEPING=2,PhysicsComponent.ACTIVATIONSTATE_WANTS_DEACTIVATION=3,PhysicsComponent.ACTIVATIONSTATE_DISABLE_DEACTIVATION=4,PhysicsComponent.ACTIVATIONSTATE_DISABLE_SIMULATION=5,PhysicsComponent.COLLISIONFLAGS_STATIC_OBJECT=1,PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT=2,PhysicsComponent.COLLISIONFLAGS_NO_CONTACT_RESPONSE=4,PhysicsComponent.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK=8,PhysicsComponent.COLLISIONFLAGS_CHARACTER_OBJECT=16,PhysicsComponent.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT=32,PhysicsComponent.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING=64,PhysicsComponent._physicObjectsMap={},PhysicsComponent._addUpdateList=!0,i(PhysicsComponent,["_tempVector30",function(){return this._tempVector30=new Rt},"_tempQuaternion0",function(){return this._tempQuaternion0=new dt},"_tempQuaternion1",function(){return this._tempQuaternion1=new dt},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new Q},"_nativeVector30",function(){return this._nativeVector30=new wt._physics3D.btVector3(0,0,0)},"_nativeQuaternion0",function(){return this._nativeQuaternion0=new wt._physics3D.btQuaternion(0,0,0,1)}]),PhysicsComponent}(f),Qt=function(e){function IndexBuffer3D(e,t,n,i){this._indexType=null,this._indexTypeByteCount=0,this._indexCount=0,this._canRead=!1,void 0===n&&(n=35044),void 0===i&&(i=!1),IndexBuffer3D.__super.call(this),this._indexType=e,this._indexCount=t,this._bufferUsage=n,this._bufferType=34963,this._canRead=i;var r;if("ushort"==e)this._indexTypeByteCount=2;else{if("ubyte"!=e)throw new Error("unidentification index type.");this._indexTypeByteCount=1}r=this._indexTypeByteCount*t,this._byteLength=r;var a=u._curBindedBufferState;a?a._bindedIndexBuffer===this?E.instance.bufferData(this._bufferType,r,this._bufferUsage):(a.unBind(),this.bind(),E.instance.bufferData(this._bufferType,r,this._bufferUsage),a.bind()):(this.bind(),E.instance.bufferData(this._bufferType,r,this._bufferUsage)),i&&("ushort"==e?this._buffer=new Uint16Array(t):"ubyte"==e&&(this._buffer=new Uint8Array(t)))}r(IndexBuffer3D,"laya.d3.graphics.IndexBuffer3D",e);var t=IndexBuffer3D.prototype;return t._bindForVAO=function(){if(!u._curBindedBufferState)throw"IndexBuffer3D: must bind current BufferState.";E.instance.bindBuffer(34963,this._glBuffer)},t.bind=function(){if(u._curBindedBufferState)throw"IndexBuffer3D: must unbind current BufferState.";return h._bindedIndexBuffer!==this._glBuffer&&(E.instance.bindBuffer(34963,this._glBuffer),h._bindedIndexBuffer=this._glBuffer,!0)},t.setData=function(e,t,n,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=4294967295);var r=0;"ushort"==this._indexType?(r=2,0===n&&4294967295===i||(e=new Uint16Array(e.buffer,n*r,i))):"ubyte"==this._indexType&&(r=1,0===n&&4294967295===i||(e=new Uint8Array(e.buffer,n*r,i)));var a=u._curBindedBufferState;if(a?a._bindedIndexBuffer===this?E.instance.bufferSubData(this._bufferType,t*r,e):(a.unBind(),this.bind(),E.instance.bufferSubData(this._bufferType,t*r,e),a.bind()):(this.bind(),E.instance.bufferSubData(this._bufferType,t*r,e)),this._canRead)if(0!==t||0!==n||4294967295!==i){var o=this._buffer.length-t;i>o&&(i=o);for(var s=0;se);r++){e&i&&(n[t[i]]="")}return n},t._compileToTree=function(e,t,n,i,r){var a,o,s,l,h,u,c,d=0,_=0,f=0,m=0;for(_=n;_=0&&(s=s.substr(0,d)),a=c||new L(i),c=null,a.text=s,(d=s.indexOf("#"))>=0){for(l="#",m=d+1,f=s.length;m0&&A.splitToWords(s,o),c=a,o.text+="\n"+s;continue}i.length>0&&A.splitToWords(s,a)}a.setParent(e)}},t.withCompile=function(e,t,n){var i,r,a;if(e&=this._publicValidDefine,t&=this._spriteValidDefine,n&=this._materialValidDefine,r=this._cacheSharders[e])if(a=r[t]){if(i=a[n])return i}else a=r[t]=[];else a=(r=this._cacheSharders[e]=[])[t]=[];var o,s=this._definesToNameDic(e,this._owner._publicDefines),l=this._definesToNameDic(t,this._owner._spriteDefines),h=this._definesToNameDic(n,this._owner._materialDefines);if(At.debugMode){var u="";for(o in s)u+=o+" ";var c="";for(o in l)c+=o+" ";var d="";for(o in h)d+=o+" ";b.shaderHighPrecision||(e+=At.SHADERDEFINE_HIGHPRECISION),console.log("%cShader3DDebugMode---(Name:"+this._owner._owner._name+" PassIndex:"+this._owner._passes.indexOf(this)+" PublicDefine:"+e+" SpriteDefine:"+t+" MaterialDefine:"+n+" PublicDefineGroup:"+u+" SpriteDefineGroup:"+c+"MaterialDefineGroup: "+d+")---ShaderCompile3DDebugMode","color:green")}var _={},f="";if(s)for(o in s)f+="#define "+o+"\n",_[o]=!0;if(l)for(o in l)f+="#define "+o+"\n",_[o]=!0;if(h)for(o in h)f+="#define "+o+"\n",_[o]=!0;var m=this._VS.toscript(_,[]),p="";0==m[0].indexOf("#version")&&(p=m[0]+"\n",m.shift());var T=this._PS.toscript(_,[]),S="";return 0==T[0].indexOf("#version")&&(S=T[0]+"\n",T.shift()),i=new Hn(p+f+m.join("\n"),S+f+T.join("\n"),this._owner._attributeMap||this._owner._owner._attributeMap,this._owner._uniformMap||this._owner._owner._uniformMap,this),a[n]=i,i},a(0,t,"renderState",function(){return this._renderState}),ShaderPass}(),$t=function(e){function MeshRenderDynamicBatchManager(){this._instanceBatchOpaqueMarks=[],this._vertexBatchOpaqueMarks=[],this._cacheBufferStates=[],MeshRenderDynamicBatchManager.__super.call(this),Cn.instance=new Cn,this._updateCountMark=0}r(MeshRenderDynamicBatchManager,"laya.d3.graphics.MeshRenderDynamicBatchManager",e);var t=MeshRenderDynamicBatchManager.prototype;return t.getInstanceBatchOpaquaMark=function(e,t,n,i){var r=this._instanceBatchOpaqueMarks[e]||(this._instanceBatchOpaqueMarks[e]=[]),a=r[t?0:1]||(r[t?0:1]=[]),o=a[n]||(a[n]=[]);return o[i]||(o[i]=new Ge)},t.getVertexBatchOpaquaMark=function(e,t,n,i){var r=this._vertexBatchOpaqueMarks[e]||(this._vertexBatchOpaqueMarks[e]=[]),a=r[t?0:1]||(r[t?0:1]=[]),o=a[n]||(a[n]=[]);return o[i]||(o[i]=new Ge)},t._getBufferState=function(e){var t=this._cacheBufferStates[e.id];if(!t){var n=Cn.instance;(t=new Zt).bind();var i=n._vertexBuffer;i.vertexDeclaration=e,t.applyVertexBuffer(i),t.applyIndexBuffer(n._indexBuffer),t.unBind(),this._cacheBufferStates[e.id]=t}return t},t._getBatchRenderElementFromPool=function(){var e=this._batchRenderElementPool[this._batchRenderElementPoolIndex++];return e||(e=new Pn,this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=e,e.vertexBatchElementList=[],e.instanceBatchElementList=[]),e},t._clear=function(){e.prototype._clear.call(this),this._updateCountMark++},i(MeshRenderDynamicBatchManager,["instance",function(){return this.instance=new MeshRenderDynamicBatchManager}]),MeshRenderDynamicBatchManager}(j),en=function(e){function SphereColliderShape(e){SphereColliderShape.__super.call(this),void 0===e&&(e=.5),this._radius=e,this._type=1,this._nativeShape=new wt._physics3D.btSphereShape(e)}r(SphereColliderShape,"laya.d3.physics.shape.SphereColliderShape",J);var t=SphereColliderShape.prototype;return t.clone=function(){var e=new SphereColliderShape(this._radius);return this.cloneTo(e),e},a(0,t,"radius",function(){return this._radius}),SphereColliderShape}(),tn=(function(e){function StaticPlaneColliderShape(e,t){StaticPlaneColliderShape.__super.call(this),this._normal=e,this._offset=t,this._type=6,StaticPlaneColliderShape._nativeNormal.setValue(-e.x,e.y,e.z),this._nativeShape=new wt._physics3D.btStaticPlaneShape(StaticPlaneColliderShape._nativeNormal,t)}r(StaticPlaneColliderShape,"laya.d3.physics.shape.StaticPlaneColliderShape",J),StaticPlaneColliderShape.prototype.clone=function(){var e=new StaticPlaneColliderShape(this._normal,this._offset);return this.cloneTo(e),e},i(StaticPlaneColliderShape,["_nativeNormal",function(){return this._nativeNormal=new wt._physics3D.btVector3(0,0,0)}])}(),function(e){function SubMesh(e){this._mesh=null,this._boneIndicesList=null,this._subIndexBufferStart=null,this._subIndexBufferCount=null,this._skinAnimationDatas=null,this._indexInMesh=0,this._vertexStart=0,this._indexStart=0,this._indexCount=0,this._indices=null,this._vertexBuffer=null,this._indexBuffer=null,this._id=0,SubMesh.__super.call(this),this._id=++SubMesh._uniqueIDCounter,this._mesh=e,this._boneIndicesList=[],this._subIndexBufferStart=[],this._subIndexBufferCount=[]}r(SubMesh,"laya.d3.resource.models.SubMesh",e);var t=SubMesh.prototype;return t._getType=function(){return SubMesh._type},t._render=function(e){this._mesh._bufferState.bind();var t=e.renderElement.render._skinnedData;if(t)for(var n=t[this._indexInMesh],i=this._boneIndicesList.length,r=0;r=ft.zeroTolerance?(this._isTempEndVertex?(o=this._endIndex-1,s=a-this._subDistance[o],this._updateVerticesByPosition(t,i,a,o),this._owner._totalLength+=s):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(t,i,a,this._endIndex),this._owner._totalLength+=a,this._endIndex++),t.cloneTo(this._lastFixedVertexPosition),this._isTempEndVertex=!1):(this._isTempEndVertex?(o=this._endIndex-1,s=a-this._subDistance[o],this._updateVerticesByPosition(t,i,a,o),this._owner._totalLength+=s):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(t,i,a,this._endIndex),this._owner._totalLength+=a,this._endIndex++),this._isTempEndVertex=!0)},t._updateVerticesByPositionData=function(e,t,n){var i=2*this._floatCountPerVertices1*n,r=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]=r,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]=r,this._vertices1[i+15]=0;var a=2*this._floatCountPerVertices1;this._vertexBuffer1.setData(this._vertices1,i,i,a)},t._updateVerticesByPosition=function(e,t,n,i){this._updateVerticesByPositionData(e,t,i),this._subDistance[i]=n,this._subBirthTime[i]=this._owner._curtime},t._updateVertexBufferUV=function(){for(var e=this._endIndex,t=0,n=this._activeIndex,i=e;n=this._owner.time+ft.zeroTolerance;t++){var n=t+1;if(n!==e&&(this._owner._totalLength-=this._subDistance[n]),this._isTempEndVertex&&n===e-1){this._floatCountPerVertices1;var i=this._lastFixedVertexPosition;i.x=this._vertices1[0],i.y=this._vertices1[1],i.z=this._vertices1[2],this._isTempEndVertex=!1}this._activeIndex++}},t._getType=function(){return TrailGeometry._type},t._prepareRender=function(e){return this._endIndex-this._activeIndex>1},t._render=function(e){this._bufferState.bind();var t=2*this._activeIndex,n=2*this._endIndex-t;E.instance.drawArrays(5,t,n),P.renderBatches++,P.trianglesFaces+=n-2},t.destroy=function(){e.prototype.destroy.call(this);var t=this._vertexBuffer1._byteLength+this._vertexBuffer2._byteLength;C._addMemory(-t,-t),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},i(TrailGeometry,["_tempVector30",function(){return this._tempVector30=new Rt},"_tempVector31",function(){return this._tempVector31=new Rt},"_tempVector32",function(){return this._tempVector32=new Rt},"_type",function(){return this._type=re._typeCounter++}]),TrailGeometry}(re),an=function(e){function VertexShurikenParticleMesh(e,t,n,i,r,a,o,s,l,h,u,c,d,_){this._cornerTextureCoordinate=null,this._positionStartLifeTime=null,this._velocity=null,this._startColor=null,this._startSize=null,this._startRotation0=null,this._startRotation1=null,this._startRotation2=null,this._startLifeTime=NaN,this._time=NaN,this._startSpeed=NaN,this._randoms0=null,this._randoms1=null,this._simulationWorldPostion=null,VertexShurikenParticleMesh.__super.call(this),this._cornerTextureCoordinate=e,this._positionStartLifeTime=t,this._velocity=n,this._startColor=i,this._startSize=r,this._startRotation0=a,this._startRotation1=o,this._startRotation2=s,this._startLifeTime=l,this._time=h,this._startSpeed=u,this._randoms0=this.random0,this._randoms1=this.random1,this._simulationWorldPostion=_}r(VertexShurikenParticleMesh,"laya.d3.graphics.Vertex.VertexShurikenParticleMesh",Z);var t=VertexShurikenParticleMesh.prototype;return a(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),a(0,t,"velocity",function(){return this._velocity}),a(0,t,"position",function(){return this._positionStartLifeTime}),a(0,t,"random0",function(){return this._randoms0}),a(0,t,"startSize",function(){return this._startSize}),a(0,t,"startColor",function(){return this._startColor}),a(0,t,"startRotation0",function(){return this._startRotation0}),a(0,t,"startRotation1",function(){return this._startRotation1}),a(0,t,"random1",function(){return this._randoms1}),a(0,t,"startRotation2",function(){return this._startRotation2}),a(0,t,"startLifeTime",function(){return this._startLifeTime}),a(0,t,"time",function(){return this._time}),a(0,t,"startSpeed",function(){return this._startSpeed}),a(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),a(1,VertexShurikenParticleMesh,"vertexDeclaration",function(){return VertexShurikenParticleMesh._vertexDeclaration},laya.d3.graphics.Vertex.VertexShuriKenParticle._$SET_vertexDeclaration),i(VertexShurikenParticleMesh,["_vertexDeclaration",function(){return this._vertexDeclaration=new _t(172,[new Y(0,"vector3",1),new Y(12,"vector4",2),new Y(28,"vector2",3),new Y(36,"vector4",4),new Y(52,"vector4",5),new Y(68,"vector4",6),new Y(84,"vector3",8),new Y(96,"vector3",9),new Y(108,"single",10),new Y(112,"vector4",11),new Y(128,"vector4",12),new Y(144,"vector3",13),new Y(156,"vector4",14)])}]),VertexShurikenParticleMesh}(),on=function(e){function SphereShape(){this.radius=NaN,this.emitFromShell=!1,SphereShape.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}r(SphereShape,"laya.d3.core.particleShuriKen.module.shape.SphereShape",e);var t=SphereShape.prototype;return t._getShapeBoundBox=function(e){var t=e.min;t.x=t.y=t.z=-this.radius;var n=e.max;n.x=n.y=n.z=this.radius},t._getSpeedBoundBox=function(e){var t=e.min;t.x=t.y=t.z=-1;var n=e.max;n.x=n.y=n.z=1},t.generatePositionAndDirection=function(e,t,n,i){n?(n.seed=i[16],this.emitFromShell?Me._randomPointUnitSphere(e,n):Me._randomPointInsideUnitSphere(e,n),i[16]=n.seed):this.emitFromShell?Me._randomPointUnitSphere(e):Me._randomPointInsideUnitSphere(e),Rt.scale(e,this.radius,e),this.randomDirection?n?(n.seed=i[17],Me._randomPointUnitSphere(t,n),i[17]=n.seed):Me._randomPointUnitSphere(t):e.cloneTo(t)},t.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.radius=this.radius,n.emitFromShell=this.emitFromShell,n.randomDirection=this.randomDirection},SphereShape}(ce),sn=function(e){function SimpleSingletonList(){SimpleSingletonList.__super.call(this)}r(SimpleSingletonList,"laya.d3.component.SimpleSingletonList",_e);var t=SimpleSingletonList.prototype;return t.add=function(e){-1===e._getIndexInList()&&(this._add(e),e._setIndexInList(this.length++))},t.remove=function(e){var t=e._getIndexInList();if(this.length--,t!==this.length){var n=this.elements[this.length];this.elements[t]=n,n&&n._setIndexInList(t)}e&&e._setIndexInList(-1)},SimpleSingletonList}(),ln=function(e){function CastShadowList(){CastShadowList.__super.call(this)}r(CastShadowList,"laya.d3.CastShadowList",_e);var t=CastShadowList.prototype;return t.add=function(e){if(-1!==e._indexInCastShadowList)throw"CastShadowList:element has in CastShadowList.";this._add(e),e._indexInCastShadowList=this.length++},t.remove=function(e){var t=e._indexInCastShadowList;if(this.length--,t!==this.length){var n=this.elements[this.length];this.elements[t]=n,n._indexInCastShadowList=t}e._indexInCastShadowList=-1},CastShadowList}(),hn=function(e){function HemisphereShape(){this.radius=NaN,this.emitFromShell=!1,HemisphereShape.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}r(HemisphereShape,"laya.d3.core.particleShuriKen.module.shape.HemisphereShape",e);var t=HemisphereShape.prototype;return t._getShapeBoundBox=function(e){var t=e.min;t.x=t.y=t.z=-this.radius;var n=e.max;n.x=n.y=this.radius,n.z=0},t._getSpeedBoundBox=function(e){var t=e.min;t.x=t.y=-1,t.z=0;var n=e.max;n.x=n.y=n.z=1},t.generatePositionAndDirection=function(e,t,n,i){n?(n.seed=i[16],this.emitFromShell?Me._randomPointUnitSphere(e,n):Me._randomPointInsideUnitSphere(e,n),i[16]=n.seed):this.emitFromShell?Me._randomPointUnitSphere(e):Me._randomPointInsideUnitSphere(e),Rt.scale(e,this.radius,e);var r=e.z;r<0&&(e.z=-1*r),this.randomDirection?n?(n.seed=i[17],Me._randomPointUnitSphere(t,n),i[17]=n.seed):Me._randomPointUnitSphere(t):e.cloneTo(t)},t.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.radius=this.radius,n.emitFromShell=this.emitFromShell,n.randomDirection=this.randomDirection},HemisphereShape}(ce),un=function(e){function SubMeshInstanceBatch(){this.maxInstanceCount=1024,SubMeshInstanceBatch.__super.call(this),this.instanceWorldMatrixData=new Float32Array(16*this.maxInstanceCount),this.instanceMVPMatrixData=new Float32Array(16*this.maxInstanceCount),this.instanceWorldMatrixBuffer=new jt(4*this.instanceWorldMatrixData.length,35048),this.instanceMVPMatrixBuffer=new jt(4*this.instanceMVPMatrixData.length,35048),this.instanceWorldMatrixBuffer.vertexDeclaration=Re.instanceWorldMatrixDeclaration,this.instanceMVPMatrixBuffer.vertexDeclaration=Re.instanceMVPMatrixDeclaration}return r(SubMeshInstanceBatch,"laya.d3.graphics.SubMeshInstanceBatch",re),SubMeshInstanceBatch.prototype._render=function(e){var t=e.renderElement,n=t.instanceSubMesh,i=t.instanceBatchElementList.length,r=n._indexCount;n._mesh._instanceBufferState.bind(),F._angleInstancedArrays.drawElementsInstancedANGLE(4,r,5123,2*n._indexStart,i),P.renderBatches++,P.savedRenderBatches+=i-1,P.trianglesFaces+=r*i/3},i(SubMeshInstanceBatch,["instance",function(){return this.instance=new SubMeshInstanceBatch}]),SubMeshInstanceBatch}(),cn=function(e){function TerrainFilter(e,t,n,i,r,a,s,l){this._owner=null,this._gridSize=NaN,this.memorySize=0,this._numberVertices=0,this._maxNumberIndices=0,this._currentNumberIndices=0,this._numberTriangle=0,this._vertexBuffer=null,this._indexBuffer=null,this._indexArrayBuffer=null,this._boundingBoxCorners=null,this._leafs=null,this._leafNum=0,this._terrainHeightData=null,this._terrainHeightDataWidth=0,this._terrainHeightDataHeight=0,this._chunkOffsetX=0,this._chunkOffsetZ=0,this._cameraCoordinateInverse=!1,this._cameraPos=null,this._currentLOD=0,this._perspectiveFactor=NaN,this._LODTolerance=0,this._boundingSphere=null,this._boundingBox=null,TerrainFilter.__super.call(this),this._bufferState=new Zt,this._owner=e,this._cameraPos=new Rt,this._chunkOffsetX=t,this._chunkOffsetZ=n,this._gridSize=i,this._terrainHeightData=r,this._terrainHeightDataWidth=a,this._terrainHeightDataHeight=s,this._leafNum=K.CHUNK_GRID_NUM/K.LEAF_GRID_NUM*(K.CHUNK_GRID_NUM/K.LEAF_GRID_NUM),this._leafs=o(this._leafNum),this._cameraCoordinateInverse=l;for(var h=0;h0){for(var i=0;ie.y?this._leafs[t]._sizeOfY.y:e.y;var n=new Rt(this._chunkOffsetX*K.CHUNK_GRID_NUM*this._gridSize,e.x,this._chunkOffsetZ*K.CHUNK_GRID_NUM*this._gridSize),i=new Rt((this._chunkOffsetX+1)*K.CHUNK_GRID_NUM*this._gridSize,e.y,(this._chunkOffsetZ+1)*K.CHUNK_GRID_NUM*this._gridSize);K.__ADAPT_MATRIX__&&(Rt.transformV3ToV3(n,K.__ADAPT_MATRIX__,n),Rt.transformV3ToV3(i,K.__ADAPT_MATRIX__,i)),this._boundingBox=new mt(n,i);var r=new Rt;Rt.subtract(i,n,r),Rt.scale(r,.5,r);var a=new Rt;Rt.add(n,r,a),this._boundingSphere=new It(a,Rt.scalarLength(r)),this._boundingBoxCorners=o(8,null),this._boundingBox.getCorners(this._boundingBoxCorners)},t.calcLeafBoudingBox=function(e){for(var t=0;t0?SetRenderTargetCMD._pool.pop():new SetRenderTargetCMD)._renderTexture=e,t},SetRenderTargetCMD._pool=[],SetRenderTargetCMD}(),pn=function(e){function PhysicsUpdateList(){PhysicsUpdateList.__super.call(this)}r(PhysicsUpdateList,"laya.d3.physics.PhysicsUpdateList",_e);var t=PhysicsUpdateList.prototype;return t.add=function(e){if(-1!==e._inPhysicUpdateListIndex)throw"PhysicsUpdateList:element has in PhysicsUpdateList.";this._add(e),e._inPhysicUpdateListIndex=this.length++},t.remove=function(e){var t=e._inPhysicUpdateListIndex;if(this.length--,t!==this.length){var n=this.elements[this.length];this.elements[t]=n,n._inPhysicUpdateListIndex=t}e._inPhysicUpdateListIndex=-1},PhysicsUpdateList}(),Tn=function(e){function ConeShape(){this.angle=NaN,this.radius=NaN,this.length=NaN,this.emitType=0,ConeShape.__super.call(this),this.angle=25/180*Math.PI,this.radius=1,this.length=5,this.emitType=0,this.randomDirection=!1}r(ConeShape,"laya.d3.core.particleShuriKen.module.shape.ConeShape",e);var t=ConeShape.prototype;return t._getShapeBoundBox=function(e){var t=this.radius+this.length*Math.sin(this.angle),n=this.length*Math.cos(this.angle),i=e.min;i.x=i.y=-t,i.z=0;var r=e.max;r.x=r.y=t,r.z=n},t._getSpeedBoundBox=function(e){var t=Math.sin(this.angle),n=e.min;n.x=n.y=-t,n.z=0;var i=e.max;i.x=i.y=t,i.z=1},t.generatePositionAndDirection=function(e,t,n,i){var r,a=ConeShape._tempPositionPoint,o=NaN,s=NaN,l=Math.cos(this.angle),h=Math.sin(this.angle);switch(this.emitType){case 0:n?(n.seed=i[16],Me._randomPointInsideUnitCircle(ConeShape._tempPositionPoint,n),i[16]=n.seed):Me._randomPointInsideUnitCircle(ConeShape._tempPositionPoint),o=a.x,s=a.y,e.x=o*this.radius,e.y=s*this.radius,e.z=0,this.randomDirection?(n?(n.seed=i[17],Me._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint,n),i[17]=n.seed):Me._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint),r=ConeShape._tempDirectionPoint,t.x=r.x*h,t.y=r.y*h):(t.x=o*h,t.y=s*h),t.z=l;break;case 1:n?(n.seed=i[16],Me._randomPointUnitCircle(ConeShape._tempPositionPoint,n),i[16]=n.seed):Me._randomPointUnitCircle(ConeShape._tempPositionPoint),o=a.x,s=a.y,e.x=o*this.radius,e.y=s*this.radius,e.z=0,this.randomDirection?(n?(n.seed=i[17],Me._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint,n),i[17]=n.seed):Me._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint),r=ConeShape._tempDirectionPoint,t.x=r.x*h,t.y=r.y*h):(t.x=o*h,t.y=s*h),t.z=l;break;case 2:n?(n.seed=i[16],Me._randomPointInsideUnitCircle(ConeShape._tempPositionPoint,n)):Me._randomPointInsideUnitCircle(ConeShape._tempPositionPoint),o=a.x,s=a.y,e.x=o*this.radius,e.y=s*this.radius,e.z=0,t.x=o*h,t.y=s*h,t.z=l,Rt.normalize(t,t),n?(Rt.scale(t,this.length*n.getFloat(),t),i[16]=n.seed):Rt.scale(t,this.length*Math.random(),t),Rt.add(e,t,e),this.randomDirection&&(n?(n.seed=i[17],Me._randomPointUnitSphere(t,n),i[17]=n.seed):Me._randomPointUnitSphere(t));break;case 3:n?(n.seed=i[16],Me._randomPointUnitCircle(ConeShape._tempPositionPoint,n)):Me._randomPointUnitCircle(ConeShape._tempPositionPoint),o=a.x,s=a.y,e.x=o*this.radius,e.y=s*this.radius,e.z=0,t.x=o*h,t.y=s*h,t.z=l,Rt.normalize(t,t),n?(Rt.scale(t,this.length*n.getFloat(),t),i[16]=n.seed):Rt.scale(t,this.length*Math.random(),t),Rt.add(e,t,e),this.randomDirection&&(n?(n.seed=i[17],Me._randomPointUnitSphere(t,n),i[17]=n.seed):Me._randomPointUnitSphere(t));break;default:throw new Error("ConeShape:emitType is invalid.")}},t.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.angle=this.angle,n.radius=this.radius,n.length=this.length,n.emitType=this.emitType,n.randomDirection=this.randomDirection},i(ConeShape,["_tempPositionPoint",function(){return this._tempPositionPoint=new Ct},"_tempDirectionPoint",function(){return this._tempDirectionPoint=new Ct}]),ConeShape}(ce),Sn=function(e){function SubMeshStaticBatch(e,t,n){SubMeshStaticBatch.__super.call(this),this._bufferState=new Zt,this._batchID=SubMeshStaticBatch._batchIDCounter++,this._batchElements=[],this._currentBatchVertexCount=0,this._currentBatchIndexCount=0,this._vertexDeclaration=n,this.batchOwner=e,this.number=t}r(SubMeshStaticBatch,"laya.d3.graphics.SubMeshStaticBatch",re);var t=SubMeshStaticBatch.prototype;return n.imps(t,{"laya.resource.IDispose":!0}),t._getStaticBatchBakedVertexs=function(e,t,n,i,r,a){var o,s=a._vertexBuffers[0],l=s.vertexDeclaration,h=l.getVertexElementByUsage(0).offset/4,u=l.getVertexElementByUsage(3),c=u?u.offset/4:-1,d=l.getVertexElementByUsage(1),_=d?d.offset/4:-1,f=l.getVertexElementByUsage(2),m=f?f.offset/4:-1,p=l.getVertexElementByUsage(7),T=p?p.offset/4:-1,S=l.getVertexElementByUsage(4),E=S?S.offset/4:-1,v=l.vertexStride/4,g=s.getData();n?(n.worldMatrix.invert(SubMeshStaticBatch._tempMatrix4x40),o=SubMeshStaticBatch._tempMatrix4x41,Q.multiply(SubMeshStaticBatch._tempMatrix4x40,i.worldMatrix,o)):o=i.worldMatrix;var x=SubMeshStaticBatch._tempQuaternion0;o.decomposeTransRotScale(SubMeshStaticBatch._tempVector30,x,SubMeshStaticBatch._tempVector31);for(var M=r.lightmapScaleOffset,y=a.vertexCount,D=0;D65535)},t.add=function(e){var t=e._render._staticBatch;t&&t.remove(e);var n=e.meshFilter.sharedMesh,i=n.vertexCount;this._batchElements.push(e);var r=e._render;r._isPartOfStaticBatch=!0,r._staticBatch=this;for(var a=r._renderElements,o=0,s=a.length;o0&&(this._bufferState.bind(),E.instance.drawArrays(1,0,2*this._lineCount),P.renderBatches++)},t.destroy=function(){this._destroyed||(e.prototype.destroy.call(this),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferState=null,this._vertexBuffer=null,this._vertices=null)},i(PixelLineFilter,["_type",function(){return this._type=re._typeCounter++}]),PixelLineFilter}(re),vn=function(e){function VertexShurikenParticleBillboard(e,t,n,i,r,a,o,s,l,h,u,c,d,_){this._cornerTextureCoordinate=null,this._positionStartLifeTime=null,this._velocity=null,this._startColor=null,this._startSize=null,this._startRotation0=null,this._startRotation1=null,this._startRotation2=null,this._startLifeTime=NaN,this._time=NaN,this._startSpeed=NaN,this._randoms0=null,this._randoms1=null,this._simulationWorldPostion=null,VertexShurikenParticleBillboard.__super.call(this),this._cornerTextureCoordinate=e,this._positionStartLifeTime=t,this._velocity=n,this._startColor=i,this._startSize=r,this._startRotation0=a,this._startRotation1=o,this._startRotation2=s,this._startLifeTime=l,this._time=h,this._startSpeed=u,this._randoms0=this.random0,this._randoms1=this.random1,this._simulationWorldPostion=_}r(VertexShurikenParticleBillboard,"laya.d3.graphics.Vertex.VertexShurikenParticleBillboard",Z);var t=VertexShurikenParticleBillboard.prototype;return a(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),a(0,t,"random1",function(){return this._randoms1}),a(0,t,"startRotation2",function(){return this._startRotation2}),a(0,t,"positionStartLifeTime",function(){return this._positionStartLifeTime}),a(0,t,"velocity",function(){return this._velocity}),a(0,t,"random0",function(){return this._randoms0}),a(0,t,"startSize",function(){return this._startSize}),a(0,t,"startColor",function(){return this._startColor}),a(0,t,"startRotation0",function(){return this._startRotation0}),a(0,t,"startRotation1",function(){return this._startRotation1}),a(0,t,"startLifeTime",function(){return this._startLifeTime}),a(0,t,"time",function(){return this._time}),a(0,t,"startSpeed",function(){return this._startSpeed}),a(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),a(1,VertexShurikenParticleBillboard,"vertexDeclaration",function(){return VertexShurikenParticleBillboard._vertexDeclaration},laya.d3.graphics.Vertex.VertexShuriKenParticle._$SET_vertexDeclaration),i(VertexShurikenParticleBillboard,["_vertexDeclaration",function(){return this._vertexDeclaration=new _t(152,[new Y(0,"vector4",0),new Y(16,"vector4",4),new Y(32,"vector4",5),new Y(48,"vector4",6),new Y(64,"vector3",8),new Y(76,"vector3",9),new Y(88,"single",10),new Y(92,"vector4",11),new Y(108,"vector4",12),new Y(124,"vector3",13),new Y(136,"vector4",14)])}]),VertexShurikenParticleBillboard}(),gn=function(e){function ConeColliderShape(e,t,n){switch(this._radius=1,this._height=.5,ConeColliderShape.__super.call(this),void 0===e&&(e=.5),void 0===t&&(t=1),void 0===n&&(n=1),this._radius=e,this._height=t,this._orientation=n,this._type=2,n){case 0:this._nativeShape=new wt._physics3D.btConeShapeX(e,t);break;case 1:this._nativeShape=new wt._physics3D.btConeShape(e,t);break;case 2:this._nativeShape=new wt._physics3D.btConeShapeZ(e,t);break;default:throw"ConeColliderShape:unknown orientation."}}r(ConeColliderShape,"laya.d3.physics.shape.ConeColliderShape",J);var t=ConeColliderShape.prototype;return t.clone=function(){var e=new ConeColliderShape(this._radius,this._height,this._orientation);return this.cloneTo(e),e},a(0,t,"radius",function(){return this._radius}),a(0,t,"height",function(){return this._height}),a(0,t,"orientation",function(){return this._orientation}),ConeColliderShape}(),xn=function(e){function BlitCMD(){this._source=null,this._dest=null,this._shader=null,this._shaderData=null,this._subShader=0,BlitCMD.__super.call(this)}r(BlitCMD,"laya.d3.core.render.command.BlitCMD",we);var t=BlitCMD.prototype;return t.run=function(){this._shaderData.setTexture(ut.SCREENTEXTURE_ID,this._source);var e=this._dest;e&&e._start();for(var t=this._shader.getSubShaderAt(this._subShader)._passes,n=0,i=t.length;n0?BlitCMD._pool.pop():new BlitCMD)._source=e,a._dest=t,a._shader=n,a._shaderData=i,a._subShader=r,a},BlitCMD._pool=[],BlitCMD}(),Mn=(function(e){function BloomEffect(){this._shader=null,this._pyramid=null,this._intensity=0,this._threshold=1,this._softKnee=.5,this._diffusion=7,this._anamorphicRatio=0,this._dirtIntensity=0,this.clamp=65472,this.fastMode=!1,this.dirtTexture=null,BloomEffect.__super.call(this),this._shaderData=new st,this._linearColor=new k,this._shaderThreshold=new Dt,this._shaderParams=new Dt,this._shaderSetting=new Dt,this._dirtTileOffset=new Dt,this.color=new k(1,1,1,1),this._shader=At.find("PostProcessBloom"),this._pyramid=new Array(32)}r(BloomEffect,"laya.d3.core.render.BloomEffect",He);var t=BloomEffect.prototype;t.render=function(e){var t=e.command,n=e.camera.viewport;this._shaderData.setTexture(BloomEffect.SHADERVALUE_AUTOEXPOSURETEX,B.whiteTexture);var i,r=this._anamorphicRatio,a=r<0?-r:0,o=r>0?r:0,s=Math.floor(n.width/(2-a)),l=Math.floor(n.height/(2-o)),h=Math.max(s,l);i=Math.log2(h)+this._diffusion-10;var u=Math.floor(i),c=Math.min(Math.max(u,1),16),d=.5+i-u;this._shaderData.setNumber(BloomEffect.SHADERVALUE_SAMPLESCALE,d);var _=fe.gammaToLinearSpace(this.threshold),f=_*this._softKnee+1e-5;this._shaderThreshold.setValue(_,_-f,2*f,.25/f),this._shaderData.setVector(BloomEffect.SHADERVALUE_THRESHOLD,this._shaderThreshold);var m=fe.gammaToLinearSpace(this.clamp);this._shaderParams.setValue(m,0,0,0),this._shaderData.setVector(BloomEffect.SHADERVALUE_PARAMS,this._shaderParams);for(var p=this.fastMode?1:0,T=e.source,S=0;S=0;S--)v=(E=2*S)+1,x=this._pyramid[E],M=this._pyramid[v],t.setShaderDataTexture(this._shaderData,BloomEffect.SHADERVALUE_BLOOMTEX,x),t.blit(y,M,this._shader,this._shaderData,4+p),y=M;var D=this._linearColor;this.color.toLinear(D);var R=Math.pow(2,this._intensity/10)-1,C=this._shaderSetting;this._shaderSetting.setValue(d,R,this._dirtIntensity,c);var I=I||B.blackTexture,A=I.width/I.height,L=n.width/n.height,O=this._dirtTileOffset;O.setValue(1,1,0,0),A>L?O.setValue(L/A,1,.5*(1-O.x),0):A=this._bufferMaxParticles&&(this._firstActiveElement=0)}},t._freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement;){var e=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*this._vertexStride+this._timeIndex];if(this.isPerformanceMode&&e<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this._bufferMaxParticles&&(this._firstRetiredElement=0)}},t._burst=function(e,t){for(var n=0,i=this._emission._bursts,r=i.length;this._burstsIndexthis.duration){if(!this.looping){for(r=Math.min(this.maxParticles-this.aliveParticleCount,r),n=0;n0){var o=1/a;for(this._frameRateTime+=o,this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)%this._maxStartLifetime;this._frameRateTime<=t&&this.emit(this._frameRateTime);)this._frameRateTime+=o;this._frameRateTime=Math.floor(t/o)*o}},t._initBufferDatas=function(){this._vertexBuffer&&(this._vertexBuffer.destroy(),this._indexBuffer.destroy());var e=this._ownerRender,t=e.renderMode;if(-1!==t&&this.maxParticles>0){var n,i,r=0,a=0,o=0,s=0,l=0,h=0,u=0,c=e.mesh;if(4===t){if(c){if(c._vertexBuffers.length>1)throw new Error("ShurikenParticleSystem: submesh Count mesh be One or all subMeshes have the same vertexDeclaration.");i=an.vertexDeclaration,this._floatCountPerVertex=i.vertexStride/4,this._startLifeTimeIndex=12,this._timeIndex=16,this._vertexStride=c._vertexBuffers[0].vertexCount;var d=this._bufferMaxParticles*this._vertexStride,_=d%65535;if(Math.floor(d/65535)+1>1)throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");h=i.vertexStride*_,this._vertexBuffer=new jt(h,35048),this._vertexBuffer.vertexDeclaration=i,this._vertices=new Float32Array(this._floatCountPerVertex*_),this._indexStride=c._indexBuffer.indexCount;var f=c._indexBuffer.getData(),m=this._bufferMaxParticles*this._indexStride;for(this._indexBuffer=new Qt("ushort",m,35044),n=new Uint16Array(m),u=h+2*m,s=0,r=0;r=this._bufferMaxParticles&&(i=0),i===this._firstRetiredElement)return!1;if(gt.create(this,this._ownerRender,this._owner.transform),this._currentTime-n>=gt.startLifeTime)return!0;var r=NaN,a=NaN,o=NaN,s=NaN,l=NaN,h=NaN,u=NaN,c=this._velocityOverLifetime&&this._velocityOverLifetime.enbale;if(c){var d=this._velocityOverLifetime.velocity.type;2===d||3===d?this.autoRandomSeed?(r=Math.random(),a=Math.random(),o=Math.random()):(this._rand.seed=this._randomSeeds[9],r=this._rand.getFloat(),a=this._rand.getFloat(),o=this._rand.getFloat(),this._randomSeeds[9]=this._rand.seed):c=!1}else c=!1;var _=this._colorOverLifetime&&this._colorOverLifetime.enbale;_?3===this._colorOverLifetime.color.type?this.autoRandomSeed?s=Math.random():(this._rand.seed=this._randomSeeds[10],s=this._rand.getFloat(),this._randomSeeds[10]=this._rand.seed):_=!1:_=!1;var f=this._sizeOverLifetime&&this._sizeOverLifetime.enbale;f?3===this._sizeOverLifetime.size.type?this.autoRandomSeed?l=Math.random():(this._rand.seed=this._randomSeeds[11],l=this._rand.getFloat(),this._randomSeeds[11]=this._rand.seed):f=!1:f=!1;var m=this._rotationOverLifetime&&this._rotationOverLifetime.enbale;if(m){var p=this._rotationOverLifetime.angularVelocity.type;2===p||3===p?this.autoRandomSeed?h=Math.random():(this._rand.seed=this._randomSeeds[12],h=this._rand.getFloat(),this._randomSeeds[12]=this._rand.seed):m=!1}else m=!1;var T=this._textureSheetAnimation&&this._textureSheetAnimation.enable;T?3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?u=Math.random():(this._rand.seed=this._randomSeeds[15],u=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):T=!1:T=!1;var S,E=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,v=gt.startUVInfo[0],g=gt.startUVInfo[1],x=gt.startUVInfo[2],M=gt.startUVInfo[3],y=0,D=0,R=0,C=0,I=0,A=this._ownerRender;if(4===A.renderMode){var L=A.mesh._vertexBuffers[0];S=L.getData();var O=L.vertexDeclaration;D=O.getVertexElementByUsage(0).offset/4;var P=O.getVertexElementByUsage(1);R=P?P.offset/4:-1;var V=O.getVertexElementByUsage(2);C=V?V.offset/4:-1,y=O.vertexStride/4,I=0}else{this._vertices[E+2]=x,this._vertices[E+3]=M+g;var N=E+this._floatCountPerVertex;this._vertices[N+2]=x+v,this._vertices[N+3]=M+g;var B=N+this._floatCountPerVertex;this._vertices[B+2]=x+v,this._vertices[B+3]=M;var w=B+this._floatCountPerVertex;this._vertices[w+2]=x,this._vertices[w+3]=M}for(var b=E,F=E+this._floatCountPerVertex*this._vertexStride;b0&&this._vertexBuffer.setData(this._vertices,0,0,this._firstFreeElement*this._vertexStride*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},t._getType=function(){return ShurikenParticleSystem._type},t._prepareRender=function(e){return this._updateEmission(),this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement},t._render=function(e){this._bufferState.bind();var t=0,n=E.instance;this._firstActiveElement0&&(t=this._firstFreeElement*this._indexStride,n.drawElements(4,t,5123,0),P.trianglesFaces+=t/3,P.renderBatches++))},t.play=function(){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,t=this._randomSeeds.length;e0)}),a(0,t,"shape",function(){return this._shape},function(e){this._shape!==e&&(e&&e.enable?this._owner._render._defineDatas.add(Ri.SHADERDEFINE_SHAPE):this._owner._render._defineDatas.remove(Ri.SHADERDEFINE_SHAPE),this._shape=e)}),a(0,t,"rotationOverLifetime",function(){return this._rotationOverLifetime},function(e){var t=this._owner._render._defineDatas,n=this._owner._render._shaderValues;if(e){var i=e.angularVelocity;if(!i)return;var r=i.separateAxes,a=i.type;if(e.enbale)switch(r?t.add(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE):t.add(Ri.SHADERDEFINE_ROTATIONOVERLIFETIME),a){case 0:t.add(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);break;case 1:t.add(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);break;case 2:t.add(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);break;case 3:t.add(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES)}else t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIME),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);switch(a){case 0:r?n.setVector3(Ri.ROLANGULARVELOCITYCONSTSEPRARATE,i.constantSeparate):n.setNumber(Ri.ROLANGULARVELOCITYCONST,i.constant);break;case 1:r?(n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTX,i.gradientX._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTY,i.gradientY._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTZ,i.gradientZ._elements)):n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENT,i.gradient._elements);break;case 2:r?(n.setVector3(Ri.ROLANGULARVELOCITYCONSTSEPRARATE,i.constantMinSeparate),n.setVector3(Ri.ROLANGULARVELOCITYCONSTMAXSEPRARATE,i.constantMaxSeparate)):(n.setNumber(Ri.ROLANGULARVELOCITYCONST,i.constantMin),n.setNumber(Ri.ROLANGULARVELOCITYCONSTMAX,i.constantMax));break;case 3:r?(n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTX,i.gradientXMin._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTXMAX,i.gradientXMax._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTY,i.gradientYMin._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTYMAX,i.gradientYMax._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTZ,i.gradientZMin._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTZMAX,i.gradientZMax._elements)):(n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENT,i.gradientMin._elements),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTMAX,i.gradientMax._elements))}}else t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIME),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS),t.remove(Ri.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES),n.setVector(Ri.ROLANGULARVELOCITYCONSTSEPRARATE,null),n.setVector(Ri.ROLANGULARVELOCITYCONSTMAXSEPRARATE,null),n.setNumber(Ri.ROLANGULARVELOCITYCONST,void 0),n.setNumber(Ri.ROLANGULARVELOCITYCONSTMAX,void 0),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTX,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTXMAX,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTY,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTYMAX,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTZ,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTZMAX,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTWMAX,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENT,null),n.setBuffer(Ri.ROLANGULARVELOCITYGRADIENTMAX,null);this._rotationOverLifetime=e}),a(0,t,"emission",function(){return this._emission}),a(0,t,"emissionTime",function(){return this._emissionTime>this.duration?this.duration:this._emissionTime}),a(0,t,"aliveParticleCount",function(){return this._firstNewElement>=this._firstRetiredElement?this._firstNewElement-this._firstRetiredElement:this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement}),a(0,t,"isPlaying",function(){return this._isPlaying}),a(0,t,"isPaused",function(){return this._isPaused}),a(0,t,"startLifetimeType",function(){return this._startLifetimeType},function(e){var t=0,n=0;switch(this.startLifetimeType){case 0:this._maxStartLifetime=this.startLifetimeConstant;break;case 1:this._maxStartLifetime=-Number.MAX_VALUE;var i=i;for(t=0,n=i.gradientCount;t0?SetShaderDataTextureCMD._pool.pop():new SetShaderDataTextureCMD)._shaderData=e,i._nameID=t,i._texture=n,i},SetShaderDataTextureCMD._pool=[],SetShaderDataTextureCMD}(),Rn=function(e){function BoxShape(){this.x=NaN,this.y=NaN,this.z=NaN,BoxShape.__super.call(this),this.x=1,this.y=1,this.z=1,this.randomDirection=!1}r(BoxShape,"laya.d3.core.particleShuriKen.module.shape.BoxShape",e);var t=BoxShape.prototype;return t._getShapeBoundBox=function(e){var t=e.min;t.x=.5*-this.x,t.y=.5*-this.y,t.z=.5*-this.z;var n=e.max;n.x=.5*this.x,n.y=.5*this.y,n.z=.5*this.z},t._getSpeedBoundBox=function(e){var t=e.min;t.x=0,t.y=0,t.z=0;var n=e.max;n.x=0,n.y=1,n.z=0},t.generatePositionAndDirection=function(e,t,n,i){n?(n.seed=i[16],Me._randomPointInsideHalfUnitBox(e,n),i[16]=n.seed):Me._randomPointInsideHalfUnitBox(e),e.x=this.x*e.x,e.y=this.y*e.y,e.z=this.z*e.z,this.randomDirection?n?(n.seed=i[17],Me._randomPointUnitSphere(t,n),i[17]=n.seed):Me._randomPointUnitSphere(t):(t.x=0,t.y=0,t.z=1)},t.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.x=this.x,n.y=this.y,n.z=this.z,n.randomDirection=this.randomDirection},BoxShape}(ce),Cn=function(e){function SubMeshDynamicBatch(){this._vertices=null,this._indices=null,this._positionOffset=0,this._normalOffset=0,this._colorOffset=0,this._uv0Offset=0,this._uv1Offset=0,this._sTangentOffset=0,this._vertexBuffer=null,this._indexBuffer=null,SubMeshDynamicBatch.__super.call(this),this._bufferState=new Zt;var e=32e3*Re.getVertexDeclaration("POSITION,NORMAL,COLOR,UV,UV1,TANGENT").vertexStride;this._vertices=new Float32Array(e/4),this._vertexBuffer=new jt(e,35048),this._indices=new Int16Array(32e3),this._indexBuffer=new Qt("ushort",this._indices.length,35048);var t=this._vertexBuffer._byteLength+this._indexBuffer._byteLength;C._addMemory(t,t)}r(SubMeshDynamicBatch,"laya.d3.graphics.SubMeshDynamicBatch",re);var t=SubMeshDynamicBatch.prototype;return t._getBatchVertices=function(e,t,n,i,r,a){var o=e.vertexStride/4,s=a._vertexBuffer.getData(),l=(r.render.lightmapScaleOffset,r._dynamicMultiSubMesh),h=r._dynamicVertexCount;r._computeWorldPositionsAndNormals(this._positionOffset,this._normalOffset,l,h);for(var u=r._dynamicWorldPositions,c=r._dynamicWorldNormals,d=a._indices,_=0;_32e3&&(this._flush(r,a),o++,P.trianglesFaces+=a/3,r=a=0);var d=h._transform;this._getBatchVertices(n,this._vertices,r,d,h,u),this._getBatchIndices(this._indices,a,r,d,u,h._dynamicMultiSubMesh),r+=h._dynamicVertexCount,a+=c}this._flush(r,a),o++,P.renderBatches+=o,P.savedRenderBatches+=s-o,P.trianglesFaces+=a/3},SubMeshDynamicBatch.maxAllowVertexCount=10,SubMeshDynamicBatch.maxAllowAttribueCount=900,SubMeshDynamicBatch.maxIndicesCount=32e3,SubMeshDynamicBatch.instance=null,SubMeshDynamicBatch}(),In=function(e){function CompoundColliderShape(){CompoundColliderShape.__super.call(this),this._childColliderShapes=[],this._type=5,this._nativeShape=new wt._physics3D.btCompoundShape}r(CompoundColliderShape,"laya.d3.physics.shape.CompoundColliderShape",e);var t=CompoundColliderShape.prototype;return t._clearChildShape=function(e){e._attatched=!1,e._compoundParent=null,e._indexInCompound=-1},t._addReference=function(){},t._removeReference=function(){},t._updateChildTransform=function(e){var t=e.localOffset,n=e.localRotation,i=J._nativeVector30,r=J._nativQuaternion0,a=J._nativeTransform0;i.setValue(-t.x,t.y,t.z),r.setValue(-n.x,n.y,n.z,-n.w),a.setOrigin(i),a.setRotation(r),this._nativeShape.updateChildTransform(e._indexInCompound,a,!0)},t.addChildShape=function(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,n=e.localRotation;CompoundColliderShape._nativeOffset.setValue(-t.x,t.y,t.z),CompoundColliderShape._nativRotation.setValue(-n.x,n.y,n.z,-n.w),CompoundColliderShape._nativeTransform.setOrigin(CompoundColliderShape._nativeOffset),CompoundColliderShape._nativeTransform.setRotation(CompoundColliderShape._nativRotation);var i=this._nativeShape.getLocalScaling();this._nativeShape.setLocalScaling(CompoundColliderShape._nativeVector3One),this._nativeShape.addChildShape(CompoundColliderShape._nativeTransform,e._nativeShape),this._nativeShape.setLocalScaling(i),this._attatchedCollisionObject&&(this._attatchedCollisionObject.colliderShape=this)},t.removeChildShape=function(e){if(e._compoundParent===this){var t=e._indexInCompound;this._clearChildShape(e);var n=this._childColliderShapes[this._childColliderShapes.length-1];n._indexInCompound=t,this._childColliderShapes[t]=n,this._childColliderShapes.pop(),this._nativeShape.removeChildShapeByIndex(t)}},t.clearChildShape=function(){for(var e=0,t=this._childColliderShapes.length;e1,r=i?t._indexCount:n._vertexCount;if(r<=10){var a=3*r;this._dynamicVertexBatch=!0,this._dynamicWorldPositions=new Float32Array(a),this._dynamicWorldNormals=new Float32Array(a),this._dynamicVertexCount=r,this._dynamicMultiSubMesh=i}else this._dynamicVertexBatch=!1}this._geometry=e}},t.addToOpaqueRenderQueue=function(e,t){var n=this.staticBatch,i=t.elements;if(n){var r=nn.instance,a=r.getBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,n._batchID);if(r._updateCountMark===a.updateMark){var o=a.indexInList;if(a.batched)i[o].staticBatchElementList.push(this);else{var s=i[o],l=s.render,h=r._getBatchRenderElementFromPool();h.renderType=1,h.setGeometry(n),h.material=s.material;var u=n.batchOwner,c=u?u._transform:null;h.setTransform(c),h.render=l;var d=h.staticBatchElementList;d.length=0,d.push(s),d.push(this),i[o]=h,a.batched=!0}}else a.updateMark=r._updateCountMark,a.indexInList=i.length,a.batched=!1,i.push(this)}else if(this.material._shader._enableInstancing&&F._angleInstancedArrays){var _=this._geometry,f=$t.instance,m=f.getInstanceBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,_._id);if(f._updateCountMark===m.updateMark){var p=m.indexInList;if(m.batched){var T=i[p].instanceBatchElementList;T.length===un.instance.maxInstanceCount?(m.updateMark=f._updateCountMark,m.indexInList=i.length,m.batched=!1,i.push(this)):T.push(this)}else{var S=i[p],E=S.render,v=f._getBatchRenderElementFromPool();v.renderType=2,v.setGeometry(un.instance),v.material=S.material,v.setTransform(null),v.render=E,v.instanceSubMesh=_;var g=v.instanceBatchElementList;g.length=0,g.push(S),g.push(this),i[p]=v,m.batched=!0}}else m.updateMark=f._updateCountMark,m.indexInList=i.length,m.batched=!1,i.push(this)}else if(this._dynamicVertexBatch){var x=this._geometry._vertexBuffer.vertexDeclaration,M=$t.instance,y=M.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,x.id);if(M._updateCountMark===y.updateMark){var D=y.indexInList;if(y.batched)i[D].vertexBatchElementList.push(this);else{var R=i[D],C=R.render,I=M._getBatchRenderElementFromPool();I.renderType=3,I.setGeometry(Cn.instance),I.material=R.material,I.setTransform(null),I.render=C,I.vertexBatchVertexDeclaration=x;var A=I.vertexBatchElementList;A.length=0,A.push(R),A.push(this),i[D]=I,y.batched=!0}}else y.updateMark=M._updateCountMark,y.indexInList=i.length,y.batched=!1,i.push(this)}else i.push(this)},t.addToTransparentRenderQueue=function(e,t){var n=this.staticBatch,i=t.elements;if(n){var r=nn.instance,a=t.lastTransparentRenderElement;if(a){var o=a.render;if(a._geometry._getType()!==this._geometry._getType()||a.staticBatch!==n||a.material!==this.material||o.receiveShadow!==this.render.receiveShadow||o.lightmapIndex!==this.render.lightmapIndex)i.push(this),t.lastTransparentBatched=!1;else{if(t.lastTransparentBatched)i[i.length-1].staticBatchElementList.push(this);else{var s=r._getBatchRenderElementFromPool();s.renderType=1,s.setGeometry(n),s.material=a.material;var l=n.batchOwner,h=l?l._transform:null;s.setTransform(h),s.render=this.render;var u=s.staticBatchElementList;u.length=0,u.push(a),u.push(this),i[i.length-1]=s}t.lastTransparentBatched=!0}}else i.push(this),t.lastTransparentBatched=!1}else if(this.material._shader._enableInstancing&&F._angleInstancedArrays){var c=this._geometry,d=$t.instance,_=t.lastTransparentRenderElement;if(_){var f=_.render;if(_._geometry._getType()!==this._geometry._getType()||_._geometry!==c||_.material!==this.material||f.receiveShadow!==this.render.receiveShadow||f.lightmapIndex!==this.render.lightmapIndex)i.push(this),t.lastTransparentBatched=!1;else{if(t.lastTransparentBatched)i[i.length-1].instanceBatchElementList.push(this);else{var m=d._getBatchRenderElementFromPool();m.renderType=2,m.setGeometry(un.instance),m.material=_.material,m.setTransform(null),m.render=this.render,m.instanceSubMesh=c;var p=m.instanceBatchElementList;p.length=0,p.push(_),p.push(this),i[i.length-1]=m}t.lastTransparentBatched=!0}}else i.push(this),t.lastTransparentBatched=!1}else if(this._dynamicVertexBatch){var T=this._geometry._vertexBuffer.vertexDeclaration,S=$t.instance,E=t.lastTransparentRenderElement;if(E){var v=E.render;if(E._geometry._getType()!==this._geometry._getType()||E._geometry._vertexBuffer._vertexDeclaration!==T||E.material!==this.material||v.receiveShadow!==this.render.receiveShadow||v.lightmapIndex!==this.render.lightmapIndex)i.push(this),t.lastTransparentBatched=!1;else{if(t.lastTransparentBatched)i[i.length-1].vertexBatchElementList.push(this);else{var g=S._getBatchRenderElementFromPool();g.renderType=3,g.setGeometry(Cn.instance),g.material=E.material,g.setTransform(null),g.render=this.render,g.vertexBatchVertexDeclaration=T;var x=g.vertexBatchElementList;x.length=0,x.push(E),x.push(this),i[i.length-1]=g}t.lastTransparentBatched=!0}}else i.push(this),t.lastTransparentBatched=!1}else i.push(this);t.lastTransparentRenderElement=this},t.destroy=function(){e.prototype.destroy.call(this),this._dynamicWorldPositions=null,this._dynamicWorldNormals=null,this.staticBatch=null,this.staticBatchElementList=null,this.vertexBatchElementList=null,this.vertexBatchVertexDeclaration=null},SubMeshRenderElement._maxInstanceCount=1024,i(SubMeshRenderElement,["_instanceMatrixData",function(){return this._instanceMatrixData=new Float32Array(16*SubMeshRenderElement._maxInstanceCount)},"_instanceMatrixBuffer",function(){return this._instanceMatrixBuffer=new jt(4*SubMeshRenderElement._instanceMatrixData.length,35048)}]),SubMeshRenderElement}(lt),Vn=function(e){function Vector3Keyframe(){Vector3Keyframe.__super.call(this),this.inTangent=new Rt,this.outTangent=new Rt,this.value=new Rt}return r(Vector3Keyframe,"laya.d3.core.Vector3Keyframe",e),Vector3Keyframe.prototype.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;this.inTangent.cloneTo(n.inTangent),this.outTangent.cloneTo(n.outTangent),this.value.cloneTo(n.value)},Vector3Keyframe}(ct),Nn=function(e){function QuaternionKeyframe(){QuaternionKeyframe.__super.call(this),this.inTangent=new Dt,this.outTangent=new Dt,this.value=new dt}return r(QuaternionKeyframe,"laya.d3.core.QuaternionKeyframe",e),QuaternionKeyframe.prototype.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;this.inTangent.cloneTo(n.inTangent),this.outTangent.cloneTo(n.outTangent),this.value.cloneTo(n.value)},QuaternionKeyframe}(ct),Bn=function(e){function FloatKeyframe(){FloatKeyframe.__super.call(this)}return r(FloatKeyframe,"laya.d3.core.FloatKeyframe",e),FloatKeyframe.prototype.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.inTangent=this.inTangent,n.outTangent=this.outTangent,n.value=this.value},FloatKeyframe}(ct),wn=function(e){function SkyBox(){SkyBox.__super.call(this);var e=new Float32Array([-.5,.5,-.5,.5,.5,-.5,.5,.5,.5,-.5,.5,.5,-.5,-.5,-.5,.5,-.5,-.5,.5,-.5,.5,-.5,-.5,.5]),t=new Uint8Array([0,1,2,2,3,0,4,7,6,6,5,4,0,3,7,7,4,0,1,5,6,6,2,1,3,2,6,6,7,3,0,4,5,5,1,0]),n=Re.getVertexDeclaration("POSITION");this._vertexBuffer=new jt(8*n.vertexStride,35044,!1),this._vertexBuffer.vertexDeclaration=n,this._indexBuffer=new Qt("ubyte",36,35044,!1),this._vertexBuffer.setData(e),this._indexBuffer.setData(t);var i=new Zt;i.bind(),i.applyVertexBuffer(this._vertexBuffer),i.applyIndexBuffer(this._indexBuffer),i.unBind(),this._bufferState=i}return r(SkyBox,"laya.d3.resource.models.SkyBox",$e),SkyBox.prototype._render=function(e){E.instance.drawElements(4,36,5121,0),P.trianglesFaces+=12,P.renderBatches++},SkyBox.__init__=function(){SkyBox.instance=new SkyBox},SkyBox.instance=null,SkyBox}(),bn=function(e){function Sprite3D(e,t){this._needProcessCollisions=!1,this._needProcessTriggers=!1,Sprite3D.__super.call(this),void 0===t&&(t=!1),this._id=++Sprite3D._uniqueIDCounter,this._transform=new qt(this),this._isStatic=t,this.layer=0,this.name=e||"New Sprite3D"}r(Sprite3D,"laya.d3.core.Sprite3D",e);var t=Sprite3D.prototype;return n.imps(t,{"laya.resource.ICreateResource":!0}),t._setCreateURL=function(e){this._url=w.formatURL(e)},t._changeAnimatorsToLinkSprite3D=function(e,t,n){var i=this.getComponent(Yt);if(i&&(i.avatar||e._changeAnimatorToLinkSprite3DNoAvatar(i,t,n)),this._parent&&this._parent instanceof laya.d3.core.Sprite3D){n.unshift(this._parent.name);var r=this._parent;r._hierarchyAnimator&&r._changeAnimatorsToLinkSprite3D(e,t,n)}},t._setHierarchyAnimator=function(e,t){this._changeHierarchyAnimator(e),this._changeAnimatorAvatar(e.avatar);for(var n=0,i=this._children.length;n=0&&e<=30))throw new Error("Layer value must be 0-30.");this._layer=e}}),a(0,t,"transform",function(){return this._transform}),a(0,t,"isStatic",function(){return this._isStatic}),Sprite3D._parse=function(e,t,n){var i,r=e.data,a=[];switch(e.version){case"LAYAHIERARCHY:02":i=fe._createNodeByJson02(r,a);break;default:i=fe._createNodeByJson(r,a)}return ae.combine(i,a),i},Sprite3D.__init__=function(){},Sprite3D.instantiate=function(e,t,n,i,r){void 0===n&&(n=!0);var a=e.clone();t&&t.addChild(a);var o=a.transform;if(n){var s=o.worldMatrix;e.transform.worldMatrix.cloneTo(s),o.worldMatrix=s}else i&&(o.position=i),r&&(o.rotation=r);return a},Sprite3D.load=function(e,t){n.loader.create(e,t,null,"HIERARCHY")},Sprite3D._createSprite3DInstance=function(e){for(var t=new e.constructor,n=e._children,i=0,r=n.length;i0&&this._removeTetxureReference(),this._shaderValues=null},t.setShaderName=function(e){if(this._shader=At.find(e),!this._shader)throw new Error("BaseMaterial: unknown shader name.")},t.cloneTo=function(e){var t=e;t.name=this.name,t.renderQueue=this.renderQueue,this._disablePublicDefineDatas.cloneTo(t._disablePublicDefineDatas),this._defineDatas.cloneTo(t._defineDatas),this._shaderValues.cloneTo(t._shaderValues)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"alphaTestValue",function(){return this._shaderValues.getNumber(BaseMaterial.ALPHATESTVALUE)},function(e){this._shaderValues.setNumber(BaseMaterial.ALPHATESTVALUE,e)}),a(0,t,"alphaTest",function(){return this._alphaTest},function(e){this._alphaTest=e,e?this._defineDatas.add(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST):this._defineDatas.remove(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST)}),BaseMaterial.load=function(e,t){n.loader.create(e,t,null,"MATERIAL")},BaseMaterial.__init__=function(){BaseMaterial.SHADERDEFINE_ALPHATEST=BaseMaterial.shaderDefines.registerDefine("ALPHATEST")},BaseMaterial._parse=function(e,t,n){var i,r=e,a=r.props,o=a.type.split("."),s=l.window;if(o.forEach(function(e){s=s[e]}),"function"!=typeof s)throw"_getSprite3DHierarchyInnerUrls 错误: "+e.type+" 不是类";switch(i=new s,r.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":var h=0,u=0;for(var c in a)switch(c){case"vectors":var d=a[c];for(h=0,u=d.length;ht);)d++,h++,n[a]=d;else for((h=d+1)!==c&&t>u[h].time&&(d=c-1,n[a]=d),h=d+1;d>-1&&!(u[d].timee?n=i-1:t=i+1}return t},t.addEvent=function(e){var t=this._binarySearchEventIndex(e.time);this._events.splice(t,0,e)},t._disposeResource=function(){this._nodes=null,this._nodesMap=null},AnimationClip._parse=function(e,t,n){var i=new AnimationClip,r=new c(e),a=r.readUTFString();switch(a){case"LAYAANIMATION:03":se.parse(i,r);break;case"LAYAANIMATION:04":case"LAYAANIMATION:COMPRESSION_04":oe.parse(i,r,a);break;default:throw"unknown animationClip version."}return i},AnimationClip.load=function(e,t){n.loader.create(e,t,null,"ANIMATIONCLIP")},i(AnimationClip,["_tempQuaternion0",function(){return this._tempQuaternion0=new dt}]),AnimationClip}(),Hn=function(e){function ShaderInstance(e,t,n,i,r){this._stateParamsMap=[],this._uploadMark=-1,this._uploadRenderType=-1,ShaderInstance.__super.call(this),this._vs=e,this._ps=t,this._attributeMap=n,this._uniformMap=i,this._shaderPass=r,this._create(),this.lock=!0}r(ShaderInstance,"laya.d3.shader.ShaderInstance",C);var t=ShaderInstance.prototype;return t._create=function(){var e=E.instance;for(var t in this._program=e.createProgram(),this._vshader=this._createShader(e,this._vs,35633),this._pshader=this._createShader(e,this._ps,35632),e.attachShader(this._program,this._vshader),e.attachShader(this._program,this._pshader),this._attributeMap)e.bindAttribLocation(this._program,this._attributeMap[t],t);if(e.linkProgram(this._program),!R.isConchApp&&At.debugMode&&!e.getProgramParameter(this._program,35714))throw e.getProgramInfoLog(this._program);var n=[],i=[],r=[],a=[],o=[];this._customUniformParamsMap=[];var s=e.getProgramParameter(this._program,35718);F.useProgram(e,this._program),this._curActTexIndex=0;var l,h=0,u=0;for(h=0;h0?(l.name=d=d.substr(0,d.length-3),l.isArray=!0):(l.name=d,l.isArray=!1),l.type=c.type,this._addShaderUnifiormFun(l);var _=this._uniformMap[d];if(null!=_)switch(l.dataOffset=At.propertyNameToID(d),_){case 0:o.push(l);break;case 1:a.push(l);break;case 2:r.push(l);break;case 3:i.push(l);break;case 4:n.push(l);break;default:throw new Error("Shader3D: period is unkonw.")}}for(this._sceneUniformParamsMap=E.instance.createCommandEncoder(4*n.length*5+4,64,!0),h=0,u=n.length;he._renderingOrder?n=i-1:t=i+1}return t},t._setCreateURL=function(e){this._url=w.formatURL(e)},t._getGroup=function(){return this._group},t._setGroup=function(e){this._group=e},t._updateScript=function(){for(var e=this._scriptPool,t=e.elements,n=0,i=e.length;n0)for(var t=0,n=0;n=this._enableLightCount);n++);},t._addCamera=function(e){for(var t=this._binarySearchIndexInCameraPool(e),n=e._renderingOrder,i=this._cameraPool.length;t=0&&this._lights.splice(t,1)},t._addRenderObject=function(e){if(this._octree)this._octree.add(e);else if(this._renders.add(e),R.supportWebGLPlusCulling){var t=e._getIndexInList(),n=this._cullingBufferIndices.length;if(t>=n){var i=this._cullingBufferIndices,r=this._cullingBufferResult;this._cullingBufferIndices=new Int32Array(n+1024),this._cullingBufferResult=new Int32Array(n+1024),this._cullingBufferIndices.set(i,0),this._cullingBufferResult.set(r,0)}this._cullingBufferIndices[t]=e._cullingBufferIndex}},t._removeRenderObject=function(e){var t;this._octree?this._octree.remove(e):(R.supportWebGLPlusCulling&&(t=this._renders.elements[this._renders.length-1]),this._renders.remove(e),R.supportWebGLPlusCulling&&(this._cullingBufferIndices[t._getIndexInList()]=t._cullingBufferIndex))},t._addShadowCastRenderObject=function(e){this._octree||this._castShadowRenders.add(e)},t._removeShadowCastRenderObject=function(e){this._octree||this._castShadowRenders.remove(e)},t._getRenderQueue=function(e){return e<=2500?this._opaqueQueue:this._transparentQueue},t.setlightmaps=function(e){for(var t=this._lightmaps,n=0,i=t.length;n0&&e.addRenderObject(this)},t.renderSubmit=function(){E.instance;this._prepareSceneToRender();var e,t,n=0;for(n=0,t=(e=this._cameraPool.length)-1;ne[t].renderingOrder){var i=e[n];e[n]=e[t],e[t]=i}},t._calculateProjectionMatrix=function(){},t._onScreenSizeChanged=function(){this._calculateProjectionMatrix()},t._prepareCameraToRender=function(){this.transform.getForward(this._forward),this.transform.getUp(this._up);var e=this._shaderValues;e.setVector3(laya.d3.core.BaseCamera.CAMERAPOS,this.transform.position),e.setVector3(laya.d3.core.BaseCamera.CAMERADIRECTION,this._forward),e.setVector3(laya.d3.core.BaseCamera.CAMERAUP,this._up)},t._prepareCameraViewProject=function(e,t,n,i){var r=this._shaderValues;r.setMatrix4x4(laya.d3.core.BaseCamera.VIEWMATRIX,e),r.setMatrix4x4(laya.d3.core.BaseCamera.PROJECTMATRIX,t),r.setMatrix4x4(laya.d3.core.BaseCamera.VIEWPROJECTMATRIX,n),this.transform.worldMatrix.cloneTo(BaseCamera._tempMatrix4x40),BaseCamera._tempMatrix4x40.transpose(),Q.multiply(t,BaseCamera._tempMatrix4x40,i),r.setMatrix4x4(laya.d3.core.BaseCamera.VPMATRIX_NO_TRANSLATE,i)},t.render=function(e,t){},t.addLayer=function(e){this.cullingMask|=Math.pow(2,e)},t.removeLayer=function(e){this.cullingMask&=~Math.pow(2,e)},t.addAllLayers=function(){this.cullingMask=2147483647},t.removeAllLayers=function(){this.cullingMask=0},t.resetProjectionMatrix=function(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()},t._onActive=function(){this._scene._addCamera(this),laya.display.Node.prototype._onActive.call(this)},t._onInActive=function(){this._scene._removeCamera(this),laya.display.Node.prototype._onInActive.call(this)},t._parse=function(t,n){e.prototype._parse.call(this,t,n);var i=t.clearFlag;void 0!==i&&(this.clearFlag=i),this.orthographic=t.orthographic,this.fieldOfView=t.fieldOfView,this.nearPlane=t.nearPlane,this.farPlane=t.farPlane;var r=t.clearColor;this.clearColor=new Dt(r[0],r[1],r[2],r[3]);var a=t.skyboxMaterial;a&&(this._skyRenderer.material=g.getRes(a.path))},t.destroy=function(t){void 0===t&&(t=!0),this._skyRenderer.destroy(),this._skyRenderer=null,n.stage.off("resize",this,this._onScreenSizeChanged),e.prototype.destroy.call(this,t)},a(0,t,"renderingOrder",function(){return this._renderingOrder},function(e){this._renderingOrder=e,this._sortCamerasByRenderingOrder()}),a(0,t,"skyRenderer",function(){return this._skyRenderer}),a(0,t,"orthographic",function(){return this._orthographic},function(e){this._orthographic=e,this._calculateProjectionMatrix()}),a(0,t,"fieldOfView",function(){return this._fieldOfView},function(e){this._fieldOfView=e,this._calculateProjectionMatrix()}),a(0,t,"nearPlane",function(){return this._nearPlane},function(e){this._nearPlane=e,this._calculateProjectionMatrix()}),a(0,t,"farPlane",function(){return this._farPlane},function(e){this._farPlane=e,this._calculateProjectionMatrix()}),a(0,t,"orthographicVerticalSize",function(){return this._orthographicVerticalSize},function(e){this._orthographicVerticalSize=e,this._calculateProjectionMatrix()}),BaseCamera.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",BaseCamera.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",BaseCamera.CLEARFLAG_SOLIDCOLOR=0,BaseCamera.CLEARFLAG_SKY=1,BaseCamera.CLEARFLAG_DEPTHONLY=2,BaseCamera.CLEARFLAG_NONE=3,i(BaseCamera,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new Q},"CAMERAPOS",function(){return this.CAMERAPOS=At.propertyNameToID("u_CameraPos")},"VIEWMATRIX",function(){return this.VIEWMATRIX=At.propertyNameToID("u_View")},"PROJECTMATRIX",function(){return this.PROJECTMATRIX=At.propertyNameToID("u_Projection")},"VIEWPROJECTMATRIX",function(){return this.VIEWPROJECTMATRIX=At.propertyNameToID("u_ViewProjection")},"VPMATRIX_NO_TRANSLATE",function(){return this.VPMATRIX_NO_TRANSLATE=At.propertyNameToID("u_MvpMatrix")},"CAMERADIRECTION",function(){return this.CAMERADIRECTION=At.propertyNameToID("u_CameraDirection")},"CAMERAUP",function(){return this.CAMERAUP=At.propertyNameToID("u_CameraUp")},"_invertYScaleMatrix",function(){return this._invertYScaleMatrix=new Q(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1)},"_invertYProjectionMatrix",function(){return this._invertYProjectionMatrix=new Q},"_invertYProjectionViewMatrix",function(){return this._invertYProjectionViewMatrix=new Q}]),BaseCamera}(bn),hi=function(e){function Terrain(e){this._terrainRes=null,this._lightmapScaleOffset=null,Terrain.__super.call(this),this._lightmapScaleOffset=new Dt(1,1,0,0),e&&(this._terrainRes=e,this.buildTerrain(e))}r(Terrain,"laya.d3.terrain.Terrain",e);var t=Terrain.prototype;return t._parse=function(t,n){e.prototype._parse.call(this,t,n),this.terrainRes=g.getRes(t.dataPath);var i=t.lightmapIndex;null!=i&&this.setLightmapIndex(i);var r=t.lightmapScaleOffset;r&&this.setLightmapScaleOffset(new Dt(r[0],r[1],r[2],r[3]))},t.setLightmapIndex=function(e){for(var t=0;t0?e._detailTextureInfos[l.detailID[h][0]].diffuseTexture:null,d=u>1?e._detailTextureInfos[l.detailID[h][1]].diffuseTexture:null,_=u>2?e._detailTextureInfos[l.detailID[h][2]].diffuseTexture:null,f=u>3?e._detailTextureInfos[l.detailID[h][3]].diffuseTexture:null,m=u>0?e._detailTextureInfos[l.detailID[h][0]].scale:null,p=u>1?e._detailTextureInfos[l.detailID[h][1]].scale:null,T=u>2?e._detailTextureInfos[l.detailID[h][2]].scale:null,S=u>3?e._detailTextureInfos[l.detailID[h][3]].scale:null;s.buildRenderElementAndMaterial(u,l.normalMap,l.alphaMap[h],c,d,_,f,e._materialInfo.ambientColor,e._materialInfo.diffuseColor,e._materialInfo.specularColor,m?m.x:1,m?m.y:1,p?p.x:1,p?p.y:1,T?T.x:1,T?T.y:1,S?S.x:1,S?S.y:1)}s.terrainRender.receiveShadow=!0,s.terrainRender.lightmapScaleOffset=this._lightmapScaleOffset,this.addChild(s)}},t.width=function(){return this._terrainRes._chunkNumX*K.CHUNK_GRID_NUM*this._terrainRes._gridSize},t.depth=function(){return this._terrainRes._chunkNumZ*K.CHUNK_GRID_NUM*this._terrainRes._gridSize},t.getHeightXZ=function(e,t){if(!this._terrainRes)return NaN;if(e-=this.transform.position.x,t-=this.transform.position.z,Terrain.__VECTOR3__||(Terrain.__VECTOR3__=new Rt),Terrain.__VECTOR3__.x=e,Terrain.__VECTOR3__.y=0,Terrain.__VECTOR3__.z=t,Rt.transformV3ToV3(Terrain.__VECTOR3__,K.__ADAPT_MATRIX_INV__,Terrain.__VECTOR3__),e=Terrain.__VECTOR3__.x,t=Terrain.__VECTOR3__.z,e<0||e>this.width()||t<0||t>this.depth())return NaN;var n=this._terrainRes._gridSize,i=parseInt(""+e/n),r=parseInt(""+t/n),a=e-i*n,o=t-r*n,s=NaN,l=this._terrainRes._heightData;return a+o>n?(s=l._terrainHeightData[(r+1-1)*l._width+i+1])+(l._terrainHeightData[(r+1-1)*l._width+i]-s)*((n-a)/n)+(l._terrainHeightData[(r-1)*l._width+i+1]-s)*((n-o)/n):(s=l._terrainHeightData[Math.max(0,r-1)*l._width+i])+(l._terrainHeightData[Math.min(l._width*l._height-1,(r+1-1)*l._width+i)]-s)*(o/n)+(l._terrainHeightData[Math.min(l._width*l._height-1,Math.max(0,r-1)*l._width+i+1)]-s)*(a/n)},a(0,t,"terrainRes",null,function(e){e&&(this._terrainRes=e,this.buildTerrain(e))}),Terrain.load=function(e){n.loader.create(e,null,null,"TERRAIN",null,null,1,!1)},Terrain.RENDER_LINE_MODEL=!1,Terrain.LOD_TOLERANCE_VALUE=4,Terrain.LOD_DISTANCE_FACTOR=2,Terrain.__VECTOR3__=null,Terrain}(bn),ui=function(e){function SkyProceduralMaterial(){this._sunDisk=0,SkyProceduralMaterial.__super.call(this),this.setShaderName("SkyBoxProcedural"),this.sunDisk=1,this.sunSize=.04,this.sunSizeConvergence=5,this.atmosphereThickness=1,this.skyTint=new Dt(.5,.5,.5,1),this.groundTint=new Dt(.369,.349,.341,1),this.exposure=1.3}r(SkyProceduralMaterial,"laya.d3.core.material.SkyProceduralMaterial",Fn);var t=SkyProceduralMaterial.prototype;return a(0,t,"exposure",function(){return this._shaderValues.getNumber(SkyProceduralMaterial.EXPOSURE)},function(e){e=Math.min(Math.max(0,e),8),this._shaderValues.setNumber(SkyProceduralMaterial.EXPOSURE,e)}),a(0,t,"sunSize",function(){return this._shaderValues.getNumber(SkyProceduralMaterial.SUNSIZE)},function(e){e=Math.min(Math.max(0,e),1),this._shaderValues.setNumber(SkyProceduralMaterial.SUNSIZE,e)}),a(0,t,"sunDisk",function(){return this._sunDisk},function(e){switch(e){case 1:this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE),this._defineDatas.add(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY);break;case 2:this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY),this._defineDatas.add(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);break;case 0:this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY),this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}),a(0,t,"sunSizeConvergence",function(){return this._shaderValues.getNumber(SkyProceduralMaterial.SUNSIZECONVERGENCE)},function(e){e=Math.min(Math.max(0,e),20),this._shaderValues.setNumber(SkyProceduralMaterial.SUNSIZECONVERGENCE,e)}),a(0,t,"atmosphereThickness",function(){return this._shaderValues.getNumber(SkyProceduralMaterial.ATMOSPHERETHICKNESS)},function(e){e=Math.min(Math.max(0,e),5),this._shaderValues.setNumber(SkyProceduralMaterial.ATMOSPHERETHICKNESS,e)}),a(0,t,"groundTint",function(){return this._shaderValues.getVector(SkyProceduralMaterial.GROUNDTINT)},function(e){this._shaderValues.setVector(SkyProceduralMaterial.GROUNDTINT,e)}),a(0,t,"skyTint",function(){return this._shaderValues.getVector(SkyProceduralMaterial.SKYTINT)},function(e){this._shaderValues.setVector(SkyProceduralMaterial.SKYTINT,e)}),SkyProceduralMaterial.__init__=function(){SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY=SkyProceduralMaterial.shaderDefines.registerDefine("SUN_HIGH_QUALITY"),SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE=SkyProceduralMaterial.shaderDefines.registerDefine("SUN_SIMPLE")},SkyProceduralMaterial.SUN_NODE=0,SkyProceduralMaterial.SUN_HIGH_QUALITY=1,SkyProceduralMaterial.SUN_SIMPLE=2,SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY=0,SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE=0,i(SkyProceduralMaterial,["SUNSIZE",function(){return this.SUNSIZE=At.propertyNameToID("u_SunSize")},"SUNSIZECONVERGENCE",function(){return this.SUNSIZECONVERGENCE=At.propertyNameToID("u_SunSizeConvergence")},"ATMOSPHERETHICKNESS",function(){return this.ATMOSPHERETHICKNESS=At.propertyNameToID("u_AtmosphereThickness")},"SKYTINT",function(){return this.SKYTINT=At.propertyNameToID("u_SkyTint")},"GROUNDTINT",function(){return this.GROUNDTINT=At.propertyNameToID("u_GroundTint")},"EXPOSURE",function(){return this.EXPOSURE=At.propertyNameToID("u_Exposure")},"defaultMaterial",function(){return this.defaultMaterial=new SkyProceduralMaterial},"shaderDefines",function(){return this.shaderDefines=new ge(Fn.shaderDefines)}]),SkyProceduralMaterial}(),ci=function(e){function ShurikenParticleMaterial(){ShurikenParticleMaterial.__super.call(this),this.setShaderName("PARTICLESHURIKEN"),this._color=new Dt(1,1,1,1),this.renderMode=0}r(ShurikenParticleMaterial,"laya.d3.core.particleShuriKen.ShurikenParticleMaterial",Fn);var t=ShurikenParticleMaterial.prototype;return a(0,t,"_TintColorB",function(){return this._color.z},function(e){this._color.z=e,this.color=this._color}),a(0,t,"_MainTex_STZ",function(){return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).z},function(e){var t=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);t.z=e,this.tilingOffset=t}),a(0,t,"texture",function(){return this._shaderValues.getTexture(ShurikenParticleMaterial.DIFFUSETEXTURE)},function(e){e?this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP):this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP),this._shaderValues.setTexture(ShurikenParticleMaterial.DIFFUSETEXTURE,e)}),a(0,t,"_TintColorR",function(){return this._color.x},function(e){this._color.x=e,this.color=this._color}),a(0,t,"_MainTex_STW",function(){return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).w},function(e){var t=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);t.w=e,this.tilingOffset=t}),a(0,t,"_TintColorG",function(){return this._color.y},function(e){this._color.y=e,this.color=this._color}),a(0,t,"_TintColorA",function(){return this._color.w},function(e){this._color.w=e,this.color=this._color}),a(0,t,"_MainTex_STY",function(){return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).y},function(e){var t=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);t.y=e,this.tilingOffset=t}),a(0,t,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.blendSrc=770,this.blendDst=1,this.alphaTest=!1,this._defineDatas.add(ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG);break;case 0:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.blendSrc=770,this.blendDst=771,this.alphaTest=!1,this._defineDatas.remove(ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("ShurikenParticleMaterial : renderMode value error.")}}),a(0,t,"_MainTex_STX",function(){return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).x},function(e){var t=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);t.x=e,this.tilingOffset=t}),a(0,t,"colorR",function(){return this._TintColorR},function(e){this._TintColorR=e}),a(0,t,"colorG",function(){return this._TintColorG},function(e){this._TintColorG=e}),a(0,t,"colorB",function(){return this._TintColorB},function(e){this._TintColorB=e}),a(0,t,"colorA",function(){return this._TintColorA},function(e){this._TintColorA=e}),a(0,t,"blend",function(){return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND)},function(e){this._shaderValues.setInt(ShurikenParticleMaterial.BLEND,e)}),a(0,t,"color",function(){return this._shaderValues.getVector(ShurikenParticleMaterial.TINTCOLOR)},function(e){e?this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR):this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR),this._shaderValues.setVector(ShurikenParticleMaterial.TINTCOLOR,e)}),a(0,t,"tilingOffsetX",function(){return this._MainTex_STX},function(e){this._MainTex_STX=e}),a(0,t,"tilingOffsetY",function(){return this._MainTex_STY},function(e){this._MainTex_STY=e}),a(0,t,"tilingOffsetZ",function(){return this._MainTex_STZ},function(e){this._MainTex_STZ=e}),a(0,t,"blendSrc",function(){return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND_SRC)},function(e){this._shaderValues.setInt(ShurikenParticleMaterial.BLEND_SRC,e)}),a(0,t,"tilingOffsetW",function(){return this._MainTex_STW},function(e){this._MainTex_STW=e}),a(0,t,"tilingOffset",function(){return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET)},function(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET):this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(ShurikenParticleMaterial.TILINGOFFSET,e)}),a(0,t,"depthWrite",function(){return this._shaderValues.getBool(ShurikenParticleMaterial.DEPTH_WRITE)},function(e){this._shaderValues.setBool(ShurikenParticleMaterial.DEPTH_WRITE,e)}),a(0,t,"cull",function(){return this._shaderValues.getInt(ShurikenParticleMaterial.CULL)},function(e){this._shaderValues.setInt(ShurikenParticleMaterial.CULL,e)}),a(0,t,"blendDst",function(){return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND_DST)},function(e){this._shaderValues.setInt(ShurikenParticleMaterial.BLEND_DST,e)}),a(0,t,"depthTest",function(){return this._shaderValues.getInt(ShurikenParticleMaterial.DEPTH_TEST)},function(e){this._shaderValues.setInt(ShurikenParticleMaterial.DEPTH_TEST,e)}),ShurikenParticleMaterial.__init__=function(){ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP=ShurikenParticleMaterial.shaderDefines.registerDefine("DIFFUSEMAP"),ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR=ShurikenParticleMaterial.shaderDefines.registerDefine("TINTCOLOR"),ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG=ShurikenParticleMaterial.shaderDefines.registerDefine("ADDTIVEFOG"),ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET=ShurikenParticleMaterial.shaderDefines.registerDefine("TILINGOFFSET")},ShurikenParticleMaterial.RENDERMODE_ALPHABLENDED=0,ShurikenParticleMaterial.RENDERMODE_ADDTIVE=1,ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP=0,ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR=0,ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET=0,ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG=0,i(ShurikenParticleMaterial,["DIFFUSETEXTURE",function(){return this.DIFFUSETEXTURE=At.propertyNameToID("u_texture")},"TINTCOLOR",function(){return this.TINTCOLOR=At.propertyNameToID("u_Tintcolor")},"TILINGOFFSET",function(){return this.TILINGOFFSET=At.propertyNameToID("u_TilingOffset")},"CULL",function(){return this.CULL=At.propertyNameToID("s_Cull")},"BLEND",function(){return this.BLEND=At.propertyNameToID("s_Blend")},"BLEND_SRC",function(){return this.BLEND_SRC=At.propertyNameToID("s_BlendSrc")},"BLEND_DST",function(){return this.BLEND_DST=At.propertyNameToID("s_BlendDst")},"DEPTH_TEST",function(){return this.DEPTH_TEST=At.propertyNameToID("s_DepthTest")},"DEPTH_WRITE",function(){return this.DEPTH_WRITE=At.propertyNameToID("s_DepthWrite")},"defaultMaterial",function(){return this.defaultMaterial=new ShurikenParticleMaterial},"shaderDefines",function(){return this.shaderDefines=new ge(Fn.shaderDefines)}]),ShurikenParticleMaterial}(),di=function(e){function TerrainMaterial(){this._diffuseScale1=null,this._diffuseScale2=null,this._diffuseScale3=null,this._diffuseScale4=null,TerrainMaterial.__super.call(this),this.setShaderName("Terrain"),this.renderMode=1,this._diffuseScale1=new Ct,this._diffuseScale2=new Ct,this._diffuseScale3=new Ct,this._diffuseScale4=new Ct,this.ambientColor=new Rt(.6,.6,.6),this.diffuseColor=new Rt(1,1,1),this.specularColor=new Dt(.2,.2,.2,32)}r(TerrainMaterial,"laya.d3.core.material.TerrainMaterial",e);var t=TerrainMaterial.prototype;return t.setDiffuseScale1=function(e,t){this._diffuseScale1.x=e,this._diffuseScale1.y=t,this._shaderValues.setVector2(6,this._diffuseScale1)},t.setDiffuseScale2=function(e,t){this._diffuseScale2.x=e,this._diffuseScale2.y=t,this._shaderValues.setVector2(7,this._diffuseScale2)},t.setDiffuseScale3=function(e,t){this._diffuseScale3.x=e,this._diffuseScale3.y=t,this._shaderValues.setVector2(8,this._diffuseScale3)},t.setDiffuseScale4=function(e,t){this._diffuseScale4.x=e,this._diffuseScale4.y=t,this._shaderValues.setVector2(9,this._diffuseScale4)},t.setDetailNum=function(e){switch(e){case 1:this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);break;case 2:this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);break;case 3:this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);break;case 4:this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3)}},t.disableLight=function(){this._disablePublicDefineDatas.add(qn.SHADERDEFINE_POINTLIGHT|qn.SHADERDEFINE_SPOTLIGHT|qn.SHADERDEFINE_DIRECTIONLIGHT)},t.setShaderName=function(t){e.prototype.setShaderName.call(this,t)},a(0,t,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.depthTest=513;break;case 2:this.renderQueue=2e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.blendSrc=770,this.blendDst=771,this.depthTest=515;break;default:throw new Error("TerrainMaterial:renderMode value error.")}}),a(0,t,"diffuseTexture2",function(){return this._shaderValues.getTexture(3)},function(e){this._shaderValues.setTexture(3,e)}),a(0,t,"ambientColor",function(){return this._shaderValues.getVector(10)},function(e){this._shaderValues.setVector3(10,e)}),a(0,t,"diffuseTexture4",function(){return this._shaderValues.getTexture(5)},function(e){this._shaderValues.setTexture(5,e)}),a(0,t,"diffuseColor",function(){return this._shaderValues.getVector(11)},function(e){this._shaderValues.setVector3(11,e)}),a(0,t,"diffuseTexture1",function(){return this._shaderValues.getTexture(2)},function(e){this._shaderValues.setTexture(2,e)}),a(0,t,"specularColor",function(){return this._shaderValues.getVector(12)},function(e){this._shaderValues.setVector(12,e)}),a(0,t,"diffuseTexture3",function(){return this._shaderValues.getTexture(4)},function(e){this._shaderValues.setTexture(4,e)}),a(0,t,"splatAlphaTexture",function(){return this._shaderValues.getTexture(0)},function(e){this._shaderValues.setTexture(0,e)}),a(0,t,"cull",function(){return this._shaderValues.getInt(TerrainMaterial.CULL)},function(e){this._shaderValues.setInt(TerrainMaterial.CULL,e)}),a(0,t,"normalTexture",function(){return this._shaderValues.getTexture(1)},function(e){this._shaderValues.setTexture(1,e)}),a(0,t,"depthWrite",function(){return this._shaderValues.getBool(TerrainMaterial.DEPTH_WRITE)},function(e){this._shaderValues.setBool(TerrainMaterial.DEPTH_WRITE,e)}),a(0,t,"blend",function(){return this._shaderValues.getInt(TerrainMaterial.BLEND)},function(e){this._shaderValues.setInt(TerrainMaterial.BLEND,e)}),a(0,t,"blendSrc",function(){return this._shaderValues.getInt(TerrainMaterial.BLEND_SRC)},function(e){this._shaderValues.setInt(TerrainMaterial.BLEND_SRC,e)}),a(0,t,"blendDst",function(){return this._shaderValues.getInt(TerrainMaterial.BLEND_DST)},function(e){this._shaderValues.setInt(TerrainMaterial.BLEND_DST,e)}),a(0,t,"depthTest",function(){return this._shaderValues.getInt(TerrainMaterial.DEPTH_TEST)},function(e){this._shaderValues.setInt(TerrainMaterial.DEPTH_TEST,e)}),TerrainMaterial.__init__=function(){TerrainMaterial.SHADERDEFINE_DETAIL_NUM1=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM1"),TerrainMaterial.SHADERDEFINE_DETAIL_NUM2=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM2"),TerrainMaterial.SHADERDEFINE_DETAIL_NUM4=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM4"),TerrainMaterial.SHADERDEFINE_DETAIL_NUM3=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM3")},TerrainMaterial.RENDERMODE_OPAQUE=1,TerrainMaterial.RENDERMODE_TRANSPARENT=2,TerrainMaterial.SPLATALPHATEXTURE=0,TerrainMaterial.NORMALTEXTURE=1,TerrainMaterial.DIFFUSETEXTURE1=2,TerrainMaterial.DIFFUSETEXTURE2=3,TerrainMaterial.DIFFUSETEXTURE3=4,TerrainMaterial.DIFFUSETEXTURE4=5,TerrainMaterial.DIFFUSESCALE1=6,TerrainMaterial.DIFFUSESCALE2=7,TerrainMaterial.DIFFUSESCALE3=8,TerrainMaterial.DIFFUSESCALE4=9,TerrainMaterial.MATERIALAMBIENT=10,TerrainMaterial.MATERIALDIFFUSE=11,TerrainMaterial.MATERIALSPECULAR=12,TerrainMaterial.SHADERDEFINE_DETAIL_NUM1=0,TerrainMaterial.SHADERDEFINE_DETAIL_NUM2=0,TerrainMaterial.SHADERDEFINE_DETAIL_NUM3=0,TerrainMaterial.SHADERDEFINE_DETAIL_NUM4=0,i(TerrainMaterial,["CULL",function(){return this.CULL=At.propertyNameToID("s_Cull")},"BLEND",function(){return this.BLEND=At.propertyNameToID("s_Blend")},"BLEND_SRC",function(){return this.BLEND_SRC=At.propertyNameToID("s_BlendSrc")},"BLEND_DST",function(){return this.BLEND_DST=At.propertyNameToID("s_BlendDst")},"DEPTH_TEST",function(){return this.DEPTH_TEST=At.propertyNameToID("s_DepthTest")},"DEPTH_WRITE",function(){return this.DEPTH_WRITE=At.propertyNameToID("s_DepthWrite")},"defaultMaterial",function(){return this.defaultMaterial=new TerrainMaterial},"shaderDefines",function(){return this.shaderDefines=new ge(Fn.shaderDefines)}]),TerrainMaterial}(Fn),_i=function(e){function BlinnPhongMaterial(){this._enableVertexColor=!1,BlinnPhongMaterial.__super.call(this),this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new Dt(1,1,1,1);var e=this._shaderValues;e.setVector(BlinnPhongMaterial.ALBEDOCOLOR,new Dt(1,1,1,1)),e.setVector(BlinnPhongMaterial.MATERIALSPECULAR,new Dt(1,1,1,1)),e.setNumber(BlinnPhongMaterial.SHININESS,.078125),e.setNumber(Fn.ALPHATESTVALUE,.5),e.setVector(BlinnPhongMaterial.TILINGOFFSET,new Dt(1,1,0,0)),this._enableLighting=!0,this.renderMode=0}r(BlinnPhongMaterial,"laya.d3.core.material.BlinnPhongMaterial",e);var t=BlinnPhongMaterial.prototype;return t.disableFog=function(){this._disablePublicDefineDatas.add(qn.SHADERDEFINE_FOG)},t.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n._enableLighting=this._enableLighting,n._albedoIntensity=this._albedoIntensity,n._enableVertexColor=this._enableVertexColor,this._albedoColor.cloneTo(n._albedoColor)},a(0,t,"_SpecColorG",function(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y},function(e){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y=e}),a(0,t,"_ColorB",function(){return this._albedoColor.z},function(e){this._albedoColor.z=e,this.albedoColor=this._albedoColor}),a(0,t,"_ColorR",function(){return this._albedoColor.x},function(e){this._albedoColor.x=e,this.albedoColor=this._albedoColor}),a(0,t,"albedoColorA",function(){return this._ColorA},function(e){this._ColorA=e}),a(0,t,"_MainTex_STX",function(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).x},function(e){var t=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);t.x=e,this.tilingOffset=t}),a(0,t,"_SpecColorB",function(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z},function(e){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z=e}),a(0,t,"renderMode",null,function(e){switch(e){case 0:this.alphaTest=!1,this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.depthTest=513;break;case 1:this.renderQueue=2450,this.alphaTest=!0,this.depthWrite=!0,this.cull=2,this.blend=0,this.depthTest=513;break;case 2:this.renderQueue=3e3,this.alphaTest=!1,this.depthWrite=!1,this.cull=2,this.blend=1,this.blendSrc=770,this.blendDst=771,this.depthTest=513;break;default:throw new Error("Material:renderMode value error.")}}),a(0,t,"_SpecColorR",function(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x},function(e){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x=e}),a(0,t,"_ColorG",function(){return this._albedoColor.y},function(e){this._albedoColor.y=e,this.albedoColor=this._albedoColor}),a(0,t,"_ColorA",function(){return this._albedoColor.w},function(e){this._albedoColor.w=e,this.albedoColor=this._albedoColor}),a(0,t,"specularColor",function(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR)},function(e){this._shaderValues.setVector(BlinnPhongMaterial.MATERIALSPECULAR,e)}),a(0,t,"albedoColorB",function(){return this._ColorB},function(e){this._ColorB=e}),a(0,t,"_SpecColorA",function(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w},function(e){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w=e}),a(0,t,"_MainTex_STZ",function(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).z},function(e){var t=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);t.z=e,this.tilingOffset=t}),a(0,t,"_AlbedoIntensity",function(){return this._albedoIntensity},function(e){if(this._albedoIntensity!==e){var t=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);Dt.scale(this._albedoColor,e,t),this._albedoIntensity=e,this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,t)}}),a(0,t,"specularColorA",function(){return this._SpecColorA},function(e){this._SpecColorA=e}),a(0,t,"_Shininess",function(){return this._shaderValues.getNumber(BlinnPhongMaterial.SHININESS)},function(e){e=Math.max(0,Math.min(1,e)),this._shaderValues.setNumber(BlinnPhongMaterial.SHININESS,e)}),a(0,t,"_MainTex_STY",function(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).y},function(e){var t=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);t.y=e,this.tilingOffset=t}),a(0,t,"_Cutoff",function(){return this.alphaTestValue},function(e){this.alphaTestValue=e}),a(0,t,"_MainTex_STW",function(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).w},function(e){var t=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);t.w=e,this.tilingOffset=t}),a(0,t,"albedoTexture",function(){return this._shaderValues.getTexture(BlinnPhongMaterial.ALBEDOTEXTURE)},function(e){e?this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP):this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP),this._shaderValues.setTexture(BlinnPhongMaterial.ALBEDOTEXTURE,e)}),a(0,t,"enableVertexColor",function(){return this._enableVertexColor},function(e){this._enableVertexColor=e,e?this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR):this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR)}),a(0,t,"albedoColor",function(){return this._albedoColor},function(e){var t=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);Dt.scale(e,this._albedoIntensity,t),this._albedoColor=e,this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,t)}),a(0,t,"tilingOffsetX",function(){return this._MainTex_STX},function(e){this._MainTex_STX=e}),a(0,t,"tilingOffsetY",function(){return this._MainTex_STY},function(e){this._MainTex_STY=e}),a(0,t,"tilingOffsetZ",function(){return this._MainTex_STZ},function(e){this._MainTex_STZ=e}),a(0,t,"blendSrc",function(){return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_SRC)},function(e){this._shaderValues.setInt(BlinnPhongMaterial.BLEND_SRC,e)}),a(0,t,"enableLighting",function(){return this._enableLighting},function(e){this._enableLighting!==e&&(e?this._disablePublicDefineDatas.remove(qn.SHADERDEFINE_POINTLIGHT|qn.SHADERDEFINE_SPOTLIGHT|qn.SHADERDEFINE_DIRECTIONLIGHT):this._disablePublicDefineDatas.add(qn.SHADERDEFINE_POINTLIGHT|qn.SHADERDEFINE_SPOTLIGHT|qn.SHADERDEFINE_DIRECTIONLIGHT),this._enableLighting=e)}),a(0,t,"tilingOffsetW",function(){return this._MainTex_STW},function(e){this._MainTex_STW=e}),a(0,t,"tilingOffset",function(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET)},function(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET):this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(BlinnPhongMaterial.TILINGOFFSET,e)}),a(0,t,"albedoColorR",function(){return this._ColorR},function(e){this._ColorR=e}),a(0,t,"albedoColorG",function(){return this._ColorG},function(e){this._ColorG=e}),a(0,t,"albedoIntensity",function(){return this._albedoIntensity},function(e){this._AlbedoIntensity=e}),a(0,t,"specularColorR",function(){return this._SpecColorR},function(e){this._SpecColorR=e}),a(0,t,"specularColorG",function(){return this._SpecColorG},function(e){this._SpecColorG=e}),a(0,t,"specularColorB",function(){return this._SpecColorB},function(e){this._SpecColorB=e}),a(0,t,"blendDst",function(){return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_DST)},function(e){this._shaderValues.setInt(BlinnPhongMaterial.BLEND_DST,e)}),a(0,t,"shininess",function(){return this._Shininess},function(e){this._Shininess=e}),a(0,t,"cull",function(){return this._shaderValues.getInt(BlinnPhongMaterial.CULL)},function(e){this._shaderValues.setInt(BlinnPhongMaterial.CULL,e)}),a(0,t,"normalTexture",function(){return this._shaderValues.getTexture(BlinnPhongMaterial.NORMALTEXTURE)},function(e){e?this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP):this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP),this._shaderValues.setTexture(BlinnPhongMaterial.NORMALTEXTURE,e)}),a(0,t,"specularTexture",function(){return this._shaderValues.getTexture(BlinnPhongMaterial.SPECULARTEXTURE)},function(e){e?this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP):this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP),this._shaderValues.setTexture(BlinnPhongMaterial.SPECULARTEXTURE,e)}),a(0,t,"depthWrite",function(){return this._shaderValues.getBool(BlinnPhongMaterial.DEPTH_WRITE)},function(e){this._shaderValues.setBool(BlinnPhongMaterial.DEPTH_WRITE,e)}),a(0,t,"blend",function(){return this._shaderValues.getInt(BlinnPhongMaterial.BLEND)},function(e){this._shaderValues.setInt(BlinnPhongMaterial.BLEND,e)}),a(0,t,"depthTest",function(){return this._shaderValues.getInt(BlinnPhongMaterial.DEPTH_TEST)},function(e){this._shaderValues.setInt(BlinnPhongMaterial.DEPTH_TEST,e)}),BlinnPhongMaterial.__init__=function(){BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP=BlinnPhongMaterial.shaderDefines.registerDefine("DIFFUSEMAP"),BlinnPhongMaterial.SHADERDEFINE_NORMALMAP=BlinnPhongMaterial.shaderDefines.registerDefine("NORMALMAP"),BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP=BlinnPhongMaterial.shaderDefines.registerDefine("SPECULARMAP"),BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET=BlinnPhongMaterial.shaderDefines.registerDefine("TILINGOFFSET"),BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=BlinnPhongMaterial.shaderDefines.registerDefine("ENABLEVERTEXCOLOR")},BlinnPhongMaterial.SPECULARSOURCE_DIFFUSEMAPALPHA=0,BlinnPhongMaterial.SPECULARSOURCE_SPECULARMAP=0,BlinnPhongMaterial.RENDERMODE_OPAQUE=0,BlinnPhongMaterial.RENDERMODE_CUTOUT=1,BlinnPhongMaterial.RENDERMODE_TRANSPARENT=2,BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP=0,BlinnPhongMaterial.SHADERDEFINE_NORMALMAP=0,BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP=0,BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET=0,BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=0,i(BlinnPhongMaterial,["ALBEDOTEXTURE",function(){return this.ALBEDOTEXTURE=At.propertyNameToID("u_DiffuseTexture")},"NORMALTEXTURE",function(){return this.NORMALTEXTURE=At.propertyNameToID("u_NormalTexture")},"SPECULARTEXTURE",function(){return this.SPECULARTEXTURE=At.propertyNameToID("u_SpecularTexture")},"ALBEDOCOLOR",function(){return this.ALBEDOCOLOR=At.propertyNameToID("u_DiffuseColor")},"MATERIALSPECULAR",function(){return this.MATERIALSPECULAR=At.propertyNameToID("u_MaterialSpecular")},"SHININESS",function(){return this.SHININESS=At.propertyNameToID("u_Shininess")},"TILINGOFFSET",function(){return this.TILINGOFFSET=At.propertyNameToID("u_TilingOffset")},"CULL",function(){return this.CULL=At.propertyNameToID("s_Cull")},"BLEND",function(){return this.BLEND=At.propertyNameToID("s_Blend")},"BLEND_SRC",function(){return this.BLEND_SRC=At.propertyNameToID("s_BlendSrc")},"BLEND_DST",function(){return this.BLEND_DST=At.propertyNameToID("s_BlendDst")},"DEPTH_TEST",function(){return this.DEPTH_TEST=At.propertyNameToID("s_DepthTest")},"DEPTH_WRITE",function(){return this.DEPTH_WRITE=At.propertyNameToID("s_DepthWrite")},"defaultMaterial",function(){return this.defaultMaterial=new BlinnPhongMaterial},"shaderDefines",function(){return this.shaderDefines=new ge(Fn.shaderDefines)}]),BlinnPhongMaterial}(Fn),fi=function(e){function EffectMaterial(){this._color=null,EffectMaterial.__super.call(this),this.setShaderName("Effect"),this._color=new Dt(1,1,1,1),this._shaderValues.setVector(EffectMaterial.TINTCOLOR,new Dt(1,1,1,1)),this.renderMode=0}r(EffectMaterial,"laya.d3.core.material.EffectMaterial",Fn);var t=EffectMaterial.prototype;return a(0,t,"_TintColorB",function(){return this._color.z},function(e){this._color.z=e,this.color=this._color}),a(0,t,"_MainTex_STZ",function(){return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).z},function(e){var t=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);t.z=e,this.tilingOffset=t}),a(0,t,"texture",function(){return this._shaderValues.getTexture(EffectMaterial.MAINTEXTURE)},function(e){e?this._defineDatas.add(laya.d3.core.material.EffectMaterial.SHADERDEFINE_MAINTEXTURE):this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_MAINTEXTURE),this._shaderValues.setTexture(EffectMaterial.MAINTEXTURE,e)}),a(0,t,"_TintColorR",function(){return this._color.x},function(e){this._color.x=e,this.color=this._color}),a(0,t,"_MainTex_STW",function(){return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).w},function(e){var t=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);t.w=e,this.tilingOffset=t}),a(0,t,"_TintColorG",function(){return this._color.y},function(e){this._color.y=e,this.color=this._color}),a(0,t,"_TintColorA",function(){return this._color.w},function(e){this._color.w=e,this.color=this._color}),a(0,t,"_MainTex_STY",function(){return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).y},function(e){var t=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);t.y=e,this.tilingOffset=t}),a(0,t,"renderMode",null,function(e){switch(e){case 0:this.renderQueue=3e3,this.alphaTest=!1,this.depthWrite=!1,this.cull=0,this.blend=1,this.blendSrc=770,this.blendDst=1,this.depthTest=513,this._defineDatas.add(EffectMaterial.SHADERDEFINE_ADDTIVEFOG);break;case 1:this.renderQueue=3e3,this.alphaTest=!1,this.depthWrite=!1,this.cull=0,this.blend=1,this.blendSrc=770,this.blendDst=771,this.depthTest=513,this._defineDatas.remove(EffectMaterial.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("MeshEffectMaterial : renderMode value error.")}}),a(0,t,"_MainTex_STX",function(){return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).x},function(e){var t=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);t.x=e,this.tilingOffset=t}),a(0,t,"colorR",function(){return this._TintColorR},function(e){this._TintColorR=e}),a(0,t,"colorG",function(){return this._TintColorG},function(e){this._TintColorG=e}),a(0,t,"colorB",function(){return this._TintColorB},function(e){this._TintColorB=e}),a(0,t,"colorA",function(){return this._TintColorA},function(e){this._TintColorA=e}),a(0,t,"blend",function(){return this._shaderValues.getInt(EffectMaterial.BLEND)},function(e){this._shaderValues.setInt(EffectMaterial.BLEND,e)}),a(0,t,"color",function(){return this._shaderValues.getVector(EffectMaterial.TINTCOLOR)},function(e){this._shaderValues.setVector(EffectMaterial.TINTCOLOR,e)}),a(0,t,"tilingOffsetX",function(){return this._MainTex_STX},function(e){this._MainTex_STX=e}),a(0,t,"tilingOffsetY",function(){return this._MainTex_STY},function(e){this._MainTex_STY=e}),a(0,t,"tilingOffsetZ",function(){return this._MainTex_STZ},function(e){this._MainTex_STZ=e}),a(0,t,"blendSrc",function(){return this._shaderValues.getInt(EffectMaterial.BLEND_SRC)},function(e){this._shaderValues.setInt(EffectMaterial.BLEND_SRC,e)}),a(0,t,"tilingOffsetW",function(){return this._MainTex_STW},function(e){this._MainTex_STW=e}),a(0,t,"tilingOffset",function(){return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET)},function(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._defineDatas.add(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET):this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(EffectMaterial.TILINGOFFSET,e)}),a(0,t,"depthWrite",function(){return this._shaderValues.getBool(EffectMaterial.DEPTH_WRITE)},function(e){this._shaderValues.setBool(EffectMaterial.DEPTH_WRITE,e)}),a(0,t,"cull",function(){return this._shaderValues.getInt(EffectMaterial.CULL)},function(e){this._shaderValues.setInt(EffectMaterial.CULL,e)}),a(0,t,"blendDst",function(){return this._shaderValues.getInt(EffectMaterial.BLEND_DST)},function(e){this._shaderValues.setInt(EffectMaterial.BLEND_DST,e)}),a(0,t,"depthTest",function(){return this._shaderValues.getInt(EffectMaterial.DEPTH_TEST)},function(e){this._shaderValues.setInt(EffectMaterial.DEPTH_TEST,e)}),EffectMaterial.__init__=function(){EffectMaterial.SHADERDEFINE_MAINTEXTURE=EffectMaterial.shaderDefines.registerDefine("MAINTEXTURE"),EffectMaterial.SHADERDEFINE_TILINGOFFSET=EffectMaterial.shaderDefines.registerDefine("TILINGOFFSET"),EffectMaterial.SHADERDEFINE_ADDTIVEFOG=EffectMaterial.shaderDefines.registerDefine("ADDTIVEFOG")},EffectMaterial.RENDERMODE_ADDTIVE=0,EffectMaterial.RENDERMODE_ALPHABLENDED=1,EffectMaterial.SHADERDEFINE_MAINTEXTURE=0,EffectMaterial.SHADERDEFINE_TILINGOFFSET=0,EffectMaterial.SHADERDEFINE_ADDTIVEFOG=0,i(EffectMaterial,["defaultMaterial",function(){return this.defaultMaterial=new EffectMaterial},"MAINTEXTURE",function(){return this.MAINTEXTURE=At.propertyNameToID("u_AlbedoTexture")},"TINTCOLOR",function(){return this.TINTCOLOR=At.propertyNameToID("u_AlbedoColor")},"TILINGOFFSET",function(){return this.TILINGOFFSET=At.propertyNameToID("u_TilingOffset")},"CULL",function(){return this.CULL=At.propertyNameToID("s_Cull")},"BLEND",function(){return this.BLEND=At.propertyNameToID("s_Blend")},"BLEND_SRC",function(){return this.BLEND_SRC=At.propertyNameToID("s_BlendSrc")},"BLEND_DST",function(){return this.BLEND_DST=At.propertyNameToID("s_BlendDst")},"DEPTH_TEST",function(){return this.DEPTH_TEST=At.propertyNameToID("s_DepthTest")},"DEPTH_WRITE",function(){return this.DEPTH_WRITE=At.propertyNameToID("s_DepthWrite")},"shaderDefines",function(){return this.shaderDefines=new ge(Fn.shaderDefines)}]),EffectMaterial}(),mi=function(e){function SkinnedMeshRenderer(e){this._bones=[],this._skinnedDataLoopMarks=[],this._localBounds=new ot(Rt._ZERO,Rt._ZERO),this._cacheAnimationNode=[],SkinnedMeshRenderer.__super.call(this,e)}r(SkinnedMeshRenderer,"laya.d3.core.SkinnedMeshRenderer",e);var t=SkinnedMeshRenderer.prototype;return t._computeSkinnedData=function(){if(this._cacheMesh&&this._cacheAvatar||this._cacheMesh&&this._cacheRootBone)for(var e=this._cacheMesh._inverseBindPoses,t=this._cacheMesh._bindPoseIndices,n=this._cacheMesh._skinDataPathMarks,i=0,r=this._cacheMesh.subMeshCount;i0&&(n^=2),n|=1):((1&n)>0&&(n^=1),n|=2),t.setCollisionFlags(n),this._nativeColliderObject=t,e.prototype._onAdded.call(this)}}(Qn),function(t){function Rigidbody3D(e,t){this._isKinematic=!1,this._mass=1,this._angularDamping=0,this._linearDamping=0,this._overrideGravity=!1,this._detectCollisions=!0,this._gravity=new Rt(0,-10,0),this._totalTorque=new Rt(0,0,0),this._linearVelocity=new Rt,this._angularVelocity=new Rt,this._linearFactor=new Rt(1,1,1),this._angularFactor=new Rt(1,1,1),void 0===e&&(e=1),void 0===t&&(t=kt.COLLISIONFILTERGROUP_ALLFILTER),Rigidbody3D.__super.call(this,e,t)}r(Rigidbody3D,"laya.d3.physics.Rigidbody3D",t);var n=Rigidbody3D.prototype;n._updateMass=function(e){this._nativeColliderObject&&this._colliderShape&&(this._colliderShape._nativeShape.calculateLocalInertia(e,Rigidbody3D._nativeInertia),this._nativeColliderObject.setMassProps(e,Rigidbody3D._nativeInertia),this._nativeColliderObject.updateInertiaTensor())},n._delegateMotionStateGetWorldTransform=function(e){},n._delegateMotionStateSetWorldTransform=function(e){var t=this._rigidbody;t._simulation._updatedRigidbodies++;var n=wt._physics3D,i=n.wrapPointer(e,n.btTransform);t._updateTransformComponent(i)},n._delegateMotionStateGetWorldTransformNative=function(e,t){},n._delegateMotionStateSetWorldTransformNative=function(e,t){var n=e;n._simulation._updatedRigidbodies++;var i=wt._physics3D,r=i.wrapPointer(t,i.btTransform);n._updateTransformComponent(r)},n._onScaleChange=function(e){laya.d3.physics.PhysicsComponent.prototype._onScaleChange.call(this,e),this._updateMass(this._isKinematic?0:this._mass)},n._delegateMotionStateClear=function(){this._rigidbody=null},n._onAdded=function(){var n=wt._physics3D,i=new n.LayaMotionState;null!=e.conch&&n.LayaMotionState.prototype.setRigidbody?(i.setRigidbody(this),i.setNativeGetWorldTransform(this._delegateMotionStateGetWorldTransformNative),i.setNativeSetWorldTransform(this._delegateMotionStateSetWorldTransformNative)):(i.getWorldTransform=this._delegateMotionStateGetWorldTransform,i.setWorldTransform=this._delegateMotionStateSetWorldTransform),i.clear=this._delegateMotionStateClear,i._rigidbody=this,this._nativeMotionState=i;var r=new n.btRigidBodyConstructionInfo(0,i,null,Rigidbody3D._nativeVector3Zero),a=new n.btRigidBody(r);a.setUserIndex(this.id),this._nativeColliderObject=a,t.prototype._onAdded.call(this),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,n.destroy(r)},n._onShapeChange=function(e){laya.d3.physics.PhysicsComponent.prototype._onShapeChange.call(this,e),this._isKinematic?this._updateMass(0):(this._nativeColliderObject.setCenterOfMassTransform(this._nativeColliderObject.getWorldTransform()),this._updateMass(this._mass))},n._parse=function(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),null!=e.mass&&(this.mass=e.mass),null!=e.isKinematic&&(this.isKinematic=e.isKinematic),null!=e.linearDamping&&(this.linearDamping=e.linearDamping),null!=e.angularDamping&&(this.angularDamping=e.angularDamping),null!=e.overrideGravity&&(this.overrideGravity=e.overrideGravity),e.gravity&&(this.gravity.fromArray(e.gravity),this.gravity=this.gravity),laya.d3.physics.PhysicsComponent.prototype._parse.call(this,e),this._parseShape(e.shapes)},n._onDestroy=function(){var e=wt._physics3D;this._nativeMotionState.clear(),e.destroy(this._nativeMotionState),laya.d3.physics.PhysicsComponent.prototype._onDestroy.call(this),this._nativeMotionState=null,this._gravity=null,this._totalTorque=null,this._linearVelocity=null,this._angularVelocity=null,this._linearFactor=null,this._angularFactor=null},n._addToSimulation=function(){this._simulation._addRigidBody(this,this._collisionGroup,this._detectCollisions?this._canCollideWith:0)},n._removeFromSimulation=function(){this._simulation._removeRigidBody(this)},n._cloneTo=function(e){t.prototype._cloneTo.call(this,e);var n=e;n.isKinematic=this._isKinematic,n.mass=this._mass,n.gravity=this._gravity,n.angularDamping=this._angularDamping,n.linearDamping=this._linearDamping,n.overrideGravity=this._overrideGravity,n.linearVelocity=this._linearVelocity,n.angularVelocity=this._angularVelocity,n.linearFactor=this._linearFactor,n.angularFactor=this._angularFactor,n.detectCollisions=this._detectCollisions},n.applyForce=function(e,t){if(null==this._nativeColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var n=Rigidbody3D._nativeTempVector30;if(n.setValue(-e.x,e.y,e.z),t){var i=Rigidbody3D._nativeTempVector31;i.setValue(-t.x,t.y,t.z),this._nativeColliderObject.applyForce(n,i)}else this._nativeColliderObject.applyCentralForce(n)},n.applyTorque=function(e){if(null==this._nativeColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=Rigidbody3D._nativeTempVector30;t.setValue(-e.x,e.y,e.z),this._nativeColliderObject.applyTorque(t)},n.applyImpulse=function(e,t){if(null==this._nativeColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";Rigidbody3D._nativeImpulse.setValue(-e.x,e.y,e.z),t?(Rigidbody3D._nativeImpulseOffset.setValue(-t.x,t.y,t.z),this._nativeColliderObject.applyImpulse(Rigidbody3D._nativeImpulse,Rigidbody3D._nativeImpulseOffset)):this._nativeColliderObject.applyCentralImpulse(Rigidbody3D._nativeImpulse)},n.applyTorqueImpulse=function(e){if(null==this._nativeColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=Rigidbody3D._nativeTempVector30;t.setValue(-e.x,e.y,e.z),this._nativeColliderObject.applyTorqueImpulse(t)},n.wakeUp=function(){this._nativeColliderObject&&this._nativeColliderObject.activate(!1)},n.clearForces=function(){var e=this._nativeColliderObject;if(null==e)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";e.clearForces();var t=Rigidbody3D._nativeVector3Zero;e.setInterpolationAngularVelocity(t),e.setLinearVelocity(t),e.setInterpolationAngularVelocity(t),e.setAngularVelocity(t)},a(0,n,"angularDamping",function(){return this._angularDamping},function(e){this._angularDamping=e,this._nativeColliderObject&&this._nativeColliderObject.setDamping(this._linearDamping,e)}),a(0,n,"mass",function(){return this._mass},function(e){e=Math.max(e,1e-7),this._mass=e,this._isKinematic||this._updateMass(e)}),a(0,n,"linearDamping",function(){return this._linearDamping},function(e){this._linearDamping=e,this._nativeColliderObject&&this._nativeColliderObject.setDamping(e,this._angularDamping)}),a(0,n,"isKinematic",function(){return this._isKinematic},function(e){this._isKinematic=e;var t=!!(this._simulation&&this._enabled&&this._colliderShape);t&&this._removeFromSimulation();var n=this._nativeColliderObject,i=n.getCollisionFlags();e?(i|=2,n.setCollisionFlags(i),this._nativeColliderObject.forceActivationState(4),this._enableProcessCollisions=!1,this._updateMass(0)):((2&i)>0&&(i^=2),n.setCollisionFlags(i),this._nativeColliderObject.setActivationState(1),this._enableProcessCollisions=!0,this._updateMass(this._mass));var r=Rigidbody3D._nativeVector3Zero;n.setInterpolationLinearVelocity(r),n.setLinearVelocity(r),n.setInterpolationAngularVelocity(r),n.setAngularVelocity(r),t&&this._addToSimulation()}),a(0,n,"gravity",function(){return this._gravity},function(e){this._gravity=e,Rigidbody3D._nativeGravity.setValue(-e.x,e.y,e.z),this._nativeColliderObject.setGravity(Rigidbody3D._nativeGravity)}),a(0,n,"overrideGravity",function(){return this._overrideGravity},function(e){if(this._overrideGravity=e,this._nativeColliderObject){var t=this._nativeColliderObject.getFlags();e?0==(1&t)&&this._nativeColliderObject.setFlags(1|t):(1&t)>0&&this._nativeColliderObject.setFlags(1^t)}}),a(0,n,"totalForce",function(){return this._nativeColliderObject?this._nativeColliderObject.getTotalForce():null}),a(0,n,"linearVelocity",function(){return this._nativeColliderObject&&fe._convertToLayaVec3(this._nativeColliderObject.getLinearVelocity(),this._linearVelocity,!0),this._linearVelocity},function(e){if(this._linearVelocity=e,this._nativeColliderObject){var t=Rigidbody3D._nativeTempVector30;fe._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),this._nativeColliderObject.setLinearVelocity(t)}}),a(0,n,"detectCollisions",function(){return this._detectCollisions},function(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)))}),a(0,n,"linearFactor",function(){return this._nativeColliderObject?this._linearFactor:null},function(e){if(this._linearFactor=e,this._nativeColliderObject){var t=Rigidbody3D._nativeTempVector30;fe._convertToBulletVec3(e,t,!1),this._nativeColliderObject.setLinearFactor(t)}}),a(0,n,"angularFactor",function(){return this._nativeColliderObject?this._angularFactor:null},function(e){if(this._angularFactor=e,this._nativeColliderObject){var t=Rigidbody3D._nativeTempVector30;fe._convertToBulletVec3(e,t,!1),this._nativeColliderObject.setAngularFactor(t)}}),a(0,n,"angularVelocity",function(){return this._nativeColliderObject&&fe._convertToLayaVec3(this._nativeColliderObject.getAngularVelocity(),this._angularVelocity,!0),this._angularVelocity},function(e){if(this._angularVelocity=e,this._nativeColliderObject){var t=Rigidbody3D._nativeTempVector30;fe._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),this._nativeColliderObject.setAngularVelocity(t)}}),a(0,n,"totalTorque",function(){if(this._nativeColliderObject){var e=this._nativeColliderObject.getTotalTorque(),t=this._totalTorque;t.x=-e.x,t.y=e.y,t.z=e.z}return null}),a(0,n,"isSleeping",function(){return!!this._nativeColliderObject&&2===this._nativeColliderObject.getActivationState()}),a(0,n,"sleepLinearVelocity",function(){return this._nativeColliderObject.getLinearSleepingThreshold()},function(e){this._nativeColliderObject.setSleepingThresholds(e,this._nativeColliderObject.getAngularSleepingThreshold())}),a(0,n,"sleepAngularVelocity",function(){return this._nativeColliderObject.getAngularSleepingThreshold()},function(e){this._nativeColliderObject.setSleepingThresholds(this._nativeColliderObject.getLinearSleepingThreshold(),e)}),Rigidbody3D.TYPE_STATIC=0,Rigidbody3D.TYPE_DYNAMIC=1,Rigidbody3D.TYPE_KINEMATIC=2,Rigidbody3D._BT_DISABLE_WORLD_GRAVITY=1,Rigidbody3D._BT_ENABLE_GYROPSCOPIC_FORCE=2,i(Rigidbody3D,["_nativeTempVector30",function(){return this._nativeTempVector30=new wt._physics3D.btVector3(0,0,0)},"_nativeTempVector31",function(){return this._nativeTempVector31=new wt._physics3D.btVector3(0,0,0)},"_nativeVector3Zero",function(){return this._nativeVector3Zero=new wt._physics3D.btVector3(0,0,0)},"_nativeInertia",function(){return this._nativeInertia=new wt._physics3D.btVector3(0,0,0)},"_nativeImpulse",function(){return this._nativeImpulse=new wt._physics3D.btVector3(0,0,0)},"_nativeImpulseOffset",function(){return this._nativeImpulseOffset=new wt._physics3D.btVector3(0,0,0)},"_nativeGravity",function(){return this._nativeGravity=new wt._physics3D.btVector3(0,0,0)}])}(Qn),function(e){function TextureCube(e,t){void 0===e&&(e=0),void 0===t&&(t=!1),TextureCube.__super.call(this,e,t),this._glTextureType=34067}r(TextureCube,"laya.d3.resource.TextureCube",s);var t=TextureCube.prototype;return t.setSixSideImageSources=function(e,t){void 0===t&&(t=!1);for(var n=0,i=0,r=0;r<6;r++){var a=e[r];if(!a)return void console.log("TextureCube: image Source can't be null.");var o=a.width,s=a.height;if(r>0&&n!==o)return void console.log("TextureCube: each side image's width and height must same.");if((n=o)!==(i=s))return void console.log("TextureCube: each side image's width and height must same.")}this._width=n,this._height=i;var l=E.instance;F.bindTexture(l,this._glTextureType,this._glTexture);var h=this._getGLFormat();if(R.isConchApp){if(1==t)for(var u=0;u<6;u++)e[u].setPremultiplyAlpha(t);l.texImage2D(34073,0,6408,6408,5121,e[0]),l.texImage2D(34074,0,6408,6408,5121,e[1]),l.texImage2D(34069,0,6408,6408,5121,e[2]),l.texImage2D(34070,0,6408,6408,5121,e[3]),l.texImage2D(34071,0,6408,6408,5121,e[4]),l.texImage2D(34072,0,6408,6408,5121,e[5])}else t&&l.pixelStorei(37441,!0),l.texImage2D(34073,0,h,h,5121,e[0]),l.texImage2D(34074,0,h,h,5121,e[1]),l.texImage2D(34069,0,h,h,5121,e[2]),l.texImage2D(34070,0,h,h,5121,e[3]),l.texImage2D(34071,0,h,h,5121,e[4]),l.texImage2D(34072,0,h,h,5121,e[5]),t&&l.pixelStorei(37441,!1);this._mipmap&&this._isPot(n)&&this._isPot(i)?(l.generateMipmap(this._glTextureType),this._setGPUMemory(n*i*4*(1+1/3)*6)):this._setGPUMemory(n*i*4*6),this._setWarpMode(10242,this._wrapModeU),this._setWarpMode(10243,this._wrapModeV),this._setFilterMode(this._filterMode),this._readyed=!0,this._activeResource()},t.setSixSidePixels=function(e,t,n){if(e<=0||t<=0)throw new Error("TextureCube:width or height must large than 0.");if(!n)throw new Error("TextureCube:pixels can't be null.");this._width=e,this._height=t;var i=E.instance;F.bindTexture(i,this._glTextureType,this._glTexture);var r=this._getGLFormat();i.texImage2D(34073,0,r,e,t,0,r,5121,n[0]),i.texImage2D(34074,0,r,e,t,0,r,5121,n[1]),i.texImage2D(34069,0,r,e,t,0,r,5121,n[2]),i.texImage2D(34070,0,r,e,t,0,r,5121,n[3]),i.texImage2D(34071,0,r,e,t,0,r,5121,n[4]),i.texImage2D(34072,0,r,e,t,0,r,5121,n[5]),this._mipmap&&this._isPot(e)&&this._isPot(t)?(i.generateMipmap(this._glTextureType),this._setGPUMemory(e*t*4*(1+1/3)*6)):this._setGPUMemory(e*t*4*6),this._setWarpMode(10242,this._wrapModeU),this._setWarpMode(10243,this._wrapModeV),this._setFilterMode(this._filterMode),this._readyed=!0,this._activeResource()},t._recoverResource=function(){},a(0,t,"defaulteTexture",function(){return TextureCube.grayTexture}),TextureCube.__init__=function(){var e=new Uint8Array(3);e[0]=128,e[1]=128,e[2]=128,TextureCube.grayTexture=new TextureCube(0,!1),TextureCube.grayTexture.setSixSidePixels(1,1,[e,e,e,e,e,e]),TextureCube.grayTexture.lock=!0},TextureCube._parse=function(e,t,n){var i=n?new TextureCube(n[0],n[1]):new TextureCube;return i.setSixSideImageSources(e),i},TextureCube.load=function(e,t){n.loader.create(e,t,null,"TEXTURECUBE")},TextureCube.grayTexture=null,TextureCube}()),Ti=function(e){function RenderTexture(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0),RenderTexture.__super.call(this,n,!1),this._glTextureType=3553,this._width=e,this._height=t,this._depthStencilFormat=i,this._create(e,t)}r(RenderTexture,"laya.d3.resource.RenderTexture",s);var t=RenderTexture.prototype;return t._create=function(e,t){var n=E.instance;this._frameBuffer=n.createFramebuffer(),F.bindTexture(n,this._glTextureType,this._glTexture);var i=this._getGLFormat();if(n.texImage2D(this._glTextureType,0,i,e,t,0,i,5121,null),this._setGPUMemory(e*t*4),n.bindFramebuffer(36160,this._frameBuffer),n.framebufferTexture2D(36160,36064,3553,this._glTexture,0),3!==this._depthStencilFormat)switch(this._depthStencilBuffer=n.createRenderbuffer(),n.bindRenderbuffer(36161,this._depthStencilBuffer),this._depthStencilFormat){case 0:n.renderbufferStorage(36161,33189,e,t),n.framebufferRenderbuffer(36160,36096,36161,this._depthStencilBuffer);break;case 1:n.renderbufferStorage(36161,36168,e,t),n.framebufferRenderbuffer(36160,36128,36161,this._depthStencilBuffer);break;case 2:n.renderbufferStorage(36161,34041,e,t),n.framebufferRenderbuffer(36160,33306,36161,this._depthStencilBuffer);break;default:throw"RenderTexture: unkonw depth format."}n.bindFramebuffer(36160,null),n.bindRenderbuffer(36161,null),this._setWarpMode(10242,this._wrapModeU),this._setWarpMode(10243,this._wrapModeV),this._setFilterMode(this._filterMode),this._setAnisotropy(this._anisoLevel),this._readyed=!0,this._activeResource()},t._start=function(){E.instance.bindFramebuffer(36160,this._frameBuffer),RenderTexture._currentActive=this,this._readyed=!1},t._end=function(){E.instance.bindFramebuffer(36160,null),RenderTexture._currentActive=null,this._readyed=!0},t.getData=function(e,t,n,i,r){if(R.isConchApp&&2==conchConfig.threadMode)throw"native 2 thread mode use getDataAsync";var a=E.instance;return a.bindFramebuffer(36160,this._frameBuffer),36053===a.checkFramebufferStatus(36160)?(a.readPixels(e,t,n,i,6408,5121,r),a.bindFramebuffer(36160,null),r):(a.bindFramebuffer(36160,null),null)},t.getDataAsync=function(e,t,n,i,r){var a=E.instance;a.bindFramebuffer(36160,this._frameBuffer),a.readPixelsAsync(e,t,n,i,6408,5121,function(e){r(new Uint8Array(e))}),a.bindFramebuffer(36160,null)},t._disposeResource=function(){if(this._frameBuffer){var e=E.instance;e.deleteTexture(this._glTexture),e.deleteFramebuffer(this._frameBuffer),e.deleteRenderbuffer(this._depthStencilBuffer),this._glTexture=null,this._frameBuffer=null,this._depthStencilBuffer=null,this._setGPUMemory(0)}},a(0,t,"depthStencilFormat",function(){return this._depthStencilFormat}),a(0,t,"defaulteTexture",function(){return B.grayTexture}),a(1,RenderTexture,"currentActive",function(){return RenderTexture._currentActive},laya.resource.BaseTexture._$SET_currentActive),RenderTexture.getTemporary=function(e,t,n,i,r){void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=1);var a=1e7*r+1e6*i+1e5*n+1e4*t+e,o=RenderTexture._temporaryMap[a];if(!o||o&&0===o.length){var s=new RenderTexture(e,t,n,i);return s.filterMode=r,s}return o.pop()},RenderTexture.setReleaseTemporary=function(e){var t=1e7*e.filterMode+1e6*e.depthStencilFormat+1e5*e.format+1e4*e.height+e.width,n=RenderTexture._temporaryMap[t];n||(RenderTexture._temporaryMap[t]=n=[]),n.push(e)},RenderTexture._temporaryMap={},RenderTexture._currentActive=null,RenderTexture}(),Si=function(e){function TerrainChunk(e,t,n,i,r,a,o,s){this._terrainFilter=null,TerrainChunk.__super.call(this,s),this._terrainFilter=new cn(this,e,t,n,i,r,a,o),this._render=new Yn(this)}r(TerrainChunk,"laya.d3.terrain.TerrainChunk",e);var t=TerrainChunk.prototype;return t.buildRenderElementAndMaterial=function(e,t,n,i,r,a,o,s,l,h,u,c,d,_,f,m,p,T){void 0===u&&(u=1),void 0===c&&(c=1),void 0===d&&(d=1),void 0===_&&(_=1),void 0===f&&(f=1),void 0===m&&(m=1),void 0===p&&(p=1),void 0===T&&(T=1);var S=new di;l&&(S.diffuseColor=l),s&&(S.ambientColor=s),h&&(S.specularColor=h),S.splatAlphaTexture=g.getRes(n),S.normalTexture=t?g.getRes(t):null,S.diffuseTexture1=i?g.getRes(i):null,S.diffuseTexture2=r?g.getRes(r):null,S.diffuseTexture3=a?g.getRes(a):null,S.diffuseTexture4=o?g.getRes(o):null,S.setDiffuseScale1(u,c),S.setDiffuseScale2(d,_),S.setDiffuseScale3(f,m),S.setDiffuseScale4(p,T),S.setDetailNum(e),0!=this._render._renderElements.length&&(S.renderMode=2);var E=new lt;E.setTransform(this._transform),E.render=this._render,E.setGeometry(this._terrainFilter),this._render._renderElements.push(E),this._render.sharedMaterial=S},t._cloneTo=function(e,t,n){console.log("Terrain Chunk can't clone")},t.destroy=function(t){void 0===t&&(t=!0),this.destroyed||(e.prototype.destroy.call(this,t),this._terrainFilter.destroy(),this._terrainFilter=null)},a(0,t,"terrainFilter",function(){return this._terrainFilter}),a(0,t,"terrainRender",function(){return this._render}),TerrainChunk}(Jn),Ei=function(e){function MeshSprite3D(e,t){MeshSprite3D.__super.call(this,t),this._meshFilter=new X(this),this._render=new Xn(this),e&&(this._meshFilter.sharedMesh=e)}r(MeshSprite3D,"laya.d3.core.MeshSprite3D",e);var t=MeshSprite3D.prototype;return t._parse=function(e,t){laya.d3.core.Sprite3D.prototype._parse.call(this,e,t);var n=this.meshRenderer,i=e.lightmapIndex;null!=i&&(n.lightmapIndex=i);var r=e.lightmapScaleOffset;r&&(n.lightmapScaleOffset=new Dt(r[0],r[1],r[2],r[3])),null!=e.meshPath&&(this.meshFilter.sharedMesh=g.getRes(e.meshPath)),null!=e.enableRender&&(this.meshRenderer.enable=e.enableRender);var a=e.materials;if(a){var o=n.sharedMaterials,s=a.length;o.length=s;for(var l=0;lthis._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount plus lines count must less than maxLineCount.";this._geometryFilter._updateLineDatas(t,e),this._geometryFilter._lineCount+=n},t.removeLine=function(e){if(!(ethis.maxLineCount)throw"PixelLineSprite3D: lineCount can't large than maxLineCount";this._geometryFilter._lineCount=e}),PixelLineSprite3D}(),Di=function(e){function DirectionLight(){this._direction=null,DirectionLight.__super.call(this),this._direction=new Rt}r(DirectionLight,"laya.d3.core.light.DirectionLight",e);var t=DirectionLight.prototype;return t._initShadow=function(){if(this._shadow)this._parallelSplitShadowMap=new Fe,this.scene.parallelSplitShadowMaps.push(this._parallelSplitShadowMap),this.transform.worldMatrix.getForward(this._direction),Rt.normalize(this._direction,this._direction),this._parallelSplitShadowMap.setInfo(this.scene,this._shadowFarPlane,this._direction,this._shadowMapSize,this._shadowMapCount,this._shadowMapPCFType);else{var e=this._scene._defineDatas,t=this.scene.parallelSplitShadowMaps;t.splice(t.indexOf(this._parallelSplitShadowMap),1),this._parallelSplitShadowMap.disposeAllRenderTarget(),this._parallelSplitShadowMap=null,e.remove(qn.SHADERDEFINE_SHADOW_PSSM1),e.remove(qn.SHADERDEFINE_SHADOW_PSSM2),e.remove(qn.SHADERDEFINE_SHADOW_PSSM3)}},t._onActive=function(){e.prototype._onActive.call(this),this._shadow&&this._initShadow(),this._lightmapBakedType!==ti.LIGHTMAPBAKEDTYPE_BAKED&&this._scene._defineDatas.add(qn.SHADERDEFINE_DIRECTIONLIGHT)},t._onInActive=function(){e.prototype._onInActive.call(this),this._lightmapBakedType!==ti.LIGHTMAPBAKEDTYPE_BAKED&&this._scene._defineDatas.remove(qn.SHADERDEFINE_DIRECTIONLIGHT)},t._prepareToScene=function(){var e=this._scene;if(e.enableLight&&this.activeInHierarchy){e._defineDatas;var t=e._shaderValues;return Rt.scale(this.color,this._intensity,this._intensityColor),t.setVector3(qn.LIGHTDIRCOLOR,this._intensityColor),this.transform.worldMatrix.getForward(this._direction),Rt.normalize(this._direction,this._direction),t.setVector3(qn.LIGHTDIRECTION,this._direction),!0}return!1},a(0,t,"shadow",e.prototype._$get_shadow,function(e){this._shadow!==e&&(this._shadow=e,this.scene&&this._initShadow())}),DirectionLight}(ti),Ri=function(e){function ShuriKenParticle3D(){ShuriKenParticle3D.__super.call(this,null),this._render=new Zn(this),this._particleSystem=new yn(this);var e=this._render._renderElements[0]=new lt;e.setTransform(this._transform),e.render=this._render,e.setGeometry(this._particleSystem),e.material=ci.defaultMaterial}r(ShuriKenParticle3D,"laya.d3.core.particleShuriKen.ShuriKenParticle3D",e);var t=ShuriKenParticle3D.prototype;return t._initParticleVelocity=function(e){for(var t=new Oe,n=e.velocitys,i=0,r=n.length;i=.5?Math.floor(i):s,d=l-r>=.5?Math.floor(r):l,_=a-h>=.5?Math.ceil(a):h,f=o-u>=.5?Math.ceil(o):u;this._viewport.x=c,this._viewport.y=d,this._viewport.width=_-c,this._viewport.height=f-d},t._parse=function(t,n){e.prototype._parse.call(this,t,n);var i=t.viewport;this.normalizedViewport=new tt(i[0],i[1],i[2],i[3])},t._calculateProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=this.orthographicVerticalSize*this.aspectRatio*.5,t=.5*this.orthographicVerticalSize;Q.createOrthoOffCenter(-e,e,-t,t,this.nearPlane,this.farPlane,this._projectionMatrix)}else Q.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix)},t._getCanvasHeight=function(){return this._offScreenRenderTexture?this._offScreenRenderTexture.height:Ze.clientHeight},t._applyPostProcessCommandBuffers=function(){for(var e=0,t=this._postProcessCommandBuffers.length;e