From beaac6313a7eba9c79b4f312cbb5713e97fff384 Mon Sep 17 00:00:00 2001 From: king2088 Date: Sat, 30 Mar 2024 17:22:26 +0800 Subject: [PATCH] build 2.2.4 --- dist/style.css | 2 +- dist/vue-3d-loader.cjs.js | 2 +- dist/vue-3d-loader.esm.js | 4 ++-- dist/vue-3d-loader.global.js | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/style.css b/dist/style.css index 5db72a1..32ace5e 100644 --- a/dist/style.css +++ b/dist/style.css @@ -1 +1 @@ -.viewer-container[data-v-550d01bf]{position:relative;width:100%;height:100%;margin:0;border:0;padding:0}.viewer-container div[data-v-550d01bf]{position:absolute!important;left:0px!important;opacity:1!important}.viewer-canvas[data-v-550d01bf]{width:100%;height:100%} +.viewer-container[data-v-e92274c2]{position:relative;width:100%;height:100%;margin:0;border:0;padding:0}.viewer-container div[data-v-e92274c2]{position:absolute!important;left:0px!important;opacity:1!important}.viewer-canvas[data-v-e92274c2]{width:100%;height:100%} diff --git a/dist/vue-3d-loader.cjs.js b/dist/vue-3d-loader.cjs.js index dad0306..62f2e8a 100644 --- a/dist/vue-3d-loader.cjs.js +++ b/dist/vue-3d-loader.cjs.js @@ -3156,4 +3156,4 @@ version 0.6.9 `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(` `);let i=[];for(let o=0,l=n.length;o=7?(Xa.setRGB(parseFloat(u[4]),parseFloat(u[5]),parseFloat(u[6])).convertSRGBToLinear(),t.colors.push(Xa.r,Xa.g,Xa.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));break;case"vt":t.uvs.push(parseFloat(u[1]),parseFloat(u[2]));break}}else if(h==="f"){const f=c.slice(1).trim().split(ad),d=[];for(let m=0,g=f.length;m0){const x=y.split("/");d.push(x)}}const p=d[0];for(let m=1,g=d.length-1;m1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const u=t.object.currentMaterial();u&&(u.smooth=t.object.smooth)}else{if(c==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+c+'"')}}t.finalize();const s=new pn;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,l=t.objects.length;o0&&m.setAttribute("normal",new Ce(h.normals,3)),h.colors.length>0&&(p=!0,m.setAttribute("color",new Ce(h.colors,3))),h.hasUVIndices===!0&&m.setAttribute("uv",new Ce(h.uvs,2));const g=[];for(let x=0,b=u.length;x1){for(let x=0,b=u.length;x0){const o=new qi({size:1,sizeAttenuation:!1}),l=new Xe;l.setAttribute("position",new Ce(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(l.setAttribute("color",new Ce(t.colors,3)),o.vertexColors=!0);const c=new _r(l,o);s.add(c)}return s}}class r1 extends Zp{constructor(e){super(e)}parse(e,t){const n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},i=542327876,s=131072,r=512,o=1024,l=2048,c=4096,h=8192,u=16384,f=32768;function d(re){return re.charCodeAt(0)+(re.charCodeAt(1)<<8)+(re.charCodeAt(2)<<16)+(re.charCodeAt(3)<<24)}function p(re){return String.fromCharCode(re&255,re>>8&255,re>>16&255,re>>24&255)}function m(re,H,ge,be){const Fe=ge*be*4,xe=new Uint8Array(re,H,Fe),Ve=new Uint8Array(Fe);let ue=0,ce=0;for(let ve=0;ve>1,1),ge=Math.max(ge>>1,1)}}return n}}class o1{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&i.onStart!==void 0&&i.onStart(h,r,o),s=!0},this.itemEnd=function(h){r++,i.onProgress!==void 0&&i.onProgress(h,r,o),r===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u=p.elements[v].count&&(v++,M=0);const _=i(p.elements[v].properties,C);o(m,p.elements[v].name,_),M++}return r(m)}function r(d){let p=new Xe;return d.indices.length>0&&p.setIndex(d.indices),p.setAttribute("position",new Ce(d.vertices,3)),d.normals.length>0&&p.setAttribute("normal",new Ce(d.normals,3)),d.uvs.length>0&&p.setAttribute("uv",new Ce(d.uvs,2)),d.colors.length>0&&p.setAttribute("color",new Ce(d.colors,3)),d.faceVertexUvs.length>0&&(p=p.toNonIndexed(),p.setAttribute("uv",new Ce(d.faceVertexUvs,2))),p.computeBoundingSphere(),p}function o(d,p,m){function g(q){for(let K=0,G=q.length;K>5&31)/31,p=(X>>10&31)/31):(f=y,d=x,p=b)}for(let X=1;X<=3;X++){const O=U+X*12,j=F*3*3+(X-1)*3;_[j]=h.getFloat32(O,!0),_[j+1]=h.getFloat32(O+4,!0),_[j+2]=h.getFloat32(O+8,!0),E[j]=q,E[j+1]=K,E[j+2]=G,m&&(g[j]=f,g[j+1]=d,g[j+2]=p)}}return C.setAttribute("position",new mt(_,3)),C.setAttribute("normal",new mt(E,3)),m&&(C.setAttribute("color",new mt(g,3)),C.hasColors=!0,C.alpha=v),C}function s(c){const h=new Xe,u=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+p+p+p,"g"),g=new RegExp("normal"+p+p+p,"g"),y=[],x=[],b=new I;let v,M=0,T=0,C=0;for(;(v=u.exec(c))!==null;){T=C;const _=v[0];for(;(v=f.exec(_))!==null;){let U=0,q=0;const K=v[0];for(;(v=g.exec(K))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),q++;for(;(v=m.exec(K))!==null;)y.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),x.push(b.x,b.y,b.z),U++,C++;q!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),U!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const E=T,F=C-T;h.addGroup(E,F,M),M++}return h.setAttribute("position",new Ce(y,3)),h.setAttribute("normal",new Ce(x,3)),h}function r(c){return typeof c!="string"?sn.decodeText(new Uint8Array(c)):c}function o(c){if(typeof c=="string"){const h=new Uint8Array(c.length);for(let u=0;u=0?c.substring(0,h):c;u=u.toLowerCase();let f=h>=0?c.substring(h+1):"";if(f=f.trim(),u==="newmtl")i={name:f},r[f]=i;else if(u==="ka"||u==="kd"||u==="ks"||u==="ke"){const d=f.split(s,3);i[u]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[u]=f}const o=new u1(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class u1{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=this.options.side!==void 0?this.options.side:bi,this.wrap=this.options.wrap!==void 0?this.options.wrap:fn}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],s={};t[n]=s;for(const r in i){let o=!0,l=i[r];const c=r.toLowerCase();switch(c){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(l=[l[0]/255,l[1]/255,l[2]/255]),this.options&&this.options.ignoreZeroRGBs&&l[0]===0&&l[1]===0&&l[2]===0&&(o=!1);break}o&&(s[c]=l)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function s(o,l){return typeof l!="string"||l===""?"":/^https?:\/\//i.test(l)?l:o+l}function r(o,l){if(i[o])return;const c=t.getTextureParams(l,i),h=t.loadTexture(s(t.baseUrl,c.url));h.repeat.copy(c.scale),h.offset.copy(c.offset),h.wrapS=t.wrap,h.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(h.encoding=it),i[o]=h}for(const o in n){const l=n[o];let c;if(l!=="")switch(o.toLowerCase()){case"kd":i.color=new we().fromArray(l).convertSRGBToLinear();break;case"ks":i.specular=new we().fromArray(l).convertSRGBToLinear();break;case"ke":i.emissive=new we().fromArray(l).convertSRGBToLinear();break;case"map_kd":r("map",l);break;case"map_ks":r("specularMap",l);break;case"map_ke":r("emissiveMap",l);break;case"norm":r("normalMap",l);break;case"map_bump":case"bump":r("bumpMap",l);break;case"map_d":r("alphaMap",l),i.transparent=!0;break;case"ns":i.shininess=parseFloat(l);break;case"d":c=parseFloat(l),c<1&&(i.opacity=c,i.transparent=!0);break;case"tr":c=parseFloat(l),this.options&&this.options.invertTrProperty&&(c=1-c),c>0&&(i.opacity=1-c,i.transparent=!0);break}}return this.materials[e]=new ti(i),this.materials[e]}getTextureParams(e,t){const n={scale:new fe(1,1),offset:new fe(0,0)},i=e.split(/\s+/);let s;return s=i.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(i[s+1]),i.splice(s,2)),s=i.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),s=i.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),n.url=i.join(" ").trim(),n}loadTexture(e,t,n,i,s){const r=this.manager!==void 0?this.manager:Yu;let o=r.getHandler(e);o===null&&(o=new zs(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const l=o.load(e,n,i,s);return t!==void 0&&(l.mapping=t),l}}const Ec=new WeakMap;class h1 extends Xt{constructor(e){super(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"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new $t(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{const o={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(r,o).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const l in t.attributeTypes){const c=t.attributeTypes[l];c.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=c.name)}const n=JSON.stringify(t);if(Ec.has(e)){const l=Ec.get(e);if(l.key===n)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 i;const s=this.workerNextTaskID++,r=e.byteLength,o=this._getWorker(s,r).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[s]={resolve:c,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Ec.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Xe;e.index&&t.setIndex(new mt(e.index.array,1));for(let n=0;n{n.load(e,i,void 0,s)})}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(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=f1.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` -`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 u=h.draco,f=new u.Decoder,d=new u.DecoderBuffer;d.Init(new Int8Array(l),l.byteLength);try{const p=t(u,f,d,c),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{u.destroy(d),u.destroy(f)}});break}};function t(r,o,l,c){const h=c.attributeIDs,u=c.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(l);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(l,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(l,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in h){const y=self[u[g]];let x,b;if(c.useUniqueIDs)b=h[g],x=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[h[g]]),b===-1)continue;x=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,y,x))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,l){const h=l.num_faces()*3,u=h*4,f=r._malloc(u);o.GetTrianglesUInt32Array(l,u,f);const d=new Uint32Array(r.HEAPF32.buffer,f,h).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,l,c,h,u){const f=u.num_components(),p=l.num_points()*f,m=p*h.BYTES_PER_ELEMENT,g=s(r,h),y=r._malloc(m);o.GetAttributeDataArrayForAllPoints(l,u,g,m,y);const x=new h(r.HEAPF32.buffer,y,p).slice();return r._free(y),{name:c,array:x,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const dl=new Li,$n=new o1;$n.addHandler(/\.dds$/i,new r1);$n.addHandler(/\.tga$/i,new xu);function d1(a){return dl.setFromObject(a),dl.getSize(new I)}function p1(a){return dl.setFromObject(a),dl.getCenter(new I)}function m1(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function g1(a,e,t,n,i){let s;e?s=e:s=m1(a),s==="glb"&&(s="gltf");let r={loader:null,getObject:null};switch(s){case"dae":r={loader:new wM($n),getObject:o=>o.scene};break;case"fbx":r={loader:new uM($n)};break;case"gltf":r={loader:new MM($n),getObject:o=>{const l=o.scene;return o.animations&&(l.animations=o.animations),l}},x1(t,r,i);break;case"obj":r={loader:new s1($n)};break;case"ply":r={loader:new a1($n),getObject:o=>(o.computeVertexNormals(),new Rt(o,n==="MeshStandardMaterial"?new Vs:new ln({vertexColors:!0})))};break;case"stl":r={loader:new l1($n),getObject:o=>new Rt(o,new ti)};break;case"json":r={loader:new tm($n)};break}return r}function y1(){return new c1($n)}function x1(a,e,t){if(a){const n=new h1;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var v1=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const _1=Et.defineComponent({name:"vue3dLoader"}),b1=Et.defineComponent({..._1,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null,verticalCtrl:{type:[Boolean,Object],default:!1},horizontalCtrl:{type:[Boolean,Object],default:!1},plyMaterial:{default:"MeshStandardMaterial"},enableAxesHelper:{type:Boolean,default:!1},axesHelperSize:{default:100},enableGridHelper:{type:Boolean,default:!1},minDistance:{default:0},maxDistance:{default:1/0},pointLightFollowCamera:{type:Boolean}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{expose:e,emit:t}){const n=a;let i=null;const s=new rm,r=new fe,o=new Ot(45,1,.1,1e5),l=new $u;let c=new El,h=null,u={},f=[],d=null,p=0,m=null,g=null,y=null,x=null,b=null;const v=Et.ref({width:n.width||0,height:n.height||0}),M=Et.ref(0),T=Et.ref(!1),C=Et.ref(!1),_=Et.ref(null),E=Et.ref(null);Et.onMounted(()=>{q()}),Et.onBeforeUnmount(()=>{U()}),Et.watch([()=>n.autoPlay],()=>{Se()}),Et.watch([()=>n.width,()=>n.height],()=>{v.value={width:n.width||0,height:n.height||0}}),Et.watch([()=>n.enableAxesHelper,()=>n.axesHelperSize,()=>n.enableGridHelper],()=>{me()}),Et.watch([()=>n.minDistance,()=>n.maxDistance],()=>{D()}),Et.watch([()=>n.filePath,()=>n.fileType,()=>n.mtlPath,()=>n.clearScene,()=>n.backgroundAlpha,()=>n.backgroundColor],V=>{(V[0]||V[1])&&F(),V[2]&&be(),V[3]&&Ue(),(V[4]||V[5])&&ae()},{deep:!0}),Et.watch([()=>n.rotation,()=>n.position,()=>n.scale,()=>n.lights],V=>{const B=["rotation","position","scale"];V.forEach((ne,de)=>{de<3&&ne?gt(B[de],ne):H()})},{deep:!0}),Et.watch([()=>v],()=>{re(!0),ae()},{deep:!0}),Et.watch([()=>n.controlsOptions],()=>{ge()},{deep:!0}),Et.watch([()=>n.cameraRotation,()=>n.cameraPosition],()=>{re()},{deep:!0}),Et.watch([()=>n.labels],()=>{k()},{deep:!0});function F(){U(),q()}function U(){p&&cancelAnimationFrame(p),h&&h.dispose(),u&&Object.keys(u).length>0&&(u.dispose(),u={});const V=_.value;V.removeEventListener("mousedown",O,!1),V.removeEventListener("mousemove",j,!1),V.removeEventListener("mouseup",Y,!1),V.removeEventListener("click",W,!1),V.removeEventListener("dblclick",Z,!1),window.removeEventListener("resize",X,!1),i=null,c&&c.clear()}function q(){const{filePath:V,outputEncoding:B,webGLRendererOptions:ne,showFps:de,enableDamping:Ee,dampingFactor:z,labels:ye}=n;V&&typeof V=="object"&&(C.value=!0);const J=_.value;K(J),X();const Ae=Object.assign({},{antialias:!0,alpha:!0},ne,{canvas:E.value});if(!h){h=new Nu(Ae),h.shadowMap.enabled=!0;const $e=B==="linear"?Mi:it;h.outputEncoding=$e}(!u||Object.keys(u).length<=0)&&(u=new kw(o,J),Ee&&(u.enableDamping=!0,z!=null&&(u.dampingFactor=z))),D(),me(),be(),Q(),G(!0),J.addEventListener("mousedown",O,!1),J.addEventListener("mouseup",Y,!1),J.addEventListener("click",W,!1),J.addEventListener("dblclick",Z,!1),window.addEventListener("resize",X,!1),de&&(m=_o(),J.appendChild(m.dom)),ve(),ye&&ye.length>0&&k()}function K(V){const{width:B,height:ne}=n;B&&(V.style.width=`${B}px`),ne&&(V.style.height=`${ne}px`)}function G(V){const B=_.value;V?B.addEventListener("mousemove",j,!1):B.removeEventListener("mousemove",j,!1)}function X(){const{width:V,height:B}=n;(!V||!B)&&Et.nextTick(()=>{const ne=_.value;v.value={width:V||ne.offsetWidth,height:B||ne.offsetHeight}})}function O(V){G(!1);const B=ee(V.clientX,V.clientY);t("mousedown",V,B)}function j(V){const B=ee(V.clientX,V.clientY);t("mousemove",V,B)}function Y(V){const B=ee(V.clientX,V.clientY);t("mouseup",V,B),G(!0)}function W(V){const B=ee(V.clientX,V.clientY);t("click",V,B)}function Z(V){const B=ee(V.clientX,V.clientY);t("dblclick",V,B)}function ee(V,B){const ne=ot();if(!ne||!_.value)return null;const de=_.value.getBoundingClientRect();V-=de.left,B-=de.top,r.x=V/v.value.width*2-1,r.y=-(B/v.value.height)*2+1,s.setFromCamera(r,o);const Ee=s.intersectObject(ne,n.intersectRecursive);return(Ee&&Ee.length)>0?Ee[0]:null}function Q(){ae(),re(),H(),ge()}function ie(){if(!i)return;const V=C.value?_e(i):null,{position:B,rotation:ne,scale:de}=n;B&&(B instanceof Array?V!=null?i.position.set(B[V].x,B[V].y,B[V].z):i.position.set(0,0,0):i.position.set(B.x,B.y,B.z)),ne&&(ne instanceof Array?V!=null?i.rotation.set(ne[V].x,ne[V].y,ne[V].z):i.rotation.set(0,0,0):i.rotation.set(ne.x,ne.y,ne.z)),de&&(de instanceof Array?V!=null?i.scale.set(de[V].x,de[V].y,de[V].z):i.scale.set(1,1,1):i.scale.set(de.x,de.y,de.z))}function ae(){const{backgroundColor:V,backgroundAlpha:B}=n;h.setSize(v.value.width,v.value.height),h.setPixelRatio(window.devicePixelRatio||1),h.setClearColor(new we(V).getHex()),h.setClearAlpha(B)}function re(V){const{cameraPosition:B,cameraRotation:ne,cameraUp:de,cameraLookAt:Ee}=n;if(o.aspect=v.value.width/v.value.height,o.updateProjectionMatrix(),!V)if(!Ee||!de){if(!i)return;const z=d1(i).length();o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),B.x===0&&B.y===0&&B.z===0&&(o.position.z=z),o.lookAt(new I)}else o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),o.up.set(de.x,de.y,de.z),o.lookAt(new I(Ee.x,Ee.y,Ee.z))}function H(){const{lights:V}=n;c.remove(...f),f=[],V.forEach(B=>{if(!B.type)return;const ne=B.type.toLowerCase();let de=null;if(ne==="ambient"||ne==="ambientlight"){const Ee=B.color===0?B.color:B.color||4210752,z=B.intensity===0?B.intensity:B.intensity||1;de=new Xo(Ee,z)}if(ne==="point"||ne==="pointLight"){const Ee=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1,ye=B.distance||0,J=B.decay===0?B.decay:B.decay||1;de=new es(Ee,z,ye,J),B.position&&de.position.copy(B.position)}if(ne==="directional"||ne==="directionallight"){const Ee=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1;de=new Wr(Ee,z),B.position&&de.position.copy(B.position),B.target&&de.target.copy(B.target)}if(ne==="hemisphere"||ne==="hemispherelight"){const Ee=B.skyColor===0?B.skyColor:B.skyColor||16777215,z=B.groundColor===0?B.groundColor:B.groundColor||16777215,ye=B.intensity===0?B.intensity:B.intensity||1;de=new Zu(Ee,z,ye),B.position&&de.position.copy(B.position)}de&&(f.push(de),c.add(de))})}function ge(){const{controlsOptions:V}=n;V&&Object.assign(u,V)}function be(){const{filePath:V,parallelLoad:B}=n;B&&C?V.forEach((ne,de)=>{Fe(de)}):Fe()}function Fe(V){const{filePath:B,fileType:ne,crossOrigin:de,requestHeader:Ee,mtlPath:z,enableDraco:ye,dracoDir:J,plyMaterial:Pe}=n;if(!B)return;const Ae=V||M.value,$e=C.value?B[Ae]:B,Tt=typeof ne=="string"?ne:ne?ne[Ae]:"",at=g1($e,Tt,ye,Pe,J);d=at.loader;const wt=at.getObject?at.getObject:ue;if(i&&Ae===0&&c.remove(i),Ee&&d.setRequestHeader(Ee),de&&d.setCrossOrigin(de),z)if(!(typeof z=="object"))Ve($e,wt,Ae);else{if(!z[Ae]){xe($e,wt,Ae);return}Ve($e,wt,Ae)}else xe($e,wt,Ae)}function xe(V,B,ne){const{textureImage:de,parallelLoad:Ee}=n;d.load(V,(...z)=>{if(i=B(...z),ce(i,V),de){const J=typeof de=="string"?de:de[ne];J&&He(i,J)}t("load",c)},z=>{Ee||Ze(z);const ye=M.value+1;t("process",z,ye)},z=>{t("error",z)})}function Ve(V,B,ne){const{crossOrigin:de,requestHeader:Ee,mtlPath:z}=n,ye=y1();de&&ye.setCrossOrigin(de),Ee&&ye.setRequestHeader(Ee);const J=typeof z=="string"?z:z[ne],Pe=/^(.*\/)([^/]*)$/.exec(J),Ae=Pe[1],$e=Pe[2];ye.setPath(Ae).load($e,Tt=>{Tt.preload(),d.setMaterials(Tt),xe(V,B,ne)})}function ue(V){return V}function ce(V,B){const ne=p1(i);T.value||(c.position.copy(ne.negate()),T.value=!0),i=V;let de=B.split("/");de=de[de.length-1],i.fileName=de,c.add(i),re(),ie(),Se()}function ve(){p=requestAnimationFrame(ve),Le();const V=l.getDelta();g&&g instanceof Qa&&g.update(V),g&&g instanceof Array&&g.forEach(B=>{B.update(V)}),u&&u.update(),ke()}function ke(){const{pointLightFollowCamera:V}=n;V&&Te(),h.render(c,o)}function Le(){const{showFps:V}=n;V&&m.update()}function Ze(V){const{filePath:B}=n;Math.floor(V.loaded/V.total*100)===100&&(C.value&&B.length>M.value?Et.nextTick(()=>{if(M.value++,M.value===B.length){M.value=0;return}Fe()}):M.value=0)}function He(V,B){y||(y=new zs),V.traverse(ne=>{ne.isMesh&&y.load(B,de=>{ne.material.map=de,ne.material.needsUpdate=!0},()=>{},de=>{t("error",de)})})}function Ue(){c.clear()}function gt(V,B){const ne=ot();if(!!ne){if(C.value){ne.children.forEach(de=>{const Ee=_e(de),z=V==="scale"?1:0;B[Ee]?de[V].set(B[Ee].x,B[Ee].y,B[Ee].z):de[V].set(z,z,z)});return}ne[V].set(B.x,B.y,B.z)}}function ot(){return C.value?c:i}function k(){const{labels:V}=n;if(!V||V.length<=0)return;P();const B=C.value?c:i,ne=Ee=>(y||(y=new zs),y.load(Ee)),de=(Ee,z)=>{const ye=oe(Ee,z),J=new It(ye);return J.needsUpdate=!0,J};V.forEach(Ee=>{const z=Ee.image?ne(Ee.image):de(Ee.text,Ee.textStyle||{}),ye=new Cl({map:z,color:Ee.spriteMaterialColor||16777215}),J=new yo(ye);Ee.scale?J.scale.set(Ee.scale.x||1,Ee.scale.y||1,Ee.scale.z||0):J.scale.set(1,1,0),Ee.position&&J.position.set(Ee.position.x,Ee.position.y,Ee.position.z),Ee.sid&&(J.sid=Ee.sid),B.add(J)})}function P(){const V=c.children;for(let B=V.length-1;B>=0;B--){const ne=V[B];ne&&(ne instanceof pn&&ne.children&&(c.children[B].children=ne.children.map(de=>de instanceof yo?null:de).filter(de=>de)),ne instanceof yo&&c.remove(ne))}}function oe(V,B){const ne=(wt,et,At,_t,Vn,cn)=>{wt.beginPath(),wt.moveTo(et+cn,At),wt.lineTo(et+_t-cn,At),wt.quadraticCurveTo(et+_t,At,et+_t,At+cn),wt.lineTo(et+_t,At+Vn-cn),wt.quadraticCurveTo(et+_t,At+Vn,et+_t-cn,At+Vn),wt.lineTo(et+cn,At+Vn),wt.quadraticCurveTo(et,At+Vn,et,At+Vn-cn),wt.lineTo(et,At+cn),wt.quadraticCurveTo(et,At,et+cn,At),wt.closePath(),wt.fill(),wt.stroke()},de=B.fontFamily||"Arial",Ee=B.fontSize===0||B.fontSize?B.fontSize:18,z=B.color||"#ffffff",ye=B.fontWeight||"normal",J=B.borderWidth===0||B.borderWidth?B.borderWidth:4,Pe=B.borderColor||"rgba(0,0,0,1)",Ae=B.borderRadius===0||B.borderRadius?B.borderRadius:4,$e=B.backgroundColor||"rgba(255, 255, 255, 1)",Tt=document.createElement("canvas"),at=Tt.getContext("2d");if(at){at.font=`${ye} ${Ee}px ${de}`;const et=at.measureText(V).width;at.fillStyle=$e,at.strokeStyle=Pe,at.lineWidth=J,ne(at,J/2,J/2,et+J,Ee*1.4+J,Ae),at.fillStyle=z,at.fillText(V,J,Ee+J)}return Tt}function _e(V){const{filePath:B}=n;let ne;return B instanceof Array&&(ne=B.map((de,Ee)=>{if(de.indexOf(V.fileName)>-1)return Ee}).filter(de=>de!=null)[0]),ne}function Se(){const V=ot();if(!!V){if(C.value){je(V);return}Ie(V)}}function Ie(V){const{autoPlay:B}=n;g=new Qa(V),V.animations&&V.animations.length>0&&V.animations.forEach(ne=>{if(ne){const de=g.clipAction(ne);B?de.play():de.stop()}})}function je(V){const{autoPlay:B}=n;g=[],V.children.forEach((ne,de)=>{g.push(new Qa(ne)),ne.animations&&ne.animations.length>0&&ne.animations.forEach(Ee=>{if(Ee){const z=g[de].clipAction(Ee);B?z.play():z.stop()}})})}function D(){if(!u)return;const{verticalCtrl:V,horizontalCtrl:B,minDistance:ne,maxDistance:de}=n;V&&typeof V=="boolean"&&(u.minAzimuthAngle=-2*Math.PI,u.maxAzimuthAngle=-2*Math.PI),V&&typeof V=="object"&&(u.minAzimuthAngle=V.min,u.maxAzimuthAngle=V.max),B&&typeof B=="boolean"&&(u.minPolarAngle=1,u.maxPolarAngle=1),B&&typeof B=="object"&&(u.minPolarAngle=B.min,u.maxPolarAngle=B.max),ne!=0&&typeof ne=="number"&&(u.minDistance=ne),de!=1/0&&typeof de=="number"&&(u.maxDistance=de)}function me(){const{enableAxesHelper:V,enableGridHelper:B,axesHelperSize:ne}=n;V?(x=new lm(ne),c.add(x)):x&&c.remove(x),B?(b=new am(2e3,100),c.add(b)):b&&c.remove(b)}function Te(){const V=o.position.clone();c.children.forEach(B=>{B instanceof es&&B.position.set(V.x,V.y,V.z)})}return e({camera:o,scene:c}),(V,B)=>(Et.openBlock(),Et.createElementBlock("div",{ref_key:"containerElement",ref:_,class:"viewer-container"},[Et.createElementVNode("canvas",{ref_key:"canvasElement",ref:E,class:"viewer-canvas"},null,512)],512))}});var pl=v1(b1,[["__scopeId","data-v-550d01bf"]]);const w1=a=>{a.component(pl.name,pl)};var M1={install:w1,vue3dLoader:pl};exports.Three=Nw;exports.default=M1;exports.vue3dLoader=pl; +`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 u=h.draco,f=new u.Decoder,d=new u.DecoderBuffer;d.Init(new Int8Array(l),l.byteLength);try{const p=t(u,f,d,c),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{u.destroy(d),u.destroy(f)}});break}};function t(r,o,l,c){const h=c.attributeIDs,u=c.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(l);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(l,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(l,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in h){const y=self[u[g]];let x,b;if(c.useUniqueIDs)b=h[g],x=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[h[g]]),b===-1)continue;x=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,y,x))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,l){const h=l.num_faces()*3,u=h*4,f=r._malloc(u);o.GetTrianglesUInt32Array(l,u,f);const d=new Uint32Array(r.HEAPF32.buffer,f,h).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,l,c,h,u){const f=u.num_components(),p=l.num_points()*f,m=p*h.BYTES_PER_ELEMENT,g=s(r,h),y=r._malloc(m);o.GetAttributeDataArrayForAllPoints(l,u,g,m,y);const x=new h(r.HEAPF32.buffer,y,p).slice();return r._free(y),{name:c,array:x,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const dl=new Li,$n=new o1;$n.addHandler(/\.dds$/i,new r1);$n.addHandler(/\.tga$/i,new xu);function d1(a){return dl.setFromObject(a),dl.getSize(new I)}function p1(a){return dl.setFromObject(a),dl.getCenter(new I)}function m1(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function g1(a,e,t,n,i){let s;e?s=e:s=m1(a),s==="glb"&&(s="gltf");let r={loader:null,getObject:null};switch(s){case"dae":r={loader:new wM($n),getObject:o=>o.scene};break;case"fbx":r={loader:new uM($n)};break;case"gltf":r={loader:new MM($n),getObject:o=>{const l=o.scene;return o.animations&&(l.animations=o.animations),l}},x1(t,r,i);break;case"obj":r={loader:new s1($n)};break;case"ply":r={loader:new a1($n),getObject:o=>(o.computeVertexNormals(),new Rt(o,n==="MeshStandardMaterial"?new Vs:new ln({vertexColors:!0})))};break;case"stl":r={loader:new l1($n),getObject:o=>new Rt(o,new ti)};break;case"json":r={loader:new tm($n)};break}return r}function y1(){return new c1($n)}function x1(a,e,t){if(a){const n=new h1;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var v1=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const _1=Et.defineComponent({name:"vue3dLoader"}),b1=Et.defineComponent({..._1,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null,verticalCtrl:{type:[Boolean,Object],default:!1},horizontalCtrl:{type:[Boolean,Object],default:!1},plyMaterial:{default:"MeshStandardMaterial"},enableAxesHelper:{type:Boolean,default:!1},axesHelperSize:{default:100},enableGridHelper:{type:Boolean,default:!1},minDistance:{default:0},maxDistance:{default:1/0},pointLightFollowCamera:{type:Boolean}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{expose:e,emit:t}){const n=a;let i=null;const s=new rm,r=new fe,o=new Ot(45,1,.1,1e5),l=new $u;let c=new El,h=null,u={},f=[],d=null,p=0,m=null,g=null,y=null,x=null,b=null;const v=Et.ref({width:n.width||0,height:n.height||0}),M=Et.ref(0),T=Et.ref(!1),C=Et.ref(!1),_=Et.ref(null),E=Et.ref(null);Et.onMounted(()=>{q()}),Et.onBeforeUnmount(()=>{U()}),Et.watch([()=>n.autoPlay],()=>{Se()}),Et.watch([()=>n.width,()=>n.height],()=>{v.value={width:n.width||0,height:n.height||0}}),Et.watch([()=>n.enableAxesHelper,()=>n.axesHelperSize,()=>n.enableGridHelper],()=>{me()}),Et.watch([()=>n.minDistance,()=>n.maxDistance],()=>{D()}),Et.watch([()=>n.filePath,()=>n.fileType,()=>n.mtlPath,()=>n.clearScene,()=>n.backgroundAlpha,()=>n.backgroundColor],V=>{(V[0]||V[1])&&F(),V[2]&&be(),V[3]&&Ue(),(V[4]||V[5])&&ae()},{deep:!0}),Et.watch([()=>n.rotation,()=>n.position,()=>n.scale,()=>n.lights],V=>{const B=["rotation","position","scale"];V.forEach((ne,de)=>{de<3&&ne?gt(B[de],ne):H()})},{deep:!0}),Et.watch([()=>v],()=>{re(!0),ae()},{deep:!0}),Et.watch([()=>n.controlsOptions],()=>{ge()},{deep:!0}),Et.watch([()=>n.cameraRotation,()=>n.cameraPosition],()=>{re()},{deep:!0}),Et.watch([()=>n.labels],()=>{k()},{deep:!0});function F(){U(),q()}function U(){p&&cancelAnimationFrame(p),h&&h.dispose(),u&&Object.keys(u).length>0&&(u.dispose(),u={});const V=_.value;V.removeEventListener("mousedown",O,!1),V.removeEventListener("mousemove",j,!1),V.removeEventListener("mouseup",Y,!1),V.removeEventListener("click",W,!1),V.removeEventListener("dblclick",Z,!1),window.removeEventListener("resize",X,!1),i=null,c&&c.clear()}function q(){const{filePath:V,outputEncoding:B,webGLRendererOptions:ne,showFps:de,enableDamping:Ee,dampingFactor:z,labels:ye}=n;V&&typeof V=="object"&&(C.value=!0);const J=_.value;K(J),X();const Ae=Object.assign({},{antialias:!0,alpha:!0},ne,{canvas:E.value});if(!h){h=new Nu(Ae),h.shadowMap.enabled=!0;const $e=B==="linear"?Mi:it;h.outputEncoding=$e}(!u||Object.keys(u).length<=0)&&(u=new kw(o,J),Ee&&(u.enableDamping=!0,z!=null&&(u.dampingFactor=z))),D(),me(),be(),Q(),G(!0),J.addEventListener("mousedown",O,!1),J.addEventListener("mouseup",Y,!1),J.addEventListener("click",W,!1),J.addEventListener("dblclick",Z,!1),window.addEventListener("resize",X,!1),de&&(m=_o(),J.appendChild(m.dom)),ve(),ye&&ye.length>0&&k()}function K(V){const{width:B,height:ne}=n;B&&(V.style.width=`${B}px`),ne&&(V.style.height=`${ne}px`)}function G(V){const B=_.value;V?B.addEventListener("mousemove",j,!1):B.removeEventListener("mousemove",j,!1)}function X(){const{width:V,height:B}=n;(!V||!B)&&Et.nextTick(()=>{const ne=_.value;v.value={width:V||ne.offsetWidth,height:B||ne.offsetHeight}})}function O(V){G(!1);const B=ee(V.clientX,V.clientY);t("mousedown",V,B)}function j(V){const B=ee(V.clientX,V.clientY);t("mousemove",V,B)}function Y(V){const B=ee(V.clientX,V.clientY);t("mouseup",V,B),G(!0)}function W(V){const B=ee(V.clientX,V.clientY);t("click",V,B)}function Z(V){const B=ee(V.clientX,V.clientY);t("dblclick",V,B)}function ee(V,B){const ne=ot();if(!ne||!_.value)return null;const de=_.value.getBoundingClientRect();V-=de.left,B-=de.top,r.x=V/v.value.width*2-1,r.y=-(B/v.value.height)*2+1,s.setFromCamera(r,o);const Ee=s.intersectObject(ne,n.intersectRecursive);return(Ee&&Ee.length)>0?Ee[0]:null}function Q(){ae(),re(),H(),ge()}function ie(){if(!i)return;const V=C.value?_e(i):null,{position:B,rotation:ne,scale:de}=n;B&&(B instanceof Array?V!=null?i.position.set(B[V].x,B[V].y,B[V].z):i.position.set(0,0,0):i.position.set(B.x,B.y,B.z)),ne&&(ne instanceof Array?V!=null?i.rotation.set(ne[V].x,ne[V].y,ne[V].z):i.rotation.set(0,0,0):i.rotation.set(ne.x,ne.y,ne.z)),de&&(de instanceof Array?V!=null?i.scale.set(de[V].x,de[V].y,de[V].z):i.scale.set(1,1,1):i.scale.set(de.x,de.y,de.z))}function ae(){const{backgroundColor:V,backgroundAlpha:B}=n;h.setSize(v.value.width,v.value.height),h.setPixelRatio(window.devicePixelRatio||1),h.setClearColor(new we(V).getHex()),h.setClearAlpha(B)}function re(V){const{cameraPosition:B,cameraRotation:ne,cameraUp:de,cameraLookAt:Ee}=n;if(o.aspect=v.value.width/v.value.height,o.updateProjectionMatrix(),!V)if(!Ee||!de){if(!i)return;const z=d1(i).length();o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),B.x===0&&B.y===0&&B.z===0&&(o.position.z=z),o.lookAt(new I)}else o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),o.up.set(de.x,de.y,de.z),o.lookAt(new I(Ee.x,Ee.y,Ee.z))}function H(){const{lights:V}=n;c.remove(...f),f=[],V.forEach(B=>{if(!B.type)return;const ne=B.type.toLowerCase();let de=null;if(ne==="ambient"||ne==="ambientlight"){const Ee=B.color===0?B.color:B.color||4210752,z=B.intensity===0?B.intensity:B.intensity||1;de=new Xo(Ee,z)}if(ne==="point"||ne==="pointlight"){const Ee=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1,ye=B.distance||0,J=B.decay===0?B.decay:B.decay||1;de=new es(Ee,z,ye,J),B.position&&de.position.copy(B.position)}if(ne==="directional"||ne==="directionallight"){const Ee=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1;de=new Wr(Ee,z),B.position&&de.position.copy(B.position),B.target&&de.target.copy(B.target)}if(ne==="hemisphere"||ne==="hemispherelight"){const Ee=B.skyColor===0?B.skyColor:B.skyColor||16777215,z=B.groundColor===0?B.groundColor:B.groundColor||16777215,ye=B.intensity===0?B.intensity:B.intensity||1;de=new Zu(Ee,z,ye),B.position&&de.position.copy(B.position)}de&&(f.push(de),c.add(de))})}function ge(){const{controlsOptions:V}=n;V&&Object.assign(u,V)}function be(){const{filePath:V,parallelLoad:B}=n;B&&C?V.forEach((ne,de)=>{Fe(de)}):Fe()}function Fe(V){const{filePath:B,fileType:ne,crossOrigin:de,requestHeader:Ee,mtlPath:z,enableDraco:ye,dracoDir:J,plyMaterial:Pe}=n;if(!B)return;const Ae=V||M.value,$e=C.value?B[Ae]:B,Tt=typeof ne=="string"?ne:ne?ne[Ae]:"",at=g1($e,Tt,ye,Pe,J);d=at.loader;const wt=at.getObject?at.getObject:ue;if(i&&Ae===0&&c.remove(i),Ee&&d.setRequestHeader(Ee),de&&d.setCrossOrigin(de),z)if(!(typeof z=="object"))Ve($e,wt,Ae);else{if(!z[Ae]){xe($e,wt,Ae);return}Ve($e,wt,Ae)}else xe($e,wt,Ae)}function xe(V,B,ne){const{textureImage:de,parallelLoad:Ee}=n;d.load(V,(...z)=>{if(i=B(...z),ce(i,V),de){const J=typeof de=="string"?de:de[ne];J&&He(i,J)}t("load",c)},z=>{Ee||Ze(z);const ye=M.value+1;t("process",z,ye)},z=>{t("error",z)})}function Ve(V,B,ne){const{crossOrigin:de,requestHeader:Ee,mtlPath:z}=n,ye=y1();de&&ye.setCrossOrigin(de),Ee&&ye.setRequestHeader(Ee);const J=typeof z=="string"?z:z[ne],Pe=/^(.*\/)([^/]*)$/.exec(J),Ae=Pe[1],$e=Pe[2];ye.setPath(Ae).load($e,Tt=>{Tt.preload(),d.setMaterials(Tt),xe(V,B,ne)})}function ue(V){return V}function ce(V,B){const ne=p1(i);T.value||(c.position.copy(ne.negate()),T.value=!0),i=V;let de=B.split("/");de=de[de.length-1],i.fileName=de,c.add(i),re(),ie(),Se()}function ve(){p=requestAnimationFrame(ve),Le();const V=l.getDelta();g&&g instanceof Qa&&g.update(V),g&&g instanceof Array&&g.forEach(B=>{B.update(V)}),u&&u.update(),ke()}function ke(){const{pointLightFollowCamera:V}=n;V&&Te(),h.render(c,o)}function Le(){const{showFps:V}=n;V&&m.update()}function Ze(V){const{filePath:B}=n;Math.floor(V.loaded/V.total*100)===100&&(C.value&&B.length>M.value?Et.nextTick(()=>{if(M.value++,M.value===B.length){M.value=0;return}Fe()}):M.value=0)}function He(V,B){y||(y=new zs),V.traverse(ne=>{ne.isMesh&&y.load(B,de=>{ne.material.map=de,ne.material.needsUpdate=!0},()=>{},de=>{t("error",de)})})}function Ue(){c.clear()}function gt(V,B){const ne=ot();if(!!ne){if(C.value){ne.children.forEach(de=>{const Ee=_e(de),z=V==="scale"?1:0;B[Ee]?de[V].set(B[Ee].x,B[Ee].y,B[Ee].z):de[V].set(z,z,z)});return}ne[V].set(B.x,B.y,B.z)}}function ot(){return C.value?c:i}function k(){const{labels:V}=n;if(!V||V.length<=0)return;P();const B=C.value?c:i,ne=Ee=>(y||(y=new zs),y.load(Ee)),de=(Ee,z)=>{const ye=oe(Ee,z),J=new It(ye);return J.needsUpdate=!0,J};V.forEach(Ee=>{const z=Ee.image?ne(Ee.image):de(Ee.text,Ee.textStyle||{}),ye=new Cl({map:z,color:Ee.spriteMaterialColor||16777215}),J=new yo(ye);Ee.scale?J.scale.set(Ee.scale.x||1,Ee.scale.y||1,Ee.scale.z||0):J.scale.set(1,1,0),Ee.position&&J.position.set(Ee.position.x,Ee.position.y,Ee.position.z),Ee.sid&&(J.sid=Ee.sid),B.add(J)})}function P(){const V=c.children;for(let B=V.length-1;B>=0;B--){const ne=V[B];ne&&(ne instanceof pn&&ne.children&&(c.children[B].children=ne.children.map(de=>de instanceof yo?null:de).filter(de=>de)),ne instanceof yo&&c.remove(ne))}}function oe(V,B){const ne=(wt,et,At,_t,Vn,cn)=>{wt.beginPath(),wt.moveTo(et+cn,At),wt.lineTo(et+_t-cn,At),wt.quadraticCurveTo(et+_t,At,et+_t,At+cn),wt.lineTo(et+_t,At+Vn-cn),wt.quadraticCurveTo(et+_t,At+Vn,et+_t-cn,At+Vn),wt.lineTo(et+cn,At+Vn),wt.quadraticCurveTo(et,At+Vn,et,At+Vn-cn),wt.lineTo(et,At+cn),wt.quadraticCurveTo(et,At,et+cn,At),wt.closePath(),wt.fill(),wt.stroke()},de=B.fontFamily||"Arial",Ee=B.fontSize===0||B.fontSize?B.fontSize:18,z=B.color||"#ffffff",ye=B.fontWeight||"normal",J=B.borderWidth===0||B.borderWidth?B.borderWidth:4,Pe=B.borderColor||"rgba(0,0,0,1)",Ae=B.borderRadius===0||B.borderRadius?B.borderRadius:4,$e=B.backgroundColor||"rgba(255, 255, 255, 1)",Tt=document.createElement("canvas"),at=Tt.getContext("2d");if(at){at.font=`${ye} ${Ee}px ${de}`;const et=at.measureText(V).width;at.fillStyle=$e,at.strokeStyle=Pe,at.lineWidth=J,ne(at,J/2,J/2,et+J,Ee*1.4+J,Ae),at.fillStyle=z,at.fillText(V,J,Ee+J)}return Tt}function _e(V){const{filePath:B}=n;let ne;return B instanceof Array&&(ne=B.map((de,Ee)=>{if(de.indexOf(V.fileName)>-1)return Ee}).filter(de=>de!=null)[0]),ne}function Se(){const V=ot();if(!!V){if(C.value){je(V);return}Ie(V)}}function Ie(V){const{autoPlay:B}=n;g=new Qa(V),V.animations&&V.animations.length>0&&V.animations.forEach(ne=>{if(ne){const de=g.clipAction(ne);B?de.play():de.stop()}})}function je(V){const{autoPlay:B}=n;g=[],V.children.forEach((ne,de)=>{g.push(new Qa(ne)),ne.animations&&ne.animations.length>0&&ne.animations.forEach(Ee=>{if(Ee){const z=g[de].clipAction(Ee);B?z.play():z.stop()}})})}function D(){if(!u)return;const{verticalCtrl:V,horizontalCtrl:B,minDistance:ne,maxDistance:de}=n;V&&typeof V=="boolean"&&(u.minAzimuthAngle=-2*Math.PI,u.maxAzimuthAngle=-2*Math.PI),V&&typeof V=="object"&&(u.minAzimuthAngle=V.min,u.maxAzimuthAngle=V.max),B&&typeof B=="boolean"&&(u.minPolarAngle=1,u.maxPolarAngle=1),B&&typeof B=="object"&&(u.minPolarAngle=B.min,u.maxPolarAngle=B.max),ne!=0&&typeof ne=="number"&&(u.minDistance=ne),de!=1/0&&typeof de=="number"&&(u.maxDistance=de)}function me(){const{enableAxesHelper:V,enableGridHelper:B,axesHelperSize:ne}=n;V?(x=new lm(ne),c.add(x)):x&&c.remove(x),B?(b=new am(2e3,100),c.add(b)):b&&c.remove(b)}function Te(){const V=o.position.clone();c.children.forEach(B=>{B instanceof es&&B.position.set(V.x,V.y,V.z)})}return e({camera:o,scene:c}),(V,B)=>(Et.openBlock(),Et.createElementBlock("div",{ref_key:"containerElement",ref:_,class:"viewer-container"},[Et.createElementVNode("canvas",{ref_key:"canvasElement",ref:E,class:"viewer-canvas"},null,512)],512))}});var pl=v1(b1,[["__scopeId","data-v-e92274c2"]]);const w1=a=>{a.component(pl.name,pl)};var M1={install:w1,vue3dLoader:pl};exports.Three=Nw;exports.default=M1;exports.vue3dLoader=pl; diff --git a/dist/vue-3d-loader.esm.js b/dist/vue-3d-loader.esm.js index ed67e2e..76a5c68 100644 --- a/dist/vue-3d-loader.esm.js +++ b/dist/vue-3d-loader.esm.js @@ -41140,7 +41140,7 @@ const _sfc_main = defineComponent({ const intensity = item.intensity === 0 ? item.intensity : item.intensity || 1; light = new AmbientLight(color, intensity); } - if (type === "point" || type === "pointLight") { + if (type === "point" || type === "pointlight") { const color = item.color === 0 ? item.color : item.color || 16777215; const intensity = item.intensity === 0 ? item.intensity : item.intensity || 1; const distance = item.distance || 0; @@ -41608,7 +41608,7 @@ const _sfc_main = defineComponent({ }; } }); -var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-550d01bf"]]); +var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-e92274c2"]]); const install = (app) => { app.component(vue3dLoader.name, vue3dLoader); }; diff --git a/dist/vue-3d-loader.global.js b/dist/vue-3d-loader.global.js index 1c098eb..f36ac14 100644 --- a/dist/vue-3d-loader.global.js +++ b/dist/vue-3d-loader.global.js @@ -3156,4 +3156,4 @@ version 0.6.9 `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(` `);let i=[];for(let o=0,l=n.length;o=7?(Al.setRGB(parseFloat(u[4]),parseFloat(u[5]),parseFloat(u[6])).convertSRGBToLinear(),t.colors.push(Al.r,Al.g,Al.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));break;case"vt":t.uvs.push(parseFloat(u[1]),parseFloat(u[2]));break}}else if(h==="f"){const f=c.slice(1).trim().split(Vm),d=[];for(let m=0,g=f.length;m0){const x=y.split("/");d.push(x)}}const p=d[0];for(let m=1,g=d.length-1;m1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const u=t.object.currentMaterial();u&&(u.smooth=t.object.smooth)}else{if(c==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+c+'"')}}t.finalize();const s=new dn;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,l=t.objects.length;o0&&m.setAttribute("normal",new Ee(h.normals,3)),h.colors.length>0&&(p=!0,m.setAttribute("color",new Ee(h.colors,3))),h.hasUVIndices===!0&&m.setAttribute("uv",new Ee(h.uvs,2));const g=[];for(let x=0,b=u.length;x1){for(let x=0,b=u.length;x0){const o=new Yi({size:1,sizeAttenuation:!1}),l=new Xe;l.setAttribute("position",new Ee(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(l.setAttribute("color",new Ee(t.colors,3)),o.vertexColors=!0);const c=new wr(l,o);s.add(c)}return s}}class MM extends ip{constructor(e){super(e)}parse(e,t){const n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},i=542327876,s=131072,r=512,o=1024,l=2048,c=4096,h=8192,u=16384,f=32768;function d(re){return re.charCodeAt(0)+(re.charCodeAt(1)<<8)+(re.charCodeAt(2)<<16)+(re.charCodeAt(3)<<24)}function p(re){return String.fromCharCode(re&255,re>>8&255,re>>16&255,re>>24&255)}function m(re,H,ge,we){const Fe=ge*we*4,xe=new Uint8Array(re,H,Fe),Ve=new Uint8Array(Fe);let ue=0,ce=0;for(let ve=0;ve>1,1),ge=Math.max(ge>>1,1)}}return n}}class SM{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&i.onStart!==void 0&&i.onStart(h,r,o),s=!0},this.itemEnd=function(h){r++,i.onProgress!==void 0&&i.onProgress(h,r,o),r===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u=p.elements[v].count&&(v++,M=0);const _=i(p.elements[v].properties,C);o(m,p.elements[v].name,_),M++}return r(m)}function r(d){let p=new Xe;return d.indices.length>0&&p.setIndex(d.indices),p.setAttribute("position",new Ee(d.vertices,3)),d.normals.length>0&&p.setAttribute("normal",new Ee(d.normals,3)),d.uvs.length>0&&p.setAttribute("uv",new Ee(d.uvs,2)),d.colors.length>0&&p.setAttribute("color",new Ee(d.colors,3)),d.faceVertexUvs.length>0&&(p=p.toNonIndexed(),p.setAttribute("uv",new Ee(d.faceVertexUvs,2))),p.computeBoundingSphere(),p}function o(d,p,m){function g(q){for(let K=0,G=q.length;K>5&31)/31,p=(X>>10&31)/31):(f=y,d=x,p=b)}for(let X=1;X<=3;X++){const O=U+X*12,j=F*3*3+(X-1)*3;_[j]=h.getFloat32(O,!0),_[j+1]=h.getFloat32(O+4,!0),_[j+2]=h.getFloat32(O+8,!0),E[j]=q,E[j+1]=K,E[j+2]=G,m&&(g[j]=f,g[j+1]=d,g[j+2]=p)}}return C.setAttribute("position",new pt(_,3)),C.setAttribute("normal",new pt(E,3)),m&&(C.setAttribute("color",new pt(g,3)),C.hasColors=!0,C.alpha=v),C}function s(c){const h=new Xe,u=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+p+p+p,"g"),g=new RegExp("normal"+p+p+p,"g"),y=[],x=[],b=new I;let v,M=0,T=0,C=0;for(;(v=u.exec(c))!==null;){T=C;const _=v[0];for(;(v=f.exec(_))!==null;){let U=0,q=0;const K=v[0];for(;(v=g.exec(K))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),q++;for(;(v=m.exec(K))!==null;)y.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),x.push(b.x,b.y,b.z),U++,C++;q!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),U!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const E=T,F=C-T;h.addGroup(E,F,M),M++}return h.setAttribute("position",new Ee(y,3)),h.setAttribute("normal",new Ee(x,3)),h}function r(c){return typeof c!="string"?sn.decodeText(new Uint8Array(c)):c}function o(c){if(typeof c=="string"){const h=new Uint8Array(c.length);for(let u=0;u=0?c.substring(0,h):c;u=u.toLowerCase();let f=h>=0?c.substring(h+1):"";if(f=f.trim(),u==="newmtl")i={name:f},r[f]=i;else if(u==="ka"||u==="kd"||u==="ks"||u==="ke"){const d=f.split(s,3);i[u]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[u]=f}const o=new CM(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class CM{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=this.options.side!==void 0?this.options.side:li,this.wrap=this.options.wrap!==void 0?this.options.wrap:cn}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],s={};t[n]=s;for(const r in i){let o=!0,l=i[r];const c=r.toLowerCase();switch(c){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(l=[l[0]/255,l[1]/255,l[2]/255]),this.options&&this.options.ignoreZeroRGBs&&l[0]===0&&l[1]===0&&l[2]===0&&(o=!1);break}o&&(s[c]=l)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function s(o,l){return typeof l!="string"||l===""?"":/^https?:\/\//i.test(l)?l:o+l}function r(o,l){if(i[o])return;const c=t.getTextureParams(l,i),h=t.loadTexture(s(t.baseUrl,c.url));h.repeat.copy(c.scale),h.offset.copy(c.offset),h.wrapS=t.wrap,h.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(h.encoding=it),i[o]=h}for(const o in n){const l=n[o];let c;if(l!=="")switch(o.toLowerCase()){case"kd":i.color=new be().fromArray(l).convertSRGBToLinear();break;case"ks":i.specular=new be().fromArray(l).convertSRGBToLinear();break;case"ke":i.emissive=new be().fromArray(l).convertSRGBToLinear();break;case"map_kd":r("map",l);break;case"map_ks":r("specularMap",l);break;case"map_ke":r("emissiveMap",l);break;case"norm":r("normalMap",l);break;case"map_bump":case"bump":r("bumpMap",l);break;case"map_d":r("alphaMap",l),i.transparent=!0;break;case"ns":i.shininess=parseFloat(l);break;case"d":c=parseFloat(l),c<1&&(i.opacity=c,i.transparent=!0);break;case"tr":c=parseFloat(l),this.options&&this.options.invertTrProperty&&(c=1-c),c>0&&(i.opacity=1-c,i.transparent=!0);break}}return this.materials[e]=new ni(i),this.materials[e]}getTextureParams(e,t){const n={scale:new he(1,1),offset:new he(0,0)},i=e.split(/\s+/);let s;return s=i.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(i[s+1]),i.splice(s,2)),s=i.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),s=i.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),n.url=i.join(" ").trim(),n}loadTexture(e,t,n,i,s){const r=this.manager!==void 0?this.manager:bu;let o=r.getHandler(e);o===null&&(o=new Os(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const l=o.load(e,n,i,s);return t!==void 0&&(l.mapping=t),l}}const uh=new WeakMap;class LM extends Ht{constructor(e){super(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"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new Jt(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{const o={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(r,o).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const l in t.attributeTypes){const c=t.attributeTypes[l];c.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=c.name)}const n=JSON.stringify(t);if(uh.has(e)){const l=uh.get(e);if(l.key===n)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 i;const s=this.workerNextTaskID++,r=e.byteLength,o=this._getWorker(s,r).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[s]={resolve:c,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),uh.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Xe;e.index&&t.setIndex(new pt(e.index.array,1));for(let n=0;n{n.load(e,i,void 0,s)})}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(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=RM.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` -`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 u=h.draco,f=new u.Decoder,d=new u.DecoderBuffer;d.Init(new Int8Array(l),l.byteLength);try{const p=t(u,f,d,c),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{u.destroy(d),u.destroy(f)}});break}};function t(r,o,l,c){const h=c.attributeIDs,u=c.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(l);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(l,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(l,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in h){const y=self[u[g]];let x,b;if(c.useUniqueIDs)b=h[g],x=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[h[g]]),b===-1)continue;x=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,y,x))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,l){const h=l.num_faces()*3,u=h*4,f=r._malloc(u);o.GetTrianglesUInt32Array(l,u,f);const d=new Uint32Array(r.HEAPF32.buffer,f,h).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,l,c,h,u){const f=u.num_components(),p=l.num_points()*f,m=p*h.BYTES_PER_ELEMENT,g=s(r,h),y=r._malloc(m);o.GetAttributeDataArrayForAllPoints(l,u,g,m,y);const x=new h(r.HEAPF32.buffer,y,p).slice();return r._free(y),{name:c,array:x,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const Cl=new di,oi=new SM;oi.addHandler(/\.dds$/i,new MM),oi.addHandler(/\.tga$/i,new sh);function IM(a){return Cl.setFromObject(a),Cl.getSize(new I)}function PM(a){return Cl.setFromObject(a),Cl.getCenter(new I)}function DM(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function FM(a,e,t,n,i){let s;e?s=e:s=DM(a),s==="glb"&&(s="gltf");let r={loader:null,getObject:null};switch(s){case"dae":r={loader:new Uw(oi),getObject:o=>o.scene};break;case"fbx":r={loader:new Cw(oi)};break;case"gltf":r={loader:new Gw(oi),getObject:o=>{const l=o.scene;return o.animations&&(l.animations=o.animations),l}},kM(t,r,i);break;case"obj":r={loader:new wM(oi)};break;case"ply":r={loader:new TM(oi),getObject:o=>(o.computeVertexNormals(),new Rt(o,n==="MeshStandardMaterial"?new Is:new on({vertexColors:!0})))};break;case"stl":r={loader:new AM(oi),getObject:o=>new Rt(o,new ni)};break;case"json":r={loader:new dp(oi)};break}return r}function NM(){return new EM(oi)}function kM(a,e,t){if(a){const n=new LM;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var S1="",OM=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const BM=At.defineComponent({name:"vue3dLoader"}),zM=At.defineComponent({...BM,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null,verticalCtrl:{type:[Boolean,Object],default:!1},horizontalCtrl:{type:[Boolean,Object],default:!1},plyMaterial:{default:"MeshStandardMaterial"},enableAxesHelper:{type:Boolean,default:!1},axesHelperSize:{default:100},enableGridHelper:{type:Boolean,default:!1},minDistance:{default:0},maxDistance:{default:1/0},pointLightFollowCamera:{type:Boolean}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{expose:e,emit:t}){const n=a;let i=null;const s=new Sp,r=new he,o=new Ot(45,1,.1,1e5),l=new Au;let c=new Ba,h=null,u={},f=[],d=null,p=0,m=null,g=null,y=null,x=null,b=null;const v=At.ref({width:n.width||0,height:n.height||0}),M=At.ref(0),T=At.ref(!1),C=At.ref(!1),_=At.ref(null),E=At.ref(null);At.onMounted(()=>{q()}),At.onBeforeUnmount(()=>{U()}),At.watch([()=>n.autoPlay],()=>{Se()}),At.watch([()=>n.width,()=>n.height],()=>{v.value={width:n.width||0,height:n.height||0}}),At.watch([()=>n.enableAxesHelper,()=>n.axesHelperSize,()=>n.enableGridHelper],()=>{me()}),At.watch([()=>n.minDistance,()=>n.maxDistance],()=>{D()}),At.watch([()=>n.filePath,()=>n.fileType,()=>n.mtlPath,()=>n.clearScene,()=>n.backgroundAlpha,()=>n.backgroundColor],V=>{(V[0]||V[1])&&F(),V[2]&&we(),V[3]&&Ue(),(V[4]||V[5])&&ae()},{deep:!0}),At.watch([()=>n.rotation,()=>n.position,()=>n.scale,()=>n.lights],V=>{const B=["rotation","position","scale"];V.forEach((ne,de)=>{de<3&&ne?gt(B[de],ne):H()})},{deep:!0}),At.watch([()=>v],()=>{re(!0),ae()},{deep:!0}),At.watch([()=>n.controlsOptions],()=>{ge()},{deep:!0}),At.watch([()=>n.cameraRotation,()=>n.cameraPosition],()=>{re()},{deep:!0}),At.watch([()=>n.labels],()=>{k()},{deep:!0});function F(){U(),q()}function U(){p&&cancelAnimationFrame(p),h&&h.dispose(),u&&Object.keys(u).length>0&&(u.dispose(),u={});const V=_.value;V.removeEventListener("mousedown",O,!1),V.removeEventListener("mousemove",j,!1),V.removeEventListener("mouseup",Y,!1),V.removeEventListener("click",W,!1),V.removeEventListener("dblclick",Z,!1),window.removeEventListener("resize",X,!1),i=null,c&&c.clear()}function q(){const{filePath:V,outputEncoding:B,webGLRendererOptions:ne,showFps:de,enableDamping:Ce,dampingFactor:z,labels:ye}=n;V&&typeof V=="object"&&(C.value=!0);const J=_.value;K(J),X();const Ae=Object.assign({},{antialias:!0,alpha:!0},ne,{canvas:E.value});if(!h){h=new $c(Ae),h.shadowMap.enabled=!0;const $e=B==="linear"?fi:it;h.outputEncoding=$e}(!u||Object.keys(u).length<=0)&&(u=new ew(o,J),Ce&&(u.enableDamping=!0,z!=null&&(u.dampingFactor=z))),D(),me(),we(),Q(),G(!0),J.addEventListener("mousedown",O,!1),J.addEventListener("mouseup",Y,!1),J.addEventListener("click",W,!1),J.addEventListener("dblclick",Z,!1),window.addEventListener("resize",X,!1),de&&(m=Oo(),J.appendChild(m.dom)),ve(),ye&&ye.length>0&&k()}function K(V){const{width:B,height:ne}=n;B&&(V.style.width=`${B}px`),ne&&(V.style.height=`${ne}px`)}function G(V){const B=_.value;V?B.addEventListener("mousemove",j,!1):B.removeEventListener("mousemove",j,!1)}function X(){const{width:V,height:B}=n;(!V||!B)&&At.nextTick(()=>{const ne=_.value;v.value={width:V||ne.offsetWidth,height:B||ne.offsetHeight}})}function O(V){G(!1);const B=ee(V.clientX,V.clientY);t("mousedown",V,B)}function j(V){const B=ee(V.clientX,V.clientY);t("mousemove",V,B)}function Y(V){const B=ee(V.clientX,V.clientY);t("mouseup",V,B),G(!0)}function W(V){const B=ee(V.clientX,V.clientY);t("click",V,B)}function Z(V){const B=ee(V.clientX,V.clientY);t("dblclick",V,B)}function ee(V,B){const ne=lt();if(!ne||!_.value)return null;const de=_.value.getBoundingClientRect();V-=de.left,B-=de.top,r.x=V/v.value.width*2-1,r.y=-(B/v.value.height)*2+1,s.setFromCamera(r,o);const Ce=s.intersectObject(ne,n.intersectRecursive);return(Ce&&Ce.length)>0?Ce[0]:null}function Q(){ae(),re(),H(),ge()}function ie(){if(!i)return;const V=C.value?_e(i):null,{position:B,rotation:ne,scale:de}=n;B&&(B instanceof Array?V!=null?i.position.set(B[V].x,B[V].y,B[V].z):i.position.set(0,0,0):i.position.set(B.x,B.y,B.z)),ne&&(ne instanceof Array?V!=null?i.rotation.set(ne[V].x,ne[V].y,ne[V].z):i.rotation.set(0,0,0):i.rotation.set(ne.x,ne.y,ne.z)),de&&(de instanceof Array?V!=null?i.scale.set(de[V].x,de[V].y,de[V].z):i.scale.set(1,1,1):i.scale.set(de.x,de.y,de.z))}function ae(){const{backgroundColor:V,backgroundAlpha:B}=n;h.setSize(v.value.width,v.value.height),h.setPixelRatio(window.devicePixelRatio||1),h.setClearColor(new be(V).getHex()),h.setClearAlpha(B)}function re(V){const{cameraPosition:B,cameraRotation:ne,cameraUp:de,cameraLookAt:Ce}=n;if(o.aspect=v.value.width/v.value.height,o.updateProjectionMatrix(),!V)if(!Ce||!de){if(!i)return;const z=IM(i).length();o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),B.x===0&&B.y===0&&B.z===0&&(o.position.z=z),o.lookAt(new I)}else o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),o.up.set(de.x,de.y,de.z),o.lookAt(new I(Ce.x,Ce.y,Ce.z))}function H(){const{lights:V}=n;c.remove(...f),f=[],V.forEach(B=>{if(!B.type)return;const ne=B.type.toLowerCase();let de=null;if(ne==="ambient"||ne==="ambientlight"){const Ce=B.color===0?B.color:B.color||4210752,z=B.intensity===0?B.intensity:B.intensity||1;de=new ko(Ce,z)}if(ne==="point"||ne==="pointLight"){const Ce=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1,ye=B.distance||0,J=B.decay===0?B.decay:B.decay||1;de=new $i(Ce,z,ye,J),B.position&&de.position.copy(B.position)}if(ne==="directional"||ne==="directionallight"){const Ce=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1;de=new Or(Ce,z),B.position&&de.position.copy(B.position),B.target&&de.target.copy(B.target)}if(ne==="hemisphere"||ne==="hemispherelight"){const Ce=B.skyColor===0?B.skyColor:B.skyColor||16777215,z=B.groundColor===0?B.groundColor:B.groundColor||16777215,ye=B.intensity===0?B.intensity:B.intensity||1;de=new wu(Ce,z,ye),B.position&&de.position.copy(B.position)}de&&(f.push(de),c.add(de))})}function ge(){const{controlsOptions:V}=n;V&&Object.assign(u,V)}function we(){const{filePath:V,parallelLoad:B}=n;B&&C?V.forEach((ne,de)=>{Fe(de)}):Fe()}function Fe(V){const{filePath:B,fileType:ne,crossOrigin:de,requestHeader:Ce,mtlPath:z,enableDraco:ye,dracoDir:J,plyMaterial:Pe}=n;if(!B)return;const Ae=V||M.value,$e=C.value?B[Ae]:B,Tt=typeof ne=="string"?ne:ne?ne[Ae]:"",ct=FM($e,Tt,ye,Pe,J);d=ct.loader;const Mt=ct.getObject?ct.getObject:ue;if(i&&Ae===0&&c.remove(i),Ce&&d.setRequestHeader(Ce),de&&d.setCrossOrigin(de),z)if(!(typeof z=="object"))Ve($e,Mt,Ae);else{if(!z[Ae]){xe($e,Mt,Ae);return}Ve($e,Mt,Ae)}else xe($e,Mt,Ae)}function xe(V,B,ne){const{textureImage:de,parallelLoad:Ce}=n;d.load(V,(...z)=>{if(i=B(...z),ce(i,V),de){const J=typeof de=="string"?de:de[ne];J&&He(i,J)}t("load",c)},z=>{Ce||Ze(z);const ye=M.value+1;t("process",z,ye)},z=>{t("error",z)})}function Ve(V,B,ne){const{crossOrigin:de,requestHeader:Ce,mtlPath:z}=n,ye=NM();de&&ye.setCrossOrigin(de),Ce&&ye.setRequestHeader(Ce);const J=typeof z=="string"?z:z[ne],Pe=/^(.*\/)([^/]*)$/.exec(J),Ae=Pe[1],$e=Pe[2];ye.setPath(Ae).load($e,Tt=>{Tt.preload(),d.setMaterials(Tt),xe(V,B,ne)})}function ue(V){return V}function ce(V,B){const ne=PM(i);T.value||(c.position.copy(ne.negate()),T.value=!0),i=V;let de=B.split("/");de=de[de.length-1],i.fileName=de,c.add(i),re(),ie(),Se()}function ve(){p=requestAnimationFrame(ve),Le();const V=l.getDelta();g&&g instanceof al&&g.update(V),g&&g instanceof Array&&g.forEach(B=>{B.update(V)}),u&&u.update(),ke()}function ke(){const{pointLightFollowCamera:V}=n;V&&Te(),h.render(c,o)}function Le(){const{showFps:V}=n;V&&m.update()}function Ze(V){const{filePath:B}=n;Math.floor(V.loaded/V.total*100)===100&&(C.value&&B.length>M.value?At.nextTick(()=>{if(M.value++,M.value===B.length){M.value=0;return}Fe()}):M.value=0)}function He(V,B){y||(y=new Os),V.traverse(ne=>{ne.isMesh&&y.load(B,de=>{ne.material.map=de,ne.material.needsUpdate=!0},()=>{},de=>{t("error",de)})})}function Ue(){c.clear()}function gt(V,B){const ne=lt();if(!!ne){if(C.value){ne.children.forEach(de=>{const Ce=_e(de),z=V==="scale"?1:0;B[Ce]?de[V].set(B[Ce].x,B[Ce].y,B[Ce].z):de[V].set(z,z,z)});return}ne[V].set(B.x,B.y,B.z)}}function lt(){return C.value?c:i}function k(){const{labels:V}=n;if(!V||V.length<=0)return;P();const B=C.value?c:i,ne=Ce=>(y||(y=new Os),y.load(Ce)),de=(Ce,z)=>{const ye=oe(Ce,z),J=new Lt(ye);return J.needsUpdate=!0,J};V.forEach(Ce=>{const z=Ce.image?ne(Ce.image):de(Ce.text,Ce.textStyle||{}),ye=new za({map:z,color:Ce.spriteMaterialColor||16777215}),J=new So(ye);Ce.scale?J.scale.set(Ce.scale.x||1,Ce.scale.y||1,Ce.scale.z||0):J.scale.set(1,1,0),Ce.position&&J.position.set(Ce.position.x,Ce.position.y,Ce.position.z),Ce.sid&&(J.sid=Ce.sid),B.add(J)})}function P(){const V=c.children;for(let B=V.length-1;B>=0;B--){const ne=V[B];ne&&(ne instanceof dn&&ne.children&&(c.children[B].children=ne.children.map(de=>de instanceof So?null:de).filter(de=>de)),ne instanceof So&&c.remove(ne))}}function oe(V,B){const ne=(Mt,et,Ct,_t,Yn,gn)=>{Mt.beginPath(),Mt.moveTo(et+gn,Ct),Mt.lineTo(et+_t-gn,Ct),Mt.quadraticCurveTo(et+_t,Ct,et+_t,Ct+gn),Mt.lineTo(et+_t,Ct+Yn-gn),Mt.quadraticCurveTo(et+_t,Ct+Yn,et+_t-gn,Ct+Yn),Mt.lineTo(et+gn,Ct+Yn),Mt.quadraticCurveTo(et,Ct+Yn,et,Ct+Yn-gn),Mt.lineTo(et,Ct+gn),Mt.quadraticCurveTo(et,Ct,et+gn,Ct),Mt.closePath(),Mt.fill(),Mt.stroke()},de=B.fontFamily||"Arial",Ce=B.fontSize===0||B.fontSize?B.fontSize:18,z=B.color||"#ffffff",ye=B.fontWeight||"normal",J=B.borderWidth===0||B.borderWidth?B.borderWidth:4,Pe=B.borderColor||"rgba(0,0,0,1)",Ae=B.borderRadius===0||B.borderRadius?B.borderRadius:4,$e=B.backgroundColor||"rgba(255, 255, 255, 1)",Tt=document.createElement("canvas"),ct=Tt.getContext("2d");if(ct){ct.font=`${ye} ${Ce}px ${de}`;const et=ct.measureText(V).width;ct.fillStyle=$e,ct.strokeStyle=Pe,ct.lineWidth=J,ne(ct,J/2,J/2,et+J,Ce*1.4+J,Ae),ct.fillStyle=z,ct.fillText(V,J,Ce+J)}return Tt}function _e(V){const{filePath:B}=n;let ne;return B instanceof Array&&(ne=B.map((de,Ce)=>{if(de.indexOf(V.fileName)>-1)return Ce}).filter(de=>de!=null)[0]),ne}function Se(){const V=lt();if(!!V){if(C.value){je(V);return}Ie(V)}}function Ie(V){const{autoPlay:B}=n;g=new al(V),V.animations&&V.animations.length>0&&V.animations.forEach(ne=>{if(ne){const de=g.clipAction(ne);B?de.play():de.stop()}})}function je(V){const{autoPlay:B}=n;g=[],V.children.forEach((ne,de)=>{g.push(new al(ne)),ne.animations&&ne.animations.length>0&&ne.animations.forEach(Ce=>{if(Ce){const z=g[de].clipAction(Ce);B?z.play():z.stop()}})})}function D(){if(!u)return;const{verticalCtrl:V,horizontalCtrl:B,minDistance:ne,maxDistance:de}=n;V&&typeof V=="boolean"&&(u.minAzimuthAngle=-2*Math.PI,u.maxAzimuthAngle=-2*Math.PI),V&&typeof V=="object"&&(u.minAzimuthAngle=V.min,u.maxAzimuthAngle=V.max),B&&typeof B=="boolean"&&(u.minPolarAngle=1,u.maxPolarAngle=1),B&&typeof B=="object"&&(u.minPolarAngle=B.min,u.maxPolarAngle=B.max),ne!=0&&typeof ne=="number"&&(u.minDistance=ne),de!=1/0&&typeof de=="number"&&(u.maxDistance=de)}function me(){const{enableAxesHelper:V,enableGridHelper:B,axesHelperSize:ne}=n;V?(x=new kp(ne),c.add(x)):x&&c.remove(x),B?(b=new Pp(2e3,100),c.add(b)):b&&c.remove(b)}function Te(){const V=o.position.clone();c.children.forEach(B=>{B instanceof $i&&B.position.set(V.x,V.y,V.z)})}return e({camera:o,scene:c}),(V,B)=>(At.openBlock(),At.createElementBlock("div",{ref_key:"containerElement",ref:_,class:"viewer-container"},[At.createElementVNode("canvas",{ref_key:"canvasElement",ref:E,class:"viewer-canvas"},null,512)],512))}});var Ll=OM(zM,[["__scopeId","data-v-550d01bf"]]),UM={install:a=>{a.component(Ll.name,Ll)},vue3dLoader:Ll};return Qr.Three=Qb,Qr.default=UM,Qr.vue3dLoader=Ll,Object.defineProperties(Qr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Qr}({},Vue); +`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 u=h.draco,f=new u.Decoder,d=new u.DecoderBuffer;d.Init(new Int8Array(l),l.byteLength);try{const p=t(u,f,d,c),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{u.destroy(d),u.destroy(f)}});break}};function t(r,o,l,c){const h=c.attributeIDs,u=c.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(l);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(l,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(l,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in h){const y=self[u[g]];let x,b;if(c.useUniqueIDs)b=h[g],x=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[h[g]]),b===-1)continue;x=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,y,x))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,l){const h=l.num_faces()*3,u=h*4,f=r._malloc(u);o.GetTrianglesUInt32Array(l,u,f);const d=new Uint32Array(r.HEAPF32.buffer,f,h).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,l,c,h,u){const f=u.num_components(),p=l.num_points()*f,m=p*h.BYTES_PER_ELEMENT,g=s(r,h),y=r._malloc(m);o.GetAttributeDataArrayForAllPoints(l,u,g,m,y);const x=new h(r.HEAPF32.buffer,y,p).slice();return r._free(y),{name:c,array:x,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const Cl=new di,oi=new SM;oi.addHandler(/\.dds$/i,new MM),oi.addHandler(/\.tga$/i,new sh);function IM(a){return Cl.setFromObject(a),Cl.getSize(new I)}function PM(a){return Cl.setFromObject(a),Cl.getCenter(new I)}function DM(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function FM(a,e,t,n,i){let s;e?s=e:s=DM(a),s==="glb"&&(s="gltf");let r={loader:null,getObject:null};switch(s){case"dae":r={loader:new Uw(oi),getObject:o=>o.scene};break;case"fbx":r={loader:new Cw(oi)};break;case"gltf":r={loader:new Gw(oi),getObject:o=>{const l=o.scene;return o.animations&&(l.animations=o.animations),l}},kM(t,r,i);break;case"obj":r={loader:new wM(oi)};break;case"ply":r={loader:new TM(oi),getObject:o=>(o.computeVertexNormals(),new Rt(o,n==="MeshStandardMaterial"?new Is:new on({vertexColors:!0})))};break;case"stl":r={loader:new AM(oi),getObject:o=>new Rt(o,new ni)};break;case"json":r={loader:new dp(oi)};break}return r}function NM(){return new EM(oi)}function kM(a,e,t){if(a){const n=new LM;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var S1="",OM=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const BM=At.defineComponent({name:"vue3dLoader"}),zM=At.defineComponent({...BM,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null,verticalCtrl:{type:[Boolean,Object],default:!1},horizontalCtrl:{type:[Boolean,Object],default:!1},plyMaterial:{default:"MeshStandardMaterial"},enableAxesHelper:{type:Boolean,default:!1},axesHelperSize:{default:100},enableGridHelper:{type:Boolean,default:!1},minDistance:{default:0},maxDistance:{default:1/0},pointLightFollowCamera:{type:Boolean}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{expose:e,emit:t}){const n=a;let i=null;const s=new Sp,r=new he,o=new Ot(45,1,.1,1e5),l=new Au;let c=new Ba,h=null,u={},f=[],d=null,p=0,m=null,g=null,y=null,x=null,b=null;const v=At.ref({width:n.width||0,height:n.height||0}),M=At.ref(0),T=At.ref(!1),C=At.ref(!1),_=At.ref(null),E=At.ref(null);At.onMounted(()=>{q()}),At.onBeforeUnmount(()=>{U()}),At.watch([()=>n.autoPlay],()=>{Se()}),At.watch([()=>n.width,()=>n.height],()=>{v.value={width:n.width||0,height:n.height||0}}),At.watch([()=>n.enableAxesHelper,()=>n.axesHelperSize,()=>n.enableGridHelper],()=>{me()}),At.watch([()=>n.minDistance,()=>n.maxDistance],()=>{D()}),At.watch([()=>n.filePath,()=>n.fileType,()=>n.mtlPath,()=>n.clearScene,()=>n.backgroundAlpha,()=>n.backgroundColor],V=>{(V[0]||V[1])&&F(),V[2]&&we(),V[3]&&Ue(),(V[4]||V[5])&&ae()},{deep:!0}),At.watch([()=>n.rotation,()=>n.position,()=>n.scale,()=>n.lights],V=>{const B=["rotation","position","scale"];V.forEach((ne,de)=>{de<3&&ne?gt(B[de],ne):H()})},{deep:!0}),At.watch([()=>v],()=>{re(!0),ae()},{deep:!0}),At.watch([()=>n.controlsOptions],()=>{ge()},{deep:!0}),At.watch([()=>n.cameraRotation,()=>n.cameraPosition],()=>{re()},{deep:!0}),At.watch([()=>n.labels],()=>{k()},{deep:!0});function F(){U(),q()}function U(){p&&cancelAnimationFrame(p),h&&h.dispose(),u&&Object.keys(u).length>0&&(u.dispose(),u={});const V=_.value;V.removeEventListener("mousedown",O,!1),V.removeEventListener("mousemove",j,!1),V.removeEventListener("mouseup",Y,!1),V.removeEventListener("click",W,!1),V.removeEventListener("dblclick",Z,!1),window.removeEventListener("resize",X,!1),i=null,c&&c.clear()}function q(){const{filePath:V,outputEncoding:B,webGLRendererOptions:ne,showFps:de,enableDamping:Ce,dampingFactor:z,labels:ye}=n;V&&typeof V=="object"&&(C.value=!0);const J=_.value;K(J),X();const Ae=Object.assign({},{antialias:!0,alpha:!0},ne,{canvas:E.value});if(!h){h=new $c(Ae),h.shadowMap.enabled=!0;const $e=B==="linear"?fi:it;h.outputEncoding=$e}(!u||Object.keys(u).length<=0)&&(u=new ew(o,J),Ce&&(u.enableDamping=!0,z!=null&&(u.dampingFactor=z))),D(),me(),we(),Q(),G(!0),J.addEventListener("mousedown",O,!1),J.addEventListener("mouseup",Y,!1),J.addEventListener("click",W,!1),J.addEventListener("dblclick",Z,!1),window.addEventListener("resize",X,!1),de&&(m=Oo(),J.appendChild(m.dom)),ve(),ye&&ye.length>0&&k()}function K(V){const{width:B,height:ne}=n;B&&(V.style.width=`${B}px`),ne&&(V.style.height=`${ne}px`)}function G(V){const B=_.value;V?B.addEventListener("mousemove",j,!1):B.removeEventListener("mousemove",j,!1)}function X(){const{width:V,height:B}=n;(!V||!B)&&At.nextTick(()=>{const ne=_.value;v.value={width:V||ne.offsetWidth,height:B||ne.offsetHeight}})}function O(V){G(!1);const B=ee(V.clientX,V.clientY);t("mousedown",V,B)}function j(V){const B=ee(V.clientX,V.clientY);t("mousemove",V,B)}function Y(V){const B=ee(V.clientX,V.clientY);t("mouseup",V,B),G(!0)}function W(V){const B=ee(V.clientX,V.clientY);t("click",V,B)}function Z(V){const B=ee(V.clientX,V.clientY);t("dblclick",V,B)}function ee(V,B){const ne=lt();if(!ne||!_.value)return null;const de=_.value.getBoundingClientRect();V-=de.left,B-=de.top,r.x=V/v.value.width*2-1,r.y=-(B/v.value.height)*2+1,s.setFromCamera(r,o);const Ce=s.intersectObject(ne,n.intersectRecursive);return(Ce&&Ce.length)>0?Ce[0]:null}function Q(){ae(),re(),H(),ge()}function ie(){if(!i)return;const V=C.value?_e(i):null,{position:B,rotation:ne,scale:de}=n;B&&(B instanceof Array?V!=null?i.position.set(B[V].x,B[V].y,B[V].z):i.position.set(0,0,0):i.position.set(B.x,B.y,B.z)),ne&&(ne instanceof Array?V!=null?i.rotation.set(ne[V].x,ne[V].y,ne[V].z):i.rotation.set(0,0,0):i.rotation.set(ne.x,ne.y,ne.z)),de&&(de instanceof Array?V!=null?i.scale.set(de[V].x,de[V].y,de[V].z):i.scale.set(1,1,1):i.scale.set(de.x,de.y,de.z))}function ae(){const{backgroundColor:V,backgroundAlpha:B}=n;h.setSize(v.value.width,v.value.height),h.setPixelRatio(window.devicePixelRatio||1),h.setClearColor(new be(V).getHex()),h.setClearAlpha(B)}function re(V){const{cameraPosition:B,cameraRotation:ne,cameraUp:de,cameraLookAt:Ce}=n;if(o.aspect=v.value.width/v.value.height,o.updateProjectionMatrix(),!V)if(!Ce||!de){if(!i)return;const z=IM(i).length();o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),B.x===0&&B.y===0&&B.z===0&&(o.position.z=z),o.lookAt(new I)}else o.position.set(B.x,B.y,B.z),ne&&o.rotation.set(ne.x,ne.y,ne.z),o.up.set(de.x,de.y,de.z),o.lookAt(new I(Ce.x,Ce.y,Ce.z))}function H(){const{lights:V}=n;c.remove(...f),f=[],V.forEach(B=>{if(!B.type)return;const ne=B.type.toLowerCase();let de=null;if(ne==="ambient"||ne==="ambientlight"){const Ce=B.color===0?B.color:B.color||4210752,z=B.intensity===0?B.intensity:B.intensity||1;de=new ko(Ce,z)}if(ne==="point"||ne==="pointlight"){const Ce=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1,ye=B.distance||0,J=B.decay===0?B.decay:B.decay||1;de=new $i(Ce,z,ye,J),B.position&&de.position.copy(B.position)}if(ne==="directional"||ne==="directionallight"){const Ce=B.color===0?B.color:B.color||16777215,z=B.intensity===0?B.intensity:B.intensity||1;de=new Or(Ce,z),B.position&&de.position.copy(B.position),B.target&&de.target.copy(B.target)}if(ne==="hemisphere"||ne==="hemispherelight"){const Ce=B.skyColor===0?B.skyColor:B.skyColor||16777215,z=B.groundColor===0?B.groundColor:B.groundColor||16777215,ye=B.intensity===0?B.intensity:B.intensity||1;de=new wu(Ce,z,ye),B.position&&de.position.copy(B.position)}de&&(f.push(de),c.add(de))})}function ge(){const{controlsOptions:V}=n;V&&Object.assign(u,V)}function we(){const{filePath:V,parallelLoad:B}=n;B&&C?V.forEach((ne,de)=>{Fe(de)}):Fe()}function Fe(V){const{filePath:B,fileType:ne,crossOrigin:de,requestHeader:Ce,mtlPath:z,enableDraco:ye,dracoDir:J,plyMaterial:Pe}=n;if(!B)return;const Ae=V||M.value,$e=C.value?B[Ae]:B,Tt=typeof ne=="string"?ne:ne?ne[Ae]:"",ct=FM($e,Tt,ye,Pe,J);d=ct.loader;const Mt=ct.getObject?ct.getObject:ue;if(i&&Ae===0&&c.remove(i),Ce&&d.setRequestHeader(Ce),de&&d.setCrossOrigin(de),z)if(!(typeof z=="object"))Ve($e,Mt,Ae);else{if(!z[Ae]){xe($e,Mt,Ae);return}Ve($e,Mt,Ae)}else xe($e,Mt,Ae)}function xe(V,B,ne){const{textureImage:de,parallelLoad:Ce}=n;d.load(V,(...z)=>{if(i=B(...z),ce(i,V),de){const J=typeof de=="string"?de:de[ne];J&&He(i,J)}t("load",c)},z=>{Ce||Ze(z);const ye=M.value+1;t("process",z,ye)},z=>{t("error",z)})}function Ve(V,B,ne){const{crossOrigin:de,requestHeader:Ce,mtlPath:z}=n,ye=NM();de&&ye.setCrossOrigin(de),Ce&&ye.setRequestHeader(Ce);const J=typeof z=="string"?z:z[ne],Pe=/^(.*\/)([^/]*)$/.exec(J),Ae=Pe[1],$e=Pe[2];ye.setPath(Ae).load($e,Tt=>{Tt.preload(),d.setMaterials(Tt),xe(V,B,ne)})}function ue(V){return V}function ce(V,B){const ne=PM(i);T.value||(c.position.copy(ne.negate()),T.value=!0),i=V;let de=B.split("/");de=de[de.length-1],i.fileName=de,c.add(i),re(),ie(),Se()}function ve(){p=requestAnimationFrame(ve),Le();const V=l.getDelta();g&&g instanceof al&&g.update(V),g&&g instanceof Array&&g.forEach(B=>{B.update(V)}),u&&u.update(),ke()}function ke(){const{pointLightFollowCamera:V}=n;V&&Te(),h.render(c,o)}function Le(){const{showFps:V}=n;V&&m.update()}function Ze(V){const{filePath:B}=n;Math.floor(V.loaded/V.total*100)===100&&(C.value&&B.length>M.value?At.nextTick(()=>{if(M.value++,M.value===B.length){M.value=0;return}Fe()}):M.value=0)}function He(V,B){y||(y=new Os),V.traverse(ne=>{ne.isMesh&&y.load(B,de=>{ne.material.map=de,ne.material.needsUpdate=!0},()=>{},de=>{t("error",de)})})}function Ue(){c.clear()}function gt(V,B){const ne=lt();if(!!ne){if(C.value){ne.children.forEach(de=>{const Ce=_e(de),z=V==="scale"?1:0;B[Ce]?de[V].set(B[Ce].x,B[Ce].y,B[Ce].z):de[V].set(z,z,z)});return}ne[V].set(B.x,B.y,B.z)}}function lt(){return C.value?c:i}function k(){const{labels:V}=n;if(!V||V.length<=0)return;P();const B=C.value?c:i,ne=Ce=>(y||(y=new Os),y.load(Ce)),de=(Ce,z)=>{const ye=oe(Ce,z),J=new Lt(ye);return J.needsUpdate=!0,J};V.forEach(Ce=>{const z=Ce.image?ne(Ce.image):de(Ce.text,Ce.textStyle||{}),ye=new za({map:z,color:Ce.spriteMaterialColor||16777215}),J=new So(ye);Ce.scale?J.scale.set(Ce.scale.x||1,Ce.scale.y||1,Ce.scale.z||0):J.scale.set(1,1,0),Ce.position&&J.position.set(Ce.position.x,Ce.position.y,Ce.position.z),Ce.sid&&(J.sid=Ce.sid),B.add(J)})}function P(){const V=c.children;for(let B=V.length-1;B>=0;B--){const ne=V[B];ne&&(ne instanceof dn&&ne.children&&(c.children[B].children=ne.children.map(de=>de instanceof So?null:de).filter(de=>de)),ne instanceof So&&c.remove(ne))}}function oe(V,B){const ne=(Mt,et,Ct,_t,Yn,gn)=>{Mt.beginPath(),Mt.moveTo(et+gn,Ct),Mt.lineTo(et+_t-gn,Ct),Mt.quadraticCurveTo(et+_t,Ct,et+_t,Ct+gn),Mt.lineTo(et+_t,Ct+Yn-gn),Mt.quadraticCurveTo(et+_t,Ct+Yn,et+_t-gn,Ct+Yn),Mt.lineTo(et+gn,Ct+Yn),Mt.quadraticCurveTo(et,Ct+Yn,et,Ct+Yn-gn),Mt.lineTo(et,Ct+gn),Mt.quadraticCurveTo(et,Ct,et+gn,Ct),Mt.closePath(),Mt.fill(),Mt.stroke()},de=B.fontFamily||"Arial",Ce=B.fontSize===0||B.fontSize?B.fontSize:18,z=B.color||"#ffffff",ye=B.fontWeight||"normal",J=B.borderWidth===0||B.borderWidth?B.borderWidth:4,Pe=B.borderColor||"rgba(0,0,0,1)",Ae=B.borderRadius===0||B.borderRadius?B.borderRadius:4,$e=B.backgroundColor||"rgba(255, 255, 255, 1)",Tt=document.createElement("canvas"),ct=Tt.getContext("2d");if(ct){ct.font=`${ye} ${Ce}px ${de}`;const et=ct.measureText(V).width;ct.fillStyle=$e,ct.strokeStyle=Pe,ct.lineWidth=J,ne(ct,J/2,J/2,et+J,Ce*1.4+J,Ae),ct.fillStyle=z,ct.fillText(V,J,Ce+J)}return Tt}function _e(V){const{filePath:B}=n;let ne;return B instanceof Array&&(ne=B.map((de,Ce)=>{if(de.indexOf(V.fileName)>-1)return Ce}).filter(de=>de!=null)[0]),ne}function Se(){const V=lt();if(!!V){if(C.value){je(V);return}Ie(V)}}function Ie(V){const{autoPlay:B}=n;g=new al(V),V.animations&&V.animations.length>0&&V.animations.forEach(ne=>{if(ne){const de=g.clipAction(ne);B?de.play():de.stop()}})}function je(V){const{autoPlay:B}=n;g=[],V.children.forEach((ne,de)=>{g.push(new al(ne)),ne.animations&&ne.animations.length>0&&ne.animations.forEach(Ce=>{if(Ce){const z=g[de].clipAction(Ce);B?z.play():z.stop()}})})}function D(){if(!u)return;const{verticalCtrl:V,horizontalCtrl:B,minDistance:ne,maxDistance:de}=n;V&&typeof V=="boolean"&&(u.minAzimuthAngle=-2*Math.PI,u.maxAzimuthAngle=-2*Math.PI),V&&typeof V=="object"&&(u.minAzimuthAngle=V.min,u.maxAzimuthAngle=V.max),B&&typeof B=="boolean"&&(u.minPolarAngle=1,u.maxPolarAngle=1),B&&typeof B=="object"&&(u.minPolarAngle=B.min,u.maxPolarAngle=B.max),ne!=0&&typeof ne=="number"&&(u.minDistance=ne),de!=1/0&&typeof de=="number"&&(u.maxDistance=de)}function me(){const{enableAxesHelper:V,enableGridHelper:B,axesHelperSize:ne}=n;V?(x=new kp(ne),c.add(x)):x&&c.remove(x),B?(b=new Pp(2e3,100),c.add(b)):b&&c.remove(b)}function Te(){const V=o.position.clone();c.children.forEach(B=>{B instanceof $i&&B.position.set(V.x,V.y,V.z)})}return e({camera:o,scene:c}),(V,B)=>(At.openBlock(),At.createElementBlock("div",{ref_key:"containerElement",ref:_,class:"viewer-container"},[At.createElementVNode("canvas",{ref_key:"canvasElement",ref:E,class:"viewer-canvas"},null,512)],512))}});var Ll=OM(zM,[["__scopeId","data-v-e92274c2"]]),UM={install:a=>{a.component(Ll.name,Ll)},vue3dLoader:Ll};return Qr.Three=Qb,Qr.default=UM,Qr.vue3dLoader=Ll,Object.defineProperties(Qr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Qr}({},Vue); diff --git a/package.json b/package.json index 1e09d47..6c86e55 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue-3d-loader", "private": false, - "version": "2.2.3", + "version": "2.2.4", "main": "dist/vue-3d-loader.cjs.js", "module": "dist/vue-3d-loader.esm.js", "types": "dist/types/index.d.ts",