import{GLTFLoader as m,ArrayItem as h}from"./glTFLoader-Bp7IfGPK.js";import{d as n,aG as p,aH as y}from"./index-CDrXokXW.js";import"./index-DWyDLubb.js";import"./bone-z620UXj2.js";import"./skeleton-3aE04lM6.js";import"./rawTexture-DYLCXHMF.js";import"./assetContainer-D7EiOqw6.js";import"./objectModelMapping-CGWnurZP.js";let i=0,u=null;class r{static get Default(){return r._Default||(r._Default=new r),r._Default}constructor(){const e=r.Configuration.decoder;this._decoderModulePromise=n.LoadBabylonScriptAsync(e.url).then(()=>MeshoptDecoder.ready)}dispose(){delete this._decoderModulePromise}async decodeGltfBufferAsync(e,s,l,t,o){await this._decoderModulePromise,i===0&&(MeshoptDecoder.useWorkers(1),i=1);const a=await MeshoptDecoder.decodeGltfBufferAsync(s,l,e,t,o);return u!==null&&clearTimeout(u),u=setTimeout(()=>{MeshoptDecoder.useWorkers(0),i=0,u=null},1e3),a}}r.Configuration={decoder:{url:`${n._DefaultCdnUrl}/meshopt_decoder.js`}};r._Default=null;const d="EXT_meshopt_compression";class _{constructor(e){this.name=d,this.enabled=e.isExtensionUsed(d),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(e,s){return m.LoadExtensionAsync(e,s,this.name,async(l,t)=>{const o=s;if(o._meshOptData)return await o._meshOptData;const a=h.Get(`${e}/buffer`,this._loader.gltf.buffers,t.buffer);return o._meshOptData=this._loader.loadBufferAsync(`/buffers/${a.index}`,a,t.byteOffset||0,t.byteLength).then(async c=>await r.Default.decodeGltfBufferAsync(c,t.count,t.byteStride,t.mode,t.filter)),await o._meshOptData})}}p(d);y(d,!0,f=>new _(f));export{_ as EXT_meshopt_compression};
