fix ball taper render in indexed mode
This commit is contained in:
parent
917a798474
commit
d5cda790c0
8 changed files with 38 additions and 31 deletions
|
|
@ -288,15 +288,15 @@ function toolUpdate(toolid, send) {
|
|||
.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.isTaperBall()) {
|
||||
const trad = Math.max(tool.tipDiameter() / 2, 0.001);
|
||||
const brad = trad; // ball radius equals tip radius
|
||||
const taperLen = flen - brad; // taper length excludes ball
|
||||
const { b, r } = tool.getBallTaperParams();
|
||||
// taper length excludes most of ball
|
||||
const taperLen = flen - b;
|
||||
// shaft at top
|
||||
mesh = cylinder(slen, srad, srad, 20, true).translate(0, 0, slen / 2)
|
||||
// taper cone in middle
|
||||
.add(cylinder(taperLen, trad, frad, 20, true).translate(0, 0, -taperLen / 2))
|
||||
// ball at bottom
|
||||
.add(sphere(brad, 20).translate(0, 0, -(taperLen + brad)));
|
||||
.add(cylinder(taperLen, b, frad, 20, true).translate(0, 0, -taperLen / 2))
|
||||
// exposed ball at bottom
|
||||
.add(sphere(r, 20).translate(0, 0, -taperLen));
|
||||
} else if (tool.isTaperMill()) {
|
||||
const trad = Math.max(tool.tipDiameter() / 2, 0.001);
|
||||
mesh = cylinder(slen, srad, srad, 20, true).translate(0, 0, slen / 2)
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ Object.assign(client, {
|
|||
color: 0x888888,
|
||||
side: THREE.DoubleSide
|
||||
});
|
||||
api.widgets.setColor(0x0055aa);
|
||||
api.widgets.setOpacity(0.5);
|
||||
client.send("animate_setup2", { settings }, ondone);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -963,7 +963,7 @@ function validateTools(tools) {
|
|||
|
||||
function animate() {
|
||||
env.isAnimate = true;
|
||||
api.widgets.opacity(env.isParsed ? 0 : 0.75);
|
||||
api.widgets.setOpacity(env.isParsed ? 0 : 0.75);
|
||||
api.hide.slider();
|
||||
STACKS.clear();
|
||||
animFn().animate(api);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class OpArea extends CamOp {
|
|||
if (mode === 'clear') {
|
||||
let zMov = flatOff ?? 0;
|
||||
let zs = flats ?
|
||||
flats.filter(z => z <= zTop && z >= zBottom).map(v => v + (zMov ?? 0)) :
|
||||
flats.filter(z => z <= zTop && z >= zBottom).map(v => v + zMov) :
|
||||
down ? base_util.lerp(zTop, zBottom, down) : [ bounds.min.z ];
|
||||
let zroc = 0;
|
||||
let zinc = 1 / zs.length;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ class Tool {
|
|||
return calcTaperAngle((flute_diam - taper_tip) / 2, flute_len);
|
||||
}
|
||||
|
||||
getBallTaperParams() {
|
||||
let a = this.getTaperAngle() * DEG2RAD,
|
||||
r = (this.tipDiameter()/2) * (1 + Math.sin(a)) / Math.cos(a),
|
||||
b = r * Math.cos(a);
|
||||
return { a, r, b };
|
||||
}
|
||||
|
||||
shaftLength() {
|
||||
return this.unitScale() * this.tool.shaft_len;
|
||||
}
|
||||
|
|
@ -152,9 +159,7 @@ class Tool {
|
|||
toolOffset = [],
|
||||
maxo = -Infinity,
|
||||
// ball taper magic
|
||||
a = this.getTaperAngle() * DEG2RAD,
|
||||
r = (tip_dia/2) * (1 + Math.sin(a)) / Math.cos(a),
|
||||
b = r * Math.cos(a),
|
||||
{ b, r } = this.getBallTaperParams(),
|
||||
pix_b = b / resolution,
|
||||
pix_r = r / resolution;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue