@immugio/three-math-extensions 0.2.0 → 0.2.1
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 +10 -2
- package/cjs/Polygon.js +8 -0
- package/esm/Polygon.js +8 -0
- package/package.json +1 -1
- package/src/Polygon.ts +9 -0
- package/types/Polygon.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,17 +7,25 @@ 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.1](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.1)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
14
14
|
- Add Rectangle, update Polygon [`58ee875`](https://github.com/Immugio/three-math-extensions/commit/58ee87539af8f9ade186e5250cba9e01926da514)
|
|
15
15
|
- Vec3, Line3D - update documentation [`67d9c32`](https://github.com/Immugio/three-math-extensions/commit/67d9c328e08cc0a5599932d2f0529e97f31c9213)
|
|
16
16
|
- Add Polygon [`629cff8`](https://github.com/Immugio/three-math-extensions/commit/629cff8ecbb963477e8ea76d7f8b16d95435cbad)
|
|
17
|
+
- Polygon from bounding size [`eae6701`](https://github.com/Immugio/three-math-extensions/commit/eae67012f57f426f8b5259b765000447ce06d608)
|
|
17
18
|
- Add Polygon to exports [`ed66775`](https://github.com/Immugio/three-math-extensions/commit/ed66775c33e961835b23843222b822cfd9c16b1d)
|
|
18
19
|
- Vec2.fromPoint and Vec3.fromPoint should accept null [`4b871af`](https://github.com/Immugio/three-math-extensions/commit/4b871af297bdcbe8584f1e2b99d602247b77687c)
|
|
19
20
|
|
|
20
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.
|
|
21
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.0...16.15.10) - 2023-01-02
|
|
22
|
+
|
|
23
|
+
## [0.2.0](https://github.com/Immugio/three-math-extensions/compare/0.1.1...0.2.0) - 2023-02-28
|
|
24
|
+
|
|
25
|
+
### Commits
|
|
26
|
+
|
|
27
|
+
- Add Rectangle, update Polygon [`58ee875`](https://github.com/Immugio/three-math-extensions/commit/58ee87539af8f9ade186e5250cba9e01926da514)
|
|
28
|
+
- Vec3, Line3D - update documentation [`67d9c32`](https://github.com/Immugio/three-math-extensions/commit/67d9c328e08cc0a5599932d2f0529e97f31c9213)
|
|
21
29
|
|
|
22
30
|
## [0.1.1](https://github.com/Immugio/three-math-extensions/compare/0.1.0...0.1.1) - 2023-01-02
|
|
23
31
|
|
package/cjs/Polygon.js
CHANGED
|
@@ -14,6 +14,14 @@ class Polygon {
|
|
|
14
14
|
static fromPoints(contour, holes) {
|
|
15
15
|
return new Polygon(contour.map(p => Vec2_1.Vec2.fromPoint(p)), holes?.map(h => h.map(p => Vec2_1.Vec2.fromPoint(p))));
|
|
16
16
|
}
|
|
17
|
+
static fromSize(width, height) {
|
|
18
|
+
return new Polygon([
|
|
19
|
+
new Vec2_1.Vec2(0, 0),
|
|
20
|
+
new Vec2_1.Vec2(width, 0),
|
|
21
|
+
new Vec2_1.Vec2(width, height),
|
|
22
|
+
new Vec2_1.Vec2(0, height),
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
17
25
|
get size() {
|
|
18
26
|
const { minX, maxX, minY, maxY } = this.boundingBox();
|
|
19
27
|
return new Vec2_1.Vec2(maxX - minX, maxY - minY);
|
package/esm/Polygon.js
CHANGED
|
@@ -11,6 +11,14 @@ export class Polygon {
|
|
|
11
11
|
static fromPoints(contour, holes) {
|
|
12
12
|
return new Polygon(contour.map(p => Vec2.fromPoint(p)), holes?.map(h => h.map(p => Vec2.fromPoint(p))));
|
|
13
13
|
}
|
|
14
|
+
static fromSize(width, height) {
|
|
15
|
+
return new Polygon([
|
|
16
|
+
new Vec2(0, 0),
|
|
17
|
+
new Vec2(width, 0),
|
|
18
|
+
new Vec2(width, height),
|
|
19
|
+
new Vec2(0, height),
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
14
22
|
get size() {
|
|
15
23
|
const { minX, maxX, minY, maxY } = this.boundingBox();
|
|
16
24
|
return new Vec2(maxX - minX, maxY - minY);
|
package/package.json
CHANGED
package/src/Polygon.ts
CHANGED
|
@@ -12,6 +12,15 @@ export class Polygon {
|
|
|
12
12
|
return new Polygon(contour.map(p => Vec2.fromPoint(p)), holes?.map(h => h.map(p => Vec2.fromPoint(p))) );
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
public static fromSize(width: number, height: number): Polygon {
|
|
16
|
+
return new Polygon([
|
|
17
|
+
new Vec2(0, 0),
|
|
18
|
+
new Vec2(width, 0),
|
|
19
|
+
new Vec2(width, height),
|
|
20
|
+
new Vec2(0, height),
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
public get size(): Vec2 {
|
|
16
25
|
const { minX, maxX, minY, maxY } = this.boundingBox();
|
|
17
26
|
return new Vec2(maxX - minX, maxY - minY);
|
package/types/Polygon.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class Polygon {
|
|
|
7
7
|
holes?: Vec2[][];
|
|
8
8
|
constructor(contour: Vec2[], holes?: Vec2[][]);
|
|
9
9
|
static fromPoints(contour: Point2[], holes?: Point2[][]): Polygon;
|
|
10
|
+
static fromSize(width: number, height: number): Polygon;
|
|
10
11
|
get size(): Vec2;
|
|
11
12
|
centerOnOrigin(): Polygon;
|
|
12
13
|
center(): Vec2;
|