UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

3 lines (2 loc) 1.7 kB
import{GLTFLoader as e,ArrayItem as t}from"./glTFLoader-DEYqxGxH.esm.min.js";import{b as s,bJ as o,bI as r}from"./index-Bw2N6w1y.esm.min.js";import"./bone-BwMp7T0B.esm.min.js";import"./skeleton-CkTZwWbM.esm.min.js";import"./rawTexture-CPAqHIA7.esm.min.js";import"./assetContainer-21j7tcC8.esm.min.js";import"./objectModelMapping-DX92iJ8M.esm.min.js";let n=0,a=null;class i{static get Default(){return i._Default||(i._Default=new i),i._Default}constructor(){const e=i.Configuration.decoder;this._decoderModulePromise=s.LoadBabylonScriptAsync(e.url).then((()=>MeshoptDecoder.ready))}dispose(){delete this._decoderModulePromise}async decodeGltfBufferAsync(e,t,s,o,r){await this._decoderModulePromise,0===n&&(MeshoptDecoder.useWorkers(1),n=1);const i=await MeshoptDecoder.decodeGltfBufferAsync(t,s,e,o,r);return null!==a&&clearTimeout(a),a=setTimeout((()=>{MeshoptDecoder.useWorkers(0),n=0,a=null}),1e3),i}}i.Configuration={decoder:{url:`${s._DefaultCdnUrl}/meshopt_decoder.js`}},i._Default=null;const d="EXT_meshopt_compression";class l{constructor(e){this.name=d,this.enabled=e.isExtensionUsed(d),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(s,o){return e.LoadExtensionAsync(s,o,this.name,(async(e,r)=>{const n=o;if(n._meshOptData)return await n._meshOptData;const a=t.Get(`${s}/buffer`,this._loader.gltf.buffers,r.buffer);return n._meshOptData=this._loader.loadBufferAsync(`/buffers/${a.index}`,a,r.byteOffset||0,r.byteLength).then((async e=>await i.Default.decodeGltfBufferAsync(e,r.count,r.byteStride,r.mode,r.filter))),await n._meshOptData}))}}o(d),r(d,!0,(e=>new l(e)));export{l as EXT_meshopt_compression}; //# sourceMappingURL=EXT_meshopt_compression-DOWaelfQ.esm.min.js.map