diff --git a/src/geo/paths.js b/src/geo/paths.js index f4d83dad..42492fc3 100644 --- a/src/geo/paths.js +++ b/src/geo/paths.js @@ -9,7 +9,7 @@ gapp.register("geo.paths", [], (root, exports) => { const { base } = root; -const { util, config, newPoint } = base; +const { util, config } = base; const { sqr, numOrDefault } = util; const DEG2RAD = Math.PI / 180; diff --git a/src/geo/point.js b/src/geo/point.js index 7db39d45..10e6b756 100644 --- a/src/geo/point.js +++ b/src/geo/point.js @@ -80,7 +80,11 @@ class Point { } clone() { - return newPoint(this.x, this.y, this.z, this._key); + let p = newPoint(this.x, this.y, this.z, this._key); + if (this.a) { + p.a = this.a; + } + return p; } slopeTo(p) { diff --git a/src/kiri-mode/cam/animate2.js b/src/kiri-mode/cam/animate2.js index 513b7cb3..d0791e61 100644 --- a/src/kiri-mode/cam/animate2.js +++ b/src/kiri-mode/cam/animate2.js @@ -492,7 +492,7 @@ kiri.load(() => { const sd = Math.sqrt(mx*mx + my*my + mz*mz); const moves = []; for (let i=0, x=lp.x, y=lp.y, z=lp.z; i { - ev.stopPropagation(); - ev.preventDefault(); - func.surfaceDone(); - func.traceDone(); - func.tabDone(); - func.opDel(rec); - }; + if (!clock) { + $(`${id}-x`).onmousedown = (ev) => { + ev.stopPropagation(); + ev.preventDefault(); + func.surfaceDone(); + func.traceDone(); + func.tabDone(); + func.opDel(rec); + }; + } else { + indexing = false; + } let el = $(id); if (rec.disabled) { el.classList.add("disabled"); @@ -422,6 +432,9 @@ CAM.init = function(kiri, api) { let inside = true; let popped = false; let poprec = popOp[rec.type]; + if (type === 'index' && indexing) { + index = rec.absolute ? rec.degrees : index + rec.degrees; + } el.rec = rec; el.unpop = () => { let pos = [...el.childNodes].indexOf(poprec.div); @@ -565,6 +578,10 @@ CAM.init = function(kiri, api) { el.onmouseleave = onLeave; } } + // update widget rotations from timeline marker + for (let widget of API.widgets.all()) { + widget.setAxisIndex(-index); + } }); func.opGCode = (label, field = 'gcode') => { diff --git a/src/kiri-mode/cam/ops.js b/src/kiri-mode/cam/ops.js index 7500f522..4fae17e0 100644 --- a/src/kiri-mode/cam/ops.js +++ b/src/kiri-mode/cam/ops.js @@ -41,6 +41,10 @@ class CamOp { class OpIndex extends CamOp { constructor(state, op) { super(state, op); + } + + slice() { + let { op, state } = this; state.setAxisIndex(op.degrees); } diff --git a/src/kiri-mode/cam/slice.js b/src/kiri-mode/cam/slice.js index 9b10f56e..d2328cf4 100644 --- a/src/kiri-mode/cam/slice.js +++ b/src/kiri-mode/cam/slice.js @@ -147,9 +147,13 @@ CAM.slice = function(settings, widget, onupdate, ondone) { } sliceAll.appendAll(slices); if (axisIndex !== undefined) { - console.log({post_axis_index: slices}); + // update slice cam lines to add axis indexing for (let slice of slices) { - slice.axisIndex = axisIndex; + for (let poly of slice.camLines) { + for (let point of poly.points) { + point.a = axisIndex; + } + } } } } @@ -189,6 +193,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) { let opSum = 0; let opTot = opList.length ? opList.map(op => op.weight()).reduce((a,v) => a + v) : 0; + // determing # of steps and step weighting for progress bar for (let op of proc.ops.filter(op => !op.disabled)) { let opfn = OPS[op.type]; if (opfn) { @@ -201,6 +206,8 @@ CAM.slice = function(settings, widget, onupdate, ondone) { // give ops access to entire sequence state.ops = opList; + // call slice() function on all ops in order + setAxisIndex(undefined); for (let op of opList) { let weight = op.weight(); op.slice((progress, message) => { diff --git a/src/kiri/widget.js b/src/kiri/widget.js index 792cbd37..41511965 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -552,6 +552,10 @@ class Widget { this.setModified(); } + setAxisIndex(deg) { + this.mesh.rotation.x = deg * (Math.PI / 180); + } + rotate(x, y, z, temp) { this.group.forEach(w => { w._rotate(x, y, z, temp);