THREE.DRACOLoader=function(e){THREE.Loader.call(this,e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}},THREE.DRACOLoader.prototype=Object.assign(Object.create(THREE.Loader.prototype),{constructor:THREE.DRACOLoader,setDecoderPath:function(e){return this.decoderPath=e,this},setDecoderConfig:function(e){return this.decoderConfig=e,this},setWorkerLimit:function(e){return this.workerLimit=e,this},setVerbosity:function(){console.warn("THREE.DRACOLoader: The .setVerbosity() method has been removed.")},setDrawMode:function(){console.warn("THREE.DRACOLoader: The .setDrawMode() method has been removed.")},setSkipDequantization:function(){console.warn("THREE.DRACOLoader: The .setSkipDequantization() method has been removed.")},load:function(e,t,r,o){var a=new THREE.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),"use-credentials"===this.crossOrigin&&a.setWithCredentials(!0),a.load(e,e=>{var r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(o)},r,o)},decodeDracoFile:function(e,t,r,o){var a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:o||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,a).then(t)},decodeGeometry:function(e,t){for(var r in t.attributeTypes){var o=t.attributeTypes[r];void 0!==o.BYTES_PER_ELEMENT&&(t.attributeTypes[r]=o.name)}var a,n=JSON.stringify(t);if(THREE.DRACOLoader.taskCache.has(e)){var s=THREE.DRACOLoader.taskCache.get(e);if(s.key===n)return s.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var i=this.workerNextTaskID++,d=e.byteLength,c=this._getWorker(i,d).then(r=>(a=r,new Promise((r,o)=>{a._callbacks[i]={resolve:r,reject:o},a.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return c.finally(()=>{a&&i&&this._releaseTask(a,i)}),THREE.DRACOLoader.taskCache.set(e,{key:n,promise:c}),c},_createGeometry:function(e){var t=new THREE.BufferGeometry;e.index&&t.setIndex(new THREE.BufferAttribute(e.index.array,1));for(var r=0;r{r.load(e,t,void 0,o)})},preload:function(){return this._initDecoder(),this},_initDecoder:function(){if(this.decoderPending)return this.decoderPending;var e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{var r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);var o=THREE.DRACOLoader.DRACOWorker.toString(),a=["/* draco decoder */",r,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending},_getWorker:function(e,t){return this._initDecoder().then(()=>{var r;return this.workerPool.lengtht._taskLoad?-1:1})),(r=this.workerPool[this.workerPool.length-1])._taskCosts[e]=t,r._taskLoad+=t,r})},_releaseTask:function(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]},debug:function(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))},dispose:function(){for(var e=0;e{var t=e.draco,o=new t.Decoder,i=new t.DecoderBuffer;i.Init(new Int8Array(n),n.byteLength);try{var d=function(e,t,o,a){var n,s,i=a.attributeIDs,d=a.attributeTypes,c=t.GetEncodedGeometryType(o);if(c===e.TRIANGULAR_MESH)n=new e.Mesh,s=t.DecodeBufferToMesh(o,n);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");n=new e.PointCloud,s=t.DecodeBufferToPointCloud(o,n)}if(!s.ok()||0===n.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+s.error_msg());var u={index:null,attributes:[]};for(var h in i){var l,f,y=self[d[h]];if(a.useUniqueIDs)f=i[h],l=t.GetAttributeByUniqueId(n,f);else{if(-1===(f=t.GetAttributeId(n,e[i[h]])))continue;l=t.GetAttribute(n,f)}u.attributes.push(r(e,t,n,h,y,l))}if(c===e.TRIANGULAR_MESH){for(var A=n.num_faces(),b=new Uint32Array(3*A),E=new e.DracoInt32Array,w=0;we.array.buffer);d.index&&c.push(d.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:d},c)}catch(e){console.error(e),self.postMessage({type:"error",id:a.id,error:e.message})}finally{t.destroy(i),t.destroy(o)}})}}},THREE.DRACOLoader.taskCache=new WeakMap,THREE.DRACOLoader.setDecoderPath=function(){console.warn("THREE.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.")},THREE.DRACOLoader.setDecoderConfig=function(){console.warn("THREE.DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.")},THREE.DRACOLoader.releaseDecoderModule=function(){console.warn("THREE.DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.")},THREE.DRACOLoader.getDecoderModule=function(){console.warn("THREE.DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.")};