fix hole toggling bugs
This commit is contained in:
parent
7757864e65
commit
43cd45cb90
1 changed files with 67 additions and 44 deletions
|
|
@ -1183,15 +1183,32 @@ CAM.init = function(kiri, api) {
|
|||
const {tool,mark} = poppedRec
|
||||
let diam = new CAM.Tool(settings,tool).fluteDiameter()
|
||||
|
||||
api.hide.alert(alert);
|
||||
alert = api.show.alert("[esc] cancels trace editing");
|
||||
kiri.api.widgets.opacity(0.8);
|
||||
|
||||
// console.log(kiri.api.widgets.all())
|
||||
const widgets = kiri.api.widgets.all()
|
||||
|
||||
if(individual && widgets.some(w=>w.holes!= undefined) ){ // if any widget already has cached holes
|
||||
// console.log("already has cached holes",widgets)
|
||||
|
||||
widgets.forEach(widget => {
|
||||
widget.holes.forEach(hole => {
|
||||
hole.mesh.parent = widget.mesh;
|
||||
widget.mesh.add(hole.mesh);
|
||||
widget.adds.push(hole.mesh);
|
||||
});
|
||||
})
|
||||
|
||||
}else{ // if no widget has cached holes
|
||||
console.log("no cached holes, must slice")
|
||||
await CAM.holes(individual?0:diam,(centers)=>{
|
||||
console.log("centers",centers)
|
||||
//flattened list of all hole centers and if they are selected
|
||||
kiri.api.widgets.for(widget => {
|
||||
const {holes} = centers.find(center=>center.id = widget.id)
|
||||
widget.holes = holes;
|
||||
api.hide.alert(alert);
|
||||
alert = api.show.alert("[esc] cancels trace editing");
|
||||
kiri.api.widgets.opacity(0.8);
|
||||
|
||||
holes.toRecord = () => {
|
||||
return holes.map(hole => {
|
||||
|
|
@ -1224,16 +1241,20 @@ CAM.init = function(kiri, api) {
|
|||
}
|
||||
})
|
||||
//add hole data to record
|
||||
|
||||
poppedRec.drills[widget.id] = holes.toRecord();
|
||||
// console.log("hole widget:",widget)
|
||||
|
||||
|
||||
widget.holes.forEach(hole => {
|
||||
hole.mesh.parent = widget.mesh;
|
||||
widget.mesh.add(hole.mesh);
|
||||
widget.adds.push(hole.mesh);
|
||||
});
|
||||
console.log("hole widget:",widget)
|
||||
|
||||
})
|
||||
});
|
||||
// console.log(" widgets sliced",kiri.api.widgets.all())
|
||||
}
|
||||
}
|
||||
|
||||
func.selectHolesHover = function(data) {
|
||||
|
|
@ -1279,6 +1300,7 @@ CAM.init = function(kiri, api) {
|
|||
func.selectHoleToggle(object.hole);
|
||||
|
||||
let widget = object.parent.widget; //only update the parent widget
|
||||
console.log(poppedRec,poppedRec.drills)
|
||||
poppedRec.drills[widget.id] = widget.holes.toRecord();
|
||||
|
||||
}
|
||||
|
|
@ -1305,6 +1327,7 @@ CAM.init = function(kiri, api) {
|
|||
widget.mesh.remove(hole.mesh);
|
||||
})
|
||||
}
|
||||
widget.adds = []
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue