wire up basic slicing visualization
This commit is contained in:
parent
5f11231e9e
commit
96f50d36a7
5 changed files with 52 additions and 47 deletions
|
|
@ -299,7 +299,7 @@ function ui_build() {
|
|||
// h.div({ class: "vsep" }),
|
||||
h.button({ _: 'automatic', onclick: tool.repair }),
|
||||
h.button({ _: 'analyze', onclick: tool.analyze }),
|
||||
h.button({ _: 'rebuild', onclick: tool.rebuild }),
|
||||
// h.button({ _: 'rebuild', onclick: tool.rebuild }),
|
||||
h.button({ _: 'clean', onclick: tool.clean }),
|
||||
]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -158,7 +158,21 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
matrix: this.matrix,
|
||||
id: this.id
|
||||
}).then(data => {
|
||||
console.log({rebuild: this.od, data});
|
||||
console.log({rebuild: this.id, data});
|
||||
let points = [];
|
||||
for (let arr of data) {
|
||||
arr.push(arr[0]);
|
||||
for (let i=0; i<arr.length-1; i++) {
|
||||
let p1 = arr[i];
|
||||
let p2 = arr[i+1];
|
||||
points.push(new THREE.Vector3().fromArray(p1));
|
||||
points.push(new THREE.Vector3().fromArray(p2));
|
||||
}
|
||||
}
|
||||
let material = new THREE.LineBasicMaterial( { color: 0xdddddd } );
|
||||
let geometry = new THREE.BufferGeometry().setFromPoints(points);
|
||||
let line = new THREE.LineSegments(geometry, material);
|
||||
space.scene.add(line);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -291,16 +291,23 @@ let model = {
|
|||
return { faces, edges, verts, point };
|
||||
},
|
||||
|
||||
rebuild(data) {
|
||||
rebuild(data, send) {
|
||||
send.async();
|
||||
let { id, matrix } = data;
|
||||
log(`${id} | rebuilding...`);
|
||||
let points = translate_encode(id, matrix);
|
||||
log(`${id} | ${points.length} points`);
|
||||
base.slice(points, { flat: true, autoDim: true }).then(sliced => {
|
||||
console.log({sliced});
|
||||
log(`${id} | ${sliced.length} slices`);
|
||||
});
|
||||
return [];
|
||||
base.slice(points, { flat: true, autoDim: true, zinc: 0 })
|
||||
.then(sliced => {
|
||||
let layers = [];
|
||||
log(`${id} | ${sliced.length} slices`);
|
||||
for (let slice of sliced) {
|
||||
for (let poly of slice.groups) {
|
||||
layers.push(poly.points.map(p => [ p.x, p.y, p.z ]));
|
||||
}
|
||||
}
|
||||
send.done(layers);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue