mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-03-19 12:21:06 +00:00
1 line
No EOL
1.4 KiB
JavaScript
1 line
No EOL
1.4 KiB
JavaScript
import{r as e}from"./chunk-DECur_0Z.js";import{r as t}from"./jsx-runtime-BpGWiA-R.js";import"./react-three-fiber.esm-1xQMUSXT.js";import"./Html-BD9DC-n9.js";import{a as n}from"./SettingsProvider-DlQTXm3x.js";import"./logger-DePRU8Hm.js";import"./traditional-DPdbI9gv.js";import{c as r}from"./three.module-Bu2Gkdne.js";import"./mission-CWASMBNZ.js";import{i,r as a}from"./engineStore-Clbs91WD.js";import{B as o,M as s}from"./index-C2tCa94d.js";import{getCachedAudioBuffer as c,getSoundGeneration as l,trackSound as u,untrackSound as d}from"./AudioEmitter-CIApS5vH.js";var f=e(t(),1);function p(){let{audioLoader:e,audioListener:t}=o(),{audioEnabled:p}=n(),m=i(e=>e.playback.streamSnapshot?.chatMessages),h=i(e=>e.playback.streamSnapshot?.timeSec),g=(0,f.useRef)(new WeakSet),_=(0,f.useRef)(new Map);return(0,f.useEffect)(()=>{if(!p||!e||!t||!m?.length||h==null)return;let n=g.current,i=_.current;for(let o of m)if(!n.has(o)&&(n.add(o),o.soundPath&&!(Math.abs(h-o.timeSec)>2)))try{let n=s(o.soundPath),f=o.soundPitch??1,p=a.getState().playback.rate,m=o.sender,h=l();c(n,e,e=>{if(h!==l())return;if(m){let e=i.get(m);if(e){try{e.stop()}catch{}d(e);try{e.disconnect()}catch{}i.delete(m)}}let n=new r(t);n.setBuffer(e),n.setPlaybackRate(f*p),u(n,f),m&&i.set(m,n),n.play(),n.source.onended=()=>{d(n);try{n.disconnect()}catch{}m&&i.get(m)===n&&i.delete(m)}})}catch{}},[p,e,t,m,h]),null}export{p as ChatSoundPlayer}; |