From 4ee236008a8e78e3584928e4bfd07daeff84863d Mon Sep 17 00:00:00 2001 From: Tony Tao Date: Sat, 30 Jul 2022 14:20:07 +0800 Subject: [PATCH] update build fiels --- dist/style.css | 2 +- dist/vue-3d-loader.cjs.js | 2 +- dist/vue-3d-loader.esm.js | 2 +- dist/vue-3d-loader.global.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/style.css b/dist/style.css index a528798..3fec46d 100644 --- a/dist/style.css +++ b/dist/style.css @@ -1 +1 @@ -.viewer-container[data-v-238f76f8]{position:relative;width:100%;height:100%;margin:0;border:0;padding:0}.viewer-container div[data-v-238f76f8]{position:absolute!important;left:0px!important;opacity:1!important}.viewer-canvas[data-v-238f76f8]{width:100%;height:100%} +.viewer-container[data-v-c3b855f0]{position:relative;width:100%;height:100%;margin:0;border:0;padding:0}.viewer-container div[data-v-c3b855f0]{position:absolute!important;left:0px!important;opacity:1!important}.viewer-canvas[data-v-c3b855f0]{width:100%;height:100%} diff --git a/dist/vue-3d-loader.cjs.js b/dist/vue-3d-loader.cjs.js index 2ac338a..905e781 100644 --- a/dist/vue-3d-loader.cjs.js +++ b/dist/vue-3d-loader.cjs.js @@ -3155,4 +3155,4 @@ version 0.6.9 `)),e.indexOf(`\\ `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(` `);let i=[];for(let o=0,c=n.length;o=7?(Ba.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(Ba.r,Ba.g,Ba.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const f=l.slice(1).trim().split($f),d=[];for(let p=0,g=f.length;p0){const x=y.split("/");d.push(x)}}const m=d[0];for(let p=1,g=d.length-1;p1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}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,c=t.objects.length;o0&&p.setAttribute("normal",new Te(u.normals,3)),u.colors.length>0&&(m=!0,p.setAttribute("color",new Te(u.colors,3))),u.hasUVIndices===!0&&p.setAttribute("uv",new Te(u.uvs,2));const g=[];for(let x=0,b=h.length;x1){for(let x=0,b=h.length;x0){const o=new Ui({size:1,sizeAttenuation:!1}),c=new je;c.setAttribute("position",new Te(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new Te(t.colors,3)),o.vertexColors=!0);const l=new mr(c,o);s.add(l)}return s}}class $M 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,c=2048,l=4096,u=8192,h=16384,f=32768;function d(Q){return Q.charCodeAt(0)+(Q.charCodeAt(1)<<8)+(Q.charCodeAt(2)<<16)+(Q.charCodeAt(3)<<24)}function m(Q){return String.fromCharCode(Q&255,Q>>8&255,Q>>16&255,Q>>24&255)}function p(Q,G,xe,Ae){const De=xe*Ae*4,ge=new Uint8Array(Q,G,De),Ge=new Uint8Array(De);let le=0,ce=0;for(let ve=0;ve>1,1),xe=Math.max(xe>>1,1)}}return n}}class Gm{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){o++,s===!1&&i.onStart!==void 0&&i.onStart(u,r,o),s=!0},this.itemEnd=function(u){r++,i.onProgress!==void 0&&i.onProgress(u,r,o),r===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h=m.elements[v].count&&(v++,S=0);const _=i(m.elements[v].properties,I);o(p,m.elements[v].name,_),S++}return r(p)}function r(d){let m=new je;return d.indices.length>0&&m.setIndex(d.indices),m.setAttribute("position",new Te(d.vertices,3)),d.normals.length>0&&m.setAttribute("normal",new Te(d.normals,3)),d.uvs.length>0&&m.setAttribute("uv",new Te(d.uvs,2)),d.colors.length>0&&m.setAttribute("color",new Te(d.colors,3)),d.faceVertexUvs.length>0&&(m=m.toNonIndexed(),m.setAttribute("uv",new Te(d.faceVertexUvs,2))),m.computeBoundingSphere(),m}function o(d,m,p){function g(W){for(let Z=0,U=W.length;Z>5&31)/31,m=(q>>10&31)/31):(f=y,d=x,m=b)}for(let q=1;q<=3;q++){const k=z+q*12,X=N*3*3+(q-1)*3;_[X]=u.getFloat32(k,!0),_[X+1]=u.getFloat32(k+4,!0),_[X+2]=u.getFloat32(k+8,!0),L[X]=W,L[X+1]=Z,L[X+2]=U,p&&(g[X]=f,g[X+1]=d,g[X+2]=m)}}return I.setAttribute("position",new gt(_,3)),I.setAttribute("normal",new gt(L,3)),p&&(I.setAttribute("color",new gt(g,3)),I.hasColors=!0,I.alpha=v),I}function s(l){const u=new je,h=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const m=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,p=new RegExp("vertex"+m+m+m,"g"),g=new RegExp("normal"+m+m+m,"g"),y=[],x=[],b=new D;let v,S=0,A=0,I=0;for(;(v=h.exec(l))!==null;){A=I;const _=v[0];for(;(v=f.exec(_))!==null;){let z=0,W=0;const Z=v[0];for(;(v=g.exec(Z))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),W++;for(;(v=p.exec(Z))!==null;)y.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),x.push(b.x,b.y,b.z),z++,I++;W!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),z!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const L=A,N=I-A;u.addGroup(L,N,S),S++}return u.setAttribute("position",new Te(y,3)),u.setAttribute("normal",new Te(x,3)),u}function r(l){return typeof l!="string"?Qt.decodeText(new Uint8Array(l)):l}function o(l){if(typeof l=="string"){const u=new Uint8Array(l.length);for(let h=0;h=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new n1(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class n1{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:Kn,this.wrap=this.options.wrap!==void 0?this.options.wrap:on}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,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}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,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=tt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new be().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new be().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new be().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Zn(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:ku;let o=r.getHandler(e);o===null&&(o=new Ps(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const rc=new Mi,Xn=new Gm;Xn.addHandler(/\.dds$/i,new $M);Xn.addHandler(/\.tga$/i,new cu);function i1(a){return rc.setFromObject(a),rc.getSize(new D)}function s1(a){return rc.setFromObject(a),rc.getCenter(new D)}function r1(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function o1(a){let e=r1(a);e==="glb"&&(e="gltf");let t={loader:null,getObject:null};switch(e){case"dae":t={loader:new mM(Xn),getObject:n=>n.scene};break;case"fbx":t={loader:new iM(Xn)};break;case"gltf":t={loader:new gM(Xn),getObject:n=>n.scene};break;case"obj":t={loader:new JM(Xn)};break;case"ply":t={loader:new QM(Xn),getObject:n=>(n.computeVertexNormals(),new St(n,new Os))};break;case"stl":t={loader:new e1(Xn),getObject:n=>new St(n,new Zn)};break;case"json":t={loader:new qp(Xn)};break}return t}function a1(){return new t1(Xn)}var c1=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const l1=Ft.defineComponent({name:"vue3dLoader"}),u1=Ft.defineComponent({...l1,props:{filePath: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:()=>[]}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new Kp,s=new he,r=new It(45,1,1,1e5),o=new vc,c=new ct;let l=null,u={},h=[];const f=new Gu;let d=null,m=0,p=null,g=null,y=null;const x=Ft.ref({width:t.width||0,height:t.height||0}),b=Ft.ref(0),v=Ft.ref(!1),S=Ft.ref(null),A=Ft.ref(!1),I=Ft.ref(null),_=Ft.ref(null);Ft.watch([()=>t.filePath,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],se=>{se[0]&&ne(),se[1]&&ve(),(se[2]||se[3])&&H()}),Ft.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],se=>{const T=["rotation","position","scale"];se.forEach((E,V)=>{V<3&&E?Fe(T[V],E):ee()})},{deep:!0}),Ft.watch([()=>x],()=>{Y(!0),H()},{deep:!0}),Ft.watch([()=>t.controlsOptions],()=>{J()},{deep:!0}),Ft.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{Y()},{deep:!0}),Ft.onMounted(()=>{const{filePath:se,outputEncoding:T,webGLRendererOptions:E,showFps:V}=t;se&&typeof se=="object"&&(A.value=!0);const K=I.value;L(K),N();const pe=Object.assign({},{antialias:!0,alpha:!0},E,{canvas:_.value});l=new Tu(pe),l.shadowMap.enabled=!0;const Ce=T==="linear"?gi:tt;l.outputEncoding=Ce,u=new Lw(r,K),o.add(c),ne(),X(),K.addEventListener("mousedown",z,!1),K.addEventListener("mousemove",W,!1),K.addEventListener("mouseup",Z,!1),K.addEventListener("click",U,!1),K.addEventListener("dblclick",q,!1),window.addEventListener("resize",N,!1),V&&(p=fo(),K.appendChild(p.dom)),De()}),Ft.onBeforeUnmount(()=>{cancelAnimationFrame(m),l.dispose(),u&&u.dispose();const se=I.value;se.removeEventListener("mousedown",z,!1),se.removeEventListener("mousemove",W,!1),se.removeEventListener("mouseup",Z,!1),se.removeEventListener("click",U,!1),se.removeEventListener("dblclick",q,!1),window.removeEventListener("resize",N,!1)});function L(se){const{width:T,height:E}=t;T&&(se.style.width=`${T}px`),E&&(se.style.height=`${E}px`)}function N(){const{width:se,height:T}=t;(!se||!T)&&Ft.nextTick(()=>{const E=I.value;x.value={width:se||E.offsetWidth,height:T||E.offsetHeight}})}function z(se){const T=k(se.clientX,se.clientY);e("mousedown",se,T)}function W(se){const T=()=>{const E=k(se.clientX,se.clientY);e("mousemove",se,E)};A.value?(clearTimeout(S.value),S.value=setTimeout(()=>{T()},200)):T()}function Z(se){const T=k(se.clientX,se.clientY);e("mouseup",se,T)}function U(se){const T=k(se.clientX,se.clientY);e("click",se,T)}function q(se){const T=k(se.clientX,se.clientY);e("dblclick",se,T)}function k(se,T){const E=Ee();if(!E||!I.value)return null;const V=I.value.getBoundingClientRect();se-=V.left,T-=V.top,s.x=se/x.value.width*2-1,s.y=-(T/x.value.height)*2+1,i.setFromCamera(s,r);const K=i.intersectObject(E,!0);return(K&&K.length)>0?K[0]:null}function X(){H(),Y(),ee(),J()}function j(){if(!n)return;const se=A.value?lt(n):null,{position:T,rotation:E,scale:V}=t;T&&(T instanceof Array?se!=null?n.position.set(T[se].x,T[se].y,T[se].z):n.position.set(0,0,0):n.position.set(T.x,T.y,T.z)),E&&(E instanceof Array?se!=null?n.rotation.set(E[se].x,E[se].y,E[se].z):n.rotation.set(0,0,0):n.rotation.set(E.x,E.y,E.z)),V&&(V instanceof Array?se!=null?n.scale.set(V[se].x,V[se].y,V[se].z):n.scale.set(0,0,0):n.scale.set(V.x,V.y,V.z))}function H(){const{backgroundColor:se,backgroundAlpha:T}=t;l.setSize(x.value.width,x.value.height),l.setPixelRatio(window.devicePixelRatio||1),l.setClearColor(new be(se).getHex()),l.setClearAlpha(T)}function Y(se){const{cameraPosition:T,cameraRotation:E,cameraUp:V,cameraLookAt:K}=t;if(r.aspect=x.value.width/x.value.height,r.updateProjectionMatrix(),!se)if(!K||!V){if(!n)return;const ae=i1(n).length();r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),T.x===0&&T.y===0&&T.z===0&&(r.position.z=ae),r.lookAt(new D)}else r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),r.up.set(V.x,V.y,V.z),r.lookAt(new D(K.x,K.y,K.z))}function ee(){const{lights:se}=t;o.remove(...h),h=[],se.forEach(T=>{if(!T.type)return;const E=T.type.toLowerCase();let V=null;if(E==="ambient"||E==="ambientlight"){const K=T.color===0?T.color:T.color||4210752,ae=T.intensity===0?T.intensity:T.intensity||1;V=new Bo(K,ae)}if(E==="point"||E==="pointlight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1,pe=T.distance||0,Ce=T.decay===0?T.decay:T.decay||1;V=new Ds(K,ae,pe,Ce),T.position&&V.position.copy(T.position)}if(E==="directional"||E==="directionallight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1;V=new zr(K,ae),T.position&&V.position.copy(T.position),T.target&&V.target.copy(T.target)}if(E==="hemisphere"||E==="hemispherelight"){const K=T.skyColor===0?T.skyColor:T.skyColor||16777215,ae=T.groundColor===0?T.groundColor:T.groundColor||16777215,pe=T.intensity===0?T.intensity:T.intensity||1;V=new Bu(K,ae,pe),T.position&&V.position.copy(T.position)}V&&(h.push(V),o.add(V))})}function J(){const{controlsOptions:se}=t;se&&Object.assign(u,se)}function ne(){const{filePath:se,parallelLoad:T}=t;T&&A?se.forEach((E,V)=>{re(V)}):re()}function re(se){const{filePath:T,crossOrigin:E,requestHeader:V,mtlPath:K}=t;if(!T)return;const ae=se||b.value,pe=A.value?T[ae]:T,Ce=o1(pe);d=Ce.loader;const F=Ce.getObject?Ce.getObject:xe;if(n&&ae===0&&c.remove(n),V&&d.setRequestHeader(V),E&&d.setCrossOrigin(E),K)if(!(typeof K=="object"))G(pe,F,ae);else{if(!K[ae]){Q(pe,F,ae);return}G(pe,F,ae)}else Q(pe,F,ae)}function Q(se,T,E){const{textureImage:V,parallelLoad:K}=t;d.load(se,(...ae)=>{if(n=T(...ae),Ae(n,se),g=new Zp(n),n.animations&&n.animations.forEach(Ce=>{g.clipAction(Ce).play()}),V){const Ce=typeof V=="string"?V:V[E];Ce&&ce(n,Ce)}Ye(),e("load",c)},ae=>{K||le(ae);const pe=b.value+1;e("process",ae,pe)},ae=>{e("error",ae)})}function G(se,T,E){const{crossOrigin:V,requestHeader:K,mtlPath:ae}=t,pe=a1();V&&pe.setCrossOrigin(V),K&&pe.setRequestHeader(K);const Ce=typeof ae=="string"?ae:ae[E],F=/^(.*\/)([^/]*)$/.exec(Ce),fe=F[1],Se=F[2];pe.setPath(fe).load(Se,Me=>{Me.preload(),d.setMaterials(Me),Q(se,T,E)})}function xe(se){return se}function Ae(se,T){const E=s1(n);v.value||(c.position.copy(E.negate()),v.value=!0),n=se;let V=T.split("/");V=V[V.length-1],n.fileName=V,c.add(n),Y(),j()}function De(){m=requestAnimationFrame(De),Ge();const se=f.getDelta();g&&g.update(se),ge()}function ge(){l.render(o,r)}function Ge(){const{showFps:se}=t;se&&p.update()}function le(se){const{filePath:T}=t;Math.floor(se.loaded/se.total*100)===100&&(A.value&&T.length>b.value?Ft.nextTick(()=>{if(b.value++,b.value===T.length){b.value=0;return}re()}):b.value=0)}function ce(se,T){y||(y=new Ps),se.traverse(E=>{E.isMesh&&y.load(T,V=>{E.material.map=V,E.material.needsUpdate=!0},()=>{},V=>{e("error",V)})})}function ve(){c.clear()}function Fe(se,T){const E=Ee();if(!!E){if(A.value){E.children.forEach(V=>{const K=lt(V),ae=se==="scale"?1:0;T[K]?V[se].set(T[K].x,T[K].y,T[K].z):V[se].set(ae,ae,ae)});return}E[se].set(T.x,T.y,T.z)}}function Ee(){return A.value?c:n}function Ye(){const{filePath:se}=t;A.value?b.value===se.length&&Ve():Ve()}function Ve(){const{labels:se}=t;if(!se)return;const T=A.value?c:n,E=K=>(y||(y=new Ps),y.load(K)),V=(K,ae)=>{const pe=Ue(K,ae),Ce=new Tt(pe);return Ce.needsUpdate=!0,Ce};se.forEach(K=>{const ae=K.image?E(K.image):V(K.text,K.textStyle||{}),pe=new _c({map:ae,color:K.spriteMaterialColor||16777215}),Ce=new Au(pe);K.scale?Ce.scale.set(K.scale.x||1,K.scale.y||1,K.scale.z||0):Ce.scale.set(1,1,0),K.position&&Ce.position.set(K.position.x,K.position.y,K.position.z),K.sid&&(Ce.sid=K.sid),T.add(Ce)})}function Ue(se,T){const E=(ye,me,ke,Le,Be,_e)=>{ye.beginPath(),ye.moveTo(me+_e,ke),ye.lineTo(me+Le-_e,ke),ye.quadraticCurveTo(me+Le,ke,me+Le,ke+_e),ye.lineTo(me+Le,ke+Be-_e),ye.quadraticCurveTo(me+Le,ke+Be,me+Le-_e,ke+Be),ye.lineTo(me+_e,ke+Be),ye.quadraticCurveTo(me,ke+Be,me,ke+Be-_e),ye.lineTo(me,ke+_e),ye.quadraticCurveTo(me,ke,me+_e,ke),ye.closePath(),ye.fill(),ye.stroke()},V=T.fontFamily||"Arial",K=T.fontSize===0||T.fontSize?T.fontSize:18,ae=T.color||"#ffffff",pe=T.fontWeight||"normal",Ce=T.borderWidth===0||T.borderWidth?T.borderWidth:4,F=T.borderColor||"rgba(0,0,0,1)",fe=T.borderRadius===0||T.borderRadius?T.borderRadius:4,Se=T.backgroundColor||"rgba(255, 255, 255, 1)",Me=document.createElement("canvas"),B=Me.getContext("2d");if(B){B.font=`${pe} ${K}px ${V}`;const me=B.measureText(se).width;B.fillStyle=Se,B.strokeStyle=F,B.lineWidth=Ce,E(B,Ce/2,Ce/2,me+Ce,K*1.4+Ce,fe),B.fillStyle=ae,B.fillText(se,Ce,K+Ce)}return Me}function lt(se){const{filePath:T}=t;let E;return T instanceof Array&&(E=T.map((V,K)=>{if(V.indexOf(se.fileName)>-1)return K}).filter(V=>V!=null)[0]),E}return(se,T)=>(Ft.openBlock(),Ft.createElementBlock("div",{ref_key:"containerElement",ref:I,class:"viewer-container"},[Ft.createElementVNode("canvas",{ref_key:"canvasElement",ref:_,class:"viewer-canvas"},null,512)],512))}});var oc=c1(u1,[["__scopeId","data-v-238f76f8"]]);const h1=a=>{a.component(oc.name,oc)};var f1={install:h1,vue3dLoader:oc};exports.Three=Cw;exports.default=f1;exports.vue3dLoader=oc; +`);let i={};const s=/\s+/,r={};for(let c=0;c=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new n1(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class n1{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:Kn,this.wrap=this.options.wrap!==void 0?this.options.wrap:on}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,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}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,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=tt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new be().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new be().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new be().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Zn(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:ku;let o=r.getHandler(e);o===null&&(o=new Ps(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const rc=new Mi,Xn=new Gm;Xn.addHandler(/\.dds$/i,new $M);Xn.addHandler(/\.tga$/i,new cu);function i1(a){return rc.setFromObject(a),rc.getSize(new D)}function s1(a){return rc.setFromObject(a),rc.getCenter(new D)}function r1(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function o1(a){let e=r1(a);e==="glb"&&(e="gltf");let t={loader:null,getObject:null};switch(e){case"dae":t={loader:new mM(Xn),getObject:n=>n.scene};break;case"fbx":t={loader:new iM(Xn)};break;case"gltf":t={loader:new gM(Xn),getObject:n=>n.scene};break;case"obj":t={loader:new JM(Xn)};break;case"ply":t={loader:new QM(Xn),getObject:n=>(n.computeVertexNormals(),new St(n,new Os))};break;case"stl":t={loader:new e1(Xn),getObject:n=>new St(n,new Zn)};break;case"json":t={loader:new qp(Xn)};break}return t}function a1(){return new t1(Xn)}var c1=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const l1=Ft.defineComponent({name:"vue3dLoader"}),u1=Ft.defineComponent({...l1,props:{filePath: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:()=>[]}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new Kp,s=new he,r=new It(45,1,1,1e5),o=new vc,c=new ct;let l=null,u={},h=[];const f=new Gu;let d=null,m=0,p=null,g=null,y=null;const x=Ft.ref({width:t.width||0,height:t.height||0}),b=Ft.ref(0),v=Ft.ref(!1),S=Ft.ref(null),A=Ft.ref(!1),I=Ft.ref(null),_=Ft.ref(null);Ft.watch([()=>t.filePath,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],se=>{se[0]&&ne(),se[1]&&ve(),(se[2]||se[3])&&H()}),Ft.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],se=>{const T=["rotation","position","scale"];se.forEach((E,V)=>{V<3&&E?Fe(T[V],E):ee()})},{deep:!0}),Ft.watch([()=>x],()=>{Y(!0),H()},{deep:!0}),Ft.watch([()=>t.controlsOptions],()=>{J()},{deep:!0}),Ft.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{Y()},{deep:!0}),Ft.onMounted(()=>{const{filePath:se,outputEncoding:T,webGLRendererOptions:E,showFps:V}=t;se&&typeof se=="object"&&(A.value=!0);const K=I.value;L(K),N();const pe=Object.assign({},{antialias:!0,alpha:!0},E,{canvas:_.value});l=new Tu(pe),l.shadowMap.enabled=!0;const Ce=T==="linear"?gi:tt;l.outputEncoding=Ce,u=new Lw(r,K),o.add(c),ne(),X(),K.addEventListener("mousedown",z,!1),K.addEventListener("mousemove",W,!1),K.addEventListener("mouseup",Z,!1),K.addEventListener("click",U,!1),K.addEventListener("dblclick",q,!1),window.addEventListener("resize",N,!1),V&&(p=fo(),K.appendChild(p.dom)),De()}),Ft.onBeforeUnmount(()=>{cancelAnimationFrame(m),l.dispose(),u&&u.dispose();const se=I.value;se.removeEventListener("mousedown",z,!1),se.removeEventListener("mousemove",W,!1),se.removeEventListener("mouseup",Z,!1),se.removeEventListener("click",U,!1),se.removeEventListener("dblclick",q,!1),window.removeEventListener("resize",N,!1)});function L(se){const{width:T,height:E}=t;T&&(se.style.width=`${T}px`),E&&(se.style.height=`${E}px`)}function N(){const{width:se,height:T}=t;(!se||!T)&&Ft.nextTick(()=>{const E=I.value;x.value={width:se||E.offsetWidth,height:T||E.offsetHeight}})}function z(se){const T=k(se.clientX,se.clientY);e("mousedown",se,T)}function W(se){const T=()=>{const E=k(se.clientX,se.clientY);e("mousemove",se,E)};A.value?(clearTimeout(S.value),S.value=setTimeout(()=>{T()},200)):T()}function Z(se){const T=k(se.clientX,se.clientY);e("mouseup",se,T)}function U(se){const T=k(se.clientX,se.clientY);e("click",se,T)}function q(se){const T=k(se.clientX,se.clientY);e("dblclick",se,T)}function k(se,T){const E=Ee();if(!E||!I.value)return null;const V=I.value.getBoundingClientRect();se-=V.left,T-=V.top,s.x=se/x.value.width*2-1,s.y=-(T/x.value.height)*2+1,i.setFromCamera(s,r);const K=i.intersectObject(E,!0);return(K&&K.length)>0?K[0]:null}function X(){H(),Y(),ee(),J()}function j(){if(!n)return;const se=A.value?lt(n):null,{position:T,rotation:E,scale:V}=t;T&&(T instanceof Array?se!=null?n.position.set(T[se].x,T[se].y,T[se].z):n.position.set(0,0,0):n.position.set(T.x,T.y,T.z)),E&&(E instanceof Array?se!=null?n.rotation.set(E[se].x,E[se].y,E[se].z):n.rotation.set(0,0,0):n.rotation.set(E.x,E.y,E.z)),V&&(V instanceof Array?se!=null?n.scale.set(V[se].x,V[se].y,V[se].z):n.scale.set(0,0,0):n.scale.set(V.x,V.y,V.z))}function H(){const{backgroundColor:se,backgroundAlpha:T}=t;l.setSize(x.value.width,x.value.height),l.setPixelRatio(window.devicePixelRatio||1),l.setClearColor(new be(se).getHex()),l.setClearAlpha(T)}function Y(se){const{cameraPosition:T,cameraRotation:E,cameraUp:V,cameraLookAt:K}=t;if(r.aspect=x.value.width/x.value.height,r.updateProjectionMatrix(),!se)if(!K||!V){if(!n)return;const ae=i1(n).length();r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),T.x===0&&T.y===0&&T.z===0&&(r.position.z=ae),r.lookAt(new D)}else r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),r.up.set(V.x,V.y,V.z),r.lookAt(new D(K.x,K.y,K.z))}function ee(){const{lights:se}=t;o.remove(...h),h=[],se.forEach(T=>{if(!T.type)return;const E=T.type.toLowerCase();let V=null;if(E==="ambient"||E==="ambientlight"){const K=T.color===0?T.color:T.color||4210752,ae=T.intensity===0?T.intensity:T.intensity||1;V=new Bo(K,ae)}if(E==="point"||E==="pointlight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1,pe=T.distance||0,Ce=T.decay===0?T.decay:T.decay||1;V=new Ds(K,ae,pe,Ce),T.position&&V.position.copy(T.position)}if(E==="directional"||E==="directionallight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1;V=new zr(K,ae),T.position&&V.position.copy(T.position),T.target&&V.target.copy(T.target)}if(E==="hemisphere"||E==="hemispherelight"){const K=T.skyColor===0?T.skyColor:T.skyColor||16777215,ae=T.groundColor===0?T.groundColor:T.groundColor||16777215,pe=T.intensity===0?T.intensity:T.intensity||1;V=new Bu(K,ae,pe),T.position&&V.position.copy(T.position)}V&&(h.push(V),o.add(V))})}function J(){const{controlsOptions:se}=t;se&&Object.assign(u,se)}function ne(){const{filePath:se,parallelLoad:T}=t;T&&A?se.forEach((E,V)=>{re(V)}):re()}function re(se){const{filePath:T,crossOrigin:E,requestHeader:V,mtlPath:K}=t;if(!T)return;const ae=se||b.value,pe=A.value?T[ae]:T,Ce=o1(pe);d=Ce.loader;const F=Ce.getObject?Ce.getObject:xe;if(n&&ae===0&&c.remove(n),V&&d.setRequestHeader(V),E&&d.setCrossOrigin(E),K)if(!(typeof K=="object"))G(pe,F,ae);else{if(!K[ae]){Q(pe,F,ae);return}G(pe,F,ae)}else Q(pe,F,ae)}function Q(se,T,E){const{textureImage:V,parallelLoad:K}=t;d.load(se,(...ae)=>{if(n=T(...ae),Ae(n,se),g=new Zp(n),n.animations&&n.animations.forEach(Ce=>{g.clipAction(Ce).play()}),V){const Ce=typeof V=="string"?V:V[E];Ce&&ce(n,Ce)}Ye(),e("load",c)},ae=>{K||le(ae);const pe=b.value+1;e("process",ae,pe)},ae=>{e("error",ae)})}function G(se,T,E){const{crossOrigin:V,requestHeader:K,mtlPath:ae}=t,pe=a1();V&&pe.setCrossOrigin(V),K&&pe.setRequestHeader(K);const Ce=typeof ae=="string"?ae:ae[E],F=/^(.*\/)([^/]*)$/.exec(Ce),fe=F[1],Se=F[2];pe.setPath(fe).load(Se,Me=>{Me.preload(),d.setMaterials(Me),Q(se,T,E)})}function xe(se){return se}function Ae(se,T){const E=s1(n);v.value||(c.position.copy(E.negate()),v.value=!0),n=se;let V=T.split("/");V=V[V.length-1],n.fileName=V,c.add(n),Y(),j()}function De(){m=requestAnimationFrame(De),Ge();const se=f.getDelta();g&&g.update(se),ge()}function ge(){l.render(o,r)}function Ge(){const{showFps:se}=t;se&&p.update()}function le(se){const{filePath:T}=t;Math.floor(se.loaded/se.total*100)===100&&(A.value&&T.length>b.value?Ft.nextTick(()=>{if(b.value++,b.value===T.length){b.value=0;return}re()}):b.value=0)}function ce(se,T){y||(y=new Ps),se.traverse(E=>{E.isMesh&&y.load(T,V=>{E.material.map=V,E.material.needsUpdate=!0},()=>{},V=>{e("error",V)})})}function ve(){c.clear()}function Fe(se,T){const E=Ee();if(!!E){if(A.value){E.children.forEach(V=>{const K=lt(V),ae=se==="scale"?1:0;T[K]?V[se].set(T[K].x,T[K].y,T[K].z):V[se].set(ae,ae,ae)});return}E[se].set(T.x,T.y,T.z)}}function Ee(){return A.value?c:n}function Ye(){const{filePath:se}=t;A.value?b.value===se.length&&Ve():Ve()}function Ve(){const{labels:se}=t;if(!se)return;const T=A.value?c:n,E=K=>(y||(y=new Ps),y.load(K)),V=(K,ae)=>{const pe=Ue(K,ae),Ce=new Tt(pe);return Ce.needsUpdate=!0,Ce};se.forEach(K=>{const ae=K.image?E(K.image):V(K.text,K.textStyle||{}),pe=new _c({map:ae,color:K.spriteMaterialColor||16777215}),Ce=new Au(pe);K.scale?Ce.scale.set(K.scale.x||1,K.scale.y||1,K.scale.z||0):Ce.scale.set(1,1,0),K.position&&Ce.position.set(K.position.x,K.position.y,K.position.z),K.sid&&(Ce.sid=K.sid),T.add(Ce)})}function Ue(se,T){const E=(ye,me,ke,Le,Be,_e)=>{ye.beginPath(),ye.moveTo(me+_e,ke),ye.lineTo(me+Le-_e,ke),ye.quadraticCurveTo(me+Le,ke,me+Le,ke+_e),ye.lineTo(me+Le,ke+Be-_e),ye.quadraticCurveTo(me+Le,ke+Be,me+Le-_e,ke+Be),ye.lineTo(me+_e,ke+Be),ye.quadraticCurveTo(me,ke+Be,me,ke+Be-_e),ye.lineTo(me,ke+_e),ye.quadraticCurveTo(me,ke,me+_e,ke),ye.closePath(),ye.fill(),ye.stroke()},V=T.fontFamily||"Arial",K=T.fontSize===0||T.fontSize?T.fontSize:18,ae=T.color||"#ffffff",pe=T.fontWeight||"normal",Ce=T.borderWidth===0||T.borderWidth?T.borderWidth:4,F=T.borderColor||"rgba(0,0,0,1)",fe=T.borderRadius===0||T.borderRadius?T.borderRadius:4,Se=T.backgroundColor||"rgba(255, 255, 255, 1)",Me=document.createElement("canvas"),B=Me.getContext("2d");if(B){B.font=`${pe} ${K}px ${V}`;const me=B.measureText(se).width;B.fillStyle=Se,B.strokeStyle=F,B.lineWidth=Ce,E(B,Ce/2,Ce/2,me+Ce,K*1.4+Ce,fe),B.fillStyle=ae,B.fillText(se,Ce,K+Ce)}return Me}function lt(se){const{filePath:T}=t;let E;return T instanceof Array&&(E=T.map((V,K)=>{if(V.indexOf(se.fileName)>-1)return K}).filter(V=>V!=null)[0]),E}return(se,T)=>(Ft.openBlock(),Ft.createElementBlock("div",{ref_key:"containerElement",ref:I,class:"viewer-container"},[Ft.createElementVNode("canvas",{ref_key:"canvasElement",ref:_,class:"viewer-canvas"},null,512)],512))}});var oc=c1(u1,[["__scopeId","data-v-c3b855f0"]]);const h1=a=>{a.component(oc.name,oc)};var f1={install:h1,vue3dLoader:oc};exports.Three=Cw;exports.default=f1;exports.vue3dLoader=oc; diff --git a/dist/vue-3d-loader.esm.js b/dist/vue-3d-loader.esm.js index 793eb9f..e723be6 100644 --- a/dist/vue-3d-loader.esm.js +++ b/dist/vue-3d-loader.esm.js @@ -40842,7 +40842,7 @@ const _sfc_main = defineComponent({ }; } }); -var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-238f76f8"]]); +var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c3b855f0"]]); 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 0f5f0c5..2b394be 100644 --- a/dist/vue-3d-loader.global.js +++ b/dist/vue-3d-loader.global.js @@ -3155,4 +3155,4 @@ version 0.6.9 `)),e.indexOf(`\\ `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(` `);let i=[];for(let o=0,c=n.length;o=7?(xc.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(xc.r,xc.g,xc.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const f=l.slice(1).trim().split(Im),d=[];for(let p=0,g=f.length;p0){const x=y.split("/");d.push(x)}}const m=d[0];for(let p=1,g=d.length-1;p1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}t.finalize();const s=new hn;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,c=t.objects.length;o0&&p.setAttribute("normal",new Te(u.normals,3)),u.colors.length>0&&(m=!0,p.setAttribute("color",new Te(u.colors,3))),u.hasUVIndices===!0&&p.setAttribute("uv",new Te(u.uvs,2));const g=[];for(let x=0,b=h.length;x1){for(let x=0,b=h.length;x0){const o=new Vi({size:1,sizeAttenuation:!1}),c=new qe;c.setAttribute("position",new Te(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new Te(t.colors,3)),o.vertexColors=!0);const l=new gr(c,o);s.add(l)}return s}}class pM extends Xd{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,c=2048,l=4096,u=8192,h=16384,f=32768;function d(Q){return Q.charCodeAt(0)+(Q.charCodeAt(1)<<8)+(Q.charCodeAt(2)<<16)+(Q.charCodeAt(3)<<24)}function m(Q){return String.fromCharCode(Q&255,Q>>8&255,Q>>16&255,Q>>24&255)}function p(Q,G,xe,Ae){const De=xe*Ae*4,ge=new Uint8Array(Q,G,De),Ge=new Uint8Array(De);let le=0,ce=0;for(let _e=0;_e>1,1),xe=Math.max(xe>>1,1)}}return n}}class Nm{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){o++,s===!1&&i.onStart!==void 0&&i.onStart(u,r,o),s=!0},this.itemEnd=function(u){r++,i.onProgress!==void 0&&i.onProgress(u,r,o),r===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h=m.elements[v].count&&(v++,S=0);const _=i(m.elements[v].properties,I);o(p,m.elements[v].name,_),S++}return r(p)}function r(d){let m=new qe;return d.indices.length>0&&m.setIndex(d.indices),m.setAttribute("position",new Te(d.vertices,3)),d.normals.length>0&&m.setAttribute("normal",new Te(d.normals,3)),d.uvs.length>0&&m.setAttribute("uv",new Te(d.uvs,2)),d.colors.length>0&&m.setAttribute("color",new Te(d.colors,3)),d.faceVertexUvs.length>0&&(m=m.toNonIndexed(),m.setAttribute("uv",new Te(d.faceVertexUvs,2))),m.computeBoundingSphere(),m}function o(d,m,p){function g(W){for(let Z=0,U=W.length;Z>5&31)/31,m=(X>>10&31)/31):(f=y,d=x,m=b)}for(let X=1;X<=3;X++){const k=z+X*12,q=N*3*3+(X-1)*3;_[q]=u.getFloat32(k,!0),_[q+1]=u.getFloat32(k+4,!0),_[q+2]=u.getFloat32(k+8,!0),L[q]=W,L[q+1]=Z,L[q+2]=U,p&&(g[q]=f,g[q+1]=d,g[q+2]=m)}}return I.setAttribute("position",new pt(_,3)),I.setAttribute("normal",new pt(L,3)),p&&(I.setAttribute("color",new pt(g,3)),I.hasColors=!0,I.alpha=v),I}function s(l){const u=new qe,h=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const m=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,p=new RegExp("vertex"+m+m+m,"g"),g=new RegExp("normal"+m+m+m,"g"),y=[],x=[],b=new D;let v,S=0,A=0,I=0;for(;(v=h.exec(l))!==null;){A=I;const _=v[0];for(;(v=f.exec(_))!==null;){let z=0,W=0;const Z=v[0];for(;(v=g.exec(Z))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),W++;for(;(v=p.exec(Z))!==null;)y.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),x.push(b.x,b.y,b.z),z++,I++;W!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),z!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const L=A,N=I-A;u.addGroup(L,N,S),S++}return u.setAttribute("position",new Te(y,3)),u.setAttribute("normal",new Te(x,3)),u}function r(l){return typeof l!="string"?$t.decodeText(new Uint8Array(l)):l}function o(l){if(typeof l=="string"){const u=new Uint8Array(l.length);for(let h=0;h=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new xM(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class xM{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:Vn,this.wrap=this.options.wrap!==void 0?this.options.wrap:sn}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,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}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,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=tt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new ve().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new ve().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new ve().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Zn(i),this.materials[e]}getTextureParams(e,t){const n={scale:new ue(1,1),offset:new ue(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:hu;let o=r.getHandler(e);o===null&&(o=new Rs(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const _c=new ai,Qn=new Nm;Qn.addHandler(/\.dds$/i,new pM),Qn.addHandler(/\.tga$/i,new Yu);function vM(a){return _c.setFromObject(a),_c.getSize(new D)}function _M(a){return _c.setFromObject(a),_c.getCenter(new D)}function bM(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function wM(a){let e=bM(a);e==="glb"&&(e="gltf");let t={loader:null,getObject:null};switch(e){case"dae":t={loader:new Iw(Qn),getObject:n=>n.scene};break;case"fbx":t={loader:new vw(Qn)};break;case"gltf":t={loader:new Pw(Qn),getObject:n=>n.scene};break;case"obj":t={loader:new dM(Qn)};break;case"ply":t={loader:new mM(Qn),getObject:n=>(n.computeVertexNormals(),new St(n,new Ts))};break;case"stl":t={loader:new gM(Qn),getObject:n=>new St(n,new Zn)};break;case"json":t={loader:new tp(Qn)};break}return t}function MM(){return new yM(Qn)}var d1="",SM=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const TM=Dt.defineComponent({name:"vue3dLoader"}),AM=Dt.defineComponent({...TM,props:{filePath: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:()=>[]}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new dp,s=new ue,r=new Rt(45,1,1,1e5),o=new Ia,c=new at;let l=null,u={},h=[];const f=new gu;let d=null,m=0,p=null,g=null,y=null;const x=Dt.ref({width:t.width||0,height:t.height||0}),b=Dt.ref(0),v=Dt.ref(!1),S=Dt.ref(null),A=Dt.ref(!1),I=Dt.ref(null),_=Dt.ref(null);Dt.watch([()=>t.filePath,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],se=>{se[0]&&ne(),se[1]&&_e(),(se[2]||se[3])&&H()}),Dt.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],se=>{const T=["rotation","position","scale"];se.forEach((E,V)=>{V<3&&E?Fe(T[V],E):ee()})},{deep:!0}),Dt.watch([()=>x],()=>{Y(!0),H()},{deep:!0}),Dt.watch([()=>t.controlsOptions],()=>{J()},{deep:!0}),Dt.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{Y()},{deep:!0}),Dt.onMounted(()=>{const{filePath:se,outputEncoding:T,webGLRendererOptions:E,showFps:V}=t;se&&typeof se=="object"&&(A.value=!0);const K=I.value;L(K),N();const pe=Object.assign({},{antialias:!0,alpha:!0},E,{canvas:_.value});l=new Wl(pe),l.shadowMap.enabled=!0;const Ce=T==="linear"?ri:tt;l.outputEncoding=Ce,u=new Xb(r,K),o.add(c),ne(),q(),K.addEventListener("mousedown",z,!1),K.addEventListener("mousemove",W,!1),K.addEventListener("mouseup",Z,!1),K.addEventListener("click",U,!1),K.addEventListener("dblclick",X,!1),window.addEventListener("resize",N,!1),V&&(p=Ro(),K.appendChild(p.dom)),De()}),Dt.onBeforeUnmount(()=>{cancelAnimationFrame(m),l.dispose(),u&&u.dispose();const se=I.value;se.removeEventListener("mousedown",z,!1),se.removeEventListener("mousemove",W,!1),se.removeEventListener("mouseup",Z,!1),se.removeEventListener("click",U,!1),se.removeEventListener("dblclick",X,!1),window.removeEventListener("resize",N,!1)});function L(se){const{width:T,height:E}=t;T&&(se.style.width=`${T}px`),E&&(se.style.height=`${E}px`)}function N(){const{width:se,height:T}=t;(!se||!T)&&Dt.nextTick(()=>{const E=I.value;x.value={width:se||E.offsetWidth,height:T||E.offsetHeight}})}function z(se){const T=k(se.clientX,se.clientY);e("mousedown",se,T)}function W(se){const T=()=>{const E=k(se.clientX,se.clientY);e("mousemove",se,E)};A.value?(clearTimeout(S.value),S.value=setTimeout(()=>{T()},200)):T()}function Z(se){const T=k(se.clientX,se.clientY);e("mouseup",se,T)}function U(se){const T=k(se.clientX,se.clientY);e("click",se,T)}function X(se){const T=k(se.clientX,se.clientY);e("dblclick",se,T)}function k(se,T){const E=Ee();if(!E||!I.value)return null;const V=I.value.getBoundingClientRect();se-=V.left,T-=V.top,s.x=se/x.value.width*2-1,s.y=-(T/x.value.height)*2+1,i.setFromCamera(s,r);const K=i.intersectObject(E,!0);return(K&&K.length)>0?K[0]:null}function q(){H(),Y(),ee(),J()}function j(){if(!n)return;const se=A.value?ut(n):null,{position:T,rotation:E,scale:V}=t;T&&(T instanceof Array?se!=null?n.position.set(T[se].x,T[se].y,T[se].z):n.position.set(0,0,0):n.position.set(T.x,T.y,T.z)),E&&(E instanceof Array?se!=null?n.rotation.set(E[se].x,E[se].y,E[se].z):n.rotation.set(0,0,0):n.rotation.set(E.x,E.y,E.z)),V&&(V instanceof Array?se!=null?n.scale.set(V[se].x,V[se].y,V[se].z):n.scale.set(0,0,0):n.scale.set(V.x,V.y,V.z))}function H(){const{backgroundColor:se,backgroundAlpha:T}=t;l.setSize(x.value.width,x.value.height),l.setPixelRatio(window.devicePixelRatio||1),l.setClearColor(new ve(se).getHex()),l.setClearAlpha(T)}function Y(se){const{cameraPosition:T,cameraRotation:E,cameraUp:V,cameraLookAt:K}=t;if(r.aspect=x.value.width/x.value.height,r.updateProjectionMatrix(),!se)if(!K||!V){if(!n)return;const ae=vM(n).length();r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),T.x===0&&T.y===0&&T.z===0&&(r.position.z=ae),r.lookAt(new D)}else r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),r.up.set(V.x,V.y,V.z),r.lookAt(new D(K.x,K.y,K.z))}function ee(){const{lights:se}=t;o.remove(...h),h=[],se.forEach(T=>{if(!T.type)return;const E=T.type.toLowerCase();let V=null;if(E==="ambient"||E==="ambientlight"){const K=T.color===0?T.color:T.color||4210752,ae=T.intensity===0?T.intensity:T.intensity||1;V=new Lo(K,ae)}if(E==="point"||E==="pointlight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1,pe=T.distance||0,Ce=T.decay===0?T.decay:T.decay||1;V=new Is(K,ae,pe,Ce),T.position&&V.position.copy(T.position)}if(E==="directional"||E==="directionallight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1;V=new Ir(K,ae),T.position&&V.position.copy(T.position),T.target&&V.target.copy(T.target)}if(E==="hemisphere"||E==="hemispherelight"){const K=T.skyColor===0?T.skyColor:T.skyColor||16777215,ae=T.groundColor===0?T.groundColor:T.groundColor||16777215,pe=T.intensity===0?T.intensity:T.intensity||1;V=new fu(K,ae,pe),T.position&&V.position.copy(T.position)}V&&(h.push(V),o.add(V))})}function J(){const{controlsOptions:se}=t;se&&Object.assign(u,se)}function ne(){const{filePath:se,parallelLoad:T}=t;T&&A?se.forEach((E,V)=>{re(V)}):re()}function re(se){const{filePath:T,crossOrigin:E,requestHeader:V,mtlPath:K}=t;if(!T)return;const ae=se||b.value,pe=A.value?T[ae]:T,Ce=wM(pe);d=Ce.loader;const F=Ce.getObject?Ce.getObject:xe;if(n&&ae===0&&c.remove(n),V&&d.setRequestHeader(V),E&&d.setCrossOrigin(E),K)if(!(typeof K=="object"))G(pe,F,ae);else{if(!K[ae]){Q(pe,F,ae);return}G(pe,F,ae)}else Q(pe,F,ae)}function Q(se,T,E){const{textureImage:V,parallelLoad:K}=t;d.load(se,(...ae)=>{if(n=T(...ae),Ae(n,se),g=new fp(n),n.animations&&n.animations.forEach(Ce=>{g.clipAction(Ce).play()}),V){const Ce=typeof V=="string"?V:V[E];Ce&&ce(n,Ce)}Ye(),e("load",c)},ae=>{K||le(ae);const pe=b.value+1;e("process",ae,pe)},ae=>{e("error",ae)})}function G(se,T,E){const{crossOrigin:V,requestHeader:K,mtlPath:ae}=t,pe=MM();V&&pe.setCrossOrigin(V),K&&pe.setRequestHeader(K);const Ce=typeof ae=="string"?ae:ae[E],F=/^(.*\/)([^/]*)$/.exec(Ce),fe=F[1],Se=F[2];pe.setPath(fe).load(Se,Me=>{Me.preload(),d.setMaterials(Me),Q(se,T,E)})}function xe(se){return se}function Ae(se,T){const E=_M(n);v.value||(c.position.copy(E.negate()),v.value=!0),n=se;let V=T.split("/");V=V[V.length-1],n.fileName=V,c.add(n),Y(),j()}function De(){m=requestAnimationFrame(De),Ge();const se=f.getDelta();g&&g.update(se),ge()}function ge(){l.render(o,r)}function Ge(){const{showFps:se}=t;se&&p.update()}function le(se){const{filePath:T}=t;Math.floor(se.loaded/se.total*100)===100&&(A.value&&T.length>b.value?Dt.nextTick(()=>{if(b.value++,b.value===T.length){b.value=0;return}re()}):b.value=0)}function ce(se,T){y||(y=new Rs),se.traverse(E=>{E.isMesh&&y.load(T,V=>{E.material.map=V,E.material.needsUpdate=!0},()=>{},V=>{e("error",V)})})}function _e(){c.clear()}function Fe(se,T){const E=Ee();if(!!E){if(A.value){E.children.forEach(V=>{const K=ut(V),ae=se==="scale"?1:0;T[K]?V[se].set(T[K].x,T[K].y,T[K].z):V[se].set(ae,ae,ae)});return}E[se].set(T.x,T.y,T.z)}}function Ee(){return A.value?c:n}function Ye(){const{filePath:se}=t;A.value?b.value===se.length&&Ve():Ve()}function Ve(){const{labels:se}=t;if(!se)return;const T=A.value?c:n,E=K=>(y||(y=new Rs),y.load(K)),V=(K,ae)=>{const pe=Ue(K,ae),Ce=new Mt(pe);return Ce.needsUpdate=!0,Ce};se.forEach(K=>{const ae=K.image?E(K.image):V(K.text,K.textStyle||{}),pe=new Pa({map:ae,color:K.spriteMaterialColor||16777215}),Ce=new ql(pe);K.scale?Ce.scale.set(K.scale.x||1,K.scale.y||1,K.scale.z||0):Ce.scale.set(1,1,0),K.position&&Ce.position.set(K.position.x,K.position.y,K.position.z),K.sid&&(Ce.sid=K.sid),T.add(Ce)})}function Ue(se,T){const E=(ye,me,ke,Le,Be,be)=>{ye.beginPath(),ye.moveTo(me+be,ke),ye.lineTo(me+Le-be,ke),ye.quadraticCurveTo(me+Le,ke,me+Le,ke+be),ye.lineTo(me+Le,ke+Be-be),ye.quadraticCurveTo(me+Le,ke+Be,me+Le-be,ke+Be),ye.lineTo(me+be,ke+Be),ye.quadraticCurveTo(me,ke+Be,me,ke+Be-be),ye.lineTo(me,ke+be),ye.quadraticCurveTo(me,ke,me+be,ke),ye.closePath(),ye.fill(),ye.stroke()},V=T.fontFamily||"Arial",K=T.fontSize===0||T.fontSize?T.fontSize:18,ae=T.color||"#ffffff",pe=T.fontWeight||"normal",Ce=T.borderWidth===0||T.borderWidth?T.borderWidth:4,F=T.borderColor||"rgba(0,0,0,1)",fe=T.borderRadius===0||T.borderRadius?T.borderRadius:4,Se=T.backgroundColor||"rgba(255, 255, 255, 1)",Me=document.createElement("canvas"),B=Me.getContext("2d");if(B){B.font=`${pe} ${K}px ${V}`;const me=B.measureText(se).width;B.fillStyle=Se,B.strokeStyle=F,B.lineWidth=Ce,E(B,Ce/2,Ce/2,me+Ce,K*1.4+Ce,fe),B.fillStyle=ae,B.fillText(se,Ce,K+Ce)}return Me}function ut(se){const{filePath:T}=t;let E;return T instanceof Array&&(E=T.map((V,K)=>{if(V.indexOf(se.fileName)>-1)return K}).filter(V=>V!=null)[0]),E}return(se,T)=>(Dt.openBlock(),Dt.createElementBlock("div",{ref_key:"containerElement",ref:I,class:"viewer-container"},[Dt.createElementVNode("canvas",{ref_key:"canvasElement",ref:_,class:"viewer-canvas"},null,512)],512))}});var bc=SM(AM,[["__scopeId","data-v-238f76f8"]]),EM={install:a=>{a.component(bc.name,bc)},vue3dLoader:bc};return Yr.Three=Wb,Yr.default=EM,Yr.vue3dLoader=bc,Object.defineProperties(Yr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Yr}({},Vue); +`);let i={};const s=/\s+/,r={};for(let c=0;c=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new xM(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class xM{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:Vn,this.wrap=this.options.wrap!==void 0?this.options.wrap:sn}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,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}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,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=tt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new ve().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new ve().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new ve().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Zn(i),this.materials[e]}getTextureParams(e,t){const n={scale:new ue(1,1),offset:new ue(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:hu;let o=r.getHandler(e);o===null&&(o=new Rs(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const _c=new ai,Qn=new Nm;Qn.addHandler(/\.dds$/i,new pM),Qn.addHandler(/\.tga$/i,new Yu);function vM(a){return _c.setFromObject(a),_c.getSize(new D)}function _M(a){return _c.setFromObject(a),_c.getCenter(new D)}function bM(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function wM(a){let e=bM(a);e==="glb"&&(e="gltf");let t={loader:null,getObject:null};switch(e){case"dae":t={loader:new Iw(Qn),getObject:n=>n.scene};break;case"fbx":t={loader:new vw(Qn)};break;case"gltf":t={loader:new Pw(Qn),getObject:n=>n.scene};break;case"obj":t={loader:new dM(Qn)};break;case"ply":t={loader:new mM(Qn),getObject:n=>(n.computeVertexNormals(),new St(n,new Ts))};break;case"stl":t={loader:new gM(Qn),getObject:n=>new St(n,new Zn)};break;case"json":t={loader:new tp(Qn)};break}return t}function MM(){return new yM(Qn)}var d1="",SM=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const TM=Dt.defineComponent({name:"vue3dLoader"}),AM=Dt.defineComponent({...TM,props:{filePath: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:()=>[]}},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new dp,s=new ue,r=new Rt(45,1,1,1e5),o=new Ia,c=new at;let l=null,u={},h=[];const f=new gu;let d=null,m=0,p=null,g=null,y=null;const x=Dt.ref({width:t.width||0,height:t.height||0}),b=Dt.ref(0),v=Dt.ref(!1),S=Dt.ref(null),A=Dt.ref(!1),I=Dt.ref(null),_=Dt.ref(null);Dt.watch([()=>t.filePath,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],se=>{se[0]&&ne(),se[1]&&_e(),(se[2]||se[3])&&H()}),Dt.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],se=>{const T=["rotation","position","scale"];se.forEach((E,V)=>{V<3&&E?Fe(T[V],E):ee()})},{deep:!0}),Dt.watch([()=>x],()=>{Y(!0),H()},{deep:!0}),Dt.watch([()=>t.controlsOptions],()=>{J()},{deep:!0}),Dt.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{Y()},{deep:!0}),Dt.onMounted(()=>{const{filePath:se,outputEncoding:T,webGLRendererOptions:E,showFps:V}=t;se&&typeof se=="object"&&(A.value=!0);const K=I.value;L(K),N();const pe=Object.assign({},{antialias:!0,alpha:!0},E,{canvas:_.value});l=new Wl(pe),l.shadowMap.enabled=!0;const Ce=T==="linear"?ri:tt;l.outputEncoding=Ce,u=new Xb(r,K),o.add(c),ne(),q(),K.addEventListener("mousedown",z,!1),K.addEventListener("mousemove",W,!1),K.addEventListener("mouseup",Z,!1),K.addEventListener("click",U,!1),K.addEventListener("dblclick",X,!1),window.addEventListener("resize",N,!1),V&&(p=Ro(),K.appendChild(p.dom)),De()}),Dt.onBeforeUnmount(()=>{cancelAnimationFrame(m),l.dispose(),u&&u.dispose();const se=I.value;se.removeEventListener("mousedown",z,!1),se.removeEventListener("mousemove",W,!1),se.removeEventListener("mouseup",Z,!1),se.removeEventListener("click",U,!1),se.removeEventListener("dblclick",X,!1),window.removeEventListener("resize",N,!1)});function L(se){const{width:T,height:E}=t;T&&(se.style.width=`${T}px`),E&&(se.style.height=`${E}px`)}function N(){const{width:se,height:T}=t;(!se||!T)&&Dt.nextTick(()=>{const E=I.value;x.value={width:se||E.offsetWidth,height:T||E.offsetHeight}})}function z(se){const T=k(se.clientX,se.clientY);e("mousedown",se,T)}function W(se){const T=()=>{const E=k(se.clientX,se.clientY);e("mousemove",se,E)};A.value?(clearTimeout(S.value),S.value=setTimeout(()=>{T()},200)):T()}function Z(se){const T=k(se.clientX,se.clientY);e("mouseup",se,T)}function U(se){const T=k(se.clientX,se.clientY);e("click",se,T)}function X(se){const T=k(se.clientX,se.clientY);e("dblclick",se,T)}function k(se,T){const E=Ee();if(!E||!I.value)return null;const V=I.value.getBoundingClientRect();se-=V.left,T-=V.top,s.x=se/x.value.width*2-1,s.y=-(T/x.value.height)*2+1,i.setFromCamera(s,r);const K=i.intersectObject(E,!0);return(K&&K.length)>0?K[0]:null}function q(){H(),Y(),ee(),J()}function j(){if(!n)return;const se=A.value?ut(n):null,{position:T,rotation:E,scale:V}=t;T&&(T instanceof Array?se!=null?n.position.set(T[se].x,T[se].y,T[se].z):n.position.set(0,0,0):n.position.set(T.x,T.y,T.z)),E&&(E instanceof Array?se!=null?n.rotation.set(E[se].x,E[se].y,E[se].z):n.rotation.set(0,0,0):n.rotation.set(E.x,E.y,E.z)),V&&(V instanceof Array?se!=null?n.scale.set(V[se].x,V[se].y,V[se].z):n.scale.set(0,0,0):n.scale.set(V.x,V.y,V.z))}function H(){const{backgroundColor:se,backgroundAlpha:T}=t;l.setSize(x.value.width,x.value.height),l.setPixelRatio(window.devicePixelRatio||1),l.setClearColor(new ve(se).getHex()),l.setClearAlpha(T)}function Y(se){const{cameraPosition:T,cameraRotation:E,cameraUp:V,cameraLookAt:K}=t;if(r.aspect=x.value.width/x.value.height,r.updateProjectionMatrix(),!se)if(!K||!V){if(!n)return;const ae=vM(n).length();r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),T.x===0&&T.y===0&&T.z===0&&(r.position.z=ae),r.lookAt(new D)}else r.position.set(T.x,T.y,T.z),E&&r.rotation.set(E.x,E.y,E.z),r.up.set(V.x,V.y,V.z),r.lookAt(new D(K.x,K.y,K.z))}function ee(){const{lights:se}=t;o.remove(...h),h=[],se.forEach(T=>{if(!T.type)return;const E=T.type.toLowerCase();let V=null;if(E==="ambient"||E==="ambientlight"){const K=T.color===0?T.color:T.color||4210752,ae=T.intensity===0?T.intensity:T.intensity||1;V=new Lo(K,ae)}if(E==="point"||E==="pointlight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1,pe=T.distance||0,Ce=T.decay===0?T.decay:T.decay||1;V=new Is(K,ae,pe,Ce),T.position&&V.position.copy(T.position)}if(E==="directional"||E==="directionallight"){const K=T.color===0?T.color:T.color||16777215,ae=T.intensity===0?T.intensity:T.intensity||1;V=new Ir(K,ae),T.position&&V.position.copy(T.position),T.target&&V.target.copy(T.target)}if(E==="hemisphere"||E==="hemispherelight"){const K=T.skyColor===0?T.skyColor:T.skyColor||16777215,ae=T.groundColor===0?T.groundColor:T.groundColor||16777215,pe=T.intensity===0?T.intensity:T.intensity||1;V=new fu(K,ae,pe),T.position&&V.position.copy(T.position)}V&&(h.push(V),o.add(V))})}function J(){const{controlsOptions:se}=t;se&&Object.assign(u,se)}function ne(){const{filePath:se,parallelLoad:T}=t;T&&A?se.forEach((E,V)=>{re(V)}):re()}function re(se){const{filePath:T,crossOrigin:E,requestHeader:V,mtlPath:K}=t;if(!T)return;const ae=se||b.value,pe=A.value?T[ae]:T,Ce=wM(pe);d=Ce.loader;const F=Ce.getObject?Ce.getObject:xe;if(n&&ae===0&&c.remove(n),V&&d.setRequestHeader(V),E&&d.setCrossOrigin(E),K)if(!(typeof K=="object"))G(pe,F,ae);else{if(!K[ae]){Q(pe,F,ae);return}G(pe,F,ae)}else Q(pe,F,ae)}function Q(se,T,E){const{textureImage:V,parallelLoad:K}=t;d.load(se,(...ae)=>{if(n=T(...ae),Ae(n,se),g=new fp(n),n.animations&&n.animations.forEach(Ce=>{g.clipAction(Ce).play()}),V){const Ce=typeof V=="string"?V:V[E];Ce&&ce(n,Ce)}Ye(),e("load",c)},ae=>{K||le(ae);const pe=b.value+1;e("process",ae,pe)},ae=>{e("error",ae)})}function G(se,T,E){const{crossOrigin:V,requestHeader:K,mtlPath:ae}=t,pe=MM();V&&pe.setCrossOrigin(V),K&&pe.setRequestHeader(K);const Ce=typeof ae=="string"?ae:ae[E],F=/^(.*\/)([^/]*)$/.exec(Ce),fe=F[1],Se=F[2];pe.setPath(fe).load(Se,Me=>{Me.preload(),d.setMaterials(Me),Q(se,T,E)})}function xe(se){return se}function Ae(se,T){const E=_M(n);v.value||(c.position.copy(E.negate()),v.value=!0),n=se;let V=T.split("/");V=V[V.length-1],n.fileName=V,c.add(n),Y(),j()}function De(){m=requestAnimationFrame(De),Ge();const se=f.getDelta();g&&g.update(se),ge()}function ge(){l.render(o,r)}function Ge(){const{showFps:se}=t;se&&p.update()}function le(se){const{filePath:T}=t;Math.floor(se.loaded/se.total*100)===100&&(A.value&&T.length>b.value?Dt.nextTick(()=>{if(b.value++,b.value===T.length){b.value=0;return}re()}):b.value=0)}function ce(se,T){y||(y=new Rs),se.traverse(E=>{E.isMesh&&y.load(T,V=>{E.material.map=V,E.material.needsUpdate=!0},()=>{},V=>{e("error",V)})})}function _e(){c.clear()}function Fe(se,T){const E=Ee();if(!!E){if(A.value){E.children.forEach(V=>{const K=ut(V),ae=se==="scale"?1:0;T[K]?V[se].set(T[K].x,T[K].y,T[K].z):V[se].set(ae,ae,ae)});return}E[se].set(T.x,T.y,T.z)}}function Ee(){return A.value?c:n}function Ye(){const{filePath:se}=t;A.value?b.value===se.length&&Ve():Ve()}function Ve(){const{labels:se}=t;if(!se)return;const T=A.value?c:n,E=K=>(y||(y=new Rs),y.load(K)),V=(K,ae)=>{const pe=Ue(K,ae),Ce=new Mt(pe);return Ce.needsUpdate=!0,Ce};se.forEach(K=>{const ae=K.image?E(K.image):V(K.text,K.textStyle||{}),pe=new Pa({map:ae,color:K.spriteMaterialColor||16777215}),Ce=new ql(pe);K.scale?Ce.scale.set(K.scale.x||1,K.scale.y||1,K.scale.z||0):Ce.scale.set(1,1,0),K.position&&Ce.position.set(K.position.x,K.position.y,K.position.z),K.sid&&(Ce.sid=K.sid),T.add(Ce)})}function Ue(se,T){const E=(ye,me,ke,Le,Be,be)=>{ye.beginPath(),ye.moveTo(me+be,ke),ye.lineTo(me+Le-be,ke),ye.quadraticCurveTo(me+Le,ke,me+Le,ke+be),ye.lineTo(me+Le,ke+Be-be),ye.quadraticCurveTo(me+Le,ke+Be,me+Le-be,ke+Be),ye.lineTo(me+be,ke+Be),ye.quadraticCurveTo(me,ke+Be,me,ke+Be-be),ye.lineTo(me,ke+be),ye.quadraticCurveTo(me,ke,me+be,ke),ye.closePath(),ye.fill(),ye.stroke()},V=T.fontFamily||"Arial",K=T.fontSize===0||T.fontSize?T.fontSize:18,ae=T.color||"#ffffff",pe=T.fontWeight||"normal",Ce=T.borderWidth===0||T.borderWidth?T.borderWidth:4,F=T.borderColor||"rgba(0,0,0,1)",fe=T.borderRadius===0||T.borderRadius?T.borderRadius:4,Se=T.backgroundColor||"rgba(255, 255, 255, 1)",Me=document.createElement("canvas"),B=Me.getContext("2d");if(B){B.font=`${pe} ${K}px ${V}`;const me=B.measureText(se).width;B.fillStyle=Se,B.strokeStyle=F,B.lineWidth=Ce,E(B,Ce/2,Ce/2,me+Ce,K*1.4+Ce,fe),B.fillStyle=ae,B.fillText(se,Ce,K+Ce)}return Me}function ut(se){const{filePath:T}=t;let E;return T instanceof Array&&(E=T.map((V,K)=>{if(V.indexOf(se.fileName)>-1)return K}).filter(V=>V!=null)[0]),E}return(se,T)=>(Dt.openBlock(),Dt.createElementBlock("div",{ref_key:"containerElement",ref:I,class:"viewer-container"},[Dt.createElementVNode("canvas",{ref_key:"canvasElement",ref:_,class:"viewer-canvas"},null,512)],512))}});var bc=SM(AM,[["__scopeId","data-v-c3b855f0"]]),EM={install:a=>{a.component(bc.name,bc)},vue3dLoader:bc};return Yr.Three=Wb,Yr.default=EM,Yr.vue3dLoader=bc,Object.defineProperties(Yr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Yr}({},Vue);