@immugio/three-math-extensions 0.3.4 → 0.3.7

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/cjs/Line2D.js +90 -13
  3. package/cjs/Polygon.js +3 -0
  4. package/docs/classes/BoundingBox.md +121 -121
  5. package/docs/classes/Line2D.md +1366 -1366
  6. package/docs/classes/Line3D.md +831 -831
  7. package/docs/classes/Polygon.md +297 -297
  8. package/docs/classes/Rectangle.md +291 -291
  9. package/docs/classes/Size2.md +55 -55
  10. package/docs/classes/Vec2.md +282 -282
  11. package/docs/classes/Vec3.md +338 -338
  12. package/docs/interfaces/Point2.md +30 -30
  13. package/docs/interfaces/Point3.md +41 -41
  14. package/docs/modules.md +209 -209
  15. package/eslint.config.mjs +111 -111
  16. package/esm/Line2D.js +90 -13
  17. package/esm/Polygon.js +3 -0
  18. package/package.json +62 -62
  19. package/src/BoundingBox.ts +13 -13
  20. package/src/Line2D.ts +951 -857
  21. package/src/Line3D.ts +586 -586
  22. package/src/MathConstants.ts +1 -1
  23. package/src/Point2.ts +3 -3
  24. package/src/Point3.ts +4 -4
  25. package/src/Polygon.ts +290 -286
  26. package/src/Rectangle.ts +92 -92
  27. package/src/Size2.ts +3 -3
  28. package/src/Vec2.ts +124 -124
  29. package/src/Vec3.ts +167 -167
  30. package/src/containsPoint.ts +65 -65
  31. package/src/directions.ts +9 -9
  32. package/src/directions2d.ts +7 -7
  33. package/src/ensurePolygonClockwise.ts +9 -9
  34. package/src/extendOrTrimPolylinesAtIntersections.ts +10 -10
  35. package/src/getPolygonArea.ts +21 -21
  36. package/src/index.ts +24 -24
  37. package/src/isContinuousClosedShape.ts +24 -24
  38. package/src/isPointInPolygon.ts +23 -23
  39. package/src/isPolygonClockwise.ts +15 -15
  40. package/src/normalizeAngleDegrees.ts +6 -6
  41. package/src/normalizeAngleRadians.ts +14 -14
  42. package/src/offsetPolyline.ts +26 -26
  43. package/src/polygonPerimeter.ts +13 -13
  44. package/src/sortLinesByConnections.ts +45 -45
  45. package/types/Line2D.d.ts +12 -5
@@ -1,338 +1,338 @@
1
- [@immugio/three-math-extensions](../../README.md) / [Exports](../modules.md) / Vec3
2
-
3
- # Class: Vec3
4
-
5
- Vec3 represents a 3D vector. It extends `Vector3` from the `threejs` library.
6
-
7
- ## Hierarchy
8
-
9
- - `Vector3`
10
-
11
- ↳ **`Vec3`**
12
-
13
- ## Table of contents
14
-
15
- ### Constructors
16
-
17
- - [constructor](Vec3.md#constructor)
18
-
19
- ### Methods
20
-
21
- - [addX](Vec3.md#addx)
22
- - [addY](Vec3.md#addy)
23
- - [addZ](Vec3.md#addz)
24
- - [clone](Vec3.md#clone)
25
- - [closest](Vec3.md#closest)
26
- - [horizontalDistanceTo](Vec3.md#horizontaldistanceto)
27
- - [isNear](Vec3.md#isnear)
28
- - [moveHalfWayTowards](Vec3.md#movehalfwaytowards)
29
- - [moveTowards](Vec3.md#movetowards)
30
- - [onPlan](Vec3.md#onplan)
31
- - [toPointWithFlippedYZ](Vec3.md#topointwithflippedyz)
32
- - [fromPoint](Vec3.md#frompoint)
33
- - [fromPoints](Vec3.md#frompoints)
34
-
35
- ## Constructors
36
-
37
- ### constructor
38
-
39
- • **new Vec3**(`x?`, `y?`, `z?`): [`Vec3`](Vec3.md)
40
-
41
- #### Parameters
42
-
43
- | Name | Type |
44
- | :------ | :------ |
45
- | `x?` | `number` |
46
- | `y?` | `number` |
47
- | `z?` | `number` |
48
-
49
- #### Returns
50
-
51
- [`Vec3`](Vec3.md)
52
-
53
- #### Inherited from
54
-
55
- Vector3.constructor
56
-
57
- #### Defined in
58
-
59
- node_modules/@types/three/src/math/Vector3.d.ts:27
60
-
61
- ## Methods
62
-
63
- ### addX
64
-
65
- ▸ **addX**(`x`): [`Vec3`](Vec3.md)
66
-
67
- Adds x amount to this Vec3 instance and return this
68
-
69
- #### Parameters
70
-
71
- | Name | Type |
72
- | :------ | :------ |
73
- | `x` | `number` |
74
-
75
- #### Returns
76
-
77
- [`Vec3`](Vec3.md)
78
-
79
- #### Defined in
80
-
81
- [src/Vec3.ts:73](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L73)
82
-
83
- ___
84
-
85
- ### addY
86
-
87
- ▸ **addY**(`y`): [`Vec3`](Vec3.md)
88
-
89
- Adds y amount to this Vec3 instance and return this
90
-
91
- #### Parameters
92
-
93
- | Name | Type |
94
- | :------ | :------ |
95
- | `y` | `number` |
96
-
97
- #### Returns
98
-
99
- [`Vec3`](Vec3.md)
100
-
101
- #### Defined in
102
-
103
- [src/Vec3.ts:64](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L64)
104
-
105
- ___
106
-
107
- ### addZ
108
-
109
- ▸ **addZ**(`z`): [`Vec3`](Vec3.md)
110
-
111
- Adds z amount to this Vec3 instance and return this
112
-
113
- #### Parameters
114
-
115
- | Name | Type |
116
- | :------ | :------ |
117
- | `z` | `number` |
118
-
119
- #### Returns
120
-
121
- [`Vec3`](Vec3.md)
122
-
123
- #### Defined in
124
-
125
- [src/Vec3.ts:82](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L82)
126
-
127
- ___
128
-
129
- ### clone
130
-
131
- ▸ **clone**(): [`Vec3`](Vec3.md)
132
-
133
- #### Returns
134
-
135
- [`Vec3`](Vec3.md)
136
-
137
- #### Overrides
138
-
139
- Vector3.clone
140
-
141
- #### Defined in
142
-
143
- [src/Vec3.ts:131](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L131)
144
-
145
- ___
146
-
147
- ### closest
148
-
149
- ▸ **closest**(`...points`): [`Vec3`](Vec3.md)
150
-
151
- Returns a clone of the point closest to this from the given points.
152
-
153
- #### Parameters
154
-
155
- | Name | Type |
156
- | :------ | :------ |
157
- | `...points` | `Vector3`[] |
158
-
159
- #### Returns
160
-
161
- [`Vec3`](Vec3.md)
162
-
163
- #### Defined in
164
-
165
- [src/Vec3.ts:91](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L91)
166
-
167
- ___
168
-
169
- ### horizontalDistanceTo
170
-
171
- ▸ **horizontalDistanceTo**(`point`): `number`
172
-
173
- Get distance to another vector while ignoring the y-axis.
174
-
175
- #### Parameters
176
-
177
- | Name | Type |
178
- | :------ | :------ |
179
- | `point` | `Vector3` |
180
-
181
- #### Returns
182
-
183
- `number`
184
-
185
- #### Defined in
186
-
187
- [src/Vec3.ts:115](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L115)
188
-
189
- ___
190
-
191
- ### isNear
192
-
193
- ▸ **isNear**(`v`, `maxDistance?`): `boolean`
194
-
195
- Determines if this Vec2 instance is near the target Vec2.
196
- maxDistance is the maximum distance between the two vectors within which they are considered `near`.
197
-
198
- #### Parameters
199
-
200
- | Name | Type | Default value |
201
- | :------ | :------ | :------ |
202
- | `v` | `Vector3` | `undefined` |
203
- | `maxDistance` | `number` | `undefined` |
204
-
205
- #### Returns
206
-
207
- `boolean`
208
-
209
- #### Defined in
210
-
211
- [src/Vec3.ts:123](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L123)
212
-
213
- ___
214
-
215
- ### moveHalfWayTowards
216
-
217
- ▸ **moveHalfWayTowards**(`target`): [`Vec3`](Vec3.md)
218
-
219
- Moves this Vec3 instance halfway towards the target Vec3 by the given amount.
220
-
221
- #### Parameters
222
-
223
- | Name | Type | Description |
224
- | :------ | :------ | :------ |
225
- | `target` | `Vector3` | The target Vec3. |
226
-
227
- #### Returns
228
-
229
- [`Vec3`](Vec3.md)
230
-
231
- This Vec3 instance.
232
-
233
- #### Defined in
234
-
235
- [src/Vec3.ts:51](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L51)
236
-
237
- ___
238
-
239
- ### moveTowards
240
-
241
- ▸ **moveTowards**(`target`, `amount`): [`Vec3`](Vec3.md)
242
-
243
- Moves this Vec3 instance towards the target Vec3 by the given amount.
244
-
245
- #### Parameters
246
-
247
- | Name | Type | Description |
248
- | :------ | :------ | :------ |
249
- | `target` | `Vector3` | The target Vec3. |
250
- | `amount` | `number` | The distance to move. |
251
-
252
- #### Returns
253
-
254
- [`Vec3`](Vec3.md)
255
-
256
- This Vec3 instance.
257
-
258
- #### Defined in
259
-
260
- [src/Vec3.ts:35](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L35)
261
-
262
- ___
263
-
264
- ### onPlan
265
-
266
- ▸ **onPlan**(): [`Vec2`](Vec2.md)
267
-
268
- Projects this Vec3 instance onto 2d plan. Vec3.z becomes Vec2.y and Vec3.y is ignored.
269
-
270
- #### Returns
271
-
272
- [`Vec2`](Vec2.md)
273
-
274
- #### Defined in
275
-
276
- [src/Vec3.ts:107](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L107)
277
-
278
- ___
279
-
280
- ### toPointWithFlippedYZ
281
-
282
- ▸ **toPointWithFlippedYZ**(): [`Vec3`](Vec3.md)
283
-
284
- Returns a clone of this Vec3 instance with y and z swapped.
285
-
286
- #### Returns
287
-
288
- [`Vec3`](Vec3.md)
289
-
290
- #### Defined in
291
-
292
- [src/Vec3.ts:100](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L100)
293
-
294
- ___
295
-
296
- ### fromPoint
297
-
298
- ▸ **fromPoint**(`point`): [`Vec3`](Vec3.md)
299
-
300
- Creates a new Vec3 instance from an {x, y, z} object.
301
-
302
- #### Parameters
303
-
304
- | Name | Type | Description |
305
- | :------ | :------ | :------ |
306
- | `point` | [`Point3`](../interfaces/Point3.md) | The {x, y, z} instance. |
307
-
308
- #### Returns
309
-
310
- [`Vec3`](Vec3.md)
311
-
312
- A new Vec3 instance.
313
-
314
- #### Defined in
315
-
316
- [src/Vec3.ts:17](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L17)
317
-
318
- ___
319
-
320
- ### fromPoints
321
-
322
- ▸ **fromPoints**(`...points`): [`Vec3`](Vec3.md)[]
323
-
324
- Creates a new Vec3[] array from arguments of {x, y, z} objects.
325
-
326
- #### Parameters
327
-
328
- | Name | Type | Description |
329
- | :------ | :------ | :------ |
330
- | `...points` | [`Point3`](../interfaces/Point3.md)[] | The ...{x, y, z} instances. |
331
-
332
- #### Returns
333
-
334
- [`Vec3`](Vec3.md)[]
335
-
336
- #### Defined in
337
-
338
- [src/Vec3.ts:25](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L25)
1
+ [@immugio/three-math-extensions](../../README.md) / [Exports](../modules.md) / Vec3
2
+
3
+ # Class: Vec3
4
+
5
+ Vec3 represents a 3D vector. It extends `Vector3` from the `threejs` library.
6
+
7
+ ## Hierarchy
8
+
9
+ - `Vector3`
10
+
11
+ ↳ **`Vec3`**
12
+
13
+ ## Table of contents
14
+
15
+ ### Constructors
16
+
17
+ - [constructor](Vec3.md#constructor)
18
+
19
+ ### Methods
20
+
21
+ - [addX](Vec3.md#addx)
22
+ - [addY](Vec3.md#addy)
23
+ - [addZ](Vec3.md#addz)
24
+ - [clone](Vec3.md#clone)
25
+ - [closest](Vec3.md#closest)
26
+ - [horizontalDistanceTo](Vec3.md#horizontaldistanceto)
27
+ - [isNear](Vec3.md#isnear)
28
+ - [moveHalfWayTowards](Vec3.md#movehalfwaytowards)
29
+ - [moveTowards](Vec3.md#movetowards)
30
+ - [onPlan](Vec3.md#onplan)
31
+ - [toPointWithFlippedYZ](Vec3.md#topointwithflippedyz)
32
+ - [fromPoint](Vec3.md#frompoint)
33
+ - [fromPoints](Vec3.md#frompoints)
34
+
35
+ ## Constructors
36
+
37
+ ### constructor
38
+
39
+ • **new Vec3**(`x?`, `y?`, `z?`): [`Vec3`](Vec3.md)
40
+
41
+ #### Parameters
42
+
43
+ | Name | Type |
44
+ | :------ | :------ |
45
+ | `x?` | `number` |
46
+ | `y?` | `number` |
47
+ | `z?` | `number` |
48
+
49
+ #### Returns
50
+
51
+ [`Vec3`](Vec3.md)
52
+
53
+ #### Inherited from
54
+
55
+ Vector3.constructor
56
+
57
+ #### Defined in
58
+
59
+ node_modules/@types/three/src/math/Vector3.d.ts:27
60
+
61
+ ## Methods
62
+
63
+ ### addX
64
+
65
+ ▸ **addX**(`x`): [`Vec3`](Vec3.md)
66
+
67
+ Adds x amount to this Vec3 instance and return this
68
+
69
+ #### Parameters
70
+
71
+ | Name | Type |
72
+ | :------ | :------ |
73
+ | `x` | `number` |
74
+
75
+ #### Returns
76
+
77
+ [`Vec3`](Vec3.md)
78
+
79
+ #### Defined in
80
+
81
+ [src/Vec3.ts:73](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L73)
82
+
83
+ ___
84
+
85
+ ### addY
86
+
87
+ ▸ **addY**(`y`): [`Vec3`](Vec3.md)
88
+
89
+ Adds y amount to this Vec3 instance and return this
90
+
91
+ #### Parameters
92
+
93
+ | Name | Type |
94
+ | :------ | :------ |
95
+ | `y` | `number` |
96
+
97
+ #### Returns
98
+
99
+ [`Vec3`](Vec3.md)
100
+
101
+ #### Defined in
102
+
103
+ [src/Vec3.ts:64](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L64)
104
+
105
+ ___
106
+
107
+ ### addZ
108
+
109
+ ▸ **addZ**(`z`): [`Vec3`](Vec3.md)
110
+
111
+ Adds z amount to this Vec3 instance and return this
112
+
113
+ #### Parameters
114
+
115
+ | Name | Type |
116
+ | :------ | :------ |
117
+ | `z` | `number` |
118
+
119
+ #### Returns
120
+
121
+ [`Vec3`](Vec3.md)
122
+
123
+ #### Defined in
124
+
125
+ [src/Vec3.ts:82](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L82)
126
+
127
+ ___
128
+
129
+ ### clone
130
+
131
+ ▸ **clone**(): [`Vec3`](Vec3.md)
132
+
133
+ #### Returns
134
+
135
+ [`Vec3`](Vec3.md)
136
+
137
+ #### Overrides
138
+
139
+ Vector3.clone
140
+
141
+ #### Defined in
142
+
143
+ [src/Vec3.ts:131](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L131)
144
+
145
+ ___
146
+
147
+ ### closest
148
+
149
+ ▸ **closest**(`...points`): [`Vec3`](Vec3.md)
150
+
151
+ Returns a clone of the point closest to this from the given points.
152
+
153
+ #### Parameters
154
+
155
+ | Name | Type |
156
+ | :------ | :------ |
157
+ | `...points` | `Vector3`[] |
158
+
159
+ #### Returns
160
+
161
+ [`Vec3`](Vec3.md)
162
+
163
+ #### Defined in
164
+
165
+ [src/Vec3.ts:91](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L91)
166
+
167
+ ___
168
+
169
+ ### horizontalDistanceTo
170
+
171
+ ▸ **horizontalDistanceTo**(`point`): `number`
172
+
173
+ Get distance to another vector while ignoring the y-axis.
174
+
175
+ #### Parameters
176
+
177
+ | Name | Type |
178
+ | :------ | :------ |
179
+ | `point` | `Vector3` |
180
+
181
+ #### Returns
182
+
183
+ `number`
184
+
185
+ #### Defined in
186
+
187
+ [src/Vec3.ts:115](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L115)
188
+
189
+ ___
190
+
191
+ ### isNear
192
+
193
+ ▸ **isNear**(`v`, `maxDistance?`): `boolean`
194
+
195
+ Determines if this Vec2 instance is near the target Vec2.
196
+ maxDistance is the maximum distance between the two vectors within which they are considered `near`.
197
+
198
+ #### Parameters
199
+
200
+ | Name | Type | Default value |
201
+ | :------ | :------ | :------ |
202
+ | `v` | `Vector3` | `undefined` |
203
+ | `maxDistance` | `number` | `undefined` |
204
+
205
+ #### Returns
206
+
207
+ `boolean`
208
+
209
+ #### Defined in
210
+
211
+ [src/Vec3.ts:123](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L123)
212
+
213
+ ___
214
+
215
+ ### moveHalfWayTowards
216
+
217
+ ▸ **moveHalfWayTowards**(`target`): [`Vec3`](Vec3.md)
218
+
219
+ Moves this Vec3 instance halfway towards the target Vec3 by the given amount.
220
+
221
+ #### Parameters
222
+
223
+ | Name | Type | Description |
224
+ | :------ | :------ | :------ |
225
+ | `target` | `Vector3` | The target Vec3. |
226
+
227
+ #### Returns
228
+
229
+ [`Vec3`](Vec3.md)
230
+
231
+ This Vec3 instance.
232
+
233
+ #### Defined in
234
+
235
+ [src/Vec3.ts:51](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L51)
236
+
237
+ ___
238
+
239
+ ### moveTowards
240
+
241
+ ▸ **moveTowards**(`target`, `amount`): [`Vec3`](Vec3.md)
242
+
243
+ Moves this Vec3 instance towards the target Vec3 by the given amount.
244
+
245
+ #### Parameters
246
+
247
+ | Name | Type | Description |
248
+ | :------ | :------ | :------ |
249
+ | `target` | `Vector3` | The target Vec3. |
250
+ | `amount` | `number` | The distance to move. |
251
+
252
+ #### Returns
253
+
254
+ [`Vec3`](Vec3.md)
255
+
256
+ This Vec3 instance.
257
+
258
+ #### Defined in
259
+
260
+ [src/Vec3.ts:35](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L35)
261
+
262
+ ___
263
+
264
+ ### onPlan
265
+
266
+ ▸ **onPlan**(): [`Vec2`](Vec2.md)
267
+
268
+ Projects this Vec3 instance onto 2d plan. Vec3.z becomes Vec2.y and Vec3.y is ignored.
269
+
270
+ #### Returns
271
+
272
+ [`Vec2`](Vec2.md)
273
+
274
+ #### Defined in
275
+
276
+ [src/Vec3.ts:107](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L107)
277
+
278
+ ___
279
+
280
+ ### toPointWithFlippedYZ
281
+
282
+ ▸ **toPointWithFlippedYZ**(): [`Vec3`](Vec3.md)
283
+
284
+ Returns a clone of this Vec3 instance with y and z swapped.
285
+
286
+ #### Returns
287
+
288
+ [`Vec3`](Vec3.md)
289
+
290
+ #### Defined in
291
+
292
+ [src/Vec3.ts:100](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L100)
293
+
294
+ ___
295
+
296
+ ### fromPoint
297
+
298
+ ▸ **fromPoint**(`point`): [`Vec3`](Vec3.md)
299
+
300
+ Creates a new Vec3 instance from an {x, y, z} object.
301
+
302
+ #### Parameters
303
+
304
+ | Name | Type | Description |
305
+ | :------ | :------ | :------ |
306
+ | `point` | [`Point3`](../interfaces/Point3.md) | The {x, y, z} instance. |
307
+
308
+ #### Returns
309
+
310
+ [`Vec3`](Vec3.md)
311
+
312
+ A new Vec3 instance.
313
+
314
+ #### Defined in
315
+
316
+ [src/Vec3.ts:17](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L17)
317
+
318
+ ___
319
+
320
+ ### fromPoints
321
+
322
+ ▸ **fromPoints**(`...points`): [`Vec3`](Vec3.md)[]
323
+
324
+ Creates a new Vec3[] array from arguments of {x, y, z} objects.
325
+
326
+ #### Parameters
327
+
328
+ | Name | Type | Description |
329
+ | :------ | :------ | :------ |
330
+ | `...points` | [`Point3`](../interfaces/Point3.md)[] | The ...{x, y, z} instances. |
331
+
332
+ #### Returns
333
+
334
+ [`Vec3`](Vec3.md)[]
335
+
336
+ #### Defined in
337
+
338
+ [src/Vec3.ts:25](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec3.ts#L25)