add more gear parameters, better dialog

This commit is contained in:
Stewart Allen 2024-07-19 12:43:13 -04:00
commit 0b69cfdc7e
6 changed files with 56 additions and 46 deletions

View file

@ -401,21 +401,18 @@ let model = {
},
gen_gear(data, send) {
const { teeth, module, angle, twist, shaft, z } = data;
let points = new mesh.tool()
.generateGear(teeth, module, angle)
.map(v => [...v, 0]).flat();
let poly = newPolygon().addVerts(points);
const { teeth, module, angle, twist, shaft, offset, height } = data;
const { gear, pitch } = new mesh.tool().generateGear(teeth, module, angle, offset);
const points = gear.map(v => [...v, 0]).flat();
const poly = newPolygon().addVerts(points);
if (shaft) {
poly.addInner(
newPolygon().centerCircle({
x:0, y:0, z:0
}, shaft / 2, Math.min(20 + shaft,100))
);
const nump = Math.min(30 + shaft, 150);
const srad = shaft / 2;
poly.addInner( newPolygon().centerCircle({ x:0, y:0, z:0 }, srad, nump) );
}
let verts = poly.extrude(z || 15);
const verts = poly.extrude(height || 15);
if (twist) {
let rad = base.util.toRadians(twist);
const rad = base.util.toRadians(twist);
for (let i=0; i<verts.length; i += 3) {
if (Math.abs(verts[i+2]) < 0.001) {
let [x, y] = base.util.rotate(