2026-04-08 23:48:42 -07:00
|
|
|
import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./jsx-runtime-BpGWiA-R.js";import{a as i,s as a}from"./react-three-fiber.esm-El6vNTZj.js";import{a as o,i as s,s as c}from"./SettingsProvider-BdqQ2Cm4.js";import{C as l,Ct as u,Ft as d,Ht as f,Lt as p,Rt as m,Tt as h,Vt as g,Wt as _,at as v,g as y,h as b,it as x,jt as S,k as C,m as w,p as T,xt as E}from"./three.module-DKAirPAO.js";import{r as D}from"./PlayerModel-D6m6HpJF.js";import{f as O,n as k,p as A,r as j}from"./playbackUtils-DuS6opSR.js";import{t as M}from"./textureUtils-Bk_jPZib.js";import{p as N,r as ee}from"./loaders-5n1D4iOD.js";import{t as P}from"./logger-B058WGzf.js";import{a as F,n as I,r as te,t as L}from"./engineStore-B1KAgiiF.js";import{a as ne,c as re,d as ie,i as ae,l as oe,o as se,r as ce,s as le}from"./AudioEmitter-3VHhCc7Y.js";import{n as R,t as ue}from"./streamPlaybackStore-D5ldcfU5.js";import{j as z}from"./index-BZ0wFa-D.js";import{t as de}from"./gameEntityTypes-CIesm-Ll.js";var B=e(n(),1),fe=t(),pe=Math.PI/180,me=-9.81,he=Math.PI/(180*1e3),ge=1/100,_e=-1e3,ve=50,V=5,ye=5,be=10;function H(e,t,n){let r=e[t];return typeof r==`number`&&Number.isFinite(r)?r:n}function U(e,t,n){let r=e[t];return typeof r==`boolean`?r:typeof r==`number`?r!==0:n}function xe(e){let t=e.keys,n=[];if(Array.isArray(t)&&t.length>0)for(let e=0;e<t.length&&e<4;e++){let r=t[e];n.push({r:r.r??1,g:r.g??1,b:r.b??1,a:r.a??1,size:(r.size??1/ve)*ve,time:e===0?0:r.time??1})}n.length===0&&n.push({r:1,g:1,b:1,a:1,size:1,time:0}),n.length<2&&n.push({...n[0],time:1});let r=``;if(typeof e.textureName==`string`&&e.textureName)r=e.textureName;else{let t=e.textures;Array.isArray(t)&&t.length>0&&t[0]&&(r=t[0])}return{dragCoefficient:H(e,`dragCoefficient`,0)*ye,windCoefficient:H(e,`windCoefficient`,1),gravityCoefficient:H(e,`gravityCoefficient`,0)*be,inheritedVelFactor:H(e,`inheritedVelFactor`,0),constantAcceleration:H(e,`constantAcceleration`,0),lifetimeMS:H(e,`lifetimeMS`,31)<<V,lifetimeVarianceMS:H(e,`lifetimeVarianceMS`,0)<<V,spinSpeed:H(e,`spinSpeed`,0),spinRandomMin:H(e,`spinRandomMin`,1e3)+_e,spinRandomMax:H(e,`spinRandomMax`,1e3)+_e,useInvAlpha:U(e,`useInvAlpha`,!1),keys:n,textureName:r}}function Se(e,t){let n,r=e.particles;if(Array.isArray(r)){for(let e of r)if(typeof e==`number`&&(n=t(e),n))break}return n?{ejectionPeriodMS:H(e,`ejectionPeriodMS`,100),periodVarianceMS:H(e,`periodVarianceMS`,0),ejectionVelocity:H(e,`ejectionVelocity`,200)*ge,velocityVariance:H(e,`velocityVariance`,100)*ge,ejectionOffset:H(e,`ejectionOffset`,0)*ge,thetaMin:H(e,`thetaMin`,0),thetaMax:H(e,`thetaMax`,90),phiReferenceVel:H(e,`phiReferenceVel`,0),phiVariance:H(e,`phiVariance`,360),overrideAdvances:U(e,`overrideAdvances`,!1),orientParticles:U(e,`orientParticles`,!1),orientOnVelocity:U(e,`orientOnVelocity`,!0),lifetimeMS:H(e,`lifetimeMS`,0)<<V,lifetimeVarianceMS:H(e,`lifetimeVarianceMS`,0)<<V,particles:xe(n)}:null}function Ce(e,t){return e+Math.random()*(t-e)}function W(e,t){return e+(Math.random()*2-1)*t}function we(e,t,n){let r,i,a;Math.abs(n)<.9?(r=t,i=-e,a=0):(r=-n,i=0,a=e);let o=Math.sqrt(r*r+i*i+a*a);return o<1e-8?[1,0,0]:[r/o,i/o,a/o]}function Te(e,t,n,r,i,a,o){let s=Math.cos(o),c=Math.sin(o),l=e*r+t*i+n*a,u=i*n-a*t,d=a*e-r*n,f=r*t-i*e;return[e*s+u*c+r*l*(1-s),t*s+d*c+i*l*(1-s),n*s+f*c+a*l*(1-s)]}function Ee(e,t){for(let n=1;n<e.length;n++)if(e[n].time>=t){let r=e[n-1],i=e[n],a=i.time-r.time,o=a>0?(t-r.time)/a:0;return{r:r.r+(i.r-r.r)*o,g:r.g+(i.g-r.g)*o,b:r.b+(i.b-r.b)*o,a:r.a+(i.a-r.a)*o,size:r.size+(i.size-r.size)*o}}let n=e[e.length-1];return{r:n.r,g:n.g,b:n.b,a:n.a,size:n.size}}var De=class{data;particles=[];maxParticles;internalClock=0;nextParticleTime=0;emitterAge=0;emitterLifetime;emitterDead=!1;constructor(e,t=256,n){this.data=e,this.maxParticles=t;let r=n??e.lifetimeMS;!n&&e.lifetimeVarianceMS>0&&(r+=Math.round(W(0,e.lifetimeVarianceMS))),this.emitterLifetime=r}emitBurst(e,t,n=[0,0,1]){for(let r=0;r<t&&this.particles.length<this.maxParticles;r++)this.addParticle(e,n)}emitPeriodic(e,t,n=[0,0,1]){if(this.emitterDead)return;let r=t;for(;r>0;){if(this.nextParticleTime>0){let e=
|
2026-04-05 22:34:39 -07:00
|
|
|
// 'position' is auto-declared by Three.js for ShaderMaterial.
|
|
|
|
|
attribute vec4 particleColor;
|
|
|
|
|
attribute float particleSize;
|
|
|
|
|
attribute float particleSpin;
|
|
|
|
|
attribute vec2 quadCorner; // (-0.5,-0.5) to (0.5,0.5)
|
|
|
|
|
attribute vec3 orientDir;
|
|
|
|
|
|
|
|
|
|
uniform bool uOrientParticles;
|
|
|
|
|
// cameraPosition is a built-in Three.js uniform.
|
|
|
|
|
|
|
|
|
|
varying vec2 vUv;
|
|
|
|
|
varying vec4 vColor;
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
vUv = quadCorner + 0.5; // [0,1] range
|
|
|
|
|
vColor = particleColor;
|
|
|
|
|
|
|
|
|
|
if (uOrientParticles) {
|
|
|
|
|
if (length(orientDir) < 0.0001) {
|
|
|
|
|
// V12: don't render oriented particles with zero velocity.
|
|
|
|
|
gl_Position = vec4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// V12 oriented particle: quad aligned along direction, facing camera.
|
|
|
|
|
vec3 worldPos = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
|
|
|
vec3 dir = normalize(orientDir);
|
|
|
|
|
vec3 dirFromCam = worldPos - cameraPosition;
|
|
|
|
|
vec3 crossDir = normalize(cross(dirFromCam, dir));
|
|
|
|
|
|
|
|
|
|
// V12 maps U along dir (velocity) — match by using quadCorner.x for dir.
|
|
|
|
|
vec3 offset = dir * quadCorner.x + crossDir * quadCorner.y;
|
|
|
|
|
worldPos += offset * particleSize;
|
|
|
|
|
|
|
|
|
|
gl_Position = projectionMatrix * viewMatrix * vec4(worldPos, 1.0);
|
|
|
|
|
} else {
|
|
|
|
|
// Standard camera-facing billboard.
|
|
|
|
|
vec3 viewPos = (modelViewMatrix * vec4(position, 1.0)).xyz;
|
|
|
|
|
|
|
|
|
|
// Apply spin rotation to quad corner.
|
|
|
|
|
float c = cos(particleSpin);
|
|
|
|
|
float s = sin(particleSpin);
|
|
|
|
|
vec2 rotated = vec2(
|
|
|
|
|
c * quadCorner.x - s * quadCorner.y,
|
|
|
|
|
s * quadCorner.x + c * quadCorner.y
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Offset in view space (camera-facing billboard).
|
|
|
|
|
viewPos.xy += rotated * particleSize;
|
|
|
|
|
|
|
|
|
|
gl_Position = projectionMatrix * vec4(viewPos, 1.0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`,ke=`
|
|
|
|
|
uniform sampler2D particleTexture;
|
|
|
|
|
uniform bool hasTexture;
|
|
|
|
|
uniform float debugOpacity;
|
|
|
|
|
|
|
|
|
|
varying vec2 vUv;
|
|
|
|
|
varying vec4 vColor;
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
if (hasTexture) {
|
|
|
|
|
vec4 texColor = texture2D(particleTexture, vUv);
|
|
|
|
|
gl_FragColor = texColor * vColor;
|
|
|
|
|
} else {
|
|
|
|
|
gl_FragColor = vColor;
|
|
|
|
|
}
|
|
|
|
|
gl_FragColor.a *= debugOpacity;
|
|
|
|
|
}
|
|
|
|
|
`,G=r(),Ae=P(`ParticleEffects`),K=256,je=new Float32Array([-.5,-.5,.5,-.5,.5,.5,-.5,.5]),Me=new Map,Ne=new Set,q=new l(new Uint8Array([255,255,255,255]),1,1,h,f);q.needsUpdate=!0;function J(e){if(!e)return q;let t=Me.get(e);if(t)return t;try{let t=M(N(e),e=>{O(e),Ne.add(e)});return O(t),Me.set(e,t),t}catch{return q}}var Pe=new d(1,6,6),Fe=new v({color:16711680,wireframe:!0}),Ie=new T(.3,.3,.3),Le=new v({color:65280,wireframe:!0}),Re=new d(1,12,8);function ze(e,t){let n=document.createElement(`canvas`),r=n.getContext(`2d`);r.font=`bold 32px monospace`;let i=r.measureText(e);n.width=Math.ceil(i.width)+16,n.height=48,r.font=`bold 32px monospace`,r.fillStyle=`#${t.toString(16).padStart(6,`0`)}`,r.textBaseline=`middle`,r.fillText(e,8,n.height/2);let a=new m({map:new y(n),transparent:!0,depthTest:!1,depthWrite:!1}),o=new p(a),s=n.width/n.height;return o.scale.set(s*2,2,1),{sprite:o,material:a}}function Be(e,t){let n=t(e);if(!n)return null;let r=n.colors??[],i=n.times??[0,.5,1,1];return{width:n.width??1,numSegments:Math.max(n.numSegments??16,4),velocity:n.velocity??0,height:n.height??0,verticalCurve:n.verticalCurve??0,acceleration:n.acceleration??0,texWrap:n.texWrap??1,lifetimeMS:n.lifetimeMS??500,is2D:!!n.is2D,renderSquare:!!n.renderSquare,renderBottom:!!n.renderBottom,mapToTerrain:!!n.mapToTerrain,colors:r,times:i,textureName:n.textureName??``,mapToTexture:n.mapToTexture??``}}function Ve(e,t){let{colors:n,times:r}=e;if(n.length===0)return[1,1,1,1];let i=0;for(let e=0;e<r.length-1;e++)t>=r[e]&&(i=e);let a=Math.min(i+1,n.length-1),o=r[i]??0,s=(r[a]??1)-o,c=s>0?Math.min((t-o)/s,1):0,l=n[i]??n[0],u=n[a]??n[0];return[l.r+(u.r-l.r)*c,l.g+(u.g-l.g)*c,l.b+(u.b-l.b)*c,l.a+(u.a-l.a)*c]}var He=`
|
|
|
|
|
attribute vec4 vertexColor;
|
|
|
|
|
attribute vec2 texCoord;
|
|
|
|
|
varying vec4 vColor;
|
|
|
|
|
varying vec2 vUV;
|
|
|
|
|
void main() {
|
|
|
|
|
vColor = vertexColor;
|
|
|
|
|
vUV = texCoord;
|
|
|
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
|
|
|
}
|
|
|
|
|
`,Ue=`
|
|
|
|
|
uniform sampler2D uTexture;
|
|
|
|
|
varying vec4 vColor;
|
|
|
|
|
varying vec2 vUV;
|
|
|
|
|
void main() {
|
|
|
|
|
vec4 tex = texture2D(uTexture, vUV);
|
|
|
|
|
gl_FragColor = vec4(vColor.rgb * tex.rgb, vColor.a * tex.a);
|
|
|
|
|
}
|
2026-04-08 23:00:53 -07:00
|
|
|
`;function We(e){let t=(e+1)*2,n=new Float32Array(t*3),r=new Float32Array(t*2),i=new Float32Array(t*4),a=e*6,o=new Uint16Array(a);for(let t=0;t<e;t++){let e=t*2,n=t*6;o[n]=e,o[n+1]=e+1,o[n+2]=e+2,o[n+3]=e+1,o[n+4]=e+3,o[n+5]=e+2}let s=new b,c=new w(n,3);c.setUsage(35048),s.setAttribute(`position`,c);let l=new w(r,2);l.setUsage(35048),s.setAttribute(`texCoord`,l);let u=new w(i,4);return u.setUsage(35048),s.setAttribute(`vertexColor`,u),s.setIndex(new w(o,1)),s}function Ge(e,t,n,r,i){let a=e.getAttribute(`position`).array,o=e.getAttribute(`texCoord`).array,s=e.getAttribute(`vertexColor`).array,c=Math.max(n-t.width*.5,0),l=n+t.width*.5,u=t.numSegments,d=r[0],f=r[1],p=r[2],m=r[3];for(let e=0;e<=u;e++){let n=e/u*Math.PI*2,r=Math.cos(n),h=Math.sin(n),g=e*2,_=g+1,v=g*3;a[v]=r*l,a[v+1]=i?0:t.height,a[v+2]=h*l;let y=_*3;a[y]=r*c,a[y+1]=0,a[y+2]=h*c;let b=e/u*t.texWrap,x=g*2;o[x]=b,o[x+1]=.05;let S=_*2;o[S]=b,o[S+1]=.95;let C=g*4;s[C]=d,s[C+1]=f,s[C+2]=p,s[C+3]=m;let w=_*4;s[w]=d,s[w+1]=f,s[w+2]=p,s[w+3]=m}e.getAttribute(`position`).needsUpdate=!0,e.getAttribute(`texCoord`).needsUpdate=!0,e.getAttribute(`vertexColor`).needsUpdate=!0,e.computeBoundingSphere()}function Ke(e){return new S({vertexShader:He,fragmentShader:Ue,uniforms:{uTexture:{value:e}},transparent:!0,depthWrite:!1,blending:2,side:2})}function qe(e){if(!e)return 16711935;let t=e.toLowerCase();return t.includes(`disc`)?4491519:t.includes(`grenade`)?16746496:t.includes(`mortar`)?16729088:t.includes(`plasma`)?4521796:t.includes(`laser`)?16720418:t.includes(`blaster`)?16776960:t.includes(`missile`)?16737792:t.includes(`bomb`)?16711680:t.includes(`mine`)?16746564:t.includes(`concussion`)?16755200:t.includes(`shocklance`)?8930559:t.includes(`chaingun`)||t.includes(`bullet`)?13421772:16711935}function Je(e){let t=e.sizes;if(Array.isArray(t)&&t.length>0){let e=0;for(let n of t)e=Math.max(e,n.x,n.y,n.z);if(e>0)return e/1e3}let n=e.particleRadius;return typeof n==`number`&&n>0?n:5}function Ye(e){let t=new b,n=e*4,r=e*6,i=new Float32Array(n*2);for(let t=0;t<e;t++)i.set(je,t*8);let a=new Uint16Array(r);for(let t=0;t<e;t++){let e=t*4,n=t*6;a[n]=e,a[n+1]=e+1,a[n+2]=e+2,a[n+3]=e,a[n+4]=e+2,a[n+5]=e+3}let o=new Float32Array(n*3),s=new Float32Array(n*4),c=new Float32Array(n),l=new Float32Array(n),u=new Float32Array(n*3);return t.setIndex(new g(a,1)),t.setAttribute(`quadCorner`,new C(i,2)),t.setAttribute(`position`,new C(o,3)),t.setAttribute(`particleColor`,new C(s,4)),t.setAttribute(`particleSize`,new C(c,1)),t.setAttribute(`particleSpin`,new C(l,1)),t.setAttribute(`orientDir`,new C(u,3)),t.setDrawRange(0,0),t}function Xe(e,t,n=!1){return new S({vertexShader:Oe,fragmentShader:ke,uniforms:{particleTexture:{value:Ne.has(e)?e:q},hasTexture:{value:!0},debugOpacity:{value:1},uOrientParticles:{value:n}},transparent:!0,depthWrite:!1,depthTest:!0,side:2,blending:t?1:2})}function Ze(e,t,n){let r=e.properties.get(t).currentProgram;if(!r)return;let i=r.program,a=e.getContext();a.getProgramParameter(i,a.LINK_STATUS)||Ae.error(`Shader LINK ERROR (%s): %s`,n,a.getProgramInfoLog(i))}function Qe(e,t){let n=t(e);if(!n)return null;let r=[],i=[],a=n.particleEmitter;if(typeof a==`number`){let e=t(a);if(e){let i=Se(e,t);if(i){let e=n.particleDensity??10;r.push({data:i,density:e})}}}let o=n.emitters;if(Array.isArray(o))for(let e of o){if(typeof e!=`number`)continue;let n=t(e);if(!n)continue;let r=Se(n,t);r&&i.push(r)}return r.length===0&&i.length===0?null:{burstEmitters:r,streamingEmitters:i,lifetimeMS:(n.lifetimeMS??31)*32}}function $e(e){let t=e.emitter.particles,n=e.geometry,r=n.getAttribute(`position`),i=n.getAttribute(`particleColor`),a=n.getAttribute(`particleSize`),o=n.getAttribute(`particleSpin`),s=n.getAttribute(`orientDir`),c=r.array,l=i.array,u=a.array,d=o.array,f=s.array,p=Math.min(t.length,K),m=e.emitter.data.orientOnVelocity;for(let e=0;e<p;e++){let n=t[e],r=n.pos[1],i=n.pos[2],a=n.pos[0],o=m?n.vel:n.orientDir,s=o[1],p=o[2],h=o[0],g=n.r,_=n.g,v=n.b,y=n.a;for(let t=0;t<4;t++){let o=e*4+t,m=o*3;c[m]=r,c[m+1]=i,c[m+2]=a;let b=o*4;l[b]=g,l[b+1]=_,l[b+2]=v,l[b+3]=y;let x=o*3;f[x]=s,f[x+1]=p,f[x+2
|