slicer-studio 0.7.0 → 0.9.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/README.md +8 -4
- package/dist/chunks/ModelPreview-CjA0mplM.js +61 -0
- package/dist/chunks/PlateEditor-pZVMpN8B.js +1 -0
- package/dist/chunks/Zoom-D5qB1eH6.js +1 -0
- package/dist/chunks/files-YWgqYMU_.js +1 -0
- package/dist/chunks/{model-read-F5cM3GZJ.js → model-read-TEBI4aDG.js} +1 -1
- package/dist/chunks/{plate-geometry-Dd9vKDEP.js → plate-geometry-B8juLONh.js} +1 -1
- package/dist/chunks/{plate-mesh-BoEG27Tx.js → plate-mesh-DKFeiUUC.js} +1 -1
- package/dist/chunks/{thumbnail-RKI9IqqD.js → thumbnail-CTbhmZcq.js} +1 -1
- package/dist/chunks/tool-button-BSd3e5SL.js +8 -0
- package/dist/chunks/triangle-alert-uvtJzBCN.js +1 -0
- package/dist/slicer-studio.js +19 -22
- package/package.json +1 -1
- package/dist/chunks/ModelPreview-b3D28pKp.js +0 -61
- package/dist/chunks/PlateEditor-BbouIi-O.js +0 -1
- package/dist/chunks/files-BZtizmc1.js +0 -1
- package/dist/chunks/tip-BR1chAbl.js +0 -5
- package/dist/chunks/triangle-alert-5i_bibCW.js +0 -1
- package/dist/chunks/view-Djv_nmDb.js +0 -1
package/README.md
CHANGED
|
@@ -306,8 +306,9 @@ The backend must:
|
|
|
306
306
|
`height`;
|
|
307
307
|
- **answer like any quote,** with `stats` for the whole plate.
|
|
308
308
|
|
|
309
|
-
A plate has up to 50 objects and 1,000,000 triangles, copies included.
|
|
310
|
-
so each has a plate of its own and is sent as it
|
|
309
|
+
A plate has up to 50 objects and 1,000,000 triangles, copies included. Objects that staff move entirely off the bed
|
|
310
|
+
aren't in the 3MF. STEP and IGES files can't be read in the browser, so each has a plate of its own and is sent as it
|
|
311
|
+
is, without `plate`, for the backend to place.
|
|
311
312
|
|
|
312
313
|
### Headless OrcaSlicer
|
|
313
314
|
|
|
@@ -993,7 +994,8 @@ await studio.open([
|
|
|
993
994
|
- **Limits:** the same as a drop, 10 files on the plates and 50 MB each, up to 500,000 triangles a model, 50 objects and
|
|
994
995
|
1,000,000 triangles a plate, and 10 plates. What goes over shows the same message as a drop, and the rest still goes on.
|
|
995
996
|
- **When it works:** only in `advanced` mode. In `quote` mode, or if the mode changes while it waits, it rejects with an
|
|
996
|
-
`Error`.
|
|
997
|
+
`Error`. Changing `api-url` starts the studio afresh: a call made after that waits for it, and one it was still
|
|
998
|
+
placing rejects, so open those files again. It waits for the studio to be ready, including your printer list and each printer's bed, so you can call it
|
|
997
999
|
straight after `whenDefined`. If your [`advanced`](#staff-access) servers turn the visitor away, it rejects.
|
|
998
1000
|
- Calls run one after another, in the order made. Anything but a list rejects with a `TypeError`.
|
|
999
1001
|
|
|
@@ -1304,7 +1306,9 @@ from the toast library. They are harmless, because the studio's styles don't dep
|
|
|
1304
1306
|
- **Files:** STL, 3MF, OBJ, STEP and IGES, up to 10 at once and 50 MB each. STEP and IGES are priced but have no 3D
|
|
1305
1307
|
preview. If your backend refuses a file, its message shows on that file's card.
|
|
1306
1308
|
- **Plates in Advanced:** up to 10 plates, 50 objects on a plate and 1,000,000 triangles on a plate, copies included.
|
|
1307
|
-
|
|
1309
|
+
An object moved entirely off the bed is left out of the slice, as OrcaSlicer leaves out what is off its plate: it
|
|
1310
|
+
shows faded, and staff can park objects there. One partly over the edge shows red and stops that plate from slicing,
|
|
1311
|
+
and so does a plate with nothing on its bed. Objects that overlap show amber.
|
|
1308
1312
|
- **Size:** about 215 kB gzipped to start, with the 3D view (about 250 kB) and the fonts (about 240 kB) loading after. The
|
|
1309
1313
|
websocket client (about 18 kB) loads with the first quote.
|
|
1310
1314
|
- **Server rendering:** importing the package on a server is safe, and does nothing. The studio has no server-rendered
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{n as r,s as i,t as a}from"./tool-button-BSd3e5SL.js";import{n as o,r as s,t as c}from"./triangle-alert-uvtJzBCN.js";import{a as l,i as u,n as d,o as f,r as p,t as m}from"./Zoom-D5qB1eH6.js";import{i as h}from"./files-YWgqYMU_.js";import{Ar as g,E as _,Ga as v,L as y,Lt as b,Qi as x,U as S,j as C,qa as w,qt as T,ro as E,ta as ee,tr as D}from"./three.core-BHZv2AuD.js";import{a as O,c as k,i as A,l as j,n as M,o as N,r as P,t as te,u as F}from"./useThemeColors-B8cttUaE.js";import{t as I}from"./bounds-C11tinGE.js";import{n as L,t as R}from"./model-read-TEBI4aDG.js";var z={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};z.node;var B=i(z),V={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]};V.node;var H=i(V),U={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};U.node;var W=i(U);function G(e,t,n,r){var i=class extends ee{constructor(i){super({vertexShader:t,fragmentShader:n,...i});for(let t in e)this.uniforms[t]=new v(e[t]),Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(e){this.uniforms[t].value=e}});this.uniforms=w.clone(this.uniforms),r?.(this)}};return i.key=D.generateUUID(),i}var K=/* @__PURE__ */ parseInt(`186`.replace(/\D+/g,``)),q=/* @__PURE__ */ e(t()),J=/* @__PURE__ */ G({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:/* @__PURE__ */ new S,sectionColor:/* @__PURE__ */ new S,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:/* @__PURE__ */ new E,worldPlanePosition:/* @__PURE__ */ new E},`
|
|
2
|
+
varying vec3 localPosition;
|
|
3
|
+
varying vec4 worldPosition;
|
|
4
|
+
|
|
5
|
+
uniform vec3 worldCamProjPosition;
|
|
6
|
+
uniform vec3 worldPlanePosition;
|
|
7
|
+
uniform float fadeDistance;
|
|
8
|
+
uniform bool infiniteGrid;
|
|
9
|
+
uniform bool followCamera;
|
|
10
|
+
|
|
11
|
+
void main() {
|
|
12
|
+
localPosition = position.xzy;
|
|
13
|
+
if (infiniteGrid) localPosition *= 1.0 + fadeDistance;
|
|
14
|
+
|
|
15
|
+
worldPosition = modelMatrix * vec4(localPosition, 1.0);
|
|
16
|
+
if (followCamera) {
|
|
17
|
+
worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);
|
|
18
|
+
localPosition = (inverse(modelMatrix) * worldPosition).xyz;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
|
22
|
+
}
|
|
23
|
+
`,`
|
|
24
|
+
varying vec3 localPosition;
|
|
25
|
+
varying vec4 worldPosition;
|
|
26
|
+
|
|
27
|
+
uniform vec3 worldCamProjPosition;
|
|
28
|
+
uniform float cellSize;
|
|
29
|
+
uniform float sectionSize;
|
|
30
|
+
uniform vec3 cellColor;
|
|
31
|
+
uniform vec3 sectionColor;
|
|
32
|
+
uniform float fadeDistance;
|
|
33
|
+
uniform float fadeStrength;
|
|
34
|
+
uniform float fadeFrom;
|
|
35
|
+
uniform float cellThickness;
|
|
36
|
+
uniform float sectionThickness;
|
|
37
|
+
|
|
38
|
+
float getGrid(float size, float thickness) {
|
|
39
|
+
vec2 r = localPosition.xz / size;
|
|
40
|
+
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
|
41
|
+
float line = min(grid.x, grid.y) + 1.0 - thickness;
|
|
42
|
+
return 1.0 - min(line, 1.0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void main() {
|
|
46
|
+
float g1 = getGrid(cellSize, cellThickness);
|
|
47
|
+
float g2 = getGrid(sectionSize, sectionThickness);
|
|
48
|
+
|
|
49
|
+
vec3 from = worldCamProjPosition*vec3(fadeFrom);
|
|
50
|
+
float dist = distance(from, worldPosition.xyz);
|
|
51
|
+
float d = 1.0 - min(dist / fadeDistance, 1.0);
|
|
52
|
+
vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));
|
|
53
|
+
|
|
54
|
+
gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));
|
|
55
|
+
gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
|
|
56
|
+
if (gl_FragColor.a <= 0.0) discard;
|
|
57
|
+
|
|
58
|
+
#include <tonemapping_fragment>
|
|
59
|
+
#include <${K>=154?`colorspace_fragment`:`encodings_fragment`}>
|
|
60
|
+
}
|
|
61
|
+
`),Y=/* @__PURE__ */ q.forwardRef(({args:e,cellColor:t=`#000000`,sectionColor:n=`#2080ff`,cellSize:r=.5,sectionSize:i=1,followCamera:a=!1,infiniteGrid:o=!1,fadeDistance:s=100,fadeStrength:c=1,fadeFrom:l=1,cellThickness:u=.5,sectionThickness:d=1,side:f=1,...p},m)=>{k({GridMaterial:J});let h=q.useRef(null);q.useImperativeHandle(m,()=>h.current,[]);let _=new g,v=new E(0,1,0),y=new E(0,0,0);j(e=>{_.setFromNormalAndCoplanarPoint(v,y).applyMatrix4(h.current.matrixWorld);let t=h.current.material,n=t.uniforms.worldCamProjPosition,r=t.uniforms.worldPlanePosition;_.projectPoint(e.camera.position,n.value),r.value.set(0,0,0).applyMatrix4(h.current.matrixWorld)});let b={cellSize:r,sectionSize:i,cellColor:t,sectionColor:n,cellThickness:u,sectionThickness:d},x={fadeDistance:s,fadeStrength:c,fadeFrom:l,infiniteGrid:o,followCamera:a};return/*#__PURE__*/ q.createElement(`mesh`,O({ref:h,frustumCulled:!1},p),/*#__PURE__*/ q.createElement(`gridMaterial`,O({transparent:!0,"extensions-derivatives":!0,side:f},b,x)),/*#__PURE__*/ q.createElement(`planeGeometry`,{args:e}))}),X=n(),Z=16;function ne(e,t){let n=document.createElement(`canvas`),r=n.getContext(`2d`),i=`500 52px "Archivo Variable", system-ui, sans-serif`;r.font=i,n.width=Math.ceil(r.measureText(e).width)+8,n.height=64,r.font=i,r.fillStyle=t,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(e,n.width/2,n.height/2);let a=new y(n);return a.colorSpace=x,{texture:a,aspect:n.width/n.height}}function re({text:e,at:t,color:n}){let r=F(e=>e.size.height),i=F(e=>e.camera.fov),{texture:a,aspect:o}=(0,q.useMemo)(()=>ne(e,n),[e,n]);(0,q.useEffect)(()=>()=>a.dispose(),[a]);let s=Z/r*2*Math.tan(D.degToRad(i/2));return/* @__PURE__ */ (0,X.jsx)(`sprite`,{position:t,scale:[s*o,s,1],renderOrder:3,children:/* @__PURE__ */ (0,X.jsx)(`spriteMaterial`,{map:a,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1})})}function ie({bounds:e,size:t,color:n}){let r=Math.max(6,.06*Math.max(...t)),i=(0,q.useMemo)(()=>d(e,r),[e,r]),a=(0,q.useMemo)(()=>{let e=i.flatMap(e=>[e.from,e.to,...e.ticks.flat()]).flat();return new C().setAttribute(`position`,new b(e,3))},[i]);return(0,q.useEffect)(()=>()=>a.dispose(),[a]),/* @__PURE__ */ (0,X.jsxs)(`group`,{children:[/* @__PURE__ */ (0,X.jsx)(`lineSegments`,{geometry:a,renderOrder:2,children:/* @__PURE__ */ (0,X.jsx)(`lineBasicMaterial`,{color:n,transparent:!0,depthTest:!1})}),i.map(e=>/* @__PURE__ */ (0,X.jsx)(re,{text:e.label,at:e.at,color:n},e.axis))]})}var Q=5e5;function ae(e,t){let n=new T;n.rotation.set(...t.map(D.degToRad),`ZYX`),n.add(e.clone()),n.updateMatrixWorld(!0);let r=new _().setFromObject(n),i=new E(-(r.min.x+r.max.x)/2,-(r.min.y+r.max.y)/2,-r.min.z),a=new T;return a.position.copy(i),a.add(n),r.translate(i),{root:a,bounds:{min:r.min.toArray(),max:r.max.toArray()},size:r.getSize(new E).toArray()}}function $({icon:e,tone:t=`text-muted`,children:n}){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:`absolute inset-0 grid place-items-center p-6`,children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`max-w-sm text-center`,children:[/* @__PURE__ */ (0,X.jsx)(e,{className:`mx-auto size-7 ${t}`,strokeWidth:1.6,"aria-hidden":!0}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-2.5 text-body text-muted`,children:n})]})})}function oe({placed:e,tooMany:t,customer:n}){let{root:i,bounds:o,size:c}=e,d=te(),h=(0,q.useRef)(null),[g,_]=(0,q.useState)({view:`iso`,key:0}),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!0),[S,C]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=h.current.getRootNode(),t=()=>C(e.fullscreenElement===h.current);return document.addEventListener(`fullscreenchange`,t),()=>document.removeEventListener(`fullscreenchange`,t)},[]);let w=Math.max(...c,100),T=I({meta:{},bounds:o});return/* @__PURE__ */ (0,X.jsxs)(`div`,{ref:h,className:`@container absolute inset-0 bg-viewer`,children:[/* @__PURE__ */ (0,X.jsxs)(N,{flat:!0,frameloop:`demand`,dpr:[1,2],camera:{fov:35,near:.1,far:1e4,up:[0,0,1],position:[0,-300,200]},children:[/* @__PURE__ */ (0,X.jsx)(`color`,{attach:`background`,args:[d.background]}),/* @__PURE__ */ (0,X.jsx)(`hemisphereLight`,{args:[`#ffffff`,`#b0b1b6`,1.5],position:[0,0,1]}),/* @__PURE__ */ (0,X.jsx)(`directionalLight`,{position:[-150,-300,400],intensity:1.1}),/* @__PURE__ */ (0,X.jsx)(`directionalLight`,{position:[250,120,120],intensity:.35}),/* @__PURE__ */ (0,X.jsx)(Y,{position:[0,0,-w*.002],rotation:[Math.PI/2,0,0],infiniteGrid:!0,fadeFrom:0,fadeDistance:w*6,fadeStrength:2,cellSize:10,cellThickness:.6,cellColor:d.rule,sectionSize:50,sectionThickness:.9,sectionColor:d.grid,side:2}),/* @__PURE__ */ (0,X.jsx)(P,{outline:T,colors:d}),/* @__PURE__ */ (0,X.jsx)(`primitive`,{object:i}),b&&/* @__PURE__ */ (0,X.jsx)(ie,{bounds:o,size:c,color:d.muted}),/* @__PURE__ */ (0,X.jsx)(A,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,X.jsx)(M,{bounds:o,far:20*w,view:g.view,fitKey:g.key}),/* @__PURE__ */ (0,X.jsx)(m,{request:v}),/* @__PURE__ */ (0,X.jsx)(p,{})]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex flex-wrap items-start justify-between gap-2 [&>*]:pointer-events-auto`,children:/* @__PURE__ */ (0,X.jsxs)(r,{className:`ml-auto`,children:[/* @__PURE__ */ (0,X.jsx)(a,{label:`Centre the model`,onClick:()=>_(e=>({view:`current`,key:e.key+1})),children:/* @__PURE__ */ (0,X.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,X.jsx)(a,{label:`Zoom in`,onClick:()=>y({factor:.8}),children:/* @__PURE__ */ (0,X.jsx)(l,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,X.jsx)(a,{label:`Zoom out`,onClick:()=>y({factor:1.25}),children:/* @__PURE__ */ (0,X.jsx)(u,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,X.jsx)(a,{label:`Reset view`,onClick:()=>_(e=>({view:`iso`,key:e.key+1})),children:/* @__PURE__ */ (0,X.jsx)(W,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,X.jsx)(a,{label:b?`Hide size lines`:`Show size lines`,pressed:b,onClick:()=>x(e=>!e),children:/* @__PURE__ */ (0,X.jsx)(s,{className:`size-4`,"aria-hidden":!0})}),document.fullscreenEnabled&&/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,X.jsx)(a,{label:S?`Leave fullscreen`:`Fullscreen`,onClick:()=>(S?document.exitFullscreen():h.current.requestFullscreen()).catch(()=>{}),children:S?/* @__PURE__ */ (0,X.jsx)(H,{className:`size-4`,"aria-hidden":!0}):/* @__PURE__ */ (0,X.jsx)(B,{className:`size-4`,"aria-hidden":!0})})]})]})})]})}function se({file:e,rot:t=[0,0,0],customer:n=!1}){let r=n?`The price still works`:`Slicing still works`,i=h(e.name).format,[a,l]=(0,q.useState)({status:`loading`});(0,q.useEffect)(()=>{if(i===`step`||i===`iges`)return;let t=!0,n=null;l({status:`loading`});let r=setTimeout(()=>{L(e,i).then(e=>{n=e,t&&l({status:`ready`,object:e,triangles:R(e)})}).catch(e=>{t&&l(e.xml?{status:`large`,xml:e.xml}:{status:`error`})})},30);return()=>{t=!1,clearTimeout(r),n?.traverse(e=>e.geometry?.dispose())}},[e,i]);let[u,d,f]=t,p=(0,q.useMemo)(()=>a.object?ae(a.object,[u,d,f]):null,[a.object,u,d,f]);return a.status===`ready`&&i!==`step`&&i!==`iges`?/* @__PURE__ */ (0,X.jsx)(oe,{placed:p,tooMany:a.triangles>Q,customer:n}):i===`step`||i===`iges`?/* @__PURE__ */ (0,X.jsx)($,{icon:s,children:n?`${i.toUpperCase()} files can’t be previewed here. The price still works.`:`${i.toUpperCase()} files are read on the server, so this one shows once it is sliced.`}):a.status===`loading`?/* @__PURE__ */ (0,X.jsxs)($,{icon:o,tone:`text-muted animate-spin`,children:[`Loading `,e.name]}):a.status===`large`?/* @__PURE__ */ (0,X.jsxs)($,{icon:s,children:[e.name,` is too detailed to preview (about `,(Math.round(a.xml/85/1e4)*1e4).toLocaleString(`en`),` triangles; the preview takes `,Q.toLocaleString(`en`),`). `,r,`.`]}):/* @__PURE__ */ (0,X.jsxs)($,{icon:c,tone:`text-warn`,children:[`No preview for `,e.name,`. `,n?`It can still be priced`:`It can still be sliced`,`, unless the server can’t read it either.`]})}export{se as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{n as r,s as i,t as a}from"./tool-button-BSd3e5SL.js";import{a as o,i as s,o as c,r as l,t as u}from"./Zoom-D5qB1eH6.js";import{n as d}from"./plate-geometry-B8juLONh.js";import{Ar as f,Lt as p,ia as m,ir as h,j as g,no as _,ra as v,ro as y}from"./three.core-BHZv2AuD.js";import{i as b,n as x,o as S,r as C,t as w,u as T}from"./useThemeColors-B8cttUaE.js";import{drawable as E}from"./plate-mesh-DKFeiUUC.js";var D={name:`footprints`,size:24,node:[[`path`,{d:`M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z`,key:`1dudjm`}],[`path`,{d:`M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z`,key:`l2t8xc`}],[`path`,{d:`M16 17h4`,key:`1dejxt`}],[`path`,{d:`M4 13h4`,key:`1bwh8b`}]]};D.node;var O=i(D),k={name:`scan-search`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`m16 16-1.9-1.9`,key:`1dq9hf`}]]};k.node;var A=i(k),j=/* @__PURE__ */ e(t());function M(e,t=`pointer`,n=`auto`,r=document.body){j.useEffect(()=>{if(e)return r.style.cursor=t,()=>void(r.style.cursor=n)},[e])}var N=n(),P=new f(new y(0,0,1),0),F={clay:`#cbccd0`,selected:`#8fb4ff`,problem:`#ef6461`,overlap:`#f2b347`};function I(e){let t=(0,j.useRef)(/* @__PURE__ */ new Map),n={};for(let[r,i]of Object.entries(e))t.current.has(r)||t.current.set(r,{mesh:i,...E(i)}),n[r]=t.current.get(r);return(0,j.useEffect)(()=>{for(let[n,r]of t.current)e[n]||(r.geometry.dispose(),t.current.delete(n))},[e]),(0,j.useEffect)(()=>()=>{for(let e of t.current.values())e.geometry.dispose()},[]),n}function L({exclude:e}){let t=(0,j.useMemo)(()=>e.map(e=>({fill:new m(new v(e.map(([e,t])=>new _(e,t)))),edge:new g().setAttribute(`position`,new p(e.flatMap(([e,t])=>[e,t,.02]),3))})),[e]);return(0,j.useEffect)(()=>()=>t.forEach(e=>{e.fill.dispose(),e.edge.dispose()}),[t]),t.map((e,t)=>/* @__PURE__ */ (0,N.jsxs)(`group`,{children:[/* @__PURE__ */ (0,N.jsx)(`mesh`,{geometry:e.fill,"position-z":.01,children:/* @__PURE__ */ (0,N.jsx)(`meshBasicMaterial`,{color:F.problem,transparent:!0,opacity:.22,side:2,depthWrite:!1})}),/* @__PURE__ */ (0,N.jsx)(`lineLoop`,{geometry:e.edge,children:/* @__PURE__ */ (0,N.jsx)(`lineBasicMaterial`,{color:F.problem})})]},t))}function R({box:e,height:t,color:n}){let r=(0,j.useMemo)(()=>{let[n,r,i,a]=e,o=t,s=[[n,r],[i,r],[i,a],[n,a]],c=s.flatMap(([e,t],n)=>{let[r,i]=s[(n+1)%4];return[e,t,o,r,i,o,e,t,0,e,t,o]});return new g().setAttribute(`position`,new p(c,3))},[e,t]);return(0,j.useEffect)(()=>()=>r.dispose(),[r]),/* @__PURE__ */ (0,N.jsx)(`lineSegments`,{geometry:r,children:/* @__PURE__ */ (0,N.jsx)(`lineBasicMaterial`,{color:n,transparent:!0,opacity:.45})})}function z({item:e,shape:t,selected:n,layMode:r,offset:i,onSelect:a,onDrag:o,onDrop:s,onLay:c}){let l=T(e=>e.controls),u=T(e=>e.gl),f=(0,j.useRef)(null),[p,m]=(0,j.useState)(!1);M(p,r?`crosshair`:`grab`,`auto`,u.domElement);let g=(0,j.useMemo)(()=>{let[t,n,r,a,o,s,c,l,u]=e.A,[d,f]=i||[0,0];return new h().set(t,n,r,e.t[0]+d,a,o,s,e.t[1]+f,c,l,u,e.t[2],0,0,0,1)},[e.A,e.t,i]),_=e=>e.ray.intersectPlane(P,new y),v=t=>{if(t.stopPropagation(),r){t.face&&c(e.id,d(e.A,[t.face.normal.x,t.face.normal.y,t.face.normal.z]));return}a(e.id);let n=_(t);n&&(t.target.setPointerCapture(t.pointerId),l&&(l.enabled=!1),u.domElement.style.cursor=`grabbing`,f.current={from:n,moved:!1})},b=t=>{if(!f.current)return;let n=_(t);if(!n)return;let r=n.x-f.current.from.x,i=n.y-f.current.from.y;!f.current.moved&&Math.hypot(r,i)<.5||(f.current.moved=!0,f.current.delta=[r,i],o(e.id,r,i))},x=t=>{f.current&&=(t.target.releasePointerCapture(t.pointerId),l&&(l.enabled=!0),u.domElement.style.cursor=p?`grab`:`auto`,f.current.moved&&s(e.id,...f.current.delta),null)},S=e.problem?F.problem:e.overlap?F.overlap:n?F.selected:F.clay;return/* @__PURE__ */ (0,N.jsx)(`mesh`,{geometry:t.geometry,matrixAutoUpdate:!1,matrix:g,onPointerDown:v,onPointerMove:b,onPointerUp:x,onPointerCancel:x,onPointerOver:e=>{e.stopPropagation(),m(!0)},onPointerOut:()=>m(!1),children:/* @__PURE__ */ (0,N.jsx)(`meshStandardMaterial`,{color:S,roughness:.72,flatShading:t.flat,emissive:n?`#1d4ed8`:`#000000`,emissiveIntensity:n?.18:0,transparent:e.away,opacity:e.away?.4:1,depthWrite:!e.away})})}function B({bed:e,scene:t,meshes:n,selected:i,layMode:d,onSelect:f,onMove:p,onLay:m,onLayMode:h}){let g=w(),_=I(n),[v,y]=(0,j.useState)(null),[T,E]=(0,j.useState)({view:`iso`,key:0}),[D,k]=(0,j.useState)(null),[M,P,B,V]=e.box,H=Math.max(B-M,V-P,e.height),U=(0,j.useMemo)(()=>({min:[M,P,0],max:[B,V,Math.min(e.height,H/4)]}),[M,P,B,V,e.height,H]),W=t.filter(e=>e.problem).length,G=t.filter(e=>e.overlap).length,K=t.filter(e=>e.away).length;return/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`absolute inset-0 bg-viewer`,children:[/* @__PURE__ */ (0,N.jsxs)(S,{flat:!0,frameloop:`demand`,dpr:[1,2],camera:{fov:35,near:.1,far:1e4,up:[0,0,1],position:[0,-400,300]},onPointerMissed:()=>{d||f(null)},children:[/* @__PURE__ */ (0,N.jsx)(`color`,{attach:`background`,args:[g.background]}),/* @__PURE__ */ (0,N.jsx)(`hemisphereLight`,{args:[`#ffffff`,`#b0b1b6`,1.5],position:[0,0,1]}),/* @__PURE__ */ (0,N.jsx)(`directionalLight`,{position:[-150,-300,400],intensity:1.1}),/* @__PURE__ */ (0,N.jsx)(`directionalLight`,{position:[250,120,120],intensity:.35}),/* @__PURE__ */ (0,N.jsx)(C,{outline:e.outline,colors:g}),/* @__PURE__ */ (0,N.jsx)(L,{exclude:e.exclude}),!e.standIn&&/* @__PURE__ */ (0,N.jsx)(R,{box:e.box,height:e.height,color:g.bedEdge}),t.filter(e=>e.loaded&&_[e.fileId]).map(e=>/* @__PURE__ */ (0,N.jsx)(z,{item:e,shape:_[e.fileId],selected:e.id===i,layMode:d,offset:v&&v.id===e.id?[v.dx,v.dy]:null,onSelect:f,onLay:m,onDrag:(e,t,n)=>y({id:e,dx:t,dy:n}),onDrop:(e,t,n)=>{y(null),p(e,t,n)}},e.id)),/* @__PURE__ */ (0,N.jsx)(b,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,N.jsx)(x,{bounds:U,far:20*H,view:T.view,fitKey:T.key}),/* @__PURE__ */ (0,N.jsx)(u,{request:D}),/* @__PURE__ */ (0,N.jsx)(l,{})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex justify-end [&>*]:pointer-events-auto`,children:/* @__PURE__ */ (0,N.jsxs)(r,{children:[/* @__PURE__ */ (0,N.jsx)(a,{label:`Lay on face: click a face to stand the object on it`,pressed:d,disabled:!i,onClick:()=>h(!d),children:/* @__PURE__ */ (0,N.jsx)(O,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,N.jsx)(a,{label:`Whole plate`,onClick:()=>E(e=>({view:`iso`,key:e.key+1})),children:/* @__PURE__ */ (0,N.jsx)(A,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(a,{label:`From above`,onClick:()=>E(e=>({view:`top`,key:e.key+1})),children:/* @__PURE__ */ (0,N.jsx)(c,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(a,{label:`Zoom in`,onClick:()=>k({factor:.8}),children:/* @__PURE__ */ (0,N.jsx)(o,{className:`size-4`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(a,{label:`Zoom out`,onClick:()=>k({factor:1.25}),children:/* @__PURE__ */ (0,N.jsx)(s,{className:`size-4`,"aria-hidden":!0})})]})}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`pointer-events-none absolute right-3 bottom-3 left-[136px] z-10 flex flex-wrap justify-end gap-1.5 text-label`,children:[d&&/* @__PURE__ */ (0,N.jsx)(`span`,{className:`rounded-full bg-ink px-2.5 py-1 text-ink-contrast`,children:`Click the face to put down`}),e.standIn&&/* @__PURE__ */ (0,N.jsx)(`span`,{className:`material rounded-full px-2.5 py-1 text-muted`,children:`Bed size unknown: a 256 mm stand-in`}),W>0&&/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`rounded-full px-2.5 py-1 text-white`,style:{background:F.problem},children:[W===1?`An object`:`${W} objects`,` can’t be printed there`]}),G>0&&/* @__PURE__ */ (0,N.jsx)(`span`,{className:`rounded-full px-2.5 py-1 text-ink`,style:{background:F.overlap},children:`Objects overlap`}),K>0&&/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`material rounded-full px-2.5 py-1 text-muted`,children:[K===1?`An object`:`${K} objects`,` off the bed, not sliced`]})]})]})}export{B as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{G as r,c as i,l as a,r as o,s}from"./tool-button-BSd3e5SL.js";import{L as c,Rn as l,Rt as u,Wr as d,Yt as f,bt as p,do as m,ea as h,ir as g,ro as _,wr as v}from"./three.core-BHZv2AuD.js";import{a as y,l as b,s as x,u as S}from"./useThemeColors-B8cttUaE.js";var C={name:`crosshair`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]};C.node;var w=s(C),T={name:`zoom-in`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]};T.node;var E=s(T),D={name:`zoom-out`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]};D.node;var O=s(D),k=/* @__PURE__ */ e(t());function A(e,t,n){let r=S(e=>e.size),i=S(e=>e.viewport),a=typeof e==`number`?e:r.width*i.dpr,o=typeof t==`number`?t:r.height*i.dpr,s=(typeof e==`number`?n:e)||{},{samples:c=0,depth:d,...h}=s,g=d??s.depthBuffer,_=k.useMemo(()=>{let e=new m(a,o,{minFilter:l,magFilter:l,type:f,...h});return g&&(e.depthTexture=new p(a,o,u)),e.samples=c,e},[]);return k.useLayoutEffect(()=>{_.setSize(a,o),c&&(_.samples=c)},[c,_,a,o]),k.useEffect(()=>()=>_.dispose(),[]),_}var j=e=>typeof e==`function`,M=/* @__PURE__ */ k.forwardRef(({envMap:e,resolution:t=256,frames:n=1/0,children:r,makeDefault:i,...a},o)=>{let s=S(({set:e})=>e),c=S(({camera:e})=>e),l=S(({size:e})=>e),u=k.useRef(null);k.useImperativeHandle(o,()=>u.current,[]);let d=k.useRef(null),f=A(t);k.useLayoutEffect(()=>{a.manual||u.current.updateProjectionMatrix()},[l,a]),k.useLayoutEffect(()=>{u.current.updateProjectionMatrix()}),k.useLayoutEffect(()=>{if(i){let e=c;return s(()=>({camera:u.current})),()=>s(()=>({camera:e}))}},[u,i,s]);let p=0,m=null,h=j(r);return b(t=>{h&&(n===1/0||p<n)&&(d.current.visible=!1,t.gl.setRenderTarget(f),m=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,u.current),t.scene.background=m,t.gl.setRenderTarget(null),d.current.visible=!0,p++)}),/*#__PURE__*/ k.createElement(k.Fragment,null,/*#__PURE__*/ k.createElement(`orthographicCamera`,y({left:l.width/-2,right:l.width/2,top:l.height/2,bottom:l.height/-2,ref:u},a),!h&&r),/*#__PURE__*/ k.createElement(`group`,{ref:d},h&&r(f.texture)))});function N({defaultScene:e,defaultCamera:t,renderPriority:n=1}){let{gl:r,scene:i,camera:a}=S(),o;return b(()=>{o=r.autoClear,n===1&&(r.autoClear=!0,r.render(e,t)),r.autoClear=!1,r.clearDepth(),r.render(i,a),r.autoClear=o},n),/*#__PURE__*/ k.createElement(`group`,{onPointerOver:()=>null})}function P({children:e,renderPriority:t=1}){let{scene:n,camera:r}=S(),[i]=k.useState(()=>new h);return/*#__PURE__*/ k.createElement(k.Fragment,null,x(/*#__PURE__*/ k.createElement(k.Fragment,null,e,/*#__PURE__*/ k.createElement(N,{defaultScene:n,defaultCamera:r,renderPriority:t})),i,{events:{priority:t+1}}))}var F=/* @__PURE__ */ k.createContext({}),I=()=>k.useContext(F),L=2*Math.PI,R=/* @__PURE__ */ new v,z=/* @__PURE__ */ new g,[B,V]=[/* @__PURE__ */ new d,/* @__PURE__ */ new d],H=/* @__PURE__ */ new _,U=/* @__PURE__ */ new _,W=e=>`minPolarAngle`in e,G=e=>`getTarget`in e,K=({alignment:e=`bottom-right`,margin:t=[80,80],renderPriority:n=1,onUpdate:r,onTarget:i,children:a})=>{let o=S(e=>e.size),s=S(e=>e.camera),c=S(e=>e.controls),l=S(e=>e.invalidate),u=k.useRef(null),d=k.useRef(null),f=k.useRef(!1),p=k.useRef(0),m=k.useRef(new _(0,0,0)),h=k.useRef(new _(0,0,0));k.useEffect(()=>{h.current.copy(s.up),R.up.copy(s.up)},[s]);let g=k.useCallback(e=>{f.current=!0,(c||i)&&(m.current=i?.()||(G(c)?c.getTarget(m.current):c?.target)),p.current=s.position.distanceTo(H),B.copy(s.quaternion),U.copy(e).multiplyScalar(p.current).add(H),R.lookAt(U),V.copy(R.quaternion),l()},[c,s,i,l]);b((e,t)=>{if(d.current&&u.current){var n;if(f.current){if(B.angleTo(V)<.01)f.current=!1,W(c)&&s.up.copy(h.current);else{let e=t*L;B.rotateTowards(V,e),s.position.set(0,0,1).applyQuaternion(B).multiplyScalar(p.current).add(m.current),s.up.set(0,1,0).applyQuaternion(B).normalize(),s.quaternion.copy(B),G(c)&&c.setPosition(s.position.x,s.position.y,s.position.z),r?r():c&&c.update(t),l()}}z.copy(s.matrix).invert(),(n=u.current)==null||n.quaternion.setFromRotationMatrix(z)}});let v=k.useMemo(()=>({tweenCamera:g}),[g]),[y,x]=t,C=e.endsWith(`-center`)?0:e.endsWith(`-left`)?-o.width/2+y:o.width/2-y,w=e.startsWith(`center-`)?0:e.startsWith(`top-`)?o.height/2-x:-o.height/2+x;return/*#__PURE__*/ k.createElement(P,{renderPriority:n},/*#__PURE__*/ k.createElement(F.Provider,{value:v},/*#__PURE__*/ k.createElement(M,{makeDefault:!0,ref:d,position:[0,0,200]}),/*#__PURE__*/ k.createElement(`group`,{ref:u,position:[C,w,0]},a)))},q=n(),J=[{name:`X`,dir:[1,0,0],color:`#e5484d`},{name:`Y`,dir:[0,1,0],color:`#30a46c`},{name:`Z`,dir:[0,0,1],color:`#3e7bfa`}];function Y(e,t){let n=document.createElement(`canvas`);n.width=n.height=64;let r=n.getContext(`2d`);return r.fillStyle=t,r.font=`700 48px system-ui, sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(e,32,34),new c(n)}function X({name:e,dir:t,color:n}){let{tweenCamera:r}=I(),i=(0,k.useMemo)(()=>new _(...t),[t]),a=(0,k.useMemo)(()=>new d().setFromUnitVectors(new _(0,1,0),i),[i]),o=(0,k.useMemo)(()=>Y(e,n),[e,n]);return(0,k.useEffect)(()=>()=>o.dispose(),[o]),/* @__PURE__ */ (0,q.jsxs)(q.Fragment,{children:[/* @__PURE__ */ (0,q.jsxs)(`group`,{quaternion:a,children:[/* @__PURE__ */ (0,q.jsxs)(`mesh`,{"position-y":.85,children:[/* @__PURE__ */ (0,q.jsx)(`cylinderGeometry`,{args:[.04,.04,.7,8]}),/* @__PURE__ */ (0,q.jsx)(`meshBasicMaterial`,{color:n})]}),/* @__PURE__ */ (0,q.jsxs)(`mesh`,{"position-y":1.32,children:[/* @__PURE__ */ (0,q.jsx)(`coneGeometry`,{args:[.12,.26,12]}),/* @__PURE__ */ (0,q.jsx)(`meshBasicMaterial`,{color:n})]})]}),/* @__PURE__ */ (0,q.jsx)(`sprite`,{position:i.clone().multiplyScalar(1.8),scale:.62,onClick:e=>{e.stopPropagation(),r(i)},children:/* @__PURE__ */ (0,q.jsx)(`spriteMaterial`,{map:o,transparent:!0,depthWrite:!1})})]})}function Z(){let e=S(e=>e.size.width)<576;return/* @__PURE__ */ (0,q.jsx)(K,{alignment:`bottom-left`,margin:e?[48,48]:[72,72],children:/* @__PURE__ */ (0,q.jsxs)(`group`,{scale:e?18:28,children:[/* @__PURE__ */ (0,q.jsx)(`ambientLight`,{intensity:1.6}),/* @__PURE__ */ (0,q.jsx)(`directionalLight`,{position:[2,3,4],intensity:1.6}),/* @__PURE__ */ (0,q.jsxs)(`mesh`,{children:[/* @__PURE__ */ (0,q.jsx)(`boxGeometry`,{args:[1,1,1]}),/* @__PURE__ */ (0,q.jsx)(`meshStandardMaterial`,{color:`#f4f6f4`,roughness:.6})]}),J.map(e=>/* @__PURE__ */ (0,q.jsx)(X,{...e},e.name))]})})}function Q({min:[e,t,n],max:[r,i,a]},o){let s=o/2,c=t-o,l=e-o,u=e=>`${e.toFixed(1)} mm`;return[{axis:`x`,label:u(r-e),from:[e,c,n],to:[r,c,n],at:[(e+r)/2,c-o,n],ticks:[e,r].map(e=>[[e,c-s,n],[e,c+s,n]])},{axis:`y`,label:u(i-t),from:[l,t,n],to:[l,i,n],at:[l-o,(t+i)/2,n],ticks:[t,i].map(e=>[[l-s,e,n],[l+s,e,n]])},{axis:`z`,label:u(a-n),from:[l,i,n],to:[l,i,a],at:[l-o,i,(n+a)/2],ticks:[n,a].map(e=>[[l-s,i,e],[l+s,i,e]])}]}function $(e,t,n,r=1){let i=e.map((e,n)=>e-t[n]),a=Math.hypot(...i),o=Math.max(a*n,r);return t.map((e,t)=>e+i[t]/a*o)}function ee({request:e}){let t=S(e=>e.camera),n=S(e=>e.controls),s=S(e=>e.invalidate),c=a(),l=(0,k.useRef)(null),u=(0,k.useRef)(null);return(0,k.useEffect)(()=>{if(!n)return;let e=l.current=r(t.position.distanceTo(n.target)),i=e.on(`change`,e=>{let r=t.position.distanceTo(n.target);t.position.fromArray($(t.position.toArray(),n.target.toArray(),e/r)),n.update(),s()}),a=()=>{e.stop(),u.current=null};return n.addEventListener(`start`,a),()=>{i(),e.stop(),n.removeEventListener(`start`,a)}},[n,t,s]),(0,k.useEffect)(()=>{let r=l.current;if(!e||!r||!n)return;let a=r.isAnimating()&&u.current!==null;a||r.jump(t.position.distanceTo(n.target));let s=Math.max((a?u.current:r.get())*e.factor,1);u.current=s,c?(r.jump(s),u.current=null):i(r,s,o).then(()=>{u.current===s&&(u.current=null)})},[e]),null}export{E as a,O as i,Q as n,w as o,Z as r,ee as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./fflate.module-ChfQ5943.js";var t={stl:`stl`,"3mf":`3mf`,obj:`obj`,step:`step`,stp:`step`,iges:`iges`,igs:`iges`},n=Object.keys(t).map(e=>`.`+e).join(`,`),r=[...new Set(Object.values(t))].map(e=>e.toUpperCase()),i=`${r.slice(0,-1).join(`, `)} or ${r[r.length-1]}`,a=`.gcode,.gco,.g,.3mf`,o=e=>e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1e3))} kB`,s=/^Metadata\/plate_(\d+)\.gcode$/;function c(t,n,r=()=>{}){try{return e(t,{filter:e=>(r(e),n(e.name))})}catch{return null}}function l(e,n){let r=(e.match(/\.(\w+)$/)||[])[1]?.toLowerCase();if([`gcode`,`gco`,`g`].includes(r))return{kind:`gcode`};if(!t[r])return{kind:`unknown`};if(r===`3mf`&&n){let e=[],t=c(n,t=>(e.push(t),/^Metadata\/plate_\d+\.png$/.test(t)))||{},r=e.map(e=>e.match(s)).filter(Boolean).map(e=>Number(e[1])).sort((e,t)=>e-t);if(r.length)return{kind:`gcode3mf`,plates:r.map(e=>({plate:e,thumbnail:t[`Metadata/plate_${e}.png`]||null}))}}return{kind:`model`,format:t[r]}}function u(e){let t=0;return c(e,e=>!1,e=>{/\.model$/i.test(e.name)&&(t+=e.originalSize)}),t}async function d(e){let t=[],n=[];for(let r of e){let e=l(r.name,/\.3mf$/i.test(r.name)?new Uint8Array(await r.arrayBuffer()):void 0);(e.kind===`model`?t:n).push({file:r,what:e})}return{models:t.map(e=>e.file),others:n}}export{o as a,l as i,n,u as o,i as r,d as s,a as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./fflate.module-ChfQ5943.js";import{a as t}from"./files-BZtizmc1.js";import{$n as n,A as r,Fr as i,Ft as a,Hn as o,Ir as s,Kn as c,Ln as l,Lt as u,Ma as d,Mn as f,Qi as p,Rn as m,U as h,V as g,Wi as _,Wr as v,_r as y,ar as b,ct as x,fr as S,gr as C,ir as w,j as T,mr as E,pa as ee,qt as D,ro as O}from"./three.core-BHZv2AuD.js";var k=class extends c{constructor(e){super(e)}load(e,t,n,r){let i=this,o=new a(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.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 i(e){let t=new DataView(e),n=t.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)t.getUint32(e,!1)==1129270351&&t.getUint8(e+4)==82&&t.getUint8(e+5)==61&&(s=!0,c=new Float32Array(n*3*3),l=t.getUint8(e+6)/255,u=t.getUint8(e+7)/255,d=t.getUint8(e+8)/255,f=t.getUint8(e+9)/255);let m=new T,g=new Float32Array(n*3*3),_=new Float32Array(n*3*3),v=new h;for(let e=0;e<n;e++){let n=84+e*50,r=t.getFloat32(n,!0),f=t.getFloat32(n+4,!0),m=t.getFloat32(n+8,!0);if(s){let e=t.getUint16(n+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=n+l*12,d=e*3*3+(l-1)*3;g[d]=t.getFloat32(u,!0),g[d+1]=t.getFloat32(u+4,!0),g[d+2]=t.getFloat32(u+8,!0),_[d]=r,_[d+1]=f,_[d+2]=m,s&&(v.setRGB(i,a,o,p),c[d]=v.r,c[d+1]=v.g,c[d+2]=v.b)}}return m.setAttribute(`position`,new r(g,3)),m.setAttribute(`normal`,new r(_,3)),s&&(m.setAttribute(`color`,new r(c,3)),m.hasColors=!0,m.alpha=f),m}function a(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=[],d=[],f=[],p=new O,m,h=0,g=0,_=0;for(;(m=n.exec(e))!==null;){g=_;let e=m[0],n=(m=i.exec(e))===null?``:m[1];for(f.push(n);(m=r.exec(e))!==null;){let e=0,t=0,n=m[0];for(;(m=c.exec(n))!==null;)p.x=parseFloat(m[1]),p.y=parseFloat(m[2]),p.z=parseFloat(m[3]),t++;for(;(m=s.exec(n))!==null;)l.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])),d.push(p.x,p.y,p.z),e++,_++;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=g,u=_-g;t.userData.groupNames=f,t.addGroup(o,u,h),h++}return t.setAttribute(`position`,new u(l,3)),t.setAttribute(`normal`,new u(d,3)),t}function o(e){return typeof e==`string`?e:new TextDecoder().decode(e)}function s(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 c=s(e);return t(c)?i(c):a(o(e))}};function A(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=j(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=j(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 j(e){let t,n,i,a=-1,o=0;for(let r=0;r<e.length;++r){let s=e[r];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(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*n}let s=new t(o),c=new r(s,n,i),l=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=l/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);c.setComponent(t+e,i,n)}}else s.set(r.array,l);l+=r.count*n}return a!==void 0&&(c.gpuType=a),c}function M(e,t=1e-4){t=Math.max(t,2**-52);let n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},l={},u=[],d=[`getX`,`getY`,`getZ`,`getW`],f=[`setX`,`setY`,`setZ`,`setW`];for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.attributes[n];c[n]=new r.constructor(new r.array.constructor(r.count*r.itemSize),r.itemSize,r.normalized);let i=e.morphAttributes[n];i&&(l[n]||(l[n]=[]),i.forEach((e,t)=>{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;t<a;t++){let i=r?r.getX(t):t,a=``;for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),o=r.itemSize;for(let e=0;e<o;e++)a+=`${Math.trunc(r[d[e]](i)*m+h)},`}if(a in n)u.push(n[a]);else{for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),a=e.morphAttributes[n],u=r.itemSize,p=c[n],m=l[n];for(let e=0;e<u;e++){let t=d[e],n=f[e];if(p[n](o,r[t](i)),a)for(let e=0,r=a.length;e<r;e++)m[e][n](o,a[e][t](i))}}n[a]=o,u.push(o),o++}}let g=e.clone();for(let t in e.attributes){let e=c[t];if(g.setAttribute(t,new e.constructor(e.array.slice(0,o*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){let n=l[t][e];g.morphAttributes[t][e]=new n.constructor(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return g.setIndex(u),g}function N(e,t=Math.PI/3){let n=e.index?e.toNonIndexed():e,i=n.attributes.position,a=i.count,o;if(i.isBufferAttribute===!0&&i.itemSize===3&&i.normalized===!1)o=i.array;else{o=new Float64Array(a*3);for(let e=0;e<a;e++)o[3*e+0]=i.getX(e),o[3*e+1]=i.getY(e),o[3*e+2]=i.getZ(e)}let s=Math.cos(t),c=(1+1e-10)*100,l=a/3,u=new Float64Array(l*3);for(let e=0;e<l;e++){let t=9*e,n=o[t+0],r=o[t+1],i=o[t+2],a=o[t+3],s=o[t+4],c=o[t+5],l=o[t+6],d=o[t+7],f=o[t+8],p=l-a,m=d-s,h=f-c,g=n-a,_=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);u[3*e+0]=y*S,u[3*e+1]=b*S,u[3*e+2]=x*S}let d=new Int32Array(a),f=new Float64Array(a*3),p=1;for(;p<a*2;)p<<=1;let m=p-1,h=new Int32Array(p),g=0;for(let e=0;e<a;e++){let t=3*e,n=Math.trunc(o[t+0]*c),r=Math.trunc(o[t+1]*c),i=Math.trunc(o[t+2]*c),a=(Math.imul(n,73856093)^Math.imul(r,19349663)^Math.imul(i,83492791))&m;for(;;){let t=h[a];if(t===0){let t=3*g;f[t+0]=n,f[t+1]=r,f[t+2]=i,h[a]=g+1,d[e]=g++;break}let o=3*(t-1);if(f[o+0]===n&&f[o+1]===r&&f[o+2]===i){d[e]=t-1;break}a=a+1&m}}let _=new Int32Array(g+1);for(let e=0;e<a;e++)_[d[e]+1]++;for(let e=0;e<g;e++)_[e+1]+=_[e];let v=new Int32Array(a),y=_.slice(0,g);for(let e=0;e<l;e++){let t=3*e;v[y[d[t+0]]++]=e,v[y[d[t+1]]++]=e,v[y[d[t+2]]++]=e}let b=new Float32Array(a*3);for(let e=0;e<l;e++){let t=3*e,n=u[t+0],r=u[t+1],i=u[t+2];for(let e=0;e<3;e++){let a=t+e,o=d[a],c=0,l=0,f=0;for(let e=_[o],t=_[o+1];e<t;e++){let t=3*v[e],a=u[t+0],o=u[t+1],d=u[t+2];n*a+r*o+i*d>s&&(c+=a,l+=o,f+=d)}let p=1/(Math.sqrt(c*c+l*l+f*f)||1);b[3*a+0]=c*p,b[3*a+1]=l*p,b[3*a+2]=f*p}}return n.setAttribute(`normal`,new r(b,3,!1)),n}var P=p,F=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02`,I=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/balls/2020/07`,te=class extends c{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,r){let i=this,o=new a(i.manager);o.setPath(i.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(t){let n=this,i=new d(this.manager);function a(t){let n=null,r=null,i,a,o=[],c=[],l,u={},d={},f={},p=new TextDecoder;try{n=e(new Uint8Array(t))}catch(e){if(e instanceof ReferenceError)return console.error(`THREE.3MFLoader: fflate missing and file is compressed.`),null}let m=null;for(r in n)r.match(/\_rels\/.rels$/)?i=r:r.match(/3D\/_rels\/.*\.model\.rels$/)?a=r:r.match(/^3D\/[^\/]*\.model$/)?m=r:r.match(/^3D\/.*\/.*\.model$/)?o.push(r):r.match(/^3D\/Textures?\/.*/)&&c.push(r);if(o.push(m),i===void 0)throw Error("THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.");let h=n[i],g=s(p.decode(h));if(a){let e=n[a];l=s(p.decode(e))}for(let e=0;e<o.length;e++){let t=o[e],r=n[t],i=p.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 l=G(s);l.xml=s,0<Object.keys(c).length&&(l.extensions=c),u[t]=l}for(let e=0;e<c.length;e++){let t=c[e];f[t]=n[t].buffer}return{rels:g,modelRels:l,model:u,printTicket:d,texture:f}}function s(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 l(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 f(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=ne(r);i.index=e,t.basematerials.push(i)}return t}function p(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 j(e){let t={id:e.getAttribute(`id`),displaypropertiesid:e.getAttribute(`displaypropertiesid`)},n=e.querySelectorAll(`color`),r=[],i=new h;for(let e=0;e<n.length;e++){let t=n[e].getAttribute(`color`);i.setStyle(t.substring(0,7),P),r.push(i.r,i.g,i.b)}return t.colors=new Float32Array(r),t}function M(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 N(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`]=M(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)]=M(e[t]);r[n.identifier]=n}}return t.operations=r,t}function te(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 ne(e){let t={};return t.name=e.getAttribute(`name`),t.displaycolor=e.getAttribute(`displaycolor`),t.displaypropertiesid=e.getAttribute(`displaypropertiesid`),t}function L(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(F,`beamlattice`)[0];return s!==void 0&&(t.beamlattice=R(s)),t}function R(e){let t={radius:parseFloat(e.getAttribute(`radius`)),minLength:parseFloat(e.getAttribute(`minlength`)),cap:e.getAttribute(`cap`)||`sphere`,ballMode:e.getAttributeNS(I,`ballmode`)||`none`,ballRadius:parseFloat(e.getAttributeNS(I,`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(F,`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(I,`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 z(e){let t=[],n=e.querySelectorAll(`component`);for(let e=0;e<n.length;e++){let r=n[e],i=B(r);t.push(i)}return t}function B(e){let t={};t.objectId=e.getAttribute(`objectid`);let n=e.getAttribute(`transform`);return n&&(t.transform=V(n)),t}function V(e){let t=[];e.split(` `).forEach(function(e){t.push(parseFloat(e))});let n=new w;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 H(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=L(c));let l=e.querySelector(`components`);return l&&(t.components=z(l)),t}function U(e){let t={};t.basematerials={};let n=e.querySelectorAll(`basematerials`);for(let e=0;e<n.length;e++){let r=n[e],i=f(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=p(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=j(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=N(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=te(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=H(n);t.object[r.id]=r}return t}function W(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=V(a)),t.push(i)}return t}function G(e){let t={unit:e.getAttribute(`unit`)||`millimeter`},n=e.querySelectorAll(`metadata`);n&&(t.metadata=l(n));let r=e.querySelector(`resources`);r&&(t.resources=U(r));let i=e.querySelector(`build`);return i&&(t.build=W(i)),t}function K(e,t,n,r){let a=e.texid,s=n.resources.texture2d[a];if(s){let e=r[s.path],t=s.contenttype,n=new Blob([e],{type:t}),a=URL.createObjectURL(n),c=i.load(a,function(){URL.revokeObjectURL(a)});switch(c.colorSpace=P,s.tilestyleu){case`wrap`:c.wrapS=_;break;case`mirror`:c.wrapS=C;break;case`none`:case`clamp`:c.wrapS=g;break;default:c.wrapS=_}switch(s.tilestylev){case`wrap`:c.wrapT=_;break;case`mirror`:c.wrapT=C;break;case`none`:case`clamp`:c.wrapT=g;break;default:c.wrapT=_}switch(s.filter){case`auto`:c.magFilter=m,c.minFilter=o;break;case`linear`:c.magFilter=m,c.minFilter=m,c.generateMipmaps=!1;break;case`nearest`:c.magFilter=y,c.minFilter=y,c.generateMipmaps=!1;break;default:c.magFilter=m,c.minFilter=o}return c}return null}function q(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 l=Object.keys(c),d=[];for(let t=0,s=l.length;t<s;t++){let s=l[t],f=c[s],p=e.basematerials[s],m=Q(p,r,i,a,o,ce),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 u(g,3));let v=new b(h,m);d.push(v)}return d}function J(e,t,n,r,i,a,o){let s=new T,c=[],l=[],d=n.vertices,f=e.uvs;for(let e=0,n=t.length;e<n;e++){let n=t[e];c.push(d[n.v1*3+0]),c.push(d[n.v1*3+1]),c.push(d[n.v1*3+2]),c.push(d[n.v2*3+0]),c.push(d[n.v2*3+1]),c.push(d[n.v2*3+2]),c.push(d[n.v3*3+0]),c.push(d[n.v3*3+1]),c.push(d[n.v3*3+2]),l.push(f[n.p1*2+0]),l.push(f[n.p1*2+1]),l.push(f[n.p2*2+0]),l.push(f[n.p2*2+1]),l.push(f[n.p3*2+0]),l.push(f[n.p3*2+1])}s.setAttribute(`position`,new u(c,3)),s.setAttribute(`uv`,new u(l,2));let p=Q(e,r,i,a,o,K),m=new S({map:p,flatShading:!0});return new b(s,m)}function Y(e,t,n,r){let i=new T,a=[],o=[],s=n.vertices,c=e.colors;for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.v1,l=n.v2,u=n.v3;a.push(s[i*3+0]),a.push(s[i*3+1]),a.push(s[i*3+2]),a.push(s[l*3+0]),a.push(s[l*3+1]),a.push(s[l*3+2]),a.push(s[u*3+0]),a.push(s[u*3+1]),a.push(s[u*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;o.push(c[d*3+0]),o.push(c[d*3+1]),o.push(c[d*3+2]),o.push(c[f*3+0]),o.push(c[f*3+1]),o.push(c[f*3+2]),o.push(c[p*3+0]),o.push(c[p*3+1]),o.push(c[p*3+2])}i.setAttribute(`position`,new u(a,3)),i.setAttribute(`color`,new u(o,3));let l=new S({vertexColors:!0,flatShading:!0});return new b(i,l)}function X(e){let t=new T;t.setIndex(new r(e.triangles,1)),t.setAttribute(`position`,new r(e.vertices,3));let n=new S({name:c.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new b(t,n)}function Z(e){let t=e.beamlattice,n=e.vertices,r=[],i=new O,a=new O,o=new O,s=new O(0,1,0),l=new v,u=new w,d=t.beams,f=t.cap!==`butt`,p=/* @__PURE__ */ new Map;for(let e=0;e<d.length;e++){let c=d[e];i.fromArray(n,c.v1*3),a.fromArray(n,c.v2*3);let m=i.distanceTo(a);if(m<t.minLength)continue;let h=c.r1===void 0?t.radius:c.r1,g=c.r2===void 0?h:c.r2,_=new x(g,h,m,8,1,f);o.subVectors(a,i).divideScalar(m),l.setFromUnitVectors(s,o),u.makeRotationFromQuaternion(l),u.setPosition(i.add(a).multiplyScalar(.5)),_.applyMatrix4(u),r.push(_),f&&(p.set(c.v1,Math.max(h,p.get(c.v1)||0)),p.set(c.v2,Math.max(g,p.get(c.v2)||0))),t.ballMode===`all`&&(p.set(c.v1,Math.max(t.ballRadius,p.get(c.v1)||0)),p.set(c.v2,Math.max(t.ballRadius,p.get(c.v2)||0)))}let m=t.balls;for(let e=0;e<m.length;e++){let n=m[e],r=n.r===void 0?t.ballRadius:n.r;p.set(n.vindex,Math.max(r,p.get(n.vindex)||0))}for(let[e,t]of p){let a=new ee(t,8,6);i.fromArray(n,e*3),a.translate(i.x,i.y,i.z),r.push(a)}let h=A(r),g=new S({name:c.DEFAULT_MATERIAL_NAME,color:16777215});return new b(h,g)}function re(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(ie(l,r)){case`material`:let e=r.resources.basematerials[l],o=q(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(J(c,u,t,n,r,i,a));break;case`vertexColors`:let d=r.resources.colorgroup[l];s.push(Y(d,u,t,a));break;case`default`:s.push(X(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 ie(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 ae(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 oe(e,t,n,r,i){let a=new D,o=re(ae(e,i),e,t,n,r,i);if(e.beamlattice!==void 0){let t=Z(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 se(e,t,r){if(!e)return;let i=[],a=Object.keys(e);for(let e=0;e<a.length;e++){let t=a[e];for(let e=0;e<n.availableExtensions.length;e++){let r=n.availableExtensions[e];r.ns===t&&i.push(r)}}for(let n=0;n<i.length;n++){let a=i[n];a.apply(r,e[a.ns],t)}}function Q(e,t,n,r,i,a){return e.build===void 0&&(e.build=a(e,t,n,r,i)),e.build}function ce(e,t,n){let r,i=e.displaypropertiesid,a=n.resources.pbmetallicdisplayproperties;if(i!==null&&a[i]!==void 0){let t=a[i].data[e.index];r=new E({flatShading:!0,roughness:t.roughness,metalness:t.metallicness})}else r=new S({flatShading:!0});r.name=e.name;let o=e.displaycolor,s=o.substring(0,7);return r.color.setStyle(s,P),o.length===9&&(r.opacity=parseInt(o.charAt(7)+o.charAt(8),16)/255),r}function le(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&&($(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 $(e,t,n,r){let i=n.resources.object[e];if(i.mesh){let e=i.mesh,a=n.extensions,o=n.xml;se(a,e,o),t[i.id]=Q(e,t,n,r,i,oe)}else{let e=i.components;t[i.id]=Q(e,t,n,r,i,le)}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];$(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=a(t);return fe(ue(pe),pe)}addExtension(e){this.availableExtensions.push(e)}},ne=/^[og]\s*(.+)?/,L=/^mtllib /,R=/^usemtl /,z=/^usemap /,B=/\s+/,V=new O,H=new O,U=new O,W=new O,G=new O,K=new h;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,o=new a(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.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
|
|
1
|
+
import{n as e}from"./fflate.module-ChfQ5943.js";import{o as t}from"./files-YWgqYMU_.js";import{$n as n,A as r,Fr as i,Ft as a,Hn as o,Ir as s,Kn as c,Ln as l,Lt as u,Ma as d,Mn as f,Qi as p,Rn as m,U as h,V as g,Wi as _,Wr as v,_r as y,ar as b,ct as x,fr as S,gr as C,ir as w,j as T,mr as E,pa as ee,qt as D,ro as O}from"./three.core-BHZv2AuD.js";var k=class extends c{constructor(e){super(e)}load(e,t,n,r){let i=this,o=new a(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.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 i(e){let t=new DataView(e),n=t.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)t.getUint32(e,!1)==1129270351&&t.getUint8(e+4)==82&&t.getUint8(e+5)==61&&(s=!0,c=new Float32Array(n*3*3),l=t.getUint8(e+6)/255,u=t.getUint8(e+7)/255,d=t.getUint8(e+8)/255,f=t.getUint8(e+9)/255);let m=new T,g=new Float32Array(n*3*3),_=new Float32Array(n*3*3),v=new h;for(let e=0;e<n;e++){let n=84+e*50,r=t.getFloat32(n,!0),f=t.getFloat32(n+4,!0),m=t.getFloat32(n+8,!0);if(s){let e=t.getUint16(n+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=n+l*12,d=e*3*3+(l-1)*3;g[d]=t.getFloat32(u,!0),g[d+1]=t.getFloat32(u+4,!0),g[d+2]=t.getFloat32(u+8,!0),_[d]=r,_[d+1]=f,_[d+2]=m,s&&(v.setRGB(i,a,o,p),c[d]=v.r,c[d+1]=v.g,c[d+2]=v.b)}}return m.setAttribute(`position`,new r(g,3)),m.setAttribute(`normal`,new r(_,3)),s&&(m.setAttribute(`color`,new r(c,3)),m.hasColors=!0,m.alpha=f),m}function a(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=[],d=[],f=[],p=new O,m,h=0,g=0,_=0;for(;(m=n.exec(e))!==null;){g=_;let e=m[0],n=(m=i.exec(e))===null?``:m[1];for(f.push(n);(m=r.exec(e))!==null;){let e=0,t=0,n=m[0];for(;(m=c.exec(n))!==null;)p.x=parseFloat(m[1]),p.y=parseFloat(m[2]),p.z=parseFloat(m[3]),t++;for(;(m=s.exec(n))!==null;)l.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])),d.push(p.x,p.y,p.z),e++,_++;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=g,u=_-g;t.userData.groupNames=f,t.addGroup(o,u,h),h++}return t.setAttribute(`position`,new u(l,3)),t.setAttribute(`normal`,new u(d,3)),t}function o(e){return typeof e==`string`?e:new TextDecoder().decode(e)}function s(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 c=s(e);return t(c)?i(c):a(o(e))}};function A(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=j(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=j(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 j(e){let t,n,i,a=-1,o=0;for(let r=0;r<e.length;++r){let s=e[r];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(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*n}let s=new t(o),c=new r(s,n,i),l=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=l/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);c.setComponent(t+e,i,n)}}else s.set(r.array,l);l+=r.count*n}return a!==void 0&&(c.gpuType=a),c}function M(e,t=1e-4){t=Math.max(t,2**-52);let n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},l={},u=[],d=[`getX`,`getY`,`getZ`,`getW`],f=[`setX`,`setY`,`setZ`,`setW`];for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.attributes[n];c[n]=new r.constructor(new r.array.constructor(r.count*r.itemSize),r.itemSize,r.normalized);let i=e.morphAttributes[n];i&&(l[n]||(l[n]=[]),i.forEach((e,t)=>{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;t<a;t++){let i=r?r.getX(t):t,a=``;for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),o=r.itemSize;for(let e=0;e<o;e++)a+=`${Math.trunc(r[d[e]](i)*m+h)},`}if(a in n)u.push(n[a]);else{for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),a=e.morphAttributes[n],u=r.itemSize,p=c[n],m=l[n];for(let e=0;e<u;e++){let t=d[e],n=f[e];if(p[n](o,r[t](i)),a)for(let e=0,r=a.length;e<r;e++)m[e][n](o,a[e][t](i))}}n[a]=o,u.push(o),o++}}let g=e.clone();for(let t in e.attributes){let e=c[t];if(g.setAttribute(t,new e.constructor(e.array.slice(0,o*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){let n=l[t][e];g.morphAttributes[t][e]=new n.constructor(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return g.setIndex(u),g}function N(e,t=Math.PI/3){let n=e.index?e.toNonIndexed():e,i=n.attributes.position,a=i.count,o;if(i.isBufferAttribute===!0&&i.itemSize===3&&i.normalized===!1)o=i.array;else{o=new Float64Array(a*3);for(let e=0;e<a;e++)o[3*e+0]=i.getX(e),o[3*e+1]=i.getY(e),o[3*e+2]=i.getZ(e)}let s=Math.cos(t),c=(1+1e-10)*100,l=a/3,u=new Float64Array(l*3);for(let e=0;e<l;e++){let t=9*e,n=o[t+0],r=o[t+1],i=o[t+2],a=o[t+3],s=o[t+4],c=o[t+5],l=o[t+6],d=o[t+7],f=o[t+8],p=l-a,m=d-s,h=f-c,g=n-a,_=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);u[3*e+0]=y*S,u[3*e+1]=b*S,u[3*e+2]=x*S}let d=new Int32Array(a),f=new Float64Array(a*3),p=1;for(;p<a*2;)p<<=1;let m=p-1,h=new Int32Array(p),g=0;for(let e=0;e<a;e++){let t=3*e,n=Math.trunc(o[t+0]*c),r=Math.trunc(o[t+1]*c),i=Math.trunc(o[t+2]*c),a=(Math.imul(n,73856093)^Math.imul(r,19349663)^Math.imul(i,83492791))&m;for(;;){let t=h[a];if(t===0){let t=3*g;f[t+0]=n,f[t+1]=r,f[t+2]=i,h[a]=g+1,d[e]=g++;break}let o=3*(t-1);if(f[o+0]===n&&f[o+1]===r&&f[o+2]===i){d[e]=t-1;break}a=a+1&m}}let _=new Int32Array(g+1);for(let e=0;e<a;e++)_[d[e]+1]++;for(let e=0;e<g;e++)_[e+1]+=_[e];let v=new Int32Array(a),y=_.slice(0,g);for(let e=0;e<l;e++){let t=3*e;v[y[d[t+0]]++]=e,v[y[d[t+1]]++]=e,v[y[d[t+2]]++]=e}let b=new Float32Array(a*3);for(let e=0;e<l;e++){let t=3*e,n=u[t+0],r=u[t+1],i=u[t+2];for(let e=0;e<3;e++){let a=t+e,o=d[a],c=0,l=0,f=0;for(let e=_[o],t=_[o+1];e<t;e++){let t=3*v[e],a=u[t+0],o=u[t+1],d=u[t+2];n*a+r*o+i*d>s&&(c+=a,l+=o,f+=d)}let p=1/(Math.sqrt(c*c+l*l+f*f)||1);b[3*a+0]=c*p,b[3*a+1]=l*p,b[3*a+2]=f*p}}return n.setAttribute(`normal`,new r(b,3,!1)),n}var P=p,F=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02`,I=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/balls/2020/07`,te=class extends c{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,r){let i=this,o=new a(i.manager);o.setPath(i.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(t){let n=this,i=new d(this.manager);function a(t){let n=null,r=null,i,a,o=[],c=[],l,u={},d={},f={},p=new TextDecoder;try{n=e(new Uint8Array(t))}catch(e){if(e instanceof ReferenceError)return console.error(`THREE.3MFLoader: fflate missing and file is compressed.`),null}let m=null;for(r in n)r.match(/\_rels\/.rels$/)?i=r:r.match(/3D\/_rels\/.*\.model\.rels$/)?a=r:r.match(/^3D\/[^\/]*\.model$/)?m=r:r.match(/^3D\/.*\/.*\.model$/)?o.push(r):r.match(/^3D\/Textures?\/.*/)&&c.push(r);if(o.push(m),i===void 0)throw Error("THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.");let h=n[i],g=s(p.decode(h));if(a){let e=n[a];l=s(p.decode(e))}for(let e=0;e<o.length;e++){let t=o[e],r=n[t],i=p.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 l=G(s);l.xml=s,0<Object.keys(c).length&&(l.extensions=c),u[t]=l}for(let e=0;e<c.length;e++){let t=c[e];f[t]=n[t].buffer}return{rels:g,modelRels:l,model:u,printTicket:d,texture:f}}function s(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 l(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 f(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=ne(r);i.index=e,t.basematerials.push(i)}return t}function p(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 j(e){let t={id:e.getAttribute(`id`),displaypropertiesid:e.getAttribute(`displaypropertiesid`)},n=e.querySelectorAll(`color`),r=[],i=new h;for(let e=0;e<n.length;e++){let t=n[e].getAttribute(`color`);i.setStyle(t.substring(0,7),P),r.push(i.r,i.g,i.b)}return t.colors=new Float32Array(r),t}function M(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 N(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`]=M(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)]=M(e[t]);r[n.identifier]=n}}return t.operations=r,t}function te(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 ne(e){let t={};return t.name=e.getAttribute(`name`),t.displaycolor=e.getAttribute(`displaycolor`),t.displaypropertiesid=e.getAttribute(`displaypropertiesid`),t}function L(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(F,`beamlattice`)[0];return s!==void 0&&(t.beamlattice=R(s)),t}function R(e){let t={radius:parseFloat(e.getAttribute(`radius`)),minLength:parseFloat(e.getAttribute(`minlength`)),cap:e.getAttribute(`cap`)||`sphere`,ballMode:e.getAttributeNS(I,`ballmode`)||`none`,ballRadius:parseFloat(e.getAttributeNS(I,`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(F,`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(I,`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 z(e){let t=[],n=e.querySelectorAll(`component`);for(let e=0;e<n.length;e++){let r=n[e],i=B(r);t.push(i)}return t}function B(e){let t={};t.objectId=e.getAttribute(`objectid`);let n=e.getAttribute(`transform`);return n&&(t.transform=V(n)),t}function V(e){let t=[];e.split(` `).forEach(function(e){t.push(parseFloat(e))});let n=new w;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 H(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=L(c));let l=e.querySelector(`components`);return l&&(t.components=z(l)),t}function U(e){let t={};t.basematerials={};let n=e.querySelectorAll(`basematerials`);for(let e=0;e<n.length;e++){let r=n[e],i=f(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=p(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=j(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=N(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=te(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=H(n);t.object[r.id]=r}return t}function W(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=V(a)),t.push(i)}return t}function G(e){let t={unit:e.getAttribute(`unit`)||`millimeter`},n=e.querySelectorAll(`metadata`);n&&(t.metadata=l(n));let r=e.querySelector(`resources`);r&&(t.resources=U(r));let i=e.querySelector(`build`);return i&&(t.build=W(i)),t}function K(e,t,n,r){let a=e.texid,s=n.resources.texture2d[a];if(s){let e=r[s.path],t=s.contenttype,n=new Blob([e],{type:t}),a=URL.createObjectURL(n),c=i.load(a,function(){URL.revokeObjectURL(a)});switch(c.colorSpace=P,s.tilestyleu){case`wrap`:c.wrapS=_;break;case`mirror`:c.wrapS=C;break;case`none`:case`clamp`:c.wrapS=g;break;default:c.wrapS=_}switch(s.tilestylev){case`wrap`:c.wrapT=_;break;case`mirror`:c.wrapT=C;break;case`none`:case`clamp`:c.wrapT=g;break;default:c.wrapT=_}switch(s.filter){case`auto`:c.magFilter=m,c.minFilter=o;break;case`linear`:c.magFilter=m,c.minFilter=m,c.generateMipmaps=!1;break;case`nearest`:c.magFilter=y,c.minFilter=y,c.generateMipmaps=!1;break;default:c.magFilter=m,c.minFilter=o}return c}return null}function q(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 l=Object.keys(c),d=[];for(let t=0,s=l.length;t<s;t++){let s=l[t],f=c[s],p=e.basematerials[s],m=Q(p,r,i,a,o,ce),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 u(g,3));let v=new b(h,m);d.push(v)}return d}function J(e,t,n,r,i,a,o){let s=new T,c=[],l=[],d=n.vertices,f=e.uvs;for(let e=0,n=t.length;e<n;e++){let n=t[e];c.push(d[n.v1*3+0]),c.push(d[n.v1*3+1]),c.push(d[n.v1*3+2]),c.push(d[n.v2*3+0]),c.push(d[n.v2*3+1]),c.push(d[n.v2*3+2]),c.push(d[n.v3*3+0]),c.push(d[n.v3*3+1]),c.push(d[n.v3*3+2]),l.push(f[n.p1*2+0]),l.push(f[n.p1*2+1]),l.push(f[n.p2*2+0]),l.push(f[n.p2*2+1]),l.push(f[n.p3*2+0]),l.push(f[n.p3*2+1])}s.setAttribute(`position`,new u(c,3)),s.setAttribute(`uv`,new u(l,2));let p=Q(e,r,i,a,o,K),m=new S({map:p,flatShading:!0});return new b(s,m)}function Y(e,t,n,r){let i=new T,a=[],o=[],s=n.vertices,c=e.colors;for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.v1,l=n.v2,u=n.v3;a.push(s[i*3+0]),a.push(s[i*3+1]),a.push(s[i*3+2]),a.push(s[l*3+0]),a.push(s[l*3+1]),a.push(s[l*3+2]),a.push(s[u*3+0]),a.push(s[u*3+1]),a.push(s[u*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;o.push(c[d*3+0]),o.push(c[d*3+1]),o.push(c[d*3+2]),o.push(c[f*3+0]),o.push(c[f*3+1]),o.push(c[f*3+2]),o.push(c[p*3+0]),o.push(c[p*3+1]),o.push(c[p*3+2])}i.setAttribute(`position`,new u(a,3)),i.setAttribute(`color`,new u(o,3));let l=new S({vertexColors:!0,flatShading:!0});return new b(i,l)}function X(e){let t=new T;t.setIndex(new r(e.triangles,1)),t.setAttribute(`position`,new r(e.vertices,3));let n=new S({name:c.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new b(t,n)}function Z(e){let t=e.beamlattice,n=e.vertices,r=[],i=new O,a=new O,o=new O,s=new O(0,1,0),l=new v,u=new w,d=t.beams,f=t.cap!==`butt`,p=/* @__PURE__ */ new Map;for(let e=0;e<d.length;e++){let c=d[e];i.fromArray(n,c.v1*3),a.fromArray(n,c.v2*3);let m=i.distanceTo(a);if(m<t.minLength)continue;let h=c.r1===void 0?t.radius:c.r1,g=c.r2===void 0?h:c.r2,_=new x(g,h,m,8,1,f);o.subVectors(a,i).divideScalar(m),l.setFromUnitVectors(s,o),u.makeRotationFromQuaternion(l),u.setPosition(i.add(a).multiplyScalar(.5)),_.applyMatrix4(u),r.push(_),f&&(p.set(c.v1,Math.max(h,p.get(c.v1)||0)),p.set(c.v2,Math.max(g,p.get(c.v2)||0))),t.ballMode===`all`&&(p.set(c.v1,Math.max(t.ballRadius,p.get(c.v1)||0)),p.set(c.v2,Math.max(t.ballRadius,p.get(c.v2)||0)))}let m=t.balls;for(let e=0;e<m.length;e++){let n=m[e],r=n.r===void 0?t.ballRadius:n.r;p.set(n.vindex,Math.max(r,p.get(n.vindex)||0))}for(let[e,t]of p){let a=new ee(t,8,6);i.fromArray(n,e*3),a.translate(i.x,i.y,i.z),r.push(a)}let h=A(r),g=new S({name:c.DEFAULT_MATERIAL_NAME,color:16777215});return new b(h,g)}function re(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(ie(l,r)){case`material`:let e=r.resources.basematerials[l],o=q(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(J(c,u,t,n,r,i,a));break;case`vertexColors`:let d=r.resources.colorgroup[l];s.push(Y(d,u,t,a));break;case`default`:s.push(X(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 ie(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 ae(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 oe(e,t,n,r,i){let a=new D,o=re(ae(e,i),e,t,n,r,i);if(e.beamlattice!==void 0){let t=Z(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 se(e,t,r){if(!e)return;let i=[],a=Object.keys(e);for(let e=0;e<a.length;e++){let t=a[e];for(let e=0;e<n.availableExtensions.length;e++){let r=n.availableExtensions[e];r.ns===t&&i.push(r)}}for(let n=0;n<i.length;n++){let a=i[n];a.apply(r,e[a.ns],t)}}function Q(e,t,n,r,i,a){return e.build===void 0&&(e.build=a(e,t,n,r,i)),e.build}function ce(e,t,n){let r,i=e.displaypropertiesid,a=n.resources.pbmetallicdisplayproperties;if(i!==null&&a[i]!==void 0){let t=a[i].data[e.index];r=new E({flatShading:!0,roughness:t.roughness,metalness:t.metallicness})}else r=new S({flatShading:!0});r.name=e.name;let o=e.displaycolor,s=o.substring(0,7);return r.color.setStyle(s,P),o.length===9&&(r.opacity=parseInt(o.charAt(7)+o.charAt(8),16)/255),r}function le(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&&($(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 $(e,t,n,r){let i=n.resources.object[e];if(i.mesh){let e=i.mesh,a=n.extensions,o=n.xml;se(a,e,o),t[i.id]=Q(e,t,n,r,i,oe)}else{let e=i.components;t[i.id]=Q(e,t,n,r,i,le)}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];$(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=a(t);return fe(ue(pe),pe)}addExtension(e){this.availableExtensions.push(e)}},ne=/^[og]\s*(.+)?/,L=/^mtllib /,R=/^usemtl /,z=/^usemap /,B=/\s+/,V=new O,H=new O,U=new O,W=new O,G=new O,K=new h;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,o=new a(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.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
2
|
`)!==-1&&(e=e.replace(/\r\n/g,`
|
|
3
3
|
`)),e.indexOf(`\\
|
|
4
4
|
`)!==-1&&(e=e.replace(/\\\n/g,``));let r=e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=.1,t=[1,0,0,0,1,0,0,0,1],n=e=>e*Math.PI/180,r=e=>{let t=n(e),r=e=>Math.abs(e)<1e-12?0:Math.abs(Math.abs(e)-1)<1e-12?Math.sign(e):e;return[r(Math.cos(t)),r(Math.sin(t))]},i=e=>{let[t,n]=r(e);return[1,0,0,0,t,-n,0,n,t]},a=e=>{let[t,n]=r(e);return[t,0,n,0,1,0,-n,0,t]},o=e=>{let[t,n]=r(e);return[t,-n,0,n,t,0,0,0,1]};function s(e,t){let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[r*3+i]=e[r*3]*t[i]+e[r*3+1]*t[3+i]+e[r*3+2]*t[6+i];return n}var c=(e,[t,n,r])=>[e[0]*t+e[1]*n+e[2]*r,e[3]*t+e[4]*n+e[5]*r,e[6]*t+e[7]*n+e[8]*r];function l([e,n,r]){let a=Math.hypot(e,n,r)||1;if([e,n,r]=[e/a,n/a,r/a],r<-1+1e-9)return t.slice();if(r>1-1e-9)return i(180);let o=Math.hypot(e,n),[s,c]=[-n/o,e/o],l=-r,u=Math.sqrt(1-l*l),d=1-l;return[d*s*s+l,d*s*c,u*c,d*s*c,d*c*c+l,-u*s,-u*c,u*s,l]}function u(e,t,n){let r=o(e.spin),i=c(r,t);return{A:s(r,e.orient),t:[n[0]+e.x-i[0],n[1]+e.y-i[1],-i[2]]}}var d=(e,t,n)=>s(o(-t),s(n,s(o(t),e)));function f(e){let t=e.slice().sort((e,t)=>e[0]-t[0]||e[1]-t[1]);if(t.length<3)return t;let n=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),r=[],i=[];for(let e of t){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(let e=t.length-1;e>=0;e--){let r=t[e];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return r.slice(0,-1).concat(i.slice(0,-1))}function p(e,t){let[n,r,i,a,o,s,c,l,u]=t,d=e.length/3,p=new Float64Array(d),m=new Float64Array(d),h=1/0,g=-1/0,_=1/0,v=-1/0,y=1/0,b=-1/0;for(let t=0;t<d;t++){let d=e[t*3],f=e[t*3+1],x=e[t*3+2],S=n*d+r*f+i*x,C=a*d+o*f+s*x,w=c*d+l*f+u*x;p[t]=S,m[t]=C,S<h&&(h=S),S>g&&(g=S),C<_&&(_=C),C>v&&(v=C),w<y&&(y=w),w>b&&(b=w)}let x=(h+g)/2,S=(_+v)/2,C=Array(d);for(let e=0;e<d;e++)C[e]=[p[e]-x,m[e]-S];return{hull:f(C),size:[g-h,v-_,b-y],shift:[x,S,y]}}function m(e,t,n,i){let[a,o]=r(t);return e.map(([e,t])=>[n+e*a-t*o,i+e*o+t*a])}var h=e=>{let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let[a,o]of e)a<t&&(t=a),a>n&&(n=a),o<r&&(r=o),o>i&&(i=o);return[t,r,n,i]},g={outline:[[0,0],[256,0],[256,256],[0,256]],exclude:[],height:256};function _(e){let t=e&&Array.isArray(e.outline)&&e.outline.length>=3,n=t?e.outline:g.outline,r=h(n);return{outline:n,exclude:t&&Array.isArray(e.exclude)?e.exclude.filter(e=>e.length>=3):[],height:t&&e.height>0?e.height:g.height,box:r,center:[(r[0]+r[2])/2,(r[1]+r[3])/2],standIn:!t}}function v([e,t],n){let r=!1;for(let i=0,a=n.length-1;i<n.length;a=i++){let[o,s]=n[i],[c,l]=n[a];s>t!=l>t&&e<(c-o)*(t-s)/(l-s)+o&&(r=!r)}return r}function y([e,t],[n,r],[i,a]){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-n-l*o,t-r-l*s)}var b=e=>e.map((t,n)=>[t,e[(n+1)%e.length]]),x=(e,t,n)=>b(t).some(([t,r])=>y(e,t,r)<=n);function S([e,t],[n,r]){let i=(e,t,n)=>Math.sign((t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])),a=(e,t,n)=>Math.min(e[0],n[0])<=t[0]&&t[0]<=Math.max(e[0],n[0])&&Math.min(e[1],n[1])<=t[1]&&t[1]<=Math.max(e[1],n[1]),o=i(e,t,n),s=i(e,t,r),c=i(n,r,e),l=i(n,r,t);return o!==s&&c!==l||o===0&&a(e,n,t)||s===0&&a(e,r,t)||c===0&&a(n,e,r)||l===0&&a(n,t,r)}function C(e,t){if(!e.length||!t.length)return!1;let[n,r,i,a]=h(e),[o,s,c,l]=h(t);if(i<o||c<n||a<s||l<r)return!1;if(v(e[0],t)||v(t[0],e))return!0;let u=b(t);return b(e).some(e=>u.some(t=>S(e,t)))}function w(e,t){if(C(e,t))return 0;let n=1/0;for(let r of e)for(let[e,i]of b(t))n=Math.min(n,y(r,e,i));for(let r of t)for(let[t,i]of b(e))n=Math.min(n,y(r,t,i));return n}function T(t,n,r){return n>r.height+e?`tall`:t.some(t=>!v(t,r.outline)&&!x(t,r.outline,e))?`outside`:r.exclude.some(e=>C(t,e))?`excluded`:null}
|
|
1
|
+
var e=.1,t=[1,0,0,0,1,0,0,0,1],n=e=>e*Math.PI/180,r=e=>{let t=n(e),r=e=>Math.abs(e)<1e-12?0:Math.abs(Math.abs(e)-1)<1e-12?Math.sign(e):e;return[r(Math.cos(t)),r(Math.sin(t))]},i=e=>{let[t,n]=r(e);return[1,0,0,0,t,-n,0,n,t]},a=e=>{let[t,n]=r(e);return[t,0,n,0,1,0,-n,0,t]},o=e=>{let[t,n]=r(e);return[t,-n,0,n,t,0,0,0,1]};function s(e,t){let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[r*3+i]=e[r*3]*t[i]+e[r*3+1]*t[3+i]+e[r*3+2]*t[6+i];return n}var c=(e,[t,n,r])=>[e[0]*t+e[1]*n+e[2]*r,e[3]*t+e[4]*n+e[5]*r,e[6]*t+e[7]*n+e[8]*r];function l([e,n,r]){let a=Math.hypot(e,n,r)||1;if([e,n,r]=[e/a,n/a,r/a],r<-1+1e-9)return t.slice();if(r>1-1e-9)return i(180);let o=Math.hypot(e,n),[s,c]=[-n/o,e/o],l=-r,u=Math.sqrt(1-l*l),d=1-l;return[d*s*s+l,d*s*c,u*c,d*s*c,d*c*c+l,-u*s,-u*c,u*s,l]}function u(e,t,n){let r=o(e.spin),i=c(r,t);return{A:s(r,e.orient),t:[n[0]+e.x-i[0],n[1]+e.y-i[1],-i[2]]}}var d=(e,t,n)=>s(o(-t),s(n,s(o(t),e)));function f(e){let t=e.slice().sort((e,t)=>e[0]-t[0]||e[1]-t[1]);if(t.length<3)return t;let n=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),r=[],i=[];for(let e of t){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(let e=t.length-1;e>=0;e--){let r=t[e];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return r.slice(0,-1).concat(i.slice(0,-1))}function p(e,t){let[n,r,i,a,o,s,c,l,u]=t,d=e.length/3,p=new Float64Array(d),m=new Float64Array(d),h=1/0,g=-1/0,_=1/0,v=-1/0,y=1/0,b=-1/0;for(let t=0;t<d;t++){let d=e[t*3],f=e[t*3+1],x=e[t*3+2],S=n*d+r*f+i*x,C=a*d+o*f+s*x,w=c*d+l*f+u*x;p[t]=S,m[t]=C,S<h&&(h=S),S>g&&(g=S),C<_&&(_=C),C>v&&(v=C),w<y&&(y=w),w>b&&(b=w)}let x=(h+g)/2,S=(_+v)/2,C=Array(d);for(let e=0;e<d;e++)C[e]=[p[e]-x,m[e]-S];return{hull:f(C),size:[g-h,v-_,b-y],shift:[x,S,y]}}function m(e,t,n,i){let[a,o]=r(t);return e.map(([e,t])=>[n+e*a-t*o,i+e*o+t*a])}var h=e=>{let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let[a,o]of e)a<t&&(t=a),a>n&&(n=a),o<r&&(r=o),o>i&&(i=o);return[t,r,n,i]},g={outline:[[0,0],[256,0],[256,256],[0,256]],exclude:[],height:256};function _(e){let t=e&&Array.isArray(e.outline)&&e.outline.length>=3,n=t?e.outline:g.outline,r=h(n);return{outline:n,exclude:t&&Array.isArray(e.exclude)?e.exclude.filter(e=>e.length>=3):[],height:t&&e.height>0?e.height:g.height,box:r,center:[(r[0]+r[2])/2,(r[1]+r[3])/2],standIn:!t}}function v([e,t],n){let r=!1;for(let i=0,a=n.length-1;i<n.length;a=i++){let[o,s]=n[i],[c,l]=n[a];s>t!=l>t&&e<(c-o)*(t-s)/(l-s)+o&&(r=!r)}return r}function y([e,t],[n,r],[i,a]){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-n-l*o,t-r-l*s)}var b=e=>e.map((t,n)=>[t,e[(n+1)%e.length]]),x=(e,t,n)=>b(t).some(([t,r])=>y(e,t,r)<=n);function S([e,t],[n,r]){let i=(e,t,n)=>Math.sign((t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])),a=(e,t,n)=>Math.min(e[0],n[0])<=t[0]&&t[0]<=Math.max(e[0],n[0])&&Math.min(e[1],n[1])<=t[1]&&t[1]<=Math.max(e[1],n[1]),o=i(e,t,n),s=i(e,t,r),c=i(n,r,e),l=i(n,r,t);return o!==s&&c!==l||o===0&&a(e,n,t)||s===0&&a(e,r,t)||c===0&&a(n,e,r)||l===0&&a(n,t,r)}function C(e,t){if(!e.length||!t.length)return!1;let[n,r,i,a]=h(e),[o,s,c,l]=h(t);if(i<o||c<n||a<s||l<r)return!1;if(v(e[0],t)||v(t[0],e))return!0;let u=b(t);return b(e).some(e=>u.some(t=>S(e,t)))}function w(e,t){if(C(e,t))return 0;let n=1/0;for(let r of e)for(let[e,i]of b(t))n=Math.min(n,y(r,e,i));for(let r of t)for(let[t,i]of b(e))n=Math.min(n,y(r,t,i));return n}function T(t,n,r){return n>r.height+e?`tall`:t.some(t=>!v(t,r.outline)&&!x(t,r.outline,e))?`outside`:r.exclude.some(e=>C(t,e))?`excluded`:null}var E=(e,t)=>!C(e,t.outline);function D(e,t){let n={};for(let r of e){let e=E(r.points,t);n[r.id]={problem:e?null:T(r.points,r.height,t),overlap:!1,away:e}}let r=e.filter(e=>!n[e.id].away);for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++)C(r[e].points,r[t].points)&&(n[r[e].id].overlap=n[r[t].id].overlap=!0);return n}function O(t,n,r,i,a){let[o,s,c,l]=n,[u,d,f,p]=r.box;if(o<u-e||s<d-e||c>f+e||l>p+e)return!1;for(let e of i){let[n,r,i,u]=e.box;if(!(c+a<=n||i+a<=o||l+a<=r||u+a<=s)&&w(t,e.points)<a)return!1}return T(t,0,r)===null}var k=e=>e.map(e=>({points:e,box:h(e)}));function A(t,n,r,i,a=6){let o=m(t,n,0,0),[s,c,l,u]=h(o),[d,f]=i.center,[p,g,_,v]=i.box,y=k(r),b=[];for(let t=p-s;t<=_-l+e;t+=5)for(let n=g-c;n<=v-u+e;n+=5)b.push([t,n]);b.push([d,f]),b.sort((e,t)=>Math.hypot(e[0]-d,e[1]-f)-Math.hypot(t[0]-d,t[1]-f));for(let[e,t]of b)if(O(o.map(([n,r])=>[n+e,r+t]),[s+e,c+t,l+e,u+t],i,y,a))return{x:e-d,y:t-f};return null}function j(t,n,r=6){let[i,a,o,s]=n.box,c=t.map(e=>{let t=m(e.points,e.spin,0,0),[n,r,i,a]=h(t);return{...e,turned:t,w:i-n,d:a-r,ox:(n+i)/2,oy:(r+a)/2}}).sort((e,t)=>t.d-e.d||t.w-e.w),l=[],u=null,d=a,f=[];for(let t of c)u&&u.x+t.w>o+e&&(d+=u.d+r,u=null),u||={y:d,x:i,d:0,items:[]},d+t.d>s+e||t.w>o-i+e?f.push(t):(u.items.push({item:t,x:u.x}),u.x+=t.w+r,u.d=Math.max(u.d,t.d),l.includes(u)||l.push(u));let p=l.flatMap(e=>e.items.map(({item:t,x:n})=>({item:t,cx:n+t.w/2,cy:e.y+t.d/2})));if(p.length){let[e,t,n,r]=h(p.flatMap(e=>[[e.cx-e.item.w/2,e.cy-e.item.d/2],[e.cx+e.item.w/2,e.cy+e.item.d/2]])),c=(i+o)/2-(e+n)/2,l=(a+s)/2-(t+r)/2;for(let e of p)e.cx+=c,e.cy+=l}let g={},_=[];for(let e of p){let t=e.cx-e.item.ox,i=e.cy-e.item.oy,a=e.item.turned.map(([e,n])=>[e+t,n+i]);O(a,h(a),n,k(_),r/2)?(g[e.item.id]={x:t-n.center[0],y:i-n.center[1]},_.push(a)):f.push(e.item)}let v=[];for(let e of f){let t=A(e.points,e.spin,_,n,r);t?(g[e.id]=t,_.push(m(e.points,e.spin,n.center[0]+t.x,n.center[1]+t.y))):v.push(e.id)}return{positions:g,overflow:v}}export{A as a,u as c,D as d,i as f,d as h,_ as i,E as l,l as m,c as n,p as o,a as p,j as r,s,t,m as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as e}from"./files-YWgqYMU_.js";import{A as t,j as n}from"./three.core-BHZv2AuD.js";import{a as r,i,n as a,r as o}from"./model-read-TEBI4aDG.js";var s=Math.PI/6,c=3e5;function l(e){e.updateMatrixWorld(!0);let t=[];if(e.traverse(e=>{if(!e.isMesh)return;let r=new n().setAttribute(`position`,e.geometry.attributes.position.clone());e.geometry.index&&(r=r.setIndex(e.geometry.index.clone()).toNonIndexed()),r.applyMatrix4(e.matrixWorld),t.push(r)}),!t.length)throw Error(`no mesh in this file`);let r=i(t.length===1?t[0]:o(t),1e-4),a=r.index.array;return{positions:Float32Array.from(r.attributes.position.array),index:Uint32Array.from(a),triangles:a.length/3}}function u({positions:e,index:i,triangles:a}){let o=new n;if(o.setAttribute(`position`,new t(e,3)),o.setIndex(new t(i,1)),a>c)return{geometry:o,flat:!0};let l=r(o,s);return o.dispose(),{geometry:l,flat:!1}}async function d(t){let n=await a(t,e(t.name).format);try{return l(n)}finally{n.traverse(e=>e.geometry?.dispose())}}export{u as drawable,d as loadMesh};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as e}from"./files-YWgqYMU_.js";import{E as t,St as n,Xt as r,ea as i,kr as a,ro as o,tr as s}from"./three.core-BHZv2AuD.js";import{t as c}from"./three.module-CQAbjdTy.js";import{n as l,t as u}from"./model-read-TEBI4aDG.js";var d=224,f=new o(-.45,-1,.75).normalize(),p=30,m=null;async function h(h){let{format:g}=e(h.name);if(g===`step`||g===`iges`)return null;let _;try{_=await l(h,g)}catch{return null}u(_);let v=new t().setFromObject(_),y=v.getSize(new o),b=v.getCenter(new o),x=Math.max(1,y.length()/2)/Math.sin(s.degToRad(p/2)),S=new a(p,1,x/100,x*3);S.up.set(0,0,1),S.position.copy(b).addScaledVector(f,x),S.lookAt(b);let C=new i,w=new r(`#ffffff`,`#b0b1b6`,1.5);w.position.set(0,0,1);let T=new n(`#ffffff`,1.1);T.position.copy(b).add(new o(-150,-300,400)),T.target.position.copy(b),C.add(w,T,T.target,_),m||(m=new c({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}),m.setSize(d,d,!1),m.setClearColor(0,0)),m.render(C,S);let E=await new Promise(e=>m.domElement.toBlob(e,`image/png`));return _.traverse(e=>e.geometry?.dispose()),E&&{url:URL.createObjectURL(E),size:y.toArray()}}export{h as renderThumbnail};
|