@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"majorant.js","sourceRoot":"","sources":["../../../src/tools/cpu/majorant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,GAEX,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;AAkDtB,SAAS,GAAG,CAAC,OAAe;IAC1B,MAAM,IAAI,aAAa,CAAC,gBAAgB,EAAE,qBAAqB,OAAO,EAAE,CAAC,CAAC;AAC5E,CAAC;AAkBD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAS,EAAE,GAAS,EAAE,UAAmC,EAAE;IAC7F,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,GAAG,CAAC,kCAAkC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvH,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,EAAE;QAAE,GAAG,CAAC,8CAA8C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzH,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,SAAS,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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjE,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBACpB,OAAO,CAAC,CAAC;gBACX,CAAC;gBACD,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;oBAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * Majorants for delta and ratio tracking (P1.2, P1.3, P1.4; docs/dev/design/K1-core.md §5).\n *\n * {@link vdbBrickMajorant} builds the brick grid the core's `majorant` WGSL profile walks: one upper\n * (and optionally lower) bound per cell of `2^brickLog2` index voxels, over the SAMPLED field. A\n * trilinear sample at `p` reads voxels `floor(p)` and `floor(p) + 1`, so a cell that holds the\n * positions `[o + B c, o + B (c + 1))` (origin `o`, edge `B`) bounds the voxels `[o + B c, o + B c + B]`\n * (its \"taps\", `B + 1` per axis): leaf voxels active or not, tile values, and the background.\n *\n * {@link vdbMajorantWalk} is the CPU twin of `vdbMajorantInit` / `vdbMajorantNext` (all three modes, and the\n * `vdbMajorantInitWorld` / `vdbMajorantInitGlobal` helpers), in f32 in the WGSL's evaluation order. Like the other\n * twins, GPU parity compares `t` with a tolerance (a GPU may fuse a multiply-add or divide less exactly) and the\n * bounds exactly. {@link vdbDeltaTrack} and {@link vdbRatioTrack} (EX1f-b) are the twins of the tracking helpers.\n */\nimport { VDBToolsError } from \"../errors.js\";\nimport type { VDBVec3 } from \"../vdb/types.js\";\nimport { vdbSampleNearestCpu, vdbSampleTrilinearCpu } from \"./sample-trilinear.js\";\nimport {\n cellBoundTrilinear,\n defaultValueMax,\n forEachTreeRegion,\n getDim,\n hddaInit,\n hddaStep,\n hddaUpdate,\n indexBBox,\n leafVoxels,\n type Vec3,\n} from \"./march.js\";\n\nconst f = Math.fround;\n\n/**\n * Brick-majorant bounds for one grid: a dense grid of cells, x fastest, cell `c` covering the index\n * positions `[origin + B c, origin + B (c + 1))` with `B = 2^brickLog2`. Built by\n * {@link vdbBrickMajorant}; the core's `VDBGridPool.setMajorant` stores it next to the grid\n * (the core exports this same type).\n */\nexport interface VDBBrickMajorant {\n /** log2 of the brick edge in index voxels (3 for 8³ bricks). */\n brickLog2: number;\n /** Cells along x, y, z. */\n dims: VDBVec3;\n /** `dims[0] * dims[1] * dims[2]` upper bounds, x fastest. */\n data: Float32Array;\n /**\n * Index position of cell 0's min corner. Default (when a host builds the grid itself and leaves it out):\n * the grid's `indexBBoxMin - 1`, where the trilinear support starts.\n */\n origin?: VDBVec3;\n /** Lower bounds, as `data` (optional; the `minima` module option reads them). */\n minima?: Float32Array;\n}\n\n/** Options of {@link vdbBrickMajorant}. */\nexport interface VDBBrickMajorantOptions {\n /** log2 of the brick edge (0..10). Default 3 (8³ voxels, the pathtracer's brick). */\n brickLog2?: number;\n /** Also build lower bounds (`minima`). Default false. */\n minima?: boolean;\n /**\n * Where the cells sit.\n * - `'support'` (default): origin `indexBBoxMin - 1`, `ceil((max - min + 2) / B)` cells per axis: the\n * smallest grid that covers the trilinear support `[min - 1, max + 1)`.\n * - `'pathtracer'`: pmndrs/pathtracer's `brickMajorants` layout for a dense grid of `resolution` voxels\n * at index `[0, n)`: origin -1, `floor((n + B) / B)` cells, cell c over `[B c - 1, B c + B - 1)`. Bounds\n * are at least 0 and a cell whose taps reach `[0, n - 1]`'s faces has minimum 0 (its rule, kept\n * bit for bit, so the arrays equal its `brickMajorants` on the same dense array). Implies\n * `outside: 'zero'`; the grid's bbox must lie in `[0, resolution - 1]`.\n */\n align?: \"support\" | \"pathtracer\";\n /**\n * The field the bounds are for, as the module's `outside` option: `'background'` (default) reads the\n * tree everywhere; `'zero'` is 0 outside the index bbox (a tap outside it reads 0).\n */\n outside?: \"background\" | \"zero\";\n /** `align: 'pathtracer'`: the dense grid's voxel counts. Default `indexBBoxMax + 1`. */\n resolution?: VDBVec3;\n}\n\nfunction bad(message: string): never {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbBrickMajorant: ${message}`);\n}\n\n/** Where the cells of a brick majorant sit, and the field it bounds ({@link brickMajorantLayout}). */\nexport interface BrickMajorantLayout {\n brickLog2: number;\n align: \"support\" | \"pathtracer\";\n /** The bounds are for the field that is 0 outside the index bbox. */\n zero: boolean;\n /** The index bbox is empty (`max < min` on an axis). */\n empty: boolean;\n /** Index position of cell 0's min corner. */\n origin: Vec3;\n /** Cells per axis. */\n dims: Vec3;\n /** `align: 'pathtracer'`: the dense grid's voxel counts; `[0, 0, 0]` for `'support'`. */\n resolution: Vec3;\n}\n\n/**\n * Checks the options of {@link vdbBrickMajorant} and lays out its cells for a grid with index bbox `[min, max]`\n * (tools internal). The core's GPU builder (`VDBGridPool.buildMajorant`, P1.15) takes the same layout, so the two\n * builders agree on origin and dims by construction.\n *\n * @throws VDBToolsError `VDB_BAD_OPTION` for invalid options or a bbox outside `resolution`.\n */\nexport function brickMajorantLayout(min: Vec3, max: Vec3, options: VDBBrickMajorantOptions = {}): BrickMajorantLayout {\n if (typeof options !== \"object\" || options === null) bad(`options must be an object, got ${JSON.stringify(options)}.`);\n const log2 = options.brickLog2 ?? 3;\n if (!Number.isInteger(log2) || log2 < 0 || log2 > 10) bad(`brickLog2 must be an integer in 0..10, got ${String(log2)}.`);\n const align = options.align ?? \"support\";\n if (align !== \"support\" && align !== \"pathtracer\") bad(`align must be 'support' or 'pathtracer', got ${JSON.stringify(align)}.`);\n if (options.outside !== undefined && options.outside !== \"background\" && options.outside !== \"zero\") {\n bad(`outside must be 'background' or 'zero', got ${JSON.stringify(options.outside)}.`);\n }\n if (align === \"pathtracer\" && options.outside === \"background\") bad(\"align 'pathtracer' samples zero outside the grid; drop outside: 'background'.\");\n const zero = align === \"pathtracer\" || options.outside === \"zero\";\n const B = 1 << log2;\n const empty = max[0] < min[0] || max[1] < min[1] || max[2] < min[2];\n\n let origin: Vec3;\n let dims: Vec3;\n let n: Vec3 = [0, 0, 0];\n if (align === \"support\") {\n origin = empty ? [0, 0, 0] : [min[0] - 1, min[1] - 1, min[2] - 1];\n dims = empty ? [1, 1, 1] : ([0, 1, 2].map((a) => Math.ceil((max[a]! - min[a]! + 2) / B)) as Vec3);\n } else {\n const res = options.resolution ?? (empty ? [1, 1, 1] : [max[0] + 1, max[1] + 1, max[2] + 1]);\n if (!Array.isArray(res) || res.length !== 3 || res.some((v) => !Number.isInteger(v) || v < 1)) {\n bad(`resolution must be [nx, ny, nz] positive integers, got ${JSON.stringify(res)}.`);\n }\n n = [res[0], res[1], res[2]];\n if (!empty && (min.some((v) => v < 0) || max.some((v, a) => v >= n[a]!))) {\n bad(`align 'pathtracer' needs the grid's bbox [${min.join(\",\")}]..[${max.join(\",\")}] inside [0, resolution - 1] = [0,0,0]..[${n.map((v) => v - 1).join(\",\")}].`);\n }\n origin = [-1, -1, -1];\n dims = [0, 1, 2].map((a) => Math.floor((n[a]! + B) / B)) as Vec3;\n }\n return { brickLog2: log2, align, zero, empty, origin, dims, resolution: n };\n}\n\n/**\n * Builds brick-majorant bounds of a NanoVDB grid image (P1.2) for the core's `majorant` profile\n * (`pool.setMajorant(id, vdbBrickMajorant(image))`, module option `majorant: 'brick'`).\n *\n * A cell's bound is the max (and with `minima`, the min) of every value a trilinear sample inside it\n * can read: its `B + 1` taps per axis, leaf voxels active or not, tiles and the background, or 0 for a\n * tap outside the index bbox with `outside: 'zero'`. So every trilinear (or nearest) sample in the cell\n * lies in `[minima, data]`. Works on every scalar grid type (Fp values as the GPU decodes them).\n *\n * @param image The grid image (little-endian u32 words, `GridData` at word 0).\n * @param options Brick size, minima, alignment and the `outside` field.\n * @throws VDBToolsError `VDB_BAD_OPTION` for invalid options or a bbox outside `resolution`.\n */\nexport function vdbBrickMajorant(image: Uint32Array, options: VDBBrickMajorantOptions = {}): VDBBrickMajorant {\n const { min, max } = indexBBox(image);\n const { brickLog2: log2, align, zero, empty, origin, dims, resolution: n } = brickMajorantLayout(min, max, options);\n const B = 1 << log2;\n\n const cells = dims[0] * dims[1] * dims[2];\n const hi = new Float64Array(cells).fill(-Infinity);\n const lo = options.minima ? new Float64Array(cells).fill(Infinity) : null;\n // Tap extent of the whole grid of cells: [origin, origin + B * dims].\n const extLo: Vec3 = [origin[0], origin[1], origin[2]];\n const extHi: Vec3 = [origin[0] + B * dims[0], origin[1] + B * dims[1], origin[2] + B * dims[2]];\n // Where values come from the tree: the bbox (zero) or the extent (background).\n const domLo: Vec3 = zero ? [Math.max(min[0], extLo[0]), Math.max(min[1], extLo[1]), Math.max(min[2], extLo[2])] : extLo;\n const domHi: Vec3 = zero ? [Math.min(max[0], extHi[0]), Math.min(max[1], extHi[1]), Math.min(max[2], extHi[2])] : extHi;\n const cellLo = (a: number, axis: number) => Math.max(0, Math.ceil((a - origin[axis]! - B) / B));\n const cellHi = (b: number, axis: number) => Math.min(dims[axis]! - 1, Math.floor((b - origin[axis]!) / B));\n\n /** Max/min `v` into every cell whose taps meet the voxel box [a, b] (inclusive), after clipping to the domain. */\n const add = (a0: number, a1: number, a2: number, b0: number, b1: number, b2: number, v: number) => {\n if (empty && zero) return;\n const x0 = Math.max(a0, domLo[0]), y0 = Math.max(a1, domLo[1]), z0 = Math.max(a2, domLo[2]);\n const x1 = Math.min(b0, domHi[0]), y1 = Math.min(b1, domHi[1]), z1 = Math.min(b2, domHi[2]);\n if (x0 > x1 || y0 > y1 || z0 > z1) return;\n const cx0 = cellLo(x0, 0), cx1 = cellHi(x1, 0);\n const cy0 = cellLo(y0, 1), cy1 = cellHi(y1, 1);\n const cz0 = cellLo(z0, 2), cz1 = cellHi(z1, 2);\n for (let cz = cz0; cz <= cz1; cz++) {\n for (let cy = cy0; cy <= cy1; cy++) {\n let i = cx0 + dims[0] * (cy + dims[1] * cz);\n for (let cx = cx0; cx <= cx1; cx++, i++) {\n if (v > hi[i]!) hi[i] = v;\n if (lo && v < lo[i]!) lo[i] = v;\n }\n }\n }\n };\n\n const { background, rootTiles } = forEachTreeRegion(image, (r) => {\n const [ox, oy, oz] = r.origin;\n if (ox > domHi[0] || oy > domHi[1] || oz > domHi[2] || ox + r.dim - 1 < domLo[0] || oy + r.dim - 1 < domLo[1] || oz + r.dim - 1 < domLo[2]) return;\n if (r.level > 0) {\n add(ox, oy, oz, ox + r.dim - 1, oy + r.dim - 1, oz + r.dim - 1, r.value);\n return;\n }\n const { values } = leafVoxels(image, r.leaf);\n for (let n0 = 0; n0 < 512; n0++) {\n const x = ox + (n0 >> 6), y = oy + ((n0 >> 3) & 7), z = oz + (n0 & 7);\n add(x, y, z, x, y, z, values[n0]!);\n }\n });\n\n // The background (space under no root tile) and the zeros a tap outside the bbox reads.\n const roots = new Set(rootTiles.map((o) => `${o[0]},${o[1]},${o[2]}`));\n const covered = (a: Vec3, b: Vec3): boolean => {\n for (let x = Math.floor(a[0] / 4096); x <= Math.floor(b[0] / 4096); x++)\n for (let y = Math.floor(a[1] / 4096); y <= Math.floor(b[1] / 4096); y++)\n for (let z = Math.floor(a[2] / 4096); z <= Math.floor(b[2] / 4096); z++) if (!roots.has(`${x * 4096},${y * 4096},${z * 4096}`)) return false;\n return true;\n };\n for (let cz = 0; cz < dims[2]; cz++) {\n for (let cy = 0; cy < dims[1]; cy++) {\n for (let cx = 0; cx < dims[0]; cx++) {\n const i = cx + dims[0] * (cy + dims[1] * cz);\n const c = [cx, cy, cz];\n const tLo = [0, 1, 2].map((a) => origin[a]! + B * c[a]!) as Vec3;\n const tHi = [0, 1, 2].map((a) => tLo[a]! + B) as Vec3;\n const inLo = [0, 1, 2].map((a) => Math.max(tLo[a]!, domLo[a]!)) as Vec3;\n const inHi = [0, 1, 2].map((a) => Math.min(tHi[a]!, domHi[a]!)) as Vec3;\n const meets = !(empty && zero) && inLo.every((v, a) => v <= inHi[a]!);\n if (meets && !covered(inLo, inHi)) {\n hi[i] = Math.max(hi[i]!, background);\n if (lo) lo[i] = Math.min(lo[i]!, background);\n }\n if (zero) {\n const leaves = empty || tLo.some((v, a) => v < min[a]!) || tHi.some((v, a) => v > max[a]!);\n if (align === \"pathtracer\") {\n // Its rule: the bound starts at 0, and the minimum is 0 when the taps start below 0 or end at n - 1 or later.\n hi[i] = Math.max(hi[i]!, 0);\n if (lo && (leaves || tLo.some((v) => v < 0) || tHi.some((v, a) => v + 1 > n[a]! - 1))) lo[i] = Math.min(lo[i]!, 0);\n } else if (leaves) {\n hi[i] = Math.max(hi[i]!, 0);\n if (lo) lo[i] = Math.min(lo[i]!, 0);\n }\n }\n }\n }\n }\n\n // A bound of -0 is stored as +0 (V214): a cell whose extreme is a signed zero has no defined sign on the GPU\n // (WGSL min / max of +0 and -0 may return either), so both builders write +0.\n const data = Float32Array.from(hi, (v) => (v === 0 ? 0 : v));\n const out: VDBBrickMajorant = { brickLog2: log2, dims, data, origin };\n if (lo) {\n const m = new Float32Array(cells);\n for (let i = 0; i < cells; i++) {\n const v = Math.min(lo[i]!, data[i]!);\n m[i] = v === 0 ? 0 : v;\n }\n out.minima = m;\n }\n return out;\n}\n\n/** Options of {@link vdbValueRange}. */\nexport interface VDBValueRangeOptions {\n /**\n * The field the range is for, as the module's `outside` option: `'background'` (default) reads the tree\n * everywhere; `'zero'` is 0 outside the index bbox.\n */\n outside?: \"background\" | \"zero\";\n}\n\n/** The range of a grid's sampled field ({@link vdbValueRange}). */\nexport interface VDBValueRange {\n /** The smallest value a sample can take. */\n min: number;\n /** The largest value a sample can take: the grid's global majorant. */\n max: number;\n}\n\n/**\n * The exact range of the field a shader samples from a grid image inside its support box (EX1f-a): every\n * trilinear or nearest sample at a point of `[min - 1, max + 1]` (the index bbox grown by one voxel, the box\n * the majorant walks cover) lies in `[min, max]`. It reads every value a tap there can read: leaf voxels\n * active or not, tiles, and the background where no root tile covers the box; with `outside: 'zero'` only\n * the values inside the index bbox, and 0. Beyond the support box the field is 0 (`'zero'`) or whatever the\n * tree holds there (`'background'`), which no walk visits.\n *\n * `max` is the tightest global majorant: `pool.setValueMax(id, vdbValueRange(image, { outside }).max)`.\n * The pool's own default, `max(root max, background)`, costs nothing and holds when the inactive values are\n * the background, but it counts a root background that no voxel near the grid may hold (3 against 1 on a fog\n * volume converted from a level set). The root max alone is not a bound: node statistics cover active\n * values only.\n *\n * It walks the whole tree (as {@link vdbBrickMajorant} does), so call it once per image, not per frame.\n *\n * @param image The grid image (little-endian u32 words, `GridData` at word 0).\n * @param options The `outside` field.\n * @throws VDBToolsError `VDB_BAD_OPTION` for an invalid `outside`.\n */\nexport function vdbValueRange(image: Uint32Array, options: VDBValueRangeOptions = {}): VDBValueRange {\n if (typeof options !== \"object\" || options === null) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbValueRange: options must be an object, got ${JSON.stringify(options)}.`);\n }\n if (options.outside !== undefined && options.outside !== \"background\" && options.outside !== \"zero\") {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbValueRange: outside must be 'background' or 'zero', got ${JSON.stringify(options.outside)}.`);\n }\n const zero = options.outside === \"zero\";\n const { min, max } = indexBBox(image);\n const empty = max[0] < min[0] || max[1] < min[1] || max[2] < min[2];\n let lo = Infinity;\n let hi = -Infinity;\n const take = (v: number): void => {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n };\n // The voxels whose tree values a tap in the support box reads: the bbox, grown by one voxel unless the\n // field is 0 out there.\n const pad = zero ? 0 : 1;\n const a: Vec3 = [min[0] - pad, min[1] - pad, min[2] - pad];\n const b: Vec3 = [max[0] + pad, max[1] + pad, max[2] + pad];\n const { background, rootTiles } = forEachTreeRegion(image, (r) => {\n const [ox, oy, oz] = r.origin;\n const e = r.dim - 1;\n if (empty || ox > b[0] || oy > b[1] || oz > b[2] || ox + e < a[0] || oy + e < a[1] || oz + e < a[2]) return;\n if (r.level > 0) {\n take(r.value);\n return;\n }\n const { values } = leafVoxels(image, r.leaf);\n const inside = ox >= a[0] && oy >= a[1] && oz >= a[2] && ox + e <= b[0] && oy + e <= b[1] && oz + e <= b[2];\n for (let n = 0; n < 512; n++) {\n if (!inside) {\n const x = ox + (n >> 6), y = oy + ((n >> 3) & 7), z = oz + (n & 7);\n if (x < a[0] || y < a[1] || z < a[2] || x > b[0] || y > b[1] || z > b[2]) continue;\n }\n take(values[n]!);\n }\n });\n if (zero) take(0); // the support box always reaches a voxel outside the bbox\n if (empty) {\n if (!zero) take(background);\n } else {\n // A part of the box under no root tile reads the background.\n const roots = new Set(rootTiles.map((o) => `${o[0]},${o[1]},${o[2]}`));\n let covered = true;\n for (let x = Math.floor(a[0] / 4096); covered && x <= Math.floor(b[0] / 4096); x++)\n for (let y = Math.floor(a[1] / 4096); covered && y <= Math.floor(b[1] / 4096); y++)\n for (let z = Math.floor(a[2] / 4096); covered && z <= Math.floor(b[2] / 4096); z++) covered = roots.has(`${x * 4096},${y * 4096},${z * 4096}`);\n if (!covered) take(background);\n }\n // -0 as +0, as the brick bounds (V214).\n return { min: lo === 0 ? 0 : lo, max: hi === 0 ? 0 : hi };\n}\n\n// ---------------------------------------------------------------------------\n// The walk (twin of the `majorant` WGSL profile)\n\n/** One segment of the majorant walk ({@link vdbMajorantWalk}): every sample on `[t0, t1)` lies in `[min, max]`. */\nexport interface VDBMajorantSegment {\n t0: number;\n t1: number;\n /** Upper bound of the sampled field on the segment. */\n max: number;\n /** Lower bound: the brick minimum with minima, else 0 (a valid minorant of a non-negative field). */\n min: number;\n /** Accessor queries the segment cost (`vdbGetDim` / `vdbNodeMax`; 1 brick load, 2 with minima). */\n lookups: number;\n}\n\n/** The internal name of {@link VDBMajorantSegment} (tests and harnesses). */\nexport type MajorantSegment = VDBMajorantSegment;\n\n/** Options of {@link vdbMajorantWalk}. */\nexport interface VDBMajorantWalkOptions {\n /** The module's `majorant` option. `'brick'` with no brick majorant walks as `'global'`. Default `'brick'`. */\n mode?: \"brick\" | \"global\" | \"nodeMax\";\n /** Ray interval before clipping. Default `[0, 3.4e38]`. */\n tMin?: number;\n tMax?: number;\n /** The record's `valueMax` (default {@link defaultValueMax}: the pool's default). */\n valueMax?: number;\n /** The module's sampler (the support box of `global` and `nodeMax`). Default `'trilinear'`. */\n sampler?: \"trilinear\" | \"nearest\";\n /** The module's `outside`; `'zero'` raises a bound below 0 to 0 (`global`, `nodeMax`). Default `'background'`. */\n outside?: \"background\" | \"zero\";\n /** The module's `minima` option (read the brick minima when it has them). Default false. */\n minima?: boolean;\n /** Safety cap on segments. Default 1 << 16. */\n maxSegments?: number;\n /**\n * Twin of `vdbMajorantInitWorld` (helper `'majorantWorld'`): the grid's world-to-index affine, 3x4 row-major\n * (`pool.info(id).worldToIndex`). `origin` and `direction` are then a world-space ray; it is taken to index\n * space as the shader does (f32 rows; the direction is not renormalized, so `t` stays a world parameter).\n */\n worldToIndex?: ArrayLike<number>;\n}\n\n/** The internal name of {@link VDBMajorantWalkOptions} (tests and harnesses). */\nexport type MajorantWalkOptions = VDBMajorantWalkOptions;\n\n/** The ray of a walk in index space, f32: `origin` / `direction` themselves, or through `worldToIndex` as the WGSL does. */\nfunction indexRay(origin: Vec3, direction: Vec3, worldToIndex: ArrayLike<number> | undefined): { o: Vec3; d: Vec3 } {\n const p = f3(origin);\n const v = f3(direction);\n if (worldToIndex === undefined) return { o: p, d: v };\n if (worldToIndex.length !== 12) throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbMajorantWalk: worldToIndex must have 12 numbers (3x4 row-major), got ${worldToIndex.length}.`);\n const m = Array.from(worldToIndex, f);\n // dot(row, vec4(p, w)), summed left to right as WGSL's dot is specified.\n const row = (r: number, a: Vec3, w: number): number => f(f(f(f(m[4 * r]! * a[0]) + f(m[4 * r + 1]! * a[1])) + f(m[4 * r + 2]! * a[2])) + f(m[4 * r + 3]! * w));\n return { o: [row(0, p, 1), row(1, p, 1), row(2, p, 1)], d: [row(0, v, 0), row(1, v, 0), row(2, v, 0)] };\n}\n\n/** f32 1e-20: below it a direction component counts as 0 (the pathtracer's DDA guard). */\nconst PARALLEL = f(1e-20);\nconst FAR = f(1e30);\n\n/**\n * Twin of the WGSL `vdb_maj_clip`: the slab test of `[lo, hi]` with a guard for axis-parallel rays (a\n * component below 1e-20 in magnitude: the ray misses unless `lo <= o < hi` on that axis; WGSL may\n * assume no infinities, CLAUDE.md Traps). Returns `[a, b]`; empty when `!(a < b)`.\n */\nfunction clip(lo: Vec3, hi: Vec3, o: Vec3, d: Vec3, t0: number, t1: number): [number, number] {\n let a = t0;\n let b = t1;\n for (let k = 0; k < 3; k++) {\n if (Math.abs(d[k]!) < PARALLEL) {\n if (o[k]! < lo[k]! || o[k]! >= hi[k]!) return [t0, t0];\n } else {\n const p = f(f(lo[k]! - o[k]!) / d[k]!);\n const q = f(f(hi[k]! - o[k]!) / d[k]!);\n a = Math.max(a, Math.min(p, q));\n b = Math.min(b, Math.max(p, q));\n }\n }\n return [a, b];\n}\n\nconst f3 = (v: readonly number[]): Vec3 => [f(v[0]!), f(v[1]!), f(v[2]!)];\n\n/**\n * Twin of `vdbMajorantInit(g, o, d, tMin, tMax)` + `vdbMajorantNext` until it ends: the segments the\n * GPU walk returns for an index-space ray (`d` unnormalized; `t` in the caller's units), in order,\n * contiguous (each `t0` is the previous `t1`), none of zero length.\n *\n * - `'brick'` with bounds: the DDA over the brick cells (the pathtracer's `ptDdaInit` / `ptDdaNext`\n * in the module's cell space `(p - origin) / B`), clipped to the cell grid's box.\n * - `'global'` (or `'brick'` without bounds): one segment over the sampler's support box\n * (`[min - 1, max + 1]` trilinear, `[min - 0.5, max + 0.5]` nearest) with bound `valueMax`.\n * - `'nodeMax'` (P1.4): the vendored HDDA at leaf size 8, widening over tiles and empty space, over the\n * support box; a cell's bound is {@link cellBoundTrilinear} (the 2x2x2 block of `dim`-cells from the\n * cell's corner: the \"8-leaf support\" of a leaf cell). Stats bound ACTIVE values, so this assumes every\n * inactive leaf voxel is <= its leaf's max (fog). Without stats the bound is `valueMax`.\n *\n * `mode: 'global'` with a brick majorant is the twin of `vdbMajorantInitGlobal`; `worldToIndex` makes it the twin\n * of `vdbMajorantInitWorld`.\n *\n * @param gridWords The grid image (little-endian u32 words, `GridData` at word 0).\n * @param majorant The grid's brick bounds (`vdbBrickMajorant`), or `null`.\n * @param origin The ray's origin, in index space (or world space with `worldToIndex`).\n * @param direction The ray's direction, same space; not normalized by the walk.\n * @param options The module's options and the ray interval.\n * @throws VDBToolsError `VDB_BAD_OPTION` for a `worldToIndex` that is not 12 numbers.\n */\nexport function vdbMajorantWalk(\n gridWords: Uint32Array,\n majorant: VDBBrickMajorant | null,\n origin: VDBVec3,\n direction: VDBVec3,\n options: VDBMajorantWalkOptions = {},\n): VDBMajorantSegment[] {\n const mode = options.mode ?? \"brick\";\n const zero = options.outside === \"zero\";\n const { o, d } = indexRay(origin, direction, options.worldToIndex);\n const tMin = f(options.tMin ?? 0);\n const tMax = f(options.tMax ?? 3.4e38);\n const maxSegments = options.maxSegments ?? 1 << 16;\n const vmaxRecord = f(options.valueMax ?? defaultValueMax(gridWords));\n const vmax = zero ? Math.max(vmaxRecord, 0) : vmaxRecord;\n const out: MajorantSegment[] = [];\n\n if (mode === \"brick\" && majorant) {\n const B = 1 << majorant.brickLog2;\n const s = f(1 / B);\n const { min } = indexBBox(gridWords);\n const org = f3(majorant.origin ?? [min[0] - 1, min[1] - 1, min[2] - 1]);\n const n = majorant.dims;\n const u: Vec3 = [f(f(o[0] - org[0]) * s), f(f(o[1] - org[1]) * s), f(f(o[2] - org[2]) * s)];\n const du: Vec3 = [f(d[0] * s), f(d[1] * s), f(d[2] * s)];\n const [tEnter, tExit] = clip([0, 0, 0], f3(n), u, du, tMin, tMax);\n if (!(tEnter < tExit)) return out;\n const cell = [0, 1, 2].map((k) => Math.min(n[k]! - 1, Math.max(0, Math.floor(f(u[k]! + f(du[k]! * tEnter)))))) as Vec3;\n const step = du.map((v) => (v > 0 ? 1 : -1));\n const tn = [0, 1, 2].map((k) => (Math.abs(du[k]!) < PARALLEL ? FAR : f(f(f(cell[k]! + (du[k]! > 0 ? 1 : 0)) - u[k]!) / du[k]!)));\n const dt = du.map((v) => (Math.abs(v) < PARALLEL ? FAR : Math.abs(f(1 / v))));\n const minima = options.minima === true && majorant.minima !== undefined;\n let t = tEnter;\n let te = tExit;\n while (t < te && out.length < maxSegments) {\n let k = 0;\n if (tn[1]! < tn[k]!) k = 1;\n if (tn[2]! < tn[k]!) k = 2;\n const t1 = Math.min(tn[k]!, te);\n const i = cell[0] + n[0] * (cell[1] + n[1] * cell[2]);\n cell[k] = cell[k]! + step[k]!;\n tn[k] = f(tn[k]! + dt[k]!);\n if (cell[k]! < 0 || cell[k]! >= n[k]!) te = t1;\n if (t1 > t) {\n out.push({ t0: t, t1, max: majorant.data[i]!, min: minima ? majorant.minima![i]! : 0, lookups: minima ? 2 : 1 });\n t = t1;\n }\n }\n return out;\n }\n\n const { min, max } = indexBBox(gridWords);\n const pad = options.sampler === \"nearest\" ? 0.5 : 1;\n const [t0, t1] = clip(f3([min[0] - pad, min[1] - pad, min[2] - pad]), f3([max[0] + pad, max[1] + pad, max[2] + pad]), o, d, tMin, tMax);\n if (!(t0 < t1)) return out;\n if (mode !== \"nodeMax\") {\n out.push({ t0, t1, max: vmax, min: 0, lookups: 0 });\n return out;\n }\n\n const bound = (ijk: Vec3, dim: number): number => {\n const b = cellBoundTrilinear(gridWords, ijk, dim, { valueMax: vmaxRecord });\n return zero ? Math.max(b, 0) : b;\n };\n const start: Vec3 = [f(o[0] + f(d[0] * t0)), f(o[1] + f(d[1] * t0)), f(o[2] + f(d[2] * t0))];\n const h = hddaInit(o, t0, d, t1, Math.max(getDim(gridWords, [Math.floor(start[0]), Math.floor(start[1]), Math.floor(start[2])]), 8));\n let t = t0;\n let te = t1;\n let lookups = 1;\n while (t < te && out.length < maxSegments) {\n let updates = 0;\n for (;;) {\n const want = Math.max(getDim(gridWords, h.voxel), 8);\n lookups++;\n if (want === h.dim || updates >= 2) break;\n hddaUpdate(h, o, d, want);\n updates++;\n }\n const end = Math.min(Math.min(Math.min(h.next[0], h.next[1]), Math.min(h.next[2], h.tmax)), te);\n const voxel: Vec3 = [h.voxel[0], h.voxel[1], h.voxel[2]];\n const dim = h.dim;\n const more = hddaStep(h);\n const e = more ? end : te;\n if (!more) te = Math.max(t, e);\n if (e > t) {\n out.push({ t0: t, t1: e, max: bound(voxel, dim), min: 0, lookups: lookups + 8 });\n lookups = 0;\n t = e;\n }\n }\n return out;\n}\n\n/** The internal name of {@link vdbMajorantWalk} (tests, harnesses and scripts written before EX1f-b published it). */\nexport const majorantWalk = vdbMajorantWalk;\n\n// ---------------------------------------------------------------------------\n// The trackers (twins of the `deltaTrack` / `ratioTrack` WGSL helpers, EX1f-b)\n\n/** What {@link vdbDeltaTrack} returns (the WGSL `VdbCollision`). */\nexport interface VDBCollision {\n /** The collision's ray parameter; without a hit, where the walk ended (or the tentative collision a truncated track stopped at). */\n t: number;\n /** The grid's sampled value at the collision (0 without a hit). */\n density: number;\n /** A real collision was found. */\n hit: boolean;\n /** `maxLookups` was reached first. */\n truncated: boolean;\n /** Majorant segments walked. */\n steps: number;\n /** Samples of the grid: tentative collisions. */\n lookups: number;\n}\n\n/** What {@link vdbRatioTrack} returns (the WGSL `VdbTransmittance`). */\nexport interface VDBTransmittance {\n /** The transmittance estimate per channel. */\n value: VDBVec3;\n /** `maxLookups` was reached first. */\n truncated: boolean;\n /** Majorant segments walked. */\n steps: number;\n /** Samples of the grid: tentative collisions. */\n lookups: number;\n}\n\n/** Options of {@link vdbDeltaTrack}: the walk's ({@link VDBMajorantWalkOptions}) and the tracker's. */\nexport interface VDBDeltaTrackOptions extends VDBMajorantWalkOptions {\n /** Extinction per unit of `t` at grid value 1. */\n sigma: number;\n /** The random stream: uniform numbers in [0, 1), drawn in the WGSL helper's order. */\n random: () => number;\n /** Stop after this many samples of the grid (`truncated`). Default 2^32 - 1. */\n maxLookups?: number;\n}\n\n/** Options of {@link vdbRatioTrack}: the walk's ({@link VDBMajorantWalkOptions}) and the tracker's. */\nexport interface VDBRatioTrackOptions extends VDBMajorantWalkOptions {\n /** Extinction per unit of `t` at grid value 1: one number, or one per channel (the majorant is the largest channel's). */\n sigma: number | VDBVec3;\n /** The random stream: uniform numbers in [0, 1), drawn in the WGSL helper's order. */\n random: () => number;\n /** Below this transmittance (the largest channel) the estimate plays Russian roulette; 0 (default) never does. */\n cutoff?: number;\n /** Stop after this many samples of the grid (`truncated`). Default 2^32 - 1. */\n maxLookups?: number;\n}\n\n/** What both trackers share: the index-space ray, the walk's segments and the sampler. */\nfunction trackSetup(gridWords: Uint32Array, majorant: VDBBrickMajorant | null, origin: VDBVec3, direction: VDBVec3, options: VDBMajorantWalkOptions) {\n const { o, d } = indexRay(origin, direction, options.worldToIndex);\n const walk: VDBMajorantWalkOptions = { ...options };\n delete walk.worldToIndex;\n const segments = vdbMajorantWalk(gridWords, majorant, o, d, walk);\n const outside = options.outside ?? \"background\";\n const read = options.sampler === \"nearest\" ? vdbSampleNearestCpu : vdbSampleTrilinearCpu;\n const sample = (t: number): number => f(read(gridWords, [f(o[0] + f(d[0] * t)), f(o[1] + f(d[1] * t)), f(o[2] + f(d[2] * t))], { outside }));\n return { segments, sample, tStart: segments.length > 0 ? segments[0]!.t0 : f(options.tMin ?? 0) };\n}\n\n/** The tentative-collision step both trackers take: `t - log(1 - u) / m` in f32. */\nconst stepT = (t: number, u: number, m: number): number => f(t - f(f(Math.log(f(1 - f(u)))) / m));\n\n/**\n * Twin of `vdbMajorantInit` (or its `World` / `Global` helper) followed by the WGSL helper\n * `vdbDeltaTrack(&it, &acc, sigma, maxLookups)` (EX1f-b): delta (Woodcock) tracking along the ray. It returns the\n * next real collision of the medium whose extinction is `sigma` times the grid's sampled value, or `hit: false`\n * when the ray leaves the walk without one. P(no collision) is the transmittance exp(-sigma ∫ value dt).\n *\n * The random numbers are drawn from `options.random` in the helper's order: per tentative collision one for\n * the distance, then one for the accept test.\n *\n * @param gridWords The grid image (little-endian u32 words, `GridData` at word 0).\n * @param majorant The grid's brick bounds, or `null` (see {@link vdbMajorantWalk}).\n * @param origin The ray's origin, in index space (or world space with `worldToIndex`).\n * @param direction The ray's direction, same space; `t` and `sigma` are in its units.\n * @param options The walk's options, `sigma`, `random` and `maxLookups`.\n */\nexport function vdbDeltaTrack(\n gridWords: Uint32Array,\n majorant: VDBBrickMajorant | null,\n origin: VDBVec3,\n direction: VDBVec3,\n options: VDBDeltaTrackOptions,\n): VDBCollision {\n const { segments, sample, tStart } = trackSetup(gridWords, majorant, origin, direction, options);\n const sigma = f(options.sigma);\n const cap = options.maxLookups ?? 0xffffffff;\n const r: VDBCollision = { t: tStart, density: 0, hit: false, truncated: false, steps: 0, lookups: 0 };\n for (const s of segments) {\n r.steps++;\n r.t = s.t1;\n const m = f(s.max * sigma);\n if (!(m > 0)) continue;\n let t = s.t0;\n for (;;) {\n t = stepT(t, options.random(), m);\n if (t >= s.t1) break;\n if (r.lookups >= cap) {\n r.t = t;\n r.truncated = true;\n return r;\n }\n r.lookups++;\n const v = sample(t);\n if (f(f(options.random()) * m) < f(v * sigma)) {\n r.t = t;\n r.density = v;\n r.hit = true;\n return r;\n }\n }\n }\n return r;\n}\n\n/**\n * Twin of `vdbMajorantInit` (or its `World` / `Global` helper) followed by the WGSL helper\n * `vdbRatioTrack(&it, &acc, sigma, cutoff, maxLookups)` (EX1f-b): ratio tracking along the ray, an unbiased\n * estimate of the transmittance exp(-sigma ∫ value dt) per channel. All channels share the tentative collisions\n * of the largest channel's majorant, so a spectral medium costs one walk.\n *\n * The random numbers are drawn from `options.random` in the helper's order: one per tentative collision, and one\n * more whenever the roulette plays (the largest channel under `cutoff`).\n *\n * @param gridWords The grid image (little-endian u32 words, `GridData` at word 0).\n * @param majorant The grid's brick bounds, or `null` (see {@link vdbMajorantWalk}).\n * @param origin The ray's origin, in index space (or world space with `worldToIndex`).\n * @param direction The ray's direction, same space; `t` and `sigma` are in its units.\n * @param options The walk's options, `sigma`, `random`, `cutoff` and `maxLookups`.\n */\nexport function vdbRatioTrack(\n gridWords: Uint32Array,\n majorant: VDBBrickMajorant | null,\n origin: VDBVec3,\n direction: VDBVec3,\n options: VDBRatioTrackOptions,\n): VDBTransmittance {\n const { segments, sample } = trackSetup(gridWords, majorant, origin, direction, options);\n const sg: Vec3 = typeof options.sigma === \"number\" ? [f(options.sigma), f(options.sigma), f(options.sigma)] : f3(options.sigma);\n const top = Math.max(sg[0], Math.max(sg[1], sg[2]));\n const cutoff = f(options.cutoff ?? 0);\n const cap = options.maxLookups ?? 0xffffffff;\n const r: VDBTransmittance = { value: [1, 1, 1], truncated: false, steps: 0, lookups: 0 };\n for (const s of segments) {\n r.steps++;\n const m = f(s.max * top);\n if (!(m > 0)) continue;\n let t = s.t0;\n for (;;) {\n t = stepT(t, options.random(), m);\n if (t >= s.t1) break;\n if (r.lookups >= cap) {\n r.truncated = true;\n return r;\n }\n r.lookups++;\n const q = f(sample(t) / m);\n for (let k = 0; k < 3; k++) r.value[k] = f(r.value[k]! * f(1 - f(sg[k]! * q)));\n const w = Math.max(r.value[0], Math.max(r.value[1], r.value[2]));\n if (w < cutoff || w <= 0) {\n if (f(f(options.random()) * cutoff) >= w) {\n r.value = [0, 0, 0];\n return r;\n }\n const g = f(cutoff / w);\n for (let k = 0; k < 3; k++) r.value[k] = r.value[k]! >= w ? cutoff : f(r.value[k]! * g);\n }\n }\n }\n return r;\n}\n"]}
@@ -42,13 +42,16 @@ export declare function nodeMax(gridWords: Uint32Array, ijk: Vec3, dim: number,
42
42
  /** Twin of `vdbIsActive`. */
43
43
  export declare function isActive(gridWords: Uint32Array, ijk: Vec3): boolean;
44
44
  /**
45
- * Twin of `vdbReadValue` (f32 decode in WGSL order; any of Float/Fp4/Fp8/Fp16/FpN).
45
+ * Twin of `vdbReadValue` (f32 decode in WGSL order; any of Float/Half/Fp4/Fp8/Fp16/FpN).
46
46
  *
47
47
  * This matches the GPU's evaluation order (f32 arithmetic), so it is the right
48
48
  * oracle for GPU parity checks. `readValue` instead returns the exact f64
49
49
  * decode; on Fp grids the two can differ by 1 ulp (f32).
50
+ *
51
+ * @param gridWords The grid image (little-endian u32 words, `GridData` at word 0).
52
+ * @param ijk Integer index coordinates of the voxel.
50
53
  */
51
- export declare function vdbReadValueF32(gridWords: Uint32Array, ijk: Vec3): number;
54
+ export declare function vdbReadValueF32Cpu(gridWords: Uint32Array, ijk: Vec3): number;
52
55
  export interface TreeNode {
53
56
  level: NodeLevel;
54
57
  /** Byte address of the node in the image. */
@@ -69,6 +72,94 @@ export interface TreeNode {
69
72
  * use {@link leafVoxels} for their values.
70
73
  */
71
74
  export declare function treeNodes(gridWords: Uint32Array): TreeNode[];
75
+ /** One region of the tree for {@link forEachTreeRegion}: a leaf, or a tile (active or not). */
76
+ export interface TreeRegion {
77
+ /** 0 leaf, 1 lower-node tile (8³), 2 upper-node tile (128³), 3 root tile (4096³). */
78
+ level: NodeLevel;
79
+ /** Index-space min corner. */
80
+ origin: Vec3;
81
+ /** Edge in voxels: 8, 8, 128 or 4096. */
82
+ dim: number;
83
+ /** Byte address of the leaf (level 0; read it with {@link leafVoxels}); 0 for a tile. */
84
+ leaf: number;
85
+ /** The tile's value (levels 1-3, active or inactive); 0 for a leaf. */
86
+ value: number;
87
+ }
88
+ /**
89
+ * Every leaf and every tile of the tree, active or not (P1.2, the brick-majorant builder needs the
90
+ * values a trilinear tap can read, inactive ones included). Space under no root tile reads the
91
+ * background: the result lists the min corners of the root tiles (with or without a child), so a
92
+ * caller can tell which 4096-blocks are covered.
93
+ */
94
+ export declare function forEachTreeRegion(gridWords: Uint32Array, visit: (r: TreeRegion) => void): {
95
+ background: number;
96
+ rootTiles: Vec3[];
97
+ };
98
+ /** Options of {@link vdbTreeNodes}. */
99
+ export interface VDBTreeNodesOptions {
100
+ /** Yield the leaves. Default `true`. */
101
+ leaves?: boolean;
102
+ /**
103
+ * Which tiles to yield: `'active'` (default), `'all'` or `'none'`. `'all'` is every table slot without a child,
104
+ * so beside the inactive tiles that mean something (a level set's interior) it yields the empty slots: inactive
105
+ * tiles that hold the background, 32,768 less the children per upper node and 4,096 less the leaves per lower
106
+ * node. Filter on `value` when you want only the former.
107
+ */
108
+ tiles?: "active" | "all" | "none";
109
+ /** Also yield the upper and lower nodes themselves, each before what it holds. Default `false`. */
110
+ internalNodes?: boolean;
111
+ }
112
+ /**
113
+ * One entry of {@link vdbTreeNodes}: a node of the tree, or a tile (a constant block stored in a node's table in
114
+ * place of a child). `origin` is the index-space min corner and `size` the edge in voxels, so the entry covers the
115
+ * voxels `origin` to `origin + size - 1` on each axis.
116
+ *
117
+ * - `'leaf'`: level 0, size 8. `activeVoxelCount` counts its value-mask bits (0 to 512).
118
+ * - `'lower'`: a lower node, level 1, size 128. `'upper'`: an upper node, level 2, size 4096.
119
+ * - `'tile'`: `level` is the level of the node that holds it: 1 (in a lower node, size 8), 2 (in an upper node,
120
+ * size 128) or 3 (in the root, size 4096). `value` is the stored value as a number (a Half grid's binary16
121
+ * widened; Float and Fp grids store tiles as f32) and `active` its state.
122
+ */
123
+ export type VDBTreeNode = {
124
+ kind: "leaf";
125
+ level: 0;
126
+ origin: Vec3;
127
+ size: 8;
128
+ activeVoxelCount: number;
129
+ } | {
130
+ kind: "lower";
131
+ level: 1;
132
+ origin: Vec3;
133
+ size: 128;
134
+ } | {
135
+ kind: "upper";
136
+ level: 2;
137
+ origin: Vec3;
138
+ size: 4096;
139
+ } | {
140
+ kind: "tile";
141
+ level: 1 | 2 | 3;
142
+ origin: Vec3;
143
+ size: 8 | 128 | 4096;
144
+ value: number;
145
+ active: boolean;
146
+ };
147
+ /**
148
+ * Walks the tree of a scalar grid image (Float, Half, Fp4, Fp8, Fp16, FpN): its leaves and tiles, and on request
149
+ * its upper and lower nodes. For drawing node boxes, counting what a grid stores, or telling where a voxel's value
150
+ * comes from (a leaf holds one value per voxel; a tile is one value for its whole block).
151
+ *
152
+ * The order is the image's own: root entries in table order (signed origin order: x, then y, then z), then each
153
+ * node's table by slot, depth first. Every entry is a new object. Space that no entry covers reads the grid's
154
+ * background. Voxel values are not decoded here: read them with `vdbReadValueCpu`.
155
+ *
156
+ * The image and the options are checked when the first entry is asked for, not when the function is called.
157
+ *
158
+ * @param image A NanoVDB grid image (`NvdbFile.gridImage`, `buildFromVdb`, `vdbBuildFromDense`, `vdbQuantize`…).
159
+ * @throws {VDBToolsError} `VDB_BAD_IMAGE` for words that are not a grid image, `VDB_UNSUPPORTED_GRID_TYPE` for a
160
+ * grid type that is not scalar (vector, point and index grids), `VDB_BAD_OPTION` for an unknown `tiles` value.
161
+ */
162
+ export declare function vdbTreeNodes(image: Uint32Array, options?: VDBTreeNodesOptions): Generator<VDBTreeNode, void, undefined>;
72
163
  /** A leaf's 512 decoded values (f32, WGSL decode order) and active flags, x-major (`n = x*64 + y*8 + z`). */
73
164
  export declare function leafVoxels(gridWords: Uint32Array, leafAddress: number): {
74
165
  values: Float32Array;
@@ -26,8 +26,14 @@
26
26
  * Fp leaf stats (NanoVDB.h `LeafFnBase`, OpenVDB a532de55): uint16 codes at
27
27
  * leaf bytes 88/90/92/94; min/max/ave = code * quantum + minimum, stddev =
28
28
  * code * quantum, with the leaf's own mMinimum (byte 80) and mQuantum (84).
29
+ *
30
+ * Half grids (K7.H, NanoVDB `GridType::Half`): voxels, tiles, the background
31
+ * and min/max stats are IEEE binary16 at every level (2-byte aligned), decoded
32
+ * exactly as the fork's `pnanovdb_read_half` (`unpack2x16float`) does;
33
+ * ave/stddev are f32.
29
34
  */
30
35
  import { VDBToolsError } from "../errors.js";
36
+ import { vdbHalfToFloat } from "../nanovdb/half.js";
31
37
  import { defineBigInt, defineNumber, gridTypeConstantsForId, gridTypeIds } from "./stride-tables.js";
32
38
  const f = Math.fround;
33
39
  const GRID_OFF_MAGIC = defineNumber("PNANOVDB_GRID_OFF_MAGIC");
@@ -57,7 +63,7 @@ const HDDA_FLOAT_MAX = f(1e38);
57
63
  const FORWARD_SCALE = f(0.999999);
58
64
  const FORWARD_BIAS = f(1.0e-6);
59
65
  const FP_TYPES = new Set([gridTypeIds.FP4, gridTypeIds.FP8, gridTypeIds.FP16, gridTypeIds.FPN]);
60
- const SUPPORTED_TYPES = new Set([gridTypeIds.FLOAT, ...FP_TYPES]);
66
+ const SUPPORTED_TYPES = new Set([gridTypeIds.FLOAT, gridTypeIds.HALF, ...FP_TYPES]);
61
67
  /** Per-image header cache, keyed by the array: images are treated as immutable once read. */
62
68
  const grids = new WeakMap();
63
69
  function u32(words, address) {
@@ -72,7 +78,7 @@ function grid(words) {
72
78
  throw new VDBToolsError("VDB_BAD_IMAGE", "march: gridWords does not start with a NanoVDB GridData block");
73
79
  const gridType = u32(words, GRID_OFF_GRID_TYPE);
74
80
  if (!SUPPORTED_TYPES.has(gridType))
75
- throw new VDBToolsError("VDB_UNSUPPORTED_GRID_TYPE", `march: grid type ${gridType} is not Float/Fp4/Fp8/Fp16/FpN`);
81
+ throw new VDBToolsError("VDB_UNSUPPORTED_GRID_TYPE", `march: grid type ${gridType} is not Float/Half/Fp4/Fp8/Fp16/FpN`);
76
82
  const root = GRID_SIZE + u32(words, GRID_SIZE + TREE_OFF_NODE_OFFSET_ROOT);
77
83
  g = {
78
84
  words,
@@ -80,6 +86,7 @@ function grid(words) {
80
86
  gridType,
81
87
  gt: gridTypeConstantsForId(gridType),
82
88
  fp: FP_TYPES.has(gridType),
89
+ half: gridType === gridTypeIds.HALF,
83
90
  hasStats: (u32(words, GRID_OFF_FLAGS) & GRID_FLAGS_HAS_MIN_MAX) !== 0,
84
91
  root,
85
92
  };
@@ -93,6 +100,13 @@ function readF32(g, address) {
93
100
  function readU16(g, address) {
94
101
  return (u32(g.words, address & ~3) >>> ((address & 2) << 3)) & 0xffff;
95
102
  }
103
+ /**
104
+ * A value slot (voxel, tile, background) or a min/max stats slot, as the
105
+ * grid stores it: binary16 for Half (the fork's `pnanovdb_read_half`), f32 otherwise.
106
+ */
107
+ function readValueSlot(g, address) {
108
+ return g.half ? vdbHalfToFloat(readU16(g, address)) : readF32(g, address);
109
+ }
96
110
  function maskBit(g, base, n) {
97
111
  return ((u32(g.words, base + 4 * (n >>> 5)) >>> (n & 31)) & 1) !== 0;
98
112
  }
@@ -194,8 +208,8 @@ export function nodeStats(gridWords, level, address) {
194
208
  ? [gt.upper_off_min, gt.upper_off_max, gt.upper_off_ave, gt.upper_off_stddev]
195
209
  : [gt.root_off_min, gt.root_off_max, gt.root_off_ave, gt.root_off_stddev];
196
210
  return {
197
- min: readF32(g, address + off[0]),
198
- max: readF32(g, address + off[1]),
211
+ min: readValueSlot(g, address + off[0]),
212
+ max: readValueSlot(g, address + off[1]),
199
213
  ave: readF32(g, address + off[2]),
200
214
  stddev: readF32(g, address + off[3]),
201
215
  };
@@ -209,7 +223,7 @@ export function defaultValueMax(gridWords) {
209
223
  const g = grid(gridWords);
210
224
  if (!g.hasStats)
211
225
  return Infinity;
212
- return Math.max(readF32(g, g.root + g.gt.root_off_max), readF32(g, g.root + g.gt.root_off_background));
226
+ return Math.max(readValueSlot(g, g.root + g.gt.root_off_max), readValueSlot(g, g.root + g.gt.root_off_background));
213
227
  }
214
228
  /**
215
229
  * Twin of `vdbNodeMax(acc, ijk, dim)`: a bound for the aligned cell of size
@@ -225,7 +239,7 @@ export function nodeMax(gridWords, ijk, dim, options = {}) {
225
239
  const path = locate(g, ijk);
226
240
  const a = DIM_OF_LEVEL[path.level];
227
241
  if (a > 1 && dim <= a)
228
- return readF32(g, path.valueAddress);
242
+ return readValueSlot(g, path.valueAddress);
229
243
  if (!g.hasStats)
230
244
  return options.valueMax ?? defaultValueMax(gridWords);
231
245
  if (dim <= 8)
@@ -241,24 +255,27 @@ export function isActive(gridWords, ijk) {
241
255
  return locate(grid(gridWords), ijk).active;
242
256
  }
243
257
  /**
244
- * Twin of `vdbReadValue` (f32 decode in WGSL order; any of Float/Fp4/Fp8/Fp16/FpN).
258
+ * Twin of `vdbReadValue` (f32 decode in WGSL order; any of Float/Half/Fp4/Fp8/Fp16/FpN).
245
259
  *
246
260
  * This matches the GPU's evaluation order (f32 arithmetic), so it is the right
247
261
  * oracle for GPU parity checks. `readValue` instead returns the exact f64
248
262
  * decode; on Fp grids the two can differ by 1 ulp (f32).
263
+ *
264
+ * @param gridWords The grid image (little-endian u32 words, `GridData` at word 0).
265
+ * @param ijk Integer index coordinates of the voxel.
249
266
  */
250
- export function vdbReadValueF32(gridWords, ijk) {
267
+ export function vdbReadValueF32Cpu(gridWords, ijk) {
251
268
  const g = grid(gridWords);
252
269
  const path = locate(g, ijk);
253
270
  if (path.level !== 0)
254
- return readF32(g, path.valueAddress);
271
+ return readValueSlot(g, path.valueAddress);
255
272
  const n = ((ijk[0] & 7) << 6) + ((ijk[1] & 7) << 3) + (ijk[2] & 7);
256
273
  return leafValue(g, path.leaf, n);
257
274
  }
258
275
  function leafValue(g, leaf, n) {
259
276
  const table = leaf + g.gt.leaf_off_table;
260
277
  if (!g.fp)
261
- return readF32(g, table + ((g.gt.value_stride_bits * n) >> 3));
278
+ return readValueSlot(g, table + ((g.gt.value_stride_bits * n) >> 3));
262
279
  let logBits;
263
280
  if (g.gridType === gridTypeIds.FP4)
264
281
  logBits = 2;
@@ -299,7 +316,7 @@ export function treeNodes(gridWords) {
299
316
  const child = childOffset(g, t + ROOT_TILE_OFF_CHILD);
300
317
  if (child === 0 && u32(g.words, t + ROOT_TILE_OFF_CHILD + 4) === 0) {
301
318
  if (u32(g.words, t + ROOT_TILE_OFF_STATE) !== 0)
302
- rootNode.activeTiles.push({ value: readF32(g, t + gt.root_tile_off_value), origin, dim: 4096 });
319
+ rootNode.activeTiles.push({ value: readValueSlot(g, t + gt.root_tile_off_value), origin, dim: 4096 });
303
320
  continue;
304
321
  }
305
322
  const upper = g.root + child;
@@ -309,7 +326,7 @@ export function treeNodes(gridWords) {
309
326
  const ut = upper + gt.upper_off_table + gt.table_stride * un;
310
327
  if (!maskBit(g, upper + UPPER_OFF_CHILD_MASK, un)) {
311
328
  if (maskBit(g, upper + UPPER_OFF_VALUE_MASK, un))
312
- out[ui].activeTiles.push({ value: readF32(g, ut), origin: uo, dim: 128 });
329
+ out[ui].activeTiles.push({ value: readValueSlot(g, ut), origin: uo, dim: 128 });
313
330
  continue;
314
331
  }
315
332
  const lower = upper + childOffset(g, ut);
@@ -319,7 +336,7 @@ export function treeNodes(gridWords) {
319
336
  const lt = lower + gt.lower_off_table + gt.table_stride * ln;
320
337
  if (!maskBit(g, lower + LOWER_OFF_CHILD_MASK, ln)) {
321
338
  if (maskBit(g, lower + LOWER_OFF_VALUE_MASK, ln))
322
- out[li].activeTiles.push({ value: readF32(g, lt), origin: lo3, dim: 8 });
339
+ out[li].activeTiles.push({ value: readValueSlot(g, lt), origin: lo3, dim: 8 });
323
340
  continue;
324
341
  }
325
342
  out.push({ level: 0, address: lower + childOffset(g, lt), origin: lo3, parent: li, activeTiles: [] });
@@ -328,6 +345,140 @@ export function treeNodes(gridWords) {
328
345
  }
329
346
  return out;
330
347
  }
348
+ /**
349
+ * Every leaf and every tile of the tree, active or not (P1.2, the brick-majorant builder needs the
350
+ * values a trilinear tap can read, inactive ones included). Space under no root tile reads the
351
+ * background: the result lists the min corners of the root tiles (with or without a child), so a
352
+ * caller can tell which 4096-blocks are covered.
353
+ */
354
+ export function forEachTreeRegion(gridWords, visit) {
355
+ const g = grid(gridWords);
356
+ const gt = g.gt;
357
+ const rootTiles = [];
358
+ const count = u32(g.words, g.root + ROOT_OFF_TABLE_SIZE);
359
+ for (let i = 0; i < count; i++) {
360
+ const t = g.root + gt.root_size + i * gt.root_tile_size;
361
+ const key = (BigInt(u32(g.words, t + ROOT_TILE_OFF_KEY + 4)) << 32n) | BigInt(u32(g.words, t + ROOT_TILE_OFF_KEY));
362
+ const origin = [
363
+ Number((key >> 42n) & 0x1fffffn) << 12 | 0,
364
+ Number((key >> 21n) & 0x1fffffn) << 12 | 0,
365
+ Number(key & 0x1fffffn) << 12 | 0,
366
+ ];
367
+ rootTiles.push(origin);
368
+ const child = childOffset(g, t + ROOT_TILE_OFF_CHILD);
369
+ if (child === 0 && u32(g.words, t + ROOT_TILE_OFF_CHILD + 4) === 0) {
370
+ visit({ level: 3, origin, dim: 4096, leaf: 0, value: readValueSlot(g, t + gt.root_tile_off_value) });
371
+ continue;
372
+ }
373
+ const upper = g.root + child;
374
+ for (let un = 0; un < 32768; un++) {
375
+ const uo = [origin[0] + ((un >> 10) & 31) * 128, origin[1] + ((un >> 5) & 31) * 128, origin[2] + (un & 31) * 128];
376
+ const ut = upper + gt.upper_off_table + gt.table_stride * un;
377
+ if (!maskBit(g, upper + UPPER_OFF_CHILD_MASK, un)) {
378
+ visit({ level: 2, origin: uo, dim: 128, leaf: 0, value: readValueSlot(g, ut) });
379
+ continue;
380
+ }
381
+ const lower = upper + childOffset(g, ut);
382
+ for (let ln = 0; ln < 4096; ln++) {
383
+ const lo3 = [uo[0] + ((ln >> 8) & 15) * 8, uo[1] + ((ln >> 4) & 15) * 8, uo[2] + (ln & 15) * 8];
384
+ const lt = lower + gt.lower_off_table + gt.table_stride * ln;
385
+ if (!maskBit(g, lower + LOWER_OFF_CHILD_MASK, ln)) {
386
+ visit({ level: 1, origin: lo3, dim: 8, leaf: 0, value: readValueSlot(g, lt) });
387
+ continue;
388
+ }
389
+ visit({ level: 0, origin: lo3, dim: 8, leaf: lower + childOffset(g, lt), value: 0 });
390
+ }
391
+ }
392
+ }
393
+ return { background: readValueSlot(g, g.root + gt.root_off_background), rootTiles };
394
+ }
395
+ function popcount32(v) {
396
+ v -= (v >>> 1) & 0x55555555;
397
+ v = (v & 0x33333333) + ((v >>> 2) & 0x33333333);
398
+ return (((v + (v >>> 4)) & 0x0f0f0f0f) * 0x01010101) >>> 24;
399
+ }
400
+ /**
401
+ * Walks the tree of a scalar grid image (Float, Half, Fp4, Fp8, Fp16, FpN): its leaves and tiles, and on request
402
+ * its upper and lower nodes. For drawing node boxes, counting what a grid stores, or telling where a voxel's value
403
+ * comes from (a leaf holds one value per voxel; a tile is one value for its whole block).
404
+ *
405
+ * The order is the image's own: root entries in table order (signed origin order: x, then y, then z), then each
406
+ * node's table by slot, depth first. Every entry is a new object. Space that no entry covers reads the grid's
407
+ * background. Voxel values are not decoded here: read them with `vdbReadValueCpu`.
408
+ *
409
+ * The image and the options are checked when the first entry is asked for, not when the function is called.
410
+ *
411
+ * @param image A NanoVDB grid image (`NvdbFile.gridImage`, `buildFromVdb`, `vdbBuildFromDense`, `vdbQuantize`…).
412
+ * @throws {VDBToolsError} `VDB_BAD_IMAGE` for words that are not a grid image, `VDB_UNSUPPORTED_GRID_TYPE` for a
413
+ * grid type that is not scalar (vector, point and index grids), `VDB_BAD_OPTION` for an unknown `tiles` value.
414
+ */
415
+ export function* vdbTreeNodes(image, options = {}) {
416
+ const tiles = options.tiles ?? "active";
417
+ if (tiles !== "active" && tiles !== "all" && tiles !== "none") {
418
+ throw new VDBToolsError("VDB_BAD_OPTION", `vdbTreeNodes: tiles must be 'active', 'all' or 'none', got ${String(tiles)}`);
419
+ }
420
+ const leaves = options.leaves !== false;
421
+ const internalNodes = options.internalNodes === true;
422
+ const allTiles = tiles === "all";
423
+ const g = grid(image);
424
+ const gt = g.gt;
425
+ const count = u32(g.words, g.root + ROOT_OFF_TABLE_SIZE);
426
+ for (let i = 0; i < count; i++) {
427
+ const t = g.root + gt.root_size + i * gt.root_tile_size;
428
+ const key = (BigInt(u32(g.words, t + ROOT_TILE_OFF_KEY + 4)) << 32n) | BigInt(u32(g.words, t + ROOT_TILE_OFF_KEY));
429
+ const ox = Number((key >> 42n) & 0x1fffffn) << 12 | 0;
430
+ const oy = Number((key >> 21n) & 0x1fffffn) << 12 | 0;
431
+ const oz = Number(key & 0x1fffffn) << 12 | 0;
432
+ const child = childOffset(g, t + ROOT_TILE_OFF_CHILD);
433
+ if (child === 0 && u32(g.words, t + ROOT_TILE_OFF_CHILD + 4) === 0) {
434
+ if (tiles === "none")
435
+ continue;
436
+ const active = u32(g.words, t + ROOT_TILE_OFF_STATE) !== 0;
437
+ if (active || allTiles)
438
+ yield { kind: "tile", level: 3, origin: [ox, oy, oz], size: 4096, value: readValueSlot(g, t + gt.root_tile_off_value), active };
439
+ continue;
440
+ }
441
+ const upper = g.root + child;
442
+ if (internalNodes)
443
+ yield { kind: "upper", level: 2, origin: [ox, oy, oz], size: 4096 };
444
+ for (let un = 0; un < 32768; un++) {
445
+ const isChild = maskBit(g, upper + UPPER_OFF_CHILD_MASK, un);
446
+ if (!isChild && tiles === "none")
447
+ continue;
448
+ const ux = ox + ((un >> 10) & 31) * 128;
449
+ const uy = oy + ((un >> 5) & 31) * 128;
450
+ const uz = oz + (un & 31) * 128;
451
+ const ut = upper + gt.upper_off_table + gt.table_stride * un;
452
+ if (!isChild) {
453
+ const active = maskBit(g, upper + UPPER_OFF_VALUE_MASK, un);
454
+ if (active || allTiles)
455
+ yield { kind: "tile", level: 2, origin: [ux, uy, uz], size: 128, value: readValueSlot(g, ut), active };
456
+ continue;
457
+ }
458
+ const lower = upper + childOffset(g, ut);
459
+ if (internalNodes)
460
+ yield { kind: "lower", level: 1, origin: [ux, uy, uz], size: 128 };
461
+ for (let ln = 0; ln < 4096; ln++) {
462
+ const isLeaf = maskBit(g, lower + LOWER_OFF_CHILD_MASK, ln);
463
+ if (isLeaf ? !leaves : tiles === "none")
464
+ continue;
465
+ const origin = [ux + ((ln >> 8) & 15) * 8, uy + ((ln >> 4) & 15) * 8, uz + (ln & 15) * 8];
466
+ const lt = lower + gt.lower_off_table + gt.table_stride * ln;
467
+ if (!isLeaf) {
468
+ const active = maskBit(g, lower + LOWER_OFF_VALUE_MASK, ln);
469
+ if (active || allTiles)
470
+ yield { kind: "tile", level: 1, origin, size: 8, value: readValueSlot(g, lt), active };
471
+ continue;
472
+ }
473
+ const mask = lower + childOffset(g, lt) + LEAF_OFF_VALUE_MASK;
474
+ let activeVoxelCount = 0;
475
+ for (let w = 0; w < 16; w++)
476
+ activeVoxelCount += popcount32(u32(g.words, mask + 4 * w));
477
+ yield { kind: "leaf", level: 0, origin, size: 8, activeVoxelCount };
478
+ }
479
+ }
480
+ }
481
+ }
331
482
  /** A leaf's 512 decoded values (f32, WGSL decode order) and active flags, x-major (`n = x*64 + y*8 + z`). */
332
483
  export function leafVoxels(gridWords, leafAddress) {
333
484
  const g = grid(gridWords);
@@ -492,7 +643,7 @@ export function nodeAverage(gridWords, ijk, dim) {
492
643
  const path = locate(g, ijk);
493
644
  const a = DIM_OF_LEVEL[path.level];
494
645
  if ((a > 1 && dim <= a) || !g.hasStats || dim <= 1)
495
- return vdbReadValueF32(gridWords, ijk);
646
+ return vdbReadValueF32Cpu(gridWords, ijk);
496
647
  if (dim <= 8) {
497
648
  let n = 0;
498
649
  for (let w = 0; w < 16; w++) {