slicer-studio 0.6.0 → 0.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicer-studio",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "A 3D printing studio as one custom element: customers upload models and see the price, staff slice and inspect the G-code, on any page.",
5
5
  "keywords": [
6
6
  "3d-printing",
@@ -1 +0,0 @@
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,r as i,t as a}from"./tip-BR1chAbl.js";import{a as o,i as s,n as c,o as l,r as u}from"./view-Djv_nmDb.js";import{n as d}from"./plate-geometry-Dd9vKDEP.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-BoEG27Tx.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),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),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})})}function B({request:e}){let t=T(e=>e.camera),n=T(e=>e.controls),r=T(e=>e.invalidate);return(0,j.useEffect)(()=>{e&&n&&(t.position.fromArray(c(t.position.toArray(),n.target.toArray(),e.factor)),n.update(),r())},[e,n,t,r]),null}function V({label:e,pressed:t,disabled:n,onClick:i,children:o}){return/* @__PURE__ */ (0,N.jsx)(a,{label:e,children:/* @__PURE__ */ (0,N.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,disabled:n,onClick:i,className:r(`grid size-9 place-items-center rounded-xl text-ink transition-colors hover:bg-raise disabled:opacity-40`,t&&`bg-ink text-ink-contrast hover:bg-ink`),children:o})})}function H({bed:e,scene:t,meshes:n,selected:r,layMode:i,onSelect:a,onMove:c,onLay:d,onLayMode:f}){let p=w(),m=I(n),[h,g]=(0,j.useState)(null),[_,v]=(0,j.useState)({view:`iso`,key:0}),[y,T]=(0,j.useState)(null),[E,D,k,M]=e.box,P=Math.max(k-E,M-D,e.height),H=(0,j.useMemo)(()=>({min:[E,D,0],max:[k,M,Math.min(e.height,P/4)]}),[E,D,k,M,e.height,P]),U=t.filter(e=>e.problem).length,W=t.filter(e=>e.overlap).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:()=>{i||a(null)},children:[/* @__PURE__ */ (0,N.jsx)(`color`,{attach:`background`,args:[p.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:p}),/* @__PURE__ */ (0,N.jsx)(L,{exclude:e.exclude}),!e.standIn&&/* @__PURE__ */ (0,N.jsx)(R,{box:e.box,height:e.height,color:p.bedEdge}),t.filter(e=>e.loaded&&m[e.fileId]).map(e=>/* @__PURE__ */ (0,N.jsx)(z,{item:e,shape:m[e.fileId],selected:e.id===r,layMode:i,offset:h&&h.id===e.id?[h.dx,h.dy]:null,onSelect:a,onLay:d,onDrag:(e,t,n)=>g({id:e,dx:t,dy:n}),onDrop:(e,t,n)=>{g(null),c(e,t,n)}},e.id)),/* @__PURE__ */ (0,N.jsx)(b,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,N.jsx)(x,{bounds:H,far:20*P,view:_.view,fitKey:_.key}),/* @__PURE__ */ (0,N.jsx)(B,{request:y}),/* @__PURE__ */ (0,N.jsx)(u,{})]}),/* @__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)(`div`,{className:`flex items-center gap-0.5 rounded-2xl bg-panel/90 p-1 backdrop-blur`,children:[/* @__PURE__ */ (0,N.jsx)(V,{label:`Lay on face: click a face to stand the object on it`,pressed:i,disabled:!r,onClick:()=>f(!i),children:/* @__PURE__ */ (0,N.jsx)(O,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`mx-0.5 h-6 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Whole plate`,onClick:()=>v(e=>({view:`iso`,key:e.key+1})),children:/* @__PURE__ */ (0,N.jsx)(A,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(V,{label:`From above`,onClick:()=>v(e=>({view:`top`,key:e.key+1})),children:/* @__PURE__ */ (0,N.jsx)(l,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Zoom in`,onClick:()=>T({factor:.8}),children:/* @__PURE__ */ (0,N.jsx)(o,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Zoom out`,onClick:()=>T({factor:1.25}),children:/* @__PURE__ */ (0,N.jsx)(s,{className:`size-[18px]`,"aria-hidden":!0})})]})}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-14 z-10 flex flex-wrap gap-1.5 text-[12px]`,children:[i&&/* @__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:`rounded-full bg-panel/90 px-2.5 py-1 text-muted backdrop-blur`,children:`Bed size not known yet: a 256 mm stand-in`}),U>0&&/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`rounded-full px-2.5 py-1 text-white`,style:{background:F.problem},children:[U===1?`An object`:`${U} objects`,` can’t be printed there`]}),W>0&&/* @__PURE__ */ (0,N.jsx)(`span`,{className:`rounded-full px-2.5 py-1 text-ink`,style:{background:F.overlap},children:`Objects overlap`})]})]})}export{H as default};