add alt/option support paint and cmd/ctrl support erase

This commit is contained in:
Stewart Allen 2021-02-18 00:12:16 -05:00
commit 00849cc3c1
3 changed files with 27 additions and 16 deletions

View file

@ -1697,7 +1697,7 @@
fdmSupport: UC.newGroup(LANG.sp_menu, null, {modes:FDM, marker:false}), fdmSupport: UC.newGroup(LANG.sp_menu, null, {modes:FDM, marker:false}),
sliceSupportNozzle: UC.newSelect(LANG.sp_nozl_s, {title:LANG.sp_nozl_l, modes:FDM}, "extruders"), sliceSupportNozzle: UC.newSelect(LANG.sp_nozl_s, {title:LANG.sp_nozl_l, modes:FDM}, "extruders"),
sliceSupportDensity: UC.newInput(LANG.sp_dens_s, {title:LANG.sp_dens_l, convert:UC.toFloat, bound:UC.bound(0.05,1.0), modes:FDM}), sliceSupportDensity: UC.newInput(LANG.sp_dens_s, {title:LANG.sp_dens_l, convert:UC.toFloat, bound:UC.bound(0.0,1.0), modes:FDM}),
fdmSep: UC.newBlank({class:"pop-sep", modes:FDM}), fdmSep: UC.newBlank({class:"pop-sep", modes:FDM}),
sliceSupportSize: UC.newInput(LANG.sp_size_s, {title:LANG.sp_size_l, bound:UC.bound(1.0,200.0), convert:UC.toFloat, modes:FDM}), sliceSupportSize: UC.newInput(LANG.sp_size_s, {title:LANG.sp_size_l, bound:UC.bound(1.0,200.0), convert:UC.toFloat, modes:FDM}),
sliceSupportOffset: UC.newInput(LANG.sp_offs_s, {title:LANG.sp_offs_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM}), sliceSupportOffset: UC.newInput(LANG.sp_offs_s, {title:LANG.sp_offs_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM}),

View file

