add paint erase supports
This commit is contained in:
parent
12448e6523
commit
f0ee714404
2 changed files with 24 additions and 12 deletions
|
|
@ -129,7 +129,7 @@ export function menu() {
|
||||||
separator: newBlank({ class:"set-sep", driven, show:manualSupport }),
|
separator: newBlank({ class:"set-sep", driven, show:manualSupport }),
|
||||||
sliceSupportManual: newRow([
|
sliceSupportManual: newRow([
|
||||||
(ui.ssmAdd = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
|
(ui.ssmAdd = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
|
||||||
(ui.ssmDun = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-check"></i>'})),
|
(ui.ssmDel = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-minus"></i>'})),
|
||||||
(ui.ssmClr = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-trash-alt"></i>'}))
|
(ui.ssmClr = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-trash-alt"></i>'}))
|
||||||
], {class:"ext-buttons f-row", show:manualSupport}),
|
], {class:"ext-buttons f-row", show:manualSupport}),
|
||||||
_____: newGroup(LANG.fl_menu, $('fdm-base'), { modes:FDM, driven, hideable, separator, group:"fdm-base" }),
|
_____: newGroup(LANG.fl_menu, $('fdm-base'), { modes:FDM, driven, hideable, separator, group:"fdm-base" }),
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ const LANG = api.language.current;
|
||||||
|
|
||||||
let lastView,
|
let lastView,
|
||||||
addingSupports = false,
|
addingSupports = false,
|
||||||
|
removingSupports = false,
|
||||||
isFdmMode = false,
|
isFdmMode = false,
|
||||||
alert = [],
|
alert = [],
|
||||||
func = {},
|
func = {},
|
||||||
|
|
@ -164,8 +165,8 @@ export function init() {
|
||||||
api.event.on("button.click", target => {
|
api.event.on("button.click", target => {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case api.ui.ssaGen: return func.sgen();
|
case api.ui.ssaGen: return func.sgen();
|
||||||
case api.ui.ssmAdd: return func.sadd();
|
case api.ui.ssmAdd: return func.sadd({ remove: false });
|
||||||
case api.ui.ssmDun: return func.sdone();
|
case api.ui.ssmDel: return func.sadd({ remove: true });
|
||||||
case api.ui.ssmClr: return func.sclear();
|
case api.ui.ssmClr: return func.sclear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -178,11 +179,15 @@ export function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// manual add supports
|
// manual add supports
|
||||||
func.sadd = () => {
|
func.sadd = ({ remove } = { remove: false }) => {
|
||||||
if (addingSupports) {
|
if (addingSupports) {
|
||||||
return func.sdone();
|
func.sdone();
|
||||||
|
if (removingSupports === remove) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
alert = api.show.alert("[esc] key cancels support editing", 1000);
|
removingSupports = remove;
|
||||||
|
alert = api.show.alert(`[esc] key cancels ${remove?'removing':'adding'} supports`, 1000);
|
||||||
api.feature.hover = addingSupports = true;
|
api.feature.hover = addingSupports = true;
|
||||||
api.feature.on_mouse_down = (int) => {
|
api.feature.on_mouse_down = (int) => {
|
||||||
if (int) {
|
if (int) {
|
||||||
|
|
@ -193,7 +198,7 @@ export function init() {
|
||||||
};
|
};
|
||||||
api.feature.on_mouse_drag = ({ int }) => {
|
api.feature.on_mouse_drag = ({ int }) => {
|
||||||
if (int?.length && int[0].face.normal.z < 0) {
|
if (int?.length && int[0].face.normal.z < 0) {
|
||||||
func.sadd_point(int[0].point, down.widget);
|
func.sadd_point(int[0].point, down.widget, remove);
|
||||||
}
|
}
|
||||||
return [ down.widget.mesh ];
|
return [ down.widget.mesh ];
|
||||||
// return api.widgets.meshes();
|
// return api.widgets.meshes();
|
||||||
|
|
@ -210,7 +215,7 @@ export function init() {
|
||||||
api.space.update();
|
api.space.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
func.sadd_point = (point, widget) => {
|
func.sadd_point = (point, widget, remove) => {
|
||||||
let { x, y, z } = point;
|
let { x, y, z } = point;
|
||||||
let rec = {
|
let rec = {
|
||||||
point: { x, y:-z, z:y },
|
point: { x, y:-z, z:y },
|
||||||
|
|
@ -221,15 +226,21 @@ export function init() {
|
||||||
let pt = newPoint(x, -z, y);
|
let pt = newPoint(x, -z, y);
|
||||||
for (let r of paint) {
|
for (let r of paint) {
|
||||||
let { point } = r;
|
let { point } = r;
|
||||||
if (newPoint(point.x, point.y, point.z).distTo2D(pt) < 1) {
|
let dist = newPoint(point.x, point.y, point.z).distTo2D(pt);
|
||||||
|
if (remove && dist < 2) {
|
||||||
|
r.delete = true;
|
||||||
|
} else if (dist < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paint.push(rec);
|
if (remove) {
|
||||||
|
paint = widget.anno.paint = paint.filter(rec => !rec.delete);
|
||||||
|
} else {
|
||||||
|
paint.push(rec);
|
||||||
|
}
|
||||||
updatePaintOverlay(widget.mesh.material[0], paint);
|
updatePaintOverlay(widget.mesh.material[0], paint);
|
||||||
api.space.update();
|
api.space.update();
|
||||||
api.conf.save();
|
api.conf.save();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// manual add done
|
// manual add done
|
||||||
|
|
@ -309,6 +320,7 @@ export function init() {
|
||||||
// rotate supports when rotation is constrained to Z axis
|
// rotate supports when rotation is constrained to Z axis
|
||||||
rotateWidgetPaint(widget, z);
|
rotateWidgetPaint(widget, z);
|
||||||
}
|
}
|
||||||
|
api.conf.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
api.event.on("mouse.hover.up", func.hoverup = (on = {}) => {
|
api.event.on("mouse.hover.up", func.hoverup = (on = {}) => {
|
||||||
|
|
@ -319,7 +331,7 @@ export function init() {
|
||||||
if (object && down.z < 0) {
|
if (object && down.z < 0) {
|
||||||
let { point } = object;
|
let { point } = object;
|
||||||
let { widget } = object.object;
|
let { widget } = object.object;
|
||||||
func.sadd_point(point, widget);
|
func.sadd_point(point, widget, removingSupports);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue