t2-mapper/docs/_next/static/chunks/bc2b324cb2101ffe.js
2026-03-12 16:34:43 -07:00

89 lines
No EOL
34 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,51295,e=>{"use strict";var t=e.i(43476),i=e.i(932),r=e.i(71645),a=e.i(71753),o=e.i(78140),n=e.i(90072),s=e.i(85557),l=e.i(12979),c=e.i(15080),u=e.i(75567);let d=Math.PI/180,m=Math.PI/18e4;function p(e,t,i){let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:i}function f(e,t,i){let r=e[t];return"boolean"==typeof r?r:"number"==typeof r?0!==r:i}function h(e,t){let i,r=e.particles;if(Array.isArray(r)){for(let e of r)if("number"==typeof e&&(i=t(e)))break}return i?{ejectionPeriodMS:p(e,"ejectionPeriodMS",100),periodVarianceMS:p(e,"periodVarianceMS",0),ejectionVelocity:.01*p(e,"ejectionVelocity",200),velocityVariance:.01*p(e,"velocityVariance",100),ejectionOffset:.01*p(e,"ejectionOffset",0),thetaMin:p(e,"thetaMin",0),thetaMax:p(e,"thetaMax",90),phiReferenceVel:p(e,"phiReferenceVel",0),phiVariance:p(e,"phiVariance",360),overrideAdvances:f(e,"overrideAdvances",!1),orientParticles:f(e,"orientParticles",!1),orientOnVelocity:f(e,"orientOnVelocity",!0),lifetimeMS:p(e,"lifetimeMS",0)<<5,lifetimeVarianceMS:p(e,"lifetimeVarianceMS",0)<<5,particles:function(e){let t=e.keys,i=[];if(Array.isArray(t)&&t.length>0)for(let e=0;e<t.length&&e<4;e++){let r=t[e];i.push({r:r.r??1,g:r.g??1,b:r.b??1,a:r.a??1,size:(r.size??.02)*50,time:0===e?0:r.time??1})}0===i.length&&i.push({r:1,g:1,b:1,a:1,size:1,time:0}),i.length<2&&i.push({...i[0],time:1});let r="";if("string"==typeof e.textureName&&e.textureName)r=e.textureName;else{let t=e.textures;Array.isArray(t)&&t.length>0&&t[0]&&(r=t[0])}return{dragCoefficient:5*p(e,"dragCoefficient",0),windCoefficient:p(e,"windCoefficient",1),gravityCoefficient:10*p(e,"gravityCoefficient",0),inheritedVelFactor:p(e,"inheritedVelFactor",0),constantAcceleration:p(e,"constantAcceleration",0),lifetimeMS:p(e,"lifetimeMS",31)<<5,lifetimeVarianceMS:p(e,"lifetimeVarianceMS",0)<<5,spinSpeed:p(e,"spinSpeed",0),spinRandomMin:p(e,"spinRandomMin",1e3)+-1e3,spinRandomMax:p(e,"spinRandomMax",1e3)+-1e3,useInvAlpha:f(e,"useInvAlpha",!1),keys:i,textureName:r}}(i)}:null}function g(e,t){return e+(2*Math.random()-1)*t}function y(e,t,i,r,a,o,n){let s=Math.cos(n),l=Math.sin(n),c=e*r+t*a+i*o;return[e*s+(a*i-o*t)*l+r*c*(1-s),t*s+(o*e-r*i)*l+a*c*(1-s),i*s+(r*t-a*e)*l+o*c*(1-s)]}class S{data;particles=[];maxParticles;internalClock=0;nextParticleTime=0;emitterAge=0;emitterLifetime;emitterDead=!1;constructor(e,t=256,i){this.data=e,this.maxParticles=t;let r=i??e.lifetimeMS;!i&&e.lifetimeVarianceMS>0&&(r+=Math.round(g(0,e.lifetimeVarianceMS))),this.emitterLifetime=r}emitBurst(e,t,i=[0,0,1]){for(let r=0;r<t&&this.particles.length<this.maxParticles;r++)this.addParticle(e,i)}emitPeriodic(e,t,i=[0,0,1]){if(this.emitterDead)return;let r=t;for(;r>0;){if(this.nextParticleTime>0){let e=Math.min(r,this.nextParticleTime);this.nextParticleTime-=e,r-=e,this.internalClock+=e;continue}if(this.particles.length<this.maxParticles&&(this.addParticle(e,i),!this.data.overrideAdvances&&r>0)){let e=this.particles[this.particles.length-1];e.currentAge+=r,e.currentAge>=e.totalLifetime&&this.particles.pop()}let t=this.data.ejectionPeriodMS;this.data.periodVarianceMS>0&&(t+=Math.round(g(0,this.data.periodVarianceMS))),this.nextParticleTime=Math.max(1,t)}}update(e){this.emitterAge+=e,this.emitterLifetime>0&&this.emitterAge>this.emitterLifetime&&(this.emitterDead=!0);let t=e/1e3,i=this.data.particles;for(let r=this.particles.length-1;r>=0;r--){let a=this.particles[r];if(a.currentAge+=e,a.currentAge>=a.totalLifetime){this.particles[r]=this.particles[this.particles.length-1],this.particles.pop();continue}let o=i.dragCoefficient,n=i.gravityCoefficient,s=a.acc[0]-a.vel[0]*o,l=a.acc[1]-a.vel[1]*o,c=a.acc[2]-a.vel[2]*o+-9.81*n;a.vel[0]+=s*t,a.vel[1]+=l*t,a.vel[2]+=c*t,a.pos[0]+=a.vel[0]*t,a.pos[1]+=a.vel[1]*t,a.pos[2]+=a.vel[2]*t;let u=a.currentAge/a.totalLifetime,d=function(e,t){for(let i=1;i<e.length;i++)if(e[i].time>=t){let r=e[i-1],a=e[i],o=a.time-r.time,n=o>0?(t-r.time)/o:0;return{r:r.r+(a.r-r.r)*n,g:r.g+(a.g-r.g)*n,b:r.b+(a.b-r.b)*n,a:r.a+(a.a-r.a)*n,size:r.size+(a.size-r.size)*n}}let i=e[e.length-1];return{r:i.r,g:i.g,b:i.b,a:i.a,size:i.size}}(i.keys,u);a.r=d.r,a.g=d.g,a.b=d.b,a.a=d.a,a.size=d.size,a.currentSpin=a.spinSpeed*a.currentAge*m}}isDead(){return this.emitterDead&&0===this.particles.length}kill(){this.emitterDead=!0}addParticle(e,t){var i,r,a,o;let n,s,l,c,u=this.data,m=u.particles,p=t[0],f=t[1],h=t[2],S=(i=p,r=f,.9>Math.abs(a=h)?(n=r,s=-i,l=0):(n=-a,s=0,l=i),(c=Math.sqrt(n*n+s*s+l*l))<1e-8?[1,0,0]:[n/c,s/c,l/c]),v=(u.thetaMin+Math.random()*(u.thetaMax-u.thetaMin))*d,b=(this.internalClock/1e3*u.phiReferenceVel+Math.random()*u.phiVariance)*d;[p,f,h]=y(p,f,h,S[0],S[1],S[2],v),[p,f,h]=y(p,f,h,t[0],t[1],t[2],b);let M=Math.sqrt(p*p+f*f+h*h);M>1e-8&&(p/=M,f/=M,h/=M);let x=g(u.ejectionVelocity,u.velocityVariance),w=[e[0]+p*u.ejectionOffset,e[1]+f*u.ejectionOffset,e[2]+h*u.ejectionOffset],T=[p*x,f*x,h*x],A=m.constantAcceleration,P=[T[0]*A,T[1]*A,T[2]*A],k=m.lifetimeMS;m.lifetimeVarianceMS>0&&(k+=Math.round(g(0,m.lifetimeVarianceMS))),k=Math.max(1,k);let C=m.spinSpeed+((o=m.spinRandomMin)+Math.random()*(m.spinRandomMax-o)),D=m.keys[0];this.particles.push({pos:w,vel:T,acc:P,orientDir:[p,f,h],currentAge:0,totalLifetime:k,dataIndex:0,spinSpeed:C,currentSpin:0,r:D.r,g:D.g,b:D.b,a:D.a,size:D.size})}}let v=`
// '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);
}
}
`,b=`
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;
}
`;var M=e.i(25645),x=e.i(79123),w=e.i(51434),T=e.i(29055),A=e.i(58647);let P=(0,M.createLogger)("ParticleEffects"),k=new Float32Array([-.5,-.5,.5,-.5,.5,.5,-.5,.5]),C=new Map,D=new Set,I=new n.DataTexture(new Uint8Array([255,255,255,255]),1,1,n.RGBAFormat,n.UnsignedByteType);function B(e){if(!e)return I;let t=C.get(e);if(t)return t;try{let t=(0,l.textureToUrl)(e),i=(0,u.loadTexture)(t,e=>{(0,s.setupEffectTexture)(e),D.add(e)});return(0,s.setupEffectTexture)(i),C.set(e,i),i}catch{return I}}I.needsUpdate=!0;let N=new n.SphereGeometry(1,6,6),E=new n.MeshBasicMaterial({color:0xff0000,wireframe:!0}),R=new n.BoxGeometry(.3,.3,.3),V=new n.MeshBasicMaterial({color:65280,wireframe:!0}),F=new n.SphereGeometry(1,12,8),_=`
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);
}
`,O=`
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);
}
`;function z(e){let t=(e+1)*2,i=new Float32Array(3*t),r=new Float32Array(2*t),a=new Float32Array(4*t),o=new Uint16Array(6*e);for(let t=0;t<e;t++){let e=2*t,i=6*t;o[i]=e,o[i+1]=e+1,o[i+2]=e+2,o[i+3]=e+1,o[i+4]=e+3,o[i+5]=e+2}let s=new n.BufferGeometry,l=new n.BufferAttribute(i,3);l.setUsage(35048),s.setAttribute("position",l);let c=new n.BufferAttribute(r,2);c.setUsage(35048),s.setAttribute("texCoord",c);let u=new n.BufferAttribute(a,4);return u.setUsage(35048),s.setAttribute("vertexColor",u),s.setIndex(new n.BufferAttribute(o,1)),s}function U(e,t,i,r,a){let o=e.getAttribute("position").array,n=e.getAttribute("texCoord").array,s=e.getAttribute("vertexColor").array,l=Math.max(i-.5*t.width,0),c=i+.5*t.width,u=t.numSegments,d=r[0],m=r[1],p=r[2],f=r[3];for(let e=0;e<=u;e++){let i=e/u*Math.PI*2,r=Math.cos(i),h=Math.sin(i),g=2*e,y=g+1,S=3*g;o[S]=r*c,o[S+1]=a?0:t.height,o[S+2]=h*c;let v=3*y;o[v]=r*l,o[v+1]=0,o[v+2]=h*l;let b=e/u*t.texWrap,M=2*g;n[M]=b,n[M+1]=.05;let x=2*y;n[x]=b,n[x+1]=.95;let w=4*g;s[w]=d,s[w+1]=m,s[w+2]=p,s[w+3]=f;let T=4*y;s[T]=d,s[T+1]=m,s[T+2]=p,s[T+3]=f}e.getAttribute("position").needsUpdate=!0,e.getAttribute("texCoord").needsUpdate=!0,e.getAttribute("vertexColor").needsUpdate=!0,e.computeBoundingSphere()}function j(e){let t=new n.BufferGeometry,i=4*e,r=new Float32Array(2*i);for(let t=0;t<e;t++)r.set(k,8*t);let a=new Uint16Array(6*e);for(let t=0;t<e;t++){let e=4*t,i=6*t;a[i]=e,a[i+1]=e+1,a[i+2]=e+2,a[i+3]=e,a[i+4]=e+2,a[i+5]=e+3}let o=new Float32Array(3*i),s=new Float32Array(4*i),l=new Float32Array(i),c=new Float32Array(i),u=new Float32Array(3*i);return t.setIndex(new n.Uint16BufferAttribute(a,1)),t.setAttribute("quadCorner",new n.Float32BufferAttribute(r,2)),t.setAttribute("position",new n.Float32BufferAttribute(o,3)),t.setAttribute("particleColor",new n.Float32BufferAttribute(s,4)),t.setAttribute("particleSize",new n.Float32BufferAttribute(l,1)),t.setAttribute("particleSpin",new n.Float32BufferAttribute(c,1)),t.setAttribute("orientDir",new n.Float32BufferAttribute(u,3)),t.setDrawRange(0,0),t}function q(e,t,i=!1){let r=D.has(e);return new n.ShaderMaterial({vertexShader:v,fragmentShader:b,uniforms:{particleTexture:{value:r?e:I},hasTexture:{value:!0},debugOpacity:{value:1},uOrientParticles:{value:i}},transparent:!0,depthWrite:!1,depthTest:!0,side:n.DoubleSide,blending:t?n.NormalBlending:n.AdditiveBlending})}function L(e){let o,s,u,d,m,p,f,g,y,v,b,M=(0,i.c)(18),{playback:k,snapshotRef:C}=e,{debugMode:I}=(0,x.useDebug)(),{audioEnabled:L}=(0,x.useSettings)(),{audioLoader:K,audioListener:$}=(0,w.useAudio)(),Y=(0,c.useThree)(H),Q=(0,r.useRef)(null);M[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],M[0]=o):o=M[0];let J=(0,r.useRef)(o);M[1]===Symbol.for("react.memo_cache_sentinel")?(s=new Set,M[1]=s):s=M[1];let X=(0,r.useRef)(s);M[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,M[2]=u):u=M[2];let Z=(0,r.useRef)(u);M[3]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,M[3]=d):d=M[3];let ee=(0,r.useRef)(d);M[4]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,M[4]=m):m=M[4];let et=(0,r.useRef)(m);M[5]===Symbol.for("react.memo_cache_sentinel")?(p=[],M[5]=p):p=M[5];let ei=(0,r.useRef)(p);M[6]===Symbol.for("react.memo_cache_sentinel")?(f=[],M[6]=f):f=M[6];let er=(0,r.useRef)(f);return M[7]!==L||M[8]!==$||M[9]!==K||M[10]!==I||M[11]!==Y||M[12]!==k||M[13]!==C?(g=(e,t)=>{let i=Q.current,r=C.current;if(!i||!r)return;let a=A.engineStore.getState().playback,o="playing"===a.status,s=o?t*a.rate:0,c=1e3*s,u=k.getDataBlockData.bind(k);for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position||X.current.has(e.id))continue;X.current.add(e.id);let t=function(e,t){let i=t(e);if(!i)return null;let r=[],a=[],o=i.particleEmitter;if("number"==typeof o){let e=t(o);if(e){let a=h(e,t);if(a){let e=i.particleDensity??10;r.push({data:a,density:e})}}}let n=i.emitters;if(Array.isArray(n))for(let e of n){if("number"!=typeof e)continue;let i=t(e);if(!i)continue;let r=h(i,t);r&&a.push(r)}return 0===r.length&&0===a.length?null:{burstEmitters:r,streamingEmitters:a,lifetimeMS:32*(i.lifetimeMS??31)}}(e.explosionDataBlockId,u);if(!t)continue;let r=[...e.position];for(let e of t.burstEmitters){let t=new S(e.data,256);t.emitBurst(r,e.density);let a=B(e.data.particles.textureName),o=j(256),s=q(a,e.data.particles.useInvAlpha,e.data.orientParticles),l=new n.Mesh(o,s);l.frustumCulled=!1,i.add(l),J.current.push({emitter:t,mesh:l,geometry:o,material:s,targetTexture:a,origin:r,isBurst:!0,hasBurst:!0})}for(let e of t.streamingEmitters){let a=new S(e,256,t.lifetimeMS),o=B(e.particles.textureName),s=j(256),l=q(o,e.particles.useInvAlpha,e.orientParticles),c=new n.Mesh(s,l);c.frustumCulled=!1,i.add(c),J.current.push({emitter:a,mesh:c,geometry:s,material:l,targetTexture:o,origin:r,isBurst:!1,hasBurst:!1})}let a=u(e.explosionDataBlockId);if(I){let o=a?function(e){let t=e.sizes;if(Array.isArray(t)&&t.length>0){let e=0;for(let i of t)e=Math.max(e,i.x,i.y,i.z);if(e>0)return e/1e3}let i=e.particleRadius;return"number"==typeof i&&i>0?i:5}(a):5,s=function(e){if(!e)return 0xff00ff;let t=e.toLowerCase();return t.includes("disc")?4491519:t.includes("grenade")?0xff8800:t.includes("mortar")?0xff4400:t.includes("plasma")?4521796:t.includes("laser")?0xff2222:t.includes("blaster")?0xffff00:t.includes("missile")?0xff6600:t.includes("bomb")?0xff0000:t.includes("mine")?0xff8844:t.includes("concussion")?0xffaa00:t.includes("shocklance")?8930559:t.includes("chaingun")||t.includes("bullet")?0xcccccc:0xff00ff}(e.dataBlock),l=new n.MeshBasicMaterial({color:s,wireframe:!0,transparent:!0,opacity:1,depthWrite:!1}),c=new n.Mesh(F,l);c.frustumCulled=!1,c.scale.setScalar(o),c.position.set(r[1],r[2],r[0]),i.add(c);let{sprite:u,material:d}=function(e,t){let i=document.createElement("canvas"),r=i.getContext("2d");r.font="bold 32px monospace",i.width=Math.ceil(r.measureText(e).width)+16,i.height=48,r.font="bold 32px monospace",r.fillStyle=`#${t.toString(16).padStart(6,"0")}`,r.textBaseline="middle",r.fillText(e,8,i.height/2);let a=new n.CanvasTexture(i),o=new n.SpriteMaterial({map:a,transparent:!0,depthTest:!1,depthWrite:!1}),s=new n.Sprite(o),l=i.width/i.height;return s.scale.set(2*l,2,1),{sprite:s,material:o}}(`${e.id}: ${e.dataBlock??`expId:${e.explosionDataBlockId}`}`,s);u.position.set(r[1],r[2]+o+2,r[0]),u.frustumCulled=!1,i.add(u),ei.current.push({entityId:e.id,mesh:c,material:l,label:u,labelMaterial:d,creationTime:(0,A.effectNow)(),lifetimeMS:Math.max(t.lifetimeMS,3e3),targetRadius:o})}let o=a?.shockwave;if("number"==typeof o){let t=function(e,t){let i=t(e);if(!i)return null;let r=i.colors??[],a=i.times??[0,.5,1,1];return{width:i.width??1,numSegments:Math.max(i.numSegments??16,4),velocity:i.velocity??0,height:i.height??0,verticalCurve:i.verticalCurve??0,acceleration:i.acceleration??0,texWrap:i.texWrap??1,lifetimeMS:i.lifetimeMS??500,is2D:!!i.is2D,renderSquare:!!i.renderSquare,renderBottom:!!i.renderBottom,mapToTerrain:!!i.mapToTerrain,colors:r,times:a,textureName:i.textureName??"",mapToTexture:i.mapToTexture??""}}(o,u);if(t){let a=B(t.textureName),o=z(t.numSegments),s=new n.ShaderMaterial({vertexShader:_,fragmentShader:O,uniforms:{uTexture:{value:a}},transparent:!0,depthWrite:!1,blending:n.AdditiveBlending,side:n.DoubleSide}),l=new n.Mesh(o,s);l.frustumCulled=!1,l.position.set(r[1],r[2],r[0]),i.add(l);let c=null,u=null;t.renderBottom&&(u=z(t.numSegments),(c=new n.Mesh(u,s)).frustumCulled=!1,c.position.set(r[1],r[2],r[0]),c.scale.y=-1,i.add(c));let d=Math.abs(t.velocity)>1e-10?t.velocity:0;er.current.push({entityId:e.id,mesh:l,bottomMesh:c,geometry:o,bottomGeometry:u,material:s,creationTime:(0,A.effectNow)(),lifetimeMS:t.lifetimeMS,data:t,radius:0,velocity:d})}}}let d=new Set;for(let e of r.entities){if(d.add(e.id),!e.maintainEmitterId||Z.current.has(e.id))continue;Z.current.add(e.id);let t=u(e.maintainEmitterId);if(!t)continue;let r=h(t,u);if(!r)continue;let a=e.position?[...e.position]:[0,0,0],o=new S(r,256),s=B(r.particles.textureName),l=j(256),c=q(s,r.particles.useInvAlpha,r.orientParticles),m=new n.Mesh(l,c);m.frustumCulled=!1,i.add(m),J.current.push({emitter:o,mesh:m,geometry:l,material:c,targetTexture:s,origin:a,isBurst:!1,hasBurst:!1,followEntityId:e.id})}for(let e of J.current)e.followEntityId&&!d.has(e.followEntityId)&&e.emitter.kill();for(let e of Z.current)d.has(e)||Z.current.delete(e);let m=J.current;for(let e=m.length-1;e>=0;e--){let t=m[e];if(t.shaderChecked||(!function(e,t,i){let r=e.properties.get(t).currentProgram;if(!r)return;let a=r.program,o=e.getContext();o.getProgramParameter(a,o.LINK_STATUS)||P.error("Shader LINK ERROR (%s): %s",i,o.getProgramInfoLog(a))}(Y,t.material,t.isBurst?"burst":"stream"),t.shaderChecked=!0),t.followEntityId){let e=r.entities.find(e=>e.id===t.followEntityId);e?.position&&(t.origin[0]=e.position[0],t.origin[1]=e.position[1],t.origin[2]=e.position[2]),e?.direction&&(t.emitAxis=e.direction)}if(t.isBurst||t.emitter.emitPeriodic(t.origin,c,t.emitAxis),t.emitter.update(c),D.has(t.targetTexture)&&t.material.uniforms.particleTexture.value!==t.targetTexture&&(t.material.uniforms.particleTexture.value=t.targetTexture),t.material.uniforms.debugOpacity.value=I?.2:1,!function(e){let t=e.emitter.particles,i=e.geometry,r=i.getAttribute("position"),a=i.getAttribute("particleColor"),o=i.getAttribute("particleSize"),n=i.getAttribute("particleSpin"),s=i.getAttribute("orientDir"),l=r.array,c=a.array,u=o.array,d=n.array,m=s.array,p=Math.min(t.length,256),f=e.emitter.data.orientOnVelocity;for(let e=0;e<p;e++){let i=t[e],r=i.pos[1],a=i.pos[2],o=i.pos[0],n=f?i.vel:i.orientDir,s=n[1],p=n[2],h=n[0],g=i.r,y=i.g,S=i.b,v=i.a;for(let t=0;t<4;t++){let n=4*e+t,f=3*n;l[f]=r,l[f+1]=a,l[f+2]=o;let b=4*n;c[b]=g,c[b+1]=y,c[b+2]=S,c[b+3]=v;let M=3*n;m[M]=s,m[M+1]=p,m[M+2]=h,u[n]=i.size,d[n]=i.currentSpin}}for(let e=p;e<256;e++)for(let t=0;t<4;t++)u[4*e+t]=0;r.needsUpdate=!0,a.needsUpdate=!0,o.needsUpdate=!0,n.needsUpdate=!0,s.needsUpdate=!0,i.setDrawRange(0,6*p)}(t),I){t.debugOriginMesh||(t.debugOriginMesh=new n.Mesh(N,E),t.debugOriginMesh.frustumCulled=!1,i.add(t.debugOriginMesh)),t.debugOriginMesh.position.set(t.origin[1],t.origin[2],t.origin[0]),t.debugParticleMeshes||(t.debugParticleMeshes=[]);let e=Math.min(t.emitter.particles.length,8);for(;t.debugParticleMeshes.length<e;){let e=new n.Mesh(R,V);e.frustumCulled=!1,i.add(e),t.debugParticleMeshes.push(e)}for(let e=0;e<t.debugParticleMeshes.length;e++){let i=t.debugParticleMeshes[e];if(e<t.emitter.particles.length){let r=t.emitter.particles[e];i.position.set(r.pos[1],r.pos[2],r.pos[0]),i.visible=!0}else i.visible=!1}}else if(t.debugOriginMesh&&(i.remove(t.debugOriginMesh),t.debugOriginMesh=void 0),t.debugParticleMeshes){for(let e of t.debugParticleMeshes)i.remove(e);t.debugParticleMeshes=void 0}if(t.emitter.isDead()){if(i.remove(t.mesh),t.geometry.dispose(),t.material.dispose(),t.debugOriginMesh&&i.remove(t.debugOriginMesh),t.debugParticleMeshes)for(let e of t.debugParticleMeshes)i.remove(e);m.splice(e,1)}}let p=ei.current,f=(0,A.effectNow)();for(let e=p.length-1;e>=0;e--){let t=p[e],r=Math.min((f-t.creationTime)/t.lifetimeMS,1),a=Math.min(r/.1,1);t.mesh.scale.setScalar(t.targetRadius*a),t.material.opacity=1-r,t.labelMaterial.opacity=1-r,r>=1&&(i.remove(t.mesh),i.remove(t.label),t.material.dispose(),t.labelMaterial.dispose(),p.splice(e,1))}let g=er.current;for(let t=g.length-1;t>=0;t--){let r=g[t],a=Math.min((f-r.creationTime)/r.lifetimeMS,1);r.velocity=r.velocity+r.data.acceleration*s,r.radius=r.radius+r.velocity*s;let o=function(e,t){let{colors:i,times:r}=e;if(0===i.length)return[1,1,1,1];let a=0;for(let e=0;e<r.length-1;e++)t>=r[e]&&(a=e);let o=Math.min(a+1,i.length-1),n=r[a]??0,s=(r[o]??1)-n,l=s>0?Math.min((t-n)/s,1):0,c=i[a]??i[0],u=i[o]??i[0];return[c.r+(u.r-c.r)*l,c.g+(u.g-c.g)*l,c.b+(u.b-c.b)*l,c.a+(u.a-c.a)*l]}(r.data,a);U(r.geometry,r.data,r.radius,o,r.data.is2D),r.bottomGeometry&&U(r.bottomGeometry,r.data,r.radius,o,r.data.is2D),r.data.is2D&&r.mesh.lookAt(e.camera.position),a>=1&&(i.remove(r.mesh),r.bottomMesh&&i.remove(r.bottomMesh),r.geometry.dispose(),r.bottomGeometry?.dispose(),r.material.dispose(),g.splice(t,1))}if(o&&L&&K&&$&&Q.current){for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position)continue;let t=`snd:${e.id}`;if(et.current.has(t))continue;et.current.add(t);let i=u(e.explosionDataBlockId);if(!i)continue;let r=i.soundProfile;if("number"!=typeof r)continue;let a=(0,T.resolveAudioProfile)(r,u);if(!a)continue;let o=new n.Vector3(e.position[1],e.position[2],e.position[0]);(0,T.playOneShotSound)(a,$,K,o,Q.current)}let e=ee.current;for(let t of r.entities){if("Projectile"!==t.type||!t.dataBlockId||!t.position)continue;if(e.has(t.id)){e.get(t.id).position.set(t.position[1],t.position[2],t.position[0]);continue}if(e.size>=20)continue;let i=u(t.dataBlockId);if(!i)continue;let r=i.sound;if("number"!=typeof r)continue;let o=(0,T.resolveAudioProfile)(r,u);if(o&&o.isLooping&&o.is3D)try{let i=(0,l.audioToUrl)(o.filename),r=(0,T.getSoundGeneration)();(0,T.getCachedAudioBuffer)(i,K,i=>{if(r!==(0,T.getSoundGeneration)()||!d.has(t.id)||e.has(t.id))return;let s=Q.current;if(!s)return;let l=new n.PositionalAudio($);l.setBuffer(i),l.setDistanceModel("inverse"),l.setRefDistance(o.refDist),l.setMaxDistance(o.maxDist),l.setRolloffFactor(1),l.setVolume(o.volume),l.setPlaybackRate(a.rate),l.setLoop(!0),l.position.set(t.position[1],t.position[2],t.position[0]),s.add(l),(0,T.trackSound)(l),l.play(),e.set(t.id,l)})}catch{}}for(let[t,i]of e)if(!d.has(t)){(0,T.untrackSound)(i);try{i.stop()}catch{}try{i.disconnect()}catch{}Q.current?.remove(i),e.delete(t)}for(let e of r.audioEvents){let t=`${e.timeSec}:${e.profileId}:${e.position?.x??""}`;if(et.current.has(t))continue;et.current.add(t);let i=(0,T.resolveAudioProfile)(e.profileId,u);if(!i)continue;let r=e.position?new n.Vector3(e.position.y,e.position.z,e.position.x):void 0;(0,T.playOneShotSound)(i,$,K,r,Q.current)}}if(X.current.size>500){let e=new Set(r.entities.map(W));for(let t of X.current)e.has(t)||X.current.delete(t)}if(et.current.size>500){let e=new Set(r.entities.map(G));for(let t of et.current)t.startsWith("snd:")&&e.has(t.slice(4))||et.current.delete(t)}},M[7]=L,M[8]=$,M[9]=K,M[10]=I,M[11]=Y,M[12]=k,M[13]=C,M[14]=g):g=M[14],(0,a.useFrame)(g),M[15]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>{let e=Q.current;for(let t of J.current){if(e&&(e.remove(t.mesh),t.debugOriginMesh&&e.remove(t.debugOriginMesh),t.debugParticleMeshes))for(let i of t.debugParticleMeshes)e.remove(i);t.geometry.dispose(),t.material.dispose()}for(let t of(J.current=[],ei.current))e&&(e.remove(t.mesh),e.remove(t.label)),t.material.dispose(),t.labelMaterial.dispose();for(let t of(ei.current=[],er.current))e&&(e.remove(t.mesh),t.bottomMesh&&e.remove(t.bottomMesh)),t.geometry.dispose(),t.bottomGeometry?.dispose(),t.material.dispose();for(let[,t]of(er.current=[],X.current.clear(),Z.current.clear(),ee.current)){(0,T.untrackSound)(t);try{t.stop()}catch{}try{t.disconnect()}catch{}e&&e.remove(t)}ee.current.clear(),et.current.clear()},y=[],M[15]=y,M[16]=v):(y=M[15],v=M[16]),(0,r.useEffect)(v,y),M[17]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("group",{ref:Q}),M[17]=b):b=M[17],b}function G(e){return e.id}function W(e){return e.id}function H(e){return e.gl}var K=e.i(9721),$=e.i(92224),Y=e.i(93784);function Q(e,t){return{id:e.id,className:e.className??e.type,ghostIndex:e.ghostIndex,dataBlockId:e.dataBlockId,shapeHint:e.shapeHint,spawnTime:t,position:e.position,rotation:e.rotation,velocity:e.velocity,keyframes:[{time:t??0,position:e.position??[0,0,0],rotation:e.rotation??[0,0,0,1]}]}}var J=e.i(77964);let X=new WeakMap;function Z(e){let t=X.get(e);return t||(t=new Map(e.entities.map(e=>[e.id,e])),X.set(e,t)),t}let ee=new n.Vector3,et=new n.Quaternion,ei=new n.Quaternion,er=new n.Quaternion(0,1,0,0),ea=new n.Vector3,eo=new n.Vector3,en=new n.Vector3;function es(e){let c,u,d,m,p,f,h,g,y,S=(0,i.c)(25),{recording:v}=e,b=(0,A.useEngineStoreApi)(),M=(0,r.useRef)(0),x=(0,r.useRef)(null),w=(0,r.useRef)(null);S[0]===Symbol.for("react.memo_cache_sentinel")?(c=new n.Vector3(0,s.DEFAULT_EYE_HEIGHT,0),S[0]=c):c=S[0];let P=(0,r.useRef)(c),k=(0,r.useRef)(v.streamingPlayback??null),C=(0,r.useRef)(null);S[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,S[1]=u):u=S[1];let D=(0,r.useRef)(u),I=(0,r.useRef)(null),[B,N]=(0,r.useState)(null);S[2]===Symbol.for("react.memo_cache_sentinel")?(d=e=>{if(e===I.current)return;I.current=e;let t=D.current,i=new Map;for(let a of e.entities){let o=t.get(a.id),n=o&&("Shape"===o.renderType||"Player"===o.renderType||"Explosion"===o.renderType);if(!o||o.className!==(a.className??a.type)||o.ghostIndex!==a.ghostIndex||o.dataBlockId!==a.dataBlockId||o.shapeHint!==a.shapeHint||n&&null!=a.dataBlock&&o.shapeName!==a.dataBlock||"Player"!==o.renderType&&n&&o.weaponShape!==a.weaponShape)o=function(e,t){if(e.sceneData){let i={id:e.id,className:e.className??e.type,ghostIndex:e.ghostIndex,dataBlockId:e.dataBlockId,shapeHint:e.shapeHint,spawnTime:t};switch(e.sceneData.className){case"TerrainBlock":return{...i,renderType:"TerrainBlock",terrainData:e.sceneData};case"InteriorInstance":return{...i,renderType:"InteriorInstance",interiorData:e.sceneData};case"Sky":return{...i,renderType:"Sky",skyData:e.sceneData};case"Sun":return{...i,renderType:"Sun",sunData:e.sceneData};case"WaterBlock":return{...i,renderType:"WaterBlock",waterData:e.sceneData};case"MissionArea":return{...i,renderType:"MissionArea",missionAreaData:e.sceneData};case"TSStatic":return{...Q(e,t),renderType:"Shape",shapeName:e.sceneData.shapeName,shapeType:"TSStatic",dataBlock:e.dataBlock}}}return e.visual?.kind==="tracer"?{...Q(e,t),renderType:"Tracer",visual:e.visual,dataBlock:e.dataBlock,direction:e.direction}:e.visual?.kind==="sprite"?{...Q(e,t),renderType:"Sprite",visual:e.visual}:"Player"===e.type?{...Q(e,t),renderType:"Player",shapeName:e.dataBlock,dataBlock:e.dataBlock,weaponShape:e.weaponShape,packShape:e.packShape,flagShape:e.flagShape,falling:e.falling,jetting:e.jetting,playerName:e.playerName,iffColor:e.iffColor,threads:e.threads,weaponImageState:e.weaponImageState,weaponImageStates:e.weaponImageStates,headPitch:e.headPitch,headYaw:e.headYaw,targetRenderFlags:e.targetRenderFlags}:"Explosion"===e.type?{...Q(e,t),renderType:"Explosion",shapeName:e.dataBlock,dataBlock:e.dataBlock,explosionDataBlockId:e.explosionDataBlockId,faceViewer:e.faceViewer}:"ForceFieldBare"===e.className?{...Q(e,t),renderType:"ForceFieldBare"}:"AudioEmitter"===e.className?{...Q(e,t),renderType:"AudioEmitter",audioFileName:e.audioFileName,audioVolume:e.audioVolume,audioIs3D:e.audioIs3D,audioIsLooping:e.audioIsLooping??!0,audioMinDistance:e.audioMinDistance,audioMaxDistance:e.audioMaxDistance,audioMinLoopGap:e.audioMinLoopGap,audioMaxLoopGap:e.audioMaxLoopGap}:"WayPoint"===e.className?{...Q(e,t),renderType:"WayPoint",label:e.label}:"Camera"===e.className?{...Q(e,t),renderType:"Camera"}:{...Q(e,t),renderType:"Shape",shapeName:e.dataBlock,shapeType:"Turret"===e.className?"Turret":"Item"===e.className?"Item":"StaticShape",dataBlock:e.dataBlock,weaponShape:e.weaponShape,threads:e.threads,targetRenderFlags:e.targetRenderFlags,iffColor:e.iffColor}}(a,e.timeSec);else{var r=o;switch(r.renderType){case"Player":r.threads=a.threads,r.weaponShape=a.weaponShape,r.packShape=a.packShape,r.flagShape=a.flagShape,r.falling=a.falling,r.jetting=a.jetting,r.weaponImageState=a.weaponImageState,r.weaponImageStates=a.weaponImageStates,r.playerName=a.playerName,r.iffColor=a.iffColor,r.headPitch=a.headPitch,r.headYaw=a.headYaw,r.targetRenderFlags=a.targetRenderFlags;break;case"Shape":r.threads=a.threads,r.targetRenderFlags=a.targetRenderFlags,r.iffColor=a.iffColor}}if(i.set(a.id,o),(0,J.isSceneEntity)(o)||"None"===o.renderType)continue;let s=o.keyframes;0===s.length&&s.push({time:e.timeSec,position:a.position??[0,0,0],rotation:a.rotation??[0,0,0,1]});let l=s[0];l.time=e.timeSec,a.position&&(l.position=a.position),a.rotation&&(l.rotation=a.rotation),l.velocity=a.velocity,l.health=a.health,l.energy=a.energy,l.actionAnim=a.actionAnim,l.actionAtEnd=a.actionAtEnd,l.damageState=a.damageState}for(let[r,a]of t)if(!i.has(r)&&"Explosion"===a.renderType&&a.shapeName&&null!=a.spawnTime&&e.timeSec-a.spawnTime<5){i.set(r,a);continue}let a=i.size!==t.size||[...i.keys()].some(e=>!t.has(e));D.current=i,a&&$.gameEntityStore.getState().setAllStreamEntities(Array.from(i.values()));let o=null;if(e.camera?.mode==="first-person"&&e.camera.controlEntityId){let t=i.get(e.camera.controlEntityId),r=t?t.shapeName:void 0;r&&(o=r)}N(e=>e===o?e:o)},S[2]=d):d=S[2];let E=d;return S[3]!==b||S[4]!==v.gameType||S[5]!==v.missionName||S[6]!==v.recorderName||S[7]!==v.recordingDate||S[8]!==v.serverDisplayName||S[9]!==v.source||S[10]!==v.streamingPlayback?(m=()=>{(0,T.stopAllTrackedSounds)(),k.current=v.streamingPlayback??null,D.current=new Map,I.current=null,C.current=null,(0,Y.resetStreamPlayback)(),M.current=0,x.current=null,w.current=null;let e=k.current;if(Y.streamPlaybackStore.setState({playback:e}),$.gameEntityStore.getState().beginStreaming(v.source),!e)return void b.getState().setPlaybackStreamSnapshot(null);e.onMissionInfoChange=()=>{$.gameEntityStore.getState().setMissionInfo({missionDisplayName:e.missionDisplayName??void 0,missionTypeDisplayName:e.missionTypeDisplayName??void 0,gameClassName:e.gameClassName??void 0,recorderName:e.connectedPlayerName??void 0})};let t=e.missionDisplayName,i=e.missionTypeDisplayName,r=e.gameClassName,a=e.serverDisplayName,n=e.connectedPlayerName;for(let s of("live"!==v.source&&e.reset(),e.missionDisplayName=t,e.missionTypeDisplayName=i,e.gameClassName=r,e.serverDisplayName=a,e.connectedPlayerName=n,$.gameEntityStore.getState().setMissionInfo({missionName:v.missionName??void 0,missionTypeDisplayName:v.gameType??void 0,missionDisplayName:t??void 0,gameClassName:r??void 0,serverDisplayName:a??v.serverDisplayName??void 0,recorderName:n??v.recorderName??void 0,recordingDate:v.recordingDate??void 0}),e.getEffectShapes()))o.useGLTF.preload((0,l.shapeToUrl)(s));let s=e.getSnapshot();return Y.streamPlaybackStore.setState({time:s.timeSec}),M.current=s.timeSec,x.current=s,w.current=s,E(s),b.getState().setPlaybackStreamSnapshot(s),C.current=s,()=>{(0,T.stopAllTrackedSounds)(),k.current=null,(0,Y.resetStreamPlayback)()}},S[3]=b,S[4]=v.gameType,S[5]=v.missionName,S[6]=v.recorderName,S[7]=v.recordingDate,S[8]=v.serverDisplayName,S[9]=v.source,S[10]=v.streamingPlayback,S[11]=m):m=S[11],S[12]!==b||S[13]!==v?(p=[v,b,E],S[12]=b,S[13]=v,S[14]=p):p=S[14],(0,r.useEffect)(m,p),S[15]!==b||S[16]!==v.source?(f=(e,t)=>{let i=k.current;if(!i)return;let r=b.getState(),a=r.playback,o="playing"===a.status,n=a.timeMs/1e3,l=!o&&Math.abs(n-M.current)>5e-4,c=o&&Math.abs(n-Y.streamPlaybackStore.getState().time)>.05,u=l||c;u&&(M.current=n),o&&((0,A.advanceEffectClock)(t,a.rate),M.current=M.current+t*a.rate);let d=Math.max(1,Math.ceil(1e3*t*Math.max(a.rate,.01)/32)+2),m=M.current+s.STREAM_TICK_SEC,p=i.stepToTime(m,o&&!u?d:1/0),f=w.current;!f||p.timeSec<f.timeSec||p.timeSec-f.timeSec>1.5*s.STREAM_TICK_SEC?(x.current=p,w.current=p):p.timeSec!==f.timeSec&&(x.current=f,w.current=p);let h=w.current??p,g=x.current??h,y=h.timeSec-s.STREAM_TICK_SEC,S=Math.max(0,Math.min(1,(M.current-y)/s.STREAM_TICK_SEC));Y.streamPlaybackStore.setState({time:M.current}),p.exhausted&&o&&(M.current=Math.min(M.current,p.timeSec)),E(h),Y.streamPlaybackStore.getState().entities=D.current,h!==C.current&&(C.current=h,r.setPlaybackStreamSnapshot(h));let T=h.camera,I=T&&g.camera&&g.camera.mode===T.mode&&g.camera.controlEntityId===T.controlEntityId&&g.camera.orbitTargetId===T.orbitTargetId?g.camera:null,B=Y.streamPlaybackStore.getState().freeFlyCamera,N="live"===v.source;if(T&&!B){if(I){let t=I.position[0],i=I.position[1],r=I.position[2],a=T.position[0],o=T.position[1],n=T.position[2];e.camera.position.set(i+(o-i)*S,r+(n-r)*S,t+(a-t)*S),N||(et.set(...I.rotation),ei.set(...T.rotation),et.slerp(ei,S),e.camera.quaternion.copy(et))}else e.camera.position.set(T.position[1],T.position[2],T.position[0]),N||e.camera.quaternion.set(...T.rotation);if(Number.isFinite(T.fov)&&"isPerspectiveCamera"in e.camera&&e.camera.isPerspectiveCamera){let t=e.camera,i=I&&Number.isFinite(I.fov)?I.fov+(T.fov-I.fov)*S:T.fov,r=(0,s.torqueHorizontalFovToThreeVerticalFov)(i,t.aspect);Math.abs(t.fov-r)>.01&&(t.fov=r,t.updateProjectionMatrix())}}let R=Z(h),V=Z(g),F=D.current,_=Y.streamPlaybackStore.getState().root;if(_)for(let t of _.children){let i=F.get(t.name);if(i&&(0,J.isSceneEntity)(i))continue;let r=R.get(t.name);if(!r){let e=i&&"keyframes"in i?i.keyframes:void 0;if(e?.[0]?.position){let i=e[0];t.visible=!0,t.position.set(i.position[1],i.position[2],i.position[0]);continue}}if(!r?.position){t.visible=!1;continue}t.visible=!0;let a=V.get(t.name);if(a?.position){let e=a.position[0],i=a.position[1],o=a.position[2],n=r.position[0],s=r.position[1],l=r.position[2],c=e+(n-e)*S,u=i+(s-i)*S,d=o+(l-o)*S;t.position.set(u,d,c)}else t.position.set(r.position[1],r.position[2],r.position[0]);r.faceViewer?t.quaternion.copy(e.camera.quaternion).multiply(er):r.visual?.kind==="tracer"?t.quaternion.identity():r.rotation&&(a?.rotation?(et.set(...a.rotation),ei.set(...r.rotation),et.slerp(ei,S),t.quaternion.copy(et)):t.quaternion.set(...r.rotation))}let O=T?.mode;if(!B&&!N&&"third-person"===O&&_&&T?.orbitTargetId){let t=_.children.find(e=>e.name===T.orbitTargetId);if(t){let i=R.get(T.orbitTargetId);eo.copy(t.position),i?.type==="Player"&&(eo.y=eo.y+1);let r=!1;if(T.orbitDirection)ea.set(T.orbitDirection[0],T.orbitDirection[1],T.orbitDirection[2]),r=ea.lengthSq()>1e-8;else if("number"==typeof T.yaw&&"number"==typeof T.pitch){let e=Math.sin(T.pitch),t=Math.cos(T.pitch),i=Math.sin(T.yaw),a=Math.cos(T.yaw);ea.set(-a*t,-e,-i*t),r=ea.lengthSq()>1e-8}if(r||(ea.copy(e.camera.position).sub(eo),r=ea.lengthSq()>1e-8),r){ea.normalize();let t=Math.max(.1,T.orbitDistance??4);en.copy(eo).addScaledVector(ea,t),e.camera.position.copy(en),e.camera.lookAt(eo)}}}if(!B&&"first-person"===O&&_&&T?.controlEntityId){let t=_.children.find(e=>e.name===T.controlEntityId);t?(ee.copy(P.current).applyQuaternion(t.quaternion),e.camera.position.add(ee)):e.camera.position.y=e.camera.position.y+P.current.y}o&&p.exhausted&&r.setPlaybackStatus("paused");let z=1e3*M.current;Math.abs(z-a.timeMs)>.5&&r.setPlaybackTime(z)},S[15]=b,S[16]=v.source,S[17]=f):f=S[17],(0,a.useFrame)(f),S[18]!==v.streamingPlayback?(h=(0,t.jsx)(L,{playback:v.streamingPlayback,snapshotRef:w}),S[18]=v.streamingPlayback,S[19]=h):h=S[19],S[20]!==B?(g=B&&(0,t.jsx)(r.Suspense,{children:(0,t.jsx)(K.PlayerEyeOffset,{shapeName:B,eyeOffsetRef:P})}),S[20]=B,S[21]=g):g=S[21],S[22]!==h||S[23]!==g?(y=(0,t.jsxs)(t.Fragment,{children:[h,g]}),S[22]=h,S[23]=g,S[24]=y):y=S[24],y}e.s(["StreamingController",()=>es],51295)}]);