@pmndrs/vdb 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (576) hide show
  1. package/CHANGELOG.md +592 -2
  2. package/README.md +85 -37
  3. package/THIRD_PARTY_NOTICES.md +197 -29
  4. package/dist/core/compute/atlas.d.ts +10 -2
  5. package/dist/core/compute/atlas.js +6 -1
  6. package/dist/core/compute/atlas.js.map +1 -1
  7. package/dist/core/compute/index.d.ts +3 -3
  8. package/dist/core/compute/index.js +2 -2
  9. package/dist/core/compute/index.js.map +1 -1
  10. package/dist/core/compute/majorant-build.d.ts +45 -0
  11. package/dist/core/compute/majorant-build.js +193 -0
  12. package/dist/core/compute/majorant-build.js.map +1 -0
  13. package/dist/core/compute/multi-scale.d.ts +155 -0
  14. package/dist/core/compute/multi-scale.js +684 -0
  15. package/dist/core/compute/multi-scale.js.map +1 -0
  16. package/dist/core/compute/pyramid.d.ts +22 -7
  17. package/dist/core/compute/pyramid.js +22 -9
  18. package/dist/core/compute/pyramid.js.map +1 -1
  19. package/dist/core/compute/shared.d.ts +1 -0
  20. package/dist/core/compute/shared.js.map +1 -1
  21. package/dist/core/compute/stats.d.ts +10 -3
  22. package/dist/core/compute/stats.js +6 -1
  23. package/dist/core/compute/stats.js.map +1 -1
  24. package/dist/core/compute/value-transform.d.ts +8 -1
  25. package/dist/core/compute/value-transform.js +9 -3
  26. package/dist/core/compute/value-transform.js.map +1 -1
  27. package/dist/core/errors.d.ts +10 -0
  28. package/dist/core/errors.js +8 -0
  29. package/dist/core/errors.js.map +1 -1
  30. package/dist/core/frame/emission.d.ts +85 -0
  31. package/dist/core/frame/emission.js +422 -0
  32. package/dist/core/frame/emission.js.map +1 -0
  33. package/dist/core/frame/environment.d.ts +47 -0
  34. package/dist/core/frame/environment.js +178 -0
  35. package/dist/core/frame/environment.js.map +1 -0
  36. package/dist/core/frame/index.d.ts +39 -0
  37. package/dist/core/frame/index.js +27 -0
  38. package/dist/core/frame/index.js.map +1 -0
  39. package/dist/core/frame/kernels.d.ts +115 -0
  40. package/dist/core/frame/kernels.js +496 -0
  41. package/dist/core/frame/kernels.js.map +1 -0
  42. package/dist/core/frame/limits.d.ts +67 -0
  43. package/dist/core/frame/limits.js +109 -0
  44. package/dist/core/frame/limits.js.map +1 -0
  45. package/dist/core/frame/phase.d.ts +17 -0
  46. package/dist/core/frame/phase.js +53 -0
  47. package/dist/core/frame/phase.js.map +1 -0
  48. package/dist/core/frame/pipelines.d.ts +49 -0
  49. package/dist/core/frame/pipelines.js +147 -0
  50. package/dist/core/frame/pipelines.js.map +1 -0
  51. package/dist/core/frame/renderer.d.ts +122 -0
  52. package/dist/core/frame/renderer.js +1712 -0
  53. package/dist/core/frame/renderer.js.map +1 -0
  54. package/dist/core/frame/resources.d.ts +71 -0
  55. package/dist/core/frame/resources.js +100 -0
  56. package/dist/core/frame/resources.js.map +1 -0
  57. package/dist/core/frame/scattering.d.ts +97 -0
  58. package/dist/core/frame/scattering.js +332 -0
  59. package/dist/core/frame/scattering.js.map +1 -0
  60. package/dist/core/frame/settings.d.ts +243 -0
  61. package/dist/core/frame/settings.js +67 -0
  62. package/dist/core/frame/settings.js.map +1 -0
  63. package/dist/core/frame/shadows.d.ts +55 -0
  64. package/dist/core/frame/shadows.js +460 -0
  65. package/dist/core/frame/shadows.js.map +1 -0
  66. package/dist/core/frame/types.d.ts +415 -0
  67. package/dist/core/frame/types.js +49 -0
  68. package/dist/core/frame/types.js.map +1 -0
  69. package/dist/core/frame/uniforms.d.ts +105 -0
  70. package/dist/core/frame/uniforms.js +276 -0
  71. package/dist/core/frame/uniforms.js.map +1 -0
  72. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  73. package/dist/core/frame/wgsl/chunks.js +728 -0
  74. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  75. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  76. package/dist/core/frame/wgsl/emission.js +353 -0
  77. package/dist/core/frame/wgsl/emission.js.map +1 -0
  78. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  79. package/dist/core/frame/wgsl/environment.js +711 -0
  80. package/dist/core/frame/wgsl/environment.js.map +1 -0
  81. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  82. package/dist/core/frame/wgsl/gather.js +850 -0
  83. package/dist/core/frame/wgsl/gather.js.map +1 -0
  84. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  85. package/dist/core/frame/wgsl/integrate.js +213 -0
  86. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  87. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  88. package/dist/core/frame/wgsl/lighting.js +1636 -0
  89. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  90. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  91. package/dist/core/frame/wgsl/occluders.js +95 -0
  92. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  93. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  94. package/dist/core/frame/wgsl/resolve.js +205 -0
  95. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  96. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  97. package/dist/core/frame/wgsl/shadows.js +328 -0
  98. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  99. package/dist/core/half.d.ts +11 -0
  100. package/dist/core/half.js +22 -0
  101. package/dist/core/half.js.map +1 -0
  102. package/dist/core/index.d.ts +25 -3
  103. package/dist/core/index.js +23 -4
  104. package/dist/core/index.js.map +1 -1
  105. package/dist/core/internal.d.ts +17 -1
  106. package/dist/core/internal.js +18 -1
  107. package/dist/core/internal.js.map +1 -1
  108. package/dist/core/pool/image-header.d.ts +13 -2
  109. package/dist/core/pool/image-header.js +24 -5
  110. package/dist/core/pool/image-header.js.map +1 -1
  111. package/dist/core/pool/layout.d.ts +35 -1
  112. package/dist/core/pool/layout.js +51 -2
  113. package/dist/core/pool/layout.js.map +1 -1
  114. package/dist/core/pool/limits.d.ts +1 -0
  115. package/dist/core/pool/limits.js +1 -0
  116. package/dist/core/pool/limits.js.map +1 -1
  117. package/dist/core/pool/pool.d.ts +120 -15
  118. package/dist/core/pool/pool.js +255 -24
  119. package/dist/core/pool/pool.js.map +1 -1
  120. package/dist/core/reference/index.d.ts +6 -0
  121. package/dist/core/reference/index.js +7 -0
  122. package/dist/core/reference/index.js.map +1 -0
  123. package/dist/core/reference/renderer.d.ts +105 -0
  124. package/dist/core/reference/renderer.js +474 -0
  125. package/dist/core/reference/renderer.js.map +1 -0
  126. package/dist/core/reference/wgsl.d.ts +65 -0
  127. package/dist/core/reference/wgsl.js +803 -0
  128. package/dist/core/reference/wgsl.js.map +1 -0
  129. package/dist/{three → core}/sequence.d.ts +32 -2
  130. package/dist/{three → core}/sequence.js +24 -2
  131. package/dist/core/sequence.js.map +1 -0
  132. package/dist/core/source/brick-cache.d.ts +165 -0
  133. package/dist/core/source/brick-cache.js +627 -0
  134. package/dist/core/source/brick-cache.js.map +1 -0
  135. package/dist/core/source/dense-fill.d.ts +53 -0
  136. package/dist/core/source/dense-fill.js +377 -0
  137. package/dist/core/source/dense-fill.js.map +1 -0
  138. package/dist/core/source/dense.d.ts +33 -2
  139. package/dist/core/source/dense.js +121 -24
  140. package/dist/core/source/dense.js.map +1 -1
  141. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  142. package/dist/core/source/sparse-wgsl.js +481 -0
  143. package/dist/core/source/sparse-wgsl.js.map +1 -0
  144. package/dist/core/source/sparse.d.ts +192 -0
  145. package/dist/core/source/sparse.js +762 -0
  146. package/dist/core/source/sparse.js.map +1 -0
  147. package/dist/core/source/types.d.ts +59 -2
  148. package/dist/core/source/types.js.map +1 -1
  149. package/dist/core/surface/index.d.ts +10 -0
  150. package/dist/core/surface/index.js +9 -0
  151. package/dist/core/surface/index.js.map +1 -0
  152. package/dist/core/surface/level-set-pass.d.ts +140 -0
  153. package/dist/core/surface/level-set-pass.js +291 -0
  154. package/dist/core/surface/level-set-pass.js.map +1 -0
  155. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  156. package/dist/core/surface/level-set-wgsl.js +99 -0
  157. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  158. package/dist/core/surface/points.d.ts +109 -0
  159. package/dist/core/surface/points.js +226 -0
  160. package/dist/core/surface/points.js.map +1 -0
  161. package/dist/core/types.d.ts +12 -3
  162. package/dist/core/types.js +6 -2
  163. package/dist/core/types.js.map +1 -1
  164. package/dist/core/wgsl/api.d.ts +29 -5
  165. package/dist/core/wgsl/api.js +110 -27
  166. package/dist/core/wgsl/api.js.map +1 -1
  167. package/dist/core/wgsl/generate.d.ts +8 -0
  168. package/dist/core/wgsl/generate.js +195 -22
  169. package/dist/core/wgsl/generate.js.map +1 -1
  170. package/dist/core/wgsl/lean.d.ts +50 -0
  171. package/dist/core/wgsl/lean.js +327 -0
  172. package/dist/core/wgsl/lean.js.map +1 -0
  173. package/dist/core/wgsl/level-set.d.ts +5 -1
  174. package/dist/core/wgsl/level-set.js +11 -5
  175. package/dist/core/wgsl/level-set.js.map +1 -1
  176. package/dist/core/wgsl/majorant.d.ts +62 -0
  177. package/dist/core/wgsl/majorant.js +381 -0
  178. package/dist/core/wgsl/majorant.js.map +1 -0
  179. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
  180. package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
  181. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
  182. package/dist/core/wgsl/types.d.ts +97 -3
  183. package/dist/core/wgsl/types.js.map +1 -1
  184. package/dist/three/coarse-first.d.ts +53 -8
  185. package/dist/three/coarse-first.js +24 -6
  186. package/dist/three/coarse-first.js.map +1 -1
  187. package/dist/three/compute.d.ts +12 -2
  188. package/dist/three/compute.js +16 -6
  189. package/dist/three/compute.js.map +1 -1
  190. package/dist/three/device.d.ts +7 -0
  191. package/dist/three/device.js +3 -0
  192. package/dist/three/device.js.map +1 -1
  193. package/dist/three/frame/core-environment.d.ts +38 -0
  194. package/dist/three/frame/core-environment.js +154 -0
  195. package/dist/three/frame/core-environment.js.map +1 -0
  196. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  197. package/dist/three/frame/core-integrate-material.js +162 -0
  198. package/dist/three/frame/core-integrate-material.js.map +1 -0
  199. package/dist/three/frame/core-occluders.d.ts +53 -0
  200. package/dist/three/frame/core-occluders.js +193 -0
  201. package/dist/three/frame/core-occluders.js.map +1 -0
  202. package/dist/three/frame/core-structs.d.ts +34 -0
  203. package/dist/three/frame/core-structs.js +61 -0
  204. package/dist/three/frame/core-structs.js.map +1 -0
  205. package/dist/three/frame/core-textures.d.ts +41 -0
  206. package/dist/three/frame/core-textures.js +114 -0
  207. package/dist/three/frame/core-textures.js.map +1 -0
  208. package/dist/three/frame/emission-light.d.ts +64 -114
  209. package/dist/three/frame/emission-light.js +188 -567
  210. package/dist/three/frame/emission-light.js.map +1 -1
  211. package/dist/three/frame/index.d.ts +11 -31
  212. package/dist/three/frame/index.js +9 -29
  213. package/dist/three/frame/index.js.map +1 -1
  214. package/dist/three/frame/medium.d.ts +12 -0
  215. package/dist/three/frame/medium.js.map +1 -1
  216. package/dist/three/frame/renderer.d.ts +58 -454
  217. package/dist/three/frame/renderer.js +409 -1427
  218. package/dist/three/frame/renderer.js.map +1 -1
  219. package/dist/three/frame/spectrum.d.ts +0 -14
  220. package/dist/three/frame/spectrum.js +2 -23
  221. package/dist/three/frame/spectrum.js.map +1 -1
  222. package/dist/three/frame/three-internals.d.ts +3 -8
  223. package/dist/three/frame/three-internals.js +13 -11
  224. package/dist/three/frame/three-internals.js.map +1 -1
  225. package/dist/three/frame/volume-shadows.d.ts +93 -107
  226. package/dist/three/frame/volume-shadows.js +278 -631
  227. package/dist/three/frame/volume-shadows.js.map +1 -1
  228. package/dist/three/frame/volume.d.ts +91 -33
  229. package/dist/three/frame/volume.js +63 -51
  230. package/dist/three/frame/volume.js.map +1 -1
  231. package/dist/three/grid-node.d.ts +34 -1
  232. package/dist/three/grid-node.js +36 -1
  233. package/dist/three/grid-node.js.map +1 -1
  234. package/dist/three/index.d.ts +20 -11
  235. package/dist/three/index.js +21 -12
  236. package/dist/three/index.js.map +1 -1
  237. package/dist/three/internal.d.ts +14 -8
  238. package/dist/three/internal.js +11 -7
  239. package/dist/three/internal.js.map +1 -1
  240. package/dist/three/level-set-material.d.ts +81 -8
  241. package/dist/three/level-set-material.js +162 -125
  242. package/dist/three/level-set-material.js.map +1 -1
  243. package/dist/three/level-set-physical-material.d.ts +154 -0
  244. package/dist/three/level-set-physical-material.js +253 -0
  245. package/dist/three/level-set-physical-material.js.map +1 -0
  246. package/dist/three/level-set-velocity.d.ts +94 -0
  247. package/dist/three/level-set-velocity.js +208 -0
  248. package/dist/three/level-set-velocity.js.map +1 -0
  249. package/dist/three/material.d.ts +141 -11
  250. package/dist/three/material.js +161 -18
  251. package/dist/three/material.js.map +1 -1
  252. package/dist/three/points.d.ts +60 -4
  253. package/dist/three/points.js +140 -9
  254. package/dist/three/points.js.map +1 -1
  255. package/dist/three/sparse-source.d.ts +49 -117
  256. package/dist/three/sparse-source.js +109 -580
  257. package/dist/three/sparse-source.js.map +1 -1
  258. package/dist/three/volume-source.d.ts +11 -156
  259. package/dist/three/volume-source.js +29 -272
  260. package/dist/three/volume-source.js.map +1 -1
  261. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  262. package/dist/tools/cpu/brick-atlas.js +129 -0
  263. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  264. package/dist/tools/cpu/compute.d.ts +23 -4
  265. package/dist/tools/cpu/compute.js +35 -14
  266. package/dist/tools/cpu/compute.js.map +1 -1
  267. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  268. package/dist/tools/cpu/lean-reads.js +262 -0
  269. package/dist/tools/cpu/lean-reads.js.map +1 -0
  270. package/dist/tools/cpu/level-set.d.ts +42 -3
  271. package/dist/tools/cpu/level-set.js +59 -7
  272. package/dist/tools/cpu/level-set.js.map +1 -1
  273. package/dist/tools/cpu/majorant.d.ts +265 -0
  274. package/dist/tools/cpu/majorant.js +541 -0
  275. package/dist/tools/cpu/majorant.js.map +1 -0
  276. package/dist/tools/cpu/march.d.ts +93 -2
  277. package/dist/tools/cpu/march.js +165 -14
  278. package/dist/tools/cpu/march.js.map +1 -1
  279. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  280. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  281. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  282. package/dist/tools/cpu/points.d.ts +29 -0
  283. package/dist/tools/cpu/points.js +38 -0
  284. package/dist/tools/cpu/points.js.map +1 -0
  285. package/dist/tools/cpu/read-value.d.ts +19 -6
  286. package/dist/tools/cpu/read-value.js +32 -17
  287. package/dist/tools/cpu/read-value.js.map +1 -1
  288. package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
  289. package/dist/tools/cpu/sample-trilinear.js +19 -7
  290. package/dist/tools/cpu/sample-trilinear.js.map +1 -1
  291. package/dist/tools/cpu/stride-tables.d.ts +2 -2
  292. package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
  293. package/dist/tools/cpu/stride-tables.generated.js +7 -6
  294. package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
  295. package/dist/tools/cpu/stride-tables.js +1 -1
  296. package/dist/tools/cpu/stride-tables.js.map +1 -1
  297. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  298. package/dist/tools/cpu/surface-nets.js +597 -0
  299. package/dist/tools/cpu/surface-nets.js.map +1 -0
  300. package/dist/tools/errors.d.ts +9 -0
  301. package/dist/tools/errors.js +9 -0
  302. package/dist/tools/errors.js.map +1 -1
  303. package/dist/tools/frame/ambient.d.ts +98 -0
  304. package/dist/tools/frame/ambient.js +274 -0
  305. package/dist/tools/frame/ambient.js.map +1 -0
  306. package/dist/tools/frame/blackbody.d.ts +15 -0
  307. package/dist/tools/frame/blackbody.js +35 -0
  308. package/dist/tools/frame/blackbody.js.map +1 -1
  309. package/dist/tools/frame/brick-cache.d.ts +165 -0
  310. package/dist/tools/frame/brick-cache.js +326 -0
  311. package/dist/tools/frame/brick-cache.js.map +1 -0
  312. package/dist/tools/frame/emission.d.ts +9 -0
  313. package/dist/tools/frame/emission.js +9 -1
  314. package/dist/tools/frame/emission.js.map +1 -1
  315. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  316. package/dist/tools/frame/environment-gpu.js +280 -0
  317. package/dist/tools/frame/environment-gpu.js.map +1 -0
  318. package/dist/tools/frame/environment.d.ts +3 -2
  319. package/dist/tools/frame/environment.js +8 -4
  320. package/dist/tools/frame/environment.js.map +1 -1
  321. package/dist/tools/frame/froxel.d.ts +58 -0
  322. package/dist/tools/frame/froxel.js +115 -0
  323. package/dist/tools/frame/froxel.js.map +1 -0
  324. package/dist/tools/frame/grid.d.ts +90 -0
  325. package/dist/tools/frame/grid.js +112 -13
  326. package/dist/tools/frame/grid.js.map +1 -1
  327. package/dist/tools/frame/index.d.ts +14 -0
  328. package/dist/tools/frame/index.js +45 -4
  329. package/dist/tools/frame/index.js.map +1 -1
  330. package/dist/tools/frame/medium.d.ts +16 -0
  331. package/dist/tools/frame/medium.js +3 -1
  332. package/dist/tools/frame/medium.js.map +1 -1
  333. package/dist/tools/frame/mie.d.ts +9 -0
  334. package/dist/tools/frame/mie.js +18 -0
  335. package/dist/tools/frame/mie.js.map +1 -1
  336. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  337. package/dist/tools/frame/mlp-nn.js +159 -0
  338. package/dist/tools/frame/mlp-nn.js.map +1 -0
  339. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  340. package/dist/tools/frame/mlp-tza.js +186 -0
  341. package/dist/tools/frame/mlp-tza.js.map +1 -0
  342. package/dist/tools/frame/mlp.d.ts +183 -0
  343. package/dist/tools/frame/mlp.js +434 -0
  344. package/dist/tools/frame/mlp.js.map +1 -0
  345. package/dist/tools/frame/ms-exit.d.ts +42 -0
  346. package/dist/tools/frame/ms-exit.js +90 -0
  347. package/dist/tools/frame/ms-exit.js.map +1 -0
  348. package/dist/tools/frame/multi-scale.d.ts +152 -0
  349. package/dist/tools/frame/multi-scale.js +302 -0
  350. package/dist/tools/frame/multi-scale.js.map +1 -0
  351. package/dist/tools/frame/neural-weights.d.ts +6 -5
  352. package/dist/tools/frame/neural-weights.js +234 -235
  353. package/dist/tools/frame/neural-weights.js.map +1 -1
  354. package/dist/tools/frame/neural.js +1 -1
  355. package/dist/tools/frame/neural.js.map +1 -1
  356. package/dist/tools/frame/occluders.d.ts +51 -0
  357. package/dist/tools/frame/occluders.js +72 -0
  358. package/dist/tools/frame/occluders.js.map +1 -0
  359. package/dist/tools/frame/pyramid-layout.d.ts +17 -0
  360. package/dist/tools/frame/pyramid-layout.js +47 -0
  361. package/dist/tools/frame/pyramid-layout.js.map +1 -1
  362. package/dist/tools/frame/shadows.d.ts +110 -0
  363. package/dist/tools/frame/shadows.js +286 -0
  364. package/dist/tools/frame/shadows.js.map +1 -1
  365. package/dist/tools/frame/sparse.d.ts +82 -0
  366. package/dist/tools/frame/sparse.js +242 -1
  367. package/dist/tools/frame/sparse.js.map +1 -1
  368. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  369. package/dist/tools/frame/spectral-stack.js +391 -0
  370. package/dist/tools/frame/spectral-stack.js.map +1 -0
  371. package/dist/tools/frame/spectral.d.ts +21 -2
  372. package/dist/tools/frame/spectral.js +30 -8
  373. package/dist/tools/frame/spectral.js.map +1 -1
  374. package/dist/tools/frame/stack.d.ts +115 -0
  375. package/dist/tools/frame/stack.js +290 -0
  376. package/dist/tools/frame/stack.js.map +1 -0
  377. package/dist/tools/frame/view.d.ts +131 -0
  378. package/dist/tools/frame/view.js +337 -0
  379. package/dist/tools/frame/view.js.map +1 -0
  380. package/dist/tools/index.d.ts +66 -15
  381. package/dist/tools/index.js +55 -11
  382. package/dist/tools/index.js.map +1 -1
  383. package/dist/tools/internal.d.ts +58 -17
  384. package/dist/tools/internal.js +65 -11
  385. package/dist/tools/internal.js.map +1 -1
  386. package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
  387. package/dist/tools/nanovdb/build-from-vdb.js +10 -2
  388. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
  389. package/dist/tools/nanovdb/bytes.d.ts +17 -4
  390. package/dist/tools/nanovdb/bytes.js +46 -3
  391. package/dist/tools/nanovdb/bytes.js.map +1 -1
  392. package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
  393. package/dist/tools/nanovdb/coarse-first.js +7 -1
  394. package/dist/tools/nanovdb/coarse-first.js.map +1 -1
  395. package/dist/tools/nanovdb/half.d.ts +22 -0
  396. package/dist/tools/nanovdb/half.js +73 -0
  397. package/dist/tools/nanovdb/half.js.map +1 -0
  398. package/dist/tools/nanovdb/index.d.ts +3 -1
  399. package/dist/tools/nanovdb/index.js +2 -1
  400. package/dist/tools/nanovdb/index.js.map +1 -1
  401. package/dist/tools/nanovdb/inspect.d.ts +10 -1
  402. package/dist/tools/nanovdb/inspect.js +8 -1
  403. package/dist/tools/nanovdb/inspect.js.map +1 -1
  404. package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
  405. package/dist/tools/nanovdb/leaf-codec.js +40 -4
  406. package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
  407. package/dist/tools/nanovdb/quantize.d.ts +39 -10
  408. package/dist/tools/nanovdb/quantize.js +96 -44
  409. package/dist/tools/nanovdb/quantize.js.map +1 -1
  410. package/dist/tools/nanovdb/resample.d.ts +20 -3
  411. package/dist/tools/nanovdb/resample.js +20 -7
  412. package/dist/tools/nanovdb/resample.js.map +1 -1
  413. package/dist/tools/nanovdb/serialize.d.ts +34 -3
  414. package/dist/tools/nanovdb/serialize.js +51 -7
  415. package/dist/tools/nanovdb/serialize.js.map +1 -1
  416. package/dist/tools/nanovdb/stats.d.ts +34 -5
  417. package/dist/tools/nanovdb/stats.js +87 -11
  418. package/dist/tools/nanovdb/stats.js.map +1 -1
  419. package/dist/tools/nanovdb/transform.d.ts +4 -0
  420. package/dist/tools/nanovdb/transform.js +3 -0
  421. package/dist/tools/nanovdb/transform.js.map +1 -1
  422. package/dist/tools/nanovdb/tree.d.ts +14 -3
  423. package/dist/tools/nanovdb/tree.js +25 -13
  424. package/dist/tools/nanovdb/tree.js.map +1 -1
  425. package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
  426. package/dist/tools/nanovdb/write-nvdb.js +108 -28
  427. package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
  428. package/dist/tools/nvdb-file.d.ts +77 -7
  429. package/dist/tools/nvdb-file.js +177 -20
  430. package/dist/tools/nvdb-file.js.map +1 -1
  431. package/dist/tools/nvdb-stream.d.ts +23 -7
  432. package/dist/tools/nvdb-stream.js +78 -34
  433. package/dist/tools/nvdb-stream.js.map +1 -1
  434. package/dist/tools/reference/analytic.d.ts +41 -0
  435. package/dist/tools/reference/analytic.js +95 -0
  436. package/dist/tools/reference/analytic.js.map +1 -0
  437. package/dist/tools/reference/environment.d.ts +62 -0
  438. package/dist/tools/reference/environment.js +154 -0
  439. package/dist/tools/reference/environment.js.map +1 -0
  440. package/dist/tools/reference/index.d.ts +12 -0
  441. package/dist/tools/reference/index.js +13 -0
  442. package/dist/tools/reference/index.js.map +1 -0
  443. package/dist/tools/reference/media.d.ts +14 -0
  444. package/dist/tools/reference/media.js +30 -0
  445. package/dist/tools/reference/media.js.map +1 -0
  446. package/dist/tools/reference/rng.d.ts +20 -0
  447. package/dist/tools/reference/rng.js +30 -0
  448. package/dist/tools/reference/rng.js.map +1 -0
  449. package/dist/tools/reference/scene.d.ts +312 -0
  450. package/dist/tools/reference/scene.js +169 -0
  451. package/dist/tools/reference/scene.js.map +1 -0
  452. package/dist/tools/reference/tables.d.ts +98 -0
  453. package/dist/tools/reference/tables.js +264 -0
  454. package/dist/tools/reference/tables.js.map +1 -0
  455. package/dist/tools/reference/trace.d.ts +160 -0
  456. package/dist/tools/reference/trace.js +497 -0
  457. package/dist/tools/reference/trace.js.map +1 -0
  458. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  459. package/dist/tools/vdb/blosc-write.js +197 -0
  460. package/dist/tools/vdb/blosc-write.js.map +1 -0
  461. package/dist/tools/vdb/blosc.d.ts +35 -5
  462. package/dist/tools/vdb/blosc.js +82 -26
  463. package/dist/tools/vdb/blosc.js.map +1 -1
  464. package/dist/tools/vdb/blosclz.d.ts +33 -0
  465. package/dist/tools/vdb/blosclz.js +112 -0
  466. package/dist/tools/vdb/blosclz.js.map +1 -0
  467. package/dist/tools/vdb/byte-reader.d.ts +13 -3
  468. package/dist/tools/vdb/byte-reader.js +26 -4
  469. package/dist/tools/vdb/byte-reader.js.map +1 -1
  470. package/dist/tools/vdb/compression.d.ts +13 -5
  471. package/dist/tools/vdb/compression.js +13 -2
  472. package/dist/tools/vdb/compression.js.map +1 -1
  473. package/dist/tools/vdb/grid.js +8 -2
  474. package/dist/tools/vdb/grid.js.map +1 -1
  475. package/dist/tools/vdb/index.d.ts +2 -1
  476. package/dist/tools/vdb/index.js.map +1 -1
  477. package/dist/tools/vdb/lz4.d.ts +30 -0
  478. package/dist/tools/vdb/lz4.js +228 -0
  479. package/dist/tools/vdb/lz4.js.map +1 -0
  480. package/dist/tools/vdb/metadata.js +1 -1
  481. package/dist/tools/vdb/metadata.js.map +1 -1
  482. package/dist/tools/vdb/parse.d.ts +24 -2
  483. package/dist/tools/vdb/parse.js +102 -32
  484. package/dist/tools/vdb/parse.js.map +1 -1
  485. package/dist/tools/vdb/point-render-data.d.ts +49 -1
  486. package/dist/tools/vdb/point-render-data.js +91 -11
  487. package/dist/tools/vdb/point-render-data.js.map +1 -1
  488. package/dist/tools/vdb/points.d.ts +26 -0
  489. package/dist/tools/vdb/points.js +46 -5
  490. package/dist/tools/vdb/points.js.map +1 -1
  491. package/dist/tools/vdb/types.d.ts +59 -2
  492. package/dist/tools/vdb/types.js.map +1 -1
  493. package/dist/tools/wvdb/bake.d.ts +38 -9
  494. package/dist/tools/wvdb/bake.js +63 -13
  495. package/dist/tools/wvdb/bake.js.map +1 -1
  496. package/dist/tools/wvdb/dense.d.ts +80 -1
  497. package/dist/tools/wvdb/dense.js +67 -8
  498. package/dist/tools/wvdb/dense.js.map +1 -1
  499. package/dist/tools/wvdb/format.d.ts +59 -0
  500. package/dist/tools/wvdb/format.js +3 -0
  501. package/dist/tools/wvdb/format.js.map +1 -1
  502. package/dist/tools/wvdb/index.d.ts +1 -0
  503. package/dist/tools/wvdb/index.js +1 -0
  504. package/dist/tools/wvdb/index.js.map +1 -1
  505. package/dist/tools/wvdb/level-set.d.ts +10 -2
  506. package/dist/tools/wvdb/level-set.js.map +1 -1
  507. package/dist/tools/wvdb/nanovdb.d.ts +6 -1
  508. package/dist/tools/wvdb/nanovdb.js +5 -1
  509. package/dist/tools/wvdb/nanovdb.js.map +1 -1
  510. package/dist/tools/wvdb/partial.d.ts +74 -0
  511. package/dist/tools/wvdb/partial.js +233 -0
  512. package/dist/tools/wvdb/partial.js.map +1 -0
  513. package/dist/tools/wvdb/read.d.ts +77 -1
  514. package/dist/tools/wvdb/read.js +30 -7
  515. package/dist/tools/wvdb/read.js.map +1 -1
  516. package/dist/tools/wvdb/write.d.ts +23 -1
  517. package/dist/tools/wvdb/write.js +8 -1
  518. package/dist/tools/wvdb/write.js.map +1 -1
  519. package/package.json +2 -1
  520. package/vendor/VENDOR.md +21 -6
  521. package/vendor/pnanovdb.wgsl +52 -14
  522. package/dist/three/frame/blackbody.d.ts +0 -42
  523. package/dist/three/frame/blackbody.js +0 -74
  524. package/dist/three/frame/blackbody.js.map +0 -1
  525. package/dist/three/frame/chunks.d.ts +0 -157
  526. package/dist/three/frame/chunks.js +0 -559
  527. package/dist/three/frame/chunks.js.map +0 -1
  528. package/dist/three/frame/density-material.d.ts +0 -53
  529. package/dist/three/frame/density-material.js +0 -353
  530. package/dist/three/frame/density-material.js.map +0 -1
  531. package/dist/three/frame/environment-grid-material.d.ts +0 -21
  532. package/dist/three/frame/environment-grid-material.js +0 -184
  533. package/dist/three/frame/environment-grid-material.js.map +0 -1
  534. package/dist/three/frame/environment-material.d.ts +0 -22
  535. package/dist/three/frame/environment-material.js +0 -87
  536. package/dist/three/frame/environment-material.js.map +0 -1
  537. package/dist/three/frame/grid-mip-material.d.ts +0 -12
  538. package/dist/three/frame/grid-mip-material.js +0 -61
  539. package/dist/three/frame/grid-mip-material.js.map +0 -1
  540. package/dist/three/frame/inject-material.d.ts +0 -56
  541. package/dist/three/frame/inject-material.js +0 -424
  542. package/dist/three/frame/inject-material.js.map +0 -1
  543. package/dist/three/frame/integrate-material.d.ts +0 -26
  544. package/dist/three/frame/integrate-material.js +0 -198
  545. package/dist/three/frame/integrate-material.js.map +0 -1
  546. package/dist/three/frame/layout.d.ts +0 -34
  547. package/dist/three/frame/layout.js +0 -48
  548. package/dist/three/frame/layout.js.map +0 -1
  549. package/dist/three/frame/lighting-material.d.ts +0 -41
  550. package/dist/three/frame/lighting-material.js +0 -257
  551. package/dist/three/frame/lighting-material.js.map +0 -1
  552. package/dist/three/frame/lights.d.ts +0 -11
  553. package/dist/three/frame/lights.js +0 -16
  554. package/dist/three/frame/lights.js.map +0 -1
  555. package/dist/three/frame/neural.d.ts +0 -14
  556. package/dist/three/frame/neural.js +0 -105
  557. package/dist/three/frame/neural.js.map +0 -1
  558. package/dist/three/frame/phase.d.ts +0 -44
  559. package/dist/three/frame/phase.js +0 -80
  560. package/dist/three/frame/phase.js.map +0 -1
  561. package/dist/three/frame/shadow-density-material.d.ts +0 -30
  562. package/dist/three/frame/shadow-density-material.js +0 -123
  563. package/dist/three/frame/shadow-density-material.js.map +0 -1
  564. package/dist/three/frame/temporal-material.d.ts +0 -29
  565. package/dist/three/frame/temporal-material.js +0 -152
  566. package/dist/three/frame/temporal-material.js.map +0 -1
  567. package/dist/three/frame/transmittance-material.d.ts +0 -31
  568. package/dist/three/frame/transmittance-material.js +0 -315
  569. package/dist/three/frame/transmittance-material.js.map +0 -1
  570. package/dist/three/frame/view.d.ts +0 -103
  571. package/dist/three/frame/view.js +0 -296
  572. package/dist/three/frame/view.js.map +0 -1
  573. package/dist/three/frame/volume-shadow-material.d.ts +0 -36
  574. package/dist/three/frame/volume-shadow-material.js +0 -128
  575. package/dist/three/frame/volume-shadow-material.js.map +0 -1
  576. package/dist/three/sequence.js.map +0 -1
@@ -1,89 +1,47 @@
1
1
  // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/webgpu/frameShaderChunks.js L65–66 (min/maxComponent), L729–763
3
- // (createVolumeUniforms), L765–798 (setMipUniforms), L834–1028 (createVolumeNodes);
4
- // src/three-openvdb/frame/core/FrameVolume.js L14–22, L357–405 (Data3DTexture setup);
5
- // src/three-openvdb/frame/webgpu/FrameRenderer.js L483–487 (configureTexture);
2
+ // src/three-openvdb/frame/core/FrameVolume.js L14–22, L357–405 (the dense texture setup this handle describes);
6
3
  // src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).
7
4
  // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
8
- // Changes: TypeScript; absent channels compile to constants instead of runtime flags; the
9
- // Shadertoy blackbody is not ported (emission colour is a caller hook; his 'planck' / 'soot' table is
10
- // `vdbFrameBlackbodyEmission`, on an analytic CIE fit: D33).
5
+ // Changes: TypeScript; K6.11 (D35): a handle only. His `createVolumeUniforms` / `createVolumeNodes` shape (the TSL half,
6
+ // `vdbVolumeUniforms` / `vdbVolumeNodes`) and the three textures are deleted: the core's `vdbDenseSource` reads the volume.
11
7
  // Divergences: DIVERGES.md V23–V25.
