add proper negative extrusion handling (normals and chamfer reversal)
This commit is contained in:
parent
96177c321f
commit
2efb9cfab8
3 changed files with 24 additions and 4 deletions
|
|
@ -2184,9 +2184,22 @@ class Polygon {
|
||||||
return earcut.map(face => face.points.map(p => [ p.x, p.y, p.z ])).flat().flat();
|
return earcut.map(face => face.points.map(p => [ p.x, p.y, p.z ])).flat().flat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let inv = z < 0;
|
||||||
|
|
||||||
|
if (inv) {
|
||||||
|
z = -z;
|
||||||
|
}
|
||||||
|
|
||||||
let chamfer = opt.chamfer || 0;
|
let chamfer = opt.chamfer || 0;
|
||||||
let chamfer_top = opt.chamfer_top || chamfer;
|
let chamfer_top = opt.chamfer_top || chamfer;
|
||||||
let chamfer_bottom = opt.chamfer_bottom || chamfer;
|
let chamfer_bottom = opt.chamfer_bottom || chamfer;
|
||||||
|
|
||||||
|
if (inv) {
|
||||||
|
let tmp = chamfer_top;
|
||||||
|
chamfer_top = chamfer_bottom;
|
||||||
|
chamfer_bottom = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
let zadd = (typeof opt === 'number' ? opt : opt.zadd || 0); // z bottom
|
let zadd = (typeof opt === 'number' ? opt : opt.zadd || 0); // z bottom
|
||||||
let obj = []; // flat output vertex array (float-x,float-y,float-z,...)
|
let obj = []; // flat output vertex array (float-x,float-y,float-z,...)
|
||||||
let top_face = earcut;
|
let top_face = earcut;
|
||||||
|
|
@ -2251,6 +2264,12 @@ class Polygon {
|
||||||
obj.appendAll(inner.ribbonZ(rib, z_side_bottom, true));
|
obj.appendAll(inner.ribbonZ(rib, z_side_bottom, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inv) {
|
||||||
|
for (let i=2; i<obj.length; i+=3) {
|
||||||
|
obj[i] -= z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,14 +231,15 @@ function space_init(data) {
|
||||||
case 'KeyA':
|
case 'KeyA':
|
||||||
if (api.mode.is([ api.modes.edge ])) return mesh.edges.add();
|
if (api.mode.is([ api.modes.edge ])) return mesh.edges.add();
|
||||||
return shiftKey && api.tool.analyze();
|
return shiftKey && api.tool.analyze();
|
||||||
case 'KeyR':
|
// case 'KeyR':
|
||||||
return shiftKey ? api.tool.rebuild() : api.tool.repair();
|
// return shiftKey ? api.tool.rebuild() : api.tool.repair();
|
||||||
case 'KeyE':
|
case 'KeyE':
|
||||||
if (api.mode.is([ api.modes.sketch ])) {
|
if (api.mode.is([ api.modes.sketch ])) {
|
||||||
estop(evt);
|
estop(evt);
|
||||||
return api.sketch.extrude();
|
return api.sketch.extrude();
|
||||||
}
|
}
|
||||||
return api.tool.clean();
|
return;
|
||||||
|
// return api.tool.clean();
|
||||||
case 'KeyV':
|
case 'KeyV':
|
||||||
return shiftKey ? selection.show() : selection.focus();
|
return shiftKey ? selection.show() : selection.focus();
|
||||||
case 'KeyN':
|
case 'KeyN':
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,6 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
log('extrude', this.file || this.id, 'into', models.length, 'solid(s)');
|
log('extrude', this.file || this.id, 'into', models.length, 'solid(s)');
|
||||||
let { center } = this;
|
let { center } = this;
|
||||||
let ngrp = api.group.new(models);
|
let ngrp = api.group.new(models);
|
||||||
ngrp.floor();
|
|
||||||
ngrp.move(center.x, center.y, center.z);
|
ngrp.move(center.x, center.y, center.z);
|
||||||
// align extrusion with sketch plane
|
// align extrusion with sketch plane
|
||||||
const euler = this.group.rotation;
|
const euler = this.group.rotation;
|
||||||
|
|
@ -560,6 +559,7 @@ class SketchItem {
|
||||||
out.renderOrder = -1;
|
out.renderOrder = -1;
|
||||||
out.sketch_line = this;
|
out.sketch_line = this;
|
||||||
out.position.z += bump + (order * bump);
|
out.position.z += bump + (order * bump);
|
||||||
|
// out.renderOrder = bump * order;
|
||||||
outs.push(out);
|
outs.push(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue