@math.gl/geometry 5.0.0-alpha.9 → 5.0.0-beta.10

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 (457) hide show
  1. package/LICENSE +97 -49
  2. package/README.md +77 -1
  3. package/THIRD-PARTY-NOTICES.md +18 -0
  4. package/dist/color/color-lut-types.d.ts +16 -0
  5. package/dist/color/color-lut-types.d.ts.map +1 -0
  6. package/dist/color/color-lut-types.js +5 -0
  7. package/dist/color/color-lut-types.js.map +1 -0
  8. package/dist/color/index.cjs +132 -0
  9. package/dist/color/index.cjs.map +6 -0
  10. package/dist/color/index.d.ts +4 -0
  11. package/dist/color/index.d.ts.map +1 -0
  12. package/dist/color/index.js +5 -0
  13. package/dist/color/index.js.map +1 -0
  14. package/dist/color/sample-lut.d.ts +13 -0
  15. package/dist/color/sample-lut.d.ts.map +1 -0
  16. package/dist/color/sample-lut.js +132 -0
  17. package/dist/color/sample-lut.js.map +1 -0
  18. package/dist/culling/bounds.d.ts +20 -0
  19. package/dist/culling/bounds.d.ts.map +1 -0
  20. package/dist/culling/bounds.js +121 -0
  21. package/dist/culling/bounds.js.map +1 -0
  22. package/dist/culling/constants.d.ts +3 -0
  23. package/dist/culling/constants.d.ts.map +1 -0
  24. package/dist/culling/constants.js +5 -0
  25. package/dist/culling/constants.js.map +1 -0
  26. package/dist/culling/frustum-planes.d.ts +5 -0
  27. package/dist/culling/frustum-planes.d.ts.map +1 -0
  28. package/dist/culling/frustum-planes.js +37 -0
  29. package/dist/culling/frustum-planes.js.map +1 -0
  30. package/dist/culling/geometric-queries.d.ts +34 -0
  31. package/dist/culling/geometric-queries.d.ts.map +1 -0
  32. package/dist/culling/geometric-queries.js +208 -0
  33. package/dist/culling/geometric-queries.js.map +1 -0
  34. package/dist/culling/index.cjs +2560 -0
  35. package/dist/culling/index.cjs.map +6 -0
  36. package/dist/culling/index.d.ts +37 -0
  37. package/dist/culling/index.d.ts.map +1 -0
  38. package/dist/culling/index.js +29 -0
  39. package/dist/culling/index.js.map +1 -0
  40. package/dist/culling/lib/algorithms/bounding-box-from-points.d.ts +15 -0
  41. package/dist/culling/lib/algorithms/bounding-box-from-points.d.ts.map +1 -0
  42. package/dist/culling/lib/algorithms/bounding-box-from-points.js +137 -0
  43. package/dist/culling/lib/algorithms/bounding-box-from-points.js.map +1 -0
  44. package/dist/culling/lib/algorithms/bounding-sphere-from-points.d.ts +14 -0
  45. package/dist/culling/lib/algorithms/bounding-sphere-from-points.d.ts.map +1 -0
  46. package/dist/culling/lib/algorithms/bounding-sphere-from-points.js +146 -0
  47. package/dist/culling/lib/algorithms/bounding-sphere-from-points.js.map +1 -0
  48. package/dist/culling/lib/algorithms/compute-eigen-decomposition.d.ts +37 -0
  49. package/dist/culling/lib/algorithms/compute-eigen-decomposition.d.ts.map +1 -0
  50. package/dist/culling/lib/algorithms/compute-eigen-decomposition.js +137 -0
  51. package/dist/culling/lib/algorithms/compute-eigen-decomposition.js.map +1 -0
  52. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.d.ts +7 -0
  53. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.d.ts.map +1 -0
  54. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.js +26 -0
  55. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.js.map +1 -0
  56. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +56 -0
  57. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.d.ts.map +1 -0
  58. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.js +133 -0
  59. package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -0
  60. package/dist/culling/lib/bounding-volumes/bounding-sphere.d.ts +40 -0
  61. package/dist/culling/lib/bounding-volumes/bounding-sphere.d.ts.map +1 -0
  62. package/dist/culling/lib/bounding-volumes/bounding-sphere.js +123 -0
  63. package/dist/culling/lib/bounding-volumes/bounding-sphere.js.map +1 -0
  64. package/dist/culling/lib/bounding-volumes/bounding-volume.d.ts +30 -0
  65. package/dist/culling/lib/bounding-volumes/bounding-volume.d.ts.map +1 -0
  66. package/dist/culling/lib/bounding-volumes/bounding-volume.js +7 -0
  67. package/dist/culling/lib/bounding-volumes/bounding-volume.js.map +1 -0
  68. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.d.ts +62 -0
  69. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.d.ts.map +1 -0
  70. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.js +230 -0
  71. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.js.map +1 -0
  72. package/dist/culling/lib/culling-volume.d.ts +49 -0
  73. package/dist/culling/lib/culling-volume.d.ts.map +1 -0
  74. package/dist/culling/lib/culling-volume.js +133 -0
  75. package/dist/culling/lib/culling-volume.js.map +1 -0
  76. package/dist/culling/lib/perspective-frustum.d.ts +153 -0
  77. package/dist/culling/lib/perspective-frustum.d.ts.map +1 -0
  78. package/dist/culling/lib/perspective-frustum.js +191 -0
  79. package/dist/culling/lib/perspective-frustum.js.map +1 -0
  80. package/dist/culling/lib/perspective-off-center-frustum.d.ts +158 -0
  81. package/dist/culling/lib/perspective-off-center-frustum.d.ts.map +1 -0
  82. package/dist/culling/lib/perspective-off-center-frustum.js +276 -0
  83. package/dist/culling/lib/perspective-off-center-frustum.js.map +1 -0
  84. package/dist/culling/lib/plane.d.ts +35 -0
  85. package/dist/culling/lib/plane.d.ts.map +1 -0
  86. package/dist/culling/lib/plane.js +90 -0
  87. package/dist/culling/lib/plane.js.map +1 -0
  88. package/dist/culling/lib/ray.d.ts +18 -0
  89. package/dist/culling/lib/ray.d.ts.map +1 -0
  90. package/dist/culling/lib/ray.js +51 -0
  91. package/dist/culling/lib/ray.js.map +1 -0
  92. package/dist/culling/lib/shapes/box-shape.d.ts +19 -0
  93. package/dist/culling/lib/shapes/box-shape.d.ts.map +1 -0
  94. package/dist/culling/lib/shapes/box-shape.js +69 -0
  95. package/dist/culling/lib/shapes/box-shape.js.map +1 -0
  96. package/dist/culling/lib/shapes/capsule-shape.d.ts +23 -0
  97. package/dist/culling/lib/shapes/capsule-shape.d.ts.map +1 -0
  98. package/dist/culling/lib/shapes/capsule-shape.js +151 -0
  99. package/dist/culling/lib/shapes/capsule-shape.js.map +1 -0
  100. package/dist/culling/lib/shapes/cylinder-shape.d.ts +22 -0
  101. package/dist/culling/lib/shapes/cylinder-shape.d.ts.map +1 -0
  102. package/dist/culling/lib/shapes/cylinder-shape.js +99 -0
  103. package/dist/culling/lib/shapes/cylinder-shape.js.map +1 -0
  104. package/dist/culling/lib/shapes/implicit-shape.d.ts +56 -0
  105. package/dist/culling/lib/shapes/implicit-shape.d.ts.map +1 -0
  106. package/dist/culling/lib/shapes/implicit-shape.js +142 -0
  107. package/dist/culling/lib/shapes/implicit-shape.js.map +1 -0
  108. package/dist/culling/lib/shapes/plane-shape.d.ts +27 -0
  109. package/dist/culling/lib/shapes/plane-shape.d.ts.map +1 -0
  110. package/dist/culling/lib/shapes/plane-shape.js +71 -0
  111. package/dist/culling/lib/shapes/plane-shape.js.map +1 -0
  112. package/dist/culling/lib/shapes/sphere-shape.d.ts +18 -0
  113. package/dist/culling/lib/shapes/sphere-shape.d.ts.map +1 -0
  114. package/dist/culling/lib/shapes/sphere-shape.js +43 -0
  115. package/dist/culling/lib/shapes/sphere-shape.js.map +1 -0
  116. package/dist/culling/oriented-box-2d.d.ts +22 -0
  117. package/dist/culling/oriented-box-2d.d.ts.map +1 -0
  118. package/dist/culling/oriented-box-2d.js +86 -0
  119. package/dist/culling/oriented-box-2d.js.map +1 -0
  120. package/dist/culling/queries.d.ts +44 -0
  121. package/dist/culling/queries.d.ts.map +1 -0
  122. package/dist/culling/queries.js +259 -0
  123. package/dist/culling/queries.js.map +1 -0
  124. package/dist/culling/screen-ray.d.ts +22 -0
  125. package/dist/culling/screen-ray.d.ts.map +1 -0
  126. package/dist/culling/screen-ray.js +55 -0
  127. package/dist/culling/screen-ray.js.map +1 -0
  128. package/dist/curves/adaptive-sampling.d.ts +16 -0
  129. package/dist/curves/adaptive-sampling.d.ts.map +1 -0
  130. package/dist/curves/adaptive-sampling.js +59 -0
  131. package/dist/curves/adaptive-sampling.js.map +1 -0
  132. package/dist/curves/bezier-curves.d.ts +18 -0
  133. package/dist/curves/bezier-curves.d.ts.map +1 -0
  134. package/dist/curves/bezier-curves.js +54 -0
  135. package/dist/curves/bezier-curves.js.map +1 -0
  136. package/dist/curves/catmull-rom-curve.d.ts +15 -0
  137. package/dist/curves/catmull-rom-curve.d.ts.map +1 -0
  138. package/dist/curves/catmull-rom-curve.js +77 -0
  139. package/dist/curves/catmull-rom-curve.js.map +1 -0
  140. package/dist/curves/curve-arc-length.d.ts +17 -0
  141. package/dist/curves/curve-arc-length.d.ts.map +1 -0
  142. package/dist/curves/curve-arc-length.js +58 -0
  143. package/dist/curves/curve-arc-length.js.map +1 -0
  144. package/dist/curves/curve.d.ts +23 -0
  145. package/dist/curves/curve.d.ts.map +1 -0
  146. package/dist/curves/curve.js +77 -0
  147. package/dist/curves/curve.js.map +1 -0
  148. package/dist/curves/hermite-curve.d.ts +9 -0
  149. package/dist/curves/hermite-curve.d.ts.map +1 -0
  150. package/dist/curves/hermite-curve.js +24 -0
  151. package/dist/curves/hermite-curve.js.map +1 -0
  152. package/dist/curves/index.d.ts +12 -0
  153. package/dist/curves/index.d.ts.map +1 -0
  154. package/dist/curves/index.js +11 -0
  155. package/dist/curves/index.js.map +1 -0
  156. package/dist/curves/parallel-transport.d.ts +12 -0
  157. package/dist/curves/parallel-transport.d.ts.map +1 -0
  158. package/dist/curves/parallel-transport.js +83 -0
  159. package/dist/curves/parallel-transport.js.map +1 -0
  160. package/dist/geometries/box-geometry.js +1 -1
  161. package/dist/geometries/box-geometry.js.map +1 -1
  162. package/dist/geometries/capsule-geometry.js +1 -1
  163. package/dist/geometries/capsule-geometry.js.map +1 -1
  164. package/dist/geometries/cylinder-geometry.js +1 -1
  165. package/dist/geometries/cylinder-geometry.js.map +1 -1
  166. package/dist/geometries/geometry-helpers.js +1 -1
  167. package/dist/geometries/geometry-helpers.js.map +1 -1
  168. package/dist/geometries/ico-sphere-geometry.js +1 -1
  169. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  170. package/dist/geometries/plane-geometry.js +1 -1
  171. package/dist/geometries/plane-geometry.js.map +1 -1
  172. package/dist/geometries/primitive-mesh-builder.d.ts +24 -0
  173. package/dist/geometries/primitive-mesh-builder.d.ts.map +1 -0
  174. package/dist/geometries/primitive-mesh-builder.js +74 -0
  175. package/dist/geometries/primitive-mesh-builder.js.map +1 -0
  176. package/dist/geometries/prism-geometry.d.ts +13 -0
  177. package/dist/geometries/prism-geometry.d.ts.map +1 -0
  178. package/dist/geometries/prism-geometry.js +34 -0
  179. package/dist/geometries/prism-geometry.js.map +1 -0
  180. package/dist/geometries/ring-geometry.d.ts +15 -0
  181. package/dist/geometries/ring-geometry.d.ts.map +1 -0
  182. package/dist/geometries/ring-geometry.js +64 -0
  183. package/dist/geometries/ring-geometry.js.map +1 -0
  184. package/dist/geometries/sphere-geometry.js +1 -1
  185. package/dist/geometries/sphere-geometry.js.map +1 -1
  186. package/dist/geometries/surface-of-revolution.js +1 -1
  187. package/dist/geometries/surface-of-revolution.js.map +1 -1
  188. package/dist/geometries/truncated-cone-geometry.js +1 -1
  189. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  190. package/dist/index.cjs +6993 -37
  191. package/dist/index.cjs.map +3 -3
  192. package/dist/index.d.ts +35 -0
  193. package/dist/index.d.ts.map +1 -1
  194. package/dist/index.js +20 -1
  195. package/dist/index.js.map +1 -1
  196. package/dist/lib/geometry-utils.js +1 -1
  197. package/dist/lib/geometry-utils.js.map +1 -1
  198. package/dist/lib/geometry.d.ts +1 -1
  199. package/dist/lib/geometry.d.ts.map +1 -1
  200. package/dist/lib/geometry.js +1 -1
  201. package/dist/lib/geometry.js.map +1 -1
  202. package/dist/lib/hinge-tree.d.ts +33 -0
  203. package/dist/lib/hinge-tree.d.ts.map +1 -0
  204. package/dist/lib/hinge-tree.js +144 -0
  205. package/dist/lib/hinge-tree.js.map +1 -0
  206. package/dist/lighting/index.cjs +175 -0
  207. package/dist/lighting/index.cjs.map +6 -0
  208. package/dist/lighting/index.d.ts +4 -0
  209. package/dist/lighting/index.d.ts.map +1 -0
  210. package/dist/lighting/index.js +5 -0
  211. package/dist/lighting/index.js.map +1 -0
  212. package/dist/lighting/lighting-types.d.ts +16 -0
  213. package/dist/lighting/lighting-types.d.ts.map +1 -0
  214. package/dist/lighting/lighting-types.js +5 -0
  215. package/dist/lighting/lighting-types.js.map +1 -0
  216. package/dist/lighting/photometry.d.ts +36 -0
  217. package/dist/lighting/photometry.d.ts.map +1 -0
  218. package/dist/lighting/photometry.js +181 -0
  219. package/dist/lighting/photometry.js.map +1 -0
  220. package/dist/parametric/lathe-geometry.d.ts +14 -0
  221. package/dist/parametric/lathe-geometry.d.ts.map +1 -0
  222. package/dist/parametric/lathe-geometry.js +48 -0
  223. package/dist/parametric/lathe-geometry.js.map +1 -0
  224. package/dist/parametric/parametric-geometry.d.ts +20 -0
  225. package/dist/parametric/parametric-geometry.d.ts.map +1 -0
  226. package/dist/parametric/parametric-geometry.js +88 -0
  227. package/dist/parametric/parametric-geometry.js.map +1 -0
  228. package/dist/parametric/torus-geometry.d.ts +19 -0
  229. package/dist/parametric/torus-geometry.d.ts.map +1 -0
  230. package/dist/parametric/torus-geometry.js +89 -0
  231. package/dist/parametric/torus-geometry.js.map +1 -0
  232. package/dist/parametric.d.ts +7 -0
  233. package/dist/parametric.d.ts.map +1 -0
  234. package/dist/parametric.js +7 -0
  235. package/dist/parametric.js.map +1 -0
  236. package/dist/polygon/clip-triangle-mesh.d.ts +41 -0
  237. package/dist/polygon/clip-triangle-mesh.d.ts.map +1 -0
  238. package/dist/polygon/clip-triangle-mesh.js +155 -0
  239. package/dist/polygon/clip-triangle-mesh.js.map +1 -0
  240. package/dist/polygon/cut-by-grid.d.ts +24 -0
  241. package/dist/polygon/cut-by-grid.d.ts.map +1 -0
  242. package/dist/polygon/cut-by-grid.js +221 -0
  243. package/dist/polygon/cut-by-grid.js.map +1 -0
  244. package/dist/polygon/cut-by-mercator-bounds.d.ts +17 -0
  245. package/dist/polygon/cut-by-mercator-bounds.d.ts.map +1 -0
  246. package/dist/polygon/cut-by-mercator-bounds.js +149 -0
  247. package/dist/polygon/cut-by-mercator-bounds.js.map +1 -0
  248. package/dist/polygon/earcut.d.ts +13 -0
  249. package/dist/polygon/earcut.d.ts.map +1 -0
  250. package/dist/polygon/earcut.js +693 -0
  251. package/dist/polygon/earcut.js.map +1 -0
  252. package/dist/polygon/index.d.ts +16 -0
  253. package/dist/polygon/index.d.ts.map +1 -0
  254. package/dist/polygon/index.js +14 -0
  255. package/dist/polygon/index.js.map +1 -0
  256. package/dist/polygon/lineclip.d.ts +31 -0
  257. package/dist/polygon/lineclip.d.ts.map +1 -0
  258. package/dist/polygon/lineclip.js +184 -0
  259. package/dist/polygon/lineclip.js.map +1 -0
  260. package/dist/polygon/pole-of-inaccessibility.d.ts +21 -0
  261. package/dist/polygon/pole-of-inaccessibility.d.ts.map +1 -0
  262. package/dist/polygon/pole-of-inaccessibility.js +285 -0
  263. package/dist/polygon/pole-of-inaccessibility.js.map +1 -0
  264. package/dist/polygon/polygon-utils.d.ts +103 -0
  265. package/dist/polygon/polygon-utils.d.ts.map +1 -0
  266. package/dist/polygon/polygon-utils.js +155 -0
  267. package/dist/polygon/polygon-utils.js.map +1 -0
  268. package/dist/polygon/polygon.d.ts +41 -0
  269. package/dist/polygon/polygon.d.ts.map +1 -0
  270. package/dist/polygon/polygon.js +76 -0
  271. package/dist/polygon/polygon.js.map +1 -0
  272. package/dist/polygon/subdivide-polyline.d.ts +56 -0
  273. package/dist/polygon/subdivide-polyline.d.ts.map +1 -0
  274. package/dist/polygon/subdivide-polyline.js +141 -0
  275. package/dist/polygon/subdivide-polyline.js.map +1 -0
  276. package/dist/polygon/subdivide-triangle-mesh.d.ts +78 -0
  277. package/dist/polygon/subdivide-triangle-mesh.d.ts.map +1 -0
  278. package/dist/polygon/subdivide-triangle-mesh.js +238 -0
  279. package/dist/polygon/subdivide-triangle-mesh.js.map +1 -0
  280. package/dist/polygon/utils.d.ts +5 -0
  281. package/dist/polygon/utils.d.ts.map +1 -0
  282. package/dist/polygon/utils.js +38 -0
  283. package/dist/polygon/utils.js.map +1 -0
  284. package/dist/spatial-index/box-index.d.ts +86 -0
  285. package/dist/spatial-index/box-index.d.ts.map +1 -0
  286. package/dist/spatial-index/box-index.js +335 -0
  287. package/dist/spatial-index/box-index.js.map +1 -0
  288. package/dist/spatial-index/index.d.ts +7 -0
  289. package/dist/spatial-index/index.d.ts.map +1 -0
  290. package/dist/spatial-index/index.js +6 -0
  291. package/dist/spatial-index/index.js.map +1 -0
  292. package/dist/spatial-index/triangle-bvh.d.ts +74 -0
  293. package/dist/spatial-index/triangle-bvh.d.ts.map +1 -0
  294. package/dist/spatial-index/triangle-bvh.js +221 -0
  295. package/dist/spatial-index/triangle-bvh.js.map +1 -0
  296. package/dist/utils/attribute-compression.d.ts +50 -0
  297. package/dist/utils/attribute-compression.d.ts.map +1 -0
  298. package/dist/utils/attribute-compression.js +186 -0
  299. package/dist/utils/attribute-compression.js.map +1 -0
  300. package/dist/utils/attribute-iterator.d.ts +8 -0
  301. package/dist/utils/attribute-iterator.d.ts.map +1 -0
  302. package/dist/utils/attribute-iterator.js +25 -0
  303. package/dist/utils/attribute-iterator.js.map +1 -0
  304. package/dist/utils/compose-attribute-provenance.d.ts +13 -0
  305. package/dist/utils/compose-attribute-provenance.d.ts.map +1 -0
  306. package/dist/utils/compose-attribute-provenance.js +63 -0
  307. package/dist/utils/compose-attribute-provenance.js.map +1 -0
  308. package/dist/utils/compute-vertex-normals.d.ts +4 -0
  309. package/dist/utils/compute-vertex-normals.d.ts.map +1 -0
  310. package/dist/utils/compute-vertex-normals.js +54 -0
  311. package/dist/utils/compute-vertex-normals.js.map +1 -0
  312. package/dist/utils/constants.d.ts +52 -0
  313. package/dist/utils/constants.d.ts.map +1 -0
  314. package/dist/utils/constants.js +39 -0
  315. package/dist/utils/constants.js.map +1 -0
  316. package/dist/utils/coordinates.d.ts +3 -0
  317. package/dist/utils/coordinates.d.ts.map +1 -0
  318. package/dist/utils/coordinates.js +8 -0
  319. package/dist/utils/coordinates.js.map +1 -0
  320. package/dist/utils/geometry.d.ts +20 -0
  321. package/dist/utils/geometry.d.ts.map +1 -0
  322. package/dist/utils/geometry.js +31 -0
  323. package/dist/utils/geometry.js.map +1 -0
  324. package/dist/utils/gl-type.d.ts +17 -0
  325. package/dist/utils/gl-type.d.ts.map +1 -0
  326. package/dist/utils/gl-type.js +69 -0
  327. package/dist/utils/gl-type.js.map +1 -0
  328. package/dist/utils/index.d.ts +18 -0
  329. package/dist/utils/index.d.ts.map +1 -0
  330. package/dist/utils/index.js +16 -0
  331. package/dist/utils/index.js.map +1 -0
  332. package/dist/utils/interpolate-packed-attributes.d.ts +43 -0
  333. package/dist/utils/interpolate-packed-attributes.d.ts.map +1 -0
  334. package/dist/utils/interpolate-packed-attributes.js +192 -0
  335. package/dist/utils/interpolate-packed-attributes.js.map +1 -0
  336. package/dist/utils/mesh-processing.d.ts +18 -0
  337. package/dist/utils/mesh-processing.d.ts.map +1 -0
  338. package/dist/utils/mesh-processing.js +300 -0
  339. package/dist/utils/mesh-processing.js.map +1 -0
  340. package/dist/utils/primitive-iterator.d.ts +21 -0
  341. package/dist/utils/primitive-iterator.d.ts.map +1 -0
  342. package/dist/utils/primitive-iterator.js +117 -0
  343. package/dist/utils/primitive-iterator.js.map +1 -0
  344. package/dist/utils/project-bounds.d.ts +44 -0
  345. package/dist/utils/project-bounds.d.ts.map +1 -0
  346. package/dist/utils/project-bounds.js +93 -0
  347. package/dist/utils/project-bounds.js.map +1 -0
  348. package/dist/utils/project-texture-coordinates.d.ts +19 -0
  349. package/dist/utils/project-texture-coordinates.d.ts.map +1 -0
  350. package/dist/utils/project-texture-coordinates.js +49 -0
  351. package/dist/utils/project-texture-coordinates.js.map +1 -0
  352. package/dist/utils/qualify-surface-transition.d.ts +21 -0
  353. package/dist/utils/qualify-surface-transition.d.ts.map +1 -0
  354. package/dist/utils/qualify-surface-transition.js +140 -0
  355. package/dist/utils/qualify-surface-transition.js.map +1 -0
  356. package/dist/utils/rgb565.d.ts +5 -0
  357. package/dist/utils/rgb565.d.ts.map +1 -0
  358. package/dist/utils/rgb565.js +24 -0
  359. package/dist/utils/rgb565.js.map +1 -0
  360. package/dist/utils/typed-array-utils.d.ts +3 -0
  361. package/dist/utils/typed-array-utils.d.ts.map +1 -0
  362. package/dist/utils/typed-array-utils.js +16 -0
  363. package/dist/utils/typed-array-utils.js.map +1 -0
  364. package/package.json +24 -4
  365. package/src/color/color-lut-types.ts +19 -0
  366. package/src/color/index.ts +6 -0
  367. package/src/color/sample-lut.ts +175 -0
  368. package/src/culling/bounds.ts +152 -0
  369. package/src/culling/constants.ts +6 -0
  370. package/src/culling/frustum-planes.ts +41 -0
  371. package/src/culling/geometric-queries.ts +299 -0
  372. package/src/culling/index.ts +93 -0
  373. package/src/culling/lib/algorithms/bounding-box-from-points.ts +174 -0
  374. package/src/culling/lib/algorithms/bounding-sphere-from-points.ts +175 -0
  375. package/src/culling/lib/algorithms/compute-eigen-decomposition.ts +171 -0
  376. package/src/culling/lib/algorithms/oriented-bounding-box-quaternion.ts +32 -0
  377. package/src/culling/lib/bounding-volumes/axis-aligned-bounding-box.ts +171 -0
  378. package/src/culling/lib/bounding-volumes/bounding-sphere.ts +154 -0
  379. package/src/culling/lib/bounding-volumes/bounding-volume.ts +38 -0
  380. package/src/culling/lib/bounding-volumes/oriented-bounding-box.ts +320 -0
  381. package/src/culling/lib/culling-volume.ts +171 -0
  382. package/src/culling/lib/perspective-frustum.ts +288 -0
  383. package/src/culling/lib/perspective-off-center-frustum.ts +381 -0
  384. package/src/culling/lib/plane.ts +118 -0
  385. package/src/culling/lib/ray.ts +54 -0
  386. package/src/culling/lib/shapes/box-shape.ts +78 -0
  387. package/src/culling/lib/shapes/capsule-shape.ts +232 -0
  388. package/src/culling/lib/shapes/cylinder-shape.ts +133 -0
  389. package/src/culling/lib/shapes/implicit-shape.ts +209 -0
  390. package/src/culling/lib/shapes/plane-shape.ts +78 -0
  391. package/src/culling/lib/shapes/sphere-shape.ts +60 -0
  392. package/src/culling/oriented-box-2d.ts +165 -0
  393. package/src/culling/queries.ts +332 -0
  394. package/src/culling/screen-ray.ts +75 -0
  395. package/src/curves/adaptive-sampling.ts +85 -0
  396. package/src/curves/bezier-curves.ts +62 -0
  397. package/src/curves/catmull-rom-curve.ts +89 -0
  398. package/src/curves/curve-arc-length.ts +70 -0
  399. package/src/curves/curve.ts +96 -0
  400. package/src/curves/hermite-curve.ts +34 -0
  401. package/src/curves/index.ts +19 -0
  402. package/src/curves/parallel-transport.ts +104 -0
  403. package/src/geometries/box-geometry.ts +1 -1
  404. package/src/geometries/capsule-geometry.ts +1 -1
  405. package/src/geometries/cylinder-geometry.ts +1 -1
  406. package/src/geometries/geometry-helpers.ts +1 -1
  407. package/src/geometries/ico-sphere-geometry.ts +1 -1
  408. package/src/geometries/plane-geometry.ts +1 -1
  409. package/src/geometries/primitive-mesh-builder.ts +84 -0
  410. package/src/geometries/prism-geometry.ts +57 -0
  411. package/src/geometries/ring-geometry.ts +102 -0
  412. package/src/geometries/sphere-geometry.ts +1 -1
  413. package/src/geometries/surface-of-revolution.ts +1 -1
  414. package/src/geometries/truncated-cone-geometry.ts +1 -1
  415. package/src/index.ts +226 -1
  416. package/src/lib/geometry-utils.ts +2 -2
  417. package/src/lib/geometry.ts +2 -2
  418. package/src/lib/hinge-tree.ts +170 -0
  419. package/src/lighting/index.ts +10 -0
  420. package/src/lighting/lighting-types.ts +20 -0
  421. package/src/lighting/photometry.ts +264 -0
  422. package/src/parametric/lathe-geometry.ts +70 -0
  423. package/src/parametric/parametric-geometry.ts +118 -0
  424. package/src/parametric/torus-geometry.ts +118 -0
  425. package/src/parametric.ts +9 -0
  426. package/src/polygon/clip-triangle-mesh.ts +218 -0
  427. package/src/polygon/cut-by-grid.ts +313 -0
  428. package/src/polygon/cut-by-mercator-bounds.ts +204 -0
  429. package/src/polygon/earcut.ts +859 -0
  430. package/src/polygon/index.ts +48 -0
  431. package/src/polygon/lineclip.ts +218 -0
  432. package/src/polygon/pole-of-inaccessibility.ts +330 -0
  433. package/src/polygon/polygon-utils.ts +273 -0
  434. package/src/polygon/polygon.ts +105 -0
  435. package/src/polygon/subdivide-polyline.ts +223 -0
  436. package/src/polygon/subdivide-triangle-mesh.ts +342 -0
  437. package/src/polygon/utils.ts +50 -0
  438. package/src/spatial-index/box-index.ts +452 -0
  439. package/src/spatial-index/index.ts +20 -0
  440. package/src/spatial-index/triangle-bvh.ts +345 -0
  441. package/src/utils/attribute-compression.ts +234 -0
  442. package/src/utils/attribute-iterator.ts +28 -0
  443. package/src/utils/compose-attribute-provenance.ts +74 -0
  444. package/src/utils/compute-vertex-normals.ts +63 -0
  445. package/src/utils/constants.ts +42 -0
  446. package/src/utils/coordinates.ts +8 -0
  447. package/src/utils/geometry.ts +49 -0
  448. package/src/utils/gl-type.ts +87 -0
  449. package/src/utils/index.ts +55 -0
  450. package/src/utils/interpolate-packed-attributes.ts +284 -0
  451. package/src/utils/mesh-processing.ts +377 -0
  452. package/src/utils/primitive-iterator.ts +145 -0
  453. package/src/utils/project-bounds.ts +154 -0
  454. package/src/utils/project-texture-coordinates.ts +67 -0
  455. package/src/utils/qualify-surface-transition.ts +169 -0
  456. package/src/utils/rgb565.ts +26 -0
  457. package/src/utils/typed-array-utils.ts +16 -0
@@ -0,0 +1,693 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT AND ISC
3
+ // SPDX-FileCopyrightText: Copyright (c) 2016, Mapbox
4
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
5
+ // SPDX-FileComment: Adapted from Mapbox earcut. Original ISC notice retained below.
6
+ import { DimIndex } from "./polygon-utils.js";
7
+ /**
8
+ * Computes a triangulation of a polygon
9
+ * @param positions a flat array of the vertex positions that define the polygon.
10
+ * @param holeIndices an array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11).
11
+ * @param dim the number of elements in each vertex. Size `2` will interpret `positions` as `[x0, y0, x1, y1, ...]` and size `3` will interpret `positions` as `[x0, y0, z0, x1, y1, z1, ...]`. Default `2`.
12
+ * @param areas areas of outer polygon and holes as computed by `getPolygonSignedArea()`. Can be optionally supplied to speed up triangulation
13
+ * @returns array of indices into the `positions` array that describes the triangulation of the polygon
14
+ * Adapted from https://github.com/mapbox/earcut
15
+ */
16
+ export function earcut(positions, holeIndices, dim = 2, areas, plane = 'xy') {
17
+ // Keep nested calls from numeric array getters isolated.
18
+ const savedIndex = vertexPoolIndex;
19
+ const savedQueue = activeHoleQueue;
20
+ if (!holeQueues[callDepth])
21
+ holeQueues[callDepth] = [];
22
+ activeHoleQueue = holeQueues[callDepth];
23
+ callDepth++;
24
+ try {
25
+ return triangulate(positions, holeIndices, dim, areas, plane);
26
+ }
27
+ finally {
28
+ activeHoleQueue.length = 0;
29
+ activeHoleQueue = savedQueue;
30
+ vertexPoolIndex = savedIndex;
31
+ callDepth--;
32
+ // Do not retain arbitrarily large object graphs after a one-off polygon.
33
+ if (callDepth === 0 && vertexPool.length > 65536)
34
+ vertexPool.length = 0;
35
+ }
36
+ }
37
+ function triangulate(positions, holeIndices, dim, areas, plane) {
38
+ const hasHoles = holeIndices && holeIndices.length;
39
+ const outerLen = hasHoles ? holeIndices[0] * dim : positions.length;
40
+ let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0], plane);
41
+ const triangles = [];
42
+ if (!outerNode || outerNode.next === outerNode.prev)
43
+ return triangles;
44
+ let invSize;
45
+ let maxX;
46
+ let maxY;
47
+ let minX;
48
+ let minY;
49
+ let x;
50
+ let y;
51
+ if (hasHoles)
52
+ outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
53
+ // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
54
+ if (positions.length > 80 * dim) {
55
+ const i0 = DimIndex[plane[0]];
56
+ const i1 = DimIndex[plane[1]];
57
+ minX = maxX = positions[i0];
58
+ minY = maxY = positions[i1];
59
+ for (let i = dim; i < outerLen; i += dim) {
60
+ x = positions[i + i0];
61
+ y = positions[i + i1];
62
+ if (x < minX)
63
+ minX = x;
64
+ if (y < minY)
65
+ minY = y;
66
+ if (x > maxX)
67
+ maxX = x;
68
+ if (y > maxY)
69
+ maxY = y;
70
+ }
71
+ // minX, minY and invSize are later used to transform coords into integers for z-order calculation
72
+ invSize = Math.max(maxX - minX, maxY - minY);
73
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
74
+ }
75
+ earcutLinked(outerNode, triangles, minX, minY, invSize, 0);
76
+ return triangles;
77
+ }
78
+ // create a circular doubly linked list from polygon points in the specified winding order
79
+ function linkedList(data, start, end, dim, clockwise, area, plane) {
80
+ if (start >= end)
81
+ return null;
82
+ let i;
83
+ let last;
84
+ const i0 = DimIndex[plane[0]];
85
+ const i1 = DimIndex[plane[1]];
86
+ if (area === undefined) {
87
+ // Combine coordinate reads and area accumulation, as in loaders.gl.
88
+ let sum = 0;
89
+ let previousX = data[end - dim + i0];
90
+ let previousY = data[end - dim + i1];
91
+ for (i = start; i < end; i += dim) {
92
+ const x = data[i + i0];
93
+ const y = data[i + i1];
94
+ sum += (x - previousX) * (y + previousY);
95
+ last = insertNode(i / dim, x, y, last);
96
+ previousX = x;
97
+ previousY = y;
98
+ }
99
+ if (last && clockwise !== sum / 2 < 0) {
100
+ let node = last;
101
+ do {
102
+ const next = node.next;
103
+ node.next = node.prev;
104
+ node.prev = next;
105
+ node = next;
106
+ } while (node !== last);
107
+ // Preserve the starting vertex and triangle order of reverse insertion.
108
+ last = last.prev;
109
+ }
110
+ }
111
+ else if (clockwise === area < 0) {
112
+ for (i = start; i < end; i += dim)
113
+ last = insertNode(i / dim, data[i + i0], data[i + i1], last);
114
+ }
115
+ else {
116
+ for (i = end - dim; i >= start; i -= dim)
117
+ last = insertNode(i / dim, data[i + i0], data[i + i1], last);
118
+ }
119
+ if (last && equals(last, last.next)) {
120
+ removeNode(last);
121
+ last = last.next;
122
+ }
123
+ return last;
124
+ }
125
+ // eliminate colinear or duplicate points
126
+ function filterPoints(start, end) {
127
+ if (!start)
128
+ return start;
129
+ if (!end)
130
+ end = start;
131
+ let p = start;
132
+ let again;
133
+ do {
134
+ again = false;
135
+ if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
136
+ removeNode(p);
137
+ p = end = p.prev;
138
+ if (p === p.next)
139
+ break;
140
+ again = true;
141
+ }
142
+ else {
143
+ p = p.next;
144
+ }
145
+ } while (again || p !== end);
146
+ return end;
147
+ }
148
+ // main ear slicing loop which triangulates a polygon (given as a linked list)
149
+ function earcutLinked(ear, triangles, minX, minY, invSize, pass) {
150
+ if (!ear)
151
+ return;
152
+ // interlink polygon nodes in z-order
153
+ if (!pass && invSize)
154
+ indexCurve(ear, minX, minY, invSize);
155
+ let stop = ear;
156
+ let prev;
157
+ let next;
158
+ // iterate through ears, slicing them one by one
159
+ while (ear.prev !== ear.next) {
160
+ prev = ear.prev;
161
+ next = ear.next;
162
+ if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
163
+ // cut off the triangle
164
+ triangles.push(prev.i);
165
+ triangles.push(ear.i);
166
+ triangles.push(next.i);
167
+ removeNode(ear);
168
+ // skipping the next vertex leads to less sliver triangles
169
+ ear = next.next;
170
+ stop = next.next;
171
+ continue;
172
+ }
173
+ ear = next;
174
+ // if we looped through the whole remaining polygon and can't find any more ears
175
+ if (ear === stop) {
176
+ // try filtering points and slicing again
177
+ if (!pass) {
178
+ earcutLinked(filterPoints(ear), triangles, minX, minY, invSize, 1);
179
+ // if this didn't work, try curing all small self-intersections locally
180
+ }
181
+ else if (pass === 1) {
182
+ ear = cureLocalIntersections(filterPoints(ear), triangles);
183
+ earcutLinked(ear, triangles, minX, minY, invSize, 2);
184
+ // as a last resort, try splitting the remaining polygon into two
185
+ }
186
+ else if (pass === 2) {
187
+ splitEarcut(ear, triangles, minX, minY, invSize);
188
+ }
189
+ break;
190
+ }
191
+ }
192
+ }
193
+ // check whether a polygon node forms a valid ear with adjacent nodes
194
+ function isEar(ear) {
195
+ const a = ear.prev;
196
+ const b = ear;
197
+ const c = ear.next;
198
+ if (area(a, b, c) >= 0)
199
+ return false; // reflex, can't be an ear
200
+ // now make sure we don't have other points inside the potential ear
201
+ const ax = a.x;
202
+ const bx = b.x;
203
+ const cx = c.x;
204
+ const ay = a.y;
205
+ const by = b.y;
206
+ const cy = c.y;
207
+ // triangle bbox; min & max are calculated like this for speed
208
+ const x0 = ax < bx ? (ax < cx ? ax : cx) : bx < cx ? bx : cx;
209
+ const y0 = ay < by ? (ay < cy ? ay : cy) : by < cy ? by : cy;
210
+ const x1 = ax > bx ? (ax > cx ? ax : cx) : bx > cx ? bx : cx;
211
+ const y1 = ay > by ? (ay > cy ? ay : cy) : by > cy ? by : cy;
212
+ let p = c.next;
213
+ while (p !== a) {
214
+ if (p.x >= x0 &&
215
+ p.x <= x1 &&
216
+ p.y >= y0 &&
217
+ p.y <= y1 &&
218
+ pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
219
+ area(p.prev, p, p.next) >= 0)
220
+ return false;
221
+ p = p.next;
222
+ }
223
+ return true;
224
+ }
225
+ function isEarHashed(ear, minX, minY, invSize) {
226
+ const a = ear.prev;
227
+ const b = ear;
228
+ const c = ear.next;
229
+ if (area(a, b, c) >= 0)
230
+ return false; // reflex, can't be an ear
231
+ const ax = a.x;
232
+ const bx = b.x;
233
+ const cx = c.x;
234
+ const ay = a.y;
235
+ const by = b.y;
236
+ const cy = c.y;
237
+ // triangle bbox; min & max are calculated like this for speed
238
+ const x0 = ax < bx ? (ax < cx ? ax : cx) : bx < cx ? bx : cx;
239
+ const y0 = ay < by ? (ay < cy ? ay : cy) : by < cy ? by : cy;
240
+ const x1 = ax > bx ? (ax > cx ? ax : cx) : bx > cx ? bx : cx;
241
+ const y1 = ay > by ? (ay > cy ? ay : cy) : by > cy ? by : cy;
242
+ // z-order range for the current triangle bbox;
243
+ const minZ = zOrder(x0, y0, minX, minY, invSize);
244
+ const maxZ = zOrder(x1, y1, minX, minY, invSize);
245
+ let p = ear.prevZ;
246
+ let n = ear.nextZ;
247
+ // look for points inside the triangle in both directions
248
+ while (p && p.z >= minZ && n && n.z <= maxZ) {
249
+ if (p.x >= x0 &&
250
+ p.x <= x1 &&
251
+ p.y >= y0 &&
252
+ p.y <= y1 &&
253
+ p !== a &&
254
+ p !== c &&
255
+ pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
256
+ area(p.prev, p, p.next) >= 0)
257
+ return false;
258
+ p = p.prevZ;
259
+ if (n.x >= x0 &&
260
+ n.x <= x1 &&
261
+ n.y >= y0 &&
262
+ n.y <= y1 &&
263
+ n !== a &&
264
+ n !== c &&
265
+ pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) &&
266
+ area(n.prev, n, n.next) >= 0)
267
+ return false;
268
+ n = n.nextZ;
269
+ }
270
+ // look for remaining points in decreasing z-order
271
+ while (p && p.z >= minZ) {
272
+ if (p.x >= x0 &&
273
+ p.x <= x1 &&
274
+ p.y >= y0 &&
275
+ p.y <= y1 &&
276
+ p !== a &&
277
+ p !== c &&
278
+ pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
279
+ area(p.prev, p, p.next) >= 0)
280
+ return false;
281
+ p = p.prevZ;
282
+ }
283
+ // look for remaining points in increasing z-order
284
+ while (n && n.z <= maxZ) {
285
+ if (n.x >= x0 &&
286
+ n.x <= x1 &&
287
+ n.y >= y0 &&
288
+ n.y <= y1 &&
289
+ n !== a &&
290
+ n !== c &&
291
+ pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) &&
292
+ area(n.prev, n, n.next) >= 0)
293
+ return false;
294
+ n = n.nextZ;
295
+ }
296
+ return true;
297
+ }
298
+ // go through all polygon nodes and cure small local self-intersections
299
+ function cureLocalIntersections(start, triangles) {
300
+ let p = start;
301
+ do {
302
+ const a = p.prev;
303
+ const b = p.next.next;
304
+ if (!equals(a, b) &&
305
+ intersects(a, p, p.next, b) &&
306
+ locallyInside(a, b) &&
307
+ locallyInside(b, a)) {
308
+ triangles.push(a.i);
309
+ triangles.push(p.i);
310
+ triangles.push(b.i);
311
+ // remove two nodes involved
312
+ removeNode(p);
313
+ removeNode(p.next);
314
+ p = start = b;
315
+ }
316
+ p = p.next;
317
+ } while (p !== start);
318
+ return filterPoints(p);
319
+ }
320
+ // try splitting polygon into two and triangulate them independently
321
+ function splitEarcut(start, triangles, minX, minY, invSize) {
322
+ // look for a valid diagonal that divides the polygon into two
323
+ let a = start;
324
+ do {
325
+ let b = a.next.next;
326
+ while (b !== a.prev) {
327
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
328
+ // split the polygon in two by the diagonal
329
+ let c = splitPolygon(a, b);
330
+ // filter colinear points around the cuts
331
+ a = filterPoints(a, a.next);
332
+ c = filterPoints(c, c.next);
333
+ // run earcut on each half
334
+ earcutLinked(a, triangles, minX, minY, invSize, 0);
335
+ earcutLinked(c, triangles, minX, minY, invSize, 0);
336
+ return;
337
+ }
338
+ b = b.next;
339
+ }
340
+ a = a.next;
341
+ } while (a !== start);
342
+ }
343
+ // link every hole into the outer loop, producing a single-ring polygon without holes
344
+ function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
345
+ const queue = activeHoleQueue;
346
+ queue.length = 0;
347
+ let i;
348
+ let len;
349
+ let start;
350
+ let end;
351
+ let list;
352
+ for (i = 0, len = holeIndices.length; i < len; i++) {
353
+ start = holeIndices[i] * dim;
354
+ end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
355
+ list = linkedList(data, start, end, dim, false, areas && areas[i + 1], plane);
356
+ if (!list)
357
+ continue;
358
+ if (list === list.next)
359
+ list.steiner = true;
360
+ queue.push(getLeftmost(list));
361
+ }
362
+ queue.sort(compareX);
363
+ // process holes from left to right
364
+ for (i = 0; i < queue.length; i++) {
365
+ outerNode = eliminateHole(queue[i], outerNode);
366
+ }
367
+ return outerNode;
368
+ }
369
+ function compareX(a, b) {
370
+ return a.x - b.x;
371
+ }
372
+ // find a bridge between vertices that connects hole with an outer ring and and link it
373
+ function eliminateHole(hole, outerNode) {
374
+ const bridge = findHoleBridge(hole, outerNode);
375
+ if (!bridge) {
376
+ return outerNode;
377
+ }
378
+ const bridgeReverse = splitPolygon(bridge, hole);
379
+ // filter collinear points around the cuts
380
+ filterPoints(bridgeReverse, bridgeReverse.next);
381
+ return filterPoints(bridge, bridge.next);
382
+ }
383
+ // David Eberly's algorithm for finding a bridge between hole and outer polygon
384
+ function findHoleBridge(hole, outerNode) {
385
+ let p = outerNode;
386
+ const hx = hole.x;
387
+ const hy = hole.y;
388
+ let qx = -Infinity;
389
+ let m;
390
+ // find a segment intersected by a ray from the hole's leftmost point to the left;
391
+ // segment's endpoint with lesser x will be potential connection point
392
+ do {
393
+ if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
394
+ const x = p.x + ((hy - p.y) * (p.next.x - p.x)) / (p.next.y - p.y);
395
+ if (x <= hx && x > qx) {
396
+ qx = x;
397
+ m = p.x < p.next.x ? p : p.next;
398
+ if (x === hx)
399
+ return m; // hole touches outer segment; pick leftmost endpoint
400
+ }
401
+ }
402
+ p = p.next;
403
+ } while (p !== outerNode);
404
+ if (!m)
405
+ return null;
406
+ // look for points inside the triangle of hole point, segment intersection and endpoint;
407
+ // if there are no points found, we have a valid connection;
408
+ // otherwise choose the point of the minimum angle with the ray as connection point
409
+ const stop = m;
410
+ const mx = m.x;
411
+ const my = m.y;
412
+ let tanMin = Infinity;
413
+ let tan;
414
+ p = m;
415
+ do {
416
+ if (hx >= p.x &&
417
+ p.x >= mx &&
418
+ hx !== p.x &&
419
+ pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
420
+ tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
421
+ if (locallyInside(p, hole) &&
422
+ (tan < tanMin ||
423
+ (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
424
+ m = p;
425
+ tanMin = tan;
426
+ }
427
+ }
428
+ p = p.next;
429
+ } while (p !== stop);
430
+ return m;
431
+ }
432
+ // whether sector in vertex m contains sector in vertex p in the same coordinates
433
+ function sectorContainsSector(m, p) {
434
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
435
+ }
436
+ // interlink polygon nodes in z-order
437
+ function indexCurve(start, minX, minY, invSize) {
438
+ let p = start;
439
+ do {
440
+ if (p.z === 0)
441
+ p.z = zOrder(p.x, p.y, minX, minY, invSize);
442
+ p.prevZ = p.prev;
443
+ p.nextZ = p.next;
444
+ p = p.next;
445
+ } while (p !== start);
446
+ p.prevZ.nextZ = null;
447
+ p.prevZ = null;
448
+ sortLinked(p);
449
+ }
450
+ // Simon Tatham's linked list merge sort algorithm
451
+ // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
452
+ function sortLinked(list) {
453
+ let e;
454
+ let i;
455
+ let inSize = 1;
456
+ let numMerges;
457
+ let p;
458
+ let pSize;
459
+ let q;
460
+ let qSize;
461
+ let tail;
462
+ do {
463
+ p = list;
464
+ list = null;
465
+ tail = null;
466
+ numMerges = 0;
467
+ while (p) {
468
+ numMerges++;
469
+ q = p;
470
+ pSize = 0;
471
+ for (i = 0; i < inSize; i++) {
472
+ pSize++;
473
+ q = q.nextZ;
474
+ if (!q)
475
+ break;
476
+ }
477
+ qSize = inSize;
478
+ while (pSize > 0 || (qSize > 0 && q)) {
479
+ if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
480
+ e = p;
481
+ p = p.nextZ;
482
+ pSize--;
483
+ }
484
+ else {
485
+ e = q;
486
+ q = q.nextZ;
487
+ qSize--;
488
+ }
489
+ if (tail)
490
+ tail.nextZ = e;
491
+ else
492
+ list = e;
493
+ e.prevZ = tail;
494
+ tail = e;
495
+ }
496
+ p = q;
497
+ }
498
+ tail.nextZ = null;
499
+ inSize *= 2;
500
+ } while (numMerges > 1);
501
+ return list;
502
+ }
503
+ // z-order of a point given coords and inverse of the longer side of data bbox
504
+ function zOrder(x, y, minX, minY, invSize) {
505
+ // coords are transformed into non-negative 15-bit integer range
506
+ x = ((x - minX) * invSize) | 0;
507
+ y = ((y - minY) * invSize) | 0;
508
+ x = (x | (x << 8)) & 0x00ff00ff;
509
+ x = (x | (x << 4)) & 0x0f0f0f0f;
510
+ x = (x | (x << 2)) & 0x33333333;
511
+ x = (x | (x << 1)) & 0x55555555;
512
+ y = (y | (y << 8)) & 0x00ff00ff;
513
+ y = (y | (y << 4)) & 0x0f0f0f0f;
514
+ y = (y | (y << 2)) & 0x33333333;
515
+ y = (y | (y << 1)) & 0x55555555;
516
+ return x | (y << 1);
517
+ }
518
+ // find the leftmost node of a polygon ring
519
+ function getLeftmost(start) {
520
+ let p = start;
521
+ let leftmost = start;
522
+ do {
523
+ if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y))
524
+ leftmost = p;
525
+ p = p.next;
526
+ } while (p !== start);
527
+ return leftmost;
528
+ }
529
+ // check if a point lies within a convex triangle
530
+ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
531
+ return ((cx - px) * (ay - py) >= (ax - px) * (cy - py) &&
532
+ (ax - px) * (by - py) >= (bx - px) * (ay - py) &&
533
+ (bx - px) * (cy - py) >= (cx - px) * (by - py));
534
+ }
535
+ // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
536
+ function isValidDiagonal(a, b) {
537
+ return (a.next.i !== b.i &&
538
+ a.prev.i !== b.i &&
539
+ !intersectsPolygon(a, b) && // dones't intersect other edges
540
+ ((locallyInside(a, b) &&
541
+ locallyInside(b, a) &&
542
+ middleInside(a, b) && // locally visible
543
+ (area(a.prev, a, b.prev) || area(a, b.prev, b))) || // does not create opposite-facing sectors
544
+ (equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0))); // special zero-length case
545
+ }
546
+ // signed area of a triangle
547
+ function area(p, q, r) {
548
+ return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
549
+ }
550
+ // check if two points are equal
551
+ function equals(p1, p2) {
552
+ return p1.x === p2.x && p1.y === p2.y;
553
+ }
554
+ // check if two segments intersect
555
+ function intersects(p1, q1, p2, q2) {
556
+ const o1 = sign(area(p1, q1, p2));
557
+ const o2 = sign(area(p1, q1, q2));
558
+ const o3 = sign(area(p2, q2, p1));
559
+ const o4 = sign(area(p2, q2, q1));
560
+ if (o1 !== o2 && o3 !== o4)
561
+ return true; // general case
562
+ if (o1 === 0 && onSegment(p1, p2, q1))
563
+ return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
564
+ if (o2 === 0 && onSegment(p1, q2, q1))
565
+ return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
566
+ if (o3 === 0 && onSegment(p2, p1, q2))
567
+ return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
568
+ if (o4 === 0 && onSegment(p2, q1, q2))
569
+ return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
570
+ return false;
571
+ }
572
+ // for collinear points p, q, r, check if point q lies on segment pr
573
+ function onSegment(p, q, r) {
574
+ return (q.x <= Math.max(p.x, r.x) &&
575
+ q.x >= Math.min(p.x, r.x) &&
576
+ q.y <= Math.max(p.y, r.y) &&
577
+ q.y >= Math.min(p.y, r.y));
578
+ }
579
+ function sign(num) {
580
+ return num > 0 ? 1 : num < 0 ? -1 : 0;
581
+ }
582
+ // check if a polygon diagonal intersects any polygon segments
583
+ function intersectsPolygon(a, b) {
584
+ let p = a;
585
+ do {
586
+ if (p.i !== a.i &&
587
+ p.next.i !== a.i &&
588
+ p.i !== b.i &&
589
+ p.next.i !== b.i &&
590
+ intersects(p, p.next, a, b))
591
+ return true;
592
+ p = p.next;
593
+ } while (p !== a);
594
+ return false;
595
+ }
596
+ // check if a polygon diagonal is locally inside the polygon
597
+ function locallyInside(a, b) {
598
+ return area(a.prev, a, a.next) < 0
599
+ ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0
600
+ : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
601
+ }
602
+ // check if the middle point of a polygon diagonal is inside the polygon
603
+ function middleInside(a, b) {
604
+ let p = a;
605
+ let inside = false;
606
+ const px = (a.x + b.x) / 2;
607
+ const py = (a.y + b.y) / 2;
608
+ do {
609
+ if (p.y > py !== p.next.y > py &&
610
+ p.next.y !== p.y &&
611
+ px < ((p.next.x - p.x) * (py - p.y)) / (p.next.y - p.y) + p.x)
612
+ inside = !inside;
613
+ p = p.next;
614
+ } while (p !== a);
615
+ return inside;
616
+ }
617
+ // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
618
+ // if one belongs to the outer ring and another to a hole, it merges it into a single ring
619
+ function splitPolygon(a, b) {
620
+ const a2 = allocateVertex(a.i, a.x, a.y);
621
+ const b2 = allocateVertex(b.i, b.x, b.y);
622
+ const an = a.next;
623
+ const bp = b.prev;
624
+ a.next = b;
625
+ b.prev = a;
626
+ a2.next = an;
627
+ an.prev = a2;
628
+ b2.next = a2;
629
+ a2.prev = b2;
630
+ bp.next = b2;
631
+ b2.prev = bp;
632
+ return b2;
633
+ }
634
+ // create a node and optionally link it with previous one (in a circular doubly linked list)
635
+ function insertNode(i, x, y, last) {
636
+ const p = allocateVertex(i, x, y);
637
+ if (!last) {
638
+ p.prev = p;
639
+ p.next = p;
640
+ }
641
+ else {
642
+ p.next = last.next;
643
+ p.prev = last;
644
+ last.next.prev = p;
645
+ last.next = p;
646
+ }
647
+ return p;
648
+ }
649
+ function removeNode(p) {
650
+ p.next.prev = p.prev;
651
+ p.prev.next = p.next;
652
+ if (p.prevZ)
653
+ p.prevZ.nextZ = p.nextZ;
654
+ if (p.nextZ)
655
+ p.nextZ.prevZ = p.prevZ;
656
+ }
657
+ // Reuse scratch nodes and queues across calls; no input or output arrays are retained.
658
+ const vertexPool = [];
659
+ let vertexPoolIndex = 0;
660
+ const holeQueues = [];
661
+ let activeHoleQueue = [];
662
+ let callDepth = 0;
663
+ function allocateVertex(i, x, y) {
664
+ let vertex = vertexPool[vertexPoolIndex];
665
+ if (!vertex)
666
+ vertexPool[vertexPoolIndex] = vertex = new Vertex(i, x, y);
667
+ vertexPoolIndex++;
668
+ vertex.i = i;
669
+ vertex.x = x;
670
+ vertex.y = y;
671
+ vertex.prev = vertex.next = vertex.prevZ = vertex.nextZ = null;
672
+ vertex.z = 0;
673
+ vertex.steiner = false;
674
+ return vertex;
675
+ }
676
+ class Vertex {
677
+ constructor(i, x, y) {
678
+ // previous and next vertex nodes in a polygon ring
679
+ this.prev = null;
680
+ this.next = null;
681
+ // z-order curve value
682
+ this.z = 0;
683
+ // previous and next nodes in z-order
684
+ this.prevZ = null;
685
+ this.nextZ = null;
686
+ // indicates whether this is a steiner point
687
+ this.steiner = false;
688
+ this.i = i;
689
+ this.x = x;
690
+ this.y = y;
691
+ }
692
+ }
693
+ //# sourceMappingURL=earcut.js.map