@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,153 @@
1
+ import { NumericArray } from '@math.gl/core';
2
+ import { Matrix4, Vector2 } from '@math.gl/core';
3
+ import { CullingVolume } from "./culling-volume.js";
4
+ type PerspectiveFrustumOptions = {
5
+ /** The angle of the field of view (FOV), in radians. */
6
+ fov?: number;
7
+ /** The aspect ratio of the frustum's width to it's height. */
8
+ aspectRatio?: number;
9
+ /** The distance of the near plane. */
10
+ near?: number;
11
+ /** The distance of the far plane. */
12
+ far?: number;
13
+ /** The offset in the x direction. */
14
+ xOffset?: number;
15
+ /** The offset in the y direction. */
16
+ yOffset?: number;
17
+ };
18
+ /**
19
+ * The viewing frustum is defined by 6 planes.
20
+ * Each plane is represented by a {@link Vector4} object, where the x, y, and z components
21
+ * define the unit vector normal to the plane, and the w component is the distance of the
22
+ * plane from the origin/camera position.
23
+ *
24
+ * @alias PerspectiveFrustum
25
+ *
26
+ * @example
27
+ * var frustum = new PerspectiveFrustum({
28
+ * fov : Math.PI_OVER_THREE,
29
+ * aspectRatio : canvas.clientWidth / canvas.clientHeight
30
+ * near : 1.0,
31
+ * far : 1000.0
32
+ * });
33
+ *
34
+ * @see PerspectiveOffCenterFrustum
35
+ */
36
+ export declare class PerspectiveFrustum {
37
+ private _offCenterFrustum;
38
+ /**
39
+ * The angle of the field of view (FOV), in radians. This angle will be used
40
+ * as the horizontal FOV if the width is greater than the height, otherwise
41
+ * it will be the vertical FOV.
42
+ */
43
+ fov?: number;
44
+ private _fov;
45
+ private _fovy;
46
+ private _sseDenominator;
47
+ /**
48
+ * The aspect ratio of the frustum's width to it's height.
49
+ */
50
+ aspectRatio?: number;
51
+ private _aspectRatio;
52
+ /**
53
+ * The distance of the near plane.
54
+ * @default 1.0
55
+ */
56
+ near: number;
57
+ private _near;
58
+ /**
59
+ * The distance of the far plane.
60
+ * @default 500000000.0
61
+ */
62
+ far: number;
63
+ private _far;
64
+ /**
65
+ * Offsets the frustum in the x direction.
66
+ * @default 0.0
67
+ */
68
+ xOffset: number;
69
+ private _xOffset;
70
+ /**
71
+ * Offsets the frustum in the y direction.
72
+ * @default 0.0
73
+ */
74
+ yOffset: number;
75
+ private _yOffset;
76
+ constructor(options?: PerspectiveFrustumOptions);
77
+ /**
78
+ * Returns a duplicate of a PerspectiveFrustum instance.
79
+ */
80
+ clone(): PerspectiveFrustum;
81
+ /**
82
+ * Compares the provided PerspectiveFrustum componentwise and returns
83
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
84
+ */
85
+ equals(other: PerspectiveFrustum): boolean;
86
+ /**
87
+ * Gets the perspective projection matrix computed from the view this.
88
+ */
89
+ get projectionMatrix(): Matrix4;
90
+ /**
91
+ * The perspective projection matrix computed from the view frustum with an infinite far plane.
92
+ */
93
+ get infiniteProjectionMatrix(): Matrix4;
94
+ /**
95
+ * Gets the angle of the vertical field of view, in radians.
96
+ */
97
+ get fovy(): number;
98
+ /**
99
+ * @private
100
+ */
101
+ get sseDenominator(): number;
102
+ /**
103
+ * Creates a culling volume for this this.ion.
104
+ * @returns {CullingVolume} A culling volume at the given position and orientation.
105
+ *
106
+ * @example
107
+ * // Check if a bounding volume intersects the this.
108
+ * var cullingVolume = this.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
109
+ * var intersect = cullingVolume.computeVisibility(boundingVolume);
110
+ */
111
+ computeCullingVolume(
112
+ /** A Vector3 defines the eye position. */
113
+ position: Readonly<NumericArray>,
114
+ /** A Vector3 defines the view direction. */
115
+ direction: Readonly<NumericArray>,
116
+ /** A Vector3 defines the up direction. */
117
+ up: Readonly<NumericArray>): CullingVolume;
118
+ /**
119
+ * Returns the pixel's width and height in meters.
120
+ * @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.
121
+ *
122
+ * @exception {DeveloperError} drawingBufferWidth must be greater than zero.
123
+ * @exception {DeveloperError} drawingBufferHeight must be greater than zero.
124
+ *
125
+ * @example
126
+ * // Example 1
127
+ * // Get the width and height of a pixel.
128
+ * var pixelSize = camera.this.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());
129
+ *
130
+ * @example
131
+ * // Example 2
132
+ * // Get the width and height of a pixel if the near plane was set to 'distance'.
133
+ * // For example, get the size of a pixel of an image on a billboard.
134
+ * var position = camera.position;
135
+ * var direction = camera.direction;
136
+ * var toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive
137
+ * var toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector
138
+ * var distance = Vector3.magnitude(toCenterProj);
139
+ * var pixelSize = camera.this.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());
140
+ */
141
+ getPixelDimensions(
142
+ /** The width of the drawing buffer. */
143
+ drawingBufferWidth: number,
144
+ /** The height of the drawing buffer. */
145
+ drawingBufferHeight: number,
146
+ /** The distance to the near plane in meters. */
147
+ distance: number,
148
+ /** The object onto which to store the result. */
149
+ result?: Vector2): Vector2;
150
+ private _update;
151
+ }
152
+ export {};
153
+ //# sourceMappingURL=perspective-frustum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perspective-frustum.d.ts","sourceRoot":"","sources":["../../../src/culling/lib/perspective-frustum.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAS,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAI/C,KAAK,yBAAyB,GAAG;IAC/B,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,iBAAiB,CAAqC;IAC9D;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,IA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IAWV,OAAO,CAAC,OAAO;CAqDhB"}
@@ -0,0 +1,191 @@
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 { assert, Vector2 } from '@math.gl/core';
7
+ import { PerspectiveOffCenterFrustum } from "./perspective-off-center-frustum.js";
8
+ const defined = (val) => val !== null && typeof val !== 'undefined';
9
+ /**
10
+ * The viewing frustum is defined by 6 planes.
11
+ * Each plane is represented by a {@link Vector4} object, where the x, y, and z components
12
+ * define the unit vector normal to the plane, and the w component is the distance of the
13
+ * plane from the origin/camera position.
14
+ *
15
+ * @alias PerspectiveFrustum
16
+ *
17
+ * @example
18
+ * var frustum = new PerspectiveFrustum({
19
+ * fov : Math.PI_OVER_THREE,
20
+ * aspectRatio : canvas.clientWidth / canvas.clientHeight
21
+ * near : 1.0,
22
+ * far : 1000.0
23
+ * });
24
+ *
25
+ * @see PerspectiveOffCenterFrustum
26
+ */
27
+ export class PerspectiveFrustum {
28
+ constructor(options = {}) {
29
+ this._offCenterFrustum = new PerspectiveOffCenterFrustum();
30
+ const { fov, aspectRatio, near = 1.0, far = 500000000.0, xOffset = 0.0, yOffset = 0.0 } = options;
31
+ this.fov = fov;
32
+ this.aspectRatio = aspectRatio;
33
+ this.near = near;
34
+ this.far = far;
35
+ this.xOffset = xOffset;
36
+ this.yOffset = yOffset;
37
+ }
38
+ /**
39
+ * Returns a duplicate of a PerspectiveFrustum instance.
40
+ */
41
+ clone() {
42
+ return new PerspectiveFrustum({
43
+ aspectRatio: this.aspectRatio,
44
+ fov: this.fov,
45
+ near: this.near,
46
+ far: this.far
47
+ });
48
+ }
49
+ /**
50
+ * Compares the provided PerspectiveFrustum componentwise and returns
51
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
52
+ */
53
+ equals(other) {
54
+ if (!defined(other) || !(other instanceof PerspectiveFrustum)) {
55
+ return false;
56
+ }
57
+ this._update();
58
+ other._update();
59
+ return (this.fov === other.fov &&
60
+ this.aspectRatio === other.aspectRatio &&
61
+ this.near === other.near &&
62
+ this.far === other.far &&
63
+ this._offCenterFrustum.equals(other._offCenterFrustum));
64
+ }
65
+ /**
66
+ * Gets the perspective projection matrix computed from the view this.
67
+ */
68
+ get projectionMatrix() {
69
+ this._update();
70
+ return this._offCenterFrustum.projectionMatrix;
71
+ }
72
+ /**
73
+ * The perspective projection matrix computed from the view frustum with an infinite far plane.
74
+ */
75
+ get infiniteProjectionMatrix() {
76
+ this._update();
77
+ return this._offCenterFrustum.infiniteProjectionMatrix;
78
+ }
79
+ /**
80
+ * Gets the angle of the vertical field of view, in radians.
81
+ */
82
+ get fovy() {
83
+ this._update();
84
+ return this._fovy;
85
+ }
86
+ /**
87
+ * @private
88
+ */
89
+ get sseDenominator() {
90
+ this._update();
91
+ return this._sseDenominator;
92
+ }
93
+ /**
94
+ * Creates a culling volume for this this.ion.
95
+ * @returns {CullingVolume} A culling volume at the given position and orientation.
96
+ *
97
+ * @example
98
+ * // Check if a bounding volume intersects the this.
99
+ * var cullingVolume = this.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
100
+ * var intersect = cullingVolume.computeVisibility(boundingVolume);
101
+ */
102
+ computeCullingVolume(
103
+ /** A Vector3 defines the eye position. */
104
+ position,
105
+ /** A Vector3 defines the view direction. */
106
+ direction,
107
+ /** A Vector3 defines the up direction. */
108
+ up) {
109
+ this._update();
110
+ return this._offCenterFrustum.computeCullingVolume(position, direction, up);
111
+ }
112
+ /**
113
+ * Returns the pixel's width and height in meters.
114
+ * @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.
115
+ *
116
+ * @exception {DeveloperError} drawingBufferWidth must be greater than zero.
117
+ * @exception {DeveloperError} drawingBufferHeight must be greater than zero.
118
+ *
119
+ * @example
120
+ * // Example 1
121
+ * // Get the width and height of a pixel.
122
+ * var pixelSize = camera.this.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());
123
+ *
124
+ * @example
125
+ * // Example 2
126
+ * // Get the width and height of a pixel if the near plane was set to 'distance'.
127
+ * // For example, get the size of a pixel of an image on a billboard.
128
+ * var position = camera.position;
129
+ * var direction = camera.direction;
130
+ * var toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive
131
+ * var toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector
132
+ * var distance = Vector3.magnitude(toCenterProj);
133
+ * var pixelSize = camera.this.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());
134
+ */
135
+ getPixelDimensions(
136
+ /** The width of the drawing buffer. */
137
+ drawingBufferWidth,
138
+ /** The height of the drawing buffer. */
139
+ drawingBufferHeight,
140
+ /** The distance to the near plane in meters. */
141
+ distance,
142
+ /** The object onto which to store the result. */
143
+ result) {
144
+ this._update();
145
+ return this._offCenterFrustum.getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result || new Vector2());
146
+ }
147
+ // eslint-disable-next-line complexity, max-statements
148
+ _update() {
149
+ assert(Number.isFinite(this.fov) &&
150
+ Number.isFinite(this.aspectRatio) &&
151
+ Number.isFinite(this.near) &&
152
+ Number.isFinite(this.far));
153
+ // 'fov, aspectRatio, near, or far parameters are not set.'
154
+ const f = this._offCenterFrustum;
155
+ if (this.fov !== this._fov ||
156
+ this.aspectRatio !== this._aspectRatio ||
157
+ this.near !== this._near ||
158
+ this.far !== this._far ||
159
+ this.xOffset !== this._xOffset ||
160
+ this.yOffset !== this._yOffset) {
161
+ assert(this.fov >= 0 && this.fov < Math.PI);
162
+ // throw new DeveloperError('fov must be in the range [0, PI).');
163
+ assert(this.aspectRatio > 0);
164
+ // throw new DeveloperError('aspectRatio must be positive.');
165
+ assert(this.near >= 0 && this.near < this.far);
166
+ // throw new DeveloperError('near must be greater than zero and less than far.');
167
+ this._aspectRatio = this.aspectRatio;
168
+ this._fov = this.fov;
169
+ this._fovy =
170
+ this.aspectRatio <= 1
171
+ ? this.fov
172
+ : Math.atan(Math.tan(this.fov * 0.5) / this.aspectRatio) * 2.0;
173
+ this._near = this.near;
174
+ this._far = this.far;
175
+ this._sseDenominator = 2.0 * Math.tan(0.5 * this._fovy);
176
+ this._xOffset = this.xOffset;
177
+ this._yOffset = this.yOffset;
178
+ f.top = this.near * Math.tan(0.5 * this._fovy);
179
+ f.bottom = -f.top;
180
+ f.right = this.aspectRatio * f.top;
181
+ f.left = -f.right;
182
+ f.near = this.near;
183
+ f.far = this.far;
184
+ f.right += this.xOffset;
185
+ f.left += this.xOffset;
186
+ f.top += this.yOffset;
187
+ f.bottom += this.yOffset;
188
+ }
189
+ }
190
+ }
191
+ //# sourceMappingURL=perspective-frustum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perspective-frustum.js","sourceRoot":"","sources":["../../../src/culling/lib/perspective-frustum.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,8CAA8C;AAC9C,oEAAoE;AACpE,4DAA4D;AAC5D,mHAAmH;AAUnH,OAAO,EAAC,MAAM,EAAW,OAAO,EAAC,MAAM,eAAe,CAAC;AACvD,OAAO,EAAC,2BAA2B,EAAC,4CAAyC;AAG7E,MAAM,OAAO,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,WAAW,CAAC;AAiB7E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,kBAAkB;IAyC7B,YAAY,UAAqC,EAAE;QAxC3C,sBAAiB,GAAG,IAAI,2BAA2B,EAAE,CAAC;QAyC5D,MAAM,EAAC,GAAG,EAAE,WAAW,EAAE,IAAI,GAAG,GAAG,EAAE,GAAG,GAAG,WAAW,EAAE,OAAO,GAAG,G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GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YACxD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;YAE7B,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAClB,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC;YACnC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;YAClB,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YACnB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;YAEjB,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC;YACxB,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC;YACvB,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC;YACtB,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC;QAC3B,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,158 @@
1
+ import { Vector2, Matrix4, NumericArray } from '@math.gl/core';
2
+ import { CullingVolume } from "./culling-volume.js";
3
+ type PerspectiveOffCenterFrustumOptions = {
4
+ left?: number;
5
+ right?: number;
6
+ top?: number;
7
+ bottom?: number;
8
+ near?: number;
9
+ far?: number;
10
+ };
11
+ export declare class PerspectiveOffCenterFrustum {
12
+ /**
13
+ * Defines the left clipping plane.
14
+ * @type {Number}
15
+ * @default undefined
16
+ */
17
+ left?: number;
18
+ private _left?;
19
+ /**
20
+ * Defines the right clipping plane.
21
+ * @type {Number}
22
+ * @default undefined
23
+ */
24
+ right?: number;
25
+ private _right?;
26
+ /**
27
+ * Defines the top clipping plane.
28
+ * @type {Number}
29
+ * @default undefined
30
+ */
31
+ top?: number;
32
+ private _top?;
33
+ /**
34
+ * Defines the bottom clipping plane.
35
+ * @type {Number}
36
+ * @default undefined
37
+ */
38
+ bottom?: number;
39
+ private _bottom?;
40
+ /**
41
+ * The distance of the near plane.
42
+ * @type {Number}
43
+ * @default 1.0
44
+ */
45
+ near: number;
46
+ private _near;
47
+ /**
48
+ * The distance of the far plane.
49
+ * @type {Number}
50
+ * @default 500000000.0
51
+ */
52
+ far: number;
53
+ private _far;
54
+ private _cullingVolume;
55
+ private _perspectiveMatrix;
56
+ private _infinitePerspective;
57
+ /**
58
+ * The viewing frustum is defined by 6 planes.
59
+ * Each plane is represented by a {@link Vector4} object, where the x, y, and z components
60
+ * define the unit vector normal to the plane, and the w component is the distance of the
61
+ * plane from the origin/camera position.
62
+ *
63
+ * @alias PerspectiveOffCenterFrustum
64
+ *
65
+ * @example
66
+ * const frustum = new PerspectiveOffCenterFrustum({
67
+ * left : -1.0,
68
+ * right : 1.0,
69
+ * top : 1.0,
70
+ * bottom : -1.0,
71
+ * near : 1.0,
72
+ * far : 100.0
73
+ * });
74
+ *
75
+ * @see PerspectiveFrustum
76
+ */
77
+ constructor(options?: PerspectiveOffCenterFrustumOptions);
78
+ /**
79
+ * Returns a duplicate of a PerspectiveOffCenterFrustum instance.
80
+ * @returns {PerspectiveOffCenterFrustum} A new PerspectiveFrustum instance.
81
+ * */
82
+ clone(): PerspectiveOffCenterFrustum;
83
+ /**
84
+ * Compares the provided PerspectiveOffCenterFrustum componentwise and returns
85
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
86
+ *
87
+ * @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
88
+ */
89
+ equals(other: PerspectiveOffCenterFrustum): boolean;
90
+ /**
91
+ * Gets the perspective projection matrix computed from the view frustum.
92
+ * @memberof PerspectiveOffCenterFrustum.prototype
93
+ * @type {Matrix4}
94
+ *
95
+ * @see PerspectiveOffCenterFrustum#infiniteProjectionMatrix
96
+ */
97
+ get projectionMatrix(): Matrix4;
98
+ /**
99
+ * Gets the perspective projection matrix computed from the view frustum with an infinite far plane.
100
+ * @memberof PerspectiveOffCenterFrustum.prototype
101
+ * @type {Matrix4}
102
+ *
103
+ * @see PerspectiveOffCenterFrustum#projectionMatrix
104
+ */
105
+ get infiniteProjectionMatrix(): Matrix4;
106
+ /**
107
+ * Creates a culling volume for this frustum.
108
+ * @returns {CullingVolume} A culling volume at the given position and orientation.
109
+ *
110
+ * @example
111
+ * // Check if a bounding volume intersects the frustum.
112
+ * const cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
113
+ * const intersect = cullingVolume.computeVisibility(boundingVolume);
114
+ */
115
+ computeCullingVolume(
116
+ /** A Vector3 defines the eye position. */
117
+ position: Readonly<NumericArray>,
118
+ /** A Vector3 defines the view direction. */
119
+ direction: Readonly<NumericArray>,
120
+ /** A Vector3 defines the up direction. */
121
+ up: Readonly<NumericArray>): CullingVolume;
122
+ /**
123
+ * Returns the pixel's width and height in meters.
124
+ *
125
+ * @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.
126
+ *
127
+ * @exception {DeveloperError} drawingBufferWidth must be greater than zero.
128
+ * @exception {DeveloperError} drawingBufferHeight must be greater than zero.
129
+ *
130
+ * @example
131
+ * // Example 1
132
+ * // Get the width and height of a pixel.
133
+ * const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());
134
+ *
135
+ * @example
136
+ * // Example 2
137
+ * // Get the width and height of a pixel if the near plane was set to 'distance'.
138
+ * // For example, get the size of a pixel of an image on a billboard.
139
+ * const position = camera.position;
140
+ * const direction = camera.direction;
141
+ * const toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive
142
+ * const toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector
143
+ * const distance = Vector3.magnitude(toCenterProj);
144
+ * const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());
145
+ */
146
+ getPixelDimensions(
147
+ /** The width of the drawing buffer. */
148
+ drawingBufferWidth: number,
149
+ /** The height of the drawing buffer. */
150
+ drawingBufferHeight: number,
151
+ /** The distance to the near plane in meters. */
152
+ distance: number,
153
+ /** The object onto which to store the result. */
154
+ result: Vector2): Vector2;
155
+ private _update;
156
+ }
157
+ export {};
158
+ //# sourceMappingURL=perspective-off-center-frustum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perspective-off-center-frustum.d.ts","sourceRoot":"","sources":["../../../src/culling/lib/perspective-off-center-frustum.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,OAAO,EAAE,OAAO,EAAU,YAAY,EAAC,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAS/C,KAAK,kCAAkC,GAAG;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,2BAA2B;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,IAAI,CAAC,CAAS;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,OAA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