From 00849cc3c172705add7a4ac61365096334709aae Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 18 Feb 2021 00:12:16 -0500 Subject: [PATCH] add alt/option support paint and cmd/ctrl support erase --- src/kiri/init.js | 2 +- src/mode/fdm/client.js | 39 +++++++++++++++++++++++++-------------- src/mode/fdm/slice.js | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/kiri/init.js b/src/kiri/init.js index 272679cd..58566445 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -1697,7 +1697,7 @@ 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"), - 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}), 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}), diff --git a/src/mode/fdm/client.js b/src/mode/fdm/client.js index 909e8d97..1b84a12a 100644 --- a/src/mode/fdm/client.js +++ b/src/mode/fdm/client.js @@ -10,7 +10,7 @@ FDM = KIRI.driver.FDM, SPACE, API, VIEWS, LANG, PROC, UI, UC, p1, p2, iw, - lastMode, lastView, lastPillar, + lastMode, lastView, lastPillar, fromPillar, isFdmMode = false, addingSupports = false, alert = [], @@ -186,6 +186,7 @@ delbox('supp'); api.hide.alert(alert); api.feature.hover = addingSupports = false; + fromPillar = undefined; }); api.event.on("fdm.supports.clear", func.sclear = () => { func.sdone(); @@ -263,8 +264,8 @@ }); } }); - api.event.on("mouse.hover.up", on => { - let { object, event } = on; + api.event.on("mouse.hover.up", func.hoverup = (on = {}) => { + let { event } = on; if (!isFdmMode) { return; } @@ -286,6 +287,7 @@ }); sa.splice(ix,1); API.conf.save(); + fromPillar = undefined; return; } if (!iw) return; @@ -299,8 +301,11 @@ let ws = (wa.support = wa.support || []); let x = p1.x - ip.x, y = -p1.z - ip.y, z = hy, id = Date.now(); 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)); - addWidgetSupport(iw, rec); + fromPillar = addWidgetSupport(iw, rec); API.conf.save(); }); api.event.on("mouse.hover", data => { @@ -310,11 +315,8 @@ if (!addingSupports) { return; } - // delbox('intZ'); - // delbox('intW'); - // addbox(point, 0xff0000, 'intZ'); delbox('supp'); - const { int, type, point } = data; + const { int, type, point, event } = data; const pillar = int ? int.object.pillar : undefined; if (lastPillar) { lastPillar.box.material.color.r = 0; @@ -323,6 +325,9 @@ if (pillar) { pillar.box.material.color.r = 0.5; lastPillar = pillar; + if (event && (event.metaKey || event.ctrlKey)) { + return func.hoverup(); + } return; } if (int && type === 'widget') { @@ -341,10 +346,10 @@ .append(SPACE.internals().platform) .appendAll(activeSupports()) ; - let i2 = ray.intersectObjects(targets, false); + let i2 = ray.intersectObjects(targets, false).filter(t => t.object.widget); if (i2 && i2.length > 0) { // 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 if (i2.length > 1) { p2 = i2[0].point; @@ -352,12 +357,14 @@ let hy = (p1.y + p2.y) / 2; let dy = Math.abs(p1.y - p2.y); let dw = api.conf.get().process.sliceSupportSize / 2; - // addbox(p2, 0x00ff00, 'intW'); addbox({x:p1.x, y:hy, z:p1.z}, 0x0000dd, 'supp', { x:dw, y:dw, z:dy }); } } + if (event && event.altKey) { + return func.hoverup(); + } }); } @@ -383,18 +390,19 @@ } 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 || {}); // prevent duplicate restore from repeated settings load calls if (!sups[id]) { pos.box = addbox( - { x, y, z }, 0x0000dd, id, + { x, y, z, rz }, 0x0000dd, id, { x:dw, y:dw, z:dh }, { group: widget.mesh } ); pos.box.pillar = Object.assign({widget}, pos); sups[id] = pos; widget.adds.push(pos.box); } + return sups[id]; } 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); const box = boxes[name] = new THREE.Mesh( new THREE.BoxGeometry(dim.x, dim.y, dim.z), @@ -449,6 +457,9 @@ group.add(box); box.groupTo = group; + if (dim.rz) { + opt.rotate = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0,0,1), dim.rz); + } if (opt.rotate) { opt.matrix = new THREE.Matrix4().makeRotationFromQuaternion(opt.rotate); } diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 8aaac1c4..c38e9e73 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -201,7 +201,7 @@ continue; } 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; } // offset pslice tops by spro.sliceSupportOffset