@ac-kit/math-geometry 0.2.3 → 0.4.0

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 (379) hide show
  1. package/CHANGELOG.md +321 -0
  2. package/README.md +363 -52
  3. package/dist/_brand.d.ts +14 -0
  4. package/dist/_brand.d.ts.map +1 -0
  5. package/dist/_brand.js +2 -0
  6. package/dist/_brand.js.map +1 -0
  7. package/dist/_ear-clipping.d.ts +20 -0
  8. package/dist/_ear-clipping.d.ts.map +1 -0
  9. package/dist/_ear-clipping.js +360 -0
  10. package/dist/_ear-clipping.js.map +1 -0
  11. package/dist/_polygon3-cross.d.ts +23 -0
  12. package/dist/_polygon3-cross.d.ts.map +1 -0
  13. package/dist/_polygon3-cross.js +418 -0
  14. package/dist/_polygon3-cross.js.map +1 -0
  15. package/dist/_ray3-intersect.d.ts +19 -0
  16. package/dist/_ray3-intersect.d.ts.map +1 -0
  17. package/dist/_ray3-intersect.js +122 -0
  18. package/dist/_ray3-intersect.js.map +1 -0
  19. package/dist/_triangle3-cross.d.ts +66 -0
  20. package/dist/_triangle3-cross.d.ts.map +1 -0
  21. package/dist/_triangle3-cross.js +396 -0
  22. package/dist/_triangle3-cross.js.map +1 -0
  23. package/dist/box2-array-boundary.d.ts +50 -0
  24. package/dist/box2-array-boundary.d.ts.map +1 -0
  25. package/dist/box2-array-boundary.js +97 -0
  26. package/dist/box2-array-boundary.js.map +1 -0
  27. package/dist/box2-array.d.ts +42 -0
  28. package/dist/box2-array.d.ts.map +1 -0
  29. package/dist/box2-array.js +134 -0
  30. package/dist/box2-array.js.map +1 -0
  31. package/dist/box2-componentwise.d.ts +110 -0
  32. package/dist/box2-componentwise.d.ts.map +1 -0
  33. package/dist/box2-componentwise.js +325 -0
  34. package/dist/box2-componentwise.js.map +1 -0
  35. package/dist/box2-grid-index.d.ts +67 -0
  36. package/dist/box2-grid-index.d.ts.map +1 -0
  37. package/dist/box2-grid-index.js +198 -0
  38. package/dist/box2-grid-index.js.map +1 -0
  39. package/dist/box2-record.d.ts +83 -0
  40. package/dist/box2-record.d.ts.map +1 -0
  41. package/dist/box2-record.js +124 -0
  42. package/dist/box2-record.js.map +1 -0
  43. package/dist/box2.d.ts +38 -0
  44. package/dist/box2.d.ts.map +1 -0
  45. package/dist/box2.js +97 -0
  46. package/dist/box2.js.map +1 -0
  47. package/dist/box3-array-boundary.d.ts +50 -0
  48. package/dist/box3-array-boundary.d.ts.map +1 -0
  49. package/dist/box3-array-boundary.js +107 -0
  50. package/dist/box3-array-boundary.js.map +1 -0
  51. package/dist/box3-componentwise.d.ts +110 -0
  52. package/dist/box3-componentwise.d.ts.map +1 -0
  53. package/dist/box3-componentwise.js +392 -0
  54. package/dist/box3-componentwise.js.map +1 -0
  55. package/dist/box3-record.d.ts +92 -0
  56. package/dist/box3-record.d.ts.map +1 -0
  57. package/dist/box3-record.js +147 -0
  58. package/dist/box3-record.js.map +1 -0
  59. package/dist/box3.d.ts +19 -16
  60. package/dist/box3.d.ts.map +1 -1
  61. package/dist/box3.js +73 -76
  62. package/dist/box3.js.map +1 -1
  63. package/dist/box4-array-boundary.d.ts +50 -0
  64. package/dist/box4-array-boundary.d.ts.map +1 -0
  65. package/dist/box4-array-boundary.js +117 -0
  66. package/dist/box4-array-boundary.js.map +1 -0
  67. package/dist/box4-componentwise.d.ts +110 -0
  68. package/dist/box4-componentwise.d.ts.map +1 -0
  69. package/dist/box4-componentwise.js +459 -0
  70. package/dist/box4-componentwise.js.map +1 -0
  71. package/dist/box4-record.d.ts +96 -0
  72. package/dist/box4-record.d.ts.map +1 -0
  73. package/dist/box4-record.js +167 -0
  74. package/dist/box4-record.js.map +1 -0
  75. package/dist/box4.d.ts +13 -8
  76. package/dist/box4.d.ts.map +1 -1
  77. package/dist/box4.js +27 -5
  78. package/dist/box4.js.map +1 -1
  79. package/dist/circle2-array-boundary.d.ts +51 -0
  80. package/dist/circle2-array-boundary.d.ts.map +1 -0
  81. package/dist/circle2-array-boundary.js +93 -0
  82. package/dist/circle2-array-boundary.js.map +1 -0
  83. package/dist/circle2-array.d.ts +17 -0
  84. package/dist/circle2-array.d.ts.map +1 -0
  85. package/dist/circle2-array.js +44 -0
  86. package/dist/circle2-array.js.map +1 -0
  87. package/dist/circle2-record.d.ts +81 -0
  88. package/dist/circle2-record.d.ts.map +1 -0
  89. package/dist/circle2-record.js +114 -0
  90. package/dist/circle2-record.js.map +1 -0
  91. package/dist/circle2.d.ts +27 -82
  92. package/dist/circle2.d.ts.map +1 -1
  93. package/dist/circle2.js +59 -104
  94. package/dist/circle2.js.map +1 -1
  95. package/dist/coordinates/cylindrical-record.d.ts +86 -0
  96. package/dist/coordinates/cylindrical-record.d.ts.map +1 -0
  97. package/dist/coordinates/cylindrical-record.js +114 -0
  98. package/dist/coordinates/cylindrical-record.js.map +1 -0
  99. package/dist/coordinates/horizontal-record.d.ts +86 -0
  100. package/dist/coordinates/horizontal-record.d.ts.map +1 -0
  101. package/dist/coordinates/horizontal-record.js +114 -0
  102. package/dist/coordinates/horizontal-record.js.map +1 -0
  103. package/dist/coordinates/horizontal.d.ts +48 -0
  104. package/dist/coordinates/horizontal.d.ts.map +1 -0
  105. package/dist/coordinates/horizontal.js +100 -0
  106. package/dist/coordinates/horizontal.js.map +1 -0
  107. package/dist/coordinates/index.d.ts +10 -0
  108. package/dist/coordinates/index.d.ts.map +1 -0
  109. package/dist/coordinates/index.js +10 -0
  110. package/dist/coordinates/index.js.map +1 -0
  111. package/dist/coordinates/longitude-latitude-record.d.ts +81 -0
  112. package/dist/coordinates/longitude-latitude-record.d.ts.map +1 -0
  113. package/dist/coordinates/longitude-latitude-record.js +104 -0
  114. package/dist/coordinates/longitude-latitude-record.js.map +1 -0
  115. package/dist/coordinates/longitude-latitude.d.ts +33 -0
  116. package/dist/coordinates/longitude-latitude.d.ts.map +1 -0
  117. package/dist/coordinates/longitude-latitude.js +78 -0
  118. package/dist/coordinates/longitude-latitude.js.map +1 -0
  119. package/dist/coordinates/polar-record.d.ts +77 -0
  120. package/dist/coordinates/polar-record.d.ts.map +1 -0
  121. package/dist/coordinates/polar-record.js +104 -0
  122. package/dist/coordinates/polar-record.js.map +1 -0
  123. package/dist/coordinates/polar.d.ts +28 -0
  124. package/dist/coordinates/polar.d.ts.map +1 -0
  125. package/dist/coordinates/polar.js +68 -0
  126. package/dist/coordinates/polar.js.map +1 -0
  127. package/dist/coordinates/spherical-cylindrical.d.ts +49 -0
  128. package/dist/coordinates/spherical-cylindrical.d.ts.map +1 -0
  129. package/dist/coordinates/spherical-cylindrical.js +110 -0
  130. package/dist/coordinates/spherical-cylindrical.js.map +1 -0
  131. package/dist/coordinates/spherical-record.d.ts +86 -0
  132. package/dist/coordinates/spherical-record.d.ts.map +1 -0
  133. package/dist/coordinates/spherical-record.js +114 -0
  134. package/dist/coordinates/spherical-record.js.map +1 -0
  135. package/dist/frustum3-record.d.ts +132 -0
  136. package/dist/frustum3-record.d.ts.map +1 -0
  137. package/dist/frustum3-record.js +333 -0
  138. package/dist/frustum3-record.js.map +1 -0
  139. package/dist/frustum3.d.ts +60 -0
  140. package/dist/frustum3.d.ts.map +1 -0
  141. package/dist/frustum3.js +186 -0
  142. package/dist/frustum3.js.map +1 -0
  143. package/dist/index.d.ts +36 -16
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +36 -16
  146. package/dist/index.js.map +1 -1
  147. package/dist/line2-record.d.ts +87 -0
  148. package/dist/line2-record.d.ts.map +1 -0
  149. package/dist/line2-record.js +123 -0
  150. package/dist/line2-record.js.map +1 -0
  151. package/dist/line2.d.ts +24 -33
  152. package/dist/line2.d.ts.map +1 -1
  153. package/dist/line2.js +78 -52
  154. package/dist/line2.js.map +1 -1
  155. package/dist/line3-record.d.ts +91 -0
  156. package/dist/line3-record.d.ts.map +1 -0
  157. package/dist/line3-record.js +146 -0
  158. package/dist/line3-record.js.map +1 -0
  159. package/dist/line3.d.ts +11 -24
  160. package/dist/line3.d.ts.map +1 -1
  161. package/dist/line3.js +32 -36
  162. package/dist/line3.js.map +1 -1
  163. package/dist/mesh/_generator-kit.d.ts +14 -0
  164. package/dist/mesh/_generator-kit.d.ts.map +1 -0
  165. package/dist/mesh/_generator-kit.js +39 -0
  166. package/dist/mesh/_generator-kit.js.map +1 -0
  167. package/dist/mesh/_index-kernels-u16.d.ts +85 -0
  168. package/dist/mesh/_index-kernels-u16.d.ts.map +1 -0
  169. package/dist/mesh/_index-kernels-u16.js +1045 -0
  170. package/dist/mesh/_index-kernels-u16.js.map +1 -0
  171. package/dist/mesh/_index-kernels-u32.d.ts +85 -0
  172. package/dist/mesh/_index-kernels-u32.d.ts.map +1 -0
  173. package/dist/mesh/_index-kernels-u32.js +1045 -0
  174. package/dist/mesh/_index-kernels-u32.js.map +1 -0
  175. package/dist/mesh/generate-box.d.ts +16 -0
  176. package/dist/mesh/generate-box.d.ts.map +1 -0
  177. package/dist/mesh/generate-box.js +79 -0
  178. package/dist/mesh/generate-box.js.map +1 -0
  179. package/dist/mesh/generate-cylinder.d.ts +25 -0
  180. package/dist/mesh/generate-cylinder.d.ts.map +1 -0
  181. package/dist/mesh/generate-cylinder.js +117 -0
  182. package/dist/mesh/generate-cylinder.js.map +1 -0
  183. package/dist/mesh/generate-heightfield.d.ts +24 -0
  184. package/dist/mesh/generate-heightfield.d.ts.map +1 -0
  185. package/dist/mesh/generate-heightfield.js +48 -0
  186. package/dist/mesh/generate-heightfield.js.map +1 -0
  187. package/dist/mesh/generate-plane.d.ts +18 -0
  188. package/dist/mesh/generate-plane.d.ts.map +1 -0
  189. package/dist/mesh/generate-plane.js +39 -0
  190. package/dist/mesh/generate-plane.js.map +1 -0
  191. package/dist/mesh/generate-sphere.d.ts +50 -0
  192. package/dist/mesh/generate-sphere.d.ts.map +1 -0
  193. package/dist/mesh/generate-sphere.js +244 -0
  194. package/dist/mesh/generate-sphere.js.map +1 -0
  195. package/dist/mesh/index.d.ts +8 -0
  196. package/dist/mesh/index.d.ts.map +1 -0
  197. package/dist/mesh/index.js +8 -0
  198. package/dist/mesh/index.js.map +1 -0
  199. package/dist/mesh/mesh3-kernels.d.ts +122 -0
  200. package/dist/mesh/mesh3-kernels.d.ts.map +1 -0
  201. package/dist/mesh/mesh3-kernels.js +220 -0
  202. package/dist/mesh/mesh3-kernels.js.map +1 -0
  203. package/dist/mesh/mesh3.d.ts +66 -0
  204. package/dist/mesh/mesh3.d.ts.map +1 -0
  205. package/dist/mesh/mesh3.js +128 -0
  206. package/dist/mesh/mesh3.js.map +1 -0
  207. package/dist/plane3-record.d.ts +88 -0
  208. package/dist/plane3-record.d.ts.map +1 -0
  209. package/dist/plane3-record.js +123 -0
  210. package/dist/plane3-record.js.map +1 -0
  211. package/dist/plane3.d.ts +43 -28
  212. package/dist/plane3.d.ts.map +1 -1
  213. package/dist/plane3.js +149 -48
  214. package/dist/plane3.js.map +1 -1
  215. package/dist/polygon2.d.ts +132 -29
  216. package/dist/polygon2.d.ts.map +1 -1
  217. package/dist/polygon2.js +529 -96
  218. package/dist/polygon2.js.map +1 -1
  219. package/dist/polygon3.d.ts +56 -21
  220. package/dist/polygon3.d.ts.map +1 -1
  221. package/dist/polygon3.js +239 -91
  222. package/dist/polygon3.js.map +1 -1
  223. package/dist/polyline2.d.ts +37 -0
  224. package/dist/polyline2.d.ts.map +1 -0
  225. package/dist/polyline2.js +146 -0
  226. package/dist/polyline2.js.map +1 -0
  227. package/dist/polyline3.d.ts +35 -0
  228. package/dist/polyline3.d.ts.map +1 -0
  229. package/dist/polyline3.js +159 -0
  230. package/dist/polyline3.js.map +1 -0
  231. package/dist/quadtree.d.ts +255 -0
  232. package/dist/quadtree.d.ts.map +1 -0
  233. package/dist/quadtree.js +1096 -0
  234. package/dist/quadtree.js.map +1 -0
  235. package/dist/ray2-record.d.ts +86 -0
  236. package/dist/ray2-record.d.ts.map +1 -0
  237. package/dist/ray2-record.js +123 -0
  238. package/dist/ray2-record.js.map +1 -0
  239. package/dist/ray2.d.ts +38 -13
  240. package/dist/ray2.d.ts.map +1 -1
  241. package/dist/ray2.js +85 -22
  242. package/dist/ray2.js.map +1 -1
  243. package/dist/ray3-array.d.ts +27 -0
  244. package/dist/ray3-array.d.ts.map +1 -0
  245. package/dist/ray3-array.js +89 -0
  246. package/dist/ray3-array.js.map +1 -0
  247. package/dist/ray3-record.d.ts +90 -0
  248. package/dist/ray3-record.d.ts.map +1 -0
  249. package/dist/ray3-record.js +146 -0
  250. package/dist/ray3-record.js.map +1 -0
  251. package/dist/ray3.d.ts +72 -25
  252. package/dist/ray3.d.ts.map +1 -1
  253. package/dist/ray3.js +233 -64
  254. package/dist/ray3.js.map +1 -1
  255. package/dist/segment2-record.d.ts +80 -0
  256. package/dist/segment2-record.d.ts.map +1 -0
  257. package/dist/segment2-record.js +122 -0
  258. package/dist/segment2-record.js.map +1 -0
  259. package/dist/segment2.d.ts +39 -19
  260. package/dist/segment2.d.ts.map +1 -1
  261. package/dist/segment2.js +104 -42
  262. package/dist/segment2.js.map +1 -1
  263. package/dist/segment3-record.d.ts +90 -0
  264. package/dist/segment3-record.d.ts.map +1 -0
  265. package/dist/segment3-record.js +146 -0
  266. package/dist/segment3-record.js.map +1 -0
  267. package/dist/segment3.d.ts +24 -12
  268. package/dist/segment3.d.ts.map +1 -1
  269. package/dist/segment3.js +67 -30
  270. package/dist/segment3.js.map +1 -1
  271. package/dist/size.d.ts +40 -0
  272. package/dist/size.d.ts.map +1 -0
  273. package/dist/size.js +72 -0
  274. package/dist/size.js.map +1 -0
  275. package/dist/sphere3-array-boundary.d.ts +51 -0
  276. package/dist/sphere3-array-boundary.d.ts.map +1 -0
  277. package/dist/sphere3-array-boundary.js +98 -0
  278. package/dist/sphere3-array-boundary.js.map +1 -0
  279. package/dist/sphere3-record.d.ts +88 -0
  280. package/dist/sphere3-record.d.ts.map +1 -0
  281. package/dist/sphere3-record.js +123 -0
  282. package/dist/sphere3-record.js.map +1 -0
  283. package/dist/sphere3.d.ts +55 -12
  284. package/dist/sphere3.d.ts.map +1 -1
  285. package/dist/sphere3.js +233 -24
  286. package/dist/sphere3.js.map +1 -1
  287. package/dist/spherical/cap.d.ts +56 -0
  288. package/dist/spherical/cap.d.ts.map +1 -0
  289. package/dist/spherical/cap.js +363 -0
  290. package/dist/spherical/cap.js.map +1 -0
  291. package/dist/spherical/great-circle.d.ts +39 -0
  292. package/dist/spherical/great-circle.d.ts.map +1 -0
  293. package/dist/spherical/great-circle.js +158 -0
  294. package/dist/spherical/great-circle.js.map +1 -0
  295. package/dist/spherical/index.d.ts +3 -0
  296. package/dist/spherical/index.d.ts.map +1 -0
  297. package/dist/spherical/index.js +3 -0
  298. package/dist/spherical/index.js.map +1 -0
  299. package/dist/triangle2-record.d.ts +91 -0
  300. package/dist/triangle2-record.d.ts.map +1 -0
  301. package/dist/triangle2-record.js +146 -0
  302. package/dist/triangle2-record.js.map +1 -0
  303. package/dist/triangle2.d.ts +29 -14
  304. package/dist/triangle2.d.ts.map +1 -1
  305. package/dist/triangle2.js +86 -22
  306. package/dist/triangle2.js.map +1 -1
  307. package/dist/triangle3-record.d.ts +97 -0
  308. package/dist/triangle3-record.d.ts.map +1 -0
  309. package/dist/triangle3-record.js +178 -0
  310. package/dist/triangle3-record.js.map +1 -0
  311. package/dist/triangle3.d.ts +60 -17
  312. package/dist/triangle3.d.ts.map +1 -1
  313. package/dist/triangle3.js +287 -38
  314. package/dist/triangle3.js.map +1 -1
  315. package/package.json +15 -8
  316. package/dist/angles.d.ts +0 -31
  317. package/dist/angles.d.ts.map +0 -1
  318. package/dist/angles.js +0 -53
  319. package/dist/angles.js.map +0 -1
  320. package/dist/coordinate-spaces.d.ts +0 -39
  321. package/dist/coordinate-spaces.d.ts.map +0 -1
  322. package/dist/coordinate-spaces.js +0 -52
  323. package/dist/coordinate-spaces.js.map +0 -1
  324. package/dist/coordinates-vec2.d.ts +0 -7
  325. package/dist/coordinates-vec2.d.ts.map +0 -1
  326. package/dist/coordinates-vec2.js +0 -35
  327. package/dist/coordinates-vec2.js.map +0 -1
  328. package/dist/coordinates-vec3.d.ts +0 -11
  329. package/dist/coordinates-vec3.d.ts.map +0 -1
  330. package/dist/coordinates-vec3.js +0 -61
  331. package/dist/coordinates-vec3.js.map +0 -1
  332. package/dist/coordinates.d.ts +0 -54
  333. package/dist/coordinates.d.ts.map +0 -1
  334. package/dist/coordinates.js +0 -2
  335. package/dist/coordinates.js.map +0 -1
  336. package/dist/euler-angles-quaternion.d.ts +0 -7
  337. package/dist/euler-angles-quaternion.d.ts.map +0 -1
  338. package/dist/euler-angles-quaternion.js +0 -100
  339. package/dist/euler-angles-quaternion.js.map +0 -1
  340. package/dist/euler-angles.d.ts +0 -33
  341. package/dist/euler-angles.d.ts.map +0 -1
  342. package/dist/euler-angles.js +0 -35
  343. package/dist/euler-angles.js.map +0 -1
  344. package/dist/geometry-vectors.d.ts +0 -11
  345. package/dist/geometry-vectors.d.ts.map +0 -1
  346. package/dist/geometry-vectors.js +0 -19
  347. package/dist/geometry-vectors.js.map +0 -1
  348. package/dist/mesh3.d.ts +0 -32
  349. package/dist/mesh3.d.ts.map +0 -1
  350. package/dist/mesh3.js +0 -142
  351. package/dist/mesh3.js.map +0 -1
  352. package/dist/point2.d.ts +0 -41
  353. package/dist/point2.d.ts.map +0 -1
  354. package/dist/point2.js +0 -92
  355. package/dist/point2.js.map +0 -1
  356. package/dist/point3.d.ts +0 -43
  357. package/dist/point3.d.ts.map +0 -1
  358. package/dist/point3.js +0 -103
  359. package/dist/point3.js.map +0 -1
  360. package/dist/point4.d.ts +0 -12
  361. package/dist/point4.d.ts.map +0 -1
  362. package/dist/point4.js +0 -28
  363. package/dist/point4.js.map +0 -1
  364. package/dist/rect2.d.ts +0 -54
  365. package/dist/rect2.d.ts.map +0 -1
  366. package/dist/rect2.js +0 -149
  367. package/dist/rect2.js.map +0 -1
  368. package/dist/size2.d.ts +0 -33
  369. package/dist/size2.d.ts.map +0 -1
  370. package/dist/size2.js +0 -81
  371. package/dist/size2.js.map +0 -1
  372. package/dist/size3.d.ts +0 -21
  373. package/dist/size3.d.ts.map +0 -1
  374. package/dist/size3.js +0 -59
  375. package/dist/size3.js.map +0 -1
  376. package/dist/size4.d.ts +0 -10
  377. package/dist/size4.d.ts.map +0 -1
  378. package/dist/size4.js +0 -16
  379. package/dist/size4.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ import type { ReadonlyBox3, Box3 } from "./box3-record.js";
