@jscad/modeling 2.12.5 → 3.0.1-alpha.0

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 (1206) hide show
  1. package/CHANGELOG.md +49 -321
  2. package/LICENSE +1 -1
  3. package/README.md +5 -3
  4. package/dist/jscad-modeling.es.js +7 -0
  5. package/dist/jscad-modeling.min.js +7 -1214
  6. package/global.d.ts +15 -0
  7. package/package.json +22 -19
  8. package/rollup.config.js +21 -0
  9. package/src/colors/colorNameToRgb.d.ts +2 -4
  10. package/src/colors/colorNameToRgb.js +4 -6
  11. package/src/colors/colorNameToRgb.test.js +2 -2
  12. package/src/colors/colorize.d.ts +6 -8
  13. package/src/colors/colorize.js +20 -26
  14. package/src/colors/colorize.test.js +14 -16
  15. package/src/colors/cssColors.d.ts +1 -1
  16. package/src/colors/cssColors.js +2 -4
  17. package/src/colors/hexToRgb.d.ts +2 -4
  18. package/src/colors/hexToRgb.js +3 -5
  19. package/src/colors/hexToRgb.test.js +2 -2
  20. package/src/colors/hslToRgb.d.ts +5 -7
  21. package/src/colors/hslToRgb.js +4 -6
  22. package/src/colors/hslToRgb.test.js +2 -2
  23. package/src/colors/hsvToRgb.d.ts +5 -7
  24. package/src/colors/hsvToRgb.js +3 -5
  25. package/src/colors/hsvToRgb.test.js +2 -2
  26. package/src/colors/hueToColorComponent.d.ts +1 -3
  27. package/src/colors/hueToColorComponent.js +2 -4
  28. package/src/colors/index.d.ts +11 -12
  29. package/src/colors/index.js +12 -13
  30. package/src/colors/rgbToHex.d.ts +3 -5
  31. package/src/colors/rgbToHex.js +2 -4
  32. package/src/colors/rgbToHex.test.js +2 -2
  33. package/src/colors/rgbToHsl.d.ts +5 -7
  34. package/src/colors/rgbToHsl.js +2 -4
  35. package/src/colors/rgbToHsl.test.js +2 -2
  36. package/src/colors/rgbToHsv.d.ts +5 -7
  37. package/src/colors/rgbToHsv.js +2 -4
  38. package/src/colors/rgbToHsv.test.js +2 -2
  39. package/src/connectors/create.js +3 -5
  40. package/src/connectors/create.test.js +3 -3
  41. package/src/connectors/extends.js +7 -8
  42. package/src/connectors/fromPointAxisNormal.js +6 -8
  43. package/src/connectors/fromPointAxisNormal.test.js +3 -3
  44. package/src/connectors/index.js +7 -9
  45. package/src/connectors/normalize.js +7 -9
  46. package/src/connectors/toString.js +1 -3
  47. package/src/connectors/transform.js +10 -12
  48. package/src/connectors/transform.test.js +3 -3
  49. package/src/connectors/transformationBetween.js +25 -27
  50. package/src/connectors/transformationBetween.test.js +13 -13
  51. package/src/curves/bezier/arcLengthToT.d.ts +2 -4
  52. package/src/curves/bezier/arcLengthToT.js +6 -8
  53. package/src/curves/bezier/arcLengthToT.test.js +13 -13
  54. package/src/curves/bezier/create.d.ts +2 -4
  55. package/src/curves/bezier/create.js +3 -5
  56. package/src/curves/bezier/create.test.js +2 -2
  57. package/src/curves/bezier/index.d.ts +7 -8
  58. package/src/curves/bezier/index.js +9 -8
  59. package/src/curves/bezier/length.d.ts +2 -4
  60. package/src/curves/bezier/length.js +4 -6
  61. package/src/curves/bezier/length.test.js +12 -12
  62. package/src/curves/bezier/lengths.d.ts +2 -4
  63. package/src/curves/bezier/lengths.js +5 -7
  64. package/src/curves/bezier/lengths.test.js +12 -12
  65. package/src/curves/bezier/tangentAt.d.ts +2 -4
  66. package/src/curves/bezier/tangentAt.js +2 -4
  67. package/src/curves/bezier/tangentAt.test.js +2 -2
  68. package/src/curves/bezier/type.d.ts +1 -3
  69. package/src/curves/bezier/valueAt.d.ts +2 -4
  70. package/src/curves/bezier/valueAt.js +2 -4
  71. package/src/curves/bezier/valueAt.test.js +2 -2
  72. package/src/curves/index.d.ts +1 -3
  73. package/src/curves/index.js +4 -5
  74. package/src/geometries/geom2/applyTransforms.js +7 -13
  75. package/src/geometries/geom2/applyTransforms.test.js +6 -6
  76. package/src/geometries/geom2/clone.d.ts +2 -4
  77. package/src/geometries/geom2/clone.js +3 -5
  78. package/src/geometries/geom2/clone.test.js +5 -5
  79. package/src/geometries/geom2/create.d.ts +3 -5
  80. package/src/geometries/geom2/create.js +19 -19
  81. package/src/geometries/geom2/create.test.js +6 -6
  82. package/src/geometries/geom2/fromCompactBinary.d.ts +2 -4
  83. package/src/geometries/geom2/fromCompactBinary.js +19 -11
  84. package/src/geometries/geom2/fromSides.d.ts +4 -0
  85. package/src/geometries/geom2/fromSides.js +115 -0
  86. package/src/geometries/geom2/fromToCompactBinary.test.js +16 -38
  87. package/src/geometries/geom2/index.d.ts +14 -15
  88. package/src/geometries/geom2/index.js +17 -24
  89. package/src/geometries/geom2/isA.d.ts +2 -4
  90. package/src/geometries/geom2/isA.js +4 -6
  91. package/src/geometries/geom2/isA.test.js +5 -3
  92. package/src/geometries/geom2/reverse.d.ts +2 -4
  93. package/src/geometries/geom2/reverse.js +12 -14
  94. package/src/geometries/geom2/reverse.test.js +29 -9
  95. package/src/geometries/geom2/toCompactBinary.d.ts +2 -4
  96. package/src/geometries/geom2/toCompactBinary.js +18 -15
  97. package/src/geometries/geom2/toOutlines.d.ts +3 -5
  98. package/src/geometries/geom2/toOutlines.js +3 -109
  99. package/src/geometries/geom2/toOutlines.test.js +34 -61
  100. package/src/geometries/geom2/toPoints.d.ts +3 -5
  101. package/src/geometries/geom2/toPoints.js +10 -13
  102. package/src/geometries/geom2/toPoints.test.js +8 -8
  103. package/src/geometries/geom2/toSides.d.ts +3 -5
  104. package/src/geometries/geom2/toSides.js +13 -6
  105. package/src/geometries/geom2/toString.d.ts +2 -4
  106. package/src/geometries/geom2/toString.js +9 -11
  107. package/src/geometries/geom2/toString.test.js +17 -0
  108. package/src/geometries/geom2/transform.d.ts +3 -5
  109. package/src/geometries/geom2/transform.js +9 -11
  110. package/src/geometries/geom2/transform.test.js +28 -29
  111. package/src/geometries/geom2/type.d.ts +5 -7
  112. package/src/geometries/geom2/validate.d.ts +1 -3
  113. package/src/geometries/geom2/validate.js +34 -13
  114. package/src/geometries/geom2/validate.test.js +39 -0
  115. package/src/geometries/geom3/applyTransforms.js +5 -7
  116. package/src/geometries/geom3/applyTransforms.test.js +6 -6
  117. package/src/geometries/geom3/clone.d.ts +2 -4
  118. package/src/geometries/geom3/clone.js +3 -5
  119. package/src/geometries/geom3/clone.test.js +5 -5
  120. package/src/geometries/geom3/create.d.ts +3 -5
  121. package/src/geometries/geom3/create.js +17 -8
  122. package/src/geometries/geom3/create.test.js +5 -5
  123. package/src/geometries/geom3/fromCompactBinary.d.ts +2 -4
  124. package/src/geometries/geom3/fromCompactBinary.js +6 -8
  125. package/src/geometries/geom3/fromPoints.d.ts +3 -5
  126. package/src/geometries/geom3/fromPoints.js +11 -19
  127. package/src/geometries/geom3/fromPoints.test.js +6 -6
  128. package/src/geometries/geom3/fromPointsConvex.d.ts +3 -5
  129. package/src/geometries/geom3/fromPointsConvex.js +6 -7
  130. package/src/geometries/geom3/fromPointsConvex.test.js +6 -5
  131. package/src/geometries/geom3/fromToCompactBinary.test.js +7 -7
  132. package/src/geometries/geom3/index.d.ts +14 -15
  133. package/src/geometries/geom3/index.js +22 -30
  134. package/src/geometries/geom3/invert.d.ts +2 -4
  135. package/src/geometries/geom3/invert.js +8 -10
  136. package/src/geometries/geom3/invert.test.js +5 -5
  137. package/src/geometries/geom3/isA.d.ts +2 -4
  138. package/src/geometries/geom3/isA.js +2 -4
  139. package/src/geometries/geom3/isA.test.js +2 -2
  140. package/src/geometries/geom3/toCompactBinary.d.ts +2 -4
  141. package/src/geometries/geom3/toCompactBinary.js +10 -12
  142. package/src/geometries/geom3/toPoints.d.ts +3 -5
  143. package/src/geometries/geom3/toPoints.js +5 -8
  144. package/src/geometries/geom3/toPoints.test.js +9 -9
  145. package/src/geometries/geom3/toPolygons.d.ts +3 -5
  146. package/src/geometries/geom3/toPolygons.js +4 -6
  147. package/src/geometries/geom3/toString.d.ts +2 -4
  148. package/src/geometries/geom3/toString.js +5 -7
  149. package/src/geometries/geom3/toString.test.js +17 -0
  150. package/src/geometries/geom3/transform.d.ts +3 -5
  151. package/src/geometries/geom3/transform.js +6 -8
  152. package/src/geometries/geom3/transform.test.js +6 -6
  153. package/src/geometries/geom3/type.d.ts +4 -6
  154. package/src/geometries/geom3/validate.d.ts +1 -3
  155. package/src/geometries/geom3/validate.js +5 -6
  156. package/src/geometries/geom3/validate.test.js +26 -0
  157. package/src/geometries/index.d.ts +6 -7
  158. package/src/geometries/index.js +10 -10
  159. package/src/geometries/path2/appendArc.d.ts +4 -6
  160. package/src/geometries/path2/appendArc.js +58 -60
  161. package/src/geometries/path2/appendArc.test.js +8 -7
  162. package/src/geometries/path2/appendBezier.d.ts +3 -5
  163. package/src/geometries/path2/appendBezier.js +41 -43
  164. package/src/geometries/path2/appendBezier.test.js +3 -3
  165. package/src/geometries/path2/appendPoints.d.ts +3 -5
  166. package/src/geometries/path2/appendPoints.js +6 -8
  167. package/src/geometries/path2/appendPoints.test.js +2 -2
  168. package/src/geometries/path2/applyTransforms.js +3 -5
  169. package/src/geometries/path2/applyTransforms.test.js +4 -4
  170. package/src/geometries/path2/clone.d.ts +2 -4
  171. package/src/geometries/path2/clone.js +3 -5
  172. package/src/geometries/path2/close.d.ts +2 -4
  173. package/src/geometries/path2/close.js +6 -8
  174. package/src/geometries/path2/close.test.js +2 -2
  175. package/src/geometries/path2/concat.d.ts +2 -4
  176. package/src/geometries/path2/concat.js +11 -13
  177. package/src/geometries/path2/concat.test.js +2 -2
  178. package/src/geometries/path2/create.d.ts +3 -5
  179. package/src/geometries/path2/create.js +12 -9
  180. package/src/geometries/path2/create.test.js +2 -2
  181. package/src/geometries/path2/equals.d.ts +2 -4
  182. package/src/geometries/path2/equals.js +9 -11
  183. package/src/geometries/path2/equals.test.js +2 -2
  184. package/src/geometries/path2/fromCompactBinary.d.ts +2 -4
  185. package/src/geometries/path2/fromCompactBinary.js +5 -7
  186. package/src/geometries/path2/fromPoints.d.ts +3 -5
  187. package/src/geometries/path2/fromPoints.js +9 -11
  188. package/src/geometries/path2/fromPoints.test.js +3 -3
  189. package/src/geometries/path2/fromToCompactBinary.test.js +2 -2
  190. package/src/geometries/path2/index.d.ts +18 -19
  191. package/src/geometries/path2/index.js +19 -28
  192. package/src/geometries/path2/isA.d.ts +2 -4
  193. package/src/geometries/path2/isA.js +2 -4
  194. package/src/geometries/path2/isA.test.js +2 -2
  195. package/src/geometries/path2/reverse.d.ts +2 -4
  196. package/src/geometries/path2/reverse.js +5 -7
  197. package/src/geometries/path2/reverse.test.js +2 -2
  198. package/src/geometries/path2/toCompactBinary.d.ts +2 -4
  199. package/src/geometries/path2/toCompactBinary.js +2 -4
  200. package/src/geometries/path2/toPoints.d.ts +3 -5
  201. package/src/geometries/path2/toPoints.js +4 -6
  202. package/src/geometries/path2/toPoints.test.js +3 -3
  203. package/src/geometries/path2/toString.d.ts +2 -4
  204. package/src/geometries/path2/toString.js +5 -7
  205. package/src/geometries/path2/transform.d.ts +3 -5
  206. package/src/geometries/path2/transform.js +6 -8
  207. package/src/geometries/path2/transform.test.js +5 -5
  208. package/src/geometries/path2/type.d.ts +4 -6
  209. package/src/geometries/path2/validate.d.ts +1 -3
  210. package/src/geometries/path2/validate.js +6 -7
  211. package/src/geometries/poly2/arePointsInside.d.ts +3 -5
  212. package/src/geometries/poly2/arePointsInside.js +21 -24
  213. package/src/geometries/poly2/arePointsInside.test.js +2 -2
  214. package/src/geometries/poly2/clone.d.ts +3 -0
  215. package/src/geometries/poly2/clone.js +8 -0
  216. package/src/geometries/poly2/clone.test.js +17 -0
  217. package/src/geometries/poly2/create.d.ts +3 -5
  218. package/src/geometries/poly2/create.js +11 -12
  219. package/src/geometries/poly2/create.test.js +4 -4
  220. package/src/geometries/poly2/index.d.ts +14 -6
  221. package/src/geometries/poly2/index.js +16 -11
  222. package/src/geometries/poly2/isA.d.ts +3 -0
  223. package/src/geometries/poly2/isA.js +16 -0
  224. package/src/geometries/poly2/isA.test.js +30 -0
  225. package/src/geometries/poly2/isConvex.d.ts +3 -0
  226. package/src/geometries/poly2/isConvex.js +37 -0
  227. package/src/geometries/poly2/isConvex.test.js +27 -0
  228. package/src/geometries/poly2/isSimple.d.ts +3 -0
  229. package/src/geometries/poly2/isSimple.js +38 -0
  230. package/src/geometries/poly2/isSimple.test.js +31 -0
  231. package/src/geometries/poly2/measureArea.d.ts +2 -4
  232. package/src/geometries/poly2/measureArea.js +5 -7
  233. package/src/geometries/poly2/measureArea.test.js +2 -2
  234. package/src/geometries/poly2/measureBoundingBox.d.ts +4 -0
  235. package/src/geometries/poly2/measureBoundingBox.js +18 -0
  236. package/src/geometries/poly2/measureBoundingBox.test.js +71 -0
  237. package/src/geometries/poly2/reverse.d.ts +3 -0
  238. package/src/geometries/poly2/reverse.js +13 -0
  239. package/src/geometries/poly2/reverse.test.js +27 -0
  240. package/src/geometries/poly2/toPoints.d.ts +4 -0
  241. package/src/geometries/poly2/toPoints.js +8 -0
  242. package/src/geometries/poly2/toPoints.test.js +18 -0
  243. package/src/geometries/poly2/toString.d.ts +3 -0
  244. package/src/geometries/poly2/toString.js +9 -0
  245. package/src/geometries/poly2/toString.test.js +10 -0
  246. package/src/geometries/poly2/transform.d.ts +4 -0
  247. package/src/geometries/poly2/transform.js +20 -0
  248. package/src/geometries/poly2/transform.test.js +62 -0
  249. package/src/geometries/poly2/type.d.ts +5 -5
  250. package/src/geometries/poly2/validate.d.ts +2 -0
  251. package/src/geometries/poly2/validate.js +46 -0
  252. package/src/geometries/poly2/validate.test.js +31 -0
  253. package/src/geometries/poly3/clone.d.ts +3 -5
  254. package/src/geometries/poly3/clone.js +6 -8
  255. package/src/geometries/poly3/clone.test.js +6 -5
  256. package/src/geometries/poly3/create.d.ts +3 -5
  257. package/src/geometries/poly3/create.js +6 -6
  258. package/src/geometries/poly3/create.test.js +15 -3
  259. package/src/geometries/poly3/fromVerticesAndPlane.d.ts +5 -0
  260. package/src/geometries/poly3/{fromPointsAndPlane.js → fromVerticesAndPlane.js} +5 -7
  261. package/src/geometries/poly3/index.d.ts +16 -18
  262. package/src/geometries/poly3/index.js +17 -22
  263. package/src/geometries/poly3/invert.d.ts +2 -4
  264. package/src/geometries/poly3/invert.js +6 -7
  265. package/src/geometries/poly3/invert.test.js +5 -5
  266. package/src/geometries/poly3/isA.d.ts +2 -4
  267. package/src/geometries/poly3/isA.js +2 -4
  268. package/src/geometries/poly3/isA.test.js +3 -3
  269. package/src/geometries/poly3/isConvex.d.ts +2 -4
  270. package/src/geometries/poly3/isConvex.js +21 -23
  271. package/src/geometries/poly3/isConvex.test.js +9 -9
  272. package/src/geometries/poly3/measureArea.d.ts +2 -4
  273. package/src/geometries/poly3/measureArea.js +4 -6
  274. package/src/geometries/poly3/measureArea.test.js +12 -11
  275. package/src/geometries/poly3/measureBoundingBox.d.ts +3 -5
  276. package/src/geometries/poly3/measureBoundingBox.js +6 -8
  277. package/src/geometries/poly3/measureBoundingBox.test.js +9 -8
  278. package/src/geometries/poly3/measureBoundingSphere.d.ts +3 -5
  279. package/src/geometries/poly3/measureBoundingSphere.js +4 -6
  280. package/src/geometries/poly3/measureBoundingSphere.test.js +8 -7
  281. package/src/geometries/poly3/measureSignedVolume.d.ts +2 -4
  282. package/src/geometries/poly3/measureSignedVolume.js +4 -6
  283. package/src/geometries/poly3/measureSignedVolume.test.js +8 -8
  284. package/src/geometries/poly3/plane.d.ts +3 -5
  285. package/src/geometries/poly3/plane.js +2 -4
  286. package/src/geometries/poly3/toString.d.ts +2 -4
  287. package/src/geometries/poly3/toString.js +4 -12
  288. package/src/geometries/poly3/toString.test.js +10 -0
  289. package/src/geometries/poly3/toVertices.d.ts +4 -0
  290. package/src/geometries/poly3/toVertices.js +8 -0
  291. package/src/geometries/poly3/transform.d.ts +3 -5
  292. package/src/geometries/poly3/transform.js +7 -9
  293. package/src/geometries/poly3/transform.test.js +7 -7
  294. package/src/geometries/poly3/type.d.ts +6 -6
  295. package/src/geometries/poly3/validate.d.ts +1 -3
  296. package/src/geometries/poly3/validate.js +14 -15
  297. package/src/geometries/slice/calculatePlane.d.ts +5 -0
  298. package/src/geometries/slice/calculatePlane.js +65 -0
  299. package/src/geometries/slice/calculatePlane.test.js +43 -0
  300. package/src/geometries/slice/clone.d.ts +3 -0
  301. package/src/geometries/slice/clone.js +9 -0
  302. package/src/geometries/slice/clone.test.js +14 -0
  303. package/src/geometries/slice/create.d.ts +4 -0
  304. package/src/geometries/slice/create.js +18 -0
  305. package/src/{operations/extrusions → geometries}/slice/create.test.js +3 -3
  306. package/src/{operations/extrusions → geometries/slice}/earcut/assignHoles.js +6 -8
  307. package/src/geometries/slice/earcut/assignHoles.test.js +75 -0
  308. package/src/{operations/extrusions → geometries/slice}/earcut/eliminateHoles.js +3 -5
  309. package/src/{operations/extrusions → geometries/slice}/earcut/index.js +7 -8
  310. package/src/{operations/extrusions → geometries/slice}/earcut/linkedList.js +3 -6
  311. package/src/{operations/extrusions → geometries/slice}/earcut/linkedListSort.js +1 -4
  312. package/src/{operations/extrusions → geometries/slice}/earcut/linkedPolygon.js +8 -10
  313. package/src/{operations/extrusions → geometries/slice}/earcut/polygonHierarchy.js +13 -13
  314. package/src/{operations/extrusions → geometries/slice}/earcut/triangle.js +2 -5
  315. package/src/geometries/slice/equals.d.ts +3 -0
  316. package/src/geometries/slice/equals.js +27 -0
  317. package/src/geometries/slice/equals.test.js +17 -0
  318. package/src/geometries/slice/fromGeom2.d.ts +5 -0
  319. package/src/geometries/slice/fromGeom2.js +17 -0
  320. package/src/geometries/slice/fromVertices.d.ts +7 -0
  321. package/src/geometries/slice/fromVertices.js +34 -0
  322. package/src/geometries/slice/fromVertices.test.js +11 -0
  323. package/src/geometries/slice/index.d.ts +16 -0
  324. package/src/geometries/slice/index.js +23 -0
  325. package/src/geometries/slice/isA.d.ts +3 -0
  326. package/src/geometries/slice/isA.js +16 -0
  327. package/src/{operations/extrusions → geometries}/slice/isA.test.js +3 -3
  328. package/src/geometries/slice/reverse.d.ts +3 -0
  329. package/src/geometries/slice/reverse.js +14 -0
  330. package/src/geometries/slice/toEdges.d.ts +3 -0
  331. package/src/geometries/slice/toEdges.js +20 -0
  332. package/src/geometries/slice/toPolygons.d.ts +5 -0
  333. package/src/{operations/extrusions → geometries}/slice/toPolygons.js +9 -10
  334. package/src/geometries/slice/toString.d.ts +3 -0
  335. package/src/geometries/slice/toString.js +16 -0
  336. package/src/geometries/slice/toString.test.js +17 -0
  337. package/src/geometries/slice/toVertices.d.ts +4 -0
  338. package/src/geometries/slice/toVertices.js +19 -0
  339. package/src/geometries/slice/transform.d.ts +5 -0
  340. package/src/geometries/slice/transform.js +19 -0
  341. package/src/{operations/extrusions → geometries}/slice/transform.test.js +11 -21
  342. package/src/geometries/slice/type.d.ts +7 -0
  343. package/src/geometries/slice/validate.d.ts +1 -0
  344. package/src/geometries/slice/validate.js +48 -0
  345. package/src/geometries/slice/validate.test.js +36 -0
  346. package/src/geometries/types.d.ts +12 -10
  347. package/src/index.d.ts +2 -4
  348. package/src/index.js +14 -16
  349. package/src/index.test-d.ts +3 -3
  350. package/src/maths/constants.d.ts +1 -1
  351. package/src/maths/constants.js +10 -20
  352. package/src/maths/index.d.ts +9 -11
  353. package/src/maths/index.js +11 -12
  354. package/src/maths/line2/clone.d.ts +2 -4
  355. package/src/maths/line2/clone.js +4 -6
  356. package/src/maths/line2/clone.test.js +4 -3
  357. package/src/maths/line2/closestPoint.d.ts +3 -5
  358. package/src/maths/line2/closestPoint.js +7 -9
  359. package/src/maths/line2/closestPoint.test.js +4 -3
  360. package/src/maths/line2/copy.d.ts +2 -4
  361. package/src/maths/line2/copy.js +4 -6
  362. package/src/maths/line2/copy.test.js +4 -3
  363. package/src/maths/line2/create.d.ts +2 -4
  364. package/src/maths/line2/create.js +5 -8
  365. package/src/maths/line2/create.test.js +3 -3
  366. package/src/maths/line2/direction.d.ts +3 -5
  367. package/src/maths/line2/direction.js +4 -6
  368. package/src/maths/line2/direction.test.js +3 -3
  369. package/src/maths/line2/distanceToPoint.d.ts +3 -5
  370. package/src/maths/line2/distanceToPoint.js +5 -7
  371. package/src/maths/line2/distanceToPoint.test.js +6 -4
  372. package/src/maths/line2/equals.d.ts +2 -4
  373. package/src/maths/line2/equals.js +4 -6
  374. package/src/maths/line2/equals.test.js +3 -2
  375. package/src/maths/line2/fromPoints.d.ts +3 -5
  376. package/src/maths/line2/fromPoints.js +6 -8
  377. package/src/maths/line2/fromPoints.test.js +4 -3
  378. package/src/maths/line2/fromValues.d.ts +2 -4
  379. package/src/maths/line2/fromValues.js +6 -8
  380. package/src/maths/line2/fromValues.test.js +4 -3
  381. package/src/maths/line2/index.d.ts +16 -17
  382. package/src/maths/line2/index.js +16 -18
  383. package/src/maths/line2/intersectPointOfLines.d.ts +3 -5
  384. package/src/maths/line2/intersectPointOfLines.js +7 -8
  385. package/src/maths/line2/intersectPointOfLines.test.js +4 -3
  386. package/src/maths/line2/origin.d.ts +3 -5
  387. package/src/maths/line2/origin.js +4 -6
  388. package/src/maths/line2/origin.test.js +4 -3
  389. package/src/maths/line2/reverse.d.ts +2 -4
  390. package/src/maths/line2/reverse.js +7 -9
  391. package/src/maths/line2/reverse.test.js +4 -3
  392. package/src/maths/line2/toString.d.ts +2 -4
  393. package/src/maths/line2/toString.js +3 -5
  394. package/src/maths/line2/transform.d.ts +3 -5
  395. package/src/maths/line2/transform.js +9 -11
  396. package/src/maths/line2/transform.test.js +4 -3
  397. package/src/maths/line2/type.d.ts +1 -3
  398. package/src/maths/line2/xAtY.d.ts +2 -4
  399. package/src/maths/line2/xAtY.js +5 -7
  400. package/src/maths/line2/xAtY.test.js +6 -4
  401. package/src/maths/line3/clone.d.ts +2 -4
  402. package/src/maths/line3/clone.js +5 -7
  403. package/src/maths/line3/clone.test.js +4 -3
  404. package/src/maths/line3/closestPoint.d.ts +3 -5
  405. package/src/maths/line3/closestPoint.js +12 -14
  406. package/src/maths/line3/closestPoint.test.js +4 -3
  407. package/src/maths/line3/copy.d.ts +2 -4
  408. package/src/maths/line3/copy.js +5 -7
  409. package/src/maths/line3/copy.test.js +4 -3
  410. package/src/maths/line3/create.d.ts +2 -4
  411. package/src/maths/line3/create.js +4 -7
  412. package/src/maths/line3/create.test.js +3 -3
  413. package/src/maths/line3/direction.d.ts +3 -5
  414. package/src/maths/line3/direction.js +3 -5
  415. package/src/maths/line3/direction.test.js +4 -3
  416. package/src/maths/line3/distanceToPoint.d.ts +3 -5
  417. package/src/maths/line3/distanceToPoint.js +8 -10
  418. package/src/maths/line3/distanceToPoint.test.js +6 -4
  419. package/src/maths/line3/equals.d.ts +2 -4
  420. package/src/maths/line3/equals.js +4 -6
  421. package/src/maths/line3/equals.test.js +3 -2
  422. package/src/maths/line3/fromPlanes.d.ts +3 -5
  423. package/src/maths/line3/fromPlanes.js +14 -17
  424. package/src/maths/line3/fromPlanes.test.js +4 -4
  425. package/src/maths/line3/fromPointAndDirection.d.ts +3 -5
  426. package/src/maths/line3/fromPointAndDirection.js +6 -8
  427. package/src/maths/line3/fromPointAndDirection.test.js +4 -3
  428. package/src/maths/line3/fromPoints.d.ts +3 -5
  429. package/src/maths/line3/fromPoints.js +7 -9
  430. package/src/maths/line3/fromPoints.test.js +4 -3
  431. package/src/maths/line3/index.d.ts +16 -17
  432. package/src/maths/line3/index.js +16 -18
  433. package/src/maths/line3/intersectPointOfLineAndPlane.d.ts +4 -6
  434. package/src/maths/line3/intersectPointOfLineAndPlane.js +10 -13
  435. package/src/maths/line3/intersectPointOfLineAndPlane.test.js +4 -4
  436. package/src/maths/line3/origin.d.ts +3 -5
  437. package/src/maths/line3/origin.js +3 -5
  438. package/src/maths/line3/origin.test.js +4 -3
  439. package/src/maths/line3/reverse.d.ts +2 -4
  440. package/src/maths/line3/reverse.js +6 -8
  441. package/src/maths/line3/reverse.test.js +4 -3
  442. package/src/maths/line3/toString.d.ts +2 -4
  443. package/src/maths/line3/toString.js +3 -5
  444. package/src/maths/line3/transform.d.ts +3 -5
  445. package/src/maths/line3/transform.js +10 -12
  446. package/src/maths/line3/transform.test.js +4 -3
  447. package/src/maths/line3/type.d.ts +2 -4
  448. package/src/maths/mat4/add.d.ts +2 -4
  449. package/src/maths/mat4/add.js +5 -7
  450. package/src/maths/mat4/add.test.js +4 -3
  451. package/src/maths/mat4/clone.d.ts +2 -4
  452. package/src/maths/mat4/clone.js +4 -6
  453. package/src/maths/mat4/clone.test.js +4 -3
  454. package/src/maths/mat4/copy.d.ts +2 -4
  455. package/src/maths/mat4/copy.js +4 -6
  456. package/src/maths/mat4/copy.test.js +4 -3
  457. package/src/maths/mat4/create.d.ts +2 -4
  458. package/src/maths/mat4/create.js +2 -5
  459. package/src/maths/mat4/create.test.js +3 -3
  460. package/src/maths/mat4/equals.d.ts +2 -4
  461. package/src/maths/mat4/equals.js +4 -6
  462. package/src/maths/mat4/equals.test.js +3 -2
  463. package/src/maths/mat4/fromRotation.d.ts +3 -5
  464. package/src/maths/mat4/fromRotation.js +8 -10
  465. package/src/maths/mat4/fromRotation.test.js +4 -3
  466. package/src/maths/mat4/fromScaling.d.ts +3 -5
  467. package/src/maths/mat4/fromScaling.js +4 -6
  468. package/src/maths/mat4/fromScaling.test.js +4 -3
  469. package/src/maths/mat4/fromTaitBryanRotation.d.ts +2 -4
  470. package/src/maths/mat4/fromTaitBryanRotation.js +7 -9
  471. package/src/maths/mat4/fromTaitBryanRotation.test.js +3 -3
  472. package/src/maths/mat4/fromTranslation.d.ts +3 -5
  473. package/src/maths/mat4/fromTranslation.js +4 -6
  474. package/src/maths/mat4/fromTranslation.test.js +4 -3
  475. package/src/maths/mat4/fromValues.d.ts +2 -4
  476. package/src/maths/mat4/fromValues.js +19 -21
  477. package/src/maths/mat4/fromValues.test.js +4 -3
  478. package/src/maths/mat4/fromVectorRotation.d.ts +3 -5
  479. package/src/maths/mat4/fromVectorRotation.js +8 -10
  480. package/src/maths/mat4/fromVectorRotation.test.js +4 -5
  481. package/src/maths/mat4/fromXRotation.d.ts +2 -4
  482. package/src/maths/mat4/fromXRotation.js +5 -7
  483. package/src/maths/mat4/fromXRotation.test.js +4 -3
  484. package/src/maths/mat4/fromYRotation.d.ts +2 -4
  485. package/src/maths/mat4/fromYRotation.js +5 -7
  486. package/src/maths/mat4/fromYRotation.test.js +4 -3
  487. package/src/maths/mat4/fromZRotation.d.ts +2 -4
  488. package/src/maths/mat4/fromZRotation.js +5 -7
  489. package/src/maths/mat4/fromZRotation.test.js +4 -3
  490. package/src/maths/mat4/identity.d.ts +2 -4
  491. package/src/maths/mat4/identity.js +3 -5
  492. package/src/maths/mat4/identity.test.js +4 -3
  493. package/src/maths/mat4/index.d.ts +30 -28
  494. package/src/maths/mat4/index.js +29 -31
  495. package/src/maths/mat4/invert.d.ts +3 -0
  496. package/src/maths/mat4/invert.js +7 -7
  497. package/src/maths/mat4/invert.test.js +6 -5
  498. package/src/maths/mat4/isIdentity.d.ts +2 -4
  499. package/src/maths/mat4/isIdentity.js +4 -6
  500. package/src/maths/mat4/isIdentity.test.js +2 -2
  501. package/src/maths/mat4/isMirroring.d.ts +2 -4
  502. package/src/maths/mat4/isMirroring.js +4 -6
  503. package/src/maths/mat4/isMirroring.test.js +3 -3
  504. package/src/maths/mat4/isOnlyTransformScale.d.ts +3 -0
  505. package/src/maths/mat4/isOnlyTransformScale.js +7 -5
  506. package/src/maths/mat4/isOnlyTransformScale.test.js +3 -3
  507. package/src/maths/mat4/mirrorByPlane.d.ts +3 -5
  508. package/src/maths/mat4/mirrorByPlane.js +4 -6
  509. package/src/maths/mat4/mirrorByPlane.test.js +4 -4
  510. package/src/maths/mat4/multiply.d.ts +2 -4
  511. package/src/maths/mat4/multiply.js +5 -7
  512. package/src/maths/mat4/multiply.test.js +4 -3
  513. package/src/maths/mat4/rotate.d.ts +3 -5
  514. package/src/maths/mat4/rotate.js +9 -11
  515. package/src/maths/mat4/rotate.test.js +6 -5
  516. package/src/maths/mat4/rotateX.d.ts +2 -4
  517. package/src/maths/mat4/rotateX.js +6 -8
  518. package/src/maths/mat4/rotateX.test.js +4 -3
  519. package/src/maths/mat4/rotateY.d.ts +2 -4
  520. package/src/maths/mat4/rotateY.js +6 -8
  521. package/src/maths/mat4/rotateY.test.js +4 -3
  522. package/src/maths/mat4/rotateZ.d.ts +2 -4
  523. package/src/maths/mat4/rotateZ.js +6 -8
  524. package/src/maths/mat4/rotateZ.test.js +4 -3
  525. package/src/maths/mat4/scale.d.ts +3 -5
  526. package/src/maths/mat4/scale.js +5 -7
  527. package/src/maths/mat4/scale.test.js +4 -3
  528. package/src/maths/mat4/subtract.d.ts +2 -4
  529. package/src/maths/mat4/subtract.js +5 -7
  530. package/src/maths/mat4/subtract.test.js +4 -3
  531. package/src/maths/mat4/toString.d.ts +2 -4
  532. package/src/maths/mat4/toString.js +3 -5
  533. package/src/maths/mat4/translate.d.ts +3 -5
  534. package/src/maths/mat4/translate.js +5 -7
  535. package/src/maths/mat4/translate.test.js +11 -15
  536. package/src/maths/mat4/type.d.ts +1 -3
  537. package/src/maths/plane/clone.d.ts +2 -4
  538. package/src/maths/plane/clone.test.js +4 -3
  539. package/src/maths/plane/copy.d.ts +2 -4
  540. package/src/maths/plane/copy.test.js +4 -3
  541. package/src/maths/plane/create.d.ts +2 -4
  542. package/src/maths/plane/create.test.js +3 -3
  543. package/src/maths/plane/equals.d.ts +2 -4
  544. package/src/maths/plane/equals.test.js +3 -2
  545. package/src/maths/plane/flip.d.ts +2 -4
  546. package/src/maths/plane/flip.js +4 -6
  547. package/src/maths/plane/flip.test.js +4 -3
  548. package/src/maths/plane/fromNormalAndPoint.d.ts +3 -5
  549. package/src/maths/plane/fromNormalAndPoint.js +6 -9
  550. package/src/maths/plane/fromNormalAndPoint.test.js +4 -3
  551. package/src/maths/plane/fromPoints.d.ts +3 -5
  552. package/src/maths/plane/fromPoints.js +4 -6
  553. package/src/maths/plane/fromPoints.test.js +4 -3
  554. package/src/maths/plane/fromPointsRandom.d.ts +3 -5
  555. package/src/maths/plane/fromPointsRandom.js +8 -10
  556. package/src/maths/plane/fromValues.d.ts +2 -4
  557. package/src/maths/plane/index.d.ts +14 -16
  558. package/src/maths/plane/index.js +38 -40
  559. package/src/maths/plane/projectionOfPoint.d.ts +3 -5
  560. package/src/maths/plane/projectionOfPoint.js +5 -7
  561. package/src/maths/plane/projectionOfPoint.test.js +3 -3
  562. package/src/maths/plane/signedDistanceToPoint.d.ts +3 -5
  563. package/src/maths/plane/signedDistanceToPoint.js +5 -7
  564. package/src/maths/plane/signedDistanceToPoint.test.js +3 -2
  565. package/src/maths/plane/toString.d.ts +2 -4
  566. package/src/maths/plane/transform.d.ts +3 -5
  567. package/src/maths/plane/transform.js +11 -13
  568. package/src/maths/plane/transform.test.js +4 -3
  569. package/src/maths/plane/type.d.ts +1 -3
  570. package/src/maths/rotation.test.js +4 -4
  571. package/src/maths/types.d.ts +15 -8
  572. package/src/maths/utils/OrthonormalFormula.d.ts +9 -0
  573. package/src/maths/utils/OrthonormalFormula.js +82 -0
  574. package/src/maths/utils/OrthonormalFormula.test.js +72 -0
  575. package/src/maths/utils/aboutEqualNormals.d.ts +2 -4
  576. package/src/maths/utils/aboutEqualNormals.js +4 -6
  577. package/src/maths/utils/area.d.ts +2 -4
  578. package/src/maths/utils/area.js +2 -4
  579. package/src/maths/utils/interpolateBetween2DPointsForY.d.ts +2 -4
  580. package/src/maths/utils/interpolateBetween2DPointsForY.js +4 -6
  581. package/src/maths/utils/intersect.d.ts +2 -4
  582. package/src/maths/utils/intersect.js +14 -9
  583. package/src/maths/utils/intersect.test.js +40 -0
  584. package/src/maths/utils/solve2Linear.d.ts +2 -4
  585. package/src/maths/utils/solve2Linear.js +1 -3
  586. package/src/maths/utils/trigonometry.js +7 -9
  587. package/src/maths/utils/trigonometry.test.js +3 -3
  588. package/src/maths/vec1/type.d.ts +1 -3
  589. package/src/maths/vec2/abs.d.ts +2 -4
  590. package/src/maths/vec2/abs.js +4 -6
  591. package/src/maths/vec2/abs.test.js +4 -3
  592. package/src/maths/vec2/add.d.ts +2 -4
  593. package/src/maths/vec2/add.js +5 -7
  594. package/src/maths/vec2/add.test.js +4 -3
  595. package/src/maths/vec2/angle.d.ts +1 -3
  596. package/src/maths/vec2/angle.js +1 -1
  597. package/src/maths/vec2/angleDegrees.d.ts +2 -4
  598. package/src/maths/vec2/angleDegrees.js +4 -6
  599. package/src/maths/vec2/angleDegrees.test.js +6 -4
  600. package/src/maths/vec2/angleRadians.d.ts +2 -4
  601. package/src/maths/vec2/angleRadians.js +3 -5
  602. package/src/maths/vec2/angleRadians.test.js +6 -4
  603. package/src/maths/vec2/clone.d.ts +2 -4
  604. package/src/maths/vec2/clone.js +4 -6
  605. package/src/maths/vec2/clone.test.js +4 -3
  606. package/src/maths/vec2/copy.d.ts +2 -4
  607. package/src/maths/vec2/copy.js +4 -6
  608. package/src/maths/vec2/copy.test.js +4 -3
  609. package/src/maths/vec2/create.d.ts +2 -4
  610. package/src/maths/vec2/create.js +2 -5
  611. package/src/maths/vec2/create.test.js +3 -3
  612. package/src/maths/vec2/cross.d.ts +3 -5
  613. package/src/maths/vec2/cross.js +5 -7
  614. package/src/maths/vec2/cross.test.js +14 -12
  615. package/src/maths/vec2/distance.d.ts +2 -4
  616. package/src/maths/vec2/distance.js +4 -6
  617. package/src/maths/vec2/distance.test.js +6 -4
  618. package/src/maths/vec2/divide.d.ts +2 -4
  619. package/src/maths/vec2/divide.js +5 -7
  620. package/src/maths/vec2/divide.test.js +4 -3
  621. package/src/maths/vec2/dot.d.ts +2 -4
  622. package/src/maths/vec2/dot.js +4 -6
  623. package/src/maths/vec2/dot.test.js +3 -2
  624. package/src/maths/vec2/equals.d.ts +2 -4
  625. package/src/maths/vec2/equals.js +3 -5
  626. package/src/maths/vec2/equals.test.js +3 -2
  627. package/src/maths/vec2/fromAngleDegrees.d.ts +2 -4
  628. package/src/maths/vec2/fromAngleDegrees.js +5 -7
  629. package/src/maths/vec2/fromAngleDegrees.test.js +4 -3
  630. package/src/maths/vec2/fromAngleRadians.d.ts +2 -4
  631. package/src/maths/vec2/fromAngleRadians.js +5 -7
  632. package/src/maths/vec2/fromAngleRadians.test.js +4 -4
  633. package/src/maths/vec2/fromScalar.d.ts +2 -4
  634. package/src/maths/vec2/fromScalar.js +4 -6
  635. package/src/maths/vec2/fromScalar.test.js +4 -3
  636. package/src/maths/vec2/fromValues.d.ts +2 -4
  637. package/src/maths/vec2/fromValues.js +5 -7
  638. package/src/maths/vec2/index.d.ts +34 -35
  639. package/src/maths/vec2/index.js +33 -35
  640. package/src/maths/vec2/length.d.ts +2 -4
  641. package/src/maths/vec2/length.js +3 -5
  642. package/src/maths/vec2/length.test.js +6 -4
  643. package/src/maths/vec2/lerp.d.ts +2 -4
  644. package/src/maths/vec2/lerp.js +6 -8
  645. package/src/maths/vec2/lerp.test.js +4 -3
  646. package/src/maths/vec2/max.d.ts +2 -4
  647. package/src/maths/vec2/max.js +5 -7
  648. package/src/maths/vec2/max.test.js +4 -3
  649. package/src/maths/vec2/min.d.ts +2 -4
  650. package/src/maths/vec2/min.js +5 -7
  651. package/src/maths/vec2/min.test.js +4 -3
  652. package/src/maths/vec2/multiply.d.ts +2 -4
  653. package/src/maths/vec2/multiply.js +5 -7
  654. package/src/maths/vec2/multiply.test.js +4 -3
  655. package/src/maths/vec2/negate.d.ts +2 -4
  656. package/src/maths/vec2/negate.js +4 -6
  657. package/src/maths/vec2/negate.test.js +4 -3
  658. package/src/maths/vec2/normal.d.ts +2 -4
  659. package/src/maths/vec2/normal.js +7 -9
  660. package/src/maths/vec2/normal.test.js +4 -3
  661. package/src/maths/vec2/normalize.d.ts +2 -4
  662. package/src/maths/vec2/normalize.js +4 -8
  663. package/src/maths/vec2/normalize.test.js +4 -3
  664. package/src/maths/vec2/rotate.d.ts +2 -4
  665. package/src/maths/vec2/rotate.js +6 -8
  666. package/src/maths/vec2/rotate.test.js +4 -4
  667. package/src/maths/vec2/scale.d.ts +2 -4
  668. package/src/maths/vec2/scale.js +5 -7
  669. package/src/maths/vec2/scale.test.js +4 -3
  670. package/src/maths/vec2/snap.d.ts +2 -4
  671. package/src/maths/vec2/snap.js +5 -7
  672. package/src/maths/vec2/snap.test.js +4 -3
  673. package/src/maths/vec2/squaredDistance.d.ts +2 -4
  674. package/src/maths/vec2/squaredDistance.js +4 -6
  675. package/src/maths/vec2/squaredDistance.test.js +6 -4
  676. package/src/maths/vec2/squaredLength.d.ts +2 -4
  677. package/src/maths/vec2/squaredLength.js +3 -5
  678. package/src/maths/vec2/squaredLength.test.js +6 -4
  679. package/src/maths/vec2/subtract.d.ts +2 -4
  680. package/src/maths/vec2/subtract.js +5 -7
  681. package/src/maths/vec2/subtract.test.js +4 -3
  682. package/src/maths/vec2/toString.d.ts +2 -4
  683. package/src/maths/vec2/toString.js +3 -5
  684. package/src/maths/vec2/transform.d.ts +3 -5
  685. package/src/maths/vec2/transform.js +5 -7
  686. package/src/maths/vec2/transform.test.js +4 -3
  687. package/src/maths/vec2/type.d.ts +1 -3
  688. package/src/maths/vec3/abs.d.ts +2 -4
  689. package/src/maths/vec3/abs.js +4 -6
  690. package/src/maths/vec3/abs.test.js +4 -3
  691. package/src/maths/vec3/add.d.ts +2 -4
  692. package/src/maths/vec3/add.js +5 -7
  693. package/src/maths/vec3/add.test.js +4 -3
  694. package/src/maths/vec3/angle.d.ts +2 -4
  695. package/src/maths/vec3/angle.js +5 -7
  696. package/src/maths/vec3/angle.test.js +6 -4
  697. package/src/maths/vec3/clone.d.ts +2 -4
  698. package/src/maths/vec3/clone.js +4 -6
  699. package/src/maths/vec3/clone.test.js +4 -3
  700. package/src/maths/vec3/copy.d.ts +2 -4
  701. package/src/maths/vec3/copy.js +4 -6
  702. package/src/maths/vec3/copy.test.js +4 -3
  703. package/src/maths/vec3/create.d.ts +2 -4
  704. package/src/maths/vec3/create.js +2 -5
  705. package/src/maths/vec3/create.test.js +3 -3
  706. package/src/maths/vec3/cross.d.ts +2 -4
  707. package/src/maths/vec3/cross.js +5 -7
  708. package/src/maths/vec3/cross.test.js +4 -3
  709. package/src/maths/vec3/distance.d.ts +2 -4
  710. package/src/maths/vec3/distance.js +4 -6
  711. package/src/maths/vec3/distance.test.js +6 -4
  712. package/src/maths/vec3/divide.d.ts +2 -4
  713. package/src/maths/vec3/divide.js +5 -7
  714. package/src/maths/vec3/divide.test.js +4 -3
  715. package/src/maths/vec3/dot.d.ts +2 -4
  716. package/src/maths/vec3/dot.js +4 -6
  717. package/src/maths/vec3/dot.test.js +3 -2
  718. package/src/maths/vec3/equals.d.ts +2 -4
  719. package/src/maths/vec3/equals.js +3 -5
  720. package/src/maths/vec3/equals.test.js +3 -2
  721. package/src/maths/vec3/fromScalar.d.ts +2 -4
  722. package/src/maths/vec3/fromScalar.js +4 -6
  723. package/src/maths/vec3/fromScalar.test.js +4 -3
  724. package/src/maths/vec3/fromValues.d.ts +2 -4
  725. package/src/maths/vec3/fromValues.js +6 -8
  726. package/src/maths/vec3/fromValues.test.js +4 -3
  727. package/src/maths/vec3/fromVec2.d.ts +3 -5
  728. package/src/maths/vec3/fromVec2.js +4 -6
  729. package/src/maths/vec3/fromVec2.test.js +3 -3
  730. package/src/maths/vec3/index.d.ts +33 -34
  731. package/src/maths/vec3/index.js +32 -34
  732. package/src/maths/vec3/length.d.ts +2 -4
  733. package/src/maths/vec3/length.js +3 -5
  734. package/src/maths/vec3/length.test.js +6 -4
  735. package/src/maths/vec3/lerp.d.ts +2 -4
  736. package/src/maths/vec3/lerp.js +6 -8
  737. package/src/maths/vec3/lerp.test.js +4 -3
  738. package/src/maths/vec3/max.d.ts +2 -4
  739. package/src/maths/vec3/max.js +5 -7
  740. package/src/maths/vec3/max.test.js +4 -3
  741. package/src/maths/vec3/min.d.ts +2 -4
  742. package/src/maths/vec3/min.js +5 -7
  743. package/src/maths/vec3/min.test.js +4 -3
  744. package/src/maths/vec3/multiply.d.ts +2 -4
  745. package/src/maths/vec3/multiply.js +5 -7
  746. package/src/maths/vec3/multiply.test.js +4 -3
  747. package/src/maths/vec3/negate.d.ts +2 -4
  748. package/src/maths/vec3/negate.js +4 -6
  749. package/src/maths/vec3/negate.test.js +4 -3
  750. package/src/maths/vec3/normalize.d.ts +2 -4
  751. package/src/maths/vec3/normalize.js +4 -6
  752. package/src/maths/vec3/normalize.test.js +4 -3
  753. package/src/maths/vec3/orthogonal.d.ts +2 -4
  754. package/src/maths/vec3/orthogonal.js +7 -9
  755. package/src/maths/vec3/orthogonal.test.js +4 -3
  756. package/src/maths/vec3/rotateX.d.ts +2 -4
  757. package/src/maths/vec3/rotateX.js +6 -8
  758. package/src/maths/vec3/rotateX.test.js +4 -4
  759. package/src/maths/vec3/rotateY.d.ts +2 -4
  760. package/src/maths/vec3/rotateY.js +6 -8
  761. package/src/maths/vec3/rotateY.test.js +4 -4
  762. package/src/maths/vec3/rotateZ.d.ts +2 -4
  763. package/src/maths/vec3/rotateZ.js +6 -8
  764. package/src/maths/vec3/rotateZ.test.js +4 -4
  765. package/src/maths/vec3/scale.d.ts +2 -4
  766. package/src/maths/vec3/scale.js +5 -7
  767. package/src/maths/vec3/scale.test.js +4 -3
  768. package/src/maths/vec3/snap.d.ts +2 -4
  769. package/src/maths/vec3/snap.js +5 -7
  770. package/src/maths/vec3/snap.test.js +4 -3
  771. package/src/maths/vec3/squaredDistance.d.ts +2 -4
  772. package/src/maths/vec3/squaredDistance.js +4 -6
  773. package/src/maths/vec3/squaredDistance.test.js +6 -4
  774. package/src/maths/vec3/squaredLength.d.ts +2 -4
  775. package/src/maths/vec3/squaredLength.js +3 -5
  776. package/src/maths/vec3/squaredLength.test.js +6 -4
  777. package/src/maths/vec3/subtract.d.ts +2 -4
  778. package/src/maths/vec3/subtract.js +5 -7
  779. package/src/maths/vec3/subtract.test.js +4 -3
  780. package/src/maths/vec3/toString.d.ts +2 -4
  781. package/src/maths/vec3/toString.js +3 -5
  782. package/src/maths/vec3/transform.d.ts +3 -5
  783. package/src/maths/vec3/transform.js +5 -7
  784. package/src/maths/vec3/transform.test.js +12 -15
  785. package/src/maths/vec3/type.d.ts +1 -3
  786. package/src/maths/vec4/clone.d.ts +2 -4
  787. package/src/maths/vec4/clone.js +4 -6
  788. package/src/maths/vec4/clone.test.js +4 -3
  789. package/src/maths/vec4/copy.d.ts +2 -4
  790. package/src/maths/vec4/copy.js +4 -6
  791. package/src/maths/vec4/copy.test.js +4 -3
  792. package/src/maths/vec4/create.d.ts +2 -4
  793. package/src/maths/vec4/create.js +2 -5
  794. package/src/maths/vec4/create.test.js +3 -3
  795. package/src/maths/vec4/dot.d.ts +2 -4
  796. package/src/maths/vec4/dot.js +4 -6
  797. package/src/maths/vec4/dot.test.js +2 -2
  798. package/src/maths/vec4/equals.d.ts +2 -4
  799. package/src/maths/vec4/equals.js +3 -5
  800. package/src/maths/vec4/equals.test.js +3 -2
  801. package/src/maths/vec4/fromScalar.d.ts +2 -4
  802. package/src/maths/vec4/fromScalar.js +3 -5
  803. package/src/maths/vec4/fromScalar.test.js +4 -3
  804. package/src/maths/vec4/fromValues.d.ts +2 -4
  805. package/src/maths/vec4/fromValues.js +7 -9
  806. package/src/maths/vec4/fromValues.test.js +4 -3
  807. package/src/maths/vec4/index.d.ts +10 -11
  808. package/src/maths/vec4/index.js +9 -11
  809. package/src/maths/vec4/toString.d.ts +2 -4
  810. package/src/maths/vec4/toString.js +3 -5
  811. package/src/maths/vec4/transform.d.ts +3 -5
  812. package/src/maths/vec4/transform.js +6 -7
  813. package/src/maths/vec4/transform.test.js +4 -3
  814. package/src/maths/vec4/type.d.ts +1 -3
  815. package/src/measurements/calculateEpsilonFromBounds.js +2 -4
  816. package/src/measurements/calculateEpsilonFromBounds.test.js +4 -3
  817. package/src/measurements/index.d.ts +13 -14
  818. package/src/measurements/index.js +13 -15
  819. package/src/measurements/measureAggregateArea.d.ts +3 -5
  820. package/src/measurements/measureAggregateArea.js +4 -7
  821. package/src/measurements/measureAggregateArea.test.js +4 -3
  822. package/src/measurements/measureAggregateBoundingBox.d.ts +4 -6
  823. package/src/measurements/measureAggregateBoundingBox.js +6 -9
  824. package/src/measurements/measureAggregateBoundingBox.test.js +4 -4
  825. package/src/measurements/measureAggregateEpsilon.d.ts +3 -5
  826. package/src/measurements/measureAggregateEpsilon.js +10 -9
  827. package/src/measurements/measureAggregateEpsilon.test.js +6 -4
  828. package/src/measurements/measureAggregateVolume.d.ts +3 -5
  829. package/src/measurements/measureAggregateVolume.js +4 -7
  830. package/src/measurements/measureAggregateVolume.test.js +4 -3
  831. package/src/measurements/measureArea.d.ts +5 -7
  832. package/src/measurements/measureArea.js +37 -20
  833. package/src/measurements/measureArea.test.js +14 -4
  834. package/src/measurements/measureBoundingBox.d.ts +6 -8
  835. package/src/measurements/measureBoundingBox.js +81 -82
  836. package/src/measurements/measureBoundingBox.test.js +26 -5
  837. package/src/measurements/measureBoundingSphere.d.ts +4 -7
  838. package/src/measurements/measureBoundingSphere.js +83 -64
  839. package/src/measurements/measureBoundingSphere.test.js +7 -4
  840. package/src/measurements/measureCenter.d.ts +4 -6
  841. package/src/measurements/measureCenter.js +4 -6
  842. package/src/measurements/measureCenter.test.js +7 -4
  843. package/src/measurements/measureCenterOfMass.d.ts +4 -6
  844. package/src/measurements/measureCenterOfMass.js +6 -8
  845. package/src/measurements/measureCenterOfMass.test.js +7 -4
  846. package/src/measurements/measureDimensions.d.ts +4 -6
  847. package/src/measurements/measureDimensions.js +3 -5
  848. package/src/measurements/measureDimensions.test.js +7 -4
  849. package/src/measurements/measureEpsilon.d.ts +5 -7
  850. package/src/measurements/measureEpsilon.js +14 -30
  851. package/src/measurements/measureEpsilon.test.js +7 -4
  852. package/src/measurements/measureVolume.d.ts +5 -7
  853. package/src/measurements/measureVolume.js +7 -31
  854. package/src/measurements/measureVolume.test.js +7 -4
  855. package/src/measurements/types.d.ts +2 -1
  856. package/src/operations/booleans/index.d.ts +4 -6
  857. package/src/operations/booleans/index.js +5 -7
  858. package/src/operations/booleans/intersect.d.ts +5 -6
  859. package/src/operations/booleans/intersect.js +13 -15
  860. package/src/operations/booleans/intersect.test.js +24 -0
  861. package/src/operations/booleans/intersectGeom2.js +10 -20
  862. package/src/operations/booleans/intersectGeom2.test.js +47 -17
  863. package/src/operations/booleans/intersectGeom3.js +9 -15
  864. package/src/operations/booleans/intersectGeom3.test.js +17 -17
  865. package/src/operations/booleans/intersectGeom3Sub.js +10 -11
  866. package/src/operations/booleans/martinez/compareEvents.js +45 -0
  867. package/src/operations/booleans/martinez/compareSegments.js +51 -0
  868. package/src/operations/booleans/martinez/computeFields.js +109 -0
  869. package/src/operations/booleans/martinez/connectEdges.js +189 -0
  870. package/src/operations/booleans/martinez/contour.js +12 -0
  871. package/src/operations/booleans/martinez/divideSegment.js +32 -0
  872. package/src/operations/booleans/martinez/edgeType.js +4 -0
  873. package/src/operations/booleans/martinez/fillQueue.js +80 -0
  874. package/src/operations/booleans/martinez/index.js +154 -0
  875. package/src/operations/booleans/martinez/operation.js +4 -0
  876. package/src/operations/booleans/martinez/possibleIntersection.js +113 -0
  877. package/src/operations/booleans/martinez/segmentIntersection.js +132 -0
  878. package/src/operations/booleans/martinez/signedArea.js +16 -0
  879. package/src/operations/booleans/martinez/splaytree.js +599 -0
  880. package/src/operations/booleans/martinez/subdivideSegments.js +82 -0
  881. package/src/operations/booleans/martinez/sweepEvent.js +132 -0
  882. package/src/operations/booleans/martinez/tinyqueue.js +76 -0
  883. package/src/operations/booleans/mayOverlap.js +5 -7
  884. package/src/operations/booleans/mayOverlap.test.js +6 -6
  885. package/src/operations/booleans/scission.d.ts +4 -5
  886. package/src/operations/booleans/scission.js +5 -13
  887. package/src/operations/booleans/scission.test.js +10 -4
  888. package/src/operations/booleans/scissionGeom3.js +15 -16
  889. package/src/operations/booleans/subtract.d.ts +5 -6
  890. package/src/operations/booleans/subtract.js +13 -15
  891. package/src/operations/booleans/subtract.test.js +24 -0
  892. package/src/operations/booleans/subtractGeom2.js +10 -20
  893. package/src/operations/booleans/subtractGeom2.test.js +46 -17
  894. package/src/operations/booleans/subtractGeom3.js +9 -15
  895. package/src/operations/booleans/subtractGeom3.test.js +16 -6
  896. package/src/operations/booleans/subtractGeom3Sub.js +10 -11
  897. package/src/operations/booleans/trees/Node.js +45 -48
  898. package/src/operations/booleans/trees/PolygonTreeNode.js +35 -37
  899. package/src/operations/booleans/trees/Tree.js +9 -12
  900. package/src/operations/booleans/trees/index.js +1 -3
  901. package/src/operations/booleans/trees/splitLineSegmentByPlane.js +2 -4
  902. package/src/operations/booleans/trees/splitPolygonByPlane.js +55 -57
  903. package/src/operations/booleans/union.d.ts +5 -6
  904. package/src/operations/booleans/union.js +13 -15
  905. package/src/operations/booleans/union.test.js +24 -0
  906. package/src/operations/booleans/unionGeom2.js +10 -20
  907. package/src/operations/booleans/unionGeom2.test.js +153 -84
  908. package/src/operations/booleans/unionGeom3.js +9 -15
  909. package/src/operations/booleans/unionGeom3.test.js +22 -9
  910. package/src/operations/booleans/unionGeom3Sub.js +10 -12
  911. package/src/operations/extrusions/extrudeFromSlices.d.ts +3 -6
  912. package/src/operations/extrusions/extrudeFromSlices.js +19 -31
  913. package/src/operations/extrusions/extrudeFromSlices.test.js +54 -48
  914. package/src/operations/extrusions/extrudeHelical.d.ts +2 -4
  915. package/src/operations/extrusions/extrudeHelical.js +19 -26
  916. package/src/operations/extrusions/extrudeHelical.test.js +6 -6
  917. package/src/operations/extrusions/extrudeLinear.d.ts +4 -6
  918. package/src/operations/extrusions/extrudeLinear.js +10 -16
  919. package/src/operations/extrusions/extrudeLinear.test.js +90 -67
  920. package/src/operations/extrusions/extrudeLinearGeom2.js +18 -23
  921. package/src/operations/extrusions/extrudeLinearPath2.js +11 -12
  922. package/src/operations/extrusions/extrudeRotate.d.ts +2 -4
  923. package/src/operations/extrusions/extrudeRotate.js +28 -32
  924. package/src/operations/extrusions/extrudeRotate.test.js +70 -34
  925. package/src/operations/extrusions/extrudeWalls.js +11 -14
  926. package/src/operations/extrusions/extrudeWalls.test.js +24 -48
  927. package/src/operations/extrusions/index.d.ts +5 -9
  928. package/src/operations/extrusions/index.js +6 -10
  929. package/src/operations/extrusions/project.d.ts +6 -8
  930. package/src/operations/extrusions/project.js +35 -32
  931. package/src/operations/extrusions/project.test.js +116 -83
  932. package/src/operations/hulls/hull.d.ts +5 -7
  933. package/src/operations/hulls/hull.js +14 -15
  934. package/src/operations/hulls/hull.test.js +101 -58
  935. package/src/operations/hulls/hullChain.d.ts +5 -7
  936. package/src/operations/hulls/hullChain.js +15 -10
  937. package/src/operations/hulls/hullChain.test.js +27 -8
  938. package/src/operations/hulls/hullGeom2.js +7 -13
  939. package/src/operations/hulls/hullGeom3.js +6 -12
  940. package/src/operations/hulls/hullPath2.js +6 -12
  941. package/src/operations/hulls/hullPath2.test.js +4 -4
  942. package/src/operations/hulls/hullPoints2.d.ts +2 -4
  943. package/src/operations/hulls/hullPoints2.js +3 -5
  944. package/src/operations/hulls/hullPoints2.test.js +2 -2
  945. package/src/operations/hulls/hullPoints3.d.ts +3 -5
  946. package/src/operations/hulls/hullPoints3.js +4 -6
  947. package/src/operations/hulls/index.d.ts +4 -6
  948. package/src/operations/hulls/index.js +5 -7
  949. package/src/operations/hulls/quickhull/Face.js +7 -21
  950. package/src/operations/hulls/quickhull/HalfEdge.js +2 -5
  951. package/src/operations/hulls/quickhull/QuickHull.js +14 -16
  952. package/src/operations/hulls/quickhull/Vertex.js +1 -3
  953. package/src/operations/hulls/quickhull/VertexList.js +1 -4
  954. package/src/operations/hulls/quickhull/index.js +2 -4
  955. package/src/operations/hulls/quickhull/point-line-distance.js +2 -6
  956. package/src/operations/hulls/toUniquePoints.js +4 -6
  957. package/src/operations/modifiers/generalize.d.ts +2 -2
  958. package/src/operations/modifiers/generalize.js +15 -21
  959. package/src/operations/modifiers/generalize.test.js +6 -6
  960. package/src/operations/modifiers/index.d.ts +3 -3
  961. package/src/operations/modifiers/index.js +4 -6
  962. package/src/operations/modifiers/insertTjunctions.js +164 -165
  963. package/src/operations/modifiers/insertTjunctions.test.js +5 -5
  964. package/src/operations/modifiers/mergePolygons.js +35 -36
  965. package/src/operations/modifiers/reTesselateCoplanarPolygons.js +235 -236
  966. package/src/operations/modifiers/reTesselateCoplanarPolygons.test.js +4 -4
  967. package/src/operations/modifiers/retessellate.d.ts +2 -2
  968. package/src/operations/modifiers/retessellate.js +7 -7
  969. package/src/operations/modifiers/retessellate.test.js +4 -4
  970. package/src/operations/modifiers/snap.d.ts +2 -2
  971. package/src/operations/modifiers/snap.js +30 -23
  972. package/src/operations/modifiers/snap.test.js +32 -10
  973. package/src/operations/modifiers/snapPolygons.js +14 -16
  974. package/src/operations/modifiers/snapPolygons.test.js +3 -3
  975. package/src/operations/modifiers/triangulatePolygons.js +5 -6
  976. package/src/operations/offsets/extrudePolygon.js +32 -0
  977. package/src/operations/offsets/index.d.ts +2 -0
  978. package/src/operations/offsets/index.js +9 -0
  979. package/src/operations/offsets/offset.d.ts +12 -0
  980. package/src/operations/offsets/offset.js +32 -0
  981. package/src/operations/offsets/offsetFromPoints.d.ts +10 -0
  982. package/src/operations/{expansions → offsets}/offsetFromPoints.js +29 -28
  983. package/src/operations/offsets/offsetFromPoints.test.js +316 -0
  984. package/src/operations/offsets/offsetGeom2.js +55 -0
  985. package/src/operations/offsets/offsetGeom2.test.js +269 -0
  986. package/src/operations/offsets/offsetGeom3.js +31 -0
  987. package/src/operations/{expansions/expandGeom3.test.js → offsets/offsetGeom3.test.js} +71 -5
  988. package/src/operations/{expansions/expandPath2.js → offsets/offsetPath2.js} +27 -33
  989. package/src/operations/offsets/offsetPath2.test.js +103 -0
  990. package/src/operations/{expansions/expandShell.js → offsets/offsetShell.js} +54 -56
  991. package/src/operations/transforms/align.d.ts +5 -7
  992. package/src/operations/transforms/align.js +16 -15
  993. package/src/operations/transforms/align.test.js +9 -8
  994. package/src/operations/transforms/center.d.ts +3 -3
  995. package/src/operations/transforms/center.js +12 -22
  996. package/src/operations/transforms/center.test.js +34 -6
  997. package/src/operations/transforms/index.d.ts +7 -9
  998. package/src/operations/transforms/index.js +8 -29
  999. package/src/operations/transforms/mirror.d.ts +3 -3
  1000. package/src/operations/transforms/mirror.js +12 -22
  1001. package/src/operations/transforms/mirror.test.js +16 -10
  1002. package/src/operations/transforms/rotate.d.ts +6 -6
  1003. package/src/operations/transforms/rotate.js +14 -24
  1004. package/src/operations/transforms/rotate.test.js +18 -7
  1005. package/src/operations/transforms/scale.d.ts +6 -6
  1006. package/src/operations/transforms/scale.js +13 -23
  1007. package/src/operations/transforms/scale.test.js +21 -6
  1008. package/src/operations/transforms/transform.d.ts +3 -3
  1009. package/src/operations/transforms/transform.js +8 -13
  1010. package/src/operations/transforms/transform.test.js +7 -7
  1011. package/src/operations/transforms/translate.d.ts +3 -5
  1012. package/src/operations/transforms/translate.js +14 -24
  1013. package/src/operations/transforms/translate.test.js +18 -6
  1014. package/src/primitives/arc.d.ts +3 -5
  1015. package/src/primitives/arc.js +26 -28
  1016. package/src/primitives/arc.test.js +17 -16
  1017. package/src/primitives/circle.d.ts +3 -5
  1018. package/src/primitives/circle.js +10 -12
  1019. package/src/primitives/circle.test.js +23 -12
  1020. package/src/primitives/commonChecks.js +3 -9
  1021. package/src/primitives/cube.d.ts +3 -5
  1022. package/src/primitives/cube.js +6 -9
  1023. package/src/primitives/cube.test.js +14 -4
  1024. package/src/primitives/cuboid.d.ts +3 -5
  1025. package/src/primitives/cuboid.js +8 -10
  1026. package/src/primitives/cuboid.test.js +14 -4
  1027. package/src/primitives/cylinder.d.ts +3 -5
  1028. package/src/primitives/cylinder.js +11 -15
  1029. package/src/primitives/cylinder.test.js +16 -4
  1030. package/src/primitives/cylinderElliptic.d.ts +3 -5
  1031. package/src/primitives/cylinderElliptic.js +33 -35
  1032. package/src/primitives/cylinderElliptic.test.js +26 -5
  1033. package/src/primitives/ellipse.d.ts +3 -5
  1034. package/src/primitives/ellipse.js +19 -21
  1035. package/src/primitives/ellipse.test.js +23 -12
  1036. package/src/primitives/ellipsoid.d.ts +3 -5
  1037. package/src/primitives/ellipsoid.js +48 -51
  1038. package/src/primitives/ellipsoid.test.js +16 -4
  1039. package/src/primitives/geodesicSphere.d.ts +2 -4
  1040. package/src/primitives/geodesicSphere.js +14 -17
  1041. package/src/primitives/geodesicSphere.test.js +12 -4
  1042. package/src/primitives/index.d.ts +21 -23
  1043. package/src/primitives/index.js +22 -24
  1044. package/src/primitives/line.d.ts +3 -5
  1045. package/src/primitives/line.js +3 -5
  1046. package/src/primitives/line.test.js +5 -5
  1047. package/src/primitives/polygon.d.ts +3 -5
  1048. package/src/primitives/polygon.js +17 -22
  1049. package/src/primitives/polygon.test.js +14 -9
  1050. package/src/primitives/polyhedron.d.ts +4 -6
  1051. package/src/primitives/polyhedron.js +15 -17
  1052. package/src/primitives/polyhedron.test.js +12 -6
  1053. package/src/primitives/rectangle.d.ts +3 -5
  1054. package/src/primitives/rectangle.js +10 -12
  1055. package/src/primitives/rectangle.test.js +13 -7
  1056. package/src/primitives/roundedCuboid.d.ts +3 -5
  1057. package/src/primitives/roundedCuboid.js +57 -58
  1058. package/src/primitives/roundedCuboid.test.js +24 -8
  1059. package/src/primitives/roundedCylinder.d.ts +3 -5
  1060. package/src/primitives/roundedCylinder.js +73 -76
  1061. package/src/primitives/roundedCylinder.test.js +24 -4
  1062. package/src/primitives/roundedRectangle.d.ts +3 -5
  1063. package/src/primitives/roundedRectangle.js +16 -16
  1064. package/src/primitives/roundedRectangle.test.js +19 -10
  1065. package/src/primitives/sphere.d.ts +3 -5
  1066. package/src/primitives/sphere.js +8 -11
  1067. package/src/primitives/sphere.test.js +16 -4
  1068. package/src/primitives/square.d.ts +3 -5
  1069. package/src/primitives/square.js +6 -9
  1070. package/src/primitives/square.test.js +14 -8
  1071. package/src/primitives/star.d.ts +3 -5
  1072. package/src/primitives/star.js +16 -18
  1073. package/src/primitives/star.test.js +18 -10
  1074. package/src/primitives/torus.d.ts +2 -4
  1075. package/src/primitives/torus.js +16 -18
  1076. package/src/primitives/torus.test.js +18 -6
  1077. package/src/primitives/triangle.d.ts +2 -4
  1078. package/src/primitives/triangle.js +9 -11
  1079. package/src/primitives/triangle.test.js +23 -13
  1080. package/src/text/fonts/single-line/hershey/simplex.js +1 -1
  1081. package/src/text/index.d.ts +2 -4
  1082. package/src/text/index.js +3 -5
  1083. package/src/text/vectorChar.d.ts +2 -8
  1084. package/src/text/vectorChar.js +51 -36
  1085. package/src/text/vectorChar.test.js +63 -0
  1086. package/src/text/vectorText.d.ts +2 -8
  1087. package/src/text/vectorText.js +100 -69
  1088. package/src/text/vectorText.test.js +267 -0
  1089. package/src/utils/areAllShapesTheSameType.d.ts +2 -4
  1090. package/src/utils/areAllShapesTheSameType.js +4 -6
  1091. package/src/utils/areAllShapesTheSameType.test.js +3 -3
  1092. package/src/utils/coalesce.d.ts +3 -0
  1093. package/src/utils/coalesce.js +20 -0
  1094. package/src/utils/degToRad.d.ts +1 -3
  1095. package/src/utils/degToRad.js +3 -5
  1096. package/src/utils/degToRad.test.js +3 -3
  1097. package/src/utils/flatten.d.ts +2 -4
  1098. package/src/utils/flatten.js +1 -3
  1099. package/src/utils/fnNumberSort.d.ts +1 -3
  1100. package/src/utils/fnNumberSort.js +1 -3
  1101. package/src/utils/index.d.ts +4 -9
  1102. package/src/utils/index.js +5 -10
  1103. package/src/utils/insertSorted.d.ts +1 -3
  1104. package/src/utils/insertSorted.js +11 -13
  1105. package/src/utils/padArrayToLength.d.ts +1 -3
  1106. package/src/utils/padArrayToLength.js +2 -4
  1107. package/src/utils/padArrayToLength.test.js +2 -2
  1108. package/src/utils/radToDeg.d.ts +1 -3
  1109. package/src/utils/radToDeg.js +3 -5
  1110. package/src/utils/radToDeg.test.js +3 -3
  1111. package/src/utils/radiusToSegments.d.ts +1 -3
  1112. package/src/utils/radiusToSegments.js +6 -8
  1113. package/src/utils/radiusToSegments.test.js +3 -3
  1114. package/src/utils/recursiveArray.d.ts +1 -3
  1115. package/test/helpers/asserts.js +9 -16
  1116. package/test/helpers/comparePoints.js +2 -4
  1117. package/test/helpers/comparePolygonLists.js +2 -4
  1118. package/test/helpers/comparePolygons.js +4 -6
  1119. package/test/helpers/comparePolygonsAsPoints.js +4 -6
  1120. package/test/helpers/compareVectors.js +5 -6
  1121. package/test/helpers/index.js +6 -8
  1122. package/test/helpers/nearlyEqual.js +1 -3
  1123. package/tsconfig.json +17 -0
  1124. package/src/geometries/geom2/fromPoints.d.ts +0 -6
  1125. package/src/geometries/geom2/fromPoints.js +0 -35
  1126. package/src/geometries/geom2/fromPoints.test.js +0 -22
  1127. package/src/geometries/poly2/flip.d.ts +0 -5
  1128. package/src/geometries/poly2/flip.js +0 -15
  1129. package/src/geometries/poly3/fromPoints.d.ts +0 -6
  1130. package/src/geometries/poly3/fromPoints.js +0 -25
  1131. package/src/geometries/poly3/fromPoints.test.js +0 -15
  1132. package/src/geometries/poly3/fromPointsAndPlane.d.ts +0 -7
  1133. package/src/geometries/poly3/toPoints.d.ts +0 -6
  1134. package/src/geometries/poly3/toPoints.js +0 -10
  1135. package/src/maths/OrthoNormalBasis.js +0 -59
  1136. package/src/maths/mat4/leftMultiplyVec2.d.ts +0 -6
  1137. package/src/maths/mat4/leftMultiplyVec2.js +0 -28
  1138. package/src/maths/mat4/leftMultiplyVec3.d.ts +0 -6
  1139. package/src/maths/mat4/leftMultiplyVec3.js +0 -29
  1140. package/src/maths/mat4/mirror.d.ts +0 -6
  1141. package/src/maths/mat4/mirror.js +0 -34
  1142. package/src/maths/mat4/rightMultiplyVec2.d.ts +0 -6
  1143. package/src/maths/mat4/rightMultiplyVec2.js +0 -29
  1144. package/src/maths/mat4/rightMultiplyVec3.d.ts +0 -6
  1145. package/src/maths/mat4/rightMultiplyVec3.js +0 -30
  1146. package/src/maths/plane/fromNoisyPoints.d.ts +0 -6
  1147. package/src/maths/plane/fromNoisyPoints.js +0 -106
  1148. package/src/maths/plane/fromNoisyPoints.test.js +0 -24
  1149. package/src/maths/utils/index.d.ts +0 -8
  1150. package/src/maths/utils/index.js +0 -15
  1151. package/src/operations/booleans/fromFakePolygons.js +0 -52
  1152. package/src/operations/booleans/to3DWalls.js +0 -36
  1153. package/src/operations/expansions/expand.d.ts +0 -18
  1154. package/src/operations/expansions/expand.js +0 -42
  1155. package/src/operations/expansions/expand.test.js +0 -188
  1156. package/src/operations/expansions/expandGeom2.js +0 -43
  1157. package/src/operations/expansions/expandGeom3.js +0 -36
  1158. package/src/operations/expansions/extrudePolygon.js +0 -34
  1159. package/src/operations/expansions/index.d.ts +0 -4
  1160. package/src/operations/expansions/index.js +0 -11
  1161. package/src/operations/expansions/offset.d.ts +0 -15
  1162. package/src/operations/expansions/offset.js +0 -36
  1163. package/src/operations/expansions/offset.test.js +0 -503
  1164. package/src/operations/expansions/offsetGeom2.js +0 -47
  1165. package/src/operations/expansions/offsetPath2.js +0 -32
  1166. package/src/operations/extrusions/earcut/assignHoles.test.js +0 -74
  1167. package/src/operations/extrusions/extrudeRectangular.d.ts +0 -17
  1168. package/src/operations/extrusions/extrudeRectangular.js +0 -45
  1169. package/src/operations/extrusions/extrudeRectangular.test.js +0 -72
  1170. package/src/operations/extrusions/extrudeRectangularGeom2.js +0 -46
  1171. package/src/operations/extrusions/extrudeRectangularPath2.js +0 -33
  1172. package/src/operations/extrusions/slice/calculatePlane.d.ts +0 -7
  1173. package/src/operations/extrusions/slice/calculatePlane.js +0 -41
  1174. package/src/operations/extrusions/slice/calculatePlane.test.js +0 -35
  1175. package/src/operations/extrusions/slice/clone.d.ts +0 -6
  1176. package/src/operations/extrusions/slice/clone.js +0 -28
  1177. package/src/operations/extrusions/slice/clone.test.js +0 -34
  1178. package/src/operations/extrusions/slice/create.d.ts +0 -5
  1179. package/src/operations/extrusions/slice/create.js +0 -20
  1180. package/src/operations/extrusions/slice/equals.d.ts +0 -5
  1181. package/src/operations/extrusions/slice/equals.js +0 -27
  1182. package/src/operations/extrusions/slice/equals.test.js +0 -17
  1183. package/src/operations/extrusions/slice/fromPoints.d.ts +0 -9
  1184. package/src/operations/extrusions/slice/fromPoints.js +0 -35
  1185. package/src/operations/extrusions/slice/fromPoints.test.js +0 -15
  1186. package/src/operations/extrusions/slice/fromSides.d.ts +0 -7
  1187. package/src/operations/extrusions/slice/fromSides.js +0 -27
  1188. package/src/operations/extrusions/slice/fromSides.test.js +0 -15
  1189. package/src/operations/extrusions/slice/index.d.ts +0 -16
  1190. package/src/operations/extrusions/slice/index.js +0 -19
  1191. package/src/operations/extrusions/slice/isA.d.ts +0 -5
  1192. package/src/operations/extrusions/slice/isA.js +0 -18
  1193. package/src/operations/extrusions/slice/repair.js +0 -62
  1194. package/src/operations/extrusions/slice/reverse.d.ts +0 -6
  1195. package/src/operations/extrusions/slice/reverse.js +0 -26
  1196. package/src/operations/extrusions/slice/toEdges.d.ts +0 -5
  1197. package/src/operations/extrusions/slice/toEdges.js +0 -13
  1198. package/src/operations/extrusions/slice/toPolygons.d.ts +0 -7
  1199. package/src/operations/extrusions/slice/toString.d.ts +0 -5
  1200. package/src/operations/extrusions/slice/toString.js +0 -15
  1201. package/src/operations/extrusions/slice/transform.d.ts +0 -7
  1202. package/src/operations/extrusions/slice/transform.js +0 -21
  1203. package/src/operations/extrusions/slice/type.d.ts +0 -7
  1204. package/src/operations/hulls/quickhull/get-plane-normal.js +0 -20
  1205. package/src/text/text.test.js +0 -187
  1206. package/src/text/vectorParams.js +0 -26
