@immugio/three-math-extensions 0.2.12 → 0.2.13

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 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.12](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.12)
10
+ ## [0.2.13](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.13)
11
11
 
12
12
  ### Commits
13
13
 
@@ -32,6 +32,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
32
32
  - Polygon from bounding size [`eae6701`](https://github.com/Immugio/three-math-extensions/commit/eae67012f57f426f8b5259b765000447ce06d608)
33
33
  - Line2D and Line3D to return this instead of specific type [`761ef6a`](https://github.com/Immugio/three-math-extensions/commit/761ef6a9d8cc4e35120b666576794e521aa3b991)
34
34
  - Line2D.in3DSpace added [`a6ce0ec`](https://github.com/Immugio/three-math-extensions/commit/a6ce0ecb67f5c7b2a75fcc283c28af626153a4af)
35
+ - Line3D.connectsTo added [`6d2cfa0`](https://github.com/Immugio/three-math-extensions/commit/6d2cfa0f5335c665f325a694a32c57b574ec326d)
35
36
  - Line2D.hasIntersectionWithAngle to support optional tolerance [`b313bbe`](https://github.com/Immugio/three-math-extensions/commit/b313bbe118d435d53750deefd9a9e29ba6ec5c71)
36
37
  - Line2D.hasIntersectionWithAngle - modulo all angles [`5409aa0`](https://github.com/Immugio/three-math-extensions/commit/5409aa0bc41510efa86d548e91837e44e5b6c343)
37
38
  - Use Vec2 instead of Vector2 [`7e6a6ea`](https://github.com/Immugio/three-math-extensions/commit/7e6a6ea272f4441ef4bc78b3fdec23fc783fa1db)
@@ -41,7 +42,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
41
42
  - Documentation update [`d5c7a07`](https://github.com/Immugio/three-math-extensions/commit/d5c7a0765f6097f5d3a3be01967d4059f19682fb)
42
43
  - Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
43
44
 
44
- ## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.11...16.15.10) - 2023-01-02
45
+ ## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.12...16.15.10) - 2023-01-02
46
+
47
+ ## [0.2.12](https://github.com/Immugio/three-math-extensions/compare/0.2.11...0.2.12) - 2023-08-30
48
+
49
+ ### Commits
50
+
51
+ - Add eslint [`98e4912`](https://github.com/Immugio/three-math-extensions/commit/98e4912d637b42ba80e2f3267638b43296113019)
52
+ - Update jest packages [`af23b4f`](https://github.com/Immugio/three-math-extensions/commit/af23b4f08154bba3407f05b773865215e7e1cba8)
53
+ - Line3D.groupConnectedLines added [`29f372b`](https://github.com/Immugio/three-math-extensions/commit/29f372bc984c06b00c50fcd9428ce9a7b9cab799)
54
+ - Dependencies update and remove now duplicate Vec2.angleTo implementation [`4774abb`](https://github.com/Immugio/three-math-extensions/commit/4774abb81d882082df0da606c79a3c7bd3aecc57)
55
+ - Add Line3D.index [`7ed13d2`](https://github.com/Immugio/three-math-extensions/commit/7ed13d213748056c9dafd86288c3bcec9a28d1ba)
45
56
 
46
57
  ## [0.2.11](https://github.com/Immugio/three-math-extensions/compare/0.2.10...0.2.11) - 2023-08-24
47
58
 
package/cjs/Line3D.js CHANGED
@@ -424,10 +424,7 @@ class Line3D extends three_1.Line3 {
424
424
  group.push(line);
425
425
  lines.forEach((neighbor) => {
426
426
  if (!visited.has(neighbor)) {
427
- if ((line.start).isNear(neighbor.start, tolerance) ||
428
- (line.start).isNear(neighbor.end, tolerance) ||
429
- (line.end).isNear(neighbor.start, tolerance) ||
430
- (line.end).isNear(neighbor.end, tolerance)) {
427
+ if (line.connectsTo(neighbor, tolerance)) {
431
428
  dfs(neighbor, group);
432
429
  }
433
430
  }
@@ -443,6 +440,17 @@ class Line3D extends three_1.Line3 {
443
440
  });
444
441
  return connectedLines;
445
442
  }
443
+ /**
444
+ * Returns true if any endpoint of this line if within the tolerance distance of any endpoint of the @other line.
445
+ * @param other
446
+ * @param tolerance
447
+ */
448
+ connectsTo(other, tolerance = 0) {
449
+ return this.start.isNear(other.start, tolerance) ||
450
+ this.start.isNear(other.end, tolerance) ||
451
+ this.end.isNear(other.start, tolerance) ||
452
+ this.end.isNear(other.end, tolerance);
453
+ }
446
454
  /**
447
455
  * Project the line to 2D space, Y value is dropped
448
456
  */
package/esm/Line3D.js CHANGED
@@ -421,10 +421,7 @@ export class Line3D extends Line3 {
421
421
  group.push(line);
422
422
  lines.forEach((neighbor) => {
423
423
  if (!visited.has(neighbor)) {
424
- if ((line.start).isNear(neighbor.start, tolerance) ||
425
- (line.start).isNear(neighbor.end, tolerance) ||
426
- (line.end).isNear(neighbor.start, tolerance) ||
427
- (line.end).isNear(neighbor.end, tolerance)) {
424
+ if (line.connectsTo(neighbor, tolerance)) {
428
425
  dfs(neighbor, group);
429
426
  }
430
427
  }
@@ -440,6 +437,17 @@ export class Line3D extends Line3 {
440
437
  });
441
438
  return connectedLines;
442
439
  }
440
+ /**
441
+ * Returns true if any endpoint of this line if within the tolerance distance of any endpoint of the @other line.
442
+ * @param other
443
+ * @param tolerance
444
+ */
445
+ connectsTo(other, tolerance = 0) {
446
+ return this.start.isNear(other.start, tolerance) ||
447
+ this.start.isNear(other.end, tolerance) ||
448
+ this.end.isNear(other.start, tolerance) ||
449
+ this.end.isNear(other.end, tolerance);
450
+ }
443
451
  /**
444
452
  * Project the line to 2D space, Y value is dropped
445
453
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immugio/three-math-extensions",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Set of utilities for 2d and 3d line math built on top of three.js",
5
5
  "author": "Jan Mikeska <janmikeska@gmail.com>",
6
6
  "license": "ISC",
package/src/Line3D.ts CHANGED
@@ -520,10 +520,7 @@ export class Line3D extends Line3 {
520
520
  lines.forEach((neighbor) => {
521
521
  if (!visited.has(neighbor)) {
522
522
  if (
523
- (line.start).isNear(neighbor.start, tolerance) ||
524
- (line.start).isNear(neighbor.end, tolerance) ||
525
- (line.end).isNear(neighbor.start, tolerance) ||
526
- (line.end).isNear(neighbor.end, tolerance)
523
+ line.connectsTo(neighbor, tolerance)
527
524
  ) {
528
525
  dfs(neighbor, group);
529
526
  }
@@ -544,6 +541,18 @@ export class Line3D extends Line3 {
544
541
  return connectedLines;
545
542
  }
546
543
 
544
+ /**
545
+ * Returns true if any endpoint of this line if within the tolerance distance of any endpoint of the @other line.
546
+ * @param other
547
+ * @param tolerance
548
+ */
549
+ public connectsTo(other: Line3D, tolerance: number = 0): boolean {
550
+ return this.start.isNear(other.start, tolerance) ||
551
+ this.start.isNear(other.end, tolerance) ||
552
+ this.end.isNear(other.start, tolerance) ||
553
+ this.end.isNear(other.end, tolerance);
554
+ }
555
+
547
556
  /**
548
557
  * Project the line to 2D space, Y value is dropped
549
558
  */
package/types/Line3D.d.ts CHANGED
@@ -152,6 +152,12 @@ export declare class Line3D extends Line3 {
152
152
  * @param tolerance Tolerance for considering lines as connected
153
153
  */
154
154
  static groupConnectedLines(lines: Line3D[], tolerance?: number): Line3D[][];
155
+ /**
156
+ * Returns true if any endpoint of this line if within the tolerance distance of any endpoint of the @other line.
157
+ * @param other
158
+ * @param tolerance
159
+ */
160
+ connectsTo(other: Line3D, tolerance?: number): boolean;
155
161
  /**
156
162
  * Project the line to 2D space, Y value is dropped
157
163
  */