@matchomag/cs2-replay 0.0.0-stage → 0.3.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.
Files changed (74) hide show
  1. package/FORMAT.md +350 -0
  2. package/README.md +453 -2
  3. package/bin/demo-replay-darwin-amd64 +0 -0
  4. package/bin/demo-replay-darwin-arm64 +0 -0
  5. package/bin/demo-replay-linux-amd64 +0 -0
  6. package/bin/demo-replay-linux-arm64 +0 -0
  7. package/bin/demo-replay-windows-amd64.exe +0 -0
  8. package/bin/demo-replay.js +22 -0
  9. package/dist/2d/index.js +1 -0
  10. package/dist/3d/index.js +11 -0
  11. package/dist/chunks/actors-EZRYEB4I.js +177 -0
  12. package/dist/chunks/chunk-5BFKVD63.js +1 -0
  13. package/dist/chunks/chunk-D5ST2XVO.js +106 -0
  14. package/dist/chunks/chunk-DQPOBPMK.js +1 -0
  15. package/dist/chunks/chunk-FBSLUYGT.js +1 -0
  16. package/dist/chunks/chunk-Q37CWKZX.js +12 -0
  17. package/dist/chunks/chunk-VSIECNZM.js +1 -0
  18. package/dist/chunks/chunk-YJG3LSSB.js +1 -0
  19. package/dist/chunks/chunk-YO73RW3Y.js +1 -0
  20. package/dist/chunks/look-2WBUGHMJ.js +669 -0
  21. package/dist/index.js +1 -0
  22. package/dist/maps/index.js +1 -0
  23. package/dist/parse/index.js +1 -0
  24. package/dist/parse/wasm/replay.wasm +0 -0
  25. package/dist/parse/worker.js +1 -0
  26. package/dist/types/2d/index.d.ts +17 -0
  27. package/dist/types/2d/radar.d.ts +35 -0
  28. package/dist/types/3d/actors.d.ts +90 -0
  29. package/dist/types/3d/characters/anim.d.ts +93 -0
  30. package/dist/types/3d/characters/ao.d.ts +3 -0
  31. package/dist/types/3d/characters/body.d.ts +37 -0
  32. package/dist/types/3d/characters/builder.d.ts +82 -0
  33. package/dist/types/3d/characters/index.d.ts +74 -0
  34. package/dist/types/3d/characters/rig.d.ts +73 -0
  35. package/dist/types/3d/characters/textures.d.ts +4 -0
  36. package/dist/types/3d/characters/viewmodel.d.ts +51 -0
  37. package/dist/types/3d/characters/weapons.d.ts +25 -0
  38. package/dist/types/3d/follow.d.ts +43 -0
  39. package/dist/types/3d/fx/batch.d.ts +87 -0
  40. package/dist/types/3d/fx/context.d.ts +34 -0
  41. package/dist/types/3d/fx/explosion.d.ts +14 -0
  42. package/dist/types/3d/fx/fire.d.ts +11 -0
  43. package/dist/types/3d/fx/index.d.ts +84 -0
  44. package/dist/types/3d/fx/lights.d.ts +25 -0
  45. package/dist/types/3d/fx/meshes.d.ts +18 -0
  46. package/dist/types/3d/fx/misc.d.ts +15 -0
  47. package/dist/types/3d/fx/random.d.ts +21 -0
  48. package/dist/types/3d/fx/smoke.d.ts +10 -0
  49. package/dist/types/3d/fx/textures.d.ts +29 -0
  50. package/dist/types/3d/fx/types.d.ts +117 -0
  51. package/dist/types/3d/greybox.d.ts +22 -0
  52. package/dist/types/3d/index.d.ts +127 -0
  53. package/dist/types/3d/look.d.ts +49 -0
  54. package/dist/types/3d/markers.d.ts +23 -0
  55. package/dist/types/3d/smoke/volume.d.ts +95 -0
  56. package/dist/types/3d/smoke/voxels.d.ts +87 -0
  57. package/dist/types/3d/world/index.d.ts +179 -0
  58. package/dist/types/3d/world/look.d.ts +16 -0
  59. package/dist/types/3d/world/material.d.ts +128 -0
  60. package/dist/types/3d/world/post.d.ts +75 -0
  61. package/dist/types/3d/world/probes.d.ts +39 -0
  62. package/dist/types/3d/world/release.d.ts +28 -0
  63. package/dist/types/3d/world/stage.d.ts +84 -0
  64. package/dist/types/core/format.d.ts +163 -0
  65. package/dist/types/core/live.d.ts +115 -0
  66. package/dist/types/core/model.d.ts +164 -0
  67. package/dist/types/core/playback.d.ts +82 -0
  68. package/dist/types/core/theme.d.ts +46 -0
  69. package/dist/types/index.d.ts +6 -0
  70. package/dist/types/maps/index.d.ts +258 -0
  71. package/dist/types/parse/index.d.ts +108 -0
  72. package/dist/types/ui/shell.d.ts +131 -0
  73. package/dist/types/ui/styles.d.ts +1 -0
  74. package/package.json +68 -4
@@ -0,0 +1,177 @@
1
+ import{e as Hn}from"./chunk-DQPOBPMK.js";import{n as kn,p as eo}from"./chunk-Q37CWKZX.js";import{b as vn}from"./chunk-VSIECNZM.js";import{a as Go}from"./chunk-YJG3LSSB.js";import*as st from"three";import*as Dt from"three";import*as Ae from"three";import*as we from"three";var y={root:0,hips:1,spine1:2,spine2:3,spine3:4,neck:5,head:6,clavL:7,armL:8,foreL:9,handL:10,clavR:11,armR:12,foreR:13,handR:14,thighL:15,calfL:16,footL:17,thighR:18,calfR:19,footR:20},_o=Object.keys(y),oo=_o.length,Ge=[-1,0,1,2,3,4,5,4,7,8,9,4,11,12,13,1,15,16,1,18,19],Do=[0,1,2,3,4,5,6,11,12,13,14,7,8,9,10,18,19,20,15,16,17],Mt=(n,t,o)=>new we.Vector3(n,t,o),t0=.285,C0=.262,L0=Mt(Math.SQRT1_2,-Math.SQRT1_2,0),Vn=Mt(.182,1.455,-.018),Sn=Vn.clone().addScaledVector(L0,t0),Bs=Sn.clone().addScaledVector(L0,C0),gt=[];{let n={[y.root]:Mt(0,0,0),[y.hips]:Mt(0,.97,0),[y.spine1]:Mt(0,1.07,-.008),[y.spine2]:Mt(0,1.19,-.014),[y.spine3]:Mt(0,1.32,-.016),[y.neck]:Mt(0,1.505,-.025),[y.head]:Mt(0,1.596,-.012),[y.clavL]:Mt(.028,1.468,.004),[y.armL]:Vn,[y.foreL]:Sn,[y.handL]:Bs,[y.thighL]:Mt(.092,.925,.002),[y.calfL]:Mt(.098,.5,.014),[y.footL]:Mt(.103,.085,-.016)};for(let t=0;t<oo;t++){let o=n[t]??n[Do[t]];gt[t]=n[t]?o.clone():o.clone().setX(-o.x)}}var Pn=gt[y.calfL].distanceTo(gt[y.thighL]),Cn=gt[y.footL].distanceTo(gt[y.calfL]),F0=gt.map((n,t)=>Ge[t]<0?n.clone():n.clone().sub(gt[Ge[t]])),u0={ankleHeight:.085,ball:Mt(0,-.066,.135),heel:Mt(0,-.076,-.055),toe:Mt(0,-.07,.205)},no={L:{along:L0.clone(),back:Mt(Math.SQRT1_2,Math.SQRT1_2,0),thumb:Mt(0,0,1)},R:{along:Mt(-Math.SQRT1_2,-Math.SQRT1_2,0),back:Mt(-Math.SQRT1_2,Math.SQRT1_2,0),thumb:Mt(0,0,1)}},so=Mt(.068,-.034,.004),xa=Mt(.055,-.022,0),zn=new we.Matrix4,An=new we.Vector3;function h0(n,t,o=new we.Quaternion){return An.crossVectors(n,t),zn.makeBasis(n,t,An),o.setFromRotationMatrix(zn)}function I0(n,t){return n.addScaledVector(t,-n.dot(t)),n.lengthSq()<1e-8&&(n.set(-t.y,t.x,0),n.lengthSq()<1e-8&&n.set(0,-t.z,t.y)),n.normalize()}function Zt(n,t,o,e=new we.Quaternion){let s=no[n],r=t.clone().normalize(),c=I0(o.clone(),r),a=h0(r,c,new we.Quaternion),i=h0(s.along,s.back,new we.Quaternion);return e.copy(a).multiply(i.invert())}var w=(n=0,t=0,o=0)=>new Ae.Vector3(n,t,o),qt=()=>new Ae.Quaternion,e0=(n,t=0,o=1)=>Math.min(o,Math.max(t,n)),O=(n,t,o)=>n+(t-n)*o,ct=(n,t,o)=>{let e=e0((o-n)/(t-n));return e*e*(3-2*e)},F=Ae.MathUtils.degToRad,_e=Math.PI*2,Wo=n=>Math.atan2(Math.sin(n),Math.cos(n)),X=(n,t,o,e=qt())=>e.setFromEuler(new Ae.Euler(n,t,o,"YXZ")),Ln=(n,t,o=qt())=>o.setFromAxisAngle(n,t);function qs(n,t){let o=Math.imul(n^2654435769,2246822507)^Math.imul(t+1663821227,3266489909);return o=Math.imul(o^o>>>15,739982445),o^=o>>>12,(o>>>0)/4294967296}function Oo(n,t,o){if(t<=n[0][0])return o.copy(n[0][1]);let e=n.length;if(t>=n[e-1][0])return o.copy(n[e-1][1]);let s=0;for(;t>n[s+1][0];)s++;let r=(t-n[s][0])/(n[s+1][0]-n[s][0]),c=n[Math.max(0,s-1)][1],a=n[s][1],i=n[s+1][1],l=n[Math.min(e-1,s+2)][1],u=r*r,h=u*r;return o.set(0,0,0).addScaledVector(c,-.5*h+u-.5*r).addScaledVector(a,1.5*h-2.5*u+1).addScaledVector(i,-1.5*h+2*u+.5*r).addScaledVector(l,.5*h-.5*u)}var B0=(n,t,o={})=>({aimP:n,aimR:[0,4,0],lowP:t,lowR:[34,22,12],chest:[-32,-18],elbowR:w(-.55,-.8,-.15),elbowL:w(.45,-.9,-.05),head:[13,14],twoHand:!0,...o}),Uo={rifle:B0(w(-.105,.145,.33),w(-.12,0,.27)),smg:B0(w(-.105,.14,.31),w(-.12,0,.26)),sniper:B0(w(-.105,.14,.42),w(-.12,-.02,.3),{head:[15,16]}),shotgun:B0(w(-.105,.14,.33),w(-.12,0,.27)),lmg:B0(w(-.11,.08,.36),w(-.12,-.04,.28),{head:[9,8],lowR:[25,18,10]}),pistol:{aimP:w(-.03,.115,.42),aimR:[0,3,0],lowP:w(-.06,-.08,.3),lowR:[48,12,0],chest:[-8,-8],elbowR:w(-.7,-.7,0),elbowL:w(.7,-.7,0),head:[3,0],twoHand:!0},taser:{aimP:w(-.1,.11,.45),aimR:[0,6,0],lowP:w(-.12,-.12,.28),lowR:[55,10,0],chest:[-20,-10],elbowR:w(-.6,-.8,0),elbowL:w(.6,-.8,-.2),head:[3,0],twoHand:!1},knife:{aimP:w(-.15,-.13,.3),aimR:[62,8,-10],lowP:w(-.16,-.16,.24),lowR:[70,8,-10],chest:[-12,-6],elbowR:w(-.7,-.7,-.2),elbowL:w(.7,-.7,-.2),head:[3,0],twoHand:!1},grenade:{aimP:w(-.12,0,.27),aimR:[-10,15,0],lowP:w(-.14,-.08,.24),lowR:[10,10,0],chest:[-10,-6],elbowR:w(-.7,-.7,-.2),elbowL:w(.7,-.7,-.2),head:[3,0],twoHand:!1},c4:{aimP:w(-.12,-.2,.29),aimR:[10,0,0],lowP:w(-.12,-.22,.27),lowR:[14,0,0],chest:[0,0],elbowR:w(-.8,-.6,-.1),elbowL:w(.8,-.6,-.1),head:[12,0],twoHand:!0},none:{aimP:w(-.15,-.3,.1),aimR:[0,0,0],lowP:w(-.15,-.3,.1),lowR:[0,0,0],chest:[0,0],elbowR:w(-.3,-.5,-1),elbowL:w(.3,-.5,-1),head:[0,0],twoHand:!1}},Gs=new Set(["none"]);function De(n,t,o){let e=w().subVectors(gt[t],gt[n]).normalize(),s=I0(o.clone(),e);return{a:e,p:s,q:h0(e,s)}}var We={armL:De(y.armL,y.foreL,w(0,0,-1)),foreL:De(y.foreL,y.handL,w(0,0,-1)),armR:De(y.armR,y.foreR,w(0,0,-1)),foreR:De(y.foreR,y.handR,w(0,0,-1)),thighL:De(y.thighL,y.calfL,w(0,0,1)),calfL:De(y.calfL,y.footL,w(0,0,1)),thighR:De(y.thighR,y.calfR,w(0,0,1)),calfR:De(y.calfR,y.footR,w(0,0,1))},ht=()=>({p:w(),q:qt(),pole:w()});function Bt(n,t,o){o<=0||(n.p.lerp(t.p,o),n.q.slerp(t.q,o),n.pole.lerp(t.pole,o).normalize())}function ro(n,t,o,e,s){let r=t.along.clone().normalize(),c=I0(t.back.clone(),r),a=n==="L"?w().crossVectors(r,c):w().crossVectors(c,r),i=t.pos.clone().addScaledVector(r,-so.x).addScaledVector(c,-so.y).addScaledVector(a,-so.z);return s.p.copy(i).applyQuaternion(e).add(o),Zt(n,r,c,s.q).premultiply(e),s}function jo(n,t,o){let e=ro("R",n.right,w(),qt(),ht());o.copy(e.q).invert(),t.copy(e.p).negate().applyQuaternion(o)}var ao=class n{bones;weapon={visible:!0,inHand:!0,pos:w(),quat:qt()};seed;rnd;lq=[];mq=[];mp=[];hipsP=w();hipsQ=qt();spine=[qt(),qt(),qt()];feet=[ht(),ht()];hands=[ht(),ht()];rootP=w();rootQ=qt();phase=0;clock=0;dirX=0;dirZ=1;s={crouch:0,move:0,run:0,speed:0,air:0,plant:0,defuse:0,blind:0,hipYaw:0,lean:0,weaponLow:0};airborne=!1;airTime=0;landAge=9;lastVy=0;initialized=!1;constructor(t,o){this.bones=t,this.seed=o|0,this.rnd=Array.from({length:16},(e,s)=>qs(this.seed,s));for(let e=0;e<oo;e++)this.lq.push(qt()),this.mq.push(qt()),this.mp.push(w());this.clock=this.rnd[0]*10}update(t){let o=t.reset||!this.initialized||t.dt<0||t.dt>.5,e=o?0:t.dt;if(this.initialized=!0,this.clock+=e,!t.alive){this.death(t),this.write();return}this.rootP.set(0,0,0),this.rootQ.identity(),this.locomotion(t,e,o),this.fkSpine(),this.arms(t),this.solveAll(),this.write()}damp(t,o,e,s,r){let c=this.s;return c[t]=r||e<=0?o:o+(c[t]-o)*Math.exp(-s/e),c[t]}locomotion(t,o,e){let s=this.s,r=this.rnd,c=Math.cos(t.yaw),a=Math.sin(t.yaw),i=t.velocity.x*c-t.velocity.z*a,l=t.velocity.x*a+t.velocity.z*c,u=t.velocity.y,h=Math.hypot(i,l),d=this.damp("speed",h,.08,o,e);if(h>.15){let D=e?1:1-Math.exp(-o/.08);this.dirX+=(i/h-this.dirX)*D,this.dirZ+=(l/h-this.dirZ)*D;let et=Math.hypot(this.dirX,this.dirZ)||1;this.dirX/=et,this.dirZ/=et}if(e)this.airborne=Math.abs(u)>2.5&&Math.abs(u)>h*.9+1,this.airTime=this.airborne?.3:0,this.landAge=9;else if(!this.airborne)(u>2.2&&u>h*.85+.8||u<-4)&&(this.airborne=!0,this.airTime=0),this.landAge+=o;else{this.airTime+=o;let D=u<-1.5,et=this.airTime>.25&&u>-.6&&this.lastVy<-1.5,Tt=this.airTime>.25&&Math.abs(u)<.3&&Math.abs(this.lastVy)<.3;(et||Tt||this.airTime>3)&&!D&&(this.airborne=!1,this.landAge=0)}this.lastVy=u;let m=this.damp("crouch",t.ducking?1:0,.09,o,e),p=this.damp("move",ct(.08,.7,h),.12,o,e),b=this.damp("run",ct(2.6,4.6,h)*(1-(t.ducking?1:0)),.15,o,e);this.damp("air",this.airborne?1:0,this.airborne?.06:.05,o,e);let f=this.damp("plant",t.planting?1:0,.18,o,e),g=this.damp("defuse",t.defusing&&!t.planting?1:0,.18,o,e),R=Math.max(f,g);this.damp("blind",t.blind?1:0,t.blind?.07:.25,o,e),this.damp("weaponLow",b*(t.scoped?0:1),.12,o,e);let E=ct(1.8,5,d)*(1-m),M=O(O(.62,.3,E),.55,m),P=O(O(.72,.86,E),.7,m),C=O(1.6+.45*d,2+.5*d,m),v=Math.max(C,2*d*M/P);e||(this.phase=(this.phase+o*v/2)%1);let L=2*Math.max(d,.001)/v,z=O(.07,.05,E)*(1-.5*m),H=Math.atan2(this.dirX,this.dirZ),x=0;Math.abs(H)<=F(110)?x=e0(H*.5,-F(48),F(48)):x=e0(Wo(H-Math.PI)*.35,-F(25),F(25)),x*=p*(1-R);let T=this.damp("hipYaw",x,.18,o,e),A=this.damp("lean",O(3,9,E)*p*(1-m*.5),.2,o,e),S=this.phase*_e,q=M/2,j=gt[y.hips].y-.04+.012*p*(1-E)-.035*E*p,K=O(j,.63,m),B=.016*Math.cos(2*(S-q*_e)),Y=-.03*Math.cos(2*(S-q*_e))-.005;K+=p*O(O(B,Y,E),.4*B,m);let Rt=Math.sin(this.clock*1.6+r[1]*6),Ut=Math.sin(this.clock*.45+r[2]*6);K+=(1-p)*.004*Rt;let ee=p*O(.022,.01,E)*Math.cos(S-q*_e)+(1-p)*.018*Ut*(1-m),pt=this.landAge<.35?Math.sin(this.landAge/.35*Math.PI)*.09*(1-m):0;K-=pt,this.hipsP.set(ee,K,-.01*m);let oe=-p*O(F(6),F(9),E)*Math.cos(S)*(1-m*.5),jt=p*F(3.5)*Math.cos(S-q*_e)*(1-E*.5)+(1-p)*F(2)*Ut,Nt=w(this.dirZ,0,-this.dirX).normalize(),Ee=Ln(Nt,F(A)*.5);this.hipsQ.copy(Ee).multiply(X(F(4)+F(14)*m,T+oe,jt));let Lt=Uo[t.cls],Yt=this.s.weaponLow,Ft=F(O(Lt.chest[0],Lt.chest[1],Yt))*(1-R),It=F(t.pitch),qe=-(T+oe)+Ft,ye=F(A)*.5+F(9)*m-It*.45+F(1.2)*Rt*(1-p),ge=-jt*.8,ue=[.3,.35,.35];for(let D=0;D<3;D++)X(ye*ue[D],qe*ue[D],ge*ue[D],this.spine[D]);let Me=O(O(O(.13,.105,p),.075,E*p),.13,m),ot=X(0,T,0),zt=w(this.dirX,0,this.dirZ),yt=Math.abs(Math.sin(H-T));for(let D=0;D<2;D++){let et=D===0?1:-1,Tt=this.feet[D],vt=(this.phase+(D===0?0:.5))%1,ze=(D===0?.07:-.07)*(1-m),c0=D===0?.17:-.24,S0=w(et*Me,0,O(ze*(1-p),c0,m)).applyQuaternion(ot),qo=0,Mn=0,l0=0;if(vt<M){let re=vt/M;qo=(.5-re)*M*L-z,l0=-F(O(14,4,E))*(1-ct(0,.18,re))+F(O(32,42,E))*ct(.6,1,re)**1.5}else{let re=(vt-M)/(1-M),Rn=M*L,Tn=-.85*(1-M)*L,P0=re*re,to=P0*re;qo=-Rn/2*(2*to-3*P0+1)+Tn*(to-2*P0+re)+Rn/2*(-2*to+3*P0)+Tn*(to-P0)-z;let Is=O(1,.65,E);Mn=O(.085,.24,E)*Math.sin(Math.PI*Math.pow(re,Is))*O(1,.7,m),l0=F(O(32,42,E))*(1-ct(0,.5,re))+F(O(10,25,E))*Math.sin(Math.PI*re)*.5-F(O(14,4,E))*ct(.6,1,re)}let J0=p*(1-R),wn=S0.addScaledVector(zt,qo*J0);vt>=M&&wn.add(w(0,0,.11*yt*Math.sin(Math.PI*(vt-M)/(1-M))*J0).applyQuaternion(ot)),D===1&&(l0=O(l0,F(55),m*(1-p))),l0*=Math.max(J0,m*D*(1-p));let xn=T+et*F(O(O(8,4,E),14,m))+(D===1?F(14)*(1-p)*(1-m):0);this.footFromGround(wn,Mn*J0,l0,xn,Tt),Tt.pole.set(et*.15,.1,1).applyQuaternion(X(0,xn,0)).normalize()}if(s.air>.001){let D=s.air*(1-.5*ct(-2,-7,t.velocity.y));for(let et=0;et<2;et++){let Tt=et===0?1:-1,vt=this.feet[et],ze=w(Tt*.11,.42+(et===0?.05:-.02),et===0?.05:-.1).applyQuaternion(ot),c0=X(F(et===0?25:40),T+Tt*F(8),0);vt.p.lerp(ze,D),vt.q.slerp(c0,D),vt.pole.lerp(w(Tt*.2,.2,1).applyQuaternion(ot),D).normalize()}this.hipsP.y=O(this.hipsP.y,gt[y.hips].y-.04,D);for(let et of this.spine)et.multiply(X(F(4)*D,0,0))}if(R>.001){let D=g/Math.max(R,1e-4);this.hipsP.lerp(w(.02,O(.52,.5,D),-.02),R),this.hipsQ.slerp(X(F(16),F(6),0),R);let et=F(O(15,13,D));for(let ze=0;ze<3;ze++)this.spine[ze].slerp(X(et,F(-2),0),R);let Tt=ht(),vt=ht();this.footFromGround(w(.12,0,.3),0,0,F(10),Tt),Tt.pole.set(.15,.4,1).normalize(),vt.p.set(-.12,.115,-.32),X(F(72),F(-8),0,vt.q),vt.pole.set(-.05,-.3,1).normalize(),Bt(this.feet[0],Tt,R),Bt(this.feet[1],vt,R)}if(t.hurtAge!==void 0&&t.hurtAge>=0&&t.hurtAge<.45){let D=t.hurtAge,et=D<.05?D/.05:Math.exp(-(D-.05)/.1),Tt=r[3]<.5?1:-1;for(let vt of this.spine)vt.multiply(X(-F(5)*et,F(4)*Tt*et,F(4)*Tt*et));this.hipsP.y-=.025*et}if(t.shotAge!==void 0&&t.shotAge>=0&&t.shotAge<.4&&t.def.kick[0]>0){let D=this.recoilCurve(t.shotAge);this.spine[2].multiply(X(-F(t.def.kick[1]*.25)*D,0,0))}}recoilCurve(t){return t<.025?t/.025:Math.exp(-(t-.025)/.065)}footFromGround(t,o,e,s,r){let c=X(0,s,0),a=X(e,0,0),i=(e>0?u0.ball:u0.heel).clone(),l=w(0,0,0).sub(i).applyQuaternion(a).add(i);l.y+=u0.ankleHeight+o,r.p.copy(l.applyQuaternion(c)).add(t).setY(l.y),r.q.copy(c).multiply(a)}fk(t){let o=Ge[t];if(o<0){this.mq[t].identity(),this.mp[t].set(0,0,0);return}this.mq[t].multiplyQuaternions(this.mq[o],this.lq[t]),t===y.hips?this.mp[t].copy(this.hipsP):this.mp[t].copy(F0[t]).applyQuaternion(this.mq[o]).add(this.mp[o])}fkSpine(){this.lq[y.root].identity(),this.lq[y.hips].copy(this.hipsQ),this.lq[y.spine1].copy(this.spine[0]),this.lq[y.spine2].copy(this.spine[1]),this.lq[y.spine3].copy(this.spine[2]);for(let t of[y.root,y.hips,y.spine1,y.spine2,y.spine3])this.fk(t)}aimQ(t){return X(-F(t),0,0)}arms(t){let o=this.s,e=this.rnd,s=Uo[t.cls],r=t.def,c=o.weaponLow,a=Math.max(o.plant,o.defuse),i=this.mp[y.spine3],l=this.aimQ(t.pitch),u=Gs.has(t.cls),h=s.aimP.clone().lerp(s.lowP,c),d=s.aimR.map((A,S)=>O(A,s.lowR[S],c)),m=this.clock,p=(1-o.move)*1;d[0]+=p*.6*Math.sin(m*.9+e[4]*6)+o.move*2.5*c*Math.sin(this.phase*_e*2),d[1]+=p*.6*Math.sin(m*.7+e[5]*6)+o.move*3*c*Math.cos(this.phase*_e);let b=l.clone().multiply(X(F(d[0]),F(d[1]),F(d[2]))),f=h.clone().applyQuaternion(l).add(i);if(t.shotAge!==void 0&&t.shotAge>=0&&t.shotAge<.45){if(t.cls==="knife")this.slash(t.shotAge,f,b,l,i);else if(r.kick[0]>0){let A=this.recoilCurve(t.shotAge);f.add(w(0,0,-r.kick[0]*A).applyQuaternion(b)),b.multiply(X(-F(r.kick[1])*A,F(r.kick[1]*.15*(e[6]-.5))*A,0))}}let g=0,R=ht();if(t.throwAge!==void 0&&t.throwAge>=0&&t.throwAge<.7&&(g=this.throwPose(t.throwAge,f,b,l,i,R)),o.plant>.001){let A=w(-.13,.06,.48),S=Math.sin(this.clock*9)*.01;A.y+=S,f.lerp(A,o.plant),b.slerp(X(0,F(4),0),o.plant)}let E=ht(),M=ht();ro("R",r.right,f,b,E),E.pole.copy(s.elbowR).normalize();let P=ht(),C=ht();this.freeArm(0,P),this.freeArm(1,C),u&&Bt(E,C,1);let v=s.twoHand&&r.left!==null;if(v||(t.cls==="none"?Bt(M,P,1):(M.p.set(.07,-.04,.24).applyQuaternion(l).add(i),M.p.lerp(P.p,c*.7),Zt("L",w(-.5,.35,.8),w(.6,.6,-.2),M.q).premultiply(l),M.q.slerp(P.q,c*.7),M.pole.copy(s.elbowL).normalize())),g>0&&Bt(M,R,g),o.defuse>.001){let A=o.defuse,S=G=>Math.sin(this.clock*7+G)*.015,q=ht(),j=ht();q.p.set(.07+S(0),.16+S(1),.46),j.p.set(-.09+S(2),.17+S(3),.44),Zt("L",w(-.3,-.5,.8),w(.3,.8,.3),q.q),Zt("R",w(.3,-.5,.8),w(-.3,.8,.3),j.q),q.pole.set(.6,-.3,-.3).normalize(),j.pole.set(-.6,-.3,-.3).normalize(),Bt(M,q,A),Bt(E,j,A)}let L=o.blind*(1-a);if(L>.001){let A=ht(),S=this.mp[y.spine3].clone().add(w(0,.3,0));if(A.p.copy(S).add(w(.02,0,.2).applyQuaternion(this.chestYawQ())),Zt("L",w(-.8,.45,.25),w(.15,.25,.95),A.q).premultiply(this.chestYawQ()),A.pole.set(.9,-.2,.1).normalize(),Bt(M,A,L),!u){let q=ht(),j=s.lowP.clone().add(w(0,-.06,-.02)).applyQuaternion(l).add(i),G=l.clone().multiply(X(F(s.lowR[0]+12),F(s.lowR[1]),F(s.lowR[2])));ro("R",r.right,j,G,q),q.pole.copy(s.elbowR).normalize(),Bt(E,q,L)}}for(let A=0;A<2;A++){let S=A===0?M:E,q=A===0?1:-1,j=this.mp[y.spine3].y+.13,G=ct(-.05,.25,S.p.y-j),K=ct(.25,.5,S.p.z-this.mp[y.spine3].z);X(0,-q*F(8)*K,q*F(14)*G,this.lq[A===0?y.clavL:y.clavR])}this.hands[0]=M,this.hands[1]=E,this.leftGripW=v?(1-L)*(1-o.defuse)*(1-g):0;let z=O(s.head[0],3,c)+(t.scoped?4:0),H=O(s.head[1],0,c)+(t.scoped?3:0),x=l.clone().multiply(X(F(z)+F(1)*Math.sin(m*.3+e[7]*6),F(3)*Math.sin(m*.23+e[8]*6)*(1-o.move),F(H)));if(L>.001&&x.slerp(X(F(22),-F(50),F(-12)),L),a>.001&&x.slerp(X(F(40),0,0),a),t.hurtAge!==void 0&&t.hurtAge>=0&&t.hurtAge<.45){let A=t.hurtAge,S=A<.04?A/.04:Math.exp(-(A-.04)/.09);x.multiply(X(-F(14)*S,F(10)*(e[3]<.5?1:-1)*S,0))}this.lookQ.copy(x),this.wpos.copy(f),this.wq.copy(b);let T=t.throwAge!==void 0&&t.throwAge>.3&&t.throwAge<.7;this.weapon.visible=r.geometry!==null&&o.defuse<.5&&!T,this.weapon.inHand=!0}leftGripW=0;lookQ=qt();wpos=w();wq=qt();chestYawQ(){let t=w(0,0,1).applyQuaternion(this.mq[y.spine3]);return X(0,Math.atan2(t.x,t.z),0)}freeArm(t,o){let e=this.s,s=t===0?1:-1,r=Math.cos((this.phase+(t===0?.5:0))*_e)*e.move,c=e.run,a=this.mp[y.hips],i=O(.12,.26,c);o.p.set(s*O(.2,.17,c),O(.86,1.02,c)+O(0,.07,c)*r,.02+O(.03,.08,c)+i*r),o.p.y+=a.y-gt[y.hips].y,o.p.x+=a.x;let l=w(0,-1,.15).lerp(w(0,-.2,1),c*(.5+.5*r)).normalize();Zt(t===0?"L":"R",l,w(s,.1,0),o.q),o.pole.set(s*.25,-.3,-1).normalize(),o.p.z+=.005*Math.sin(this.clock*1.6+this.rnd[1]*6)*(1-e.move)}slash(t,o,e,s,r){let c=[[0,w(-.15,-.13,.3)],[.08,w(-.3,.08,.22)],[.18,w(.05,.02,.5)],[.26,w(.2,-.1,.38)],[.42,w(-.15,-.13,.3)]],a=Oo(c,t,w()),i=ct(0,.05,t)*(1-ct(.3,.42,t));o.lerp(a.applyQuaternion(s).add(r),i);let l=t<.08?O(0,-50,t/.08):O(-50,60,ct(.08,.26,t));e.slerp(s.clone().multiply(X(F(75),F(l),F(-60))),i)}throwPose(t,o,e,s,r,c){let a=[[0,w(-.12,0,.27)],[.2,w(-.25,.32,-.15)],[.27,w(-.22,.38,-.08)],[.36,w(-.12,.3,.42)],[.46,w(-.05,-.05,.42)],[.65,w(-.12,0,.27)]],i=ct(0,.06,t)*(1-ct(.48,.65,t)),l=Oo(a,t,w());o.lerp(l.applyQuaternion(s).add(r),i);let u=t<.2?O(-10,-70,t/.2):O(-70,50,ct(.25,.42,t));e.slerp(s.clone().multiply(X(F(u),F(10),0)),i);let h=Oo([[0,w(.07,-.04,.24)],[.18,w(.12,.2,.42)],[.3,w(.14,.18,.4)],[.42,w(.18,-.15,.1)],[.65,w(.07,-.04,.24)]],t,w());c.p.copy(h).applyQuaternion(s).add(r),Zt("L",w(0,.2,1),w(1,.3,0),c.q).premultiply(s),c.pole.set(.7,-.7,-.1).normalize();let d=t<.22?O(0,-28,ct(0,.22,t)):O(-28,22,ct(.24,.42,t)),m=t<.22?O(0,-8,ct(0,.22,t)):O(-8,12,ct(.24,.42,t));for(let p=0;p<3;p++)this.spine[p].multiply(X(F(m/3)*i,F(d/3)*i,0));return this.fkSpine(),i}solveAll(){this.fk(y.neck);let t=this.lookQ,o=this.mq[y.spine3].clone().invert().multiply(t);if(this.lq[y.neck].copy(qt().slerp(o,.4)),this.fk(y.neck),this.lq[y.head].copy(this.mq[y.neck].clone().invert().multiply(t)),this.fk(y.head),this.fk(y.clavR),this.fk(y.armR),this.solveArm(1,this.hands[1]),this.leftGripW>.001){let e=this.curDef,s=this.mq[y.handR],r=this.mp[y.handR],c=w(),a=qt();jo(e,c,a);let i=s.clone().multiply(a),l=c.clone().applyQuaternion(s).add(r),u=ro("L",e.left,l,i,ht());u.pole.copy(Uo[e.cls].elbowL).normalize();let h=this.hands[0],d=this.leftGripW;if(d>=.999)Bt(h,u,1);else{let m=ht();m.p.copy(u.p),m.q.copy(u.q),m.pole.copy(u.pole),Bt(m,h,1-d),Bt(h,m,1)}}this.fk(y.clavL),this.fk(y.armL),this.solveArm(0,this.hands[0]),this.solveLeg(0,this.feet[0]),this.solveLeg(1,this.feet[1])}curDef=null;solveArm(t,o){let e=t===0;this.solveLimb(e?y.armL:y.armR,e?y.foreL:y.foreR,e?y.handL:y.handR,o,e?We.armL:We.armR,e?We.foreL:We.foreR,t0,C0,.6)}solveLeg(t,o){let e=t===0;this.fk(e?y.thighL:y.thighR),this.solveLimb(e?y.thighL:y.thighR,e?y.calfL:y.calfR,e?y.footL:y.footR,o,e?We.thighL:We.thighR,e?We.calfL:We.calfR,Pn,Cn,0)}solveLimb(t,o,e,s,r,c,a,i,l){let u=this.mp[t],h=w().subVectors(s.p,u),d=h.length(),m=d>1e-6?h.divideScalar(d):w(0,-1,0);d=e0(d,Math.abs(a-i)+.001,a+i-1e-4);let p=e0((a*a+d*d-i*i)/(2*a*d),-1,1),b=Math.sqrt(1-p*p),f=I0(s.pole.clone(),m),g=u.clone().addScaledVector(m,a*p).addScaledVector(f,a*b),R=u.clone().addScaledVector(m,d),E=w().crossVectors(m,f).normalize(),M=w().subVectors(g,u).normalize(),P=w().subVectors(R,g).normalize(),C=w().crossVectors(E,M),v=w().crossVectors(E,P),L=h0(M,C).multiply(r.q.clone().invert()),z=h0(P,v).multiply(c.q.clone().invert());if(l>0){let x=z.clone().invert().multiply(s.q),T=c.a,A=x.x*T.x+x.y*T.y+x.z*T.z,S=new Ae.Quaternion(T.x*A,T.y*A,T.z*A,x.w);S.lengthSq()>1e-10&&(S.normalize(),S.w<0&&S.set(-S.x,-S.y,-S.z,-S.w),z.multiply(qt().slerp(S,l)))}let H=Ge[t];this.lq[t].copy(this.mq[H]).invert().multiply(L),this.mq[t].copy(L),this.lq[o].copy(L).invert().multiply(z),this.mq[o].copy(z),this.mp[o].copy(g),this.lq[e].copy(z).invert().multiply(s.q),this.mq[e].copy(s.q),this.mp[e].copy(R)}write(){let t=this.bones;t[y.root].position.copy(this.rootP),t[y.root].quaternion.copy(this.rootQ);for(let o=1;o<oo;o++)t[o].quaternion.copy(this.lq[o]);t[y.hips].position.copy(this.hipsP)}death(t){let o=this.rnd,e=Math.max(0,t.deathAge??10),s=t.headshot,r,c=t.deathDir;if(c&&c.x*c.x+c.z*c.z>1e-6){let ot=Math.cos(t.yaw),zt=Math.sin(t.yaw),yt=c.x*ot-c.z*zt,D=c.x*zt+c.z*ot;r=Math.atan2(yt,D)}else r=(o[9]<.55?Math.PI:0)+(o[10]-.5)*1.4;r=Wo(r);let a=Math.abs(r),i=a<F(55)?"front":a>F(125)?"back":"side",l=i==="front"?0:i==="back"?Math.PI*Math.sign(r||1):Math.PI/2*Math.sign(r),u=Wo(r-l)+(o[11]-.5)*.35,h=i==="side"?Math.sign(r):0,d=s?.1:.06,m=s?.8:.88+o[12]*.14,p=e0((e-d)/(m-d)),b=Math.PI/2*Math.pow(p,i==="back"&&!s?1.6:2);e>m&&(b-=.05*Math.sin(Math.PI*e0((e-m)/.22))*Math.exp(-(e-m)*3));let f=u*ct(.04,m*.9,e),g=ct(m-.12,m+.08,e),R=ct(m-.25,m+.2,e),E=ct(m-.1,m+.45,e),M=w(Math.sin(r),0,Math.cos(r)),P=w(M.z,0,-M.x),C=Ln(P,b).multiply(X(0,f,0)),v=M.clone().multiplyScalar(.07);this.rootQ.copy(C),this.rootP.copy(v).sub(v.clone().applyQuaternion(C));let z=(s?.45:i==="front"?.34:i==="back"?.22:.32)*ct(0,s?.34:.42,e);this.hipsP.set(0,gt[y.hips].y-.02-z,0);let H=(e<.05?e/.05:Math.exp(-(e-.05)/.12))*(s?1.5:1),x=Math.sin(r-f),T=Math.cos(r-f),S=Math.sin(Math.PI*p)*(i==="front"?.3:i==="back"?.2:.15)*(1-g)+.12*H*T+(i==="front"?.06:0)*g,q=-.15*H*x+(i==="side"?.15*h*g:0),j=(o[13]-.5)*.5*g;this.hipsQ.copy(X((i==="front"?.3*z:-.25*z)*(1-g),0,0));for(let ot=0;ot<3;ot++)X(S/3,j/3,q/3,this.spine[ot]);this.fkSpine();let G=X(0,f,0),K=[ht(),ht()];this.footFromGround(w(.11,0,.03).applyQuaternion(G),0,0,f+F(8),K[0]),this.footFromGround(w(-.11,0,-.03).applyQuaternion(G),0,0,f-F(8),K[1]);let B=[ht(),ht()],Y=.12+o[14]*.08,Rt=this.hipsP.y+F0[y.thighL].y-(s?.7:.81);if(i==="back")B[0].p.set(Y,Rt,.02),B[1].p.set(-Y-.03,Rt+o[15]*.12,.04),X(-.25,.55,.3,B[0].q),X(-.25,-.6,-.3,B[1].q);else if(i==="front")B[0].p.set(Y*.8,Rt,0),B[1].p.set(-Y*.8,Rt+.02,-.02),X(1.2,.2,0,B[0].q),X(1.15,-.25,0,B[1].q);else{let ot=h>0?B[1]:B[0],zt=h>0?B[0]:B[1];zt.p.set(.1*h,Rt+.05,-.1),ot.p.set(-.06*h,Rt+.22,.16),X(.5,0,0,zt.q),X(.3,0,0,ot.q)}let Ut=this.rootQ.clone().invert();for(let ot=0;ot<2;ot++){let zt=K[ot];zt.p.sub(this.rootP).applyQuaternion(Ut),zt.q.premultiply(Ut),zt.pole.set(ot===0?.15:-.15,0,1).normalize();let yt=s?ot===0?1:-1:ot===0?.3:-.3;B[ot].pole.set(yt,0,1).normalize(),Bt(zt,B[ot],E),this.feet[ot]=zt}let ee=i==="front"?w(0,0,1):i==="back"?w(0,0,-1):w(h,0,0),pt=ee.clone().negate(),oe=this.mp[y.spine3],jt=ht(),Nt=ht();jt.p.set(.24,oe.y-.42,.14),Nt.p.set(-.24,oe.y-.38,.22),Zt("L",w(0,-1,.3),w(1,0,0),jt.q),Zt("R",w(0,-1,.3),w(-1,0,0),Nt.q),jt.pole.set(.5,-.4,-.6).normalize(),Nt.pole.set(-.5,-.4,-.6).normalize();let Ee=ct(.02,.16,e)*(1-ct(.3,.7,e))*(s?.5:1),Lt=ht(),Yt=ht();Lt.p.set(.42+o[1]*.08,oe.y-.05+o[2]*.12,.12-T*.15),Yt.p.set(-.42-o[3]*.08,oe.y-.08+o[4]*.12,.1-T*.15),Zt("L",w(.7,.3,.2),w(.2,.2,-.9),Lt.q),Zt("R",w(-.7,.3,.2),w(-.2,.2,-.9),Yt.q),Lt.pole.set(.3,-.8,-.4).normalize(),Yt.pole.set(-.3,-.8,-.4).normalize(),Bt(jt,Lt,Ee),Bt(Nt,Yt,Ee);let Ft=ht(),It=ht();if(i==="back")Ft.p.set(.42+o[5]*.15,1+o[6]*.45,-.02),It.p.set(-.38-o[7]*.12,.8+o[8]*.35,-.02);else if(i==="front")Ft.p.set(.32+o[5]*.12,1.2+o[6]*.35,.06),It.p.set(-.3-o[7]*.1,.8+o[8]*.2,.06);else{let ot=h>0?Ft:It,zt=h>0?It:Ft;ot.p.set(.08*h,1.3+o[5]*.15,.3),zt.p.set(-.04*h,1+o[6]*.1,.3)}Zt("L",w(.4,-.4,.2).addScaledVector(ee,.2),pt,Ft.q),Zt("R",w(-.4,-.4,.2).addScaledVector(ee,.2),pt,It.q),Ft.pole.set(1,0,0).addScaledVector(pt,.6).normalize(),It.pole.set(-1,0,0).addScaledVector(pt,.6).normalize();let qe=ct(.3,m+.15,e);Bt(jt,Ft,qe),Bt(Nt,It,qe),this.hands[0]=jt,this.hands[1]=Nt,this.leftGripW=0;let ye=o[0]<.5?1:-1,ge=H*(s?.7:.3),ue=i==="front"?X(-.25,1.15*ye,.2*ye):i==="back"?X(-.15,.75*ye,.25*ye):X(.15,.2*h,.35*h);this.lookQ.copy(this.mq[y.spine3]).multiply(X(-ge*T,0,ge*x*.6));let Me=this.mq[y.spine3].clone().multiply(ue);this.lookQ.slerp(Me,ct(.15,m+.2,e)),this.solveAll(),this.groundClamp(g),this.projectToGround(R,1-E+E*R),this.solveAll(),this.groundClamp(g,!0),this.dropWeapon(e,t,M)}static PROBES=[[y.hips,.1,w(0,-.04,-.03)],[y.hips,.1,w(0,-.02,.03)],[y.spine1,.115,w()],[y.spine2,.12,w()],[y.spine3,.125,w(0,.04,0)],[y.head,.11,w(0,.1,.02)],[y.armL,.065,w()],[y.armR,.065,w()],[y.thighL,.09,w(0,-.15,.01)],[y.thighR,.09,w(0,-.15,.01)],[y.calfL,.06,w()],[y.calfR,.06,w()]];groundClamp(t,o=!1){let e=1/0,s=w();for(let[c,a,i]of n.PROBES)s.copy(i).applyQuaternion(this.mq[c]).add(this.mp[c]).applyQuaternion(this.rootQ).add(this.rootP),e=Math.min(e,s.y-a);let r=e<0?-e:o?0:-e*t;this.rootP.y+=r}projectToGround(t,o){let e=this.rootQ.clone().invert(),s=[[this.hands[0],.035,t],[this.hands[1],.035,t],[this.feet[0],u0.ankleHeight,o],[this.feet[1],u0.ankleHeight,o]];for(let[r,c,a]of s){if(a<=0)continue;let i=r.p.clone().applyQuaternion(this.rootQ).add(this.rootP);i.y=i.y>c?O(i.y,c,a):c,r.p.copy(i.sub(this.rootP).applyQuaternion(e))}}dropWeapon(t,o,e){let s=this.weapon;if(s.inHand=!1,s.visible=o.def.geometry!==null&&o.cls!=="knife",!s.visible)return;let r=this.rnd,c=w(-.1,1.36,.32),a=e.clone().multiplyScalar(.8).add(w(-.3+r[2]*.3,.4,.25)),i=9.8,u=(a.y+Math.sqrt(a.y*a.y+2*i*(c.y-.03)))/i,h=Math.min(t,u);s.pos.set(c.x+a.x*h,c.y+a.y*h-.5*i*h*h,c.z+a.z*h),t>u&&s.pos.addScaledVector(w(a.x,0,a.z),.12*(1-Math.exp(-(t-u)*6)));let d=X(0,(r[3]-.5)*3,(r[4]<.5?1:-1)*Math.PI/2);s.quat.identity().slerp(d,ct(0,u,t))}};import*as V from"three";import{RoundedBoxGeometry as Ws}from"three/addons/geometries/RoundedBoxGeometry.js";import*as m0 from"three";var q0=.01,G0=22,In=.32,No=q0*1.8,Qo=(()=>{let n=new Float64Array(G0*3),t=Math.PI*(3-Math.sqrt(5));for(let o=0;o<G0;o++){let e=Math.sqrt((o+.5)/G0),s=o*t;n[o*3]=e*Math.cos(s),n[o*3+1]=e*Math.sin(s),n[o*3+2]=Math.sqrt(Math.max(0,1-e*e))}return n})(),Fn=(()=>{let n=[];for(let t=0;t<In;t+=q0*.6+t*.1)n.push(t);return Float64Array.from(n)})();function p0(n,t=1){let o=n.getAttribute("position"),e=n.getAttribute("normal"),s=n.getIndex();if(!s)throw new Error("bakeAO: indexed geometry expected");n.computeBoundingBox();let r=n.boundingBox.clone().expandByScalar(q0*2),c=1/q0,a=Math.ceil((r.max.x-r.min.x)*c),i=Math.ceil((r.max.y-r.min.y)*c),l=Math.ceil((r.max.z-r.min.z)*c),u=new Uint8Array(a*i*l),h=r.min.x,d=r.min.y,m=r.min.z,p=new m0.Vector3,b=new m0.Vector3,f=new m0.Vector3;for(let v=0;v<s.count;v+=3){p.fromBufferAttribute(o,s.getX(v)),b.fromBufferAttribute(o,s.getX(v+1)),f.fromBufferAttribute(o,s.getX(v+2));let L=Math.max(p.distanceTo(b),b.distanceTo(f),f.distanceTo(p)),z=Math.max(1,Math.ceil(L/(q0*.5)));for(let H=0;H<=z;H++)for(let x=0;x<=z-H;x++){let T=H/z,A=x/z,S=1-T-A,q=(p.x*S+b.x*T+f.x*A-h)*c|0,j=(p.y*S+b.y*T+f.y*A-d)*c|0,G=(p.z*S+b.z*T+f.z*A-m)*c|0;u[(G*i+j)*a+q]=1}}let g=new Float32Array(o.count),R=new Map,E=(v,L)=>Math.round((v-L)*1e4),M=v=>Math.round(v*1.5+1.5);for(let v=0;v<o.count;v++){let L=o.getX(v),z=o.getY(v),H=o.getZ(v),x=e.getX(v),T=e.getY(v),A=e.getZ(v),S=Math.hypot(x,T,A)||1;x/=S,T/=S,A/=S;let q=((E(L,h)*32768+E(z,d))*16384+E(H,m))*64+M(x)*16+M(T)*4+M(A),j=R.get(q);if(j!==void 0){g[v]=j;continue}let G,K,B;Math.abs(x)<.9?(G=0,K=A,B=-T):(G=-A,K=0,B=x);let Y=Math.hypot(G,K,B);G/=Y,K/=Y,B/=Y;let Rt=T*B-A*K,Ut=A*G-x*B,ee=x*K-T*G,pt=(L+x*No-h)*c,oe=(z+T*No-d)*c,jt=(H+A*No-m)*c,Nt=0;for(let Lt=0;Lt<G0;Lt++){let Yt=Qo[Lt*3],Ft=Qo[Lt*3+1],It=Qo[Lt*3+2],qe=(G*Yt+Rt*Ft+x*It)*c,ye=(K*Yt+Ut*Ft+T*It)*c,ge=(B*Yt+ee*Ft+A*It)*c;for(let ue=0;ue<Fn.length;ue++){let Me=Fn[ue],ot=pt+qe*Me,zt=oe+ye*Me,yt=jt+ge*Me;if(ot<0||zt<0||yt<0||ot>=a||zt>=i||yt>=l)break;if(u[((yt|0)*i+(zt|0))*a+(ot|0)]){let D=1-Me/In;Nt+=D*D*(3-2*D);break}}}let Ee=1-Math.min(1,t*(Nt/G0)*1.25);R.set(q,Ee),g[v]=Ee}let P=new Float32Array(o.count),C=new Uint16Array(o.count);for(let v=0;v<2;v++){P.fill(0),C.fill(0);for(let L=0;L<s.count;L+=3){let z=s.getX(L),H=s.getX(L+1),x=s.getX(L+2);P[z]+=g[H]+g[x],P[H]+=g[z]+g[x],P[x]+=g[z]+g[H],C[z]+=2,C[H]+=2,C[x]+=2}for(let L=0;L<o.count;L++)C[L]&&(g[L]=.5*g[L]+.5*P[L]/C[L])}n.setAttribute("ao",new m0.Float32BufferAttribute(g,1))}import*as ut from"three";var W={skin:0,fabric:1,gear:2,hard:3,camo:4},io=5,Oe=new ut.Vector3,Ue=new ut.Vector3,Bn=new ut.Vector3,_s=new ut.Vector3,je=class{pos=[];nrm=[];uv=[];col=[];pbr=[];si=[];sw=[];idx=Array.from({length:io},()=>[]);mirror=!1;transform=null;get vertexCount(){return this.pos.length/3}vertex(t,o,e,s,r,c){let a=Oe.copy(t),i=Ue.copy(o);this.transform&&(a.applyMatrix4(this.transform),i.transformDirection(this.transform));let l=typeof c=="function"?c(a.clone()):c;this.mirror&&(a.x=-a.x,i.x=-i.x),this.pos.push(a.x,a.y,a.z),this.nrm.push(i.x,i.y,i.z),this.uv.push(e,s),this.col.push(r.color.r,r.color.g,r.color.b),this.pbr.push(r.rough??1,r.metal??0);let u=l.map(([p,b])=>[this.mirror?Do[p]:p,b]).filter(p=>p[1]>1e-4).sort((p,b)=>b[1]-p[1]),h=[];for(let p of u){let b=h.find(f=>f[0]===p[0]);b?b[1]+=p[1]:h.push([p[0],p[1]])}h.sort((p,b)=>b[1]-p[1]);let d=h.slice(0,4),m=d.reduce((p,b)=>p+b[1],0)||1;for(let p=0;p<4;p++)this.si.push(d[p]?.[0]??0),this.sw.push(d[p]?d[p][1]/m:0);return this.pos.length/3-1}tri(t,o,e,s){this.mirror!==(this.transform?this.transform.determinant()<0:!1)?this.idx[t].push(o,s,e):this.idx[t].push(o,e,s)}grid(t){let o=t.u,e=t.v,s=o+1,r=[];for(let b=0;b<=e;b++)for(let f=0;f<=o;f++)r.push(t.fn(t.wrapU&&f===o?0:f/o,b/e,new ut.Vector3));let c=[],a=.001;for(let b=0;b<=e;b++)for(let f=0;f<=o;f++){let g=f/o,R=Math.min(1-2*a,Math.max(2*a,b/e)),E=g-a,M=g+a;t.wrapU?(M>=1&&(M-=1),E<0&&(E+=1)):(E=Math.max(0,E),M=Math.min(1,M)),t.fn(M,R,Oe),t.fn(E,R,Ue);let P=Bn.subVectors(Oe,Ue);t.fn(g,Math.min(1,R+a),Oe),t.fn(g,Math.max(0,R-a),Ue);let C=_s.subVectors(Oe,Ue),v=P.length(),L=C.length(),z=new ut.Vector3;if(v>1e-12&&L>1e-12&&z.crossVectors(P.divideScalar(v),C.divideScalar(L)),z.lengthSq()<1e-10&&(t.inside&&z.subVectors(r[b*s+f],t.inside(g,b/e,Oe)),z.lengthSq()<1e-14&&z.set(0,1,0)),z.normalize(),t.inside){let H=t.inside(g,b/e,Oe);Ue.subVectors(r[b*s+f],H).dot(z)<0&&z.negate()}c.push(z)}let i=t.uvScale?.[0],l=t.uvScale?.[1];if(i===void 0){i=0;for(let b=0;b<=e;b++){let f=0;for(let g=0;g<o;g++)f+=r[b*s+g].distanceTo(r[b*s+g+1]);i=Math.max(i,f)}}if(l===void 0){l=0;let b=Math.floor(o/2);for(let f=0;f<e;f++)l+=r[f*s+b].distanceTo(r[(f+1)*s+b])}let u=new Map,h=(b,f,g)=>typeof t.paint=="function"?t.paint(b,f,g):t.paint,d=(b,f,g)=>{let R=(f*s+b)*128+g.mat*16+(m.get(g)??0),E=u.get(R);if(E===void 0){let M=r[f*s+b],P=t.tint?t.tint(b/o,f/e,M):1,C=P===1?g:{...g,color:g.color.clone().multiplyScalar(P)};E=this.vertex(M,c[f*s+b],b/o*i,f/e*l,C,t.weights),u.set(R,E)}return E},m=new Map,p=new ut.Vector3;for(let b=0;b<e;b++)for(let f=0;f<o;f++){p.copy(r[b*s+f]).add(r[(b+1)*s+f+1]).multiplyScalar(.5);let g=h((f+.5)/o,(b+.5)/e,p);if(!g)continue;m.has(g)||m.set(g,m.size%16);let R=d(f,b,g),E=d(f+1,b,g),M=d(f,b+1,g),P=d(f+1,b+1,g),C=r[b*s+f],v=r[b*s+f+1],L=r[(b+1)*s+f],z=Oe.subVectors(v,C).cross(Ue.subVectors(L,C)),H=Bn.copy(c[b*s+f]).add(c[(b+1)*s+f+1]);if(z.lengthSq()<1e-16){let x=r[(b+1)*s+f+1];z.subVectors(v,x).cross(Ue.subVectors(L,x)).negate()}z.dot(H)>=0?(this.tri(g.mat,R,E,P),this.tri(g.mat,R,P,M)):(this.tri(g.mat,R,P,E),this.tri(g.mat,R,M,P))}}geometry(t,o,e,s,r=1){let c=t.getAttribute("position"),a=t.getAttribute("normal"),i=o?new ut.Matrix3().getNormalMatrix(o):null,l=[],u=new ut.Vector3,h=new ut.Vector3;for(let p=0;p<c.count;p++){u.fromBufferAttribute(c,p),h.fromBufferAttribute(a,p),o&&(u.applyMatrix4(o),h.applyMatrix3(i).normalize());let b=Math.abs(h.x),f=Math.abs(h.y),g=Math.abs(h.z),R,E;f>=b&&f>=g?(R=u.x,E=u.z):b>=g?(R=u.z,E=u.y):(R=u.x,E=u.y),l.push(this.vertex(u,h,R*r,E*r,e,s))}let d=o?o.determinant()<0:!1,m=(p,b,f)=>d?this.tri(e.mat,l[p],l[f],l[b]):this.tri(e.mat,l[p],l[b],l[f]);if(t.index)for(let p=0;p<t.index.count;p+=3)m(t.index.getX(p),t.index.getX(p+1),t.index.getX(p+2));else for(let p=0;p<c.count;p+=3)m(p,p+1,p+2)}build(){let t=new ut.BufferGeometry;t.setAttribute("position",new ut.Float32BufferAttribute(this.pos,3)),t.setAttribute("normal",new ut.Float32BufferAttribute(this.nrm,3)),t.setAttribute("uv",new ut.Float32BufferAttribute(this.uv,2)),t.setAttribute("color",new ut.Float32BufferAttribute(this.col,3)),t.setAttribute("pbr",new ut.Float32BufferAttribute(this.pbr,2)),t.setAttribute("skinIndex",new ut.Uint16BufferAttribute(this.si,4)),t.setAttribute("skinWeight",new ut.Float32BufferAttribute(this.sw,4)),t.setAttribute("ao",new ut.Float32BufferAttribute(new Float32Array(this.pos.length/3).fill(1),1));let o=[];for(let e=0;e<io;e++){this.idx[e].length&&t.addGroup(o.length,this.idx[e].length,e);for(let s of this.idx[e])o.push(s)}return t.setIndex(o),t.computeBoundingSphere(),t}get triangleCount(){return this.idx.reduce((t,o)=>t+o.length/3,0)}},tt=(n,t,o)=>{let e=Math.min(1,Math.max(0,(o-n)/(t-n)));return e*e*(3-2*e)};function _n(n,t){let o=n.slice(1).map((c,a)=>c.distanceTo(n[a])),e=[0];for(let c of o)e.push(e[e.length-1]+c);let s=new ut.Vector3,r=new ut.Vector3;return c=>{let a=1/0,i=0;for(let l=0;l<o.length;l++){s.subVectors(n[l+1],n[l]);let u=Math.max(l===0?-1:0,Math.min(l===o.length-1?2:1,r.subVectors(c,n[l]).dot(s)/(o[l]*o[l]))),h=Math.max(0,Math.min(1,u)),d=r.copy(n[l]).addScaledVector(s,h).distanceToSquared(c);d<a-1e-9&&(a=d,i=e[l]+u*o[l])}return d0(t,i)}}function d0(n,t){if(t<=n[0].s)return[[n[0].bone,1]];for(let o=0;o<n.length-1;o++){let e=n[o],s=n[o+1];if(t<=s.s){if(e.bone===s.bone)return[[e.bone,1]];let r=tt(e.s,s.s,t);return[[e.bone,1-r],[s.bone,r]]}}return[[n[n.length-1].bone,1]]}var At=gt,xe=n=>{let t=d0([{s:.99,bone:y.hips},{s:1.09,bone:y.spine1},{s:1.13,bone:y.spine1},{s:1.22,bone:y.spine2},{s:1.25,bone:y.spine2},{s:1.34,bone:y.spine3},{s:1.47,bone:y.spine3},{s:1.55,bone:y.neck}],n.y),o=Math.abs(n.x),e=n.x>0,s=t.slice(),r=tt(.06,.17,o)*tt(1.36,1.46,n.y)*.55,c=tt(.15,.23,o)*tt(1.3,1.42,n.y)*.3,a=tt(.97,.86,n.y)*tt(.02,.1,o)*.65,i=1-r-c-a;for(let l of s)l[1]*=Math.max(0,i);return r>0&&s.push([e?y.clavL:y.clavR,r]),c>0&&s.push([e?y.armL:y.armR,c]),a>0&&s.push([e?y.thighL:y.thighR,a]),s},Ds=[At[y.clavL],At[y.armL],At[y.foreL],At[y.handL],At[y.handL].clone().add(new ut.Vector3(.13,-.13,0))],Ko=At[y.clavL].distanceTo(At[y.armL]),Xo=Ko+At[y.armL].distanceTo(At[y.foreL]),qn=Xo+At[y.foreL].distanceTo(At[y.handL]),co=_n(Ds,[{s:Ko-.07,bone:y.clavL},{s:Ko+.03,bone:y.armL},{s:Xo-.05,bone:y.armL},{s:Xo+.05,bone:y.foreL},{s:qn-.035,bone:y.foreL},{s:qn+.02,bone:y.handL}]),Yo=[At[y.hips].clone().setX(At[y.thighL].x),At[y.thighL],At[y.calfL],At[y.footL],At[y.footL].clone().add(new ut.Vector3(0,-.06,.15))],Zo=Yo[0].distanceTo(Yo[1]),$o=Zo+At[y.thighL].distanceTo(At[y.calfL]),Gn=$o+At[y.calfL].distanceTo(At[y.footL]),Re=_n(Yo,[{s:Zo-.02,bone:y.hips},{s:Zo+.1,bone:y.thighL},{s:$o-.06,bone:y.thighL},{s:$o+.05,bone:y.calfL},{s:Gn-.04,bone:y.calfL},{s:Gn+.01,bone:y.footL}]),lo=n=>d0([{s:1.47,bone:y.spine3},{s:1.52,bone:y.neck},{s:1.555,bone:y.neck},{s:1.6,bone:y.head}],n.y),Jo=n=>[[n,1]];var Os={T:{side:"T",skin:"#c99a78",hair:"#2b2119",top:"#8a7556",topCut:"jacket",pants:"#4a5466",pantsCut:"jeans",camo:!1,bulk:0,gear:"#6b5338",gear2:"#57432d",boots:"#4a3626",gloves:"none",gloveColor:"#222",head:"balaclava",headColor:"#1d1d1c",maskColor:"#1d1d1c",eyewear:"none",earpro:!1,kneepads:!1,torsoGear:"rig",patch:null},CT:{side:"CT",skin:"#c99a78",hair:"#2b2119",top:"#3a4456",topCut:"shirt",pants:"#384255",pantsCut:"cargo",camo:!0,bulk:.013,gear:"#262d3a",gear2:"#1e2430",boots:"#1b1b1d",gloves:"full",gloveColor:"#26272a",head:"helmet",headColor:"#2c3442",maskColor:"#1b1c1f",eyewear:"glasses",earpro:!0,kneepads:!0,torsoGear:"carrier",patch:"#5d6470"}};function D0(n){return Os[n]}function Se(n){return t=>{if(t<=n[0][0])return n[0][1];let o=n.length;if(t>=n[o-1][0])return n[o-1][1];let e=0;for(;t>n[e+1][0];)e++;let s=n[e][0],r=n[e+1][0],c=(t-s)/(r-s),a=n[Math.max(0,e-1)][1],i=n[e][1],l=n[e+1][1],u=n[Math.min(o-1,e+2)][1],h=c*c,d=h*c;return .5*(2*i+(-a+l)*c+(2*a-5*i+4*l-u)*h+(-a+3*i-3*l+u)*d)}}function uo(n,t){let o=Math.sin(n),e=Math.cos(n);return[Math.sign(o)*Math.pow(Math.abs(o),2/t),Math.sign(e)*Math.pow(Math.abs(e),2/t)]}var Ht=n=>Math.exp(-n*n);function Ve(n,t,o,e=0){let s=1.5*Math.sin(t+e)+.7*Math.sin(2*t+1.7*e)+.35*Math.sin(3*t-e),r=Math.sin(2*Math.PI*n/o+s);return r>0?1-2*(1-r)**2:r}var Us=(n,t=1)=>new V.Color(n).multiplyScalar(t),at=(n,t,o=1,e=0,s=1)=>({mat:n,color:Us(t,s),rough:o,metal:e}),js=new V.Matrix4,Ns=new V.Quaternion,Qs=new V.Euler,Ks=new V.Vector3(1,1,1);function nt(n,t,o,e=0,s=0,r=0){return js.clone().compose(new V.Vector3(n,t,o),Ns.setFromEuler(Qs.set(e,s,r,"YXZ")),Ks)}function dt(n,t,o,e,s,r,c,a,i=1){let l=new Ws(t,o,e,i,Math.min(s,t/2-1e-4,o/2-1e-4,e/2-1e-4));n.geometry(l,r,c,a),l.dispose()}function en(n,t,o,e,s,r,c,a,i=!1){let l=new V.CylinderGeometry(o,t,e,s,1,i);n.geometry(l,r,c,a),l.dispose()}function f0(n,t,o,e,s,r,c,a=10){let i=new V.SphereGeometry(1,a,Math.max(4,Math.round(a*.7)));i.scale(t,o,e),n.geometry(i,s,r,c),i.dispose()}function Ke(n,t,o,e,s,r,c,a=12,i=!1){let l=new V.CatmullRomCurve3(t,i),u=h=>{let d=l.getPointAt(h),m=l.getTangentAt(h),p=new V.Vector3().crossVectors(m,s).normalize(),b=new V.Vector3().crossVectors(p,m).normalize();return{c:d,side:p,nrm:b}};n.grid({u:8,v:a,wrapU:!0,fn:(h,d,m)=>{let p=u(i&&d>=1?0:d),[b,f]=uo(h*Math.PI*2,6);return m.copy(p.c).addScaledVector(p.side,b*o*.5).addScaledVector(p.nrm,f*e*.5)},inside:(h,d,m)=>m.copy(l.getPointAt(i&&d>=1?0:d)),paint:r,weights:c})}function Xe(n,t,o,e,s,r,c,a,i,l,u=1){let h=new V.Vector3().crossVectors(c,a);dt(n,t,o,e,s,new V.Matrix4().makeBasis(c,a,h).setPosition(r),i,l,u)}var Ne=.83,ho=1.555,Xs=Se([[.83,.03],[.86,.125],[.9,.168],[.95,.178],[1,.171],[1.07,.16],[1.15,.166],[1.25,.181],[1.34,.192],[1.41,.193],[1.46,.181],[1.5,.154],[1.53,.114],[1.555,.074]]),on=Se([[.83,.03],[.86,.074],[.9,.097],[.97,.104],[1.05,.099],[1.15,.106],[1.25,.121],[1.32,.127],[1.4,.113],[1.46,.088],[1.5,.068],[1.555,.054]]),nn=Se([[.83,.03],[.86,.097],[.9,.125],[.95,.125],[1.02,.108],[1.1,.1],[1.2,.106],[1.3,.112],[1.4,.108],[1.46,.098],[1.5,.078],[1.555,.056]]),b0=Se([[.83,0],[1,-.008],[1.3,-.012],[1.5,-.022],[1.555,-.026]]),Ys=Se([[.83,2],[.9,2.3],[1.2,2.5],[1.45,2.4],[1.555,2]]);function Qt(n,t,o,e=new V.Vector3){let s=Ys(n),[r,c]=uo(t,s),a=c>=0?on(n):nn(n);return e.set(r*(Xs(n)+o),n,b0(n)+c*(a+o))}var o0=gt[y.head].clone().add(new V.Vector3(0,.094,.024)),_0=new V.Vector3(.079,.114,.1);function $t(n,t,o,e,s=new V.Vector3){let r=_0.x,c=_0.y,a=_0.z,i=tt(-.15,-.85,t);r*=1-.15*i,o<0?a*=1+.06*tt(-.2,.5,t)-.25*i:a*=1-.06*i;let l=n*r,u=t*c,h=o*a;if(o>0){let m=o;h+=.024*Ht(n/.13)*Ht((t+.2)/.2)*m**3,h+=.008*Ht((t-.21)/.08)*tt(.5,.9,m),h-=.01*Ht((Math.abs(n)-.32)/.13)*Ht((t-.07)/.09)*tt(.5,.9,m),l+=Math.sign(n)*.007*Ht((t+.05)/.15)*tt(.3,.6,m)*tt(.9,.5,m),h+=.011*Ht((t+.82)/.12)*Ht(n/.3)}u-=.012*tt(.6,1,t);let d=Math.hypot(l,u,h)||1;return s.set(o0.x+l+l/d*e,o0.y+u+u/d*e,o0.z+h+h/d*e)}function Dn(n,t){let o=n*Math.PI*2,e=t*Math.PI;return[Math.sin(e)*Math.sin(o),Math.cos(e),Math.sin(e)*Math.cos(o)]}function Wn(n,t,o,e){let s=new V.Vector3(n,t,o).normalize(),r=new V.Vector3(0,1,0).cross(s);r.lengthSq()<1e-6&&r.set(1,0,0),r.normalize();let c=new V.Vector3().crossVectors(s,r),a=.01,i=d=>$t(d.x,d.y,d.z,e),l=i(s.clone().addScaledVector(r,a).normalize()).sub(i(s.clone().addScaledVector(r,-a).normalize())),u=i(s.clone().addScaledVector(c,a).normalize()).sub(i(s.clone().addScaledVector(c,-a).normalize())),h=new V.Vector3().crossVectors(l,u).normalize();return h.dot(s)<0?h.negate():h}function On(n,t,o=new V.Vector3){let e=t*Math.PI*2,s=5,r=(n.y1-n.y0)/2,c=Math.sin(e),a=Math.cos(e),i=Math.pow(Math.abs(c/n.x)**s+Math.abs(a/r)**s,-1/s),l=c*i,u=(n.y0+n.y1)/2+a*i;return o.set(l,u,Math.sqrt(Math.max(0,1-l*l-u*u))).normalize()}var mo=new Map;function W0(n){let t=mo.get(n.side);return t||(t=Zs(n),mo.set(n.side,t)),t}function Un(){mo.forEach(n=>n.dispose()),mo.clear()}function Zs(n){let t=new je,o=n.camo?W.camo:W.fabric,e={skin:at(W.skin,n.skin,1),top:at(o,n.top),topDark:at(o,n.top,1,0,.78),pants:at(o,n.pants),pantsDark:at(o,n.pants,1,0,.8),gear:at(W.gear,n.gear),gear2:at(W.gear,n.gear2),gearDark:at(W.gear,n.gear,1,0,.7),boot:at(W.hard,n.boots,.8),bootDark:at(W.hard,n.boots,.9,0,.6),sole:at(W.hard,"#141312",1),glove:at(W.hard,n.gloveColor,1),hair:at(W.fabric,n.hair,.9),lens:at(W.hard,"#101317",.1,.25),blackHard:at(W.hard,"#141516",.7),metal:at(W.hard,"#5a5d62",.45,.8),headwear:at(W.fabric,n.maskColor),shell:at(W.hard,n.headColor,.75),patch:n.patch?at(W.gear,n.patch,.9):null};$s(t,n,e);let s=n.torsoGear==="carrier";for(let c of[!1,!0])t.mirror=c,Js(t,n,e),er(t,n,e.skin,e.glove),sr(t,n,e,!(c&&s)),ir(t,e,n.pantsCut==="cargo"),n.kneepads&&rr(t,n,e),c&&s&&ar(t,n,e);t.mirror=!1,s?(cr(t,n,e),lr(t,n,e)):hr(t,e),ur(t,n,e);let r=t.build();return p0(r),r}function $s(n,t,o){let e=t.topCut==="jacket",s=t.bulk,r=(c,a)=>{if(c<1)return s;let i=e?0:.006*Ht((c-1.03)/.035);return s+i+.0022*Ve(c,a,.032,1.1)*Ht((c-1.07)/.07)};n.grid({u:28,v:34,wrapU:!0,fn:(c,a,i)=>{let l=Ne+(ho-Ne)*a,u=c*Math.PI*2;return Qt(l,u,r(l,u),i)},inside:(c,a,i)=>i.set(0,Ne+(ho-Ne)*a,b0(Ne+(ho-Ne)*a)),paint:(c,a,i)=>i.y<.985?o.pants:o.top,tint:(c,a)=>{let i=Ne+(ho-Ne)*a;return 1+8*(r(i,c*Math.PI*2)-s)-(i>.99&&i<1.01?.12:0)},weights:xe}),n.grid({u:28,v:2,wrapU:!0,fn:(c,a,i)=>Qt(.962+.042*a,c*Math.PI*2,s+.008+.003*Math.sin(a*Math.PI),i),inside:(c,a,i)=>i.set(0,.962+.042*a,0),paint:at(W.gear,t.side==="T"?"#3a2c20":"#1a1a1b"),weights:xe});{let c=Qt(.983,0,s+.013);dt(n,.05,.036,.012,.004,nt(c.x,c.y,c.z),o.metal,xe)}if(e){let i=u=>s+.001+.022*tt(1.2,1,u);n.grid({u:28,v:10,wrapU:!0,fn:(u,h,d)=>{let m=u*Math.PI*2;if(h>.95)return Qt(.94+.012,m,i(.94)-.008,d);let p=1.2+(.94-1.2)*h/.95;return Qt(p,m,i(p)+.0025*Ve(p,m,.045,2.3)*tt(1.15,1,p),d)},inside:(u,h,d)=>d.set(0,1.2+(.94-1.2)*h,-.01),paint:o.top,weights:xe});for(let u of[1,-1]){let h=Qt(1.02,.7*u,i(1.02)+.004);dt(n,.075,.016,.008,.003,nt(h.x,h.y,h.z,-.05,.62*u,.55*u),o.topDark,xe)}let l=[];for(let u=.94+.012;u<1.49;u+=.04)l.push(Qt(u,0,(u<1.2?i(u):s+.001)+.003));Ke(n,l,.012,.004,new V.Vector3(0,0,1),o.topDark,xe,24)}{let c=e?.065:.045;n.grid({u:24,v:3,wrapU:!0,fn:(a,i,l)=>{let u=a*Math.PI*2,h=Math.max(0,Math.cos(u)),d=Math.min(i,2/3)*1.5,m=1.488+c*d-(e?.035:.02)*h*(1-d)-.008*h*d,p=.078+.5*s-.004*d+(e?.008*d:0);return i>.7&&(p-=.007),l.set(Math.sin(u)*p,m+.02*tt(.2,-1,Math.cos(u)),-.024+Math.cos(u)*p*1.03)},inside:(a,i,l)=>l.set(0,1.5+.04*i,-.02),paint:o.topDark,weights:a=>lo(a.clone().setY(a.y-.02))})}n.grid({u:18,v:6,wrapU:!0,fn:(c,a,i)=>{let l=1.47+.15*a,u=c*Math.PI*2,h=.068+.3*s-.004*a+.02*(1-a)**2,d=.022*tt(.3,1,a)*Math.max(0,Math.cos(u));return i.set(Math.sin(u)*h,l,-.022+.014*a+Math.cos(u)*h*(Math.cos(u)>0?.95:1.05)+d)},inside:(c,a,i)=>i.set(0,1.47+.15*a,-.02),paint:o.headwear,weights:lo})}function Js(n,t,o){let e=gt[y.armL],s=L0,r=new V.Vector3(0,0,1),c=new V.Vector3().crossVectors(r,s).normalize(),a=-.1,i=t0+C0+.005,l=Se([[-.1,0],[-.095,.03],[-.08,.045],[-.05,.054],[0,.058],[.05,.057],[.12,.051],[.2,.047],[.265,.043],[.29,.042],[.33,.045],[.41,.04],[.5,.032],[.55,.03]]),u=t0,h=.011+.6*t.bulk,d=(m,p)=>{if(m<-.08)return 0;let b=h+.006*Ht((m-u-.03)/.08)+.003*tt(.36,.46,m)-(h-.005)*tt(.505,.535,m),f=.0032*Ve(m,p,.042,.5)*Ht((m-u)/.075)+.0024*Ve(m,p,.03,2.1)*tt(.38,.46,m)*tt(.53,.5,m)+.0014*Ve(m,p,.07,4)*tt(0,.08,m)*tt(.25,.18,m);return b+f};if(n.grid({u:18,v:52,wrapU:!0,fn:(m,p,b)=>{let f=a+(i-a)*p,g=m*Math.PI*2,R=l(f)+d(f,g),E=.006*Math.exp(-(((f-.02)/.06)**2)),M=f>t0?.9:1,P=e.clone().addScaledVector(s,f).addScaledVector(c,E);return f<0&&P.addScaledVector(c,.9*f),b.copy(P).addScaledVector(r,Math.cos(g)*R*M).addScaledVector(c,Math.sin(g)*R)},inside:(m,p,b)=>{let f=a+(i-a)*p;return b.copy(e).addScaledVector(s,f),f<0?b.addScaledVector(c,.9*f):b},paint:(m,p)=>a+(i-a)*p>.505?o.topDark:o.top,tint:(m,p)=>{let b=a+(i-a)*p,f=d(b,m*Math.PI*2);return f>0?1+14*(f-h):1},weights:co}),o.patch){let p=e.clone().addScaledVector(s,.125).addScaledVector(c,l(.125)+d(.125,Math.PI/2)+.005);Xe(n,.078,.1,.012,.006,p,r,s,o.topDark,co,2),Xe(n,.06,.04,.004,.002,p.clone().addScaledVector(c,.007).addScaledVector(s,-.015),r,s,o.patch,co)}}function tr(){let n=no.L;return new V.Matrix4().makeBasis(n.along,n.back,n.thumb).setPosition(gt[y.handL])}function er(n,t,o,e){let s=gt[y.handL],r=no.L.along,c=m=>{let p=m.clone().sub(s).dot(r);return d0([{s:-.03,bone:y.foreL},{s:.012,bone:y.handL}],p)},a=t.gloves==="full",i=t.gloves==="none"?o:e,l=a?e:o;n.transform=tr(),dt(n,.092,.03,.08,.012,nt(.044,0,0),i,c,1),t.gloves!=="none"&&en(n,.034,.037,.05,12,nt(-.004,0,0,0,0,Math.PI/2),e,c,!0),a&&dt(n,.034,.008,.066,.004,nt(.07,.016,0),at(W.hard,"#2c2d30",.6),c,1);let u=new V.Vector3(.068,-.034,0),h=[{z:.027,len:.09,r:.0098},{z:.0085,len:.098,r:.0102},{z:-.0105,len:.093,r:.0098},{z:-.0285,len:.078,r:.0088}];for(let m of h){let p=new V.Vector3(.086,.003,m.z),b=p.clone().sub(u),f=Math.atan2(b.y,b.x),g=Math.hypot(b.x,b.y),R=.031,E=(z,H)=>{if(z<0)return H.set(p.x+z*.03,p.y-.004,m.z);let x=g+(R-g)*Math.min(1,z*1.5),T=f-z*m.len/((g+R)/2);return H.set(u.x+Math.cos(T)*x,u.y+Math.sin(T)*x,m.z)},M=new V.Vector3,P=new V.Vector3(0,0,1),C=new V.Vector3,v=new V.Vector3,L=new V.Vector3;n.grid({u:6,v:7,wrapU:!0,fn:(z,H,x)=>{let T=-.35+1.35*H;E(T,v),E(T+.01,L),M.subVectors(L,v).normalize(),C.crossVectors(P,M).normalize();let A=z*Math.PI*2,S=T>.88?Math.sqrt(Math.max(0,1-((T-.88)/.12)**2)):1,q=m.r*(.35+.65*S);return T>.88&&v.addScaledVector(M,(T-.88)*.02),x.copy(v).addScaledVector(P,Math.cos(A)*q*1.08).addScaledVector(C,Math.sin(A)*q)},inside:(z,H,x)=>E(-.35+1.35*H,x),paint:l,weights:c})}let d=new V.CatmullRomCurve3([new V.Vector3(.008,-.004,.026),new V.Vector3(.032,-.012,.044),new V.Vector3(.056,-.03,.048),new V.Vector3(.074,-.05,.04),new V.Vector3(.082,-.062,.028)]);n.grid({u:6,v:6,wrapU:!0,fn:(m,p,b)=>{let f=d.getPointAt(p),g=d.getTangentAt(p),R=new V.Vector3().crossVectors(g,new V.Vector3(0,0,1)).normalize(),E=new V.Vector3().crossVectors(R,g).normalize(),M=p>.85?Math.sqrt(Math.max(0,1-((p-.85)/.15)**2)):1,P=(.0135-.003*p)*(.35+.65*M),C=m*Math.PI*2;return b.copy(f).addScaledVector(R,Math.cos(C)*P).addScaledVector(E,Math.sin(C)*P)},inside:(m,p,b)=>b.copy(d.getPointAt(p)),paint:l,weights:c}),n.transform=null}var sn=gt[y.thighL],E0=gt[y.calfL],Qe=gt[y.footL],Ye=sn.distanceTo(E0),or=E0.distanceTo(Qe),jn=Se([[-.13,0],[-.125,.03],[-.11,.06],[-.07,.086],[0,.1],[.1,.093],[.2,.083],[.32,.069],[.425,.06],[.47,.061],[.55,.065],[.65,.056],[.75,.045],[.84,.039]]),n0=(n,t)=>n<Ye?t.lerpVectors(sn,E0,n/Ye):t.lerpVectors(E0,Qe,Math.min(1.2,(n-Ye)/or)),nr=n=>(n<Ye?new V.Vector3().subVectors(E0,sn):new V.Vector3().subVectors(Qe,E0)).normalize();function fo(n){let t=nr(n),o=new V.Vector3(1,0,0),e=new V.Vector3().crossVectors(o,t).normalize().negate();return e.z<0&&e.negate(),o.crossVectors(t,e).normalize(),o.x<0&&o.negate(),{d:t,side:o,fwd:e}}var tn=n=>(n.pantsCut==="jeans"?.017:.024)+.5*n.bulk;function y0(n,t,o){let e=n.pantsCut==="jeans",s=jn(t)+(t>-.11?tn(n):0);return s+=.0026*Ve(t,o,.038,.7)*Ht((t-Ye)/.07)*(.6-.4*Math.cos(o)),s+=.0016*Ve(t,o,.09,2.2)*tt(-.05,.05,t)*tt(.3,.2,t),e?s+=.012*tt(.5,.8,t)+.003*Ve(t,o,.032,1.3)*tt(.62,.74,t):(s+=.01*Ht((t-Ye)/.09)+.016*Ht((t-.62)/.045)+.003*Ve(t,o,.03,3.1)*Ht((t-.62)/.05),s+=(.05-s)*tt(.655,.705,t)),s}function sr(n,t,o,e){let s=t.pantsCut==="jeans",r=-.13,c=s?.82:.73;if(n.grid({u:20,v:56,wrapU:!0,fn:(a,i,l)=>{let u=r+(c-r)*i,h=a*Math.PI*2,d=n0(u,new V.Vector3),{side:m,fwd:p}=fo(u),b=y0(t,u,h),f=.008*Math.exp(-(((u-.08)/.12)**2)),g=.008*Math.exp(-(((u-.12)/.15)**2))-.014*Math.exp(-(((u-.56)/.1)**2));return d.addScaledVector(m,f).addScaledVector(p,g),l.copy(d).addScaledVector(p,Math.cos(h)*b).addScaledVector(m,Math.sin(h)*b)},inside:(a,i,l)=>n0(r+(c-r)*i,l),paint:(a,i)=>r+(c-r)*i>c-.02&&s?o.pantsDark:o.pants,tint:(a,i)=>{let l=r+(c-r)*i,u=a*Math.PI*2,h=Math.abs(a-.25)<.01?.82:1,d=jn(l)+(l>-.11?tn(t):0);return h*(1+6*Math.max(-.01,Math.min(.01,y0(t,l,u)-d-(s?.012*tt(.5,.8,l):.01*Ht((l-Ye)/.09)))))},weights:Re}),!s&&e){let a=new V.Vector3(.198+tn(t)-.024,.68,.014);dt(n,.034,.15,.13,.014,nt(a.x,a.y,a.z,0,0,.04),o.pants,Re,2),dt(n,.038,.04,.136,.01,nt(a.x+.003,a.y+.06,a.z,0,0,.04),o.pantsDark,Re,1)}}function po(n,t,o,e,s,r){n.grid({u:18,v:2,wrapU:!0,fn:(c,a,i)=>{let l=c*Math.PI*2,u=o+(a-.5)*s,h=fo(u),d=y0(t,u,l)+e+.003*Math.sin(a*Math.PI);return n0(u,i).addScaledVector(h.fwd,Math.cos(l)*d).addScaledVector(h.side,Math.sin(l)*d)},inside:(c,a,i)=>n0(o+(a-.5)*s,i),paint:r,weights:Re})}function rr(n,t,o){let e=Ye+.01,s=n0(e,new V.Vector3),{fwd:r}=fo(e),c=s.clone().addScaledVector(r,y0(t,e,0)+.02),a=Re(c);dt(n,.1,.13,.045,.021,nt(c.x,c.y,c.z,-.06),o.blackHard,a,3),dt(n,.072,.042,.006,.003,nt(c.x,c.y+.015,c.z+.022,-.06),at(W.hard,"#2a2c30",.5),a,1),po(n,t,e-.05,.004,.02,o.gearDark),po(n,t,e+.05,.004,.02,o.gearDark)}function ar(n,t,o){let{side:s,fwd:r,d:c}=fo(.26),a=c.clone().negate(),i=n0(.26,new V.Vector3).addScaledVector(s,y0(t,.26,Math.PI/2)+.01),l=at(W.hard,"#1b1c1f",.6);Xe(n,.11,.18,.016,.006,i,r,a,o.gear2,Re,2);let u=i.clone().addScaledVector(s,.031).addScaledVector(a,-.012).addScaledVector(r,.006);Xe(n,.078,.15,.046,.014,u,r,a,l,Re,2);let h=.3,d=a.clone().multiplyScalar(Math.cos(h)).addScaledVector(r,-Math.sin(h)),m=r.clone().multiplyScalar(Math.cos(h)).addScaledVector(a,Math.sin(h));Xe(n,.034,.075,.028,.009,u.clone().addScaledVector(a,.1).addScaledVector(r,-.018),m,d,o.blackHard,Re,2),po(n,t,.26-.05,.006,.026,o.gearDark),po(n,t,.26+.055,.006,.026,o.gearDark);let p=b=>n0(b,new V.Vector3).addScaledVector(s,y0(t,b,Math.PI/2)+.008*Ht((b-.08)/.12)+.006);Ke(n,[Qt(1,1.45,t.bulk+.034),p(.04),p(.12),i.clone().addScaledVector(a,.085)],.036,.006,s,o.gearDark,Re,10)}function ir(n,t,o){let e=Qe.x+.004,s=Qe.z-.078,r=Qe.z+.232,c=p=>Math.pow(Math.max(0,1-Math.pow(Math.abs(2*p-1),3)),1/3),a=Se([[0,.044],[.25,.048],[.6,.055],[.85,.052],[1,.044]]),i=p=>a(p)*c(p),l=Se([[0,.095],[.12,.13],[.3,.145],[.5,.115],[.7,.088],[.9,.07],[1,.06]]),u=p=>d0([{s:.13,bone:y.footL},{s:.2,bone:y.calfL}],p.y),h=.03,d=p=>l(p)*(.35+.65*c(p));n.grid({u:18,v:16,wrapU:!0,fn:(p,b,f)=>{let g=s+(r-s)*b,R=p*Math.PI*2,[E,M]=uo(R,3),P=d(b);return f.set(e+E*i(b),h+P/2+M*P/2,g)},inside:(p,b,f)=>f.set(e,h+d(b)/2,s+(r-s)*b-.04*(2*b-1)),paint:(p,b)=>{let f=Math.cos(p*Math.PI*2);return b>.78&&f>-.2||b<.14&&f>-.6?t.bootDark:t.boot},tint:(p,b)=>{let f=p*Math.PI*2;return Math.cos(f)>.75&&b>.36&&b<.74?Math.sin(b*95)>.2?.55:.85:1},weights:u});let m=o?.25:.19;n.grid({u:18,v:7,wrapU:!0,fn:(p,b,f)=>{let g=Math.min(1,b/.86),R=.07+(m-.07)*g-(b>.86?.012:0),E=p*Math.PI*2,M=.056+.004*g+.006*tt(.75,1,g);return b>.86&&(M-=.01),f.set(e-.002+Math.sin(E)*M,R,Qe.z-.012+Math.cos(E)*M*1.08)},inside:(p,b,f)=>f.set(e,.07+(m-.07)*Math.min(1,b),Qe.z),paint:(p,b)=>b>.75?t.bootDark:t.boot,tint:(p,b)=>{let f=p*Math.PI*2;return Math.cos(f)>.8&&b<.75?Math.sin(b*40)>.2?.55:.85:1},weights:u}),n.grid({u:16,v:10,wrapU:!0,fn:(p,b,f)=>{let g=s-.007+(r-s+.014)*b,R=p*Math.PI*2,[E,M]=uo(R,6);return f.set(e+E*(i(b)+.007*c(b)),.016+M*.016,g)},inside:(p,b,f)=>f.set(e,.016,s+(r-s)*b),paint:t.sole,tint:p=>Math.abs(Math.cos(p*Math.PI*2))<.5?.75:1,weights:Jo(y.footL)})}function cr(n,t,o){let e=xe,s=t.bulk,r=i=>b0(i)+on(i)+s,c=i=>b0(i)-nn(i)-s;dt(n,.32,.32,.056,.022,nt(0,1.3,r(1.3)+.028,-.04),o.gear,e,2),dt(n,.32,.34,.056,.022,nt(0,1.3,c(1.3)-.028,.04),o.gear,e,2),n.grid({u:32,v:3,wrapU:!0,fn:(i,l,u)=>Qt(1.08+.19*l,i*Math.PI*2,s+.03+.008*Math.sin(l*Math.PI),u),inside:(i,l,u)=>u.set(0,1.08+.19*l,0),paint:o.gear,weights:e});for(let i of[1,-1]){let l=[new V.Vector3(.097*i,1.43,r(1.43)+.04),new V.Vector3(.108*i,1.51,.058),new V.Vector3(.113*i,1.555,-.02),new V.Vector3(.108*i,1.51,-.108),new V.Vector3(.097*i,1.43,c(1.43)-.04)];Ke(n,l,.078,.03,new V.Vector3(i,0,0),o.gear2,e,12)}let a=r(1.3)+.056+.026;for(let i of[-.09,0,.09])dt(n,.08,.13,.054,.013,nt(i,1.215,a,-.04),o.gear2,e,2),dt(n,.084,.034,.058,.008,nt(i,1.277,a+.002,-.04),o.gearDark,e,1),dt(n,.014,.026,.006,.003,nt(i,1.255,a+.031,-.04),o.blackHard,e,1);dt(n,.2,.09,.034,.012,nt(0,1.37,r(1.35)+.07,-.06),o.gear2,e,2),dt(n,.07,.04,.006,.004,nt(.04,1.375,r(1.35)+.089,-.06),at(W.hard,"#55585e",.9),e,1);for(let[i,l,u]of[[1.95,.066,.15],[-1.95,.086,.11]]){let h=Qt(1.18,i,s+.07);dt(n,l,u,.05,.014,nt(h.x,h.y,h.z,0,i),o.gear2,e,2)}{let i=Qt(1.3,1.95,s+.07);en(n,.006,.005,.17,6,nt(i.x,i.y+.05,i.z-.01),o.blackHard,e)}dt(n,.25,.3,.04,.016,nt(0,1.27,c(1.3)-.074,.05),o.gear2,e,2)}function lr(n,t,o){let e=xe,s=t.bulk;n.grid({u:32,v:3,wrapU:!0,fn:(c,a,i)=>Qt(.945+.07*a,c*Math.PI*2,s+.02+.008*Math.sin(a*Math.PI),i),inside:(c,a,i)=>i.set(0,.945+.07*a,0),paint:o.gear,weights:e});{let c=Qt(.98,0,s+.03);dt(n,.06,.042,.014,.004,nt(c.x,c.y,c.z),o.blackHard,e,1)}let r=(c,a,i,l,u)=>{let h=Qt(a,c,s+.028+u/2);dt(n,i,l,u,.012,nt(h.x,h.y,h.z,0,c),o.gear2,e,2)};r(1.1,.97,.07,.1,.045),r(1.75,.97,.06,.09,.04),r(Math.PI,.96,.17,.09,.05),r(-.8,.975,.06,.07,.034)}function hr(n,t){let o=xe,e=c=>b0(c)+on(c),s=c=>b0(c)-nn(c),r=e(1.19)+.02;dt(n,.34,.15,.03,.012,nt(0,1.19,r,-.03),t.gear,o,2);for(let c of[-.118,-.04,.04,.118])dt(n,.068,.14,.05,.012,nt(c,1.2,r+.037,-.03),t.gear2,o,2),dt(n,.072,.034,.054,.008,nt(c,1.263,r+.039,-.03),t.gearDark,o,1);for(let c of[1,-1]){dt(n,.052,.088,.042,.01,nt(.18*c,1.17,e(1.17)-.03,0,c*Math.PI/2.6),t.gear2,o,2);let a=[new V.Vector3(.12*c,1.26,r),new V.Vector3(.118*c,1.42,e(1.42)+.014),new V.Vector3(.112*c,1.535,-.02),new V.Vector3(.09*c,1.44,s(1.44)-.014),new V.Vector3(0,1.3,s(1.3)-.018),new V.Vector3(-.12*c,1.15,s(1.15)-.014)];Ke(n,a,.042,.009,new V.Vector3(c,0,0),t.gearDark,o,16)}n.grid({u:28,v:1,wrapU:!0,fn:(c,a,i)=>Qt(1.135+.03*a,c*Math.PI*2,.01,i),inside:(c,a,i)=>i.set(0,1.135+.03*a,0),paint:t.gearDark,weights:o})}function ur(n,t,o){let e=lo,s=Jo(y.head),r=t.head==="helmet",c=(i,l,u)=>Ht((Math.abs(i)-.33)/.13)*Ht((l-.06)/.09)*tt(.5,.9,u);n.grid({u:40,v:30,wrapU:!0,fn:(i,l,u)=>{let[h,d,m]=Dn(i,l);return $t(h,d,m,0,u)},inside:(i,l,u)=>u.copy(o0),paint:o.skin,tint:(i,l)=>{let[u,h,d]=Dn(i,l);return(1-.25*c(u,h,d))*.82},weights:e});for(let i of[1,-1]){let l=$t(.33*i,.06,.94,-.006),u=Wn(.33*i,.06,.94,0);f0(n,.0118,.0098,.0105,nt(l.x,l.y,l.z),at(W.hard,"#b8afa3",.3),s,8);let h=l.clone().addScaledVector(u,.0088).add(new V.Vector3(-.0012*i,6e-4,0));f0(n,.0056,.0056,.0026,nt(h.x,h.y,h.z,0,.32*i),at(W.hard,"#2a1d14",.12),s,8);let d=l.clone().addScaledVector(u,.004).add(new V.Vector3(0,.0072,0));f0(n,.0135,.0042,.0082,nt(d.x,d.y,d.z,.25,.3*i),at(W.skin,t.skin,1,0,.62),s,8);let m=$t(.33*i,.205,.92,0);f0(n,.018,.0034,.0045,nt(m.x,m.y,m.z,0,.3*i,-.08*i),o.hair,s,7)}{let l={x:.5,y0:-.13,y1:.255},u=new V.Vector3(0,(l.y0+l.y1)/2,1).normalize().negate(),h=new V.Vector3,d=new V.Vector3,m=(f,g,R)=>{On(l,f,d);let E=d.angleTo(u),M=h.crossVectors(d,u);return M.lengthSq()<1e-10?R.copy(u):(M.normalize(),R.copy(d).applyAxisAngle(M,E*g))},p=new V.Vector3;n.grid({u:56,v:26,wrapU:!0,fn:(f,g,R)=>(m(f,g,p),$t(p.x,p.y,p.z,.007+.0015*tt(.15,0,g),R)),inside:(f,g,R)=>R.copy(o0),paint:o.headwear,weights:e});let b=[];for(let f=0;f<32;f++)On(l,f/32,p),b.push($t(p.x,p.y,p.z,.007-.001));Ke(n,b,.009,.007,u.clone().negate(),at(W.fabric,t.maskColor,1,0,.85),s,36,!0)}let a=(i,l,u,h=new V.Vector3)=>$t(Math.sin(l)*Math.sin(i),Math.cos(l),Math.sin(l)*Math.cos(i),u,h);if(r){let i=m=>{let p=Math.abs(mr(m));return 1.1-.2*Ht((p-1.62)/.42)+.62*tt(1.95,2.75,p)},l=m=>.022+.006*Math.cos(m)**2+.012*tt(.6,1,Math.cos(m)),u=(m,p,b,f,g)=>n.grid({u:g,v:f,wrapU:!0,fn:(R,E,M)=>{let P=R*Math.PI*2,C=E*p(P);return a(P,C,m(C),M)},inside:(R,E,M)=>M.copy(o0),paint:b,weights:s});u(l,i,o.shell,16,56);let h=[];for(let m=0;m<64;m++){let p=m/64*Math.PI*2;h.push(a(p,i(p),l(i(p))-.004))}Ke(n,h,.014,.012,new V.Vector3(0,1,0),at(W.hard,t.headColor,.9,0,.6),s,96,!0);let d=(m,p,b)=>a(m,p,l(p)+b);for(let m of[1,-1]){let p=[];for(let b=0;b<=6;b++){let f=m*(.95+1.3*b/6);p.push(d(f,i(f)-.1,.003))}Ke(n,p,.02,.008,new V.Vector3(m,0,0),o.blackHard,s,14)}{let p=d(0,.7,.006),b=Wn(0,Math.cos(.7),Math.sin(.7),l(.7)),f=new V.Vector3(0,1,0).addScaledVector(b,-b.y).normalize();Xe(n,.052,.034,.008,.003,p,new V.Vector3(1,0,0),f,o.blackHard,s,1),Xe(n,.02,.012,.014,.003,p.clone().addScaledVector(b,.008).addScaledVector(f,-.008),new V.Vector3(1,0,0),f,o.metal,s,1);let g=d(Math.PI,1.45,.016);dt(n,.07,.05,.03,.01,nt(g.x,g.y,g.z,-.2),at(W.gear,t.headColor,1,0,.85),s,2)}u(m=>l(m)+.0025,()=>.42,at(W.gear,t.headColor,1,0,.82),3,24);for(let m of[1,-1]){let p=[d(m*1.45,i(m*1.45)-.02,-.022),$t(.92*m,-.45,.1,.014),$t(.55*m,-.84,.28,.013),$t(0,-.93,.35,.013)];Ke(n,p,.014,.004,new V.Vector3(m,0,0),o.blackHard,s,10)}}if(t.earpro)for(let i of[1,-1]){let l=$t(i,-.04,-.06,.03);f0(n,.022,.044,.037,nt(l.x,l.y,l.z),o.blackHard,s,14),f0(n,.016,.038,.031,nt(l.x+.008*i,l.y,l.z),at(W.hard,"#2a2c2f",.55),s,12);let u=l.clone().add(new V.Vector3(-.004*i,.04,.004)),d=$t(.84*i,.5,-.06,r?.036:.012).clone().sub(u);Xe(n,.016,d.length()+.01,.007,.003,u.clone().addScaledVector(d,.5),new V.Vector3(0,0,1),d.normalize(),o.blackHard,s,1),i===1&&en(n,.003,.003,.07,5,nt(l.x+.004,l.y-.02,l.z+.06,1.2,0,.3),o.blackHard,s)}if(t.eyewear==="glasses"){for(let d of[0,1]){let m=d?0:.003;n.grid({u:18,v:3,fn:(p,b,f)=>{let g=(p-.5)*2*.95*(1+m*4),R=.4*Ht(g/.22)*(1-b),E=(.036+2*m)*(1-.25*Math.abs(p-.5)*2)*(1-R),M=.075+(b-.5)*(E/_0.y)+R*.25*(.036/_0.y);return $t(Math.sin(g),M,Math.cos(g),.013+d*.004+.004*Math.cos(g),f)},inside:(p,b,f)=>f.copy(o0),paint:d?o.lens:o.blackHard,weights:s})}for(let d of[1,-1]){let m=$t(.97*d,.125,.2,.013);dt(n,.004,.008,.09,.002,nt(m.x,m.y,m.z-.035,.05,0,0),o.blackHard,s,1)}}}var mr=n=>Math.atan2(Math.sin(n),Math.cos(n));import*as _t from"three";var wt=256;function bo(n,t,o){let e=Math.imul(n|0,374761393)^Math.imul(t|0,668265263)^Math.imul(o|0,1274126177);return e=Math.imul(e^e>>>13,1103515245),e^=e>>>16,(e>>>0)/4294967296}function pr(n,t,o,e){let s=Math.floor(n),r=Math.floor(t),c=n-s,a=t-r,i=c*c*(3-2*c),l=a*a*(3-2*a),u=E=>(E%o+o)%o,h=u(s),d=u(s+1),m=u(r),p=u(r+1),b=bo(h,m,e),f=bo(d,m,e),g=bo(h,p,e),R=bo(d,p,e);return b+(f-b)*i+(g-b)*l+(b-f-g+R)*i*l}function ft(n,t,o,e,s){let r=0,c=.5,a=0,i=o;for(let l=0;l<e;l++)r+=c*pr(n/wt*i,t/wt*i,i,s+l*17),a+=c,c*=.5,i*=2;return r/a}function Nn(n,t,o){let e=Math.floor(n/o),s=Math.floor(t/o),r=.5-.5*Math.cos(2*Math.PI*(n%o)/o),c=.5-.5*Math.cos(2*Math.PI*(t%o)/o);return e+s&1?r:c}var Qn=(n,t)=>Math.min(1,Math.max(0,(t-n)/.012+.5)),g0={skin:{height:(n,t)=>.6*ft(n,t,32,3,11)+.4*ft(n,t,4,3,12),albedo:(n,t)=>.9+.1*ft(n,t,6,4,13),rough:(n,t)=>.75+.25*ft(n,t,16,3,14),strength:1.2},fabric:{height:(n,t)=>.25*Nn(n,t,4)+.75*ft(n,t,3,4,21)+.08*ft(n,t,64,2,22),albedo:(n,t)=>.82+.18*ft(n,t,5,5,23)-.05*(ft(n,t,64,1,24)>.7?1:0),rough:(n,t)=>.85+.15*ft(n,t,8,3,25),strength:2.2},gear:{height:(n,t)=>{let e=.5+.25*Math.cos(2*Math.PI*n/4)*Math.cos(2*Math.PI*t/4),s=t%64,r=s<34?1:0,c=s<2||s>31&&s<34?-.5:0,a=r&&n%64<3?-.6:0;return .15*e+.55*r+.3*(c+a)+.2*ft(n,t,4,3,31)},albedo:(n,t)=>(t%64<34?.95:.8)*(.85+.15*ft(n,t,6,4,32)),rough:(n,t)=>.8+.2*ft(n,t,8,3,33),strength:2.5},hard:{height:(n,t)=>.85*ft(n,t,48,2,41)+.15*ft(n,t,6,3,42),albedo:(n,t)=>.9+.1*ft(n,t,8,4,43),rough:(n,t)=>.7+.3*ft(n,t,12,3,44),strength:.8},camo:{height:(n,t)=>.22*Nn(n,t,2)+.12*(n%16<1||t%16<1?1:0)+.66*ft(n,t,2,4,61),albedo:(n,t)=>{let o=Qn(.53,ft(n,t,4,4,62)),e=Qn(.57,ft(n+37,t+91,5,4,63));return(1-.24*o-.2*e*(1-.4*o))*(.86+.14*ft(n,t,8,3,64))},rough:(n,t)=>.85+.15*ft(n,t,8,3,65),strength:2},metal:{height:(n,t)=>.5*ft(n,t,64,2,51)+.5*ft(n,t,8,2,52),albedo:(n,t)=>.88+.12*ft(n,t,10,4,53),rough:(n,t)=>.6+.4*ft(n,t,16,4,54),strength:.5}};function rn(n,t,o){let e=new _t.DataTexture(n,wt,wt,_t.RGBAFormat);return e.wrapS=e.wrapT=_t.RepeatWrapping,e.magFilter=_t.LinearFilter,e.minFilter=_t.LinearMipmapLinearFilter,e.generateMipmaps=!0,e.anisotropy=4,e.repeat.set(o,o),t&&(e.colorSpace=_t.SRGBColorSpace),e.needsUpdate=!0,e}function M0(n,t){let o=new Float32Array(wt*wt);for(let a=0;a<wt;a++)for(let i=0;i<wt;i++)o[a*wt+i]=n.height(i,a);let e=new Uint8Array(wt*wt*4),s=new Uint8Array(wt*wt*4),r=new Uint8Array(wt*wt*4),c=(a,i)=>o[(i+wt)%wt*wt+(a+wt)%wt];for(let a=0;a<wt;a++)for(let i=0;i<wt;i++){let l=(a*wt+i)*4,u=(c(i+1,a)-c(i-1,a))*n.strength,h=(c(i,a+1)-c(i,a-1))*n.strength,d=Math.hypot(u,h,1);s[l]=Math.round((-u/d*.5+.5)*255),s[l+1]=Math.round((-h/d*.5+.5)*255),s[l+2]=Math.round((1/d*.5+.5)*255),s[l+3]=255;let m=Math.round(Math.min(1,n.albedo(i,a))*255);e[l]=e[l+1]=e[l+2]=m,e[l+3]=255;let p=Math.round(Math.min(1,n.rough(i,a))*255);r[l]=r[l+1]=r[l+2]=p,r[l+3]=255}return{map:rn(e,!0,t),normalMap:rn(s,!1,t),roughnessMap:rn(r,!1,t)}}var dr=n=>{n.vertexShader=n.vertexShader.replace("#include <common>",`#include <common>
2
+ attribute vec2 pbr;
3
+ attribute float ao;
4
+ varying vec2 vPbr;
5
+ varying float vAo;`).replace("#include <begin_vertex>",`#include <begin_vertex>
6
+ vPbr = pbr;
7
+ vAo = ao;`),n.fragmentShader=n.fragmentShader.replace("#include <common>",`#include <common>
8
+ varying vec2 vPbr;
9
+ varying float vAo;`).replace("#include <roughnessmap_fragment>",`#include <roughnessmap_fragment>
10
+ roughnessFactor *= vPbr.x;`).replace("#include <metalnessmap_fragment>",`#include <metalnessmap_fragment>
11
+ metalnessFactor *= vPbr.y;`).replace("#include <aomap_fragment>",`#include <aomap_fragment>
12
+ {
13
+ float cs2Ao = clamp( vAo, 0.0, 1.0 );
14
+ reflectedLight.indirectDiffuse *= cs2Ao;
15
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( saturate( dot( geometryNormal, geometryViewDir ) ), cs2Ao, material.roughness );
16
+ float cs2AoDirect = mix( 1.0, cs2Ao, 0.55 );
17
+ reflectedLight.directDiffuse *= cs2AoDirect;
18
+ reflectedLight.directSpecular *= cs2AoDirect;
19
+ }`)},fr=()=>"cs2r-character-pbr";function w0(n,t,o){let e=new _t.MeshStandardMaterial({name:o,vertexColors:!0,map:n.map,normalMap:n.normalMap,normalScale:new _t.Vector2(t,t),roughnessMap:n.roughnessMap,roughness:1,metalness:1});return e.onBeforeCompile=dr,e.customProgramCacheKey=fr,e}var s0=null;function Kn(){let n=M0(g0.skin,5),t=M0(g0.fabric,5),o=M0(g0.gear,4),e=M0(g0.hard,4),s=M0(g0.metal,6),r=M0(g0.camo,2.2),c=new Array(io);c[0]=w0(n,.25,"character-skin"),c[1]=w0(t,.7,"character-fabric"),c[2]=w0(o,.8,"character-gear"),c[3]=w0(e,.25,"character-hard"),c[4]=w0(r,.6,"character-camo");let a=w0(s,.3,"character-weapon");return{textures:[n,t,o,e,s,r].flatMap(i=>[i.map,i.normalMap,i.roughnessMap]),body:c,weapon:a}}function an(){return(s0??=Kn()).body}function Eo(){return(s0??=Kn()).weapon}function Xn(){s0&&(s0.textures.forEach(n=>n.dispose()),s0.body.forEach(n=>n.dispose()),s0.weapon.dispose(),s0=null)}import*as it from"three";import{RoundedBoxGeometry as Sr}from"three/addons/geometries/RoundedBoxGeometry.js";import*as rt from"three";import{RoundedBoxGeometry as br}from"three/addons/geometries/RoundedBoxGeometry.js";var Zn={},Ce=(n,t)=>t.forEach(o=>Zn[o.toLowerCase()]=n);Ce("rifle",["AK-47","M4A4","M4A1-S","M4A1","FAMAS","Galil AR","AUG","SG 553","SG 556"]);Ce("sniper",["AWP","SSG 08","SCAR-20","G3SG1"]);Ce("smg",["MP9","MP7","MP5-SD","MAC-10","UMP-45","P90","PP-Bizon"]);Ce("shotgun",["Nova","XM1014","MAG-7","Sawed-Off"]);Ce("lmg",["Negev","M249"]);Ce("pistol",["USP-S","Glock-18","P2000","P250","Five-SeveN","Tec-9","CZ75-Auto","Desert Eagle","R8 Revolver","Dual Berettas"]);Ce("grenade",["Smoke Grenade","Flashbang","HE Grenade","Molotov","Incendiary Grenade","Decoy Grenade","Snowball"]);Ce("c4",["C4","C4 Explosive"]);Ce("taser",["Zeus x27","Zeus"]);function Te(n){if(!n)return"none";let t=n.trim().toLowerCase(),o=Zn[t];return o||(/knife|bayonet|karambit|dagger|daggers|blade|bowie|falchion|stiletto|talon|ursus|navaja|kukri|huntsman|butterfly/.test(t)?"knife":/grenade|flash|molotov|incendiary|decoy|smoke/.test(t)?"grenade":/zeus|taser/.test(t)?"taser":/\bc4\b|bomb/.test(t)?"c4":"none")}var J=(n,t,o)=>new rt.Vector3(n,t,o),Pt=rt.MathUtils.degToRad;function Pe(n=18,t=J(0,0,0)){let o=Pt(n);return{pos:t,along:J(0,-Math.sin(o),Math.cos(o)),back:J(-1,0,0)}}function cn(n,t=.45){return{pos:n,along:J(-Math.cos(t),Math.sin(t),0),back:J(-Math.sin(t),-Math.cos(t),0)}}function Yn(n,t=8){let o=Pt(t),e=J(-.45,-Math.sin(o)*.9,.9).normalize(),s=J(0,Math.cos(o),Math.sin(o));return{pos:n,along:e,back:new rt.Vector3().crossVectors(s,e).normalize()}}var k={polymer:{mat:W.hard,color:new rt.Color("#1e1f21"),rough:.62,metal:0},polymer2:{mat:W.hard,color:new rt.Color("#2a2b2e"),rough:.55,metal:0},metal:{mat:W.hard,color:new rt.Color("#2c2e31"),rough:.38,metal:.85},bright:{mat:W.hard,color:new rt.Color("#6d7076"),rough:.3,metal:.9},tan:{mat:W.hard,color:new rt.Color("#8a7556"),rough:.6,metal:0},wood:{mat:W.hard,color:new rt.Color("#6a4529"),rough:.5,metal:0},olive:{mat:W.hard,color:new rt.Color("#4a4c39"),rough:.6,metal:0},glass:{mat:W.hard,color:new rt.Color("#0c1218"),rough:.08,metal:.5},yellow:{mat:W.hard,color:new rt.Color("#c9a227"),rough:.45,metal:0},red:{mat:W.hard,color:new rt.Color("#7a1c18"),rough:.5,metal:0},green:{mat:W.hard,color:new rt.Color("#3d4a2f"),rough:.6,metal:0},clay:{mat:W.hard,color:new rt.Color("#a59a7c"),rough:.85,metal:0}},yo=[[0,1]],Er=new rt.Quaternion,yr=new rt.Euler;function I(n,t,o,e=0,s=0,r=0){return new rt.Matrix4().compose(J(n,t,o),Er.setFromEuler(yr.set(e,s,r,"XYZ")),J(1,1,1))}var ae=class{b=new je;box(t,o,e,s,r,c=.004){let a=new br(t,o,e,1,Math.min(c,t/2-1e-4,o/2-1e-4,e/2-1e-4));this.b.geometry(a,s,r,yo,4),a.dispose()}tube(t,o,e,s,r,c,a,i=10,l=0){let u=new rt.CylinderGeometry(o,t,s-e,i,1,!1);u.rotateX(Math.PI/2),l&&u.rotateZ(l),this.b.geometry(u,I(r,c,(e+s)/2),a,yo,4),u.dispose()}cylY(t,o,e,s,r=10){let c=new rt.CylinderGeometry(t,t,o,r);this.b.geometry(c,e,s,yo,4),c.dispose()}shape(t,o,e,s,r=.0015){let c=new rt.Shape(t.map(([i,l])=>new rt.Vector2(i,l))),a=new rt.ExtrudeGeometry(c,{depth:o,bevelEnabled:r>0,bevelThickness:r,bevelSize:r,bevelSegments:1,curveSegments:4});a.translate(0,0,-o/2),this.b.geometry(a,e,s,yo,4),a.dispose()}done(){let t=this.b.build();return t.deleteAttribute("skinIndex"),t.deleteAttribute("skinWeight"),t.clearGroups(),p0(t,.8),t}};function O0(n,t,o=18){n.box(.03,.115,.042,I(0,-.005,-.012,Pt(o)),t,.008),n.box(.012,.006,.06,I(0,.012,.045),k.metal),n.box(.012,.03,.006,I(0,.028,.074),k.metal)}function gr(){let n=new ae;return n.box(.052,.072,.33,I(0,.074,.05),k.metal),n.box(.026,.012,.3,I(0,.115,.07),k.polymer2,.002),n.tube(.019,.019,.02,.1,0,.142,k.polymer),n.tube(.021,.021,.085,.105,0,.142,k.polymer),n.box(.014,.022,.03,I(0,.124,.06),k.polymer),n.tube(.027,.026,.215,.5,0,.074,k.polymer2,8,Math.PI/8),n.tube(.011,.011,.5,.62,0,.074,k.metal),n.tube(.016,.016,.6,.665,0,.074,k.metal,8),n.tube(.014,.014,-.25,-.1,0,.088,k.metal),n.box(.042,.1,.19,I(0,.06,-.225,Pt(-4)),k.polymer,.012),n.box(.046,.115,.022,I(0,.05,-.318),k.polymer2,.006),n.box(.03,.155,.066,I(0,-.035,.11,Pt(12)),k.polymer,.006),n.box(.03,.06,.07,I(0,-.12,.13,Pt(24)),k.polymer,.006),O0(n,k.polymer),n.done()}function Mr(){let n=new ae;return n.box(.046,.078,.27,I(0,.07,.05),k.polymer2,.008),n.box(.02,.01,.2,I(0,.114,.06),k.metal,.002),n.box(.02,.03,.03,I(0,.128,0),k.polymer),n.box(.02,.03,.02,I(0,.128,.16),k.polymer),n.tube(.012,.012,.18,.31,0,.074,k.metal),n.tube(.018,.018,.27,.33,0,.074,k.metal),n.box(.026,.17,.04,I(0,-.045,.085,Pt(4)),k.polymer,.005),n.cylY(.015,.085,I(0,-.005,.2),k.polymer),n.box(.008,.008,.2,I(.018,.085,-.17),k.metal,.002),n.box(.008,.008,.2,I(-.018,.085,-.17),k.metal,.002),n.box(.044,.07,.012,I(0,.07,-.27),k.polymer,.004),O0(n,k.polymer,12),n.done()}function wr(){let n=new ae;n.box(.05,.068,.3,I(0,.072,.04),k.metal),n.box(.056,.06,.32,I(0,.06,.33),k.olive,.012),n.tube(.012,.011,.45,.86,0,.078,k.metal),n.box(.034,.03,.055,I(0,.078,.885),k.metal,.004),n.tube(.018,.018,-.07,.22,0,.152,k.polymer),n.tube(.022,.029,.2,.28,0,.152,k.polymer),n.tube(.024,.024,-.12,-.06,0,.152,k.polymer),n.tube(.026,.026,.278,.282,0,.152,k.glass,12),n.cylY(.012,.03,I(0,.152,.07,0),k.polymer,8);for(let t of[-.02,.15])n.box(.026,.05,.02,I(0,.124,t),k.metal);return n.tube(.007,.007,0,.05,-.035,.085,k.bright,6),n.box(.008,.01,.045,I(-.035,.085,0,0,Pt(80)),k.bright),n.box(.046,.04,.32,I(0,.1,-.27),k.olive,.012),n.box(.046,.06,.2,I(0,.015,-.33,Pt(10)),k.olive,.012),n.box(.048,.13,.025,I(0,.06,-.43),k.polymer,.008),n.box(.034,.03,.09,I(0,.135,-.3),k.polymer,.008),n.box(.03,.06,.07,I(0,.015,.1),k.polymer,.006),n.box(.008,.008,.18,I(.012,.025,.42),k.metal,.002),n.box(.008,.008,.18,I(-.012,.025,.42),k.metal,.002),O0(n,k.olive,14),n.done()}function xr(){let n=new ae;return n.box(.05,.075,.22,I(0,.074,.05),k.metal,.006),n.tube(.013,.013,.16,.64,0,.096,k.metal),n.tube(.012,.012,.16,.58,0,.064,k.metal),n.box(.046,.046,.16,I(0,.062,.31),k.polymer,.014),n.box(.008,.012,.012,I(0,.112,.62),k.bright),n.box(.044,.1,.25,I(0,.05,-.18,Pt(-6)),k.polymer,.014),n.box(.046,.12,.02,I(0,.035,-.31,Pt(-6)),k.polymer2,.006),n.box(.03,.05,.11,I(0,-.02,-.06,Pt(30)),k.polymer,.01),O0(n,k.polymer,22),n.done()}function Rr(){let n=new ae;return n.box(.07,.1,.4,I(0,.07,.05),k.metal,.008),n.box(.066,.025,.2,I(0,.13,.02),k.polymer2,.006),n.tube(.032,.03,.25,.6,0,.078,k.polymer2,10),n.tube(.014,.014,.6,.76,0,.078,k.metal),n.tube(.02,.02,.74,.79,0,.078,k.metal,8),n.box(.012,.05,.012,I(0,.135,.3),k.metal),n.box(.012,.012,.16,I(0,.16,.24),k.metal),n.box(.1,.13,.12,I(.01,-.06,.08),k.green,.01),n.cylY(.016,.09,I(0,0,.27),k.polymer),n.box(.05,.1,.24,I(0,.055,-.24,Pt(-3)),k.polymer,.014),n.box(.052,.12,.02,I(0,.05,-.36),k.polymer2,.006),n.box(.008,.008,.22,I(.015,.03,.55),k.metal,.002),n.box(.008,.008,.22,I(-.015,.03,.55),k.metal,.002),O0(n,k.polymer,16),n.done()}function Tr(){let n=new ae;n.box(.03,.034,.19,I(0,.062,.058),k.metal,.005);for(let t=0;t<5;t++)n.box(.031,.026,.003,I(0,.064,-.02+t*.007),k.polymer);return n.box(.028,.026,.15,I(0,.034,.06),k.polymer,.006),n.box(.03,.11,.046,I(0,-.01,-.008,Pt(16)),k.polymer,.009),n.box(.01,.005,.045,I(0,.012,.045),k.polymer),n.box(.01,.022,.005,I(0,.022,.068),k.polymer),n.box(.006,.008,.006,I(0,.082,.14),k.metal),n.tube(.006,.006,.145,.155,0,.066,k.polymer,8),n.done()}function vr(){let n=new ae;return n.box(.036,.06,.15,I(0,.05,.06),k.yellow,.012),n.box(.04,.05,.04,I(0,.055,.155),k.polymer,.008),n.box(.032,.105,.045,I(0,-.01,-.01,Pt(14)),k.polymer,.01),n.box(.01,.005,.045,I(0,.012,.045),k.polymer),n.done()}function Hr(){let n=new ae;return n.box(.026,.11,.032,I(0,-.005,0),k.polymer,.01),n.box(.03,.01,.05,I(0,.055,.004),k.metal,.003),n.shape([[-.013,.06],[.022,.06],[.021,.17],[.012,.215],[0,.25],[-.006,.215],[-.013,.2]],.0035,I(0,0,0,0,-Math.PI/2),k.bright,.001),n.done()}function kr(){let n=new ae;return n.cylY(.028,.085,I(0,0,.01),k.olive,12),n.cylY(.012,.02,I(0,.05,.01),k.metal,8),n.box(.01,.006,.05,I(0,.06,.03,Pt(-20)),k.metal,.002),n.tube(.008,.008,0,.003,.016,.06,k.bright,8),n.done()}function zr(){let n=new ae;n.box(.25,.065,.13,I(.12,0,.035),k.clay,.01),n.box(.11,.022,.08,I(.13,.042,.04),k.polymer,.004),n.box(.05,.006,.03,I(.11,.055,.045),k.green,.001),n.box(.004,.004,.2,I(.07,.036,.035),k.red,.001),n.box(.004,.004,.2,I(.17,.036,.035),k.yellow,.001);for(let t of[.03,.21])n.box(.016,.07,.135,I(t,0,.035),k.polymer,.003);return n.done()}var Ar={rifle:()=>({right:Pe(18),left:cn(J(.004,.068,.27)),muzzle:J(0,.074,.67),stock:J(0,.06,-.33),kick:[.028,4]}),smg:()=>({right:Pe(12),left:Yn(J(0,-.005,.2)),muzzle:J(0,.074,.33),stock:J(0,.07,-.28),kick:[.018,3]}),sniper:()=>({right:Pe(14),left:cn(J(.004,.055,.23),.35),muzzle:J(0,.078,.91),stock:J(0,.06,-.44),kick:[.07,11]}),shotgun:()=>({right:Pe(22),left:cn(J(.004,.058,.3),.4),muzzle:J(0,.096,.64),stock:J(0,.03,-.32),kick:[.06,9]}),lmg:()=>({right:Pe(16),left:Yn(J(0,0,.27)),muzzle:J(0,.078,.79),stock:J(0,.05,-.37),kick:[.022,3]}),pistol:()=>({right:Pe(16),left:{pos:J(.022,-.012,.012),along:J(0,-Math.sin(Pt(16)),Math.cos(Pt(16))),back:J(1,0,.1)},muzzle:J(0,.066,.16),stock:null,kick:[.025,10]}),taser:()=>({right:Pe(14),left:null,muzzle:J(0,.055,.18),stock:null,kick:[.02,6]}),knife:()=>({right:Pe(0),left:null,muzzle:null,stock:null,kick:[0,0]}),grenade:()=>({right:{pos:J(0,0,.01),along:J(0,0,1),back:J(-1,0,0)},left:null,muzzle:null,stock:null,kick:[0,0]}),c4:()=>({right:{pos:J(0,0,.03),along:J(0,-.2,1).normalize(),back:J(-1,0,0)},left:{pos:J(.24,0,.03),along:J(0,-.2,1).normalize(),back:J(1,0,0)},muzzle:null,stock:null,kick:[0,0]}),none:()=>({right:Pe(0),left:null,muzzle:null,stock:null,kick:[0,0]})},Vr={rifle:gr,smg:Mr,sniper:wr,shotgun:xr,lmg:Rr,pistol:Tr,taser:vr,knife:Hr,grenade:kr,c4:zr},go=new Map;function x0(n){let t=go.get(n);return t||(t={cls:n,geometry:Vr[n]?.()??null,...Ar[n]()},go.set(n,t)),t}function $n(){go.forEach(n=>n.geometry?.dispose()),go.clear()}var N0=.25,ss={rifle:{p:[.16,-.215,-.4],r:[1.5,2.5,-3]},smg:{p:[.15,-.195,-.37],r:[1.5,2.5,-3]},sniper:{p:[.165,-.22,-.38],r:[1,2,-2]},shotgun:{p:[.16,-.215,-.4],r:[1.5,2.5,-3]},lmg:{p:[.165,-.23,-.4],r:[1.5,2.5,-3]},pistol:{p:[.115,-.15,-.4],r:[2,3,-2]},taser:{p:[.115,-.15,-.4],r:[2,3,-2]},knife:{p:[.16,-.17,-.36],r:[-30,12,-25]},grenade:{p:[.15,-.16,-.34],r:[15,6,-6]},c4:{p:[.06,-.2,-.36],r:[15,0,0]},none:{p:[0,0,0],r:[0,0,0]}},ln=.35,Mo=.55,Pr=1.7,Cr=6.35,R0=it.MathUtils.degToRad,rs=new it.Quaternion().setFromAxisAngle(new it.Vector3(0,1,0),Math.PI),Jn=new it.Euler,Lr=new it.Quaternion,j0=class{object=new it.Group;weaponMesh;handsMesh;def=x0("none");weaponName="\0";draw=1;low=0;constructor(){this.object.name="viewmodel",this.object.visible=!1;let t=Eo();this.weaponMesh=new it.Mesh(void 0,t),this.handsMesh=new it.Mesh(void 0,t),this.weaponMesh.name="viewmodel-weapon",this.handsMesh.name="viewmodel-hands";for(let o of[this.weaponMesh,this.handsMesh])o.castShadow=!1,o.receiveShadow=!0,o.frustumCulled=!1,o.visible=!1;this.weaponMesh.add(this.handsMesh),this.object.add(this.weaponMesh)}get weaponClass(){return this.def.cls}update(t,o){t.updateMatrixWorld(),t.matrixWorld.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.scale.setScalar(N0);let e=o.reset||o.dt<0||o.dt>.5,s=Math.max(0,o.dt),c=o.throwAge!==void 0&&o.throwAge<Mo&&o.thrown?o.thrown:o.weapon;c!==this.weaponName&&(this.setWeapon(c),this.draw=e?1:0),this.draw=e?1:Math.min(1,this.draw+s/ln);let a=o.busy?1:0;this.low=e?a:this.low+(a-this.low)*(1-Math.exp(-s/.15));let i=this.def,l=ss[i.cls],u=this.weaponMesh.position.set(l.p[0],l.p[1],l.p[2]),[h,d,m]=l.r,p=i.geometry!==null&&!o.scoped&&this.low<.98,b=1-this.draw;if(i.cls==="grenade"){let R=o.throwIn!==void 0&&o.throwIn<.35?1-o.throwIn/.35:0,E=o.throwAge;if(E!==void 0&&E<.12){let M=E/.12;u.x-=.04*M,u.y+=.05*(1-M),u.z-=.28*M,h+=35*(1-M)-10*M}else if(E!==void 0&&E<Mo)p=!1;else if(E!==void 0&&E<Mo+ln)b=Math.max(b,1-(E-Mo)/ln);else if(R>0){let M=R*R*(3-2*R);u.x+=.03*M,u.y+=.07*M,u.z+=.1*M,h+=35*M}}if(i.cls==="knife"&&o.swingAge!==void 0&&o.swingAge<.32){let R=o.swingAge/.32,E=Math.sin(Math.PI*R);u.x-=.16*R-.04,u.y+=.03*E,u.z-=.1*E,d+=50*R-15,m-=40*E}b=b*b*(3-2*b),u.y-=.2*b+.3*this.low,h-=40*b;let f=Math.min(2,Math.max(0,o.recoil));u.z+=i.kick[0]*f,h+=i.kick[1]*.7*f,u.y+=i.kick[0]*.15*f;let g=Math.min(1,o.speed/Cr);if(g>.05){let R=o.time*Pr*Math.PI*2;u.x+=Math.sin(R)*.007*g,u.y-=Math.abs(Math.cos(R))*.009*g,m+=Math.sin(R)*1.2*g}Jn.set(R0(h),R0(d),R0(m),"YXZ"),this.weaponMesh.quaternion.setFromEuler(Jn).multiply(rs),this.weaponMesh.visible=p,this.handsMesh.visible=p&&this.handsMesh.geometry!==void 0,this.object.updateMatrixWorld(!0)}muzzle(t){let o=this.def.muzzle;return!o||!this.object.visible||!this.weaponMesh.visible?null:t.copy(o).applyMatrix4(this.weaponMesh.matrixWorld)}setWeapon(t){this.weaponName=t;let o=x0(Te(t));this.def=o,o.geometry&&(this.weaponMesh.geometry=o.geometry);let e=Gr(o);e&&(this.handsMesh.geometry=e)}},ts={mat:W.hard,color:new it.Color("#1c1d1f"),rough:.95,metal:0},Fr={mat:W.hard,color:new it.Color("#2b2c2e"),rough:.9,metal:0},Ir={mat:W.hard,color:new it.Color("#262823"),rough:1,metal:0},Br={mat:W.hard,color:new it.Color("#18191a"),rough:1,metal:0},es=[[0,1]],qr=new it.Vector3(0,1,0),os={R:new it.Vector3(.28,-.42,.86).normalize(),L:new it.Vector3(-.12,-.5,.86).normalize()},U0=new Map;function Gr(n){if(U0.has(n.cls))return U0.get(n.cls);let t=null;if(n.geometry){let o=ss[n.cls].r,e=new it.Quaternion().setFromEuler(new it.Euler(R0(o[0]),R0(o[1]),R0(o[2]),"YXZ")).multiply(rs).invert(),s=new je;ns(s,n.right,os.R.clone().applyQuaternion(e)),n.left&&ns(s,n.left,os.L.clone().applyQuaternion(e)),t=s.build(),t.deleteAttribute("skinIndex"),t.deleteAttribute("skinWeight"),t.clearGroups(),p0(t,.8)}return U0.set(n.cls,t),t}function ns(n,t,o){let e=t.along.clone().normalize(),s=new it.Vector3().crossVectors(t.back,e).normalize(),r=new it.Vector3().crossVectors(e,s),c=new it.Matrix4().makeBasis(s,r,e),a=t.pos.clone().addScaledVector(r,.008),i=(h,d,m,p,b,f)=>{let g=new Sr(h,d,m,2,f);n.geometry(g,c.clone().setPosition(p),b,es,4),g.dispose()};i(.088,.066,.096,a,ts,.022),i(.09,.03,.03,a.clone().addScaledVector(e,.035).addScaledVector(r,.024),Fr,.012);let l=a.clone().addScaledVector(e,-.055),u=(h,d,m,p,b)=>{let f=new it.CylinderGeometry(d,h,p-m,12),g=new it.Matrix4().compose(l.clone().addScaledVector(o,(m+p)/2),Lr.setFromUnitVectors(qr,o),new it.Vector3(1,1,1));n.geometry(f,g,b,es,4),f.dispose()};u(.033,.036,-.01,.05,ts),u(.041,.042,.045,.085,Br),u(.037,.045,.08,.42,Ir)}function as(){U0.forEach(n=>n?.dispose()),U0.clear()}var _r=new Dt.Sphere(new Dt.Vector3(0,.9,0),2.4),wo=class{object=new Dt.Group;mesh;bones;skeleton;anim;seed;side;weaponMesh;holder=new Dt.Object3D;weaponName="\0";def=x0("none");alive=!0;constructor(t){this.seed=Math.abs(Math.floor(t.seed??0)),this.side=t.side,this.object.name="character",this.bones=_o.map((o,e)=>{let s=new Dt.Bone;return s.name=o,s.position.copy(F0[e]),s}),this.bones.forEach((o,e)=>Ge[e]>=0&&this.bones[Ge[e]].add(o)),this.mesh=new Dt.SkinnedMesh(W0(D0(this.side)),an()),this.mesh.name="character-body",this.mesh.castShadow=!0,this.mesh.receiveShadow=!0,this.mesh.boundingSphere=_r.clone(),this.mesh.add(this.bones[y.root]),this.skeleton=new Dt.Skeleton(this.bones),this.mesh.bind(this.skeleton),this.object.add(this.mesh),this.weaponMesh=new Dt.Mesh(void 0,Eo()),this.weaponMesh.name="character-weapon",this.weaponMesh.castShadow=!0,this.weaponMesh.receiveShadow=!0,this.weaponMesh.visible=!1,this.holder.add(this.weaponMesh),this.bones[y.handR].add(this.holder),this.anim=new ao(this.bones,this.seed)}setSide(t){t!==this.side&&(this.side=t,this.mesh.geometry=W0(D0(t)))}update(t){this.object.position.copy(t.position),this.object.rotation.set(0,t.yaw,0),t.weapon!==this.weaponName&&this.setWeapon(t.weapon),this.alive=t.alive;let o=this.def;this.anim.curDef=o,this.anim.update({dt:t.dt,yaw:t.yaw,velocity:t.velocity,alive:t.alive,ducking:t.ducking,cls:o.cls,def:o,pitch:t.pitch??0,planting:t.planting??!1,defusing:t.defusing??!1,blind:t.blind??!1,scoped:t.scoped??!1,shotAge:t.shotAge,throwAge:t.throwAge,hurtAge:t.hurtAge,deathAge:t.deathAge,deathDir:t.deathDir,headshot:t.headshot??!1,reset:t.reset??!1});let e=this.anim.weapon;this.weaponMesh.visible=e.visible&&o.geometry!==null,e.inHand?(this.weaponMesh.parent!==this.holder&&this.holder.add(this.weaponMesh),this.weaponMesh.position.set(0,0,0),this.weaponMesh.quaternion.identity()):(this.weaponMesh.parent!==this.object&&this.object.add(this.weaponMesh),this.weaponMesh.position.copy(e.pos),this.weaponMesh.quaternion.copy(e.quat))}muzzle(t){let o=this.def.muzzle;return!o||!this.alive||!this.weaponMesh.visible||this.weaponMesh.parent!==this.holder?null:(this.weaponMesh.updateWorldMatrix(!0,!1),t.copy(o).applyMatrix4(this.weaponMesh.matrixWorld))}get weaponClass(){return this.def.cls}dispose(){this.object.removeFromParent(),this.skeleton.dispose()}setWeapon(t){this.weaponName=t;let o=x0(Te(t));o===this.def&&this.weaponMesh.geometry===o.geometry||(this.def=o,o.geometry&&(this.weaponMesh.geometry=o.geometry),jo(o,this.holder.position,this.holder.quaternion))}};async function is(n){for(let t of[an,()=>W0(D0("T")),()=>W0(D0("CT"))])await n(),t()}function cs(){Un(),as(),$n(),Xn()}import*as Gt from"three";import*as Z from"three";import*as Jt from"three";function T0(n){return n^=n>>>16,n=Math.imul(n,2146121005),n^=n>>>15,n=Math.imul(n,2221713035),n^=n>>>16,n>>>0}function Ct(n,t=0,o=0){return T0((n|0)+T0((t|0)+T0((o|0)^2654435769)))/4294967296}function bt(n,t,o,e){let s=T0((n|0)+T0((t|0)^2654435769));for(let r=0;r<e;r++)s=T0(s+1831565813+r),o[r]=s/4294967296}var xo=(n,t=0,o=0)=>Ct(n,t,o)*2-1,xt=n=>n<0?0:n>1?1:n;function N(n,t,o){let e=xt((o-n)/(t-n));return e*e*(3-2*e)}var ls=n=>1-(1-n)*(1-n)*(1-n),Wt=(n,t)=>n<=0?0:1-Math.exp(-n/t),Q0=n=>n<=0||n>=1?0:Math.sin(Math.PI*n);function hn(n,t){let o=N(0,.3,n)*(.75+n*.9);return t[0]=o,t[1]=o*(.32+.45*N(.2,1,n))+.3*N(.7,1.3,n),t[2]=N(.6,1.4,n)*(.15+n*.9),t}function v0(n,t){let o=t*1.618;return Math.sin(n*11.3+o)*.45+Math.sin(n*23.1+o*2.1+1.3)*.3+Math.sin(n*37.7+o*3.7+.5)*.25}var Le=4,kt={puff:0,puffs:6,wisp:6,dust:8,chunk:10,soft:11,scorch:12},Q={soft:0,core:1,streak:2,star4:3,star6:4,ring:5,muzzle:6,muzzleSide:7,flame:8,fireball:12,disc:14,tracer:15},Ze=class{p=new Uint8Array(512);constructor(t){let o=Array.from({length:256},(e,s)=>s);for(let e=255;e>0;e--){let s=Math.floor(Ct(t,e,7)*(e+1));[o[e],o[s]]=[o[s],o[e]]}for(let e=0;e<512;e++)this.p[e]=o[e&255]}grad(t,o,e){switch(t&7){case 0:return o+e;case 1:return-o+e;case 2:return o-e;case 3:return-o-e;case 4:return o*1.41;case 5:return-o*1.41;case 6:return e*1.41;default:return-e*1.41}}noise(t,o){let e=Math.floor(t),s=Math.floor(o),r=t-e,c=o-s,a=e&255,i=s&255,l=this.p,u=r*r*r*(r*(r*6-15)+10),h=c*c*c*(c*(c*6-15)+10),d=this.grad(l[l[a]+i],r,c),m=this.grad(l[l[a+1]+i],r-1,c),p=this.grad(l[l[a]+i+1],r,c-1),b=this.grad(l[l[a+1]+i+1],r-1,c-1),f=d+(m-d)*u,g=p+(b-p)*u;return(f+(g-f)*h)*.75}fbm(t,o,e=4){let s=0,r=1,c=0,a=1;for(let i=0;i<e;i++)s+=this.noise(t*a+i*17.3,o*a-i*9.1)*r,c+=r,r*=.5,a*=2.03;return s/c}},U=128,ve=U*Le;function us(n){let t=new Jt.DataTexture(n,ve,ve,Jt.RGBAFormat,Jt.UnsignedByteType);return t.generateMipmaps=!0,t.minFilter=Jt.LinearMipmapLinearFilter,t.magFilter=Jt.LinearFilter,t.wrapS=t.wrapT=Jt.ClampToEdgeWrapping,t.colorSpace=Jt.NoColorSpace,t.needsUpdate=!0,t}function H0(n,t,o,e){let s=t%Le*U,r=Math.floor(t/Le)*U,c=2/U;for(let a=0;a<U;a++)for(let i=0;i<U;i++){let l=a*U+i,u=o[a*U+Math.max(0,i-1)],h=o[a*U+Math.min(U-1,i+1)],d=o[Math.max(0,a-1)*U+i],m=o[Math.min(U-1,a+1)*U+i],p=-(h-u)/(2*c),b=-(m-d)/(2*c),f=1,g=Math.hypot(p,b,f);p/=g,b/=g,f/=g;let R=((r+a)*ve+s+i)*4;n[R]=Math.round((p*.5+.5)*255),n[R+1]=Math.round((b*.5+.5)*255),n[R+2]=Math.round((f*.5+.5)*255),n[R+3]=Math.round(Math.max(0,Math.min(1,e[l]))*255)}}function ie(n,t,o){let e=t%Le*U,s=Math.floor(t/Le)*U;for(let r=0;r<U;r++){let c=(r+.5)/U*2-1;for(let a=0;a<U;a++){let i=(a+.5)/U*2-1,l=1-N(.9,.99,Math.max(Math.abs(i),Math.abs(c))),u=Math.max(0,Math.min(1,o(i,c)*l)),h=((s+r)*ve+e+a)*4,d=Math.round(u*255);n[h]=n[h+1]=n[h+2]=n[h+3]=d}}}function hs(n,t,o,e){let s=new Ze(n),r=[0,0,t?.55:.5],c=t?5:8+Math.floor(Ct(n,1)*5);for(let a=0;a<c;a++){let i=Ct(n,a,2)*Math.PI*2,l=Math.sqrt(Ct(n,a,3))*(t?.3:.38);r.push(Math.cos(i)*l,Math.sin(i)*l*.9,(t?.3:.2)+Ct(n,a,4)*.2)}for(let a=0;a<U;a++){let i=(a+.5)/U*2-1;for(let l=0;l<U;l++){let u=(l+.5)/U*2-1,h=0;for(let M=0;M<r.length;M+=3){let P=u-r[M],C=i-r[M+1],v=r[M+2],L=v*v-P*P-C*C;L>0&&(h=Math.max(h,Math.sqrt(L)))}let d=Math.hypot(u,i),m=Math.sqrt(Math.max(0,.72-d*d)),p=s.fbm(u*3.2+n,i*3.2,5),b=s.fbm(u*7+3,i*7-n,3),f=1-N(.7,.96,d),R=(t?N(-.05,.5,h+p*.3):N(-.06,.36,h+p*.24+b*.05))*(.62+.38*(b*.5+.5))*(.85+.15*p),E=a*U+l;e[E]=R*f,o[E]=(.5*m+.5*h+p*.05+b*.02)*f}}}function Dr(n,t,o){let e=new Ze(n);for(let s=0;s<U;s++){let r=(s+.5)/U*2-1;for(let c=0;c<U;c++){let a=(c+.5)/U*2-1,i=Math.hypot(a,r*1.15),l=e.fbm(a*2+5,r*2,4)*.35,u=1-N(.2,.9,i+l),h=e.fbm(a*5,r*5-2,5),d=s*U+c;o[d]=Math.max(0,u*(.55+.6*h)),t[d]=Math.sqrt(Math.max(0,.5-i*i*.5))*.6+h*.06}}}function Wr(n,t,o){let e=new Ze(n);for(let s=0;s<U;s++){let r=(s+.5)/U*2-1;for(let c=0;c<U;c++){let a=(c+.5)/U*2-1,i=Math.atan2(r,a),l=.45+.18*e.noise(Math.cos(i)*1.5+3,Math.sin(i)*1.5),u=Math.hypot(a,r),h=s*U+c;o[h]=1-N(l-.05,l,u),t[h]=Math.sqrt(Math.max(0,l*l-u*u))}}}function Or(n,t){for(let o=0;o<U;o++){let e=(o+.5)/U*2-1;for(let s=0;s<U;s++){let r=(s+.5)/U*2-1,c=r*r+e*e,a=o*U+s;t[a]=Math.max(0,1-c)**2*(1-N(.9,.99,Math.sqrt(c))),n[a]=Math.sqrt(Math.max(0,.81-c))}}}function Ur(n,t,o){let e=new Ze(n);for(let s=0;s<U;s++){let r=(s+.5)/U*2-1;for(let c=0;c<U;c++){let a=(c+.5)/U*2-1,i=Math.hypot(a,r),l=Math.atan2(r,a),u=Math.abs(e.noise(Math.cos(l)*3+11,Math.sin(l)*3))*.35,h=1-N(.25,.9,i+e.fbm(a*2.5,r*2.5,4)*.3-u*(1-i)),d=.75+.25*e.fbm(a*9,r*9,3),m=s*U+c;o[m]=Math.max(0,h*d)*(1-N(.85,.98,i)),t[m]=0}}}function ms(){let n=new Uint8Array(ve*ve*4);for(let e=0;e<ve*ve;e++)n[e*4]=128,n[e*4+1]=128,n[e*4+2]=255;let t=new Float32Array(U*U),o=new Float32Array(U*U);for(let e=0;e<6;e++)hs(101+e*13,!1,t,o),H0(n,kt.puff+e,t,o);for(let e=0;e<2;e++)hs(301+e*7,!0,t,o),H0(n,kt.wisp+e,t,o);for(let e=0;e<2;e++)Dr(401+e*5,t,o),H0(n,kt.dust+e,t,o);Wr(501,t,o),H0(n,kt.chunk,t,o),Or(t,o),H0(n,kt.soft,t,o);for(let e=0;e<2;e++)Ur(601+e*3,t,o),H0(n,kt.scorch+e,t,o);return us(n)}function ps(){let n=new Uint8Array(ve*ve*4),t=new Ze(907);ie(n,Q.soft,(e,s)=>{let r=e*e+s*s;return Math.exp(-r*5)*(1-N(.7,.95,Math.sqrt(r)))}),ie(n,Q.core,(e,s)=>{let r=e*e+s*s;return(Math.exp(-r*40)+.4*Math.exp(-r*7))*(1-N(.7,.95,Math.sqrt(r)))}),ie(n,Q.streak,(e,s)=>{let r=Math.max(0,1-e*e)**1.5;return Math.exp(-(s*s)*18)*r});let o=(e,s,r,c)=>{let a=Math.hypot(e,s),i=Math.atan2(s,e),l=Math.pow(Math.abs(Math.cos(i*r/2)),60+40*t.noise(i*3+c,1))*Math.max(0,1-a)**1.2;return Math.min(1,l*.9+Math.exp(-a*a*60)+.25*Math.exp(-a*a*6))*(1-N(.8,.97,a))};ie(n,Q.star4,(e,s)=>o(e,s,4,1)),ie(n,Q.star6,(e,s)=>o(e,s,6,5)),ie(n,Q.ring,(e,s)=>{let r=Math.hypot(e,s),c=Math.atan2(s,e),a=.07+.03*t.noise(Math.cos(c)*2,Math.sin(c)*2+9);return Math.exp(-(((r-.8)/a)**2))*(.8+.2*t.noise(Math.cos(c)*6,Math.sin(c)*6))}),ie(n,Q.muzzle,(e,s)=>{let r=Math.hypot(e,s),c=Math.atan2(s,e),a=.32+.5*Math.pow(Math.abs(Math.cos(c*2.5+.3)),3)*(.75+.25*t.noise(c*2,4)),i=1-N(a*.35,a,r+.08*t.fbm(e*5,s*5,3));return Math.min(1,i*.8+Math.exp(-r*r*30))*(1-N(.85,.97,r))}),ie(n,Q.muzzleSide,(e,s)=>{let r=(e+1)/2,c=.12+.45*Math.sin(Math.PI*Math.min(1,r*1.25))*(1-r*.5),a=Math.abs(s)/c+.3*t.fbm(r*6,s*4+2,3);return(1-N(.3,1,a))*N(0,.08,r)*(1-N(.75,.98,r))*(1.1-r*.6)});for(let e=0;e<4;e++){let s=31+e*19;ie(n,Q.flame+e,(r,c)=>{let a=(c+1)/2,i=t.fbm(a*1.6+s,s*.3,3)*.35*a,l=.62*Math.pow(1-a,.75)*(.55+.45*Math.sin(Math.PI*Math.min(1,a*2.2+.1))),u=Math.abs(r-i)/Math.max(.02,l)+.45*t.fbm(r*3+s,a*4.5-s,4);return(1-N(.15,1,u))*N(0,.14,a)*(1-.45*a)*(1-N(.85,.98,a))})}for(let e=0;e<2;e++){let s=new Ze(70+e);ie(n,Q.fireball+e,(r,c)=>{let a=Math.hypot(r,c);return(1-N(.25,.85,a+s.fbm(r*2.2,c*2.2,4)*.32))*(.55+.45*(s.fbm(r*5+3,c*5,4)*.5+.5))*(1-N(.85,.97,a))})}return ie(n,Q.disc,(e,s)=>{let r=e*e+s*s;return Math.max(0,1-r)**2}),ie(n,Q.tracer,(e,s)=>{let r=(e+1)/2;return Math.exp(-(s*s)*30)*Math.pow(r,.7)*N(0,.2,r)*(1-N(.9,.99,r))}),us(n)}var ce=0,To=1,mt=2,r0=3,jr=0,me=1,Fe=2,He=24,Nr=-1e5,Qr=`
20
+ #include <common>
21
+ #include <fog_pars_vertex>
22
+ attribute vec4 a0; // pos.xyz, rotation
23
+ attribute vec4 a1; // size.xy, cell, type
24
+ attribute vec4 a2; // colour rgb, alpha
25
+ attribute vec4 a3; // axis.xyz, mode
26
+ attribute vec4 a4; // erode | heat, sun transmittance, ambient, ground y
27
+ attribute vec4 a5; // emission rgb, near-fade scale
28
+ uniform vec3 uSunDir;
29
+ #if FX_LIGHTS > 0
30
+ uniform vec3 uLightPos[FX_LIGHTS];
31
+ uniform vec4 uLightColor[FX_LIGHTS]; // rgb \xD7 intensity, cutoff distance
32
+ #endif
33
+ varying vec2 vUv;
34
+ varying vec4 vColor;
35
+ varying vec4 vShade; // erode | heat, sunT, ambient, type
36
+ varying vec3 vL;
37
+ varying vec3 vU;
38
+ varying vec3 vEmit;
39
+ varying vec3 vFade; // world y, ground y, view depth
40
+ varying float vPhase; // forward scattering towards the camera
41
+
42
+ void main() {
43
+ vec3 p = a0.xyz;
44
+ float type = a1.w;
45
+ float mode = a3.w;
46
+ vec3 camRight = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);
47
+ vec3 camUp = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);
48
+ vec3 camBack = vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]);
49
+ vec3 T = camRight, B = camUp, N = camBack;
50
+ if (mode > 1.5) {
51
+ N = a3.xyz;
52
+ vec3 ref = abs(N.y) < 0.99 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
53
+ T = normalize(cross(ref, N));
54
+ B = cross(N, T);
55
+ } else if (mode > 0.5) {
56
+ T = a3.xyz;
57
+ vec3 toCam = normalize(cameraPosition - p);
58
+ vec3 side = cross(toCam, T);
59
+ float sl = length(side);
60
+ B = sl > 1e-4 ? side / sl : camUp;
61
+ N = toCam;
62
+ }
63
+ float c = cos(a0.w), s = sin(a0.w);
64
+ vec3 Tr = T * c + B * s;
65
+ vec3 Br = B * c - T * s;
66
+ vec3 world = p + Tr * (position.x * a1.x) + Br * (position.y * a1.y);
67
+ vUv = (vec2(mod(a1.z, ${Le}.0), floor(a1.z / ${Le}.0)) + position.xy + 0.5) / ${Le}.0;
68
+ vColor = a2;
69
+ vShade = vec4(a4.xyz, type);
70
+ vEmit = a5.rgb;
71
+ vL = vec3(0.0);
72
+ vU = vec3(0.0, 1.0, 0.0);
73
+ vPhase = 0.0;
74
+ if (type < 0.5) {
75
+ float mu = dot(normalize(p - cameraPosition), uSunDir);
76
+ float g = 0.6;
77
+ vPhase = (1.0 - g * g) / pow(1.0 + g * g - 2.0 * g * mu, 1.5) * 0.25;
78
+ vL = vec3(dot(uSunDir, Tr), dot(uSunDir, Br), dot(uSunDir, N));
79
+ vU = vec3(Tr.y, Br.y, N.y);
80
+ #if FX_LIGHTS > 0
81
+ vec3 pl = vec3(0.0);
82
+ for (int i = 0; i < FX_LIGHTS; i++) {
83
+ vec3 d = uLightPos[i] - p;
84
+ float dist = length(d);
85
+ float att = 1.0 / max(dist * dist, 0.5);
86
+ float k = saturate(1.0 - pow4(dist / max(uLightColor[i].w, 0.01)));
87
+ pl += uLightColor[i].rgb * att * k * k;
88
+ }
89
+ // A puff is lit from every side by a light inside or next to it.
90
+ vEmit += pl * a2.rgb * (0.6 * RECIPROCAL_PI) * (0.5 + 0.5 * a4.z);
91
+ #endif
92
+ }
93
+ vec4 mvPosition = viewMatrix * vec4(world, 1.0);
94
+ // a5.w scales the near fade (first-person flashes are drawn shrunk towards the eye).
95
+ vFade = vec3(world.y, a4.w, -mvPosition.z / (a5.w > 0.0 ? a5.w : 1.0));
96
+ gl_Position = projectionMatrix * mvPosition;
97
+ #include <fog_vertex>
98
+ }
99
+ `,Kr=`
100
+ #include <common>
101
+ #include <fog_pars_fragment>
102
+ uniform sampler2D uSmoke;
103
+ uniform sampler2D uGlow;
104
+ uniform vec3 uSunColor;
105
+ uniform vec3 uSky;
106
+ uniform vec3 uGround;
107
+ uniform vec3 uAmbient;
108
+ varying vec2 vUv;
109
+ varying vec4 vColor;
110
+ varying vec4 vShade;
111
+ varying vec3 vL;
112
+ varying vec3 vU;
113
+ varying vec3 vEmit;
114
+ varying vec3 vFade;
115
+ varying float vPhase;
116
+
117
+ vec3 heatRamp(float h) {
118
+ // deep orange -> orange -> yellow -> white, HDR above 1 (keep in sync with random.ts)
119
+ float r = smoothstep(0.0, 0.3, h) * (0.75 + h * 0.9);
120
+ return vec3(
121
+ r,
122
+ r * (0.32 + 0.45 * smoothstep(0.2, 1.0, h)) + 0.3 * smoothstep(0.7, 1.3, h),
123
+ smoothstep(0.6, 1.4, h) * (0.15 + h * 0.9)
124
+ );
125
+ }
126
+
127
+ void main() {
128
+ float type = vShade.w;
129
+ // Soft contact with the floor the effect sits on, and no hard cut at the near plane.
130
+ float fade = smoothstep(vFade.y, vFade.y + 0.3, vFade.x) * smoothstep(0.08, 0.6, vFade.z);
131
+ #ifdef USE_FOG
132
+ #ifdef FOG_EXP2
133
+ float fogFactor = 1.0 - exp(-fogDensity * fogDensity * vFogDepth * vFogDepth);
134
+ #else
135
+ float fogFactor = smoothstep(fogNear, fogFar, vFogDepth);
136
+ #endif
137
+ #else
138
+ float fogFactor = 0.0;
139
+ #endif
140
+ if (type < 1.5) {
141
+ vec4 t = texture2D(uSmoke, vUv);
142
+ float e = vShade.x;
143
+ float a = saturate((t.a - e) / max(1.0 - e, 1e-3)) * vColor.a * fade;
144
+ if (a < 0.002) discard;
145
+ vec3 col;
146
+ if (type < 0.5) {
147
+ vec3 n = normalize(t.rgb * 2.0 - 1.0);
148
+ float ndl = dot(n, normalize(vL));
149
+ float diff = saturate((ndl + 0.45) / 1.45);
150
+ float hk = dot(n, normalize(vU)) * 0.5 + 0.5;
151
+ // Multiple scattering greys out the sky tint a little.
152
+ vec3 amb = mix(uGround, uSky, hk) + uAmbient;
153
+ amb = mix(vec3(dot(amb, vec3(0.2126, 0.7152, 0.0722))), amb, 0.55);
154
+ // Thin, sunlit edges glow when looking towards the sun.
155
+ float rim = vPhase * (1.0 - t.a) * vShade.y;
156
+ vec3 irr = uSunColor * (diff * vShade.y + rim) + amb * vShade.z;
157
+ col = vColor.rgb * irr * RECIPROCAL_PI + vEmit;
158
+ } else {
159
+ col = vColor.rgb + vEmit;
160
+ }
161
+ #ifdef USE_FOG
162
+ col = mix(col, fogColor, fogFactor);
163
+ #endif
164
+ gl_FragColor = vec4(col * a, a);
165
+ } else {
166
+ float v = texture2D(uGlow, vUv).r;
167
+ vec3 col = type > 2.5 ? heatRamp(v * vShade.x) * vColor.rgb : vColor.rgb * v;
168
+ float k = vColor.a * fade;
169
+ col *= k * (1.0 - fogFactor);
170
+ float occ = saturate(v * 1.6) * vShade.y * k;
171
+ if (dot(col, vec3(1.0)) + occ < 0.0005) discard;
172
+ gl_FragColor = vec4(col, occ);
173
+ }
174
+ #include <tonemapping_fragment>
175
+ #include <colorspace_fragment>
176
+ }
177
+ `,un=class{type=0;cell=0;x=.5;y=.5;z=.5;rot=.5;w=.5;h=.5;r=.5;g=.5;b=.5;a=.5;mode=0;ax=.5;ay=.5;az=.5;erode=.5;heat=.5;sunT=.5;amb=.5;occlude=.5;ground=.5;er=.5;eg=.5;eb=.5;near=.5},Ro=class{mesh;capacity;p=new un;count=0;staging;gpu;buffer;geometry;material;keys;constructor(t,o,e,s){this.capacity=Math.min(t,65535),this.staging=new Float32Array(this.capacity*He),this.gpu=new Float32Array(this.capacity*He),this.keys=new Uint32Array(this.capacity);let r=new Z.InstancedBufferGeometry;r.setAttribute("position",new Z.Float32BufferAttribute([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0],3)),r.setIndex([0,1,2,0,2,3]),this.buffer=new Z.InstancedInterleavedBuffer(this.gpu,He,1),this.buffer.setUsage(Z.DynamicDrawUsage);for(let a=0;a<6;a++)r.setAttribute(`a${a}`,new Z.InterleavedBufferAttribute(this.buffer,4,a*4));r.instanceCount=0,this.geometry=r;let c=Z.UniformsUtils.merge([Z.UniformsLib.fog,{uSunDir:{value:new Z.Vector3(.4,.8,.3).normalize()},uSunColor:{value:new Z.Color(3,3,3)},uSky:{value:new Z.Color(.6,.65,.75)},uGround:{value:new Z.Color(.3,.27,.24)},uAmbient:{value:new Z.Color(.2,.2,.2)},uLightPos:{value:Array.from({length:Math.max(1,o)},()=>new Z.Vector3)},uLightColor:{value:Array.from({length:Math.max(1,o)},()=>new Z.Vector4)}}]);c.uSmoke={value:e},c.uGlow={value:s},this.material=new Z.ShaderMaterial({name:"cs2r-fx-particles",uniforms:c,vertexShader:Qr,fragmentShader:Kr,defines:{FX_LIGHTS:o},transparent:!0,depthWrite:!1,depthTest:!0,fog:!0,side:Z.DoubleSide,blending:Z.CustomBlending,blendEquation:Z.AddEquation,blendSrc:Z.OneFactor,blendDst:Z.OneMinusSrcAlphaFactor,blendEquationAlpha:Z.AddEquation,blendSrcAlpha:Z.OneFactor,blendDstAlpha:Z.OneMinusSrcAlphaFactor}),this.mesh=new Z.Mesh(r,this.material),this.mesh.name="cs2r-fx-particles",this.mesh.frustumCulled=!1,this.mesh.renderOrder=20}begin(){this.count=0}start(t,o){let e=this.p;return e.type=t,e.cell=o,e.x=0,e.y=0,e.z=0,e.rot=0,e.w=1,e.h=1,e.r=1,e.g=1,e.b=1,e.a=1,e.mode=jr,e.ax=0,e.ay=1,e.az=0,e.erode=0,e.heat=0,e.sunT=1,e.amb=1,e.occlude=0,e.ground=Nr,e.er=0,e.eg=0,e.eb=0,e.near=1,e}push(){let t=this.p;if(this.count>=this.capacity||!(t.a>0)||!(t.w>0)||!(t.h>0))return;let o=this.count++*He,e=this.staging,s=t.type>=mt;e[o]=t.x,e[o+1]=t.y,e[o+2]=t.z,e[o+3]=t.rot,e[o+4]=t.w,e[o+5]=t.h,e[o+6]=t.cell,e[o+7]=t.type,e[o+8]=t.r,e[o+9]=t.g,e[o+10]=t.b,e[o+11]=t.a;let r=Math.sqrt(t.ax*t.ax+t.ay*t.ay+t.az*t.az)||1;e[o+12]=t.ax/r,e[o+13]=t.ay/r,e[o+14]=t.az/r,e[o+15]=t.mode,e[o+16]=s?t.heat:t.erode,e[o+17]=s?t.occlude:t.sunT,e[o+18]=t.amb,e[o+19]=t.ground,e[o+20]=t.er,e[o+21]=t.eg,e[o+22]=t.eb,e[o+23]=t.near}setLighting(t){let o=this.material.uniforms;o.uSunDir.value.copy(t.sunDir).normalize(),o.uSunColor.value.copy(t.sunColor),o.uSky.value.copy(t.sky),o.uGround.value.copy(t.ground),o.uAmbient.value.copy(t.ambient)}setLight(t,o,e,s,r,c,a,i){let l=this.material.uniforms,u=l.uLightPos.value,h=l.uLightColor.value;t>=u.length||(u[t].set(o,e,s),h[t].set(r,c,a,i))}finish(t,o){let e=this.count,s=this.staging,r=this.gpu,c=this.keys,a=.001;for(let u=0;u<e;u++){let h=u*He,d=(s[h]-t.x)*o.x+(s[h+1]-t.y)*o.y+(s[h+2]-t.z)*o.z;d>a&&(a=d)}let i=65535/a;for(let u=0;u<e;u++){let h=u*He,d=(s[h]-t.x)*o.x+(s[h+1]-t.y)*o.y+(s[h+2]-t.z)*o.z,m=65535-Math.max(0,Math.min(65535,Math.round(d*i)));c[u]=m*65536+u}let l=c.subarray(0,e);l.sort();for(let u=0;u<e;u++){let h=(l[u]&65535)*He,d=u*He;for(let m=0;m<He;m++)r[d+m]=s[h+m]}this.buffer.clearUpdateRanges(),e>0&&(this.buffer.addUpdateRange(0,e*He),this.buffer.needsUpdate=!0),this.geometry.instanceCount=e,this.mesh.visible=e>0}dispose(){this.geometry.dispose(),this.material.dispose()}};var le={bombBlast:100,he:90,flash:85,fire:60,molotov:45,bombLed:40,muzzle:25,decoy:15};var mn=3,Xr=8,K0=.6,vo=9.8,$e=new Float64Array(3),_=new Float64Array(10),Yr=n=>n>1.5?Xr:mn;function Ho(n,t,o,e,s){let r=Yr(s);if(e<0||e>r)return;let c=n.batch,a=n.high,i=s,l=s>1.5?1.5:1,u=o.y,h=o.x,d=u+.35*i,m=o.z;bt(t,0,_,2);let p=i*i*(320*Math.exp(-e/.05)+60*Math.exp(-e/(.2*l))),b=xt(e/.25);if(n.lights.request(h,d+.5*i,m,1,.82-.3*b,.6-.42*b,p,16*i,i>1.5?le.bombBlast:le.he),e<.16*l){let x=1-e/(.16*l),T=c.start(mt,Q.core);T.x=h,T.y=d,T.z=m,T.w=T.h=(1.6+8*e)*i,T.rot=_[0]*6.28,T.r=4,T.g=3,T.b=2,T.a=x*x,c.push()}let f=a?16:9;for(let x=0;x<f;x++){bt(t,x+100,_,8);let T=e-_[0]*.04;if(T<=0)continue;let A=(.9+.5*_[1])*l;if(T>A)continue;let S=_[2]*Math.PI*2,q=.1+.9*_[3],j=Math.sqrt(1-q*q),G=i*(.9+.9*_[4])*Wt(T,.09*l),K=.06+.1*xt(T/A),B=c.start(ce,kt.puff+x%6);B.x=h+Math.cos(S)*j*G,B.y=d+q*G*.75+T*.7*i,B.z=m+Math.sin(S)*j*G,B.w=B.h=i*(1+.6*_[5])*(.5+1.25*Wt(T,.13*l)),B.rot=_[6]*6.28+T*.5,B.r=K,B.g=K*.92,B.b=K*.85,B.a=.92*(1-N(.45,1,T/A)),hn(Math.max(0,1.5*Math.exp(-T/((.18+.1*_[7])*l))-.06),$e),B.er=$e[0]*2.2,B.eg=$e[1]*2.2,B.eb=$e[2]*2.2,B.sunT=.6,B.amb=.6,B.erode=N(.3,1,T/A)*.6,c.push()}if(e<.5*l){let x=1-e/(.5*l),T=c.start(mt,Q.ring);T.x=h,T.y=u+.06,T.z=m,T.w=T.h=2*i*7.5*Wt(e,.13*l),T.rot=_[1]*6.28,T.r=1.3,T.g=1.05,T.b=.8,T.a=.5*x*x,T.mode=Fe,c.push()}if(e<.2*l){let x=c.start(mt,Q.ring);x.x=h,x.y=d,x.z=m,x.w=x.h=2*i*5*(e/(.2*l)),x.r=.8,x.g=.75,x.b=.7,x.a=.35*(1-e/(.2*l)),c.push()}let g=a?18:10,R=.7*N(0,.06,e)*xt(1-e/(2.2*l));if(R>0)for(let x=0;x<g;x++){bt(t,x+200,_,4);let T=x/g*Math.PI*2+(_[0]*2-1)*.3,A=i*(.6+(3.6+1.2*_[1])*Wt(e,.32*l)),S=c.start(ce,kt.dust+(x&1));S.x=h+Math.cos(T)*A,S.y=u+.3*i+.25*e,S.z=m+Math.sin(T)*A,S.w=S.h=i*(.9+1.9*Wt(e,.5*l))*(.8+.4*_[2]),S.rot=_[3]*6.28+e*.3,S.r=.5,S.g=.45,S.b=.38,S.a=R,S.sunT=.85,S.amb=.75,S.erode=xt(e/(2.2*l))*.6,S.ground=u-.05,c.push()}let E=Math.round((a?42:20)*(i>1.5?1.6:1)),M=2.2,P=(1-Math.exp(-M*e))/M,C=Math.exp(-M*e),v=Math.sqrt(i);for(let x=0;x<E;x++){bt(t,x+300,_,4);let T=(.35+.6*_[0])*l;if(e>T)continue;let A=_[1]*Math.PI*2,S=.05+.95*_[2],q=Math.sqrt(1-S*S),j=(6+13*_[3])*v,G=Math.cos(A)*q*j,K=S*j,B=Math.sin(A)*q*j,Y=G*C,Rt=K*C-vo*e,Ut=B*C,ee=Math.sqrt(Y*Y+Rt*Rt+Ut*Ut),pt=c.start(mt,Q.streak);pt.x=h+G*P,pt.y=Math.max(u+.02,d+K*P-.5*vo*e*e),pt.z=m+B*P,pt.w=Math.min(.9,Math.max(.1,ee*.06)),pt.h=.05,pt.r=7,pt.g=3.6,pt.b=1.2,pt.a=1-e/T,pt.mode=me,pt.ax=Y,pt.ay=Rt,pt.az=Ut,c.push()}let L=a?12:6;for(let x=0;x<L;x++){bt(t,x+400,_,5);let T=_[0]*Math.PI*2,A=(2.5+4*_[1])*v,S=(1.5+4*_[2])*v,q=2*A/vo,j=Math.min(e,q),G=c.start(To,kt.chunk);G.x=h+Math.cos(T)*S*j,G.y=Math.max(u+.04,d+A*j-.5*vo*j*j),G.z=m+Math.sin(T)*S*j,G.w=G.h=(.07+.08*_[3])*i,G.rot=e*9*(_[4]*2-1),G.r=.035,G.g=.032,G.b=.03,G.a=xt(1-(e-q)/.6),c.push()}i>1.5&&Zr(n,t,h,u,m,e,r);let z=Math.round((a?14:8)*(i>1.5?1.5:1)),H=r-.2;for(let x=0;x<z;x++){bt(t,x+500,_,10);let T=e-.06-.06*_[0];if(T<=0)continue;let A=.78*N(0,.12,T)*xt((H-T)/(H*.6));if(A<=.004)continue;let S=_[1]*Math.PI*2,q=.1+.9*_[2],j=Math.sqrt(1-q*q),G=i*(.8+1*_[3])*Wt(T,.25*l),K=.16+.16*xt(T/(1.5*l)),B=Math.exp(-T/(.1*l)),Y=c.start(ce,kt.puff+x%6);Y.x=h+Math.cos(S)*j*G+T*.15*(_[5]*2-1),Y.y=d+q*G*.7+(.25+.45*_[4])*T*v,Y.z=m+Math.sin(S)*j*G,Y.w=Y.h=i*(1.2+.7*_[6])*(.7+1.5*Wt(T,.7*l)),Y.rot=_[7]*6.28+T*.2*(_[8]*2-1),Y.r=K,Y.g=K*.94,Y.b=K*.88,Y.a=A,Y.er=1.2*B,Y.eg=.45*B,Y.eb=.1*B,Y.sunT=.55+.35*_[9],Y.amb=.55+.4*q,Y.erode=N(r*.25,r,T)*.85,c.push()}}function Zr(n,t,o,e,s,r,c){let a=n.batch,i=n.high?16:9;for(let l=0;l<i;l++){bt(t,l+600,_,6);let u=r-.08-.3*_[0];if(u<=0)continue;let h=.88*N(0,.3,u)*xt((c-.3-u)/(c*.45));if(h<=.004)continue;let d=l/(i-1),m=(.6+2.2*d*d)*Wt(u,1.4),p=_[1]*Math.PI*2,b=.2+.12*xt(u/3),f=a.start(ce,kt.puff+l%6);f.x=o+Math.cos(p)*m+u*.25*(_[2]*2-1),f.y=e+1.2+Wt(u,1.1)*(1.5+7.5*d),f.z=s+Math.sin(p)*m+u*.25*(_[3]*2-1),f.w=f.h=(2.4+2.6*d)*(.55+.9*Wt(u,1.2)),f.rot=_[4]*6.28+u*.15*(_[5]*2-1),f.r=b,f.g=b*.93,f.b=b*.85,f.a=h,hn(Math.max(0,1.1*Math.exp(-u/.35)-.05)*(1-d*.6),$e),f.er=$e[0]*1.8,f.eg=$e[1]*1.8,f.eb=$e[2]*1.8,f.sunT=.6+.35*d,f.amb=.5+.4*d,f.erode=N(c*.4,c,u)*.85,a.push()}}function ds(n,t,o,e){if(e<0||e>K0)return;let s=n.batch,r=o.x,c=o.y,a=o.z;n.lights.request(r,c+.3,a,1,.98,.94,380*Math.exp(-e/.035)+30*Math.exp(-e/.15),20,le.flash),bt(t,0,_,1);let i=_[0]*6.28,l=Math.exp(-e/.06),u=Math.exp(-e/.1),h=s.start(mt,Q.core);h.x=r,h.y=c,h.z=a,h.w=h.h=1.1+2*e,h.r=12*l,h.g=12*l,h.b=13*l,s.push(),h=s.start(mt,Q.star4),h.x=r,h.y=c,h.z=a,h.w=h.h=4,h.rot=i,h.r=3.2*l,h.g=3.2*l,h.b=3.5*l,s.push(),h=s.start(mt,Q.star6),h.x=r,h.y=c,h.z=a,h.w=h.h=6,h.rot=i+.4,h.r=.8*l,h.g=.8*l,h.b=.9*l,s.push(),h=s.start(mt,Q.ring),h.x=r,h.y=c,h.z=a,h.w=h.h=1.5+10*e,h.rot=i,h.r=.8*u,h.g=.8*u,h.b=.9*u,s.push();for(let m=0;m<(n.high?14:7);m++){bt(t,m+100,_,4);let p=.15+.12*_[0];if(e>p)continue;let b=_[1]*Math.PI*2,f=(_[2]*2-1)*.8,g=Math.sqrt(1-f*f),R=(9+8*_[3])*e;h=s.start(mt,Q.streak),h.x=r+Math.cos(b)*g*R,h.y=c+f*R,h.z=a+Math.sin(b)*g*R,h.w=.45,h.h=.04,h.r=6,h.g=6,h.b=5,h.a=1-e/p,h.mode=me,h.ax=Math.cos(b)*g,h.ay=f,h.az=Math.sin(b)*g,s.push()}let d=e-.02;if(!(d<=0))for(let m=0;m<(n.high?6:3);m++){bt(t,m+200,_,2);let p=_[0]*Math.PI*2,b=.35*Wt(d,.1);h=s.start(ce,kt.puff+m),h.x=r+Math.cos(p)*b,h.y=c+.1+d*.4,h.z=a+Math.sin(p)*b,h.w=h.h=.5+1.1*Wt(d,.15),h.rot=_[1]*6.28,h.r=h.g=h.b=.7,h.a=.5*xt(1-e/K0),h.sunT=.85,h.amb=.8,h.er=h.eg=h.eb=1.5*l,h.erode=e/K0*.6,s.push()}}var Ao=4,ko=1,zo=2.6,a0=new Float64Array(8),he=new Float64Array(4),Kt=new Float64Array(6);function fs(n,t,o,e,s){if(e<0||s<-Ao)return;let r=n.batch,c=n.high,a=c?10:7,i=o.x,l=o.z,u=o.y,h=xt(s/.8),d=.82+.18*v0(e,t),m=N(0,ko,e);if(h>0){let f=24*h*(.35+.65*m)*d;n.lights.request(i+v0(e*.7,t+3)*.15,u+.9,l+v0(e*.8,t+5)*.15,1,.52,.2,f,11,le.fire)}for(let f=0;f<a;f++){bt(t,f,a0,8);let g=i,R=l,E=0;if(f>0){let H=f/(a-1)*Math.PI*2+(a0[1]*2-1)*.5,x=.9+(zo-.9)*Math.sqrt(a0[2]);g+=Math.cos(H)*x,R+=Math.sin(H)*x,E=.1+(ko-.25)*(x/zo)}let M=N(E,E+.35,e);if(M<=0)continue;let P=f===0?.75:.6,C=xt((s+a0[3]*.5)/.8),v=r.start(To,kt.scorch+(f&1));if(v.x=g,v.y=u+.025+f*.001,v.z=R,v.w=v.h=2.4+P,v.rot=a0[4]*6.28,v.r=.022,v.g=.018,v.b=.014,v.a=.82*M*xt(1+s/Ao),v.mode=Fe,r.push(),s<0&&s>-2){let H=1+s/2;v=r.start(r0,Q.fireball+(f&1)),v.x=g,v.y=u+.04,v.z=R,v.w=v.h=1.1,v.rot=a0[5]*6.28,v.a=.6*H*H,v.heat=.5,v.mode=Fe,r.push()}let L=M*C;if(L<=0)continue;v=r.start(r0,Q.fireball+(f&1)),v.x=g,v.y=u+.035,v.z=R,v.w=v.h=1.9*P+.6,v.rot=a0[6]*6.28+e*.1,v.a=L,v.heat=.62*d,v.mode=Fe,r.push(),v=r.start(mt,Q.disc),v.x=g,v.y=u+.05,v.z=R,v.w=v.h=3.6*P+1.2,v.r=.9*d,v.g=.32*d,v.b=.08*d,v.a=.55*L,v.mode=Fe,r.push();let z=c?9:5;for(let H=0;H<z;H++){let x=f*16+H;bt(t,x+1e3,he,4);let T=.5+.35*he[0],A=(e+he[1]*T)/T,S=Math.floor(A),q=A-S;bt(t*7919+x,S,Kt,3);let j=Kt[0]*Math.PI*2,G=Math.sqrt(Kt[1])*P,K=.75+.5*Kt[2],B=(.62+.4*K)*Math.pow(Q0(Math.pow(q,.55)),.6)*L;if(B<=.02)continue;let Y=B*(1.45+.35*he[2]),Rt=Math.pow(q,.9)*(.45+.55*K)*L;v=r.start(r0,Q.flame+(x&3)),v.x=g+Math.cos(j)*G+Math.sin(q*3+x)*.1,v.y=u+.02+Rt+Y*.42,v.z=R+Math.sin(j)*G,v.w=B,v.h=Y,v.rot=(he[3]*2-1)*.2,v.a=.7,v.heat=(.95-.68*q)*d*(.85+.25*K),v.occlude=.3,r.push()}}if(h<=0&&s<-2)return;let p=c?36:14;for(let f=0;f<p;f++){bt(t,f+2e3,he,2);let g=1.1+.8*he[0],R=(e+he[1]*g)/g,E=Math.floor(R),M=(R-E)*g,P=e-M;if(P<.2||s+M<-.5)continue;bt(t*104729+f,E,Kt,4);let C=Kt[0]*Math.PI*2,v=Math.sqrt(Kt[1])*zo*N(0,ko,P),L=1.3+1.4*Kt[2],z=.25+.3*Kt[3],H=1-M/g,x=r.start(mt,Q.streak);x.x=i+Math.cos(C)*v+Math.sin(M*4.5+f)*z*M,x.y=u+.2+L*M-.25*M*M,x.z=l+Math.sin(C)*v+Math.cos(M*3.7+f)*z*M,x.w=.11,x.h=.035,x.r=4.5,x.g=1.7,x.b=.45,x.a=H*H,x.mode=me,x.ax=Math.cos(M*4.5+f)*z*4.5*M,x.ay=L-.5*M,x.az=-Math.sin(M*3.7+f)*z*3.7*M,r.push()}let b=c?18:9;for(let f=0;f<b;f++){bt(t,f+3e3,he,4);let g=2.4+.8*he[0],R=(e+he[1]*g)/g,E=Math.floor(R),M=R-E,P=e-M*g;if(P<.3||s+M*g<-1.5)continue;bt(t*15485863+f,E,Kt,5);let C=Kt[0]*Math.PI*2,v=Math.sqrt(Kt[1])*zo*.8*N(0,ko,P),L=1+2*M,z=(1-M)*(1-M)*h*d,H=r.start(ce,kt.wisp+(f&1));H.x=i+Math.cos(C)*v+M*.4*(Kt[2]*2-1),H.y=u+.9+M*(2.6+Kt[4]),H.z=l+Math.sin(C)*v+M*.4*(Kt[3]*2-1),H.w=H.h=L,H.rot=he[2]*6.28+M,H.r=.035,H.g=.032,H.b=.03,H.a=.55*Q0(Math.min(1,M*1.25))*(h>0?1:.5),H.er=.35*z,H.eg=.12*z,H.eb=.03*z,H.sunT=.6,H.amb=.5,H.erode=M*.5,r.push()}}import*as Co from"three";var Vo=128,So=9,Po=class{lights=[];group=new Co.Group;requests=0;used=0;req=new Float32Array(Vo*So);order=new Int32Array(Vo);score=new Float32Array(Vo);constructor(t){this.group.name="cs2r-fx-lights";for(let o=0;o<t;o++){let e=new Co.PointLight(16777215,0,1,2);e.name=`cs2r-fx-light-${o}`,e.castShadow=!1,this.lights.push(e),this.group.add(e)}}begin(){this.requests=0}request(t,o,e,s,r,c,a,i,l){if(a<=.01||this.requests>=Vo)return;let u=this.requests++*So,h=this.req;h[u]=t,h[u+1]=o,h[u+2]=e,h[u+3]=s,h[u+4]=r,h[u+5]=c,h[u+6]=a,h[u+7]=i,h[u+8]=l}commit(t,o){let e=this.requests,s=this.req,r=this.order,c=this.score;for(let i=0;i<e;i++){let l=i*So,u=s[l]-t.x,h=s[l+1]-t.y,d=s[l+2]-t.z,m=u*u+h*h+d*d;c[i]=s[l+8]*1e3+Math.min(999,s[l+6]*100/(100+m)),r[i]=i}let a=Math.min(e,this.lights.length);for(let i=0;i<a;i++){let l=i;for(let h=i+1;h<e;h++)c[r[h]]>c[r[l]]&&(l=h);let u=r[i];r[i]=r[l],r[l]=u}for(let i=0;i<this.lights.length;i++){let l=this.lights[i];if(i<a){let u=r[i]*So;l.position.set(s[u],s[u+1],s[u+2]),l.color.setRGB(s[u+3],s[u+4],s[u+5]),l.intensity=s[u+6],l.distance=s[u+7],o?.(i,s[u],s[u+1],s[u+2],s[u+3]*s[u+6],s[u+4]*s[u+6],s[u+5]*s[u+6],s[u+7])}else l.intensity=0,o?.(i,0,-1e4,0,0,0,0,1)}this.used=a}dispose(){for(let t of this.lights)t.dispose()}};import*as $ from"three";import{mergeGeometries as $r}from"three/addons/utils/BufferGeometryUtils.js";function lt(n,t,o=0,e=0,s=0,r=0,c=0){let a=n;(r||c)&&a.applyMatrix4(new $.Matrix4().makeRotationFromEuler(new $.Euler(r,0,c))),a.translate(o,e,s);let i=new $.Color(t),l=a.attributes.position.count,u=new Float32Array(l*3);for(let h=0;h<l;h++)u[h*3]=i.r,u[h*3+1]=i.g,u[h*3+2]=i.b;return a.setAttribute("color",new $.BufferAttribute(u,3)),a.deleteAttribute("uv"),a}var Xt=(n,t,o=14)=>new $.CylinderGeometry(n,n,t,o);function Je(n){let t=$r(n.map(o=>o.index?o.toNonIndexed():o));return n.forEach(o=>o.dispose()),t.computeBoundingSphere(),t}var Lo=(n,t)=>[lt(Xt(t*.55,.016,10),2829358,0,n+.008,0),lt(new $.BoxGeometry(.007,.08,.013),9278102,t+.004,n-.03,0),lt(new $.TorusGeometry(.009,.0018,6,12),12172737,-t*.4,n+.02,0,Math.PI/2)];function Es(n){switch(n){case"smoke":return Je([lt(Xt(.03,.11),4936265,0,0,0),lt(Xt(.0305,.014),13948889,0,.034,0),lt(Xt(.0305,.006),2303530,0,-.05,0),...Lo(.055,.03)]);case"flash":return Je([lt(Xt(.026,.105),10725806,0,0,0),lt(Xt(.0265,.01),3356733,0,.04,0),lt(Xt(.0265,.01),3356733,0,-.04,0),...Lo(.0525,.026)]);case"he":{let t=new $.SphereGeometry(.036,14,10);return t.scale(1,1.18,1),Je([lt(t,4608815,0,0,0),lt(Xt(.014,.012),3093796,0,.042,0),...Lo(.048,.02)])}case"fire":return Je([lt(Xt(.034,.11,16),8016416,0,0,0),lt(new $.CylinderGeometry(.013,.034,.035,16),8016416,0,.0725,0),lt(Xt(.013,.04),8016416,0,.11,0),lt(new $.CylinderGeometry(.02,.012,.04,8),13482904,0,.14,0),lt(Xt(.0345,.04,16),14208952,0,-.01,0)]);case"decoy":return Je([lt(Xt(.028,.1),3226924,0,0,0),lt(Xt(.0285,.016),12561991,0,.02,0),lt(Xt(.0285,.006),1843227,0,-.045,0),...Lo(.05,.028)]);default:return Je([lt(new $.SphereGeometry(.03,12,8),8225415)])}}var X0=new $.Vector3(-.045,.112,.032);function ys(){return Je([lt(new $.BoxGeometry(.28,.07,.16),8090196,0,.035,0),lt(new $.BoxGeometry(.026,.074,.164),2368548,-.085,.035,0),lt(new $.BoxGeometry(.026,.074,.164),2368548,.085,.035,0),lt(new $.BoxGeometry(.13,.036,.105),2764339,0,.088,0),lt(new $.BoxGeometry(.06,.004,.07),6975866,.03,.108,0),lt(new $.BoxGeometry(.038,.004,.05),1916202,-.035,.108,-.01),lt(new $.CylinderGeometry(.004,.004,.09,6),11022888,-.06,.075,.06,0,Math.PI/2.6),lt(new $.CylinderGeometry(.004,.004,.09,6),2903968,-.06,.075,.05,0,Math.PI/2.4),lt(new $.CylinderGeometry(.006,.006,.006,8),3804943,X0.x,X0.y-.003,X0.z)])}function gs(){return Je([lt(Xt(.0045,.02,8),13214796,0,0,0,0,Math.PI/2)])}var z0=["smoke","flash","he","fire","decoy","other"],bs=new $.Matrix4,Jr=new $.Quaternion,ta=new $.Vector3,ea=new $.Vector3,k0=class{mesh;count=0;constructor(t,o,e,s){this.mesh=new $.InstancedMesh(t,o,e),this.mesh.name=s,this.mesh.frustumCulled=!1,this.mesh.instanceMatrix.setUsage($.DynamicDrawUsage),this.mesh.count=0}begin(){this.count=0}add(t,o,e,s,r){this.count>=this.mesh.instanceMatrix.count||(bs.compose(ea.set(t,o,e),Jr.copy(s),ta.setScalar(r)),this.mesh.setMatrixAt(this.count++,bs))}finish(){this.mesh.count=this.count,this.mesh.visible=this.count>0,this.count&&(this.mesh.instanceMatrix.clearUpdateRanges(),this.mesh.instanceMatrix.addUpdateRange(0,this.count*16),this.mesh.instanceMatrix.needsUpdate=!0)}dispose(){this.mesh.geometry.dispose(),this.mesh.dispose()}};import*as te from"three";var i0=9.8,be=new te.Quaternion,Ms=new te.Quaternion,Be=new te.Vector3,pe=new te.Vector3,fn=new te.Vector3(0,1,0);function Rs(n,t,o,e,s){if(e<0||s<0)return;be.setFromAxisAngle(Be.set(1,0,0),Math.PI/2),Ms.setFromAxisAngle(fn,Ct(t,0,1)*Math.PI*2),be.premultiply(Ms);let r=n.projectileScale;n.props.decoy.add(o.x,o.y+.028*r,o.z,be,r);let c=.5;for(let a=0;c<=e&&a<200;a++){let i=1+Math.floor(Ct(t,a,2)*4),l=.09+.07*Ct(t,a,3);for(let u=0;u<i;u++){let h=e-(c+u*l);h>=0&&h<.2&&oa(n,t*977+a*8+u,o,h)}c+=i*l+.6+1.6*Ct(t,a,4)}}function oa(n,t,o,e){let s=n.batch,r=o.y+.08;if(e<.06){let c=1-e/.06,a=s.start(mt,Q.muzzle);a.x=o.x,a.y=r,a.z=o.z,a.w=a.h=.42,a.rot=Ct(t,1)*6.28,a.r=5*c,a.g=3.6*c,a.b=2*c,s.push(),n.lights.request(o.x,r+.2,o.z,1,.7,.4,8*c,4,le.decoy)}for(let c=0;c<5;c++){let a=.12+.08*Ct(t,c,2);if(e>a)continue;let i=Ct(t,c,3)*Math.PI*2,l=1+2.5*Ct(t,c,4),u=1.5+2*Ct(t,c,5),h=s.start(mt,Q.streak);h.x=o.x+Math.cos(i)*u*e,h.y=r+l*e-.5*i0*e*e,h.z=o.z+Math.sin(i)*u*e,h.w=.12,h.h=.025,h.r=4,h.g=2.4,h.b=1,h.a=1-e/a,h.mode=me,h.ax=Math.cos(i)*u,h.ay=l-i0*e,h.az=Math.sin(i)*u,s.push()}}var na={smoke:[.5,.52,.55],flash:[.7,.72,.78],he:[.62,.58,.45],fire:[1.2,.5,.15],decoy:[.45,.55,.42],other:[.5,.5,.5]};function Ts(n,t,o,e,s){let r=n.projectileScale,c=9+6*Ct(t,0,3);Be.set(xo(t,0,4),xo(t,0,5)*.3,xo(t,0,6)),Be.lengthSq()<1e-4&&Be.set(1,0,0),be.setFromAxisAngle(Be.normalize(),n.time*c%(Math.PI*2)),n.props[o].add(e.x,e.y,e.z,be,r);let a=n.batch,i=s?s.length():0;if(s&&i>.5){let l=Math.min(1.8,i*.09);pe.copy(s).multiplyScalar(-1/i);let u=na[o],h=a.start(mt,Q.tracer);h.x=e.x+pe.x*l*.5,h.y=e.y+pe.y*l*.5,h.z=e.z+pe.z*l*.5,h.w=l,h.h=.07*r,h.r=u[0],h.g=u[1],h.b=u[2],h.a=.5,h.mode=me,h.ax=-pe.x,h.ay=-pe.y,h.az=-pe.z,a.push()}if(o==="fire"){let l=.8+.2*v0(n.time*1.7,t);pe.set(0,.14*r,0).applyQuaternion(be);let u=e.x+pe.x,h=e.y+pe.y,d=e.z+pe.z,m=a.start(r0,Q.flame+(t&3));if(m.x=u,m.y=h+.08,m.z=d,m.w=.16*r*l,m.h=.26*r*l,m.heat=1.2*l,a.push(),m=a.start(mt,Q.soft),m.x=u,m.y=h,m.z=d,m.w=m.h=.5,m.r=.5*l,m.g=.2*l,m.b=.05*l,a.push(),s&&i>.5)for(let p=1;p<=3;p++){let b=p*.12,f=1-p/4;m=a.start(r0,Q.flame+(t+p&3)),m.x=u-s.x/i*b,m.y=h-s.y/i*b+.05,m.z=d-s.z/i*b,m.w=.14*f*r,m.h=.2*f*r,m.a=f,m.heat=.9*f*l,a.push()}n.lights.request(u,h,d,1,.55,.22,3*l,4,le.molotov)}}var Z0=40,sa=43,ws=8,ra=n=>sa*Math.log((Z0+ws)/Math.max(.001,Z0-Math.min(n,Z0)+ws)),aa=.6,Ot=new te.Vector3;function vs(n,t,o){let e=t.state;if(e==="hidden"||e==="carried")return;let s=t.position,r=n.bombScale,c=e==="exploded",a=c?t.sinceExplode??Math.max(0,t.sincePlant-Z0):0;be.setFromAxisAngle(fn,aa),o&&(!c||a<.03)&&n.bomb.add(s.x,s.y,s.z,be,r),Ot.copy(X0).multiplyScalar(r).applyQuaternion(be).add(s);let i=n.batch;if(e==="planted"){let l=t.sincePlant,u=ra(l),h=u-Math.floor(u),d=Math.exp(-h*9);l>Z0-1&&(d=Math.max(d,.6+.4*Math.sin(l*60)));let m=i.start(mt,Q.core);m.x=Ot.x,m.y=Ot.y+.01,m.z=Ot.z,m.w=m.h=.1+.3*d,m.r=.3+7*d,m.g=.02+.35*d,m.b=.01+.2*d,i.push(),n.lights.request(Ot.x,Ot.y+.15,Ot.z,1,.07,.04,.15+2.2*d,2.5,le.bombLed)}else if(e==="defused"){let l=i.start(mt,Q.core);l.x=Ot.x,l.y=Ot.y+.01,l.z=Ot.z,l.w=l.h=.12,l.r=.05,l.g=.9,l.b=.25,i.push();let u=t.sinceDefuse;if(u!==void 0&&u>=0&&u<1.2){let h=1-u/1.2;l=i.start(mt,Q.ring),l.x=s.x,l.y=s.y+.04,l.z=s.z,l.w=l.h=2*(.3+2.2*Wt(u,.25)),l.r=.25,l.g=1.4,l.b=.7,l.a=h*h,l.mode=Fe,i.push(),l=i.start(mt,Q.soft),l.x=Ot.x,l.y=Ot.y+.05,l.z=Ot.z,l.w=l.h=.8,l.r=.2*h,l.g=1.6*h,l.b=.6*h,i.push(),n.lights.request(Ot.x,Ot.y+.3,Ot.z,.3,1,.55,5*h,4,le.bombLed)}}else c&&Ho(n,2827,s,a,2.6)}var pn={pistol:{flash:.3,dur:.04,light:6,tracerW:.024,tracerI:3.2,pellets:1,spread:0},smg:{flash:.32,dur:.04,light:6,tracerW:.024,tracerI:3.4,pellets:1,spread:0},rifle:{flash:.45,dur:.05,light:9,tracerW:.03,tracerI:4.5,pellets:1,spread:0},heavy:{flash:.5,dur:.05,light:10,tracerW:.032,tracerI:4.5,pellets:1,spread:0},sniper:{flash:.7,dur:.06,light:15,tracerW:.045,tracerI:6,pellets:1,spread:0},shotgun:{flash:.62,dur:.06,light:12,tracerW:.018,tracerI:2.4,pellets:8,spread:.045}},ia={mg:"heavy",machinegun:"heavy",lmg:"heavy",ar:"rifle",awp:"sniper",ssg08:"sniper"},xs=new Map;function ca(n){if(!n)return pn.rifle;let t=xs.get(n);if(!t){let o=n.toLowerCase();t=pn[ia[o]??o]??pn.rifle,xs.set(n,t)}return t}var dn=380,la=60,Et=new te.Vector3,ke=new te.Vector3,A0=new te.Vector3,ne=new te.Vector3,de=new te.Vector3,fe=new te.Vector3,Ie=new Float64Array(12),Fo=new Float64Array(3),Y0=new Float64Array(5);function Hs(n,t){let o=t.age;if(o<0||o>1.6)return;let e=ca(t.weaponClass);if(Et.copy(t.direction),Et.lengthSq()<1e-8)return;if(Et.normalize(),ke.crossVectors(Et,fn),ke.lengthSq()<1e-6&&ke.set(1,0,0),ke.normalize(),A0.crossVectors(ke,Et),t.muzzle)ne.copy(t.muzzle);else{let a=n.muzzle;ne.copy(t.origin).addScaledVector(Et,a[0]).addScaledVector(ke,a[1]).addScaledVector(A0,a[2])}let s=n.batch,r=t.id;if(bt(r,20743,Ie,12),o<e.dur&&t.flash!==!1){let a=1-o/e.dur,i=t.view,l=i?i.scale:1;i?de.copy(ne).sub(i.eye).multiplyScalar(l).add(i.eye):de.copy(ne);let u=e.flash*(.8+.4*Ie[0])*(.7+.3*a)*l,h=s.start(mt,Q.muzzle);h.x=de.x+Et.x*u*.2,h.y=de.y+Et.y*u*.2,h.z=de.z+Et.z*u*.2,h.w=h.h=u,h.rot=Ie[1]*6.28,h.r=6*a,h.g=4.2*a,h.b=2*a,h.near=l,s.push();let d=e.flash*1.6*l;h=s.start(mt,Q.muzzleSide),h.x=de.x+Et.x*d*.5,h.y=de.y+Et.y*d*.5,h.z=de.z+Et.z*d*.5,h.w=d,h.h=e.flash*.7*l,h.r=4.5*a,h.g=2.8*a,h.b=1.1*a,h.mode=me,h.ax=Et.x,h.ay=Et.y,h.az=Et.z,h.near=l,s.push();let m=i?.12:.3;n.lights.request(de.x+Et.x*m,de.y+Et.y*m,de.z+Et.z*m,1,.72,.42,e.light*a,5,le.muzzle)}let c=t.distance??la;for(let a=0;a<e.pellets;a++){fe.copy(Et),e.spread>0&&(bt(r,a,Fo,3),fe.addScaledVector(ke,(Fo[0]*2-1)*e.spread).addScaledVector(A0,(Fo[1]*2-1)*e.spread).normalize());let i=c*(e.spread>0?.9+.2*Fo[2]:1),l=e.tracerW>.03?7:4,u=Math.min(i,dn*o),h=Math.max(0,Math.min(i,dn*o-l));if(u-h>.05){let d=(u+h)*.5,m=1-h/i,p=s.start(mt,Q.tracer);p.x=ne.x+fe.x*d,p.y=ne.y+fe.y*d,p.z=ne.z+fe.z*d,p.w=u-h,p.h=e.tracerW*(1+d*.01),p.r=e.tracerI,p.g=e.tracerI*.78,p.b=e.tracerI*.45,p.a=.5+.5*m,p.mode=me,p.ax=fe.x,p.ay=fe.y,p.az=fe.z,s.push()}if(t.distance!==void 0){let d=o-i/dn;d>=0&&d<.25&&ha(n,r*31+a,ne.x+fe.x*i,ne.y+fe.y*i,ne.z+fe.z*i,d)}}if(n.brass&&!t.view&&o<1.4){let a=t.groundY??t.origin.y-1.6,i=ke.x*1.7+A0.x*1.4-Et.x*.3+(Ie[2]*2-1)*.3,l=ke.y*1.7+A0.y*1.4-Et.y*.3+.3*Ie[3],u=ke.z*1.7+A0.z*1.4-Et.z*.3+(Ie[4]*2-1)*.3,h=ne.y-Et.y*.35,d=l*l+2*i0*Math.max(0,h-a),m=(l+Math.sqrt(d))/i0,p=Math.min(o,m),b=ne.x-Et.x*.35+i*p,f=ne.z-Et.z*.35+u*p,g=Math.max(a+.006,h+l*p-.5*i0*p*p);Be.set(Ie[5]*2-1,Ie[6]*2-1,Ie[7]*2-1),Be.lengthSq()<1e-4&&Be.set(0,0,1),be.setFromAxisAngle(Be.normalize(),p*28);let R=xt((1.4-o)/.3);n.brass.add(b,g,f,be,1.3*R)}}function ha(n,t,o,e,s,r){let c=n.batch;if(r<.05){let a=1-r/.05,i=c.start(mt,Q.core);i.x=o,i.y=e,i.z=s,i.w=i.h=.35,i.r=4*a,i.g=3*a,i.b=2*a,c.push()}for(let a=0;a<4;a++){bt(t,a,Y0,4);let i=.1+.12*Y0[0];if(r>i)continue;let l=(Y0[1]*2-1)*3,u=1+2*Y0[2],h=(Y0[3]*2-1)*3,d=c.start(mt,Q.streak);d.x=o+l*r,d.y=e+u*r-.5*i0*r*r,d.z=s+h*r,d.w=.1,d.h=.02,d.r=4,d.g=2.6,d.b=1.2,d.a=1-r/i,d.mode=me,d.ax=l,d.ay=u-i0*r,d.az=h,c.push()}if(r<.25){let a=c.start(ce,kt.dust+(t&1));a.x=o,a.y=e+r*.3,a.z=s,a.w=a.h=.25+.5*Wt(r,.08),a.rot=t%7*.9,a.r=.55,a.g=.52,a.b=.48,a.a=.5*(1-r/.25),a.sunT=.8,a.amb=.8,c.push()}}var ua=2.6,bn=2.75,En=2.2,ks=.45,ma=.85,Vt=new Float64Array(16);function zs(n,t,o,e,s,r){if(e<0||s<=0)return;let c=n.batch,a=n.high?110:56,i=n.high?1.08:1.3,l=Math.round(a*.26),u=xt(1-s/ua),h=.8,d=.81,m=.82;r&&(h+=(r.r-h)*.18,d+=(r.g-d)*.18,m+=(r.b-m)*.18);let p=o.x,b=o.z,f=o.y,g=f+ks+En*.4,R=bn+.7,E=En*.7+.5,M=n.sunDir,P=M.x/R,C=M.y/E,v=M.z/R,L=Math.sqrt(P*P+C*C+v*v);P/=L,C/=L,v/=L;for(let z=0;z<a;z++){bt(t,z,Vt,16);let H=z<l,x=0,T=0,A=0;if(H){let D=Vt[1]*Math.PI*2,et=.1+.5*Math.sqrt(Vt[2]);x=Math.cos(D)*et,A=Math.sin(D)*et,T=.12+.5*Vt[3]}else{let D=z-l,et=a-l,Tt=Math.min(.995,(D+.5)/et+(Vt[3]*2-1)*.03),vt=Math.sqrt(1-Tt*Tt),ze=Math.pow(vt*vt*vt+Tt*Tt*Tt,-1/3),c0=D*2.39996323+Vt[1]*.7,S0=(.86+.18*Vt[2])*ze;x=Math.cos(c0)*vt*S0,A=Math.sin(c0)*vt*S0,T=Tt*S0}let S=Math.min(1,Math.sqrt(x*x+T*T+A*A)),q=.02+.28*S+.1*Vt[4],j=e-q;if(j<=0)continue;let G=xt(j/(.7+.5*Vt[5])),K=ls(G),B=f+.15,Y=p+x*bn*K,Rt=B+(f+ks+T*En-B)*K+Q0(G)*.45*(1-.5*S),Ut=b+A*bn*K,ee=.16+.22*Vt[6],pt=Vt[7]*Math.PI*2,oe=(.12+.2*Vt[8])*K;Y+=Math.sin(e*ee+pt)*oe,Rt+=Math.sin(e*ee*.73+pt*1.7)*oe*.45,Ut+=Math.cos(e*ee*.89+pt*.6)*oe;let jt=(H?2.9+.6*Vt[11]:2.1+.8*Vt[11])*i;jt*=.3+.7*Math.pow(K,.6);let Nt=(H?.88:.74)*N(0,.12,j),Ee=0;if(u>0){let D=H?.3+.35*Vt[12]:.4*Vt[12]*(1-T*.5),et=xt((u*1.4-D)/.6);Ee=Math.min(.97,u*.3+et*.75),Nt*=1-et*et*et,Rt+=u*u*(.4+.6*T),jt*=1+.22*u}if(Nt<=.004)continue;let Lt=(Y-p)/R,Yt=(Rt-g)/E,Ft=(Ut-b)/R,It=Lt*P+Yt*C+Ft*v,qe=Lt*Lt+Yt*Yt+Ft*Ft-1,ye=Math.max(0,-It+Math.sqrt(Math.max(0,It*It-qe)))/L,ge=.08+.92*Math.exp(-ye*ma*(.4+.6*K));ge+=(1-ge)*u*.5;let ue=Math.sqrt(x*x+A*A),Me=.3+.7*xt(.6*T+.55*ue)+u*.2,ot=.97+.06*Vt[13],zt=H?kt.puff+z%6:Vt[14]<.7?kt.puff+Math.floor(Vt[15]*6):kt.wisp+(z&1),yt=c.start(ce,zt);yt.x=Y,yt.y=Rt,yt.z=Ut,yt.w=yt.h=jt,yt.rot=Vt[9]*Math.PI*2+e*(Vt[10]*2-1)*.12,yt.r=h*ot,yt.g=d*ot,yt.b=m*ot,yt.a=Nt,yt.sunT=ge,yt.amb=Math.min(1,Me),yt.erode=Ee,yt.ground=f-.05,c.push()}}function Vs(n,t){switch(n){case"he":return mn;case"flash":return K0;case"fire":return t+Ao;default:return t}}var As=new Gt.Vector3,yn=new Gt.Vector3,pa=new Gt.Vector3,Io=class{object=new Gt.Group;batch;pool;smokeAtlas;glowAtlas;propMaterial;props;brass;bombProp;ctx;showBomb;lighting={};sunDir=new Gt.Vector3(.45,.8,.35).normalize();sunColor=new Gt.Color(3,3,3);sky=new Gt.Color(.55,.6,.7);groundCol=new Gt.Color(.3,.27,.24);ambient=new Gt.Color(.25,.25,.25);particleLighting={sunDir:this.sunDir,sunColor:this.sunColor,sky:this.sky,ground:this.groundCol,ambient:this.ambient};vel=new Map;velOut=new Gt.Vector3;frameNo=0;volumes=null;smokeInputs=[];onLight;constructor(t={}){let o=(t.quality??"high")==="high",e=Math.max(0,Math.min(16,t.maxLights??(o?6:4)));this.object.name="cs2r-fx",this.smokeAtlas=ms(),this.glowAtlas=ps(),this.batch=new Ro(o?2048:1024,e,this.smokeAtlas,this.glowAtlas),this.pool=new Po(e),this.propMaterial=new Gt.MeshStandardMaterial({vertexColors:!0,roughness:.5,metalness:.3,name:"cs2r-fx-props"}),this.props={};for(let r of z0)this.props[r]=new k0(Es(r),this.propMaterial,24,`cs2r-fx-grenade-${r}`),this.object.add(this.props[r].mesh);this.brass=t.brass??o?new k0(gs(),this.propMaterial,64,"cs2r-fx-brass"):null,this.brass&&this.object.add(this.brass.mesh),this.bombProp=new k0(ys(),this.propMaterial,1,"cs2r-fx-bomb"),this.showBomb=t.bombModel??!0,this.object.add(this.bombProp.mesh,this.batch.mesh,this.pool.group),this.ctx={batch:this.batch,lights:this.pool,props:this.props,brass:this.brass,bomb:this.bombProp,high:o,camPos:new Gt.Vector3,sunDir:this.sunDir,time:0,projectileScale:t.projectileScale??1.6,bombScale:t.bombScale??1.3,muzzle:t.muzzleOffset??[.55,.12,-.12]};let s=this.batch;this.onLight=(r,c,a,i,l,u,h,d)=>s.setLight(r,c,a,i,l,u,h,d)}compile(t,o,e,s){let r=[this.batch.mesh,this.bombProp.mesh,...z0.map(d=>this.props[d].mesh)];this.brass&&r.push(this.brass.mesh);let c=r.map(d=>d.visible);r.forEach(d=>d.visible=!0);let a=this.object;for(;a.parent;)a=a.parent;let i=e??(a.isScene?a:null),l=this.object.parent,u=l?l.children.indexOf(this.object):-1;l?.remove(this.object);let h=t.getRenderTarget();s!==void 0&&t.setRenderTarget(s);try{t.compile(this.object,o,i)}finally{s!==void 0&&t.setRenderTarget(h),l&&(l.add(this.object),l.children.splice(l.children.length-1,1),l.children.splice(u,0,this.object)),r.forEach((d,m)=>d.visible=c[m])}}setSmokeVolumes(t){this.volumes=t}setLighting(t){this.lighting={...t}}get stats(){return{particles:this.batch.count,particleCapacity:this.batch.capacity,lights:this.pool.used,lightRequests:this.pool.requests,lightPool:this.pool.lights.length}}update(t){this.frameNo++;let o=this.ctx,e=t.camera;e.updateMatrixWorld(),o.camPos.setFromMatrixPosition(e.matrixWorld),As.set(0,0,-1).transformDirection(e.matrixWorld),o.time=t.time,this.resolveLighting(t.sunDirection),this.batch.begin(),this.pool.begin();for(let r of z0)this.props[r].begin();this.brass?.begin(),this.bombProp.begin();let s=this.smokeInputs;s.length=0;for(let r of t.grenades){if(r.projectile){let a=r.velocity??this.estimateVelocity(r.id,r.projectile,t.time);Ts(o,r.id,r.kind,r.projectile,a)}let c=r.effect;if(c)switch(c.kind){case"smoke":this.volumes?s.push({id:r.id,center:r.voxels?.center??c.position,voxels:r.voxels?.data??null,age:c.age,remaining:c.remaining}):zs(o,r.id,c.position,c.age,c.remaining,r.color);break;case"fire":fs(o,r.id,c.position,c.age,c.remaining);break;case"he":Ho(o,r.id,c.position,c.age,1);break;case"flash":ds(o,r.id,c.position,c.age);break;case"decoy":Rs(o,r.id,c.position,c.age,c.remaining);break;default:break}}if(this.volumes?.update(s,t.blasts??[]),this.vel.size)for(let[r,c]of this.vel)c.seen!==this.frameNo&&this.vel.delete(r);for(let r of t.shots)Hs(o,r);t.bomb&&vs(o,t.bomb,this.showBomb),this.pool.commit(o.camPos,this.onLight),this.batch.finish(o.camPos,As);for(let r of z0)this.props[r].finish();this.brass?.finish(),this.bombProp.finish()}resolveLighting(t){let o=this.lighting,e=o.smokeBrightness??1;if(o.sun){let s=o.sun;s.target.parent||s.target.updateMatrixWorld(),s.updateMatrixWorld(),yn.setFromMatrixPosition(s.matrixWorld).sub(pa.setFromMatrixPosition(s.target.matrixWorld)),yn.lengthSq()>1e-8&&this.sunDir.copy(yn).normalize(),this.sunColor.copy(s.color).multiplyScalar(s.intensity*e)}else this.sunColor.setRGB(3*e,3*e,3*e);o.hemi?(this.sky.copy(o.hemi.color).multiplyScalar(o.hemi.intensity*e),this.groundCol.copy(o.hemi.groundColor).multiplyScalar(o.hemi.intensity*e)):(this.sky.setRGB(.55*e,.6*e,.7*e),this.groundCol.setRGB(.3*e,.27*e,.24*e)),o.ambient?this.ambient.copy(o.ambient).multiplyScalar(e):this.ambient.setRGB(.25*e,.25*e,.25*e),t&&t.lengthSq()>1e-8&&this.sunDir.copy(t).normalize(),this.batch.setLighting(this.particleLighting)}estimateVelocity(t,o,e){let s=this.vel.get(t);if(!s)return s={x:o.x,y:o.y,z:o.z,t:e,vx:0,vy:0,vz:0,ok:!1,seen:this.frameNo},this.vel.set(t,s),null;let r=e-s.t;if(Math.abs(r)>1e-4){if(Math.abs(r)<.25){let c=(o.x-s.x)/r,a=(o.y-s.y)/r,i=(o.z-s.z)/r;s.ok=c*c+a*a+i*i<3600,s.ok&&(s.vx=c,s.vy=a,s.vz=i)}else s.ok=!1;s.x=o.x,s.y=o.y,s.z=o.z,s.t=e}return s.seen=this.frameNo,s.ok?this.velOut.set(s.vx,s.vy,s.vz):null}dispose(){this.object.removeFromParent(),this.batch.dispose(),this.pool.dispose();for(let t of z0)this.props[t].dispose();this.brass?.dispose(),this.bombProp.dispose(),this.propMaterial.dispose(),this.smokeAtlas.dispose(),this.glowAtlas.dispose(),this.vel.clear()}};import*as St from"three";var V0=.0254,da=new St.CapsuleGeometry(.33,1.15,4,10).translate(0,.33+.575,0),fa=new St.ConeGeometry(.16,.5,8).rotateX(Math.PI/2).translate(0,1.5,.45),Ss=new St.BoxGeometry(.9,.06,.18),Bo=class{object=new St.Group;alive=[];dead=[];team={T:gn(),CT:gn()};grave={T:Ps(),CT:Ps()};nose=gn(16777215);key="";constructor(t){this.object.name="cs2r-markers",this.grow(t)}grow(t){for(let o=this.alive.length;o<t;o++){let e=new St.Group;e.add(new St.Mesh(da,this.team.T),new St.Mesh(fa,this.nose));let s=new St.Group,r=new St.Mesh(Ss,this.grave.T),c=new St.Mesh(Ss,this.grave.T);r.rotation.y=Math.PI/4,c.rotation.y=-Math.PI/4,s.add(r,c),e.visible=s.visible=!1,this.alive.push(e),this.dead.push(s),this.object.add(e,s)}}setTheme(t,o){let e=`${t.t}|${t.ct}`;e!==this.key&&(this.key=e,this.team.T.color.copy(o(t.t)),this.team.CT.color.copy(o(t.ct)),this.grave.T.color.copy(o(t.t)).multiplyScalar(.55),this.grave.CT.color.copy(o(t.ct)).multiplyScalar(.55))}update(t,o){let e=this.alive[t.index],s=this.dead[t.index];if(e.visible=t.present&&t.alive&&!o,e.visible&&(e.position.set(t.y*V0,t.z*V0,t.x*V0),e.rotation.y=St.MathUtils.degToRad(t.yaw),e.scale.y=t.ducking?.76:1,e.children[0].material=this.team[t.side]),s.visible=t.present&&t.death!==null,t.death){s.position.set(t.death.y*V0,t.death.z*V0+.04,t.death.x*V0);for(let r of s.children)r.material=this.grave[t.death.side]}}dispose(){for(let t of[this.team.T,this.team.CT,this.grave.T,this.grave.CT,this.nose])t.dispose()}};function gn(n=16777215){let t=new St.MeshLambertMaterial({color:n});return t.toneMapped=!1,t}function Ps(){let n=new St.MeshBasicMaterial;return n.toneMapped=!1,n}var $0=.0254,se=(n,t,o,e)=>e.set(t*$0,o*$0,n*$0),ba=64*$0,Ea=46*$0,Cs=3.2,Ls=120,ya={rifle:"rifle",smg:"smg",sniper:"sniper",shotgun:"shotgun",lmg:"heavy",pistol:"pistol",taser:"pistol"},ga=()=>new Promise(n=>typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(),{timeout:500}):setTimeout(n,0)),Fs=class n{constructor(t,o={}){this.model=t;let e=t.replay;this.object.name="cs2r-actors",o.players==="markers"&&(this.markers=new Bo(e.players.length),this.object.add(this.markers.object)),this.object.add(this.viewmodel.object),this.aim=new Hn(e),this.fx=new Io({quality:o.quality??"high"}),this.object.add(this.fx.object),this.sync()}model;static async create(t,o={}){let e=async()=>{await ga(),await o.wait?.()};return o.players!=="markers"&&await is(e),await e(),new n(t,o)}object=new st.Group;fx;characters=[];markers=null;blobs=[];blobMat=null;sides=[];shotsBy=[];hurtsBy=[];hurtAt=new Map;deathKill=new Map;seen={shots:0,hurts:0,kills:0};lastTick=NaN;w=new st.Vector3;pool={shots:[],grenades:[],blasts:[]};voxels=new Map;inputPos=new st.Vector3;inputVel=new st.Vector3;deathDir=new st.Vector3;bomb={state:"hidden",position:new st.Vector3,sincePlant:0};smokeColor=new st.Color;smokeKey="";probes=null;lit=[];probe={ambient:new st.Color,sun:1};pov=-1;viewmodel=new j0;viewLit=null;viewInput={dt:0,time:0,weapon:"",recoil:0,speed:0};aim;eye=new st.Vector3;sync(){let t=this.model.replay,o=t.shots,e=t.hurts;((o?.tick.length??0)<this.seen.shots||(e?.tick.length??0)<this.seen.hurts||t.kills.length<this.seen.kills)&&(this.shotsBy=[],this.hurtsBy=[],this.hurtAt.clear(),this.deathKill.clear(),this.seen={shots:0,hurts:0,kills:0});for(let s=this.sides.length;s<t.players.length;s++){if(this.sides.push(null),!this.markers){let r=new wo({side:"T",seed:s});r.object.visible=!1,this.object.add(r.object),this.characters.push(r),this.probes&&this.lit.push(eo(r.object))}this.blobMat&&this.addBlob()}for(this.markers?.grow(t.players.length);this.shotsBy.length<t.players.length;)this.shotsBy.push([]);for(;this.hurtsBy.length<t.players.length;)this.hurtsBy.push([]);if(o)for(let s=this.seen.shots;s<o.tick.length;s++)this.shotsBy[o.p[s]]?.push(s);if(e)for(let s=this.seen.hurts;s<e.tick.length;s++)this.hurtsBy[e.victim[s]]?.push(s),e.attacker[s]>=0&&this.hurtAt.set(`${e.attacker[s]}:${e.tick[s]}`,e.victim[s]);for(let s=this.seen.kills;s<t.kills.length;s++)this.deathKill.set(`${t.kills[s].victim}:${t.kills[s].f}`,s);this.seen={shots:o?.tick.length??0,hurts:e?.tick.length??0,kills:t.kills.length},this.aim.sync()}addBlob(){let t=new st.Mesh(Ma,this.blobMat);t.name="cs2r-blob",t.renderOrder=1,t.visible=!1,this.blobs.push(t),this.object.add(t)}setStage(t){if(this.fx.setLighting(t.lighting),this.fx.setSmokeVolumes(t.smoke??null),this.probes=t.probes??null,this.probes&&!this.viewLit&&(this.lit=this.characters.map(o=>eo(o.object)),this.viewLit=eo(this.viewmodel.object)),t.blobShadows&&!this.blobMat){this.blobMat=new st.MeshBasicMaterial({map:wa(),color:0,transparent:!0,opacity:.5,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2}),this.blobMat.toneMapped=!1;for(let o=0;o<this.sides.length;o++)this.addBlob()}}tickAt(t){let o=this.model.replay.ticks;if(!o.length)return 0;let e=Math.max(0,Math.min(o.length-1,Math.floor(t))),s=Math.min(o.length-1,e+1);return o[e]+(o[s]-o[e])*Math.max(0,Math.min(1,t-e))}frameAt(t){let o=this.model.replay.ticks,e=0,s=o.length-1;if(s<0||t<=o[0])return 0;if(t>=o[s])return s;for(;s-e>1;){let r=e+s>>1;o[r]<=t?e=r:s=r}return e+(t-o[e])/Math.max(1,o[s]-o[e])}posAt(t,o,e){let s=this.model.replay,r=s.players.length,c=Math.max(0,Math.min(s.frames-1,Math.floor(o))),a=Math.min(s.frames-1,c+1),i=o-c,l=(c*r+t)*4,u=(a*r+t)*4,h=Math.hypot(s.pos[u]-s.pos[l],s.pos[u+1]-s.pos[l+1])>Ls;for(let d=0;d<3;d++)e[d]=h?s.pos[l+d]:s.pos[l+d]+(s.pos[u+d]-s.pos[l+d])*i;return e}velocityAt(t,o,e){let s=this.model.replay,r=s.players.length,c=s.ticks,a=m=>{if(m<0||m+1>=s.frames)return null;let p=(m*r+t)*4,b=((m+1)*r+t)*4,f=(c[m+1]-c[m])/s.tickRate,g=s.pos[b]-s.pos[p],R=s.pos[b+1]-s.pos[p+1],E=s.pos[b+2]-s.pos[p+2];return f<=0||Math.hypot(g,R)>Ls||!(s.state[p+1]&Go.Alive)?[0,0,0]:[g/f,R/f,E/f]},i=Math.floor(o),l=o-i,u=a(i-1)??a(i)??[0,0,0],h=a(i)??u,d=.5+l*.5;return se(u[0]+(h[0]-u[0])*d,u[1]+(h[1]-u[1])*d,u[2]+(h[2]-u[2])*d,e)}lastBefore(t,o,e){let s=0,r=t.length-1,c=-1;for(;s<=r;){let a=s+r>>1;o[t[a]]<=e?(c=a,s=a+1):r=a-1}return c}update(t,o,e,s){let r=this.model.replay,c=r.tickRate,a=this.tickAt(t.t),i=Number.isNaN(this.lastTick)?1e9:(a-this.lastTick)/c;this.lastTick=a;let l=r.shots,u=r.hurts,h=[0,0,0];this.markers?.setTheme(e,s),this.viewmodel.object.visible=!1;for(let E of t.players){let M=E.index===this.pov;M&&E.present&&E.alive&&this.updateViewmodel(E,t.t,a,i,o);let P=this.blobs[E.index];if(P&&(P.visible=E.present&&E.alive&&!M,P.visible&&(se(E.x,E.y,E.z,P.position).y+=.02)),this.markers){this.markers.update(E,M);continue}let C=this.characters[E.index],v=E.present&&(E.alive||E.death!==null)&&!M;if(C.object.visible=v,!v)continue;let L=E.alive?E.side:E.death.side;this.sides[E.index]!==L&&(C.setSide(L),this.sides[E.index]=L);let z={dt:i,position:this.inputPos,yaw:st.MathUtils.degToRad(E.yaw),velocity:this.inputVel.set(0,0,0),alive:E.alive,ducking:E.ducking,weapon:E.alive?E.weapon:"",blind:E.blind,defusing:E.defusing,scoped:E.scoped};if(E.alive){if(se(E.x,E.y,E.z,this.inputPos),this.velocityAt(E.index,t.t,this.inputVel),l){let H=this.shotsBy[E.index],x=this.lastBefore(H,l.tick,a);for(let T=x,A=0;T>=0&&A<6;T--,A++){let S=H[T],q=(a-l.tick[S])/c;if(q>2)break;if(Te(r.weapons[l.w[S]]??"")==="grenade")z.throwAge??=q;else if(z.shotAge===void 0){z.shotAge=q;let G=1-st.MathUtils.smoothstep(q,1,2);z.pitch=-l.pitch[S]*G}}}if(u){let H=this.hurtsBy[E.index],x=this.lastBefore(H,u.tick,a);if(x>=0){let T=(a-u.tick[H[x]])/c;T<1&&(z.hurtAge=T)}}for(let H of this.model.plants){if(H.player!==E.index)continue;let x=r.ticks[Math.min(H.f,r.frames-1)];a<=x&&a>=x-Cs*c&&(z.planting=!0)}}else{let H=E.death;se(H.x,H.y,H.z,this.inputPos),z.deathAge=Math.max(0,(a-r.ticks[Math.min(H.frame,r.frames-1)])/c);let x=this.deathKill.get(`${E.index}:${H.frame}`),T=x!==void 0?r.kills[x]:void 0;T&&T.killer>=0&&T.killer!==E.index&&(this.posAt(T.killer,Math.max(0,H.frame-1),h),se(h[0],h[1],h[2],this.w),this.deathDir.copy(this.inputPos).sub(this.w).setY(0),this.deathDir.lengthSq()>1e-6&&(z.deathDir=this.deathDir.normalize())),z.headshot=T?.hs===!0}C.update(z),this.probes&&this.relight(this.lit[E.index],i)}let d=this.pool.shots;if(d.length=0,l){let E=0,M=l.tick.length,P=a-1.5*c;for(;E<M;){let C=E+M>>1;l.tick[C]<P?E=C+1:M=C}for(let C=E;C<l.tick.length&&l.tick[C]<=a;C++){let v=ya[Te(r.weapons[l.w[C]]??"")];if(!v)continue;let L=l.p[C],z=this.frameAt(l.tick[C]);this.posAt(L,z,h);let H=Math.max(0,Math.min(r.frames-1,Math.round(z))),x=(r.state[(H*r.players.length+L)*4+1]&Go.Duck)!==0,T=se(h[0],h[1],h[2],new st.Vector3),A=T.y;T.y+=x?Ea:ba;let S=st.MathUtils.degToRad(l.yaw[C]),q=st.MathUtils.degToRad(l.pitch[C]),j=new st.Vector3(Math.cos(q)*Math.sin(S),-Math.sin(q),Math.cos(q)*Math.cos(S)),G={id:C,origin:T,direction:j,age:(a-l.tick[C])/c,weaponClass:v,groundY:A};if(L===this.pov&&this.viewmodel.object.visible){let B=o.getWorldPosition(this.eye),Y=this.viewmodel.muzzle(new st.Vector3);Y?(G.muzzle=Y.sub(B).divideScalar(N0).add(B),G.view={eye:B,scale:N0}):(G.muzzle=B.clone().addScaledVector(j,.5),G.muzzle.y-=.08,G.flash=!1)}let K=this.hurtAt.get(`${L}:${l.tick[C]}`);K!==void 0&&(this.posAt(K,z,h),se(h[0],h[1],h[2],this.w).y+=1.2,G.distance=this.w.distanceTo(T)),d.push(G)}}let m=e.smoke;m!==this.smokeKey&&(this.smokeKey=m,this.smokeColor.copy(s(e.smoke)));let p=this.pool.grenades;p.length=0;let b=this.pool.blasts;b.length=0;let f=new Map;for(let E of t.grenades)E.projectile&&f.set(E.index,E);r.grenades.forEach((E,M)=>{let P=vn(E.type),C=f.get(M),v=null;if(E.effectAt&&E.effectPos){let z=r.ticks[Math.min(E.effectAt,r.frames-1)],H=(a-z)/c,x=this.model.effectEnds[M],A=((x?r.ticks[Math.min(x,r.frames-1)]:z+20*c)-z)/c;H>=0&&H<=Vs(P,A)&&(v={kind:P,position:se(E.effectPos[0],E.effectPos[1],E.effectPos[2],new st.Vector3),age:H,remaining:A-H,burst:Math.min(1,H/.6)}),P==="he"&&H>=0&&H<7&&b.push({position:se(E.effectPos[0],E.effectPos[1],E.effectPos[2],new st.Vector3),age:H})}if(!C&&!v)return;let L=null;if(P==="smoke"&&v&&E.voxels){let z=this.voxels.get(M);if(z?.src!==E.voxels.data){let H=E.voxels.origin;z={src:E.voxels.data,voxels:{center:se(H[0],H[1],H[2],new st.Vector3),data:kn(E.voxels.data)}},this.voxels.set(M,z)}L=z.voxels}p.push({id:M,kind:P,projectile:C?.projectile?se(C.projectile.x,C.projectile.y,C.projectile.z,new st.Vector3):null,effect:v,color:this.smokeColor,voxels:L})});let g=t.bomb,R=this.bomb;R.state=g.state,se(g.x,g.y,g.z,R.position),R.sincePlant=g.sincePlant,R.sinceExplode=void 0,R.sinceDefuse=void 0;for(let E of r.bomb){let M=r.ticks[Math.min(E.f,r.frames-1)];if(M>a)break;E.event==="explode"&&(R.sinceExplode=(a-M)/c),E.event==="defuse"&&(R.sinceDefuse=(a-M)/c),E.event==="plant"&&(R.sinceExplode=R.sinceDefuse=void 0)}this.fx.update({dt:Math.max(0,Math.min(i,.25)),time:a/c,camera:o,grenades:p,shots:d,bomb:g.state==="hidden"?null:R,blasts:b})}setPov(t){this.pov=t,this.characters[t]&&(this.characters[t].object.visible=!1),t<0&&(this.viewmodel.object.visible=!1)}updateViewmodel(t,o,e,s,r){let c=this.model.replay,a=c.tickRate,i=c.shots,l=this.viewInput;l.dt=s,l.time=e/a,l.weapon=t.weapon,l.recoil=this.aim.recoil(t.index,o),l.speed=Math.hypot(this.velocityAt(t.index,o,this.inputVel).x,this.inputVel.z),l.scoped=t.scoped,l.busy=t.defusing,l.throwAge=l.throwIn=l.swingAge=l.thrown=void 0,l.reset=void 0;for(let u of this.model.plants){if(u.player!==t.index)continue;let h=c.ticks[Math.min(u.f,c.frames-1)];e<=h&&e>=h-Cs*a&&(l.busy=!0)}if(i){let u=this.shotsBy[t.index],h=this.lastBefore(u,i.tick,e),d=u[h+1];d!==void 0&&Te(c.weapons[i.w[d]]??"")==="grenade"&&(l.throwIn=(i.tick[d]-e)/a);for(let m=h,p=0;m>=0&&p<6;m--,p++){let b=u[m],f=(e-i.tick[b])/a;if(f>2)break;let g=Te(c.weapons[i.w[b]]??"");g==="grenade"&&l.throwAge===void 0&&(l.throwAge=f,l.thrown=c.weapons[i.w[b]]),g==="knife"&&(l.swingAge??=f)}}this.viewmodel.object.visible=!0,this.viewmodel.update(r,l),this.viewLit&&(se(t.x,t.y,t.z,this.inputPos),this.relight(this.viewLit,s))}relight(t,o){if(!t||!this.probes.sample(this.inputPos,this.probe))return;let e=o<0||o>.5?1:1-Math.exp(-o/.12);t.ambient.lerp(this.probe.ambient,e),t.sun+=(this.probe.sun-t.sun)*e;let s=this.probe.ambient.r*.3+this.probe.ambient.g*.6+this.probe.ambient.b*.1;t.spec+=(Math.min(1,Math.max(.15,s/.3,this.probe.sun))-t.spec)*e}dispose(){this.object.removeFromParent(),this.characters.forEach(t=>t.dispose()),this.markers?.dispose(),this.blobMat?.map?.dispose(),this.blobMat?.dispose(),this.fx.dispose(),cs()}},Ma=new st.PlaneGeometry(1.1,1.1).rotateX(-Math.PI/2);function wa(){let t=new Uint8Array(4096);for(let e=0;e<32;e++)for(let s=0;s<32;s++){let r=Math.hypot(s+.5-16,e+.5-16)/16,c=Math.max(0,1-r);t.set([255,255,255,Math.round(255*c*c*(3-2*c))],(e*32+s)*4)}let o=new st.DataTexture(t,32,32);return o.magFilter=o.minFilter=st.LinearFilter,o.needsUpdate=!0,o}export{Fs as GameActors};
@@ -0,0 +1 @@
1
+ var p={ct:"#5b9be6",t:"#e8b04a",background:"#0b0f17",panel:"rgba(8, 11, 18, 0.82)",border:"rgba(255, 255, 255, 0.12)",text:"#f3f5f8",muted:"#9aa3b2",track:"#262c38",trackAlt:"#323a49",accent:"#ffffff",bomb:"#ff3b3b",hpHigh:"#6fe06f",hpMid:"#ffd84a",hpLow:"#ff4a4a",smoke:"#c9ced6",flash:"#ffffff",he:"#ff5a3c",fire:"#ff7a1a",decoy:"#8be08b",font:"system-ui, sans-serif",mono:"ui-monospace, SFMono-Regular, Menlo, monospace"},r={ct:"--replay-ct",t:"--replay-t",background:"--replay-bg",panel:"--replay-panel",border:"--replay-border",text:"--replay-text",muted:"--replay-muted",track:"--replay-track",trackAlt:"--replay-track-alt",accent:"--replay-accent",bomb:"--replay-bomb",hpHigh:"--replay-hp-high",hpMid:"--replay-hp-mid",hpLow:"--replay-hp-low",smoke:"--replay-smoke",flash:"--replay-flash",he:"--replay-he",fire:"--replay-fire",decoy:"--replay-decoy",font:"--replay-font",mono:"--replay-mono"};function y(e,t={}){let o=e&&typeof getComputedStyle<"u"?getComputedStyle(e):null,n={...p};for(let a of Object.keys(r)){let l=t[a],s=o?.getPropertyValue(r[a]).trim();n[a]=l||s||p[a]}return n}function f(e,t){for(let o of Object.keys(r))e.style.setProperty(r[o],t[o])}var i=(e,t)=>t==="CT"?e.ct:t==="T"?e.t:e.muted,c=(e,t)=>t>50?e.hpHigh:t>20?e.hpMid:e.hpLow;export{p as a,r as b,y as c,f as d,i as e,c as f};