@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,85 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import {Curve} from './curve';
5
+
6
+ export type AdaptiveCurveOptions = {
7
+ tolerance: number;
8
+ maxDepth?: number;
9
+ maxPoints?: number;
10
+ };
11
+ export type AdaptiveCurveSamples = {
12
+ parameters: Float64Array;
13
+ positions: Float64Array;
14
+ /** False means a work limit prevented meeting the sampled chord-error criterion. */
15
+ converged: boolean;
16
+ maxSampledError: number;
17
+ };
18
+
19
+ /** Quarter/midpoint chord-error sampling. This is not a certified bound for arbitrary curves. */
20
+ export function sampleCurveAdaptive(
21
+ curve: Curve,
22
+ options: AdaptiveCurveOptions
23
+ ): AdaptiveCurveSamples {
24
+ const {tolerance, maxDepth = 16, maxPoints = 65536} = options;
25
+ if (
26
+ !Number.isFinite(tolerance) ||
27
+ tolerance <= 0 ||
28
+ !Number.isInteger(maxDepth) ||
29
+ maxDepth < 0 ||
30
+ maxDepth > 30 ||
31
+ !Number.isSafeInteger(maxPoints) ||
32
+ maxPoints < 2
33
+ )
34
+ throw new RangeError('Invalid adaptive sampling budget');
35
+ const parameters = [0],
36
+ positions = [...curve.getPoint(0)];
37
+ let converged = true,
38
+ maxSampledError = 0;
39
+ const stack = [{t0: 0, t1: 1, a: curve.getPoint(0), b: curve.getPoint(1), depth: 0}];
40
+ while (stack.length) {
41
+ const segment = stack.pop()!;
42
+ const {t0, t1, a, b, depth} = segment;
43
+ const localEdge = b.map((x, i) => x - a[i]);
44
+ const samples = [0.25, 0.5, 0.75].map(f => curve.getPoint(t0 + (t1 - t0) * f));
45
+ const localSamples = samples.map(point => point.map((x, i) => x - a[i]));
46
+ const local = [...localEdge, ...localSamples.flat()].every(Number.isFinite);
47
+ const scale = local
48
+ ? Math.max(...localEdge.map(Math.abs), ...localSamples.flat().map(Math.abs), Number.MIN_VALUE)
49
+ : Math.max(...a.map(Math.abs), ...b.map(Math.abs), ...samples.flat().map(Math.abs));
50
+ const edge = local ? localEdge.map(x => x / scale) : b.map((x, i) => x / scale - a[i] / scale);
51
+ const squared = edge.reduce((sum, x) => sum + x * x, 0);
52
+ const measuredError = Math.max(
53
+ ...samples.map((p, sampleIndex) => {
54
+ const offset = local
55
+ ? localSamples[sampleIndex].map(x => x / scale)
56
+ : p.map((x, i) => x / scale - a[i] / scale);
57
+ const t = squared
58
+ ? Math.max(0, Math.min(1, edge.reduce((sum, x, i) => sum + x * offset[i], 0) / squared))
59
+ : 0;
60
+ return Math.hypot(...offset.map((x, i) => x - t * edge[i])) * scale;
61
+ })
62
+ );
63
+ const error = Number.isFinite(measuredError) ? measuredError : Infinity;
64
+ if (
65
+ error > tolerance &&
66
+ depth < maxDepth &&
67
+ parameters.length + stack.length + 2 <= maxPoints
68
+ ) {
69
+ const mid = (t0 + t1) / 2;
70
+ stack.push({t0: mid, t1, a: samples[1], b, depth: depth + 1});
71
+ stack.push({t0, t1: mid, a, b: samples[1], depth: depth + 1});
72
+ } else {
73
+ if (error > tolerance) converged = false;
74
+ maxSampledError = Math.max(maxSampledError, error);
75
+ parameters.push(t1);
76
+ positions.push(...b);
77
+ }
78
+ }
79
+ return {
80
+ parameters: new Float64Array(parameters),
81
+ positions: new Float64Array(positions),
82
+ converged,
83
+ maxSampledError
84
+ };
85
+ }
@@ -0,0 +1,62 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {NumericArray} from '@math.gl/core';
6
+ import {Curve, copyPoints, type CurvePoint} from './curve';
7
+
8
+ abstract class BezierCurve extends Curve {
9
+ private readonly points: number[][];
10
+
11
+ protected constructor(points: readonly CurvePoint[]) {
12
+ const copied = copyPoints(points);
13
+ super(copied[0].length);
14
+ this.points = copied;
15
+ }
16
+
17
+ protected evaluate(t: number, result: NumericArray, derivative: boolean): void {
18
+ const degree = this.points.length - 1;
19
+ // Scalar de Casteljau evaluation avoids temporary vectors and preserves endpoints.
20
+ for (let i = 0; i < this.dimension; i++) {
21
+ let a = this.points[0][i];
22
+ let b = this.points[1][i];
23
+ let c = degree >= 2 ? this.points[2][i] : 0;
24
+ const d = degree === 3 ? this.points[3][i] : 0;
25
+ let order = degree;
26
+ if (derivative) {
27
+ a = degree * (b - a);
28
+ b = degree * (c - b);
29
+ c = degree * (d - c);
30
+ order--;
31
+ }
32
+ if (order === 3) {
33
+ a = (1 - t) * a + t * b;
34
+ b = (1 - t) * b + t * c;
35
+ c = (1 - t) * c + t * d;
36
+ }
37
+ if (order >= 2) {
38
+ a = (1 - t) * a + t * b;
39
+ b = (1 - t) * b + t * c;
40
+ }
41
+ result[i] = order >= 1 ? (1 - t) * a + t * b : a;
42
+ }
43
+ }
44
+ }
45
+
46
+ export class LineCurve extends BezierCurve {
47
+ constructor(start: CurvePoint, end: CurvePoint) {
48
+ super([start, end]);
49
+ }
50
+ }
51
+
52
+ export class QuadraticBezierCurve extends BezierCurve {
53
+ constructor(start: CurvePoint, control: CurvePoint, end: CurvePoint) {
54
+ super([start, control, end]);
55
+ }
56
+ }
57
+
58
+ export class CubicBezierCurve extends BezierCurve {
59
+ constructor(start: CurvePoint, control1: CurvePoint, control2: CurvePoint, end: CurvePoint) {
60
+ super([start, control1, control2, end]);
61
+ }
62
+ }
@@ -0,0 +1,89 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {NumericArray} from '@math.gl/core';
6
+ import {Curve, copyPoints, type CurvePoint} from './curve';
7
+ import {HermiteCurve} from './hermite-curve';
8
+
9
+ export type CatmullRomCurveOptions = {
10
+ closed?: boolean;
11
+ parameterization?: 'centripetal' | 'chordal' | 'uniform';
12
+ /** Uniform splines only. Default 0.5; zero gives stationary knot tangents. */
13
+ tension?: number;
14
+ };
15
+
16
+ export class CatmullRomCurve extends Curve {
17
+ readonly closed: boolean;
18
+ private readonly segments: HermiteCurve[];
19
+
20
+ constructor(points: readonly CurvePoint[], options: CatmullRomCurveOptions = {}) {
21
+ const data = copyPoints(points);
22
+ super(data[0].length);
23
+ this.closed = options.closed ?? false;
24
+ if (data.length < (this.closed ? 3 : 2)) throw new RangeError('Not enough spline points');
25
+ const mode = options.parameterization ?? 'centripetal';
26
+ if (!['centripetal', 'chordal', 'uniform'].includes(mode)) {
27
+ throw new RangeError('Unknown Catmull-Rom parameterization');
28
+ }
29
+ const tension = options.tension ?? 0.5;
30
+ if (!Number.isFinite(tension) || tension < 0 || tension > 1) {
31
+ throw new RangeError('tension must be in [0, 1]');
32
+ }
33
+ if (options.tension !== undefined && mode !== 'uniform') {
34
+ throw new RangeError('tension is only supported for uniform splines');
35
+ }
36
+ const point = (index: number): number[] => {
37
+ if (this.closed) return data[(index + data.length) % data.length];
38
+ if (index < 0) return data[0].map((x, i) => 2 * x - data[1][i]);
39
+ if (index >= data.length) {
40
+ return data[data.length - 1].map((x, i) => 2 * x - data[data.length - 2][i]);
41
+ }
42
+ return data[index];
43
+ };
44
+ this.segments = [];
45
+ for (let s = 0; s < data.length - (this.closed ? 0 : 1); s++) {
46
+ const p0 = point(s - 1);
47
+ const p1 = point(s);
48
+ const p2 = point(s + 1);
49
+ const p3 = point(s + 2);
50
+ const interval = (a: number[], b: number[]): number => {
51
+ const distance = Math.hypot(...a.map((x, i) => b[i] - x));
52
+ return distance ** (mode === 'chordal' ? 1 : 0.5);
53
+ };
54
+ const d1 = interval(p1, p2);
55
+ if (mode !== 'uniform' && d1 === 0) {
56
+ // A repeated knot is a stationary segment, rather than a spurious loop.
57
+ const zero = new Array<number>(this.dimension).fill(0);
58
+ this.segments.push(new HermiteCurve(p1, p2, zero, zero));
59
+ continue;
60
+ }
61
+ // Reuse the current interval for coincident neighbors. This is scale invariant.
62
+ const d0 = interval(p0, p1) || d1;
63
+ const d2 = interval(p2, p3) || d1;
64
+ const m1 = p1.map((x, i) =>
65
+ mode === 'uniform'
66
+ ? tension * (p2[i] - p0[i])
67
+ : d1 * ((x - p0[i]) / d0 - (p2[i] - p0[i]) / (d0 + d1) + (p2[i] - x) / d1)
68
+ );
69
+ const m2 = p2.map((x, i) =>
70
+ mode === 'uniform'
71
+ ? tension * (p3[i] - p1[i])
72
+ : d1 * ((x - p1[i]) / d1 - (p3[i] - p1[i]) / (d1 + d2) + (p3[i] - x) / d2)
73
+ );
74
+ this.segments.push(new HermiteCurve(p1, p2, m1, m2));
75
+ }
76
+ }
77
+
78
+ protected evaluate(t: number, result: NumericArray, derivative: boolean): void {
79
+ const scaled = t * this.segments.length;
80
+ const index = Math.min(Math.floor(scaled), this.segments.length - 1);
81
+ const local = scaled - index;
82
+ if (derivative) {
83
+ this.segments[index].getDerivative(local, result);
84
+ for (let i = 0; i < this.dimension; i++) result[i] *= this.segments.length;
85
+ } else {
86
+ this.segments[index].getPoint(local, result);
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,70 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {NumericArray} from '@math.gl/core';
6
+ import {Curve, validateDivisions, validateParameter} from './curve';
7
+
8
+ /** Reusable polyline approximation to a curve's cumulative arc length. */
9
+ export class CurveArcLength {
10
+ readonly curve: Curve;
11
+ readonly divisions: number;
12
+ readonly length: number;
13
+ private readonly cumulativeLengths: Float64Array;
14
+
15
+ constructor(curve: Curve, divisions = 1024) {
16
+ validateDivisions(divisions);
17
+ this.curve = curve;
18
+ this.divisions = divisions;
19
+ this.cumulativeLengths = new Float64Array(divisions + 1);
20
+ let previous = curve.getPoint(0);
21
+ let current = new Array<number>(curve.dimension);
22
+ let length = 0;
23
+ for (let i = 1; i <= divisions; i++) {
24
+ curve.getPoint(i / divisions, current);
25
+ length += Math.hypot(
26
+ current[0] - previous[0],
27
+ current[1] - previous[1],
28
+ curve.dimension === 3 ? current[2] - previous[2] : 0
29
+ );
30
+ if (!Number.isFinite(length)) throw new RangeError('Curve arc length must be finite');
31
+ this.cumulativeLengths[i] = length;
32
+ [previous, current] = [current, previous];
33
+ }
34
+ this.length = length;
35
+ }
36
+
37
+ /** Map a fraction of total length to t, preserving endpoints and zero-length curves. */
38
+ getParameterAt(u: number): number {
39
+ validateParameter(u);
40
+ if (u === 0 || u === 1 || this.length === 0) return u;
41
+ const target = u * this.length;
42
+ let low = 0;
43
+ let high = this.divisions;
44
+ while (low + 1 < high) {
45
+ const middle = Math.floor((low + high) / 2);
46
+ if (this.cumulativeLengths[middle] <= target) low = middle;
47
+ else high = middle;
48
+ }
49
+ const span = this.cumulativeLengths[high] - this.cumulativeLengths[low];
50
+ return (low + (span > 0 ? (target - this.cumulativeLengths[low]) / span : 0)) / this.divisions;
51
+ }
52
+
53
+ getPointAt(u: number): number[];
54
+ getPointAt<T extends NumericArray>(u: number, result: T): T;
55
+ getPointAt(u: number, result: NumericArray = new Array(this.curve.dimension)): NumericArray {
56
+ return this.curve.getPoint(this.getParameterAt(u), result);
57
+ }
58
+
59
+ /** Flat samples at approximately equal distances along the curve. */
60
+ getSpacedPoints(divisions = 64): Float64Array {
61
+ validateDivisions(divisions);
62
+ const points = new Float64Array((divisions + 1) * this.curve.dimension);
63
+ const point = new Array<number>(this.curve.dimension);
64
+ for (let i = 0; i <= divisions; i++) {
65
+ this.getPointAt(i / divisions, point);
66
+ points.set(point, i * this.curve.dimension);
67
+ }
68
+ return points;
69
+ }
70
+ }
@@ -0,0 +1,96 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {NumericArray} from '@math.gl/core';
6
+
7
+ export type CurvePoint = Readonly<ArrayLike<number>>;
8
+
9
+ /** Parameterized Euclidean curve, with t in [0, 1]. */
10
+ export abstract class Curve {
11
+ readonly dimension: number;
12
+
13
+ protected constructor(dimension: number) {
14
+ if (dimension !== 2 && dimension !== 3) {
15
+ throw new RangeError('Curve points must have two or three coordinates');
16
+ }
17
+ this.dimension = dimension;
18
+ }
19
+
20
+ getPoint(t: number): number[];
21
+ getPoint<T extends NumericArray>(t: number, result: T): T;
22
+ getPoint(t: number, result: NumericArray = new Array(this.dimension)): NumericArray {
23
+ validateParameter(t);
24
+ validateResult(result, this.dimension);
25
+ this.evaluate(t, result, false);
26
+ return result;
27
+ }
28
+
29
+ /** Derivative with respect to the normalized curve parameter t. */
30
+ getDerivative(t: number): number[];
31
+ getDerivative<T extends NumericArray>(t: number, result: T): T;
32
+ getDerivative(t: number, result: NumericArray = new Array(this.dimension)): NumericArray {
33
+ validateParameter(t);
34
+ validateResult(result, this.dimension);
35
+ this.evaluate(t, result, true);
36
+ return result;
37
+ }
38
+
39
+ /** Unit tangent; returns a zero vector at stationary points. */
40
+ getTangent(t: number): number[];
41
+ getTangent<T extends NumericArray>(t: number, result: T): T;
42
+ getTangent(t: number, result: NumericArray = new Array(this.dimension)): NumericArray {
43
+ this.getDerivative(t, result);
44
+ const length = Math.hypot(result[0], result[1], this.dimension === 3 ? result[2] : 0);
45
+ if (length > 0) {
46
+ for (let i = 0; i < this.dimension; i++) result[i] /= length;
47
+ }
48
+ return result;
49
+ }
50
+
51
+ /** Flat coordinates for divisions + 1 evenly spaced parameter samples. */
52
+ getPoints(divisions = 64): Float64Array {
53
+ validateDivisions(divisions);
54
+ const points = new Float64Array((divisions + 1) * this.dimension);
55
+ const point = new Array<number>(this.dimension);
56
+ for (let i = 0; i <= divisions; i++) {
57
+ this.getPoint(i / divisions, point);
58
+ points.set(point, i * this.dimension);
59
+ }
60
+ return points;
61
+ }
62
+
63
+ protected abstract evaluate(t: number, result: NumericArray, derivative: boolean): void;
64
+ }
65
+
66
+ /** Copy caller-owned control data so curves and their length tables stay stable. */
67
+ export function copyPoints(points: readonly CurvePoint[]): number[][] {
68
+ if (!points.length) throw new RangeError('Invalid number of curve control points');
69
+ const dimension = points[0].length;
70
+ if (dimension !== 2 && dimension !== 3) {
71
+ throw new RangeError('Curve points must have two or three coordinates');
72
+ }
73
+ return points.map(point => {
74
+ if (point.length !== dimension) throw new RangeError('Control point dimensions must match');
75
+ return Array.from(point, value => {
76
+ if (!Number.isFinite(value)) throw new RangeError('Control coordinates must be finite');
77
+ return value;
78
+ });
79
+ });
80
+ }
81
+
82
+ export function validateParameter(t: number): void {
83
+ if (!Number.isFinite(t) || t < 0 || t > 1) {
84
+ throw new RangeError('Curve parameter must be finite and in [0, 1]');
85
+ }
86
+ }
87
+
88
+ export function validateDivisions(divisions: number): void {
89
+ if (!Number.isSafeInteger(divisions) || divisions < 1) {
90
+ throw new RangeError('divisions must be a positive safe integer');
91
+ }
92
+ }
93
+
94
+ function validateResult(result: NumericArray, dimension: number): void {
95
+ if (result.length < dimension) throw new RangeError('Result buffer is too short');
96
+ }
@@ -0,0 +1,34 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {NumericArray} from '@math.gl/core';
6
+ import {Curve, copyPoints, type CurvePoint} from './curve';
7
+
8
+ /** Cubic curve with endpoint derivatives (not unit tangent directions). */
9
+ export class HermiteCurve extends Curve {
10
+ private readonly data: number[][];
11
+
12
+ constructor(
13
+ start: CurvePoint,
14
+ end: CurvePoint,
15
+ startTangent: CurvePoint,
16
+ endTangent: CurvePoint
17
+ ) {
18
+ const data = copyPoints([start, end, startTangent, endTangent]);
19
+ super(data[0].length);
20
+ this.data = data;
21
+ }
22
+
23
+ protected evaluate(t: number, result: NumericArray, derivative: boolean): void {
24
+ const t2 = t * t;
25
+ const h0 = derivative ? 6 * t2 - 6 * t : (1 + 2 * t) * (1 - t) ** 2;
26
+ const h1 = derivative ? -6 * t2 + 6 * t : t2 * (3 - 2 * t);
27
+ const h2 = derivative ? 3 * t2 - 4 * t + 1 : t * (1 - t) ** 2;
28
+ const h3 = derivative ? 3 * t2 - 2 * t : t2 * (t - 1);
29
+ for (let i = 0; i < this.dimension; i++) {
30
+ result[i] =
31
+ h0 * this.data[0][i] + h1 * this.data[1][i] + h2 * this.data[2][i] + h3 * this.data[3][i];
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,19 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ export {Curve} from './curve';
6
+ export type {CurvePoint} from './curve';
7
+ export {
8
+ LineCurve,
9
+ QuadraticBezierCurve,
10
+ CubicBezierCurve
11
+ } from './bezier-curves';
12
+ export {HermiteCurve} from './hermite-curve';
13
+ export {CatmullRomCurve} from './catmull-rom-curve';
14
+ export type {CatmullRomCurveOptions} from './catmull-rom-curve';
15
+ export {CurveArcLength} from './curve-arc-length';
16
+ export {sampleCurveAdaptive} from './adaptive-sampling';
17
+ export type {AdaptiveCurveOptions, AdaptiveCurveSamples} from './adaptive-sampling';
18
+ export {computeParallelTransportFrames} from './parallel-transport';
19
+ export type {CurveFrames} from './parallel-transport';
@@ -0,0 +1,104 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import type {CurvePoint} from './curve';
5
+
6
+ export type CurveFrames = {tangents: Float64Array; normals: Float64Array; binormals: Float64Array};
7
+ type V = number[];
8
+ const sub = (a: V, b: V) => a.map((x, i) => x - b[i]);
9
+ const dot = (a: V, b: V) => a.reduce((sum, x, i) => sum + x * b[i], 0);
10
+ const cross = (a: V, b: V): V => [
11
+ a[1] * b[2] - a[2] * b[1],
12
+ a[2] * b[0] - a[0] * b[2],
13
+ a[0] * b[1] - a[1] * b[0]
14
+ ];
15
+ const unit = (a: V) => {
16
+ const length = Math.hypot(...a);
17
+ if (!length) throw new RangeError('Cannot construct a frame for a stationary path');
18
+ return a.map(x => x / length);
19
+ };
20
+ function rotate(v: V, axis: V, angle: number): V {
21
+ const c = Math.cos(angle),
22
+ s = Math.sin(angle),
23
+ d = dot(axis, v),
24
+ k = cross(axis, v);
25
+ return v.map((x, i) => x * c + k[i] * s + axis[i] * d * (1 - c));
26
+ }
27
+ /** Frames on a 3D polyline; repeated points inherit a neighboring direction. Closed paths repeat the first point. */
28
+ export function computeParallelTransportFrames(
29
+ points: readonly CurvePoint[],
30
+ options: {closed?: boolean; initialNormal?: CurvePoint} = {}
31
+ ): CurveFrames {
32
+ if (
33
+ points.length < 2 ||
34
+ points.some(p => p.length !== 3 || Array.from(p).some(x => !Number.isFinite(x)))
35
+ )
36
+ throw new RangeError('Expected at least two finite 3D points');
37
+ const data = points.map(p => Array.from(p)),
38
+ n = data.length,
39
+ closed = options.closed ?? false;
40
+ if (closed && (n < 4 || Math.hypot(...sub(data[0], data[n - 1])) !== 0))
41
+ throw new RangeError('A closed path must repeat its first point');
42
+ // Cache adjacent nonzero directions, then propagate backwards across equal runs.
43
+ // This keeps repeated-point paths linear rather than rescanning each suffix.
44
+ const tangent: V[] = new Array(n);
45
+ const edges: (V | undefined)[] = new Array(n - 1);
46
+ let last: V | undefined;
47
+ for (let i = 0; i < n - 1; i++) {
48
+ const edge = sub(data[i + 1], data[i]);
49
+ if (Math.hypot(...edge) > 0) last = edges[i] = unit(edge);
50
+ }
51
+ if (!last) throw new RangeError('Cannot construct a frame for a stationary path');
52
+ tangent[n - 1] = last;
53
+ for (let i = n - 2; i >= 0; i--) {
54
+ last = edges[i] ?? last;
55
+ tangent[i] = last;
56
+ }
57
+ if (closed) tangent[n - 1] = [...tangent[0]];
58
+ const t = tangent[0];
59
+ let initial = options.initialNormal ? Array.from(options.initialNormal) : [0, 0, 0];
60
+ if (options.initialNormal && (initial.length !== 3 || initial.some(x => !Number.isFinite(x))))
61
+ throw new RangeError('Invalid initial normal');
62
+ // Select an axis by absolute alignment (including negative tangent components).
63
+ if (!options.initialNormal) {
64
+ initial = [0, 0, 0];
65
+ initial[t.map(Math.abs).indexOf(Math.min(...t.map(Math.abs)))] = 1;
66
+ }
67
+ initial = unit(initial);
68
+ const perpendicular = cross(t, initial);
69
+ if (Math.hypot(...perpendicular) <= 1e-12) {
70
+ throw new RangeError('Initial normal must not be parallel to the tangent');
71
+ }
72
+ // A double cross product avoids normalizing a cancellation residual along t.
73
+ const normals: V[] = [unit(cross(perpendicular, t))];
74
+ for (let i = 1; i < n; i++) {
75
+ const axis = cross(tangent[i - 1], tangent[i]),
76
+ length = Math.hypot(...axis),
77
+ cosine = Math.max(-1, Math.min(1, dot(tangent[i - 1], tangent[i])));
78
+ let normal = normals[i - 1];
79
+ if (length > 1e-12)
80
+ normal = rotate(
81
+ normal,
82
+ axis.map(x => x / length),
83
+ Math.atan2(length, cosine)
84
+ );
85
+ // At an exact reversal the previous normal defines the deterministic 180-degree axis.
86
+ normals.push(unit(normal.map((x, j) => x - dot(normal, tangent[i]) * tangent[i][j])));
87
+ }
88
+ if (closed) {
89
+ const mismatch = Math.atan2(
90
+ dot(tangent[0], cross(normals[n - 1], normals[0])),
91
+ dot(normals[n - 1], normals[0])
92
+ );
93
+ const lengths = [0];
94
+ for (let i = 1; i < n; i++)
95
+ lengths.push(lengths[i - 1] + Math.hypot(...sub(data[i], data[i - 1])));
96
+ for (let i = 1; i < n; i++)
97
+ normals[i] = rotate(normals[i], tangent[i], (mismatch * lengths[i]) / lengths[n - 1]);
98
+ }
99
+ return {
100
+ tangents: new Float64Array(tangent.flat()),
101
+ normals: new Float64Array(normals.flat()),
102
+ binormals: new Float64Array(normals.flatMap((normal, i) => cross(tangent[i], normal)))
103
+ };
104
+ }
@@ -1,6 +1,6 @@
1
1
  // math.gl
2
2
  // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Geometry, type GeometryAttributeInput} from '../lib/geometry';
6
6
  import {assertPositive, makeIndices, type PrimitiveGeometryProps} from './geometry-helpers';
@@ -1,6 +1,6 @@
1
1
  // math.gl
2
2
  // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Geometry} from '../lib/geometry';
6
6
  import {
@@ -1,6 +1,6 @@
1
1
  // math.gl
2
2
  // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
5
  import {TruncatedConeGeometry, type TruncatedConeGeometryProps} from './truncated-cone-geometry';
6
6
 
@@ -1,6 +1,6 @@
1
1
  // math.gl
2
2
  // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
5
  import type {GeometryAttributeInput} from '../lib/geometry';
6
6
 
@@ -1,6 +1,6 @@
1
1
  // math.gl
2
2
  // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Geometry} from '../lib/geometry';
6
6
  import {assertPositive, assertSegments, type PrimitiveGeometryProps} from './geometry-helpers';
@@ -1,6 +1,6 @@
1
1
  // math.gl
2
2
  // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Geometry} from '../lib/geometry';
6
6
  import {