start lathe step down
This commit is contained in:
parent
d73f72586a
commit
69493a0daf
5 changed files with 61 additions and 2 deletions
|
|
@ -629,6 +629,16 @@ export class Polygon {
|
||||||
return minZ;
|
return minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxZ() {
|
||||||
|
let maxZ = Math.max(...this.points.map(p => p.z));
|
||||||
|
if (this.inner) {
|
||||||
|
for (let i of this.inner) {
|
||||||
|
maxZ = Math.max(minZ, i.maxZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
avgZ() {
|
avgZ() {
|
||||||
return [...this.points.map(p => p.z)].reduce((a,v) => a+v) / this.points.length;
|
return [...this.points.map(p => p.z)].reduce((a,v) => a+v) / this.points.length;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -519,6 +519,7 @@ export const conf = {
|
||||||
camLatheLinear: true,
|
camLatheLinear: true,
|
||||||
camLatheOver: 0.1,
|
camLatheOver: 0.1,
|
||||||
camLatheDown: 0,
|
camLatheDown: 0,
|
||||||
|
camLatheExpand: 0,
|
||||||
camLatheSpeed: 500,
|
camLatheSpeed: 500,
|
||||||
camLatheSpindle: 1000,
|
camLatheSpindle: 1000,
|
||||||
camLatheTool: 1000,
|
camLatheTool: 1000,
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,11 @@ export function createPopOp(type, map) {
|
||||||
for (let inp of Object.values(op.inputs)) {
|
for (let inp of Object.values(op.inputs)) {
|
||||||
let parent = inp.parentElement;
|
let parent = inp.parentElement;
|
||||||
if (parent && parent.setVisible && parent.__opt.show) {
|
if (parent && parent.setVisible && parent.__opt.show) {
|
||||||
|
// for normal inputs
|
||||||
parent.setVisible(parent.__opt.show(op, api.conf.get()));
|
parent.setVisible(parent.__opt.show(op, api.conf.get()));
|
||||||
|
} else if (inp.__opt?.show) {
|
||||||
|
// for blanks
|
||||||
|
inp.setVisible(inp.__opt.show(op, api.conf.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -353,6 +357,7 @@ export function createPopOps() {
|
||||||
angle: 'camLatheAngle',
|
angle: 'camLatheAngle',
|
||||||
step: 'camLatheOver',
|
step: 'camLatheOver',
|
||||||
down: 'camLatheDown',
|
down: 'camLatheDown',
|
||||||
|
expand: 'camLatheExpand',
|
||||||
rate: 'camLatheSpeed',
|
rate: 'camLatheSpeed',
|
||||||
tolerance: 'camTolerance',
|
tolerance: 'camTolerance',
|
||||||
filter: 'camContourFilter',
|
filter: 'camContourFilter',
|
||||||
|
|
@ -368,7 +373,9 @@ export function createPopOps() {
|
||||||
sep: UC.newBlank({ class: "pop-sep" }),
|
sep: UC.newBlank({ class: "pop-sep" }),
|
||||||
angle: UC.newInput(LANG.cc_sang_s, { title: LANG.cc_sang_l, convert: toFloat, bound: UC.bound(0.01, 180.0) }),
|
angle: UC.newInput(LANG.cc_sang_s, { title: LANG.cc_sang_l, convert: toFloat, bound: UC.bound(0.01, 180.0) }),
|
||||||
step: UC.newInput(LANG.cc_sovr_s, { title: LANG.cc_sovr_l, convert: toFloat, bound: UC.bound(0.01, 100.0) }),
|
step: UC.newInput(LANG.cc_sovr_s, { title: LANG.cc_sovr_l, convert: toFloat, bound: UC.bound(0.01, 100.0) }),
|
||||||
// down: UC.newInput(LANG.cc_sdwn_s, { title: LANG.cc_sdwn_l, convert: toFloat, units }),
|
sepDn: UC.newBlank({ class: "pop-sep", show: () => env.poppedRec.down > 0 }),
|
||||||
|
down: UC.newInput(LANG.cc_sdwn_s, { title: LANG.cc_sdwn_l, convert: toFloat, units }),
|
||||||
|
expand: UC.newInput(LANG.cl_xpnd_s, { title: LANG.cl_xpnd_l, convert: toFloat, units, show: () => env.poppedRec.down > 0 }),
|
||||||
sep: UC.newBlank({ class: "pop-sep" }),
|
sep: UC.newBlank({ class: "pop-sep" }),
|
||||||
offStart: UC.newInput(LANG.ci_laso_s, { title: LANG.ci_laso_l, convert: toFloat}),
|
offStart: UC.newInput(LANG.ci_laso_s, { title: LANG.ci_laso_l, convert: toFloat}),
|
||||||
offEnd: UC.newInput(LANG.ci_laeo_s, { title: LANG.ci_laeo_l, convert: toFloat}),
|
offEnd: UC.newInput(LANG.ci_laeo_s, { title: LANG.ci_laeo_l, convert: toFloat}),
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,9 @@ export class Topo {
|
||||||
tolerance = op.tolerance,
|
tolerance = op.tolerance,
|
||||||
resolution = (tolerance ? tolerance : 1 / Math.sqrt(density / (span.x * span.y))).round(5),
|
resolution = (tolerance ? tolerance : 1 / Math.sqrt(density / (span.x * span.y))).round(5),
|
||||||
step = this.step = (tool.traceOffset() * 2) * op.step,
|
step = this.step = (tool.traceOffset() * 2) * op.step,
|
||||||
angle = this.angle = op.angle || 1;
|
angle = this.angle = op.angle || 1,
|
||||||
|
down = this.down = op.down,
|
||||||
|
expand = this.expand = op.expand;
|
||||||
|
|
||||||
if (tool.isTaperMill() && step === 0) {
|
if (tool.isTaperMill() && step === 0) {
|
||||||
step = this.step = op.step * tool.unitScale();
|
step = this.step = op.step * tool.unitScale();
|
||||||
|
|
@ -160,6 +162,7 @@ export class Topo {
|
||||||
|
|
||||||
async sliceGPU(onupdate) {
|
async sliceGPU(onupdate) {
|
||||||
const { angle, diam, leave, linear, offStart, offEnd, resolution, tool, units, vertices, zBottom } = this;
|
const { angle, diam, leave, linear, offStart, offEnd, resolution, tool, units, vertices, zBottom } = this;
|
||||||
|
const { down, expand } = this;
|
||||||
|
|
||||||
// invert tool Z offset for gpu code
|
// invert tool Z offset for gpu code
|
||||||
let toolBounds = new THREE.Box3()
|
let toolBounds = new THREE.Box3()
|
||||||
|
|
@ -240,6 +243,40 @@ export class Topo {
|
||||||
slices.push(slice);
|
slices.push(slice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let maxZ = 0;
|
||||||
|
if (down) {
|
||||||
|
for (let r of rows)
|
||||||
|
for (let p of r) {
|
||||||
|
maxZ = Math.max(maxZ, p.z);
|
||||||
|
}
|
||||||
|
console.log({ maxZ, down, expand });
|
||||||
|
maxZ += expand;
|
||||||
|
}
|
||||||
|
if (down) {
|
||||||
|
for (let slice of slices) {
|
||||||
|
let z = slice.z;
|
||||||
|
let poly = slice.camLines[0].clone();
|
||||||
|
let pMinZ = poly.minZ();
|
||||||
|
let steps = Math.floor((maxZ - pMinZ) / down);
|
||||||
|
let stack = [ poly.clone() ];
|
||||||
|
for (let i=0; i<steps; i++) {
|
||||||
|
for (let p of poly.points) {
|
||||||
|
p.z = Math.min(p.z + down, maxZ);
|
||||||
|
}
|
||||||
|
stack.push(poly.clone());
|
||||||
|
}
|
||||||
|
stack.reverse();
|
||||||
|
slice.stack = stack.map(poly => {
|
||||||
|
let slice = newSlice(z);
|
||||||
|
slice.camLines = [ poly ];
|
||||||
|
return slice;
|
||||||
|
});
|
||||||
|
// todo: add line to line reversals
|
||||||
|
// todo: add move to maxZ after stack is run
|
||||||
|
}
|
||||||
|
slices = this.gpu_slices = slices.map(slice => slice.stack).flat();
|
||||||
|
slices.forEach((slice,index) => slice.index = index);
|
||||||
|
}
|
||||||
for (let slice of slices) {
|
for (let slice of slices) {
|
||||||
slice.output()
|
slice.output()
|
||||||
.setLayer("lathe", { line: this.lineColor })
|
.setLayer("lathe", { line: this.lineColor })
|
||||||
|
|
|
||||||
|
|
@ -714,6 +714,10 @@ self.lang['en-us'] = {
|
||||||
ct_nabl_s: "auto",
|
ct_nabl_s: "auto",
|
||||||
ct_nabl_l: ["auto generate radial tabs","projected from part center","using count and angle offset"],
|
ct_nabl_l: ["auto generate radial tabs","projected from part center","using count and angle offset"],
|
||||||
|
|
||||||
|
// CNC LATHE
|
||||||
|
cl_xpnd_s: "expand",
|
||||||
|
cl_xpnd_l: ["grow starting radius for step down. radius is defined as the highest Z point measured from the X axis center of the part"],
|
||||||
|
|
||||||
// OUTPUT
|
// OUTPUT
|
||||||
ou_menu: "output",
|
ou_menu: "output",
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue