From 8c9ff300dcb30e8a09f518f86844963619eeddd5 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 15 Jun 2025 18:59:59 -0400 Subject: [PATCH] fix sketch centering --- src2/mesh/api.js | 7 +++++-- src2/mesh/sketch.js | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src2/mesh/api.js b/src2/mesh/api.js index ea8355a7..61400ccf 100644 --- a/src2/mesh/api.js +++ b/src2/mesh/api.js @@ -293,7 +293,7 @@ const selection = { }, focus() { - api.focus(selection.list()); + selection.count() && api.focus(selection.list()); }, bounds() { @@ -1537,7 +1537,10 @@ const api = { if (isNaN(center.x * center.y * center.z)) { center = { x: 0, y: 0, z: 0 }; } - let { normal } = Array.isArray(object) ? object[0].object : object.object; + let { normal } = Array.isArray(object) && object.length ? + object[0].object : + object.object || + { }; let left, up; if (normal) { let { x, y, z } = normal; diff --git a/src2/mesh/sketch.js b/src2/mesh/sketch.js index 42fdd408..604d8fe3 100644 --- a/src2/mesh/sketch.js +++ b/src2/mesh/sketch.js @@ -118,6 +118,11 @@ class MeshSketch extends meshObject { return this.group; } + get bounds() { + this.plane.geometry.computeBoundingBox(); + return this.plane.geometry.boundingBox.clone(); + } + get meshes() { return this.group.children.filter(c => { return c.sketch || (c.sketch_item && c.sketch_item.selected) ? c : undefined