From aa49b8b04e28c8546bf3e8393fcf794a762c535d Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Thu, 17 Jul 2025 18:57:04 -0600 Subject: [PATCH] add configurable vertex tolerance --- src/mesh/tool.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesh/tool.js b/src/mesh/tool.js index 8391da56..73e0d687 100644 --- a/src/mesh/tool.js +++ b/src/mesh/tool.js @@ -322,8 +322,11 @@ class MeshTool { face = Number(face) const radianTolerance = 8 * (Math.PI/180); + const vertexTolerance = 1e-4; //helper function - const dissimilar = (a,b,c) => a!==b && a!==c && b!==c + const dissimilar = (a,b,c) => Math.abs(a-b) > vertexTolerance && + Math.abs(b-c) > vertexTolerance && + Math.abs(a-c) > vertexTolerance; let found = {}, out = [face], @@ -338,7 +341,7 @@ class MeshTool { //check for errors, and throw if found if(dissimilar(...zs)){ - throw "face must have only 2 Z values" + throw `face must have only 2 Z values. found: ${zs.join(", ")}` }else if(Math.abs( faces[face * 6 + 2] > 1e-6 )){ throw "face's normal must be perpendicular to Z axis" }