fix rendering of cnc tool shafts
This commit is contained in:
parent
1c6e4429aa
commit
b67a823b3b
2 changed files with 9 additions and 8 deletions
|
|
@ -640,19 +640,22 @@ kiri.load(() => {
|
||||||
const srad = tool.shaftDiameter() / 2;
|
const srad = tool.shaftDiameter() / 2;
|
||||||
const flen = tool.fluteLength() || 15;
|
const flen = tool.fluteLength() || 15;
|
||||||
const frad = toolRadius = tool.fluteDiameter() / 2;
|
const frad = toolRadius = tool.fluteDiameter() / 2;
|
||||||
|
const tlen = slen + flen; // total tool length
|
||||||
let { cylinder, sphere } = Instance.Manifold;
|
let { cylinder, sphere } = Instance.Manifold;
|
||||||
let mesh;
|
let mesh;
|
||||||
if (tool.isBallMill()) {
|
if (tool.isBallMill()) {
|
||||||
mesh = cylinder(flen + slen - frad * 2, frad, frad, 20, true)
|
mesh = cylinder(tlen - frad * 2, frad, frad, 20, true)
|
||||||
.add(sphere(frad, 20).translate(0, 0, -(flen + slen - frad * 2)/2));
|
.add(sphere(frad, 20).translate(0, 0, -(tlen - frad * 2)/2))
|
||||||
|
.add(cylinder(slen, srad, srad, 20, true).translate(0, 0, flen/2));
|
||||||
} else if (tool.isTaperMill()) {
|
} else if (tool.isTaperMill()) {
|
||||||
const trad = Math.max(tool.tipDiameter() / 2, 0.001);
|
const trad = Math.max(tool.tipDiameter() / 2, 0.001);
|
||||||
mesh = cylinder(slen, srad, srad, 20, true).translate(0, 0, slen/2)
|
mesh = cylinder(slen, srad, srad, 20, true).translate(0, 0, slen/2)
|
||||||
.add(cylinder(flen, trad, frad, 20, true).translate(0, 0, -flen/2));
|
.add(cylinder(flen, trad, frad, 20, true).translate(0, 0, -flen/2));
|
||||||
} else {
|
} else {
|
||||||
mesh = cylinder(flen + slen, frad, frad, 20, true);
|
mesh = cylinder(tlen, frad, frad, 20, true)
|
||||||
|
.add(cylinder(slen, srad, srad, 20, true).translate(0, 0, flen/2));
|
||||||
}
|
}
|
||||||
mesh = mesh.translate(0, 0, (flen + slen - stockZ) / 2);
|
mesh = mesh.translate(0, 0, (tlen - stockZ) / 2);
|
||||||
const raw = mesh.getMesh();
|
const raw = mesh.getMesh();
|
||||||
const vertex = raw.vertProperties;
|
const vertex = raw.vertProperties;
|
||||||
const index = raw.triVerts;
|
const index = raw.triVerts;
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,7 @@ class Tool {
|
||||||
|
|
||||||
generateProfile(resolution) {
|
generateProfile(resolution) {
|
||||||
// generate tool profile
|
// generate tool profile
|
||||||
let type = this.getType(),
|
let ball = this.isBallMill(),
|
||||||
ball = this.isBallMill(),
|
|
||||||
taper = this.isTaperMill(),
|
taper = this.isTaperMill(),
|
||||||
tip_diameter = this.tipDiameter(),
|
tip_diameter = this.tipDiameter(),
|
||||||
shaft_offset = this.fluteLength(),
|
shaft_offset = this.fluteLength(),
|
||||||
|
|
@ -134,7 +133,6 @@ class Tool {
|
||||||
dist_from_center = Math.sqrt(dx * dx + dy * dy);
|
dist_from_center = Math.sqrt(dx * dx + dy * dy);
|
||||||
if (dist_from_center <= flute_radius_pix_float) {
|
if (dist_from_center <= flute_radius_pix_float) {
|
||||||
maxo = Math.max(maxo, dx, dy);
|
maxo = Math.max(maxo, dx, dy);
|
||||||
// console.log({x,y,dx,dy,dist:dist_from_center,ln:dbl.length})
|
|
||||||
// flute offset points
|
// flute offset points
|
||||||
let z_offset = 0;
|
let z_offset = 0;
|
||||||
if (ball) {
|
if (ball) {
|
||||||
|
|
@ -147,7 +145,7 @@ class Tool {
|
||||||
toolOffset.push(dx, dy, z_offset);
|
toolOffset.push(dx, dy, z_offset);
|
||||||
} else if (shaft_offset && larger_shaft && dist_from_center <= shaft_radius_pix_float) {
|
} else if (shaft_offset && larger_shaft && dist_from_center <= shaft_radius_pix_float) {
|
||||||
// shaft offset points
|
// shaft offset points
|
||||||
// toolOffset.push(dx, dy, -shaft_offset);
|
toolOffset.push(dx, dy, -shaft_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue