@pmndrs/vdb 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (576) hide show
  1. package/CHANGELOG.md +592 -2
  2. package/README.md +85 -37
  3. package/THIRD_PARTY_NOTICES.md +197 -29
  4. package/dist/core/compute/atlas.d.ts +10 -2
  5. package/dist/core/compute/atlas.js +6 -1
  6. package/dist/core/compute/atlas.js.map +1 -1
  7. package/dist/core/compute/index.d.ts +3 -3
  8. package/dist/core/compute/index.js +2 -2
  9. package/dist/core/compute/index.js.map +1 -1
  10. package/dist/core/compute/majorant-build.d.ts +45 -0
  11. package/dist/core/compute/majorant-build.js +193 -0
  12. package/dist/core/compute/majorant-build.js.map +1 -0
  13. package/dist/core/compute/multi-scale.d.ts +155 -0
  14. package/dist/core/compute/multi-scale.js +684 -0
  15. package/dist/core/compute/multi-scale.js.map +1 -0
  16. package/dist/core/compute/pyramid.d.ts +22 -7
  17. package/dist/core/compute/pyramid.js +22 -9
  18. package/dist/core/compute/pyramid.js.map +1 -1
  19. package/dist/core/compute/shared.d.ts +1 -0
  20. package/dist/core/compute/shared.js.map +1 -1
  21. package/dist/core/compute/stats.d.ts +10 -3
  22. package/dist/core/compute/stats.js +6 -1
  23. package/dist/core/compute/stats.js.map +1 -1
  24. package/dist/core/compute/value-transform.d.ts +8 -1
  25. package/dist/core/compute/value-transform.js +9 -3
  26. package/dist/core/compute/value-transform.js.map +1 -1
  27. package/dist/core/errors.d.ts +10 -0
  28. package/dist/core/errors.js +8 -0
  29. package/dist/core/errors.js.map +1 -1
  30. package/dist/core/frame/emission.d.ts +85 -0
  31. package/dist/core/frame/emission.js +422 -0
  32. package/dist/core/frame/emission.js.map +1 -0
  33. package/dist/core/frame/environment.d.ts +47 -0
  34. package/dist/core/frame/environment.js +178 -0
  35. package/dist/core/frame/environment.js.map +1 -0
  36. package/dist/core/frame/index.d.ts +39 -0
  37. package/dist/core/frame/index.js +27 -0
  38. package/dist/core/frame/index.js.map +1 -0
  39. package/dist/core/frame/kernels.d.ts +115 -0
  40. package/dist/core/frame/kernels.js +496 -0
  41. package/dist/core/frame/kernels.js.map +1 -0
  42. package/dist/core/frame/limits.d.ts +67 -0
  43. package/dist/core/frame/limits.js +109 -0
  44. package/dist/core/frame/limits.js.map +1 -0
  45. package/dist/core/frame/phase.d.ts +17 -0
  46. package/dist/core/frame/phase.js +53 -0
  47. package/dist/core/frame/phase.js.map +1 -0
  48. package/dist/core/frame/pipelines.d.ts +49 -0
  49. package/dist/core/frame/pipelines.js +147 -0
  50. package/dist/core/frame/pipelines.js.map +1 -0
  51. package/dist/core/frame/renderer.d.ts +122 -0
  52. package/dist/core/frame/renderer.js +1712 -0
  53. package/dist/core/frame/renderer.js.map +1 -0
  54. package/dist/core/frame/resources.d.ts +71 -0
  55. package/dist/core/frame/resources.js +100 -0
  56. package/dist/core/frame/resources.js.map +1 -0
  57. package/dist/core/frame/scattering.d.ts +97 -0
  58. package/dist/core/frame/scattering.js +332 -0
  59. package/dist/core/frame/scattering.js.map +1 -0
  60. package/dist/core/frame/settings.d.ts +243 -0
  61. package/dist/core/frame/settings.js +67 -0
  62. package/dist/core/frame/settings.js.map +1 -0
  63. package/dist/core/frame/shadows.d.ts +55 -0
  64. package/dist/core/frame/shadows.js +460 -0
  65. package/dist/core/frame/shadows.js.map +1 -0
  66. package/dist/core/frame/types.d.ts +415 -0
  67. package/dist/core/frame/types.js +49 -0
  68. package/dist/core/frame/types.js.map +1 -0
  69. package/dist/core/frame/uniforms.d.ts +105 -0
  70. package/dist/core/frame/uniforms.js +276 -0
  71. package/dist/core/frame/uniforms.js.map +1 -0
  72. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  73. package/dist/core/frame/wgsl/chunks.js +728 -0
  74. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  75. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  76. package/dist/core/frame/wgsl/emission.js +353 -0
  77. package/dist/core/frame/wgsl/emission.js.map +1 -0
  78. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  79. package/dist/core/frame/wgsl/environment.js +711 -0
  80. package/dist/core/frame/wgsl/environment.js.map +1 -0
  81. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  82. package/dist/core/frame/wgsl/gather.js +850 -0
  83. package/dist/core/frame/wgsl/gather.js.map +1 -0
  84. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  85. package/dist/core/frame/wgsl/integrate.js +213 -0
  86. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  87. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  88. package/dist/core/frame/wgsl/lighting.js +1636 -0
  89. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  90. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  91. package/dist/core/frame/wgsl/occluders.js +95 -0
  92. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  93. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  94. package/dist/core/frame/wgsl/resolve.js +205 -0
  95. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  96. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  97. package/dist/core/frame/wgsl/shadows.js +328 -0
  98. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  99. package/dist/core/half.d.ts +11 -0
  100. package/dist/core/half.js +22 -0
  101. package/dist/core/half.js.map +1 -0
  102. package/dist/core/index.d.ts +25 -3
  103. package/dist/core/index.js +23 -4
  104. package/dist/core/index.js.map +1 -1
  105. package/dist/core/internal.d.ts +17 -1
  106. package/dist/core/internal.js +18 -1
  107. package/dist/core/internal.js.map +1 -1
  108. package/dist/core/pool/image-header.d.ts +13 -2
  109. package/dist/core/pool/image-header.js +24 -5
  110. package/dist/core/pool/image-header.js.map +1 -1
  111. package/dist/core/pool/layout.d.ts +35 -1
  112. package/dist/core/pool/layout.js +51 -2
  113. package/dist/core/pool/layout.js.map +1 -1
  114. package/dist/core/pool/limits.d.ts +1 -0
  115. package/dist/core/pool/limits.js +1 -0
  116. package/dist/core/pool/limits.js.map +1 -1
  117. package/dist/core/pool/pool.d.ts +120 -15
  118. package/dist/core/pool/pool.js +255 -24
  119. package/dist/core/pool/pool.js.map +1 -1
  120. package/dist/core/reference/index.d.ts +6 -0
  121. package/dist/core/reference/index.js +7 -0
  122. package/dist/core/reference/index.js.map +1 -0
  123. package/dist/core/reference/renderer.d.ts +105 -0
  124. package/dist/core/reference/renderer.js +474 -0
  125. package/dist/core/reference/renderer.js.map +1 -0
  126. package/dist/core/reference/wgsl.d.ts +65 -0
  127. package/dist/core/reference/wgsl.js +803 -0
  128. package/dist/core/reference/wgsl.js.map +1 -0
  129. package/dist/{three → core}/sequence.d.ts +32 -2
  130. package/dist/{three → core}/sequence.js +24 -2
  131. package/dist/core/sequence.js.map +1 -0
  132. package/dist/core/source/brick-cache.d.ts +165 -0
  133. package/dist/core/source/brick-cache.js +627 -0
  134. package/dist/core/source/brick-cache.js.map +1 -0
  135. package/dist/core/source/dense-fill.d.ts +53 -0
  136. package/dist/core/source/dense-fill.js +377 -0
  137. package/dist/core/source/dense-fill.js.map +1 -0
  138. package/dist/core/source/dense.d.ts +33 -2
  139. package/dist/core/source/dense.js +121 -24
  140. package/dist/core/source/dense.js.map +1 -1
  141. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  142. package/dist/core/source/sparse-wgsl.js +481 -0
  143. package/dist/core/source/sparse-wgsl.js.map +1 -0
  144. package/dist/core/source/sparse.d.ts +192 -0
  145. package/dist/core/source/sparse.js +762 -0
  146. package/dist/core/source/sparse.js.map +1 -0
  147. package/dist/core/source/types.d.ts +59 -2
  148. package/dist/core/source/types.js.map +1 -1
  149. package/dist/core/surface/index.d.ts +10 -0
  150. package/dist/core/surface/index.js +9 -0
  151. package/dist/core/surface/index.js.map +1 -0
  152. package/dist/core/surface/level-set-pass.d.ts +140 -0
  153. package/dist/core/surface/level-set-pass.js +291 -0
  154. package/dist/core/surface/level-set-pass.js.map +1 -0
  155. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  156. package/dist/core/surface/level-set-wgsl.js +99 -0
  157. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  158. package/dist/core/surface/points.d.ts +109 -0
  159. package/dist/core/surface/points.js +226 -0
  160. package/dist/core/surface/points.js.map +1 -0
  161. package/dist/core/types.d.ts +12 -3
  162. package/dist/core/types.js +6 -2
  163. package/dist/core/types.js.map +1 -1
  164. package/dist/core/wgsl/api.d.ts +29 -5
  165. package/dist/core/wgsl/api.js +110 -27
  166. package/dist/core/wgsl/api.js.map +1 -1
  167. package/dist/core/wgsl/generate.d.ts +8 -0
  168. package/dist/core/wgsl/generate.js +195 -22
  169. package/dist/core/wgsl/generate.js.map +1 -1
  170. package/dist/core/wgsl/lean.d.ts +50 -0
  171. package/dist/core/wgsl/lean.js +327 -0
  172. package/dist/core/wgsl/lean.js.map +1 -0
  173. package/dist/core/wgsl/level-set.d.ts +5 -1
  174. package/dist/core/wgsl/level-set.js +11 -5
  175. package/dist/core/wgsl/level-set.js.map +1 -1
  176. package/dist/core/wgsl/majorant.d.ts +62 -0
  177. package/dist/core/wgsl/majorant.js +381 -0
  178. package/dist/core/wgsl/majorant.js.map +1 -0
  179. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
  180. package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
  181. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
  182. package/dist/core/wgsl/types.d.ts +97 -3
  183. package/dist/core/wgsl/types.js.map +1 -1
  184. package/dist/three/coarse-first.d.ts +53 -8
  185. package/dist/three/coarse-first.js +24 -6
  186. package/dist/three/coarse-first.js.map +1 -1
  187. package/dist/three/compute.d.ts +12 -2
  188. package/dist/three/compute.js +16 -6
  189. package/dist/three/compute.js.map +1 -1
  190. package/dist/three/device.d.ts +7 -0
  191. package/dist/three/device.js +3 -0
  192. package/dist/three/device.js.map +1 -1
  193. package/dist/three/frame/core-environment.d.ts +38 -0
  194. package/dist/three/frame/core-environment.js +154 -0
  195. package/dist/three/frame/core-environment.js.map +1 -0
  196. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  197. package/dist/three/frame/core-integrate-material.js +162 -0
  198. package/dist/three/frame/core-integrate-material.js.map +1 -0
  199. package/dist/three/frame/core-occluders.d.ts +53 -0
  200. package/dist/three/frame/core-occluders.js +193 -0
  201. package/dist/three/frame/core-occluders.js.map +1 -0
  202. package/dist/three/frame/core-structs.d.ts +34 -0
  203. package/dist/three/frame/core-structs.js +61 -0
  204. package/dist/three/frame/core-structs.js.map +1 -0
  205. package/dist/three/frame/core-textures.d.ts +41 -0
  206. package/dist/three/frame/core-textures.js +114 -0
  207. package/dist/three/frame/core-textures.js.map +1 -0
  208. package/dist/three/frame/emission-light.d.ts +64 -114
  209. package/dist/three/frame/emission-light.js +188 -567
  210. package/dist/three/frame/emission-light.js.map +1 -1
  211. package/dist/three/frame/index.d.ts +11 -31
  212. package/dist/three/frame/index.js +9 -29
  213. package/dist/three/frame/index.js.map +1 -1
  214. package/dist/three/frame/medium.d.ts +12 -0
  215. package/dist/three/frame/medium.js.map +1 -1
  216. package/dist/three/frame/renderer.d.ts +58 -454
  217. package/dist/three/frame/renderer.js +409 -1427
  218. package/dist/three/frame/renderer.js.map +1 -1
  219. package/dist/three/frame/spectrum.d.ts +0 -14
  220. package/dist/three/frame/spectrum.js +2 -23
  221. package/dist/three/frame/spectrum.js.map +1 -1
  222. package/dist/three/frame/three-internals.d.ts +3 -8
  223. package/dist/three/frame/three-internals.js +13 -11
  224. package/dist/three/frame/three-internals.js.map +1 -1
  225. package/dist/three/frame/volume-shadows.d.ts +93 -107
  226. package/dist/three/frame/volume-shadows.js +278 -631
  227. package/dist/three/frame/volume-shadows.js.map +1 -1
  228. package/dist/three/frame/volume.d.ts +91 -33
  229. package/dist/three/frame/volume.js +63 -51
  230. package/dist/three/frame/volume.js.map +1 -1
  231. package/dist/three/grid-node.d.ts +34 -1
  232. package/dist/three/grid-node.js +36 -1
  233. package/dist/three/grid-node.js.map +1 -1
  234. package/dist/three/index.d.ts +20 -11
  235. package/dist/three/index.js +21 -12
  236. package/dist/three/index.js.map +1 -1
  237. package/dist/three/internal.d.ts +14 -8
  238. package/dist/three/internal.js +11 -7
  239. package/dist/three/internal.js.map +1 -1
  240. package/dist/three/level-set-material.d.ts +81 -8
  241. package/dist/three/level-set-material.js +162 -125
  242. package/dist/three/level-set-material.js.map +1 -1
  243. package/dist/three/level-set-physical-material.d.ts +154 -0
  244. package/dist/three/level-set-physical-material.js +253 -0
  245. package/dist/three/level-set-physical-material.js.map +1 -0
  246. package/dist/three/level-set-velocity.d.ts +94 -0
  247. package/dist/three/level-set-velocity.js +208 -0
  248. package/dist/three/level-set-velocity.js.map +1 -0
  249. package/dist/three/material.d.ts +141 -11
  250. package/dist/three/material.js +161 -18
  251. package/dist/three/material.js.map +1 -1
  252. package/dist/three/points.d.ts +60 -4
  253. package/dist/three/points.js +140 -9
  254. package/dist/three/points.js.map +1 -1
  255. package/dist/three/sparse-source.d.ts +49 -117
  256. package/dist/three/sparse-source.js +109 -580
  257. package/dist/three/sparse-source.js.map +1 -1
  258. package/dist/three/volume-source.d.ts +11 -156
  259. package/dist/three/volume-source.js +29 -272
  260. package/dist/three/volume-source.js.map +1 -1
  261. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  262. package/dist/tools/cpu/brick-atlas.js +129 -0
  263. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  264. package/dist/tools/cpu/compute.d.ts +23 -4
  265. package/dist/tools/cpu/compute.js +35 -14
  266. package/dist/tools/cpu/compute.js.map +1 -1
  267. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  268. package/dist/tools/cpu/lean-reads.js +262 -0
  269. package/dist/tools/cpu/lean-reads.js.map +1 -0
  270. package/dist/tools/cpu/level-set.d.ts +42 -3
  271. package/dist/tools/cpu/level-set.js +59 -7
  272. package/dist/tools/cpu/level-set.js.map +1 -1
  273. package/dist/tools/cpu/majorant.d.ts +265 -0
  274. package/dist/tools/cpu/majorant.js +541 -0
  275. package/dist/tools/cpu/majorant.js.map +1 -0
  276. package/dist/tools/cpu/march.d.ts +93 -2
  277. package/dist/tools/cpu/march.js +165 -14
  278. package/dist/tools/cpu/march.js.map +1 -1
  279. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  280. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  281. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  282. package/dist/tools/cpu/points.d.ts +29 -0
  283. package/dist/tools/cpu/points.js +38 -0
  284. package/dist/tools/cpu/points.js.map +1 -0
  285. package/dist/tools/cpu/read-value.d.ts +19 -6
  286. package/dist/tools/cpu/read-value.js +32 -17
  287. package/dist/tools/cpu/read-value.js.map +1 -1
  288. package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
  289. package/dist/tools/cpu/sample-trilinear.js +19 -7
  290. package/dist/tools/cpu/sample-trilinear.js.map +1 -1
  291. package/dist/tools/cpu/stride-tables.d.ts +2 -2
  292. package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
  293. package/dist/tools/cpu/stride-tables.generated.js +7 -6
  294. package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
  295. package/dist/tools/cpu/stride-tables.js +1 -1
  296. package/dist/tools/cpu/stride-tables.js.map +1 -1
  297. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  298. package/dist/tools/cpu/surface-nets.js +597 -0
  299. package/dist/tools/cpu/surface-nets.js.map +1 -0
  300. package/dist/tools/errors.d.ts +9 -0
  301. package/dist/tools/errors.js +9 -0
  302. package/dist/tools/errors.js.map +1 -1
  303. package/dist/tools/frame/ambient.d.ts +98 -0
  304. package/dist/tools/frame/ambient.js +274 -0
  305. package/dist/tools/frame/ambient.js.map +1 -0
  306. package/dist/tools/frame/blackbody.d.ts +15 -0
  307. package/dist/tools/frame/blackbody.js +35 -0
  308. package/dist/tools/frame/blackbody.js.map +1 -1
  309. package/dist/tools/frame/brick-cache.d.ts +165 -0
  310. package/dist/tools/frame/brick-cache.js +326 -0
  311. package/dist/tools/frame/brick-cache.js.map +1 -0
  312. package/dist/tools/frame/emission.d.ts +9 -0
  313. package/dist/tools/frame/emission.js +9 -1
  314. package/dist/tools/frame/emission.js.map +1 -1
  315. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  316. package/dist/tools/frame/environment-gpu.js +280 -0
  317. package/dist/tools/frame/environment-gpu.js.map +1 -0
  318. package/dist/tools/frame/environment.d.ts +3 -2
  319. package/dist/tools/frame/environment.js +8 -4
  320. package/dist/tools/frame/environment.js.map +1 -1
  321. package/dist/tools/frame/froxel.d.ts +58 -0
  322. package/dist/tools/frame/froxel.js +115 -0
  323. package/dist/tools/frame/froxel.js.map +1 -0
  324. package/dist/tools/frame/grid.d.ts +90 -0
  325. package/dist/tools/frame/grid.js +112 -13
  326. package/dist/tools/frame/grid.js.map +1 -1
  327. package/dist/tools/frame/index.d.ts +14 -0
  328. package/dist/tools/frame/index.js +45 -4
  329. package/dist/tools/frame/index.js.map +1 -1
  330. package/dist/tools/frame/medium.d.ts +16 -0
  331. package/dist/tools/frame/medium.js +3 -1
  332. package/dist/tools/frame/medium.js.map +1 -1
  333. package/dist/tools/frame/mie.d.ts +9 -0
  334. package/dist/tools/frame/mie.js +18 -0
  335. package/dist/tools/frame/mie.js.map +1 -1
  336. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  337. package/dist/tools/frame/mlp-nn.js +159 -0
  338. package/dist/tools/frame/mlp-nn.js.map +1 -0
  339. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  340. package/dist/tools/frame/mlp-tza.js +186 -0
  341. package/dist/tools/frame/mlp-tza.js.map +1 -0
  342. package/dist/tools/frame/mlp.d.ts +183 -0
  343. package/dist/tools/frame/mlp.js +434 -0
  344. package/dist/tools/frame/mlp.js.map +1 -0
  345. package/dist/tools/frame/ms-exit.d.ts +42 -0
  346. package/dist/tools/frame/ms-exit.js +90 -0
  347. package/dist/tools/frame/ms-exit.js.map +1 -0
  348. package/dist/tools/frame/multi-scale.d.ts +152 -0
  349. package/dist/tools/frame/multi-scale.js +302 -0
  350. package/dist/tools/frame/multi-scale.js.map +1 -0
  351. package/dist/tools/frame/neural-weights.d.ts +6 -5
  352. package/dist/tools/frame/neural-weights.js +234 -235
  353. package/dist/tools/frame/neural-weights.js.map +1 -1
  354. package/dist/tools/frame/neural.js +1 -1
  355. package/dist/tools/frame/neural.js.map +1 -1
  356. package/dist/tools/frame/occluders.d.ts +51 -0
  357. package/dist/tools/frame/occluders.js +72 -0
  358. package/dist/tools/frame/occluders.js.map +1 -0
  359. package/dist/tools/frame/pyramid-layout.d.ts +17 -0
  360. package/dist/tools/frame/pyramid-layout.js +47 -0
  361. package/dist/tools/frame/pyramid-layout.js.map +1 -1
  362. package/dist/tools/frame/shadows.d.ts +110 -0
  363. package/dist/tools/frame/shadows.js +286 -0
  364. package/dist/tools/frame/shadows.js.map +1 -1
  365. package/dist/tools/frame/sparse.d.ts +82 -0
  366. package/dist/tools/frame/sparse.js +242 -1
  367. package/dist/tools/frame/sparse.js.map +1 -1
  368. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  369. package/dist/tools/frame/spectral-stack.js +391 -0
  370. package/dist/tools/frame/spectral-stack.js.map +1 -0
  371. package/dist/tools/frame/spectral.d.ts +21 -2
  372. package/dist/tools/frame/spectral.js +30 -8
  373. package/dist/tools/frame/spectral.js.map +1 -1
  374. package/dist/tools/frame/stack.d.ts +115 -0
  375. package/dist/tools/frame/stack.js +290 -0
  376. package/dist/tools/frame/stack.js.map +1 -0
  377. package/dist/tools/frame/view.d.ts +131 -0
  378. package/dist/tools/frame/view.js +337 -0
  379. package/dist/tools/frame/view.js.map +1 -0
  380. package/dist/tools/index.d.ts +66 -15
  381. package/dist/tools/index.js +55 -11
  382. package/dist/tools/index.js.map +1 -1
  383. package/dist/tools/internal.d.ts +58 -17
  384. package/dist/tools/internal.js +65 -11
  385. package/dist/tools/internal.js.map +1 -1
  386. package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
  387. package/dist/tools/nanovdb/build-from-vdb.js +10 -2
  388. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
  389. package/dist/tools/nanovdb/bytes.d.ts +17 -4
  390. package/dist/tools/nanovdb/bytes.js +46 -3
  391. package/dist/tools/nanovdb/bytes.js.map +1 -1
  392. package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
  393. package/dist/tools/nanovdb/coarse-first.js +7 -1
  394. package/dist/tools/nanovdb/coarse-first.js.map +1 -1
  395. package/dist/tools/nanovdb/half.d.ts +22 -0
  396. package/dist/tools/nanovdb/half.js +73 -0
  397. package/dist/tools/nanovdb/half.js.map +1 -0
  398. package/dist/tools/nanovdb/index.d.ts +3 -1
  399. package/dist/tools/nanovdb/index.js +2 -1
  400. package/dist/tools/nanovdb/index.js.map +1 -1
  401. package/dist/tools/nanovdb/inspect.d.ts +10 -1
  402. package/dist/tools/nanovdb/inspect.js +8 -1
  403. package/dist/tools/nanovdb/inspect.js.map +1 -1
  404. package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
  405. package/dist/tools/nanovdb/leaf-codec.js +40 -4
  406. package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
  407. package/dist/tools/nanovdb/quantize.d.ts +39 -10
  408. package/dist/tools/nanovdb/quantize.js +96 -44
  409. package/dist/tools/nanovdb/quantize.js.map +1 -1
  410. package/dist/tools/nanovdb/resample.d.ts +20 -3
  411. package/dist/tools/nanovdb/resample.js +20 -7
  412. package/dist/tools/nanovdb/resample.js.map +1 -1
  413. package/dist/tools/nanovdb/serialize.d.ts +34 -3
  414. package/dist/tools/nanovdb/serialize.js +51 -7
  415. package/dist/tools/nanovdb/serialize.js.map +1 -1
  416. package/dist/tools/nanovdb/stats.d.ts +34 -5
  417. package/dist/tools/nanovdb/stats.js +87 -11
  418. package/dist/tools/nanovdb/stats.js.map +1 -1
  419. package/dist/tools/nanovdb/transform.d.ts +4 -0
  420. package/dist/tools/nanovdb/transform.js +3 -0
  421. package/dist/tools/nanovdb/transform.js.map +1 -1
  422. package/dist/tools/nanovdb/tree.d.ts +14 -3
  423. package/dist/tools/nanovdb/tree.js +25 -13
  424. package/dist/tools/nanovdb/tree.js.map +1 -1
  425. package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
  426. package/dist/tools/nanovdb/write-nvdb.js +108 -28
  427. package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
  428. package/dist/tools/nvdb-file.d.ts +77 -7
  429. package/dist/tools/nvdb-file.js +177 -20
  430. package/dist/tools/nvdb-file.js.map +1 -1
  431. package/dist/tools/nvdb-stream.d.ts +23 -7
  432. package/dist/tools/nvdb-stream.js +78 -34
  433. package/dist/tools/nvdb-stream.js.map +1 -1
  434. package/dist/tools/reference/analytic.d.ts +41 -0
  435. package/dist/tools/reference/analytic.js +95 -0
  436. package/dist/tools/reference/analytic.js.map +1 -0
  437. package/dist/tools/reference/environment.d.ts +62 -0
  438. package/dist/tools/reference/environment.js +154 -0
  439. package/dist/tools/reference/environment.js.map +1 -0
  440. package/dist/tools/reference/index.d.ts +12 -0
  441. package/dist/tools/reference/index.js +13 -0
  442. package/dist/tools/reference/index.js.map +1 -0
  443. package/dist/tools/reference/media.d.ts +14 -0
  444. package/dist/tools/reference/media.js +30 -0
  445. package/dist/tools/reference/media.js.map +1 -0
  446. package/dist/tools/reference/rng.d.ts +20 -0
  447. package/dist/tools/reference/rng.js +30 -0
  448. package/dist/tools/reference/rng.js.map +1 -0
  449. package/dist/tools/reference/scene.d.ts +312 -0
  450. package/dist/tools/reference/scene.js +169 -0
  451. package/dist/tools/reference/scene.js.map +1 -0
  452. package/dist/tools/reference/tables.d.ts +98 -0
  453. package/dist/tools/reference/tables.js +264 -0
  454. package/dist/tools/reference/tables.js.map +1 -0
  455. package/dist/tools/reference/trace.d.ts +160 -0
  456. package/dist/tools/reference/trace.js +497 -0
  457. package/dist/tools/reference/trace.js.map +1 -0
  458. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  459. package/dist/tools/vdb/blosc-write.js +197 -0
  460. package/dist/tools/vdb/blosc-write.js.map +1 -0
  461. package/dist/tools/vdb/blosc.d.ts +35 -5
  462. package/dist/tools/vdb/blosc.js +82 -26
  463. package/dist/tools/vdb/blosc.js.map +1 -1
  464. package/dist/tools/vdb/blosclz.d.ts +33 -0
  465. package/dist/tools/vdb/blosclz.js +112 -0
  466. package/dist/tools/vdb/blosclz.js.map +1 -0
  467. package/dist/tools/vdb/byte-reader.d.ts +13 -3
  468. package/dist/tools/vdb/byte-reader.js +26 -4
  469. package/dist/tools/vdb/byte-reader.js.map +1 -1
  470. package/dist/tools/vdb/compression.d.ts +13 -5
  471. package/dist/tools/vdb/compression.js +13 -2
  472. package/dist/tools/vdb/compression.js.map +1 -1
  473. package/dist/tools/vdb/grid.js +8 -2
  474. package/dist/tools/vdb/grid.js.map +1 -1
  475. package/dist/tools/vdb/index.d.ts +2 -1
  476. package/dist/tools/vdb/index.js.map +1 -1
  477. package/dist/tools/vdb/lz4.d.ts +30 -0
  478. package/dist/tools/vdb/lz4.js +228 -0
  479. package/dist/tools/vdb/lz4.js.map +1 -0
  480. package/dist/tools/vdb/metadata.js +1 -1
  481. package/dist/tools/vdb/metadata.js.map +1 -1
  482. package/dist/tools/vdb/parse.d.ts +24 -2
  483. package/dist/tools/vdb/parse.js +102 -32
  484. package/dist/tools/vdb/parse.js.map +1 -1
  485. package/dist/tools/vdb/point-render-data.d.ts +49 -1
  486. package/dist/tools/vdb/point-render-data.js +91 -11
  487. package/dist/tools/vdb/point-render-data.js.map +1 -1
  488. package/dist/tools/vdb/points.d.ts +26 -0
  489. package/dist/tools/vdb/points.js +46 -5
  490. package/dist/tools/vdb/points.js.map +1 -1
  491. package/dist/tools/vdb/types.d.ts +59 -2
  492. package/dist/tools/vdb/types.js.map +1 -1
  493. package/dist/tools/wvdb/bake.d.ts +38 -9
  494. package/dist/tools/wvdb/bake.js +63 -13
  495. package/dist/tools/wvdb/bake.js.map +1 -1
  496. package/dist/tools/wvdb/dense.d.ts +80 -1
  497. package/dist/tools/wvdb/dense.js +67 -8
  498. package/dist/tools/wvdb/dense.js.map +1 -1
  499. package/dist/tools/wvdb/format.d.ts +59 -0
  500. package/dist/tools/wvdb/format.js +3 -0
  501. package/dist/tools/wvdb/format.js.map +1 -1
  502. package/dist/tools/wvdb/index.d.ts +1 -0
  503. package/dist/tools/wvdb/index.js +1 -0
  504. package/dist/tools/wvdb/index.js.map +1 -1
  505. package/dist/tools/wvdb/level-set.d.ts +10 -2
  506. package/dist/tools/wvdb/level-set.js.map +1 -1
  507. package/dist/tools/wvdb/nanovdb.d.ts +6 -1
  508. package/dist/tools/wvdb/nanovdb.js +5 -1
  509. package/dist/tools/wvdb/nanovdb.js.map +1 -1
  510. package/dist/tools/wvdb/partial.d.ts +74 -0
  511. package/dist/tools/wvdb/partial.js +233 -0
  512. package/dist/tools/wvdb/partial.js.map +1 -0
  513. package/dist/tools/wvdb/read.d.ts +77 -1
  514. package/dist/tools/wvdb/read.js +30 -7
  515. package/dist/tools/wvdb/read.js.map +1 -1
  516. package/dist/tools/wvdb/write.d.ts +23 -1
  517. package/dist/tools/wvdb/write.js +8 -1
  518. package/dist/tools/wvdb/write.js.map +1 -1
  519. package/package.json +2 -1
  520. package/vendor/VENDOR.md +21 -6
  521. package/vendor/pnanovdb.wgsl +52 -14
  522. package/dist/three/frame/blackbody.d.ts +0 -42
  523. package/dist/three/frame/blackbody.js +0 -74
  524. package/dist/three/frame/blackbody.js.map +0 -1
  525. package/dist/three/frame/chunks.d.ts +0 -157
  526. package/dist/three/frame/chunks.js +0 -559
  527. package/dist/three/frame/chunks.js.map +0 -1
  528. package/dist/three/frame/density-material.d.ts +0 -53
  529. package/dist/three/frame/density-material.js +0 -353
  530. package/dist/three/frame/density-material.js.map +0 -1
  531. package/dist/three/frame/environment-grid-material.d.ts +0 -21
  532. package/dist/three/frame/environment-grid-material.js +0 -184
  533. package/dist/three/frame/environment-grid-material.js.map +0 -1
  534. package/dist/three/frame/environment-material.d.ts +0 -22
  535. package/dist/three/frame/environment-material.js +0 -87
  536. package/dist/three/frame/environment-material.js.map +0 -1
  537. package/dist/three/frame/grid-mip-material.d.ts +0 -12
  538. package/dist/three/frame/grid-mip-material.js +0 -61
  539. package/dist/three/frame/grid-mip-material.js.map +0 -1
  540. package/dist/three/frame/inject-material.d.ts +0 -56
  541. package/dist/three/frame/inject-material.js +0 -424
  542. package/dist/three/frame/inject-material.js.map +0 -1
  543. package/dist/three/frame/integrate-material.d.ts +0 -26
  544. package/dist/three/frame/integrate-material.js +0 -198
  545. package/dist/three/frame/integrate-material.js.map +0 -1
  546. package/dist/three/frame/layout.d.ts +0 -34
  547. package/dist/three/frame/layout.js +0 -48
  548. package/dist/three/frame/layout.js.map +0 -1
  549. package/dist/three/frame/lighting-material.d.ts +0 -41
  550. package/dist/three/frame/lighting-material.js +0 -257
  551. package/dist/three/frame/lighting-material.js.map +0 -1
  552. package/dist/three/frame/lights.d.ts +0 -11
  553. package/dist/three/frame/lights.js +0 -16
  554. package/dist/three/frame/lights.js.map +0 -1
  555. package/dist/three/frame/neural.d.ts +0 -14
  556. package/dist/three/frame/neural.js +0 -105
  557. package/dist/three/frame/neural.js.map +0 -1
  558. package/dist/three/frame/phase.d.ts +0 -44
  559. package/dist/three/frame/phase.js +0 -80
  560. package/dist/three/frame/phase.js.map +0 -1
  561. package/dist/three/frame/shadow-density-material.d.ts +0 -30
  562. package/dist/three/frame/shadow-density-material.js +0 -123
  563. package/dist/three/frame/shadow-density-material.js.map +0 -1
  564. package/dist/three/frame/temporal-material.d.ts +0 -29
  565. package/dist/three/frame/temporal-material.js +0 -152
  566. package/dist/three/frame/temporal-material.js.map +0 -1
  567. package/dist/three/frame/transmittance-material.d.ts +0 -31
  568. package/dist/three/frame/transmittance-material.js +0 -315
  569. package/dist/three/frame/transmittance-material.js.map +0 -1
  570. package/dist/three/frame/view.d.ts +0 -103
  571. package/dist/three/frame/view.js +0 -296
  572. package/dist/three/frame/view.js.map +0 -1
  573. package/dist/three/frame/volume-shadow-material.d.ts +0 -36
  574. package/dist/three/frame/volume-shadow-material.js +0 -128
  575. package/dist/three/frame/volume-shadow-material.js.map +0 -1
  576. package/dist/three/sequence.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/tools/wvdb/write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,GAeb,MAAM,aAAa,CAAC;AAoFrB,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAa,EAAE,MAAM,EAAE,QAAsB,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC1H,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEhC,MAAM,eAAe,GAAG,CAAC,GAAe,EAAc,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AAErF,4FAA4F;AAC5F,MAAM,UAAU,mBAAmB,CAAC,KAAqB,EAAE,QAAgB;IACzE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC;IACnC,MAAM,IAAI,GAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,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;IAC/D,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAC1C,IAAI,EAAE,GAAG,kBAAkB,GAAG,WAAW,CAAC,UAAU,CAAC;IACrD,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpB,EAAE,IAAI,KAAK,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * write.ts — `.wvdb` writer (mjurczyk's WebVDB spec v0.5.x) from dense\n * volume levels and point lists.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345:\n * `src/wvdb/bake.js` (downsample, getDensityStats, getBrickValues, encodeLod,\n * getPointLods, getPointsBox, the header assembly) and `writeWVDBFile` in\n * `src/openvdb/wvdb/format.js`. The goal is files his `WVDBLoader` reads, and,\n * given the same values and a zlib with the same output (Node's\n * `deflateSync(level 9)`, which his CLI uses), the same bytes. His choices we\n * keep (spec text in brackets where it only says SHOULD/MAY):\n * - defaults: 3 LODs, 8 bits, sparse layout, 1024 bricks per page, 2^18\n * points per points chunk;\n * - coarse LODs are 2x box filters of the next finer LOD over the voxels\n * that exist (§3.2.4), summed in float64, stored as float32;\n * - a sparse LOD drops a brick only when every value (all channels,\n * including the edge-replicated voxels outside the LOD) equals the\n * background exactly (§3.4); a dense LOD stores every brick;\n * - sparse pages hold the bricks with the largest sum of |v - background|\n * first, ties in index order (§9 SHOULD);\n * - `meanDensity` / `nonZeroVoxels` of the finest LOD for scalar grids (his\n * 8-bit `floor(clamp(v, 0, 1) * 255)` texels; level sets count the band);\n * - header member order is his, so `JSON.stringify` gives his header bytes.\n *\n * Compression defaults to fflate `zlibSync` at level 9 (Node + browser). Its\n * deflate stream differs from Node's zlib, so for byte-identical output pass\n * `compress: (b) => zlib.deflateSync(b, { level: 9 })` in Node.\n */\n\nimport { VDBToolsError } from \"../errors.js\";\nimport { zlibSync } from \"fflate\";\nimport {\n WVDB_BRICK_DIM,\n WVDB_BRICK_VOXELS,\n WVDB_MAGIC,\n WVDB_POINTS_PAGE,\n WVDB_POINTS_VERSION,\n WVDB_PREAMBLE_SIZE,\n brickCounts,\n brickOrigin,\n encodeMask,\n encodePage,\n encodePoints,\n type WvdbBits,\n type WvdbBox,\n type WvdbChunkRef,\n type WvdbGridHeader,\n type WvdbHeader,\n type WvdbLayout,\n type WvdbPageRef,\n type WvdbPointsGridHeader,\n type WvdbPointsLodHeader,\n type WvdbPointsPageRef,\n type WvdbSource,\n type WvdbVec3,\n type WvdbVolumeGridHeader,\n type WvdbVolumeLodHeader,\n} from \"./format.js\";\n\n/** One dense level: channel planes one after the other, x fastest. */\nexport interface WvdbDenseLevel {\n dimensions: WvdbVec3;\n values: Float32Array;\n /**\n * Sparse layout only: the bricks to store, in page order (e.g. a decoded\n * level's `brickIndices`, to keep a file's order when re-encoding). Must\n * hold every brick that is not all background (§3.4). Default: his order\n * (most data first, ties by index).\n */\n brickOrder?: ArrayLike<number>;\n}\n\nexport interface WvdbVolumeGridInput {\n type?: \"volume\";\n name: string;\n /** Default `\"unknown\"`. */\n class?: string;\n /** Default 1. */\n channels?: 1 | 3;\n /** One number, or 3 for a vector grid. */\n background: number | readonly number[];\n bbox: WvdbBox | null;\n /**\n * The finest LOD. Coarser LODs are built by `downsampleWvdbLevel` (§3.2).\n * Give `levels` instead to supply every LOD yourself.\n */\n finest?: WvdbDenseLevel;\n /** Every LOD, coarse first (`levels.length` must equal `lods`). */\n levels?: readonly WvdbDenseLevel[];\n /**\n * `meanDensity` / `nonZeroVoxels` for a scalar grid. Default true (his\n * writer always writes them for scalar grids); false omits them; an object\n * writes the given numbers.\n */\n stats?: boolean | { meanDensity: number; nonZeroVoxels: number };\n}\n\nexport interface WvdbPointsGridInput {\n type: \"points\";\n name: string;\n class?: string;\n /** xyz per point, in the stored order (near indices should be near in space, §3.5). */\n positions: Float32Array;\n /** rgb per point in [0, 1], or null/absent. */\n colors?: Float32Array | null;\n /** Points of the source. Default: the point count before `maxPoints` thinning. */\n sourceCount?: number;\n /** Mean distance between stored points (world units). Default: estimated from the box (see `writeWvdb`). */\n spacing?: number;\n}\n\nexport type WvdbGridInput = WvdbVolumeGridInput | WvdbPointsGridInput;\n\nexport interface WriteWvdbOptions {\n /** LOD count. Default 3. */\n lods?: number;\n /** Quantization bits. Default 8. */\n bits?: WvdbBits;\n /** Default `\"sparse\"`. */\n layout?: WvdbLayout;\n /** Bricks per page chunk. Default 1024. */\n pageBricks?: number;\n /** Recorded as `bake.resolution`. Default: the longest side of the finest LOD of the first volume grid (else 128). */\n resolution?: number;\n /** Recorded as `bake.grids`. Default null. */\n gridNames?: string[] | null;\n /** Recorded as `bake.bbox` (the sequence box, §10). Default null. */\n bakeBBox?: WvdbBox | null;\n /** Keep every n-th point above this many per points grid (his `--max-points`). Default 4,000,000. */\n maxPoints?: number;\n /** `source` header member. Default `{ file: \"\", sha256: \"\" + 64 zeros }`. */\n source?: WvdbSource;\n /** zlib compressor. Default fflate `zlibSync(level 9)`. */\n compress?: (raw: Uint8Array) => Uint8Array;\n}\n\nexport interface WriteWvdbResult {\n bytes: Uint8Array;\n header: WvdbHeader;\n}\n\nconst DEFAULTS = { lods: 3, bits: 8 as WvdbBits, layout: \"sparse\" as WvdbLayout, pageBricks: 1024, maxPoints: 4_000_000 };\nconst ZERO_SHA = \"0\".repeat(64);\n\nconst defaultCompress = (raw: Uint8Array): Uint8Array => zlibSync(raw, { level: 9 });\n\n/** §3.2.3-5: one 2x box-filter step, each channel alone, over the voxels inside the LOD. */\nexport function downsampleWvdbLevel(level: WvdbDenseLevel, channels: number): WvdbDenseLevel {\n const [w, h, d] = level.dimensions;\n const dims: WvdbVec3 = [Math.ceil(w / 2), Math.ceil(h / 2), Math.ceil(d / 2)];\n const [ow, oh, od] = dims;\n const count = w * h * d;\n const outCount = ow * oh * od;\n const out = new Float32Array(outCount * channels);\n for (let c = 0; c < channels; c++) {\n const src = c * count;\n let o = c * outCount;\n for (let z = 0; z < od; z++) {\n for (let y = 0; y < oh; y++) {\n for (let x = 0; x < ow; x++) {\n let sum = 0;\n let n = 0;\n for (let dz = 0; dz < 2; dz++) {\n for (let dy = 0; dy < 2; dy++) {\n for (let dx = 0; dx < 2; dx++) {\n const sx = 2 * x + dx;\n const sy = 2 * y + dy;\n const sz = 2 * z + dz;\n if (sx < w && sy < h && sz < d) {\n sum += level.values[src + sx + sy * w + sz * w * h]!;\n n++;\n }\n }\n }\n }\n out[o++] = sum / n;\n }\n }\n }\n }\n return { dimensions: dims, values: out };\n}\n\n/** His `getDensityStats`: mean and count of the non-zero 8-bit density texels of one LOD. */\nexport function wvdbDensityStats(\n values: Float32Array,\n background: number,\n isLevelSet: boolean,\n): { meanDensity: number; nonZeroVoxels: number } {\n let sum = 0;\n let count = 0;\n for (let i = 0; i < values.length; i++) {\n const texel = isLevelSet\n ? Math.abs(values[i]!) < background\n ? 255\n : 0\n : (Math.min(Math.max(values[i]!, 0), 1) * 255) | 0;\n if (texel > 0) {\n sum += texel;\n count++;\n }\n }\n return { meanDensity: count > 0 ? sum / 255 / count : 0, nonZeroVoxels: count };\n}\n\n/** 512 values per channel; voxels outside the LOD copy the nearest voxel inside (§3.3). */\nfunction brickValues(level: WvdbDenseLevel, index: number, channels: number): Float32Array {\n const [w, h, d] = level.dimensions;\n const [ox, oy, oz] = brickOrigin(level.dimensions, index);\n const count = w * h * d;\n const brick = new Float32Array(WVDB_BRICK_VOXELS * channels);\n let v = 0;\n for (let c = 0; c < channels; c++) {\n const plane = c * count;\n for (let z = 0; z < WVDB_BRICK_DIM; z++) {\n const sz = Math.min(oz + z, d - 1);\n for (let y = 0; y < WVDB_BRICK_DIM; y++) {\n const sy = Math.min(oy + y, h - 1);\n for (let x = 0; x < WVDB_BRICK_DIM; x++) {\n const sx = Math.min(ox + x, w - 1);\n brick[v++] = level.values[plane + sx + sy * w + sz * w * h]!;\n }\n }\n }\n }\n return brick;\n}\n\ninterface EncodedLod {\n dimensions: WvdbVec3;\n bricks: number;\n mask: Uint8Array | null;\n pages: { bricks: number; bytes: Uint8Array }[];\n}\n\nfunction encodeLod(\n level: WvdbDenseLevel,\n background: readonly number[],\n channels: number,\n o: { layout: WvdbLayout; bits: WvdbBits; pageBricks: number; compress: (raw: Uint8Array) => Uint8Array },\n): EncodedLod {\n const sparse = o.layout === \"sparse\";\n const [cx, cy, cz] = brickCounts(level.dimensions);\n const total = cx * cy * cz;\n const bricks: { index: number; weight: number }[] = [];\n for (let index = 0; index < total; index++) {\n const values = brickValues(level, index, channels);\n let isBackground = true;\n let weight = 0;\n for (let v = 0; v < values.length; v++) {\n const bg = background[Math.floor(v / WVDB_BRICK_VOXELS)]!;\n isBackground = isBackground && values[v] === bg;\n weight += Math.abs(values[v]! - bg);\n }\n if (sparse && isBackground) continue;\n bricks.push({ index, weight });\n }\n if (sparse) bricks.sort((a, b) => b.weight - a.weight || a.index - b.index);\n if (sparse && level.brickOrder) {\n const given = Array.from(level.brickOrder);\n const set = new Set(given);\n if (set.size !== given.length) throw new VDBToolsError(\"VDB_BAD_OPTION\", \"writeWvdb: brickOrder lists a brick twice\");\n for (const i of given) {\n if (!Number.isInteger(i) || i < 0 || i >= total) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: brickOrder index ${i} is out of range`);\n }\n for (const b of bricks) {\n if (!set.has(b.index)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: brickOrder omits brick ${b.index}, which is not all background`);\n }\n bricks.length = 0;\n for (const index of given) bricks.push({ index, weight: 0 });\n }\n\n const pages: EncodedLod[\"pages\"] = [];\n for (let start = 0; start < bricks.length; start += o.pageBricks) {\n const page = bricks\n .slice(start, start + o.pageBricks)\n .map(({ index }) => ({ index, values: brickValues(level, index, channels) }));\n pages.push({ bricks: page.length, bytes: o.compress(encodePage(page, { layout: o.layout, bits: o.bits, channels })) });\n }\n return {\n dimensions: [...level.dimensions] as WvdbVec3,\n bricks: bricks.length,\n mask: sparse ? o.compress(encodeMask(bricks.map((b) => b.index), total)) : null,\n pages,\n };\n}\n\n/** §3.5: point i is in the first LOD k where i is a multiple of 8^(lods-1-k). */\nexport function wvdbPointLods(count: number, lods: number): number[][] {\n return Array.from({ length: lods }, (_, lod) => {\n const stride = 8 ** (lods - 1 - lod);\n const coarser = stride * 8;\n const indices: number[] = [];\n for (let p = 0; p < count; p += stride) if (lod === 0 || p % coarser !== 0) indices.push(p);\n return indices;\n });\n}\n\nfunction gather(source: Float32Array, indices: readonly number[]): Float32Array {\n const out = new Float32Array(indices.length * 3);\n indices.forEach((p, i) => out.set(source.subarray(p * 3, p * 3 + 3), i * 3));\n return out;\n}\n\nfunction pointsBox(positions: Float32Array): WvdbBox | null {\n if (!positions.length) return null;\n const min = [Infinity, Infinity, Infinity];\n const max = [-Infinity, -Infinity, -Infinity];\n for (let i = 0; i < positions.length; i++) {\n min[i % 3] = Math.min(min[i % 3]!, positions[i]!);\n max[i % 3] = Math.max(max[i % 3]!, positions[i]!);\n }\n return [min.map(Math.fround) as WvdbVec3, max.map(Math.fround) as WvdbVec3];\n}\n\nfunction checkLevel(level: WvdbDenseLevel, channels: number, what: string): void {\n const [x, y, z] = level.dimensions;\n if (![x, y, z].every((n) => Number.isInteger(n) && n >= 1)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: ${what}: dimensions must be integers >= 1`);\n if (level.values.length !== x * y * z * channels) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: ${what}: ${level.values.length} values, expected ${x * y * z * channels} (X*Y*Z*channels)`);\n }\n}\n\ntype PendingChunk = { bytes: Uint8Array; entry: WvdbChunkRef };\n\n/**\n * Writes a `.wvdb` file. Volume grids give their finest LOD (or all LODs);\n * points grids give their points. All grids get `lods` LODs. Version 2 is\n * written iff a points grid is present (§11).\n *\n * Points `spacing`, when not given, is `cbrt(boxVolume / sourceCount) *\n * cbrt(stride)` (a uniform-density estimate; his CLI derives it from the\n * source voxel size instead).\n */\nexport function writeWvdb(grids: readonly WvdbGridInput[], options: WriteWvdbOptions = {}): WriteWvdbResult {\n const lods = options.lods ?? DEFAULTS.lods;\n const bits = options.bits ?? DEFAULTS.bits;\n const layout = options.layout ?? DEFAULTS.layout;\n const pageBricks = options.pageBricks ?? DEFAULTS.pageBricks;\n const maxPoints = options.maxPoints ?? DEFAULTS.maxPoints;\n const compress = options.compress ?? defaultCompress;\n if (!Number.isInteger(lods) || lods < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid LOD count ${lods}`);\n if (bits !== 8 && bits !== 16) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: bits must be 8 or 16 (got ${String(bits)})`);\n if (layout !== \"dense\" && layout !== \"sparse\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid layout ${String(layout)}`);\n if (!Number.isInteger(pageBricks) || pageBricks < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid pageBricks ${pageBricks}`);\n if (!Number.isInteger(maxPoints) || maxPoints < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid maxPoints ${maxPoints}`);\n const names = new Set<string>();\n for (const g of grids) {\n if (names.has(g.name)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: grid name \"${g.name}\" is not unique`);\n names.add(g.name);\n }\n\n type Encoded =\n | { kind: \"volume\"; header: Omit<WvdbVolumeGridHeader, \"lods\">; lods: EncodedLod[] }\n | { kind: \"points\"; header: Omit<WvdbPointsGridHeader, \"lods\">; lods: { points: number; pages: { points: number; bytes: Uint8Array }[] }[] };\n\n let resolution = options.resolution;\n const encoded: Encoded[] = grids.map((grid): Encoded => {\n if (grid.type === \"points\") {\n const total = grid.positions.length / 3;\n if (!Number.isInteger(total)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": positions length is not a multiple of 3`);\n if (grid.colors && grid.colors.length !== grid.positions.length) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": colors must have 3 values per point`);\n }\n const stride = Math.max(1, Math.ceil(total / maxPoints));\n const count = total > 0 ? Math.floor((total - 1) / stride) + 1 : 0;\n let positions = grid.positions;\n let colors = grid.colors ?? null;\n if (stride > 1) {\n const keep = Array.from({ length: count }, (_, i) => i * stride);\n positions = gather(grid.positions, keep);\n colors = colors ? gather(colors, keep) : null;\n }\n const bbox = pointsBox(positions);\n let spacing = grid.spacing;\n if (spacing === undefined) {\n const size = bbox ? bbox[1].map((v, a) => v - bbox[0][a]!) : [0, 0, 0];\n const volume = size[0]! * size[1]! * size[2]!;\n const sourceCount = grid.sourceCount ?? total;\n spacing = sourceCount > 0 && volume > 0 ? Math.cbrt(volume / sourceCount) * Math.cbrt(stride) : 0;\n }\n return {\n kind: \"points\",\n header: {\n name: grid.name,\n type: \"points\",\n class: grid.class ?? \"unknown\",\n count,\n sourceCount: grid.sourceCount ?? total,\n spacing: Math.fround(spacing),\n colors: !!colors,\n bbox,\n },\n lods: wvdbPointLods(count, lods).map((indices) => {\n const pages: { points: number; bytes: Uint8Array }[] = [];\n for (let start = 0; start < indices.length; start += WVDB_POINTS_PAGE) {\n const page = indices.slice(start, start + WVDB_POINTS_PAGE);\n pages.push({ points: page.length, bytes: compress(encodePoints(gather(positions, page), colors ? gather(colors, page) : null)) });\n }\n return { points: indices.length, pages };\n }),\n };\n }\n\n const channels = grid.channels ?? 1;\n if (channels !== 1 && channels !== 3) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": channels must be 1 or 3`);\n const background = typeof grid.background === \"number\" ? [grid.background] : [...grid.background];\n if (background.length !== channels) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": background needs ${channels} value(s)`);\n const bg32 = background.map(Math.fround);\n let levels: WvdbDenseLevel[];\n if (grid.levels) {\n if (grid.levels.length !== lods) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": ${grid.levels.length} levels given, lods is ${lods}`);\n levels = [...grid.levels];\n } else if (grid.finest) {\n levels = [];\n levels[lods - 1] = grid.finest;\n for (let lod = lods - 2; lod >= 0; lod--) levels[lod] = downsampleWvdbLevel(levels[lod + 1]!, channels);\n } else {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": give finest or levels`);\n }\n levels.forEach((l, i) => checkLevel(l, channels, `\"${grid.name}\" LOD ${i}`));\n resolution ??= Math.max(...levels[lods - 1]!.dimensions);\n const gridClass = grid.class ?? \"unknown\";\n let stats: { meanDensity: number; nonZeroVoxels: number } | null = null;\n if (channels === 1 && grid.stats !== false) {\n stats =\n typeof grid.stats === \"object\"\n ? grid.stats\n : wvdbDensityStats(levels[lods - 1]!.values, bg32[0]!, gridClass === \"level set\");\n }\n return {\n kind: \"volume\",\n header: {\n name: grid.name,\n class: gridClass,\n channels,\n background: channels === 1 ? bg32[0]! : (bg32 as WvdbVec3),\n bbox: grid.bbox,\n ...(stats ? { meanDensity: stats.meanDensity, nonZeroVoxels: stats.nonZeroVoxels } : {}),\n },\n lods: levels.map((level) => encodeLod(level, bg32, channels, { layout, bits, pageBricks, compress })),\n };\n });\n\n // §9: LOD 0 of all grids, then LOD 1, ...; per grid the mask, then the pages.\n const chunks: PendingChunk[] = [];\n const headerLods: (WvdbVolumeLodHeader | WvdbPointsLodHeader)[][] = encoded.map(() => []);\n for (let lod = 0; lod < lods; lod++) {\n encoded.forEach((grid, gi) => {\n if (grid.kind === \"points\") {\n const { points, pages } = grid.lods[lod]!;\n headerLods[gi]![lod] = {\n points,\n pages: pages.map((page) => {\n const entry: WvdbPointsPageRef = { offset: 0, length: 0, points: page.points };\n chunks.push({ bytes: page.bytes, entry });\n return entry;\n }),\n };\n return;\n }\n const { dimensions, bricks, mask, pages } = grid.lods[lod]!;\n // Key order dimensions, bricks, mask, pages (his header bytes); pages are added after the mask.\n const entry = { dimensions, bricks } as WvdbVolumeLodHeader;\n if (mask) {\n entry.mask = { offset: 0, length: 0 };\n chunks.push({ bytes: mask, entry: entry.mask });\n }\n entry.pages = pages.map((page) => {\n const ref: WvdbPageRef = { offset: 0, length: 0, bricks: page.bricks };\n chunks.push({ bytes: page.bytes, entry: ref });\n return ref;\n });\n headerLods[gi]![lod] = entry;\n });\n }\n\n const hasPoints = encoded.some((g) => g.kind === \"points\");\n const header: WvdbHeader = {\n version: hasPoints ? WVDB_POINTS_VERSION : 1,\n source: options.source ?? { file: \"\", sha256: ZERO_SHA },\n bake: {\n grids: options.gridNames ?? null,\n resolution: resolution ?? 128,\n lods,\n bits,\n layout,\n pageBricks,\n bbox: options.bakeBBox ?? null,\n ...(hasPoints ? { maxPoints } : {}),\n },\n brickDim: WVDB_BRICK_DIM,\n grids: encoded.map((g, gi) => ({ ...g.header, lods: headerLods[gi] }) as WvdbGridHeader),\n };\n return { bytes: assembleWvdb(header, chunks), header };\n}\n\n/** Sets each chunk's offset/length, then lays out preamble + header JSON + chunks (§4). */\nfunction assembleWvdb(header: WvdbHeader, chunks: PendingChunk[]): Uint8Array {\n let offset = 0;\n for (const { bytes, entry } of chunks) {\n entry.offset = offset;\n entry.length = bytes.byteLength;\n offset += bytes.byteLength;\n }\n const headerBytes = new TextEncoder().encode(JSON.stringify(header));\n const file = new Uint8Array(WVDB_PREAMBLE_SIZE + headerBytes.byteLength + offset);\n const view = new DataView(file.buffer);\n for (let i = 0; i < 4; i++) file[i] = WVDB_MAGIC.charCodeAt(i);\n view.setUint32(4, header.version, true);\n view.setUint32(8, headerBytes.byteLength, true);\n file.set(headerBytes, WVDB_PREAMBLE_SIZE);\n let at = WVDB_PREAMBLE_SIZE + headerBytes.byteLength;\n for (const { bytes } of chunks) {\n file.set(bytes, at);\n at += bytes.byteLength;\n }\n return file;\n}\n"]}
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/tools/wvdb/write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,GAeb,MAAM,aAAa,CAAC;AAmGrB,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAa,EAAE,MAAM,EAAE,QAAsB,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC1H,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEhC,MAAM,eAAe,GAAG,CAAC,GAAe,EAAc,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AAErF,4FAA4F;AAC5F,MAAM,UAAU,mBAAmB,CAAC,KAAqB,EAAE,QAAgB;IACzE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC;IACnC,MAAM,IAAI,GAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9E,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,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AAC,CAAC;IACxC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAC1C,IAAI,EAAE,GAAG,kBAAkB,GAAG,WAAW,CAAC,UAAU,CAAC;IACrD,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpB,EAAE,IAAI,KAAK,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * write.ts — `.wvdb` writer (mjurczyk's WebVDB spec v0.5.x) from dense\n * volume levels and point lists.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345:\n * `src/wvdb/bake.js` (downsample, getDensityStats, getBrickValues, encodeLod,\n * getPointLods, getPointsBox, the header assembly) and `writeWVDBFile` in\n * `src/openvdb/wvdb/format.js`. The goal is files his `WVDBLoader` reads, and,\n * given the same values and a zlib with the same output (Node's\n * `deflateSync(level 9)`, which his CLI uses), the same bytes. His choices we\n * keep (spec text in brackets where it only says SHOULD/MAY):\n * - defaults: 3 LODs, 8 bits, sparse layout, 1024 bricks per page, 2^18\n * points per points chunk;\n * - coarse LODs are 2x box filters of the next finer LOD over the voxels\n * that exist (§3.2.4), summed in float64, stored as float32;\n * - a sparse LOD drops a brick only when every value (all channels,\n * including the edge-replicated voxels outside the LOD) equals the\n * background exactly (§3.4); a dense LOD stores every brick;\n * - sparse pages hold the bricks with the largest sum of |v - background|\n * first, ties in index order (§9 SHOULD);\n * - `meanDensity` / `nonZeroVoxels` of the finest LOD for scalar grids (his\n * 8-bit `floor(clamp(v, 0, 1) * 255)` texels; level sets count the band);\n * - header member order is his, so `JSON.stringify` gives his header bytes.\n *\n * Compression defaults to fflate `zlibSync` at level 9 (Node + browser). Its\n * deflate stream differs from Node's zlib, so for byte-identical output pass\n * `compress: (b) => zlib.deflateSync(b, { level: 9 })` in Node.\n */\n\nimport { VDBToolsError } from \"../errors.js\";\nimport { zlibSync } from \"fflate\";\nimport {\n WVDB_BRICK_DIM,\n WVDB_BRICK_VOXELS,\n WVDB_MAGIC,\n WVDB_POINTS_PAGE,\n WVDB_POINTS_VERSION,\n WVDB_PREAMBLE_SIZE,\n brickCounts,\n brickOrigin,\n encodeMask,\n encodePage,\n encodePoints,\n type WvdbBits,\n type WvdbBox,\n type WvdbChunkRef,\n type WvdbGridHeader,\n type WvdbHeader,\n type WvdbLayout,\n type WvdbPageRef,\n type WvdbPointsGridHeader,\n type WvdbPointsLodHeader,\n type WvdbPointsPageRef,\n type WvdbSource,\n type WvdbVec3,\n type WvdbVolumeGridHeader,\n type WvdbVolumeLodHeader,\n} from \"./format.js\";\n\n/** One dense level: channel planes one after the other, x fastest. */\nexport interface WvdbDenseLevel {\n /** Voxels per axis. */\n dimensions: WvdbVec3;\n /** The values: all channel planes one after the other (x fastest within a plane). */\n values: Float32Array;\n /**\n * Sparse layout only: the bricks to store, in page order (e.g. a decoded\n * level's `brickIndices`, to keep a file's order when re-encoding). Must\n * hold every brick that is not all background (§3.4). Default: his order\n * (most data first, ties by index).\n */\n brickOrder?: ArrayLike<number>;\n}\n\n/** A volume grid to write with {@link writeWvdb}. */\nexport interface WvdbVolumeGridInput {\n /** `\"volume\"` (the default). */\n type?: \"volume\";\n /** The grid name. */\n name: string;\n /** Default `\"unknown\"`. */\n class?: string;\n /** Default 1. */\n channels?: 1 | 3;\n /** One number, or 3 for a vector grid. */\n background: number | readonly number[];\n /** The grid's active-voxel box in world units, or null when it has none. */\n bbox: WvdbBox | null;\n /**\n * The finest LOD. Coarser LODs are built by `downsampleWvdbLevel` (§3.2).\n * Give `levels` instead to supply every LOD yourself.\n */\n finest?: WvdbDenseLevel;\n /** Every LOD, coarse first (`levels.length` must equal `lods`). */\n levels?: readonly WvdbDenseLevel[];\n /**\n * `meanDensity` / `nonZeroVoxels` for a scalar grid. Default true (his\n * writer always writes them for scalar grids); false omits them; an object\n * writes the given numbers.\n */\n stats?: boolean | { meanDensity: number; nonZeroVoxels: number };\n}\n\n/** A points grid to write with {@link writeWvdb} (makes the file version 2). */\nexport interface WvdbPointsGridInput {\n /** Always `\"points\"`. */\n type: \"points\";\n /** The grid name. */\n name: string;\n /** The grid class string. Default `\"unknown\"`. */\n class?: string;\n /** xyz per point, in the stored order (near indices should be near in space, §3.5). */\n positions: Float32Array;\n /** rgb per point in [0, 1], or null/absent. */\n colors?: Float32Array | null;\n /** Points of the source. Default: the point count before `maxPoints` thinning. */\n sourceCount?: number;\n /** Mean distance between stored points (world units). Default: estimated from the box (see `writeWvdb`). */\n spacing?: number;\n}\n\n/** A grid to write: a volume or a points grid. */\nexport type WvdbGridInput = WvdbVolumeGridInput | WvdbPointsGridInput;\n\n/** Options of {@link writeWvdb}. */\nexport interface WriteWvdbOptions {\n /** LOD count. Default 3. */\n lods?: number;\n /** Quantization bits. Default 8. */\n bits?: WvdbBits;\n /** Default `\"sparse\"`. */\n layout?: WvdbLayout;\n /** Bricks per page chunk. Default 1024. */\n pageBricks?: number;\n /** Recorded as `bake.resolution`. Default: the longest side of the finest LOD of the first volume grid (else 128). */\n resolution?: number;\n /** Recorded as `bake.grids`. Default null. */\n gridNames?: string[] | null;\n /** Recorded as `bake.bbox` (the sequence box, §10). Default null. */\n bakeBBox?: WvdbBox | null;\n /** Keep every n-th point above this many per points grid (his `--max-points`). Default 4,000,000. */\n maxPoints?: number;\n /** `source` header member. Default `{ file: \"\", sha256: \"\" + 64 zeros }`. */\n source?: WvdbSource;\n /** zlib compressor. Default fflate `zlibSync(level 9)`. */\n compress?: (raw: Uint8Array) => Uint8Array;\n}\n\n/** What {@link writeWvdb} returns. */\nexport interface WriteWvdbResult {\n /** The file's bytes. */\n bytes: Uint8Array;\n /** The header that was written. */\n header: WvdbHeader;\n}\n\nconst DEFAULTS = { lods: 3, bits: 8 as WvdbBits, layout: \"sparse\" as WvdbLayout, pageBricks: 1024, maxPoints: 4_000_000 };\nconst ZERO_SHA = \"0\".repeat(64);\n\nconst defaultCompress = (raw: Uint8Array): Uint8Array => zlibSync(raw, { level: 9 });\n\n/** §3.2.3-5: one 2x box-filter step, each channel alone, over the voxels inside the LOD. */\nexport function downsampleWvdbLevel(level: WvdbDenseLevel, channels: number): WvdbDenseLevel {\n const [w, h, d] = level.dimensions;\n const dims: WvdbVec3 = [Math.ceil(w / 2), Math.ceil(h / 2), Math.ceil(d / 2)];\n const [ow, oh, od] = dims;\n const count = w * h * d;\n const outCount = ow * oh * od;\n const out = new Float32Array(outCount * channels);\n for (let c = 0; c < channels; c++) {\n const src = c * count;\n let o = c * outCount;\n for (let z = 0; z < od; z++) {\n for (let y = 0; y < oh; y++) {\n for (let x = 0; x < ow; x++) {\n let sum = 0;\n let n = 0;\n for (let dz = 0; dz < 2; dz++) {\n for (let dy = 0; dy < 2; dy++) {\n for (let dx = 0; dx < 2; dx++) {\n const sx = 2 * x + dx;\n const sy = 2 * y + dy;\n const sz = 2 * z + dz;\n if (sx < w && sy < h && sz < d) {\n sum += level.values[src + sx + sy * w + sz * w * h]!;\n n++;\n }\n }\n }\n }\n out[o++] = sum / n;\n }\n }\n }\n }\n return { dimensions: dims, values: out };\n}\n\n/** His `getDensityStats`: mean and count of the non-zero 8-bit density texels of one LOD. */\nexport function wvdbDensityStats(\n values: Float32Array,\n background: number,\n isLevelSet: boolean,\n): { meanDensity: number; nonZeroVoxels: number } {\n let sum = 0;\n let count = 0;\n for (let i = 0; i < values.length; i++) {\n const texel = isLevelSet\n ? Math.abs(values[i]!) < background\n ? 255\n : 0\n : (Math.min(Math.max(values[i]!, 0), 1) * 255) | 0;\n if (texel > 0) {\n sum += texel;\n count++;\n }\n }\n return { meanDensity: count > 0 ? sum / 255 / count : 0, nonZeroVoxels: count };\n}\n\n/** 512 values per channel; voxels outside the LOD copy the nearest voxel inside (§3.3). */\nfunction brickValues(level: WvdbDenseLevel, index: number, channels: number): Float32Array {\n const [w, h, d] = level.dimensions;\n const [ox, oy, oz] = brickOrigin(level.dimensions, index);\n const count = w * h * d;\n const brick = new Float32Array(WVDB_BRICK_VOXELS * channels);\n let v = 0;\n for (let c = 0; c < channels; c++) {\n const plane = c * count;\n for (let z = 0; z < WVDB_BRICK_DIM; z++) {\n const sz = Math.min(oz + z, d - 1);\n for (let y = 0; y < WVDB_BRICK_DIM; y++) {\n const sy = Math.min(oy + y, h - 1);\n for (let x = 0; x < WVDB_BRICK_DIM; x++) {\n const sx = Math.min(ox + x, w - 1);\n brick[v++] = level.values[plane + sx + sy * w + sz * w * h]!;\n }\n }\n }\n }\n return brick;\n}\n\ninterface EncodedLod {\n dimensions: WvdbVec3;\n bricks: number;\n mask: Uint8Array | null;\n pages: { bricks: number; bytes: Uint8Array }[];\n}\n\nfunction encodeLod(\n level: WvdbDenseLevel,\n background: readonly number[],\n channels: number,\n o: { layout: WvdbLayout; bits: WvdbBits; pageBricks: number; compress: (raw: Uint8Array) => Uint8Array },\n): EncodedLod {\n const sparse = o.layout === \"sparse\";\n const [cx, cy, cz] = brickCounts(level.dimensions);\n const total = cx * cy * cz;\n const bricks: { index: number; weight: number }[] = [];\n for (let index = 0; index < total; index++) {\n const values = brickValues(level, index, channels);\n let isBackground = true;\n let weight = 0;\n for (let v = 0; v < values.length; v++) {\n const bg = background[Math.floor(v / WVDB_BRICK_VOXELS)]!;\n isBackground = isBackground && values[v] === bg;\n weight += Math.abs(values[v]! - bg);\n }\n if (sparse && isBackground) continue;\n bricks.push({ index, weight });\n }\n if (sparse) bricks.sort((a, b) => b.weight - a.weight || a.index - b.index);\n if (sparse && level.brickOrder) {\n const given = Array.from(level.brickOrder);\n const set = new Set(given);\n if (set.size !== given.length) throw new VDBToolsError(\"VDB_BAD_OPTION\", \"writeWvdb: brickOrder lists a brick twice\");\n for (const i of given) {\n if (!Number.isInteger(i) || i < 0 || i >= total) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: brickOrder index ${i} is out of range`);\n }\n for (const b of bricks) {\n if (!set.has(b.index)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: brickOrder omits brick ${b.index}, which is not all background`);\n }\n bricks.length = 0;\n for (const index of given) bricks.push({ index, weight: 0 });\n }\n\n const pages: EncodedLod[\"pages\"] = [];\n for (let start = 0; start < bricks.length; start += o.pageBricks) {\n const page = bricks\n .slice(start, start + o.pageBricks)\n .map(({ index }) => ({ index, values: brickValues(level, index, channels) }));\n pages.push({ bricks: page.length, bytes: o.compress(encodePage(page, { layout: o.layout, bits: o.bits, channels })) });\n }\n return {\n dimensions: [...level.dimensions] as WvdbVec3,\n bricks: bricks.length,\n mask: sparse ? o.compress(encodeMask(bricks.map((b) => b.index), total)) : null,\n pages,\n };\n}\n\n/**\n * §3.5: point i is in the first LOD k where i is a multiple of 8^(lods-1-k).\n * @param count Points in the grid.\n * @param lods Number of LODs.\n * @returns Per LOD (coarse first), the stored indices of the points it adds.\n */\nexport function wvdbPointLods(count: number, lods: number): number[][] {\n return Array.from({ length: lods }, (_, lod) => {\n const stride = 8 ** (lods - 1 - lod);\n const coarser = stride * 8;\n const indices: number[] = [];\n for (let p = 0; p < count; p += stride) if (lod === 0 || p % coarser !== 0) indices.push(p);\n return indices;\n });\n}\n\nfunction gather(source: Float32Array, indices: readonly number[]): Float32Array {\n const out = new Float32Array(indices.length * 3);\n indices.forEach((p, i) => out.set(source.subarray(p * 3, p * 3 + 3), i * 3));\n return out;\n}\n\nfunction pointsBox(positions: Float32Array): WvdbBox | null {\n if (!positions.length) return null;\n const min = [Infinity, Infinity, Infinity];\n const max = [-Infinity, -Infinity, -Infinity];\n for (let i = 0; i < positions.length; i++) {\n min[i % 3] = Math.min(min[i % 3]!, positions[i]!);\n max[i % 3] = Math.max(max[i % 3]!, positions[i]!);\n }\n return [min.map(Math.fround) as WvdbVec3, max.map(Math.fround) as WvdbVec3];\n}\n\nfunction checkLevel(level: WvdbDenseLevel, channels: number, what: string): void {\n const [x, y, z] = level.dimensions;\n if (![x, y, z].every((n) => Number.isInteger(n) && n >= 1)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: ${what}: dimensions must be integers >= 1`);\n if (level.values.length !== x * y * z * channels) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: ${what}: ${level.values.length} values, expected ${x * y * z * channels} (X*Y*Z*channels)`);\n }\n}\n\ntype PendingChunk = { bytes: Uint8Array; entry: WvdbChunkRef };\n\n/**\n * Writes a `.wvdb` file. Volume grids give their finest LOD (or all LODs);\n * points grids give their points. All grids get `lods` LODs. Version 2 is\n * written iff a points grid is present (§11).\n *\n * Points `spacing`, when not given, is `cbrt(boxVolume / sourceCount) *\n * cbrt(stride)` (a uniform-density estimate; his CLI derives it from the\n * source voxel size instead).\n * @param grids The grids to write.\n * @param options LOD count, bits, layout, page size and the header fields.\n */\nexport function writeWvdb(grids: readonly WvdbGridInput[], options: WriteWvdbOptions = {}): WriteWvdbResult {\n const lods = options.lods ?? DEFAULTS.lods;\n const bits = options.bits ?? DEFAULTS.bits;\n const layout = options.layout ?? DEFAULTS.layout;\n const pageBricks = options.pageBricks ?? DEFAULTS.pageBricks;\n const maxPoints = options.maxPoints ?? DEFAULTS.maxPoints;\n const compress = options.compress ?? defaultCompress;\n if (!Number.isInteger(lods) || lods < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid LOD count ${lods}`);\n if (bits !== 8 && bits !== 16) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: bits must be 8 or 16 (got ${String(bits)})`);\n if (layout !== \"dense\" && layout !== \"sparse\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid layout ${String(layout)}`);\n if (!Number.isInteger(pageBricks) || pageBricks < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid pageBricks ${pageBricks}`);\n if (!Number.isInteger(maxPoints) || maxPoints < 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: invalid maxPoints ${maxPoints}`);\n const names = new Set<string>();\n for (const g of grids) {\n if (names.has(g.name)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: grid name \"${g.name}\" is not unique`);\n names.add(g.name);\n }\n\n type Encoded =\n | { kind: \"volume\"; header: Omit<WvdbVolumeGridHeader, \"lods\">; lods: EncodedLod[] }\n | { kind: \"points\"; header: Omit<WvdbPointsGridHeader, \"lods\">; lods: { points: number; pages: { points: number; bytes: Uint8Array }[] }[] };\n\n let resolution = options.resolution;\n const encoded: Encoded[] = grids.map((grid): Encoded => {\n if (grid.type === \"points\") {\n const total = grid.positions.length / 3;\n if (!Number.isInteger(total)) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": positions length is not a multiple of 3`);\n if (grid.colors && grid.colors.length !== grid.positions.length) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": colors must have 3 values per point`);\n }\n const stride = Math.max(1, Math.ceil(total / maxPoints));\n const count = total > 0 ? Math.floor((total - 1) / stride) + 1 : 0;\n let positions = grid.positions;\n let colors = grid.colors ?? null;\n if (stride > 1) {\n const keep = Array.from({ length: count }, (_, i) => i * stride);\n positions = gather(grid.positions, keep);\n colors = colors ? gather(colors, keep) : null;\n }\n const bbox = pointsBox(positions);\n let spacing = grid.spacing;\n if (spacing === undefined) {\n const size = bbox ? bbox[1].map((v, a) => v - bbox[0][a]!) : [0, 0, 0];\n const volume = size[0]! * size[1]! * size[2]!;\n const sourceCount = grid.sourceCount ?? total;\n spacing = sourceCount > 0 && volume > 0 ? Math.cbrt(volume / sourceCount) * Math.cbrt(stride) : 0;\n }\n return {\n kind: \"points\",\n header: {\n name: grid.name,\n type: \"points\",\n class: grid.class ?? \"unknown\",\n count,\n sourceCount: grid.sourceCount ?? total,\n spacing: Math.fround(spacing),\n colors: !!colors,\n bbox,\n },\n lods: wvdbPointLods(count, lods).map((indices) => {\n const pages: { points: number; bytes: Uint8Array }[] = [];\n for (let start = 0; start < indices.length; start += WVDB_POINTS_PAGE) {\n const page = indices.slice(start, start + WVDB_POINTS_PAGE);\n pages.push({ points: page.length, bytes: compress(encodePoints(gather(positions, page), colors ? gather(colors, page) : null)) });\n }\n return { points: indices.length, pages };\n }),\n };\n }\n\n const channels = grid.channels ?? 1;\n if (channels !== 1 && channels !== 3) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": channels must be 1 or 3`);\n const background = typeof grid.background === \"number\" ? [grid.background] : [...grid.background];\n if (background.length !== channels) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": background needs ${channels} value(s)`);\n const bg32 = background.map(Math.fround);\n let levels: WvdbDenseLevel[];\n if (grid.levels) {\n if (grid.levels.length !== lods) throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": ${grid.levels.length} levels given, lods is ${lods}`);\n levels = [...grid.levels];\n } else if (grid.finest) {\n levels = [];\n levels[lods - 1] = grid.finest;\n for (let lod = lods - 2; lod >= 0; lod--) levels[lod] = downsampleWvdbLevel(levels[lod + 1]!, channels);\n } else {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `writeWvdb: \"${grid.name}\": give finest or levels`);\n }\n levels.forEach((l, i) => checkLevel(l, channels, `\"${grid.name}\" LOD ${i}`));\n resolution ??= Math.max(...levels[lods - 1]!.dimensions);\n const gridClass = grid.class ?? \"unknown\";\n let stats: { meanDensity: number; nonZeroVoxels: number } | null = null;\n if (channels === 1 && grid.stats !== false) {\n stats =\n typeof grid.stats === \"object\"\n ? grid.stats\n : wvdbDensityStats(levels[lods - 1]!.values, bg32[0]!, gridClass === \"level set\");\n }\n return {\n kind: \"volume\",\n header: {\n name: grid.name,\n class: gridClass,\n channels,\n background: channels === 1 ? bg32[0]! : (bg32 as WvdbVec3),\n bbox: grid.bbox,\n ...(stats ? { meanDensity: stats.meanDensity, nonZeroVoxels: stats.nonZeroVoxels } : {}),\n },\n lods: levels.map((level) => encodeLod(level, bg32, channels, { layout, bits, pageBricks, compress })),\n };\n });\n\n // §9: LOD 0 of all grids, then LOD 1, ...; per grid the mask, then the pages.\n const chunks: PendingChunk[] = [];\n const headerLods: (WvdbVolumeLodHeader | WvdbPointsLodHeader)[][] = encoded.map(() => []);\n for (let lod = 0; lod < lods; lod++) {\n encoded.forEach((grid, gi) => {\n if (grid.kind === \"points\") {\n const { points, pages } = grid.lods[lod]!;\n headerLods[gi]![lod] = {\n points,\n pages: pages.map((page) => {\n const entry: WvdbPointsPageRef = { offset: 0, length: 0, points: page.points };\n chunks.push({ bytes: page.bytes, entry });\n return entry;\n }),\n };\n return;\n }\n const { dimensions, bricks, mask, pages } = grid.lods[lod]!;\n // Key order dimensions, bricks, mask, pages (his header bytes); pages are added after the mask.\n const entry = { dimensions, bricks } as WvdbVolumeLodHeader;\n if (mask) {\n entry.mask = { offset: 0, length: 0 };\n chunks.push({ bytes: mask, entry: entry.mask });\n }\n entry.pages = pages.map((page) => {\n const ref: WvdbPageRef = { offset: 0, length: 0, bricks: page.bricks };\n chunks.push({ bytes: page.bytes, entry: ref });\n return ref;\n });\n headerLods[gi]![lod] = entry;\n });\n }\n\n const hasPoints = encoded.some((g) => g.kind === \"points\");\n const header: WvdbHeader = {\n version: hasPoints ? WVDB_POINTS_VERSION : 1,\n source: options.source ?? { file: \"\", sha256: ZERO_SHA },\n bake: {\n grids: options.gridNames ?? null,\n resolution: resolution ?? 128,\n lods,\n bits,\n layout,\n pageBricks,\n bbox: options.bakeBBox ?? null,\n ...(hasPoints ? { maxPoints } : {}),\n },\n brickDim: WVDB_BRICK_DIM,\n grids: encoded.map((g, gi) => ({ ...g.header, lods: headerLods[gi] }) as WvdbGridHeader),\n };\n return { bytes: assembleWvdb(header, chunks), header };\n}\n\n/** Sets each chunk's offset/length, then lays out preamble + header JSON + chunks (§4). */\nfunction assembleWvdb(header: WvdbHeader, chunks: PendingChunk[]): Uint8Array {\n let offset = 0;\n for (const { bytes, entry } of chunks) {\n entry.offset = offset;\n entry.length = bytes.byteLength;\n offset += bytes.byteLength;\n }\n const headerBytes = new TextEncoder().encode(JSON.stringify(header));\n const file = new Uint8Array(WVDB_PREAMBLE_SIZE + headerBytes.byteLength + offset);\n const view = new DataView(file.buffer);\n for (let i = 0; i < 4; i++) file[i] = WVDB_MAGIC.charCodeAt(i);\n view.setUint32(4, header.version, true);\n view.setUint32(8, headerBytes.byteLength, true);\n file.set(headerBytes, WVDB_PREAMBLE_SIZE);\n let at = WVDB_PREAMBLE_SIZE + headerBytes.byteLength;\n for (const { bytes } of chunks) {\n file.set(bytes, at);\n at += bytes.byteLength;\n }\n return file;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmndrs/vdb",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Sparse NanoVDB volumes on WebGPU: engine-free WGSL core, pure-TS CPU tools, three.js adapter",
5
5
  "license": "MIT",
6
6
  "homepage": "https://pmndrs.github.io/vdb/",
@@ -77,6 +77,7 @@
77
77
  },
78
78
  "devDependencies": {
79
79
  "@types/three": "0.187.0",
80
+ "meshoptimizer": "^1.3.0",
80
81
  "three": "0.187.0",
81
82
  "typescript": "^5.8.0",
82
83
  "vitest": "^4.1.12"
package/vendor/VENDOR.md CHANGED
@@ -15,12 +15,12 @@ upstream fixes if the author engages.
15
15
  | Pinned commit | `265e8d825e4e4ab8752196a28cccad592d9b4262` |
16
16
  | Vendored | 2026-07-11 |
17
17
  | License | Apache-2.0 (see `LICENSE`; attribution in `NOTICE`) |
18
- | SHA-256 of vendored file | `f28fe6927ea1eead9e4d4d619c9b2e1fe365ac75514e1d19738354ecaf56b4ca` |
18
+ | SHA-256 of vendored file | `93bf47dea257f60b6f58f6f48ad3049a982c82c1984bdc6094f4c7af955f4a80` |
19
19
 
20
20
  The SHA-256 above is of the file **as vendored**. It started byte-identical
21
21
  to upstream at the pinned commit; the Phase 2 additions logged below (all
22
22
  appended after the upstream body — no upstream lines were modified) have
23
- since advanced it, as has the K1.4b leaf-stats fix (which edits only WebVDB-added lines). It is asserted by `test/vendor.test.ts` so accidental
23
+ since advanced it, as have the K1.4b leaf-stats fix and the K7.H Half additions (both edit only WebVDB-added lines). It is asserted by `test/vendor.test.ts` so accidental
24
24
  edits fail CI; deliberate edits update the hash *and* the diff log below in
25
25
  the same commit.
26
26
 
@@ -36,11 +36,22 @@ diffs against a fixed target:
36
36
  |---|---|
37
37
  | Upstream | <https://github.com/AcademySoftwareFoundation/openvdb> |
38
38
  | File | `nanovdb/nanovdb/PNanoVDB.h` |
39
- | Pinned commit | `a532de5526ef791280b6483a872336a811a68542` |
40
- | ABI | 32.9.1 (`PNANOVDB_MAJOR/MINOR/PATCH_VERSION_NUMBER`) |
41
- | Vendored | 2026-07-11 |
39
+ | Pinned tag | `v14.0.0` (commit `ecae2bda85744412b0cd47e1b8e1e4e76beb7b88`) |
40
+ | ABI | 32.11.0 (`PNANOVDB_MAJOR/MINOR/PATCH_VERSION_NUMBER`) |
41
+ | Vendored | 2026-11-28 (K7.5; first vendored 2026-07-11 at `a532de5526ef791280b6483a872336a811a68542`, ABI 32.9.1) |
42
42
  | License | Apache-2.0 (SPDX header in file) |
43
- | SHA-256 | `083a61491472bd2b008d5c3406aea0b1ac047c031b251047a5e38dac29f17410` |
43
+ | SHA-256 | `babd0a1df29d8cfd371c9d05387f219f28e5aa29f1e98f25fdcc4bc8cf862037` |
44
+
45
+ Provenance (repo, path, commit, tag, SHA-256, ABI) is also recorded in
46
+ `stride-tables.json` `$meta` by `scripts/extract-stride-tables.mjs` and asserted by
47
+ `test/tools/stride-tables.test.ts`. The upstream watch (K7.6,
48
+ `.github/upstream-pins.json`) reports new OpenVDB releases.
49
+
50
+ ### Re-pin log
51
+
52
+ | Date | From → to | What moved in the header | Effect here |
53
+ |---|---|---|---|
54
+ | 2026-11-28 (K7.5) | `a532de55` (32.9.1) → `v14.0.0` (32.11.0) | `PNANOVDB_MINOR/PATCH_VERSION_NUMBER` 9/1 → 11/0; a new C-only `PNANOVDB_UNUSED(X)` macro (empty for GLSL/HLSL) called on unused parameters in 37 places; `(void)size_in_words` in the C `pnanovdb_buf_t` branch. No struct, offset, constant-table, grid-type or function-body change. | `stride-tables.json`, `src/tools/cpu/stride-tables.generated.ts` and `src/core/wgsl/pnanovdb-constants.generated.wgsl` regenerated (only `$meta` and the two version defines moved). The fork, the generated modules (size snapshot unchanged) and the `tools` mirrors need nothing. Our writers keep stamping 32.9.1 (DIVERGES V163, TASKS K7.5a). |
44
55
 
45
56
  ## Extracted stride tables: `stride-tables.json`
46
57
 
@@ -57,6 +68,7 @@ Every in-tree change to `pnanovdb.wgsl` gets one row here, newest first.
57
68
 
58
69
  | Date | Change | Reason | Upstreamed? |
59
70
  |---|---|---|---|
71
+ | 2026-11-24 (K7.H) | **Half grids** (NanoVDB `GridType::Half` = 9, raw IEEE binary16; implemented in NanoVDB 13.2 / OpenVDB PR 2335; layout = the HALF row of `pnanovdb_grid_type_constants`, unchanged between `a532de55` and v14.0.0). Added `pnanovdb_read_half` (PNanoVDB.h, GLSL branch: `unpackHalf2x16` -> WGSL `unpack2x16float` of the word shifted by `(address & 2) * 8`), `pnanovdb_read_minmax_float` (root/upper/lower min/max slot: binary16 for HALF, f32 otherwise) and `pnanovdb_leaf_get_minmax_float` (leaf min/max: binary16 for HALF, else `pnanovdb_leaf_get_stat_float`). Edited WebVDB-added lines only: a HALF branch in `pnanovdb_read_float_typed` (its comment claimed HALF was stored as f32), the eight `{root,upper,lower,leaf}_get_{min,max}_float` readers now call the two min/max readers, and comments. Ave/stddev stay f32 for HALF. CPU twins: `tools/cpu/read-value.ts`, `tools/cpu/march.ts` (`nodeStats`); parity: `e2e/core-parity.spec.ts`. | Read, sample and march Half grids (K7.H). | No (WebVDB; `pnanovdb_read_half` is a transliteration). |
60
72
  | 2026-11-18 (K1.4b) | **Fix:** `pnanovdb_leaf_get_{min,max,ave,stddev}_float` read the leaf stats slot as f32 for every type. For Fp4/Fp8/Fp16/FpN leaves the slots are uint16 codes at bytes 88/90/92/94 (NanoVDB.h `LeafFnBase::mMin/mMax/mAvg/mDev`), so the f32 read returned two packed codes (byte 90 is not word-aligned). Added `pnanovdb_read_uint16` (PNanoVDB.h, plus an explicit `& 65535u` mask), `pnanovdb_leaf_fp_get_stat_float` (`code * mQuantum + mMinimum`; `mDev` is `code * mQuantum`, as `LeafFnBase::getMin/getMax/getAvg/getDev` at OpenVDB `a532de55`) and the dispatcher `pnanovdb_leaf_get_stat_float`; the four leaf readers call it. Root/upper/lower readers unchanged (their Fp stats are f32). Only WebVDB-added lines changed. CPU twin: `tools/cpu/march.ts` `nodeStats`; parity: `test/tools/cpu-march.test.ts`. | Design note K1-core §5.3; `vdbNodeMax` (`march` profile) reads leaf max. v1 never called the leaf readers. | No (the `_float` readers are WebVDB). |
61
73
  | 2026-07-11 | Phase 2 audit: line-by-line diff of the existing port against `upstream/PNanoVDB.h` (constants table, coord_to_key, readaccessor cache, child getters, HDDA, is_active). No functional deviations found; no edits to upstream lines. | Establish audited baseline before extending. | N/A (no change) |
62
74
  | 2026-07-11 | Add stats readers: `{root,lower,leaf}_get_{min,max,ave,stddev}_address` + `root_get_background_address` (upstream parity; `upper_*` already present), plus `{root,upper,lower,leaf}_get_{min,max,ave,stddev}_float` f32 convenience readers. | Renderer needs node min/max for shading/empty-space skipping. | Address getters yes; `_float` readers are WebVDB. |
@@ -82,4 +94,7 @@ above. One row per transform (design note `docs/dev/design/K1-core.md` §3.3).
82
94
  | 2026-11-18 (K1.4a) | `pnanovdb_read_float_typed` | only the compiled Fp types' branches; Float is the fallthrough, or, with no Float, the last compiled Fp type is | Decoders of types not compiled drop out of the closure. Reads of other types never get here (`VdbAccessor.ok`). |
83
95
  | 2026-11-18 (K1.4a) | `pnanovdb_sample_trilinear_{float,fp8,fpn}` | not emitted (unreachable) | The API layer's `vdbSample` calls `pnanovdb_sample_trilinear_typed` with the grid's runtime type. |
84
96
  | 2026-11-18 (K1.4b) | `pnanovdb_leaf_get_stat_float` (the leaf-stats dispatch added by the K1.4b fix) | only the compiled types' branch: no Fp type compiled, a plain `pnanovdb_read_float`; only Fp types, the uint16 decode unconditionally; both, one branch over the compiled Fp types | The uint16 decoder (`pnanovdb_read_uint16`, `pnanovdb_leaf_fp_get_stat_float`) drops out of Float-only `march` modules. |
97
+ | 2026-11-24 (K7.H) | `pnanovdb_read_float_typed` (Half) | the Half branch (`pnanovdb_read_half(buf, address)`, every level) only when `half` is compiled; Half is the fallthrough when it is the last compiled non-Float type | As transform 3 for the Fp types. |
98
+ | 2026-11-24 (K7.H) | `pnanovdb_read_minmax_float`, `pnanovdb_leaf_get_minmax_float` and their call sites | without `half`: call sites become the readers they wrap (`pnanovdb_read_float(buf, ...)`, `pnanovdb_leaf_get_stat_float(..., true)`) and the two drop out; with `half` only: `return pnanovdb_read_half(buf, address);`; with `half` and others: one Half branch | Modules without `half` stay byte-identical to those generated before K7.H (size snapshot unchanged). |
99
+ | 2026-11-24 (K7.H) | `pnanovdb_leaf_get_stat_float` (with Half) | Half counts as a plain (f32) type: its leaf ave/stddev are f32 | Half leaf min/max go through `pnanovdb_leaf_get_minmax_float`. |
85
100
  | 2026-11-18 (K1.4a) | every `pnanovdb_` / `PNANOVDB_` identifier | `vdb_` / `VDB_` | One prefix for the whole module (D10, D17). |
@@ -1297,10 +1297,11 @@ fn pnanovdb_root_fpn_read_float(buf: pnanovdb_buf_t, address: pnanovdb_address_t
1297
1297
  // --- Typed value read (WebVDB extension) ---
1298
1298
  // Resolve a voxel to a decoded f32. This is the ONE runtime grid_type switch:
1299
1299
  // it wraps the upstream address+level lookup and applies the per-grid-type
1300
- // leaf decode (plain f32 for FLOAT/HALF and all tile/background levels;
1301
- // quantized decode for Fp4/Fp8/Fp16/FpN leaves). Per-type public entry points
1302
- // (the sample_trilinear_* family) are thin wrappers over this — the fork
1303
- // specializes at the public API boundary rather than duplicating traversal.
1300
+ // decode (plain f32 for FLOAT and all Fp tile/background levels; binary16 at
1301
+ // every level for HALF; quantized decode for Fp4/Fp8/Fp16/FpN leaves).
1302
+ // Per-type public entry points (the sample_trilinear_* family) are thin
1303
+ // wrappers over this — the fork specializes at the public API boundary rather
1304
+ // than duplicating traversal.
1304
1305
  fn pnanovdb_read_float_typed(grid_type: u32, buf: pnanovdb_buf_t, address: pnanovdb_address_t, ijk: vec3i, level: u32) -> f32 {
1305
1306
  if grid_type == PNANOVDB_GRID_TYPE_FP4 {
1306
1307
  return pnanovdb_root_fp4_read_float(buf, address, ijk, level);
@@ -1310,8 +1311,10 @@ fn pnanovdb_read_float_typed(grid_type: u32, buf: pnanovdb_buf_t, address: pnano
1310
1311
  return pnanovdb_root_fp16_read_float(buf, address, ijk, level);
1311
1312
  } else if grid_type == PNANOVDB_GRID_TYPE_FPN {
1312
1313
  return pnanovdb_root_fpn_read_float(buf, address, ijk, level);
1314
+ } else if grid_type == PNANOVDB_GRID_TYPE_HALF {
1315
+ return pnanovdb_read_half(buf, address);
1313
1316
  }
1314
- // FLOAT (and HALF stored as f32 in these fixtures) read verbatim.
1317
+ // FLOAT reads verbatim.
1315
1318
  return pnanovdb_read_float(buf, address);
1316
1319
  }
1317
1320
 
@@ -1451,12 +1454,14 @@ fn pnanovdb_leaf_get_stddev_address(grid_type: u32, buf: pnanovdb_buf_t, node: p
1451
1454
  // f32 convenience readers over the stats slots (WebVDB: upstream returns the
1452
1455
  // address and lets the caller read a typed value). Root, upper and lower
1453
1456
  // stats are f32 for FLOAT and the Fp types; leaf stats of the Fp types are
1454
- // uint16 codes and are decoded by pnanovdb_leaf_get_stat_float.
1457
+ // uint16 codes and are decoded by pnanovdb_leaf_get_stat_float. HALF min/max
1458
+ // are binary16 at every level (pnanovdb_read_minmax_float,
1459
+ // pnanovdb_leaf_get_minmax_float); its ave/stddev stay f32.
1455
1460
  fn pnanovdb_root_get_min_float(grid_type: u32, buf: pnanovdb_buf_t, root: pnanovdb_root_handle_t) -> f32 {
1456
- return pnanovdb_read_float(buf, pnanovdb_root_get_min_address(grid_type, buf, root));
1461
+ return pnanovdb_read_minmax_float(grid_type, buf, pnanovdb_root_get_min_address(grid_type, buf, root));
1457
1462
  }
1458
1463
  fn pnanovdb_root_get_max_float(grid_type: u32, buf: pnanovdb_buf_t, root: pnanovdb_root_handle_t) -> f32 {
1459
- return pnanovdb_read_float(buf, pnanovdb_root_get_max_address(grid_type, buf, root));
1464
+ return pnanovdb_read_minmax_float(grid_type, buf, pnanovdb_root_get_max_address(grid_type, buf, root));
1460
1465
  }
1461
1466
  fn pnanovdb_root_get_ave_float(grid_type: u32, buf: pnanovdb_buf_t, root: pnanovdb_root_handle_t) -> f32 {
1462
1467
  return pnanovdb_read_float(buf, pnanovdb_root_get_ave_address(grid_type, buf, root));
@@ -1465,10 +1470,10 @@ fn pnanovdb_root_get_stddev_float(grid_type: u32, buf: pnanovdb_buf_t, root: pna
1465
1470
  return pnanovdb_read_float(buf, pnanovdb_root_get_stddev_address(grid_type, buf, root));
1466
1471
  }
1467
1472
  fn pnanovdb_upper_get_min_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_upper_handle_t) -> f32 {
1468
- return pnanovdb_read_float(buf, pnanovdb_upper_get_min_address(grid_type, buf, node));
1473
+ return pnanovdb_read_minmax_float(grid_type, buf, pnanovdb_upper_get_min_address(grid_type, buf, node));
1469
1474
  }
1470
1475
  fn pnanovdb_upper_get_max_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_upper_handle_t) -> f32 {
1471
- return pnanovdb_read_float(buf, pnanovdb_upper_get_max_address(grid_type, buf, node));
1476
+ return pnanovdb_read_minmax_float(grid_type, buf, pnanovdb_upper_get_max_address(grid_type, buf, node));
1472
1477
  }
1473
1478
  fn pnanovdb_upper_get_ave_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_upper_handle_t) -> f32 {
1474
1479
  return pnanovdb_read_float(buf, pnanovdb_upper_get_ave_address(grid_type, buf, node));
@@ -1477,10 +1482,10 @@ fn pnanovdb_upper_get_stddev_float(grid_type: u32, buf: pnanovdb_buf_t, node: pn
1477
1482
  return pnanovdb_read_float(buf, pnanovdb_upper_get_stddev_address(grid_type, buf, node));
1478
1483
  }
1479
1484
  fn pnanovdb_lower_get_min_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_lower_handle_t) -> f32 {
1480
- return pnanovdb_read_float(buf, pnanovdb_lower_get_min_address(grid_type, buf, node));
1485
+ return pnanovdb_read_minmax_float(grid_type, buf, pnanovdb_lower_get_min_address(grid_type, buf, node));
1481
1486
  }
1482
1487
  fn pnanovdb_lower_get_max_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_lower_handle_t) -> f32 {
1483
- return pnanovdb_read_float(buf, pnanovdb_lower_get_max_address(grid_type, buf, node));
1488
+ return pnanovdb_read_minmax_float(grid_type, buf, pnanovdb_lower_get_max_address(grid_type, buf, node));
1484
1489
  }
1485
1490
  fn pnanovdb_lower_get_ave_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_lower_handle_t) -> f32 {
1486
1491
  return pnanovdb_read_float(buf, pnanovdb_lower_get_ave_address(grid_type, buf, node));
@@ -1526,10 +1531,10 @@ fn pnanovdb_leaf_get_stat_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnano
1526
1531
  }
1527
1532
 
1528
1533
  fn pnanovdb_leaf_get_min_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_leaf_handle_t) -> f32 {
1529
- return pnanovdb_leaf_get_stat_float(grid_type, buf, node, pnanovdb_leaf_get_min_address(grid_type, buf, node), true);
1534
+ return pnanovdb_leaf_get_minmax_float(grid_type, buf, node, pnanovdb_leaf_get_min_address(grid_type, buf, node));
1530
1535
  }
1531
1536
  fn pnanovdb_leaf_get_max_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_leaf_handle_t) -> f32 {
1532
- return pnanovdb_leaf_get_stat_float(grid_type, buf, node, pnanovdb_leaf_get_max_address(grid_type, buf, node), true);
1537
+ return pnanovdb_leaf_get_minmax_float(grid_type, buf, node, pnanovdb_leaf_get_max_address(grid_type, buf, node));
1533
1538
  }
1534
1539
  fn pnanovdb_leaf_get_ave_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_leaf_handle_t) -> f32 {
1535
1540
  return pnanovdb_leaf_get_stat_float(grid_type, buf, node, pnanovdb_leaf_get_ave_address(grid_type, buf, node), true);
@@ -1537,3 +1542,36 @@ fn pnanovdb_leaf_get_ave_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanov
1537
1542
  fn pnanovdb_leaf_get_stddev_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_leaf_handle_t) -> f32 {
1538
1543
  return pnanovdb_leaf_get_stat_float(grid_type, buf, node, pnanovdb_leaf_get_stddev_address(grid_type, buf, node), false);
1539
1544
  }
