slicer-studio 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +301 -2
- package/dist/chunks/ModelPreview-CYVyGDd1.js +61 -0
- package/dist/chunks/StudioContext-CsxoZNKd.js +1 -0
- package/dist/chunks/Viewer3D-o2piEXHZ.js +60 -0
- package/dist/chunks/features-6cCl0G7E.js +1 -0
- package/dist/chunks/files-uJ4WD9Mr.js +1 -0
- package/dist/chunks/fonts-DxaZCWS1.js +1 -0
- package/dist/chunks/model-read-UJhMfy15.js +5 -0
- package/dist/chunks/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/chunks/three.module-MNvRIzJI.js +4220 -0
- package/dist/chunks/thumbnail-21laMIqI.js +1 -0
- package/dist/chunks/tip-C-Kdakwj.js +5 -0
- package/dist/chunks/useThemeColors-Dpdj0pe9.js +12 -0
- package/dist/slicer-studio.js +56 -0
- package/package.json +53 -4
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{i as e,o as t}from"./files-uJ4WD9Mr.js";import{D as n,E as r,F as i,G as a,I as o,L as s,N as c,P as l,R as u,T as d,U as f,W as p,X as m,Y as h,a as g,c as _,f as v,g as y,h as b,it as x,j as S,k as C,lt as w,o as T,tt as ee,u as E,v as D,w as O}from"./three.module-MNvRIzJI.js";var k=class extends C{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new b(this.manager);a.setPath(this.path),a.setResponseType(`arraybuffer`),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){function t(e){let t=new DataView(e);if(84+t.getUint32(80,!0)*50===t.byteLength)return!0;let r=[115,111,108,105,100];for(let e=0;e<5;e++)if(n(r,t,e))return!1;return!0}function n(e,t,n){for(let r=0,i=e.length;r<i;r++)if(e[r]!==t.getUint8(n+r))return!1;return!0}function r(e){let t=new DataView(e),n=t.getUint32(80,!0),r,i,a,o=!1,s,c,l,u,d;for(let e=0;e<70;e++)t.getUint32(e,!1)==1129270351&&t.getUint8(e+4)==82&&t.getUint8(e+5)==61&&(o=!0,s=new Float32Array(n*3*3),c=t.getUint8(e+6)/255,l=t.getUint8(e+7)/255,u=t.getUint8(e+8)/255,d=t.getUint8(e+9)/255);let f=new T,p=new Float32Array(n*3*3),h=new Float32Array(n*3*3),_=new E;for(let e=0;e<n;e++){let n=84+e*50,d=t.getFloat32(n,!0),f=t.getFloat32(n+4,!0),g=t.getFloat32(n+8,!0);if(o){let e=t.getUint16(n+48,!0);e&32768?(r=c,i=l,a=u):(r=(e&31)/31,i=(e>>5&31)/31,a=(e>>10&31)/31)}for(let c=1;c<=3;c++){let l=n+c*12,u=e*3*3+(c-1)*3;p[u]=t.getFloat32(l,!0),p[u+1]=t.getFloat32(l+4,!0),p[u+2]=t.getFloat32(l+8,!0),h[u]=d,h[u+1]=f,h[u+2]=g,o&&(_.setRGB(r,i,a,m),s[u]=_.r,s[u+1]=_.g,s[u+2]=_.b)}}return f.setAttribute(`position`,new g(p,3)),f.setAttribute(`normal`,new g(h,3)),o&&(f.setAttribute(`color`,new g(s,3)),f.hasColors=!0,f.alpha=d),f}function i(e){let t=new T,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,i=/solid\s(.+)/,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],u=[],d=[],f=new w,p,m=0,h=0,g=0;for(;(p=n.exec(e))!==null;){h=g;let e=p[0],n=(p=i.exec(e))===null?``:p[1];for(d.push(n);(p=r.exec(e))!==null;){let e=0,t=0,n=p[0];for(;(p=c.exec(n))!==null;)f.x=parseFloat(p[1]),f.y=parseFloat(p[2]),f.z=parseFloat(p[3]),t++;for(;(p=s.exec(n))!==null;)l.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),u.push(f.x,f.y,f.z),e++,g++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let o=h,_=g-h;t.userData.groupNames=d,t.addGroup(o,_,m),m++}return t.setAttribute(`position`,new y(l,3)),t.setAttribute(`normal`,new y(u,3)),t}function a(e){return typeof e==`string`?e:new TextDecoder().decode(e)}function o(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer||t}return e}let s=o(e);return t(s)?r(s):i(a(e))}};function te(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new T,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=A(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t!==0){c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=A(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}}return c}function A(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new g(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}function j(e,t=Math.PI/3){let n=e.index?e.toNonIndexed():e,r=n.attributes.position,i=r.count,a;if(r.isBufferAttribute===!0&&r.itemSize===3&&r.normalized===!1)a=r.array;else{a=new Float64Array(i*3);for(let e=0;e<i;e++)a[3*e+0]=r.getX(e),a[3*e+1]=r.getY(e),a[3*e+2]=r.getZ(e)}let o=Math.cos(t),s=(1+1e-10)*100,c=i/3,l=new Float64Array(c*3);for(let e=0;e<c;e++){let t=9*e,n=a[t+0],r=a[t+1],i=a[t+2],o=a[t+3],s=a[t+4],c=a[t+5],u=a[t+6],d=a[t+7],f=a[t+8],p=u-o,m=d-s,h=f-c,g=n-o,_=r-s,v=i-c,y=m*v-h*_,b=h*g-p*v,x=p*_-m*g,S=1/(Math.sqrt(y*y+b*b+x*x)||1);l[3*e+0]=y*S,l[3*e+1]=b*S,l[3*e+2]=x*S}let u=new Int32Array(i),d=new Float64Array(i*3),f=1;for(;f<i*2;)f<<=1;let p=f-1,m=new Int32Array(f),h=0;for(let e=0;e<i;e++){let t=3*e,n=Math.trunc(a[t+0]*s),r=Math.trunc(a[t+1]*s),i=Math.trunc(a[t+2]*s),o=(Math.imul(n,73856093)^Math.imul(r,19349663)^Math.imul(i,83492791))&p;for(;;){let t=m[o];if(t===0){let t=3*h;d[t+0]=n,d[t+1]=r,d[t+2]=i,m[o]=h+1,u[e]=h++;break}let a=3*(t-1);if(d[a+0]===n&&d[a+1]===r&&d[a+2]===i){u[e]=t-1;break}o=o+1&p}}let _=new Int32Array(h+1);for(let e=0;e<i;e++)_[u[e]+1]++;for(let e=0;e<h;e++)_[e+1]+=_[e];let v=new Int32Array(i),y=_.slice(0,h);for(let e=0;e<c;e++){let t=3*e;v[y[u[t+0]]++]=e,v[y[u[t+1]]++]=e,v[y[u[t+2]]++]=e}let b=new Float32Array(i*3);for(let e=0;e<c;e++){let t=3*e,n=l[t+0],r=l[t+1],i=l[t+2];for(let e=0;e<3;e++){let a=t+e,s=u[a],c=0,d=0,f=0;for(let e=_[s],t=_[s+1];e<t;e++){let t=3*v[e],a=l[t+0],s=l[t+1],u=l[t+2];n*a+r*s+i*u>o&&(c+=a,d+=s,f+=u)}let p=1/(Math.sqrt(c*c+d*d+f*f)||1);b[3*a+0]=c*p,b[3*a+1]=d*p,b[3*a+2]=f*p}}return n.setAttribute(`normal`,new g(b,3,!1)),n}var M=m,N=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02`,P=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/balls/2020/07`,F=class extends C{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,r){let i=this,a=new b(i.manager);a.setPath(i.path),a.setResponseType(`arraybuffer`),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){let d=this,f=new x(this.manager);function p(e){let n=null,r=null,i,a,o=[],s=[],c,l={},u={},d={},f=new TextDecoder;try{n=t(new Uint8Array(e))}catch(e){if(e instanceof ReferenceError)return console.error(`THREE.3MFLoader: fflate missing and file is compressed.`),null}let p=null;for(r in n)r.match(/\_rels\/.rels$/)?i=r:r.match(/3D\/_rels\/.*\.model\.rels$/)?a=r:r.match(/^3D\/[^\/]*\.model$/)?p=r:r.match(/^3D\/.*\/.*\.model$/)?o.push(r):r.match(/^3D\/Textures?\/.*/)&&s.push(r);if(o.push(p),i===void 0)throw Error("THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.");let h=n[i],g=m(f.decode(h));if(a){let e=n[a];c=m(f.decode(e))}for(let e=0;e<o.length;e++){let t=o[e],r=n[t],i=f.decode(r),a=new DOMParser().parseFromString(i,`application/xml`);a.documentElement.nodeName.toLowerCase()!==`model`&&console.error(`THREE.3MFLoader: Error loading 3MF - no 3MF document found: `,t);let s=a.querySelector(`model`),c={};for(let e=0;e<s.attributes.length;e++){let t=s.attributes[e];t.name.match(/^xmlns:(.+)$/)&&(c[t.value]=RegExp.$1)}let u=K(s);u.xml=s,0<Object.keys(c).length&&(u.extensions=c),l[t]=u}for(let e=0;e<s.length;e++){let t=s[e];d[t]=n[t].buffer}return{rels:g,modelRels:c,model:l,printTicket:u,texture:d}}function m(e){let t=[],n=new DOMParser().parseFromString(e,`application/xml`).querySelectorAll(`Relationship`);for(let e=0;e<n.length;e++){let r=n[e],i={target:r.getAttribute(`Target`),id:r.getAttribute(`Id`),type:r.getAttribute(`Type`)};t.push(i)}return t}function b(e){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=r.getAttribute(`name`);0<=[`Title`,`Designer`,`Description`,`Copyright`,`LicenseTerms`,`Rating`,`CreationDate`,`ModificationDate`].indexOf(i)&&(t[i]=r.textContent)}return t}function S(e){let t={id:e.getAttribute(`id`),basematerials:[]},n=e.querySelectorAll(`base`);for(let e=0;e<n.length;e++){let r=n[e],i=L(r);i.index=e,t.basematerials.push(i)}return t}function O(e){return{id:e.getAttribute(`id`),path:e.getAttribute(`path`),contenttype:e.getAttribute(`contenttype`),tilestyleu:e.getAttribute(`tilestyleu`),tilestylev:e.getAttribute(`tilestylev`),filter:e.getAttribute(`filter`)}}function k(e){let t={id:e.getAttribute(`id`),texid:e.getAttribute(`texid`),displaypropertiesid:e.getAttribute(`displaypropertiesid`)},n=e.querySelectorAll(`tex2coord`),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.getAttribute(`u`),a=t.getAttribute(`v`);r.push(parseFloat(i),parseFloat(a))}return t.uvs=new Float32Array(r),t}function A(e){let t={id:e.getAttribute(`id`),displaypropertiesid:e.getAttribute(`displaypropertiesid`)},n=e.querySelectorAll(`color`),r=[],i=new E;for(let e=0;e<n.length;e++){let t=n[e].getAttribute(`color`);i.setStyle(t.substring(0,7),M),r.push(i.r,i.g,i.b)}return t.colors=new Float32Array(r),t}function j(e){let t=e.children,n={};for(let e=0;e<t.length;e++){let r={type:t[e].nodeName.substring(2)};for(let n=0;n<t[e].attributes.length;n++){let i=t[e].attributes[n];i.specified&&(r[i.name]=i.value)}n[t[e].getAttribute(`identifier`)]=r}return n}function F(e){let t={id:e.getAttribute(`id`),displayname:e.getAttribute(`displayname`)},n=e.children,r={};for(let e=0;e<n.length;e++){let t=n[e];if(t.nodeName===`i:in`||t.nodeName===`i:out`)r[t.nodeName===`i:in`?`inputs`:`outputs`]=j(t);else{let e=t.children,n={op:t.nodeName.substring(2),identifier:t.getAttribute(`identifier`)};for(let t=0;t<e.length;t++)n[e[t].nodeName.substring(2)]=j(e[t]);r[n.identifier]=n}}return t.operations=r,t}function I(e){let t={id:e.getAttribute(`id`)},n=e.querySelectorAll(`pbmetallic`),r=[];for(let e=0;e<n.length;e++){let t=n[e];r.push({name:t.getAttribute(`name`),metallicness:parseFloat(t.getAttribute(`metallicness`)),roughness:parseFloat(t.getAttribute(`roughness`))})}return t.data=r,t}function L(e){let t={};return t.name=e.getAttribute(`name`),t.displaycolor=e.getAttribute(`displaycolor`),t.displaypropertiesid=e.getAttribute(`displaypropertiesid`),t}function R(e){let t={},n=[],r=e.querySelectorAll(`vertices vertex`);for(let e=0;e<r.length;e++){let t=r[e],i=t.getAttribute(`x`),a=t.getAttribute(`y`),o=t.getAttribute(`z`);n.push(parseFloat(i),parseFloat(a),parseFloat(o))}t.vertices=new Float32Array(n);let i=[],a=[],o=e.querySelectorAll(`triangles triangle`);for(let e=0;e<o.length;e++){let t=o[e],n=t.getAttribute(`v1`),r=t.getAttribute(`v2`),s=t.getAttribute(`v3`),c=t.getAttribute(`p1`),l=t.getAttribute(`p2`),u=t.getAttribute(`p3`),d=t.getAttribute(`pid`),f={};f.v1=parseInt(n,10),f.v2=parseInt(r,10),f.v3=parseInt(s,10),a.push(f.v1,f.v2,f.v3),c&&(f.p1=parseInt(c,10)),l&&(f.p2=parseInt(l,10)),u&&(f.p3=parseInt(u,10)),d&&(f.pid=d),0<Object.keys(f).length&&i.push(f)}t.triangleProperties=i,t.triangles=new Uint32Array(a);let s=e.getElementsByTagNameNS(N,`beamlattice`)[0];return s!==void 0&&(t.beamlattice=z(s)),t}function z(e){let t={radius:parseFloat(e.getAttribute(`radius`)),minLength:parseFloat(e.getAttribute(`minlength`)),cap:e.getAttribute(`cap`)||`sphere`,ballMode:e.getAttributeNS(P,`ballmode`)||`none`,ballRadius:parseFloat(e.getAttributeNS(P,`ballradius`)),beams:[],balls:[]},n=e.getAttribute(`clippingmode`)||e.getAttribute(`clipping`);n!==null&&n!==`none`&&console.warn(`THREE.3MFLoader: Beam lattice clipping is not supported. The lattice is rendered unclipped.`);let r=e.getElementsByTagNameNS(N,`beam`);for(let e=0;e<r.length;e++){let n=r[e],i={v1:parseInt(n.getAttribute(`v1`),10),v2:parseInt(n.getAttribute(`v2`),10)},a=n.getAttribute(`r1`),o=n.getAttribute(`r2`);a!==null&&(i.r1=parseFloat(a)),o!==null&&(i.r2=parseFloat(o)),t.beams.push(i)}let i=e.getElementsByTagNameNS(P,`ball`);for(let e=0;e<i.length;e++){let n=i[e],r={vindex:parseInt(n.getAttribute(`vindex`),10)},a=n.getAttribute(`r`);a!==null&&(r.r=parseFloat(a)),t.balls.push(r)}return t}function B(e){let t=[],n=e.querySelectorAll(`component`);for(let e=0;e<n.length;e++){let r=n[e],i=V(r);t.push(i)}return t}function V(e){let t={};t.objectId=e.getAttribute(`objectid`);let n=e.getAttribute(`transform`);return n&&(t.transform=H(n)),t}function H(e){let t=[];e.split(` `).forEach(function(e){t.push(parseFloat(e))});let n=new c;return n.set(t[0],t[3],t[6],t[9],t[1],t[4],t[7],t[10],t[2],t[5],t[8],t[11],0,0,0,1),n}function U(e){let t={type:e.getAttribute(`type`)},n=e.getAttribute(`id`);n&&(t.id=n);let r=e.getAttribute(`pid`);r&&(t.pid=r);let i=e.getAttribute(`pindex`);i&&(t.pindex=i);let a=e.getAttribute(`thumbnail`);a&&(t.thumbnail=a);let o=e.getAttribute(`partnumber`);o&&(t.partnumber=o);let s=e.getAttribute(`name`);s&&(t.name=s);let c=e.querySelector(`mesh`);c&&(t.mesh=R(c));let l=e.querySelector(`components`);return l&&(t.components=B(l)),t}function W(e){let t={};t.basematerials={};let n=e.querySelectorAll(`basematerials`);for(let e=0;e<n.length;e++){let r=n[e],i=S(r);t.basematerials[i.id]=i}t.texture2d={};let r=e.querySelectorAll(`texture2d`);for(let e=0;e<r.length;e++){let n=r[e],i=O(n);t.texture2d[i.id]=i}t.colorgroup={};let i=e.querySelectorAll(`colorgroup`);for(let e=0;e<i.length;e++){let n=i[e],r=A(n);t.colorgroup[r.id]=r}let a=e.querySelectorAll(`implicitfunction`);a.length>0&&(t.implicitfunction={});for(let e=0;e<a.length;e++){let n=a[e],r=F(n);t.implicitfunction[r.id]=r}t.pbmetallicdisplayproperties={};let o=e.querySelectorAll(`pbmetallicdisplayproperties`);for(let e=0;e<o.length;e++){let n=o[e],r=I(n);t.pbmetallicdisplayproperties[r.id]=r}t.texture2dgroup={};let s=e.querySelectorAll(`texture2dgroup`);for(let e=0;e<s.length;e++){let n=s[e],r=k(n);t.texture2dgroup[r.id]=r}t.object={};let c=e.querySelectorAll(`object`);for(let e=0;e<c.length;e++){let n=c[e],r=U(n);t.object[r.id]=r}return t}function G(e){let t=[],n=e.querySelectorAll(`item`);for(let e=0;e<n.length;e++){let r=n[e],i={objectId:r.getAttribute(`objectid`)},a=r.getAttribute(`transform`);a&&(i.transform=H(a)),t.push(i)}return t}function K(e){let t={unit:e.getAttribute(`unit`)||`millimeter`},n=e.querySelectorAll(`metadata`);n&&(t.metadata=b(n));let r=e.querySelector(`resources`);r&&(t.resources=W(r));let i=e.querySelector(`build`);return i&&(t.build=G(i)),t}function q(e,t,i,a){let o=e.texid,c=i.resources.texture2d[o];if(c){let e=a[c.path],t=c.contenttype,i=new Blob([e],{type:t}),o=URL.createObjectURL(i),l=f.load(o,function(){URL.revokeObjectURL(o)});switch(l.colorSpace=M,c.tilestyleu){case`wrap`:l.wrapS=h;break;case`mirror`:l.wrapS=s;break;case`none`:case`clamp`:l.wrapS=_;break;default:l.wrapS=h}switch(c.tilestylev){case`wrap`:l.wrapT=h;break;case`mirror`:l.wrapT=s;break;case`none`:case`clamp`:l.wrapT=_;break;default:l.wrapT=h}switch(c.filter){case`auto`:l.magFilter=r,l.minFilter=n;break;case`linear`:l.magFilter=r,l.minFilter=r,l.generateMipmaps=!1;break;case`nearest`:l.magFilter=u,l.minFilter=u,l.generateMipmaps=!1;break;default:l.magFilter=r,l.minFilter=n}return l}return null}function J(e,t,n,r,i,a,o){let s=o.pindex,c={};for(let e=0,n=t.length;e<n;e++){let n=t[e],r=n.p1===void 0?s:n.p1;c[r]===void 0&&(c[r]=[]),c[r].push(n)}let u=Object.keys(c),d=[];for(let t=0,s=u.length;t<s;t++){let s=u[t],f=c[s],p=e.basematerials[s],m=$(p,r,i,a,o,se),h=new T,g=[],_=n.vertices;for(let e=0,t=f.length;e<t;e++){let t=f[e];g.push(_[t.v1*3+0]),g.push(_[t.v1*3+1]),g.push(_[t.v1*3+2]),g.push(_[t.v2*3+0]),g.push(_[t.v2*3+1]),g.push(_[t.v2*3+2]),g.push(_[t.v3*3+0]),g.push(_[t.v3*3+1]),g.push(_[t.v3*3+2])}h.setAttribute(`position`,new y(g,3));let v=new l(h,m);d.push(v)}return d}function Y(e,t,n,r,a,o,s){let c=new T,u=[],d=[],f=n.vertices,p=e.uvs;for(let e=0,n=t.length;e<n;e++){let n=t[e];u.push(f[n.v1*3+0]),u.push(f[n.v1*3+1]),u.push(f[n.v1*3+2]),u.push(f[n.v2*3+0]),u.push(f[n.v2*3+1]),u.push(f[n.v2*3+2]),u.push(f[n.v3*3+0]),u.push(f[n.v3*3+1]),u.push(f[n.v3*3+2]),d.push(p[n.p1*2+0]),d.push(p[n.p1*2+1]),d.push(p[n.p2*2+0]),d.push(p[n.p2*2+1]),d.push(p[n.p3*2+0]),d.push(p[n.p3*2+1])}c.setAttribute(`position`,new y(u,3)),c.setAttribute(`uv`,new y(d,2));let m=$(e,r,a,o,s,q),h=new i({map:m,flatShading:!0});return new l(c,h)}function X(e,t,n,r){let a=new T,o=[],s=[],c=n.vertices,u=e.colors;for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.v1,a=n.v2,l=n.v3;o.push(c[i*3+0]),o.push(c[i*3+1]),o.push(c[i*3+2]),o.push(c[a*3+0]),o.push(c[a*3+1]),o.push(c[a*3+2]),o.push(c[l*3+0]),o.push(c[l*3+1]),o.push(c[l*3+2]);let d=n.p1===void 0?r.pindex:n.p1,f=n.p2===void 0?d:n.p2,p=n.p3===void 0?d:n.p3;s.push(u[d*3+0]),s.push(u[d*3+1]),s.push(u[d*3+2]),s.push(u[f*3+0]),s.push(u[f*3+1]),s.push(u[f*3+2]),s.push(u[p*3+0]),s.push(u[p*3+1]),s.push(u[p*3+2])}a.setAttribute(`position`,new y(o,3)),a.setAttribute(`color`,new y(s,3));let d=new i({vertexColors:!0,flatShading:!0});return new l(a,d)}function Z(e){let t=new T;t.setIndex(new g(e.triangles,1)),t.setAttribute(`position`,new g(e.vertices,3));let n=new i({name:C.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new l(t,n)}function Q(e){let t=e.beamlattice,n=e.vertices,r=[],o=new w,s=new w,u=new w,d=new w(0,1,0),f=new a,p=new c,m=t.beams,h=t.cap!==`butt`,g=/* @__PURE__ */ new Map;for(let e=0;e<m.length;e++){let i=m[e];o.fromArray(n,i.v1*3),s.fromArray(n,i.v2*3);let a=o.distanceTo(s);if(a<t.minLength)continue;let c=i.r1===void 0?t.radius:i.r1,l=i.r2===void 0?c:i.r2,_=new v(l,c,a,8,1,h);u.subVectors(s,o).divideScalar(a),f.setFromUnitVectors(d,u),p.makeRotationFromQuaternion(f),p.setPosition(o.add(s).multiplyScalar(.5)),_.applyMatrix4(p),r.push(_),h&&(g.set(i.v1,Math.max(c,g.get(i.v1)||0)),g.set(i.v2,Math.max(l,g.get(i.v2)||0))),t.ballMode===`all`&&(g.set(i.v1,Math.max(t.ballRadius,g.get(i.v1)||0)),g.set(i.v2,Math.max(t.ballRadius,g.get(i.v2)||0)))}let _=t.balls;for(let e=0;e<_.length;e++){let n=_[e],r=n.r===void 0?t.ballRadius:n.r;g.set(n.vindex,Math.max(r,g.get(n.vindex)||0))}for(let[e,t]of g){let i=new ee(t,8,6);o.fromArray(n,e*3),i.translate(o.x,o.y,o.z),r.push(i)}let y=te(r),b=new i({name:C.DEFAULT_MATERIAL_NAME,color:16777215});return new l(y,b)}function ne(e,t,n,r,i,a){let o=Object.keys(e),s=[];for(let c=0,l=o.length;c<l;c++){let l=o[c],u=e[l];switch(re(l,r)){case`material`:let e=r.resources.basematerials[l],o=J(e,u,t,n,r,i,a);for(let e=0,t=o.length;e<t;e++)s.push(o[e]);break;case`texture`:let c=r.resources.texture2dgroup[l];s.push(Y(c,u,t,n,r,i,a));break;case`vertexColors`:let d=r.resources.colorgroup[l];s.push(X(d,u,t,a));break;case`default`:s.push(Z(t));break;default:console.error(`THREE.3MFLoader: Unsupported resource type.`)}}if(a.name)for(let e=0;e<s.length;e++)s[e].name=a.name;return s}function re(e,t){if(t.resources.texture2dgroup[e]!==void 0)return`texture`;if(t.resources.basematerials[e]!==void 0)return`material`;if(t.resources.colorgroup[e]!==void 0)return`vertexColors`;if(e==="default")return`default`}function ie(e,t){let n={},r=e.triangleProperties,i=t.pid;for(let e=0,t=r.length;e<t;e++){let t=r[e],a=t.pid===void 0?i:t.pid;a===void 0&&(a=`default`),n[a]===void 0&&(n[a]=[]),n[a].push(t)}return n}function ae(e,t,n,r,i){let a=new D,o=ne(ie(e,i),e,t,n,r,i);if(e.beamlattice!==void 0){let t=Q(e);i.name&&(t.name=i.name),o.push(t)}for(let e=0,t=o.length;e<t;e++)a.add(o[e]);return a}function oe(e,t,n){if(!e)return;let r=[],i=Object.keys(e);for(let e=0;e<i.length;e++){let t=i[e];for(let e=0;e<d.availableExtensions.length;e++){let n=d.availableExtensions[e];n.ns===t&&r.push(n)}}for(let i=0;i<r.length;i++){let a=r[i];a.apply(n,e[a.ns],t)}}function $(e,t,n,r,i,a){return e.build===void 0&&(e.build=a(e,t,n,r,i)),e.build}function se(e,t,n){let r,a=e.displaypropertiesid,s=n.resources.pbmetallicdisplayproperties;if(a!==null&&s[a]!==void 0){let t=s[a].data[e.index];r=new o({flatShading:!0,roughness:t.roughness,metalness:t.metallicness})}else r=new i({flatShading:!0});r.name=e.name;let c=e.displaycolor,l=c.substring(0,7);return r.color.setStyle(l,M),c.length===9&&(r.opacity=parseInt(c.charAt(7)+c.charAt(8),16)/255),r}function ce(e,t,n,r){let i=new D;for(let a=0;a<e.length;a++){let o=e[a],s=t[o.objectId];s===void 0&&(le(o.objectId,t,n,r),s=t[o.objectId]);let c=s.clone(),l=o.transform;l&&c.applyMatrix4(l),i.add(c)}return i}function le(e,t,n,r){let i=n.resources.object[e];if(i.mesh){let e=i.mesh,a=n.extensions,o=n.xml;oe(a,e,o),t[i.id]=$(e,t,n,r,i,ae)}else{let e=i.components;t[i.id]=$(e,t,n,r,i,ce)}i.name&&(t[i.id].name=i.name),n.resources.implicitfunction&&console.warn(`THREE.ThreeMFLoader: Implicit Functions are implemented in data-only.`,n.resources.implicitfunction)}function ue(e){let t=e.model,n=e.modelRels,r={},i=Object.keys(t),a={};if(n)for(let t=0,r=n.length;t<r;t++){let r=n[t],i=r.target.substring(1);e.texture[i]&&(a[r.target]=e.texture[i])}for(let e=0;e<i.length;e++){let n=t[i[e]],o=Object.keys(n.resources.object);for(let e=0;e<o.length;e++){let t=o[e];le(t,r,n,a)}}return r}function de(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.target.split(`.`).pop().toLowerCase()===`model`)return n}}function fe(e,t){let n=new D,r=de(t.rels),i=t.model[r.target.substring(1)].build;for(let t=0;t<i.length;t++){let r=i[t],a=e[r.objectId].clone(),o=r.transform;o&&a.applyMatrix4(o),n.add(a)}return n}let pe=p(e);return fe(ue(pe),pe)}addExtension(e){this.availableExtensions.push(e)}},I=/^[og]\s*(.+)?/,L=/^mtllib /,R=/^usemtl /,z=/^usemap /,B=/\s+/,V=new w,H=new w,U=new w,W=new w,G=new w,K=new E;function q(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;V.fromArray(r,e),H.fromArray(r,t),U.fromArray(r,n),G.subVectors(U,H),W.subVectors(V,H),G.cross(W),G.normalize(),i.push(G.x,G.y,G.z),i.push(G.x,G.y,G.z),i.push(G.x,G.y,G.z)},addColor:function(e,t,n){let r=this.colors,i=this.object.geometry.colors;r[e]!==void 0&&i.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&i.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){let r=this.uvs,i=this.object.geometry.uvs;i.push(r[e+0],r[e+1]),i.push(r[t+0],r[t+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,r,i,a,o,s,c){let l=this.vertices.length,u=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),f=this.parseVertexIndex(n,l);if(this.addVertex(u,d,f),this.addColor(u,d,f),o!==void 0&&o!==``){let e=this.normals.length;u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(s,e),f=this.parseNormalIndex(c,e),this.addNormal(u,d,f)}else this.addFaceNormal(u,d,f);if(r!==void 0&&r!==``){let e=this.uvs.length;u=this.parseUVIndex(r,e),d=this.parseUVIndex(i,e),f=this.parseUVIndex(a,e),this.addUV(u,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=`Points`;let t=this.vertices.length;for(let n=0,r=e.length;n<r;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type=`Line`;let n=this.vertices.length,r=this.uvs.length;for(let t=0,r=e.length;t<r;t++)this.addVertexLine(this.parseVertexIndex(e[t],n));for(let e=0,n=t.length;e<n;e++)this.addUVLine(this.parseUVIndex(t[e],r))}};return e.startObject(``,!1),e}var J=class extends C{constructor(e){super(e),this.materials=null}load(e,t,n,r){let i=this,a=new b(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}setMaterials(e){return this.materials=e,this}parse(e){let t=new q;e.indexOf(`\r
|
|
2
|
+
`)!==-1&&(e=e.replace(/\r\n/g,`
|
|
3
|
+
`)),e.indexOf(`\\
|
|
4
|
+
`)!==-1&&(e=e.replace(/\\\n/g,``));let n=e.split(`
|
|
5
|
+
`),r=[];for(let e=0,i=n.length;e<i;e++){let i=n[e].trimStart();if(i.length===0)continue;let a=i.charAt(0);if(a!==`#`){if(a===`v`){let e=i.split(B);switch(e[0]){case`v`:t.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?(K.setRGB(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6]),m),t.colors.push(K.r,K.g,K.b)):t.colors.push(void 0,void 0,void 0);break;case`vn`:t.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:t.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if(a===`f`){let e=i.slice(1).trim().split(B),n=[];for(let t=0,r=e.length;t<r;t++){let r=e[t];if(r.length>0){let e=r.split(`/`);n.push(e)}}let r=n[0];for(let e=1,i=n.length-1;e<i;e++){let i=n[e],a=n[e+1];t.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if(a===`l`){let e=i.substring(1).trim().split(` `),n=[],r=[];if(i.indexOf(`/`)===-1)n=e;else for(let t=0,i=e.length;t<i;t++){let i=e[t].split(`/`);i[0]!==``&&n.push(i[0]),i[1]!==``&&r.push(i[1])}t.addLineGeometry(n,r)}else if(a===`p`){let e=i.slice(1).trim().split(` `);t.addPointGeometry(e)}else if((r=I.exec(i))!==null){let e=(` `+r[0].slice(1).trim()).slice(1);t.startObject(e)}else if(R.test(i))t.object.startMaterial(i.substring(7).trim(),t.materialLibraries);else if(L.test(i))t.materialLibraries.push(i.substring(7).trim());else if(z.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(r=i.split(` `),r.length>1){let e=r[1].trim().toLowerCase();t.object.smooth=e!==`0`&&e!==`off`}else t.object.smooth=!0;let e=t.object.currentMaterial();e&&(e.smooth=t.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}}t.finalize();let a=new D;if(a.materialLibraries=[].concat(t.materialLibraries),t.objects.length!==1||t.objects[0].geometry.vertices.length!==0)for(let e=0,n=t.objects.length;e<n;e++){let n=t.objects[e],r=n.geometry,o=n.materials,s=r.type===`Line`,c=r.type===`Points`,u=!1;if(r.vertices.length===0)continue;let m=new T;m.setAttribute(`position`,new y(r.vertices,3)),r.normals.length>0&&m.setAttribute(`normal`,new y(r.normals,3)),r.colors.length>0&&(u=!0,m.setAttribute(`color`,new y(r.colors,3))),r.hasUVIndices===!0&&m.setAttribute(`uv`,new y(r.uvs,2));let h=[];for(let e=0,n=o.length;e<n;e++){let n=o[e],r=n.name+`_`+n.smooth+`_`+u,a=t.materials[r];if(this.materials!==null){if(a=this.materials.create(n.name),s&&a&&!(a instanceof O)){let e=new O;S.prototype.copy.call(e,a),e.color.copy(a.color),a=e}else if(c&&a&&!(a instanceof p)){let e=new p({size:10,sizeAttenuation:!1});S.prototype.copy.call(e,a),e.color.copy(a.color),e.map=a.map,a=e}}a===void 0&&(a=s?new O:c?new p({size:1,sizeAttenuation:!1}):new i,a.name=n.name,a.flatShading=!n.smooth,a.vertexColors=u,t.materials[r]=a),h.push(a)}let g;if(h.length>1){for(let e=0,t=o.length;e<t;e++){let t=o[e];m.addGroup(t.groupStart,t.groupCount,e)}g=s?new d(m,h):c?new f(m,h):new l(m,h)}else g=s?new d(m,h[0]):c?new f(m,h[0]):new l(m,h[0]);g.name=n.name,a.add(g)}else if(t.vertices.length>0){let e=new p({size:1,sizeAttenuation:!1}),n=new T;n.setAttribute(`position`,new y(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(n.setAttribute(`color`,new y(t.colors,3)),e.vertexColors=!0);let r=new f(n,e);a.add(r)}return a}},Y=3e7,X=new o({color:`#cbccd0`,roughness:.72}),Z=Math.PI/6,Q=3e5;async function ne(t,n){if(n===`stl`)return new l(new k().parse(await t.arrayBuffer()));if(n===`3mf`){let n=await t.arrayBuffer(),r=e(new Uint8Array(n));if(r>Y)throw Object.assign(/* @__PURE__ */ Error(`too large to preview`),{xml:r});return new F().parse(n)}return new J().parse(await t.text())}function re(e){let t=[];e.traverse(e=>{e.isMesh&&t.push(e)});let n=e=>(e.index?e.index.count:e.attributes.position.count)/3,r=t.reduce((e,t)=>e+n(t.geometry),0);for(let e of t){if(e.material=X,r>Q)continue;let t=j(e.geometry,Z);t!==e.geometry&&e.geometry.dispose(),e.geometry=t}return r}export{ne as n,re as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));export{s as n,l as r,o as t};
|