add toggle on click to the holes
This commit is contained in:
parent
654092b18c
commit
29f4f98ad7
2 changed files with 49 additions and 5 deletions
|
|
@ -1205,7 +1205,8 @@ CAM.init = function(kiri, api) {
|
|||
mesh.position.z -= depth/2
|
||||
mesh.rotation.x = Math.PI/2
|
||||
|
||||
hole.mesh = mesh;
|
||||
hole.mesh = mesh; //add pointers to both objects
|
||||
mesh.hole = hole;
|
||||
hole.updateColor = ()=>{
|
||||
hole.mesh.material.color.set(hole.selected?0xFF0000:0x39e366)
|
||||
}
|
||||
|
|
@ -1215,6 +1216,7 @@ CAM.init = function(kiri, api) {
|
|||
})
|
||||
widget.holes.forEach(hole => {
|
||||
widget.mesh.add(hole.mesh);
|
||||
widget.adds.push(hole.mesh);
|
||||
});
|
||||
console.log("hole widget:",widget)
|
||||
})
|
||||
|
|
@ -1222,9 +1224,52 @@ CAM.init = function(kiri, api) {
|
|||
}
|
||||
|
||||
func.selectHolesHover = function(data) {
|
||||
|
||||
|
||||
if (lastTrace) {
|
||||
let { color, colorSave } = lastTrace.material[0] || lastTrace.material;
|
||||
color.r = colorSave.r;
|
||||
color.g = colorSave.g;
|
||||
color.b = colorSave.b;
|
||||
lastTrace.position.z -= 0.01;
|
||||
}
|
||||
if (data.type === 'platform') {
|
||||
lastTrace = null;
|
||||
return;
|
||||
}
|
||||
// console.log("selectHolesHover",data)
|
||||
// if (!data.int.object.trace) {
|
||||
// return;
|
||||
// }
|
||||
// lastTrace = data.int.object;
|
||||
// lastTrace.position.z += 0.01;
|
||||
// if (lastTrace.selected) {
|
||||
// let event = data.event;
|
||||
// let target = event.target;
|
||||
// let { clientX, clientY } = event;
|
||||
// let { offsetWidth, offsetHeight } = target;
|
||||
// }
|
||||
// let material = lastTrace.material[0] || lastTrace.material;
|
||||
// let color = material.color;
|
||||
// let {r, g, b} = color;
|
||||
// material.colorSave = {r, g, b};
|
||||
// color.r = 0;
|
||||
// color.g = 0;
|
||||
// color.b = 1;
|
||||
|
||||
}
|
||||
|
||||
func.selectHolesHoverUp = function(int, ev) {
|
||||
console.log("selectHolesHoverUp",int)
|
||||
if (!int) return; //if not a hole mesh return
|
||||
let { object } = int;
|
||||
func.selectHoleToggle(object.hole);
|
||||
|
||||
}
|
||||
|
||||
func.selectHoleToggle = function(hole) {
|
||||
hole.selected = !hole.selected;
|
||||
hole.updateColor();
|
||||
}
|
||||
|
||||
func.selectHolesDone = () => {
|
||||
|
|
|
|||
|
|
@ -1461,19 +1461,18 @@ class OpDrill extends CamOp {
|
|||
|
||||
async slice(progress) {
|
||||
let { op, state } = this;
|
||||
let { settings, addSlices, tslices, updateToolDiams } = state;
|
||||
let { settings, addSlices, widget, updateToolDiams } = state;
|
||||
let { zBottom, zThru, thruHoles, color } = state;
|
||||
|
||||
let drills = [],
|
||||
drillTool = new CAM.Tool(settings, op.tool),
|
||||
drillToolDiam = drillTool.fluteDiameter(),
|
||||
centerDiff = drillToolDiam * 0.1,
|
||||
area = (drillToolDiam/2) * (drillToolDiam/2) * Math.PI,
|
||||
areaDelta = op.mark ? Infinity : area * 0.05,
|
||||
sliceOut = this.sliceOut = [];
|
||||
|
||||
updateToolDiams(drillToolDiam);
|
||||
|
||||
console.log(widget)
|
||||
|
||||
// for each slice, look for polygons with 98.5% circularity whose
|
||||
// area is within the tolerance of a circle matching the tool diameter
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue