@immugio/three-math-extensions 0.2.12 → 0.2.14
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/CHANGELOG.md +20 -2
- package/cjs/Line3D.js +15 -5
- package/esm/Line3D.js +15 -5
- package/package.json +1 -1
- package/src/Line3D.ts +18 -5
- package/types/Line3D.d.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
9
9
|
|
|
10
|
-
## [0.2.
|
|
10
|
+
## [0.2.14](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.14)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
@@ -27,11 +27,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
27
27
|
- Add Vec2.fromPoints to accept multiple points [`a261402`](https://github.com/Immugio/three-math-extensions/commit/a2614027cf5fb8263189b48f7e0bb9a23a552c15)
|
|
28
28
|
- Add Vec2.parallelTo [`989874d`](https://github.com/Immugio/three-math-extensions/commit/989874dcfe122d3ee84d8d56d79cb88e4e441736)
|
|
29
29
|
- Line2D.intersect - enable line segments intersection only [`1f1470e`](https://github.com/Immugio/three-math-extensions/commit/1f1470e1cf00118e643f5c44a135e0baf6b76d41)
|
|
30
|
+
- Line3D.groupConnectedLines now supports line breaks [`417a9ea`](https://github.com/Immugio/three-math-extensions/commit/417a9ea471bf4c539f73f5fb170c962a78ee4ab4)
|
|
30
31
|
- Add Line2D.projectOn [`4c52c5c`](https://github.com/Immugio/three-math-extensions/commit/4c52c5c2e649fbddb72ce3fca60cfd3f1319f72f)
|
|
31
32
|
- Add Line3D.index [`7ed13d2`](https://github.com/Immugio/three-math-extensions/commit/7ed13d213748056c9dafd86288c3bcec9a28d1ba)
|
|
32
33
|
- Polygon from bounding size [`eae6701`](https://github.com/Immugio/three-math-extensions/commit/eae67012f57f426f8b5259b765000447ce06d608)
|
|
33
34
|
- Line2D and Line3D to return this instead of specific type [`761ef6a`](https://github.com/Immugio/three-math-extensions/commit/761ef6a9d8cc4e35120b666576794e521aa3b991)
|
|
34
35
|
- Line2D.in3DSpace added [`a6ce0ec`](https://github.com/Immugio/three-math-extensions/commit/a6ce0ecb67f5c7b2a75fcc283c28af626153a4af)
|
|
36
|
+
- Line3D.connectsTo added [`6d2cfa0`](https://github.com/Immugio/three-math-extensions/commit/6d2cfa0f5335c665f325a694a32c57b574ec326d)
|
|
35
37
|
- Line2D.hasIntersectionWithAngle to support optional tolerance [`b313bbe`](https://github.com/Immugio/three-math-extensions/commit/b313bbe118d435d53750deefd9a9e29ba6ec5c71)
|
|
36
38
|
- Line2D.hasIntersectionWithAngle - modulo all angles [`5409aa0`](https://github.com/Immugio/three-math-extensions/commit/5409aa0bc41510efa86d548e91837e44e5b6c343)
|
|
37
39
|
- Use Vec2 instead of Vector2 [`7e6a6ea`](https://github.com/Immugio/three-math-extensions/commit/7e6a6ea272f4441ef4bc78b3fdec23fc783fa1db)
|
|
@@ -41,7 +43,23 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
41
43
|
- Documentation update [`d5c7a07`](https://github.com/Immugio/three-math-extensions/commit/d5c7a0765f6097f5d3a3be01967d4059f19682fb)
|
|
42
44
|
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
43
45
|
|
|
44
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.
|
|
46
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.13...16.15.10) - 2023-01-02
|
|
47
|
+
|
|
48
|
+
## [0.2.13](https://github.com/Immugio/three-math-extensions/compare/0.2.12...0.2.13) - 2023-08-31
|
|
49
|
+
|
|
50
|
+
### Commits
|
|
51
|
+
|
|
52
|
+
- Line3D.connectsTo added [`6d2cfa0`](https://github.com/Immugio/three-math-extensions/commit/6d2cfa0f5335c665f325a694a32c57b574ec326d)
|
|
53
|
+
|
|
54
|
+
## [0.2.12](https://github.com/Immugio/three-math-extensions/compare/0.2.11...0.2.12) - 2023-08-30
|
|
55
|
+
|
|
56
|
+
### Commits
|
|
57
|
+
|
|
58
|
+
- Add eslint [`98e4912`](https://github.com/Immugio/three-math-extensions/commit/98e4912d637b42ba80e2f3267638b43296113019)
|
|
59
|
+
- Update jest packages [`af23b4f`](https://github.com/Immugio/three-math-extensions/commit/af23b4f08154bba3407f05b773865215e7e1cba8)
|
|
60
|
+
- Line3D.groupConnectedLines added [`29f372b`](https://github.com/Immugio/three-math-extensions/commit/29f372bc984c06b00c50fcd9428ce9a7b9cab799)
|
|
61
|
+
- Dependencies update and remove now duplicate Vec2.angleTo implementation [`4774abb`](https://github.com/Immugio/three-math-extensions/commit/4774abb81d882082df0da606c79a3c7bd3aecc57)
|
|
62
|
+
- Add Line3D.index [`7ed13d2`](https://github.com/Immugio/three-math-extensions/commit/7ed13d213748056c9dafd86288c3bcec9a28d1ba)
|
|
45
63
|
|
|
46
64
|
## [0.2.11](https://github.com/Immugio/three-math-extensions/compare/0.2.10...0.2.11) - 2023-08-24
|
|
47
65
|
|
package/cjs/Line3D.js
CHANGED
|
@@ -412,8 +412,9 @@ class Line3D extends three_1.Line3 {
|
|
|
412
412
|
* Accepts an array of Line3D and groups them into arrays of connected lines
|
|
413
413
|
* @param lines Lines to be grouped
|
|
414
414
|
* @param tolerance Tolerance for considering lines as connected
|
|
415
|
+
* @param breakpoints
|
|
415
416
|
*/
|
|
416
|
-
static groupConnectedLines(lines, tolerance = 0) {
|
|
417
|
+
static groupConnectedLines(lines, tolerance = 0, breakpoints = []) {
|
|
417
418
|
const visited = new Set();
|
|
418
419
|
// Use graph-based approach. Each line can be considered as an edge in the graph, and the endpoints of the lines can be considered as vertices.
|
|
419
420
|
// Then use Depth-First Search (DFS) to find connected components in the graph.
|
|
@@ -424,10 +425,7 @@ class Line3D extends three_1.Line3 {
|
|
|
424
425
|
group.push(line);
|
|
425
426
|
lines.forEach((neighbor) => {
|
|
426
427
|
if (!visited.has(neighbor)) {
|
|
427
|
-
if (
|
|
428
|
-
(line.start).isNear(neighbor.end, tolerance) ||
|
|
429
|
-
(line.end).isNear(neighbor.start, tolerance) ||
|
|
430
|
-
(line.end).isNear(neighbor.end, tolerance)) {
|
|
428
|
+
if (line.connectsTo(neighbor, tolerance, breakpoints)) {
|
|
431
429
|
dfs(neighbor, group);
|
|
432
430
|
}
|
|
433
431
|
}
|
|
@@ -443,6 +441,18 @@ class Line3D extends three_1.Line3 {
|
|
|
443
441
|
});
|
|
444
442
|
return connectedLines;
|
|
445
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* Returns true if any endpoint of this line is within the tolerance of any @other line's endpoints.
|
|
446
|
+
* @param other
|
|
447
|
+
* @param tolerance
|
|
448
|
+
* @param breakpoints
|
|
449
|
+
*/
|
|
450
|
+
connectsTo(other, tolerance = 0, breakpoints = []) {
|
|
451
|
+
return ((this.start.isNear(other.start, tolerance) && breakpoints.every(b => !b.isNear(this.start, tolerance))) ||
|
|
452
|
+
(this.start.isNear(other.end, tolerance) && breakpoints.every(b => !b.isNear(this.start, tolerance))) ||
|
|
453
|
+
(this.end.isNear(other.start, tolerance) && breakpoints.every(b => !b.isNear(this.end, tolerance))) ||
|
|
454
|
+
(this.end.isNear(other.end, tolerance) && breakpoints.every(b => !b.isNear(this.end, tolerance))));
|
|
455
|
+
}
|
|
446
456
|
/**
|
|
447
457
|
* Project the line to 2D space, Y value is dropped
|
|
448
458
|
*/
|
package/esm/Line3D.js
CHANGED
|
@@ -409,8 +409,9 @@ export class Line3D extends Line3 {
|
|
|
409
409
|
* Accepts an array of Line3D and groups them into arrays of connected lines
|
|
410
410
|
* @param lines Lines to be grouped
|
|
411
411
|
* @param tolerance Tolerance for considering lines as connected
|
|
412
|
+
* @param breakpoints
|
|
412
413
|
*/
|
|
413
|
-
static groupConnectedLines(lines, tolerance = 0) {
|
|
414
|
+
static groupConnectedLines(lines, tolerance = 0, breakpoints = []) {
|
|
414
415
|
const visited = new Set();
|
|
415
416
|
// Use graph-based approach. Each line can be considered as an edge in the graph, and the endpoints of the lines can be considered as vertices.
|
|
416
417
|
// Then use Depth-First Search (DFS) to find connected components in the graph.
|
|
@@ -421,10 +422,7 @@ export class Line3D extends Line3 {
|
|
|
421
422
|
group.push(line);
|
|
422
423
|
lines.forEach((neighbor) => {
|
|
423
424
|
if (!visited.has(neighbor)) {
|
|
424
|
-
if (
|
|
425
|
-
(line.start).isNear(neighbor.end, tolerance) ||
|
|
426
|
-
(line.end).isNear(neighbor.start, tolerance) ||
|
|
427
|
-
(line.end).isNear(neighbor.end, tolerance)) {
|
|
425
|
+
if (line.connectsTo(neighbor, tolerance, breakpoints)) {
|
|
428
426
|
dfs(neighbor, group);
|
|
429
427
|
}
|
|
430
428
|
}
|
|
@@ -440,6 +438,18 @@ export class Line3D extends Line3 {
|
|
|
440
438
|
});
|
|
441
439
|
return connectedLines;
|
|
442
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Returns true if any endpoint of this line is within the tolerance of any @other line's endpoints.
|
|
443
|
+
* @param other
|
|
444
|
+
* @param tolerance
|
|
445
|
+
* @param breakpoints
|
|
446
|
+
*/
|
|
447
|
+
connectsTo(other, tolerance = 0, breakpoints = []) {
|
|
448
|
+
return ((this.start.isNear(other.start, tolerance) && breakpoints.every(b => !b.isNear(this.start, tolerance))) ||
|
|
449
|
+
(this.start.isNear(other.end, tolerance) && breakpoints.every(b => !b.isNear(this.start, tolerance))) ||
|
|
450
|
+
(this.end.isNear(other.start, tolerance) && breakpoints.every(b => !b.isNear(this.end, tolerance))) ||
|
|
451
|
+
(this.end.isNear(other.end, tolerance) && breakpoints.every(b => !b.isNear(this.end, tolerance))));
|
|
452
|
+
}
|
|
443
453
|
/**
|
|
444
454
|
* Project the line to 2D space, Y value is dropped
|
|
445
455
|
*/
|
package/package.json
CHANGED
package/src/Line3D.ts
CHANGED
|
@@ -506,8 +506,9 @@ export class Line3D extends Line3 {
|
|
|
506
506
|
* Accepts an array of Line3D and groups them into arrays of connected lines
|
|
507
507
|
* @param lines Lines to be grouped
|
|
508
508
|
* @param tolerance Tolerance for considering lines as connected
|
|
509
|
+
* @param breakpoints
|
|
509
510
|
*/
|
|
510
|
-
public static groupConnectedLines(lines: Line3D[], tolerance: number = 0): Line3D[][] {
|
|
511
|
+
public static groupConnectedLines(lines: Line3D[], tolerance: number = 0, breakpoints: Vec3[] = []): Line3D[][] {
|
|
511
512
|
const visited: Set<Line3D> = new Set();
|
|
512
513
|
|
|
513
514
|
// Use graph-based approach. Each line can be considered as an edge in the graph, and the endpoints of the lines can be considered as vertices.
|
|
@@ -520,10 +521,7 @@ export class Line3D extends Line3 {
|
|
|
520
521
|
lines.forEach((neighbor) => {
|
|
521
522
|
if (!visited.has(neighbor)) {
|
|
522
523
|
if (
|
|
523
|
-
|
|
524
|
-
(line.start).isNear(neighbor.end, tolerance) ||
|
|
525
|
-
(line.end).isNear(neighbor.start, tolerance) ||
|
|
526
|
-
(line.end).isNear(neighbor.end, tolerance)
|
|
524
|
+
line.connectsTo(neighbor, tolerance, breakpoints)
|
|
527
525
|
) {
|
|
528
526
|
dfs(neighbor, group);
|
|
529
527
|
}
|
|
@@ -544,6 +542,21 @@ export class Line3D extends Line3 {
|
|
|
544
542
|
return connectedLines;
|
|
545
543
|
}
|
|
546
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Returns true if any endpoint of this line is within the tolerance of any @other line's endpoints.
|
|
547
|
+
* @param other
|
|
548
|
+
* @param tolerance
|
|
549
|
+
* @param breakpoints
|
|
550
|
+
*/
|
|
551
|
+
public connectsTo(other: Line3D, tolerance: number = 0, breakpoints: Vec3[] = []): boolean {
|
|
552
|
+
return (
|
|
553
|
+
(this.start.isNear(other.start, tolerance) && breakpoints.every(b => !b.isNear(this.start, tolerance))) ||
|
|
554
|
+
(this.start.isNear(other.end, tolerance) && breakpoints.every(b => !b.isNear(this.start, tolerance))) ||
|
|
555
|
+
(this.end.isNear(other.start, tolerance) && breakpoints.every(b => !b.isNear(this.end, tolerance))) ||
|
|
556
|
+
(this.end.isNear(other.end, tolerance) && breakpoints.every(b => !b.isNear(this.end, tolerance)))
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
547
560
|
/**
|
|
548
561
|
* Project the line to 2D space, Y value is dropped
|
|
549
562
|
*/
|
package/types/Line3D.d.ts
CHANGED
|
@@ -150,8 +150,16 @@ export declare class Line3D extends Line3 {
|
|
|
150
150
|
* Accepts an array of Line3D and groups them into arrays of connected lines
|
|
151
151
|
* @param lines Lines to be grouped
|
|
152
152
|
* @param tolerance Tolerance for considering lines as connected
|
|
153
|
+
* @param breakpoints
|
|
153
154
|
*/
|
|
154
|
-
static groupConnectedLines(lines: Line3D[], tolerance?: number): Line3D[][];
|
|
155
|
+
static groupConnectedLines(lines: Line3D[], tolerance?: number, breakpoints?: Vec3[]): Line3D[][];
|
|
156
|
+
/**
|
|
157
|
+
* Returns true if any endpoint of this line is within the tolerance of any @other line's endpoints.
|
|
158
|
+
* @param other
|
|
159
|
+
* @param tolerance
|
|
160
|
+
* @param breakpoints
|
|
161
|
+
*/
|
|
162
|
+
connectsTo(other: Line3D, tolerance?: number, breakpoints?: Vec3[]): boolean;
|
|
155
163
|
/**
|
|
156
164
|
* Project the line to 2D space, Y value is dropped
|
|
157
165
|
*/
|