@quake2ts/engine 0.0.781 → 0.0.785
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.global.js +1 -1
- package/dist/browser/index.global.js.map +1 -1
- package/dist/cjs/index.cjs +4 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/render/camera.d.ts +1 -0
- package/dist/types/render/camera.d.ts.map +1 -1
- package/dist/types/render/webgpu/frame.d.ts +24 -1
- package/dist/types/render/webgpu/frame.d.ts.map +1 -1
- package/dist/types/render/webgpu/pipelines/bspPipeline.d.ts +3 -0
- package/dist/types/render/webgpu/pipelines/bspPipeline.d.ts.map +1 -1
- package/dist/types/render/webgpu/pipelines/skybox.d.ts +1 -0
- package/dist/types/render/webgpu/pipelines/skybox.d.ts.map +1 -1
- package/dist/types/render/webgpu/renderer.d.ts +4 -2
- package/dist/types/render/webgpu/renderer.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -476,7 +476,7 @@ void main() {
|
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
o_color = finalColor;
|
|
479
|
-
}`;function Y1(t){let e=t.x*t.x+t.y*t.y+t.z*t.z;if(e<=0)return{x:0,y:0,z:1};let r=1/Math.sqrt(e);return{x:t.x*r,y:t.y*r,z:t.z*r}}function Vd(t,e,r){return t+(e-t)*r}function Dh(t,e,r){return{x:Vd(t.x,e.x,r),y:Vd(t.y,e.y,r),z:Vd(t.z,e.z,r)}}function $1(t,e,r){return[t/r.skinWidth,1-e/r.skinHeight]}function Xd(t){if(t.glCommands.length===0){let n=[],i=[];return t.triangles.forEach(a=>{let o=n.length;for(let s=0;s<3;s+=1){let c=a.vertexIndices[s],l=a.texCoordIndices[s],d=t.texCoords[l];n.push({vertexIndex:c,texCoord:$1(d.s,d.t,t.header)})}i.push(o,o+1,o+2)}),{vertices:n,indices:new Uint16Array(i)}}let e=[],r=[];for(let n of t.glCommands){let i=e.length;if(e.push(...n.vertices.map(a=>({vertexIndex:a.vertexIndex,texCoord:[a.s,1-a.t]}))),n.mode==="strip")for(let a=0;a<n.vertices.length-2;a+=1){let o=a%2===0,s=i+a+(o?0:1),c=i+a+(o?1:0),l=i+a+2;r.push(s,c,l)}else for(let a=1;a<n.vertices.length-1;a+=1)r.push(i,i+a,i+a+1)}return{vertices:e,indices:new Uint16Array(r)}}function Kd(t,e,r){let{frame0:n,frame1:i,lerp:a}=r,o=t.frames[n],s=t.frames[i];if(!o||!s)throw new Error("Requested MD2 frames are out of range");let c=new Float32Array(e.vertices.length*8);return e.vertices.forEach((l,d)=>{let f=o.vertices[l.vertexIndex],u=s.vertices[l.vertexIndex];if(!f||!u)throw new Error("MD2 vertex index out of range for frame");let h=Dh(f.position,u.position,a),m=Y1(Dh(f.normal,u.normal,a)),g=d*8;c[g]=h.x,c[g+1]=h.y,c[g+2]=h.z,c[g+3]=m.x,c[g+4]=m.y,c[g+5]=m.z,c[g+6]=l.texCoord[0],c[g+7]=l.texCoord[1]}),c}var ma=class{constructor(e,r,n){this.gl=e,this.geometry=Xd(r),this.vertexBuffer=new Ae(e,e.STATIC_DRAW),this.indexBuffer=new Qe(e,e.STATIC_DRAW),this.vertexArray=new Ee(e),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:32,offset:0},{index:1,size:3,type:e.FLOAT,stride:32,offset:12},{index:2,size:2,type:e.FLOAT,stride:32,offset:24}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,e.STATIC_DRAW),this.update(r,n)}update(e,r){let n=Kd(e,this.geometry,r);this.vertexBuffer.upload(n,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose(),this.wireframeIndexBuffer?.dispose()}},pa=class{constructor(e){this.uniformDlights=[];this.gl=e,this.program=le.create(e,{vertex:Gd,fragment:Wd},{a_position:0,a_normal:1,a_texCoord:2}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformModelMatrix=this.program.getUniformLocation("u_modelMatrix"),this.uniformLightDir=this.program.getUniformLocation("u_lightDir"),this.uniformAmbient=this.program.getUniformLocation("u_ambient"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor"),this.uniformNumDlights=this.program.getUniformLocation("u_numDlights");for(let r=0;r<Dn;r++)this.uniformDlights.push({pos:this.program.getUniformLocation(`u_dlights[${r}].position`),color:this.program.getUniformLocation(`u_dlights[${r}].color`),intensity:this.program.getUniformLocation(`u_dlights[${r}].intensity`)});this.uniformBrightness=this.program.getUniformLocation("u_brightness"),this.uniformGamma=this.program.getUniformLocation("u_gamma"),this.uniformFullbright=this.program.getUniformLocation("u_fullbright"),this.uniformGlobalAmbient=this.program.getUniformLocation("u_globalAmbient")}get shaderSize(){return this.program.sourceSize}bind(e){let{modelViewProjection:r,modelMatrix:n,lightDirection:i=[0,0,1],ambientLight:a=.2,tint:o=[1,1,1,1],diffuseSampler:s=0,dlights:c=[],renderMode:l,brightness:d=1,gamma:f=1,fullbright:u=!1,ambient:h=0}=e,m=new Float32Array(i),g=new Float32Array(o);this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),n?this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,n):this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])),this.gl.uniform3fv(this.uniformLightDir,m),this.gl.uniform1f(this.uniformAmbient,a),this.gl.uniform4fv(this.uniformTint,g),this.gl.uniform1i(this.uniformDiffuse,s);let p=0,y=[1,1,1,1];l&&(l.mode==="solid"||l.mode==="wireframe"?p=1:l.mode==="solid-faceted"&&(p=2),l.color?y=[...l.color]:l.generateRandomColor),this.gl.uniform1i(this.uniformRenderMode,p),this.gl.uniform4f(this.uniformSolidColor,y[0],y[1],y[2],y[3]);let v=Math.min(c.length,Dn);this.gl.uniform1i(this.uniformNumDlights,v);for(let x=0;x<v;x++){let b=c[x];this.gl.uniform3f(this.uniformDlights[x].pos,b.origin.x,b.origin.y,b.origin.z),this.gl.uniform3f(this.uniformDlights[x].color,b.color.x,b.color.y,b.color.z),this.gl.uniform1f(this.uniformDlights[x].intensity,b.intensity)}this.gl.uniform1f(this.uniformBrightness,d),this.gl.uniform1f(this.uniformGamma,f),this.gl.uniform1i(this.uniformFullbright,u?1:0),this.gl.uniform1f(this.uniformGlobalAmbient,h)}draw(e,r){if(e.vertexArray.bind(),r&&r.mode==="wireframe"){if(!e.wireframeIndexBuffer){e.wireframeIndexBuffer=new Qe(this.gl,this.gl.STATIC_DRAW);let n=ua(e.geometry.indices);e.wireframeIndexBuffer.upload(n),e.wireframeIndexCount=n.length}e.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,e.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else e.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,e.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var $=1e-6,xe=typeof Float32Array<"u"?Float32Array:Array,er=Math.random,zh="zyx";function tn(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var OE=Math.PI/180,UE=180/Math.PI;function Oh(){var t=new xe(9);return xe!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var j={};Na(j,{add:()=>Fy,adjoint:()=>ny,clone:()=>j1,copy:()=>Q1,create:()=>Z1,decompose:()=>vy,determinant:()=>iy,equals:()=>Oy,exactEquals:()=>zy,frob:()=>By,fromQuat:()=>wy,fromQuat2:()=>yy,fromRotation:()=>hy,fromRotationTranslation:()=>Hh,fromRotationTranslationScale:()=>_y,fromRotationTranslationScaleOrigin:()=>Sy,fromScaling:()=>fy,fromTranslation:()=>uy,fromValues:()=>J1,fromXRotation:()=>my,fromYRotation:()=>py,fromZRotation:()=>gy,frustum:()=>My,getRotation:()=>xy,getScaling:()=>Vh,getTranslation:()=>by,identity:()=>Uh,invert:()=>ry,lookAt:()=>Cy,mul:()=>Uy,multiply:()=>Nh,multiplyScalar:()=>ky,multiplyScalarAndAdd:()=>Dy,ortho:()=>Ty,orthoNO:()=>Wh,orthoZO:()=>Ry,perspective:()=>Ay,perspectiveFromFieldOfView:()=>Ly,perspectiveNO:()=>Gh,perspectiveZO:()=>Ey,rotate:()=>sy,rotateX:()=>ly,rotateY:()=>cy,rotateZ:()=>dy,scale:()=>oy,set:()=>ey,str:()=>Iy,sub:()=>Ny,subtract:()=>Xh,targetTo:()=>Py,translate:()=>ay,transpose:()=>ty});function Z1(){var t=new xe(16);return xe!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function j1(t){var e=new xe(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Q1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function J1(t,e,r,n,i,a,o,s,c,l,d,f,u,h,m,g){var p=new xe(16);return p[0]=t,p[1]=e,p[2]=r,p[3]=n,p[4]=i,p[5]=a,p[6]=o,p[7]=s,p[8]=c,p[9]=l,p[10]=d,p[11]=f,p[12]=u,p[13]=h,p[14]=m,p[15]=g,p}function ey(t,e,r,n,i,a,o,s,c,l,d,f,u,h,m,g,p){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=d,t[10]=f,t[11]=u,t[12]=h,t[13]=m,t[14]=g,t[15]=p,t}function Uh(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ty(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function ry(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],d=e[8],f=e[9],u=e[10],h=e[11],m=e[12],g=e[13],p=e[14],y=e[15],v=r*s-n*o,x=r*c-i*o,b=r*l-a*o,_=n*c-i*s,w=n*l-a*s,S=i*l-a*c,E=d*g-f*m,L=d*p-u*m,M=d*y-h*m,R=f*p-u*g,I=f*y-h*g,B=u*y-h*p,F=v*B-x*I+b*R+_*M-w*L+S*E;return F?(F=1/F,t[0]=(s*B-c*I+l*R)*F,t[1]=(i*I-n*B-a*R)*F,t[2]=(g*S-p*w+y*_)*F,t[3]=(u*w-f*S-h*_)*F,t[4]=(c*M-o*B-l*L)*F,t[5]=(r*B-i*M+a*L)*F,t[6]=(p*b-m*S-y*x)*F,t[7]=(d*S-u*b+h*x)*F,t[8]=(o*I-s*M+l*E)*F,t[9]=(n*M-r*I-a*E)*F,t[10]=(m*w-g*b+y*v)*F,t[11]=(f*b-d*w-h*v)*F,t[12]=(s*L-o*R-c*E)*F,t[13]=(r*R-n*L+i*E)*F,t[14]=(g*x-m*_-p*v)*F,t[15]=(d*_-f*x+u*v)*F,t):null}function ny(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],d=e[8],f=e[9],u=e[10],h=e[11],m=e[12],g=e[13],p=e[14],y=e[15],v=r*s-n*o,x=r*c-i*o,b=r*l-a*o,_=n*c-i*s,w=n*l-a*s,S=i*l-a*c,E=d*g-f*m,L=d*p-u*m,M=d*y-h*m,R=f*p-u*g,I=f*y-h*g,B=u*y-h*p;return t[0]=s*B-c*I+l*R,t[1]=i*I-n*B-a*R,t[2]=g*S-p*w+y*_,t[3]=u*w-f*S-h*_,t[4]=c*M-o*B-l*L,t[5]=r*B-i*M+a*L,t[6]=p*b-m*S-y*x,t[7]=d*S-u*b+h*x,t[8]=o*I-s*M+l*E,t[9]=n*M-r*I-a*E,t[10]=m*w-g*b+y*v,t[11]=f*b-d*w-h*v,t[12]=s*L-o*R-c*E,t[13]=r*R-n*L+i*E,t[14]=g*x-m*_-p*v,t[15]=d*_-f*x+u*v,t}function iy(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],d=t[9],f=t[10],u=t[11],h=t[12],m=t[13],g=t[14],p=t[15],y=e*o-r*a,v=e*s-n*a,x=r*s-n*o,b=l*m-d*h,_=l*g-f*h,w=d*g-f*m,S=e*w-r*_+n*b,E=a*w-o*_+s*b,L=l*x-d*v+f*y,M=h*x-m*v+g*y;return c*S-i*E+p*L-u*M}function Nh(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],c=e[5],l=e[6],d=e[7],f=e[8],u=e[9],h=e[10],m=e[11],g=e[12],p=e[13],y=e[14],v=e[15],x=r[0],b=r[1],_=r[2],w=r[3];return t[0]=x*n+b*s+_*f+w*g,t[1]=x*i+b*c+_*u+w*p,t[2]=x*a+b*l+_*h+w*y,t[3]=x*o+b*d+_*m+w*v,x=r[4],b=r[5],_=r[6],w=r[7],t[4]=x*n+b*s+_*f+w*g,t[5]=x*i+b*c+_*u+w*p,t[6]=x*a+b*l+_*h+w*y,t[7]=x*o+b*d+_*m+w*v,x=r[8],b=r[9],_=r[10],w=r[11],t[8]=x*n+b*s+_*f+w*g,t[9]=x*i+b*c+_*u+w*p,t[10]=x*a+b*l+_*h+w*y,t[11]=x*o+b*d+_*m+w*v,x=r[12],b=r[13],_=r[14],w=r[15],t[12]=x*n+b*s+_*f+w*g,t[13]=x*i+b*c+_*u+w*p,t[14]=x*a+b*l+_*h+w*y,t[15]=x*o+b*d+_*m+w*v,t}function ay(t,e,r){var n=r[0],i=r[1],a=r[2],o,s,c,l,d,f,u,h,m,g,p,y;return e===t?(t[12]=e[0]*n+e[4]*i+e[8]*a+e[12],t[13]=e[1]*n+e[5]*i+e[9]*a+e[13],t[14]=e[2]*n+e[6]*i+e[10]*a+e[14],t[15]=e[3]*n+e[7]*i+e[11]*a+e[15]):(o=e[0],s=e[1],c=e[2],l=e[3],d=e[4],f=e[5],u=e[6],h=e[7],m=e[8],g=e[9],p=e[10],y=e[11],t[0]=o,t[1]=s,t[2]=c,t[3]=l,t[4]=d,t[5]=f,t[6]=u,t[7]=h,t[8]=m,t[9]=g,t[10]=p,t[11]=y,t[12]=o*n+d*i+m*a+e[12],t[13]=s*n+f*i+g*a+e[13],t[14]=c*n+u*i+p*a+e[14],t[15]=l*n+h*i+y*a+e[15]),t}function oy(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function sy(t,e,r,n){var i=n[0],a=n[1],o=n[2],s=Math.sqrt(i*i+a*a+o*o),c,l,d,f,u,h,m,g,p,y,v,x,b,_,w,S,E,L,M,R,I,B,F,U;return s<$?null:(s=1/s,i*=s,a*=s,o*=s,c=Math.sin(r),l=Math.cos(r),d=1-l,f=e[0],u=e[1],h=e[2],m=e[3],g=e[4],p=e[5],y=e[6],v=e[7],x=e[8],b=e[9],_=e[10],w=e[11],S=i*i*d+l,E=a*i*d+o*c,L=o*i*d-a*c,M=i*a*d-o*c,R=a*a*d+l,I=o*a*d+i*c,B=i*o*d+a*c,F=a*o*d-i*c,U=o*o*d+l,t[0]=f*S+g*E+x*L,t[1]=u*S+p*E+b*L,t[2]=h*S+y*E+_*L,t[3]=m*S+v*E+w*L,t[4]=f*M+g*R+x*I,t[5]=u*M+p*R+b*I,t[6]=h*M+y*R+_*I,t[7]=m*M+v*R+w*I,t[8]=f*B+g*F+x*U,t[9]=u*B+p*F+b*U,t[10]=h*B+y*F+_*U,t[11]=m*B+v*F+w*U,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function ly(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],d=e[9],f=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+l*n,t[5]=o*i+d*n,t[6]=s*i+f*n,t[7]=c*i+u*n,t[8]=l*i-a*n,t[9]=d*i-o*n,t[10]=f*i-s*n,t[11]=u*i-c*n,t}function cy(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],c=e[3],l=e[8],d=e[9],f=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-l*n,t[1]=o*i-d*n,t[2]=s*i-f*n,t[3]=c*i-u*n,t[8]=a*n+l*i,t[9]=o*n+d*i,t[10]=s*n+f*i,t[11]=c*n+u*i,t}function dy(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],c=e[3],l=e[4],d=e[5],f=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+l*n,t[1]=o*i+d*n,t[2]=s*i+f*n,t[3]=c*i+u*n,t[4]=l*i-a*n,t[5]=d*i-o*n,t[6]=f*i-s*n,t[7]=u*i-c*n,t}function uy(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function fy(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function hy(t,e,r){var n=r[0],i=r[1],a=r[2],o=Math.sqrt(n*n+i*i+a*a),s,c,l;return o<$?null:(o=1/o,n*=o,i*=o,a*=o,s=Math.sin(e),c=Math.cos(e),l=1-c,t[0]=n*n*l+c,t[1]=i*n*l+a*s,t[2]=a*n*l-i*s,t[3]=0,t[4]=n*i*l-a*s,t[5]=i*i*l+c,t[6]=a*i*l+n*s,t[7]=0,t[8]=n*a*l+i*s,t[9]=i*a*l-n*s,t[10]=a*a*l+c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function my(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function py(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function gy(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Hh(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,c=i+i,l=a+a,d=n*s,f=n*c,u=n*l,h=i*c,m=i*l,g=a*l,p=o*s,y=o*c,v=o*l;return t[0]=1-(h+g),t[1]=f+v,t[2]=u-y,t[3]=0,t[4]=f-v,t[5]=1-(d+g),t[6]=m+p,t[7]=0,t[8]=u+y,t[9]=m-p,t[10]=1-(d+h),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function yy(t,e){var r=new xe(3),n=-e[0],i=-e[1],a=-e[2],o=e[3],s=e[4],c=e[5],l=e[6],d=e[7],f=n*n+i*i+a*a+o*o;return f>0?(r[0]=(s*o+d*n+c*a-l*i)*2/f,r[1]=(c*o+d*i+l*n-s*a)*2/f,r[2]=(l*o+d*a+s*i-c*n)*2/f):(r[0]=(s*o+d*n+c*a-l*i)*2,r[1]=(c*o+d*i+l*n-s*a)*2,r[2]=(l*o+d*a+s*i-c*n)*2),Hh(t,e,r),t}function by(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Vh(t,e){var r=e[0],n=e[1],i=e[2],a=e[4],o=e[5],s=e[6],c=e[8],l=e[9],d=e[10];return t[0]=Math.sqrt(r*r+n*n+i*i),t[1]=Math.sqrt(a*a+o*o+s*s),t[2]=Math.sqrt(c*c+l*l+d*d),t}function xy(t,e){var r=new xe(3);Vh(r,e);var n=1/r[0],i=1/r[1],a=1/r[2],o=e[0]*n,s=e[1]*i,c=e[2]*a,l=e[4]*n,d=e[5]*i,f=e[6]*a,u=e[8]*n,h=e[9]*i,m=e[10]*a,g=o+d+m,p=0;return g>0?(p=Math.sqrt(g+1)*2,t[3]=.25*p,t[0]=(f-h)/p,t[1]=(u-c)/p,t[2]=(s-l)/p):o>d&&o>m?(p=Math.sqrt(1+o-d-m)*2,t[3]=(f-h)/p,t[0]=.25*p,t[1]=(s+l)/p,t[2]=(u+c)/p):d>m?(p=Math.sqrt(1+d-o-m)*2,t[3]=(u-c)/p,t[0]=(s+l)/p,t[1]=.25*p,t[2]=(f+h)/p):(p=Math.sqrt(1+m-o-d)*2,t[3]=(s-l)/p,t[0]=(u+c)/p,t[1]=(f+h)/p,t[2]=.25*p),t}function vy(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];var i=n[0],a=n[1],o=n[2],s=n[4],c=n[5],l=n[6],d=n[8],f=n[9],u=n[10];r[0]=Math.sqrt(i*i+a*a+o*o),r[1]=Math.sqrt(s*s+c*c+l*l),r[2]=Math.sqrt(d*d+f*f+u*u);var h=1/r[0],m=1/r[1],g=1/r[2],p=i*h,y=a*m,v=o*g,x=s*h,b=c*m,_=l*g,w=d*h,S=f*m,E=u*g,L=p+b+E,M=0;return L>0?(M=Math.sqrt(L+1)*2,t[3]=.25*M,t[0]=(_-S)/M,t[1]=(w-v)/M,t[2]=(y-x)/M):p>b&&p>E?(M=Math.sqrt(1+p-b-E)*2,t[3]=(_-S)/M,t[0]=.25*M,t[1]=(y+x)/M,t[2]=(w+v)/M):b>E?(M=Math.sqrt(1+b-p-E)*2,t[3]=(w-v)/M,t[0]=(y+x)/M,t[1]=.25*M,t[2]=(_+S)/M):(M=Math.sqrt(1+E-p-b)*2,t[3]=(y-x)/M,t[0]=(w+v)/M,t[1]=(_+S)/M,t[2]=.25*M),t}function _y(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3],c=i+i,l=a+a,d=o+o,f=i*c,u=i*l,h=i*d,m=a*l,g=a*d,p=o*d,y=s*c,v=s*l,x=s*d,b=n[0],_=n[1],w=n[2];return t[0]=(1-(m+p))*b,t[1]=(u+x)*b,t[2]=(h-v)*b,t[3]=0,t[4]=(u-x)*_,t[5]=(1-(f+p))*_,t[6]=(g+y)*_,t[7]=0,t[8]=(h+v)*w,t[9]=(g-y)*w,t[10]=(1-(f+m))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Sy(t,e,r,n,i){var a=e[0],o=e[1],s=e[2],c=e[3],l=a+a,d=o+o,f=s+s,u=a*l,h=a*d,m=a*f,g=o*d,p=o*f,y=s*f,v=c*l,x=c*d,b=c*f,_=n[0],w=n[1],S=n[2],E=i[0],L=i[1],M=i[2],R=(1-(g+y))*_,I=(h+b)*_,B=(m-x)*_,F=(h-b)*w,U=(1-(u+y))*w,ce=(p+v)*w,Nt=(m+x)*S,Ct=(p-v)*S,zr=(1-(u+g))*S;return t[0]=R,t[1]=I,t[2]=B,t[3]=0,t[4]=F,t[5]=U,t[6]=ce,t[7]=0,t[8]=Nt,t[9]=Ct,t[10]=zr,t[11]=0,t[12]=r[0]+E-(R*E+F*L+Nt*M),t[13]=r[1]+L-(I*E+U*L+Ct*M),t[14]=r[2]+M-(B*E+ce*L+zr*M),t[15]=1,t}function wy(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,c=i+i,l=r*o,d=n*o,f=n*s,u=i*o,h=i*s,m=i*c,g=a*o,p=a*s,y=a*c;return t[0]=1-f-m,t[1]=d+y,t[2]=u-p,t[3]=0,t[4]=d-y,t[5]=1-l-m,t[6]=h+g,t[7]=0,t[8]=u+p,t[9]=h-g,t[10]=1-l-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function My(t,e,r,n,i,a,o){var s=1/(r-e),c=1/(i-n),l=1/(a-o);return t[0]=a*2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(i+n)*c,t[10]=(o+a)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*a*2*l,t[15]=0,t}function Gh(t,e,r,n,i){var a=1/Math.tan(e/2);if(t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){var o=1/(n-i);t[10]=(i+n)*o,t[14]=2*i*n*o}else t[10]=-1,t[14]=-2*n;return t}var Ay=Gh;function Ey(t,e,r,n,i){var a=1/Math.tan(e/2);if(t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){var o=1/(n-i);t[10]=i*o,t[14]=i*n*o}else t[10]=-1,t[14]=-n;return t}function Ly(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+s),l=2/(i+a);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((o-s)*c*.5),t[9]=(i-a)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function Wh(t,e,r,n,i,a,o){var s=1/(e-r),c=1/(n-i),l=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*c,t[14]=(o+a)*l,t[15]=1,t}var Ty=Wh;function Ry(t,e,r,n,i,a,o){var s=1/(e-r),c=1/(n-i),l=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*c,t[14]=a*l,t[15]=1,t}function Cy(t,e,r,n){var i,a,o,s,c,l,d,f,u,h,m=e[0],g=e[1],p=e[2],y=n[0],v=n[1],x=n[2],b=r[0],_=r[1],w=r[2];return Math.abs(m-b)<$&&Math.abs(g-_)<$&&Math.abs(p-w)<$?Uh(t):(d=m-b,f=g-_,u=p-w,h=1/Math.sqrt(d*d+f*f+u*u),d*=h,f*=h,u*=h,i=v*u-x*f,a=x*d-y*u,o=y*f-v*d,h=Math.sqrt(i*i+a*a+o*o),h?(h=1/h,i*=h,a*=h,o*=h):(i=0,a=0,o=0),s=f*o-u*a,c=u*i-d*o,l=d*a-f*i,h=Math.sqrt(s*s+c*c+l*l),h?(h=1/h,s*=h,c*=h,l*=h):(s=0,c=0,l=0),t[0]=i,t[1]=s,t[2]=d,t[3]=0,t[4]=a,t[5]=c,t[6]=f,t[7]=0,t[8]=o,t[9]=l,t[10]=u,t[11]=0,t[12]=-(i*m+a*g+o*p),t[13]=-(s*m+c*g+l*p),t[14]=-(d*m+f*g+u*p),t[15]=1,t)}function Py(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=n[0],c=n[1],l=n[2],d=i-r[0],f=a-r[1],u=o-r[2],h=d*d+f*f+u*u;h>0&&(h=1/Math.sqrt(h),d*=h,f*=h,u*=h);var m=c*u-l*f,g=l*d-s*u,p=s*f-c*d;return h=m*m+g*g+p*p,h>0&&(h=1/Math.sqrt(h),m*=h,g*=h,p*=h),t[0]=m,t[1]=g,t[2]=p,t[3]=0,t[4]=f*p-u*g,t[5]=u*m-d*p,t[6]=d*g-f*m,t[7]=0,t[8]=d,t[9]=f,t[10]=u,t[11]=0,t[12]=i,t[13]=a,t[14]=o,t[15]=1,t}function Iy(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function By(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function Fy(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function Xh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function ky(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function Dy(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function zy(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function Oy(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],u=t[10],h=t[11],m=t[12],g=t[13],p=t[14],y=t[15],v=e[0],x=e[1],b=e[2],_=e[3],w=e[4],S=e[5],E=e[6],L=e[7],M=e[8],R=e[9],I=e[10],B=e[11],F=e[12],U=e[13],ce=e[14],Nt=e[15];return Math.abs(r-v)<=$*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-x)<=$*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(i-b)<=$*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-_)<=$*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(o-w)<=$*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-S)<=$*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(c-E)<=$*Math.max(1,Math.abs(c),Math.abs(E))&&Math.abs(l-L)<=$*Math.max(1,Math.abs(l),Math.abs(L))&&Math.abs(d-M)<=$*Math.max(1,Math.abs(d),Math.abs(M))&&Math.abs(f-R)<=$*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(u-I)<=$*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(h-B)<=$*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(m-F)<=$*Math.max(1,Math.abs(m),Math.abs(F))&&Math.abs(g-U)<=$*Math.max(1,Math.abs(g),Math.abs(U))&&Math.abs(p-ce)<=$*Math.max(1,Math.abs(p),Math.abs(ce))&&Math.abs(y-Nt)<=$*Math.max(1,Math.abs(y),Math.abs(Nt))}var Uy=Nh,Ny=Xh;var Jl={};Na(Jl,{add:()=>cx,calculateW:()=>Qb,clone:()=>ax,conjugate:()=>rx,copy:()=>sx,create:()=>iu,dot:()=>um,equals:()=>px,exactEquals:()=>mx,exp:()=>sm,fromEuler:()=>nx,fromMat3:()=>cm,fromValues:()=>ox,getAngle:()=>$b,getAxisAngle:()=>Yb,identity:()=>Kb,invert:()=>tx,len:()=>fx,length:()=>fm,lerp:()=>ux,ln:()=>lm,mul:()=>dx,multiply:()=>om,normalize:()=>au,pow:()=>Jb,random:()=>ex,rotateX:()=>qb,rotateY:()=>Zb,rotateZ:()=>jb,rotationTo:()=>gx,scale:()=>dm,set:()=>lx,setAxes:()=>bx,setAxisAngle:()=>am,slerp:()=>Ql,sqlerp:()=>yx,sqrLen:()=>hx,squaredLength:()=>hm,str:()=>ix});var C={};Na(C,{add:()=>Wy,angle:()=>ub,bezier:()=>nb,ceil:()=>Xy,clone:()=>Hy,copy:()=>Vy,create:()=>Yl,cross:()=>ns,dist:()=>xb,distance:()=>Zh,div:()=>bb,divide:()=>qh,dot:()=>rs,equals:()=>pb,exactEquals:()=>mb,floor:()=>Ky,forEach:()=>Sb,fromValues:()=>$l,hermite:()=>rb,inverse:()=>Jy,len:()=>$d,length:()=>Kh,lerp:()=>eb,max:()=>$y,min:()=>Yy,mul:()=>yb,multiply:()=>$h,negate:()=>Qy,normalize:()=>Yd,random:()=>ib,rotateX:()=>lb,rotateY:()=>cb,rotateZ:()=>db,round:()=>qy,scale:()=>Zy,scaleAndAdd:()=>jy,set:()=>Gy,slerp:()=>tb,sqrDist:()=>vb,sqrLen:()=>_b,squaredDistance:()=>jh,squaredLength:()=>Qh,str:()=>hb,sub:()=>gb,subtract:()=>Yh,transformMat3:()=>ob,transformMat4:()=>ab,transformQuat:()=>sb,zero:()=>fb});function Yl(){var t=new xe(3);return xe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Hy(t){var e=new xe(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Kh(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function $l(t,e,r){var n=new xe(3);return n[0]=t,n[1]=e,n[2]=r,n}function Vy(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Gy(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function Wy(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Yh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function $h(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function qh(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Xy(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function Ky(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function Yy(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function $y(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function qy(t,e){return t[0]=tn(e[0]),t[1]=tn(e[1]),t[2]=tn(e[2]),t}function Zy(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function jy(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function Zh(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function jh(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function Qh(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function Qy(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Jy(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Yd(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t}function rs(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ns(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],c=r[2];return t[0]=i*c-a*s,t[1]=a*o-n*c,t[2]=n*s-i*o,t}function eb(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t}function tb(t,e,r,n){var i=Math.acos(Math.min(Math.max(rs(e,r),-1),1)),a=Math.sin(i),o=Math.sin((1-n)*i)/a,s=Math.sin(n*i)/a;return t[0]=o*e[0]+s*r[0],t[1]=o*e[1]+s*r[1],t[2]=o*e[2]+s*r[2],t}function rb(t,e,r,n,i,a){var o=a*a,s=o*(2*a-3)+1,c=o*(a-2)+a,l=o*(a-1),d=o*(3-2*a);return t[0]=e[0]*s+r[0]*c+n[0]*l+i[0]*d,t[1]=e[1]*s+r[1]*c+n[1]*l+i[1]*d,t[2]=e[2]*s+r[2]*c+n[2]*l+i[2]*d,t}function nb(t,e,r,n,i,a){var o=1-a,s=o*o,c=a*a,l=s*o,d=3*a*s,f=3*c*o,u=c*a;return t[0]=e[0]*l+r[0]*d+n[0]*f+i[0]*u,t[1]=e[1]*l+r[1]*d+n[1]*f+i[1]*u,t[2]=e[2]*l+r[2]*d+n[2]*f+i[2]*u,t}function ib(t,e){e=e===void 0?1:e;var r=er()*2*Math.PI,n=er()*2-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}function ab(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}function ob(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}function sb(t,e,r){var n=r[0],i=r[1],a=r[2],o=r[3],s=e[0],c=e[1],l=e[2],d=i*l-a*c,f=a*s-n*l,u=n*c-i*s;return d=d+d,f=f+f,u=u+u,t[0]=s+o*d+i*u-a*f,t[1]=c+o*f+a*d-n*u,t[2]=l+o*u+n*f-i*d,t}function lb(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t}function cb(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t}function db(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t}function ub(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],o=e[1],s=e[2],c=Math.sqrt((r*r+n*n+i*i)*(a*a+o*o+s*s)),l=c&&rs(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function fb(t){return t[0]=0,t[1]=0,t[2]=0,t}function hb(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function mb(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function pb(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],o=e[1],s=e[2];return Math.abs(r-a)<=$*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-o)<=$*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-s)<=$*Math.max(1,Math.abs(i),Math.abs(s))}var gb=Yh,yb=$h,bb=qh,xb=Zh,vb=jh,$d=Kh,_b=Qh,Sb=(function(){var t=Yl();return function(e,r,n,i,a,o){var s,c;for(r||(r=3),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,s=n;s<c;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2];return e}})();var ga={};Na(ga,{add:()=>Jd,ceil:()=>wb,clone:()=>qd,copy:()=>jd,create:()=>Jh,cross:()=>Pb,dist:()=>Hb,distance:()=>nm,div:()=>Nb,divide:()=>rm,dot:()=>jl,equals:()=>zb,exactEquals:()=>nu,floor:()=>Mb,forEach:()=>Xb,fromValues:()=>Zd,inverse:()=>Cb,len:()=>Gb,length:()=>ql,lerp:()=>ru,max:()=>Eb,min:()=>Ab,mul:()=>Ub,multiply:()=>tm,negate:()=>Rb,normalize:()=>tu,random:()=>Ib,round:()=>Lb,scale:()=>eu,scaleAndAdd:()=>Tb,set:()=>Qd,sqrDist:()=>Vb,sqrLen:()=>Wb,squaredDistance:()=>im,squaredLength:()=>Zl,str:()=>Db,sub:()=>Ob,subtract:()=>em,transformMat4:()=>Bb,transformQuat:()=>Fb,zero:()=>kb});function Jh(){var t=new xe(4);return xe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function qd(t){var e=new xe(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Zd(t,e,r,n){var i=new xe(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}function jd(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Qd(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function Jd(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function em(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function tm(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function rm(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function wb(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function Mb(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function Ab(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function Eb(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function Lb(t,e){return t[0]=tn(e[0]),t[1]=tn(e[1]),t[2]=tn(e[2]),t[3]=tn(e[3]),t}function eu(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function Tb(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}function nm(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)}function im(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}function ql(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}function Zl(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}function Rb(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function Cb(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function tu(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o,t}function jl(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Pb(t,e,r,n){var i=r[0]*n[1]-r[1]*n[0],a=r[0]*n[2]-r[2]*n[0],o=r[0]*n[3]-r[3]*n[0],s=r[1]*n[2]-r[2]*n[1],c=r[1]*n[3]-r[3]*n[1],l=r[2]*n[3]-r[3]*n[2],d=e[0],f=e[1],u=e[2],h=e[3];return t[0]=f*l-u*c+h*s,t[1]=-(d*l)+u*o-h*a,t[2]=d*c-f*o+h*i,t[3]=-(d*s)+f*a-u*i,t}function ru(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t}function Ib(t,e){e=e===void 0?1:e;var r,n,i,a,o,s,c;c=er(),r=c*2-1,n=(4*er()-2)*Math.sqrt(c*-c+c),o=r*r+n*n,c=er(),i=c*2-1,a=(4*er()-2)*Math.sqrt(c*-c+c),s=i*i+a*a;var l=Math.sqrt((1-o)/s);return t[0]=e*r,t[1]=e*n,t[2]=e*i*l,t[3]=e*a*l,t}function Bb(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function Fb(t,e,r){var n=r[0],i=r[1],a=r[2],o=r[3],s=e[0],c=e[1],l=e[2],d=i*l-a*c,f=a*s-n*l,u=n*c-i*s;return d=d+d,f=f+f,u=u+u,t[0]=s+o*d+i*u-a*f,t[1]=c+o*f+a*d-n*u,t[2]=l+o*u+n*f-i*d,t[3]=e[3],t}function kb(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function Db(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function nu(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function zb(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],c=e[2],l=e[3];return Math.abs(r-o)<=$*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=$*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-c)<=$*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(a-l)<=$*Math.max(1,Math.abs(a),Math.abs(l))}var Ob=em,Ub=tm,Nb=rm,Hb=nm,Vb=im,Gb=ql,Wb=Zl,Xb=(function(){var t=Jh();return function(e,r,n,i,a,o){var s,c;for(r||(r=4),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,s=n;s<c;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],t[3]=e[s+3],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2],e[s+3]=t[3];return e}})();function iu(){var t=new xe(4);return xe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Kb(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function am(t,e,r){r=r*.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function Yb(t,e){var r=Math.acos(e[3])*2,n=Math.sin(r/2);return n>$?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function $b(t,e){var r=um(t,e);return Math.acos(2*r*r-1)}function om(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=r[0],c=r[1],l=r[2],d=r[3];return t[0]=n*d+o*s+i*l-a*c,t[1]=i*d+o*c+a*s-n*l,t[2]=a*d+o*l+n*c-i*s,t[3]=o*d-n*s-i*c-a*l,t}function qb(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*s,t[1]=i*c+a*s,t[2]=a*c-i*s,t[3]=o*c-n*s,t}function Zb(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),c=Math.cos(r);return t[0]=n*c-a*s,t[1]=i*c+o*s,t[2]=a*c+n*s,t[3]=o*c-i*s,t}function jb(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*s,t[1]=i*c-n*s,t[2]=a*c+o*s,t[3]=o*c-a*s,t}function Qb(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t}function sm(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=Math.sqrt(r*r+n*n+i*i),s=Math.exp(a),c=o>0?s*Math.sin(o)/o:0;return t[0]=r*c,t[1]=n*c,t[2]=i*c,t[3]=s*Math.cos(o),t}function lm(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=Math.sqrt(r*r+n*n+i*i),s=o>0?Math.atan2(o,a)/o:0;return t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=.5*Math.log(r*r+n*n+i*i+a*a),t}function Jb(t,e,r){return lm(t,e),dm(t,t,r),sm(t,t),t}function Ql(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3],c=r[0],l=r[1],d=r[2],f=r[3],u,h,m,g,p;return h=i*c+a*l+o*d+s*f,h<0&&(h=-h,c=-c,l=-l,d=-d,f=-f),1-h>$?(u=Math.acos(h),m=Math.sin(u),g=Math.sin((1-n)*u)/m,p=Math.sin(n*u)/m):(g=1-n,p=n),t[0]=g*i+p*c,t[1]=g*a+p*l,t[2]=g*o+p*d,t[3]=g*s+p*f,t}function ex(t){var e=er(),r=er(),n=er(),i=Math.sqrt(1-e),a=Math.sqrt(e);return t[0]=i*Math.sin(2*Math.PI*r),t[1]=i*Math.cos(2*Math.PI*r),t[2]=a*Math.sin(2*Math.PI*n),t[3]=a*Math.cos(2*Math.PI*n),t}function tx(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return t[0]=-r*s,t[1]=-n*s,t[2]=-i*s,t[3]=a*s,t}function rx(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function cm(t,e){var r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[i*3+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;n=Math.sqrt(e[i*3+i]-e[a*3+a]-e[o*3+o]+1),t[i]=.5*n,n=.5/n,t[3]=(e[a*3+o]-e[o*3+a])*n,t[a]=(e[a*3+i]+e[i*3+a])*n,t[o]=(e[o*3+i]+e[i*3+o])*n}return t}function nx(t,e,r,n){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:zh,a=Math.PI/360;e*=a,n*=a,r*=a;var o=Math.sin(e),s=Math.cos(e),c=Math.sin(r),l=Math.cos(r),d=Math.sin(n),f=Math.cos(n);switch(i){case"xyz":t[0]=o*l*f+s*c*d,t[1]=s*c*f-o*l*d,t[2]=s*l*d+o*c*f,t[3]=s*l*f-o*c*d;break;case"xzy":t[0]=o*l*f-s*c*d,t[1]=s*c*f-o*l*d,t[2]=s*l*d+o*c*f,t[3]=s*l*f+o*c*d;break;case"yxz":t[0]=o*l*f+s*c*d,t[1]=s*c*f-o*l*d,t[2]=s*l*d-o*c*f,t[3]=s*l*f+o*c*d;break;case"yzx":t[0]=o*l*f+s*c*d,t[1]=s*c*f+o*l*d,t[2]=s*l*d-o*c*f,t[3]=s*l*f-o*c*d;break;case"zxy":t[0]=o*l*f-s*c*d,t[1]=s*c*f+o*l*d,t[2]=s*l*d+o*c*f,t[3]=s*l*f-o*c*d;break;case"zyx":t[0]=o*l*f-s*c*d,t[1]=s*c*f+o*l*d,t[2]=s*l*d-o*c*f,t[3]=s*l*f+o*c*d;break;default:throw new Error("Unknown angle order "+i)}return t}function ix(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var ax=qd,ox=Zd,sx=jd,lx=Qd,cx=Jd,dx=om,dm=eu,um=jl,ux=ru,fm=ql,fx=fm,hm=Zl,hx=hm,au=tu,mx=nu;function px(t,e){return Math.abs(jl(t,e))>=1-$}var gx=(function(){var t=Yl(),e=$l(1,0,0),r=$l(0,1,0);return function(n,i,a){var o=rs(i,a);return o<-.999999?(ns(t,e,i),$d(t)<1e-6&&ns(t,r,i),Yd(t,t),am(n,t,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(ns(t,i,a),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+o,au(n,n))}})(),yx=(function(){var t=iu(),e=iu();return function(r,n,i,a,o,s){return Ql(t,n,o,s),Ql(e,i,a,s),Ql(r,t,e,2*s*(1-s)),r}})(),bx=(function(){var t=Oh();return function(e,r,n,i){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],au(e,cm(e,t))}})();var ec=class{constructor(){this._position=C.create();this._angles=C.create();this._bobAngles=C.create();this._bobOffset=C.create();this._kickAngles=C.create();this._rollAngle=0;this._fov=90;this._aspect=1;this._near=.1;this._far=1e3;this._viewMatrix=j.create();this._projectionMatrix=j.create();this._viewProjectionMatrix=j.create();this._dirty=!0}get position(){return this._position}set position(e){C.equals(this._position,e)||(C.copy(this._position,e),this._dirty=!0,this.triggerMoveEvent())}get angles(){return this._angles}set angles(e){C.equals(this._angles,e)||(C.copy(this._angles,e),this._dirty=!0,this.triggerMoveEvent())}get bobAngles(){return this._bobAngles}set bobAngles(e){C.copy(this._bobAngles,e),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(e){C.copy(this._kickAngles,e),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(e){C.copy(this._bobOffset,e),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(e){this._rollAngle=e,this._dirty=!0}get fov(){return this._fov}set fov(e){this._fov=e,this._dirty=!0}get aspect(){return this._aspect}set aspect(e){this._aspect=e,this._dirty=!0}setPosition(e,r,n){let i=C.fromValues(e,r,n);C.equals(this._position,i)||(C.copy(this._position,i),this._dirty=!0,this.triggerMoveEvent())}setRotation(e,r,n){let i=C.fromValues(e,r,n);C.equals(this._angles,i)||(C.copy(this._angles,i),this._dirty=!0,this.triggerMoveEvent())}setFov(e){this.fov=e}setAspectRatio(e){this.aspect=e}lookAt(e){let r=C.create();if(C.subtract(r,e,this._position),C.length(r)<.001)return;let i=Math.atan2(r[1],r[0])*zc,a=Math.hypot(r[0],r[1]),o=-Math.atan2(r[2],a)*zc;this.setRotation(o,i,0)}triggerMoveEvent(){this.onCameraMove&&this.onCameraMove({position:C.clone(this._position),angles:C.clone(this._angles)})}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(e){let r=j.create();return j.perspective(r,e*Pi,this._aspect,this._near,this._far),r}screenToWorldRay(e,r){let n=e*2-1,i=1-r*2,a=C.fromValues(n,i,-1),o=C.fromValues(n,i,1),s=j.create();j.invert(s,this.viewProjectionMatrix);let c=C.create(),l=C.create();C.transformMat4(c,a,s),C.transformMat4(l,o,s);let d=C.create();return C.subtract(d,l,c),C.normalize(d,d),{origin:C.clone(this._position),direction:d}}updateMatrices(){if(!this._dirty)return;j.perspective(this._projectionMatrix,this._fov*Pi,this._aspect,this._near,this._far);let e=j.fromValues(0,0,-1,0,-1,0,0,0,0,1,0,0,0,0,0,1),r=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],n=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],i=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,a=r*Pi,o=n*Pi,s=i*Pi,c=j.create();j.identity(c),j.rotateZ(c,c,-o),j.rotateY(c,c,-a),j.rotateX(c,c,-s);let l=j.create();j.multiply(l,e,c);let d=C.add(C.create(),this._position,this._bobOffset),f=C.negate(C.create(),d),u=C.create();C.transformMat4(u,f,c);let h=C.fromValues(u[1]?-u[1]:0,u[2]||0,u[0]?-u[0]:0);j.copy(this._viewMatrix,l),this._viewMatrix[12]=h[0],this._viewMatrix[13]=h[1],this._viewMatrix[14]=h[2],j.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};var xx=[.2,.2,.2],vx={x:0,y:0,z:1},_x=[.8,.8,.8];function ou(t,e,r){return t+(e-t)*r}function ba(t,e,r){return{x:ou(t.x,e.x,r),y:ou(t.y,e.y,r),z:ou(t.z,e.z,r)}}function ya(t){return t<0?0:t>1?1:t}function su(t){let e=[],r=[];for(let n of t.triangles){let i=e.length,[a,o,s]=n.indices,c=t.texCoords[a],l=t.texCoords[o],d=t.texCoords[s];if(!c||!l||!d)throw new Error(`Missing texCoord for triangle in surface ${t.name}`);e.push({vertexIndex:a,texCoord:[c.s,1-c.t]},{vertexIndex:o,texCoord:[l.s,1-l.t]},{vertexIndex:s,texCoord:[d.s,1-d.t]}),r.push(i,i+1,i+2)}return{vertices:e,indices:new Uint16Array(r)}}function Sx(t,e,r){let n=r?.ambient??xx,i=r?.directional??{direction:vx,color:_x},a=Hr(t),o=Hr(i.direction),s=ya(a.x*o.x+a.y*o.y+a.z*o.z),c=n[0]+i.color[0]*s,l=n[1]+i.color[1]*s,d=n[2]+i.color[2]*s;if(r?.dynamicLights){let f=r.modelMatrix?ff(r.modelMatrix,e):e;for(let u of r.dynamicLights){let h=f.x-u.origin.x,m=f.y-u.origin.y,g=f.z-u.origin.z,p=h*h+m*m+g*g,y=u.radius*u.radius;if(p<y&&y>0){let v=1-Math.sqrt(p)/u.radius,x=Math.sqrt(p),b=x>0?ya(-(h*a.x+m*a.y+g*a.z)/x):0,_=ya(v*b);c+=u.color[0]*_,l+=u.color[1]*_,d+=u.color[2]*_}}}return[ya(c),ya(l),ya(d)]}function lu(t,e,r,n){let i=t.vertices[r.frame0],a=t.vertices[r.frame1];if(!i||!a)throw new Error("Requested MD3 frames are out of range");let o=new Float32Array(e.vertices.length*12);return e.vertices.forEach((s,c)=>{let l=i[s.vertexIndex],d=a[s.vertexIndex];if(!l||!d)throw new Error(`Vertex index ${s.vertexIndex} missing for frame`);let f=ba(l.position,d.position,r.lerp),u=Hr(ba(l.normal,d.normal,r.lerp)),h=Sx(u,f,n),m=c*12;o[m]=f.x,o[m+1]=f.y,o[m+2]=f.z,o[m+3]=u.x,o[m+4]=u.y,o[m+5]=u.z,o[m+6]=s.texCoord[0],o[m+7]=s.texCoord[1],o[m+8]=h[0],o[m+9]=h[1],o[m+10]=h[2],o[m+11]=1}),o}function mm(t,e,r){let n=t.tags[0];if(!n)return null;let i=n.findIndex(g=>g.name===r);if(i===-1)return null;let a=t.tags[e.frame0]?.[i],o=t.tags[e.frame1]?.[i];if(!a||!o)throw new Error(`Tag ${r} is missing for one of the interpolated frames`);let s=ba(a.origin,o.origin,e.lerp),c=Hr(ba(a.axis[0],o.axis[0],e.lerp)),l=Hr(ba(a.axis[1],o.axis[1],e.lerp)),d=Hr(ba(a.axis[2],o.axis[2],e.lerp)),f=c,u=Hr({x:l.x-f.x*(f.x*l.x+f.y*l.y+f.z*l.z),y:l.y-f.y*(f.x*l.x+f.y*l.y+f.z*l.z),z:l.z-f.z*(f.x*l.x+f.y*l.y+f.z*l.z)}),h=Hr({x:f.y*u.z-f.z*u.y,y:f.z*u.x-f.x*u.z,z:f.x*u.y-f.y*u.x}),m=[f,u,h];return{origin:s,axis:m,matrix:hf(s,m)}}var cu=`#version 300 es
|
|
479
|
+
}`;function Y1(t){let e=t.x*t.x+t.y*t.y+t.z*t.z;if(e<=0)return{x:0,y:0,z:1};let r=1/Math.sqrt(e);return{x:t.x*r,y:t.y*r,z:t.z*r}}function Vd(t,e,r){return t+(e-t)*r}function Dh(t,e,r){return{x:Vd(t.x,e.x,r),y:Vd(t.y,e.y,r),z:Vd(t.z,e.z,r)}}function $1(t,e,r){return[t/r.skinWidth,1-e/r.skinHeight]}function Xd(t){if(t.glCommands.length===0){let n=[],i=[];return t.triangles.forEach(a=>{let o=n.length;for(let s=0;s<3;s+=1){let c=a.vertexIndices[s],l=a.texCoordIndices[s],d=t.texCoords[l];n.push({vertexIndex:c,texCoord:$1(d.s,d.t,t.header)})}i.push(o,o+1,o+2)}),{vertices:n,indices:new Uint16Array(i)}}let e=[],r=[];for(let n of t.glCommands){let i=e.length;if(e.push(...n.vertices.map(a=>({vertexIndex:a.vertexIndex,texCoord:[a.s,1-a.t]}))),n.mode==="strip")for(let a=0;a<n.vertices.length-2;a+=1){let o=a%2===0,s=i+a+(o?0:1),c=i+a+(o?1:0),l=i+a+2;r.push(s,c,l)}else for(let a=1;a<n.vertices.length-1;a+=1)r.push(i,i+a,i+a+1)}return{vertices:e,indices:new Uint16Array(r)}}function Kd(t,e,r){let{frame0:n,frame1:i,lerp:a}=r,o=t.frames[n],s=t.frames[i];if(!o||!s)throw new Error("Requested MD2 frames are out of range");let c=new Float32Array(e.vertices.length*8);return e.vertices.forEach((l,d)=>{let f=o.vertices[l.vertexIndex],u=s.vertices[l.vertexIndex];if(!f||!u)throw new Error("MD2 vertex index out of range for frame");let h=Dh(f.position,u.position,a),m=Y1(Dh(f.normal,u.normal,a)),g=d*8;c[g]=h.x,c[g+1]=h.y,c[g+2]=h.z,c[g+3]=m.x,c[g+4]=m.y,c[g+5]=m.z,c[g+6]=l.texCoord[0],c[g+7]=l.texCoord[1]}),c}var ma=class{constructor(e,r,n){this.gl=e,this.geometry=Xd(r),this.vertexBuffer=new Ae(e,e.STATIC_DRAW),this.indexBuffer=new Qe(e,e.STATIC_DRAW),this.vertexArray=new Ee(e),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:32,offset:0},{index:1,size:3,type:e.FLOAT,stride:32,offset:12},{index:2,size:2,type:e.FLOAT,stride:32,offset:24}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,e.STATIC_DRAW),this.update(r,n)}update(e,r){let n=Kd(e,this.geometry,r);this.vertexBuffer.upload(n,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose(),this.wireframeIndexBuffer?.dispose()}},pa=class{constructor(e){this.uniformDlights=[];this.gl=e,this.program=le.create(e,{vertex:Gd,fragment:Wd},{a_position:0,a_normal:1,a_texCoord:2}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformModelMatrix=this.program.getUniformLocation("u_modelMatrix"),this.uniformLightDir=this.program.getUniformLocation("u_lightDir"),this.uniformAmbient=this.program.getUniformLocation("u_ambient"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformRenderMode=this.program.getUniformLocation("u_renderMode"),this.uniformSolidColor=this.program.getUniformLocation("u_solidColor"),this.uniformNumDlights=this.program.getUniformLocation("u_numDlights");for(let r=0;r<Dn;r++)this.uniformDlights.push({pos:this.program.getUniformLocation(`u_dlights[${r}].position`),color:this.program.getUniformLocation(`u_dlights[${r}].color`),intensity:this.program.getUniformLocation(`u_dlights[${r}].intensity`)});this.uniformBrightness=this.program.getUniformLocation("u_brightness"),this.uniformGamma=this.program.getUniformLocation("u_gamma"),this.uniformFullbright=this.program.getUniformLocation("u_fullbright"),this.uniformGlobalAmbient=this.program.getUniformLocation("u_globalAmbient")}get shaderSize(){return this.program.sourceSize}bind(e){let{modelViewProjection:r,modelMatrix:n,lightDirection:i=[0,0,1],ambientLight:a=.2,tint:o=[1,1,1,1],diffuseSampler:s=0,dlights:c=[],renderMode:l,brightness:d=1,gamma:f=1,fullbright:u=!1,ambient:h=0}=e,m=new Float32Array(i),g=new Float32Array(o);this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),n?this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,n):this.gl.uniformMatrix4fv(this.uniformModelMatrix,!1,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])),this.gl.uniform3fv(this.uniformLightDir,m),this.gl.uniform1f(this.uniformAmbient,a),this.gl.uniform4fv(this.uniformTint,g),this.gl.uniform1i(this.uniformDiffuse,s);let p=0,y=[1,1,1,1];l&&(l.mode==="solid"||l.mode==="wireframe"?p=1:l.mode==="solid-faceted"&&(p=2),l.color?y=[...l.color]:l.generateRandomColor),this.gl.uniform1i(this.uniformRenderMode,p),this.gl.uniform4f(this.uniformSolidColor,y[0],y[1],y[2],y[3]);let v=Math.min(c.length,Dn);this.gl.uniform1i(this.uniformNumDlights,v);for(let x=0;x<v;x++){let b=c[x];this.gl.uniform3f(this.uniformDlights[x].pos,b.origin.x,b.origin.y,b.origin.z),this.gl.uniform3f(this.uniformDlights[x].color,b.color.x,b.color.y,b.color.z),this.gl.uniform1f(this.uniformDlights[x].intensity,b.intensity)}this.gl.uniform1f(this.uniformBrightness,d),this.gl.uniform1f(this.uniformGamma,f),this.gl.uniform1i(this.uniformFullbright,u?1:0),this.gl.uniform1f(this.uniformGlobalAmbient,h)}draw(e,r){if(e.vertexArray.bind(),r&&r.mode==="wireframe"){if(!e.wireframeIndexBuffer){e.wireframeIndexBuffer=new Qe(this.gl,this.gl.STATIC_DRAW);let n=ua(e.geometry.indices);e.wireframeIndexBuffer.upload(n),e.wireframeIndexCount=n.length}e.wireframeIndexBuffer.bind(),this.gl.drawElements(this.gl.LINES,e.wireframeIndexCount,this.gl.UNSIGNED_SHORT,0)}else e.indexBuffer.bind(),this.gl.drawElements(this.gl.TRIANGLES,e.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var $=1e-6,xe=typeof Float32Array<"u"?Float32Array:Array,er=Math.random,zh="zyx";function tn(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var OE=Math.PI/180,UE=180/Math.PI;function Oh(){var t=new xe(9);return xe!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var j={};Na(j,{add:()=>Fy,adjoint:()=>ny,clone:()=>j1,copy:()=>Q1,create:()=>Z1,decompose:()=>vy,determinant:()=>iy,equals:()=>Oy,exactEquals:()=>zy,frob:()=>By,fromQuat:()=>wy,fromQuat2:()=>yy,fromRotation:()=>hy,fromRotationTranslation:()=>Hh,fromRotationTranslationScale:()=>_y,fromRotationTranslationScaleOrigin:()=>Sy,fromScaling:()=>fy,fromTranslation:()=>uy,fromValues:()=>J1,fromXRotation:()=>my,fromYRotation:()=>py,fromZRotation:()=>gy,frustum:()=>My,getRotation:()=>xy,getScaling:()=>Vh,getTranslation:()=>by,identity:()=>Uh,invert:()=>ry,lookAt:()=>Cy,mul:()=>Uy,multiply:()=>Nh,multiplyScalar:()=>ky,multiplyScalarAndAdd:()=>Dy,ortho:()=>Ty,orthoNO:()=>Wh,orthoZO:()=>Ry,perspective:()=>Ay,perspectiveFromFieldOfView:()=>Ly,perspectiveNO:()=>Gh,perspectiveZO:()=>Ey,rotate:()=>sy,rotateX:()=>ly,rotateY:()=>cy,rotateZ:()=>dy,scale:()=>oy,set:()=>ey,str:()=>Iy,sub:()=>Ny,subtract:()=>Xh,targetTo:()=>Py,translate:()=>ay,transpose:()=>ty});function Z1(){var t=new xe(16);return xe!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function j1(t){var e=new xe(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Q1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function J1(t,e,r,n,i,a,o,s,c,l,d,f,u,h,m,g){var p=new xe(16);return p[0]=t,p[1]=e,p[2]=r,p[3]=n,p[4]=i,p[5]=a,p[6]=o,p[7]=s,p[8]=c,p[9]=l,p[10]=d,p[11]=f,p[12]=u,p[13]=h,p[14]=m,p[15]=g,p}function ey(t,e,r,n,i,a,o,s,c,l,d,f,u,h,m,g,p){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=d,t[10]=f,t[11]=u,t[12]=h,t[13]=m,t[14]=g,t[15]=p,t}function Uh(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ty(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function ry(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],d=e[8],f=e[9],u=e[10],h=e[11],m=e[12],g=e[13],p=e[14],y=e[15],v=r*s-n*o,x=r*c-i*o,b=r*l-a*o,_=n*c-i*s,w=n*l-a*s,S=i*l-a*c,E=d*g-f*m,L=d*p-u*m,M=d*y-h*m,R=f*p-u*g,I=f*y-h*g,B=u*y-h*p,F=v*B-x*I+b*R+_*M-w*L+S*E;return F?(F=1/F,t[0]=(s*B-c*I+l*R)*F,t[1]=(i*I-n*B-a*R)*F,t[2]=(g*S-p*w+y*_)*F,t[3]=(u*w-f*S-h*_)*F,t[4]=(c*M-o*B-l*L)*F,t[5]=(r*B-i*M+a*L)*F,t[6]=(p*b-m*S-y*x)*F,t[7]=(d*S-u*b+h*x)*F,t[8]=(o*I-s*M+l*E)*F,t[9]=(n*M-r*I-a*E)*F,t[10]=(m*w-g*b+y*v)*F,t[11]=(f*b-d*w-h*v)*F,t[12]=(s*L-o*R-c*E)*F,t[13]=(r*R-n*L+i*E)*F,t[14]=(g*x-m*_-p*v)*F,t[15]=(d*_-f*x+u*v)*F,t):null}function ny(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],d=e[8],f=e[9],u=e[10],h=e[11],m=e[12],g=e[13],p=e[14],y=e[15],v=r*s-n*o,x=r*c-i*o,b=r*l-a*o,_=n*c-i*s,w=n*l-a*s,S=i*l-a*c,E=d*g-f*m,L=d*p-u*m,M=d*y-h*m,R=f*p-u*g,I=f*y-h*g,B=u*y-h*p;return t[0]=s*B-c*I+l*R,t[1]=i*I-n*B-a*R,t[2]=g*S-p*w+y*_,t[3]=u*w-f*S-h*_,t[4]=c*M-o*B-l*L,t[5]=r*B-i*M+a*L,t[6]=p*b-m*S-y*x,t[7]=d*S-u*b+h*x,t[8]=o*I-s*M+l*E,t[9]=n*M-r*I-a*E,t[10]=m*w-g*b+y*v,t[11]=f*b-d*w-h*v,t[12]=s*L-o*R-c*E,t[13]=r*R-n*L+i*E,t[14]=g*x-m*_-p*v,t[15]=d*_-f*x+u*v,t}function iy(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],d=t[9],f=t[10],u=t[11],h=t[12],m=t[13],g=t[14],p=t[15],y=e*o-r*a,v=e*s-n*a,x=r*s-n*o,b=l*m-d*h,_=l*g-f*h,w=d*g-f*m,S=e*w-r*_+n*b,E=a*w-o*_+s*b,L=l*x-d*v+f*y,M=h*x-m*v+g*y;return c*S-i*E+p*L-u*M}function Nh(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],c=e[5],l=e[6],d=e[7],f=e[8],u=e[9],h=e[10],m=e[11],g=e[12],p=e[13],y=e[14],v=e[15],x=r[0],b=r[1],_=r[2],w=r[3];return t[0]=x*n+b*s+_*f+w*g,t[1]=x*i+b*c+_*u+w*p,t[2]=x*a+b*l+_*h+w*y,t[3]=x*o+b*d+_*m+w*v,x=r[4],b=r[5],_=r[6],w=r[7],t[4]=x*n+b*s+_*f+w*g,t[5]=x*i+b*c+_*u+w*p,t[6]=x*a+b*l+_*h+w*y,t[7]=x*o+b*d+_*m+w*v,x=r[8],b=r[9],_=r[10],w=r[11],t[8]=x*n+b*s+_*f+w*g,t[9]=x*i+b*c+_*u+w*p,t[10]=x*a+b*l+_*h+w*y,t[11]=x*o+b*d+_*m+w*v,x=r[12],b=r[13],_=r[14],w=r[15],t[12]=x*n+b*s+_*f+w*g,t[13]=x*i+b*c+_*u+w*p,t[14]=x*a+b*l+_*h+w*y,t[15]=x*o+b*d+_*m+w*v,t}function ay(t,e,r){var n=r[0],i=r[1],a=r[2],o,s,c,l,d,f,u,h,m,g,p,y;return e===t?(t[12]=e[0]*n+e[4]*i+e[8]*a+e[12],t[13]=e[1]*n+e[5]*i+e[9]*a+e[13],t[14]=e[2]*n+e[6]*i+e[10]*a+e[14],t[15]=e[3]*n+e[7]*i+e[11]*a+e[15]):(o=e[0],s=e[1],c=e[2],l=e[3],d=e[4],f=e[5],u=e[6],h=e[7],m=e[8],g=e[9],p=e[10],y=e[11],t[0]=o,t[1]=s,t[2]=c,t[3]=l,t[4]=d,t[5]=f,t[6]=u,t[7]=h,t[8]=m,t[9]=g,t[10]=p,t[11]=y,t[12]=o*n+d*i+m*a+e[12],t[13]=s*n+f*i+g*a+e[13],t[14]=c*n+u*i+p*a+e[14],t[15]=l*n+h*i+y*a+e[15]),t}function oy(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function sy(t,e,r,n){var i=n[0],a=n[1],o=n[2],s=Math.sqrt(i*i+a*a+o*o),c,l,d,f,u,h,m,g,p,y,v,x,b,_,w,S,E,L,M,R,I,B,F,U;return s<$?null:(s=1/s,i*=s,a*=s,o*=s,c=Math.sin(r),l=Math.cos(r),d=1-l,f=e[0],u=e[1],h=e[2],m=e[3],g=e[4],p=e[5],y=e[6],v=e[7],x=e[8],b=e[9],_=e[10],w=e[11],S=i*i*d+l,E=a*i*d+o*c,L=o*i*d-a*c,M=i*a*d-o*c,R=a*a*d+l,I=o*a*d+i*c,B=i*o*d+a*c,F=a*o*d-i*c,U=o*o*d+l,t[0]=f*S+g*E+x*L,t[1]=u*S+p*E+b*L,t[2]=h*S+y*E+_*L,t[3]=m*S+v*E+w*L,t[4]=f*M+g*R+x*I,t[5]=u*M+p*R+b*I,t[6]=h*M+y*R+_*I,t[7]=m*M+v*R+w*I,t[8]=f*B+g*F+x*U,t[9]=u*B+p*F+b*U,t[10]=h*B+y*F+_*U,t[11]=m*B+v*F+w*U,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function ly(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],d=e[9],f=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+l*n,t[5]=o*i+d*n,t[6]=s*i+f*n,t[7]=c*i+u*n,t[8]=l*i-a*n,t[9]=d*i-o*n,t[10]=f*i-s*n,t[11]=u*i-c*n,t}function cy(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],c=e[3],l=e[8],d=e[9],f=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-l*n,t[1]=o*i-d*n,t[2]=s*i-f*n,t[3]=c*i-u*n,t[8]=a*n+l*i,t[9]=o*n+d*i,t[10]=s*n+f*i,t[11]=c*n+u*i,t}function dy(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],c=e[3],l=e[4],d=e[5],f=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+l*n,t[1]=o*i+d*n,t[2]=s*i+f*n,t[3]=c*i+u*n,t[4]=l*i-a*n,t[5]=d*i-o*n,t[6]=f*i-s*n,t[7]=u*i-c*n,t}function uy(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function fy(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function hy(t,e,r){var n=r[0],i=r[1],a=r[2],o=Math.sqrt(n*n+i*i+a*a),s,c,l;return o<$?null:(o=1/o,n*=o,i*=o,a*=o,s=Math.sin(e),c=Math.cos(e),l=1-c,t[0]=n*n*l+c,t[1]=i*n*l+a*s,t[2]=a*n*l-i*s,t[3]=0,t[4]=n*i*l-a*s,t[5]=i*i*l+c,t[6]=a*i*l+n*s,t[7]=0,t[8]=n*a*l+i*s,t[9]=i*a*l-n*s,t[10]=a*a*l+c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function my(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function py(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function gy(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Hh(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,c=i+i,l=a+a,d=n*s,f=n*c,u=n*l,h=i*c,m=i*l,g=a*l,p=o*s,y=o*c,v=o*l;return t[0]=1-(h+g),t[1]=f+v,t[2]=u-y,t[3]=0,t[4]=f-v,t[5]=1-(d+g),t[6]=m+p,t[7]=0,t[8]=u+y,t[9]=m-p,t[10]=1-(d+h),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function yy(t,e){var r=new xe(3),n=-e[0],i=-e[1],a=-e[2],o=e[3],s=e[4],c=e[5],l=e[6],d=e[7],f=n*n+i*i+a*a+o*o;return f>0?(r[0]=(s*o+d*n+c*a-l*i)*2/f,r[1]=(c*o+d*i+l*n-s*a)*2/f,r[2]=(l*o+d*a+s*i-c*n)*2/f):(r[0]=(s*o+d*n+c*a-l*i)*2,r[1]=(c*o+d*i+l*n-s*a)*2,r[2]=(l*o+d*a+s*i-c*n)*2),Hh(t,e,r),t}function by(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Vh(t,e){var r=e[0],n=e[1],i=e[2],a=e[4],o=e[5],s=e[6],c=e[8],l=e[9],d=e[10];return t[0]=Math.sqrt(r*r+n*n+i*i),t[1]=Math.sqrt(a*a+o*o+s*s),t[2]=Math.sqrt(c*c+l*l+d*d),t}function xy(t,e){var r=new xe(3);Vh(r,e);var n=1/r[0],i=1/r[1],a=1/r[2],o=e[0]*n,s=e[1]*i,c=e[2]*a,l=e[4]*n,d=e[5]*i,f=e[6]*a,u=e[8]*n,h=e[9]*i,m=e[10]*a,g=o+d+m,p=0;return g>0?(p=Math.sqrt(g+1)*2,t[3]=.25*p,t[0]=(f-h)/p,t[1]=(u-c)/p,t[2]=(s-l)/p):o>d&&o>m?(p=Math.sqrt(1+o-d-m)*2,t[3]=(f-h)/p,t[0]=.25*p,t[1]=(s+l)/p,t[2]=(u+c)/p):d>m?(p=Math.sqrt(1+d-o-m)*2,t[3]=(u-c)/p,t[0]=(s+l)/p,t[1]=.25*p,t[2]=(f+h)/p):(p=Math.sqrt(1+m-o-d)*2,t[3]=(s-l)/p,t[0]=(u+c)/p,t[1]=(f+h)/p,t[2]=.25*p),t}function vy(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];var i=n[0],a=n[1],o=n[2],s=n[4],c=n[5],l=n[6],d=n[8],f=n[9],u=n[10];r[0]=Math.sqrt(i*i+a*a+o*o),r[1]=Math.sqrt(s*s+c*c+l*l),r[2]=Math.sqrt(d*d+f*f+u*u);var h=1/r[0],m=1/r[1],g=1/r[2],p=i*h,y=a*m,v=o*g,x=s*h,b=c*m,_=l*g,w=d*h,S=f*m,E=u*g,L=p+b+E,M=0;return L>0?(M=Math.sqrt(L+1)*2,t[3]=.25*M,t[0]=(_-S)/M,t[1]=(w-v)/M,t[2]=(y-x)/M):p>b&&p>E?(M=Math.sqrt(1+p-b-E)*2,t[3]=(_-S)/M,t[0]=.25*M,t[1]=(y+x)/M,t[2]=(w+v)/M):b>E?(M=Math.sqrt(1+b-p-E)*2,t[3]=(w-v)/M,t[0]=(y+x)/M,t[1]=.25*M,t[2]=(_+S)/M):(M=Math.sqrt(1+E-p-b)*2,t[3]=(y-x)/M,t[0]=(w+v)/M,t[1]=(_+S)/M,t[2]=.25*M),t}function _y(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3],c=i+i,l=a+a,d=o+o,f=i*c,u=i*l,h=i*d,m=a*l,g=a*d,p=o*d,y=s*c,v=s*l,x=s*d,b=n[0],_=n[1],w=n[2];return t[0]=(1-(m+p))*b,t[1]=(u+x)*b,t[2]=(h-v)*b,t[3]=0,t[4]=(u-x)*_,t[5]=(1-(f+p))*_,t[6]=(g+y)*_,t[7]=0,t[8]=(h+v)*w,t[9]=(g-y)*w,t[10]=(1-(f+m))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Sy(t,e,r,n,i){var a=e[0],o=e[1],s=e[2],c=e[3],l=a+a,d=o+o,f=s+s,u=a*l,h=a*d,m=a*f,g=o*d,p=o*f,y=s*f,v=c*l,x=c*d,b=c*f,_=n[0],w=n[1],S=n[2],E=i[0],L=i[1],M=i[2],R=(1-(g+y))*_,I=(h+b)*_,B=(m-x)*_,F=(h-b)*w,U=(1-(u+y))*w,ce=(p+v)*w,Nt=(m+x)*S,Ct=(p-v)*S,zr=(1-(u+g))*S;return t[0]=R,t[1]=I,t[2]=B,t[3]=0,t[4]=F,t[5]=U,t[6]=ce,t[7]=0,t[8]=Nt,t[9]=Ct,t[10]=zr,t[11]=0,t[12]=r[0]+E-(R*E+F*L+Nt*M),t[13]=r[1]+L-(I*E+U*L+Ct*M),t[14]=r[2]+M-(B*E+ce*L+zr*M),t[15]=1,t}function wy(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,c=i+i,l=r*o,d=n*o,f=n*s,u=i*o,h=i*s,m=i*c,g=a*o,p=a*s,y=a*c;return t[0]=1-f-m,t[1]=d+y,t[2]=u-p,t[3]=0,t[4]=d-y,t[5]=1-l-m,t[6]=h+g,t[7]=0,t[8]=u+p,t[9]=h-g,t[10]=1-l-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function My(t,e,r,n,i,a,o){var s=1/(r-e),c=1/(i-n),l=1/(a-o);return t[0]=a*2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(i+n)*c,t[10]=(o+a)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*a*2*l,t[15]=0,t}function Gh(t,e,r,n,i){var a=1/Math.tan(e/2);if(t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){var o=1/(n-i);t[10]=(i+n)*o,t[14]=2*i*n*o}else t[10]=-1,t[14]=-2*n;return t}var Ay=Gh;function Ey(t,e,r,n,i){var a=1/Math.tan(e/2);if(t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){var o=1/(n-i);t[10]=i*o,t[14]=i*n*o}else t[10]=-1,t[14]=-n;return t}function Ly(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+s),l=2/(i+a);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((o-s)*c*.5),t[9]=(i-a)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function Wh(t,e,r,n,i,a,o){var s=1/(e-r),c=1/(n-i),l=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*c,t[14]=(o+a)*l,t[15]=1,t}var Ty=Wh;function Ry(t,e,r,n,i,a,o){var s=1/(e-r),c=1/(n-i),l=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*c,t[14]=a*l,t[15]=1,t}function Cy(t,e,r,n){var i,a,o,s,c,l,d,f,u,h,m=e[0],g=e[1],p=e[2],y=n[0],v=n[1],x=n[2],b=r[0],_=r[1],w=r[2];return Math.abs(m-b)<$&&Math.abs(g-_)<$&&Math.abs(p-w)<$?Uh(t):(d=m-b,f=g-_,u=p-w,h=1/Math.sqrt(d*d+f*f+u*u),d*=h,f*=h,u*=h,i=v*u-x*f,a=x*d-y*u,o=y*f-v*d,h=Math.sqrt(i*i+a*a+o*o),h?(h=1/h,i*=h,a*=h,o*=h):(i=0,a=0,o=0),s=f*o-u*a,c=u*i-d*o,l=d*a-f*i,h=Math.sqrt(s*s+c*c+l*l),h?(h=1/h,s*=h,c*=h,l*=h):(s=0,c=0,l=0),t[0]=i,t[1]=s,t[2]=d,t[3]=0,t[4]=a,t[5]=c,t[6]=f,t[7]=0,t[8]=o,t[9]=l,t[10]=u,t[11]=0,t[12]=-(i*m+a*g+o*p),t[13]=-(s*m+c*g+l*p),t[14]=-(d*m+f*g+u*p),t[15]=1,t)}function Py(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=n[0],c=n[1],l=n[2],d=i-r[0],f=a-r[1],u=o-r[2],h=d*d+f*f+u*u;h>0&&(h=1/Math.sqrt(h),d*=h,f*=h,u*=h);var m=c*u-l*f,g=l*d-s*u,p=s*f-c*d;return h=m*m+g*g+p*p,h>0&&(h=1/Math.sqrt(h),m*=h,g*=h,p*=h),t[0]=m,t[1]=g,t[2]=p,t[3]=0,t[4]=f*p-u*g,t[5]=u*m-d*p,t[6]=d*g-f*m,t[7]=0,t[8]=d,t[9]=f,t[10]=u,t[11]=0,t[12]=i,t[13]=a,t[14]=o,t[15]=1,t}function Iy(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function By(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function Fy(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function Xh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function ky(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function Dy(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function zy(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function Oy(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],u=t[10],h=t[11],m=t[12],g=t[13],p=t[14],y=t[15],v=e[0],x=e[1],b=e[2],_=e[3],w=e[4],S=e[5],E=e[6],L=e[7],M=e[8],R=e[9],I=e[10],B=e[11],F=e[12],U=e[13],ce=e[14],Nt=e[15];return Math.abs(r-v)<=$*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-x)<=$*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(i-b)<=$*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-_)<=$*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(o-w)<=$*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-S)<=$*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(c-E)<=$*Math.max(1,Math.abs(c),Math.abs(E))&&Math.abs(l-L)<=$*Math.max(1,Math.abs(l),Math.abs(L))&&Math.abs(d-M)<=$*Math.max(1,Math.abs(d),Math.abs(M))&&Math.abs(f-R)<=$*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(u-I)<=$*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(h-B)<=$*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(m-F)<=$*Math.max(1,Math.abs(m),Math.abs(F))&&Math.abs(g-U)<=$*Math.max(1,Math.abs(g),Math.abs(U))&&Math.abs(p-ce)<=$*Math.max(1,Math.abs(p),Math.abs(ce))&&Math.abs(y-Nt)<=$*Math.max(1,Math.abs(y),Math.abs(Nt))}var Uy=Nh,Ny=Xh;var Jl={};Na(Jl,{add:()=>cx,calculateW:()=>Qb,clone:()=>ax,conjugate:()=>rx,copy:()=>sx,create:()=>iu,dot:()=>um,equals:()=>px,exactEquals:()=>mx,exp:()=>sm,fromEuler:()=>nx,fromMat3:()=>cm,fromValues:()=>ox,getAngle:()=>$b,getAxisAngle:()=>Yb,identity:()=>Kb,invert:()=>tx,len:()=>fx,length:()=>fm,lerp:()=>ux,ln:()=>lm,mul:()=>dx,multiply:()=>om,normalize:()=>au,pow:()=>Jb,random:()=>ex,rotateX:()=>qb,rotateY:()=>Zb,rotateZ:()=>jb,rotationTo:()=>gx,scale:()=>dm,set:()=>lx,setAxes:()=>bx,setAxisAngle:()=>am,slerp:()=>Ql,sqlerp:()=>yx,sqrLen:()=>hx,squaredLength:()=>hm,str:()=>ix});var C={};Na(C,{add:()=>Wy,angle:()=>ub,bezier:()=>nb,ceil:()=>Xy,clone:()=>Hy,copy:()=>Vy,create:()=>Yl,cross:()=>ns,dist:()=>xb,distance:()=>Zh,div:()=>bb,divide:()=>qh,dot:()=>rs,equals:()=>pb,exactEquals:()=>mb,floor:()=>Ky,forEach:()=>Sb,fromValues:()=>$l,hermite:()=>rb,inverse:()=>Jy,len:()=>$d,length:()=>Kh,lerp:()=>eb,max:()=>$y,min:()=>Yy,mul:()=>yb,multiply:()=>$h,negate:()=>Qy,normalize:()=>Yd,random:()=>ib,rotateX:()=>lb,rotateY:()=>cb,rotateZ:()=>db,round:()=>qy,scale:()=>Zy,scaleAndAdd:()=>jy,set:()=>Gy,slerp:()=>tb,sqrDist:()=>vb,sqrLen:()=>_b,squaredDistance:()=>jh,squaredLength:()=>Qh,str:()=>hb,sub:()=>gb,subtract:()=>Yh,transformMat3:()=>ob,transformMat4:()=>ab,transformQuat:()=>sb,zero:()=>fb});function Yl(){var t=new xe(3);return xe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Hy(t){var e=new xe(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Kh(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function $l(t,e,r){var n=new xe(3);return n[0]=t,n[1]=e,n[2]=r,n}function Vy(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Gy(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function Wy(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Yh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function $h(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function qh(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Xy(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function Ky(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function Yy(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function $y(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function qy(t,e){return t[0]=tn(e[0]),t[1]=tn(e[1]),t[2]=tn(e[2]),t}function Zy(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function jy(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function Zh(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function jh(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function Qh(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function Qy(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Jy(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Yd(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t}function rs(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ns(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],c=r[2];return t[0]=i*c-a*s,t[1]=a*o-n*c,t[2]=n*s-i*o,t}function eb(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t}function tb(t,e,r,n){var i=Math.acos(Math.min(Math.max(rs(e,r),-1),1)),a=Math.sin(i),o=Math.sin((1-n)*i)/a,s=Math.sin(n*i)/a;return t[0]=o*e[0]+s*r[0],t[1]=o*e[1]+s*r[1],t[2]=o*e[2]+s*r[2],t}function rb(t,e,r,n,i,a){var o=a*a,s=o*(2*a-3)+1,c=o*(a-2)+a,l=o*(a-1),d=o*(3-2*a);return t[0]=e[0]*s+r[0]*c+n[0]*l+i[0]*d,t[1]=e[1]*s+r[1]*c+n[1]*l+i[1]*d,t[2]=e[2]*s+r[2]*c+n[2]*l+i[2]*d,t}function nb(t,e,r,n,i,a){var o=1-a,s=o*o,c=a*a,l=s*o,d=3*a*s,f=3*c*o,u=c*a;return t[0]=e[0]*l+r[0]*d+n[0]*f+i[0]*u,t[1]=e[1]*l+r[1]*d+n[1]*f+i[1]*u,t[2]=e[2]*l+r[2]*d+n[2]*f+i[2]*u,t}function ib(t,e){e=e===void 0?1:e;var r=er()*2*Math.PI,n=er()*2-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}function ab(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}function ob(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}function sb(t,e,r){var n=r[0],i=r[1],a=r[2],o=r[3],s=e[0],c=e[1],l=e[2],d=i*l-a*c,f=a*s-n*l,u=n*c-i*s;return d=d+d,f=f+f,u=u+u,t[0]=s+o*d+i*u-a*f,t[1]=c+o*f+a*d-n*u,t[2]=l+o*u+n*f-i*d,t}function lb(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t}function cb(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t}function db(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t}function ub(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],o=e[1],s=e[2],c=Math.sqrt((r*r+n*n+i*i)*(a*a+o*o+s*s)),l=c&&rs(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function fb(t){return t[0]=0,t[1]=0,t[2]=0,t}function hb(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function mb(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function pb(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],o=e[1],s=e[2];return Math.abs(r-a)<=$*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-o)<=$*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-s)<=$*Math.max(1,Math.abs(i),Math.abs(s))}var gb=Yh,yb=$h,bb=qh,xb=Zh,vb=jh,$d=Kh,_b=Qh,Sb=(function(){var t=Yl();return function(e,r,n,i,a,o){var s,c;for(r||(r=3),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,s=n;s<c;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2];return e}})();var ga={};Na(ga,{add:()=>Jd,ceil:()=>wb,clone:()=>qd,copy:()=>jd,create:()=>Jh,cross:()=>Pb,dist:()=>Hb,distance:()=>nm,div:()=>Nb,divide:()=>rm,dot:()=>jl,equals:()=>zb,exactEquals:()=>nu,floor:()=>Mb,forEach:()=>Xb,fromValues:()=>Zd,inverse:()=>Cb,len:()=>Gb,length:()=>ql,lerp:()=>ru,max:()=>Eb,min:()=>Ab,mul:()=>Ub,multiply:()=>tm,negate:()=>Rb,normalize:()=>tu,random:()=>Ib,round:()=>Lb,scale:()=>eu,scaleAndAdd:()=>Tb,set:()=>Qd,sqrDist:()=>Vb,sqrLen:()=>Wb,squaredDistance:()=>im,squaredLength:()=>Zl,str:()=>Db,sub:()=>Ob,subtract:()=>em,transformMat4:()=>Bb,transformQuat:()=>Fb,zero:()=>kb});function Jh(){var t=new xe(4);return xe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function qd(t){var e=new xe(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Zd(t,e,r,n){var i=new xe(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}function jd(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Qd(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function Jd(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function em(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function tm(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function rm(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function wb(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function Mb(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function Ab(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function Eb(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function Lb(t,e){return t[0]=tn(e[0]),t[1]=tn(e[1]),t[2]=tn(e[2]),t[3]=tn(e[3]),t}function eu(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function Tb(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}function nm(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)}function im(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}function ql(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}function Zl(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}function Rb(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function Cb(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function tu(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o,t}function jl(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Pb(t,e,r,n){var i=r[0]*n[1]-r[1]*n[0],a=r[0]*n[2]-r[2]*n[0],o=r[0]*n[3]-r[3]*n[0],s=r[1]*n[2]-r[2]*n[1],c=r[1]*n[3]-r[3]*n[1],l=r[2]*n[3]-r[3]*n[2],d=e[0],f=e[1],u=e[2],h=e[3];return t[0]=f*l-u*c+h*s,t[1]=-(d*l)+u*o-h*a,t[2]=d*c-f*o+h*i,t[3]=-(d*s)+f*a-u*i,t}function ru(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t}function Ib(t,e){e=e===void 0?1:e;var r,n,i,a,o,s,c;c=er(),r=c*2-1,n=(4*er()-2)*Math.sqrt(c*-c+c),o=r*r+n*n,c=er(),i=c*2-1,a=(4*er()-2)*Math.sqrt(c*-c+c),s=i*i+a*a;var l=Math.sqrt((1-o)/s);return t[0]=e*r,t[1]=e*n,t[2]=e*i*l,t[3]=e*a*l,t}function Bb(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function Fb(t,e,r){var n=r[0],i=r[1],a=r[2],o=r[3],s=e[0],c=e[1],l=e[2],d=i*l-a*c,f=a*s-n*l,u=n*c-i*s;return d=d+d,f=f+f,u=u+u,t[0]=s+o*d+i*u-a*f,t[1]=c+o*f+a*d-n*u,t[2]=l+o*u+n*f-i*d,t[3]=e[3],t}function kb(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function Db(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function nu(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function zb(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],c=e[2],l=e[3];return Math.abs(r-o)<=$*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=$*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-c)<=$*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(a-l)<=$*Math.max(1,Math.abs(a),Math.abs(l))}var Ob=em,Ub=tm,Nb=rm,Hb=nm,Vb=im,Gb=ql,Wb=Zl,Xb=(function(){var t=Jh();return function(e,r,n,i,a,o){var s,c;for(r||(r=4),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,s=n;s<c;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],t[3]=e[s+3],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2],e[s+3]=t[3];return e}})();function iu(){var t=new xe(4);return xe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Kb(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function am(t,e,r){r=r*.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function Yb(t,e){var r=Math.acos(e[3])*2,n=Math.sin(r/2);return n>$?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function $b(t,e){var r=um(t,e);return Math.acos(2*r*r-1)}function om(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=r[0],c=r[1],l=r[2],d=r[3];return t[0]=n*d+o*s+i*l-a*c,t[1]=i*d+o*c+a*s-n*l,t[2]=a*d+o*l+n*c-i*s,t[3]=o*d-n*s-i*c-a*l,t}function qb(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*s,t[1]=i*c+a*s,t[2]=a*c-i*s,t[3]=o*c-n*s,t}function Zb(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),c=Math.cos(r);return t[0]=n*c-a*s,t[1]=i*c+o*s,t[2]=a*c+n*s,t[3]=o*c-i*s,t}function jb(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*s,t[1]=i*c-n*s,t[2]=a*c+o*s,t[3]=o*c-a*s,t}function Qb(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t}function sm(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=Math.sqrt(r*r+n*n+i*i),s=Math.exp(a),c=o>0?s*Math.sin(o)/o:0;return t[0]=r*c,t[1]=n*c,t[2]=i*c,t[3]=s*Math.cos(o),t}function lm(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=Math.sqrt(r*r+n*n+i*i),s=o>0?Math.atan2(o,a)/o:0;return t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=.5*Math.log(r*r+n*n+i*i+a*a),t}function Jb(t,e,r){return lm(t,e),dm(t,t,r),sm(t,t),t}function Ql(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3],c=r[0],l=r[1],d=r[2],f=r[3],u,h,m,g,p;return h=i*c+a*l+o*d+s*f,h<0&&(h=-h,c=-c,l=-l,d=-d,f=-f),1-h>$?(u=Math.acos(h),m=Math.sin(u),g=Math.sin((1-n)*u)/m,p=Math.sin(n*u)/m):(g=1-n,p=n),t[0]=g*i+p*c,t[1]=g*a+p*l,t[2]=g*o+p*d,t[3]=g*s+p*f,t}function ex(t){var e=er(),r=er(),n=er(),i=Math.sqrt(1-e),a=Math.sqrt(e);return t[0]=i*Math.sin(2*Math.PI*r),t[1]=i*Math.cos(2*Math.PI*r),t[2]=a*Math.sin(2*Math.PI*n),t[3]=a*Math.cos(2*Math.PI*n),t}function tx(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return t[0]=-r*s,t[1]=-n*s,t[2]=-i*s,t[3]=a*s,t}function rx(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function cm(t,e){var r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[i*3+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;n=Math.sqrt(e[i*3+i]-e[a*3+a]-e[o*3+o]+1),t[i]=.5*n,n=.5/n,t[3]=(e[a*3+o]-e[o*3+a])*n,t[a]=(e[a*3+i]+e[i*3+a])*n,t[o]=(e[o*3+i]+e[i*3+o])*n}return t}function nx(t,e,r,n){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:zh,a=Math.PI/360;e*=a,n*=a,r*=a;var o=Math.sin(e),s=Math.cos(e),c=Math.sin(r),l=Math.cos(r),d=Math.sin(n),f=Math.cos(n);switch(i){case"xyz":t[0]=o*l*f+s*c*d,t[1]=s*c*f-o*l*d,t[2]=s*l*d+o*c*f,t[3]=s*l*f-o*c*d;break;case"xzy":t[0]=o*l*f-s*c*d,t[1]=s*c*f-o*l*d,t[2]=s*l*d+o*c*f,t[3]=s*l*f+o*c*d;break;case"yxz":t[0]=o*l*f+s*c*d,t[1]=s*c*f-o*l*d,t[2]=s*l*d-o*c*f,t[3]=s*l*f+o*c*d;break;case"yzx":t[0]=o*l*f+s*c*d,t[1]=s*c*f+o*l*d,t[2]=s*l*d-o*c*f,t[3]=s*l*f-o*c*d;break;case"zxy":t[0]=o*l*f-s*c*d,t[1]=s*c*f+o*l*d,t[2]=s*l*d+o*c*f,t[3]=s*l*f-o*c*d;break;case"zyx":t[0]=o*l*f-s*c*d,t[1]=s*c*f+o*l*d,t[2]=s*l*d-o*c*f,t[3]=s*l*f+o*c*d;break;default:throw new Error("Unknown angle order "+i)}return t}function ix(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var ax=qd,ox=Zd,sx=jd,lx=Qd,cx=Jd,dx=om,dm=eu,um=jl,ux=ru,fm=ql,fx=fm,hm=Zl,hx=hm,au=tu,mx=nu;function px(t,e){return Math.abs(jl(t,e))>=1-$}var gx=(function(){var t=Yl(),e=$l(1,0,0),r=$l(0,1,0);return function(n,i,a){var o=rs(i,a);return o<-.999999?(ns(t,e,i),$d(t)<1e-6&&ns(t,r,i),Yd(t,t),am(n,t,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(ns(t,i,a),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+o,au(n,n))}})(),yx=(function(){var t=iu(),e=iu();return function(r,n,i,a,o,s){return Ql(t,n,o,s),Ql(e,i,a,s),Ql(r,t,e,2*s*(1-s)),r}})(),bx=(function(){var t=Oh();return function(e,r,n,i){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],au(e,cm(e,t))}})();var ec=class{constructor(e,r){this._position=C.create();this._angles=C.create();this._bobAngles=C.create();this._bobOffset=C.create();this._kickAngles=C.create();this._rollAngle=0;this._fov=90;this._aspect=1;this._near=.1;this._far=1e3;this._viewMatrix=j.create();this._projectionMatrix=j.create();this._viewProjectionMatrix=j.create();this._dirty=!0;e!==void 0&&r!==void 0&&r>0&&(this._aspect=e/r)}get position(){return this._position}set position(e){C.equals(this._position,e)||(C.copy(this._position,e),this._dirty=!0,this.triggerMoveEvent())}get angles(){return this._angles}set angles(e){C.equals(this._angles,e)||(C.copy(this._angles,e),this._dirty=!0,this.triggerMoveEvent())}get bobAngles(){return this._bobAngles}set bobAngles(e){C.copy(this._bobAngles,e),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(e){C.copy(this._kickAngles,e),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(e){C.copy(this._bobOffset,e),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(e){this._rollAngle=e,this._dirty=!0}get fov(){return this._fov}set fov(e){this._fov=e,this._dirty=!0}get aspect(){return this._aspect}set aspect(e){this._aspect=e,this._dirty=!0}setPosition(e,r,n){let i=C.fromValues(e,r,n);C.equals(this._position,i)||(C.copy(this._position,i),this._dirty=!0,this.triggerMoveEvent())}setRotation(e,r,n){let i=C.fromValues(e,r,n);C.equals(this._angles,i)||(C.copy(this._angles,i),this._dirty=!0,this.triggerMoveEvent())}setFov(e){this.fov=e}setAspectRatio(e){this.aspect=e}lookAt(e){let r=C.create();if(C.subtract(r,e,this._position),C.length(r)<.001)return;let i=Math.atan2(r[1],r[0])*zc,a=Math.hypot(r[0],r[1]),o=-Math.atan2(r[2],a)*zc;this.setRotation(o,i,0)}triggerMoveEvent(){this.onCameraMove&&this.onCameraMove({position:C.clone(this._position),angles:C.clone(this._angles)})}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(e){let r=j.create();return j.perspective(r,e*Pi,this._aspect,this._near,this._far),r}screenToWorldRay(e,r){let n=e*2-1,i=1-r*2,a=C.fromValues(n,i,-1),o=C.fromValues(n,i,1),s=j.create();j.invert(s,this.viewProjectionMatrix);let c=C.create(),l=C.create();C.transformMat4(c,a,s),C.transformMat4(l,o,s);let d=C.create();return C.subtract(d,l,c),C.normalize(d,d),{origin:C.clone(this._position),direction:d}}updateMatrices(){if(!this._dirty)return;j.perspective(this._projectionMatrix,this._fov*Pi,this._aspect,this._near,this._far);let e=j.fromValues(0,0,-1,0,-1,0,0,0,0,1,0,0,0,0,0,1),r=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],n=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],i=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,a=r*Pi,o=n*Pi,s=i*Pi,c=j.create();j.identity(c),j.rotateZ(c,c,-o),j.rotateY(c,c,-a),j.rotateX(c,c,-s);let l=j.create();j.multiply(l,e,c);let d=C.add(C.create(),this._position,this._bobOffset),f=C.negate(C.create(),d),u=C.create();C.transformMat4(u,f,c);let h=C.fromValues(u[1]?-u[1]:0,u[2]||0,u[0]?-u[0]:0);j.copy(this._viewMatrix,l),this._viewMatrix[12]=h[0],this._viewMatrix[13]=h[1],this._viewMatrix[14]=h[2],j.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};var xx=[.2,.2,.2],vx={x:0,y:0,z:1},_x=[.8,.8,.8];function ou(t,e,r){return t+(e-t)*r}function ba(t,e,r){return{x:ou(t.x,e.x,r),y:ou(t.y,e.y,r),z:ou(t.z,e.z,r)}}function ya(t){return t<0?0:t>1?1:t}function su(t){let e=[],r=[];for(let n of t.triangles){let i=e.length,[a,o,s]=n.indices,c=t.texCoords[a],l=t.texCoords[o],d=t.texCoords[s];if(!c||!l||!d)throw new Error(`Missing texCoord for triangle in surface ${t.name}`);e.push({vertexIndex:a,texCoord:[c.s,1-c.t]},{vertexIndex:o,texCoord:[l.s,1-l.t]},{vertexIndex:s,texCoord:[d.s,1-d.t]}),r.push(i,i+1,i+2)}return{vertices:e,indices:new Uint16Array(r)}}function Sx(t,e,r){let n=r?.ambient??xx,i=r?.directional??{direction:vx,color:_x},a=Hr(t),o=Hr(i.direction),s=ya(a.x*o.x+a.y*o.y+a.z*o.z),c=n[0]+i.color[0]*s,l=n[1]+i.color[1]*s,d=n[2]+i.color[2]*s;if(r?.dynamicLights){let f=r.modelMatrix?ff(r.modelMatrix,e):e;for(let u of r.dynamicLights){let h=f.x-u.origin.x,m=f.y-u.origin.y,g=f.z-u.origin.z,p=h*h+m*m+g*g,y=u.radius*u.radius;if(p<y&&y>0){let v=1-Math.sqrt(p)/u.radius,x=Math.sqrt(p),b=x>0?ya(-(h*a.x+m*a.y+g*a.z)/x):0,_=ya(v*b);c+=u.color[0]*_,l+=u.color[1]*_,d+=u.color[2]*_}}}return[ya(c),ya(l),ya(d)]}function lu(t,e,r,n){let i=t.vertices[r.frame0],a=t.vertices[r.frame1];if(!i||!a)throw new Error("Requested MD3 frames are out of range");let o=new Float32Array(e.vertices.length*12);return e.vertices.forEach((s,c)=>{let l=i[s.vertexIndex],d=a[s.vertexIndex];if(!l||!d)throw new Error(`Vertex index ${s.vertexIndex} missing for frame`);let f=ba(l.position,d.position,r.lerp),u=Hr(ba(l.normal,d.normal,r.lerp)),h=Sx(u,f,n),m=c*12;o[m]=f.x,o[m+1]=f.y,o[m+2]=f.z,o[m+3]=u.x,o[m+4]=u.y,o[m+5]=u.z,o[m+6]=s.texCoord[0],o[m+7]=s.texCoord[1],o[m+8]=h[0],o[m+9]=h[1],o[m+10]=h[2],o[m+11]=1}),o}function mm(t,e,r){let n=t.tags[0];if(!n)return null;let i=n.findIndex(g=>g.name===r);if(i===-1)return null;let a=t.tags[e.frame0]?.[i],o=t.tags[e.frame1]?.[i];if(!a||!o)throw new Error(`Tag ${r} is missing for one of the interpolated frames`);let s=ba(a.origin,o.origin,e.lerp),c=Hr(ba(a.axis[0],o.axis[0],e.lerp)),l=Hr(ba(a.axis[1],o.axis[1],e.lerp)),d=Hr(ba(a.axis[2],o.axis[2],e.lerp)),f=c,u=Hr({x:l.x-f.x*(f.x*l.x+f.y*l.y+f.z*l.z),y:l.y-f.y*(f.x*l.x+f.y*l.y+f.z*l.z),z:l.z-f.z*(f.x*l.x+f.y*l.y+f.z*l.z)}),h=Hr({x:f.y*u.z-f.z*u.y,y:f.z*u.x-f.x*u.z,z:f.x*u.y-f.y*u.x}),m=[f,u,h];return{origin:s,axis:m,matrix:hf(s,m)}}var cu=`#version 300 es
|
|
480
480
|
precision highp float;
|
|
481
481
|
|
|
482
482
|
layout(location = 0) in vec3 a_position;
|