1545
+
1546
+ // --- Half (WebVDB, K7.H) ---
1547
+ // NanoVDB GridType::Half (9; implemented in NanoVDB 13.2, OpenVDB PR 2335)
1548
+ // stores raw IEEE binary16 voxels (512 x 2 bytes from leaf byte 96), tile and
1549
+ // background values in their slots, and binary16 min/max at every level; ave
1550
+ // and stddev are f32 (FloatTraits<Half> is float). Offsets: the HALF row of
1551
+ // pnanovdb_grid_type_constants (root 28/30/32/36/40, upper 8224/8226/8228/8232,
1552
+ // lower 1056/1058/1060/1064, leaf 80/82/84/88, leaf table 96, value stride 16).
1553
+
1554
+ // pnanovdb_read_half (PNanoVDB.h, GLSL branch: unpackHalf2x16). The address is
1555
+ // 2-byte aligned; the word read truncates it, the shift picks the half.
1556
+ fn pnanovdb_read_half(buf: pnanovdb_buf_t, address: pnanovdb_address_t) -> f32 {
1557
+ let raw = pnanovdb_read_uint32(buf, address);
1558
+ return unpack2x16float(raw >> ((address & 2u) << 3u)).x;
1559
+ }
1560
+
1561
+ // A root/upper/lower min or max stats slot as f32: binary16 for HALF, f32
1562
+ // otherwise.
1563
+ fn pnanovdb_read_minmax_float(grid_type: u32, buf: pnanovdb_buf_t, address: pnanovdb_address_t) -> f32 {
1564
+ if grid_type == PNANOVDB_GRID_TYPE_HALF {
1565
+ return pnanovdb_read_half(buf, address);
1566
+ }
1567
+ return pnanovdb_read_float(buf, address);
1568
+ }
1569
+
1570
+ // A leaf min or max stats slot as f32: binary16 for HALF, else the leaf stat
1571
+ // dispatch (uint16 code for the Fp types, f32 otherwise).
1572
+ fn pnanovdb_leaf_get_minmax_float(grid_type: u32, buf: pnanovdb_buf_t, node: pnanovdb_leaf_handle_t, address: pnanovdb_address_t) -> f32 {
1573
+ if grid_type == PNANOVDB_GRID_TYPE_HALF {
1574
+ return pnanovdb_read_half(buf, address);
1575
+ }
1576
+ return pnanovdb_leaf_get_stat_float(grid_type, buf, node, address, true);
1577
+ }
@@ -1,42 +0,0 @@
1
- /**
2
- * K3.6: his physical emission spectra as an emission colour hook:
3
- *
4
- * const flames = vdbFrameBlackbodyEmission("soot", 1.39);
5
- * new VDBFrameVolume(source, { emissionColor: flames, temperatureRange: [0, 3000], emissiveIntensity: 13 });
6
- * flames.sootExponent.value = 2.0; // a uniform: no rebuild
7
- *
8
- * `'planck'`: blackbody colour; `'soot'`: × λ^−exponent (0–3). The colour is normalized (largest channel 1); the
9
- * volume's power still grows with temperature⁴ (`sampleEmission`). The CIE 1931 colour matching functions are the
10
- * analytic fit of Wyman, Sloan & Shirley (2013; D33): against the CIE table the normalized colour moves by ≤ 0.021
11
- * per channel over 1,000–40,000 K (chromaticity Δxy ≤ 0.0016 from 3,000 K up, 0.015 at 1,000 K where the fit's red
12
- * tail past ~680 nm is short).
13
- */
14
- import * as THREE from "three";
15
- import type { VDBTslNode } from "../grid-node.js";
16
- import { type VDBColorMatchingFunctions } from "../../tools/frame/blackbody.js";
17
- type N = VDBTslNode;
18
- /** The 256 × 16 RGBA float table as a texture (made once per `cmf`; read with `load`, no filtering). */
19
- export declare function getFrameBlackbodyMap(cmf?: VDBColorMatchingFunctions): THREE.DataTexture;
20
- /** frameBlackbodyColor: the table at a temperature (K) and soot exponent, linear in log temperature and exponent. */
21
- export declare const frameBlackbodyColor: (map: N, temperature: N, exponent: N) => N;
22
- /** An emission colour hook with its soot exponent uniform. */
23
- export interface VDBFrameBlackbodyHook {
24
- (temperature: N): N;
25
- /** The soot exponent (0–3; 'planck': 0). Set `.value` at runtime. */
26
- readonly sootExponent: {
27
- value: number;
28
- };
29
- readonly spectrum: "planck" | "soot";
30
- /** The table texture this hook reads (one per colour matching functions; D33). */
31
- readonly table: THREE.DataTexture;
32
- }
33
- /**
34
- * The `emissionColor` hook of his `'planck'` / `'soot'` emission spectra (`VDBFrameVolume` / `vdbVolumeNodes`
35
- * `emissionColor`). Temperatures ≤ 0 give black (the source's `sampleEmission` already selects them out).
36
- * `options.cmf`: the CIE 1931 colour matching functions (x̄, ȳ, z̄ at a wavelength in nm, read at 380–780 nm in 5 nm
37
- * steps); default the analytic fit `vdbCie1931Fit` (D33). Pass the exact CIE table here to match his colours exactly.
38
- */
39
- export declare function vdbFrameBlackbodyEmission(spectrum?: "planck" | "soot", sootExponent?: number, options?: {
40
- cmf?: VDBColorMatchingFunctions;
41
- }): VDBFrameBlackbodyHook;
42
- export {};
@@ -1,74 +0,0 @@
1
- // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/webgpu/frameShaderChunks.js L222–256 (the blackbody table texture and
3
- // frameBlackbodyColor), L1003–1010 (the 'planck' / 'soot' branch of sampleEmission).
4
- // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
- // Changes: TypeScript; an `emissionColor` hook of `VDBFrameVolume` (the volume-source seam) instead of a built-in
6
- // spectrum switch; his 'approximate' (Shadertoy) spectrum is not ported (R1 §7, DIVERGES V24). The table is engine-free
7
- // (`@pmndrs/vdb/tools` `vdbFrameBlackbodyTable`, with a CPU twin of the read). D33: the colour matching functions are
8
- // the analytic fit of Wyman, Sloan & Shirley (JCGT 2(2), 2013), not his CIE 1931 table (CC BY-SA 4.0); `options.cmf`
9
- // takes others (e.g. the exact table, supplied by the caller under its own licence).
10
- /**
11
- * K3.6: his physical emission spectra as an emission colour hook:
12
- *
13
- * const flames = vdbFrameBlackbodyEmission("soot", 1.39);
14
- * new VDBFrameVolume(source, { emissionColor: flames, temperatureRange: [0, 3000], emissiveIntensity: 13 });
15
- * flames.sootExponent.value = 2.0; // a uniform: no rebuild
16
- *
17
- * `'planck'`: blackbody colour; `'soot'`: × λ^−exponent (0–3). The colour is normalized (largest channel 1); the
18
- * volume's power still grows with temperature⁴ (`sampleEmission`). The CIE 1931 colour matching functions are the
19
- * analytic fit of Wyman, Sloan & Shirley (2013; D33): against the CIE table the normalized colour moves by ≤ 0.021
20
- * per channel over 1,000–40,000 K (chromaticity Δxy ≤ 0.0016 from 3,000 K up, 0.015 at 1,000 K where the fit's red
21
- * tail past ~680 nm is short).
22
- */
23
- import * as THREE from "three";
24
- import * as TSL from "three/tsl";
25
- import { frameBlackbodyMaxTemperature, frameBlackbodyMinTemperature, frameBlackbodyTableRows, frameBlackbodyTableSize, frameMaxSootExponent, vdbCie1931Fit, vdbFrameBlackbodyTable, vdbFrameEmissionSpectrum, } from "../../tools/frame/blackbody.js";
26
- const { clamp, float, int, ivec2, log, max, min, mix, texture, uniform } = TSL;
27
- const tableTextures = new WeakMap();
28
- /** The 256 × 16 RGBA float table as a texture (made once per `cmf`; read with `load`, no filtering). */
29
- export function getFrameBlackbodyMap(cmf = vdbCie1931Fit) {
30
- let tableTexture = tableTextures.get(cmf);
31
- if (!tableTexture) {
32
- tableTexture = new THREE.DataTexture(vdbFrameBlackbodyTable(cmf), frameBlackbodyTableSize, frameBlackbodyTableRows, THREE.RGBAFormat, THREE.FloatType);
33
- tableTexture.minFilter = THREE.NearestFilter;
34
- tableTexture.magFilter = THREE.NearestFilter;
35
- tableTexture.generateMipmaps = false;
36
- tableTexture.needsUpdate = true;
37
- tableTextures.set(cmf, tableTexture);
38
- }
39
- return tableTexture;
40
- }
41
- /** frameBlackbodyColor: the table at a temperature (K) and soot exponent, linear in log temperature and exponent. */
42
- export const frameBlackbodyColor = (map, temperature, exponent) => {
43
- const temperatureScale = Math.log(frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature);
44
- const logTemperature = log(max(temperature, 1e-3).div(frameBlackbodyMinTemperature));
45
- const x = clamp(logTemperature.div(temperatureScale), 0.0, 1.0)
46
- .mul(frameBlackbodyTableSize - 1)
47
- .toVar();
48
- const y = clamp(exponent.div(frameMaxSootExponent), 0.0, 1.0)
49
- .mul(frameBlackbodyTableRows - 1)
50
- .toVar();
51
- const column = min(int(x), int(frameBlackbodyTableSize - 2)).toVar();
52
- const row = min(int(y), int(frameBlackbodyTableRows - 2)).toVar();
53
- const blendX = x.sub(float(column)).toVar();
54
- const texel = (offsetX, offsetY) => map.load(ivec2(column.add(offsetX), row.add(offsetY))).rgb;
55
- return mix(mix(texel(0, 0), texel(1, 0), blendX), mix(texel(0, 1), texel(1, 1), blendX), y.sub(float(row)));
56
- };
57
- /**
58
- * The `emissionColor` hook of his `'planck'` / `'soot'` emission spectra (`VDBFrameVolume` / `vdbVolumeNodes`
59
- * `emissionColor`). Temperatures ≤ 0 give black (the source's `sampleEmission` already selects them out).
60
- * `options.cmf`: the CIE 1931 colour matching functions (x̄, ȳ, z̄ at a wavelength in nm, read at 380–780 nm in 5 nm
61
- * steps); default the analytic fit `vdbCie1931Fit` (D33). Pass the exact CIE table here to match his colours exactly.
62
- */
63
- export function vdbFrameBlackbodyEmission(spectrum = "planck", sootExponent = 1.39, options = {}) {
64
- const [, exponent] = vdbFrameEmissionSpectrum(spectrum, sootExponent);
65
- const exponentNode = uniform(exponent);
66
- const table = getFrameBlackbodyMap(options.cmf);
67
- const map = texture(table);
68
- const hook = ((temperature) => frameBlackbodyColor(map, temperature, exponentNode));
69
- Object.defineProperty(hook, "sootExponent", { value: exponentNode });
70
- Object.defineProperty(hook, "spectrum", { value: spectrum });
71
- Object.defineProperty(hook, "table", { value: table });
72
- return hook;
73
- }
74
- //# sourceMappingURL=blackbody.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blackbody.js","sourceRoot":"","sources":["../../../src/three/frame/blackbody.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kGAAkG;AAClG,uFAAuF;AACvF,4GAA4G;AAC5G,kHAAkH;AAClH,wHAAwH;AACxH,sHAAsH;AACtH,qHAAqH;AACrH,qFAAqF;AAErF;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,wBAAwB,GAEzB,MAAM,gCAAgC,CAAC;AAExC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,GAA4C,CAAC;AAIxH,MAAM,aAAa,GAAG,IAAI,OAAO,EAAgD,CAAC;AAElF,wGAAwG;AACxG,MAAM,UAAU,oBAAoB,CAAC,MAAiC,aAAa;IACjF,IAAI,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;QACvJ,YAAY,CAAC,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC;QAC7C,YAAY,CAAC,SAAS,GAAG,KAAK,CAAC,aAAa,CAA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IAC7D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L222–256 (the blackbody table texture and\n// frameBlackbodyColor), L1003–1010 (the 'planck' / 'soot' branch of sampleEmission).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; an `emissionColor` hook of `VDBFrameVolume` (the volume-source seam) instead of a built-in\n// spectrum switch; his 'approximate' (Shadertoy) spectrum is not ported (R1 §7, DIVERGES V24). The table is engine-free\n// (`@pmndrs/vdb/tools` `vdbFrameBlackbodyTable`, with a CPU twin of the read). D33: the colour matching functions are\n// the analytic fit of Wyman, Sloan & Shirley (JCGT 2(2), 2013), not his CIE 1931 table (CC BY-SA 4.0); `options.cmf`\n// takes others (e.g. the exact table, supplied by the caller under its own licence).\n\n/**\n * K3.6: his physical emission spectra as an emission colour hook:\n *\n * const flames = vdbFrameBlackbodyEmission(\"soot\", 1.39);\n * new VDBFrameVolume(source, { emissionColor: flames, temperatureRange: [0, 3000], emissiveIntensity: 13 });\n * flames.sootExponent.value = 2.0; // a uniform: no rebuild\n *\n * `'planck'`: blackbody colour; `'soot'`: × λ^−exponent (0–3). The colour is normalized (largest channel 1); the\n * volume's power still grows with temperature⁴ (`sampleEmission`). The CIE 1931 colour matching functions are the\n * analytic fit of Wyman, Sloan & Shirley (2013; D33): against the CIE table the normalized colour moves by ≤ 0.021\n * per channel over 1,000–40,000 K (chromaticity Δxy ≤ 0.0016 from 3,000 K up, 0.015 at 1,000 K where the fit's red\n * tail past ~680 nm is short).\n */\n\nimport * as THREE from \"three\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport {\n frameBlackbodyMaxTemperature,\n frameBlackbodyMinTemperature,\n frameBlackbodyTableRows,\n frameBlackbodyTableSize,\n frameMaxSootExponent,\n vdbCie1931Fit,\n vdbFrameBlackbodyTable,\n vdbFrameEmissionSpectrum,\n type VDBColorMatchingFunctions,\n} from \"../../tools/frame/blackbody.js\";\n\nconst { clamp, float, int, ivec2, log, max, min, mix, texture, uniform } = TSL as unknown as Record<string, VDBTslNode>;\n\ntype N = VDBTslNode;\n\nconst tableTextures = new WeakMap<VDBColorMatchingFunctions, THREE.DataTexture>();\n\n/** The 256 × 16 RGBA float table as a texture (made once per `cmf`; read with `load`, no filtering). */\nexport function getFrameBlackbodyMap(cmf: VDBColorMatchingFunctions = vdbCie1931Fit): THREE.DataTexture {\n let tableTexture = tableTextures.get(cmf);\n if (!tableTexture) {\n tableTexture = new THREE.DataTexture(vdbFrameBlackbodyTable(cmf), frameBlackbodyTableSize, frameBlackbodyTableRows, THREE.RGBAFormat, THREE.FloatType);\n tableTexture.minFilter = THREE.NearestFilter;\n tableTexture.magFilter = THREE.NearestFilter;\n tableTexture.generateMipmaps = false;\n tableTexture.needsUpdate = true;\n tableTextures.set(cmf, tableTexture);\n }\n\n return tableTexture;\n}\n\n/** frameBlackbodyColor: the table at a temperature (K) and soot exponent, linear in log temperature and exponent. */\nexport const frameBlackbodyColor = (map: N, temperature: N, exponent: N): N => {\n const temperatureScale = Math.log(frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature);\n const logTemperature = log(max(temperature, 1e-3).div(frameBlackbodyMinTemperature));\n const x = clamp(logTemperature.div(temperatureScale), 0.0, 1.0)\n .mul(frameBlackbodyTableSize - 1)\n .toVar();\n const y = clamp(exponent.div(frameMaxSootExponent), 0.0, 1.0)\n .mul(frameBlackbodyTableRows - 1)\n .toVar();\n const column = min(int(x), int(frameBlackbodyTableSize - 2)).toVar();\n const row = min(int(y), int(frameBlackbodyTableRows - 2)).toVar();\n const blendX = x.sub(float(column)).toVar();\n const texel = (offsetX: number, offsetY: number) => map.load(ivec2(column.add(offsetX), row.add(offsetY))).rgb;\n\n return mix(mix(texel(0, 0), texel(1, 0), blendX), mix(texel(0, 1), texel(1, 1), blendX), y.sub(float(row)));\n};\n\n/** An emission colour hook with its soot exponent uniform. */\nexport interface VDBFrameBlackbodyHook {\n (temperature: N): N;\n /** The soot exponent (0–3; 'planck': 0). Set `.value` at runtime. */\n readonly sootExponent: { value: number };\n readonly spectrum: \"planck\" | \"soot\";\n /** The table texture this hook reads (one per colour matching functions; D33). */\n readonly table: THREE.DataTexture;\n}\n\n/**\n * The `emissionColor` hook of his `'planck'` / `'soot'` emission spectra (`VDBFrameVolume` / `vdbVolumeNodes`\n * `emissionColor`). Temperatures ≤ 0 give black (the source's `sampleEmission` already selects them out).\n * `options.cmf`: the CIE 1931 colour matching functions (x̄, ȳ, z̄ at a wavelength in nm, read at 380–780 nm in 5 nm\n * steps); default the analytic fit `vdbCie1931Fit` (D33). Pass the exact CIE table here to match his colours exactly.\n */\nexport function vdbFrameBlackbodyEmission(spectrum: \"planck\" | \"soot\" = \"planck\", sootExponent = 1.39, options: { cmf?: VDBColorMatchingFunctions } = {}): VDBFrameBlackbodyHook {\n const [, exponent] = vdbFrameEmissionSpectrum(spectrum, sootExponent);\n const exponentNode = uniform(exponent);\n const table = getFrameBlackbodyMap(options.cmf);\n const map = texture(table);\n const hook = ((temperature: N) => frameBlackbodyColor(map, temperature, exponentNode)) as VDBFrameBlackbodyHook;\n\n Object.defineProperty(hook, \"sootExponent\", { value: exponentNode });\n Object.defineProperty(hook, \"spectrum\", { value: spectrum });\n Object.defineProperty(hook, \"table\", { value: table });\n\n return hook;\n}\n"]}