From 9149376874bf8e9c0050f40beddb6d9d69d41624 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 15 Jan 2022 16:55:26 -0500 Subject: [PATCH] log split --- src/main/mesh.js | 7 ++++++- src/mesh/model.js | 2 +- src/mesh/work.js | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/mesh.js b/src/main/mesh.js index 9576a4c9..dec6cff5 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -175,8 +175,13 @@ let split = { }, select() { + let { log } = mesh.api; let { models, plane } = split.state; - Promise.all(models.map(m => m.split(plane))).then(split.end); + log.emit(`splitting ${models.length} model(s) at ${plane.z.round(3)}`).pin(); + Promise.all(models.map(m => m.split(plane))).then(() => { + log.emit('split complete').unpin(); + split.end(); + }); }, end() { diff --git a/src/mesh/model.js b/src/mesh/model.js index 74366d27..b770932c 100644 --- a/src/mesh/model.js +++ b/src/mesh/model.js @@ -348,7 +348,7 @@ mesh.model = class MeshModel extends mesh.object { // new model becomes top if (o2.length) this.group.add(new mesh.model({ - file: `${this.file}-split`, + file: `${this.file}`, mesh: o2 }).applyMatrix4(m4)).select(); // this becomes bottom diff --git a/src/mesh/work.js b/src/mesh/work.js index c33445a6..fefa7c13 100644 --- a/src/mesh/work.js +++ b/src/mesh/work.js @@ -83,6 +83,8 @@ let model = { return data; }, + // split a model along an axis at a given point + // return two arrays of vertices for each resulting object split(data) { let { id, matrix, z } = data; let o1 = [];