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

1 line
No EOL
5.3 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,29055,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(15080),o=e.i(71753),i=e.i(90072),u=e.i(12979),a=e.i(51434),c=e.i(79123),s=e.i(89887);e.i(13876);var l=e.i(58647);let f=new Map,d=new Map;function p(e,t=1){d.set(e,t)}function h(e){d.delete(e)}let y=0;function m(){return y}function g(){for(let[e]of(y++,d)){try{e.stop()}catch{}try{e.disconnect()}catch{}}d.clear()}function S(e,t){let r=t(e),n=r?.filename;if(!n)return null;let o=n.endsWith(".wav")?n:`${n}.wav`,i=r.description,u=null!=i?t(i):void 0,a=u?.is3D??!0,c=u?.isLooping??!1,s=u?.referenceDistance??20;return{filename:o,is3D:a,isLooping:c,refDist:s,maxDist:u?.maxDistance??100,volume:u?.volume??1}}function b(e,t,r,n,o){let a;try{a=(0,u.audioToUrl)(e.filename)}catch{return}let c=l.engineStore.getState().playback.rate,s=y;R(a,r,r=>{if(s===y)try{if(e.is3D&&o){let u=new i.PositionalAudio(t);u.setBuffer(r),u.setDistanceModel("inverse"),u.setRefDistance(e.refDist),u.setMaxDistance(e.maxDist),u.setRolloffFactor(1),u.setVolume(e.volume),u.setPlaybackRate(c),n&&u.position.copy(n),o.add(u),d.set(u,1),u.play(),u.source.onended=()=>{d.delete(u);try{u.disconnect()}catch{}o.remove(u)}}else{let n=new i.Audio(t);n.setBuffer(r),n.setVolume(e.volume),n.setPlaybackRate(c),d.set(n,1),n.play(),n.source.onended=()=>{d.delete(n);try{n.disconnect()}catch{}}}}catch{}})}function R(e,t,r){f.has(e)?r(f.get(e)):t.load(e,t=>{f.set(e,t),r(t)},void 0,t=>{console.error("Audio load error",e,t)})}l.engineStore.subscribe(e=>e.playback.rate,e=>{for(let[t,r]of d)try{t.setPlaybackRate(r*e)}catch{}});let v=(0,r.memo)(function({entity:e}){let{debugMode:l}=(0,c.useDebug)(),f=e.audioFileName??"",d=e.audioVolume??1,p=e.audioMinDistance??1,h=e.audioMaxDistance??1,y=e.audioMinLoopGap??0,m=e.audioMaxLoopGap??0,g=e.audioIs3D??!0?1:0,S=e.audioIsLooping??!0,[b,v,M]=e.position??[0,0,0],{scene:D,camera:k}=(0,n.useThree)(),{audioLoader:A,audioListener:P}=(0,a.useAudio)(),{audioEnabled:T}=(0,c.useSettings)(),w=(0,r.useRef)(null),x=(0,r.useRef)(null),B=(0,r.useRef)(null),E=(0,r.useRef)(!1),C=(0,r.useRef)(!1),G=(0,r.useRef)(new i.Vector3(b,v,M)),L=(0,r.useRef)(0),V=()=>{null!=x.current&&(clearTimeout(x.current),x.current=null),null!=B.current&&(clearTimeout(B.current),B.current=null)};(0,r.useEffect)(()=>{let e;if(A&&P){if(L.current++,g){let t=new i.PositionalAudio(P);t.position.copy(G.current),t.setDistanceModel("inverse"),t.setRefDistance(p),t.setMaxDistance(h),t.setRolloffFactor(1),t.setVolume(d),e=t,D.add(e)}else(e=new i.Audio(P)).setVolume(d);return w.current=e,()=>{V();try{e.stop()}catch{}try{e.disconnect()}catch{}g&&D.remove(e),w.current=null,E.current=!1,C.current=!1}}},[A,P,g,p,h,d,D]);let j=(e,t)=>{if(S)if(y>0||m>0){let r=Math.max(0,y),n=Math.max(r,m),o=r===n?r:Math.random()*(n-r)+r;e.loop=!1;let i=()=>{t===L.current&&(!1===e.isPlaying?x.current=setTimeout(()=>{if(t===L.current)try{e.play(),j(e,t)}catch{}},o):B.current=setTimeout(i,100))};B.current=setTimeout(i,100)}else e.setLoop(!0)},F=e=>{if(!A)return;let t=L.current;if(E.current)try{e.isPlaying||(e.play(),j(e,t))}catch{}else{let r;try{r=(0,u.audioToUrl)(f)}catch{return}R(r,A,r=>{if(t===L.current&&!e.buffer){e.setBuffer(r),E.current=!0;try{e.play(),j(e,t)}catch{}}})}};return(0,r.useEffect)(()=>{let e=w.current;e&&!g&&T&&f&&F(e)},[T,g,f,A,P]),(0,o.useFrame)(()=>{let e=w.current;if(!e||!g||!T||!f)return;let t=k.position.distanceTo(G.current),r=C.current,n=t<=h;if(n&&!r)C.current=!0,F(e);else if(!n&&r){C.current=!1,V();try{e.stop()}catch{}}}),(0,r.useEffect)(()=>{let e=w.current;if(e&&!T){V();try{e.stop()}catch{}C.current=!1}},[T]),l?(0,t.jsxs)("mesh",{position:G.current,children:[(0,t.jsx)("sphereGeometry",{args:[p,12,12]}),(0,t.jsx)("meshBasicMaterial",{color:"#00ff00",wireframe:!0,opacity:.05,transparent:!0,toneMapped:!1}),(0,t.jsx)(s.FloatingLabel,{color:"#00ff00",position:[0,p+1,0],children:f})]}):null});e.s(["AudioEmitter",0,v,"audioBufferCache",0,f,"getCachedAudioBuffer",()=>R,"getSoundGeneration",()=>m,"playOneShotSound",()=>b,"resolveAudioProfile",()=>S,"stopAllTrackedSounds",()=>g,"trackSound",()=>p,"untrackSound",()=>h])},9962,e=>{"use strict";var t=e.i(71645),r=e.i(90072),n=e.i(12979),o=e.i(51434),i=e.i(29055),u=e.i(79123);e.i(13876);var a=e.i(58647);function c(){let{audioLoader:e,audioListener:c}=(0,o.useAudio)(),s=(0,u.useSettings)(),l=s?.audioEnabled??!1,f=(0,a.useEngineSelector)(e=>e.playback.streamSnapshot?.chatMessages),d=(0,a.useEngineSelector)(e=>e.playback.streamSnapshot?.timeSec),p=(0,t.useRef)(new WeakSet),h=(0,t.useRef)(new Map);return(0,t.useEffect)(()=>{if(!l||!e||!c||!f?.length||null==d)return;let t=p.current,o=h.current;for(let u of f){if(!t.has(u)){if((t.add(u),u.soundPath)&&!(Math.abs(d-u.timeSec)>2))try{let t=(0,n.audioToUrl)(u.soundPath),s=u.soundPitch??1,l=a.engineStore.getState().playback.rate,f=u.sender,d=(0,i.getSoundGeneration)();(0,i.getCachedAudioBuffer)(t,e,e=>{if(d!==(0,i.getSoundGeneration)())return;if(f){let e=o.get(f);if(e){try{e.stop()}catch{}(0,i.untrackSound)(e);try{e.disconnect()}catch{}o.delete(f)}}let t=new r.Audio(c);t.setBuffer(e),t.setPlaybackRate(s*l),(0,i.trackSound)(t,s),f&&o.set(f,t),t.play(),t.source.onended=()=>{(0,i.untrackSound)(t);try{t.disconnect()}catch{}f&&o.get(f)===t&&o.delete(f)}})}catch{}}}},[l,e,c,f,d]),null}e.s(["ChatSoundPlayer",()=>c])}]);