add click-to-delete manual supports

This commit is contained in:
Stewart Allen 2020-11-22 20:06:11 -05:00
commit f2b5b42d7a
4 changed files with 43 additions and 19 deletions

View file

@ -565,6 +565,7 @@
let out = []; let out = [];
forAllWidgets(function(widget) { forAllWidgets(function(widget) {
out.push(widget.mesh); out.push(widget.mesh);
out.appendAll(widget.adds);
}); });
return out; return out;
} }

View file

@ -113,12 +113,15 @@
} }
// rotation stack (for undo) // rotation stack (for undo)
this.roto = []; this.roto = [];
// added meshes
this.adds = [];
// THREE Mesh and points
this.mesh = null; this.mesh = null;
this.points = null; this.points = null;
// todo resolve use of this vs. mesh.bounds // todo resolve use of this vs. mesh.bounds
this.bounds = null; this.bounds = null;
// wireframe
this.wire = null; this.wire = null;
this.topo = null;
this.slices = null; this.slices = null;
this.settings = null; this.settings = null;
this.modified = true; this.modified = true;
@ -564,9 +567,6 @@
if (reply.send_start) { if (reply.send_start) {
widget.xfer = {start: reply.send_start}; widget.xfer = {start: reply.send_start};
} }
if (reply.topo) {
widget.topo = reply.topo;
}
if (reply.stats) { if (reply.stats) {
widget.stats = reply.stats; widget.stats = reply.stats;
} }
@ -576,9 +576,6 @@
if (reply.slice) { if (reply.slice) {
widget.slices.push(KIRI.codec.decode(reply.slice, {mesh:widget.mesh})); widget.slices.push(KIRI.codec.decode(reply.slice, {mesh:widget.mesh}));
} }
if (reply.polish) {
widget.polish = KIRI.codec.decode(reply.polish);
}
if (reply.error) { if (reply.error) {
ondone(false, reply.error); ondone(false, reply.error);
} }

View file

@ -86,9 +86,6 @@ KIRI.worker = {
slices.forEach(function(slice,index) { slices.forEach(function(slice,index) {
send.data({index: index, slice: slice.encode(state)}); send.data({index: index, slice: slice.encode(state)});
}) })
if (self.debug && widget.polish) {
send.data({polish: KIRI.codec.encode(widget.polish)});
}
send.data({send_end: time()}); send.data({send_end: time()});
} }
send.done({done: true}); send.done({done: true});

View file

@ -10,7 +10,7 @@
FDM = KIRI.driver.FDM, FDM = KIRI.driver.FDM,
SPACE, API, SPACE, API,
p1, p2, iw, p1, p2, iw,
lastMode, lastView, lastMode, lastView, lastPillar,
alert = [], alert = [],
func = {}; func = {};
@ -96,6 +96,21 @@
}); });
api.event.on("mouse.hover.up", int => { api.event.on("mouse.hover.up", int => {
delbox('supp'); delbox('supp');
if (lastPillar) {
const {widget, box, id} = lastPillar;
widget.adds.remove(box);
widget.mesh.remove(box);
delete widget.sups[id];
let sa = API.widgets.annotate(widget.id).support;
let ix = 0;
sa.forEach((rec,i) => {
if (rec.id === id) {
ix = i;
}
});
sa.splice(ix,1);
return;
}
if (!iw) return; if (!iw) return;
let hy = (p1.y + p2.y) / 2; let hy = (p1.y + p2.y) / 2;
let dh = Math.abs(p1.y - p2.y); let dh = Math.abs(p1.y - p2.y);
@ -103,23 +118,33 @@
let ip = iw.track.pos; let ip = iw.track.pos;
let wa = api.widgets.annotate(iw.id); let wa = api.widgets.annotate(iw.id);
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; let x = p1.x - ip.x, y = -p1.z - ip.y, z = hy, id = Date.now();
let id = Date.now(); let rec = {x, y, z, dw, dh, id};
ws.push({x, y, z, dw, dh, id}); ws.push(Object.clone(rec));
addWidgetSupport(iw, {x, y, z, dw, dh, id}); addWidgetSupport(iw, rec);
API.conf.save(); API.conf.save();
}); });
api.event.on("mouse.hover", data => { api.event.on("mouse.hover", data => {
// delbox('intZ');
// delbox('intW');
// addbox(point, 0xff0000, 'intZ');
delbox('supp');
const { int, type, point } = data; const { int, type, point } = data;
const pillar = int ? int.object.pillar : undefined;
if (lastPillar) {
lastPillar.box.material.color.r = 0;
lastPillar = null;
}
if (pillar) {
pillar.box.material.color.r = 0.5;
lastPillar = pillar;
return;
}
if (int && type === 'widget') { if (int && type === 'widget') {
iw = int.object.widget || iw; iw = int.object.widget || iw;
} else { } else {
iw = null; iw = null;
} }
// delbox('intZ');
// delbox('intW');
// addbox(point, 0xff0000, 'intZ');
delbox('supp');
p1 = point; p1 = point;
let dir = new THREE.Vector3(0,1,0) let dir = new THREE.Vector3(0,1,0)
let ray = new THREE.Raycaster(point, dir); let ray = new THREE.Raycaster(point, dir);
@ -178,7 +203,9 @@
// 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({x, y, z}, 0x0000dd, 'supp', { x:dw, y:dw, z:dh }, widget.mesh); pos.box = addbox({x, y, z}, 0x0000dd, 'supp', { x:dw, y:dw, z:dh }, widget.mesh);
pos.box.pillar = Object.assign({widget}, pos);
sups[id] = pos; sups[id] = pos;
widget.adds.push(pos.box);
} }
} }
@ -202,8 +229,10 @@
function clearWidgetSupports(widget) { function clearWidgetSupports(widget) {
Object.values(widget.sups || {}).forEach(support => { Object.values(widget.sups || {}).forEach(support => {
widget.adds.remove(support.box);
widget.mesh.remove(support.box); widget.mesh.remove(support.box);
}); });
widget.sups = {};
delete API.widgets.annotate(widget.id).support; delete API.widgets.annotate(widget.id).support;
} }