add gear generator to mesh tool

This commit is contained in:
Stewart Allen 2024-07-18 10:53:27 -06:00
commit cc93c9a6e9
6 changed files with 143 additions and 2 deletions

View file

@ -318,6 +318,40 @@ let add = {
});
api.modal.bound.gencyl.focus();
}
},
gear(opt = {}) {
function gengear(teeth, module, angle) {
api.modal.hide();
worker.model_gen_gear({
teeth: parseInt(teeth),
module: parseFloat(module),
angle: parseFloat(angle)
}).then(gear => {
const nmdl = new mesh.model({ file: "gear", mesh: gear.toFloat32() });
const ngrp = group.new([ nmdl ]);
ngrp.floor();
});
}
api.modal.dialog({
title: "gear generator",
body: [ h.div({ class: "addgear" }, [
h.label('number of teeth'),
h.input({ value: opt.teeth || 20, size: 5, id: "gteeth" }),
h.label('module (diam / teeth)'),
h.input({ value: opt.module || 3, size: 5, id: "gmodule" }),
h.label('pressure angle'),
h.input({ value: opt.angle || 20, size: 5, id: "gangle" }),
h.button({ _: "create", onclick() {
gengear(
api.modal.bound.gteeth.value,
api.modal.bound.gmodule.value,
api.modal.bound.gangle.value,
)
} })
]) ]
});
api.modal.bound.gteeth.focus();
}
};