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

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 (378) 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 +2124 -0
  9. package/dist/culling/index.cjs.map +6 -0
  10. package/dist/culling/index.d.ts +31 -0
  11. package/dist/culling/index.d.ts.map +1 -0
  12. package/dist/culling/index.js +25 -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.d.ts +22 -0
  91. package/dist/culling/oriented-box-2d.d.ts.map +1 -0
  92. package/dist/culling/oriented-box-2d.js +86 -0
  93. package/dist/culling/oriented-box-2d.js.map +1 -0
  94. package/dist/culling/queries.d.ts +44 -0
  95. package/dist/culling/queries.d.ts.map +1 -0
  96. package/dist/culling/queries.js +259 -0
  97. package/dist/culling/queries.js.map +1 -0
  98. package/dist/curves/bezier-curves.d.ts +18 -0
  99. package/dist/curves/bezier-curves.d.ts.map +1 -0
  100. package/dist/curves/bezier-curves.js +54 -0
  101. package/dist/curves/bezier-curves.js.map +1 -0
  102. package/dist/curves/catmull-rom-curve.d.ts +15 -0
  103. package/dist/curves/catmull-rom-curve.d.ts.map +1 -0
  104. package/dist/curves/catmull-rom-curve.js +77 -0
  105. package/dist/curves/catmull-rom-curve.js.map +1 -0
  106. package/dist/curves/curve-arc-length.d.ts +17 -0
  107. package/dist/curves/curve-arc-length.d.ts.map +1 -0
  108. package/dist/curves/curve-arc-length.js +58 -0
  109. package/dist/curves/curve-arc-length.js.map +1 -0
  110. package/dist/curves/curve.d.ts +23 -0
  111. package/dist/curves/curve.d.ts.map +1 -0
  112. package/dist/curves/curve.js +77 -0
  113. package/dist/curves/curve.js.map +1 -0
  114. package/dist/curves/hermite-curve.d.ts +9 -0
  115. package/dist/curves/hermite-curve.d.ts.map +1 -0
  116. package/dist/curves/hermite-curve.js +24 -0
  117. package/dist/curves/hermite-curve.js.map +1 -0
  118. package/dist/curves/index.d.ts +8 -0
  119. package/dist/curves/index.d.ts.map +1 -0
  120. package/dist/curves/index.js +9 -0
  121. package/dist/curves/index.js.map +1 -0
  122. package/dist/geometries/box-geometry.js +1 -1
  123. package/dist/geometries/box-geometry.js.map +1 -1
  124. package/dist/geometries/capsule-geometry.js +1 -1
  125. package/dist/geometries/capsule-geometry.js.map +1 -1
  126. package/dist/geometries/cylinder-geometry.js +1 -1
  127. package/dist/geometries/cylinder-geometry.js.map +1 -1
  128. package/dist/geometries/geometry-helpers.js +1 -1
  129. package/dist/geometries/geometry-helpers.js.map +1 -1
  130. package/dist/geometries/ico-sphere-geometry.js +1 -1
  131. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  132. package/dist/geometries/plane-geometry.js +1 -1
  133. package/dist/geometries/plane-geometry.js.map +1 -1
  134. package/dist/geometries/primitive-mesh-builder.d.ts +24 -0
  135. package/dist/geometries/primitive-mesh-builder.d.ts.map +1 -0
  136. package/dist/geometries/primitive-mesh-builder.js +74 -0
  137. package/dist/geometries/primitive-mesh-builder.js.map +1 -0
  138. package/dist/geometries/prism-geometry.d.ts +13 -0
  139. package/dist/geometries/prism-geometry.d.ts.map +1 -0
  140. package/dist/geometries/prism-geometry.js +34 -0
  141. package/dist/geometries/prism-geometry.js.map +1 -0
  142. package/dist/geometries/ring-geometry.d.ts +15 -0
  143. package/dist/geometries/ring-geometry.d.ts.map +1 -0
  144. package/dist/geometries/ring-geometry.js +64 -0
  145. package/dist/geometries/ring-geometry.js.map +1 -0
  146. package/dist/geometries/sphere-geometry.js +1 -1
  147. package/dist/geometries/sphere-geometry.js.map +1 -1
  148. package/dist/geometries/surface-of-revolution.js +1 -1
  149. package/dist/geometries/surface-of-revolution.js.map +1 -1
  150. package/dist/geometries/truncated-cone-geometry.js +1 -1
  151. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  152. package/dist/index.cjs +6105 -16
  153. package/dist/index.cjs.map +3 -3
  154. package/dist/index.d.ts +26 -0
  155. package/dist/index.d.ts.map +1 -1
  156. package/dist/index.js +15 -1
  157. package/dist/index.js.map +1 -1
  158. package/dist/lib/geometry-utils.js +1 -1
  159. package/dist/lib/geometry-utils.js.map +1 -1
  160. package/dist/lib/geometry.d.ts +1 -1
  161. package/dist/lib/geometry.d.ts.map +1 -1
  162. package/dist/lib/geometry.js +1 -1
  163. package/dist/lib/geometry.js.map +1 -1
  164. package/dist/lib/hinge-tree.d.ts +33 -0
  165. package/dist/lib/hinge-tree.d.ts.map +1 -0
  166. package/dist/lib/hinge-tree.js +144 -0
  167. package/dist/lib/hinge-tree.js.map +1 -0
  168. package/dist/parametric/lathe-geometry.d.ts +14 -0
  169. package/dist/parametric/lathe-geometry.d.ts.map +1 -0
  170. package/dist/parametric/lathe-geometry.js +48 -0
  171. package/dist/parametric/lathe-geometry.js.map +1 -0
  172. package/dist/parametric/parametric-geometry.d.ts +20 -0
  173. package/dist/parametric/parametric-geometry.d.ts.map +1 -0
  174. package/dist/parametric/parametric-geometry.js +88 -0
  175. package/dist/parametric/parametric-geometry.js.map +1 -0
  176. package/dist/parametric/torus-geometry.d.ts +19 -0
  177. package/dist/parametric/torus-geometry.d.ts.map +1 -0
  178. package/dist/parametric/torus-geometry.js +89 -0
  179. package/dist/parametric/torus-geometry.js.map +1 -0
  180. package/dist/parametric.d.ts +7 -0
  181. package/dist/parametric.d.ts.map +1 -0
  182. package/dist/parametric.js +7 -0
  183. package/dist/parametric.js.map +1 -0
  184. package/dist/polygon/clip-triangle-mesh.d.ts +41 -0
  185. package/dist/polygon/clip-triangle-mesh.d.ts.map +1 -0
  186. package/dist/polygon/clip-triangle-mesh.js +155 -0
  187. package/dist/polygon/clip-triangle-mesh.js.map +1 -0
  188. package/dist/polygon/cut-by-grid.d.ts +24 -0
  189. package/dist/polygon/cut-by-grid.d.ts.map +1 -0
  190. package/dist/polygon/cut-by-grid.js +221 -0
  191. package/dist/polygon/cut-by-grid.js.map +1 -0
  192. package/dist/polygon/cut-by-mercator-bounds.d.ts +17 -0
  193. package/dist/polygon/cut-by-mercator-bounds.d.ts.map +1 -0
  194. package/dist/polygon/cut-by-mercator-bounds.js +149 -0
  195. package/dist/polygon/cut-by-mercator-bounds.js.map +1 -0
  196. package/dist/polygon/earcut.d.ts +13 -0
  197. package/dist/polygon/earcut.d.ts.map +1 -0
  198. package/dist/polygon/earcut.js +693 -0
  199. package/dist/polygon/earcut.js.map +1 -0
  200. package/dist/polygon/index.d.ts +14 -0
  201. package/dist/polygon/index.d.ts.map +1 -0
  202. package/dist/polygon/index.js +13 -0
  203. package/dist/polygon/index.js.map +1 -0
  204. package/dist/polygon/lineclip.d.ts +31 -0
  205. package/dist/polygon/lineclip.d.ts.map +1 -0
  206. package/dist/polygon/lineclip.js +184 -0
  207. package/dist/polygon/lineclip.js.map +1 -0
  208. package/dist/polygon/polygon-utils.d.ts +103 -0
  209. package/dist/polygon/polygon-utils.d.ts.map +1 -0
  210. package/dist/polygon/polygon-utils.js +155 -0
  211. package/dist/polygon/polygon-utils.js.map +1 -0
  212. package/dist/polygon/polygon.d.ts +41 -0
  213. package/dist/polygon/polygon.d.ts.map +1 -0
  214. package/dist/polygon/polygon.js +76 -0
  215. package/dist/polygon/polygon.js.map +1 -0
  216. package/dist/polygon/subdivide-polyline.d.ts +56 -0
  217. package/dist/polygon/subdivide-polyline.d.ts.map +1 -0
  218. package/dist/polygon/subdivide-polyline.js +141 -0
  219. package/dist/polygon/subdivide-polyline.js.map +1 -0
  220. package/dist/polygon/subdivide-triangle-mesh.d.ts +78 -0
  221. package/dist/polygon/subdivide-triangle-mesh.d.ts.map +1 -0
  222. package/dist/polygon/subdivide-triangle-mesh.js +238 -0
  223. package/dist/polygon/subdivide-triangle-mesh.js.map +1 -0
  224. package/dist/polygon/utils.d.ts +5 -0
  225. package/dist/polygon/utils.d.ts.map +1 -0
  226. package/dist/polygon/utils.js +38 -0
  227. package/dist/polygon/utils.js.map +1 -0
  228. package/dist/spatial-index/box-index.d.ts +86 -0
  229. package/dist/spatial-index/box-index.d.ts.map +1 -0
  230. package/dist/spatial-index/box-index.js +335 -0
  231. package/dist/spatial-index/box-index.js.map +1 -0
  232. package/dist/spatial-index/index.d.ts +7 -0
  233. package/dist/spatial-index/index.d.ts.map +1 -0
  234. package/dist/spatial-index/index.js +6 -0
  235. package/dist/spatial-index/index.js.map +1 -0
  236. package/dist/spatial-index/triangle-bvh.d.ts +74 -0
  237. package/dist/spatial-index/triangle-bvh.d.ts.map +1 -0
  238. package/dist/spatial-index/triangle-bvh.js +221 -0
  239. package/dist/spatial-index/triangle-bvh.js.map +1 -0
  240. package/dist/utils/attribute-compression.d.ts +50 -0
  241. package/dist/utils/attribute-compression.d.ts.map +1 -0
  242. package/dist/utils/attribute-compression.js +186 -0
  243. package/dist/utils/attribute-compression.js.map +1 -0
  244. package/dist/utils/attribute-iterator.d.ts +8 -0
  245. package/dist/utils/attribute-iterator.d.ts.map +1 -0
  246. package/dist/utils/attribute-iterator.js +25 -0
  247. package/dist/utils/attribute-iterator.js.map +1 -0
  248. package/dist/utils/compose-attribute-provenance.d.ts +13 -0
  249. package/dist/utils/compose-attribute-provenance.d.ts.map +1 -0
  250. package/dist/utils/compose-attribute-provenance.js +63 -0
  251. package/dist/utils/compose-attribute-provenance.js.map +1 -0
  252. package/dist/utils/compute-vertex-normals.d.ts +4 -0
  253. package/dist/utils/compute-vertex-normals.d.ts.map +1 -0
  254. package/dist/utils/compute-vertex-normals.js +54 -0
  255. package/dist/utils/compute-vertex-normals.js.map +1 -0
  256. package/dist/utils/constants.d.ts +52 -0
  257. package/dist/utils/constants.d.ts.map +1 -0
  258. package/dist/utils/constants.js +39 -0
  259. package/dist/utils/constants.js.map +1 -0
  260. package/dist/utils/coordinates.d.ts +3 -0
  261. package/dist/utils/coordinates.d.ts.map +1 -0
  262. package/dist/utils/coordinates.js +8 -0
  263. package/dist/utils/coordinates.js.map +1 -0
  264. package/dist/utils/geometry.d.ts +20 -0
  265. package/dist/utils/geometry.d.ts.map +1 -0
  266. package/dist/utils/geometry.js +31 -0
  267. package/dist/utils/geometry.js.map +1 -0
  268. package/dist/utils/gl-type.d.ts +17 -0
  269. package/dist/utils/gl-type.d.ts.map +1 -0
  270. package/dist/utils/gl-type.js +69 -0
  271. package/dist/utils/gl-type.js.map +1 -0
  272. package/dist/utils/index.d.ts +18 -0
  273. package/dist/utils/index.d.ts.map +1 -0
  274. package/dist/utils/index.js +16 -0
  275. package/dist/utils/index.js.map +1 -0
  276. package/dist/utils/interpolate-packed-attributes.d.ts +43 -0
  277. package/dist/utils/interpolate-packed-attributes.d.ts.map +1 -0
  278. package/dist/utils/interpolate-packed-attributes.js +192 -0
  279. package/dist/utils/interpolate-packed-attributes.js.map +1 -0
  280. package/dist/utils/mesh-processing.d.ts +18 -0
  281. package/dist/utils/mesh-processing.d.ts.map +1 -0
  282. package/dist/utils/mesh-processing.js +300 -0
  283. package/dist/utils/mesh-processing.js.map +1 -0
  284. package/dist/utils/primitive-iterator.d.ts +21 -0
  285. package/dist/utils/primitive-iterator.d.ts.map +1 -0
  286. package/dist/utils/primitive-iterator.js +117 -0
  287. package/dist/utils/primitive-iterator.js.map +1 -0
  288. package/dist/utils/qualify-surface-transition.d.ts +21 -0
  289. package/dist/utils/qualify-surface-transition.d.ts.map +1 -0
  290. package/dist/utils/qualify-surface-transition.js +140 -0
  291. package/dist/utils/qualify-surface-transition.js.map +1 -0
  292. package/dist/utils/rgb565.d.ts +5 -0
  293. package/dist/utils/rgb565.d.ts.map +1 -0
  294. package/dist/utils/rgb565.js +24 -0
  295. package/dist/utils/rgb565.js.map +1 -0
  296. package/dist/utils/typed-array-utils.d.ts +3 -0
  297. package/dist/utils/typed-array-utils.d.ts.map +1 -0
  298. package/dist/utils/typed-array-utils.js +16 -0
  299. package/dist/utils/typed-array-utils.js.map +1 -0
  300. package/package.json +12 -4
  301. package/src/culling/constants.ts +6 -0
  302. package/src/culling/index.ts +55 -0
  303. package/src/culling/lib/algorithms/bounding-box-from-points.ts +174 -0
  304. package/src/culling/lib/algorithms/bounding-sphere-from-points.ts +175 -0
  305. package/src/culling/lib/algorithms/compute-eigen-decomposition.ts +171 -0
  306. package/src/culling/lib/algorithms/oriented-bounding-box-quaternion.ts +32 -0
  307. package/src/culling/lib/bounding-volumes/axis-aligned-bounding-box.ts +153 -0
  308. package/src/culling/lib/bounding-volumes/bounding-sphere.ts +154 -0
  309. package/src/culling/lib/bounding-volumes/bounding-volume.ts +38 -0
  310. package/src/culling/lib/bounding-volumes/oriented-bounding-box.ts +320 -0
  311. package/src/culling/lib/culling-volume.ts +163 -0
  312. package/src/culling/lib/perspective-frustum.ts +288 -0
  313. package/src/culling/lib/perspective-off-center-frustum.ts +381 -0
  314. package/src/culling/lib/plane.ts +118 -0
  315. package/src/culling/lib/ray.ts +33 -0
  316. package/src/culling/lib/shapes/box-shape.ts +78 -0
  317. package/src/culling/lib/shapes/capsule-shape.ts +232 -0
  318. package/src/culling/lib/shapes/cylinder-shape.ts +133 -0
  319. package/src/culling/lib/shapes/implicit-shape.ts +209 -0
  320. package/src/culling/lib/shapes/plane-shape.ts +78 -0
  321. package/src/culling/lib/shapes/sphere-shape.ts +60 -0
  322. package/src/culling/oriented-box-2d.ts +165 -0
  323. package/src/culling/queries.ts +332 -0
  324. package/src/curves/bezier-curves.ts +62 -0
  325. package/src/curves/catmull-rom-curve.ts +89 -0
  326. package/src/curves/curve-arc-length.ts +70 -0
  327. package/src/curves/curve.ts +96 -0
  328. package/src/curves/hermite-curve.ts +34 -0
  329. package/src/curves/index.ts +15 -0
  330. package/src/geometries/box-geometry.ts +1 -1
  331. package/src/geometries/capsule-geometry.ts +1 -1
  332. package/src/geometries/cylinder-geometry.ts +1 -1
  333. package/src/geometries/geometry-helpers.ts +1 -1
  334. package/src/geometries/ico-sphere-geometry.ts +1 -1
  335. package/src/geometries/plane-geometry.ts +1 -1
  336. package/src/geometries/primitive-mesh-builder.ts +84 -0
  337. package/src/geometries/prism-geometry.ts +57 -0
  338. package/src/geometries/ring-geometry.ts +102 -0
  339. package/src/geometries/sphere-geometry.ts +1 -1
  340. package/src/geometries/surface-of-revolution.ts +1 -1
  341. package/src/geometries/truncated-cone-geometry.ts +1 -1
  342. package/src/index.ts +179 -1
  343. package/src/lib/geometry-utils.ts +2 -2
  344. package/src/lib/geometry.ts +2 -2
  345. package/src/lib/hinge-tree.ts +170 -0
  346. package/src/parametric/lathe-geometry.ts +70 -0
  347. package/src/parametric/parametric-geometry.ts +118 -0
  348. package/src/parametric/torus-geometry.ts +118 -0
  349. package/src/parametric.ts +9 -0
  350. package/src/polygon/clip-triangle-mesh.ts +218 -0
  351. package/src/polygon/cut-by-grid.ts +313 -0
  352. package/src/polygon/cut-by-mercator-bounds.ts +204 -0
  353. package/src/polygon/earcut.ts +859 -0
  354. package/src/polygon/index.ts +42 -0
  355. package/src/polygon/lineclip.ts +218 -0
  356. package/src/polygon/polygon-utils.ts +273 -0
  357. package/src/polygon/polygon.ts +105 -0
  358. package/src/polygon/subdivide-polyline.ts +223 -0
  359. package/src/polygon/subdivide-triangle-mesh.ts +342 -0
  360. package/src/polygon/utils.ts +50 -0
  361. package/src/spatial-index/box-index.ts +452 -0
  362. package/src/spatial-index/index.ts +20 -0
  363. package/src/spatial-index/triangle-bvh.ts +345 -0
  364. package/src/utils/attribute-compression.ts +234 -0
  365. package/src/utils/attribute-iterator.ts +28 -0
  366. package/src/utils/compose-attribute-provenance.ts +74 -0
  367. package/src/utils/compute-vertex-normals.ts +63 -0
  368. package/src/utils/constants.ts +42 -0
  369. package/src/utils/coordinates.ts +8 -0
  370. package/src/utils/geometry.ts +49 -0
  371. package/src/utils/gl-type.ts +87 -0
  372. package/src/utils/index.ts +55 -0
  373. package/src/utils/interpolate-packed-attributes.ts +284 -0
  374. package/src/utils/mesh-processing.ts +377 -0
  375. package/src/utils/primitive-iterator.ts +145 -0
  376. package/src/utils/qualify-surface-transition.ts +169 -0
  377. package/src/utils/rgb565.ts +26 -0
  378. package/src/utils/typed-array-utils.ts +16 -0
