background healing in the worker
This commit is contained in:
parent
a899b517e5
commit
3d9564c1d0
4 changed files with 36 additions and 19 deletions
|
|
@ -126,6 +126,12 @@ KIRI.work = {
|
|||
});
|
||||
},
|
||||
|
||||
heal: function(vertices, callback) {
|
||||
send("heal", {vertices}, function(output) {
|
||||
callback(output);
|
||||
});
|
||||
},
|
||||
|
||||
config: function(obj) {
|
||||
send("config", obj, function(reply) { });
|
||||
},
|
||||
|
|
|
|||
|
|
@ -858,23 +858,20 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
let widgets = API.widgets.all();
|
||||
let marker;
|
||||
if (widgets.length) {
|
||||
marker = API.show.alert("Analyzing objects");
|
||||
marker = API.show.alert("Analyzing objects", 100000);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
let healed = 0;
|
||||
for (let w of widgets) {
|
||||
if (w.heal()) {
|
||||
healed++;
|
||||
}
|
||||
}
|
||||
Promise.all(widgets.map(w => w.heal())).then(mod => {
|
||||
API.hide.alert(marker);
|
||||
let healed = mod.map(m => m).length;
|
||||
if (healed) {
|
||||
API.show.alert(`${healed} Object${healed ? 's':''} healed`);
|
||||
} else {
|
||||
API.show.alert('Nothing found to heal');
|
||||
}
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,9 +307,8 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
};
|
||||
|
||||
PRO.heal = function(debug) {
|
||||
let mesh = this.debugMesh();
|
||||
mesh.heal();
|
||||
if (debug) {
|
||||
let mesh = this.debugMesh().heal();
|
||||
let verts = mesh.vertices;
|
||||
let edges = mesh.edges;
|
||||
let split = mesh.edges.filter(l => l.split);
|
||||
|
|
@ -342,11 +341,15 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
stack.addLayers(layrz);
|
||||
return { mesh, layrz, stack };
|
||||
}
|
||||
if (mesh.newFaces) {
|
||||
this.loadVertices(mesh.unrolled().toFloat32());
|
||||
return this.modified = true;
|
||||
return new Promise((resolve, reject) => {
|
||||
KIRI.client.heal(this.getVertices().array, data => {
|
||||
if (data.vertices) {
|
||||
this.loadVertices(data.vertices);
|
||||
this.modified = true;
|
||||
}
|
||||
return false;
|
||||
resolve(this.modified);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
PRO.debugMesh = function(precision) {
|
||||
|
|
|
|||
|
|
@ -202,6 +202,17 @@ KIRI.worker = {
|
|||
send.done(vertices);
|
||||
},
|
||||
|
||||
heal: function(data, send) {
|
||||
let { vertices } = data;
|
||||
let mesh = new base.Mesh({vertices}).heal();
|
||||
if (mesh.newFaces) {
|
||||
vertices = mesh.unrolled().toFloat32();
|
||||
send.done({vertices}, [vertices]);
|
||||
} else {
|
||||
send.done({});
|
||||
}
|
||||
},
|
||||
|
||||
snap: function(data, send) {
|
||||
current.snap = data;
|
||||
send.done();
|
||||
|
|
|
|||
Loading…
Reference in a new issue