@@ -1,14 +1,16 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { comparePolygonsAsPoints } = require('../../../test/helpers')
3
+ import { comparePolygonsAsPoints } from '../../../test/helpers/index.js'
4
4
 
5
- const { geom3 } = require('../../geometries')
5
+ import { geom3 } from '../../geometries/index.js'
6
6
 
7
- const { sphere, cuboid } = require('../../primitives')
7
+ import { measureArea, measureVolume } from '../../measurements/index.js'
8
8
 
9
- const { union } = require('./index')
9
+ import { sphere, cuboid } from '../../primitives/index.js'
10
10
 
11
- const { center } = require('../transforms/center')
11
+ import { center } from '../transforms/index.js'
12
+
13
+ import { union } from './index.js'
12
14
 
13
15
  test('union of one or more geom3 objects produces expected geometry', (t) => {
14
16
  const geometry1 = sphere({ radius: 2, segments: 8 })
@@ -67,6 +69,9 @@ test('union of one or more geom3 objects produces expected geometry', (t) => {
67
69
  [[8.65956056235493e-17, 8.659560562354935e-17, 2], [1.4142135623730951, 3.4638242249419736e-16, 1.414213562373095], [0.9999999999999998, 1.0000000000000002, 1.414213562373095]]
68
70
  ]
69
71
  t.notThrows.skip(() => geom3.validate(result1))
72
+ t.is(measureArea(result1), 44.053756306589825)
73
+ t.is(measureVolume(result1), 25.751611331979678)
74
+ t.is(obs.length, 32)
70
75
  t.true(comparePolygonsAsPoints(obs, exp))
71
76
 
72
77
  // union of two non-overlapping objects
@@ -75,6 +80,8 @@ test('union of one or more geom3 objects produces expected geometry', (t) => {
75
80
  const result2 = union(geometry1, geometry2)
76
81
  obs = geom3.toPoints(result2)
77
82
  t.notThrows.skip(() => geom3.validate(result2))
83
+ t.is(measureArea(result2), 140.05375630658983)
84
+ t.is(measureVolume(result2), 89.75161133197969)
78
85
  t.is(obs.length, 38)
79
86
 
80
87
  // union of two partially overlapping objects
@@ -103,6 +110,8 @@ test('union of one or more geom3 objects produces expected geometry', (t) => {
103
110
  [[-9, 8, 9], [-9, -9, 9], [9, -9, 9], [9, 8, 9]]
104
111
  ]
105
112
  t.notThrows.skip(() => geom3.validate(result3))
113
+ t.is(measureArea(result3), 2034)
114
+ t.is(measureVolume(result3), 5895)
106
115
  t.is(obs.length, 18)
107
116
  t.true(comparePolygonsAsPoints(obs, exp))
108
117
 
@@ -118,6 +127,8 @@ test('union of one or more geom3 objects produces expected geometry', (t) => {
118
127
  [[-9, -9, 9], [9, -9, 9], [9, 9, 9], [-9, 9, 9]]
119
128
  ]
120
129
  t.notThrows(() => geom3.validate(result4))
130
+ t.is(measureArea(result4), 1944)
131
+ t.is(measureVolume(result4), 5832)
121
132
  t.is(obs.length, 6)
122
133
  t.true(comparePolygonsAsPoints(obs, exp))
123
134
  })
@@ -126,8 +137,10 @@ test('union of geom3 with rounding issues #137', (t) => {
126
137
  const geometry1 = center({ relativeTo: [0, 0, -1] }, cuboid({ size: [44, 26, 5] }))
127
138
  const geometry2 = center({ relativeTo: [0, 0, -4.400001] }, cuboid({ size: [44, 26, 1.8] })) // introduce precision error
128
139
 
129
- const obs = union(geometry1, geometry2)
130
- const pts = geom3.toPoints(obs)
131
- t.notThrows(() => geom3.validate(obs))
140
+ const result = union(geometry1, geometry2)
141
+ const pts = geom3.toPoints(result)
142
+ t.notThrows(() => geom3.validate(result))
143
+ t.is(measureArea(result), 3240.00014)
144
+ t.is(measureVolume(result), 7779.201144000001)
132
145
  t.is(pts.length, 6) // number of polygons in union
133
146
  })
@@ -1,15 +1,16 @@
1
- const geom3 = require('../../geometries/geom3')
1
+ import * as geom3 from '../../geometries/geom3/index.js'
2
2
 
3
- const mayOverlap = require('./mayOverlap')
4
- const { Tree } = require('./trees')
3
+ import { Tree } from './trees/index.js'
4
+
5
+ import { mayOverlap } from './mayOverlap.js'
5
6
 
6
7
  /*
7
8
  * Return a new 3D geometry representing the space in the given geometries.
8
- * @param {geom3} geometry1 - geometry to union
9
- * @param {geom3} geometry2 - geometry to union
10
- * @returns {geom3} new 3D geometry
9
+ * @param {Geom3} geometry1 - geometry to union
10
+ * @param {Geom3} geometry2 - geometry to union
11
+ * @returns {Geom3} new 3D geometry
11
12
  */
12
- const unionSub = (geometry1, geometry2) => {
13
+ export const unionGeom3Sub = (geometry1, geometry2) => {
13
14
  if (!mayOverlap(geometry1, geometry2)) {
14
15
  return unionForNonIntersecting(geometry1, geometry2)
15
16
  }
@@ -24,9 +25,8 @@ const unionSub = (geometry1, geometry2) => {
24
25
  b.clipTo(a)
25
26
  b.invert()
26
27
 
27
- const newpolygons = a.allPolygons().concat(b.allPolygons())
28
- const result = geom3.create(newpolygons)
29
- return result
28
+ const newPolygons = a.allPolygons().concat(b.allPolygons())
29
+ return geom3.create(newPolygons)
30
30
  }
31
31
 
32
32
  // Like union, but when we know that the two solids are not intersecting
@@ -36,5 +36,3 @@ const unionForNonIntersecting = (geometry1, geometry2) => {
36
36
  newpolygons = newpolygons.concat(geom3.toPolygons(geometry2))
37
37
  return geom3.create(newpolygons)
38
38
  }
39
-
40
- module.exports = unionSub
@@ -1,8 +1,5 @@
1
- import Geom3 from '../../geometries/geom3/type'
2
-
3
- import Slice from './slice/type'
4
-
5
- export default extrudeFromSlices
1
+ import type { Geom3 } from '../../geometries/geom3/type.d.ts'
2
+ import type { Slice } from '../../geometries/slice/type.d.ts'
6
3
 
7
4
  export interface ExtrudeFromSlicesOptions<Base> {
8
5
  numberOfSlices?: number
@@ -12,4 +9,4 @@ export interface ExtrudeFromSlicesOptions<Base> {
12
9
  callback?: (progress: number, index: number, base: Base) => Slice
13
10
  }
14
11
 
15
- declare function extrudeFromSlices<Base>(options: ExtrudeFromSlicesOptions<Base>, base: Base): Geom3
12
+ export function extrudeFromSlices<Base>(options: ExtrudeFromSlicesOptions<Base>, base: Base): Geom3
@@ -1,18 +1,16 @@
1
- const mat4 = require('../../maths/mat4')
1
+ import * as mat4 from '../../maths/mat4/index.js'
2
2
 
3
- const geom2 = require('../../geometries/geom2')
4
- const geom3 = require('../../geometries/geom3')
5
- const poly3 = require('../../geometries/poly3')
3
+ import * as geom2 from '../../geometries/geom2/index.js'
4
+ import * as geom3 from '../../geometries/geom3/index.js'
5
+ import * as poly3 from '../../geometries/poly3/index.js'
6
+ import * as slice from '../../geometries/slice/index.js'
6
7
 
7
- const slice = require('./slice')
8
- const repairSlice = require('./slice/repair')
9
-
10
- const extrudeWalls = require('./extrudeWalls')
8
+ import { extrudeWalls } from './extrudeWalls.js'
11
9
 
12
10
  const defaultCallback = (progress, index, base) => {
13
11
  let baseSlice = null
14
- if (geom2.isA(base)) baseSlice = slice.fromSides(geom2.toSides(base))
15
- if (poly3.isA(base)) baseSlice = slice.fromPoints(poly3.toPoints(base))
12
+ if (geom2.isA(base)) baseSlice = slice.fromGeom2(base)
13
+ if (poly3.isA(base)) baseSlice = slice.fromVertices(poly3.toVertices(base))
16
14
 
17
15
  return progress === 0 || progress === 1 ? slice.transform(mat4.fromTranslation(mat4.create(), [0, 0, progress]), baseSlice) : null
18
16
  }
@@ -21,15 +19,15 @@ const defaultCallback = (progress, index, base) => {
21
19
  * Extrude a solid from the slices as returned by the callback function.
22
20
  * @see slice
23
21
  *
24
- * @param {Object} options - options for extrude
25
- * @param {Integer} [options.numberOfSlices=2] the number of slices to be generated by the callback
26
- * @param {Boolean} [options.capStart=true] the solid should have a cap at the start
27
- * @param {Boolean} [options.capEnd=true] the solid should have a cap at the end
28
- * @param {Boolean} [options.close=false] the solid should have a closing section between start and end
29
- * @param {Boolean} [options.repair=true] - repair gaps in the geometry
22
+ * @param {object} options - options for extrude
23
+ * @param {number} [options.numberOfSlices=2] the number of slices to be generated by the callback
24
+ * @param {boolean} [options.capStart=true] the solid should have a cap at the start
25
+ * @param {boolean} [options.capEnd=true] the solid should have a cap at the end
26
+ * @param {boolean} [options.close=false] the solid should have a closing section between start and end
27
+ * @param {boolean} [options.repair=true] - repair gaps in the geometry
30
28
  * @param {Function} [options.callback] the callback function that generates each slice
31
- * @param {Object} base - the base object which is used to create slices (see the example for callback information)
32
- * @return {geom3} the extruded shape
29
+ * @param {object} base - the base object which is used to create slices (see the example for callback information)
30
+ * @return {Geom3} the extruded shape
33
31
  * @alias module:modeling/extrusions.extrudeFromSlices
34
32
  *
35
33
  * @example
@@ -44,25 +42,18 @@ const defaultCallback = (progress, index, base) => {
44
42
  * return slice
45
43
  * }
46
44
  */
47
- const extrudeFromSlices = (options, base) => {
45
+ export const extrudeFromSlices = (options, base) => {
48
46
  const defaults = {
49
47
  numberOfSlices: 2,
50
48
  capStart: true,
51
49
  capEnd: true,
52
50
  close: false,
53
- repair: true,
54
51
  callback: defaultCallback
55
52
  }
56
- const { numberOfSlices, capStart, capEnd, close, repair, callback: generate } = Object.assign({ }, defaults, options)
53
+ const { numberOfSlices, capStart, capEnd, close, callback: generate } = Object.assign({ }, defaults, options)
57
54
 
58
55
  if (numberOfSlices < 2) throw new Error('numberOfSlices must be 2 or more')
59
56
 
60
- // Repair gaps in the base slice
61
- if (repair) {
62
- // note: base must be a slice, if base is geom2 this doesn't repair
63
- base = repairSlice(base)
64
- }
65
-
66
57
  const sMax = numberOfSlices - 1
67
58
 
68
59
  let startSlice = null
@@ -77,8 +68,7 @@ const extrudeFromSlices = (options, base) => {
77
68
  if (currentSlice) {
78
69
  if (!slice.isA(currentSlice)) throw new Error('the callback function must return slice objects')
79
70
 
80
- const edges = slice.toEdges(currentSlice)
81
- if (edges.length === 0) throw new Error('the callback function must return slices with one or more edges')
71
+ if (currentSlice.contours.length === 0) throw new Error('the callback function must return slices with one or more contours')
82
72
 
83
73
  if (prevSlice) {
84
74
  polygons = polygons.concat(extrudeWalls(prevSlice, currentSlice))
@@ -110,5 +100,3 @@ const extrudeFromSlices = (options, base) => {
110
100
  }
111
101
  return geom3.create(polygons)
112
102
  }
113
-
114
- module.exports = extrudeFromSlices
@@ -1,43 +1,49 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const comparePolygonsAsPoints = require('../../../test/helpers/comparePolygonsAsPoints')
3
+ import { comparePolygonsAsPoints } from '../../../test/helpers/index.js'
4
4
 
5
- const { TAU } = require('../../maths/constants')
6
- const mat4 = require('../../maths/mat4')
5
+ import { TAU } from '../../maths/constants.js'
6
+ import { mat4 } from '../../maths/index.js'
7
7
 
8
- const { geom2, geom3, poly3 } = require('../../geometries')
8
+ import { geom2, geom3, poly3, slice } from '../../geometries/index.js'
9
9
 
10
- const { circle } = require('../../primitives')
10
+ import { measureArea, measureVolume } from '../../measurements/index.js'
11
11
 
12
- const { extrudeFromSlices, slice } = require('./index')
12
+ import { circle, square } from '../../primitives/index.js'
13
+
14
+ import { extrudeFromSlices } from './index.js'
13
15
 
14
16
  test('extrudeFromSlices (defaults)', (t) => {
15
- const geometry2 = geom2.fromPoints([[10, 10], [-10, 10], [-10, -10], [10, -10]])
17
+ const geometry2 = square({ size: 20 })
16
18
 
17
19
  let geometry3 = extrudeFromSlices({ }, geometry2)
18
20
  let pts = geom3.toPoints(geometry3)
19
21
  const exp = [
22
+ [[-10, -10, 0], [10, -10, 0], [10, -10, 1]],
23
+ [[-10, -10, 0], [10, -10, 1], [-10, -10, 1]],
20
24
  [[10, -10, 0], [10, 10, 0], [10, 10, 1]],
21
25
  [[10, -10, 0], [10, 10, 1], [10, -10, 1]],
22
26
  [[10, 10, 0], [-10, 10, 0], [-10, 10, 1]],
23
27
  [[10, 10, 0], [-10, 10, 1], [10, 10, 1]],
24
28
  [[-10, 10, 0], [-10, -10, 0], [-10, -10, 1]],
25
29
  [[-10, 10, 0], [-10, -10, 1], [-10, 10, 1]],
26
- [[-10, -10, 0], [10, -10, 0], [10, -10, 1]],
27
- [[-10, -10, 0], [10, -10, 1], [-10, -10, 1]],
28
- [[-10, -10, 1], [10, -10, 1], [10, 10, 1]],
29
30
  [[10, 10, 1], [-10, 10, 1], [-10, -10, 1]],
30
- [[10, 10, 0], [10, -10, 0], [-10, -10, 0]],
31
- [[-10, -10, 0], [-10, 10, 0], [10, 10, 0]]
31
+ [[-10, -10, 1], [10, -10, 1], [10, 10, 1]],
32
+ [[-10, -10, 0], [-10, 10, 0], [10, 10, 0]],
33
+ [[10, 10, 0], [10, -10, 0], [-10, -10, 0]]
32
34
  ]
35
+ t.is(measureArea(geometry3), 880)
36
+ t.is(measureVolume(geometry3), 400.00000000000006)
33
37
  t.is(pts.length, 12)
34
38
  t.true(comparePolygonsAsPoints(pts, exp))
35
39
 
36
- const poly2 = poly3.create([[10, 10, 0], [-10, 10, 0], [-10, -10, 0], [10, -10, 0]])
40
+ const poly2 = poly3.create([[-10, -10, 0], [10, -10, 0], [10, 10, 0], [-10, 10, 0]])
37
41
  geometry3 = extrudeFromSlices({ }, poly2)
38
42
  pts = geom3.toPoints(geometry3)
39
43
 
40
44
  t.notThrows(() => geom3.validate(geometry3))
45
+ t.is(measureArea(geometry3), 880)
46
+ t.is(measureVolume(geometry3), 400.00000000000006)
41
47
  t.is(pts.length, 12)
42
48
  t.true(comparePolygonsAsPoints(pts, exp))
43
49
  })
@@ -55,7 +61,7 @@ test('extrudeFromSlices (torus)', (t) => {
55
61
  [radius / 2, -radius * sqrt3, 0]
56
62
  ])
57
63
  hex = poly3.transform(mat4.fromTranslation(mat4.create(), [0, 20, 0]), hex)
58
- hex = slice.fromPoints(poly3.toPoints(hex))
64
+ hex = slice.fromVertices(poly3.toVertices(hex))
59
65
 
60
66
  const angle = TAU / 8
61
67
  const geometry3 = extrudeFromSlices(
@@ -71,26 +77,30 @@ test('extrudeFromSlices (torus)', (t) => {
71
77
  )
72
78
  const pts = geom3.toPoints(geometry3)
73
79
  t.notThrows(() => geom3.validate(geometry3))
80
+ t.is(measureArea(geometry3), 7070.694617452831)
81
+ t.is(measureVolume(geometry3), 29393.876913398108)
74
82
  t.is(pts.length, 96)
75
83
  })
76
84
 
77
85
  test('extrudeFromSlices (same shape, changing dimensions)', (t) => {
78
- const base = slice.fromPoints([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]])
86
+ const base = slice.fromVertices([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]])
79
87
  const geometry3 = extrudeFromSlices(
80
88
  {
81
89
  numberOfSlices: 4,
82
90
  capStart: true,
83
91
  capEnd: false,
84
92
  callback: function (progress, count, base) {
85
- let newslice = slice.transform(mat4.fromTranslation(mat4.create(), [0, 0, count * 2]), base)
86
- newslice = slice.transform(mat4.fromScaling(mat4.create(), [1 + count, 1 + (count / 2), 1]), newslice)
87
- return newslice
93
+ let newSlice = slice.transform(mat4.fromTranslation(mat4.create(), [0, 0, count * 2]), base)
94
+ newSlice = slice.transform(mat4.fromScaling(mat4.create(), [1 + count, 1 + (count / 2), 1]), newSlice)
95
+ return newSlice
88
96
  }
89
97
  }, base
90
98
  )
91
99
  const pts = geom3.toPoints(geometry3)
92
100
  // expected to throw because capEnd is false (non-closed geometry)
93
101
  t.throws(() => geom3.validate(geometry3))
102
+ t.is(measureArea(geometry3), 53.70100297794013)
103
+ t.is(measureVolume(geometry3), 8.5)
94
104
  t.is(pts.length, 26)
95
105
  })
96
106
 
@@ -100,31 +110,25 @@ test('extrudeFromSlices (changing shape, changing dimensions)', (t) => {
100
110
  {
101
111
  numberOfSlices: 5,
102
112
  callback: (progress, count, base) => {
103
- const newshape = circle({ radius: 5 + count, segments: 4 + count })
104
- let newslice = slice.fromSides(geom2.toSides(newshape))
105
- newslice = slice.transform(mat4.fromTranslation(mat4.create(), [0, 0, count * 10]), newslice)
106
- return newslice
113
+ const newShape = circle({ radius: 5 + count, segments: 4 + count })
114
+ let newSlice = slice.fromGeom2(newShape)
115
+ newSlice = slice.transform(mat4.fromTranslation(mat4.create(), [0, 0, count * 10]), newSlice)
116
+ return newSlice
107
117
  }
108
118
  }, base
109
119
  )
110
120
  const pts = geom3.toPoints(geometry3)
111
121
  t.notThrows.skip(() => geom3.validate(geometry3))
122
+ t.is(measureArea(geometry3), 1965.8643589631802)
123
+ t.is(measureVolume(geometry3), 5260.067107417433)
112
124
  t.is(pts.length, 304)
113
125
  })
114
126
 
115
127
  test('extrudeFromSlices (holes)', (t) => {
116
- const geometry2 = geom2.create(
117
- [
118
- [[-10, 10], [-10, -10]],
119
- [[-10, -10], [10, -10]],
120
- [[10, -10], [10, 10]],
121
- [[10, 10], [-10, 10]],
122
- [[-5, -5], [-5, 5]],
123
- [[5, -5], [-5, -5]],
124
- [[5, 5], [5, -5]],
125
- [[-5, 5], [5, 5]]
126
- ]
127
- )
128
+ const geometry2 = geom2.create([
129
+ [[-10, 10], [-10, -10], [10, -10], [10, 10]],
130
+ [[-5, -5], [-5, 5], [5, 5], [5, -5]]
131
+ ])
128
132
  const geometry3 = extrudeFromSlices({ }, geometry2)
129
133
  const pts = geom3.toPoints(geometry3)
130
134
  const exp = [
@@ -138,30 +142,32 @@ test('extrudeFromSlices (holes)', (t) => {
138
142
  [[10, 10, 0], [-10, 10, 1], [10, 10, 1]],
139
143
  [[-5, -5, 0], [-5, 5, 0], [-5, 5, 1]],
140
144
  [[-5, -5, 0], [-5, 5, 1], [-5, -5, 1]],
141
- [[5, -5, 0], [-5, -5, 0], [-5, -5, 1]],
142
- [[5, -5, 0], [-5, -5, 1], [5, -5, 1]],
143
- [[5, 5, 0], [5, -5, 0], [5, -5, 1]],
144
- [[5, 5, 0], [5, -5, 1], [5, 5, 1]],
145
145
  [[-5, 5, 0], [5, 5, 0], [5, 5, 1]],
146
146
  [[-5, 5, 0], [5, 5, 1], [-5, 5, 1]],
147
- [[10, -10, 1], [10, 10, 1], [5, 5, 1]],
147
+ [[5, 5, 0], [5, -5, 0], [5, -5, 1]],
148
+ [[5, 5, 0], [5, -5, 1], [5, 5, 1]],
149
+ [[5, -5, 0], [-5, -5, 0], [-5, -5, 1]],
150
+ [[5, -5, 0], [-5, -5, 1], [5, -5, 1]],
148
151
  [[-5, 5, 1], [5, 5, 1], [10, 10, 1]],
149
- [[10, -10, 1], [5, 5, 1], [5, -5, 1]],
152
+ [[10, -10, 1], [10, 10, 1], [5, 5, 1]],
150
153
  [[-5, 5, 1], [10, 10, 1], [-10, 10, 1]],
151
- [[-10, -10, 1], [10, -10, 1], [5, -5, 1]],
154
+ [[10, -10, 1], [5, 5, 1], [5, -5, 1]],
152
155
  [[-5, -5, 1], [-5, 5, 1], [-10, 10, 1]],
153
- [[-10, -10, 1], [5, -5, 1], [-5, -5, 1]],
156
+ [[-10, -10, 1], [10, -10, 1], [5, -5, 1]],
154
157
  [[-5, -5, 1], [-10, 10, 1], [-10, -10, 1]],
155
- [[5, 5, 0], [10, 10, 0], [10, -10, 0]],
158
+ [[-10, -10, 1], [5, -5, 1], [-5, -5, 1]],
156
159
  [[10, 10, 0], [5, 5, 0], [-5, 5, 0]],
157
- [[5, -5, 0], [5, 5, 0], [10, -10, 0]],
160
+ [[5, 5, 0], [10, 10, 0], [10, -10, 0]],
158
161
  [[-10, 10, 0], [10, 10, 0], [-5, 5, 0]],
159
- [[5, -5, 0], [10, -10, 0], [-10, -10, 0]],
162
+ [[5, -5, 0], [5, 5, 0], [10, -10, 0]],
160
163
  [[-10, 10, 0], [-5, 5, 0], [-5, -5, 0]],
161
- [[-5, -5, 0], [5, -5, 0], [-10, -10, 0]],
162
- [[-10, -10, 0], [-10, 10, 0], [-5, -5, 0]]
164
+ [[5, -5, 0], [10, -10, 0], [-10, -10, 0]],
165
+ [[-10, -10, 0], [-10, 10, 0], [-5, -5, 0]],
166
+ [[-5, -5, 0], [5, -5, 0], [-10, -10, 0]]
163
167
  ]
164
168
  t.notThrows(() => geom3.validate(geometry3))
169
+ t.is(measureArea(geometry3), 720)
170
+ t.is(measureVolume(geometry3), 300)
165
171
  t.is(pts.length, 32)
166
172
  t.true(comparePolygonsAsPoints(pts, exp))
167
173
  })
@@ -1,6 +1,4 @@
1
- import { Geom2, Geom3 } from '../../geometries/types'
2
-
3
- export default extrudeHelical
1
+ import type { Geom2, Geom3 } from '../../geometries/types.d.ts'
4
2
 
5
3
  export interface ExtrudeHelicalOptions {
6
4
  angle?: number
@@ -11,4 +9,4 @@ export interface ExtrudeHelicalOptions {
11
9
  segmentsPerRotation?: number
12
10
  }
13
11
 
14
- declare function extrudeHelical(options: ExtrudeHelicalOptions, geometry: Geom2): Geom3
12
+ export function extrudeHelical(options: ExtrudeHelicalOptions, geometry: Geom2): Geom3
@@ -1,28 +1,28 @@
1
- const { TAU } = require('../../maths/constants')
2
- const slice = require('./slice')
3
- const mat4 = require('../../maths/mat4')
4
- const extrudeFromSlices = require('./extrudeFromSlices')
5
- const geom2 = require('../../geometries/geom2')
1
+ import { TAU } from '../../maths/constants.js'
2
+ import * as slice from '../../geometries/slice/index.js'
3
+ import * as mat4 from '../../maths/mat4/index.js'
4
+ import { measureBoundingBox } from '../../measurements/measureBoundingBox.js'
5
+ import { extrudeFromSlices } from './extrudeFromSlices.js'
6
6
 
7
7
  /**
8
8
  * Perform a helical extrude of the geometry, using the given options.
9
9
  *
10
- * @param {Object} options - options for extrusion
11
- * @param {Number} [options.angle=TAU] - angle of the extrusion (RADIANS) positive for right-hand rotation, negative for left-hand
12
- * @param {Number} [options.startAngle=0] - start angle of the extrusion (RADIANS)
13
- * @param {Number} [options.pitch=10] - elevation gain for each turn
14
- * @param {Number} [options.height] - total height of the helix path. Ignored if pitch is set.
15
- * @param {Number} [options.endOffset=0] - offset the final radius of the extrusion, allowing for tapered helix, and or spiral
16
- * @param {Number} [options.segmentsPerRotation=32] - number of segments per full rotation of the extrusion
17
- * @param {geom2} geometry - the geometry to extrude
18
- * @returns {geom3} the extruded geometry
10
+ * @param {object} options - options for extrusion
11
+ * @param {number} [options.angle=TAU] - angle of the extrusion (RADIANS) positive for right-hand rotation, negative for left-hand
12
+ * @param {number} [options.startAngle=0] - start angle of the extrusion (RADIANS)
13
+ * @param {number} [options.pitch=10] - elevation gain for each turn
14
+ * @param {number} [options.height] - total height of the helix path. Ignored if pitch is set.
15
+ * @param {number} [options.endOffset=0] - offset the final radius of the extrusion, allowing for tapered helix, and or spiral
16
+ * @param {number} [options.segmentsPerRotation=32] - number of segments per full rotation of the extrusion
17
+ * @param {Geom2} geometry - the geometry to extrude
18
+ * @returns {Geom3} the extruded geometry
19
19
  * @alias module:modeling/extrusions.extrudeHelical
20
20
  *
21
21
  * @example
22
22
  * const myshape = circle({size: 3, center: [10, 0]}) // position for extrusion about Z
23
23
  * const mycoil = extrudeHelical({angle: TAU*2, pitch: 10, segmentsPerRotation: 64}, myshape))
24
24
  */
25
- const extrudeHelical = (options, geometry) => {
25
+ export const extrudeHelical = (options, geometry) => {
26
26
  const defaults = {
27
27
  angle: TAU,
28
28
  startAngle: 0,
@@ -45,15 +45,10 @@ const extrudeHelical = (options, geometry) => {
45
45
 
46
46
  if (segmentsPerRotation < minNumberOfSegments) { throw new Error('The number of segments per rotation needs to be at least 3.') }
47
47
 
48
- const shapeSides = geom2.toSides(geometry)
49
- if (shapeSides.length === 0) throw new Error('the given geometry cannot be empty')
48
+ let baseSlice = slice.fromGeom2(geometry)
50
49
 
51
- // const pointsWithNegativeX = shapeSides.filter((s) => (s[0][0] < 0))
52
- const pointsWithPositiveX = shapeSides.filter((s) => (s[0][0] >= 0))
53
-
54
- let baseSlice = slice.fromSides(shapeSides)
55
-
56
- if (pointsWithPositiveX.length === 0) {
50
+ const bounds = measureBoundingBox(geometry)
51
+ if (bounds[1][0] <= 0) {
57
52
  // only points in negative x plane, reverse
58
53
  baseSlice = slice.reverse(baseSlice)
59
54
  }
@@ -91,7 +86,7 @@ const extrudeHelical = (options, geometry) => {
91
86
  mat4.fromZRotation(mat4.create(), zRotation),
92
87
  step1
93
88
  )
94
- return slice.transform(matrix, base)
89
+ return slice.transform(matrix, baseSlice)
95
90
  }
96
91
 
97
92
  return extrudeFromSlices(
@@ -103,5 +98,3 @@ const extrudeHelical = (options, geometry) => {
103
98
  baseSlice
104
99
  )
105
100
  }
106
-
107
- module.exports = extrudeHelical
@@ -1,12 +1,12 @@
1
- const test = require('ava')
2
- const { TAU } = require('../../maths/constants')
3
- const { geom2, geom3 } = require('../../geometries')
4
- const { circle } = require('../../primitives')
1
+ import test from 'ava'
2
+ import { TAU } from '../../maths/constants.js'
3
+ import { geom2, geom3 } from '../../geometries/index.js'
4
+ import { circle } from '../../primitives/index.js'
5
5
 
6
- const { extrudeHelical } = require('./index')
6
+ import { extrudeHelical } from './index.js'
7
7
 
8
8
  test('extrudeHelical: (defaults) extruding of a geom2 produces an expected geom3', (t) => {
9
- const geometry2 = geom2.fromPoints([[10, 8], [10, -8], [26, -8], [26, 8]])
9
+ const geometry2 = geom2.create([[[10, 8], [10, -8], [26, -8], [26, 8]]])
10
10
 
11
11
  const geometry3 = extrudeHelical({}, geometry2)
12
12
  t.notThrows(() => geom3.validate(geometry3))
@@ -1,7 +1,5 @@
1
- import { Path2, Geom2, Geom3 } from '../../geometries/types'
2
- import RecursiveArray from '../../utils/recursiveArray'
3
-
4
- export default extrudeLinear
1
+ import type { Path2, Geom2, Geom3 } from '../../geometries/types.d.ts'
2
+ import type { RecursiveArray } from '../../utils/recursiveArray.d.ts'
5
3
 
6
4
  export interface ExtrudeLinearOptions {
7
5
  height?: number
@@ -11,5 +9,5 @@ export interface ExtrudeLinearOptions {
11
9
 
12
10
  type Geometry = Path2 | Geom2
13
11
 
14
- declare function extrudeLinear(options: ExtrudeLinearOptions, geometry: Geometry): Geom3
15
- declare function extrudeLinear(options: ExtrudeLinearOptions, ...geometries: RecursiveArray<Geometry>): Geom3
12
+ export function extrudeLinear(options: ExtrudeLinearOptions, geometry: Geometry): Geom3
13
+ export function extrudeLinear(options: ExtrudeLinearOptions, ...geometries: RecursiveArray<Geometry>): Geom3
@@ -1,19 +1,17 @@
1
- const flatten = require('../../utils/flatten')
1
+ import * as geom2 from '../../geometries/geom2/index.js'
2
+ import * as path2 from '../../geometries/path2/index.js'
2
3
 
3
- const geom2 = require('../../geometries/geom2')
4
- const path2 = require('../../geometries/path2')
5
-
6
- const extrudeLinearGeom2 = require('./extrudeLinearGeom2')
7
- const extrudeLinearPath2 = require('./extrudeLinearPath2')
4
+ import { extrudeLinearGeom2 } from './extrudeLinearGeom2.js'
5
+ import { extrudeLinearPath2 } from './extrudeLinearPath2.js'
8
6
 
9
7
  /**
10
8
  * Extrude the given geometry in an upward linear direction using the given options.
11
9
  * Accepts path2 or geom2 objects as input. Paths must be closed.
12
10
  *
13
- * @param {Object} options - options for extrude
14
- * @param {Number} [options.height=1] the height of the extrusion
15
- * @param {Number} [options.twistAngle=0] the final rotation (RADIANS) about the origin of the shape (if any)
16
- * @param {Integer} [options.twistSteps=1] the resolution of the twist about the axis (if any)
11
+ * @param {object} options - options for extrude
12
+ * @param {number} [options.height=1] the height of the extrusion
13
+ * @param {number} [options.twistAngle=0] the final rotation (RADIANS) about the origin of the shape (if any)
14
+ * @param {number} [options.twistSteps=1] the resolution of the twist about the axis (if any)
17
15
  * @param {...Object} objects - the geometries to extrude
18
16
  * @return {Object|Array} the extruded geometry, or a list of extruded geometry
19
17
  * @alias module:modeling/extrusions.extrudeLinear
@@ -21,7 +19,7 @@ const extrudeLinearPath2 = require('./extrudeLinearPath2')
21
19
  * @example
22
20
  * let myshape = extrudeLinear({height: 10}, rectangle({size: [20, 25]}))
23
21
  */
24
- const extrudeLinear = (options, ...objects) => {
22
+ export const extrudeLinear = (options, ...objects) => {
25
23
  const defaults = {
26
24
  height: 1,
27
25
  twistAngle: 0,
@@ -30,18 +28,14 @@ const extrudeLinear = (options, ...objects) => {
30
28
  }
31
29
  const { height, twistAngle, twistSteps, repair } = Object.assign({ }, defaults, options)
32
30
 
33
- objects = flatten(objects)
34
- if (objects.length === 0) throw new Error('wrong number of arguments')
35
-
36
31
  options = { offset: [0, 0, height], twistAngle, twistSteps, repair }
37
32
 
38
33
  const results = objects.map((object) => {
39
34
  if (path2.isA(object)) return extrudeLinearPath2(options, object)
40
35
  if (geom2.isA(object)) return extrudeLinearGeom2(options, object)
41
36
  // if (geom3.isA(object)) return geom3.extrude(options, object)
37
+ if (Array.isArray(object)) return extrudeLinear(options, ...object)
42
38
  return object
43
39
  })
44
40
  return results.length === 1 ? results[0] : results
45
41
  }
46
-
47
- module.exports = extrudeLinear