slicer-studio 0.7.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/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 @@
|
|
|
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-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-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,transparent:e.away,opacity:e.away?.4:1,depthWrite:!e.away})})}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,G=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:()=>{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`}),G>0&&/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`rounded-full bg-panel/90 px-2.5 py-1 text-muted backdrop-blur`,children:[G===1?`An object is`:`${G} objects are`,` off the bed and won’t be sliced`]})]})]})}export{H as default};
|
|
@@ -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};
|