@pmndrs/vdb 0.0.0-stage → 0.2.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 (570) hide show
  1. package/CHANGELOG.md +727 -0
  2. package/LICENSE +21 -0
  3. package/README.md +496 -2
  4. package/THIRD_PARTY_NOTICES.md +315 -0
  5. package/dist/core/compute/atlas.d.ts +102 -0
  6. package/dist/core/compute/atlas.js +103 -0
  7. package/dist/core/compute/atlas.js.map +1 -0
  8. package/dist/core/compute/index.d.ts +13 -0
  9. package/dist/core/compute/index.js +9 -0
  10. package/dist/core/compute/index.js.map +1 -0
  11. package/dist/core/compute/majorant-build.d.ts +45 -0
  12. package/dist/core/compute/majorant-build.js +193 -0
  13. package/dist/core/compute/majorant-build.js.map +1 -0
  14. package/dist/core/compute/multi-scale.d.ts +155 -0
  15. package/dist/core/compute/multi-scale.js +684 -0
  16. package/dist/core/compute/multi-scale.js.map +1 -0
  17. package/dist/core/compute/pyramid.d.ts +120 -0
  18. package/dist/core/compute/pyramid.js +468 -0
  19. package/dist/core/compute/pyramid.js.map +1 -0
  20. package/dist/core/compute/shared.d.ts +116 -0
  21. package/dist/core/compute/shared.js +211 -0
  22. package/dist/core/compute/shared.js.map +1 -0
  23. package/dist/core/compute/stats.d.ts +78 -0
  24. package/dist/core/compute/stats.js +193 -0
  25. package/dist/core/compute/stats.js.map +1 -0
  26. package/dist/core/compute/value-transform.d.ts +30 -0
  27. package/dist/core/compute/value-transform.js +64 -0
  28. package/dist/core/compute/value-transform.js.map +1 -0
  29. package/dist/core/errors.d.ts +21 -0
  30. package/dist/core/errors.js +17 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/frame/emission.d.ts +85 -0
  33. package/dist/core/frame/emission.js +422 -0
  34. package/dist/core/frame/emission.js.map +1 -0
  35. package/dist/core/frame/environment.d.ts +47 -0
  36. package/dist/core/frame/environment.js +178 -0
  37. package/dist/core/frame/environment.js.map +1 -0
  38. package/dist/core/frame/index.d.ts +39 -0
  39. package/dist/core/frame/index.js +27 -0
  40. package/dist/core/frame/index.js.map +1 -0
  41. package/dist/core/frame/kernels.d.ts +115 -0
  42. package/dist/core/frame/kernels.js +496 -0
  43. package/dist/core/frame/kernels.js.map +1 -0
  44. package/dist/core/frame/limits.d.ts +67 -0
  45. package/dist/core/frame/limits.js +109 -0
  46. package/dist/core/frame/limits.js.map +1 -0
  47. package/dist/core/frame/phase.d.ts +17 -0
  48. package/dist/core/frame/phase.js +53 -0
  49. package/dist/core/frame/phase.js.map +1 -0
  50. package/dist/core/frame/pipelines.d.ts +49 -0
  51. package/dist/core/frame/pipelines.js +147 -0
  52. package/dist/core/frame/pipelines.js.map +1 -0
  53. package/dist/core/frame/renderer.d.ts +122 -0
  54. package/dist/core/frame/renderer.js +1712 -0
  55. package/dist/core/frame/renderer.js.map +1 -0
  56. package/dist/core/frame/resources.d.ts +71 -0
  57. package/dist/core/frame/resources.js +100 -0
  58. package/dist/core/frame/resources.js.map +1 -0
  59. package/dist/core/frame/scattering.d.ts +97 -0
  60. package/dist/core/frame/scattering.js +332 -0
  61. package/dist/core/frame/scattering.js.map +1 -0
  62. package/dist/core/frame/settings.d.ts +243 -0
  63. package/dist/core/frame/settings.js +67 -0
  64. package/dist/core/frame/settings.js.map +1 -0
  65. package/dist/core/frame/shadows.d.ts +55 -0
  66. package/dist/core/frame/shadows.js +460 -0
  67. package/dist/core/frame/shadows.js.map +1 -0
  68. package/dist/core/frame/types.d.ts +415 -0
  69. package/dist/core/frame/types.js +49 -0
  70. package/dist/core/frame/types.js.map +1 -0
  71. package/dist/core/frame/uniforms.d.ts +105 -0
  72. package/dist/core/frame/uniforms.js +276 -0
  73. package/dist/core/frame/uniforms.js.map +1 -0
  74. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  75. package/dist/core/frame/wgsl/chunks.js +728 -0
  76. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  77. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  78. package/dist/core/frame/wgsl/emission.js +353 -0
  79. package/dist/core/frame/wgsl/emission.js.map +1 -0
  80. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  81. package/dist/core/frame/wgsl/environment.js +711 -0
  82. package/dist/core/frame/wgsl/environment.js.map +1 -0
  83. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  84. package/dist/core/frame/wgsl/gather.js +850 -0
  85. package/dist/core/frame/wgsl/gather.js.map +1 -0
  86. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  87. package/dist/core/frame/wgsl/integrate.js +213 -0
  88. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  89. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  90. package/dist/core/frame/wgsl/lighting.js +1636 -0
  91. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  92. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  93. package/dist/core/frame/wgsl/occluders.js +95 -0
  94. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  95. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  96. package/dist/core/frame/wgsl/resolve.js +205 -0
  97. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  98. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  99. package/dist/core/frame/wgsl/shadows.js +328 -0
  100. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  101. package/dist/core/half.d.ts +11 -0
  102. package/dist/core/half.js +22 -0
  103. package/dist/core/half.js.map +1 -0
  104. package/dist/core/index.d.ts +52 -0
  105. package/dist/core/index.js +46 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/internal.d.ts +31 -0
  108. package/dist/core/internal.js +32 -0
  109. package/dist/core/internal.js.map +1 -0
  110. package/dist/core/pool/affine.d.ts +34 -0
  111. package/dist/core/pool/affine.js +100 -0
  112. package/dist/core/pool/affine.js.map +1 -0
  113. package/dist/core/pool/allocator.d.ts +32 -0
  114. package/dist/core/pool/allocator.js +81 -0
  115. package/dist/core/pool/allocator.js.map +1 -0
  116. package/dist/core/pool/image-header.d.ts +93 -0
  117. package/dist/core/pool/image-header.js +194 -0
  118. package/dist/core/pool/image-header.js.map +1 -0
  119. package/dist/core/pool/layout.d.ts +198 -0
  120. package/dist/core/pool/layout.js +316 -0
  121. package/dist/core/pool/layout.js.map +1 -0
  122. package/dist/core/pool/limits.d.ts +41 -0
  123. package/dist/core/pool/limits.js +80 -0
  124. package/dist/core/pool/limits.js.map +1 -0
  125. package/dist/core/pool/pool.d.ts +384 -0
  126. package/dist/core/pool/pool.js +1184 -0
  127. package/dist/core/pool/pool.js.map +1 -0
  128. package/dist/core/reference/index.d.ts +6 -0
  129. package/dist/core/reference/index.js +7 -0
  130. package/dist/core/reference/index.js.map +1 -0
  131. package/dist/core/reference/renderer.d.ts +105 -0
  132. package/dist/core/reference/renderer.js +474 -0
  133. package/dist/core/reference/renderer.js.map +1 -0
  134. package/dist/core/reference/wgsl.d.ts +65 -0
  135. package/dist/core/reference/wgsl.js +803 -0
  136. package/dist/core/reference/wgsl.js.map +1 -0
  137. package/dist/core/sequence.d.ts +347 -0
  138. package/dist/core/sequence.js +548 -0
  139. package/dist/core/sequence.js.map +1 -0
  140. package/dist/core/source/brick-cache.d.ts +165 -0
  141. package/dist/core/source/brick-cache.js +627 -0
  142. package/dist/core/source/brick-cache.js.map +1 -0
  143. package/dist/core/source/dense-fill.d.ts +53 -0
  144. package/dist/core/source/dense-fill.js +377 -0
  145. package/dist/core/source/dense-fill.js.map +1 -0
  146. package/dist/core/source/dense.d.ts +50 -0
  147. package/dist/core/source/dense.js +384 -0
  148. package/dist/core/source/dense.js.map +1 -0
  149. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  150. package/dist/core/source/sparse-wgsl.js +481 -0
  151. package/dist/core/source/sparse-wgsl.js.map +1 -0
  152. package/dist/core/source/sparse.d.ts +192 -0
  153. package/dist/core/source/sparse.js +762 -0
  154. package/dist/core/source/sparse.js.map +1 -0
  155. package/dist/core/source/types.d.ts +120 -0
  156. package/dist/core/source/types.js +9 -0
  157. package/dist/core/source/types.js.map +1 -0
  158. package/dist/core/surface/index.d.ts +10 -0
  159. package/dist/core/surface/index.js +9 -0
  160. package/dist/core/surface/index.js.map +1 -0
  161. package/dist/core/surface/level-set-pass.d.ts +140 -0
  162. package/dist/core/surface/level-set-pass.js +291 -0
  163. package/dist/core/surface/level-set-pass.js.map +1 -0
  164. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  165. package/dist/core/surface/level-set-wgsl.js +99 -0
  166. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  167. package/dist/core/surface/points.d.ts +109 -0
  168. package/dist/core/surface/points.js +226 -0
  169. package/dist/core/surface/points.js.map +1 -0
  170. package/dist/core/types.d.ts +37 -0
  171. package/dist/core/types.js +32 -0
  172. package/dist/core/types.js.map +1 -0
  173. package/dist/core/wgsl/api.d.ts +65 -0
  174. package/dist/core/wgsl/api.js +546 -0
  175. package/dist/core/wgsl/api.js.map +1 -0
  176. package/dist/core/wgsl/generate.d.ts +90 -0
  177. package/dist/core/wgsl/generate.js +678 -0
  178. package/dist/core/wgsl/generate.js.map +1 -0
  179. package/dist/core/wgsl/lean.d.ts +50 -0
  180. package/dist/core/wgsl/lean.js +327 -0
  181. package/dist/core/wgsl/lean.js.map +1 -0
  182. package/dist/core/wgsl/level-set.d.ts +58 -0
  183. package/dist/core/wgsl/level-set.js +200 -0
  184. package/dist/core/wgsl/level-set.js.map +1 -0
  185. package/dist/core/wgsl/majorant.d.ts +62 -0
  186. package/dist/core/wgsl/majorant.js +381 -0
  187. package/dist/core/wgsl/majorant.js.map +1 -0
  188. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  189. package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
  190. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  191. package/dist/core/wgsl/reserved.d.ts +9 -0
  192. package/dist/core/wgsl/reserved.js +26 -0
  193. package/dist/core/wgsl/reserved.js.map +1 -0
  194. package/dist/core/wgsl/types.d.ts +198 -0
  195. package/dist/core/wgsl/types.js +2 -0
  196. package/dist/core/wgsl/types.js.map +1 -0
  197. package/dist/three/coarse-first.d.ts +207 -0
  198. package/dist/three/coarse-first.js +205 -0
  199. package/dist/three/coarse-first.js.map +1 -0
  200. package/dist/three/compute.d.ts +73 -0
  201. package/dist/three/compute.js +66 -0
  202. package/dist/three/compute.js.map +1 -0
  203. package/dist/three/device.d.ts +66 -0
  204. package/dist/three/device.js +62 -0
  205. package/dist/three/device.js.map +1 -0
  206. package/dist/three/frame/core-environment.d.ts +38 -0
  207. package/dist/three/frame/core-environment.js +154 -0
  208. package/dist/three/frame/core-environment.js.map +1 -0
  209. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  210. package/dist/three/frame/core-integrate-material.js +162 -0
  211. package/dist/three/frame/core-integrate-material.js.map +1 -0
  212. package/dist/three/frame/core-occluders.d.ts +53 -0
  213. package/dist/three/frame/core-occluders.js +193 -0
  214. package/dist/three/frame/core-occluders.js.map +1 -0
  215. package/dist/three/frame/core-structs.d.ts +34 -0
  216. package/dist/three/frame/core-structs.js +61 -0
  217. package/dist/three/frame/core-structs.js.map +1 -0
  218. package/dist/three/frame/core-textures.d.ts +41 -0
  219. package/dist/three/frame/core-textures.js +114 -0
  220. package/dist/three/frame/core-textures.js.map +1 -0
  221. package/dist/three/frame/emission-light.d.ts +117 -0
  222. package/dist/three/frame/emission-light.js +276 -0
  223. package/dist/three/frame/emission-light.js.map +1 -0
  224. package/dist/three/frame/index.d.ts +19 -0
  225. package/dist/three/frame/index.js +15 -0
  226. package/dist/three/frame/index.js.map +1 -0
  227. package/dist/three/frame/medium.d.ts +33 -0
  228. package/dist/three/frame/medium.js +29 -0
  229. package/dist/three/frame/medium.js.map +1 -0
  230. package/dist/three/frame/renderer.d.ts +97 -0
  231. package/dist/three/frame/renderer.js +480 -0
  232. package/dist/three/frame/renderer.js.map +1 -0
  233. package/dist/three/frame/spectrum.d.ts +4 -0
  234. package/dist/three/frame/spectrum.js +15 -0
  235. package/dist/three/frame/spectrum.js.map +1 -0
  236. package/dist/three/frame/three-internals.d.ts +60 -0
  237. package/dist/three/frame/three-internals.js +152 -0
  238. package/dist/three/frame/three-internals.js.map +1 -0
  239. package/dist/three/frame/volume-shadows.d.ts +139 -0
  240. package/dist/three/frame/volume-shadows.js +403 -0
  241. package/dist/three/frame/volume-shadows.js.map +1 -0
  242. package/dist/three/frame/volume.d.ts +230 -0
  243. package/dist/three/frame/volume.js +268 -0
  244. package/dist/three/frame/volume.js.map +1 -0
  245. package/dist/three/grid-node.d.ts +229 -0
  246. package/dist/three/grid-node.js +545 -0
  247. package/dist/three/grid-node.js.map +1 -0
  248. package/dist/three/index.d.ts +52 -0
  249. package/dist/three/index.js +58 -0
  250. package/dist/three/index.js.map +1 -0
  251. package/dist/three/internal.d.ts +20 -0
  252. package/dist/three/internal.js +18 -0
  253. package/dist/three/internal.js.map +1 -0
  254. package/dist/three/level-set-material.d.ts +185 -0
  255. package/dist/three/level-set-material.js +241 -0
  256. package/dist/three/level-set-material.js.map +1 -0
  257. package/dist/three/level-set-physical-material.d.ts +154 -0
  258. package/dist/three/level-set-physical-material.js +253 -0
  259. package/dist/three/level-set-physical-material.js.map +1 -0
  260. package/dist/three/level-set-velocity.d.ts +94 -0
  261. package/dist/three/level-set-velocity.js +208 -0
  262. package/dist/three/level-set-velocity.js.map +1 -0
  263. package/dist/three/material.d.ts +324 -0
  264. package/dist/three/material.js +502 -0
  265. package/dist/three/material.js.map +1 -0
  266. package/dist/three/points.d.ts +140 -0
  267. package/dist/three/points.js +261 -0
  268. package/dist/three/points.js.map +1 -0
  269. package/dist/three/sparse-source.d.ts +165 -0
  270. package/dist/three/sparse-source.js +405 -0
  271. package/dist/three/sparse-source.js.map +1 -0
  272. package/dist/three/volume-source.d.ts +22 -0
  273. package/dist/three/volume-source.js +110 -0
  274. package/dist/three/volume-source.js.map +1 -0
  275. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  276. package/dist/tools/cpu/brick-atlas.js +129 -0
  277. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  278. package/dist/tools/cpu/compute.d.ts +116 -0
  279. package/dist/tools/cpu/compute.js +239 -0
  280. package/dist/tools/cpu/compute.js.map +1 -0
  281. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  282. package/dist/tools/cpu/lean-reads.js +262 -0
  283. package/dist/tools/cpu/lean-reads.js.map +1 -0
  284. package/dist/tools/cpu/level-set.d.ts +111 -0
  285. package/dist/tools/cpu/level-set.js +313 -0
  286. package/dist/tools/cpu/level-set.js.map +1 -0
  287. package/dist/tools/cpu/majorant.d.ts +265 -0
  288. package/dist/tools/cpu/majorant.js +541 -0
  289. package/dist/tools/cpu/majorant.js.map +1 -0
  290. package/dist/tools/cpu/march.d.ts +297 -0
  291. package/dist/tools/cpu/march.js +726 -0
  292. package/dist/tools/cpu/march.js.map +1 -0
  293. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  294. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  295. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  296. package/dist/tools/cpu/points.d.ts +29 -0
  297. package/dist/tools/cpu/points.js +38 -0
  298. package/dist/tools/cpu/points.js.map +1 -0
  299. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  300. package/dist/tools/cpu/probe-coords.js +116 -0
  301. package/dist/tools/cpu/probe-coords.js.map +1 -0
  302. package/dist/tools/cpu/read-value.d.ts +44 -0
  303. package/dist/tools/cpu/read-value.js +351 -0
  304. package/dist/tools/cpu/read-value.js.map +1 -0
  305. package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
  306. package/dist/tools/cpu/sample-trilinear.js +168 -0
  307. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  308. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  309. package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
  310. package/dist/tools/cpu/stride-tables.generated.js +1267 -0
  311. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  312. package/dist/tools/cpu/stride-tables.js +78 -0
  313. package/dist/tools/cpu/stride-tables.js.map +1 -0
  314. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  315. package/dist/tools/cpu/surface-nets.js +597 -0
  316. package/dist/tools/cpu/surface-nets.js.map +1 -0
  317. package/dist/tools/errors.d.ts +66 -0
  318. package/dist/tools/errors.js +67 -0
  319. package/dist/tools/errors.js.map +1 -0
  320. package/dist/tools/frame/ambient.d.ts +98 -0
  321. package/dist/tools/frame/ambient.js +274 -0
  322. package/dist/tools/frame/ambient.js.map +1 -0
  323. package/dist/tools/frame/blackbody.d.ts +57 -0
  324. package/dist/tools/frame/blackbody.js +151 -0
  325. package/dist/tools/frame/blackbody.js.map +1 -0
  326. package/dist/tools/frame/brick-cache.d.ts +165 -0
  327. package/dist/tools/frame/brick-cache.js +326 -0
  328. package/dist/tools/frame/brick-cache.js.map +1 -0
  329. package/dist/tools/frame/emission.d.ts +137 -0
  330. package/dist/tools/frame/emission.js +290 -0
  331. package/dist/tools/frame/emission.js.map +1 -0
  332. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  333. package/dist/tools/frame/environment-gpu.js +280 -0
  334. package/dist/tools/frame/environment-gpu.js.map +1 -0
  335. package/dist/tools/frame/environment.d.ts +106 -0
  336. package/dist/tools/frame/environment.js +272 -0
  337. package/dist/tools/frame/environment.js.map +1 -0
  338. package/dist/tools/frame/froxel.d.ts +58 -0
  339. package/dist/tools/frame/froxel.js +115 -0
  340. package/dist/tools/frame/froxel.js.map +1 -0
  341. package/dist/tools/frame/grid.d.ts +392 -0
  342. package/dist/tools/frame/grid.js +802 -0
  343. package/dist/tools/frame/grid.js.map +1 -0
  344. package/dist/tools/frame/index.d.ts +150 -0
  345. package/dist/tools/frame/index.js +389 -0
  346. package/dist/tools/frame/index.js.map +1 -0
  347. package/dist/tools/frame/medium.d.ts +77 -0
  348. package/dist/tools/frame/medium.js +101 -0
  349. package/dist/tools/frame/medium.js.map +1 -0
  350. package/dist/tools/frame/mie-table.d.ts +6 -0
  351. package/dist/tools/frame/mie-table.js +16 -0
  352. package/dist/tools/frame/mie-table.js.map +1 -0
  353. package/dist/tools/frame/mie.d.ts +63 -0
  354. package/dist/tools/frame/mie.js +194 -0
  355. package/dist/tools/frame/mie.js.map +1 -0
  356. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  357. package/dist/tools/frame/mlp-nn.js +159 -0
  358. package/dist/tools/frame/mlp-nn.js.map +1 -0
  359. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  360. package/dist/tools/frame/mlp-tza.js +186 -0
  361. package/dist/tools/frame/mlp-tza.js.map +1 -0
  362. package/dist/tools/frame/mlp.d.ts +183 -0
  363. package/dist/tools/frame/mlp.js +434 -0
  364. package/dist/tools/frame/mlp.js.map +1 -0
  365. package/dist/tools/frame/ms-exit.d.ts +42 -0
  366. package/dist/tools/frame/ms-exit.js +90 -0
  367. package/dist/tools/frame/ms-exit.js.map +1 -0
  368. package/dist/tools/frame/multi-scale.d.ts +152 -0
  369. package/dist/tools/frame/multi-scale.js +302 -0
  370. package/dist/tools/frame/multi-scale.js.map +1 -0
  371. package/dist/tools/frame/neural-weights.d.ts +10 -0
  372. package/dist/tools/frame/neural-weights.js +244 -0
  373. package/dist/tools/frame/neural-weights.js.map +1 -0
  374. package/dist/tools/frame/neural.d.ts +80 -0
  375. package/dist/tools/frame/neural.js +150 -0
  376. package/dist/tools/frame/neural.js.map +1 -0
  377. package/dist/tools/frame/occluders.d.ts +51 -0
  378. package/dist/tools/frame/occluders.js +72 -0
  379. package/dist/tools/frame/occluders.js.map +1 -0
  380. package/dist/tools/frame/pyramid-layout.d.ts +55 -0
  381. package/dist/tools/frame/pyramid-layout.js +100 -0
  382. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  383. package/dist/tools/frame/shadows.d.ts +190 -0
  384. package/dist/tools/frame/shadows.js +468 -0
  385. package/dist/tools/frame/shadows.js.map +1 -0
  386. package/dist/tools/frame/sparse.d.ts +147 -0
  387. package/dist/tools/frame/sparse.js +432 -0
  388. package/dist/tools/frame/sparse.js.map +1 -0
  389. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  390. package/dist/tools/frame/spectral-stack.js +391 -0
  391. package/dist/tools/frame/spectral-stack.js.map +1 -0
  392. package/dist/tools/frame/spectral.d.ts +222 -0
  393. package/dist/tools/frame/spectral.js +572 -0
  394. package/dist/tools/frame/spectral.js.map +1 -0
  395. package/dist/tools/frame/stack.d.ts +115 -0
  396. package/dist/tools/frame/stack.js +290 -0
  397. package/dist/tools/frame/stack.js.map +1 -0
  398. package/dist/tools/frame/view.d.ts +131 -0
  399. package/dist/tools/frame/view.js +337 -0
  400. package/dist/tools/frame/view.js.map +1 -0
  401. package/dist/tools/index.d.ts +157 -0
  402. package/dist/tools/index.js +132 -0
  403. package/dist/tools/index.js.map +1 -0
  404. package/dist/tools/internal.d.ts +87 -0
  405. package/dist/tools/internal.js +85 -0
  406. package/dist/tools/internal.js.map +1 -0
  407. package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
  408. package/dist/tools/nanovdb/build-from-vdb.js +100 -0
  409. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  410. package/dist/tools/nanovdb/bytes.d.ts +233 -0
  411. package/dist/tools/nanovdb/bytes.js +388 -0
  412. package/dist/tools/nanovdb/bytes.js.map +1 -0
  413. package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
  414. package/dist/tools/nanovdb/coarse-first.js +92 -0
  415. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  416. package/dist/tools/nanovdb/half.d.ts +22 -0
  417. package/dist/tools/nanovdb/half.js +73 -0
  418. package/dist/tools/nanovdb/half.js.map +1 -0
  419. package/dist/tools/nanovdb/index.d.ts +34 -0
  420. package/dist/tools/nanovdb/index.js +25 -0
  421. package/dist/tools/nanovdb/index.js.map +1 -0
  422. package/dist/tools/nanovdb/inspect.d.ts +33 -0
  423. package/dist/tools/nanovdb/inspect.js +70 -0
  424. package/dist/tools/nanovdb/inspect.js.map +1 -0
  425. package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
  426. package/dist/tools/nanovdb/leaf-codec.js +356 -0
  427. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  428. package/dist/tools/nanovdb/quantize.d.ts +72 -0
  429. package/dist/tools/nanovdb/quantize.js +329 -0
  430. package/dist/tools/nanovdb/quantize.js.map +1 -0
  431. package/dist/tools/nanovdb/resample.d.ts +177 -0
  432. package/dist/tools/nanovdb/resample.js +692 -0
  433. package/dist/tools/nanovdb/resample.js.map +1 -0
  434. package/dist/tools/nanovdb/serialize.d.ts +176 -0
  435. package/dist/tools/nanovdb/serialize.js +439 -0
  436. package/dist/tools/nanovdb/serialize.js.map +1 -0
  437. package/dist/tools/nanovdb/stats.d.ts +87 -0
  438. package/dist/tools/nanovdb/stats.js +225 -0
  439. package/dist/tools/nanovdb/stats.js.map +1 -0
  440. package/dist/tools/nanovdb/transform.d.ts +30 -0
  441. package/dist/tools/nanovdb/transform.js +94 -0
  442. package/dist/tools/nanovdb/transform.js.map +1 -0
  443. package/dist/tools/nanovdb/tree.d.ts +186 -0
  444. package/dist/tools/nanovdb/tree.js +530 -0
  445. package/dist/tools/nanovdb/tree.js.map +1 -0
  446. package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
  447. package/dist/tools/nanovdb/write-nvdb.js +290 -0
  448. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  449. package/dist/tools/nvdb-file.d.ts +265 -0
  450. package/dist/tools/nvdb-file.js +763 -0
  451. package/dist/tools/nvdb-file.js.map +1 -0
  452. package/dist/tools/nvdb-stream.d.ts +154 -0
  453. package/dist/tools/nvdb-stream.js +409 -0
  454. package/dist/tools/nvdb-stream.js.map +1 -0
  455. package/dist/tools/reference/analytic.d.ts +41 -0
  456. package/dist/tools/reference/analytic.js +95 -0
  457. package/dist/tools/reference/analytic.js.map +1 -0
  458. package/dist/tools/reference/environment.d.ts +62 -0
  459. package/dist/tools/reference/environment.js +154 -0
  460. package/dist/tools/reference/environment.js.map +1 -0
  461. package/dist/tools/reference/index.d.ts +12 -0
  462. package/dist/tools/reference/index.js +13 -0
  463. package/dist/tools/reference/index.js.map +1 -0
  464. package/dist/tools/reference/media.d.ts +14 -0
  465. package/dist/tools/reference/media.js +30 -0
  466. package/dist/tools/reference/media.js.map +1 -0
  467. package/dist/tools/reference/rng.d.ts +20 -0
  468. package/dist/tools/reference/rng.js +30 -0
  469. package/dist/tools/reference/rng.js.map +1 -0
  470. package/dist/tools/reference/scene.d.ts +312 -0
  471. package/dist/tools/reference/scene.js +169 -0
  472. package/dist/tools/reference/scene.js.map +1 -0
  473. package/dist/tools/reference/tables.d.ts +98 -0
  474. package/dist/tools/reference/tables.js +264 -0
  475. package/dist/tools/reference/tables.js.map +1 -0
  476. package/dist/tools/reference/trace.d.ts +160 -0
  477. package/dist/tools/reference/trace.js +497 -0
  478. package/dist/tools/reference/trace.js.map +1 -0
  479. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  480. package/dist/tools/vdb/bit-utils.js +42 -0
  481. package/dist/tools/vdb/bit-utils.js.map +1 -0
  482. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  483. package/dist/tools/vdb/blosc-write.js +197 -0
  484. package/dist/tools/vdb/blosc-write.js.map +1 -0
  485. package/dist/tools/vdb/blosc.d.ts +86 -0
  486. package/dist/tools/vdb/blosc.js +287 -0
  487. package/dist/tools/vdb/blosc.js.map +1 -0
  488. package/dist/tools/vdb/blosclz.d.ts +33 -0
  489. package/dist/tools/vdb/blosclz.js +112 -0
  490. package/dist/tools/vdb/blosclz.js.map +1 -0
  491. package/dist/tools/vdb/byte-reader.d.ts +50 -0
  492. package/dist/tools/vdb/byte-reader.js +161 -0
  493. package/dist/tools/vdb/byte-reader.js.map +1 -0
  494. package/dist/tools/vdb/compression.d.ts +81 -0
  495. package/dist/tools/vdb/compression.js +260 -0
  496. package/dist/tools/vdb/compression.js.map +1 -0
  497. package/dist/tools/vdb/errors.d.ts +10 -0
  498. package/dist/tools/vdb/errors.js +11 -0
  499. package/dist/tools/vdb/errors.js.map +1 -0
  500. package/dist/tools/vdb/grid.d.ts +37 -0
  501. package/dist/tools/vdb/grid.js +153 -0
  502. package/dist/tools/vdb/grid.js.map +1 -0
  503. package/dist/tools/vdb/half-float.d.ts +9 -0
  504. package/dist/tools/vdb/half-float.js +24 -0
  505. package/dist/tools/vdb/half-float.js.map +1 -0
  506. package/dist/tools/vdb/index.d.ts +4 -0
  507. package/dist/tools/vdb/index.js +3 -0
  508. package/dist/tools/vdb/index.js.map +1 -0
  509. package/dist/tools/vdb/inflate.d.ts +24 -0
  510. package/dist/tools/vdb/inflate.js +334 -0
  511. package/dist/tools/vdb/inflate.js.map +1 -0
  512. package/dist/tools/vdb/lz4.d.ts +30 -0
  513. package/dist/tools/vdb/lz4.js +228 -0
  514. package/dist/tools/vdb/lz4.js.map +1 -0
  515. package/dist/tools/vdb/metadata.d.ts +17 -0
  516. package/dist/tools/vdb/metadata.js +72 -0
  517. package/dist/tools/vdb/metadata.js.map +1 -0
  518. package/dist/tools/vdb/parse.d.ts +47 -0
  519. package/dist/tools/vdb/parse.js +241 -0
  520. package/dist/tools/vdb/parse.js.map +1 -0
  521. package/dist/tools/vdb/point-render-data.d.ts +79 -0
  522. package/dist/tools/vdb/point-render-data.js +137 -0
  523. package/dist/tools/vdb/point-render-data.js.map +1 -0
  524. package/dist/tools/vdb/points.d.ts +186 -0
  525. package/dist/tools/vdb/points.js +835 -0
  526. package/dist/tools/vdb/points.js.map +1 -0
  527. package/dist/tools/vdb/transform.d.ts +23 -0
  528. package/dist/tools/vdb/transform.js +54 -0
  529. package/dist/tools/vdb/transform.js.map +1 -0
  530. package/dist/tools/vdb/tree.d.ts +111 -0
  531. package/dist/tools/vdb/tree.js +228 -0
  532. package/dist/tools/vdb/tree.js.map +1 -0
  533. package/dist/tools/vdb/types.d.ts +195 -0
  534. package/dist/tools/vdb/types.js +3 -0
  535. package/dist/tools/vdb/types.js.map +1 -0
  536. package/dist/tools/wvdb/bake.d.ts +145 -0
  537. package/dist/tools/wvdb/bake.js +361 -0
  538. package/dist/tools/wvdb/bake.js.map +1 -0
  539. package/dist/tools/wvdb/dense.d.ts +191 -0
  540. package/dist/tools/wvdb/dense.js +368 -0
  541. package/dist/tools/wvdb/dense.js.map +1 -0
  542. package/dist/tools/wvdb/format.d.ts +220 -0
  543. package/dist/tools/wvdb/format.js +306 -0
  544. package/dist/tools/wvdb/format.js.map +1 -0
  545. package/dist/tools/wvdb/index.d.ts +14 -0
  546. package/dist/tools/wvdb/index.js +15 -0
  547. package/dist/tools/wvdb/index.js.map +1 -0
  548. package/dist/tools/wvdb/level-set.d.ts +56 -0
  549. package/dist/tools/wvdb/level-set.js +153 -0
  550. package/dist/tools/wvdb/level-set.js.map +1 -0
  551. package/dist/tools/wvdb/nanovdb.d.ts +59 -0
  552. package/dist/tools/wvdb/nanovdb.js +64 -0
  553. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  554. package/dist/tools/wvdb/partial.d.ts +74 -0
  555. package/dist/tools/wvdb/partial.js +233 -0
  556. package/dist/tools/wvdb/partial.js.map +1 -0
  557. package/dist/tools/wvdb/read.d.ts +336 -0
  558. package/dist/tools/wvdb/read.js +766 -0
  559. package/dist/tools/wvdb/read.js.map +1 -0
  560. package/dist/tools/wvdb/sha256.d.ts +7 -0
  561. package/dist/tools/wvdb/sha256.js +76 -0
  562. package/dist/tools/wvdb/sha256.js.map +1 -0
  563. package/dist/tools/wvdb/write.d.ts +149 -0
  564. package/dist/tools/wvdb/write.js +403 -0
  565. package/dist/tools/wvdb/write.js.map +1 -0
  566. package/package.json +83 -4
  567. package/vendor/LICENSE +201 -0
  568. package/vendor/NOTICE +19 -0
  569. package/vendor/VENDOR.md +100 -0
  570. package/vendor/pnanovdb.wgsl +1577 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"points.js","sourceRoot":"","sources":["../../../src/tools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ClC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACtG,CAAC;AACH,CAAC","sourcesContent":["/**\n * points.ts — OpenVDB point data grids (`points::PointDataGrid`, grid type\n * `Tree_ptdataidx32_5_4_3`): the multi-pass leaf buffers and the attribute\n * arrays they hold.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/openvdb/core/PointDataBuffers.js`, `src/openvdb/utils/points.js`): the\n * pass walk and the position decode follow the same OpenVDB sources his reader\n * cites. The format authority is OpenVDB itself (pinned a532de55):\n * `Grid::readBuffers` (multi-pass I/O), `points/PointDataGrid.h`\n * (`PointDataLeafNode::readBuffers`, the `PointDataIndex32`\n * `readCompressedValues` specialization), `points/AttributeSet.cc`\n * (`Descriptor::read`, `readMetadata`, `groupIndex`), `points/AttributeArray.h`\n * (`TypedAttributeArray::readMetadata` / `readBuffers` / `readPagedBuffers`,\n * the codecs) and `points/StreamCompression.cc` (`PagedInputStream`, `Page`).\n *\n * ## On-disk layout\n *\n * The tree topology is ordinary (leaves store only their value mask there).\n * The buffers start with a `u16 numPasses`; then the whole tree is walked\n * `numPasses` times, every leaf reading the part of its data that belongs to\n * the pass. With `n = (numPasses - 4) / 2` attributes:\n *\n * pass 0 u16 compressed size of the leaf's voxel buffer\n * pass 1 [u8 header, attribute descriptor, (header & 2) u64 skip]\n * unless a previous leaf shared its descriptor (header & 1);\n * then each attribute array's metadata\n * pass 2..n+1 attribute (pass - 2): page headers of paged arrays\n * pass n+2 the voxel buffer: value mask, then u16 size and a Blosc\n * frame (or 0xFFFF and 512 raw u32 end offsets)\n * pass n+3..2n+2 attribute (pass - n - 3): page bodies of paged arrays, or\n * the whole buffer of a non-paged array\n * pass 2n+3 cleanup (no I/O)\n *\n * Paged arrays (Blosc files) share pages: a page holds the arrays of many\n * consecutive leaves. A page header is an i32 compressed size and, when\n * positive, an i32 uncompressed size; a negative size means the page is\n * stored raw. Page bodies are read only when the next array starts a new\n * page, so the bytes stay views into the file until {@link decodePoints}.\n *\n * Each leaf voxel holds the *end* offset of its points in the leaf's arrays.\n * The position attribute `P` is a voxel-space offset from the voxel centre;\n * world position = `indexToWorld(ijk + P)`.\n *\n * ## Hostile input (K4.2 hardening)\n *\n * Every count, size and offset read from the file is bounded before it drives\n * an allocation or a loop, and every failure is a `VdbFormatError` or\n * `VDBUnsupportedError`:\n *\n * - The pass loops only visit the leaves that own an array for the pass, so\n * their work is bounded by the array metadata actually stored (a large\n * `numPasses` costs nothing). A leaf with more attributes than the passes\n * cover is rejected.\n * - Page headers: a page body must fit in the file, and a Blosc page may claim\n * at most {@link MAX_BLOSC_RATIO} times its compressed size. A page must be\n * filled exactly by the arrays assigned to it.\n * - Point counts: the grid's total point count, times the 12 bytes of its\n * positions, may not exceed {@link MAX_POINT_EXPANSION} times the file size.\n * Uniform arrays store one value for any number of points, so nothing else\n * bounds a count.\n * - Decoding: every output array and every decoded page is charged against a\n * budget of {@link MAX_POINT_EXPANSION} times the file size before it is\n * allocated. Strides and group offsets are range-checked (no int32\n * wrap-around).\n *\n * ## OpenVDB v14.0.0 security checks (K7.C)\n *\n * OpenVDB v14 throws `IoError` on four PointDataGrid inconsistencies\n * (CHANGES \"Security Fixes\"; `TypedAttributeArray::readMetadata` /\n * `readBuffers` / `readPagedBuffers`, `PagedInputStream::createHandle` /\n * `read`, `Page::readHeader`, `codecs/PointDataCodec.h`\n * `validateReadOffsets` / `validatePointDataAttributeCount`). Each maps here:\n *\n * 1. Attribute byte count smaller than the array: a byte count below its 6\n * header bytes, a size of 0, a constant stride of 0 or with `size * stride`\n * past u32, and a total size below `size` fail in `readArrayMetadata`;\n * the stored bytes must equal the array's exactly (stricter than v14's\n * \"at least\") when {@link decodePoints} reads them.\n * 2. Page size that does not match its data: page headers of 0, i32 minimum or\n * a non-positive uncompressed size, an array of 0 bytes or past its page\n * (`createPageHandle`), and a page whose arrays don't fill it exactly\n * (`checkStreamComplete`, stricter than v14's unread-page check); a\n * decoded page must be exactly its header's size.\n * 3. Voxel offsets beyond the arrays: end offsets must not decrease, and every\n * array's size must equal the leaf's last offset (v14: offsets at most the\n * last, the last at most each size; ours is exact).\n * 4. Pass count too small: a leaf with more arrays than `(numPasses - 4) / 2`\n * covers fails (and fewer than 4 passes with leaves).\n */\n\nimport type { ByteReader } from \"./byte-reader.js\";\nimport { decompressBlosc } from \"./blosc.js\";\nimport { VdbFormatError, VDBUnsupportedError } from \"./errors.js\";\nimport { halfToFloat } from \"./half-float.js\";\nimport { readMetadataMap } from \"./metadata.js\";\nimport type { VdbPointAttributeArray, VdbPointAttributeInfo, VdbPointList } from \"./types.js\";\n\nconst LEAF_NUM_VALUES = 512;\nconst LEAF_LOG2DIM = 3;\n\n/** `PointDataLeafNode::readBuffers` descriptor header bits. */\nconst HEADER_SHARED_DESCRIPTOR = 0x1;\nconst HEADER_SKIP_BYTES = 0x2;\n\n/** `AttributeArray::SerializationFlag`. */\nconst WRITE_STRIDED = 0x1;\nconst WRITE_UNIFORM = 0x2;\nconst WRITE_PAGED = 0x8;\n/** `AttributeArray::Flag::CONSTANTSTRIDE`. */\nconst FLAG_CONSTANT_STRIDE = 0x8;\n\n/** The `u16` voxel-buffer size that marks an uncompressed buffer. */\nconst VOXEL_BUFFER_UNCOMPRESSED = 0xffff;\n\n/**\n * The most a Blosc1 frame from OpenVDB can expand: deflate's worst case is\n * about 1032:1 and LZ4's 255:1 (each length byte adds at most 255 output\n * bytes). A Blosc page header claiming more is not a real page.\n */\nexport const MAX_BLOSC_RATIO = 1032;\n\n/**\n * Decoded point output allowed per byte of the source file. The real samples\n * need under 3 (waterfall_points: 156 MB in, 381 MB of positions and\n * attributes out); 256 matches LZ4's ceiling and leaves room for uniform\n * arrays, which store one value for a whole leaf.\n */\nexport const MAX_POINT_EXPANSION = 256;\n\n/** Bytes of decoded position per point (3 x f32). */\nconst POSITION_BYTES = 12;\n\n/** Descriptor limits: far above any real file, low enough to bound the loops. */\nconst MAX_ATTRIBUTES = 1 << 16;\nconst MAX_GROUPS = 1 << 16;\n\n/** One attribute set descriptor (`AttributeSet::Descriptor`). */\nexport interface PointDescriptor {\n /** In attribute-set order (`index` = position). */\n attributes: VdbPointAttributeInfo[];\n /** Group name -> bit offset across the group attributes. */\n groups: { name: string; offset: number }[];\n}\n\n/** A page of a paged attribute stream (`compression::Page`). */\nexport interface PointPage {\n /** > 0: Blosc frame size; < 0: raw, `-compressedBytes` bytes. */\n compressedBytes: number;\n uncompressedBytes: number;\n /** The page body as stored (a view into the file), once read. */\n data: Uint8Array | null;\n}\n\n/** One leaf's attribute array (`TypedAttributeArray` metadata plus where its bytes are). */\nexport interface PointArrayData {\n flags: number;\n serialization: number;\n /** Points in the array (`mSize`). */\n size: number;\n /** Stride (constant-stride arrays) or total element count. */\n strideOrTotal: number;\n /** Uncompressed array bytes for paged arrays; stored bytes for non-paged ones. */\n bytes: number;\n isUniform: boolean;\n isPaged: boolean;\n /** Non-paged arrays: the stored bytes and whether they are a Blosc frame. */\n raw: Uint8Array | null;\n bloscCompressed: boolean;\n /** Paged arrays: the page and the array's byte offset inside it. */\n page: PointPage | null;\n pageOffset: number;\n}\n\n/** One point data leaf after the buffer passes. */\nexport interface PointLeafData {\n origin: [number, number, number];\n valueMask: Uint32Array;\n /** Per-voxel end offsets into the leaf's arrays. */\n offsets: Uint32Array;\n descriptor: PointDescriptor;\n arrays: PointArrayData[];\n}\n\ninterface PagedStream {\n page: PointPage | null;\n byteIndex: number;\n uncompressedBytes: number;\n}\n\nexport interface ReadPointBuffersOptions {\n fileVersion: number;\n /** Leaves in buffer order, with their topology origins. */\n leaves: readonly { origin: [number, number, number] }[];\n}\n\n/** `AttributeSet::Descriptor::read`. */\nfunction readDescriptor(reader: ByteReader): PointDescriptor {\n const count = reader.u64();\n if (count > BigInt(MAX_ATTRIBUTES)) throw new VdbFormatError(`point attribute descriptor claims ${count} attributes`);\n const n = Number(count);\n const types: { type: string; codec: string }[] = [];\n for (let i = 0; i < n; i++) types.push({ type: reader.string(), codec: reader.string() });\n const names = new Array<string | undefined>(n);\n const seen = new Set<string>();\n for (let i = 0; i < n; i++) {\n const name = reader.string();\n const index = reader.u64();\n if (index >= count) throw new VdbFormatError(`point attribute \"${name}\" has index ${index} of ${n}`);\n // Descriptor::read inserts into a std::map, so a repeated name would leave an attribute unnamed.\n if (seen.has(name)) throw new VdbFormatError(`point attribute name \"${name}\" appears twice`);\n seen.add(name);\n names[Number(index)] = name;\n }\n const attributes = types.map(({ type, codec }, index) => {\n const name = names[index];\n if (name === undefined) throw new VdbFormatError(`point attribute ${index} has no name`);\n return { name, type, codec, index };\n });\n const groupCount = reader.u64();\n if (groupCount > BigInt(MAX_GROUPS)) throw new VdbFormatError(`point attribute descriptor claims ${groupCount} groups`);\n const groups: { name: string; offset: number }[] = [];\n const groupNames = new Set<string>();\n for (let i = 0; i < Number(groupCount); i++) {\n const name = reader.string();\n const offset = reader.u64();\n // The group map is a std::map too: the first entry for a name wins.\n if (groupNames.has(name)) continue;\n groupNames.add(name);\n // Range-checked against the group arrays when decoded (`Descriptor::groupIndex`);\n // anything past 2^32 bits is out of range for any descriptor.\n groups.push({ name, offset: offset > 0xffffffffn ? Number.MAX_SAFE_INTEGER : Number(offset) });\n }\n readMetadataMap(reader); // descriptor metadata (default values, string tables): not needed here\n return { attributes, groups };\n}\n\n/** `TypedAttributeArray::readMetadata`. */\nfunction readArrayMetadata(reader: ByteReader): PointArrayData {\n const total = reader.u64();\n const flags = reader.u8();\n const serialization = reader.u8();\n const size = reader.u32();\n if (serialization >= 0x10) {\n throw new VDBUnsupportedError(`point attribute serialization flags 0x${serialization.toString(16)}`);\n }\n if (total < 6n || total > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new VdbFormatError(`point attribute array byte count ${total} is out of range`);\n }\n const bytes = Number(total) - 2 - 4; // minus the two flag bytes and the u32 size\n const strideOrTotal = serialization & WRITE_STRIDED ? reader.u32() : 1;\n // OpenVDB v14 (`readMetadata`): size and stride come from the file, so a size of 0, a constant\n // stride of 0 or whose `size * stride` passes u32, or a total below the size is an IoError.\n if (size === 0) throw new VdbFormatError(\"point attribute array has a size of 0\");\n const constantStride = !(serialization & WRITE_STRIDED) || (flags & FLAG_CONSTANT_STRIDE) !== 0;\n if (constantStride) {\n if (strideOrTotal === 0) throw new VdbFormatError(\"point attribute array has a constant stride of 0\");\n if (size * strideOrTotal > 0xffffffff) {\n throw new VdbFormatError(`point attribute array of ${size} x stride ${strideOrTotal} values passes 2^32`);\n }\n } else if (strideOrTotal < size) {\n throw new VdbFormatError(`point attribute array has a total size of ${strideOrTotal}, below its ${size} points`);\n }\n return {\n flags,\n serialization,\n size,\n strideOrTotal,\n bytes,\n isUniform: (serialization & WRITE_UNIFORM) !== 0,\n isPaged: (serialization & WRITE_PAGED) !== 0,\n raw: null,\n bloscCompressed: false,\n page: null,\n pageOffset: 0,\n };\n}\n\n/** `PagedInputStream::createHandle`: assign the array its page, reading a page header when one starts. */\nfunction createPageHandle(reader: ByteReader, stream: PagedStream, array: PointArrayData): void {\n if (stream.byteIndex === stream.uncompressedBytes) {\n const compressedBytes = reader.i32();\n const uncompressedBytes = compressedBytes > 0 ? reader.i32() : -compressedBytes;\n // OpenVDB v14 `Page::readHeader`: 0 and the i32 minimum (whose negation overflows) are invalid.\n if (compressedBytes === 0 || compressedBytes === -0x80000000 || uncompressedBytes <= 0) {\n throw new VdbFormatError(`point attribute page header ${compressedBytes}/${uncompressedBytes} is empty`);\n }\n // The body follows later in the file, so it can be no larger than the file.\n const storedBytes = Math.abs(compressedBytes);\n if (storedBytes > reader.length) {\n throw new VdbFormatError(\n `point attribute page header claims ${storedBytes} stored bytes in a ${reader.length}-byte file`,\n );\n }\n if (compressedBytes > 0 && uncompressedBytes > Math.max(compressedBytes * MAX_BLOSC_RATIO, BLOSC_PAD_BYTES)) {\n throw new VdbFormatError(\n `point attribute page header claims ${uncompressedBytes} bytes from a ${compressedBytes}-byte Blosc frame`,\n );\n }\n stream.page = { compressedBytes, uncompressedBytes, data: null };\n stream.uncompressedBytes = uncompressedBytes;\n stream.byteIndex = 0;\n }\n // OpenVDB v14 `PagedInputStream::createHandle`: a handle of n <= 0 bytes, or past the page, is an IoError.\n if (array.bytes <= 0 || stream.byteIndex + array.bytes > stream.uncompressedBytes) {\n throw new VdbFormatError(\n `point attribute array of ${array.bytes} bytes ${array.bytes <= 0 ? \"is empty in\" : \"overruns\"} its ${stream.uncompressedBytes}-byte page`,\n );\n }\n array.page = stream.page;\n array.pageOffset = stream.byteIndex;\n stream.byteIndex += array.bytes;\n}\n\n/** `PagedInputStream::read`: read the array's page body when it starts a new page. */\nfunction readPage(reader: ByteReader, stream: PagedStream, array: PointArrayData): void {\n const page = array.page;\n if (!page) throw new VdbFormatError(\"paged point attribute array has no page\");\n if (stream.byteIndex === stream.uncompressedBytes) {\n stream.uncompressedBytes = page.uncompressedBytes;\n page.data = reader.bytes_(Math.abs(page.compressedBytes));\n stream.byteIndex = 0;\n }\n stream.byteIndex += array.bytes;\n}\n\n/** `LeafNode::readBuffers` with the `PointDataIndex32` `readCompressedValues` specialization. */\nfunction readVoxelBuffer(reader: ByteReader, fileVersion: number): { valueMask: Uint32Array; offsets: Uint32Array } {\n const valueMask = reader.maskWords(LEAF_NUM_VALUES);\n if (fileVersion < 222) {\n reader.vec3i(); // origin\n const numBuffers = reader.u8();\n if (numBuffers !== 1) throw new VdbFormatError(`point leaf numBuffers ${numBuffers} !== 1`);\n }\n const destBytes = LEAF_NUM_VALUES * 4;\n const size = reader.u16();\n const bytes =\n size === VOXEL_BUFFER_UNCOMPRESSED\n ? reader.bytes_(destBytes)\n : decompressBlosc(reader.bytes_(size), { maxBytes: destBytes, expectedCbytes: size });\n if (bytes.length !== destBytes) {\n throw new VdbFormatError(`point leaf voxel buffer decoded to ${bytes.length} bytes, expected ${destBytes}`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const offsets = new Uint32Array(LEAF_NUM_VALUES);\n for (let i = 0; i < LEAF_NUM_VALUES; i++) offsets[i] = view.getUint32(i * 4, true);\n for (let i = 1; i < LEAF_NUM_VALUES; i++) {\n if (offsets[i]! < offsets[i - 1]!) throw new VdbFormatError(\"point leaf end offsets decrease\");\n }\n return { valueMask, offsets };\n}\n\n/**\n * Reads a point data grid's buffers (after its topology): `u16 numPasses`,\n * then every pass over every leaf. Returns one entry per leaf, in order.\n */\nexport function readPointDataBuffers(reader: ByteReader, opts: ReadPointBuffersOptions): PointLeafData[] {\n const numPasses = reader.u16();\n const n = opts.leaves.length;\n if (n === 0) return [];\n if (numPasses < 4) throw new VdbFormatError(`point data grid has ${numPasses} buffer passes (expected >= 4)`);\n const attributeCount = Math.floor((numPasses - 4) / 2);\n\n const leaves: PointLeafData[] = opts.leaves.map((l) => ({\n origin: l.origin,\n valueMask: EMPTY_MASK,\n offsets: EMPTY_OFFSETS,\n descriptor: { attributes: [], groups: [] },\n arrays: [],\n }));\n let sharedDescriptor: PointDescriptor | null = null;\n\n // Pass 0: voxel buffer sizes (only used by OpenVDB for delayed loading).\n for (let i = 0; i < n; i++) reader.u16();\n\n // Pass 1: descriptors and attribute array metadata.\n let maxArrays = 0;\n for (const leaf of leaves) {\n if (sharedDescriptor) {\n leaf.descriptor = sharedDescriptor;\n } else {\n const header = reader.u8();\n leaf.descriptor = readDescriptor(reader);\n if (header & HEADER_SHARED_DESCRIPTOR) sharedDescriptor = leaf.descriptor;\n if (header & HEADER_SKIP_BYTES) {\n const skip = reader.u64();\n if (skip > BigInt(reader.length - reader.pos)) {\n throw new VdbFormatError(`point leaf descriptor asks to skip ${skip} bytes past the end of the file`);\n }\n reader.skip(Number(skip));\n }\n if (header > 3) throw new VDBUnsupportedError(`point leaf descriptor header flags 0x${header.toString(16)}`);\n }\n leaf.arrays = leaf.descriptor.attributes.map(() => readArrayMetadata(reader));\n maxArrays = Math.max(maxArrays, leaf.arrays.length);\n }\n // `PointDataLeafNode::buffers()` is 2 * attributes + 4, and the grid writes the\n // largest leaf's count: arrays past `attributeCount` would never be read.\n if (maxArrays > attributeCount) {\n throw new VdbFormatError(\n `point leaf has ${maxArrays} attribute arrays, but the grid writes ${numPasses} passes (room for ${attributeCount})`,\n );\n }\n // The leaves that own array i, so passes cost no more than the arrays stored.\n const owners: PointLeafData[][] = Array.from({ length: maxArrays }, () => []);\n for (const leaf of leaves) for (let i = 0; i < leaf.arrays.length; i++) owners[i]!.push(leaf);\n const streams: PagedStream[] = Array.from({ length: maxArrays }, () => ({\n page: null,\n byteIndex: 0,\n uncompressedBytes: 0,\n }));\n\n // Passes 2 .. n+1: page headers.\n for (let i = 0; i < maxArrays; i++) {\n for (const leaf of owners[i]!) {\n const array = leaf.arrays[i]!;\n if (array.isPaged) createPageHandle(reader, streams[i]!, array);\n }\n checkStreamComplete(streams[i]!, i, \"page headers\");\n }\n\n // Pass n+2: voxel buffers. Every attribute array holds one entry per point of the leaf.\n let totalPoints = 0;\n for (const leaf of leaves) {\n const { valueMask, offsets } = readVoxelBuffer(reader, opts.fileVersion);\n leaf.valueMask = valueMask;\n leaf.offsets = offsets;\n const points = offsets[LEAF_NUM_VALUES - 1]!;\n const bad = leaf.arrays.find((a) => a.size !== points);\n if (bad) {\n throw new VdbFormatError(`point leaf has ${points} points but an attribute array of size ${bad.size}`);\n }\n totalPoints += points;\n }\n if (totalPoints * POSITION_BYTES > MAX_POINT_EXPANSION * reader.length) {\n throw new VdbFormatError(\n `point data grid claims ${totalPoints} points, more than a ${reader.length}-byte file can hold`,\n );\n }\n\n // Passes n+3 .. 2n+2: page bodies, or the buffers of non-paged arrays.\n for (let i = 0; i < maxArrays; i++) {\n for (const leaf of owners[i]!) {\n const array = leaf.arrays[i]!;\n if (array.isPaged) {\n readPage(reader, streams[i]!, array);\n } else {\n // TypedAttributeArray::readBuffers.\n array.bloscCompressed = array.isUniform ? false : reader.u8() === 1;\n array.raw = reader.bytes_(array.bytes);\n }\n }\n checkStreamComplete(streams[i]!, i, \"page bodies\");\n }\n // Passes past 2n+2 are cleanup only (no I/O), however many the header claims.\n return leaves;\n}\n\nconst EMPTY_MASK = new Uint32Array(LEAF_NUM_VALUES / 32);\nconst EMPTY_OFFSETS = new Uint32Array(LEAF_NUM_VALUES);\n\n/** A paged stream must end on a page boundary, or the next pass reads out of step. */\nfunction checkStreamComplete(stream: PagedStream, index: number, what: string): void {\n if (stream.byteIndex !== stream.uncompressedBytes) {\n throw new VdbFormatError(\n `point attribute ${index} ${what} end mid-page (${stream.byteIndex} of ${stream.uncompressedBytes} bytes)`,\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Attribute decoding\n// ---------------------------------------------------------------------------\n\ntype ScalarKind = \"bool\" | \"i8\" | \"u8\" | \"i16\" | \"u16\" | \"i32\" | \"u32\" | \"i64\" | \"u64\" | \"f16\" | \"f32\" | \"f64\";\n\n/** OpenVDB `typeNameAsString` -> element shape. */\nconst VALUE_TYPES: Record<string, { components: number; kind: ScalarKind }> = {\n bool: { components: 1, kind: \"bool\" },\n half: { components: 1, kind: \"f16\" },\n float: { components: 1, kind: \"f32\" },\n double: { components: 1, kind: \"f64\" },\n int8: { components: 1, kind: \"i8\" },\n uint8: { components: 1, kind: \"u8\" },\n int16: { components: 1, kind: \"i16\" },\n uint16: { components: 1, kind: \"u16\" },\n int32: { components: 1, kind: \"i32\" },\n uint32: { components: 1, kind: \"u32\" },\n int64: { components: 1, kind: \"i64\" },\n uint64: { components: 1, kind: \"u64\" },\n vec2i: { components: 2, kind: \"i32\" },\n vec2s: { components: 2, kind: \"f32\" },\n vec2d: { components: 2, kind: \"f64\" },\n vec3u8: { components: 3, kind: \"u8\" },\n vec3u16: { components: 3, kind: \"u16\" },\n vec3i: { components: 3, kind: \"i32\" },\n vec3s: { components: 3, kind: \"f32\" },\n vec3d: { components: 3, kind: \"f64\" },\n vec4i: { components: 4, kind: \"i32\" },\n vec4s: { components: 4, kind: \"f32\" },\n vec4d: { components: 4, kind: \"f64\" },\n quats: { components: 4, kind: \"f32\" },\n quatd: { components: 4, kind: \"f64\" },\n mat3s: { components: 9, kind: \"f32\" },\n mat3d: { components: 9, kind: \"f64\" },\n mat4s: { components: 16, kind: \"f32\" },\n mat4d: { components: 16, kind: \"f64\" },\n};\n\nconst KIND_BYTES: Record<ScalarKind, number> = {\n bool: 1,\n i8: 1,\n u8: 1,\n i16: 2,\n u16: 2,\n i32: 4,\n u32: 4,\n i64: 8,\n u64: 8,\n f16: 2,\n f32: 4,\n f64: 8,\n};\n\ntype ArrayCtor = { new (n: number): VdbPointAttributeArray; readonly BYTES_PER_ELEMENT: number };\n\nconst OUTPUT_CTOR: Record<ScalarKind, ArrayCtor> = {\n bool: Uint8Array,\n i8: Int8Array,\n u8: Uint8Array,\n i16: Int16Array,\n u16: Uint16Array,\n i32: Int32Array,\n u32: Uint32Array,\n i64: BigInt64Array,\n u64: BigUint64Array,\n f16: Float32Array,\n f32: Float32Array,\n f64: Float64Array,\n};\n\nfunction scalarReader(kind: ScalarKind): (view: DataView, at: number) => number | bigint {\n switch (kind) {\n case \"bool\":\n case \"u8\":\n return (v, at) => v.getUint8(at);\n case \"i8\":\n return (v, at) => v.getInt8(at);\n case \"i16\":\n return (v, at) => v.getInt16(at, true);\n case \"u16\":\n return (v, at) => v.getUint16(at, true);\n case \"i32\":\n return (v, at) => v.getInt32(at, true);\n case \"u32\":\n return (v, at) => v.getUint32(at, true);\n case \"i64\":\n return (v, at) => v.getBigInt64(at, true);\n case \"u64\":\n return (v, at) => v.getBigUint64(at, true);\n case \"f16\":\n return (v, at) => halfToFloat(v.getUint16(at, true));\n case \"f32\":\n return (v, at) => v.getFloat32(at, true);\n case \"f64\":\n return (v, at) => v.getFloat64(at, true);\n }\n}\n\nconst fround = Math.fround;\n\nlet unitVecWeights: Float32Array | null = null;\n/**\n * `math::QuantizedUnitVec::sNormalizationWeights`, generated: `1 / |(x, y, 126 - x - y)|`\n * per slot. Exported for the test against OpenVDB's literal table.\n */\nexport function unitVecWeightTable(): Float32Array {\n if (unitVecWeights) return unitVecWeights;\n const table = new Float32Array(8192);\n for (let slot = 0; slot < 8192; slot++) {\n let x = (slot & 0x1f80) >> 7;\n let y = slot & 0x007f;\n if (x + y > 126) {\n x = 127 - x;\n y = 127 - y;\n }\n const z = 126 - x - y;\n table[slot] = 1 / Math.sqrt(x * x + y * y + z * z);\n }\n unitVecWeights = table;\n return table;\n}\n\n/** `math::QuantizedUnitVec::unpack`. */\nexport function unpackUnitVec(data: number, out: Float32Array | Float64Array, at: number): void {\n const w = unitVecWeightTable()[data & 0x1fff]!;\n let x = (data & 0x1f80) >> 7;\n let y = data & 0x007f;\n if (x + y > 126) {\n x = 127 - x;\n y = 127 - y;\n }\n let vx = fround(x * w);\n let vy = fround(y * w);\n let vz = fround((126 - x - y) * w);\n if (data & 0x8000) vx = -vx;\n if (data & 0x4000) vy = -vy;\n if (data & 0x2000) vz = -vz;\n out[at] = vx;\n out[at + 1] = vy;\n out[at + 2] = vz;\n}\n\n/** How one stored element decodes. */\ninterface AttributeCodec {\n components: number;\n /** Bytes of one stored element (all components). */\n storageBytes: number;\n output: ArrayCtor;\n /** Decodes the element at byte `at` into `out[outAt .. outAt + components)`. */\n decode(view: DataView, at: number, out: VdbPointAttributeArray, outAt: number): void;\n}\n\n/** The codec for an attribute's (type, codec) pair, or null when unsupported. */\nfunction attributeCodec(type: string, codec: string): AttributeCodec | null {\n const shape = VALUE_TYPES[type];\n if (!shape) return null;\n const { components, kind } = shape;\n\n const perComponent = (storage: ScalarKind, map: (x: number) => number, output: ArrayCtor): AttributeCodec => {\n const read = scalarReader(storage);\n const step = KIND_BYTES[storage];\n return {\n components,\n storageBytes: step * components,\n output,\n decode(view, at, out, outAt) {\n for (let c = 0; c < components; c++) (out as Float32Array)[outAt + c] = map(read(view, at + c * step) as number);\n },\n };\n };\n\n switch (codec) {\n case \"null\":\n case \"str\": {\n const read = scalarReader(kind);\n const step = KIND_BYTES[kind];\n return {\n components,\n storageBytes: step * components,\n output: OUTPUT_CTOR[kind],\n decode(view, at, out, outAt) {\n for (let c = 0; c < components; c++) (out as unknown as (number | bigint)[])[outAt + c] = read(view, at + c * step);\n },\n };\n }\n case \"trnc\":\n // TruncateTrait: float -> half, int -> short (and their Vec3s).\n if (kind === \"f32\") return perComponent(\"f16\", (x) => x, Float32Array);\n if (kind === \"i32\") return perComponent(\"i16\", (x) => x, Int32Array);\n return null;\n case \"fxpt8\":\n case \"fxpt16\":\n case \"ufxpt8\":\n case \"ufxpt16\": {\n if (kind !== \"f32\") return null;\n const oneByte = codec.endsWith(\"8\");\n const max = oneByte ? 255 : 65535;\n // FixedPointCodec: float(s) / float(max), then PositionRange shifts by -0.5.\n const shift = codec.startsWith(\"u\") ? 0 : 0.5;\n return perComponent(oneByte ? \"u8\" : \"u16\", (s) => fround(fround(s / max) - shift), Float32Array);\n }\n case \"uvec\":\n if (type !== \"vec3s\") return null;\n return {\n components: 3,\n storageBytes: 2,\n output: Float32Array,\n decode(view, at, out, outAt) {\n unpackUnitVec(view.getUint16(at, true), out as Float32Array, outAt);\n },\n };\n default:\n return null;\n }\n}\n\n/** Element stride of an array, or null for a variable-stride array. */\nfunction arrayStride(array: PointArrayData): number | null {\n if (!(array.serialization & WRITE_STRIDED)) return 1;\n return array.flags & FLAG_CONSTANT_STRIDE ? array.strideOrTotal : null;\n}\n\n/** OpenVDB pads Blosc input shorter than this with zeros (`BLOSC_PAD_BYTES`). */\nconst BLOSC_PAD_BYTES = 48;\n\n/**\n * Decompresses a Blosc frame that must hold `expectedBytes` bytes, accepting\n * the zero-padded 48-byte frame OpenVDB writes for shorter input (the rule in\n * `compression::bloscDecompress`).\n */\nfunction decompressExact(frame: Uint8Array, expectedBytes: number, what: string): Uint8Array {\n const bytes = decompressBlosc(frame, {\n maxBytes: Math.max(expectedBytes, BLOSC_PAD_BYTES),\n expectedCbytes: frame.length,\n });\n const padded = bytes.length === BLOSC_PAD_BYTES && expectedBytes <= BLOSC_PAD_BYTES;\n if (bytes.length !== expectedBytes && !padded) {\n throw new VdbFormatError(`${what} decoded to ${bytes.length} bytes, expected ${expectedBytes}`);\n }\n return bytes;\n}\n\n/**\n * The decoded-output budget of one {@link decodePoints} call. Output arrays\n * and decoded pages are charged before they are allocated; a short-lived\n * buffer is only checked against what is left.\n */\nclass DecodeBudget {\n private used = 0;\n\n constructor(private readonly limit: number) {}\n\n private fail(bytes: number, what: string): never {\n throw new VdbFormatError(\n `decoding ${what} needs ${bytes} bytes, past the point grid's ${this.limit}-byte output budget ` +\n `(${MAX_POINT_EXPANSION} x the file size; ${this.used} bytes already used)`,\n );\n }\n\n /** Reserves `bytes` for an allocation that lives until the decode ends. */\n charge(bytes: number, what: string): void {\n if (bytes > this.limit - this.used) this.fail(bytes, what);\n this.used += bytes;\n }\n\n /** Checks a short-lived allocation against the budget left. */\n check(bytes: number, what: string): void {\n if (bytes > this.limit - this.used) this.fail(bytes, what);\n }\n}\n\ninterface DecodeContext {\n budget: DecodeBudget;\n /** Decoded Blosc pages, shared by the arrays they hold; dropped when the decode ends. */\n pages: Map<PointPage, Uint8Array>;\n}\n\n/** The array's stored bytes (decompressed), checked to be exactly `expectedBytes`. */\nfunction arrayBytes(\n array: PointArrayData,\n expectedBytes: number,\n ctx: DecodeContext,\n): { bytes: Uint8Array; offset: number } {\n if (array.isPaged) {\n if (array.bytes !== expectedBytes) {\n throw new VdbFormatError(`paged point attribute holds ${array.bytes} bytes, expected ${expectedBytes}`);\n }\n const page = array.page;\n if (!page?.data) throw new VdbFormatError(\"paged point attribute has no page body\");\n let decoded = page.compressedBytes > 0 ? ctx.pages.get(page) : page.data;\n if (!decoded) {\n ctx.budget.charge(Math.max(page.uncompressedBytes, BLOSC_PAD_BYTES), \"a point attribute page\");\n decoded = decompressExact(page.data, page.uncompressedBytes, \"point attribute page\");\n ctx.pages.set(page, decoded);\n }\n if (array.pageOffset + expectedBytes > decoded.length) {\n throw new VdbFormatError(`paged point attribute runs past its ${decoded.length}-byte page`);\n }\n return { bytes: decoded, offset: array.pageOffset };\n }\n if (!array.raw) throw new VdbFormatError(\"point attribute has no buffer\");\n if (array.bloscCompressed) {\n ctx.budget.check(expectedBytes, \"a point attribute buffer\");\n return { bytes: decompressExact(array.raw, expectedBytes, \"point attribute\"), offset: 0 };\n }\n if (array.raw.length !== expectedBytes) {\n throw new VdbFormatError(`point attribute holds ${array.raw.length} bytes, expected ${expectedBytes}`);\n }\n return { bytes: array.raw, offset: 0 };\n}\n\n/** Sorted attribute indices of the group arrays (`Descriptor::groupIndex`). */\nfunction groupArrayIndices(descriptor: PointDescriptor): number[] {\n return descriptor.attributes\n .filter((a) => a.type === \"uint8\" && a.codec === \"grp\")\n .map((a) => a.index)\n .sort((a, b) => a - b);\n}\n\nexport interface DecodePointsOptions {\n /**\n * Upper bound on the bytes the decode may allocate (outputs plus decoded\n * pages). The parser passes {@link MAX_POINT_EXPANSION} times the file size.\n * Default: unlimited.\n */\n maxOutputBytes?: number;\n /** Called after each leaf with the points decoded so far and the total (G14a). */\n onProgress?: (decoded: number, total: number) => void;\n}\n\n/**\n * Decodes the points of a parsed point data grid: world-space positions from\n * `P` (through `matrix`, a row-major 4x4 index->world transform) and every\n * other attribute the codec table covers.\n */\nexport function decodePoints(\n leaves: readonly PointLeafData[],\n matrix: readonly number[],\n options: DecodePointsOptions = {},\n): VdbPointList {\n const ctx: DecodeContext = {\n budget: new DecodeBudget(options.maxOutputBytes ?? Number.POSITIVE_INFINITY),\n pages: new Map(),\n };\n let count = 0;\n for (const leaf of leaves) count += leaf.offsets[LEAF_NUM_VALUES - 1]!;\n\n ctx.budget.charge(count * POSITION_BYTES, \"point positions\");\n const positions = new Float32Array(count * 3);\n const attributes: Record<string, VdbPointAttributeArray> = {};\n const attributeShapes: Record<string, { components: number; stride: number }> = {};\n const groups: Record<string, Uint8Array> = {};\n const skipped: VdbPointAttributeInfo[] = [];\n const skippedNames = new Set<string>();\n const skip = (info: VdbPointAttributeInfo): void => {\n if (skippedNames.has(info.name)) return;\n skippedNames.add(info.name);\n skipped.push(info);\n };\n\n const m = matrix;\n let base = 0;\n for (const leaf of leaves) {\n const leafCount = leaf.offsets[LEAF_NUM_VALUES - 1]!;\n const { descriptor, arrays } = leaf;\n\n // Positions: voxel ijk + P offset, then index -> world.\n const pInfo = descriptor.attributes.find((a) => a.name === \"P\");\n // f32 offsets (every OpenVDB P codec but vec3d/null) decode in place into\n // `positions`, then each point is transformed over its own offset.\n let p: ArrayLike<number> | null = null;\n let pAt = 0;\n if (pInfo) {\n const codec = attributeCodec(pInfo.type, pInfo.codec);\n if (!codec || codec.components !== 3) {\n throw new VDBUnsupportedError(`point position attribute P is ${pInfo.type}/${pInfo.codec}`);\n }\n if (codec.output === Float32Array) {\n decodeArrayInto(arrays[pInfo.index]!, codec, leafCount, pInfo, ctx, positions, base * 3);\n p = positions;\n pAt = base * 3;\n } else {\n ctx.budget.check(leafCount * 3 * codec.output.BYTES_PER_ELEMENT, \"a leaf's point offsets\");\n const offsets = new codec.output(leafCount * 3);\n decodeArrayInto(arrays[pInfo.index]!, codec, leafCount, pInfo, ctx, offsets, 0);\n p = offsets as ArrayLike<number>;\n }\n }\n let voxel = 0;\n for (let i = 0; i < leafCount; i++) {\n while (leaf.offsets[voxel]! <= i) voxel++;\n const ix = leaf.origin[0] + (voxel >> (2 * LEAF_LOG2DIM));\n const iy = leaf.origin[1] + ((voxel >> LEAF_LOG2DIM) & 7);\n const iz = leaf.origin[2] + (voxel & 7);\n const x = ix + (p ? p[pAt + i * 3]! : 0);\n const y = iy + (p ? p[pAt + i * 3 + 1]! : 0);\n const z = iz + (p ? p[pAt + i * 3 + 2]! : 0);\n const out = (base + i) * 3;\n positions[out] = m[0]! * x + m[1]! * y + m[2]! * z + m[3]!;\n positions[out + 1] = m[4]! * x + m[5]! * y + m[6]! * z + m[7]!;\n positions[out + 2] = m[8]! * x + m[9]! * y + m[10]! * z + m[11]!;\n }\n\n // Other attributes, decoded straight into the grid-wide output.\n for (const info of descriptor.attributes) {\n if (info.name === \"P\" || (info.type === \"uint8\" && info.codec === \"grp\")) continue;\n const codec = attributeCodec(info.type, info.codec);\n const array = arrays[info.index]!;\n const stride = arrayStride(array);\n if (!codec || stride === null) {\n skip(info);\n continue;\n }\n let target = attributes[info.name];\n const shape = attributeShapes[info.name];\n if (!target) {\n const length = count * stride * codec.components;\n ctx.budget.charge(length * codec.output.BYTES_PER_ELEMENT, `point attribute \"${info.name}\"`);\n target = new codec.output(length);\n attributes[info.name] = target;\n attributeShapes[info.name] = { components: codec.components, stride };\n } else if (\n !shape ||\n shape.components !== codec.components ||\n shape.stride !== stride ||\n target.constructor !== codec.output\n ) {\n throw new VDBUnsupportedError(`point attribute \"${info.name}\" changes type between leaves`);\n }\n decodeArrayInto(array, codec, leafCount * stride, info, ctx, target, base * stride * codec.components);\n }\n\n // Groups: one bit per point in the uint8 group arrays (`Descriptor::groupIndex`).\n if (descriptor.groups.length > 0) {\n const groupArrays = groupArrayIndices(descriptor);\n const decodedGroups = new Map<number, Uint8Array>();\n const uint8 = attributeCodec(\"uint8\", \"null\")!;\n for (const { name, offset } of descriptor.groups) {\n if (offset >= groupArrays.length * 8) {\n throw new VdbFormatError(`point group \"${name}\" offset ${offset} is out of range`);\n }\n const arrayIndex = groupArrays[Math.floor(offset / 8)]!;\n let bits = decodedGroups.get(arrayIndex);\n if (!bits) {\n ctx.budget.check(leafCount, \"a leaf's group bits\");\n bits = new Uint8Array(leafCount);\n decodeArrayInto(arrays[arrayIndex]!, uint8, leafCount, descriptor.attributes[arrayIndex]!, ctx, bits, 0);\n decodedGroups.set(arrayIndex, bits);\n }\n let target = groups[name];\n if (!target) {\n ctx.budget.charge(count, `point group \"${name}\"`);\n target = groups[name] = new Uint8Array(count);\n }\n const bit = offset % 8;\n for (let i = 0; i < leafCount; i++) target[base + i] = (bits[i]! >> bit) & 1;\n }\n }\n\n base += leafCount;\n options.onProgress?.(base, count);\n }\n if (leaves.length === 0) options.onProgress?.(0, 0);\n\n return { count, positions, attributes, attributeShapes, groups, skipped };\n}\n\n/**\n * Decodes `elements` elements of one leaf array into `out` from `outAt` (a\n * uniform array repeats its single value). The array's size and stride are\n * checked before any byte is read.\n */\nfunction decodeArrayInto(\n array: PointArrayData,\n codec: AttributeCodec,\n elements: number,\n info: VdbPointAttributeInfo,\n ctx: DecodeContext,\n out: VdbPointAttributeArray,\n outAt: number,\n): void {\n const stride = arrayStride(array) ?? 1;\n if (array.size * stride !== elements) {\n throw new VdbFormatError(\n `point attribute \"${info.name}\" holds ${array.size} x ${stride} values, but the leaf has ${elements / stride} points`,\n );\n }\n const stored = array.isUniform ? 1 : elements;\n const storedBytes = stored * codec.storageBytes;\n const { bytes, offset } = arrayBytes(array, storedBytes, ctx);\n const view = new DataView(bytes.buffer, bytes.byteOffset + offset, storedBytes);\n for (let i = 0; i < elements; i++) {\n codec.decode(view, array.isUniform ? 0 : i * codec.storageBytes, out, outAt + i * codec.components);\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * transform.ts — `GridDescriptor`'s `Map` (the index<->world affine
3
+ * transform), per `GridTransform.js`'s `readTransform` and `vdb-rs`'s
4
+ * `read_transform` (both agree on field order: translation, scale,
5
+ * voxelSize, scaleInverse, scaleInverseSq, scaleInverseDouble — each a
6
+ * vec3d — for the translate-bearing maps; the no-translation maps drop the
7
+ * leading `translation` read).
8
+ *
9
+ * Only axis-aligned maps are supported (uniform/non-uniform scale + optional
10
+ * translate) — the samples in this corpus use `UniformScaleTranslateMap`.
11
+ * Rotated/sheared maps (`UnitaryMap`, `NonlinearFrustumMap`, general 4x4
12
+ * `AffineMap`) are out of scope (per the Phase 3 handoff's note that
13
+ * `NanoVDBGrid.indexToWorld()` is axis-aligned-only today) and raise
14
+ * `VDBUnsupportedError`.
15
+ */
16
+ import type { ByteReader } from "./byte-reader.js";
17
+ export interface VdbTransform {
18
+ type: string;
19
+ /** 4x4 row-major index->world affine matrix. */
20
+ matrix: number[];
21
+ voxelSize: [number, number, number];
22
+ }
23
+ export declare function readTransform(reader: ByteReader): VdbTransform;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * transform.ts — `GridDescriptor`'s `Map` (the index<->world affine
3
+ * transform), per `GridTransform.js`'s `readTransform` and `vdb-rs`'s
4
+ * `read_transform` (both agree on field order: translation, scale,
5
+ * voxelSize, scaleInverse, scaleInverseSq, scaleInverseDouble — each a
6
+ * vec3d — for the translate-bearing maps; the no-translation maps drop the
7
+ * leading `translation` read).
8
+ *
9
+ * Only axis-aligned maps are supported (uniform/non-uniform scale + optional
10
+ * translate) — the samples in this corpus use `UniformScaleTranslateMap`.
11
+ * Rotated/sheared maps (`UnitaryMap`, `NonlinearFrustumMap`, general 4x4
12
+ * `AffineMap`) are out of scope (per the Phase 3 handoff's note that
13
+ * `NanoVDBGrid.indexToWorld()` is axis-aligned-only today) and raise
14
+ * `VDBUnsupportedError`.
15
+ */
16
+ import { VDBUnsupportedError } from "./errors.js";
17
+ const IDENTITY_VEC3 = [0, 0, 0];
18
+ function toMatrix(scale, translation) {
19
+ const [sx, sy, sz] = scale;
20
+ const [tx, ty, tz] = translation;
21
+ // prettier-ignore
22
+ return [
23
+ sx, 0, 0, tx,
24
+ 0, sy, 0, ty,
25
+ 0, 0, sz, tz,
26
+ 0, 0, 0, 1,
27
+ ];
28
+ }
29
+ export function readTransform(reader) {
30
+ const mapType = reader.string();
31
+ if (mapType === "UniformScaleTranslateMap" || mapType === "ScaleTranslateMap") {
32
+ const translation = reader.vec3d();
33
+ const scale = reader.vec3d();
34
+ const voxelSize = reader.vec3d();
35
+ reader.vec3d(); // scaleInverse (unused — derivable, kept for stream alignment)
36
+ reader.vec3d(); // scaleInverseSq
37
+ reader.vec3d(); // scaleInverseDouble
38
+ return { type: mapType, matrix: toMatrix(scale, translation), voxelSize };
39
+ }
40
+ if (mapType === "UniformScaleMap" || mapType === "ScaleMap") {
41
+ const scale = reader.vec3d();
42
+ const voxelSize = reader.vec3d();
43
+ reader.vec3d(); // scaleInverse
44
+ reader.vec3d(); // scaleInverseSq
45
+ reader.vec3d(); // scaleInverseDouble
46
+ return { type: mapType, matrix: toMatrix(scale, IDENTITY_VEC3), voxelSize };
47
+ }
48
+ if (mapType === "TranslationMap") {
49
+ const translation = reader.vec3d();
50
+ return { type: mapType, matrix: toMatrix([1, 1, 1], translation), voxelSize: [1, 1, 1] };
51
+ }
52
+ throw new VDBUnsupportedError(`transform map type "${mapType}" (only Uniform/ScaleTranslateMap, Uniform/ScaleMap, TranslationMap are supported — rotated/sheared/frustum maps need the loader to surface the raw Map, per the Phase 3 handoff)`);
53
+ }
54
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/tools/vdb/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AASlD,MAAM,aAAa,GAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE1D,SAAS,QAAQ,CACf,KAA+B,EAC/B,WAAqC;IAErC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC;IAC3B,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC;IACjC,kBAAkB;IAClB,OAAO;QACL,EAAE,EAAE,CAAC,EAAG,CAAC,EAAG,EAAE;QACd,CAAC,EAAG,EAAE,EAAE,CAAC,EAAG,EAAE;QACd,CAAC,EAAG,CAAC,EAAG,EAAE,EAAE,EAAE;QACd,CAAC,EAAG,CAAC,EAAG,CAAC,EAAG,CAAC;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;IAEhC,IA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,EAAE,CAAC,CAAC,EAAE,CAAC;IAC3F,CAAC;IAED,MAAM,IAAI,mBAAmB,CAC3B,uBAAuB,OAAO,mLAAmL,CAClN,CAAC;AACJ,CAAC","sourcesContent":["/**\n * transform.ts — `GridDescriptor`'s `Map` (the index<->world affine\n * transform), per `GridTransform.js`'s `readTransform` and `vdb-rs`'s\n * `read_transform` (both agree on field order: translation, scale,\n * voxelSize, scaleInverse, scaleInverseSq, scaleInverseDouble — each a\n * vec3d — for the translate-bearing maps; the no-translation maps drop the\n * leading `translation` read).\n *\n * Only axis-aligned maps are supported (uniform/non-uniform scale + optional\n * translate) — the samples in this corpus use `UniformScaleTranslateMap`.\n * Rotated/sheared maps (`UnitaryMap`, `NonlinearFrustumMap`, general 4x4\n * `AffineMap`) are out of scope (per the Phase 3 handoff's note that\n * `NanoVDBGrid.indexToWorld()` is axis-aligned-only today) and raise\n * `VDBUnsupportedError`.\n */\n\nimport type { ByteReader } from \"./byte-reader.js\";\nimport { VDBUnsupportedError } from \"./errors.js\";\n\nexport interface VdbTransform {\n type: string;\n /** 4x4 row-major index->world affine matrix. */\n matrix: number[];\n voxelSize: [number, number, number];\n}\n\nconst IDENTITY_VEC3: [number, number, number] = [0, 0, 0];\n\nfunction toMatrix(\n scale: [number, number, number],\n translation: [number, number, number],\n): number[] {\n const [sx, sy, sz] = scale;\n const [tx, ty, tz] = translation;\n // prettier-ignore\n return [\n sx, 0, 0, tx,\n 0, sy, 0, ty,\n 0, 0, sz, tz,\n 0, 0, 0, 1,\n ];\n}\n\nexport function readTransform(reader: ByteReader): VdbTransform {\n const mapType = reader.string();\n\n if (mapType === \"UniformScaleTranslateMap\" || mapType === \"ScaleTranslateMap\") {\n const translation = reader.vec3d();\n const scale = reader.vec3d();\n const voxelSize = reader.vec3d();\n reader.vec3d(); // scaleInverse (unused — derivable, kept for stream alignment)\n reader.vec3d(); // scaleInverseSq\n reader.vec3d(); // scaleInverseDouble\n return { type: mapType, matrix: toMatrix(scale, translation), voxelSize };\n }\n\n if (mapType === \"UniformScaleMap\" || mapType === \"ScaleMap\") {\n const scale = reader.vec3d();\n const voxelSize = reader.vec3d();\n reader.vec3d(); // scaleInverse\n reader.vec3d(); // scaleInverseSq\n reader.vec3d(); // scaleInverseDouble\n return { type: mapType, matrix: toMatrix(scale, IDENTITY_VEC3), voxelSize };\n }\n\n if (mapType === \"TranslationMap\") {\n const translation = reader.vec3d();\n return { type: mapType, matrix: toMatrix([1, 1, 1], translation), voxelSize: [1, 1, 1] };\n }\n\n throw new VDBUnsupportedError(\n `transform map type \"${mapType}\" (only Uniform/ScaleTranslateMap, Uniform/ScaleMap, TranslationMap are supported — rotated/sheared/frustum maps need the loader to surface the raw Map, per the Phase 3 handoff)`,\n );\n}\n"]}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * tree.ts — the 5-4-3 tree: root -> upper (32^3 slots, log2dim 5) -> lower
3
+ * (16^3 slots, log2dim 4) -> leaf (8^3 voxels, log2dim 3).
4
+ *
5
+ * Two-phase read, per both format references (and matching real OpenVDB's
6
+ * `Tree::readTopology`/`Tree::readBuffers` split):
7
+ * 1. **Topology** (single recursive pass): root tiles/children; each
8
+ * upper/lower node's `(childMask, valueMask, tileValues)` inline (file
9
+ * version >= 214, "internal-node compression" — always true for our
10
+ * 218-224 window); each leaf's `valueMask` ONLY (its value buffer is
11
+ * deferred).
12
+ * 2. **Buffers** (second pass, same recursion order, leaves only): each
13
+ * leaf re-serializes its `valueMask` (a genuine on-disk quirk — OpenVDB's
14
+ * `LeafNode::writeBuffers` re-saves the mask right before the buffer;
15
+ * confirmed against `vdb-rs`'s `read_tree_data`, which does the same
16
+ * double read) followed by its compressed voxel values.
17
+ *
18
+ * The `mjurczyk/openvdb` JS reader (this repo's other reference) never
19
+ * actually implements leaf value decoding — `ChildNode.readValues()` returns
20
+ * early for leaves with a mask-derived 0/1 placeholder array and
21
+ * `GridDescriptor.readBuffers()` is a bare `// TODO`. That's fine for its
22
+ * boolean-active demos but useless for real voxel data, which is the whole
23
+ * point of this parser (handing Phase 5b's serializer real floats) — the
24
+ * two-phase buffer reading here is lifted from `vdb-rs` instead.
25
+ *
26
+ * ## Active tiles (K4.1)
27
+ *
28
+ * Root, upper and lower nodes may hold *active tiles*: a slot whose child bit
29
+ * is clear and whose value-mask bit is set stands for a uniform, active block
30
+ * of `childDim^3` voxels (lower slot: one 8^3 leaf; upper slot: one 128^3 lower
31
+ * node; root tile: one 4096^3 upper node). They are read from the formats'
32
+ * own topology fields (OpenVDB `RootNode::readTopology` /
33
+ * `InternalNode::readTopology`) and returned as {@link TileData}, so
34
+ * `buildFromVdb` can emit them as NanoVDB tiles rather than expanding them.
35
+ * Inactive tiles are kept too (K4.9): `active: false`, with their stored value
36
+ * (a level set's interior reads `-background`). Internal-node inactive tiles
37
+ * equal to the background are skipped, as they read identically to no tile.
38
+ *
39
+ * ## Value types and point data (K4.2)
40
+ *
41
+ * Values follow the grid's {@link ValueFormat} (float, vec3s/vec3d/vec3i, or
42
+ * `PointDataIndex32` for point data grids): the root background and root
43
+ * tile values are full-width `ValueType`s, internal-node and leaf arrays go
44
+ * through `readCompressedValues`, `components` scalars per value. Point data
45
+ * grids write their leaf buffers in passes; `points.ts` reads those.
46
+ *
47
+ * Scope limits (throw `VDBUnsupportedError`, not silently wrong data):
48
+ * multi-buffer trees.
49
+ */
50
+ import type { ByteReader } from "./byte-reader.js";
51
+ import type { CompressionFlags, ValueFormat } from "./compression.js";
52
+ import { type PointLeafData } from "./points.js";
53
+ export declare const LEAF_LOG2DIM = 3;
54
+ export declare const LOWER_LOG2DIM = 4;
55
+ export declare const UPPER_LOG2DIM = 5;
56
+ export declare const LEAF_DIM: number;
57
+ export declare const LEAF_NUM_VALUES: number;
58
+ /** Edge length, in voxels, of an active tile at each level. */
59
+ export declare const LOWER_TILE_DIM = 8;
60
+ export declare const UPPER_TILE_DIM = 128;
61
+ export declare const ROOT_TILE_DIM = 4096;
62
+ export interface LeafData {
63
+ origin: [number, number, number];
64
+ values: Float32Array;
65
+ valueMask: Uint32Array;
66
+ }
67
+ /**
68
+ * One tile above leaf level: `dim^3` voxels, all `value`. Active tiles have their
69
+ * value-mask bit set. Inactive tiles (K4.9) keep a stored value, e.g. a level
70
+ * set's interior `-background`; internal-node inactive tiles whose value equals
71
+ * the background are not kept (they read the same as no tile).
72
+ */
73
+ export interface TileData {
74
+ /** Index-space min corner, a multiple of `dim`. */
75
+ origin: [number, number, number];
76
+ /** Edge length in voxels: 8 (lower-node tile), 128 (upper-node tile) or 4096 (root tile). */
77
+ dim: 8 | 128 | 4096;
78
+ /** The tile value, `components` scalars. */
79
+ value: number[];
80
+ /** True for an active tile, false for an inactive tile with a stored value. */
81
+ active: boolean;
82
+ }
83
+ export interface TreeReadResult {
84
+ /** The background value, `components` scalars. */
85
+ background: number[];
86
+ leaves: LeafData[];
87
+ /** Point data grids only: per-leaf attribute data, in `leaves` order. */
88
+ pointLeaves?: PointLeafData[];
89
+ /** Point data grids only: the most `points()` may allocate (a multiple of the file size). */
90
+ pointOutputBudget?: number;
91
+ /** Tiles at root, upper and lower level: active ones and inactive ones with a non-background value (root: all). */
92
+ tiles: TileData[];
93
+ /** Active voxels in leaves plus `dim^3` per active tile. */
94
+ activeVoxelCount: number;
95
+ }
96
+ export interface LeafPlaceholder {
97
+ origin: [number, number, number];
98
+ }
99
+ export interface TreeReadOptions {
100
+ fileVersion: number;
101
+ compression: CompressionFlags;
102
+ useHalf: boolean;
103
+ /** The grid's value layout. Default: float. */
104
+ format?: ValueFormat;
105
+ /**
106
+ * A `PointDataGrid`: leaf buffers are written in passes (OpenVDB
107
+ * `Grid::readBuffers` with `io::MultiPass`) and hold attribute arrays.
108
+ */
109
+ pointData?: boolean;
110
+ }
111
+ export declare function readTree(reader: ByteReader, options: TreeReadOptions): TreeReadResult;
@@ -0,0 +1,228 @@
1
+ /**
2
+ * tree.ts — the 5-4-3 tree: root -> upper (32^3 slots, log2dim 5) -> lower
3
+ * (16^3 slots, log2dim 4) -> leaf (8^3 voxels, log2dim 3).
4
+ *
5
+ * Two-phase read, per both format references (and matching real OpenVDB's
6
+ * `Tree::readTopology`/`Tree::readBuffers` split):
7
+ * 1. **Topology** (single recursive pass): root tiles/children; each
8
+ * upper/lower node's `(childMask, valueMask, tileValues)` inline (file
9
+ * version >= 214, "internal-node compression" — always true for our
10
+ * 218-224 window); each leaf's `valueMask` ONLY (its value buffer is
11
+ * deferred).
12
+ * 2. **Buffers** (second pass, same recursion order, leaves only): each
13
+ * leaf re-serializes its `valueMask` (a genuine on-disk quirk — OpenVDB's
14
+ * `LeafNode::writeBuffers` re-saves the mask right before the buffer;
15
+ * confirmed against `vdb-rs`'s `read_tree_data`, which does the same
16
+ * double read) followed by its compressed voxel values.
17
+ *
18
+ * The `mjurczyk/openvdb` JS reader (this repo's other reference) never
19
+ * actually implements leaf value decoding — `ChildNode.readValues()` returns
20
+ * early for leaves with a mask-derived 0/1 placeholder array and
21
+ * `GridDescriptor.readBuffers()` is a bare `// TODO`. That's fine for its
22
+ * boolean-active demos but useless for real voxel data, which is the whole
23
+ * point of this parser (handing Phase 5b's serializer real floats) — the
24
+ * two-phase buffer reading here is lifted from `vdb-rs` instead.
25
+ *
26
+ * ## Active tiles (K4.1)
27
+ *
28
+ * Root, upper and lower nodes may hold *active tiles*: a slot whose child bit
29
+ * is clear and whose value-mask bit is set stands for a uniform, active block
30
+ * of `childDim^3` voxels (lower slot: one 8^3 leaf; upper slot: one 128^3 lower
31
+ * node; root tile: one 4096^3 upper node). They are read from the formats'
32
+ * own topology fields (OpenVDB `RootNode::readTopology` /
33
+ * `InternalNode::readTopology`) and returned as {@link TileData}, so
34
+ * `buildFromVdb` can emit them as NanoVDB tiles rather than expanding them.
35
+ * Inactive tiles are kept too (K4.9): `active: false`, with their stored value
36
+ * (a level set's interior reads `-background`). Internal-node inactive tiles
37
+ * equal to the background are skipped, as they read identically to no tile.
38
+ *
39
+ * ## Value types and point data (K4.2)
40
+ *
41
+ * Values follow the grid's {@link ValueFormat} (float, vec3s/vec3d/vec3i, or
42
+ * `PointDataIndex32` for point data grids): the root background and root
43
+ * tile values are full-width `ValueType`s, internal-node and leaf arrays go
44
+ * through `readCompressedValues`, `components` scalars per value. Point data
45
+ * grids write their leaf buffers in passes; `points.ts` reads those.
46
+ *
47
+ * Scope limits (throw `VDBUnsupportedError`, not silently wrong data):
48
+ * multi-buffer trees.
49
+ */
50
+ import { countBits, countZeroBits, iterOnes, testBit } from "./bit-utils.js";
51
+ import { FLOAT_FORMAT, readCompressedValues, readFullValue } from "./compression.js";
52
+ import { VdbFormatError, VDBUnsupportedError } from "./errors.js";
53
+ import { MAX_POINT_EXPANSION, readPointDataBuffers } from "./points.js";
54
+ export const LEAF_LOG2DIM = 3;
55
+ export const LOWER_LOG2DIM = 4;
56
+ export const UPPER_LOG2DIM = 5;
57
+ export const LEAF_DIM = 1 << LEAF_LOG2DIM; // 8
58
+ export const LEAF_NUM_VALUES = 1 << (3 * LEAF_LOG2DIM); // 512
59
+ const LOWER_NUM_VALUES = 1 << (3 * LOWER_LOG2DIM); // 4096
60
+ const UPPER_NUM_VALUES = 1 << (3 * UPPER_LOG2DIM); // 32768
61
+ const LOWER_TOTAL = LEAF_LOG2DIM; // 3
62
+ const UPPER_TOTAL = LEAF_LOG2DIM + LOWER_LOG2DIM; // 7
63
+ /** Edge length, in voxels, of an active tile at each level. */
64
+ export const LOWER_TILE_DIM = 8; // 1 << LOWER_TOTAL: a lower-node tile covers one leaf
65
+ export const UPPER_TILE_DIM = 128; // 1 << UPPER_TOTAL: an upper-node tile covers one lower node
66
+ export const ROOT_TILE_DIM = 4096; // 1 << (3 + 4 + 5): a root tile covers one upper node
67
+ function offsetToLocalCoord(offset, log2dim) {
68
+ const x = offset >> (2 * log2dim);
69
+ const rem = offset & ((1 << (2 * log2dim)) - 1);
70
+ const y = rem >> log2dim;
71
+ const z = rem & ((1 << log2dim) - 1);
72
+ return [x, y, z];
73
+ }
74
+ function offsetToGlobalCoord(offset, log2dim, total, origin) {
75
+ const [lx, ly, lz] = offsetToLocalCoord(offset, log2dim);
76
+ return [origin[0] + (lx << total), origin[1] + (ly << total), origin[2] + (lz << total)];
77
+ }
78
+ /**
79
+ * Reads `(childMask, valueMask, tileValues)` for an upper/lower node and
80
+ * appends every active tile (child bit clear, value bit set) to `ctx.tiles`.
81
+ *
82
+ * Tile-value layout follows OpenVDB `InternalNode::readTopology`: from file
83
+ * version 222 (node-mask compression) the stream holds a value for every slot,
84
+ * indexed by slot; before 222 it holds one value per child-*off* slot, packed
85
+ * in slot order.
86
+ */
87
+ function readInternalNodeTopology(ctx, origin, log2dim, childTotal, fullNumValues) {
88
+ const childMask = ctx.reader.maskWords(fullNumValues);
89
+ const valueMask = ctx.reader.maskWords(fullNumValues);
90
+ const packed = ctx.fileVersion < 222;
91
+ const numValuesForStream = packed ? countZeroBits(childMask, fullNumValues) : fullNumValues;
92
+ const values = readCompressedValues(ctx.reader, {
93
+ fileVersion: ctx.fileVersion,
94
+ compression: ctx.compression,
95
+ useHalf: ctx.useHalf,
96
+ background: ctx.background,
97
+ numValues: numValuesForStream,
98
+ valueMask,
99
+ format: ctx.format,
100
+ });
101
+ const comps = ctx.format.components;
102
+ const dim = (1 << childTotal);
103
+ let packedIdx = 0;
104
+ for (let i = 0; i < fullNumValues; i++) {
105
+ if (testBit(childMask, i))
106
+ continue;
107
+ const at = (packed ? packedIdx++ : i) * comps;
108
+ const active = testBit(valueMask, i);
109
+ const value = Array.from(values.subarray(at, at + comps));
110
+ // An inactive tile holding the background reads exactly like no tile.
111
+ if (!active && value.every((v, c) => v === ctx.background[c]))
112
+ continue;
113
+ ctx.tiles.push({ origin: offsetToGlobalCoord(i, log2dim, childTotal, origin), dim, value, active });
114
+ }
115
+ return { childMask, valueMask };
116
+ }
117
+ function readLowerTopology(ctx, origin) {
118
+ const { childMask } = readInternalNodeTopology(ctx, origin, LOWER_LOG2DIM, LOWER_TOTAL, LOWER_NUM_VALUES);
119
+ const leaves = new Map();
120
+ for (const idx of iterOnes(childMask, LOWER_NUM_VALUES)) {
121
+ const leafOrigin = offsetToGlobalCoord(idx, LOWER_LOG2DIM, LOWER_TOTAL, origin);
122
+ // Leaf topology: value mask only, no child mask, no data (deferred).
123
+ ctx.reader.maskWords(LEAF_NUM_VALUES);
124
+ leaves.set(idx, { origin: leafOrigin });
125
+ }
126
+ return { origin, childMask, leaves };
127
+ }
128
+ function readUpperTopology(ctx, origin) {
129
+ const { childMask } = readInternalNodeTopology(ctx, origin, UPPER_LOG2DIM, UPPER_TOTAL, UPPER_NUM_VALUES);
130
+ const lowers = new Map();
131
+ for (const idx of iterOnes(childMask, UPPER_NUM_VALUES)) {
132
+ const lowerOrigin = offsetToGlobalCoord(idx, UPPER_LOG2DIM, UPPER_TOTAL, origin);
133
+ lowers.set(idx, readLowerTopology(ctx, lowerOrigin));
134
+ }
135
+ return { origin, childMask, lowers };
136
+ }
137
+ function readLeafBuffer(ctx, placeholder) {
138
+ // The value mask is re-serialized immediately before the buffer data — a
139
+ // real on-disk quirk of LeafNode::writeBuffers, not a bug in this reader.
140
+ const valueMask = ctx.reader.maskWords(LEAF_NUM_VALUES);
141
+ // Before v222 the origin and a buffer count follow the mask
142
+ // (OpenVDB `LeafNode::readBuffers`).
143
+ if (ctx.fileVersion < 222) {
144
+ ctx.reader.vec3i(); // origin (redundant with topology-derived origin)
145
+ const numBuffers = ctx.reader.u8();
146
+ if (numBuffers !== 1) {
147
+ throw new VdbFormatError(`leaf node numBuffers ${numBuffers} !== 1 (multi-buffer leaves unsupported)`);
148
+ }
149
+ }
150
+ const values = readCompressedValues(ctx.reader, {
151
+ fileVersion: ctx.fileVersion,
152
+ compression: ctx.compression,
153
+ useHalf: ctx.useHalf,
154
+ background: ctx.background,
155
+ numValues: LEAF_NUM_VALUES,
156
+ valueMask,
157
+ format: ctx.format,
158
+ });
159
+ return { origin: placeholder.origin, values, valueMask };
160
+ }
161
+ export function readTree(reader, options) {
162
+ const bufferCount = reader.u32();
163
+ if (bufferCount !== 1) {
164
+ throw new VDBUnsupportedError(`multi-buffer trees are not supported (bufferCount=${bufferCount})`);
165
+ }
166
+ // RootNode::readTopology: the background is a full-width ValueType.
167
+ const format = options.format ?? FLOAT_FORMAT;
168
+ const background = readFullValue(reader, format);
169
+ const tiles = [];
170
+ const ctx = {
171
+ reader,
172
+ fileVersion: options.fileVersion,
173
+ compression: options.compression,
174
+ useHalf: options.useHalf,
175
+ format,
176
+ background,
177
+ tiles,
178
+ };
179
+ const numTiles = reader.u32();
180
+ const numRootChildren = reader.u32();
181
+ // Root tiles: origin, value (always full-width ValueType, never half — see
182
+ // OpenVDB `RootNode::readTopology`), active flag. Inactive tiles are kept (K4.9).
183
+ for (let i = 0; i < numTiles; i++) {
184
+ const origin = reader.vec3i();
185
+ const value = readFullValue(reader, format);
186
+ const active = reader.bool();
187
+ if (origin.some((c) => c % ROOT_TILE_DIM !== 0)) {
188
+ throw new VdbFormatError(`root tile origin [${origin.join(", ")}] is not ${ROOT_TILE_DIM}-aligned`);
189
+ }
190
+ tiles.push({ origin, dim: ROOT_TILE_DIM, value, active });
191
+ }
192
+ const uppers = [];
193
+ for (let i = 0; i < numRootChildren; i++) {
194
+ const origin = reader.vec3i();
195
+ uppers.push(readUpperTopology(ctx, origin));
196
+ }
197
+ const placeholders = [];
198
+ for (const upper of uppers) {
199
+ for (const lower of upper.lowers.values()) {
200
+ for (const placeholder of lower.leaves.values())
201
+ placeholders.push(placeholder);
202
+ }
203
+ }
204
+ let leaves;
205
+ let pointLeaves;
206
+ if (options.pointData) {
207
+ // Compression is recorded per array (paged, Blosc flag), not taken from the grid.
208
+ pointLeaves = readPointDataBuffers(reader, { fileVersion: options.fileVersion, leaves: placeholders });
209
+ leaves = pointLeaves.map((p) => ({ origin: p.origin, values: Float32Array.from(p.offsets), valueMask: p.valueMask }));
210
+ }
211
+ else {
212
+ leaves = placeholders.map((placeholder) => readLeafBuffer(ctx, placeholder));
213
+ }
214
+ let activeVoxelCount = 0;
215
+ for (const leaf of leaves)
216
+ activeVoxelCount += countBits(leaf.valueMask);
217
+ for (const tile of tiles)
218
+ if (tile.active)
219
+ activeVoxelCount += tile.dim ** 3;
220
+ return {
221
+ background,
222
+ leaves,
223
+ tiles,
224
+ activeVoxelCount,
225
+ ...(pointLeaves ? { pointLeaves, pointOutputBudget: MAX_POINT_EXPANSION * reader.length } : {}),
226
+ };
227
+ }
228
+ //# sourceMappingURL=tree.js.map