@immugio/three-math-extensions 0.2.30 → 0.2.31
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 +7 -1
- package/cjs/Vec3.js +9 -0
- package/esm/Vec3.js +9 -0
- package/package.json +1 -1
- package/src/Vec3.ts +13 -0
- package/types/Vec3.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,13 @@ 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.31](https://github.com/Immugio/three-math-extensions/compare/0.2.30...0.2.31)
|
|
11
|
+
|
|
12
|
+
### Commits
|
|
13
|
+
|
|
14
|
+
- Add Vec3.applyAxisAngleAroundCenter [`a45aaea`](https://github.com/Immugio/three-math-extensions/commit/a45aaea2b6579e8f94859d1ed29abf81479d3a76)
|
|
15
|
+
|
|
16
|
+
## [0.2.30](https://github.com/Immugio/three-math-extensions/compare/0.2.29...0.2.30) - 2024-09-12
|
|
11
17
|
|
|
12
18
|
### Commits
|
|
13
19
|
|
package/cjs/Vec3.js
CHANGED
|
@@ -81,6 +81,15 @@ 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
|
+
applyAxisAngleAroundCenter(axis, angle, center) {
|
|
85
|
+
// Translate the vector to the origin
|
|
86
|
+
this.sub(center);
|
|
87
|
+
// Apply the axis-angle rotation
|
|
88
|
+
this.applyAxisAngle(axis, angle);
|
|
89
|
+
// Translate the vector back to the original position
|
|
90
|
+
this.add(center);
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
84
93
|
roundIfCloseToInteger(max = 0.000000000001) {
|
|
85
94
|
if (Math.abs(this.x - Math.round(this.x)) < max) {
|
|
86
95
|
this.x = Math.round(this.x);
|
package/esm/Vec3.js
CHANGED
|
@@ -78,6 +78,15 @@ 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
|
+
applyAxisAngleAroundCenter(axis, angle, center) {
|
|
82
|
+
// Translate the vector to the origin
|
|
83
|
+
this.sub(center);
|
|
84
|
+
// Apply the axis-angle rotation
|
|
85
|
+
this.applyAxisAngle(axis, angle);
|
|
86
|
+
// Translate the vector back to the original position
|
|
87
|
+
this.add(center);
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
81
90
|
roundIfCloseToInteger(max = 0.000000000001) {
|
|
82
91
|
if (Math.abs(this.x - Math.round(this.x)) < max) {
|
|
83
92
|
this.x = Math.round(this.x);
|
package/package.json
CHANGED
package/src/Vec3.ts
CHANGED
|
@@ -94,6 +94,19 @@ export class Vec3 extends Vector3 {
|
|
|
94
94
|
return Vec3.fromPoint(closest.point);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
public applyAxisAngleAroundCenter(axis: Vector3, angle: number, center: Vector3): this {
|
|
98
|
+
// Translate the vector to the origin
|
|
99
|
+
this.sub(center);
|
|
100
|
+
|
|
101
|
+
// Apply the axis-angle rotation
|
|
102
|
+
this.applyAxisAngle(axis, angle);
|
|
103
|
+
|
|
104
|
+
// Translate the vector back to the original position
|
|
105
|
+
this.add(center);
|
|
106
|
+
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
97
110
|
public roundIfCloseToInteger(max: number = 0.000000000001): this {
|
|
98
111
|
if (Math.abs(this.x - Math.round(this.x)) < max) {
|
|
99
112
|
this.x = Math.round(this.x);
|
package/types/Vec3.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare class Vec3 extends Vector3 {
|
|
|
50
50
|
* @param points
|
|
51
51
|
*/
|
|
52
52
|
closest(...points: Vector3[]): Vec3;
|
|
53
|
+
applyAxisAngleAroundCenter(axis: Vector3, angle: number, center: Vector3): this;
|
|
53
54
|
roundIfCloseToInteger(max?: number): this;
|
|
54
55
|
/**
|
|
55
56
|
* Returns a clone of this Vec3 instance with y and z swapped.
|