@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
@@ -4,8 +4,9 @@
4
4
  *
5
5
  * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345:
6
6
  * `src/wvdb/bake.js` (getWVDBBox, getFinestDimensions, forEachTexel,
7
- * sampleScalarGrid, the level-set band limit) and `src/wvdb/cli.js` (the
8
- * `source` member). His sampling is reproduced, including its arithmetic order:
7
+ * sampleScalarGrid, the level-set band limit, getBakedGrids and
8
+ * encodePointGrid: point data grids become points grids in file order, G14b)
9
+ * and `src/wvdb/cli.js` (the `source` member). His sampling is reproduced, including its arithmetic order:
9
10
  * - one shared world box for all grids: the union of the grids' active-voxel
10
11
  * index boxes (voxel centres, so `max` is the last voxel, not one past it)
11
12
  * mapped to world space, unless `bbox` is given;
@@ -41,9 +42,10 @@ import { vdbResampleDense } from "../nanovdb/resample.js";
41
42
  import { gridTypeConstantsForId } from "../cpu/stride-tables.js";
42
43
  import { GRID_NAME_MAX, GRID_OFF_GRID_CLASS, GRID_OFF_GRID_NAME, GRID_OFF_GRID_TYPE, GRID_OFF_MAP, GRID_SIZE, MAP_OFF_INVMATD, MAP_OFF_MATD, MAP_OFF_VECD, ROOT_OFF_BBOX_MAX, ROOT_OFF_BBOX_MIN, TREE_OFF_NODE_OFFSET_ROOT, } from "../nanovdb/bytes.js";
43
44
  import { parseVdb } from "../vdb/parse.js";
45
+ import { vdbPointRenderData } from "../vdb/point-render-data.js";
44
46
  import { sampleWvdbLevelSetSurfaceMean } from "./level-set.js";
45
47
  import { sha256Hex } from "./sha256.js";
46
- import { writeWvdb } from "./write.js";
48
+ import { writeWvdb, } from "./write.js";
47
49
  function unionBox(boxes) {
48
50
  if (!boxes.length)
49
51
  return null;
@@ -121,8 +123,17 @@ export function sampleWvdbDenseBox(source, bbox, dimensions, bits = 8) {
121
123
  }
122
124
  return values;
123
125
  }
124
- /** Bakes sources to a `.wvdb` with his CLI defaults (128, 3 LODs, 8 bits, sparse, 1024 bricks per page). */
126
+ /**
127
+ * Bakes sources to a `.wvdb` with his CLI defaults (128, 3 LODs, 8 bits, sparse, 1024 bricks per page).
128
+ * @param sources The grids to bake, point-sampled in world space.
129
+ * @param options Resolution, box, grid names, sampling and the writer's options ({@link BakeWvdbOptions}).
130
+ */
125
131
  export function bakeWvdb(sources, options = {}) {
132
+ const { grids, write } = bakeWvdbVolumes(sources, options);
133
+ return writeWvdb(grids, write);
134
+ }
135
+ /** The volume grids {@link bakeWvdb} writes, and the writer's options (shared with `vdbToWvdb`'s points path). */
136
+ function bakeWvdbVolumes(sources, options) {
126
137
  const { resolution = 128, bbox: bakeBBox = null, dimensions, gridNames = null, sampling = "nearest", levelSetSampler = "spec", ...write } = options;
127
138
  if (sampling !== "nearest" && sampling !== "box")
128
139
  throw new VDBToolsError("VDB_BAD_OPTION", `bakeWvdb: unknown sampling "${String(sampling)}"`);
@@ -149,7 +160,7 @@ export function bakeWvdb(sources, options = {}) {
149
160
  : sampleWvdbDense(s, box, dims, bits),
150
161
  },
151
162
  }));
152
- return writeWvdb(grids, { ...write, resolution, gridNames, bakeBBox });
163
+ return { grids, write: { ...write, resolution, gridNames, bakeBBox } };
153
164
  }
154
165
  // ---------------------------------------------------------------------------
155
166
  // Sources
@@ -277,11 +288,37 @@ export function wvdbSourceFromNvdb(gridWords) {
277
288
  grid: gridWords,
278
289
  };
279
290
  }
291
+ /**
292
+ * A parsed point data grid as a `.wvdb` points grid (G14b, his `encodePointGrid`): world positions and `Cd` in
293
+ * the grid's point order, every n-th point above `maxPoints` (`vdbPointRenderData`'s stride rule, his
294
+ * `createPointData`), the source count and his spacing. `writeWvdb` then splits it into LODs (§3.5).
295
+ *
296
+ * @param grid A point data grid from `parseVdb`.
297
+ * @param maxPoints Keep every `ceil(total / maxPoints)`-th point above this many (default 4,000,000).
298
+ */
299
+ export function wvdbPointsFromVdbGrid(grid, maxPoints) {
300
+ const data = vdbPointRenderData(grid, maxPoints === undefined ? {} : { maxPoints });
301
+ const cls = grid.metadata["class"];
302
+ return {
303
+ type: "points",
304
+ name: grid.name,
305
+ class: typeof cls === "string" ? cls : "unknown",
306
+ positions: data.positions,
307
+ colors: data.colors,
308
+ sourceCount: data.totalCount,
309
+ spacing: data.spacing,
310
+ };
311
+ }
280
312
  /**
281
313
  * `.vdb` → `.wvdb`, like his `wvdb` CLI with the same options. Given the file
282
- * bytes, `source.sha256` is their digest. Only float grids are baked: vector
283
- * and point data grids are skipped (his CLI bakes vectors as 3 channels and
284
- * point data grids as points grids; not ported yet).
314
+ * bytes, `source.sha256` is their digest. Float grids are baked as volumes and
315
+ * point data grids as points grids (G14b: positions and `Cd`, every n-th point
316
+ * above `maxPoints`, the §3.5 LOD order), in file order; the volume box ignores
317
+ * the points (his `getWVDBBox`). Vector grids are skipped (his CLI bakes them as
318
+ * 3 channels; not ported).
319
+ * @param input The `.vdb` file's bytes, or an already parsed {@link VdbFile}.
320
+ * @param options Baker options and the `source.file` name.
321
+ * @throws VDBToolsError `VDB_UNSUPPORTED_GRID_TYPE` when the file has no float or point data grids.
285
322
  */
286
323
  export function vdbToWvdb(input, options = {}) {
287
324
  const { fileName = "", ...bake } = options;
@@ -298,12 +335,25 @@ export function vdbToWvdb(input, options = {}) {
298
335
  else {
299
336
  file = input;
300
337
  }
301
- const floatGrids = file.grids.filter((g) => g.valueType === "float");
302
- if (floatGrids.length === 0)
303
- throw new VDBToolsError("VDB_UNSUPPORTED_GRID_TYPE", "vdbToWvdb: the file has no float grids to bake");
304
- return bakeWvdb(floatGrids.map(wvdbSourceFromVdbGrid), { ...bake, ...(source ? { source } : {}) });
338
+ // His getBakedGrids: the selected scalar and point data grids, in file order.
339
+ const names = bake.gridNames ?? null;
340
+ const baked = file.grids.filter((g) => (g.valueType === "float" || g.valueType === "ptdataidx32") && (!names || names.includes(g.name)));
341
+ if (!file.grids.some((g) => g.valueType === "float" || g.valueType === "ptdataidx32")) {
342
+ throw new VDBToolsError("VDB_UNSUPPORTED_GRID_TYPE", "vdbToWvdb: the file has no float or point data grids to bake");
343
+ }
344
+ const options2 = { ...bake, ...(source ? { source } : {}) };
345
+ if (!baked.some((g) => g.valueType === "ptdataidx32"))
346
+ return bakeWvdb(file.grids.filter((g) => g.valueType === "float").map(wvdbSourceFromVdbGrid), options2);
347
+ const floats = baked.filter((g) => g.valueType === "float");
348
+ const { grids: volumes, write } = bakeWvdbVolumes(floats.map(wvdbSourceFromVdbGrid), options2);
349
+ const grids = baked.map((g) => g.valueType === "float" ? volumes[floats.indexOf(g)] : wvdbPointsFromVdbGrid(g, bake.maxPoints));
350
+ return writeWvdb(grids, write);
305
351
  }
306
- /** NanoVDB grid image(s) → `.wvdb`, sampled through the CPU oracle. */
352
+ /**
353
+ * NanoVDB grid image(s) → `.wvdb`, sampled through the CPU oracle.
354
+ * @param images One grid image or several.
355
+ * @param options Baker options.
356
+ */
307
357
  export function nvdbToWvdb(images, options = {}) {
308
358
  const list = images instanceof Uint32Array ? [images] : images;
309
359
  return bakeWvdb(list.map(wvdbSourceFromNvdb), options);
@@ -1 +1 @@
1
- {"version":3,"file":"bake.js","sourceRoot":"","sources":["../../../src/tools/wvdb/bake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,eAAe,EACf,YAAY,EACZ,YAAY,EAC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E,MAAM,UAAU,UAAU,CAAC,MAA4C,EAAE,UAA2B,EAAE;IACpG,MAAM,IAAI,GAAG,MAAM,YAAY,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/D,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/**\n * bake.ts — resample sparse grids (a parsed `.vdb`, or a NanoVDB grid image\n * through the CPU oracle) to dense levels and write a `.wvdb`.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345:\n * `src/wvdb/bake.js` (getWVDBBox, getFinestDimensions, forEachTexel,\n * sampleScalarGrid, the level-set band limit) and `src/wvdb/cli.js` (the\n * `source` member). His sampling is reproduced, including its arithmetic order:\n * - one shared world box for all grids: the union of the grids' active-voxel\n * index boxes (voxel centres, so `max` is the last voxel, not one past it)\n * mapped to world space, unless `bbox` is given;\n * - the finest LOD has `resolution` voxels on the longest box side, the other\n * sides `max(1, round(side * resolution / longest))` (§3.2.1);\n * - **point sampling, no prefilter** (§3.2.2): world position of voxel centre\n * `min + ((i + 0.5) / X) * size`, mapped to index space with the inverse\n * map, rounded with `Math.round` (halves toward +infinity) and read with\n * the grid's own value lookup (inactive values included). A source much\n * finer than the target resolution aliases; that is his behaviour and the\n * default here (`sampling: 'nearest'`).\n *\n * Options beyond his CLI (K4.13):\n * - `sampling: 'box'` prefilters: each texel is the area-weighted mean of the\n * source voxels its cell covers, on the same lattice (`vdbResampleDense`, the\n * K4.4 `vdbResampleGrid` box filter). Mass is conserved and thin features fade\n * instead of flickering in and out;\n * - `levelSetSampler: 'surface-mean'` samples level sets with his CLI's\n * `sampleLevelSet` (`level-set.ts`), which reproduces his level-set files.\n *\n * Differences from his CLI (also in docs/archive/handoffs/K4-3.md):\n * - by default (`levelSetSampler: 'spec'`) level sets are point-sampled and\n * then encoded by the §8 rule (active: clamp to `±(b - 2b/maxCode)`;\n * inactive: `±b` by sign). His CLI uses `sampleLevelSet` (a surface-aware\n * mean) instead, so level-set bytes differ (DIVERGES V17);\n * - `dimensions` can override the finest LOD size (his pre-0.11 bakes used\n * `resolution`³ for every box, e.g. the committed `smoke.wvdb` and\n * `bunny_cloud.wvdb`; this reproduces them).\n */\n\nimport { VDBToolsError, VDBUnsupportedError } from \"../errors.js\";\nimport { vdbReadValueCpu } from \"../cpu/read-value.js\";\nimport { vdbResampleDense } from \"../nanovdb/resample.js\";\nimport { gridTypeConstantsForId } from \"../cpu/stride-tables.js\";\nimport {\n GRID_NAME_MAX,\n GRID_OFF_GRID_CLASS,\n GRID_OFF_GRID_NAME,\n GRID_OFF_GRID_TYPE,\n GRID_OFF_MAP,\n GRID_SIZE,\n MAP_OFF_INVMATD,\n MAP_OFF_MATD,\n MAP_OFF_VECD,\n ROOT_OFF_BBOX_MAX,\n ROOT_OFF_BBOX_MIN,\n TREE_OFF_NODE_OFFSET_ROOT,\n} from \"../nanovdb/bytes.js\";\nimport { parseVdb } from \"../vdb/parse.js\";\nimport type { VdbFile, VdbGrid } from \"../vdb/types.js\";\nimport type { WvdbBits, WvdbBox, WvdbSource, WvdbVec3 } from \"./format.js\";\nimport { sampleWvdbLevelSetSurfaceMean, type WvdbIndexAccess } from \"./level-set.js\";\nimport { sha256Hex } from \"./sha256.js\";\nimport { writeWvdb, type WriteWvdbOptions, type WriteWvdbResult, type WvdbVolumeGridInput } from \"./write.js\";\n\n/** A grid the baker can point-sample in world space. */\nexport interface WvdbSampleSource {\n name: string;\n /** `.wvdb` class string: \"fog volume\", \"level set\", \"staggered\" or \"unknown\". */\n class: string;\n background: number;\n /** World box of the active voxels (voxel centres), or null when the grid has none. */\n bbox: WvdbBox | null;\n /** The grid value (and active state) at the voxel nearest to a world position. */\n sample(world: WvdbVec3): { value: number; active: boolean };\n /** Index-space access, for `levelSetSampler: 'surface-mean'`. The built-in sources have it. */\n index?: WvdbIndexAccess;\n /** The sparse grid behind the source, for `sampling: 'box'`. The built-in sources have it. */\n grid?: Uint32Array | VdbGrid;\n}\n\nexport interface BakeWvdbOptions extends Omit<WriteWvdbOptions, \"resolution\" | \"bakeBBox\"> {\n /** Voxels on the longest box side of the finest LOD. Default 128. */\n resolution?: number;\n /** One world box for all grids (a sequence box, §10; recorded as `bake.bbox`). Default: union of the grids' boxes. */\n bbox?: WvdbBox | null;\n /** Override the finest LOD dimensions (default from `resolution` and the box). */\n dimensions?: WvdbVec3;\n /**\n * Grids to keep, by name; also recorded as `bake.grids`. Default null (all).\n */\n gridNames?: string[] | null;\n /**\n * Resampling filter. `\"nearest\"` (default): his point sampling. `\"box\"`: the\n * area-weighted mean over each texel's cell (K4.4's box filter; conserves\n * mass, no aliasing when the source is finer than the texels). Needs a source\n * with `grid` (the built-in sources).\n */\n sampling?: WvdbSampling;\n /**\n * How level sets are sampled. `\"spec\"` (default): `sampling`, then the spec\n * §8 rule by active state. `\"surface-mean\"`: his CLI's `sampleLevelSet`\n * (trilinear near the surface, a 4x4x4 mean in texels that cross it), which\n * reproduces his level-set `.wvdb` files; it ignores `sampling`.\n */\n levelSetSampler?: WvdbLevelSetSampler;\n}\n\nexport type WvdbSampling = \"nearest\" | \"box\";\nexport type WvdbLevelSetSampler = \"spec\" | \"surface-mean\";\n\nfunction unionBox(boxes: WvdbBox[]): WvdbBox | null {\n if (!boxes.length) return null;\n const min = [...boxes[0]![0]] as WvdbVec3;\n const max = [...boxes[0]![1]] as WvdbVec3;\n for (const [lo, hi] of boxes.slice(1)) {\n for (let a = 0; a < 3; a++) {\n min[a] = Math.min(min[a]!, lo[a]!);\n max[a] = Math.max(max[a]!, hi[a]!);\n }\n }\n return [min, max];\n}\n\n/** §3.2.1, his `getFinestDimensions`. */\nexport function wvdbFinestDimensions(bbox: WvdbBox | null, resolution: number): WvdbVec3 {\n const size = bbox ? ([0, 1, 2].map((a) => bbox[1][a]! - bbox[0][a]!) as WvdbVec3) : ([0, 0, 0] as WvdbVec3);\n const longest = Math.max(...size);\n if (!(longest > 0)) return [resolution, resolution, resolution];\n return size.map((side) => Math.max(1, Math.round((side * resolution) / longest))) as WvdbVec3;\n}\n\n/** Point-samples one source over the box (his `forEachTexel` + `sampleScalarGrid`). */\nexport function sampleWvdbDense(\n source: WvdbSampleSource,\n bbox: WvdbBox | null,\n dimensions: WvdbVec3,\n bits: WvdbBits = 8,\n): Float32Array {\n const [w, h, d] = dimensions;\n const values = new Float32Array(w * h * d);\n const background = source.background;\n if (!source.bbox || !bbox) return values.fill(background);\n const min = bbox[0];\n const size = [0, 1, 2].map((a) => bbox[1][a]! - min[a]!);\n const isLevelSet = source.class === \"level set\";\n const band = background - (2 * background) / ((1 << bits) - 1);\n const world: WvdbVec3 = [0, 0, 0];\n let o = 0;\n for (let z = 0; z < d; z++) {\n world[2] = ((z + 0.5) / d) * size[2]! + min[2];\n for (let y = 0; y < h; y++) {\n world[1] = ((y + 0.5) / h) * size[1]! + min[1];\n for (let x = 0; x < w; x++) {\n world[0] = ((x + 0.5) / w) * size[0]! + min[0];\n const { value, active } = source.sample(world);\n let v = Number.isFinite(value) ? value : background;\n if (isLevelSet) v = active ? Math.min(Math.max(v, -band), band) : v < 0 ? -background : background;\n values[o++] = v;\n }\n }\n }\n return values;\n}\n\n/**\n * Box-filters one source over the box (`sampling: 'box'`): `vdbResampleDense` on\n * his lattice, then the level-set rule of {@link sampleWvdbDense} by the\n * filtered active state.\n */\nexport function sampleWvdbDenseBox(\n source: WvdbSampleSource,\n bbox: WvdbBox | null,\n dimensions: WvdbVec3,\n bits: WvdbBits = 8,\n): Float32Array {\n const background = source.background;\n if (!source.bbox || !bbox) return new Float32Array(dimensions[0] * dimensions[1] * dimensions[2]).fill(background);\n if (!source.grid) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: sampling \"box\" needs the source grid; \"${source.name}\" has none (use wvdbSourceFromVdbGrid or wvdbSourceFromNvdb)`);\n }\n const { values, active } = vdbResampleDense(source.grid, { bbox, dimensions, filter: \"box\" });\n if (source.class === \"level set\") {\n const band = background - (2 * background) / ((1 << bits) - 1);\n for (let i = 0; i < values.length; i++) {\n const v = Number.isFinite(values[i]!) ? values[i]! : background;\n values[i] = active[i] ? Math.min(Math.max(v, -band), band) : v < 0 ? -background : background;\n }\n } else {\n for (let i = 0; i < values.length; i++) if (!Number.isFinite(values[i]!)) values[i] = background;\n }\n return values;\n}\n\n/** Bakes sources to a `.wvdb` with his CLI defaults (128, 3 LODs, 8 bits, sparse, 1024 bricks per page). */\nexport function bakeWvdb(sources: readonly WvdbSampleSource[], options: BakeWvdbOptions = {}): WriteWvdbResult {\n const {\n resolution = 128,\n bbox: bakeBBox = null,\n dimensions,\n gridNames = null,\n sampling = \"nearest\",\n levelSetSampler = \"spec\",\n ...write\n } = options;\n if (sampling !== \"nearest\" && sampling !== \"box\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: unknown sampling \"${String(sampling)}\"`);\n if (levelSetSampler !== \"spec\" && levelSetSampler !== \"surface-mean\") {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: unknown levelSetSampler \"${String(levelSetSampler)}\"`);\n }\n if (!Number.isInteger(resolution) || resolution < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: invalid resolution ${resolution}`);\n const selected = gridNames ? sources.filter((s) => gridNames.includes(s.name)) : [...sources];\n const box = bakeBBox ?? unionBox(selected.flatMap((s) => (s.bbox ? [s.bbox] : [])));\n const dims = dimensions ?? wvdbFinestDimensions(box, resolution);\n const bits = write.bits ?? 8;\n const grids: WvdbVolumeGridInput[] = selected.map((s) => ({\n name: s.name,\n class: s.class,\n background: s.background,\n bbox: box,\n finest: {\n dimensions: dims,\n values:\n s.class === \"level set\" && levelSetSampler === \"surface-mean\"\n ? sampleWvdbLevelSetSurfaceMean(s, box, dims, bits)\n : sampling === \"box\"\n ? sampleWvdbDenseBox(s, box, dims, bits)\n : sampleWvdbDense(s, box, dims, bits),\n },\n }));\n return writeWvdb(grids, { ...write, resolution, gridNames, bakeBBox });\n}\n\n// ---------------------------------------------------------------------------\n// Sources\n// ---------------------------------------------------------------------------\n\n/** A parsed `.vdb` grid (axis-aligned map) as a sample source. */\nexport function wvdbSourceFromVdbGrid(grid: VdbGrid): WvdbSampleSource {\n if (grid.valueType !== \"float\") {\n throw new VDBToolsError(\"VDB_UNSUPPORTED_GRID_TYPE\", \n `wvdbSourceFromVdbGrid: grid \"${grid.name}\" is a ${grid.valueType} grid; only float grids can be baked ` +\n `(vdbToWvdb skips the others)`,\n );\n }\n const m = grid.transform.matrix;\n if (m[1] !== 0 || m[2] !== 0 || m[4] !== 0 || m[6] !== 0 || m[8] !== 0 || m[9] !== 0) {\n throw new VDBUnsupportedError(`wvdbSourceFromVdbGrid: grid \"${grid.name}\" has a rotated map; only axis-aligned maps are supported`);\n }\n const scale = [m[0]!, m[5]!, m[10]!];\n const translation = [m[3]!, m[7]!, m[11]!];\n const inverse = scale.map((s) => 1 / s);\n const lo = [Infinity, Infinity, Infinity];\n const hi = [-Infinity, -Infinity, -Infinity];\n for (const leaf of grid.iterLeaves()) {\n for (let offset = 0; offset < 512; offset++) {\n if (((leaf.valueMask[offset >>> 5]! >>> (offset & 31)) & 1) === 0) continue;\n const ijk = [leaf.origin[0] + (offset >> 6), leaf.origin[1] + ((offset >> 3) & 7), leaf.origin[2] + (offset & 7)];\n for (let a = 0; a < 3; a++) {\n lo[a] = Math.min(lo[a]!, ijk[a]!);\n hi[a] = Math.max(hi[a]!, ijk[a]!);\n }\n }\n }\n let bbox: WvdbBox | null = null;\n if (lo[0]! <= hi[0]!) {\n const a = [0, 1, 2].map((i) => lo[i]! * scale[i]! + translation[i]!);\n const b = [0, 1, 2].map((i) => hi[i]! * scale[i]! + translation[i]!);\n bbox = [a.map((v, i) => Math.min(v, b[i]!)) as WvdbVec3, a.map((v, i) => Math.max(v, b[i]!)) as WvdbVec3];\n }\n const cls = grid.metadata[\"class\"];\n const ijk: [number, number, number] = [0, 0, 0];\n return {\n name: grid.name,\n class: typeof cls === \"string\" ? cls : \"unknown\",\n background: grid.background,\n bbox,\n sample(world) {\n for (let a = 0; a < 3; a++) ijk[a] = Math.round((world[a]! - translation[a]!) * inverse[a]!);\n return grid.readValue(ijk);\n },\n index: {\n // His GridTransform scale-translate maps: (v - translation) * scaleInverse.\n toIndex(world, out) {\n for (let a = 0; a < 3; a++) out[a] = (world[a]! - translation[a]!) * inverse[a]!;\n return out;\n },\n toIndexVector(v, out) {\n for (let a = 0; a < 3; a++) out[a] = v[a]! * inverse[a]!;\n return out;\n },\n voxel: (p) => grid.readValue(p),\n },\n grid,\n };\n}\n\nconst NANO_CLASS: Record<number, string> = { 1: \"level set\", 2: \"fog volume\", 3: \"staggered\" };\n\n/** A NanoVDB FLOAT/Fp8/FpN grid image as a sample source, read through the CPU oracle (`readValue`). */\nexport function wvdbSourceFromNvdb(gridWords: Uint32Array): WvdbSampleSource {\n const view = new DataView(gridWords.buffer, gridWords.byteOffset, gridWords.byteLength);\n const nameBytes = new Uint8Array(gridWords.buffer, gridWords.byteOffset + GRID_OFF_GRID_NAME, GRID_NAME_MAX);\n const nul = nameBytes.indexOf(0);\n const name = new TextDecoder().decode(nameBytes.subarray(0, nul < 0 ? GRID_NAME_MAX : nul));\n const gridType = view.getUint32(GRID_OFF_GRID_TYPE, true);\n const cls = NANO_CLASS[view.getUint32(GRID_OFF_GRID_CLASS, true)] ?? \"unknown\";\n const mat = Array.from({ length: 9 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_MATD + i * 8, true));\n const inv = Array.from({ length: 9 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_INVMATD + i * 8, true));\n const vec = Array.from({ length: 3 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_VECD + i * 8, true));\n const root = GRID_SIZE + Number(view.getBigUint64(GRID_SIZE + TREE_OFF_NODE_OFFSET_ROOT, true));\n const lo = [0, 1, 2].map((i) => view.getInt32(root + ROOT_OFF_BBOX_MIN + i * 4, true));\n const hi = [0, 1, 2].map((i) => view.getInt32(root + ROOT_OFF_BBOX_MAX + i * 4, true));\n const background = view.getFloat32(root + gridTypeConstantsForId(gridType).root_off_background, true);\n\n const toWorld = (p: number[]): number[] =>\n [0, 1, 2].map((r) => mat[r * 3]! * p[0]! + mat[r * 3 + 1]! * p[1]! + mat[r * 3 + 2]! * p[2]! + vec[r]!);\n let bbox: WvdbBox | null = null;\n if (lo[0]! <= hi[0]! && lo[1]! <= hi[1]! && lo[2]! <= hi[2]!) {\n const min = [Infinity, Infinity, Infinity];\n const max = [-Infinity, -Infinity, -Infinity];\n for (let c = 0; c < 8; c++) {\n const w = toWorld([c & 1 ? hi[0]! : lo[0]!, c & 2 ? hi[1]! : lo[1]!, c & 4 ? hi[2]! : lo[2]!]);\n for (let a = 0; a < 3; a++) {\n min[a] = Math.min(min[a]!, w[a]!);\n max[a] = Math.max(max[a]!, w[a]!);\n }\n }\n bbox = [min as WvdbVec3, max as WvdbVec3];\n }\n const ijk: [number, number, number] = [0, 0, 0];\n return {\n name,\n class: cls,\n background,\n bbox,\n sample(world) {\n const p = [world[0] - vec[0]!, world[1] - vec[1]!, world[2] - vec[2]!];\n for (let r = 0; r < 3; r++) ijk[r] = Math.round(inv[r * 3]! * p[0]! + inv[r * 3 + 1]! * p[1]! + inv[r * 3 + 2]! * p[2]!);\n return vdbReadValueCpu(gridWords, ijk);\n },\n index: {\n toIndex(world, out) {\n const p0 = world[0] - vec[0]!;\n const p1 = world[1] - vec[1]!;\n const p2 = world[2] - vec[2]!;\n for (let r = 0; r < 3; r++) out[r] = inv[r * 3]! * p0 + inv[r * 3 + 1]! * p1 + inv[r * 3 + 2]! * p2;\n return out;\n },\n toIndexVector(v, out) {\n const [v0, v1, v2] = v;\n for (let r = 0; r < 3; r++) out[r] = inv[r * 3]! * v0 + inv[r * 3 + 1]! * v1 + inv[r * 3 + 2]! * v2;\n return out;\n },\n voxel: (p) => vdbReadValueCpu(gridWords, p),\n },\n grid: gridWords,\n };\n}\n\nexport interface VdbToWvdbOptions extends BakeWvdbOptions {\n /** `source.file` (the name without directories). Default \"\". */\n fileName?: string;\n}\n\n/**\n * `.vdb` → `.wvdb`, like his `wvdb` CLI with the same options. Given the file\n * bytes, `source.sha256` is their digest. Only float grids are baked: vector\n * and point data grids are skipped (his CLI bakes vectors as 3 channels and\n * point data grids as points grids; not ported yet).\n */\nexport function vdbToWvdb(input: ArrayBuffer | Uint8Array | VdbFile, options: VdbToWvdbOptions = {}): WriteWvdbResult {\n const { fileName = \"\", ...bake } = options;\n let file: VdbFile;\n let source: WvdbSource | undefined = bake.source;\n if (input instanceof ArrayBuffer || input instanceof Uint8Array) {\n const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);\n const buffer = bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength && bytes.buffer instanceof ArrayBuffer\n ? bytes.buffer\n : bytes.slice().buffer;\n file = parseVdb(buffer);\n source ??= { file: fileName, sha256: sha256Hex(bytes) };\n } else {\n file = input;\n }\n const floatGrids = file.grids.filter((g) => g.valueType === \"float\");\n if (floatGrids.length === 0) throw new VDBToolsError(\"VDB_UNSUPPORTED_GRID_TYPE\", \"vdbToWvdb: the file has no float grids to bake\");\n return bakeWvdb(floatGrids.map(wvdbSourceFromVdbGrid), { ...bake, ...(source ? { source } : {}) });\n}\n\n/** NanoVDB grid image(s) → `.wvdb`, sampled through the CPU oracle. */\nexport function nvdbToWvdb(images: Uint32Array | readonly Uint32Array[], options: BakeWvdbOptions = {}): WriteWvdbResult {\n const list = images instanceof Uint32Array ? [images] : images;\n return bakeWvdb(list.map(wvdbSourceFromNvdb), options);\n}\n"]}
1
+ {"version":3,"file":"bake.js","sourceRoot":"","sources":["../../../src/tools/wvdb/bake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MA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AC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/D,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/**\n * bake.ts — resample sparse grids (a parsed `.vdb`, or a NanoVDB grid image\n * through the CPU oracle) to dense levels and write a `.wvdb`.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345:\n * `src/wvdb/bake.js` (getWVDBBox, getFinestDimensions, forEachTexel,\n * sampleScalarGrid, the level-set band limit, getBakedGrids and\n * encodePointGrid: point data grids become points grids in file order, G14b)\n * and `src/wvdb/cli.js` (the `source` member). His sampling is reproduced, including its arithmetic order:\n * - one shared world box for all grids: the union of the grids' active-voxel\n * index boxes (voxel centres, so `max` is the last voxel, not one past it)\n * mapped to world space, unless `bbox` is given;\n * - the finest LOD has `resolution` voxels on the longest box side, the other\n * sides `max(1, round(side * resolution / longest))` (§3.2.1);\n * - **point sampling, no prefilter** (§3.2.2): world position of voxel centre\n * `min + ((i + 0.5) / X) * size`, mapped to index space with the inverse\n * map, rounded with `Math.round` (halves toward +infinity) and read with\n * the grid's own value lookup (inactive values included). A source much\n * finer than the target resolution aliases; that is his behaviour and the\n * default here (`sampling: 'nearest'`).\n *\n * Options beyond his CLI (K4.13):\n * - `sampling: 'box'` prefilters: each texel is the area-weighted mean of the\n * source voxels its cell covers, on the same lattice (`vdbResampleDense`, the\n * K4.4 `vdbResampleGrid` box filter). Mass is conserved and thin features fade\n * instead of flickering in and out;\n * - `levelSetSampler: 'surface-mean'` samples level sets with his CLI's\n * `sampleLevelSet` (`level-set.ts`), which reproduces his level-set files.\n *\n * Differences from his CLI (also in docs/archive/handoffs/K4-3.md):\n * - by default (`levelSetSampler: 'spec'`) level sets are point-sampled and\n * then encoded by the §8 rule (active: clamp to `±(b - 2b/maxCode)`;\n * inactive: `±b` by sign). His CLI uses `sampleLevelSet` (a surface-aware\n * mean) instead, so level-set bytes differ (DIVERGES V17);\n * - `dimensions` can override the finest LOD size (his pre-0.11 bakes used\n * `resolution`³ for every box, e.g. the committed `smoke.wvdb` and\n * `bunny_cloud.wvdb`; this reproduces them).\n */\n\nimport { VDBToolsError, VDBUnsupportedError } from \"../errors.js\";\nimport { vdbReadValueCpu } from \"../cpu/read-value.js\";\nimport { vdbResampleDense } from \"../nanovdb/resample.js\";\nimport { gridTypeConstantsForId } from \"../cpu/stride-tables.js\";\nimport {\n GRID_NAME_MAX,\n GRID_OFF_GRID_CLASS,\n GRID_OFF_GRID_NAME,\n GRID_OFF_GRID_TYPE,\n GRID_OFF_MAP,\n GRID_SIZE,\n MAP_OFF_INVMATD,\n MAP_OFF_MATD,\n MAP_OFF_VECD,\n ROOT_OFF_BBOX_MAX,\n ROOT_OFF_BBOX_MIN,\n TREE_OFF_NODE_OFFSET_ROOT,\n} from \"../nanovdb/bytes.js\";\nimport { parseVdb } from \"../vdb/parse.js\";\nimport { vdbPointRenderData } from \"../vdb/point-render-data.js\";\nimport type { VdbFile, VdbGrid, VdbPointDataGrid } from \"../vdb/types.js\";\nimport type { WvdbBits, WvdbBox, WvdbSource, WvdbVec3 } from \"./format.js\";\nimport { sampleWvdbLevelSetSurfaceMean, type WvdbIndexAccess } from \"./level-set.js\";\nimport { sha256Hex } from \"./sha256.js\";\nimport {\n writeWvdb,\n type WriteWvdbOptions,\n type WriteWvdbResult,\n type WvdbGridInput,\n type WvdbPointsGridInput,\n type WvdbVolumeGridInput,\n} from \"./write.js\";\n\n/** A grid the baker can point-sample in world space. */\nexport interface WvdbSampleSource {\n /** The grid name (matched by `gridNames`). */\n name: string;\n /** `.wvdb` class string: \"fog volume\", \"level set\", \"staggered\" or \"unknown\". */\n class: string;\n /** The value outside the grid's active voxels. */\n background: number;\n /** World box of the active voxels (voxel centres), or null when the grid has none. */\n bbox: WvdbBox | null;\n /** The grid value (and active state) at the voxel nearest to a world position. */\n sample(world: WvdbVec3): { value: number; active: boolean };\n /** Index-space access, for `levelSetSampler: 'surface-mean'`. The built-in sources have it. */\n index?: WvdbIndexAccess;\n /** The sparse grid behind the source, for `sampling: 'box'`. The built-in sources have it. */\n grid?: Uint32Array | VdbGrid;\n}\n\n/** Options of {@link bakeWvdb}: the writer's options plus the box, resolution and sampling choices. */\nexport interface BakeWvdbOptions extends Omit<WriteWvdbOptions, \"resolution\" | \"bakeBBox\"> {\n /** Voxels on the longest box side of the finest LOD. Default 128. */\n resolution?: number;\n /** One world box for all grids (a sequence box, §10; recorded as `bake.bbox`). Default: union of the grids' boxes. */\n bbox?: WvdbBox | null;\n /** Override the finest LOD dimensions (default from `resolution` and the box). */\n dimensions?: WvdbVec3;\n /**\n * Grids to keep, by name; also recorded as `bake.grids`. Default null (all).\n */\n gridNames?: string[] | null;\n /**\n * Resampling filter. `\"nearest\"` (default): his point sampling. `\"box\"`: the\n * area-weighted mean over each texel's cell (K4.4's box filter; conserves\n * mass, no aliasing when the source is finer than the texels). Needs a source\n * with `grid` (the built-in sources).\n */\n sampling?: WvdbSampling;\n /**\n * How level sets are sampled. `\"spec\"` (default): `sampling`, then the spec\n * §8 rule by active state. `\"surface-mean\"`: his CLI's `sampleLevelSet`\n * (trilinear near the surface, a 4x4x4 mean in texels that cross it), which\n * reproduces his level-set `.wvdb` files; it ignores `sampling`.\n */\n levelSetSampler?: WvdbLevelSetSampler;\n}\n\n/** Resampling filter of the baker: point sampling (`nearest`) or the area-weighted mean of each texel cell (`box`). */\nexport type WvdbSampling = \"nearest\" | \"box\";\n/** How the baker samples level sets: the spec rule (`spec`) or his CLI sampler (`surface-mean`). */\nexport type WvdbLevelSetSampler = \"spec\" | \"surface-mean\";\n\nfunction unionBox(boxes: WvdbBox[]): WvdbBox | null {\n if (!boxes.length) return null;\n const min = [...boxes[0]![0]] as WvdbVec3;\n const max = [...boxes[0]![1]] as WvdbVec3;\n for (const [lo, hi] of boxes.slice(1)) {\n for (let a = 0; a < 3; a++) {\n min[a] = Math.min(min[a]!, lo[a]!);\n max[a] = Math.max(max[a]!, hi[a]!);\n }\n }\n return [min, max];\n}\n\n/** §3.2.1, his `getFinestDimensions`. */\nexport function wvdbFinestDimensions(bbox: WvdbBox | null, resolution: number): WvdbVec3 {\n const size = bbox ? ([0, 1, 2].map((a) => bbox[1][a]! - bbox[0][a]!) as WvdbVec3) : ([0, 0, 0] as WvdbVec3);\n const longest = Math.max(...size);\n if (!(longest > 0)) return [resolution, resolution, resolution];\n return size.map((side) => Math.max(1, Math.round((side * resolution) / longest))) as WvdbVec3;\n}\n\n/** Point-samples one source over the box (his `forEachTexel` + `sampleScalarGrid`). */\nexport function sampleWvdbDense(\n source: WvdbSampleSource,\n bbox: WvdbBox | null,\n dimensions: WvdbVec3,\n bits: WvdbBits = 8,\n): Float32Array {\n const [w, h, d] = dimensions;\n const values = new Float32Array(w * h * d);\n const background = source.background;\n if (!source.bbox || !bbox) return values.fill(background);\n const min = bbox[0];\n const size = [0, 1, 2].map((a) => bbox[1][a]! - min[a]!);\n const isLevelSet = source.class === \"level set\";\n const band = background - (2 * background) / ((1 << bits) - 1);\n const world: WvdbVec3 = [0, 0, 0];\n let o = 0;\n for (let z = 0; z < d; z++) {\n world[2] = ((z + 0.5) / d) * size[2]! + min[2];\n for (let y = 0; y < h; y++) {\n world[1] = ((y + 0.5) / h) * size[1]! + min[1];\n for (let x = 0; x < w; x++) {\n world[0] = ((x + 0.5) / w) * size[0]! + min[0];\n const { value, active } = source.sample(world);\n let v = Number.isFinite(value) ? value : background;\n if (isLevelSet) v = active ? Math.min(Math.max(v, -band), band) : v < 0 ? -background : background;\n values[o++] = v;\n }\n }\n }\n return values;\n}\n\n/**\n * Box-filters one source over the box (`sampling: 'box'`): `vdbResampleDense` on\n * his lattice, then the level-set rule of {@link sampleWvdbDense} by the\n * filtered active state.\n */\nexport function sampleWvdbDenseBox(\n source: WvdbSampleSource,\n bbox: WvdbBox | null,\n dimensions: WvdbVec3,\n bits: WvdbBits = 8,\n): Float32Array {\n const background = source.background;\n if (!source.bbox || !bbox) return new Float32Array(dimensions[0] * dimensions[1] * dimensions[2]).fill(background);\n if (!source.grid) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: sampling \"box\" needs the source grid; \"${source.name}\" has none (use wvdbSourceFromVdbGrid or wvdbSourceFromNvdb)`);\n }\n const { values, active } = vdbResampleDense(source.grid, { bbox, dimensions, filter: \"box\" });\n if (source.class === \"level set\") {\n const band = background - (2 * background) / ((1 << bits) - 1);\n for (let i = 0; i < values.length; i++) {\n const v = Number.isFinite(values[i]!) ? values[i]! : background;\n values[i] = active[i] ? Math.min(Math.max(v, -band), band) : v < 0 ? -background : background;\n }\n } else {\n for (let i = 0; i < values.length; i++) if (!Number.isFinite(values[i]!)) values[i] = background;\n }\n return values;\n}\n\n/**\n * Bakes sources to a `.wvdb` with his CLI defaults (128, 3 LODs, 8 bits, sparse, 1024 bricks per page).\n * @param sources The grids to bake, point-sampled in world space.\n * @param options Resolution, box, grid names, sampling and the writer's options ({@link BakeWvdbOptions}).\n */\nexport function bakeWvdb(sources: readonly WvdbSampleSource[], options: BakeWvdbOptions = {}): WriteWvdbResult {\n const { grids, write } = bakeWvdbVolumes(sources, options);\n return writeWvdb(grids, write);\n}\n\n/** The volume grids {@link bakeWvdb} writes, and the writer's options (shared with `vdbToWvdb`'s points path). */\nfunction bakeWvdbVolumes(\n sources: readonly WvdbSampleSource[],\n options: BakeWvdbOptions,\n): { grids: WvdbVolumeGridInput[]; write: WriteWvdbOptions } {\n const {\n resolution = 128,\n bbox: bakeBBox = null,\n dimensions,\n gridNames = null,\n sampling = \"nearest\",\n levelSetSampler = \"spec\",\n ...write\n } = options;\n if (sampling !== \"nearest\" && sampling !== \"box\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: unknown sampling \"${String(sampling)}\"`);\n if (levelSetSampler !== \"spec\" && levelSetSampler !== \"surface-mean\") {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: unknown levelSetSampler \"${String(levelSetSampler)}\"`);\n }\n if (!Number.isInteger(resolution) || resolution < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `bakeWvdb: invalid resolution ${resolution}`);\n const selected = gridNames ? sources.filter((s) => gridNames.includes(s.name)) : [...sources];\n const box = bakeBBox ?? unionBox(selected.flatMap((s) => (s.bbox ? [s.bbox] : [])));\n const dims = dimensions ?? wvdbFinestDimensions(box, resolution);\n const bits = write.bits ?? 8;\n const grids: WvdbVolumeGridInput[] = selected.map((s) => ({\n name: s.name,\n class: s.class,\n background: s.background,\n bbox: box,\n finest: {\n dimensions: dims,\n values:\n s.class === \"level set\" && levelSetSampler === \"surface-mean\"\n ? sampleWvdbLevelSetSurfaceMean(s, box, dims, bits)\n : sampling === \"box\"\n ? sampleWvdbDenseBox(s, box, dims, bits)\n : sampleWvdbDense(s, box, dims, bits),\n },\n }));\n return { grids, write: { ...write, resolution, gridNames, bakeBBox } };\n}\n\n// ---------------------------------------------------------------------------\n// Sources\n// ---------------------------------------------------------------------------\n\n/** A parsed `.vdb` grid (axis-aligned map) as a sample source. */\nexport function wvdbSourceFromVdbGrid(grid: VdbGrid): WvdbSampleSource {\n if (grid.valueType !== \"float\") {\n throw new VDBToolsError(\"VDB_UNSUPPORTED_GRID_TYPE\", \n `wvdbSourceFromVdbGrid: grid \"${grid.name}\" is a ${grid.valueType} grid; only float grids can be baked ` +\n `(vdbToWvdb skips the others)`,\n );\n }\n const m = grid.transform.matrix;\n if (m[1] !== 0 || m[2] !== 0 || m[4] !== 0 || m[6] !== 0 || m[8] !== 0 || m[9] !== 0) {\n throw new VDBUnsupportedError(`wvdbSourceFromVdbGrid: grid \"${grid.name}\" has a rotated map; only axis-aligned maps are supported`);\n }\n const scale = [m[0]!, m[5]!, m[10]!];\n const translation = [m[3]!, m[7]!, m[11]!];\n const inverse = scale.map((s) => 1 / s);\n const lo = [Infinity, Infinity, Infinity];\n const hi = [-Infinity, -Infinity, -Infinity];\n for (const leaf of grid.iterLeaves()) {\n for (let offset = 0; offset < 512; offset++) {\n if (((leaf.valueMask[offset >>> 5]! >>> (offset & 31)) & 1) === 0) continue;\n const ijk = [leaf.origin[0] + (offset >> 6), leaf.origin[1] + ((offset >> 3) & 7), leaf.origin[2] + (offset & 7)];\n for (let a = 0; a < 3; a++) {\n lo[a] = Math.min(lo[a]!, ijk[a]!);\n hi[a] = Math.max(hi[a]!, ijk[a]!);\n }\n }\n }\n let bbox: WvdbBox | null = null;\n if (lo[0]! <= hi[0]!) {\n const a = [0, 1, 2].map((i) => lo[i]! * scale[i]! + translation[i]!);\n const b = [0, 1, 2].map((i) => hi[i]! * scale[i]! + translation[i]!);\n bbox = [a.map((v, i) => Math.min(v, b[i]!)) as WvdbVec3, a.map((v, i) => Math.max(v, b[i]!)) as WvdbVec3];\n }\n const cls = grid.metadata[\"class\"];\n const ijk: [number, number, number] = [0, 0, 0];\n return {\n name: grid.name,\n class: typeof cls === \"string\" ? cls : \"unknown\",\n background: grid.background,\n bbox,\n sample(world) {\n for (let a = 0; a < 3; a++) ijk[a] = Math.round((world[a]! - translation[a]!) * inverse[a]!);\n return grid.readValue(ijk);\n },\n index: {\n // His GridTransform scale-translate maps: (v - translation) * scaleInverse.\n toIndex(world, out) {\n for (let a = 0; a < 3; a++) out[a] = (world[a]! - translation[a]!) * inverse[a]!;\n return out;\n },\n toIndexVector(v, out) {\n for (let a = 0; a < 3; a++) out[a] = v[a]! * inverse[a]!;\n return out;\n },\n voxel: (p) => grid.readValue(p),\n },\n grid,\n };\n}\n\nconst NANO_CLASS: Record<number, string> = { 1: \"level set\", 2: \"fog volume\", 3: \"staggered\" };\n\n/** A NanoVDB FLOAT/Fp8/FpN grid image as a sample source, read through the CPU oracle (`readValue`). */\nexport function wvdbSourceFromNvdb(gridWords: Uint32Array): WvdbSampleSource {\n const view = new DataView(gridWords.buffer, gridWords.byteOffset, gridWords.byteLength);\n const nameBytes = new Uint8Array(gridWords.buffer, gridWords.byteOffset + GRID_OFF_GRID_NAME, GRID_NAME_MAX);\n const nul = nameBytes.indexOf(0);\n const name = new TextDecoder().decode(nameBytes.subarray(0, nul < 0 ? GRID_NAME_MAX : nul));\n const gridType = view.getUint32(GRID_OFF_GRID_TYPE, true);\n const cls = NANO_CLASS[view.getUint32(GRID_OFF_GRID_CLASS, true)] ?? \"unknown\";\n const mat = Array.from({ length: 9 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_MATD + i * 8, true));\n const inv = Array.from({ length: 9 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_INVMATD + i * 8, true));\n const vec = Array.from({ length: 3 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_VECD + i * 8, true));\n const root = GRID_SIZE + Number(view.getBigUint64(GRID_SIZE + TREE_OFF_NODE_OFFSET_ROOT, true));\n const lo = [0, 1, 2].map((i) => view.getInt32(root + ROOT_OFF_BBOX_MIN + i * 4, true));\n const hi = [0, 1, 2].map((i) => view.getInt32(root + ROOT_OFF_BBOX_MAX + i * 4, true));\n const background = view.getFloat32(root + gridTypeConstantsForId(gridType).root_off_background, true);\n\n const toWorld = (p: number[]): number[] =>\n [0, 1, 2].map((r) => mat[r * 3]! * p[0]! + mat[r * 3 + 1]! * p[1]! + mat[r * 3 + 2]! * p[2]! + vec[r]!);\n let bbox: WvdbBox | null = null;\n if (lo[0]! <= hi[0]! && lo[1]! <= hi[1]! && lo[2]! <= hi[2]!) {\n const min = [Infinity, Infinity, Infinity];\n const max = [-Infinity, -Infinity, -Infinity];\n for (let c = 0; c < 8; c++) {\n const w = toWorld([c & 1 ? hi[0]! : lo[0]!, c & 2 ? hi[1]! : lo[1]!, c & 4 ? hi[2]! : lo[2]!]);\n for (let a = 0; a < 3; a++) {\n min[a] = Math.min(min[a]!, w[a]!);\n max[a] = Math.max(max[a]!, w[a]!);\n }\n }\n bbox = [min as WvdbVec3, max as WvdbVec3];\n }\n const ijk: [number, number, number] = [0, 0, 0];\n return {\n name,\n class: cls,\n background,\n bbox,\n sample(world) {\n const p = [world[0] - vec[0]!, world[1] - vec[1]!, world[2] - vec[2]!];\n for (let r = 0; r < 3; r++) ijk[r] = Math.round(inv[r * 3]! * p[0]! + inv[r * 3 + 1]! * p[1]! + inv[r * 3 + 2]! * p[2]!);\n return vdbReadValueCpu(gridWords, ijk);\n },\n index: {\n toIndex(world, out) {\n const p0 = world[0] - vec[0]!;\n const p1 = world[1] - vec[1]!;\n const p2 = world[2] - vec[2]!;\n for (let r = 0; r < 3; r++) out[r] = inv[r * 3]! * p0 + inv[r * 3 + 1]! * p1 + inv[r * 3 + 2]! * p2;\n return out;\n },\n toIndexVector(v, out) {\n const [v0, v1, v2] = v;\n for (let r = 0; r < 3; r++) out[r] = inv[r * 3]! * v0 + inv[r * 3 + 1]! * v1 + inv[r * 3 + 2]! * v2;\n return out;\n },\n voxel: (p) => vdbReadValueCpu(gridWords, p),\n },\n grid: gridWords,\n };\n}\n\n/** Options of {@link vdbToWvdb}: the baker's options plus the source file name. */\nexport interface VdbToWvdbOptions extends BakeWvdbOptions {\n /** `source.file` (the name without directories). Default \"\". */\n fileName?: string;\n}\n\n/**\n * A parsed point data grid as a `.wvdb` points grid (G14b, his `encodePointGrid`): world positions and `Cd` in\n * the grid's point order, every n-th point above `maxPoints` (`vdbPointRenderData`'s stride rule, his\n * `createPointData`), the source count and his spacing. `writeWvdb` then splits it into LODs (§3.5).\n *\n * @param grid A point data grid from `parseVdb`.\n * @param maxPoints Keep every `ceil(total / maxPoints)`-th point above this many (default 4,000,000).\n */\nexport function wvdbPointsFromVdbGrid(grid: VdbPointDataGrid, maxPoints?: number): WvdbPointsGridInput {\n const data = vdbPointRenderData(grid, maxPoints === undefined ? {} : { maxPoints });\n const cls = grid.metadata[\"class\"];\n return {\n type: \"points\",\n name: grid.name,\n class: typeof cls === \"string\" ? cls : \"unknown\",\n positions: data.positions,\n colors: data.colors,\n sourceCount: data.totalCount,\n spacing: data.spacing,\n };\n}\n\n/**\n * `.vdb` → `.wvdb`, like his `wvdb` CLI with the same options. Given the file\n * bytes, `source.sha256` is their digest. Float grids are baked as volumes and\n * point data grids as points grids (G14b: positions and `Cd`, every n-th point\n * above `maxPoints`, the §3.5 LOD order), in file order; the volume box ignores\n * the points (his `getWVDBBox`). Vector grids are skipped (his CLI bakes them as\n * 3 channels; not ported).\n * @param input The `.vdb` file's bytes, or an already parsed {@link VdbFile}.\n * @param options Baker options and the `source.file` name.\n * @throws VDBToolsError `VDB_UNSUPPORTED_GRID_TYPE` when the file has no float or point data grids.\n */\nexport function vdbToWvdb(input: ArrayBuffer | Uint8Array | VdbFile, options: VdbToWvdbOptions = {}): WriteWvdbResult {\n const { fileName = \"\", ...bake } = options;\n let file: VdbFile;\n let source: WvdbSource | undefined = bake.source;\n if (input instanceof ArrayBuffer || input instanceof Uint8Array) {\n const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);\n const buffer = bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength && bytes.buffer instanceof ArrayBuffer\n ? bytes.buffer\n : bytes.slice().buffer;\n file = parseVdb(buffer);\n source ??= { file: fileName, sha256: sha256Hex(bytes) };\n } else {\n file = input;\n }\n // His getBakedGrids: the selected scalar and point data grids, in file order.\n const names = bake.gridNames ?? null;\n const baked = file.grids.filter((g) => (g.valueType === \"float\" || g.valueType === \"ptdataidx32\") && (!names || names.includes(g.name)));\n if (!file.grids.some((g) => g.valueType === \"float\" || g.valueType === \"ptdataidx32\")) {\n throw new VDBToolsError(\"VDB_UNSUPPORTED_GRID_TYPE\", \"vdbToWvdb: the file has no float or point data grids to bake\");\n }\n const options2 = { ...bake, ...(source ? { source } : {}) };\n if (!baked.some((g) => g.valueType === \"ptdataidx32\")) return bakeWvdb(file.grids.filter((g) => g.valueType === \"float\").map(wvdbSourceFromVdbGrid), options2);\n const floats = baked.filter((g) => g.valueType === \"float\");\n const { grids: volumes, write } = bakeWvdbVolumes(floats.map(wvdbSourceFromVdbGrid), options2);\n const grids: WvdbGridInput[] = baked.map((g) =>\n g.valueType === \"float\" ? volumes[floats.indexOf(g)]! : wvdbPointsFromVdbGrid(g as VdbPointDataGrid, bake.maxPoints),\n );\n return writeWvdb(grids, write);\n}\n\n/**\n * NanoVDB grid image(s) → `.wvdb`, sampled through the CPU oracle.\n * @param images One grid image or several.\n * @param options Baker options.\n */\nexport function nvdbToWvdb(images: Uint32Array | readonly Uint32Array[], options: BakeWvdbOptions = {}): WriteWvdbResult {\n const list = images instanceof Uint32Array ? [images] : images;\n return bakeWvdb(list.map(wvdbSourceFromNvdb), options);\n}\n"]}
@@ -4,41 +4,82 @@ import type { WvdbFile, WvdbVolumeGrid, WvdbVolumeLevel } from "./read.js";
4
4
  export interface WvdbDenseTexture {
5
5
  /** 1 byte per texel (`r8unorm`) or 4 (`rgba8unorm`). */
6
6
  readonly data: Uint8Array<ArrayBuffer>;
7
+ /** Texels per axis. */
7
8
  readonly dimensions: WvdbVec3;
9
+ /** The WebGPU texture format the bytes are laid out for. */
8
10
  readonly format: "r8unorm" | "rgba8unorm";
9
11
  /** Bytes per texel (1 or 4). */
10
12
  readonly texelBytes: 1 | 4;
11
13
  /** CPU box mip atlas (levels 1..`levels` side by side on x), or null without mipmaps. */
12
14
  readonly mip: WvdbMipAtlas | null;
15
+ /**
16
+ * K4.22: a partially streamed LOD's bricks to fill from a coarser LOD (`wvdbDensePartialVolume` with
17
+ * `fill: 'upsample'`), or absent / null. `data` and `mip` then hold the background in those bricks; the core's
18
+ * dense source fills them on the GPU, `wvdbDenseResolve` on the CPU.
19
+ */
20
+ readonly fill?: WvdbDenseFill | null;
21
+ }
22
+ /**
23
+ * K4.22: the bricks of a partially streamed LOD that are stored but not decoded yet, and the coarser LOD's texels
24
+ * to fill them with (his `wvdbKernel` upsample: trilinear, texel centres aligned, edges clamped).
25
+ */
26
+ export interface WvdbDenseFill {
27
+ /** One bit per brick of the texture (brick index x fastest; word `index >> 5`, bit `index & 31`). */
28
+ readonly pending: Uint32Array;
29
+ /** Bricks set in `pending`. */
30
+ readonly count: number;
31
+ /** The coarser LOD's texels in the texture's format (a complete LOD), and their size. */
32
+ readonly from: {
33
+ readonly data: Uint8Array<ArrayBuffer>;
34
+ readonly dimensions: WvdbVec3;
35
+ };
36
+ /**
37
+ * The mip atlas of the filled texture: `'box'` builds every level from the filled texels (his frameMipmaps);
38
+ * `'coarse'` takes level 1 of the pending bricks from the coarser LOD itself (the LOD a `.wvdb` bake makes by a
39
+ * 2x box filter of this one), when its size is level 1's, so a far view of a pending brick is the coarser LOD,
40
+ * not a blur of its upsample. Default `'coarse'`.
41
+ */
42
+ readonly mips?: "coarse" | "box";
13
43
  }
14
44
  /** His `packAtlas` output (frameMipmaps.js L65–88). */
15
45
  export interface WvdbMipAtlas {
46
+ /** The atlas texels, x fastest. */
16
47
  readonly data: Uint8Array<ArrayBuffer>;
48
+ /** Atlas size in texels per axis. */
17
49
  readonly dimensions: WvdbVec3;
18
50
  /** Levels in the atlas (level 0 is the texture itself). */
19
51
  readonly levels: number;
20
52
  }
21
53
  /** Density statistics as his `getDensityStats` (FrameVolume.js L50–62): sum of non-zero texels / 255, and their count. */
22
54
  export interface WvdbTexelStats {
55
+ /** Sum of the non-zero texels, each divided by 255. */
23
56
  readonly sum: number;
57
+ /** Number of non-zero texels. */
24
58
  readonly count: number;
25
59
  }
26
60
  /** A `.wvdb` LOD as the dense textures his renderer uploads (R1 §4.2 `vdbDenseSource` input). */
27
61
  export interface WvdbDenseVolume {
62
+ /** Discriminant: a dense (texture) volume. */
28
63
  readonly kind: "dense";
29
64
  /** The only dense normalization: 8-bit, `clamp(value / scale, 0, 1)` (R1 §4.3). */
30
65
  readonly normalize: "clamp01";
66
+ /** The LOD these textures were built from (0 is the coarsest). */
31
67
  readonly lod: number;
32
68
  /** Texels of the density texture; aux textures have the same size. */
33
69
  readonly dimensions: WvdbVec3;
34
70
  /** World box of the density grid (`grid.bbox`), or null for an empty grid. */
35
71
  readonly bbox: WvdbBox | null;
72
+ /** The density texture (R8). */
36
73
  readonly density: WvdbDenseTexture;
74
+ /** The mask texture (R8), or null without a mask grid. */
37
75
  readonly mask: WvdbDenseTexture | null;
76
+ /** The albedo texture (RGBA8), or null without an albedo grid. */
38
77
  readonly albedo: WvdbDenseTexture | null;
78
+ /** The emission texture (R8), or null without an emission grid. */
39
79
  readonly emission: WvdbDenseTexture | null;
40
80
  /** The stats his volume ends up with: baked (header) when present and the scale is 1, else from the texels. */
41
81
  readonly densityStats: WvdbTexelStats;
82
+ /** Where `densityStats` came from: the file header (`baked`) or the texels. */
42
83
  readonly densityStatsSource: "baked" | "texels";
43
84
  /** `getMeanDensity` of the one volume: `sum / count`, 0 when empty. */
44
85
  readonly meanDensity: number;
@@ -46,6 +87,7 @@ export interface WvdbDenseVolume {
46
87
  readonly maxDensity: number;
47
88
  /** Non-zero density texels. */
48
89
  readonly activeTexels: number;
90
+ /** The names of the `.wvdb` grids each texture was read from. */
49
91
  readonly gridNames: {
50
92
  readonly density: string;
51
93
  readonly mask?: string;
@@ -53,6 +95,7 @@ export interface WvdbDenseVolume {
53
95
  readonly emission?: string;
54
96
  };
55
97
  }
98
+ /** Options of {@link wvdbDenseVolume}: which grids fill which channel, the LOD, scales and mipmaps. */
56
99
  export interface WvdbDenseOptions {
57
100
  /** Density grid. Default: the grid named `density`, else the first volume grid (his frame.js L519). */
58
101
  density?: string;
@@ -85,20 +128,56 @@ export declare function wvdbTexelStats(data: Uint8Array): WvdbTexelStats;
85
128
  export declare const wvdbMipLevelSize: (size: number, level: number) => number;
86
129
  /** frameMipmaps.js L16–17 `getMipLevelCount`. */
87
130
  export declare const wvdbMipLevelCount: (width: number, height: number, depth: number) => number;
131
+ /**
132
+ * The mip atlas size and level count `wvdbMipAtlas` gives for a texture of `dimensions`, without building it
133
+ * (null when the texture has one texel on every side).
134
+ */
135
+ export declare function wvdbMipAtlasLayout(dimensions: readonly number[]): {
136
+ dimensions: WvdbVec3;
137
+ levels: number;
138
+ } | null;
88
139
  /**
89
140
  * frameMipmaps.js L90–106 `buildAtlas` + L65–88 `packAtlas`: levels 1..n (n =
90
141
  * `ceil(log2(max side))`), level l at x = atlasWidth − atlasWidth / 2^(l−1);
91
142
  * atlas width 2^max(ceil(log2 width), n), height and depth those of level 1.
92
143
  * Null when the texture has one texel on every side.
93
144
  */
94
- export declare function wvdbMipAtlas(data: Uint8Array<ArrayBuffer>, dimensions: readonly number[], channels: 1 | 4): WvdbMipAtlas | null;
145
+ export declare function wvdbMipAtlas(data: Uint8Array<ArrayBuffer>, dimensions: readonly number[], channels: 1 | 4,
146
+ /** K4.22: edits level 1 (texels x fastest) before the higher levels are built from it. */
147
+ editLevel1?: (level: {
148
+ data: Uint8Array<ArrayBuffer>;
149
+ width: number;
150
+ height: number;
151
+ depth: number;
152
+ }) => void): WvdbMipAtlas | null;
153
+ /**
154
+ * K4.22: a texture whose `fill` bricks are still background. Its mip atlas is built on first read of `mip.data`
155
+ * (from the background-filled texels): the core's dense source builds the filled atlas on the GPU and never reads it.
156
+ */
157
+ export declare function wvdbDenseFillTexture(data: Uint8Array<ArrayBuffer>, dimensions: WvdbVec3, texelBytes: 1 | 4, mipmaps: boolean, fill: WvdbDenseFill | null): WvdbDenseTexture;
158
+ /** @internal How {@link wvdbDenseAssemble} reads each grid's level and makes its texture (K4.22: partial LODs). */
159
+ export interface WvdbDenseAssembly {
160
+ /** The level of `grid` to upload. */
161
+ level(grid: WvdbVolumeGrid, role: string): WvdbVolumeLevel;
162
+ /** The texture of `grid` from its texels (default: {@link denseTexture} with a CPU atlas). */
163
+ texture?(grid: WvdbVolumeGrid, level: WvdbVolumeLevel, data: Uint8Array<ArrayBuffer>, texelBytes: 1 | 4, mipmaps: boolean, scale: number): WvdbDenseTexture;
164
+ }
95
165
  /**
96
166
  * Builds the dense textures his renderer would upload for one LOD of a decoded
97
167
  * `.wvdb` file: density (R8), optional mask (R8), albedo (RGBA8) and emission
98
168
  * (R8), each with its CPU box mip atlas, plus the density stats his volume uses
99
169
  * for `normalizeDensity` (`meanDensity`).
170
+ * @param file A decoded `.wvdb` ({@link readWvdb}) with the LOD's levels.
171
+ * @param o Which grids to read, the LOD, scales and mipmaps.
100
172
  */
101
173
  export declare function wvdbDenseVolume(file: WvdbFile, o?: WvdbDenseOptions): WvdbDenseVolume;
174
+ /** @internal The density grid {@link wvdbDenseVolume} reads (`o.density`, else `density`, else the first volume grid). */
175
+ export declare function wvdbDenseDensityGrid(file: WvdbFile, o: Pick<WvdbDenseOptions, "density">): WvdbVolumeGrid;
176
+ /**
177
+ * @internal {@link wvdbDenseVolume}'s assembly from one level per grid (`how.level`): texels, aux channels, stats.
178
+ * K4.22's partial volumes pass the stream event's levels and textures with a `fill`.
179
+ */
180
+ export declare function wvdbDenseAssemble(file: WvdbFile, o: WvdbDenseOptions, lod: number, how: WvdbDenseAssembly): WvdbDenseVolume;
102
181
  /** FrameVolume.js L561–568 `getDensityScale`: `densityScale / meanDensity` with `normalizeDensity`. */
103
182
  export declare function wvdbDensityScale(volume: Pick<WvdbDenseVolume, "meanDensity">, densityScale?: number, normalizeDensity?: boolean): number;
104
183
  /**
@@ -111,13 +111,26 @@ function downsample(source, width, height, depth, channels) {
111
111
  }
112
112
  return { data: target, width: tw, height: th, depth: td };
113
113
  }
114
+ /**
115
+ * The mip atlas size and level count `wvdbMipAtlas` gives for a texture of `dimensions`, without building it
116
+ * (null when the texture has one texel on every side).
117
+ */
118
+ export function wvdbMipAtlasLayout(dimensions) {
119
+ const [width, height, depth] = dimensions;
120
+ const levels = wvdbMipLevelCount(width, height, depth);
121
+ if (levels < 1)
122
+ return null;
123
+ return { dimensions: [2 ** Math.max(Math.ceil(Math.log2(width)), levels), wvdbMipLevelSize(height, 1), wvdbMipLevelSize(depth, 1)], levels };
124
+ }
114
125
  /**
115
126
  * frameMipmaps.js L90–106 `buildAtlas` + L65–88 `packAtlas`: levels 1..n (n =
116
127
  * `ceil(log2(max side))`), level l at x = atlasWidth − atlasWidth / 2^(l−1);
117
128
  * atlas width 2^max(ceil(log2 width), n), height and depth those of level 1.
118
129
  * Null when the texture has one texel on every side.
119
130
  */
120
- export function wvdbMipAtlas(data, dimensions, channels) {
131
+ export function wvdbMipAtlas(data, dimensions, channels,
132
+ /** K4.22: edits level 1 (texels x fastest) before the higher levels are built from it. */
133
+ editLevel1) {
121
134
  const [width, height, depth] = dimensions;
122
135
  const count = wvdbMipLevelCount(width, height, depth);
123
136
  if (count < 1)
@@ -126,6 +139,8 @@ export function wvdbMipAtlas(data, dimensions, channels) {
126
139
  let level = { data, width, height, depth };
127
140
  for (let index = 1; index <= count; index++) {
128
141
  level = downsample(level.data, level.width, level.height, level.depth, channels);
142
+ if (index === 1)
143
+ editLevel1?.(level);
129
144
  levels.push(level);
130
145
  }
131
146
  const atlasWidth = 2 ** Math.max(Math.ceil(Math.log2(width)), levels.length);
@@ -153,6 +168,26 @@ function denseTexture(data, dimensions, texelBytes, mipmaps) {
153
168
  mip: mipmaps ? wvdbMipAtlas(data, dimensions, texelBytes) : null,
154
169
  };
155
170
  }
171
+ /**
172
+ * K4.22: a texture whose `fill` bricks are still background. Its mip atlas is built on first read of `mip.data`
173
+ * (from the background-filled texels): the core's dense source builds the filled atlas on the GPU and never reads it.
174
+ */
175
+ export function wvdbDenseFillTexture(data, dimensions, texelBytes, mipmaps, fill) {
176
+ if (!fill)
177
+ return denseTexture(data, dimensions, texelBytes, mipmaps);
178
+ const layout = mipmaps ? wvdbMipAtlasLayout(dimensions) : null;
179
+ let atlas = null;
180
+ const mip = layout
181
+ ? {
182
+ get data() {
183
+ return (atlas ??= wvdbMipAtlas(data, dimensions, texelBytes).data);
184
+ },
185
+ dimensions: layout.dimensions,
186
+ levels: layout.levels,
187
+ }
188
+ : null;
189
+ return { data, dimensions, format: texelBytes === 4 ? "rgba8unorm" : "r8unorm", texelBytes, mip, fill };
190
+ }
156
191
  function volumeGrid(file, name, role) {
157
192
  const grid = file.grids.find((g) => g.name === name);
158
193
  if (!grid)
@@ -173,8 +208,18 @@ function levelOf(grid, lod) {
173
208
  * `.wvdb` file: density (R8), optional mask (R8), albedo (RGBA8) and emission
174
209
  * (R8), each with its CPU box mip atlas, plus the density stats his volume uses
175
210
  * for `normalizeDensity` (`meanDensity`).
211
+ * @param file A decoded `.wvdb` ({@link readWvdb}) with the LOD's levels.
212
+ * @param o Which grids to read, the LOD, scales and mipmaps.
176
213
  */
177
214
  export function wvdbDenseVolume(file, o = {}) {
215
+ const density = wvdbDenseDensityGrid(file, o);
216
+ const lod = o.lod ?? density.levels.length - 1;
217
+ if (!Number.isInteger(lod) || lod < 0)
218
+ throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: lod must be a non-negative integer, got ${o.lod}`);
219
+ return wvdbDenseAssemble(file, o, lod, { level: (grid) => levelOf(grid, lod) });
220
+ }
221
+ /** @internal The density grid {@link wvdbDenseVolume} reads (`o.density`, else `density`, else the first volume grid). */
222
+ export function wvdbDenseDensityGrid(file, o) {
178
223
  const volumeGrids = file.grids.filter((g) => g.kind === "volume");
179
224
  const densityName = o.density ?? (file.grids.find((g) => g.name === "density" && g.kind === "volume") ?? volumeGrids[0])?.name;
180
225
  if (densityName === undefined)
@@ -182,15 +227,22 @@ export function wvdbDenseVolume(file, o = {}) {
182
227
  const density = volumeGrid(file, densityName, "density");
183
228
  if (density.channels !== 1)
184
229
  throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: density grid "${densityName}" has 3 channels; pass a scalar grid`);
185
- const lod = o.lod ?? density.levels.length - 1;
186
- if (!Number.isInteger(lod) || lod < 0)
187
- throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: lod must be a non-negative integer, got ${o.lod}`);
230
+ return density;
231
+ }
232
+ /**
233
+ * @internal {@link wvdbDenseVolume}'s assembly from one level per grid (`how.level`): texels, aux channels, stats.
234
+ * K4.22's partial volumes pass the stream event's levels and textures with a `fill`.
235
+ */
236
+ export function wvdbDenseAssemble(file, o, lod, how) {
237
+ const density = wvdbDenseDensityGrid(file, o);
238
+ const densityName = density.name;
188
239
  const mipmaps = o.mipmaps ?? true;
189
240
  // WVDBReader.js L494: scales[name] || 1.0
190
241
  const scaleOf = (name) => o.scales?.[name] || 1.0;
191
- const level = levelOf(density, lod);
242
+ const level = how.level(density, "density");
192
243
  const dimensions = [...level.dimensions];
193
244
  const densityData = wvdbTexels(density, level, scaleOf(densityName));
245
+ const makeTexture = (grid, l, data, texelBytes) => how.texture ? how.texture(grid, l, data, texelBytes, mipmaps, scaleOf(grid.name)) : denseTexture(data, dimensions, texelBytes, mipmaps);
194
246
  const aux = (name, role) => {
195
247
  if (name === undefined)
196
248
  return null;
@@ -198,14 +250,14 @@ export function wvdbDenseVolume(file, o = {}) {
198
250
  const want = role === "albedo" ? 3 : 1;
199
251
  if (grid.channels !== want)
200
252
  throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: ${role} grid "${name}" has ${grid.channels} channel(s), expected ${want}`);
201
- const auxLevel = levelOf(grid, lod);
253
+ const auxLevel = how.level(grid, role);
202
254
  if (auxLevel.dimensions.some((v, a) => v !== dimensions[a])) {
203
255
  // FrameVolume.js L357–405: raw aux grids are uploaded at the density grid's dimensions.
204
256
  throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: ${role} grid "${name}" LOD ${lod} is ${auxLevel.dimensions.join("x")}, density is ${dimensions.join("x")}; ` +
205
257
  "his renderer uploads aux grids at the density size, so they must match");
206
258
  }
207
259
  const data = wvdbTexels(grid, auxLevel, scaleOf(name));
208
- return denseTexture(data, dimensions, role === "albedo" ? 4 : 1, mipmaps);
260
+ return makeTexture(grid, auxLevel, data, role === "albedo" ? 4 : 1);
209
261
  };
210
262
  // WVDBReader.js L519–523 + WVDBLoader.js L147–152: baked stats when the header has
211
263
  // meanDensity and the scale is 1; else WVDBLoader.js L196–198 getDensityStats(data).
@@ -222,13 +274,20 @@ export function wvdbDenseVolume(file, o = {}) {
222
274
  if (v > 0)
223
275
  active++;
224
276
  }
277
+ const densityTexture = makeTexture(density, level, densityData, 1);
278
+ // K4.22: upsampled texels lie between coarse texels, so the coarse LOD's largest bounds them (vdbSrcMaxIn).
279
+ const from = densityTexture.fill?.from.data;
280
+ if (from)
281
+ for (let i = 0; i < from.length; i++)
282
+ if (from[i] > max)
283
+ max = from[i];
225
284
  return {
226
285
  kind: "dense",
227
286
  normalize: "clamp01",
228
287
  lod,
229
288
  dimensions,
230
289
  bbox: density.bbox,
231
- density: denseTexture(densityData, dimensions, 1, mipmaps),
290
+ density: densityTexture,
232
291
  mask: aux(o.mask, "mask"),
233
292
  albedo: aux(o.albedo, "albedo"),
234
293
  emission: aux(o.emission, "emission"),