add threads dialog
This commit is contained in:
parent
3897ac658d
commit
ab1f64196e
2 changed files with 42 additions and 17 deletions
|
|
@ -875,22 +875,47 @@ let add = {
|
||||||
},
|
},
|
||||||
|
|
||||||
threads() {
|
threads() {
|
||||||
worker.model_gen_threads({
|
function genthreads(bound) {
|
||||||
height: 25,
|
const { _height, _radius, _turns, _depth, _steps, _taper } = bound;
|
||||||
radius: 10,
|
api.modal.hide();
|
||||||
turns: 10,
|
let params;
|
||||||
depth: 1,
|
worker.model_gen_threads(params = {
|
||||||
steps: 75,
|
height: parseFloat(_height.value),
|
||||||
taper: true
|
radius: parseFloat(_radius.value),
|
||||||
}).then(verts => {
|
turns: parseFloat(_turns.value),
|
||||||
const nmdl = new mesh.model({ file: "gear", mesh: verts.toFloat32() });
|
depth: parseFloat(_depth.value),
|
||||||
const ngrp = group.new([ nmdl ]);
|
steps: parseFloat(_steps.value),
|
||||||
selection.set([ nmdl ]);
|
taper: _taper.checked ? true : false,
|
||||||
ngrp.floor();
|
}).then(verts => {
|
||||||
// Object.assign(last, params);
|
const nmdl = new mesh.model({ file: "threads", mesh: verts.toFloat32() });
|
||||||
api.prefs.save();
|
const ngrp = group.new([ nmdl ]);
|
||||||
|
selection.set([ nmdl ]);
|
||||||
|
ngrp.floor();
|
||||||
|
Object.assign(last, params);
|
||||||
|
api.prefs.save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let last = api.prefs.map.threads = (api.prefs.map.threads || {});
|
||||||
|
api.modal.dialog({
|
||||||
|
title: "gear generator",
|
||||||
|
body: [ h.div({ class: "additem" }, [
|
||||||
|
h.label('height'),
|
||||||
|
h.input({ value: last.height || 25, size: 5, id: "_height" }),
|
||||||
|
h.label('radius'),
|
||||||
|
h.input({ value: last.radius || 10, size: 5, id: "_radius" }),
|
||||||
|
h.label('turns'),
|
||||||
|
h.input({ value: last.turns || 10, size: 5, id: "_turns" }),
|
||||||
|
h.label('depth'),
|
||||||
|
h.input({ value: last.depth || 1, size: 5, id: "_depth" }),
|
||||||
|
h.label('steps'),
|
||||||
|
h.input({ value: last.steps || 100, size: 5, id: "_steps" }),
|
||||||
|
h.label('taper'),
|
||||||
|
h.input({ id: "_taper", type: "checkbox" }),
|
||||||
|
h.button({ _: "create", onclick() { genthreads(api.modal.bound) } })
|
||||||
|
]) ]
|
||||||
});
|
});
|
||||||
|
api.modal.bound._height.focus();
|
||||||
|
if (last.taper) api.modal.bound._taper.checked = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -839,11 +839,11 @@ mesh.tool = class MeshTool {
|
||||||
let itern = iter + steps;
|
let itern = iter + steps;
|
||||||
let rm = radius - depth;
|
let rm = radius - depth;
|
||||||
let rx = true &&
|
let rx = true &&
|
||||||
// iter < mute_min ? rm + (iter / mute_min) * depth :
|
taper && iter < mute_min ? rm + (iter / mute_min) * depth :
|
||||||
taper && iter > mute_max ? rm + ((iter_max - iter) / mute_min) * depth :
|
taper && iter > mute_max ? rm + ((iter_max - iter) / mute_min) * depth :
|
||||||
radius;
|
radius;
|
||||||
let rxt = true &&
|
let rxt = true &&
|
||||||
// itern < mute_min ? rm + (itern / mute_min) * depth :
|
taper && itern < mute_min ? rm + (itern / mute_min) * depth :
|
||||||
taper && itern > mute_max ? rm + ((iter_max - itern) / mute_min) * depth :
|
taper && itern > mute_max ? rm + ((iter_max - itern) / mute_min) * depth :
|
||||||
radius;
|
radius;
|
||||||
let angle0 = rstep * step - Math.PI/2;
|
let angle0 = rstep * step - Math.PI/2;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue