Checkpoint fore-edge direction fix

This commit is contained in:
2026-06-05 16:32:16 +02:00
parent ee14916661
commit 738e683c7b
2 changed files with 9 additions and 7 deletions
+8 -6
View File
@@ -634,7 +634,7 @@ function buildSupportSolvedLine(anchor, target, lowerLine, side, segments, segme
let cursor = 0;
for (let index = 1; index <= segments; index += 1) {
const stepLength = segmentLengths[index - 1];
const next = nextPointOnSupportPath(support, cursor, points[index - 1], stepLength);
const next = nextPointOnSupportPath(support, cursor, points[index - 1], stepLength, side, target);
points.push(next.point);
cursor = next.cursor;
}
@@ -704,7 +704,7 @@ function createMeasuredPath(points) {
return { points, lengths, totalLength: lengths[lengths.length - 1] ?? 0 };
}
function nextPointOnSupportPath(support, cursor, previous, segmentLength) {
function nextPointOnSupportPath(support, cursor, previous, segmentLength, side, target) {
let segmentIndex = Math.max(0, support.lengths.findIndex((length) => length > cursor) - 1);
if (segmentIndex < 0) segmentIndex = support.points.length - 2;
let startDistance = cursor;
@@ -713,7 +713,7 @@ function nextPointOnSupportPath(support, cursor, previous, segmentLength) {
const to = support.points[segmentIndex + 1];
const endDistance = support.lengths[segmentIndex + 1];
const hit = circleSegmentIntersection(previous, from, to, segmentLength);
if (hit !== null) {
if (hit !== null && side * (hit.point.x - previous.x) >= -0.000001) {
return {
point: hit.point,
cursor: THREE.MathUtils.lerp(startDistance, endDistance, hit.t)
@@ -723,7 +723,7 @@ function nextPointOnSupportPath(support, cursor, previous, segmentLength) {
from = support.points[segmentIndex];
startDistance = support.lengths[segmentIndex];
}
return extendSupportPathEnd(support, previous, segmentLength);
return extendSupportPathEnd(support, previous, segmentLength, side, target);
}
function pointAtMeasuredPathDistance(support, distance) {
@@ -768,10 +768,12 @@ function circleSegmentIntersection(center, from, to, radius) {
};
}
function extendSupportPathEnd(support, previous, segmentLength) {
function extendSupportPathEnd(support, previous, segmentLength, side, target) {
const last = support.points[support.points.length - 1];
const before = support.points[Math.max(0, support.points.length - 2)];
const direction = normalizedVector(last.x - before.x, last.y - before.y);
const supportDirection = normalizedVector(last.x - before.x, last.y - before.y);
const targetDirection = normalizedVector(target.x - previous.x, target.y - previous.y);
const direction = side * supportDirection.x >= 0.05 ? supportDirection : targetDirection;
const point = {
x: previous.x + direction.x * segmentLength,
y: previous.y + direction.y * segmentLength