@immugio/three-math-extensions 0.2.16 → 0.2.18
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 +17 -2
- package/cjs/Line2D.js +10 -0
- package/cjs/Line3D.js +4 -4
- package/esm/Line2D.js +10 -0
- package/esm/Line3D.js +4 -4
- package/package.json +10 -10
- package/src/Line2D.ts +14 -1
- package/src/Line3D.ts +4 -4
- package/types/Line2D.d.ts +1 -0
- package/types/Line3D.d.ts +2 -2
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.18](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.18)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
@@ -16,6 +16,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
16
16
|
- Update jest packages [`af23b4f`](https://github.com/Immugio/three-math-extensions/commit/af23b4f08154bba3407f05b773865215e7e1cba8)
|
|
17
17
|
- Add Rectangle, update Polygon [`58ee875`](https://github.com/Immugio/three-math-extensions/commit/58ee87539af8f9ade186e5250cba9e01926da514)
|
|
18
18
|
- Add isPointInPolygon [`a59eb4b`](https://github.com/Immugio/three-math-extensions/commit/a59eb4be026f17a3106070ae626a0588cd4f4411)
|
|
19
|
+
- Packages update [`c2ef857`](https://github.com/Immugio/three-math-extensions/commit/c2ef857c01792e64c1558424fdd2f401f72720d0)
|
|
19
20
|
- Improve Line2D.closestPointToPoint, add Vec2.signedAngle [`151f214`](https://github.com/Immugio/three-math-extensions/commit/151f21462e0358057ad8e9d75d5782563a1061f6)
|
|
20
21
|
- Improve documentation [`d0fcb51`](https://github.com/Immugio/three-math-extensions/commit/d0fcb5132f127b4382ac5f7291575a061b8ec121)
|
|
21
22
|
- Add isContinuousClosedShape, add Line2D.groupConnectedLines [`4ef8c2f`](https://github.com/Immugio/three-math-extensions/commit/4ef8c2fe83fdc71dd87fee4cbc478ddf0a086442)
|
|
@@ -26,6 +27,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
26
27
|
- Line2D.isCloserToHorizontal [`b6f1429`](https://github.com/Immugio/three-math-extensions/commit/b6f14292d1d2765f7314c45e4c74be91280ac764)
|
|
27
28
|
- Add Vec2.angleTo and tests [`dcf1e53`](https://github.com/Immugio/three-math-extensions/commit/dcf1e531aecf8c115f323e14e5e44059e5c5d15c)
|
|
28
29
|
- Add Vec2.signedAngle [`863c8f2`](https://github.com/Immugio/three-math-extensions/commit/863c8f27f11288cbda535e21bb688206259269ed)
|
|
30
|
+
- Add parallelism check to Line2D [`18064ee`](https://github.com/Immugio/three-math-extensions/commit/18064ee35a28e2c4d656f3dfb543b545044167dd)
|
|
29
31
|
- Add Vec2.fromPoints to accept multiple points [`a261402`](https://github.com/Immugio/three-math-extensions/commit/a2614027cf5fb8263189b48f7e0bb9a23a552c15)
|
|
30
32
|
- Add Vec2.parallelTo [`989874d`](https://github.com/Immugio/three-math-extensions/commit/989874dcfe122d3ee84d8d56d79cb88e4e441736)
|
|
31
33
|
- Line2D.intersect - enable line segments intersection only [`1f1470e`](https://github.com/Immugio/three-math-extensions/commit/1f1470e1cf00118e643f5c44a135e0baf6b76d41)
|
|
@@ -48,7 +50,20 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
48
50
|
- Documentation update [`d5c7a07`](https://github.com/Immugio/three-math-extensions/commit/d5c7a0765f6097f5d3a3be01967d4059f19682fb)
|
|
49
51
|
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
50
52
|
|
|
51
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.
|
|
53
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.17...16.15.10) - 2023-01-02
|
|
54
|
+
|
|
55
|
+
## [0.2.17](https://github.com/Immugio/three-math-extensions/compare/0.2.16...0.2.17) - 2023-12-26
|
|
56
|
+
|
|
57
|
+
### Commits
|
|
58
|
+
|
|
59
|
+
- Packages update [`c2ef857`](https://github.com/Immugio/three-math-extensions/commit/c2ef857c01792e64c1558424fdd2f401f72720d0)
|
|
60
|
+
|
|
61
|
+
## [0.2.16](https://github.com/Immugio/three-math-extensions/compare/0.2.15...0.2.16) - 2023-11-21
|
|
62
|
+
|
|
63
|
+
### Commits
|
|
64
|
+
|
|
65
|
+
- Add functionality for incrementing x, y, z coordinates [`b292dcc`](https://github.com/Immugio/three-math-extensions/commit/b292dcc4e8f7f0f2a63e1810c482d96ca6bebebe)
|
|
66
|
+
- Use double quotes [`c1f19db`](https://github.com/Immugio/three-math-extensions/commit/c1f19db2d0886a6ff5555bdbf353dfca20a70f0a)
|
|
52
67
|
|
|
53
68
|
## [0.2.15](https://github.com/Immugio/three-math-extensions/compare/0.2.14...0.2.15) - 2023-10-12
|
|
54
69
|
|
package/cjs/Line2D.js
CHANGED
|
@@ -80,6 +80,16 @@ class Line2D {
|
|
|
80
80
|
this.moveEndPoint(amount / 2);
|
|
81
81
|
return this;
|
|
82
82
|
}
|
|
83
|
+
isParallelTo(other, angleTolerance = Number.EPSILON) {
|
|
84
|
+
const direction = this.direction;
|
|
85
|
+
const otherDirection = other.direction;
|
|
86
|
+
const angle = direction.angleTo(otherDirection);
|
|
87
|
+
if (angle <= angleTolerance) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
const opposite = direction.angleTo(otherDirection.negate());
|
|
91
|
+
return opposite <= angleTolerance;
|
|
92
|
+
}
|
|
83
93
|
/*
|
|
84
94
|
* Moves start point on the line by the given amount. Plus values move the point further away from the center.
|
|
85
95
|
* Modifies this line.
|
package/cjs/Line3D.js
CHANGED
|
@@ -282,16 +282,16 @@ class Line3D extends three_1.Line3 {
|
|
|
282
282
|
/**
|
|
283
283
|
* Check if @other is parallel to this line.
|
|
284
284
|
* @param other
|
|
285
|
-
* @param
|
|
285
|
+
* @param angleTolerance
|
|
286
286
|
*/
|
|
287
|
-
isParallelTo(other,
|
|
287
|
+
isParallelTo(other, angleTolerance = Number.EPSILON) {
|
|
288
288
|
const direction = this.direction;
|
|
289
289
|
const otherDirection = other.direction;
|
|
290
|
-
const areTheSameDirection = direction.
|
|
290
|
+
const areTheSameDirection = direction.angleTo(otherDirection) <= angleTolerance;
|
|
291
291
|
if (areTheSameDirection) {
|
|
292
292
|
return true;
|
|
293
293
|
}
|
|
294
|
-
return direction.negate().
|
|
294
|
+
return direction.negate().angleTo(otherDirection) < angleTolerance;
|
|
295
295
|
}
|
|
296
296
|
/*
|
|
297
297
|
* Extends or reduces the line to the given length while keeping the center of the line constant.
|
package/esm/Line2D.js
CHANGED
|
@@ -77,6 +77,16 @@ export class Line2D {
|
|
|
77
77
|
this.moveEndPoint(amount / 2);
|
|
78
78
|
return this;
|
|
79
79
|
}
|
|
80
|
+
isParallelTo(other, angleTolerance = Number.EPSILON) {
|
|
81
|
+
const direction = this.direction;
|
|
82
|
+
const otherDirection = other.direction;
|
|
83
|
+
const angle = direction.angleTo(otherDirection);
|
|
84
|
+
if (angle <= angleTolerance) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const opposite = direction.angleTo(otherDirection.negate());
|
|
88
|
+
return opposite <= angleTolerance;
|
|
89
|
+
}
|
|
80
90
|
/*
|
|
81
91
|
* Moves start point on the line by the given amount. Plus values move the point further away from the center.
|
|
82
92
|
* Modifies this line.
|
package/esm/Line3D.js
CHANGED
|
@@ -279,16 +279,16 @@ export class Line3D extends Line3 {
|
|
|
279
279
|
/**
|
|
280
280
|
* Check if @other is parallel to this line.
|
|
281
281
|
* @param other
|
|
282
|
-
* @param
|
|
282
|
+
* @param angleTolerance
|
|
283
283
|
*/
|
|
284
|
-
isParallelTo(other,
|
|
284
|
+
isParallelTo(other, angleTolerance = Number.EPSILON) {
|
|
285
285
|
const direction = this.direction;
|
|
286
286
|
const otherDirection = other.direction;
|
|
287
|
-
const areTheSameDirection = direction.
|
|
287
|
+
const areTheSameDirection = direction.angleTo(otherDirection) <= angleTolerance;
|
|
288
288
|
if (areTheSameDirection) {
|
|
289
289
|
return true;
|
|
290
290
|
}
|
|
291
|
-
return direction.negate().
|
|
291
|
+
return direction.negate().angleTo(otherDirection) < angleTolerance;
|
|
292
292
|
}
|
|
293
293
|
/*
|
|
294
294
|
* Extends or reduces the line to the given length while keeping the center of the line constant.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@immugio/three-math-extensions",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.18",
|
|
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",
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
"postversion": "git push && git push --tags"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/jest": "^29.5.
|
|
37
|
-
"@types/offscreencanvas": "2019.7.
|
|
38
|
-
"@types/three": "0.
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
36
|
+
"@types/jest": "^29.5.11",
|
|
37
|
+
"@types/offscreencanvas": "2019.7.3",
|
|
38
|
+
"@types/three": "0.160.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
40
40
|
"auto-changelog": "^2.4.0",
|
|
41
41
|
"jest": "^29.7.0",
|
|
42
42
|
"rimraf": "^5.0.5",
|
|
43
43
|
"ts-jest": "^29.1.1",
|
|
44
|
-
"typedoc": "^0.25.
|
|
45
|
-
"typedoc-plugin-markdown": "^3.
|
|
46
|
-
"typescript": "5.
|
|
47
|
-
"eslint": "^8.
|
|
44
|
+
"typedoc": "^0.25.4",
|
|
45
|
+
"typedoc-plugin-markdown": "^3.17.1",
|
|
46
|
+
"typescript": "5.3.3",
|
|
47
|
+
"eslint": "^8.56.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"three": "0.
|
|
50
|
+
"three": "0.160.0"
|
|
51
51
|
},
|
|
52
52
|
"repository": {
|
|
53
53
|
"type": "git",
|
package/src/Line2D.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Vec2 } from "./Vec2";
|
|
|
4
4
|
import { MathUtils } from "three";
|
|
5
5
|
import { TwoPI } from "./MathConstants";
|
|
6
6
|
import { Line3D } from "./Line3D";
|
|
7
|
-
import {directions2d} from "./directions2d";
|
|
7
|
+
import { directions2d } from "./directions2d";
|
|
8
8
|
|
|
9
9
|
const _startP = /*@__PURE__*/ new Vec2();
|
|
10
10
|
const _startEnd = /*@__PURE__*/ new Vec2();
|
|
@@ -87,6 +87,19 @@ export class Line2D {
|
|
|
87
87
|
return this;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
public isParallelTo(other: Line2D, angleTolerance: number = Number.EPSILON): boolean {
|
|
91
|
+
const direction = this.direction;
|
|
92
|
+
const otherDirection = other.direction;
|
|
93
|
+
|
|
94
|
+
const angle = direction.angleTo(otherDirection);
|
|
95
|
+
if (angle <= angleTolerance) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const opposite = direction.angleTo(otherDirection.negate());
|
|
100
|
+
return opposite <= angleTolerance;
|
|
101
|
+
}
|
|
102
|
+
|
|
90
103
|
/*
|
|
91
104
|
* Moves start point on the line by the given amount. Plus values move the point further away from the center.
|
|
92
105
|
* Modifies this line.
|
package/src/Line3D.ts
CHANGED
|
@@ -339,18 +339,18 @@ export class Line3D extends Line3 {
|
|
|
339
339
|
/**
|
|
340
340
|
* Check if @other is parallel to this line.
|
|
341
341
|
* @param other
|
|
342
|
-
* @param
|
|
342
|
+
* @param angleTolerance
|
|
343
343
|
*/
|
|
344
|
-
public isParallelTo(other: Line3D,
|
|
344
|
+
public isParallelTo(other: Line3D, angleTolerance: number = Number.EPSILON): boolean {
|
|
345
345
|
const direction = this.direction;
|
|
346
346
|
const otherDirection = other.direction;
|
|
347
347
|
|
|
348
|
-
const areTheSameDirection = direction.
|
|
348
|
+
const areTheSameDirection = direction.angleTo(otherDirection) <= angleTolerance;
|
|
349
349
|
if (areTheSameDirection) {
|
|
350
350
|
return true;
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
return direction.negate().
|
|
353
|
+
return direction.negate().angleTo(otherDirection) < angleTolerance;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/*
|
package/types/Line2D.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare class Line2D {
|
|
|
30
30
|
*/
|
|
31
31
|
setCenter(value: Point2): this;
|
|
32
32
|
resize(amount: number): this;
|
|
33
|
+
isParallelTo(other: Line2D, angleTolerance?: number): boolean;
|
|
33
34
|
moveStartPoint(amount: number): this;
|
|
34
35
|
/**
|
|
35
36
|
* Moves end point on the line by the given amount. Plus values move the point further away from the center.
|
package/types/Line3D.d.ts
CHANGED
|
@@ -109,9 +109,9 @@ export declare class Line3D extends Line3 {
|
|
|
109
109
|
/**
|
|
110
110
|
* Check if @other is parallel to this line.
|
|
111
111
|
* @param other
|
|
112
|
-
* @param
|
|
112
|
+
* @param angleTolerance
|
|
113
113
|
*/
|
|
114
|
-
isParallelTo(other: Line3D,
|
|
114
|
+
isParallelTo(other: Line3D, angleTolerance?: number): boolean;
|
|
115
115
|
resize(amount: number): this;
|
|
116
116
|
moveStartPoint(amount: number): this;
|
|
117
117
|
moveEndPoint(amount: number): this;
|