t2-mapper/docs/_next/static/chunks/0c29da8d7ee18a67.js
2026-03-09 12:38:40 -07:00

89 lines
No EOL
33 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,21500,e=>{"use strict";var t=e.i(43476),i=e.i(932),r=e.i(32865),a=e.i(71645),o=e.i(71753),n=e.i(78140),l=e.i(90072),s=e.i(85557),c=e.i(12979),u=e.i(15080),d=e.i(75567);let m=Math.PI/180,p=Math.PI/18e4;function f(e,t,i){let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:i}function h(e,t,i){let r=e[t];return"boolean"==typeof r?r:"number"==typeof r?0!==r:i}function g(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:f(e,"ejectionPeriodMS",100),periodVarianceMS:f(e,"periodVarianceMS",0),ejectionVelocity:.01*f(e,"ejectionVelocity",200),velocityVariance:.01*f(e,"velocityVariance",100),ejectionOffset:.01*f(e,"ejectionOffset",0),thetaMin:f(e,"thetaMin",0),thetaMax:f(e,"thetaMax",90),phiReferenceVel:f(e,"phiReferenceVel",0),phiVariance:f(e,"phiVariance",360),overrideAdvances:h(e,"overrideAdvances",!1),orientParticles:h(e,"orientParticles",!1),orientOnVelocity:h(e,"orientOnVelocity",!0),lifetimeMS:f(e,"lifetimeMS",0)<<5,lifetimeVarianceMS:f(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*f(e,"dragCoefficient",0),windCoefficient:f(e,"windCoefficient",1),gravityCoefficient:10*f(e,"gravityCoefficient",0),inheritedVelFactor:f(e,"inheritedVelFactor",0),constantAcceleration:f(e,"constantAcceleration",0),lifetimeMS:f(e,"lifetimeMS",31)<<5,lifetimeVarianceMS:f(e,"lifetimeVarianceMS",0)<<5,spinSpeed:f(e,"spinSpeed",0),spinRandomMin:f(e,"spinRandomMin",1e3)+-1e3,spinRandomMax:f(e,"spinRandomMax",1e3)+-1e3,useInvAlpha:h(e,"useInvAlpha",!1),keys:i,textureName:r}}(i)}:null}function y(e,t){return e+(2*Math.random()-1)*t}function S(e,t,i,r,a,o,n){let l=Math.cos(n),s=Math.sin(n),c=e*r+t*a+i*o;return[e*l+(a*i-o*t)*s+r*c*(1-l),t*l+(o*e-r*i)*s+a*c*(1-l),i*l+(r*t-a*e)*s+o*c*(1-l)]}class b{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(y(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(y(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,l=a.acc[0]-a.vel[0]*o,s=a.acc[1]-a.vel[1]*o,c=a.acc[2]-a.vel[2]*o+-9.81*n;a.vel[0]+=l*t,a.vel[1]+=s*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*p}}isDead(){return this.emitterDead&&0===this.particles.length}kill(){this.emitterDead=!0}addParticle(e,t){var i,r,a,o;let n,l,s,c,u=this.data,d=u.particles,p=t[0],f=t[1],h=t[2],g=(i=p,r=f,.9>Math.abs(a=h)?(n=r,l=-i,s=0):(n=-a,l=0,s=i),(c=Math.sqrt(n*n+l*l+s*s))<1e-8?[1,0,0]:[n/c,l/c,s/c]),b=(u.thetaMin+Math.random()*(u.thetaMax-u.thetaMin))*m,v=(this.internalClock/1e3*u.phiReferenceVel+Math.random()*u.phiVariance)*m;[p,f,h]=S(p,f,h,g[0],g[1],g[2],b),[p,f,h]=S(p,f,h,t[0],t[1],t[2],v);let M=Math.sqrt(p*p+f*f+h*h);M>1e-8&&(p/=M,f/=M,h/=M);let x=y(u.ejectionVelocity,u.velocityVariance),w=[e[0]+p*u.ejectionOffset,e[1]+f*u.ejectionOffset,e[2]+h*u.ejectionOffset],A=[p*x,f*x,h*x],T=d.constantAcceleration,P=[A[0]*T,A[1]*T,A[2]*T],k=d.lifetimeMS;d.lifetimeVarianceMS>0&&(k+=Math.round(y(0,d.lifetimeVarianceMS))),k=Math.max(1,k);let C=d.spinSpeed+((o=d.spinRandomMin)+Math.random()*(d.spinRandomMax-o)),I=d.keys[0];this.particles.push({pos:w,vel:A,acc:P,orientDir:[p,f,h],currentAge:0,totalLifetime:k,dataIndex:0,spinSpeed:C,currentSpin:0,r:I.r,g:I.g,b:I.b,a:I.a,size:I.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);
}
}
`,M=`
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 x=e.i(79123),w=e.i(51434),A=e.i(29055);e.i(13876);var T=e.i(58647);let P=new Float32Array([-.5,-.5,.5,-.5,.5,.5,-.5,.5]),k=new Map,C=new Set,I=new l.DataTexture(new Uint8Array([255,255,255,255]),1,1,l.RGBAFormat,l.UnsignedByteType);function B(e){if(!e)return I;let t=k.get(e);if(t)return t;try{let t=(0,c.textureToUrl)(e),i=(0,d.loadTexture)(t,e=>{(0,s.setupEffectTexture)(e),C.add(e)});return(0,s.setupEffectTexture)(i),k.set(e,i),i}catch{return I}}I.needsUpdate=!0;let D=new l.SphereGeometry(1,6,6),E=new l.MeshBasicMaterial({color:0xff0000,wireframe:!0}),R=new l.BoxGeometry(.3,.3,.3),V=new l.MeshBasicMaterial({color:65280,wireframe:!0}),F=new l.SphereGeometry(1,12,8),N=`
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);
}
`,_=`
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 O(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 n=new l.BufferGeometry,s=new l.BufferAttribute(i,3);s.setUsage(35048),n.setAttribute("position",s);let c=new l.BufferAttribute(r,2);c.setUsage(35048),n.setAttribute("texCoord",c);let u=new l.BufferAttribute(a,4);return u.setUsage(35048),n.setAttribute("vertexColor",u),n.setIndex(new l.BufferAttribute(o,1)),n}function z(e,t,i,r,a){let o=e.getAttribute("position").array,n=e.getAttribute("texCoord").array,l=e.getAttribute("vertexColor").array,s=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 b=3*y;o[b]=r*s,o[b+1]=0,o[b+2]=h*s;let v=e/u*t.texWrap,M=2*g;n[M]=v,n[M+1]=.05;let x=2*y;n[x]=v,n[x+1]=.95;let w=4*g;l[w]=d,l[w+1]=m,l[w+2]=p,l[w+3]=f;let A=4*y;l[A]=d,l[A+1]=m,l[A+2]=p,l[A+3]=f}e.getAttribute("position").needsUpdate=!0,e.getAttribute("texCoord").needsUpdate=!0,e.getAttribute("vertexColor").needsUpdate=!0,e.computeBoundingSphere()}function U(e){let t=new l.BufferGeometry,i=4*e,r=new Float32Array(2*i);for(let t=0;t<e;t++)r.set(P,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),n=new Float32Array(4*i),s=new Float32Array(i),c=new Float32Array(i),u=new Float32Array(3*i);return t.setIndex(new l.Uint16BufferAttribute(a,1)),t.setAttribute("quadCorner",new l.Float32BufferAttribute(r,2)),t.setAttribute("position",new l.Float32BufferAttribute(o,3)),t.setAttribute("particleColor",new l.Float32BufferAttribute(n,4)),t.setAttribute("particleSize",new l.Float32BufferAttribute(s,1)),t.setAttribute("particleSpin",new l.Float32BufferAttribute(c,1)),t.setAttribute("orientDir",new l.Float32BufferAttribute(u,3)),t.setDrawRange(0,0),t}function q(e,t,i=!1){let r=C.has(e);return new l.ShaderMaterial({vertexShader:v,fragmentShader:M,uniforms:{particleTexture:{value:r?e:I},hasTexture:{value:!0},debugOpacity:{value:1},uOrientParticles:{value:i}},transparent:!0,depthWrite:!1,depthTest:!0,side:l.DoubleSide,blending:t?l.NormalBlending:l.AdditiveBlending})}function j(e){let r,n,s,d,m,p,f,h,y,S,v,M=(0,i.c)(18),{playback:P,snapshotRef:k}=e,{debugMode:I}=(0,x.useDebug)(),{audioEnabled:j}=(0,x.useSettings)(),{audioLoader:H,audioListener:$}=(0,w.useAudio)(),K=(0,u.useThree)(W),Y=(0,a.useRef)(null);M[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],M[0]=r):r=M[0];let Q=(0,a.useRef)(r);M[1]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,M[1]=n):n=M[1];let X=(0,a.useRef)(n);M[2]===Symbol.for("react.memo_cache_sentinel")?(s=new Set,M[2]=s):s=M[2];let J=(0,a.useRef)(s);M[3]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,M[3]=d):d=M[3];let Z=(0,a.useRef)(d);M[4]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,M[4]=m):m=M[4];let ee=(0,a.useRef)(m);M[5]===Symbol.for("react.memo_cache_sentinel")?(p=[],M[5]=p):p=M[5];let et=(0,a.useRef)(p);M[6]===Symbol.for("react.memo_cache_sentinel")?(f=[],M[6]=f):f=M[6];let ei=(0,a.useRef)(f);return M[7]!==j||M[8]!==$||M[9]!==H||M[10]!==I||M[11]!==K||M[12]!==P||M[13]!==k?(h=(e,t)=>{let i=Y.current,r=k.current;if(!i||!r)return;let a=T.engineStore.getState().playback,o="playing"===a.status,n=o?t*a.rate:0,s=1e3*n,u=P.getDataBlockData.bind(P);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=g(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=g(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 b(e.data,256);t.emitBurst(r,e.density);let a=B(e.data.particles.textureName),o=U(256),n=q(a,e.data.particles.useInvAlpha,e.data.orientParticles),s=new l.Mesh(o,n);s.frustumCulled=!1,i.add(s),Q.current.push({emitter:t,mesh:s,geometry:o,material:n,targetTexture:a,origin:r,isBurst:!0,hasBurst:!0})}for(let e of t.streamingEmitters){let a=new b(e,256,t.lifetimeMS),o=B(e.particles.textureName),n=U(256),s=q(o,e.particles.useInvAlpha,e.orientParticles),c=new l.Mesh(n,s);c.frustumCulled=!1,i.add(c),Q.current.push({emitter:a,mesh:c,geometry:n,material:s,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,n=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),s=new l.MeshBasicMaterial({color:n,wireframe:!0,transparent:!0,opacity:1,depthWrite:!1}),c=new l.Mesh(F,s);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 l.CanvasTexture(i),o=new l.SpriteMaterial({map:a,transparent:!0,depthTest:!1,depthWrite:!1}),n=new l.Sprite(o),s=i.width/i.height;return n.scale.set(2*s,2,1),{sprite:n,material:o}}(`${e.id}: ${e.dataBlock??`expId:${e.explosionDataBlockId}`}`,n);u.position.set(r[1],r[2]+o+2,r[0]),u.frustumCulled=!1,i.add(u),et.current.push({entityId:e.id,mesh:c,material:s,label:u,labelMaterial:d,creationTime:(0,T.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=O(t.numSegments),n=new l.ShaderMaterial({vertexShader:N,fragmentShader:_,uniforms:{uTexture:{value:a}},transparent:!0,depthWrite:!1,blending:l.AdditiveBlending,side:l.DoubleSide}),s=new l.Mesh(o,n);s.frustumCulled=!1,s.position.set(r[1],r[2],r[0]),i.add(s);let c=null,u=null;t.renderBottom&&(u=O(t.numSegments),(c=new l.Mesh(u,n)).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;ei.current.push({entityId:e.id,mesh:s,bottomMesh:c,geometry:o,bottomGeometry:u,material:n,creationTime:(0,T.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||J.current.has(e.id))continue;J.current.add(e.id);let t=u(e.maintainEmitterId);if(!t)continue;let r=g(t,u);if(!r)continue;let a=e.position?[...e.position]:[0,0,0],o=new b(r,256),n=B(r.particles.textureName),s=U(256),c=q(n,r.particles.useInvAlpha,r.orientParticles),m=new l.Mesh(s,c);m.frustumCulled=!1,i.add(m),Q.current.push({emitter:o,mesh:m,geometry:s,material:c,targetTexture:n,origin:a,isBurst:!1,hasBurst:!1,followEntityId:e.id})}for(let e of Q.current)e.followEntityId&&!d.has(e.followEntityId)&&e.emitter.kill();for(let e of J.current)d.has(e)||J.current.delete(e);let m=Q.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)||console.error(`[ParticleFX] Shader LINK ERROR (${i}):`,o.getProgramInfoLog(a))}(K,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,s,t.emitAxis),t.emitter.update(s),C.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"),l=i.getAttribute("orientDir"),s=r.array,c=a.array,u=o.array,d=n.array,m=l.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,l=n[1],p=n[2],h=n[0],g=i.r,y=i.g,S=i.b,b=i.a;for(let t=0;t<4;t++){let n=4*e+t,f=3*n;s[f]=r,s[f+1]=a,s[f+2]=o;let v=4*n;c[v]=g,c[v+1]=y,c[v+2]=S,c[v+3]=b;let M=3*n;m[M]=l,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,l.needsUpdate=!0,i.setDrawRange(0,6*p)}(t),I){t.debugOriginMesh||(t.debugOriginMesh=new l.Mesh(D,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 l.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=et.current,f=(0,T.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 h=ei.current;for(let t=h.length-1;t>=0;t--){let r=h[t],a=Math.min((f-r.creationTime)/r.lifetimeMS,1);r.velocity=r.velocity+r.data.acceleration*n,r.radius=r.radius+r.velocity*n;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,l=(r[o]??1)-n,s=l>0?Math.min((t-n)/l,1):0,c=i[a]??i[0],u=i[o]??i[0];return[c.r+(u.r-c.r)*s,c.g+(u.g-c.g)*s,c.b+(u.b-c.b)*s,c.a+(u.a-c.a)*s]}(r.data,a);z(r.geometry,r.data,r.radius,o,r.data.is2D),r.bottomGeometry&&z(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(),h.splice(t,1))}if(o&&j&&H&&$&&Y.current){for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position)continue;let t=`snd:${e.id}`;if(ee.current.has(t))continue;ee.current.add(t);let i=u(e.explosionDataBlockId);if(!i)continue;let r=i.soundProfile;if("number"!=typeof r)continue;let a=(0,A.resolveAudioProfile)(r,u);if(!a)continue;let o=new l.Vector3(e.position[1],e.position[2],e.position[0]);(0,A.playOneShotSound)(a,$,H,o,Y.current)}let e=Z.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,A.resolveAudioProfile)(r,u);if(o&&o.isLooping&&o.is3D)try{let i=(0,c.audioToUrl)(o.filename),r=(0,A.getSoundGeneration)();(0,A.getCachedAudioBuffer)(i,H,i=>{if(r!==(0,A.getSoundGeneration)()||!d.has(t.id)||e.has(t.id))return;let n=Y.current;if(!n)return;let s=new l.PositionalAudio($);s.setBuffer(i),s.setDistanceModel("inverse"),s.setRefDistance(o.refDist),s.setMaxDistance(o.maxDist),s.setRolloffFactor(1),s.setVolume(o.volume),s.setPlaybackRate(a.rate),s.setLoop(!0),s.position.set(t.position[1],t.position[2],t.position[0]),n.add(s),(0,A.trackSound)(s),s.play(),e.set(t.id,s)})}catch{}}for(let[t,i]of e)if(!d.has(t)){(0,A.untrackSound)(i);try{i.stop()}catch{}try{i.disconnect()}catch{}Y.current?.remove(i),e.delete(t)}for(let e of r.audioEvents){let t=`${e.timeSec}:${e.profileId}:${e.position?.x??""}`;if(ee.current.has(t))continue;ee.current.add(t);let i=(0,A.resolveAudioProfile)(e.profileId,u);if(!i)continue;let r=e.position?new l.Vector3(e.position.y,e.position.z,e.position.x):void 0;(0,A.playOneShotSound)(i,$,H,r,Y.current)}}if(X.current.size>500){let e=new Set(r.entities.map(G));for(let t of X.current)e.has(t)||X.current.delete(t)}if(ee.current.size>500){let e=new Set(r.entities.map(L));for(let t of ee.current)t.startsWith("snd:")&&e.has(t.slice(4))||ee.current.delete(t)}},M[7]=j,M[8]=$,M[9]=H,M[10]=I,M[11]=K,M[12]=P,M[13]=k,M[14]=h):h=M[14],(0,o.useFrame)(h),M[15]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>{let e=Y.current;for(let t of Q.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(Q.current=[],et.current))e&&(e.remove(t.mesh),e.remove(t.label)),t.material.dispose(),t.labelMaterial.dispose();for(let t of(et.current=[],ei.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(ei.current=[],X.current.clear(),J.current.clear(),Z.current)){(0,A.untrackSound)(t);try{t.stop()}catch{}try{t.disconnect()}catch{}e&&e.remove(t)}Z.current.clear(),ee.current.clear()},y=[],M[15]=y,M[16]=S):(y=M[15],S=M[16]),(0,a.useEffect)(S,y),M[17]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("group",{ref:Y}),M[17]=v):v=M[17],v}function L(e){return e.id}function G(e){return e.id}function W(e){return e.gl}var H=e.i(9721),$=e.i(92224),K=e.i(93784);function Y(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 Q=e.i(77964);let X=new WeakMap;function J(e){let t=X.get(e);return t||(t=new Map(e.entities.map(e=>[e.id,e])),X.set(e,t)),t}let Z=new l.Vector3,ee=new l.Quaternion,et=new l.Quaternion,ei=new l.Quaternion(0,1,0,0),er=new l.Vector3,ea=new l.Vector3,eo=new l.Vector3;function en(e){let r,u,d,m,p,f,h,g,y,S=(0,i.c)(19),{recording:b}=e,v=(0,T.useEngineStoreApi)(),M=(0,a.useRef)(0),x=(0,a.useRef)(null),w=(0,a.useRef)(null);S[0]===Symbol.for("react.memo_cache_sentinel")?(r=new l.Vector3(0,s.DEFAULT_EYE_HEIGHT,0),S[0]=r):r=S[0];let P=(0,a.useRef)(r),k=(0,a.useRef)(b.streamingPlayback??null),C=(0,a.useRef)(null);S[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,S[1]=u):u=S[1];let I=(0,a.useRef)(u),B=(0,a.useRef)(null),[D,E]=(0,a.useState)(null);S[2]===Symbol.for("react.memo_cache_sentinel")?(d=e=>{if(e===B.current)return;B.current=e;let t=I.current,i=new Map,r=!1;for(let o of e.entities){let n=t.get(o.id);if(n&&n.className===(o.className??o.type)&&n.ghostIndex===o.ghostIndex&&n.dataBlockId===o.dataBlockId&&n.shapeHint===o.shapeHint&&n.shapeName===o.dataBlock&&("Player"===n.renderType||n.weaponShape===o.weaponShape)){var a=n;switch(a.renderType){case"Player":a.threads=o.threads,a.weaponShape=o.weaponShape,a.weaponImageState=o.weaponImageState,a.weaponImageStates=o.weaponImageStates,a.playerName=o.playerName,a.iffColor=o.iffColor,a.headPitch=o.headPitch,a.headYaw=o.headYaw,a.targetRenderFlags=o.targetRenderFlags;break;case"Shape":a.threads=o.threads,a.targetRenderFlags=o.targetRenderFlags,a.iffColor=o.iffColor}}else n=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{...Y(e,t),renderType:"Shape",shapeName:e.sceneData.shapeName,shapeType:"TSStatic",dataBlock:e.dataBlock}}}return e.visual?.kind==="tracer"?{...Y(e,t),renderType:"Tracer",visual:e.visual,dataBlock:e.dataBlock,direction:e.direction}:e.visual?.kind==="sprite"?{...Y(e,t),renderType:"Sprite",visual:e.visual}:"Player"===e.type?{...Y(e,t),renderType:"Player",shapeName:e.dataBlock,dataBlock:e.dataBlock,weaponShape:e.weaponShape,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?{...Y(e,t),renderType:"Explosion",shapeName:e.dataBlock,dataBlock:e.dataBlock,explosionDataBlockId:e.explosionDataBlockId,faceViewer:e.faceViewer}:"ForceFieldBare"===e.className?{...Y(e,t),renderType:"ForceFieldBare"}:"AudioEmitter"===e.className?{...Y(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?{...Y(e,t),renderType:"WayPoint",label:e.label}:"Camera"===e.className?{...Y(e,t),renderType:"Camera"}:{...Y(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}}(o,e.timeSec),r=!0;if(i.set(o.id,n),(0,Q.isSceneEntity)(n)||"None"===n.renderType)continue;let l=n.keyframes;0===l.length&&l.push({time:e.timeSec,position:o.position??[0,0,0],rotation:o.rotation??[0,0,0,1]});let s=l[0];s.time=e.timeSec,o.position&&(s.position=o.position),o.rotation&&(s.rotation=o.rotation),s.velocity=o.velocity,s.health=o.health,s.energy=o.energy,s.actionAnim=o.actionAnim,s.actionAtEnd=o.actionAtEnd,s.damageState=o.damageState}for(let[a,o]of t)if(!i.has(a)){if("Explosion"===o.renderType&&o.shapeName&&null!=o.spawnTime&&e.timeSec-o.spawnTime<5){i.set(a,o);continue}r=!0}i.size!==t.size&&(r=!0),I.current=i,r&&$.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)}E(e=>e===o?e:o)},S[2]=d):d=S[2];let R=d;return S[3]!==v||S[4]!==b.streamingPlayback?(m=()=>{(0,A.stopAllTrackedSounds)(),k.current=b.streamingPlayback??null,I.current=new Map,B.current=null,C.current=null,(0,K.resetStreamPlayback)(),M.current=0,x.current=null,w.current=null;let e=k.current;if(K.streamPlaybackStore.setState({playback:e}),$.gameEntityStore.getState().beginStreaming(),!e)return void v.getState().setPlaybackStreamSnapshot(null);for(let t of(e.reset(),e.getEffectShapes()))n.useGLTF.preload((0,c.shapeToUrl)(t));let t=e.getSnapshot();return K.streamPlaybackStore.setState({time:t.timeSec}),M.current=t.timeSec,x.current=t,w.current=t,R(t),v.getState().setPlaybackStreamSnapshot(t),C.current=t,()=>{(0,A.stopAllTrackedSounds)(),$.gameEntityStore.getState().endStreaming(),(0,K.resetStreamPlayback)(),v.getState().setPlaybackStreamSnapshot(null)}},S[3]=v,S[4]=b.streamingPlayback,S[5]=m):m=S[5],S[6]!==v||S[7]!==b?(p=[b,v,R],S[6]=v,S[7]=b,S[8]=p):p=S[8],(0,a.useEffect)(m,p),S[9]!==v||S[10]!==b.source?(f=(e,t)=>{let i=k.current;if(!i)return;let r=v.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-K.streamPlaybackStore.getState().time)>.05,u=l||c;u&&(M.current=n),o&&((0,T.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));K.streamPlaybackStore.setState({time:M.current}),p.exhausted&&o&&(M.current=Math.min(M.current,p.timeSec)),R(h),K.streamPlaybackStore.getState().entities=I.current,h!==C.current&&(C.current=h,r.setPlaybackStreamSnapshot(h));let A=h.camera,B=A&&g.camera&&g.camera.mode===A.mode&&g.camera.controlEntityId===A.controlEntityId&&g.camera.orbitTargetId===A.orbitTargetId?g.camera:null,D=K.streamPlaybackStore.getState().freeFlyCamera,E="live"===b.source;if(A&&!D){if(B){let t=B.position[0],i=B.position[1],r=B.position[2],a=A.position[0],o=A.position[1],n=A.position[2];e.camera.position.set(i+(o-i)*S,r+(n-r)*S,t+(a-t)*S),E||(ee.set(...B.rotation),et.set(...A.rotation),ee.slerp(et,S),e.camera.quaternion.copy(ee))}else e.camera.position.set(A.position[1],A.position[2],A.position[0]),E||e.camera.quaternion.set(...A.rotation);if(!E&&Number.isFinite(A.fov)&&"isPerspectiveCamera"in e.camera&&e.camera.isPerspectiveCamera){let t=e.camera,i=B&&Number.isFinite(B.fov)?B.fov+(A.fov-B.fov)*S:A.fov,r=(0,s.torqueHorizontalFovToThreeVerticalFov)(i,t.aspect);Math.abs(t.fov-r)>.01&&(t.fov=r,t.updateProjectionMatrix())}}let V=J(h),F=J(g),N=I.current,_=K.streamPlaybackStore.getState().root;if(_)for(let t of _.children){let i=N.get(t.name);if(i&&(0,Q.isSceneEntity)(i))continue;let r=V.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=F.get(t.name);if(a?.position){let e=a.position[0],i=a.position[1],o=a.position[2],n=r.position[0],l=r.position[1],s=r.position[2],c=e+(n-e)*S,u=i+(l-i)*S,d=o+(s-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(ei):r.visual?.kind==="tracer"?t.quaternion.identity():r.rotation&&(a?.rotation?(ee.set(...a.rotation),et.set(...r.rotation),ee.slerp(et,S),t.quaternion.copy(ee)):t.quaternion.set(...r.rotation))}let O=A?.mode;if(!D&&!E&&"third-person"===O&&_&&A?.orbitTargetId){let t=_.children.find(e=>e.name===A.orbitTargetId);if(t){let i=V.get(A.orbitTargetId);ea.copy(t.position),i?.type==="Player"&&(ea.y=ea.y+1);let r=!1;if("number"==typeof A.yaw&&"number"==typeof A.pitch){let e=Math.sin(A.pitch),t=Math.cos(A.pitch),i=Math.sin(A.yaw),a=Math.cos(A.yaw);er.set(-t,-i*e,-a*e),r=er.lengthSq()>1e-8}if(r||(er.copy(e.camera.position).sub(ea),r=er.lengthSq()>1e-8),r){er.normalize();let t=Math.max(.1,A.orbitDistance??4);eo.copy(ea).addScaledVector(er,t),e.camera.position.copy(eo),e.camera.lookAt(ea)}}}if(!D&&"first-person"===O&&_&&A?.controlEntityId){let t=_.children.find(e=>e.name===A.controlEntityId);t?(Z.copy(P.current).applyQuaternion(t.quaternion),e.camera.position.add(Z)):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[9]=v,S[10]=b.source,S[11]=f):f=S[11],(0,o.useFrame)(f),S[12]!==b.streamingPlayback?(h=(0,t.jsx)(j,{playback:b.streamingPlayback,snapshotRef:w}),S[12]=b.streamingPlayback,S[13]=h):h=S[13],S[14]!==D?(g=D&&(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(H.PlayerEyeOffset,{shapeName:D,eyeOffsetRef:P})}),S[14]=D,S[15]=g):g=S[15],S[16]!==h||S[17]!==g?(y=(0,t.jsxs)(t.Fragment,{children:[h,g]}),S[16]=h,S[17]=g,S[18]=y):y=S[18],y}function el(){let e,a=(0,i.c)(2),o=(0,r.useRecording)();return o?(a[0]!==o?(e=(0,t.jsx)(en,{recording:o}),a[0]=o,a[1]=e):e=a[1],e):null}e.s(["DemoPlayback",()=>el],21500)}]);