tela.js 1.2.23 → 1.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Tela/Tela.js +18 -20
package/package.json
CHANGED
package/src/Tela/Tela.js
CHANGED
|
@@ -331,29 +331,27 @@ function isInsideConvex(positions) {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
function clipLine(p0, p1, box) {
|
|
334
|
-
const
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
inStack.push(p);
|
|
341
|
-
} else {
|
|
342
|
-
outStack.push(p);
|
|
343
|
-
}
|
|
334
|
+
const p0In = box.collidesWith(p0);
|
|
335
|
+
const p1In = box.collidesWith(p1);
|
|
336
|
+
|
|
337
|
+
// Case 1: Both points are inside
|
|
338
|
+
if (p0In && p1In) {
|
|
339
|
+
return [p0, p1];
|
|
344
340
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
341
|
+
|
|
342
|
+
// Case 2: p0 is inside, p1 is outside
|
|
343
|
+
if (p0In) {
|
|
344
|
+
return [p0, ...lineBoxIntersection(p0, p1, box)];
|
|
348
345
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return [inPoint, ...lineBoxIntersection(inPoint, outPoint, box)];
|
|
346
|
+
|
|
347
|
+
// Case 3: p1 is inside, p0 is outside
|
|
348
|
+
if (p1In) {
|
|
349
|
+
return [p1, ...lineBoxIntersection(p1, p0, box)];
|
|
354
350
|
}
|
|
355
|
-
|
|
356
|
-
|
|
351
|
+
|
|
352
|
+
// Case 4: Both are outside (line could still pass through the box)
|
|
353
|
+
// Note: lineBoxIntersection should return an empty array if no intersection exists
|
|
354
|
+
return lineBoxIntersection(p0, p1, box);
|
|
357
355
|
}
|
|
358
356
|
|
|
359
357
|
function lineBoxIntersection(start, end, box) {
|