!function(e,t){"use strict";class r{constructor(){}static isZero(e){return Math.abs(e)0&&(n=1/Math.sqrt(n),t.x=r*n,t.y=i*n)}static scalarLength(e){var t=e.x,r=e.y;return Math.sqrt(t*t+r*r)}clone(){var e=new i;return this.cloneTo(e),e}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y):this.elements=new Float32Array([this.x,this.y]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1)}static rewriteNumProperty(e,t,r){Object.defineProperty(e,t,{get:function(){return this.elements[r]},set:function(e){this.elements[r]=e}})}}i.ZERO=new i(0,0),i.ONE=new i(1,1);class n{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.z=r,this.w=i}setValue(e,t,r,i){this.x=e,this.y=t,this.z=r,this.w=i}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]}cloneTo(e){var t=e;t.x=this.x,t.y=this.y,t.z=this.z,t.w=this.w}clone(){var e=new n;return this.cloneTo(e),e}static lerp(e,t,r,i){var n=e.x,a=e.y,s=e.z,o=e.w;i.x=n+r*(t.x-n),i.y=a+r*(t.y-a),i.z=s+r*(t.z-s),i.w=o+r*(t.w-o)}static transformByM4x4(e,t,r){var i=e.x,n=e.y,a=e.z,s=e.w,o=t.elements;r.x=i*o[0]+n*o[4]+a*o[8]+s*o[12],r.y=i*o[1]+n*o[5]+a*o[9]+s*o[13],r.z=i*o[2]+n*o[6]+a*o[10]+s*o[14],r.w=i*o[3]+n*o[7]+a*o[11]+s*o[15]}static equals(e,t){return r.nearEqual(Math.abs(e.x),Math.abs(t.x))&&r.nearEqual(Math.abs(e.y),Math.abs(t.y))&&r.nearEqual(Math.abs(e.z),Math.abs(t.z))&&r.nearEqual(Math.abs(e.w),Math.abs(t.w))}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static normalize(e,t){var r=e.length();r>0&&(t.x=e.x*r,t.y=e.y*r,t.z=e.z*r,t.w=e.w*r)}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z,r.w=e.w-t.w}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z,r.w=e.w*t.w}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w*t}static Clamp(e,t,r,i){var n=e.x,a=e.y,s=e.z,o=e.w,l=t.x,_=t.y,h=t.z,c=t.w,d=r.x,u=r.y,f=r.z,E=r.w;n=(n=n>d?d:n)u?u:a)<_?_:a,s=(s=s>f?f:s)E?E:o)0&&(a=1/Math.sqrt(a),t.x=e.x*a,t.y=e.y*a,t.z=e.z*a)}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t}static lerp(e,t,r,i){var n=e.x,a=e.y,s=e.z;i.x=n+r*(t.x-n),i.y=a+r*(t.y-a),i.z=s+r*(t.z-s)}static transformV3ToV3(e,t,r){var i=a._tempVector4;a.transformV3ToV4(e,t,i),r.x=i.x,r.y=i.y,r.z=i.z}static transformV3ToV4(e,t,r){var i=e.x,n=e.y,a=e.z,s=t.elements;r.x=i*s[0]+n*s[4]+a*s[8]+s[12],r.y=i*s[1]+n*s[5]+a*s[9]+s[13],r.z=i*s[2]+n*s[6]+a*s[10]+s[14],r.w=i*s[3]+n*s[7]+a*s[11]+s[15]}static TransformNormal(e,t,r){var i=e.x,n=e.y,a=e.z,s=t.elements;r.x=i*s[0]+n*s[4]+a*s[8],r.y=i*s[1]+n*s[5]+a*s[9],r.z=i*s[2]+n*s[6]+a*s[10]}static transformCoordinate(e,t,r){var i=e.x,n=e.y,a=e.z,s=t.elements,o=i*s[3]+n*s[7]+a*s[11]+s[15];r.x=i*s[0]+n*s[4]+a*s[8]+s[12]/o,r.y=i*s[1]+n*s[5]+a*s[9]+s[13]/o,r.z=i*s[2]+n*s[6]+a*s[10]+s[14]/o}static Clamp(e,t,r,i){var n=e.x,a=e.y,s=e.z,o=t.x,l=t.y,_=t.z,h=r.x,c=r.y,d=r.z;n=(n=n>h?h:n)c?c:a)d?d:s)<_?_:s,i.x=n,i.y=a,i.z=s}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z}static cross(e,t,r){var i=e.x,n=e.y,a=e.z,s=t.x,o=t.y,l=t.z;r.x=n*l-a*o,r.y=a*s-i*l,r.z=i*o-n*s}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}static equals(e,t){return r.nearEqual(e.x,t.x)&&r.nearEqual(e.y,t.y)&&r.nearEqual(e.z,t.z)}setValue(e,t,r){this.x=e,this.y=t,this.z=r}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2]}cloneTo(e){var t=e;t.x=this.x,t.y=this.y,t.z=this.z}clone(){var e=new a;return this.cloneTo(e),e}toDefault(){this.x=0,this.y=0,this.z=0}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y,this.elements[2]=this.z):this.elements=new Float32Array([this.x,this.y,this.z]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1),i.rewriteNumProperty(this,"z",2)}}a._tempVector4=new n,a._ZERO=new a(0,0,0),a._ONE=new a(1,1,1),a._NegativeUnitX=new a(-1,0,0),a._UnitX=new a(1,0,0),a._UnitY=new a(0,1,0),a._UnitZ=new a(0,0,1),a._ForwardRH=new a(0,0,-1),a._ForwardLH=new a(0,0,1),a._Up=new a(0,1,0);class s{constructor(){this._defaultPhysicsMemory=16,this._editerEnvironment=!1,this.isAntialias=!0,this.isAlpha=!1,this.premultipliedAlpha=!0,this.isStencil=!0,this.octreeCulling=!1,this.octreeInitialSize=64,this.octreeInitialCenter=new a(0,0,0),this.octreeMinNodeSize=2,this.octreeLooseness=1.25,this.debugFrustumCulling=!1}get defaultPhysicsMemory(){return this._defaultPhysicsMemory}set defaultPhysicsMemory(e){if(e<16)throw"defaultPhysicsMemory must large than 16M";this._defaultPhysicsMemory=e}cloneTo(e){var t=e;t._defaultPhysicsMemory=this._defaultPhysicsMemory,t._editerEnvironment=this._editerEnvironment,t.isAntialias=this.isAntialias,t.isAlpha=this.isAlpha,t.premultipliedAlpha=this.premultipliedAlpha,t.isStencil=this.isStencil,t.octreeCulling=this.octreeCulling,this.octreeInitialCenter.cloneTo(t.octreeInitialCenter),t.octreeInitialSize=this.octreeInitialSize,t.octreeMinNodeSize=this.octreeMinNodeSize,t.octreeLooseness=this.octreeLooseness,t.debugFrustumCulling=this.debugFrustumCulling}clone(){var e=new s;return this.cloneTo(e),e}}s._default=new s,window.Config3D=s;class o{}o.Scene3D=null,o.MeshRenderStaticBatchManager=null,o.MeshRenderDynamicBatchManager=null,o.SubMeshDynamicBatch=null,o.Laya3D=null,o.Matrix4x4=null;class l{constructor(){this._batchRenderElementPool=[]}static _registerManager(e){l._managers.push(e)}_clear(){this._batchRenderElementPoolIndex=0}_getBatchRenderElementFromPool(){throw"StaticBatch:must override this function."}dispose(){}}l._managers=[];class _ extends t.BufferStateBase{constructor(){super()}applyVertexBuffer(e){if(t.BufferStateBase._curBindedBufferState!==this)throw"BufferState: must call bind() function first.";var r=t.LayaGL.instance,i=e.vertexDeclaration,n=i._shaderValues.getData();for(var a in this.vertexDeclaration=i,e.bind(),n){var s=parseInt(a),o=n[a];r.enableVertexAttribArray(s),r.vertexAttribPointer(s,o[0],o[1],!!o[2],o[3],o[4])}}applyVertexBuffers(e){if(t.BufferStateBase._curBindedBufferState!==this)throw"BufferState: must call bind() function first.";for(var r=t.LayaGL.instance,i=0,n=e.length;io&&(n=o);for(var l=0;l0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){a.subtract(t,e,E.TEMPVector30),a.normalize(E.TEMPVector30,E.TEMPVector30),r.x=Math.asin(E.TEMPVector30.y),r.y=E.arcTanAngle(-E.TEMPVector30.z,-E.TEMPVector30.x)}static createFromAxisAngle(e,t,r){t*=.5;var i=Math.sin(t);r.x=i*e.x,r.y=i*e.y,r.z=i*e.z,r.w=Math.cos(t)}static createFromMatrix4x4(e,t){var r,i,n=e.elements,a=n[0]+n[5]+n[10];a>0?(r=Math.sqrt(a+1),t.w=.5*r,r=.5/r,t.x=(n[6]-n[9])*r,t.y=(n[8]-n[2])*r,t.z=(n[1]-n[4])*r):n[0]>=n[5]&&n[0]>=n[10]?(i=.5/(r=Math.sqrt(1+n[0]-n[5]-n[10])),t.x=.5*r,t.y=(n[1]+n[4])*i,t.z=(n[2]+n[8])*i,t.w=(n[6]-n[9])*i):n[5]>n[10]?(i=.5/(r=Math.sqrt(1+n[5]-n[0]-n[10])),t.x=(n[4]+n[1])*i,t.y=.5*r,t.z=(n[9]+n[6])*i,t.w=(n[8]-n[2])*i):(i=.5/(r=Math.sqrt(1+n[10]-n[0]-n[5])),t.x=(n[8]+n[2])*i,t.y=(n[9]+n[6])*i,t.z=.5*r,t.w=(n[1]-n[4])*i)}static slerp(e,t,r,i){var n,a,s,o,l,_=e.x,h=e.y,c=e.z,d=e.w,u=t.x,f=t.y,E=t.z,T=t.w;return(a=_*u+h*f+c*E+d*T)<0&&(a=-a,u=-u,f=-f,E=-E,T=-T),1-a>1e-6?(n=Math.acos(a),s=Math.sin(n),o=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(o=1-r,l=r),i.x=o*_+l*u,i.y=o*h+l*f,i.z=o*c+l*E,i.w=o*d+l*T,i}static lerp(e,t,r,i){var n=1-r;E.dot(e,t)>=0?(i.x=n*e.x+r*t.x,i.y=n*e.y+r*t.y,i.z=n*e.z+r*t.z,i.w=n*e.w+r*t.w):(i.x=n*e.x-r*t.x,i.y=n*e.y-r*t.y,i.z=n*e.z-r*t.z,i.w=n*e.w-r*t.w),i.normalize(i)}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}scaling(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e}normalize(e){var t=this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w;t>0&&(t=1/Math.sqrt(t),e.x=this.x*t,e.y=this.y*t,e.z=this.z*t,e.w=this.w*t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}rotateX(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.w*r,t.y=this.y*i+this.z*r,t.z=this.z*i-this.y*r,t.w=this.w*i-this.x*r}rotateY(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i-this.z*r,t.y=this.y*i+this.w*r,t.z=this.z*i+this.x*r,t.w=this.w*i-this.y*r}rotateZ(e,t){e*=.5;var r=Math.sin(e),i=Math.cos(e);t.x=this.x*i+this.y*r,t.y=this.y*i-this.x*r,t.z=this.z*i+this.w*r,t.w=this.w*i-this.z*r}getYawPitchRoll(e){a.transformQuat(a._ForwardRH,this,E.TEMPVector31),a.transformQuat(a._Up,this,E.TEMPVector32);var t=E.TEMPVector32;E.angleTo(a._ZERO,E.TEMPVector31,E.TEMPVector33);var r=E.TEMPVector33;r.x==Math.PI/2?(r.y=E.arcTanAngle(t.z,t.x),r.z=0):r.x==-Math.PI/2?(r.y=E.arcTanAngle(-t.z,-t.x),r.z=0):(o.Matrix4x4.createRotationY(-r.y,o.Matrix4x4.TEMPMatrix0),o.Matrix4x4.createRotationX(-r.x,o.Matrix4x4.TEMPMatrix1),a.transformCoordinate(E.TEMPVector32,o.Matrix4x4.TEMPMatrix0,E.TEMPVector32),a.transformCoordinate(E.TEMPVector32,o.Matrix4x4.TEMPMatrix1,E.TEMPVector32),r.z=E.arcTanAngle(t.y,-t.x)),r.y<=-Math.PI&&(r.y=Math.PI),r.z<=-Math.PI&&(r.z=Math.PI),r.y>=Math.PI&&r.z>=Math.PI&&(r.y=0,r.z=0,r.x=Math.PI-r.x);var i=e;i.x=r.y,i.y=r.x,i.z=r.z}invert(e){var t=this.x,r=this.y,i=this.z,n=this.w,a=t*t+r*r+i*i+n*n,s=a?1/a:0;e.x=-t*s,e.y=-r*s,e.z=-i*s,e.w=n*s}identity(){this.x=0,this.y=0,this.z=0,this.w=1}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]}cloneTo(e){this!==e&&(e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w)}clone(){var e=new E;return this.cloneTo(e),e}equals(e){return r.nearEqual(this.x,e.x)&&r.nearEqual(this.y,e.y)&&r.nearEqual(this.z,e.z)&&r.nearEqual(this.w,e.w)}static rotationLookAt(e,t,r){E.lookAt(a._ZERO,e,t,r)}static lookAt(e,t,r,i){f.lookAt(e,t,r,E._tempMatrix3x3),E.rotationMatrix(E._tempMatrix3x3,i)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static invert(e,t){var i=e.lengthSquared();r.isZero(i)||(i=1/i,t.x=-e.x*i,t.y=-e.y*i,t.z=-e.z*i,t.w=e.w*i)}static rotationMatrix(e,t){var r,i,n=e.elements,a=n[0],s=n[1],o=n[2],l=n[3],_=n[4],h=n[5],c=n[6],d=n[7],u=n[8],f=a+_+u;f>0?(r=Math.sqrt(f+1),t.w=.5*r,r=.5/r,t.x=(h-d)*r,t.y=(c-o)*r,t.z=(s-l)*r):a>=_&&a>=u?(i=.5/(r=Math.sqrt(1+a-_-u)),t.x=.5*r,t.y=(s+l)*i,t.z=(o+c)*i,t.w=(h-d)*i):_>u?(i=.5/(r=Math.sqrt(1+_-a-u)),t.x=(l+s)*i,t.y=.5*r,t.z=(d+h)*i,t.w=(c-o)*i):(i=.5/(r=Math.sqrt(1+u-a-_)),t.x=(c+o)*i,t.y=(d+h)*i,t.z=.5*r,t.w=(s-l)*i)}forNativeElement(e=null){e?(this.elements=e,this.elements[0]=this.x,this.elements[1]=this.y,this.elements[2]=this.z,this.elements[3]=this.w):this.elements=new Float32Array([this.x,this.y,this.z,this.w]),i.rewriteNumProperty(this,"x",0),i.rewriteNumProperty(this,"y",1),i.rewriteNumProperty(this,"z",2),i.rewriteNumProperty(this,"w",3)}}E.TEMPVector30=new a,E.TEMPVector31=new a,E.TEMPVector32=new a,E.TEMPVector33=new a,E._tempMatrix3x3=new f,E.DEFAULT=new E,E.NAN=new E(NaN,NaN,NaN,NaN);class T{constructor(e=1,t=0,r=0,i=0,n=0,a=1,s=0,o=0,l=0,_=0,h=1,c=0,d=0,u=0,f=0,E=1,T=null){var m=this.elements=T||new Float32Array(16);m[0]=e,m[1]=t,m[2]=r,m[3]=i,m[4]=n,m[5]=a,m[6]=s,m[7]=o,m[8]=l,m[9]=_,m[10]=h,m[11]=c,m[12]=d,m[13]=u,m[14]=f,m[15]=E}static createRotationX(e,t){var r=t.elements,i=Math.sin(e),n=Math.cos(e);r[1]=r[2]=r[3]=r[4]=r[7]=r[8]=r[11]=r[12]=r[13]=r[14]=0,r[0]=r[15]=1,r[5]=r[10]=n,r[6]=i,r[9]=-i}static createRotationY(e,t){var r=t.elements,i=Math.sin(e),n=Math.cos(e);r[1]=r[3]=r[4]=r[6]=r[7]=r[9]=r[11]=r[12]=r[13]=r[14]=0,r[5]=r[15]=1,r[0]=r[10]=n,r[2]=-i,r[8]=i}static createRotationZ(e,t){var r=t.elements,i=Math.sin(e),n=Math.cos(e);r[2]=r[3]=r[6]=r[7]=r[8]=r[9]=r[11]=r[12]=r[13]=r[14]=0,r[10]=r[15]=1,r[0]=r[5]=n,r[1]=i,r[4]=-i}static createRotationYawPitchRoll(e,t,r,i){E.createFromYawPitchRoll(e,t,r,T._tempQuaternion),T.createRotationQuaternion(T._tempQuaternion,i)}static createRotationAxis(e,t,r){var i=e.x,n=e.y,a=e.z,s=Math.cos(t),o=Math.sin(t),l=i*i,_=n*n,h=a*a,c=i*n,d=i*a,u=n*a,f=r.elements;f[3]=f[7]=f[11]=f[12]=f[13]=f[14]=0,f[15]=1,f[0]=l+s*(1-l),f[1]=c-s*c+o*a,f[2]=d-s*d-o*n,f[4]=c-s*c-o*a,f[5]=_+s*(1-_),f[6]=u-s*u+o*i,f[8]=d-s*d+o*n,f[9]=u-s*u-o*i,f[10]=h+s*(1-h)}setRotation(e){var t=e.x,r=e.y,i=e.z,n=e.w,a=t*t,s=r*r,o=i*i,l=t*r,_=i*n,h=i*t,c=r*n,d=r*i,u=t*n,f=this.elements;f[0]=1-2*(s+o),f[1]=2*(l+_),f[2]=2*(h-c),f[4]=2*(l-_),f[5]=1-2*(o+a),f[6]=2*(d+u),f[8]=2*(h+c),f[9]=2*(d-u),f[10]=1-2*(s+a)}setPosition(e){var t=this.elements;t[12]=e.x,t[13]=e.y,t[14]=e.z}static createRotationQuaternion(e,t){var r=t.elements,i=e.x,n=e.y,a=e.z,s=e.w,o=i*i,l=n*n,_=a*a,h=i*n,c=a*s,d=a*i,u=n*s,f=n*a,E=i*s;r[3]=r[7]=r[11]=r[12]=r[13]=r[14]=0,r[15]=1,r[0]=1-2*(l+_),r[1]=2*(h+c),r[2]=2*(d-u),r[4]=2*(h-c),r[5]=1-2*(_+o),r[6]=2*(f+E),r[8]=2*(d+u),r[9]=2*(f-E),r[10]=1-2*(l+o)}static createTranslate(e,t){var r=t.elements;r[4]=r[8]=r[1]=r[9]=r[2]=r[6]=r[3]=r[7]=r[11]=0,r[0]=r[5]=r[10]=r[15]=1,r[12]=e.x,r[13]=e.y,r[14]=e.z}static createScaling(e,t){var r=t.elements;r[0]=e.x,r[5]=e.y,r[10]=e.z,r[1]=r[4]=r[8]=r[12]=r[9]=r[13]=r[2]=r[6]=r[14]=r[3]=r[7]=r[11]=0,r[15]=1}static multiply(e,t,r){var i=t.elements,n=e.elements,a=r.elements,s=i[0],o=i[1],l=i[2],_=i[3],h=i[4],c=i[5],d=i[6],u=i[7],f=i[8],E=i[9],T=i[10],m=i[11],p=i[12],g=i[13],S=i[14],v=i[15],R=n[0],A=n[1],D=n[2],I=n[3],x=n[4],M=n[5],L=n[6],C=n[7],y=n[8],O=n[9],N=n[10],P=n[11],w=n[12],V=n[13],b=n[14],F=n[15];a[0]=s*R+o*x+l*y+_*w,a[1]=s*A+o*M+l*O+_*V,a[2]=s*D+o*L+l*N+_*b,a[3]=s*I+o*C+l*P+_*F,a[4]=h*R+c*x+d*y+u*w,a[5]=h*A+c*M+d*O+u*V,a[6]=h*D+c*L+d*N+u*b,a[7]=h*I+c*C+d*P+u*F,a[8]=f*R+E*x+T*y+m*w,a[9]=f*A+E*M+T*O+m*V,a[10]=f*D+E*L+T*N+m*b,a[11]=f*I+E*C+T*P+m*F,a[12]=p*R+g*x+S*y+v*w,a[13]=p*A+g*M+S*O+v*V,a[14]=p*D+g*L+S*N+v*b,a[15]=p*I+g*C+S*P+v*F}static multiplyForNative(e,r,i){t.LayaGL.instance.matrix4x4Multiply(e.elements,r.elements,i.elements)}static createFromQuaternion(e,t){var r=t.elements,i=e.x,n=e.y,a=e.z,s=e.w,o=i+i,l=n+n,_=a+a,h=i*o,c=n*o,d=n*l,u=a*o,f=a*l,E=a*_,T=s*o,m=s*l,p=s*_;r[0]=1-d-E,r[1]=c+p,r[2]=u-m,r[3]=0,r[4]=c-p,r[5]=1-h-E,r[6]=f+T,r[7]=0,r[8]=u+m,r[9]=f-T,r[10]=1-h-d,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1}static createAffineTransformation(e,t,r,i){var n=i.elements,a=t.x,s=t.y,o=t.z,l=t.w,_=a+a,h=s+s,c=o+o,d=a*_,u=a*h,f=a*c,E=s*h,T=s*c,m=o*c,p=l*_,g=l*h,S=l*c,v=r.x,R=r.y,A=r.z;n[0]=(1-(E+m))*v,n[1]=(u+S)*v,n[2]=(f-g)*v,n[3]=0,n[4]=(u-S)*R,n[5]=(1-(d+m))*R,n[6]=(T+p)*R,n[7]=0,n[8]=(f+g)*A,n[9]=(T-p)*A,n[10]=(1-(d+E))*A,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1}static createLookAt(e,t,r,i){var n=i.elements,s=T._tempVector0,o=T._tempVector1,l=T._tempVector2;a.subtract(e,t,l),a.normalize(l,l),a.cross(r,l,s),a.normalize(s,s),a.cross(l,s,o),i.identity(),n[0]=s.x,n[4]=s.y,n[8]=s.z,n[1]=o.x,n[5]=o.y,n[9]=o.z,n[2]=l.x,n[6]=l.y,n[10]=l.z,n[12]=-a.dot(s,e),n[13]=-a.dot(o,e),n[14]=-a.dot(l,e)}static createPerspective(e,t,r,i,n){var a=1/Math.tan(.5*e),s=r/(a/t),o=r/a;T.createPerspectiveOffCenter(-s,s,-o,o,r,i,n)}static createPerspectiveOffCenter(e,t,r,i,n,a,s){var o=s.elements,l=a/(a-n);o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[12]=o[13]=o[15]=0,o[0]=2*n/(t-e),o[5]=2*n/(i-r),o[8]=(e+t)/(t-e),o[9]=(i+r)/(i-r),o[10]=-l,o[11]=-1,o[14]=-n*l}static createOrthoOffCenter(e,t,r,i,n,a,s){var o=s.elements,l=1/(a-n);o[1]=o[2]=o[3]=o[4]=o[6]=o[8]=o[7]=o[9]=o[11]=0,o[15]=1,o[0]=2/(t-e),o[5]=2/(i-r),o[10]=-l,o[12]=(e+t)/(e-t),o[13]=(i+r)/(r-i),o[14]=-n*l}getElementByRowColumn(e,t){if(e<0||e>3)throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");return this.elements[4*e+t]}setElementByRowColumn(e,t,r){if(e<0||e>3)throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");this.elements[4*e+t]=r}equalsOtherMatrix(e){var t=this.elements,i=e.elements;return r.nearEqual(t[0],i[0])&&r.nearEqual(t[1],i[1])&&r.nearEqual(t[2],i[2])&&r.nearEqual(t[3],i[3])&&r.nearEqual(t[4],i[4])&&r.nearEqual(t[5],i[5])&&r.nearEqual(t[6],i[6])&&r.nearEqual(t[7],i[7])&&r.nearEqual(t[8],i[8])&&r.nearEqual(t[9],i[9])&&r.nearEqual(t[10],i[10])&&r.nearEqual(t[11],i[11])&&r.nearEqual(t[12],i[12])&&r.nearEqual(t[13],i[13])&&r.nearEqual(t[14],i[14])&&r.nearEqual(t[15],i[15])}decomposeTransRotScale(e,t,r){var i=T._tempMatrix4x4;return this.decomposeTransRotMatScale(e,i,r)?(E.createFromMatrix4x4(i,t),!0):(t.identity(),!1)}decomposeTransRotMatScale(e,t,i){var n=this.elements,s=e,o=t.elements,l=i;s.x=n[12],s.y=n[13],s.z=n[14];var _=n[0],h=n[1],c=n[2],d=n[4],u=n[5],f=n[6],E=n[8],m=n[9],p=n[10],g=l.x=Math.sqrt(_*_+h*h+c*c),S=l.y=Math.sqrt(d*d+u*u+f*f),v=l.z=Math.sqrt(E*E+m*m+p*p);if(r.isZero(g)||r.isZero(S)||r.isZero(v))return o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[8]=o[9]=o[11]=o[12]=o[13]=o[14]=0,o[0]=o[5]=o[10]=o[15]=1,!1;var R=T._tempVector0;R.x=E/v,R.y=m/v,R.z=p/v;var A=T._tempVector1;A.x=_/g,A.y=h/g,A.z=c/g;var D=T._tempVector2;a.cross(R,A,D);var I=T._tempVector1;return a.cross(D,R,I),o[3]=o[7]=o[11]=o[12]=o[13]=o[14]=0,o[15]=1,o[0]=I.x,o[1]=I.y,o[2]=I.z,o[4]=D.x,o[5]=D.y,o[6]=D.z,o[8]=R.x,o[9]=R.y,o[10]=R.z,o[0]*_+o[1]*h+o[2]*c<0&&(l.x=-g),o[4]*d+o[5]*u+o[6]*f<0&&(l.y=-S),o[8]*E+o[9]*m+o[10]*p<0&&(l.z=-v),!0}decomposeYawPitchRoll(e){var t=Math.asin(-this.elements[9]);e.y=t,Math.cos(t)>r.zeroTolerance?(e.z=Math.atan2(this.elements[1],this.elements[5]),e.x=Math.atan2(this.elements[8],this.elements[10])):(e.z=Math.atan2(-this.elements[4],this.elements[0]),e.x=0)}normalize(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=Math.sqrt(t*t+r*r+i*i);if(!n)return e[0]=0,e[1]=0,void(e[2]=0);1!=n&&(n=1/n,e[0]=t*n,e[1]=r*n,e[2]=i*n)}transpose(){var e,t;return t=(e=this.elements)[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}invert(e){var t=this.elements,r=e.elements,i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],_=t[6],h=t[7],c=t[8],d=t[9],u=t[10],f=t[11],E=t[12],T=t[13],m=t[14],p=t[15],g=i*l-n*o,S=i*_-a*o,v=i*h-s*o,R=n*_-a*l,A=n*h-s*l,D=a*h-s*_,I=c*T-d*E,x=c*m-u*E,M=c*p-f*E,L=d*m-u*T,C=d*p-f*T,y=u*p-f*m,O=g*y-S*C+v*L+R*M-A*x+D*I;0!==Math.abs(O)&&(O=1/O,r[0]=(l*y-_*C+h*L)*O,r[1]=(a*C-n*y-s*L)*O,r[2]=(T*D-m*A+p*R)*O,r[3]=(u*A-d*D-f*R)*O,r[4]=(_*M-o*y-h*x)*O,r[5]=(i*y-a*M+s*x)*O,r[6]=(m*v-E*D-p*S)*O,r[7]=(c*D-u*v+f*S)*O,r[8]=(o*C-l*M+h*I)*O,r[9]=(n*M-i*C-s*I)*O,r[10]=(E*A-T*v+p*g)*O,r[11]=(d*v-c*A-f*g)*O,r[12]=(l*x-o*L-_*I)*O,r[13]=(i*L-n*x+a*I)*O,r[14]=(T*S-E*R-m*g)*O,r[15]=(c*R-d*S+u*g)*O)}static billboard(e,t,i,n,s,o){a.subtract(e,t,T._tempVector0);var l=a.scalarLengthSquared(T._tempVector0);r.isZero(l)?(a.scale(s,-1,T._tempVector1),T._tempVector1.cloneTo(T._tempVector0)):a.scale(T._tempVector0,1/Math.sqrt(l),T._tempVector0),a.cross(n,T._tempVector0,T._tempVector2),a.normalize(T._tempVector2,T._tempVector2),a.cross(T._tempVector0,T._tempVector2,T._tempVector3);var _=T._tempVector2,h=T._tempVector3,c=T._tempVector0,d=e,u=o.elements;u[0]=_.x,u[1]=_.y,u[2]=_.z,u[3]=0,u[4]=h.x,u[5]=h.y,u[6]=h.z,u[7]=0,u[8]=c.x,u[9]=c.y,u[10]=c.z,u[11]=0,u[12]=d.x,u[13]=d.y,u[14]=d.z,u[15]=1}identity(){var e=this.elements;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1}cloneTo(e){var t,r,i;if((r=this.elements)!==(i=e.elements))for(t=0;t<16;++t)i[t]=r[t]}clone(){var e=new T;return this.cloneTo(e),e}static translation(e,t){var r=t.elements;r[0]=r[5]=r[10]=r[15]=1,r[12]=e.x,r[13]=e.y,r[14]=e.z}getTranslationVector(e){var t=this.elements;e.x=t[12],e.y=t[13],e.z=t[14]}setTranslationVector(e){var t=this.elements,r=e;t[12]=r.x,t[13]=r.y,t[14]=r.z}getForward(e){var t=this.elements;e.x=-t[8],e.y=-t[9],e.z=-t[10]}setForward(e){var t=this.elements;t[8]=-e.x,t[9]=-e.y,t[10]=-e.z}}T._tempMatrix4x4=new T,T.TEMPMatrix0=new T,T.TEMPMatrix1=new T,T._tempVector0=new a,T._tempVector1=new a,T._tempVector2=new a,T._tempVector3=new a,T._tempQuaternion=new E,T.DEFAULT=new T,T.ZERO=new T(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);class m{constructor(){this.value=0}add(e){this.value|=e}remove(e){this.value&=~e}has(e){return(this.value&e)>0}cloneTo(e){e.value=this.value}clone(){var e=new m;return this.cloneTo(e),e}}class p{constructor(e=null){this._ownerResource=null,this._data=null,this._defineDatas=new m,this._runtimeCopyValues=[],this._ownerResource=e,this._initData()}_initData(){this._data=new Object}getData(){return this._data}addDefine(e){this._defineDatas.add(e)}removeDefine(e){this._defineDatas.remove(e)}hasDefine(e){return(this._defineDatas.value&e)>0}clearDefine(){this._defineDatas.value=0}getBool(e){return this._data[e]}setBool(e,t){this._data[e]=t}getInt(e){return this._data[e]}setInt(e,t){this._data[e]=t}getNumber(e){return this._data[e]}setNumber(e,t){this._data[e]=t}getVector2(e){return this._data[e]}setVector2(e,t){this._data[e]=t}getVector3(e){return this._data[e]}setVector3(e,t){this._data[e]=t}getVector(e){return this._data[e]}setVector(e,t){this._data[e]=t}getQuaternion(e){return this._data[e]}setQuaternion(e,t){this._data[e]=t}getMatrix4x4(e){return this._data[e]}setMatrix4x4(e,t){this._data[e]=t}getBuffer(e){return this._data[e]}setBuffer(e,t){this._data[e]=t}setTexture(e,t){var r=this._data[e];this._data[e]=t,this._ownerResource&&this._ownerResource.referenceCount>0&&(r&&r._removeReference(),t&&t._addReference())}getTexture(e){return this._data[e]}setAttribute(e,t){this._data[e]=t}getAttribute(e){return this._data[e]}getLength(){return this._data.length}setLength(e){this._data.length=e}cloneTo(e){var r=e,s=r._data;for(var o in this._data){var l=this._data[o];if(null!=l)if("number"==typeof l)s[o]=l;else if("number"==typeof l)s[o]=l;else if("boolean"==typeof l)s[o]=l;else if(l instanceof i){var _=s[o]||(s[o]=new i);l.cloneTo(_),s[o]=_}else if(l instanceof a){var h=s[o]||(s[o]=new a);l.cloneTo(h),s[o]=h}else if(l instanceof n){var c=s[o]||(s[o]=new n);l.cloneTo(c),s[o]=c}else if(l instanceof T){var d=s[o]||(s[o]=new T);l.cloneTo(d),s[o]=d}else l instanceof t.BaseTexture&&(s[o]=l)}this._defineDatas.cloneTo(r._defineDatas)}clone(){var e=new p;return this.cloneTo(e),e}cloneToForNative(e){var r=e;this._int32Data.length-r._int32Data.length>0&&r.needRenewArrayBufferForNative(this._int32Data.length),r._int32Data.set(this._int32Data,0);var s=r._nativeArray,o=this._nativeArray.length;s.length=o;for(var l=0;l=this._int32Data.length){var r=4*(e+1),i=this._int32Data,n=this._data.conchRef,a=this._data._ptrID;this._data=new ArrayBuffer(r),this._int32Data=new Int32Array(this._data),this._float32Data=new Float32Array(this._data),this._data.conchRef=n,this._data._ptrID=a,i&&this._int32Data.set(i,0);var s=t.LayaGL.instance;s.updateArrayBufferRef?s.updateArrayBufferRef(this._data._ptrID,n.isSyncToRender(),this._data):window.conch.updateArrayBufferRef(this._data._ptrID,n.isSyncToRender(),this._data)}}getDataForNative(){return this._nativeArray}getIntForNative(e){return this._int32Data[e]}setIntForNative(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t,this._nativeArray[e]=t}getBoolForNative(e){return 1==this._int32Data[e]}setBoolForNative(e,t){this.needRenewArrayBufferForNative(e),this._int32Data[e]=t?1:0,this._nativeArray[e]=t}getNumberForNative(e){return this._float32Data[e]}setNumberForNative(e,t){this.needRenewArrayBufferForNative(e),this._float32Data[e]=t,this._nativeArray[e]=t}getMatrix4x4ForNative(e){return this._nativeArray[e]}setMatrix4x4ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVectorForNative(e){return this._nativeArray[e]}setVectorForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVector2ForNative(e){return this._nativeArray[e]}setVector2ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getVector3ForNative(e){return this._nativeArray[e]}setVector3ForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getQuaternionForNative(e){return this._nativeArray[e]}setQuaternionForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t,t.elements||t.forNativeElement();var r=this.setReferenceForNative(t.elements);this._int32Data[e]=r}getBufferForNative(e){return this._nativeArray[e]}setBufferForNative(e,t){this.needRenewArrayBufferForNative(e),this._nativeArray[e]=t;var r=this.setReferenceForNative(t);this._int32Data[e]=r}getAttributeForNative(e){return this._nativeArray[e]}setAttributeForNative(e,r){this._nativeArray[e]=r,r._ptrID||t.LayaGL.instance.createArrayBufferRef(r,t.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0),t.LayaGL.instance.syncBufferToRenderThread(r),this._int32Data[e]=r._ptrID}getTextureForNative(e){return this._nativeArray[e]}setTextureForNative(e,t){if(t){this.needRenewArrayBufferForNative(e);var r=this._nativeArray[e];this._nativeArray[e]=t,this._int32Data[e]=t._glTexture.id,this._ownerResource&&this._ownerResource.referenceCount>0&&(r&&r._removeReference(),t&&t._addReference())}}setReferenceForNative(e){this.clearRuntimeCopyArray();var r=0,i=0;return p._SET_RUNTIME_VALUE_MODE_REFERENCE_?(t.LayaGL.instance.createArrayBufferRefs(e,t.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0,t.LayaGL.ARRAY_BUFFER_REF_REFERENCE),r=0,i=e.getPtrID(r)):(t.LayaGL.instance.createArrayBufferRefs(e,t.LayaGL.ARRAY_BUFFER_TYPE_DATA,!0,t.LayaGL.ARRAY_BUFFER_REF_COPY),r=e.getRefNum()-1,i=e.getPtrID(r),this._runtimeCopyValues.push({obj:e,refID:r,ptrID:i})),t.LayaGL.instance.syncBufferToRenderThread(e,r),i}static setRuntimeValueMode(e){p._SET_RUNTIME_VALUE_MODE_REFERENCE_=e}clearRuntimeCopyArray(){var e=t.Stat.loopCount;if(this._frameCount!=e){this._frameCount=e;for(var r=0,i=this._runtimeCopyValues.length;rR.maxIndicesCount&&(this._flush(a,s),o++,t.Stat.trianglesFaces+=s/3,a=s=0);var f=c._transform;this._getBatchVertices(i,this._vertices,a,f,c,d),this._getBatchIndices(this._indices,s,a,f,d,c._dynamicMultiSubMesh),a+=c._dynamicVertexCount,s+=u}this._flush(a,s),o++,t.Stat.renderBatches+=o,t.Stat.savedRenderBatches+=l-o,t.Stat.trianglesFaces+=s/3}}R.maxAllowVertexCount=10,R.maxAllowAttribueCount=900,R.maxIndicesCount=32e3;class A{constructor(){this.updateMark=-1,this.indexInList=-1,this.batched=!1}}class D extends h{constructor(){super(),this.maxInstanceCount=1024,this.instanceWorldMatrixData=new Float32Array(16*this.maxInstanceCount),this.instanceMVPMatrixData=new Float32Array(16*this.maxInstanceCount);var e=t.LayaGL.instance;this.instanceWorldMatrixBuffer=new d(4*this.instanceWorldMatrixData.length,e.DYNAMIC_DRAW),this.instanceMVPMatrixBuffer=new d(4*this.instanceMVPMatrixData.length,e.DYNAMIC_DRAW),this.instanceWorldMatrixBuffer.vertexDeclaration=v.instanceWorldMatrixDeclaration,this.instanceMVPMatrixBuffer.vertexDeclaration=v.instanceMVPMatrixDeclaration}static __init__(){D.instance=new D}_render(e){var r=t.LayaGL.instance,i=e.renderElement,n=i.instanceSubMesh,a=i.instanceBatchElementList.length,s=n._indexCount;n._mesh._instanceBufferState.bind(),t.LayaGL.layaGPUInstance.drawElementsInstanced(r.TRIANGLES,s,r.UNSIGNED_SHORT,2*n._indexStart,a),t.Stat.renderBatches++,t.Stat.savedRenderBatches+=a-1,t.Stat.trianglesFaces+=s*a/3}}class I{constructor(e=1,t=1,r=1,i=1){this.r=e,this.g=t,this.b=r,this.a=i}static gammaToLinearSpace(e){return e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)}static linearToGammaSpace(e){return e<=0?0:e<=.0031308?12.92*e:e<=1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)}toLinear(e){e.r=I.gammaToLinearSpace(this.r),e.g=I.gammaToLinearSpace(this.g),e.b=I.gammaToLinearSpace(this.b)}toGamma(e){e.r=I.linearToGammaSpace(this.r),e.g=I.linearToGammaSpace(this.g),e.b=I.linearToGammaSpace(this.b)}cloneTo(e){var t=e;t.r=this.r,t.g=this.g,t.b=this.b,t.a=this.a}clone(){var e=new I;return this.cloneTo(e),e}forNativeElement(){}}I.RED=new I(1,0,0,1),I.GREEN=new I(0,1,0,1),I.BLUE=new I(0,0,1,1),I.CYAN=new I(0,1,1,1),I.YELLOW=new I(1,.92,.016,1),I.MAGENTA=new I(1,0,1,1),I.GRAY=new I(.5,.5,.5,1),I.WHITE=new I(1,1,1,1),I.BLACK=new I(0,0,0,1);class x{constructor(){}static lightAttenTexture(e,t,r,i,n,a){var s=e/r,o=1/(1+25*s);s>=.64&&(s>1?o=0:o*=1-(s-.64)/.36),a[n]=Math.floor(255*o+.5)}static haloTexture(e,t,r,i,n,a){var s=(e-(r>>=1))/r,o=(t-(i>>=1))/i,l=s*s+o*o;l>1&&(l=1),a[n]=Math.floor(255*(1-l)+.5)}static _generateTexture2D(e,r,i,n){var a=0,s=0;switch(e.format){case t.BaseTexture.FORMAT_R8G8B8:s=3;break;case t.BaseTexture.FORMAT_R8G8B8A8:s=4;break;case t.BaseTexture.FORMAT_ALPHA8:s=1;break;default:throw"GeneratedTexture._generateTexture: unkonw texture format."}for(var o=new Uint8Array(r*i*s),l=0;l=0?e.substr(t):null}static _createAffineTransformationArray(e,t,r,i){var n=t.x,a=t.y,s=t.z,o=t.w,l=n+n,_=a+a,h=s+s,c=n*l,d=n*_,u=n*h,f=a*_,E=a*h,T=s*h,m=o*l,p=o*_,g=o*h,S=r.x,v=r.y,R=r.z;i[0]=(1-(f+T))*S,i[1]=(d+g)*S,i[2]=(u-p)*S,i[3]=0,i[4]=(d-g)*v,i[5]=(1-(c+T))*v,i[6]=(E+m)*v,i[7]=0,i[8]=(u+p)*R,i[9]=(E-m)*R,i[10]=(1-(c+f))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1}static _mulMatrixArray(e,t,r,i){var n,a,s,o,l,_=t.elements,h=_[0],c=_[1],d=_[2],u=_[3],f=_[4],E=_[5],T=_[6],m=_[7],p=_[8],g=_[9],S=_[10],v=_[11],R=_[12],A=_[13],D=_[14],I=_[15],x=i,M=i+4,L=i+8,C=i+12;for(n=0;n<4;n++)a=e[n],s=e[n+4],o=e[n+8],l=e[n+12],r[x+n]=a*h+s*c+o*d+l*u,r[M+n]=a*f+s*E+o*T+l*m,r[L+n]=a*p+s*g+o*S+l*v,r[C+n]=a*R+s*A+o*D+l*I}static arcTanAngle(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){a.subtract(t,e,E.TEMPVector30),a.normalize(E.TEMPVector30,E.TEMPVector30),r.x=Math.asin(E.TEMPVector30.y),r.y=M.arcTanAngle(-E.TEMPVector30.z,-E.TEMPVector30.x)}static transformQuat(e,t,r){var i=t,n=e.x,a=e.y,s=e.z,o=i[0],l=i[1],_=i[2],h=i[3],c=h*n+l*s-_*a,d=h*a+_*n-o*s,u=h*s+o*a-l*n,f=-o*n-l*a-_*s;r.x=c*h+f*-o+d*-_-u*-l,r.y=d*h+f*-l+u*-o-c*-_,r.z=u*h+f*-_+c*-l-d*-o}static quaternionWeight(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w}static quaternionConjugate(e,t){t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w}static scaleWeight(e,t,r){var i=e.x,n=e.y,a=e.z;r.x=i>0?Math.pow(Math.abs(i),t):-Math.pow(Math.abs(i),t),r.y=n>0?Math.pow(Math.abs(n),t):-Math.pow(Math.abs(n),t),r.z=a>0?Math.pow(Math.abs(a),t):-Math.pow(Math.abs(a),t)}static scaleBlend(e,t,r,i){var n=M._tempVector3_0,a=M._tempVector3_1;M.scaleWeight(e,1-r,n),M.scaleWeight(t,r,a);var s=r>.5?t:e;i.x=s.x>0?Math.abs(n.x*a.x):-Math.abs(n.x*a.x),i.y=s.y>0?Math.abs(n.y*a.y):-Math.abs(n.y*a.y),i.z=s.z>0?Math.abs(n.z*a.z):-Math.abs(n.z*a.z)}static matrix4x4MultiplyFFF(e,t,r){var i,n,a,s,o;if(r===t)for(t=new Float32Array(16),i=0;i<16;++i)t[i]=r[i];var l=t[0],_=t[1],h=t[2],c=t[3],d=t[4],u=t[5],f=t[6],E=t[7],T=t[8],m=t[9],p=t[10],g=t[11],S=t[12],v=t[13],R=t[14],A=t[15];for(i=0;i<4;i++)n=e[i],a=e[i+4],s=e[i+8],o=e[i+12],r[i]=n*l+a*_+s*h+o*c,r[i+4]=n*d+a*u+s*f+o*E,r[i+8]=n*T+a*m+s*p+o*g,r[i+12]=n*S+a*v+s*R+o*A}static matrix4x4MultiplyFFFForNative(e,r,i){t.LayaGL.instance.matrix4x4Multiply(e,r,i)}static matrix4x4MultiplyMFM(e,t,r){M.matrix4x4MultiplyFFF(e.elements,t,r.elements)}static _buildTexture2D(e,r,i,n,a=!1){var s=new t.Texture2D(e,r,i,a,!0);return s.anisoLevel=1,s.filterMode=t.BaseTexture.FILTERMODE_POINT,x._generateTexture2D(s,e,r,n),s}static _drawBound(e,t,r){e.lineCount+12>e.maxLineCount&&(e.maxLineCount+=12);var i=M._tempVector3_0,n=M._tempVector3_1,a=t.min,s=t.max;i.setValue(a.x,a.y,a.z),n.setValue(s.x,a.y,a.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,a.z),n.setValue(a.x,a.y,s.z),e.addLine(i,n,r,r),i.setValue(s.x,a.y,a.z),n.setValue(s.x,a.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,s.z),n.setValue(s.x,a.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,a.z),n.setValue(a.x,s.y,a.z),e.addLine(i,n,r,r),i.setValue(a.x,a.y,s.z),n.setValue(a.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(s.x,a.y,a.z),n.setValue(s.x,s.y,a.z),e.addLine(i,n,r,r),i.setValue(s.x,a.y,s.z),n.setValue(s.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,s.y,a.z),n.setValue(s.x,s.y,a.z),e.addLine(i,n,r,r),i.setValue(a.x,s.y,a.z),n.setValue(a.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(s.x,s.y,a.z),n.setValue(s.x,s.y,s.z),e.addLine(i,n,r,r),i.setValue(a.x,s.y,s.z),n.setValue(s.x,s.y,s.z),e.addLine(i,n,r,r)}static _getHierarchyPath(e,t,r){r.length=0;for(var i=t;i!==e;){var n=i._parent;if(!n)return null;r.push(n.getChildIndex(i)),i=n}return r}static _getNodeByHierarchyPath(e,t){for(var r=e,i=t.length-1;i>=0;i--)r=r.getChildAt(t[i]);return r}}M._tempVector3_0=new a,M._tempVector3_1=new a,M._tempVector3_2=new a,M._tempColor0=new I,M._tempArray16_0=new Float32Array(16),M._tempArray16_1=new Float32Array(16),M._tempArray16_2=new Float32Array(16),M._tempArray16_3=new Float32Array(16),M._compIdToNode=new Object;class L{constructor(e,t,r,i){this._attributeMap=null,this._uniformMap=null,this._enableInstancing=!1,this._subShaders=[],this._name=e,this._attributeMap=t,this._uniformMap=r,this._enableInstancing=i}static propertyNameToID(e){if(null!=L._propertyNameMap[e])return L._propertyNameMap[e];var t=L._propertyNameCounter++;return L._propertyNameMap[e]=t,t}static addInclude(e,r){r=r.replace(t.ShaderCompile._clearCR,""),t.ShaderCompile.addInclude(e,r)}static registerPublicDefine(e){var t=Math.pow(2,L._publicCounter++);return L._globleDefines[t]=e,t}static compileShader(e,r,i,n,a,s){var o=L.find(e);if(o){var l=o.getSubShaderAt(r);if(l){var _=l._passes[i];_?t.WebGL.shaderHighPrecision?_.withCompile(n,a,s):_.withCompile(n-L.SHADERDEFINE_HIGHPRECISION,a,s):console.warn("Shader3D: unknown passIndex.")}else console.warn("Shader3D: unknown subShaderIndex.")}else console.warn("Shader3D: unknown shader name.")}static add(e,t=null,r=null,i=!1){return L._preCompileShader[e]=new L(e,t,r,i)}static find(e){return L._preCompileShader[e]}addSubShader(e){this._subShaders.push(e),e._owner=this}getSubShaderAt(e){return this._subShaders[e]}}L.RENDER_STATE_CULL=0,L.RENDER_STATE_BLEND=1,L.RENDER_STATE_BLEND_SRC=2,L.RENDER_STATE_BLEND_DST=3,L.RENDER_STATE_BLEND_SRC_RGB=4,L.RENDER_STATE_BLEND_DST_RGB=5,L.RENDER_STATE_BLEND_SRC_ALPHA=6,L.RENDER_STATE_BLEND_DST_ALPHA=7,L.RENDER_STATE_BLEND_CONST_COLOR=8,L.RENDER_STATE_BLEND_EQUATION=9,L.RENDER_STATE_BLEND_EQUATION_RGB=10,L.RENDER_STATE_BLEND_EQUATION_ALPHA=11,L.RENDER_STATE_DEPTH_TEST=12,L.RENDER_STATE_DEPTH_WRITE=13,L.PERIOD_CUSTOM=0,L.PERIOD_MATERIAL=1,L.PERIOD_SPRITE=2,L.PERIOD_CAMERA=3,L.PERIOD_SCENE=4,L._propertyNameCounter=0,L._propertyNameMap={},L._publicCounter=0,L._globleDefines=[],L._preCompileShader={},L.debugMode=!1;class C{constructor(e=null){if(this._counter=0,this.defines={},e)for(var t in this._counter=e._counter,e.defines)this.defines[t]=e.defines[t]}registerDefine(e){var t=Math.pow(2,this._counter++);return this.defines[t]=e,t}}class y{get normalizedTime(){return this._normalizedTime}get duration(){return this._duration}constructor(){}_resetPlayState(e){this._finish=!1,this._startPlayTime=e,this._elapsedTime=e,this._playEventIndex=0,this._lastIsFront=!0}_cloneTo(e){e._finish=this._finish,e._startPlayTime=this._startPlayTime,e._elapsedTime=this._elapsedTime,e._playEventIndex=this._playEventIndex,e._lastIsFront=this._lastIsFront}}class O{constructor(e){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 y,this._crossPlayStateInfo=new y,this._srcCrossClipNodeIndices=[],this._destCrossClipNodeIndices=[],this.name=e,this.defaultWeight=1,this.blendingMode=O.BLENDINGMODE_OVERRIDE}get defaultState(){return this._defaultState}set defaultState(e){this._defaultState=e,this._statesMap[e.name]=e}_removeClip(e,t,r,i){var n=i._clip,a=e[r];if(e.splice(r,1),delete t[i.name],this._animator){var s=n._nodes,o=a._nodeOwners;n._removeReference();for(var l=0,_=s.count;l<_;l++)this._animator._removeKeyframeNodeOwner(o,s.getNodeByIndex(l))}}_getReferenceCount(){return this._referenceCount}_addReference(e=1){for(var t=0,r=this._states.length;t0&&this._clip._removeReference(this._referenceCount),e&&(this._currentFrameIndices=new Int16Array(e._nodes.count),this._resetFrameIndices(),this._referenceCount>0&&this._clip._addReference(this._referenceCount)),this._clip=e)}_getReferenceCount(){return this._referenceCount}_addReference(e=1){this._clip&&this._clip._addReference(e),this._referenceCount+=e}_removeReference(e=1){this._clip&&this._clip._removeReference(e),this._referenceCount-=e}_clearReference(){this._removeReference(-this._referenceCount)}_resetFrameIndices(){for(var e=0,t=this._currentFrameIndices.length;e=n){if(t._finish=!0,t._elapsedTime=n,t._normalizedPlayTime=1,_)for(var h=0,c=_.length;h=0&&(s=t[r]).time>=i;r--)for(o=0,l=e.length;o=t._lastElapsedTime;if(t._lastIsFront!==_&&(_?t._playEventIndex++:t._playEventIndex--,t._lastIsFront=_),0==l)t._playEventIndex=this._eventScript(r,n,t._playEventIndex,o,_);else if(_){this._eventScript(r,n,t._playEventIndex,a,!0);for(var h=0,c=l-1;hr._lastElapsedTime;n._evaluateClipDatasRealTime(n._nodes,s,o,t,l)}_applyFloat(e,t,r,i,n,a,s){if(r.updateMark===this._updateMark)if(i)e[t]+=n*s;else{var o=e[t];e[t]=o+n*(s-o)}else if(a)e[t]=i?r.defaultValue+s:s;else if(i)e[t]=r.defaultValue+n*s;else{var l=r.defaultValue;e[t]=l+n*(s-l)}}_applyPositionAndRotationEuler(e,t,r,i,n,a){if(e.updateMark===this._updateMark)if(t)a.x+=r*n.x,a.y+=r*n.y,a.z+=r*n.z;else{var s=a.x,o=a.y,l=a.z;a.x=s+r*(n.x-s),a.y=o+r*(n.y-o),a.z=l+r*(n.z-l)}else if(i)if(t){var _=e.defaultValue;a.x=_.x+n.x,a.y=_.y+n.y,a.z=_.z+n.z}else a.x=n.x,a.y=n.y,a.z=n.z;else if(_=e.defaultValue,t)a.x=_.x+r*n.x,a.y=_.y+r*n.y,a.z=_.z+r*n.z;else{var h=_.x,c=_.y,d=_.z;a.x=h+r*(n.x-h),a.y=c+r*(n.y-c),a.z=d+r*(n.z-d)}}_applyRotation(e,t,r,i,n,a){if(e.updateMark===this._updateMark)if(t){var s=w._tempQuaternion1;M.quaternionWeight(n,r,s),s.normalize(s),E.multiply(a,s,a)}else E.lerp(a,n,r,a);else if(i)if(t){var o=e.defaultValue;E.multiply(o,n,a)}else a.x=n.x,a.y=n.y,a.z=n.z,a.w=n.w;else o=e.defaultValue,t?(s=w._tempQuaternion1,M.quaternionWeight(n,r,s),s.normalize(s),E.multiply(o,s,a)):E.lerp(o,n,r,a)}_applyScale(e,t,r,i,n,a){if(e.updateMark===this._updateMark)if(t){var s=w._tempVector31;M.scaleWeight(n,r,s),a.x=a.x*s.x,a.y=a.y*s.y,a.z=a.z*s.z}else M.scaleBlend(a,n,r,a);else if(i)if(t){var o=e.defaultValue;a.x=o.x*n.x,a.y=o.y*n.y,a.z=o.z*n.z}else a.x=n.x,a.y=n.y,a.z=n.z;else o=e.defaultValue,t?(s=w._tempVector31,M.scaleWeight(n,r,s),a.x=o.x*s.x,a.y=o.y*s.y,a.z=o.z*s.z):M.scaleBlend(o,n,r,a)}_applyCrossData(e,t,r,i,n,a,s){var o=e.propertyOwner;if(o){switch(e.type){case 0:for(var l=e.property,_=l.length-1,h=0;h<_&&(o=o[l[h]]);h++);var c=n+s*(a-n);this._applyFloat(o,l[_],e,t,r,i,c);break;case 1:var d=o.localPosition,u=w._tempVector30,f=n.x,T=n.y,m=n.z;u.x=f+s*(a.x-f),u.y=T+s*(a.y-T),u.z=m+s*(a.z-m),this._applyPositionAndRotationEuler(e,t,r,i,u,d),o.localPosition=d;break;case 2:var p=o.localRotation,g=w._tempQuaternion0;E.lerp(n,a,s,g),this._applyRotation(e,t,r,i,g,p),o.localRotation=p;break;case 3:var S=o.localScale,v=w._tempVector30;M.scaleBlend(n,a,s,v),this._applyScale(e,t,r,i,v,S),o.localScale=S;break;case 4:var R=o.localRotationEuler,A=w._tempVector30;f=n.x,T=n.y,m=n.z,A.x=f+s*(a.x-f),A.y=T+s*(a.y-T),A.z=m+s*(a.z-m),this._applyPositionAndRotationEuler(e,t,r,i,A,R),o.localRotationEuler=R}e.updateMark=this._updateMark}}_setClipDatasToNode(e,t,r,i){for(var n=e._clip._nodes,a=e._nodeOwners,s=0,o=n.count;sg?g/m:1,v=this._speed*E.speed;this._updatePlayer(E,_,r*S*v,T.islooping);var R=(_._elapsedTime-p)/S/m;R>=1?i&&(this._updateClipDatas(E,f,_,s*v),this._setClipDatasToNode(E,f,o.defaultWeight,0===n),o._playType=0,o._currentPlayState=E,_._cloneTo(l)):(l._finish||(d=this._speed*h.speed,this._updatePlayer(h,l,r*d,c.islooping)),i&&(this._updateClipDatas(h,f,l,s*d),this._updateClipDatas(E,f,_,s*S*v),this._setCrossClipDatasToNode(o,h,E,R,0===n))),i&&(this._updateEventScript(h,l),this._updateEventScript(E,_));break;case 2:T=(E=o._crossPlayState)._clip,m=o._crossDuration,p=_._startPlayTime,S=m>(g=T._duration-p)?g/m:1,v=this._speed*E.speed,this._updatePlayer(E,_,r*S*v,T.islooping),i&&((R=(_._elapsedTime-p)/S/m)>=1?(this._updateClipDatas(E,f,_,s*v),this._setClipDatasToNode(E,f,1,0===n),o._playType=0,o._currentPlayState=E,_._cloneTo(l)):(this._updateClipDatas(E,f,_,s*S*v),this._setFixedCrossClipDatasToNode(o,E,R,0===n)),this._updateEventScript(E,_))}}i&&this._avatar&&(t.Render.supportWebGLPlusAnimation&&this._updateAnimationNodeWorldMatix(this._animationNodeLocalPositions,this._animationNodeLocalRotations,this._animationNodeLocalScales,this._animationNodeWorldMatrixs,this._animationNodeParentIndices),this._updateAvatarNodesToSprite())}}_cloneTo(e){var t=e;t.avatar=this.avatar,t.cullingMode=this.cullingMode;for(var r=0,i=this._controllerLayers.length;r=0&&e<=30))throw new Error("Layer value must be 0-30.");this._layer=e}}get url(){return this._url}get isStatic(){return this._isStatic}get transform(){return this._transform}_setCreateURL(e){this._url=t.URL.formatURL(e)}_changeAnimatorsToLinkSprite3D(e,t,r){var i=this.getComponent(w);if(i&&(i.avatar||e._changeAnimatorToLinkSprite3DNoAvatar(i,t,r)),this._parent&&this._parent instanceof b){r.unshift(this._parent.name);var n=this._parent;n._hierarchyAnimator&&n._changeAnimatorsToLinkSprite3D(e,t,r)}}_setHierarchyAnimator(e,t){this._changeHierarchyAnimator(e),this._changeAnimatorAvatar(e.avatar);for(var r=0,i=this._children.length;r0){for(var i=0;i0;)r--;if(t1){var i=this._partition(e,t,r),n=i-1;t0&&_._quickSort(0,E-1),(E=h.elements.length)>0&&h._quickSort(0,E-1)}static renderObjectCullingNative(e,r,i,n,s,o){var _,h=r._opaqueQueue,c=r._transparentQueue;h.clear(),c.clear();var d=B._managers;for(m=0,_=d.length;m<_;m++)d[m]._clear();var u=l._managers;for(m=0,_=u.length;m<_;m++)u[m]._clear();var f=n.length,E=n.elements;for(m=0;m0&&h._quickSort(0,R-1),(R=c.elements.length)>0&&c._quickSort(0,R-1)}static cullingNative(e,r,i,n,a){return t.LayaGL.instance.culling(e,r,i,n,a)}}U._tempVector3=new a,U._tempColor0=new I,U.debugFrustumCulling=!1;class G{constructor(e,t=0){this.normal=e,this.distance=t}static createPlaneBy3P(e,t,r){var i=t.x-e.x,n=t.y-e.y,a=t.z-e.z,s=r.x-e.x,o=r.y-e.y,l=r.z-e.z,_=n*l-a*o,h=a*s-i*l,c=i*o-n*s,d=1/Math.sqrt(_*_+h*h+c*c),u=_*d,f=h*d,E=c*d;G._TEMPVec3.x=u,G._TEMPVec3.y=f,G._TEMPVec3.z=E;var T=-(u*e.x+f*e.y+E*e.z);return new G(G._TEMPVec3,T)}normalize(){var e=this.normal.x,t=this.normal.y,r=this.normal.z,i=1/Math.sqrt(e*e+t*t+r*r);this.normal.x=e*i,this.normal.y=t*i,this.normal.z=r*i,this.distance*=i}}G._TEMPVec3=new a,G.PlaneIntersectionType_Back=0,G.PlaneIntersectionType_Front=1,G.PlaneIntersectionType_Intersecting=2;class z{constructor(e,t){this.origin=e,this.direction=t}}class H{}H.Disjoint=0,H.Contains=1,H.Intersects=2;class W{constructor(){}static distancePlaneToPoint(e,t){return a.dot(e.normal,t)-e.distance}static distanceBoxToPoint(e,t){var r=e.min,i=r.x,n=r.y,a=r.z,s=e.max,o=s.x,l=s.y,_=s.z,h=t.x,c=t.y,d=t.z,u=0;return ho&&(u+=(o-h)*(o-h)),cl&&(u+=(l-c)*(l-c)),d_&&(u+=(_-d)*(_-d)),Math.sqrt(u)}static distanceBoxToBox(e,t){var r,i=e.min,n=i.x,a=i.y,s=i.z,o=e.max,l=o.x,_=o.y,h=o.z,c=t.min,d=c.x,u=c.y,f=c.z,E=t.max,T=E.x,m=E.y,p=E.z,g=0;return n>T?g+=(r=n-T)*r:d>l&&(g+=(r=d-l)*r),a>m?g+=(r=a-m)*r:u>_&&(g+=(r=u-_)*r),s>p?g+=(r=s-p)*r:f>h&&(g+=(r=f-h)*r),Math.sqrt(g)}static distanceSphereToPoint(e,t){var r=Math.sqrt(a.distanceSquared(e.center,t));return r-=e.radius,Math.max(r,0)}static distanceSphereToSphere(e,t){var r=Math.sqrt(a.distanceSquared(e.center,t.center));return r-=e.radius+t.radius,Math.max(r,0)}static intersectsRayAndTriangleRD(e,t,i,n,a){var s=e.origin,o=s.x,l=s.y,_=s.z,h=e.direction,c=h.x,d=h.y,u=h.z,f=t.x,E=t.y,T=t.z,m=i.x,p=i.y,g=i.z,S=n.x,v=n.y,R=n.z,A=W._tempV30.x,D=W._tempV30.y,I=W._tempV30.z;A=m-f,D=p-E,I=g-T;var x=W._tempV31.x,M=W._tempV31.y,L=W._tempV31.z;x=S-f,M=v-E,L=R-T;var C=W._tempV32.x,y=W._tempV32.y,O=W._tempV32.z,N=A*(C=d*L-u*M)+D*(y=u*x-c*L)+I*(O=c*M-d*x);if(r.isZero(N))return!1;var P=1/N,w=W._tempV33.x,V=W._tempV33.y,b=W._tempV33.z,F=(w=o-f)*C+(V=l-E)*y+(b=_-T)*O;if((F*=P)<0||F>1)return!1;var B=W._tempV34.x,U=W._tempV34.y,G=W._tempV34.z,z=c*(B=V*I-b*D)+d*(U=b*A-w*I)+u*(G=w*D-V*A);if((z*=P)<0||F+z>1)return!1;var H=x*B+M*U+L*G;return!((H*=P)<0)}static intersectsRayAndTriangleRP(e,t,r,i,n){return W.intersectsRayAndTriangleRD(e,t,r,i,void 0)?(a.scale(e.direction,void 0,W._tempV30),a.add(e.origin,W._tempV30,n),!0):(n=a._ZERO,!1)}static intersectsRayAndPoint(e,t){a.subtract(e.origin,t,W._tempV30);var i=a.dot(W._tempV30,e.direction),n=a.dot(W._tempV30,W._tempV30)-r.zeroTolerance;return!(n>0&&i>0)&&!(i*i-n<0)}static intersectsRayAndRay(e,t,i){var n=e.origin,s=n.x,o=n.y,l=n.z,_=e.direction,h=_.x,c=_.y,d=_.z,u=t.origin,f=u.x,E=u.y,T=u.z,m=t.direction,p=m.x,g=m.y,S=m.z;a.cross(_,m,W._tempV30);var v=W._tempV30,R=a.scalarLength(W._tempV30);if(r.isZero(R)&&r.nearEqual(f,s)&&r.nearEqual(E,o)&&r.nearEqual(T,l))return!0;R*=R;var A=f-s,D=E-o,I=T-l,x=p,M=g,L=S,C=v.x,y=v.y,O=v.z,N=A*M*O+D*L*C+I*x*y-A*L*y-D*x*O-I*M*C;x=h,M=c,L=d;var P=N/R;a.scale(_,P,W._tempV30),a.scale(m,P,W._tempV31),a.add(n,W._tempV30,W._tempV32),a.add(u,W._tempV31,W._tempV33);var w=W._tempV32,V=W._tempV33;return!!(r.nearEqual(V.x,w.x)&&r.nearEqual(V.y,w.y)&&r.nearEqual(V.z,w.z))}static intersectsPlaneAndTriangle(e,t,r,i){var n=W.intersectsPlaneAndPoint(e,t),a=W.intersectsPlaneAndPoint(e,r),s=W.intersectsPlaneAndPoint(e,i);return n==G.PlaneIntersectionType_Front&&a==G.PlaneIntersectionType_Front&&s==G.PlaneIntersectionType_Front?G.PlaneIntersectionType_Front:n==G.PlaneIntersectionType_Back&&a==G.PlaneIntersectionType_Back&&s==G.PlaneIntersectionType_Back?G.PlaneIntersectionType_Back:G.PlaneIntersectionType_Intersecting}static intersectsRayAndPlaneRD(e,t,i){var n=t.normal,s=a.dot(n,e.direction);if(r.isZero(s))return 0,!1;var o=a.dot(n,e.origin);return!((-t.distance-o)/s<0)||(0,!1)}static intersectsRayAndPlaneRP(e,t,r){return!!W.intersectsRayAndPlaneRD(e,t,void 0)&&(a.scale(e.direction,void 0,W._tempV30),a.add(e.origin,W._tempV30,W._tempV31),!0)}static intersectsRayAndBoxRD(e,t){var i=e.origin,n=i.x,a=i.y,s=i.z,o=e.direction,l=o.x,_=o.y,h=o.z,c=t.min,d=c.x,u=c.y,f=c.z,E=t.max,T=E.x,m=E.y,p=E.z,g=0,S=r.MaxValue;if(r.isZero(l)){if(nT)return-1}else{var v=1/l,R=(d-n)*v,A=(T-n)*v;if(R>A){var D=R;R=A,A=D}if((g=Math.max(R,g))>(S=Math.min(A,S)))return-1}if(r.isZero(_)){if(am)return-1}else{var I=1/_,x=(u-a)*I,M=(m-a)*I;if(x>M){var L=x;x=M,M=L}if((g=Math.max(x,g))>(S=Math.min(M,S)))return-1}if(r.isZero(h)){if(sp)return-1}else{var C=1/h,y=(f-s)*C,O=(p-s)*C;if(y>O){var N=y;y=O,O=N}if((g=Math.max(y,g))>(S=Math.min(O,S)))return-1}return g}static intersectsRayAndBoxRP(e,t,r){var i=W.intersectsRayAndBoxRD(e,t);return-1===i?(a._ZERO.cloneTo(r),i):(a.scale(e.direction,i,W._tempV30),a.add(e.origin,W._tempV30,W._tempV31),W._tempV31.cloneTo(r),i)}static intersectsRayAndSphereRD(e,t){var r=t.radius;a.subtract(e.origin,t.center,W._tempV30);var i=a.dot(W._tempV30,e.direction),n=a.dot(W._tempV30,W._tempV30)-r*r;if(n>0&&i>0)return-1;var s=i*i-n;if(s<0)return-1;var o=-i-Math.sqrt(s);return o<0&&(o=0),o}static intersectsRayAndSphereRP(e,t,r){var i=W.intersectsRayAndSphereRD(e,t);return-1===i?(a._ZERO.cloneTo(r),i):(a.scale(e.direction,i,W._tempV30),a.add(e.origin,W._tempV30,W._tempV31),W._tempV31.cloneTo(r),i)}static intersectsSphereAndTriangle(e,t,r,i){var n=e.center,s=e.radius;return W.closestPointPointTriangle(n,t,r,i,W._tempV30),a.subtract(W._tempV30,n,W._tempV31),a.dot(W._tempV31,W._tempV31)<=s*s}static intersectsPlaneAndPoint(e,t){var r=a.dot(e.normal,t)+e.distance;return r>0?G.PlaneIntersectionType_Front:r<0?G.PlaneIntersectionType_Back:G.PlaneIntersectionType_Intersecting}static intersectsPlaneAndPlane(e,t){a.cross(e.normal,t.normal,W._tempV30);var i=a.dot(W._tempV30,W._tempV30);return!r.isZero(i)}static intersectsPlaneAndPlaneRL(e,t,i){var n=e.normal,s=t.normal;a.cross(n,s,W._tempV34);var o=a.dot(W._tempV34,W._tempV34);return!r.isZero(o)&&(a.scale(s,e.distance,W._tempV30),a.scale(n,t.distance,W._tempV31),a.subtract(W._tempV30,W._tempV31,W._tempV32),a.cross(W._tempV32,W._tempV34,W._tempV33),a.normalize(W._tempV34,W._tempV34),!0)}static intersectsPlaneAndBox(e,t){var r=e.distance,i=e.normal,n=i.x,s=i.y,o=i.z,l=t.min,_=l.x,h=l.y,c=l.z,d=t.max,u=d.x,f=d.y,E=d.z;W._tempV30.x=n>0?_:u,W._tempV30.y=s>0?h:f,W._tempV30.z=o>0?c:E,W._tempV31.x=n>0?u:_,W._tempV31.y=s>0?f:h,W._tempV31.z=o>0?E:c;var T=a.dot(i,W._tempV30);return T+r>0?G.PlaneIntersectionType_Front:(T=a.dot(i,W._tempV31))+r<0?G.PlaneIntersectionType_Back:G.PlaneIntersectionType_Intersecting}static intersectsPlaneAndSphere(e,t){var r=t.radius,i=a.dot(e.normal,t.center)+e.distance;return i>r?G.PlaneIntersectionType_Front:i<-r?G.PlaneIntersectionType_Back:G.PlaneIntersectionType_Intersecting}static intersectsBoxAndBox(e,t){var r=e.min,i=e.max,n=t.min,a=t.max;return!(r.x>a.x||n.x>i.x)&&(!(r.y>a.y||n.y>i.y)&&!(r.z>a.z||n.z>i.z))}static intersectsBoxAndSphere(e,t){var r=t.center,i=t.radius;return a.Clamp(r,e.min,e.max,W._tempV30),a.distanceSquared(r,W._tempV30)<=i*i}static intersectsSphereAndSphere(e,t){var r=e.radius+t.radius;return a.distanceSquared(e.center,t.center)<=r*r}static boxContainsPoint(e,t){var r=e.min,i=e.max;return r.x<=t.x&&i.x>=t.x&&r.y<=t.y&&i.y>=t.y&&r.z<=t.z&&i.z>=t.z?H.Contains:H.Disjoint}static boxContainsBox(e,t){var r=e.min,i=r.x,n=r.y,a=r.z,s=e.max,o=s.x,l=s.y,_=s.z,h=t.min,c=h.x,d=h.y,u=h.z,f=t.max,E=f.x,T=f.y,m=f.z;return oE?H.Disjoint:lT?H.Disjoint:_m?H.Disjoint:i<=c&&E<=o&&n<=d&&T<=l&&a<=u&&m<=_?H.Contains:H.Intersects}static boxContainsSphere(e,t){var r=e.min,i=r.x,n=r.y,s=r.z,o=e.max,l=o.x,_=o.y,h=o.z,c=t.center,d=c.x,u=c.y,f=c.z,E=t.radius;return a.Clamp(c,r,o,W._tempV30),a.distanceSquared(c,W._tempV30)>E*E?H.Disjoint:i+E<=d&&d<=l-E&&l-i>E&&n+E<=u&&u<=_-E&&_-n>E&&s+E<=f&&f<=h-E&&h-s>E?H.Contains:H.Intersects}static sphereContainsPoint(e,t){return a.distanceSquared(t,e.center)<=e.radius*e.radius?H.Contains:H.Disjoint}static sphereContainsTriangle(e,t,r,i){var n=W.sphereContainsPoint(e,t),a=W.sphereContainsPoint(e,r),s=W.sphereContainsPoint(e,i);return n==H.Contains&&a==H.Contains&&s==H.Contains?H.Contains:W.intersectsSphereAndTriangle(e,t,r,i)?H.Intersects:H.Disjoint}static sphereContainsBox(e,t){var r=e.center,i=r.x,n=r.y,s=r.z,o=e.radius,l=t.min,_=l.x,h=l.y,c=l.z,d=t.max,u=d.x,f=d.y,E=d.z,T=W._tempV30;T.x,T.y,T.z;if(!W.intersectsBoxAndSphere(t,e))return H.Disjoint;var m=o*o;return i-_,n-f,s-E,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:(i-u,n-f,s-E,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:(i-u,n-h,s-E,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:(i-_,n-h,s-E,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:(i-_,n-f,s-c,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:(i-u,n-f,s-c,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:(i-u,n-h,s-c,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:(i-_,n-h,s-c,a.scalarLengthSquared(W._tempV30)>m?H.Intersects:H.Contains)))))))}static sphereContainsSphere(e,t){var r=e.radius,i=t.radius,n=a.distance(e.center,t.center);return r+i=0&&_<=l)r.cloneTo(n);else{var d=s*_-l*o;if(d<=0&&s>=0&&l<=0){var u=s/(s-l);return a.scale(W._tempV30,u,n),void a.add(t,n,n)}if(c>=0&&h<=c)i.cloneTo(n);else{var f=h*o-s*c;if(f<=0&&o>=0&&c<=0){var E=o/(o-c);return a.scale(W._tempV31,E,n),void a.add(t,n,n)}var T=l*c-h*_;if(T<=0&&_-l>=0&&h-c>=0){var m=(_-l)/(_-l+(h-c));return a.subtract(i,r,n),a.scale(n,m,n),void a.add(r,n,n)}var p=1/(T+f+d),g=f*p,S=d*p;a.scale(W._tempV30,g,W._tempV35),a.scale(W._tempV31,S,W._tempV36),a.add(W._tempV35,W._tempV36,n),a.add(t,n,n)}}}static closestPointPlanePoint(e,t,r){var i=e.normal,n=a.dot(i,t)-e.distance;a.scale(i,n,W._tempV30),a.subtract(t,W._tempV30,r)}static closestPointBoxPoint(e,t,r){a.max(t,e.min,W._tempV30),a.min(W._tempV30,e.max,r)}static closestPointSpherePoint(e,t,r){var i=e.center;a.subtract(t,i,r),a.normalize(r,r),a.scale(r,e.radius,r),a.add(r,i,r)}static closestPointSphereSphere(e,t,r){var i=e.center;a.subtract(t.center,i,r),a.normalize(r,r),a.scale(r,e.radius,r),a.add(r,i,r)}}W._tempV30=new a,W._tempV31=new a,W._tempV32=new a,W._tempV33=new a,W._tempV34=new a,W._tempV35=new a,W._tempV36=new a;class k{constructor(e){this._matrix=e,this._near=new G(new a),this._far=new G(new a),this._left=new G(new a),this._right=new G(new a),this._top=new G(new a),this._bottom=new G(new a),k._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get matrix(){return this._matrix}set matrix(e){this._matrix=e,k._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get near(){return this._near}get far(){return this._far}get left(){return this._left}get right(){return this._right}get top(){return this._top}get bottom(){return this._bottom}equalsBoundFrustum(e){return this._matrix.equalsOtherMatrix(e.matrix)}equalsObj(e){if(e instanceof k){var t=e;return this.equalsBoundFrustum(t)}return!1}getPlane(e){switch(e){case 0:return this._near;case 1:return this._far;case 2:return this._left;case 3:return this._right;case 4:return this._top;case 5:return this._bottom;default:return null}}static _getPlanesFromMatrix(e,t,r,i,n,a,s){var o=e.elements,l=o[0],_=o[1],h=o[2],c=o[3],d=o[4],u=o[5],f=o[6],E=o[7],T=o[8],m=o[9],p=o[10],g=o[11],S=o[12],v=o[13],R=o[14],A=o[15],D=t.normal;D.x=c+h,D.y=E+f,D.z=g+p,t.distance=A+R,t.normalize();var I=r.normal;I.x=c-h,I.y=E-f,I.z=g-p,r.distance=A-R,r.normalize();var x=i.normal;x.x=c+l,x.y=E+d,x.z=g+T,i.distance=A+S,i.normalize();var M=n.normal;M.x=c-l,M.y=E-d,M.z=g-T,n.distance=A-S,n.normalize();var L=a.normal;L.x=c-_,L.y=E-u,L.z=g-m,a.distance=A-v,a.normalize();var C=s.normal;C.x=c+_,C.y=E+u,C.z=g+m,s.distance=A+v,s.normalize()}static _get3PlaneInterPoint(e,t,r){var i=e.normal,n=t.normal,s=r.normal;a.cross(n,s,k._tempV30),a.cross(s,i,k._tempV31),a.cross(i,n,k._tempV32);var o=a.dot(i,k._tempV30),l=a.dot(n,k._tempV31),_=a.dot(s,k._tempV32);return a.scale(k._tempV30,-e.distance/o,k._tempV33),a.scale(k._tempV31,-t.distance/l,k._tempV34),a.scale(k._tempV32,-r.distance/_,k._tempV35),a.add(k._tempV33,k._tempV34,k._tempV36),a.add(k._tempV35,k._tempV36,k._tempV37),k._tempV37}getCorners(e){k._get3PlaneInterPoint(this._near,this._bottom,this._right).cloneTo(e[0]),k._get3PlaneInterPoint(this._near,this._top,this._right).cloneTo(e[1]),k._get3PlaneInterPoint(this._near,this._top,this._left).cloneTo(e[2]),k._get3PlaneInterPoint(this._near,this._bottom,this._left).cloneTo(e[3]),k._get3PlaneInterPoint(this._far,this._bottom,this._right).cloneTo(e[4]),k._get3PlaneInterPoint(this._far,this._top,this._right).cloneTo(e[5]),k._get3PlaneInterPoint(this._far,this._top,this._left).cloneTo(e[6]),k._get3PlaneInterPoint(this._far,this._bottom,this._left).cloneTo(e[7])}containsPoint(e){for(var t=G.PlaneIntersectionType_Front,r=G.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=W.intersectsPlaneAndPoint(this._near,e);break;case 1:r=W.intersectsPlaneAndPoint(this._far,e);break;case 2:r=W.intersectsPlaneAndPoint(this._left,e);break;case 3:r=W.intersectsPlaneAndPoint(this._right,e);break;case 4:r=W.intersectsPlaneAndPoint(this._top,e);break;case 5:r=W.intersectsPlaneAndPoint(this._bottom,e)}switch(r){case G.PlaneIntersectionType_Back:return H.Disjoint;case G.PlaneIntersectionType_Intersecting:t=G.PlaneIntersectionType_Intersecting}}switch(t){case G.PlaneIntersectionType_Intersecting:return H.Intersects;default:return H.Contains}}intersects(e){var t=e.min,r=e.max,i=t.x,n=t.y,a=t.z,s=r.x,o=r.y,l=r.z,_=this._near.normal;if(this._near.distance+_.x*(_.x<0?i:s)+_.y*(_.y<0?n:o)+_.z*(_.z<0?a:l)<0)return!1;var h=this._left.normal;if(this._left.distance+h.x*(h.x<0?i:s)+h.y*(h.y<0?n:o)+h.z*(h.z<0?a:l)<0)return!1;var c=this._right.normal;if(this._right.distance+c.x*(c.x<0?i:s)+c.y*(c.y<0?n:o)+c.z*(c.z<0?a:l)<0)return!1;var d=this._bottom.normal;if(this._bottom.distance+d.x*(d.x<0?i:s)+d.y*(d.y<0?n:o)+d.z*(d.z<0?a:l)<0)return!1;var u=this._top.normal;if(this._top.distance+u.x*(u.x<0?i:s)+u.y*(u.y<0?n:o)+u.z*(u.z<0?a:l)<0)return!1;var f=this._far.normal;return!(this._far.distance+f.x*(f.x<0?i:s)+f.y*(f.y<0?n:o)+f.z*(f.z<0?a:l)<0)}containsBoundBox(e){for(var t=k._tempV30,r=k._tempV31,i=e.min,n=e.max,a=H.Contains,s=0;s<6;s++){var o=this.getPlane(s),l=o.normal;if(l.x>=0?(t.x=n.x,r.x=i.x):(t.x=i.x,r.x=n.x),l.y>=0?(t.y=n.y,r.y=i.y):(t.y=i.y,r.y=n.y),l.z>=0?(t.z=n.z,r.z=i.z):(t.z=i.z,r.z=n.z),W.intersectsPlaneAndPoint(o,t)===G.PlaneIntersectionType_Back)return H.Disjoint;W.intersectsPlaneAndPoint(o,r)===G.PlaneIntersectionType_Back&&(a=H.Intersects)}return a}containsBoundSphere(e){for(var t=G.PlaneIntersectionType_Front,r=G.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:r=W.intersectsPlaneAndSphere(this._near,e);break;case 1:r=W.intersectsPlaneAndSphere(this._far,e);break;case 2:r=W.intersectsPlaneAndSphere(this._left,e);break;case 3:r=W.intersectsPlaneAndSphere(this._right,e);break;case 4:r=W.intersectsPlaneAndSphere(this._top,e);break;case 5:r=W.intersectsPlaneAndSphere(this._bottom,e)}switch(r){case G.PlaneIntersectionType_Back:return H.Disjoint;case G.PlaneIntersectionType_Intersecting:t=G.PlaneIntersectionType_Intersecting}}switch(t){case G.PlaneIntersectionType_Intersecting:return H.Intersects;default:return H.Contains}}}k._tempV30=new a,k._tempV31=new a,k._tempV32=new a,k._tempV33=new a,k._tempV34=new a,k._tempV35=new a,k._tempV36=new a,k._tempV37=new a;class X{constructor(e,t,r,i){this.minDepth=0,this.maxDepth=1,this.x=e,this.y=t,this.width=r,this.height=i}project(e,t,r){a.transformV3ToV3(e,t,r);var i=t.elements,n=e.x*i[3]+e.y*i[7]+e.z*i[11]+i[15];1!==n&&(r.x=r.x/n,r.y=r.y/n,r.z=r.z/n),r.x=.5*(r.x+1)*this.width+this.x,r.y=.5*(1-r.y)*this.height+this.y,r.z=r.z*(this.maxDepth-this.minDepth)+this.minDepth}unprojectFromMat(e,t,r){var i=t.elements;r.x=(e.x-this.x)/this.width*2-1,r.y=-((e.y-this.y)/this.height*2-1);var n=(this.maxDepth-this.minDepth)/2;r.z=(e.z-this.minDepth-n)/n;var s=r.x*i[3]+r.y*i[7]+r.z*i[11]+i[15];a.transformV3ToV3(r,t,r),1!==s&&(r.x=r.x/s,r.y=r.y/s,r.z=r.z/s)}unprojectFromWVP(e,t,r,i,n){T.multiply(t,r,X._tempMatrix4x4),i&&T.multiply(X._tempMatrix4x4,i,X._tempMatrix4x4),X._tempMatrix4x4.invert(X._tempMatrix4x4),this.unprojectFromMat(e,X._tempMatrix4x4,n)}cloneTo(e){e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e.minDepth=this.minDepth,e.maxDepth=this.maxDepth}}X._tempMatrix4x4=new T;class Y extends t.BaseTexture{constructor(e,r,i=t.BaseTexture.FORMAT_R8G8B8,n=t.BaseTexture.FORMAT_DEPTH_16){super(i,!1),this._inPool=!1,this._glTextureType=t.LayaGL.instance.TEXTURE_2D,this._width=e,this._height=r,this._depthStencilFormat=n,this._create(e,r)}static get currentActive(){return Y._currentActive}static createFromPool(e,r,i=t.BaseTexture.FORMAT_R8G8B8,n=t.BaseTexture.FORMAT_DEPTH_16,a=t.BaseTexture.FILTERMODE_BILINEAR){for(var s,o=0,l=Y._pool.length;o-Number.MIN_VALUE&&o1)return Number.NaN;var d,u,f=Z._tempVector34;return a.cross(c,n,f),d=a.dot(e.direction,f),(d*=h)<0||_+d>1?Number.NaN:(u=a.dot(s,f),(u*=h)<0?Number.NaN:u)}}Z._tempVector30=new a,Z._tempVector31=new a,Z._tempVector32=new a,Z._tempVector33=new a,Z._tempVector34=new a;class j{constructor(){}_render(e){}}class q extends j{static __init__(){q.instance=new q}constructor(){super();var e=t.LayaGL.instance,r=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]),i=new Uint8Array([0,1,2,2,3,0,4,7,6,6,5,4,0,3,7,7,4,0,1,5,6,6,2,1,3,2,6,6,7,3,0,4,5,5,1,0]),n=v.getVertexDeclaration("POSITION");this._vertexBuffer=new d(8*n.vertexStride,e.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=n,this._indexBuffer=new c(c.INDEXTYPE_UBYTE,36,e.STATIC_DRAW,!1),this._vertexBuffer.setData(r.buffer),this._indexBuffer.setData(i);var a=new _;a.bind(),a.applyVertexBuffer(this._vertexBuffer),a.applyIndexBuffer(this._indexBuffer),a.unBind(),this._bufferState=a}_render(e){var r=t.LayaGL.instance;r.drawElements(r.TRIANGLES,36,r.UNSIGNED_BYTE,0),t.Stat.trianglesFaces+=12,t.Stat.renderBatches++}}class K{constructor(){this._mesh=q.instance}get material(){return this._material}set material(e){this._material!==e&&(this._material&&this._material._removeReference(),e&&e._addReference(),this._material=e)}get mesh(){return this._mesh}set mesh(e){this._mesh!==e&&(this._mesh=e)}_isAvailable(){return!(!this._material||!this._mesh)}_render(e){if(this._material&&this._mesh){var r=t.LayaGL.instance,i=e.scene,n=e.camera,a=p._SET_RUNTIME_VALUE_MODE_REFERENCE_;t.ILaya.Render.supportWebGLPlusRendering&&p.setRuntimeValueMode(!1),t.WebGLContext.setCullFace(r,!1),t.WebGLContext.setDepthFunc(r,r.LEQUAL),t.WebGLContext.setDepthMask(r,!1);var s=e.shader=this._material._shader.getSubShaderAt(0)._passes[0].withCompile(0,0,this._material._shaderValues._defineDatas.value),o=s.bind(),l=t.Stat.loopCount!==s._uploadMark,_=s._uploadScene!==i||l;(_||o)&&(s.uploadUniforms(s._sceneUniformParamsMap,i._shaderValues,_),s._uploadScene=i);var h=n._renderTexture||n._offScreenRenderTexture,c=s._uploadCamera!==n||l;if(c||o){var d=K._tempMatrix0,u=n.projectionMatrix;n.transform.worldMatrix.cloneTo(d),d.transpose(),n.orthographic&&(u=K._tempMatrix1,T.createPerspective(n.fieldOfView,n.aspectRatio,n.nearPlane,n.farPlane,u)),n._applyViewProject(e,d,u,!!h),s.uploadUniforms(s._cameraUniformParamsMap,n._shaderValues,c),s._uploadCamera=n}var f=s._uploadMaterial!==this._material||l;(f||o)&&(s.uploadUniforms(s._materialUniformParamsMap,this._material._shaderValues,f),s._uploadMaterial=this._material),this._mesh._bufferState.bind(),this._mesh._render(e),t.ILaya.Render.supportWebGLPlusRendering&&p.setRuntimeValueMode(a),t.WebGLContext.setDepthFunc(r,r.LESS),t.WebGLContext.setDepthMask(r,!0),n._applyViewProject(e,n.viewMatrix,n.projectionMatrix,!!h)}}destroy(){this._material&&(this._material._removeReference(),this._material=null)}}K._tempMatrix0=new T,K._tempMatrix1=new T;class Q extends b{constructor(e=.3,t=1e3){super(),this._skyRenderer=new K,this._forward=new a,this._up=new a,this.clearColor=new n(100/255,149/255,237/255,1),this._shaderValues=new p(null),this._fieldOfView=60,this._useUserProjectionMatrix=!1,this._orthographic=!1,this._orthographicVerticalSize=10,this.renderingOrder=0,this._nearPlane=e,this._farPlane=t,this.cullingMask=2147483647,this.clearFlag=Q.CLEARFLAG_SOLIDCOLOR,this.useOcclusionCulling=!0}get skyRenderer(){return this._skyRenderer}get fieldOfView(){return this._fieldOfView}set fieldOfView(e){this._fieldOfView=e,this._calculateProjectionMatrix()}get nearPlane(){return this._nearPlane}set nearPlane(e){this._nearPlane=e,this._calculateProjectionMatrix()}get farPlane(){return this._farPlane}set farPlane(e){this._farPlane=e,this._calculateProjectionMatrix()}get orthographic(){return this._orthographic}set orthographic(e){this._orthographic=e,this._calculateProjectionMatrix()}get orthographicVerticalSize(){return this._orthographicVerticalSize}set orthographicVerticalSize(e){this._orthographicVerticalSize=e,this._calculateProjectionMatrix()}get renderingOrder(){return this._renderingOrder}set renderingOrder(e){this._renderingOrder=e,this._sortCamerasByRenderingOrder()}_sortCamerasByRenderingOrder(){if(this.displayedInStage)for(var e=this.scene._cameraPool,t=e.length-1,r=0;re[t].renderingOrder){var i=e[r];e[r]=e[t],e[t]=i}}_calculateProjectionMatrix(){}_onScreenSizeChanged(){this._calculateProjectionMatrix()}_prepareCameraToRender(){var e=this._shaderValues;this.transform.getForward(this._forward),this.transform.getUp(this._up),e.setVector3(Q.CAMERAPOS,this.transform.position),e.setVector3(Q.CAMERADIRECTION,this._forward),e.setVector3(Q.CAMERAUP,this._up)}render(e=null,t=null){}addLayer(e){this.cullingMask|=Math.pow(2,e)}removeLayer(e){this.cullingMask&=~Math.pow(2,e)}addAllLayers(){this.cullingMask=2147483647}removeAllLayers(){this.cullingMask=0}resetProjectionMatrix(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()}_onActive(){this._scene._addCamera(this),super._onActive()}_onInActive(){this._scene._removeCamera(this),super._onInActive()}_parse(e,r){super._parse(e,r);var i=e.clearFlag;void 0!==i&&(this.clearFlag=i),this.orthographic=e.orthographic,void 0!==e.orthographicVerticalSize&&(this.orthographicVerticalSize=e.orthographicVerticalSize),void 0!==e.fieldOfView&&(this.fieldOfView=e.fieldOfView),this.nearPlane=e.nearPlane,this.farPlane=e.farPlane;var a=e.clearColor;this.clearColor=new n(a[0],a[1],a[2],a[3]);var s=e.skyboxMaterial;s&&(this._skyRenderer.material=t.Loader.getRes(s.path))}destroy(e=!0){this._skyRenderer.destroy(),this._skyRenderer=null,t.Laya.stage.off(t.Event.RESIZE,this,this._onScreenSizeChanged),super.destroy(e)}_create(){return new Q}}Q._tempMatrix4x40=new T,Q.CAMERAPOS=L.propertyNameToID("u_CameraPos"),Q.VIEWMATRIX=L.propertyNameToID("u_View"),Q.PROJECTMATRIX=L.propertyNameToID("u_Projection"),Q.VIEWPROJECTMATRIX=L.propertyNameToID("u_ViewProjection"),Q.CAMERADIRECTION=L.propertyNameToID("u_CameraDirection"),Q.CAMERAUP=L.propertyNameToID("u_CameraUp"),Q.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",Q.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",Q.CLEARFLAG_SOLIDCOLOR=0,Q.CLEARFLAG_SKY=1,Q.CLEARFLAG_DEPTHONLY=2,Q.CLEARFLAG_NONE=3,Q._invertYScaleMatrix=new T(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1),Q._invertYProjectionMatrix=new T,Q._invertYProjectionViewMatrix=new T;class J{constructor(){}}J._instance=new J;class $ extends t.Resource{constructor(){super(),this._bufferState=new _,this._bufferStateInvertUV=new _;var e=t.LayaGL.instance;this._vertexBuffer=new d(64,e.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=$._vertexDeclaration,this._vertexBuffer.setData($._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new d(64,e.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=$._vertexDeclaration,this._vertexBufferInvertUV.setData($._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){$._vertexDeclaration=new g(16,[new S(0,u.Vector4,$.SCREENQUAD_POSITION_UV)]),$.instance=new $,$.instance.lock=!0}render(){var e=t.LayaGL.instance;this._bufferState.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4),t.Stat.renderBatches++}renderInvertUV(){var e=t.LayaGL.instance;this._bufferStateInvertUV.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4),t.Stat.renderBatches++}destroy(){super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferStateInvertUV.destroy(),this._vertexBufferInvertUV.destroy(),this._setGPUMemory(0)}}$.SCREENQUAD_POSITION_UV=0,$._vertices=new Float32Array([1,1,1,0,1,-1,1,1,-1,1,0,0,-1,-1,0,1]),$._verticesInvertUV=new Float32Array([1,1,1,1,1,-1,1,0,-1,1,0,1,-1,-1,0,0]);class ee extends t.Resource{constructor(){super(),this._bufferState=new _,this._bufferStateInvertUV=new _;var e=t.LayaGL.instance;this._vertexBuffer=new d(48,e.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=ee._vertexDeclaration,this._vertexBuffer.setData(ee._vertices.buffer),this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind(),this._vertexBufferInvertUV=new d(48,e.STATIC_DRAW,!1),this._vertexBufferInvertUV.vertexDeclaration=ee._vertexDeclaration,this._vertexBufferInvertUV.setData(ee._verticesInvertUV.buffer),this._bufferStateInvertUV.bind(),this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV),this._bufferStateInvertUV.unBind(),this._setGPUMemory(this._vertexBuffer._byteLength+this._vertexBufferInvertUV._byteLength)}static __init__(){ee._vertexDeclaration=new g(16,[new S(0,u.Vector4,ee.SCREENTRIANGLE_POSITION_UV)]),ee.instance=new ee,ee.instance.lock=!0}render(){var e=t.LayaGL.instance;this._bufferState.bind(),e.drawArrays(e.TRIANGLES,0,3),t.Stat.renderBatches++}renderInvertUV(){var e=t.LayaGL.instance;this._bufferStateInvertUV.bind(),e.drawArrays(e.TRIANGLES,0,3),t.Stat.renderBatches++}destroy(){super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferStateInvertUV.destroy(),this._vertexBufferInvertUV.destroy(),this._setGPUMemory(0)}}ee.SCREENTRIANGLE_POSITION_UV=0,ee._vertices=new Float32Array([-1,-1,0,1,-1,3,0,-1,3,-1,2,1]),ee._verticesInvertUV=new Float32Array([-1,-1,0,0,-1,3,0,2,3,-1,2,0]);class te{constructor(){this._commandBuffer=null}static __init__(){te._screenShaderData=new p,te._screenShader=L.find("BlitScreen")}run(){}recover(){this._commandBuffer=null}}te.SCREENTEXTURE_NAME="u_MainTex",te.MAINTEXTURE_TEXELSIZE_NAME="u_MainTex_TexelSize",te.SCREENTEXTURE_ID=L.propertyNameToID(te.SCREENTEXTURE_NAME),te.MAINTEXTURE_TEXELSIZE_ID=L.propertyNameToID(te.MAINTEXTURE_TEXELSIZE_NAME);class re extends te{constructor(){super(...arguments),this._source=null,this._dest=null,this._shader=null,this._shaderData=null,this._subShader=0,this._sourceTexelSize=new n,this._screenType=0}static create(e,t,r=null,i=null,n=0,a=re._SCREENTYPE_QUAD){var s;return(s=re._pool.length>0?re._pool.pop():new re)._source=e,s._dest=t,s._shader=r,s._shaderData=i,s._subShader=n,s._screenType=a,s}run(){var e=this._shader||te._screenShader,r=this._shaderData||te._screenShaderData,i=this._dest;t.LayaGL.instance.viewport(0,0,i?i.width:J.clientWidth,i?i.height:J.clientHeight),r.setTexture(te.SCREENTEXTURE_ID,this._source),this._sourceTexelSize.setValue(1/this._source.width,1/this._source.height,this._source.width,this._source.height),r.setVector(te.MAINTEXTURE_TEXELSIZE_ID,this._sourceTexelSize),i&&i._start();for(var n=e.getSubShaderAt(this._subShader)._passes,a=0,s=n.length;a0?ie._pool.pop():new ie)._renderTexture=e,t}run(){this._renderTexture._start()}recover(){ie._pool.push(this),this._renderTexture=null}}ie._pool=[];class ne extends te{constructor(){super(...arguments),this._shaderData=null,this._nameID=0,this._texture=null}static create(e,t,r){var i;return(i=ne._pool.length>0?ne._pool.pop():new ne)._shaderData=e,i._nameID=t,i._texture=r,i}run(){this._shaderData.setTexture(this._nameID,this._texture)}recover(){ne._pool.push(this),this._shaderData=null,this._nameID=0,this._texture=null}}ne._pool=[];class ae{constructor(){this._camera=null,this._commands=[]}_apply(){for(var e=0,t=this._commands.length;e=.5?Math.floor(i):o,d=l-n>=.5?Math.floor(n):l,u=a-_>=.5?Math.ceil(a):_,f=s-h>=.5?Math.ceil(s):h;this._viewport.x=c,this._viewport.y=d,this._viewport.width=u-c,this._viewport.height=f-d}_parse(e,t){super._parse(e,t);var r=e.viewport;this.normalizedViewport=new X(r[0],r[1],r[2],r[3]);var i=e.enableHDR;void 0!==i&&(this.enableHDR=i)}_calculateProjectionMatrix(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=this.orthographicVerticalSize*this.aspectRatio*.5,t=.5*this.orthographicVerticalSize;T.createOrthoOffCenter(-e,e,-t,t,this.nearPlane,this.farPlane,this._projectionMatrix)}else T.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix)}_getCanvasHeight(){return this._offScreenRenderTexture?this._offScreenRenderTexture.height:J.clientHeight}_applyPostProcessCommandBuffers(){for(var e=0,t=this._postProcessCommandBuffers.length;e1,n=i?t._indexCount:r._vertexCount;if(n<=o.SubMeshDynamicBatch.maxAllowVertexCount){var a=3*n;this._dynamicVertexBatch=!0,this._dynamicWorldPositions=new Float32Array(a),this._dynamicWorldNormals=new Float32Array(a),this._dynamicVertexCount=n,this._dynamicMultiSubMesh=i}else this._dynamicVertexBatch=!1}this._geometry=e}}addToOpaqueRenderQueue(e,r){var i=this.staticBatch,n=r.elements,a=n.elements;if(i){var s=o.MeshRenderStaticBatchManager.instance,l=s.getBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,i._batchID);if(s._updateCountMark===l.updateMark){var _=l.indexInList;if(l.batched)a[_].staticBatchElementList.add(this);else{var h=a[_],c=h.render,d=s._getBatchRenderElementFromPool();d.renderType=le.RENDERTYPE_STATICBATCH,d.setGeometry(i),d.material=h.material;var u=i.batchOwner,f=u?u._transform:null;d.setTransform(f),d.render=c,d.renderSubShader=h.renderSubShader;var E=d.staticBatchElementList;E.length=0,E.add(h),E.add(this),a[_]=d,l.batched=!0}}else l.updateMark=s._updateCountMark,l.indexInList=n.length,l.batched=!1,n.add(this)}else if(this.renderSubShader._owner._enableInstancing&&t.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0){var T=this._geometry,m=o.MeshRenderDynamicBatchManager.instance,p=m.getInstanceBatchOpaquaMark(this.render.receiveShadow,this.material.id,T._id,this._transform._isFrontFaceInvert);if(m._updateCountMark===p.updateMark){var g=p.indexInList;if(p.batched){var S=a[g].instanceBatchElementList;S.length===D.instance.maxInstanceCount?(p.updateMark=m._updateCountMark,p.indexInList=n.length,p.batched=!1,n.add(this)):S.add(this)}else{var v=a[g],R=v.render,A=m._getBatchRenderElementFromPool();A.renderType=le.RENDERTYPE_INSTANCEBATCH,A.setGeometry(D.instance),A.material=v.material,A.setTransform(null),A.render=R,A.instanceSubMesh=T,A.renderSubShader=v.renderSubShader;var I=A.instanceBatchElementList;I.length=0,I.add(v),I.add(this),a[g]=A,p.batched=!0}}else p.updateMark=m._updateCountMark,p.indexInList=n.length,p.batched=!1,n.add(this)}else if(this._dynamicVertexBatch){var x=this._geometry._vertexBuffer.vertexDeclaration,M=o.MeshRenderDynamicBatchManager.instance,L=M.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,x.id);if(M._updateCountMark===L.updateMark){var C=L.indexInList;if(L.batched)a[C].vertexBatchElementList.add(this);else{var y=a[C],O=y.render,N=M._getBatchRenderElementFromPool();N.renderType=le.RENDERTYPE_VERTEXBATCH,N.setGeometry(o.SubMeshDynamicBatch.instance),N.material=y.material,N.setTransform(null),N.render=O,N.vertexBatchVertexDeclaration=x,N.renderSubShader=y.renderSubShader;var P=N.vertexBatchElementList;P.length=0,P.add(y),P.add(this),a[C]=N,L.batched=!0}}else L.updateMark=M._updateCountMark,L.indexInList=n.length,L.batched=!1,n.add(this)}else n.add(this)}addToTransparentRenderQueue(e,r){var i=this.staticBatch,n=r.elements,a=n.elements;if(i){var s=o.MeshRenderStaticBatchManager.instance,l=r.lastTransparentRenderElement;if(l){var _=l.render;if(l._geometry._getType()!==this._geometry._getType()||l.staticBatch!==i||l.material!==this.material||_.receiveShadow!==this.render.receiveShadow||_.lightmapIndex!==this.render.lightmapIndex)n.add(this),r.lastTransparentBatched=!1;else{if(r.lastTransparentBatched)a[n.length-1].staticBatchElementList.add(this);else{var h=s._getBatchRenderElementFromPool();h.renderType=le.RENDERTYPE_STATICBATCH,h.setGeometry(i),h.material=l.material;var c=i.batchOwner,d=c?c._transform:null;h.setTransform(d),h.render=this.render,h.renderSubShader=l.renderSubShader;var u=h.staticBatchElementList;u.length=0,u.add(l),u.add(this),a[n.length-1]=h}r.lastTransparentBatched=!0}}else n.add(this),r.lastTransparentBatched=!1}else if(this.renderSubShader._owner._enableInstancing&&t.LayaGL.layaGPUInstance.supportInstance()&&this.render.lightmapIndex<0){var f=this._geometry,E=o.MeshRenderDynamicBatchManager.instance,T=r.lastTransparentRenderElement;if(T){var m=T.render;if(T._geometry._getType()!==this._geometry._getType()||T._geometry!==f||T.material!==this.material||m.receiveShadow!==this.render.receiveShadow)n.add(this),r.lastTransparentBatched=!1;else if(r.lastTransparentBatched){var p=a[n.length-1].instanceBatchElementList;p.length===D.instance.maxInstanceCount?(n.add(this),r.lastTransparentBatched=!1):(p.add(this),r.lastTransparentBatched=!0)}else{var g=E._getBatchRenderElementFromPool();g.renderType=le.RENDERTYPE_INSTANCEBATCH,g.setGeometry(D.instance),g.material=T.material,g.setTransform(null),g.render=this.render,g.instanceSubMesh=f,g.renderSubShader=T.renderSubShader;var S=g.instanceBatchElementList;S.length=0,S.add(T),S.add(this),a[n.length-1]=g,r.lastTransparentBatched=!0}}else n.add(this),r.lastTransparentBatched=!1}else if(this._dynamicVertexBatch){var v=this._geometry._vertexBuffer.vertexDeclaration,R=o.MeshRenderDynamicBatchManager.instance,A=r.lastTransparentRenderElement;if(A){var I=A.render;if(A._geometry._getType()!==this._geometry._getType()||A._geometry._vertexBuffer._vertexDeclaration!==v||A.material!==this.material||I.receiveShadow!==this.render.receiveShadow||I.lightmapIndex!==this.render.lightmapIndex)n.add(this),r.lastTransparentBatched=!1;else{if(r.lastTransparentBatched)a[n.length-1].vertexBatchElementList.add(this);else{var x=R._getBatchRenderElementFromPool();x.renderType=le.RENDERTYPE_VERTEXBATCH,x.setGeometry(o.SubMeshDynamicBatch.instance),x.material=A.material,x.setTransform(null),x.render=this.render,x.vertexBatchVertexDeclaration=v,x.renderSubShader=A.renderSubShader;var M=x.vertexBatchElementList;M.length=0,M.add(A),M.add(this),a[n.length-1]=x}r.lastTransparentBatched=!0}}else n.add(this),r.lastTransparentBatched=!1}else n.add(this);r.lastTransparentRenderElement=this}getInvertFront(){switch(this.renderType){case le.RENDERTYPE_NORMAL:return this._transform._isFrontFaceInvert;case le.RENDERTYPE_STATICBATCH:case le.RENDERTYPE_VERTEXBATCH:return!1;case le.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 he{constructor(){this.elements=[],this.length=0}_add(e){this.length===this.elements.length?this.elements.push(e):this.elements[this.length]=e}add(e){this.length===this.elements.length?this.elements.push(e):this.elements[this.length]=e,this.length++}}class ce extends l{constructor(){super(),this._instanceBatchOpaqueMarks=[],this._vertexBatchOpaqueMarks=[],this._cacheBufferStates=[],this._updateCountMark=0}getInstanceBatchOpaquaMark(e,t,r,i){var n=this._instanceBatchOpaqueMarks[e?0:1]||(this._instanceBatchOpaqueMarks[e?0:1]=[]),a=n[t]||(n[t]=[]),s=a[r]||(a[r]=[]);return s[i?1:0]||(s[i?1:0]=new A)}getVertexBatchOpaquaMark(e,t,r,i){var n=this._vertexBatchOpaqueMarks[e]||(this._vertexBatchOpaqueMarks[e]=[]),a=n[t?0:1]||(n[t?0:1]=[]),s=a[r]||(a[r]=[]);return s[i]||(s[i]=new A)}_getBufferState(e){var t=this._cacheBufferStates[e.id];if(!t){var r=R.instance;(t=new _).bind();var i=r._vertexBuffer;i.vertexDeclaration=e,t.applyVertexBuffer(i),t.applyIndexBuffer(r._indexBuffer),t.unBind(),this._cacheBufferStates[e.id]=t}return t}_getBatchRenderElementFromPool(){var e=this._batchRenderElementPool[this._batchRenderElementPoolIndex++];return e||(e=new _e,this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=e,e.vertexBatchElementList=new he,e.instanceBatchElementList=new he),e}_clear(){super._clear(),this._updateCountMark++}}ce.instance=new ce;class de extends h{constructor(e,t,r){super(),this._bufferState=new _,this._batchID=de._batchIDCounter++,this._batchElements=[],this._currentBatchVertexCount=0,this._currentBatchIndexCount=0,this._vertexDeclaration=r,this.batchOwner=e,this.number=t}_getStaticBatchBakedVertexs(e,t,r,i,n,a){var s,o=a._vertexBuffer,l=o.vertexDeclaration,_=l.getVertexElementByUsage(v.MESH_POSITION0)._offset/4,h=l.getVertexElementByUsage(v.MESH_NORMAL0),c=h?h._offset/4:-1,d=l.getVertexElementByUsage(v.MESH_COLOR0),u=d?d._offset/4:-1,f=l.getVertexElementByUsage(v.MESH_TEXTURECOORDINATE0),E=f?f._offset/4:-1,m=l.getVertexElementByUsage(v.MESH_TEXTURECOORDINATE1),p=m?m._offset/4:-1,g=l.getVertexElementByUsage(v.MESH_TANGENT0),S=g?g._offset/4:-1,R=l.vertexStride/4,A=o.getFloat32Data();r?(r.worldMatrix.invert(de._tempMatrix4x40),s=de._tempMatrix4x41,T.multiply(de._tempMatrix4x40,i.worldMatrix,s)):s=i.worldMatrix;var D=de._tempQuaternion0;s.decomposeTransRotScale(de._tempVector30,D,de._tempVector31);for(var I=n.lightmapScaleOffset,x=a.vertexCount,L=0;Lde.maxBatchVertexCount)}add(e){var t=e._render._staticBatch;t&&t.remove(e);var r=e.meshFilter.sharedMesh,i=r.vertexCount;this._batchElements.push(e);var n=e._render;n._isPartOfStaticBatch=!0,n._staticBatch=this;for(var a=n._renderElements,s=0,o=a.length;s0&&t.setCollisionFlags(r^De.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK)}_onAdded(){this.enabled=this._enabled,this.restitution=this._restitution,this.friction=this._friction,this.rollingFriction=this._rollingFriction,this.ccdMotionThreshold=this._ccdMotionThreshold,this.ccdSweptSphereRadius=this._ccdSweptSphereRadius,this.owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onTransformChanged)}_onDestroy(){var e=fe._physics3D;delete De._physicObjectsMap[this.id],e.destroy(this._nativeColliderObject),this._colliderShape.destroy(),super._onDestroy(),this._nativeColliderObject=null,this._colliderShape=null,this._simulation=null,this.owner.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onTransformChanged)}_onTransformChanged(e){De._addUpdateList&&(e&=V.TRANSFORM_WORLDPOSITION|V.TRANSFORM_WORLDQUATERNION|V.TRANSFORM_WORLDSCALE)&&(this._transformFlag|=e,this._isValid()&&-1===this._inPhysicUpdateListIndex&&this._simulation._physicsUpdateList.add(this))}_cloneTo(e){var t=e;t.restitution=this._restitution,t.friction=this._friction,t.rollingFriction=this._rollingFriction,t.ccdMotionThreshold=this._ccdMotionThreshold,t.ccdSweptSphereRadius=this._ccdSweptSphereRadius,t.collisionGroup=this._collisionGroup,t.canCollideWith=this._canCollideWith,t.canScaleShape=this.canScaleShape,this._colliderShape&&(t.colliderShape=this._colliderShape.clone())}}De.ACTIVATIONSTATE_ACTIVE_TAG=1,De.ACTIVATIONSTATE_ISLAND_SLEEPING=2,De.ACTIVATIONSTATE_WANTS_DEACTIVATION=3,De.ACTIVATIONSTATE_DISABLE_DEACTIVATION=4,De.ACTIVATIONSTATE_DISABLE_SIMULATION=5,De.COLLISIONFLAGS_STATIC_OBJECT=1,De.COLLISIONFLAGS_KINEMATIC_OBJECT=2,De.COLLISIONFLAGS_NO_CONTACT_RESPONSE=4,De.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK=8,De.COLLISIONFLAGS_CHARACTER_OBJECT=16,De.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT=32,De.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING=64,De._tempVector30=new a,De._tempQuaternion0=new E,De._tempQuaternion1=new E,De._tempMatrix4x40=new T,De._physicObjectsMap={},De._addUpdateList=!0;class Ie extends he{constructor(){super()}add(e){if(-1!==e._inPhysicUpdateListIndex)throw"PhysicsUpdateList:element has in PhysicsUpdateList.";this._add(e),e._inPhysicUpdateListIndex=this.length++}remove(e){var t=e._inPhysicUpdateListIndex;if(this.length--,t!==this.length){var r=this.elements[this.length];this.elements[t]=r,r._inPhysicUpdateListIndex=t}e._inPhysicUpdateListIndex=-1}}class xe{constructor(){this._idCounter=0,this.colliderA=null,this.colliderB=null,this.distance=0,this.normal=new a,this.positionOnA=new a,this.positionOnB=new a,this._id=++this._idCounter}}class Me{constructor(){this.succeeded=!1,this.collider=null,this.point=new a,this.normal=new a,this.hitFraction=0}}class Le{constructor(){this._lastUpdateFrame=-2147483648,this._updateFrame=-2147483648,this._isTrigger=!1,this.contacts=[]}_setUpdateFrame(e){this._lastUpdateFrame=this._updateFrame,this._updateFrame=e}}class Ce{constructor(){this._hitResultsPoolIndex=0,this._hitResultsPool=[],this._contactPonintsPoolIndex=0,this._contactPointsPool=[],this._collisionsPool=[],this._collisions={}}getHitResult(){var e=this._hitResultsPool[this._hitResultsPoolIndex++];return e||(e=new Me,this._hitResultsPool.push(e)),e}recoverAllHitResultsPool(){this._hitResultsPoolIndex=0}getContactPoints(){var e=this._contactPointsPool[this._contactPonintsPoolIndex++];return e||(e=new xe,this._contactPointsPool.push(e)),e}recoverAllContactPointsPool(){this._contactPonintsPoolIndex=0}getCollision(e,t){var r,i=e.id,n=t.id,a=this._collisions[i];return a&&(r=a[n]),r||(a||(a={},this._collisions[i]=a),(r=0===this._collisionsPool.length?new Le:this._collisionsPool.pop())._colliderA=e,r._colliderB=t,a[n]=r),r}recoverCollision(e){var t=e._colliderA.id,r=e._colliderB.id;this._collisions[t][r]=null,this._collisionsPool.push(e)}garbageCollection(){for(var e in this._hitResultsPoolIndex=0,this._hitResultsPool.length=0,this._contactPonintsPoolIndex=0,this._contactPointsPool.length=0,this._collisionsPool.length=0,this._collisionsPool){var t=this._collisionsPool[e],r=!0;for(var i in t)t[i]?r=!1:delete t[i];r&&delete this._collisionsPool[e]}}}class ye{constructor(e,t=0){this._gravity=new a(0,-10,0),this._nativeVector3Zero=new fe._physics3D.btVector3(0,0,0),this._nativeDefaultQuaternion=new fe._physics3D.btQuaternion(0,0,0,-1),this._collisionsUtils=new Ce,this._previousFrameCollisions=[],this._currentFrameCollisions=[],this._physicsUpdateList=new Ie,this._characters=[],this._updatedRigidbodies=0,this.maxSubSteps=1,this.fixedTimeStep=1/60,this.maxSubSteps=e.maxSubSteps,this.fixedTimeStep=e.fixedTimeStep;var r=fe._physics3D;this._nativeCollisionConfiguration=new r.btDefaultCollisionConfiguration,this._nativeDispatcher=new r.btCollisionDispatcher(this._nativeCollisionConfiguration),this._nativeBroadphase=new r.btDbvtBroadphase,this._nativeBroadphase.getOverlappingPairCache().setInternalGhostPairCallback(new r.btGhostPairCallback);var i=e.flags;if(i&ye.PHYSICSENGINEFLAGS_COLLISIONSONLY)this._nativeCollisionWorld=new r.btCollisionWorld(this._nativeDispatcher,this._nativeBroadphase,this._nativeCollisionConfiguration);else{if(i&ye.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT)throw"PhysicsSimulation:SoftBody processing is not yet available";var n=new r.btSequentialImpulseConstraintSolver;this._nativeDiscreteDynamicsWorld=new r.btDiscreteDynamicsWorld(this._nativeDispatcher,this._nativeBroadphase,n,this._nativeCollisionConfiguration),this._nativeCollisionWorld=this._nativeDiscreteDynamicsWorld}this._nativeDiscreteDynamicsWorld&&(this._nativeSolverInfo=this._nativeDiscreteDynamicsWorld.getSolverInfo(),this._nativeDispatchInfo=this._nativeDiscreteDynamicsWorld.getDispatchInfo()),this._nativeClosestRayResultCallback=new r.ClosestRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeAllHitsRayResultCallback=new r.AllHitsRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeClosestConvexResultCallback=new r.ClosestConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),this._nativeAllConvexResultCallback=new r.AllConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero),r._btGImpactCollisionAlgorithm_RegisterAlgorithm(this._nativeDispatcher.a)}static __init__(){ye._nativeTempVector30=new fe._physics3D.btVector3(0,0,0),ye._nativeTempVector31=new fe._physics3D.btVector3(0,0,0),ye._nativeTempQuaternion0=new fe._physics3D.btQuaternion(0,0,0,1),ye._nativeTempQuaternion1=new fe._physics3D.btQuaternion(0,0,0,1),ye._nativeTempTransform0=new fe._physics3D.btTransform,ye._nativeTempTransform1=new fe._physics3D.btTransform}static createConstraint(){}get continuousCollisionDetection(){return this._nativeDispatchInfo.get_m_useContinuous()}set continuousCollisionDetection(e){this._nativeDispatchInfo.set_m_useContinuous(e)}get gravity(){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";return this._gravity}set gravity(e){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._gravity=e;var t=ye._nativeTempVector30;t.setValue(-e.x,e.y,e.z),this._nativeDiscreteDynamicsWorld.setGravity(t)}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(e){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeDiscreteDynamicsWorld.setApplySpeculativeContactRestitution(e)}_simulate(e){this._updatedRigidbodies=0,this._nativeDiscreteDynamicsWorld?this._nativeDiscreteDynamicsWorld.stepSimulation(e,this.maxSubSteps,this.fixedTimeStep):this._nativeCollisionWorld.PerformDiscreteCollisionDetection()}_destroy(){var e=fe._physics3D;this._nativeDiscreteDynamicsWorld?(e.destroy(this._nativeDiscreteDynamicsWorld),this._nativeDiscreteDynamicsWorld=null):(e.destroy(this._nativeCollisionWorld),this._nativeCollisionWorld=null),e.destroy(this._nativeBroadphase),this._nativeBroadphase=null,e.destroy(this._nativeDispatcher),this._nativeDispatcher=null,e.destroy(this._nativeCollisionConfiguration),this._nativeCollisionConfiguration=null}_addPhysicsCollider(e,t,r){this._nativeCollisionWorld.addCollisionObject(e._nativeColliderObject,t,r)}_removePhysicsCollider(e){this._nativeCollisionWorld.removeCollisionObject(e._nativeColliderObject)}_addRigidBody(e,t,r){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.addRigidBody(e._nativeColliderObject,t,r)}_removeRigidBody(e){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.removeRigidBody(e._nativeColliderObject)}_addCharacter(e,t,r){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.addCollisionObject(e._nativeColliderObject,t,r),this._nativeCollisionWorld.addAction(e._nativeKinematicCharacter)}_removeCharacter(e){if(!this._nativeDiscreteDynamicsWorld)throw"Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";this._nativeCollisionWorld.removeCollisionObject(e._nativeColliderObject),this._nativeCollisionWorld.removeAction(e._nativeKinematicCharacter)}raycastFromTo(e,t,r=null,i=Ee.COLLISIONFILTERGROUP_ALLFILTER,n=Ee.COLLISIONFILTERGROUP_ALLFILTER){var a=this._nativeClosestRayResultCallback,s=ye._nativeTempVector30,o=ye._nativeTempVector31;if(s.setValue(-e.x,e.y,e.z),o.setValue(-t.x,t.y,t.z),a.set_m_rayFromWorld(s),a.set_m_rayToWorld(o),a.set_m_collisionFilterGroup(i),a.set_m_collisionFilterMask(n),a.set_m_collisionObject(null),a.set_m_closestHitFraction(1),this._nativeCollisionWorld.rayTest(s,o,a),a.hasHit()){if(r){r.succeeded=!0,r.collider=De._physicObjectsMap[a.get_m_collisionObject().getUserIndex()],r.hitFraction=a.get_m_closestHitFraction();var l=a.get_m_hitPointWorld(),_=r.point;_.x=-l.x(),_.y=l.y(),_.z=l.z();var h=a.get_m_hitNormalWorld(),c=r.normal;c.x=-h.x(),c.y=h.y(),c.z=h.z()}return!0}return r&&(r.succeeded=!1),!1}raycastAllFromTo(e,t,r,i=Ee.COLLISIONFILTERGROUP_ALLFILTER,n=Ee.COLLISIONFILTERGROUP_ALLFILTER){var a=this._nativeAllHitsRayResultCallback,s=ye._nativeTempVector30,o=ye._nativeTempVector31;r.length=0,s.setValue(-e.x,e.y,e.z),o.setValue(-t.x,t.y,t.z),a.set_m_rayFromWorld(s),a.set_m_rayToWorld(o),a.set_m_collisionFilterGroup(i),a.set_m_collisionFilterMask(n);var l=a.get_m_collisionObjects(),_=a.get_m_hitPointWorld(),h=a.get_m_hitNormalWorld(),c=a.get_m_hitFractions();l.clear(),_.clear(),h.clear(),c.clear(),this._nativeCollisionWorld.rayTest(s,o,a);var d=l.size();if(d>0){this._collisionsUtils.recoverAllHitResultsPool();for(var u=0;u0){for(var g=_.get_m_hitPointWorld(),S=_.get_m_hitNormalWorld(),v=_.get_m_hitFractions(),R=0;R=e.length)throw new Error("start"+t+"Must be in the range [0, "+(e.length-1)+"]");if(r<0||t+r>e.length)throw new Error("count"+r+"Must be in the range <= "+e.length+"}");var n=t+r,s=Ne._tempVector3;s.x=0,s.y=0,s.z=0;for(var o=t;o_&&(_=h)}i.radius=Math.sqrt(_)}static createfromPoints(e,t){if(null==e)throw new Error("points");Ne.createFromSubPoints(e,0,e.length,t)}intersectsRayDistance(e){return W.intersectsRayAndSphereRD(e,this)}intersectsRayPoint(e,t){return W.intersectsRayAndSphereRP(e,this,t)}cloneTo(e){var t=e;this.center.cloneTo(t.center),t.radius=this.radius}clone(){var e=new Ne(new a,0);return this.cloneTo(e),e}}Ne._tempVector3=new a;class Pe{constructor(){var e;for(this._spiltDistance=[],this._currentPSSM=-1,this._shadowMapCount=3,this._maxDistance=200,this._ratioOfDistance=1/this._shadowMapCount,this._globalParallelLightDir=new a(0,-1,0),this._statesDirty=!0,this._shadowMapTextureSize=1024,this._scene=null,this._boundingSphere=new Array(Pe.MAX_PSSM_COUNT+1),this._boundingBox=new Array(Pe.MAX_PSSM_COUNT+1),this._frustumPos=new Array(4*(Pe.MAX_PSSM_COUNT+1)),this._uniformDistance=new Array(Pe.MAX_PSSM_COUNT+1),this._logDistance=new Array(Pe.MAX_PSSM_COUNT+1),this._dimension=new Array(Pe.MAX_PSSM_COUNT+1),this._PCFType=0,this._tempLookAt3=new a,this._tempLookAt4=new n,this._tempValue=new n,this._tempPos=new a,this._tempLightUp=new a,this._tempMin=new n,this._tempMax=new n,this._tempMatrix44=new T,this._splitFrustumCulling=new k(T.DEFAULT),this._tempScaleMatrix44=new T,this._shadowPCFOffset=new i(1/1024,1/1024),this._shaderValueDistance=new n,this._shaderValueLightVP=null,this.cameras=[],this._shaderValueVPs=[],e=0;ePe.MAX_PSSM_COUNT&&(this._shadowMapCount=Pe.MAX_PSSM_COUNT),this._scene=e,this._maxDistance=t,this.shadowMapCount=n,this._globalParallelLightDir=r,this._ratioOfDistance=1/this._shadowMapCount;for(var s=0;s0?e:1)<=Pe.MAX_PSSM_COUNT?e:Pe.MAX_PSSM_COUNT,this._shadowMapCount!=e){this._shadowMapCount=e,this._ratioOfDistance=1/this._shadowMapCount,this._statesDirty=!0,this._shaderValueLightVP=new Float32Array(16*e),this._shaderValueVPs.length=e;for(var t=0;tthis._shadowMapCount)throw new Error("ParallelSplitShadowMap: beginSample invalid index");this._currentPSSM=e,this._update(t)}endSampler(e){this._currentPSSM=-1}_calcAllLightCameraInfo(e){if(1===this._shadowMapCount)this._beginSampler(0,e),this.endSampler(e);else for(var t=0,r=this._shadowMapCount+1;t0?T.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[this._currentPSSM-1],this._spiltDistance[this._currentPSSM],this._tempMatrix44):T.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[0],this._spiltDistance[this._shadowMapCount],this._tempMatrix44),T.multiply(this._tempMatrix44,e.viewMatrix,this._tempMatrix44),this._splitFrustumCulling.matrix=this._tempMatrix44}_rebuildRenderInfo(){var e,r=this._shadowMapCount+1;for(this.cameras.length=r,e=0;ec.x?u.x:c.x,c.y=u.y>c.y?u.y:c.y,c.z=u.z>c.z?u.z:c.z}n.add(this._tempMax,this._tempMin,this._tempValue),u.x*=.5,u.y*=.5,u.z*=.5,u.w=1,n.transformByM4x4(this._tempValue,h.transform.worldMatrix,this._tempValue);var p=Math.abs(-this._tempMax.z),g=p>this._maxDistance?p:this._maxDistance;a.scale(this._globalParallelLightDir,g,this._tempPos);var S=this._tempPos;S.x=u.x-S.x,S.y=u.y-S.y,S.z=u.z-S.z,h.transform.position=this._tempPos,h.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1),T.createOrthoOffCenter(d.x,c.x,d.y,c.y,1,g+.5*(c.z-d.z),h.projectionMatrix);var v=h.projectionViewMatrix;Pe.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,v,this._shaderValueVPs[this._currentPSSM]),this._scene._shaderValues.setBuffer(o.Scene3D.SHADOWLIGHTVIEWPROJECT,this._shaderValueLightVP)}static multiplyMatrixOutFloat32Array(e,t,r){var i,n,a,s,o,l,_;for(n=e.elements,a=t.elements,i=0;i<4;i++)s=n[i],o=n[i+4],l=n[i+8],_=n[i+12],r[i]=s*a[0]+o*a[1]+l*a[2]+_*a[3],r[i+4]=s*a[4]+o*a[5]+l*a[6]+_*a[7],r[i+8]=s*a[8]+o*a[9]+l*a[10]+_*a[11],r[i+12]=s*a[12]+o*a[13]+l*a[14]+_*a[15]}setShadowMapTextureSize(e){e!==this._shadowMapTextureSize&&(this._shadowMapTextureSize=e,this._shadowPCFOffset.x=1/this._shadowMapTextureSize,this._shadowPCFOffset.y=1/this._shadowMapTextureSize,this._statesDirty=!0)}disposeAllRenderTarget(){for(var e=0,t=this._shadowMapCount+1;e0&&this._removeTetxureReference(),this._shaderValues=null}setShaderName(e){if(this._shader=L.find(e),!this._shader)throw new Error("BaseMaterial: unknown shader name.")}cloneTo(e){var t=e;t.name=this.name,t.renderQueue=this.renderQueue,this._disablePublicDefineDatas.cloneTo(t._disablePublicDefineDatas),this._shaderValues.cloneTo(t._shaderValues)}clone(){var e=new Ge;return this.cloneTo(e),e}get _defineDatas(){return this._shaderValues._defineDatas}}Ge.MATERIAL="MATERIAL",Ge.RENDERQUEUE_OPAQUE=2e3,Ge.RENDERQUEUE_ALPHATEST=2450,Ge.RENDERQUEUE_TRANSPARENT=3e3,Ge.ALPHATESTVALUE=L.propertyNameToID("u_AlphaTestValue"),Ge.shaderDefines=null;class ze{constructor(){this.cull=ze.CULL_BACK,this.blend=ze.BLEND_DISABLE,this.srcBlend=ze.BLENDPARAM_ONE,this.dstBlend=ze.BLENDPARAM_ZERO,this.srcBlendRGB=ze.BLENDPARAM_ONE,this.dstBlendRGB=ze.BLENDPARAM_ZERO,this.srcBlendAlpha=ze.BLENDPARAM_ONE,this.dstBlendAlpha=ze.BLENDPARAM_ZERO,this.blendConstColor=new n(1,1,1,1),this.blendEquation=ze.BLENDEQUATION_ADD,this.blendEquationRGB=ze.BLENDEQUATION_ADD,this.blendEquationAlpha=ze.BLENDEQUATION_ADD,this.depthTest=ze.DEPTHTEST_LEQUAL,this.depthWrite=!0}cloneTo(e){var t=e;t.cull=this.cull,t.blend=this.blend,t.srcBlend=this.srcBlend,t.dstBlend=this.dstBlend,t.srcBlendRGB=this.srcBlendRGB,t.dstBlendRGB=this.dstBlendRGB,t.srcBlendAlpha=this.srcBlendAlpha,t.dstBlendAlpha=this.dstBlendAlpha,this.blendConstColor.cloneTo(t.blendConstColor),t.blendEquation=this.blendEquation,t.blendEquationRGB=this.blendEquationRGB,t.blendEquationAlpha=this.blendEquationAlpha,t.depthTest=this.depthTest,t.depthWrite=this.depthWrite}clone(){var e=new ze;return this.cloneTo(e),e}}ze.CULL_NONE=0,ze.CULL_FRONT=1,ze.CULL_BACK=2,ze.BLEND_DISABLE=0,ze.BLEND_ENABLE_ALL=1,ze.BLEND_ENABLE_SEPERATE=2,ze.BLENDPARAM_ZERO=0,ze.BLENDPARAM_ONE=1,ze.BLENDPARAM_SRC_COLOR=768,ze.BLENDPARAM_ONE_MINUS_SRC_COLOR=769,ze.BLENDPARAM_DST_COLOR=774,ze.BLENDPARAM_ONE_MINUS_DST_COLOR=775,ze.BLENDPARAM_SRC_ALPHA=770,ze.BLENDPARAM_ONE_MINUS_SRC_ALPHA=771,ze.BLENDPARAM_DST_ALPHA=772,ze.BLENDPARAM_ONE_MINUS_DST_ALPHA=773,ze.BLENDPARAM_SRC_ALPHA_SATURATE=776,ze.BLENDEQUATION_ADD=0,ze.BLENDEQUATION_SUBTRACT=1,ze.BLENDEQUATION_REVERSE_SUBTRACT=2,ze.DEPTHTEST_OFF=0,ze.DEPTHTEST_NEVER=512,ze.DEPTHTEST_LESS=513,ze.DEPTHTEST_EQUAL=514,ze.DEPTHTEST_LEQUAL=515,ze.DEPTHTEST_GREATER=516,ze.DEPTHTEST_NOTEQUAL=517,ze.DEPTHTEST_GEQUAL=518,ze.DEPTHTEST_ALWAYS=519;class He extends Ge{constructor(){super(),this._enableVertexColor=!1,this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new n(1,1,1,1);var e=this._shaderValues;e.setVector(He.ALBEDOCOLOR,new n(1,1,1,1)),e.setVector(He.MATERIALSPECULAR,new n(1,1,1,1)),e.setNumber(He.SHININESS,.078125),e.setNumber(Ge.ALPHATESTVALUE,.5),e.setVector(He.TILINGOFFSET,new n(1,1,0,0)),this._enableLighting=!0,this.renderMode=He.RENDERMODE_OPAQUE}static __initDefine__(){He.shaderDefines=new C(Ge.shaderDefines),He.SHADERDEFINE_DIFFUSEMAP=He.shaderDefines.registerDefine("DIFFUSEMAP"),He.SHADERDEFINE_NORMALMAP=He.shaderDefines.registerDefine("NORMALMAP"),He.SHADERDEFINE_SPECULARMAP=He.shaderDefines.registerDefine("SPECULARMAP"),He.SHADERDEFINE_TILINGOFFSET=He.shaderDefines.registerDefine("TILINGOFFSET"),He.SHADERDEFINE_ENABLEVERTEXCOLOR=He.shaderDefines.registerDefine("ENABLEVERTEXCOLOR")}get _ColorR(){return this._albedoColor.x}set _ColorR(e){this._albedoColor.x=e,this.albedoColor=this._albedoColor}get _ColorG(){return this._albedoColor.y}set _ColorG(e){this._albedoColor.y=e,this.albedoColor=this._albedoColor}get _ColorB(){return this._albedoColor.z}set _ColorB(e){this._albedoColor.z=e,this.albedoColor=this._albedoColor}get _ColorA(){return this._albedoColor.w}set _ColorA(e){this._albedoColor.w=e,this.albedoColor=this._albedoColor}get _SpecColorR(){return this._shaderValues.getVector(He.MATERIALSPECULAR).x}set _SpecColorR(e){this._shaderValues.getVector(He.MATERIALSPECULAR).x=e}get _SpecColorG(){return this._shaderValues.getVector(He.MATERIALSPECULAR).y}set _SpecColorG(e){this._shaderValues.getVector(He.MATERIALSPECULAR).y=e}get _SpecColorB(){return this._shaderValues.getVector(He.MATERIALSPECULAR).z}set _SpecColorB(e){this._shaderValues.getVector(He.MATERIALSPECULAR).z=e}get _SpecColorA(){return this._shaderValues.getVector(He.MATERIALSPECULAR).w}set _SpecColorA(e){this._shaderValues.getVector(He.MATERIALSPECULAR).w=e}get _AlbedoIntensity(){return this._albedoIntensity}set _AlbedoIntensity(e){if(this._albedoIntensity!==e){var t=this._shaderValues.getVector(He.ALBEDOCOLOR);n.scale(this._albedoColor,e,t),this._albedoIntensity=e,this._shaderValues.setVector(He.ALBEDOCOLOR,t)}}get _Shininess(){return this._shaderValues.getNumber(He.SHININESS)}set _Shininess(e){e=Math.max(0,Math.min(1,e)),this._shaderValues.setNumber(He.SHININESS,e)}get _MainTex_STX(){return this._shaderValues.getVector(He.TILINGOFFSET).x}set _MainTex_STX(e){var t=this._shaderValues.getVector(He.TILINGOFFSET);t.x=e,this.tilingOffset=t}get _MainTex_STY(){return this._shaderValues.getVector(He.TILINGOFFSET).y}set _MainTex_STY(e){var t=this._shaderValues.getVector(He.TILINGOFFSET);t.y=e,this.tilingOffset=t}get _MainTex_STZ(){return this._shaderValues.getVector(He.TILINGOFFSET).z}set _MainTex_STZ(e){var t=this._shaderValues.getVector(He.TILINGOFFSET);t.z=e,this.tilingOffset=t}get _MainTex_STW(){return this._shaderValues.getVector(He.TILINGOFFSET).w}set _MainTex_STW(e){var t=this._shaderValues.getVector(He.TILINGOFFSET);t.w=e,this.tilingOffset=t}get _Cutoff(){return this.alphaTestValue}set _Cutoff(e){this.alphaTestValue=e}set renderMode(e){switch(e){case He.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=Ge.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=ze.CULL_BACK,this.blend=ze.BLEND_DISABLE,this.depthTest=ze.DEPTHTEST_LESS;break;case He.RENDERMODE_CUTOUT:this.renderQueue=Ge.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=ze.CULL_BACK,this.blend=ze.BLEND_DISABLE,this.depthTest=ze.DEPTHTEST_LESS;break;case He.RENDERMODE_TRANSPARENT:this.renderQueue=Ge.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=ze.CULL_BACK,this.blend=ze.BLEND_ENABLE_ALL,this.blendSrc=ze.BLENDPARAM_SRC_ALPHA,this.blendDst=ze.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=ze.DEPTHTEST_LESS;break;default:throw new Error("Material:renderMode value error.")}}get enableVertexColor(){return this._enableVertexColor}set enableVertexColor(e){this._enableVertexColor=e,e?this._shaderValues.addDefine(He.SHADERDEFINE_ENABLEVERTEXCOLOR):this._shaderValues.removeDefine(He.SHADERDEFINE_ENABLEVERTEXCOLOR)}get tilingOffsetX(){return this._MainTex_STX}set tilingOffsetX(e){this._MainTex_STX=e}get tilingOffsetY(){return this._MainTex_STY}set tilingOffsetY(e){this._MainTex_STY=e}get tilingOffsetZ(){return this._MainTex_STZ}set tilingOffsetZ(e){this._MainTex_STZ=e}get tilingOffsetW(){return this._MainTex_STW}set tilingOffsetW(e){this._MainTex_STW=e}get tilingOffset(){return this._shaderValues.getVector(He.TILINGOFFSET)}set tilingOffset(e){e&&(1!=e.x||1!=e.y||0!=e.z||0!=e.w)?this._shaderValues.addDefine(He.SHADERDEFINE_TILINGOFFSET):this._shaderValues.removeDefine(He.SHADERDEFINE_TILINGOFFSET),this._shaderValues.setVector(He.TILINGOFFSET,e)}get albedoColorR(){return this._ColorR}set albedoColorR(e){this._ColorR=e}get albedoColorG(){return this._ColorG}set albedoColorG(e){this._ColorG=e}get albedoColorB(){return this._ColorB}set albedoColorB(e){this._ColorB=e}get albedoColorA(){return this._ColorA}set albedoColorA(e){this._ColorA=e}get albedoColor(){return this._albedoColor}set albedoColor(e){var t=this._shaderValues.getVector(He.ALBEDOCOLOR);n.scale(e,this._albedoIntensity,t),this._albedoColor=e,this._shaderValues.setVector(He.ALBEDOCOLOR,t)}get albedoIntensity(){return this._albedoIntensity}set albedoIntensity(e){this._AlbedoIntensity=e}get specularColorR(){return this._SpecColorR}set specularColorR(e){this._SpecColorR=e}get specularColorG(){return this._SpecColorG}set specularColorG(e){this._SpecColorG=e}get specularColorB(){return this._SpecColorB}set specularColorB(e){this._SpecColorB=e}get specularColorA(){return this._SpecColorA}set specularColorA(e){this._SpecColorA=e}get specularColor(){return this._shaderValues.getVector(He.MATERIALSPECULAR)}set specularColor(e){this._shaderValues.setVector(He.MATERIALSPECULAR,e)}get shininess(){return this._Shininess}set shininess(e){this._Shininess=e}get albedoTexture(){return this._shaderValues.getTexture(He.ALBEDOTEXTURE)}set albedoTexture(e){e?this._shaderValues.addDefine(He.SHADERDEFINE_DIFFUSEMAP):this._shaderValues.removeDefine(He.SHADERDEFINE_DIFFUSEMAP),this._shaderValues.setTexture(He.ALBEDOTEXTURE,e)}get normalTexture(){return this._shaderValues.getTexture(He.NORMALTEXTURE)}set normalTexture(e){e?this._shaderValues.addDefine(He.SHADERDEFINE_NORMALMAP):this._shaderValues.removeDefine(He.SHADERDEFINE_NORMALMAP),this._shaderValues.setTexture(He.NORMALTEXTURE,e)}get specularTexture(){return this._shaderValues.getTexture(He.SPECULARTEXTURE)}set specularTexture(e){e?this._shaderValues.addDefine(He.SHADERDEFINE_SPECULARMAP):this._shaderValues.removeDefine(He.SHADERDEFINE_SPECULARMAP),this._shaderValues.setTexture(He.SPECULARTEXTURE,e)}get enableLighting(){return this._enableLighting}set enableLighting(e){this._enableLighting!==e&&(e?this._disablePublicDefineDatas.remove(se.SHADERDEFINE_POINTLIGHT|se.SHADERDEFINE_SPOTLIGHT|se.SHADERDEFINE_DIRECTIONLIGHT):this._disablePublicDefineDatas.add(se.SHADERDEFINE_POINTLIGHT|se.SHADERDEFINE_SPOTLIGHT|se.SHADERDEFINE_DIRECTIONLIGHT),this._enableLighting=e)}set depthWrite(e){this._shaderValues.setBool(He.DEPTH_WRITE,e)}get depthWrite(){return this._shaderValues.getBool(He.DEPTH_WRITE)}set cull(e){this._shaderValues.setInt(He.CULL,e)}get cull(){return this._shaderValues.getInt(He.CULL)}set blend(e){this._shaderValues.setInt(He.BLEND,e)}get blend(){return this._shaderValues.getInt(He.BLEND)}set blendSrc(e){this._shaderValues.setInt(He.BLEND_SRC,e)}get blendSrc(){return this._shaderValues.getInt(He.BLEND_SRC)}set blendDst(e){this._shaderValues.setInt(He.BLEND_DST,e)}get blendDst(){return this._shaderValues.getInt(He.BLEND_DST)}set depthTest(e){this._shaderValues.setInt(He.DEPTH_TEST,e)}get depthTest(){return this._shaderValues.getInt(He.DEPTH_TEST)}clone(){var e=new He;return this.cloneTo(e),e}cloneTo(e){super.cloneTo(e);var t=e;t._enableLighting=this._enableLighting,t._albedoIntensity=this._albedoIntensity,t._enableVertexColor=this._enableVertexColor,this._albedoColor.cloneTo(t._albedoColor)}}He.RENDERMODE_OPAQUE=0,He.RENDERMODE_CUTOUT=1,He.RENDERMODE_TRANSPARENT=2,He.ALBEDOTEXTURE=L.propertyNameToID("u_DiffuseTexture"),He.NORMALTEXTURE=L.propertyNameToID("u_NormalTexture"),He.SPECULARTEXTURE=L.propertyNameToID("u_SpecularTexture"),He.ALBEDOCOLOR=L.propertyNameToID("u_DiffuseColor"),He.MATERIALSPECULAR=L.propertyNameToID("u_MaterialSpecular"),He.SHININESS=L.propertyNameToID("u_Shininess"),He.TILINGOFFSET=L.propertyNameToID("u_TilingOffset"),He.CULL=L.propertyNameToID("s_Cull"),He.BLEND=L.propertyNameToID("s_Blend"),He.BLEND_SRC=L.propertyNameToID("s_BlendSrc"),He.BLEND_DST=L.propertyNameToID("s_BlendDst"),He.DEPTH_TEST=L.propertyNameToID("s_DepthTest"),He.DEPTH_WRITE=L.propertyNameToID("s_DepthWrite"),He.shaderDefines=null;class We{constructor(e,t){this._updateFlag=0,this._center=new a,this._extent=new a,this._boundBox=new Oe(new a,new a),e.cloneTo(this._boundBox.min),t.cloneTo(this._boundBox.max),this._setUpdateFlag(We._UPDATE_CENTER|We._UPDATE_EXTENT,!0)}setMin(e){var t=this._boundBox.min;e!==t&&e.cloneTo(t),this._setUpdateFlag(We._UPDATE_CENTER|We._UPDATE_EXTENT,!0),this._setUpdateFlag(We._UPDATE_MIN,!1)}getMin(){var e=this._boundBox.min;return this._getUpdateFlag(We._UPDATE_MIN)&&(this._getMin(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(We._UPDATE_MIN,!1)),e}setMax(e){var t=this._boundBox.max;e!==t&&e.cloneTo(t),this._setUpdateFlag(We._UPDATE_CENTER|We._UPDATE_EXTENT,!0),this._setUpdateFlag(We._UPDATE_MAX,!1)}getMax(){var e=this._boundBox.max;return this._getUpdateFlag(We._UPDATE_MAX)&&(this._getMax(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(We._UPDATE_MAX,!1)),e}setCenter(e){e!==this._center&&e.cloneTo(this._center),this._setUpdateFlag(We._UPDATE_MIN|We._UPDATE_MAX,!0),this._setUpdateFlag(We._UPDATE_CENTER,!1)}getCenter(){return this._getUpdateFlag(We._UPDATE_CENTER)&&(this._getCenter(this.getMin(),this.getMax(),this._center),this._setUpdateFlag(We._UPDATE_CENTER,!1)),this._center}setExtent(e){e!==this._extent&&e.cloneTo(this._extent),this._setUpdateFlag(We._UPDATE_MIN|We._UPDATE_MAX,!0),this._setUpdateFlag(We._UPDATE_EXTENT,!1)}getExtent(){return this._getUpdateFlag(We._UPDATE_EXTENT)&&(this._getExtent(this.getMin(),this.getMax(),this._extent),this._setUpdateFlag(We._UPDATE_EXTENT,!1)),this._extent}_getUpdateFlag(e){return 0!=(this._updateFlag&e)}_setUpdateFlag(e,t){t?this._updateFlag|=e:this._updateFlag&=~e}_getCenter(e,t,r){a.add(e,t,r),a.scale(r,.5,r)}_getExtent(e,t,r){a.subtract(t,e,r),a.scale(r,.5,r)}_getMin(e,t,r){a.subtract(e,t,r)}_getMax(e,t,r){a.add(e,t,r)}_rotateExtents(e,t,r){var i=e.x,n=e.y,a=e.z,s=t.elements;r.x=Math.abs(s[0]*i)+Math.abs(s[4]*n)+Math.abs(s[8]*a),r.y=Math.abs(s[1]*i)+Math.abs(s[5]*n)+Math.abs(s[9]*a),r.z=Math.abs(s[2]*i)+Math.abs(s[6]*n)+Math.abs(s[10]*a)}_tranform(e,t){var r=t._center,i=t._extent;a.transformCoordinate(this.getCenter(),e,r),this._rotateExtents(this.getExtent(),e,i),t._boundBox.setCenterAndExtent(r,i),t._updateFlag=0}_getBoundBox(){if(this._updateFlag&We._UPDATE_MIN){var e=this._boundBox.min;this._getMin(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(We._UPDATE_MIN,!1)}if(this._updateFlag&We._UPDATE_MAX){var t=this._boundBox.max;this._getMax(this.getCenter(),this.getExtent(),t),this._setUpdateFlag(We._UPDATE_MAX,!1)}return this._boundBox}cloneTo(e){var t=e;this.getMin().cloneTo(t._boundBox.min),this.getMax().cloneTo(t._boundBox.max),this.getCenter().cloneTo(t._center),this.getExtent().cloneTo(t._extent),t._updateFlag=0}clone(){var e=new We(new a,new a);return this.cloneTo(e),e}}We._UPDATE_MIN=1,We._UPDATE_MAX=2,We._UPDATE_CENTER=4,We._UPDATE_EXTENT=8;class ke extends t.EventDispatcher{constructor(e){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=++ke._uniqueIDCounter,this._indexInCastShadowList=-1,this._bounds=new We(a._ZERO,a._ZERO),t.Render.supportWebGLPlusCulling){var r=U._cullingBufferLength;this._cullingBufferIndex=r;var i=U._cullingBuffer,n=r+7;if(n>=i.length){var s=i;(i=U._cullingBuffer=new Float32Array(i.length+4096)).set(s,0)}i[r]=2,U._cullingBufferLength=n}this._renderElements=[],this._owner=e,this._enable=!0,this._materialsInstance=[],this._shaderValues=new p(null),this.lightmapIndex=-1,this._castShadow=!1,this.receiveShadow=!1,this.sortingFudge=0,e&&this._owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange)}get id(){return this._id}get lightmapIndex(){return this._lightmapIndex}set lightmapIndex(e){this._lightmapIndex!==e&&(this._lightmapIndex=e,this._applyLightMapParams())}get lightmapScaleOffset(){return this._lightmapScaleOffset}set lightmapScaleOffset(e){this._lightmapScaleOffset=e,this._shaderValues.setVector(F.LIGHTMAPSCALEOFFSET,e),this._shaderValues.addDefine(F.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV)}get enable(){return this._enable}set enable(e){this._enable=!!e}get material(){var e=this._sharedMaterials[0];if(e&&!this._materialsInstance[0]){var t=this._getInstanceMaterial(e,0),r=this._renderElements[0];r&&(r.material=t)}return this._sharedMaterials[0]}set material(e){this.sharedMaterial=e}get materials(){for(var e=0,t=this._sharedMaterials.length;e=0){var e=this._scene.getlightmaps();this._lightmapIndex=0;s--){var o=4*s;if(e===(u=n[o]))return t.r=n[o+1],t.g=n[o+2],t.b=n[o+3],a;switch(this._mode){case Ze.Blend:if(e>u){if(e>(d=n[o+4]))throw"Gradient:wrong startSearchIndex.";var l=d-u,_=d-e,h=e-u;return t.r=(_*n[o+1]+h*n[o+5])/l,t.g=(_*n[o+2]+h*n[o+6])/l,t.b=(_*n[o+3]+h*n[o+7])/l,a}a--;continue;case Ze.Fixed:if(e>u){if(e>n[o+4])throw"Gradient:wrong startSearchIndex.";return t.r=n[o+5],t.g=n[o+6],t.b=n[o+7],a}a--;continue;default:throw"Gradient:unknown mode."}}else{s=0;for(var c=this._rgbElements.length;s=0;s--){if(e===(u=n[c=2*s]))return t.a=n[c+1],a;switch(this._mode){case Ze.Blend:if(e>u){if(e>(d=n[c+2]))throw"Gradient:wrong startSearchIndex.";var o=d-u,l=d-e,_=e-u;return t.a=(l*n[c+1]+_*n[c+3])/o,a}a--;continue;case Ze.Fixed:if(e>u){if(e>n[c+2])throw"Gradient:wrong startSearchIndex.";return t.a=n[c+3],a}a--;continue;default:throw"Gradient:unknown mode."}}else{s=a;for(var h=this._alphaElements.length;s=r){var s=e.getKeyByIndex(i-1),o=(r-s)/(a-s);return t.MathUtil.lerp(e.getValueByIndex(i-1),e.getValueByIndex(i),o)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")}static _randomInvertRoationArray(e,t,r,i,n){var a;i?(i.seed=n[6],a=i.getFloat(),n[6]=i.seed):a=Math.random(),a0)for(var r=0;re.time&&this._bursts.splice(r,0,e);this._bursts.push(e)}removeBurst(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)}removeBurstByIndex(e){this._bursts.splice(e,1)}clearBurst(){this._bursts.length=0}cloneTo(e){var t=e,r=t._bursts;r.length=this._bursts.length;for(var i=0,n=this._bursts.length;i>>15}get seed(){return this.seeds[0]}set seed(e){this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}getUint(){return this._temp[0]=this.seeds[0]^this.seeds[0]<<11,this.seeds[0]=this.seeds[1],this.seeds[1]=this.seeds[2],this.seeds[2]=this.seeds[3],this.seeds[3]=this.seeds[3]^this.seeds[3]>>>19^this._temp[0]^this._temp[0]>>>8,this.seeds[3]}getFloat(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)}getSignedFloat(){return 2*this.getFloat()-1}}class at extends h{constructor(e){super(),this._tempRotationMatrix=new T,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 i,this._vertexStride=0,this._indexStride=0,this._vertexBuffer=null,this._indexBuffer=null,this._bufferState=new _,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=e,this._ownerRender=e.particleRenderer,this._boundingBoxCorners=[],this._boundingSphere=new Ne(new a,Number.MAX_VALUE),this._boundingBox=new Oe(new a(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),new a(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 et,this._startLifetimeConstantMin=0,this._startLifetimeConstantMax=5,this._startLifeTimeGradientMin=new et,this._startLifeTimeGradientMax=new et,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 a(1,1,1),this.startSizeConstantMin=0,this.startSizeConstantMax=1,this.startSizeConstantMinSeparate=new a(0,0,0),this.startSizeConstantMaxSeparate=new a(1,1,1),this.threeDStartRotation=!1,this.startRotationType=0,this.startRotationConstant=0,this.startRotationConstantSeparate=new a(0,0,0),this.startRotationConstantMin=0,this.startRotationConstantMax=0,this.startRotationConstantMinSeparate=new a(0,0,0),this.startRotationConstantMaxSeparate=new a(0,0,0),this.randomizeRotationDirection=0,this.startColorType=0,this.startColorConstant=new n(1,1,1,1),this.startColorConstantMin=new n(1,1,1,1),this.startColorConstantMax=new n(1,1,1,1),this.gravityModifier=0,this.simulationSpace=1,this.scaleMode=0,this.playOnAwake=!0,this._rand=new nt(0),this.autoRandomSeed=!0,this.randomSeed=new Uint32Array(1),this._randomSeeds=new Uint32Array(at._RANDOMOFFSET.length),this.isPerformanceMode=!0,this._emission=new $e,this._emission.enbale=!0}get maxParticles(){return this._bufferMaxParticles-1}set maxParticles(e){var t=e+1;t!==this._bufferMaxParticles&&(this._bufferMaxParticles=t,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(e){this._shape!==e&&(e&&e.enable?this._owner._render._shaderValues.addDefine(Ke.SHADERDEFINE_SHAPE):this._owner._render._shaderValues.removeDefine(Ke.SHADERDEFINE_SHAPE),this._shape=e)}get isAlive(){return!!(this._isPlaying||this.aliveParticleCount>0)}get isEmitting(){return this._isEmitting}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get startLifetimeType(){return this._startLifetimeType}set startLifetimeType(e){var t,r;switch(this.startLifetimeType){case 0:this._maxStartLifetime=this.startLifetimeConstant;break;case 1:this._maxStartLifetime=-Number.MAX_VALUE;var i=i;for(t=0,r=i.gradientCount;t=this._bufferMaxParticles&&(this._firstActiveElement=0)}}_freeRetiredParticles(){for(;this._firstRetiredElement!=this._firstActiveElement;){var e=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*this._vertexStride+this._timeIndex];if(this.isPerformanceMode&&e<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this._bufferMaxParticles&&(this._firstRetiredElement=0)}}_burst(e,r){for(var i=0,n=this._emission._bursts,a=n.length;this._burstsIndexthis.duration){if(!this.looping){for(n=Math.min(this.maxParticles-this.aliveParticleCount,n),r=0;r0){var s=1/a;for(this._frameRateTime+=s,this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)%this._maxStartLifetime;this._frameRateTime<=t&&this.emit(this._frameRateTime);)this._frameRateTime+=s;this._frameRateTime=Math.floor(t/s)*s}}_initBufferDatas(){this._vertexBuffer&&(this._vertexBuffer.destroy(),this._indexBuffer.destroy());var e=t.LayaGL.instance,r=this._ownerRender,i=r.renderMode;if(-1!==i&&this.maxParticles>0){var n,a,s,o,l,_,h,u=0,f=0,E=r.mesh;if(4===i){if(E){h=it.vertexDeclaration,this._floatCountPerVertex=h.vertexStride/4,this._startLifeTimeIndex=12,this._timeIndex=16,this._vertexStride=E._vertexBuffer.vertexCount;var T=this._bufferMaxParticles*this._vertexStride,m=T%65535;if(Math.floor(T/65535)+1>1)throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");u=h.vertexStride*m,this._vertexBuffer=new d(u,e.DYNAMIC_DRAW),this._vertexBuffer.vertexDeclaration=h,this._vertices=new Float32Array(this._floatCountPerVertex*m),this._indexStride=E._indexBuffer.indexCount;var p=E._indexBuffer.getData(),g=this._bufferMaxParticles*this._indexStride;for(this._indexBuffer=new c(c.INDEXTYPE_USHORT,g,e.STATIC_DRAW),n=new Uint16Array(g),f=u+2*g,l=0,a=0;a=this._bufferMaxParticles&&(c=0),c===this._firstRetiredElement)return!1;if(Je.create(this,this._ownerRender,this._owner.transform),this._currentTime-r>=Je.startLifeTime)return!0;var d=this._velocityOverLifetime&&this._velocityOverLifetime.enbale;if(d){var u=this._velocityOverLifetime.velocity.type;2===u||3===u?this.autoRandomSeed?(i=Math.random(),n=Math.random(),s=Math.random()):(this._rand.seed=this._randomSeeds[9],i=this._rand.getFloat(),n=this._rand.getFloat(),s=this._rand.getFloat(),this._randomSeeds[9]=this._rand.seed):d=!1}else d=!1;var f=this._colorOverLifetime&&this._colorOverLifetime.enbale;f?3===this._colorOverLifetime.color.type?this.autoRandomSeed?o=Math.random():(this._rand.seed=this._randomSeeds[10],o=this._rand.getFloat(),this._randomSeeds[10]=this._rand.seed):f=!1:f=!1;var E=this._sizeOverLifetime&&this._sizeOverLifetime.enbale;E?3===this._sizeOverLifetime.size.type?this.autoRandomSeed?l=Math.random():(this._rand.seed=this._randomSeeds[11],l=this._rand.getFloat(),this._randomSeeds[11]=this._rand.seed):E=!1:E=!1;var T=this._rotationOverLifetime&&this._rotationOverLifetime.enbale;if(T){var m=this._rotationOverLifetime.angularVelocity.type;2===m||3===m?this.autoRandomSeed?_=Math.random():(this._rand.seed=this._randomSeeds[12],_=this._rand.getFloat(),this._randomSeeds[12]=this._rand.seed):T=!1}else T=!1;var p=this._textureSheetAnimation&&this._textureSheetAnimation.enable;p?3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?h=Math.random():(this._rand.seed=this._randomSeeds[15],h=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):p=!1:p=!1;var g,S,R,A,D,I,x=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,M=Je.startUVInfo[0],L=Je.startUVInfo[1],C=Je.startUVInfo[2],y=Je.startUVInfo[3],O=this._ownerRender;if(4===O.renderMode){var N=O.mesh._vertexBuffer;g=N.getFloat32Data();var P=N.vertexDeclaration;R=P.getVertexElementByUsage(v.MESH_POSITION0)._offset/4;var w=P.getVertexElementByUsage(v.MESH_COLOR0);A=w?w._offset/4:-1;var V=P.getVertexElementByUsage(v.MESH_TEXTURECOORDINATE0);D=V?V._offset/4:-1,S=P.vertexStride/4,I=0}else{this._vertices[x+2]=C,this._vertices[x+3]=y+L;var b=x+this._floatCountPerVertex;this._vertices[b+2]=C+M,this._vertices[b+3]=y+L;var F=b+this._floatCountPerVertex;this._vertices[F+2]=C+M,this._vertices[F+3]=y;var B=F+this._floatCountPerVertex;this._vertices[B+2]=C,this._vertices[B+3]=y}for(var U=x,G=x+this._floatCountPerVertex*this._vertexStride;U0&&this._vertexBuffer.setData(this._vertices.buffer,0,0,this._firstFreeElement*t)),this._firstNewElement=this._firstFreeElement}_getType(){return at._type}_prepareRender(e){return this._updateEmission(),this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement}_render(e){var r;this._bufferState.bind();var i=t.LayaGL.instance;this._firstActiveElement0&&(r=this._firstFreeElement*this._indexStride,i.drawElements(i.TRIANGLES,r,i.UNSIGNED_SHORT,0),t.Stat.trianglesFaces+=r/3,t.Stat.renderBatches++))}play(){if(this._burstsIndex=0,this._isEmitting=!0,this._isPlaying=!0,this._isPaused=!1,this._emissionTime=0,this._totalDelayTime=0,!this.autoRandomSeed)for(var e=0,r=this._randomSeeds.length;e{e.preventDefault(),this._eventList.push(e)}).bind(this)}__init__(e,t){this._scene=t,e.oncontextmenu=function(e){return!1}}_onCanvasEvent(e){e.addEventListener("mousedown",this._pushEventList),e.addEventListener("mouseup",this._pushEventList,!0),e.addEventListener("mousemove",this._pushEventList,!0),e.addEventListener("touchstart",this._pushEventList),e.addEventListener("touchend",this._pushEventList,!0),e.addEventListener("touchmove",this._pushEventList,!0),e.addEventListener("touchcancel",this._pushEventList,!0)}_offCanvasEvent(e){e.removeEventListener("mousedown",this._pushEventList),e.removeEventListener("mouseup",this._pushEventList,!0),e.removeEventListener("mousemove",this._pushEventList,!0),e.removeEventListener("touchstart",this._pushEventList),e.removeEventListener("touchend",this._pushEventList,!0),e.removeEventListener("touchmove",this._pushEventList,!0),e.removeEventListener("touchcancel",this._pushEventList,!0),this._eventList.length=0,this._touches.length=0}touchCount(){return this._touches.length}get multiTouchEnabled(){return this._multiTouchEnabled}set multiTouchEnabled(e){this._multiTouchEnabled=e}_getTouch(e){var t=this._touchPool[e];return t||(t=new yt,this._touchPool[e]=t,t._identifier=e),t}_mouseTouchDown(){var e=this._mouseTouch,r=e.sprite;if(e._pressedSprite=r,e._pressedLoopCount=t.Stat.loopCount,r){var i=r._scripts;if(i)for(var n=0,a=i.length;n=0;s--){var o=e[s],l=o.viewport;if(r.x>=l.x&&r.y>=l.y&&r.x<=l.width&&r.y<=l.height)if(o.viewportPointToRay(r,i),this._scene._physicsSimulation.rayCast(i,t)||o.clearFlag===Q.CLEARFLAG_SOLIDCOLOR||o.clearFlag===Q.CLEARFLAG_SKY)break}var _=this._mouseTouch,h=_.sprite;if(t.succeeded){var c=t.collider.owner;_.sprite=c;var d=c._scripts;if(h!==c&&d)for(var u=0,f=d.length;u0){var o=!1;for(e=0;ec._pressedLoopCount){var u=d._scripts;if(u)for(i=0,n=u.length;i=r.zeroTolerance?(this._isTempEndVertex?(_=this._endIndex-1,h=c-this._subDistance[_],this._updateVerticesByPosition(i,s,c,_),this._owner._totalLength+=h):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(i,s,c,this._endIndex),this._owner._totalLength+=c,this._endIndex++),i.cloneTo(this._lastFixedVertexPosition),this._isTempEndVertex=!1):(this._isTempEndVertex?(_=this._endIndex-1,h=c-this._subDistance[_],this._updateVerticesByPosition(i,s,c,_),this._owner._totalLength+=h):(this._endIndex===this._segementCount&&this._resetData(),this._updateVerticesByPosition(i,s,c,this._endIndex),this._owner._totalLength+=c,this._endIndex++),this._isTempEndVertex=!0)}_updateVerticesByPositionData(e,r,i){var n=2*this._floatCountPerVertices1*i,s=this._owner._curtime;this._vertices1[n]=e.x,this._vertices1[n+1]=e.y,this._vertices1[n+2]=e.z,this._vertices1[n+3]=-r.x,this._vertices1[n+4]=-r.y,this._vertices1[n+5]=-r.z,this._vertices1[n+6]=s,this._vertices1[n+7]=1,this._vertices1[n+8]=e.x,this._vertices1[n+9]=e.y,this._vertices1[n+10]=e.z,this._vertices1[n+11]=r.x,this._vertices1[n+12]=r.y,this._vertices1[n+13]=r.z,this._vertices1[n+14]=s,this._vertices1[n+15]=0;var o=this._owner._owner.trailRenderer.bounds,l=o.getMin(),_=o.getMax(),h=$t._tempVector35,c=$t._tempVector36,d=$t._tempVector32;a.add(e,r,h),a.subtract(e,r,c),a.min(c,h,d),a.min(l,d,l),o.setMin(l),a.max(h,c,d),a.max(_,d,_),o.setMax(_),t.Render.supportWebGLPlusCulling&&this._calculateBoundingBoxForNative();var u=2*this._floatCountPerVertices1;this._vertexBuffer1.setData(this._vertices1.buffer,4*n,4*n,4*u)}_updateVerticesByPosition(e,t,r,i){this._updateVerticesByPositionData(e,t,i),this._subDistance[i]=r,this._subBirthTime[i]=this._owner._curtime}_updateVertexBufferUV(){var e,r,i;this._disappearBoundsMode&&(r=(e=this._owner._owner.trailRenderer.bounds).getMin(),i=e.getMax(),r.setValue(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i.setValue(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),t.Render.supportWebGLPlusCulling&&this._calculateBoundingBoxForNative());for(var n=this._endIndex,s=0,o=this._owner.colorGradient,l=o.colorAlphaKeysCount-1,_=o.colorRGBKeysCount-1,h=this._owner._totalLength,c=2*this._floatCountPerVertices2,d=this._activeIndex;d=this._owner.time+r.zeroTolerance;t++){var i=t+1;if(i!==e&&(this._owner._totalLength-=this._subDistance[i]),this._isTempEndVertex&&i===e-1){this._floatCountPerVertices1;var n=this._lastFixedVertexPosition;n.x=this._vertices1[0],n.y=this._vertices1[1],n.z=this._vertices1[2],this._isTempEndVertex=!1}this._activeIndex++,this._disappearBoundsMode=!0}}_getType(){return $t._type}_prepareRender(e){return this._endIndex-this._activeIndex>1}_render(e){this._bufferState.bind();var r=t.LayaGL.instance,i=2*this._activeIndex,n=2*this._endIndex-i;r.drawArrays(r.TRIANGLE_STRIP,i,n),t.Stat.renderBatches++,t.Stat.trianglesFaces+=n-2}destroy(){super.destroy();var e=this._vertexBuffer1._byteLength+this._vertexBuffer2._byteLength;t.Resource._addMemory(-e,-e),this._bufferState.destroy(),this._vertexBuffer1.destroy(),this._vertexBuffer2.destroy(),this._bufferState=null,this._vertices1=null,this._vertexBuffer1=null,this._vertices2=null,this._vertexBuffer2=null,this._subBirthTime=null,this._subDistance=null,this._lastFixedVertexPosition=null,this._disappearBoundsMode=!1}_calculateBoundingBoxForNative(){var e=this._owner._owner.trailRenderer,t=e.bounds,r=t.getMin(),i=t.getMax(),n=U._cullingBuffer;n[e._cullingBufferIndex+1]=r.x,n[e._cullingBufferIndex+2]=r.y,n[e._cullingBufferIndex+3]=r.z,n[e._cullingBufferIndex+4]=i.x,n[e._cullingBufferIndex+5]=i.y,n[e._cullingBufferIndex+6]=i.z}}$t.ALIGNMENT_VIEW=0,$t.ALIGNMENT_TRANSFORM_Z=1,$t._tempVector30=new a,$t._tempVector31=new a,$t._tempVector32=new a,$t._tempVector33=new a,$t._tempVector34=new a,$t._tempVector35=new a,$t._tempVector36=new a,$t._type=h._typeCounter++;class er{constructor(e){this._totalLength=0,this._lastPosition=new a,this._curtime=0,this.alignment=er.ALIGNMENT_VIEW,this._owner=e,this._initDefaultData(),this.addRenderElement()}get time(){return this._time}set time(e){this._time=e,this._owner._render._shaderValues.setNumber(er.LIFETIME,e)}get minVertexDistance(){return this._minVertexDistance}set minVertexDistance(e){this._minVertexDistance=e}get widthMultiplier(){return this._widthMultiplier}set widthMultiplier(e){this._widthMultiplier=e}get widthCurve(){return this._widthCurve}set widthCurve(e){this._widthCurve=e;var t,r,i=new Float32Array(4*e.length),n=0;for(t=0,r=e.length;t0?(l.name=u=u.substr(0,u.length-3),l.isArray=!0):(l.name=u,l.isArray=!1),l.type=d.type,this._addShaderUnifiormFun(l);var f=this._uniformMap[u];if(null!=f)switch(l.dataOffset=L.propertyNameToID(u),f){case L.PERIOD_CUSTOM:o.push(l);break;case L.PERIOD_MATERIAL:s.push(l);break;case L.PERIOD_SPRITE:a.push(l);break;case L.PERIOD_CAMERA:n.push(l);break;case L.PERIOD_SCENE:i.push(l);break;default:throw new Error("Shader3D: period is unkonw.")}}for(this._sceneUniformParamsMap=t.LayaGL.instance.createCommandEncoder(4*i.length*5+4,64,!0),_=0,h=i.length;_e);n++){e&i&&(r[t[i]]="")}return r}_compileToTree(e,r,i,n,a){var s,o,l,_,h,c,d,u,f,E,T;for(f=i;f=0&&(l=l.substr(0,c)),s=u||new t.ShaderNode(n),u=null,s.text=l,(c=l.indexOf("#"))>=0){for(_="#",T=c+1,E=l.length;T0&&t.ShaderCompile.splitToWords(l,o),u=s,o.text+="\n"+l;continue}n.length>0&&t.ShaderCompile.splitToWords(l,s)}s.setParent(e)}}withCompile(e,r,i){var n,a,s;if(e&=this._publicValidDefine,r&=this._spriteValidDefine,i&=this._materialValidDefine,a=this._cacheSharders[e])if(s=a[r]){if(n=s[i])return n}else s=a[r]=[];else s=(a=this._cacheSharders[e]=[])[r]=[];var o,l=this._definesToNameDic(e,this._owner._publicDefines),_=this._definesToNameDic(r,this._owner._spriteDefines),h=this._definesToNameDic(i,this._owner._materialDefines);if(L.debugMode){var c="";for(o in l)c+=o+" ";var d="";for(o in _)d+=o+" ";var u="";for(o in h)u+=o+" ";t.WebGL.shaderHighPrecision||(e+=L.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:"+e+" SpriteDefine:"+r+" MaterialDefine:"+i+" PublicDefineGroup:"+c+" SpriteDefineGroup:"+d+"MaterialDefineGroup: "+u+")---ShaderCompile3DDebugMode","color:green")}var f={},E="";if(l)for(o in l)E+="#define "+o+"\n",f[o]=!0;if(_)for(o in _)E+="#define "+o+"\n",f[o]=!0;if(h)for(o in h)E+="#define "+o+"\n",f[o]=!0;var T=this._VS.toscript(f,[]),m="";0==T[0].indexOf("#version")&&(m=T[0]+"\n",T.shift());var p=this._PS.toscript(f,[]),g="";return 0==p[0].indexOf("#version")&&(g=p[0]+"\n",p.shift()),n=new nr(m+E+T.join("\n"),g+E+p.join("\n"),this._owner._attributeMap||this._owner._owner._attributeMap,this._owner._uniformMap||this._owner._owner._uniformMap,this),s[i]=n,n}}class sr{constructor(e,t,r=null,i=null){this._flags={},this._passes=[],this._publicDefines=[],this._publicDefinesMap={},this._spriteDefines=[],this._spriteDefinesMap={},this._materialDefines=[],this._materialDefinesMap={},this._addDefines(this._publicDefines,this._publicDefinesMap,L._globleDefines),r&&this._addDefines(this._spriteDefines,this._spriteDefinesMap,r.defines),i&&this._addDefines(this._materialDefines,this._materialDefinesMap,i.defines),this._attributeMap=e,this._uniformMap=t}_addDefines(e,t,r){for(var i in r){var n=r[i],a=parseInt(i);e[a]=n,t[n]=a}}getMaterialDefineByName(e){return this._materialDefinesMap[e]}setFlag(e,t){t?this._flags[e]=t:delete this._flags[e]}getFlag(e){return this._flags[e]}addShaderPass(e,t,r=null){var i=new ar(this,e,t,r);return this._passes.push(i),i}}var or="#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",lr='#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}',_r="#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",hr='#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}',cr='#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',dr='#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}',ur="\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",fr="#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",Er='#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}',Tr='#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",Xr="#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 ",Yr='#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',Zr="#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",jr='#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}',qr='#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',Kr='#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 Qr{constructor(){}static __init__(){Qr._rangeAttenTex=M._buildTexture2D(1024,1,t.BaseTexture.FORMAT_ALPHA8,x.lightAttenTexture),Qr._rangeAttenTex.wrapModeU=t.BaseTexture.WARPMODE_CLAMP,Qr._rangeAttenTex.wrapModeV=t.BaseTexture.WARPMODE_CLAMP,Qr._rangeAttenTex.lock=!0,L.SHADERDEFINE_HIGHPRECISION=L.registerPublicDefine("HIGHPRECISION"),L.addInclude("Lighting.glsl",ur),L.addInclude("ShadowHelper.glsl",Gr),L.addInclude("BRDF.glsl",Sr),L.addInclude("PBRUtils.glsl",Ar),L.addInclude("PBRStandardLighting.glsl",Rr),L.addInclude("PBRSpecularLighting.glsl",vr),L.addInclude("Colors.glsl",Vr),L.addInclude("Sampling.glsl",Br),L.addInclude("StdLib.glsl",Ur);var e={a_Position:v.MESH_POSITION0,a_Color:v.MESH_COLOR0,a_Normal:v.MESH_NORMAL0,a_Texcoord0:v.MESH_TEXTURECOORDINATE0,a_Texcoord1:v.MESH_TEXTURECOORDINATE1,a_BoneWeights:v.MESH_BLENDWEIGHT0,a_BoneIndices:v.MESH_BLENDINDICES0,a_Tangent0:v.MESH_TANGENT0,a_MvpMatrix:v.MESH_MVPMATRIX_ROW0,a_WorldMat:v.MESH_WORLDMATRIX_ROW0},r={u_Bones:L.PERIOD_CUSTOM,u_DiffuseTexture:L.PERIOD_MATERIAL,u_SpecularTexture:L.PERIOD_MATERIAL,u_NormalTexture:L.PERIOD_MATERIAL,u_AlphaTestValue:L.PERIOD_MATERIAL,u_DiffuseColor:L.PERIOD_MATERIAL,u_MaterialSpecular:L.PERIOD_MATERIAL,u_Shininess:L.PERIOD_MATERIAL,u_TilingOffset:L.PERIOD_MATERIAL,u_WorldMat:L.PERIOD_SPRITE,u_MvpMatrix:L.PERIOD_SPRITE,u_LightmapScaleOffset:L.PERIOD_SPRITE,u_LightMap:L.PERIOD_SPRITE,u_CameraPos:L.PERIOD_CAMERA,u_ReflectTexture:L.PERIOD_SCENE,u_ReflectIntensity:L.PERIOD_SCENE,u_FogStart:L.PERIOD_SCENE,u_FogRange:L.PERIOD_SCENE,u_FogColor:L.PERIOD_SCENE,"u_DirectionLight.Color":L.PERIOD_SCENE,"u_DirectionLight.Direction":L.PERIOD_SCENE,"u_PointLight.Position":L.PERIOD_SCENE,"u_PointLight.Range":L.PERIOD_SCENE,"u_PointLight.Color":L.PERIOD_SCENE,"u_SpotLight.Position":L.PERIOD_SCENE,"u_SpotLight.Direction":L.PERIOD_SCENE,"u_SpotLight.Range":L.PERIOD_SCENE,"u_SpotLight.Spot":L.PERIOD_SCENE,"u_SpotLight.Color":L.PERIOD_SCENE,u_AmbientColor:L.PERIOD_SCENE,u_shadowMap1:L.PERIOD_SCENE,u_shadowMap2:L.PERIOD_SCENE,u_shadowMap3:L.PERIOD_SCENE,u_shadowPSSMDistance:L.PERIOD_SCENE,u_lightShadowVP:L.PERIOD_SCENE,u_shadowPCFoffset:L.PERIOD_SCENE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("BLINNPHONG",null,null,!0),a=new sr(e,r,Yt.shaderDefines,He.shaderDefines);n.addSubShader(a),a.addShaderPass(mr,Tr,i),e={a_Position:v.MESH_POSITION0,a_Color:v.MESH_COLOR0},r={u_MvpMatrix:L.PERIOD_SPRITE,u_Color:L.PERIOD_MATERIAL},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("LineShader"),a=new sr(e,r),n.addSubShader(a),a.addShaderPass(Er,fr,i),e={a_Position:v.MESH_POSITION0,a_Normal:v.MESH_NORMAL0,a_Tangent0:v.MESH_TANGENT0,a_Texcoord0:v.MESH_TEXTURECOORDINATE0,a_BoneWeights:v.MESH_BLENDWEIGHT0,a_BoneIndices:v.MESH_BLENDINDICES0,a_MvpMatrix:v.MESH_MVPMATRIX_ROW0,a_WorldMat:v.MESH_WORLDMATRIX_ROW0},r={u_Bones:L.PERIOD_CUSTOM,u_MvpMatrix:L.PERIOD_SPRITE,u_WorldMat:L.PERIOD_SPRITE,u_CameraPos:L.PERIOD_CAMERA,u_AlphaTestValue:L.PERIOD_MATERIAL,u_AlbedoColor:L.PERIOD_MATERIAL,u_EmissionColor:L.PERIOD_MATERIAL,u_AlbedoTexture:L.PERIOD_MATERIAL,u_NormalTexture:L.PERIOD_MATERIAL,u_ParallaxTexture:L.PERIOD_MATERIAL,u_MetallicGlossTexture:L.PERIOD_MATERIAL,u_OcclusionTexture:L.PERIOD_MATERIAL,u_EmissionTexture:L.PERIOD_MATERIAL,u_metallic:L.PERIOD_MATERIAL,u_smoothness:L.PERIOD_MATERIAL,u_smoothnessScale:L.PERIOD_MATERIAL,u_occlusionStrength:L.PERIOD_MATERIAL,u_normalScale:L.PERIOD_MATERIAL,u_parallaxScale:L.PERIOD_MATERIAL,u_TilingOffset:L.PERIOD_MATERIAL,"u_DirectionLight.Direction":L.PERIOD_SCENE,"u_DirectionLight.Color":L.PERIOD_SCENE,u_PointLightMatrix:L.PERIOD_SCENE,"u_PointLight.Position":L.PERIOD_SCENE,"u_PointLight.Range":L.PERIOD_SCENE,"u_PointLight.Color":L.PERIOD_SCENE,"u_SpotLight.Position":L.PERIOD_SCENE,"u_SpotLight.Direction":L.PERIOD_SCENE,"u_SpotLight.Range":L.PERIOD_SCENE,"u_SpotLight.SpotAngle":L.PERIOD_SCENE,"u_SpotLight.Color":L.PERIOD_SCENE,u_RangeTexture:L.PERIOD_SCENE,u_ReflectTexture:L.PERIOD_SCENE,u_ReflectIntensity:L.PERIOD_SCENE,u_AmbientColor:L.PERIOD_SCENE,u_shadowMap1:L.PERIOD_SCENE,u_shadowMap2:L.PERIOD_SCENE,u_shadowMap3:L.PERIOD_SCENE,u_shadowPSSMDistance:L.PERIOD_SCENE,u_lightShadowVP:L.PERIOD_SCENE,u_shadowPCFoffset:L.PERIOD_SCENE,u_FogStart:L.PERIOD_SCENE,u_FogRange:L.PERIOD_SCENE,u_FogColor:L.PERIOD_SCENE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("PBRStandard",null,null,!0),a=new sr(e,r,Yt.shaderDefines,Gt.shaderDefines),n.addSubShader(a),a.addShaderPass(Mr,xr,i),e={a_Position:v.MESH_POSITION0,a_Normal:v.MESH_NORMAL0,a_Tangent0:v.MESH_TANGENT0,a_Texcoord0:v.MESH_TEXTURECOORDINATE0,a_BoneWeights:v.MESH_BLENDWEIGHT0,a_BoneIndices:v.MESH_BLENDINDICES0,a_MvpMatrix:v.MESH_MVPMATRIX_ROW0,a_WorldMat:v.MESH_WORLDMATRIX_ROW0},r={u_Bones:L.PERIOD_CUSTOM,u_MvpMatrix:L.PERIOD_SPRITE,u_WorldMat:L.PERIOD_SPRITE,u_CameraPos:L.PERIOD_CAMERA,u_AlphaTestValue:L.PERIOD_MATERIAL,u_AlbedoColor:L.PERIOD_MATERIAL,u_SpecularColor:L.PERIOD_MATERIAL,u_EmissionColor:L.PERIOD_MATERIAL,u_AlbedoTexture:L.PERIOD_MATERIAL,u_NormalTexture:L.PERIOD_MATERIAL,u_ParallaxTexture:L.PERIOD_MATERIAL,u_SpecularTexture:L.PERIOD_MATERIAL,u_OcclusionTexture:L.PERIOD_MATERIAL,u_EmissionTexture:L.PERIOD_MATERIAL,u_smoothness:L.PERIOD_MATERIAL,u_smoothnessScale:L.PERIOD_MATERIAL,u_occlusionStrength:L.PERIOD_MATERIAL,u_normalScale:L.PERIOD_MATERIAL,u_parallaxScale:L.PERIOD_MATERIAL,u_TilingOffset:L.PERIOD_MATERIAL,"u_DirectionLight.Direction":L.PERIOD_SCENE,"u_DirectionLight.Color":L.PERIOD_SCENE,u_PointLightMatrix:L.PERIOD_SCENE,"u_PointLight.Position":L.PERIOD_SCENE,"u_PointLight.Range":L.PERIOD_SCENE,"u_PointLight.Color":L.PERIOD_SCENE,"u_SpotLight.Position":L.PERIOD_SCENE,"u_SpotLight.Direction":L.PERIOD_SCENE,"u_SpotLight.Range":L.PERIOD_SCENE,"u_SpotLight.SpotAngle":L.PERIOD_SCENE,"u_SpotLight.Color":L.PERIOD_SCENE,u_RangeTexture:L.PERIOD_SCENE,u_ReflectTexture:L.PERIOD_SCENE,u_ReflectIntensity:L.PERIOD_SCENE,u_AmbientColor:L.PERIOD_SCENE,u_shadowMap1:L.PERIOD_SCENE,u_shadowMap2:L.PERIOD_SCENE,u_shadowMap3:L.PERIOD_SCENE,u_shadowPSSMDistance:L.PERIOD_SCENE,u_lightShadowVP:L.PERIOD_SCENE,u_shadowPCFoffset:L.PERIOD_SCENE,u_FogStart:L.PERIOD_SCENE,u_FogRange:L.PERIOD_SCENE,u_FogColor:L.PERIOD_SCENE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("PBRSpecular",null,null,!0),a=new sr(e,r,Yt.shaderDefines,Ut.shaderDefines),n.addSubShader(a),a.addShaderPass(Ir,Dr,i),e={a_Position:v.MESH_POSITION0,a_Color:v.MESH_COLOR0,a_Texcoord0:v.MESH_TEXTURECOORDINATE0,a_BoneWeights:v.MESH_BLENDWEIGHT0,a_BoneIndices:v.MESH_BLENDINDICES0,a_MvpMatrix:v.MESH_MVPMATRIX_ROW0},r={u_Bones:L.PERIOD_CUSTOM,u_AlbedoTexture:L.PERIOD_MATERIAL,u_AlbedoColor:L.PERIOD_MATERIAL,u_TilingOffset:L.PERIOD_MATERIAL,u_AlphaTestValue:L.PERIOD_MATERIAL,u_MvpMatrix:L.PERIOD_SPRITE,u_FogStart:L.PERIOD_SCENE,u_FogRange:L.PERIOD_SCENE,u_FogColor:L.PERIOD_SCENE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("Unlit",null,null,!0),a=new sr(e,r,Yt.shaderDefines,Ht.shaderDefines),n.addSubShader(a),a.addShaderPass(jr,Zr,i),e={a_Position:v.MESH_POSITION0,a_Texcoord0:v.MESH_TEXTURECOORDINATE0,a_BoneWeights:v.MESH_BLENDWEIGHT0,a_BoneIndices:v.MESH_BLENDINDICES0,a_MvpMatrix:v.MESH_MVPMATRIX_ROW0},r={u_Bones:L.PERIOD_CUSTOM,u_AlbedoTexture:L.PERIOD_MATERIAL,u_AlbedoColor:L.PERIOD_MATERIAL,u_TilingOffset:L.PERIOD_MATERIAL,u_AlphaTestValue:L.PERIOD_MATERIAL,u_MvpMatrix:L.PERIOD_SPRITE,u_FogStart:L.PERIOD_SCENE,u_FogRange:L.PERIOD_SCENE,u_FogColor:L.PERIOD_SCENE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("Effect",null,null,!0),a=new sr(e,r,Yt.shaderDefines,Ft.shaderDefines),n.addSubShader(a),a.addShaderPass(hr,_r,i),e={a_CornerTextureCoordinate:tt.PARTICLE_CORNERTEXTURECOORDINATE0,a_MeshPosition:tt.PARTICLE_POSITION0,a_MeshColor:tt.PARTICLE_COLOR0,a_MeshTextureCoordinate:tt.PARTICLE_TEXTURECOORDINATE0,a_ShapePositionStartLifeTime:tt.PARTICLE_SHAPEPOSITIONSTARTLIFETIME,a_DirectionTime:tt.PARTICLE_DIRECTIONTIME,a_StartColor:tt.PARTICLE_STARTCOLOR0,a_EndColor:tt.PARTICLE_ENDCOLOR0,a_StartSize:tt.PARTICLE_STARTSIZE,a_StartRotation0:tt.PARTICLE_STARTROTATION,a_StartSpeed:tt.PARTICLE_STARTSPEED,a_Random0:tt.PARTICLE_RANDOM0,a_Random1:tt.PARTICLE_RANDOM1,a_SimulationWorldPostion:tt.PARTICLE_SIMULATIONWORLDPOSTION,a_SimulationWorldRotation:tt.PARTICLE_SIMULATIONWORLDROTATION},r={u_Tintcolor:L.PERIOD_MATERIAL,u_TilingOffset:L.PERIOD_MATERIAL,u_texture:L.PERIOD_MATERIAL,u_WorldPosition:L.PERIOD_SPRITE,u_WorldRotation:L.PERIOD_SPRITE,u_PositionScale:L.PERIOD_SPRITE,u_SizeScale:L.PERIOD_SPRITE,u_ScalingMode:L.PERIOD_SPRITE,u_Gravity:L.PERIOD_SPRITE,u_ThreeDStartRotation:L.PERIOD_SPRITE,u_StretchedBillboardLengthScale:L.PERIOD_SPRITE,u_StretchedBillboardSpeedScale:L.PERIOD_SPRITE,u_SimulationSpace:L.PERIOD_SPRITE,u_CurrentTime:L.PERIOD_SPRITE,u_ColorOverLifeGradientAlphas:L.PERIOD_SPRITE,u_ColorOverLifeGradientColors:L.PERIOD_SPRITE,u_MaxColorOverLifeGradientAlphas:L.PERIOD_SPRITE,u_MaxColorOverLifeGradientColors:L.PERIOD_SPRITE,u_VOLVelocityConst:L.PERIOD_SPRITE,u_VOLVelocityGradientX:L.PERIOD_SPRITE,u_VOLVelocityGradientY:L.PERIOD_SPRITE,u_VOLVelocityGradientZ:L.PERIOD_SPRITE,u_VOLVelocityConstMax:L.PERIOD_SPRITE,u_VOLVelocityGradientMaxX:L.PERIOD_SPRITE,u_VOLVelocityGradientMaxY:L.PERIOD_SPRITE,u_VOLVelocityGradientMaxZ:L.PERIOD_SPRITE,u_VOLSpaceType:L.PERIOD_SPRITE,u_SOLSizeGradient:L.PERIOD_SPRITE,u_SOLSizeGradientX:L.PERIOD_SPRITE,u_SOLSizeGradientY:L.PERIOD_SPRITE,u_SOLSizeGradientZ:L.PERIOD_SPRITE,u_SOLSizeGradientMax:L.PERIOD_SPRITE,u_SOLSizeGradientMaxX:L.PERIOD_SPRITE,u_SOLSizeGradientMaxY:L.PERIOD_SPRITE,u_SOLSizeGradientMaxZ:L.PERIOD_SPRITE,u_ROLAngularVelocityConst:L.PERIOD_SPRITE,u_ROLAngularVelocityConstSeprarate:L.PERIOD_SPRITE,u_ROLAngularVelocityGradient:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientX:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientY:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientZ:L.PERIOD_SPRITE,u_ROLAngularVelocityConstMax:L.PERIOD_SPRITE,u_ROLAngularVelocityConstMaxSeprarate:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientMax:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxX:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxY:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxZ:L.PERIOD_SPRITE,u_ROLAngularVelocityGradientMaxW:L.PERIOD_SPRITE,u_TSACycles:L.PERIOD_SPRITE,u_TSASubUVLength:L.PERIOD_SPRITE,u_TSAGradientUVs:L.PERIOD_SPRITE,u_TSAMaxGradientUVs:L.PERIOD_SPRITE,u_CameraPos:L.PERIOD_CAMERA,u_CameraDirection:L.PERIOD_CAMERA,u_CameraUp:L.PERIOD_CAMERA,u_View:L.PERIOD_CAMERA,u_Projection:L.PERIOD_CAMERA,u_FogStart:L.PERIOD_SCENE,u_FogRange:L.PERIOD_SCENE,u_FogColor:L.PERIOD_SCENE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("PARTICLESHURIKEN"),a=new sr(e,r,xt.shaderDefines,qe.shaderDefines),n.addSubShader(a),a.addShaderPass(gr,pr,i),e={a_Position:v.MESH_POSITION0},r={u_TintColor:L.PERIOD_MATERIAL,u_Exposure:L.PERIOD_MATERIAL,u_Rotation:L.PERIOD_MATERIAL,u_CubeTexture:L.PERIOD_MATERIAL,u_ViewProjection:L.PERIOD_CAMERA},n=L.add("SkyBox"),a=new sr(e,r),n.addSubShader(a),a.addShaderPass(Hr,zr),e={a_Position:v.MESH_POSITION0},r={u_SunSize:L.PERIOD_MATERIAL,u_SunSizeConvergence:L.PERIOD_MATERIAL,u_AtmosphereThickness:L.PERIOD_MATERIAL,u_SkyTint:L.PERIOD_MATERIAL,u_GroundTint:L.PERIOD_MATERIAL,u_Exposure:L.PERIOD_MATERIAL,u_ViewProjection:L.PERIOD_CAMERA,"u_DirectionLight.Direction":L.PERIOD_SCENE,"u_DirectionLight.Color":L.PERIOD_SCENE},n=L.add("SkyBoxProcedural"),a=new sr(e,r,null,zt.shaderDefines),n.addSubShader(a),a.addShaderPass(kr,Wr),e={a_Position:v.MESH_POSITION0,a_Normal:v.MESH_NORMAL0,a_Texcoord0:v.MESH_TEXTURECOORDINATE0},r={u_MvpMatrix:L.PERIOD_SPRITE,u_WorldMat:L.PERIOD_SPRITE,u_CameraPos:L.PERIOD_CAMERA,u_LightmapScaleOffset:L.PERIOD_SPRITE,u_LightMap:L.PERIOD_SPRITE,u_SplatAlphaTexture:L.PERIOD_MATERIAL,u_DiffuseTexture1:L.PERIOD_MATERIAL,u_DiffuseTexture2:L.PERIOD_MATERIAL,u_DiffuseTexture3:L.PERIOD_MATERIAL,u_DiffuseTexture4:L.PERIOD_MATERIAL,u_DiffuseTexture5:L.PERIOD_MATERIAL,u_DiffuseScaleOffset1:L.PERIOD_MATERIAL,u_DiffuseScaleOffset2:L.PERIOD_MATERIAL,u_DiffuseScaleOffset3:L.PERIOD_MATERIAL,u_DiffuseScaleOffset4:L.PERIOD_MATERIAL,u_DiffuseScaleOffset5:L.PERIOD_MATERIAL,u_FogStart:L.PERIOD_SCENE,u_FogRange:L.PERIOD_SCENE,u_FogColor:L.PERIOD_SCENE,"u_DirectionLight.Direction":L.PERIOD_SCENE,"u_DirectionLight.Color":L.PERIOD_SCENE,"u_PointLight.Position":L.PERIOD_SCENE,"u_PointLight.Range":L.PERIOD_SCENE,"u_PointLight.Attenuation":L.PERIOD_SCENE,"u_PointLight.Color":L.PERIOD_SCENE,"u_SpotLight.Position":L.PERIOD_SCENE,"u_SpotLight.Direction":L.PERIOD_SCENE,"u_SpotLight.Range":L.PERIOD_SCENE,"u_SpotLight.Spot":L.PERIOD_SCENE,"u_SpotLight.Color":L.PERIOD_SCENE,u_AmbientColor:L.PERIOD_SCENE,u_shadowMap1:L.PERIOD_SCENE,u_shadowMap2:L.PERIOD_SCENE,u_shadowMap3:L.PERIOD_SCENE,u_shadowPSSMDistance:L.PERIOD_SCENE,u_lightShadowVP:L.PERIOD_SCENE,u_shadowPCFoffset:L.PERIOD_SCENE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("ExtendTerrain"),a=new sr(e,r,F.shaderDefines,Bt.shaderDefines),n.addSubShader(a),a.addShaderPass(dr,cr,i),e={a_Position:Jt.TRAIL_POSITION0,a_OffsetVector:Jt.TRAIL_OFFSETVECTOR,a_Texcoord0X:Jt.TRAIL_TEXTURECOORDINATE0X,a_Texcoord0Y:Jt.TRAIL_TEXTURECOORDINATE0Y,a_BirthTime:Jt.TRAIL_TIME0,a_Color:Jt.TRAIL_COLOR},r={u_MvpMatrix:L.PERIOD_SPRITE,u_View:L.PERIOD_CAMERA,u_Projection:L.PERIOD_CAMERA,u_TilingOffset:L.PERIOD_MATERIAL,u_MainTexture:L.PERIOD_MATERIAL,u_MainColor:L.PERIOD_MATERIAL,u_CurTime:L.PERIOD_SPRITE,u_LifeTime:L.PERIOD_SPRITE,u_WidthCurve:L.PERIOD_SPRITE,u_WidthCurveKeyLength:L.PERIOD_SPRITE,u_GradientColorkey:L.PERIOD_SPRITE,u_GradientAlphakey:L.PERIOD_SPRITE},i={s_Cull:L.RENDER_STATE_CULL,s_Blend:L.RENDER_STATE_BLEND,s_BlendSrc:L.RENDER_STATE_BLEND_SRC,s_BlendDst:L.RENDER_STATE_BLEND_DST,s_DepthTest:L.RENDER_STATE_DEPTH_TEST,s_DepthWrite:L.RENDER_STATE_DEPTH_WRITE},n=L.add("Trail"),a=new sr(e,r,rr.shaderDefines,Zt.shaderDefines),n.addSubShader(a),a.addShaderPass(Yr,Xr,i),e={a_Position:v.MESH_POSITION0,a_Normal:v.MESH_NORMAL0,a_Tangent0:v.MESH_TANGENT0},r={u_MvpMatrix:L.PERIOD_SPRITE,u_WorldMat:L.PERIOD_SPRITE,u_CameraPos:L.PERIOD_CAMERA,u_Time:L.PERIOD_SCENE,u_MainTexture:L.PERIOD_MATERIAL,u_NormalTexture:L.PERIOD_MATERIAL,u_HorizonColor:L.PERIOD_MATERIAL,u_WaveScale:L.PERIOD_MATERIAL,u_WaveSpeed:L.PERIOD_MATERIAL},n=L.add("WaterPrimary"),a=new sr(e,r,null,Wt.shaderDefines),n.addSubShader(a),a.addShaderPass(Kr,qr),e={a_PositionTexcoord:v.MESH_POSITION0},r={u_MainTex:L.PERIOD_MATERIAL},n=L.add("BlitScreen"),a=new sr(e,r,null,null),n.addSubShader(a);var s=a.addShaderPass(lr,or),o=s.renderState;o.depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE,e={a_PositionTexcoord:v.MESH_POSITION0},r={u_MainTex:L.PERIOD_MATERIAL,u_BloomTex:L.PERIOD_MATERIAL,u_AutoExposureTex:L.PERIOD_MATERIAL,u_MainTex_TexelSize:L.PERIOD_MATERIAL,u_SampleScale:L.PERIOD_MATERIAL,u_Threshold:L.PERIOD_MATERIAL,u_Params:L.PERIOD_MATERIAL},n=L.add("PostProcessBloom",e,r),a=new sr(null,null,null,null),n.addSubShader(a),(o=(s=a.addShaderPass(Lr,Or)).renderState).depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE,a=new sr(null,null,null,null),n.addSubShader(a),(o=(s=a.addShaderPass(Lr,Nr)).renderState).depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE,a=new sr(null,null,null,null),n.addSubShader(a),(o=(s=a.addShaderPass(Lr,Cr)).renderState).depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE,a=new sr(null,null,null,null),n.addSubShader(a),(o=(s=a.addShaderPass(Lr,yr)).renderState).depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE,a=new sr(null,null,null,null),n.addSubShader(a),(o=(s=a.addShaderPass(Lr,wr)).renderState).depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE,a=new sr(null,null,null,null),n.addSubShader(a),(o=(s=a.addShaderPass(Lr,Pr)).renderState).depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE,e={a_PositionTexcoord:v.MESH_POSITION0},r={u_MainTex:L.PERIOD_MATERIAL,u_BloomTex:L.PERIOD_MATERIAL,u_AutoExposureTex:L.PERIOD_MATERIAL,u_Bloom_DirtTileOffset:L.PERIOD_MATERIAL,u_Bloom_DirtTex:L.PERIOD_MATERIAL,u_BloomTex_TexelSize:L.PERIOD_MATERIAL,u_Bloom_Settings:L.PERIOD_MATERIAL,u_Bloom_Color:L.PERIOD_MATERIAL},n=L.add("PostProcessComposite",e,r),a=new sr(null,null,null,bt.shaderDefines),n.addSubShader(a),(o=(s=a.addShaderPass(Fr,br)).renderState).depthTest=ze.DEPTHTEST_ALWAYS,o.depthWrite=!1,o.cull=ze.CULL_NONE,o.blend=ze.BLEND_DISABLE}}class Jr extends Ge{constructor(){super(),this.setShaderName("LineShader"),this._shaderValues.setVector(Jr.COLOR,new n(1,1,1,1))}static __initDefine__(){Jr.shaderDefines=new C(Ge.shaderDefines)}get color(){return this._shaderValues.getVector(Jr.COLOR)}set color(e){this._shaderValues.setVector(Jr.COLOR,e)}set depthWrite(e){this._shaderValues.setBool(Jr.DEPTH_WRITE,e)}get depthWrite(){return this._shaderValues.getBool(Jr.DEPTH_WRITE)}set cull(e){this._shaderValues.setInt(Jr.CULL,e)}get cull(){return this._shaderValues.getInt(Jr.CULL)}set blend(e){this._shaderValues.setInt(Jr.BLEND,e)}get blend(){return this._shaderValues.getInt(Jr.BLEND)}set blendSrc(e){this._shaderValues.setInt(Jr.BLEND_SRC,e)}get blendSrc(){return this._shaderValues.getInt(Jr.BLEND_SRC)}set blendDst(e){this._shaderValues.setInt(Jr.BLEND_DST,e)}get blendDst(){return this._shaderValues.getInt(Jr.BLEND_DST)}set depthTest(e){this._shaderValues.setInt(Jr.DEPTH_TEST,e)}get depthTest(){return this._shaderValues.getInt(Jr.DEPTH_TEST)}clone(){var e=new Jr;return this.cloneTo(e),e}}Jr.COLOR=L.propertyNameToID("u_Color"),Jr.shaderDefines=null,Jr.CULL=L.propertyNameToID("s_Cull"),Jr.BLEND=L.propertyNameToID("s_Blend"),Jr.BLEND_SRC=L.propertyNameToID("s_BlendSrc"),Jr.BLEND_DST=L.propertyNameToID("s_BlendDst"),Jr.DEPTH_TEST=L.propertyNameToID("s_DepthTest"),Jr.DEPTH_WRITE=L.propertyNameToID("s_DepthWrite");class $r{static get vertexDeclaration(){return $r._vertexDeclaration}static __init__(){$r._vertexDeclaration=new g(28,[new S(0,u.Vector3,v.MESH_POSITION0),new S(12,u.Vector4,v.MESH_COLOR0)])}get vertexDeclaration(){return $r._vertexDeclaration}constructor(){}}class ei extends h{constructor(e,r){super(),this._floatCountPerVertices=7,this._minUpdate=Number.MAX_VALUE,this._maxUpdate=Number.MIN_VALUE,this._bufferState=new _,this._maxLineCount=0,this._lineCount=0;var i=2*r;this._owner=e,this._maxLineCount=r,this._vertices=new Float32Array(i*this._floatCountPerVertices),this._vertexBuffer=new d($r.vertexDeclaration.vertexStride*i,t.LayaGL.instance.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=$r.vertexDeclaration,this._bufferState.bind(),this._bufferState.applyVertexBuffer(this._vertexBuffer),this._bufferState.unBind()}_getType(){return ei._type}_resizeLineData(e){var r=2*e,i=this._vertices;this._vertexBuffer.destroy(),this._maxLineCount=e;var n=r*this._floatCountPerVertices;this._vertices=new Float32Array(n),this._vertexBuffer=new d($r.vertexDeclaration.vertexStride*r,t.LayaGL.instance.STATIC_DRAW,!1),this._vertexBuffer.vertexDeclaration=$r.vertexDeclaration,n0){this._bufferState.bind();var r=t.LayaGL.instance;r.drawArrays(r.LINES,0,2*this._lineCount),t.Stat.renderBatches++}}destroy(){this._destroyed||(super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferState=null,this._vertexBuffer=null,this._vertices=null)}}ei._type=h._typeCounter++;class ti extends ke{constructor(e){super(e),this._projectionViewWorldMatrix=new T,this._supportOctree=!1}_calculateBoundingBox(){if((e=this._bounds.getMin()).x=-Number.MAX_VALUE,e.y=-Number.MAX_VALUE,e.z=-Number.MAX_VALUE,this._bounds.setMin(e),(r=this._bounds.getMax()).x=Number.MAX_VALUE,r.y=Number.MAX_VALUE,r.z=Number.MAX_VALUE,this._bounds.setMax(r),t.Render.supportWebGLPlusCulling){var e=this._bounds.getMin(),r=this._bounds.getMax(),i=U._cullingBuffer;i[this._cullingBufferIndex+1]=e.x,i[this._cullingBufferIndex+2]=e.y,i[this._cullingBufferIndex+3]=e.z,i[this._cullingBufferIndex+4]=r.x,i[this._cullingBufferIndex+5]=r.y,i[this._cullingBufferIndex+6]=r.z}}_renderUpdateWithCamera(e,t){var r=e.projectionViewMatrix,i=this._shaderValues;if(t){var n=t.worldMatrix;i.setMatrix4x4(b.WORLDMATRIX,n),T.multiply(r,n,this._projectionViewWorldMatrix),i.setMatrix4x4(b.MVPMATRIX,this._projectionViewWorldMatrix)}else i.setMatrix4x4(b.WORLDMATRIX,T.DEFAULT),i.setMatrix4x4(b.MVPMATRIX,r)}}class ri extends F{get maxLineCount(){return this._geometryFilter._maxLineCount}set maxLineCount(e){this._geometryFilter._resizeLineData(e),this._geometryFilter._lineCount=Math.min(this._geometryFilter._lineCount,e)}get lineCount(){return this._geometryFilter._lineCount}set lineCount(e){if(e>this.maxLineCount)throw"PixelLineSprite3D: lineCount can't large than maxLineCount";this._geometryFilter._lineCount=e}get pixelLineRenderer(){return this._render}constructor(e=2,t=null){super(t),this._geometryFilter=new ei(this,e),this._render=new ti(this),this._changeRenderObjects(this._render,0,Jr.defaultMaterial)}_changeRenderObjects(e,t,r){var i=this._render._renderElements;r||(r=Jr.defaultMaterial);var n=i[t];n||(n=i[t]=new le),n.setTransform(this._transform),n.setGeometry(this._geometryFilter),n.render=this._render,n.material=r}addLine(e,t,r,i){if(this._geometryFilter._lineCount===this._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount has equal with maxLineCount.";this._geometryFilter._updateLineData(this._geometryFilter._lineCount++,e,t,r,i)}addLines(e){var t=this._geometryFilter._lineCount,r=e.length;if(t+r>this._geometryFilter._maxLineCount)throw"PixelLineSprite3D: lineCount plus lines count must less than maxLineCount.";this._geometryFilter._updateLineDatas(t,e),this._geometryFilter._lineCount+=r}removeLine(e){if(!(e0;)t--;if(e1){var r=this._partitionRenderObject(e,t),i=r-1;e=0;i--){var n=r[i];this._objects.push(n),n._setOctreeNode(this)}}}this._children=null}_merge(){if(null===this._children){var e=this._parent;e&&e._shouldMerge()&&(e._mergeChildren(),e._merge())}}_checkAddNode(e){if(null==this._children){if(this._objects.length=0;t--){var r=this._objects[t],i=this._bestFitChild(r.bounds.getCenter());ni._encapsulates(this._getChildBound(i),r.bounds._getBoundBox())&&(this._objects.splice(this._objects.indexOf(r),1),this._getChild(i)._add(r))}}var n=this._bestFitChild(e.bounds.getCenter());return ni._encapsulates(this._getChildBound(n),e.bounds._getBoundBox())?this._getChild(n)._checkAddNode(e):this}_add(e){var t=this._checkAddNode(e);t._objects.push(e),e._setOctreeNode(t)}_remove(e){var t=this._objects.indexOf(e);this._objects.splice(t,1),e._setOctreeNode(null),this._merge()}_addUp(e){return W.boxContainsBox(this._bounds,e.bounds._getBoundBox())===H.Contains?(this._add(e),!0):!!this._parent&&this._parent._addUp(e)}_getCollidingWithFrustum(e,r,i,n,s,o){if(i){var l=r.containsBoundBox(this._bounds);if(t.Stat.octreeNodeCulling++,l===H.Disjoint)return;i=l===H.Intersects}this._isContaion=!i;for(var _=e.camera,h=e.scene,c=0,d=this._objects.length;c=this.center.y?0:4)+(e.z<=this.center.z?0:2)}_update(e){if(W.boxContainsBox(this._bounds,e.bounds._getBoundBox())===H.Contains){var t=this._checkAddNode(e);if(t!==e._getOctreeNode()){t._objects.push(e),e._setOctreeNode(t);var r=this._objects.indexOf(e);this._objects.splice(r,1),this._merge()}return!0}if(this._parent){var i=this._parent._addUp(e);return i&&(r=this._objects.indexOf(e),this._objects.splice(r,1),this._merge()),i}return!1}add(e){return!!ni._encapsulates(this._bounds,e.bounds._getBoundBox())&&(this._add(e),!0)}remove(e){return e._getOctreeNode()===this&&(this._remove(e),!0)}update(e){return e._getOctreeNode()===this&&this._update(e)}shrinkIfPossible(e){if(this.baseLength<2*e)return this;for(var t=-1,r=0,i=this._objects.length;r=0&&t!=r)return this;l=!0,t=r}}if(-1!=t){var h=this._children[t];return h._parent=null,h}return this}hasAnyObjects(){if(this._objects.length>0)return!0;if(null!=this._children)for(var e=0;e<8;e++){var t=this._children[e];if(t&&t.hasAnyObjects())return!0}return!1}getCollidingWithBoundBox(e,t){this._getCollidingWithBoundBox(e,!0,t)}getCollidingWithRay(e,t,r=Number.MAX_VALUE){var i=W.intersectsRayAndBoxRD(e,this._bounds);if(!(-1==i||i>r)){for(var n=0,a=this._objects.length;nt)return!1;for(var i=0,n=this._objects.length;ie&&(console.warn("Minimum node size must be at least as big as the initial world size. Was: "+r+" Adjusted to: "+e),r=e),this._initialSize=e,this._minSize=r,this._looseness=Math.min(Math.max(i,1),2),this._rootNode=new ni(this,null,e,t)}_getMaxDepth(e,t){t++;var r=e._children;if(null!=r)for(var i=t,n=0,a=r.length;n=0?1:-1,r=e.y>=0?1:-1,i=e.z>=0?1:-1,n=this._rootNode,s=this._rootNode.baseLength/2,o=2*this._rootNode.baseLength,l=this._rootNode.center,_=new a(l.x+t*s,l.y+r*s,l.z+i*s);if(this._rootNode=new ni(this,null,o,_),n.hasAnyObjects()){for(var h=this._rootNode._bestFitChild(n.center),c=[],d=0;d<8;d++)d==h&&(n._parent=this._rootNode,c[d]=n);this._rootNode._children=c}}add(e){for(var t=0;!this._rootNode.add(e);){var r=si._tempVector30;if(a.subtract(e.bounds.getCenter(),this._rootNode.center,r),this._grow(r),++t>20)throw"Aborted Add operation as it seemed to be going on forever ("+(t-1)+") attempts at growing the octree."}this.count++}remove(e){var t=e._getOctreeNode().remove(e);return t&&this.count--,t}update(e){var t=0,r=e._getOctreeNode();if(r){for(;!r._update(e);){var i=si._tempVector30;if(a.subtract(e.bounds.getCenter(),this._rootNode.center,i),this._grow(i),++t>20)throw"Aborted Add operation as it seemed to be going on forever ("+(t-1)+") attempts at growing the octree."}return!0}return!1}shrinkRootIfPossible(){this._rootNode=this._rootNode.shrinkIfPossible(this._initialSize)}addMotionObject(e){this._motionObjects.add(e)}removeMotionObject(e){this._motionObjects.remove(e)}updateMotionObjects(){for(var e=this._motionObjects.elements,t=0,r=this._motionObjects.length;te._renderingOrder?i=t-1:r=t+1}return r}onEnable(){this._input._onCanvasEvent(t.Render.canvas)}onDisable(){this._input._offCanvasEvent(t.Render.canvas)}_setCreateURL(e){this._url=t.URL.formatURL(e)}_getGroup(){return this._group}_setGroup(e){this._group=e}_clearScript(){if(this._needClearScriptPool){for(var e=this._scriptPool,t=0,r=e.length;t0)for(var t=0,r=0;r=this._enableLightCount);r++);}_addCamera(e){for(var t=this._binarySearchIndexInCameraPool(e),r=e._renderingOrder,i=this._cameraPool.length;t=0&&this._lights.splice(t,1)}_addRenderObject(e){if(this._octree&&e._supportOctree)this._octree.add(e);else if(this._renders.add(e),t.Render.supportWebGLPlusCulling){var r=e._getIndexInList(),i=this._cullingBufferIndices.length;if(r>=i){var n=this._cullingBufferIndices,a=this._cullingBufferResult;this._cullingBufferIndices=new Int32Array(i+1024),this._cullingBufferResult=new Int32Array(i+1024),this._cullingBufferIndices.set(n,0),this._cullingBufferResult.set(a,0)}this._cullingBufferIndices[r]=e._cullingBufferIndex}}_removeRenderObject(e){var r;this._octree&&e._supportOctree?this._octree.remove(e):(t.Render.supportWebGLPlusCulling&&(r=this._renders.elements[this._renders.length-1]),this._renders.remove(e),t.Render.supportWebGLPlusCulling&&(this._cullingBufferIndices[r._getIndexInList()]=r._cullingBufferIndex))}_addShadowCastRenderObject(e){this._octree||this._castShadowRenders.add(e)}_removeShadowCastRenderObject(e){this._octree||this._castShadowRenders.remove(e)}_getRenderQueue(e){return e<=2500?this._opaqueQueue:this._transparentQueue}setlightmaps(e){for(var t=this._lightmaps,r=0,i=t.length;r0&&e.addRenderObject(this)}renderSubmit(){var e,r,i;t.LayaGL.instance;for(this._prepareSceneToRender(),e=0,i=(r=this._cameraPool.length)-1;e0&&(i[0]=r[0]*n,i[1]=r[1]*n,i[2]=r[2]*n,i[3]=r[3]*n)}static add(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3]}static subtract(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]-a[0],i[1]=n[1]-a[1],i[2]=n[2]-a[2],i[3]=n[3]-a[3]}static multiply(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]*a[0],i[1]=n[1]*a[1],i[2]=n[2]*a[2],i[3]=n[3]*a[3]}static scale(e,t,r){var i=r.elements,n=e.elements;i[0]=n[0]*t,i[1]=n[1]*t,i[2]=n[2]*t,i[3]=n[3]*t}static Clamp(e,t,r,i){var n=e.elements,a=n[0],s=n[1],o=n[2],l=n[3],_=t.elements,h=_[0],c=_[1],d=_[2],u=_[3],f=r.elements,E=f[0],T=f[1],m=f[2],p=f[3],g=i.elements;a=(a=a>E?E:a)T?T:s)m?m:o)p?p:l)0&&(o=1/Math.sqrt(o),i[0]=r[0]*o,i[1]=r[1]*o,i[2]=r[2]*o)}static multiply(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]*a[0],i[1]=n[1]*a[1],i[2]=n[2]*a[2]}static scale(e,t,r){var i=r.elements,n=e.elements;i[0]=n[0]*t,i[1]=n[1]*t,i[2]=n[2]*t}static lerp(e,t,r,i){var n=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],_=a[2];n[0]=o+r*(s[0]-o),n[1]=l+r*(s[1]-l),n[2]=_+r*(s[2]-_)}static transformV3ToV3(e,t,r){var i=fi._tempVector4;fi.transformV3ToV4(e,t,i);var n=i.elements,a=r.elements;a[0]=n[0],a[1]=n[1],a[2]=n[2]}static transformV3ToV4(e,t,r){var i=e.elements,n=i[0],a=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=n*o[0]+a*o[4]+s*o[8]+o[12],l[1]=n*o[1]+a*o[5]+s*o[9]+o[13],l[2]=n*o[2]+a*o[6]+s*o[10]+o[14],l[3]=n*o[3]+a*o[7]+s*o[11]+o[15]}static TransformNormal(e,t,r){var i=e.elements,n=i[0],a=i[1],s=i[2],o=t.elements,l=r.elements;l[0]=n*o[0]+a*o[4]+s*o[8],l[1]=n*o[1]+a*o[5]+s*o[9],l[2]=n*o[2]+a*o[6]+s*o[10]}static transformCoordinate(e,t,r){var i=e.elements,n=i[0],a=i[1],s=i[2],o=t.elements,l=n*o[3]+a*o[7]+s*o[11]+o[15],_=r.elements;_[0]=n*o[0]+a*o[4]+s*o[8]+o[12]/l,_[1]=n*o[1]+a*o[5]+s*o[9]+o[13]/l,_[2]=n*o[2]+a*o[6]+s*o[10]+o[14]/l}static Clamp(e,t,r,i){var n=e.elements,a=n[0],s=n[1],o=n[2],l=t.elements,_=l[0],h=l[1],c=l[2],d=r.elements,u=d[0],f=d[1],E=d[2],T=i.elements;a=(a=a>u?u:a)<_?_:a,s=(s=s>f?f:s)E?E:o)0&&(s=1/Math.sqrt(s),t[0]=r*s,t[1]=i*s,t[2]=n*s,t[3]=a*s)}static _lerpArray(e,t,r,i){var n=1-r;Ei._dotArray(e,t)>=0?(i[0]=n*e[0]+r*t[0],i[1]=n*e[1]+r*t[1],i[2]=n*e[2]+r*t[2],i[3]=n*e[3]+r*t[3]):(i[0]=n*e[0]-r*t[0],i[1]=n*e[1]-r*t[1],i[2]=n*e[2]-r*t[2],i[3]=n*e[3]-r*t[3]),Ei._normalizeArray(i,i)}static createFromYawPitchRoll(e,t,r,i){var n=.5*r,a=.5*t,s=.5*e,o=Math.sin(n),l=Math.cos(n),_=Math.sin(a),h=Math.cos(a),c=Math.sin(s),d=Math.cos(s),u=i.elements;u[0]=d*_*l+c*h*o,u[1]=c*h*l-d*_*o,u[2]=d*h*o-c*_*l,u[3]=d*h*l+c*_*o}static multiply(e,t,r){var i=e.elements,n=t.elements,a=r.elements,s=i[0],o=i[1],l=i[2],_=i[3],h=n[0],c=n[1],d=n[2],u=n[3],f=o*d-l*c,E=l*h-s*d,T=s*c-o*h,m=s*h+o*c+l*d;a[0]=s*u+h*_+f,a[1]=o*u+c*_+E,a[2]=l*u+d*_+T,a[3]=_*u-m}static arcTanAngle(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){fi.subtract(t,e,Ei.TEMPVector30),fi.normalize(Ei.TEMPVector30,Ei.TEMPVector30),r.elements[0]=Math.asin(Ei.TEMPVector30.y),r.elements[1]=Ei.arcTanAngle(-Ei.TEMPVector30.z,-Ei.TEMPVector30.x)}static createFromAxisAngle(e,t,r){var i=r.elements,n=e.elements;t*=.5;var a=Math.sin(t);i[0]=a*n[0],i[1]=a*n[1],i[2]=a*n[2],i[3]=Math.cos(t)}static createFromMatrix3x3(e,t){var r,i=t.elements,n=e.elements,a=n[0]+n[4]+n[8];if(a>0)r=Math.sqrt(a+1),i[3]=.5*r,r=.5/r,i[0]=(n[5]-n[7])*r,i[1]=(n[6]-n[2])*r,i[2]=(n[1]-n[3])*r;else{var s=0;n[4]>n[0]&&(s=1),n[8]>n[3*s+s]&&(s=2);var o=(s+1)%3,l=(s+2)%3;r=Math.sqrt(n[3*s+s]-n[3*o+o]-n[3*l+l]+1),i[s]=.5*r,r=.5/r,i[3]=(n[3*o+l]-n[3*l+o])*r,i[o]=(n[3*o+s]+n[3*s+o])*r,i[l]=(n[3*l+s]+n[3*s+l])*r}}static createFromMatrix4x4(e,t){var r,i,n=e.elements,a=t.elements,s=n[0]+n[5]+n[10];s>0?(r=Math.sqrt(s+1),a[3]=.5*r,r=.5/r,a[0]=(n[6]-n[9])*r,a[1]=(n[8]-n[2])*r,a[2]=(n[1]-n[4])*r):n[0]>=n[5]&&n[0]>=n[10]?(i=.5/(r=Math.sqrt(1+n[0]-n[5]-n[10])),a[0]=.5*r,a[1]=(n[1]+n[4])*i,a[2]=(n[2]+n[8])*i,a[3]=(n[6]-n[9])*i):n[5]>n[10]?(i=.5/(r=Math.sqrt(1+n[5]-n[0]-n[10])),a[0]=(n[4]+n[1])*i,a[1]=.5*r,a[2]=(n[9]+n[6])*i,a[3]=(n[8]-n[2])*i):(i=.5/(r=Math.sqrt(1+n[10]-n[0]-n[5])),a[0]=(n[8]+n[2])*i,a[1]=(n[9]+n[6])*i,a[2]=.5*r,a[3]=(n[1]-n[4])*i)}static slerp(e,t,r,i){var n,a,s,o,l,_=e.elements,h=t.elements,c=i.elements,d=_[0],u=_[1],f=_[2],E=_[3],T=h[0],m=h[1],p=h[2],g=h[3];return(a=d*T+u*m+f*p+E*g)<0&&(a=-a,T=-T,m=-m,p=-p,g=-g),1-a>1e-6?(n=Math.acos(a),s=Math.sin(n),o=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(o=1-r,l=r),c[0]=o*d+l*T,c[1]=o*u+l*m,c[2]=o*f+l*p,c[3]=o*E+l*g,c}static lerp(e,t,r,i){Ei._lerpArray(e.elements,t.elements,r,i.elements)}static add(e,t,r){var i=r.elements,n=e.elements,a=t.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3]}static dot(e,t){return Ei._dotArray(e.elements,t.elements)}get x(){return this.elements[0]}set x(e){this.elements[0]=e}get y(){return this.elements[1]}set y(e){this.elements[1]=e}get z(){return this.elements[2]}set z(e){this.elements[2]=e}get w(){return this.elements[3]}set w(e){this.elements[3]=e}scaling(e,t){var r=t.elements,i=this.elements;r[0]=i[0]*e,r[1]=i[1]*e,r[2]=i[2]*e,r[3]=i[3]*e}normalize(e){Ei._normalizeArray(this.elements,e.elements)}length(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3];return Math.sqrt(t*t+r*r+i*i+n*n)}rotateX(e,t){var r=t.elements,i=this.elements;e*=.5;var n=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=n*_+o*l,r[1]=a*_+s*l,r[2]=s*_-a*l,r[3]=o*_-n*l}rotateY(e,t){var r=t.elements,i=this.elements;e*=.5;var n=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=n*_-s*l,r[1]=a*_+o*l,r[2]=s*_+n*l,r[3]=o*_-a*l}rotateZ(e,t){var r=t.elements,i=this.elements;e*=.5;var n=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),_=Math.cos(e);r[0]=n*_+a*l,r[1]=a*_-n*l,r[2]=s*_+o*l,r[3]=o*_-s*l}getYawPitchRoll(e){fi.transformQuat(fi.ForwardRH,this,Ei.TEMPVector31),fi.transformQuat(fi.Up,this,Ei.TEMPVector32);var t=Ei.TEMPVector32.elements;Ei.angleTo(fi.ZERO,Ei.TEMPVector31,Ei.TEMPVector33);var r=Ei.TEMPVector33.elements;r[0]==Math.PI/2?(r[1]=Ei.arcTanAngle(t[2],t[0]),r[2]=0):r[0]==-Math.PI/2?(r[1]=Ei.arcTanAngle(-t[2],-t[0]),r[2]=0):(T.createRotationY(-r[1],Ei.TEMPMatrix0),T.createRotationX(-r[0],Ei.TEMPMatrix1),fi.transformCoordinate(Ei.TEMPVector32,Ei.TEMPMatrix0,Ei.TEMPVector32),fi.transformCoordinate(Ei.TEMPVector32,Ei.TEMPMatrix1,Ei.TEMPVector32),r[2]=Ei.arcTanAngle(t[1],-t[0])),r[1]<=-Math.PI&&(r[1]=Math.PI),r[2]<=-Math.PI&&(r[2]=Math.PI),r[1]>=Math.PI&&r[2]>=Math.PI&&(r[1]=0,r[2]=0,r[0]=Math.PI-r[0]);var i=e.elements;i[0]=r[1],i[1]=r[0],i[2]=r[2]}invert(e){var t=e.elements,r=this.elements,i=r[0],n=r[1],a=r[2],s=r[3],o=i*i+n*n+a*a+s*s,l=o?1/o:0;t[0]=-i*l,t[1]=-n*l,t[2]=-a*l,t[3]=s*l}identity(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1}fromArray(e,t=0){this.elements[0]=e[t+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2],this.elements[3]=e[t+3]}cloneTo(e){var t,r,i;if((r=this.elements)!==(i=e.elements))for(t=0;t<4;++t)i[t]=r[t]}clone(){var e=new Ei;return this.cloneTo(e),e}equals(e){var t=this.elements,i=e.elements;return r.nearEqual(t[0],i[0])&&r.nearEqual(t[1],i[1])&&r.nearEqual(t[2],i[2])&&r.nearEqual(t[3],i[3])}static rotationLookAt(e,t,r){Ei.lookAt(fi.ZERO,e,t,r)}static lookAt(e,t,r,i){f.lookAt(e,t,r,Ei._tempMatrix3x3),Ei.rotationMatrix(Ei._tempMatrix3x3,i)}lengthSquared(){var e=this.elements[0],t=this.elements[1],r=this.elements[2],i=this.elements[3];return e*e+t*t+r*r+i*i}static invert(e,t){var i=e.elements,n=t.elements,a=e.lengthSquared();r.isZero(a)||(a=1/a,n[0]=-i[0]*a,n[1]=-i[1]*a,n[2]=-i[2]*a,n[3]=i[3]*a)}static rotationMatrix(e,t){var r,i,n=e.elements,a=n[0],s=n[1],o=n[2],l=n[3],_=n[4],h=n[5],c=n[6],d=n[7],u=n[8],f=t.elements,E=a+_+u;E>0?(r=Math.sqrt(E+1),f[3]=.5*r,r=.5/r,f[0]=(h-d)*r,f[1]=(c-o)*r,f[2]=(s-l)*r):a>=_&&a>=u?(i=.5/(r=Math.sqrt(1+a-_-u)),f[0]=.5*r,f[1]=(s+l)*i,f[2]=(o+c)*i,f[3]=(h-d)*i):_>u?(i=.5/(r=Math.sqrt(1+_-a-u)),f[0]=(l+s)*i,f[1]=.5*r,f[2]=(d+h)*i,f[3]=(c-o)*i):(i=.5/(r=Math.sqrt(1+u-a-_)),f[0]=(c+o)*i,f[1]=(d+h)*i,f[2]=.5*r,f[3]=(s-l)*i)}}Ei.TEMPVector30=new fi,Ei.TEMPVector31=new fi,Ei.TEMPVector32=new fi,Ei.TEMPVector33=new fi,Ei.TEMPMatrix0=new T,Ei.TEMPMatrix1=new T,Ei._tempMatrix3x3=new f,Ei.DEFAULT=new Ei,Ei.NAN=new Ei(NaN,NaN,NaN,NaN);class Ti{static READ_DATA(){Ti._DATA.offset=Ti._reader.getUint32(),Ti._DATA.size=Ti._reader.getUint32()}static READ_BLOCK(){for(var e=Ti._BLOCK.count=Ti._reader.getUint16(),t=Ti._BLOCK.blockStarts=[],r=Ti._BLOCK.blockLengths=[],i=0;i0&&(V.params=w=[]),r=0;r>-t-14,mi._baseTable[256|e]=1024>>-t-14|32768,mi._shiftTable[0|e]=-t-1,mi._shiftTable[256|e]=-t-1):t<=15?(mi._baseTable[0|e]=t+15<<10,mi._baseTable[256|e]=t+15<<10|32768,mi._shiftTable[0|e]=13,mi._shiftTable[256|e]=13):t<128?(mi._baseTable[0|e]=31744,mi._baseTable[256|e]=64512,mi._shiftTable[0|e]=24,mi._shiftTable[256|e]=24):(mi._baseTable[0|e]=31744,mi._baseTable[256|e]=64512,mi._shiftTable[0|e]=13,mi._shiftTable[256|e]=13)}for(mi._mantissaTable[0]=0,e=1;e<1024;++e){var r=e<<13;for(t=0;0==(8388608&r);)t-=8388608,r<<=1;r&=-8388609,t+=947912704,mi._mantissaTable[e]=r|t}for(e=1024;e<2048;++e)mi._mantissaTable[e]=939524096+(e-1024<<13);for(mi._exponentTable[0]=0,e=1;e<31;++e)mi._exponentTable[e]=e<<23;for(mi._exponentTable[31]=1199570944,mi._exponentTable[32]=2147483648,e=33;e<63;++e)mi._exponentTable[e]=2147483648+(e-32<<23);for(mi._exponentTable[63]=3347054592,mi._offsetTable[0]=0,e=1;e<64;++e)mi._offsetTable[e]=32===e?0:1024}static roundToFloat16Bits(e){mi._floatView[0]=e;var t=mi._uint32View[0],r=t>>23&511;return mi._baseTable[r]+((8388607&t)>>mi._shiftTable[r])}static convertToNumber(e){var t=e>>10;return mi._uint32View[0]=mi._mantissaTable[mi._offsetTable[t]+(1023&e)]+mi._exponentTable[t],mi._floatView[0]}}mi._buffer=new ArrayBuffer(4),mi._floatView=new Float32Array(mi._buffer),mi._uint32View=new Uint32Array(mi._buffer),mi._baseTable=new Uint32Array(512),mi._shiftTable=new Uint32Array(512),mi._mantissaTable=new Uint32Array(2048),mi._exponentTable=new Uint32Array(64),mi._offsetTable=new Uint32Array(64);class pi{static READ_DATA(){pi._DATA.offset=pi._reader.getUint32(),pi._DATA.size=pi._reader.getUint32()}static READ_BLOCK(){for(var e=pi._BLOCK.count=pi._reader.getUint16(),t=pi._BLOCK.blockStarts=[],r=pi._BLOCK.blockLengths=[],i=0;i0&&(V.params=w=[]),r=0;rt);)d++,o++,r[a]=d;else for((o=d+1)!==c&&t>h[o].time&&(d=c-1,r[a]=d),o=d+1;d>-1&&!(h[d].timee?i=t-1:r=t+1}return r}addEvent(e){var t=this._binarySearchEventIndex(e.time);this._animationEvents.splice(t,0,e)}_disposeResource(){this._nodes=null,this._nodesMap=null}}Si.ANIMATIONCLIP="ANIMATIONCLIP",Si._tempQuaternion0=new E;class vi extends t.EventDispatcher{constructor(e,r=null,i=null,n=null,s=null){super(),this._owner=e,this._children=[],this._localMatrix=new Float32Array(16),t.Render.supportWebGLPlusAnimation?(this._localPosition=new fi(0,0,0,r),this._localRotation=new Ei(0,0,0,1,i),this._localScale=new fi(0,0,0,n),this._worldMatrix=s):(this._localPosition=new a,this._localRotation=new E,this._localScale=new a,this._worldMatrix=new Float32Array(16)),this._localQuaternionUpdate=!1,this._locaEulerlUpdate=!1,this._localUpdate=!1,this._worldUpdate=!0}_getlocalMatrix(){return this._localUpdate&&(M._createAffineTransformationArray(this._localPosition,this._localRotation,this._localScale,this._localMatrix),this._localUpdate=!1),this._localMatrix}_onWorldTransform(){if(!this._worldUpdate){this._worldUpdate=!0,this.event(t.Event.TRANSFORM_CHANGED);for(var e=0,r=this._children.length;e>a,1),Math.max(e>>a,1));this._setGPUMemory(e*e*4*(1+1/3)*6)}else this._mipmapCount=1,this._setGPUMemory(e*e*4*6)}static __init__(){var e=new Uint8Array(3);e[0]=128,e[1]=128,e[2]=128,yi.grayTexture=new yi(1,t.BaseTexture.FORMAT_R8G8B8,!1),yi.grayTexture.setSixSidePixels([e,e,e,e,e,e]),yi.grayTexture.lock=!0}static _parse(e,t=null,r=null){var i=r?new yi(0,r[0],r[1]):new yi(0);return i.setSixSideImageSources(e),i}static load(e,r){t.ILaya.loader.create(e,r,null,yi.TEXTURECUBE)}get defaulteTexture(){return yi.grayTexture}_setPixels(e,r,i,n){var a=t.LayaGL.instance,s=this._getGLFormat();t.WebGLContext.bindTexture(a,this._glTextureType,this._glTexture),this.format===t.BaseTexture.FORMAT_R8G8B8?(a.pixelStorei(a.UNPACK_ALIGNMENT,1),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[0]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[1]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[2]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[3]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[4]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[5]),a.pixelStorei(a.UNPACK_ALIGNMENT,4)):(a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[0]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Z,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[1]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[2]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_X,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[3]),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[4]),a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Y,r,s,i,n,0,s,a.UNSIGNED_BYTE,e[5]))}setSixSideImageSources(e,r=!1){for(var i,n,a=0;a<6;a++){var s=e[a];if(!s)return void console.log("TextureCube: image Source can't be null.");var o=s.width,l=s.height;if(a>0&&i!==o)return void console.log("TextureCube: each side image's width and height must same.");if((i=o)!==(n=l))return void console.log("TextureCube: each side image's width and height must same.")}this._width=i,this._height=n;var _=t.LayaGL.instance;t.WebGLContext.bindTexture(_,this._glTextureType,this._glTexture);var h=this._getGLFormat();if(t.Render.isConchApp){if(1==r)for(var c=0;c<6;c++)e[c].setPremultiplyAlpha(r);_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[0]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[1]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[2]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[3]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[4]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,e[5])}else r&&_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z,0,h,h,_.UNSIGNED_BYTE,e[0]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,h,h,_.UNSIGNED_BYTE,e[1]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X,0,h,h,_.UNSIGNED_BYTE,e[2]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X,0,h,h,_.UNSIGNED_BYTE,e[3]),_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y,0,h,h,_.UNSIGNED_BYTE,e[4]),_.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,h,h,_.UNSIGNED_BYTE,e[5]),r&&_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);this._mipmap&&this._isPot(i)&&this._isPot(n)?(_.generateMipmap(this._glTextureType),this._setGPUMemory(i*n*4*(1+1/3)*6)):this._setGPUMemory(i*n*4*6),this._setWarpMode(_.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(_.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),this._readyed=!0,this._activeResource()}setSixSidePixels(e,r=0){if(!e)throw new Error("TextureCube:pixels can't be null.");var i=Math.max(this._width>>r,1),n=Math.max(this._height>>r,1),a=i*n*this._getFormatByteCount();if(e[0].length0&&(t^=De.COLLISIONFLAGS_KINEMATIC_OBJECT),t|=De.COLLISIONFLAGS_STATIC_OBJECT):((t&De.COLLISIONFLAGS_STATIC_OBJECT)>0&&(t^=De.COLLISIONFLAGS_STATIC_OBJECT),t|=De.COLLISIONFLAGS_KINEMATIC_OBJECT),e.setCollisionFlags(t),this._nativeColliderObject=e,super._onAdded()}}class Pi extends De{constructor(e=.1,t=null,r=Ee.COLLISIONFILTERGROUP_DEFAULTFILTER,i=Ee.COLLISIONFILTERGROUP_ALLFILTER){super(r,i),this._upAxis=new a(0,1,0),this._maxSlope=45,this._jumpSpeed=10,this._fallSpeed=55,this._gravity=new a(0,3*-9.8,0),this._nativeKinematicCharacter=null,this._stepHeight=e,t&&(this._upAxis=t)}static __init__(){Pi._nativeTempVector30=new fe._physics3D.btVector3(0,0,0)}get fallSpeed(){return this._fallSpeed}set fallSpeed(e){this._fallSpeed=e,this._nativeKinematicCharacter.setFallSpeed(e)}get jumpSpeed(){return this._jumpSpeed}set jumpSpeed(e){this._jumpSpeed=e,this._nativeKinematicCharacter.setJumpSpeed(e)}get gravity(){return this._gravity}set gravity(e){this._gravity=e;var t=Pi._nativeTempVector30;t.setValue(-e.x,e.y,e.z),this._nativeKinematicCharacter.setGravity(t)}get maxSlope(){return this._maxSlope}set maxSlope(e){this._maxSlope=e,this._nativeKinematicCharacter.setMaxSlope(e/180*Math.PI)}get isGrounded(){return this._nativeKinematicCharacter.onGround()}get stepHeight(){return this._stepHeight}set stepHeight(e){this._stepHeight=e,this._constructCharacter()}get upAxis(){return this._upAxis}set upAxis(e){this._upAxis=e,this._constructCharacter()}_constructCharacter(){var e=fe._physics3D;this._nativeKinematicCharacter&&e.destroy(this._nativeKinematicCharacter);var t=Pi._nativeTempVector30;t.setValue(this._upAxis.x,this._upAxis.y,this._upAxis.z),this._nativeKinematicCharacter=new e.btKinematicCharacterController(this._nativeColliderObject,this._colliderShape._nativeShape,this._stepHeight,t),this.fallSpeed=this._fallSpeed,this.maxSlope=this._maxSlope,this.jumpSpeed=this._jumpSpeed,this.gravity=this._gravity}_onShapeChange(e){super._onShapeChange(e),this._constructCharacter()}_onAdded(){var e=new fe._physics3D.btPairCachingGhostObject;e.setUserIndex(this.id),e.setCollisionFlags(De.COLLISIONFLAGS_CHARACTER_OBJECT),this._nativeColliderObject=e,this._colliderShape&&this._constructCharacter(),super._onAdded()}_addToSimulation(){this._simulation._characters.push(this),this._simulation._addCharacter(this,this._collisionGroup,this._canCollideWith)}_removeFromSimulation(){this._simulation._removeCharacter(this);var e=this._simulation._characters;e.splice(e.indexOf(this),1)}_cloneTo(e){super._cloneTo(e);var t=e;t.stepHeight=this._stepHeight,t.upAxis=this._upAxis,t.maxSlope=this._maxSlope,t.jumpSpeed=this._jumpSpeed,t.fallSpeed=this._fallSpeed,t.gravity=this._gravity}_onDestroy(){fe._physics3D.destroy(this._nativeKinematicCharacter),super._onDestroy(),this._nativeKinematicCharacter=null}move(e){var t=Pi._nativeVector30;t.setValue(-e.x,e.y,e.z),this._nativeKinematicCharacter.setWalkDirection(t)}jump(e=null){if(e){var t=Pi._nativeVector30;M._convertToBulletVec3(e,t,!0),this._nativeKinematicCharacter.jump(t)}else this._nativeKinematicCharacter.jump()}}Pi.UPAXIS_X=0,Pi.UPAXIS_Y=1,Pi.UPAXIS_Z=2;class wi extends Oi{constructor(e=Ee.COLLISIONFILTERGROUP_DEFAULTFILTER,t=Ee.COLLISIONFILTERGROUP_ALLFILTER){super(e,t),this._isKinematic=!1,this._mass=1,this._gravity=new a(0,-10,0),this._angularDamping=0,this._linearDamping=0,this._overrideGravity=!1,this._totalTorque=new a(0,0,0),this._totalForce=new a(0,0,0),this._linearVelocity=new a,this._angularVelocity=new a,this._linearFactor=new a(1,1,1),this._angularFactor=new a(1,1,1),this._detectCollisions=!0}static __init__(){wi._nativeTempVector30=new fe._physics3D.btVector3(0,0,0),wi._nativeTempVector31=new fe._physics3D.btVector3(0,0,0),wi._nativeVector3Zero=new fe._physics3D.btVector3(0,0,0),wi._nativeInertia=new fe._physics3D.btVector3(0,0,0),wi._nativeImpulse=new fe._physics3D.btVector3(0,0,0),wi._nativeImpulseOffset=new fe._physics3D.btVector3(0,0,0),wi._nativeGravity=new fe._physics3D.btVector3(0,0,0)}get mass(){return this._mass}set mass(e){e=Math.max(e,1e-7),this._mass=e,this._isKinematic||this._updateMass(e)}get isKinematic(){return this._isKinematic}set isKinematic(e){this._isKinematic=e;var t=!!(this._simulation&&this._enabled&&this._colliderShape);t&&this._removeFromSimulation();var r=this._nativeColliderObject,i=r.getCollisionFlags();e?(i|=De.COLLISIONFLAGS_KINEMATIC_OBJECT,r.setCollisionFlags(i),this._nativeColliderObject.forceActivationState(De.ACTIVATIONSTATE_DISABLE_DEACTIVATION),this._enableProcessCollisions=!1,this._updateMass(0)):((i&De.COLLISIONFLAGS_KINEMATIC_OBJECT)>0&&(i^=De.COLLISIONFLAGS_KINEMATIC_OBJECT),r.setCollisionFlags(i),this._nativeColliderObject.setActivationState(De.ACTIVATIONSTATE_ACTIVE_TAG),this._enableProcessCollisions=!0,this._updateMass(this._mass));var n=wi._nativeVector3Zero;r.setInterpolationLinearVelocity(n),r.setLinearVelocity(n),r.setInterpolationAngularVelocity(n),r.setAngularVelocity(n),t&&this._addToSimulation()}get linearDamping(){return this._linearDamping}set linearDamping(e){this._linearDamping=e,this._nativeColliderObject&&this._nativeColliderObject.setDamping(e,this._angularDamping)}get angularDamping(){return this._angularDamping}set angularDamping(e){this._angularDamping=e,this._nativeColliderObject&&this._nativeColliderObject.setDamping(this._linearDamping,e)}get overrideGravity(){return this._overrideGravity}set overrideGravity(e){if(this._overrideGravity=e,this._nativeColliderObject){var t=this._nativeColliderObject.getFlags();e?0==(t&wi._BT_DISABLE_WORLD_GRAVITY)&&this._nativeColliderObject.setFlags(t|wi._BT_DISABLE_WORLD_GRAVITY):(t&wi._BT_DISABLE_WORLD_GRAVITY)>0&&this._nativeColliderObject.setFlags(t^wi._BT_DISABLE_WORLD_GRAVITY)}}get gravity(){return this._gravity}set gravity(e){this._gravity=e,wi._nativeGravity.setValue(-e.x,e.y,e.z),this._nativeColliderObject.setGravity(wi._nativeGravity)}get totalForce(){if(this._nativeColliderObject){var e=this._nativeColliderObject.getTotalForce();return M._convertToLayaVec3(e,this._totalForce,!0),this._totalForce}return null}get linearFactor(){return this._nativeColliderObject?this._linearFactor:null}set linearFactor(e){if(this._linearFactor=e,this._nativeColliderObject){var t=wi._nativeTempVector30;M._convertToBulletVec3(e,t,!1),this._nativeColliderObject.setLinearFactor(t)}}get linearVelocity(){return this._nativeColliderObject&&M._convertToLayaVec3(this._nativeColliderObject.getLinearVelocity(),this._linearVelocity,!0),this._linearVelocity}set linearVelocity(e){if(this._linearVelocity=e,this._nativeColliderObject){var t=wi._nativeTempVector30;M._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),this._nativeColliderObject.setLinearVelocity(t)}}get angularFactor(){return this._nativeColliderObject?this._angularFactor:null}set angularFactor(e){if(this._angularFactor=e,this._nativeColliderObject){var t=wi._nativeTempVector30;M._convertToBulletVec3(e,t,!1),this._nativeColliderObject.setAngularFactor(t)}}get angularVelocity(){return this._nativeColliderObject&&M._convertToLayaVec3(this._nativeColliderObject.getAngularVelocity(),this._angularVelocity,!0),this._angularVelocity}set angularVelocity(e){if(this._angularVelocity=e,this._nativeColliderObject){var t=wi._nativeTempVector30;M._convertToBulletVec3(e,t,!0),this.isSleeping&&this.wakeUp(),this._nativeColliderObject.setAngularVelocity(t)}}get totalTorque(){if(this._nativeColliderObject){var e=this._nativeColliderObject.getTotalTorque();return M._convertToLayaVec3(e,this._totalTorque,!0),this._totalTorque}return null}get detectCollisions(){return this._detectCollisions}set detectCollisions(e){this._detectCollisions!==e&&(this._detectCollisions=e,this._colliderShape&&this._enabled&&this._simulation&&(this._simulation._removeRigidBody(this),this._simulation._addRigidBody(this,this._collisionGroup,e?this._canCollideWith:0)))}get isSleeping(){return!!this._nativeColliderObject&&this._nativeColliderObject.getActivationState()===De.ACTIVATIONSTATE_ISLAND_SLEEPING}get sleepLinearVelocity(){return this._nativeColliderObject.getLinearSleepingThreshold()}set sleepLinearVelocity(e){this._nativeColliderObject.setSleepingThresholds(e,this._nativeColliderObject.getAngularSleepingThreshold())}get sleepAngularVelocity(){return this._nativeColliderObject.getAngularSleepingThreshold()}set sleepAngularVelocity(e){this._nativeColliderObject.setSleepingThresholds(this._nativeColliderObject.getLinearSleepingThreshold(),e)}_updateMass(e){this._nativeColliderObject&&this._colliderShape&&(this._colliderShape._nativeShape.calculateLocalInertia(e,wi._nativeInertia),this._nativeColliderObject.setMassProps(e,wi._nativeInertia),this._nativeColliderObject.updateInertiaTensor())}_delegateMotionStateGetWorldTransform(e){}_delegateMotionStateSetWorldTransform(e){var t=this._rigidbody;t._simulation._updatedRigidbodies++;var r=fe._physics3D,i=r.wrapPointer(e,r.btTransform);t._updateTransformComponent(i)}_delegateMotionStateGetWorldTransformNative(e,t){}_delegateMotionStateSetWorldTransformNative(e,t){var r=e;r._simulation._updatedRigidbodies++;var i=fe._physics3D,n=i.wrapPointer(t,i.btTransform);r._updateTransformComponent(n)}_onScaleChange(e){super._onScaleChange(e),this._updateMass(this._isKinematic?0:this._mass)}_delegateMotionStateClear(){this._rigidbody=null}_onAdded(){var e=fe._physics3D,t=new e.LayaMotionState;null!=window.conch&&e.LayaMotionState.prototype.setRigidbody?(t.setRigidbody(this),t.setNativeGetWorldTransform(this._delegateMotionStateGetWorldTransformNative),t.setNativeSetWorldTransform(this._delegateMotionStateSetWorldTransformNative)):(t.getWorldTransform=this._delegateMotionStateGetWorldTransform,t.setWorldTransform=this._delegateMotionStateSetWorldTransform),t.clear=this._delegateMotionStateClear,t._rigidbody=this,this._nativeMotionState=t;var r=new e.btRigidBodyConstructionInfo(0,t,null,wi._nativeVector3Zero),i=new e.btRigidBody(r);i.setUserIndex(this.id),this._nativeColliderObject=i,super._onAdded(),this.mass=this._mass,this.linearFactor=this._linearFactor,this.angularFactor=this._angularFactor,this.linearDamping=this._linearDamping,this.angularDamping=this._angularDamping,this.overrideGravity=this._overrideGravity,this.gravity=this._gravity,this.isKinematic=this._isKinematic,e.destroy(r)}_onShapeChange(e){super._onShapeChange(e),this._isKinematic?this._updateMass(0):(this._nativeColliderObject.setCenterOfMassTransform(this._nativeColliderObject.getWorldTransform()),this._updateMass(this._mass))}_parse(e){null!=e.friction&&(this.friction=e.friction),null!=e.rollingFriction&&(this.rollingFriction=e.rollingFriction),null!=e.restitution&&(this.restitution=e.restitution),null!=e.isTrigger&&(this.isTrigger=e.isTrigger),null!=e.mass&&(this.mass=e.mass),null!=e.isKinematic&&(this.isKinematic=e.isKinematic),null!=e.linearDamping&&(this.linearDamping=e.linearDamping),null!=e.angularDamping&&(this.angularDamping=e.angularDamping),null!=e.overrideGravity&&(this.overrideGravity=e.overrideGravity),e.gravity&&(this.gravity.fromArray(e.gravity),this.gravity=this.gravity),super._parse(e),this._parseShape(e.shapes)}_onDestroy(){var e=fe._physics3D;this._nativeMotionState.clear(),e.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(e){super._cloneTo(e);var t=e;t.isKinematic=this._isKinematic,t.mass=this._mass,t.gravity=this._gravity,t.angularDamping=this._angularDamping,t.linearDamping=this._linearDamping,t.overrideGravity=this._overrideGravity,t.linearVelocity=this._linearVelocity,t.angularVelocity=this._angularVelocity,t.linearFactor=this._linearFactor,t.angularFactor=this._angularFactor,t.detectCollisions=this._detectCollisions}applyForce(e,t=null){if(null==this._nativeColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var r=wi._nativeTempVector30;if(r.setValue(-e.x,e.y,e.z),t){var i=wi._nativeTempVector31;i.setValue(-t.x,t.y,t.z),this._nativeColliderObject.applyForce(r,i)}else this._nativeColliderObject.applyCentralForce(r)}applyTorque(e){if(null==this._nativeColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=wi._nativeTempVector30;t.setValue(-e.x,e.y,e.z),this._nativeColliderObject.applyTorque(t)}applyImpulse(e,t=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.";wi._nativeImpulse.setValue(-e.x,e.y,e.z),t?(wi._nativeImpulseOffset.setValue(-t.x,t.y,t.z),this._nativeColliderObject.applyImpulse(wi._nativeImpulse,wi._nativeImpulseOffset)):this._nativeColliderObject.applyCentralImpulse(wi._nativeImpulse)}applyTorqueImpulse(e){if(null==this._nativeColliderObject)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";var t=wi._nativeTempVector30;t.setValue(-e.x,e.y,e.z),this._nativeColliderObject.applyTorqueImpulse(t)}wakeUp(){this._nativeColliderObject&&this._nativeColliderObject.activate(!1)}clearForces(){var e=this._nativeColliderObject;if(null==e)throw"Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";e.clearForces();var t=wi._nativeVector3Zero;e.setInterpolationLinearVelocity(t),e.setLinearVelocity(t),e.setInterpolationAngularVelocity(t),e.setAngularVelocity(t)}}wi.TYPE_STATIC=0,wi.TYPE_DYNAMIC=1,wi.TYPE_KINEMATIC=2,wi._BT_DISABLE_WORLD_GRAVITY=1,wi._BT_ENABLE_GYROPSCOPIC_FORCE=2;class Vi extends Te{static __init__(){Vi._nativeNormal=new fe._physics3D.btVector3(0,0,0)}constructor(e,t){super(),this._normal=e,this._offset=t,this._type=Te.SHAPETYPES_STATICPLANE,Vi._nativeNormal.setValue(-e.x,e.y,e.z),this._nativeShape=new fe._physics3D.btStaticPlaneShape(Vi._nativeNormal,t)}clone(){var e=new Vi(this._normal,this._offset);return this.cloneTo(e),e}}class bi{static __init__(){}static _createMesh(e,r,i){var n=t.LayaGL.instance,a=new Ci,s=new Ii(a),o=new d(4*r.length,n.STATIC_DRAW,!0);o.vertexDeclaration=e,o.setData(r.buffer),a._vertexBuffer=o,a._vertexCount+=o.vertexCount;var l=new c(c.INDEXTYPE_USHORT,i.length,n.STATIC_DRAW,!0);l.setData(i),a._indexBuffer=l;a._setBuffer(o,l),s._vertexBuffer=o,s._indexBuffer=l,s._setIndexRange(0,l.indexCount);var _=s._subIndexBufferStart,h=s._subIndexBufferCount,u=s._boneIndicesList;_.length=1,h.length=1,u.length=1,_[0]=0,h[0]=l.indexCount;var f=[];f.push(s),a._setSubMeshes(f);var E=o._byteLength+l._byteLength;return a._setCPUMemory(E),a._setGPUMemory(E),a}static createBox(e=1,t=1,r=1){var i=v.getVertexDeclaration("POSITION,NORMAL,UV"),n=e/2,a=t/2,s=r/2,o=new Float32Array([-n,a,-s,0,1,0,0,0,n,a,-s,0,1,0,1,0,n,a,s,0,1,0,1,1,-n,a,s,0,1,0,0,1,-n,-a,-s,0,-1,0,0,1,n,-a,-s,0,-1,0,1,1,n,-a,s,0,-1,0,1,0,-n,-a,s,0,-1,0,0,0,-n,a,-s,-1,0,0,0,0,-n,a,s,-1,0,0,1,0,-n,-a,s,-1,0,0,1,1,-n,-a,-s,-1,0,0,0,1,n,a,-s,1,0,0,1,0,n,a,s,1,0,0,0,0,n,-a,s,1,0,0,0,1,n,-a,-s,1,0,0,1,1,-n,a,s,0,0,1,0,0,n,a,s,0,0,1,1,0,n,-a,s,0,0,1,1,1,-n,-a,s,0,0,1,0,1,-n,a,-s,0,0,-1,1,0,n,a,-s,0,0,-1,0,0,n,-a,-s,0,0,-1,0,1,-n,-a,-s,0,0,-1,1,1]),l=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 bi._createMesh(i,o,l)}static createCapsule(e=.5,t=2,r=16,i=32){var n,a,s=(r+1)*(i+1)*2+2*(i+1),o=3*r*(i+1)*2*2+2*i*3,l=v.getVertexDeclaration("POSITION,NORMAL,UV"),_=l.vertexStride/4,h=new Float32Array(s*_),c=new Uint16Array(o),d=Math.PI/2/r,u=2*Math.PI/i,f=t/2-e,E=0,T=0,m=0,p=0,g=0,S=0;for(n=0;n<=r;n++)for(a=0;a<=i;a++)E=e*Math.cos(n*d)*Math.cos(a*u+Math.PI),T=e*Math.sin(n*d),m=e*Math.cos(n*d)*Math.sin(a*u+Math.PI),h[p++]=E,h[p++]=T+f,h[p++]=m,h[p++]=E,h[p++]=T,h[p++]=m,h[p++]=1-a/i,h[p++]=(1-n/r)*(Math.PI*e/2/(t+Math.PI*e)),n0&&".."!==i[s]&&(i.splice(s,2),n-=2)}r=i.join("/")}return r}static _endLoad(e,r=null,i=null){if(i)for(var n=0,a=i.length;n0){var f=c/d,E=t.Handler.create(null,Bi._onProcessChange,[e,u,f],!1);Bi._innerFourthLevelLoaderManager._create(_,!1,t.Handler.create(null,Bi._onHierarchyInnerForthLevResouLoaded,[e,E,r,h,s,o,l,u+f*_.length,f]),E,null,null,null,1,!0)}else Bi._onHierarchyInnerForthLevResouLoaded(e,null,r,h,s,o,l,u,f)}static _onHierarchyInnerForthLevResouLoaded(e,r,i,n,a,s,o,l,_){if(r&&r.recover(),o.length>0){var h=t.Handler.create(null,Bi._onProcessChange,[e,l,_],!1);Bi._innerThirdLevelLoaderManager._create(o,!1,t.Handler.create(null,Bi._onHierarchyInnerThirdLevResouLoaded,[e,h,i,n,a,s,l+_*s.length,_]),r,null,null,null,1,!0)}else Bi._onHierarchyInnerThirdLevResouLoaded(e,null,i,n,a,s,l,_)}static _onHierarchyInnerThirdLevResouLoaded(e,r,i,n,a,s,o,l){if(r&&r.recover(),s.length>0){var _=t.Handler.create(null,Bi._onProcessChange,[e,o,l],!1);Bi._innerSecondLevelLoaderManager._create(s,!1,t.Handler.create(null,Bi._onHierarchyInnerSecondLevResouLoaded,[e,_,i,n,a,o+l*s.length,l]),r,null,null,null,1,!0)}else Bi._onHierarchyInnerSecondLevResouLoaded(e,null,i,n,a,o,l)}static _onHierarchyInnerSecondLevResouLoaded(e,r,i,n,a,s,o){if(r&&r.recover(),a.length>0){var l=t.Handler.create(null,Bi._onProcessChange,[e,s,o],!1);Bi._innerFirstLevelLoaderManager._create(a,!1,t.Handler.create(null,Bi._onHierarchyInnerFirstLevResouLoaded,[e,l,i,n]),r,null,null,null,1,!0)}else Bi._onHierarchyInnerFirstLevResouLoaded(e,null,i,n)}static _onHierarchyInnerFirstLevResouLoaded(e,t,r,i){t&&t.recover(),e._cache=e._createCache;var n="Scene3D"===r.data.type?li._parseScene(r,e._propertyParams,e._constructParams):li._parse(r,e._propertyParams,e._constructParams);Bi._endLoad(e,n,i)}static _loadMesh(e){e.on(t.Event.LOADED,null,Bi._onMeshLmLoaded,[e]),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _onMeshLmLoaded(e,t){e._cache=e._createCache;var r=Ci._parse(t,e._propertyParams,e._constructParams);Bi._endLoad(e,r)}static _loadMaterial(e){e.on(t.Event.LOADED,null,Bi._onMaterilLmatLoaded,[e]),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _onMaterilLmatLoaded(e,r){var i,n=e.url,a=M.getURLVerion(n),s=t.URL.getPath(n),o=[],l=[];r.customProps;switch(r.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":var _,h,c=r.props.textures;if(c)for(_=0,h=c.length;_0){var m=t.Handler.create(null,Bi._onProcessChange,[e,T,f/E],!1);Bi._innerFourthLevelLoaderManager._create(o,!1,t.Handler.create(null,Bi._onMateialTexturesLoaded,[e,m,r,l]),m,null,null,null,1,!0)}else Bi._onMateialTexturesLoaded(e,null,r,null)}static _onMateialTexturesLoaded(e,t,r,i){e._cache=e._createCache;var n=Ge._parse(r,e._propertyParams,e._constructParams);Bi._endLoad(e,n,i),t&&t.recover()}static _loadAvatar(e){e.on(t.Event.LOADED,null,function(t){e._cache=e._createCache;var r=Ai._parse(t,e._propertyParams,e._constructParams);Bi._endLoad(e,r)}),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _loadAnimationClip(e){e.on(t.Event.LOADED,null,function(t){e._cache=e._createCache;var r=Si._parse(t,e._propertyParams,e._constructParams);Bi._endLoad(e,r)}),e.load(e.url,t.Loader.BUFFER,!1,null,!0)}static _loadTexture2D(e){var r,i=e.url,n=i.lastIndexOf(".")+1,a=i.indexOf("?"),s=-1==a?i.length:a;switch(i.substr(n,s-n)){case"jpg":case"jpeg":case"bmp":case"gif":case"png":r="nativeimage";break;case"dds":case"ktx":case"pvr":r=t.Loader.BUFFER}e.on(t.Event.LOADED,null,function(r){e._cache=e._createCache;var i=t.Texture2D._parse(r,e._propertyParams,e._constructParams);Bi._endLoad(e,i)}),e.load(e.url,r,!1,null,!0)}static _loadTextureCube(e){e.on(t.Event.LOADED,null,Bi._onTextureCubeLtcLoaded,[e]),e.load(e.url,t.Loader.JSON,!1,null,!0)}static _onTextureCubeLtcLoaded(e,r){var i=t.URL.getPath(e.url),n=[Bi.formatRelativePath(i,r.front),Bi.formatRelativePath(i,r.back),Bi.formatRelativePath(i,r.left),Bi.formatRelativePath(i,r.right),Bi.formatRelativePath(i,r.up),Bi.formatRelativePath(i,r.down)];Bi._onProcessChange(e,0,1/7,1);var a=t.Handler.create(null,Bi._onProcessChange,[e,1/7,6/7],!1);Bi._innerFourthLevelLoaderManager.load(n,t.Handler.create(null,Bi._onTextureCubeImagesLoaded,[e,n,a]),a,"nativeimage")}static _onTextureCubeImagesLoaded(e,r,i){for(var n=new Array(6),a=0;a<6;a++)n[a]=t.Loader.getRes(r[a]);e._cache=e._createCache;var s=yi._parse(n,e._propertyParams,e._constructParams);for(i.recover(),a=0;a<6;a++)t.Loader.clearRes(r[a]);Bi._endLoad(e,s)}static _onProcessChange(e,r,i,n){(n=r+n*i)<1&&e.event(t.Event.PROGRESS,n)}static init(e,t,r=null,i=null){if(!Bi._isInit){Bi._isInit=!0,(r=r||s._default).cloneTo(Bi._config),U.debugFrustumCulling=r.debugFrustumCulling,Bi._editerEnvironment=Bi._config._editerEnvironment,oi.octreeCulling=r.octreeCulling,oi.octreeInitialSize=r.octreeInitialSize,oi.octreeInitialCenter=r.octreeInitialCenter,oi.octreeMinNodeSize=r.octreeMinNodeSize,oi.octreeLooseness=r.octreeLooseness;var n=window.Physics3D;null==n?(fe._enbalePhysics=!1,Bi.__init__(e,t,Bi._config),i&&i.run()):(fe._enbalePhysics=!0,n(1024*Bi._config.defaultPhysicsMemory*1024).then(function(){Bi.__init__(e,t,Bi._config),i&&i.run()}))}}}Bi.HIERARCHY="HIERARCHY",Bi.MESH="MESH",Bi.MATERIAL="MATERIAL",Bi.TEXTURE2D="TEXTURE2D",Bi.TEXTURECUBE="TEXTURECUBE",Bi.ANIMATIONCLIP="ANIMATIONCLIP",Bi.AVATAR="AVATAR",Bi.TERRAINHEIGHTDATA="TERRAINHEIGHTDATA",Bi.TERRAINRES="TERRAIN",Bi._innerFirstLevelLoaderManager=new t.LoaderManager,Bi._innerSecondLevelLoaderManager=new t.LoaderManager,Bi._innerThirdLevelLoaderManager=new t.LoaderManager,Bi._innerFourthLevelLoaderManager=new t.LoaderManager,Bi._isInit=!1,Bi._editerEnvironment=!1,Bi._config=new s,Bi.physicsSettings=new Nt,window.Laya3D=Bi;class Ui extends t.Component{constructor(){super(...arguments),this._indexInPool=-1}get isSingleton(){return!1}_checkProcessTriggers(){var e=Ui.prototype;return this.onTriggerEnter!==e.onTriggerEnter||(this.onTriggerStay!==e.onTriggerStay||this.onTriggerExit!==e.onTriggerExit)}_checkProcessCollisions(){var e=Ui.prototype;return this.onCollisionEnter!==e.onCollisionEnter||(this.onCollisionStay!==e.onCollisionStay||this.onCollisionExit!==e.onCollisionExit)}_onAwake(){this.onAwake(),this.onStart!==Ui.prototype.onStart&&t.Laya.startTimer.callLater(this,this.onStart)}_onEnable(){this.owner._scene._addScript(this);var e=Ui.prototype;this.onKeyDown!==e.onKeyDown&&t.Laya.stage.on(t.Event.KEY_DOWN,this,this.onKeyDown),this.onKeyPress!==e.onKeyPress&&t.Laya.stage.on(t.Event.KEY_PRESS,this,this.onKeyUp),this.onKeyUp!==e.onKeyUp&&t.Laya.stage.on(t.Event.KEY_UP,this,this.onKeyUp)}_onDisable(){this.owner._scene._removeScript(this),this.owner.offAllCaller(this),t.Laya.stage.offAllCaller(this)}_isScript(){return!0}_onAdded(){var e=this.owner,t=e._scripts;t||(e._scripts=t=[]),t.push(this),e._needProcessCollisions||(e._needProcessCollisions=this._checkProcessCollisions()),e._needProcessTriggers||(e._needProcessTriggers=this._checkProcessTriggers())}_onDestroy(){var e=this.owner._scripts;e.splice(e.indexOf(this),1);var t=this.owner;t._needProcessTriggers=!1;for(var r=0,i=e.length;r=0&&e=0&&t0?s:0,_=Math.floor(i.width/(2-o)),h=Math.floor(i.height/(2-l)),c=Math.max(_,h);a=Math.log2(c)+this._diffusion-10;var d=Math.floor(a),u=Math.min(Math.max(d,1),ki.MAXPYRAMIDSIZE),f=.5+a-d;this._shaderData.setNumber(ki.SHADERVALUE_SAMPLESCALE,f);var E=I.gammaToLinearSpace(this.threshold),T=E*this._softKnee+1e-5;this._shaderThreshold.setValue(E,E-T,2*T,.25/T),this._shaderData.setVector(ki.SHADERVALUE_THRESHOLD,this._shaderThreshold);var m=I.gammaToLinearSpace(this.clamp);this._shaderParams.setValue(m,0,0,0),this._shaderData.setVector(ki.SHADERVALUE_PARAMS,this._shaderParams);for(var p=this.fastMode?1:0,g=e.source,S=0;S=0;S--)R=(v=2*S)+1,D=this._pyramid[v],x=this._pyramid[R],r.setShaderDataTexture(this._shaderData,ki.SHADERVALUE_BLOOMTEX,D),r.blitScreenTriangle(M,x,this._shader,this._shaderData,ki.SUBSHADER_UPSAMPLETENT+p),M=x;var L=this._linearColor;this.color.toLinear(L);var C=Math.pow(2,this._intensity/10)-1,y=this._shaderSetting;this._shaderSetting.setValue(f,C,this._dirtIntensity,u);var O=this.dirtTexture?this.dirtTexture:t.Texture2D.blackTexture,N=O.width/O.height,P=i.width/i.height,w=this._dirtTileOffset;N>P?w.setValue(P/N,1,.5*(1-w.x),0):N>>0)+(t>>>0),a=r+e+(n/2>>>31)>>>0,s=n>>>0;this._state0U=r,this._state0L=i;var o=0,l=0;o=(e^=o=e<<23|(-512&t)>>>9)^r,l=(t^=l=t<<23)^i;o^=e>>>18,l^=t>>>18|(262143&e)<<14;return o^=r>>>5,l^=i>>>5|(31&r)<<27,this._state1U=o,this._state1L=l,[a,s]}random(){var e=this.randomint(),t=e[0],r=1023<<20|t>>>12,i=0|(e[1]>>>12|(4095&t)<<20);return Xi._CONVERTION_BUFFER.setUint32(0,r,!1),Xi._CONVERTION_BUFFER.setUint32(4,i,!1),Xi._CONVERTION_BUFFER.getFloat64(0,!1)-1}}Xi._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8)),Xi.defaultRand=new Xi([0,Date.now()/65536,0,Date.now()%65536]);class Yi{constructor(e,t){this._width=0,this._height=0,this._width=e,this._height=t}static get fullScreen(){return new Yi(-1,-1)}get width(){return-1===this._width?J.clientWidth:this._width}get height(){return-1===this._height?J.clientHeight:this._height}}e.AnimationClip=Si,e.AnimationClipParser03=Ti,e.AnimationClipParser04=pi,e.AnimationEvent=hi,e.AnimationNode=Ri,e.AnimationTransform3D=vi,e.Animator=w,e.AnimatorControllerLayer=O,e.AnimatorPlayState=y,e.AnimatorState=N,e.AnimatorStateScript=class{constructor(){}onStateEnter(){}onStateUpdate(){}onStateExit(){}},e.Avatar=Ai,e.BaseCamera=Q,e.BaseMaterial=Ge,e.BaseRender=ke,e.BaseShape=Et,e.BatchMark=A,e.BlinnPhongMaterial=He,e.BlitScreenQuadCMD=re,e.BloomEffect=ki,e.BoundBox=Oe,e.BoundFrustum=k,e.BoundSphere=Ne,e.Bounds=We,e.BoundsOctree=si,e.BoundsOctreeNode=ni,e.BoxColliderShape=me,e.BoxShape=mt,e.BufferState=_,e.Burst=st,e.Camera=oe,e.CapsuleColliderShape=pe,e.CastShadowList=Mt,e.CharacterController=Pi,e.CircleShape=pt,e.ColliderShape=Te,e.Collision=Le,e.CollisionTool=Ce,e.CollisionUtils=W,e.Color=I,e.ColorOverLifetime=lt,e.Command=te,e.CommandBuffer=ae,e.CompoundColliderShape=ge,e.ConchQuaternion=Ei,e.ConchVector3=fi,e.ConchVector4=ui,e.ConeColliderShape=Se,e.ConeShape=gt,e.Config3D=s,e.Constraint3D=class{constructor(){}},e.ConstraintComponent=class extends t.Component{constructor(){super(),this._feedbackEnabled=!1}get enabled(){return super.enabled}set enabled(e){this._nativeConstraint.IsEnabled=e,super.enabled=e}get breakingImpulseThreshold(){return this._breakingImpulseThreshold}set breakingImpulseThreshold(e){this._nativeConstraint.BreakingImpulseThreshold=e,this._breakingImpulseThreshold=e}get appliedImpulse(){return this._feedbackEnabled||(this._nativeConstraint.EnableFeedback(!0),this._feedbackEnabled=!0),this._nativeConstraint.AppliedImpulse}get connectedBody(){return this._connectedBody}set connectedBody(e){this._connectedBody=e}_onDestroy(){fe._physics3D.destroy(this._nativeConstraint),this._nativeConstraint=null}},e.ContactPoint=xe,e.ContainmentType=H,e.CylinderColliderShape=ve,e.DefineDatas=m,e.DirectionLight=Ve,e.DynamicBatchManager=l,e.EffectMaterial=Ft,e.Emission=$e,e.ExtendTerrainMaterial=Bt,e.FloatKeyframe=qt,e.FrameOverTime=_t,e.FrustumCulling=U,e.GeometryElement=h,e.Gradient=je,e.GradientAngularVelocity=ht,e.GradientColor=ot,e.GradientDataInt=ct,e.GradientDataNumber=et,e.GradientDataVector2=Hi,e.GradientMode=Ze,e.GradientSize=dt,e.GradientVelocity=ut,e.HalfFloatUtils=mi,e.HeightMap=Gi,e.HeightfieldColliderShape=class{constructor(){}},e.HemisphereShape=St,e.HitResult=Me,e.ILaya3D=o,e.IndexBuffer3D=c,e.Input3D=Ot,e.Keyframe=jt,e.KeyframeNode=_i,e.KeyframeNodeList=gi,e.KeyframeNodeOwner=P,e.Laya3D=Bi,e.LightSprite=we,e.LoadModelV04=xi,e.LoadModelV05=Mi,e.MathUtils3D=r,e.Matrix3x3=f,e.Matrix4x4=T,e.Mesh=Ci,e.MeshColliderShape=Re,e.MeshFilter=Ue,e.MeshReader=Li,e.MeshRenderDynamicBatchManager=ce,e.MeshRenderStaticBatchManager=ue,e.MeshRenderer=Xe,e.MeshSprite3D=Ye,e.MeshSprite3DShaderDeclaration=Be,e.MeshTerrainSprite3D=zi,e.MouseTouch=Ct,e.OctreeMotionList=ai,e.PBRSpecularMaterial=Ut,e.PBRStandardMaterial=Gt,e.ParallelSplitShadowMap=Pe,e.Physics3D=fe,e.Physics3DUtils=Ee,e.PhysicsCollider=Ni,e.PhysicsComponent=De,e.PhysicsSettings=Nt,e.PhysicsSimulation=ye,e.PhysicsTriggerComponent=Oi,e.PhysicsUpdateList=Ie,e.Picker=Z,e.PixelLineData=class{constructor(){this.startPosition=new a,this.endPosition=new a,this.startColor=new I,this.endColor=new I}cloneTo(e){this.startPosition.cloneTo(e.startPosition),this.endPosition.cloneTo(e.endPosition),this.startColor.cloneTo(e.startColor),this.endColor.cloneTo(e.endColor)}},e.PixelLineFilter=ei,e.PixelLineMaterial=Jr,e.PixelLineRenderer=ti,e.PixelLineSprite3D=ri,e.PixelLineVertex=$r,e.Plane=G,e.Point2PointConstraint=class{constructor(){this._pivotInA=new a,this._pivotInB=new a}get pivotInA(){return this._pivotInA}set pivotInA(e){this._pivotInA=e}get pivotInB(){return this._pivotInB}set pivotInB(e){this._pivotInB=e}get damping(){return this._damping}set damping(e){this._damping=e}get impulseClamp(){return this._impulseClamp}set impulseClamp(e){this._impulseClamp=e}get tau(){return this._tau}set tau(e){this._tau=e}},e.PointLight=be,e.PostProcess=bt,e.PostProcessEffect=Wi,e.PostProcessRenderContext=Vt,e.PrimitiveMesh=bi,e.Quaternion=E,e.QuaternionKeyframe=ci,e.Rand=nt,e.RandX=Xi,e.Ray=z,e.RenderContext3D=J,e.RenderElement=le,e.RenderQueue=ii,e.RenderState=ze,e.RenderTexture=Y,e.RenderableSprite3D=F,e.Rigidbody3D=wi,e.RotationOverLifetime=ft,e.Scene3D=oi,e.Scene3DShaderDeclaration=se,e.Scene3DUtils=li,e.SceneManager=class{constructor(){}},e.ScreenQuad=$,e.ScreenTriangle=ee,e.Script3D=Ui,e.SetRenderTargetCMD=ie,e.SetShaderDataTextureCMD=ne,e.Shader3D=L,e.ShaderData=p,e.ShaderDefines=C,e.ShaderInit3D=Qr,e.ShaderInstance=nr,e.ShaderPass=ar,e.ShaderVariable=ir,e.ShapeUtils=Tt,e.ShuriKenParticle3D=xt,e.ShuriKenParticle3DShaderDeclaration=Ke,e.ShurikenParticleData=Je,e.ShurikenParticleMaterial=qe,e.ShurikenParticleRenderer=Qe,e.ShurikenParticleSystem=at,e.SimpleSingletonList=Lt,e.SingletonList=he,e.Size=Yi,e.SizeOverLifetime=Rt,e.SkinnedMeshRenderer=Xt,e.SkinnedMeshSprite3D=Yt,e.SkinnedMeshSprite3DShaderDeclaration=kt,e.SkyBox=q,e.SkyBoxMaterial=Di,e.SkyDome=wt,e.SkyMesh=j,e.SkyProceduralMaterial=zt,e.SkyRenderer=K,e.SphereColliderShape=Ae,e.SphereShape=vt,e.SpotLight=Fe,e.Sprite3D=b,e.StartFrame=At,e.StaticBatchManager=B,e.StaticPlaneColliderShape=Vi,e.SubMesh=Ii,e.SubMeshDynamicBatch=R,e.SubMeshInstanceBatch=D,e.SubMeshRenderElement=_e,e.SubMeshStaticBatch=de,e.SubShader=sr,e.TextMesh=class{get text(){return this._text}set text(e){this._text=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e}get color(){return this._color}set color(e){this._color=e}constructor(){}_createVertexBuffer(e){}_resizeVertexBuffer(e){}_addChar(){}},e.TextureCube=yi,e.TextureGenerator=x,e.TextureMode=Kt,e.TextureSheetAnimation=Dt,e.Touch=yt,e.TrailFilter=er,e.TrailGeometry=$t,e.TrailMaterial=Zt,e.TrailRenderer=tr,e.TrailSprite3D=rr,e.Transform3D=V,e.UnlitMaterial=Ht,e.Utils3D=M,e.Vector2=i,e.Vector3=a,e.Vector3Keyframe=di,e.Vector4=n,e.VelocityOverLifetime=It,e.VertexBuffer3D=d,e.VertexDeclaration=g,e.VertexElement=S,e.VertexElementFormat=u,e.VertexMesh=v,e.VertexPositionTerrain=Fi,e.VertexPositionTexture0=Pt,e.VertexShuriKenParticle=tt,e.VertexShurikenParticleBillboard=rt,e.VertexShurikenParticleMesh=it,e.VertexTrail=Jt,e.Viewport=X,e.WaterPrimaryMaterial=Wt}(window.Laya=window.Laya||{},Laya);