@korial29/tiny-fps 0.27.1 → 0.28.0
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/README.md +1 -1
- package/dist/index.js +13 -12
- package/dist/types/client/gun.d.ts +4 -4
- package/dist/types/client/render.d.ts +16 -2
- package/dist/types/client/skyline.d.ts +2 -2
- package/dist/types/client/street.d.ts +23 -0
- package/dist/types/client/traffic.d.ts +40 -0
- package/dist/types/client/vision.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ It started as a co-op shooter inspired by carlini's [Yet Another Doom Clone](htt
|
|
|
30
30
|
| `@korial29/tiny-fps/local` | Same-browser multiplayer, no server: the host runs in a tab | ~8.4 KB |
|
|
31
31
|
| `@korial29/tiny-fps/server` | Node WebSocket server (needs `ws`) | Node only |
|
|
32
32
|
|
|
33
|
-
CI checks the budgets (
|
|
33
|
+
CI checks the budgets (48 KB and 16 KB) on every pull request.
|
|
34
34
|
|
|
35
35
|
## Live demo
|
|
36
36
|
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var e=.4,t=1.8,n=1.55,r=.5,i=.9,a=7.5,o=2.4,s=5.5,c=2.5,l=[`Red`,`Blue`],u=[`#ff3d4f`,`#2f80ff`],d=1.5,f=.012,p=1.2,m={HOME:0,CARRIED:1,DROPPED:2},h={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,SPRINT:32,DASH:64,CROUCH:128,FIRE:256},g={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6},_={NONE:0,EAST:1,WEST:2,SOUTH:3,NORTH:4},v={JUMP:1,DOUBLE:2,DASH:4,LAND:8,GRAB:16,CLIMB:32,WALLRUN_START:64,WALLRUN_END:128,SLIDE_START:256,SLIDE_END:512,RESPAWN:1024},y={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11},b=-30,x=(e,t,n,r,i,a=y.CONCRETE)=>({min:[e,b,t],max:[n,i,r],top:y.CONCRETE,side:a}),S=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[x(4,57.7,24,76,10),x(4,36,24,53.5,10,y.GLASS),x(4,20,24,36,12.4),x(4,-5,24,7,12.4,y.GLASS),x(27,20,47,50,8),x(27,60,47,76,8,y.BRICK),S([9,12.2,39],[19,12.6,47],y.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>S([12,t,e-n],[14,t+.4*n,e-n+1],y.CONCRETE)))(53,10),S([5,10,42],[5.5,14,42.5],y.STEEL),S([5,10,50],[5.5,14,50.5],y.STEEL),S([8,12.4,24],[20,12.85,24.45],y.STEEL),S([36,8,22],[37,14.5,48],y.PAINT,y.PAINT,[.15,.72,.62]),S([30,8,28],[34,10,32],y.CONCRETE),S([40,8,30],[44,10.2,34],y.PAINT,y.PAINT,[1,.3,.06]),S([28,9.2,44],[35,12,46],y.STEEL,y.PAINT,[.2,.42,1]),S([41.5,7.6,50],[42,8,60],y.STEEL),S([30,8,64],[34,9.6,68],y.PAINT,y.PAINT,[.2,.8,.3])];var C=240,w=[1,.22,.26],T=[.2,.46,1],E=[1,.42,.08],D=[.12,.7,.62],O=(e,t,n,r,i,a,o)=>S([e,t,n],[r,i,a],y.PAINT,y.PAINT,o),k=(e,t,n,r,i,a,o,s=b)=>{let c=Math.ceil((o-a)/.46);return Array.from({length:c},(l,u)=>{let[d,f]=[t+(n-t)*u/c,t+(n-t)*(u+1)/c].sort((e,t)=>e-t),p=a+(o-a)*(u+1)/c;return e===0?S([d,s,r],[f,p,i],y.CONCRETE):S([r,s,d],[i,p,f],y.CONCRETE)})},A=(e,t,n,r,i,a,o)=>o.map((o,s)=>S([e+s*n,a,t+s*r],[e+s*n+4,o,t+s*r+i],y.STEEL,y.CONCRETE)),j=[x(12,212,52,240,26,y.GLASS),O(12,26,212,52,26.12,212.5,w),O(12,26,239.5,52,26.12,240,w),O(12,26,212.5,12.5,26.12,239.5,w),O(51.5,26,212.5,52,26.12,239.5,w),O(11.6,12,222,12,25.8,232,w),O(28,12,211.4,31,25.5,212,w),S([19,26,222],[22,27.4,225],y.STEEL),S([42,26,222],[45,27.4,225],y.STEEL),S([29,26,229],[35,27.1,229.6],y.CONCRETE),x(6,164,26,201,26,y.GLASS),x(6,134,26,147,26,y.GLASS),x(6,201,26,212,19),x(15,147,26,164,19),S([14,26,164],[15,32,196],y.PAINT,y.PAINT,D),S([14,18,147],[15,32,164],y.PAINT,y.PAINT,D),S([14,26,134],[15,32,147],y.PAINT,y.PAINT,D),...A(6,201,7,0,4,19,[21.2,23.4,25]),...[[18,152,22,156,21.2],[18,158,22,162,23.4],[23,160,26,164,25]].map(([e,t,n,r,i])=>S([e,19,t],[n,i,r],y.STEEL,y.CONCRETE)),S([20,26,178],[23,27.3,181],y.STEEL),S([8,26,176],[11,27.2,179],y.STEEL),S([8,26,190],[11,27.3,193],y.STEEL),S([20,26,140],[23,27.3,143],y.STEEL),x(32,186,76,209,19),O(32,19,207.5,76,19.1,209,w),...A(33,209,7,0,3,19,[21.2,23.4,25]),...[[28,196,32,200,21.2],[28,190,32,194,23.4],[26,184,30,188,25]].map(([e,t,n,r,i])=>S([e,b,t],[n,i,r],y.STEEL,y.CONCRETE)),x(32,166,64,182,21.2,y.GLASS),x(32,140,64,161,19),S([40,21.2,172],[44,22.6,176],y.STEEL),S([52,19,148],[57,20.3,151],y.STEEL),S([38,19,196],[41,20.4,199],y.STEEL),S([60,19,200],[63,20.4,203],y.STEEL),S([52,19,190],[58,20.6,194],y.STEEL),S([66,19,204],[72,20.2,207],y.STEEL),S([56,21.2,170],[60,22.4,174],y.STEEL),S([34,19,152],[37,20.3,156],y.STEEL),...A(36,135,18,0,3,15,[17.2,17.2]),...A(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),x(76,213,100,240,14.5,y.STEEL),O(76,14.5,238.5,100,14.6,240,w),x(76,185,100,209,14.5),x(76,138,100,181,14.5,y.GLASS),S([80,15.7,158],[96,17.7,162],y.STEEL,y.PAINT,E),S([82,14.5,234],[85,15.9,237],y.STEEL),S([91,14.5,190],[94,15.9,193],y.STEEL),S([80,14.5,204],[83,15.6,207],y.STEEL),S([78,14.5,170],[81,15.9,173],y.STEEL),S([92,14.5,146],[95,15.7,149],y.STEEL),S([92,14.5,222],[96,15.8,226],y.STEEL),...k(0,76,52,226,232,14.5,26),...k(0,85,76,196,202,14.5,19,14.5)],M=[x(6,106,62,134,15),x(62,106,100,134,14.5),S([34,15,112],[54,17.2,128],y.CONCRETE),O(38,17.2,116,50,17.3,124,E),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>S([e,17.2,t],[e+.8,21.5,t+.8],y.STEEL)),S([34.6,21.5,112.6],[52.2,21.9,127.4],y.GLASS),S([14,15,114],[17,16.5,117],y.STEEL),S([14,15,123],[17,16.5,126],y.STEEL),S([56,15,114],[59,16.5,117],y.STEEL),S([56,15,123],[59,16.5,126],y.STEEL),S([15.35,25.5,106],[15.85,26,134],y.STEEL),S([70,14.5,108],[70.8,38,108.8],y.STEEL),S([70,14.5,131.2],[70.8,38,132],y.STEEL),S([66,14.5,110],[69,15.9,113],y.STEEL),S([66,14.5,127],[69,15.9,130],y.STEEL)],ee=e=>({...e,min:[e.min[0],e.min[1],C-e.max[2]],max:[e.max[0],e.max[1],C-e.min[2]],tint:e.tint===w?T:e.tint}),N=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],P=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],F=[[21,26,168],[46,19,144],[36,21.2,178],[88,14.5,216],[88,14.5,172]],I={name:`Highline`,brushes:[...j,...j.map(ee),...M],teams:[{base:[32,26,224],spawns:N(0,236,231),rack:[47,26,234]},{base:[32,26,16],spawns:N(Math.PI,4,9),rack:[47,26,6]}],packs:[...P,...P.map(([e,t,n])=>[e,t,C-n]),[24,15,112],[24,15,128]],ammo:[...F,...F.map(([e,t,n])=>[e,t,C-n])],floor:-25,sun:{dir:[.8,.6,0],color:[2.6,2.3,1.8]},sky:[[.04,.2,.72],[.72,.86,.98]],fog:[.72,.86,.98,.0035]},L=4,R=1024,z=(e,t)=>(e+R)*(2*R)+t+R,B=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),te=(e,t=L)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=B(e[0],t);a<=B(r[0],t);a++)for(let o=B(e[2],t);o<=B(r[2],t);o++){let e=z(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),{def:e,cell:t,grid:n}},ne=(e,t,n,r)=>{let i=[];for(let a=B(t-r,e.cell);a<=B(t+r,e.cell);a++)for(let t=B(n-r,e.cell);t<=B(n+r,e.cell);t++)for(let n of e.grid.get(z(a,t))??[])i.includes(n)||i.push(n);return i},V=(e,t,n,r)=>{let{cell:i,def:a}=e,o=r,s=B(t[0],i),c=B(t[2],i),l=Math.sign(n[0]),u=Math.sign(n[2]),d=l?((s+ +(l>0))*i-t[0])/n[0]:1/0,f=u?((c+ +(u>0))*i-t[2])/n[2]:1/0,p=d,m=f,h=l?i/Math.abs(n[0]):1/0,g=u?i/Math.abs(n[2]):1/0;for(;;){for(let r of e.grid.get(z(s,c))??[]){let e=a.brushes[r],[i,s]=[0,o];for(let r=0;r<3&&i<=s;r++){if(!n[r]){(t[r]<e.min[r]||t[r]>e.max[r])&&(s=-1);continue}let a=(e.min[r]-t[r])/n[r],o=(e.max[r]-t[r])/n[r];i=Math.max(i,Math.min(a,o)),s=Math.min(s,Math.max(a,o))}i<=s&&s>0&&i<o&&(o=i)}if(Math.min(p,m)>=o||Math.abs(s)>R||Math.abs(c)>R)return o;p<m?(s+=l,p+=h):(c+=u,m+=g)}},re=(e,t,n)=>{let[r,i,a]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],o=Math.hypot(r,i,a);return o>0&&V(e,t,[r/o,i/o,a/o],o)<o-1e-4},H=1/60,U=Math.PI*2,ie=1e-6,ae=.01,oe=.001,se=e=>(e%U+U)%U,ce=e=>[-Math.sin(e),-Math.cos(e)],le=Math.fround,ue=Math.sqrt,de=(e,t,n)=>Math.min(Math.max(e,t),n),W=(e,t)=>ue(e*e+t*t),fe=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],pe={vx:0,vz:0,mode:g.GROUND,t:0,wall:_.NONE,edge:0,jumps:1,dashes:1,dash:0,stun:0,coyote:6,buffer:0,held:0,hp:5,ammo:-1,cool:0,rack:!1,down:0,shots:0,hits:0,ev:0,fall:0},me=(e,t,n,r=0)=>{let{spawns:i}=t.def.teams[r],[a,o,s,c]=i[(n%i.length+i.length)%i.length];return{id:e,x:le(a),y:le(o),z:le(s),vy:0,yaw:se(c),pitch:0,ground:!0,...pe}},he=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:o,hits:s}=e;Object.assign(e,me(a,t,a,n),{yaw:r,pitch:i,shots:o,hits:s,ev:e.ev|v.RESPAWN})},ge=e=>e===g.GROUND||e===g.SLIDE||e===g.CROUCH,_e=e=>e.mode===g.SLIDE||e.mode===g.CROUCH?i:t,ve=e=>e.mode===g.SLIDE||e.mode===g.CROUCH?.7:1.6,ye=e=>W(e.vx,e.vz),be=e=>e.mode===g.GROUND&&W(e.vx,e.vz)>6.5,xe=(e,t,n)=>e.max[1]>t+.5+ae&&e.min[1]<t+n-ae,Se=(e,t,n)=>[t-de(t,e.min[0],e.max[0]),n-de(n,e.min[2],e.max[2])],Ce=(t,n,r)=>{let{brushes:i}=n.def,a=ne(n,t.x,t.z,2*e),o=(e-ie)**2,[s,c]=[0,0];for(let n=0;n<4;n++){let n=0,l=0,u=0;for(let s of a){let a=i[s];if(!xe(a,t.y,r))continue;let[c,d]=Se(a,t.x,t.z),f=c*c+d*d;if(f>=o)continue;if(f){let t=ue(f);.4-t>n&&(n=e-t,l=c/t*n,u=d/t*n);continue}let[p,m,h]=[[t.x-a.min[0],-1,0],[a.max[0]-t.x,1,0],[t.z-a.min[2],0,-1],[a.max[2]-t.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);p+.4>n&&(n=p+e,[l,u]=[m*n,h*n])}if(!n)break;t.x+=l,t.z+=u,s+=l,c+=u}return[s,c]},we=(t,n,r)=>{let{brushes:i}=n.def,a=(e-ie)**2,o=-1/0,s=1/0;for(let c of ne(n,t.x,t.z,e)){let e=i[c],[n,l]=Se(e,t.x,t.z);n*n+l*l>=a||(e.max[1]<=t.y+.5+ae?o=Math.max(o,e.max[1]):e.min[1]>=t.y+r-ae&&(s=Math.min(s,e.min[1])))}return[o,s]},Te=(t,n)=>{let r=(e-ie)**2;return ne(n,t.x,t.z,e).every(e=>{let i=n.def.brushes[e],[a,o]=Se(i,t.x,t.z);return a*a+o*o>=r||!xe(i,t.y,1.8)})},Ee=(t,n,r,i,a)=>{let o=(e-ie)**2;return ne(t,n,r,e).every(e=>{let s=t.def.brushes[e],[c,l]=Se(s,n,r);return c*c+l*l>=o||s.max[1]<=i||s.min[1]>=a})},De=(e,t)=>{let[n,r]=fe[t],i=n?0:2;return{a:i,o:2-i,sign:n||r,c:n?e.x:e.z,co:n?e.z:e.x}},Oe=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=De(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-oe&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},ke=(t,n,r)=>{let i;for(let a of ne(n,t.x,t.z,.9)){let o=n.def.brushes[a],s=Oe(o,t,r,.5);s!==void 0&&o.min[1]<t.y+.5&&o.max[1]>t.y+1.8&&(i=Math.min(i??1/0,Math.max(0,s-e)))}return i},Ae=(e,t)=>{let[n,r]=ce(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=fe[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=De(e,a);for(let n of ne(t,e.x,e.z,.6000000000000001)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(Oe(r,e,a,.2)===void 0||s<1.2||s>2.4||r.min[1]>o-.25||i&&i.top>=o)continue;let u=l>0?r.min[c]:r.max[c],d=u-l*.43000000000000005,f=u+l*.2,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Ee(t,p,m,Math.min(e.y,o-2)+ae,o+1.8)&&Ee(t,h,g,o+ae,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},je=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=De(e,e.wall);return ne(t,e.x,e.z,0).some(s=>{let c=t.def.brushes[s],l=i>0?a-c.min[n]:c.max[n]-a;return le(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},Me=(e,n)=>{if(e.vy>=0)return!1;let[r]=we(e,n,t),i=6*H;return e.y-r<=-e.vy*i+10*i*i},G=(e,t)=>{e.mode=t,e.t=0},Ne=(e,t)=>{let n=W(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},Pe=(t,n,r,i)=>{let[a,o]=[r.wx,r.wz];for(let r of ne(n,t.x,t.z,e+oe)){let e=n.def.brushes[r],[s,c]=Se(e,t.x,t.z),l=W(s,c);if(l>0&&l<=.4+oe&&xe(e,t.y,i)){let e=(-a*s-o*c)/l;e>0&&(a+=e*s/l,o+=e*c/l)}}return[a,o]},Fe=(e,t,n)=>{let r=W(t[0],t[1]);if(r<ie){let t=W(e.vx,e.vz),n=t?Math.max(0,t-45*H)/t:0;e.vx*=n,e.vz*=n;return}let[i,a]=[t[0]/r,t[1]/r],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a],l=W(s,c);if(l){let e=Math.max(0,l-45*H)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*H):Math.max(n,o-12*H),e.vx=s+o*i,e.vz=c+o*a},Ie=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*H,e.z+=e.vz*H;let[o,s]=Ce(e,t,n),c=W(o,s);if(c){let t=(e.vx*o+e.vz*s)/c;t<0&&(e.vx-=t*o/c,e.vz-=t*s/c)}let[l,u]=we(e,t,n),d=e.vy-r*20*H;if(e.y+=(e.vy+d)/2*H,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+ae:e.y<l){if(e.y=l,e.vy<=0){let t=-e.vy;return e.vy=0,t}}else if(i&&e.vy<=0&&l>=a-.5)return e.y=l,e.vy=0,0;return-1},Le=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=v.JUMP},Re=(e,n,r)=>{let[i,a]=fe[e.wall],o=t=>{G(e,t),e.edge=0};if(r.keys&(h.BACK|h.CROUCH))o(g.AIR),e.coyote=0;else if(r.jump&&r.fx*i+r.fz*a<0)o(g.AIR),e.vx=-i*4,e.vz=-a*4,Le(e,6);else if(r.jump||r.fwd&&e.t>=6)G(e,g.CLIMB);else if(e.t>=30)o(g.AIR),e.coyote=0;else{let r=Math.max(e.edge-2,we(e,n,t)[0]);e.y+=de(r-e.y,-8*H,8*H)}},ze=(e,t)=>{let[n,r]=fe[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*H):(e.x+=n*s*H,e.z+=r*s*H),e.y>=e.edge&&je(e,t)?(G(e,g.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=_.NONE,e.coyote=6,e.ev|=v.CLIMB):e.t>=40&&(G(e,e.y>=e.edge?g.GROUND:g.AIR),e.edge=0,e.wall=_.NONE)},Be=(e,t,n)=>{let[r,i]=fe[e.wall],a=e.vx*r+e.vz*i,[o,s]=[e.vx-a*r,e.vz-a*i],c=W(o,s);if(n.jump)G(e,g.AIR),e.vx=o-r*5,e.vz=s-i*5,Le(e,6.5),e.jumps=1,e.dashes=1,e.ev|=v.WALLRUN_END;else{let a=ke(e,t,e.wall);if(a===void 0||!n.fwd||c<3.5||e.t>=60){G(e,g.AIR),e.ev|=v.WALLRUN_END;return}let l=Math.max(0,c-1.5*H)/c;e.vx=o*l,e.vz=s*l;let u=Math.min(a,4*H);e.x+=r*u,e.z+=i*u}},Ve=(e,t,n)=>{if(!n.fwd)return;let r=W(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[i,a]=fe[n],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a];if(n!==e.wall&&o<=.75*r&&o>=-.2*r&&ke(e,t,n)!==void 0){let t=W(s,c),i=Math.max(t,.9*r)/t;G(e,g.WALLRUN),e.wall=n,[e.vx,e.vz]=[s*i,c*i],e.vy=de(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=v.WALLRUN_START;return}}},He=(e,t)=>{G(e,g.HANG),e.wall=t.side,e.edge=le(t.top),t.side<=_.WEST?e.x=t.hang:e.z=t.hang,e.vx=e.vy=e.vz=0,e.jumps=1,e.dashes=1,e.coyote=0,e.buffer=0,e.ev|=v.GRAB},Ue=(e,t,n)=>{let r=e.mode===g.GROUND;if(n.dash&&e.dash===0&&(r||(e.mode===g.AIR||e.mode===g.WALLRUN)&&e.dashes>0)){let[t,i]=n.wx||n.wz?[n.wx,n.wz]:[n.fx,n.fz];r||(e.dashes--,e.vy=0,e.mode===g.WALLRUN&&(G(e,g.AIR),e.ev|=v.WALLRUN_END)),e.vx=t*16,e.vz=i*16,e.dash=60,e.ev|=v.DASH}let i=e.dash>50;e.mode===g.WALLRUN&&Be(e,t,n),ge(e.mode)&&We(e,t,n,i),e.mode===g.AIR&&Ge(e,t,n,i);let o=i&&e.vy<=0?0:e.mode===g.WALLRUN?.15:1,s=e.mode,c=Ie(e,t,_e(e),o,ge(s));if(c>=0){if(!ge(e.mode)){if(e.ev|=v.LAND|(e.mode===g.WALLRUN?v.WALLRUN_END:0),e.fall=c,e.jumps=1,e.dashes=1,e.wall=_.NONE,n.keys&h.CROUCH){let t=W(e.vx,e.vz)>=a;G(e,t?g.SLIDE:g.CROUCH),e.ev|=t?v.SLIDE_START:0}else G(e,g.GROUND)}e.coyote=6}else ge(e.mode)&&(e.ev|=e.mode===g.SLIDE?v.SLIDE_END:0,G(e,g.AIR));if(e.mode===g.AIR){let r=Ae(e,t);r?He(e,r):Ve(e,t,n)}},We=(e,n,r,o)=>{let s=(r.keys&h.CROUCH)!==0;if(e.buffer>0&&(e.mode===g.GROUND||Te(e,n))){e.ev|=e.mode===g.SLIDE?v.SLIDE_END:0,G(e,g.AIR),Le(e,7);return}let l=W(e.vx,e.vz);if(e.mode===g.GROUND&&s){let t=l>=a;G(e,t?g.SLIDE:g.CROUCH),e.ev|=t?v.SLIDE_START:0}else e.mode===g.SLIDE&&(e.t>=60||l<4.5||r.stumble)?(e.ev|=v.SLIDE_END,G(e,!s&&Te(e,n)?g.GROUND:g.CROUCH)):e.mode===g.SLIDE&&!s&&Te(e,n)?(e.ev|=v.SLIDE_END,G(e,g.GROUND)):e.mode===g.CROUCH&&!s&&Te(e,n)&&G(e,g.GROUND);if(!o){if(r.stumble){if(l>2.5){let t=Math.max(c,l-12*H)/l;e.vx*=t,e.vz*=t}else Fe(e,Pe(e,n,r,_e(e)),c)}else if(e.mode===g.SLIDE){let t=Math.max(0,l-4*H)/l;e.vx*=t,e.vz*=t}else if(e.mode===g.CROUCH)Fe(e,Pe(e,n,r,i),3);else{let i=(r.keys&h.SPRINT)!==0&&r.fwd;Fe(e,Pe(e,n,r,t),i?9:6)}}},Ge=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?Le(e,7):e.jumps>0&&!Me(e,t)&&(e.jumps--,Le(e,6),e.ev=e.ev&~v.JUMP|v.DOUBLE)),r||!n.wx&&!n.wz)return;let i=W(e.vx,e.vz);e.vx+=n.wx*14*H,e.vz+=n.wz*14*H,Ne(e,Math.max(i,6))},Ke=(e,t,r,i=0)=>{e.yaw=se(t.yaw),e.pitch=Math.max(-1.55,Math.min(n,t.pitch));let a=(t.keys&h.FORWARD?1:0)-(t.keys&h.BACK?1:0),o=(t.keys&h.RIGHT?1:0)-(t.keys&h.LEFT?1:0),s=W(a,o)||1,[c,l]=ce(e.yaw),u=n=>(t.keys&n)!==0&&(e.held&n)===0,d=e.stun>0,f={keys:t.keys,stumble:d,jump:!d&&u(h.JUMP),dash:!d&&u(h.DASH),fwd:a>0,wx:(c*a-l*o)/s,wz:(l*a+c*o)/s,fx:c,fz:l},p=e.mode;e.ev=0,e.fall=0,f.jump&&(e.buffer=7),d&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&Ne(e,10)),e.mode===g.HANG&&Re(e,r,f),e.mode===g.CLIMB?ze(e,r):e.mode!==g.HANG&&Ue(e,r,f),e.y<r.def.floor&&he(e,r,i),e.t=e.mode===p?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===g.AIR&&p===g.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=t.keys&(h.JUMP|h.DASH),e.ground=ge(e.mode),e.x=le(e.x),e.y=le(e.y),e.z=le(e.z),e.vx=le(e.vx),e.vy=le(e.vy),e.vz=le(e.vz),e.edge=le(e.edge)},qe=127,Je=16,Ye=65536/(2*Math.PI),Xe=e=>Math.round(e*Ye)&65535,Ze=e=>Math.max(-32768,Math.min(32767,Math.round(e))),Qe=e=>Ze(e*1e4),$e=e=>e/1e4,et=e=>e/Ye,tt=(e=0)=>Math.round(e*256)&16777215,nt=e=>({...e,yaw:et(Xe(e.yaw)),pitch:$e(Qe(e.pitch)),...e.view!==void 0&&{view:tt(e.view)/256}}),rt=e=>{let t=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(12));t.setUint8(0,1),t.setUint16(1,e.seq&65535),t.setUint16(3,e.keys&511),t.setUint16(5,Xe(e.yaw)),t.setInt16(7,Qe(e.pitch));let n=tt(e.view);return t.setUint16(9,n>>8),t.setUint8(11,n&255),t.buffer},it=e=>e===m.CARRIED?2:e===m.DROPPED?8:1,at=e=>{if(e.byteLength<4)return null;let t=new DataView(e),n=t.getUint8(3),r=4+45*n;if(t.getUint8(0)!==2||e.byteLength<r+8+2)return null;let i=[];for(let e=0;e<n;e++){let n=4+e*45,r=t.getUint8(n+35),a=t.getUint8(n+38),[o,s]=[t.getUint8(n+37),t.getUint8(n+39)],c=r&7,l=t.getUint8(n+40)<<16|t.getUint16(n+41);i.push({id:t.getUint8(n),x:t.getFloat32(n+1),y:t.getFloat32(n+5),z:t.getFloat32(n+9),vx:t.getFloat32(n+13),vy:t.getFloat32(n+17),vz:t.getFloat32(n+21),edge:t.getFloat32(n+25),yaw:et(t.getUint16(n+29)),pitch:$e(t.getInt16(n+31)),ack:t.getUint16(n+33),ground:c===g.GROUND||c===g.SLIDE||c===g.CROUCH,mode:c,wall:r>>3&7,jumps:r>>6&1,dashes:r>>7,t:t.getUint8(n+36),dash:o&63,stun:s&63,by:o>>6<<2|s>>6,coyote:a&7,buffer:a>>3&7,held:(a&64?h.JUMP:0)|(a&128?h.DASH:0),ev:0,fall:0,hp:l&7,cool:l>>3&7,ammo:(l>>6&127)===qe?-1:l>>6&127,down:l>>13&127,rack:(l>>20&1)==1,shots:t.getUint8(n+43),hits:t.getUint8(n+44)})}let a=t.getUint16(r+2),o=r+8,s=[];for(let n=0;n<2;n++){let n=o<e.byteLength?t.getUint8(o):-1;if(n<0||n>m.DROPPED||o+it(n)>e.byteLength)return null;let r={state:n,by:0,x:0,y:0,z:0,left:0};n===m.CARRIED?r.by=t.getUint8(o+1):n===m.DROPPED&&([r.x,r.y,r.z]=[1,3,5].map(e=>t.getInt16(o+e)/Je),r.left=t.getUint8(o+7)),s.push(r),o+=it(n)}return o===e.byteLength?{tick:t.getUint16(1),players:i,score:[t.getUint8(r),t.getUint8(r+1)],clock:a&32767,over:!!(a&32768),flags:s,packs:t.getUint32(r+4)}:null},ot=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},st=44100,ct=([e,t,n,r,i,a,o,s,c,l,u],d)=>{let f=new Float32Array(Math.ceil((r+i+a)*st)),p=0,m=0,h=0,g=()=>{d=d+1831565813|0;let e=Math.imul(d^d>>>15,1|d);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/2**31-1};for(let d=0;d<f.length;d++){let _=d/st;p+=t*2**(n*_)*(_>c?l:1)*(1+o*Math.sin(_*44))/st,p>=1&&(p%=1,h=g());let v=e==3?h:e==2?Math.sin(p*2*Math.PI):e?1-2*p:p<.5?1:-1;m+=(v-m)*s;let y=_<r?_/r:_<r+i?1:((r+i+a-_)/a)**2;f[d]=m*y*u}return f},K={STEP:0,WALLSTEP:1,JUMP:2,DOUBLE:3,DASH:4,LAND:5,GRAB:6,SCUFF:7,WIND:8,SCRAPE:9,TAKE:10,DROP:11,RETURN:12,CAPTURE:13,TACKLE:14,GRUNT:15,LASER:16,HIT:17,HURT:18,DOWN:19,GUN:20,PACK:21,DRY:22},lt=[[[2,130,-3,.001,.005,.06,0,1,0,1,.7],[3,8e3,-1,.001,0,.035,0,.4,0,1,.45]],[[3,12e3,0,.001,0,.03,0,.5,0,1,.4],[2,190,-3,.001,0,.04,0,1,0,1,.3]],[[3,14e3,0,.015,.02,.09,.3,.18,0,1,.5],[2,70,-2,.003,0,.07,0,1,0,1,.3]],[[3,4e3,3.5,.03,.03,.2,0,.25,0,1,.5],[2,350,1.2,.03,.02,.18,.02,1,0,1,.12]],[[3,14e3,-2.5,.008,.07,.2,.25,.3,0,1,.8],[3,3500,.5,.01,.06,.2,0,.12,0,1,.5]],[[2,70,-2.5,.001,.01,.2,0,1,0,1,.9],[3,7e3,-1,.001,0,.09,0,.25,0,1,.5]],[[3,6e3,-1,.001,0,.05,0,.5,0,1,.7],[2,160,-4,.001,0,.07,0,1,0,1,.5]],[[3,5e3,0,.01,.04,.14,.5,.3,0,1,.5],[3,2500,0,.03,0,.1,.4,.2,0,1,.3,.08]],[[3,2e4,0,.001,2.1,.001,.25,.06,0,1,1.2],[3,2e4,0,.001,2.1,.001,.35,.3,0,1,.3]],[[3,9e3,0,.001,2.1,.001,.5,.4,0,1,.5],[3,3e3,0,.001,2.1,.001,.4,.2,0,1,.5]],[[0,392,0,.003,.05,.08,0,.35,.07,1.5,.5],[2,784,0,.003,.03,.1,.01,1,0,1,.3,.05]],[[1,330,-2.2,.003,.04,.22,.04,.25,0,1,.45],[3,2500,-1,.001,0,.12,0,.3,0,1,.4]],[[2,659,0,.003,.06,.25,.015,1,.09,1.5,.5],[2,1318,0,.003,.03,.2,0,1,0,1,.2,.09]],[[0,523,0,.004,.07,.1,0,.3,0,1,.4],[0,659,0,.004,.07,.1,0,.3,0,1,.4,.11],[0,784,0,.004,.07,.1,0,.3,0,1,.4,.22],[0,1047,0,.004,.2,.35,.008,.3,0,1,.5,.33],[2,262,0,.004,.25,.3,0,1,0,1,.35,.33]],[[2,120,-3,.001,.01,.24,0,1,0,1,1],[3,5e3,-1.5,.001,0,.09,0,.35,0,1,.7],[3,2200,0,.01,.03,.16,.3,.15,0,1,.4,.03]],[[1,170,-.9,.012,.05,.17,.06,.2,0,1,.5],[3,3e3,0,.01,.04,.14,.4,.12,0,1,.5]],[[1,3600,-10,.001,.01,.09,0,.5,0,1,.4],[0,1900,-8,.001,0,.06,0,.3,0,1,.25],[3,9e3,0,.001,0,.03,0,.4,0,1,.25]],[[2,1700,0,.001,0,.13,0,1,0,1,.6],[2,4700,0,.001,0,.05,0,1,0,1,.3],[2,1790,0,.001,0,.09,0,1,0,1,.3]],[[2,110,-2.5,.002,.01,.2,0,1,0,1,.9],[3,2500,0,.02,.03,.17,.3,.12,0,1,.5,.04]],[[2,90,-1.2,.002,.04,.45,0,1,0,1,.9],[1,180,-1.5,.01,.06,.4,.05,.2,0,1,.45],[3,3e3,0,.02,0,.35,.3,.1,0,1,.4,.12]],[[3,5e3,0,.001,0,.02,0,.5,0,1,.5],[0,260,1.5,.005,.06,.12,0,.25,0,1,.4,.02],[2,1040,.5,.003,.03,.18,.01,1,0,1,.25,.1]],[[2,523,0,.003,.03,.1,0,1,0,1,.4],[2,659,0,.003,.03,.1,0,1,0,1,.4,.07],[2,880,0,.003,.05,.2,.01,1,0,1,.45,.14]],[[0,190,-3,.001,0,.04,0,.6,0,1,.6],[3,6e3,0,.001,0,.02,0,.5,0,1,.5]]],ut=[K.WIND,K.SCRAPE],dt=(e,t=lt)=>{let n=t[e].map((t,n)=>[ct(t,e*9+n),Math.round((t[11]??0)*st)]);return Float32Array.from({length:Math.max(...n.map(([e,t])=>t+e.length))},(e,t)=>Math.tanh(n.reduce((e,[n,r])=>e+(n[t-r]??0),0)))},ft=(e,t=st/10)=>{let n=e.length-t;return Float32Array.from({length:n},(r,i)=>i<t?e[i]*Math.sqrt(i/t)+e[n+i]*Math.sqrt(1-i/t):e[i])},pt=st*60/108,mt=pt/4,ht=4,gt=[2,150,-6,.002,0,.25,0,1,0,1,1],_t=[3,9e3,0,.002,0,.15,0,.5,0,1,.5],vt=[3,3e4,0,.001,0,.04,0,.7,0,1,.15],yt=()=>{let e=new Float32Array(pt*4*ht),t={},n=(n,r)=>(t[String(r)]??=ct(r,1)).forEach((t,r)=>e[(n*mt+r)%e.length]+=t),r=e=>55*2**(e/12),i=[0,0,-4,-5],a=[0,0,12,0,0,7,12,7];for(let e=0;e<64;e++){let t=e%16;if(`x.......x.x.....`[t]==`x`&&n(e,gt),`....x.......x...`[t]==`x`&&n(e,_t),t%2==0){n(e,vt);let o=i[e>>4]+a[t>>1];n(e,[1,r(o),0,.005,.08,.18,0,.15,0,1,.6])}}[15,12,10,19,17,15].forEach((e,t)=>n([18,24,28,50,54,60][t],[2,r(e+24),0,.02,.1,.6,.01,1,0,1,.5]));let o=e.reduce((e,t)=>Math.max(e,Math.abs(t)),0);return e.map(e=>e/o*.35)},bt=40,xt=24,St=.5,Ct=`tiny-fps:muted`,wt=()=>{let e=!1;return{unlock:()=>{},listen:()=>{},play:()=>{},loop:()=>({set:()=>{}}),mute:t=>{e=t},get muted(){return e},destroy:()=>{}}},Tt=(e=lt)=>{let t;try{t=new AudioContext}catch{return wt()}let n=(e,n=1)=>{let r=t.createGain();return r.gain.value=n,r.connect(e),r},r=n(t.destination),i=n(r,St),a=[],o=!1,s=/* @__PURE__ */ new Set,c=[0,0,0],l=0,u=!1,d=e=>{let n=t.createBuffer(1,e.length,st);return n.getChannelData(0).set(e),n},f=e=>{let n=t.createBufferSource();return n.buffer=e,n};return{unlock(){if(t.resume().catch(()=>{}),!o){o=!0,e.forEach((t,n)=>{let r=dt(n,e);a[n]=d(ut.includes(n)?ft(r):r)});let t=f(d(yt()));t.loop=!0,t.connect(i),t.start()}},listen(e,t){[c,l]=[e,t]},play(e,i,o=1,u=1){let d=0,p=o;if(i){let[e,t,n]=i.map((e,t)=>e-c[t]),r=Math.hypot(e,t,n);p=Math.max(0,1-r/bt)**2*o,d=(e*Math.cos(l)-n*Math.sin(l))/Math.max(r,1)}let m=a[e];if(!m||!p)return;if(s.size>=xt){let e=[...s].reduce((e,t)=>t.vol<e.vol?t:e);if(e.vol>=p)return;e.src.stop(),s.delete(e)}let h=f(m);h.playbackRate.value=u;let g=t.createStereoPanner();g.pan.value=d,h.connect(g).connect(n(r,p));let _={vol:p,src:h};s.add(_),h.onended=()=>s.delete(_),h.start()},loop(e){let i,o;return{set(s,c){!i&&a[e]&&(i=f(a[e]),i.loop=!0,i.connect(o=n(r,0)),i.start()),i&&(o.gain.setTargetAtTime(s,t.currentTime,.08),i.playbackRate.setTargetAtTime(c,t.currentTime,.08))}}},mute(e){u=e,r.gain.setTargetAtTime(+!e,t.currentTime,.05)},get muted(){return u},destroy:()=>void t.close().catch(()=>{})}},Et=()=>{try{return localStorage.getItem(Ct)==`1`}catch{return!1}},Dt=e=>{e.mute(!e.muted);try{localStorage.setItem(Ct,e.muted?`1`:`0`)}catch{}return e.muted},q=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Ot=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],kt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],At=(e,t,n)=>[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n],jt=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Mt=(e,t,n=0)=>{let[r,i,a,o,s,c]=[e,t,n].flatMap(e=>[Math.sin(e),Math.cos(e)]),l=[i,0,-r],u=[r*a,o,i*a];return[l.map((e,t)=>e*c-u[t]*s),u.map((e,t)=>e*c+l[t]*s),[-r*o,a,-i*o]]},Nt=(e,t,n=[0,0,0])=>{let r=[],i=e.filter((t,n)=>!n||Math.hypot(t[0]-e[n-1][0],t[1]-e[n-1][1])>1e-9),a=i.slice(1).map(([e,t],n)=>{let[r,a]=i[n],o=Math.hypot(e-r,t-a);return[(t-a)/o,-(e-r)/o]}),o=i.map(([e],t)=>{let[n,r]=[0,1].map(e=>(a[t-1]?.[e]??0)+(a[t]?.[e]??0)),i=Math.hypot(n,r);return e?[n/i,r/i]:[0,Math.sign(r)]}),s=(e,a)=>{let[s,c]=i[a],[l,u]=[Math.cos(e*U/t),Math.sin(e*U/t)];r.push(n[0]+s*l,n[1]+s*u,n[2]-c,o[a][0]*l,o[a][0]*u,-o[a][1])};for(let e=1;e<i.length;e++)for(let n=0;n<t;n++)[...i[e-1][0]?[[n,e-1],[n+1,e-1],[n+1,e]]:[],...i[e][0]?[[n,e-1],[n+1,e],[n,e]]:[]].forEach(([e,t])=>s(e,t));return r},Pt=(e,t,n,[r,i],a)=>{let o=(e,t,n,r)=>Array.from({length:t},(i,a)=>{let o=a*U/t/4;return[e*Math.sin(o),n-r*e*Math.cos(o)]});return Nt([...r?o(t[0],r,0,1):[[0,0]],...t.map((n,r)=>[n,e*r/(t.length-1)]),...i?o(t[t.length-1],i,e,-1).reverse():[[0,e]]],n,a)},Ft=(e,[t,n,r])=>Array.from({length:e.length*(10/6)},(i,a)=>{let[o,s]=[Math.floor(a/10),a%10];return s<6?e[o*6+s]:[t,n,-1,r][s-6]}),It=[[5,1],[7,2],[10,3]],Lt=/* @__PURE__ */ new Map,Rt=(e,t,n,r=[1,1])=>{let[i,a]=It[e];!e&&n.length>3&&(n=[n[0],n[n.length>>1],n[n.length-1]]);let o=`${e} ${t} ${n} ${r}`,s=Lt.get(o);return s||(s=Ft(Pt(t,n,i,r.map(e=>Math.ceil(a*e))),[1,1,1]),Lt.set(o,s)),s},zt=(e,t,n,[r,i,a],o,s,c=[1,1,1])=>{let[l,u,d]=typeof s==`number`?[s,s,s]:s,f=l==u&&u==d,[p,m,h,g,_,v,y,b,x]=[...r,...i,...a],S=n[0]+p*o[0]+g*o[1]+y*o[2],C=n[1]+m*o[0]+_*o[1]+b*o[2],w=n[2]+h*o[0]+v*o[1]+x*o[2];for(let n=0;n<t.length;n+=10){let[r,i,a]=[t[n]*l,t[n+1]*u,t[n+2]*d],[o,s,T]=[t[n+3],t[n+4],t[n+5]];if(!f){[o,s,T]=[o/l,s/u,T/d];let e=Math.sqrt(o*o+s*s+T*T)||1;[o,s,T]=[o/e,s/e,T/e]}e.push(S+p*r+g*i-y*a,C+m*r+_*i-b*a,w+h*r+v*i-x*a,p*o+g*s-y*T,m*o+_*s-b*T,h*o+v*s-x*T,t[n+6]*c[0],t[n+7]*c[1],t[n+8],t[n+9]*c[2])}},Bt=(e,t)=>{let n=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],r=t.map((t,r)=>t-e[r]*n),i=Math.hypot(...r)||1,[a,o,s]=r.map(e=>e/i);return[[a,o,s],[o*e[2]-s*e[1],s*e[0]-a*e[2],a*e[1]-o*e[0]],e]},Vt=(e,t,n,r,i,a,o=1,s)=>{let c=[r[0]-n[0],r[1]-n[1],r[2]-n[2]],l=Math.hypot(...c)||1,[u,d]=typeof o==`number`?[o,o]:o;zt(e,t,n,Bt([c[0]/l,c[1]/l,c[2]/l],i),[0,0,0],[u,d,l/a],s)},Ht=2.4,Ut=[1,.62],Wt=8,Gt=28,Kt=2.2,qt=.04,Jt=.045,Yt=e=>{let t=parseInt(u[e].slice(1),16);return[t>>16,t>>8&255,t&255].map(e=>e/255)},Xt=(e,t,n)=>e.flatMap((e,r)=>{if(e.state===m.DROPPED)return[{team:r,at:[e.x,e.y,e.z],dropped:!0}];if(e.state===m.CARRIED){let t=n(e.by);return t?[{team:r,at:[t.x,t.y,t.z],by:{yaw:t.yaw,vx:t.vx,vz:t.vz}}]:[]}return[{team:r,at:t[r]}]}),Zt=[[1,0,0],[0,1,0],[0,0,1]],Qt=(e,t,n)=>{for(let r=t;r<e.length;r+=10)e[r+6]*=n,e[r+7]*=n,e[r+9]*=n,e[r+8]=-2},$t=(e,t,n,r,[i,a,o])=>{let[s,c,l]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],[u,d,f]=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],p=[c*f-l*d,l*u-s*f,s*d-c*u],m=Math.hypot(...p)||1;for(let s of[t,n,r])e.push(...s,p[0]/m,p[1]/m,p[2]/m,i,a,-1,o)},en=(e,t,n,r,i)=>{for(let a=0;a<Gt;a++){let[o,s]=[a,a+1].map(e=>e*2*Math.PI/Gt),c=(e,n)=>[t[0]+e*Math.cos(n),t[1],t[2]+e*Math.sin(n)];$t(e,c(n,o),c(r,s),c(r,o),i),$t(e,c(n,o),c(n,s),c(r,s),i)}},tn=(e,t,n,r)=>{for(let i=0;i<Gt;i++){let[a,o]=[i,i+1].map(e=>e*2*Math.PI/Gt);$t(e,t,[t[0]+n*Math.cos(o),t[1],t[2]+n*Math.sin(o)],[t[0]+n*Math.cos(a),t[1],t[2]+n*Math.sin(a)],r)}},nn=(e,t,n,r)=>{tn(e,[t[0],t[1]+qt,t[2]],d,n.map(e=>e*.4));let i=e.length;en(e,[t[0],t[1]+Jt,t[2]],d-.16,d,n),Qt(e,i,Kt*(.75+.25*Math.sin(r*3)))},rn=(e,t,n,[r,i],a,o,s)=>{let c=[-n[2],0,n[0]],l=(e,s)=>{let l=a*e*Math.sin(o*7-e*5),u=i*s*(1-e);return[t[0]+n[0]*r*e+c[0]*l,t[1]-u+.12*r*e*Math.sin(o*5-e*4)*a,t[2]+n[2]*r*e+c[2]*l]};for(let t=0;t<Wt;t++){let[n,r]=[t/Wt,(t+1)/Wt],[i,a,o,c]=[l(n,0),l(r,0),l(r,1),l(n,1)],u=[(a[1]-i[1])*(c[2]-i[2])-(a[2]-i[2])*(c[1]-i[1]),(a[2]-i[2])*(c[0]-i[0])-(a[0]-i[0])*(c[2]-i[2]),(a[0]-i[0])*(c[1]-i[1])-(a[1]-i[1])*(c[0]-i[0])],d=Math.hypot(...u)||1,f=(e,t)=>[e[0]+u[0]/d*.004*t,e[1]+u[1]/d*.004*t,e[2]+u[2]/d*.004*t];for(let t of[1,-1]){let n=[i,a,o,c].map(e=>f(e,t)),[r,l,u,d]=t>0?n:[n[0],n[3],n[2],n[1]];$t(e,r,l,u,s),$t(e,r,u,d,s)}}},an=(e,t,n,r)=>{Vt(e,Rt(1,1,[1,1],[0,0]),t,n,[.6,0,.8],1,.045,[.82,.84,.9]);let i=e.length;zt(e,Rt(1,0,[1,1]),n,Zt,[0,0,0],.09,r),Qt(e,i,Kt)},on=(e,t,n,r)=>{let[i,a,o]=t.at,s=r+t.team*1.7;if(t.by){let{yaw:r,vx:c,vz:l}=t.by,u=-Math.sin(r),d=-Math.cos(r),f=Math.hypot(c,l),p=[i-u*.28,a+.55,o-d*.28],m=[i-u*.38,a+.55+Ht-.2,o-d*.38],[h,g]=f>1?[-c/f,-l/f]:[-u,-d];an(e,p,m,n);let _=Math.min(1,f/8);rn(e,m,[h,0,g],[Ut[0]*(.7+.5*_),Ut[1]],.1+.16*_,s,n);return}if(t.dropped){let t=i*12.9898+o*78.233,[c,l]=[Math.cos(t),Math.sin(t)],u=[i+c*2.3,a+.6,o+l*2.3];an(e,[i,a+.06,o],u,n),rn(e,u,[c,0,l],[Ut[0]*.8,Ut[1]*.8],.04,s,n);let f=e.length;en(e,[i,a+Jt,o],d-.1,d,n),Qt(e,f,Kt*(.5+.5*Math.abs(Math.sin(r*5))));return}let c=[i,a+Ht,o];an(e,[i,a,o],c,n);let l=.6+t.team*Math.PI;rn(e,c,[Math.cos(l),0,Math.sin(l)],Ut,.18,s,n)},sn={SPOT:0,POINT:1},cn=9,ln=6,un=e=>{let{ctf:t,t:n}=e;if(!t)return[];let r=([e,t,n],r,i,a)=>({kind:sn.POINT,p:[e,t,n],d:[0,-1,0],cone:0,range:i,color:Yt(r).map(e=>e*a),shadow:!1});return[...t.bases.map(([e,t,i],a)=>r([e,t+1.2,i],a,cn,1.1+.3*Math.sin(n*3))),...t.flags.filter(e=>e.dropped).map(e=>r([e.at[0],e.at[1]+.8,e.at[2]],e.team,ln,.9))]},dn=.08,fn=.06,pn=.22,mn=7,hn=[[.022,[.4,.15,1.3],0],[.007,[.7,1.7,2.2],.02]],gn=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],_n=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],vn=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},yn=(e,t,[n,r,i])=>e.push(...t,0,1,0,n,r,-2,i),bn=(e,t,n,r,i,a,o)=>{let s=gn(n,t),c=_n(s,gn(t,a));Math.hypot(...c)<1e-6*Math.hypot(...s)&&(c=_n(s,[0,1,0])),c=vn(c);let[l,u,d,f]=[[t,1],[t,-1],[n,-1],[n,1]].map(([e,t])=>{let n=vn(gn(a,e)),i=r*Math.min(Math.max(Math.hypot(...gn(a,e))/5,1),2.5);return e.map((e,r)=>e+c[r]*i*t+n[r]*o)});for(let t of[l,u,d,l,d,f])yn(e,t,i)},xn=()=>{let e=[],t=[],n=7,r=()=>(n=n*16807%2147483647)/2147483647*2-1;return{mount(t){e.forEach(e=>e.own&&(e.a=t))},shoot(n,i,a,o=!1){if(e.push({a:n,b:i,age:0,hit:a,own:o}),e=e.slice(-16),a){let e=vn(gn(n,i));for(let n=0;n<mn;n++)t.push({p:i,v:[0,1,2].map(t=>e[t]*3+r()*3+(t==1?2:0)),age:0});t=t.slice(-112)}},update(n){for(let r of[...e,...t])r.age+=n;e=e.filter(e=>e.age<dn),t=t.filter(e=>e.age<pn);for(let e of t)e.v[1]-=9*n,e.p=e.p.map((t,r)=>t+e.v[r]*n)},draw(n,r){for(let{a:t,b:i,age:a}of e){let e=1-a/dn;hn.forEach(([a,o,s])=>bn(n,t,i,a*e**.7,o.map(t=>t*(.6+.4*e)),r,s))}for(let{p:e,age:i}of t){let t=1-i/pn,a=vn(_n(gn(e,r),[0,1,0])),o=vn(_n(a,gn(e,r))),[s,c]=[.022*t,.022*t],l=(t,n)=>[e[0]+a[0]*t+o[0]*n,e[1]+a[1]*t+o[1]*n,e[2]+a[2]*t+o[2]*n];for(let e of[l(-s,0),l(0,c),l(s,0),l(-s,0),l(s,0),l(0,-c)])yn(n,e,[1.4*t+.4,2.2*t+.3,3])}},lights(){let t=(e,t,n,r)=>({kind:sn.POINT,p:e,d:[0,-1,0],cone:0,range:t,color:r.map(e=>e*n),shadow:!1});return e.filter(e=>e.age<fn).slice(-3).flatMap(e=>{let n=1-e.age/fn;return[t(e.a,6,1.3*n,[.35,.8,1.5]),...e.hit?[t(e.b,3.5,.9*n,[.3,.7,1.3])]:[]]})},get count(){return e.length}}},Sn=(e,t)=>{if(!e)return[];if(e.over||t.over)return e.over&&!t.over?[{kind:`start`}]:[];let n=[];for(let r of[0,1])t.score[r]>e.score[r]&&n.push({kind:`capture`,team:r});let r=n.length>0;t.flags.forEach((t,i)=>{let a=e.flags[i];t.state===m.CARRIED&&(a.state!==m.CARRIED||a.by!==t.by)?n.push({kind:`take`,flag:i,by:t.by}):t.state===m.DROPPED&&a.state===m.CARRIED?n.push({kind:`drop`,flag:i}):t.state===m.HOME&&(a.state===m.DROPPED||a.state===m.CARRIED&&!r)&&n.push({kind:`return`,flag:i})});for(let r of t.players)r.stun>(e.players.find(e=>e.id===r.id)?.stun??1/0)&&n.push({kind:`tackle`,who:r.id,by:r.by,at:[r.x,r.y+1,r.z]});return n},Cn=(e,t,n)=>{let r=e=>l[e].toLowerCase();switch(e.kind){case`take`:{let i=1-e.flag;return{team:i,text:e.flag===t.team?`${l[i]} took your flag`:e.by===t.id?`You took the ${r(e.flag)} flag`:`${n(e.by)} took the ${r(e.flag)} flag`}}case`drop`:return{team:e.flag,text:e.flag===t.team?`Your flag was dropped`:`${l[e.flag]} flag dropped`};case`return`:return{team:e.flag,text:e.flag===t.team?`Your flag returned`:`${l[e.flag]} flag returned`};case`capture`:return{team:e.team,text:`${l[e.team]} scored`};case`tackle`:return e.by===t.id?{team:t.team,text:`Tackled ${n(e.who)}!`}:void 0;default:return{text:`New match`}}},wn=(e,t)=>{let{team:n}=t;switch(e.kind){case`take`:return[{id:K.TAKE,rate:e.flag===n?.8:1}];case`drop`:return[{id:K.DROP,rate:e.flag===n?1:.85}];case`return`:return[{id:K.RETURN,rate:e.flag===n?1:.85}];case`capture`:return[{id:K.CAPTURE,rate:e.team===n?1:.8}];case`tackle`:return e.who===t.id?[{id:K.TACKLE},{id:K.GRUNT}]:e.by===t.id?[{id:K.TACKLE,gain:.8,rate:1.1}]:[{id:K.TACKLE,at:e.at}];default:return[]}},J={PELVIS:0,SPINE:1,CHEST:2,NECK:3,HEAD:4,CLAVICLE_L:5,ARM_L:6,FOREARM_L:7,HAND_L:8,CLAVICLE_R:9,ARM_R:10,FOREARM_R:11,HAND_R:12,THIGH_L:13,SHIN_L:14,FOOT_L:15,TOE_L:16,THIGH_R:17,SHIN_R:18,FOOT_R:19,TOE_R:20},Tn=Object.keys(J).length,En=[-1,0,1,2,3,2,5,6,7,2,9,10,11,0,13,14,15,0,17,18,19],Dn=[[0,.98,0],[0,.12,0],[0,.2,0],[0,.22,0],[0,.1,0],[-.04,.17,0],[-.15,0,0],[-.03,-.29,0],[0,-.26,0],[.04,.17,0],[.15,0,0],[.03,-.29,0],[0,-.26,0],[-.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13],[.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13]],On=[0,0,0,1],kn=(e=[0,0,0],t=0)=>({at:e,yaw:t,hips:[0,0,0],rot:Array.from({length:Tn},()=>[...On])}),Y=([e,t,n,r],[i,a,o,s])=>[r*i+e*s+t*o-n*a,r*a-e*o+t*s+n*i,r*o+e*a-t*i+n*s,r*s-e*i-t*a-n*o],X=([e,t,n],r)=>{let i=Math.sin(r/2);return[e*i,t*i,n*i,Math.cos(r/2)]},An=(e,[t,n,r])=>{let[i,a,o,s]=e,[c,l,u]=[2*(a*r-o*n),2*(o*t-i*r),2*(i*n-a*t)];return[t+s*c+a*u-o*l,n+s*l+o*c-i*u,r+s*u+i*l-a*c]},jn=(e,t,n)=>{let r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],i=r<0?-1:1;if(r*=i,r>.9995){let r=e.map((e,r)=>e+(i*t[r]-e)*n),a=Math.hypot(...r);return r.map(e=>e/a)}let a=Math.acos(r),[o,s]=[Math.sin((1-n)*a),Math.sin(n*a)*i],c=1/Math.sin(a);return e.map((e,n)=>(e*o+t[n]*s)*c)},Mn=e=>{let t=[],n=[],r=X([0,1,0],e.yaw);for(let i=0;i<Tn;i++){let a=En[i],o=a<0?r:n[a];n[i]=Y(o,e.rot[i]);let s=An(o,i===0?Dn[0].map((t,n)=>t+e.hips[n]):Dn[i]),c=a<0?e.at:t[a];t[i]=[c[0]+s[0],c[1]+s[1],c[2]+s[2]]}return{pos:t,rot:n}},Nn=(e,t,n,r,i)=>{let a=e[t]-n,o=e[t+1]+r*a,s=Math.exp(-r*i);return e[t]=n+(a+o*i)*s,e[t+1]=(e[t+1]-r*o*i)*s,e[t]},Pn=Math.PI*2,[Z,Fn,In]=[[1,0,0],[0,1,0],[0,0,1]],[Ln,Rn,zn]=[.44,.43,.06],[Bn,Vn]=[.2915,.26],Hn=Ln+Rn,Q=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Un=e=>(e=Q(e))*e*(3-2*e),Wn=(e,t)=>Math.atan2(Math.sin(t-e),Math.cos(t-e)),Gn=e=>[-e[0],-e[1],-e[2],e[3]],Kn=(e,t)=>{let n=Math.sin(e*78.233+t*37.719)*43758.5453;return n-Math.floor(n)},qn=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Jn=(e,t,n,r=0)=>e.map((e,i)=>e*t+n[i]*r),Yn=e=>Jn(e,1/(Math.hypot(...e)||1),e),Xn=(e,t)=>Jn(e,1,t,-(e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),Zn=(e,t,n)=>{let r=Math.max(n-Math.abs(e-t),0)/n;return Math.min(e,t)-r*r*n/4},Qn=(e,t)=>{let n=[-t[0],-t[1],-t[2]],r=qn(e,n),i=[e[0]+n[1]+r[2],e[0]-n[1]-r[2],n[1]-e[0]-r[2],r[2]-e[0]-n[1]],a=i.indexOf(Math.max(...i)),[o,s,c,l]=[1+i[a],n[2]-r[1],r[0]-e[2],e[1]-n[0]],[u,d,f]=[n[0]+e[1],r[0]+e[2],r[1]+n[2]],p=[[s,c,l,o],[o,u,d,s],[u,o,f,c],[d,f,o,l]][a],m=Math.hypot(...p);return p.map(e=>e/m)},$n=(e,t,n,r=Ln,i=Rn,a=1)=>{let o=Jn(t,1,e,-1),s=Math.hypot(...o)||1e-6,c=Q(s,.2,(r+i)*.999),l=Jn(o,1/s,o),u=Yn(Xn(n,l)),d=Q((r*r+c*c-i*i)/(2*r*c),-1,1),f=Jn(l,d,u,Math.sqrt(1-d*d)),p=Yn(Jn(l,c,f,-r)),m=Jn(qn(l,u),a,l);return[Qn(m,f),Qn(m,p)]},er=e=>{let[t,n]=[Math.abs(e),e>0?.07:.13],[r,i]=[Math.sin(t),Math.cos(t)];return[(e>0?-1:1)*(n*(1-i)+zn*r),zn*(i-1)+n*r]},tr=[1.4,5,9],nr={f:[.95,1.4,1.8],s:[.88,.95,1],k:[.45,.42,.4],lat:[.11,.09,.07],lift:[.09,.3,.4],d0:[.002,.01,.01],d1:[.008,.075,.05],td:[.12,.1,-.12],to:[-.45,-.6,-.8],pr:[.07,.1,.14],po:[.06,.06,.05],pt:[.04,.1,.16],pa:[.02,.05,.06],cc:[.1,.16,.22],aa:[.35,.8,1],am:[-.05,.12,.25],em:[.3,1.4,1.75],ea:[.12,.25,.3],ab:[.1,.12,.1],sw:[.025,.012,.008],hop:[0,.02,.025]},$={AIR:0,RISE:1,DASH:2,WALL_L:3,WALL_R:4,HANG:5,CLIMB:6,SLIDE:7,STUN:8,TUCK:9,DOWN:10},rr=[[-.05,.12,0,.35,.5,.15,.7,.25,.5,.25,.5,1.15,0,0],[0,.1,0,1.2,1.5,-.35,.3,2.4,.3,2.2,.3,.35,0,0],[-.35,1.25,0,1.1,1.3,-.6,.25,-1,.3,-1,.3,.25,0,0],[],[-.02,.2,.4,.9,1.2,.6,1.3,.8,1,.3,.5,.6,0,.1],[.07,.05,0,.2,.3,.1,.2,3,.2,3,.2,.2,-.22,0],[0,.5,0,.2,.4,1.4,1.7,1,1.4,1,1.4,.15,-.1,0],[-.78,-1.1,0,1.1,1.8,1.4,.1,.5,.8,.4,.5,.8,0,0],[0,0,0,0,0,0,0,.8,1.6,.8,1.6,.2,0,0],[-.05,.9,0,1.7,2,1.7,2,.8,1.6,.8,1.6,.2,0,0],[-.5,.35,0,1.3,.3,1.1,.2,.4,.4,.2,.3,.6,0,0]],ir=rr[$.WALL_R];rr[$.WALL_L]=[ir[0],ir[1],-ir[2],ir[5],ir[6],ir[3],ir[4],ir[9],ir[10],ir[7],ir[8],ir[11],ir[12],-ir[13]];var ar=[J.PELVIS,J.SPINE,J.CHEST,J.ARM_L,J.FOREARM_L,J.ARM_R,J.FOREARM_R,J.THIGH_L,J.SHIN_L,J.FOOT_L,J.TOE_L,J.THIGH_R,J.SHIN_R,J.FOOT_R,J.TOE_R],or=e=>{let t=[],[n,r,i]=[e[1],e[2],e[11]];return t[J.PELVIS]=Y(X(In,r*.4),X(Z,-.3*n)),t[J.SPINE]=Y(X(In,r*.3),X(Z,-.35*n)),t[J.CHEST]=t[J.SPINE],t[J.ARM_L]=Y(X(In,-i),X(Z,e[7])),t[J.FOREARM_L]=X(Z,e[8]),t[J.ARM_R]=Y(X(In,i),X(Z,e[9])),t[J.FOREARM_R]=X(Z,e[10]),[J.THIGH_L,J.THIGH_R].forEach((r,i)=>{t[r]=X(Z,e[3+2*i]+.3*n),t[r+1]=X(Z,-e[4+2*i]),t[r+2]=X(Z,-.35),t[r+3]=sr}),t},sr=[0,0,0,1],cr=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],[lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br]=[0,2,4,6,8,10,12,14,16,18,20,22],xr=5,Sr=.1,Cr=()=>{let e=kn(),t={},n=Array(br+2*rr.length).fill(0),r=[0,1].map(()=>({x:0,y:0,z:0,px:0,pz:0,gy:0,lx:0,ly:0,lz:0,dl:0,tg:0,u:0,x0:0,w:0,th:0,tw:1,on:!0})),i={},a=!1,[o,s,c,l,u,d,f]=[0,0,0,0,0,0,0],[p,m,h,_,v]=[0,0,0,.6,0],[y,b,x,S]=[!1,!0,!0,-1],C=[1,1,1,0,.06,0],[w,T,E]=[0,0,[0,0,0]],[D,O,k,A]=[1,[1,0],[0,0,0,-1,0],!1],j=(e,j,M)=>{j=Q(j,0,.1),b=!a||Math.hypot(e.x-i.x,e.y-i.y,e.z-i.z)>xr;let ee=e.mode==g.GROUND||e.mode==g.CROUCH,N=e.mode==g.AIR,P=(e,t,r)=>{b?[n[e],n[e+1]]=[t,0]:Nn(n,e,t,r,j)};P(mr,e.vx,12),P(hr,e.vz,12);let[F,I]=[n[mr],n[hr]];l=Math.sqrt(F*F+I*I);let L=l>1?Math.atan2(-F,-I):e.yaw;if(b){let t=e.id;C=[1+.08*(Kn(t,0)-.5),1+.16*(Kn(t,1)-.5),1+.16*(Kn(t,2)-.5),.03*(Kn(t,3)-.5),.05+.04*Kn(t,4),Kn(t,6)],o=l>.25?Kn(t,5):Kn(t,5)<.5?.05:.55,[s,c,h,p,m,y,S]=[0,0,0,0,0,!1,-1],f=L,d=e.yaw}else N&&i.mode==g.AIR&&e.jumps<i.jumps&&e.vy>i.vy&&(h=.001),N?m=Math.min(m,e.vy):(i.mode==g.AIR&&(ee||e.mode==g.SLIDE)&&m<-3&&(p=Q(-m/12,.3)),m=0),h&&=(h+=j*(N?2.2:8),h>=1?0:h);c+=j,p*=Math.exp(-j*7);let R=cr[e.wall],z=e.mode==g.WALLRUN,B=e.mode==g.HANG||e.mode==g.CLIMB;z&&([D,O]=[R[0]*Math.cos(L)-R[1]*Math.sin(L)<0?-1:1,R]),B&&e.wall&&(d=Math.atan2(-R[0],-R[1]),e.mode!=g.HANG&&A||(k=[e.x,e.z,R[0],R[1],0]),k[4]=e.edge),A=B,[N,N&&e.vy>.5,e.dash>50,z&&D<0,z&&D>0,e.mode==g.HANG,e.mode==g.CLIMB,e.mode==g.SLIDE,e.stun>0,h&&Math.sqrt(Math.sin(Math.PI*h))].forEach((e,t)=>P(br+2*t,+e,12)),P(br+2*$.DOWN,+(e.down>0),5),P(pr,+(e.mode==g.CROUCH),12),P(_r,B?Q((1.7-k[4]+e.y)/1.2):0,14),P(fr,p,26);let te=b||l<2?0:Wn(f,L)/Math.max(j,.001);f=L;let ne=b?0:-((e.vx-i.vx)*Math.sin(u)+(e.vz-i.vz)*Math.cos(u))/Math.max(j,.001),V=-(F*Math.sin(u)+I*Math.cos(u)),re=Math.sign(V)*Q((Math.abs(V)-1.5)*.028,0,.22);P(lr,(V>0?re:re/2)+Q(ne*.012,-.3,.3),7),P(ur,Q(.3*Math.atan(l*te/9.8),-.4,.4),8),P(dr,.5*Math.sin(Wn(e.yaw,L))*Q(l/2),10);let H=e=>n[br+2*e],U=Q(H($.DASH)+H($.WALL_L)+H($.WALL_R)+H($.SLIDE)),ie=e.yaw+Wn(e.yaw,L)*U;u=ie+Wn(ie,d)*Q(H($.HANG)+H($.CLIMB)),u+=n[dr]*(1-U);let[ae,oe]=[Math.cos(u),Math.sin(u)];P(vr,e.stun>0?Q(-(e.vx*oe+e.vz*ae)/4.2,-1,1):0,18),P(yr,e.stun>0?Q((e.vx*ae-e.vz*oe)/4.2,-1,1):0,18),[w,T,E]=[e.yaw,e.pitch,[e.x,e.y,e.z]];let se=l<tr[1]?0:1,ce=Q((l-tr[se])/(tr[se+1]-tr[se]));for(let e in nr){let n=nr[e];t[e]=n[se]+(n[se+1]-n[se])*ce}v=Un((l-.2)/1.2);let le=t.f*C[0]*(.35+.65*Q(l/1.4))*(1+.5*H($.STUN));_=Q(t.s*le/Math.max(l,.1),.2,.62);let[ue,de]=[Math.cos(u),-Math.sin(u)],W=(t,n)=>{let r=M?M(t,n):e.y;return Math.abs(r-e.y)<.6?r:e.y},fe=l<=.25,pe=ee&&(!fe||!r[0].on||!r[1].on);(pe||z)&&(o=(o+(fe&&!z?.9:le)*j)%1),r.forEach((n,a)=>{let c=a?1:-1,l=(o+a/2)%1,[d,f]=[e.x+ue*c*Sr,e.z+de*c*Sr],p=u-c*C[4],[m,h]=[-Math.sin(p),-Math.cos(p)];if(ee){if(y||([n.px,n.pz,n.gy,n.on]=[d,f,W(d,f),!0],b&&([n.x,n.y,n.z,n.th,n.tw]=[d,n.gy+zn,f,0,1])),n.on&&pe&&(l>=_||Math.hypot(n.x-d,n.z-f)>.56))[n.on,n.lx,n.ly,n.lz,n.dl]=[!1,n.x-e.x,n.y,n.z-e.z,l];else if(!n.on&&l<n.u){let[e]=er(t.td*v);[n.on,n.px,n.pz,n.gy]=[!0,n.x-m*e,n.z-h*e,n.tg],s++}if(n.u=l,n.on){if(fe&&r[0].on&&r[1].on){let e=1-Math.exp(-8*j);n.px+=(d-n.px)*e,n.pz+=(f-n.pz)*e,n.gy+=(W(d,f)-n.gy)*e}n.x0=Q(l/_),n.th=v*(t.td*(1-Un(n.x0/.25))+t.to*Un((n.x0-.55)/.45));let[e,i]=er(n.th);[n.x,n.y,n.z]=[n.px+m*e,n.gy+zn+i,n.pz+h*e],n.w=1-v*(1-Un(Math.min(n.x0,1-n.x0)/.12)),n.tw=Un(n.x0*10)}else{let r=Q((l-n.dl)/(1-n.dl+1e-6)),[i,a]=[t.k*_/le,(1-l)/le+t.k*_/le],[o,s]=[F*i+ue*c*t.lat,I*i+de*c*t.lat];n.tg=W(e.x+F*a+ue*c*t.lat,e.z+I*a+de*c*t.lat);let[u,d]=[t.td*v,t.to*v],f=Un((r-.12)/.78);n.x=e.x+n.lx+(o-n.lx)*f,n.z=e.z+n.lz+(s-n.lz)*f,n.y=n.ly+(n.tg+zn+er(u)[1]-n.ly)*Un(r*1.5)+t.lift*Math.sin(Math.PI*r**.6),n.th=d+(u-d)*Un(r)+.15*Math.sin(Math.PI*r),n.tw=1-Un(r*4),n.w=0}}else{let t=b?0:Math.exp(-10*j),r=b?[0,0,0]:[n.x-i.x,n.y-i.y,n.z-i.z];n.x=e.x+r[0]*t+(d-e.x)*(1-t),n.y=e.y+r[1]*t+zn*(1-t),n.z=e.z+r[2]*t+(f-e.z)*(1-t),[n.th,n.tw,n.w,n.on,n.u]=[n.th*t,n.tw*t,0,!1,l]}}),y=ee,x=!0,Object.assign(i,e),a=!0},M=()=>{let t=e=>n[br+2*e],{rot:r}=e,[i,a]=[Math.cos(u),Math.sin(u)],s=(e,t,n,r=E)=>[r[0]+e*i+n*a,t,r[2]+n*i-e*a],c=(e,t,n)=>s(e,t,n,[0,0,0]),l=[],{pos:d,rot:f}=Mn(e),p=d[J.PELVIS],m=e=>e<0?J.HAND_L:J.HAND_R,h=e=>e<0?J.FOOT_L:J.FOOT_R,g=Y(X(Fn,u),X(Z,-.2)),_=Q(t($.HANG)+t($.CLIMB));if(_>.002){let[r,i,a,o,s]=k,u=.4+.14*n[_r],f=[-1,1].map(e=>{let t=d[m(e)-2],n=Math.max(u,(t[0]-r)*a+(t[2]-i)*o),c=[r+a*n-o*e*.21,s+.03,i+o*n+a*e*.21],l=(t[0]-c[0])**2+(t[2]-c[2])**2;return[c,t[1]-c[1]-Math.sqrt(Math.max(((Bn+Vn)*.97)**2-l,0))]}),g=_**4*Q(Math.max(...f.map(e=>e[1])));e.at[1]-=g,d.forEach(e=>e[1]-=g),[-1,1].forEach((e,t)=>l.push([m(e),_,f[t][0],c(e*.8,0,.6),Qn([0,e,0],[a,0,o])]));let v=(p[0]-r)*a+(p[2]-i)*o,y=Math.max(.58,v+.45);[-1,1].forEach(e=>l.push([h(e),t($.CLIMB)*Q(e<0?(v-.25)*4:n[_r]*2-.4),[r+a*y-o*e*.1,s+zn,i+o*y+a*e*.1],[a,.5,o],Qn([-o,0,a],[0,-1,0])]))}[-1,1].forEach(e=>{let n=t(e<0?$.WALL_L:$.WALL_R);if(n>.002){let[t,r]=O;[e,-e].forEach((i,a)=>{let d=(o+.5*a)%1,f=d<.55,_=f?d/.55:(d-.55)/.45,v=f?0:Math.sin(Math.PI*_),y=(f?2*_-1:1-2*Un(_))*(a?.4:.3);l.push([h(i),n,a?s(-e*.12,p[1]-.7+.4*v,y):s(e*(.34-.2*v),p[1]-.52+.3*v,y),c(-e*.7,1,-1),a?Y(X(Fn,u),X(Z,-.5)):jn(g,Qn(qn([t,0,r],c(0,0,-1)),[t,0,r]),1-v)]);let b=Math.cos(Pn*(o+.5*(1-a)));l.push([m(i),n,a?s(-e*.5,p[1]+.3+.12*b,.2*b):s(e*.37,p[1]+.3+.05*b,.1*b),c(a?-e*.7:0,a?0:-.5,.7),Qn(a?[0,i,0]:[-i*t,0,-i*r],c(0,0,-1))])})}});let v=t($.SLIDE);if(v>.002){let e=E[1];l.push([J.FOOT_R,v,s(.12,e+zn+.14,-.85,p),c(.1,1,-.3),g],[J.FOOT_L,v,s(-.2,e+zn,-.3,p),c(-.4,1,-.1),g],[J.HAND_L,v,s(-.4,e+.03,.4,p),c(-.7,0,.7),Qn([0,-1,0],c(-1,0,0))])}l.forEach(([e,t,n,i,a])=>{let[o,s,c]=[e-2,e<J.THIGH_L,t*t],l=Jn(Jn(d[o+1],1,d[o],-1),1,An(f[o],[0,0,s?1:-1]),.05),[u,p]=[Jn(d[e],1-c,n,c),e=>Yn(Jn(e,1,d[o],-1))],m=Jn(Yn(Xn(l,p(d[e]))),1-c,Yn(Xn(i,p(n))),c),[h,g]=s?$n(d[o],u,m,Bn,Vn,-1):$n(d[o],u,m),_=s?Y(h,X(In,o==J.ARM_L?.1:-.1)):h;r[o]=Y(Gn(f[En[o]]),_),r[o+1]=Y(Gn(_),g),r[e]=jn(r[e],Y(Gn(g),a),c)})},ee=()=>{let{rot:i}=e,a=v,s=e=>n[br+2*e],[l,d,f,p,m]=[n[lr],n[ur],n[dr],n[fr],n[pr]],[g,y]=[Math.cos(Pn*o),Math.cos(2*Pn*o)],b=Math.cos(Pn*(o-(1+_)/2)),D=t.po*a*b,O=t.pt+C[3]+t.pa*a*y,k=(t.cc+t.pr)*a*g,A=1-a,j=A*.012*Math.sin(Pn*.28*c),ee=A*.012*Math.sin(Pn*.17*c+C[1]*9),N=t.sw*a*b+ee;e.at[0]=E[0],e.at[1]=E[1],e.at[2]=E[2],e.yaw=u,i[J.PELVIS]=Y(Y(X(Fn,-t.pr*a*g),X(In,D+.4*d)),X(Z,-(O+.25*l+.3*m+.5*p)));let P=O+.25*l-l-.7*m-.8*p;i[J.SPINE]=Y(Y(X(Fn,.4*k-.25*f),X(In,.25*d-.8*D+.5*ee)),X(Z,.45*P+j*.5)),i[J.CHEST]=Y(Y(X(Fn,.6*k-.25*f),X(In,.25*d-.8*D-.5*ee)),X(Z,.55*P+j)),[-1,1].forEach(e=>{let n=Math.cos(Pn*(o-(e<0?.5:0))),r=C[e<0?1:2];i[e<0?J.ARM_L:J.ARM_R]=Y(X(In,e*(.06+t.ab*a+.5*p)),X(Z,(t.am+t.aa*r*n)*a+.05*A*e*Math.sin(c*1.3)+p+.5*m)),i[e<0?J.FOREARM_L:J.FOREARM_R]=X(Z,.15*A+a*(t.em+t.ea*n)+p+.5*m)});let F=X(Fn,u),I=Y(F,i[J.PELVIS]),[L,R]=[Math.cos(u),-Math.sin(u)],z=[E[0]+L*N,0,E[2]+R*N],B=[J.THIGH_L,J.THIGH_R].map(e=>An(I,Dn[e])),te=1-.25*m-.7*p,ne=E[1]+.05+zn+Hn*(te-t.d0-.6*t.d1*a)+t.hop*a*(.5-.5*Math.cos(2*Pn*o-2*Pn*_/2)),V=r.map((e,n)=>{let[r,i]=[e.x-z[0]-B[n][0],e.z-z[2]-B[n][2]],o=t.d0+t.d1*a*Math.sin(Math.PI*e.x0)+1-te,s=Math.min(Hn*(1-o),Hn*.99),c=e.y+Math.sqrt(Math.max(s*s-r*r-i*i,.04));return ne+(c-B[n][1]-ne)*e.w}),re=Zn(V[0],V[1],.05),H=c-S;S=c,H>.1?[n[gr],n[gr+1]]=[re,0]:Nn(n,gr,re,30,H),z[1]=Math.min(re,n[gr]),e.hips=[N,z[1]-E[1]-Dn[0][1],0],r.forEach((e,t)=>{let n=t?1:-1,r=[z[0]+B[t][0],z[1]+B[t][1],z[2]+B[t][2]],a=u-n*C[4],[o,s]=$n(r,[e.x,e.y,e.z],[-Math.sin(a),0,-Math.cos(a)]),c=t?J.THIGH_R:J.THIGH_L;i[c]=Y(Gn(I),o),i[c+1]=Y(Gn(o),s),i[c+2]=Y(Gn(s),Y(X(Fn,a),X(Z,e.th))),i[c+3]=X(Z,e.th<0?-e.th*e.tw:0)}),rr.forEach((t,n)=>{let r=s(n);if(r>.002){let a=or(t),o=n==$.STUN;ar.slice(o?3:0,o?7:15).forEach(e=>i[e]=jn(i[e],a[e],r)),o||[t[13],t[0],t[12]].forEach((t,n)=>e.hips[n]+=(t-e.hips[n])*r)}}),h&&(i[J.PELVIS]=Y(X(Z,-Pn*(3-2*h)*h*h),i[J.PELVIS]));let U=s($.HANG);if(U>.002){let[t,n]=[.01*Math.sin(Pn*(.3*c+C[5])),.006*Math.sin(Pn*(.2*c+3*C[5]))].map(e=>e*U);i[J.PELVIS]=Y(Y(X(In,n),X(Z,t)),i[J.PELVIS]),[J.THIGH_L,J.THIGH_R].forEach(e=>i[e]=Y(i[e],X(Z,t))),e.hips[0]+=n,e.hips[2]-=t}let ie=s($.STUN);if(ie){[J.SPINE,J.CHEST].forEach((e,t)=>{let r=.3+.1*t;i[e]=Y(i[e],Y(X(In,-r*n[yr]),X(Z,-r*n[vr])))});let e=Math.sin(c*13);[J.ARM_L,J.ARM_R].forEach((t,n)=>i[t]=Y(i[t],X(Z,ie*(n?e:-e)))),i[J.CHEST]=Y(i[J.CHEST],X(Fn,.3*ie*Math.sin(c*8)))}M();let ae=Un((s($.DOWN)-.35)/.65);ae&&(i[J.PELVIS]=Y(X(Z,-1.45*ae),i[J.PELVIS]),e.hips[1]+=(.17-Dn[0][1]-e.hips[1])*ae,[J.THIGH_L,J.THIGH_R].forEach(e=>i[e]=Y(i[e],X(Z,-1.25*ae))),[J.ARM_L,J.ARM_R].forEach(e=>i[e]=Y(i[e],X(Z,-.5*ae))));let oe=Y(Y(F,i[J.PELVIS]),Y(i[J.SPINE],i[J.CHEST])),se=Y(X(Fn,w),X(Z,Q(T,-1,1)*.9)),ce=Y(Gn(oe),jn(oe,se,.85*(1-s($.TUCK))*(1-.5*ie)*(1-s($.DOWN))));return i[J.NECK]=jn([0,0,0,1],ce,.4),i[J.HEAD]=Y(Gn(i[J.NECK]),ce),x=!1,e};return{update:j,pose:()=>x?ee():e,get phase(){return o},get steps(){return s}}},wr=e=>Math.sign(e)*Math.abs(e)**.8,Tr=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),Er=e=>Math.min(Math.max(e,0),1),Dr=(e,t,n,r)=>{let i=[],a=[],o=[],s=t.map(([e,r,o,s,c=0],l)=>{let[u,d]=[t[Math.max(l-1,0)],t[Math.min(l+1,t.length-1)]],f=Math.hypot(d[0]-u[0],d[1]-u[1])||1,[p,m]=[(d[0]-u[0])/f,(d[1]-u[1])/f];return Array.from({length:o?n:1},(t,l)=>{let[u,d]=[wr(Math.cos(l*U/n)),wr(Math.sin(l*U/n))];return i.push([c+o*u,r+s*d*p,-(e-s*d*m)]),a.push([0,0,0]),i.length-1})});s.slice(1).forEach((e,r)=>{let c=s[r],l=[(t[r][4]??0)+(t[r+1][4]??0),t[r][1]+t[r+1][1],-t[r][0]-t[r+1][0]];for(let t=0;t<n;t++){let[n,r,s,u]=[c[t%c.length],c[(t+1)%c.length],e[(t+1)%e.length],e[t%e.length]];for(let e of[[n,r,s],[n,s,u]]){if(new Set(e).size<3)continue;let[t,n]=[1,2].map(t=>[0,1,2].map(n=>i[e[t]][n]-i[e[0]][n])),r=[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]],s=[0,1,2].reduce((t,n)=>t+r[n]*(i[e[0]][n]*2-l[n]),0)<0;o.push(...s?[e[0],e[2],e[1]]:e);for(let t of e)[0,1,2].forEach(e=>a[t][e]+=s?-r[e]:r[e])}}});for(let t of o){let n=Math.hypot(...a[t])||1,o=a[t].map(e=>e/n);e.push(...i[t],...o,...r(i[t],o))}},Or=[.34,.12,.62],kr=[.72,.46,1],Ar=[.1,.38,.72],jr=[.16,.06,.34],Mr=[.5,1.9,2.3],Nr=(e=0)=>(t,n)=>{let r=Tr(Tr(Or,Ar,Er(-t[2]*5-.3)*.8),kr,Math.max(n[1],0)**1.5*.7),[i,a,,o]=Tr([...r.slice(0,2),0,r[2]],[...jr.slice(0,2),0,jr[2]],Er(-n[1]*.5+e));return[i,a,-1,o]},Pr=[.035,.025,.08],Fr=()=>[Mr[0],Mr[1],-2,Mr[2]],Ir=[0,.095,.06],Lr=[0,.075,-.21],Rr=[Math.sin(.4),Math.cos(.4)],zr=[[-.06,.095,0,0],[-.055,.098,.022,.022],[-.035,.103,.042,.036],[-.005,.104,.048,.04],[.035,.1,.044,.038],[.08,.094,.036,.034],[.12,.088,.028,.028],[.135,.084,0,0]],Br=[[-.05,-.02,0,0],[-.045,-.025,.018,.012],[-.025,-.052,.032,.018],[.01,-.066,.036,.02],[.06,-.06,.034,.02],[.11,-.04,.028,.018],[.16,0,.02,.014],[.2,.04,.012,.01],[.222,.065,0,0]],Vr=[],Hr=e=>{if(Vr[e])return Vr[e];let[t,n]=e?[12,8]:[8,5],r=[];Dr(r,zr,t,Nr()),Dr(r,Br,t,Nr(.25)),Dr(r,[[.03,.06,0,0],[.02,.046,.021,.022],[0,0,.021,.023],[-.02,-.046,.021,.022],[-.03,-.06,0,0]],n,Nr(.1));for(let t of[-1,1])Dr(r,[[.06,.095,.018,.03,.026*t],[.1,.093,.017,.028,.027*t],[.15,.088,.015,.024,.024*t],[.19,.081,.012,.018,.019*t],[.222,.074,.008,.012,.015*t],[.232,.07,0,0,.014*t]],n,Nr(.05)),Dr(r,zr.slice(1,6).map(([e,n,r,i])=>[e,n-.1*i,.0035,.006,t*r*.93]),e?5:3,Fr),Dr(r,Br.slice(1,7).map(([e,n,r,i])=>[e,n+.3*i,.0035,.005,t*r*.92]),e?5:3,Fr);return Dr(r,[[.09,.088,0,0],[.1,.088,.009,.009],[.15,.084,.009,.009],[.2,.078,.007,.007],[-Lr[2],Lr[1],0,0]],n,Fr),Vr[e]=r},Ur=e=>{let[t,n,r]=[An(e,[0,0,-1]),An(e,[1,0,0]),An(e,[0,-1,0])],[i,a]=Rr;return[n,t.map((e,t)=>a*e-i*r[t]),t.map((e,t)=>i*e+a*r[t])]},Wr=(e,t)=>{let[n,r]=[An(t,[0,-1,0]),An(t,[1,0,0])];return e.map((e,t)=>e+n[t]*.078-r[t]*.022)},Gr=[`abcdef`,`bc`,`abdeg`,`abcdg`,`bcfg`,`acdfg`,`acdefg`,`abc`,`abcdefg`,`abcdfg`],[Kr,qr,Jr,Yr]=[.019,.026,.0055,.004],Xr={a:[0,qr-Jr,Kr,qr],b:[Kr-Jr,qr/2,Kr,qr],c:[Kr-Jr,0,Kr,qr/2],d:[0,0,Kr,Jr],e:[0,0,Jr,qr/2],f:[0,qr/2,Jr,qr],g:[0,(qr-Jr)/2,Kr,(qr+Jr)/2]},Zr=[[.036,.112,.056],[.036,.112,.012]],Qr=[[.028,.156,.036],[.028,.152,.02]],$r=[.2,.075,.36],[ei,ti,ni]=[.023,.0175,.0455],ri=/* @__PURE__ */ new Map,ii=e=>{let t=Math.min(Math.max(Math.floor(e),0),99),n=ri.get(t);if(!n){let e=n=[],r=e=>[-e[0],e[1],e[2]],[i,a,o,s]=[Zr[0],Zr[1],Qr[0],Qr[1]],c=[i,a,o,s].flatMap(e=>[e,r(e)]),l=[0,1,2].map(e=>c.reduce((t,n)=>t+n[e],0)/c.length),u=(t,n)=>{let[r,i]=[q(t[1],t[0]),q(t[2],t[0])],a=kt([r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],q(t[0],l))<0?[t[0],t[3],t[2],t[1]]:t;$t(e,a[0],a[1],a[2],n),$t(e,a[0],a[2],a[3],n)};u([i,r(i),r(o),o],$r),u([a,r(a),r(s),s],$r),u([i,a,s,o],$r),u([r(i),r(a),r(s),r(o)],$r),u([o,r(o),r(s),s],$r);let d=jt(q(o,i)),[f,p]=[[0,i[1],i[2]],[0,-d[2],d[1]]],m=(e,t,n)=>[f[0]+e,f[1]+d[1]*t+p[1]*n,f[2]+d[2]*t+p[2]*n];u([m(-ei,ti,.0012),m(ei,ti,.0012),m(ei,ni,.0012),m(-ei,ni,.0012)],Pr);let h=e.length;[...`${t}`.padStart(2,`0`)].forEach((n,r)=>{let i=-Kr-Yr/2+r*(Kr+Yr);for(let r of Gr[+n]){let[n,a,o,s]=Xr[r],c=(e,t)=>m(i+e,(ti+ni-qr)/2+t,.0027),l=t>10?[.25,.9,1]:[1,.18,.12];$t(e,c(n,a),c(o,a),c(o,s),l),$t(e,c(n,a),c(o,s),c(n,s),l)}}),Qt(e,h,1),ri.set(t,n)}return n},ai=(e,t,n,r,i=1,a)=>{let[o,s]=[Wr(t,n),Ur(n)];zt(e,Hr(r),o,s,[0,0,0],i),a!==void 0&&zt(e,ii(a),o,s,[0,0,0],i)},oi=(e,[,t,n])=>[0,1,2].map(r=>e[r]+t[r]*Lr[1]-n[r]*Lr[2]),si=Math.atan2(Ir[1]-Lr[1],Ir[2]-Lr[2]),ci=(e,t,n,r)=>{let i=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],a=[n,r,jt(q(t,e))];for(let o=0;o<3;o++){let s=jt(q(t,o?oi(e,a):e)),c=jt(q(n,i(s,kt(n,s)))),l=jt(q(q(r,i(s,kt(r,s))),i(c,kt(r,c)))),[u,d]=[Math.sin(si),Math.cos(si)];a=[c,Ot(i(l,d),i(s,-u)),Ot(i(s,d),i(l,u))]}return a},li=(e,t)=>{let n=[e.x,e.y+ve(e),e.z],r=Mt(e.yaw,e.pitch)[2],i=V(t,n,r,80);return[[0,1,2].map(e=>n[e]+r[e]*i),i<80]},ui=(e,t)=>{let[n,r,i]=Mt(e.yaw,e.pitch),a=[e.x,e.y+ve(e),e.z],o=[0,1,2].map(e=>a[e]+n[e]*.2-r[e]*.17+i[e]*.42);return[o,ci(o,t,n,r)]},di=[.66,.45,.35],[fi,pi,mi,hi,gi,_i,vi,yi,bi]=[0,1,2,3,4,5,6,7,8],xi=e=>[e,e.map(e=>e*.5),[.12,.13,.17],di,[.09,.07,.06],[.74,.74,.77],[.93,.93,.94],[.26,.26,.3],[.03,.03,.04]],Si={chain:[J.PELVIS,J.SPINE,J.CHEST,J.NECK,J.HEAD],n:[8,8],e:2.3,far:[0,2,4,6,8,10,13],rings:[[.84,0,0,0,0,0,mi],[.88,0,.005,.13,.09,0,mi],[.94,0,.01,.187,.108,0,mi],[.99,0,.005,.18,.106,.25,pi],[1.03,0,0,.17,.102,.5,fi],[1.12,0,0,.155,.097,1,fi],[1.24,0,-.003,.176,.112,1.7,fi],[1.35,0,-.005,.19,.126,2,fi],[1.44,0,-.004,.2,.116,2,fi],[1.485,0,0,.2,.098,2.05,fi],[1.512,0,0,.125,.08,2.1,fi],[1.532,0,0,.07,.068,2.25,pi],[1.555,0,0,.06,.062,2.6,hi],[1.6,0,0,.057,.059,3.5,hi]]},Ci={chain:[J.PELVIS,J.THIGH_R,J.SHIN_R,J.FOOT_R],n:[6,8],m:!0,far:[0,2,4,6,7,9],rings:[[1,.1,.01,0,0,0,mi],[.9,.1,.006,.093,.098,.5,mi],[.72,.1,-.002,.088,.09,1,mi],[.55,.1,-.003,.066,.07,1.25,mi],[.49,.1,-.004,.058,.064,1.5,mi],[.42,.1,.002,.056,.064,1.8,mi],[.33,.1,.012,.055,.068,2,mi],[.19,.1,.003,.04,.047,2.05,mi],[.09,.1,0,.036,.04,2.6,mi],[.06,.1,0,0,0,3,mi]]},wi={chain:[J.ARM_R,J.FOREARM_R,J.HAND_R],n:[5,7],m:!0,far:[0,2,4,6,7,9,11],rings:[[1.5,.19,0,0,0,0,fi],[1.465,.192,0,.052,.056,0,fi],[1.38,.198,0,.056,.058,.1,fi],[1.27,.21,0,.049,.051,.3,fi],[1.18,.22,0,.043,.046,.5,fi],[1.09,.222,-.002,.046,.048,.8,fi],[.975,.222,0,.034,.034,1.2,pi],[.935,.222,0,.03,.03,1.8,yi],[.885,.222,-.004,.027,.037,2,yi],[.84,.222,-.008,.029,.042,2,yi],[.795,.222,-.012,.025,.034,2,yi],[.772,.222,-.014,0,0,2,yi]]},Ti={chain:[J.FOOT_R,J.TOE_R],n:[5,6],e:2.6,z:!0,m:!0,far:[0,1,3,5,7],rings:[[.095,.1,.05,0,0,0,_i],[.08,.1,.048,.032,.042,0,_i,130,vi],[.03,.1,.052,.042,.052,.05,_i,130,vi],[-.05,.1,.04,.045,.044,.3,_i,130,vi],[-.12,.1,.033,.047,.034,.6,_i,130,vi],[-.17,.1,.028,.042,.028,1,_i,130,vi],[-.205,.1,.024,.028,.02,1,_i,130,vi],[-.215,.1,.022,0,0,1,_i]]},Ei={chain:[J.HEAD],n:[7,10],far:[0,1,3,5,6,7],rings:[[1.575,0,-.0075,.034,.0425,0,hi],[1.6,0,-.0165,.058,.0665,0,hi],[1.635,0,-.0085,.072,.0785,0,hi,150,gi],[1.675,0,-.001,.08,.089,0,hi,-36,bi,110,gi],[1.71,0,.0035,.083,.0935,0,hi,72,gi],[1.75,0,.0065,.08,.0885,0,gi],[1.785,0,.011,.056,.061,0,gi],[1.8,0,.015,0,0,0,gi]]},Di={chain:[J.HEAD],n:[0,5],z:!0,far:[],rings:[[-.075,0,1.675,.014,.034,0,hi],[-.1,0,1.66,.012,.024,0,hi],[-.115,0,1.649,0,0,0,hi]]},Oi=[Si,Ci,wi,Ti,Ei,Di],ki=(e,t)=>Math.sign(e)*Math.abs(e)**(2/t),Ai=e=>{let[t,n,r,i,a]=[[],[],[],[],[]];for(let o of Oi){let s=o.n[Math.min(e,1)];if(!s||e>1&&(o===Ei||o===Di))continue;let c=e>1&&o===Si?[...o.rings.slice(0,9),[1.455,0,0,0,0,2,fi]]:e>1&&o===wi?[...o.rings.slice(0,7),[.95,.222,0,.037,.037,1.6,yi],[.925,.222,0,.027,.027,2,yi],[.91,.222,0,0,0,2,yi]]:e?o.rings:o.far.map(e=>o.rings[e]),l=c[c.length-1][0]>c[0][0];for(let e of o.m?[1,-1]:[1]){let u=t=>e<0&&t>J.HEAD?t-4:t,d=c.map(([i,a,c,l,d,f])=>{let p=Math.min(Math.floor(f),o.chain.length-2),m=[];for(let h=0;h<(l?s:1);h++){let g=h*2*Math.PI/s,[_,v]=[a+l*ki(Math.sin(g),o.e??2),c+d*ki(Math.cos(g),o.e??2)];t.push(e*_,...o.z?[v,i]:[i,-v],0,0,0),n.push(u(o.chain[Math.max(p,0)]),u(o.chain[p+1]??o.chain[0])),r.push(p<0||o.chain[p+1]===void 0?0:f-p),m.push(r.length-1)}return m});d.slice(1).forEach((t,n)=>{let r=d[n],[,,,,,,o,...u]=c[n];for(let n=0;n<s;n++){let[c,d,f,p]=[r[n%r.length],r[(n+1)%r.length],t[(n+1)%t.length],t[n%t.length]],m=Math.abs(((n+.5)/s*360+180)%360-180),h=u.findIndex((e,t)=>!(t%2)&&(e>0?m>e:m<-e));for(let t of[[c,d,f],[c,f,p]])new Set(t).size>2&&(i.push(...l===e<0?t:[t[0],t[2],t[1]]),a.push(h<0?o:u[h+1]))}})}}for(let e=0;e<i.length;e+=3){let[n,r,a]=[i[e],i[e+1],i[e+2]].map(e=>e*6),o=[0,1,2].map(e=>[t[r+e]-t[n+e],t[a+e]-t[n+e]]),s=[o[1][0]*o[2][1]-o[2][0]*o[1][1],o[2][0]*o[0][1]-o[0][0]*o[2][1],o[0][0]*o[1][1]-o[1][0]*o[0][1]];for(let e of[n,r,a])for(let n=0;n<3;n++)t[e+3+n]+=s[n]}for(let e=0;e<t.length;e+=6){let n=Math.hypot(t[e+3],t[e+4],t[e+5])||1;for(let r=3;r<6;r++)t[e+r]/=n}return{v:new Float32Array(t),j:new Uint8Array(n),w:new Float32Array(r),t:new Uint16Array(i),c:new Uint8Array(a)}},ji=[],Mi=e=>ji[e]??=Ai(e),Ni=Mn(kn()).pos,Pi=new Float64Array(Tn*12),Fi=/* @__PURE__ */ new Float32Array,Ii=(e,t,{pos:n,rot:r},i)=>{for(let e=0;e<Tn;e++){let[t,i,a,o]=r[e],s=[1-2*(i*i+a*a),2*(t*i-a*o),2*(t*a+i*o),2*(t*i+a*o),1-2*(t*t+a*a),2*(i*a-t*o),2*(t*a-i*o),2*(i*a+t*o),1-2*(t*t+i*i)];for(let t=0;t<3;t++)Pi.set(s.slice(t*3,t*3+3),e*12+t*3),Pi[e*12+9+t]=n[e][t]-(s[t*3]*Ni[e][0]+s[t*3+1]*Ni[e][1]+s[t*3+2]*Ni[e][2])}let a=t.w.length;Fi.length<a*6&&(Fi=new Float32Array(a*6));for(let e=0;e<a;e++){let[n,r,i,a]=[t.j[e*2]*12,t.j[e*2+1]*12,t.w[e],e*6];for(let e=0;e<6;e++){let[o,s]=[e%3*3,e<3?a:a+3],[c,l,u,d]=[t.v[s],t.v[s+1],t.v[s+2],+(e<3)];Fi[a+e]=(1-i)*(Pi[n+o]*c+Pi[n+o+1]*l+Pi[n+o+2]*u+d*Pi[n+9+e%3])+i*(Pi[r+o]*c+Pi[r+o+1]*l+Pi[r+o+2]*u+d*Pi[r+9+e%3])}let o=Math.sqrt(Fi[a+3]**2+Fi[a+4]**2+Fi[a+5]**2)||1;Fi[a+3]/=o,Fi[a+4]/=o,Fi[a+5]/=o}for(let n=0;n<t.t.length;n+=3){let[r,a,o]=i[t.c[n/3]];for(let i=n;i<n+3;i++){let n=t.t[i]*6;e.push(Fi[n],Fi[n+1],Fi[n+2],Fi[n+3],Fi[n+4],Fi[n+5],r,a,-1,o)}}},Li=1,[Ri,zi]=[.12,.03],[Bi,Vi]=[[1,0,0],[0,1,0]],Hi=[.7,-1,-.5],Ui=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Wi=([e,t,n,r])=>[-e,-t,-n,r],Gi=(e,t)=>Math.hypot(...q(e,t)),Ki=(e,t,n)=>Ot(e,At([0,0,0],t,n)),qi=(e,t)=>{let[n,r]=[jt(e),jt(t)],i=[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0],1+kt(n,r)],a=Math.hypot(...i)||1;return i.map(e=>e/a)},Ji=(e,t,n,r,i)=>{let a=q(t,e),o=jt(a),s=Math.max(Math.min(Math.hypot(...a),(r+i)*.99),.15),c=(r*r-i*i+s*s)/(2*s),l=Math.sqrt(Math.max(r*r-c*c,0)),u=jt(q(n,At([0,0,0],o,kt(n,o))));return[Ki(Ki(e,o,c),u,l),Ki(e,o,s)]},Yi=(e,t,n,r,i,a=!1)=>{let[o,s,c]=[t.pos[n],t.pos[n+1],t.pos[n+2]],[l,u]=Ji(o,r,i,Gi(o,s),Gi(s,c)),d=Y(qi(q(s,o),q(l,o)),t.rot[n]),f=Y(qi(q(c,s),q(u,l)),t.rot[n+1]);e.rot[n]=Y(Wi(t.rot[En[n]]),d),e.rot[n+1]=Y(Wi(d),f),a&&(e.rot[n+2]=Y(Wi(f),t.rot[n+2]))},Xi=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Zi=()=>Rt(0,.04,[.0105,.0095],[1,2]),Qi=[1,1.1,1,.82],$i=[[[.55,-.2,.8],[.2,-.75,.6]],[[.4,-.1,.9],[-.55,-.5,.65]]],ea=(e,t,n,r,i,a,o)=>{let s=([e,a,o])=>[t[0]+i[0]*e+r[0]*a+n[0]*o,t[1]+i[1]*e+r[1]*a+n[1]*o,t[2]+i[2]*e+r[2]*a+n[2]*o],c=(t,n,r,a)=>n.reduce((t,n,c)=>{let l=[t[0]+n[0]*r,t[1]+n[1]*r,t[2]+n[2]*r];return Vt(e,Zi(),s(t),s(l),i,.04,a*.88**c,o),l},t);zt(e,Rt(1,0,[1,1]),t,[i,r,n],[0,0,.045],[.0425,.02,.058],o);for(let e=0;e<4;e++){let[t,n]=[.1+1.3*a,.2+3*a],r=-(e-1.5)*.08*(1-a),i=[t,n].map(e=>jt([r,-Math.sin(e),Math.cos(e)]));c([.0315-.021*e,-.004,.092],i,.04*Qi[e],1)}c([.034,-.012,.025],$i.map(([e,t])=>jt(At(e,t,a))),.037,1.25)},ta=(e,t)=>(n,i)=>{let a=V(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},na={amp:8,sprint:6,air:12,rise:10,dash:14,plant:16,wall:10,slide:10,stun:14,gun:10},ra=e=>{let t=Cr(),n,r={amp:0,sprint:0,air:0,rise:0,dash:0,plant:0,wall:0,slide:0,stun:0,gun:0},[i,a,o]=[0,0,1.6],s=[0,0,8],c=0,l=0,u,d=[0,0],f=(a,s,d=0,f=1.6)=>{if(i=d,o=f,!a){n=void 0;return}t.update(a,s,e&&ta(e,a.y)),n={...a},c+=s;let p=a.mode==g.GROUND||a.mode==g.CROUCH||a.mode==g.WALLRUN,m=a.dash>50,h=a.mode==g.AIR&&!m,_={amp:p?Ui(ye(a)/9):0,sprint:+be(a),air:+h,rise:+(h&&a.vy>.5),dash:+m,plant:+(a.mode==g.HANG||a.mode==g.CLIMB),wall:+(a.mode==g.WALLRUN),slide:+(a.mode==g.SLIDE),stun:+(a.stun>0),gun:+(a.ammo>=0&&!a.down)};for(let e of Object.keys(na))r[e]+=(_[e]-r[e])*(1-Math.exp(-s*na[e]));let[v,y]=Xi[a.wall];l+=(Ui(v*Math.cos(a.yaw)-y*Math.sin(a.yaw),-1,1)-l)*(1-Math.exp(-s*10)),_.plant&&a.edge&&(u={x:a.x,y:a.edge,z:a.z,dx:v,dz:y})},p=()=>{let e=r.amp*(1+.5*r.sprint),[n,a]=[Math.sin(U*t.phase),Math.cos(U*t.phase)],c=[Math.min(.22,.18*o)+.012*e*n,-.25+.018*e*a-.3*(1-r.gun),.4-.05*i];return[c,ci(c,[s[0],s[1]+.1*i*Math.hypot(...s),s[2]],Bi,Vi)]},m=(e,i,o,s=0)=>{if(!n||n.down||Gi(e,[n.x,n.y+ve(n),n.z])>Li)return;let f=t.pose(),m={at:[...f.at],yaw:f.yaw,hips:[...f.hips],rot:f.rot.map(e=>[...e])},[h,g,_]=Mt(i,o,s),v=([e,t,n])=>[h[0]*e+g[0]*t+_[0]*n,h[1]*e+g[1]*t+_[1]*n,h[2]*e+g[2]*t+_[2]*n],y=e=>[kt(e,h),kt(e,g),kt(e,_)];for(let e of[J.SPINE,J.CHEST])m.rot[e]=Y(m.rot[e],X(Bi,.12*Ui(o,-1.3,1.3)));let b=Mn(m),x=[-Math.sin(i),0,-Math.cos(i)],S=Ot(b.pos[J.HEAD],An(b.rot[J.HEAD],[0,.02,-.08]));m.at=Ot(m.at,q(e,Ki(S,[-x[0]*Ri,-zi,-x[2]*Ri],r.plant)));let C=Mn(m),w=[-Math.sin(m.yaw),0,-Math.cos(m.yaw)];for(let e of[J.THIGH_L,J.THIGH_R])Yi(m,C,e,b.pos[e+2],w,!0);let[T,E]=p(),D=[0,1,2].map(e=>Rr[1]*E[2][e]-Rr[0]*E[1][e]),O=[0,1,2].map(e=>T[e]-.078*D[e]+.022*E[0][e]);for(let n of[-1,1]){let i=Math.cos(U*t.phase)*n,o=r.amp*(1+.5*r.sprint),s=At([.25,-.17,.36],[.2,-.14,.42],r.sprint);s=[s[0],s[1]+.07*o*i,s[2]+.12*o*i],n<0&&(s=At(s,[-.2,-.65,.2],r.gun*(1-Ui(r.amp*2.5)))),s=At(s,[.38,-.2,.34],r.air),s=At(s,[.3,.02,.45],r.rise),s=At(s,[.14,-.1,.5],r.dash);let f=r.wall*Ui(l*n);s=At(s,[.42,-.16,.42],f),s=At(s,n>0?[.36,-.26,.38]:[.28,-.1,.42],r.slide);let p=Math.sin(c*12+(n>0?Math.PI:0));if(s=At(s,[.46,.05+.2*p,.4+.1*p],r.stun),u){let[t,i]=[-u.dz,u.dx];kt([t,0,i],h)<0&&([t,i]=[-t,-i]);let a=.35000000000000003,[o,c,l]=y(q([u.x+u.dx*a+t*.12*n,u.y+.03,u.z+u.dz*a+i*.12*n],e));s=At(s,[o*n,Math.max(c,-.28),Math.max(l,.4)],r.plant)}n>0&&(a=r.gun*(1-Ui(r.plant+f+r.stun)),s=At(s,O,a));let g=.75+.25*r.sprint;for(let[e,t]of[[.25,r.air],[.1,r.rise],[1,r.dash],[.1,f],[.1,r.slide],[.1,r.plant],[.2,r.stun]])g+=(e-g)*t;d[(n+1)/2]=n>0?g+(.9-g)*a:g;let _=Ot(e,v([s[0]*n,s[1],s[2]])),b=n<0?J.ARM_L:J.ARM_R;if(Yi(m,C,b,_,v([Hi[0]*n,Hi[1],Hi[2]])),m.rot[b+2]=X(Vi,n*(1+.5*(r.plant+r.slide))),n>0&&a>.002){let e=Qn(v(E[0]),v(D));m.rot[b+2]=jn(m.rot[b+2],Y(Wi(Mn(m).rot[J.FOREARM_R]),e),a)}}return Mn(m)};return{get id(){return n?.id??-1},update:f,pose:m,draw(e,t,r,i,o=0,s=[.7,.7,.7]){let c=m(t,r,i,o);if(c){let t=xi(s);Ii(e,Mi(2),c,t),[J.HAND_L,J.HAND_R].forEach((n,r)=>{let i=c.rot[n];ea(e,c.pos[n],An(i,[0,-1,0]),An(i,[r*2-1,0,0]),An(i,[0,0,-1]),d[r],t[7])}),a>.2&&ai(e,c.pos[J.HAND_R],c.rot[J.HAND_R],1,Ui(a*1.5-.5),n?.ammo)}},aim(e){let t=Math.hypot(...e);s=t<3?t?e.map(e=>e*3/t):[0,0,3]:e},muzzle:()=>oi(...p())}},ia=(e,t,n,r,i,a)=>{let o=Mt(r,i)[2],s=V(e,t,o,80),c=[0,1,2].map(e=>t[e]+o[e]*s);return{end:c,hit:s<80,local:Mt(r,a).map(e=>(c[0]-n[0])*e[0]+(c[1]-n[1])*e[1]+(c[2]-n[2])*e[2])}},aa=(e,t)=>e&&t?t.shots-e.shots&255:0,oa=3,sa=(e,t,r,i,a,o)=>{let s=0,c,l=!1,u=0,d=/* @__PURE__ */ new Map,p=()=>.94+.12*(u++*.618%1),m=e=>t.play(K.LASER,e,e?.7:.5,p());return{step(e,t){let r=aa(e,t);s+=r;for(let e=0;e<r;e++)o.pitch=Math.min(n,o.pitch+f),i.fire()},frame(n,o,u,f,p){if(a.update(p),o){let e=c;e&&o.hits!=e.hits&&(t.play(K.HIT),r.hit()),e&&o.hp<e.hp?(t.play(o.down&&!e.down?K.DOWN:K.HURT),i.wound()):e&&o.hp>e.hp&&!e.down&&t.play(K.PACK),e&&(e.ammo<0||o.ammo>e.ammo)&&o.ammo>=0&&t.play(K.GUN);let n=!!(f&h.FIRE);n&&!l&&o.ammo==0&&!o.down&&t.play(K.DRY),l=n,r.vitals(o.hp,o.ammo),r.down(i.lie,o.down/60),c={...o}}else c=void 0;if(n){let[e,t,r]=Mt(n.yaw,n.drawn),i=n.muzzle,o=[0,1,2].map(a=>n.cam[a]+e[a]*i[0]+t[a]*i[1]+r[a]*i[2]);for(a.mount(o);s>0;s--)a.shoot(o,n.end,n.hit,!0),m()}s=0;for(let t of u){let n=d.get(t.id),r=Math.min(n===void 0?0:t.shots-n&255,oa),[i,o]=li(t,e),[s,c]=ui(t,i);for(let e=0;e<r;e++)a.shoot(oi(s,c),i,o),m([t.x,t.y+ve(t),t.z]);d.set(t.id,t.shots)}for(let e of d.keys())u.some(t=>t.id==e)||d.delete(e)}}},ca=e=>.6+.2*e,la=e=>e?.mode===g.GROUND||e?.mode===g.CROUCH,ua=e=>la(e)||e?.mode===g.WALLRUN,da=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],fa=e=>.02+.0025*e,pa=.006,ma=.03,ha=.14,ga=.05,_a=5,va=9,ya=6.5,ba=.25,xa=.22,Sa=.9,Ca=4,wa=1,Ta=.12,Ea=24,Da=15.7,Oa=.45,ka=[-8,4,5],Aa=3,ja=[-1,1.2],Ma=4,Na=[-.25,.4,.5],Pa=[-1.5,.8,1.5],Fa=[.9,.3],Ia=[.1,.05,11],La=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ra=(e,t)=>{let n=Math.ceil(t*120);for(let r=0;r<n;r++)e[1]+=(-15.7*Da*e[0]-2*Oa*Da*e[1])*(t/n),e[0]+=e[1]*(t/n)},za=()=>{let e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c,l,u=[0,0],d=[0,0],f=[0,0],p={dy:0,pitch:0,roll:0,fov:0,lines:0,stride:0,hurt:0,kick:0,lie:0,fire(){s++,u[1]+=Na[0],d[1]+=Na[1],f[1]+=Na[2]*Math.sin(s*2.4),p.kick=1},wound(){u[1]+=Pa[0],d[1]+=Pa[1],f[1]+=Pa[2]*Math.sin(s++),p.hurt=1},jolt(){u[1]+=ka[0],d[1]+=ka[1],f[1]+=ka[2],p.hurt=1},punch(){u[1]+=ja[0],d[1]+=ja[1],a=1},update(s,m,_,y={ev:0,fall:0}){let b=e=>Math.min(1,_*e),x=s?ye(s):0,S=s&&l&&ua(s)&&ua(l)?Math.hypot(s.x-l.x,s.z-l.z):0;S<1&&(p.stride+=S/ca(x)),e+=((la(s)&&S>.5*_&&S<1?1:0)-e)*b(10),l=s,y.ev&v.LAND&&(u[1]-=xa*Math.min(y.fall,20)),y.ev&v.CLIMB&&(u[1]-=xa*Ca),y.ev&(v.JUMP|v.DOUBLE)&&(u[1]+=Sa),y.ev&v.GRAB&&(d[1]-=wa),Ra(u,_),Ra(d,_),Ra(f,_),p.hurt*=Math.exp(-_*Aa),a*=Math.exp(-_*10),p.kick*=Math.exp(-_*22),p.lie+=(+!!s?.down-p.lie)*b(5),o+=_*Ia[2];let C=s?Math.min(1,s.stun/48):0,w=s?ve(s):0;c=s?c===void 0?w:c+(w-c)*b(14):void 0,p.dy=(c??0)-w+u[0]-Math.cos(p.stride*2*Math.PI)*fa(x)*e-p.lie*(w-Fa[1]),i+=((s?.mode===g.CLIMB?Ta*Math.sin(Math.PI*La(s.t/Ea)):0)-i)*b(10),p.pitch=d[0]+i+Math.sin(o*.8)*Ia[1]*C;let T=s?.mode===g.WALLRUN?da[s.wall]:[0,0],E=s?T[0]*Math.cos(s.yaw)-T[1]*Math.sin(s.yaw):0,D=+!!(m&h.RIGHT)-!!(m&h.LEFT);t+=(D*ma+E*ha+(s?.mode===g.SLIDE?ga:0)-t)*b(8),p.roll=t+Math.sin(p.stride*Math.PI)*pa*e+f[0]+Math.sin(o)*Ia[0]*C+p.lie*Fa[0];let O=!!s&&s.dash>50;n+=(+O-n)*b(O?40:6),r+=(La((x-6)/3)-r)*b(4),p.fov=r*_a+n*va+a*Ma,p.lines+=(La((x-ya)/(9-ya))*ba+n*.75-p.lines)*b(8)}};return p},Ba=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Va=e=>{let t=e.loop(K.WIND),n=e.loop(K.SCRAPE),r=0,i=/* @__PURE__ */ new Map,a=(t,n,r)=>{let i=be(t);e.play(t.mode===g.WALLRUN?K.WALLSTEP:K.STEP,r,i||t.mode===g.WALLRUN?1:t.mode===g.CROUCH?.35:.6,(i?.92:1)*(n&1?1.06:.94))},o=(t,n)=>e.play(K.LAND,n,Ba(t/14,.2),1.25-.5*Ba(t/20));return{me(i,s,c){let l=Math.floor(c),u=l>r;if(r=l,!i||e.muted)return;u&&a(i,l);for(let[t,n]of[[v.JUMP,K.JUMP],[v.DOUBLE,K.DOUBLE],[v.DASH,K.DASH],[v.GRAB,K.GRAB],[v.CLIMB,K.SCUFF]])s.ev&t&&e.play(n);s.ev&v.LAND&&o(s.fall);let d=Ba((Math.hypot(i.vx,i.vy,i.vz)-4)/12);t.set(.55*d**1.5,.6+.9*d);let f=Ba(ye(i)/9);n.set(i.mode===g.SLIDE?.2+.5*f:0,.8+.4*f)},others(t){for(let n of t){let t=i.get(n.id);if(t&&!e.muted){let e=[n.x,n.y+.1,n.z],r=Math.hypot(n.x-t.p.x,n.z-t.p.z);if(ua(n)&&ua(t.p)&&r<1){let i=Math.floor(t.stride);t.stride+=r/ca(ye(n)),Math.floor(t.stride)>i&&a(n,i,e)}n.ground&&!t.p.ground&&t.p.vy<-3&&o(-t.p.vy,e)}i.set(n.id,{p:n,stride:t?.stride??0})}for(let e of i.keys())t.some(t=>t.id===e)||i.delete(e)}}},Ha=`h5,aside,nav,output,section,em,u,ul,dl,s,mark{position:absolute;margin:0;padding:0;pointer-events:none;user-select:none;white-space:pre-line}h5{top:8px;right:12px;font-size:12px}u{inset:0;opacity:0;background:radial-gradient(ellipse at center,#0000 35%,#d10000dd 120%)}nav{top:8px;left:50%;transform:translateX(-50%);display:grid;grid-template-columns:1fr auto 1fr;gap:2px 16px;align-items:center;text-align:center;font-size:13px}nav span,nav time{font:900 clamp(16px,4.6vw,24px)/1 system-ui,sans-serif;letter-spacing:.03em;white-space:nowrap}nav time{min-width:4.2ch;font-variant-numeric:tabular-nums;font-size:clamp(14px,3.8vw,20px)}nav small{font-size:clamp(10px,2.6vw,12px);white-space:nowrap;opacity:.95}nav small:first-of-type{text-align:right}nav small:last-of-type{text-align:left}output{top:20%;left:50%;transform:translateX(-50%);padding:6px 18px;font:900 clamp(18px,3.4vw,30px)/1.1 system-ui,sans-serif;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;background:#000a;border-bottom:3px solid currentColor}em{font-style:normal;font-size:13px;font-weight:800;line-height:1.1;text-align:center;transform:translate(-50%,-50%)}em span{display:block;font-size:20px;line-height:1}section{inset:0;z-index:2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:0 12px;text-align:center;background:#000c}section h6{font:900 clamp(30px,9vw,72px)/1 system-ui,sans-serif;letter-spacing:.04em}section strong{font-size:34px}section td:first-child{text-align:left;opacity:1}section td+td{text-align:center}section th{padding:2px 10px;font-size:12px;opacity:.7;font-weight:600}aside{inset:0;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:0 12px;text-align:center;background:#000b}h6{margin:0;font-size:inherit;text-shadow:none}aside h6{font:900 clamp(36px,13vw,84px)/1 system-ui,sans-serif;letter-spacing:.04em;transform:skewX(-8deg);background:linear-gradient(#fe6,#f92 45%,#d21);-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 3px 0 #500) drop-shadow(0 0 14px #f604)}ul{left:12px;bottom:30px;display:flex;gap:4px;list-style:none}li{width:16px;height:6px;background:#fff;box-shadow:0 0 0 1px #0008}li.e{background:#0000;box-shadow:inset 0 0 0 1px #fffb,0 0 0 1px #0008}ul.low li{background:#f55}ul.low li.e{background:#0000}dl{left:50%;bottom:10px;transform:translateX(-50%);display:flex;align-items:center;gap:10px}dl svg{width:38px;fill:#fff;filter:drop-shadow(0 1px 1px #000)}@media(max-width:520px){dl{left:auto;right:12px;bottom:46px;transform:none}}dl data{font:900 clamp(30px,5vw,46px)/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}dl.e data{color:#f66}s{left:50%;top:50%;width:28px;height:28px;margin:-14px 0 0 -14px;background:linear-gradient(45deg,#0000 44%,#fff 44% 56%,#0000 56%),linear-gradient(-45deg,#0000 44%,#fff 44% 56%,#0000 56%);-webkit-mask:radial-gradient(#0000 6px,#000 7px);mask:radial-gradient(#0000 6px,#000 7px)}mark{inset:0;z-index:1;padding-top:30vh;text-align:center;color:#ddd;background:radial-gradient(ellipse at center,#6668 0%,#4a0c0ce8 130%);backdrop-filter:grayscale(1)}mark::first-line{font:900 clamp(30px,8vw,64px)/1 system-ui,sans-serif;letter-spacing:.24em}strong{font-size:22px}table{border-collapse:collapse;font-size:16px}td{padding:2px 10px}td+td{text-align:left}td:first-child{text-align:right;opacity:.7}`,Ua=2800,Wa=e=>`${Math.floor(e/60)}:${`${e%60}`.padStart(2,`0`)}`,Ga=e=>{e.insertAdjacentHTML(`beforeend`,`<aside hidden><h6>TINY FPS</h6><span></span><table><tr><td>Mouse<td>look<tr><td>WASD / ZQSD<td>move<tr><td>Shift<td>sprint<tr><td>Space<td>jump, again in the air<tr><td>Move key twice<td>dash that way<tr><td>C<td>crouch, slide when fast<tr><td>Left click<td>fire the gun<tr><td>M<td>mute</table><span>Take the enemy flag to your own base while yours is home. Take the gun at your rack.</span><strong></strong></aside><u></u><h5 hidden>Muted (M)</h5><ul>${`<li></li>`.repeat(5)}</ul><dl hidden><svg viewBox="0 0 38 22"><path d="M1 7c3-5 13-7 22-4l7 3 3 1v4l-6 1-4 2-1 1-3 6h-5l2-7-5-1c-6-1-12-3-10-6z"/></svg><data></data></dl><s hidden></s><mark hidden></mark><nav hidden><span></span><time></time><span></span><small></small><small></small></nav><output hidden></output><section hidden><h6></h6><strong></strong><table></table><span></span></section>`);let t=t=>e.querySelector(t),[n,r]=[`h5`,`aside`].map(e=>t(e)),[i,a]=[`aside span`,`aside strong`].map(e=>t(e)),o=(e,t)=>e.textContent!=t&&(e.textContent=t),s=t(`nav`),[c,d,f]=[...s.querySelectorAll(`span, time`)],[p,h]=[...s.querySelectorAll(`small`)],g=[...e.querySelectorAll(`li`)],[_,v,y,b]=[t(`ul`),t(`dl`),t(`s`),t(`mark`)],x,S=t(`output`),C=t(`u`),w=t(`section`),[T,E,D]=[`h6`,`strong`,`span`].map(e=>w.querySelector(e)),O=w.querySelector(`table`),k=[],A,j,M=(e,t)=>e.style.color=u[t];return[c,p].forEach(e=>M(e,0)),[f,h].forEach(e=>M(e,1)),{title(e,t){r.hidden=!e,o(i,t),o(a,e)},mute:e=>n.hidden=!e,match(e,t){s.hidden=!1,o(c,`${l[0].toUpperCase()} ${e.score[0]}`),o(f,`${e.score[1]} ${l[1].toUpperCase()}`),o(d,e.over?`END`:Wa(e.clock)),e.flags.forEach((e,n)=>{let r=e.state===m.CARRIED?`taken by ${t(e.by)}`:e.state===m.DROPPED?`dropped ${e.left}s`:`home`;o(n?h:p,`${l[n]} flag: ${r}`)})},marks(t){for(;k.length<t.length;){let t=document.createElement(`em`);t.innerHTML=`<span></span><small></small>`,k.push(t),e.append(t)}k.splice(t.length).forEach(e=>e.remove()),t.forEach((e,t)=>{let n=k[t];n.style.left=`${e.x*100}%`,n.style.top=`${e.y*100}%`,M(n,e.team);let[r,i]=[n.children[0],n.children[1]];r.style.transform=e.arrow===void 0?``:`rotate(${e.arrow}rad)`,o(r,e.arrow===void 0?`▼`:`▲`),o(i,`${e.kind===`base`?`Base `:``}${e.text}`)})},hurt(e){let t=e<.01?``:`${Math.min(1,e)}`;C.style.opacity!=t&&(C.style.opacity=t)},vitals(e,t){g.forEach((t,n)=>t.classList.toggle(`e`,n>=e)),_.classList.toggle(`low`,e<=1),v.hidden=t<0,v.classList.toggle(`e`,!t),o(v.lastElementChild,`${Math.max(t,0)}`)},hit(){y.hidden=!1,clearTimeout(x),x=setTimeout(()=>y.hidden=!0,140)},down(e,t){b.hidden=e<.02,b.style.opacity=`${Math.min(e,1)}`,o(b,b.hidden?``:`DOWN\nBack in ${t.toFixed(1)}`)},banner(e,t){S.hidden=!1,o(S,e),S.style.color=t===void 0?`#fff`:u[t],clearTimeout(A),A=setTimeout(()=>S.hidden=!0,Ua)},end(e,t){if(w.hidden=!e,!e)j=void 0;else{if(j!==e){j=e;let[t,n]=e.score,r=t>n?0:n>t?1:-1;o(T,r<0?`DRAW`:`${l[r].toUpperCase()} WINS`),T.style.color=r<0?`#fff`:u[r],o(E,`${t} – ${n}`);let i=[...e.players].sort((e,t)=>t.caps-e.caps||t.returns-e.returns||e.id-t.id);O.replaceChildren(),O.insertAdjacentHTML(`beforeend`,`<tr><th>Player<th>Captures<th>Returns</tr>`);for(let e of i){let t=O.insertRow();[e.name,e.caps,e.returns].forEach(e=>t.insertCell().textContent=`${e}`),t.style.color=u[e.team]}}o(D,`Next match in ${t}`)}}}},Ka=.0025,qa=Math.PI*2,Ja={KeyW:h.FORWARD,ArrowUp:h.FORWARD,KeyS:h.BACK,ArrowDown:h.BACK,KeyA:h.LEFT,ArrowLeft:h.LEFT,KeyD:h.RIGHT,ArrowRight:h.RIGHT,Space:h.JUMP,ShiftLeft:h.SPRINT,ShiftRight:h.SPRINT,KeyC:h.CROUCH},Ya=h.FORWARD|h.BACK|h.LEFT|h.RIGHT,Xa=(e,t)=>e&~Ya|t|h.DASH,Za=e=>Ja[e]??0,Qa=(e,t=()=>{})=>{let r=new AbortController,i=(e,t,n)=>e.addEventListener(t,n,{signal:r.signal}),a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Map,s=0,c={yaw:0,pitch:0,keys:0,take(){let e=s?Xa(c.keys,s):c.keys;return s=0,e},locked:()=>e.getRootNode().pointerLockElement==e,destroy:()=>r.abort()};i(e,`click`,()=>{Promise.resolve(e.requestPointerLock()).catch(()=>{})}),i(document,`mousemove`,e=>{c.locked()&&(c.yaw=((c.yaw-e.movementX*Ka)%qa+qa)%qa,c.pitch=Math.max(-1.55,Math.min(n,c.pitch-e.movementY*Ka)))}),i(document,`mousedown`,e=>{c.locked()&&!e.button&&(c.keys|=h.FIRE)}),i(document,`mouseup`,e=>{e.button||(c.keys&=~h.FIRE)}),i(document,`keydown`,e=>{let n=Za(e.code);if(e.code==`KeyM`&&!e.repeat&&c.locked()&&t(),n&&c.locked()){if(n&Ya&&!e.repeat&&!a.has(e.code)){let t=performance.now(),r=o.get(e.code);r!==void 0&&t-r<=250?(s=n,o.delete(e.code)):o.set(e.code,t)}a.add(e.code),c.keys|=n,e.preventDefault()}}),i(document,`keyup`,e=>{a.delete(e.code),c.keys&=~Za(e.code)});let l=()=>{c.keys=s=0,a.clear(),o.clear()};return i(window,`blur`,l),i(document,`pointerlockchange`,()=>c.locked()||l()),c},$a=(e,t,n)=>{let[r,i]=[e.x-t[0],e.z-t[2]];return r*r+i*i<n*n&&Math.abs(e.y-t[1])<1},eo=(e,t,n,r,i=!0)=>{let a=e.down>0;if(Ke(e,a?{...t,keys:0}:t,n,r),a)return e.down>0&&!--e.down&&he(e,n,r),!1;let o=n.def.teams[r].rack,s=!!o&&$a(e,o,1.2);return i&&s&&!e.rack&&(e.ammo=60),e.rack=s,e.cool=Math.max(0,e.cool-1),i&&t.keys&h.FIRE&&!e.cool&&e.ammo>0&&e.mode!==g.HANG&&e.mode!==g.CLIMB?(e.ammo--,e.shots=e.shots+1&255,e.cool=7,!0):!1},to=120,no=16,ro=e=>{let t={...e};return delete t.ack,delete t.by,t},io=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,z:e.z+(t.z-e.z)*n}),ao=(e,t,n)=>se(e+(((t-e+Math.PI)%U+U)%U-Math.PI)*n),oo=(e,t)=>(t-e&65535)<32768,so=(e,t,n)=>({...t,...io(e,t,n),yaw:ao(e.yaw,t.yaw,n),pitch:e.pitch+(t.pitch-e.pitch)*n}),co=e=>{let t,n=0,r=0,i=[],a,o,s=[],c=0,l=0,u=!0,d=e=>{let t=e-100,n=0;for(;n+1<s.length&&s[n+1].t<=t;)n++;let r=s[n],i=s[n+1]??r;return{a:r,b:i,u:i.t>r.t?Math.max(0,Math.min(1,(t-r.t)/(i.t-r.t))):0}},f=e=>{if(!s.length)return;let{a:t,b:n,u:r}=d(e);return(t.s.tick+(n.s.tick-t.s.tick&65535)*r)%65536};return{you:(e,r=0)=>{[t,n]=[e,r]},step:(t,s)=>{let d=nt({...t,seq:r,view:s===void 0?void 0:f(s)});return r=r+1&65535,i.push(d),i.length>to&&i.shift(),a&&(o=ro(a),eo(a,d,e,n,u),c|=a.ev,l=Math.max(l,a.fall)),d},snapshot:(r,c)=>{s.push({t:c,s:r}),s.length>no&&s.shift();let l=r.players.find(e=>e.id===t);l&&(u=!r.over,i=i.filter(e=>!oo(e.seq,l.ack)),a=ro(l),o=ro(a),i.forEach((t,r)=>{r===i.length-1&&(o=ro(a)),eo(a,t,e,n,u)}))},events:()=>{let e={ev:c,fall:l};return c=l=0,e},me:e=>a&&o?so(o,a,Math.max(0,Math.min(1,e))):void 0,others:e=>{let n=s.at(-1);if(!n)return[];let{a:r,b:i,u:a}=d(e);return n.s.players.filter(e=>e.id!==t).map(e=>{let t=r.s.players.find(t=>t.id===e.id),n=i.s.players.find(t=>t.id===e.id);return t&&n?so(ro(t),ro(n),a):ro(n??t??e)})}}},lo={x0:.05,x1:.95,y0:.15,y1:.92},uo=(e,t,n,r,i)=>{let[a,o]=[r-e,i-t];return Math.atan2(a*Math.cos(n)-o*Math.sin(n),-a*Math.sin(n)-o*Math.cos(n))},fo=e=>{let[t,n]=[Math.sin(e),-Math.cos(e)],[r,i]=[(lo.x0+lo.x1)/2,(lo.y0+lo.y1)/2],[a,o]=[(lo.x1-lo.x0)/2,(lo.y1-lo.y0)/2],s=Math.min(a/(Math.abs(t)||1e-9),o/(Math.abs(n)||1e-9));return[r+t*s,i+n*s]},po=2.6,mo=e=>{let t=[],n=(n,r,[i,a,o])=>{let s=Math.round(Math.hypot(i-e.eye[0],a+po-e.eye[1],o-e.eye[2])),c=e.project(i,a+po,o),l=c&&c[0]>=lo.x0&&c[0]<=lo.x1&&c[1]>=lo.y0&&c[1]<=lo.y1,u=`${s} m`;if(l)t.push({team:n,kind:r,x:c[0],y:c[1],text:u});else{let a=uo(e.eye[0],e.eye[2],e.yaw,i,o),[s,c]=fo(a);t.push({team:n,kind:r,x:s,y:c,arrow:a,text:u})}},r=e.flags.some(t=>t.state===m.CARRIED&&t.by===e.id);return e.flags.forEach((t,i)=>{if(t.state===m.CARRIED&&t.by===e.id){n(e.team,`base`,e.bases[e.team]);return}if(r&&i===e.team&&t.state===m.HOME)return;let a=t.state===m.HOME?e.bases[i]:t.state===m.DROPPED?[t.x,t.y,t.z]:e.where(t.by);a&&n(i,`flag`,a)}),t},ho=(e=[],t=0,n=0)=>e.filter((e,r)=>n+r<32&&t>>>n+r&1),go=(e,t,n,r)=>{let i=n.map(e=>e*.45);Vt(e,Rt(1,1,[1,1],[0,0]),t,[t[0],t[1]+.72,t[2]],[1,0,0],1,.06,i);let[a,o,s]=t;zt(e,Rt(1,0,[1,1]),[a,o+.74,s],Mt(0,0),[0,0,0],[.3,.035,.3],n);let c=e.length;en(e,[a,o+.045,s],p-.07,p,n),Qt(e,c,1.2*Kt*(.7+.3*Math.sin(r*2.5))),zt(e,Hr(0),[a,o+1.05+.04*Math.sin(r*2),s],Mt(r*.8,0),[0,0,0],1.5)},_o=[[[1,0,0],[0,1,0],[0,0,1]],[[-1,0,0],[0,0,1],[0,1,0]],[[0,1,0],[0,0,1],[1,0,0]],[[0,-1,0],[1,0,0],[0,0,1]],[[0,0,1],[1,0,0],[0,1,0]],[[0,0,-1],[0,1,0],[1,0,0]]],vo=(e,t,n,r)=>[[[e,t],[n,t],[n,r]],[[e,t],[n,r],[e,r]]],yo=[...vo(-.13,-.04,.13,.04),...vo(-.04,-.13,.04,.13)],bo=[...vo(-.035,-.09,.035,.04),[[-.035,.04],[.035,.04],[0,.11]],...vo(-.05,-.12,.05,-.095)],xo=(e,t,n,r,i,a,o)=>{let[s,,c]=Mt(n*.9,0),l=[t[0],t[1]+.45+.07*Math.sin(n*2.2+t[0]),t[2]],u=([e,t,n])=>[s[0]*e-c[0]*n,t,s[2]*e-c[2]*n];for(let[t,n,s]of _o){let c=(e,i,a)=>{let[o,c,d]=u([0,1,2].map(o=>t[o]*r*a+n[o]*e+s[o]*i));return[l[0]+o,l[1]+c,l[2]+d]};$t(e,c(-r,-r,1),c(r,-r,1),c(r,r,1),i),$t(e,c(-r,-r,1),c(r,r,1),c(-r,r,1),i);let d=e.length;for(let[t,n,r]of a)$t(e,c(...t,1.01),c(...n,1.01),c(...r,1.01),o);for(let t=d;t<e.length;t+=10)e[t+8]=-2}},So=(e,t,n)=>xo(e,t,n,.17,[.86,.9,.88],yo,[.1,1.2,.4]),Co=(e,t,n)=>xo(e,t,n,.15,[.34,.14,.58],bo,[.3,1.4,1.8]),wo=14,To=e=>{let t=Mt(e.yaw,e.pitch)[2];return[e.x+t[0]*30,e.y+1.6+t[1]*30,e.z+t[2]*30]},Eo=.5,Do=e=>e.dash>50,Oo=e=>{let t=Cr();return t.update(e,0),{p:{...e},gait:t,dash:+Do(e),since:1e3,aim:0,focus:To(e)}},ko=(e,t)=>(n,i)=>{let a=V(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},Ao=(e,t,n,r)=>{for(let n of e.keys())t.some(e=>e.id==n)||e.delete(n);for(let i of t){let t=e.get(i.id);t?(t.gait.update(i,n,r&&ko(r,i.y)),t.dash+=(+Do(i)-t.dash)*(1-Math.exp(-n*wo)),t.since=i.shots==t.p.shots?t.since+n:0,t.aim=t.since==0?1:t.aim+(+(t.since<Eo)-t.aim)*(1-Math.exp(-n*12)),t.focus=t.since<Eo?r?li(i,r)[0]:To(i):t.focus,t.p={...i}):e.set(i.id,Oo(i))}},jo=(e,t,n,r,i)=>{let[a,o]=ui(n,r),s=e.rot.slice(),c={...e,rot:s},[l,u]=[o[0],o[2].map((e,t)=>e*Rr[1]-o[1][t]*Rr[0])],d=a.map((e,t)=>e-.078*u[t]+.022*l[t]),f=[l[0]*.7,-1,l[2]*.7];return Yi(c,t,J.ARM_R,d.map((e,n)=>t.pos[J.HAND_R][n]+(e-t.pos[J.HAND_R][n])*i),f),s[J.HAND_R]=jn(s[J.HAND_R],Y(Wi(Mn(c).rot[J.FOREARM_R]),Qn(l,u)),i),c},Mo=(e,t,n,r)=>{let i=jt([-t.p.vx,0,-t.p.vz]),[a,o,s]=n.map(e=>.6+.6*e);[[.5,.12,1.3],[.9,-.16,1.7],[1.25,.14,1.2]].forEach(([n,c,l],u)=>{let d=r([c,n,-.2-.1*u]),f=d.map((e,n)=>e+i[n]*l*t.dash);for(let t of[[-i[2]*.03,0,i[0]*.03],[0,.03,0]])for(let n of[d.map((e,n)=>e+t[n]),d.map((e,n)=>e-t[n]),f])e.push(...n,0,1,0,a,o,-2,s)})},No=(e,t,n,r=1)=>{let i=t.gait.pose(),{p:a}=t;a.down&&(i={...i,at:[i.at[0],i.at[1]-.5*Math.min(Math.max(1-a.down/30,0),1),i.at[2]]});let o=Mn(i);if(t.aim>.01&&a.ammo>=0&&(i=jo(i,o,a,t.focus,t.aim),o=Mn(i)),Ii(e,Mi(r),o,xi(n)),a.ammo>=0&&!a.down&&ai(e,o.pos[J.HAND_R],o.rot[J.HAND_R],r),t.dash>.15){let[r,a]=[Math.sin(i.yaw),Math.cos(i.yaw)],{x:o,y:s,z:c}=t.p;Mo(e,t,n,([e,t,n])=>[o+e*a-n*r,s+t,c-e*r-n*a])}},Po=Object.keys(y).length,Fo=(e,t,n)=>{let r=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,144665)|0;return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967296},Io=(e,t,n,r)=>{let[i,a]=[Math.floor(e),Math.floor(t)],[o,s]=[e-i,t-a].map(e=>e*e*(3-2*e)),c=(e,t)=>Fo((i+e)%n,(a+t)%n,r);return(c(0,0)*(1-o)+c(1,0)*o)*(1-s)+(c(0,1)*(1-o)+c(1,1)*o)*s},Lo=(e,t,n,r,i)=>{let[a,o]=[0,.5];for(let s=0;s<r;s++,o/=2)a+=o*Io(e*(1<<s),t*(1<<s),n<<s,i+s);return a/(1-o*2)},Ro=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),zo=(e,t)=>e.map(e=>e*t),Bo=e=>Math.min(Math.max(e,0),1),Vo=Math.PI*2,Ho=[];Ho[y.BRICK]=(e,t)=>{let n=Math.floor(t*8),r=e*4+(n&1)*.5,[i,a,o]=[Math.floor(r)%4,r%1,t*8%1],s=Io(e*16,t*16,16,5),c=.8+.4*s;return a<.05||o<.1?[zo([165,160,150],.7+.3*c),.1+.1*s]:[zo([170,78,56],(.8+.4*Fo(i,n,1))*c*(.85+.15*o)),.7+.2*s+.1*Bo(Math.min(a-.05,o-.1)*12)]},Ho[y.TILE]=(e,t)=>{let[n,r]=[Math.floor(e*4),Math.floor(t*4)],[i,a]=[e*4%1,t*4%1],o=Io(e*16,t*16,16,7),s=.9+.2*o;return i<.05||a<.05?[zo([85,85,80],s),.1]:[zo([196,190,172],s*(.88+.08*(n+r&1)+.1*Fo(n,r,2))),.8+.1*o+.1*Bo((Math.min(i,a)-.05)*14)]},Ho[y.LAVA]=(e,t)=>{let n=Lo(e*4,t*4,4,4,11),r=Math.max(0,1-Math.abs(n-.5)*7)**2;return[Ro(Ro([55,8,4],[230,70,8],n),[255,215,90],r),.5]},Ho[y.STONE]=(e,t)=>{let n=Lo(e*8,t*8,8,4,3);return[zo([128,124,120],.45+.7*(n*1.3+.1*Fo(Math.floor(e*128),Math.floor(t*128),4))),Bo(n*1.4-.2)]},Ho[y.METAL]=(e,t)=>{let[n,r,i,a]=[Math.floor(e*2),Math.floor(t*2),e*2%1,t*2%1],o=Bo((Io(e*8,t*8,8,13)-.68)*6),s=e=>Math.min(Math.max(Math.round((e-.1)/.4),0),2)*.4+.1,[c,l]=[s(i),s(a)],u=c==l&&c==.5?1:Math.hypot(i-c,a-l),d=Bo(1-u/.07),f=zo([98,108,124],(.9+.2*Io(e*32,t*32,32,9)+.12*Fo(n,r,6))*(1+.3*d)*(.65+.35*Bo((u-.06)/.04)));return Math.min(i,a,1-i,1-a)<.03?[zo([40,44,50],1+o),.05]:[Ro(f,[105,68,45],o*.7),.5+.1*(1-o)+.4*d]},Ho[y.WOOD]=(e,t)=>{let n=Math.floor(t*8),r=e*2+Fo(n,0,8)*2,[i,a,o]=[Math.floor(r)%2,r%1,t*8%1],s=Fo(n,i,3),c=.5+.5*Math.sin(Vo*(t*40+2.5*Io(e*4,t*4,4,21)+s*7));return o<.08||a<.015?[[28,18,10],.05]:[Ro([92,58,32],[158,106,62],c*.6+s*.35),.7+.15*c+.15*Bo((o-.08)*15)]},Ho[y.MOSS]=(e,t)=>{let n=Math.floor(t*4),r=e*2+(n&1)*.5,[i,a,o]=[Math.floor(r)%2,r%1,t*4%1],s=Math.min(a,1-a,(o<.5?o:1-o)*.5),c=a<.04||o<.06,l=Bo((.3*Lo(e*12,t*12,12,3,17)-.03-s)*12),u=Io(e*64,t*64,64,19),d=zo([128,126,118],(.7+.4*Fo(i,n,5))*(.7+.5*Io(e*16,t*16,16,15)));return[Ro(c?zo(d,.45):d,Ro([52,100,34],[96,148,56],u),l),c?.1+.6*l*u:.6+.2*Bo(s*30)+.2*l*u]},Ho[y.GRATE]=(e,t)=>{let[n,r]=[e*8%1,t*8%1],i=Math.max(Math.abs(n-.5),Math.abs(r-.5)),a=Math.min(Math.abs(n-.5),Math.abs(r-.5))>.43,o=Io(e*16,t*16,16,23);return i<.36?[[9,9,12],0]:[zo(Ro([104,108,116],[96,80,68],Bo((o-.55)*4)),(a?1.25:1)-(.5-i)*2.2+.2*o),a?1:.6+.4*Bo((i-.36)*12)]},Ho[y.CONCRETE]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=Lo(e*4,t*4,4,3,41),a=Fo(Math.floor(e*128),Math.floor(t*128),43)>.992,o=Math.hypot(n%.5-.25,r%.5-.25)<.02,s=(.94+.1*i+.03*Fo(Math.floor(e*2),Math.floor(t*2),44))*(a||o?.9:1);return n<.015||r<.015?[zo([160,164,172],s),.3]:[zo([206,209,214],s),o?.5:.8+.2*i-(a?.15:0)]},Ho[y.GLASS]=(e,t)=>{let n=e*2%1,r=((n+t*.7)%1-.5)/.12,i=Math.exp(-r*r);return n<.03||t<.03?[zo([150,158,170],1-.3*n),.9]:[Ro(Ro([7,20,44],[48,88,136],t**2),[120,160,200],i*.18),.4]},Ho[y.STEEL]=(e,t)=>{let n=Math.floor(t*128),r=.5*Fo(n,3,31)+.5*Io(e*8,0,8,n+7),i=e*4%1;return i<.03?[[60,66,76],.1]:[zo([176,184,196],.8+.35*r+(i>.97?.15:0)),.6+.2*r]},Ho[y.PAINT]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=Fo(Math.floor(e*128),Math.floor(t*128),47);return n<.02||r<.02?[[200,200,206],.3]:[zo([246,246,248],.96+.06*i),.85+.04*i]};var Uo=()=>{let e=new Uint8ClampedArray(Po*128*128*4);return Ho.forEach((t,n)=>{for(let r=0;r<16384;r++){let[i,a]=t(r%128/128,Math.floor(r/128)/128);e.set([...i,a*255],(n*128*128+r)*4)}}),e},Wo=[18,26],Go=8,Ko=40,qo=55,Jo=-60,Yo=[[1,.45,.12],[.2,.6,1],[.9,.15,.2],[.25,.85,.55]],Xo=({brushes:e})=>{let[t,n,r,i]=[0,2].flatMap(t=>[Math.min(...e.map(e=>e.min[t])),Math.max(...e.map(e=>e.max[t]))]),[a,o,s]=[(t+n)/2,(r+i)/2,Math.hypot(n-t,i-r)/2];return Wo.flatMap((e,t)=>Array.from({length:e},(n,r)=>{let i=e=>Fo(r,t,Go+e),c=(r+i(1)*.8)/e*2*Math.PI,l=s+Ko+t*qo+i(2)*30,[u,d]=[a+l*Math.cos(c),o+l*Math.sin(c)],[f,p]=[5+i(3)*8,5+i(4)*8],m=t?-5+i(5)**2*90:-20+i(5)*30,h=[y.GLASS,y.STEEL,y.CONCRETE][+(i(6)>.7)+ +(i(6)>.85)],g={min:[u-f,Jo,d-p],max:[u+f,m,d+p],top:y.CONCRETE,side:h};return i(7)<.35?[g,{min:[u-f/2,m,d-p/2],max:[u+f/2,m+3+i(8)*3,d+p/2],top:y.PAINT,side:y.PAINT,tint:Yo[Math.floor(i(9)*Yo.length)]}]:[g]}).flat())},Zo=r,Qo=o+.05,$o=1.5,es=.6,ts=8,ns=2.5,rs=3,is=.4,as=.012,os=.2,ss=[1.2,1.45],cs=[1.6,.12,.08],ls=[.9,.07,.05],us=[.85,.07,.05],ds=(e,t,n,r)=>{let i=-1/0;for(let a of e)if(a!=t&&a.min[0]<=n&&n<=a.max[0]&&a.min[2]<=r&&r<=a.max[2]){if(a.max[1]>t.max[1]+.001){if(a.min[1]<t.max[1])return 1/0}else i=Math.max(i,a.max[1])}return t.max[1]-i},fs=({brushes:e,floor:t},n)=>{let r=n.max.map((e,t)=>e-n.min[t]),i=[...r].sort((e,t)=>e-t),a={beam:i[1]<=es&&i[2]>=2*es,lips:[],stripes:[]};if(a.beam)return a;for(let i of[0,2]){let o=2-i;for(let t of[0,1]){let s=[n.min[0],0,n.min[2]];s[i]=(t?n.max:n.min)[i]+(t?is:-.4),s[o]=(n.min[o]+n.max[o])/2;let c=ds(e,n,s[0],s[2]);c>Zo&&c<=Qo&&r[o]>=$o&&a.lips.push([i,t])}n.min[1]>t&&r[1]>=ns&&r[o]>=ts&&r[i]<=rs&&a.stripes.push([i,0],[i,1])}return a},ps=(e,t,n,r,i,a,o)=>{let[s,c]=[(r+1)%3,(r+2)%3],l=[0,0,0];l[r]=i?1:-1;for(let[u,d]of[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]]){let f=[0,0,0];[f[r],f[s],f[c]]=[(i?n:t)[r],(u?n:t)[s],(d?n:t)[c]],e.push(...f,...l,o[0],o[1],a,o[2])}},ms=e=>{let t=[];for(let n of e.brushes){let{beam:r,lips:i,stripes:a}=fs(e,n),[o,s]=[n.min.map(e=>e-as),n.max.map(e=>e+as)];if(r)for(let e=0;e<3;e++)for(let n of[0,1])(e!=1||n)&&ps(t,o,s,e,n,-1,us);for(let[e,r]of i){let i=r?1:-1,a=(r?n.max:n.min)[e],o=[n.min[0],n.max[1]+as,n.min[2]],s=[n.max[0],n.max[1]+as,n.max[2]];[o[e],s[e]]=r?[a-os,a]:[a,a+os],ps(t,o,s,1,1,-2,cs);let[c,l]=[o.slice(),s.slice()];[c[1],l[1]]=[n.max[1]-os,n.max[1]],[c[e],l[e]]=[a+i*as,a+i*as],ps(t,c,l,e,r,-2,cs)}for(let[e,r]of a){let i=2-e,[a,o]=[[...n.min],[...n.max]];[a[1],o[1]]=[n.min[1]+ss[0],n.min[1]+ss[1]],[a[i],o[i]]=[n.min[i]+.3,n.max[i]-.3],a[e]=o[e]=(r?n.max:n.min)[e]+(r?as:-.012),ps(t,a,o,e,r,-2,ls)}}return t},hs=4.2,gs=({teams:e})=>{let t=[];return e.forEach(({base:[e,n,r]},i)=>{let a=Yt(i),o=a.map(e=>.25+.45*e),s=(i,a,o,s,c,l)=>ps(t,[e+i,n+l,r+a],[e+o,n+l,r+s],1,1,-1,c);s(-4.2,-4.2,hs,hs,o,.02);for(let[e,t,n,r]of[[-4.2,-4.2,hs,-3.85],[-4.2,3.85,hs,hs],[-4.2,-4.2,-3.85,hs],[3.85,-4.2,hs,hs]])s(e,t,n,r,a.map(e=>e*.8),.03)}),t},_s=1<<18,vs=2,ys=1024,bs=.6,xs=Math.tan(70*Math.PI/360),Ss=10,Cs=4,ws=`#version 300 es
|
|
1
|
+
var e=.4,t=1.8,n=1.55,r=.5,i=.9,a=7.5,o=2.4,s=5.5,c=2.5,l=[`Red`,`Blue`],u=[`#ff3d4f`,`#2f80ff`],d=1.5,f=.012,p=1.2,m={HOME:0,CARRIED:1,DROPPED:2},h={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,SPRINT:32,DASH:64,CROUCH:128,FIRE:256},g={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6},_={NONE:0,EAST:1,WEST:2,SOUTH:3,NORTH:4},v={JUMP:1,DOUBLE:2,DASH:4,LAND:8,GRAB:16,CLIMB:32,WALLRUN_START:64,WALLRUN_END:128,SLIDE_START:256,SLIDE_END:512,RESPAWN:1024},y={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11},b=-30,x=(e,t,n,r,i,a=y.CONCRETE)=>({min:[e,b,t],max:[n,i,r],top:y.CONCRETE,side:a}),S=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[x(4,57.7,24,76,10),x(4,36,24,53.5,10,y.GLASS),x(4,20,24,36,12.4),x(4,-5,24,7,12.4,y.GLASS),x(27,20,47,50,8),x(27,60,47,76,8,y.BRICK),S([9,12.2,39],[19,12.6,47],y.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>S([12,t,e-n],[14,t+.4*n,e-n+1],y.CONCRETE)))(53,10),S([5,10,42],[5.5,14,42.5],y.STEEL),S([5,10,50],[5.5,14,50.5],y.STEEL),S([8,12.4,24],[20,12.85,24.45],y.STEEL),S([36,8,22],[37,14.5,48],y.PAINT,y.PAINT,[.15,.72,.62]),S([30,8,28],[34,10,32],y.CONCRETE),S([40,8,30],[44,10.2,34],y.PAINT,y.PAINT,[1,.3,.06]),S([28,9.2,44],[35,12,46],y.STEEL,y.PAINT,[.2,.42,1]),S([41.5,7.6,50],[42,8,60],y.STEEL),S([30,8,64],[34,9.6,68],y.PAINT,y.PAINT,[.2,.8,.3])];var C=240,w=[1,.22,.26],T=[.2,.46,1],E=[1,.42,.08],D=[.12,.7,.62],O=(e,t,n,r,i,a,o)=>S([e,t,n],[r,i,a],y.PAINT,y.PAINT,o),k=(e,t,n,r,i,a,o,s=b)=>{let c=Math.ceil((o-a)/.46);return Array.from({length:c},(l,u)=>{let[d,f]=[t+(n-t)*u/c,t+(n-t)*(u+1)/c].sort((e,t)=>e-t),p=a+(o-a)*(u+1)/c;return e===0?S([d,s,r],[f,p,i],y.CONCRETE):S([r,s,d],[i,p,f],y.CONCRETE)})},A=(e,t,n,r,i,a,o)=>o.map((o,s)=>S([e+s*n,a,t+s*r],[e+s*n+4,o,t+s*r+i],y.STEEL,y.CONCRETE)),j=[x(12,212,52,240,26,y.GLASS),O(12,26,212,52,26.12,212.5,w),O(12,26,239.5,52,26.12,240,w),O(12,26,212.5,12.5,26.12,239.5,w),O(51.5,26,212.5,52,26.12,239.5,w),O(11.6,12,222,12,25.8,232,w),O(28,12,211.4,31,25.5,212,w),S([19,26,222],[22,27.4,225],y.STEEL),S([42,26,222],[45,27.4,225],y.STEEL),S([29,26,229],[35,27.1,229.6],y.CONCRETE),x(6,164,26,201,26,y.GLASS),x(6,134,26,147,26,y.GLASS),x(6,201,26,212,19),x(15,147,26,164,19),S([14,26,164],[15,32,196],y.PAINT,y.PAINT,D),S([14,18,147],[15,32,164],y.PAINT,y.PAINT,D),S([14,26,134],[15,32,147],y.PAINT,y.PAINT,D),...A(6,201,7,0,4,19,[21.2,23.4,25]),...[[18,152,22,156,21.2],[18,158,22,162,23.4],[23,160,26,164,25]].map(([e,t,n,r,i])=>S([e,19,t],[n,i,r],y.STEEL,y.CONCRETE)),S([20,26,178],[23,27.3,181],y.STEEL),S([8,26,176],[11,27.2,179],y.STEEL),S([8,26,190],[11,27.3,193],y.STEEL),S([20,26,140],[23,27.3,143],y.STEEL),x(32,186,76,209,19),O(32,19,207.5,76,19.1,209,w),...A(33,209,7,0,3,19,[21.2,23.4,25]),...[[28,196,32,200,21.2],[28,190,32,194,23.4],[26,184,30,188,25]].map(([e,t,n,r,i])=>S([e,b,t],[n,i,r],y.STEEL,y.CONCRETE)),x(32,166,64,182,21.2,y.GLASS),x(32,140,64,161,19),S([40,21.2,172],[44,22.6,176],y.STEEL),S([52,19,148],[57,20.3,151],y.STEEL),S([38,19,196],[41,20.4,199],y.STEEL),S([60,19,200],[63,20.4,203],y.STEEL),S([52,19,190],[58,20.6,194],y.STEEL),S([66,19,204],[72,20.2,207],y.STEEL),S([56,21.2,170],[60,22.4,174],y.STEEL),S([34,19,152],[37,20.3,156],y.STEEL),...A(36,135,18,0,3,15,[17.2,17.2]),...A(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),x(76,213,100,240,14.5,y.STEEL),O(76,14.5,238.5,100,14.6,240,w),x(76,185,100,209,14.5),x(76,138,100,181,14.5,y.GLASS),S([80,15.7,158],[96,17.7,162],y.STEEL,y.PAINT,E),S([82,14.5,234],[85,15.9,237],y.STEEL),S([91,14.5,190],[94,15.9,193],y.STEEL),S([80,14.5,204],[83,15.6,207],y.STEEL),S([78,14.5,170],[81,15.9,173],y.STEEL),S([92,14.5,146],[95,15.7,149],y.STEEL),S([92,14.5,222],[96,15.8,226],y.STEEL),...k(0,76,52,226,232,14.5,26),...k(0,85,76,196,202,14.5,19,14.5)],ee=[x(6,106,62,134,15),x(62,106,100,134,14.5),S([34,15,112],[54,17.2,128],y.CONCRETE),O(38,17.2,116,50,17.3,124,E),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>S([e,17.2,t],[e+.8,21.5,t+.8],y.STEEL)),S([34.6,21.5,112.6],[52.2,21.9,127.4],y.GLASS),S([14,15,114],[17,16.5,117],y.STEEL),S([14,15,123],[17,16.5,126],y.STEEL),S([56,15,114],[59,16.5,117],y.STEEL),S([56,15,123],[59,16.5,126],y.STEEL),S([15.35,25.5,106],[15.85,26,134],y.STEEL),S([70,14.5,108],[70.8,38,108.8],y.STEEL),S([70,14.5,131.2],[70.8,38,132],y.STEEL),S([66,14.5,110],[69,15.9,113],y.STEEL),S([66,14.5,127],[69,15.9,130],y.STEEL)],M=e=>({...e,min:[e.min[0],e.min[1],C-e.max[2]],max:[e.max[0],e.max[1],C-e.min[2]],tint:e.tint===w?T:e.tint}),N=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],P=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],F=[[21,26,168],[46,19,144],[36,21.2,178],[88,14.5,216],[88,14.5,172]],I={name:`Highline`,brushes:[...j,...j.map(M),...ee],teams:[{base:[32,26,224],spawns:N(0,236,231),rack:[47,26,234]},{base:[32,26,16],spawns:N(Math.PI,4,9),rack:[47,26,6]}],packs:[...P,...P.map(([e,t,n])=>[e,t,C-n]),[24,15,112],[24,15,128]],ammo:[...F,...F.map(([e,t,n])=>[e,t,C-n])],floor:-25,sun:{dir:[.8,.6,0],color:[2.6,2.3,1.8]},sky:[[.04,.2,.72],[.72,.86,.98]],fog:[.72,.86,.98,.0035]},L=4,R=1024,z=(e,t)=>(e+R)*(2*R)+t+R,B=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),te=(e,t=L)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=B(e[0],t);a<=B(r[0],t);a++)for(let o=B(e[2],t);o<=B(r[2],t);o++){let e=z(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),{def:e,cell:t,grid:n}},ne=(e,t,n,r)=>{let i=[];for(let a=B(t-r,e.cell);a<=B(t+r,e.cell);a++)for(let t=B(n-r,e.cell);t<=B(n+r,e.cell);t++)for(let n of e.grid.get(z(a,t))??[])i.includes(n)||i.push(n);return i},re=(e,t,n,r)=>{let{cell:i,def:a}=e,o=r,s=B(t[0],i),c=B(t[2],i),l=Math.sign(n[0]),u=Math.sign(n[2]),d=l?((s+ +(l>0))*i-t[0])/n[0]:1/0,f=u?((c+ +(u>0))*i-t[2])/n[2]:1/0,p=d,m=f,h=l?i/Math.abs(n[0]):1/0,g=u?i/Math.abs(n[2]):1/0;for(;;){for(let r of e.grid.get(z(s,c))??[]){let e=a.brushes[r],[i,s]=[0,o];for(let r=0;r<3&&i<=s;r++){if(!n[r]){(t[r]<e.min[r]||t[r]>e.max[r])&&(s=-1);continue}let a=(e.min[r]-t[r])/n[r],o=(e.max[r]-t[r])/n[r];i=Math.max(i,Math.min(a,o)),s=Math.min(s,Math.max(a,o))}i<=s&&s>0&&i<o&&(o=i)}if(Math.min(p,m)>=o||Math.abs(s)>R||Math.abs(c)>R)return o;p<m?(s+=l,p+=h):(c+=u,m+=g)}},ie=(e,t,n)=>{let[r,i,a]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],o=Math.hypot(r,i,a);return o>0&&re(e,t,[r/o,i/o,a/o],o)<o-1e-4},V=1/60,H=Math.PI*2,U=1e-6,W=.01,ae=.001,oe=e=>(e%H+H)%H,se=e=>[-Math.sin(e),-Math.cos(e)],ce=Math.fround,le=Math.sqrt,ue=(e,t,n)=>Math.min(Math.max(e,t),n),G=(e,t)=>le(e*e+t*t),de=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],fe={vx:0,vz:0,mode:g.GROUND,t:0,wall:_.NONE,edge:0,jumps:1,dashes:1,dash:0,stun:0,coyote:6,buffer:0,held:0,hp:5,ammo:-1,cool:0,rack:!1,down:0,shots:0,hits:0,ev:0,fall:0},pe=(e,t,n,r=0)=>{let{spawns:i}=t.def.teams[r],[a,o,s,c]=i[(n%i.length+i.length)%i.length];return{id:e,x:ce(a),y:ce(o),z:ce(s),vy:0,yaw:oe(c),pitch:0,ground:!0,...fe}},me=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:o,hits:s}=e;Object.assign(e,pe(a,t,a,n),{yaw:r,pitch:i,shots:o,hits:s,ev:e.ev|v.RESPAWN})},he=e=>e===g.GROUND||e===g.SLIDE||e===g.CROUCH,ge=e=>e.mode===g.SLIDE||e.mode===g.CROUCH?i:t,_e=e=>e.mode===g.SLIDE||e.mode===g.CROUCH?.7:1.6,ve=e=>G(e.vx,e.vz),ye=e=>e.mode===g.GROUND&&G(e.vx,e.vz)>6.5,be=(e,t,n)=>e.max[1]>t+.5+W&&e.min[1]<t+n-W,xe=(e,t,n)=>[t-ue(t,e.min[0],e.max[0]),n-ue(n,e.min[2],e.max[2])],Se=(t,n,r)=>{let{brushes:i}=n.def,a=ne(n,t.x,t.z,2*e),o=(e-U)**2,[s,c]=[0,0];for(let n=0;n<4;n++){let n=0,l=0,u=0;for(let s of a){let a=i[s];if(!be(a,t.y,r))continue;let[c,d]=xe(a,t.x,t.z),f=c*c+d*d;if(f>=o)continue;if(f){let t=le(f);.4-t>n&&(n=e-t,l=c/t*n,u=d/t*n);continue}let[p,m,h]=[[t.x-a.min[0],-1,0],[a.max[0]-t.x,1,0],[t.z-a.min[2],0,-1],[a.max[2]-t.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);p+.4>n&&(n=p+e,[l,u]=[m*n,h*n])}if(!n)break;t.x+=l,t.z+=u,s+=l,c+=u}return[s,c]},Ce=(t,n,r)=>{let{brushes:i}=n.def,a=(e-U)**2,o=-1/0,s=1/0;for(let c of ne(n,t.x,t.z,e)){let e=i[c],[n,l]=xe(e,t.x,t.z);n*n+l*l>=a||(e.max[1]<=t.y+.5+W?o=Math.max(o,e.max[1]):e.min[1]>=t.y+r-W&&(s=Math.min(s,e.min[1])))}return[o,s]},we=(t,n)=>{let r=(e-U)**2;return ne(n,t.x,t.z,e).every(e=>{let i=n.def.brushes[e],[a,o]=xe(i,t.x,t.z);return a*a+o*o>=r||!be(i,t.y,1.8)})},Te=(t,n,r,i,a)=>{let o=(e-U)**2;return ne(t,n,r,e).every(e=>{let s=t.def.brushes[e],[c,l]=xe(s,n,r);return c*c+l*l>=o||s.max[1]<=i||s.min[1]>=a})},Ee=(e,t)=>{let[n,r]=de[t],i=n?0:2;return{a:i,o:2-i,sign:n||r,c:n?e.x:e.z,co:n?e.z:e.x}},De=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=Ee(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-ae&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},Oe=(t,n,r)=>{let i;for(let a of ne(n,t.x,t.z,.9)){let o=n.def.brushes[a],s=De(o,t,r,.5);s!==void 0&&o.min[1]<t.y+.5&&o.max[1]>t.y+1.8&&(i=Math.min(i??1/0,Math.max(0,s-e)))}return i},ke=(e,t)=>{let[n,r]=se(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=de[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=Ee(e,a);for(let n of ne(t,e.x,e.z,.6000000000000001)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(De(r,e,a,.2)===void 0||s<1.2||s>2.4||r.min[1]>o-.25||i&&i.top>=o)continue;let u=l>0?r.min[c]:r.max[c],d=u-l*.43000000000000005,f=u+l*.2,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Te(t,p,m,Math.min(e.y,o-2)+W,o+1.8)&&Te(t,h,g,o+W,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},Ae=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=Ee(e,e.wall);return ne(t,e.x,e.z,0).some(s=>{let c=t.def.brushes[s],l=i>0?a-c.min[n]:c.max[n]-a;return ce(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},je=(e,n)=>{if(e.vy>=0)return!1;let[r]=Ce(e,n,t),i=6*V;return e.y-r<=-e.vy*i+10*i*i},Me=(e,t)=>{e.mode=t,e.t=0},Ne=(e,t)=>{let n=G(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},Pe=(t,n,r,i)=>{let[a,o]=[r.wx,r.wz];for(let r of ne(n,t.x,t.z,e+ae)){let e=n.def.brushes[r],[s,c]=xe(e,t.x,t.z),l=G(s,c);if(l>0&&l<=.4+ae&&be(e,t.y,i)){let e=(-a*s-o*c)/l;e>0&&(a+=e*s/l,o+=e*c/l)}}return[a,o]},Fe=(e,t,n)=>{let r=G(t[0],t[1]);if(r<U){let t=G(e.vx,e.vz),n=t?Math.max(0,t-45*V)/t:0;e.vx*=n,e.vz*=n;return}let[i,a]=[t[0]/r,t[1]/r],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a],l=G(s,c);if(l){let e=Math.max(0,l-45*V)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*V):Math.max(n,o-12*V),e.vx=s+o*i,e.vz=c+o*a},Ie=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*V,e.z+=e.vz*V;let[o,s]=Se(e,t,n),c=G(o,s);if(c){let t=(e.vx*o+e.vz*s)/c;t<0&&(e.vx-=t*o/c,e.vz-=t*s/c)}let[l,u]=Ce(e,t,n),d=e.vy-r*20*V;if(e.y+=(e.vy+d)/2*V,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+W:e.y<l){if(e.y=l,e.vy<=0){let t=-e.vy;return e.vy=0,t}}else if(i&&e.vy<=0&&l>=a-.5)return e.y=l,e.vy=0,0;return-1},Le=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=v.JUMP},Re=(e,n,r)=>{let[i,a]=de[e.wall],o=t=>{Me(e,t),e.edge=0};if(r.keys&(h.BACK|h.CROUCH))o(g.AIR),e.coyote=0;else if(r.jump&&r.fx*i+r.fz*a<0)o(g.AIR),e.vx=-i*4,e.vz=-a*4,Le(e,6);else if(r.jump||r.fwd&&e.t>=6)Me(e,g.CLIMB);else if(e.t>=30)o(g.AIR),e.coyote=0;else{let r=Math.max(e.edge-2,Ce(e,n,t)[0]);e.y+=ue(r-e.y,-8*V,8*V)}},ze=(e,t)=>{let[n,r]=de[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*V):(e.x+=n*s*V,e.z+=r*s*V),e.y>=e.edge&&Ae(e,t)?(Me(e,g.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=_.NONE,e.coyote=6,e.ev|=v.CLIMB):e.t>=40&&(Me(e,e.y>=e.edge?g.GROUND:g.AIR),e.edge=0,e.wall=_.NONE)},Be=(e,t,n)=>{let[r,i]=de[e.wall],a=e.vx*r+e.vz*i,[o,s]=[e.vx-a*r,e.vz-a*i],c=G(o,s);if(n.jump)Me(e,g.AIR),e.vx=o-r*5,e.vz=s-i*5,Le(e,6.5),e.jumps=1,e.dashes=1,e.ev|=v.WALLRUN_END;else{let a=Oe(e,t,e.wall);if(a===void 0||!n.fwd||c<3.5||e.t>=60){Me(e,g.AIR),e.ev|=v.WALLRUN_END;return}let l=Math.max(0,c-1.5*V)/c;e.vx=o*l,e.vz=s*l;let u=Math.min(a,4*V);e.x+=r*u,e.z+=i*u}},Ve=(e,t,n)=>{if(!n.fwd)return;let r=G(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[i,a]=de[n],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a];if(n!==e.wall&&o<=.75*r&&o>=-.2*r&&Oe(e,t,n)!==void 0){let t=G(s,c),i=Math.max(t,.9*r)/t;Me(e,g.WALLRUN),e.wall=n,[e.vx,e.vz]=[s*i,c*i],e.vy=ue(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=v.WALLRUN_START;return}}},He=(e,t)=>{Me(e,g.HANG),e.wall=t.side,e.edge=ce(t.top),t.side<=_.WEST?e.x=t.hang:e.z=t.hang,e.vx=e.vy=e.vz=0,e.jumps=1,e.dashes=1,e.coyote=0,e.buffer=0,e.ev|=v.GRAB},Ue=(e,t,n)=>{let r=e.mode===g.GROUND;if(n.dash&&e.dash===0&&(r||(e.mode===g.AIR||e.mode===g.WALLRUN)&&e.dashes>0)){let[t,i]=n.wx||n.wz?[n.wx,n.wz]:[n.fx,n.fz];r||(e.dashes--,e.vy=0,e.mode===g.WALLRUN&&(Me(e,g.AIR),e.ev|=v.WALLRUN_END)),e.vx=t*16,e.vz=i*16,e.dash=60,e.ev|=v.DASH}let i=e.dash>50;e.mode===g.WALLRUN&&Be(e,t,n),he(e.mode)&&We(e,t,n,i),e.mode===g.AIR&&Ge(e,t,n,i);let o=i&&e.vy<=0?0:e.mode===g.WALLRUN?.15:1,s=e.mode,c=Ie(e,t,ge(e),o,he(s));if(c>=0){if(!he(e.mode)){if(e.ev|=v.LAND|(e.mode===g.WALLRUN?v.WALLRUN_END:0),e.fall=c,e.jumps=1,e.dashes=1,e.wall=_.NONE,n.keys&h.CROUCH){let t=G(e.vx,e.vz)>=a;Me(e,t?g.SLIDE:g.CROUCH),e.ev|=t?v.SLIDE_START:0}else Me(e,g.GROUND)}e.coyote=6}else he(e.mode)&&(e.ev|=e.mode===g.SLIDE?v.SLIDE_END:0,Me(e,g.AIR));if(e.mode===g.AIR){let r=ke(e,t);r?He(e,r):Ve(e,t,n)}},We=(e,n,r,o)=>{let s=(r.keys&h.CROUCH)!==0;if(e.buffer>0&&(e.mode===g.GROUND||we(e,n))){e.ev|=e.mode===g.SLIDE?v.SLIDE_END:0,Me(e,g.AIR),Le(e,7);return}let l=G(e.vx,e.vz);if(e.mode===g.GROUND&&s){let t=l>=a;Me(e,t?g.SLIDE:g.CROUCH),e.ev|=t?v.SLIDE_START:0}else e.mode===g.SLIDE&&(e.t>=60||l<4.5||r.stumble)?(e.ev|=v.SLIDE_END,Me(e,!s&&we(e,n)?g.GROUND:g.CROUCH)):e.mode===g.SLIDE&&!s&&we(e,n)?(e.ev|=v.SLIDE_END,Me(e,g.GROUND)):e.mode===g.CROUCH&&!s&&we(e,n)&&Me(e,g.GROUND);if(!o){if(r.stumble){if(l>2.5){let t=Math.max(c,l-12*V)/l;e.vx*=t,e.vz*=t}else Fe(e,Pe(e,n,r,ge(e)),c)}else if(e.mode===g.SLIDE){let t=Math.max(0,l-4*V)/l;e.vx*=t,e.vz*=t}else if(e.mode===g.CROUCH)Fe(e,Pe(e,n,r,i),3);else{let i=(r.keys&h.SPRINT)!==0&&r.fwd;Fe(e,Pe(e,n,r,t),i?9:6)}}},Ge=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?Le(e,7):e.jumps>0&&!je(e,t)&&(e.jumps--,Le(e,6),e.ev=e.ev&~v.JUMP|v.DOUBLE)),r||!n.wx&&!n.wz)return;let i=G(e.vx,e.vz);e.vx+=n.wx*14*V,e.vz+=n.wz*14*V,Ne(e,Math.max(i,6))},Ke=(e,t,r,i=0)=>{e.yaw=oe(t.yaw),e.pitch=Math.max(-1.55,Math.min(n,t.pitch));let a=(t.keys&h.FORWARD?1:0)-(t.keys&h.BACK?1:0),o=(t.keys&h.RIGHT?1:0)-(t.keys&h.LEFT?1:0),s=G(a,o)||1,[c,l]=se(e.yaw),u=n=>(t.keys&n)!==0&&(e.held&n)===0,d=e.stun>0,f={keys:t.keys,stumble:d,jump:!d&&u(h.JUMP),dash:!d&&u(h.DASH),fwd:a>0,wx:(c*a-l*o)/s,wz:(l*a+c*o)/s,fx:c,fz:l},p=e.mode;e.ev=0,e.fall=0,f.jump&&(e.buffer=7),d&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&Ne(e,10)),e.mode===g.HANG&&Re(e,r,f),e.mode===g.CLIMB?ze(e,r):e.mode!==g.HANG&&Ue(e,r,f),e.y<r.def.floor&&me(e,r,i),e.t=e.mode===p?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===g.AIR&&p===g.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=t.keys&(h.JUMP|h.DASH),e.ground=he(e.mode),e.x=ce(e.x),e.y=ce(e.y),e.z=ce(e.z),e.vx=ce(e.vx),e.vy=ce(e.vy),e.vz=ce(e.vz),e.edge=ce(e.edge)},qe=127,Je=16,Ye=65536/(2*Math.PI),Xe=e=>Math.round(e*Ye)&65535,Ze=e=>Math.max(-32768,Math.min(32767,Math.round(e))),Qe=e=>Ze(e*1e4),$e=e=>e/1e4,et=e=>e/Ye,tt=(e=0)=>Math.round(e*256)&16777215,nt=e=>({...e,yaw:et(Xe(e.yaw)),pitch:$e(Qe(e.pitch)),...e.view!==void 0&&{view:tt(e.view)/256}}),rt=e=>{let t=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(12));t.setUint8(0,1),t.setUint16(1,e.seq&65535),t.setUint16(3,e.keys&511),t.setUint16(5,Xe(e.yaw)),t.setInt16(7,Qe(e.pitch));let n=tt(e.view);return t.setUint16(9,n>>8),t.setUint8(11,n&255),t.buffer},it=e=>e===m.CARRIED?2:e===m.DROPPED?8:1,at=e=>{if(e.byteLength<4)return null;let t=new DataView(e),n=t.getUint8(3),r=4+45*n;if(t.getUint8(0)!==2||e.byteLength<r+8+2)return null;let i=[];for(let e=0;e<n;e++){let n=4+e*45,r=t.getUint8(n+35),a=t.getUint8(n+38),[o,s]=[t.getUint8(n+37),t.getUint8(n+39)],c=r&7,l=t.getUint8(n+40)<<16|t.getUint16(n+41);i.push({id:t.getUint8(n),x:t.getFloat32(n+1),y:t.getFloat32(n+5),z:t.getFloat32(n+9),vx:t.getFloat32(n+13),vy:t.getFloat32(n+17),vz:t.getFloat32(n+21),edge:t.getFloat32(n+25),yaw:et(t.getUint16(n+29)),pitch:$e(t.getInt16(n+31)),ack:t.getUint16(n+33),ground:c===g.GROUND||c===g.SLIDE||c===g.CROUCH,mode:c,wall:r>>3&7,jumps:r>>6&1,dashes:r>>7,t:t.getUint8(n+36),dash:o&63,stun:s&63,by:o>>6<<2|s>>6,coyote:a&7,buffer:a>>3&7,held:(a&64?h.JUMP:0)|(a&128?h.DASH:0),ev:0,fall:0,hp:l&7,cool:l>>3&7,ammo:(l>>6&127)===qe?-1:l>>6&127,down:l>>13&127,rack:(l>>20&1)==1,shots:t.getUint8(n+43),hits:t.getUint8(n+44)})}let a=t.getUint16(r+2),o=r+8,s=[];for(let n=0;n<2;n++){let n=o<e.byteLength?t.getUint8(o):-1;if(n<0||n>m.DROPPED||o+it(n)>e.byteLength)return null;let r={state:n,by:0,x:0,y:0,z:0,left:0};n===m.CARRIED?r.by=t.getUint8(o+1):n===m.DROPPED&&([r.x,r.y,r.z]=[1,3,5].map(e=>t.getInt16(o+e)/Je),r.left=t.getUint8(o+7)),s.push(r),o+=it(n)}return o===e.byteLength?{tick:t.getUint16(1),players:i,score:[t.getUint8(r),t.getUint8(r+1)],clock:a&32767,over:!!(a&32768),flags:s,packs:t.getUint32(r+4)}:null},ot=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},st=44100,ct=([e,t,n,r,i,a,o,s,c,l,u],d)=>{let f=new Float32Array(Math.ceil((r+i+a)*st)),p=0,m=0,h=0,g=()=>{d=d+1831565813|0;let e=Math.imul(d^d>>>15,1|d);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/2**31-1};for(let d=0;d<f.length;d++){let _=d/st;p+=t*2**(n*_)*(_>c?l:1)*(1+o*Math.sin(_*44))/st,p>=1&&(p%=1,h=g());let v=e==3?h:e==2?Math.sin(p*2*Math.PI):e?1-2*p:p<.5?1:-1;m+=(v-m)*s;let y=_<r?_/r:_<r+i?1:((r+i+a-_)/a)**2;f[d]=m*y*u}return f},K={STEP:0,WALLSTEP:1,JUMP:2,DOUBLE:3,DASH:4,LAND:5,GRAB:6,SCUFF:7,WIND:8,SCRAPE:9,TAKE:10,DROP:11,RETURN:12,CAPTURE:13,TACKLE:14,GRUNT:15,LASER:16,HIT:17,HURT:18,DOWN:19,GUN:20,PACK:21,DRY:22},lt=[[[2,130,-3,.001,.005,.06,0,1,0,1,.7],[3,8e3,-1,.001,0,.035,0,.4,0,1,.45]],[[3,12e3,0,.001,0,.03,0,.5,0,1,.4],[2,190,-3,.001,0,.04,0,1,0,1,.3]],[[3,14e3,0,.015,.02,.09,.3,.18,0,1,.5],[2,70,-2,.003,0,.07,0,1,0,1,.3]],[[3,4e3,3.5,.03,.03,.2,0,.25,0,1,.5],[2,350,1.2,.03,.02,.18,.02,1,0,1,.12]],[[3,14e3,-2.5,.008,.07,.2,.25,.3,0,1,.8],[3,3500,.5,.01,.06,.2,0,.12,0,1,.5]],[[2,70,-2.5,.001,.01,.2,0,1,0,1,.9],[3,7e3,-1,.001,0,.09,0,.25,0,1,.5]],[[3,6e3,-1,.001,0,.05,0,.5,0,1,.7],[2,160,-4,.001,0,.07,0,1,0,1,.5]],[[3,5e3,0,.01,.04,.14,.5,.3,0,1,.5],[3,2500,0,.03,0,.1,.4,.2,0,1,.3,.08]],[[3,2e4,0,.001,2.1,.001,.25,.06,0,1,1.2],[3,2e4,0,.001,2.1,.001,.35,.3,0,1,.3]],[[3,9e3,0,.001,2.1,.001,.5,.4,0,1,.5],[3,3e3,0,.001,2.1,.001,.4,.2,0,1,.5]],[[0,392,0,.003,.05,.08,0,.35,.07,1.5,.5],[2,784,0,.003,.03,.1,.01,1,0,1,.3,.05]],[[1,330,-2.2,.003,.04,.22,.04,.25,0,1,.45],[3,2500,-1,.001,0,.12,0,.3,0,1,.4]],[[2,659,0,.003,.06,.25,.015,1,.09,1.5,.5],[2,1318,0,.003,.03,.2,0,1,0,1,.2,.09]],[[0,523,0,.004,.07,.1,0,.3,0,1,.4],[0,659,0,.004,.07,.1,0,.3,0,1,.4,.11],[0,784,0,.004,.07,.1,0,.3,0,1,.4,.22],[0,1047,0,.004,.2,.35,.008,.3,0,1,.5,.33],[2,262,0,.004,.25,.3,0,1,0,1,.35,.33]],[[2,120,-3,.001,.01,.24,0,1,0,1,1],[3,5e3,-1.5,.001,0,.09,0,.35,0,1,.7],[3,2200,0,.01,.03,.16,.3,.15,0,1,.4,.03]],[[1,170,-.9,.012,.05,.17,.06,.2,0,1,.5],[3,3e3,0,.01,.04,.14,.4,.12,0,1,.5]],[[1,3600,-10,.001,.01,.09,0,.5,0,1,.4],[0,1900,-8,.001,0,.06,0,.3,0,1,.25],[3,9e3,0,.001,0,.03,0,.4,0,1,.25]],[[2,1700,0,.001,0,.13,0,1,0,1,.6],[2,4700,0,.001,0,.05,0,1,0,1,.3],[2,1790,0,.001,0,.09,0,1,0,1,.3]],[[2,110,-2.5,.002,.01,.2,0,1,0,1,.9],[3,2500,0,.02,.03,.17,.3,.12,0,1,.5,.04]],[[2,90,-1.2,.002,.04,.45,0,1,0,1,.9],[1,180,-1.5,.01,.06,.4,.05,.2,0,1,.45],[3,3e3,0,.02,0,.35,.3,.1,0,1,.4,.12]],[[3,5e3,0,.001,0,.02,0,.5,0,1,.5],[0,260,1.5,.005,.06,.12,0,.25,0,1,.4,.02],[2,1040,.5,.003,.03,.18,.01,1,0,1,.25,.1]],[[2,523,0,.003,.03,.1,0,1,0,1,.4],[2,659,0,.003,.03,.1,0,1,0,1,.4,.07],[2,880,0,.003,.05,.2,.01,1,0,1,.45,.14]],[[0,190,-3,.001,0,.04,0,.6,0,1,.6],[3,6e3,0,.001,0,.02,0,.5,0,1,.5]]],ut=[K.WIND,K.SCRAPE],dt=(e,t=lt)=>{let n=t[e].map((t,n)=>[ct(t,e*9+n),Math.round((t[11]??0)*st)]);return Float32Array.from({length:Math.max(...n.map(([e,t])=>t+e.length))},(e,t)=>Math.tanh(n.reduce((e,[n,r])=>e+(n[t-r]??0),0)))},ft=(e,t=st/10)=>{let n=e.length-t;return Float32Array.from({length:n},(r,i)=>i<t?e[i]*Math.sqrt(i/t)+e[n+i]*Math.sqrt(1-i/t):e[i])},pt=st*60/108,mt=pt/4,ht=4,gt=[2,150,-6,.002,0,.25,0,1,0,1,1],_t=[3,9e3,0,.002,0,.15,0,.5,0,1,.5],vt=[3,3e4,0,.001,0,.04,0,.7,0,1,.15],yt=()=>{let e=new Float32Array(pt*4*ht),t={},n=(n,r)=>(t[String(r)]??=ct(r,1)).forEach((t,r)=>e[(n*mt+r)%e.length]+=t),r=e=>55*2**(e/12),i=[0,0,-4,-5],a=[0,0,12,0,0,7,12,7];for(let e=0;e<64;e++){let t=e%16;if(`x.......x.x.....`[t]==`x`&&n(e,gt),`....x.......x...`[t]==`x`&&n(e,_t),t%2==0){n(e,vt);let o=i[e>>4]+a[t>>1];n(e,[1,r(o),0,.005,.08,.18,0,.15,0,1,.6])}}[15,12,10,19,17,15].forEach((e,t)=>n([18,24,28,50,54,60][t],[2,r(e+24),0,.02,.1,.6,.01,1,0,1,.5]));let o=e.reduce((e,t)=>Math.max(e,Math.abs(t)),0);return e.map(e=>e/o*.35)},bt=40,xt=24,St=.5,Ct=`tiny-fps:muted`,wt=()=>{let e=!1;return{unlock:()=>{},listen:()=>{},play:()=>{},loop:()=>({set:()=>{}}),mute:t=>{e=t},get muted(){return e},destroy:()=>{}}},Tt=(e=lt)=>{let t;try{t=new AudioContext}catch{return wt()}let n=(e,n=1)=>{let r=t.createGain();return r.gain.value=n,r.connect(e),r},r=n(t.destination),i=n(r,St),a=[],o=!1,s=/* @__PURE__ */ new Set,c=[0,0,0],l=0,u=!1,d=e=>{let n=t.createBuffer(1,e.length,st);return n.getChannelData(0).set(e),n},f=e=>{let n=t.createBufferSource();return n.buffer=e,n};return{unlock(){if(t.resume().catch(()=>{}),!o){o=!0,e.forEach((t,n)=>{let r=dt(n,e);a[n]=d(ut.includes(n)?ft(r):r)});let t=f(d(yt()));t.loop=!0,t.connect(i),t.start()}},listen(e,t){[c,l]=[e,t]},play(e,i,o=1,u=1){let d=0,p=o;if(i){let[e,t,n]=i.map((e,t)=>e-c[t]),r=Math.hypot(e,t,n);p=Math.max(0,1-r/bt)**2*o,d=(e*Math.cos(l)-n*Math.sin(l))/Math.max(r,1)}let m=a[e];if(!m||!p)return;if(s.size>=xt){let e=[...s].reduce((e,t)=>t.vol<e.vol?t:e);if(e.vol>=p)return;e.src.stop(),s.delete(e)}let h=f(m);h.playbackRate.value=u;let g=t.createStereoPanner();g.pan.value=d,h.connect(g).connect(n(r,p));let _={vol:p,src:h};s.add(_),h.onended=()=>s.delete(_),h.start()},loop(e){let i,o;return{set(s,c){!i&&a[e]&&(i=f(a[e]),i.loop=!0,i.connect(o=n(r,0)),i.start()),i&&(o.gain.setTargetAtTime(s,t.currentTime,.08),i.playbackRate.setTargetAtTime(c,t.currentTime,.08))}}},mute(e){u=e,r.gain.setTargetAtTime(+!e,t.currentTime,.05)},get muted(){return u},destroy:()=>void t.close().catch(()=>{})}},Et=()=>{try{return localStorage.getItem(Ct)==`1`}catch{return!1}},Dt=e=>{e.mute(!e.muted);try{localStorage.setItem(Ct,e.muted?`1`:`0`)}catch{}return e.muted},q=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Ot=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],kt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],At=(e,t,n)=>[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n],jt=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Mt=(e,t,n=0)=>{let[r,i,a,o,s,c]=[e,t,n].flatMap(e=>[Math.sin(e),Math.cos(e)]),l=[i,0,-r],u=[r*a,o,i*a];return[l.map((e,t)=>e*c-u[t]*s),u.map((e,t)=>e*c+l[t]*s),[-r*o,a,-i*o]]},Nt=(e,t,n=[0,0,0])=>{let r=[],i=e.filter((t,n)=>!n||Math.hypot(t[0]-e[n-1][0],t[1]-e[n-1][1])>1e-9),a=i.slice(1).map(([e,t],n)=>{let[r,a]=i[n],o=Math.hypot(e-r,t-a);return[(t-a)/o,-(e-r)/o]}),o=i.map(([e],t)=>{let[n,r]=[0,1].map(e=>(a[t-1]?.[e]??0)+(a[t]?.[e]??0)),i=Math.hypot(n,r);return e?[n/i,r/i]:[0,Math.sign(r)]}),s=(e,a)=>{let[s,c]=i[a],[l,u]=[Math.cos(e*H/t),Math.sin(e*H/t)];r.push(n[0]+s*l,n[1]+s*u,n[2]-c,o[a][0]*l,o[a][0]*u,-o[a][1])};for(let e=1;e<i.length;e++)for(let n=0;n<t;n++)[...i[e-1][0]?[[n,e-1],[n+1,e-1],[n+1,e]]:[],...i[e][0]?[[n,e-1],[n+1,e],[n,e]]:[]].forEach(([e,t])=>s(e,t));return r},Pt=(e,t,n,[r,i],a)=>{let o=(e,t,n,r)=>Array.from({length:t},(i,a)=>{let o=a*H/t/4;return[e*Math.sin(o),n-r*e*Math.cos(o)]});return Nt([...r?o(t[0],r,0,1):[[0,0]],...t.map((n,r)=>[n,e*r/(t.length-1)]),...i?o(t[t.length-1],i,e,-1).reverse():[[0,e]]],n,a)},Ft=(e,[t,n,r])=>Array.from({length:e.length*(10/6)},(i,a)=>{let[o,s]=[Math.floor(a/10),a%10];return s<6?e[o*6+s]:[t,n,-1,r][s-6]}),It=[[5,1],[7,2],[10,3]],Lt=/* @__PURE__ */ new Map,Rt=(e,t,n,r=[1,1])=>{let[i,a]=It[e];!e&&n.length>3&&(n=[n[0],n[n.length>>1],n[n.length-1]]);let o=`${e} ${t} ${n} ${r}`,s=Lt.get(o);return s||(s=Ft(Pt(t,n,i,r.map(e=>Math.ceil(a*e))),[1,1,1]),Lt.set(o,s)),s},zt=(e,t,n,[r,i,a],o,s,c=[1,1,1])=>{let[l,u,d]=typeof s==`number`?[s,s,s]:s,f=l==u&&u==d,[p,m,h,g,_,v,y,b,x]=[...r,...i,...a],S=n[0]+p*o[0]+g*o[1]+y*o[2],C=n[1]+m*o[0]+_*o[1]+b*o[2],w=n[2]+h*o[0]+v*o[1]+x*o[2];for(let n=0;n<t.length;n+=10){let[r,i,a]=[t[n]*l,t[n+1]*u,t[n+2]*d],[o,s,T]=[t[n+3],t[n+4],t[n+5]];if(!f){[o,s,T]=[o/l,s/u,T/d];let e=Math.sqrt(o*o+s*s+T*T)||1;[o,s,T]=[o/e,s/e,T/e]}e.push(S+p*r+g*i-y*a,C+m*r+_*i-b*a,w+h*r+v*i-x*a,p*o+g*s-y*T,m*o+_*s-b*T,h*o+v*s-x*T,t[n+6]*c[0],t[n+7]*c[1],t[n+8],t[n+9]*c[2])}},Bt=(e,t)=>{let n=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],r=t.map((t,r)=>t-e[r]*n),i=Math.hypot(...r)||1,[a,o,s]=r.map(e=>e/i);return[[a,o,s],[o*e[2]-s*e[1],s*e[0]-a*e[2],a*e[1]-o*e[0]],e]},Vt=(e,t,n,r,i,a,o=1,s)=>{let c=[r[0]-n[0],r[1]-n[1],r[2]-n[2]],l=Math.hypot(...c)||1,[u,d]=typeof o==`number`?[o,o]:o;zt(e,t,n,Bt([c[0]/l,c[1]/l,c[2]/l],i),[0,0,0],[u,d,l/a],s)},Ht=2.4,Ut=[1,.62],Wt=8,Gt=28,Kt=2.2,qt=.04,Jt=.045,Yt=e=>{let t=parseInt(u[e].slice(1),16);return[t>>16,t>>8&255,t&255].map(e=>e/255)},Xt=(e,t,n)=>e.flatMap((e,r)=>{if(e.state===m.DROPPED)return[{team:r,at:[e.x,e.y,e.z],dropped:!0}];if(e.state===m.CARRIED){let t=n(e.by);return t?[{team:r,at:[t.x,t.y,t.z],by:{yaw:t.yaw,vx:t.vx,vz:t.vz}}]:[]}return[{team:r,at:t[r]}]}),Zt=[[1,0,0],[0,1,0],[0,0,1]],Qt=(e,t,n)=>{for(let r=t;r<e.length;r+=10)e[r+6]*=n,e[r+7]*=n,e[r+9]*=n,e[r+8]=-2},$t=(e,t,n,r,[i,a,o])=>{let[s,c,l]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],[u,d,f]=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],p=[c*f-l*d,l*u-s*f,s*d-c*u],m=Math.hypot(...p)||1;for(let s of[t,n,r])e.push(...s,p[0]/m,p[1]/m,p[2]/m,i,a,-1,o)},en=(e,t,n,r,i)=>{for(let a=0;a<Gt;a++){let[o,s]=[a,a+1].map(e=>e*2*Math.PI/Gt),c=(e,n)=>[t[0]+e*Math.cos(n),t[1],t[2]+e*Math.sin(n)];$t(e,c(n,o),c(r,s),c(r,o),i),$t(e,c(n,o),c(n,s),c(r,s),i)}},tn=(e,t,n,r)=>{for(let i=0;i<Gt;i++){let[a,o]=[i,i+1].map(e=>e*2*Math.PI/Gt);$t(e,t,[t[0]+n*Math.cos(o),t[1],t[2]+n*Math.sin(o)],[t[0]+n*Math.cos(a),t[1],t[2]+n*Math.sin(a)],r)}},nn=(e,t,n,r)=>{tn(e,[t[0],t[1]+qt,t[2]],d,n.map(e=>e*.4));let i=e.length;en(e,[t[0],t[1]+Jt,t[2]],d-.16,d,n),Qt(e,i,Kt*(.75+.25*Math.sin(r*3)))},rn=(e,t,n,[r,i],a,o,s)=>{let c=[-n[2],0,n[0]],l=(e,s)=>{let l=a*e*Math.sin(o*7-e*5),u=i*s*(1-e);return[t[0]+n[0]*r*e+c[0]*l,t[1]-u+.12*r*e*Math.sin(o*5-e*4)*a,t[2]+n[2]*r*e+c[2]*l]};for(let t=0;t<Wt;t++){let[n,r]=[t/Wt,(t+1)/Wt],[i,a,o,c]=[l(n,0),l(r,0),l(r,1),l(n,1)],u=[(a[1]-i[1])*(c[2]-i[2])-(a[2]-i[2])*(c[1]-i[1]),(a[2]-i[2])*(c[0]-i[0])-(a[0]-i[0])*(c[2]-i[2]),(a[0]-i[0])*(c[1]-i[1])-(a[1]-i[1])*(c[0]-i[0])],d=Math.hypot(...u)||1,f=(e,t)=>[e[0]+u[0]/d*.004*t,e[1]+u[1]/d*.004*t,e[2]+u[2]/d*.004*t];for(let t of[1,-1]){let n=[i,a,o,c].map(e=>f(e,t)),[r,l,u,d]=t>0?n:[n[0],n[3],n[2],n[1]];$t(e,r,l,u,s),$t(e,r,u,d,s)}}},an=(e,t,n,r)=>{Vt(e,Rt(1,1,[1,1],[0,0]),t,n,[.6,0,.8],1,.045,[.82,.84,.9]);let i=e.length;zt(e,Rt(1,0,[1,1]),n,Zt,[0,0,0],.09,r),Qt(e,i,Kt)},on=(e,t,n,r)=>{let[i,a,o]=t.at,s=r+t.team*1.7;if(t.by){let{yaw:r,vx:c,vz:l}=t.by,u=-Math.sin(r),d=-Math.cos(r),f=Math.hypot(c,l),p=[i-u*.28,a+.55,o-d*.28],m=[i-u*.38,a+.55+Ht-.2,o-d*.38],[h,g]=f>1?[-c/f,-l/f]:[-u,-d];an(e,p,m,n);let _=Math.min(1,f/8);rn(e,m,[h,0,g],[Ut[0]*(.7+.5*_),Ut[1]],.1+.16*_,s,n);return}if(t.dropped){let t=i*12.9898+o*78.233,[c,l]=[Math.cos(t),Math.sin(t)],u=[i+c*2.3,a+.6,o+l*2.3];an(e,[i,a+.06,o],u,n),rn(e,u,[c,0,l],[Ut[0]*.8,Ut[1]*.8],.04,s,n);let f=e.length;en(e,[i,a+Jt,o],d-.1,d,n),Qt(e,f,Kt*(.5+.5*Math.abs(Math.sin(r*5))));return}let c=[i,a+Ht,o];an(e,[i,a,o],c,n);let l=.6+t.team*Math.PI;rn(e,c,[Math.cos(l),0,Math.sin(l)],Ut,.18,s,n)},sn={SPOT:0,POINT:1},cn=9,ln=6,un=e=>{let{ctf:t,t:n}=e;if(!t)return[];let r=([e,t,n],r,i,a)=>({kind:sn.POINT,p:[e,t,n],d:[0,-1,0],cone:0,range:i,color:Yt(r).map(e=>e*a),shadow:!1});return[...t.bases.map(([e,t,i],a)=>r([e,t+1.2,i],a,cn,1.1+.3*Math.sin(n*3))),...t.flags.filter(e=>e.dropped).map(e=>r([e.at[0],e.at[1]+.8,e.at[2]],e.team,ln,.9))]},dn=.08,fn=.06,pn=.22,mn=7,hn=[[.022,[.4,.15,1.3],0],[.007,[.7,1.7,2.2],.02]],gn=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],_n=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],vn=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},yn=(e,t,[n,r,i])=>e.push(...t,0,1,0,n,r,-2,i),bn=(e,t,n,r,i,a,o)=>{let s=gn(n,t),c=_n(s,gn(t,a));Math.hypot(...c)<1e-6*Math.hypot(...s)&&(c=_n(s,[0,1,0])),c=vn(c);let[l,u,d,f]=[[t,1],[t,-1],[n,-1],[n,1]].map(([e,t])=>{let n=vn(gn(a,e)),i=r*Math.min(Math.max(Math.hypot(...gn(a,e))/5,1),2.5);return e.map((e,r)=>e+c[r]*i*t+n[r]*o)});for(let t of[l,u,d,l,d,f])yn(e,t,i)},xn=()=>{let e=[],t=[],n=7,r=()=>(n=n*16807%2147483647)/2147483647*2-1;return{mount(t){e.forEach(e=>e.own&&(e.a=t))},shoot(n,i,a,o=!1){if(e.push({a:n,b:i,age:0,hit:a,own:o}),e=e.slice(-16),a){let e=vn(gn(n,i));for(let n=0;n<mn;n++)t.push({p:i,v:[0,1,2].map(t=>e[t]*3+r()*3+(t==1?2:0)),age:0});t=t.slice(-112)}},update(n){for(let r of[...e,...t])r.age+=n;e=e.filter(e=>e.age<dn),t=t.filter(e=>e.age<pn);for(let e of t)e.v[1]-=9*n,e.p=e.p.map((t,r)=>t+e.v[r]*n)},draw(n,r){for(let{a:t,b:i,age:a}of e){let e=1-a/dn;hn.forEach(([a,o,s])=>bn(n,t,i,a*e**.7,o.map(t=>t*(.6+.4*e)),r,s))}for(let{p:e,age:i}of t){let t=1-i/pn,a=vn(_n(gn(e,r),[0,1,0])),o=vn(_n(a,gn(e,r))),[s,c]=[.022*t,.022*t],l=(t,n)=>[e[0]+a[0]*t+o[0]*n,e[1]+a[1]*t+o[1]*n,e[2]+a[2]*t+o[2]*n];for(let e of[l(-s,0),l(0,c),l(s,0),l(-s,0),l(s,0),l(0,-c)])yn(n,e,[1.4*t+.4,2.2*t+.3,3])}},lights(){let t=(e,t,n,r)=>({kind:sn.POINT,p:e,d:[0,-1,0],cone:0,range:t,color:r.map(e=>e*n),shadow:!1});return e.filter(e=>e.age<fn).slice(-3).flatMap(e=>{let n=1-e.age/fn;return[t(e.a,6,1.3*n,[.35,.8,1.5]),...e.hit?[t(e.b,3.5,.9*n,[.3,.7,1.3])]:[]]})},get count(){return e.length}}},Sn=(e,t)=>{if(!e)return[];if(e.over||t.over)return e.over&&!t.over?[{kind:`start`}]:[];let n=[];for(let r of[0,1])t.score[r]>e.score[r]&&n.push({kind:`capture`,team:r});let r=n.length>0;t.flags.forEach((t,i)=>{let a=e.flags[i];t.state===m.CARRIED&&(a.state!==m.CARRIED||a.by!==t.by)?n.push({kind:`take`,flag:i,by:t.by}):t.state===m.DROPPED&&a.state===m.CARRIED?n.push({kind:`drop`,flag:i}):t.state===m.HOME&&(a.state===m.DROPPED||a.state===m.CARRIED&&!r)&&n.push({kind:`return`,flag:i})});for(let r of t.players)r.stun>(e.players.find(e=>e.id===r.id)?.stun??1/0)&&n.push({kind:`tackle`,who:r.id,by:r.by,at:[r.x,r.y+1,r.z]});return n},Cn=(e,t,n)=>{let r=e=>l[e].toLowerCase();switch(e.kind){case`take`:{let i=1-e.flag;return{team:i,text:e.flag===t.team?`${l[i]} took your flag`:e.by===t.id?`You took the ${r(e.flag)} flag`:`${n(e.by)} took the ${r(e.flag)} flag`}}case`drop`:return{team:e.flag,text:e.flag===t.team?`Your flag was dropped`:`${l[e.flag]} flag dropped`};case`return`:return{team:e.flag,text:e.flag===t.team?`Your flag returned`:`${l[e.flag]} flag returned`};case`capture`:return{team:e.team,text:`${l[e.team]} scored`};case`tackle`:return e.by===t.id?{team:t.team,text:`Tackled ${n(e.who)}!`}:void 0;default:return{text:`New match`}}},wn=(e,t)=>{let{team:n}=t;switch(e.kind){case`take`:return[{id:K.TAKE,rate:e.flag===n?.8:1}];case`drop`:return[{id:K.DROP,rate:e.flag===n?1:.85}];case`return`:return[{id:K.RETURN,rate:e.flag===n?1:.85}];case`capture`:return[{id:K.CAPTURE,rate:e.team===n?1:.8}];case`tackle`:return e.who===t.id?[{id:K.TACKLE},{id:K.GRUNT}]:e.by===t.id?[{id:K.TACKLE,gain:.8,rate:1.1}]:[{id:K.TACKLE,at:e.at}];default:return[]}},J={PELVIS:0,SPINE:1,CHEST:2,NECK:3,HEAD:4,CLAVICLE_L:5,ARM_L:6,FOREARM_L:7,HAND_L:8,CLAVICLE_R:9,ARM_R:10,FOREARM_R:11,HAND_R:12,THIGH_L:13,SHIN_L:14,FOOT_L:15,TOE_L:16,THIGH_R:17,SHIN_R:18,FOOT_R:19,TOE_R:20},Tn=Object.keys(J).length,En=[-1,0,1,2,3,2,5,6,7,2,9,10,11,0,13,14,15,0,17,18,19],Dn=[[0,.98,0],[0,.12,0],[0,.2,0],[0,.22,0],[0,.1,0],[-.04,.17,0],[-.15,0,0],[-.03,-.29,0],[0,-.26,0],[.04,.17,0],[.15,0,0],[.03,-.29,0],[0,-.26,0],[-.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13],[.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13]],On=[0,0,0,1],kn=(e=[0,0,0],t=0)=>({at:e,yaw:t,hips:[0,0,0],rot:Array.from({length:Tn},()=>[...On])}),Y=([e,t,n,r],[i,a,o,s])=>[r*i+e*s+t*o-n*a,r*a-e*o+t*s+n*i,r*o+e*a-t*i+n*s,r*s-e*i-t*a-n*o],X=([e,t,n],r)=>{let i=Math.sin(r/2);return[e*i,t*i,n*i,Math.cos(r/2)]},An=(e,[t,n,r])=>{let[i,a,o,s]=e,[c,l,u]=[2*(a*r-o*n),2*(o*t-i*r),2*(i*n-a*t)];return[t+s*c+a*u-o*l,n+s*l+o*c-i*u,r+s*u+i*l-a*c]},jn=(e,t,n)=>{let r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],i=r<0?-1:1;if(r*=i,r>.9995){let r=e.map((e,r)=>e+(i*t[r]-e)*n),a=Math.hypot(...r);return r.map(e=>e/a)}let a=Math.acos(r),[o,s]=[Math.sin((1-n)*a),Math.sin(n*a)*i],c=1/Math.sin(a);return e.map((e,n)=>(e*o+t[n]*s)*c)},Mn=e=>{let t=[],n=[],r=X([0,1,0],e.yaw);for(let i=0;i<Tn;i++){let a=En[i],o=a<0?r:n[a];n[i]=Y(o,e.rot[i]);let s=An(o,i===0?Dn[0].map((t,n)=>t+e.hips[n]):Dn[i]),c=a<0?e.at:t[a];t[i]=[c[0]+s[0],c[1]+s[1],c[2]+s[2]]}return{pos:t,rot:n}},Nn=(e,t,n,r,i)=>{let a=e[t]-n,o=e[t+1]+r*a,s=Math.exp(-r*i);return e[t]=n+(a+o*i)*s,e[t+1]=(e[t+1]-r*o*i)*s,e[t]},Pn=Math.PI*2,[Z,Fn,In]=[[1,0,0],[0,1,0],[0,0,1]],[Ln,Rn,zn]=[.44,.43,.06],[Bn,Vn]=[.2915,.26],Hn=Ln+Rn,Q=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Un=e=>(e=Q(e))*e*(3-2*e),Wn=(e,t)=>Math.atan2(Math.sin(t-e),Math.cos(t-e)),Gn=e=>[-e[0],-e[1],-e[2],e[3]],Kn=(e,t)=>{let n=Math.sin(e*78.233+t*37.719)*43758.5453;return n-Math.floor(n)},qn=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Jn=(e,t,n,r=0)=>e.map((e,i)=>e*t+n[i]*r),Yn=e=>Jn(e,1/(Math.hypot(...e)||1),e),Xn=(e,t)=>Jn(e,1,t,-(e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),Zn=(e,t,n)=>{let r=Math.max(n-Math.abs(e-t),0)/n;return Math.min(e,t)-r*r*n/4},Qn=(e,t)=>{let n=[-t[0],-t[1],-t[2]],r=qn(e,n),i=[e[0]+n[1]+r[2],e[0]-n[1]-r[2],n[1]-e[0]-r[2],r[2]-e[0]-n[1]],a=i.indexOf(Math.max(...i)),[o,s,c,l]=[1+i[a],n[2]-r[1],r[0]-e[2],e[1]-n[0]],[u,d,f]=[n[0]+e[1],r[0]+e[2],r[1]+n[2]],p=[[s,c,l,o],[o,u,d,s],[u,o,f,c],[d,f,o,l]][a],m=Math.hypot(...p);return p.map(e=>e/m)},$n=(e,t,n,r=Ln,i=Rn,a=1)=>{let o=Jn(t,1,e,-1),s=Math.hypot(...o)||1e-6,c=Q(s,.2,(r+i)*.999),l=Jn(o,1/s,o),u=Yn(Xn(n,l)),d=Q((r*r+c*c-i*i)/(2*r*c),-1,1),f=Jn(l,d,u,Math.sqrt(1-d*d)),p=Yn(Jn(l,c,f,-r)),m=Jn(qn(l,u),a,l);return[Qn(m,f),Qn(m,p)]},er=e=>{let[t,n]=[Math.abs(e),e>0?.07:.13],[r,i]=[Math.sin(t),Math.cos(t)];return[(e>0?-1:1)*(n*(1-i)+zn*r),zn*(i-1)+n*r]},tr=[1.4,5,9],nr={f:[.95,1.4,1.8],s:[.88,.95,1],k:[.45,.42,.4],lat:[.11,.09,.07],lift:[.09,.3,.4],d0:[.002,.01,.01],d1:[.008,.075,.05],td:[.12,.1,-.12],to:[-.45,-.6,-.8],pr:[.07,.1,.14],po:[.06,.06,.05],pt:[.04,.1,.16],pa:[.02,.05,.06],cc:[.1,.16,.22],aa:[.35,.8,1],am:[-.05,.12,.25],em:[.3,1.4,1.75],ea:[.12,.25,.3],ab:[.1,.12,.1],sw:[.025,.012,.008],hop:[0,.02,.025]},$={AIR:0,RISE:1,DASH:2,WALL_L:3,WALL_R:4,HANG:5,CLIMB:6,SLIDE:7,STUN:8,TUCK:9,DOWN:10},rr=[[-.05,.12,0,.35,.5,.15,.7,.25,.5,.25,.5,1.15,0,0],[0,.1,0,1.2,1.5,-.35,.3,2.4,.3,2.2,.3,.35,0,0],[-.35,1.25,0,1.1,1.3,-.6,.25,-1,.3,-1,.3,.25,0,0],[],[-.02,.2,.4,.9,1.2,.6,1.3,.8,1,.3,.5,.6,0,.1],[.07,.05,0,.2,.3,.1,.2,3,.2,3,.2,.2,-.22,0],[0,.5,0,.2,.4,1.4,1.7,1,1.4,1,1.4,.15,-.1,0],[-.78,-1.1,0,1.1,1.8,1.4,.1,.5,.8,.4,.5,.8,0,0],[0,0,0,0,0,0,0,.8,1.6,.8,1.6,.2,0,0],[-.05,.9,0,1.7,2,1.7,2,.8,1.6,.8,1.6,.2,0,0],[-.5,.35,0,1.3,.3,1.1,.2,.4,.4,.2,.3,.6,0,0]],ir=rr[$.WALL_R];rr[$.WALL_L]=[ir[0],ir[1],-ir[2],ir[5],ir[6],ir[3],ir[4],ir[9],ir[10],ir[7],ir[8],ir[11],ir[12],-ir[13]];var ar=[J.PELVIS,J.SPINE,J.CHEST,J.ARM_L,J.FOREARM_L,J.ARM_R,J.FOREARM_R,J.THIGH_L,J.SHIN_L,J.FOOT_L,J.TOE_L,J.THIGH_R,J.SHIN_R,J.FOOT_R,J.TOE_R],or=e=>{let t=[],[n,r,i]=[e[1],e[2],e[11]];return t[J.PELVIS]=Y(X(In,r*.4),X(Z,-.3*n)),t[J.SPINE]=Y(X(In,r*.3),X(Z,-.35*n)),t[J.CHEST]=t[J.SPINE],t[J.ARM_L]=Y(X(In,-i),X(Z,e[7])),t[J.FOREARM_L]=X(Z,e[8]),t[J.ARM_R]=Y(X(In,i),X(Z,e[9])),t[J.FOREARM_R]=X(Z,e[10]),[J.THIGH_L,J.THIGH_R].forEach((r,i)=>{t[r]=X(Z,e[3+2*i]+.3*n),t[r+1]=X(Z,-e[4+2*i]),t[r+2]=X(Z,-.35),t[r+3]=sr}),t},sr=[0,0,0,1],cr=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],[lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br]=[0,2,4,6,8,10,12,14,16,18,20,22],xr=5,Sr=.1,Cr=()=>{let e=kn(),t={},n=Array(br+2*rr.length).fill(0),r=[0,1].map(()=>({x:0,y:0,z:0,px:0,pz:0,gy:0,lx:0,ly:0,lz:0,dl:0,tg:0,u:0,x0:0,w:0,th:0,tw:1,on:!0})),i={},a=!1,[o,s,c,l,u,d,f]=[0,0,0,0,0,0,0],[p,m,h,_,v]=[0,0,0,.6,0],[y,b,x,S]=[!1,!0,!0,-1],C=[1,1,1,0,.06,0],[w,T,E]=[0,0,[0,0,0]],[D,O,k,A]=[1,[1,0],[0,0,0,-1,0],!1],j=(e,j,ee)=>{j=Q(j,0,.1),b=!a||Math.hypot(e.x-i.x,e.y-i.y,e.z-i.z)>xr;let M=e.mode==g.GROUND||e.mode==g.CROUCH,N=e.mode==g.AIR,P=(e,t,r)=>{b?[n[e],n[e+1]]=[t,0]:Nn(n,e,t,r,j)};P(mr,e.vx,12),P(hr,e.vz,12);let[F,I]=[n[mr],n[hr]];l=Math.sqrt(F*F+I*I);let L=l>1?Math.atan2(-F,-I):e.yaw;if(b){let t=e.id;C=[1+.08*(Kn(t,0)-.5),1+.16*(Kn(t,1)-.5),1+.16*(Kn(t,2)-.5),.03*(Kn(t,3)-.5),.05+.04*Kn(t,4),Kn(t,6)],o=l>.25?Kn(t,5):Kn(t,5)<.5?.05:.55,[s,c,h,p,m,y,S]=[0,0,0,0,0,!1,-1],f=L,d=e.yaw}else N&&i.mode==g.AIR&&e.jumps<i.jumps&&e.vy>i.vy&&(h=.001),N?m=Math.min(m,e.vy):(i.mode==g.AIR&&(M||e.mode==g.SLIDE)&&m<-3&&(p=Q(-m/12,.3)),m=0),h&&=(h+=j*(N?2.2:8),h>=1?0:h);c+=j,p*=Math.exp(-j*7);let R=cr[e.wall],z=e.mode==g.WALLRUN,B=e.mode==g.HANG||e.mode==g.CLIMB;z&&([D,O]=[R[0]*Math.cos(L)-R[1]*Math.sin(L)<0?-1:1,R]),B&&e.wall&&(d=Math.atan2(-R[0],-R[1]),e.mode!=g.HANG&&A||(k=[e.x,e.z,R[0],R[1],0]),k[4]=e.edge),A=B,[N,N&&e.vy>.5,e.dash>50,z&&D<0,z&&D>0,e.mode==g.HANG,e.mode==g.CLIMB,e.mode==g.SLIDE,e.stun>0,h&&Math.sqrt(Math.sin(Math.PI*h))].forEach((e,t)=>P(br+2*t,+e,12)),P(br+2*$.DOWN,+(e.down>0),5),P(pr,+(e.mode==g.CROUCH),12),P(_r,B?Q((1.7-k[4]+e.y)/1.2):0,14),P(fr,p,26);let te=b||l<2?0:Wn(f,L)/Math.max(j,.001);f=L;let ne=b?0:-((e.vx-i.vx)*Math.sin(u)+(e.vz-i.vz)*Math.cos(u))/Math.max(j,.001),re=-(F*Math.sin(u)+I*Math.cos(u)),ie=Math.sign(re)*Q((Math.abs(re)-1.5)*.028,0,.22);P(lr,(re>0?ie:ie/2)+Q(ne*.012,-.3,.3),7),P(ur,Q(.3*Math.atan(l*te/9.8),-.4,.4),8),P(dr,.5*Math.sin(Wn(e.yaw,L))*Q(l/2),10);let V=e=>n[br+2*e],H=Q(V($.DASH)+V($.WALL_L)+V($.WALL_R)+V($.SLIDE)),U=e.yaw+Wn(e.yaw,L)*H;u=U+Wn(U,d)*Q(V($.HANG)+V($.CLIMB)),u+=n[dr]*(1-H);let[W,ae]=[Math.cos(u),Math.sin(u)];P(vr,e.stun>0?Q(-(e.vx*ae+e.vz*W)/4.2,-1,1):0,18),P(yr,e.stun>0?Q((e.vx*W-e.vz*ae)/4.2,-1,1):0,18),[w,T,E]=[e.yaw,e.pitch,[e.x,e.y,e.z]];let oe=l<tr[1]?0:1,se=Q((l-tr[oe])/(tr[oe+1]-tr[oe]));for(let e in nr){let n=nr[e];t[e]=n[oe]+(n[oe+1]-n[oe])*se}v=Un((l-.2)/1.2);let ce=t.f*C[0]*(.35+.65*Q(l/1.4))*(1+.5*V($.STUN));_=Q(t.s*ce/Math.max(l,.1),.2,.62);let[le,ue]=[Math.cos(u),-Math.sin(u)],G=(t,n)=>{let r=ee?ee(t,n):e.y;return Math.abs(r-e.y)<.6?r:e.y},de=l<=.25,fe=M&&(!de||!r[0].on||!r[1].on);(fe||z)&&(o=(o+(de&&!z?.9:ce)*j)%1),r.forEach((n,a)=>{let c=a?1:-1,l=(o+a/2)%1,[d,f]=[e.x+le*c*Sr,e.z+ue*c*Sr],p=u-c*C[4],[m,h]=[-Math.sin(p),-Math.cos(p)];if(M){if(y||([n.px,n.pz,n.gy,n.on]=[d,f,G(d,f),!0],b&&([n.x,n.y,n.z,n.th,n.tw]=[d,n.gy+zn,f,0,1])),n.on&&fe&&(l>=_||Math.hypot(n.x-d,n.z-f)>.56))[n.on,n.lx,n.ly,n.lz,n.dl]=[!1,n.x-e.x,n.y,n.z-e.z,l];else if(!n.on&&l<n.u){let[e]=er(t.td*v);[n.on,n.px,n.pz,n.gy]=[!0,n.x-m*e,n.z-h*e,n.tg],s++}if(n.u=l,n.on){if(de&&r[0].on&&r[1].on){let e=1-Math.exp(-8*j);n.px+=(d-n.px)*e,n.pz+=(f-n.pz)*e,n.gy+=(G(d,f)-n.gy)*e}n.x0=Q(l/_),n.th=v*(t.td*(1-Un(n.x0/.25))+t.to*Un((n.x0-.55)/.45));let[e,i]=er(n.th);[n.x,n.y,n.z]=[n.px+m*e,n.gy+zn+i,n.pz+h*e],n.w=1-v*(1-Un(Math.min(n.x0,1-n.x0)/.12)),n.tw=Un(n.x0*10)}else{let r=Q((l-n.dl)/(1-n.dl+1e-6)),[i,a]=[t.k*_/ce,(1-l)/ce+t.k*_/ce],[o,s]=[F*i+le*c*t.lat,I*i+ue*c*t.lat];n.tg=G(e.x+F*a+le*c*t.lat,e.z+I*a+ue*c*t.lat);let[u,d]=[t.td*v,t.to*v],f=Un((r-.12)/.78);n.x=e.x+n.lx+(o-n.lx)*f,n.z=e.z+n.lz+(s-n.lz)*f,n.y=n.ly+(n.tg+zn+er(u)[1]-n.ly)*Un(r*1.5)+t.lift*Math.sin(Math.PI*r**.6),n.th=d+(u-d)*Un(r)+.15*Math.sin(Math.PI*r),n.tw=1-Un(r*4),n.w=0}}else{let t=b?0:Math.exp(-10*j),r=b?[0,0,0]:[n.x-i.x,n.y-i.y,n.z-i.z];n.x=e.x+r[0]*t+(d-e.x)*(1-t),n.y=e.y+r[1]*t+zn*(1-t),n.z=e.z+r[2]*t+(f-e.z)*(1-t),[n.th,n.tw,n.w,n.on,n.u]=[n.th*t,n.tw*t,0,!1,l]}}),y=M,x=!0,Object.assign(i,e),a=!0},ee=()=>{let t=e=>n[br+2*e],{rot:r}=e,[i,a]=[Math.cos(u),Math.sin(u)],s=(e,t,n,r=E)=>[r[0]+e*i+n*a,t,r[2]+n*i-e*a],c=(e,t,n)=>s(e,t,n,[0,0,0]),l=[],{pos:d,rot:f}=Mn(e),p=d[J.PELVIS],m=e=>e<0?J.HAND_L:J.HAND_R,h=e=>e<0?J.FOOT_L:J.FOOT_R,g=Y(X(Fn,u),X(Z,-.2)),_=Q(t($.HANG)+t($.CLIMB));if(_>.002){let[r,i,a,o,s]=k,u=.4+.14*n[_r],f=[-1,1].map(e=>{let t=d[m(e)-2],n=Math.max(u,(t[0]-r)*a+(t[2]-i)*o),c=[r+a*n-o*e*.21,s+.03,i+o*n+a*e*.21],l=(t[0]-c[0])**2+(t[2]-c[2])**2;return[c,t[1]-c[1]-Math.sqrt(Math.max(((Bn+Vn)*.97)**2-l,0))]}),g=_**4*Q(Math.max(...f.map(e=>e[1])));e.at[1]-=g,d.forEach(e=>e[1]-=g),[-1,1].forEach((e,t)=>l.push([m(e),_,f[t][0],c(e*.8,0,.6),Qn([0,e,0],[a,0,o])]));let v=(p[0]-r)*a+(p[2]-i)*o,y=Math.max(.58,v+.45);[-1,1].forEach(e=>l.push([h(e),t($.CLIMB)*Q(e<0?(v-.25)*4:n[_r]*2-.4),[r+a*y-o*e*.1,s+zn,i+o*y+a*e*.1],[a,.5,o],Qn([-o,0,a],[0,-1,0])]))}[-1,1].forEach(e=>{let n=t(e<0?$.WALL_L:$.WALL_R);if(n>.002){let[t,r]=O;[e,-e].forEach((i,a)=>{let d=(o+.5*a)%1,f=d<.55,_=f?d/.55:(d-.55)/.45,v=f?0:Math.sin(Math.PI*_),y=(f?2*_-1:1-2*Un(_))*(a?.4:.3);l.push([h(i),n,a?s(-e*.12,p[1]-.7+.4*v,y):s(e*(.34-.2*v),p[1]-.52+.3*v,y),c(-e*.7,1,-1),a?Y(X(Fn,u),X(Z,-.5)):jn(g,Qn(qn([t,0,r],c(0,0,-1)),[t,0,r]),1-v)]);let b=Math.cos(Pn*(o+.5*(1-a)));l.push([m(i),n,a?s(-e*.5,p[1]+.3+.12*b,.2*b):s(e*.37,p[1]+.3+.05*b,.1*b),c(a?-e*.7:0,a?0:-.5,.7),Qn(a?[0,i,0]:[-i*t,0,-i*r],c(0,0,-1))])})}});let v=t($.SLIDE);if(v>.002){let e=E[1];l.push([J.FOOT_R,v,s(.12,e+zn+.14,-.85,p),c(.1,1,-.3),g],[J.FOOT_L,v,s(-.2,e+zn,-.3,p),c(-.4,1,-.1),g],[J.HAND_L,v,s(-.4,e+.03,.4,p),c(-.7,0,.7),Qn([0,-1,0],c(-1,0,0))])}l.forEach(([e,t,n,i,a])=>{let[o,s,c]=[e-2,e<J.THIGH_L,t*t],l=Jn(Jn(d[o+1],1,d[o],-1),1,An(f[o],[0,0,s?1:-1]),.05),[u,p]=[Jn(d[e],1-c,n,c),e=>Yn(Jn(e,1,d[o],-1))],m=Jn(Yn(Xn(l,p(d[e]))),1-c,Yn(Xn(i,p(n))),c),[h,g]=s?$n(d[o],u,m,Bn,Vn,-1):$n(d[o],u,m),_=s?Y(h,X(In,o==J.ARM_L?.1:-.1)):h;r[o]=Y(Gn(f[En[o]]),_),r[o+1]=Y(Gn(_),g),r[e]=jn(r[e],Y(Gn(g),a),c)})},M=()=>{let{rot:i}=e,a=v,s=e=>n[br+2*e],[l,d,f,p,m]=[n[lr],n[ur],n[dr],n[fr],n[pr]],[g,y]=[Math.cos(Pn*o),Math.cos(2*Pn*o)],b=Math.cos(Pn*(o-(1+_)/2)),D=t.po*a*b,O=t.pt+C[3]+t.pa*a*y,k=(t.cc+t.pr)*a*g,A=1-a,j=A*.012*Math.sin(Pn*.28*c),M=A*.012*Math.sin(Pn*.17*c+C[1]*9),N=t.sw*a*b+M;e.at[0]=E[0],e.at[1]=E[1],e.at[2]=E[2],e.yaw=u,i[J.PELVIS]=Y(Y(X(Fn,-t.pr*a*g),X(In,D+.4*d)),X(Z,-(O+.25*l+.3*m+.5*p)));let P=O+.25*l-l-.7*m-.8*p;i[J.SPINE]=Y(Y(X(Fn,.4*k-.25*f),X(In,.25*d-.8*D+.5*M)),X(Z,.45*P+j*.5)),i[J.CHEST]=Y(Y(X(Fn,.6*k-.25*f),X(In,.25*d-.8*D-.5*M)),X(Z,.55*P+j)),[-1,1].forEach(e=>{let n=Math.cos(Pn*(o-(e<0?.5:0))),r=C[e<0?1:2];i[e<0?J.ARM_L:J.ARM_R]=Y(X(In,e*(.06+t.ab*a+.5*p)),X(Z,(t.am+t.aa*r*n)*a+.05*A*e*Math.sin(c*1.3)+p+.5*m)),i[e<0?J.FOREARM_L:J.FOREARM_R]=X(Z,.15*A+a*(t.em+t.ea*n)+p+.5*m)});let F=X(Fn,u),I=Y(F,i[J.PELVIS]),[L,R]=[Math.cos(u),-Math.sin(u)],z=[E[0]+L*N,0,E[2]+R*N],B=[J.THIGH_L,J.THIGH_R].map(e=>An(I,Dn[e])),te=1-.25*m-.7*p,ne=E[1]+.05+zn+Hn*(te-t.d0-.6*t.d1*a)+t.hop*a*(.5-.5*Math.cos(2*Pn*o-2*Pn*_/2)),re=r.map((e,n)=>{let[r,i]=[e.x-z[0]-B[n][0],e.z-z[2]-B[n][2]],o=t.d0+t.d1*a*Math.sin(Math.PI*e.x0)+1-te,s=Math.min(Hn*(1-o),Hn*.99),c=e.y+Math.sqrt(Math.max(s*s-r*r-i*i,.04));return ne+(c-B[n][1]-ne)*e.w}),ie=Zn(re[0],re[1],.05),V=c-S;S=c,V>.1?[n[gr],n[gr+1]]=[ie,0]:Nn(n,gr,ie,30,V),z[1]=Math.min(ie,n[gr]),e.hips=[N,z[1]-E[1]-Dn[0][1],0],r.forEach((e,t)=>{let n=t?1:-1,r=[z[0]+B[t][0],z[1]+B[t][1],z[2]+B[t][2]],a=u-n*C[4],[o,s]=$n(r,[e.x,e.y,e.z],[-Math.sin(a),0,-Math.cos(a)]),c=t?J.THIGH_R:J.THIGH_L;i[c]=Y(Gn(I),o),i[c+1]=Y(Gn(o),s),i[c+2]=Y(Gn(s),Y(X(Fn,a),X(Z,e.th))),i[c+3]=X(Z,e.th<0?-e.th*e.tw:0)}),rr.forEach((t,n)=>{let r=s(n);if(r>.002){let a=or(t),o=n==$.STUN;ar.slice(o?3:0,o?7:15).forEach(e=>i[e]=jn(i[e],a[e],r)),o||[t[13],t[0],t[12]].forEach((t,n)=>e.hips[n]+=(t-e.hips[n])*r)}}),h&&(i[J.PELVIS]=Y(X(Z,-Pn*(3-2*h)*h*h),i[J.PELVIS]));let H=s($.HANG);if(H>.002){let[t,n]=[.01*Math.sin(Pn*(.3*c+C[5])),.006*Math.sin(Pn*(.2*c+3*C[5]))].map(e=>e*H);i[J.PELVIS]=Y(Y(X(In,n),X(Z,t)),i[J.PELVIS]),[J.THIGH_L,J.THIGH_R].forEach(e=>i[e]=Y(i[e],X(Z,t))),e.hips[0]+=n,e.hips[2]-=t}let U=s($.STUN);if(U){[J.SPINE,J.CHEST].forEach((e,t)=>{let r=.3+.1*t;i[e]=Y(i[e],Y(X(In,-r*n[yr]),X(Z,-r*n[vr])))});let e=Math.sin(c*13);[J.ARM_L,J.ARM_R].forEach((t,n)=>i[t]=Y(i[t],X(Z,U*(n?e:-e)))),i[J.CHEST]=Y(i[J.CHEST],X(Fn,.3*U*Math.sin(c*8)))}ee();let W=Un((s($.DOWN)-.35)/.65);W&&(i[J.PELVIS]=Y(X(Z,-1.45*W),i[J.PELVIS]),e.hips[1]+=(.17-Dn[0][1]-e.hips[1])*W,[J.THIGH_L,J.THIGH_R].forEach(e=>i[e]=Y(i[e],X(Z,-1.25*W))),[J.ARM_L,J.ARM_R].forEach(e=>i[e]=Y(i[e],X(Z,-.5*W))));let ae=Y(Y(F,i[J.PELVIS]),Y(i[J.SPINE],i[J.CHEST])),oe=Y(X(Fn,w),X(Z,Q(T,-1,1)*.9)),se=Y(Gn(ae),jn(ae,oe,.85*(1-s($.TUCK))*(1-.5*U)*(1-s($.DOWN))));return i[J.NECK]=jn([0,0,0,1],se,.4),i[J.HEAD]=Y(Gn(i[J.NECK]),se),x=!1,e};return{update:j,pose:()=>x?M():e,get phase(){return o},get steps(){return s}}},wr=e=>Math.sign(e)*Math.abs(e)**.8,Tr=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),Er=e=>Math.min(Math.max(e,0),1),Dr=(e,t,n,r)=>{let i=[],a=[],o=[],s=t.map(([e,r,o,s,c=0],l)=>{let[u,d]=[t[Math.max(l-1,0)],t[Math.min(l+1,t.length-1)]],f=Math.hypot(d[0]-u[0],d[1]-u[1])||1,[p,m]=[(d[0]-u[0])/f,(d[1]-u[1])/f];return Array.from({length:o?n:1},(t,l)=>{let[u,d]=[wr(Math.cos(l*H/n)),wr(Math.sin(l*H/n))];return i.push([c+o*u,r+s*d*p,-(e-s*d*m)]),a.push([0,0,0]),i.length-1})});s.slice(1).forEach((e,r)=>{let c=s[r],l=[(t[r][4]??0)+(t[r+1][4]??0),t[r][1]+t[r+1][1],-t[r][0]-t[r+1][0]];for(let t=0;t<n;t++){let[n,r,s,u]=[c[t%c.length],c[(t+1)%c.length],e[(t+1)%e.length],e[t%e.length]];for(let e of[[n,r,s],[n,s,u]]){if(new Set(e).size<3)continue;let[t,n]=[1,2].map(t=>[0,1,2].map(n=>i[e[t]][n]-i[e[0]][n])),r=[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]],s=[0,1,2].reduce((t,n)=>t+r[n]*(i[e[0]][n]*2-l[n]),0)<0;o.push(...s?[e[0],e[2],e[1]]:e);for(let t of e)[0,1,2].forEach(e=>a[t][e]+=s?-r[e]:r[e])}}});for(let t of o){let n=Math.hypot(...a[t])||1,o=a[t].map(e=>e/n);e.push(...i[t],...o,...r(i[t],o))}},Or=[.34,.12,.62],kr=[.72,.46,1],Ar=[.1,.38,.72],jr=[.16,.06,.34],Mr=[.5,1.9,2.3],Nr=(e=0)=>(t,n)=>{let r=Tr(Tr(Or,Ar,Er(-t[2]*5-.3)*.8),kr,Math.max(n[1],0)**1.5*.7),[i,a,,o]=Tr([...r.slice(0,2),0,r[2]],[...jr.slice(0,2),0,jr[2]],Er(-n[1]*.5+e));return[i,a,-1,o]},Pr=[.035,.025,.08],Fr=()=>[Mr[0],Mr[1],-2,Mr[2]],Ir=[0,.095,.06],Lr=[0,.075,-.21],Rr=[Math.sin(.4),Math.cos(.4)],zr=[[-.06,.095,0,0],[-.055,.098,.022,.022],[-.035,.103,.042,.036],[-.005,.104,.048,.04],[.035,.1,.044,.038],[.08,.094,.036,.034],[.12,.088,.028,.028],[.16,.082,.021,.021],[.19,.078,.015,.015],[.205,.076,.01,.01],[.208,.0755,0,0]],Br=[[-.05,-.02,0,0],[-.045,-.025,.018,.012],[-.025,-.052,.032,.018],[.01,-.066,.036,.02],[.06,-.06,.034,.02],[.11,-.04,.028,.018],[.16,0,.02,.014],[.2,.04,.012,.01],[.222,.065,0,0]],Vr=[],Hr=e=>{if(Vr[e])return Vr[e];let[t,n]=e?[12,8]:[8,5],r=[];Dr(r,zr,t,Nr()),Dr(r,Br,t,Nr(.25)),Dr(r,[[.03,.06,0,0],[.02,.046,.021,.022],[0,0,.021,.023],[-.02,-.046,.021,.022],[-.03,-.06,0,0]],n,Nr(.1));for(let t of[-1,1])Dr(r,zr.slice(1,6).map(([e,n,r,i])=>[e,n-.1*i,.0035,.006,t*r*.93]),e?5:3,Fr),Dr(r,Br.slice(1,7).map(([e,n,r,i])=>[e,n+.3*i,.0035,.005,t*r*.92]),e?5:3,Fr);return Dr(r,[[.198,.077,0,0],[.2,.077,.011,.011],[.207,.0757,.008,.008],[-Lr[2],Lr[1],0,0]],n,Fr),Vr[e]=r},Ur=e=>{let[t,n,r]=[An(e,[0,0,-1]),An(e,[1,0,0]),An(e,[0,-1,0])],[i,a]=Rr;return[n,t.map((e,t)=>a*e-i*r[t]),t.map((e,t)=>i*e+a*r[t])]},Wr=(e,t)=>{let[n,r]=[An(t,[0,-1,0]),An(t,[1,0,0])];return e.map((e,t)=>e+n[t]*.078-r[t]*.022)},Gr=[`abcdef`,`bc`,`abdeg`,`abcdg`,`bcfg`,`acdfg`,`acdefg`,`abc`,`abcdefg`,`abcdfg`],[Kr,qr,Jr,Yr]=[.019,.026,.0055,.004],Xr={a:[0,qr-Jr,Kr,qr],b:[Kr-Jr,qr/2,Kr,qr],c:[Kr-Jr,0,Kr,qr/2],d:[0,0,Kr,Jr],e:[0,0,Jr,qr/2],f:[0,qr/2,Jr,qr],g:[0,(qr-Jr)/2,Kr,(qr+Jr)/2]},Zr=[[.036,.112,.056],[.036,.112,.012]],Qr=[[.028,.156,.036],[.028,.152,.02]],$r=[.2,.075,.36],[ei,ti,ni]=[.023,.0175,.0455],ri=/* @__PURE__ */ new Map,ii=e=>{let t=Math.min(Math.max(Math.floor(e),0),99),n=ri.get(t);if(!n){let e=n=[],r=e=>[-e[0],e[1],e[2]],[i,a,o,s]=[Zr[0],Zr[1],Qr[0],Qr[1]],c=[i,a,o,s].flatMap(e=>[e,r(e)]),l=[0,1,2].map(e=>c.reduce((t,n)=>t+n[e],0)/c.length),u=(t,n)=>{let[r,i]=[q(t[1],t[0]),q(t[2],t[0])],a=kt([r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],q(t[0],l))<0?[t[0],t[3],t[2],t[1]]:t;$t(e,a[0],a[1],a[2],n),$t(e,a[0],a[2],a[3],n)};u([i,r(i),r(o),o],$r),u([a,r(a),r(s),s],$r),u([i,a,s,o],$r),u([r(i),r(a),r(s),r(o)],$r),u([o,r(o),r(s),s],$r);let d=jt(q(o,i)),[f,p]=[[0,i[1],i[2]],[0,-d[2],d[1]]],m=(e,t,n)=>[f[0]+e,f[1]+d[1]*t+p[1]*n,f[2]+d[2]*t+p[2]*n];u([m(-ei,ti,.0012),m(ei,ti,.0012),m(ei,ni,.0012),m(-ei,ni,.0012)],Pr);let h=e.length;[...`${t}`.padStart(2,`0`)].forEach((n,r)=>{let i=-Kr-Yr/2+r*(Kr+Yr);for(let r of Gr[+n]){let[n,a,o,s]=Xr[r],c=(e,t)=>m(i+e,(ti+ni-qr)/2+t,.0027),l=t>10?[.25,.9,1]:[1,.18,.12];$t(e,c(n,a),c(o,a),c(o,s),l),$t(e,c(n,a),c(o,s),c(n,s),l)}}),Qt(e,h,1),ri.set(t,n)}return n},ai=(e,t,n,r,i=1,a)=>{let[o,s]=[Wr(t,n),Ur(n)];zt(e,Hr(r),o,s,[0,0,0],i),a!==void 0&&zt(e,ii(a),o,s,[0,0,0],i)},oi=(e,[,t,n])=>[0,1,2].map(r=>e[r]+t[r]*Lr[1]-n[r]*Lr[2]),si=Math.atan2(Ir[1]-Lr[1],Ir[2]-Lr[2]),ci=(e,t,n,r)=>{let i=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],a=[n,r,jt(q(t,e))];for(let o=0;o<3;o++){let s=jt(q(t,o?oi(e,a):e)),c=jt(q(n,i(s,kt(n,s)))),l=jt(q(q(r,i(s,kt(r,s))),i(c,kt(r,c)))),[u,d]=[Math.sin(si),Math.cos(si)];a=[c,Ot(i(l,d),i(s,-u)),Ot(i(s,d),i(l,u))]}return a},li=(e,t)=>{let n=[e.x,e.y+_e(e),e.z],r=Mt(e.yaw,e.pitch)[2],i=re(t,n,r,80);return[[0,1,2].map(e=>n[e]+r[e]*i),i<80]},ui=(e,t)=>{let[n,r,i]=Mt(e.yaw,e.pitch),a=[e.x,e.y+_e(e),e.z],o=[0,1,2].map(e=>a[e]+n[e]*.2-r[e]*.17+i[e]*.42);return[o,ci(o,t,n,r)]},di=[.66,.45,.35],[fi,pi,mi,hi,gi,_i,vi,yi,bi]=[0,1,2,3,4,5,6,7,8],xi=e=>[e,e.map(e=>e*.5),[.12,.13,.17],di,[.09,.07,.06],[.74,.74,.77],[.93,.93,.94],[.26,.26,.3],[.03,.03,.04]],Si={chain:[J.PELVIS,J.SPINE,J.CHEST,J.NECK,J.HEAD],n:[8,8],e:2.3,far:[0,2,4,6,8,10,13],rings:[[.84,0,0,0,0,0,mi],[.88,0,.005,.13,.09,0,mi],[.94,0,.01,.187,.108,0,mi],[.99,0,.005,.18,.106,.25,pi],[1.03,0,0,.17,.102,.5,fi],[1.12,0,0,.155,.097,1,fi],[1.24,0,-.003,.176,.112,1.7,fi],[1.35,0,-.005,.19,.126,2,fi],[1.44,0,-.004,.2,.116,2,fi],[1.485,0,0,.2,.098,2.05,fi],[1.512,0,0,.125,.08,2.1,fi],[1.532,0,0,.07,.068,2.25,pi],[1.555,0,0,.06,.062,2.6,hi],[1.6,0,0,.057,.059,3.5,hi]]},Ci={chain:[J.PELVIS,J.THIGH_R,J.SHIN_R,J.FOOT_R],n:[6,8],m:!0,far:[0,2,4,6,7,9],rings:[[1,.1,.01,0,0,0,mi],[.9,.1,.006,.093,.098,.5,mi],[.72,.1,-.002,.088,.09,1,mi],[.55,.1,-.003,.066,.07,1.25,mi],[.49,.1,-.004,.058,.064,1.5,mi],[.42,.1,.002,.056,.064,1.8,mi],[.33,.1,.012,.055,.068,2,mi],[.19,.1,.003,.04,.047,2.05,mi],[.09,.1,0,.036,.04,2.6,mi],[.06,.1,0,0,0,3,mi]]},wi={chain:[J.ARM_R,J.FOREARM_R,J.HAND_R],n:[5,7],m:!0,far:[0,2,4,6,7,9,11],rings:[[1.5,.19,0,0,0,0,fi],[1.465,.192,0,.052,.056,0,fi],[1.38,.198,0,.056,.058,.1,fi],[1.27,.21,0,.049,.051,.3,fi],[1.18,.22,0,.043,.046,.5,fi],[1.09,.222,-.002,.046,.048,.8,fi],[.975,.222,0,.034,.034,1.2,pi],[.935,.222,0,.03,.03,1.8,yi],[.885,.222,-.004,.027,.037,2,yi],[.84,.222,-.008,.029,.042,2,yi],[.795,.222,-.012,.025,.034,2,yi],[.772,.222,-.014,0,0,2,yi]]},Ti={chain:[J.FOOT_R,J.TOE_R],n:[5,6],e:2.6,z:!0,m:!0,far:[0,1,3,5,7],rings:[[.095,.1,.05,0,0,0,_i],[.08,.1,.048,.032,.042,0,_i,130,vi],[.03,.1,.052,.042,.052,.05,_i,130,vi],[-.05,.1,.04,.045,.044,.3,_i,130,vi],[-.12,.1,.033,.047,.034,.6,_i,130,vi],[-.17,.1,.028,.042,.028,1,_i,130,vi],[-.205,.1,.024,.028,.02,1,_i,130,vi],[-.215,.1,.022,0,0,1,_i]]},Ei={chain:[J.HEAD],n:[7,10],far:[0,1,3,5,6,7],rings:[[1.575,0,-.0075,.034,.0425,0,hi],[1.6,0,-.0165,.058,.0665,0,hi],[1.635,0,-.0085,.072,.0785,0,hi,150,gi],[1.675,0,-.001,.08,.089,0,hi,-36,bi,110,gi],[1.71,0,.0035,.083,.0935,0,hi,72,gi],[1.75,0,.0065,.08,.0885,0,gi],[1.785,0,.011,.056,.061,0,gi],[1.8,0,.015,0,0,0,gi]]},Di={chain:[J.HEAD],n:[0,5],z:!0,far:[],rings:[[-.075,0,1.675,.014,.034,0,hi],[-.1,0,1.66,.012,.024,0,hi],[-.115,0,1.649,0,0,0,hi]]},Oi=[Si,Ci,wi,Ti,Ei,Di],ki=(e,t)=>Math.sign(e)*Math.abs(e)**(2/t),Ai=e=>{let[t,n,r,i,a]=[[],[],[],[],[]];for(let o of Oi){let s=o.n[Math.min(e,1)];if(!s||e>1&&(o===Ei||o===Di))continue;let c=e>1&&o===Si?[...o.rings.slice(0,9),[1.455,0,0,0,0,2,fi]]:e>1&&o===wi?[...o.rings.slice(0,7),[.95,.222,0,.037,.037,1.6,yi],[.925,.222,0,.027,.027,2,yi],[.91,.222,0,0,0,2,yi]]:e?o.rings:o.far.map(e=>o.rings[e]),l=c[c.length-1][0]>c[0][0];for(let e of o.m?[1,-1]:[1]){let u=t=>e<0&&t>J.HEAD?t-4:t,d=c.map(([i,a,c,l,d,f])=>{let p=Math.min(Math.floor(f),o.chain.length-2),m=[];for(let h=0;h<(l?s:1);h++){let g=h*2*Math.PI/s,[_,v]=[a+l*ki(Math.sin(g),o.e??2),c+d*ki(Math.cos(g),o.e??2)];t.push(e*_,...o.z?[v,i]:[i,-v],0,0,0),n.push(u(o.chain[Math.max(p,0)]),u(o.chain[p+1]??o.chain[0])),r.push(p<0||o.chain[p+1]===void 0?0:f-p),m.push(r.length-1)}return m});d.slice(1).forEach((t,n)=>{let r=d[n],[,,,,,,o,...u]=c[n];for(let n=0;n<s;n++){let[c,d,f,p]=[r[n%r.length],r[(n+1)%r.length],t[(n+1)%t.length],t[n%t.length]],m=Math.abs(((n+.5)/s*360+180)%360-180),h=u.findIndex((e,t)=>!(t%2)&&(e>0?m>e:m<-e));for(let t of[[c,d,f],[c,f,p]])new Set(t).size>2&&(i.push(...l===e<0?t:[t[0],t[2],t[1]]),a.push(h<0?o:u[h+1]))}})}}for(let e=0;e<i.length;e+=3){let[n,r,a]=[i[e],i[e+1],i[e+2]].map(e=>e*6),o=[0,1,2].map(e=>[t[r+e]-t[n+e],t[a+e]-t[n+e]]),s=[o[1][0]*o[2][1]-o[2][0]*o[1][1],o[2][0]*o[0][1]-o[0][0]*o[2][1],o[0][0]*o[1][1]-o[1][0]*o[0][1]];for(let e of[n,r,a])for(let n=0;n<3;n++)t[e+3+n]+=s[n]}for(let e=0;e<t.length;e+=6){let n=Math.hypot(t[e+3],t[e+4],t[e+5])||1;for(let r=3;r<6;r++)t[e+r]/=n}return{v:new Float32Array(t),j:new Uint8Array(n),w:new Float32Array(r),t:new Uint16Array(i),c:new Uint8Array(a)}},ji=[],Mi=e=>ji[e]??=Ai(e),Ni=Mn(kn()).pos,Pi=new Float64Array(Tn*12),Fi=/* @__PURE__ */ new Float32Array,Ii=(e,t,{pos:n,rot:r},i)=>{for(let e=0;e<Tn;e++){let[t,i,a,o]=r[e],s=[1-2*(i*i+a*a),2*(t*i-a*o),2*(t*a+i*o),2*(t*i+a*o),1-2*(t*t+a*a),2*(i*a-t*o),2*(t*a-i*o),2*(i*a+t*o),1-2*(t*t+i*i)];for(let t=0;t<3;t++)Pi.set(s.slice(t*3,t*3+3),e*12+t*3),Pi[e*12+9+t]=n[e][t]-(s[t*3]*Ni[e][0]+s[t*3+1]*Ni[e][1]+s[t*3+2]*Ni[e][2])}let a=t.w.length;Fi.length<a*6&&(Fi=new Float32Array(a*6));for(let e=0;e<a;e++){let[n,r,i,a]=[t.j[e*2]*12,t.j[e*2+1]*12,t.w[e],e*6];for(let e=0;e<6;e++){let[o,s]=[e%3*3,e<3?a:a+3],[c,l,u,d]=[t.v[s],t.v[s+1],t.v[s+2],+(e<3)];Fi[a+e]=(1-i)*(Pi[n+o]*c+Pi[n+o+1]*l+Pi[n+o+2]*u+d*Pi[n+9+e%3])+i*(Pi[r+o]*c+Pi[r+o+1]*l+Pi[r+o+2]*u+d*Pi[r+9+e%3])}let o=Math.sqrt(Fi[a+3]**2+Fi[a+4]**2+Fi[a+5]**2)||1;Fi[a+3]/=o,Fi[a+4]/=o,Fi[a+5]/=o}for(let n=0;n<t.t.length;n+=3){let[r,a,o]=i[t.c[n/3]];for(let i=n;i<n+3;i++){let n=t.t[i]*6;e.push(Fi[n],Fi[n+1],Fi[n+2],Fi[n+3],Fi[n+4],Fi[n+5],r,a,-1,o)}}},Li=1,[Ri,zi]=[.12,.03],[Bi,Vi]=[[1,0,0],[0,1,0]],Hi=[.7,-1,-.5],Ui=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Wi=([e,t,n,r])=>[-e,-t,-n,r],Gi=(e,t)=>Math.hypot(...q(e,t)),Ki=(e,t,n)=>Ot(e,At([0,0,0],t,n)),qi=(e,t)=>{let[n,r]=[jt(e),jt(t)],i=[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0],1+kt(n,r)],a=Math.hypot(...i)||1;return i.map(e=>e/a)},Ji=(e,t,n,r,i)=>{let a=q(t,e),o=jt(a),s=Math.max(Math.min(Math.hypot(...a),(r+i)*.99),.15),c=(r*r-i*i+s*s)/(2*s),l=Math.sqrt(Math.max(r*r-c*c,0)),u=jt(q(n,At([0,0,0],o,kt(n,o))));return[Ki(Ki(e,o,c),u,l),Ki(e,o,s)]},Yi=(e,t,n,r,i,a=!1)=>{let[o,s,c]=[t.pos[n],t.pos[n+1],t.pos[n+2]],[l,u]=Ji(o,r,i,Gi(o,s),Gi(s,c)),d=Y(qi(q(s,o),q(l,o)),t.rot[n]),f=Y(qi(q(c,s),q(u,l)),t.rot[n+1]);e.rot[n]=Y(Wi(t.rot[En[n]]),d),e.rot[n+1]=Y(Wi(d),f),a&&(e.rot[n+2]=Y(Wi(f),t.rot[n+2]))},Xi=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Zi=()=>Rt(0,.04,[.0105,.0095],[1,2]),Qi=[1,1.1,1,.82],$i=[[[.55,-.2,.8],[.2,-.75,.6]],[[.4,-.1,.9],[-.55,-.5,.65]]],ea=(e,t,n,r,i,a,o)=>{let s=([e,a,o])=>[t[0]+i[0]*e+r[0]*a+n[0]*o,t[1]+i[1]*e+r[1]*a+n[1]*o,t[2]+i[2]*e+r[2]*a+n[2]*o],c=(t,n,r,a)=>n.reduce((t,n,c)=>{let l=[t[0]+n[0]*r,t[1]+n[1]*r,t[2]+n[2]*r];return Vt(e,Zi(),s(t),s(l),i,.04,a*.88**c,o),l},t);zt(e,Rt(1,0,[1,1]),t,[i,r,n],[0,0,.045],[.0425,.02,.058],o);for(let e=0;e<4;e++){let[t,n]=[.1+1.3*a,.2+3*a],r=-(e-1.5)*.08*(1-a),i=[t,n].map(e=>jt([r,-Math.sin(e),Math.cos(e)]));c([.0315-.021*e,-.004,.092],i,.04*Qi[e],1)}c([.034,-.012,.025],$i.map(([e,t])=>jt(At(e,t,a))),.037,1.25)},ta=(e,t)=>(n,i)=>{let a=re(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},na={amp:8,sprint:6,air:12,rise:10,dash:14,plant:16,wall:10,slide:10,stun:14,gun:10},ra=e=>{let t=Cr(),n,r={amp:0,sprint:0,air:0,rise:0,dash:0,plant:0,wall:0,slide:0,stun:0,gun:0},[i,a,o]=[0,0,1.6],s=[0,0,8],c=0,l=0,u,d=[0,0],f=(a,s,d=0,f=1.6)=>{if(i=d,o=f,!a){n=void 0;return}t.update(a,s,e&&ta(e,a.y)),n={...a},c+=s;let p=a.mode==g.GROUND||a.mode==g.CROUCH||a.mode==g.WALLRUN,m=a.dash>50,h=a.mode==g.AIR&&!m,_={amp:p?Ui(ve(a)/9):0,sprint:+ye(a),air:+h,rise:+(h&&a.vy>.5),dash:+m,plant:+(a.mode==g.HANG||a.mode==g.CLIMB),wall:+(a.mode==g.WALLRUN),slide:+(a.mode==g.SLIDE),stun:+(a.stun>0),gun:+(a.ammo>=0&&!a.down)};for(let e of Object.keys(na))r[e]+=(_[e]-r[e])*(1-Math.exp(-s*na[e]));let[v,y]=Xi[a.wall];l+=(Ui(v*Math.cos(a.yaw)-y*Math.sin(a.yaw),-1,1)-l)*(1-Math.exp(-s*10)),_.plant&&a.edge&&(u={x:a.x,y:a.edge,z:a.z,dx:v,dz:y})},p=()=>{let e=r.amp*(1+.5*r.sprint),[n,a]=[Math.sin(H*t.phase),Math.cos(H*t.phase)],c=[Math.min(.22,.18*o)+.012*e*n,-.25+.018*e*a-.3*(1-r.gun),.4-.05*i];return[c,ci(c,[s[0],s[1]+.1*i*Math.hypot(...s),s[2]],Bi,Vi)]},m=(e,i,o,s=0)=>{if(!n||n.down||Gi(e,[n.x,n.y+_e(n),n.z])>Li)return;let f=t.pose(),m={at:[...f.at],yaw:f.yaw,hips:[...f.hips],rot:f.rot.map(e=>[...e])},[h,g,_]=Mt(i,o,s),v=([e,t,n])=>[h[0]*e+g[0]*t+_[0]*n,h[1]*e+g[1]*t+_[1]*n,h[2]*e+g[2]*t+_[2]*n],y=e=>[kt(e,h),kt(e,g),kt(e,_)];for(let e of[J.SPINE,J.CHEST])m.rot[e]=Y(m.rot[e],X(Bi,.12*Ui(o,-1.3,1.3)));let b=Mn(m),x=[-Math.sin(i),0,-Math.cos(i)],S=Ot(b.pos[J.HEAD],An(b.rot[J.HEAD],[0,.02,-.08]));m.at=Ot(m.at,q(e,Ki(S,[-x[0]*Ri,-zi,-x[2]*Ri],r.plant)));let C=Mn(m),w=[-Math.sin(m.yaw),0,-Math.cos(m.yaw)];for(let e of[J.THIGH_L,J.THIGH_R])Yi(m,C,e,b.pos[e+2],w,!0);let[T,E]=p(),D=[0,1,2].map(e=>Rr[1]*E[2][e]-Rr[0]*E[1][e]),O=[0,1,2].map(e=>T[e]-.078*D[e]+.022*E[0][e]);for(let n of[-1,1]){let i=Math.cos(H*t.phase)*n,o=r.amp*(1+.5*r.sprint),s=At([.25,-.17,.36],[.2,-.14,.42],r.sprint);s=[s[0],s[1]+.07*o*i,s[2]+.12*o*i],n<0&&(s=At(s,[-.2,-.65,.2],r.gun*(1-Ui(r.amp*2.5)))),s=At(s,[.38,-.2,.34],r.air),s=At(s,[.3,.02,.45],r.rise),s=At(s,[.14,-.1,.5],r.dash);let f=r.wall*Ui(l*n);s=At(s,[.42,-.16,.42],f),s=At(s,n>0?[.36,-.26,.38]:[.28,-.1,.42],r.slide);let p=Math.sin(c*12+(n>0?Math.PI:0));if(s=At(s,[.46,.05+.2*p,.4+.1*p],r.stun),u){let[t,i]=[-u.dz,u.dx];kt([t,0,i],h)<0&&([t,i]=[-t,-i]);let a=.35000000000000003,[o,c,l]=y(q([u.x+u.dx*a+t*.12*n,u.y+.03,u.z+u.dz*a+i*.12*n],e));s=At(s,[o*n,Math.max(c,-.28),Math.max(l,.4)],r.plant)}n>0&&(a=r.gun*(1-Ui(r.plant+f+r.stun)),s=At(s,O,a));let g=.75+.25*r.sprint;for(let[e,t]of[[.25,r.air],[.1,r.rise],[1,r.dash],[.1,f],[.1,r.slide],[.1,r.plant],[.2,r.stun]])g+=(e-g)*t;d[(n+1)/2]=n>0?g+(.9-g)*a:g;let _=Ot(e,v([s[0]*n,s[1],s[2]])),b=n<0?J.ARM_L:J.ARM_R;if(Yi(m,C,b,_,v([Hi[0]*n,Hi[1],Hi[2]])),m.rot[b+2]=X(Vi,n*(1+.5*(r.plant+r.slide))),n>0&&a>.002){let e=Qn(v(E[0]),v(D));m.rot[b+2]=jn(m.rot[b+2],Y(Wi(Mn(m).rot[J.FOREARM_R]),e),a)}}return Mn(m)};return{get id(){return n?.id??-1},update:f,pose:m,draw(e,t,r,i,o=0,s=[.7,.7,.7]){let c=m(t,r,i,o);if(c){let t=xi(s);Ii(e,Mi(2),c,t),[J.HAND_L,J.HAND_R].forEach((n,r)=>{let i=c.rot[n];ea(e,c.pos[n],An(i,[0,-1,0]),An(i,[r*2-1,0,0]),An(i,[0,0,-1]),d[r],t[7])}),a>.2&&ai(e,c.pos[J.HAND_R],c.rot[J.HAND_R],1,Ui(a*1.5-.5),n?.ammo)}},aim(e){let t=Math.hypot(...e);s=t<3?t?e.map(e=>e*3/t):[0,0,3]:e},muzzle:()=>oi(...p())}},ia=(e,t,n,r,i,a)=>{let o=Mt(r,i)[2],s=re(e,t,o,80),c=[0,1,2].map(e=>t[e]+o[e]*s);return{end:c,hit:s<80,local:Mt(r,a).map(e=>(c[0]-n[0])*e[0]+(c[1]-n[1])*e[1]+(c[2]-n[2])*e[2])}},aa=(e,t)=>e&&t?t.shots-e.shots&255:0,oa=3,sa=(e,t,r,i,a,o)=>{let s=0,c,l=!1,u=0,d=/* @__PURE__ */ new Map,p=()=>.94+.12*(u++*.618%1),m=e=>t.play(K.LASER,e,e?.7:.5,p());return{step(e,t){let r=aa(e,t);s+=r;for(let e=0;e<r;e++)o.pitch=Math.min(n,o.pitch+f),i.fire()},frame(n,o,u,f,p){if(a.update(p),o){let e=c;e&&o.hits!=e.hits&&(t.play(K.HIT),r.hit()),e&&o.hp<e.hp?(t.play(o.down&&!e.down?K.DOWN:K.HURT),i.wound()):e&&o.hp>e.hp&&!e.down&&t.play(K.PACK),e&&(e.ammo<0||o.ammo>e.ammo)&&o.ammo>=0&&t.play(K.GUN);let n=!!(f&h.FIRE);n&&!l&&o.ammo==0&&!o.down&&t.play(K.DRY),l=n,r.vitals(o.hp,o.ammo),r.down(i.lie,o.down/60),c={...o}}else c=void 0;if(n){let[e,t,r]=Mt(n.yaw,n.drawn),i=n.muzzle,o=[0,1,2].map(a=>n.cam[a]+e[a]*i[0]+t[a]*i[1]+r[a]*i[2]);for(a.mount(o);s>0;s--)a.shoot(o,n.end,n.hit,!0),m()}s=0;for(let t of u){let n=d.get(t.id),r=Math.min(n===void 0?0:t.shots-n&255,oa),[i,o]=li(t,e),[s,c]=ui(t,i);for(let e=0;e<r;e++)a.shoot(oi(s,c),i,o),m([t.x,t.y+_e(t),t.z]);d.set(t.id,t.shots)}for(let e of d.keys())u.some(t=>t.id==e)||d.delete(e)}}},ca=e=>.6+.2*e,la=e=>e?.mode===g.GROUND||e?.mode===g.CROUCH,ua=e=>la(e)||e?.mode===g.WALLRUN,da=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],fa=e=>.02+.0025*e,pa=.006,ma=.03,ha=.14,ga=.05,_a=5,va=9,ya=6.5,ba=.25,xa=.22,Sa=.9,Ca=4,wa=1,Ta=.12,Ea=24,Da=15.7,Oa=.45,ka=[-8,4,5],Aa=3,ja=[-1,1.2],Ma=4,Na=[-.25,.4,.5],Pa=[-1.5,.8,1.5],Fa=[.9,.3],Ia=[.1,.05,11],La=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ra=(e,t)=>{let n=Math.ceil(t*120);for(let r=0;r<n;r++)e[1]+=(-15.7*Da*e[0]-2*Oa*Da*e[1])*(t/n),e[0]+=e[1]*(t/n)},za=()=>{let e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c,l,u=[0,0],d=[0,0],f=[0,0],p={dy:0,pitch:0,roll:0,fov:0,lines:0,stride:0,hurt:0,kick:0,lie:0,fire(){s++,u[1]+=Na[0],d[1]+=Na[1],f[1]+=Na[2]*Math.sin(s*2.4),p.kick=1},wound(){u[1]+=Pa[0],d[1]+=Pa[1],f[1]+=Pa[2]*Math.sin(s++),p.hurt=1},jolt(){u[1]+=ka[0],d[1]+=ka[1],f[1]+=ka[2],p.hurt=1},punch(){u[1]+=ja[0],d[1]+=ja[1],a=1},update(s,m,_,y={ev:0,fall:0}){let b=e=>Math.min(1,_*e),x=s?ve(s):0,S=s&&l&&ua(s)&&ua(l)?Math.hypot(s.x-l.x,s.z-l.z):0;S<1&&(p.stride+=S/ca(x)),e+=((la(s)&&S>.5*_&&S<1?1:0)-e)*b(10),l=s,y.ev&v.LAND&&(u[1]-=xa*Math.min(y.fall,20)),y.ev&v.CLIMB&&(u[1]-=xa*Ca),y.ev&(v.JUMP|v.DOUBLE)&&(u[1]+=Sa),y.ev&v.GRAB&&(d[1]-=wa),Ra(u,_),Ra(d,_),Ra(f,_),p.hurt*=Math.exp(-_*Aa),a*=Math.exp(-_*10),p.kick*=Math.exp(-_*22),p.lie+=(+!!s?.down-p.lie)*b(5),o+=_*Ia[2];let C=s?Math.min(1,s.stun/48):0,w=s?_e(s):0;c=s?c===void 0?w:c+(w-c)*b(14):void 0,p.dy=(c??0)-w+u[0]-Math.cos(p.stride*2*Math.PI)*fa(x)*e-p.lie*(w-Fa[1]),i+=((s?.mode===g.CLIMB?Ta*Math.sin(Math.PI*La(s.t/Ea)):0)-i)*b(10),p.pitch=d[0]+i+Math.sin(o*.8)*Ia[1]*C;let T=s?.mode===g.WALLRUN?da[s.wall]:[0,0],E=s?T[0]*Math.cos(s.yaw)-T[1]*Math.sin(s.yaw):0,D=+!!(m&h.RIGHT)-!!(m&h.LEFT);t+=(D*ma+E*ha+(s?.mode===g.SLIDE?ga:0)-t)*b(8),p.roll=t+Math.sin(p.stride*Math.PI)*pa*e+f[0]+Math.sin(o)*Ia[0]*C+p.lie*Fa[0];let O=!!s&&s.dash>50;n+=(+O-n)*b(O?40:6),r+=(La((x-6)/3)-r)*b(4),p.fov=r*_a+n*va+a*Ma,p.lines+=(La((x-ya)/(9-ya))*ba+n*.75-p.lines)*b(8)}};return p},Ba=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Va=e=>{let t=e.loop(K.WIND),n=e.loop(K.SCRAPE),r=0,i=/* @__PURE__ */ new Map,a=(t,n,r)=>{let i=ye(t);e.play(t.mode===g.WALLRUN?K.WALLSTEP:K.STEP,r,i||t.mode===g.WALLRUN?1:t.mode===g.CROUCH?.35:.6,(i?.92:1)*(n&1?1.06:.94))},o=(t,n)=>e.play(K.LAND,n,Ba(t/14,.2),1.25-.5*Ba(t/20));return{me(i,s,c){let l=Math.floor(c),u=l>r;if(r=l,!i||e.muted)return;u&&a(i,l);for(let[t,n]of[[v.JUMP,K.JUMP],[v.DOUBLE,K.DOUBLE],[v.DASH,K.DASH],[v.GRAB,K.GRAB],[v.CLIMB,K.SCUFF]])s.ev&t&&e.play(n);s.ev&v.LAND&&o(s.fall);let d=Ba((Math.hypot(i.vx,i.vy,i.vz)-4)/12);t.set(.55*d**1.5,.6+.9*d);let f=Ba(ve(i)/9);n.set(i.mode===g.SLIDE?.2+.5*f:0,.8+.4*f)},others(t){for(let n of t){let t=i.get(n.id);if(t&&!e.muted){let e=[n.x,n.y+.1,n.z],r=Math.hypot(n.x-t.p.x,n.z-t.p.z);if(ua(n)&&ua(t.p)&&r<1){let i=Math.floor(t.stride);t.stride+=r/ca(ve(n)),Math.floor(t.stride)>i&&a(n,i,e)}n.ground&&!t.p.ground&&t.p.vy<-3&&o(-t.p.vy,e)}i.set(n.id,{p:n,stride:t?.stride??0})}for(let e of i.keys())t.some(t=>t.id===e)||i.delete(e)}}},Ha=`h5,aside,nav,output,section,em,u,ul,dl,s,mark{position:absolute;margin:0;padding:0;pointer-events:none;user-select:none;white-space:pre-line}h5{top:8px;right:12px;font-size:12px}u{inset:0;opacity:0;background:radial-gradient(ellipse at center,#0000 35%,#d10000dd 120%)}nav{top:8px;left:50%;transform:translateX(-50%);display:grid;grid-template-columns:1fr auto 1fr;gap:2px 16px;align-items:center;text-align:center;font-size:13px}nav span,nav time{font:900 clamp(16px,4.6vw,24px)/1 system-ui,sans-serif;letter-spacing:.03em;white-space:nowrap}nav time{min-width:4.2ch;font-variant-numeric:tabular-nums;font-size:clamp(14px,3.8vw,20px)}nav small{font-size:clamp(10px,2.6vw,12px);white-space:nowrap;opacity:.95}nav small:first-of-type{text-align:right}nav small:last-of-type{text-align:left}output{top:20%;left:50%;transform:translateX(-50%);padding:6px 18px;font:900 clamp(18px,3.4vw,30px)/1.1 system-ui,sans-serif;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;background:#000a;border-bottom:3px solid currentColor}em{font-style:normal;font-size:13px;font-weight:800;line-height:1.1;text-align:center;transform:translate(-50%,-50%)}em span{display:block;font-size:20px;line-height:1}section{inset:0;z-index:2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:0 12px;text-align:center;background:#000c}section h6{font:900 clamp(30px,9vw,72px)/1 system-ui,sans-serif;letter-spacing:.04em}section strong{font-size:34px}section td:first-child{text-align:left;opacity:1}section td+td{text-align:center}section th{padding:2px 10px;font-size:12px;opacity:.7;font-weight:600}aside{inset:0;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:0 12px;text-align:center;background:#000b}h6{margin:0;font-size:inherit;text-shadow:none}aside h6{font:900 clamp(36px,13vw,84px)/1 system-ui,sans-serif;letter-spacing:.04em;transform:skewX(-8deg);background:linear-gradient(#fe6,#f92 45%,#d21);-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 3px 0 #500) drop-shadow(0 0 14px #f604)}ul{left:12px;bottom:30px;display:flex;gap:4px;list-style:none}li{width:16px;height:6px;background:#fff;box-shadow:0 0 0 1px #0008}li.e{background:#0000;box-shadow:inset 0 0 0 1px #fffb,0 0 0 1px #0008}ul.low li{background:#f55}ul.low li.e{background:#0000}dl{left:50%;bottom:10px;transform:translateX(-50%);display:flex;align-items:center;gap:10px}dl svg{width:38px;fill:#fff;filter:drop-shadow(0 1px 1px #000)}@media(max-width:520px){dl{left:auto;right:12px;bottom:46px;transform:none}}dl data{font:900 clamp(30px,5vw,46px)/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}dl.e data{color:#f66}s{left:50%;top:50%;width:28px;height:28px;margin:-14px 0 0 -14px;background:linear-gradient(45deg,#0000 44%,#fff 44% 56%,#0000 56%),linear-gradient(-45deg,#0000 44%,#fff 44% 56%,#0000 56%);-webkit-mask:radial-gradient(#0000 6px,#000 7px);mask:radial-gradient(#0000 6px,#000 7px)}mark{inset:0;z-index:1;padding-top:30vh;text-align:center;color:#ddd;background:radial-gradient(ellipse at center,#6668 0%,#4a0c0ce8 130%);backdrop-filter:grayscale(1)}mark::first-line{font:900 clamp(30px,8vw,64px)/1 system-ui,sans-serif;letter-spacing:.24em}strong{font-size:22px}table{border-collapse:collapse;font-size:16px}td{padding:2px 10px}td+td{text-align:left}td:first-child{text-align:right;opacity:.7}`,Ua=2800,Wa=e=>`${Math.floor(e/60)}:${`${e%60}`.padStart(2,`0`)}`,Ga=e=>{e.insertAdjacentHTML(`beforeend`,`<aside hidden><h6>TINY FPS</h6><span></span><table><tr><td>Mouse<td>look<tr><td>WASD / ZQSD<td>move<tr><td>Shift<td>sprint<tr><td>Space<td>jump, again in the air<tr><td>Move key twice<td>dash that way<tr><td>C<td>crouch, slide when fast<tr><td>Left click<td>fire the gun<tr><td>M<td>mute</table><span>Take the enemy flag to your own base while yours is home. Take the gun at your rack.</span><strong></strong></aside><u></u><h5 hidden>Muted (M)</h5><ul>${`<li></li>`.repeat(5)}</ul><dl hidden><svg viewBox="0 0 38 22"><path d="M1 7c3-5 13-7 22-4l7 3 3 1v4l-6 1-4 2-1 1-3 6h-5l2-7-5-1c-6-1-12-3-10-6z"/></svg><data></data></dl><s hidden></s><mark hidden></mark><nav hidden><span></span><time></time><span></span><small></small><small></small></nav><output hidden></output><section hidden><h6></h6><strong></strong><table></table><span></span></section>`);let t=t=>e.querySelector(t),[n,r]=[`h5`,`aside`].map(e=>t(e)),[i,a]=[`aside span`,`aside strong`].map(e=>t(e)),o=(e,t)=>e.textContent!=t&&(e.textContent=t),s=t(`nav`),[c,d,f]=[...s.querySelectorAll(`span, time`)],[p,h]=[...s.querySelectorAll(`small`)],g=[...e.querySelectorAll(`li`)],[_,v,y,b]=[t(`ul`),t(`dl`),t(`s`),t(`mark`)],x,S=t(`output`),C=t(`u`),w=t(`section`),[T,E,D]=[`h6`,`strong`,`span`].map(e=>w.querySelector(e)),O=w.querySelector(`table`),k=[],A,j,ee=(e,t)=>e.style.color=u[t];return[c,p].forEach(e=>ee(e,0)),[f,h].forEach(e=>ee(e,1)),{title(e,t){r.hidden=!e,o(i,t),o(a,e)},mute:e=>n.hidden=!e,match(e,t){s.hidden=!1,o(c,`${l[0].toUpperCase()} ${e.score[0]}`),o(f,`${e.score[1]} ${l[1].toUpperCase()}`),o(d,e.over?`END`:Wa(e.clock)),e.flags.forEach((e,n)=>{let r=e.state===m.CARRIED?`taken by ${t(e.by)}`:e.state===m.DROPPED?`dropped ${e.left}s`:`home`;o(n?h:p,`${l[n]} flag: ${r}`)})},marks(t){for(;k.length<t.length;){let t=document.createElement(`em`);t.innerHTML=`<span></span><small></small>`,k.push(t),e.append(t)}k.splice(t.length).forEach(e=>e.remove()),t.forEach((e,t)=>{let n=k[t];n.style.left=`${e.x*100}%`,n.style.top=`${e.y*100}%`,ee(n,e.team);let[r,i]=[n.children[0],n.children[1]];r.style.transform=e.arrow===void 0?``:`rotate(${e.arrow}rad)`,o(r,e.arrow===void 0?`▼`:`▲`),o(i,`${e.kind===`base`?`Base `:``}${e.text}`)})},hurt(e){let t=e<.01?``:`${Math.min(1,e)}`;C.style.opacity!=t&&(C.style.opacity=t)},vitals(e,t){g.forEach((t,n)=>t.classList.toggle(`e`,n>=e)),_.classList.toggle(`low`,e<=1),v.hidden=t<0,v.classList.toggle(`e`,!t),o(v.lastElementChild,`${Math.max(t,0)}`)},hit(){y.hidden=!1,clearTimeout(x),x=setTimeout(()=>y.hidden=!0,140)},down(e,t){b.hidden=e<.02,b.style.opacity=`${Math.min(e,1)}`,o(b,b.hidden?``:`DOWN\nBack in ${t.toFixed(1)}`)},banner(e,t){S.hidden=!1,o(S,e),S.style.color=t===void 0?`#fff`:u[t],clearTimeout(A),A=setTimeout(()=>S.hidden=!0,Ua)},end(e,t){if(w.hidden=!e,!e)j=void 0;else{if(j!==e){j=e;let[t,n]=e.score,r=t>n?0:n>t?1:-1;o(T,r<0?`DRAW`:`${l[r].toUpperCase()} WINS`),T.style.color=r<0?`#fff`:u[r],o(E,`${t} – ${n}`);let i=[...e.players].sort((e,t)=>t.caps-e.caps||t.returns-e.returns||e.id-t.id);O.replaceChildren(),O.insertAdjacentHTML(`beforeend`,`<tr><th>Player<th>Captures<th>Returns</tr>`);for(let e of i){let t=O.insertRow();[e.name,e.caps,e.returns].forEach(e=>t.insertCell().textContent=`${e}`),t.style.color=u[e.team]}}o(D,`Next match in ${t}`)}}}},Ka=.0025,qa=Math.PI*2,Ja={KeyW:h.FORWARD,ArrowUp:h.FORWARD,KeyS:h.BACK,ArrowDown:h.BACK,KeyA:h.LEFT,ArrowLeft:h.LEFT,KeyD:h.RIGHT,ArrowRight:h.RIGHT,Space:h.JUMP,ShiftLeft:h.SPRINT,ShiftRight:h.SPRINT,KeyC:h.CROUCH},Ya=h.FORWARD|h.BACK|h.LEFT|h.RIGHT,Xa=(e,t)=>e&~Ya|t|h.DASH,Za=e=>Ja[e]??0,Qa=(e,t=()=>{})=>{let r=new AbortController,i=(e,t,n)=>e.addEventListener(t,n,{signal:r.signal}),a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Map,s=0,c={yaw:0,pitch:0,keys:0,take(){let e=s?Xa(c.keys,s):c.keys;return s=0,e},locked:()=>e.getRootNode().pointerLockElement==e,destroy:()=>r.abort()};i(e,`click`,()=>{Promise.resolve(e.requestPointerLock()).catch(()=>{})}),i(document,`mousemove`,e=>{c.locked()&&(c.yaw=((c.yaw-e.movementX*Ka)%qa+qa)%qa,c.pitch=Math.max(-1.55,Math.min(n,c.pitch-e.movementY*Ka)))}),i(document,`mousedown`,e=>{c.locked()&&!e.button&&(c.keys|=h.FIRE)}),i(document,`mouseup`,e=>{e.button||(c.keys&=~h.FIRE)}),i(document,`keydown`,e=>{let n=Za(e.code);if(e.code==`KeyM`&&!e.repeat&&c.locked()&&t(),n&&c.locked()){if(n&Ya&&!e.repeat&&!a.has(e.code)){let t=performance.now(),r=o.get(e.code);r!==void 0&&t-r<=250?(s=n,o.delete(e.code)):o.set(e.code,t)}a.add(e.code),c.keys|=n,e.preventDefault()}}),i(document,`keyup`,e=>{a.delete(e.code),c.keys&=~Za(e.code)});let l=()=>{c.keys=s=0,a.clear(),o.clear()};return i(window,`blur`,l),i(document,`pointerlockchange`,()=>c.locked()||l()),c},$a=(e,t,n)=>{let[r,i]=[e.x-t[0],e.z-t[2]];return r*r+i*i<n*n&&Math.abs(e.y-t[1])<1},eo=(e,t,n,r,i=!0)=>{let a=e.down>0;if(Ke(e,a?{...t,keys:0}:t,n,r),a)return e.down>0&&!--e.down&&me(e,n,r),!1;let o=n.def.teams[r].rack,s=!!o&&$a(e,o,1.2);return i&&s&&!e.rack&&(e.ammo=60),e.rack=s,e.cool=Math.max(0,e.cool-1),i&&t.keys&h.FIRE&&!e.cool&&e.ammo>0&&e.mode!==g.HANG&&e.mode!==g.CLIMB?(e.ammo--,e.shots=e.shots+1&255,e.cool=7,!0):!1},to=120,no=16,ro=e=>{let t={...e};return delete t.ack,delete t.by,t},io=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,z:e.z+(t.z-e.z)*n}),ao=(e,t,n)=>oe(e+(((t-e+Math.PI)%H+H)%H-Math.PI)*n),oo=(e,t)=>(t-e&65535)<32768,so=(e,t,n)=>({...t,...io(e,t,n),yaw:ao(e.yaw,t.yaw,n),pitch:e.pitch+(t.pitch-e.pitch)*n}),co=e=>{let t,n=0,r=0,i=[],a,o,s=[],c=0,l=0,u=!0,d=e=>{let t=e-100,n=0;for(;n+1<s.length&&s[n+1].t<=t;)n++;let r=s[n],i=s[n+1]??r;return{a:r,b:i,u:i.t>r.t?Math.max(0,Math.min(1,(t-r.t)/(i.t-r.t))):0}},f=e=>{if(!s.length)return;let{a:t,b:n,u:r}=d(e);return(t.s.tick+(n.s.tick-t.s.tick&65535)*r)%65536};return{you:(e,r=0)=>{[t,n]=[e,r]},step:(t,s)=>{let d=nt({...t,seq:r,view:s===void 0?void 0:f(s)});return r=r+1&65535,i.push(d),i.length>to&&i.shift(),a&&(o=ro(a),eo(a,d,e,n,u),c|=a.ev,l=Math.max(l,a.fall)),d},snapshot:(r,c)=>{s.push({t:c,s:r}),s.length>no&&s.shift();let l=r.players.find(e=>e.id===t);l&&(u=!r.over,i=i.filter(e=>!oo(e.seq,l.ack)),a=ro(l),o=ro(a),i.forEach((t,r)=>{r===i.length-1&&(o=ro(a)),eo(a,t,e,n,u)}))},events:()=>{let e={ev:c,fall:l};return c=l=0,e},me:e=>a&&o?so(o,a,Math.max(0,Math.min(1,e))):void 0,others:e=>{let n=s.at(-1);if(!n)return[];let{a:r,b:i,u:a}=d(e);return n.s.players.filter(e=>e.id!==t).map(e=>{let t=r.s.players.find(t=>t.id===e.id),n=i.s.players.find(t=>t.id===e.id);return t&&n?so(ro(t),ro(n),a):ro(n??t??e)})}}},lo={x0:.05,x1:.95,y0:.15,y1:.92},uo=(e,t,n,r,i)=>{let[a,o]=[r-e,i-t];return Math.atan2(a*Math.cos(n)-o*Math.sin(n),-a*Math.sin(n)-o*Math.cos(n))},fo=e=>{let[t,n]=[Math.sin(e),-Math.cos(e)],[r,i]=[(lo.x0+lo.x1)/2,(lo.y0+lo.y1)/2],[a,o]=[(lo.x1-lo.x0)/2,(lo.y1-lo.y0)/2],s=Math.min(a/(Math.abs(t)||1e-9),o/(Math.abs(n)||1e-9));return[r+t*s,i+n*s]},po=2.6,mo=e=>{let t=[],n=(n,r,[i,a,o])=>{let s=Math.round(Math.hypot(i-e.eye[0],a+po-e.eye[1],o-e.eye[2])),c=e.project(i,a+po,o),l=c&&c[0]>=lo.x0&&c[0]<=lo.x1&&c[1]>=lo.y0&&c[1]<=lo.y1,u=`${s} m`;if(l)t.push({team:n,kind:r,x:c[0],y:c[1],text:u});else{let a=uo(e.eye[0],e.eye[2],e.yaw,i,o),[s,c]=fo(a);t.push({team:n,kind:r,x:s,y:c,arrow:a,text:u})}},r=e.flags.some(t=>t.state===m.CARRIED&&t.by===e.id);return e.flags.forEach((t,i)=>{if(t.state===m.CARRIED&&t.by===e.id){n(e.team,`base`,e.bases[e.team]);return}if(r&&i===e.team&&t.state===m.HOME)return;let a=t.state===m.HOME?e.bases[i]:t.state===m.DROPPED?[t.x,t.y,t.z]:e.where(t.by);a&&n(i,`flag`,a)}),t},ho=(e=[],t=0,n=0)=>e.filter((e,r)=>n+r<32&&t>>>n+r&1),go=(e,t,n,r)=>{let i=n.map(e=>e*.45);Vt(e,Rt(1,1,[1,1],[0,0]),t,[t[0],t[1]+.72,t[2]],[1,0,0],1,.06,i);let[a,o,s]=t;zt(e,Rt(1,0,[1,1]),[a,o+.74,s],Mt(0,0),[0,0,0],[.3,.035,.3],n);let c=e.length;en(e,[a,o+.045,s],p-.07,p,n),Qt(e,c,1.2*Kt*(.7+.3*Math.sin(r*2.5))),zt(e,Hr(0),[a,o+1.05+.04*Math.sin(r*2),s],Mt(r*.8,0),[0,0,0],1.5)},_o=[[[1,0,0],[0,1,0],[0,0,1]],[[-1,0,0],[0,0,1],[0,1,0]],[[0,1,0],[0,0,1],[1,0,0]],[[0,-1,0],[1,0,0],[0,0,1]],[[0,0,1],[1,0,0],[0,1,0]],[[0,0,-1],[0,1,0],[1,0,0]]],vo=(e,t,n,r)=>[[[e,t],[n,t],[n,r]],[[e,t],[n,r],[e,r]]],yo=[...vo(-.13,-.04,.13,.04),...vo(-.04,-.13,.04,.13)],bo=[...vo(-.035,-.09,.035,.04),[[-.035,.04],[.035,.04],[0,.11]],...vo(-.05,-.12,.05,-.095)],xo=(e,t,n,r,i,a,o)=>{let[s,,c]=Mt(n*.9,0),l=[t[0],t[1]+.45+.07*Math.sin(n*2.2+t[0]),t[2]],u=([e,t,n])=>[s[0]*e-c[0]*n,t,s[2]*e-c[2]*n];for(let[t,n,s]of _o){let c=(e,i,a)=>{let[o,c,d]=u([0,1,2].map(o=>t[o]*r*a+n[o]*e+s[o]*i));return[l[0]+o,l[1]+c,l[2]+d]};$t(e,c(-r,-r,1),c(r,-r,1),c(r,r,1),i),$t(e,c(-r,-r,1),c(r,r,1),c(-r,r,1),i);let d=e.length;for(let[t,n,r]of a)$t(e,c(...t,1.01),c(...n,1.01),c(...r,1.01),o);for(let t=d;t<e.length;t+=10)e[t+8]=-2}},So=(e,t,n)=>xo(e,t,n,.17,[.86,.9,.88],yo,[.1,1.2,.4]),Co=(e,t,n)=>xo(e,t,n,.15,[.34,.14,.58],bo,[.3,1.4,1.8]),wo=14,To=e=>{let t=Mt(e.yaw,e.pitch)[2];return[e.x+t[0]*30,e.y+1.6+t[1]*30,e.z+t[2]*30]},Eo=.5,Do=e=>e.dash>50,Oo=e=>{let t=Cr();return t.update(e,0),{p:{...e},gait:t,dash:+Do(e),since:1e3,aim:0,focus:To(e)}},ko=(e,t)=>(n,i)=>{let a=re(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},Ao=(e,t,n,r)=>{for(let n of e.keys())t.some(e=>e.id==n)||e.delete(n);for(let i of t){let t=e.get(i.id);t?(t.gait.update(i,n,r&&ko(r,i.y)),t.dash+=(+Do(i)-t.dash)*(1-Math.exp(-n*wo)),t.since=i.shots==t.p.shots?t.since+n:0,t.aim=t.since==0?1:t.aim+(+(t.since<Eo)-t.aim)*(1-Math.exp(-n*12)),t.focus=t.since<Eo?r?li(i,r)[0]:To(i):t.focus,t.p={...i}):e.set(i.id,Oo(i))}},jo=(e,t,n,r,i)=>{let[a,o]=ui(n,r),s=e.rot.slice(),c={...e,rot:s},[l,u]=[o[0],o[2].map((e,t)=>e*Rr[1]-o[1][t]*Rr[0])],d=a.map((e,t)=>e-.078*u[t]+.022*l[t]),f=[l[0]*.7,-1,l[2]*.7];return Yi(c,t,J.ARM_R,d.map((e,n)=>t.pos[J.HAND_R][n]+(e-t.pos[J.HAND_R][n])*i),f),s[J.HAND_R]=jn(s[J.HAND_R],Y(Wi(Mn(c).rot[J.FOREARM_R]),Qn(l,u)),i),c},Mo=(e,t,n,r)=>{let i=jt([-t.p.vx,0,-t.p.vz]),[a,o,s]=n.map(e=>.6+.6*e);[[.5,.12,1.3],[.9,-.16,1.7],[1.25,.14,1.2]].forEach(([n,c,l],u)=>{let d=r([c,n,-.2-.1*u]),f=d.map((e,n)=>e+i[n]*l*t.dash);for(let t of[[-i[2]*.03,0,i[0]*.03],[0,.03,0]])for(let n of[d.map((e,n)=>e+t[n]),d.map((e,n)=>e-t[n]),f])e.push(...n,0,1,0,a,o,-2,s)})},No=(e,t,n,r=1)=>{let i=t.gait.pose(),{p:a}=t;a.down&&(i={...i,at:[i.at[0],i.at[1]-.5*Math.min(Math.max(1-a.down/30,0),1),i.at[2]]});let o=Mn(i);if(t.aim>.01&&a.ammo>=0&&(i=jo(i,o,a,t.focus,t.aim),o=Mn(i)),Ii(e,Mi(r),o,xi(n)),a.ammo>=0&&!a.down&&ai(e,o.pos[J.HAND_R],o.rot[J.HAND_R],r),t.dash>.15){let[r,a]=[Math.sin(i.yaw),Math.cos(i.yaw)],{x:o,y:s,z:c}=t.p;Mo(e,t,n,([e,t,n])=>[o+e*a-n*r,s+t,c-e*r-n*a])}},Po=r,Fo=o+.05,Io=1.5,Lo=.6,Ro=8,zo=2.5,Bo=3,Vo=.4,Ho=.012,Uo=.2,Wo=[1.2,1.45],Go=[1.6,.12,.08],Ko=[.9,.07,.05],qo=[.85,.07,.05],Jo=(e,t,n,r)=>{let i=-1/0;for(let a of e)if(a!=t&&a.min[0]<=n&&n<=a.max[0]&&a.min[2]<=r&&r<=a.max[2]){if(a.max[1]>t.max[1]+.001){if(a.min[1]<t.max[1])return 1/0}else i=Math.max(i,a.max[1])}return t.max[1]-i},Yo=({brushes:e,floor:t},n)=>{let r=n.max.map((e,t)=>e-n.min[t]),i=[...r].sort((e,t)=>e-t),a={beam:i[1]<=Lo&&i[2]>=2*Lo,lips:[],stripes:[]};if(a.beam)return a;for(let i of[0,2]){let o=2-i;for(let t of[0,1]){let s=[n.min[0],0,n.min[2]];s[i]=(t?n.max:n.min)[i]+(t?Vo:-.4),s[o]=(n.min[o]+n.max[o])/2;let c=Jo(e,n,s[0],s[2]);c>Po&&c<=Fo&&r[o]>=Io&&a.lips.push([i,t])}n.min[1]>t&&r[1]>=zo&&r[o]>=Ro&&r[i]<=Bo&&a.stripes.push([i,0],[i,1])}return a},Xo=(e,t,n,r,i,a,o)=>{let[s,c]=[(r+1)%3,(r+2)%3],l=[0,0,0];l[r]=i?1:-1;for(let[u,d]of[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]]){let f=[0,0,0];[f[r],f[s],f[c]]=[(i?n:t)[r],(u?n:t)[s],(d?n:t)[c]],e.push(...f,...l,o[0],o[1],a,o[2])}},Zo=e=>{let t=[];for(let n of e.brushes){let{beam:r,lips:i,stripes:a}=Yo(e,n),[o,s]=[n.min.map(e=>e-Ho),n.max.map(e=>e+Ho)];if(r)for(let e=0;e<3;e++)for(let n of[0,1])(e!=1||n)&&Xo(t,o,s,e,n,-1,qo);for(let[e,r]of i){let i=r?1:-1,a=(r?n.max:n.min)[e],o=[n.min[0],n.max[1]+Ho,n.min[2]],s=[n.max[0],n.max[1]+Ho,n.max[2]];[o[e],s[e]]=r?[a-Uo,a]:[a,a+Uo],Xo(t,o,s,1,1,-2,Go);let[c,l]=[o.slice(),s.slice()];[c[1],l[1]]=[n.max[1]-Uo,n.max[1]],[c[e],l[e]]=[a+i*Ho,a+i*Ho],Xo(t,c,l,e,r,-2,Go)}for(let[e,r]of a){let i=2-e,[a,o]=[[...n.min],[...n.max]];[a[1],o[1]]=[n.min[1]+Wo[0],n.min[1]+Wo[1]],[a[i],o[i]]=[n.min[i]+.3,n.max[i]-.3],a[e]=o[e]=(r?n.max:n.min)[e]+(r?Ho:-.012),Xo(t,a,o,e,r,-2,Ko)}}return t},Qo=4.2,$o=({teams:e})=>{let t=[];return e.forEach(({base:[e,n,r]},i)=>{let a=Yt(i),o=a.map(e=>.25+.45*e),s=(i,a,o,s,c,l)=>Xo(t,[e+i,n+l,r+a],[e+o,n+l,r+s],1,1,-1,c);s(-4.2,-4.2,Qo,Qo,o,.02);for(let[e,t,n,r]of[[-4.2,-4.2,Qo,-3.85],[-4.2,3.85,Qo,Qo],[-4.2,-4.2,-3.85,Qo],[3.85,-4.2,Qo,Qo]])s(e,t,n,r,a.map(e=>e*.8),.03)}),t},es=10,ts=150,ns=3,rs=3,[is,as,os,ss]=[[.3,.3,.29],[.09,.09,.1],[.8,.8,.78],[.85,.62,.08]],cs=({brushes:e})=>[0,2].flatMap(t=>[Math.min(...e.map(e=>e.min[t])),Math.max(...e.map(e=>e.max[t]))]),ls=e=>{let t=cs(e),n=Math.hypot(t[1]-t[0],t[3]-t[2])/2+ts,r=(e,t)=>{let r=[];for(let i=0;(t-e)/2+es+8+i*72<=n;i++)r.push(e-es-8-i*72,t+es+8+i*72);return r.sort((e,t)=>e-t)};return{box:t,reach:n,xs:r(t[0],t[1]),zs:r(t[2],t[3])}},us=({brushes:e,floor:t})=>e.map(e=>e.min[1]<=t?{...e,min:[e.min[0],-80,e.min[2]]}:e),ds=e=>{let{box:t,xs:n,zs:r}=ls(e),i=[],a=(e,t,n,r,a,o)=>Xo(i,[e,-80+a,t],[n,-80+a,r],1,1,-1,o),[o,s]=[(t[0]+t[1])/2,(t[2]+t[3])/2];a(o-1e3,s-1e3,o+1e3,s+1e3,0,is),a(t[0],t[2],t[1],t[3],.12,as);for(let{min:t,max:n}of e.brushes)t[1]<=e.floor&&a(t[0]-rs,t[2]-rs,n[0]+rs,n[2]+rs,.3,is);for(let[e,t,i]of[[0,n,r],[1,r,n]])for(let n of t){let t=(t,r,i,o,s,c)=>e?a(i,n+t,o,n+r,s,c):a(n+t,i,n+r,o,s,c);t(-8,8,i[0]-8,i[i.length-1]+8,.12,as),i.forEach((e,n)=>{for(let n of[-1,1])for(let r=0;r<8;r++)t(2*r-8+.5,2*r-8+1.5,e+n*8,e+n*11,.24,os);let[r,a]=[e+8+ns,i[n+1]-8-ns];if(a>r){t(-7.6,-7.2,r,a,.24,os),t(7.2,7.6,r,a,.24,os);for(let e=r+2;e+4<a;e+=9)t(-.2,.2,e,e+4,.24,ss)}})}return i},fs=Object.keys(y).length,ps=(e,t,n)=>{let r=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,144665)|0;return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967296},ms=(e,t,n,r)=>{let[i,a]=[Math.floor(e),Math.floor(t)],[o,s]=[e-i,t-a].map(e=>e*e*(3-2*e)),c=(e,t)=>ps((i+e)%n,(a+t)%n,r);return(c(0,0)*(1-o)+c(1,0)*o)*(1-s)+(c(0,1)*(1-o)+c(1,1)*o)*s},hs=(e,t,n,r,i)=>{let[a,o]=[0,.5];for(let s=0;s<r;s++,o/=2)a+=o*ms(e*(1<<s),t*(1<<s),n<<s,i+s);return a/(1-o*2)},gs=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),_s=(e,t)=>e.map(e=>e*t),vs=e=>Math.min(Math.max(e,0),1),ys=Math.PI*2,bs=[];bs[y.BRICK]=(e,t)=>{let n=Math.floor(t*8),r=e*4+(n&1)*.5,[i,a,o]=[Math.floor(r)%4,r%1,t*8%1],s=ms(e*16,t*16,16,5),c=.8+.4*s;return a<.05||o<.1?[_s([165,160,150],.7+.3*c),.1+.1*s]:[_s([170,78,56],(.8+.4*ps(i,n,1))*c*(.85+.15*o)),.7+.2*s+.1*vs(Math.min(a-.05,o-.1)*12)]},bs[y.TILE]=(e,t)=>{let[n,r]=[Math.floor(e*4),Math.floor(t*4)],[i,a]=[e*4%1,t*4%1],o=ms(e*16,t*16,16,7),s=.9+.2*o;return i<.05||a<.05?[_s([85,85,80],s),.1]:[_s([196,190,172],s*(.88+.08*(n+r&1)+.1*ps(n,r,2))),.8+.1*o+.1*vs((Math.min(i,a)-.05)*14)]},bs[y.LAVA]=(e,t)=>{let n=hs(e*4,t*4,4,4,11),r=Math.max(0,1-Math.abs(n-.5)*7)**2;return[gs(gs([55,8,4],[230,70,8],n),[255,215,90],r),.5]},bs[y.STONE]=(e,t)=>{let n=hs(e*8,t*8,8,4,3);return[_s([128,124,120],.45+.7*(n*1.3+.1*ps(Math.floor(e*128),Math.floor(t*128),4))),vs(n*1.4-.2)]},bs[y.METAL]=(e,t)=>{let[n,r,i,a]=[Math.floor(e*2),Math.floor(t*2),e*2%1,t*2%1],o=vs((ms(e*8,t*8,8,13)-.68)*6),s=e=>Math.min(Math.max(Math.round((e-.1)/.4),0),2)*.4+.1,[c,l]=[s(i),s(a)],u=c==l&&c==.5?1:Math.hypot(i-c,a-l),d=vs(1-u/.07),f=_s([98,108,124],(.9+.2*ms(e*32,t*32,32,9)+.12*ps(n,r,6))*(1+.3*d)*(.65+.35*vs((u-.06)/.04)));return Math.min(i,a,1-i,1-a)<.03?[_s([40,44,50],1+o),.05]:[gs(f,[105,68,45],o*.7),.5+.1*(1-o)+.4*d]},bs[y.WOOD]=(e,t)=>{let n=Math.floor(t*8),r=e*2+ps(n,0,8)*2,[i,a,o]=[Math.floor(r)%2,r%1,t*8%1],s=ps(n,i,3),c=.5+.5*Math.sin(ys*(t*40+2.5*ms(e*4,t*4,4,21)+s*7));return o<.08||a<.015?[[28,18,10],.05]:[gs([92,58,32],[158,106,62],c*.6+s*.35),.7+.15*c+.15*vs((o-.08)*15)]},bs[y.MOSS]=(e,t)=>{let n=Math.floor(t*4),r=e*2+(n&1)*.5,[i,a,o]=[Math.floor(r)%2,r%1,t*4%1],s=Math.min(a,1-a,(o<.5?o:1-o)*.5),c=a<.04||o<.06,l=vs((.3*hs(e*12,t*12,12,3,17)-.03-s)*12),u=ms(e*64,t*64,64,19),d=_s([128,126,118],(.7+.4*ps(i,n,5))*(.7+.5*ms(e*16,t*16,16,15)));return[gs(c?_s(d,.45):d,gs([52,100,34],[96,148,56],u),l),c?.1+.6*l*u:.6+.2*vs(s*30)+.2*l*u]},bs[y.GRATE]=(e,t)=>{let[n,r]=[e*8%1,t*8%1],i=Math.max(Math.abs(n-.5),Math.abs(r-.5)),a=Math.min(Math.abs(n-.5),Math.abs(r-.5))>.43,o=ms(e*16,t*16,16,23);return i<.36?[[9,9,12],0]:[_s(gs([104,108,116],[96,80,68],vs((o-.55)*4)),(a?1.25:1)-(.5-i)*2.2+.2*o),a?1:.6+.4*vs((i-.36)*12)]},bs[y.CONCRETE]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=hs(e*4,t*4,4,3,41),a=ps(Math.floor(e*128),Math.floor(t*128),43)>.992,o=Math.hypot(n%.5-.25,r%.5-.25)<.02,s=(.94+.1*i+.03*ps(Math.floor(e*2),Math.floor(t*2),44))*(a||o?.9:1);return n<.015||r<.015?[_s([160,164,172],s),.3]:[_s([206,209,214],s),o?.5:.8+.2*i-(a?.15:0)]},bs[y.GLASS]=(e,t)=>{let n=e*2%1,r=((n+t*.7)%1-.5)/.12,i=Math.exp(-r*r);return n<.03||t<.03?[_s([150,158,170],1-.3*n),.9]:[gs(gs([7,20,44],[48,88,136],t**2),[120,160,200],i*.18),.4]},bs[y.STEEL]=(e,t)=>{let n=Math.floor(t*128),r=.5*ps(n,3,31)+.5*ms(e*8,0,8,n+7),i=e*4%1;return i<.03?[[60,66,76],.1]:[_s([176,184,196],.8+.35*r+(i>.97?.15:0)),.6+.2*r]},bs[y.PAINT]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=ps(Math.floor(e*128),Math.floor(t*128),47);return n<.02||r<.02?[[200,200,206],.3]:[_s([246,246,248],.96+.06*i),.85+.04*i]};var xs=()=>{let e=new Uint8ClampedArray(fs*128*128*4);return bs.forEach((t,n)=>{for(let r=0;r<16384;r++){let[i,a]=t(r%128/128,Math.floor(r/128)/128);e.set([...i,a*255],(n*128*128+r)*4)}}),e},Ss=8,Cs=40,ws=130,Ts=60,Es=[[1,.45,.12],[.2,.6,1],[.9,.15,.2],[.25,.85,.55]],Ds=e=>{let{box:t,reach:n,xs:r,zs:i}=ls(e),[a,o]=[(t[0]+t[1])/2,(t[2]+t[3])/2],s=Math.min(...e.brushes.map(e=>e.max[1]));return r.slice(1).flatMap((e,c)=>i.slice(1).flatMap((l,u)=>{let[d,f,p,m]=[r[c]+8,e-8,i[u]+8,l-8];if(Math.hypot((d+f)/2-a,(p+m)/2-o)>n||d<a&&a<f&&p<o&&o<m)return[];let[h,g]=[f-d,m-p].map(e=>Math.max(1,Math.round(e/Cs)));return Array.from({length:h*g},(e,n)=>{let[r,i]=[n%h,Math.floor(n/h)],a=e=>ps(c*16+r,u*16+i,Ss+e),[o,l]=[d+(f-d)*r/h,p+(m-p)*i/g],[_,v]=[o+(f-d)/h,l+(m-p)/g],[b,x]=[7+a(3)*7,7+a(4)*7],[S,C]=[(o+_)/2,(l+v)/2],w=Math.hypot(Math.max(t[0]-S,S-t[1],0),Math.max(t[2]-C,C-t[3],0)),T=w<ws?-20+a(5)*30:-5+a(5)**1.5*100,E=[y.GLASS,y.STEEL,y.CONCRETE][+(a(6)>.7)+ +(a(6)>.85)],D={min:[o+b,-80,l+x],max:[_-b,w<Ts?Math.min(T,s-6):T,v-x],top:y.CONCRETE,side:E},O=D.max[1];return a(0)>.75?[]:a(7)<.35?[D,{min:[S-(_-o)/6,O,C-(v-l)/6],max:[S+(_-o)/6,O+3+a(8)*3,C+(v-l)/6],top:y.PAINT,side:y.PAINT,tint:Es[Math.floor(a(9)*Es.length)]}]:[D]}).flat()}))},Os=1.3,ks=6.5,As=.4,js=3,Ms=12,Ns=4.4*Os,Ps=4,Fs=260,Is=90,Ls=[[.95,.62,.03],[.9,.9,.88],[.04,.04,.045],[.7,.05,.06],[.08,.22,.7],[.5,.52,.55]],Rs=e=>{let{xs:t,zs:n}=ls(e),r=e=>e.slice(e.length/2-2,e.length/2+2),i=[];for(let[e,a,o]of[[0,t,n],[1,n,t]])for(let t of r(a))for(let n of[1,-1]){let a=n>0?r(o):r(o).reverse();a.forEach((r,o)=>Array.from({length:js},(r,s)=>i.push({axis:e,at:t,d:n,stops:a,cell:o,slot:s,paint:0})))}return i.map((e,t)=>[ps(t,e.cell,3),e,ps(t,1,4)]).sort((e,t)=>e[0]-t[0]).slice(0,64).map(([,e,t])=>({...e,paint:Math.floor(t*Ls.length)}))},zs=({axis:e,d:t})=>e?[t,0]:[0,t],Bs=(e,t)=>{let{axis:n,at:r,d:i,stops:a,cell:o,slot:s}=e,c=t-n*16/2,l=Math.floor(c/16),u=Math.min(Math.max((c-l*16-s*As)/(ks-2*As),0),1),d=((o+l)%a.length+a.length)%a.length,f=e=>a[e]-i*(Ms+Ns/2+s*8),p=f(d),m=u*u*(3-2*u),h=p+((d+1<a.length?f(d+1):p+i*72)-p)*m,g=d+1==a.length?1-m:d?1:m;return n?[h,r+i*Ps,g]:[r-i*Ps,h,g]},Vs=(e,[t,n,r,i],a)=>{$t(e,t,n,r,a),$t(e,t,r,i,a)},Hs=(e,t,n,r,i,a,o)=>{let s=([e,t,n,r],i)=>[[e,i,n],[t,i,n],[t,i,r],[e,i,r]],[c,l]=[s(r,t),s(i,n)];c.forEach((t,n)=>{let r=(n+1)%4;Vs(e,[c[r],t,l[n],l[r]],a)}),Vs(e,[l[0],l[3],l[2],l[1]],o)},[Us,Ws,Gs]=(()=>{let[e,t,n]=[[],[],[]];Hs(e,.25,.85,[-.95,.95,-2.2,2.2],[-.9,.9,-2.05,2.05],[1,1,1],[1,1,1]),Hs(t,.85,1.4,[-.82,.82,-.6,1.5],[-.7,.7,-.15,1.05],[.1,.13,.17],[1,1,1]);for(let[e,t]of[[-1,[1,.95,.75]],[1,[1,.08,.05]]])for(let r of[-.6,.6]){let i=n.length,[a,o]=[e*2.2,e*2.1],s=[[r+.3,.5,a],[r-.3,.5,a],[r-.3,.68,a],[r+.3,.68,a]];Vs(n,e<0?s:s.reverse(),t);let c=[[r-.3,.86,o],[r-.3,.86,o-e*.25],[r+.3,.86,o-e*.25],[r+.3,.86,o]];Vs(n,e<0?c:c.reverse(),t),Qt(n,i,2.5)}return[e,t,n]})(),Ks=e=>{let t=Rs(e);return(e,n,r,i)=>{for(let a of t){let[t,o,s]=Bs(a,i),c=[t-n[0],-80-n[1],o-n[2]],l=c[0]**2+c[1]**2+c[2]**2;if(s<.05||l>Fs**2||c[0]*r[0]+c[1]*r[1]+c[2]*r[2]<-5.720000000000001)continue;let[u,d]=zs(a),f=[[-d,0,u],[0,1,0],[u,0,d]],p=[t,-79.88,o];zt(e,Us,p,f,[0,0,0],Os*s,Ls[a.paint]),l<Is**2&&zt(e,Ws,p,f,[0,0,0],Os*s,Ls[a.paint]),zt(e,Gs,p,f,[0,0,0],Os*s)}}},qs=1<<19,Js=2,Ys=1024,Xs=.6,Zs=.02,Qs=.05,$s=Math.tan(70*Math.PI/360),ec=10,tc=4,nc=`#version 300 es
|
|
2
2
|
layout(location=0)in vec3 p;layout(location=1)in vec3 n;layout(location=2)in vec4 c;
|
|
3
3
|
uniform mat4 m;uniform float Y;uniform vec3 J[3];out vec3 P,N;out vec4 C;
|
|
4
4
|
void main(){
|
|
5
5
|
if(Y>.5){vec2 q=vec2(gl_VertexID&1,gl_VertexID>>1)*4.-1.;gl_Position=vec4(q,1,1);P=J[0]*q.x+J[1]*q.y+J[2];N=vec3(0);C=vec4(0);return;}
|
|
6
|
-
P=p;N=n;C=c;gl_Position=m*vec4(p,1);}`,
|
|
7
|
-
out vec2 U;void main(){U=vec2(gl_VertexID&1,gl_VertexID>>1)*2.;gl_Position=vec4(U*2.-1.,0,1);}`,
|
|
6
|
+
P=p;N=n;C=c;gl_Position=m*vec4(p,1);}`,rc=`#version 300 es
|
|
7
|
+
out vec2 U;void main(){U=vec2(gl_VertexID&1,gl_VertexID>>1)*2.;gl_Position=vec4(U*2.-1.,0,1);}`,ic=`#version 300 es
|
|
8
8
|
precision highp float;uniform sampler2D S[4];uniform vec4 Y;uniform float L;in vec2 U;out vec4 o;
|
|
9
9
|
vec3 b(vec2 x){vec3 c=texture(S[0],x).rgb;return c*smoothstep(.9,2.,max(c.r,max(c.g,c.b)));}
|
|
10
10
|
#define T(k)texture(S[0],U+Y.xy*(k)).rgb
|
|
@@ -20,12 +20,12 @@ float a=atan(q.y,q.x)*24.,h=fract(sin(floor(a)*12.9898)*43758.5453);
|
|
|
20
20
|
c+=L*step(.85-.5*L,h)*sin(fract(a)*3.1416)*smoothstep(.2,.6,length(q))*fract(length(q)*3.-Y.w*.002+h*9.)*.22;
|
|
21
21
|
c*=1.-(.7+.3*L)*dot(q,q);
|
|
22
22
|
c=pow(c*vec3(.97,1.,1.03),vec3(.92))+(fract(sin(dot(gl_FragCoord.xy+Y.w,vec2(12.9898,78.233)))*43758.5453)-.5)*.03;}
|
|
23
|
-
o=vec4(c,1);}`,
|
|
23
|
+
o=vec4(c,1);}`,ac=[[.04,8],[.25,30],[0,1],[.08,10],[.8,48],[.06,12],[.3,20],[.7,40],[.06,14],[1.5,110],[.9,60],[.25,30],[.1,24]],oc=`#version 300 es
|
|
24
24
|
precision highp float;precision highp sampler2DArray;precision highp sampler2DArrayShadow;
|
|
25
25
|
in vec3 P,N;in vec4 C;uniform vec3 E;uniform float T,Z,Y;uniform int Q;
|
|
26
|
-
uniform vec4 A[16],B[16],K[16],F;uniform vec3 G[16],H[5],O,X;uniform mat4 M[4],W;
|
|
26
|
+
uniform vec4 A[16],B[16],K[16],F;uniform float U;uniform vec3 G[16],H[5],O,X;uniform mat4 M[4],W;
|
|
27
27
|
uniform sampler2DArray S;uniform sampler2DArrayShadow D;out vec4 o;
|
|
28
|
-
const vec2 SP[${
|
|
28
|
+
const vec2 SP[${ac.length}]=vec2[](${ac.map(([e,t])=>`vec2(${e},${t})`)});
|
|
29
29
|
vec3 e(vec3 x){return 2.*(1.-exp(-.5*x));}
|
|
30
30
|
vec3 K0(vec3 d){
|
|
31
31
|
float h=d.y,k=max(dot(d,O),0.);
|
|
@@ -36,19 +36,19 @@ void main(){
|
|
|
36
36
|
if(Z<0.)return;
|
|
37
37
|
if(Y>.5){o=vec4(K0(normalize(P)),1);return;}
|
|
38
38
|
float L=C.z,s=step(0.,L),I=floor(C.w*.5),g=step(abs(L-${y.LAVA}.),.5)+step(L,-1.5);
|
|
39
|
-
vec4 t=texture(S,vec3(C.xy/${
|
|
39
|
+
vec4 t=texture(S,vec3(C.xy/${Js}.+vec2(g*T*.01,0),max(L,0.)));
|
|
40
40
|
vec3 c=mix(vec3(C.xy,C.w),t.rgb,s);
|
|
41
41
|
vec3 n=normalize(N),dx=dFdx(P),dy=dFdy(P),a=cross(dy,n),b=cross(n,dx);
|
|
42
42
|
float h=t.a*s*0.06,det=dot(dx,a);
|
|
43
|
-
float f=1.-smoothstep(.6,2.5,${128/
|
|
43
|
+
float f=1.-smoothstep(.6,2.5,${128/Js}.*max(length(dFdx(C.xy)),length(dFdy(C.xy))));
|
|
44
44
|
vec3 m=normalize(abs(det)*n-sign(det)*f*(dFdx(h)*a+dFdy(h)*b)+n*1e-9);
|
|
45
|
-
vec2 R=SP[int(s>0.?L+.5:${
|
|
45
|
+
vec2 R=SP[int(s>0.?L+.5:${fs}.)];
|
|
46
46
|
vec3 y=mix(vec3(1),G[int(min(I,15.))]*(C.w-2.*I),s),V=normalize(E-P),w=normalize(n+m);
|
|
47
47
|
float sd=max(dot(m,O),0.)*smoothstep(0.,.1,dot(n,O)),sv=1.;
|
|
48
48
|
if(sd>0.&&g<1.){
|
|
49
49
|
vec4 q=W*vec4(P+n*.08,1);q.xyz=q.xyz*.5+.5;
|
|
50
50
|
float v=0.;
|
|
51
|
-
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/
|
|
51
|
+
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/Ys},0,q.z-.0004));
|
|
52
52
|
sv=mix(v/4.,1.,smoothstep(.8,1.,max(abs(q.x-.5),abs(q.y-.5))*2.));}
|
|
53
53
|
vec3 l=y*(mix(mix(H[1],H[0],max(w.y,0.)),H[2],max(-w.y,0.))+X*sd*sv),sp=X*sv*sd*pow(max(dot(m,normalize(O+V)),0.),R.y);
|
|
54
54
|
for(int i=0;i<16;i++){
|
|
@@ -60,10 +60,11 @@ w*=w*smoothstep(u,u+(1.-u)*.4,-dot(d,B[i].xyz))*max(dot(m,d),0.);
|
|
|
60
60
|
if(w>0.&&k>=0.){
|
|
61
61
|
vec4 q=M[int(k)]*vec4(P+n*.03,1);q.xyz=q.xyz/q.w*.5+.5;
|
|
62
62
|
float v=0.;
|
|
63
|
-
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/
|
|
63
|
+
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/Ys},k+1.,q.z-.0005));
|
|
64
64
|
w*=v/4.;}
|
|
65
65
|
l+=K[i].rgb*w;
|
|
66
66
|
sp+=K[i].rgb*w*pow(max(dot(m,normalize(d+V)),0.),R.y);}
|
|
67
67
|
c=c*mix(e(l),vec3(1.4),g)+e(sp*R.x*(.4+.6*mix(1.,t.a,s)));
|
|
68
68
|
c+=step(abs(L-${y.GLASS}.),.5)*K0(reflect(-V,m))*(.1+.9*pow(1.-max(dot(m,V),0.),4.));
|
|
69
|
-
o=vec4(mix(c,F.rgb,1.-exp(-F.a*length(P-E))),1.);}`,ks=(e,t,n,r,i=0,a=xs,[o,s]=[.1,400])=>{let[c,l,u]=Mt(t,n,i),d=(s+o)/(s-o),f=[c.map(e=>e/(a*r)),l.map(e=>e/a),u.map(e=>e*d),u].map(t=>[...t,-t[0]*e[0]-t[1]*e[1]-t[2]*e[2]]);return f[2][3]-=2*s*o/(s-o),Float32Array.from({length:16},(e,t)=>f[t&3][t>>2])},As=(e,t,n,r)=>{let i=e[3]*t+e[7]*n+e[11]*r+e[15];if(i<=0)return;let a=e[0]*t+e[4]*n+e[8]*r+e[12],o=e[1]*t+e[5]*n+e[9]*r+e[13];return[.5+a/(2*i),.5-o/(2*i)]},js=({p:e,d:t,cone:n,range:r})=>ks(e,Math.atan2(-t[0],-t[2]),Math.atan2(t[1],Math.hypot(t[0],t[2])),1,0,Math.min(Math.tan(Math.acos(n)),5.7),[.3,r]),Ms=e=>{let[t,n,r]=[0,0,0].map(()=>/* @__PURE__ */ new Float32Array(64)),i=/* @__PURE__ */ new Float32Array(64),a=0,o=e.slice(0,16);return o.forEach((e,o)=>{let s=e.shadow&&e.kind==sn.SPOT&&a<4?a++:-1;t.set([...e.p,e.range],o*4),n.set([...e.d,e.kind==sn.POINT?-9:e.cone],o*4),r.set([...e.color,s],o*4),s>=0&&i.set(js(e),s*16)}),{n:o.length,maps:a,a:t,b:n,k:r,m:i}},Ns=(e,t,n=64,r=100)=>{let i=e.map(e=>-e),a=Math.hypot(i[0],i[2]),o=a>.001?[-i[2]/a,0,i[0]/a]:[1,0,0],s=[o[1]*i[2]-o[2]*i[1],o[2]*i[0]-o[0]*i[2],o[0]*i[1]-o[1]*i[0]],c=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],[l,u]=[n/2,n/ys],d=[o,s].map(e=>[...e.map(e=>e/l),-(Math.round(c(e,t)/u)*u)/l]);return d.push([...i.map(e=>e/r),-c(i,t)/r],[0,0,0,1]),Float32Array.from({length:16},(e,t)=>d[t&3][t>>2])},Ps=({def:e})=>[...new Map([[`1,1,1`,[1,1,1]],...e.brushes.flatMap(({tint:e})=>e?[[`${e}`,e]]:[])]).values()].slice(0,16),Fs=[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]],Is=e=>{let{brushes:t,floor:n}=e.def,r=[],i=Ps(e).map(String);return t.forEach((e,a)=>{let o=1+2*Math.max(0,i.indexOf(`${e.tint}`));for(let i=0;i<3;i++){let[s,c]=[(i+1)%3,(i+2)%3],[l,u]=i==0?[2,1]:i==1?[0,2]:[0,1];for(let d of[0,1]){let f=d?e.max[i]:e.min[i];if(t.some((t,n)=>n!=a&&(d?t.min[i]:t.max[i])==f&&t.min[s]<=e.min[s]&&t.max[s]>=e.max[s]&&t.min[c]<=e.min[c]&&t.max[c]>=e.max[c])||i==1&&!d&&e.min[1]<=n)continue;let p=[0,0,0];p[i]=d?1:-1;for(let[t,n]of Fs){let a=[0,0,0];[a[i],a[s],a[c]]=[f,(t?e.max:e.min)[s],(n?e.max:e.min)[c]],r.push(...a,...p,a[l],a[u],i==1&&d?e.top:e.side,o)}}}}),r},Ls=({sky:[e,t]})=>[e.map(e=>(e*.45+.55)*.74),t.map(e=>(e*.7+.3)*.58),t.map((e,t)=>e*[1,.92,.8][t]*.34),e,t],Rs=e=>({...e,def:{...e.def,brushes:[...e.def.brushes,...Xo(e.def)]}}),zs=({fog:e,sky:t})=>e?[...[0,1,2].map(n=>e[n]+(t[1][n]-e[n])*bs),e[3]]:[...t[1],0],Bs=2073600,Vs=(e,t,n)=>{let r=Math.min(n,2,Math.sqrt(Bs/(e*t||1)));return[Math.round(e*r),Math.round(t*r)]},Hs=(e,t)=>{let n=/* @__PURE__ */ new Map,r=performance.now()/1e3,i=e.getContext(`webgl2`,{antialias:!1,depth:!1});if(!i)throw Error(`WebGL2 is not available`);let a=document.createElement(`canvas`).getContext(`2d`),o=/* @__PURE__ */ new Map,s=e=>{let t=o.get(e);if(!t){a.fillStyle=`#888`,a.fillStyle=e;let n=parseInt(a.fillStyle.slice(1),16),r=n>=0?n:8947848;o.set(e,t=[r>>16,r>>8&255,r&255].map(e=>e/255))}return t},c=()=>Vs(e.clientWidth,e.clientHeight,devicePixelRatio),l=[...Is({...t,def:{...t.def,brushes:[...t.def.brushes,...Xo(t.def)]}}),...ms(t.def),...gs(t.def)],{sun:u,sky:d}=t.def,f=u.dir.map(e=>e/Math.hypot(...u.dir)),p=Uo(),m=l.length*4,h=m+_s,g={},_,v,y,b,x={},S,C,w,T,E=[0,0],D=[],O=!1,k=/* @__PURE__ */ new Float32Array(16),A=()=>{i.bufferData(i.ARRAY_BUFFER,h,i.DYNAMIC_DRAW),i.bufferSubData(i.ARRAY_BUFFER,0,new Float32Array(l))},j=(e,t,n)=>{let r=i.createProgram();for(let[n,a]of[[i.VERTEX_SHADER,e],[i.FRAGMENT_SHADER,t]]){let e=i.createShader(n);i.shaderSource(e,a),i.compileShader(e),i.attachShader(r,e)}return i.linkProgram(r),i.useProgram(r),[r,Object.fromEntries(n.map(e=>[e,i.getUniformLocation(r,e)]))]},M=(e,t)=>{let n=i.createTexture();i.bindTexture(i.TEXTURE_2D,n),i.texStorage2D(i.TEXTURE_2D,1,S,e,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);let r=i.createFramebuffer();return i.bindFramebuffer(i.FRAMEBUFFER,r),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,n,0),D.push(()=>i.deleteTexture(n),()=>i.deleteFramebuffer(r)),{t:n,f:r,w:e,h:t}},ee=(e,t)=>{D.splice(0).forEach(e=>e()),E=[e,t],w=M(e,t),T=[1,2,3].map(n=>[0,1].map(()=>M(e>>n||1,t>>n||1)));let n=n=>{let r=i.createRenderbuffer();return i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,Cs,n,e,t),D.push(()=>i.deleteRenderbuffer(r)),r};i.bindFramebuffer(i.FRAMEBUFFER,C=i.createFramebuffer()),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n(S)),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,n(i.DEPTH_COMPONENT24)),D.push(()=>i.deleteFramebuffer(C))},N=(e,t,n,r,...a)=>{i.bindFramebuffer(i.FRAMEBUFFER,e?.f??null),i.viewport(0,0,e?.w??E[0],e?.h??E[1]),a.forEach((e,t)=>{i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,e.t)}),i.uniform4f(x.Y,n,r,t,performance.now()%1e4),i.drawArrays(i.TRIANGLES,0,3)},P=()=>{S=i.getExtension(`EXT_color_buffer_float`)?i.RGBA16F:i.RGBA8,D.length=0,E=[0,0],[b,x]=j(Ts,Es,[`S`,`Y`,`L`]),i.uniform1iv(x.S,[0,1,2,3]),[y,g]=j(ws,Os,[`m`,`E`,`T`,`Z`,`Q`,`A`,`B`,`K`,`M`,`D`,`F`,`G`,`W`,`H`,`O`,`X`,`Y`,`J`]),i.uniform1i(g.D,1),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),A(),[3,3,4].reduce((e,t,n)=>(i.enableVertexAttribArray(n),i.vertexAttribPointer(n,t,i.FLOAT,!1,40,e*4),e+t),0),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,_=i.createTexture()),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH_COMPONENT24,ys,ys,5);for(let[e,t]of[[i.TEXTURE_MIN_FILTER,i.LINEAR],[i.TEXTURE_MAG_FILTER,i.LINEAR],[i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE],[i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE],[i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE]])i.texParameteri(i.TEXTURE_2D_ARRAY,e,t);i.bindFramebuffer(i.FRAMEBUFFER,v=i.createFramebuffer()),i.drawBuffers([i.NONE]),i.bindFramebuffer(i.FRAMEBUFFER,null),i.polygonOffset(2,4),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D_ARRAY,i.createTexture()),i.texImage3D(i.TEXTURE_2D_ARRAY,0,i.RGBA8,128,128,Po,0,i.RGBA,i.UNSIGNED_BYTE,p),i.generateMipmap(i.TEXTURE_2D_ARRAY),i.texParameteri(i.TEXTURE_2D_ARRAY,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR);let e=i.getExtension(`EXT_texture_filter_anisotropic`);e&&i.texParameterf(i.TEXTURE_2D_ARRAY,e.TEXTURE_MAX_ANISOTROPY_EXT,8),i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL),F();let[t,n]=c();t&&n&&ee(t,n)},F=()=>{let e=Ps(Rs(t));i.uniform4fv(g.F,zs(t.def)),i.uniform3fv(g.H,Ls(t.def).flat()),i.uniform3fv(g.O,f),i.uniform3fv(g.X,u.color),i.uniform3fv(g.G,Float32Array.from({length:48},(t,n)=>e[n/3|0]?.[n%3]??1)),i.clearColor(...d[1],1)};P();let I=e=>{e.preventDefault(),O=!0},L=()=>{P(),O=!1};return e.addEventListener(`webglcontextlost`,I),e.addEventListener(`webglcontextrestored`,L),{frame(a,o,u,d,p,S,D,j,M,P){let[F,I]=c();if(O||!F||!I)return;(e.width!=F||e.height!=I)&&(e.width=F,e.height=I),(E[0]!=F||E[1]!=I)&&ee(F,I);let L=Math.tan((70+S.fov)*Math.PI/360);k=ks(a,o,u,F/I,S.roll,L);let R=[],z=performance.now()/1e3,B=Math.min(.1,z-r);r=z,Ao(n,d,B,t),M?.bases.forEach((e,t)=>nn(R,e,Yt(t),z)),M?.flags.forEach(e=>on(R,e,Yt(e.team),z)),M?.racks?.forEach((e,t)=>e&&go(R,e,Yt(t),z)),M?.packs?.forEach(e=>So(R,e,z)),M?.ammo?.forEach(e=>Co(R,e,z));for(let e of d)No(R,n.get(e.id),s(p.get(e.id)??`#888`),+(Math.hypot(e.x-a[0],e.z-a[2])<Ss));let te=R.length;P?.draw(R,a);let ne=R.length;j?.draw(R,a,o,u,S.roll,s(p.get(j.id)??`#888`)),m+R.length*4>h&&(h=m+R.length*8,A()),i.bufferSubData(i.ARRAY_BUFFER,m,new Float32Array(R));let V=Ms(D),re=l.length/10,H=Ns(f,a);i.uniform1f(g.Z,-1),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,null),i.bindFramebuffer(i.FRAMEBUFFER,v),i.viewport(0,0,ys,ys),i.enable(i.POLYGON_OFFSET_FILL);for(let e=0;e<=V.maps;e++)i.framebufferTextureLayer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,_,0,e),i.uniformMatrix4fv(g.m,!1,e?V.m.subarray(e*16-16,e*16):H),i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,re+te/10);i.disable(i.POLYGON_OFFSET_FILL),i.bindTexture(i.TEXTURE_2D_ARRAY,_),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,C),i.viewport(0,0,F,I),i.uniformMatrix4fv(g.m,!1,k),i.uniformMatrix4fv(g.W,!1,H),i.uniform3fv(g.E,a),i.uniform1f(g.T,performance.now()/1e3),i.uniform1f(g.Z,1),i.uniform1i(g.Q,V.n),i.uniform4fv(g.A,V.a),i.uniform4fv(g.B,V.b),i.uniform4fv(g.K,V.k),i.uniformMatrix4fv(g.M,!1,V.m),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT);let[U,ie,ae]=Mt(o,u,S.roll);i.uniform3fv(g.J,[U.map(e=>e*L*(F/I)),ie.map(e=>e*L),ae].flat()),i.uniform1f(g.Y,1),i.drawArrays(i.TRIANGLES,0,3),i.uniform1f(g.Y,0),i.drawArrays(i.TRIANGLES,0,re+ne/10),R.length>ne&&(i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,re+ne/10,(R.length-ne)/10)),i.bindFramebuffer(i.READ_FRAMEBUFFER,C),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,w.f),i.blitFramebuffer(0,0,F,I,0,0,F,I,i.COLOR_BUFFER_BIT,i.NEAREST),i.useProgram(b),N(T[0][0],0,1/F,1/I,w),T.forEach(([e,t],n)=>{N(t,1,1/t.w,0,T[n&&n-1][0]),N(e,1,0,1/e.h,t)}),i.uniform1f(x.L,S.lines),N(void 0,2,0,0,w,...T.map(e=>e[0]));for(let e=3;e>0;e--)i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,null);i.activeTexture(i.TEXTURE0),i.useProgram(y)},project:(e,t,n)=>As(k,e,t,n),destroy(){e.removeEventListener(`webglcontextlost`,I),e.removeEventListener(`webglcontextrestored`,L),i.getExtension(`WEBGL_lose_context`)?.loseContext()}}},Us=1/60,Ws=5,Gs=(e,n)=>{let r=document.createElement(`div`),i=r.attachShadow({mode:`open`});i.innerHTML=`<style>:host{display:block;width:100%;height:100%}div{position:relative;width:100%;height:100%;overflow:hidden;background:#000;font:600 14px system-ui,sans-serif;color:#fff;text-shadow:0 1px 2px #000}canvas{display:block;width:100%;height:100%;cursor:pointer}i,p,b{position:absolute;pointer-events:none;user-select:none;margin:0}`+Ha+`i{left:50%;top:50%;width:6px;height:6px;margin:-3px;border-radius:50%;background:#fff;box-shadow:0 0 0 1px #0008}p{bottom:8px;left:12px}b{transform:translate(-50%,-100%);font-size:12px;white-space:nowrap}[hidden]{display:none}</style><div><canvas></canvas><i></i><p></p></div>`,e.append(r);let a=i.querySelector(`canvas`),o=i.querySelector(`p`),s=i.querySelector(`div`),c=Ga(s),l={roster:[],open:[],close:[]},u=e=>l[e].forEach(e=>e()),d=te(I),f=co(d),p=Tt();p.mute(Et()),c.mute(p.muted);let m=Qa(a,()=>c.mute(Dt(p)));a.addEventListener(`click`,()=>p.unlock());let h=za(),g=Va(p),_=ra(d),v=xn(),y=sa(d,p,c,h,v,m),b;try{b=Hs(a,d)}catch{}let x=d.def.teams.map(e=>e.base),S=d.def.teams.map(e=>e.rack),C=[],w={id:-1,team:0},T,E,D=/* @__PURE__ */ new Map,O=/* @__PURE__ */ new Map,k=/* @__PURE__ */ new Map,A=!1,j=b?``:`WebGL2 is not available`,M=!1,ee=performance.now(),N=0,P=0,F=!1,L=n.socket??new WebSocket(n.url);L.binaryType=`arraybuffer`,L.onopen=()=>{A=!0,L.send(JSON.stringify({t:`join`,name:n.name})),u(`open`)},L.onclose=()=>{A=!1,j||=`Connection closed`,u(`close`)},L.onmessage=({data:e})=>{if(typeof e!=`string`){let t=at(e);if(t){f.snapshot(t,performance.now());for(let e of Sn(T,t)){let t=Cn(e,w,e=>O.get(e)??`Someone`);t&&c.banner(t.text,t.team),e.kind==`start`&&([m.yaw,m.pitch]=[d.def.teams[w.team].spawns[0][3],0]);for(let t of wn(e,w))p.play(t.id,t.at,t.gain,t.rate);e.kind==`tackle`&&(e.who==w.id?h.jolt():e.by==w.id&&h.punch())}T=t}return}let t=ot(e);t?.t==`roster`?(C=t.players,D=new Map(C.map(e=>[e.id,e.color])),O=new Map(C.map(e=>[e.id,e.name])),w={id:t.you,team:C.find(e=>e.id==t.you)?.team??0},f.you(w.id,w.team),o.textContent=`Players: ${C.length}`,u(`roster`)):t?.t==`end`?E={score:t.score,players:t.players}:t?.t==`full`&&(j=`Room is full`)};let R=e=>{let t=k.get(e);return t||(k.set(e,t=document.createElement(`b`)),s.append(t)),t},z=()=>{P=requestAnimationFrame(z);let e=performance.now(),n=ee;if(N=Math.min(N+(e-ee)/1e3,Ws*Us),ee=e,!M){let e=f.me(0);e&&([m.yaw,m.pitch,M]=[e.yaw,e.pitch,!0]),N=0}for(;M&&N>=Us;N-=Us){let t=f.me(1),n=f.step({keys:m.take(),yaw:m.yaw,pitch:m.pitch},e);y.step(t,f.me(1)),A&&L.send(rt(n))}let r=f.me(N/Us),i=f.others(e),o=r?[r.x,r.y+ve(r),r.z]:[0,0,0];p.listen(o,m.yaw);let s=Math.min((e-n)/1e3,.1),l=e=>e==w.id?r:i.find(t=>t.id==e),u=T&&{bases:x,flags:Xt(T.flags,x,l),racks:S,packs:ho(d.def.packs,T.packs),ammo:ho(d.def.ammo,T.packs,d.def.packs?.length)},C=f.events();h.update(r,m.keys,s,C),c.hurt(h.hurt),g.me(r,C,h.stride),g.others(i),_.update(r,s,h.kick,a.clientWidth/(a.clientHeight||1));let F=[o[0],o[1]+h.dy,o[2]],I=m.pitch+h.pitch,B=r&&ia(d,o,F,m.yaw,m.pitch,I);B&&_.aim(B.local),y.frame(r&&B&&{eye:o,cam:F,yaw:m.yaw,pitch:m.pitch,drawn:I,muzzle:_.muzzle(),...B},r,i,m.keys,s),r&&b&&b.frame(F,m.yaw,I,i,D,h,[...un({eye:F,yaw:m.yaw,pitch:I,others:i,t:e/1e3,ctf:u}),...v.lights()],_,u,v),T&&(c.match(T,e=>O.get(e)??`?`),c.marks(r&&b?mo({eye:o,id:w.id,team:w.team,yaw:m.yaw,flags:T.flags,bases:x,where:e=>{let t=l(e);return t&&[t.x,t.y,t.z]},project:b.project}):[]),c.end(T.over?E:void 0,T.clock));let te=/* @__PURE__ */ new Set;for(let e of i){let n=[e.x,e.y+t+.3,e.z],i=r&&!re(d,o,n)?b?.project(...n):void 0,a=R(e.id);te.add(e.id),a.hidden=!i,i&&(a.style.left=i[0]*100+`%`,a.style.top=i[1]*100+`%`);let s=O.get(e.id)??``;a.textContent!=s&&(a.textContent=s),a.style.color=D.get(e.id)??``}for(let[e,t]of k)te.has(e)||(t.remove(),k.delete(e));c.title(j||(A?M?m.locked()?``:`Click to play`:`Joining…`:`Connecting…`),d.def.name??``)};return P=requestAnimationFrame(z),{on:(e,t)=>void l[e].push(t),players:()=>C,destroy(){F||(F=!0,cancelAnimationFrame(P),m.destroy(),p.destroy(),b?.destroy(),L.onopen=L.onclose=L.onmessage=null,L.close(),document.exitPointerLock(),r.remove())}}};export{Gs as tinyFps};
|
|
69
|
+
float D=length(P-E),x=${Qs}*(P.y-E.y);
|
|
70
|
+
o=vec4(mix(c,F.rgb,1.-exp(-F.a*D*(1.+${Zs}*exp(${Qs}*(U-E.y))*(abs(x)<1e-3?1.-x*.5:(1.-exp(-x))/x)))),1.);}`,sc=(e,t,n,r,i=0,a=$s,[o,s]=[.1,900])=>{let[c,l,u]=Mt(t,n,i),d=(s+o)/(s-o),f=[c.map(e=>e/(a*r)),l.map(e=>e/a),u.map(e=>e*d),u].map(t=>[...t,-t[0]*e[0]-t[1]*e[1]-t[2]*e[2]]);return f[2][3]-=2*s*o/(s-o),Float32Array.from({length:16},(e,t)=>f[t&3][t>>2])},cc=(e,t,n,r)=>{let i=e[3]*t+e[7]*n+e[11]*r+e[15];if(i<=0)return;let a=e[0]*t+e[4]*n+e[8]*r+e[12],o=e[1]*t+e[5]*n+e[9]*r+e[13];return[.5+a/(2*i),.5-o/(2*i)]},lc=({p:e,d:t,cone:n,range:r})=>sc(e,Math.atan2(-t[0],-t[2]),Math.atan2(t[1],Math.hypot(t[0],t[2])),1,0,Math.min(Math.tan(Math.acos(n)),5.7),[.3,r]),uc=e=>{let[t,n,r]=[0,0,0].map(()=>/* @__PURE__ */ new Float32Array(64)),i=/* @__PURE__ */ new Float32Array(64),a=0,o=e.slice(0,16);return o.forEach((e,o)=>{let s=e.shadow&&e.kind==sn.SPOT&&a<4?a++:-1;t.set([...e.p,e.range],o*4),n.set([...e.d,e.kind==sn.POINT?-9:e.cone],o*4),r.set([...e.color,s],o*4),s>=0&&i.set(lc(e),s*16)}),{n:o.length,maps:a,a:t,b:n,k:r,m:i}},dc=(e,t,n=64,r=100)=>{let i=e.map(e=>-e),a=Math.hypot(i[0],i[2]),o=a>.001?[-i[2]/a,0,i[0]/a]:[1,0,0],s=[o[1]*i[2]-o[2]*i[1],o[2]*i[0]-o[0]*i[2],o[0]*i[1]-o[1]*i[0]],c=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],[l,u]=[n/2,n/Ys],d=[o,s].map(e=>[...e.map(e=>e/l),-(Math.round(c(e,t)/u)*u)/l]);return d.push([...i.map(e=>e/r),-c(i,t)/r],[0,0,0,1]),Float32Array.from({length:16},(e,t)=>d[t&3][t>>2])},fc=({def:e})=>[...new Map([[`1,1,1`,[1,1,1]],...e.brushes.flatMap(({tint:e})=>e?[[`${e}`,e]]:[])]).values()].slice(0,16),pc=[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]],mc=e=>{let{brushes:t,floor:n}=e.def,r=[],i=fc(e).map(String);return t.forEach((e,a)=>{let o=1+2*Math.max(0,i.indexOf(`${e.tint}`));for(let i=0;i<3;i++){let[s,c]=[(i+1)%3,(i+2)%3],[l,u]=i==0?[2,1]:i==1?[0,2]:[0,1];for(let d of[0,1]){let f=d?e.max[i]:e.min[i];if(t.some((t,n)=>n!=a&&(d?t.min[i]:t.max[i])==f&&t.min[s]<=e.min[s]&&t.max[s]>=e.max[s]&&t.min[c]<=e.min[c]&&t.max[c]>=e.max[c])||i==1&&!d&&e.min[1]<=n)continue;let p=[0,0,0];p[i]=d?1:-1;for(let[t,n]of pc){let a=[0,0,0];[a[i],a[s],a[c]]=[f,(t?e.max:e.min)[s],(n?e.max:e.min)[c]],r.push(...a,...p,a[l],a[u],i==1&&d?e.top:e.side,o)}}}}),r},hc=({sky:[e,t]})=>[e.map(e=>(e*.45+.55)*.74),t.map(e=>(e*.7+.3)*.58),t.map((e,t)=>e*[1,.92,.8][t]*.34),e,t],gc=e=>({...e,def:{...e.def,brushes:[...us(e.def),...Ds(e.def)]}}),_c=e=>[...mc(gc(e)),...ds(e.def),...Zo(e.def),...$o(e.def)],vc=({brushes:e})=>Math.min(...e.map(e=>e.max[1])),yc=({fog:e,sky:t})=>e?[...[0,1,2].map(n=>e[n]+(t[1][n]-e[n])*Xs),e[3]]:[...t[1],0],bc=2073600,xc=(e,t,n)=>{let r=Math.min(n,2,Math.sqrt(bc/(e*t||1)));return[Math.round(e*r),Math.round(t*r)]},Sc=(e,t)=>{let n=/* @__PURE__ */ new Map,r=performance.now()/1e3,i=e.getContext(`webgl2`,{antialias:!1,depth:!1});if(!i)throw Error(`WebGL2 is not available`);let a=document.createElement(`canvas`).getContext(`2d`),o=/* @__PURE__ */ new Map,s=e=>{let t=o.get(e);if(!t){a.fillStyle=`#888`,a.fillStyle=e;let n=parseInt(a.fillStyle.slice(1),16),r=n>=0?n:8947848;o.set(e,t=[r>>16,r>>8&255,r&255].map(e=>e/255))}return t},c=()=>xc(e.clientWidth,e.clientHeight,devicePixelRatio),l=_c(t),u=Ks(t.def),{sun:d,sky:f}=t.def,p=d.dir.map(e=>e/Math.hypot(...d.dir)),m=xs(),h=l.length*4,g=h+qs,_={},v,y,b,x,S={},C,w,T,E,D=[0,0],O=[],k=!1,A=/* @__PURE__ */ new Float32Array(16),j=()=>{i.bufferData(i.ARRAY_BUFFER,g,i.DYNAMIC_DRAW),i.bufferSubData(i.ARRAY_BUFFER,0,new Float32Array(l))},ee=(e,t,n)=>{let r=i.createProgram();for(let[n,a]of[[i.VERTEX_SHADER,e],[i.FRAGMENT_SHADER,t]]){let e=i.createShader(n);i.shaderSource(e,a),i.compileShader(e),i.attachShader(r,e)}return i.linkProgram(r),i.useProgram(r),[r,Object.fromEntries(n.map(e=>[e,i.getUniformLocation(r,e)]))]},M=(e,t)=>{let n=i.createTexture();i.bindTexture(i.TEXTURE_2D,n),i.texStorage2D(i.TEXTURE_2D,1,C,e,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);let r=i.createFramebuffer();return i.bindFramebuffer(i.FRAMEBUFFER,r),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,n,0),O.push(()=>i.deleteTexture(n),()=>i.deleteFramebuffer(r)),{t:n,f:r,w:e,h:t}},N=(e,t)=>{O.splice(0).forEach(e=>e()),D=[e,t],T=M(e,t),E=[1,2,3].map(n=>[0,1].map(()=>M(e>>n||1,t>>n||1)));let n=n=>{let r=i.createRenderbuffer();return i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,tc,n,e,t),O.push(()=>i.deleteRenderbuffer(r)),r};i.bindFramebuffer(i.FRAMEBUFFER,w=i.createFramebuffer()),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n(C)),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,n(i.DEPTH_COMPONENT24)),O.push(()=>i.deleteFramebuffer(w))},P=(e,t,n,r,...a)=>{i.bindFramebuffer(i.FRAMEBUFFER,e?.f??null),i.viewport(0,0,e?.w??D[0],e?.h??D[1]),a.forEach((e,t)=>{i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,e.t)}),i.uniform4f(S.Y,n,r,t,performance.now()%1e4),i.drawArrays(i.TRIANGLES,0,3)},F=()=>{C=i.getExtension(`EXT_color_buffer_float`)?i.RGBA16F:i.RGBA8,O.length=0,D=[0,0],[x,S]=ee(rc,ic,[`S`,`Y`,`L`]),i.uniform1iv(S.S,[0,1,2,3]),[b,_]=ee(nc,oc,[`m`,`E`,`T`,`Z`,`Q`,`A`,`B`,`K`,`M`,`D`,`F`,`U`,`G`,`W`,`H`,`O`,`X`,`Y`,`J`]),i.uniform1i(_.D,1),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),j(),[3,3,4].reduce((e,t,n)=>(i.enableVertexAttribArray(n),i.vertexAttribPointer(n,t,i.FLOAT,!1,40,e*4),e+t),0),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,v=i.createTexture()),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH_COMPONENT24,Ys,Ys,5);for(let[e,t]of[[i.TEXTURE_MIN_FILTER,i.LINEAR],[i.TEXTURE_MAG_FILTER,i.LINEAR],[i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE],[i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE],[i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE]])i.texParameteri(i.TEXTURE_2D_ARRAY,e,t);i.bindFramebuffer(i.FRAMEBUFFER,y=i.createFramebuffer()),i.drawBuffers([i.NONE]),i.bindFramebuffer(i.FRAMEBUFFER,null),i.polygonOffset(2,4),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D_ARRAY,i.createTexture()),i.texImage3D(i.TEXTURE_2D_ARRAY,0,i.RGBA8,128,128,fs,0,i.RGBA,i.UNSIGNED_BYTE,m),i.generateMipmap(i.TEXTURE_2D_ARRAY),i.texParameteri(i.TEXTURE_2D_ARRAY,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR);let e=i.getExtension(`EXT_texture_filter_anisotropic`);e&&i.texParameterf(i.TEXTURE_2D_ARRAY,e.TEXTURE_MAX_ANISOTROPY_EXT,8),i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL),I();let[t,n]=c();t&&n&&N(t,n)},I=()=>{let e=fc(gc(t));i.uniform4fv(_.F,yc(t.def)),i.uniform1f(_.U,vc(t.def)),i.uniform3fv(_.H,hc(t.def).flat()),i.uniform3fv(_.O,p),i.uniform3fv(_.X,d.color),i.uniform3fv(_.G,Float32Array.from({length:48},(t,n)=>e[n/3|0]?.[n%3]??1)),i.clearColor(...f[1],1)};F();let L=e=>{e.preventDefault(),k=!0},R=()=>{F(),k=!1};return e.addEventListener(`webglcontextlost`,L),e.addEventListener(`webglcontextrestored`,R),{frame(a,o,d,f,m,C,O,ee,M,F){let[I,L]=c();if(k||!I||!L)return;(e.width!=I||e.height!=L)&&(e.width=I,e.height=L),(D[0]!=I||D[1]!=L)&&N(I,L);let R=Math.tan((70+C.fov)*Math.PI/360);A=sc(a,o,d,I/L,C.roll,R);let z=[],B=performance.now()/1e3,te=Math.min(.1,B-r);r=B,Ao(n,f,te,t);let[ne,re,ie]=Mt(o,d,C.roll);u(z,a,ie,Date.now()/1e3),M?.bases.forEach((e,t)=>nn(z,e,Yt(t),B)),M?.flags.forEach(e=>on(z,e,Yt(e.team),B)),M?.racks?.forEach((e,t)=>e&&go(z,e,Yt(t),B)),M?.packs?.forEach(e=>So(z,e,B)),M?.ammo?.forEach(e=>Co(z,e,B));for(let e of f)No(z,n.get(e.id),s(m.get(e.id)??`#888`),+(Math.hypot(e.x-a[0],e.z-a[2])<ec));let V=z.length;F?.draw(z,a);let H=z.length;ee?.draw(z,a,o,d,C.roll,s(m.get(ee.id)??`#888`)),h+z.length*4>g&&(g=h+z.length*8,j()),i.bufferSubData(i.ARRAY_BUFFER,h,new Float32Array(z));let U=uc(O),W=l.length/10,ae=dc(p,a);i.uniform1f(_.Z,-1),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,null),i.bindFramebuffer(i.FRAMEBUFFER,y),i.viewport(0,0,Ys,Ys),i.enable(i.POLYGON_OFFSET_FILL);for(let e=0;e<=U.maps;e++)i.framebufferTextureLayer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,v,0,e),i.uniformMatrix4fv(_.m,!1,e?U.m.subarray(e*16-16,e*16):ae),i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,W+V/10);i.disable(i.POLYGON_OFFSET_FILL),i.bindTexture(i.TEXTURE_2D_ARRAY,v),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,w),i.viewport(0,0,I,L),i.uniformMatrix4fv(_.m,!1,A),i.uniformMatrix4fv(_.W,!1,ae),i.uniform3fv(_.E,a),i.uniform1f(_.T,performance.now()/1e3),i.uniform1f(_.Z,1),i.uniform1i(_.Q,U.n),i.uniform4fv(_.A,U.a),i.uniform4fv(_.B,U.b),i.uniform4fv(_.K,U.k),i.uniformMatrix4fv(_.M,!1,U.m),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.uniform3fv(_.J,[ne.map(e=>e*R*(I/L)),re.map(e=>e*R),ie].flat()),i.uniform1f(_.Y,1),i.drawArrays(i.TRIANGLES,0,3),i.uniform1f(_.Y,0),i.drawArrays(i.TRIANGLES,0,W+H/10),z.length>H&&(i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,W+H/10,(z.length-H)/10)),i.bindFramebuffer(i.READ_FRAMEBUFFER,w),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,T.f),i.blitFramebuffer(0,0,I,L,0,0,I,L,i.COLOR_BUFFER_BIT,i.NEAREST),i.useProgram(x),P(E[0][0],0,1/I,1/L,T),E.forEach(([e,t],n)=>{P(t,1,1/t.w,0,E[n&&n-1][0]),P(e,1,0,1/e.h,t)}),i.uniform1f(S.L,C.lines),P(void 0,2,0,0,T,...E.map(e=>e[0]));for(let e=3;e>0;e--)i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,null);i.activeTexture(i.TEXTURE0),i.useProgram(b)},project:(e,t,n)=>cc(A,e,t,n),destroy(){e.removeEventListener(`webglcontextlost`,L),e.removeEventListener(`webglcontextrestored`,R),i.getExtension(`WEBGL_lose_context`)?.loseContext()}}},Cc=1/60,wc=5,Tc=(e,n)=>{let r=document.createElement(`div`),i=r.attachShadow({mode:`open`});i.innerHTML=`<style>:host{display:block;width:100%;height:100%}div{position:relative;width:100%;height:100%;overflow:hidden;background:#000;font:600 14px system-ui,sans-serif;color:#fff;text-shadow:0 1px 2px #000}canvas{display:block;width:100%;height:100%;cursor:pointer}i,p,b{position:absolute;pointer-events:none;user-select:none;margin:0}`+Ha+`i{left:50%;top:50%;width:6px;height:6px;margin:-3px;border-radius:50%;background:#fff;box-shadow:0 0 0 1px #0008}p{bottom:8px;left:12px}b{transform:translate(-50%,-100%);font-size:12px;white-space:nowrap}[hidden]{display:none}</style><div><canvas></canvas><i></i><p></p></div>`,e.append(r);let a=i.querySelector(`canvas`),o=i.querySelector(`p`),s=i.querySelector(`div`),c=Ga(s),l={roster:[],open:[],close:[]},u=e=>l[e].forEach(e=>e()),d=te(I),f=co(d),p=Tt();p.mute(Et()),c.mute(p.muted);let m=Qa(a,()=>c.mute(Dt(p)));a.addEventListener(`click`,()=>p.unlock());let h=za(),g=Va(p),_=ra(d),v=xn(),y=sa(d,p,c,h,v,m),b;try{b=Sc(a,d)}catch{}let x=d.def.teams.map(e=>e.base),S=d.def.teams.map(e=>e.rack),C=[],w={id:-1,team:0},T,E,D=/* @__PURE__ */ new Map,O=/* @__PURE__ */ new Map,k=/* @__PURE__ */ new Map,A=!1,j=b?``:`WebGL2 is not available`,ee=!1,M=performance.now(),N=0,P=0,F=!1,L=n.socket??new WebSocket(n.url);L.binaryType=`arraybuffer`,L.onopen=()=>{A=!0,L.send(JSON.stringify({t:`join`,name:n.name})),u(`open`)},L.onclose=()=>{A=!1,j||=`Connection closed`,u(`close`)},L.onmessage=({data:e})=>{if(typeof e!=`string`){let t=at(e);if(t){f.snapshot(t,performance.now());for(let e of Sn(T,t)){let t=Cn(e,w,e=>O.get(e)??`Someone`);t&&c.banner(t.text,t.team),e.kind==`start`&&([m.yaw,m.pitch]=[d.def.teams[w.team].spawns[0][3],0]);for(let t of wn(e,w))p.play(t.id,t.at,t.gain,t.rate);e.kind==`tackle`&&(e.who==w.id?h.jolt():e.by==w.id&&h.punch())}T=t}return}let t=ot(e);t?.t==`roster`?(C=t.players,D=new Map(C.map(e=>[e.id,e.color])),O=new Map(C.map(e=>[e.id,e.name])),w={id:t.you,team:C.find(e=>e.id==t.you)?.team??0},f.you(w.id,w.team),o.textContent=`Players: ${C.length}`,u(`roster`)):t?.t==`end`?E={score:t.score,players:t.players}:t?.t==`full`&&(j=`Room is full`)};let R=e=>{let t=k.get(e);return t||(k.set(e,t=document.createElement(`b`)),s.append(t)),t},z=()=>{P=requestAnimationFrame(z);let e=performance.now(),n=M;if(N=Math.min(N+(e-M)/1e3,wc*Cc),M=e,!ee){let e=f.me(0);e&&([m.yaw,m.pitch,ee]=[e.yaw,e.pitch,!0]),N=0}for(;ee&&N>=Cc;N-=Cc){let t=f.me(1),n=f.step({keys:m.take(),yaw:m.yaw,pitch:m.pitch},e);y.step(t,f.me(1)),A&&L.send(rt(n))}let r=f.me(N/Cc),i=f.others(e),o=r?[r.x,r.y+_e(r),r.z]:[0,0,0];p.listen(o,m.yaw);let s=Math.min((e-n)/1e3,.1),l=e=>e==w.id?r:i.find(t=>t.id==e),u=T&&{bases:x,flags:Xt(T.flags,x,l),racks:S,packs:ho(d.def.packs,T.packs),ammo:ho(d.def.ammo,T.packs,d.def.packs?.length)},C=f.events();h.update(r,m.keys,s,C),c.hurt(h.hurt),g.me(r,C,h.stride),g.others(i),_.update(r,s,h.kick,a.clientWidth/(a.clientHeight||1));let F=[o[0],o[1]+h.dy,o[2]],I=m.pitch+h.pitch,B=r&&ia(d,o,F,m.yaw,m.pitch,I);B&&_.aim(B.local),y.frame(r&&B&&{eye:o,cam:F,yaw:m.yaw,pitch:m.pitch,drawn:I,muzzle:_.muzzle(),...B},r,i,m.keys,s),r&&b&&b.frame(F,m.yaw,I,i,D,h,[...un({eye:F,yaw:m.yaw,pitch:I,others:i,t:e/1e3,ctf:u}),...v.lights()],_,u,v),T&&(c.match(T,e=>O.get(e)??`?`),c.marks(r&&b?mo({eye:o,id:w.id,team:w.team,yaw:m.yaw,flags:T.flags,bases:x,where:e=>{let t=l(e);return t&&[t.x,t.y,t.z]},project:b.project}):[]),c.end(T.over?E:void 0,T.clock));let te=/* @__PURE__ */ new Set;for(let e of i){let n=[e.x,e.y+t+.3,e.z],i=r&&!ie(d,o,n)?b?.project(...n):void 0,a=R(e.id);te.add(e.id),a.hidden=!i,i&&(a.style.left=i[0]*100+`%`,a.style.top=i[1]*100+`%`);let s=O.get(e.id)??``;a.textContent!=s&&(a.textContent=s),a.style.color=D.get(e.id)??``}for(let[e,t]of k)te.has(e)||(t.remove(),k.delete(e));c.title(j||(A?ee?m.locked()?``:`Click to play`:`Joining…`:`Connecting…`),d.def.name??``)};return P=requestAnimationFrame(z),{on:(e,t)=>void l[e].push(t),players:()=>C,destroy(){F||(F=!0,cancelAnimationFrame(P),m.destroy(),p.destroy(),b?.destroy(),L.onopen=L.onclose=L.onmessage=null,L.close(),document.exitPointerLock(),r.remove())}}};export{Tc as tinyFps};
|
|
@@ -3,7 +3,7 @@ import type { World } from '../shared/world';
|
|
|
3
3
|
import type { Vec3 } from './mesh';
|
|
4
4
|
import type { Quat } from './rig';
|
|
5
5
|
/**
|
|
6
|
-
* The back of the body and the muzzle,
|
|
6
|
+
* The back of the body and the muzzle, the tip of the nose, in model space (the tail and the front of
|
|
7
7
|
* the emitter): the line through them is the gun's long axis, the way it points and the way the
|
|
8
8
|
* beam leaves. The grip's tilt: its lower end goes back by TILT[0] for each TILT[1] down.
|
|
9
9
|
*/
|
|
@@ -12,9 +12,9 @@ export declare const MUZZLE: Vec3;
|
|
|
12
12
|
export declare const TILT: number[];
|
|
13
13
|
/**
|
|
14
14
|
* The gun at a level of detail (0 far, 1 near), built once, in the vertex format of mesh.ts, after
|
|
15
|
-
* the Halo plasma pistol: a smooth bulbous upper body
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* the Halo plasma pistol: a smooth bulbous upper body tapering to a glowing emitter on its nose, a
|
|
16
|
+
* chunky lower shell under the hand, a short thick grip between them, and cyan strips along the
|
|
17
|
+
* sides.
|
|
18
18
|
*/
|
|
19
19
|
export declare const gun: (lod: number) => number[];
|
|
20
20
|
/** The middle of the grip, for a wrist at `pos`: 8 cm along the fingers and 2 cm toward the palm. */
|
|
@@ -16,6 +16,13 @@ export declare const SUN_AREA = 64;
|
|
|
16
16
|
export declare const SUN_DEPTH = 100;
|
|
17
17
|
/** How far the fog colour is pulled toward the sky's horizon, 0 to 1: a fog unlike the horizon draws an edge against the sky. */
|
|
18
18
|
export declare const HAZE = 0.6;
|
|
19
|
+
/**
|
|
20
|
+
* The height fog: besides the haze at the density of the world's fog, a layer of FOG_LAYER times that
|
|
21
|
+
* density at the lowest roof, which grows by e every 1 / FOG_RISE metres down: 2 % more at the roofs,
|
|
22
|
+
* about three times the haze on the street 94 m under them.
|
|
23
|
+
*/
|
|
24
|
+
export declare const FOG_LAYER = 0.02;
|
|
25
|
+
export declare const FOG_RISE = 0.05;
|
|
19
26
|
/** The vertical field of view at rest, degrees, and the tangent of its half. */
|
|
20
27
|
export declare const FOV_DEG = 70;
|
|
21
28
|
export declare const FOV: number;
|
|
@@ -76,10 +83,17 @@ export declare const level: (world: World) => number[];
|
|
|
76
83
|
* blue-grey and not blue, and dimmer on the sides and below.
|
|
77
84
|
*/
|
|
78
85
|
export declare const daylight: ({ sky: [zenith, horizon] }: WorldDef) => Vec3[];
|
|
79
|
-
/** The world as it is drawn: its
|
|
86
|
+
/** The world as it is drawn: its buildings down to the street, and a city around them. The physics knows only `world`. */
|
|
80
87
|
export declare const city: (world: World) => World;
|
|
81
|
-
/** All the map's vertices, drawn once: the city, the brushes, the runner's red and the team zones. */
|
|
88
|
+
/** All the map's vertices, drawn once: the city, the brushes, the street under them, the runner's red and the team zones. */
|
|
82
89
|
export declare const scenery: (world: World) => number[];
|
|
90
|
+
/** The height the fog layer is anchored at: the lowest top of the world, so that at a roof the layer is a few percent of the haze at most. */
|
|
91
|
+
export declare const fogRef: ({ brushes }: WorldDef) => number;
|
|
92
|
+
/**
|
|
93
|
+
* The fog's optical depth from `eye` to `p`, what the shader integrates: the haze plus the layer,
|
|
94
|
+
* for a world whose fog density is `density` and whose layer sits at `ref`.
|
|
95
|
+
*/
|
|
96
|
+
export declare const fogDepth: (density: number, ref: number, eye: Vec3, p: Vec3) => number;
|
|
83
97
|
/** The shader's fog uniform: the world's fog colour pulled toward its horizon by HAZE, and its density; none when the world has no fog. */
|
|
84
98
|
export declare const fogOf: ({ fog, sky }: WorldDef) => [number, number, number, number];
|
|
85
99
|
export interface Renderer {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Brush, WorldDef } from '../shared/world';
|
|
2
|
-
/** The towers of a world's skyline,
|
|
3
|
-
export declare const skyline: (
|
|
2
|
+
/** The towers of a world's skyline, in the blocks round its play area; the same ones every time. */
|
|
3
|
+
export declare const skyline: (def: WorldDef) => Brush[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Brush, WorldDef } from '../shared/world';
|
|
2
|
+
/** The ground of the city, metres: about 100 m under the roofs. */
|
|
3
|
+
export declare const STREET = -80;
|
|
4
|
+
/** The asphalt's width, and the distance between two roads' centres. */
|
|
5
|
+
export declare const ROAD = 16;
|
|
6
|
+
export declare const PITCH = 72;
|
|
7
|
+
/** The box of the play area over the brushes: [x0, x1, z0, z1]. */
|
|
8
|
+
export declare const area: ({ brushes }: WorldDef) => number[];
|
|
9
|
+
/**
|
|
10
|
+
* The road grid: the x of each road that runs along z (`xs`) and the z of each that runs along x
|
|
11
|
+
* (`zs`), sorted. Two roads hug the play area at PLAZA from its box and the rest follow every PITCH
|
|
12
|
+
* out to `reach` from its centre, so no road crosses a building and every road crosses every other.
|
|
13
|
+
*/
|
|
14
|
+
export declare const grid: (def: WorldDef) => {
|
|
15
|
+
box: number[];
|
|
16
|
+
reach: number;
|
|
17
|
+
xs: number[];
|
|
18
|
+
zs: number[];
|
|
19
|
+
};
|
|
20
|
+
/** The brushes as they are drawn: the buildings, which go down to the floor, go on down to the street. */
|
|
21
|
+
export declare const deepen: ({ brushes, floor }: WorldDef) => Brush[];
|
|
22
|
+
/** The paving, the asphalt of every road, its lane markings and the crosswalks at its crossings. */
|
|
23
|
+
export declare const street: (def: WorldDef) => number[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { WorldDef } from '../shared/world';
|
|
2
|
+
import type { Vec3 } from './mesh';
|
|
3
|
+
/** Cars on the street. */
|
|
4
|
+
export declare const CARS = 64;
|
|
5
|
+
/** Seconds of a cycle, of one axis' green (the other's starts half a cycle later), and between the starts of two cars of a queue. */
|
|
6
|
+
export declare const CYCLE = 16;
|
|
7
|
+
/** Metres from a crossing's centre to the bumper of the first car waiting, between the cars of a queue, and a car's length. */
|
|
8
|
+
export declare const STOP: number;
|
|
9
|
+
export declare const GAP = 8;
|
|
10
|
+
export declare const LENGTH: number;
|
|
11
|
+
/** One car: its lane, and its place in the queue it starts in. */
|
|
12
|
+
export interface Car {
|
|
13
|
+
/** 0 on a road along z (constant x), 1 along x. */
|
|
14
|
+
axis: 0 | 1;
|
|
15
|
+
/** The road's x or z, and the way along its axis the lane goes: 1 or -1. */
|
|
16
|
+
at: number;
|
|
17
|
+
d: 1 | -1;
|
|
18
|
+
/** The crossings of the lane, in the order it drives them. */
|
|
19
|
+
stops: number[];
|
|
20
|
+
/** The crossing it waits before at time 0, and its place in that queue (0 is first). */
|
|
21
|
+
cell: number;
|
|
22
|
+
slot: number;
|
|
23
|
+
paint: number;
|
|
24
|
+
}
|
|
25
|
+
/** The cars of a world: CARS of the lanes' places, taken in the order of a hash, always the same. */
|
|
26
|
+
export declare const cars: (def: WorldDef) => Car[];
|
|
27
|
+
/** The way a car faces: x and z. */
|
|
28
|
+
export declare const facing: ({ axis, d }: Car) => [number, number];
|
|
29
|
+
/** Where a car's centre is at time t, seconds: x and z, and its size, 0 to 1: it shrinks away on its last hop and grows back on its first, so the end of its road is not seen. */
|
|
30
|
+
export declare const carAt: (car: Car, t: number) => [number, number, number];
|
|
31
|
+
export declare const MODEL: {
|
|
32
|
+
body: number[];
|
|
33
|
+
cabin: number[];
|
|
34
|
+
lamps: number[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The drawer of a world's traffic: appends the cars in view (in front of the camera, within FAR) at
|
|
38
|
+
* time t. At most CARS of them, each BODY + CABIN + LAMPS vertices (the cabin only up to NEAR_CAR).
|
|
39
|
+
*/
|
|
40
|
+
export declare const traffic: (def: WorldDef) => (out: number[], eye: Vec3, fwd: Vec3, t: number) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Brush, WorldDef } from '../shared/world';
|
|
2
|
+
import type { Vec3 } from './mesh';
|
|
2
3
|
/** A side of a brush: its axis (0 x, 2 z) and 1 for its max, 0 for its min. */
|
|
3
4
|
export type Side = [axis: number, up: number];
|
|
4
5
|
export interface Use {
|
|
@@ -11,6 +12,8 @@ export interface Use {
|
|
|
11
12
|
}
|
|
12
13
|
/** What a runner can use on brush `b` of the world `def`. */
|
|
13
14
|
export declare const uses: ({ brushes, floor }: WorldDef, b: Brush) => Use;
|
|
15
|
+
/** One face of the box min..max (flat on `axis` when min and max agree there) as two triangles, pushed in the map's vertex format. */
|
|
16
|
+
export declare const face: (out: number[], min: Vec3, max: Vec3, axis: number, up: number, layer: number, rgb: number[]) => void;
|
|
14
17
|
/** The red of every use in the world, in the map's vertex format (layer -2 glows, -1 is lit). */
|
|
15
18
|
export declare const vision: (def: WorldDef) => number[];
|
|
16
19
|
/** A square on each team's roof around its base, lit paint of the team's colour: pale inside, a strong frame. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.28.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|