Visualize Your Ideas With Code
fix(2d): fix line jitter under certain conditions (#863)
Jacobfb110a2f3583
diff --git a/packages/2d/src/curves/getPolylineProfile.ts b/packages/2d/src/curves/getPolylineProfile.tsindex bc91bd29..e4ac0e9f 100644--- a/packages/2d/src/curves/getPolylineProfile.ts+++ b/packages/2d/src/curves/getPolylineProfile.ts@@ -65,11 +65,14 @@ export function getPolylineProfile(counter,);- profile.segments.push(line);- profile.segments.push(circle);-- profile.arcLength += line.arcLength;- profile.arcLength += circle.arcLength;+ if (line.arcLength > 0) {+ profile.segments.push(line);+ profile.arcLength += line.arcLength;+ }+ if (circle.arcLength > 0) {+ profile.segments.push(circle);+ profile.arcLength += circle.arcLength;+ }profile.minSin = Math.min(profile.minSin, Math.abs(angleSin));@@ -77,7 +80,10 @@ export function getPolylineProfile(}const line = new LineSegment(last, points[points.length - 1]);- profile.segments.push(line);- profile.arcLength += line.arcLength;+ if (line.arcLength > 0) {+ profile.segments.push(line);+ profile.arcLength += line.arcLength;+ }+return profile;}