@math.gl/geometry 5.0.0-alpha.2 → 5.0.0-alpha.20

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 (381) hide show
  1. package/LICENSE +97 -49
  2. package/README.md +16 -1
  3. package/THIRD-PARTY-NOTICES.md +18 -0
  4. package/dist/culling/constants.d.ts +3 -0
  5. package/dist/culling/constants.d.ts.map +1 -0
  6. package/dist/culling/constants.js +5 -0
  7. package/dist/culling/constants.js.map +1 -0
  8. package/dist/culling/index.cjs +2014 -0
  9. package/dist/culling/index.cjs.map +6 -0
  10. package/dist/culling/index.d.ts +29 -0
  11. package/dist/culling/index.d.ts.map +1 -0
  12. package/dist/culling/index.js +23 -0
  13. package/dist/culling/index.js.map +1 -0
  14. package/dist/culling/lib/algorithms/bounding-box-from-points.d.ts +15 -0
  15. package/dist/culling/lib/algorithms/bounding-box-from-points.d.ts.map +1 -0
  16. package/dist/culling/lib/algorithms/bounding-box-from-points.js +137 -0
  17. package/dist/culling/lib/algorithms/bounding-box-from-points.js.map +1 -0
  18. package/dist/culling/lib/algorithms/bounding-sphere-from-points.d.ts +14 -0
  19. package/dist/culling/lib/algorithms/bounding-sphere-from-points.d.ts.map +1 -0
  20. package/dist/culling/lib/algorithms/bounding-sphere-from-points.js +146 -0
  21. package/dist/culling/lib/algorithms/bounding-sphere-from-points.js.map +1 -0
  22. package/dist/culling/lib/algorithms/compute-eigen-decomposition.d.ts +37 -0
  23. package/dist/culling/lib/algorithms/compute-eigen-decomposition.d.ts.map +1 -0
  24. package/dist/culling/lib/algorithms/compute-eigen-decomposition.js +137 -0
  25. package/dist/culling/lib/algorithms/compute-eigen-decomposition.js.map +1 -0
  26. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.d.ts +7 -0
  27. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.d.ts.map +1 -0
  28. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.js +26 -0
  29. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.js.map +1 -0
  30. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +56 -0
  31. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.d.ts.map +1 -0
  32. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.js +116 -0
  33. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -0
  34. package/dist/culling/lib/bounding-volumes/bounding-sphere.d.ts +40 -0
  35. package/dist/culling/lib/bounding-volumes/bounding-sphere.d.ts.map +1 -0
  36. package/dist/culling/lib/bounding-volumes/bounding-sphere.js +123 -0
  37. package/dist/culling/lib/bounding-volumes/bounding-sphere.js.map +1 -0
  38. package/dist/culling/lib/bounding-volumes/bounding-volume.d.ts +30 -0
  39. package/dist/culling/lib/bounding-volumes/bounding-volume.d.ts.map +1 -0
  40. package/dist/culling/lib/bounding-volumes/bounding-volume.js +7 -0
  41. package/dist/culling/lib/bounding-volumes/bounding-volume.js.map +1 -0
  42. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.d.ts +62 -0
  43. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.d.ts.map +1 -0
  44. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.js +230 -0
  45. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.js.map +1 -0
  46. package/dist/culling/lib/culling-volume.d.ts +46 -0
  47. package/dist/culling/lib/culling-volume.d.ts.map +1 -0
  48. package/dist/culling/lib/culling-volume.js +126 -0
  49. package/dist/culling/lib/culling-volume.js.map +1 -0
  50. package/dist/culling/lib/perspective-frustum.d.ts +153 -0
  51. package/dist/culling/lib/perspective-frustum.d.ts.map +1 -0
  52. package/dist/culling/lib/perspective-frustum.js +191 -0
  53. package/dist/culling/lib/perspective-frustum.js.map +1 -0
  54. package/dist/culling/lib/perspective-off-center-frustum.d.ts +158 -0
  55. package/dist/culling/lib/perspective-off-center-frustum.d.ts.map +1 -0
  56. package/dist/culling/lib/perspective-off-center-frustum.js +276 -0
  57. package/dist/culling/lib/perspective-off-center-frustum.js.map +1 -0
  58. package/dist/culling/lib/plane.d.ts +35 -0
  59. package/dist/culling/lib/plane.d.ts.map +1 -0
  60. package/dist/culling/lib/plane.js +90 -0
  61. package/dist/culling/lib/plane.js.map +1 -0
  62. package/dist/culling/lib/ray.d.ts +13 -0
  63. package/dist/culling/lib/ray.d.ts.map +1 -0
  64. package/dist/culling/lib/ray.js +30 -0
  65. package/dist/culling/lib/ray.js.map +1 -0
  66. package/dist/culling/lib/shapes/box-shape.d.ts +19 -0
  67. package/dist/culling/lib/shapes/box-shape.d.ts.map +1 -0
  68. package/dist/culling/lib/shapes/box-shape.js +69 -0
  69. package/dist/culling/lib/shapes/box-shape.js.map +1 -0
  70. package/dist/culling/lib/shapes/capsule-shape.d.ts +23 -0
  71. package/dist/culling/lib/shapes/capsule-shape.d.ts.map +1 -0
  72. package/dist/culling/lib/shapes/capsule-shape.js +151 -0
  73. package/dist/culling/lib/shapes/capsule-shape.js.map +1 -0
  74. package/dist/culling/lib/shapes/cylinder-shape.d.ts +22 -0
  75. package/dist/culling/lib/shapes/cylinder-shape.d.ts.map +1 -0
  76. package/dist/culling/lib/shapes/cylinder-shape.js +99 -0
  77. package/dist/culling/lib/shapes/cylinder-shape.js.map +1 -0
  78. package/dist/culling/lib/shapes/implicit-shape.d.ts +56 -0
  79. package/dist/culling/lib/shapes/implicit-shape.d.ts.map +1 -0
  80. package/dist/culling/lib/shapes/implicit-shape.js +142 -0
  81. package/dist/culling/lib/shapes/implicit-shape.js.map +1 -0
  82. package/dist/culling/lib/shapes/plane-shape.d.ts +27 -0
  83. package/dist/culling/lib/shapes/plane-shape.d.ts.map +1 -0
  84. package/dist/culling/lib/shapes/plane-shape.js +71 -0
  85. package/dist/culling/lib/shapes/plane-shape.js.map +1 -0
  86. package/dist/culling/lib/shapes/sphere-shape.d.ts +18 -0
  87. package/dist/culling/lib/shapes/sphere-shape.d.ts.map +1 -0
  88. package/dist/culling/lib/shapes/sphere-shape.js +43 -0
  89. package/dist/culling/lib/shapes/sphere-shape.js.map +1 -0
  90. package/dist/culling/oriented-box-2d.cjs +73 -0
  91. package/dist/culling/oriented-box-2d.cjs.map +6 -0
  92. package/dist/culling/oriented-box-2d.d.ts +22 -0
  93. package/dist/culling/oriented-box-2d.d.ts.map +1 -0
  94. package/dist/culling/oriented-box-2d.js +86 -0
  95. package/dist/culling/oriented-box-2d.js.map +1 -0
  96. package/dist/culling/queries.cjs +161 -0
  97. package/dist/culling/queries.cjs.map +6 -0
  98. package/dist/culling/queries.d.ts +20 -0
  99. package/dist/culling/queries.d.ts.map +1 -0
  100. package/dist/culling/queries.js +139 -0
  101. package/dist/culling/queries.js.map +1 -0
  102. package/dist/curves/bezier-curves.d.ts +18 -0
  103. package/dist/curves/bezier-curves.d.ts.map +1 -0
  104. package/dist/curves/bezier-curves.js +54 -0
  105. package/dist/curves/bezier-curves.js.map +1 -0
  106. package/dist/curves/catmull-rom-curve.d.ts +15 -0
  107. package/dist/curves/catmull-rom-curve.d.ts.map +1 -0
  108. package/dist/curves/catmull-rom-curve.js +77 -0
  109. package/dist/curves/catmull-rom-curve.js.map +1 -0
  110. package/dist/curves/curve-arc-length.d.ts +17 -0
  111. package/dist/curves/curve-arc-length.d.ts.map +1 -0
  112. package/dist/curves/curve-arc-length.js +58 -0
  113. package/dist/curves/curve-arc-length.js.map +1 -0
  114. package/dist/curves/curve.d.ts +23 -0
  115. package/dist/curves/curve.d.ts.map +1 -0
  116. package/dist/curves/curve.js +77 -0
  117. package/dist/curves/curve.js.map +1 -0
  118. package/dist/curves/hermite-curve.d.ts +9 -0
  119. package/dist/curves/hermite-curve.d.ts.map +1 -0
  120. package/dist/curves/hermite-curve.js +24 -0
  121. package/dist/curves/hermite-curve.js.map +1 -0
  122. package/dist/curves/index.cjs +293 -0
  123. package/dist/curves/index.cjs.map +6 -0
  124. package/dist/curves/index.d.ts +8 -0
  125. package/dist/curves/index.d.ts.map +1 -0
  126. package/dist/curves/index.js +9 -0
  127. package/dist/curves/index.js.map +1 -0
  128. package/dist/geometries/box-geometry.js +1 -1
  129. package/dist/geometries/box-geometry.js.map +1 -1
  130. package/dist/geometries/capsule-geometry.js +1 -1
  131. package/dist/geometries/capsule-geometry.js.map +1 -1
  132. package/dist/geometries/cylinder-geometry.js +1 -1
  133. package/dist/geometries/cylinder-geometry.js.map +1 -1
  134. package/dist/geometries/geometry-helpers.js +1 -1
  135. package/dist/geometries/geometry-helpers.js.map +1 -1
  136. package/dist/geometries/ico-sphere-geometry.js +1 -1
  137. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  138. package/dist/geometries/plane-geometry.js +1 -1
  139. package/dist/geometries/plane-geometry.js.map +1 -1
  140. package/dist/geometries/primitive-mesh-builder.d.ts +24 -0
  141. package/dist/geometries/primitive-mesh-builder.d.ts.map +1 -0
  142. package/dist/geometries/primitive-mesh-builder.js +74 -0
  143. package/dist/geometries/primitive-mesh-builder.js.map +1 -0
  144. package/dist/geometries/prism-geometry.d.ts +13 -0
  145. package/dist/geometries/prism-geometry.d.ts.map +1 -0
  146. package/dist/geometries/prism-geometry.js +34 -0
  147. package/dist/geometries/prism-geometry.js.map +1 -0
  148. package/dist/geometries/ring-geometry.d.ts +15 -0
  149. package/dist/geometries/ring-geometry.d.ts.map +1 -0
  150. package/dist/geometries/ring-geometry.js +64 -0
  151. package/dist/geometries/ring-geometry.js.map +1 -0
  152. package/dist/geometries/sphere-geometry.js +1 -1
  153. package/dist/geometries/sphere-geometry.js.map +1 -1
  154. package/dist/geometries/surface-of-revolution.js +1 -1
  155. package/dist/geometries/surface-of-revolution.js.map +1 -1
  156. package/dist/geometries/truncated-cone-geometry.js +1 -1
  157. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  158. package/dist/index.cjs +290 -9
  159. package/dist/index.cjs.map +3 -3
  160. package/dist/index.d.ts +6 -0
  161. package/dist/index.d.ts.map +1 -1
  162. package/dist/index.js +4 -1
  163. package/dist/index.js.map +1 -1
  164. package/dist/lib/geometry-utils.js +1 -1
  165. package/dist/lib/geometry-utils.js.map +1 -1
  166. package/dist/lib/geometry.d.ts +1 -1
  167. package/dist/lib/geometry.d.ts.map +1 -1
  168. package/dist/lib/geometry.js +1 -1
  169. package/dist/lib/geometry.js.map +1 -1
  170. package/dist/lib/hinge-tree.d.ts +33 -0
  171. package/dist/lib/hinge-tree.d.ts.map +1 -0
  172. package/dist/lib/hinge-tree.js +144 -0
  173. package/dist/lib/hinge-tree.js.map +1 -0
  174. package/dist/parametric/lathe-geometry.d.ts +14 -0
  175. package/dist/parametric/lathe-geometry.d.ts.map +1 -0
  176. package/dist/parametric/lathe-geometry.js +48 -0
  177. package/dist/parametric/lathe-geometry.js.map +1 -0
  178. package/dist/parametric/parametric-geometry.d.ts +20 -0
  179. package/dist/parametric/parametric-geometry.d.ts.map +1 -0
  180. package/dist/parametric/parametric-geometry.js +88 -0
  181. package/dist/parametric/parametric-geometry.js.map +1 -0
  182. package/dist/parametric/torus-geometry.d.ts +19 -0
  183. package/dist/parametric/torus-geometry.d.ts.map +1 -0
  184. package/dist/parametric/torus-geometry.js +89 -0
  185. package/dist/parametric/torus-geometry.js.map +1 -0
  186. package/dist/parametric.cjs +328 -0
  187. package/dist/parametric.cjs.map +6 -0
  188. package/dist/parametric.d.ts +7 -0
  189. package/dist/parametric.d.ts.map +1 -0
  190. package/dist/parametric.js +7 -0
  191. package/dist/parametric.js.map +1 -0
  192. package/dist/polygon/cut-by-grid.d.ts +24 -0
  193. package/dist/polygon/cut-by-grid.d.ts.map +1 -0
  194. package/dist/polygon/cut-by-grid.js +221 -0
  195. package/dist/polygon/cut-by-grid.js.map +1 -0
  196. package/dist/polygon/cut-by-mercator-bounds.d.ts +17 -0
  197. package/dist/polygon/cut-by-mercator-bounds.d.ts.map +1 -0
  198. package/dist/polygon/cut-by-mercator-bounds.js +149 -0
  199. package/dist/polygon/cut-by-mercator-bounds.js.map +1 -0
  200. package/dist/polygon/earcut.d.ts +13 -0
  201. package/dist/polygon/earcut.d.ts.map +1 -0
  202. package/dist/polygon/earcut.js +627 -0
  203. package/dist/polygon/earcut.js.map +1 -0
  204. package/dist/polygon/index.cjs +1437 -0
  205. package/dist/polygon/index.cjs.map +6 -0
  206. package/dist/polygon/index.d.ts +12 -0
  207. package/dist/polygon/index.d.ts.map +1 -0
  208. package/dist/polygon/index.js +12 -0
  209. package/dist/polygon/index.js.map +1 -0
  210. package/dist/polygon/lineclip.d.ts +31 -0
  211. package/dist/polygon/lineclip.d.ts.map +1 -0
  212. package/dist/polygon/lineclip.js +184 -0
  213. package/dist/polygon/lineclip.js.map +1 -0
  214. package/dist/polygon/polygon-utils.d.ts +103 -0
  215. package/dist/polygon/polygon-utils.d.ts.map +1 -0
  216. package/dist/polygon/polygon-utils.js +155 -0
  217. package/dist/polygon/polygon-utils.js.map +1 -0
  218. package/dist/polygon/polygon.d.ts +41 -0
  219. package/dist/polygon/polygon.d.ts.map +1 -0
  220. package/dist/polygon/polygon.js +76 -0
  221. package/dist/polygon/polygon.js.map +1 -0
  222. package/dist/polygon/subdivide-polyline.d.ts +56 -0
  223. package/dist/polygon/subdivide-polyline.d.ts.map +1 -0
  224. package/dist/polygon/subdivide-polyline.js +141 -0
  225. package/dist/polygon/subdivide-polyline.js.map +1 -0
  226. package/dist/polygon/subdivide-triangle-mesh.d.ts +68 -0
  227. package/dist/polygon/subdivide-triangle-mesh.d.ts.map +1 -0
  228. package/dist/polygon/subdivide-triangle-mesh.js +228 -0
  229. package/dist/polygon/subdivide-triangle-mesh.js.map +1 -0
  230. package/dist/polygon/utils.d.ts +5 -0
  231. package/dist/polygon/utils.d.ts.map +1 -0
  232. package/dist/polygon/utils.js +38 -0
  233. package/dist/polygon/utils.js.map +1 -0
  234. package/dist/spatial-index/box-index.cjs +328 -0
  235. package/dist/spatial-index/box-index.cjs.map +6 -0
  236. package/dist/spatial-index/box-index.d.ts +65 -0
  237. package/dist/spatial-index/box-index.d.ts.map +1 -0
  238. package/dist/spatial-index/box-index.js +263 -0
  239. package/dist/spatial-index/box-index.js.map +1 -0
  240. package/dist/spatial-index/index.cjs +494 -0
  241. package/dist/spatial-index/index.cjs.map +6 -0
  242. package/dist/spatial-index/index.d.ts +5 -0
  243. package/dist/spatial-index/index.d.ts.map +1 -0
  244. package/dist/spatial-index/index.js +6 -0
  245. package/dist/spatial-index/index.js.map +1 -0
  246. package/dist/spatial-index/triangle-bvh.d.ts +53 -0
  247. package/dist/spatial-index/triangle-bvh.d.ts.map +1 -0
  248. package/dist/spatial-index/triangle-bvh.js +102 -0
  249. package/dist/spatial-index/triangle-bvh.js.map +1 -0
  250. package/dist/utils/attribute-compression.d.ts +50 -0
  251. package/dist/utils/attribute-compression.d.ts.map +1 -0
  252. package/dist/utils/attribute-compression.js +186 -0
  253. package/dist/utils/attribute-compression.js.map +1 -0
  254. package/dist/utils/attribute-iterator.d.ts +8 -0
  255. package/dist/utils/attribute-iterator.d.ts.map +1 -0
  256. package/dist/utils/attribute-iterator.js +25 -0
  257. package/dist/utils/attribute-iterator.js.map +1 -0
  258. package/dist/utils/compute-vertex-normals.d.ts +4 -0
  259. package/dist/utils/compute-vertex-normals.d.ts.map +1 -0
  260. package/dist/utils/compute-vertex-normals.js +54 -0
  261. package/dist/utils/compute-vertex-normals.js.map +1 -0
  262. package/dist/utils/constants.d.ts +52 -0
  263. package/dist/utils/constants.d.ts.map +1 -0
  264. package/dist/utils/constants.js +39 -0
  265. package/dist/utils/constants.js.map +1 -0
  266. package/dist/utils/coordinates.d.ts +3 -0
  267. package/dist/utils/coordinates.d.ts.map +1 -0
  268. package/dist/utils/coordinates.js +8 -0
  269. package/dist/utils/coordinates.js.map +1 -0
  270. package/dist/utils/geometry.d.ts +20 -0
  271. package/dist/utils/geometry.d.ts.map +1 -0
  272. package/dist/utils/geometry.js +31 -0
  273. package/dist/utils/geometry.js.map +1 -0
  274. package/dist/utils/gl-type.d.ts +17 -0
  275. package/dist/utils/gl-type.d.ts.map +1 -0
  276. package/dist/utils/gl-type.js +69 -0
  277. package/dist/utils/gl-type.js.map +1 -0
  278. package/dist/utils/index.cjs +965 -0
  279. package/dist/utils/index.cjs.map +6 -0
  280. package/dist/utils/index.d.ts +18 -0
  281. package/dist/utils/index.d.ts.map +1 -0
  282. package/dist/utils/index.js +16 -0
  283. package/dist/utils/index.js.map +1 -0
  284. package/dist/utils/interpolate-packed-attributes.cjs +176 -0
  285. package/dist/utils/interpolate-packed-attributes.cjs.map +6 -0
  286. package/dist/utils/interpolate-packed-attributes.d.ts +43 -0
  287. package/dist/utils/interpolate-packed-attributes.d.ts.map +1 -0
  288. package/dist/utils/interpolate-packed-attributes.js +192 -0
  289. package/dist/utils/interpolate-packed-attributes.js.map +1 -0
  290. package/dist/utils/mesh-processing.d.ts +18 -0
  291. package/dist/utils/mesh-processing.d.ts.map +1 -0
  292. package/dist/utils/mesh-processing.js +300 -0
  293. package/dist/utils/mesh-processing.js.map +1 -0
  294. package/dist/utils/primitive-iterator.d.ts +21 -0
  295. package/dist/utils/primitive-iterator.d.ts.map +1 -0
  296. package/dist/utils/primitive-iterator.js +117 -0
  297. package/dist/utils/primitive-iterator.js.map +1 -0
  298. package/dist/utils/rgb565.d.ts +5 -0
  299. package/dist/utils/rgb565.d.ts.map +1 -0
  300. package/dist/utils/rgb565.js +24 -0
  301. package/dist/utils/rgb565.js.map +1 -0
  302. package/dist/utils/typed-array-utils.d.ts +3 -0
  303. package/dist/utils/typed-array-utils.d.ts.map +1 -0
  304. package/dist/utils/typed-array-utils.js +16 -0
  305. package/dist/utils/typed-array-utils.js.map +1 -0
  306. package/package.json +57 -4
  307. package/src/culling/constants.ts +6 -0
  308. package/src/culling/index.ts +45 -0
  309. package/src/culling/lib/algorithms/bounding-box-from-points.ts +174 -0
  310. package/src/culling/lib/algorithms/bounding-sphere-from-points.ts +175 -0
  311. package/src/culling/lib/algorithms/compute-eigen-decomposition.ts +171 -0
  312. package/src/culling/lib/algorithms/oriented-bounding-box-quaternion.ts +32 -0
  313. package/src/culling/lib/bounding-volumes/axis-aligned-bounding-box.ts +153 -0
  314. package/src/culling/lib/bounding-volumes/bounding-sphere.ts +154 -0
  315. package/src/culling/lib/bounding-volumes/bounding-volume.ts +38 -0
  316. package/src/culling/lib/bounding-volumes/oriented-bounding-box.ts +320 -0
  317. package/src/culling/lib/culling-volume.ts +163 -0
  318. package/src/culling/lib/perspective-frustum.ts +288 -0
  319. package/src/culling/lib/perspective-off-center-frustum.ts +381 -0
  320. package/src/culling/lib/plane.ts +118 -0
  321. package/src/culling/lib/ray.ts +33 -0
  322. package/src/culling/lib/shapes/box-shape.ts +78 -0
  323. package/src/culling/lib/shapes/capsule-shape.ts +232 -0
  324. package/src/culling/lib/shapes/cylinder-shape.ts +133 -0
  325. package/src/culling/lib/shapes/implicit-shape.ts +209 -0
  326. package/src/culling/lib/shapes/plane-shape.ts +78 -0
  327. package/src/culling/lib/shapes/sphere-shape.ts +60 -0
  328. package/src/culling/oriented-box-2d.ts +165 -0
  329. package/src/culling/queries.ts +155 -0
  330. package/src/curves/bezier-curves.ts +62 -0
  331. package/src/curves/catmull-rom-curve.ts +89 -0
  332. package/src/curves/curve-arc-length.ts +70 -0
  333. package/src/curves/curve.ts +96 -0
  334. package/src/curves/hermite-curve.ts +34 -0
  335. package/src/curves/index.ts +15 -0
  336. package/src/geometries/box-geometry.ts +1 -1
  337. package/src/geometries/capsule-geometry.ts +1 -1
  338. package/src/geometries/cylinder-geometry.ts +1 -1
  339. package/src/geometries/geometry-helpers.ts +1 -1
  340. package/src/geometries/ico-sphere-geometry.ts +1 -1
  341. package/src/geometries/plane-geometry.ts +1 -1
  342. package/src/geometries/primitive-mesh-builder.ts +84 -0
  343. package/src/geometries/prism-geometry.ts +57 -0
  344. package/src/geometries/ring-geometry.ts +102 -0
  345. package/src/geometries/sphere-geometry.ts +1 -1
  346. package/src/geometries/surface-of-revolution.ts +1 -1
  347. package/src/geometries/truncated-cone-geometry.ts +1 -1
  348. package/src/index.ts +10 -1
  349. package/src/lib/geometry-utils.ts +2 -2
  350. package/src/lib/geometry.ts +2 -2
  351. package/src/lib/hinge-tree.ts +170 -0
  352. package/src/parametric/lathe-geometry.ts +70 -0
  353. package/src/parametric/parametric-geometry.ts +118 -0
  354. package/src/parametric/torus-geometry.ts +118 -0
  355. package/src/parametric.ts +9 -0
  356. package/src/polygon/cut-by-grid.ts +313 -0
  357. package/src/polygon/cut-by-mercator-bounds.ts +204 -0
  358. package/src/polygon/earcut.ts +798 -0
  359. package/src/polygon/index.ts +35 -0
  360. package/src/polygon/lineclip.ts +218 -0
  361. package/src/polygon/polygon-utils.ts +273 -0
  362. package/src/polygon/polygon.ts +105 -0
  363. package/src/polygon/subdivide-polyline.ts +223 -0
  364. package/src/polygon/subdivide-triangle-mesh.ts +322 -0
  365. package/src/polygon/utils.ts +50 -0
  366. package/src/spatial-index/box-index.ts +343 -0
  367. package/src/spatial-index/index.ts +18 -0
  368. package/src/spatial-index/triangle-bvh.ts +162 -0
  369. package/src/utils/attribute-compression.ts +234 -0
  370. package/src/utils/attribute-iterator.ts +28 -0
  371. package/src/utils/compute-vertex-normals.ts +63 -0
  372. package/src/utils/constants.ts +42 -0
  373. package/src/utils/coordinates.ts +8 -0
  374. package/src/utils/geometry.ts +49 -0
  375. package/src/utils/gl-type.ts +87 -0
  376. package/src/utils/index.ts +55 -0
  377. package/src/utils/interpolate-packed-attributes.ts +284 -0
  378. package/src/utils/mesh-processing.ts +377 -0
  379. package/src/utils/primitive-iterator.ts +145 -0
  380. package/src/utils/rgb565.ts +26 -0
  381. package/src/utils/typed-array-utils.ts +16 -0
