!function(exports,Laya){"use strict";class MathUtils3D{constructor(){}static isZero(v){return Math.abs(v)0&&(len=1/Math.sqrt(len),out.x=x*len,out.y=y*len)}static scalarLength(a){var x=a.x,y=a.y;return Math.sqrt(x*x+y*y)}clone(){var destVector2=new Vector2;return this.cloneTo(destVector2),destVector2}forNativeElement(nativeElements=null){nativeElements?(this.elements=nativeElements,this.elements[0]=this.x,this.elements[1]=this.y):this.elements=new Float32Array([this.x,this.y]),Vector2.rewriteNumProperty(this,"x",0),Vector2.rewriteNumProperty(this,"y",1)}static rewriteNumProperty(proto,name,index){Object.defineProperty(proto,name,{get:function(){return this.elements[index]},set:function(v){this.elements[index]=v}})}}Vector2.ZERO=new Vector2(0,0),Vector2.ONE=new Vector2(1,1);class Vector4{constructor(x=0,y=0,z=0,w=0){this.x=x,this.y=y,this.z=z,this.w=w}setValue(x,y,z,w){this.x=x,this.y=y,this.z=z,this.w=w}fromArray(array,offset=0){this.x=array[offset+0],this.y=array[offset+1],this.z=array[offset+2],this.w=array[offset+3]}cloneTo(destObject){var destVector4=destObject;destVector4.x=this.x,destVector4.y=this.y,destVector4.z=this.z,destVector4.w=this.w}clone(){var destVector4=new Vector4;return this.cloneTo(destVector4),destVector4}static lerp(a,b,t,out){var ax=a.x,ay=a.y,az=a.z,aw=a.w;out.x=ax+t*(b.x-ax),out.y=ay+t*(b.y-ay),out.z=az+t*(b.z-az),out.w=aw+t*(b.w-aw)}static transformByM4x4(vector4,m4x4,out){var vx=vector4.x,vy=vector4.y,vz=vector4.z,vw=vector4.w,me=m4x4.elements;out.x=vx*me[0]+vy*me[4]+vz*me[8]+vw*me[12],out.y=vx*me[1]+vy*me[5]+vz*me[9]+vw*me[13],out.z=vx*me[2]+vy*me[6]+vz*me[10]+vw*me[14],out.w=vx*me[3]+vy*me[7]+vz*me[11]+vw*me[15]}static equals(a,b){return MathUtils3D.nearEqual(Math.abs(a.x),Math.abs(b.x))&&MathUtils3D.nearEqual(Math.abs(a.y),Math.abs(b.y))&&MathUtils3D.nearEqual(Math.abs(a.z),Math.abs(b.z))&&MathUtils3D.nearEqual(Math.abs(a.w),Math.abs(b.w))}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static normalize(s,out){var len=s.length();len>0&&(out.x=s.x*len,out.y=s.y*len,out.z=s.z*len,out.w=s.w*len)}static add(a,b,out){out.x=a.x+b.x,out.y=a.y+b.y,out.z=a.z+b.z,out.w=a.w+b.w}static subtract(a,b,out){out.x=a.x-b.x,out.y=a.y-b.y,out.z=a.z-b.z,out.w=a.w-b.w}static multiply(a,b,out){out.x=a.x*b.x,out.y=a.y*b.y,out.z=a.z*b.z,out.w=a.w*b.w}static scale(a,b,out){out.x=a.x*b,out.y=a.y*b,out.z=a.z*b,out.w=a.w*b}static Clamp(value,min,max,out){var x=value.x,y=value.y,z=value.z,w=value.w,mineX=min.x,mineY=min.y,mineZ=min.z,mineW=min.w,maxeX=max.x,maxeY=max.y,maxeZ=max.z,maxeW=max.w;x=(x=x>maxeX?maxeX:x)maxeY?maxeY:y)maxeZ?maxeZ:z)maxeW?maxeW:w)0&&(len=1/Math.sqrt(len),out.x=s.x*len,out.y=s.y*len,out.z=s.z*len)}static multiply(a,b,out){out.x=a.x*b.x,out.y=a.y*b.y,out.z=a.z*b.z}static scale(a,b,out){out.x=a.x*b,out.y=a.y*b,out.z=a.z*b}static lerp(a,b,t,out){var ax=a.x,ay=a.y,az=a.z;out.x=ax+t*(b.x-ax),out.y=ay+t*(b.y-ay),out.z=az+t*(b.z-az)}static transformV3ToV3(vector,transform,result){var intermediate=Vector3._tempVector4;Vector3.transformV3ToV4(vector,transform,intermediate),result.x=intermediate.x,result.y=intermediate.y,result.z=intermediate.z}static transformV3ToV4(vector,transform,result){var vectorX=vector.x,vectorY=vector.y,vectorZ=vector.z,transformElem=transform.elements;result.x=vectorX*transformElem[0]+vectorY*transformElem[4]+vectorZ*transformElem[8]+transformElem[12],result.y=vectorX*transformElem[1]+vectorY*transformElem[5]+vectorZ*transformElem[9]+transformElem[13],result.z=vectorX*transformElem[2]+vectorY*transformElem[6]+vectorZ*transformElem[10]+transformElem[14],result.w=vectorX*transformElem[3]+vectorY*transformElem[7]+vectorZ*transformElem[11]+transformElem[15]}static TransformNormal(normal,transform,result){var normalX=normal.x,normalY=normal.y,normalZ=normal.z,transformElem=transform.elements;result.x=normalX*transformElem[0]+normalY*transformElem[4]+normalZ*transformElem[8],result.y=normalX*transformElem[1]+normalY*transformElem[5]+normalZ*transformElem[9],result.z=normalX*transformElem[2]+normalY*transformElem[6]+normalZ*transformElem[10]}static transformCoordinate(coordinate,transform,result){var coordinateX=coordinate.x,coordinateY=coordinate.y,coordinateZ=coordinate.z,transformElem=transform.elements,w=coordinateX*transformElem[3]+coordinateY*transformElem[7]+coordinateZ*transformElem[11]+transformElem[15];result.x=coordinateX*transformElem[0]+coordinateY*transformElem[4]+coordinateZ*transformElem[8]+transformElem[12]/w,result.y=coordinateX*transformElem[1]+coordinateY*transformElem[5]+coordinateZ*transformElem[9]+transformElem[13]/w,result.z=coordinateX*transformElem[2]+coordinateY*transformElem[6]+coordinateZ*transformElem[10]+transformElem[14]/w}static Clamp(value,min,max,out){var x=value.x,y=value.y,z=value.z,mineX=min.x,mineY=min.y,mineZ=min.z,maxeX=max.x,maxeY=max.y,maxeZ=max.z;x=(x=x>maxeX?maxeX:x)maxeY?maxeY:y)maxeZ?maxeZ:z)maxLength&&(dataCount=maxLength);for(var i=0;i0?Math.atan(y/x):x<0?y>0?Math.atan(y/x)+Math.PI:Math.atan(y/x)-Math.PI:0}static angleTo(from,location,angle){Vector3.subtract(location,from,Quaternion.TEMPVector30),Vector3.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30),angle.x=Math.asin(Quaternion.TEMPVector30.y),angle.y=Quaternion.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x)}static createFromAxisAngle(axis,rad,out){rad*=.5;var s=Math.sin(rad);out.x=s*axis.x,out.y=s*axis.y,out.z=s*axis.z,out.w=Math.cos(rad)}static createFromMatrix4x4(mat,out){var sqrt,half,me=mat.elements,scale=me[0]+me[5]+me[10];scale>0?(sqrt=Math.sqrt(scale+1),out.w=.5*sqrt,sqrt=.5/sqrt,out.x=(me[6]-me[9])*sqrt,out.y=(me[8]-me[2])*sqrt,out.z=(me[1]-me[4])*sqrt):me[0]>=me[5]&&me[0]>=me[10]?(half=.5/(sqrt=Math.sqrt(1+me[0]-me[5]-me[10])),out.x=.5*sqrt,out.y=(me[1]+me[4])*half,out.z=(me[2]+me[8])*half,out.w=(me[6]-me[9])*half):me[5]>me[10]?(half=.5/(sqrt=Math.sqrt(1+me[5]-me[0]-me[10])),out.x=(me[4]+me[1])*half,out.y=.5*sqrt,out.z=(me[9]+me[6])*half,out.w=(me[8]-me[2])*half):(half=.5/(sqrt=Math.sqrt(1+me[10]-me[0]-me[5])),out.x=(me[8]+me[2])*half,out.y=(me[9]+me[6])*half,out.z=.5*sqrt,out.w=(me[1]-me[4])*half)}static slerp(left,right,t,out){var omega,cosom,sinom,scale0,scale1,ax=left.x,ay=left.y,az=left.z,aw=left.w,bx=right.x,by=right.y,bz=right.z,bw=right.w;return(cosom=ax*bx+ay*by+az*bz+aw*bw)<0&&(cosom=-cosom,bx=-bx,by=-by,bz=-bz,bw=-bw),1-cosom>1e-6?(omega=Math.acos(cosom),sinom=Math.sin(omega),scale0=Math.sin((1-t)*omega)/sinom,scale1=Math.sin(t*omega)/sinom):(scale0=1-t,scale1=t),out.x=scale0*ax+scale1*bx,out.y=scale0*ay+scale1*by,out.z=scale0*az+scale1*bz,out.w=scale0*aw+scale1*bw,out}static lerp(left,right,amount,out){var inverse=1-amount;Quaternion.dot(left,right)>=0?(out.x=inverse*left.x+amount*right.x,out.y=inverse*left.y+amount*right.y,out.z=inverse*left.z+amount*right.z,out.w=inverse*left.w+amount*right.w):(out.x=inverse*left.x-amount*right.x,out.y=inverse*left.y-amount*right.y,out.z=inverse*left.z-amount*right.z,out.w=inverse*left.w-amount*right.w),out.normalize(out)}static add(left,right,out){out.x=left.x+right.x,out.y=left.y+right.y,out.z=left.z+right.z,out.w=left.w+right.w}static dot(left,right){return left.x*right.x+left.y*right.y+left.z*right.z+left.w*right.w}scaling(scaling,out){out.x=this.x*scaling,out.y=this.y*scaling,out.z=this.z*scaling,out.w=this.w*scaling}normalize(out){var len=this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w;len>0&&(len=1/Math.sqrt(len),out.x=this.x*len,out.y=this.y*len,out.z=this.z*len,out.w=this.w*len)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}rotateX(rad,out){rad*=.5;var bx=Math.sin(rad),bw=Math.cos(rad);out.x=this.x*bw+this.w*bx,out.y=this.y*bw+this.z*bx,out.z=this.z*bw-this.y*bx,out.w=this.w*bw-this.x*bx}rotateY(rad,out){rad*=.5;var by=Math.sin(rad),bw=Math.cos(rad);out.x=this.x*bw-this.z*by,out.y=this.y*bw+this.w*by,out.z=this.z*bw+this.x*by,out.w=this.w*bw-this.y*by}rotateZ(rad,out){rad*=.5;var bz=Math.sin(rad),bw=Math.cos(rad);out.x=this.x*bw+this.y*bz,out.y=this.y*bw-this.x*bz,out.z=this.z*bw+this.w*bz,out.w=this.w*bw-this.z*bz}getYawPitchRoll(out){Vector3.transformQuat(Vector3._ForwardRH,this,Quaternion.TEMPVector31),Vector3.transformQuat(Vector3._Up,this,Quaternion.TEMPVector32);var upe=Quaternion.TEMPVector32;Quaternion.angleTo(Vector3._ZERO,Quaternion.TEMPVector31,Quaternion.TEMPVector33);var angle=Quaternion.TEMPVector33;angle.x==Math.PI/2?(angle.y=Quaternion.arcTanAngle(upe.z,upe.x),angle.z=0):angle.x==-Math.PI/2?(angle.y=Quaternion.arcTanAngle(-upe.z,-upe.x),angle.z=0):(ILaya3D.Matrix4x4.createRotationY(-angle.y,ILaya3D.Matrix4x4.TEMPMatrix0),ILaya3D.Matrix4x4.createRotationX(-angle.x,ILaya3D.Matrix4x4.TEMPMatrix1),Vector3.transformCoordinate(Quaternion.TEMPVector32,ILaya3D.Matrix4x4.TEMPMatrix0,Quaternion.TEMPVector32),Vector3.transformCoordinate(Quaternion.TEMPVector32,ILaya3D.Matrix4x4.TEMPMatrix1,Quaternion.TEMPVector32),angle.z=Quaternion.arcTanAngle(upe.y,-upe.x)),angle.y<=-Math.PI&&(angle.y=Math.PI),angle.z<=-Math.PI&&(angle.z=Math.PI),angle.y>=Math.PI&&angle.z>=Math.PI&&(angle.y=0,angle.z=0,angle.x=Math.PI-angle.x);var oe=out;oe.x=angle.y,oe.y=angle.x,oe.z=angle.z}invert(out){var a0=this.x,a1=this.y,a2=this.z,a3=this.w,dot=a0*a0+a1*a1+a2*a2+a3*a3,invDot=dot?1/dot:0;out.x=-a0*invDot,out.y=-a1*invDot,out.z=-a2*invDot,out.w=a3*invDot}identity(){this.x=0,this.y=0,this.z=0,this.w=1}fromArray(array,offset=0){this.x=array[offset+0],this.y=array[offset+1],this.z=array[offset+2],this.w=array[offset+3]}cloneTo(destObject){this!==destObject&&(destObject.x=this.x,destObject.y=this.y,destObject.z=this.z,destObject.w=this.w)}clone(){var dest=new Quaternion;return this.cloneTo(dest),dest}equals(b){return MathUtils3D.nearEqual(this.x,b.x)&&MathUtils3D.nearEqual(this.y,b.y)&&MathUtils3D.nearEqual(this.z,b.z)&&MathUtils3D.nearEqual(this.w,b.w)}static rotationLookAt(forward,up,out){Quaternion.lookAt(Vector3._ZERO,forward,up,out)}static lookAt(eye,target,up,out){Matrix3x3.lookAt(eye,target,up,Quaternion._tempMatrix3x3),Quaternion.rotationMatrix(Quaternion._tempMatrix3x3,out)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static invert(value,out){var lengthSq=value.lengthSquared();MathUtils3D.isZero(lengthSq)||(lengthSq=1/lengthSq,out.x=-value.x*lengthSq,out.y=-value.y*lengthSq,out.z=-value.z*lengthSq,out.w=value.w*lengthSq)}static rotationMatrix(matrix3x3,out){var sqrt,half,me=matrix3x3.elements,m11=me[0],m12=me[1],m13=me[2],m21=me[3],m22=me[4],m23=me[5],m31=me[6],m32=me[7],m33=me[8],scale=m11+m22+m33;scale>0?(sqrt=Math.sqrt(scale+1),out.w=.5*sqrt,sqrt=.5/sqrt,out.x=(m23-m32)*sqrt,out.y=(m31-m13)*sqrt,out.z=(m12-m21)*sqrt):m11>=m22&&m11>=m33?(half=.5/(sqrt=Math.sqrt(1+m11-m22-m33)),out.x=.5*sqrt,out.y=(m12+m21)*half,out.z=(m13+m31)*half,out.w=(m23-m32)*half):m22>m33?(half=.5/(sqrt=Math.sqrt(1+m22-m11-m33)),out.x=(m21+m12)*half,out.y=.5*sqrt,out.z=(m32+m23)*half,out.w=(m31-m13)*half):(half=.5/(sqrt=Math.sqrt(1+m33-m11-m22)),out.x=(m31+m13)*half,out.y=(m32+m23)*half,out.z=.5*sqrt,out.w=(m12-m21)*half)}forNativeElement(nativeElements=null){nativeElements?(this.elements=nativeElements,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]),Vector2.rewriteNumProperty(this,"x",0),Vector2.rewriteNumProperty(this,"y",1),Vector2.rewriteNumProperty(this,"z",2),Vector2.rewriteNumProperty(this,"w",3)}}Quaternion.TEMPVector30=new Vector3,Quaternion.TEMPVector31=new Vector3,Quaternion.TEMPVector32=new Vector3,Quaternion.TEMPVector33=new Vector3,Quaternion._tempMatrix3x3=new Matrix3x3,Quaternion.DEFAULT=new Quaternion,Quaternion.NAN=new Quaternion(NaN,NaN,NaN,NaN);class Matrix4x4{constructor(m11=1,m12=0,m13=0,m14=0,m21=0,m22=1,m23=0,m24=0,m31=0,m32=0,m33=1,m34=0,m41=0,m42=0,m43=0,m44=1,elements=null){var e=this.elements=elements||new Float32Array(16);e[0]=m11,e[1]=m12,e[2]=m13,e[3]=m14,e[4]=m21,e[5]=m22,e[6]=m23,e[7]=m24,e[8]=m31,e[9]=m32,e[10]=m33,e[11]=m34,e[12]=m41,e[13]=m42,e[14]=m43,e[15]=m44}static createRotationX(rad,out){var oe=out.elements,s=Math.sin(rad),c=Math.cos(rad);oe[1]=oe[2]=oe[3]=oe[4]=oe[7]=oe[8]=oe[11]=oe[12]=oe[13]=oe[14]=0,oe[0]=oe[15]=1,oe[5]=oe[10]=c,oe[6]=s,oe[9]=-s}static createRotationY(rad,out){var oe=out.elements,s=Math.sin(rad),c=Math.cos(rad);oe[1]=oe[3]=oe[4]=oe[6]=oe[7]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0,oe[5]=oe[15]=1,oe[0]=oe[10]=c,oe[2]=-s,oe[8]=s}static createRotationZ(rad,out){var oe=out.elements,s=Math.sin(rad),c=Math.cos(rad);oe[2]=oe[3]=oe[6]=oe[7]=oe[8]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0,oe[10]=oe[15]=1,oe[0]=oe[5]=c,oe[1]=s,oe[4]=-s}static createRotationYawPitchRoll(yaw,pitch,roll,result){Quaternion.createFromYawPitchRoll(yaw,pitch,roll,Matrix4x4._tempQuaternion),Matrix4x4.createRotationQuaternion(Matrix4x4._tempQuaternion,result)}static createRotationAxis(axis,angle,result){var x=axis.x,y=axis.y,z=axis.z,cos=Math.cos(angle),sin=Math.sin(angle),xx=x*x,yy=y*y,zz=z*z,xy=x*y,xz=x*z,yz=y*z,resultE=result.elements;resultE[3]=resultE[7]=resultE[11]=resultE[12]=resultE[13]=resultE[14]=0,resultE[15]=1,resultE[0]=xx+cos*(1-xx),resultE[1]=xy-cos*xy+sin*z,resultE[2]=xz-cos*xz-sin*y,resultE[4]=xy-cos*xy-sin*z,resultE[5]=yy+cos*(1-yy),resultE[6]=yz-cos*yz+sin*x,resultE[8]=xz-cos*xz+sin*y,resultE[9]=yz-cos*yz-sin*x,resultE[10]=zz+cos*(1-zz)}setRotation(rotation){var rotationX=rotation.x,rotationY=rotation.y,rotationZ=rotation.z,rotationW=rotation.w,xx=rotationX*rotationX,yy=rotationY*rotationY,zz=rotationZ*rotationZ,xy=rotationX*rotationY,zw=rotationZ*rotationW,zx=rotationZ*rotationX,yw=rotationY*rotationW,yz=rotationY*rotationZ,xw=rotationX*rotationW,e=this.elements;e[0]=1-2*(yy+zz),e[1]=2*(xy+zw),e[2]=2*(zx-yw),e[4]=2*(xy-zw),e[5]=1-2*(zz+xx),e[6]=2*(yz+xw),e[8]=2*(zx+yw),e[9]=2*(yz-xw),e[10]=1-2*(yy+xx)}setPosition(position){var e=this.elements;e[12]=position.x,e[13]=position.y,e[14]=position.z}static createRotationQuaternion(rotation,result){var resultE=result.elements,rotationX=rotation.x,rotationY=rotation.y,rotationZ=rotation.z,rotationW=rotation.w,xx=rotationX*rotationX,yy=rotationY*rotationY,zz=rotationZ*rotationZ,xy=rotationX*rotationY,zw=rotationZ*rotationW,zx=rotationZ*rotationX,yw=rotationY*rotationW,yz=rotationY*rotationZ,xw=rotationX*rotationW;resultE[3]=resultE[7]=resultE[11]=resultE[12]=resultE[13]=resultE[14]=0,resultE[15]=1,resultE[0]=1-2*(yy+zz),resultE[1]=2*(xy+zw),resultE[2]=2*(zx-yw),resultE[4]=2*(xy-zw),resultE[5]=1-2*(zz+xx),resultE[6]=2*(yz+xw),resultE[8]=2*(zx+yw),resultE[9]=2*(yz-xw),resultE[10]=1-2*(yy+xx)}static createTranslate(trans,out){var oe=out.elements;oe[4]=oe[8]=oe[1]=oe[9]=oe[2]=oe[6]=oe[3]=oe[7]=oe[11]=0,oe[0]=oe[5]=oe[10]=oe[15]=1,oe[12]=trans.x,oe[13]=trans.y,oe[14]=trans.z}static createScaling(scale,out){var oe=out.elements;oe[0]=scale.x,oe[5]=scale.y,oe[10]=scale.z,oe[1]=oe[4]=oe[8]=oe[12]=oe[9]=oe[13]=oe[2]=oe[6]=oe[14]=oe[3]=oe[7]=oe[11]=0,oe[15]=1}static multiply(left,right,out){var l=right.elements,r=left.elements,e=out.elements,l11=l[0],l12=l[1],l13=l[2],l14=l[3],l21=l[4],l22=l[5],l23=l[6],l24=l[7],l31=l[8],l32=l[9],l33=l[10],l34=l[11],l41=l[12],l42=l[13],l43=l[14],l44=l[15],r11=r[0],r12=r[1],r13=r[2],r14=r[3],r21=r[4],r22=r[5],r23=r[6],r24=r[7],r31=r[8],r32=r[9],r33=r[10],r34=r[11],r41=r[12],r42=r[13],r43=r[14],r44=r[15];e[0]=l11*r11+l12*r21+l13*r31+l14*r41,e[1]=l11*r12+l12*r22+l13*r32+l14*r42,e[2]=l11*r13+l12*r23+l13*r33+l14*r43,e[3]=l11*r14+l12*r24+l13*r34+l14*r44,e[4]=l21*r11+l22*r21+l23*r31+l24*r41,e[5]=l21*r12+l22*r22+l23*r32+l24*r42,e[6]=l21*r13+l22*r23+l23*r33+l24*r43,e[7]=l21*r14+l22*r24+l23*r34+l24*r44,e[8]=l31*r11+l32*r21+l33*r31+l34*r41,e[9]=l31*r12+l32*r22+l33*r32+l34*r42,e[10]=l31*r13+l32*r23+l33*r33+l34*r43,e[11]=l31*r14+l32*r24+l33*r34+l34*r44,e[12]=l41*r11+l42*r21+l43*r31+l44*r41,e[13]=l41*r12+l42*r22+l43*r32+l44*r42,e[14]=l41*r13+l42*r23+l43*r33+l44*r43,e[15]=l41*r14+l42*r24+l43*r34+l44*r44}static multiplyForNative(left,right,out){Laya.LayaGL.instance.matrix4x4Multiply(left.elements,right.elements,out.elements)}static createFromQuaternion(rotation,out){var e=out.elements,x=rotation.x,y=rotation.y,z=rotation.z,w=rotation.w,x2=x+x,y2=y+y,z2=z+z,xx=x*x2,yx=y*x2,yy=y*y2,zx=z*x2,zy=z*y2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;e[0]=1-yy-zz,e[1]=yx+wz,e[2]=zx-wy,e[3]=0,e[4]=yx-wz,e[5]=1-xx-zz,e[6]=zy+wx,e[7]=0,e[8]=zx+wy,e[9]=zy-wx,e[10]=1-xx-yy,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}static createAffineTransformation(trans,rot,scale,out){var oe=out.elements,x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2,sx=scale.x,sy=scale.y,sz=scale.z;oe[0]=(1-(yy+zz))*sx,oe[1]=(xy+wz)*sx,oe[2]=(xz-wy)*sx,oe[3]=0,oe[4]=(xy-wz)*sy,oe[5]=(1-(xx+zz))*sy,oe[6]=(yz+wx)*sy,oe[7]=0,oe[8]=(xz+wy)*sz,oe[9]=(yz-wx)*sz,oe[10]=(1-(xx+yy))*sz,oe[11]=0,oe[12]=trans.x,oe[13]=trans.y,oe[14]=trans.z,oe[15]=1}static createLookAt(eye,target,up,out){var oE=out.elements,xaxis=Matrix4x4._tempVector0,yaxis=Matrix4x4._tempVector1,zaxis=Matrix4x4._tempVector2;Vector3.subtract(eye,target,zaxis),Vector3.normalize(zaxis,zaxis),Vector3.cross(up,zaxis,xaxis),Vector3.normalize(xaxis,xaxis),Vector3.cross(zaxis,xaxis,yaxis),out.identity(),oE[0]=xaxis.x,oE[4]=xaxis.y,oE[8]=xaxis.z,oE[1]=yaxis.x,oE[5]=yaxis.y,oE[9]=yaxis.z,oE[2]=zaxis.x,oE[6]=zaxis.y,oE[10]=zaxis.z,oE[12]=-Vector3.dot(xaxis,eye),oE[13]=-Vector3.dot(yaxis,eye),oE[14]=-Vector3.dot(zaxis,eye)}static createPerspective(fov,aspect,znear,zfar,out){var yScale=1/Math.tan(.5*fov),halfWidth=znear/(yScale/aspect),halfHeight=znear/yScale;Matrix4x4.createPerspectiveOffCenter(-halfWidth,halfWidth,-halfHeight,halfHeight,znear,zfar,out)}static createPerspectiveOffCenter(left,right,bottom,top,znear,zfar,out){var oe=out.elements,zRange=zfar/(zfar-znear);oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[7]=oe[12]=oe[13]=oe[15]=0,oe[0]=2*znear/(right-left),oe[5]=2*znear/(top-bottom),oe[8]=(left+right)/(right-left),oe[9]=(top+bottom)/(top-bottom),oe[10]=-zRange,oe[11]=-1,oe[14]=-znear*zRange}static createOrthoOffCenter(left,right,bottom,top,znear,zfar,out){var oe=out.elements,zRange=1/(zfar-znear);oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[8]=oe[7]=oe[9]=oe[11]=0,oe[15]=1,oe[0]=2/(right-left),oe[5]=2/(top-bottom),oe[10]=-zRange,oe[12]=(left+right)/(left-right),oe[13]=(top+bottom)/(bottom-top),oe[14]=-znear*zRange}getElementByRowColumn(row,column){if(row<0||row>3)throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");if(column<0||column>3)throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");return this.elements[4*row+column]}setElementByRowColumn(row,column,value){if(row<0||row>3)throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");if(column<0||column>3)throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");this.elements[4*row+column]=value}equalsOtherMatrix(other){var e=this.elements,oe=other.elements;return MathUtils3D.nearEqual(e[0],oe[0])&&MathUtils3D.nearEqual(e[1],oe[1])&&MathUtils3D.nearEqual(e[2],oe[2])&&MathUtils3D.nearEqual(e[3],oe[3])&&MathUtils3D.nearEqual(e[4],oe[4])&&MathUtils3D.nearEqual(e[5],oe[5])&&MathUtils3D.nearEqual(e[6],oe[6])&&MathUtils3D.nearEqual(e[7],oe[7])&&MathUtils3D.nearEqual(e[8],oe[8])&&MathUtils3D.nearEqual(e[9],oe[9])&&MathUtils3D.nearEqual(e[10],oe[10])&&MathUtils3D.nearEqual(e[11],oe[11])&&MathUtils3D.nearEqual(e[12],oe[12])&&MathUtils3D.nearEqual(e[13],oe[13])&&MathUtils3D.nearEqual(e[14],oe[14])&&MathUtils3D.nearEqual(e[15],oe[15])}decomposeTransRotScale(translation,rotation,scale){var rotationMatrix=Matrix4x4._tempMatrix4x4;return this.decomposeTransRotMatScale(translation,rotationMatrix,scale)?(Quaternion.createFromMatrix4x4(rotationMatrix,rotation),!0):(rotation.identity(),!1)}decomposeTransRotMatScale(translation,rotationMatrix,scale){var e=this.elements,te=translation,re=rotationMatrix.elements,se=scale;te.x=e[12],te.y=e[13],te.z=e[14];var m11=e[0],m12=e[1],m13=e[2],m21=e[4],m22=e[5],m23=e[6],m31=e[8],m32=e[9],m33=e[10],sX=se.x=Math.sqrt(m11*m11+m12*m12+m13*m13),sY=se.y=Math.sqrt(m21*m21+m22*m22+m23*m23),sZ=se.z=Math.sqrt(m31*m31+m32*m32+m33*m33);if(MathUtils3D.isZero(sX)||MathUtils3D.isZero(sY)||MathUtils3D.isZero(sZ))return re[1]=re[2]=re[3]=re[4]=re[6]=re[7]=re[8]=re[9]=re[11]=re[12]=re[13]=re[14]=0,re[0]=re[5]=re[10]=re[15]=1,!1;var at=Matrix4x4._tempVector0;at.x=m31/sZ,at.y=m32/sZ,at.z=m33/sZ;var tempRight=Matrix4x4._tempVector1;tempRight.x=m11/sX,tempRight.y=m12/sX,tempRight.z=m13/sX;var up=Matrix4x4._tempVector2;Vector3.cross(at,tempRight,up);var right=Matrix4x4._tempVector1;return Vector3.cross(up,at,right),re[3]=re[7]=re[11]=re[12]=re[13]=re[14]=0,re[15]=1,re[0]=right.x,re[1]=right.y,re[2]=right.z,re[4]=up.x,re[5]=up.y,re[6]=up.z,re[8]=at.x,re[9]=at.y,re[10]=at.z,re[0]*m11+re[1]*m12+re[2]*m13<0&&(se.x=-sX),re[4]*m21+re[5]*m22+re[6]*m23<0&&(se.y=-sY),re[8]*m31+re[9]*m32+re[10]*m33<0&&(se.z=-sZ),!0}decomposeYawPitchRoll(yawPitchRoll){var pitch=Math.asin(-this.elements[9]);yawPitchRoll.y=pitch,Math.cos(pitch)>MathUtils3D.zeroTolerance?(yawPitchRoll.z=Math.atan2(this.elements[1],this.elements[5]),yawPitchRoll.x=Math.atan2(this.elements[8],this.elements[10])):(yawPitchRoll.z=Math.atan2(-this.elements[4],this.elements[0]),yawPitchRoll.x=0)}normalize(){var v=this.elements,c=v[0],d=v[1],e=v[2],g=Math.sqrt(c*c+d*d+e*e);if(!g)return v[0]=0,v[1]=0,void(v[2]=0);1!=g&&(g=1/g,v[0]=c*g,v[1]=d*g,v[2]=e*g)}transpose(){var e,t;return t=(e=this.elements)[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}invert(out){var ae=this.elements,oe=out.elements,a00=ae[0],a01=ae[1],a02=ae[2],a03=ae[3],a10=ae[4],a11=ae[5],a12=ae[6],a13=ae[7],a20=ae[8],a21=ae[9],a22=ae[10],a23=ae[11],a30=ae[12],a31=ae[13],a32=ae[14],a33=ae[15],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;0!==Math.abs(det)&&(det=1/det,oe[0]=(a11*b11-a12*b10+a13*b09)*det,oe[1]=(a02*b10-a01*b11-a03*b09)*det,oe[2]=(a31*b05-a32*b04+a33*b03)*det,oe[3]=(a22*b04-a21*b05-a23*b03)*det,oe[4]=(a12*b08-a10*b11-a13*b07)*det,oe[5]=(a00*b11-a02*b08+a03*b07)*det,oe[6]=(a32*b02-a30*b05-a33*b01)*det,oe[7]=(a20*b05-a22*b02+a23*b01)*det,oe[8]=(a10*b10-a11*b08+a13*b06)*det,oe[9]=(a01*b08-a00*b10-a03*b06)*det,oe[10]=(a30*b04-a31*b02+a33*b00)*det,oe[11]=(a21*b02-a20*b04-a23*b00)*det,oe[12]=(a11*b07-a10*b09-a12*b06)*det,oe[13]=(a00*b09-a01*b07+a02*b06)*det,oe[14]=(a31*b01-a30*b03-a32*b00)*det,oe[15]=(a20*b03-a21*b01+a22*b00)*det)}static billboard(objectPosition,cameraPosition,cameraRight,cameraUp,cameraForward,mat){Vector3.subtract(objectPosition,cameraPosition,Matrix4x4._tempVector0);var lengthSq=Vector3.scalarLengthSquared(Matrix4x4._tempVector0);MathUtils3D.isZero(lengthSq)?(Vector3.scale(cameraForward,-1,Matrix4x4._tempVector1),Matrix4x4._tempVector1.cloneTo(Matrix4x4._tempVector0)):Vector3.scale(Matrix4x4._tempVector0,1/Math.sqrt(lengthSq),Matrix4x4._tempVector0),Vector3.cross(cameraUp,Matrix4x4._tempVector0,Matrix4x4._tempVector2),Vector3.normalize(Matrix4x4._tempVector2,Matrix4x4._tempVector2),Vector3.cross(Matrix4x4._tempVector0,Matrix4x4._tempVector2,Matrix4x4._tempVector3);var crosse=Matrix4x4._tempVector2,finale=Matrix4x4._tempVector3,diffee=Matrix4x4._tempVector0,obpose=objectPosition,mate=mat.elements;mate[0]=crosse.x,mate[1]=crosse.y,mate[2]=crosse.z,mate[3]=0,mate[4]=finale.x,mate[5]=finale.y,mate[6]=finale.z,mate[7]=0,mate[8]=diffee.x,mate[9]=diffee.y,mate[10]=diffee.z,mate[11]=0,mate[12]=obpose.x,mate[13]=obpose.y,mate[14]=obpose.z,mate[15]=1}identity(){var e=this.elements;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1}cloneTo(destObject){var i,s,d;if((s=this.elements)!==(d=destObject.elements))for(i=0;i<16;++i)d[i]=s[i]}clone(){var dest=new Matrix4x4;return this.cloneTo(dest),dest}static translation(v3,out){var oe=out.elements;oe[0]=oe[5]=oe[10]=oe[15]=1,oe[12]=v3.x,oe[13]=v3.y,oe[14]=v3.z}getTranslationVector(out){var me=this.elements;out.x=me[12],out.y=me[13],out.z=me[14]}setTranslationVector(translate){var me=this.elements,ve=translate;me[12]=ve.x,me[13]=ve.y,me[14]=ve.z}getForward(out){var me=this.elements;out.x=-me[8],out.y=-me[9],out.z=-me[10]}setForward(forward){var me=this.elements;me[8]=-forward.x,me[9]=-forward.y,me[10]=-forward.z}}Matrix4x4._tempMatrix4x4=new Matrix4x4,Matrix4x4.TEMPMatrix0=new Matrix4x4,Matrix4x4.TEMPMatrix1=new Matrix4x4,Matrix4x4._tempVector0=new Vector3,Matrix4x4._tempVector1=new Vector3,Matrix4x4._tempVector2=new Vector3,Matrix4x4._tempVector3=new Vector3,Matrix4x4._tempQuaternion=new Quaternion,Matrix4x4.DEFAULT=new Matrix4x4,Matrix4x4.ZERO=new Matrix4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);class DefineDatas{constructor(){this.value=0}add(define){this.value|=define}remove(define){this.value&=~define}has(define){return(this.value&define)>0}cloneTo(destObject){destObject.value=this.value}clone(){var dest=new DefineDatas;return this.cloneTo(dest),dest}}class ShaderData{constructor(ownerResource=null){this._ownerResource=null,this._data=null,this._defineDatas=new DefineDatas,this._runtimeCopyValues=[],this._ownerResource=ownerResource,this._initData()}_initData(){this._data=new Object}getData(){return this._data}addDefine(define){this._defineDatas.add(define)}removeDefine(define){this._defineDatas.remove(define)}hasDefine(define){return(this._defineDatas.value&define)>0}clearDefine(){this._defineDatas.value=0}getBool(index){return this._data[index]}setBool(index,value){this._data[index]=value}getInt(index){return this._data[index]}setInt(index,value){this._data[index]=value}getNumber(index){return this._data[index]}setNumber(index,value){this._data[index]=value}getVector2(index){return this._data[index]}setVector2(index,value){this._data[index]=value}getVector3(index){return this._data[index]}setVector3(index,value){this._data[index]=value}getVector(index){return this._data[index]}setVector(index,value){this._data[index]=value}getQuaternion(index){return this._data[index]}setQuaternion(index,value){this._data[index]=value}getMatrix4x4(index){return this._data[index]}setMatrix4x4(index,value){this._data[index]=value}getBuffer(shaderIndex){return this._data[shaderIndex]}setBuffer(index,value){this._data[index]=value}setTexture(index,value){var lastValue=this._data[index];this._data[index]=value,this._ownerResource&&this._ownerResource.referenceCount>0&&(lastValue&&lastValue._removeReference(),value&&value._addReference())}getTexture(index){return this._data[index]}setAttribute(index,value){this._data[index]=value}getAttribute(index){return this._data[index]}getLength(){return this._data.length}setLength(value){this._data.length=value}cloneTo(destObject){var dest=destObject,destData=dest._data;for(var k in this._data){var value=this._data[k];if(null!=value)if("number"==typeof value)destData[k]=value;else if("number"==typeof value)destData[k]=value;else if("boolean"==typeof value)destData[k]=value;else if(value instanceof Vector2){var v2=destData[k]||(destData[k]=new Vector2);value.cloneTo(v2),destData[k]=v2}else if(value instanceof Vector3){var v3=destData[k]||(destData[k]=new Vector3);value.cloneTo(v3),destData[k]=v3}else if(value instanceof Vector4){var v4=destData[k]||(destData[k]=new Vector4);value.cloneTo(v4),destData[k]=v4}else if(value instanceof Matrix4x4){var mat=destData[k]||(destData[k]=new Matrix4x4);value.cloneTo(mat),destData[k]=mat}else value instanceof Laya.BaseTexture&&(destData[k]=value)}this._defineDatas.cloneTo(dest._defineDatas)}clone(){var dest=new ShaderData;return this.cloneTo(dest),dest}cloneToForNative(destObject){var dest=destObject;this._int32Data.length-dest._int32Data.length>0&&dest.needRenewArrayBufferForNative(this._int32Data.length),dest._int32Data.set(this._int32Data,0);var destData=dest._nativeArray,dataCount=this._nativeArray.length;destData.length=dataCount;for(var i=0;i=this._int32Data.length){var nByteLen=4*(index+1),pre=this._int32Data,preConchRef=this._data.conchRef,prePtrID=this._data._ptrID;this._data=new ArrayBuffer(nByteLen),this._int32Data=new Int32Array(this._data),this._float32Data=new Float32Array(this._data),this._data.conchRef=preConchRef,this._data._ptrID=prePtrID,pre&&this._int32Data.set(pre,0);var layagl=Laya.LayaGL.instance;layagl.updateArrayBufferRef?layagl.updateArrayBufferRef(this._data._ptrID,preConchRef.isSyncToRender(),this._data):window.conch.updateArrayBufferRef(this._data._ptrID,preConchRef.isSyncToRender(),this._data)}}getDataForNative(){return this._nativeArray}getIntForNative(index){return this._int32Data[index]}setIntForNative(index,value){this.needRenewArrayBufferForNative(index),this._int32Data[index]=value,this._nativeArray[index]=value}getBoolForNative(index){return 1==this._int32Data[index]}setBoolForNative(index,value){this.needRenewArrayBufferForNative(index),this._int32Data[index]=value?1:0,this._nativeArray[index]=value}getNumberForNative(index){return this._float32Data[index]}setNumberForNative(index,value){this.needRenewArrayBufferForNative(index),this._float32Data[index]=value,this._nativeArray[index]=value}getMatrix4x4ForNative(index){return this._nativeArray[index]}setMatrix4x4ForNative(index,value){this.needRenewArrayBufferForNative(index),this._nativeArray[index]=value;var nPtrID=this.setReferenceForNative(value.elements);this._int32Data[index]=nPtrID}getVectorForNative(index){return this._nativeArray[index]}setVectorForNative(index,value){this.needRenewArrayBufferForNative(index),this._nativeArray[index]=value,value.elements||value.forNativeElement();var nPtrID=this.setReferenceForNative(value.elements);this._int32Data[index]=nPtrID}getVector2ForNative(index){return this._nativeArray[index]}setVector2ForNative(index,value){this.needRenewArrayBufferForNative(index),this._nativeArray[index]=value,value.elements||value.forNativeElement();var nPtrID=this.setReferenceForNative(value.elements);this._int32Data[index]=nPtrID}getVector3ForNative(index){return this._nativeArray[index]}setVector3ForNative(index,value){this.needRenewArrayBufferForNative(index),this._nativeArray[index]=value,value.elements||value.forNativeElement();var nPtrID=this.setReferenceForNative(value.elements);this._int32Data[index]=nPtrID}getQuaternionForNative(index){return this._nativeArray[index]}setQuaternionForNative(index,value){this.needRenewArrayBufferForNative(index),this._nativeArray[index]=value,value.elements||value.forNativeElement();var nPtrID=this.setReferenceForNative(value.elements);this._int32Data[index]=nPtrID}getBufferForNative(shaderIndex){return this._nativeArray[shaderIndex]}setBufferForNative(index,value){this.needRenewArrayBufferForNative(index),this._nativeArray[index]=value;var nPtrID=this.setReferenceForNative(value);this._int32Data[index]=nPtrID}getAttributeForNative(index){return this._nativeArray[index]}setAttributeForNative(index,value){this._nativeArray[index]=value,value._ptrID||Laya.LayaGL.instance.createArrayBufferRef(value,Laya.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0),Laya.LayaGL.instance.syncBufferToRenderThread(value),this._int32Data[index]=value._ptrID}getTextureForNative(index){return this._nativeArray[index]}setTextureForNative(index,value){if(value){this.needRenewArrayBufferForNative(index);var lastValue=this._nativeArray[index];this._nativeArray[index]=value,this._int32Data[index]=value._glTexture.id,this._ownerResource&&this._ownerResource.referenceCount>0&&(lastValue&&lastValue._removeReference(),value&&value._addReference())}}setReferenceForNative(value){this.clearRuntimeCopyArray();var nRefID=0,nPtrID=0;return ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_?(Laya.LayaGL.instance.createArrayBufferRefs(value,Laya.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0,Laya.LayaGL.ARRAY_BUFFER_REF_REFERENCE),nRefID=0,nPtrID=value.getPtrID(nRefID)):(Laya.LayaGL.instance.createArrayBufferRefs(value,Laya.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0,Laya.LayaGL.ARRAY_BUFFER_REF_COPY),nRefID=value.getRefNum()-1,nPtrID=value.getPtrID(nRefID),this._runtimeCopyValues.push({obj:value,refID:nRefID,ptrID:nPtrID})),Laya.LayaGL.instance.syncBufferToRenderThread(value,nRefID),nPtrID}static setRuntimeValueMode(bReference){ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_=bReference}clearRuntimeCopyArray(){var currentFrame=Laya.Stat.loopCount;if(this._frameCount!=currentFrame){this._frameCount=currentFrame;for(var i=0,n=this._runtimeCopyValues.length;iSubMeshDynamicBatch.maxIndicesCount&&(this._flush(batchVertexCount,batchIndexCount),renderBatchCount++,Laya.Stat.trianglesFaces+=batchIndexCount/3,batchVertexCount=batchIndexCount=0);var transform=subElement._transform;this._getBatchVertices(vertexDeclaration,this._vertices,batchVertexCount,transform,subElement,subMesh),this._getBatchIndices(this._indices,batchIndexCount,batchVertexCount,transform,subMesh,subElement._dynamicMultiSubMesh),batchVertexCount+=subElement._dynamicVertexCount,batchIndexCount+=indexCount}this._flush(batchVertexCount,batchIndexCount),renderBatchCount++,Laya.Stat.renderBatches+=renderBatchCount,Laya.Stat.savedRenderBatches+=elementCount-renderBatchCount,Laya.Stat.trianglesFaces+=batchIndexCount/3}}SubMeshDynamicBatch.maxAllowVertexCount=10,SubMeshDynamicBatch.maxAllowAttribueCount=900,SubMeshDynamicBatch.maxIndicesCount=32e3;class BatchMark{constructor(){this.updateMark=-1,this.indexInList=-1,this.batched=!1}}class SubMeshInstanceBatch extends GeometryElement{constructor(){super(),this.maxInstanceCount=1024,this.instanceWorldMatrixData=new Float32Array(16*this.maxInstanceCount),this.instanceMVPMatrixData=new Float32Array(16*this.maxInstanceCount);var gl=Laya.LayaGL.instance;this.instanceWorldMatrixBuffer=new VertexBuffer3D(4*this.instanceWorldMatrixData.length,gl.DYNAMIC_DRAW),this.instanceMVPMatrixBuffer=new VertexBuffer3D(4*this.instanceMVPMatrixData.length,gl.DYNAMIC_DRAW),this.instanceWorldMatrixBuffer.vertexDeclaration=VertexMesh.instanceWorldMatrixDeclaration,this.instanceMVPMatrixBuffer.vertexDeclaration=VertexMesh.instanceMVPMatrixDeclaration}static __init__(){SubMeshInstanceBatch.instance=new SubMeshInstanceBatch}_render(state){var gl=Laya.LayaGL.instance,element=state.renderElement,subMesh=element.instanceSubMesh,count=element.instanceBatchElementList.length,indexCount=subMesh._indexCount;subMesh._mesh._instanceBufferState.bind(),Laya.LayaGL.layaGPUInstance.drawElementsInstanced(gl.TRIANGLES,indexCount,gl.UNSIGNED_SHORT,2*subMesh._indexStart,count),Laya.Stat.renderBatches++,Laya.Stat.savedRenderBatches+=count-1,Laya.Stat.trianglesFaces+=indexCount*count/3}}class Color{constructor(r=1,g=1,b=1,a=1){this.r=r,this.g=g,this.b=b,this.a=a}static gammaToLinearSpace(value){return value<=.04045?value/12.92:value<1?Math.pow((value+.055)/1.055,2.4):Math.pow(value,2.4)}static linearToGammaSpace(value){return value<=0?0:value<=.0031308?12.92*value:value<=1?1.055*Math.pow(value,.41666)-.055:Math.pow(value,.41666)}toLinear(out){out.r=Color.gammaToLinearSpace(this.r),out.g=Color.gammaToLinearSpace(this.g),out.b=Color.gammaToLinearSpace(this.b)}toGamma(out){out.r=Color.linearToGammaSpace(this.r),out.g=Color.linearToGammaSpace(this.g),out.b=Color.linearToGammaSpace(this.b)}cloneTo(destObject){var destColor=destObject;destColor.r=this.r,destColor.g=this.g,destColor.b=this.b,destColor.a=this.a}clone(){var dest=new Color;return this.cloneTo(dest),dest}forNativeElement(){}}Color.RED=new Color(1,0,0,1),Color.GREEN=new Color(0,1,0,1),Color.BLUE=new Color(0,0,1,1),Color.CYAN=new Color(0,1,1,1),Color.YELLOW=new Color(1,.92,.016,1),Color.MAGENTA=new Color(1,0,1,1),Color.GRAY=new Color(.5,.5,.5,1),Color.WHITE=new Color(1,1,1,1),Color.BLACK=new Color(0,0,0,1);class TextureGenerator{constructor(){}static lightAttenTexture(x,y,maxX,maxY,index,data){var sqrRange=x/maxX,atten=1/(1+25*sqrRange);sqrRange>=.64&&(sqrRange>1?atten=0:atten*=1-(sqrRange-.64)/.36),data[index]=Math.floor(255*atten+.5)}static haloTexture(x,y,maxX,maxY,index,data){var xFac=(x-(maxX>>=1))/maxX,yFac=(y-(maxY>>=1))/maxY,sqrRange=xFac*xFac+yFac*yFac;sqrRange>1&&(sqrRange=1),data[index]=Math.floor(255*(1-sqrRange)+.5)}static _generateTexture2D(texture,textureWidth,textureHeight,func){var index=0,size=0;switch(texture.format){case Laya.BaseTexture.FORMAT_R8G8B8:size=3;break;case Laya.BaseTexture.FORMAT_R8G8B8A8:size=4;break;case Laya.BaseTexture.FORMAT_ALPHA8:size=1;break;default:throw"GeneratedTexture._generateTexture: unkonw texture format."}for(var data=new Uint8Array(textureWidth*textureHeight*size),y=0;y=0?url.substr(index):null}static _createAffineTransformationArray(trans,rot,scale,outE){var x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2,sx=scale.x,sy=scale.y,sz=scale.z;outE[0]=(1-(yy+zz))*sx,outE[1]=(xy+wz)*sx,outE[2]=(xz-wy)*sx,outE[3]=0,outE[4]=(xy-wz)*sy,outE[5]=(1-(xx+zz))*sy,outE[6]=(yz+wx)*sy,outE[7]=0,outE[8]=(xz+wy)*sz,outE[9]=(yz-wx)*sz,outE[10]=(1-(xx+yy))*sz,outE[11]=0,outE[12]=trans.x,outE[13]=trans.y,outE[14]=trans.z,outE[15]=1}static _mulMatrixArray(leftMatrixE,rightMatrix,outArray,outOffset){var i,ai0,ai1,ai2,ai3,rightMatrixE=rightMatrix.elements,m11=rightMatrixE[0],m12=rightMatrixE[1],m13=rightMatrixE[2],m14=rightMatrixE[3],m21=rightMatrixE[4],m22=rightMatrixE[5],m23=rightMatrixE[6],m24=rightMatrixE[7],m31=rightMatrixE[8],m32=rightMatrixE[9],m33=rightMatrixE[10],m34=rightMatrixE[11],m41=rightMatrixE[12],m42=rightMatrixE[13],m43=rightMatrixE[14],m44=rightMatrixE[15],ai0OutOffset=outOffset,ai1OutOffset=outOffset+4,ai2OutOffset=outOffset+8,ai3OutOffset=outOffset+12;for(i=0;i<4;i++)ai0=leftMatrixE[i],ai1=leftMatrixE[i+4],ai2=leftMatrixE[i+8],ai3=leftMatrixE[i+12],outArray[ai0OutOffset+i]=ai0*m11+ai1*m12+ai2*m13+ai3*m14,outArray[ai1OutOffset+i]=ai0*m21+ai1*m22+ai2*m23+ai3*m24,outArray[ai2OutOffset+i]=ai0*m31+ai1*m32+ai2*m33+ai3*m34,outArray[ai3OutOffset+i]=ai0*m41+ai1*m42+ai2*m43+ai3*m44}static arcTanAngle(x,y){return 0==x?1==y?Math.PI/2:-Math.PI/2:x>0?Math.atan(y/x):x<0?y>0?Math.atan(y/x)+Math.PI:Math.atan(y/x)-Math.PI:0}static angleTo(from,location,angle){Vector3.subtract(location,from,Quaternion.TEMPVector30),Vector3.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30),angle.x=Math.asin(Quaternion.TEMPVector30.y),angle.y=Utils3D.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x)}static transformQuat(source,rotation,out){var re=rotation,x=source.x,y=source.y,z=source.z,qx=re[0],qy=re[1],qz=re[2],qw=re[3],ix=qw*x+qy*z-qz*y,iy=qw*y+qz*x-qx*z,iz=qw*z+qx*y-qy*x,iw=-qx*x-qy*y-qz*z;out.x=ix*qw+iw*-qx+iy*-qz-iz*-qy,out.y=iy*qw+iw*-qy+iz*-qx-ix*-qz,out.z=iz*qw+iw*-qz+ix*-qy-iy*-qx}static quaternionWeight(f,weight,e){e.x=f.x*weight,e.y=f.y*weight,e.z=f.z*weight,e.w=f.w}static quaternionConjugate(value,result){result.x=-value.x,result.y=-value.y,result.z=-value.z,result.w=value.w}static scaleWeight(s,w,out){var sX=s.x,sY=s.y,sZ=s.z;out.x=sX>0?Math.pow(Math.abs(sX),w):-Math.pow(Math.abs(sX),w),out.y=sY>0?Math.pow(Math.abs(sY),w):-Math.pow(Math.abs(sY),w),out.z=sZ>0?Math.pow(Math.abs(sZ),w):-Math.pow(Math.abs(sZ),w)}static scaleBlend(sa,sb,w,out){var saw=Utils3D._tempVector3_0,sbw=Utils3D._tempVector3_1;Utils3D.scaleWeight(sa,1-w,saw),Utils3D.scaleWeight(sb,w,sbw);var sng=w>.5?sb:sa;out.x=sng.x>0?Math.abs(saw.x*sbw.x):-Math.abs(saw.x*sbw.x),out.y=sng.y>0?Math.abs(saw.y*sbw.y):-Math.abs(saw.y*sbw.y),out.z=sng.z>0?Math.abs(saw.z*sbw.z):-Math.abs(saw.z*sbw.z)}static matrix4x4MultiplyFFF(a,b,e){var i,ai0,ai1,ai2,ai3;if(e===b)for(b=new Float32Array(16),i=0;i<16;++i)b[i]=e[i];var b0=b[0],b1=b[1],b2=b[2],b3=b[3],b4=b[4],b5=b[5],b6=b[6],b7=b[7],b8=b[8],b9=b[9],b10=b[10],b11=b[11],b12=b[12],b13=b[13],b14=b[14],b15=b[15];for(i=0;i<4;i++)ai0=a[i],ai1=a[i+4],ai2=a[i+8],ai3=a[i+12],e[i]=ai0*b0+ai1*b1+ai2*b2+ai3*b3,e[i+4]=ai0*b4+ai1*b5+ai2*b6+ai3*b7,e[i+8]=ai0*b8+ai1*b9+ai2*b10+ai3*b11,e[i+12]=ai0*b12+ai1*b13+ai2*b14+ai3*b15}static matrix4x4MultiplyFFFForNative(a,b,e){Laya.LayaGL.instance.matrix4x4Multiply(a,b,e)}static matrix4x4MultiplyMFM(left,right,out){Utils3D.matrix4x4MultiplyFFF(left.elements,right,out.elements)}static _buildTexture2D(width,height,format,colorFunc,mipmaps=!1){var texture=new Laya.Texture2D(width,height,format,mipmaps,!0);return texture.anisoLevel=1,texture.filterMode=Laya.BaseTexture.FILTERMODE_POINT,TextureGenerator._generateTexture2D(texture,width,height,colorFunc),texture}static _drawBound(debugLine,boundBox,color){debugLine.lineCount+12>debugLine.maxLineCount&&(debugLine.maxLineCount+=12);var start=Utils3D._tempVector3_0,end=Utils3D._tempVector3_1,min=boundBox.min,max=boundBox.max;start.setValue(min.x,min.y,min.z),end.setValue(max.x,min.y,min.z),debugLine.addLine(start,end,color,color),start.setValue(min.x,min.y,min.z),end.setValue(min.x,min.y,max.z),debugLine.addLine(start,end,color,color),start.setValue(max.x,min.y,min.z),end.setValue(max.x,min.y,max.z),debugLine.addLine(start,end,color,color),start.setValue(min.x,min.y,max.z),end.setValue(max.x,min.y,max.z),debugLine.addLine(start,end,color,color),start.setValue(min.x,min.y,min.z),end.setValue(min.x,max.y,min.z),debugLine.addLine(start,end,color,color),start.setValue(min.x,min.y,max.z),end.setValue(min.x,max.y,max.z),debugLine.addLine(start,end,color,color),start.setValue(max.x,min.y,min.z),end.setValue(max.x,max.y,min.z),debugLine.addLine(start,end,color,color),start.setValue(max.x,min.y,max.z),end.setValue(max.x,max.y,max.z),debugLine.addLine(start,end,color,color),start.setValue(min.x,max.y,min.z),end.setValue(max.x,max.y,min.z),debugLine.addLine(start,end,color,color),start.setValue(min.x,max.y,min.z),end.setValue(min.x,max.y,max.z),debugLine.addLine(start,end,color,color),start.setValue(max.x,max.y,min.z),end.setValue(max.x,max.y,max.z),debugLine.addLine(start,end,color,color),start.setValue(min.x,max.y,max.z),end.setValue(max.x,max.y,max.z),debugLine.addLine(start,end,color,color)}static _getHierarchyPath(rootSprite,checkSprite,path){path.length=0;for(var sprite=checkSprite;sprite!==rootSprite;){var parent=sprite._parent;if(!parent)return null;path.push(parent.getChildIndex(sprite)),sprite=parent}return path}static _getNodeByHierarchyPath(rootSprite,invPath){for(var sprite=rootSprite,i=invPath.length-1;i>=0;i--)sprite=sprite.getChildAt(invPath[i]);return sprite}}Utils3D._tempVector3_0=new Vector3,Utils3D._tempVector3_1=new Vector3,Utils3D._tempVector3_2=new Vector3,Utils3D._tempColor0=new Color,Utils3D._tempArray16_0=new Float32Array(16),Utils3D._tempArray16_1=new Float32Array(16),Utils3D._tempArray16_2=new Float32Array(16),Utils3D._tempArray16_3=new Float32Array(16),Utils3D._compIdToNode=new Object;class Shader3D{constructor(name,attributeMap,uniformMap,enableInstancing){this._attributeMap=null,this._uniformMap=null,this._enableInstancing=!1,this._subShaders=[],this._name=name,this._attributeMap=attributeMap,this._uniformMap=uniformMap,this._enableInstancing=enableInstancing}static propertyNameToID(name){if(null!=Shader3D._propertyNameMap[name])return Shader3D._propertyNameMap[name];var id=Shader3D._propertyNameCounter++;return Shader3D._propertyNameMap[name]=id,id}static addInclude(fileName,txt){txt=txt.replace(Laya.ShaderCompile._clearCR,""),Laya.ShaderCompile.addInclude(fileName,txt)}static registerPublicDefine(name){var value=Math.pow(2,Shader3D._publicCounter++);return Shader3D._globleDefines[value]=name,value}static compileShader(name,subShaderIndex,passIndex,publicDefine,spriteDefine,materialDefine){var shader=Shader3D.find(name);if(shader){var subShader=shader.getSubShaderAt(subShaderIndex);if(subShader){var pass=subShader._passes[passIndex];pass?Laya.WebGL.shaderHighPrecision?pass.withCompile(publicDefine,spriteDefine,materialDefine):pass.withCompile(publicDefine-Shader3D.SHADERDEFINE_HIGHPRECISION,spriteDefine,materialDefine):console.warn("Shader3D: unknown passIndex.")}else console.warn("Shader3D: unknown subShaderIndex.")}else console.warn("Shader3D: unknown shader name.")}static add(name,attributeMap=null,uniformMap=null,enableInstancing=!1){return Shader3D._preCompileShader[name]=new Shader3D(name,attributeMap,uniformMap,enableInstancing)}static find(name){return Shader3D._preCompileShader[name]}addSubShader(subShader){this._subShaders.push(subShader),subShader._owner=this}getSubShaderAt(index){return this._subShaders[index]}}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._propertyNameCounter=0,Shader3D._propertyNameMap={},Shader3D._publicCounter=0,Shader3D._globleDefines=[],Shader3D._preCompileShader={},Shader3D.debugMode=!1;class ShaderDefines{constructor(superDefines=null){if(this._counter=0,this.defines={},superDefines)for(var k in this._counter=superDefines._counter,superDefines.defines)this.defines[k]=superDefines.defines[k]}registerDefine(name){var value=Math.pow(2,this._counter++);return this.defines[value]=name,value}}class AnimatorPlayState{get normalizedTime(){return this._normalizedTime}get duration(){return this._duration}constructor(){}_resetPlayState(startTime){this._finish=!1,this._startPlayTime=startTime,this._elapsedTime=startTime,this._playEventIndex=0,this._lastIsFront=!0}_cloneTo(dest){dest._finish=this._finish,dest._startPlayTime=this._startPlayTime,dest._elapsedTime=this._elapsedTime,dest._playEventIndex=this._playEventIndex,dest._lastIsFront=this._lastIsFront}}class AnimatorControllerLayer{constructor(name){this._defaultState=null,this._referenceCount=0,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 AnimatorPlayState,this._crossPlayStateInfo=new AnimatorPlayState,this._srcCrossClipNodeIndices=[],this._destCrossClipNodeIndices=[],this.name=name,this.defaultWeight=1,this.blendingMode=AnimatorControllerLayer.BLENDINGMODE_OVERRIDE}get defaultState(){return this._defaultState}set defaultState(value){this._defaultState=value,this._statesMap[value.name]=value}_removeClip(clipStateInfos,statesMap,index,state){var clip=state._clip,clipStateInfo=clipStateInfos[index];if(clipStateInfos.splice(index,1),delete statesMap[state.name],this._animator){var frameNodes=clip._nodes,nodeOwners=clipStateInfo._nodeOwners;clip._removeReference();for(var i=0,n=frameNodes.count;i0&&this._clip._removeReference(this._referenceCount),value&&(this._currentFrameIndices=new Int16Array(value._nodes.count),this._resetFrameIndices(),this._referenceCount>0&&this._clip._addReference(this._referenceCount)),this._clip=value)}_getReferenceCount(){return this._referenceCount}_addReference(count=1){this._clip&&this._clip._addReference(count),this._referenceCount+=count}_removeReference(count=1){this._clip&&this._clip._removeReference(count),this._referenceCount-=count}_clearReference(){this._removeReference(-this._referenceCount)}_resetFrameIndices(){for(var i=0,n=this._currentFrameIndices.length;i=clipDuration){if(playState._finish=!0,playState._elapsedTime=clipDuration,playState._normalizedPlayTime=1,scripts)for(var i=0,n=scripts.length;i=0&&(event=events[eventIndex]).time>=endTime;eventIndex--)for(j=0,m=scripts.length;j=playStateInfo._lastElapsedTime;if(playStateInfo._lastIsFront!==frontPlay&&(frontPlay?playStateInfo._playEventIndex++:playStateInfo._playEventIndex--,playStateInfo._lastIsFront=frontPlay),0==loopCount)playStateInfo._playEventIndex=this._eventScript(scripts,events,playStateInfo._playEventIndex,time,frontPlay);else if(frontPlay){this._eventScript(scripts,events,playStateInfo._playEventIndex,clipDuration,!0);for(var i=0,n=loopCount-1;iplayStateInfo._lastElapsedTime;clip._evaluateClipDatasRealTime(clip._nodes,curPlayTime,currentFrameIndices,addtive,frontPlay)}_applyFloat(pro,proName,nodeOwner,additive,weight,isFirstLayer,data){if(nodeOwner.updateMark===this._updateMark)if(additive)pro[proName]+=weight*data;else{var oriValue=pro[proName];pro[proName]=oriValue+weight*(data-oriValue)}else if(isFirstLayer)pro[proName]=additive?nodeOwner.defaultValue+data:data;else if(additive)pro[proName]=nodeOwner.defaultValue+weight*data;else{var defValue=nodeOwner.defaultValue;pro[proName]=defValue+weight*(data-defValue)}}_applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,data,out){if(nodeOwner.updateMark===this._updateMark)if(additive)out.x+=weight*data.x,out.y+=weight*data.y,out.z+=weight*data.z;else{var oriX=out.x,oriY=out.y,oriZ=out.z;out.x=oriX+weight*(data.x-oriX),out.y=oriY+weight*(data.y-oriY),out.z=oriZ+weight*(data.z-oriZ)}else if(isFirstLayer)if(additive){var defValue=nodeOwner.defaultValue;out.x=defValue.x+data.x,out.y=defValue.y+data.y,out.z=defValue.z+data.z}else out.x=data.x,out.y=data.y,out.z=data.z;else if(defValue=nodeOwner.defaultValue,additive)out.x=defValue.x+weight*data.x,out.y=defValue.y+weight*data.y,out.z=defValue.z+weight*data.z;else{var defX=defValue.x,defY=defValue.y,defZ=defValue.z;out.x=defX+weight*(data.x-defX),out.y=defY+weight*(data.y-defY),out.z=defZ+weight*(data.z-defZ)}}_applyRotation(nodeOwner,additive,weight,isFirstLayer,clipRot,localRotation){if(nodeOwner.updateMark===this._updateMark)if(additive){var tempQuat=Animator._tempQuaternion1;Utils3D.quaternionWeight(clipRot,weight,tempQuat),tempQuat.normalize(tempQuat),Quaternion.multiply(localRotation,tempQuat,localRotation)}else Quaternion.lerp(localRotation,clipRot,weight,localRotation);else if(isFirstLayer)if(additive){var defaultRot=nodeOwner.defaultValue;Quaternion.multiply(defaultRot,clipRot,localRotation)}else localRotation.x=clipRot.x,localRotation.y=clipRot.y,localRotation.z=clipRot.z,localRotation.w=clipRot.w;else defaultRot=nodeOwner.defaultValue,additive?(tempQuat=Animator._tempQuaternion1,Utils3D.quaternionWeight(clipRot,weight,tempQuat),tempQuat.normalize(tempQuat),Quaternion.multiply(defaultRot,tempQuat,localRotation)):Quaternion.lerp(defaultRot,clipRot,weight,localRotation)}_applyScale(nodeOwner,additive,weight,isFirstLayer,clipSca,localScale){if(nodeOwner.updateMark===this._updateMark)if(additive){var scale=Animator._tempVector31;Utils3D.scaleWeight(clipSca,weight,scale),localScale.x=localScale.x*scale.x,localScale.y=localScale.y*scale.y,localScale.z=localScale.z*scale.z}else Utils3D.scaleBlend(localScale,clipSca,weight,localScale);else if(isFirstLayer)if(additive){var defaultSca=nodeOwner.defaultValue;localScale.x=defaultSca.x*clipSca.x,localScale.y=defaultSca.y*clipSca.y,localScale.z=defaultSca.z*clipSca.z}else localScale.x=clipSca.x,localScale.y=clipSca.y,localScale.z=clipSca.z;else defaultSca=nodeOwner.defaultValue,additive?(scale=Animator._tempVector31,Utils3D.scaleWeight(clipSca,weight,scale),localScale.x=defaultSca.x*scale.x,localScale.y=defaultSca.y*scale.y,localScale.z=defaultSca.z*scale.z):Utils3D.scaleBlend(defaultSca,clipSca,weight,localScale)}_applyCrossData(nodeOwner,additive,weight,isFirstLayer,srcValue,desValue,crossWeight){var pro=nodeOwner.propertyOwner;if(pro){switch(nodeOwner.type){case 0:for(var proPat=nodeOwner.property,m=proPat.length-1,j=0;jcrossClipDuration?crossClipDuration/crossDuratuion:1,crossSpeed=this._speed*crossClipState.speed;this._updatePlayer(crossClipState,crossPlayStateInfo,delta*crossScale*crossSpeed,crossClip.islooping);var crossWeight=(crossPlayStateInfo._elapsedTime-startPlayTime)/crossScale/crossDuratuion;crossWeight>=1?needRender&&(this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale*crossSpeed),this._setClipDatasToNode(crossClipState,addtive,controllerLayer.defaultWeight,0===i),controllerLayer._playType=0,controllerLayer._currentPlayState=crossClipState,crossPlayStateInfo._cloneTo(playStateInfo)):(playStateInfo._finish||(speed=this._speed*animatorState.speed,this._updatePlayer(animatorState,playStateInfo,delta*speed,clip.islooping)),needRender&&(this._updateClipDatas(animatorState,addtive,playStateInfo,timerScale*speed),this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale*crossScale*crossSpeed),this._setCrossClipDatasToNode(controllerLayer,animatorState,crossClipState,crossWeight,0===i))),needRender&&(this._updateEventScript(animatorState,playStateInfo),this._updateEventScript(crossClipState,crossPlayStateInfo));break;case 2:crossClip=(crossClipState=controllerLayer._crossPlayState)._clip,crossDuratuion=controllerLayer._crossDuration,startPlayTime=crossPlayStateInfo._startPlayTime,crossScale=crossDuratuion>(crossClipDuration=crossClip._duration-startPlayTime)?crossClipDuration/crossDuratuion:1,crossSpeed=this._speed*crossClipState.speed,this._updatePlayer(crossClipState,crossPlayStateInfo,delta*crossScale*crossSpeed,crossClip.islooping),needRender&&((crossWeight=(crossPlayStateInfo._elapsedTime-startPlayTime)/crossScale/crossDuratuion)>=1?(this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale*crossSpeed),this._setClipDatasToNode(crossClipState,addtive,1,0===i),controllerLayer._playType=0,controllerLayer._currentPlayState=crossClipState,crossPlayStateInfo._cloneTo(playStateInfo)):(this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale*crossScale*crossSpeed),this._setFixedCrossClipDatasToNode(controllerLayer,crossClipState,crossWeight,0===i)),this._updateEventScript(crossClipState,crossPlayStateInfo))}}needRender&&this._avatar&&(Laya.Render.supportWebGLPlusAnimation&&this._updateAnimationNodeWorldMatix(this._animationNodeLocalPositions,this._animationNodeLocalRotations,this._animationNodeLocalScales,this._animationNodeWorldMatrixs,this._animationNodeParentIndices),this._updateAvatarNodesToSprite())}}_cloneTo(dest){var animator=dest;animator.avatar=this.avatar,animator.cullingMode=this.cullingMode;for(var i=0,n=this._controllerLayers.length;i=0&&value<=30))throw new Error("Layer value must be 0-30.");this._layer=value}}get url(){return this._url}get isStatic(){return this._isStatic}get transform(){return this._transform}_setCreateURL(url){this._url=Laya.URL.formatURL(url)}_changeAnimatorsToLinkSprite3D(sprite3D,isLink,path){var animator=this.getComponent(Animator);if(animator&&(animator.avatar||sprite3D._changeAnimatorToLinkSprite3DNoAvatar(animator,isLink,path)),this._parent&&this._parent instanceof Sprite3D){path.unshift(this._parent.name);var p=this._parent;p._hierarchyAnimator&&p._changeAnimatorsToLinkSprite3D(sprite3D,isLink,path)}}_setHierarchyAnimator(animator,parentAnimator){this._changeHierarchyAnimator(animator),this._changeAnimatorAvatar(animator.avatar);for(var i=0,n=this._children.length;i0){for(var i=0;i0;)right--;if(left1){var index=this._partition(items,left,right),leftIndex=index-1;left0&&opaqueQueue._quickSort(0,count-1),(count=transparentQueue.elements.length)>0&&transparentQueue._quickSort(0,count-1)}static renderObjectCullingNative(camera,scene,context,renderList,customShader,replacementTag){var n,opaqueQueue=scene._opaqueQueue,transparentQueue=scene._transparentQueue;opaqueQueue.clear(),transparentQueue.clear();var staticBatchManagers=StaticBatchManager._managers;for(i=0,n=staticBatchManagers.length;i0&&opaqueQueue._quickSort(0,count-1),(count=transparentQueue.elements.length)>0&&transparentQueue._quickSort(0,count-1)}static cullingNative(boundFrustumBuffer,cullingBuffer,cullingBufferIndices,cullingCount,cullingBufferResult){return Laya.LayaGL.instance.culling(boundFrustumBuffer,cullingBuffer,cullingBufferIndices,cullingCount,cullingBufferResult)}}FrustumCulling._tempVector3=new Vector3,FrustumCulling._tempColor0=new Color,FrustumCulling.debugFrustumCulling=!1;class Plane{constructor(normal,d=0){this.normal=normal,this.distance=d}static createPlaneBy3P(point1,point2,point3){var x1=point2.x-point1.x,y1=point2.y-point1.y,z1=point2.z-point1.z,x2=point3.x-point1.x,y2=point3.y-point1.y,z2=point3.z-point1.z,yz=y1*z2-z1*y2,xz=z1*x2-x1*z2,xy=x1*y2-y1*x2,invPyth=1/Math.sqrt(yz*yz+xz*xz+xy*xy),x=yz*invPyth,y=xz*invPyth,z=xy*invPyth;Plane._TEMPVec3.x=x,Plane._TEMPVec3.y=y,Plane._TEMPVec3.z=z;var d=-(x*point1.x+y*point1.y+z*point1.z);return new Plane(Plane._TEMPVec3,d)}normalize(){var normalEX=this.normal.x,normalEY=this.normal.y,normalEZ=this.normal.z,magnitude=1/Math.sqrt(normalEX*normalEX+normalEY*normalEY+normalEZ*normalEZ);this.normal.x=normalEX*magnitude,this.normal.y=normalEY*magnitude,this.normal.z=normalEZ*magnitude,this.distance*=magnitude}}Plane._TEMPVec3=new Vector3,Plane.PlaneIntersectionType_Back=0,Plane.PlaneIntersectionType_Front=1,Plane.PlaneIntersectionType_Intersecting=2;class Ray{constructor(origin,direction){this.origin=origin,this.direction=direction}}class ContainmentType{}ContainmentType.Disjoint=0,ContainmentType.Contains=1,ContainmentType.Intersects=2;class CollisionUtils{constructor(){}static distancePlaneToPoint(plane,point){return Vector3.dot(plane.normal,point)-plane.distance}static distanceBoxToPoint(box,point){var boxMin=box.min,boxMineX=boxMin.x,boxMineY=boxMin.y,boxMineZ=boxMin.z,boxMax=box.max,boxMaxeX=boxMax.x,boxMaxeY=boxMax.y,boxMaxeZ=boxMax.z,pointeX=point.x,pointeY=point.y,pointeZ=point.z,distance=0;return pointeXboxMaxeX&&(distance+=(boxMaxeX-pointeX)*(boxMaxeX-pointeX)),pointeYboxMaxeY&&(distance+=(boxMaxeY-pointeY)*(boxMaxeY-pointeY)),pointeZboxMaxeZ&&(distance+=(boxMaxeZ-pointeZ)*(boxMaxeZ-pointeZ)),Math.sqrt(distance)}static distanceBoxToBox(box1,box2){var delta,box1Mine=box1.min,box1MineX=box1Mine.x,box1MineY=box1Mine.y,box1MineZ=box1Mine.z,box1Maxe=box1.max,box1MaxeX=box1Maxe.x,box1MaxeY=box1Maxe.y,box1MaxeZ=box1Maxe.z,box2Mine=box2.min,box2MineX=box2Mine.x,box2MineY=box2Mine.y,box2MineZ=box2Mine.z,box2Maxe=box2.max,box2MaxeX=box2Maxe.x,box2MaxeY=box2Maxe.y,box2MaxeZ=box2Maxe.z,distance=0;return box1MineX>box2MaxeX?distance+=(delta=box1MineX-box2MaxeX)*delta:box2MineX>box1MaxeX&&(distance+=(delta=box2MineX-box1MaxeX)*delta),box1MineY>box2MaxeY?distance+=(delta=box1MineY-box2MaxeY)*delta:box2MineY>box1MaxeY&&(distance+=(delta=box2MineY-box1MaxeY)*delta),box1MineZ>box2MaxeZ?distance+=(delta=box1MineZ-box2MaxeZ)*delta:box2MineZ>box1MaxeZ&&(distance+=(delta=box2MineZ-box1MaxeZ)*delta),Math.sqrt(distance)}static distanceSphereToPoint(sphere,point){var distance=Math.sqrt(Vector3.distanceSquared(sphere.center,point));return distance-=sphere.radius,Math.max(distance,0)}static distanceSphereToSphere(sphere1,sphere2){var distance=Math.sqrt(Vector3.distanceSquared(sphere1.center,sphere2.center));return distance-=sphere1.radius+sphere2.radius,Math.max(distance,0)}static intersectsRayAndTriangleRD(ray,vertex1,vertex2,vertex3,out){var rayO=ray.origin,rayOeX=rayO.x,rayOeY=rayO.y,rayOeZ=rayO.z,rayD=ray.direction,rayDeX=rayD.x,rayDeY=rayD.y,rayDeZ=rayD.z,v1eX=vertex1.x,v1eY=vertex1.y,v1eZ=vertex1.z,v2eX=vertex2.x,v2eY=vertex2.y,v2eZ=vertex2.z,v3eX=vertex3.x,v3eY=vertex3.y,v3eZ=vertex3.z,_tempV30eX=CollisionUtils._tempV30.x,_tempV30eY=CollisionUtils._tempV30.y,_tempV30eZ=CollisionUtils._tempV30.z;_tempV30eX=v2eX-v1eX,_tempV30eY=v2eY-v1eY,_tempV30eZ=v2eZ-v1eZ;var _tempV31eX=CollisionUtils._tempV31.x,_tempV31eY=CollisionUtils._tempV31.y,_tempV31eZ=CollisionUtils._tempV31.z;_tempV31eX=v3eX-v1eX,_tempV31eY=v3eY-v1eY,_tempV31eZ=v3eZ-v1eZ;var _tempV32eX=CollisionUtils._tempV32.x,_tempV32eY=CollisionUtils._tempV32.y,_tempV32eZ=CollisionUtils._tempV32.z,determinant=_tempV30eX*(_tempV32eX=rayDeY*_tempV31eZ-rayDeZ*_tempV31eY)+_tempV30eY*(_tempV32eY=rayDeZ*_tempV31eX-rayDeX*_tempV31eZ)+_tempV30eZ*(_tempV32eZ=rayDeX*_tempV31eY-rayDeY*_tempV31eX);if(MathUtils3D.isZero(determinant))return!1;var inversedeterminant=1/determinant,_tempV33eX=CollisionUtils._tempV33.x,_tempV33eY=CollisionUtils._tempV33.y,_tempV33eZ=CollisionUtils._tempV33.z,triangleU=(_tempV33eX=rayOeX-v1eX)*_tempV32eX+(_tempV33eY=rayOeY-v1eY)*_tempV32eY+(_tempV33eZ=rayOeZ-v1eZ)*_tempV32eZ;if((triangleU*=inversedeterminant)<0||triangleU>1)return!1;var _tempV34eX=CollisionUtils._tempV34.x,_tempV34eY=CollisionUtils._tempV34.y,_tempV34eZ=CollisionUtils._tempV34.z,triangleV=rayDeX*(_tempV34eX=_tempV33eY*_tempV30eZ-_tempV33eZ*_tempV30eY)+rayDeY*(_tempV34eY=_tempV33eZ*_tempV30eX-_tempV33eX*_tempV30eZ)+rayDeZ*(_tempV34eZ=_tempV33eX*_tempV30eY-_tempV33eY*_tempV30eX);if((triangleV*=inversedeterminant)<0||triangleU+triangleV>1)return!1;var raydistance=_tempV31eX*_tempV34eX+_tempV31eY*_tempV34eY+_tempV31eZ*_tempV34eZ;return!((raydistance*=inversedeterminant)<0)}static intersectsRayAndTriangleRP(ray,vertex1,vertex2,vertex3,out){return CollisionUtils.intersectsRayAndTriangleRD(ray,vertex1,vertex2,vertex3,void 0)?(Vector3.scale(ray.direction,void 0,CollisionUtils._tempV30),Vector3.add(ray.origin,CollisionUtils._tempV30,out),!0):(out=Vector3._ZERO,!1)}static intersectsRayAndPoint(ray,point){Vector3.subtract(ray.origin,point,CollisionUtils._tempV30);var b=Vector3.dot(CollisionUtils._tempV30,ray.direction),c=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-MathUtils3D.zeroTolerance;return!(c>0&&b>0)&&!(b*b-c<0)}static intersectsRayAndRay(ray1,ray2,out){var ray1o=ray1.origin,ray1oeX=ray1o.x,ray1oeY=ray1o.y,ray1oeZ=ray1o.z,ray1d=ray1.direction,ray1deX=ray1d.x,ray1deY=ray1d.y,ray1deZ=ray1d.z,ray2o=ray2.origin,ray2oeX=ray2o.x,ray2oeY=ray2o.y,ray2oeZ=ray2o.z,ray2d=ray2.direction,ray2deX=ray2d.x,ray2deY=ray2d.y,ray2deZ=ray2d.z;Vector3.cross(ray1d,ray2d,CollisionUtils._tempV30);var tempV3=CollisionUtils._tempV30,denominator=Vector3.scalarLength(CollisionUtils._tempV30);if(MathUtils3D.isZero(denominator)&&MathUtils3D.nearEqual(ray2oeX,ray1oeX)&&MathUtils3D.nearEqual(ray2oeY,ray1oeY)&&MathUtils3D.nearEqual(ray2oeZ,ray1oeZ))return!0;denominator*=denominator;var m11=ray2oeX-ray1oeX,m12=ray2oeY-ray1oeY,m13=ray2oeZ-ray1oeZ,m21=ray2deX,m22=ray2deY,m23=ray2deZ,m31=tempV3.x,m32=tempV3.y,m33=tempV3.z,dets=m11*m22*m33+m12*m23*m31+m13*m21*m32-m11*m23*m32-m12*m21*m33-m13*m22*m31;m21=ray1deX,m22=ray1deY,m23=ray1deZ;var s=dets/denominator;Vector3.scale(ray1d,s,CollisionUtils._tempV30),Vector3.scale(ray2d,s,CollisionUtils._tempV31),Vector3.add(ray1o,CollisionUtils._tempV30,CollisionUtils._tempV32),Vector3.add(ray2o,CollisionUtils._tempV31,CollisionUtils._tempV33);var point1e=CollisionUtils._tempV32,point2e=CollisionUtils._tempV33;return!!(MathUtils3D.nearEqual(point2e.x,point1e.x)&&MathUtils3D.nearEqual(point2e.y,point1e.y)&&MathUtils3D.nearEqual(point2e.z,point1e.z))}static intersectsPlaneAndTriangle(plane,vertex1,vertex2,vertex3){var test1=CollisionUtils.intersectsPlaneAndPoint(plane,vertex1),test2=CollisionUtils.intersectsPlaneAndPoint(plane,vertex2),test3=CollisionUtils.intersectsPlaneAndPoint(plane,vertex3);return test1==Plane.PlaneIntersectionType_Front&&test2==Plane.PlaneIntersectionType_Front&&test3==Plane.PlaneIntersectionType_Front?Plane.PlaneIntersectionType_Front:test1==Plane.PlaneIntersectionType_Back&&test2==Plane.PlaneIntersectionType_Back&&test3==Plane.PlaneIntersectionType_Back?Plane.PlaneIntersectionType_Back:Plane.PlaneIntersectionType_Intersecting}static intersectsRayAndPlaneRD(ray,plane,out){var planeNor=plane.normal,direction=Vector3.dot(planeNor,ray.direction);if(MathUtils3D.isZero(direction))return 0,!1;var position=Vector3.dot(planeNor,ray.origin);return!((-plane.distance-position)/direction<0)||(0,!1)}static intersectsRayAndPlaneRP(ray,plane,out){return!!CollisionUtils.intersectsRayAndPlaneRD(ray,plane,void 0)&&(Vector3.scale(ray.direction,void 0,CollisionUtils._tempV30),Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31),!0)}static intersectsRayAndBoxRD(ray,box){var rayoe=ray.origin,rayoeX=rayoe.x,rayoeY=rayoe.y,rayoeZ=rayoe.z,rayde=ray.direction,raydeX=rayde.x,raydeY=rayde.y,raydeZ=rayde.z,boxMine=box.min,boxMineX=boxMine.x,boxMineY=boxMine.y,boxMineZ=boxMine.z,boxMaxe=box.max,boxMaxeX=boxMaxe.x,boxMaxeY=boxMaxe.y,boxMaxeZ=boxMaxe.z,out=0,tmax=MathUtils3D.MaxValue;if(MathUtils3D.isZero(raydeX)){if(rayoeXboxMaxeX)return-1}else{var inverse=1/raydeX,t1=(boxMineX-rayoeX)*inverse,t2=(boxMaxeX-rayoeX)*inverse;if(t1>t2){var temp=t1;t1=t2,t2=temp}if((out=Math.max(t1,out))>(tmax=Math.min(t2,tmax)))return-1}if(MathUtils3D.isZero(raydeY)){if(rayoeYboxMaxeY)return-1}else{var inverse1=1/raydeY,t3=(boxMineY-rayoeY)*inverse1,t4=(boxMaxeY-rayoeY)*inverse1;if(t3>t4){var temp1=t3;t3=t4,t4=temp1}if((out=Math.max(t3,out))>(tmax=Math.min(t4,tmax)))return-1}if(MathUtils3D.isZero(raydeZ)){if(rayoeZboxMaxeZ)return-1}else{var inverse2=1/raydeZ,t5=(boxMineZ-rayoeZ)*inverse2,t6=(boxMaxeZ-rayoeZ)*inverse2;if(t5>t6){var temp2=t5;t5=t6,t6=temp2}if((out=Math.max(t5,out))>(tmax=Math.min(t6,tmax)))return-1}return out}static intersectsRayAndBoxRP(ray,box,out){var distance=CollisionUtils.intersectsRayAndBoxRD(ray,box);return-1===distance?(Vector3._ZERO.cloneTo(out),distance):(Vector3.scale(ray.direction,distance,CollisionUtils._tempV30),Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31),CollisionUtils._tempV31.cloneTo(out),distance)}static intersectsRayAndSphereRD(ray,sphere){var sphereR=sphere.radius;Vector3.subtract(ray.origin,sphere.center,CollisionUtils._tempV30);var b=Vector3.dot(CollisionUtils._tempV30,ray.direction),c=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-sphereR*sphereR;if(c>0&&b>0)return-1;var discriminant=b*b-c;if(discriminant<0)return-1;var distance=-b-Math.sqrt(discriminant);return distance<0&&(distance=0),distance}static intersectsRayAndSphereRP(ray,sphere,out){var distance=CollisionUtils.intersectsRayAndSphereRD(ray,sphere);return-1===distance?(Vector3._ZERO.cloneTo(out),distance):(Vector3.scale(ray.direction,distance,CollisionUtils._tempV30),Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31),CollisionUtils._tempV31.cloneTo(out),distance)}static intersectsSphereAndTriangle(sphere,vertex1,vertex2,vertex3){var sphereC=sphere.center,sphereR=sphere.radius;return CollisionUtils.closestPointPointTriangle(sphereC,vertex1,vertex2,vertex3,CollisionUtils._tempV30),Vector3.subtract(CollisionUtils._tempV30,sphereC,CollisionUtils._tempV31),Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV31)<=sphereR*sphereR}static intersectsPlaneAndPoint(plane,point){var distance=Vector3.dot(plane.normal,point)+plane.distance;return distance>0?Plane.PlaneIntersectionType_Front:distance<0?Plane.PlaneIntersectionType_Back:Plane.PlaneIntersectionType_Intersecting}static intersectsPlaneAndPlane(plane1,plane2){Vector3.cross(plane1.normal,plane2.normal,CollisionUtils._tempV30);var denominator=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30);return!MathUtils3D.isZero(denominator)}static intersectsPlaneAndPlaneRL(plane1,plane2,line){var plane1nor=plane1.normal,plane2nor=plane2.normal;Vector3.cross(plane1nor,plane2nor,CollisionUtils._tempV34);var denominator=Vector3.dot(CollisionUtils._tempV34,CollisionUtils._tempV34);return!MathUtils3D.isZero(denominator)&&(Vector3.scale(plane2nor,plane1.distance,CollisionUtils._tempV30),Vector3.scale(plane1nor,plane2.distance,CollisionUtils._tempV31),Vector3.subtract(CollisionUtils._tempV30,CollisionUtils._tempV31,CollisionUtils._tempV32),Vector3.cross(CollisionUtils._tempV32,CollisionUtils._tempV34,CollisionUtils._tempV33),Vector3.normalize(CollisionUtils._tempV34,CollisionUtils._tempV34),!0)}static intersectsPlaneAndBox(plane,box){var planeD=plane.distance,planeNor=plane.normal,planeNoreX=planeNor.x,planeNoreY=planeNor.y,planeNoreZ=planeNor.z,boxMine=box.min,boxMineX=boxMine.x,boxMineY=boxMine.y,boxMineZ=boxMine.z,boxMaxe=box.max,boxMaxeX=boxMaxe.x,boxMaxeY=boxMaxe.y,boxMaxeZ=boxMaxe.z;CollisionUtils._tempV30.x=planeNoreX>0?boxMineX:boxMaxeX,CollisionUtils._tempV30.y=planeNoreY>0?boxMineY:boxMaxeY,CollisionUtils._tempV30.z=planeNoreZ>0?boxMineZ:boxMaxeZ,CollisionUtils._tempV31.x=planeNoreX>0?boxMaxeX:boxMineX,CollisionUtils._tempV31.y=planeNoreY>0?boxMaxeY:boxMineY,CollisionUtils._tempV31.z=planeNoreZ>0?boxMaxeZ:boxMineZ;var distance=Vector3.dot(planeNor,CollisionUtils._tempV30);return distance+planeD>0?Plane.PlaneIntersectionType_Front:(distance=Vector3.dot(planeNor,CollisionUtils._tempV31))+planeD<0?Plane.PlaneIntersectionType_Back:Plane.PlaneIntersectionType_Intersecting}static intersectsPlaneAndSphere(plane,sphere){var sphereR=sphere.radius,distance=Vector3.dot(plane.normal,sphere.center)+plane.distance;return distance>sphereR?Plane.PlaneIntersectionType_Front:distance<-sphereR?Plane.PlaneIntersectionType_Back:Plane.PlaneIntersectionType_Intersecting}static intersectsBoxAndBox(box1,box2){var box1Mine=box1.min,box1Maxe=box1.max,box2Mine=box2.min,box2Maxe=box2.max;return!(box1Mine.x>box2Maxe.x||box2Mine.x>box1Maxe.x)&&(!(box1Mine.y>box2Maxe.y||box2Mine.y>box1Maxe.y)&&!(box1Mine.z>box2Maxe.z||box2Mine.z>box1Maxe.z))}static intersectsBoxAndSphere(box,sphere){var sphereC=sphere.center,sphereR=sphere.radius;return Vector3.Clamp(sphereC,box.min,box.max,CollisionUtils._tempV30),Vector3.distanceSquared(sphereC,CollisionUtils._tempV30)<=sphereR*sphereR}static intersectsSphereAndSphere(sphere1,sphere2){var radiisum=sphere1.radius+sphere2.radius;return Vector3.distanceSquared(sphere1.center,sphere2.center)<=radiisum*radiisum}static boxContainsPoint(box,point){var boxMine=box.min,boxMaxe=box.max;return boxMine.x<=point.x&&boxMaxe.x>=point.x&&boxMine.y<=point.y&&boxMaxe.y>=point.y&&boxMine.z<=point.z&&boxMaxe.z>=point.z?ContainmentType.Contains:ContainmentType.Disjoint}static boxContainsBox(box1,box2){var box1Mine=box1.min,box1MineX=box1Mine.x,box1MineY=box1Mine.y,box1MineZ=box1Mine.z,box1Maxe=box1.max,box1MaxeX=box1Maxe.x,box1MaxeY=box1Maxe.y,box1MaxeZ=box1Maxe.z,box2Mine=box2.min,box2MineX=box2Mine.x,box2MineY=box2Mine.y,box2MineZ=box2Mine.z,box2Maxe=box2.max,box2MaxeX=box2Maxe.x,box2MaxeY=box2Maxe.y,box2MaxeZ=box2Maxe.z;return box1MaxeXbox2MaxeX?ContainmentType.Disjoint:box1MaxeYbox2MaxeY?ContainmentType.Disjoint:box1MaxeZbox2MaxeZ?ContainmentType.Disjoint:box1MineX<=box2MineX&&box2MaxeX<=box1MaxeX&&box1MineY<=box2MineY&&box2MaxeY<=box1MaxeY&&box1MineZ<=box2MineZ&&box2MaxeZ<=box1MaxeZ?ContainmentType.Contains:ContainmentType.Intersects}static boxContainsSphere(box,sphere){var boxMin=box.min,boxMineX=boxMin.x,boxMineY=boxMin.y,boxMineZ=boxMin.z,boxMax=box.max,boxMaxeX=boxMax.x,boxMaxeY=boxMax.y,boxMaxeZ=boxMax.z,sphereC=sphere.center,sphereCeX=sphereC.x,sphereCeY=sphereC.y,sphereCeZ=sphereC.z,sphereR=sphere.radius;return Vector3.Clamp(sphereC,boxMin,boxMax,CollisionUtils._tempV30),Vector3.distanceSquared(sphereC,CollisionUtils._tempV30)>sphereR*sphereR?ContainmentType.Disjoint:boxMineX+sphereR<=sphereCeX&&sphereCeX<=boxMaxeX-sphereR&&boxMaxeX-boxMineX>sphereR&&boxMineY+sphereR<=sphereCeY&&sphereCeY<=boxMaxeY-sphereR&&boxMaxeY-boxMineY>sphereR&&boxMineZ+sphereR<=sphereCeZ&&sphereCeZ<=boxMaxeZ-sphereR&&boxMaxeZ-boxMineZ>sphereR?ContainmentType.Contains:ContainmentType.Intersects}static sphereContainsPoint(sphere,point){return Vector3.distanceSquared(point,sphere.center)<=sphere.radius*sphere.radius?ContainmentType.Contains:ContainmentType.Disjoint}static sphereContainsTriangle(sphere,vertex1,vertex2,vertex3){var test1=CollisionUtils.sphereContainsPoint(sphere,vertex1),test2=CollisionUtils.sphereContainsPoint(sphere,vertex2),test3=CollisionUtils.sphereContainsPoint(sphere,vertex3);return test1==ContainmentType.Contains&&test2==ContainmentType.Contains&&test3==ContainmentType.Contains?ContainmentType.Contains:CollisionUtils.intersectsSphereAndTriangle(sphere,vertex1,vertex2,vertex3)?ContainmentType.Intersects:ContainmentType.Disjoint}static sphereContainsBox(sphere,box){var sphereC=sphere.center,sphereCeX=sphereC.x,sphereCeY=sphereC.y,sphereCeZ=sphereC.z,sphereR=sphere.radius,boxMin=box.min,boxMineX=boxMin.x,boxMineY=boxMin.y,boxMineZ=boxMin.z,boxMax=box.max,boxMaxeX=boxMax.x,boxMaxeY=boxMax.y,boxMaxeZ=boxMax.z,_tempV30e=CollisionUtils._tempV30;_tempV30e.x,_tempV30e.y,_tempV30e.z;if(!CollisionUtils.intersectsBoxAndSphere(box,sphere))return ContainmentType.Disjoint;var radiusSquared=sphereR*sphereR;return sphereCeX-boxMineX,sphereCeY-boxMaxeY,sphereCeZ-boxMaxeZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:(sphereCeX-boxMaxeX,sphereCeY-boxMaxeY,sphereCeZ-boxMaxeZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:(sphereCeX-boxMaxeX,sphereCeY-boxMineY,sphereCeZ-boxMaxeZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:(sphereCeX-boxMineX,sphereCeY-boxMineY,sphereCeZ-boxMaxeZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:(sphereCeX-boxMineX,sphereCeY-boxMaxeY,sphereCeZ-boxMineZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:(sphereCeX-boxMaxeX,sphereCeY-boxMaxeY,sphereCeZ-boxMineZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:(sphereCeX-boxMaxeX,sphereCeY-boxMineY,sphereCeZ-boxMineZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:(sphereCeX-boxMineX,sphereCeY-boxMineY,sphereCeZ-boxMineZ,Vector3.scalarLengthSquared(CollisionUtils._tempV30)>radiusSquared?ContainmentType.Intersects:ContainmentType.Contains)))))))}static sphereContainsSphere(sphere1,sphere2){var sphere1R=sphere1.radius,sphere2R=sphere2.radius,distance=Vector3.distance(sphere1.center,sphere2.center);return sphere1R+sphere2R=0&&d4<=d3)vertex2.cloneTo(out);else{var vc=d1*d4-d3*d2;if(vc<=0&&d1>=0&&d3<=0){var v=d1/(d1-d3);return Vector3.scale(CollisionUtils._tempV30,v,out),void Vector3.add(vertex1,out,out)}if(d6>=0&&d5<=d6)vertex3.cloneTo(out);else{var vb=d5*d2-d1*d6;if(vb<=0&&d2>=0&&d6<=0){var w=d2/(d2-d6);return Vector3.scale(CollisionUtils._tempV31,w,out),void Vector3.add(vertex1,out,out)}var va=d3*d6-d5*d4;if(va<=0&&d4-d3>=0&&d5-d6>=0){var w3=(d4-d3)/(d4-d3+(d5-d6));return Vector3.subtract(vertex3,vertex2,out),Vector3.scale(out,w3,out),void Vector3.add(vertex2,out,out)}var denom=1/(va+vb+vc),v2=vb*denom,w2=vc*denom;Vector3.scale(CollisionUtils._tempV30,v2,CollisionUtils._tempV35),Vector3.scale(CollisionUtils._tempV31,w2,CollisionUtils._tempV36),Vector3.add(CollisionUtils._tempV35,CollisionUtils._tempV36,out),Vector3.add(vertex1,out,out)}}}static closestPointPlanePoint(plane,point,out){var planeN=plane.normal,t=Vector3.dot(planeN,point)-plane.distance;Vector3.scale(planeN,t,CollisionUtils._tempV30),Vector3.subtract(point,CollisionUtils._tempV30,out)}static closestPointBoxPoint(box,point,out){Vector3.max(point,box.min,CollisionUtils._tempV30),Vector3.min(CollisionUtils._tempV30,box.max,out)}static closestPointSpherePoint(sphere,point,out){var sphereC=sphere.center;Vector3.subtract(point,sphereC,out),Vector3.normalize(out,out),Vector3.scale(out,sphere.radius,out),Vector3.add(out,sphereC,out)}static closestPointSphereSphere(sphere1,sphere2,out){var sphere1C=sphere1.center;Vector3.subtract(sphere2.center,sphere1C,out),Vector3.normalize(out,out),Vector3.scale(out,sphere1.radius,out),Vector3.add(out,sphere1C,out)}}CollisionUtils._tempV30=new Vector3,CollisionUtils._tempV31=new Vector3,CollisionUtils._tempV32=new Vector3,CollisionUtils._tempV33=new Vector3,CollisionUtils._tempV34=new Vector3,CollisionUtils._tempV35=new Vector3,CollisionUtils._tempV36=new Vector3;class BoundFrustum{constructor(matrix){this._matrix=matrix,this._near=new Plane(new Vector3),this._far=new Plane(new Vector3),this._left=new Plane(new Vector3),this._right=new Plane(new Vector3),this._top=new Plane(new Vector3),this._bottom=new Plane(new Vector3),BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get matrix(){return this._matrix}set matrix(matrix){this._matrix=matrix,BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get near(){return this._near}get far(){return this._far}get left(){return this._left}get right(){return this._right}get top(){return this._top}get bottom(){return this._bottom}equalsBoundFrustum(other){return this._matrix.equalsOtherMatrix(other.matrix)}equalsObj(obj){if(obj instanceof BoundFrustum){var bf=obj;return this.equalsBoundFrustum(bf)}return!1}getPlane(index){switch(index){case 0:return this._near;case 1:return this._far;case 2:return this._left;case 3:return this._right;case 4:return this._top;case 5:return this._bottom;default:return null}}static _getPlanesFromMatrix(m,np,fp,lp,rp,tp,bp){var matrixE=m.elements,m11=matrixE[0],m12=matrixE[1],m13=matrixE[2],m14=matrixE[3],m21=matrixE[4],m22=matrixE[5],m23=matrixE[6],m24=matrixE[7],m31=matrixE[8],m32=matrixE[9],m33=matrixE[10],m34=matrixE[11],m41=matrixE[12],m42=matrixE[13],m43=matrixE[14],m44=matrixE[15],nearNorE=np.normal;nearNorE.x=m14+m13,nearNorE.y=m24+m23,nearNorE.z=m34+m33,np.distance=m44+m43,np.normalize();var farNorE=fp.normal;farNorE.x=m14-m13,farNorE.y=m24-m23,farNorE.z=m34-m33,fp.distance=m44-m43,fp.normalize();var leftNorE=lp.normal;leftNorE.x=m14+m11,leftNorE.y=m24+m21,leftNorE.z=m34+m31,lp.distance=m44+m41,lp.normalize();var rightNorE=rp.normal;rightNorE.x=m14-m11,rightNorE.y=m24-m21,rightNorE.z=m34-m31,rp.distance=m44-m41,rp.normalize();var topNorE=tp.normal;topNorE.x=m14-m12,topNorE.y=m24-m22,topNorE.z=m34-m32,tp.distance=m44-m42,tp.normalize();var bottomNorE=bp.normal;bottomNorE.x=m14+m12,bottomNorE.y=m24+m22,bottomNorE.z=m34+m32,bp.distance=m44+m42,bp.normalize()}static _get3PlaneInterPoint(p1,p2,p3){var p1Nor=p1.normal,p2Nor=p2.normal,p3Nor=p3.normal;Vector3.cross(p2Nor,p3Nor,BoundFrustum._tempV30),Vector3.cross(p3Nor,p1Nor,BoundFrustum._tempV31),Vector3.cross(p1Nor,p2Nor,BoundFrustum._tempV32);var a=Vector3.dot(p1Nor,BoundFrustum._tempV30),b=Vector3.dot(p2Nor,BoundFrustum._tempV31),c=Vector3.dot(p3Nor,BoundFrustum._tempV32);return Vector3.scale(BoundFrustum._tempV30,-p1.distance/a,BoundFrustum._tempV33),Vector3.scale(BoundFrustum._tempV31,-p2.distance/b,BoundFrustum._tempV34),Vector3.scale(BoundFrustum._tempV32,-p3.distance/c,BoundFrustum._tempV35),Vector3.add(BoundFrustum._tempV33,BoundFrustum._tempV34,BoundFrustum._tempV36),Vector3.add(BoundFrustum._tempV35,BoundFrustum._tempV36,BoundFrustum._tempV37),BoundFrustum._tempV37}getCorners(corners){BoundFrustum._get3PlaneInterPoint(this._near,this._bottom,this._right).cloneTo(corners[0]),BoundFrustum._get3PlaneInterPoint(this._near,this._top,this._right).cloneTo(corners[1]),BoundFrustum._get3PlaneInterPoint(this._near,this._top,this._left).cloneTo(corners[2]),BoundFrustum._get3PlaneInterPoint(this._near,this._bottom,this._left).cloneTo(corners[3]),BoundFrustum._get3PlaneInterPoint(this._far,this._bottom,this._right).cloneTo(corners[4]),BoundFrustum._get3PlaneInterPoint(this._far,this._top,this._right).cloneTo(corners[5]),BoundFrustum._get3PlaneInterPoint(this._far,this._top,this._left).cloneTo(corners[6]),BoundFrustum._get3PlaneInterPoint(this._far,this._bottom,this._left).cloneTo(corners[7])}containsPoint(point){for(var result=Plane.PlaneIntersectionType_Front,planeResult=Plane.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:planeResult=CollisionUtils.intersectsPlaneAndPoint(this._near,point);break;case 1:planeResult=CollisionUtils.intersectsPlaneAndPoint(this._far,point);break;case 2:planeResult=CollisionUtils.intersectsPlaneAndPoint(this._left,point);break;case 3:planeResult=CollisionUtils.intersectsPlaneAndPoint(this._right,point);break;case 4:planeResult=CollisionUtils.intersectsPlaneAndPoint(this._top,point);break;case 5:planeResult=CollisionUtils.intersectsPlaneAndPoint(this._bottom,point)}switch(planeResult){case Plane.PlaneIntersectionType_Back:return ContainmentType.Disjoint;case Plane.PlaneIntersectionType_Intersecting:result=Plane.PlaneIntersectionType_Intersecting}}switch(result){case Plane.PlaneIntersectionType_Intersecting:return ContainmentType.Intersects;default:return ContainmentType.Contains}}intersects(box){var min=box.min,max=box.max,minX=min.x,minY=min.y,minZ=min.z,maxX=max.x,maxY=max.y,maxZ=max.z,nearNormal=this._near.normal;if(this._near.distance+nearNormal.x*(nearNormal.x<0?minX:maxX)+nearNormal.y*(nearNormal.y<0?minY:maxY)+nearNormal.z*(nearNormal.z<0?minZ:maxZ)<0)return!1;var leftNormal=this._left.normal;if(this._left.distance+leftNormal.x*(leftNormal.x<0?minX:maxX)+leftNormal.y*(leftNormal.y<0?minY:maxY)+leftNormal.z*(leftNormal.z<0?minZ:maxZ)<0)return!1;var rightNormal=this._right.normal;if(this._right.distance+rightNormal.x*(rightNormal.x<0?minX:maxX)+rightNormal.y*(rightNormal.y<0?minY:maxY)+rightNormal.z*(rightNormal.z<0?minZ:maxZ)<0)return!1;var bottomNormal=this._bottom.normal;if(this._bottom.distance+bottomNormal.x*(bottomNormal.x<0?minX:maxX)+bottomNormal.y*(bottomNormal.y<0?minY:maxY)+bottomNormal.z*(bottomNormal.z<0?minZ:maxZ)<0)return!1;var topNormal=this._top.normal;if(this._top.distance+topNormal.x*(topNormal.x<0?minX:maxX)+topNormal.y*(topNormal.y<0?minY:maxY)+topNormal.z*(topNormal.z<0?minZ:maxZ)<0)return!1;var farNormal=this._far.normal;return!(this._far.distance+farNormal.x*(farNormal.x<0?minX:maxX)+farNormal.y*(farNormal.y<0?minY:maxY)+farNormal.z*(farNormal.z<0?minZ:maxZ)<0)}containsBoundBox(box){for(var p=BoundFrustum._tempV30,n=BoundFrustum._tempV31,boxMin=box.min,boxMax=box.max,result=ContainmentType.Contains,i=0;i<6;i++){var plane=this.getPlane(i),planeNor=plane.normal;if(planeNor.x>=0?(p.x=boxMax.x,n.x=boxMin.x):(p.x=boxMin.x,n.x=boxMax.x),planeNor.y>=0?(p.y=boxMax.y,n.y=boxMin.y):(p.y=boxMin.y,n.y=boxMax.y),planeNor.z>=0?(p.z=boxMax.z,n.z=boxMin.z):(p.z=boxMin.z,n.z=boxMax.z),CollisionUtils.intersectsPlaneAndPoint(plane,p)===Plane.PlaneIntersectionType_Back)return ContainmentType.Disjoint;CollisionUtils.intersectsPlaneAndPoint(plane,n)===Plane.PlaneIntersectionType_Back&&(result=ContainmentType.Intersects)}return result}containsBoundSphere(sphere){for(var result=Plane.PlaneIntersectionType_Front,planeResult=Plane.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:planeResult=CollisionUtils.intersectsPlaneAndSphere(this._near,sphere);break;case 1:planeResult=CollisionUtils.intersectsPlaneAndSphere(this._far,sphere);break;case 2:planeResult=CollisionUtils.intersectsPlaneAndSphere(this._left,sphere);break;case 3:planeResult=CollisionUtils.intersectsPlaneAndSphere(this._right,sphere);break;case 4:planeResult=CollisionUtils.intersectsPlaneAndSphere(this._top,sphere);break;case 5:planeResult=CollisionUtils.intersectsPlaneAndSphere(this._bottom,sphere)}switch(planeResult){case Plane.PlaneIntersectionType_Back:return ContainmentType.Disjoint;case Plane.PlaneIntersectionType_Intersecting:result=Plane.PlaneIntersectionType_Intersecting}}switch(result){case Plane.PlaneIntersectionType_Intersecting:return ContainmentType.Intersects;default:return ContainmentType.Contains}}}BoundFrustum._tempV30=new Vector3,BoundFrustum._tempV31=new Vector3,BoundFrustum._tempV32=new Vector3,BoundFrustum._tempV33=new Vector3,BoundFrustum._tempV34=new Vector3,BoundFrustum._tempV35=new Vector3,BoundFrustum._tempV36=new Vector3,BoundFrustum._tempV37=new Vector3;class Viewport{constructor(x,y,width,height){this.minDepth=0,this.maxDepth=1,this.x=x,this.y=y,this.width=width,this.height=height}project(source,matrix,out){Vector3.transformV3ToV3(source,matrix,out);var matrixEleme=matrix.elements,a=source.x*matrixEleme[3]+source.y*matrixEleme[7]+source.z*matrixEleme[11]+matrixEleme[15];1!==a&&(out.x=out.x/a,out.y=out.y/a,out.z=out.z/a),out.x=.5*(out.x+1)*this.width+this.x,out.y=.5*(1-out.y)*this.height+this.y,out.z=out.z*(this.maxDepth-this.minDepth)+this.minDepth}unprojectFromMat(source,matrix,out){var matrixEleme=matrix.elements;out.x=(source.x-this.x)/this.width*2-1,out.y=-((source.y-this.y)/this.height*2-1);var halfDepth=(this.maxDepth-this.minDepth)/2;out.z=(source.z-this.minDepth-halfDepth)/halfDepth;var a=out.x*matrixEleme[3]+out.y*matrixEleme[7]+out.z*matrixEleme[11]+matrixEleme[15];Vector3.transformV3ToV3(out,matrix,out),1!==a&&(out.x=out.x/a,out.y=out.y/a,out.z=out.z/a)}unprojectFromWVP(source,projection,view,world,out){Matrix4x4.multiply(projection,view,Viewport._tempMatrix4x4),world&&Matrix4x4.multiply(Viewport._tempMatrix4x4,world,Viewport._tempMatrix4x4),Viewport._tempMatrix4x4.invert(Viewport._tempMatrix4x4),this.unprojectFromMat(source,Viewport._tempMatrix4x4,out)}cloneTo(out){out.x=this.x,out.y=this.y,out.width=this.width,out.height=this.height,out.minDepth=this.minDepth,out.maxDepth=this.maxDepth}}Viewport._tempMatrix4x4=new Matrix4x4;class RenderTexture extends Laya.BaseTexture{constructor(width,height,format=Laya.BaseTexture.FORMAT_R8G8B8,depthStencilFormat=Laya.BaseTexture.FORMAT_DEPTH_16){super(format,!1),this._inPool=!1,this._glTextureType=Laya.LayaGL.instance.TEXTURE_2D,this._width=width,this._height=height,this._depthStencilFormat=depthStencilFormat,this._create(width,height)}static get currentActive(){return RenderTexture._currentActive}static createFromPool(width,height,format=Laya.BaseTexture.FORMAT_R8G8B8,depthStencilFormat=Laya.BaseTexture.FORMAT_DEPTH_16,filterMode=Laya.BaseTexture.FILTERMODE_BILINEAR){for(var tex,i=0,n=RenderTexture._pool.length;i-Number.MIN_VALUE&&determinant1)return Number.NaN;var triangleV,rayDistance,distanceCrossEdge1=Picker._tempVector34;return Vector3.cross(distanceVector,edge1,distanceCrossEdge1),triangleV=Vector3.dot(ray.direction,distanceCrossEdge1),(triangleV*=inverseDeterminant)<0||triangleU+triangleV>1?Number.NaN:(rayDistance=Vector3.dot(edge2,distanceCrossEdge1),(rayDistance*=inverseDeterminant)<0?Number.NaN:rayDistance)}}Picker._tempVector30=new Vector3,Picker._tempVector31=new Vector3,Picker._tempVector32=new Vector3,Picker._tempVector33=new Vector3,Picker._tempVector34=new Vector3;class SkyMesh{constructor(){}_render(state){}}class SkyBox extends SkyMesh{static __init__(){SkyBox.instance=new SkyBox}constructor(){super();var gl=Laya.LayaGL.instance,vertices=new Float32Array([-1,1,-1,1,1,-1,1,1,1,-1,1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1]),indices=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]),verDec=VertexMesh.getVertexDeclaration("POSITION");this._vertexBuffer=new VertexBuffer3D(8*verDec.vertexStride,gl.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=verDec,this._indexBuffer=new IndexBuffer3D(IndexBuffer3D.INDEXTYPE_UBYTE,36,gl.STATIC_DRAW,!1),this._vertexBuffer.setData(vertices.buffer),this._indexBuffer.setData(indices);var bufferState=new BufferState;bufferState.bind(),bufferState.applyVertexBuffer(this._vertexBuffer),bufferState.applyIndexBuffer(this._indexBuffer),bufferState.unBind(),this._bufferState=bufferState}_render(state){var gl=Laya.LayaGL.instance;gl.drawElements(gl.TRIANGLES,36,gl.UNSIGNED_BYTE,0),Laya.Stat.trianglesFaces+=12,Laya.Stat.renderBatches++}}class SkyRenderer{constructor(){this._mesh=SkyBox.instance}get material(){return this._material}set material(value){this._material!==value&&(this._material&&this._material._removeReference(),value&&value._addReference(),this._material=value)}get mesh(){return this._mesh}set mesh(value){this._mesh!==value&&(this._mesh=value)}_isAvailable(){return!(!this._material||!this._mesh)}_render(state){if(this._material&&this._mesh){var gl=Laya.LayaGL.instance,scene=state.scene,camera=state.camera,noteValue=ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_;Laya.ILaya.Render.supportWebGLPlusRendering&&ShaderData.setRuntimeValueMode(!1),Laya.WebGLContext.setCullFace(gl,!1),Laya.WebGLContext.setDepthFunc(gl,gl.LEQUAL),Laya.WebGLContext.setDepthMask(gl,!1);var shader=state.shader=this._material._shader.getSubShaderAt(0)._passes[0].withCompile(0,0,this._material._shaderValues._defineDatas.value),switchShader=shader.bind(),switchShaderLoop=Laya.Stat.loopCount!==shader._uploadMark,uploadScene=shader._uploadScene!==scene||switchShaderLoop;(uploadScene||switchShader)&&(shader.uploadUniforms(shader._sceneUniformParamsMap,scene._shaderValues,uploadScene),shader._uploadScene=scene);var renderTar=camera._renderTexture||camera._offScreenRenderTexture,uploadCamera=shader._uploadCamera!==camera||switchShaderLoop;if(uploadCamera||switchShader){var viewMatrix=SkyRenderer._tempMatrix0,projectionMatrix=camera.projectionMatrix;camera.transform.worldMatrix.cloneTo(viewMatrix),viewMatrix.transpose(),camera.orthographic&&(projectionMatrix=SkyRenderer._tempMatrix1,Matrix4x4.createPerspective(camera.fieldOfView,camera.aspectRatio,camera.nearPlane,camera.farPlane,projectionMatrix)),camera._applyViewProject(state,viewMatrix,projectionMatrix,!!renderTar),shader.uploadUniforms(shader._cameraUniformParamsMap,camera._shaderValues,uploadCamera),shader._uploadCamera=camera}var uploadMaterial=shader._uploadMaterial!==this._material||switchShaderLoop;(uploadMaterial||switchShader)&&(shader.uploadUniforms(shader._materialUniformParamsMap,this._material._shaderValues,uploadMaterial),shader._uploadMaterial=this._material),this._mesh._bufferState.bind(),this._mesh._render(state),Laya.ILaya.Render.supportWebGLPlusRendering&&ShaderData.setRuntimeValueMode(noteValue),Laya.WebGLContext.setDepthFunc(gl,gl.LESS),Laya.WebGLContext.setDepthMask(gl,!0),camera._applyViewProject(state,camera.viewMatrix,camera.projectionMatrix,!!renderTar)}}destroy(){this._material&&(this._material._removeReference(),this._material=null)}}SkyRenderer._tempMatrix0=new Matrix4x4,SkyRenderer._tempMatrix1=new Matrix4x4;class BaseCamera extends Sprite3D{constructor(nearPlane=.3,farPlane=1e3){super(),this._skyRenderer=new SkyRenderer,this._forward=new Vector3,this._up=new Vector3,this.clearColor=new Vector4(100/255,149/255,237/255,1),this._shaderValues=new ShaderData(null),this._fieldOfView=60,this._useUserProjectionMatrix=!1,this._orthographic=!1,this._orthographicVerticalSize=10,this.renderingOrder=0,this._nearPlane=nearPlane,this._farPlane=farPlane,this.cullingMask=2147483647,this.clearFlag=BaseCamera.CLEARFLAG_SOLIDCOLOR,this.useOcclusionCulling=!0}get skyRenderer(){return this._skyRenderer}get fieldOfView(){return this._fieldOfView}set fieldOfView(value){this._fieldOfView=value,this._calculateProjectionMatrix()}get nearPlane(){return this._nearPlane}set nearPlane(value){this._nearPlane=value,this._calculateProjectionMatrix()}get farPlane(){return this._farPlane}set farPlane(vaule){this._farPlane=vaule,this._calculateProjectionMatrix()}get orthographic(){return this._orthographic}set orthographic(vaule){this._orthographic=vaule,this._calculateProjectionMatrix()}get orthographicVerticalSize(){return this._orthographicVerticalSize}set orthographicVerticalSize(vaule){this._orthographicVerticalSize=vaule,this._calculateProjectionMatrix()}get renderingOrder(){return this._renderingOrder}set renderingOrder(value){this._renderingOrder=value,this._sortCamerasByRenderingOrder()}_sortCamerasByRenderingOrder(){if(this.displayedInStage)for(var cameraPool=this.scene._cameraPool,n=cameraPool.length-1,i=0;icameraPool[n].renderingOrder){var tempCamera=cameraPool[i];cameraPool[i]=cameraPool[n],cameraPool[n]=tempCamera}}_calculateProjectionMatrix(){}_onScreenSizeChanged(){this._calculateProjectionMatrix()}_prepareCameraToRender(){var cameraSV=this._shaderValues;this.transform.getForward(this._forward),this.transform.getUp(this._up),cameraSV.setVector3(BaseCamera.CAMERAPOS,this.transform.position),cameraSV.setVector3(BaseCamera.CAMERADIRECTION,this._forward),cameraSV.setVector3(BaseCamera.CAMERAUP,this._up)}render(shader=null,replacementTag=null){}addLayer(layer){this.cullingMask|=Math.pow(2,layer)}removeLayer(layer){this.cullingMask&=~Math.pow(2,layer)}addAllLayers(){this.cullingMask=2147483647}removeAllLayers(){this.cullingMask=0}resetProjectionMatrix(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()}_onActive(){this._scene._addCamera(this),super._onActive()}_onInActive(){this._scene._removeCamera(this),super._onInActive()}_parse(data,spriteMap){super._parse(data,spriteMap);var clearFlagData=data.clearFlag;void 0!==clearFlagData&&(this.clearFlag=clearFlagData),this.orthographic=data.orthographic,void 0!==data.orthographicVerticalSize&&(this.orthographicVerticalSize=data.orthographicVerticalSize),void 0!==data.fieldOfView&&(this.fieldOfView=data.fieldOfView),this.nearPlane=data.nearPlane,this.farPlane=data.farPlane;var color=data.clearColor;this.clearColor=new Vector4(color[0],color[1],color[2],color[3]);var skyboxMaterial=data.skyboxMaterial;skyboxMaterial&&(this._skyRenderer.material=Laya.Loader.getRes(skyboxMaterial.path))}destroy(destroyChild=!0){this._skyRenderer.destroy(),this._skyRenderer=null,Laya.Laya.stage.off(Laya.Event.RESIZE,this,this._onScreenSizeChanged),super.destroy(destroyChild)}_create(){return new BaseCamera}}BaseCamera._tempMatrix4x40=new Matrix4x4,BaseCamera.CAMERAPOS=Shader3D.propertyNameToID("u_CameraPos"),BaseCamera.VIEWMATRIX=Shader3D.propertyNameToID("u_View"),BaseCamera.PROJECTMATRIX=Shader3D.propertyNameToID("u_Projection"),BaseCamera.VIEWPROJECTMATRIX=Shader3D.propertyNameToID("u_ViewProjection"),BaseCamera.CAMERADIRECTION=Shader3D.propertyNameToID("u_CameraDirection"),BaseCamera.CAMERAUP=Shader3D.propertyNameToID("u_CameraUp"),BaseCamera.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",BaseCamera.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",BaseCamera.CLEARFLAG_SOLIDCOLOR=0,BaseCamera.CLEARFLAG_SKY=1,BaseCamera.CLEARFLAG_DEPTHONLY=2,BaseCamera.CLEARFLAG_NONE=3,BaseCamera._invertYScaleMatrix=new Matrix4x4(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1),BaseCamera._invertYProjectionMatrix=new Matrix4x4,BaseCamera._invertYProjectionViewMatrix=new Matrix4x4;class RenderContext3D{constructor(){}}RenderContext3D._instance=new RenderContext3D;class ScreenQuad extends Laya.Resource{constructor(){super(),this._bufferState=new BufferState,this._bufferStateInvertUV=new BufferState;var gl=Laya.LayaGL.instance;this._vertexBuffer=new VertexBuffer3D(64,gl.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=ScreenQuad._vertexDeclaration,this._vertexBuffer.setData(ScreenQuad._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new VertexBuffer3D(64,gl.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=ScreenQuad._vertexDeclaration,this._vertexBufferInvertUV.setData(ScreenQuad._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){ScreenQuad._vertexDeclaration=new VertexDeclaration(16,[new VertexElement(0,VertexElementFormat.Vector4,ScreenQuad.SCREENQUAD_POSITION_UV)]),ScreenQuad.instance=new ScreenQuad,ScreenQuad.instance.lock=!0}render(){var gl=Laya.LayaGL.instance;this._bufferState.bind(),gl.drawArrays(gl.TRIANGLE_STRIP,0,4),Laya.Stat.renderBatches++}renderInvertUV(){var gl=Laya.LayaGL.instance;this._bufferStateInvertUV.bind(),gl.drawArrays(gl.TRIANGLE_STRIP,0,4),Laya.Stat.renderBatches++}destroy(){super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferStateInvertUV.destroy(),this._vertexBufferInvertUV.destroy(),this._setGPUMemory(0)}}ScreenQuad.SCREENQUAD_POSITION_UV=0,ScreenQuad._vertices=new Float32Array([1,1,1,0,1,-1,1,1,-1,1,0,0,-1,-1,0,1]),ScreenQuad._verticesInvertUV=new Float32Array([1,1,1,1,1,-1,1,0,-1,1,0,1,-1,-1,0,0]);class ScreenTriangle extends Laya.Resource{constructor(){super(),this._bufferState=new BufferState,this._bufferStateInvertUV=new BufferState;var gl=Laya.LayaGL.instance;this._vertexBuffer=new VertexBuffer3D(48,gl.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=ScreenTriangle._vertexDeclaration,this._vertexBuffer.setData(ScreenTriangle._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new VertexBuffer3D(48,gl.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=ScreenTriangle._vertexDeclaration,this._vertexBufferInvertUV.setData(ScreenTriangle._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){ScreenTriangle._vertexDeclaration=new VertexDeclaration(16,[new VertexElement(0,VertexElementFormat.Vector4,ScreenTriangle.SCREENTRIANGLE_POSITION_UV)]),ScreenTriangle.instance=new ScreenTriangle,ScreenTriangle.instance.lock=!0}render(){var gl=Laya.LayaGL.instance;this._bufferState.bind(),gl.drawArrays(gl.TRIANGLES,0,3),Laya.Stat.renderBatches++}renderInvertUV(){var gl=Laya.LayaGL.instance;this._bufferStateInvertUV.bind(),gl.drawArrays(gl.TRIANGLES,0,3),Laya.Stat.renderBatches++}destroy(){super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferStateInvertUV.destroy(),this._vertexBufferInvertUV.destroy(),this._setGPUMemory(0)}}ScreenTriangle.SCREENTRIANGLE_POSITION_UV=0,ScreenTriangle._vertices=new Float32Array([-1,-1,0,1,-1,3,0,-1,3,-1,2,1]),ScreenTriangle._verticesInvertUV=new Float32Array([-1,-1,0,0,-1,3,0,2,3,-1,2,0]);class Command{constructor(){this._commandBuffer=null}static __init__(){Command._screenShaderData=new ShaderData,Command._screenShader=Shader3D.find("BlitScreen")}run(){}recover(){this._commandBuffer=null}}Command.SCREENTEXTURE_NAME="u_MainTex",Command.MAINTEXTURE_TEXELSIZE_NAME="u_MainTex_TexelSize",Command.SCREENTEXTURE_ID=Shader3D.propertyNameToID(Command.SCREENTEXTURE_NAME),Command.MAINTEXTURE_TEXELSIZE_ID=Shader3D.propertyNameToID(Command.MAINTEXTURE_TEXELSIZE_NAME);class BlitScreenQuadCMD extends Command{constructor(){super(...arguments),this._source=null,this._dest=null,this._shader=null,this._shaderData=null,this._subShader=0,this._sourceTexelSize=new Vector4,this._screenType=0}static create(source,dest,shader=null,shaderData=null,subShader=0,screenType=BlitScreenQuadCMD._SCREENTYPE_QUAD){var cmd;return(cmd=BlitScreenQuadCMD._pool.length>0?BlitScreenQuadCMD._pool.pop():new BlitScreenQuadCMD)._source=source,cmd._dest=dest,cmd._shader=shader,cmd._shaderData=shaderData,cmd._subShader=subShader,cmd._screenType=screenType,cmd}run(){var shader=this._shader||Command._screenShader,shaderData=this._shaderData||Command._screenShaderData,dest=this._dest;Laya.LayaGL.instance.viewport(0,0,dest?dest.width:RenderContext3D.clientWidth,dest?dest.height:RenderContext3D.clientHeight),shaderData.setTexture(Command.SCREENTEXTURE_ID,this._source),this._sourceTexelSize.setValue(1/this._source.width,1/this._source.height,this._source.width,this._source.height),shaderData.setVector(Command.MAINTEXTURE_TEXELSIZE_ID,this._sourceTexelSize),dest&&dest._start();for(var passes=shader.getSubShaderAt(this._subShader)._passes,i=0,n=passes.length;i0?SetRenderTargetCMD._pool.pop():new SetRenderTargetCMD)._renderTexture=renderTexture,cmd}run(){this._renderTexture._start()}recover(){SetRenderTargetCMD._pool.push(this),this._renderTexture=null}}SetRenderTargetCMD._pool=[];class SetShaderDataTextureCMD extends Command{constructor(){super(...arguments),this._shaderData=null,this._nameID=0,this._texture=null}static create(shaderData,nameID,texture){var cmd;return(cmd=SetShaderDataTextureCMD._pool.length>0?SetShaderDataTextureCMD._pool.pop():new SetShaderDataTextureCMD)._shaderData=shaderData,cmd._nameID=nameID,cmd._texture=texture,cmd}run(){this._shaderData.setTexture(this._nameID,this._texture)}recover(){SetShaderDataTextureCMD._pool.push(this),this._shaderData=null,this._nameID=0,this._texture=null}}SetShaderDataTextureCMD._pool=[];class CommandBuffer{constructor(){this._camera=null,this._commands=[]}_apply(){for(var i=0,n=this._commands.length;i=.5?Math.floor(lx):ceilLeftX,pixelLeftY=ceilLeftY-ly>=.5?Math.floor(ly):ceilLeftY,pixelRightX=rx-floorRightX>=.5?Math.ceil(rx):floorRightX,pixelRightY=ry-floorRightY>=.5?Math.ceil(ry):floorRightY;this._viewport.x=pixelLeftX,this._viewport.y=pixelLeftY,this._viewport.width=pixelRightX-pixelLeftX,this._viewport.height=pixelRightY-pixelLeftY}_parse(data,spriteMap){super._parse(data,spriteMap);var viewport=data.viewport;this.normalizedViewport=new Viewport(viewport[0],viewport[1],viewport[2],viewport[3]);var enableHDR=data.enableHDR;void 0!==enableHDR&&(this.enableHDR=enableHDR)}_calculateProjectionMatrix(){if(!this._useUserProjectionMatrix)if(this._orthographic){var halfWidth=this.orthographicVerticalSize*this.aspectRatio*.5,halfHeight=.5*this.orthographicVerticalSize;Matrix4x4.createOrthoOffCenter(-halfWidth,halfWidth,-halfHeight,halfHeight,this.nearPlane,this.farPlane,this._projectionMatrix)}else Matrix4x4.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix)}_getCanvasHeight(){return this._offScreenRenderTexture?this._offScreenRenderTexture.height:RenderContext3D.clientHeight}_applyPostProcessCommandBuffers(){for(var i=0,n=this._postProcessCommandBuffers.length;i1,dynBatVerCount=multiSubMesh?subMesh._indexCount:mesh._vertexCount;if(dynBatVerCount<=ILaya3D.SubMeshDynamicBatch.maxAllowVertexCount){var length=3*dynBatVerCount;this._dynamicVertexBatch=!0,this._dynamicWorldPositions=new Float32Array(length),this._dynamicWorldNormals=new Float32Array(length),this._dynamicVertexCount=dynBatVerCount,this._dynamicMultiSubMesh=multiSubMesh}else this._dynamicVertexBatch=!1}this._geometry=geometry}}addToOpaqueRenderQueue(context,queue){var subMeshStaticBatch=this.staticBatch,queueElements=queue.elements,elements=queueElements.elements;if(subMeshStaticBatch){var staManager=ILaya3D.MeshRenderStaticBatchManager.instance,staBatchMarks=staManager.getBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,subMeshStaticBatch._batchID);if(staManager._updateCountMark===staBatchMarks.updateMark){var staBatchIndex=staBatchMarks.indexInList;if(staBatchMarks.batched)elements[staBatchIndex].staticBatchElementList.add(this);else{var staOriElement=elements[staBatchIndex],staOriRender=staOriElement.render,staBatchElement=staManager._getBatchRenderElementFromPool();staBatchElement.renderType=RenderElement.RENDERTYPE_STATICBATCH,staBatchElement.setGeometry(subMeshStaticBatch),staBatchElement.material=staOriElement.material;var staRootOwner=subMeshStaticBatch.batchOwner,staBatchTransform=staRootOwner?staRootOwner._transform:null;staBatchElement.setTransform(staBatchTransform),staBatchElement.render=staOriRender,staBatchElement.renderSubShader=staOriElement.renderSubShader;var staBatchList=staBatchElement.staticBatchElementList;staBatchList.length=0,staBatchList.add(staOriElement),staBatchList.add(this),elements[staBatchIndex]=staBatchElement,staBatchMarks.batched=!0}}else staBatchMarks.updateMark=staManager._updateCountMark,staBatchMarks.indexInList=queueElements.length,staBatchMarks.batched=!1,queueElements.add(this)}else if(this.renderSubShader._owner._enableInstancing&&Laya.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0){var subMesh=this._geometry,insManager=ILaya3D.MeshRenderDynamicBatchManager.instance,insBatchMarks=insManager.getInstanceBatchOpaquaMark(this.render.receiveShadow,this.material.id,subMesh._id,this._transform._isFrontFaceInvert);if(insManager._updateCountMark===insBatchMarks.updateMark){var insBatchIndex=insBatchMarks.indexInList;if(insBatchMarks.batched){var instanceBatchElementList=elements[insBatchIndex].instanceBatchElementList;instanceBatchElementList.length===SubMeshInstanceBatch.instance.maxInstanceCount?(insBatchMarks.updateMark=insManager._updateCountMark,insBatchMarks.indexInList=queueElements.length,insBatchMarks.batched=!1,queueElements.add(this)):instanceBatchElementList.add(this)}else{var insOriElement=elements[insBatchIndex],insOriRender=insOriElement.render,insBatchElement=insManager._getBatchRenderElementFromPool();insBatchElement.renderType=RenderElement.RENDERTYPE_INSTANCEBATCH,insBatchElement.setGeometry(SubMeshInstanceBatch.instance),insBatchElement.material=insOriElement.material,insBatchElement.setTransform(null),insBatchElement.render=insOriRender,insBatchElement.instanceSubMesh=subMesh,insBatchElement.renderSubShader=insOriElement.renderSubShader;var insBatchList=insBatchElement.instanceBatchElementList;insBatchList.length=0,insBatchList.add(insOriElement),insBatchList.add(this),elements[insBatchIndex]=insBatchElement,insBatchMarks.batched=!0}}else insBatchMarks.updateMark=insManager._updateCountMark,insBatchMarks.indexInList=queueElements.length,insBatchMarks.batched=!1,queueElements.add(this)}else if(this._dynamicVertexBatch){var verDec=this._geometry._vertexBuffer.vertexDeclaration,dynManager=ILaya3D.MeshRenderDynamicBatchManager.instance,dynBatchMarks=dynManager.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,verDec.id);if(dynManager._updateCountMark===dynBatchMarks.updateMark){var dynBatchIndex=dynBatchMarks.indexInList;if(dynBatchMarks.batched)elements[dynBatchIndex].vertexBatchElementList.add(this);else{var dynOriElement=elements[dynBatchIndex],dynOriRender=dynOriElement.render,dynBatchElement=dynManager._getBatchRenderElementFromPool();dynBatchElement.renderType=RenderElement.RENDERTYPE_VERTEXBATCH,dynBatchElement.setGeometry(ILaya3D.SubMeshDynamicBatch.instance),dynBatchElement.material=dynOriElement.material,dynBatchElement.setTransform(null),dynBatchElement.render=dynOriRender,dynBatchElement.vertexBatchVertexDeclaration=verDec,dynBatchElement.renderSubShader=dynOriElement.renderSubShader;var dynBatchList=dynBatchElement.vertexBatchElementList;dynBatchList.length=0,dynBatchList.add(dynOriElement),dynBatchList.add(this),elements[dynBatchIndex]=dynBatchElement,dynBatchMarks.batched=!0}}else dynBatchMarks.updateMark=dynManager._updateCountMark,dynBatchMarks.indexInList=queueElements.length,dynBatchMarks.batched=!1,queueElements.add(this)}else queueElements.add(this)}addToTransparentRenderQueue(context,queue){var subMeshStaticBatch=this.staticBatch,queueElements=queue.elements,elements=queueElements.elements;if(subMeshStaticBatch){var staManager=ILaya3D.MeshRenderStaticBatchManager.instance,staLastElement=queue.lastTransparentRenderElement;if(staLastElement){var staLastRender=staLastElement.render;if(staLastElement._geometry._getType()!==this._geometry._getType()||staLastElement.staticBatch!==subMeshStaticBatch||staLastElement.material!==this.material||staLastRender.receiveShadow!==this.render.receiveShadow||staLastRender.lightmapIndex!==this.render.lightmapIndex)queueElements.add(this),queue.lastTransparentBatched=!1;else{if(queue.lastTransparentBatched)elements[queueElements.length-1].staticBatchElementList.add(this);else{var staBatchElement=staManager._getBatchRenderElementFromPool();staBatchElement.renderType=RenderElement.RENDERTYPE_STATICBATCH,staBatchElement.setGeometry(subMeshStaticBatch),staBatchElement.material=staLastElement.material;var staRootOwner=subMeshStaticBatch.batchOwner,staBatchTransform=staRootOwner?staRootOwner._transform:null;staBatchElement.setTransform(staBatchTransform),staBatchElement.render=this.render,staBatchElement.renderSubShader=staLastElement.renderSubShader;var staBatchList=staBatchElement.staticBatchElementList;staBatchList.length=0,staBatchList.add(staLastElement),staBatchList.add(this),elements[queueElements.length-1]=staBatchElement}queue.lastTransparentBatched=!0}}else queueElements.add(this),queue.lastTransparentBatched=!1}else if(this.renderSubShader._owner._enableInstancing&&Laya.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0){var subMesh=this._geometry,insManager=ILaya3D.MeshRenderDynamicBatchManager.instance,insLastElement=queue.lastTransparentRenderElement;if(insLastElement){var insLastRender=insLastElement.render;if(insLastElement._geometry._getType()!==this._geometry._getType()||insLastElement._geometry!==subMesh||insLastElement.material!==this.material||insLastRender.receiveShadow!==this.render.receiveShadow)queueElements.add(this),queue.lastTransparentBatched=!1;else if(queue.lastTransparentBatched){var instanceBatchElementList=elements[queueElements.length-1].instanceBatchElementList;instanceBatchElementList.length===SubMeshInstanceBatch.instance.maxInstanceCount?(queueElements.add(this),queue.lastTransparentBatched=!1):(instanceBatchElementList.add(this),queue.lastTransparentBatched=!0)}else{var insBatchElement=insManager._getBatchRenderElementFromPool();insBatchElement.renderType=RenderElement.RENDERTYPE_INSTANCEBATCH,insBatchElement.setGeometry(SubMeshInstanceBatch.instance),insBatchElement.material=insLastElement.material,insBatchElement.setTransform(null),insBatchElement.render=this.render,insBatchElement.instanceSubMesh=subMesh,insBatchElement.renderSubShader=insLastElement.renderSubShader;var insBatchList=insBatchElement.instanceBatchElementList;insBatchList.length=0,insBatchList.add(insLastElement),insBatchList.add(this),elements[queueElements.length-1]=insBatchElement,queue.lastTransparentBatched=!0}}else queueElements.add(this),queue.lastTransparentBatched=!1}else if(this._dynamicVertexBatch){var verDec=this._geometry._vertexBuffer.vertexDeclaration,dynManager=ILaya3D.MeshRenderDynamicBatchManager.instance,dynLastElement=queue.lastTransparentRenderElement;if(dynLastElement){var dynLastRender=dynLastElement.render;if(dynLastElement._geometry._getType()!==this._geometry._getType()||dynLastElement._geometry._vertexBuffer._vertexDeclaration!==verDec||dynLastElement.material!==this.material||dynLastRender.receiveShadow!==this.render.receiveShadow||dynLastRender.lightmapIndex!==this.render.lightmapIndex)queueElements.add(this),queue.lastTransparentBatched=!1;else{if(queue.lastTransparentBatched)elements[queueElements.length-1].vertexBatchElementList.add(this);else{var dynBatchElement=dynManager._getBatchRenderElementFromPool();dynBatchElement.renderType=RenderElement.RENDERTYPE_VERTEXBATCH,dynBatchElement.setGeometry(ILaya3D.SubMeshDynamicBatch.instance),dynBatchElement.material=dynLastElement.material,dynBatchElement.setTransform(null),dynBatchElement.render=this.render,dynBatchElement.vertexBatchVertexDeclaration=verDec,dynBatchElement.renderSubShader=dynLastElement.renderSubShader;var dynBatchList=dynBatchElement.vertexBatchElementList;dynBatchList.length=0,dynBatchList.add(dynLastElement),dynBatchList.add(this),elements[queueElements.length-1]=dynBatchElement}queue.lastTransparentBatched=!0}}else queueElements.add(this),queue.lastTransparentBatched=!1}else queueElements.add(this);queue.lastTransparentRenderElement=this}getInvertFront(){switch(this.renderType){case RenderElement.RENDERTYPE_NORMAL:return this._transform._isFrontFaceInvert;case RenderElement.RENDERTYPE_STATICBATCH:case RenderElement.RENDERTYPE_VERTEXBATCH:return!1;case RenderElement.RENDERTYPE_INSTANCEBATCH:return this.instanceBatchElementList.elements[0]._transform._isFrontFaceInvert;default:throw"SubMeshRenderElement: unknown renderType"}}destroy(){super.destroy(),this._dynamicWorldPositions=null,this._dynamicWorldNormals=null,this.staticBatch=null,this.staticBatchElementList=null,this.vertexBatchElementList=null,this.vertexBatchVertexDeclaration=null}}class SingletonList{constructor(){this.elements=[],this.length=0}_add(element){this.length===this.elements.length?this.elements.push(element):this.elements[this.length]=element}add(element){this.length===this.elements.length?this.elements.push(element):this.elements[this.length]=element,this.length++}}class MeshRenderDynamicBatchManager extends DynamicBatchManager{constructor(){super(),this._instanceBatchOpaqueMarks=[],this._vertexBatchOpaqueMarks=[],this._cacheBufferStates=[],this._updateCountMark=0}getInstanceBatchOpaquaMark(receiveShadow,materialID,subMeshID,invertFace){var instanceReceiveShadowMarks=this._instanceBatchOpaqueMarks[receiveShadow?0:1]||(this._instanceBatchOpaqueMarks[receiveShadow?0:1]=[]),instanceMaterialMarks=instanceReceiveShadowMarks[materialID]||(instanceReceiveShadowMarks[materialID]=[]),instancSubMeshMarks=instanceMaterialMarks[subMeshID]||(instanceMaterialMarks[subMeshID]=[]);return instancSubMeshMarks[invertFace?1:0]||(instancSubMeshMarks[invertFace?1:0]=new BatchMark)}getVertexBatchOpaquaMark(lightMapIndex,receiveShadow,materialID,verDecID){var dynLightMapMarks=this._vertexBatchOpaqueMarks[lightMapIndex]||(this._vertexBatchOpaqueMarks[lightMapIndex]=[]),dynReceiveShadowMarks=dynLightMapMarks[receiveShadow?0:1]||(dynLightMapMarks[receiveShadow?0:1]=[]),dynMaterialMarks=dynReceiveShadowMarks[materialID]||(dynReceiveShadowMarks[materialID]=[]);return dynMaterialMarks[verDecID]||(dynMaterialMarks[verDecID]=new BatchMark)}_getBufferState(vertexDeclaration){var bufferState=this._cacheBufferStates[vertexDeclaration.id];if(!bufferState){var instance=SubMeshDynamicBatch.instance;(bufferState=new BufferState).bind();var vertexBuffer=instance._vertexBuffer;vertexBuffer.vertexDeclaration=vertexDeclaration,bufferState.applyVertexBuffer(vertexBuffer),bufferState.applyIndexBuffer(instance._indexBuffer),bufferState.unBind(),this._cacheBufferStates[vertexDeclaration.id]=bufferState}return bufferState}_getBatchRenderElementFromPool(){var renderElement=this._batchRenderElementPool[this._batchRenderElementPoolIndex++];return renderElement||(renderElement=new SubMeshRenderElement,this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=renderElement,renderElement.vertexBatchElementList=new SingletonList,renderElement.instanceBatchElementList=new SingletonList),renderElement}_clear(){super._clear(),this._updateCountMark++}}MeshRenderDynamicBatchManager.instance=new MeshRenderDynamicBatchManager;class SubMeshStaticBatch extends GeometryElement{constructor(batchOwner,number,vertexDeclaration){super(),this._bufferState=new BufferState,this._batchID=SubMeshStaticBatch._batchIDCounter++,this._batchElements=[],this._currentBatchVertexCount=0,this._currentBatchIndexCount=0,this._vertexDeclaration=vertexDeclaration,this.batchOwner=batchOwner,this.number=number}_getStaticBatchBakedVertexs(batchVertices,batchOffset,batchOwnerTransform,transform,render,mesh){var worldMat,vertexBuffer=mesh._vertexBuffer,vertexDeclaration=vertexBuffer.vertexDeclaration,positionOffset=vertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_POSITION0)._offset/4,normalElement=vertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_NORMAL0),normalOffset=normalElement?normalElement._offset/4:-1,colorElement=vertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_COLOR0),colorOffset=colorElement?colorElement._offset/4:-1,uv0Element=vertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_TEXTURECOORDINATE0),uv0Offset=uv0Element?uv0Element._offset/4:-1,uv1Element=vertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_TEXTURECOORDINATE1),uv1Offset=uv1Element?uv1Element._offset/4:-1,tangentElement=vertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_TANGENT0),sTangentOffset=tangentElement?tangentElement._offset/4:-1,oriVertexFloatCount=vertexDeclaration.vertexStride/4,oriVertexes=vertexBuffer.getFloat32Data();batchOwnerTransform?(batchOwnerTransform.worldMatrix.invert(SubMeshStaticBatch._tempMatrix4x40),worldMat=SubMeshStaticBatch._tempMatrix4x41,Matrix4x4.multiply(SubMeshStaticBatch._tempMatrix4x40,transform.worldMatrix,worldMat)):worldMat=transform.worldMatrix;var rotation=SubMeshStaticBatch._tempQuaternion0;worldMat.decomposeTransRotScale(SubMeshStaticBatch._tempVector30,rotation,SubMeshStaticBatch._tempVector31);for(var lightmapScaleOffset=render.lightmapScaleOffset,vertexCount=mesh.vertexCount,i=0;iSubMeshStaticBatch.maxBatchVertexCount)}add(sprite){var oldStaticBatch=sprite._render._staticBatch;oldStaticBatch&&oldStaticBatch.remove(sprite);var mesh=sprite.meshFilter.sharedMesh,subMeshVertexCount=mesh.vertexCount;this._batchElements.push(sprite);var render=sprite._render;render._isPartOfStaticBatch=!0,render._staticBatch=this;for(var renderElements=render._renderElements,i=0,n=renderElements.length;i0&&btColObj.setCollisionFlags(flags^PhysicsComponent.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK)}_onAdded(){this.enabled=this._enabled,this.restitution=this._restitution,this.friction=this._friction,this.rollingFriction=this._rollingFriction,this.ccdMotionThreshold=this._ccdMotionThreshold,this.ccdSweptSphereRadius=this._ccdSweptSphereRadius,this.owner.transform.on(Laya.Event.TRANSFORM_CHANGED,this,this._onTransformChanged)}_onDestroy(){var physics3D=Physics3D._physics3D;delete PhysicsComponent._physicObjectsMap[this.id],physics3D.destroy(this._nativeColliderObject),this._colliderShape.destroy(),super._onDestroy(),this._nativeColliderObject=null,this._colliderShape=null,this._simulation=null,this.owner.transform.off(Laya.Event.TRANSFORM_CHANGED,this,this._onTransformChanged)}_onTransformChanged(flag){PhysicsComponent._addUpdateList&&(flag&=Transform3D.TRANSFORM_WORLDPOSITION|Transform3D.TRANSFORM_WORLDQUATERNION|Transform3D.TRANSFORM_WORLDSCALE)&&(this._transformFlag|=flag,this._isValid()&&-1===this._inPhysicUpdateListIndex&&this._simulation._physicsUpdateList.add(this))}_cloneTo(dest){var destPhysicsComponent=dest;destPhysicsComponent.restitution=this._restitution,destPhysicsComponent.friction=this._friction,destPhysicsComponent.rollingFriction=this._rollingFriction,destPhysicsComponent.ccdMotionThreshold=this._ccdMotionThreshold,destPhysicsComponent.ccdSweptSphereRadius=this._ccdSweptSphereRadius,destPhysicsComponent.collisionGroup=this._collisionGroup,destPhysicsComponent.canCollideWith=this._canCollideWith,destPhysicsComponent.canScaleShape=this.canScaleShape,this._colliderShape&&(destPhysicsComponent.colliderShape=this._colliderShape.clone())}}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._tempVector30=new Vector3,PhysicsComponent._tempQuaternion0=new Quaternion,PhysicsComponent._tempQuaternion1=new Quaternion,PhysicsComponent._tempMatrix4x40=new Matrix4x4,PhysicsComponent._physicObjectsMap={},PhysicsComponent._addUpdateList=!0;class PhysicsUpdateList extends SingletonList{constructor(){super()}add(element){if(-1!==element._inPhysicUpdateListIndex)throw"PhysicsUpdateList:element has in PhysicsUpdateList.";this._add(element),element._inPhysicUpdateListIndex=this.length++}remove(element){var index=element._inPhysicUpdateListIndex;if(this.length--,index!==this.length){var end=this.elements[this.length];this.elements[index]=end,end._inPhysicUpdateListIndex=index}element._inPhysicUpdateListIndex=-1}}class ContactPoint{constructor(){this._idCounter=0,this.colliderA=null,this.colliderB=null,this.distance=0,this.normal=new Vector3,this.positionOnA=new Vector3,this.positionOnB=new Vector3,this._id=++this._idCounter}}class HitResult{constructor(){this.succeeded=!1,this.collider=null,this.point=new Vector3,this.normal=new Vector3,this.hitFraction=0}}class Collision{constructor(){this._lastUpdateFrame=-2147483648,this._updateFrame=-2147483648,this._isTrigger=!1,this.contacts=[]}_setUpdateFrame(farme){this._lastUpdateFrame=this._updateFrame,this._updateFrame=farme}}class CollisionTool{constructor(){this._hitResultsPoolIndex=0,this._hitResultsPool=[],this._contactPonintsPoolIndex=0,this._contactPointsPool=[],this._collisionsPool=[],this._collisions={}}getHitResult(){var hitResult=this._hitResultsPool[this._hitResultsPoolIndex++];return hitResult||(hitResult=new HitResult,this._hitResultsPool.push(hitResult)),hitResult}recoverAllHitResultsPool(){this._hitResultsPoolIndex=0}getContactPoints(){var contactPoint=this._contactPointsPool[this._contactPonintsPoolIndex++];return contactPoint||(contactPoint=new ContactPoint,this._contactPointsPool.push(contactPoint)),contactPoint}recoverAllContactPointsPool(){this._contactPonintsPoolIndex=0}getCollision(physicComponentA,physicComponentB){var collision,idA=physicComponentA.id,idB=physicComponentB.id,subCollisionFirst=this._collisions[idA];return subCollisionFirst&&(collision=subCollisionFirst[idB]),collision||(subCollisionFirst||(subCollisionFirst={},this._collisions[idA]=subCollisionFirst),(collision=0===this._collisionsPool.length?new Collision:this._collisionsPool.pop())._colliderA=physicComponentA,collision._colliderB=physicComponentB,subCollisionFirst[idB]=collision),collision}recoverCollision(collision){var idA=collision._colliderA.id,idB=collision._colliderB.id;this._collisions[idA][idB]=null,this._collisionsPool.push(collision)}garbageCollection(){for(var subCollisionsKey in this._hitResultsPoolIndex=0,this._hitResultsPool.length=0,this._contactPonintsPoolIndex=0,this._contactPointsPool.length=0,this._collisionsPool.length=0,this._collisionsPool){var subCollisions=this._collisionsPool[subCollisionsKey],wholeDelete=!0;for(var collisionKey in subCollisions)subCollisions[collisionKey]?wholeDelete=!1:delete subCollisions[collisionKey];wholeDelete&&delete this._collisionsPool[subCollisionsKey]}}}class PhysicsSimulation{constructor(configuration,flags=0){this._gravity=new Vector3(0,-10,0),this._nativeVector3Zero=new Physics3D._physics3D.btVector3(0,0,0),this._nativeDefaultQuaternion=new Physics3D._physics3D.btQuaternion(0,0,0,-1),this._collisionsUtils=new CollisionTool,this._previousFrameCollisions=[],this._currentFrameCollisions=[],this._physicsUpdateList=new PhysicsUpdateList,this._characters=[],this._updatedRigidbodies=0,this.maxSubSteps=1,this.fixedTimeStep=1/60,this.maxSubSteps=configuration.maxSubSteps,this.fixedTimeStep=configuration.fixedTimeStep;var physics3D=Physics3D._physics3D;this._nativeCollisionConfiguration=new physics3D.btDefaultCollisionConfiguration,this._nativeDispatcher=new physics3D.btCollisionDispatcher(this._nativeCollisionConfiguration),this._nativeBroadphase=new physics3D.btDbvtBroadphase,this._nativeBroadphase.getOverlappingPairCache().setInternalGhostPairCallback(new physics3D.btGhostPairCallback);var conFlags=configuration.flags;if(conFlags&PhysicsSimulation.PHYSICSENGINEFLAGS_COLLISIONSONLY)this._nativeCollisionWorld=new physics3D.btCollisionWorld(this._nativeDispatcher,this._nativeBroadphase,this._nativeCollisionConfiguration);else{if(conFlags&PhysicsSimulation.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT)throw"PhysicsSimulation:SoftBody processing is not yet available";var solver=new physics3D.btSequentialImpulseConstraintSolver;this._nativeDiscreteDynamicsWorld=new physics3D.btDiscreteDynamicsWorld(this._nativeDispatcher,this._nativeBroadphase,solver,this._nativeCollisionConfiguration),this._nativeCollisionWorld=this._nativeDiscreteDynamicsWorld}this._nativeDiscreteDynamicsWorld&&(this._nativeSolverInfo=this._nativeDiscreteDynamicsWorld.getSolverInfo(),this._nativeDispatchInfo=this._nativeDiscreteDynamicsWorld.getDispatchInfo()),this._nativeClosestRayResultCallback=new physics3D.ClosestRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeAllHitsRayResultCallback=new physics3D.AllHitsRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeClosestConvexResultCallback=new physics3D.ClosestConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeAllConvexResultCallback=new physics3D.AllConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),physics3D._btGImpactCollisionAlgorithm_RegisterAlgorithm(this._nativeDispatcher.a)}static __init__(){PhysicsSimulation._nativeTempVector30=new Physics3D._physics3D.btVector3(0,0,0),PhysicsSimulation._nativeTempVector31=new Physics3D._physics3D.btVector3(0,0,0),PhysicsSimulation._nativeTempQuaternion0=new Physics3D._physics3D.btQuaternion(0,0,0,1),PhysicsSimulation._nativeTempQuaternion1=new Physics3D._physics3D.btQuaternion(0,0,0,1),PhysicsSimulation._nativeTempTransform0=new Physics3D._physics3D.btTransform,PhysicsSimulation._nativeTempTransform1=new Physics3D._physics3D.btTransform}static createConstraint(){}get continuousCollisionDetection(){return this._nativeDispatchInfo.get_m_useContinuous()}set continuousCollisionDetection(value){this._nativeDispatchInfo.set_m_useContinuous(value)}get gravity(){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";return this._gravity}set gravity(value){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._gravity=value;var nativeGravity=PhysicsSimulation._nativeTempVector30;nativeGravity.setValue(-value.x,value.y,value.z),this._nativeDiscreteDynamicsWorld.setGravity(nativeGravity)}get speculativeContactRestitution(){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";return this._nativeDiscreteDynamicsWorld.getApplySpeculativeContactRestitution()}set speculativeContactRestitution(value){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeDiscreteDynamicsWorld.setApplySpeculativeContactRestitution(value)}_simulate(deltaTime){this._updatedRigidbodies=0,this._nativeDiscreteDynamicsWorld?this._nativeDiscreteDynamicsWorld.stepSimulation(deltaTime,this.maxSubSteps,this.fixedTimeStep):this._nativeCollisionWorld.PerformDiscreteCollisionDetection()}_destroy(){var physics3D=Physics3D._physics3D;this._nativeDiscreteDynamicsWorld?(physics3D.destroy(this._nativeDiscreteDynamicsWorld),this._nativeDiscreteDynamicsWorld=null):(physics3D.destroy(this._nativeCollisionWorld),this._nativeCollisionWorld=null),physics3D.destroy(this._nativeBroadphase),this._nativeBroadphase=null,physics3D.destroy(this._nativeDispatcher),this._nativeDispatcher=null,physics3D.destroy(this._nativeCollisionConfiguration),this._nativeCollisionConfiguration=null}_addPhysicsCollider(component,group,mask){this._nativeCollisionWorld.addCollisionObject(component._nativeColliderObject,group,mask)}_removePhysicsCollider(component){this._nativeCollisionWorld.removeCollisionObject(component._nativeColliderObject)}_addRigidBody(rigidBody,group,mask){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.addRigidBody(rigidBody._nativeColliderObject,group,mask)}_removeRigidBody(rigidBody){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.removeRigidBody(rigidBody._nativeColliderObject)}_addCharacter(character,group,mask){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.addCollisionObject(character._nativeColliderObject,group,mask),this._nativeCollisionWorld.addAction(character._nativeKinematicCharacter)}_removeCharacter(character){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.removeCollisionObject(character._nativeColliderObject),this._nativeCollisionWorld.removeAction(character._nativeKinematicCharacter)}raycastFromTo(from,to,out=null,collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER,collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER){var rayResultCall=this._nativeClosestRayResultCallback,rayFrom=PhysicsSimulation._nativeTempVector30,rayTo=PhysicsSimulation._nativeTempVector31;if(rayFrom.setValue(-from.x,from.y,from.z),rayTo.setValue(-to.x,to.y,to.z),rayResultCall.set_m_rayFromWorld(rayFrom),rayResultCall.set_m_rayToWorld(rayTo),rayResultCall.set_m_collisionFilterGroup(collisonGroup),rayResultCall.set_m_collisionFilterMask(collisionMask),rayResultCall.set_m_collisionObject(null),rayResultCall.set_m_closestHitFraction(1),this._nativeCollisionWorld.rayTest(rayFrom,rayTo,rayResultCall),rayResultCall.hasHit()){if(out){out.succeeded=!0,out.collider=PhysicsComponent._physicObjectsMap[rayResultCall.get_m_collisionObject().getUserIndex()],out.hitFraction=rayResultCall.get_m_closestHitFraction();var nativePoint=rayResultCall.get_m_hitPointWorld(),point=out.point;point.x=-nativePoint.x(),point.y=nativePoint.y(),point.z=nativePoint.z();var nativeNormal=rayResultCall.get_m_hitNormalWorld(),normal=out.normal;normal.x=-nativeNormal.x(),normal.y=nativeNormal.y(),normal.z=nativeNormal.z()}return!0}return out&&(out.succeeded=!1),!1}raycastAllFromTo(from,to,out,collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER,collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER){var rayResultCall=this._nativeAllHitsRayResultCallback,rayFrom=PhysicsSimulation._nativeTempVector30,rayTo=PhysicsSimulation._nativeTempVector31;out.length=0,rayFrom.setValue(-from.x,from.y,from.z),rayTo.setValue(-to.x,to.y,to.z),rayResultCall.set_m_rayFromWorld(rayFrom),rayResultCall.set_m_rayToWorld(rayTo),rayResultCall.set_m_collisionFilterGroup(collisonGroup),rayResultCall.set_m_collisionFilterMask(collisionMask);var collisionObjects=rayResultCall.get_m_collisionObjects(),nativePoints=rayResultCall.get_m_hitPointWorld(),nativeNormals=rayResultCall.get_m_hitNormalWorld(),nativeFractions=rayResultCall.get_m_hitFractions();collisionObjects.clear(),nativePoints.clear(),nativeNormals.clear(),nativeFractions.clear(),this._nativeCollisionWorld.rayTest(rayFrom,rayTo,rayResultCall);var count=collisionObjects.size();if(count>0){this._collisionsUtils.recoverAllHitResultsPool();for(var i=0;i0){for(var nativePoints=convexResultCall.get_m_hitPointWorld(),nativeNormals=convexResultCall.get_m_hitNormalWorld(),nativeFractions=convexResultCall.get_m_hitFractions(),i=0;i=points.length)throw new Error("start"+start+"Must be in the range [0, "+(points.length-1)+"]");if(count<0||start+count>points.length)throw new Error("count"+count+"Must be in the range <= "+points.length+"}");var upperEnd=start+count,center=BoundSphere._tempVector3;center.x=0,center.y=0,center.z=0;for(var i=start;iradius&&(radius=distance)}out.radius=Math.sqrt(radius)}static createfromPoints(points,out){if(null==points)throw new Error("points");BoundSphere.createFromSubPoints(points,0,points.length,out)}intersectsRayDistance(ray){return CollisionUtils.intersectsRayAndSphereRD(ray,this)}intersectsRayPoint(ray,outPoint){return CollisionUtils.intersectsRayAndSphereRP(ray,this,outPoint)}cloneTo(destObject){var dest=destObject;this.center.cloneTo(dest.center),dest.radius=this.radius}clone(){var dest=new BoundSphere(new Vector3,0);return this.cloneTo(dest),dest}}BoundSphere._tempVector3=new Vector3;class ParallelSplitShadowMap{constructor(){var i;for(this._spiltDistance=[],this._currentPSSM=-1,this._shadowMapCount=3,this._maxDistance=200,this._ratioOfDistance=1/this._shadowMapCount,this._globalParallelLightDir=new Vector3(0,-1,0),this._statesDirty=!0,this._shadowMapTextureSize=1024,this._scene=null,this._boundingSphere=new Array(ParallelSplitShadowMap.MAX_PSSM_COUNT+1),this._boundingBox=new Array(ParallelSplitShadowMap.MAX_PSSM_COUNT+1),this._frustumPos=new Array(4*(ParallelSplitShadowMap.MAX_PSSM_COUNT+1)),this._uniformDistance=new Array(ParallelSplitShadowMap.MAX_PSSM_COUNT+1),this._logDistance=new Array(ParallelSplitShadowMap.MAX_PSSM_COUNT+1),this._dimension=new Array(ParallelSplitShadowMap.MAX_PSSM_COUNT+1),this._PCFType=0,this._tempLookAt3=new Vector3,this._tempLookAt4=new Vector4,this._tempValue=new Vector4,this._tempPos=new Vector3,this._tempLightUp=new Vector3,this._tempMin=new Vector4,this._tempMax=new Vector4,this._tempMatrix44=new Matrix4x4,this._splitFrustumCulling=new BoundFrustum(Matrix4x4.DEFAULT),this._tempScaleMatrix44=new Matrix4x4,this._shadowPCFOffset=new Vector2(1/1024,1/1024),this._shaderValueDistance=new Vector4,this._shaderValueLightVP=null,this.cameras=[],this._shaderValueVPs=[],i=0;iParallelSplitShadowMap.MAX_PSSM_COUNT&&(this._shadowMapCount=ParallelSplitShadowMap.MAX_PSSM_COUNT),this._scene=scene,this._maxDistance=maxDistance,this.shadowMapCount=numberOfPSSM,this._globalParallelLightDir=globalParallelDir,this._ratioOfDistance=1/this._shadowMapCount;for(var i=0;i0?value:1)<=ParallelSplitShadowMap.MAX_PSSM_COUNT?value:ParallelSplitShadowMap.MAX_PSSM_COUNT,this._shadowMapCount!=value){this._shadowMapCount=value,this._ratioOfDistance=1/this._shadowMapCount,this._statesDirty=!0,this._shaderValueLightVP=new Float32Array(16*value),this._shaderValueVPs.length=value;for(var i=0;ithis._shadowMapCount)throw new Error("ParallelSplitShadowMap: beginSample invalid index");this._currentPSSM=index,this._update(sceneCamera)}endSampler(sceneCamera){this._currentPSSM=-1}_calcAllLightCameraInfo(sceneCamera){if(1===this._shadowMapCount)this._beginSampler(0,sceneCamera),this.endSampler(sceneCamera);else for(var i=0,n=this._shadowMapCount+1;i0?Matrix4x4.createPerspective(3.1416*sceneCamera.fieldOfView/180,sceneCamera.aspectRatio,this._spiltDistance[this._currentPSSM-1],this._spiltDistance[this._currentPSSM],this._tempMatrix44):Matrix4x4.createPerspective(3.1416*sceneCamera.fieldOfView/180,sceneCamera.aspectRatio,this._spiltDistance[0],this._spiltDistance[this._shadowMapCount],this._tempMatrix44),Matrix4x4.multiply(this._tempMatrix44,sceneCamera.viewMatrix,this._tempMatrix44),this._splitFrustumCulling.matrix=this._tempMatrix44}_rebuildRenderInfo(){var i,nNum=this._shadowMapCount+1;for(this.cameras.length=nNum,i=0;itempMax.x?tempValueElement.x:tempMax.x,tempMax.y=tempValueElement.y>tempMax.y?tempValueElement.y:tempMax.y,tempMax.z=tempValueElement.z>tempMax.z?tempValueElement.z:tempMax.z}Vector4.add(this._tempMax,this._tempMin,this._tempValue),tempValueElement.x*=.5,tempValueElement.y*=.5,tempValueElement.z*=.5,tempValueElement.w=1,Vector4.transformByM4x4(this._tempValue,curLightCamera.transform.worldMatrix,this._tempValue);var distance=Math.abs(-this._tempMax.z),farPlane=distance>this._maxDistance?distance:this._maxDistance;Vector3.scale(this._globalParallelLightDir,farPlane,this._tempPos);var tempPosElement=this._tempPos;tempPosElement.x=tempValueElement.x-tempPosElement.x,tempPosElement.y=tempValueElement.y-tempPosElement.y,tempPosElement.z=tempValueElement.z-tempPosElement.z,curLightCamera.transform.position=this._tempPos,curLightCamera.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1),Matrix4x4.createOrthoOffCenter(tempMin.x,tempMax.x,tempMin.y,tempMax.y,1,farPlane+.5*(tempMax.z-tempMin.z),curLightCamera.projectionMatrix);var projectView=curLightCamera.projectionViewMatrix;ParallelSplitShadowMap.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,projectView,this._shaderValueVPs[this._currentPSSM]),this._scene._shaderValues.setBuffer(ILaya3D.Scene3D.SHADOWLIGHTVIEWPROJECT,this._shaderValueLightVP)}static multiplyMatrixOutFloat32Array(left,right,out){var i,a,b,ai0,ai1,ai2,ai3;for(a=left.elements,b=right.elements,i=0;i<4;i++)ai0=a[i],ai1=a[i+4],ai2=a[i+8],ai3=a[i+12],out[i]=ai0*b[0]+ai1*b[1]+ai2*b[2]+ai3*b[3],out[i+4]=ai0*b[4]+ai1*b[5]+ai2*b[6]+ai3*b[7],out[i+8]=ai0*b[8]+ai1*b[9]+ai2*b[10]+ai3*b[11],out[i+12]=ai0*b[12]+ai1*b[13]+ai2*b[14]+ai3*b[15]}setShadowMapTextureSize(size){size!==this._shadowMapTextureSize&&(this._shadowMapTextureSize=size,this._shadowPCFOffset.x=1/this._shadowMapTextureSize,this._shadowPCFOffset.y=1/this._shadowMapTextureSize,this._statesDirty=!0)}disposeAllRenderTarget(){for(var i=0,n=this._shadowMapCount+1;i0&&this._removeTetxureReference(),this._shaderValues=null}setShaderName(name){if(this._shader=Shader3D.find(name),!this._shader)throw new Error("BaseMaterial: unknown shader name.")}cloneTo(destObject){var destBaseMaterial=destObject;destBaseMaterial.name=this.name,destBaseMaterial.renderQueue=this.renderQueue,this._disablePublicDefineDatas.cloneTo(destBaseMaterial._disablePublicDefineDatas),this._shaderValues.cloneTo(destBaseMaterial._shaderValues)}clone(){var dest=new BaseMaterial;return this.cloneTo(dest),dest}get _defineDatas(){return this._shaderValues._defineDatas}}BaseMaterial.MATERIAL="MATERIAL",BaseMaterial.RENDERQUEUE_OPAQUE=2e3,BaseMaterial.RENDERQUEUE_ALPHATEST=2450,BaseMaterial.RENDERQUEUE_TRANSPARENT=3e3,BaseMaterial.ALPHATESTVALUE=Shader3D.propertyNameToID("u_AlphaTestValue"),BaseMaterial.shaderDefines=null;class RenderState{constructor(){this.cull=RenderState.CULL_BACK,this.blend=RenderState.BLEND_DISABLE,this.srcBlend=RenderState.BLENDPARAM_ONE,this.dstBlend=RenderState.BLENDPARAM_ZERO,this.srcBlendRGB=RenderState.BLENDPARAM_ONE,this.dstBlendRGB=RenderState.BLENDPARAM_ZERO,this.srcBlendAlpha=RenderState.BLENDPARAM_ONE,this.dstBlendAlpha=RenderState.BLENDPARAM_ZERO,this.blendConstColor=new Vector4(1,1,1,1),this.blendEquation=RenderState.BLENDEQUATION_ADD,this.blendEquationRGB=RenderState.BLENDEQUATION_ADD,this.blendEquationAlpha=RenderState.BLENDEQUATION_ADD,this.depthTest=RenderState.DEPTHTEST_LEQUAL,this.depthWrite=!0}cloneTo(dest){var destState=dest;destState.cull=this.cull,destState.blend=this.blend,destState.srcBlend=this.srcBlend,destState.dstBlend=this.dstBlend,destState.srcBlendRGB=this.srcBlendRGB,destState.dstBlendRGB=this.dstBlendRGB,destState.srcBlendAlpha=this.srcBlendAlpha,destState.dstBlendAlpha=this.dstBlendAlpha,this.blendConstColor.cloneTo(destState.blendConstColor),destState.blendEquation=this.blendEquation,destState.blendEquationRGB=this.blendEquationRGB,destState.blendEquationAlpha=this.blendEquationAlpha,destState.depthTest=this.depthTest,destState.depthWrite=this.depthWrite}clone(){var dest=new RenderState;return this.cloneTo(dest),dest}}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;class BlinnPhongMaterial extends BaseMaterial{constructor(){super(),this._enableVertexColor=!1,this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new Vector4(1,1,1,1);var sv=this._shaderValues;sv.setVector(BlinnPhongMaterial.ALBEDOCOLOR,new Vector4(1,1,1,1)),sv.setVector(BlinnPhongMaterial.MATERIALSPECULAR,new Vector4(1,1,1,1)),sv.setNumber(BlinnPhongMaterial.SHININESS,.078125),sv.setNumber(BaseMaterial.ALPHATESTVALUE,.5),sv.setVector(BlinnPhongMaterial.TILINGOFFSET,new Vector4(1,1,0,0)),this._enableLighting=!0,this.renderMode=BlinnPhongMaterial.RENDERMODE_OPAQUE}static __initDefine__(){BlinnPhongMaterial.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines),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")}get _ColorR(){return this._albedoColor.x}set _ColorR(value){this._albedoColor.x=value,this.albedoColor=this._albedoColor}get _ColorG(){return this._albedoColor.y}set _ColorG(value){this._albedoColor.y=value,this.albedoColor=this._albedoColor}get _ColorB(){return this._albedoColor.z}set _ColorB(value){this._albedoColor.z=value,this.albedoColor=this._albedoColor}get _ColorA(){return this._albedoColor.w}set _ColorA(value){this._albedoColor.w=value,this.albedoColor=this._albedoColor}get _SpecColorR(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x}set _SpecColorR(value){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x=value}get _SpecColorG(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y}set _SpecColorG(value){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y=value}get _SpecColorB(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z}set _SpecColorB(value){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z=value}get _SpecColorA(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w}set _SpecColorA(value){this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w=value}get _AlbedoIntensity(){return this._albedoIntensity}set _AlbedoIntensity(value){if(this._albedoIntensity!==value){var finalAlbedo=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);Vector4.scale(this._albedoColor,value,finalAlbedo),this._albedoIntensity=value,this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,finalAlbedo)}}get _Shininess(){return this._shaderValues.getNumber(BlinnPhongMaterial.SHININESS)}set _Shininess(value){value=Math.max(0,Math.min(1,value)),this._shaderValues.setNumber(BlinnPhongMaterial.SHININESS,value)}get _MainTex_STX(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).x}set _MainTex_STX(x){var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);tilOff.x=x,this.tilingOffset=tilOff}get _MainTex_STY(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).y}set _MainTex_STY(y){var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);tilOff.y=y,this.tilingOffset=tilOff}get _MainTex_STZ(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).z}set _MainTex_STZ(z){var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);tilOff.z=z,this.tilingOffset=tilOff}get _MainTex_STW(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).w}set _MainTex_STW(w){var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);tilOff.w=w,this.tilingOffset=tilOff}get _Cutoff(){return this.alphaTestValue}set _Cutoff(value){this.alphaTestValue=value}set renderMode(value){switch(value){case BlinnPhongMaterial.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=BaseMaterial.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=RenderState.CULL_BACK,this.blend=RenderState.BLEND_DISABLE,this.depthTest=RenderState.DEPTHTEST_LESS;break;case BlinnPhongMaterial.RENDERMODE_CUTOUT:this.renderQueue=BaseMaterial.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=RenderState.CULL_BACK,this.blend=RenderState.BLEND_DISABLE,this.depthTest=RenderState.DEPTHTEST_LESS;break;case BlinnPhongMaterial.RENDERMODE_TRANSPARENT:this.renderQueue=BaseMaterial.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=RenderState.CULL_BACK,this.blend=RenderState.BLEND_ENABLE_ALL,this.blendSrc=RenderState.BLENDPARAM_SRC_ALPHA,this.blendDst=RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=RenderState.DEPTHTEST_LESS;break;default:throw new Error("Material:renderMode value error.")}}get enableVertexColor(){return this._enableVertexColor}set enableVertexColor(value){this._enableVertexColor=value,value?this._shaderValues.addDefine(BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR):this._shaderValues.removeDefine(BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR)}get tilingOffsetX(){return this._MainTex_STX}set tilingOffsetX(x){this._MainTex_STX=x}get tilingOffsetY(){return this._MainTex_STY}set tilingOffsetY(y){this._MainTex_STY=y}get tilingOffsetZ(){return this._MainTex_STZ}set tilingOffsetZ(z){this._MainTex_STZ=z}get tilingOffsetW(){return this._MainTex_STW}set tilingOffsetW(w){this._MainTex_STW=w}get tilingOffset(){return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET)}set tilingOffset(value){value&&(1!=value.x||1!=value.y||0!=value.z||0!=value.w)?this._shaderValues.addDefine(BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(BlinnPhongMaterial.TILINGOFFSET,value)}get albedoColorR(){return this._ColorR}set albedoColorR(value){this._ColorR=value}get albedoColorG(){return this._ColorG}set albedoColorG(value){this._ColorG=value}get albedoColorB(){return this._ColorB}set albedoColorB(value){this._ColorB=value}get albedoColorA(){return this._ColorA}set albedoColorA(value){this._ColorA=value}get albedoColor(){return this._albedoColor}set albedoColor(value){var finalAlbedo=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);Vector4.scale(value,this._albedoIntensity,finalAlbedo),this._albedoColor=value,this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,finalAlbedo)}get albedoIntensity(){return this._albedoIntensity}set albedoIntensity(value){this._AlbedoIntensity=value}get specularColorR(){return this._SpecColorR}set specularColorR(value){this._SpecColorR=value}get specularColorG(){return this._SpecColorG}set specularColorG(value){this._SpecColorG=value}get specularColorB(){return this._SpecColorB}set specularColorB(value){this._SpecColorB=value}get specularColorA(){return this._SpecColorA}set specularColorA(value){this._SpecColorA=value}get specularColor(){return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR)}set specularColor(value){this._shaderValues.setVector(BlinnPhongMaterial.MATERIALSPECULAR,value)}get shininess(){return this._Shininess}set shininess(value){this._Shininess=value}get albedoTexture(){return this._shaderValues.getTexture(BlinnPhongMaterial.ALBEDOTEXTURE)}set albedoTexture(value){value?this._shaderValues.addDefine(BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP):this._shaderValues.removeDefine(BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP),this._shaderValues.setTexture(BlinnPhongMaterial.ALBEDOTEXTURE,value)}get normalTexture(){return this._shaderValues.getTexture(BlinnPhongMaterial.NORMALTEXTURE)}set normalTexture(value){value?this._shaderValues.addDefine(BlinnPhongMaterial.SHADERDEFINE_NORMALMAP):this._shaderValues.removeDefine(BlinnPhongMaterial.SHADERDEFINE_NORMALMAP),this._shaderValues.setTexture(BlinnPhongMaterial.NORMALTEXTURE,value)}get specularTexture(){return this._shaderValues.getTexture(BlinnPhongMaterial.SPECULARTEXTURE)}set specularTexture(value){value?this._shaderValues.addDefine(BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP):this._shaderValues.removeDefine(BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP),this._shaderValues.setTexture(BlinnPhongMaterial.SPECULARTEXTURE,value)}get enableLighting(){return this._enableLighting}set enableLighting(value){this._enableLighting!==value&&(value?this._disablePublicDefineDatas.remove(Scene3DShaderDeclaration.SHADERDEFINE_POINTLIGHT|Scene3DShaderDeclaration.SHADERDEFINE_SPOTLIGHT|Scene3DShaderDeclaration.SHADERDEFINE_DIRECTIONLIGHT):this._disablePublicDefineDatas.add(Scene3DShaderDeclaration.SHADERDEFINE_POINTLIGHT|Scene3DShaderDeclaration.SHADERDEFINE_SPOTLIGHT|Scene3DShaderDeclaration.SHADERDEFINE_DIRECTIONLIGHT),this._enableLighting=value)}set depthWrite(value){this._shaderValues.setBool(BlinnPhongMaterial.DEPTH_WRITE,value)}get depthWrite(){return this._shaderValues.getBool(BlinnPhongMaterial.DEPTH_WRITE)}set cull(value){this._shaderValues.setInt(BlinnPhongMaterial.CULL,value)}get cull(){return this._shaderValues.getInt(BlinnPhongMaterial.CULL)}set blend(value){this._shaderValues.setInt(BlinnPhongMaterial.BLEND,value)}get blend(){return this._shaderValues.getInt(BlinnPhongMaterial.BLEND)}set blendSrc(value){this._shaderValues.setInt(BlinnPhongMaterial.BLEND_SRC,value)}get blendSrc(){return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_SRC)}set blendDst(value){this._shaderValues.setInt(BlinnPhongMaterial.BLEND_DST,value)}get blendDst(){return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_DST)}set depthTest(value){this._shaderValues.setInt(BlinnPhongMaterial.DEPTH_TEST,value)}get depthTest(){return this._shaderValues.getInt(BlinnPhongMaterial.DEPTH_TEST)}clone(){var dest=new BlinnPhongMaterial;return this.cloneTo(dest),dest}cloneTo(destObject){super.cloneTo(destObject);var destMaterial=destObject;destMaterial._enableLighting=this._enableLighting,destMaterial._albedoIntensity=this._albedoIntensity,destMaterial._enableVertexColor=this._enableVertexColor,this._albedoColor.cloneTo(destMaterial._albedoColor)}}BlinnPhongMaterial.RENDERMODE_OPAQUE=0,BlinnPhongMaterial.RENDERMODE_CUTOUT=1,BlinnPhongMaterial.RENDERMODE_TRANSPARENT=2,BlinnPhongMaterial.ALBEDOTEXTURE=Shader3D.propertyNameToID("u_DiffuseTexture"),BlinnPhongMaterial.NORMALTEXTURE=Shader3D.propertyNameToID("u_NormalTexture"),BlinnPhongMaterial.SPECULARTEXTURE=Shader3D.propertyNameToID("u_SpecularTexture"),BlinnPhongMaterial.ALBEDOCOLOR=Shader3D.propertyNameToID("u_DiffuseColor"),BlinnPhongMaterial.MATERIALSPECULAR=Shader3D.propertyNameToID("u_MaterialSpecular"),BlinnPhongMaterial.SHININESS=Shader3D.propertyNameToID("u_Shininess"),BlinnPhongMaterial.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset"),BlinnPhongMaterial.CULL=Shader3D.propertyNameToID("s_Cull"),BlinnPhongMaterial.BLEND=Shader3D.propertyNameToID("s_Blend"),BlinnPhongMaterial.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc"),BlinnPhongMaterial.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst"),BlinnPhongMaterial.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest"),BlinnPhongMaterial.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite"),BlinnPhongMaterial.shaderDefines=null;class Bounds{constructor(min,max){this._updateFlag=0,this._center=new Vector3,this._extent=new Vector3,this._boundBox=new BoundBox(new Vector3,new Vector3),min.cloneTo(this._boundBox.min),max.cloneTo(this._boundBox.max),this._setUpdateFlag(Bounds._UPDATE_CENTER|Bounds._UPDATE_EXTENT,!0)}setMin(value){var min=this._boundBox.min;value!==min&&value.cloneTo(min),this._setUpdateFlag(Bounds._UPDATE_CENTER|Bounds._UPDATE_EXTENT,!0),this._setUpdateFlag(Bounds._UPDATE_MIN,!1)}getMin(){var min=this._boundBox.min;return this._getUpdateFlag(Bounds._UPDATE_MIN)&&(this._getMin(this.getCenter(),this.getExtent(),min),this._setUpdateFlag(Bounds._UPDATE_MIN,!1)),min}setMax(value){var max=this._boundBox.max;value!==max&&value.cloneTo(max),this._setUpdateFlag(Bounds._UPDATE_CENTER|Bounds._UPDATE_EXTENT,!0),this._setUpdateFlag(Bounds._UPDATE_MAX,!1)}getMax(){var max=this._boundBox.max;return this._getUpdateFlag(Bounds._UPDATE_MAX)&&(this._getMax(this.getCenter(),this.getExtent(),max),this._setUpdateFlag(Bounds._UPDATE_MAX,!1)),max}setCenter(value){value!==this._center&&value.cloneTo(this._center),this._setUpdateFlag(Bounds._UPDATE_MIN|Bounds._UPDATE_MAX,!0),this._setUpdateFlag(Bounds._UPDATE_CENTER,!1)}getCenter(){return this._getUpdateFlag(Bounds._UPDATE_CENTER)&&(this._getCenter(this.getMin(),this.getMax(),this._center),this._setUpdateFlag(Bounds._UPDATE_CENTER,!1)),this._center}setExtent(value){value!==this._extent&&value.cloneTo(this._extent),this._setUpdateFlag(Bounds._UPDATE_MIN|Bounds._UPDATE_MAX,!0),this._setUpdateFlag(Bounds._UPDATE_EXTENT,!1)}getExtent(){return this._getUpdateFlag(Bounds._UPDATE_EXTENT)&&(this._getExtent(this.getMin(),this.getMax(),this._extent),this._setUpdateFlag(Bounds._UPDATE_EXTENT,!1)),this._extent}_getUpdateFlag(type){return 0!=(this._updateFlag&type)}_setUpdateFlag(type,value){value?this._updateFlag|=type:this._updateFlag&=~type}_getCenter(min,max,out){Vector3.add(min,max,out),Vector3.scale(out,.5,out)}_getExtent(min,max,out){Vector3.subtract(max,min,out),Vector3.scale(out,.5,out)}_getMin(center,extent,out){Vector3.subtract(center,extent,out)}_getMax(center,extent,out){Vector3.add(center,extent,out)}_rotateExtents(extents,rotation,out){var extentsX=extents.x,extentsY=extents.y,extentsZ=extents.z,matE=rotation.elements;out.x=Math.abs(matE[0]*extentsX)+Math.abs(matE[4]*extentsY)+Math.abs(matE[8]*extentsZ),out.y=Math.abs(matE[1]*extentsX)+Math.abs(matE[5]*extentsY)+Math.abs(matE[9]*extentsZ),out.z=Math.abs(matE[2]*extentsX)+Math.abs(matE[6]*extentsY)+Math.abs(matE[10]*extentsZ)}_tranform(matrix,out){var outCen=out._center,outExt=out._extent;Vector3.transformCoordinate(this.getCenter(),matrix,outCen),this._rotateExtents(this.getExtent(),matrix,outExt),out._boundBox.setCenterAndExtent(outCen,outExt),out._updateFlag=0}_getBoundBox(){if(this._updateFlag&Bounds._UPDATE_MIN){var min=this._boundBox.min;this._getMin(this.getCenter(),this.getExtent(),min),this._setUpdateFlag(Bounds._UPDATE_MIN,!1)}if(this._updateFlag&Bounds._UPDATE_MAX){var max=this._boundBox.max;this._getMax(this.getCenter(),this.getExtent(),max),this._setUpdateFlag(Bounds._UPDATE_MAX,!1)}return this._boundBox}cloneTo(destObject){var destBounds=destObject;this.getMin().cloneTo(destBounds._boundBox.min),this.getMax().cloneTo(destBounds._boundBox.max),this.getCenter().cloneTo(destBounds._center),this.getExtent().cloneTo(destBounds._extent),destBounds._updateFlag=0}clone(){var dest=new Bounds(new Vector3,new Vector3);return this.cloneTo(dest),dest}}Bounds._UPDATE_MIN=1,Bounds._UPDATE_MAX=2,Bounds._UPDATE_CENTER=4,Bounds._UPDATE_EXTENT=8;class BaseRender extends Laya.EventDispatcher{constructor(owner){if(super(),this._indexInList=-1,this._indexInCastShadowList=-1,this._boundsChange=!0,this._supportOctree=!0,this._sharedMaterials=[],this._visible=!0,this._indexInOctreeMotionList=-1,this._updateMark=-1,this._updateRenderType=-1,this._isPartOfStaticBatch=!1,this._staticBatch=null,this._id=++BaseRender._uniqueIDCounter,this._indexInCastShadowList=-1,this._bounds=new Bounds(Vector3._ZERO,Vector3._ZERO),Laya.Render.supportWebGLPlusCulling){var length=FrustumCulling._cullingBufferLength;this._cullingBufferIndex=length;var cullingBuffer=FrustumCulling._cullingBuffer,resizeLength=length+7;if(resizeLength>=cullingBuffer.length){var temp=cullingBuffer;(cullingBuffer=FrustumCulling._cullingBuffer=new Float32Array(cullingBuffer.length+4096)).set(temp,0)}cullingBuffer[length]=2,FrustumCulling._cullingBufferLength=resizeLength}this._renderElements=[],this._owner=owner,this._enable=!0,this._materialsInstance=[],this._shaderValues=new ShaderData(null),this.lightmapIndex=-1,this._castShadow=!1,this.receiveShadow=!1,this.sortingFudge=0,owner&&this._owner.transform.on(Laya.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange)}get id(){return this._id}get lightmapIndex(){return this._lightmapIndex}set lightmapIndex(value){this._lightmapIndex!==value&&(this._lightmapIndex=value,this._applyLightMapParams())}get lightmapScaleOffset(){return this._lightmapScaleOffset}set lightmapScaleOffset(value){this._lightmapScaleOffset=value,this._shaderValues.setVector(RenderableSprite3D.LIGHTMAPSCALEOFFSET,value),this._shaderValues.addDefine(RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV)}get enable(){return this._enable}set enable(value){this._enable=!!value}get material(){var material=this._sharedMaterials[0];if(material&&!this._materialsInstance[0]){var insMat=this._getInstanceMaterial(material,0),renderElement=this._renderElements[0];renderElement&&(renderElement.material=insMat)}return this._sharedMaterials[0]}set material(value){this.sharedMaterial=value}get materials(){for(var i=0,n=this._sharedMaterials.length;i=0){var lightMaps=this._scene.getlightmaps();this._lightmapIndex=0;i--){var offset=4*i;if(lerpFactor===(left=rgbElements[offset]))return out.r=rgbElements[offset+1],out.g=rgbElements[offset+2],out.b=rgbElements[offset+3],curIndex;switch(this._mode){case GradientMode.Blend:if(lerpFactor>left){if(lerpFactor>(right=rgbElements[offset+4]))throw"Gradient:wrong startSearchIndex.";var diff=right-left,y1=right-lerpFactor,y2=lerpFactor-left;return out.r=(y1*rgbElements[offset+1]+y2*rgbElements[offset+5])/diff,out.g=(y1*rgbElements[offset+2]+y2*rgbElements[offset+6])/diff,out.b=(y1*rgbElements[offset+3]+y2*rgbElements[offset+7])/diff,curIndex}curIndex--;continue;case GradientMode.Fixed:if(lerpFactor>left){if(lerpFactor>rgbElements[offset+4])throw"Gradient:wrong startSearchIndex.";return out.r=rgbElements[offset+5],out.g=rgbElements[offset+6],out.b=rgbElements[offset+7],curIndex}curIndex--;continue;default:throw"Gradient:unknown mode."}}else{i=0;for(var n=this._rgbElements.length;i=0;i--){if(lerpFactor===(left=alphaElements[offset=2*i]))return outColor.a=alphaElements[offset+1],curIndex;switch(this._mode){case GradientMode.Blend:if(lerpFactor>left){if(lerpFactor>(right=alphaElements[offset+2]))throw"Gradient:wrong startSearchIndex.";var diff=right-left,x1=right-lerpFactor,x2=lerpFactor-left;return outColor.a=(x1*alphaElements[offset+1]+x2*alphaElements[offset+3])/diff,curIndex}curIndex--;continue;case GradientMode.Fixed:if(lerpFactor>left){if(lerpFactor>alphaElements[offset+2])throw"Gradient:wrong startSearchIndex.";return outColor.a=alphaElements[offset+3],curIndex}curIndex--;continue;default:throw"Gradient:unknown mode."}}else{i=curIndex;for(var n=this._alphaElements.length;i=emissionTime){var lastKey=startLifeTimeGradient.getKeyByIndex(i-1),age=(emissionTime-lastKey)/(key-lastKey);return Laya.MathUtil.lerp(startLifeTimeGradient.getValueByIndex(i-1),startLifeTimeGradient.getValueByIndex(i),age)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")}static _randomInvertRoationArray(rotatonE,outE,randomizeRotationDirection,rand,randomSeeds){var randDic;rand?(rand.seed=randomSeeds[6],randDic=rand.getFloat(),randomSeeds[6]=rand.seed):randDic=Math.random(),randDic0)for(var i=0;iburst.time&&this._bursts.splice(i,0,burst);this._bursts.push(burst)}removeBurst(burst){var index=this._bursts.indexOf(burst);-1!==index&&this._bursts.splice(index,1)}removeBurstByIndex(index){this._bursts.splice(index,1)}clearBurst(){this._bursts.length=0}cloneTo(destObject){var destEmission=destObject,destBursts=destEmission._bursts;destBursts.length=this._bursts.length;for(var i=0,n=this._bursts.length;i>>15}get seed(){return this.seeds[0]}set seed(seed){this.seeds[0]=seed,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}getUint(){return this._temp[0]=this.seeds[0]^this.seeds[0]<<11,this.seeds[0]=this.seeds[1],this.seeds[1]=this.seeds[2],this.seeds[2]=this.seeds[3],this.seeds[3]=this.seeds[3]^this.seeds[3]>>>19^this._temp[0]^this._temp[0]>>>8,this.seeds[3]}getFloat(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)}getSignedFloat(){return 2*this.getFloat()-1}}class ShurikenParticleSystem extends GeometryElement{constructor(owner){super(),this._tempRotationMatrix=new Matrix4x4,this._boundingSphere=null,this._boundingBox=null,this._boundingBoxCorners=null,this._owner=null,this._ownerRender=null,this._vertices=null,this._floatCountPerVertex=0,this._startLifeTimeIndex=0,this._timeIndex=0,this._simulateUpdate=!1,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._drawCounter=0,this._bufferMaxParticles=0,this._emission=null,this._shape=null,this._isEmitting=!1,this._isPlaying=!1,this._isPaused=!1,this._playStartDelay=0,this._frameRateTime=0,this._emissionTime=0,this._totalDelayTime=0,this._burstsIndex=0,this._velocityOverLifetime=null,this._colorOverLifetime=null,this._sizeOverLifetime=null,this._rotationOverLifetime=null,this._textureSheetAnimation=null,this._startLifetimeType=0,this._startLifetimeConstant=0,this._startLifeTimeGradient=null,this._startLifetimeConstantMin=0,this._startLifetimeConstantMax=0,this._startLifeTimeGradientMin=null,this._startLifeTimeGradientMax=null,this._maxStartLifetime=0,this._uvLength=new Vector2,this._vertexStride=0,this._indexStride=0,this._vertexBuffer=null,this._indexBuffer=null,this._bufferState=new BufferState,this._currentTime=0,this._startUpdateLoopCount=0,this._rand=null,this._randomSeeds=null,this.duration=0,this.looping=!1,this.prewarm=!1,this.startDelayType=0,this.startDelay=0,this.startDelayMin=0,this.startDelayMax=0,this.startSpeedType=0,this.startSpeedConstant=0,this.startSpeedConstantMin=0,this.startSpeedConstantMax=0,this.threeDStartSize=!1,this.startSizeType=0,this.startSizeConstant=0,this.startSizeConstantSeparate=null,this.startSizeConstantMin=0,this.startSizeConstantMax=0,this.startSizeConstantMinSeparate=null,this.startSizeConstantMaxSeparate=null,this.threeDStartRotation=!1,this.startRotationType=0,this.startRotationConstant=0,this.startRotationConstantSeparate=null,this.startRotationConstantMin=0,this.startRotationConstantMax=0,this.startRotationConstantMinSeparate=null,this.startRotationConstantMaxSeparate=null,this.randomizeRotationDirection=0,this.startColorType=0,this.startColorConstant=null,this.startColorConstantMin=null,this.startColorConstantMax=null,this.gravityModifier=0,this.simulationSpace=0,this.scaleMode=0,this.playOnAwake=!1,this.randomSeed=null,this.autoRandomSeed=!1,this.isPerformanceMode=!1,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._owner=owner,this._ownerRender=owner.particleRenderer,this._boundingBoxCorners=[],this._boundingSphere=new BoundSphere(new Vector3,Number.MAX_VALUE),this._boundingBox=new BoundBox(new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)),this._currentTime=0,this._isEmitting=!1,this._isPlaying=!1,this._isPaused=!1,this._burstsIndex=0,this._frameRateTime=0,this._emissionTime=0,this._totalDelayTime=0,this._simulateUpdate=!1,this._bufferMaxParticles=1,this.duration=5,this.looping=!0,this.prewarm=!1,this.startDelayType=0,this.startDelay=0,this.startDelayMin=0,this.startDelayMax=0,this._startLifetimeType=0,this._startLifetimeConstant=5,this._startLifeTimeGradient=new GradientDataNumber,this._startLifetimeConstantMin=0,this._startLifetimeConstantMax=5,this._startLifeTimeGradientMin=new GradientDataNumber,this._startLifeTimeGradientMax=new GradientDataNumber,this._maxStartLifetime=5,this.startSpeedType=0,this.startSpeedConstant=5,this.startSpeedConstantMin=0,this.startSpeedConstantMax=5,this.threeDStartSize=!1,this.startSizeType=0,this.startSizeConstant=1,this.startSizeConstantSeparate=new Vector3(1,1,1),this.startSizeConstantMin=0,this.startSizeConstantMax=1,this.startSizeConstantMinSeparate=new Vector3(0,0,0),this.startSizeConstantMaxSeparate=new Vector3(1,1,1),this.threeDStartRotation=!1,this.startRotationType=0,this.startRotationConstant=0,this.startRotationConstantSeparate=new Vector3(0,0,0),this.startRotationConstantMin=0,this.startRotationConstantMax=0,this.startRotationConstantMinSeparate=new Vector3(0,0,0),this.startRotationConstantMaxSeparate=new Vector3(0,0,0),this.randomizeRotationDirection=0,this.startColorType=0,this.startColorConstant=new Vector4(1,1,1,1),this.startColorConstantMin=new Vector4(1,1,1,1),this.startColorConstantMax=new Vector4(1,1,1,1),this.gravityModifier=0,this.simulationSpace=1,this.scaleMode=0,this.playOnAwake=!0,this._rand=new Rand(0),this.autoRandomSeed=!0,this.randomSeed=new Uint32Array(1),this._randomSeeds=new Uint32Array(ShurikenParticleSystem._RANDOMOFFSET.length),this.isPerformanceMode=!0,this._emission=new Emission,this._emission.enbale=!0}get maxParticles(){return this._bufferMaxParticles-1}set maxParticles(value){var newMaxParticles=value+1;newMaxParticles!==this._bufferMaxParticles&&(this._bufferMaxParticles=newMaxParticles,this._initBufferDatas())}get emission(){return this._emission}get aliveParticleCount(){return this._firstNewElement>=this._firstRetiredElement?this._firstNewElement-this._firstRetiredElement:this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement}get emissionTime(){return this._emissionTime>this.duration?this.duration:this._emissionTime}get shape(){return this._shape}set shape(value){this._shape!==value&&(value&&value.enable?this._owner._render._shaderValues.addDefine(ShuriKenParticle3DShaderDeclaration.SHADERDEFINE_SHAPE):this._owner._render._shaderValues.removeDefine(ShuriKenParticle3DShaderDeclaration.SHADERDEFINE_SHAPE),this._shape=value)}get isAlive(){return!!(this._isPlaying||this.aliveParticleCount>0)}get isEmitting(){return this._isEmitting}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get startLifetimeType(){return this._startLifetimeType}set startLifetimeType(value){var i,n;switch(this.startLifetimeType){case 0:this._maxStartLifetime=this.startLifetimeConstant;break;case 1:this._maxStartLifetime=-Number.MAX_VALUE;var startLifeTimeGradient=startLifeTimeGradient;for(i=0,n=startLifeTimeGradient.gradientCount;i=this._bufferMaxParticles&&(this._firstActiveElement=0)}}_freeRetiredParticles(){for(;this._firstRetiredElement!=this._firstActiveElement;){var age=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*this._vertexStride+this._timeIndex];if(this.isPerformanceMode&&age<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this._bufferMaxParticles&&(this._firstRetiredElement=0)}}_burst(fromTime,toTime){for(var totalEmitCount=0,bursts=this._emission._bursts,n=bursts.length;this._burstsIndexthis.duration){if(!this.looping){for(totalEmitCount=Math.min(this.maxParticles-this.aliveParticleCount,totalEmitCount),i=0;i0){var minEmissionTime=1/emissionRate;for(this._frameRateTime+=minEmissionTime,this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)%this._maxStartLifetime;this._frameRateTime<=emitTime&&this.emit(this._frameRateTime);)this._frameRateTime+=minEmissionTime;this._frameRateTime=Math.floor(emitTime/minEmissionTime)*minEmissionTime}}_initBufferDatas(){this._vertexBuffer&&(this._vertexBuffer.destroy(),this._indexBuffer.destroy());var gl=Laya.LayaGL.instance,render=this._ownerRender,renderMode=render.renderMode;if(-1!==renderMode&&this.maxParticles>0){var indices,i,j,m,indexOffset,perPartOffset,vertexDeclaration,vbMemorySize=0,memorySize=0,mesh=render.mesh;if(4===renderMode){if(mesh){vertexDeclaration=VertexShurikenParticleMesh.vertexDeclaration,this._floatCountPerVertex=vertexDeclaration.vertexStride/4,this._startLifeTimeIndex=12,this._timeIndex=16,this._vertexStride=mesh._vertexBuffer.vertexCount;var totalVertexCount=this._bufferMaxParticles*this._vertexStride,lastVBVertexCount=totalVertexCount%65535;if(Math.floor(totalVertexCount/65535)+1>1)throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");vbMemorySize=vertexDeclaration.vertexStride*lastVBVertexCount,this._vertexBuffer=new VertexBuffer3D(vbMemorySize,gl.DYNAMIC_DRAW),this._vertexBuffer.vertexDeclaration=vertexDeclaration,this._vertices=new Float32Array(this._floatCountPerVertex*lastVBVertexCount),this._indexStride=mesh._indexBuffer.indexCount;var indexDatas=mesh._indexBuffer.getData(),indexCount=this._bufferMaxParticles*this._indexStride;for(this._indexBuffer=new IndexBuffer3D(IndexBuffer3D.INDEXTYPE_USHORT,indexCount,gl.STATIC_DRAW),indices=new Uint16Array(indexCount),memorySize=vbMemorySize+2*indexCount,indexOffset=0,i=0;i=this._bufferMaxParticles&&(nextFreeParticle=0),nextFreeParticle===this._firstRetiredElement)return!1;if(ShurikenParticleData.create(this,this._ownerRender,this._owner.transform),this._currentTime-time>=ShurikenParticleData.startLifeTime)return!0;var needRandomVelocity=this._velocityOverLifetime&&this._velocityOverLifetime.enbale;if(needRandomVelocity){var velocityType=this._velocityOverLifetime.velocity.type;2===velocityType||3===velocityType?this.autoRandomSeed?(randomVelocityX=Math.random(),randomVelocityY=Math.random(),randomVelocityZ=Math.random()):(this._rand.seed=this._randomSeeds[9],randomVelocityX=this._rand.getFloat(),randomVelocityY=this._rand.getFloat(),randomVelocityZ=this._rand.getFloat(),this._randomSeeds[9]=this._rand.seed):needRandomVelocity=!1}else needRandomVelocity=!1;var needRandomColor=this._colorOverLifetime&&this._colorOverLifetime.enbale;needRandomColor?3===this._colorOverLifetime.color.type?this.autoRandomSeed?randomColor=Math.random():(this._rand.seed=this._randomSeeds[10],randomColor=this._rand.getFloat(),this._randomSeeds[10]=this._rand.seed):needRandomColor=!1:needRandomColor=!1;var needRandomSize=this._sizeOverLifetime&&this._sizeOverLifetime.enbale;needRandomSize?3===this._sizeOverLifetime.size.type?this.autoRandomSeed?randomSize=Math.random():(this._rand.seed=this._randomSeeds[11],randomSize=this._rand.getFloat(),this._randomSeeds[11]=this._rand.seed):needRandomSize=!1:needRandomSize=!1;var needRandomRotation=this._rotationOverLifetime&&this._rotationOverLifetime.enbale;if(needRandomRotation){var rotationType=this._rotationOverLifetime.angularVelocity.type;2===rotationType||3===rotationType?this.autoRandomSeed?randomRotation=Math.random():(this._rand.seed=this._randomSeeds[12],randomRotation=this._rand.getFloat(),this._randomSeeds[12]=this._rand.seed):needRandomRotation=!1}else needRandomRotation=!1;var needRandomTextureAnimation=this._textureSheetAnimation&&this._textureSheetAnimation.enable;needRandomTextureAnimation?3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?randomTextureAnimation=Math.random():(this._rand.seed=this._randomSeeds[15],randomTextureAnimation=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):needRandomTextureAnimation=!1:needRandomTextureAnimation=!1;var meshVertices,meshVertexStride,meshPosOffset,meshCorOffset,meshUVOffset,meshVertexIndex,startIndex=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,subU=ShurikenParticleData.startUVInfo[0],subV=ShurikenParticleData.startUVInfo[1],startU=ShurikenParticleData.startUVInfo[2],startV=ShurikenParticleData.startUVInfo[3],render=this._ownerRender;if(4===render.renderMode){var meshVB=render.mesh._vertexBuffer;meshVertices=meshVB.getFloat32Data();var meshVertexDeclaration=meshVB.vertexDeclaration;meshPosOffset=meshVertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_POSITION0)._offset/4;var colorElement=meshVertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_COLOR0);meshCorOffset=colorElement?colorElement._offset/4:-1;var uvElement=meshVertexDeclaration.getVertexElementByUsage(VertexMesh.MESH_TEXTURECOORDINATE0);meshUVOffset=uvElement?uvElement._offset/4:-1,meshVertexStride=meshVertexDeclaration.vertexStride/4,meshVertexIndex=0}else{this._vertices[startIndex+2]=startU,this._vertices[startIndex+3]=startV+subV;var secondOffset=startIndex+this._floatCountPerVertex;this._vertices[secondOffset+2]=startU+subU,this._vertices[secondOffset+3]=startV+subV;var thirdOffset=secondOffset+this._floatCountPerVertex;this._vertices[thirdOffset+2]=startU+subU,this._vertices[thirdOffset+3]=startV;var fourthOffset=thirdOffset+this._floatCountPerVertex;this._vertices[fourthOffset+2]=startU,this._vertices[fourthOffset+3]=startV}for(var i=startIndex,n=startIndex+this._floatCountPerVertex*this._vertexStride;i0&&this._vertexBuffer.setData(this._vertices.buffer,0,0,this._firstFreeElement*byteStride)),this._firstNewElement=this._firstFreeElement}_getType(){return ShurikenParticleSystem._type}_prepareRender(state){return this._updateEmission(),this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement}_render(state){var indexCount;this._bufferState.bind();var gl=Laya.LayaGL.instance;this._firstActiveElement0&&(indexCount=this._firstFreeElement*this._indexStride,gl.drawElements(gl.TRIANGLES,indexCount,gl.UNSIGNED_SHORT,0),Laya.Stat.trianglesFaces+=indexCount/3,Laya.Stat.renderBatches++))}play(){if(this._burstsIndex=0,this._isEmitting=!0,this._isPlaying=!0,this._isPaused=!1,this._emissionTime=0,this._totalDelayTime=0,!this.autoRandomSeed)for(var i=0,n=this._randomSeeds.length;i{e.preventDefault(),this._eventList.push(e)}).bind(this)}__init__(canvas,scene){this._scene=scene,canvas.oncontextmenu=function(e){return!1}}_onCanvasEvent(canvas){canvas.addEventListener("mousedown",this._pushEventList),canvas.addEventListener("mouseup",this._pushEventList,!0),canvas.addEventListener("mousemove",this._pushEventList,!0),canvas.addEventListener("touchstart",this._pushEventList),canvas.addEventListener("touchend",this._pushEventList,!0),canvas.addEventListener("touchmove",this._pushEventList,!0),canvas.addEventListener("touchcancel",this._pushEventList,!0)}_offCanvasEvent(canvas){canvas.removeEventListener("mousedown",this._pushEventList),canvas.removeEventListener("mouseup",this._pushEventList,!0),canvas.removeEventListener("mousemove",this._pushEventList,!0),canvas.removeEventListener("touchstart",this._pushEventList),canvas.removeEventListener("touchend",this._pushEventList,!0),canvas.removeEventListener("touchmove",this._pushEventList,!0),canvas.removeEventListener("touchcancel",this._pushEventList,!0),this._eventList.length=0,this._touches.length=0}touchCount(){return this._touches.length}get multiTouchEnabled(){return this._multiTouchEnabled}set multiTouchEnabled(value){this._multiTouchEnabled=value}_getTouch(touchID){var touch=this._touchPool[touchID];return touch||(touch=new Touch,this._touchPool[touchID]=touch,touch._identifier=touchID),touch}_mouseTouchDown(){var touch=this._mouseTouch,sprite=touch.sprite;if(touch._pressedSprite=sprite,touch._pressedLoopCount=Laya.Stat.loopCount,sprite){var scripts=sprite._scripts;if(scripts)for(var i=0,n=scripts.length;i=0;i--){var camera=cameras[i],viewport=camera.viewport;if(touchPos.x>=viewport.x&&touchPos.y>=viewport.y&&touchPos.x<=viewport.width&&touchPos.y<=viewport.height)if(camera.viewportPointToRay(touchPos,touchRay),this._scene._physicsSimulation.rayCast(touchRay,touchHitResult)||camera.clearFlag===BaseCamera.CLEARFLAG_SOLIDCOLOR||camera.clearFlag===BaseCamera.CLEARFLAG_SKY)break}var touch=this._mouseTouch,lastSprite=touch.sprite;if(touchHitResult.succeeded){var touchSprite=touchHitResult.collider.owner;touch.sprite=touchSprite;var scripts=touchSprite._scripts;if(lastSprite!==touchSprite&&scripts)for(var j=0,m=scripts.length;j0){var rayCast=!1;for(i=0;imouseTouch._pressedLoopCount){var pressedScripts=pressedSprite._scripts;if(pressedScripts)for(j=0,m=pressedScripts.length;j=MathUtils3D.zeroTolerance?(this._isTempEndVertex?(tempEndIndex=this._endIndex-1,offset=delLength-this._subDistance[tempEndIndex],this._updateVerticesByPosition(position,pointAtoBVector3,delLength,tempEndIndex),this._owner._totalLength+=offset):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(position,pointAtoBVector3,delLength,this._endIndex),this._owner._totalLength+=delLength,this._endIndex++),position.cloneTo(this._lastFixedVertexPosition),this._isTempEndVertex=!1):(this._isTempEndVertex?(tempEndIndex=this._endIndex-1,offset=delLength-this._subDistance[tempEndIndex],this._updateVerticesByPosition(position,pointAtoBVector3,delLength,tempEndIndex),this._owner._totalLength+=offset):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(position,pointAtoBVector3,delLength,this._endIndex),this._owner._totalLength+=delLength,this._endIndex++),this._isTempEndVertex=!0)}_updateVerticesByPositionData(position,pointAtoBVector3,index){var vertexOffset=2*this._floatCountPerVertices1*index,curtime=this._owner._curtime;this._vertices1[vertexOffset]=position.x,this._vertices1[vertexOffset+1]=position.y,this._vertices1[vertexOffset+2]=position.z,this._vertices1[vertexOffset+3]=-pointAtoBVector3.x,this._vertices1[vertexOffset+4]=-pointAtoBVector3.y,this._vertices1[vertexOffset+5]=-pointAtoBVector3.z,this._vertices1[vertexOffset+6]=curtime,this._vertices1[vertexOffset+7]=1,this._vertices1[vertexOffset+8]=position.x,this._vertices1[vertexOffset+9]=position.y,this._vertices1[vertexOffset+10]=position.z,this._vertices1[vertexOffset+11]=pointAtoBVector3.x,this._vertices1[vertexOffset+12]=pointAtoBVector3.y,this._vertices1[vertexOffset+13]=pointAtoBVector3.z,this._vertices1[vertexOffset+14]=curtime,this._vertices1[vertexOffset+15]=0;var bounds=this._owner._owner.trailRenderer.bounds,min=bounds.getMin(),max=bounds.getMax(),up=TrailGeometry._tempVector35,down=TrailGeometry._tempVector36,out=TrailGeometry._tempVector32;Vector3.add(position,pointAtoBVector3,up),Vector3.subtract(position,pointAtoBVector3,down),Vector3.min(down,up,out),Vector3.min(min,out,min),bounds.setMin(min),Vector3.max(up,down,out),Vector3.max(max,out,max),bounds.setMax(max),Laya.Render.supportWebGLPlusCulling&&this._calculateBoundingBoxForNative();var floatCount=2*this._floatCountPerVertices1;this._vertexBuffer1.setData(this._vertices1.buffer,4*vertexOffset,4*vertexOffset,4*floatCount)}_updateVerticesByPosition(position,pointAtoBVector3,delDistance,index){this._updateVerticesByPositionData(position,pointAtoBVector3,index),this._subDistance[index]=delDistance,this._subBirthTime[index]=this._owner._curtime}_updateVertexBufferUV(){var bounds,min,max;this._disappearBoundsMode&&(min=(bounds=this._owner._owner.trailRenderer.bounds).getMin(),max=bounds.getMax(),min.setValue(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),max.setValue(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),Laya.Render.supportWebGLPlusCulling&&this._calculateBoundingBoxForNative());for(var vertexCount=this._endIndex,curLength=0,gradient=this._owner.colorGradient,startAlphaIndex=gradient.colorAlphaKeysCount-1,startColorIndex=gradient.colorRGBKeysCount-1,totalLength=this._owner._totalLength,stride=2*this._floatCountPerVertices2,i=this._activeIndex;i=this._owner.time+MathUtils3D.zeroTolerance;i++){var nextIndex=i+1;if(nextIndex!==count&&(this._owner._totalLength-=this._subDistance[nextIndex]),this._isTempEndVertex&&nextIndex===count-1){this._floatCountPerVertices1;var fixedPos=this._lastFixedVertexPosition;fixedPos.x=this._vertices1[0],fixedPos.y=this._vertices1[1],fixedPos.z=this._vertices1[2],this._isTempEndVertex=!1}this._activeIndex++,this._disappearBoundsMode=!0}}_getType(){return TrailGeometry._type}_prepareRender(state){return this._endIndex-this._activeIndex>1}_render(state){this._bufferState.bind();var gl=Laya.LayaGL.instance,start=2*this._activeIndex,count=2*this._endIndex-start;gl.drawArrays(gl.TRIANGLE_STRIP,start,count),Laya.Stat.renderBatches++,Laya.Stat.trianglesFaces+=count-2}destroy(){super.destroy();var memorySize=this._vertexBuffer1._byteLength+this._vertexBuffer2._byteLength;Laya.Resource._addMemory(-memorySize,-memorySize),this._bufferState.destroy(),this._vertexBuffer1.destroy(),this._vertexBuffer2.destroy(),this._bufferState=null,this._vertices1=null,this._vertexBuffer1=null,this._vertices2=null,this._vertexBuffer2=null,this._subBirthTime=null,this._subDistance=null,this._lastFixedVertexPosition=null,this._disappearBoundsMode=!1}_calculateBoundingBoxForNative(){var trail=this._owner._owner.trailRenderer,bounds=trail.bounds,min=bounds.getMin(),max=bounds.getMax(),buffer=FrustumCulling._cullingBuffer;buffer[trail._cullingBufferIndex+1]=min.x,buffer[trail._cullingBufferIndex+2]=min.y,buffer[trail._cullingBufferIndex+3]=min.z,buffer[trail._cullingBufferIndex+4]=max.x,buffer[trail._cullingBufferIndex+5]=max.y,buffer[trail._cullingBufferIndex+6]=max.z}}TrailGeometry.ALIGNMENT_VIEW=0,TrailGeometry.ALIGNMENT_TRANSFORM_Z=1,TrailGeometry._tempVector30=new Vector3,TrailGeometry._tempVector31=new Vector3,TrailGeometry._tempVector32=new Vector3,TrailGeometry._tempVector33=new Vector3,TrailGeometry._tempVector34=new Vector3,TrailGeometry._tempVector35=new Vector3,TrailGeometry._tempVector36=new Vector3,TrailGeometry._type=GeometryElement._typeCounter++;class TrailFilter{constructor(owner){this._totalLength=0,this._lastPosition=new Vector3,this._curtime=0,this.alignment=TrailFilter.ALIGNMENT_VIEW,this._owner=owner,this._initDefaultData(),this.addRenderElement()}get time(){return this._time}set time(value){this._time=value,this._owner._render._shaderValues.setNumber(TrailFilter.LIFETIME,value)}get minVertexDistance(){return this._minVertexDistance}set minVertexDistance(value){this._minVertexDistance=value}get widthMultiplier(){return this._widthMultiplier}set widthMultiplier(value){this._widthMultiplier=value}get widthCurve(){return this._widthCurve}set widthCurve(value){this._widthCurve=value;var i,j,widthCurveFloatArray=new Float32Array(4*value.length),index=0;for(i=0,j=value.length;i0?(one.name=uniName=uniName.substr(0,uniName.length-3),one.isArray=!0):(one.name=uniName,one.isArray=!1),one.type=uniformData.type,this._addShaderUnifiormFun(one);var uniformPeriod=this._uniformMap[uniName];if(null!=uniformPeriod)switch(one.dataOffset=Shader3D.propertyNameToID(uniName),uniformPeriod){case Shader3D.PERIOD_CUSTOM:customParms.push(one);break;case Shader3D.PERIOD_MATERIAL:materialParms.push(one);break;case Shader3D.PERIOD_SPRITE:spriteParms.push(one);break;case Shader3D.PERIOD_CAMERA:cameraParms.push(one);break;case Shader3D.PERIOD_SCENE:sceneParms.push(one);break;default:throw new Error("Shader3D: period is unkonw.")}}for(this._sceneUniformParamsMap=Laya.LayaGL.instance.createCommandEncoder(4*sceneParms.length*5+4,64,!0),i=0,n=sceneParms.length;ivalue);i++){value&d&&(o[int2Name[d]]="")}return o}_compileToTree(parent,lines,start,includefiles,defs){var node,preNode,text,name,fname,ofs,words,noUseNode,i,n,j;for(i=start;i=0&&(text=text.substr(0,ofs)),node=noUseNode||new Laya.ShaderNode(includefiles),noUseNode=null,node.text=text,(ofs=text.indexOf("#"))>=0){for(name="#",j=ofs+1,n=text.length;j0&&Laya.ShaderCompile.splitToWords(text,preNode),noUseNode=node,preNode.text+="\n"+text;continue}includefiles.length>0&&Laya.ShaderCompile.splitToWords(text,node)}node.setParent(parent)}}withCompile(publicDefine,spriteDefine,materialDefine){var shader,spriteDefShaders,materialDefShaders;if(publicDefine&=this._publicValidDefine,spriteDefine&=this._spriteValidDefine,materialDefine&=this._materialValidDefine,spriteDefShaders=this._cacheSharders[publicDefine])if(materialDefShaders=spriteDefShaders[spriteDefine]){if(shader=materialDefShaders[materialDefine])return shader}else materialDefShaders=spriteDefShaders[spriteDefine]=[];else materialDefShaders=(spriteDefShaders=this._cacheSharders[publicDefine]=[])[spriteDefine]=[];var key,publicDefGroup=this._definesToNameDic(publicDefine,this._owner._publicDefines),spriteDefGroup=this._definesToNameDic(spriteDefine,this._owner._spriteDefines),materialDefGroup=this._definesToNameDic(materialDefine,this._owner._materialDefines);if(Shader3D.debugMode){var publicDefGroupStr="";for(key in publicDefGroup)publicDefGroupStr+=key+" ";var spriteDefGroupStr="";for(key in spriteDefGroup)spriteDefGroupStr+=key+" ";var materialDefGroupStr="";for(key in materialDefGroup)materialDefGroupStr+=key+" ";Laya.WebGL.shaderHighPrecision||(publicDefine+=Shader3D.SHADERDEFINE_HIGHPRECISION),console.log("%cShader3DDebugMode---(Name:"+this._owner._owner._name+" SubShaderIndex:"+this._owner._owner._subShaders.indexOf(this._owner)+" PassIndex:"+this._owner._passes.indexOf(this)+" PublicDefine:"+publicDefine+" SpriteDefine:"+spriteDefine+" MaterialDefine:"+materialDefine+" PublicDefineGroup:"+publicDefGroupStr+" SpriteDefineGroup:"+spriteDefGroupStr+"MaterialDefineGroup: "+materialDefGroupStr+")---ShaderCompile3DDebugMode","color:green")}var defMap={},defineStr="";if(publicDefGroup)for(key in publicDefGroup)defineStr+="#define "+key+"\n",defMap[key]=!0;if(spriteDefGroup)for(key in spriteDefGroup)defineStr+="#define "+key+"\n",defMap[key]=!0;if(materialDefGroup)for(key in materialDefGroup)defineStr+="#define "+key+"\n",defMap[key]=!0;var vs=this._VS.toscript(defMap,[]),vsVersion="";0==vs[0].indexOf("#version")&&(vsVersion=vs[0]+"\n",vs.shift());var ps=this._PS.toscript(defMap,[]),psVersion="";return 0==ps[0].indexOf("#version")&&(psVersion=ps[0]+"\n",ps.shift()),shader=new ShaderInstance(vsVersion+defineStr+vs.join("\n"),psVersion+defineStr+ps.join("\n"),this._owner._attributeMap||this._owner._owner._attributeMap,this._owner._uniformMap||this._owner._owner._uniformMap,this),materialDefShaders[materialDefine]=shader,shader}}class SubShader{constructor(attributeMap,uniformMap,spriteDefines=null,materialDefines=null){this._flags={},this._passes=[],this._publicDefines=[],this._publicDefinesMap={},this._spriteDefines=[],this._spriteDefinesMap={},this._materialDefines=[],this._materialDefinesMap={},this._addDefines(this._publicDefines,this._publicDefinesMap,Shader3D._globleDefines),spriteDefines&&this._addDefines(this._spriteDefines,this._spriteDefinesMap,spriteDefines.defines),materialDefines&&this._addDefines(this._materialDefines,this._materialDefinesMap,materialDefines.defines),this._attributeMap=attributeMap,this._uniformMap=uniformMap}_addDefines(defines,definesMap,supportDefines){for(var k in supportDefines){var name=supportDefines[k],i=parseInt(k);defines[i]=name,definesMap[name]=i}}getMaterialDefineByName(name){return this._materialDefinesMap[name]}setFlag(key,value){value?this._flags[key]=value:delete this._flags[key]}getFlag(key){return this._flags[key]}addShaderPass(vs,ps,stateMap=null){var shaderPass=new ShaderPass(this,vs,ps,stateMap);return this._passes.push(shaderPass),shaderPass}}var BlitScreenPS="#ifdef FSHIGHPRECISION\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\nuniform sampler2D u_MainTex;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_FragColor = texture2D(u_MainTex, v_Texcoord0);\r\n}\r\n\r\n",BlitScreenVS='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_PositionTexcoord;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\r\n\tv_Texcoord0 = a_PositionTexcoord.zw;\r\n\tgl_Position = remapGLPositionZ(gl_Position);\r\n}',EffectPS="#ifdef HIGHPRECISION\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#ifdef COLOR\r\n\tvarying vec4 v_Color;\r\n#endif\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef MAINTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\t#ifdef ADDTIVEFOG\r\n\t#else\r\n\t\tuniform vec3 u_FogColor;\r\n\t#endif\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 color = 2.0 * u_AlbedoColor;\r\n\t#ifdef COLOR\r\n\t\tcolor *= v_Color;\r\n\t#endif\r\n\t#ifdef MAINTEXTURE\r\n\t\tcolor *= texture2D(u_AlbedoTexture, v_Texcoord0);\r\n\t#endif\r\n\t\r\n\tgl_FragColor = color;\r\n\t\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\r\n\t\t#ifdef ADDTIVEFOG\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.0), lerpFact);\r\n\t\t#else\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\r\n\t\t#endif\r\n\t#endif\r\n}\r\n\r\n",EffectVS='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec4 a_Color;\r\nattribute vec2 a_Texcoord0;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n#endif\r\n\r\n#ifdef COLOR\r\n\tvarying vec4 v_Color;\r\n#endif\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\t\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t#else\r\n\t\tv_Texcoord0=a_Texcoord0;\r\n\t#endif\r\n\t\t\r\n\t#ifdef COLOR\r\n\t\tv_Color = a_Color;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',extendTerrainPS='#ifdef HIGHPRECISION\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Lighting.glsl";\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\r\n\tuniform vec3 u_CameraPos;\r\n\tvarying vec3 v_Normal;\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\tuniform vec3 u_FogColor;\r\n#endif\r\n\r\n\r\n#ifdef DIRECTIONLIGHT\r\n\tuniform DirectionLight u_DirectionLight;\r\n#endif\r\n\r\n#ifdef POINTLIGHT\r\n\tuniform PointLight u_PointLight;\r\n#endif\r\n\r\n#ifdef SPOTLIGHT\r\n\tuniform SpotLight u_SpotLight;\r\n#endif\r\n\r\n#include "ShadowHelper.glsl"\r\n#ifdef RECEIVESHADOW\r\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\r\n\tuniform mat4 u_lightShadowVP[4];\r\n\t#endif\r\n\t#ifdef SHADOWMAP_PSSM1 \r\n\tvarying vec4 v_lightMVPPos;\r\n\t#endif\r\n#endif\r\nvarying float v_posViewZ;\r\n\r\nuniform vec3 u_AmbientColor;\r\n\r\nuniform sampler2D u_SplatAlphaTexture;\r\n\r\nuniform sampler2D u_DiffuseTexture1;\r\nuniform sampler2D u_DiffuseTexture2;\r\nuniform sampler2D u_DiffuseTexture3;\r\nuniform sampler2D u_DiffuseTexture4;\r\nuniform sampler2D u_DiffuseTexture5;\r\n\r\nuniform vec4 u_DiffuseScaleOffset1;\r\nuniform vec4 u_DiffuseScaleOffset2;\r\nuniform vec4 u_DiffuseScaleOffset3;\r\nuniform vec4 u_DiffuseScaleOffset4;\r\nuniform vec4 u_DiffuseScaleOffset5;\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef LIGHTMAP\r\n\tuniform sampler2D u_LightMap;\r\n\tvarying vec2 v_LightMapUV;\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 splatAlpha = vec4(1.0);\r\n\t#ifdef ExtendTerrain_DETAIL_NUM1\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r;\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM2\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * (1.0 - splatAlpha.r);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM3\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * (1.0 - splatAlpha.r - splatAlpha.g);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM4\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM5\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\r\n\t\tvec4 color5 = texture2D(u_DiffuseTexture5, v_Texcoord0 * u_DiffuseScaleOffset5.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * splatAlpha.a + color5.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b - splatAlpha.a);\r\n\t#endif\r\n\t\tgl_FragColor.w = splatAlpha.a;\r\n\t\t\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n vec3 normal = v_Normal;\r\n\tvec3 dif, spe;\r\n#endif\r\n\r\nvec3 diffuse = vec3(0.0);\r\nvec3 specular= vec3(0.0);\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\r\n\tvec3 toEye;\r\n\t#ifdef FOG\r\n\t\ttoEye=u_CameraPos-v_PositionWorld;\r\n\t\tfloat toEyeLength=length(toEye);\r\n\t\ttoEye/=toEyeLength;\r\n\t#else\r\n\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\r\n\t#endif\r\n#endif\r\n\r\n#ifdef DIRECTIONLIGHT\r\n\tLayaAirBlinnPhongDiectionLight(vec3(0.0), 1.0, normal, vec3(1.0), toEye,u_DirectionLight, dif, spe);\r\n\tdiffuse+=dif;\r\n\tspecular+=spe;\r\n#endif\r\n \r\n#ifdef POINTLIGHT\r\n\tLayaAirBlinnPhongPointLight(v_PositionWorld, vec3(0.0), 1.0, normal, vec3(1.0), toEye, u_PointLight, dif, spe);\r\n\tdiffuse+=dif;\r\n\tspecular+=spe;\r\n#endif\r\n\r\n#ifdef SPOTLIGHT\r\n\tLayaAirBlinnPhongSpotLight(v_PositionWorld, vec3(0.0), 1.0, normal, vec3(1.0), toEye, u_SpotLight, dif, spe);\r\n\tdiffuse+=dif;\r\n\tspecular+=spe;\r\n#endif\r\n\r\nvec3 globalDiffuse = u_AmbientColor;\r\n#ifdef LIGHTMAP\r\n\tglobalDiffuse += DecodeLightmap(texture2D(u_LightMap, v_LightMapUV));\r\n#endif\r\n\r\n#ifdef RECEIVESHADOW\r\n\tfloat shadowValue = 1.0;\r\n\t#ifdef SHADOWMAP_PSSM3\r\n\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\r\n\t#endif\r\n\t#ifdef SHADOWMAP_PSSM2\r\n\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\r\n\t#endif \r\n\t#ifdef SHADOWMAP_PSSM1\r\n\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\r\n\t#endif\r\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse) * shadowValue, gl_FragColor.a);\r\n#else\r\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse), gl_FragColor.a);\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t#ifdef RECEIVESHADOW\r\n\t\tgl_FragColor.rgb += specular * shadowValue;\r\n\t#else\r\n\t\tgl_FragColor.rgb += specular;\r\n\t#endif\r\n#endif\r\n\r\n#ifdef FOG\r\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\r\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\r\n#endif\r\n}\r\n\r\n\r\n\r\n\r\n\r\n',extendTerrainVS='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec2 a_Texcoord0;\r\n\r\nuniform mat4 u_MvpMatrix;\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\r\n\tattribute vec3 a_Normal;\r\n\tvarying vec3 v_Normal;\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\r\n\tuniform mat4 u_WorldMat;\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform vec4 u_LightmapScaleOffset;\r\n#endif\r\n\r\n#ifdef RECEIVESHADOW\r\n\tvarying float v_posViewZ;\r\n\t#ifdef SHADOWMAP_PSSM1 \r\n\t\tvarying vec4 v_lightMVPPos;\r\n\t\tuniform mat4 u_lightShadowVP[4];\r\n\t#endif\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tgl_Position = u_MvpMatrix * a_Position;\r\n \r\n\tv_Texcoord0 = a_Texcoord0;\r\n \r\n\t#ifdef LIGHTMAP\r\n\t\tv_LightMapUV = vec2(a_Texcoord0.x, 1.0 - a_Texcoord0.y) * u_LightmapScaleOffset.xy + u_LightmapScaleOffset.zw;\r\n\t\tv_LightMapUV.y = 1.0 - v_LightMapUV.y;\r\n\t#endif\r\n \r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tv_Normal = a_Normal;\r\n\t#endif\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\r\n\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\r\n\t#endif\r\n\r\n\t#ifdef RECEIVESHADOW\r\n\t\tv_posViewZ = gl_Position.w;\r\n\t\t#ifdef SHADOWMAP_PSSM1\r\n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\r\n\t\t#endif\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',LightingGLSL="\r\nstruct DirectionLight {\r\n\tvec3 Color;\r\n\tvec3 Direction;\r\n};\r\n\r\nstruct PointLight {\r\n\tvec3 Color;\r\n\tvec3 Position;\r\n\tfloat Range;\r\n};\r\n\r\nstruct SpotLight {\r\n\tvec3 Color;\r\n\tvec3 Position;\r\n\tvec3 Direction;\r\n\tfloat Spot;\r\n\tfloat Range;\r\n};\r\n\r\n// Laya中使用衰减纹理\r\nfloat LayaAttenuation(in vec3 L,in float invLightRadius) {\r\n\tfloat fRatio = clamp(length(L) * invLightRadius,0.0,1.0);\r\n\tfRatio *= fRatio;\r\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\r\n}\r\n\r\n// Same as Just Cause 2 and Crysis 2 (you can read GPU Pro 1 book for more information)\r\nfloat BasicAttenuation(in vec3 L,in float invLightRadius) {\r\n\tvec3 distance = L * invLightRadius;\r\n\tfloat attenuation = clamp(1.0 - dot(distance, distance),0.0,1.0); // Equals float attenuation = saturate(1.0f - dot(L, L) / (lightRadius * lightRadius));\r\n\treturn attenuation * attenuation;\r\n}\r\n\r\n// Inspired on http://fools.slindev.com/viewtopic.php?f=11&t=21&view=unread#unread\r\nfloat NaturalAttenuation(in vec3 L,in float invLightRadius) {\r\n\tfloat attenuationFactor = 30.0;\r\n\tvec3 distance = L * invLightRadius;\r\n\tfloat attenuation = dot(distance, distance); // Equals float attenuation = dot(L, L) / (lightRadius * lightRadius);\r\n\tattenuation = 1.0 / (attenuation * attenuationFactor + 1.0);\r\n\t// Second we move down the function therewith it reaches zero at abscissa 1:\r\n\tattenuationFactor = 1.0 / (attenuationFactor + 1.0); //attenuationFactor contains now the value we have to subtract\r\n\tattenuation = max(attenuation - attenuationFactor, 0.0); // The max fixes a bug.\r\n\t// Finally we expand the equation along the y-axis so that it starts with a function value of 1 again.\r\n\tattenuation /= 1.0 - attenuationFactor;\r\n\treturn attenuation;\r\n}\r\n\r\nvoid LayaAirBlinnPhongLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir,in vec3 lightColor, in vec3 lightVec,out vec3 diffuseColor,out vec3 specularColor) {\r\n\tmediump vec3 h = normalize(viewDir-lightVec);\r\n\tlowp float ln = max (0.0, dot (-lightVec,normal));\r\n\tfloat nh = max (0.0, dot (h,normal));\r\n\tdiffuseColor=lightColor * ln;\r\n\tspecularColor=lightColor *specColor*pow (nh, specColorIntensity*128.0) * gloss;\r\n}\r\n\r\nvoid LayaAirBlinnPhongDiectionLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor,out vec3 specularColor) {\r\n\tvec3 lightVec=normalize(light.Direction);\r\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec,diffuseColor,specularColor);\r\n}\r\n\r\nvoid LayaAirBlinnPhongPointLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in PointLight light,out vec3 diffuseColor,out vec3 specularColor) {\r\n\tvec3 lightVec = pos-light.Position;\r\n\t//if( length(lightVec) > light.Range )\r\n\t//\treturn;\r\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec/length(lightVec),diffuseColor,specularColor);\r\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.Range);\r\n\tdiffuseColor *= attenuate;\r\n\tspecularColor*= attenuate;\r\n}\r\n\r\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) {\r\n\tvec3 lightVec = pos-light.Position;\r\n\t//if( length(lightVec) > light.Range)\r\n\t//\treturn;\r\n\r\n\tvec3 normalLightVec=lightVec/length(lightVec);\r\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,normalLightVec,diffuseColor,specularColor);\r\n\tvec2 cosAngles=cos(vec2(light.Spot,light.Spot*0.5)*0.5);//ConeAttenuation\r\n\tfloat dl=dot(normalize(light.Direction),normalLightVec);\r\n\tdl*=smoothstep(cosAngles[0],cosAngles[1],dl);\r\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.Range)*dl;\r\n\tdiffuseColor *=attenuate;\r\n\tspecularColor *=attenuate;\r\n}\r\n\r\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent,vec3 binormal) {\r\n\tvec3 normalT =vec3(2.0*normalMapSample.x - 1.0,1.0-2.0*normalMapSample.y,2.0*normalMapSample.z - 1.0);\r\n\r\n\t// Build orthonormal basis.\r\n\tvec3 N = normalize(unitNormal);\r\n\tvec3 T = normalize(tangent);\r\n\tvec3 B = normalize(binormal);\r\n\tmat3 TBN = mat3(T, B, N);\r\n\r\n\t// Transform from tangent space to world space.\r\n\tvec3 bumpedNormal = TBN*normalT;\r\n\r\n\treturn bumpedNormal;\r\n}\r\n\r\nvec3 NormalSampleToWorldSpace1(vec4 normalMapSample, vec3 tangent, vec3 binormal, vec3 unitNormal) {\r\n\tvec3 normalT;\r\n\tnormalT.x = 2.0 * normalMapSample.x - 1.0;\r\n\tnormalT.y = 1.0 - 2.0 * normalMapSample.y;\r\n\tnormalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\r\n\r\n\tvec3 T = normalize(tangent);\r\n\tvec3 B = normalize(binormal);\r\n\tvec3 N = normalize(unitNormal);\r\n\tmat3 TBN = mat3(T, B, N);\r\n\r\n\t// Transform from tangent space to world space.\r\n\tvec3 bumpedNormal = TBN * normalize(normalT);\r\n\r\n\treturn bumpedNormal;\r\n}\r\n\r\nvec3 DecodeLightmap(vec4 color) {\r\n\treturn color.rgb*color.a*5.0;\r\n}\r\n\r\nvec2 TransformUV(vec2 texcoord,vec4 tilingOffset) {\r\n\tvec2 transTexcoord=vec2(texcoord.x,texcoord.y-1.0)*tilingOffset.xy+vec2(tilingOffset.z,-tilingOffset.w);\r\n\ttransTexcoord.y+=1.0;\r\n\treturn transTexcoord;\r\n}\r\n\r\nvec4 remapGLPositionZ(vec4 position) {\r\n\tposition.z=position.z * 2.0 - position.w;\r\n\treturn position;\r\n}\r\n\r\nmat3 inverse(mat3 m) {\r\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\r\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\r\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\r\n\r\n float b01 = a22 * a11 - a12 * a21;\r\n float b11 = -a22 * a10 + a12 * a20;\r\n float b21 = a21 * a10 - a11 * a20;\r\n\r\n float det = a00 * b01 + a01 * b11 + a02 * b21;\r\n\r\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\r\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\r\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\r\n}\r\n\r\n",linePS="#ifdef HIGHPRECISION\r\nprecision highp float;\r\n#else\r\nprecision mediump float;\r\n#endif\r\n\r\nvarying vec4 v_Color;\r\nuniform vec4 u_Color;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = v_Color * u_Color; \r\n}\r\n\r\n",lineVS='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nuniform mat4 u_MvpMatrix;\r\nuniform vec4 u_Color;\r\nattribute vec4 a_Color;\r\nvarying vec4 v_Color;\r\n\r\n\r\nvoid main()\r\n{\r\n\tgl_Position = u_MvpMatrix * a_Position;\r\n\tv_Color=a_Color*u_Color;\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',MeshBlinnPhongPS='#ifdef HIGHPRECISION\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Lighting.glsl";\r\n\r\nuniform vec4 u_DiffuseColor;\r\n\r\n#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\tvarying vec4 v_Color;\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\tvarying vec3 v_ViewDir; \r\n#endif\r\n\r\n#ifdef ALPHATEST\r\n\tuniform float u_AlphaTestValue;\r\n#endif\r\n\r\n#ifdef DIFFUSEMAP\r\n\tuniform sampler2D u_DiffuseTexture;\r\n#endif\r\n\r\n\r\n\r\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform sampler2D u_LightMap;\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\tuniform vec3 u_MaterialSpecular;\r\n\tuniform float u_Shininess;\r\n\t#ifdef SPECULARMAP \r\n\t\tuniform sampler2D u_SpecularTexture;\r\n\t#endif\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\tuniform vec3 u_FogColor;\r\n#endif\r\n\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\tvarying vec3 v_Normal;\r\n#endif\r\n\r\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\r\n\tuniform sampler2D u_NormalTexture;\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\r\n#endif\r\n\r\n#ifdef DIRECTIONLIGHT\r\n\tuniform DirectionLight u_DirectionLight;\r\n#endif\r\n\r\n#ifdef POINTLIGHT\r\n\tuniform PointLight u_PointLight;\r\n#endif\r\n\r\n#ifdef SPOTLIGHT\r\n\tuniform SpotLight u_SpotLight;\r\n#endif\r\n\r\nuniform vec3 u_AmbientColor;\r\n\r\n\r\n#if defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n#include "ShadowHelper.glsl"\r\nvarying float v_posViewZ;\r\n#ifdef RECEIVESHADOW\r\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\r\n\t\tuniform mat4 u_lightShadowVP[4];\r\n\t#endif\r\n\t#ifdef SHADOWMAP_PSSM1 \r\n\t\tvarying vec4 v_lightMVPPos;\r\n\t#endif\r\n#endif\r\n\r\nvoid main_castShadow()\r\n{\r\n\t//gl_FragColor=vec4(v_posViewZ,0.0,0.0,1.0);\r\n\tgl_FragColor=packDepth(v_posViewZ);\r\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\r\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\r\n\t\tif( alpha < u_AlphaTestValue )\r\n\t\t{\r\n\t\t\tdiscard;\r\n\t\t}\r\n\t#endif\r\n}\r\nvoid main_normal()\r\n{\r\n\tvec3 globalDiffuse=u_AmbientColor;\r\n\t#ifdef LIGHTMAP\t\r\n\t\tglobalDiffuse += DecodeLightmap(texture2D(u_LightMap, v_LightMapUV));\r\n\t#endif\r\n\t\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tvec3 normal;\r\n\t\t#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\r\n\t\t\tvec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\r\n\t\t\tnormal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent,v_Binormal));\r\n\t\t#else\r\n\t\t\tnormal = normalize(v_Normal);\r\n\t\t#endif\r\n\t\tvec3 viewDir= normalize(v_ViewDir);\r\n\t#endif\r\n\t\r\n\tvec4 mainColor=u_DiffuseColor;\r\n\t#ifdef DIFFUSEMAP\r\n\t\tvec4 difTexColor=texture2D(u_DiffuseTexture, v_Texcoord0);\r\n\t\tmainColor=mainColor*difTexColor;\r\n\t#endif \r\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\t\tmainColor=mainColor*v_Color;\r\n\t#endif \r\n \r\n\t#ifdef ALPHATEST\r\n\t\tif(mainColor.a= 0.0) {// Sky\r\n\t\t// Calculate the length of the \"atmosphere\"\r\n\t\tfar = sqrt(outerRadius2 + innerRadius2 * eyeRay.y * eyeRay.y - innerRadius2) - innerRadius * eyeRay.y;\r\n\r\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\r\n\t\tfloat height = innerRadius + cameraHeight;\r\n\t\tfloat depth = exp(scaleOverScaleDepth * -cameraHeight);\r\n\t\tfloat startAngle = dot(eyeRay, cameraPos) / height;\r\n\t\tfloat startOffset = depth*scaleAngle(startAngle);\r\n\r\n\t\t// Initialize the scattering loop variables\r\n\t\tfloat sampleLength = far / samples;\r\n\t\tfloat scaledLength = sampleLength * scale;\r\n\t\tvec3 sampleRay = eyeRay * sampleLength;\r\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\r\n\r\n\t\tvec3 frontColor = vec3(0.0);\r\n\t\t//unrolling this manually to avoid some platform for loop slow\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat lightAngle = dot(-u_DirectionLight.Direction, samplePoint) / height;\r\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\r\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\r\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat lightAngle = dot(-u_DirectionLight.Direction, samplePoint) / height;\r\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\r\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\r\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\r\n\t\t// Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\r\n\t\tcIn = frontColor * (invWavelength * krESun);\r\n\t\tcOut = frontColor * kmESun;\r\n\t} else {// Ground\r\n\t\tfar = (-cameraHeight) / (min(-0.001, eyeRay.y));\r\n\t\tvec3 pos = cameraPos + far * eyeRay;\r\n\r\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\r\n\t\tfloat depth = exp((-cameraHeight) * (1.0/scaleDepth));\r\n\t\tfloat cameraAngle = dot(-eyeRay, pos);\r\n\t\tfloat lightAngle = dot(-u_DirectionLight.Direction, pos);\r\n\t\tfloat cameraScale = scaleAngle(cameraAngle);\r\n\t\tfloat lightScale = scaleAngle(lightAngle);\r\n\t\tfloat cameraOffset = depth*cameraScale;\r\n\t\tfloat temp = lightScale + cameraScale;\r\n\r\n\t\t// Initialize the scattering loop variables\r\n\t\tfloat sampleLength = far / samples;\r\n\t\tfloat scaledLength = sampleLength * scale;\r\n\t\tvec3 sampleRay = eyeRay * sampleLength;\r\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\r\n\r\n\t\t// Now loop through the sample rays\r\n\t\tvec3 frontColor = vec3(0.0, 0.0, 0.0);\r\n\t\tvec3 attenuate;\r\n\r\n\t\t// Loop removed because we kept hitting SM2.0 temp variable limits. Doesn't affect the image too much.\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat scatter = depth*temp - cameraOffset;\r\n\t\t\tattenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\r\n\t\tcIn = frontColor * (invWavelength * krESun + kmESun);\r\n\t\tcOut = clamp(attenuate, 0.0, 1.0);\r\n\t}\r\n\r\n\t#ifdef SUN_HIGH_QUALITY\r\n\t\tv_Vertex = -a_Position.xyz;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tv_RayDir = -eyeRay;\r\n\t#else\r\n\t\tv_SkyGroundFactor = -eyeRay.y / SKY_GROUND_THRESHOLD;\r\n\t#endif\r\n\r\n\t// if we want to calculate color in vprog:\r\n\t// in case of linear: multiply by _Exposure in here (even in case of lerp it will be common multiplier, so we can skip mul in fshader)\r\n\tv_GroundColor = u_Exposure * (cIn + u_GroundTint*u_GroundTint * cOut);//u_GroundColor*u_GroundColor is gamma space convert to linear space\r\n\tv_SkyColor = u_Exposure * (cIn * getRayleighPhase(-u_DirectionLight.Direction, -eyeRay));\r\n\r\n\t\r\n\t// The sun should have a stable intensity in its course in the sky. Moreover it should match the highlight of a purely specular material.\r\n\t// This matching was done using the Unity3D standard shader BRDF1 on the 5/31/2017\r\n\t// Finally we want the sun to be always bright even in LDR thus the normalization of the lightColor for low intensity.\r\n\tfloat lightColorIntensity = clamp(length(u_DirectionLight.Color), 0.25, 1.0);\r\n\r\n\t#ifdef SUN_HIGH_QUALITY \r\n\t\tv_SunColor = HDSundiskIntensityFactor * clamp(cOut,0.0,1.0) * u_DirectionLight.Color / lightColorIntensity;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tv_SunColor = simpleSundiskIntensityFactor * clamp(cOut * sunScale,0.0,1.0) * u_DirectionLight.Color / lightColorIntensity;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n",TrailPS="#ifdef HIGHPRECISION\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\nuniform sampler2D u_MainTexture;\r\nuniform vec4 u_MainColor;\r\n\r\nvarying vec2 v_Texcoord0;\r\nvarying vec4 v_Color;\r\n\r\nvoid main()\r\n{\r\n\tvec4 color = 2.0 * u_MainColor * v_Color;\r\n\t#ifdef MAINTEXTURE\r\n\t\tvec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\r\n\t\tcolor *= mainTextureColor;\r\n\t#endif\r\n\tgl_FragColor = color;\r\n}\r\n\r\n ",TrailVS='#include "Lighting.glsl";\r\n\r\nattribute vec3 a_Position;\r\nattribute vec3 a_OffsetVector;\r\nattribute vec4 a_Color;\r\nattribute float a_Texcoord0X;\r\nattribute float a_Texcoord0Y;\r\nattribute float a_BirthTime;\r\n\r\nuniform mat4 u_View;\r\nuniform mat4 u_Projection;\r\n\r\nuniform vec4 u_TilingOffset;\r\n\r\nuniform float u_CurTime;\r\nuniform float u_LifeTime;\r\nuniform vec4 u_WidthCurve[10];\r\nuniform int u_WidthCurveKeyLength;\r\n\r\nvarying vec2 v_Texcoord0;\r\nvarying vec4 v_Color;\r\n\r\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\r\n{\r\n\tfloat t2 = t * t;\r\n\tfloat t3 = t2 * t;\r\n\tfloat a = 2.0 * t3 - 3.0 * t2 + 1.0;\r\n\tfloat b = t3 - 2.0 * t2 + t;\r\n\tfloat c = t3 - t2;\r\n\tfloat d = -2.0 * t3 + 3.0 * t2;\r\n\treturn a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\r\n}\r\n\r\nfloat getCurWidth(in float normalizeTime)\r\n{\r\n\tfloat width;\r\n\tif(normalizeTime == 0.0){\r\n\t\twidth=u_WidthCurve[0].w;\r\n\t}\r\n\telse if(normalizeTime >= 1.0){\r\n\t\twidth=u_WidthCurve[u_WidthCurveKeyLength - 1].w;\r\n\t}\r\n\telse{\r\n\t\tfor(int i = 0; i < 10; i ++ )\r\n\t\t{\r\n\t\t\tif(normalizeTime == u_WidthCurve[i].x){\r\n\t\t\t\twidth=u_WidthCurve[i].w;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvec4 lastFrame = u_WidthCurve[i];\r\n\t\t\tvec4 nextFrame = u_WidthCurve[i + 1];\r\n\t\t\tif(normalizeTime > lastFrame.x && normalizeTime < nextFrame.x)\r\n\t\t\t{\r\n\t\t\t\tfloat duration = nextFrame.x - lastFrame.x;\r\n\t\t\t\tfloat t = (normalizeTime - lastFrame.x) / duration;\r\n\t\t\t\tfloat outTangent = lastFrame.z;\r\n\t\t\t\tfloat inTangent = nextFrame.y;\r\n\t\t\t\tfloat value1 = lastFrame.w;\r\n\t\t\t\tfloat value2 = nextFrame.w;\r\n\t\t\t\twidth=hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn width;\r\n}\t\r\n\r\nvoid main()\r\n{\r\n\tfloat normalizeTime = (u_CurTime - a_BirthTime) / u_LifeTime;\r\n\t\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, 1.0 - a_Texcoord0Y) * u_TilingOffset.xy + u_TilingOffset.zw;\r\n\t#else\r\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\r\n\t#endif\r\n\t\r\n\tv_Color = a_Color;\r\n\t\r\n\tgl_Position = u_Projection * u_View * vec4(a_Position + a_OffsetVector * getCurWidth(normalizeTime),1.0);\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n',UnlitPS="#ifdef HIGHPRECISION\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\tvarying vec4 v_Color;\r\n#endif\r\n\r\n#ifdef ALBEDOTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\r\n\r\n#ifdef ALPHATEST\r\n\tuniform float u_AlphaTestValue;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\t#ifdef ADDTIVEFOG\r\n\t#else\r\n\t\tuniform vec3 u_FogColor;\r\n\t#endif\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 color = u_AlbedoColor;\r\n\t#ifdef ALBEDOTEXTURE\r\n\t\tcolor *= texture2D(u_AlbedoTexture, v_Texcoord0);\r\n\t#endif\r\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\t\tcolor *= v_Color;\r\n\t#endif\r\n\t\r\n\t#ifdef ALPHATEST\r\n\t\tif(color.a < u_AlphaTestValue)\r\n\t\t\tdiscard;\r\n\t#endif\r\n\t\r\n\tgl_FragColor = color;\r\n\t\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\r\n\t\t#ifdef ADDTIVEFOG\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.0), lerpFact);\r\n\t\t#else\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\r\n\t\t#endif\r\n\t#endif\r\n\t\r\n}\r\n\r\n",UnlitVS='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\n\r\nattribute vec2 a_Texcoord0;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n#endif\r\n\r\nattribute vec4 a_Color;\r\nvarying vec4 v_Color;\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nvoid main() {\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t#else\r\n\t\tv_Texcoord0=a_Texcoord0;\r\n\t#endif\r\n\r\n\t#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\r\n\t\tv_Color = a_Color;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',WaterPrimaryPS='#ifdef HIGHPRECISION\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#ifdef MAINTEXTURE\r\n\tuniform sampler2D u_MainTexture;\r\n#endif\r\n\r\n#ifdef NORMALTEXTURE\r\n\tuniform sampler2D u_NormalTexture;\r\n#endif\r\n\r\nuniform vec4 u_HorizonColor;\r\n\r\nvarying vec3 v_Normal;\r\nvarying vec3 v_Tangent;\r\nvarying vec3 v_Binormal;\r\nvarying vec3 v_ViewDir;\r\nvarying vec2 v_Texcoord0;\r\nvarying vec2 v_Texcoord1;\r\n\r\n#include "Lighting.glsl"\r\n\r\nvoid main()\r\n{\r\n\tvec4 bumpColor1 = texture2D(u_NormalTexture, v_Texcoord0);\r\n\tvec4 bumpColor2 = texture2D(u_NormalTexture, v_Texcoord1);\r\n\t\r\n\tvec3 normal1 = NormalSampleToWorldSpace1(bumpColor1, v_Tangent, v_Binormal, v_Normal);\r\n\tvec3 normal2 = NormalSampleToWorldSpace1(bumpColor2, v_Tangent, v_Binormal, v_Normal);\r\n\t\r\n\tvec3 normal = normalize((normal1 + normal2) * 0.5);\r\n\tvec3 viewDir = normalize(v_ViewDir);\r\n\tfloat fresnel = dot(viewDir, normal);\r\n\t\r\n\tvec4 waterColor = texture2D(u_MainTexture, vec2(fresnel, fresnel));\r\n\t\r\n\tvec4 color;\r\n\tcolor.rgb = mix(waterColor.rgb, u_HorizonColor.rgb, vec3(waterColor.a));\r\n\tcolor.a = u_HorizonColor.a;\r\n\t\r\n\tgl_FragColor = color;\r\n}\r\n\r\n',WaterPrimaryVS='#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec3 a_Normal;\r\nattribute vec4 a_Tangent0;\r\n\r\nuniform mat4 u_MvpMatrix;\r\nuniform mat4 u_WorldMat;\r\nuniform vec3 u_CameraPos;\r\nuniform float u_WaveScale;\r\nuniform vec4 u_WaveSpeed;\r\nuniform float u_Time;\r\n\r\nvarying vec3 v_Normal;\r\nvarying vec3 v_Tangent;\r\nvarying vec3 v_Binormal;\r\nvarying vec3 v_ViewDir;\r\nvarying vec2 v_Texcoord0;\r\nvarying vec2 v_Texcoord1;\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionWorld = u_WorldMat * a_Position;\r\n\tvec4 position = u_MvpMatrix * a_Position;\r\n\t\r\n\tvec4 temp = vec4(positionWorld.x, positionWorld.z, positionWorld.x, positionWorld.z) * u_WaveScale + u_WaveSpeed * u_WaveScale * u_Time;\r\n\t\r\n\tv_Texcoord0 = temp.xy * vec2(0.4, 0.45);\r\n\tv_Texcoord1 = temp.wz;\r\n\t\r\n\tmat3 worldMat = mat3(u_WorldMat);\r\n\tv_Normal = worldMat * a_Normal;\r\n\tv_Tangent = worldMat * a_Tangent0.xyz;\r\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\r\n\t\r\n\tv_ViewDir = u_CameraPos - positionWorld.xyz;\r\n\tgl_Position = position;\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}';class ShaderInit3D{constructor(){}static __init__(){ShaderInit3D._rangeAttenTex=Utils3D._buildTexture2D(1024,1,Laya.BaseTexture.FORMAT_ALPHA8,TextureGenerator.lightAttenTexture),ShaderInit3D._rangeAttenTex.wrapModeU=Laya.BaseTexture.WARPMODE_CLAMP,ShaderInit3D._rangeAttenTex.wrapModeV=Laya.BaseTexture.WARPMODE_CLAMP,ShaderInit3D._rangeAttenTex.lock=!0,Shader3D.SHADERDEFINE_HIGHPRECISION=Shader3D.registerPublicDefine("HIGHPRECISION"),Shader3D.addInclude("Lighting.glsl",LightingGLSL),Shader3D.addInclude("ShadowHelper.glsl",ShadowHelperGLSL),Shader3D.addInclude("BRDF.glsl",BRDFGLSL),Shader3D.addInclude("PBRUtils.glsl",PBRUtilsGLSL),Shader3D.addInclude("PBRStandardLighting.glsl",PBRStandardLightingGLSL),Shader3D.addInclude("PBRSpecularLighting.glsl",PBRSpecularLightingGLSL),Shader3D.addInclude("Colors.glsl",ColorsGLSL),Shader3D.addInclude("Sampling.glsl",SamplingGLSL),Shader3D.addInclude("StdLib.glsl",StdLibGLSL);var attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Color:VertexMesh.MESH_COLOR0,a_Normal:VertexMesh.MESH_NORMAL0,a_Texcoord0:VertexMesh.MESH_TEXTURECOORDINATE0,a_Texcoord1:VertexMesh.MESH_TEXTURECOORDINATE1,a_BoneWeights:VertexMesh.MESH_BLENDWEIGHT0,a_BoneIndices:VertexMesh.MESH_BLENDINDICES0,a_Tangent0:VertexMesh.MESH_TANGENT0,a_MvpMatrix:VertexMesh.MESH_MVPMATRIX_ROW0,a_WorldMat:VertexMesh.MESH_WORLDMATRIX_ROW0},uniformMap={u_Bones:Shader3D.PERIOD_CUSTOM,u_DiffuseTexture:Shader3D.PERIOD_MATERIAL,u_SpecularTexture:Shader3D.PERIOD_MATERIAL,u_NormalTexture:Shader3D.PERIOD_MATERIAL,u_AlphaTestValue:Shader3D.PERIOD_MATERIAL,u_DiffuseColor:Shader3D.PERIOD_MATERIAL,u_MaterialSpecular:Shader3D.PERIOD_MATERIAL,u_Shininess:Shader3D.PERIOD_MATERIAL,u_TilingOffset:Shader3D.PERIOD_MATERIAL,u_WorldMat:Shader3D.PERIOD_SPRITE,u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_LightmapScaleOffset:Shader3D.PERIOD_SPRITE,u_LightMap:Shader3D.PERIOD_SPRITE,u_CameraPos:Shader3D.PERIOD_CAMERA,u_ReflectTexture:Shader3D.PERIOD_SCENE,u_ReflectIntensity:Shader3D.PERIOD_SCENE,u_FogStart:Shader3D.PERIOD_SCENE,u_FogRange:Shader3D.PERIOD_SCENE,u_FogColor:Shader3D.PERIOD_SCENE,"u_DirectionLight.Color":Shader3D.PERIOD_SCENE,"u_DirectionLight.Direction":Shader3D.PERIOD_SCENE,"u_PointLight.Position":Shader3D.PERIOD_SCENE,"u_PointLight.Range":Shader3D.PERIOD_SCENE,"u_PointLight.Color":Shader3D.PERIOD_SCENE,"u_SpotLight.Position":Shader3D.PERIOD_SCENE,"u_SpotLight.Direction":Shader3D.PERIOD_SCENE,"u_SpotLight.Range":Shader3D.PERIOD_SCENE,"u_SpotLight.Spot":Shader3D.PERIOD_SCENE,"u_SpotLight.Color":Shader3D.PERIOD_SCENE,u_AmbientColor:Shader3D.PERIOD_SCENE,u_shadowMap1:Shader3D.PERIOD_SCENE,u_shadowMap2:Shader3D.PERIOD_SCENE,u_shadowMap3:Shader3D.PERIOD_SCENE,u_shadowPSSMDistance:Shader3D.PERIOD_SCENE,u_lightShadowVP:Shader3D.PERIOD_SCENE,u_shadowPCFoffset:Shader3D.PERIOD_SCENE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("BLINNPHONG",null,null,!0),subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,BlinnPhongMaterial.shaderDefines);shader.addSubShader(subShader),subShader.addShaderPass(MeshBlinnPhongVS,MeshBlinnPhongPS,stateMap),attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Color:VertexMesh.MESH_COLOR0},uniformMap={u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_Color:Shader3D.PERIOD_MATERIAL},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("LineShader"),subShader=new SubShader(attributeMap,uniformMap),shader.addSubShader(subShader),subShader.addShaderPass(lineVS,linePS,stateMap),attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Normal:VertexMesh.MESH_NORMAL0,a_Tangent0:VertexMesh.MESH_TANGENT0,a_Texcoord0:VertexMesh.MESH_TEXTURECOORDINATE0,a_BoneWeights:VertexMesh.MESH_BLENDWEIGHT0,a_BoneIndices:VertexMesh.MESH_BLENDINDICES0,a_MvpMatrix:VertexMesh.MESH_MVPMATRIX_ROW0,a_WorldMat:VertexMesh.MESH_WORLDMATRIX_ROW0},uniformMap={u_Bones:Shader3D.PERIOD_CUSTOM,u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_WorldMat:Shader3D.PERIOD_SPRITE,u_CameraPos:Shader3D.PERIOD_CAMERA,u_AlphaTestValue:Shader3D.PERIOD_MATERIAL,u_AlbedoColor:Shader3D.PERIOD_MATERIAL,u_EmissionColor:Shader3D.PERIOD_MATERIAL,u_AlbedoTexture:Shader3D.PERIOD_MATERIAL,u_NormalTexture:Shader3D.PERIOD_MATERIAL,u_ParallaxTexture:Shader3D.PERIOD_MATERIAL,u_MetallicGlossTexture:Shader3D.PERIOD_MATERIAL,u_OcclusionTexture:Shader3D.PERIOD_MATERIAL,u_EmissionTexture:Shader3D.PERIOD_MATERIAL,u_metallic:Shader3D.PERIOD_MATERIAL,u_smoothness:Shader3D.PERIOD_MATERIAL,u_smoothnessScale:Shader3D.PERIOD_MATERIAL,u_occlusionStrength:Shader3D.PERIOD_MATERIAL,u_normalScale:Shader3D.PERIOD_MATERIAL,u_parallaxScale:Shader3D.PERIOD_MATERIAL,u_TilingOffset:Shader3D.PERIOD_MATERIAL,"u_DirectionLight.Direction":Shader3D.PERIOD_SCENE,"u_DirectionLight.Color":Shader3D.PERIOD_SCENE,u_PointLightMatrix:Shader3D.PERIOD_SCENE,"u_PointLight.Position":Shader3D.PERIOD_SCENE,"u_PointLight.Range":Shader3D.PERIOD_SCENE,"u_PointLight.Color":Shader3D.PERIOD_SCENE,"u_SpotLight.Position":Shader3D.PERIOD_SCENE,"u_SpotLight.Direction":Shader3D.PERIOD_SCENE,"u_SpotLight.Range":Shader3D.PERIOD_SCENE,"u_SpotLight.SpotAngle":Shader3D.PERIOD_SCENE,"u_SpotLight.Color":Shader3D.PERIOD_SCENE,u_RangeTexture:Shader3D.PERIOD_SCENE,u_ReflectTexture:Shader3D.PERIOD_SCENE,u_ReflectIntensity:Shader3D.PERIOD_SCENE,u_AmbientColor:Shader3D.PERIOD_SCENE,u_shadowMap1:Shader3D.PERIOD_SCENE,u_shadowMap2:Shader3D.PERIOD_SCENE,u_shadowMap3:Shader3D.PERIOD_SCENE,u_shadowPSSMDistance:Shader3D.PERIOD_SCENE,u_lightShadowVP:Shader3D.PERIOD_SCENE,u_shadowPCFoffset:Shader3D.PERIOD_SCENE,u_FogStart:Shader3D.PERIOD_SCENE,u_FogRange:Shader3D.PERIOD_SCENE,u_FogColor:Shader3D.PERIOD_SCENE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("PBRStandard",null,null,!0),subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,PBRStandardMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(PBRStandardVS,PBRStandardPS,stateMap),attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Normal:VertexMesh.MESH_NORMAL0,a_Tangent0:VertexMesh.MESH_TANGENT0,a_Texcoord0:VertexMesh.MESH_TEXTURECOORDINATE0,a_BoneWeights:VertexMesh.MESH_BLENDWEIGHT0,a_BoneIndices:VertexMesh.MESH_BLENDINDICES0,a_MvpMatrix:VertexMesh.MESH_MVPMATRIX_ROW0,a_WorldMat:VertexMesh.MESH_WORLDMATRIX_ROW0},uniformMap={u_Bones:Shader3D.PERIOD_CUSTOM,u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_WorldMat:Shader3D.PERIOD_SPRITE,u_CameraPos:Shader3D.PERIOD_CAMERA,u_AlphaTestValue:Shader3D.PERIOD_MATERIAL,u_AlbedoColor:Shader3D.PERIOD_MATERIAL,u_SpecularColor:Shader3D.PERIOD_MATERIAL,u_EmissionColor:Shader3D.PERIOD_MATERIAL,u_AlbedoTexture:Shader3D.PERIOD_MATERIAL,u_NormalTexture:Shader3D.PERIOD_MATERIAL,u_ParallaxTexture:Shader3D.PERIOD_MATERIAL,u_SpecularTexture:Shader3D.PERIOD_MATERIAL,u_OcclusionTexture:Shader3D.PERIOD_MATERIAL,u_EmissionTexture:Shader3D.PERIOD_MATERIAL,u_smoothness:Shader3D.PERIOD_MATERIAL,u_smoothnessScale:Shader3D.PERIOD_MATERIAL,u_occlusionStrength:Shader3D.PERIOD_MATERIAL,u_normalScale:Shader3D.PERIOD_MATERIAL,u_parallaxScale:Shader3D.PERIOD_MATERIAL,u_TilingOffset:Shader3D.PERIOD_MATERIAL,"u_DirectionLight.Direction":Shader3D.PERIOD_SCENE,"u_DirectionLight.Color":Shader3D.PERIOD_SCENE,u_PointLightMatrix:Shader3D.PERIOD_SCENE,"u_PointLight.Position":Shader3D.PERIOD_SCENE,"u_PointLight.Range":Shader3D.PERIOD_SCENE,"u_PointLight.Color":Shader3D.PERIOD_SCENE,"u_SpotLight.Position":Shader3D.PERIOD_SCENE,"u_SpotLight.Direction":Shader3D.PERIOD_SCENE,"u_SpotLight.Range":Shader3D.PERIOD_SCENE,"u_SpotLight.SpotAngle":Shader3D.PERIOD_SCENE,"u_SpotLight.Color":Shader3D.PERIOD_SCENE,u_RangeTexture:Shader3D.PERIOD_SCENE,u_ReflectTexture:Shader3D.PERIOD_SCENE,u_ReflectIntensity:Shader3D.PERIOD_SCENE,u_AmbientColor:Shader3D.PERIOD_SCENE,u_shadowMap1:Shader3D.PERIOD_SCENE,u_shadowMap2:Shader3D.PERIOD_SCENE,u_shadowMap3:Shader3D.PERIOD_SCENE,u_shadowPSSMDistance:Shader3D.PERIOD_SCENE,u_lightShadowVP:Shader3D.PERIOD_SCENE,u_shadowPCFoffset:Shader3D.PERIOD_SCENE,u_FogStart:Shader3D.PERIOD_SCENE,u_FogRange:Shader3D.PERIOD_SCENE,u_FogColor:Shader3D.PERIOD_SCENE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("PBRSpecular",null,null,!0),subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,PBRSpecularMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(PBRSpecularVS,PBRSpecularPS,stateMap),attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Color:VertexMesh.MESH_COLOR0,a_Texcoord0:VertexMesh.MESH_TEXTURECOORDINATE0,a_BoneWeights:VertexMesh.MESH_BLENDWEIGHT0,a_BoneIndices:VertexMesh.MESH_BLENDINDICES0,a_MvpMatrix:VertexMesh.MESH_MVPMATRIX_ROW0},uniformMap={u_Bones:Shader3D.PERIOD_CUSTOM,u_AlbedoTexture:Shader3D.PERIOD_MATERIAL,u_AlbedoColor:Shader3D.PERIOD_MATERIAL,u_TilingOffset:Shader3D.PERIOD_MATERIAL,u_AlphaTestValue:Shader3D.PERIOD_MATERIAL,u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_FogStart:Shader3D.PERIOD_SCENE,u_FogRange:Shader3D.PERIOD_SCENE,u_FogColor:Shader3D.PERIOD_SCENE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("Unlit",null,null,!0),subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,UnlitMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(UnlitVS,UnlitPS,stateMap),attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Texcoord0:VertexMesh.MESH_TEXTURECOORDINATE0,a_BoneWeights:VertexMesh.MESH_BLENDWEIGHT0,a_BoneIndices:VertexMesh.MESH_BLENDINDICES0,a_MvpMatrix:VertexMesh.MESH_MVPMATRIX_ROW0},uniformMap={u_Bones:Shader3D.PERIOD_CUSTOM,u_AlbedoTexture:Shader3D.PERIOD_MATERIAL,u_AlbedoColor:Shader3D.PERIOD_MATERIAL,u_TilingOffset:Shader3D.PERIOD_MATERIAL,u_AlphaTestValue:Shader3D.PERIOD_MATERIAL,u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_FogStart:Shader3D.PERIOD_SCENE,u_FogRange:Shader3D.PERIOD_SCENE,u_FogColor:Shader3D.PERIOD_SCENE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("Effect",null,null,!0),subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,EffectMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(EffectVS,EffectPS,stateMap),attributeMap={a_CornerTextureCoordinate:VertexShuriKenParticle.PARTICLE_CORNERTEXTURECOORDINATE0,a_MeshPosition:VertexShuriKenParticle.PARTICLE_POSITION0,a_MeshColor:VertexShuriKenParticle.PARTICLE_COLOR0,a_MeshTextureCoordinate:VertexShuriKenParticle.PARTICLE_TEXTURECOORDINATE0,a_ShapePositionStartLifeTime:VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME,a_DirectionTime:VertexShuriKenParticle.PARTICLE_DIRECTIONTIME,a_StartColor:VertexShuriKenParticle.PARTICLE_STARTCOLOR0,a_EndColor:VertexShuriKenParticle.PARTICLE_ENDCOLOR0,a_StartSize:VertexShuriKenParticle.PARTICLE_STARTSIZE,a_StartRotation0:VertexShuriKenParticle.PARTICLE_STARTROTATION,a_StartSpeed:VertexShuriKenParticle.PARTICLE_STARTSPEED,a_Random0:VertexShuriKenParticle.PARTICLE_RANDOM0,a_Random1:VertexShuriKenParticle.PARTICLE_RANDOM1,a_SimulationWorldPostion:VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION,a_SimulationWorldRotation:VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION},uniformMap={u_Tintcolor:Shader3D.PERIOD_MATERIAL,u_TilingOffset:Shader3D.PERIOD_MATERIAL,u_texture:Shader3D.PERIOD_MATERIAL,u_WorldPosition:Shader3D.PERIOD_SPRITE,u_WorldRotation:Shader3D.PERIOD_SPRITE,u_PositionScale:Shader3D.PERIOD_SPRITE,u_SizeScale:Shader3D.PERIOD_SPRITE,u_ScalingMode:Shader3D.PERIOD_SPRITE,u_Gravity:Shader3D.PERIOD_SPRITE,u_ThreeDStartRotation:Shader3D.PERIOD_SPRITE,u_StretchedBillboardLengthScale:Shader3D.PERIOD_SPRITE,u_StretchedBillboardSpeedScale:Shader3D.PERIOD_SPRITE,u_SimulationSpace:Shader3D.PERIOD_SPRITE,u_CurrentTime:Shader3D.PERIOD_SPRITE,u_ColorOverLifeGradientAlphas:Shader3D.PERIOD_SPRITE,u_ColorOverLifeGradientColors:Shader3D.PERIOD_SPRITE,u_MaxColorOverLifeGradientAlphas:Shader3D.PERIOD_SPRITE,u_MaxColorOverLifeGradientColors:Shader3D.PERIOD_SPRITE,u_VOLVelocityConst:Shader3D.PERIOD_SPRITE,u_VOLVelocityGradientX:Shader3D.PERIOD_SPRITE,u_VOLVelocityGradientY:Shader3D.PERIOD_SPRITE,u_VOLVelocityGradientZ:Shader3D.PERIOD_SPRITE,u_VOLVelocityConstMax:Shader3D.PERIOD_SPRITE,u_VOLVelocityGradientMaxX:Shader3D.PERIOD_SPRITE,u_VOLVelocityGradientMaxY:Shader3D.PERIOD_SPRITE,u_VOLVelocityGradientMaxZ:Shader3D.PERIOD_SPRITE,u_VOLSpaceType:Shader3D.PERIOD_SPRITE,u_SOLSizeGradient:Shader3D.PERIOD_SPRITE,u_SOLSizeGradientX:Shader3D.PERIOD_SPRITE,u_SOLSizeGradientY:Shader3D.PERIOD_SPRITE,u_SOLSizeGradientZ:Shader3D.PERIOD_SPRITE,u_SOLSizeGradientMax:Shader3D.PERIOD_SPRITE,u_SOLSizeGradientMaxX:Shader3D.PERIOD_SPRITE,u_SOLSizeGradientMaxY:Shader3D.PERIOD_SPRITE,u_SOLSizeGradientMaxZ:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityConst:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityConstSeprarate:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradient:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientX:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientY:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientZ:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityConstMax:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityConstMaxSeprarate:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientMax:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxX:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxY:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxZ:Shader3D.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxW:Shader3D.PERIOD_SPRITE,u_TSACycles:Shader3D.PERIOD_SPRITE,u_TSASubUVLength:Shader3D.PERIOD_SPRITE,u_TSAGradientUVs:Shader3D.PERIOD_SPRITE,u_TSAMaxGradientUVs:Shader3D.PERIOD_SPRITE,u_CameraPos:Shader3D.PERIOD_CAMERA,u_CameraDirection:Shader3D.PERIOD_CAMERA,u_CameraUp:Shader3D.PERIOD_CAMERA,u_View:Shader3D.PERIOD_CAMERA,u_Projection:Shader3D.PERIOD_CAMERA,u_FogStart:Shader3D.PERIOD_SCENE,u_FogRange:Shader3D.PERIOD_SCENE,u_FogColor:Shader3D.PERIOD_SCENE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("PARTICLESHURIKEN"),subShader=new SubShader(attributeMap,uniformMap,ShuriKenParticle3D.shaderDefines,ShurikenParticleMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(ParticleShuriKenVS,ParticleShuriKenPS,stateMap),attributeMap={a_Position:VertexMesh.MESH_POSITION0},uniformMap={u_TintColor:Shader3D.PERIOD_MATERIAL,u_Exposure:Shader3D.PERIOD_MATERIAL,u_Rotation:Shader3D.PERIOD_MATERIAL,u_CubeTexture:Shader3D.PERIOD_MATERIAL,u_ViewProjection:Shader3D.PERIOD_CAMERA},shader=Shader3D.add("SkyBox"),subShader=new SubShader(attributeMap,uniformMap),shader.addSubShader(subShader),subShader.addShaderPass(SkyBoxVS,SkyBoxPS),attributeMap={a_Position:VertexMesh.MESH_POSITION0},uniformMap={u_SunSize:Shader3D.PERIOD_MATERIAL,u_SunSizeConvergence:Shader3D.PERIOD_MATERIAL,u_AtmosphereThickness:Shader3D.PERIOD_MATERIAL,u_SkyTint:Shader3D.PERIOD_MATERIAL,u_GroundTint:Shader3D.PERIOD_MATERIAL,u_Exposure:Shader3D.PERIOD_MATERIAL,u_ViewProjection:Shader3D.PERIOD_CAMERA,"u_DirectionLight.Direction":Shader3D.PERIOD_SCENE,"u_DirectionLight.Color":Shader3D.PERIOD_SCENE},shader=Shader3D.add("SkyBoxProcedural"),subShader=new SubShader(attributeMap,uniformMap,null,SkyProceduralMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(SkyBoxProceduralVS,SkyBoxProceduralPS),attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Normal:VertexMesh.MESH_NORMAL0,a_Texcoord0:VertexMesh.MESH_TEXTURECOORDINATE0},uniformMap={u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_WorldMat:Shader3D.PERIOD_SPRITE,u_CameraPos:Shader3D.PERIOD_CAMERA,u_LightmapScaleOffset:Shader3D.PERIOD_SPRITE,u_LightMap:Shader3D.PERIOD_SPRITE,u_SplatAlphaTexture:Shader3D.PERIOD_MATERIAL,u_DiffuseTexture1:Shader3D.PERIOD_MATERIAL,u_DiffuseTexture2:Shader3D.PERIOD_MATERIAL,u_DiffuseTexture3:Shader3D.PERIOD_MATERIAL,u_DiffuseTexture4:Shader3D.PERIOD_MATERIAL,u_DiffuseTexture5:Shader3D.PERIOD_MATERIAL,u_DiffuseScaleOffset1:Shader3D.PERIOD_MATERIAL,u_DiffuseScaleOffset2:Shader3D.PERIOD_MATERIAL,u_DiffuseScaleOffset3:Shader3D.PERIOD_MATERIAL,u_DiffuseScaleOffset4:Shader3D.PERIOD_MATERIAL,u_DiffuseScaleOffset5:Shader3D.PERIOD_MATERIAL,u_FogStart:Shader3D.PERIOD_SCENE,u_FogRange:Shader3D.PERIOD_SCENE,u_FogColor:Shader3D.PERIOD_SCENE,"u_DirectionLight.Direction":Shader3D.PERIOD_SCENE,"u_DirectionLight.Color":Shader3D.PERIOD_SCENE,"u_PointLight.Position":Shader3D.PERIOD_SCENE,"u_PointLight.Range":Shader3D.PERIOD_SCENE,"u_PointLight.Attenuation":Shader3D.PERIOD_SCENE,"u_PointLight.Color":Shader3D.PERIOD_SCENE,"u_SpotLight.Position":Shader3D.PERIOD_SCENE,"u_SpotLight.Direction":Shader3D.PERIOD_SCENE,"u_SpotLight.Range":Shader3D.PERIOD_SCENE,"u_SpotLight.Spot":Shader3D.PERIOD_SCENE,"u_SpotLight.Color":Shader3D.PERIOD_SCENE,u_AmbientColor:Shader3D.PERIOD_SCENE,u_shadowMap1:Shader3D.PERIOD_SCENE,u_shadowMap2:Shader3D.PERIOD_SCENE,u_shadowMap3:Shader3D.PERIOD_SCENE,u_shadowPSSMDistance:Shader3D.PERIOD_SCENE,u_lightShadowVP:Shader3D.PERIOD_SCENE,u_shadowPCFoffset:Shader3D.PERIOD_SCENE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("ExtendTerrain"),subShader=new SubShader(attributeMap,uniformMap,RenderableSprite3D.shaderDefines,ExtendTerrainMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(extendTerrainVS,extendTerrainPS,stateMap),attributeMap={a_Position:VertexTrail.TRAIL_POSITION0,a_OffsetVector:VertexTrail.TRAIL_OFFSETVECTOR,a_Texcoord0X:VertexTrail.TRAIL_TEXTURECOORDINATE0X,a_Texcoord0Y:VertexTrail.TRAIL_TEXTURECOORDINATE0Y,a_BirthTime:VertexTrail.TRAIL_TIME0,a_Color:VertexTrail.TRAIL_COLOR},uniformMap={u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_View:Shader3D.PERIOD_CAMERA,u_Projection:Shader3D.PERIOD_CAMERA,u_TilingOffset:Shader3D.PERIOD_MATERIAL,u_MainTexture:Shader3D.PERIOD_MATERIAL,u_MainColor:Shader3D.PERIOD_MATERIAL,u_CurTime:Shader3D.PERIOD_SPRITE,u_LifeTime:Shader3D.PERIOD_SPRITE,u_WidthCurve:Shader3D.PERIOD_SPRITE,u_WidthCurveKeyLength:Shader3D.PERIOD_SPRITE,u_GradientColorkey:Shader3D.PERIOD_SPRITE,u_GradientAlphakey:Shader3D.PERIOD_SPRITE},stateMap={s_Cull:Shader3D.RENDER_STATE_CULL,s_Blend:Shader3D.RENDER_STATE_BLEND,s_BlendSrc:Shader3D.RENDER_STATE_BLEND_SRC,s_BlendDst:Shader3D.RENDER_STATE_BLEND_DST,s_DepthTest:Shader3D.RENDER_STATE_DEPTH_TEST,s_DepthWrite:Shader3D.RENDER_STATE_DEPTH_WRITE},shader=Shader3D.add("Trail"),subShader=new SubShader(attributeMap,uniformMap,TrailSprite3D.shaderDefines,TrailMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(TrailVS,TrailPS,stateMap),attributeMap={a_Position:VertexMesh.MESH_POSITION0,a_Normal:VertexMesh.MESH_NORMAL0,a_Tangent0:VertexMesh.MESH_TANGENT0},uniformMap={u_MvpMatrix:Shader3D.PERIOD_SPRITE,u_WorldMat:Shader3D.PERIOD_SPRITE,u_CameraPos:Shader3D.PERIOD_CAMERA,u_Time:Shader3D.PERIOD_SCENE,u_MainTexture:Shader3D.PERIOD_MATERIAL,u_NormalTexture:Shader3D.PERIOD_MATERIAL,u_HorizonColor:Shader3D.PERIOD_MATERIAL,u_WaveScale:Shader3D.PERIOD_MATERIAL,u_WaveSpeed:Shader3D.PERIOD_MATERIAL},shader=Shader3D.add("WaterPrimary"),subShader=new SubShader(attributeMap,uniformMap,null,WaterPrimaryMaterial.shaderDefines),shader.addSubShader(subShader),subShader.addShaderPass(WaterPrimaryVS,WaterPrimaryPS),attributeMap={a_PositionTexcoord:VertexMesh.MESH_POSITION0},uniformMap={u_MainTex:Shader3D.PERIOD_MATERIAL},shader=Shader3D.add("BlitScreen"),subShader=new SubShader(attributeMap,uniformMap,null,null),shader.addSubShader(subShader);var shaderPass=subShader.addShaderPass(BlitScreenVS,BlitScreenPS),renderState=shaderPass.renderState;renderState.depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE,attributeMap={a_PositionTexcoord:VertexMesh.MESH_POSITION0},uniformMap={u_MainTex:Shader3D.PERIOD_MATERIAL,u_BloomTex:Shader3D.PERIOD_MATERIAL,u_AutoExposureTex:Shader3D.PERIOD_MATERIAL,u_MainTex_TexelSize:Shader3D.PERIOD_MATERIAL,u_SampleScale:Shader3D.PERIOD_MATERIAL,u_Threshold:Shader3D.PERIOD_MATERIAL,u_Params:Shader3D.PERIOD_MATERIAL},shader=Shader3D.add("PostProcessBloom",attributeMap,uniformMap),subShader=new SubShader(null,null,null,null),shader.addSubShader(subShader),(renderState=(shaderPass=subShader.addShaderPass(BloomVS,BloomPrefilter13PS)).renderState).depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE,subShader=new SubShader(null,null,null,null),shader.addSubShader(subShader),(renderState=(shaderPass=subShader.addShaderPass(BloomVS,BloomPrefilter4PS)).renderState).depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE,subShader=new SubShader(null,null,null,null),shader.addSubShader(subShader),(renderState=(shaderPass=subShader.addShaderPass(BloomVS,BloomDownsample13PS)).renderState).depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE,subShader=new SubShader(null,null,null,null),shader.addSubShader(subShader),(renderState=(shaderPass=subShader.addShaderPass(BloomVS,BloomDownsample4PS)).renderState).depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE,subShader=new SubShader(null,null,null,null),shader.addSubShader(subShader),(renderState=(shaderPass=subShader.addShaderPass(BloomVS,BloomUpsampleTentPS)).renderState).depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE,subShader=new SubShader(null,null,null,null),shader.addSubShader(subShader),(renderState=(shaderPass=subShader.addShaderPass(BloomVS,BloomUpsampleBoxPS)).renderState).depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE,attributeMap={a_PositionTexcoord:VertexMesh.MESH_POSITION0},uniformMap={u_MainTex:Shader3D.PERIOD_MATERIAL,u_BloomTex:Shader3D.PERIOD_MATERIAL,u_AutoExposureTex:Shader3D.PERIOD_MATERIAL,u_Bloom_DirtTileOffset:Shader3D.PERIOD_MATERIAL,u_Bloom_DirtTex:Shader3D.PERIOD_MATERIAL,u_BloomTex_TexelSize:Shader3D.PERIOD_MATERIAL,u_Bloom_Settings:Shader3D.PERIOD_MATERIAL,u_Bloom_Color:Shader3D.PERIOD_MATERIAL},shader=Shader3D.add("PostProcessComposite",attributeMap,uniformMap),subShader=new SubShader(null,null,null,PostProcess.shaderDefines),shader.addSubShader(subShader),(renderState=(shaderPass=subShader.addShaderPass(CompositeVS,CompositePS)).renderState).depthTest=RenderState.DEPTHTEST_ALWAYS,renderState.depthWrite=!1,renderState.cull=RenderState.CULL_NONE,renderState.blend=RenderState.BLEND_DISABLE}}class PixelLineMaterial extends BaseMaterial{constructor(){super(),this.setShaderName("LineShader"),this._shaderValues.setVector(PixelLineMaterial.COLOR,new Vector4(1,1,1,1))}static __initDefine__(){PixelLineMaterial.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines)}get color(){return this._shaderValues.getVector(PixelLineMaterial.COLOR)}set color(value){this._shaderValues.setVector(PixelLineMaterial.COLOR,value)}set depthWrite(value){this._shaderValues.setBool(PixelLineMaterial.DEPTH_WRITE,value)}get depthWrite(){return this._shaderValues.getBool(PixelLineMaterial.DEPTH_WRITE)}set cull(value){this._shaderValues.setInt(PixelLineMaterial.CULL,value)}get cull(){return this._shaderValues.getInt(PixelLineMaterial.CULL)}set blend(value){this._shaderValues.setInt(PixelLineMaterial.BLEND,value)}get blend(){return this._shaderValues.getInt(PixelLineMaterial.BLEND)}set blendSrc(value){this._shaderValues.setInt(PixelLineMaterial.BLEND_SRC,value)}get blendSrc(){return this._shaderValues.getInt(PixelLineMaterial.BLEND_SRC)}set blendDst(value){this._shaderValues.setInt(PixelLineMaterial.BLEND_DST,value)}get blendDst(){return this._shaderValues.getInt(PixelLineMaterial.BLEND_DST)}set depthTest(value){this._shaderValues.setInt(PixelLineMaterial.DEPTH_TEST,value)}get depthTest(){return this._shaderValues.getInt(PixelLineMaterial.DEPTH_TEST)}clone(){var dest=new PixelLineMaterial;return this.cloneTo(dest),dest}}PixelLineMaterial.COLOR=Shader3D.propertyNameToID("u_Color"),PixelLineMaterial.shaderDefines=null,PixelLineMaterial.CULL=Shader3D.propertyNameToID("s_Cull"),PixelLineMaterial.BLEND=Shader3D.propertyNameToID("s_Blend"),PixelLineMaterial.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc"),PixelLineMaterial.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst"),PixelLineMaterial.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest"),PixelLineMaterial.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");class PixelLineVertex{static get vertexDeclaration(){return PixelLineVertex._vertexDeclaration}static __init__(){PixelLineVertex._vertexDeclaration=new VertexDeclaration(28,[new VertexElement(0,VertexElementFormat.Vector3,VertexMesh.MESH_POSITION0),new VertexElement(12,VertexElementFormat.Vector4,VertexMesh.MESH_COLOR0)])}get vertexDeclaration(){return PixelLineVertex._vertexDeclaration}constructor(){}}class PixelLineFilter extends GeometryElement{constructor(owner,maxLineCount){super(),this._floatCountPerVertices=7,this._minUpdate=Number.MAX_VALUE,this._maxUpdate=Number.MIN_VALUE,this._bufferState=new BufferState,this._maxLineCount=0,this._lineCount=0;var pointCount=2*maxLineCount;this._owner=owner,this._maxLineCount=maxLineCount,this._vertices=new Float32Array(pointCount*this._floatCountPerVertices),this._vertexBuffer=new VertexBuffer3D(PixelLineVertex.vertexDeclaration.vertexStride*pointCount,Laya.LayaGL.instance.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=PixelLineVertex.vertexDeclaration,this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind()}_getType(){return PixelLineFilter._type}_resizeLineData(maxCount){var pointCount=2*maxCount,lastVertices=this._vertices;this._vertexBuffer.destroy(),this._maxLineCount=maxCount;var vertexCount=pointCount*this._floatCountPerVertices;this._vertices=new Float32Array(vertexCount),this._vertexBuffer=new VertexBuffer3D(PixelLineVertex.vertexDeclaration.vertexStride*pointCount,Laya.LayaGL.instance.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=PixelLineVertex.vertexDeclaration,vertexCount0){this._bufferState.bind();var gl=Laya.LayaGL.instance;gl.drawArrays(gl.LINES,0,2*this._lineCount),Laya.Stat.renderBatches++}}destroy(){this._destroyed||(super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferState=null,this._vertexBuffer=null,this._vertices=null)}}PixelLineFilter._type=GeometryElement._typeCounter++;class PixelLineRenderer extends BaseRender{constructor(owner){super(owner),this._projectionViewWorldMatrix=new Matrix4x4,this._supportOctree=!1}_calculateBoundingBox(){if((min=this._bounds.getMin()).x=-Number.MAX_VALUE,min.y=-Number.MAX_VALUE,min.z=-Number.MAX_VALUE,this._bounds.setMin(min),(max=this._bounds.getMax()).x=Number.MAX_VALUE,max.y=Number.MAX_VALUE,max.z=Number.MAX_VALUE,this._bounds.setMax(max),Laya.Render.supportWebGLPlusCulling){var min=this._bounds.getMin(),max=this._bounds.getMax(),buffer=FrustumCulling._cullingBuffer;buffer[this._cullingBufferIndex+1]=min.x,buffer[this._cullingBufferIndex+2]=min.y,buffer[this._cullingBufferIndex+3]=min.z,buffer[this._cullingBufferIndex+4]=max.x,buffer[this._cullingBufferIndex+5]=max.y,buffer[this._cullingBufferIndex+6]=max.z}}_renderUpdateWithCamera(context,transform){var projectionView=context.projectionViewMatrix,sv=this._shaderValues;if(transform){var worldMat=transform.worldMatrix;sv.setMatrix4x4(Sprite3D.WORLDMATRIX,worldMat),Matrix4x4.multiply(projectionView,worldMat,this._projectionViewWorldMatrix),sv.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix)}else sv.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT),sv.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView)}}class PixelLineSprite3D extends RenderableSprite3D{get maxLineCount(){return this._geometryFilter._maxLineCount}set maxLineCount(value){this._geometryFilter._resizeLineData(value),this._geometryFilter._lineCount=Math.min(this._geometryFilter._lineCount,value)}get lineCount(){return this._geometryFilter._lineCount}set lineCount(value){if(value>this.maxLineCount)throw"PixelLineSprite3D: lineCount can't large than maxLineCount";this._geometryFilter._lineCount=value}get pixelLineRenderer(){return this._render}constructor(maxCount=2,name=null){super(name),this._geometryFilter=new PixelLineFilter(this,maxCount),this._render=new PixelLineRenderer(this),this._changeRenderObjects(this._render,0,PixelLineMaterial.defaultMaterial)}_changeRenderObjects(sender,index,material){var renderObjects=this._render._renderElements;material||(material=PixelLineMaterial.defaultMaterial);var renderElement=renderObjects[index];renderElement||(renderElement=renderObjects[index]=new RenderElement),renderElement.setTransform(this._transform),renderElement.setGeometry(this._geometryFilter),renderElement.render=this._render,renderElement.material=material}addLine(startPosition,endPosition,startColor,endColor){if(this._geometryFilter._lineCount===this._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount has equal with maxLineCount.";this._geometryFilter._updateLineData(this._geometryFilter._lineCount++,startPosition,endPosition,startColor,endColor)}addLines(lines){var lineCount=this._geometryFilter._lineCount,addCount=lines.length;if(lineCount+addCount>this._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount plus lines count must less than maxLineCount.";this._geometryFilter._updateLineDatas(lineCount,lines),this._geometryFilter._lineCount+=addCount}removeLine(index){if(!(index0;)right--;if(left1){var index=this._partitionRenderObject(left,right),leftIndex=index-1;left=0;j--){var childObject=childObjects[j];this._objects.push(childObject),childObject._setOctreeNode(this)}}}this._children=null}_merge(){if(null===this._children){var parent=this._parent;parent&&parent._shouldMerge()&&(parent._mergeChildren(),parent._merge())}}_checkAddNode(object){if(null==this._children){if(this._objects.length=0;i--){var existObject=this._objects[i],fitChildIndex=this._bestFitChild(existObject.bounds.getCenter());BoundsOctreeNode._encapsulates(this._getChildBound(fitChildIndex),existObject.bounds._getBoundBox())&&(this._objects.splice(this._objects.indexOf(existObject),1),this._getChild(fitChildIndex)._add(existObject))}}var newFitChildIndex=this._bestFitChild(object.bounds.getCenter());return BoundsOctreeNode._encapsulates(this._getChildBound(newFitChildIndex),object.bounds._getBoundBox())?this._getChild(newFitChildIndex)._checkAddNode(object):this}_add(object){var addNode=this._checkAddNode(object);addNode._objects.push(object),object._setOctreeNode(addNode)}_remove(object){var index=this._objects.indexOf(object);this._objects.splice(index,1),object._setOctreeNode(null),this._merge()}_addUp(object){return CollisionUtils.boxContainsBox(this._bounds,object.bounds._getBoundBox())===ContainmentType.Contains?(this._add(object),!0):!!this._parent&&this._parent._addUp(object)}_getCollidingWithFrustum(context,frustum,testVisible,camPos,customShader,replacementTag){if(testVisible){var type=frustum.containsBoundBox(this._bounds);if(Laya.Stat.octreeNodeCulling++,type===ContainmentType.Disjoint)return;testVisible=type===ContainmentType.Intersects}this._isContaion=!testVisible;for(var camera=context.camera,scene=context.scene,i=0,n=this._objects.length;i=this.center.y?0:4)+(boundCenter.z<=this.center.z?0:2)}_update(object){if(CollisionUtils.boxContainsBox(this._bounds,object.bounds._getBoundBox())===ContainmentType.Contains){var addNode=this._checkAddNode(object);if(addNode!==object._getOctreeNode()){addNode._objects.push(object),object._setOctreeNode(addNode);var index=this._objects.indexOf(object);this._objects.splice(index,1),this._merge()}return!0}if(this._parent){var sucess=this._parent._addUp(object);return sucess&&(index=this._objects.indexOf(object),this._objects.splice(index,1),this._merge()),sucess}return!1}add(object){return!!BoundsOctreeNode._encapsulates(this._bounds,object.bounds._getBoundBox())&&(this._add(object),!0)}remove(object){return object._getOctreeNode()===this&&(this._remove(object),!0)}update(object){return object._getOctreeNode()===this&&this._update(object)}shrinkIfPossible(minLength){if(this.baseLength<2*minLength)return this;for(var bestFit=-1,i=0,n=this._objects.length;i=0&&bestFit!=i)return this;childHadContent=!0,bestFit=i}}if(-1!=bestFit){var newRoot=this._children[bestFit];return newRoot._parent=null,newRoot}return this}hasAnyObjects(){if(this._objects.length>0)return!0;if(null!=this._children)for(var i=0;i<8;i++){var child=this._children[i];if(child&&child.hasAnyObjects())return!0}return!1}getCollidingWithBoundBox(checkBound,result){this._getCollidingWithBoundBox(checkBound,!0,result)}getCollidingWithRay(ray,result,maxDistance=Number.MAX_VALUE){var distance=CollisionUtils.intersectsRayAndBoxRD(ray,this._bounds);if(!(-1==distance||distance>maxDistance)){for(var i=0,n=this._objects.length;imaxDistance)return!1;for(var i=0,n=this._objects.length;iinitialWorldSize&&(console.warn("Minimum node size must be at least as big as the initial world size. Was: "+minNodeSize+" Adjusted to: "+initialWorldSize),minNodeSize=initialWorldSize),this._initialSize=initialWorldSize,this._minSize=minNodeSize,this._looseness=Math.min(Math.max(looseness,1),2),this._rootNode=new BoundsOctreeNode(this,null,initialWorldSize,initialWorldPos)}_getMaxDepth(node,depth){depth++;var children=node._children;if(null!=children)for(var curDepth=depth,i=0,n=children.length;i=0?1:-1,yDirection=growObjectCenter.y>=0?1:-1,zDirection=growObjectCenter.z>=0?1:-1,oldRoot=this._rootNode,half=this._rootNode.baseLength/2,newLength=2*this._rootNode.baseLength,rootCenter=this._rootNode.center,newCenter=new Vector3(rootCenter.x+xDirection*half,rootCenter.y+yDirection*half,rootCenter.z+zDirection*half);if(this._rootNode=new BoundsOctreeNode(this,null,newLength,newCenter),oldRoot.hasAnyObjects()){for(var rootPos=this._rootNode._bestFitChild(oldRoot.center),children=[],i=0;i<8;i++)i==rootPos&&(oldRoot._parent=this._rootNode,children[i]=oldRoot);this._rootNode._children=children}}add(object){for(var count=0;!this._rootNode.add(object);){var growCenter=BoundsOctree._tempVector30;if(Vector3.subtract(object.bounds.getCenter(),this._rootNode.center,growCenter),this._grow(growCenter),++count>20)throw"Aborted Add operation as it seemed to be going on forever ("+(count-1)+") attempts at growing the octree."}this.count++}remove(object){var removed=object._getOctreeNode().remove(object);return removed&&this.count--,removed}update(object){var count=0,octreeNode=object._getOctreeNode();if(octreeNode){for(;!octreeNode._update(object);){var growCenter=BoundsOctree._tempVector30;if(Vector3.subtract(object.bounds.getCenter(),this._rootNode.center,growCenter),this._grow(growCenter),++count>20)throw"Aborted Add operation as it seemed to be going on forever ("+(count-1)+") attempts at growing the octree."}return!0}return!1}shrinkRootIfPossible(){this._rootNode=this._rootNode.shrinkIfPossible(this._initialSize)}addMotionObject(object){this._motionObjects.add(object)}removeMotionObject(object){this._motionObjects.remove(object)}updateMotionObjects(){for(var elements=this._motionObjects.elements,i=0,n=this._motionObjects.length;icamera._renderingOrder?end=mid-1:start=mid+1}return start}onEnable(){this._input._onCanvasEvent(Laya.Render.canvas)}onDisable(){this._input._offCanvasEvent(Laya.Render.canvas)}_setCreateURL(url){this._url=Laya.URL.formatURL(url)}_getGroup(){return this._group}_setGroup(value){this._group=value}_clearScript(){if(this._needClearScriptPool){for(var scripts=this._scriptPool,i=0,n=scripts.length;i0)for(var renderLightCount=0,i=0;i=this._enableLightCount);i++);}_addCamera(camera){for(var index=this._binarySearchIndexInCameraPool(camera),order=camera._renderingOrder,count=this._cameraPool.length;index=0&&this._lights.splice(index,1)}_addRenderObject(render){if(this._octree&&render._supportOctree)this._octree.add(render);else if(this._renders.add(render),Laya.Render.supportWebGLPlusCulling){var indexInList=render._getIndexInList(),length=this._cullingBufferIndices.length;if(indexInList>=length){var tempIndices=this._cullingBufferIndices,tempResult=this._cullingBufferResult;this._cullingBufferIndices=new Int32Array(length+1024),this._cullingBufferResult=new Int32Array(length+1024),this._cullingBufferIndices.set(tempIndices,0),this._cullingBufferResult.set(tempResult,0)}this._cullingBufferIndices[indexInList]=render._cullingBufferIndex}}_removeRenderObject(render){var endRender;this._octree&&render._supportOctree?this._octree.remove(render):(Laya.Render.supportWebGLPlusCulling&&(endRender=this._renders.elements[this._renders.length-1]),this._renders.remove(render),Laya.Render.supportWebGLPlusCulling&&(this._cullingBufferIndices[endRender._getIndexInList()]=endRender._cullingBufferIndex))}_addShadowCastRenderObject(render){this._octree||this._castShadowRenders.add(render)}_removeShadowCastRenderObject(render){this._octree||this._castShadowRenders.remove(render)}_getRenderQueue(index){return index<=2500?this._opaqueQueue:this._transparentQueue}setlightmaps(value){for(var maps=this._lightmaps,i=0,n=maps.length;i0&&ctx.addRenderObject(this)}renderSubmit(){var i,n,n1;Laya.LayaGL.instance;for(this._prepareSceneToRender(),i=0,n1=(n=this._cameraPool.length)-1;i0&&(oe[0]=se[0]*len,oe[1]=se[1]*len,oe[2]=se[2]*len,oe[3]=se[3]*len)}static add(a,b,out){var oe=out.elements,ae=a.elements,be=b.elements;oe[0]=ae[0]+be[0],oe[1]=ae[1]+be[1],oe[2]=ae[2]+be[2],oe[3]=ae[3]+be[3]}static subtract(a,b,out){var oe=out.elements,ae=a.elements,be=b.elements;oe[0]=ae[0]-be[0],oe[1]=ae[1]-be[1],oe[2]=ae[2]-be[2],oe[3]=ae[3]-be[3]}static multiply(a,b,out){var oe=out.elements,ae=a.elements,be=b.elements;oe[0]=ae[0]*be[0],oe[1]=ae[1]*be[1],oe[2]=ae[2]*be[2],oe[3]=ae[3]*be[3]}static scale(a,b,out){var oe=out.elements,ae=a.elements;oe[0]=ae[0]*b,oe[1]=ae[1]*b,oe[2]=ae[2]*b,oe[3]=ae[3]*b}static Clamp(value,min,max,out){var valuee=value.elements,x=valuee[0],y=valuee[1],z=valuee[2],w=valuee[3],mine=min.elements,mineX=mine[0],mineY=mine[1],mineZ=mine[2],mineW=mine[3],maxe=max.elements,maxeX=maxe[0],maxeY=maxe[1],maxeZ=maxe[2],maxeW=maxe[3],oute=out.elements;x=(x=x>maxeX?maxeX:x)maxeY?maxeY:y)maxeZ?maxeZ:z)maxeW?maxeW:w)0&&(len=1/Math.sqrt(len),oe[0]=se[0]*len,oe[1]=se[1]*len,oe[2]=se[2]*len)}static multiply(a,b,out){var e=out.elements,f=a.elements,g=b.elements;e[0]=f[0]*g[0],e[1]=f[1]*g[1],e[2]=f[2]*g[2]}static scale(a,b,out){var e=out.elements,f=a.elements;e[0]=f[0]*b,e[1]=f[1]*b,e[2]=f[2]*b}static lerp(a,b,t,out){var e=out.elements,f=a.elements,g=b.elements,ax=f[0],ay=f[1],az=f[2];e[0]=ax+t*(g[0]-ax),e[1]=ay+t*(g[1]-ay),e[2]=az+t*(g[2]-az)}static transformV3ToV3(vector,transform,result){var intermediate=ConchVector3._tempVector4;ConchVector3.transformV3ToV4(vector,transform,intermediate);var intermediateElem=intermediate.elements,resultElem=result.elements;resultElem[0]=intermediateElem[0],resultElem[1]=intermediateElem[1],resultElem[2]=intermediateElem[2]}static transformV3ToV4(vector,transform,result){var vectorElem=vector.elements,vectorX=vectorElem[0],vectorY=vectorElem[1],vectorZ=vectorElem[2],transformElem=transform.elements,resultElem=result.elements;resultElem[0]=vectorX*transformElem[0]+vectorY*transformElem[4]+vectorZ*transformElem[8]+transformElem[12],resultElem[1]=vectorX*transformElem[1]+vectorY*transformElem[5]+vectorZ*transformElem[9]+transformElem[13],resultElem[2]=vectorX*transformElem[2]+vectorY*transformElem[6]+vectorZ*transformElem[10]+transformElem[14],resultElem[3]=vectorX*transformElem[3]+vectorY*transformElem[7]+vectorZ*transformElem[11]+transformElem[15]}static TransformNormal(normal,transform,result){var normalElem=normal.elements,normalX=normalElem[0],normalY=normalElem[1],normalZ=normalElem[2],transformElem=transform.elements,resultElem=result.elements;resultElem[0]=normalX*transformElem[0]+normalY*transformElem[4]+normalZ*transformElem[8],resultElem[1]=normalX*transformElem[1]+normalY*transformElem[5]+normalZ*transformElem[9],resultElem[2]=normalX*transformElem[2]+normalY*transformElem[6]+normalZ*transformElem[10]}static transformCoordinate(coordinate,transform,result){var coordinateElem=coordinate.elements,coordinateX=coordinateElem[0],coordinateY=coordinateElem[1],coordinateZ=coordinateElem[2],transformElem=transform.elements,w=coordinateX*transformElem[3]+coordinateY*transformElem[7]+coordinateZ*transformElem[11]+transformElem[15],resultElem=result.elements;resultElem[0]=coordinateX*transformElem[0]+coordinateY*transformElem[4]+coordinateZ*transformElem[8]+transformElem[12]/w,resultElem[1]=coordinateX*transformElem[1]+coordinateY*transformElem[5]+coordinateZ*transformElem[9]+transformElem[13]/w,resultElem[2]=coordinateX*transformElem[2]+coordinateY*transformElem[6]+coordinateZ*transformElem[10]+transformElem[14]/w}static Clamp(value,min,max,out){var valuee=value.elements,x=valuee[0],y=valuee[1],z=valuee[2],mine=min.elements,mineX=mine[0],mineY=mine[1],mineZ=mine[2],maxe=max.elements,maxeX=maxe[0],maxeY=maxe[1],maxeZ=maxe[2],oute=out.elements;x=(x=x>maxeX?maxeX:x)maxeY?maxeY:y)maxeZ?maxeZ:z)0&&(len=1/Math.sqrt(len),o[0]=x*len,o[1]=y*len,o[2]=z*len,o[3]=w*len)}static _lerpArray(l,r,amount,o){var inverse=1-amount;ConchQuaternion._dotArray(l,r)>=0?(o[0]=inverse*l[0]+amount*r[0],o[1]=inverse*l[1]+amount*r[1],o[2]=inverse*l[2]+amount*r[2],o[3]=inverse*l[3]+amount*r[3]):(o[0]=inverse*l[0]-amount*r[0],o[1]=inverse*l[1]-amount*r[1],o[2]=inverse*l[2]-amount*r[2],o[3]=inverse*l[3]-amount*r[3]),ConchQuaternion._normalizeArray(o,o)}static createFromYawPitchRoll(yaw,pitch,roll,out){var halfRoll=.5*roll,halfPitch=.5*pitch,halfYaw=.5*yaw,sinRoll=Math.sin(halfRoll),cosRoll=Math.cos(halfRoll),sinPitch=Math.sin(halfPitch),cosPitch=Math.cos(halfPitch),sinYaw=Math.sin(halfYaw),cosYaw=Math.cos(halfYaw),oe=out.elements;oe[0]=cosYaw*sinPitch*cosRoll+sinYaw*cosPitch*sinRoll,oe[1]=sinYaw*cosPitch*cosRoll-cosYaw*sinPitch*sinRoll,oe[2]=cosYaw*cosPitch*sinRoll-sinYaw*sinPitch*cosRoll,oe[3]=cosYaw*cosPitch*cosRoll+sinYaw*sinPitch*sinRoll}static multiply(left,right,out){var le=left.elements,re=right.elements,oe=out.elements,lx=le[0],ly=le[1],lz=le[2],lw=le[3],rx=re[0],ry=re[1],rz=re[2],rw=re[3],a=ly*rz-lz*ry,b=lz*rx-lx*rz,c=lx*ry-ly*rx,d=lx*rx+ly*ry+lz*rz;oe[0]=lx*rw+rx*lw+a,oe[1]=ly*rw+ry*lw+b,oe[2]=lz*rw+rz*lw+c,oe[3]=lw*rw-d}static arcTanAngle(x,y){return 0==x?1==y?Math.PI/2:-Math.PI/2:x>0?Math.atan(y/x):x<0?y>0?Math.atan(y/x)+Math.PI:Math.atan(y/x)-Math.PI:0}static angleTo(from,location,angle){ConchVector3.subtract(location,from,ConchQuaternion.TEMPVector30),ConchVector3.normalize(ConchQuaternion.TEMPVector30,ConchQuaternion.TEMPVector30),angle.elements[0]=Math.asin(ConchQuaternion.TEMPVector30.y),angle.elements[1]=ConchQuaternion.arcTanAngle(-ConchQuaternion.TEMPVector30.z,-ConchQuaternion.TEMPVector30.x)}static createFromAxisAngle(axis,rad,out){var e=out.elements,f=axis.elements;rad*=.5;var s=Math.sin(rad);e[0]=s*f[0],e[1]=s*f[1],e[2]=s*f[2],e[3]=Math.cos(rad)}static createFromMatrix3x3(sou,out){var fRoot,e=out.elements,f=sou.elements,fTrace=f[0]+f[4]+f[8];if(fTrace>0)fRoot=Math.sqrt(fTrace+1),e[3]=.5*fRoot,fRoot=.5/fRoot,e[0]=(f[5]-f[7])*fRoot,e[1]=(f[6]-f[2])*fRoot,e[2]=(f[1]-f[3])*fRoot;else{var i=0;f[4]>f[0]&&(i=1),f[8]>f[3*i+i]&&(i=2);var j=(i+1)%3,k=(i+2)%3;fRoot=Math.sqrt(f[3*i+i]-f[3*j+j]-f[3*k+k]+1),e[i]=.5*fRoot,fRoot=.5/fRoot,e[3]=(f[3*j+k]-f[3*k+j])*fRoot,e[j]=(f[3*j+i]+f[3*i+j])*fRoot,e[k]=(f[3*k+i]+f[3*i+k])*fRoot}}static createFromMatrix4x4(mat,out){var sqrt,half,me=mat.elements,oe=out.elements,scale=me[0]+me[5]+me[10];scale>0?(sqrt=Math.sqrt(scale+1),oe[3]=.5*sqrt,sqrt=.5/sqrt,oe[0]=(me[6]-me[9])*sqrt,oe[1]=(me[8]-me[2])*sqrt,oe[2]=(me[1]-me[4])*sqrt):me[0]>=me[5]&&me[0]>=me[10]?(half=.5/(sqrt=Math.sqrt(1+me[0]-me[5]-me[10])),oe[0]=.5*sqrt,oe[1]=(me[1]+me[4])*half,oe[2]=(me[2]+me[8])*half,oe[3]=(me[6]-me[9])*half):me[5]>me[10]?(half=.5/(sqrt=Math.sqrt(1+me[5]-me[0]-me[10])),oe[0]=(me[4]+me[1])*half,oe[1]=.5*sqrt,oe[2]=(me[9]+me[6])*half,oe[3]=(me[8]-me[2])*half):(half=.5/(sqrt=Math.sqrt(1+me[10]-me[0]-me[5])),oe[0]=(me[8]+me[2])*half,oe[1]=(me[9]+me[6])*half,oe[2]=.5*sqrt,oe[3]=(me[1]-me[4])*half)}static slerp(left,right,t,out){var omega,cosom,sinom,scale0,scale1,a=left.elements,b=right.elements,oe=out.elements,ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3];return(cosom=ax*bx+ay*by+az*bz+aw*bw)<0&&(cosom=-cosom,bx=-bx,by=-by,bz=-bz,bw=-bw),1-cosom>1e-6?(omega=Math.acos(cosom),sinom=Math.sin(omega),scale0=Math.sin((1-t)*omega)/sinom,scale1=Math.sin(t*omega)/sinom):(scale0=1-t,scale1=t),oe[0]=scale0*ax+scale1*bx,oe[1]=scale0*ay+scale1*by,oe[2]=scale0*az+scale1*bz,oe[3]=scale0*aw+scale1*bw,oe}static lerp(left,right,amount,out){ConchQuaternion._lerpArray(left.elements,right.elements,amount,out.elements)}static add(left,right,out){var e=out.elements,f=left.elements,g=right.elements;e[0]=f[0]+g[0],e[1]=f[1]+g[1],e[2]=f[2]+g[2],e[3]=f[3]+g[3]}static dot(left,right){return ConchQuaternion._dotArray(left.elements,right.elements)}get x(){return this.elements[0]}set x(value){this.elements[0]=value}get y(){return this.elements[1]}set y(value){this.elements[1]=value}get z(){return this.elements[2]}set z(value){this.elements[2]=value}get w(){return this.elements[3]}set w(value){this.elements[3]=value}scaling(scaling,out){var e=out.elements,f=this.elements;e[0]=f[0]*scaling,e[1]=f[1]*scaling,e[2]=f[2]*scaling,e[3]=f[3]*scaling}normalize(out){ConchQuaternion._normalizeArray(this.elements,out.elements)}length(){var f=this.elements,x=f[0],y=f[1],z=f[2],w=f[3];return Math.sqrt(x*x+y*y+z*z+w*w)}rotateX(rad,out){var e=out.elements,f=this.elements;rad*=.5;var ax=f[0],ay=f[1],az=f[2],aw=f[3],bx=Math.sin(rad),bw=Math.cos(rad);e[0]=ax*bw+aw*bx,e[1]=ay*bw+az*bx,e[2]=az*bw-ay*bx,e[3]=aw*bw-ax*bx}rotateY(rad,out){var e=out.elements,f=this.elements;rad*=.5;var ax=f[0],ay=f[1],az=f[2],aw=f[3],by=Math.sin(rad),bw=Math.cos(rad);e[0]=ax*bw-az*by,e[1]=ay*bw+aw*by,e[2]=az*bw+ax*by,e[3]=aw*bw-ay*by}rotateZ(rad,out){var e=out.elements,f=this.elements;rad*=.5;var ax=f[0],ay=f[1],az=f[2],aw=f[3],bz=Math.sin(rad),bw=Math.cos(rad);e[0]=ax*bw+ay*bz,e[1]=ay*bw-ax*bz,e[2]=az*bw+aw*bz,e[3]=aw*bw-az*bz}getYawPitchRoll(out){ConchVector3.transformQuat(ConchVector3.ForwardRH,this,ConchQuaternion.TEMPVector31),ConchVector3.transformQuat(ConchVector3.Up,this,ConchQuaternion.TEMPVector32);var upe=ConchQuaternion.TEMPVector32.elements;ConchQuaternion.angleTo(ConchVector3.ZERO,ConchQuaternion.TEMPVector31,ConchQuaternion.TEMPVector33);var anglee=ConchQuaternion.TEMPVector33.elements;anglee[0]==Math.PI/2?(anglee[1]=ConchQuaternion.arcTanAngle(upe[2],upe[0]),anglee[2]=0):anglee[0]==-Math.PI/2?(anglee[1]=ConchQuaternion.arcTanAngle(-upe[2],-upe[0]),anglee[2]=0):(Matrix4x4.createRotationY(-anglee[1],ConchQuaternion.TEMPMatrix0),Matrix4x4.createRotationX(-anglee[0],ConchQuaternion.TEMPMatrix1),ConchVector3.transformCoordinate(ConchQuaternion.TEMPVector32,ConchQuaternion.TEMPMatrix0,ConchQuaternion.TEMPVector32),ConchVector3.transformCoordinate(ConchQuaternion.TEMPVector32,ConchQuaternion.TEMPMatrix1,ConchQuaternion.TEMPVector32),anglee[2]=ConchQuaternion.arcTanAngle(upe[1],-upe[0])),anglee[1]<=-Math.PI&&(anglee[1]=Math.PI),anglee[2]<=-Math.PI&&(anglee[2]=Math.PI),anglee[1]>=Math.PI&&anglee[2]>=Math.PI&&(anglee[1]=0,anglee[2]=0,anglee[0]=Math.PI-anglee[0]);var oe=out.elements;oe[0]=anglee[1],oe[1]=anglee[0],oe[2]=anglee[2]}invert(out){var e=out.elements,f=this.elements,a0=f[0],a1=f[1],a2=f[2],a3=f[3],dot=a0*a0+a1*a1+a2*a2+a3*a3,invDot=dot?1/dot:0;e[0]=-a0*invDot,e[1]=-a1*invDot,e[2]=-a2*invDot,e[3]=a3*invDot}identity(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1}fromArray(array,offset=0){this.elements[0]=array[offset+0],this.elements[1]=array[offset+1],this.elements[2]=array[offset+2],this.elements[3]=array[offset+3]}cloneTo(destObject){var i,s,d;if((s=this.elements)!==(d=destObject.elements))for(i=0;i<4;++i)d[i]=s[i]}clone(){var dest=new ConchQuaternion;return this.cloneTo(dest),dest}equals(b){var ae=this.elements,be=b.elements;return MathUtils3D.nearEqual(ae[0],be[0])&&MathUtils3D.nearEqual(ae[1],be[1])&&MathUtils3D.nearEqual(ae[2],be[2])&&MathUtils3D.nearEqual(ae[3],be[3])}static rotationLookAt(forward,up,out){ConchQuaternion.lookAt(ConchVector3.ZERO,forward,up,out)}static lookAt(eye,target,up,out){Matrix3x3.lookAt(eye,target,up,ConchQuaternion._tempMatrix3x3),ConchQuaternion.rotationMatrix(ConchQuaternion._tempMatrix3x3,out)}lengthSquared(){var x=this.elements[0],y=this.elements[1],z=this.elements[2],w=this.elements[3];return x*x+y*y+z*z+w*w}static invert(value,out){var vE=value.elements,oE=out.elements,lengthSq=value.lengthSquared();MathUtils3D.isZero(lengthSq)||(lengthSq=1/lengthSq,oE[0]=-vE[0]*lengthSq,oE[1]=-vE[1]*lengthSq,oE[2]=-vE[2]*lengthSq,oE[3]=vE[3]*lengthSq)}static rotationMatrix(matrix3x3,out){var sqrt,half,me=matrix3x3.elements,m11=me[0],m12=me[1],m13=me[2],m21=me[3],m22=me[4],m23=me[5],m31=me[6],m32=me[7],m33=me[8],oe=out.elements,scale=m11+m22+m33;scale>0?(sqrt=Math.sqrt(scale+1),oe[3]=.5*sqrt,sqrt=.5/sqrt,oe[0]=(m23-m32)*sqrt,oe[1]=(m31-m13)*sqrt,oe[2]=(m12-m21)*sqrt):m11>=m22&&m11>=m33?(half=.5/(sqrt=Math.sqrt(1+m11-m22-m33)),oe[0]=.5*sqrt,oe[1]=(m12+m21)*half,oe[2]=(m13+m31)*half,oe[3]=(m23-m32)*half):m22>m33?(half=.5/(sqrt=Math.sqrt(1+m22-m11-m33)),oe[0]=(m21+m12)*half,oe[1]=.5*sqrt,oe[2]=(m32+m23)*half,oe[3]=(m31-m13)*half):(half=.5/(sqrt=Math.sqrt(1+m33-m11-m22)),oe[0]=(m31+m13)*half,oe[1]=(m32+m23)*half,oe[2]=.5*sqrt,oe[3]=(m12-m21)*half)}}ConchQuaternion.TEMPVector30=new ConchVector3,ConchQuaternion.TEMPVector31=new ConchVector3,ConchQuaternion.TEMPVector32=new ConchVector3,ConchQuaternion.TEMPVector33=new ConchVector3,ConchQuaternion.TEMPMatrix0=new Matrix4x4,ConchQuaternion.TEMPMatrix1=new Matrix4x4,ConchQuaternion._tempMatrix3x3=new Matrix3x3,ConchQuaternion.DEFAULT=new ConchQuaternion,ConchQuaternion.NAN=new ConchQuaternion(NaN,NaN,NaN,NaN);class AnimationClipParser03{static READ_DATA(){AnimationClipParser03._DATA.offset=AnimationClipParser03._reader.getUint32(),AnimationClipParser03._DATA.size=AnimationClipParser03._reader.getUint32()}static READ_BLOCK(){for(var count=AnimationClipParser03._BLOCK.count=AnimationClipParser03._reader.getUint16(),blockStarts=AnimationClipParser03._BLOCK.blockStarts=[],blockLengths=AnimationClipParser03._BLOCK.blockLengths=[],i=0;i0&&(event.params=params=[]),j=0;j>-e-14,HalfFloatUtils._baseTable[256|i]=1024>>-e-14|32768,HalfFloatUtils._shiftTable[0|i]=-e-1,HalfFloatUtils._shiftTable[256|i]=-e-1):e<=15?(HalfFloatUtils._baseTable[0|i]=e+15<<10,HalfFloatUtils._baseTable[256|i]=e+15<<10|32768,HalfFloatUtils._shiftTable[0|i]=13,HalfFloatUtils._shiftTable[256|i]=13):e<128?(HalfFloatUtils._baseTable[0|i]=31744,HalfFloatUtils._baseTable[256|i]=64512,HalfFloatUtils._shiftTable[0|i]=24,HalfFloatUtils._shiftTable[256|i]=24):(HalfFloatUtils._baseTable[0|i]=31744,HalfFloatUtils._baseTable[256|i]=64512,HalfFloatUtils._shiftTable[0|i]=13,HalfFloatUtils._shiftTable[256|i]=13)}for(HalfFloatUtils._mantissaTable[0]=0,i=1;i<1024;++i){var m=i<<13;for(e=0;0==(8388608&m);)e-=8388608,m<<=1;m&=-8388609,e+=947912704,HalfFloatUtils._mantissaTable[i]=m|e}for(i=1024;i<2048;++i)HalfFloatUtils._mantissaTable[i]=939524096+(i-1024<<13);for(HalfFloatUtils._exponentTable[0]=0,i=1;i<31;++i)HalfFloatUtils._exponentTable[i]=i<<23;for(HalfFloatUtils._exponentTable[31]=1199570944,HalfFloatUtils._exponentTable[32]=2147483648,i=33;i<63;++i)HalfFloatUtils._exponentTable[i]=2147483648+(i-32<<23);for(HalfFloatUtils._exponentTable[63]=3347054592,HalfFloatUtils._offsetTable[0]=0,i=1;i<64;++i)HalfFloatUtils._offsetTable[i]=32===i?0:1024}static roundToFloat16Bits(num){HalfFloatUtils._floatView[0]=num;var f=HalfFloatUtils._uint32View[0],e=f>>23&511;return HalfFloatUtils._baseTable[e]+((8388607&f)>>HalfFloatUtils._shiftTable[e])}static convertToNumber(float16bits){var m=float16bits>>10;return HalfFloatUtils._uint32View[0]=HalfFloatUtils._mantissaTable[HalfFloatUtils._offsetTable[m]+(1023&float16bits)]+HalfFloatUtils._exponentTable[m],HalfFloatUtils._floatView[0]}}HalfFloatUtils._buffer=new ArrayBuffer(4),HalfFloatUtils._floatView=new Float32Array(HalfFloatUtils._buffer),HalfFloatUtils._uint32View=new Uint32Array(HalfFloatUtils._buffer),HalfFloatUtils._baseTable=new Uint32Array(512),HalfFloatUtils._shiftTable=new Uint32Array(512),HalfFloatUtils._mantissaTable=new Uint32Array(2048),HalfFloatUtils._exponentTable=new Uint32Array(64),HalfFloatUtils._offsetTable=new Uint32Array(64);class AnimationClipParser04{static READ_DATA(){AnimationClipParser04._DATA.offset=AnimationClipParser04._reader.getUint32(),AnimationClipParser04._DATA.size=AnimationClipParser04._reader.getUint32()}static READ_BLOCK(){for(var count=AnimationClipParser04._BLOCK.count=AnimationClipParser04._reader.getUint16(),blockStarts=AnimationClipParser04._BLOCK.blockStarts=[],blockLengths=AnimationClipParser04._BLOCK.blockLengths=[],i=0;i0&&(event.params=params=[]),j=0;jplayCurTime);)frameIndex++,nextFrameIndex++,realTimeCurrentFrameIndexes[i]=frameIndex;else for((nextFrameIndex=frameIndex+1)!==keyFramesCount&&playCurTime>keyFrames[nextFrameIndex].time&&(frameIndex=keyFramesCount-1,realTimeCurrentFrameIndexes[i]=frameIndex),nextFrameIndex=frameIndex+1;frameIndex>-1&&!(keyFrames[frameIndex].timetime?end=mid-1:start=mid+1}return start}addEvent(event){var index=this._binarySearchEventIndex(event.time);this._animationEvents.splice(index,0,event)}_disposeResource(){this._nodes=null,this._nodesMap=null}}AnimationClip.ANIMATIONCLIP="ANIMATIONCLIP",AnimationClip._tempQuaternion0=new Quaternion;class AnimationTransform3D extends Laya.EventDispatcher{constructor(owner,localPosition=null,localRotation=null,localScale=null,worldMatrix=null){super(),this._owner=owner,this._children=[],this._localMatrix=new Float32Array(16),Laya.Render.supportWebGLPlusAnimation?(this._localPosition=new ConchVector3(0,0,0,localPosition),this._localRotation=new ConchQuaternion(0,0,0,1,localRotation),this._localScale=new ConchVector3(0,0,0,localScale),this._worldMatrix=worldMatrix):(this._localPosition=new Vector3,this._localRotation=new Quaternion,this._localScale=new Vector3,this._worldMatrix=new Float32Array(16)),this._localQuaternionUpdate=!1,this._locaEulerlUpdate=!1,this._localUpdate=!1,this._worldUpdate=!0}_getlocalMatrix(){return this._localUpdate&&(Utils3D._createAffineTransformationArray(this._localPosition,this._localRotation,this._localScale,this._localMatrix),this._localUpdate=!1),this._localMatrix}_onWorldTransform(){if(!this._worldUpdate){this._worldUpdate=!0,this.event(Laya.Event.TRANSFORM_CHANGED);for(var i=0,n=this._children.length;i>i,1),Math.max(size>>i,1));this._setGPUMemory(size*size*4*(1+1/3)*6)}else this._mipmapCount=1,this._setGPUMemory(size*size*4*6)}static __init__(){var pixels=new Uint8Array(3);pixels[0]=128,pixels[1]=128,pixels[2]=128,TextureCube.grayTexture=new TextureCube(1,Laya.BaseTexture.FORMAT_R8G8B8,!1),TextureCube.grayTexture.setSixSidePixels([pixels,pixels,pixels,pixels,pixels,pixels]),TextureCube.grayTexture.lock=!0}static _parse(data,propertyParams=null,constructParams=null){var texture=constructParams?new TextureCube(0,constructParams[0],constructParams[1]):new TextureCube(0);return texture.setSixSideImageSources(data),texture}static load(url,complete){Laya.ILaya.loader.create(url,complete,null,TextureCube.TEXTURECUBE)}get defaulteTexture(){return TextureCube.grayTexture}_setPixels(pixels,miplevel,width,height){var gl=Laya.LayaGL.instance,glFormat=this._getGLFormat();Laya.WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture),this.format===Laya.BaseTexture.FORMAT_R8G8B8?(gl.pixelStorei(gl.UNPACK_ALIGNMENT,1),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[0]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[1]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[2]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[3]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[4]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[5]),gl.pixelStorei(gl.UNPACK_ALIGNMENT,4)):(gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[0]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[1]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[2]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[3]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[4]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,miplevel,glFormat,width,height,0,glFormat,gl.UNSIGNED_BYTE,pixels[5]))}setSixSideImageSources(source,premultiplyAlpha=!1){for(var width,height,i=0;i<6;i++){var img=source[i];if(!img)return void console.log("TextureCube: image Source can't be null.");var nextWidth=img.width,nextHeight=img.height;if(i>0&&width!==nextWidth)return void console.log("TextureCube: each side image's width and height must same.");if((width=nextWidth)!==(height=nextHeight))return void console.log("TextureCube: each side image's width and height must same.")}this._width=width,this._height=height;var gl=Laya.LayaGL.instance;Laya.WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);var glFormat=this._getGLFormat();if(Laya.Render.isConchApp){if(1==premultiplyAlpha)for(var j=0;j<6;j++)source[j].setPremultiplyAlpha(premultiplyAlpha);gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,source[0]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,source[1]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,source[2]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,source[3]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,source[4]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,source[5])}else premultiplyAlpha&&gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z,0,glFormat,glFormat,gl.UNSIGNED_BYTE,source[0]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,glFormat,glFormat,gl.UNSIGNED_BYTE,source[1]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X,0,glFormat,glFormat,gl.UNSIGNED_BYTE,source[2]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X,0,glFormat,glFormat,gl.UNSIGNED_BYTE,source[3]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y,0,glFormat,glFormat,gl.UNSIGNED_BYTE,source[4]),gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,glFormat,glFormat,gl.UNSIGNED_BYTE,source[5]),premultiplyAlpha&&gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);this._mipmap&&this._isPot(width)&&this._isPot(height)?(gl.generateMipmap(this._glTextureType),this._setGPUMemory(width*height*4*(1+1/3)*6)):this._setGPUMemory(width*height*4*6),this._setWarpMode(gl.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(gl.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),this._readyed=!0,this._activeResource()}setSixSidePixels(pixels,miplevel=0){if(!pixels)throw new Error("TextureCube:pixels can't be null.");var width=Math.max(this._width>>miplevel,1),height=Math.max(this._height>>miplevel,1),pixelsCount=width*height*this._getFormatByteCount();if(pixels[0].length0&&(flags^=PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT),flags|=PhysicsComponent.COLLISIONFLAGS_STATIC_OBJECT):((flags&PhysicsComponent.COLLISIONFLAGS_STATIC_OBJECT)>0&&(flags^=PhysicsComponent.COLLISIONFLAGS_STATIC_OBJECT),flags|=PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT),btColObj.setCollisionFlags(flags),this._nativeColliderObject=btColObj,super._onAdded()}}class CharacterController extends PhysicsComponent{constructor(stepheight=.1,upAxis=null,collisionGroup=Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER,canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER){super(collisionGroup,canCollideWith),this._upAxis=new Vector3(0,1,0),this._maxSlope=45,this._jumpSpeed=10,this._fallSpeed=55,this._gravity=new Vector3(0,3*-9.8,0),this._nativeKinematicCharacter=null,this._stepHeight=stepheight,upAxis&&(this._upAxis=upAxis)}static __init__(){CharacterController._nativeTempVector30=new Physics3D._physics3D.btVector3(0,0,0)}get fallSpeed(){return this._fallSpeed}set fallSpeed(value){this._fallSpeed=value,this._nativeKinematicCharacter.setFallSpeed(value)}get jumpSpeed(){return this._jumpSpeed}set jumpSpeed(value){this._jumpSpeed=value,this._nativeKinematicCharacter.setJumpSpeed(value)}get gravity(){return this._gravity}set gravity(value){this._gravity=value;var nativeGravity=CharacterController._nativeTempVector30;nativeGravity.setValue(-value.x,value.y,value.z),this._nativeKinematicCharacter.setGravity(nativeGravity)}get maxSlope(){return this._maxSlope}set maxSlope(value){this._maxSlope=value,this._nativeKinematicCharacter.setMaxSlope(value/180*Math.PI)}get isGrounded(){return this._nativeKinematicCharacter.onGround()}get stepHeight(){return this._stepHeight}set stepHeight(value){this._stepHeight=value,this._constructCharacter()}get upAxis(){return this._upAxis}set upAxis(value){this._upAxis=value,this._constructCharacter()}_constructCharacter(){var physics3D=Physics3D._physics3D;this._nativeKinematicCharacter&&physics3D.destroy(this._nativeKinematicCharacter);var nativeUpAxis=CharacterController._nativeTempVector30;nativeUpAxis.setValue(this._upAxis.x,this._upAxis.y,this._upAxis.z),this._nativeKinematicCharacter=new physics3D.btKinematicCharacterController(this._nativeColliderObject,this._colliderShape._nativeShape,this._stepHeight,nativeUpAxis),this.fallSpeed=this._fallSpeed,this.maxSlope=this._maxSlope,this.jumpSpeed=this._jumpSpeed,this.gravity=this._gravity}_onShapeChange(colShape){super._onShapeChange(colShape),this._constructCharacter()}_onAdded(){var ghostObject=new Physics3D._physics3D.btPairCachingGhostObject;ghostObject.setUserIndex(this.id),ghostObject.setCollisionFlags(PhysicsComponent.COLLISIONFLAGS_CHARACTER_OBJECT),this._nativeColliderObject=ghostObject,this._colliderShape&&this._constructCharacter(),super._onAdded()}_addToSimulation(){this._simulation._characters.push(this),this._simulation._addCharacter(this,this._collisionGroup,this._canCollideWith)}_removeFromSimulation(){this._simulation._removeCharacter(this);var characters=this._simulation._characters;characters.splice(characters.indexOf(this),1)}_cloneTo(dest){super._cloneTo(dest);var destCharacterController=dest;destCharacterController.stepHeight=this._stepHeight,destCharacterController.upAxis=this._upAxis,destCharacterController.maxSlope=this._maxSlope,destCharacterController.jumpSpeed=this._jumpSpeed,destCharacterController.fallSpeed=this._fallSpeed,destCharacterController.gravity=this._gravity}_onDestroy(){Physics3D._physics3D.destroy(this._nativeKinematicCharacter),super._onDestroy(),this._nativeKinematicCharacter=null}move(movement){var nativeMovement=CharacterController._nativeVector30;nativeMovement.setValue(-movement.x,movement.y,movement.z),this._nativeKinematicCharacter.setWalkDirection(nativeMovement)}jump(velocity=null){if(velocity){var nativeVelocity=CharacterController._nativeVector30;Utils3D._convertToBulletVec3(velocity,nativeVelocity,!0),this._nativeKinematicCharacter.jump(nativeVelocity)}else this._nativeKinematicCharacter.jump()}}CharacterController.UPAXIS_X=0,CharacterController.UPAXIS_Y=1,CharacterController.UPAXIS_Z=2;class Rigidbody3D extends PhysicsTriggerComponent{constructor(collisionGroup=Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER,canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER){super(collisionGroup,canCollideWith),this._isKinematic=!1,this._mass=1,this._gravity=new Vector3(0,-10,0),this._angularDamping=0,this._linearDamping=0,this._overrideGravity=!1,this._totalTorque=new Vector3(0,0,0),this._totalForce=new Vector3(0,0,0),this._linearVelocity=new Vector3,this._angularVelocity=new Vector3,this._linearFactor=new Vector3(1,1,1),this._angularFactor=new Vector3(1,1,1),this._detectCollisions=!0}static __init__(){Rigidbody3D._nativeTempVector30=new Physics3D._physics3D.btVector3(0,0,0),Rigidbody3D._nativeTempVector31=new Physics3D._physics3D.btVector3(0,0,0),Rigidbody3D._nativeVector3Zero=new Physics3D._physics3D.btVector3(0,0,0),Rigidbody3D._nativeInertia=new Physics3D._physics3D.btVector3(0,0,0),Rigidbody3D._nativeImpulse=new Physics3D._physics3D.btVector3(0,0,0),Rigidbody3D._nativeImpulseOffset=new Physics3D._physics3D.btVector3(0,0,0),Rigidbody3D._nativeGravity=new Physics3D._physics3D.btVector3(0,0,0)}get mass(){return this._mass}set mass(value){value=Math.max(value,1e-7),this._mass=value,this._isKinematic||this._updateMass(value)}get isKinematic(){return this._isKinematic}set isKinematic(value){this._isKinematic=value;var canInSimulation=!!(this._simulation&&this._enabled&&this._colliderShape);canInSimulation&&this._removeFromSimulation();var natColObj=this._nativeColliderObject,flags=natColObj.getCollisionFlags();value?(flags|=PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT,natColObj.setCollisionFlags(flags),this._nativeColliderObject.forceActivationState(PhysicsComponent.ACTIVATIONSTATE_DISABLE_DEACTIVATION),this._enableProcessCollisions=!1,this._updateMass(0)):((flags&PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(flags^=PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT),natColObj.setCollisionFlags(flags),this._nativeColliderObject.setActivationState(PhysicsComponent.ACTIVATIONSTATE_ACTIVE_TAG),this._enableProcessCollisions=!0,this._updateMass(this._mass));var nativeZero=Rigidbody3D._nativeVector3Zero;natColObj.setInterpolationLinearVelocity(nativeZero),natColObj.setLinearVelocity(nativeZero),natColObj.setInterpolationAngularVelocity(nativeZero),natColObj.setAngularVelocity(nativeZero),canInSimulation&&this._addToSimulation()}get linearDamping(){return this._linearDamping}set linearDamping(value){this._linearDamping=value,this._nativeColliderObject&&this._nativeColliderObject.setDamping(value,this._angularDamping)}get angularDamping(){return this._angularDamping}set angularDamping(value){this._angularDamping=value,this._nativeColliderObject&&this._nativeColliderObject.setDamping(this._linearDamping,value)}get overrideGravity(){return this._overrideGravity}set overrideGravity(value){if(this._overrideGravity=value,this._nativeColliderObject){var flag=this._nativeColliderObject.getFlags();value?0==(flag&Rigidbody3D._BT_DISABLE_WORLD_GRAVITY)&&this._nativeColliderObject.setFlags(flag|Rigidbody3D._BT_DISABLE_WORLD_GRAVITY):(flag&Rigidbody3D._BT_DISABLE_WORLD_GRAVITY)>0&&this._nativeColliderObject.setFlags(flag^Rigidbody3D._BT_DISABLE_WORLD_GRAVITY)}}get gravity(){return this._gravity}set gravity(value){this._gravity=value,Rigidbody3D._nativeGravity.setValue(-value.x,value.y,value.z),this._nativeColliderObject.setGravity(Rigidbody3D._nativeGravity)}get totalForce(){if(this._nativeColliderObject){var nativeTotalForce=this._nativeColliderObject.getTotalForce();return Utils3D._convertToLayaVec3(nativeTotalForce,this._totalForce,!0),this._totalForce}return null}get linearFactor(){return this._nativeColliderObject?this._linearFactor:null}set linearFactor(value){if(this._linearFactor=value,this._nativeColliderObject){var nativeValue=Rigidbody3D._nativeTempVector30;Utils3D._convertToBulletVec3(value,nativeValue,!1),this._nativeColliderObject.setLinearFactor(nativeValue)}}get linearVelocity(){return this._nativeColliderObject&&Utils3D._convertToLayaVec3(this._nativeColliderObject.getLinearVelocity(),this._linearVelocity,!0),this._linearVelocity}set linearVelocity(value){if(this._linearVelocity=value,this._nativeColliderObject){var nativeValue=Rigidbody3D._nativeTempVector30;Utils3D._convertToBulletVec3(value,nativeValue,!0),this.isSleeping&&this.wakeUp(),this._nativeColliderObject.setLinearVelocity(nativeValue)}}get angularFactor(){return this._nativeColliderObject?this._angularFactor:null}set angularFactor(value){if(this._angularFactor=value,this._nativeColliderObject){var nativeValue=Rigidbody3D._nativeTempVector30;Utils3D._convertToBulletVec3(value,nativeValue,!1),this._nativeColliderObject.setAngularFactor(nativeValue)}}get angularVelocity(){return this._nativeColliderObject&&Utils3D._convertToLayaVec3(this._nativeColliderObject.getAngularVelocity(),this._angularVelocity,!0),this._angularVelocity}set angularVelocity(value){if(this._angularVelocity=value,this._nativeColliderObject){var nativeValue=Rigidbody3D._nativeTempVector30;Utils3D._convertToBulletVec3(value,nativeValue,!0),this.isSleeping&&this.wakeUp(),this._nativeColliderObject.setAngularVelocity(nativeValue)}}get totalTorque(){if(this._nativeColliderObject){var nativeTotalTorque=this._nativeColliderObject.getTotalTorque();return Utils3D._convertToLayaVec3(nativeTotalTorque,this._totalTorque,!0),this._totalTorque}return null}get detectCollisions(){return this._detectCollisions}set detectCollisions(value){this._detectCollisions!==value&&(this._detectCollisions=value,this._colliderShape&&this._enabled&&this._simulation&&(this._simulation._removeRigidBody(this),this._simulation._addRigidBody(this,this._collisionGroup,value?this._canCollideWith:0)))}get isSleeping(){return!!this._nativeColliderObject&&this._nativeColliderObject.getActivationState()===PhysicsComponent.ACTIVATIONSTATE_ISLAND_SLEEPING}get sleepLinearVelocity(){return this._nativeColliderObject.getLinearSleepingThreshold()}set sleepLinearVelocity(value){this._nativeColliderObject.setSleepingThresholds(value,this._nativeColliderObject.getAngularSleepingThreshold())}get sleepAngularVelocity(){return this._nativeColliderObject.getAngularSleepingThreshold()}set sleepAngularVelocity(value){this._nativeColliderObject.setSleepingThresholds(this._nativeColliderObject.getLinearSleepingThreshold(),value)}_updateMass(mass){this._nativeColliderObject&&this._colliderShape&&(this._colliderShape._nativeShape.calculateLocalInertia(mass,Rigidbody3D._nativeInertia),this._nativeColliderObject.setMassProps(mass,Rigidbody3D._nativeInertia),this._nativeColliderObject.updateInertiaTensor())}_delegateMotionStateGetWorldTransform(worldTransPointer){}_delegateMotionStateSetWorldTransform(worldTransPointer){var rigidBody=this._rigidbody;rigidBody._simulation._updatedRigidbodies++;var physics3D=Physics3D._physics3D,worldTrans=physics3D.wrapPointer(worldTransPointer,physics3D.btTransform);rigidBody._updateTransformComponent(worldTrans)}_delegateMotionStateGetWorldTransformNative(ridgidBody3D,worldTransPointer){}_delegateMotionStateSetWorldTransformNative(rigidBody3D,worldTransPointer){var rigidBody=rigidBody3D;rigidBody._simulation._updatedRigidbodies++;var physics3D=Physics3D._physics3D,worldTrans=physics3D.wrapPointer(worldTransPointer,physics3D.btTransform);rigidBody._updateTransformComponent(worldTrans)}_onScaleChange(scale){super._onScaleChange(scale),this._updateMass(this._isKinematic?0:this._mass)}_delegateMotionStateClear(){this._rigidbody=null}_onAdded(){var physics3D=Physics3D._physics3D,motionState=new physics3D.LayaMotionState;null!=window.conch&&physics3D.LayaMotionState.prototype.setRigidbody?(motionState.setRigidbody(this),motionState.setNativeGetWorldTransform(this._delegateMotionStateGetWorldTransformNative),motionState.setNativeSetWorldTransform(this._delegateMotionStateSetWorldTransformNative)):(motionState.getWorldTransform=this._delegateMotionStateGetWorldTransform,motionState.setWorldTransform=this._delegateMotionStateSetWorldTransform),motionState.clear=this._delegateMotionStateClear,motionState._rigidbody=this,this._nativeMotionState=motionState;var constructInfo=new physics3D.btRigidBodyConstructionInfo(0,motionState,null,Rigidbody3D._nativeVector3Zero),btRigid=new physics3D.btRigidBody(constructInfo);btRigid.setUserIndex(this.id),this._nativeColliderObject=btRigid,super._onAdded(),this.mass=this._mass,this.linearFactor=this._linearFactor,this.angularFactor=this._angularFactor,this.linearDamping=this._linearDamping,this.angularDamping=this._angularDamping,this.overrideGravity=this._overrideGravity,this.gravity=this._gravity,this.isKinematic=this._isKinematic,physics3D.destroy(constructInfo)}_onShapeChange(colShape){super._onShapeChange(colShape),this._isKinematic?this._updateMass(0):(this._nativeColliderObject.setCenterOfMassTransform(this._nativeColliderObject.getWorldTransform()),this._updateMass(this._mass))}_parse(data){null!=data.friction&&(this.friction=data.friction),null!=data.rollingFriction&&(this.rollingFriction=data.rollingFriction),null!=data.restitution&&(this.restitution=data.restitution),null!=data.isTrigger&&(this.isTrigger=data.isTrigger),null!=data.mass&&(this.mass=data.mass),null!=data.isKinematic&&(this.isKinematic=data.isKinematic),null!=data.linearDamping&&(this.linearDamping=data.linearDamping),null!=data.angularDamping&&(this.angularDamping=data.angularDamping),null!=data.overrideGravity&&(this.overrideGravity=data.overrideGravity),data.gravity&&(this.gravity.fromArray(data.gravity),this.gravity=this.gravity),super._parse(data),this._parseShape(data.shapes)}_onDestroy(){var physics3D=Physics3D._physics3D;this._nativeMotionState.clear(),physics3D.destroy(this._nativeMotionState),super._onDestroy(),this._nativeMotionState=null,this._gravity=null,this._totalTorque=null,this._linearVelocity=null,this._angularVelocity=null,this._linearFactor=null,this._angularFactor=null}_addToSimulation(){this._simulation._addRigidBody(this,this._collisionGroup,this._detectCollisions?this._canCollideWith:0)}_removeFromSimulation(){this._simulation._removeRigidBody(this)}_cloneTo(dest){super._cloneTo(dest);var destRigidbody3D=dest;destRigidbody3D.isKinematic=this._isKinematic,destRigidbody3D.mass=this._mass,destRigidbody3D.gravity=this._gravity,destRigidbody3D.angularDamping=this._angularDamping,destRigidbody3D.linearDamping=this._linearDamping,destRigidbody3D.overrideGravity=this._overrideGravity,destRigidbody3D.linearVelocity=this._linearVelocity,destRigidbody3D.angularVelocity=this._angularVelocity,destRigidbody3D.linearFactor=this._linearFactor,destRigidbody3D.angularFactor=this._angularFactor,destRigidbody3D.detectCollisions=this._detectCollisions}applyForce(force,localOffset=null){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 nativeForce=Rigidbody3D._nativeTempVector30;if(nativeForce.setValue(-force.x,force.y,force.z),localOffset){var nativeOffset=Rigidbody3D._nativeTempVector31;nativeOffset.setValue(-localOffset.x,localOffset.y,localOffset.z),this._nativeColliderObject.applyForce(nativeForce,nativeOffset)}else this._nativeColliderObject.applyCentralForce(nativeForce)}applyTorque(torque){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 nativeTorque=Rigidbody3D._nativeTempVector30;nativeTorque.setValue(-torque.x,torque.y,torque.z),this._nativeColliderObject.applyTorque(nativeTorque)}applyImpulse(impulse,localOffset=null){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(-impulse.x,impulse.y,impulse.z),localOffset?(Rigidbody3D._nativeImpulseOffset.setValue(-localOffset.x,localOffset.y,localOffset.z),this._nativeColliderObject.applyImpulse(Rigidbody3D._nativeImpulse,Rigidbody3D._nativeImpulseOffset)):this._nativeColliderObject.applyCentralImpulse(Rigidbody3D._nativeImpulse)}applyTorqueImpulse(torqueImpulse){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 nativeTorqueImpulse=Rigidbody3D._nativeTempVector30;nativeTorqueImpulse.setValue(-torqueImpulse.x,torqueImpulse.y,torqueImpulse.z),this._nativeColliderObject.applyTorqueImpulse(nativeTorqueImpulse)}wakeUp(){this._nativeColliderObject&&this._nativeColliderObject.activate(!1)}clearForces(){var rigidBody=this._nativeColliderObject;if(null==rigidBody)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";rigidBody.clearForces();var nativeZero=Rigidbody3D._nativeVector3Zero;rigidBody.setInterpolationLinearVelocity(nativeZero),rigidBody.setLinearVelocity(nativeZero),rigidBody.setInterpolationAngularVelocity(nativeZero),rigidBody.setAngularVelocity(nativeZero)}}Rigidbody3D.TYPE_STATIC=0,Rigidbody3D.TYPE_DYNAMIC=1,Rigidbody3D.TYPE_KINEMATIC=2,Rigidbody3D._BT_DISABLE_WORLD_GRAVITY=1,Rigidbody3D._BT_ENABLE_GYROPSCOPIC_FORCE=2;class StaticPlaneColliderShape extends ColliderShape{static __init__(){StaticPlaneColliderShape._nativeNormal=new Physics3D._physics3D.btVector3(0,0,0)}constructor(normal,offset){super(),this._normal=normal,this._offset=offset,this._type=ColliderShape.SHAPETYPES_STATICPLANE,StaticPlaneColliderShape._nativeNormal.setValue(-normal.x,normal.y,normal.z),this._nativeShape=new Physics3D._physics3D.btStaticPlaneShape(StaticPlaneColliderShape._nativeNormal,offset)}clone(){var dest=new StaticPlaneColliderShape(this._normal,this._offset);return this.cloneTo(dest),dest}}class PrimitiveMesh{static __init__(){}static _createMesh(vertexDeclaration,vertices,indices){var gl=Laya.LayaGL.instance,mesh=new Mesh,subMesh=new SubMesh(mesh),vertexBuffer=new VertexBuffer3D(4*vertices.length,gl.STATIC_DRAW,!0);vertexBuffer.vertexDeclaration=vertexDeclaration,vertexBuffer.setData(vertices.buffer),mesh._vertexBuffer=vertexBuffer,mesh._vertexCount+=vertexBuffer.vertexCount;var indexBuffer=new IndexBuffer3D(IndexBuffer3D.INDEXTYPE_USHORT,indices.length,gl.STATIC_DRAW,!0);indexBuffer.setData(indices),mesh._indexBuffer=indexBuffer;mesh._setBuffer(vertexBuffer,indexBuffer),subMesh._vertexBuffer=vertexBuffer,subMesh._indexBuffer=indexBuffer,subMesh._setIndexRange(0,indexBuffer.indexCount);var subIndexBufferStart=subMesh._subIndexBufferStart,subIndexBufferCount=subMesh._subIndexBufferCount,boneIndicesList=subMesh._boneIndicesList;subIndexBufferStart.length=1,subIndexBufferCount.length=1,boneIndicesList.length=1,subIndexBufferStart[0]=0,subIndexBufferCount[0]=indexBuffer.indexCount;var subMeshes=[];subMeshes.push(subMesh),mesh._setSubMeshes(subMeshes);var memorySize=vertexBuffer._byteLength+indexBuffer._byteLength;return mesh._setCPUMemory(memorySize),mesh._setGPUMemory(memorySize),mesh}static createBox(long=1,height=1,width=1){var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),halfLong=long/2,halfHeight=height/2,halfWidth=width/2,vertices=new Float32Array([-halfLong,halfHeight,-halfWidth,0,1,0,0,0,halfLong,halfHeight,-halfWidth,0,1,0,1,0,halfLong,halfHeight,halfWidth,0,1,0,1,1,-halfLong,halfHeight,halfWidth,0,1,0,0,1,-halfLong,-halfHeight,-halfWidth,0,-1,0,0,1,halfLong,-halfHeight,-halfWidth,0,-1,0,1,1,halfLong,-halfHeight,halfWidth,0,-1,0,1,0,-halfLong,-halfHeight,halfWidth,0,-1,0,0,0,-halfLong,halfHeight,-halfWidth,-1,0,0,0,0,-halfLong,halfHeight,halfWidth,-1,0,0,1,0,-halfLong,-halfHeight,halfWidth,-1,0,0,1,1,-halfLong,-halfHeight,-halfWidth,-1,0,0,0,1,halfLong,halfHeight,-halfWidth,1,0,0,1,0,halfLong,halfHeight,halfWidth,1,0,0,0,0,halfLong,-halfHeight,halfWidth,1,0,0,0,1,halfLong,-halfHeight,-halfWidth,1,0,0,1,1,-halfLong,halfHeight,halfWidth,0,0,1,0,0,halfLong,halfHeight,halfWidth,0,0,1,1,0,halfLong,-halfHeight,halfWidth,0,0,1,1,1,-halfLong,-halfHeight,halfWidth,0,0,1,0,1,-halfLong,halfHeight,-halfWidth,0,0,-1,1,0,halfLong,halfHeight,-halfWidth,0,0,-1,0,0,halfLong,-halfHeight,-halfWidth,0,0,-1,0,1,-halfLong,-halfHeight,-halfWidth,0,0,-1,1,1]),indices=new Uint16Array([0,1,2,2,3,0,4,7,6,6,5,4,8,9,10,10,11,8,12,15,14,14,13,12,16,17,18,18,19,16,20,23,22,22,21,20]);return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices)}static createCapsule(radius=.5,height=2,stacks=16,slices=32){var stack,slice,vertexCount=(stacks+1)*(slices+1)*2+2*(slices+1),indexCount=3*stacks*(slices+1)*2*2+2*slices*3,vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),vertexFloatStride=vertexDeclaration.vertexStride/4,vertices=new Float32Array(vertexCount*vertexFloatStride),indices=new Uint16Array(indexCount),stackAngle=Math.PI/2/stacks,sliceAngle=2*Math.PI/slices,hcHeight=height/2-radius,posX=0,posY=0,posZ=0,vc=0,ic=0,verticeCount=0;for(stack=0;stack<=stacks;stack++)for(slice=0;slice<=slices;slice++)posX=radius*Math.cos(stack*stackAngle)*Math.cos(slice*sliceAngle+Math.PI),posY=radius*Math.sin(stack*stackAngle),posZ=radius*Math.cos(stack*stackAngle)*Math.sin(slice*sliceAngle+Math.PI),vertices[vc++]=posX,vertices[vc++]=posY+hcHeight,vertices[vc++]=posZ,vertices[vc++]=posX,vertices[vc++]=posY,vertices[vc++]=posZ,vertices[vc++]=1-slice/slices,vertices[vc++]=(1-stack/stacks)*(Math.PI*radius/2/(height+Math.PI*radius)),stack0&&".."!==parts[index]&&(parts.splice(index,2),i-=2)}path=parts.join("/")}return path}static _endLoad(loader,content=null,subResous=null){if(subResous)for(var i=0,n=subResous.length;i0){var processCeil=urlCount/totalProcessCount,processHandler=Laya.Handler.create(null,Laya3D._onProcessChange,[loader,weight,processCeil],!1);Laya3D._innerFourthLevelLoaderManager._create(forthLevUrls,!1,Laya.Handler.create(null,Laya3D._onHierarchyInnerForthLevResouLoaded,[loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,weight+processCeil*forthLevUrls.length,processCeil]),processHandler,null,null,null,1,!0)}else Laya3D._onHierarchyInnerForthLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,weight,processCeil)}static _onHierarchyInnerForthLevResouLoaded(loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,processOffset,processCeil){if(processHandler&&processHandler.recover(),thirdLevUrls.length>0){var process=Laya.Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],!1);Laya3D._innerThirdLevelLoaderManager._create(thirdLevUrls,!1,Laya.Handler.create(null,Laya3D._onHierarchyInnerThirdLevResouLoaded,[loader,process,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset+processCeil*secondLevUrls.length,processCeil]),processHandler,null,null,null,1,!0)}else Laya3D._onHierarchyInnerThirdLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset,processCeil)}static _onHierarchyInnerThirdLevResouLoaded(loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset,processCeil){if(processHandler&&processHandler.recover(),secondLevUrls.length>0){var process=Laya.Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],!1);Laya3D._innerSecondLevelLoaderManager._create(secondLevUrls,!1,Laya.Handler.create(null,Laya3D._onHierarchyInnerSecondLevResouLoaded,[loader,process,lhData,subUrls,firstLevUrls,processOffset+processCeil*secondLevUrls.length,processCeil]),processHandler,null,null,null,1,!0)}else Laya3D._onHierarchyInnerSecondLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,processOffset,processCeil)}static _onHierarchyInnerSecondLevResouLoaded(loader,processHandler,lhData,subUrls,firstLevUrls,processOffset,processCeil){if(processHandler&&processHandler.recover(),firstLevUrls.length>0){var process=Laya.Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],!1);Laya3D._innerFirstLevelLoaderManager._create(firstLevUrls,!1,Laya.Handler.create(null,Laya3D._onHierarchyInnerFirstLevResouLoaded,[loader,process,lhData,subUrls]),processHandler,null,null,null,1,!0)}else Laya3D._onHierarchyInnerFirstLevResouLoaded(loader,null,lhData,subUrls)}static _onHierarchyInnerFirstLevResouLoaded(loader,processHandler,lhData,subUrls){processHandler&&processHandler.recover(),loader._cache=loader._createCache;var item="Scene3D"===lhData.data.type?Scene3DUtils._parseScene(lhData,loader._propertyParams,loader._constructParams):Scene3DUtils._parse(lhData,loader._propertyParams,loader._constructParams);Laya3D._endLoad(loader,item,subUrls)}static _loadMesh(loader){loader.on(Laya.Event.LOADED,null,Laya3D._onMeshLmLoaded,[loader]),loader.load(loader.url,Laya.Loader.BUFFER,!1,null,!0)}static _onMeshLmLoaded(loader,lmData){loader._cache=loader._createCache;var mesh=Mesh._parse(lmData,loader._propertyParams,loader._constructParams);Laya3D._endLoad(loader,mesh)}static _loadMaterial(loader){loader.on(Laya.Event.LOADED,null,Laya3D._onMaterilLmatLoaded,[loader]),loader.load(loader.url,Laya.Loader.JSON,!1,null,!0)}static _onMaterilLmatLoaded(loader,lmatData){var formatSubUrl,url=loader.url,urlVersion=Utils3D.getURLVerion(url),materialBasePath=Laya.URL.getPath(url),urls=[],subUrls=[];lmatData.customProps;switch(lmatData.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":var i,n,textures=lmatData.props.textures;if(textures)for(i=0,n=textures.length;i0){var processHandler=Laya.Handler.create(null,Laya3D._onProcessChange,[loader,lmatWeight,urlCount/totalProcessCount],!1);Laya3D._innerFourthLevelLoaderManager._create(urls,!1,Laya.Handler.create(null,Laya3D._onMateialTexturesLoaded,[loader,processHandler,lmatData,subUrls]),processHandler,null,null,null,1,!0)}else Laya3D._onMateialTexturesLoaded(loader,null,lmatData,null)}static _onMateialTexturesLoaded(loader,processHandler,lmatData,subUrls){loader._cache=loader._createCache;var mat=BaseMaterial._parse(lmatData,loader._propertyParams,loader._constructParams);Laya3D._endLoad(loader,mat,subUrls),processHandler&&processHandler.recover()}static _loadAvatar(loader){loader.on(Laya.Event.LOADED,null,function(data){loader._cache=loader._createCache;var avatar=Avatar._parse(data,loader._propertyParams,loader._constructParams);Laya3D._endLoad(loader,avatar)}),loader.load(loader.url,Laya.Loader.JSON,!1,null,!0)}static _loadAnimationClip(loader){loader.on(Laya.Event.LOADED,null,function(data){loader._cache=loader._createCache;var clip=AnimationClip._parse(data,loader._propertyParams,loader._constructParams);Laya3D._endLoad(loader,clip)}),loader.load(loader.url,Laya.Loader.BUFFER,!1,null,!0)}static _loadTexture2D(loader){var type,url=loader.url,index=url.lastIndexOf(".")+1,verIndex=url.indexOf("?"),endIndex=-1==verIndex?url.length:verIndex;switch(url.substr(index,endIndex-index)){case"jpg":case"jpeg":case"bmp":case"gif":case"png":type="nativeimage";break;case"dds":case"ktx":case"pvr":type=Laya.Loader.BUFFER}loader.on(Laya.Event.LOADED,null,function(image){loader._cache=loader._createCache;var tex=Laya.Texture2D._parse(image,loader._propertyParams,loader._constructParams);Laya3D._endLoad(loader,tex)}),loader.load(loader.url,type,!1,null,!0)}static _loadTextureCube(loader){loader.on(Laya.Event.LOADED,null,Laya3D._onTextureCubeLtcLoaded,[loader]),loader.load(loader.url,Laya.Loader.JSON,!1,null,!0)}static _onTextureCubeLtcLoaded(loader,ltcData){var ltcBasePath=Laya.URL.getPath(loader.url),urls=[Laya3D.formatRelativePath(ltcBasePath,ltcData.front),Laya3D.formatRelativePath(ltcBasePath,ltcData.back),Laya3D.formatRelativePath(ltcBasePath,ltcData.left),Laya3D.formatRelativePath(ltcBasePath,ltcData.right),Laya3D.formatRelativePath(ltcBasePath,ltcData.up),Laya3D.formatRelativePath(ltcBasePath,ltcData.down)];Laya3D._onProcessChange(loader,0,1/7,1);var processHandler=Laya.Handler.create(null,Laya3D._onProcessChange,[loader,1/7,6/7],!1);Laya3D._innerFourthLevelLoaderManager.load(urls,Laya.Handler.create(null,Laya3D._onTextureCubeImagesLoaded,[loader,urls,processHandler]),processHandler,"nativeimage")}static _onTextureCubeImagesLoaded(loader,urls,processHandler){for(var images=new Array(6),i=0;i<6;i++)images[i]=Laya.Loader.getRes(urls[i]);loader._cache=loader._createCache;var tex=TextureCube._parse(images,loader._propertyParams,loader._constructParams);for(processHandler.recover(),i=0;i<6;i++)Laya.Loader.clearRes(urls[i]);Laya3D._endLoad(loader,tex)}static _onProcessChange(loader,offset,weight,process){(process=offset+process*weight)<1&&loader.event(Laya.Event.PROGRESS,process)}static init(width,height,config=null,compolete=null){if(!Laya3D._isInit){Laya3D._isInit=!0,(config=config||Config3D._default).cloneTo(Laya3D._config),FrustumCulling.debugFrustumCulling=config.debugFrustumCulling,Laya3D._editerEnvironment=Laya3D._config._editerEnvironment,Scene3D.octreeCulling=config.octreeCulling,Scene3D.octreeInitialSize=config.octreeInitialSize,Scene3D.octreeInitialCenter=config.octreeInitialCenter,Scene3D.octreeMinNodeSize=config.octreeMinNodeSize,Scene3D.octreeLooseness=config.octreeLooseness;var physics3D=window.Physics3D;null==physics3D?(Physics3D._enbalePhysics=!1,Laya3D.__init__(width,height,Laya3D._config),compolete&&compolete.run()):(Physics3D._enbalePhysics=!0,physics3D(1024*Laya3D._config.defaultPhysicsMemory*1024).then(function(){Laya3D.__init__(width,height,Laya3D._config),compolete&&compolete.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._innerFirstLevelLoaderManager=new Laya.LoaderManager,Laya3D._innerSecondLevelLoaderManager=new Laya.LoaderManager,Laya3D._innerThirdLevelLoaderManager=new Laya.LoaderManager,Laya3D._innerFourthLevelLoaderManager=new Laya.LoaderManager,Laya3D._isInit=!1,Laya3D._editerEnvironment=!1,Laya3D._config=new Config3D,Laya3D.physicsSettings=new PhysicsSettings,window.Laya3D=Laya3D;class Script3D extends Laya.Component{constructor(){super(...arguments),this._indexInPool=-1}get isSingleton(){return!1}_checkProcessTriggers(){var prototype=Script3D.prototype;return this.onTriggerEnter!==prototype.onTriggerEnter||(this.onTriggerStay!==prototype.onTriggerStay||this.onTriggerExit!==prototype.onTriggerExit)}_checkProcessCollisions(){var prototype=Script3D.prototype;return this.onCollisionEnter!==prototype.onCollisionEnter||(this.onCollisionStay!==prototype.onCollisionStay||this.onCollisionExit!==prototype.onCollisionExit)}_onAwake(){this.onAwake(),this.onStart!==Script3D.prototype.onStart&&Laya.Laya.startTimer.callLater(this,this.onStart)}_onEnable(){this.owner._scene._addScript(this);var proto=Script3D.prototype;this.onKeyDown!==proto.onKeyDown&&Laya.Laya.stage.on(Laya.Event.KEY_DOWN,this,this.onKeyDown),this.onKeyPress!==proto.onKeyPress&&Laya.Laya.stage.on(Laya.Event.KEY_PRESS,this,this.onKeyUp),this.onKeyUp!==proto.onKeyUp&&Laya.Laya.stage.on(Laya.Event.KEY_UP,this,this.onKeyUp)}_onDisable(){this.owner._scene._removeScript(this),this.owner.offAllCaller(this),Laya.Laya.stage.offAllCaller(this)}_isScript(){return!0}_onAdded(){var sprite=this.owner,scripts=sprite._scripts;scripts||(sprite._scripts=scripts=[]),scripts.push(this),sprite._needProcessCollisions||(sprite._needProcessCollisions=this._checkProcessCollisions()),sprite._needProcessTriggers||(sprite._needProcessTriggers=this._checkProcessTriggers())}_onDestroy(){var scripts=this.owner._scripts;scripts.splice(scripts.indexOf(this),1);var sprite=this.owner;sprite._needProcessTriggers=!1;for(var i=0,n=scripts.length;i=0&&row=0&&col0?ratio:0,tw=Math.floor(viewport.width/(2-rw)),th=Math.floor(viewport.height/(2-rh)),s=Math.max(tw,th);logs=Math.log2(s)+this._diffusion-10;var logsInt=Math.floor(logs),iterations=Math.min(Math.max(logsInt,1),BloomEffect.MAXPYRAMIDSIZE),sampleScale=.5+logs-logsInt;this._shaderData.setNumber(BloomEffect.SHADERVALUE_SAMPLESCALE,sampleScale);var lthresh=Color.gammaToLinearSpace(this.threshold),knee=lthresh*this._softKnee+1e-5;this._shaderThreshold.setValue(lthresh,lthresh-knee,2*knee,.25/knee),this._shaderData.setVector(BloomEffect.SHADERVALUE_THRESHOLD,this._shaderThreshold);var lclamp=Color.gammaToLinearSpace(this.clamp);this._shaderParams.setValue(lclamp,0,0,0),this._shaderData.setVector(BloomEffect.SHADERVALUE_PARAMS,this._shaderParams);for(var qualityOffset=this.fastMode?1:0,lastDownTexture=context.source,i=0;i=0;i--)upIndex=(downIndex=2*i)+1,mipDownTexture=this._pyramid[downIndex],mipUpTexture=this._pyramid[upIndex],cmd.setShaderDataTexture(this._shaderData,BloomEffect.SHADERVALUE_BLOOMTEX,mipDownTexture),cmd.blitScreenTriangle(lastUpTexture,mipUpTexture,this._shader,this._shaderData,BloomEffect.SUBSHADER_UPSAMPLETENT+qualityOffset),lastUpTexture=mipUpTexture;var linearColor=this._linearColor;this.color.toLinear(linearColor);var intensity=Math.pow(2,this._intensity/10)-1,shaderSettings=this._shaderSetting;this._shaderSetting.setValue(sampleScale,intensity,this._dirtIntensity,iterations);var dirtTexture=this.dirtTexture?this.dirtTexture:Laya.Texture2D.blackTexture,dirtRatio=dirtTexture.width/dirtTexture.height,screenRatio=viewport.width/viewport.height,dirtTileOffset=this._dirtTileOffset;dirtRatio>screenRatio?dirtTileOffset.setValue(screenRatio/dirtRatio,1,.5*(1-dirtTileOffset.x),0):dirtRatio>>0)+(s1L>>>0),resU=s0U+s1U+(sumL/2>>>31)>>>0,resL=sumL>>>0;this._state0U=s0U,this._state0L=s0L;var t1U=0,t1L=0;t1U=(s1U^=t1U=s1U<<23|(-512&s1L)>>>9)^s0U,t1L=(s1L^=t1L=s1L<<23)^s0L;t1U^=s1U>>>18,t1L^=s1L>>>18|(262143&s1U)<<14;return t1U^=s0U>>>5,t1L^=s0L>>>5|(31&s0U)<<27,this._state1U=t1U,this._state1L=t1L,[resU,resL]}random(){var t2=this.randomint(),t2U=t2[0],xU=1023<<20|t2U>>>12,xL=0|(t2[1]>>>12|(4095&t2U)<<20);return RandX._CONVERTION_BUFFER.setUint32(0,xU,!1),RandX._CONVERTION_BUFFER.setUint32(4,xL,!1),RandX._CONVERTION_BUFFER.getFloat64(0,!1)-1}}RandX._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8)),RandX.defaultRand=new RandX([0,Date.now()/65536,0,Date.now()%65536]);class Size{constructor(width,height){this._width=0,this._height=0,this._width=width,this._height=height}static get fullScreen(){return new Size(-1,-1)}get width(){return-1===this._width?RenderContext3D.clientWidth:this._width}get height(){return-1===this._height?RenderContext3D.clientHeight:this._height}}exports.AnimationClip=AnimationClip,exports.AnimationClipParser03=AnimationClipParser03,exports.AnimationClipParser04=AnimationClipParser04,exports.AnimationEvent=AnimationEvent,exports.AnimationNode=AnimationNode,exports.AnimationTransform3D=AnimationTransform3D,exports.Animator=Animator,exports.AnimatorControllerLayer=AnimatorControllerLayer,exports.AnimatorPlayState=AnimatorPlayState,exports.AnimatorState=AnimatorState,exports.AnimatorStateScript=class{constructor(){}onStateEnter(){}onStateUpdate(){}onStateExit(){}},exports.Avatar=Avatar,exports.BaseCamera=BaseCamera,exports.BaseMaterial=BaseMaterial,exports.BaseRender=BaseRender,exports.BaseShape=BaseShape,exports.BatchMark=BatchMark,exports.BlinnPhongMaterial=BlinnPhongMaterial,exports.BlitScreenQuadCMD=BlitScreenQuadCMD,exports.BloomEffect=BloomEffect,exports.BoundBox=BoundBox,exports.BoundFrustum=BoundFrustum,exports.BoundSphere=BoundSphere,exports.Bounds=Bounds,exports.BoundsOctree=BoundsOctree,exports.BoundsOctreeNode=BoundsOctreeNode,exports.BoxColliderShape=BoxColliderShape,exports.BoxShape=BoxShape,exports.BufferState=BufferState,exports.Burst=Burst,exports.Camera=Camera,exports.CapsuleColliderShape=CapsuleColliderShape,exports.CastShadowList=CastShadowList,exports.CharacterController=CharacterController,exports.CircleShape=CircleShape,exports.ColliderShape=ColliderShape,exports.Collision=Collision,exports.CollisionTool=CollisionTool,exports.CollisionUtils=CollisionUtils,exports.Color=Color,exports.ColorOverLifetime=ColorOverLifetime,exports.Command=Command,exports.CommandBuffer=CommandBuffer,exports.CompoundColliderShape=CompoundColliderShape,exports.ConchQuaternion=ConchQuaternion,exports.ConchVector3=ConchVector3,exports.ConchVector4=ConchVector4,exports.ConeColliderShape=ConeColliderShape,exports.ConeShape=ConeShape,exports.Config3D=Config3D,exports.Constraint3D=class{constructor(){}},exports.ConstraintComponent=class extends Laya.Component{constructor(){super(),this._feedbackEnabled=!1}get enabled(){return super.enabled}set enabled(value){this._nativeConstraint.IsEnabled=value,super.enabled=value}get breakingImpulseThreshold(){return this._breakingImpulseThreshold}set breakingImpulseThreshold(value){this._nativeConstraint.BreakingImpulseThreshold=value,this._breakingImpulseThreshold=value}get appliedImpulse(){return this._feedbackEnabled||(this._nativeConstraint.EnableFeedback(!0),this._feedbackEnabled=!0),this._nativeConstraint.AppliedImpulse}get connectedBody(){return this._connectedBody}set connectedBody(value){this._connectedBody=value}_onDestroy(){Physics3D._physics3D.destroy(this._nativeConstraint),this._nativeConstraint=null}},exports.ContactPoint=ContactPoint,exports.ContainmentType=ContainmentType,exports.CylinderColliderShape=CylinderColliderShape,exports.DefineDatas=DefineDatas,exports.DirectionLight=DirectionLight,exports.DynamicBatchManager=DynamicBatchManager,exports.EffectMaterial=EffectMaterial,exports.Emission=Emission,exports.ExtendTerrainMaterial=ExtendTerrainMaterial,exports.FloatKeyframe=FloatKeyframe,exports.FrameOverTime=FrameOverTime,exports.FrustumCulling=FrustumCulling,exports.GeometryElement=GeometryElement,exports.Gradient=Gradient,exports.GradientAngularVelocity=GradientAngularVelocity,exports.GradientColor=GradientColor,exports.GradientDataInt=GradientDataInt,exports.GradientDataNumber=GradientDataNumber,exports.GradientDataVector2=GradientDataVector2,exports.GradientMode=GradientMode,exports.GradientSize=GradientSize,exports.GradientVelocity=GradientVelocity,exports.HalfFloatUtils=HalfFloatUtils,exports.HeightMap=HeightMap,exports.HeightfieldColliderShape=class{constructor(){}},exports.HemisphereShape=HemisphereShape,exports.HitResult=HitResult,exports.ILaya3D=ILaya3D,exports.IndexBuffer3D=IndexBuffer3D,exports.Input3D=Input3D,exports.Keyframe=Keyframe,exports.KeyframeNode=KeyframeNode,exports.KeyframeNodeList=KeyframeNodeList,exports.KeyframeNodeOwner=KeyframeNodeOwner,exports.Laya3D=Laya3D,exports.LightSprite=LightSprite,exports.LoadModelV04=LoadModelV04,exports.LoadModelV05=LoadModelV05,exports.MathUtils3D=MathUtils3D,exports.Matrix3x3=Matrix3x3,exports.Matrix4x4=Matrix4x4,exports.Mesh=Mesh,exports.MeshColliderShape=MeshColliderShape,exports.MeshFilter=MeshFilter,exports.MeshReader=MeshReader,exports.MeshRenderDynamicBatchManager=MeshRenderDynamicBatchManager,exports.MeshRenderStaticBatchManager=MeshRenderStaticBatchManager,exports.MeshRenderer=MeshRenderer,exports.MeshSprite3D=MeshSprite3D,exports.MeshSprite3DShaderDeclaration=MeshSprite3DShaderDeclaration,exports.MeshTerrainSprite3D=MeshTerrainSprite3D,exports.MouseTouch=MouseTouch,exports.OctreeMotionList=OctreeMotionList,exports.PBRSpecularMaterial=PBRSpecularMaterial,exports.PBRStandardMaterial=PBRStandardMaterial,exports.ParallelSplitShadowMap=ParallelSplitShadowMap,exports.Physics3D=Physics3D,exports.Physics3DUtils=Physics3DUtils,exports.PhysicsCollider=PhysicsCollider,exports.PhysicsComponent=PhysicsComponent,exports.PhysicsSettings=PhysicsSettings,exports.PhysicsSimulation=PhysicsSimulation,exports.PhysicsTriggerComponent=PhysicsTriggerComponent,exports.PhysicsUpdateList=PhysicsUpdateList,exports.Picker=Picker,exports.PixelLineData=class{constructor(){this.startPosition=new Vector3,this.endPosition=new Vector3,this.startColor=new Color,this.endColor=new Color}cloneTo(destObject){this.startPosition.cloneTo(destObject.startPosition),this.endPosition.cloneTo(destObject.endPosition),this.startColor.cloneTo(destObject.startColor),this.endColor.cloneTo(destObject.endColor)}},exports.PixelLineFilter=PixelLineFilter,exports.PixelLineMaterial=PixelLineMaterial,exports.PixelLineRenderer=PixelLineRenderer,exports.PixelLineSprite3D=PixelLineSprite3D,exports.PixelLineVertex=PixelLineVertex,exports.Plane=Plane,exports.Point2PointConstraint=class{constructor(){this._pivotInA=new Vector3,this._pivotInB=new Vector3}get pivotInA(){return this._pivotInA}set pivotInA(value){this._pivotInA=value}get pivotInB(){return this._pivotInB}set pivotInB(value){this._pivotInB=value}get damping(){return this._damping}set damping(value){this._damping=value}get impulseClamp(){return this._impulseClamp}set impulseClamp(value){this._impulseClamp=value}get tau(){return this._tau}set tau(value){this._tau=value}},exports.PointLight=PointLight,exports.PostProcess=PostProcess,exports.PostProcessEffect=PostProcessEffect,exports.PostProcessRenderContext=PostProcessRenderContext,exports.PrimitiveMesh=PrimitiveMesh,exports.Quaternion=Quaternion,exports.QuaternionKeyframe=QuaternionKeyframe,exports.Rand=Rand,exports.RandX=RandX,exports.Ray=Ray,exports.RenderContext3D=RenderContext3D,exports.RenderElement=RenderElement,exports.RenderQueue=RenderQueue,exports.RenderState=RenderState,exports.RenderTexture=RenderTexture,exports.RenderableSprite3D=RenderableSprite3D,exports.Rigidbody3D=Rigidbody3D,exports.RotationOverLifetime=RotationOverLifetime,exports.Scene3D=Scene3D,exports.Scene3DShaderDeclaration=Scene3DShaderDeclaration,exports.Scene3DUtils=Scene3DUtils,exports.SceneManager=class{constructor(){}},exports.ScreenQuad=ScreenQuad,exports.ScreenTriangle=ScreenTriangle,exports.Script3D=Script3D,exports.SetRenderTargetCMD=SetRenderTargetCMD,exports.SetShaderDataTextureCMD=SetShaderDataTextureCMD,exports.Shader3D=Shader3D,exports.ShaderData=ShaderData,exports.ShaderDefines=ShaderDefines,exports.ShaderInit3D=ShaderInit3D,exports.ShaderInstance=ShaderInstance,exports.ShaderPass=ShaderPass,exports.ShaderVariable=ShaderVariable,exports.ShapeUtils=ShapeUtils,exports.ShuriKenParticle3D=ShuriKenParticle3D,exports.ShuriKenParticle3DShaderDeclaration=ShuriKenParticle3DShaderDeclaration,exports.ShurikenParticleData=ShurikenParticleData,exports.ShurikenParticleMaterial=ShurikenParticleMaterial,exports.ShurikenParticleRenderer=ShurikenParticleRenderer,exports.ShurikenParticleSystem=ShurikenParticleSystem,exports.SimpleSingletonList=SimpleSingletonList,exports.SingletonList=SingletonList,exports.Size=Size,exports.SizeOverLifetime=SizeOverLifetime,exports.SkinnedMeshRenderer=SkinnedMeshRenderer,exports.SkinnedMeshSprite3D=SkinnedMeshSprite3D,exports.SkinnedMeshSprite3DShaderDeclaration=SkinnedMeshSprite3DShaderDeclaration,exports.SkyBox=SkyBox,exports.SkyBoxMaterial=SkyBoxMaterial,exports.SkyDome=SkyDome,exports.SkyMesh=SkyMesh,exports.SkyProceduralMaterial=SkyProceduralMaterial,exports.SkyRenderer=SkyRenderer,exports.SphereColliderShape=SphereColliderShape,exports.SphereShape=SphereShape,exports.SpotLight=SpotLight,exports.Sprite3D=Sprite3D,exports.StartFrame=StartFrame,exports.StaticBatchManager=StaticBatchManager,exports.StaticPlaneColliderShape=StaticPlaneColliderShape,exports.SubMesh=SubMesh,exports.SubMeshDynamicBatch=SubMeshDynamicBatch,exports.SubMeshInstanceBatch=SubMeshInstanceBatch,exports.SubMeshRenderElement=SubMeshRenderElement,exports.SubMeshStaticBatch=SubMeshStaticBatch,exports.SubShader=SubShader,exports.TextMesh=class{get text(){return this._text}set text(value){this._text=value}get fontSize(){return this._fontSize}set fontSize(value){this._fontSize=value}get color(){return this._color}set color(value){this._color=value}constructor(){}_createVertexBuffer(charCount){}_resizeVertexBuffer(charCount){}_addChar(){}},exports.TextureCube=TextureCube,exports.TextureGenerator=TextureGenerator,exports.TextureMode=TextureMode,exports.TextureSheetAnimation=TextureSheetAnimation,exports.Touch=Touch,exports.TrailFilter=TrailFilter,exports.TrailGeometry=TrailGeometry,exports.TrailMaterial=TrailMaterial,exports.TrailRenderer=TrailRenderer,exports.TrailSprite3D=TrailSprite3D,exports.Transform3D=Transform3D,exports.UnlitMaterial=UnlitMaterial,exports.Utils3D=Utils3D,exports.Vector2=Vector2,exports.Vector3=Vector3,exports.Vector3Keyframe=Vector3Keyframe,exports.Vector4=Vector4,exports.VelocityOverLifetime=VelocityOverLifetime,exports.VertexBuffer3D=VertexBuffer3D,exports.VertexDeclaration=VertexDeclaration,exports.VertexElement=VertexElement,exports.VertexElementFormat=VertexElementFormat,exports.VertexMesh=VertexMesh,exports.VertexPositionTerrain=VertexPositionTerrain,exports.VertexPositionTexture0=VertexPositionTexture0,exports.VertexShuriKenParticle=VertexShuriKenParticle,exports.VertexShurikenParticleBillboard=VertexShurikenParticleBillboard,exports.VertexShurikenParticleMesh=VertexShurikenParticleMesh,exports.VertexTrail=VertexTrail,exports.Viewport=Viewport,exports.WaterPrimaryMaterial=WaterPrimaryMaterial}(window.Laya=window.Laya||{},Laya);