From 30c7b841ceefd37b55339c5b4f6e46fb552f4297 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 28 Nov 2020 08:21:25 -0500 Subject: [PATCH] add control of tab depth (projection from surface) --- src/kiri/conf.js | 1 + src/kiri/init.js | 1 + src/kiri/worker.js | 8 ++++---- src/mode/cam/client.js | 8 ++++---- web/kiri/lang/en.js | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/kiri/conf.js b/src/kiri/conf.js index 70767ed7..b00c73f3 100644 --- a/src/kiri/conf.js +++ b/src/kiri/conf.js @@ -440,6 +440,7 @@ camDrillReg: "none", camTabsWidth: 5, camTabsHeight: 5, + camTabsDepth: 5, camTabsOn: false, camDepthFirst: false, camEaseDown: false, diff --git a/src/kiri/init.js b/src/kiri/init.js index d0448ff8..6097a3fc 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -1543,6 +1543,7 @@ camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM, marker:false}), camTabsWidth: UC.newInput(LANG.ct_wdth_s, {title:LANG.ct_wdth_l, convert:UC.toFloat, bound:UC.bound(0.005,100), modes:CAM, units:true}), camTabsHeight: UC.newInput(LANG.ct_hght_s, {title:LANG.ct_hght_l, convert:UC.toFloat, bound:UC.bound(0.005,100), modes:CAM, units:true}), + camTabsDepth: UC.newInput(LANG.ct_dpth_s, {title:LANG.ct_dpth_l, convert:UC.toFloat, bound:UC.bound(0.005,100), modes:CAM, units:true}), camTabSep: UC.newBlank({class:"pop-sep"}), camTabsManual: UC.newRow([ (UI.tabAdd = UC.newButton(undefined, onButtonClick, {icon:''})), diff --git a/src/kiri/worker.js b/src/kiri/worker.js index 788a5dbc..b2c68169 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -362,11 +362,11 @@ KIRI.worker = { let p3 = (x * height); let p4 = (x - 1) * height; faces[ii++] = p1; + faces[ii++] = p3; faces[ii++] = p2; - faces[ii++] = p3; faces[ii++] = p1; - faces[ii++] = p3; faces[ii++] = p4; + faces[ii++] = p3; } } // create bottom vertices & faces @@ -407,11 +407,11 @@ KIRI.worker = { let p3 = 0 + (y - 1); let p4 = 0 + (y - 0); faces[ii++] = p1; + faces[ii++] = p3; faces[ii++] = p2; - faces[ii++] = p3; faces[ii++] = p1; - faces[ii++] = p3; faces[ii++] = p4; + faces[ii++] = p3; } } // create right vertices & faces diff --git a/src/mode/cam/client.js b/src/mode/cam/client.js index b780ae0d..e05904b7 100644 --- a/src/mode/cam/client.js +++ b/src/mode/cam/client.js @@ -241,15 +241,15 @@ function createTabBox(iw, ic, n) { const { track } = iw; const { stock, bounds, process } = API.conf.get(); - const { camTabsWidth, camTabsHeight } = process; + const { camTabsWidth, camTabsHeight, camTabsDepth } = process; const sz = stock.z || bounds.max.z; const zp = sz - track.box.d + process.camZBottom - process.camZTopOffset + camTabsHeight / 2; - ic.x += n.x * 2.5; // offset from part - ic.z -= n.y * 2.5; // offset swap z,y + ic.x += n.x * camTabsDepth / 2; // offset from part + ic.z -= n.y * camTabsDepth / 2; // offset swap z,y ic.y = zp; // offset swap in world space y,z const rot = new THREE.Quaternion().setFromAxisAngle(zaxis, Math.atan2(n.y, n.x)); const pos = { x:ic.x, y:ic.y, z:ic.z }; - const dim = { x:5, y:camTabsWidth, z:camTabsHeight }; + const dim = { x:camTabsDepth, y:camTabsWidth, z:camTabsHeight }; const tab = addbox(pos, 0x0000dd, 'tabb', dim, { rotate: rot }); return { pos, dim, rot, tab, width: camTabsWidth, height: camTabsHeight }; } diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index 930cefe2..38a97f50 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -349,6 +349,8 @@ kiri.lang['en-us'] = { ct_wdth_l: "width in workspace units", ct_hght_s: "height", ct_hght_l: "height in workspace units", + ct_dpth_s: "depth", + ct_dpth_l: "distance in workspace units\nthat the tab projects from\nthe part surface", ct_nabl_s: "auto", ct_nabl_l: "auto generate radial tabs\nprojected from part center\nusing count and angle offset",