@@ -0,0 +1,35 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ export {Polygon} from './polygon';
6
+
7
+ export {
8
+ getPolygonSignedArea,
9
+ getPolygonWindingDirection,
10
+ forEachSegmentInPolygon,
11
+ modifyPolygonWindingDirection
12
+ } from './polygon-utils';
13
+ export type {PolygonWinding, WindingDirection} from './polygon-utils';
14
+
15
+ export {earcut} from './earcut';
16
+
17
+ export {clipPolygon, clipPolyline} from './lineclip';
18
+
19
+ export {cutPolygonByGrid, cutPolylineByGrid} from './cut-by-grid';
20
+
21
+ export {cutPolylineByMercatorBounds, cutPolygonByMercatorBounds} from './cut-by-mercator-bounds';
22
+
23
+ export {subdividePolyline} from './subdivide-polyline';
24
+ export type {
25
+ SubdividePolylineOptions,
26
+ SubdividedPolyline,
27
+ PolylineEdgeSampler
28
+ } from './subdivide-polyline';
29
+
30
+ export {subdivideTriangleMesh} from './subdivide-triangle-mesh';
31
+ export type {
32
+ TriangleMesh,
33
+ SubdivideTriangleMeshOptions,
34
+ SubdividedTriangleMesh
35
+ } from './subdivide-triangle-mesh';
@@ -0,0 +1,218 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT AND ISC
3
+ // SPDX-FileCopyrightText: Copyright (c) 2015, Mapbox
4
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
5
+ // SPDX-FileComment: Adapted from Mapbox lineclip for flat arrays and 3D positions. Original ISC notice retained below.
6
+
7
+ /*
8
+ Adapted from https://github.com/mapbox/lineclip to work with flat arrays
9
+ and 3d positions
10
+
11
+ ISC License
12
+
13
+ Copyright (c) 2015, Mapbox
14
+
15
+ Permission to use, copy, modify, and/or distribute this software for any purpose
16
+ with or without fee is hereby granted, provided that the above copyright notice
17
+ and this permission notice appear in all copies.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
23
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
24
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25
+ THIS SOFTWARE.
26
+
27
+ */
28
+
29
+ /* eslint-disable max-statements, max-depth, complexity */
30
+
31
+ import {push, copy, getPointAtIndex} from './utils';
32
+ import type {NumericArray} from '@math.gl/core';
33
+
34
+ export type BoundingBox = [number, number, number, number];
35
+
36
+ /**
37
+ * Cohen-Sutherland line clipping algorithm, adapted to efficiently
38
+ * handle polylines rather than just segments
39
+ */
40
+ export function clipPolyline(
41
+ positions: Readonly<NumericArray>,
42
+ bbox: BoundingBox,
43
+ options?: {
44
+ size?: number;
45
+ startIndex?: number;
46
+ endIndex?: number;
47
+ }
48
+ ): number[][] {
49
+ const {size = 2, startIndex = 0, endIndex = positions.length} = options || {};
50
+ const numPoints = (endIndex - startIndex) / size;
51
+ const result: number[][] = [];
52
+ let part: number[] = [];
53
+ let a: number[];
54
+ let b: number[];
55
+ let codeA: number = -1;
56
+ let codeB: number;
57
+ let lastCode: number;
58
+
59
+ for (let i = 1; i < numPoints; i++) {
60
+ a = getPointAtIndex(positions, i - 1, size, startIndex, a);
61
+ b = getPointAtIndex(positions, i, size, startIndex, b);
62
+ if (codeA < 0) {
63
+ codeA = bitCode(a, bbox);
64
+ }
65
+ codeB = lastCode = bitCode(b, bbox);
66
+
67
+ // eslint-disable-next-line no-constant-condition
68
+ while (true) {
69
+ if (!(codeA | codeB)) {
70
+ // accept
71
+ push(part, a);
72
+
73
+ if (codeB !== lastCode) {
74
+ // segment went outside
75
+ push(part, b);
76
+
77
+ if (i < numPoints - 1) {
78
+ // start a new line
79
+ result.push(part);
80
+ part = [];
81
+ }
82
+ } else if (i === numPoints - 1) {
83
+ push(part, b);
84
+ }
85
+ break;
86
+ } else if (codeA & codeB) {
87
+ // trivial reject
88
+ break;
89
+ } else if (codeA) {
90
+ // a outside, intersect with clip edge
91
+ intersect(a, b, codeA, bbox, a);
92
+ codeA = bitCode(a, bbox);
93
+ } else {
94
+ // b outside
95
+ intersect(a, b, codeB, bbox, b);
96
+ codeB = bitCode(b, bbox);
97
+ }
98
+ }
99
+
100
+ codeA = lastCode;
101
+ }
102
+
103
+ if (part.length) result.push(part);
104
+
105
+ return result;
106
+ }
107
+
108
+ /**
109
+ * Sutherland-Hodgeman polygon clipping algorithm
110
+ * polygon must be closed (first vertex == last vertex)
111
+ */
112
+ export function clipPolygon(
113
+ positions: Readonly<NumericArray>,
114
+ bbox: BoundingBox,
115
+ options?: {
116
+ size?: number;
117
+ startIndex?: number;
118
+ endIndex?: number;
119
+ }
120
+ ): number[] {
121
+ const {size = 2, endIndex = positions.length} = options || {};
122
+ let {startIndex = 0} = options || {};
123
+ let numPoints = (endIndex - startIndex) / size;
124
+ let result: number[];
125
+ let p: number[];
126
+ let prev: number[];
127
+ let inside: boolean;
128
+ let prevInside: boolean;
129
+
130
+ // clip against each side of the clip rectangle
131
+ for (let edge = 1; edge <= 8; edge *= 2) {
132
+ result = [];
133
+ prev = getPointAtIndex(positions, numPoints - 1, size, startIndex, prev);
134
+ prevInside = !(bitCode(prev, bbox) & edge);
135
+
136
+ for (let i = 0; i < numPoints; i++) {
137
+ p = getPointAtIndex(positions, i, size, startIndex, p);
138
+ inside = !(bitCode(p, bbox) & edge);
139
+
140
+ // if segment goes through the clip window, add an intersection
141
+ if (inside !== prevInside) push(result, intersect(prev, p, edge, bbox));
142
+
143
+ if (inside) push(result, p); // add a point if it's inside
144
+
145
+ copy(prev, p);
146
+ prevInside = inside;
147
+ }
148
+
149
+ // close loop
150
+ positions = result;
151
+ startIndex = 0;
152
+ numPoints = result.length / size;
153
+
154
+ if (!numPoints) break;
155
+ }
156
+
157
+ return result;
158
+ }
159
+
160
+ /** intersect a segment against one of the 4 lines that make up the bbox */
161
+
162
+ export function intersect(
163
+ a: number[],
164
+ b: number[],
165
+ edge: number,
166
+ bbox: BoundingBox,
167
+ out: number[] = []
168
+ ): number[] {
169
+ let t;
170
+ // Forces out[snapI] to be on the bbox edge
171
+ // Interpolation introduces precision issue which may cause lineclip to be
172
+ // stuck in an infinite loop
173
+ let snap: number;
174
+ if (edge & 8) {
175
+ // top
176
+ t = (bbox[3] - a[1]) / (b[1] - a[1]);
177
+ snap = 3;
178
+ } else if (edge & 4) {
179
+ // bottom
180
+ t = (bbox[1] - a[1]) / (b[1] - a[1]);
181
+ snap = 1;
182
+ } else if (edge & 2) {
183
+ // right
184
+ t = (bbox[2] - a[0]) / (b[0] - a[0]);
185
+ snap = 2;
186
+ } else if (edge & 1) {
187
+ // left
188
+ t = (bbox[0] - a[0]) / (b[0] - a[0]);
189
+ snap = 0;
190
+ } else {
191
+ return null;
192
+ }
193
+ for (let i = 0; i < a.length; i++) {
194
+ out[i] = (snap & 1) === i ? bbox[snap] : t * (b[i] - a[i]) + a[i];
195
+ }
196
+ return out;
197
+ }
198
+
199
+ /**
200
+ * bit code reflects the point position relative to the bbox:
201
+ * left mid right
202
+ * top 1001 1000 1010
203
+ * mid 0001 0000 0010
204
+ * bottom 0101 0100 0110
205
+ */
206
+ export function bitCode(p: number[], bbox: BoundingBox): number {
207
+ let code = 0;
208
+
209
+ if (p[0] < bbox[0]) code |= 1;
210
+ // left
211
+ else if (p[0] > bbox[2]) code |= 2; // right
212
+
213
+ if (p[1] < bbox[1]) code |= 4;
214
+ // bottom
215
+ else if (p[1] > bbox[3]) code |= 8; // top
216
+
217
+ return code;
218
+ }
@@ -0,0 +1,273 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT AND ISC
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ /* eslint-disable max-statements, max-depth, complexity, no-unused-expressions */
6
+
7
+ import {equals} from '@math.gl/core';
8
+ import type {NumericArray} from '@math.gl/core';
9
+
10
+ /** Direction in which a polygon's vertices are ordered. */
11
+ export type WindingDirection = 'clockwise' | 'counter-clockwise' | 'none';
12
+
13
+ /** A non-degenerate polygon winding direction. */
14
+ export type PolygonWinding = Exclude<WindingDirection, 'none'>;
15
+
16
+ /** Polygon representation where each point is represented as a separate array of positions. */
17
+ type PointsArray = NumericArray[];
18
+
19
+ /** Segment visitor callback type for polygons defined with flat arrays, */
20
+ type SegmentVisitorFlat = (
21
+ p1x: number,
22
+ p1y: number,
23
+ p2x: number,
24
+ p2y: number,
25
+ i1: number,
26
+ i2: number
27
+ ) => void;
28
+
29
+ /** Segment visitor callback type for polygons defined with array of points. */
30
+ export type SegmentVisitorPoints = (
31
+ p1: NumericArray,
32
+ p2: NumericArray,
33
+ i1: number,
34
+ i2: number
35
+ ) => void;
36
+
37
+ export type Plane2D = 'xy' | 'yz' | 'xz';
38
+
39
+ /** Parameters of a polygon. */
40
+ type PolygonParams = {
41
+ /**
42
+ * Start index of the polygon in the array of positions.
43
+ * @default `0`
44
+ */
45
+ start?: number;
46
+ /**
47
+ * End index of the polygon in the array of positions.
48
+ * @default number of positions
49
+ */
50
+ end?: number;
51
+ /**
52
+ * Size of a point, 2 (XZ) or 3 (XYZ). Affects only polygons stored in flat arrays.
53
+ * @default `2`
54
+ */
55
+ size?: number;
56
+ /**
57
+ * Indicates that the first point of the polygon is equal to the last point, and additional checks should be ommited.
58
+ */
59
+ isClosed?: boolean;
60
+ /**
61
+ * The 2D projection plane on which to calculate the area of a 3D polygon.
62
+ * @default `'xy'`
63
+ */
64
+ plane?: Plane2D;
65
+ };
66
+
67
+ /**
68
+ * Checks winding direction of the polygon and reverses the polygon in case of opposite winding direction.
69
+ * Note: points are modified in-place.
70
+ * @param points An array that represents points of the polygon.
71
+ * @param direction Requested winding direction.
72
+ * @param options Parameters of the polygon.
73
+ * @return Returns true if the winding direction was changed.
74
+ */
75
+ export function modifyPolygonWindingDirection(
76
+ points: NumericArray,
77
+ direction: PolygonWinding,
78
+ options: PolygonParams = {}
79
+ ): boolean {
80
+ const windingDirection = getPolygonWindingDirection(points, options);
81
+ if (windingDirection !== direction) {
82
+ reversePolygon(points, options);
83
+ return true;
84
+ }
85
+ return false;
86
+ }
87
+
88
+ /**
89
+ * Returns winding direction of the polygon.
90
+ * @param points An array that represents points of the polygon.
91
+ * @param options Parameters of the polygon.
92
+ * @returns Winding direction of the polygon.
93
+ */
94
+ export function getPolygonWindingDirection(
95
+ points: NumericArray,
96
+ options: PolygonParams = {}
97
+ ): WindingDirection {
98
+ return getWindingDirection(getPolygonSignedArea(points, options));
99
+ }
100
+
101
+ export const DimIndex: Record<string, number> = {
102
+ x: 0,
103
+ y: 1,
104
+ z: 2
105
+ } as const;
106
+
107
+ /**
108
+ * Returns signed area of the polygon.
109
+ * @param points An array that represents points of the polygon.
110
+ * @param options Parameters of the polygon.
111
+ * @returns Signed area of the polygon.
112
+ * https://en.wikipedia.org/wiki/Shoelace_formula
113
+ */
114
+ export function getPolygonSignedArea(points: NumericArray, options: PolygonParams = {}): number {
115
+ const {start = 0, end = points.length, plane = 'xy'} = options;
116
+ const dim = options.size || 2;
117
+ let area = 0;
118
+ const i0 = DimIndex[plane[0]];
119
+ const i1 = DimIndex[plane[1]];
120
+
121
+ for (let i = start, j = end - dim; i < end; i += dim) {
122
+ area += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
123
+ j = i;
124
+ }
125
+ return area / 2;
126
+ }
127
+
128
+ /**
129
+ * Calls the visitor callback for each segment in the polygon.
130
+ * @param points An array that represents points of the polygon
131
+ * @param visitor A callback to call for each segment.
132
+ * @param options Parameters of the polygon.
133
+ */
134
+ export function forEachSegmentInPolygon(
135
+ points: NumericArray,
136
+ visitor: SegmentVisitorFlat,
137
+ options: PolygonParams = {}
138
+ ): void {
139
+ const {start = 0, end = points.length, size = 2, isClosed} = options;
140
+
141
+ const numPoints = (end - start) / size;
142
+ for (let i = 0; i < numPoints - 1; ++i) {
143
+ visitor(
144
+ points[start + i * size],
145
+ points[start + i * size + 1],
146
+ points[start + (i + 1) * size],
147
+ points[start + (i + 1) * size + 1],
148
+ i,
149
+ i + 1
150
+ );
151
+ }
152
+
153
+ const endPointIndex = start + (numPoints - 1) * size;
154
+ const isClosedEx =
155
+ isClosed ||
156
+ (equals(points[start], points[endPointIndex]) &&
157
+ equals(points[start + 1], points[endPointIndex + 1]));
158
+
159
+ if (!isClosedEx) {
160
+ visitor(
161
+ points[endPointIndex],
162
+ points[endPointIndex + 1],
163
+ points[start],
164
+ points[start + 1],
165
+ numPoints - 1,
166
+ 0
167
+ );
168
+ }
169
+ }
170
+
171
+ function reversePolygon(
172
+ points: NumericArray,
173
+ options: {start?: number; end?: number; size?: number}
174
+ ): void {
175
+ const {start = 0, end = points.length, size = 2} = options;
176
+
177
+ const numPoints = (end - start) / size;
178
+ const numSwaps = Math.floor(numPoints / 2);
179
+ for (let i = 0; i < numSwaps; ++i) {
180
+ const b1 = start + i * size;
181
+ const b2 = start + (numPoints - 1 - i) * size;
182
+ for (let j = 0; j < size; ++j) {
183
+ const tmp = points[b1 + j];
184
+ points[b1 + j] = points[b2 + j];
185
+ points[b2 + j] = tmp;
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Checks winding direction of the polygon and reverses the polygon in case of opposite winding direction.
192
+ * Note: points are modified in-place.
193
+ * @param points Array of points that represent the polygon.
194
+ * @param direction Requested winding direction.
195
+ * @param options Parameters of the polygon.
196
+ * @return Returns true if the winding direction was changed.
197
+ */
198
+ export function modifyPolygonWindingDirectionPoints(
199
+ points: PointsArray,
200
+ direction: PolygonWinding,
201
+ options: PolygonParams = {}
202
+ ): boolean {
203
+ const currentDirection = getPolygonWindingDirectionPoints(points, options);
204
+ if (currentDirection !== direction) {
205
+ points.reverse();
206
+ return true;
207
+ }
208
+ return false;
209
+ }
210
+
211
+ /**
212
+ * Returns winding direction of the polygon.
213
+ * @param points Array of points that represent the polygon.
214
+ * @param options Parameters of the polygon.
215
+ * @returns Winding direction of the polygon.
216
+ */
217
+ export function getPolygonWindingDirectionPoints(
218
+ points: PointsArray,
219
+ options: PolygonParams = {}
220
+ ): WindingDirection {
221
+ return getWindingDirection(getPolygonSignedAreaPoints(points, options));
222
+ }
223
+
224
+ function getWindingDirection(signedArea: number): WindingDirection {
225
+ if (signedArea > 0) return 'clockwise';
226
+ if (signedArea < 0) return 'counter-clockwise';
227
+ return 'none';
228
+ }
229
+
230
+ /**
231
+ * Returns signed area of the polygon.
232
+ * @param points Array of points that represent the polygon.
233
+ * @param options Parameters of the polygon.
234
+ * @returns Signed area of the polygon.
235
+ */
236
+ export function getPolygonSignedAreaPoints(
237
+ points: PointsArray,
238
+ options: PolygonParams = {}
239
+ ): number {
240
+ // https://en.wikipedia.org/wiki/Shoelace_formula
241
+ const {start = 0, end = points.length, plane = 'xy'} = options;
242
+ let area = 0;
243
+ const i0 = DimIndex[plane[0]];
244
+ const i1 = DimIndex[plane[1]];
245
+
246
+ for (let i = start, j = end - 1; i < end; ++i) {
247
+ area += (points[i][i0] - points[j][i0]) * (points[i][i1] + points[j][i1]);
248
+ j = i;
249
+ }
250
+ return area / 2;
251
+ }
252
+
253
+ /**
254
+ * Calls visitor callback for each segment in the polygon.
255
+ * @param points Array of points that represent the polygon.
256
+ * @param visitor A callback to call for each segment.
257
+ * @param options Parameters of the polygon.
258
+ */
259
+ export function forEachSegmentInPolygonPoints(
260
+ points: PointsArray,
261
+ visitor: SegmentVisitorPoints,
262
+ options: PolygonParams = {}
263
+ ): void {
264
+ const {start = 0, end = points.length, isClosed} = options;
265
+ for (let i = start; i < end - 1; ++i) {
266
+ visitor(points[i], points[i + 1], i, i + 1);
267
+ }
268
+
269
+ const isClosedEx = isClosed || equals(points[end - 1], points[0]);
270
+ if (!isClosedEx) {
271
+ visitor(points[end - 1], points[0], end - 1, 0);
272
+ }
273
+ }
@@ -0,0 +1,105 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ /* eslint-disable no-undef, no-console */
6
+ import {isArray} from '@math.gl/core';
7
+ import type {PolygonWinding, SegmentVisitorPoints, WindingDirection} from './polygon-utils';
8
+ import type {NumericArray} from '@math.gl/core';
9
+
10
+ import {
11
+ getPolygonSignedArea,
12
+ forEachSegmentInPolygon,
13
+ modifyPolygonWindingDirection,
14
+ getPolygonSignedAreaPoints,
15
+ forEachSegmentInPolygonPoints,
16
+ modifyPolygonWindingDirectionPoints
17
+ } from './polygon-utils';
18
+
19
+ export type PolygonOptions = {
20
+ start?: number;
21
+ end?: number;
22
+ size?: number;
23
+ isClosed?: boolean;
24
+ };
25
+
26
+ export class Polygon {
27
+ points: NumericArray | number[][];
28
+ isFlatArray: boolean;
29
+ options: PolygonOptions;
30
+
31
+ constructor(points: NumericArray | number[][], options: PolygonOptions = {}) {
32
+ this.points = points;
33
+ this.isFlatArray = !isArray(points[0]);
34
+
35
+ this.options = {
36
+ start: options.start || 0,
37
+ end: options.end || points.length,
38
+ size: options.size || 2,
39
+ isClosed: options.isClosed
40
+ };
41
+
42
+ Object.freeze(this);
43
+ }
44
+
45
+ /**
46
+ * Returns signed area of the polygon.
47
+ * @returns Signed area of the polygon.
48
+ */
49
+ getSignedArea(): number {
50
+ if (this.isFlatArray) return getPolygonSignedArea(this.points as NumericArray, this.options);
51
+
52
+ return getPolygonSignedAreaPoints(this.points as number[][], this.options);
53
+ }
54
+
55
+ /**
56
+ * Returns absolute area of the polygon.
57
+ * @returns Absolute area of the polygon.
58
+ */
59
+ getArea(): number {
60
+ return Math.abs(this.getSignedArea());
61
+ }
62
+
63
+ /**
64
+ * Returns winding direction of the polygon.
65
+ * @returns `'clockwise'`, `'counter-clockwise'`, or `'none'` for a degenerate polygon.
66
+ */
67
+ getWindingDirection(): WindingDirection {
68
+ const signedArea = this.getSignedArea();
69
+ if (signedArea > 0) return 'clockwise';
70
+ if (signedArea < 0) return 'counter-clockwise';
71
+ return 'none';
72
+ }
73
+
74
+ /**
75
+ * Calls the visitor callback for each segment in the polygon.
76
+ * @param visitor A callback to call for each segment.
77
+ */
78
+ forEachSegment(visitor: SegmentVisitorPoints): void {
79
+ if (this.isFlatArray) {
80
+ forEachSegmentInPolygon(
81
+ this.points as NumericArray,
82
+ // eslint-disable-next-line max-params
83
+ (x1, y1, x2, y2, i1, i2) => {
84
+ // TODO @igorDykhta original visitor uses arrays for each point, but with flat arrays performance degrades if we allocate points for each segment
85
+ visitor([x1, y1], [x2, y2], i1, i2);
86
+ },
87
+ this.options
88
+ );
89
+ } else {
90
+ forEachSegmentInPolygonPoints(this.points as number[][], visitor, this.options);
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Checks winding direction of the polygon and reverses the polygon in case of opposite winding direction.
96
+ * @param direction Requested winding direction.
97
+ * @return Returns true if the winding direction was changed.
98
+ */
99
+ modifyWindingDirection(direction: PolygonWinding): boolean {
100
+ if (this.isFlatArray) {
101
+ return modifyPolygonWindingDirection(this.points as NumericArray, direction, this.options);
102
+ }
103
+ return modifyPolygonWindingDirectionPoints(this.points as number[][], direction, this.options);
104
+ }
105
+ }