@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,151 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { closestDistanceToCircleArc2D, closestDistanceToSegment2D, ImplicitShapeBase, solveQuadratic } from "./implicit-shape.js";
5
+ const EPSILON = 1e-6;
6
+ /** Analytic glTF capsule: the convex hull of two spheres on the Y axis. */
7
+ export class CapsuleShape extends ImplicitShapeBase {
8
+ constructor(props = {}) {
9
+ super(props.matrix);
10
+ this.type = 'capsule';
11
+ this.height = props.height ?? 1;
12
+ this.radiusBottom = props.radiusBottom ?? 0.5;
13
+ this.radiusTop = props.radiusTop ?? 0.5;
14
+ if (!Number.isFinite(this.height) || this.height <= 0)
15
+ throw new Error('Capsule height must be greater than zero');
16
+ if (![this.radiusBottom, this.radiusTop].every(value => Number.isFinite(value) && value >= 0))
17
+ throw new Error('Capsule radii must be non-negative');
18
+ if (this.radiusBottom === 0 && this.radiusTop === 0)
19
+ throw new Error('At least one capsule radius must be greater than zero');
20
+ }
21
+ clone() {
22
+ return new CapsuleShape({
23
+ height: this.height,
24
+ radiusBottom: this.radiusBottom,
25
+ radiusTop: this.radiusTop,
26
+ matrix: this.matrix
27
+ });
28
+ }
29
+ equals(shape) {
30
+ return (shape instanceof CapsuleShape &&
31
+ super.equals(shape) &&
32
+ this.height === shape.height &&
33
+ this.radiusBottom === shape.radiusBottom &&
34
+ this.radiusTop === shape.radiusTop);
35
+ }
36
+ containsLocalPoint(point) {
37
+ const profile = this.getProfile();
38
+ const radial = Math.hypot(point[0], point[2]);
39
+ if (profile.sphere)
40
+ return (Math.hypot(radial, point[1] - profile.sphere.center) <= profile.sphere.radius + EPSILON);
41
+ if (point[1] < profile.bottom.y)
42
+ return Math.hypot(radial, point[1] + this.height / 2) <= this.radiusBottom + EPSILON;
43
+ if (point[1] > profile.top.y)
44
+ return Math.hypot(radial, point[1] - this.height / 2) <= this.radiusTop + EPSILON;
45
+ const t = (point[1] - profile.bottom.y) / (profile.top.y - profile.bottom.y);
46
+ return (radial <= profile.bottom.radius + (profile.top.radius - profile.bottom.radius) * t + EPSILON);
47
+ }
48
+ distanceToLocalPoint(point) {
49
+ if (this.containsLocalPoint(point))
50
+ return 0;
51
+ const profile = this.getProfile();
52
+ const radial = Math.hypot(point[0], point[2]);
53
+ if (profile.sphere)
54
+ return Math.max(0, Math.hypot(radial, point[1] - profile.sphere.center) - profile.sphere.radius);
55
+ const delta = this.radiusTop - this.radiusBottom;
56
+ const sideNormalY = -delta / this.height;
57
+ const bottomArc = closestDistanceToCircleArc2D(radial, point[1], -this.height / 2, this.radiusBottom, -1, sideNormalY);
58
+ const topArc = closestDistanceToCircleArc2D(radial, point[1], this.height / 2, this.radiusTop, sideNormalY, 1);
59
+ const side = closestDistanceToSegment2D(radial, point[1], profile.bottom.radius, profile.bottom.y, profile.top.radius, profile.top.y);
60
+ return Math.min(bottomArc, topArc, side);
61
+ }
62
+ supportLocal(direction) {
63
+ const length = Math.hypot(...direction);
64
+ const unit = length ? direction.map(value => value / length) : [1, 0, 0];
65
+ const bottom = [
66
+ unit[0] * this.radiusBottom,
67
+ -this.height / 2 + unit[1] * this.radiusBottom,
68
+ unit[2] * this.radiusBottom
69
+ ];
70
+ const top = [
71
+ unit[0] * this.radiusTop,
72
+ this.height / 2 + unit[1] * this.radiusTop,
73
+ unit[2] * this.radiusTop
74
+ ];
75
+ return dot(top, direction) >= dot(bottom, direction) ? top : bottom;
76
+ }
77
+ intersectLocalRay(origin, direction) {
78
+ const profile = this.getProfile();
79
+ if (profile.sphere)
80
+ return intersectSphere(origin, direction, profile.sphere.center, profile.sphere.radius);
81
+ const candidates = [];
82
+ const slope = (profile.top.radius - profile.bottom.radius) / (profile.top.y - profile.bottom.y);
83
+ const intercept = profile.bottom.radius - slope * profile.bottom.y;
84
+ const radialAtOrigin = intercept + slope * origin[1];
85
+ const radialAlongRay = slope * direction[1];
86
+ for (const distance of solveQuadratic(direction[0] ** 2 + direction[2] ** 2 - radialAlongRay ** 2, 2 * (origin[0] * direction[0] + origin[2] * direction[2] - radialAtOrigin * radialAlongRay), origin[0] ** 2 + origin[2] ** 2 - radialAtOrigin ** 2)) {
87
+ const y = origin[1] + distance * direction[1];
88
+ if (distance >= 0 && y >= profile.bottom.y - EPSILON && y <= profile.top.y + EPSILON) {
89
+ const x = origin[0] + distance * direction[0];
90
+ const z = origin[2] + distance * direction[2];
91
+ const radial = Math.hypot(x, z) || 1;
92
+ const normal = [x / radial, -slope, z / radial];
93
+ const length = Math.hypot(...normal);
94
+ candidates.push({ distance, normal: normal.map(value => value / length) });
95
+ }
96
+ }
97
+ for (const bottomHit of intersectSphereRoots(origin, direction, -this.height / 2, this.radiusBottom)) {
98
+ const y = origin[1] + bottomHit.distance * direction[1];
99
+ if (y <= profile.bottom.y + EPSILON)
100
+ candidates.push(bottomHit);
101
+ }
102
+ for (const topHit of intersectSphereRoots(origin, direction, this.height / 2, this.radiusTop)) {
103
+ const y = origin[1] + topHit.distance * direction[1];
104
+ if (y >= profile.top.y - EPSILON)
105
+ candidates.push(topHit);
106
+ }
107
+ return candidates.sort((a, b) => a.distance - b.distance)[0];
108
+ }
109
+ getProfile() {
110
+ const delta = this.radiusTop - this.radiusBottom;
111
+ if (Math.abs(delta) >= this.height) {
112
+ const topWins = this.radiusTop >= this.radiusBottom;
113
+ return {
114
+ sphere: {
115
+ center: topWins ? this.height / 2 : -this.height / 2,
116
+ radius: topWins ? this.radiusTop : this.radiusBottom
117
+ },
118
+ bottom: { radius: 0, y: 0 },
119
+ top: { radius: 0, y: 0 }
120
+ };
121
+ }
122
+ const sinSlope = delta / this.height;
123
+ const radialNormal = Math.sqrt(1 - sinSlope * sinSlope);
124
+ const normalY = -sinSlope;
125
+ return {
126
+ bottom: {
127
+ radius: this.radiusBottom * radialNormal,
128
+ y: -this.height / 2 + this.radiusBottom * normalY
129
+ },
130
+ top: { radius: this.radiusTop * radialNormal, y: this.height / 2 + this.radiusTop * normalY }
131
+ };
132
+ }
133
+ }
134
+ function intersectSphere(origin, direction, centerY, radius) {
135
+ return intersectSphereRoots(origin, direction, centerY, radius)[0];
136
+ }
137
+ function intersectSphereRoots(origin, direction, centerY, radius) {
138
+ if (radius === 0)
139
+ return [];
140
+ const relative = [origin[0], origin[1] - centerY, origin[2]];
141
+ return solveQuadratic(dot(direction, direction), 2 * dot(relative, direction), dot(relative, relative) - radius * radius)
142
+ .filter(distance => distance >= 0)
143
+ .map(distance => ({
144
+ distance,
145
+ normal: relative.map((value, i) => (value + distance * direction[i]) / radius)
146
+ }));
147
+ }
148
+ function dot(a, b) {
149
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
150
+ }
151
+ //# sourceMappingURL=capsule-shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capsule-shape.js","sourceRoot":"","sources":["../../../../src/culling/lib/shapes/capsule-shape.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,iBAAiB,EACjB,cAAc,EAGf,4BAAyB;AAE1B,MAAM,OAAO,GAAG,IAAI,CAAC;AASrB,2EAA2E;AAC3E,MAAM,OAAO,YAAa,SAAQ,iBAAiB;IAMjD,YAAY,QAA2B,EAAE;QACvC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QANb,SAAI,GAAG,SAAkB,CAAC;QAOjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,IAAI,GAAG,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,GAAG,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YAC3F,MAAM,IAAI,KAAK,CAAC,oCAA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E,OAAO,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,cAAc,CACnB,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,EACzB,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,EAC5B,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,GAAG,MAAM,CAC1C;SACE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,IAAI,CAAC,CAAC;SACjC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChB,QAAQ;QACR,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;KAC/E,CAAC,CAAC,CAAC;AACR,CAAC;AAED,SAAS,GAAG,CAAC,CAAoB,EAAE,CAAoB;IACrD,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { ImplicitShapeBase, type ImplicitShape, type LocalRayIntersection } from "./implicit-shape.js";
2
+ export type CylinderShapeProps = {
3
+ height?: number;
4
+ radiusBottom?: number;
5
+ radiusTop?: number;
6
+ matrix?: readonly number[];
7
+ };
8
+ /** Analytic closed, Y-aligned glTF cylinder shape, including tapered cylinders. */
9
+ export declare class CylinderShape extends ImplicitShapeBase {
10
+ readonly type: "cylinder";
11
+ readonly height: number;
12
+ readonly radiusBottom: number;
13
+ readonly radiusTop: number;
14
+ constructor(props?: CylinderShapeProps);
15
+ clone(): CylinderShape;
16
+ equals(shape: ImplicitShape): boolean;
17
+ containsLocalPoint(point: readonly number[]): boolean;
18
+ distanceToLocalPoint(point: readonly number[]): number;
19
+ supportLocal(direction: readonly number[]): readonly number[];
20
+ intersectLocalRay(origin: readonly number[], direction: readonly number[]): LocalRayIntersection | undefined;
21
+ }
22
+ //# sourceMappingURL=cylinder-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cylinder-shape.d.ts","sourceRoot":"","sources":["../../../../src/culling/lib/shapes/cylinder-shape.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,iBAAiB,EAEjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAC1B,4BAAyB;AAI1B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,mFAAmF;AACnF,qBAAa,aAAc,SAAQ,iBAAiB;IAClD,QAAQ,CAAC,IAAI,EAAG,UAAU,CAAU;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,KAAK,GAAE,kBAAuB;IAa1C,KAAK,IAAI,aAAa;IAQb,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAS9C,kBAAkB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO;IAOrD,oBAAoB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAgBtD,YAAY,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE;IAW7D,iBAAiB,CACf,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,oBAAoB,GAAG,SAAS;CAqCpC"}
@@ -0,0 +1,99 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { closestDistanceToSegment2D, ImplicitShapeBase, solveQuadratic } from "./implicit-shape.js";
5
+ const EPSILON = 1e-6;
6
+ /** Analytic closed, Y-aligned glTF cylinder shape, including tapered cylinders. */
7
+ export class CylinderShape extends ImplicitShapeBase {
8
+ constructor(props = {}) {
9
+ super(props.matrix);
10
+ this.type = 'cylinder';
11
+ this.height = props.height ?? 2;
12
+ this.radiusBottom = props.radiusBottom ?? 0.5;
13
+ this.radiusTop = props.radiusTop ?? 0.5;
14
+ if (!Number.isFinite(this.height) || this.height <= 0)
15
+ throw new Error('Cylinder height must be greater than zero');
16
+ if (![this.radiusBottom, this.radiusTop].every(value => Number.isFinite(value) && value >= 0))
17
+ throw new Error('Cylinder radii must be non-negative');
18
+ if (this.radiusBottom === 0 && this.radiusTop === 0)
19
+ throw new Error('At least one cylinder radius must be greater than zero');
20
+ }
21
+ clone() {
22
+ return new CylinderShape({
23
+ height: this.height,
24
+ radiusBottom: this.radiusBottom,
25
+ radiusTop: this.radiusTop,
26
+ matrix: this.matrix
27
+ });
28
+ }
29
+ equals(shape) {
30
+ return (shape instanceof CylinderShape &&
31
+ super.equals(shape) &&
32
+ this.height === shape.height &&
33
+ this.radiusBottom === shape.radiusBottom &&
34
+ this.radiusTop === shape.radiusTop);
35
+ }
36
+ containsLocalPoint(point) {
37
+ const half = this.height / 2;
38
+ if (point[1] < -half - EPSILON || point[1] > half + EPSILON)
39
+ return false;
40
+ const t = (point[1] + half) / this.height;
41
+ const radius = this.radiusBottom + (this.radiusTop - this.radiusBottom) * t;
42
+ return Math.hypot(point[0], point[2]) <= radius + EPSILON;
43
+ }
44
+ distanceToLocalPoint(point) {
45
+ if (this.containsLocalPoint(point))
46
+ return 0;
47
+ const radial = Math.hypot(point[0], point[2]);
48
+ const half = this.height / 2;
49
+ const side = closestDistanceToSegment2D(radial, point[1], this.radiusBottom, -half, this.radiusTop, half);
50
+ const bottom = closestDistanceToSegment2D(radial, point[1], 0, -half, this.radiusBottom, -half);
51
+ const top = closestDistanceToSegment2D(radial, point[1], 0, half, this.radiusTop, half);
52
+ return Math.min(side, bottom, top);
53
+ }
54
+ supportLocal(direction) {
55
+ const radialLength = Math.hypot(direction[0], direction[2]);
56
+ const x = radialLength ? direction[0] / radialLength : 1;
57
+ const z = radialLength ? direction[2] / radialLength : 0;
58
+ const half = this.height / 2;
59
+ const bottomValue = radialLength * this.radiusBottom - direction[1] * half;
60
+ const topValue = radialLength * this.radiusTop + direction[1] * half;
61
+ return topValue >= bottomValue
62
+ ? [x * this.radiusTop, half, z * this.radiusTop]
63
+ : [x * this.radiusBottom, -half, z * this.radiusBottom];
64
+ }
65
+ intersectLocalRay(origin, direction) {
66
+ const half = this.height / 2;
67
+ const slope = (this.radiusTop - this.radiusBottom) / this.height;
68
+ const intercept = (this.radiusTop + this.radiusBottom) / 2;
69
+ const radialAtOrigin = intercept + slope * origin[1];
70
+ const radialAlongRay = slope * direction[1];
71
+ const candidates = [];
72
+ const roots = solveQuadratic(direction[0] ** 2 + direction[2] ** 2 - radialAlongRay ** 2, 2 * (origin[0] * direction[0] + origin[2] * direction[2] - radialAtOrigin * radialAlongRay), origin[0] ** 2 + origin[2] ** 2 - radialAtOrigin ** 2);
73
+ for (const distance of roots) {
74
+ const y = origin[1] + distance * direction[1];
75
+ if (distance >= 0 && y >= -half - EPSILON && y <= half + EPSILON) {
76
+ const x = origin[0] + distance * direction[0];
77
+ const z = origin[2] + distance * direction[2];
78
+ const radial = Math.hypot(x, z) || 1;
79
+ const normal = [x / radial, -slope, z / radial];
80
+ const length = Math.hypot(...normal);
81
+ candidates.push({ distance, normal: normal.map(value => value / length) });
82
+ }
83
+ }
84
+ if (Math.abs(direction[1]) > 1e-15) {
85
+ for (const [y, radius, normalY] of [
86
+ [-half, this.radiusBottom, -1],
87
+ [half, this.radiusTop, 1]
88
+ ]) {
89
+ const distance = (y - origin[1]) / direction[1];
90
+ const x = origin[0] + distance * direction[0];
91
+ const z = origin[2] + distance * direction[2];
92
+ if (distance >= 0 && Math.hypot(x, z) <= radius + EPSILON)
93
+ candidates.push({ distance, normal: [0, normalY, 0] });
94
+ }
95
+ }
96
+ return candidates.sort((a, b) => a.distance - b.distance)[0];
97
+ }
98
+ }
99
+ //# sourceMappingURL=cylinder-shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cylinder-shape.js","sourceRoot":"","sources":["../../../../src/culling/lib/shapes/cylinder-shape.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,cAAc,EAGf,4BAAyB;AAE1B,MAAM,OAAO,GAAG,IAAI,CAAC;AASrB,mFAAmF;AACnF,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAMlD,YAAY,QAA4B,EAAE;QACxC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QANb,SAAI,GAAG,UAAmB,CAAC;QAOlC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,IAAI,GAAG,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,GAAG,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAA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,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;YACnC,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI;gBACjC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;gBAC9B,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;aAC1B,EAAE,CAAC;gBACF,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBAChD,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBAC9C,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,QAAQ,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,GAAG,OAAO;oBACvD,UAAU,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF"}
@@ -0,0 +1,56 @@
1
+ import { Matrix4, Vector3 } from '@math.gl/core';
2
+ import type { CullingResult } from "../../constants.js";
3
+ import { AxisAlignedBoundingBox } from "../bounding-volumes/axis-aligned-bounding-box.js";
4
+ import { BoundingSphere } from "../bounding-volumes/bounding-sphere.js";
5
+ import type { BoundingVolume } from "../bounding-volumes/bounding-volume.js";
6
+ import type { Plane } from "../plane.js";
7
+ import type { Ray } from "../ray.js";
8
+ export type RayIntersection = {
9
+ distance: number;
10
+ point: Vector3;
11
+ normal: Vector3;
12
+ entering: boolean;
13
+ };
14
+ export interface ImplicitShape extends BoundingVolume {
15
+ readonly type: 'box' | 'capsule' | 'cylinder' | 'plane' | 'sphere';
16
+ readonly matrix: Matrix4;
17
+ clone(): ImplicitShape;
18
+ equals(shape: ImplicitShape): boolean;
19
+ containsPoint(point: readonly number[]): boolean;
20
+ intersectRay(ray: Ray): RayIntersection | undefined;
21
+ getAxisAlignedBoundingBox(): AxisAlignedBoundingBox | undefined;
22
+ getBoundingSphere(): BoundingSphere | undefined;
23
+ }
24
+ export type LocalRayIntersection = {
25
+ distance: number;
26
+ normal: readonly number[];
27
+ };
28
+ /** Shared affine transform, support mapping and query implementation for finite convex shapes. */
29
+ export declare abstract class ImplicitShapeBase implements ImplicitShape {
30
+ abstract readonly type: ImplicitShape['type'];
31
+ readonly matrix: Matrix4;
32
+ protected inverseMatrix: Matrix4;
33
+ constructor(matrix?: readonly number[]);
34
+ abstract clone(): ImplicitShapeBase;
35
+ abstract containsLocalPoint(point: readonly number[]): boolean;
36
+ abstract distanceToLocalPoint(point: readonly number[]): number;
37
+ abstract supportLocal(direction: readonly number[]): readonly number[];
38
+ abstract intersectLocalRay(origin: readonly number[], direction: readonly number[]): LocalRayIntersection | undefined;
39
+ equals(shape: ImplicitShape): boolean;
40
+ transform(transform: readonly number[]): this;
41
+ containsPoint(point: readonly number[]): boolean;
42
+ distanceSquaredTo(point: readonly number[]): number;
43
+ /** Exact for rigid/uniform transforms; conservative estimate for non-uniform scale or shear. */
44
+ distanceTo(point: readonly number[]): number;
45
+ intersectPlane(plane: Plane): CullingResult;
46
+ intersectRay(ray: Ray): RayIntersection | undefined;
47
+ getAxisAlignedBoundingBox(): AxisAlignedBoundingBox | undefined;
48
+ getBoundingSphere(): BoundingSphere | undefined;
49
+ protected getSupportPoint(worldDirection: readonly number[]): Vector3;
50
+ }
51
+ export declare function validateAffineMatrix(matrix: readonly number[]): void;
52
+ export declare function solveQuadratic(a: number, b: number, c: number): number[];
53
+ export declare function closestDistanceToSegment2D(px: number, py: number, ax: number, ay: number, bx: number, by: number): number;
54
+ /** Distance in the radial/Y half-plane to a spherical profile arc selected by normal Y range. */
55
+ export declare function closestDistanceToCircleArc2D(px: number, py: number, centerY: number, radius: number, minimumNormalY: number, maximumNormalY: number): number;
56
+ //# sourceMappingURL=implicit-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implicit-shape.d.ts","sourceRoot":"","sources":["../../../../src/culling/lib/shapes/implicit-shape.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAC,aAAa,EAAC,2BAAwB;AACnD,OAAO,EAAC,sBAAsB,EAAC,yDAAsD;AACrF,OAAO,EAAC,cAAc,EAAC,+CAA4C;AACnE,OAAO,KAAK,EAAC,cAAc,EAAC,+CAA4C;AACxE,OAAO,KAAK,EAAC,KAAK,EAAC,oBAAiB;AACpC,OAAO,KAAK,EAAC,GAAG,EAAC,kBAAe;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IACnE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,KAAK,IAAI,aAAa,CAAC;IACvB,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAA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AAM,EAAE,GAAG,MAAM;IAKnD,gGAAgG;IAChG,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAO5C,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa;IAU3C,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,GAAG,SAAS;IAkBnD,yBAAyB,IAAI,sBAAsB,GAAG,SAAS;IAa/D,iBAAiB,IAAI,cAAc,GAAG,SAAS;IAM/C,SAAS,CAAC,eAAe,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO;CAStE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAcpE;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxE;AAED,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,MAAM,CAQR;AAED,iGAAiG;AACjG,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,MAAM,CAeR"}
@@ -0,0 +1,142 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { Matrix4, Vector3 } from '@math.gl/core';
5
+ import { AxisAlignedBoundingBox } from "../bounding-volumes/axis-aligned-bounding-box.js";
6
+ import { BoundingSphere } from "../bounding-volumes/bounding-sphere.js";
7
+ /** Shared affine transform, support mapping and query implementation for finite convex shapes. */
8
+ export class ImplicitShapeBase {
9
+ constructor(matrix) {
10
+ this.matrix = new Matrix4();
11
+ if (matrix)
12
+ this.matrix.copy(matrix);
13
+ validateAffineMatrix(this.matrix);
14
+ this.inverseMatrix = this.matrix.clone().invert();
15
+ }
16
+ equals(shape) {
17
+ if (this.type !== shape.type)
18
+ return false;
19
+ for (let i = 0; i < 16; i++)
20
+ if (this.matrix[i] !== shape.matrix[i])
21
+ return false;
22
+ return true;
23
+ }
24
+ transform(transform) {
25
+ const next = new Matrix4().copy(transform);
26
+ validateAffineMatrix(next);
27
+ this.matrix.multiplyLeft(next);
28
+ validateAffineMatrix(this.matrix);
29
+ this.inverseMatrix.copy(this.matrix).invert();
30
+ return this;
31
+ }
32
+ containsPoint(point) {
33
+ return this.containsLocalPoint(this.inverseMatrix.transformAsPoint(point));
34
+ }
35
+ distanceSquaredTo(point) {
36
+ const distance = this.distanceTo(point);
37
+ return distance * distance;
38
+ }
39
+ /** Exact for rigid/uniform transforms; conservative estimate for non-uniform scale or shear. */
40
+ distanceTo(point) {
41
+ const localPoint = this.inverseMatrix.transformAsPoint(point);
42
+ const localDistance = this.distanceToLocalPoint(localPoint);
43
+ const scales = this.matrix.getScale();
44
+ return localDistance * Math.min(scales[0], scales[1], scales[2]);
45
+ }
46
+ intersectPlane(plane) {
47
+ const maximum = this.getSupportPoint(plane.normal);
48
+ const minimum = this.getSupportPoint([-plane.normal[0], -plane.normal[1], -plane.normal[2]]);
49
+ const maxDistance = plane.getPointDistance(maximum);
50
+ const minDistance = plane.getPointDistance(minimum);
51
+ if (minDistance > 0)
52
+ return 'inside';
53
+ if (maxDistance < 0)
54
+ return 'outside';
55
+ return 'intersecting';
56
+ }
57
+ intersectRay(ray) {
58
+ const localOrigin = this.inverseMatrix.transformAsPoint(ray.origin);
59
+ const localDirection = this.inverseMatrix.transformAsVector(ray.direction);
60
+ const hit = this.intersectLocalRay(localOrigin, localDirection);
61
+ if (!hit || hit.distance < 0)
62
+ return undefined;
63
+ const point = new Vector3(ray.direction).scale(hit.distance).add(ray.origin);
64
+ const inverse = this.inverseMatrix;
65
+ const normal = new Vector3(inverse[0] * hit.normal[0] + inverse[1] * hit.normal[1] + inverse[2] * hit.normal[2], inverse[4] * hit.normal[0] + inverse[5] * hit.normal[1] + inverse[6] * hit.normal[2], inverse[8] * hit.normal[0] + inverse[9] * hit.normal[1] + inverse[10] * hit.normal[2]).normalize();
66
+ return { distance: hit.distance, point, normal, entering: ray.direction.dot(normal) < 0 };
67
+ }
68
+ getAxisAlignedBoundingBox() {
69
+ const minimum = new Vector3();
70
+ const maximum = new Vector3();
71
+ for (let axis = 0; axis < 3; axis++) {
72
+ const direction = [0, 0, 0];
73
+ direction[axis] = 1;
74
+ maximum[axis] = this.getSupportPoint(direction)[axis];
75
+ direction[axis] = -1;
76
+ minimum[axis] = this.getSupportPoint(direction)[axis];
77
+ }
78
+ return new AxisAlignedBoundingBox(minimum, maximum);
79
+ }
80
+ getBoundingSphere() {
81
+ const box = this.getAxisAlignedBoundingBox();
82
+ if (!box)
83
+ return undefined;
84
+ return new BoundingSphere().fromCornerPoints(box.minimum, box.maximum);
85
+ }
86
+ getSupportPoint(worldDirection) {
87
+ const matrix = this.matrix;
88
+ const localDirection = [
89
+ matrix[0] * worldDirection[0] + matrix[1] * worldDirection[1] + matrix[2] * worldDirection[2],
90
+ matrix[4] * worldDirection[0] + matrix[5] * worldDirection[1] + matrix[6] * worldDirection[2],
91
+ matrix[8] * worldDirection[0] + matrix[9] * worldDirection[1] + matrix[10] * worldDirection[2]
92
+ ];
93
+ return new Vector3(this.supportLocal(localDirection)).transform(this.matrix);
94
+ }
95
+ }
96
+ export function validateAffineMatrix(matrix) {
97
+ if (matrix.length !== 16 || matrix.some(value => !Number.isFinite(value))) {
98
+ throw new Error('Shape matrix must contain 16 finite values');
99
+ }
100
+ if (Math.abs(matrix[3]) > 1e-12 ||
101
+ Math.abs(matrix[7]) > 1e-12 ||
102
+ Math.abs(matrix[11]) > 1e-12 ||
103
+ Math.abs(matrix[15] - 1) > 1e-12) {
104
+ throw new Error('Shape matrix must be affine');
105
+ }
106
+ if (Math.abs(new Matrix4().copy(matrix).determinant()) < 1e-15)
107
+ throw new Error('Shape matrix must be invertible');
108
+ }
109
+ export function solveQuadratic(a, b, c) {
110
+ if (Math.abs(a) < 1e-15)
111
+ return Math.abs(b) < 1e-15 ? [] : [-c / b];
112
+ const discriminant = b * b - 4 * a * c;
113
+ if (discriminant < 0)
114
+ return [];
115
+ const root = Math.sqrt(Math.max(0, discriminant));
116
+ return [(-b - root) / (2 * a), (-b + root) / (2 * a)].sort((left, right) => left - right);
117
+ }
118
+ export function closestDistanceToSegment2D(px, py, ax, ay, bx, by) {
119
+ const dx = bx - ax;
120
+ const dy = by - ay;
121
+ const denominator = dx * dx + dy * dy;
122
+ const t = denominator
123
+ ? Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / denominator))
124
+ : 0;
125
+ return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
126
+ }
127
+ /** Distance in the radial/Y half-plane to a spherical profile arc selected by normal Y range. */
128
+ export function closestDistanceToCircleArc2D(px, py, centerY, radius, minimumNormalY, maximumNormalY) {
129
+ if (radius === 0)
130
+ return Math.hypot(px, py - centerY);
131
+ const dx = px;
132
+ const dy = py - centerY;
133
+ const length = Math.hypot(dx, dy);
134
+ const normalY = length ? dy / length : 0;
135
+ if (normalY >= minimumNormalY && normalY <= maximumNormalY) {
136
+ return Math.abs(length - radius);
137
+ }
138
+ const minimumRadius = radius * Math.sqrt(Math.max(0, 1 - minimumNormalY ** 2));
139
+ const maximumRadius = radius * Math.sqrt(Math.max(0, 1 - maximumNormalY ** 2));
140
+ return Math.min(Math.hypot(px - minimumRadius, py - (centerY + radius * minimumNormalY)), Math.hypot(px - maximumRadius, py - (centerY + radius * maximumNormalY)));
141
+ }
142
+ //# sourceMappingURL=implicit-shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implicit-shape.js","sourceRoot":"","sources":["../../../../src/culling/lib/shap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CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,cAAc,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/E,MAAM,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,cAAc,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/E,OAAO,IAAI,CAAC,GAAG,CACb,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,aAAa,EAAE,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,GAAG,cAAc,CAAC,CAAC,EACxE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,aAAa,EAAE,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,GAAG,cAAc,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { CullingResult } from "../../constants.js";
2
+ import { ImplicitShapeBase, type ImplicitShape, type LocalRayIntersection } from "./implicit-shape.js";
3
+ import type { AxisAlignedBoundingBox } from "../bounding-volumes/axis-aligned-bounding-box.js";
4
+ import type { BoundingSphere } from "../bounding-volumes/bounding-sphere.js";
5
+ import type { Plane } from "../plane.js";
6
+ export type PlaneShapeProps = {
7
+ sizeX?: number;
8
+ sizeZ?: number;
9
+ matrix?: readonly number[];
10
+ };
11
+ /** Analytic glTF plane. The surface faces +Y and the negative-Y half-space is inside. */
12
+ export declare class PlaneShape extends ImplicitShapeBase {
13
+ readonly type: "plane";
14
+ readonly sizeX?: number;
15
+ readonly sizeZ?: number;
16
+ constructor(props?: PlaneShapeProps);
17
+ clone(): PlaneShape;
18
+ equals(shape: ImplicitShape): boolean;
19
+ containsLocalPoint(point: readonly number[]): boolean;
20
+ distanceToLocalPoint(point: readonly number[]): number;
21
+ supportLocal(): readonly number[];
22
+ intersectLocalRay(origin: readonly number[], direction: readonly number[]): LocalRayIntersection | undefined;
23
+ intersectPlane(plane: Plane): CullingResult;
24
+ getAxisAlignedBoundingBox(): AxisAlignedBoundingBox | undefined;
25
+ getBoundingSphere(): BoundingSphere | undefined;
26
+ }
27
+ //# sourceMappingURL=plane-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plane-shape.d.ts","sourceRoot":"","sources":["../../../../src/culling/lib/shapes/plane-shape.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,aAAa,EAAC,2BAAwB;AACnD,OAAO,EAAC,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAC,4BAAyB;AAClG,OAAO,KAAK,EAAC,sBAAsB,EAAC,yDAAsD;AAC1F,OAAO,KAAK,EAAC,cAAc,EAAC,+CAA4C;AACxE,OAAO,KAAK,EAAC,KAAK,EAAC,oBAAiB;AAEpC,MAAM,MAAM,eAAe,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAC,CAAC;AAE3F,yFAAyF;AACzF,qBAAa,UAAW,SAAQ,iBAAiB;IAC/C,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAU;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBACZ,KAAK,GAAE,eAAoB;IASvC,KAAK,IAAI,UAAU;IAGV,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAQ9C,kBAAkB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO;IAGrD,oBAAoB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAGtD,YAAY,IAAI,SAAS,MAAM,EAAE;IAGjC,iBAAiB,CACf,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,oBAAoB,GAAG,SAAS;IAU1B,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa;IAW3C,yBAAyB,IAAI,sBAAsB,GAAG,SAAS;IAG/D,iBAAiB,IAAI,cAAc,GAAG,SAAS;CAGzD"}
@@ -0,0 +1,71 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { Vector3 } from '@math.gl/core';
5
+ import { ImplicitShapeBase } from "./implicit-shape.js";
6
+ /** Analytic glTF plane. The surface faces +Y and the negative-Y half-space is inside. */
7
+ export class PlaneShape extends ImplicitShapeBase {
8
+ constructor(props = {}) {
9
+ super(props.matrix);
10
+ this.type = 'plane';
11
+ this.sizeX = props.sizeX;
12
+ this.sizeZ = props.sizeZ;
13
+ if (this.sizeX !== undefined && (!Number.isFinite(this.sizeX) || this.sizeX <= 0))
14
+ throw new Error('Plane sizeX must be greater than zero');
15
+ if (this.sizeZ !== undefined && (!Number.isFinite(this.sizeZ) || this.sizeZ <= 0))
16
+ throw new Error('Plane sizeZ must be greater than zero');
17
+ }
18
+ clone() {
19
+ return new PlaneShape({ sizeX: this.sizeX, sizeZ: this.sizeZ, matrix: this.matrix });
20
+ }
21
+ equals(shape) {
22
+ return (shape instanceof PlaneShape &&
23
+ super.equals(shape) &&
24
+ this.sizeX === shape.sizeX &&
25
+ this.sizeZ === shape.sizeZ);
26
+ }
27
+ containsLocalPoint(point) {
28
+ return point[1] <= 1e-12;
29
+ }
30
+ distanceToLocalPoint(point) {
31
+ return Math.max(0, point[1]);
32
+ }
33
+ supportLocal() {
34
+ throw new Error('An unbounded plane half-space has no finite support point');
35
+ }
36
+ intersectLocalRay(origin, direction) {
37
+ if (Math.abs(direction[1]) < 1e-15)
38
+ return undefined;
39
+ const distance = -origin[1] / direction[1];
40
+ if (distance < 0)
41
+ return undefined;
42
+ const x = origin[0] + distance * direction[0];
43
+ const z = origin[2] + distance * direction[2];
44
+ if (this.sizeX !== undefined && Math.abs(x) > this.sizeX / 2 + 1e-12)
45
+ return undefined;
46
+ if (this.sizeZ !== undefined && Math.abs(z) > this.sizeZ / 2 + 1e-12)
47
+ return undefined;
48
+ return { distance, normal: [0, 1, 0] };
49
+ }
50
+ intersectPlane(plane) {
51
+ const boundaryPoint = new Vector3(0, 0, 0).transform(this.matrix);
52
+ const inverse = this.inverseMatrix;
53
+ const boundaryNormal = new Vector3(inverse[1], inverse[5], inverse[9]).normalize();
54
+ const alignment = boundaryNormal.dot(plane.normal);
55
+ if (Math.abs(Math.abs(alignment) - 1) > 1e-10)
56
+ return 'intersecting';
57
+ const boundaryDistance = plane.getPointDistance(boundaryPoint);
58
+ if (alignment < 0 && boundaryDistance > 0)
59
+ return 'inside';
60
+ if (alignment > 0 && boundaryDistance < 0)
61
+ return 'outside';
62
+ return 'intersecting';
63
+ }
64
+ getAxisAlignedBoundingBox() {
65
+ return undefined;
66
+ }
67
+ getBoundingSphere() {
68
+ return undefined;
69
+ }
70
+ }
71
+ //# sourceMappingURL=plane-shape.js.map