t2-mapper/docs/assets/StreamingController-uMft_M6W.js

89 lines
34 KiB
JavaScript
Raw Normal View History

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{i,o as a}from"./react-three-fiber.esm-dhSWjERg.js";import{a as o,i as s}from"./SettingsProvider-xrmxG700.js";import{a as c,g as l,h as u,o as d}from"./GenericShape-C-0r5jzJ.js";import{t as f}from"./logger-z_EpIdIa.js";import"./traditional-BTL5qX2E.js";import{At as p,Bt as m,C as h,It as g,Lt as _,O as v,Pt as y,St as b,Ut as x,Vt as S,bt as C,g as w,h as T,it as E,m as D,p as O,rt as k,wt as A}from"./three.module-CwgFV8Kd.js";import"./mission-C2iDKeMo.js";import{a as j,n as M,r as N,t as P}from"./engineStore-Cio8vU1L.js";import{v as F}from"./index-BMiY1uIn.js";import{p as I,r as ee}from"./loaders-0nekNxyt.js";import{n as te}from"./AudioContext-Dn9ry4KA.js";import"./FloatingLabel-D3hPNzZS.js";import{getCachedAudioBuffer as L,getSoundGeneration as R,playOneShotSound as z,resolveAudioProfile as ne,stopAllTrackedSounds as B,trackSound as re,untrackSound as ie}from"./AudioEmitter-_djhBYQd.js";import"./DebugSuspense-evFO3StN.js";import{t as ae}from"./gameEntityTypes-9Mm4qfyP.js";import{n as V,t as oe}from"./streamPlaybackStore-uClZ1maO.js";import{l as se}from"./globalFogUniforms-CaAkHfiE.js";import"./ShapeErrorBoundary-ClcZWdMf.js";import{PlayerEyeOffset as ce}from"./PlayerModel-_jDNy_lG.js";var le=t(),H=e(n(),1),ue=Math.PI/180,de=-9.81,fe=Math.PI/(180*1e3),pe=1/100,me=-1e3,he=50,U=5,ge=5,_e=10;function W(e,t,n){let r=e[t];return typeof r==`number`&&Number.isFinite(r)?r:n}function ve(e,t,n){let r=e[t];return typeof r==`boolean`?r:typeof r==`number`?r!==0:n}function ye(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/he)*he,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:W(e,`dragCoefficient`,0)*ge,windCoefficient:W(e,`windCoefficient`,1),gravityCoefficient:W(e,`gravityCoefficient`,0)*_e,inheritedVelFactor:W(e,`inheritedVelFactor`,0),constantAcceleration:W(e,`constantAcceleration`,0),lifetimeMS:W(e,`lifetimeMS`,31)<<U,lifetimeVarianceMS:W(e,`lifetimeVarianceMS`,0)<<U,spinSpeed:W(e,`spinSpeed`,0),spinRandomMin:W(e,`spinRandomMin`,1e3)+me,spinRandomMax:W(e,`spinRandomMax`,1e3)+me,useInvAlpha:ve(e,`useInvAlpha`,!1),keys:n,textureName:r}}function be(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:W(e,`ejectionPeriodMS`,100),periodVarianceMS:W(e,`periodVarianceMS`,0),ejectionVelocity:W(e,`ejectionVelocity`,200)*pe,velocityVariance:W(e,`velocityVariance`,100)*pe,ejectionOffset:W(e,`ejectionOffset`,0)*pe,thetaMin:W(e,`thetaMin`,0),thetaMax:W(e,`thetaMax`,90),phiReferenceVel:W(e,`phiReferenceVel`,0),phiVariance:W(e,`phiVariance`,360),overrideAdvances:ve(e,`overrideAdvances`,!1),orientParticles:ve(e,`orientParticles`,!1),orientOnVelocity:ve(e,`orientOnVelocity`,!0),lifetimeMS:W(e,`lifetimeMS`,0)<<U,lifetimeVarianceMS:W(e,`lifetimeVarianceMS`,0)<<U,particles:ye(n)}:null}function xe(e,t){return e+Math.random()*(t-e)}function G(e,t){return e+(Math.random()*2-1)*t}function Se(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 Ce(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 we(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 Te=class{data;particles=[];maxParticles;internalClock=0;nextParticleTime=0;emitterAge=0;emitterLifetime;emitterDead=!1;constructor(e,t=256,n){this.data=e,this.maxParticles=t
2026-03-15 10:26:24 -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);
}
}
`,De=`
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;
}
2026-03-18 06:26:17 -07:00
`,K=r(),Oe=f(`ParticleEffects`),q=256,ke=new Float32Array([-.5,-.5,.5,-.5,.5,.5,-.5,.5]),Ae=new Map,je=new Set,J=new h(new Uint8Array([255,255,255,255]),1,1,A,S);J.needsUpdate=!0;function Y(e){if(!e)return J;let t=Ae.get(e);if(t)return t;try{let t=se(I(e),e=>{u(e),je.add(e)});return u(t),Ae.set(e,t),t}catch{return J}}var Me=new y(1,6,6),Ne=new E({color:16711680,wireframe:!0}),Pe=new O(.3,.3,.3),Fe=new E({color:65280,wireframe:!0}),Ie=new y(1,12,8);function Le(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 _({map:new w(n),transparent:!0,depthTest:!1,depthWrite:!1}),o=new g(a),s=n.width/n.height;return o.scale.set(s*2,2,1),{sprite:o,material:a}}function Re(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 ze(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 Be=`
2026-03-15 10:26:24 -07:00
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);
}
`,Ve=`
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-03-18 06:26:17 -07:00
`;function He(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 T,c=new D(n,3);c.setUsage(35048),s.setAttribute(`position`,c);let l=new D(r,2);l.setUsage(35048),s.setAttribute(`texCoord`,l);let u=new D(i,4);return u.setUsage(35048),s.setAttribute(`vertexColor`,u),s.setIndex(new D(o,1)),s}function Ue(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 We(e){return new p({vertexShader:Be,fragmentShader:Ve,uniforms:{uTexture:{value:e}},transparent:!0,depthWrite:!1,blending:2,side:2})}function Ge(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 Ke(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 qe(e){let t=new T,n=e*4,r=e*6,i=new Float32Array(n*2);for(let t=0;t<e;t++)i.set(ke,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 m(a,1)),t.setAttribute(`quadCorner`,new v(i,2)),t.setAttribute(`position`,new v(o,3)),t.setAttribute(`particleColor`,new v(s,4)),t.setAttribute(`particleSize`,new v(c,1)),t.setAttribute(`particleSpin`,new v(l,1)),t.setAttribute(`orientDir`,new v(u,3)),t.setDrawRange(0,0),t}function Je(e,t,n=!1){return new p({vertexShader:Ee,fragmentShader:De,uniforms:{particleTexture:{value:je.has(e)?e:J},hasTexture:{value:!0},debugOpacity:{value:1},uOrientParticles:{value:n}},transparent:!0,depthWrite:!1,depthTest:!0,side:2,blending:t?1:2})}function Ye(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)||Oe.error(`Shader LINK ERROR (%s): %s`,n,a.getProgramInfoLog(i))}function Xe(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=be(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=be(n,t);r&&i.push(r)}return r.length===0&&i.length===0?null:{burstEmitters:r,streamingEmitters:i,lifetimeMS:(n.lifetimeMS??31)*32}}function Ze(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,q),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