diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index 3ac3d1c4..e6abff07 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -1422,7 +1422,7 @@ CAM.init = function(kiri, api) { tolerance: 'camTolerance', filter: 'camContourFilter', leave: 'camContourLeave', - axis: 'X' + linear: 'camLatheLinear' }).inputs = { tool: UC.newSelect(LANG.cc_tool, {}, "tools"), // axis: UC.newSelect(LANG.cd_axis, {}, "xyaxis"), @@ -1435,6 +1435,8 @@ CAM.init = function(kiri, api) { sep: UC.newBlank({class:"pop-sep"}), tolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0,10.0), units:true, round:4}), leave: UC.newInput(LANG.cf_leav_s, {title:LANG.cf_leav_l, convert:UC.toFloat, bound:UC.bound(0,100)}), + sep: UC.newBlank({class:"pop-sep"}), + linear: UC.newBoolean(LANG.ci_line_s, undefined, {title:LANG.ci_line_l}), // filter: UC.newRow([ UC.newButton(LANG.filter, contourFilter) ], {class:"ext-buttons f-row"}) }; diff --git a/src/kiri-mode/cam/tool.js b/src/kiri-mode/cam/tool.js index aa45cdc6..01e42b78 100644 --- a/src/kiri-mode/cam/tool.js +++ b/src/kiri-mode/cam/tool.js @@ -62,6 +62,10 @@ class Tool { return this.unitScale() * this.tool.taper_tip; } + maxDiameter() { + return Math.max(this.fluteDiameter(), this.tipDiameter(), this.shaftDiameter()); + } + traceOffset() { return (this.isTaperMill() ? this.tipDiameter() : this.fluteDiameter()) / 2; } diff --git a/src/kiri-mode/cam/topo4.js b/src/kiri-mode/cam/topo4.js index bf94ba9b..090be98d 100644 --- a/src/kiri-mode/cam/topo4.js +++ b/src/kiri-mode/cam/topo4.js @@ -73,6 +73,7 @@ class Topo4 { this.diam = tool.fluteDiameter(); this.zoff = widget.track.top || 0; this.leave = op.leave || 0; + this.linear = op.linear || false; this.lineColor = state.settings.controller.dark ? 0xffff00 : 0x555500; onupdate(0, "lathe"); @@ -363,7 +364,7 @@ class Topo4 { } async latheMinions(onupdate) { - const { sliced, tool, zoff, leave, maxo, zBottom, step, resolution } = this; + const { sliced, tool, zoff, leave, maxo, zBottom, step, resolution, linear } = this; const { putCache, clearCache, queue } = this; const rota = this.angle * DEG2RAD; @@ -404,19 +405,34 @@ class Topo4 { await Promise.all(promises); recs.sort((a, b) => { return b.angle - a.angle }); - count = recs[0].heights.length / 3; + // let linear = true; + + count = linear ? recs.length : recs[0].heights.length / 3; while (count-- > 0) { let slice = newSlice(count); slice.camLines = [ newPolygon().setOpen() ]; paths.push(slice); } - for (let rec of recs) { - const { degrees, heights } = rec; - [...heights].group(3).forEach((a,i) => { - // progress each path 360 degrees to prevent A rolling backwards - paths[i].camLines[0].push( newPoint(a[0], a[1], a[2] + leave).setA(degrees + i * -360) ); + if (linear) { + recs.forEach((rec,i) => { + const { degrees, heights } = rec; + [...heights].group(3).forEach((a) => { + // progress each path 360 degrees to prevent A rolling backwards + paths[i].camLines[0].push( newPoint(a[0], a[1], a[2] + leave).setA(degrees + i * -360) ); + }); + if (i % 2 === 1) { + paths[i].camLines[0].reverse(); + } }); + } else { + for (let rec of recs) { + const { degrees, heights } = rec; + [...heights].group(3).forEach((a,i) => { + // progress each path 360 degrees to prevent A rolling backwards + paths[i].camLines[0].push( newPoint(a[0], a[1], a[2] + leave).setA(degrees + i * -360) ); + }); + } } for (let slice of paths) { @@ -425,9 +441,11 @@ class Topo4 { console.log('empty', slice); continue; } - // repeat first point 360 degrees progressed - const repeat = poly.points[0]; - slice.camLines[0].push(repeat.clone().setA(repeat.a - 360)); + if (!linear) { + // repeat first point 360 degrees progressed + const repeat = poly.points[0]; + slice.camLines[0].push(repeat.clone().setA(repeat.a - 360)); + } slice.output() .setLayer("lathe", { line: this.lineColor }) .addPoly(poly.clone().applyRotations().move({ z: -zoff, x:0, y:0 })); diff --git a/web/kiri/index.css b/web/kiri/index.css index 62ba9c90..614a04a3 100644 --- a/web/kiri/index.css +++ b/web/kiri/index.css @@ -725,6 +725,7 @@ button:hover { right: 0; bottom: 0; position: fixed; + color: black; background-color: #fff; font-family: 'Russo One', sans-serif; z-index: 1000; diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index 3a056a29..9ca5b021 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -607,6 +607,8 @@ self.kiri.lang['en-us'] = { ci_abso_l: "degree rotation is absolute", ci_face_s: "face", ci_face_l: "select face to rotate facing up", + ci_line_s: "linear", + ci_line_l: "make linear passes along X then rotate Y", // CNC LASER On/Off Operations (Carvera) cl_powr_s: "power",