@@ -0,0 +1,38 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT AND Apache-2.0
3
+ // SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
4
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
5
+ // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
+
7
+ import {Plane} from '../plane';
8
+ import type {CullingResult} from '../../constants';
9
+
10
+ /**
11
+ * Common interface for BoundingVolumes
12
+ * including BoundingSphere, AxisAlignedBoundingBox and OrientedBoundingBox
13
+ */
14
+ export interface BoundingVolume {
15
+ /**
16
+ * Applies a 4x4 affine transformation matrix to a bounding sphere.
17
+ * @param sphere The bounding sphere to apply the transformation to.
18
+ * @param transform The transformation matrix to apply to the bounding sphere.
19
+ * @returns itself, i.e. the modified BoundingVolume.
20
+ */
21
+ transform(transform: readonly number[]): this;
22
+
23
+ /** Computes the estimated distance squared from the closest point on a bounding sphere to a point. */
24
+ distanceSquaredTo(point: readonly number[]): number;
25
+ /** Computes the estimated distance from the closest point on a bounding sphere to a point. */
26
+ distanceTo(point: readonly number[]): number;
27
+
28
+ /**
29
+ * Determines which side of a plane the oriented bounding box is located.
30
+ *
31
+ * @param plane The plane to test against.
32
+ * @returns
33
+ * - `'inside'` if the entire box is on the side of the plane the normal is pointing.
34
+ * - `'outside'` if the entire box is on the opposite side.
35
+ * - `'intersecting'` if the box intersects the plane.
36
+ */
37
+ intersectPlane(plane: Plane): CullingResult;
38
+ }
@@ -0,0 +1,320 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT AND Apache-2.0
3
+ // SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
4
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
5
+ // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
+
7
+ // This file is derived from the Cesium math library under Apache 2 license
8
+ // See ../../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
+
10
+ import {NumericArray} from '@math.gl/core';
11
+ import {Vector3, Matrix3, Matrix4} from '@math.gl/core';
12
+
13
+ import type {BoundingVolume} from './bounding-volume';
14
+ import {BoundingSphere} from './bounding-sphere';
15
+ import {Plane} from '../plane';
16
+ import type {CullingResult} from '../../constants';
17
+
18
+ const scratchVector3 = new Vector3();
19
+ const scratchOffset = new Vector3();
20
+ const scratchVectorU = new Vector3();
21
+ const scratchVectorV = new Vector3();
22
+ const scratchVectorW = new Vector3();
23
+ const scratchCorner = new Vector3();
24
+ const scratchToCenter = new Vector3();
25
+
26
+ const MATRIX3 = {
27
+ COLUMN0ROW0: 0,
28
+ COLUMN0ROW1: 1,
29
+ COLUMN0ROW2: 2,
30
+ COLUMN1ROW0: 3,
31
+ COLUMN1ROW1: 4,
32
+ COLUMN1ROW2: 5,
33
+ COLUMN2ROW0: 6,
34
+ COLUMN2ROW1: 7,
35
+ COLUMN2ROW2: 8
36
+ };
37
+
38
+ /**
39
+ * An OrientedBoundingBox of some object is a closed and convex cuboid.
40
+ * It can provide a tighter bounding volume than `BoundingSphere` or
41
+ * `AxisAlignedBoundingBox` in many cases.
42
+ */
43
+ export class OrientedBoundingBox implements BoundingVolume {
44
+ center: Vector3;
45
+ halfAxes: Matrix3;
46
+
47
+ /**
48
+ * An OrientedBoundingBox of some object is a closed and convex cuboid.
49
+ * It can provide a tighter bounding volume than
50
+ * `BoundingSphere` or `AxisAlignedBoundingBox` in many cases.
51
+ */
52
+ constructor(center?: Readonly<NumericArray>, halfAxes?: Readonly<NumericArray>);
53
+ constructor(
54
+ center: Readonly<NumericArray> = [0, 0, 0],
55
+ halfAxes: Readonly<NumericArray> = [0, 0, 0, 0, 0, 0, 0, 0, 0]
56
+ ) {
57
+ this.center = new Vector3().from(center);
58
+ this.halfAxes = new Matrix3(halfAxes);
59
+ }
60
+
61
+ /** Returns an array with three halfSizes for the bounding box */
62
+ get halfSize(): number[] {
63
+ const xAxis = this.halfAxes.getColumn(0);
64
+ const yAxis = this.halfAxes.getColumn(1);
65
+ const zAxis = this.halfAxes.getColumn(2);
66
+ return [new Vector3(xAxis).len(), new Vector3(yAxis).len(), new Vector3(zAxis).len()];
67
+ }
68
+
69
+ /** Duplicates a OrientedBoundingBox instance. */
70
+ clone(): OrientedBoundingBox {
71
+ return new OrientedBoundingBox(this.center, this.halfAxes);
72
+ }
73
+
74
+ /** Compares the provided OrientedBoundingBox component wise and returns */
75
+ equals(right: OrientedBoundingBox): boolean {
76
+ return (
77
+ this === right ||
78
+ (Boolean(right) && this.center.equals(right.center) && this.halfAxes.equals(right.halfAxes))
79
+ );
80
+ }
81
+
82
+ /** Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box. */
83
+ getBoundingSphere(result = new BoundingSphere()): BoundingSphere {
84
+ const halfAxes = this.halfAxes;
85
+ const u = halfAxes.getColumn(0, scratchVectorU);
86
+ const v = halfAxes.getColumn(1, scratchVectorV);
87
+ const w = halfAxes.getColumn(2, scratchVectorW);
88
+
89
+ // Calculate "corner" vector
90
+ const cornerVector = scratchVector3.copy(u).add(v).add(w);
91
+
92
+ result.center.copy(this.center);
93
+ result.radius = cornerVector.magnitude();
94
+
95
+ return result;
96
+ }
97
+
98
+ /** Determines which side of a plane the oriented bounding box is located. */
99
+ intersectPlane(plane: Plane): CullingResult {
100
+ const center = this.center;
101
+ const normal = plane.normal;
102
+ const halfAxes = this.halfAxes;
103
+
104
+ const normalX = normal.x;
105
+ const normalY = normal.y;
106
+ const normalZ = normal.z;
107
+
108
+ // Plane is used as if it is its normal; the first three components are assumed to be normalized
109
+ const radEffective =
110
+ Math.abs(
111
+ normalX * halfAxes[MATRIX3.COLUMN0ROW0] +
112
+ normalY * halfAxes[MATRIX3.COLUMN0ROW1] +
113
+ normalZ * halfAxes[MATRIX3.COLUMN0ROW2]
114
+ ) +
115
+ Math.abs(
116
+ normalX * halfAxes[MATRIX3.COLUMN1ROW0] +
117
+ normalY * halfAxes[MATRIX3.COLUMN1ROW1] +
118
+ normalZ * halfAxes[MATRIX3.COLUMN1ROW2]
119
+ ) +
120
+ Math.abs(
121
+ normalX * halfAxes[MATRIX3.COLUMN2ROW0] +
122
+ normalY * halfAxes[MATRIX3.COLUMN2ROW1] +
123
+ normalZ * halfAxes[MATRIX3.COLUMN2ROW2]
124
+ );
125
+ const distanceToPlane = normal.dot(center) + plane.distance;
126
+
127
+ if (distanceToPlane <= -radEffective) {
128
+ // The entire box is on the negative side of the plane normal
129
+ return 'outside';
130
+ } else if (distanceToPlane >= radEffective) {
131
+ // The entire box is on the positive side of the plane normal
132
+ return 'inside';
133
+ }
134
+ return 'intersecting';
135
+ }
136
+
137
+ /** Computes the estimated distance from the closest point on a bounding box to a point. */
138
+ distanceTo(point: readonly number[]): number {
139
+ return Math.sqrt(this.distanceSquaredTo(point));
140
+ }
141
+
142
+ /**
143
+ * Computes the estimated distance squared from the closest point
144
+ * on a bounding box to a point.
145
+ * See Geometric Tools for Computer Graphics 10.4.2
146
+ */
147
+ distanceSquaredTo(point: readonly number[]): number {
148
+ // Computes the estimated distance squared from the
149
+ // closest point on a bounding box to a point.
150
+ // See Geometric Tools for Computer Graphics 10.4.2
151
+ const offset = scratchOffset.from(point).subtract(this.center);
152
+
153
+ const halfAxes = this.halfAxes;
154
+ const u = halfAxes.getColumn(0, scratchVectorU);
155
+ const v = halfAxes.getColumn(1, scratchVectorV);
156
+ const w = halfAxes.getColumn(2, scratchVectorW);
157
+
158
+ const uHalf = u.magnitude();
159
+ const vHalf = v.magnitude();
160
+ const wHalf = w.magnitude();
161
+
162
+ u.normalize();
163
+ v.normalize();
164
+ w.normalize();
165
+
166
+ let distanceSquared = 0.0;
167
+ let d;
168
+
169
+ d = Math.abs(offset.dot(u)) - uHalf;
170
+ if (d > 0) {
171
+ distanceSquared += d * d;
172
+ }
173
+
174
+ d = Math.abs(offset.dot(v)) - vHalf;
175
+ if (d > 0) {
176
+ distanceSquared += d * d;
177
+ }
178
+
179
+ d = Math.abs(offset.dot(w)) - wHalf;
180
+ if (d > 0) {
181
+ distanceSquared += d * d;
182
+ }
183
+
184
+ return distanceSquared;
185
+ }
186
+
187
+ /**
188
+ * The distances calculated by the vector from the center of the bounding box
189
+ * to position projected onto direction.
190
+ *
191
+ * - If you imagine the infinite number of planes with normal direction,
192
+ * this computes the smallest distance to the closest and farthest planes
193
+ * from `position` that intersect the bounding box.
194
+ *
195
+ * @param position The position to calculate the distance from.
196
+ * @param direction The direction from position.
197
+ * @param result An Interval (array of length 2) to store the nearest and farthest distances.
198
+ * @returns Interval (array of length 2) with nearest and farthest distances
199
+ * on the bounding box from position in direction.
200
+ */
201
+ // eslint-disable-next-line max-statements
202
+ computePlaneDistances(
203
+ position: readonly number[],
204
+ direction: Vector3,
205
+ result: number[] = [-0, -0]
206
+ ): number[] {
207
+ let minDist = Number.POSITIVE_INFINITY;
208
+ let maxDist = Number.NEGATIVE_INFINITY;
209
+
210
+ const center = this.center;
211
+ const halfAxes = this.halfAxes;
212
+
213
+ const u = halfAxes.getColumn(0, scratchVectorU);
214
+ const v = halfAxes.getColumn(1, scratchVectorV);
215
+ const w = halfAxes.getColumn(2, scratchVectorW);
216
+
217
+ // project first corner
218
+ const corner = scratchCorner.copy(u).add(v).add(w).add(center);
219
+
220
+ const toCenter = scratchToCenter.copy(corner).subtract(position);
221
+ let mag = direction.dot(toCenter);
222
+
223
+ minDist = Math.min(mag, minDist);
224
+ maxDist = Math.max(mag, maxDist);
225
+
226
+ // project second corner
227
+ corner.copy(center).add(u).add(v).subtract(w);
228
+
229
+ toCenter.copy(corner).subtract(position);
230
+ mag = direction.dot(toCenter);
231
+
232
+ minDist = Math.min(mag, minDist);
233
+ maxDist = Math.max(mag, maxDist);
234
+
235
+ // project third corner
236
+ corner.copy(center).add(u).subtract(v).add(w);
237
+
238
+ toCenter.copy(corner).subtract(position);
239
+ mag = direction.dot(toCenter);
240
+
241
+ minDist = Math.min(mag, minDist);
242
+ maxDist = Math.max(mag, maxDist);
243
+
244
+ // project fourth corner
245
+ corner.copy(center).add(u).subtract(v).subtract(w);
246
+
247
+ toCenter.copy(corner).subtract(position);
248
+ mag = direction.dot(toCenter);
249
+
250
+ minDist = Math.min(mag, minDist);
251
+ maxDist = Math.max(mag, maxDist);
252
+
253
+ // project fifth corner
254
+ center.copy(corner).subtract(u).add(v).add(w);
255
+
256
+ toCenter.copy(corner).subtract(position);
257
+ mag = direction.dot(toCenter);
258
+
259
+ minDist = Math.min(mag, minDist);
260
+ maxDist = Math.max(mag, maxDist);
261
+
262
+ // project sixth corner
263
+ center.copy(corner).subtract(u).add(v).subtract(w);
264
+
265
+ toCenter.copy(corner).subtract(position);
266
+ mag = direction.dot(toCenter);
267
+
268
+ minDist = Math.min(mag, minDist);
269
+ maxDist = Math.max(mag, maxDist);
270
+
271
+ // project seventh corner
272
+ center.copy(corner).subtract(u).subtract(v).add(w);
273
+
274
+ toCenter.copy(corner).subtract(position);
275
+ mag = direction.dot(toCenter);
276
+
277
+ minDist = Math.min(mag, minDist);
278
+ maxDist = Math.max(mag, maxDist);
279
+
280
+ // project eighth corner
281
+ center.copy(corner).subtract(u).subtract(v).subtract(w);
282
+
283
+ toCenter.copy(corner).subtract(position);
284
+ mag = direction.dot(toCenter);
285
+
286
+ minDist = Math.min(mag, minDist);
287
+ maxDist = Math.max(mag, maxDist);
288
+
289
+ result[0] = minDist;
290
+ result[1] = maxDist;
291
+ return result;
292
+ }
293
+
294
+ /**
295
+ * Applies a 4x4 affine transformation matrix to a bounding sphere.
296
+ * @param transform The transformation matrix to apply to the bounding sphere.
297
+ * @returns itself, i.e. the modified BoundingVolume.
298
+ */
299
+ transform(transformation: readonly number[]): this {
300
+ this.center.transformAsPoint(transformation);
301
+
302
+ const xAxis = this.halfAxes.getColumn(0, scratchVectorU);
303
+ xAxis.transformAsPoint(transformation);
304
+
305
+ const yAxis = this.halfAxes.getColumn(1, scratchVectorV);
306
+ yAxis.transformAsPoint(transformation);
307
+
308
+ const zAxis = this.halfAxes.getColumn(2, scratchVectorW);
309
+ zAxis.transformAsPoint(transformation);
310
+
311
+ this.halfAxes = new Matrix3([...xAxis, ...yAxis, ...zAxis]);
312
+ return this;
313
+ }
314
+
315
+ getTransform(): Matrix4 {
316
+ // const modelMatrix = Matrix4.fromRotationTranslation(this.boundingVolume.halfAxes, this.boundingVolume.center);
317
+ // return modelMatrix;
318
+ throw new Error('not implemented');
319
+ }
320
+ }
@@ -0,0 +1,163 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT AND Apache-2.0
3
+ // SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
4
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
5
+ // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
+
7
+ // This file is derived from the Cesium math library under Apache 2 license
8
+ // See ../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
+
10
+ /* eslint-disable */
11
+ import {Vector3, assert} from '@math.gl/core';
12
+ import type {CullingResult} from '../constants';
13
+ import {Plane} from './plane';
14
+ import type {BoundingVolume} from './bounding-volumes/bounding-volume';
15
+ import type {BoundingSphere} from './bounding-volumes/bounding-sphere';
16
+
17
+ // X, Y, Z Unit vectors
18
+ const faces = [new Vector3([1, 0, 0]), new Vector3([0, 1, 0]), new Vector3([0, 0, 1])];
19
+
20
+ const scratchPlaneCenter = new Vector3();
21
+ const scratchPlaneNormal = new Vector3();
22
+ // const scratchPlane = new Plane(new Vector3(1.0, 0.0, 0.0), 0.0);
23
+
24
+ /** A culling volume defined by planes. */
25
+ export class CullingVolume {
26
+ /**
27
+ * For plane masks (as used in {@link CullingVolume#computeVisibilityWithPlaneMask}), this special value
28
+ * represents the case where the object bounding volume is entirely outside the culling volume.
29
+ */
30
+ static MASK_OUTSIDE = 0xffffffff;
31
+
32
+ /**
33
+ * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
34
+ * represents the case where the object bounding volume is entirely inside the culling volume.
35
+ */
36
+ static MASK_INSIDE = 0x00000000;
37
+
38
+ /**
39
+ * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
40
+ * represents the case where the object bounding volume (may) intersect all planes of the culling volume.
41
+ */
42
+ static MASK_INDETERMINATE = 0x7fffffff;
43
+
44
+ /** Array of clipping planes. */
45
+ readonly planes: Plane[];
46
+
47
+ /**
48
+ * Create a new `CullingVolume` bounded by an array of clipping planed
49
+ * @param planes Array of clipping planes.
50
+ * */
51
+ constructor(planes: Plane[] = []) {
52
+ this.planes = planes;
53
+ }
54
+
55
+ /**
56
+ * Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.
57
+ * The planes are aligned to the x, y, and z axes in world coordinates.
58
+ */
59
+ fromBoundingSphere(boundingSphere: BoundingSphere): CullingVolume {
60
+ this.planes.length = 2 * faces.length;
61
+
62
+ const center = boundingSphere.center;
63
+ const radius = boundingSphere.radius;
64
+
65
+ let planeIndex = 0;
66
+
67
+ for (const faceNormal of faces) {
68
+ let plane0 = this.planes[planeIndex];
69
+ let plane1 = this.planes[planeIndex + 1];
70
+
71
+ if (!plane0) {
72
+ plane0 = this.planes[planeIndex] = new Plane();
73
+ }
74
+ if (!plane1) {
75
+ plane1 = this.planes[planeIndex + 1] = new Plane();
76
+ }
77
+
78
+ const plane0Center = scratchPlaneCenter.copy(faceNormal).scale(-radius).add(center);
79
+ // const plane0Distance = -faceNormal.dot(plane0Center);
80
+
81
+ plane0.fromPointNormal(plane0Center, faceNormal);
82
+
83
+ const plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center);
84
+
85
+ const negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate();
86
+
87
+ // const plane1Distance = -negatedFaceNormal.dot(plane1Center);
88
+
89
+ plane1.fromPointNormal(plane1Center, negatedFaceNormal);
90
+
91
+ planeIndex += 2;
92
+ }
93
+
94
+ return this;
95
+ }
96
+
97
+ /** Determines whether a bounding volume intersects the culling volume. */
98
+ computeVisibility(boundingVolume: BoundingVolume): CullingResult {
99
+ // const planes = this.planes;
100
+ let intersect: CullingResult = 'inside';
101
+ for (const plane of this.planes) {
102
+ const result = boundingVolume.intersectPlane(plane);
103
+ switch (result) {
104
+ case 'outside':
105
+ // We are done
106
+ return 'outside';
107
+
108
+ case 'intersecting':
109
+ // If no other intersection is outside, return INTERSECTING
110
+ intersect = 'intersecting';
111
+ break;
112
+
113
+ default:
114
+ }
115
+ }
116
+
117
+ return intersect;
118
+ }
119
+
120
+ /**
121
+ * Determines whether a bounding volume intersects the culling volume.
122
+ *
123
+ * @param parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling
124
+ * volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then
125
+ * the parent (and therefore this) volume is completely inside plane[planeIndex]
126
+ * and that plane check can be skipped.
127
+ */
128
+ computeVisibilityWithPlaneMask(boundingVolume: BoundingVolume, parentPlaneMask: number): number {
129
+ assert(Number.isFinite(parentPlaneMask), 'parentPlaneMask is required.');
130
+
131
+ if (
132
+ parentPlaneMask === CullingVolume.MASK_OUTSIDE ||
133
+ parentPlaneMask === CullingVolume.MASK_INSIDE
134
+ ) {
135
+ // parent is completely outside or completely inside, so this child is as well.
136
+ return parentPlaneMask;
137
+ }
138
+
139
+ // Start with MASK_INSIDE (all zeros) so that after the loop, the return value can be compared with MASK_INSIDE.
140
+ // (Because if there are fewer than 31 planes, the upper bits wont be changed.)
141
+ let mask = CullingVolume.MASK_INSIDE;
142
+
143
+ const planes = this.planes;
144
+ for (let k = 0; k < this.planes.length; ++k) {
145
+ // For k greater than 31 (since 31 is the maximum number of INSIDE/INTERSECTING bits we can store), skip the optimization.
146
+ const flag = k < 31 ? 1 << k : 0;
147
+ if (k < 31 && (parentPlaneMask & flag) === 0) {
148
+ // boundingVolume is known to be INSIDE this plane.
149
+ continue;
150
+ }
151
+
152
+ const plane = planes[k];
153
+ const result = boundingVolume.intersectPlane(plane);
154
+ if (result === 'outside') {
155
+ return CullingVolume.MASK_OUTSIDE;
156
+ } else if (result === 'intersecting') {
157
+ mask |= flag;
158
+ }
159
+ }
160
+
161
+ return mask;
162
+ }
163
+ }