@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 @@
1
+ {"version":3,"file":"bounding-volume.d.ts","sourceRoot":"","sources":["../../../../src/culling/lib/bounding-volumes/bounding-volume.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,EAAC,oBAAiB;AAC/B,OAAO,KAAK,EAAC,aAAa,EAAC,2BAAwB;AAEnD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAE9C,sGAAsG;IACtG,iBAAiB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC;IACpD,8FAA8F;IAC9F,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC;IAE7C;;;;;;;;OAQG;IACH,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAAC;CAC7C"}
@@ -0,0 +1,7 @@
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
+ export {};
7
+ //# sourceMappingURL=bounding-volume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounding-volume.js","sourceRoot":"","sources":["../../../../src/culling/lib/bounding-volumes/bounding-volume.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,8CAA8C;AAC9C,oEAAoE;AACpE,4DAA4D;AAC5D,mHAAmH"}
@@ -0,0 +1,62 @@
1
+ import { NumericArray } from '@math.gl/core';
2
+ import { Vector3, Matrix3, Matrix4 } from '@math.gl/core';
3
+ import type { BoundingVolume } from "./bounding-volume.js";
4
+ import { BoundingSphere } from "./bounding-sphere.js";
5
+ import { Plane } from "../plane.js";
6
+ import type { CullingResult } from "../../constants.js";
7
+ /**
8
+ * An OrientedBoundingBox of some object is a closed and convex cuboid.
9
+ * It can provide a tighter bounding volume than `BoundingSphere` or
10
+ * `AxisAlignedBoundingBox` in many cases.
11
+ */
12
+ export declare class OrientedBoundingBox implements BoundingVolume {
13
+ center: Vector3;
14
+ halfAxes: Matrix3;
15
+ /**
16
+ * An OrientedBoundingBox of some object is a closed and convex cuboid.
17
+ * It can provide a tighter bounding volume than
18
+ * `BoundingSphere` or `AxisAlignedBoundingBox` in many cases.
19
+ */
20
+ constructor(center?: Readonly<NumericArray>, halfAxes?: Readonly<NumericArray>);
21
+ /** Returns an array with three halfSizes for the bounding box */
22
+ get halfSize(): number[];
23
+ /** Duplicates a OrientedBoundingBox instance. */
24
+ clone(): OrientedBoundingBox;
25
+ /** Compares the provided OrientedBoundingBox component wise and returns */
26
+ equals(right: OrientedBoundingBox): boolean;
27
+ /** Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box. */
28
+ getBoundingSphere(result?: BoundingSphere): BoundingSphere;
29
+ /** Determines which side of a plane the oriented bounding box is located. */
30
+ intersectPlane(plane: Plane): CullingResult;
31
+ /** Computes the estimated distance from the closest point on a bounding box to a point. */
32
+ distanceTo(point: readonly number[]): number;
33
+ /**
34
+ * Computes the estimated distance squared from the closest point
35
+ * on a bounding box to a point.
36
+ * See Geometric Tools for Computer Graphics 10.4.2
37
+ */
38
+ distanceSquaredTo(point: readonly number[]): number;
39
+ /**
40
+ * The distances calculated by the vector from the center of the bounding box
41
+ * to position projected onto direction.
42
+ *
43
+ * - If you imagine the infinite number of planes with normal direction,
44
+ * this computes the smallest distance to the closest and farthest planes
45
+ * from `position` that intersect the bounding box.
46
+ *
47
+ * @param position The position to calculate the distance from.
48
+ * @param direction The direction from position.
49
+ * @param result An Interval (array of length 2) to store the nearest and farthest distances.
50
+ * @returns Interval (array of length 2) with nearest and farthest distances
51
+ * on the bounding box from position in direction.
52
+ */
53
+ computePlaneDistances(position: readonly number[], direction: Vector3, result?: number[]): number[];
54
+ /**
55
+ * Applies a 4x4 affine transformation matrix to a bounding sphere.
56
+ * @param transform The transformation matrix to apply to the bounding sphere.
57
+ * @returns itself, i.e. the modified BoundingVolume.
58
+ */
59
+ transform(transformation: readonly number[]): this;
60
+ getTransform(): Matrix4;
61
+ }
62
+ //# sourceMappingURL=oriented-bounding-box.d.ts.map
@@ -0,0 +1 @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FX;;;;OAIG;IACH,SAAS,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAgBlD,YAAY,IAAI,OAAO;CAKxB"}
@@ -0,0 +1,230 @@
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
+ import { Vector3, Matrix3 } from '@math.gl/core';
7
+ import { BoundingSphere } from "./bounding-sphere.js";
8
+ const scratchVector3 = new Vector3();
9
+ const scratchOffset = new Vector3();
10
+ const scratchVectorU = new Vector3();
11
+ const scratchVectorV = new Vector3();
12
+ const scratchVectorW = new Vector3();
13
+ const scratchCorner = new Vector3();
14
+ const scratchToCenter = new Vector3();
15
+ const MATRIX3 = {
16
+ COLUMN0ROW0: 0,
17
+ COLUMN0ROW1: 1,
18
+ COLUMN0ROW2: 2,
19
+ COLUMN1ROW0: 3,
20
+ COLUMN1ROW1: 4,
21
+ COLUMN1ROW2: 5,
22
+ COLUMN2ROW0: 6,
23
+ COLUMN2ROW1: 7,
24
+ COLUMN2ROW2: 8
25
+ };
26
+ /**
27
+ * An OrientedBoundingBox of some object is a closed and convex cuboid.
28
+ * It can provide a tighter bounding volume than `BoundingSphere` or
29
+ * `AxisAlignedBoundingBox` in many cases.
30
+ */
31
+ export class OrientedBoundingBox {
32
+ constructor(center = [0, 0, 0], halfAxes = [0, 0, 0, 0, 0, 0, 0, 0, 0]) {
33
+ this.center = new Vector3().from(center);
34
+ this.halfAxes = new Matrix3(halfAxes);
35
+ }
36
+ /** Returns an array with three halfSizes for the bounding box */
37
+ get halfSize() {
38
+ const xAxis = this.halfAxes.getColumn(0);
39
+ const yAxis = this.halfAxes.getColumn(1);
40
+ const zAxis = this.halfAxes.getColumn(2);
41
+ return [new Vector3(xAxis).len(), new Vector3(yAxis).len(), new Vector3(zAxis).len()];
42
+ }
43
+ /** Duplicates a OrientedBoundingBox instance. */
44
+ clone() {
45
+ return new OrientedBoundingBox(this.center, this.halfAxes);
46
+ }
47
+ /** Compares the provided OrientedBoundingBox component wise and returns */
48
+ equals(right) {
49
+ return (this === right ||
50
+ (Boolean(right) && this.center.equals(right.center) && this.halfAxes.equals(right.halfAxes)));
51
+ }
52
+ /** Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box. */
53
+ getBoundingSphere(result = new BoundingSphere()) {
54
+ const halfAxes = this.halfAxes;
55
+ const u = halfAxes.getColumn(0, scratchVectorU);
56
+ const v = halfAxes.getColumn(1, scratchVectorV);
57
+ const w = halfAxes.getColumn(2, scratchVectorW);
58
+ // Calculate "corner" vector
59
+ const cornerVector = scratchVector3.copy(u).add(v).add(w);
60
+ result.center.copy(this.center);
61
+ result.radius = cornerVector.magnitude();
62
+ return result;
63
+ }
64
+ /** Determines which side of a plane the oriented bounding box is located. */
65
+ intersectPlane(plane) {
66
+ const center = this.center;
67
+ const normal = plane.normal;
68
+ const halfAxes = this.halfAxes;
69
+ const normalX = normal.x;
70
+ const normalY = normal.y;
71
+ const normalZ = normal.z;
72
+ // Plane is used as if it is its normal; the first three components are assumed to be normalized
73
+ const radEffective = Math.abs(normalX * halfAxes[MATRIX3.COLUMN0ROW0] +
74
+ normalY * halfAxes[MATRIX3.COLUMN0ROW1] +
75
+ normalZ * halfAxes[MATRIX3.COLUMN0ROW2]) +
76
+ Math.abs(normalX * halfAxes[MATRIX3.COLUMN1ROW0] +
77
+ normalY * halfAxes[MATRIX3.COLUMN1ROW1] +
78
+ normalZ * halfAxes[MATRIX3.COLUMN1ROW2]) +
79
+ Math.abs(normalX * halfAxes[MATRIX3.COLUMN2ROW0] +
80
+ normalY * halfAxes[MATRIX3.COLUMN2ROW1] +
81
+ normalZ * halfAxes[MATRIX3.COLUMN2ROW2]);
82
+ const distanceToPlane = normal.dot(center) + plane.distance;
83
+ if (distanceToPlane <= -radEffective) {
84
+ // The entire box is on the negative side of the plane normal
85
+ return 'outside';
86
+ }
87
+ else if (distanceToPlane >= radEffective) {
88
+ // The entire box is on the positive side of the plane normal
89
+ return 'inside';
90
+ }
91
+ return 'intersecting';
92
+ }
93
+ /** Computes the estimated distance from the closest point on a bounding box to a point. */
94
+ distanceTo(point) {
95
+ return Math.sqrt(this.distanceSquaredTo(point));
96
+ }
97
+ /**
98
+ * Computes the estimated distance squared from the closest point
99
+ * on a bounding box to a point.
100
+ * See Geometric Tools for Computer Graphics 10.4.2
101
+ */
102
+ distanceSquaredTo(point) {
103
+ // Computes the estimated distance squared from the
104
+ // closest point on a bounding box to a point.
105
+ // See Geometric Tools for Computer Graphics 10.4.2
106
+ const offset = scratchOffset.from(point).subtract(this.center);
107
+ const halfAxes = this.halfAxes;
108
+ const u = halfAxes.getColumn(0, scratchVectorU);
109
+ const v = halfAxes.getColumn(1, scratchVectorV);
110
+ const w = halfAxes.getColumn(2, scratchVectorW);
111
+ const uHalf = u.magnitude();
112
+ const vHalf = v.magnitude();
113
+ const wHalf = w.magnitude();
114
+ u.normalize();
115
+ v.normalize();
116
+ w.normalize();
117
+ let distanceSquared = 0.0;
118
+ let d;
119
+ d = Math.abs(offset.dot(u)) - uHalf;
120
+ if (d > 0) {
121
+ distanceSquared += d * d;
122
+ }
123
+ d = Math.abs(offset.dot(v)) - vHalf;
124
+ if (d > 0) {
125
+ distanceSquared += d * d;
126
+ }
127
+ d = Math.abs(offset.dot(w)) - wHalf;
128
+ if (d > 0) {
129
+ distanceSquared += d * d;
130
+ }
131
+ return distanceSquared;
132
+ }
133
+ /**
134
+ * The distances calculated by the vector from the center of the bounding box
135
+ * to position projected onto direction.
136
+ *
137
+ * - If you imagine the infinite number of planes with normal direction,
138
+ * this computes the smallest distance to the closest and farthest planes
139
+ * from `position` that intersect the bounding box.
140
+ *
141
+ * @param position The position to calculate the distance from.
142
+ * @param direction The direction from position.
143
+ * @param result An Interval (array of length 2) to store the nearest and farthest distances.
144
+ * @returns Interval (array of length 2) with nearest and farthest distances
145
+ * on the bounding box from position in direction.
146
+ */
147
+ // eslint-disable-next-line max-statements
148
+ computePlaneDistances(position, direction, result = [-0, -0]) {
149
+ let minDist = Number.POSITIVE_INFINITY;
150
+ let maxDist = Number.NEGATIVE_INFINITY;
151
+ const center = this.center;
152
+ const halfAxes = this.halfAxes;
153
+ const u = halfAxes.getColumn(0, scratchVectorU);
154
+ const v = halfAxes.getColumn(1, scratchVectorV);
155
+ const w = halfAxes.getColumn(2, scratchVectorW);
156
+ // project first corner
157
+ const corner = scratchCorner.copy(u).add(v).add(w).add(center);
158
+ const toCenter = scratchToCenter.copy(corner).subtract(position);
159
+ let mag = direction.dot(toCenter);
160
+ minDist = Math.min(mag, minDist);
161
+ maxDist = Math.max(mag, maxDist);
162
+ // project second corner
163
+ corner.copy(center).add(u).add(v).subtract(w);
164
+ toCenter.copy(corner).subtract(position);
165
+ mag = direction.dot(toCenter);
166
+ minDist = Math.min(mag, minDist);
167
+ maxDist = Math.max(mag, maxDist);
168
+ // project third corner
169
+ corner.copy(center).add(u).subtract(v).add(w);
170
+ toCenter.copy(corner).subtract(position);
171
+ mag = direction.dot(toCenter);
172
+ minDist = Math.min(mag, minDist);
173
+ maxDist = Math.max(mag, maxDist);
174
+ // project fourth corner
175
+ corner.copy(center).add(u).subtract(v).subtract(w);
176
+ toCenter.copy(corner).subtract(position);
177
+ mag = direction.dot(toCenter);
178
+ minDist = Math.min(mag, minDist);
179
+ maxDist = Math.max(mag, maxDist);
180
+ // project fifth corner
181
+ center.copy(corner).subtract(u).add(v).add(w);
182
+ toCenter.copy(corner).subtract(position);
183
+ mag = direction.dot(toCenter);
184
+ minDist = Math.min(mag, minDist);
185
+ maxDist = Math.max(mag, maxDist);
186
+ // project sixth corner
187
+ center.copy(corner).subtract(u).add(v).subtract(w);
188
+ toCenter.copy(corner).subtract(position);
189
+ mag = direction.dot(toCenter);
190
+ minDist = Math.min(mag, minDist);
191
+ maxDist = Math.max(mag, maxDist);
192
+ // project seventh corner
193
+ center.copy(corner).subtract(u).subtract(v).add(w);
194
+ toCenter.copy(corner).subtract(position);
195
+ mag = direction.dot(toCenter);
196
+ minDist = Math.min(mag, minDist);
197
+ maxDist = Math.max(mag, maxDist);
198
+ // project eighth corner
199
+ center.copy(corner).subtract(u).subtract(v).subtract(w);
200
+ toCenter.copy(corner).subtract(position);
201
+ mag = direction.dot(toCenter);
202
+ minDist = Math.min(mag, minDist);
203
+ maxDist = Math.max(mag, maxDist);
204
+ result[0] = minDist;
205
+ result[1] = maxDist;
206
+ return result;
207
+ }
208
+ /**
209
+ * Applies a 4x4 affine transformation matrix to a bounding sphere.
210
+ * @param transform The transformation matrix to apply to the bounding sphere.
211
+ * @returns itself, i.e. the modified BoundingVolume.
212
+ */
213
+ transform(transformation) {
214
+ this.center.transformAsPoint(transformation);
215
+ const xAxis = this.halfAxes.getColumn(0, scratchVectorU);
216
+ xAxis.transformAsPoint(transformation);
217
+ const yAxis = this.halfAxes.getColumn(1, scratchVectorV);
218
+ yAxis.transformAsPoint(transformation);
219
+ const zAxis = this.halfAxes.getColumn(2, scratchVectorW);
220
+ zAxis.transformAsPoint(transformation);
221
+ this.halfAxes = new Matrix3([...xAxis, ...yAxis, ...zAxis]);
222
+ return this;
223
+ }
224
+ getTransform() {
225
+ // const modelMatrix = Matrix4.fromRotationTranslation(this.boundingVolume.halfAxes, this.boundingVolume.center);
226
+ // return modelMatrix;
227
+ throw new Error('not implemented');
228
+ }
229
+ }
230
+ //# sourceMappingURL=oriented-bounding-box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oriented-bounding-box.js","sourceRoot":"","sources":["../../../../src/culling/lib/bounding-volumes/oriented-bounding-box.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,8CAA8C;AAC9C,oEAAoE;AACpE,4DAA4D;AAC5D,mHAAmH;AAMnH,OAAO,EAAC,OAAO,EAAE,OAAO,EAAU,MAAM,eAAe,CAAC;AAGxD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M,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QACzD,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAEvC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QACzD,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAEvC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QACzD,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAEvC,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY;QACV,iHAAiH;QACjH,sBAAsB;QACtB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,49 @@
1
+ import { type ProjectionDepthOptions } from '@math.gl/core';
2
+ import type { CullingResult } from "../constants.js";
3
+ import { Plane } from "./plane.js";
4
+ import type { BoundingVolume } from "./bounding-volumes/bounding-volume.js";
5
+ import type { BoundingSphere } from "./bounding-volumes/bounding-sphere.js";
6
+ /** A culling volume defined by planes. */
7
+ export declare class CullingVolume {
8
+ /**
9
+ * For plane masks (as used in {@link CullingVolume#computeVisibilityWithPlaneMask}), this special value
10
+ * represents the case where the object bounding volume is entirely outside the culling volume.
11
+ */
12
+ static MASK_OUTSIDE: number;
13
+ /**
14
+ * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
15
+ * represents the case where the object bounding volume is entirely inside the culling volume.
16
+ */
17
+ static MASK_INSIDE: number;
18
+ /**
19
+ * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
20
+ * represents the case where the object bounding volume (may) intersect all planes of the culling volume.
21
+ */
22
+ static MASK_INDETERMINATE: number;
23
+ /** Array of clipping planes. */
24
+ readonly planes: Plane[];
25
+ /**
26
+ * Create a new `CullingVolume` bounded by an array of clipping planed
27
+ * @param planes Array of clipping planes.
28
+ * */
29
+ constructor(planes?: Plane[]);
30
+ /**
31
+ * Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.
32
+ * The planes are aligned to the x, y, and z axes in world coordinates.
33
+ */
34
+ fromBoundingSphere(boundingSphere: BoundingSphere): CullingVolume;
35
+ /** Replace planes from a view-projection matrix; validates before mutating. */
36
+ fromViewProjection(matrix: ArrayLike<number>, options?: ProjectionDepthOptions): this;
37
+ /** Determines whether a bounding volume intersects the culling volume. */
38
+ computeVisibility(boundingVolume: BoundingVolume): CullingResult;
39
+ /**
40
+ * Determines whether a bounding volume intersects the culling volume.
41
+ *
42
+ * @param parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling
43
+ * volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then
44
+ * the parent (and therefore this) volume is completely inside plane[planeIndex]
45
+ * and that plane check can be skipped.
46
+ */
47
+ computeVisibilityWithPlaneMask(boundingVolume: BoundingVolume, parentPlaneMask: number): number;
48
+ }
49
+ //# sourceMappingURL=culling-volume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"culling-volume.d.ts","sourceRoot":"","sources":["../../../src/culling/lib/culling-volume.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkB,KAAK,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAE3E,OAAO,KAAK,EAAC,aAAa,EAAC,wBAAqB;AAChD,OAAO,EAAC,KAAK,EAAC,mBAAgB;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,8CAA2C;AACvE,OAAO,KAAK,EAAC,cAAc,EAAC,8CAA2C;AASvE,0CAA0C;AAC1C,qBAAa,aAAa;IACxB;;;OAGG;IACH,MAAM,CAAC,YAAY,SAAc;IAEjC;;;OAGG;IACH,MAAM,CAAC,WAAW,SAAc;IAEhC;;;OAGG;IACH,MAAM,CAAC,kBAAkB,SAAc;IAEvC,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IAEzB;;;SAGK;gBACO,MAAM,GAAE,KAAK,EAAO;IAIhC;;;OAGG;IACH,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,aAAa;IAsCjE,+EAA+E;IAC/E,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAE,sBAA2B,GAAG,IAAI;IAMzF,0EAA0E;IAC1E,iBAAiB,CAAC,cAAc,EAAE,cAAc,GAAG,aAAa;IAsBhE;;;;;;;OAOG;IACH,8BAA8B,CAAC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM;CAmChG"}
@@ -0,0 +1,133 @@
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
+ // This file is derived from the Cesium math library under Apache 2 license
7
+ // See ../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
8
+ /* eslint-disable */
9
+ import { Vector3, assert } from '@math.gl/core';
10
+ import { extractFrustumPlanes } from "../frustum-planes.js";
11
+ import { Plane } from "./plane.js";
12
+ // X, Y, Z Unit vectors
13
+ const faces = [new Vector3([1, 0, 0]), new Vector3([0, 1, 0]), new Vector3([0, 0, 1])];
14
+ const scratchPlaneCenter = new Vector3();
15
+ const scratchPlaneNormal = new Vector3();
16
+ // const scratchPlane = new Plane(new Vector3(1.0, 0.0, 0.0), 0.0);
17
+ /** A culling volume defined by planes. */
18
+ export class CullingVolume {
19
+ /**
20
+ * Create a new `CullingVolume` bounded by an array of clipping planed
21
+ * @param planes Array of clipping planes.
22
+ * */
23
+ constructor(planes = []) {
24
+ this.planes = planes;
25
+ }
26
+ /**
27
+ * Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.
28
+ * The planes are aligned to the x, y, and z axes in world coordinates.
29
+ */
30
+ fromBoundingSphere(boundingSphere) {
31
+ this.planes.length = 2 * faces.length;
32
+ const center = boundingSphere.center;
33
+ const radius = boundingSphere.radius;
34
+ let planeIndex = 0;
35
+ for (const faceNormal of faces) {
36
+ let plane0 = this.planes[planeIndex];
37
+ let plane1 = this.planes[planeIndex + 1];
38
+ if (!plane0) {
39
+ plane0 = this.planes[planeIndex] = new Plane();
40
+ }
41
+ if (!plane1) {
42
+ plane1 = this.planes[planeIndex + 1] = new Plane();
43
+ }
44
+ const plane0Center = scratchPlaneCenter.copy(faceNormal).scale(-radius).add(center);
45
+ // const plane0Distance = -faceNormal.dot(plane0Center);
46
+ plane0.fromPointNormal(plane0Center, faceNormal);
47
+ const plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center);
48
+ const negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate();
49
+ // const plane1Distance = -negatedFaceNormal.dot(plane1Center);
50
+ plane1.fromPointNormal(plane1Center, negatedFaceNormal);
51
+ planeIndex += 2;
52
+ }
53
+ return this;
54
+ }
55
+ /** Replace planes from a view-projection matrix; validates before mutating. */
56
+ fromViewProjection(matrix, options = {}) {
57
+ const planes = extractFrustumPlanes(matrix, options);
58
+ this.planes.splice(0, this.planes.length, ...planes);
59
+ return this;
60
+ }
61
+ /** Determines whether a bounding volume intersects the culling volume. */
62
+ computeVisibility(boundingVolume) {
63
+ // const planes = this.planes;
64
+ let intersect = 'inside';
65
+ for (const plane of this.planes) {
66
+ const result = boundingVolume.intersectPlane(plane);
67
+ switch (result) {
68
+ case 'outside':
69
+ // We are done
70
+ return 'outside';
71
+ case 'intersecting':
72
+ // If no other intersection is outside, return INTERSECTING
73
+ intersect = 'intersecting';
74
+ break;
75
+ default:
76
+ }
77
+ }
78
+ return intersect;
79
+ }
80
+ /**
81
+ * Determines whether a bounding volume intersects the culling volume.
82
+ *
83
+ * @param parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling
84
+ * volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then
85
+ * the parent (and therefore this) volume is completely inside plane[planeIndex]
86
+ * and that plane check can be skipped.
87
+ */
88
+ computeVisibilityWithPlaneMask(boundingVolume, parentPlaneMask) {
89
+ assert(Number.isFinite(parentPlaneMask), 'parentPlaneMask is required.');
90
+ if (parentPlaneMask === CullingVolume.MASK_OUTSIDE ||
91
+ parentPlaneMask === CullingVolume.MASK_INSIDE) {
92
+ // parent is completely outside or completely inside, so this child is as well.
93
+ return parentPlaneMask;
94
+ }
95
+ // Start with MASK_INSIDE (all zeros) so that after the loop, the return value can be compared with MASK_INSIDE.
96
+ // (Because if there are fewer than 31 planes, the upper bits wont be changed.)
97
+ let mask = CullingVolume.MASK_INSIDE;
98
+ const planes = this.planes;
99
+ for (let k = 0; k < this.planes.length; ++k) {
100
+ // For k greater than 31 (since 31 is the maximum number of INSIDE/INTERSECTING bits we can store), skip the optimization.
101
+ const flag = k < 31 ? 1 << k : 0;
102
+ if (k < 31 && (parentPlaneMask & flag) === 0) {
103
+ // boundingVolume is known to be INSIDE this plane.
104
+ continue;
105
+ }
106
+ const plane = planes[k];
107
+ const result = boundingVolume.intersectPlane(plane);
108
+ if (result === 'outside') {
109
+ return CullingVolume.MASK_OUTSIDE;
110
+ }
111
+ else if (result === 'intersecting') {
112
+ mask |= flag;
113
+ }
114
+ }
115
+ return mask;
116
+ }
117
+ }
118
+ /**
119
+ * For plane masks (as used in {@link CullingVolume#computeVisibilityWithPlaneMask}), this special value
120
+ * represents the case where the object bounding volume is entirely outside the culling volume.
121
+ */
122
+ CullingVolume.MASK_OUTSIDE = 0xffffffff;
123
+ /**
124
+ * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
125
+ * represents the case where the object bounding volume is entirely inside the culling volume.
126
+ */
127
+ CullingVolume.MASK_INSIDE = 0x00000000;
128
+ /**
129
+ * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
130
+ * represents the case where the object bounding volume (may) intersect all planes of the culling volume.
131
+ */
132
+ CullingVolume.MASK_INDETERMINATE = 0x7fffffff;
133
+ //# sourceMappingURL=culling-volume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"culling-volume.js","sourceRoot":"","sources":["../../../src/culling/lib/culling-volume.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,8CAA8C;AAC9C,oEAAoE;AACpE,4DAA4D;AAC5D,mHAAmH;AAEnH,2EAA2E;AAC3E,4EAA4E;AAE5E,oBAAoB;AACpB,OAAO,EAAC,OAAO,EAAE,MAAM,EAA8B,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAC,oBAAoB,EAAC,6BAA0B;AAEvD,OAAO,EAAC,KAAK,EAAC,mBAAgB;AAI9B,uBAAuB;AACvB,MAAM,KAAK,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvF,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAE,CAAC;AACzC,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAE,CAAC;AACzC,mEAAmE;AAEnE,0CAA0C;AAC1C,MAAM,OAAO,aAAa;IAsBxB;;;SAGK;IACL,YAAY,SAAkB,EAAE;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAAC,cAA8B;QAC/C,IAAI,CAAC,MAA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