@pmndrs/vdb 0.1.0 → 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 (576) hide show
  1. package/CHANGELOG.md +592 -2
  2. package/README.md +85 -37
  3. package/THIRD_PARTY_NOTICES.md +197 -29
  4. package/dist/core/compute/atlas.d.ts +10 -2
  5. package/dist/core/compute/atlas.js +6 -1
  6. package/dist/core/compute/atlas.js.map +1 -1
  7. package/dist/core/compute/index.d.ts +3 -3
  8. package/dist/core/compute/index.js +2 -2
  9. package/dist/core/compute/index.js.map +1 -1
  10. package/dist/core/compute/majorant-build.d.ts +45 -0
  11. package/dist/core/compute/majorant-build.js +193 -0
  12. package/dist/core/compute/majorant-build.js.map +1 -0
  13. package/dist/core/compute/multi-scale.d.ts +155 -0
  14. package/dist/core/compute/multi-scale.js +684 -0
  15. package/dist/core/compute/multi-scale.js.map +1 -0
  16. package/dist/core/compute/pyramid.d.ts +22 -7
  17. package/dist/core/compute/pyramid.js +22 -9
  18. package/dist/core/compute/pyramid.js.map +1 -1
  19. package/dist/core/compute/shared.d.ts +1 -0
  20. package/dist/core/compute/shared.js.map +1 -1
  21. package/dist/core/compute/stats.d.ts +10 -3
  22. package/dist/core/compute/stats.js +6 -1
  23. package/dist/core/compute/stats.js.map +1 -1
  24. package/dist/core/compute/value-transform.d.ts +8 -1
  25. package/dist/core/compute/value-transform.js +9 -3
  26. package/dist/core/compute/value-transform.js.map +1 -1
  27. package/dist/core/errors.d.ts +10 -0
  28. package/dist/core/errors.js +8 -0
  29. package/dist/core/errors.js.map +1 -1
  30. package/dist/core/frame/emission.d.ts +85 -0
  31. package/dist/core/frame/emission.js +422 -0
  32. package/dist/core/frame/emission.js.map +1 -0
  33. package/dist/core/frame/environment.d.ts +47 -0
  34. package/dist/core/frame/environment.js +178 -0
  35. package/dist/core/frame/environment.js.map +1 -0
  36. package/dist/core/frame/index.d.ts +39 -0
  37. package/dist/core/frame/index.js +27 -0
  38. package/dist/core/frame/index.js.map +1 -0
  39. package/dist/core/frame/kernels.d.ts +115 -0
  40. package/dist/core/frame/kernels.js +496 -0
  41. package/dist/core/frame/kernels.js.map +1 -0
  42. package/dist/core/frame/limits.d.ts +67 -0
  43. package/dist/core/frame/limits.js +109 -0
  44. package/dist/core/frame/limits.js.map +1 -0
  45. package/dist/core/frame/phase.d.ts +17 -0
  46. package/dist/core/frame/phase.js +53 -0
  47. package/dist/core/frame/phase.js.map +1 -0
  48. package/dist/core/frame/pipelines.d.ts +49 -0
  49. package/dist/core/frame/pipelines.js +147 -0
  50. package/dist/core/frame/pipelines.js.map +1 -0
  51. package/dist/core/frame/renderer.d.ts +122 -0
  52. package/dist/core/frame/renderer.js +1712 -0
  53. package/dist/core/frame/renderer.js.map +1 -0
  54. package/dist/core/frame/resources.d.ts +71 -0
  55. package/dist/core/frame/resources.js +100 -0
  56. package/dist/core/frame/resources.js.map +1 -0
  57. package/dist/core/frame/scattering.d.ts +97 -0
  58. package/dist/core/frame/scattering.js +332 -0
  59. package/dist/core/frame/scattering.js.map +1 -0
  60. package/dist/core/frame/settings.d.ts +243 -0
  61. package/dist/core/frame/settings.js +67 -0
  62. package/dist/core/frame/settings.js.map +1 -0
  63. package/dist/core/frame/shadows.d.ts +55 -0
  64. package/dist/core/frame/shadows.js +460 -0
  65. package/dist/core/frame/shadows.js.map +1 -0
  66. package/dist/core/frame/types.d.ts +415 -0
  67. package/dist/core/frame/types.js +49 -0
  68. package/dist/core/frame/types.js.map +1 -0
  69. package/dist/core/frame/uniforms.d.ts +105 -0
  70. package/dist/core/frame/uniforms.js +276 -0
  71. package/dist/core/frame/uniforms.js.map +1 -0
  72. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  73. package/dist/core/frame/wgsl/chunks.js +728 -0
  74. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  75. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  76. package/dist/core/frame/wgsl/emission.js +353 -0
  77. package/dist/core/frame/wgsl/emission.js.map +1 -0
  78. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  79. package/dist/core/frame/wgsl/environment.js +711 -0
  80. package/dist/core/frame/wgsl/environment.js.map +1 -0
  81. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  82. package/dist/core/frame/wgsl/gather.js +850 -0
  83. package/dist/core/frame/wgsl/gather.js.map +1 -0
  84. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  85. package/dist/core/frame/wgsl/integrate.js +213 -0
  86. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  87. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  88. package/dist/core/frame/wgsl/lighting.js +1636 -0
  89. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  90. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  91. package/dist/core/frame/wgsl/occluders.js +95 -0
  92. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  93. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  94. package/dist/core/frame/wgsl/resolve.js +205 -0
  95. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  96. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  97. package/dist/core/frame/wgsl/shadows.js +328 -0
  98. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  99. package/dist/core/half.d.ts +11 -0
  100. package/dist/core/half.js +22 -0
  101. package/dist/core/half.js.map +1 -0
  102. package/dist/core/index.d.ts +25 -3
  103. package/dist/core/index.js +23 -4
  104. package/dist/core/index.js.map +1 -1
  105. package/dist/core/internal.d.ts +17 -1
  106. package/dist/core/internal.js +18 -1
  107. package/dist/core/internal.js.map +1 -1
  108. package/dist/core/pool/image-header.d.ts +13 -2
  109. package/dist/core/pool/image-header.js +24 -5
  110. package/dist/core/pool/image-header.js.map +1 -1
  111. package/dist/core/pool/layout.d.ts +35 -1
  112. package/dist/core/pool/layout.js +51 -2
  113. package/dist/core/pool/layout.js.map +1 -1
  114. package/dist/core/pool/limits.d.ts +1 -0
  115. package/dist/core/pool/limits.js +1 -0
  116. package/dist/core/pool/limits.js.map +1 -1
  117. package/dist/core/pool/pool.d.ts +120 -15
  118. package/dist/core/pool/pool.js +255 -24
  119. package/dist/core/pool/pool.js.map +1 -1
  120. package/dist/core/reference/index.d.ts +6 -0
  121. package/dist/core/reference/index.js +7 -0
  122. package/dist/core/reference/index.js.map +1 -0
  123. package/dist/core/reference/renderer.d.ts +105 -0
  124. package/dist/core/reference/renderer.js +474 -0
  125. package/dist/core/reference/renderer.js.map +1 -0
  126. package/dist/core/reference/wgsl.d.ts +65 -0
  127. package/dist/core/reference/wgsl.js +803 -0
  128. package/dist/core/reference/wgsl.js.map +1 -0
  129. package/dist/{three → core}/sequence.d.ts +32 -2
  130. package/dist/{three → core}/sequence.js +24 -2
  131. package/dist/core/sequence.js.map +1 -0
  132. package/dist/core/source/brick-cache.d.ts +165 -0
  133. package/dist/core/source/brick-cache.js +627 -0
  134. package/dist/core/source/brick-cache.js.map +1 -0
  135. package/dist/core/source/dense-fill.d.ts +53 -0
  136. package/dist/core/source/dense-fill.js +377 -0
  137. package/dist/core/source/dense-fill.js.map +1 -0
  138. package/dist/core/source/dense.d.ts +33 -2
  139. package/dist/core/source/dense.js +121 -24
  140. package/dist/core/source/dense.js.map +1 -1
  141. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  142. package/dist/core/source/sparse-wgsl.js +481 -0
  143. package/dist/core/source/sparse-wgsl.js.map +1 -0
  144. package/dist/core/source/sparse.d.ts +192 -0
  145. package/dist/core/source/sparse.js +762 -0
  146. package/dist/core/source/sparse.js.map +1 -0
  147. package/dist/core/source/types.d.ts +59 -2
  148. package/dist/core/source/types.js.map +1 -1
  149. package/dist/core/surface/index.d.ts +10 -0
  150. package/dist/core/surface/index.js +9 -0
  151. package/dist/core/surface/index.js.map +1 -0
  152. package/dist/core/surface/level-set-pass.d.ts +140 -0
  153. package/dist/core/surface/level-set-pass.js +291 -0
  154. package/dist/core/surface/level-set-pass.js.map +1 -0
  155. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  156. package/dist/core/surface/level-set-wgsl.js +99 -0
  157. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  158. package/dist/core/surface/points.d.ts +109 -0
  159. package/dist/core/surface/points.js +226 -0
  160. package/dist/core/surface/points.js.map +1 -0
  161. package/dist/core/types.d.ts +12 -3
  162. package/dist/core/types.js +6 -2
  163. package/dist/core/types.js.map +1 -1
  164. package/dist/core/wgsl/api.d.ts +29 -5
  165. package/dist/core/wgsl/api.js +110 -27
  166. package/dist/core/wgsl/api.js.map +1 -1
  167. package/dist/core/wgsl/generate.d.ts +8 -0
  168. package/dist/core/wgsl/generate.js +195 -22
  169. package/dist/core/wgsl/generate.js.map +1 -1
  170. package/dist/core/wgsl/lean.d.ts +50 -0
  171. package/dist/core/wgsl/lean.js +327 -0
  172. package/dist/core/wgsl/lean.js.map +1 -0
  173. package/dist/core/wgsl/level-set.d.ts +5 -1
  174. package/dist/core/wgsl/level-set.js +11 -5
  175. package/dist/core/wgsl/level-set.js.map +1 -1
  176. package/dist/core/wgsl/majorant.d.ts +62 -0
  177. package/dist/core/wgsl/majorant.js +381 -0
  178. package/dist/core/wgsl/majorant.js.map +1 -0
  179. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
  180. package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
  181. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
  182. package/dist/core/wgsl/types.d.ts +97 -3
  183. package/dist/core/wgsl/types.js.map +1 -1
  184. package/dist/three/coarse-first.d.ts +53 -8
  185. package/dist/three/coarse-first.js +24 -6
  186. package/dist/three/coarse-first.js.map +1 -1
  187. package/dist/three/compute.d.ts +12 -2
  188. package/dist/three/compute.js +16 -6
  189. package/dist/three/compute.js.map +1 -1
  190. package/dist/three/device.d.ts +7 -0
  191. package/dist/three/device.js +3 -0
  192. package/dist/three/device.js.map +1 -1
  193. package/dist/three/frame/core-environment.d.ts +38 -0
  194. package/dist/three/frame/core-environment.js +154 -0
  195. package/dist/three/frame/core-environment.js.map +1 -0
  196. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  197. package/dist/three/frame/core-integrate-material.js +162 -0
  198. package/dist/three/frame/core-integrate-material.js.map +1 -0
  199. package/dist/three/frame/core-occluders.d.ts +53 -0
  200. package/dist/three/frame/core-occluders.js +193 -0
  201. package/dist/three/frame/core-occluders.js.map +1 -0
  202. package/dist/three/frame/core-structs.d.ts +34 -0
  203. package/dist/three/frame/core-structs.js +61 -0
  204. package/dist/three/frame/core-structs.js.map +1 -0
  205. package/dist/three/frame/core-textures.d.ts +41 -0
  206. package/dist/three/frame/core-textures.js +114 -0
  207. package/dist/three/frame/core-textures.js.map +1 -0
  208. package/dist/three/frame/emission-light.d.ts +64 -114
  209. package/dist/three/frame/emission-light.js +188 -567
  210. package/dist/three/frame/emission-light.js.map +1 -1
  211. package/dist/three/frame/index.d.ts +11 -31
  212. package/dist/three/frame/index.js +9 -29
  213. package/dist/three/frame/index.js.map +1 -1
  214. package/dist/three/frame/medium.d.ts +12 -0
  215. package/dist/three/frame/medium.js.map +1 -1
  216. package/dist/three/frame/renderer.d.ts +58 -454
  217. package/dist/three/frame/renderer.js +409 -1427
  218. package/dist/three/frame/renderer.js.map +1 -1
  219. package/dist/three/frame/spectrum.d.ts +0 -14
  220. package/dist/three/frame/spectrum.js +2 -23
  221. package/dist/three/frame/spectrum.js.map +1 -1
  222. package/dist/three/frame/three-internals.d.ts +3 -8
  223. package/dist/three/frame/three-internals.js +13 -11
  224. package/dist/three/frame/three-internals.js.map +1 -1
  225. package/dist/three/frame/volume-shadows.d.ts +93 -107
  226. package/dist/three/frame/volume-shadows.js +278 -631
  227. package/dist/three/frame/volume-shadows.js.map +1 -1
  228. package/dist/three/frame/volume.d.ts +91 -33
  229. package/dist/three/frame/volume.js +63 -51
  230. package/dist/three/frame/volume.js.map +1 -1
  231. package/dist/three/grid-node.d.ts +34 -1
  232. package/dist/three/grid-node.js +36 -1
  233. package/dist/three/grid-node.js.map +1 -1
  234. package/dist/three/index.d.ts +20 -11
  235. package/dist/three/index.js +21 -12
  236. package/dist/three/index.js.map +1 -1
  237. package/dist/three/internal.d.ts +14 -8
  238. package/dist/three/internal.js +11 -7
  239. package/dist/three/internal.js.map +1 -1
  240. package/dist/three/level-set-material.d.ts +81 -8
  241. package/dist/three/level-set-material.js +162 -125
  242. package/dist/three/level-set-material.js.map +1 -1
  243. package/dist/three/level-set-physical-material.d.ts +154 -0
  244. package/dist/three/level-set-physical-material.js +253 -0
  245. package/dist/three/level-set-physical-material.js.map +1 -0
  246. package/dist/three/level-set-velocity.d.ts +94 -0
  247. package/dist/three/level-set-velocity.js +208 -0
  248. package/dist/three/level-set-velocity.js.map +1 -0
  249. package/dist/three/material.d.ts +141 -11
  250. package/dist/three/material.js +161 -18
  251. package/dist/three/material.js.map +1 -1
  252. package/dist/three/points.d.ts +60 -4
  253. package/dist/three/points.js +140 -9
  254. package/dist/three/points.js.map +1 -1
  255. package/dist/three/sparse-source.d.ts +49 -117
  256. package/dist/three/sparse-source.js +109 -580
  257. package/dist/three/sparse-source.js.map +1 -1
  258. package/dist/three/volume-source.d.ts +11 -156
  259. package/dist/three/volume-source.js +29 -272
  260. package/dist/three/volume-source.js.map +1 -1
  261. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  262. package/dist/tools/cpu/brick-atlas.js +129 -0
  263. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  264. package/dist/tools/cpu/compute.d.ts +23 -4
  265. package/dist/tools/cpu/compute.js +35 -14
  266. package/dist/tools/cpu/compute.js.map +1 -1
  267. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  268. package/dist/tools/cpu/lean-reads.js +262 -0
  269. package/dist/tools/cpu/lean-reads.js.map +1 -0
  270. package/dist/tools/cpu/level-set.d.ts +42 -3
  271. package/dist/tools/cpu/level-set.js +59 -7
  272. package/dist/tools/cpu/level-set.js.map +1 -1
  273. package/dist/tools/cpu/majorant.d.ts +265 -0
  274. package/dist/tools/cpu/majorant.js +541 -0
  275. package/dist/tools/cpu/majorant.js.map +1 -0
  276. package/dist/tools/cpu/march.d.ts +93 -2
  277. package/dist/tools/cpu/march.js +165 -14
  278. package/dist/tools/cpu/march.js.map +1 -1
  279. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  280. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  281. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  282. package/dist/tools/cpu/points.d.ts +29 -0
  283. package/dist/tools/cpu/points.js +38 -0
  284. package/dist/tools/cpu/points.js.map +1 -0
  285. package/dist/tools/cpu/read-value.d.ts +19 -6
  286. package/dist/tools/cpu/read-value.js +32 -17
  287. package/dist/tools/cpu/read-value.js.map +1 -1
  288. package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
  289. package/dist/tools/cpu/sample-trilinear.js +19 -7
  290. package/dist/tools/cpu/sample-trilinear.js.map +1 -1
  291. package/dist/tools/cpu/stride-tables.d.ts +2 -2
  292. package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
  293. package/dist/tools/cpu/stride-tables.generated.js +7 -6
  294. package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
  295. package/dist/tools/cpu/stride-tables.js +1 -1
  296. package/dist/tools/cpu/stride-tables.js.map +1 -1
  297. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  298. package/dist/tools/cpu/surface-nets.js +597 -0
  299. package/dist/tools/cpu/surface-nets.js.map +1 -0
  300. package/dist/tools/errors.d.ts +9 -0
  301. package/dist/tools/errors.js +9 -0
  302. package/dist/tools/errors.js.map +1 -1
  303. package/dist/tools/frame/ambient.d.ts +98 -0
  304. package/dist/tools/frame/ambient.js +274 -0
  305. package/dist/tools/frame/ambient.js.map +1 -0
  306. package/dist/tools/frame/blackbody.d.ts +15 -0
  307. package/dist/tools/frame/blackbody.js +35 -0
  308. package/dist/tools/frame/blackbody.js.map +1 -1
  309. package/dist/tools/frame/brick-cache.d.ts +165 -0
  310. package/dist/tools/frame/brick-cache.js +326 -0
  311. package/dist/tools/frame/brick-cache.js.map +1 -0
  312. package/dist/tools/frame/emission.d.ts +9 -0
  313. package/dist/tools/frame/emission.js +9 -1
  314. package/dist/tools/frame/emission.js.map +1 -1
  315. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  316. package/dist/tools/frame/environment-gpu.js +280 -0
  317. package/dist/tools/frame/environment-gpu.js.map +1 -0
  318. package/dist/tools/frame/environment.d.ts +3 -2
  319. package/dist/tools/frame/environment.js +8 -4
  320. package/dist/tools/frame/environment.js.map +1 -1
  321. package/dist/tools/frame/froxel.d.ts +58 -0
  322. package/dist/tools/frame/froxel.js +115 -0
  323. package/dist/tools/frame/froxel.js.map +1 -0
  324. package/dist/tools/frame/grid.d.ts +90 -0
  325. package/dist/tools/frame/grid.js +112 -13
  326. package/dist/tools/frame/grid.js.map +1 -1
  327. package/dist/tools/frame/index.d.ts +14 -0
  328. package/dist/tools/frame/index.js +45 -4
  329. package/dist/tools/frame/index.js.map +1 -1
  330. package/dist/tools/frame/medium.d.ts +16 -0
  331. package/dist/tools/frame/medium.js +3 -1
  332. package/dist/tools/frame/medium.js.map +1 -1
  333. package/dist/tools/frame/mie.d.ts +9 -0
  334. package/dist/tools/frame/mie.js +18 -0
  335. package/dist/tools/frame/mie.js.map +1 -1
  336. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  337. package/dist/tools/frame/mlp-nn.js +159 -0
  338. package/dist/tools/frame/mlp-nn.js.map +1 -0
  339. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  340. package/dist/tools/frame/mlp-tza.js +186 -0
  341. package/dist/tools/frame/mlp-tza.js.map +1 -0
  342. package/dist/tools/frame/mlp.d.ts +183 -0
  343. package/dist/tools/frame/mlp.js +434 -0
  344. package/dist/tools/frame/mlp.js.map +1 -0
  345. package/dist/tools/frame/ms-exit.d.ts +42 -0
  346. package/dist/tools/frame/ms-exit.js +90 -0
  347. package/dist/tools/frame/ms-exit.js.map +1 -0
  348. package/dist/tools/frame/multi-scale.d.ts +152 -0
  349. package/dist/tools/frame/multi-scale.js +302 -0
  350. package/dist/tools/frame/multi-scale.js.map +1 -0
  351. package/dist/tools/frame/neural-weights.d.ts +6 -5
  352. package/dist/tools/frame/neural-weights.js +234 -235
  353. package/dist/tools/frame/neural-weights.js.map +1 -1
  354. package/dist/tools/frame/neural.js +1 -1
  355. package/dist/tools/frame/neural.js.map +1 -1
  356. package/dist/tools/frame/occluders.d.ts +51 -0
  357. package/dist/tools/frame/occluders.js +72 -0
  358. package/dist/tools/frame/occluders.js.map +1 -0
  359. package/dist/tools/frame/pyramid-layout.d.ts +17 -0
  360. package/dist/tools/frame/pyramid-layout.js +47 -0
  361. package/dist/tools/frame/pyramid-layout.js.map +1 -1
  362. package/dist/tools/frame/shadows.d.ts +110 -0
  363. package/dist/tools/frame/shadows.js +286 -0
  364. package/dist/tools/frame/shadows.js.map +1 -1
  365. package/dist/tools/frame/sparse.d.ts +82 -0
  366. package/dist/tools/frame/sparse.js +242 -1
  367. package/dist/tools/frame/sparse.js.map +1 -1
  368. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  369. package/dist/tools/frame/spectral-stack.js +391 -0
  370. package/dist/tools/frame/spectral-stack.js.map +1 -0
  371. package/dist/tools/frame/spectral.d.ts +21 -2
  372. package/dist/tools/frame/spectral.js +30 -8
  373. package/dist/tools/frame/spectral.js.map +1 -1
  374. package/dist/tools/frame/stack.d.ts +115 -0
  375. package/dist/tools/frame/stack.js +290 -0
  376. package/dist/tools/frame/stack.js.map +1 -0
  377. package/dist/tools/frame/view.d.ts +131 -0
  378. package/dist/tools/frame/view.js +337 -0
  379. package/dist/tools/frame/view.js.map +1 -0
  380. package/dist/tools/index.d.ts +66 -15
  381. package/dist/tools/index.js +55 -11
  382. package/dist/tools/index.js.map +1 -1
  383. package/dist/tools/internal.d.ts +58 -17
  384. package/dist/tools/internal.js +65 -11
  385. package/dist/tools/internal.js.map +1 -1
  386. package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
  387. package/dist/tools/nanovdb/build-from-vdb.js +10 -2
  388. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
  389. package/dist/tools/nanovdb/bytes.d.ts +17 -4
  390. package/dist/tools/nanovdb/bytes.js +46 -3
  391. package/dist/tools/nanovdb/bytes.js.map +1 -1
  392. package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
  393. package/dist/tools/nanovdb/coarse-first.js +7 -1
  394. package/dist/tools/nanovdb/coarse-first.js.map +1 -1
  395. package/dist/tools/nanovdb/half.d.ts +22 -0
  396. package/dist/tools/nanovdb/half.js +73 -0
  397. package/dist/tools/nanovdb/half.js.map +1 -0
  398. package/dist/tools/nanovdb/index.d.ts +3 -1
  399. package/dist/tools/nanovdb/index.js +2 -1
  400. package/dist/tools/nanovdb/index.js.map +1 -1
  401. package/dist/tools/nanovdb/inspect.d.ts +10 -1
  402. package/dist/tools/nanovdb/inspect.js +8 -1
  403. package/dist/tools/nanovdb/inspect.js.map +1 -1
  404. package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
  405. package/dist/tools/nanovdb/leaf-codec.js +40 -4
  406. package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
  407. package/dist/tools/nanovdb/quantize.d.ts +39 -10
  408. package/dist/tools/nanovdb/quantize.js +96 -44
  409. package/dist/tools/nanovdb/quantize.js.map +1 -1
  410. package/dist/tools/nanovdb/resample.d.ts +20 -3
  411. package/dist/tools/nanovdb/resample.js +20 -7
  412. package/dist/tools/nanovdb/resample.js.map +1 -1
  413. package/dist/tools/nanovdb/serialize.d.ts +34 -3
  414. package/dist/tools/nanovdb/serialize.js +51 -7
  415. package/dist/tools/nanovdb/serialize.js.map +1 -1
  416. package/dist/tools/nanovdb/stats.d.ts +34 -5
  417. package/dist/tools/nanovdb/stats.js +87 -11
  418. package/dist/tools/nanovdb/stats.js.map +1 -1
  419. package/dist/tools/nanovdb/transform.d.ts +4 -0
  420. package/dist/tools/nanovdb/transform.js +3 -0
  421. package/dist/tools/nanovdb/transform.js.map +1 -1
  422. package/dist/tools/nanovdb/tree.d.ts +14 -3
  423. package/dist/tools/nanovdb/tree.js +25 -13
  424. package/dist/tools/nanovdb/tree.js.map +1 -1
  425. package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
  426. package/dist/tools/nanovdb/write-nvdb.js +108 -28
  427. package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
  428. package/dist/tools/nvdb-file.d.ts +77 -7
  429. package/dist/tools/nvdb-file.js +177 -20
  430. package/dist/tools/nvdb-file.js.map +1 -1
  431. package/dist/tools/nvdb-stream.d.ts +23 -7
  432. package/dist/tools/nvdb-stream.js +78 -34
  433. package/dist/tools/nvdb-stream.js.map +1 -1
  434. package/dist/tools/reference/analytic.d.ts +41 -0
  435. package/dist/tools/reference/analytic.js +95 -0
  436. package/dist/tools/reference/analytic.js.map +1 -0
  437. package/dist/tools/reference/environment.d.ts +62 -0
  438. package/dist/tools/reference/environment.js +154 -0
  439. package/dist/tools/reference/environment.js.map +1 -0
  440. package/dist/tools/reference/index.d.ts +12 -0
  441. package/dist/tools/reference/index.js +13 -0
  442. package/dist/tools/reference/index.js.map +1 -0
  443. package/dist/tools/reference/media.d.ts +14 -0
  444. package/dist/tools/reference/media.js +30 -0
  445. package/dist/tools/reference/media.js.map +1 -0
  446. package/dist/tools/reference/rng.d.ts +20 -0
  447. package/dist/tools/reference/rng.js +30 -0
  448. package/dist/tools/reference/rng.js.map +1 -0
  449. package/dist/tools/reference/scene.d.ts +312 -0
  450. package/dist/tools/reference/scene.js +169 -0
  451. package/dist/tools/reference/scene.js.map +1 -0
  452. package/dist/tools/reference/tables.d.ts +98 -0
  453. package/dist/tools/reference/tables.js +264 -0
  454. package/dist/tools/reference/tables.js.map +1 -0
  455. package/dist/tools/reference/trace.d.ts +160 -0
  456. package/dist/tools/reference/trace.js +497 -0
  457. package/dist/tools/reference/trace.js.map +1 -0
  458. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  459. package/dist/tools/vdb/blosc-write.js +197 -0
  460. package/dist/tools/vdb/blosc-write.js.map +1 -0
  461. package/dist/tools/vdb/blosc.d.ts +35 -5
  462. package/dist/tools/vdb/blosc.js +82 -26
  463. package/dist/tools/vdb/blosc.js.map +1 -1
  464. package/dist/tools/vdb/blosclz.d.ts +33 -0
  465. package/dist/tools/vdb/blosclz.js +112 -0
  466. package/dist/tools/vdb/blosclz.js.map +1 -0
  467. package/dist/tools/vdb/byte-reader.d.ts +13 -3
  468. package/dist/tools/vdb/byte-reader.js +26 -4
  469. package/dist/tools/vdb/byte-reader.js.map +1 -1
  470. package/dist/tools/vdb/compression.d.ts +13 -5
  471. package/dist/tools/vdb/compression.js +13 -2
  472. package/dist/tools/vdb/compression.js.map +1 -1
  473. package/dist/tools/vdb/grid.js +8 -2
  474. package/dist/tools/vdb/grid.js.map +1 -1
  475. package/dist/tools/vdb/index.d.ts +2 -1
  476. package/dist/tools/vdb/index.js.map +1 -1
  477. package/dist/tools/vdb/lz4.d.ts +30 -0
  478. package/dist/tools/vdb/lz4.js +228 -0
  479. package/dist/tools/vdb/lz4.js.map +1 -0
  480. package/dist/tools/vdb/metadata.js +1 -1
  481. package/dist/tools/vdb/metadata.js.map +1 -1
  482. package/dist/tools/vdb/parse.d.ts +24 -2
  483. package/dist/tools/vdb/parse.js +102 -32
  484. package/dist/tools/vdb/parse.js.map +1 -1
  485. package/dist/tools/vdb/point-render-data.d.ts +49 -1
  486. package/dist/tools/vdb/point-render-data.js +91 -11
  487. package/dist/tools/vdb/point-render-data.js.map +1 -1
  488. package/dist/tools/vdb/points.d.ts +26 -0
  489. package/dist/tools/vdb/points.js +46 -5
  490. package/dist/tools/vdb/points.js.map +1 -1
  491. package/dist/tools/vdb/types.d.ts +59 -2
  492. package/dist/tools/vdb/types.js.map +1 -1
  493. package/dist/tools/wvdb/bake.d.ts +38 -9
  494. package/dist/tools/wvdb/bake.js +63 -13
  495. package/dist/tools/wvdb/bake.js.map +1 -1
  496. package/dist/tools/wvdb/dense.d.ts +80 -1
  497. package/dist/tools/wvdb/dense.js +67 -8
  498. package/dist/tools/wvdb/dense.js.map +1 -1
  499. package/dist/tools/wvdb/format.d.ts +59 -0
  500. package/dist/tools/wvdb/format.js +3 -0
  501. package/dist/tools/wvdb/format.js.map +1 -1
  502. package/dist/tools/wvdb/index.d.ts +1 -0
  503. package/dist/tools/wvdb/index.js +1 -0
  504. package/dist/tools/wvdb/index.js.map +1 -1
  505. package/dist/tools/wvdb/level-set.d.ts +10 -2
  506. package/dist/tools/wvdb/level-set.js.map +1 -1
  507. package/dist/tools/wvdb/nanovdb.d.ts +6 -1
  508. package/dist/tools/wvdb/nanovdb.js +5 -1
  509. package/dist/tools/wvdb/nanovdb.js.map +1 -1
  510. package/dist/tools/wvdb/partial.d.ts +74 -0
  511. package/dist/tools/wvdb/partial.js +233 -0
  512. package/dist/tools/wvdb/partial.js.map +1 -0
  513. package/dist/tools/wvdb/read.d.ts +77 -1
  514. package/dist/tools/wvdb/read.js +30 -7
  515. package/dist/tools/wvdb/read.js.map +1 -1
  516. package/dist/tools/wvdb/write.d.ts +23 -1
  517. package/dist/tools/wvdb/write.js +8 -1
  518. package/dist/tools/wvdb/write.js.map +1 -1
  519. package/package.json +2 -1
  520. package/vendor/VENDOR.md +21 -6
  521. package/vendor/pnanovdb.wgsl +52 -14
  522. package/dist/three/frame/blackbody.d.ts +0 -42
  523. package/dist/three/frame/blackbody.js +0 -74
  524. package/dist/three/frame/blackbody.js.map +0 -1
  525. package/dist/three/frame/chunks.d.ts +0 -157
  526. package/dist/three/frame/chunks.js +0 -559
  527. package/dist/three/frame/chunks.js.map +0 -1
  528. package/dist/three/frame/density-material.d.ts +0 -53
  529. package/dist/three/frame/density-material.js +0 -353
  530. package/dist/three/frame/density-material.js.map +0 -1
  531. package/dist/three/frame/environment-grid-material.d.ts +0 -21
  532. package/dist/three/frame/environment-grid-material.js +0 -184
  533. package/dist/three/frame/environment-grid-material.js.map +0 -1
  534. package/dist/three/frame/environment-material.d.ts +0 -22
  535. package/dist/three/frame/environment-material.js +0 -87
  536. package/dist/three/frame/environment-material.js.map +0 -1
  537. package/dist/three/frame/grid-mip-material.d.ts +0 -12
  538. package/dist/three/frame/grid-mip-material.js +0 -61
  539. package/dist/three/frame/grid-mip-material.js.map +0 -1
  540. package/dist/three/frame/inject-material.d.ts +0 -56
  541. package/dist/three/frame/inject-material.js +0 -424
  542. package/dist/three/frame/inject-material.js.map +0 -1
  543. package/dist/three/frame/integrate-material.d.ts +0 -26
  544. package/dist/three/frame/integrate-material.js +0 -198
  545. package/dist/three/frame/integrate-material.js.map +0 -1
  546. package/dist/three/frame/layout.d.ts +0 -34
  547. package/dist/three/frame/layout.js +0 -48
  548. package/dist/three/frame/layout.js.map +0 -1
  549. package/dist/three/frame/lighting-material.d.ts +0 -41
  550. package/dist/three/frame/lighting-material.js +0 -257
  551. package/dist/three/frame/lighting-material.js.map +0 -1
  552. package/dist/three/frame/lights.d.ts +0 -11
  553. package/dist/three/frame/lights.js +0 -16
  554. package/dist/three/frame/lights.js.map +0 -1
  555. package/dist/three/frame/neural.d.ts +0 -14
  556. package/dist/three/frame/neural.js +0 -105
  557. package/dist/three/frame/neural.js.map +0 -1
  558. package/dist/three/frame/phase.d.ts +0 -44
  559. package/dist/three/frame/phase.js +0 -80
  560. package/dist/three/frame/phase.js.map +0 -1
  561. package/dist/three/frame/shadow-density-material.d.ts +0 -30
  562. package/dist/three/frame/shadow-density-material.js +0 -123
  563. package/dist/three/frame/shadow-density-material.js.map +0 -1
  564. package/dist/three/frame/temporal-material.d.ts +0 -29
  565. package/dist/three/frame/temporal-material.js +0 -152
  566. package/dist/three/frame/temporal-material.js.map +0 -1
  567. package/dist/three/frame/transmittance-material.d.ts +0 -31
  568. package/dist/three/frame/transmittance-material.js +0 -315
  569. package/dist/three/frame/transmittance-material.js.map +0 -1
  570. package/dist/three/frame/view.d.ts +0 -103
  571. package/dist/three/frame/view.js +0 -296
  572. package/dist/three/frame/view.js.map +0 -1
  573. package/dist/three/frame/volume-shadow-material.d.ts +0 -36
  574. package/dist/three/frame/volume-shadow-material.js +0 -128
  575. package/dist/three/frame/volume-shadow-material.js.map +0 -1
  576. package/dist/three/sequence.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/tools/vdb/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,kDAAkD;AAChF,MAAM,qBAAqB,GAAG,GAAG,CAAC,CAAC,oCAAoC;AACvE,MAAM,qBAAqB,GAAG,GAAG,CAAC,CAAC,uDAAuD;AAC1F,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC,MAAM,YAAY,GAAG,yCAAyC,CAAC;AAE/D,+DAA+D;AAC/D,MAAM,aAAa,GAAsC;IACvD,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,YAAY;IACnB,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J,CAAC;QACD,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YAC3C,MAAM,IAAI,mBAAmB,CAC3B,SAAS,IAAI,yBAAyB,EAAE,IAAI,EAAE,IAAI,EAAE,qDAAqD,CAC1G,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE;YACvG,WAAW;YACX,WAAW;YACX,OAAO;YACP,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC;YAChC,SAAS,EAAE,SAAS,KAAK,aAAa;SACvC,CAAC,CAAC;QAEH,KAAK,CAAC,IAAI,CACR,aAAa,CAAC;YACZ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,SAAS;YACT,QAAQ;YACR,SAAS,EAAE,oBAAoB,CAAC,QAAQ,CAAC;YACzC,gBAAgB;YAChB,UAAU;YACV,MAAM;YACN,KAAK;YACL,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3D,CAAC,CACH,CAAC;QAEF,wEAAwE;QACxE,oEAAoE;QACpE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AAChC,CAAC","sourcesContent":["/**\n * parse.ts — top-level `.vdb` container reader (docs/archive/v1/SPEC.md §4).\n *\n * File layout (format facts cross-checked between `mjurczyk/openvdb`'s\n * `OpenVDBReader`/`GridDescriptor` and `vdb-rs`'s `VdbReader::new`/\n * `read_grid_descriptors`/`read_grid_internal`):\n *\n * magic(u64) file_version(u32) [lib_major(u32) lib_minor(u32)]\n * has_grid_offsets(u8) [is_compressed(u8) if 220<=v<222] guid(36 chars)\n * metadata_map grid_count(u32)\n * grid_count x {\n * unique_name type_name [instance_parent] grid_pos(u64) block_pos(u64) end_pos(u64)\n * -- seek to grid_pos --\n * [compression(u32) if v>=222] metadata_map transform tree_topology tree_buffers\n * }\n *\n * Unlike both references' lazy/two-pass grid-descriptor tables (built for\n * random access to a single named grid), `parseVdb` decodes every grid in\n * one linear pass and defensively re-seeks to each descriptor's `end_pos`\n * afterward — the `mjurczyk/openvdb` reader does the same \"hack\" for\n * multi-grid files, and it's cheap insurance against any of our own\n * byte-accounting bugs desyncing the stream for the next grid.\n */\n\nimport { ByteReader } from \"./byte-reader.js\";\nimport type { CompressionFlags, ValueFormat } from \"./compression.js\";\nimport {\n compressionFromBits,\n FLOAT_FORMAT,\n PTDATAIDX32_FORMAT,\n VEC3D_FORMAT,\n VEC3I_FORMAT,\n VEC3S_FORMAT,\n} from \"./compression.js\";\nimport { VdbFormatError, VDBUnsupportedError } from \"./errors.js\";\nimport { createVdbGrid } from \"./grid.js\";\nimport { readMetadataMap } from \"./metadata.js\";\nimport { readTransform } from \"./transform.js\";\nimport { readTree } from \"./tree.js\";\nimport type { VdbBBox, VdbFile, VdbGrid, VdbValueType } from \"./types.js\";\n\nconst MAGIC_LOW = 0x56444220; // 'V','D','B',' ' read little-endian, low 32 bits\nconst MIN_SUPPORTED_VERSION = 213; // OPENVDB_FILE_VERSION_ROOTNODE_MAP\nconst MAX_SUPPORTED_VERSION = 225; // OPENVDB_FILE_VERSION: OpenVDB rejects anything newer\nconst VERSION_GRID_INSTANCING = 216;\nconst VERSION_BOOST_UUID = 218;\nconst VERSION_SELECTIVE_COMPRESSION = 220;\nconst VERSION_NODE_MASK_COMPRESSION = 222;\nconst VERSION_BLOSC_COMPRESSION = 223;\n\nconst GRID_TYPE_RE = /^Tree_([A-Za-z0-9]+)_(\\d+)_(\\d+)_(\\d+)$/;\n\n/** Value types this parser reads, and their on-disk layout. */\nconst VALUE_FORMATS: Record<VdbValueType, ValueFormat> = {\n float: FLOAT_FORMAT,\n vec3s: VEC3S_FORMAT,\n vec3d: VEC3D_FORMAT,\n vec3i: VEC3I_FORMAT,\n ptdataidx32: PTDATAIDX32_FORMAT,\n};\n\nfunction isSupportedValueType(t: string): t is VdbValueType {\n return Object.prototype.hasOwnProperty.call(VALUE_FORMATS, t);\n}\n\nfunction readHeaderCompression(reader: ByteReader, fileVersion: number): CompressionFlags {\n let compression: CompressionFlags = { zip: false, activeMask: true, blosc: true }; // DEFAULT_COMPRESSION\n if (fileVersion < VERSION_BLOSC_COMPRESSION) {\n compression = { zip: true, activeMask: true, blosc: false };\n }\n if (fileVersion >= VERSION_SELECTIVE_COMPRESSION && fileVersion < VERSION_NODE_MASK_COMPRESSION) {\n const isCompressed = reader.bool();\n compression = isCompressed\n ? { zip: true, activeMask: false, blosc: false }\n : { zip: false, activeMask: false, blosc: false };\n }\n return compression;\n}\n\nfunction readBBoxFromMetadata(metadata: Record<string, unknown>): VdbBBox | null {\n const min = metadata[\"file_bbox_min\"];\n const max = metadata[\"file_bbox_max\"];\n if (Array.isArray(min) && Array.isArray(max) && min.length === 3 && max.length === 3) {\n return {\n min: [min[0], min[1], min[2]] as [number, number, number],\n max: [max[0], max[1], max[2]] as [number, number, number],\n };\n }\n return null;\n}\n\nexport function parseVdb(buffer: ArrayBuffer): VdbFile {\n const reader = new ByteReader(buffer);\n\n if (reader.length < 8) {\n throw new VdbFormatError(\"buffer too short to contain the magic number\");\n }\n const magicLow = reader.u32();\n const magicHigh = reader.u32();\n if (magicLow !== MAGIC_LOW || magicHigh !== 0) {\n throw new VdbFormatError(\n `bad magic number (expected 0x${MAGIC_LOW.toString(16)}, got 0x${magicLow.toString(16)}) — not a .vdb file`,\n );\n }\n\n const fileVersion = reader.u32();\n if (fileVersion < MIN_SUPPORTED_VERSION) {\n throw new VDBUnsupportedError(\n `file version ${fileVersion} is older than the minimum supported version ${MIN_SUPPORTED_VERSION}`,\n );\n }\n\n if (fileVersion > MAX_SUPPORTED_VERSION) {\n throw new VDBUnsupportedError(\n `file version ${fileVersion} is newer than the maximum supported version ${MAX_SUPPORTED_VERSION}`,\n );\n }\n\n reader.u32(); // library version major (informational only)\n reader.u32(); // library version minor (informational only)\n\n const hasGridOffsets = reader.bool();\n if (!hasGridOffsets) {\n throw new VDBUnsupportedError(\"VDB streams without grid offsets are not supported\");\n }\n\n const headerCompression = readHeaderCompression(reader, fileVersion);\n\n if (fileVersion < VERSION_BOOST_UUID) {\n throw new VDBUnsupportedError(`file version ${fileVersion} predates the Boost-UUID header layout (< 218)`);\n }\n reader.fixedString(36); // uuid (informational only)\n\n readMetadataMap(reader); // file-level metadata (informational only)\n\n const gridCount = reader.u32();\n const grids: VdbGrid[] = [];\n\n for (let i = 0; i < gridCount; i++) {\n const uniqueName = reader.string();\n const name = uniqueName.split(\"\\x1e\")[0] ?? uniqueName;\n let gridType = reader.string();\n\n let savedAsHalfFloat = false;\n if (gridType.includes(\"_HalfFloat\")) {\n savedAsHalfFloat = true;\n gridType = gridType.split(\"_HalfFloat\").join(\"\");\n }\n\n let instanceParentName = \"\";\n if (fileVersion >= VERSION_GRID_INSTANCING) {\n instanceParentName = reader.string();\n }\n if (instanceParentName !== \"\") {\n throw new VDBUnsupportedError(`grid \"${name}\": instanced grids (sharing another grid's tree) are not supported`);\n }\n\n const gridPos = reader.u64AsNumber();\n const blockPos = reader.u64AsNumber();\n void blockPos; // not needed: we read topology+buffers in one contiguous pass\n const endPos = reader.u64AsNumber();\n\n reader.seek(gridPos);\n\n const compression =\n fileVersion >= VERSION_NODE_MASK_COMPRESSION\n ? compressionFromBits(reader.u32())\n : headerCompression;\n\n const metadata = readMetadataMap(reader);\n const useHalf = savedAsHalfFloat || metadata[\"is_saved_as_half_float\"] === true;\n\n const match = GRID_TYPE_RE.exec(gridType);\n if (!match) {\n throw new VDBUnsupportedError(\n `grid \"${name}\": unrecognized grid type \"${gridType}\" (expected \"Tree_<valueType>_<log2dim>_<log2dim>_<log2dim>\")`,\n );\n }\n const [, valueType, d0, d1, d2] = match;\n if (!isSupportedValueType(valueType!)) {\n throw new VDBUnsupportedError(\n `grid \"${name}\": value type \"${valueType}\" is not supported ` +\n `(supported: ${Object.keys(VALUE_FORMATS).join(\", \")})`,\n );\n }\n if (d0 !== \"5\" || d1 !== \"4\" || d2 !== \"3\") {\n throw new VDBUnsupportedError(\n `grid \"${name}\": tree configuration ${d0}-${d1}-${d2} is not supported (only the 5-4-3 tree is in scope)`,\n );\n }\n\n const transform = readTransform(reader);\n const { background, leaves, tiles, activeVoxelCount, pointLeaves, pointOutputBudget } = readTree(reader, {\n fileVersion,\n compression,\n useHalf,\n format: VALUE_FORMATS[valueType],\n pointData: valueType === \"ptdataidx32\",\n });\n\n grids.push(\n createVdbGrid({\n name,\n gridType,\n valueType,\n transform,\n metadata,\n indexBBox: readBBoxFromMetadata(metadata),\n activeVoxelCount,\n background,\n leaves,\n tiles,\n ...(pointLeaves ? { pointLeaves, pointOutputBudget } : {}),\n }),\n );\n\n // Defensive re-sync (matches the `mjurczyk/openvdb` reader's own hack):\n // land exactly on the next grid descriptor regardless of any drift.\n reader.seek(endPos);\n }\n\n return { fileVersion, grids };\n}\n"]}
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/tools/vdb/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EA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KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YAC/F,MAAM,EAAE,GAAG,SAA4B,CAAC;YACxC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE;gBACvG,WAAW;gBACX,WAAW;gBACX,OAAO;gBACP,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;gBACzB,SAAS,EAAE,EAAE,KAAK,aAAa;aAChC,CAAC,CAAC;YAEH,KAAK,CAAC,IAAI,CACR,aAAa,CAAC;gBACZ,IAAI;gBACJ,QAAQ;gBACR,SAAS,EAAE,iBAAiB,CAAC,EAAE,CAAC;gBAChC,SAAS;gBACT,QAAQ;gBACR,SAAS;gBACT,gBAAgB;gBAChB,UAAU;gBACV,MAAM;gBACN,KAAK;gBACL,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3D,CAAC,CACH,CAAC;QACJ,CAAC;QAED,wEAAwE;QACxE,oEAAoE;QACpE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAC7C,CAAC","sourcesContent":["/**\n * parse.ts — top-level `.vdb` container reader (docs/archive/v1/SPEC.md §4).\n *\n * File layout (format facts cross-checked between `mjurczyk/openvdb`'s\n * `OpenVDBReader`/`GridDescriptor` and `vdb-rs`'s `VdbReader::new`/\n * `read_grid_descriptors`/`read_grid_internal`):\n *\n * magic(u64) file_version(u32) [lib_major(u32) lib_minor(u32)]\n * has_grid_offsets(u8) [is_compressed(u8) if 220<=v<222] guid(36 chars)\n * metadata_map grid_count(u32)\n * grid_count x {\n * unique_name type_name [instance_parent] grid_pos(u64) block_pos(u64) end_pos(u64)\n * -- seek to grid_pos --\n * [compression(u32) if v>=222] metadata_map transform tree_topology tree_buffers\n * }\n *\n * Unlike both references' lazy/two-pass grid-descriptor tables (built for\n * random access to a single named grid), `parseVdb` decodes every grid in\n * one linear pass and defensively re-seeks to each descriptor's `end_pos`\n * afterward — the `mjurczyk/openvdb` reader does the same \"hack\" for\n * multi-grid files, and it's cheap insurance against any of our own\n * byte-accounting bugs desyncing the stream for the next grid.\n */\n\nimport { ByteReader } from \"./byte-reader.js\";\nimport type { CompressionFlags, ValueFormat } from \"./compression.js\";\nimport {\n compressionFromBits,\n FLOAT_FORMAT,\n HALF_FORMAT,\n PTDATAIDX32_FORMAT,\n VEC3D_FORMAT,\n VEC3I_FORMAT,\n VEC3S_FORMAT,\n} from \"./compression.js\";\nimport { VdbFormatError, VDBUnsupportedError } from \"./errors.js\";\nimport { createVdbGrid } from \"./grid.js\";\nimport { readMetadataMap } from \"./metadata.js\";\nimport { readTransform } from \"./transform.js\";\nimport { readTree } from \"./tree.js\";\nimport type { VdbBBox, VdbFile, VdbGrid, VdbGridDescriptor, VdbTransformInfo, VdbValueType } from \"./types.js\";\n\nconst MAGIC_LOW = 0x56444220; // 'V','D','B',' ' read little-endian, low 32 bits\nconst MIN_SUPPORTED_VERSION = 213; // OPENVDB_FILE_VERSION_ROOTNODE_MAP\n/**\n * OPENVDB_FILE_VERSION (225, `OPENVDB_FILE_VERSION_HALF_GRID`), still current in OpenVDB v14.0.0.\n * A newer file fails with `VDBUnsupportedError` before anything after the header is read: a\n * future layout could misparse silently. OpenVDB 13.2+ warns for 226-299 and rejects 300+\n * (`OPENVDB_UNSUPPORTED_FILE_VERSION`); we reject from 226 (DIVERGES V71).\n */\nconst MAX_SUPPORTED_VERSION = 225;\nconst VERSION_GRID_INSTANCING = 216;\nconst VERSION_BOOST_UUID = 218;\nconst VERSION_SELECTIVE_COMPRESSION = 220;\nconst VERSION_NODE_MASK_COMPRESSION = 222;\nconst VERSION_BLOSC_COMPRESSION = 223;\n\nconst GRID_TYPE_RE = /^Tree_([A-Za-z0-9]+)_(\\d+)_(\\d+)_(\\d+)$/;\n\n/** On-disk value types this parser reads (the `<valueType>` of the grid type), and their layout. */\nconst VALUE_FORMATS = {\n float: FLOAT_FORMAT,\n vec3s: VEC3S_FORMAT,\n vec3d: VEC3D_FORMAT,\n vec3i: VEC3I_FORMAT,\n ptdataidx32: PTDATAIDX32_FORMAT,\n // K7.C: OpenVDB 13+ `HalfGrid`. Values widen exactly to f32, so it parses as a float grid\n // (`valueType: \"float\"`, `gridType` keeps `Tree_half_5_4_3`; DIVERGES V70).\n half: HALF_FORMAT,\n} as const satisfies Record<string, ValueFormat>;\n\ntype OnDiskValueType = keyof typeof VALUE_FORMATS;\n\n/** The parsed grid's `valueType` for each on-disk value type. */\nconst PARSED_VALUE_TYPE: Record<OnDiskValueType, VdbValueType> = {\n float: \"float\",\n vec3s: \"vec3s\",\n vec3d: \"vec3d\",\n vec3i: \"vec3i\",\n ptdataidx32: \"ptdataidx32\",\n half: \"float\",\n};\n\nfunction isSupportedValueType(t: string): t is OnDiskValueType {\n return Object.prototype.hasOwnProperty.call(VALUE_FORMATS, t);\n}\n\nfunction readHeaderCompression(reader: ByteReader, fileVersion: number): CompressionFlags {\n let compression: CompressionFlags = { zip: false, activeMask: true, blosc: true }; // DEFAULT_COMPRESSION\n if (fileVersion < VERSION_BLOSC_COMPRESSION) {\n compression = { zip: true, activeMask: true, blosc: false };\n }\n if (fileVersion >= VERSION_SELECTIVE_COMPRESSION && fileVersion < VERSION_NODE_MASK_COMPRESSION) {\n const isCompressed = reader.bool();\n compression = isCompressed\n ? { zip: true, activeMask: false, blosc: false }\n : { zip: false, activeMask: false, blosc: false };\n }\n return compression;\n}\n\nfunction readBBoxFromMetadata(metadata: Record<string, unknown>): VdbBBox | null {\n const min = metadata[\"file_bbox_min\"];\n const max = metadata[\"file_bbox_max\"];\n if (Array.isArray(min) && Array.isArray(max) && min.length === 3 && max.length === 3) {\n return {\n min: [min[0], min[1], min[2]] as [number, number, number],\n max: [max[0], max[1], max[2]] as [number, number, number],\n };\n }\n return null;\n}\n\nexport interface ParseVdbOptions {\n /**\n * Called for every grid once its header (name, type, metadata, transform) is read, before its tree. Return `false`\n * to skip decoding that grid; it still appears in `VdbFile.descriptors`. Passing `select` also switches the\n * parser to report mode: a grid it cannot decode (unsupported value type, tree layout, transform or instancing)\n * is listed with `descriptor.unsupported` set and skipped, instead of throwing. `select` is not called for it.\n *\n * Without `select`, every grid is decoded and an unsupported grid throws `VDBUnsupportedError`, as before.\n * `select: () => false` is a cheap listing pass: no tree is decoded or decompressed.\n */\n select?: (descriptor: VdbGridDescriptor) => boolean;\n}\n\n/**\n * Parses an OpenVDB `.vdb` file (float, half, vec3 and point data grids) into trees you can read, iterate or\n * convert to NanoVDB. Returns the decoded `grids` and a `descriptors` entry for every grid in the file.\n * Throws `VdbFormatError` for a malformed buffer, `VDBUnsupportedError` for unsupported constructs (without\n * `select`; with it, an unsupported grid is reported in its descriptor). See {@link ParseVdbOptions.select} to list\n * grids cheaply or decode only some of them.\n *\n * @param buffer The file's bytes.\n * @param options `select`: which grids to decode.\n */\nexport function parseVdb(buffer: ArrayBuffer, options: ParseVdbOptions = {}): VdbFile {\n const reader = new ByteReader(buffer);\n\n if (reader.length < 8) {\n throw new VdbFormatError(\"buffer too short to contain the magic number\");\n }\n const magicLow = reader.u32();\n const magicHigh = reader.u32();\n if (magicLow !== MAGIC_LOW || magicHigh !== 0) {\n throw new VdbFormatError(\n `bad magic number (expected 0x${MAGIC_LOW.toString(16)}, got 0x${magicLow.toString(16)}) — not a .vdb file`,\n );\n }\n\n const fileVersion = reader.u32();\n if (fileVersion < MIN_SUPPORTED_VERSION) {\n throw new VDBUnsupportedError(\n `file version ${fileVersion} is older than the minimum supported version ${MIN_SUPPORTED_VERSION}`,\n );\n }\n\n if (fileVersion > MAX_SUPPORTED_VERSION) {\n throw new VDBUnsupportedError(\n `file version ${fileVersion} is newer than the maximum supported version ${MAX_SUPPORTED_VERSION} ` +\n `(the file was written by a newer OpenVDB; OpenVDB v14 still writes ${MAX_SUPPORTED_VERSION}). ` +\n `Re-save it with OpenVDB 14 or earlier.`,\n );\n }\n\n reader.u32(); // library version major (informational only)\n reader.u32(); // library version minor (informational only)\n\n const hasGridOffsets = reader.bool();\n if (!hasGridOffsets) {\n throw new VDBUnsupportedError(\"VDB streams without grid offsets are not supported\");\n }\n\n const headerCompression = readHeaderCompression(reader, fileVersion);\n\n if (fileVersion < VERSION_BOOST_UUID) {\n throw new VDBUnsupportedError(`file version ${fileVersion} predates the Boost-UUID header layout (< 218)`);\n }\n reader.fixedString(36); // uuid (informational only)\n\n readMetadataMap(reader); // file-level metadata (informational only)\n\n const gridCount = reader.u32();\n const grids: VdbGrid[] = [];\n const descriptors: VdbGridDescriptor[] = [];\n const select = options.select;\n const strict = !select;\n\n for (let i = 0; i < gridCount; i++) {\n const uniqueName = reader.string();\n const name = uniqueName.split(\"\\x1e\")[0] ?? uniqueName;\n let gridType = reader.string();\n\n let savedAsHalfFloat = false;\n if (gridType.includes(\"_HalfFloat\")) {\n savedAsHalfFloat = true;\n gridType = gridType.split(\"_HalfFloat\").join(\"\");\n }\n\n let instanceParentName = \"\";\n if (fileVersion >= VERSION_GRID_INSTANCING) {\n instanceParentName = reader.string();\n }\n const instanced = instanceParentName !== \"\";\n if (instanced && strict) {\n throw new VDBUnsupportedError(`grid \"${name}\": instanced grids (sharing another grid's tree) are not supported`);\n }\n\n const gridPos = reader.u64AsNumber();\n const blockPos = reader.u64AsNumber();\n void blockPos; // not needed: we read topology+buffers in one contiguous pass\n const endPos = reader.u64AsNumber();\n\n reader.seek(gridPos);\n\n const compression =\n fileVersion >= VERSION_NODE_MASK_COMPRESSION\n ? compressionFromBits(reader.u32())\n : headerCompression;\n\n const metadata = readMetadataMap(reader);\n const useHalf = savedAsHalfFloat || metadata[\"is_saved_as_half_float\"] === true;\n\n const indexBBox = readBBoxFromMetadata(metadata);\n const gridClass = typeof metadata[\"class\"] === \"string\" ? (metadata[\"class\"] as string) : \"\";\n\n // Why this grid cannot be decoded, or null. Strict mode (no `select`) throws it; report mode records it.\n let unsupported: string | null = null;\n let valueType = \"\";\n const match = GRID_TYPE_RE.exec(gridType);\n if (instanced) {\n unsupported = \"instanced grids (sharing another grid's tree) are not supported\";\n } else if (!match) {\n unsupported = `unrecognized grid type \"${gridType}\" (expected \"Tree_<valueType>_<log2dim>_<log2dim>_<log2dim>\")`;\n } else {\n const [, vt, d0, d1, d2] = match;\n valueType = vt!;\n if (!isSupportedValueType(valueType)) {\n unsupported = `value type \"${valueType}\" is not supported (supported: ${Object.keys(VALUE_FORMATS).join(\", \")})`;\n } else if (d0 !== \"5\" || d1 !== \"4\" || d2 !== \"3\") {\n unsupported = `tree configuration ${d0}-${d1}-${d2} is not supported (only the 5-4-3 tree is in scope)`;\n }\n }\n if (unsupported !== null && strict) throw new VDBUnsupportedError(`grid \"${name}\": ${unsupported}`);\n\n let transform: VdbTransformInfo | null = null;\n if (unsupported === null) {\n try {\n transform = readTransform(reader);\n } catch (e) {\n if (strict || !(e instanceof VDBUnsupportedError)) throw e;\n unsupported = `transform: ${e.message}`;\n }\n }\n\n const descriptor: VdbGridDescriptor = {\n name,\n gridType,\n valueType,\n gridClass,\n transform,\n indexBBox,\n compression: { zip: compression.zip, activeMask: compression.activeMask, blosc: compression.blosc },\n unsupported,\n };\n descriptors.push(descriptor);\n\n if (unsupported === null && transform !== null && (select === undefined || select(descriptor))) {\n const vt = valueType as OnDiskValueType;\n const { background, leaves, tiles, activeVoxelCount, pointLeaves, pointOutputBudget } = readTree(reader, {\n fileVersion,\n compression,\n useHalf,\n format: VALUE_FORMATS[vt],\n pointData: vt === \"ptdataidx32\",\n });\n\n grids.push(\n createVdbGrid({\n name,\n gridType,\n valueType: PARSED_VALUE_TYPE[vt],\n transform,\n metadata,\n indexBBox,\n activeVoxelCount,\n background,\n leaves,\n tiles,\n ...(pointLeaves ? { pointLeaves, pointOutputBudget } : {}),\n }),\n );\n }\n\n // Defensive re-sync (matches the `mjurczyk/openvdb` reader's own hack):\n // land exactly on the next grid descriptor regardless of any drift.\n reader.seek(endPos);\n }\n\n return { fileVersion, grids, descriptors };\n}\n"]}
@@ -1,4 +1,11 @@
1
- import type { VdbPointDataGrid } from "./types.js";
1
+ import type { VdbPointAttributeArray, VdbPointDataGrid } from "./types.js";
2
+ /** One extra attribute carried by {@link VDBPointRenderData}: values in the kept points' order. */
3
+ export interface VDBPointRenderAttribute {
4
+ /** `count * components` values, the decoder's element type (real attributes are `Float32Array`, `double` `Float64Array`). */
5
+ values: VdbPointAttributeArray;
6
+ /** Values per point (vector components times the attribute's stride). */
7
+ components: number;
8
+ }
2
9
  /** What `VDBPoints` draws: world positions (xyz per point), optional linear RGB, the mean spacing. */
