@immugio/three-math-extensions 0.2.27 → 0.2.28
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 +9 -2
- package/cjs/Polygon.js +5 -0
- package/cjs/Vec2.js +6 -0
- package/cjs/Vec3.js +21 -0
- package/esm/Polygon.js +5 -0
- package/esm/Vec2.js +6 -0
- package/esm/Vec3.js +21 -0
- package/package.json +1 -1
- package/src/Polygon.ts +6 -0
- package/src/Vec2.ts +6 -0
- package/src/Vec3.ts +22 -0
- package/types/Polygon.d.ts +1 -0
- package/types/Vec3.d.ts +1 -0
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.28](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.28)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
@@ -45,6 +45,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
45
45
|
- Line2D.clipLines to support tolerances [`e397290`](https://github.com/Immugio/three-math-extensions/commit/e3972909339f01f0c018ad49e14b958d18e489e5)
|
|
46
46
|
- Add functionality for incrementing x, y, z coordinates [`b292dcc`](https://github.com/Immugio/three-math-extensions/commit/b292dcc4e8f7f0f2a63e1810c482d96ca6bebebe)
|
|
47
47
|
- Add Line3D.index [`7ed13d2`](https://github.com/Immugio/three-math-extensions/commit/7ed13d213748056c9dafd86288c3bcec9a28d1ba)
|
|
48
|
+
- Add Polygon.roundIfCloseToInteger, Vec3.roundIfCloseToInteger [`ee9a90d`](https://github.com/Immugio/three-math-extensions/commit/ee9a90de07eb9827d1a53cdac65be3a51862cdc2)
|
|
48
49
|
- Polygon from bounding size [`eae6701`](https://github.com/Immugio/three-math-extensions/commit/eae67012f57f426f8b5259b765000447ce06d608)
|
|
49
50
|
- Add Vec3.fromPoints [`62684d7`](https://github.com/Immugio/three-math-extensions/commit/62684d7f6dc1318d345ed74288bb6afd5394e1d3)
|
|
50
51
|
- Line2D and Line3D to return this instead of specific type [`761ef6a`](https://github.com/Immugio/three-math-extensions/commit/761ef6a9d8cc4e35120b666576794e521aa3b991)
|
|
@@ -63,7 +64,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
63
64
|
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
64
65
|
- Correct test file extension [`91b5e2a`](https://github.com/Immugio/three-math-extensions/commit/91b5e2ad338e8404704381a36813dcce5f00d978)
|
|
65
66
|
|
|
66
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.
|
|
67
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.27...16.15.10) - 2023-01-02
|
|
68
|
+
|
|
69
|
+
## [0.2.27](https://github.com/Immugio/three-math-extensions/compare/0.2.26...0.2.27) - 2024-09-10
|
|
70
|
+
|
|
71
|
+
### Commits
|
|
72
|
+
|
|
73
|
+
- Add Polygon.rotate [`4f2d581`](https://github.com/Immugio/three-math-extensions/commit/4f2d5814cdb3df067ab0a0cefcdfdb7a71696312)
|
|
67
74
|
|
|
68
75
|
## [0.2.26](https://github.com/Immugio/three-math-extensions/compare/0.2.25...0.2.26) - 2024-09-06
|
|
69
76
|
|
package/cjs/Polygon.js
CHANGED
|
@@ -118,6 +118,11 @@ class Polygon {
|
|
|
118
118
|
clone() {
|
|
119
119
|
return new Polygon(this.contour.map(p => p.clone()), this.holes?.map(h => h.map(p => p.clone())));
|
|
120
120
|
}
|
|
121
|
+
roundIfCloseToInteger(max = 0.000000000001) {
|
|
122
|
+
this.contour.forEach(p => p.roundIfCloseToInteger(max));
|
|
123
|
+
this.holes?.forEach(h => h.forEach(p => p.roundIfCloseToInteger(max)));
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
121
126
|
equals(other) {
|
|
122
127
|
if (this.contour.length !== other.contour.length) {
|
|
123
128
|
return false;
|
package/cjs/Vec2.js
CHANGED
|
@@ -62,6 +62,12 @@ class Vec2 extends three_1.Vector2 {
|
|
|
62
62
|
if (Math.abs(this.y - Math.round(this.y)) < max) {
|
|
63
63
|
this.y = Math.round(this.y);
|
|
64
64
|
}
|
|
65
|
+
if (Object.is(this.x, -0)) {
|
|
66
|
+
this.x = 0;
|
|
67
|
+
}
|
|
68
|
+
if (Object.is(this.y, -0)) {
|
|
69
|
+
this.y = 0;
|
|
70
|
+
}
|
|
65
71
|
return this;
|
|
66
72
|
}
|
|
67
73
|
/**
|
package/cjs/Vec3.js
CHANGED
|
@@ -81,6 +81,27 @@ class Vec3 extends three_1.Vector3 {
|
|
|
81
81
|
const closest = withDistances.reduce((a, b) => a.distance < b.distance ? a : b);
|
|
82
82
|
return Vec3.fromPoint(closest.point);
|
|
83
83
|
}
|
|
84
|
+
roundIfCloseToInteger(max = 0.000000000001) {
|
|
85
|
+
if (Math.abs(this.x - Math.round(this.x)) < max) {
|
|
86
|
+
this.x = Math.round(this.x);
|
|
87
|
+
}
|
|
88
|
+
if (Math.abs(this.y - Math.round(this.y)) < max) {
|
|
89
|
+
this.y = Math.round(this.y);
|
|
90
|
+
}
|
|
91
|
+
if (Math.abs(this.z - Math.round(this.z)) < max) {
|
|
92
|
+
this.z = Math.round(this.z);
|
|
93
|
+
}
|
|
94
|
+
if (Object.is(this.x, -0)) {
|
|
95
|
+
this.x = 0;
|
|
96
|
+
}
|
|
97
|
+
if (Object.is(this.y, -0)) {
|
|
98
|
+
this.y = 0;
|
|
99
|
+
}
|
|
100
|
+
if (Object.is(this.z, -0)) {
|
|
101
|
+
this.z = 0;
|
|
102
|
+
}
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
84
105
|
/**
|
|
85
106
|
* Returns a clone of this Vec3 instance with y and z swapped.
|
|
86
107
|
*/
|
package/esm/Polygon.js
CHANGED
|
@@ -115,6 +115,11 @@ export class Polygon {
|
|
|
115
115
|
clone() {
|
|
116
116
|
return new Polygon(this.contour.map(p => p.clone()), this.holes?.map(h => h.map(p => p.clone())));
|
|
117
117
|
}
|
|
118
|
+
roundIfCloseToInteger(max = 0.000000000001) {
|
|
119
|
+
this.contour.forEach(p => p.roundIfCloseToInteger(max));
|
|
120
|
+
this.holes?.forEach(h => h.forEach(p => p.roundIfCloseToInteger(max)));
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
118
123
|
equals(other) {
|
|
119
124
|
if (this.contour.length !== other.contour.length) {
|
|
120
125
|
return false;
|
package/esm/Vec2.js
CHANGED
|
@@ -59,6 +59,12 @@ export class Vec2 extends Vector2 {
|
|
|
59
59
|
if (Math.abs(this.y - Math.round(this.y)) < max) {
|
|
60
60
|
this.y = Math.round(this.y);
|
|
61
61
|
}
|
|
62
|
+
if (Object.is(this.x, -0)) {
|
|
63
|
+
this.x = 0;
|
|
64
|
+
}
|
|
65
|
+
if (Object.is(this.y, -0)) {
|
|
66
|
+
this.y = 0;
|
|
67
|
+
}
|
|
62
68
|
return this;
|
|
63
69
|
}
|
|
64
70
|
/**
|
package/esm/Vec3.js
CHANGED
|
@@ -78,6 +78,27 @@ export class Vec3 extends Vector3 {
|
|
|
78
78
|
const closest = withDistances.reduce((a, b) => a.distance < b.distance ? a : b);
|
|
79
79
|
return Vec3.fromPoint(closest.point);
|
|
80
80
|
}
|
|
81
|
+
roundIfCloseToInteger(max = 0.000000000001) {
|
|
82
|
+
if (Math.abs(this.x - Math.round(this.x)) < max) {
|
|
83
|
+
this.x = Math.round(this.x);
|
|
84
|
+
}
|
|
85
|
+
if (Math.abs(this.y - Math.round(this.y)) < max) {
|
|
86
|
+
this.y = Math.round(this.y);
|
|
87
|
+
}
|
|
88
|
+
if (Math.abs(this.z - Math.round(this.z)) < max) {
|
|
89
|
+
this.z = Math.round(this.z);
|
|
90
|
+
}
|
|
91
|
+
if (Object.is(this.x, -0)) {
|
|
92
|
+
this.x = 0;
|
|
93
|
+
}
|
|
94
|
+
if (Object.is(this.y, -0)) {
|
|
95
|
+
this.y = 0;
|
|
96
|
+
}
|
|
97
|
+
if (Object.is(this.z, -0)) {
|
|
98
|
+
this.z = 0;
|
|
99
|
+
}
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
81
102
|
/**
|
|
82
103
|
* Returns a clone of this Vec3 instance with y and z swapped.
|
|
83
104
|
*/
|
package/package.json
CHANGED
package/src/Polygon.ts
CHANGED
|
@@ -138,6 +138,12 @@ export class Polygon {
|
|
|
138
138
|
return new Polygon(this.contour.map(p => p.clone()), this.holes?.map(h => h.map(p => p.clone())));
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
public roundIfCloseToInteger(max: number = 0.000000000001): this {
|
|
142
|
+
this.contour.forEach(p => p.roundIfCloseToInteger(max));
|
|
143
|
+
this.holes?.forEach(h => h.forEach(p => p.roundIfCloseToInteger(max)));
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
|
|
141
147
|
public equals(other: Polygon): boolean {
|
|
142
148
|
if (this.contour.length !== other.contour.length) {
|
|
143
149
|
return false;
|
package/src/Vec2.ts
CHANGED
|
@@ -67,6 +67,12 @@ export class Vec2 extends Vector2 {
|
|
|
67
67
|
if (Math.abs(this.y - Math.round(this.y)) < max) {
|
|
68
68
|
this.y = Math.round(this.y);
|
|
69
69
|
}
|
|
70
|
+
if (Object.is(this.x, -0)) {
|
|
71
|
+
this.x = 0;
|
|
72
|
+
}
|
|
73
|
+
if (Object.is(this.y, -0)) {
|
|
74
|
+
this.y = 0;
|
|
75
|
+
}
|
|
70
76
|
return this;
|
|
71
77
|
}
|
|
72
78
|
|
package/src/Vec3.ts
CHANGED
|
@@ -94,6 +94,28 @@ export class Vec3 extends Vector3 {
|
|
|
94
94
|
return Vec3.fromPoint(closest.point);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
public roundIfCloseToInteger(max: number = 0.000000000001): this {
|
|
98
|
+
if (Math.abs(this.x - Math.round(this.x)) < max) {
|
|
99
|
+
this.x = Math.round(this.x);
|
|
100
|
+
}
|
|
101
|
+
if (Math.abs(this.y - Math.round(this.y)) < max) {
|
|
102
|
+
this.y = Math.round(this.y);
|
|
103
|
+
}
|
|
104
|
+
if (Math.abs(this.z - Math.round(this.z)) < max) {
|
|
105
|
+
this.z = Math.round(this.z);
|
|
106
|
+
}
|
|
107
|
+
if (Object.is(this.x, -0)) {
|
|
108
|
+
this.x = 0;
|
|
109
|
+
}
|
|
110
|
+
if (Object.is(this.y, -0)) {
|
|
111
|
+
this.y = 0;
|
|
112
|
+
}
|
|
113
|
+
if (Object.is(this.z, -0)) {
|
|
114
|
+
this.z = 0;
|
|
115
|
+
}
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
97
119
|
/**
|
|
98
120
|
* Returns a clone of this Vec3 instance with y and z swapped.
|
|
99
121
|
*/
|
package/types/Polygon.d.ts
CHANGED
package/types/Vec3.d.ts
CHANGED