add heal option to context menu
This commit is contained in:
parent
083d6256f3
commit
2c78e5e9cc
6 changed files with 97 additions and 12 deletions
|
|
@ -2581,6 +2581,7 @@
|
|||
$('render-wire').onclick = () => { API.view.wireframe(true, 0, 0.5); };
|
||||
$('render-solid').onclick = () => { API.view.wireframe(false, 0, 1); };
|
||||
// context menu
|
||||
$('context-heal-mesh').onclick = () => { API.widgets.heal() };
|
||||
$('context-export-stl').onclick = () => { objectsExport() };
|
||||
$('context-export-workspace').onclick = () => { profileExport(true) };
|
||||
$('context-clear-workspace').onclick = () => {
|
||||
|
|
|
|||
|
|
@ -388,6 +388,7 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
filter: (fn) => { WIDGETS = WIDGETS.filter(fn) },
|
||||
for: forAllWidgets,
|
||||
load: Widget.loadFromCatalog,
|
||||
heal: healWidgets,
|
||||
meshes: meshArray,
|
||||
opacity: setOpacity,
|
||||
annotate: (id) => {
|
||||
|
|
@ -853,6 +854,26 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
return out;
|
||||
}
|
||||
|
||||
function healWidgets() {
|
||||
let widgets = API.widgets.all();
|
||||
if (widgets.length) {
|
||||
API.show.alert("Analyzing objects");
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
let healed = 0;
|
||||
for (let w of widgets) {
|
||||
if (w.heal()) {
|
||||
healed++;
|
||||
}
|
||||
}
|
||||
if (healed) {
|
||||
API.show.alert(`${healed} Object${healed ? 's':''} healed`);
|
||||
} else {
|
||||
API.show.alert('Nothing found to heal');
|
||||
}
|
||||
}
|
||||
|
||||
function forAllWidgets(f) {
|
||||
WIDGETS.slice().forEach(function(widget) {
|
||||
f(widget);
|
||||
|
|
|
|||
|
|
@ -289,9 +289,12 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
}
|
||||
}
|
||||
if (this.mesh) {
|
||||
this.mesh.geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
||||
this.mesh.geometry.computeFaceNormals();
|
||||
this.mesh.geometry.computeVertexNormals();
|
||||
let geo = this.mesh.geometry;
|
||||
geo.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
||||
geo.setAttribute('normal', undefined);
|
||||
geo.attributes.position.needsUpdate = true;
|
||||
geo.computeFaceNormals();
|
||||
geo.computeVertexNormals();
|
||||
this.points = null;
|
||||
this.meta.vertices = vertices.length / 3;
|
||||
return this;
|
||||
|
|
@ -303,9 +306,18 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
}
|
||||
};
|
||||
|
||||
PRO.heal = function() {
|
||||
let mesh = this.debugMesh();
|
||||
mesh.heal();
|
||||
if (mesh.newFaces) {
|
||||
this.loadVertices(mesh.unrolled().toFloat32());
|
||||
return this.modified = true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
PRO.debugMesh = function(precision) {
|
||||
let mesh = new base.Mesh({precision, vertices: this.getVertices().array});
|
||||
return mesh;
|
||||
return new base.Mesh({precision, vertices: this.getVertices().array});
|
||||
};
|
||||
|
||||
PRO.getVertices = function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue