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; let cursor = 0;
for (let index = 1; index <= segments; index += 1) { for (let index = 1; index <= segments; index += 1) {
const stepLength = segmentLengths[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); points.push(next.point);
cursor = next.cursor; cursor = next.cursor;
} }
@@ -704,7 +704,7 @@ function createMeasuredPath(points) {
return { points, lengths, totalLength: lengths[lengths.length - 1] ?? 0 }; 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); let segmentIndex = Math.max(0, support.lengths.findIndex((length) => length > cursor) - 1);
if (segmentIndex < 0) segmentIndex = support.points.length - 2; if (segmentIndex < 0) segmentIndex = support.points.length - 2;
let startDistance = cursor; let startDistance = cursor;
@@ -713,7 +713,7 @@ function nextPointOnSupportPath(support, cursor, previous, segmentLength) {
const to = support.points[segmentIndex + 1]; const to = support.points[segmentIndex + 1];
const endDistance = support.lengths[segmentIndex + 1]; const endDistance = support.lengths[segmentIndex + 1];
const hit = circleSegmentIntersection(previous, from, to, segmentLength); const hit = circleSegmentIntersection(previous, from, to, segmentLength);
if (hit !== null) { if (hit !== null && side * (hit.point.x - previous.x) >= -0.000001) {
return { return {
point: hit.point, point: hit.point,
cursor: THREE.MathUtils.lerp(startDistance, endDistance, hit.t) cursor: THREE.MathUtils.lerp(startDistance, endDistance, hit.t)
@@ -723,7 +723,7 @@ function nextPointOnSupportPath(support, cursor, previous, segmentLength) {
from = support.points[segmentIndex]; from = support.points[segmentIndex];
startDistance = support.lengths[segmentIndex]; startDistance = support.lengths[segmentIndex];
} }
return extendSupportPathEnd(support, previous, segmentLength); return extendSupportPathEnd(support, previous, segmentLength, side, target);
} }
function pointAtMeasuredPathDistance(support, distance) { 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 last = support.points[support.points.length - 1];
const before = support.points[Math.max(0, support.points.length - 2)]; 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 = { const point = {
x: previous.x + direction.x * segmentLength, x: previous.x + direction.x * segmentLength,
y: previous.y + direction.y * segmentLength y: previous.y + direction.y * segmentLength
+1 -1
View File
@@ -74,6 +74,6 @@
<button id="fast_forward" type="button">Fast Forward</button> <button id="fast_forward" type="button">Fast Forward</button>
<output id="flip_count">0 / 10</output> <output id="flip_count">0 / 10</output>
</div> </div>
<script type="module" src="/js/webgl-book-shape-lab.js?v=deterministic-page-support-1"></script> <script type="module" src="/js/webgl-book-shape-lab.js?v=deterministic-page-support-end-1"></script>
</body> </body>
</html> </html>