@immugio/three-math-extensions 0.0.4 → 0.0.6

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/cjs/Point2.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/Point3.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/Vec2.js CHANGED
@@ -1,23 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vec2 = void 0;
4
- const three_1 = require("three");
5
- const Vec3_1 = require("./Vec3");
6
- class Vec2 extends three_1.Vector2 {
7
- static fromPoint(point) {
8
- return new Vec2(point.x, point.y);
9
- }
10
- roundIfCloseToInteger(max = 0.000000000001) {
11
- if (Math.abs(this.x - Math.round(this.x)) < max) {
12
- this.x = Math.round(this.x);
13
- }
14
- if (Math.abs(this.y - Math.round(this.y)) < max) {
15
- this.y = Math.round(this.y);
16
- }
17
- return this;
18
- }
19
- in3DSpace(z = 0) {
20
- return new Vec3_1.Vec3(this.x, z, this.y);
21
- }
22
- }
23
- exports.Vec2 = Vec2;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Vec2 = void 0;
4
+ const three_1 = require("three");
5
+ const Vec3_1 = require("./Vec3");
6
+ class Vec2 extends three_1.Vector2 {
7
+ static fromPoint(point) {
8
+ return new Vec2(point.x, point.y);
9
+ }
10
+ roundIfCloseToInteger(max = 0.000000000001) {
11
+ if (Math.abs(this.x - Math.round(this.x)) < max) {
12
+ this.x = Math.round(this.x);
13
+ }
14
+ if (Math.abs(this.y - Math.round(this.y)) < max) {
15
+ this.y = Math.round(this.y);
16
+ }
17
+ return this;
18
+ }
19
+ in3DSpace(z = 0) {
20
+ return new Vec3_1.Vec3(this.x, z, this.y);
21
+ }
22
+ }
23
+ exports.Vec2 = Vec2;
package/cjs/Vec3.js CHANGED
@@ -1,57 +1,57 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vec3 = void 0;
4
- const three_1 = require("three");
5
- const Vec2_1 = require("./Vec2");
6
- class Vec3 extends three_1.Vector3 {
7
- #target;
8
- static fromPoint(point) {
9
- return new Vec3(point.x, point.y, point.z);
10
- }
11
- moveTowards(target, amount) {
12
- if (this.#target === undefined) {
13
- this.#target = new three_1.Vector3();
14
- }
15
- this.#target.copy(target);
16
- this.add(this.#target.sub(this).normalize().multiplyScalar(amount));
17
- return this;
18
- }
19
- centerTowards(target) {
20
- if (this.#target === undefined) {
21
- this.#target = new three_1.Vector3();
22
- }
23
- return this.moveTowards(target, this.distanceTo(target) / 2);
24
- }
25
- addY(y) {
26
- this.y += y;
27
- return this;
28
- }
29
- addX(x) {
30
- this.x += x;
31
- return this;
32
- }
33
- scale(p) {
34
- this.x *= p.x;
35
- this.y *= p.y;
36
- this.z *= p.z;
37
- return this;
38
- }
39
- closest(...points) {
40
- const withDistances = points.map(p => ({ point: p, distance: this.distanceTo(p) }));
41
- const closest = withDistances.reduce((a, b) => a.distance < b.distance ? a : b);
42
- return Vec3.fromPoint(closest.point);
43
- }
44
- toPointWithFlippedYZ() {
45
- return new Vec3(this.x, this.z, this.y);
46
- }
47
- onPlan() {
48
- return new Vec2_1.Vec2(this.x, this.z);
49
- }
50
- horizontalDistanceTo(point) {
51
- return new three_1.Vector3(this.x, 0, this.z).distanceTo(new three_1.Vector3(point.x, 0, point.z));
52
- }
53
- clone() {
54
- return super.clone();
55
- }
56
- }
57
- exports.Vec3 = Vec3;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Vec3 = void 0;
4
+ const three_1 = require("three");
5
+ const Vec2_1 = require("./Vec2");
6
+ class Vec3 extends three_1.Vector3 {
7
+ #target;
8
+ static fromPoint(point) {
9
+ return new Vec3(point.x, point.y, point.z);
10
+ }
11
+ moveTowards(target, amount) {
12
+ if (this.#target === undefined) {
13
+ this.#target = new three_1.Vector3();
14
+ }
15
+ this.#target.copy(target);
16
+ this.add(this.#target.sub(this).normalize().multiplyScalar(amount));
17
+ return this;
18
+ }
19
+ centerTowards(target) {
20
+ if (this.#target === undefined) {
21
+ this.#target = new three_1.Vector3();
22
+ }
23
+ return this.moveTowards(target, this.distanceTo(target) / 2);
24
+ }
25
+ addY(y) {
26
+ this.y += y;
27
+ return this;
28
+ }
29
+ addX(x) {
30
+ this.x += x;
31
+ return this;
32
+ }
33
+ scale(p) {
34
+ this.x *= p.x;
35
+ this.y *= p.y;
36
+ this.z *= p.z;
37
+ return this;
38
+ }
39
+ closest(...points) {
40
+ const withDistances = points.map(p => ({ point: p, distance: this.distanceTo(p) }));
41
+ const closest = withDistances.reduce((a, b) => a.distance < b.distance ? a : b);
42
+ return Vec3.fromPoint(closest.point);
43
+ }
44
+ toPointWithFlippedYZ() {
45
+ return new Vec3(this.x, this.z, this.y);
46
+ }
47
+ onPlan() {
48
+ return new Vec2_1.Vec2(this.x, this.z);
49
+ }
50
+ horizontalDistanceTo(point) {
51
+ return new three_1.Vector3(this.x, 0, this.z).distanceTo(new three_1.Vector3(point.x, 0, point.z));
52
+ }
53
+ clone() {
54
+ return super.clone();
55
+ }
56
+ }
57
+ exports.Vec3 = Vec3;
package/cjs/index.js CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Line3D = exports.Line2D = exports.Vec3 = exports.Vec2 = void 0;
4
- var Vec2_1 = require("./Vec2");
5
- Object.defineProperty(exports, "Vec2", { enumerable: true, get: function () { return Vec2_1.Vec2; } });
6
- var Vec3_1 = require("./Vec3");
7
- Object.defineProperty(exports, "Vec3", { enumerable: true, get: function () { return Vec3_1.Vec3; } });
8
- var Line2D_1 = require("./Line2D");
9
- Object.defineProperty(exports, "Line2D", { enumerable: true, get: function () { return Line2D_1.Line2D; } });
10
- var Line3D_1 = require("./Line3D");
11
- Object.defineProperty(exports, "Line3D", { enumerable: true, get: function () { return Line3D_1.Line3D; } });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Line3D = exports.Line2D = exports.Vec3 = exports.Vec2 = void 0;
4
+ var Vec2_1 = require("./Vec2");
5
+ Object.defineProperty(exports, "Vec2", { enumerable: true, get: function () { return Vec2_1.Vec2; } });
6
+ var Vec3_1 = require("./Vec3");
7
+ Object.defineProperty(exports, "Vec3", { enumerable: true, get: function () { return Vec3_1.Vec3; } });
8
+ var Line2D_1 = require("./Line2D");
9
+ Object.defineProperty(exports, "Line2D", { enumerable: true, get: function () { return Line2D_1.Line2D; } });
10
+ var Line3D_1 = require("./Line3D");
11
+ Object.defineProperty(exports, "Line3D", { enumerable: true, get: function () { return Line3D_1.Line3D; } });