add auto-timed spinner on pinned logs. add alt options for calculating face normal deviation. center spinner

This commit is contained in:
Stewart Allen 2022-04-01 09:45:35 -04:00
commit d0ab98f6ac
4 changed files with 31 additions and 10 deletions

View file

@ -114,6 +114,7 @@ const modal = api.modal = {
} }
}; };
let pinner;
// transient logging window bottom/left // transient logging window bottom/left
const log = api.log = { const log = api.log = {
age: 10000, // age out lines more than 10 seconds old age: 10000, // age out lines more than 10 seconds old
@ -149,16 +150,20 @@ const log = api.log = {
return log.pinned ? log.unpin() && log.hide() : log.pin(opt); return log.pinned ? log.unpin() && log.hide() : log.pin(opt);
}, },
pin(opt = { spinner: true }) { pin(opt = { spinner: 100 }) {
log.pinned = true; log.pinned = true;
if (opt.spinner) { if (opt.spinner > 0) {
$('pinner').style.display = 'inline-block'; clearTimeout(pinner);
pinner = setTimeout(() => {
$('pinner').style.display = 'inline-block';
}, opt.spinner);
} }
return log.show(); return log.show();
}, },
unpin() { unpin() {
log.pinned = false; log.pinned = false;
clearTimeout(pinner);
$('pinner').style.display = 'none'; $('pinner').style.display = 'none';
return log.show(); return log.show();
}, },

View file

@ -595,7 +595,7 @@ mesh.model = class MeshModel extends mesh.object {
let timer = setTimeout(() => { let timer = setTimeout(() => {
timer = undefined; timer = undefined;
mesh.api.log.emit("matching surface").pin(); mesh.api.log.emit("matching surface").pin();
}, 500); }, 150);
worker.model_select({ worker.model_select({
id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix, radians id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix, radians
}).then(data => { }).then(data => {

View file

@ -8,6 +8,7 @@ gapp.register("mesh.tool", [], (root, exports) => {
const { mesh } = root; const { mesh } = root;
const { geom } = mesh; const { geom } = mesh;
const { Vector3 } = THREE;
/** /**
* tool for identiying defects and healing them * tool for identiying defects and healing them
@ -163,14 +164,27 @@ mesh.tool = class MeshTool {
for (let face of faces) { for (let face of faces) {
found[face] = 1; found[face] = 1;
} }
// const _v1 = new Vector3();
// const _v2 = new Vector3();
while (check.length) { while (check.length) {
const face = check.shift(); const face = check.shift();
const norm = this.normals[face]; const norm = this.normals[face];
const fadj = this.getAdjacentFaces(face).filter(f => !found[f]); const fadj = this.getAdjacentFaces(face).filter(f => !found[f]);
for (let f of fadj) { for (let f of fadj) {
const fn = this.normals[f] // #1 most accurate
.map((v,i) => Math.abs(norm[i] - v)) // const nf = this.normals[f];
.reduce((a,v) => a + v); // _v1.set(nf[0], nf[1], nf[2]);
// _v2.set(norm[0], norm[1], norm[2]);
// const fn = _v1.angleTo(_v2);
// #2 slightly less so
// const pf = Math.PI / 4;
// const fn = Math.sin(pf * Math.sqrt(this.normals[f]
// .map((v,i) => Math.pow(norm[i] - v, 2))
// .reduce((a,v) => a + v)));
// #3 fastest, still good
const fn = Math.sqrt(this.normals[f]
.map((v,i) => Math.pow(norm[i] - v, 2))
.reduce((a,v) => a + v));
if (fn <= radians) { if (fn <= radians) {
faces.push(f); faces.push(f);
check.push(f) check.push(f)

View file

@ -592,8 +592,10 @@ button.selected:hover {
z-index: 5000; z-index: 5000;
display: none; display: none;
position: absolute; position: absolute;
left: 5px; left: 50%;
bottom: 5px; bottom: 50%;
translateX: -50%;
translateX: -50%;
width: 25px; width: 25px;
height: 25px; height: 25px;
border: 6px solid rgba(0,0,0,0.1); border: 6px solid rgba(0,0,0,0.1);
@ -603,5 +605,5 @@ button.selected:hover {
} }
@keyframes spin { @keyframes spin {
to { -webkit-transform: rotate(360deg); } to { transform: rotate(360deg); }
} }