PageSourceSearch

https://wedraw.kr/assets/WoodPreview3D.CwaOxVkZ.js

js wedraw.kr collected 2026-10-04 07:44:36 UTC 57,469 bytes, 24 lines download raw bytes

1import{j as e}from"./vendor-ui.BwPBmVwt.js";import{r as J,b as Qe}from"./vendor-react.kR8tqwKZ.js";import{C as Je,aw as Ke,bZ as et,O as tt,b2 as $e,u as st,B as ce,aA as ve,ay as he,I as we,T as Ae,y as De,b_ as Ee,V as _,D as se,aC as xe,bd as ot,aD as ye,bY as Le,k as Xe,aE as je,g as _e,b$ as nt,ai as at,a7 as rt}from"./vendor-three.C5-HLXBy.js";import{U as Ve,V as Ye,C as it,a as ct,T as lt,r as ht,Q as pt,W as ut,X as dt,Y as mt,Z as ft}from"./processingFormatter.D21Evgig.js";import{n as gt}from"./woodCartConverter.CbGBTwwu.js";import{E as xt,B as Y,S as U}from"./Evaluator.DqK84_8_.js";import"./vendor-utils.D2q0l15H.js";function bt(c,n){const o=c.length;if(o<3)return new Array(o).fill(!1);let a=0;for(let l=0;l<o;l++){const B=c[l],r=c[(l+1)%o];a+=B.x*r.z-r.x*B.z}const s=a>=0?1:-1,f=1e-6,b=[];for(let l=0;l<o;l++){const B=c[(l-1+o)%o],r=c[l],X=c[(l+1)%o],W=r.x-B.x,T=r.z-B.z,I=X.x-r.x,V=X.z-r.z,k=W*V-T*I,C=Math.hypot(W,T)*Math.hypot(I,V),O=C>0?k/C:0;b.push(Math.abs(O)>f&&(O>=0?1:-1)!==s)}return b}const Oe=(c,n,o)=>{switch(o){case"minX":return c.x>=n.minX;case"maxX":return c.x<=n.maxX;case"minZ":return c.z>=n.minZ;case"maxZ":return c.z<=n.maxZ}},Re=(c,n,o,a)=>{if(a==="minX"||a==="maxX"){const b=a==="minX"?o.minX:o.maxX,l=(b-c.x)/(n.x-c.x);return{x:b,z:c.z+l*(n.z-c.z)}}const s=a==="minZ"?o.minZ:o.maxZ,f=(s-c.z)/(n.z-c.z);return{x:c.x+f*(n.x-c.x),z:s}};function Mt(c,n){if(c.length<3)return[];if(!(n.maxX>n.minX&&n.maxZ>n.minZ))return[];let o=c.slice();const a=o[0],s=o[o.length-1];Math.abs(a.x-s.x)<1e-12&&Math.abs(a.z-s.z)<1e-12&&(o=o.slice(0,-1));const f=["minX","maxX","minZ","maxZ"];for(const b of f){const l=o;if(o=[],l.length===0)break;for(let B=0;B<l.length;B++){const r=l[B],X=l[(B-1+l.length)%l.length],W=Oe(r,n,b),T=Oe(X,n,b);
1W?(T||o.push(Re(X,r,n,b)),o.push(r)):T&&o.push(Re(X,r,n,b))}}return o.length>=3?o:[]}function We(c,n,o,a){if(!(a>0))return null;const s=[it,ct,lt].map(r=>({id:r,item:c.find(X=>X.id===r||X.params?.type===r)})).filter(({item:r})=>!!r?.params);if(s.length===0)return null;const f=o/a,b=n/a,l=([r,X])=>[-n/2+r*a,o/2-X*a],B={cutters:[],outline:{},replacedFaces:[],removedCorners:[]};for(const{id:r,item:X}of s){const W=ht(r,X.params);B.cutters.push(...pt(W,f,b).map(I=>ut(I,f,b).map(l)));const T=dt(W,f,b);Object.keys(T).forEach(I=>{B.outline[I]=(T[I]||[]).map(l)}),B.replacedFaces.push(...mt(W,f,b)),B.removedCorners.push(...ft(W,f,b))}return B}const me="#A0A0A0",fe=.4;function jt(){const[c,n]=J.useState(!1);return J.useEffect(()=>{const o=()=>{n(window.innerWidth<768||"ontouchstart"in window)};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),c}function yt(c){const n=c.match(/(\d+\.?\d*)/);return n?parseFloat(n[1]):18}function vt(c){return c.includes("목봉")||c.includes("지름")}function Bt(c){const n=c.match(/지름\s*(\d+)/);return n?parseInt(n[1],10):10}function He(c,n,o){const a=c==="A"?n:o,s=c==="A"?o:n;if(a<300)return[];let f=0;if(s<450?a<1e3?f=2:a<1600?f=3:a<2e3?f=4:f=5:a<1e3?f=3:a<1600?f=4:f=5,f===5){const B=a/2,r=a-600;(B-600<300||r-B<300)&&(f=4)}if(f===4){const B=a-700;(B<=700||B-700<300)&&(f=3)}if(f===3){const B=a/2,r=a-100;(B-100<300||r-B<300)&&(f=2)}if(f===0)return[];const b=[];return f===2?b.push(100,a-100):f===3?b.push(100,a/2,a-100):f===4?b.push(100,700,a-700,a-100):f===5&&b.push(100,600,a/2,a-600,a-100),b.sort((l,B)=>l-B)}function Ct(c){const a=c-60;if(a<=0)return[];const s=Math.floor(a/600)+2,f=[];if(s>=2){const b=a/(s-1);for(let l=0;l<s;l++)f.push(30+l*b)}return f}function Ue(c){return new at({uniforms:{time:{value:0},color:{value:new rt(c)}},vertexShader:`
2      varying vec2 vUv;
3      void main() {
4        vUv = uv;
5        gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
6      }
7    `,fragmentShader:`
8      uniform float time;
9      uniform vec3 color;
10      varying vec2 vUv;
11      void main() {
12        // 빛이 U 방향으로 흐르는 효과 (튜브의 길이 방향)
13        float shimmer = smoothstep(0.0, 0.15, vUv.x - fract(time * 0.5))
14                      - smoothstep(0.15, 0.3, vUv.x - fract(time * 0.5));
15        shimmer = max(shimmer, 0.0);
16
17        // 기본 색상 + 쉬머 하이라이트
18        vec3 baseColor = color * 0.8;
19        vec3 finalColor = baseColor + vec3(1.0) * shimmer * 0.6;
20        float alpha = 0.9 + shimmer * 0.1;
21
22        gl_FragColor = vec4(finalColor, alpha);
23      }
24    `,transparent:!0})}function Ne({curve:c,color:n="#36583D",segments:o=64}){const a=J.useMemo(()=>Ue(n),[n]);return _e(s=>{a&&(a.uniforms.time.value=s.clock.elapsedTime)}),e.jsxs("mesh",{children:[e.jsx("tubeGeometry",{args:[c,o,.02,8,!1]}),e.jsx("primitive",{object:a,attach:"material"})]})}function Ce({start:c,end:n,color:o="#36583D"}){const a=J.useMemo(()=>new nt(c,n),[c,n]),s=J.useMemo(()=>Ue(o),[o]);return _e(f=>{s&&(s.uniforms.time.value=f.clock.elapsedTime)}),e.jsxs("mesh",{children:[e.jsx("tubeGeometry",{args:[a,2,.02,8,!1]}),e.jsx("primitive",{object:s,attach:"material"})]})}function Dt({position:c,scale:n}){const o=J.useRef(null);_e(b=>{if(o.current){const l=b.clock.elapsedTime,B=Math.sin(l*3)*.06+.1;o.current.position.y=c[1]+B}});const a=.15,s=.05,f=.025;return e.jsxs("group",{ref:o,position:c,children:[e.jsxs("mesh",{position:[0,a/2+s,0],children:[e.jsx("cylinderGeometry",{args:[f,f,a,16]}),e.jsx("meshStandardMaterial",{color:"#4a5568",metalness:.7,roughness:.3})]}),e.jsxs("mesh",{position:[0,s/2,0],rotation:[Math.PI,0,0],children:[e.jsx("coneGeometry",{args:[f,s,16]}),e.jsx("meshStandardMaterial",{color:"#718096",metalness:.8,roughness:.2})]})]})}function Pt({processing:c,w:n,h:o,d:a,scale:s,widthMm:f,lengthMm:b,showSanding:l=!1,markerRadius:B=.04}){const r=[],X=o/2+.002,W=k=>({fillColor:k?"#ef4444":"#36583D",fillOpacity:.4,borderColor:k?"#dc2626":"#36583D"}),T="#ef4444",I=.4,V="#dc2626";return c.forEach((k,C)=>{const{fillColor:O,fillOpacity:N,borderColor:re}=W(k.isPreview);switch(k.id){case"basic_circle":k.params?.processingItems&&k.params.processingItems.forEac
24h((g,P)=>{if(g.diameter>0){const M=g.diameter/2*s,x=-n/2+(g.positionA||0)*s,v=a/2-(g.positionB||0)*s,w=j=>{const t=[];for(let i=0;i<=64;i++){const d=i/64*Math.PI*2;t.push([x+M*Math.cos(d),j,v+M*Math.sin(d)])}return t};if(r.push(e.jsx(he,{points:w(o/2+.001),color:me,lineWidth:1,transparent:!0,opacity:fe},`basic-circle-top-${C}-${P}`)),r.push(e.jsxs("mesh",{position:[x,o/2+.002,v],rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[B,32]}),e.jsx("meshBasicMaterial",{color:"#36583D",side:se})]},`basic-circle-center-${C}-${P}`)),g.kind==="cutting")r.push(e.jsx(he,{points:w(-o/2-.001),color:me,lineWidth:1,transparent:!0,opacity:fe},`basic-circle-bottom-${C}-${P}`));else if(g.kind==="pocket"){const j=Math.min((g.depth||5)*s,o-.005),t=o/2-j;r.push(e.jsxs("mesh",{position:[x,t+.001,v],rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[M,64]}),e.jsx("meshBasicMaterial",{color:O,side:se,transparent:!0,opacity:N})]},`basic-circle-pocket-fill-${C}-${P}`)),r.push(e.jsx(he,{points:w(t+.002),color:me,lineWidth:1,transparent:!0,opacity:fe},`basic-circle-pocket-bottom-${C}-${P}`))}}});break;case"basic_square":k.params?.processingItems&&k.params.processingItems.forEach((g,P)=>{const M=g.sizeC||g.width||0,x=g.sizeD||g.height||0;if(M>0&&x>0){const v=M*s,w=x*s,j=-n/2+(g.positionA||0)*s+v/2,t=a/2-(g.positionB||0)*s-w/2,h=i=>[[j-v/2,i,t-w/2],[j+v/2,i,t-w/2],[j+v/2,i,t+w/2],[j-v/2,i,t+w/2],[j-v/2,i,t-w/2]];if(r.push(e.jsx(he,{points:h(o/2+.001),color:me,lineWidth:1,transparent:!0,opacity:fe},`basic-square-top-${C}-${P}`)),r.push(e.jsxs("mesh",{position:[j-v/2,o/2+.002,t+w/2],rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[B,32]}),e.jsx("meshBasicMaterial",{color:"#36583D",side:se})]},`basic-square-origin-${C}-${P}`)),g.kind==="cutting")r.push(e.jsx(he,{points:h(-o/2-.001),color:me,lineWidth:1,transparent:!0,opacity:fe},`basic-square-bottom-${C}-${P}`));else if(g.kind==="pocket"){const i=Math.min((g.depth||5)*s,o-.005),d=o/2-i;r.push(e.jsxs("mesh",{position:[j,d+.001,t],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[v,w]}),e.jsx("meshBasicMaterial",{color:O,side:se,transparent:!0,opacity:N})]},`basic-square-pocket-fill-${C}-${P}`)),r.push(e.jsx(he,{points:h(d+.002),color:me,lineWidth:1,transparent:!0,opacity:fe},`basic-square-pocket-bottom-${C}-${P}`))}}});break;case"corner_rounding":break;case"sink_hinge_panel":if(k.params?.position){const D=17.5*s,g=13*s,P=k.params.position,M=Array.isArray(k.params?.hingePositions)?k.params.hingePositions:He(P,f,b),x=22*s;M.forEach((v,w)=>{let j,t;P==="A"?(j=-n/2+x,t=a/2-v*s):(j=-n/2+v*s,t=a/2-x);const h=o/2-g+.002;r.push(e.jsxs("mesh",{position:[j,h,t],rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[D,32]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.8})]},`hinge-shade-${C}-${w}`));const i=o/2+.002;r.push(e.jsxs("mesh",{position:[j,i,t],rotation:[-Math.PI/2,0,0],children:[e.jsx("ringGeometry",{args:[D-.003,D+.003,32]}),e.jsx("meshBasicMaterial",{color:re})]},`hinge-outline-${C}-${w}`))})}break;case"piece_drilling":{const D=4*s,P=o/s/2*s;(Array.isArray(k.params?.positions)?k.params.positions:k.params?.position?[k.params.position]:[]).forEach(x=>{Ct(x==="A"||x==="C"?f:b).forEach((t,h)=>{let i;switch(x){case"A":i=[-n/2+P,X,-a/2+t*s];break;case"B":i=[-n/2+t*s,X,-a/2+P];break;case"C":i=[n/2-P,X,-a/2+t*s];break;case"D":i=[-n/2+t*s,X,a/2-P];break;default:return}r.push(e.jsxs("mesh",{position:i,rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[D,16]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.9})]},`drilling-fill-${C}-${x}-${h}`)),r.push(e.jsxs("mesh",{position:[i[0],i[1]+.001,i[2]],rotation:[-Math.PI/2,0,0],children:[e.jsx("ringGeometry",{args:[D-.005,D,16]}),e.jsx("meshBasicMaterial",{color:re})]},`drilling-border-${C}-${x}-${h}`)),r.push(e.jsx(Dt,{position:i,scale:s},`drill-${C}-${x}-${h}`))})})}break;case"top-groove-panel":if(k.params?.position){const D=3*s,g=17*s;let P,M;switch(k.params.position){case"A":P=[-n/2+g+D/2,X,0],M=[D,a];break;case"B":P=[0,X,-a/2+g+D/2],M=[n,D];break;case"C":P=[n/2-g-D/2,X,0],M=[D,a];break;case"D":P=[0,X,a/2-g-D/2],M=[n,D];break;default:return}r.push(e.jsxs("mesh",{position:P,rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:M}),e.jsx("meshBasicMaterial",{color:O,side:se,transparent:!0,opacity:N})]},`groove-fill-${C}
24`)),r.push(e.jsxs("lineSegments",{position:[P[0],P[1]+.001,P[2]],rotation:[-Math.PI/2,0,0],children:[e.jsx("edgesGeometry",{args:[new Le(M[0],M[1])]}),e.jsx("lineBasicMaterial",{color:re})]},`groove-line-${C}`))}break;case"frame-cutting":if(k.params?.frameWidth){const D=k.params.frameWidth*s,g=n-D*2,P=a-D*2;r.push(e.jsxs("mesh",{position:[0,X,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[g,P]}),e.jsx("meshBasicMaterial",{color:O,side:se,transparent:!0,opacity:N})]},`frame-${C}`)),r.push(e.jsxs("lineSegments",{position:[0,X+.001,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("edgesGeometry",{args:[new Le(g,P)]}),e.jsx("lineBasicMaterial",{color:re,linewidth:2})]},`frame-line-${C}`))}break;case"sanding":if(!l)break;{const D=k.params?.faceSanding,g=k.params?.faceEdgeSanding,P=k.params?.sideSanding,M=.008,x=D==="both"||D==="all";if((D==="single"||D==="both"||D==="all")&&(r.push(e.jsxs("mesh",{position:[0,X,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[n-.02,a-.02]}),e.jsx("meshBasicMaterial",{color:T,side:se,transparent:!0,opacity:I})]},`sanding-top-${C}`)),x&&r.push(e.jsxs("mesh",{position:[0,-o/2-.002,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[n-.02,a-.02]}),e.jsx("meshBasicMaterial",{color:T,side:se,transparent:!0,opacity:I})]},`sanding-bottom-${C}`))),g&&(D==="single"||D==="both"||D==="all")){const v=M*2;r.push(e.jsxs("mesh",{position:[0,o/2,a/2],children:[e.jsx("boxGeometry",{args:[n,v,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-top-edge-front-${C}`),e.jsxs("mesh",{position:[0,o/2,-a/2],children:[e.jsx("boxGeometry",{args:[n,v,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-top-edge-back-${C}`),e.jsxs("mesh",{position:[-n/2,o/2,0],children:[e.jsx("boxGeometry",{args:[v,v,a]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-top-edge-left-${C}`),e.jsxs("mesh",{position:[n/2,o/2,0],children:[e.jsx("boxGeometry",{args:[v,v,a]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-top-edge-right-${C}`)),x&&r.push(e.jsxs("mesh",{position:[0,-o/2,a/2],children:[e.jsx("boxGeometry",{args:[n,v,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-bottom-edge-front-${C}`),e.jsxs("mesh",{position:[0,-o/2,-a/2],children:[e.jsx("boxGeometry",{args:[n,v,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-bottom-edge-back-${C}`),e.jsxs("mesh",{position:[-n/2,-o/2,0],children:[e.jsx("boxGeometry",{args:[v,v,a]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-bottom-edge-left-${C}`),e.jsxs("mesh",{position:[n/2,-o/2,0],children:[e.jsx("boxGeometry",{args:[v,v,a]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-bottom-edge-right-${C}`))}if(P){r.push(e.jsxs("mesh",{position:[0,0,a/2+.002],children:[e.jsx("planeGeometry",{args:[n-.02,o-.02]}),e.jsx("meshBasicMaterial",{color:T,side:se,transparent:!0,opacity:I})]},`sanding-side-front-${C}`)),r.push(e.jsxs("mesh",{position:[0,0,-a/2-.002],children:[e.jsx("planeGeometry",{args:[n-.02,o-.02]}),e.jsx("meshBasicMaterial",{color:T,side:se,transparent:!0,opacity:I})]},`sanding-side-back-${C}`)),r.push(e.jsxs("mesh",{position:[-n/2-.002,0,0],rotation:[0,Math.PI/2,0],children:[e.jsx("planeGeometry",{args:[a-.02,o-.02]}),e.jsx("meshBasicMaterial",{color:T,side:se,transparent:!0,opacity:I})]},`sanding-side-left-${C}`)),r.push(e.jsxs("mesh",{position:[n/2+.002,0,0],rotation:[0,Math.PI/2,0],children:[e.jsx("planeGeometry",{args:[a-.02,o-.02]}),e.jsx("meshBasicMaterial",{color:T,side:se,transparent:!0,opacity:I})]},`sanding-side-right-${C}`));const v=M*2;r.push(e.jsxs("mesh",{position:[-n/2,0,-a/2],children:[e.jsx("boxGeometry",{args:[v,o,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-vertical-edge-0-${C}`),e.jsxs("mesh",{position:[n/2,0,-a/2],children:[e.jsx("boxGeometry",{args:[v,o,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-vertical-edge-1-${C}`),e.jsxs("mesh",{position:[-n/2,0,a/2],children:[e.jsx("boxGeometry",{args:[v,o,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-vertical-edge-2-${C}`),e.jsxs("mesh",{position:[n/2,0,a/2],children:[e.jsx("boxGeometry",{args:[v,o,v]}),e.jsx("meshBasicMaterial",{color:V})]},`sanding-vertical-edge-3-${C}`))}}break;case"shape_cutting":{const D=k.params?.shapeType||"circle",g=k.params?.diameter?k.params.diameter*s:Math.min(n,a),P=k.params?.shapeWidth?k.params.shapeWidth*s:n,M=k.params?.shapeLength?k.params.shapeLength*s:a,x=64,v=o+.002,w=new xe;
24w.moveTo(-n/2,-a/2),w.lineTo(n/2,-a/2),w.lineTo(n/2,a/2),w.lineTo(-n/2,a/2),w.closePath();const j=new ot;if(D==="circle"){const h=g/2;for(let i=0;i<=x;i++){const d=i/x*Math.PI*2,u=h*Math.cos(d),p=h*Math.sin(d);i===0?j.moveTo(u,p):j.lineTo(u,p)}j.closePath()}else if(D==="oval"){for(let h=0;h<=x;h++){const i=h/x*Math.PI*2,d=M/2*Math.cos(i),u=P/2*Math.sin(i);h===0?j.moveTo(d,u):j.lineTo(d,u)}j.closePath()}else if(D==="roundbar"){const h=M/2,i=P/2;if(P>M){const u=Math.min(i,h);j.absarc(0,i-u,u,0,Math.PI,!1),j.lineTo(-u,-i+u),j.absarc(0,-i+u,u,Math.PI,Math.PI*2,!1),j.lineTo(u,i-u),j.closePath()}else{const u=Math.min(i,h);j.absarc(-h+u,0,u,Math.PI/2,Math.PI*1.5,!1),j.lineTo(h-u,-u),j.absarc(h-u,0,u,-Math.PI/2,Math.PI/2,!1),j.lineTo(-h+u,u),j.closePath()}}else if(D==="arch"){const h=M/2,i=P/2;if(P>M){const u=Math.min(i,h),p=u;j.moveTo(-p,-i),j.lineTo(p,-i),j.lineTo(p,i-u),j.absarc(0,i-u,u,0,Math.PI,!1),j.lineTo(-p,-i),j.closePath()}else{const u=Math.min(i,h),p=u;j.moveTo(-h,-p),j.lineTo(-h,p),j.lineTo(h-u,p),j.absarc(h-u,0,u,Math.PI/2,-Math.PI/2,!0),j.lineTo(-
24h,-p),j.closePath()}}w.holes.push(j);const t=new ye(w,{depth:v,bevelEnabled:!1});t.rotateX(-Math.PI/2),t.translate(0,-o/2,0),r.push(e.jsx("mesh",{geometry:t,children:e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:N,side:se})},`shape-cutaway-3d-${C}`))}break;case"edge_circle_cut":k.params?.edgeItems&&k.params.edgeItems.forEach((g,P)=>{const M=g.edge,x=g.spacing||0;if((g.diameter||0)<=0)return;const w=x*s;let j=0,t=0;switch(M){case"A":j=-n/2,t=a/2-w;break;case"B":j=-n/2+w,t=-a/2;break;case"C":j=n/2,t=a/2-w;break;case"D":j=-n/2+w,t=a/2;break;default:return}r.push(e.jsxs("mesh",{position:[j,o/2+.002,t],rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[B,32]}),e.jsx("meshBasicMaterial",{color:"#36583D",side:se})]},`edge-circle-center-${C}-${P}`))});break;case"edge_square_cut":k.params?.edgeItems&&k.params.edgeItems.forEach((g,P)=>{const M=g.edge,x=g.spacing||0,v=g.length||0,w=g.width||0;if(v<=0||w<=0)return;const j=x*s;let t=0,h=0;switch(M){case"A":t=-n/2,h=a/2-j;break;case"B":t=-n/2+j,h=-a/2;break;case"C":t=n/2,h=a/2-j;break;case"D":t=-n/2+j,h=a/2;break;default:return}r.push(e.jsxs("mesh",{position:[t,o/2+.002,h],rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[B,32]}),e.jsx("meshBasicMaterial",{color:"#36583D",side:se})]},`edge-square-ref-${C}-${P}`))});break;case"arch_cut":{const D=k.params||{},g=D.edge||"A",P=Number(D.archWidth)||0,M=Number(D.totalDepth)||0,x=(Number(D.spacing)||0)*s;if(P>0&&M>0){let v=0,w=0;switch(g){case"A":v=-n/2,w=a/2-x;break;case"B":v=-n/2+x,w=-a/2;break;case"C":v=n/2,w=a/2-x;break;case"D":v=-n/2+x,w=a/2;break}r.push(e.jsxs("mesh",{position:[v,o/2+.002,w],rotation:[-Math.PI/2,0,0],children:[e.jsx("circleGeometry",{args:[.04,32]}),e.jsx("meshBasicMaterial",{color:"#36583D",side:se})]},`arch-ref-${C}`))}break}case"edge_round_bevel":{const D=k.params?.direction||"both",g="#36583D",P=D==="top"||D==="both",M=D==="bottom"||D==="both",x=k.params?.blockedTopPositions||[],v=k.params?.blockedBottomPositions||[],w=["B","C","D","A"],j=c.find(p=>p.id==="corner_rounding"),t=j?.params&&(j.params.enableA||j.params.enableB||j.params.enableC||j.params.enableD),h=c.some(p=>p.id==="shape_cutting"),i=["corner_circle_cut","corner_square_cut","edge_circle_cut","edge_square_cut","arch_cut",...Ve],d=c.some(p=>i.includes(p.id));if(t||h||d){const p=Pe(n,o,a,c,s),y=p.length,z=bt(p);let S=0,$=0;for(;S<y-1;){if(z[S]||z[S+1]){S++;continue}const G=[p[S]];for(;S<y-1&&!z[S]&&!z[S+1];)G.push(p[S+1]),S++;const Z=Math.cos(Math.PI/9),ee=[[G[0]]];for(let F=1;F<G.length;F++)if(ee[ee.length-1].push(G[F]),F<G.length-1){const te=G[F-1],K=G[F],de=G[F+1],be=K.x-te.x,q=K.z-te.z,H=de.x-K.x,ie=de.z-K.z,L=Math.hypot(be,q)*Math.hypot(H,ie);(L>0?(be*H+q*ie)/L:1)<Z&&ee.push([K])}for(const F of ee){if(F.length>2){if(P){const te=new Ee(F.map(K=>new _(K.x,o/2,K.z)),!1);r.push(e.jsx(Ne,{curve:te,color:g,segments:Math.max(16,F.length*4)},`edge-round-top-run-${C}-${$}`))}if(M){const te=new Ee(F.map(K=>new _(K.x,-o/2,K.z)),!1);r.push(e.jsx(Ne,{curve:te,color:g,segments:Math.max(16,F.length*4)},`edge-round-bottom-run-${C}-${$}`))}}else if(F.length===2){const[te,K]=F;P&&r.push(e.jsx(Ce,{start:new _(te.x,o/2,te.z),end:new _(K.x,o/2,K.z),color:g},`edge-round-top-line-${C}-${$}`)),M&&r.push(e.jsx(Ce,{start:new _(te.x,-o/2,te.z),end:new _(K.x,-o/2,K.z),color:g},`edge-round-bottom-line-${C}-${$}`))}$++}}}else{const p=n/2,y=a/2,z=[new _(-p,0,-y),new _(p,0,-y),new _(p,0,y),new _(-p,0,y)];[[z[0],z[1]],[z[1],z[2]],[z[2],z[3]],[z[3],z[0]]].forEach(($,G)=>{const Z=w[G],ee=x.includes(Z),F=v.includes(Z);if(P&&!ee){const te=new _($[0].x,o/2,$[0].z),K=new _($[1].x,o/2,$[1].z);r.push(e.jsx(Ce,{start:te,end:K,color:g},`edge-round-top-line-${C}-${G}`))}if(M&&!F){const te=new _($[0].x,-o/2,$[0].z),K=new _($[1].x,-o/2,$[1].z);r.push(e.jsx(Ce,{start:te,end:K,color:g},`edge-round-bottom-line-${C}-${G}`))}})}}break;case"frame_cutting":break;case"top_groove":if(k.params?.grooves){const D=k.params.grooves,g=5*s,P=.7;D.A&&Array.isArray(D.A)&&D.A.forEach((M,x)=>{const v=(M.width??0)*s,w=(M.depth||5)*s,j=o/2-w;r.push(e.jsxs("mesh",{position:[-n/2+v+g/2,j+.001,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[g,a]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:P,side:se})]},`top-groove-A-${C}-${x}`))}),D.B&&Array.isArray(D.B)&&D.B.forEach((M,x)=>{const v=(M.width??0)*s,w=(M.depth||5)*s,j=o/2-w;r.push(e.jsxs("mesh",{position:[0,j+.001,-a/2+v+g/2],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[n,g]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:P,side:se})]},`top-groove-B-${C}-${x}`))}
24),D.C&&Array.isArray(D.C)&&D.C.forEach((M,x)=>{const v=(M.width??0)*s,w=(M.depth||5)*s,j=o/2-w;r.push(e.jsxs("mesh",{position:[n/2-v-g/2,j+.001,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[g,a]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:P,side:se})]},`top-groove-C-${C}-${x}`))}),D.D&&Array.isArray(D.D)&&D.D.forEach((M,x)=>{const v=(M.width??0)*s,w=(M.depth||5)*s,j=o/2-w;r.push(e.jsxs("mesh",{position:[0,j+.001,a/2-v-g/2],rotation:[-Math.PI/2,0,0],children:[e.jsx("planeGeometry",{args:[n,g]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:P,side:se})]},`top-groove-D-${C}-${x}`))})}break;case"half_rabbet":case"half_lap":{const g=k.params||{},P=Pe(n,o,a,c,s),M=x=>{const v=Mt(P,x);if(v.length<3)return null;const w=new xe;w.moveTo(v[0].x,-v[0].z);for(let j=1;j<v.length;j++)w.lineTo(v[j].x,-v[j].z);return w.closePath(),w};if(g.enableA&&g.widthA>0){const x=(g.widthA||10)*s,v=(g.depthA||5)*s,w=o/2-v,j=M({minX:-n/2,maxX:-n/2+x,minZ:-a/2,maxZ:a/2});j&&r.push(e.jsxs("mesh",{position:[0,w+.001,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("shapeGeometry",{args:[j]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`half-lap-A-${C}`))}if(g.enableB&&g.widthB>0){const x=(g.widthB||10)*s,v=(g.depthB||5)*s,w=o/2-v,j=M({minX:-n/2,maxX:n/2,minZ:-a/2,maxZ:-a/2+x});j&&r.push(e.jsxs("mesh",{position:[0,w+.001,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("shapeGeometry",{args:[j]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`half-lap-B-${C}`))}if(g.enableC&&g.widthC>0){const x=(g.widthC||10)*s,v=(g.depthC||5)*s,w=o/2-v,j=M({minX:n/2-x,maxX:n/2,minZ:-a/2,maxZ:a/2});j&&r.push(e.jsxs("mesh",{position:[0,w+.001,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("shapeGeometry",{args:[j]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`half-lap-C-${C}`))}if(g.enableD&&g.widthD>0){const x=(g.widthD||10)*s,v=(g.depthD||5)*s,w=o/2-v,j=M({minX:-n/2,maxX:n/2,minZ:a/2-x,maxZ:a/2});j&&r.push(e.jsxs("mesh",{position:[0,w+.001,0],rotation:[-Math.PI/2,0,0],children:[e.jsx("shapeGeometry",{args:[j]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`half-lap-D-${C}`))}}break;case"side_groove":{const g=k.params||{},M=c.find(h=>h.id==="corner_rounding")?.params||{},x=M.radius||0,v=M.enableA?(M.radiusA||M.cornerA||x)*s:0,w=M.enableB?(M.radiusB||M.cornerB||x)*s:0,j=M.enableC?(M.radiusC||M.cornerC||x)*s:0,t=M.enableD?(M.radiusD||M.cornerD||x)*s:0;if(g.enableA&&g.widthA>0&&g.depthA>0){const h=(g.widthA||10)*s,i=(g.depthA||5)*s,d=v,u=t,p=a-d-u,y=(u-d)/2;p>0&&r.push(e.jsxs("mesh",{position:[-n/2+i,0,y],rotation:[0,Math.PI/2,0],children:[e.jsx("planeGeometry",{args:[p,h]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`side-groove-A-${C}`))}if(g.enableB&&g.widthB>0&&g.depthB>0){const h=(g.widthB||10)*s,i=(g.depthB||5)*s,d=v,u=w,p=n-d-u,y=(d-u)/2;p>0&&r.push(e.jsxs("mesh",{position:[y,0,-a/2+i],children:[e.jsx("planeGeometry",{args:[p,h]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`side-groove-B-${C}`))}if(g.enableC&&g.widthC>0&&g.depthC>0){const h=(g.widthC||10)*s,i=(g.depthC||5)*s,d=w,u=j,p=a-d-u,y=(u-d)/2;p>0&&r.push(e.jsxs("mesh",{position:[n/2-i,0,y],rotation:[0,Math.PI/2,0],children:[e.jsx("planeGeometry",{args:[p,h]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`side-groove-C-${C}`))}if(g.enableD&&g.widthD>0&&g.depthD>0){const h=(g.widthD||10)*s,i=(g.depthD||5)*s,d=t,u=j,p=n-d-u,y=(d-u)/2;p>0&&r.push(e.jsxs("mesh",{position:[y,0,a/2-i],children:[e.jsx("planeGeometry",{args:[p,h]}),e.jsx("meshBasicMaterial",{color:O,transparent:!0,opacity:.7,side:se})]},`side-groove-D-${C}`))}}break}}),e.jsx(e.Fragment,{children:r})}function wt({w:c,h:n,d:o,textureUrl:a,isCoatingPlywood:s=!1,scale:f=.01}){const b=we(Ae,a);J.useMemo(()=>{b.wrapS=De,b.wrapT=De,b.repeat.set(1,1),b.needsUpdate=!0},[b]);const l=J.useMemo(()=>{const B=c>0?c:600*f,r=n>0?n:18*f,X=o>0?o:300*f,W=new ce(B,r,X),T=W.attributes.uv,I=W.attributes.position,V=W.attributes.normal,k=(s?1200:2400)*f,C=1200*f;for(let O=0;O<I.count;O++){const N=I.getX(O),re=I.getZ(O),D=V.getY(O);if(Math.abs(D)>.9){const g=(N+B/2)/k,P=(re+X/2)/C;T.setXY(O,g,P)}}return T.needsUpdate=!0,W},[c,n,o,s,f]);return e.jsx("mesh",{geometry:l,children:e.jsx("meshBasicMaterial",{map:b})})}function Ze({w:c,h:n,d:o,color:a="#F8F0E4"}){return e.jsxs("mesh",{children:[e.jsx("boxGeometry",{args:[c,n,o]}),e.jsx("meshBasicMaterial",{color:a})]})}function At({length:c,diameter:n,color:o="#FFFFFF",textureUrl:a}){const s=n/2,f=64,b=J.useMemo(()=>{const l=[];for(let B=0;B<=f;B++){const r=B/f*Math.PI*2;l.push([0,Math.cos(r)*s,Math.sin(r)*s])}return l},[s,f]);return e.jsxs("group",{children:[e.jsxs("mesh",{rotation:[0,0,Math.PI/2],children:[e.jsx("cylinderGeometry",{args:[s,s,c,32]}),a?e.jsx(J.Suspense,{fallback:e.jsx("meshBasicMaterial",{color:o}),children:e.jsx(_t,{textureUrl:a})}):e.jsx("meshBasicMaterial",{color:o})]}),e.jsx(he,{points:b.map(([l,B,r])=>[-c/2,B,r]),color:me,lineWidth:1,transparent:!0,opacity:fe}),e.jsx(he,{points:b.map(([l,B,r])=>[c/2,B,r]),color:me,lineWidth:1,transparent:!0,opacity:fe})]})}function _t({textureUrl:c}){const n=we(Ae,c);return J.useMemo(()=>{n.wrapS=Xe,n.wrapT=Xe},[n]),e.jsx("meshBasicMaterial",{map:n})}function qe(c,n,o,a,s,f=!1){c=c>0?c:600*s,n=n>0?n:18*s,o=o>0?o:300*s;const b=()=>new ce(c,n,o);try{const l=new xt,B=new ce(c,n,o);let r=new Y(B);const X=a.find(t=>
24t.id==="corner_rounding"||t.params?.type==="corner_rounding");if(X?.params){const t=X.params;[{enabled:t.enableA,radius:(t.radiusA??t.cornerA??t.radius??20)*s,x:-c/2,z:-o/2,offsetX:1,offsetZ:1},{enabled:t.enableB,radius:(t.radiusB??t.cornerB??t.radius??20)*s,x:c/2,z:-o/2,offsetX:-1,offsetZ:1},{enabled:t.enableC,radius:(t.radiusC??t.cornerC??t.radius??20)*s,x:c/2,z:o/2,offsetX:-1,offsetZ:-1},{enabled:t.enableD,radius:(t.radiusD??t.cornerD??t.radius??20)*s,x:-c/2,z:o/2,offsetX:1,offsetZ:-1}].forEach(i=>{if(i.enabled&&i.radius>0){const d=i.radius,u=new ce(d+.001,n+.002,d+.001),p=new Y(u);p.position.set(i.x+i.offsetX*d/2,0,i.z+i.offsetZ*d/2),p.updateMatrixWorld();const y=new je(d,d,n+.004,32),z=new Y(y);z.position.set(i.x+i.offsetX*d,0,i.z+i.offsetZ*d),z.updateMatrixWorld();const S=l.evaluate(p,z,U);r=l.evaluate(r,S,U),u.dispose(),y.dispose()}})}const W=a.find(t=>t.id==="corner_circle_cut"||t.params?.type==="corner_circle_cut");if(W?.params){const t=W.params;[{enabled:t.enableA,radius:(t.radiusA||30)*s,x:-c/2,z:-o/2},{enabled:t.enableB,radius:(t.radiusB||30)*s,x:c/2,z:-o/2},{enabled:t.enableC,radius:(t.radiusC||30)*s,x:c/2,z:o/2},{enabled:t.enableD,radius:(t.radiusD||30)*s,x:-c/2,z:o/2}].forEach(i=>{if(i.enabled&&i.radius>0){const d=i.radius,u=new je(d,d,n+.004,32),p=new Y(u);p.position.set(i.x,0,i.z),p.updateMatrixWorld(),r=l.evaluate(r,p,U),u.dispose()}})}const T=a.find(t=>t.id==="corner_square_cut"||t.params?.type==="corner_square_cut");if(T?.params){const t=T.params;[{enabled:t.enableA,length:(Number(t.lengthA)||50)*s,width:(Number(t.widthA)||30)*s,x:-c/2,z:-o/2,offsetX:1,offsetZ:1},{enabled:t.enableB,length:(Number(t.lengthB)||50)*s,width:(Number(t.widthB)||30)*s,x:c/2,z:-o/2,offsetX:-1,offsetZ:1},{enabled:t.enableC,length:(Number(t.lengthC)||50)*s,width:(Number(t.widthC)||30)*s,x:c/2,z:o/2,offsetX:-1,offsetZ:-1},{enabled:t.enableD,length:(Number(t.lengthD)||50)*s,width:(Number(t.widthD)||30)*s,x:-c/2,z:o/2,offsetX:1,offsetZ:-1}].forEach(i=>{if(i.enabled&&i.length>0&&i.width>0){const u=new ce(i.length+.1,n+.004,i.width+.1),p=new Y(u);p.position.set(i.x+i.offsetX*i.length/2-i.offsetX*.1/2,0,i.z+i.offsetZ*i.width/2-i.offsetZ*.1/2),p.updateMatrixWorld(),r=l.evaluate(r,p,U),u.dispose()}})}const I=a.find(t=>t.id==="basic_circle"||t.params?.type==="basic_circle");I?.params?.processingItems&&I.params.processingItems.forEach(h=>{if(h.diameter>0){const i=h.diameter/2*s,d=-c/2+(h.positionA||0)*s,u=o/2-(h.positionB||0)*s;if(h.kind==="cutting"){const p=new je(i,i,n+.004,32),y=new Y(p);y.position.set(d,0,u),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}else if(h.kind==="pocket"){const p=(h.depth||5)*s,y=new je(i,i,p+.002,32),z=new Y(y);z.position.set(d,n/2-p/2+.001,u),z.updateMatrixWorld(),r=l.evaluate(r,z,U),y.dispose()}}});const V=a.find(t=>t.id==="basic_square"||t.params?.type==="basic_square");V?.params?.processingItems&&V.params.processingItems.forEach(h=>{const i=h.sizeC||h.width||0,d=h.sizeD||h.height||0;if(i>0&&d>0){const u=i*s,p=d*s,y=-c/2+(h.positionA||0)*s+u/2,z=o/2-(h.positionB||0)*s-p/2;if(h.kind==="cutting"){const S=new ce(u,n+.004,p),$=new Y(S);$.position.set(y,0,z),$.updateMatrixWorld(),r=l.evaluate(r,$,U),S.dispose()}else if(h.kind==="pocket"){const S=(h.depth||5)*s,$=new ce(u,S+.002,p),G=new Y($);G.position.set(y,n/2-S/2+.001,z),G.updateMatrixWorld(),r=l.evaluate(r,G,U),$.dispose()}}});const k=a.find(t=>t.id==="shape_cutting"||t.params?.type==="shape_cutting");if(k?.params){const t=k.params,h=t.shapeType||"circle",i=t.diameter?t.diameter*s:Math.min(c,o),d=t.shapeWidth?t.shapeWidth*s:c,u=t.shapeLength?t.shapeLength*s:o,p=new xe;if(h==="circle"){const q=i/2,H=64;for(let ie=0;ie<=H;ie++){const L=ie/H*Math.PI*2,le=q*Math.cos(L),Me=q*Math.sin(L);ie===0?p.moveTo(le,Me):p.lineTo(le,Me)}p.closePath()}else if(h==="oval"){for(let H=0;H<=64;H++){const ie=H/64*Math.PI*2,L=u/2*Math.cos(ie),le=d/2*Math.sin(ie);H===0?p.moveTo(L,le):p.lineTo(L,le)}p.closePath()}else if(h==="roundbar"){const q=u/2,H=d/2;if(d>u){const L=Math.min(H,q);p.absarc(0,H-L,L,0,Math.PI,!1),p.lineTo(-L,-H+L),p.absarc(0,-H+L,L,Math.PI,Math.PI*2,!1),p.lineTo(L,H-L),p.closePath()}else{const L=Math.min(H,q);p.absarc(-q+L,0,L,Math.PI/2,Math.PI*1.5,!1),p.lineTo(q-L,-L),p.absarc(q-L,0,L,-Math.PI/2,Math.PI/2,!1),p.lineTo(-q+L,L),p.closePath()}}else if(h==="arch"){const q=u/2,H=d/2;if(d>u){const L=Math.min(H,q),le=L;p.moveTo(-le,-H),p.lineTo(le,-H),p.lineTo(le,H-L),p.absarc(0,H-L,L,0,Math.PI,!1),p.lineTo(-le,-H),p.closePath()}else{const L=Math.min(H,q),le=L;p.moveTo(-q,-le),p.lineTo(-q,le),p.lineTo(q-L,le),p.absarc(q-L,0,L,Math.PI/2,-Math.PI/2,!0),p.lineTo(-q,-le),p.closePath()}}const y={steps:1,depth:n,bevelEnabled:!1},z=new ye(p,y);z.rotateX(-Math.PI/2),z.translate(0,-n/2,0);const S=z.attributes.uv,$=z.attributes.position,G=z.attributes.normal,Z=(f?1200:2400)*s,ee=1200*s;for(let q=0;q<$.count;q++){const H=$.getX(q),ie=$.getZ(q),L=G.getY(q);if(Math.abs(L)>.9){const le=(H+c/2)/Z,Me=(ie+o/2)/ee;S.setXY(q,le,Me)}}S.needsUpdate=!0;
24const F=Math.max(c,o)*2,te=new ce(F,n+.01,F),K=new Y(te);K.updateMatrixWorld();const de=new Y(z);de.updateMatrixWorld();const be=l.evaluate(K,de,U);r=l.evaluate(r,be,U),r.updateMatrixWorld(),te.dispose(),z.dispose()}const C=a.find(t=>t.id==="edge_circle_cut"||t.params?.type==="edge_circle_cut");C?.params?.edgeItems&&C.params.edgeItems.forEach(h=>{const i=h.edge,d=h.spacing||0,u=h.diameter||0;if(u<=0)return;const p=u/2*s,y=d*s;let z=0,S=0;switch(i){case"A":z=-c/2,S=o/2-y;break;case"B":z=-c/2+y,S=-o/2;break;case"C":z=c/2,S=o/2-y;break;case"D":z=-c/2+y,S=o/2;break;default:return}const $=new je(p,p,n+.004,32),G=new Y($);G.position.set(z,0,S),G.updateMatrixWorld(),r=l.evaluate(r,G,U),$.dispose()});const O=a.find(t=>t.id==="edge_square_cut"||t.params?.type==="edge_square_cut");O?.params?.edgeItems&&O.params.edgeItems.forEach(h=>{const i=h.edge,d=h.spacing||0,u=h.length||0,p=h.width||0;if(u<=0||p<=0)return;const y=u*s,z=p*s,S=d*s;let $=0,G=0,Z=0,ee=0;switch(i){case"A":Z=y,ee=z,$=-c/2+Z/2,G=o/2-S-ee/2;break;case"B":Z=y,ee=z,$=-c/2+S+Z/2,G=-o/2+ee/2;break;case"C":Z=y,ee=z,$=c/2-Z/2,G=o/2-S-ee/2;break;case"D":Z=y,ee=z,$=-c/2+S+Z/2,G=o/2-ee/2;break;default:return}const F=new ce(Z,n+.004,ee),te=new Y(F);te.position.set($,0,G),te.updateMatrixWorld(),r=l.evaluate(r,te,U),F.dispose()});const N=a.find(t=>t.id==="arch_cut"||t.params?.type==="arch_cut");if(N?.params){const t=N.params,h=t.edge||"A",i=Number(t.archWidth)||0,d=Number(t.totalDepth)||0,u=Number(t.spacing)||0;if(i>0&&d>0){const p=Ye({edge:h,spacing:u,archWidth:i,totalDepth:d}),y=p.length*s,z=p.width*s,S=u*s,$=p.radius*s;let G=0,Z=0,ee=0,F=0;switch(h){case"A":G=-c/2+y/2,Z=o/2-S-z/2,ee=G+y/2,F=Z;break;case"B":G=-c/2+S+y/2,Z=-o/2+z/2,ee=G,F=Z+z/2;break;case"C":G=c/2-y/2,Z=o/2-S-z/2,ee=G-y/2,F=Z;break;case"D":G=-c/2+S+y/2,Z=o/2-z/2,ee=G,F=Z-z/2;break;default:break}if((h==="A"||h==="C"?p.length:p.width)>1e-4){const de={A:[-1,0],B:[0,-1],C:[1,0],D:[0,1]}[h]||[0,0],be=Math.max(y,1e-4)+Math.abs(de[0])*.1,q=Math.max(z,1e-4)+Math.abs(de[1])*.1,H=new ce(be,n+.004,q),ie=new Y(H);ie.position.set(G+de[0]*.1/2,0,Z+de[1]*.1/2),ie.updateMatrixWorld(),r=l.evaluate(r,ie,U),H.dispose()}if($>0){const K=new je($,$,n+.004,48),de=new Y(K);de.position.set(ee,0,F),de.updateMatrixWorld(),r=l.evaluate(r,de,U),K.dispose()}}}We(a,c,o,s)?.cutters.forEach(t=>{const h=new xe;h.moveTo(t[0][0],-t[0][1]),t.slice(1).forEach(([p,y])=>h.lineTo(p,-y)),h.closePath();const i=n+.004,d=new ye(h,{depth:i,bevelEnabled:!1});d.rotateX(-Math.PI/2),d.translate(0,-i/2,0);const u=new Y(d);u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()});const re=a.find(t=>t.id==="frame_cutting"||t.params?.type==="frame_cutting");if(re?.params){const t=re.params.cuttingType||"thickness",h=re.params.position||"both";if(t==="thickness"){const i=n;if(h==="both"||h==="left"){const d=new xe;d.moveTo(0,-n/2-.001),d.lineTo(0,n/2+.001),d.lineTo(i,n/2+.001),d.closePath();const u={depth:o+.004,bevelEnabled:!1},p=new ye(d,u),y=new Y(p);y.position.set(-c/2,0,-o/2-.002),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}if(h==="both"||h==="right"){const d=new xe;d.moveTo(0,-n/2-.001),d.lineTo(0,n/2+.001),d.lineTo(-i,n/2+.001),d.closePath();const u={depth:o+.004,bevelEnabled:!1},p=new ye(d,u),y=new Y(p);y.position.set(c/2,0,-o/2-.002),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}}else{const i=o;if(h==="both"||h==="left"){const d=new xe;d.moveTo(0,0),d.lineTo(0,i+.002),d.lineTo(i+.002,i+.002),d.closePath();const u={depth:n+.004,bevelEnabled:!1},p=new ye(d,u);p.rotateX(-Math.PI/2);const y=new Y(p);y.position.set(-c/2,-n/2-.002,o/2),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}if(h==="both"||h==="right"){const d=new xe;d.moveTo(0,0),d.lineTo(0,i+.002),d.lineTo(-i-.002,i+.002),d.closePath();const u={depth:n+.004,bevelEnabled:!1},p=new ye(d,u);p.rotateX(-Math.PI/2);const y=new Y(p);y.position.set(c/2,-n/2-.002,o/2),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}}}const D=a.find(t=>t.id==="top_groove"||t.params?.type==="top_groove");if(D?.params?.grooves){const t=D.params.grooves,h=5*s;t.A&&Array.isArray(t.A)&&t.A.forEach(i=>{const d=(i.width??0)*s,u=(i.depth||5)*s,p=new ce(h,u+.002,o+.002),y=new Y(p);y.position.set(-c/2+d+h/2,n/2-u/2+.001,0),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}),t.B&&Array.isArray(t.B)&&t.B.forEach(i=>
24{const d=(i.width??0)*s,u=(i.depth||5)*s,p=new ce(c+.002,u+.002,h),y=new Y(p);y.position.set(0,n/2-u/2+.001,-o/2+d+h/2),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}),t.C&&Array.isArray(t.C)&&t.C.forEach(i=>{const d=(i.width??0)*s,u=(i.depth||5)*s,p=new ce(h,u+.002,o+.002),y=new Y(p);y.position.set(c/2-d-h/2,n/2-u/2+.001,0),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()}),t.D&&Array.isArray(t.D)&&t.D.forEach(i=>{const d=(i.width??0)*s,u=(i.depth||5)*s,p=new ce(c+.002,u+.002,h),y=new Y(p);y.position.set(0,n/2-u/2+.001,o/2-d-h/2),y.updateMatrixWorld(),r=l.evaluate(r,y,U),p.dispose()})}const g=a.find(t=>t.id==="half_rabbet"||t.id==="half_lap"||t.params?.type==="half_rabbet"||t.params?.type==="half_lap");if(g?.params){const t=g.params;if(t.enableA&&t.widthA>0&&t.depthA>0){const h=t.widthA*s,i=t.depthA*s,d=new ce(h+.002,i+.002,o+.002),u=new Y(d);u.position.set(-c/2+h/2,n/2-i/2+.001,0),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}if(t.enableB&&t.widthB>0&&t.depthB>0){const h=t.widthB*s,i=t.depthB*s,d=new ce(c+.002,i+.002,h+.002),u=new Y(d);u.position.set(0,n/2-i/2+.001,-o/2+h/2),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}if(t.enableC&&t.widthC>0&&t.depthC>
240){const h=t.widthC*s,i=t.depthC*s,d=new ce(h+.002,i+.002,o+.002),u=new Y(d);u.position.set(c/2-h/2,n/2-i/2+.001,0),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}if(t.enableD&&t.widthD>0&&t.depthD>0){const h=t.widthD*s,i=t.depthD*s,d=new ce(c+.002,i+.002,h+.002),u=new Y(d);u.position.set(0,n/2-i/2+.001,o/2-h/2),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}}const P=a.find(t=>t.id==="side_groove"||t.params?.type==="side_groove");if(P?.params){const t=P.params;if(t.enableA&&t.widthA>0&&t.depthA>0){const h=t.widthA*s,i=t.depthA*s,d=new ce(i+.002,h+.002,o+.002),u=new Y(d);u.position.set(-c/2+i/2,0,0),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}if(t.enableB&&t.widthB>0&&t.depthB>0){const h=t.widthB*s,i=t.depthB*s,d=new ce(c+.002,h+.002,i+.002),u=new Y(d);u.position.set(0,0,-o/2+i/2),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}if(t.enableC&&t.widthC>0&&t.depthC>0){const h=t.widthC*s,i=t.depthC*s,d=new ce(i+.002,h+.002,o+.002),u=new Y(d);u.position.set(c/2-i/2,0,0),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}if(t.enableD&&t.widthD>0&&t.depthD>0){const h=t.widthD*s,i=t.depthD*s,d=new ce(c+.002,h+.002,i+.002),u=new Y(d);u.position.set(0,0,o/2-i/2),u.updateMatrixWorld(),r=l.evaluate(r,u,U),d.dispose()}}const M=a.find(t=>t.id==="sink_hinge_panel"||t.params?.type==="sink_hinge_panel");if(M?.params?.position){const t=17.5*s,h=13*s,i=M.params.position,d=o/s,u=c/s,p=Array.isArray(M.params.hingePositions)?M.params.hingePositions:He(i,d,u);if(p.length>0){const y=22*s;p.forEach(z=>{let S,$;i==="A"?(S=-c/2+y,$=o/2-z*s):(S=-c/2+z*s,$=o/2-y);const G=new je(t,t,h+.002,32),Z=new Y(G);Z.position.set(S,n/2-h/2+.001,$),Z.updateMatrixWorld(),r=l.evaluate(r,Z,U),G.dispose()})}}const x=r.geometry.clone();x.computeVertexNormals();const v=x.attributes.uv,w=x.attributes.position,j=x.attributes.normal;if(v&&w&&j){const t=(f?1200:2400)*s,h=1200*s,i=50*s;for(let d=0;d<w.count;d++){const u=w.getX(d),p=w.getY(d),y=w.getZ(d),z=j.getX(d),S=j.getY(d),$=j.getZ(d);let G=0,Z=0;Math.abs(S)>Math.abs(z)&&Math.abs(S)>Math.abs($)?(G=(u+c/2)/t,Z=(y+o/2)/h):Math.abs(z)>Math.abs($)?(G=(y+o/2)/h,Z=(p+n/2)/i):(G=(u+c/2)/t,Z=(p+n/2)/i),v.setXY(d,G,Z)}v.needsUpdate=!0}return B.dispose(),x}catch(l){return console.error("CSG 가공 처리 중 오류 발생:",l),b()}}function Fe({w:c,h:n,d:o,color:a="#F8F0E4",processing:s,scale:f}){const b=J.useMemo(()=>qe(c,n,o,s,f),[c,n,o,s,f]);return e.jsx("mesh",{geometry:b,children:e.jsx("meshBasicMaterial",{color:a})})}function Wt({w:c,h:n,d:o,textureUrl:a,processing:s,scale:f,isCoatingPlywood:b=!1}){const l=we(Ae,a);J.useMemo(()=>{l.wrapS=De,l.wrapT=De,l.repeat.set(1,1),l.needsUpdate=!0},[l]);const B=J.useMemo(()=>qe(c,n,o,s,f,b),[c,n,o,s,f,b]);return e.jsx("mesh",{geometry:B,children:e.jsx("meshBasicMaterial",{map:l})})}function Pe(c,n,o,a,s){const f=c/2,b=o/2,l=[],B=64,r=a.find(m=>m.id==="shape_cutting"||m.params?.type==="shape_cutting");if(r?.params){const m=r.params,A=m.shapeType||"circle",E=m.diameter?m.diameter*s:Math.min(c,o),R=m.shapeWidth?m.shapeWidth*s:c,ue=m.shapeLength?m.shapeLength*s:o;if(A==="circle"){const ne=E/2;for(let ae=0;ae<=B;ae++){const ge=ae/B*Math.PI*2;l.push(new _(ne*Math.cos(ge),0,ne*Math.sin(ge)))}}else if(A==="oval")for(let ne=0;ne<=B;ne++){const ae=ne/B*Math.PI*2;l.push(new _(ue/2*Math.cos(ae),0,R/2*Math.sin(ae)))}else if(A==="roundbar"){const ne=ue/2,ae=R/2;if(R>ue){const Q=Math.min(ae,ne);for(let oe=0;oe<=B/2;oe++){const pe=oe/(B/2)*Math.PI;l.push(new _(Q*Math.cos(pe),0,ae-Q+Q*Math.sin(pe)))}for(let oe=0;oe<=B/2;oe++){const pe=Math.PI+oe/(B/2)*Math.PI;l.push(new _(Q*Math.cos(pe),0,-ae+Q+Q*Math.sin(pe)))}l.push(l[0].clone())}else{const Q=Math.min(ae,ne);for(let oe=0;oe<=B/2;oe++){const pe=Math.PI/2+oe/(B/2)*Math.PI;l.push(new _(-ne+Q+Q*Math.cos(pe),0,Q*Math.sin(pe)))}for(let oe=0;oe<=B/2;oe++){const pe=-Math.PI/2+oe/(B/2)*Math.PI;l.push(new _(ne-Q+Q*Math.cos(pe),0,Q*Math.sin(pe)))}l.push(l[0].clone())}}else if(A==="arch"){const ne=ue/2,ae=R/2;if(R>ue){const Q=Math.min(ae,ne),oe=Q;l.push(new _(-oe,0,ae)),l.push(new _(oe,0,ae)),l.push(new _(oe,0,-ae+Q));for(let pe=0;pe<=B/2;pe++){const Be=pe/(B/2)*Math.PI;l.push(new _(Q*Math.cos(Be),0,-ae+Q-Q*Math.sin(Be)))}l.push(new _(-oe,0,-ae+Q)),l.push(l[0].clone())}else{const Q=Math.min(ae,ne),oe=Q;l.push(new _(-ne,0,-oe)),l.push(new _(-ne,0,oe)),l.push(new _(ne-Q,0,oe));for(let pe=0;pe<=B/2;pe++){const Be=Math.PI/2-pe/(B/2)*Math.PI;l.push(new _(ne-Q+Q*Math.cos(Be),0,Q*Math.sin(Be)))}l.push(new _(ne-Q,0,-oe)),l.push(l[0].clone())}}return l}const X=a.find(m=>m.id==="frame_cutting"||m.params?.type==="frame_cutting");if(X?.params&&(X.params.cuttingType||"thickness")==="width"){const m=X.params.position||"both",A=m==="both"||m==="left",E=m==="both"||m==="right",R=o,ue=new _(-f,0,-b),ne=new _(f,0,-b),ae=new _(f,0,b),ge=new _(-f,0,b),Q=new _(-f+R,0,-b),oe=new _(f-R,0,-b);return l.push(ge),l.push(A?Q:ue),l.push(E?oe:ne),l.push(ae),l.push(ge.clone()),l}const T=a.find(m=>m.id==="corner_rounding"||m.params?.type==="corner_rounding")?.params,I=T?.enableA?(T.radiu
24sA??T.cornerA??T.radius??20)*s:0,V=T?.enableB?(T.radiusB??T.cornerB??T.radius??20)*s:0,k=T?.enableC?(T.radiusC??T.cornerC??T.radius??20)*s:0,C=T?.enableD?(T.radiusD??T.cornerD??T.radius??20)*s:0,N=a.find(m=>m.id==="corner_circle_cut"||m.params?.type==="corner_circle_cut")?.params,re=N?.enableA?(N.radiusA||30)*s:0,D=N?.enableB?(N.radiusB||30)*s:0,g=N?.enableC?(N.radiusC||30)*s:0,P=N?.enableD?(N.radiusD||30)*s:0,x=a.find(m=>m.id==="corner_square_cut"||m.params?.type==="corner_square_cut")?.params,v=x?.enableA?(Number(x.lengthA)||50)*s:0,w=x?.enableA?(Number(x.widthA)||30)*s:0,j=x?.enableB?(Number(x.lengthB)||50)*s:0,t=x?.enableB?(Number(x.widthB)||30)*s:0,h=x?.enableC?(Number(x.lengthC)||50)*s:0,i=x?.enableC?(Number(x.widthC)||30)*s:0,d=x?.enableD?(Number(x.lengthD)||50)*s:0,u=x?.enableD?(Number(x.widthD)||30)*s:0,p=We(a,c,o,s),y=m=>p?.outline[m],z=m=>!!p?.replacedFaces.includes(m),S=m=>m.forEach(([A,E])=>l.push(new _(A,0,E))),$=[],G=32,Z=(m,A,E,R)=>{switch(m){case"A":return new _(-f+R,0,A-E);case"B":return new _(A+E,0,-b+R);case"C":return new _(f-R,0,A+E);case"D":return new _(A-E,0,b-R);default:return new _(0,0,0)}},ee=(m,A)=>{switch(m){case"A":return b-A;case"B":return A+f;case"C":return A+b;case"D":return f-A;default:return 0}},F=(m,A,E)=>{$.push({edge:m,t:ee(m,A),pts:E.map(R=>Z(m,A,R.u,R.v))})},te=(m,A)=>[{u:-m,v:0},{u:-m,v:A},{u:m,v:A},{u:m,v:0}],K=m=>{const A=[];for(let E=0;E<=G;E++){const R=Math.PI*(1-E/G);A.push({u:m*Math.cos(R),v:m*Math.sin(R)})}return A},de=(m,A)=>{const E=[{u:-m,v:0}];for(let R=0;R<=G;R++){const ue=Math.PI*(1-R/G);E.push({u:m*Math.cos(ue),v:A+m*Math.sin(ue)})}return E.push({u:m,v:0}),E};a.find(m=>m.id==="edge_square_cut"||m.params?.type==="edge_square_cut")?.params?.edgeItems?.forEach(m=>{const A=m.edge,E=(Number(m.length)||0)*s,R=(Number(m.width)||0)*s,ue=(Number(m.spacing)||0)*s;!(E>0&&R>0)||!["A","B","C","D"].includes(A)||(A==="A"||A==="C"?F(A,b-ue-R/2,te(R/2,E)):F(A,-f+ue+E/2,te(E/2,R)))}),a.find(m=>m.id==="edge_circle_cut"||m.params?.type==="edge_circle_cut")?.params?.edgeItems?.forEach(m=>{const A=m.edge,E=(Number(m.diameter)||0)/2*s,R=(Number(m.spacing)||0)*s;if(!(E>0)||!["A","B","C","D"].includes(A))return;const ue=A==="A"||A==="C"?b-R:-f+R;F(A,ue,K(E))});const H=a.find(m=>m.id==="arch_cut"||m.params?.type==="arch_cut");{const m=H?.params,A=Number(m?.archWidth)||0,E=Number(m?.totalDepth)||0;if(m&&A>0&&E>0){const R=m.edge||"A",ue=(Number(m.spacing)||0)*s,ne=Ye({edge:R,archWidth:A,totalDepth:E}),ae=ne.radius*s,ge=(R==="A"||R==="C"?ne.length:ne.width)*s,Q=R==="A"||R==="C"?b-ue-ae:-f+ue+ae;F(R,Q,de(ae,ge))}}const ie=m=>{const A=$.filter(E=>E.edge===m).sort((E,R)=>E.t-R.t);return A.length===0?!1:(A.forEach(E=>E.pts.forEach(R=>l.push(R))),!0)},L=4,le=y("A");if(le)S(le);else if(I>0)for(let m=0;m<=B/2;m++){const A=Math.PI+Math.PI/2*(m/(B/2));l.push(new _(-f+I+I*Math.cos(A),0,-b+I+I*Math.sin(A)))}else if(re>0)for(let m=0;m<=B/2;m++){const A=m/(B/2),E=Math.PI/2*A;l.push(new _(-f+re*Math.sin(E),0,-b+re*Math.cos(E)))}else v>0?(l.push(new _(-f,0,-b+w)),l.push(new _(-f+v,0,-b+w)),l.push(new _(-f+v,0,-b))):l.push(new _(-f,0,-b));const Me=I===0&&re===0&&v===0&&!le,Ie=V===0&&D===0&&j===0&&!y("B"),ke=k===0&&g===0&&h===0&&!y("C"),ze=C===0&&P===0&&d===0&&!y("D");if(!z("B")&&!ie("B")&&Me&&Ie)for(let m=1;m<L;m++){const A=m/L;l.push(new _(-f+2*f*A,0,-b))}const Te=y("B");if(Te)S(Te);else if(V>0)for(let m=0;m<=B/2;m++){const A=Math.PI*1.5+Math.PI/2*(m/(B/2));l.push(new _(f-V+V*Math.cos(A),0,-b+V+V*Math.sin(A)))}else if(D>0)for(let m=0;m<=B/2;m++){const A=m/(B/2),E=Math.PI/2*A;l.push(new _(f-D*Math.cos(E),0,-b+D*Math.sin(E)))}else j>0?(l.push(new _(f-j,0,-b)),l.push(new _(f-j,0,-b+t)),l.push(new _(f,0,-b+t))):l.push(new _(f,0,-b));if(!z("C")&&!ie("C")&&Ie&&ke)for(let m=1;m<L;m++){const A=m/L;l.push(new _(f,0,-b+2*b*A))}const Ge=y("C");if(Ge)S(Ge);else if(k>0)for(let m=0;m<=B/2;m++){const A=0+Math.PI/2*(m/(B/2));l.push(new _(f-k+k*Math.cos(A),0,b-k+k*Math.sin(A)))}else if(g>0)for(let m=0;m<=B/2;m++){const A=m/(B/2),E=Math.PI/2*A;l.push(new _(f-g*Math.sin(E),0,b-g*Math.cos(E)))}else h>0?(l.push(new _(f,0,b-i)),l.push(new _(f-h,0,b-i)),l.push(new _(f-h,0,b))):l.push(new _(f,0,b));if(!z("D")&&!ie("D")&&ke&&ze)for(let m=1;m<L;m++){const A=m/L;l.push(new _(f-2*f*A,0,b))}const Se=y("D");if(Se)S(Se);else if(C>0)for(let m=0;m<=B/2;m++){const A=Math.PI*.5+Math.PI/2*(m/(B/2));l.push(new _(-f+C+C*Math.cos(A),0,b-C+C*Math.sin(A)))}else if(P>0)for(let m=0;m<=B/2;m++){const A=m/(B/2),E=Math.PI/2*A;l.push(new _(-f+P*Math.cos(E),0,b-P*Math.sin(E)))}else d>0?(l.push(new _(-f+d,0,b)),l.push(new _(-f+d,0,b-u)),l.push(new _(-f,0,b-u))):l.push(new _(-f,0,b));if(!z("A")&&!ie("A")&&ze&&Me)for(let m=1;m<L;m++){const A=m/L;l.push(new _(-f,0,b-2*b*A))}return l.push(l[0].clone()),l}function It({w:c,h:n,d:o,processing:a,scale:s}){const f=J.useMemo(()=>Pe(c,n,o,a,s),[c,n,o,a,s]),b=J.useMemo(()=>f.map(r=>[r.x,n/2,r.z]),[f,n]),l=J.useMemo(()=>f.map(r=>[r.x,-n/2,r.z]),[f,n]),B=J.useMemo(()=>{const r=[],W=a.find(N=>N.id==="corner_rounding"||N.params?.type==="corner_rounding")?.params,I=a.find(N=>N.id==="corner_circle_cut"||N.params?.type==="corner_circle_cut")?.params,k=a.find(N=>N.id==="corner_square_cut"||N.params?.type==="corner_square_cut")?.params,C=new Set(We(a,c,o,s)?.removedCorners??[]);return[{x:-c/2,z:-o/2,hasProcessing:W?.enableA||I?.enableA||k?.enableA||C.has("A")},{x:c/2,z:-o/2,hasProcessing:W?.enableB||I?.enableB||k?.enableB||C.has("B")},{x:c/2,z:o/2,hasProcessing:W?.enableC||I?.enableC||k?.enableC||C.has("C")},{x:-c/2,z:o/2,hasProcessing:W?.enableD||I?.enableD||k?.enableD||C.has("D")}
24].forEach(N=>{N.hasProcessing||r.push([[N.x,n/2,N.z],[N.x,-n/2,N.z]])}),r},[c,n,o,a,s]);return e.jsxs("group",{children:[e.jsx(he,{points:b,color:me,lineWidth:1,transparent:!0,opacity:fe}),e.jsx(he,{points:l,color:me,lineWidth:1,transparent:!0,opacity:fe}),B.map((r,X)=>e.jsx(he,{points:r,color:me,lineWidth:1,transparent:!0,opacity:fe},`v-${X}`))]})}function kt(c){const n=["corner_rounding","shape_cutting","corner_circle_cut","corner_square_cut","basic_circle","basic_square","edge_circle_cut","edge_square_cut","arch_cut",...Ve,"frame_cutting","top_groove","half_rabbet","half_lap","side_groove","sink_hinge_panel"];return c.some(o=>n.includes(o.id)||n.includes(o.params?.type))}const zt=["구조재","방부목","각재/목봉"];function Tt({width:c,length:n,thickness:o,thicknessStr:a="",textureUrl:s,woodType:f,processing:b=[],showSanding:l=!1,isCoatingPlywood:B=!1,cameraDistance:r=10}){const W=n*.01,T=o*.01,I=c*.01,V=r*8e-4,k=r*.0024,C=f&&zt.includes(f),O=C?"#FFFFFF":"#F8F0E4",N=kt(b),re=vt(a),D=re?Bt(a)*.01:0;return re?e.jsx("group",{children:e.jsx(At,{length:W,diameter:D,color:O,textureUrl:s})}):e.jsxs("group",{children:[N?s?e.jsx(J.Suspense,{fallback:e.jsx(Fe,{w:W,h:T,d:I,color:O,processing:b,scale:.01}),children:e.jsx(Wt,{w:W,h:T,d:I,textureUrl:s,processing:b,scale:.01,isCoatingPlywood:B})}):e.jsx(Fe,{w:W,h:T,d:I,color:O,processing:b,scale:.01}):s?e.jsx(J.Suspense,{fallback:e.jsx(Ze,{w:W,h:T,d:I,color:O}),children:e.jsx(wt,{w:W,h:T,d:I,textureUrl:s,isCoatingPlywood:B,scale:.01})}):e.jsx(Ze,{w:W,h:T,d:I,color:O}),N?e.jsx(It,{w:W,h:T,d:I,processing:b,scale:.01}):e.jsxs("lineSegments",{children:[e.jsx("edgesGeometry",{args:[new ce(W,T,I)]}),e.jsx("lineBasicMaterial",{color:me,transparent:!0,opacity:fe})]}),!C&&e.jsxs("mesh",{position:[-W/2,T/2+.01,I/2],children:[e.jsx("sphereGeometry",{args:[k,16,16]}),e.jsx("meshBasicMaterial",{color:"#ef4444"})]}),e.jsx(Pt,{processing:b,w:W,h:T,d:I,scale:.01,widthMm:c,lengthMm:n,showSanding:l,markerRadius:V}),e.jsxs(ve,{position:[0,T/2+.1,0],center:!0,zIndexRange:[1,0],style:{color:"#333",fontSize:"12px",fontWeight:"500",whiteSpace:"nowrap",pointerEvents:"none"},children:[o," mm"]}),(()=>{const M=-T/2-.05,x=I/2+.25;return e.jsxs("group",{children:[e.jsx(he,{points:[[-W/2,M,I/2],[-W/2,M,x+.15]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[W/2,M,I/2],[W/2,M,x+.15]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[-W/2,M,x],[W/2,M,x]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[-W/2+.08,M,x-.04],[-W/2,M,x],[-W/2+.08,M,x+.04]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[W/2-.08,M,x-.04],[W/2,M,x],[W/2-.08,M,x+.04]],color:"#333",lineWidth:1}),e.jsxs(ve,{position:[0,M,x+.15+.03],center:!0,zIndexRange:[1,0],style:{color:"#333",fontSize:"12px",fontWeight:"500",whiteSpace:"nowrap",pointerEvents:"none"},children:[n," mm"]})]})})(),(()=>{const M=-W/2-.25,x=-T/2-.05;return e.jsxs("group",{children:[e.jsx(he,{points:[[-W/2,x,I/2],[M-.15,x,I/2]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[-W/2,x,-I/2],[M-.15,x,-I/2]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[M,x,-I/2],[M,x,I/2]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[M-.04,x,-I/2+.08],[M,x,-I/2],[M+.04,x,-I/2+.08]],color:"#333",lineWidth:1}),e.jsx(he,{points:[[M-.04,x,I/2-.08],[M,x,I/2],[M+.04,x,I/2-.08]],color:"#333",lineWidth:1}),e.jsxs(ve,{position:[M-.15-.03,x,0],center:!0,zIndexRange:[1,0],style:{color:"#333",fontSize:"12px",fontWeight:"500",whiteSpace:"nowrap",pointerEvents:"none"},children:[c," mm"]})]})})()]})}function Gt(){return e.jsx(ve,{center:!0,children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-gray-300 border-t-gray-600 rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:"로딩 중..."})]})})}function St({targetDistance:c,controlsRef:n,lookAtOffset:o}){const{camera:a}=st();return J.useEffect(()=>{const s=c*.8,f=c*.6;a.position.set(0,s,f),a.lookAt(0,0,o),a.updateProjectionMatrix(),n.current&&(n.current.maxDistance=c*2,n.current.target.set(0,0,o),n.current.update())},[a,c,n,o]),null}function $t({widthMm:c,lengthMm:n,thicknessMm:o,labelType:a}){const f=n*.01/2,b=c*.01/2,l=o*.01/2+.3,B={color:"#000",fontSize:"13px",fontWeight:"bold",userSelect:"none",pointerEvents:"none",textShadow:"0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff"};if(a==="corner"){const X=[{label:"D",x:-f,z:b},{label:"A",x:-f,z:-b},{label:"B",x:f,z:-b},{label:"C",x:f,z:b}];return e.jsx(e.Fragment,{children:X.map(({label:W,x:T,z:I})=>e.jsx(ve,{position:[T,l,I],center:!0,children:e.jsx("div",{style:B,children:W})},W))})}const r=[{label:"A",x:-f,z:0},{label:"B",x:0,z:-b},{label:"C",x:f,z:0},{label:"D",x:0,z:b}];return e.jsx(e.Fragment,{children:r.map(({label:X,x:W,z:T})=>e.jsx(ve,{position:[W,l,T],center:!0,children:e.jsx("div",{style:B,children:X})},X))})}function Ft({width:c,length:n,thickness:o,woodType:a,textureImg:s,processing:f=[],compact:b=!1,showSanding:l=!1,isCoatingPlywood:B=!1,labelType:r=null}){const X=J.useMemo(()=>f.map(t=>({...t,params:gt(t.id,t.params)})),[f]),W=jt(),T=J.useRef(null),I=J.useRef(null),[V,k]=J.useState({width:400,height:300}),[C,O]=J.useState(!1),[N,re]=J.useState(!1),D=()=>{const t=localStorage.getItem("3d-control-guide-hide-until");return t?new Date().getTime()<parseInt(t,10):!1},g=()=>{const t=new Date().getTime()+864e5;localStorage.setItem("3d-control-guide-hide-until",t.toString()),re(!1)},P=c>0?c:300,M=n>0?n:600,x=yt(o||"18mm");J.useEffect(()=>{const t=()=>{if(T.current){const h=T.current.getBoundingClientRect();k({width:h.width,height:h.height})}};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const{cameraDistance:v,fov:w,lookAtOffset:j}=J.useMemo(()=>{const h=M*.01,i=P*.01,d=.5,u=h+d,p=i+d,y=V.width/V.height,z=W?50:45,S=z*Math.PI/180,$=2*Math.atan(Math.tan(S/2)*y),G=.7,Z=u/2/Math.tan($/2)/G,ee=p/2/Math.tan(S/2)/G;let F=Math.max(Z,ee);F=Math.max(5,Math.min(F,500));const te=i/25;return{cameraDistance:F,fov:z,lookAtOffset:te}},[P,M,V,W]);return e.jsxs("div",{ref:T,className:"relative w-full h-full overflow-hidden",style:{touchAction:W&&!C?"pan-y":"none"},children:[e.jsxs(Je,{shadows:!W,dpr:W?[1,1.5]:[1,2],camera:{position:[0,v*.8,v*.
246],fov:w,near:.1,far:2e3},style:{background:"transparent",touchAction:W&&!C?"pan-y":"none"},gl:{antialias:!W,powerPreference:W?"low-power":"high-performance",toneMapping:Ke},children:[e.jsx(et,{pixelated:!0}),e.jsx(St,{targetDistance:v,controlsRef:I,lookAtOffset:j}),e.jsxs(J.Suspense,{fallback:e.jsx(Gt,{}),children:[e.jsx("ambientLight",{intensity:1}),e.jsx(Tt,{width:P,length:M,thickness:x,thicknessStr:o||"",textureUrl:s,woodType:a,processing:X,showSanding:l,isCoatingPlywood:B,cameraDistance:v}),r&&e.jsx($t,{widthMm:P,lengthMm:M,thicknessMm:x,labelType:r}),(!W||C)&&e.jsx(tt,{ref:I,enablePan:!0,enableZoom:!0,minDistance:W?3:2,maxDistance:v*2,touches:{ONE:$e.ROTATE,TWO:$e.DOLLY_PAN},rotateSpeed:.25,zoomSpeed:.5,panSpeed:.5,makeDefault:!0})]})]}),W&&e.jsx("button",{onClick:()=>{const t=!C;O(t),t&&!D()&&re(!0),!t&&I.current&&I.current.reset()},className:`absolute top-3 right-3 px-3 py-1.5 rounded-full text-xs font-medium shadow-lg transition-all ${C?"bg-[#36583D] text-white":"bg-gray-900 text-white"}`,children:C?"3D 조작 끄기":"3D 조작 켜기"}),N&&Qe.createPortal(e.jsx("div",{className:"flex items-center justify-center",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",zIndex:10001,pointerEvents:"auto",touchAction:"auto"},onClick:t=>{t.target===t.currentTarget&&re(!1)},children:e.jsxs("div",{style:{backgroundColor:"white",borderRadius:"16px",padding:"24px",margin:"0 16px",maxWidth:"340px",width:"100%",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",pointerEvents:"auto",touchAction:"manipulation"},onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{style:{fontSize:"18px",fontWeight:700,color:"#111827",textAlign:"center",marginBottom:"20px",marginTop:0},children:"3D 조작 방법"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",backgroundColor:"#dbeafe",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx("span",{style:{fontSize:"20px"},children:"🔍"})}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"14px",fontWeight:600,color:"#111827",margin:0},children:"확대/축소"}),e.jsx("p",{style:{fontSize:"13px",color:"#6b7280",margin:"2px 0 0 0"},children:"두 손가락으로 핀치"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",backgroundColor:"#dcfce7",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx("span",{style:{fontSize:"20px"},children:"🔄"})}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"14px",fontWeight:600,color:"#111827",margin:0},children:"회전"}),e.jsx("p",{style:{fontSize:"13px",color:"#6b7280",margin:"2px 0 0 0"},children:"한 손가락으로 드래그"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",backgroundColor:"#f3e8ff",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx("span",{style:{fontSize:"20px"},children:"✋"})}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"14px",fontWeight:600,color:"#111827",margin:0},children:"이동"}),e.jsx("p",{style:{fontSize:"13px",color:"#6b7280",margin:"2px 0 0 0"},children:"두 손가락으로 드래그"})]})]})]}),e.jsxs("div",{style:{marginTop:"20px",display:"flex",gap:"8px"},children:[e.jsx("button",{type:"button",className:"control-guide-btn",onTouchEnd:t=>{t.preventDefault(),g()},onClick:g,style:{flex:1,padding:"10px 12px",fontSize:"13px",color:"#4b5563",backgroundColor:"#f3f4f6",border:"none",borderRadius:"8px",touchAction:"manipulation",cursor:"pointer"},children:"하루 보지 않기"}),e.jsx("button",{type:"button",className:"control-guide-btn",onTouchEnd:t=>{t.preventDefault(),re(!1)},onClick:()=>re(!1),style:{flex:1,padding:"10px 12px",fontSize:"13px",color:"white",backgroundColor:"#111827",border:"none",borderRadius:"8px",fontWeight:500,touchAction:"manipulation",cursor:"pointer"},children:"닫기"})]})]})}),document.body)]})}
24export{Ft as WoodPreview3D,Ft as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.