1?d=new ae:c.length===1?d=c[0]:d=new Ar,d!==c[0])for(let h=0,p=c.length;h{const h=new Map;for(const[p,v]of r.associations)(p instanceof mc||p instanceof Sp)&&h.set(p,v);return d.traverse(p=>{const v=r.associations.get(p);v!=null&&h.set(p,v)}),h};return r.associations=c(a),a})}_createAnimationTracks(e,t,i,r,a){const s=[],o=e.name?e.name:e.uuid,l=[];u9[a.path]===u9.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let c;switch(u9[a.path]){case u9.weights:c=Tp;break;case u9.rotation:c=Ap;break;case u9.position:case u9.scale:c=Cp;break;default:switch(i.itemSize){case 1:c=Tp;break;case 2:case 3:default:c=Cp;break}break}const d=r.interpolation!==void 0?sI[r.interpolation]:Q_,h=this._getArrayFromAccessor(i);for(let p=0,v=l.length;p{this.parse(s,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,G6).catch(i)}decodeDracoFile(e,t,i,r,a=h5,s=()=>{}){const o={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:a};return this.decodeGeometry(e,o).then(t).catch(s)}decodeGeometry(e,t){const i=JSON.stringify(t);if(wc.has(e)){const l=wc.get(e);if(l.key===i)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const a=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(a,s).then(l=>(r=l,new Promise((c,d)=>{r._callbacks[a]={resolve:c,reject:d},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),wc.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new Pn;e.index&&t.setIndex(new kn(e.index.array,1));for(let i=0;i{i.load(e,r,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",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(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const a=pI.toString(),s=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
+`);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengtha._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const h=d.draco,p=new h.Decoder;try{const v=t(h,p,new Int8Array(l),c),T=v.attributes.map(I=>I.array.buffer);v.index&&T.push(v.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:v},T)}catch(v){console.error(v),self.postMessage({type:"error",id:o.id,error:v.message})}finally{h.destroy(p)}});break}};function t(s,o,l,c){const d=c.attributeIDs,h=c.attributeTypes;let p,v;const T=o.GetEncodedGeometryType(l);if(T===s.TRIANGULAR_MESH)p=new s.Mesh,v=o.DecodeArrayToMesh(l,l.byteLength,p);else if(T===s.POINT_CLOUD)p=new s.PointCloud,v=o.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!v.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+v.error_msg());const I={index:null,attributes:[]};for(const k in d){const G=self[h[k]];let V,Z;if(c.useUniqueIDs)Z=d[k],V=o.GetAttributeByUniqueId(p,Z);else{if(Z=o.GetAttributeId(p,s[d[k]]),Z===-1)continue;V=o.GetAttribute(p,Z)}const Y=r(s,o,p,k,G,V);k==="color"&&(Y.vertexColorSpace=c.vertexColorSpace),I.attributes.push(Y)}return T===s.TRIANGULAR_MESH&&(I.index=i(s,o,p)),s.destroy(p),I}function i(s,o,l){const d=l.num_faces()*3,h=d*4,p=s._malloc(h);o.GetTrianglesUInt32Array(l,h,p);const v=new Uint32Array(s.HEAPF32.buffer,p,d).slice();return s._free(p),{array:v,itemSize:1}}function r(s,o,l,c,d,h){const p=h.num_components(),T=l.num_points()*p,I=T*d.BYTES_PER_ELEMENT,k=a(s,d),G=s._malloc(I);o.GetAttributeDataArrayForAllPoints(l,h,k,I,G);const V=new d(s.HEAPF32.buffer,G,T).slice();return s._free(G),{name:c,array:V,itemSize:p}}function a(s,o){switch(o){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}let Zs={GLTFLoader:"GLTF",TextureLoader:"Texture",FontLoader:"Font",MMDLoader:"MMD",MTLLoader:"MTL",OBJLoader:"OBJ",PCDLoader:"PCD",FileLoader:"File",ImageLoader:"Image",ObjectLoader:"Object",MaterialLoader:"Material",CubeTextureLoader:"CubeTexture",RGBELoader:"RGBELoader",FBXLoader:"FBX"};const yI=Object.values(Zs);class vI extends hl{constructor({dracoPath:e,cloneTextures:t=!1}={}){super(),this.dracoPath=e||"./draco/gltf/",this.cloneTextures=t,this.loaded=!1,this.itemsLoaded=0,this.itemsTotal=0,this.assets=[],this.loaders={},this.initDefaultLoader()}initManager(){const e=new Ik;return e.onProgress=(t,i,r)=>{this.itemsLoaded=i,this.itemsTotal=r,this.emit("onProgress",t,i,r)},e.onError=t=>{this.emit("onError",t)},e}initDefaultLoader(){[{loader:FR,name:"GLTFLoader"},{loader:K_,name:"TextureLoader"}].map(e=>this.addLoader(e.loader,e.name))}initDraco(e){const t=new gI;t.setDecoderPath(this.dracoPath),t.preload(),e.setDRACOLoader(t)}addLoader(e,t=""){if(e.name&&Zs[t]){if(!this.loaders[t]){let r=new e(this.manager),a=t;r instanceof Ph&&(a==="GLTFLoader"&&this.initDraco(r),this.loaders[Zs[a]]=r)}}else throw new Error("请配置正确的加载器")}loadItem(e){return new Promise((t,i)=>{if(!this.loaders[e.type])throw new Error(`资源${e.path}没有配置加载器`);this.loaders[e.type].load(e.path,r=>{this.itemsLoaded++,this.emit("onProgress",e.path,this.itemsLoaded,this.itemsTotal),t(l3(G2({},e),{data:r}))},null,r=>{this.emit("onError",r),i(r)})})}loadAll(e){return this.itemsLoaded=0,this.itemsTotal=0,new Promise((t,i)=>{let r=this.matchType(e),a=[];this.itemsTotal=r.length,r.map(s=>{let o=this.loadItem(s);a.push(o)}),Promise.all(a).then(s=>{this.assets=s,this.loaded=!0,this.emit("onLoad"),t(s)}).catch(s=>{this.emit("onError",s),i(s)})})}matchType(e){return this.assets=e.map(t=>({type:yI.includes(t.type)?t.type:"",path:t.path,name:t.name,data:null})).filter(t=>{if(!t.type)throw new Error(`资源${t.path},type不正确`);return t.type}),this.assets}getResource(e){var i;let t=this.assets.find(r=>r.name===e);if(!t)throw new Error(`资源${e}不存在`);return this.cloneTextures&&t.type===Zs.TextureLoader&&((i=t.data)!=null&&i.isTexture)?t.data.clone():t.data}destroy(){this.off("onProgress"),this.off("onLoad"),this.off("onError"),this.assets=[]}}function _I(n=10,e=62){var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[],r;if(e=e||t.length,n)for(r=0;rbI(typeof n=="string"?JSON.parse(n):n);function bI(n){var t,i,r,a;let e=(n==null?void 0:n.features)||[];for(let s=0;s0){for(s=e[--t];t>0&&(i=s,r=e[--t],s=i+r,a=r-(s-i),!a););t>0&&(a<0&&e[t-1]<0||a>0&&e[t-1]>0)&&(r=a*2,i=s+r,r==i-s&&(s=i))}return s}}function*TI(n){for(const e of n)yield*yp(e)}function db(n){return Array.from(TI(n))}var me=1e-6,AI=1e-12,A0=Math.PI,S6=A0/2,Dp=A0/4,gn=A0*2,D6=180/A0,Je=A0/180,Be=Math.abs,hb=Math.atan,J7=Math.atan2,Ve=Math.cos,xI=Math.exp,EI=Math.log,He=Math.sin,PI=Math.sign||function(n){return n>0?1:n<0?-1:0},fl=Math.sqrt,MI=Math.tan;function kI(n){return n>1?0:n<-1?A0:Math.acos(n)}function Q7(n){return n>1?S6:n<-1?-S6:Math.asin(n)}function C7(){}function yo(n,e){n&&Bp.hasOwnProperty(n.type)&&Bp[n.type](n,e)}var Op={Feature:function(n,e){yo(n.geometry,e)},FeatureCollection:function(n,e){for(var t=n.features,i=-1,r=t.length;++iA0&&(n-=Math.round(n/gn)*gn),[n,e]}Gd.invert=Gd;function fb(n,e,t){return(n%=gn)?e||t?Bd(jp(n),Up(e,t)):jp(n):e||t?Up(e,t):Gd}function zp(n){return function(e,t){return e+=n,Be(e)>A0&&(e-=Math.round(e/gn)*gn),[e,t]}}function jp(n){var e=zp(n);return e.invert=zp(-n),e}function Up(n,e){var t=Ve(n),i=He(n),r=Ve(e),a=He(e);function s(o,l){var c=Ve(l),d=Ve(o)*c,h=He(o)*c,p=He(l),v=p*t+d*i;return[J7(h*r-v*a,d*t-p*i),Q7(v*r+h*a)]}return s.invert=function(o,l){var c=Ve(l),d=Ve(o)*c,h=He(o)*c,p=He(l),v=p*r-h*a;return[J7(h*r+p*a,d*t+v*i),Q7(v*t-d*i)]},s}function II(n){n=fb(n[0]*Je,n[1]*Je,n.length>2?n[2]*Je:0);function e(t){return t=n(t[0]*Je,t[1]*Je),t[0]*=D6,t[1]*=D6,t}return e.invert=function(t){return t=n.invert(t[0]*Je,t[1]*Je),t[0]*=D6,t[1]*=D6,t},e}function NI(n,e,t,i,r,a){if(t){var s=Ve(e),o=He(e),l=i*t;r==null?(r=e+i*gn,a=e-l/2):(r=$p(s,r),a=$p(s,a),(i>0?r