@immugio/three-math-extensions 0.3.7 → 0.3.8

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 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.3.7](https://github.com/Immugio/three-math-extensions/compare/0.3.6...0.3.7)
10
+ ## [0.3.8](https://github.com/Immugio/three-math-extensions/compare/0.3.7...0.3.8)
11
+
12
+ ### Commits
13
+
14
+ - ensurePolygonLastPoint and ensurePolygonOpen functions to be also available as separate functions [`09036c1`](https://github.com/Immugio/three-math-extensions/commit/09036c18f9c9f579076d97a7b7cdcbffd345826a)
15
+
16
+ ## [0.3.7](https://github.com/Immugio/three-math-extensions/compare/0.3.6...0.3.7) - 2026-01-16
11
17
 
12
18
  ### Commits
13
19
 
package/cjs/Polygon.js CHANGED
@@ -10,6 +10,8 @@ const isPolygonClockwise_1 = require("./isPolygonClockwise");
10
10
  const ensurePolygonClockwise_1 = require("./ensurePolygonClockwise");
11
11
  const containsPoint_1 = require("./containsPoint");
12
12
  const getPolygonArea_1 = require("./getPolygonArea");
13
+ const ensurePolygonLastPoint_1 = require("./ensurePolygonLastPoint");
14
+ const ensurePolygonOpen_1 = require("./ensurePolygonOpen");
13
15
  class Polygon {
14
16
  contour;
15
17
  holes;
@@ -53,26 +55,16 @@ class Polygon {
53
55
  return new Vec2_1.Vec2(x, y);
54
56
  }
55
57
  ensureLastPoint() {
56
- function ensure(points) {
57
- if (!points[0].equals(points.at(-1))) {
58
- points.push(points[0].clone());
59
- }
60
- }
61
- ensure(this.contour);
58
+ (0, ensurePolygonLastPoint_1.ensurePolygonLastPoint)(this.contour);
62
59
  for (const hole of this.holes || []) {
63
- ensure(hole);
60
+ (0, ensurePolygonLastPoint_1.ensurePolygonLastPoint)(hole);
64
61
  }
65
62
  return this;
66
63
  }
67
64
  ensureOpen() {
68
- function ensure(points) {
69
- if (points.length > 2 && points[0].equals(points.at(-1))) {
70
- points.pop();
71
- }
72
- }
73
- ensure(this.contour);
65
+ (0, ensurePolygonOpen_1.ensurePolygonOpen)(this.contour);
74
66
  for (const hole of this.holes || []) {
75
- ensure(hole);
67
+ (0, ensurePolygonOpen_1.ensurePolygonOpen)(hole);
76
68
  }
77
69
  return this;
78
70
  }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensurePolygonLastPoint = void 0;
4
+ function ensurePolygonLastPoint(points) {
5
+ if (!points[0].equals(points.at(-1))) {
6
+ points.push(points[0].clone());
7
+ }
8
+ }
9
+ exports.ensurePolygonLastPoint = ensurePolygonLastPoint;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensurePolygonOpen = void 0;
4
+ function ensurePolygonOpen(points) {
5
+ if (points.length > 2 && points[0].equals(points.at(-1))) {
6
+ points.pop();
7
+ }
8
+ }
9
+ exports.ensurePolygonOpen = ensurePolygonOpen;
package/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPolygonArea = exports.containsPoints = exports.containsPoint = exports.ensurePolygonClockwise = exports.isPolygonClockwise = exports.sortLinesByConnections = exports.extendOrTrimPolylinesAtIntersections = exports.offsetPolyline = exports.polygonPerimeter = exports.isContinuousClosedShape = exports.directions2d = exports.directions = exports.isPointInPolygon = exports.HalfPI = exports.TwoPI = exports.normalizeAngleRadians = exports.normalizeAngleDegrees = exports.Rectangle = exports.BoundingBox = exports.Polygon = exports.Size2 = exports.Line3D = exports.Line2D = exports.Vec3 = exports.Vec2 = void 0;
3
+ exports.ensurePolygonOpen = exports.ensurePolygonLastPoint = exports.getPolygonArea = exports.containsPoints = exports.containsPoint = exports.ensurePolygonClockwise = exports.isPolygonClockwise = exports.sortLinesByConnections = exports.extendOrTrimPolylinesAtIntersections = exports.offsetPolyline = exports.polygonPerimeter = exports.isContinuousClosedShape = exports.directions2d = exports.directions = exports.isPointInPolygon = exports.HalfPI = exports.TwoPI = exports.normalizeAngleRadians = exports.normalizeAngleDegrees = exports.Rectangle = exports.BoundingBox = exports.Polygon = exports.Size2 = exports.Line3D = exports.Line2D = exports.Vec3 = exports.Vec2 = void 0;
4
4
  var Vec2_1 = require("./Vec2");
5
5
  Object.defineProperty(exports, "Vec2", { enumerable: true, get: function () { return Vec2_1.Vec2; } });
6
6
  var Vec3_1 = require("./Vec3");
@@ -49,3 +49,7 @@ Object.defineProperty(exports, "containsPoint", { enumerable: true, get: functio
49
49
  Object.defineProperty(exports, "containsPoints", { enumerable: true, get: function () { return containsPoint_1.containsPoints; } });
50
50
  var getPolygonArea_1 = require("./getPolygonArea");
51
51
  Object.defineProperty(exports, "getPolygonArea", { enumerable: true, get: function () { return getPolygonArea_1.getPolygonArea; } });
52
+ var ensurePolygonLastPoint_1 = require("./ensurePolygonLastPoint");
53
+ Object.defineProperty(exports, "ensurePolygonLastPoint", { enumerable: true, get: function () { return ensurePolygonLastPoint_1.ensurePolygonLastPoint; } });
54
+ var ensurePolygonOpen_1 = require("./ensurePolygonOpen");
55
+ Object.defineProperty(exports, "ensurePolygonOpen", { enumerable: true, get: function () { return ensurePolygonOpen_1.ensurePolygonOpen; } });
package/esm/Polygon.js CHANGED
@@ -7,6 +7,8 @@ import { isPolygonClockwise } from "./isPolygonClockwise";
7
7
  import { ensurePolygonClockwise } from "./ensurePolygonClockwise";
8
8
  import { containsPoint } from "./containsPoint";
9
9
  import { getPolygonArea } from "./getPolygonArea";
10
+ import { ensurePolygonLastPoint } from "./ensurePolygonLastPoint";
11
+ import { ensurePolygonOpen } from "./ensurePolygonOpen";
10
12
  export class Polygon {
11
13
  contour;
12
14
  holes;
@@ -50,26 +52,16 @@ export class Polygon {
50
52
  return new Vec2(x, y);
51
53
  }
52
54
  ensureLastPoint() {
53
- function ensure(points) {
54
- if (!points[0].equals(points.at(-1))) {
55
- points.push(points[0].clone());
56
- }
57
- }
58
- ensure(this.contour);
55
+ ensurePolygonLastPoint(this.contour);
59
56
  for (const hole of this.holes || []) {
60
- ensure(hole);
57
+ ensurePolygonLastPoint(hole);
61
58
  }
62
59
  return this;
63
60
  }
64
61
  ensureOpen() {
65
- function ensure(points) {
66
- if (points.length > 2 && points[0].equals(points.at(-1))) {
67
- points.pop();
68
- }
69
- }
70
- ensure(this.contour);
62
+ ensurePolygonOpen(this.contour);
71
63
  for (const hole of this.holes || []) {
72
- ensure(hole);
64
+ ensurePolygonOpen(hole);
73
65
  }
74
66
  return this;
75
67
  }
@@ -0,0 +1,5 @@
1
+ export function ensurePolygonLastPoint(points) {
2
+ if (!points[0].equals(points.at(-1))) {
3
+ points.push(points[0].clone());
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ export function ensurePolygonOpen(points) {
2
+ if (points.length > 2 && points[0].equals(points.at(-1))) {
3
+ points.pop();
4
+ }
5
+ }
package/esm/index.js CHANGED
@@ -21,3 +21,5 @@ export { isPolygonClockwise } from "./isPolygonClockwise";
21
21
  export { ensurePolygonClockwise } from "./ensurePolygonClockwise";
22
22
  export { containsPoint, containsPoints } from "./containsPoint";
23
23
  export { getPolygonArea } from "./getPolygonArea";
24
+ export { ensurePolygonLastPoint } from "./ensurePolygonLastPoint";
25
+ export { ensurePolygonOpen } from "./ensurePolygonOpen";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immugio/three-math-extensions",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
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",
package/src/Polygon.ts CHANGED
@@ -8,6 +8,8 @@ import { isPolygonClockwise } from "./isPolygonClockwise";
8
8
  import { ensurePolygonClockwise } from "./ensurePolygonClockwise";
9
9
  import { containsPoint } from "./containsPoint";
10
10
  import { getPolygonArea } from "./getPolygonArea";
11
+ import { ensurePolygonLastPoint } from "./ensurePolygonLastPoint";
12
+ import { ensurePolygonOpen } from "./ensurePolygonOpen";
11
13
 
12
14
  export class Polygon {
13
15
 
@@ -61,32 +63,20 @@ export class Polygon {
61
63
  }
62
64
 
63
65
  public ensureLastPoint(): this {
64
- function ensure(points: Vec2[]): void {
65
- if (!points[0].equals(points.at(-1))) {
66
- points.push(points[0].clone());
67
- }
68
- }
69
-
70
- ensure(this.contour);
66
+ ensurePolygonLastPoint(this.contour);
71
67
 
72
68
  for (const hole of this.holes || []) {
73
- ensure(hole);
69
+ ensurePolygonLastPoint(hole);
74
70
  }
75
71
 
76
72
  return this;
77
73
  }
78
74
 
79
75
  public ensureOpen(): this {
80
- function ensure(points: Vec2[]): void {
81
- if (points.length > 2 && points[0].equals(points.at(-1))) {
82
- points.pop();
83
- }
84
- }
85
-
86
- ensure(this.contour);
76
+ ensurePolygonOpen(this.contour);
87
77
 
88
78
  for (const hole of this.holes || []) {
89
- ensure(hole);
79
+ ensurePolygonOpen(hole);
90
80
  }
91
81
 
92
82
  return this;
@@ -0,0 +1,7 @@
1
+ import { Vec2 } from "./Vec2";
2
+
3
+ export function ensurePolygonLastPoint(points: Vec2[]): void {
4
+ if (!points[0].equals(points.at(-1))) {
5
+ points.push(points[0].clone());
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Vec2 } from "./Vec2";
2
+
3
+ export function ensurePolygonOpen(points: Vec2[]): void {
4
+ if (points.length > 2 && points[0].equals(points.at(-1))) {
5
+ points.pop();
6
+ }
7
+ }
package/src/index.ts CHANGED
@@ -22,4 +22,6 @@ export { sortLinesByConnections } from "./sortLinesByConnections";
22
22
  export { isPolygonClockwise } from "./isPolygonClockwise";
23
23
  export { ensurePolygonClockwise } from "./ensurePolygonClockwise";
24
24
  export { containsPoint, containsPoints } from "./containsPoint";
25
- export { getPolygonArea } from "./getPolygonArea";
25
+ export { getPolygonArea } from "./getPolygonArea";
26
+ export { ensurePolygonLastPoint } from "./ensurePolygonLastPoint";
27
+ export { ensurePolygonOpen } from "./ensurePolygonOpen";
@@ -0,0 +1,2 @@
1
+ import { Vec2 } from "./Vec2";
2
+ export declare function ensurePolygonLastPoint(points: Vec2[]): void;
@@ -0,0 +1,2 @@
1
+ import { Vec2 } from "./Vec2";
2
+ export declare function ensurePolygonOpen(points: Vec2[]): void;
package/types/index.d.ts CHANGED
@@ -23,3 +23,5 @@ export { isPolygonClockwise } from "./isPolygonClockwise";
23
23
  export { ensurePolygonClockwise } from "./ensurePolygonClockwise";
24
24
  export { containsPoint, containsPoints } from "./containsPoint";
25
25
  export { getPolygonArea } from "./getPolygonArea";
26
+ export { ensurePolygonLastPoint } from "./ensurePolygonLastPoint";
27
+ export { ensurePolygonOpen } from "./ensurePolygonOpen";