@ -10,7 +10,7 @@
FDM = KIRI.driver.FDM, FDM = KIRI.driver.FDM,
SPACE, API, VIEWS, LANG, PROC, UI, UC, SPACE, API, VIEWS, LANG, PROC, UI, UC,
p1, p2, iw, p1, p2, iw,
lastMode, lastView, lastPillar, lastMode, lastView, lastPillar, fromPillar,
isFdmMode = false, isFdmMode = false,
addingSupports = false, addingSupports = false,
alert = [], alert = [],
@ -186,6 +186,7 @@
delbox('supp'); delbox('supp');
api.hide.alert(alert); api.hide.alert(alert);
api.feature.hover = addingSupports = false; api.feature.hover = addingSupports = false;
fromPillar = undefined;
}); });
api.event.on("fdm.supports.clear", func.sclear = () => { api.event.on("fdm.supports.clear", func.sclear = () => {
func.sdone(); func.sdone();
@ -263,8 +264,8 @@
}); });
} }
}); });
api.event.on("mouse.hover.up", on => { api.event.on("mouse.hover.up", func.hoverup = (on = {}) => {
let { object, event } = on; let { event } = on;
if (!isFdmMode) { if (!isFdmMode) {
return; return;
} }
@ -286,6 +287,7 @@
}); });
sa.splice(ix,1); sa.splice(ix,1);
API.conf.save(); API.conf.save();
fromPillar = undefined;
return; return;
} }
if (!iw) return; if (!iw) return;
@ -299,8 +301,11 @@
let ws = (wa.support = wa.support || []); let ws = (wa.support = wa.support || []);
let x = p1.x - ip.x, y = -p1.z - ip.y, z = hy, id = Date.now(); let x = p1.x - ip.x, y = -p1.z - ip.y, z = hy, id = Date.now();
let rec = {x, y, z, dw, dh, id}; let rec = {x, y, z, dw, dh, id};
if (fromPillar && event && event.shiftKey) {
// console.log("lerp pillars from", fromPillar, 'to', rec);
}
ws.push(Object.clone(rec)); ws.push(Object.clone(rec));
addWidgetSupport(iw, rec); fromPillar = addWidgetSupport(iw, rec);
API.conf.save(); API.conf.save();
}); });
api.event.on("mouse.hover", data => { api.event.on("mouse.hover", data => {
@ -310,11 +315,8 @@
if (!addingSupports) { if (!addingSupports) {
return; return;
} }
// delbox('intZ');
// delbox('intW');
// addbox(point, 0xff0000, 'intZ');
delbox('supp'); delbox('supp');
const { int, type, point } = data; const { int, type, point, event } = data;
const pillar = int ? int.object.pillar : undefined; const pillar = int ? int.object.pillar : undefined;
if (lastPillar) { if (lastPillar) {
lastPillar.box.material.color.r = 0; lastPillar.box.material.color.r = 0;
@ -323,6 +325,9 @@
if (pillar) { if (pillar) {
pillar.box.material.color.r = 0.5; pillar.box.material.color.r = 0.5;
lastPillar = pillar; lastPillar = pillar;
if (event && (event.metaKey || event.ctrlKey)) {
return func.hoverup();
}
return; return;
} }
if (int && type === 'widget') { if (int && type === 'widget') {
@ -341,10 +346,10 @@
.append(SPACE.internals().platform) .append(SPACE.internals().platform)
.appendAll(activeSupports()) .appendAll(activeSupports())
; ;
let i2 = ray.intersectObjects(targets, false); let i2 = ray.intersectObjects(targets, false).filter(t => t.object.widget);
if (i2 && i2.length > 0) { if (i2 && i2.length > 0) {
// prevent false matches close to origin of ray // prevent false matches close to origin of ray
i2 = i2.filter(i => i.distance > 0.01); i2 = i2.filter(i => i.distance > 0.1);
// prevent single point base to top matches // prevent single point base to top matches
if (i2.length > 1) { if (i2.length > 1) {
p2 = i2[0].point; p2 = i2[0].point;
@ -352,12 +357,14 @@
let hy = (p1.y + p2.y) / 2; let hy = (p1.y + p2.y) / 2;
let dy = Math.abs(p1.y - p2.y); let dy = Math.abs(p1.y - p2.y);
let dw = api.conf.get().process.sliceSupportSize / 2; let dw = api.conf.get().process.sliceSupportSize / 2;
// addbox(p2, 0x00ff00, 'intW');
addbox({x:p1.x, y:hy, z:p1.z}, 0x0000dd, 'supp', { addbox({x:p1.x, y:hy, z:p1.z}, 0x0000dd, 'supp', {
x:dw, y:dw, z:dy x:dw, y:dw, z:dy
}); });
} }
} }
if (event && event.altKey) {
return func.hoverup();
}
}); });
} }
@ -383,18 +390,19 @@
} }
function addWidgetSupport(widget, pos) { function addWidgetSupport(widget, pos) {
const { x, y, z, dw, dh, id } = pos; const { x, y, z, rz, dw, dh, id } = pos;
const sups = widget.sups = (widget.sups || {}); const sups = widget.sups = (widget.sups || {});
// prevent duplicate restore from repeated settings load calls // prevent duplicate restore from repeated settings load calls
if (!sups[id]) { if (!sups[id]) {
pos.box = addbox( pos.box = addbox(
{ x, y, z }, 0x0000dd, id, { x, y, z, rz }, 0x0000dd, id,
{ x:dw, y:dw, z:dh }, { group: widget.mesh } { x:dw, y:dw, z:dh }, { group: widget.mesh }
); );
pos.box.pillar = Object.assign({widget}, pos); pos.box.pillar = Object.assign({widget}, pos);
sups[id] = pos; sups[id] = pos;
widget.adds.push(pos.box); widget.adds.push(pos.box);
} }
return sups[id];
} }
function updateVisiblity() { function updateVisiblity() {
@ -431,7 +439,7 @@
} }
} }
function addbox(point, color, name, dim = {x:1,y:1,z:1}, opt = {}) { function addbox(point, color, name, dim = {x:1,y:1,z:1,rz:0}, opt = {}) {
delbox(name); delbox(name);
const box = boxes[name] = new THREE.Mesh( const box = boxes[name] = new THREE.Mesh(
new THREE.BoxGeometry(dim.x, dim.y, dim.z), new THREE.BoxGeometry(dim.x, dim.y, dim.z),
@ -449,6 +457,9 @@
group.add(box); group.add(box);
box.groupTo = group; box.groupTo = group;
if (dim.rz) {
opt.rotate = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0,0,1), dim.rz);
}
if (opt.rotate) { if (opt.rotate) {
opt.matrix = new THREE.Matrix4().makeRotationFromQuaternion(opt.rotate); opt.matrix = new THREE.Matrix4().makeRotationFromQuaternion(opt.rotate);
} }

View file

@ -201,7 +201,7 @@
continue; continue;
} }
for (let pslice of peer.slices) { for (let pslice of peer.slices) {
if (Math.abs(Math.abs(pslice.z - slice.z) - gap) > 0.05) { if (Math.abs(Math.abs(pslice.z - slice.z) - gap) > 0.1) {
continue; continue;
} }
// offset pslice tops by spro.sliceSupportOffset // offset pslice tops by spro.sliceSupportOffset