12
8
  /**
13
- * The dense `.wvdb` volume source in three (K3.0, R1 §4.2).
9
+ * The dense `.wvdb` volume source in three (K3.0, R1 §4.2): a handle `VDBFrameVolume` draws.
14
10
  *
15
11
  * const file = readWvdb(bytes);
16
12
  * const volume = wvdbDenseVolume(file); // @pmndrs/vdb/tools: his 8-bit texels + mip atlas
17
- * const source = vdbDenseTextures(volume); // three Data3DTextures, set up as his FrameVolume
18
- * const uniforms = vdbVolumeUniforms(source, { extinction: 100 });
19
- * const nodes = vdbVolumeNodes(source, uniforms, { useMipmaps: true });
20
- * // inside a TSL Fn: nodes.sampleExtinction(localPos, lod), nodes.sampleAlbedo(...), nodes.boxSegment(...)
13
+ * const source = vdbDenseTextures(volume); // the handle
14
+ * const frameVolume = new VDBFrameVolume(source, { extinction: 100 });
21
15
  *
22
- * `vdbVolumeNodes` returns the shape of his `createVolumeNodes()` (`getLod`,
23
- * `sampleExtinction`, `sampleAlbedo`, `sampleEmission`, `insideBox`, `boxExit`,
24
- * `boxSegment`), so the K3 port of his materials changes one import per file.
25
- * Positions are in the local unit box [-0.5, 0.5]³.
16
+ * K6.11: the handle holds no GPU object. `VDBFrameRenderer` reads `source.volume` into the core's dense source
17
+ * (`vdbDenseSource`, which makes the textures and the `vdbSrc*` WGSL). A custom TSL material samples a pooled grid
18
+ * through `VDBGridNode`; custom WGSL or compute uses the core source's `wgsl()`.
26
19
  */
27
- import * as THREE from "three";
28
- import { If, abs, ceil, clamp, exp2, float, floor, fract, log2, max, min, mix, mod, pow, select, texture3D, uniform, vec2, vec3, vec4, } from "three/tsl";
29
20
  import { VDBError } from "../core/errors.js";
30
21
  const CHANNELS = ["density", "mask", "albedo", "emission"];
31
- /**
32
- * FrameVolume.js L14–22 `createTexture3D` + FrameRenderer.js L483–487
33
- * `configureTexture` (and frameMipmaps.js L183–189 for the atlas): an 8-bit
34
- * `Data3DTexture`, `RedFormat` or `RGBAFormat`, `unpackAlignment` 1, linear
35
- * min/mag, no mipmaps, default clamp-to-edge wrapping.
36
- */
37
- function texture3DFrom(data, dims, texelBytes) {
38
- const [w, h, d] = dims;
39
- const texture = new THREE.Data3DTexture(data, w, h, d);
40
- texture.format = texelBytes === 4 ? THREE.RGBAFormat : THREE.RedFormat;
41
- texture.type = THREE.UnsignedByteType;
42
- texture.unpackAlignment = 1;
43
- texture.minFilter = THREE.LinearFilter;
44
- texture.magFilter = THREE.LinearFilter;
45
- texture.generateMipmaps = false;
46
- texture.needsUpdate = true;
47
- return texture;
48
- }
49
- function channelTextures(tex) {
50
- if (!tex)
51
- return null;
52
- return {
53
- map: texture3DFrom(tex.data, tex.dimensions, tex.texelBytes),
54
- mip: tex.mip ? texture3DFrom(tex.mip.data, tex.mip.dimensions, tex.texelBytes) : null,
55
- };
56
- }
57
- /** K5.9: a channel's absent value (mask and albedo 1, emission 0) as a texture of the density's size (and mip atlas). */
58
- function constantChannel(name, t, density) {
59
- const texelBytes = t.map.format === THREE.RGBAFormat ? 4 : 1;
60
- const value = name === "emission" ? 0 : 255;
61
- const fill = (dims) => new Uint8Array(dims[0] * dims[1] * dims[2] * texelBytes).fill(value);
62
- const mip = t.mip && density.mip ? { data: fill(density.mip.dimensions), dimensions: density.mip.dimensions, levels: density.mip.levels } : null;
63
- return { data: fill(density.dimensions), dimensions: density.dimensions, format: texelBytes === 4 ? "rgba8unorm" : "r8unorm", texelBytes, mip };
64
- }
65
22
  const channelsOf = (v) => ({
66
23
  density: v.density,
67
24
  mask: v.mask,
68
25
  albedo: v.albedo,
69
26
  emission: v.emission,
70
27
  });
28
+ const sameDims = (a, b) => !!a && !!b && a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
71
29
  class ThreeDenseSource {
72
30
  kind = "dense";
73
31
  boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);
74
32
  channels;
75
33
  volume;
76
- textures;
77
34
  texels;
78
35
  lodLevels;
79
36
  stats;
80
37
  version = 0;
81
38
  warnedExtra = new Set();
39
+ #shape;
82
40
  constructor(volume) {
83
41
  this.volume = volume;
84
42
  this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };
85
43
  const c = channelsOf(volume);
86
- this.textures = { density: channelTextures(c.density), mask: channelTextures(c.mask), albedo: channelTextures(c.albedo), emission: channelTextures(c.emission) };
44
+ this.#shape = Object.fromEntries(CHANNELS.map((n) => [n, c[n] ? { mip: !!c[n].mip } : null]));
87
45
  this.texels = [...volume.dimensions];
88
46
  this.lodLevels = volume.density.mip?.levels ?? 0;
89
47
  this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };
@@ -92,54 +50,39 @@ class ThreeDenseSource {
92
50
  if (!volume || volume.kind !== "dense" || !volume.density) {
93
51
  throw new VDBError("VDB_BAD_OPTION", "vdbDenseTextures.replace: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).");
94
52
  }
53
+ const shape = this.#shape;
95
54
  const next = channelsOf(volume);
96
55
  const densityMip = next.density.mip;
97
- if (!!this.textures.density.mip !== !!densityMip && this.textures.density.mip) {
56
+ if (!!shape.density.mip !== !!densityMip && shape.density.mip) {
98
57
  throw new VDBError("VDB_BAD_OPTION", "vdbDenseTextures.replace: the frame's density has no mip atlas but the source's has; bake every frame with mipmaps, or make the source without.");
99
58
  }
100
59
  // K5.9 (sequences): a channel the source has and the frame lacks reads its absent value (mask and albedo 1,
101
- // emission 0) from a constant texture of the frame's size; a channel (or mip atlas) the source lacks is ignored,
102
- // since the shaders were built without it (warned once: make the source from a frame that has every channel).
60
+ // emission 0; the core's dense source does that); a channel (or mip atlas) the source lacks is ignored, since the
61
+ // shaders were built without it (warned once: make the source from a frame that has every channel).
103
62
  for (const name of CHANNELS) {
104
- const t = this.textures[name];
63
+ const s = shape[name];
105
64
  const v = next[name];
106
- if (!t && v) {
65
+ if (!s && v) {
107
66
  if (!this.warnedExtra.has(name)) {
108
67
  this.warnedExtra.add(name);
109
68
  console.warn(`vdbDenseTextures.replace: the frame has a ${name} channel the source was made without; it is ignored.`);
110
69
  }
111
70
  next[name] = null;
112
71
  }
113
- else if (t && !v) {
114
- next[name] = constantChannel(name, t, next.density);
115
- }
116
- else if (t && v && !!t.mip !== !!v.mip) {
117
- if (t.mip)
118
- throw new VDBError("VDB_BAD_OPTION", `vdbDenseTextures.replace: the frame's ${name} channel has no mip atlas but the source's has; make a new source.`);
119
- next[name] = { ...v, mip: null };
72
+ else if (s && v && s.mip !== !!v.mip && s.mip) {
73
+ throw new VDBError("VDB_BAD_OPTION", `vdbDenseTextures.replace: the frame's ${name} channel has no mip atlas but the source's has; make a new source.`);
120
74
  }
121
75
  }
122
- // WVDBLoader.js L37–48 updateTexture: a new size disposes the GPU texture first.
76
+ // WVDBLoader.js L37–48 updateTexture: a new size is a new texture (here: bumps `version`).
77
+ const before = channelsOf(this.volume);
123
78
  let resized = false;
124
79
  for (const name of CHANNELS) {
125
- const t = this.textures[name];
80
+ const o = before[name];
126
81
  const v = next[name];
127
- if (!t || !v)
82
+ if (!o || !v)
128
83
  continue;
129
- const set = (tex, data, dims) => {
130
- const [width, height, depth] = dims;
131
- const img = tex.image;
132
- const changed = img.width !== width || img.height !== height || img.depth !== depth;
133
- tex.image = { data, width, height, depth };
134
- if (changed) {
135
- tex.dispose();
136
- resized = true;
137
- }
138
- tex.needsUpdate = true;
139
- };
140
- set(t.map, v.data, v.dimensions);
141
- if (t.mip && v.mip)
142
- set(t.mip, v.mip.data, v.mip.dimensions);
84
+ if (!sameDims(o.dimensions, v.dimensions) || (!!o.mip && !!v.mip && !sameDims(o.mip.dimensions, v.mip.dimensions)))
85
+ resized = true;
143
86
  }
144
87
  // A frame with another world box (his WVDB sequences give each frame its own) also bumps `version`, so a
145
88
  // VDBFrameVolume whose box is the source's moves its box (an empty frame's null box keeps the last one).
@@ -150,204 +93,18 @@ class ThreeDenseSource {
150
93
  this.version++;
151
94
  this.volume = volume;
152
95
  this.texels = [...volume.dimensions];
153
- this.lodLevels = this.textures.density.mip ? (volume.density.mip?.levels ?? 0) : 0;
96
+ this.lodLevels = shape.density.mip ? (volume.density.mip?.levels ?? 0) : 0;
154
97
  this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };
155
98
  }
156
99
  dispose() {
157
- for (const t of Object.values(this.textures)) {
158
- t?.map.dispose();
159
- t?.mip?.dispose();
160
- }
100
+ // No GPU object: the core's dense source (the frame renderer's) owns the textures.
161
101
  }
162
102
  }
163
- /** Upload a dense volume (`wvdbDenseVolume`, `@pmndrs/vdb/tools`) as three textures, set up as his `FrameVolume` does. */
103
+ /** A dense `.wvdb` volume (`wvdbDenseVolume`, `@pmndrs/vdb/tools`) as a handle for `VDBFrameVolume`. */
164
104
  export function vdbDenseTextures(volume) {
165
105
  if (!volume || volume.kind !== "dense" || !volume.density) {
166
106
  throw new VDBError("VDB_BAD_OPTION", "vdbDenseTextures: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).");
167
107
  }
168
108
  return new ThreeDenseSource(volume);
169
109
  }
170
- /** FrameVolume.js L561–568 `getDensityScale`. */
171
- export const vdbDensityScaleOf = (source, densityScale, normalize) => normalize && source.stats.meanNonZero > 0 ? densityScale / source.stats.meanNonZero : densityScale;
172
- const densityScaleOf = vdbDensityScaleOf;
173
- /**
174
- * Live uniforms for one source (his `createVolumeUniforms` + `setVolumeUniforms` + `setMipUniforms`).
175
- * A sparse source makes its own (`source.createUniforms`), with the same fields.
176
- */
177
- export function vdbVolumeUniforms(source, p = {}) {
178
- if (source.kind === "sparse")
179
- return source.createUniforms(p);
180
- const tex = source.textures;
181
- let densityScale = p.densityScale ?? 1.0;
182
- let normalize = p.normalizeDensity ?? true;
183
- const maps = {};
184
- const mipMaps = {};
185
- const mipLevels = {};
186
- for (const name of CHANNELS) {
187
- maps[name] = tex[name] ? texture3D(tex[name].map) : null;
188
- mipMaps[name] = tex[name]?.mip ? texture3D(tex[name].mip) : null;
189
- mipLevels[name] = uniform(0.0);
190
- }
191
- const gridTexels = uniform(new THREE.Vector3(1, 1, 1));
192
- const mipAtlasSize = uniform(new THREE.Vector3(1, 1, 1));
193
- const densityScaleU = uniform(densityScaleOf(source, densityScale, normalize));
194
- const u = {
195
- worldScale: uniform(p.worldScale ?? 1.0),
196
- gridTexels,
197
- mipAtlasSize,
198
- maps,
199
- mipMaps,
200
- mipLevels,
201
- baseColor: uniform(new THREE.Color(p.baseColor ?? 0xffffff)),
202
- extinction: uniform(p.extinction ?? 100.0),
203
- densityScale: densityScaleU,
204
- densityCutoff: uniform(p.densityCutoff ?? 0.0),
205
- emissiveIntensity: uniform(p.emissiveIntensity ?? 1.0),
206
- temperatureRange: uniform(new THREE.Vector2(...(p.temperatureRange ?? [0.0, 6500.0]))),
207
- offset3D: uniform(new THREE.Vector3().copy((p.offset3D ?? { x: 0, y: 0, z: 0 }))),
208
- wrap3D: uniform(p.wrap3D ?? THREE.ClampToEdgeWrapping, "int"),
209
- update(s0, o = {}) {
210
- if (s0.kind !== "dense")
211
- throw new VDBError("VDB_BAD_OPTION", "vdbVolumeUniforms: these uniforms belong to a dense source.");
212
- const s = s0;
213
- if (o.densityScale !== undefined)
214
- densityScale = o.densityScale;
215
- if (o.normalizeDensity !== undefined)
216
- normalize = o.normalizeDensity;
217
- densityScaleU.value = densityScaleOf(s, densityScale, normalize);
218
- const [w, h, d] = s.texels;
219
- gridTexels.value.set(w, h, d);
220
- const densityMip = s.textures.density?.mip;
221
- if (densityMip) {
222
- const img = densityMip.image;
223
- mipAtlasSize.value.set(img.width, img.height, img.depth);
224
- }
225
- for (const name of CHANNELS) {
226
- const t = s.textures[name];
227
- if (t && maps[name])
228
- maps[name].value = t.map;
229
- if (t?.mip && mipMaps[name])
230
- mipMaps[name].value = t.mip;
231
- // Every channel shares the density size (wvdbDenseVolume checks it), so all levels are the mip's.
232
- // A channel the frame lacks (K5.9: a constant texture) has the density's levels.
233
- mipLevels[name].value = densityMip && t?.mip ? (s.volume[name]?.mip?.levels ?? s.volume.density.mip?.levels ?? 0) : 0;
234
- }
235
- },
236
- dispose() {
237
- // A dense source registers nothing.
238
- },
239
- };
240
- u.update(source);
241
- return u;
242
- }
243
- /** frameShaderChunks.js L65–66. */
244
- export const vdbMinComponent = (v) => min(v.x, min(v.y, v.z));
245
- export const vdbMaxComponent = (v) => max(v.x, max(v.y, v.z));
246
- /**
247
- * Sampling of one dense source, in his `createVolumeNodes` shape. Call the
248
- * sample functions inside a TSL `Fn` body. Absent channels give his fallbacks
249
- * (mask 1, albedo `baseColor`, emission 0) without sampling.
250
- */
251
- /**
252
- * His mip sampling (frameShaderChunks.js L838–872) over one texture and its box mip atlas:
253
- * `sampleMipAtlas` (level 1 and up, frameMipmaps.js layout) and `sampleMipmapped` (linear between
254
- * two levels). `gridTexels` is the size of `map` (level 0 of this chain), `mipAtlasSize` the atlas's.
255
- * Shared by the dense source and the sparse source's coarse pyramid. Call in a TSL Fn body.
256
- */
257
- export function vdbMipSampler(gridTexels, mipAtlasSize) {
258
- // L838–846: level 1 and up of the mip atlas (layout of frameMipmaps.js).
259
- const sampleMipAtlas = (mipMap, level, uvw) => {
260
- const size = max(vec3(1.0), ceil(gridTexels.div(exp2(level))));
261
- const offset = mipAtlasSize.x.sub(mipAtlasSize.x.div(exp2(level.sub(1.0))));
262
- const texel = clamp(uvw.mul(size), vec3(0.5), size.sub(0.5));
263
- return mipMap.sample(vec3(texel.x.add(offset), texel.y, texel.z).div(mipAtlasSize)).level(float(0.0));
264
- };
265
- // L849–872: linear between two mip levels (LinearMipmapLinearFilter).
266
- const sampleMipmapped = (map, mipMap, levels, position, lod) => {
267
- const uvw = vec3(position).toVar();
268
- const result = vec4(0.0).toVar();
269
- const level = min(lod, levels).toVar();
270
- If(level.lessThanEqual(0.0), () => {
271
- result.assign(map.sample(uvw).level(float(0.0)));
272
- }).Else(() => {
273
- const level0 = floor(level).toVar();
274
- const low = vec4(0.0).toVar();
275
- If(level0.lessThan(0.5), () => {
276
- low.assign(map.sample(uvw).level(float(0.0)));
277
- }).Else(() => {
278
- low.assign(sampleMipAtlas(mipMap, level0, uvw));
279
- });
280
- const high = sampleMipAtlas(mipMap, min(level0.add(1.0), levels), uvw);
281
- result.assign(mix(low, high, level.sub(level0)));
282
- });
283
- return result;
284
- };
285
- return { sampleMipAtlas, sampleMipmapped };
286
- }
287
- /** His `wrapUv` / `gridUv` (frameShaderChunks.js L894–911): the local position as a wrapped, offset uvw. */
288
- export function vdbGridUv(u) {
289
- const T = THREE;
290
- const mirrorAxis = (value) => {
291
- const period = mod(value, 2.0);
292
- return select(period.greaterThan(1.0), float(2.0).sub(period), period);
293
- };
294
- const wrapUv = (uvw) => select(u.wrap3D.equal(T.RepeatWrapping), fract(uvw), select(u.wrap3D.equal(T.MirroredRepeatWrapping), vec3(mirrorAxis(uvw.x), mirrorAxis(uvw.y), mirrorAxis(uvw.z)), uvw));
295
- return (localPosition) => wrapUv(localPosition.add(0.5).add(u.offset3D));
296
- }
297
- /** His box geometry (frameShaderChunks.js L938–958): `insideBox`, `boxExit`, `boxSegment` of the local unit box. */
298
- export const vdbBoxNodes = {
299
- insideBox: (localPosition) => vdbMaxComponent(abs(localPosition)).lessThanEqual(0.5),
300
- boxExit: (origin, direction) => {
301
- const inverseDirection = vec3(1.0).div(direction);
302
- const tMin = vec3(-0.5).sub(origin).mul(inverseDirection);
303
- const tMax = vec3(0.5).sub(origin).mul(inverseDirection);
304
- return max(0.0, vdbMinComponent(max(tMin, tMax)));
305
- },
306
- boxSegment: (start, end) => {
307
- const inverseDirection = vec3(1.0).div(end.sub(start));
308
- const tMin = vec3(-0.5).sub(start).mul(inverseDirection);
309
- const tMax = vec3(0.5).sub(start).mul(inverseDirection);
310
- return vec2(max(0.0, vdbMaxComponent(min(tMin, tMax))), min(1.0, vdbMinComponent(max(tMin, tMax))));
311
- },
312
- };
313
- export function vdbVolumeNodes(source, u, o = {}) {
314
- if (source.kind === "sparse")
315
- return source.createNodes(u, o);
316
- const useMipmaps = o.useMipmaps ?? source.lodLevels > 0;
317
- const { gridTexels, mipAtlasSize } = u;
318
- const { sampleMipmapped } = vdbMipSampler(gridTexels, mipAtlasSize);
319
- // L874–877 sample3D (a channel without a mip atlas samples level 0).
320
- const sample3D = (name, uvw, lod) => {
321
- const map = u.maps[name];
322
- const mip = u.mipMaps[name];
323
- return useMipmaps && mip ? sampleMipmapped(map, mip, u.mipLevels[name], uvw, lod) : map.sample(uvw).level(float(0.0));
324
- };
325
- // L892
326
- const getLod = (localSize) => max(0.0, log2(localSize.mul(vdbMaxComponent(gridTexels))));
327
- // L894–911
328
- const gridUv = vdbGridUv(u);
329
- // L914–936: extinction per world unit. The mask is read at local + 0.5 (no offset or wrap), as his.
330
- const sampleExtinction = (localPosition, lod) => {
331
- const mask = source.channels.mask ? sample3D("mask", localPosition.add(0.5), lod).r : float(1.0);
332
- const value = sample3D("density", gridUv(localPosition), lod).r.mul(mask);
333
- return select(value.greaterThan(u.densityCutoff), value, float(0.0)).mul(u.densityScale).mul(u.extinction).div(u.worldScale);
334
- };
335
- // L938–958
336
- const { insideBox, boxExit, boxSegment } = vdbBoxNodes;
337
- // L960–971
338
- const sampleAlbedo = (localPosition, lod) => source.channels.albedo ? u.baseColor.mul(sample3D("albedo", gridUv(localPosition), lod).rgb) : u.baseColor.mul(vec3(1.0));
339
- // L990–1017, colour via the caller's hook (see VDBVolumeNodesOptions.emissionColor).
340
- const emissionColor = o.emissionColor ?? (() => vec3(1.0));
341
- const sampleEmission = (localPosition, lod) => {
342
- if (!source.channels.emission)
343
- return vec3(0.0);
344
- const range = u.temperatureRange;
345
- const value = sample3D("emission", gridUv(localPosition), lod).r;
346
- const temperature = mix(range.x, range.y, value);
347
- const power = pow(temperature.div(max(range.y, 1.0)), 4.0);
348
- const color = select(temperature.greaterThan(0.0), emissionColor(temperature), vec3(0.0));
349
- return color.mul(power).mul(u.emissiveIntensity);
350
- };
351
- return { getLod, sampleExtinction, sampleAlbedo, sampleEmission, insideBox, boxExit, boxSegment };
352
- }
353
110
  //# sourceMappingURL=volume-source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"volume-source.js","sourceRoot":"","sources":["../../src/three/volume-source.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4FAA4F;AAC5F,sFAAsF;AACtF,wFAAwF;AACxF,iFAAiF;AACjF,iFAAiF;AACjF,4GAA4G;AAC5G,0FAA0F;AAC1F,sGAAsG;AACtG,6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;IACnD,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACpG,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L65–66 (min/maxComponent), L729–763\n// (createVolumeUniforms), L765–798 (setMipUniforms), L834–1028 (createVolumeNodes);\n// src/three-openvdb/frame/core/FrameVolume.js L14–22, L357–405 (Data3DTexture setup);\n// src/three-openvdb/frame/webgpu/FrameRenderer.js L483–487 (configureTexture);\n// src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; absent channels compile to constants instead of runtime flags; the\n// Shadertoy blackbody is not ported (emission colour is a caller hook; his 'planck' / 'soot' table is\n// `vdbFrameBlackbodyEmission`, on an analytic CIE fit: D33).\n// Divergences: DIVERGES.md V23–V25.\n\n/**\n * The dense `.wvdb` volume source in three (K3.0, R1 §4.2).\n *\n * const file = readWvdb(bytes);\n * const volume = wvdbDenseVolume(file); // @pmndrs/vdb/tools: his 8-bit texels + mip atlas\n * const source = vdbDenseTextures(volume); // three Data3DTextures, set up as his FrameVolume\n * const uniforms = vdbVolumeUniforms(source, { extinction: 100 });\n * const nodes = vdbVolumeNodes(source, uniforms, { useMipmaps: true });\n * // inside a TSL Fn: nodes.sampleExtinction(localPos, lod), nodes.sampleAlbedo(...), nodes.boxSegment(...)\n *\n * `vdbVolumeNodes` returns the shape of his `createVolumeNodes()` (`getLod`,\n * `sampleExtinction`, `sampleAlbedo`, `sampleEmission`, `insideBox`, `boxExit`,\n * `boxSegment`), so the K3 port of his materials changes one import per file.\n * Positions are in the local unit box [-0.5, 0.5]³.\n */\n\nimport * as THREE from \"three\";\nimport {\n If,\n abs,\n ceil,\n clamp,\n exp2,\n float,\n floor,\n fract,\n log2,\n max,\n min,\n mix,\n mod,\n pow,\n select,\n texture3D,\n uniform,\n vec2,\n vec3,\n vec4,\n} from \"three/tsl\";\nimport { VDBError } from \"../core/errors.js\";\nimport type { VDBVolumeChannels, VDBVolumeSourceInfo } from \"../core/source/types.js\";\nimport type { WvdbDenseTexture, WvdbDenseVolume } from \"../tools/wvdb/dense.js\";\nimport type { VDBTslNode } from \"./grid-node.js\";\n\ntype ChannelName = \"density\" | \"mask\" | \"albedo\" | \"emission\";\nconst CHANNELS: readonly ChannelName[] = [\"density\", \"mask\", \"albedo\", \"emission\"];\n\n/** The three textures of one channel. */\nexport interface VDBDenseChannelTextures {\n readonly map: THREE.Data3DTexture;\n readonly mip: THREE.Data3DTexture | null;\n}\n\n/** A dense source as three textures (the descriptive part of `VDBVolumeSource`; no raw bindings). */\nexport interface VDBThreeDenseSource extends VDBVolumeSourceInfo {\n readonly kind: \"dense\";\n readonly volume: WvdbDenseVolume;\n readonly textures: Readonly<Record<ChannelName, VDBDenseChannelTextures | null>>;\n /**\n * Swap in another LOD or sequence frame. New sizes make new textures and bump `version`, and so does a frame with\n * another `.wvdb` box (a `VDBFrameVolume` follows by itself, its box too unless it was given a `bbox`; other users\n * call `uniforms.update(source)`). A channel the source has and the frame lacks reads its\n * absent value (mask and albedo 1, emission 0); a channel the source lacks is ignored (warned once). The density's\n * mip atlas must stay if the source has one.\n */\n replace(volume: WvdbDenseVolume): void;\n dispose(): void;\n}\n\n/**\n * FrameVolume.js L14–22 `createTexture3D` + FrameRenderer.js L483–487\n * `configureTexture` (and frameMipmaps.js L183–189 for the atlas): an 8-bit\n * `Data3DTexture`, `RedFormat` or `RGBAFormat`, `unpackAlignment` 1, linear\n * min/mag, no mipmaps, default clamp-to-edge wrapping.\n */\nfunction texture3DFrom(data: Uint8Array<ArrayBuffer>, dims: readonly number[], texelBytes: 1 | 4): THREE.Data3DTexture {\n const [w, h, d] = dims as [number, number, number];\n const texture = new THREE.Data3DTexture(data, w, h, d);\n texture.format = texelBytes === 4 ? THREE.RGBAFormat : THREE.RedFormat;\n texture.type = THREE.UnsignedByteType;\n texture.unpackAlignment = 1;\n texture.minFilter = THREE.LinearFilter;\n texture.magFilter = THREE.LinearFilter;\n texture.generateMipmaps = false;\n texture.needsUpdate = true;\n return texture;\n}\n\nfunction channelTextures(tex: WvdbDenseTexture | null): VDBDenseChannelTextures | null {\n if (!tex) return null;\n return {\n map: texture3DFrom(tex.data, tex.dimensions, tex.texelBytes),\n mip: tex.mip ? texture3DFrom(tex.mip.data, tex.mip.dimensions, tex.texelBytes) : null,\n };\n}\n\n/** K5.9: a channel's absent value (mask and albedo 1, emission 0) as a texture of the density's size (and mip atlas). */\nfunction constantChannel(name: ChannelName, t: VDBDenseChannelTextures, density: WvdbDenseTexture): WvdbDenseTexture {\n const texelBytes: 1 | 4 = t.map.format === THREE.RGBAFormat ? 4 : 1;\n const value = name === \"emission\" ? 0 : 255;\n const fill = (dims: readonly number[]) => new Uint8Array(dims[0]! * dims[1]! * dims[2]! * texelBytes).fill(value);\n const mip = t.mip && density.mip ? { data: fill(density.mip.dimensions), dimensions: density.mip.dimensions, levels: density.mip.levels } : null;\n return { data: fill(density.dimensions), dimensions: density.dimensions, format: texelBytes === 4 ? \"rgba8unorm\" : \"r8unorm\", texelBytes, mip };\n}\n\nconst channelsOf = (v: WvdbDenseVolume): Record<ChannelName, WvdbDenseTexture | null> => ({\n density: v.density,\n mask: v.mask,\n albedo: v.albedo,\n emission: v.emission,\n});\n\nclass ThreeDenseSource implements VDBThreeDenseSource {\n readonly kind = \"dense\" as const;\n readonly boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);\n readonly channels: VDBVolumeChannels;\n volume: WvdbDenseVolume;\n textures: Record<ChannelName, VDBDenseChannelTextures | null>;\n texels: [number, number, number];\n lodLevels: number;\n stats: { meanNonZero: number; max: number; activeVoxels: number };\n version = 0;\n private readonly warnedExtra = new Set<ChannelName>();\n\n constructor(volume: WvdbDenseVolume) {\n this.volume = volume;\n this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };\n const c = channelsOf(volume);\n this.textures = { density: channelTextures(c.density), mask: channelTextures(c.mask), albedo: channelTextures(c.albedo), emission: channelTextures(c.emission) };\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n replace(volume: WvdbDenseVolume): void {\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures.replace: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n const next = channelsOf(volume);\n const densityMip = next.density!.mip;\n if (!!this.textures.density!.mip !== !!densityMip && this.textures.density!.mip) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures.replace: the frame's density has no mip atlas but the source's has; bake every frame with mipmaps, or make the source without.\");\n }\n // K5.9 (sequences): a channel the source has and the frame lacks reads its absent value (mask and albedo 1,\n // emission 0) from a constant texture of the frame's size; a channel (or mip atlas) the source lacks is ignored,\n // since the shaders were built without it (warned once: make the source from a frame that has every channel).\n for (const name of CHANNELS) {\n const t = this.textures[name];\n const v = next[name];\n if (!t && v) {\n if (!this.warnedExtra.has(name)) {\n this.warnedExtra.add(name);\n console.warn(`vdbDenseTextures.replace: the frame has a ${name} channel the source was made without; it is ignored.`);\n }\n next[name] = null;\n } else if (t && !v) {\n next[name] = constantChannel(name, t, next.density!);\n } else if (t && v && !!t.mip !== !!v.mip) {\n if (t.mip) throw new VDBError(\"VDB_BAD_OPTION\", `vdbDenseTextures.replace: the frame's ${name} channel has no mip atlas but the source's has; make a new source.`);\n next[name] = { ...v, mip: null };\n }\n }\n // WVDBLoader.js L37–48 updateTexture: a new size disposes the GPU texture first.\n let resized = false;\n for (const name of CHANNELS) {\n const t = this.textures[name];\n const v = next[name];\n if (!t || !v) continue;\n const set = (tex: THREE.Data3DTexture, data: Uint8Array<ArrayBuffer>, dims: readonly number[]) => {\n const [width, height, depth] = dims as [number, number, number];\n const img = tex.image as { width: number; height: number; depth: number };\n const changed = img.width !== width || img.height !== height || img.depth !== depth;\n tex.image = { data, width, height, depth } as never;\n if (changed) {\n tex.dispose();\n resized = true;\n }\n tex.needsUpdate = true;\n };\n set(t.map, v.data, v.dimensions);\n if (t.mip && v.mip) set(t.mip, v.mip.data, v.mip.dimensions);\n }\n // A frame with another world box (his WVDB sequences give each frame its own) also bumps `version`, so a\n // VDBFrameVolume whose box is the source's moves its box (an empty frame's null box keeps the last one).\n const a = this.volume.bbox;\n const b = volume.bbox;\n const moved = !!b && (!a || a.some((corner, i) => corner.some((v, k) => v !== b[i]![k])));\n if (resized || moved) this.version++;\n this.volume = volume;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = this.textures.density!.mip ? (volume.density.mip?.levels ?? 0) : 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n dispose(): void {\n for (const t of Object.values(this.textures)) {\n t?.map.dispose();\n t?.mip?.dispose();\n }\n }\n}\n\n/** Upload a dense volume (`wvdbDenseVolume`, `@pmndrs/vdb/tools`) as three textures, set up as his `FrameVolume` does. */\nexport function vdbDenseTextures(volume: WvdbDenseVolume): VDBThreeDenseSource {\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n return new ThreeDenseSource(volume);\n}\n\n/**\n * The sparse source (`vdbSparseSource`, `./sparse-source.ts`) as far as this file needs it: it makes\n * its own uniforms and nodes (the K3.1 brief's `nodes(uniforms, options)` factory), so the frame\n * passes take either kind through {@link vdbVolumeUniforms} / {@link vdbVolumeNodes}.\n */\nexport interface VDBThreeSourceFactory extends VDBVolumeSourceInfo {\n readonly kind: \"sparse\";\n /** World box of the volume (`[min, max]`), the default `VDBFrameVolume` box. */\n readonly bbox: [[number, number, number], [number, number, number]];\n createUniforms(p: VDBVolumeUniformParameters): VDBVolumeUniforms;\n createNodes(u: VDBVolumeUniforms, o: VDBVolumeNodesOptions): VDBVolumeNodes;\n dispose(): void;\n}\n\n/** A volume source the three frame passes read: dense textures or the sparse pool. */\nexport type VDBThreeVolumeSource = VDBThreeDenseSource | VDBThreeSourceFactory;\n\n/** Initial values of {@link vdbVolumeUniforms} (his `FrameVolume` props of the same names and defaults). */\nexport interface VDBVolumeUniformParameters {\n /** Optical depth of the longest box side at the mean density, with `normalizeDensity` (default 100). */\n extinction?: number;\n /** Density multiplier (default 1); with `normalizeDensity` it divides by `stats.meanNonZero`. */\n densityScale?: number;\n normalizeDensity?: boolean;\n densityCutoff?: number;\n baseColor?: THREE.ColorRepresentation;\n emissiveIntensity?: number;\n /** Kelvin at emission values 0 and 1 (default [0, 6500]). */\n temperatureRange?: [number, number];\n offset3D?: THREE.Vector3Like;\n wrap3D?: THREE.Wrapping;\n /** `matrixWorld.getMaxScaleOnAxis()` of the volume (default 1). */\n worldScale?: number;\n}\n\n/** His `createVolumeUniforms()` subset the source reads (frameShaderChunks.js L729–763), as live TSL uniforms. */\nexport interface VDBVolumeUniforms {\n readonly worldScale: VDBTslNode;\n readonly gridTexels: VDBTslNode;\n readonly mipAtlasSize: VDBTslNode;\n readonly maps: Readonly<Record<ChannelName, VDBTslNode | null>>;\n readonly mipMaps: Readonly<Record<ChannelName, VDBTslNode | null>>;\n readonly mipLevels: Readonly<Record<ChannelName, VDBTslNode>>;\n readonly baseColor: VDBTslNode;\n readonly extinction: VDBTslNode;\n readonly densityScale: VDBTslNode;\n readonly densityCutoff: VDBTslNode;\n readonly emissiveIntensity: VDBTslNode;\n readonly temperatureRange: VDBTslNode;\n readonly offset3D: VDBTslNode;\n readonly wrap3D: VDBTslNode;\n /** Re-read textures, sizes and the normalized density scale after `source.replace` (setMipUniforms, L773–798). */\n update(source: VDBThreeVolumeSource, o?: { densityScale?: number; normalizeDensity?: boolean }): void;\n /**\n * Stops following the source: a sparse source drops the listeners these uniforms registered (its stats and, with\n * `followImage`, its layout), which it otherwise keeps for its lifetime. `VDBFrameVolume.dispose()` calls it; call it\n * yourself for uniforms you made with `vdbVolumeUniforms`. A no-op for a dense source. Idempotent.\n */\n dispose(): void;\n}\n\n/** FrameVolume.js L561–568 `getDensityScale`. */\nexport const vdbDensityScaleOf = (source: VDBVolumeSourceInfo, densityScale: number, normalize: boolean): number =>\n normalize && source.stats.meanNonZero > 0 ? densityScale / source.stats.meanNonZero : densityScale;\nconst densityScaleOf = vdbDensityScaleOf;\n\n/**\n * Live uniforms for one source (his `createVolumeUniforms` + `setVolumeUniforms` + `setMipUniforms`).\n * A sparse source makes its own (`source.createUniforms`), with the same fields.\n */\nexport function vdbVolumeUniforms(source: VDBThreeVolumeSource, p: VDBVolumeUniformParameters = {}): VDBVolumeUniforms {\n if (source.kind === \"sparse\") return source.createUniforms(p);\n const tex = source.textures;\n let densityScale = p.densityScale ?? 1.0;\n let normalize = p.normalizeDensity ?? true;\n const maps = {} as Record<ChannelName, VDBTslNode | null>;\n const mipMaps = {} as Record<ChannelName, VDBTslNode | null>;\n const mipLevels = {} as Record<ChannelName, VDBTslNode>;\n for (const name of CHANNELS) {\n maps[name] = tex[name] ? texture3D(tex[name]!.map) : null;\n mipMaps[name] = tex[name]?.mip ? texture3D(tex[name]!.mip!) : null;\n mipLevels[name] = uniform(0.0);\n }\n const gridTexels = uniform(new THREE.Vector3(1, 1, 1));\n const mipAtlasSize = uniform(new THREE.Vector3(1, 1, 1));\n const densityScaleU = uniform(densityScaleOf(source, densityScale, normalize));\n const u: VDBVolumeUniforms = {\n worldScale: uniform(p.worldScale ?? 1.0),\n gridTexels,\n mipAtlasSize,\n maps,\n mipMaps,\n mipLevels,\n baseColor: uniform(new THREE.Color(p.baseColor ?? 0xffffff)),\n extinction: uniform(p.extinction ?? 100.0),\n densityScale: densityScaleU,\n densityCutoff: uniform(p.densityCutoff ?? 0.0),\n emissiveIntensity: uniform(p.emissiveIntensity ?? 1.0),\n temperatureRange: uniform(new THREE.Vector2(...(p.temperatureRange ?? [0.0, 6500.0]))),\n offset3D: uniform(new THREE.Vector3().copy((p.offset3D ?? { x: 0, y: 0, z: 0 }) as THREE.Vector3)),\n wrap3D: uniform(p.wrap3D ?? THREE.ClampToEdgeWrapping, \"int\"),\n update(s0, o = {}) {\n if (s0.kind !== \"dense\") throw new VDBError(\"VDB_BAD_OPTION\", \"vdbVolumeUniforms: these uniforms belong to a dense source.\");\n const s = s0;\n if (o.densityScale !== undefined) densityScale = o.densityScale;\n if (o.normalizeDensity !== undefined) normalize = o.normalizeDensity;\n densityScaleU.value = densityScaleOf(s, densityScale, normalize);\n const [w, h, d] = s.texels;\n gridTexels.value.set(w, h, d);\n const densityMip = s.textures.density?.mip;\n if (densityMip) {\n const img = densityMip.image as { width: number; height: number; depth: number };\n mipAtlasSize.value.set(img.width, img.height, img.depth);\n }\n for (const name of CHANNELS) {\n const t = s.textures[name];\n if (t && maps[name]) maps[name].value = t.map;\n if (t?.mip && mipMaps[name]) mipMaps[name].value = t.mip;\n // Every channel shares the density size (wvdbDenseVolume checks it), so all levels are the mip's.\n // A channel the frame lacks (K5.9: a constant texture) has the density's levels.\n mipLevels[name].value = densityMip && t?.mip ? (s.volume[name]?.mip?.levels ?? s.volume.density.mip?.levels ?? 0) : 0;\n }\n },\n dispose() {\n // A dense source registers nothing.\n },\n };\n u.update(source);\n return u;\n}\n\n/** Options of {@link vdbVolumeNodes}. */\nexport interface VDBVolumeNodesOptions {\n /** Sample the CPU mip atlas at `lod` (his shaders built with `useMipmaps`). Default: the source has mips. */\n useMipmaps?: boolean;\n /**\n * Emission colour from temperature (Kelvin node) → vec3 node. Default: white.\n * His `'approximate'` blackbody is from Shadertoy (CC BY-NC-SA unless stated) and is not\n * ported (R1 §7); his `'planck'`/`'soot'` table is the hook `vdbFrameBlackbodyEmission` (K3.6; its CIE 1931\n * colour matching functions are the Wyman–Sloan–Shirley 2013 analytic fit, D33).\n */\n emissionColor?: (temperature: VDBTslNode) => VDBTslNode;\n}\n\n/** The node factory of his `createVolumeNodes()` (frameShaderChunks.js L834–1028). */\nexport interface VDBVolumeNodes {\n getLod(localSize: VDBTslNode): VDBTslNode;\n sampleExtinction(localPosition: VDBTslNode, lod: VDBTslNode): VDBTslNode;\n sampleAlbedo(localPosition: VDBTslNode, lod: VDBTslNode): VDBTslNode;\n sampleEmission(localPosition: VDBTslNode, lod: VDBTslNode): VDBTslNode;\n insideBox(localPosition: VDBTslNode): VDBTslNode;\n boxExit(origin: VDBTslNode, direction: VDBTslNode): VDBTslNode;\n boxSegment(start: VDBTslNode, end: VDBTslNode): VDBTslNode;\n /**\n * Sparse sources only (K3.2): the empty-space query of a march along `origin + direction·t`\n * (local units) whose samples are read at `lod`. Returns `vec2(ts, te)`: every sample with\n * `t < ts` is exactly 0 (skip it), the samples in `[ts, te)` must be read, ask again from `te`.\n * When no safe bound exists (a coarse level, wrapping, an offset) it returns `(t0, 1e30)`.\n * Call in the Fn body. Absent for dense sources (no skipping).\n */\n skipEmpty?(origin: VDBTslNode, direction: VDBTslNode, t0: VDBTslNode, t1: VDBTslNode, lod: VDBTslNode): VDBTslNode;\n}\n\n/** frameShaderChunks.js L65–66. */\nexport const vdbMinComponent = (v: VDBTslNode): VDBTslNode => min(v.x, min(v.y, v.z));\nexport const vdbMaxComponent = (v: VDBTslNode): VDBTslNode => max(v.x, max(v.y, v.z));\n\n/**\n * Sampling of one dense source, in his `createVolumeNodes` shape. Call the\n * sample functions inside a TSL `Fn` body. Absent channels give his fallbacks\n * (mask 1, albedo `baseColor`, emission 0) without sampling.\n */\n/**\n * His mip sampling (frameShaderChunks.js L838–872) over one texture and its box mip atlas:\n * `sampleMipAtlas` (level 1 and up, frameMipmaps.js layout) and `sampleMipmapped` (linear between\n * two levels). `gridTexels` is the size of `map` (level 0 of this chain), `mipAtlasSize` the atlas's.\n * Shared by the dense source and the sparse source's coarse pyramid. Call in a TSL Fn body.\n */\nexport function vdbMipSampler(gridTexels: VDBTslNode, mipAtlasSize: VDBTslNode): {\n sampleMipAtlas(mipMap: VDBTslNode, level: VDBTslNode, uvw: VDBTslNode): VDBTslNode;\n sampleMipmapped(map: VDBTslNode, mipMap: VDBTslNode, levels: VDBTslNode, position: VDBTslNode, lod: VDBTslNode): VDBTslNode;\n} {\n // L838–846: level 1 and up of the mip atlas (layout of frameMipmaps.js).\n const sampleMipAtlas = (mipMap: VDBTslNode, level: VDBTslNode, uvw: VDBTslNode): VDBTslNode => {\n const size = max(vec3(1.0), ceil(gridTexels.div(exp2(level))));\n const offset = mipAtlasSize.x.sub(mipAtlasSize.x.div(exp2(level.sub(1.0))));\n const texel = clamp(uvw.mul(size), vec3(0.5), size.sub(0.5));\n return mipMap.sample(vec3(texel.x.add(offset), texel.y, texel.z).div(mipAtlasSize)).level(float(0.0));\n };\n\n // L849–872: linear between two mip levels (LinearMipmapLinearFilter).\n const sampleMipmapped = (map: VDBTslNode, mipMap: VDBTslNode, levels: VDBTslNode, position: VDBTslNode, lod: VDBTslNode): VDBTslNode => {\n const uvw = vec3(position).toVar();\n const result = vec4(0.0).toVar();\n const level = min(lod, levels).toVar();\n If(level.lessThanEqual(0.0), () => {\n result.assign(map.sample(uvw).level(float(0.0)));\n }).Else(() => {\n const level0 = floor(level).toVar();\n const low = vec4(0.0).toVar();\n If(level0.lessThan(0.5), () => {\n low.assign(map.sample(uvw).level(float(0.0)));\n }).Else(() => {\n low.assign(sampleMipAtlas(mipMap, level0, uvw));\n });\n const high = sampleMipAtlas(mipMap, min(level0.add(1.0), levels), uvw);\n result.assign(mix(low, high, level.sub(level0)));\n });\n return result;\n };\n return { sampleMipAtlas, sampleMipmapped };\n}\n\n/** His `wrapUv` / `gridUv` (frameShaderChunks.js L894–911): the local position as a wrapped, offset uvw. */\nexport function vdbGridUv(u: Pick<VDBVolumeUniforms, \"wrap3D\" | \"offset3D\">): (localPosition: VDBTslNode) => VDBTslNode {\n const T = THREE as unknown as Record<string, number>;\n const mirrorAxis = (value: VDBTslNode) => {\n const period = mod(value, 2.0);\n return select(period.greaterThan(1.0), float(2.0).sub(period), period);\n };\n const wrapUv = (uvw: VDBTslNode) =>\n select(\n u.wrap3D.equal(T.RepeatWrapping!),\n fract(uvw),\n select(u.wrap3D.equal(T.MirroredRepeatWrapping!), vec3(mirrorAxis(uvw.x), mirrorAxis(uvw.y), mirrorAxis(uvw.z)), uvw),\n );\n return (localPosition: VDBTslNode) => wrapUv(localPosition.add(0.5).add(u.offset3D));\n}\n\n/** His box geometry (frameShaderChunks.js L938–958): `insideBox`, `boxExit`, `boxSegment` of the local unit box. */\nexport const vdbBoxNodes = {\n insideBox: (localPosition: VDBTslNode) => vdbMaxComponent(abs(localPosition)).lessThanEqual(0.5),\n boxExit: (origin: VDBTslNode, direction: VDBTslNode) => {\n const inverseDirection = vec3(1.0).div(direction);\n const tMin = vec3(-0.5).sub(origin).mul(inverseDirection);\n const tMax = vec3(0.5).sub(origin).mul(inverseDirection);\n return max(0.0, vdbMinComponent(max(tMin, tMax)));\n },\n boxSegment: (start: VDBTslNode, end: VDBTslNode) => {\n const inverseDirection = vec3(1.0).div(end.sub(start));\n const tMin = vec3(-0.5).sub(start).mul(inverseDirection);\n const tMax = vec3(0.5).sub(start).mul(inverseDirection);\n return vec2(max(0.0, vdbMaxComponent(min(tMin, tMax))), min(1.0, vdbMinComponent(max(tMin, tMax))));\n },\n};\n\nexport function vdbVolumeNodes(source: VDBThreeVolumeSource, u: VDBVolumeUniforms, o: VDBVolumeNodesOptions = {}): VDBVolumeNodes {\n if (source.kind === \"sparse\") return source.createNodes(u, o);\n const useMipmaps = o.useMipmaps ?? source.lodLevels > 0;\n const { gridTexels, mipAtlasSize } = u;\n const { sampleMipmapped } = vdbMipSampler(gridTexels, mipAtlasSize);\n\n // L874–877 sample3D (a channel without a mip atlas samples level 0).\n const sample3D = (name: ChannelName, uvw: VDBTslNode, lod: VDBTslNode): VDBTslNode => {\n const map = u.maps[name]!;\n const mip = u.mipMaps[name];\n return useMipmaps && mip ? sampleMipmapped(map, mip, u.mipLevels[name], uvw, lod) : map.sample(uvw).level(float(0.0));\n };\n\n // L892\n const getLod = (localSize: VDBTslNode) => max(0.0, log2(localSize.mul(vdbMaxComponent(gridTexels))));\n\n // L894–911\n const gridUv = vdbGridUv(u);\n\n // L914–936: extinction per world unit. The mask is read at local + 0.5 (no offset or wrap), as his.\n const sampleExtinction = (localPosition: VDBTslNode, lod: VDBTslNode) => {\n const mask = source.channels.mask ? sample3D(\"mask\", localPosition.add(0.5), lod).r : float(1.0);\n const value = sample3D(\"density\", gridUv(localPosition), lod).r.mul(mask);\n return select(value.greaterThan(u.densityCutoff), value, float(0.0)).mul(u.densityScale).mul(u.extinction).div(u.worldScale);\n };\n\n // L938–958\n const { insideBox, boxExit, boxSegment } = vdbBoxNodes;\n\n // L960–971\n const sampleAlbedo = (localPosition: VDBTslNode, lod: VDBTslNode) =>\n source.channels.albedo ? u.baseColor.mul(sample3D(\"albedo\", gridUv(localPosition), lod).rgb) : u.baseColor.mul(vec3(1.0));\n\n // L990–1017, colour via the caller's hook (see VDBVolumeNodesOptions.emissionColor).\n const emissionColor = o.emissionColor ?? (() => vec3(1.0));\n const sampleEmission = (localPosition: VDBTslNode, lod: VDBTslNode) => {\n if (!source.channels.emission) return vec3(0.0);\n const range = u.temperatureRange;\n const value = sample3D(\"emission\", gridUv(localPosition), lod).r;\n const temperature = mix(range.x, range.y, value);\n const power = pow(temperature.div(max(range.y, 1.0)), 4.0);\n const color = select(temperature.greaterThan(0.0), emissionColor(temperature), vec3(0.0));\n return color.mul(power).mul(u.emissiveIntensity);\n };\n\n return { getLod, sampleExtinction, sampleAlbedo, sampleEmission, insideBox, boxExit, boxSegment };\n}\n"]}
1
+ {"version":3,"file":"vol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CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;IAC9G,CAAC;IAED,OAAO;QACL,mFAAmF;IACrF,CAAC;CACF;AAED,wGAAwG;AACxG,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACtD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,mFAAmF,CAAC,CAAC;IAC5H,CAAC;IACD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/FrameVolume.js L14–22, L357–405 (the dense texture setup this handle describes);\n// src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; K6.11 (D35): a handle only. His `createVolumeUniforms` / `createVolumeNodes` shape (the TSL half,\n// `vdbVolumeUniforms` / `vdbVolumeNodes`) and the three textures are deleted: the core's `vdbDenseSource` reads the volume.\n// Divergences: DIVERGES.md V23–V25.\n\n/**\n * The dense `.wvdb` volume source in three (K3.0, R1 §4.2): a handle `VDBFrameVolume` draws.\n *\n * const file = readWvdb(bytes);\n * const volume = wvdbDenseVolume(file); // @pmndrs/vdb/tools: his 8-bit texels + mip atlas\n * const source = vdbDenseTextures(volume); // the handle\n * const frameVolume = new VDBFrameVolume(source, { extinction: 100 });\n *\n * K6.11: the handle holds no GPU object. `VDBFrameRenderer` reads `source.volume` into the core's dense source\n * (`vdbDenseSource`, which makes the textures and the `vdbSrc*` WGSL). A custom TSL material samples a pooled grid\n * through `VDBGridNode`; custom WGSL or compute uses the core source's `wgsl()`.\n */\n\nimport { VDBError } from \"../core/errors.js\";\nimport type { VDBVolumeChannels, VDBVolumeSourceInfo } from \"../core/source/types.js\";\nimport type { WvdbDenseTexture, WvdbDenseVolume } from \"../tools/wvdb/dense.js\";\nimport type { VDBThreeSparseSource } from \"./sparse-source.js\";\n\ntype ChannelName = \"density\" | \"mask\" | \"albedo\" | \"emission\";\nconst CHANNELS: readonly ChannelName[] = [\"density\", \"mask\", \"albedo\", \"emission\"];\n\n/** A dense source as a handle (the descriptive part of `VDBVolumeSource`; no raw bindings). */\nexport interface VDBThreeDenseSource extends VDBVolumeSourceInfo {\n /** Always `\"dense\"`. */\n readonly kind: \"dense\";\n /** The `.wvdb` volume currently set (`VDBFrameVolume`: the core frame renderer uploads it into its own textures). */\n readonly volume: WvdbDenseVolume;\n /**\n * Swap in another LOD or sequence frame. New sizes bump `version`, and so does a frame with another `.wvdb` box\n * (a `VDBFrameVolume` follows by itself, its box too unless it was given a `bbox`). A channel the source lacks is\n * ignored (warned once). The density's mip atlas must stay if the source has one.\n */\n replace(volume: WvdbDenseVolume): void;\n /** Releases the handle (it holds no GPU object). */\n dispose(): void;\n}\n\n/** A volume source `VDBFrameVolume` reads: a dense `.wvdb` volume or a pool grid. */\nexport type VDBThreeVolumeSource = VDBThreeDenseSource | VDBThreeSparseSource;\n\nconst channelsOf = (v: WvdbDenseVolume): Record<ChannelName, WvdbDenseTexture | null> => ({\n density: v.density,\n mask: v.mask,\n albedo: v.albedo,\n emission: v.emission,\n});\n\n/** Which channels (and whether each has a mip atlas) a dense source was made with; fixed for its life. */\ntype DenseShape = Record<ChannelName, { mip: boolean } | null>;\n\nconst sameDims = (a: readonly number[] | undefined, b: readonly number[] | undefined): boolean => !!a && !!b && a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n\nclass ThreeDenseSource implements VDBThreeDenseSource {\n readonly kind = \"dense\" as const;\n readonly boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);\n readonly channels: VDBVolumeChannels;\n volume: WvdbDenseVolume;\n texels: [number, number, number];\n lodLevels: number;\n stats: { meanNonZero: number; max: number; activeVoxels: number };\n version = 0;\n private readonly warnedExtra = new Set<ChannelName>();\n readonly #shape: DenseShape;\n\n constructor(volume: WvdbDenseVolume) {\n this.volume = volume;\n this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };\n const c = channelsOf(volume);\n this.#shape = Object.fromEntries(CHANNELS.map((n) => [n, c[n] ? { mip: !!c[n]!.mip } : null])) as DenseShape;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n replace(volume: WvdbDenseVolume): void {\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures.replace: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n const shape = this.#shape;\n const next = channelsOf(volume);\n const densityMip = next.density!.mip;\n if (!!shape.density!.mip !== !!densityMip && shape.density!.mip) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures.replace: the frame's density has no mip atlas but the source's has; bake every frame with mipmaps, or make the source without.\");\n }\n // K5.9 (sequences): a channel the source has and the frame lacks reads its absent value (mask and albedo 1,\n // emission 0; the core's dense source does that); a channel (or mip atlas) the source lacks is ignored, since the\n // shaders were built without it (warned once: make the source from a frame that has every channel).\n for (const name of CHANNELS) {\n const s = shape[name];\n const v = next[name];\n if (!s && v) {\n if (!this.warnedExtra.has(name)) {\n this.warnedExtra.add(name);\n console.warn(`vdbDenseTextures.replace: the frame has a ${name} channel the source was made without; it is ignored.`);\n }\n next[name] = null;\n } else if (s && v && s.mip !== !!v.mip && s.mip) {\n throw new VDBError(\"VDB_BAD_OPTION\", `vdbDenseTextures.replace: the frame's ${name} channel has no mip atlas but the source's has; make a new source.`);\n }\n }\n // WVDBLoader.js L37–48 updateTexture: a new size is a new texture (here: bumps `version`).\n const before = channelsOf(this.volume);\n let resized = false;\n for (const name of CHANNELS) {\n const o = before[name];\n const v = next[name];\n if (!o || !v) continue;\n if (!sameDims(o.dimensions, v.dimensions) || (!!o.mip && !!v.mip && !sameDims(o.mip.dimensions, v.mip.dimensions))) resized = true;\n }\n // A frame with another world box (his WVDB sequences give each frame its own) also bumps `version`, so a\n // VDBFrameVolume whose box is the source's moves its box (an empty frame's null box keeps the last one).\n const a = this.volume.bbox;\n const b = volume.bbox;\n const moved = !!b && (!a || a.some((corner, i) => corner.some((v, k) => v !== b[i]![k])));\n if (resized || moved) this.version++;\n this.volume = volume;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = shape.density!.mip ? (volume.density.mip?.levels ?? 0) : 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n dispose(): void {\n // No GPU object: the core's dense source (the frame renderer's) owns the textures.\n }\n}\n\n/** A dense `.wvdb` volume (`wvdbDenseVolume`, `@pmndrs/vdb/tools`) as a handle for `VDBFrameVolume`. */\nexport function vdbDenseTextures(volume: WvdbDenseVolume): VDBThreeDenseSource {\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n return new ThreeDenseSource(volume);\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import type { VDBVec3 } from "../vdb/types.js";
2
+ /** pmndrs/pathtracer's V3.2 sparse brick atlas (its `BrickAtlas`), built by {@link vdbBrickAtlas}. */
3
+ export interface VDBBrickAtlas {
4
+ /** The dense grid's voxel counts (`[0, resolution)` in index space). */
5
+ resolution: VDBVec3;
6
+ /** Bricks per axis over the grid: `floor((resolution + 8) / 8)` (its `brickDims`). */
7
+ cells: VDBVec3;
8
+ /** Atlas size in bricks. */
9
+ bricks: VDBVec3;
10
+ /** Atlas size in texels (`bricks * 9`). */
11
+ dims: VDBVec3;
12
+ /** The atlas texels, x fastest; voxels outside the grid (and empty texels) are 0. */
13
+ data: Float32Array;
14
+ /** One texel per brick of `cells`, x fastest: `0xffffffff` (empty) or `bx | by << 10 | bz << 20` (atlas brick). */
15
+ indirection: Uint32Array;
16
+ /** Occupied bricks. */
17
+ occupied: number;
18
+ }
19
+ /** Options of {@link vdbBrickAtlas}. */
20
+ export interface VDBBrickAtlasOptions {
21
+ /** The dense grid's voxel counts. Default `indexBBoxMax + 1` (the grid's bbox must lie in `[0, resolution - 1]`). */
22
+ resolution?: VDBVec3;
23
+ }
24
+ /**
25
+ * Builds pmndrs/pathtracer's V3.2 brick atlas and indirection (`volumes.gridLayout: 'atlas'`) from a NanoVDB grid image
26
+ * (P1.12): the arrays its `buildBrickAtlas(resolution, dense)` gives for the dense grid of the same field, without
27
+ * making that dense grid. Values come from the tree (leaf voxels active or not, tiles, the background), 0 outside the
28
+ * index bbox and outside `[0, resolution)` (the P1.1 contract: for a `vdbBuildFromDense` image of its array, the
29
+ * same array). Works on every scalar grid type (Fp values as decoded by the readers).
30
+ *
31
+ * @param image The grid image (little-endian u32 words, `GridData` at word 0).
32
+ * @param options The dense grid's resolution.
33
+ * @throws VDBToolsError `VDB_BAD_OPTION` for a bad resolution, a bbox outside it, or more occupied bricks than its
34
+ * 10-bit atlas coordinates hold.
35
+ */
36
+ export declare function vdbBrickAtlas(image: Uint32Array, options?: VDBBrickAtlasOptions): VDBBrickAtlas;