3
10
  export interface VDBPointRenderData {
4
11
  /** Points in the arrays. */
@@ -13,6 +20,27 @@ export interface VDBPointRenderData {
13
20
  positions: Float32Array;
14
21
  /** `Cd` per point (`count * 3`), or null when the grid has no 3-component real `Cd`. */
15
22
  colors: Float32Array | null;
23
+ /** The attributes asked for with `attributes` that the grid has, in the same order as `positions`. */
24
+ attributes: Record<string, VDBPointRenderAttribute>;
25
+ /**
26
+ * `order: 'prefix'` only: `prefix[k]` (k = 0..10) is how many points the first k tenths of the arrays hold.
27
+ * `prefix[1]` is every 10th kept point, `prefix[5]` every 2nd, `prefix[10]` = `count`. Null for `order: 'grid'`.
28
+ */
29
+ prefix: number[] | null;
30
+ /** Box of the kept positions (world units), or null without points. */
31
+ bounds: {
32
+ min: [number, number, number];
33
+ max: [number, number, number];
34
+ } | null;
35
+ }
36
+ /** Progress of {@link vdbPointRenderData}: the decode (per leaf of the grid), then the copy into render order. */
37
+ export interface VDBPointRenderDataProgress {
38
+ /** `'decode'`: the grid's attribute arrays (skipped when `grid.points()` already ran); `'copy'`: the render arrays. */
39
+ stage: "decode" | "copy";
40
+ /** Points done so far in this stage. */
41
+ done: number;
42
+ /** Points in this stage. */
43
+ total: number;
16
44
  }
17
45
  /** Options of {@link vdbPointRenderData}. */
18
46
  export interface VDBPointRenderDataOptions {
@@ -20,6 +48,16 @@ export interface VDBPointRenderDataOptions {
20
48
  maxPoints?: number;
21
49
  /** Colour attribute name. Default `'Cd'`. */
22
50
  color?: string;
51
+ /** Other attributes to carry, by name (e.g. `['v']`). Names the grid does not have (or could not decode) are left out. */
52
+ attributes?: readonly string[];
53
+ /**
54
+ * `'grid'` (default): the grid's point order. `'prefix'`: residue classes of the kept index mod 10 in the order
55
+ * 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, so every prefix of k tenths (`prefix[k]` points) is an even subsample: drawing
56
+ * fewer points is an instance count, not new buffers.
57
+ */
58
+ order?: "grid" | "prefix";
59
+ /** Called during the decode (per leaf) and the copy (every 2^20 points), and once at the end of each stage. */
60
+ onProgress?: (progress: VDBPointRenderDataProgress) => void;
23
61
  }
24
62
  /** His `defaultMaxPoints`. */
25
63
  export declare const VDB_POINTS_DEFAULT_MAX = 4000000;
@@ -27,5 +65,15 @@ export declare const VDB_POINTS_DEFAULT_MAX = 4000000;
27
65
  * Builds the {@link VDBPointRenderData} of a parsed point data grid
28
66
  * (`parseVdb(...).grids` entry with `valueType: 'ptdataidx32'`). Decodes the
29
67
  * grid's points (`grid.points()`, cached by the grid).
68
+ *
69
+ * @param grid A point data grid from `parseVdb`.
70
+ * @param options Point limit, attributes, order and progress ({@link VDBPointRenderDataOptions}).
30
71
  */
31
72
  export declare function vdbPointRenderData(grid: VdbPointDataGrid, options?: VDBPointRenderDataOptions): VDBPointRenderData;
73
+ /**
74
+ * The buffers of a {@link VDBPointRenderData} to pass as a `postMessage` transfer list (each once), so a worker hands
75
+ * the arrays to the page without a copy: `self.postMessage(data, vdbPointRenderDataTransfer(data))`.
76
+ *
77
+ * @param data Render data from {@link vdbPointRenderData}.
78
+ */
79
+ export declare function vdbPointRenderDataTransfer(data: VDBPointRenderData): ArrayBuffer[];
@@ -1,23 +1,34 @@
1
1
  /**
2
- * The render-ready point list of a point data grid (K3.7): world positions,
3
- * optional `Cd` colours, a subsample stride above `maxPoints`, and the mean
4
- * point spacing that sizes the sprites. The input `VDBPoints` (`./three`)
5
- * draws.
2
+ * The render-ready point list of a point data grid (K3.7, G14a): world positions,
3
+ * optional `Cd` colours and other attributes, a subsample stride above
4
+ * `maxPoints`, an optional prefix-subsample order, and the mean point spacing
5
+ * that sizes the sprites. The input `VDBPoints` (`./three`) draws.
6
6
  *
7
7
  * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345
8
8
  * (`src/openvdb/utils/points.js` `createPointData`: the stride rule, the count,
9
9
  * the spacing formula). Copyright (c) mjurczyk/openvdb contributors, MIT (see
10
10
  * THIRD_PARTY_NOTICES.md). Changes: built on our parsed `VdbPointDataGrid.points()`
11
11
  * (K4.2) in one pass instead of a sliced generator; `Cd` of any decoded
12
- * 3-component real attribute (DIVERGES.md).
12
+ * 3-component real attribute; other attributes, a prefix order, progress and
13
+ * bounds (G14a) (DIVERGES.md).
14
+ *
15
+ * Worker use: everything here is plain data (typed arrays and numbers), so a
16
+ * worker can `parseVdb` and call {@link vdbPointRenderData}, then post the result
17
+ * with {@link vdbPointRenderDataTransfer} as the transfer list.
13
18
  */
14
19
  import { VDBToolsError } from "../errors.js";
15
20
  /** His `defaultMaxPoints`. */
16
21
  export const VDB_POINTS_DEFAULT_MAX = 4_000_000;
22
+ /** Residue classes mod 10 in prefix order: 10 % (class 0), then to 50 % (the even classes), then the odd ones. */
23
+ const PREFIX_CLASSES = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9];
24
+ const classSize = (n, c) => (c < n ? Math.floor((n - 1 - c) / 10) + 1 : 0);
17
25
  /**
18
26
  * Builds the {@link VDBPointRenderData} of a parsed point data grid
19
27
  * (`parseVdb(...).grids` entry with `valueType: 'ptdataidx32'`). Decodes the
20
28
  * grid's points (`grid.points()`, cached by the grid).
29
+ *
30
+ * @param grid A point data grid from `parseVdb`.
31
+ * @param options Point limit, attributes, order and progress ({@link VDBPointRenderDataOptions}).
21
32
  */
22
33
  export function vdbPointRenderData(grid, options = {}) {
23
34
  if (grid?.valueType !== "ptdataidx32" || typeof grid.points !== "function") {
@@ -26,7 +37,11 @@ export function vdbPointRenderData(grid, options = {}) {
26
37
  const maxPoints = options.maxPoints ?? VDB_POINTS_DEFAULT_MAX;
27
38
  if (!(maxPoints >= 1))
28
39
  throw new VDBToolsError("VDB_BAD_OPTION", `vdbPointRenderData: maxPoints must be >= 1, got ${maxPoints}.`);
29
- const list = grid.points();
40
+ const order = options.order ?? "grid";
41
+ if (order !== "grid" && order !== "prefix")
42
+ throw new VDBToolsError("VDB_BAD_OPTION", `vdbPointRenderData: order must be 'grid' or 'prefix', got ${JSON.stringify(order)}.`);
43
+ const onProgress = options.onProgress;
44
+ const list = grid.points(onProgress ? { onProgress: (done, total) => onProgress({ stage: "decode", done, total }) } : undefined);
30
45
  const totalCount = list.count;
31
46
  const stride = Math.max(1, Math.ceil(totalCount / maxPoints));
32
47
  const count = totalCount > 0 ? Math.floor((totalCount - 1) / stride) + 1 : 0;
@@ -36,22 +51,87 @@ export function vdbPointRenderData(grid, options = {}) {
36
51
  const shape = list.attributeShapes[name];
37
52
  const hasColors = cd !== undefined && shape?.components === 3 && shape.stride === 1 && (cd instanceof Float32Array || cd instanceof Float64Array);
38
53
  const colors = hasColors ? new Float32Array(count * 3) : null;
39
- for (let i = 0, j = 0; i < totalCount; i += stride, j++) {
40
- positions[j * 3] = list.positions[i * 3];
41
- positions[j * 3 + 1] = list.positions[i * 3 + 1];
42
- positions[j * 3 + 2] = list.positions[i * 3 + 2];
54
+ const extra = [];
55
+ const attributes = {};
56
+ for (const a of options.attributes ?? []) {
57
+ const src = list.attributes[a];
58
+ const s = list.attributeShapes[a];
59
+ if (!src || !s || attributes[a])
60
+ continue;
61
+ const k = s.components * s.stride;
62
+ const dst = new src.constructor(count * k);
63
+ attributes[a] = { values: dst, components: k };
64
+ extra.push({ src, dst, k });
65
+ }
66
+ const min = [Infinity, Infinity, Infinity];
67
+ const max = [-Infinity, -Infinity, -Infinity];
68
+ const src = list.positions;
69
+ const copy = (i, j) => {
70
+ for (let c = 0; c < 3; c++) {
71
+ const p = src[i * 3 + c];
72
+ positions[j * 3 + c] = p;
73
+ if (p < min[c])
74
+ min[c] = p;
75
+ if (p > max[c])
76
+ max[c] = p;
77
+ }
43
78
  if (colors) {
44
79
  const c = cd;
45
80
  colors[j * 3] = c[i * 3];
46
81
  colors[j * 3 + 1] = c[i * 3 + 1];
47
82
  colors[j * 3 + 2] = c[i * 3 + 2];
48
83
  }
84
+ for (const e of extra)
85
+ for (let c = 0; c < e.k; c++)
86
+ e.dst[j * e.k + c] = e.src[i * e.k + c];
87
+ };
88
+ const tick = (j) => {
89
+ if (onProgress && (j & 0xfffff) === 0 && j > 0)
90
+ onProgress({ stage: "copy", done: j, total: count });
91
+ };
92
+ let prefix = null;
93
+ if (order === "prefix") {
94
+ // Kept index q = 0..count-1 (grid point q * stride), output position by residue class of q.
95
+ prefix = [0];
96
+ let j = 0;
97
+ for (const c of PREFIX_CLASSES) {
98
+ for (let q = c; q < count; q += 10, j++) {
99
+ copy(q * stride, j);
100
+ tick(j);
101
+ }
102
+ prefix.push(prefix[prefix.length - 1] + classSize(count, c));
103
+ }
49
104
  }
105
+ else {
106
+ for (let i = 0, j = 0; i < totalCount; i += stride, j++) {
107
+ copy(i, j);
108
+ tick(j);
109
+ }
110
+ }
111
+ onProgress?.({ stage: "copy", done: count, total: count });
50
112
  const [sx, sy, sz] = grid.transform.voxelSize;
51
113
  const voxelSize = Math.cbrt(Math.abs(sx * sy * sz));
52
114
  const activeVoxels = Number(grid.activeVoxelCount);
53
115
  const pointsPerVoxel = activeVoxels > 0 ? totalCount / activeVoxels : 1;
54
116
  const spacing = (voxelSize / Math.cbrt(pointsPerVoxel)) * Math.cbrt(stride);
55
- return { count, totalCount, stride, spacing, positions, colors };
117
+ return { count, totalCount, stride, spacing, positions, colors, attributes, prefix, bounds: count > 0 ? { min, max } : null };
118
+ }
119
+ /**
120
+ * The buffers of a {@link VDBPointRenderData} to pass as a `postMessage` transfer list (each once), so a worker hands
121
+ * the arrays to the page without a copy: `self.postMessage(data, vdbPointRenderDataTransfer(data))`.
122
+ *
123
+ * @param data Render data from {@link vdbPointRenderData}.
124
+ */
125
+ export function vdbPointRenderDataTransfer(data) {
126
+ const out = new Set();
127
+ const add = (a) => {
128
+ if (a && a.buffer instanceof ArrayBuffer)
129
+ out.add(a.buffer);
130
+ };
131
+ add(data.positions);
132
+ add(data.colors);
133
+ for (const a of Object.values(data.attributes))
134
+ add(a.values);
135
+ return [...out];
56
136
  }
57
137
  //# sourceMappingURL=point-render-data.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"point-render-data.js","sourceRoot":"","sources":["../../../src/tools/vdb/point-render-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA2B7C,8BAA8B;AAC9B,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAsB,EAAE,UAAqC,EAAE;IAChG,IAAI,IAAI,EAAE,SAAS,KAAK,aAAa,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAC3E,MAAM,IAAI,aAAa,CAAC,2BAA2B,EAAE,sFAAsF,CAAC,CAAC;IAC/I,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,sBAAsB,CAAC;IAC9D,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,aAAa,CAAC,gBAAgB,EAAE,mDAAmD,SAAS,GAAG,CAAC,CAAC;IAClI,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC;IAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC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AC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;QAClD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,EAAiC,CAAC;YAC5C,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC;YAC1B,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;YAClC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;QACpC,CAAC;IACH,CAAC;IACD,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AACnE,CAAC","sourcesContent":["/**\n * The render-ready point list of a point data grid (K3.7): world positions,\n * optional `Cd` colours, a subsample stride above `maxPoints`, and the mean\n * point spacing that sizes the sprites. The input `VDBPoints` (`./three`)\n * draws.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/openvdb/utils/points.js` `createPointData`: the stride rule, the count,\n * the spacing formula). Copyright (c) mjurczyk/openvdb contributors, MIT (see\n * THIRD_PARTY_NOTICES.md). Changes: built on our parsed `VdbPointDataGrid.points()`\n * (K4.2) in one pass instead of a sliced generator; `Cd` of any decoded\n * 3-component real attribute (DIVERGES.md).\n */\nimport { VDBToolsError } from \"../errors.js\";\nimport type { VdbPointDataGrid } from \"./types.js\";\n\n/** What `VDBPoints` draws: world positions (xyz per point), optional linear RGB, the mean spacing. */\nexport interface VDBPointRenderData {\n /** Points in the arrays. */\n count: number;\n /** Points in the grid before the stride. */\n totalCount: number;\n /** Every `stride`-th point (in the grid's point order) is kept; 1 below `maxPoints`. */\n stride: number;\n /** Mean distance between the kept points in world units: `voxelSize / cbrt(points per active voxel) * cbrt(stride)`. */\n spacing: number;\n /** World positions, `count * 3`. */\n positions: Float32Array;\n /** `Cd` per point (`count * 3`), or null when the grid has no 3-component real `Cd`. */\n colors: Float32Array | null;\n}\n\n/** Options of {@link vdbPointRenderData}. */\nexport interface VDBPointRenderDataOptions {\n /** Above this many points every `ceil(total / maxPoints)`-th point is kept (his default 4,000,000). */\n maxPoints?: number;\n /** Colour attribute name. Default `'Cd'`. */\n color?: string;\n}\n\n/** His `defaultMaxPoints`. */\nexport const VDB_POINTS_DEFAULT_MAX = 4_000_000;\n\n/**\n * Builds the {@link VDBPointRenderData} of a parsed point data grid\n * (`parseVdb(...).grids` entry with `valueType: 'ptdataidx32'`). Decodes the\n * grid's points (`grid.points()`, cached by the grid).\n */\nexport function vdbPointRenderData(grid: VdbPointDataGrid, options: VDBPointRenderDataOptions = {}): VDBPointRenderData {\n if (grid?.valueType !== \"ptdataidx32\" || typeof grid.points !== \"function\") {\n throw new VDBToolsError(\"VDB_UNSUPPORTED_GRID_TYPE\", \"vdbPointRenderData: grid must be a parsed point data grid (valueType 'ptdataidx32').\");\n }\n const maxPoints = options.maxPoints ?? VDB_POINTS_DEFAULT_MAX;\n if (!(maxPoints >= 1)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbPointRenderData: maxPoints must be >= 1, got ${maxPoints}.`);\n const list = grid.points();\n const totalCount = list.count;\n const stride = Math.max(1, Math.ceil(totalCount / maxPoints));\n const count = totalCount > 0 ? Math.floor((totalCount - 1) / stride) + 1 : 0;\n const positions = new Float32Array(count * 3);\n const name = options.color ?? \"Cd\";\n const cd = list.attributes[name];\n const shape = list.attributeShapes[name];\n const hasColors = cd !== undefined && shape?.components === 3 && shape.stride === 1 && (cd instanceof Float32Array || cd instanceof Float64Array);\n const colors = hasColors ? new Float32Array(count * 3) : null;\n for (let i = 0, j = 0; i < totalCount; i += stride, j++) {\n positions[j * 3] = list.positions[i * 3]!;\n positions[j * 3 + 1] = list.positions[i * 3 + 1]!;\n positions[j * 3 + 2] = list.positions[i * 3 + 2]!;\n if (colors) {\n const c = cd as Float32Array | Float64Array;\n colors[j * 3] = c[i * 3]!;\n colors[j * 3 + 1] = c[i * 3 + 1]!;\n colors[j * 3 + 2] = c[i * 3 + 2]!;\n }\n }\n const [sx, sy, sz] = grid.transform.voxelSize;\n const voxelSize = Math.cbrt(Math.abs(sx * sy * sz));\n const activeVoxels = Number(grid.activeVoxelCount);\n const pointsPerVoxel = activeVoxels > 0 ? totalCount / activeVoxels : 1;\n const spacing = (voxelSize / Math.cbrt(pointsPerVoxel)) * Math.cbrt(stride);\n return { count, totalCount, stride, spacing, positions, colors };\n}\n"]}
1
+ {"version":3,"file":"point-render-data.js","sourceRoot":"","sources":["../../../src/tools/vdb/point-render-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAgE7C,8BAA8B;AAC9B,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD,kHAAkH;AAClH,MAAM,cAAc,GAAG,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M,CAAC,CAAC;IAC5E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAChI,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAwB;IACjE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAe,CAAC;IACnC,MAAM,GAAG,GAAG,CAAC,CAAyB,EAAQ,EAAE;QAC9C,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW;YAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QAAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * The render-ready point list of a point data grid (K3.7, G14a): world positions,\n * optional `Cd` colours and other attributes, a subsample stride above\n * `maxPoints`, an optional prefix-subsample order, and the mean point spacing\n * that sizes the sprites. The input `VDBPoints` (`./three`) draws.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/openvdb/utils/points.js` `createPointData`: the stride rule, the count,\n * the spacing formula). Copyright (c) mjurczyk/openvdb contributors, MIT (see\n * THIRD_PARTY_NOTICES.md). Changes: built on our parsed `VdbPointDataGrid.points()`\n * (K4.2) in one pass instead of a sliced generator; `Cd` of any decoded\n * 3-component real attribute; other attributes, a prefix order, progress and\n * bounds (G14a) (DIVERGES.md).\n *\n * Worker use: everything here is plain data (typed arrays and numbers), so a\n * worker can `parseVdb` and call {@link vdbPointRenderData}, then post the result\n * with {@link vdbPointRenderDataTransfer} as the transfer list.\n */\nimport { VDBToolsError } from \"../errors.js\";\nimport type { VdbPointAttributeArray, VdbPointDataGrid } from \"./types.js\";\n\n/** One extra attribute carried by {@link VDBPointRenderData}: values in the kept points' order. */\nexport interface VDBPointRenderAttribute {\n /** `count * components` values, the decoder's element type (real attributes are `Float32Array`, `double` `Float64Array`). */\n values: VdbPointAttributeArray;\n /** Values per point (vector components times the attribute's stride). */\n components: number;\n}\n\n/** What `VDBPoints` draws: world positions (xyz per point), optional linear RGB, the mean spacing. */\nexport interface VDBPointRenderData {\n /** Points in the arrays. */\n count: number;\n /** Points in the grid before the stride. */\n totalCount: number;\n /** Every `stride`-th point (in the grid's point order) is kept; 1 below `maxPoints`. */\n stride: number;\n /** Mean distance between the kept points in world units: `voxelSize / cbrt(points per active voxel) * cbrt(stride)`. */\n spacing: number;\n /** World positions, `count * 3`. */\n positions: Float32Array;\n /** `Cd` per point (`count * 3`), or null when the grid has no 3-component real `Cd`. */\n colors: Float32Array | null;\n /** The attributes asked for with `attributes` that the grid has, in the same order as `positions`. */\n attributes: Record<string, VDBPointRenderAttribute>;\n /**\n * `order: 'prefix'` only: `prefix[k]` (k = 0..10) is how many points the first k tenths of the arrays hold.\n * `prefix[1]` is every 10th kept point, `prefix[5]` every 2nd, `prefix[10]` = `count`. Null for `order: 'grid'`.\n */\n prefix: number[] | null;\n /** Box of the kept positions (world units), or null without points. */\n bounds: { min: [number, number, number]; max: [number, number, number] } | null;\n}\n\n/** Progress of {@link vdbPointRenderData}: the decode (per leaf of the grid), then the copy into render order. */\nexport interface VDBPointRenderDataProgress {\n /** `'decode'`: the grid's attribute arrays (skipped when `grid.points()` already ran); `'copy'`: the render arrays. */\n stage: \"decode\" | \"copy\";\n /** Points done so far in this stage. */\n done: number;\n /** Points in this stage. */\n total: number;\n}\n\n/** Options of {@link vdbPointRenderData}. */\nexport interface VDBPointRenderDataOptions {\n /** Above this many points every `ceil(total / maxPoints)`-th point is kept (his default 4,000,000). */\n maxPoints?: number;\n /** Colour attribute name. Default `'Cd'`. */\n color?: string;\n /** Other attributes to carry, by name (e.g. `['v']`). Names the grid does not have (or could not decode) are left out. */\n attributes?: readonly string[];\n /**\n * `'grid'` (default): the grid's point order. `'prefix'`: residue classes of the kept index mod 10 in the order\n * 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, so every prefix of k tenths (`prefix[k]` points) is an even subsample: drawing\n * fewer points is an instance count, not new buffers.\n */\n order?: \"grid\" | \"prefix\";\n /** Called during the decode (per leaf) and the copy (every 2^20 points), and once at the end of each stage. */\n onProgress?: (progress: VDBPointRenderDataProgress) => void;\n}\n\n/** His `defaultMaxPoints`. */\nexport const VDB_POINTS_DEFAULT_MAX = 4_000_000;\n\n/** Residue classes mod 10 in prefix order: 10 % (class 0), then to 50 % (the even classes), then the odd ones. */\nconst PREFIX_CLASSES = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9] as const;\nconst classSize = (n: number, c: number): number => (c < n ? Math.floor((n - 1 - c) / 10) + 1 : 0);\n\n/**\n * Builds the {@link VDBPointRenderData} of a parsed point data grid\n * (`parseVdb(...).grids` entry with `valueType: 'ptdataidx32'`). Decodes the\n * grid's points (`grid.points()`, cached by the grid).\n *\n * @param grid A point data grid from `parseVdb`.\n * @param options Point limit, attributes, order and progress ({@link VDBPointRenderDataOptions}).\n */\nexport function vdbPointRenderData(grid: VdbPointDataGrid, options: VDBPointRenderDataOptions = {}): VDBPointRenderData {\n if (grid?.valueType !== \"ptdataidx32\" || typeof grid.points !== \"function\") {\n throw new VDBToolsError(\"VDB_UNSUPPORTED_GRID_TYPE\", \"vdbPointRenderData: grid must be a parsed point data grid (valueType 'ptdataidx32').\");\n }\n const maxPoints = options.maxPoints ?? VDB_POINTS_DEFAULT_MAX;\n if (!(maxPoints >= 1)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbPointRenderData: maxPoints must be >= 1, got ${maxPoints}.`);\n const order = options.order ?? \"grid\";\n if (order !== \"grid\" && order !== \"prefix\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbPointRenderData: order must be 'grid' or 'prefix', got ${JSON.stringify(order)}.`);\n const onProgress = options.onProgress;\n const list = grid.points(onProgress ? { onProgress: (done, total) => onProgress({ stage: \"decode\", done, total }) } : undefined);\n const totalCount = list.count;\n const stride = Math.max(1, Math.ceil(totalCount / maxPoints));\n const count = totalCount > 0 ? Math.floor((totalCount - 1) / stride) + 1 : 0;\n const positions = new Float32Array(count * 3);\n const name = options.color ?? \"Cd\";\n const cd = list.attributes[name];\n const shape = list.attributeShapes[name];\n const hasColors = cd !== undefined && shape?.components === 3 && shape.stride === 1 && (cd instanceof Float32Array || cd instanceof Float64Array);\n const colors = hasColors ? new Float32Array(count * 3) : null;\n const extra: { src: VdbPointAttributeArray; dst: VdbPointAttributeArray; k: number }[] = [];\n const attributes: Record<string, VDBPointRenderAttribute> = {};\n for (const a of options.attributes ?? []) {\n const src = list.attributes[a];\n const s = list.attributeShapes[a];\n if (!src || !s || attributes[a]) continue;\n const k = s.components * s.stride;\n const dst = new (src.constructor as new (n: number) => VdbPointAttributeArray)(count * k);\n attributes[a] = { values: dst, components: k };\n extra.push({ src, dst, k });\n }\n const min: [number, number, number] = [Infinity, Infinity, Infinity];\n const max: [number, number, number] = [-Infinity, -Infinity, -Infinity];\n const src = list.positions;\n const copy = (i: number, j: number): void => {\n for (let c = 0; c < 3; c++) {\n const p = src[i * 3 + c]!;\n positions[j * 3 + c] = p;\n if (p < min[c]!) min[c] = p;\n if (p > max[c]!) max[c] = p;\n }\n if (colors) {\n const c = cd as Float32Array | Float64Array;\n colors[j * 3] = c[i * 3]!;\n colors[j * 3 + 1] = c[i * 3 + 1]!;\n colors[j * 3 + 2] = c[i * 3 + 2]!;\n }\n for (const e of extra) for (let c = 0; c < e.k; c++) (e.dst as Float32Array)[j * e.k + c] = (e.src as Float32Array)[i * e.k + c]!;\n };\n const tick = (j: number): void => {\n if (onProgress && (j & 0xfffff) === 0 && j > 0) onProgress({ stage: \"copy\", done: j, total: count });\n };\n let prefix: number[] | null = null;\n if (order === \"prefix\") {\n // Kept index q = 0..count-1 (grid point q * stride), output position by residue class of q.\n prefix = [0];\n let j = 0;\n for (const c of PREFIX_CLASSES) {\n for (let q = c; q < count; q += 10, j++) {\n copy(q * stride, j);\n tick(j);\n }\n prefix.push(prefix[prefix.length - 1]! + classSize(count, c));\n }\n } else {\n for (let i = 0, j = 0; i < totalCount; i += stride, j++) {\n copy(i, j);\n tick(j);\n }\n }\n onProgress?.({ stage: \"copy\", done: count, total: count });\n const [sx, sy, sz] = grid.transform.voxelSize;\n const voxelSize = Math.cbrt(Math.abs(sx * sy * sz));\n const activeVoxels = Number(grid.activeVoxelCount);\n const pointsPerVoxel = activeVoxels > 0 ? totalCount / activeVoxels : 1;\n const spacing = (voxelSize / Math.cbrt(pointsPerVoxel)) * Math.cbrt(stride);\n return { count, totalCount, stride, spacing, positions, colors, attributes, prefix, bounds: count > 0 ? { min, max } : null };\n}\n\n/**\n * The buffers of a {@link VDBPointRenderData} to pass as a `postMessage` transfer list (each once), so a worker hands\n * the arrays to the page without a copy: `self.postMessage(data, vdbPointRenderDataTransfer(data))`.\n *\n * @param data Render data from {@link vdbPointRenderData}.\n */\nexport function vdbPointRenderDataTransfer(data: VDBPointRenderData): ArrayBuffer[] {\n const out = new Set<ArrayBuffer>();\n const add = (a: ArrayBufferView | null): void => {\n if (a && a.buffer instanceof ArrayBuffer) out.add(a.buffer);\n };\n add(data.positions);\n add(data.colors);\n for (const a of Object.values(data.attributes)) add(a.values);\n return [...out];\n}\n"]}
@@ -63,6 +63,30 @@
63
63
  * budget of {@link MAX_POINT_EXPANSION} times the file size before it is
64
64
  * allocated. Strides and group offsets are range-checked (no int32
65
65
  * wrap-around).
66
+ *
67
+ * ## OpenVDB v14.0.0 security checks (K7.C)
68
+ *
69
+ * OpenVDB v14 throws `IoError` on four PointDataGrid inconsistencies
70
+ * (CHANGES "Security Fixes"; `TypedAttributeArray::readMetadata` /
71
+ * `readBuffers` / `readPagedBuffers`, `PagedInputStream::createHandle` /
72
+ * `read`, `Page::readHeader`, `codecs/PointDataCodec.h`
73
+ * `validateReadOffsets` / `validatePointDataAttributeCount`). Each maps here:
74
+ *
75
+ * 1. Attribute byte count smaller than the array: a byte count below its 6
76
+ * header bytes, a size of 0, a constant stride of 0 or with `size * stride`
77
+ * past u32, and a total size below `size` fail in `readArrayMetadata`;
78
+ * the stored bytes must equal the array's exactly (stricter than v14's
79
+ * "at least") when {@link decodePoints} reads them.
80
+ * 2. Page size that does not match its data: page headers of 0, i32 minimum or
81
+ * a non-positive uncompressed size, an array of 0 bytes or past its page
82
+ * (`createPageHandle`), and a page whose arrays don't fill it exactly
83
+ * (`checkStreamComplete`, stricter than v14's unread-page check); a
84
+ * decoded page must be exactly its header's size.
85
+ * 3. Voxel offsets beyond the arrays: end offsets must not decrease, and every
86
+ * array's size must equal the leaf's last offset (v14: offsets at most the
87
+ * last, the last at most each size; ours is exact).
88
+ * 4. Pass count too small: a leaf with more arrays than `(numPasses - 4) / 2`
89
+ * covers fails (and fewer than 4 passes with leaves).
66
90
  */
67
91
  import type { ByteReader } from "./byte-reader.js";
68
92
  import type { VdbPointAttributeInfo, VdbPointList } from "./types.js";
@@ -151,6 +175,8 @@ export interface DecodePointsOptions {
151
175
  * Default: unlimited.
152
176
  */
153
177
  maxOutputBytes?: number;
178
+ /** Called after each leaf with the points decoded so far and the total (G14a). */
179
+ onProgress?: (decoded: number, total: number) => void;
154
180
  }
155
181
  /**
156
182
  * Decodes the points of a parsed point data grid: world-space positions from
@@ -63,6 +63,30 @@
63
63
  * budget of {@link MAX_POINT_EXPANSION} times the file size before it is
64
64
  * allocated. Strides and group offsets are range-checked (no int32
65
65
  * wrap-around).
66
+ *
67
+ * ## OpenVDB v14.0.0 security checks (K7.C)
68
+ *
69
+ * OpenVDB v14 throws `IoError` on four PointDataGrid inconsistencies
70
+ * (CHANGES "Security Fixes"; `TypedAttributeArray::readMetadata` /
71
+ * `readBuffers` / `readPagedBuffers`, `PagedInputStream::createHandle` /
72
+ * `read`, `Page::readHeader`, `codecs/PointDataCodec.h`
73
+ * `validateReadOffsets` / `validatePointDataAttributeCount`). Each maps here:
74
+ *
75
+ * 1. Attribute byte count smaller than the array: a byte count below its 6
76
+ * header bytes, a size of 0, a constant stride of 0 or with `size * stride`
77
+ * past u32, and a total size below `size` fail in `readArrayMetadata`;
78
+ * the stored bytes must equal the array's exactly (stricter than v14's
79
+ * "at least") when {@link decodePoints} reads them.
80
+ * 2. Page size that does not match its data: page headers of 0, i32 minimum or
81
+ * a non-positive uncompressed size, an array of 0 bytes or past its page
82
+ * (`createPageHandle`), and a page whose arrays don't fill it exactly
83
+ * (`checkStreamComplete`, stricter than v14's unread-page check); a
84
+ * decoded page must be exactly its header's size.
85
+ * 3. Voxel offsets beyond the arrays: end offsets must not decrease, and every
86
+ * array's size must equal the leaf's last offset (v14: offsets at most the
87
+ * last, the last at most each size; ours is exact).
88
+ * 4. Pass count too small: a leaf with more arrays than `(numPasses - 4) / 2`
89
+ * covers fails (and fewer than 4 passes with leaves).
66
90
  */
67
91
  import { decompressBlosc } from "./blosc.js";
68
92
  import { VdbFormatError, VDBUnsupportedError } from "./errors.js";
@@ -160,8 +184,20 @@ function readArrayMetadata(reader) {
160
184
  }
161
185
  const bytes = Number(total) - 2 - 4; // minus the two flag bytes and the u32 size
162
186
  const strideOrTotal = serialization & WRITE_STRIDED ? reader.u32() : 1;
163
- if (serialization & WRITE_STRIDED && flags & FLAG_CONSTANT_STRIDE && strideOrTotal === 0) {
164
- throw new VdbFormatError("point attribute array has a constant stride of 0");
187
+ // OpenVDB v14 (`readMetadata`): size and stride come from the file, so a size of 0, a constant
188
+ // stride of 0 or whose `size * stride` passes u32, or a total below the size is an IoError.
189
+ if (size === 0)
190
+ throw new VdbFormatError("point attribute array has a size of 0");
191
+ const constantStride = !(serialization & WRITE_STRIDED) || (flags & FLAG_CONSTANT_STRIDE) !== 0;
192
+ if (constantStride) {
193
+ if (strideOrTotal === 0)
194
+ throw new VdbFormatError("point attribute array has a constant stride of 0");
195
+ if (size * strideOrTotal > 0xffffffff) {
196
+ throw new VdbFormatError(`point attribute array of ${size} x stride ${strideOrTotal} values passes 2^32`);
197
+ }
198
+ }
199
+ else if (strideOrTotal < size) {
200
+ throw new VdbFormatError(`point attribute array has a total size of ${strideOrTotal}, below its ${size} points`);
165
201
  }
166
202
  return {
167
203
  flags,
@@ -182,7 +218,8 @@ function createPageHandle(reader, stream, array) {
182
218
  if (stream.byteIndex === stream.uncompressedBytes) {
183
219
  const compressedBytes = reader.i32();
184
220
  const uncompressedBytes = compressedBytes > 0 ? reader.i32() : -compressedBytes;
185
- if (compressedBytes === 0 || uncompressedBytes <= 0) {
221
+ // OpenVDB v14 `Page::readHeader`: 0 and the i32 minimum (whose negation overflows) are invalid.
222
+ if (compressedBytes === 0 || compressedBytes === -0x80000000 || uncompressedBytes <= 0) {
186
223
  throw new VdbFormatError(`point attribute page header ${compressedBytes}/${uncompressedBytes} is empty`);
187
224
  }
188
225
  // The body follows later in the file, so it can be no larger than the file.
@@ -197,8 +234,9 @@ function createPageHandle(reader, stream, array) {
197
234
  stream.uncompressedBytes = uncompressedBytes;
198
235
  stream.byteIndex = 0;
199
236
  }
200
- if (stream.byteIndex + array.bytes > stream.uncompressedBytes) {
201
- throw new VdbFormatError(`point attribute array of ${array.bytes} bytes overruns its ${stream.uncompressedBytes}-byte page`);
237
+ // OpenVDB v14 `PagedInputStream::createHandle`: a handle of n <= 0 bytes, or past the page, is an IoError.
238
+ if (array.bytes <= 0 || stream.byteIndex + array.bytes > stream.uncompressedBytes) {
239
+ throw new VdbFormatError(`point attribute array of ${array.bytes} bytes ${array.bytes <= 0 ? "is empty in" : "overruns"} its ${stream.uncompressedBytes}-byte page`);
202
240
  }
203
241
  array.page = stream.page;
204
242
  array.pageOffset = stream.byteIndex;
@@ -770,7 +808,10 @@ export function decodePoints(leaves, matrix, options = {}) {
770
808
  }
771
809
  }
772
810
  base += leafCount;
811
+ options.onProgress?.(base, count);
773
812
  }
813
+ if (leaves.length === 0)
814
+ options.onProgress?.(0, 0);
774
815
  return { count, positions, attributes, attributeShapes, groups, skipped };
775
816
  }
776
817
  /**