2
+ /**
3
+ * Creates a buffer for `count` boxes: a zero-filled `Float64Array` of `count ×
4
+ * 6` numbers, element `i` at `[i·6, i·6 + 6)`. Allocates.
5
+ *
6
+ * @throws {RangeError} When `count` is not a non-negative safe integer or
7
+ * `count × 6` is not a valid typed array length.
8
+ */
9
+ export declare function box3ArrayCreate(count: number): Float64Array<ArrayBuffer>;
10
+ /**
11
+ * Writes element `index` of `array`, the numbers at `[index·6, index·6 + 6)`,
12
+ * into `out`. Each component is written as `+array[i]`, so an index past the
13
+ * end of `array` gives `NaN`, never `undefined`: the box stays clean whatever
14
+ * the caller does. Checking the index is the job of the checked layer.
15
+ *
16
+ * The box is copied: it is never a view of `array`. O(1).
17
+ */
18
+ export declare function box3Load(out: Box3, array: Float64Array, index: number): Box3;
19
+ /**
20
+ * Writes `value` into `array` as element `index`, at `[index·6, index·6 + 6)`.
21
+ * An element past the end of `array` writes nothing, as a typed array drops an
22
+ * out-of-range write. O(1).
23
+ */
24
+ export declare function box3Store(array: Float64Array, index: number, value: ReadonlyBox3): void;
25
+ /**
26
+ * Like {@link box3Load} for interleaved data: element `index` starts at `offset +
27
+ * index·stride`, both counted in numbers, and its 6 components follow one
28
+ * another. An index past the end gives `NaN` components. O(1).
29
+ */
30
+ export declare function box3LoadStrided(out: Box3, array: Float64Array, offset: number, stride: number, index: number): Box3;
31
+ /**
32
+ * Like {@link box3Store} for interleaved data: element `index` starts at `offset +
33
+ * index·stride`, both counted in numbers. A component past the end of `array`
34
+ * writes nothing. O(1).
35
+ */
36
+ export declare function box3StoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyBox3): void;
37
+ /**
38
+ * Narrows `value` to binary32 and writes its 6 components into `array` from
39
+ * element `offset` on, unrolled: the way to stage a bounds or instance value
40
+ * for the GPU, where `array.set` costs several times as much for one value. A
41
+ * component past the end of `array` writes nothing. O(1).
42
+ */
43
+ export declare function box3StoreFloat32(array: Float32Array, offset: number, value: ReadonlyBox3): void;
44
+ /**
45
+ * Whether every number of `array` is finite: the check for a buffer of box3
46
+ * elements read from untrusted data or about to be uploaded. The length is not
47
+ * required to be a multiple of 6. O(n).
48
+ */
49
+ export declare function box3ArrayIsFinite(array: Float64Array): boolean;
50
+ //# sourceMappingURL=box3-array-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box3-array-boundary.d.ts","sourceRoot":"","sources":["../src/box3-array-boundary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAGxE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAU5E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACxB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GACjB,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,IAAI,CAUN;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GACjB,IAAI,CAQN;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GACjB,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAU9D"}
@@ -0,0 +1,107 @@
1
+ // Generated from scripts/templates/array-boundary.liquid by scripts/generate-records.ts. Do not edit.
2
+ import { assertInteger } from "@ac-kit/core";
3
+ /**
4
+ * Creates a buffer for `count` boxes: a zero-filled `Float64Array` of `count ×
5
+ * 6` numbers, element `i` at `[i·6, i·6 + 6)`. Allocates.
6
+ *
7
+ * @throws {RangeError} When `count` is not a non-negative safe integer or
8
+ * `count × 6` is not a valid typed array length.
9
+ */
10
+ export function box3ArrayCreate(count) {
11
+ assertInteger(count, "box3ArrayCreate: count", 0);
12
+ return new Float64Array(count * 6);
13
+ }
14
+ /**
15
+ * Writes element `index` of `array`, the numbers at `[index·6, index·6 + 6)`,
16
+ * into `out`. Each component is written as `+array[i]`, so an index past the
17
+ * end of `array` gives `NaN`, never `undefined`: the box stays clean whatever
18
+ * the caller does. Checking the index is the job of the checked layer.
19
+ *
20
+ * The box is copied: it is never a view of `array`. O(1).
21
+ */
22
+ export function box3Load(out, array, index) {
23
+ const base = index * 6;
24
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
25
+ out[0] = +array[base];
26
+ out[1] = +array[base + 1];
27
+ out[2] = +array[base + 2];
28
+ out[3] = +array[base + 3];
29
+ out[4] = +array[base + 4];
30
+ out[5] = +array[base + 5];
31
+ return out;
32
+ }
33
+ /**
34
+ * Writes `value` into `array` as element `index`, at `[index·6, index·6 + 6)`.
35
+ * An element past the end of `array` writes nothing, as a typed array drops an
36
+ * out-of-range write. O(1).
37
+ */
38
+ export function box3Store(array, index, value) {
39
+ const base = index * 6;
40
+ array[base] = value[0];
41
+ array[base + 1] = value[1];
42
+ array[base + 2] = value[2];
43
+ array[base + 3] = value[3];
44
+ array[base + 4] = value[4];
45
+ array[base + 5] = value[5];
46
+ }
47
+ /**
48
+ * Like {@link box3Load} for interleaved data: element `index` starts at `offset +
49
+ * index·stride`, both counted in numbers, and its 6 components follow one
50
+ * another. An index past the end gives `NaN` components. O(1).
51
+ */
52
+ export function box3LoadStrided(out, array, offset, stride, index) {
53
+ const base = offset + index * stride;
54
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
55
+ out[0] = +array[base];
56
+ out[1] = +array[base + 1];
57
+ out[2] = +array[base + 2];
58
+ out[3] = +array[base + 3];
59
+ out[4] = +array[base + 4];
60
+ out[5] = +array[base + 5];
61
+ return out;
62
+ }
63
+ /**
64
+ * Like {@link box3Store} for interleaved data: element `index` starts at `offset +
65
+ * index·stride`, both counted in numbers. A component past the end of `array`
66
+ * writes nothing. O(1).
67
+ */
68
+ export function box3StoreStrided(array, offset, stride, index, value) {
69
+ const base = offset + index * stride;
70
+ array[base] = value[0];
71
+ array[base + 1] = value[1];
72
+ array[base + 2] = value[2];
73
+ array[base + 3] = value[3];
74
+ array[base + 4] = value[4];
75
+ array[base + 5] = value[5];
76
+ }
77
+ /**
78
+ * Narrows `value` to binary32 and writes its 6 components into `array` from
79
+ * element `offset` on, unrolled: the way to stage a bounds or instance value
80
+ * for the GPU, where `array.set` costs several times as much for one value. A
81
+ * component past the end of `array` writes nothing. O(1).
82
+ */
83
+ export function box3StoreFloat32(array, offset, value) {
84
+ array[offset] = value[0];
85
+ array[offset + 1] = value[1];
86
+ array[offset + 2] = value[2];
87
+ array[offset + 3] = value[3];
88
+ array[offset + 4] = value[4];
89
+ array[offset + 5] = value[5];
90
+ }
91
+ /**
92
+ * Whether every number of `array` is finite: the check for a buffer of box3
93
+ * elements read from untrusted data or about to be uploaded. The length is not
94
+ * required to be a multiple of 6. O(n).
95
+ */
96
+ export function box3ArrayIsFinite(array) {
97
+ // A loop, not `array.every(Number.isFinite)`: measured at 0.5–0.7 ms against
98
+ // 4.1 ms per million numbers on Node (the callback is not inlined), and the
99
+ // check runs on every upload of an untrusted buffer.
100
+ for (let index = 0; index < array.length; index++) {
101
+ if (!Number.isFinite(array[index])) {
102
+ return false;
103
+ }
104
+ }
105
+ return true;
106
+ }
107
+ //# sourceMappingURL=box3-array-boundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box3-array-boundary.js","sourceRoot":"","sources":["../src/box3-array-boundary.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAEtG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,aAAa,CAAC,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAS,EAAE,KAAmB,EAAE,KAAa;IACrE,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,mEAAmE;IACnE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC;IACvB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,OAAO,GAAG,CAAC;A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,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACpD,6EAA6E;IAC7E,4EAA4E;IAC5E,qDAAqD;IACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,110 @@
1
+ import type { ReadonlyVec3, Vec3 } from "@ac-kit/math-linear";
2
+ import type { ReadonlyBox3, Box3 } from "./box3-record.js";
3
+ /**
4
+ * Writes the empty box into `out`: `+∞` minima and `−∞` maxima, so that the
5
+ * union with any box is that box and nothing intersects it.
6
+ */
7
+ export declare function box3Empty(out: Box3): Box3;
8
+ /**
9
+ * Writes the box of the given `center` and `size` (the full extent on each
10
+ * axis) into `out`. A negative size gives an empty box.
11
+ */
12
+ export declare function box3FromCenterSize(out: Box3, center: ReadonlyVec3, size: ReadonlyVec3): Box3;
13
+ /** Writes the box spanned by any two opposite corners into `out`. */
14
+ export declare function box3FromCorners(out: Box3, a: ReadonlyVec3, b: ReadonlyVec3): Box3;
15
+ /**
16
+ * Writes the bounds of the 3-number points of `points` into `out`; an empty
17
+ * buffer gives the empty box. A point with a `NaN` component leaves that axis
18
+ * to the other points. O(n).
19
+ *
20
+ * @throws {RangeError} When `points.length` is not a multiple of 3.
21
+ */
22
+ export declare function box3FromPoints(out: Box3, points: Float64Array): Box3;
23
+ /**
24
+ * Like {@link box3FromPoints} for interleaved data: point `i` starts at `offset +
25
+ * i·stride`, both counted in numbers, for `count` points. O(count).
26
+ *
27
+ * @throws {RangeError} When `count` is not a non-negative integer or the last
28
+ * point does not fit in `points`.
29
+ */
30
+ export declare function box3FromPointsStrided(out: Box3, points: Float64Array, offset: number, stride: number, count: number): Box3;
31
+ /**
32
+ * Whether the box has a minimum above its maximum on some axis. `NaN` is not
33
+ * above anything.
34
+ */
35
+ export declare function box3IsEmpty(box: ReadonlyBox3): boolean;
36
+ /**
37
+ * Writes the extent of the box on each axis, `max − min`, into `out`. An empty
38
+ * box gives negative extents.
39
+ */
40
+ export declare function box3Size(out: Vec3, box: ReadonlyBox3): Vec3;
41
+ /**
42
+ * Writes the centre of the box into `out`. An empty box gives `NaN` where a
43
+ * bound is infinite.
44
+ */
45
+ export declare function box3Center(out: Vec3, box: ReadonlyBox3): Vec3;
46
+ /** Whether `point` lies in the box, boundary included. */
47
+ export declare function box3ContainsPoint(box: ReadonlyBox3, point: ReadonlyVec3): boolean;
48
+ /**
49
+ * Whether `inner` lies in the box, boundary included. An empty `inner` is
50
+ * contained in any box.
51
+ */
52
+ export declare function box3ContainsBox3(box: ReadonlyBox3, inner: ReadonlyBox3): boolean;
53
+ /**
54
+ * Whether the two boxes share a point, boundaries included. An empty box (an
55
+ * inverted axis) intersects nothing.
56
+ */
57
+ export declare function box3IntersectsBox3(a: ReadonlyBox3, b: ReadonlyBox3): boolean;
58
+ /**
59
+ * Writes the common part of two boxes into `out`; disjoint boxes give an empty
60
+ * box ({@link box3IsEmpty}).
61
+ */
62
+ export declare function box3Intersection(out: Box3, a: ReadonlyBox3, b: ReadonlyBox3): Box3;
63
+ /**
64
+ * Writes the smallest box holding both boxes into `out`; an empty box (an
65
+ * inverted axis) adds nothing, and two empty boxes give {@link box3Empty}. `out`
66
+ * may be `a` or `b`.
67
+ */
68
+ export declare function box3Union(out: Box3, a: ReadonlyBox3, b: ReadonlyBox3): Box3;
69
+ /** Writes the smallest box holding `box` and `point` into `out`. */
70
+ export declare function box3ExpandByPoint(out: Box3, box: ReadonlyBox3, point: ReadonlyVec3): Box3;
71
+ /**
72
+ * Writes `box` grown by `margin` on every side into `out`; a negative margin
73
+ * insets and may empty the box.
74
+ */
75
+ export declare function box3ExpandByScalar(out: Box3, box: ReadonlyBox3, margin: number): Box3;
76
+ /** Writes `box` moved by `offset` into `out`. */
77
+ export declare function box3Translate(out: Box3, box: ReadonlyBox3, offset: ReadonlyVec3): Box3;
78
+ /**
79
+ * Writes the point of the box nearest to `point` into `out`; `out` may be
80
+ * `point`. An empty box gives an unspecified point.
81
+ */
82
+ export declare function box3ClampPoint(out: Vec3, box: ReadonlyBox3, point: ReadonlyVec3): Vec3;
83
+ /** The distance from `point` to the box: `0` inside or on it. */
84
+ export declare function box3DistanceToPoint(box: ReadonlyBox3, point: ReadonlyVec3): number;
85
+ /**
86
+ * Writes the bounds interpolated from `a` (`t = 0`) to `b` (`t = 1`, exact)
87
+ * into `out`. Not math-scalar's `lerp`, which is `a + (b − a)·t` and misses `b`
88
+ * by rounding at `t = 1`.
89
+ */
90
+ export declare function box3Lerp(out: Box3, a: ReadonlyBox3, b: ReadonlyBox3, t: number): Box3;
91
+ /**
92
+ * Writes the coordinates of `point` inside the box, `0` at the minimum corner
93
+ * and `1` at the maximum, into `out`: the inverse of {@link box3PointAt}. A flat
94
+ * axis gives non-finite coordinates.
95
+ */
96
+ export declare function box3Parameter(out: Vec3, box: ReadonlyBox3, point: ReadonlyVec3): Vec3;
97
+ /**
98
+ * Writes the point of the box at `parameter` (`0` at the minimum corner, `1` at
99
+ * the maximum) into `out`.
100
+ */
101
+ export declare function box3PointAt(out: Vec3, box: ReadonlyBox3, parameter: ReadonlyVec3): Vec3;
102
+ /**
103
+ * Writes the union of every box of `boxes` (6 numbers each) into `out`; an
104
+ * empty buffer, or one of empty (inverted) boxes only, gives the empty box.
105
+ * O(n).
106
+ *
107
+ * @throws {RangeError} When `boxes.length` is not a multiple of 6.
108
+ */
109
+ export declare function box3ArrayUnion(out: Box3, boxes: Float64Array): Box3;
110
+ //# sourceMappingURL=box3-componentwise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box3-componentwise.d.ts","sourceRoot":"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,IAAI,CAKN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,GACrB,IAAI,CAKN;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAmCnE"}
@@ -0,0 +1,392 @@
1
+ // Generated from scripts/templates/box-componentwise.liquid by scripts/generate-records.ts. Do not edit.
2
+ import { inverseLerp, lerp } from "@ac-kit/math-scalar";
3
+ /**
4
+ * Writes the empty box into `out`: `+∞` minima and `−∞` maxima, so that the
5
+ * union with any box is that box and nothing intersects it.
6
+ */
7
+ export function box3Empty(out) {
8
+ out[0] = Number.POSITIVE_INFINITY;
9
+ out[1] = Number.POSITIVE_INFINITY;
10
+ out[2] = Number.POSITIVE_INFINITY;
11
+ out[3] = Number.NEGATIVE_INFINITY;
12
+ out[4] = Number.NEGATIVE_INFINITY;
13
+ out[5] = Number.NEGATIVE_INFINITY;
14
+ return out;
15
+ }
16
+ /**
17
+ * Writes the box of the given `center` and `size` (the full extent on each
18
+ * axis) into `out`. A negative size gives an empty box.
19
+ */
20
+ export function box3FromCenterSize(out, center, size) {
21
+ out[0] = center[0] - size[0] / 2;
22
+ out[3] = center[0] + size[0] / 2;
23
+ out[1] = center[1] - size[1] / 2;
24
+ out[4] = center[1] + size[1] / 2;
25
+ out[2] = center[2] - size[2] / 2;
26
+ out[5] = center[2] + size[2] / 2;
27
+ return out;
28
+ }
29
+ /** Writes the box spanned by any two opposite corners into `out`. */
30
+ export function box3FromCorners(out, a, b) {
31
+ out[0] = Math.min(a[0], b[0]);
32
+ out[3] = Math.max(a[0], b[0]);
33
+ out[1] = Math.min(a[1], b[1]);
34
+ out[4] = Math.max(a[1], b[1]);
35
+ out[2] = Math.min(a[2], b[2]);
36
+ out[5] = Math.max(a[2], b[2]);
37
+ return out;
38
+ }
39
+ /**
40
+ * Writes the bounds of the 3-number points of `points` into `out`; an empty
41
+ * buffer gives the empty box. A point with a `NaN` component leaves that axis
42
+ * to the other points. O(n).
43
+ *
44
+ * @throws {RangeError} When `points.length` is not a multiple of 3.
45
+ */
46
+ export function box3FromPoints(out, points) {
47
+ const length = points.length;
48
+ if (length % 3 !== 0) {
49
+ throw new RangeError(`box3FromPoints: points has ${length} numbers, not a multiple of 3.`);
50
+ }
51
+ let min0 = Number.POSITIVE_INFINITY;
52
+ let max0 = Number.NEGATIVE_INFINITY;
53
+ let min1 = Number.POSITIVE_INFINITY;
54
+ let max1 = Number.NEGATIVE_INFINITY;
55
+ let min2 = Number.POSITIVE_INFINITY;
56
+ let max2 = Number.NEGATIVE_INFINITY;
57
+ for (let index = 0; index < length; index += 3) {
58
+ const value0 = points[index];
59
+ if (value0 < min0) {
60
+ min0 = value0;
61
+ }
62
+ if (value0 > max0) {
63
+ max0 = value0;
64
+ }
65
+ const value1 = points[index + 1];
66
+ if (value1 < min1) {
67
+ min1 = value1;
68
+ }
69
+ if (value1 > max1) {
70
+ max1 = value1;
71
+ }
72
+ const value2 = points[index + 2];
73
+ if (value2 < min2) {
74
+ min2 = value2;
75
+ }
76
+ if (value2 > max2) {
77
+ max2 = value2;
78
+ }
79
+ }
80
+ out[0] = min0;
81
+ out[3] = max0;
82
+ out[1] = min1;
83
+ out[4] = max1;
84
+ out[2] = min2;
85
+ out[5] = max2;
86
+ return out;
87
+ }
88
+ /**
89
+ * Like {@link box3FromPoints} for interleaved data: point `i` starts at `offset +
90
+ * i·stride`, both counted in numbers, for `count` points. O(count).
91
+ *
92
+ * @throws {RangeError} When `count` is not a non-negative integer or the last
93
+ * point does not fit in `points`.
94
+ */
95
+ export function box3FromPointsStrided(out, points, offset, stride, count) {
96
+ if (!Number.isInteger(count) ||
97
+ count < 0 ||
98
+ (count > 0 &&
99
+ !(offset >= 0 &&
100
+ stride >= 0 &&
101
+ offset + (count - 1) * stride + 3 <= points.length))) {
102
+ throw new RangeError(`box3FromPointsStrided: ${count} points at offset ${offset} and stride ${stride} do not fit in ${points.length} numbers.`);
103
+ }
104
+ let min0 = Number.POSITIVE_INFINITY;
105
+ let max0 = Number.NEGATIVE_INFINITY;
106
+ let min1 = Number.POSITIVE_INFINITY;
107
+ let max1 = Number.NEGATIVE_INFINITY;
108
+ let min2 = Number.POSITIVE_INFINITY;
109
+ let max2 = Number.NEGATIVE_INFINITY;
110
+ for (let point = 0, index = offset; point < count; point++, index += stride) {
111
+ const value0 = points[index];
112
+ if (value0 < min0) {
113
+ min0 = value0;
114
+ }
115
+ if (value0 > max0) {
116
+ max0 = value0;
117
+ }
118
+ const value1 = points[index + 1];
119
+ if (value1 < min1) {
120
+ min1 = value1;
121
+ }
122
+ if (value1 > max1) {
123
+ max1 = value1;
124
+ }
125
+ const value2 = points[index + 2];
126
+ if (value2 < min2) {
127
+ min2 = value2;
128
+ }
129
+ if (value2 > max2) {
130
+ max2 = value2;
131
+ }
132
+ }
133
+ out[0] = min0;
134
+ out[3] = max0;
135
+ out[1] = min1;
136
+ out[4] = max1;
137
+ out[2] = min2;
138
+ out[5] = max2;
139
+ return out;
140
+ }
141
+ /**
142
+ * Whether the box has a minimum above its maximum on some axis. `NaN` is not
143
+ * above anything.
144
+ */
145
+ export function box3IsEmpty(box) {
146
+ return box[0] > box[3] || box[1] > box[4] || box[2] > box[5];
147
+ }
148
+ /**
149
+ * Writes the extent of the box on each axis, `max − min`, into `out`. An empty
150
+ * box gives negative extents.
151
+ */
152
+ export function box3Size(out, box) {
153
+ out[0] = box[3] - box[0];
154
+ out[1] = box[4] - box[1];
155
+ out[2] = box[5] - box[2];
156
+ return out;
157
+ }
158
+ /**
159
+ * Writes the centre of the box into `out`. An empty box gives `NaN` where a
160
+ * bound is infinite.
161
+ */
162
+ export function box3Center(out, box) {
163
+ out[0] = (box[0] + box[3]) / 2;
164
+ out[1] = (box[1] + box[4]) / 2;
165
+ out[2] = (box[2] + box[5]) / 2;
166
+ return out;
167
+ }
168
+ /** Whether `point` lies in the box, boundary included. */
169
+ export function box3ContainsPoint(box, point) {
170
+ return (point[0] >= box[0] &&
171
+ point[0] <= box[3] &&
172
+ point[1] >= box[1] &&
173
+ point[1] <= box[4] &&
174
+ point[2] >= box[2] &&
175
+ point[2] <= box[5]);
176
+ }
177
+ /**
178
+ * Whether `inner` lies in the box, boundary included. An empty `inner` is
179
+ * contained in any box.
180
+ */
181
+ export function box3ContainsBox3(box, inner) {
182
+ return (box3IsEmpty(inner) ||
183
+ (inner[0] >= box[0] &&
184
+ inner[3] <= box[3] &&
185
+ inner[1] >= box[1] &&
186
+ inner[4] <= box[4] &&
187
+ inner[2] >= box[2] &&
188
+ inner[5] <= box[5]));
189
+ }
190
+ /**
191
+ * Whether the two boxes share a point, boundaries included. An empty box (an
192
+ * inverted axis) intersects nothing.
193
+ */
194
+ export function box3IntersectsBox3(a, b) {
195
+ return (a[0] <= a[3] &&
196
+ b[0] <= b[3] &&
197
+ a[0] <= b[3] &&
198
+ b[0] <= a[3] &&
199
+ a[1] <= a[4] &&
200
+ b[1] <= b[4] &&
201
+ a[1] <= b[4] &&
202
+ b[1] <= a[4] &&
203
+ a[2] <= a[5] &&
204
+ b[2] <= b[5] &&
205
+ a[2] <= b[5] &&
206
+ b[2] <= a[5]);
207
+ }
208
+ /**
209
+ * Writes the common part of two boxes into `out`; disjoint boxes give an empty
210
+ * box ({@link box3IsEmpty}).
211
+ */
212
+ export function box3Intersection(out, a, b) {
213
+ out[0] = Math.max(a[0], b[0]);
214
+ out[3] = Math.min(a[3], b[3]);
215
+ out[1] = Math.max(a[1], b[1]);
216
+ out[4] = Math.min(a[4], b[4]);
217
+ out[2] = Math.max(a[2], b[2]);
218
+ out[5] = Math.min(a[5], b[5]);
219
+ return out;
220
+ }
221
+ /**
222
+ * Writes the smallest box holding both boxes into `out`; an empty box (an
223
+ * inverted axis) adds nothing, and two empty boxes give {@link box3Empty}. `out`
224
+ * may be `a` or `b`.
225
+ */
226
+ export function box3Union(out, a, b) {
227
+ if (box3IsEmpty(a)) {
228
+ if (box3IsEmpty(b)) {
229
+ return box3Empty(out);
230
+ }
231
+ out[0] = b[0];
232
+ out[3] = b[3];
233
+ out[1] = b[1];
234
+ out[4] = b[4];
235
+ out[2] = b[2];
236
+ out[5] = b[5];
237
+ return out;
238
+ }
239
+ if (box3IsEmpty(b)) {
240
+ out[0] = a[0];
241
+ out[3] = a[3];
242
+ out[1] = a[1];
243
+ out[4] = a[4];
244
+ out[2] = a[2];
245
+ out[5] = a[5];
246
+ return out;
247
+ }
248
+ out[0] = Math.min(a[0], b[0]);
249
+ out[3] = Math.max(a[3], b[3]);
250
+ out[1] = Math.min(a[1], b[1]);
251
+ out[4] = Math.max(a[4], b[4]);
252
+ out[2] = Math.min(a[2], b[2]);
253
+ out[5] = Math.max(a[5], b[5]);
254
+ return out;
255
+ }
256
+ /** Writes the smallest box holding `box` and `point` into `out`. */
257
+ export function box3ExpandByPoint(out, box, point) {
258
+ out[0] = Math.min(box[0], point[0]);
259
+ out[3] = Math.max(box[3], point[0]);
260
+ out[1] = Math.min(box[1], point[1]);
261
+ out[4] = Math.max(box[4], point[1]);
262
+ out[2] = Math.min(box[2], point[2]);
263
+ out[5] = Math.max(box[5], point[2]);
264
+ return out;
265
+ }
266
+ /**
267
+ * Writes `box` grown by `margin` on every side into `out`; a negative margin
268
+ * insets and may empty the box.
269
+ */
270
+ export function box3ExpandByScalar(out, box, margin) {
271
+ out[0] = box[0] - margin;
272
+ out[3] = box[3] + margin;
273
+ out[1] = box[1] - margin;
274
+ out[4] = box[4] + margin;
275
+ out[2] = box[2] - margin;
276
+ out[5] = box[5] + margin;
277
+ return out;
278
+ }
279
+ /** Writes `box` moved by `offset` into `out`. */
280
+ export function box3Translate(out, box, offset) {
281
+ out[0] = box[0] + offset[0];
282
+ out[3] = box[3] + offset[0];
283
+ out[1] = box[1] + offset[1];
284
+ out[4] = box[4] + offset[1];
285
+ out[2] = box[2] + offset[2];
286
+ out[5] = box[5] + offset[2];
287
+ return out;
288
+ }
289
+ /**
290
+ * Writes the point of the box nearest to `point` into `out`; `out` may be
291
+ * `point`. An empty box gives an unspecified point.
292
+ */
293
+ export function box3ClampPoint(out, box, point) {
294
+ out[0] = Math.min(Math.max(point[0], box[0]), box[3]);
295
+ out[1] = Math.min(Math.max(point[1], box[1]), box[4]);
296
+ out[2] = Math.min(Math.max(point[2], box[2]), box[5]);
297
+ return out;
298
+ }
299
+ /** The distance from `point` to the box: `0` inside or on it. */
300
+ export function box3DistanceToPoint(box, point) {
301
+ const delta0 = Math.max(box[0] - point[0], 0, point[0] - box[3]);
302
+ const delta1 = Math.max(box[1] - point[1], 0, point[1] - box[4]);
303
+ const delta2 = Math.max(box[2] - point[2], 0, point[2] - box[5]);
304
+ return Math.sqrt(delta0 * delta0 + delta1 * delta1 + delta2 * delta2);
305
+ }
306
+ /**
307
+ * Writes the bounds interpolated from `a` (`t = 0`) to `b` (`t = 1`, exact)
308
+ * into `out`. Not math-scalar's `lerp`, which is `a + (b − a)·t` and misses `b`
309
+ * by rounding at `t = 1`.
310
+ */
311
+ export function box3Lerp(out, a, b, t) {
312
+ // The endpoints are copied: the blend below would give `NaN` for an empty
313
+ // box (`0 · ∞`) and turn `−0` into `+0`.
314
+ if (t === 0 || t === 1) {
315
+ const source = t === 0 ? a : b;
316
+ out[0] = source[0];
317
+ out[3] = source[3];
318
+ out[1] = source[1];
319
+ out[4] = source[4];
320
+ out[2] = source[2];
321
+ out[5] = source[5];
322
+ return out;
323
+ }
324
+ out[0] = a[0] * (1 - t) + b[0] * t;
325
+ out[3] = a[3] * (1 - t) + b[3] * t;
326
+ out[1] = a[1] * (1 - t) + b[1] * t;
327
+ out[4] = a[4] * (1 - t) + b[4] * t;
328
+ out[2] = a[2] * (1 - t) + b[2] * t;
329
+ out[5] = a[5] * (1 - t) + b[5] * t;
330
+ return out;
331
+ }
332
+ /**
333
+ * Writes the coordinates of `point` inside the box, `0` at the minimum corner
334
+ * and `1` at the maximum, into `out`: the inverse of {@link box3PointAt}. A flat
335
+ * axis gives non-finite coordinates.
336
+ */
337
+ export function box3Parameter(out, box, point) {
338
+ out[0] = inverseLerp(box[0], box[3], point[0]);
339
+ out[1] = inverseLerp(box[1], box[4], point[1]);
340
+ out[2] = inverseLerp(box[2], box[5], point[2]);
341
+ return out;
342
+ }
343
+ /**
344
+ * Writes the point of the box at `parameter` (`0` at the minimum corner, `1` at
345
+ * the maximum) into `out`.
346
+ */
347
+ export function box3PointAt(out, box, parameter) {
348
+ out[0] = lerp(box[0], box[3], parameter[0]);
349
+ out[1] = lerp(box[1], box[4], parameter[1]);
350
+ out[2] = lerp(box[2], box[5], parameter[2]);
351
+ return out;
352
+ }
353
+ /**
354
+ * Writes the union of every box of `boxes` (6 numbers each) into `out`; an
355
+ * empty buffer, or one of empty (inverted) boxes only, gives the empty box.
356
+ * O(n).
357
+ *
358
+ * @throws {RangeError} When `boxes.length` is not a multiple of 6.
359
+ */
360
+ export function box3ArrayUnion(out, boxes) {
361
+ const length = boxes.length;
362
+ if (length % 6 !== 0) {
363
+ throw new RangeError(`box3ArrayUnion: boxes has ${length} numbers, not a multiple of 6.`);
364
+ }
365
+ let min0 = Number.POSITIVE_INFINITY;
366
+ let max0 = Number.NEGATIVE_INFINITY;
367
+ let min1 = Number.POSITIVE_INFINITY;
368
+ let max1 = Number.NEGATIVE_INFINITY;
369
+ let min2 = Number.POSITIVE_INFINITY;
370
+ let max2 = Number.NEGATIVE_INFINITY;
371
+ for (let index = 0; index < length; index += 6) {
372
+ if (boxes[index] > boxes[index + 3] ||
373
+ boxes[index + 1] > boxes[index + 4] ||
374
+ boxes[index + 2] > boxes[index + 5]) {
375
+ continue;
376
+ }
377
+ min0 = Math.min(min0, boxes[index]);
378
+ max0 = Math.max(max0, boxes[index + 3]);
379
+ min1 = Math.min(min1, boxes[index + 1]);
380
+ max1 = Math.max(max1, boxes[index + 4]);
381
+ min2 = Math.min(min2, boxes[index + 2]);
382
+ max2 = Math.max(max2, boxes[index + 5]);
383
+ }
384
+ out[0] = min0;
385
+ out[3] = max0;
386
+ out[1] = min1;
387
+ out[4] = max1;
388
+ out[2] = min2;
389
+ out[5] = max2;
390
+ return out;
391
+ }
392
+ //# sourceMappingURL=box3-componentwise.js.map