@pmndrs/vdb 0.0.0-stage → 0.1.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 (390) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/LICENSE +21 -0
  3. package/README.md +448 -2
  4. package/THIRD_PARTY_NOTICES.md +147 -0
  5. package/dist/core/compute/atlas.d.ts +94 -0
  6. package/dist/core/compute/atlas.js +98 -0
  7. package/dist/core/compute/atlas.js.map +1 -0
  8. package/dist/core/compute/index.d.ts +13 -0
  9. package/dist/core/compute/index.js +9 -0
  10. package/dist/core/compute/index.js.map +1 -0
  11. package/dist/core/compute/pyramid.d.ts +105 -0
  12. package/dist/core/compute/pyramid.js +455 -0
  13. package/dist/core/compute/pyramid.js.map +1 -0
  14. package/dist/core/compute/shared.d.ts +115 -0
  15. package/dist/core/compute/shared.js +211 -0
  16. package/dist/core/compute/shared.js.map +1 -0
  17. package/dist/core/compute/stats.d.ts +71 -0
  18. package/dist/core/compute/stats.js +188 -0
  19. package/dist/core/compute/stats.js.map +1 -0
  20. package/dist/core/compute/value-transform.d.ts +23 -0
  21. package/dist/core/compute/value-transform.js +58 -0
  22. package/dist/core/compute/value-transform.js.map +1 -0
  23. package/dist/core/errors.d.ts +11 -0
  24. package/dist/core/errors.js +9 -0
  25. package/dist/core/errors.js.map +1 -0
  26. package/dist/core/index.d.ts +30 -0
  27. package/dist/core/index.js +27 -0
  28. package/dist/core/index.js.map +1 -0
  29. package/dist/core/internal.d.ts +15 -0
  30. package/dist/core/internal.js +15 -0
  31. package/dist/core/internal.js.map +1 -0
  32. package/dist/core/pool/affine.d.ts +34 -0
  33. package/dist/core/pool/affine.js +100 -0
  34. package/dist/core/pool/affine.js.map +1 -0
  35. package/dist/core/pool/allocator.d.ts +32 -0
  36. package/dist/core/pool/allocator.js +81 -0
  37. package/dist/core/pool/allocator.js.map +1 -0
  38. package/dist/core/pool/image-header.d.ts +82 -0
  39. package/dist/core/pool/image-header.js +175 -0
  40. package/dist/core/pool/image-header.js.map +1 -0
  41. package/dist/core/pool/layout.d.ts +164 -0
  42. package/dist/core/pool/layout.js +267 -0
  43. package/dist/core/pool/layout.js.map +1 -0
  44. package/dist/core/pool/limits.d.ts +40 -0
  45. package/dist/core/pool/limits.js +79 -0
  46. package/dist/core/pool/limits.js.map +1 -0
  47. package/dist/core/pool/pool.d.ts +279 -0
  48. package/dist/core/pool/pool.js +953 -0
  49. package/dist/core/pool/pool.js.map +1 -0
  50. package/dist/core/source/dense.d.ts +19 -0
  51. package/dist/core/source/dense.js +287 -0
  52. package/dist/core/source/dense.js.map +1 -0
  53. package/dist/core/source/types.d.ts +63 -0
  54. package/dist/core/source/types.js +9 -0
  55. package/dist/core/source/types.js.map +1 -0
  56. package/dist/core/types.d.ts +28 -0
  57. package/dist/core/types.js +28 -0
  58. package/dist/core/types.js.map +1 -0
  59. package/dist/core/wgsl/api.d.ts +41 -0
  60. package/dist/core/wgsl/api.js +463 -0
  61. package/dist/core/wgsl/api.js.map +1 -0
  62. package/dist/core/wgsl/generate.d.ts +82 -0
  63. package/dist/core/wgsl/generate.js +505 -0
  64. package/dist/core/wgsl/generate.js.map +1 -0
  65. package/dist/core/wgsl/level-set.d.ts +54 -0
  66. package/dist/core/wgsl/level-set.js +194 -0
  67. package/dist/core/wgsl/level-set.js.map +1 -0
  68. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  69. package/dist/core/wgsl/pnanovdb.chunks.generated.js +330 -0
  70. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  71. package/dist/core/wgsl/reserved.d.ts +9 -0
  72. package/dist/core/wgsl/reserved.js +26 -0
  73. package/dist/core/wgsl/reserved.js.map +1 -0
  74. package/dist/core/wgsl/types.d.ts +104 -0
  75. package/dist/core/wgsl/types.js +2 -0
  76. package/dist/core/wgsl/types.js.map +1 -0
  77. package/dist/three/coarse-first.d.ts +162 -0
  78. package/dist/three/coarse-first.js +187 -0
  79. package/dist/three/coarse-first.js.map +1 -0
  80. package/dist/three/compute.d.ts +63 -0
  81. package/dist/three/compute.js +56 -0
  82. package/dist/three/compute.js.map +1 -0
  83. package/dist/three/device.d.ts +59 -0
  84. package/dist/three/device.js +59 -0
  85. package/dist/three/device.js.map +1 -0
  86. package/dist/three/frame/blackbody.d.ts +42 -0
  87. package/dist/three/frame/blackbody.js +74 -0
  88. package/dist/three/frame/blackbody.js.map +1 -0
  89. package/dist/three/frame/chunks.d.ts +157 -0
  90. package/dist/three/frame/chunks.js +559 -0
  91. package/dist/three/frame/chunks.js.map +1 -0
  92. package/dist/three/frame/density-material.d.ts +53 -0
  93. package/dist/three/frame/density-material.js +353 -0
  94. package/dist/three/frame/density-material.js.map +1 -0
  95. package/dist/three/frame/emission-light.d.ts +167 -0
  96. package/dist/three/frame/emission-light.js +655 -0
  97. package/dist/three/frame/emission-light.js.map +1 -0
  98. package/dist/three/frame/environment-grid-material.d.ts +21 -0
  99. package/dist/three/frame/environment-grid-material.js +184 -0
  100. package/dist/three/frame/environment-grid-material.js.map +1 -0
  101. package/dist/three/frame/environment-material.d.ts +22 -0
  102. package/dist/three/frame/environment-material.js +87 -0
  103. package/dist/three/frame/environment-material.js.map +1 -0
  104. package/dist/three/frame/grid-mip-material.d.ts +12 -0
  105. package/dist/three/frame/grid-mip-material.js +61 -0
  106. package/dist/three/frame/grid-mip-material.js.map +1 -0
  107. package/dist/three/frame/index.d.ts +39 -0
  108. package/dist/three/frame/index.js +35 -0
  109. package/dist/three/frame/index.js.map +1 -0
  110. package/dist/three/frame/inject-material.d.ts +56 -0
  111. package/dist/three/frame/inject-material.js +424 -0
  112. package/dist/three/frame/inject-material.js.map +1 -0
  113. package/dist/three/frame/integrate-material.d.ts +26 -0
  114. package/dist/three/frame/integrate-material.js +198 -0
  115. package/dist/three/frame/integrate-material.js.map +1 -0
  116. package/dist/three/frame/layout.d.ts +34 -0
  117. package/dist/three/frame/layout.js +48 -0
  118. package/dist/three/frame/layout.js.map +1 -0
  119. package/dist/three/frame/lighting-material.d.ts +41 -0
  120. package/dist/three/frame/lighting-material.js +257 -0
  121. package/dist/three/frame/lighting-material.js.map +1 -0
  122. package/dist/three/frame/lights.d.ts +11 -0
  123. package/dist/three/frame/lights.js +16 -0
  124. package/dist/three/frame/lights.js.map +1 -0
  125. package/dist/three/frame/medium.d.ts +21 -0
  126. package/dist/three/frame/medium.js +29 -0
  127. package/dist/three/frame/medium.js.map +1 -0
  128. package/dist/three/frame/neural.d.ts +14 -0
  129. package/dist/three/frame/neural.js +105 -0
  130. package/dist/three/frame/neural.js.map +1 -0
  131. package/dist/three/frame/phase.d.ts +44 -0
  132. package/dist/three/frame/phase.js +80 -0
  133. package/dist/three/frame/phase.js.map +1 -0
  134. package/dist/three/frame/renderer.d.ts +493 -0
  135. package/dist/three/frame/renderer.js +1498 -0
  136. package/dist/three/frame/renderer.js.map +1 -0
  137. package/dist/three/frame/shadow-density-material.d.ts +30 -0
  138. package/dist/three/frame/shadow-density-material.js +123 -0
  139. package/dist/three/frame/shadow-density-material.js.map +1 -0
  140. package/dist/three/frame/spectrum.d.ts +18 -0
  141. package/dist/three/frame/spectrum.js +36 -0
  142. package/dist/three/frame/spectrum.js.map +1 -0
  143. package/dist/three/frame/temporal-material.d.ts +29 -0
  144. package/dist/three/frame/temporal-material.js +152 -0
  145. package/dist/three/frame/temporal-material.js.map +1 -0
  146. package/dist/three/frame/three-internals.d.ts +65 -0
  147. package/dist/three/frame/three-internals.js +150 -0
  148. package/dist/three/frame/three-internals.js.map +1 -0
  149. package/dist/three/frame/transmittance-material.d.ts +31 -0
  150. package/dist/three/frame/transmittance-material.js +315 -0
  151. package/dist/three/frame/transmittance-material.js.map +1 -0
  152. package/dist/three/frame/view.d.ts +103 -0
  153. package/dist/three/frame/view.js +296 -0
  154. package/dist/three/frame/view.js.map +1 -0
  155. package/dist/three/frame/volume-shadow-material.d.ts +36 -0
  156. package/dist/three/frame/volume-shadow-material.js +128 -0
  157. package/dist/three/frame/volume-shadow-material.js.map +1 -0
  158. package/dist/three/frame/volume-shadows.d.ts +153 -0
  159. package/dist/three/frame/volume-shadows.js +756 -0
  160. package/dist/three/frame/volume-shadows.js.map +1 -0
  161. package/dist/three/frame/volume.d.ts +172 -0
  162. package/dist/three/frame/volume.js +256 -0
  163. package/dist/three/frame/volume.js.map +1 -0
  164. package/dist/three/grid-node.d.ts +196 -0
  165. package/dist/three/grid-node.js +510 -0
  166. package/dist/three/grid-node.js.map +1 -0
  167. package/dist/three/index.d.ts +43 -0
  168. package/dist/three/index.js +49 -0
  169. package/dist/three/index.js.map +1 -0
  170. package/dist/three/internal.d.ts +14 -0
  171. package/dist/three/internal.js +14 -0
  172. package/dist/three/internal.js.map +1 -0
  173. package/dist/three/level-set-material.d.ts +112 -0
  174. package/dist/three/level-set-material.js +204 -0
  175. package/dist/three/level-set-material.js.map +1 -0
  176. package/dist/three/material.d.ts +194 -0
  177. package/dist/three/material.js +359 -0
  178. package/dist/three/material.js.map +1 -0
  179. package/dist/three/points.d.ts +84 -0
  180. package/dist/three/points.js +130 -0
  181. package/dist/three/points.js.map +1 -0
  182. package/dist/three/sequence.d.ts +317 -0
  183. package/dist/three/sequence.js +526 -0
  184. package/dist/three/sequence.js.map +1 -0
  185. package/dist/three/sparse-source.d.ts +233 -0
  186. package/dist/three/sparse-source.js +876 -0
  187. package/dist/three/sparse-source.js.map +1 -0
  188. package/dist/three/volume-source.d.ts +167 -0
  189. package/dist/three/volume-source.js +353 -0
  190. package/dist/three/volume-source.js.map +1 -0
  191. package/dist/tools/cpu/compute.d.ts +97 -0
  192. package/dist/tools/cpu/compute.js +218 -0
  193. package/dist/tools/cpu/compute.js.map +1 -0
  194. package/dist/tools/cpu/level-set.d.ts +72 -0
  195. package/dist/tools/cpu/level-set.js +261 -0
  196. package/dist/tools/cpu/level-set.js.map +1 -0
  197. package/dist/tools/cpu/march.d.ts +206 -0
  198. package/dist/tools/cpu/march.js +575 -0
  199. package/dist/tools/cpu/march.js.map +1 -0
  200. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  201. package/dist/tools/cpu/probe-coords.js +116 -0
  202. package/dist/tools/cpu/probe-coords.js.map +1 -0
  203. package/dist/tools/cpu/read-value.d.ts +31 -0
  204. package/dist/tools/cpu/read-value.js +336 -0
  205. package/dist/tools/cpu/read-value.js.map +1 -0
  206. package/dist/tools/cpu/sample-trilinear.d.ts +30 -0
  207. package/dist/tools/cpu/sample-trilinear.js +156 -0
  208. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  209. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  210. package/dist/tools/cpu/stride-tables.generated.d.ts +1058 -0
  211. package/dist/tools/cpu/stride-tables.generated.js +1266 -0
  212. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  213. package/dist/tools/cpu/stride-tables.js +78 -0
  214. package/dist/tools/cpu/stride-tables.js.map +1 -0
  215. package/dist/tools/errors.d.ts +57 -0
  216. package/dist/tools/errors.js +58 -0
  217. package/dist/tools/errors.js.map +1 -0
  218. package/dist/tools/frame/blackbody.d.ts +42 -0
  219. package/dist/tools/frame/blackbody.js +116 -0
  220. package/dist/tools/frame/blackbody.js.map +1 -0
  221. package/dist/tools/frame/emission.d.ts +128 -0
  222. package/dist/tools/frame/emission.js +282 -0
  223. package/dist/tools/frame/emission.js.map +1 -0
  224. package/dist/tools/frame/environment.d.ts +105 -0
  225. package/dist/tools/frame/environment.js +268 -0
  226. package/dist/tools/frame/environment.js.map +1 -0
  227. package/dist/tools/frame/grid.d.ts +302 -0
  228. package/dist/tools/frame/grid.js +703 -0
  229. package/dist/tools/frame/grid.js.map +1 -0
  230. package/dist/tools/frame/index.d.ts +136 -0
  231. package/dist/tools/frame/index.js +348 -0
  232. package/dist/tools/frame/index.js.map +1 -0
  233. package/dist/tools/frame/medium.d.ts +61 -0
  234. package/dist/tools/frame/medium.js +99 -0
  235. package/dist/tools/frame/medium.js.map +1 -0
  236. package/dist/tools/frame/mie-table.d.ts +6 -0
  237. package/dist/tools/frame/mie-table.js +16 -0
  238. package/dist/tools/frame/mie-table.js.map +1 -0
  239. package/dist/tools/frame/mie.d.ts +54 -0
  240. package/dist/tools/frame/mie.js +176 -0
  241. package/dist/tools/frame/mie.js.map +1 -0
  242. package/dist/tools/frame/neural-weights.d.ts +9 -0
  243. package/dist/tools/frame/neural-weights.js +245 -0
  244. package/dist/tools/frame/neural-weights.js.map +1 -0
  245. package/dist/tools/frame/neural.d.ts +80 -0
  246. package/dist/tools/frame/neural.js +150 -0
  247. package/dist/tools/frame/neural.js.map +1 -0
  248. package/dist/tools/frame/pyramid-layout.d.ts +38 -0
  249. package/dist/tools/frame/pyramid-layout.js +53 -0
  250. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  251. package/dist/tools/frame/shadows.d.ts +80 -0
  252. package/dist/tools/frame/shadows.js +182 -0
  253. package/dist/tools/frame/shadows.js.map +1 -0
  254. package/dist/tools/frame/sparse.d.ts +65 -0
  255. package/dist/tools/frame/sparse.js +191 -0
  256. package/dist/tools/frame/sparse.js.map +1 -0
  257. package/dist/tools/frame/spectral.d.ts +203 -0
  258. package/dist/tools/frame/spectral.js +550 -0
  259. package/dist/tools/frame/spectral.js.map +1 -0
  260. package/dist/tools/index.d.ts +106 -0
  261. package/dist/tools/index.js +88 -0
  262. package/dist/tools/index.js.map +1 -0
  263. package/dist/tools/internal.d.ts +46 -0
  264. package/dist/tools/internal.js +31 -0
  265. package/dist/tools/internal.js.map +1 -0
  266. package/dist/tools/nanovdb/build-from-vdb.d.ts +50 -0
  267. package/dist/tools/nanovdb/build-from-vdb.js +92 -0
  268. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  269. package/dist/tools/nanovdb/bytes.d.ts +220 -0
  270. package/dist/tools/nanovdb/bytes.js +345 -0
  271. package/dist/tools/nanovdb/bytes.js.map +1 -0
  272. package/dist/tools/nanovdb/coarse-first.d.ts +62 -0
  273. package/dist/tools/nanovdb/coarse-first.js +86 -0
  274. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  275. package/dist/tools/nanovdb/index.d.ts +32 -0
  276. package/dist/tools/nanovdb/index.js +24 -0
  277. package/dist/tools/nanovdb/index.js.map +1 -0
  278. package/dist/tools/nanovdb/inspect.d.ts +24 -0
  279. package/dist/tools/nanovdb/inspect.js +63 -0
  280. package/dist/tools/nanovdb/inspect.js.map +1 -0
  281. package/dist/tools/nanovdb/leaf-codec.d.ts +85 -0
  282. package/dist/tools/nanovdb/leaf-codec.js +320 -0
  283. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  284. package/dist/tools/nanovdb/quantize.d.ts +43 -0
  285. package/dist/tools/nanovdb/quantize.js +277 -0
  286. package/dist/tools/nanovdb/quantize.js.map +1 -0
  287. package/dist/tools/nanovdb/resample.d.ts +160 -0
  288. package/dist/tools/nanovdb/resample.js +679 -0
  289. package/dist/tools/nanovdb/resample.js.map +1 -0
  290. package/dist/tools/nanovdb/serialize.d.ts +145 -0
  291. package/dist/tools/nanovdb/serialize.js +395 -0
  292. package/dist/tools/nanovdb/serialize.js.map +1 -0
  293. package/dist/tools/nanovdb/stats.d.ts +58 -0
  294. package/dist/tools/nanovdb/stats.js +149 -0
  295. package/dist/tools/nanovdb/stats.js.map +1 -0
  296. package/dist/tools/nanovdb/transform.d.ts +26 -0
  297. package/dist/tools/nanovdb/transform.js +91 -0
  298. package/dist/tools/nanovdb/transform.js.map +1 -0
  299. package/dist/tools/nanovdb/tree.d.ts +175 -0
  300. package/dist/tools/nanovdb/tree.js +518 -0
  301. package/dist/tools/nanovdb/tree.js.map +1 -0
  302. package/dist/tools/nanovdb/write-nvdb.d.ts +39 -0
  303. package/dist/tools/nanovdb/write-nvdb.js +210 -0
  304. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  305. package/dist/tools/nvdb-file.d.ts +195 -0
  306. package/dist/tools/nvdb-file.js +606 -0
  307. package/dist/tools/nvdb-file.js.map +1 -0
  308. package/dist/tools/nvdb-stream.d.ts +138 -0
  309. package/dist/tools/nvdb-stream.js +365 -0
  310. package/dist/tools/nvdb-stream.js.map +1 -0
  311. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  312. package/dist/tools/vdb/bit-utils.js +42 -0
  313. package/dist/tools/vdb/bit-utils.js.map +1 -0
  314. package/dist/tools/vdb/blosc.d.ts +56 -0
  315. package/dist/tools/vdb/blosc.js +231 -0
  316. package/dist/tools/vdb/blosc.js.map +1 -0
  317. package/dist/tools/vdb/byte-reader.d.ts +40 -0
  318. package/dist/tools/vdb/byte-reader.js +139 -0
  319. package/dist/tools/vdb/byte-reader.js.map +1 -0
  320. package/dist/tools/vdb/compression.d.ts +73 -0
  321. package/dist/tools/vdb/compression.js +249 -0
  322. package/dist/tools/vdb/compression.js.map +1 -0
  323. package/dist/tools/vdb/errors.d.ts +10 -0
  324. package/dist/tools/vdb/errors.js +11 -0
  325. package/dist/tools/vdb/errors.js.map +1 -0
  326. package/dist/tools/vdb/grid.d.ts +37 -0
  327. package/dist/tools/vdb/grid.js +147 -0
  328. package/dist/tools/vdb/grid.js.map +1 -0
  329. package/dist/tools/vdb/half-float.d.ts +9 -0
  330. package/dist/tools/vdb/half-float.js +24 -0
  331. package/dist/tools/vdb/half-float.js.map +1 -0
  332. package/dist/tools/vdb/index.d.ts +3 -0
  333. package/dist/tools/vdb/index.js +3 -0
  334. package/dist/tools/vdb/index.js.map +1 -0
  335. package/dist/tools/vdb/inflate.d.ts +24 -0
  336. package/dist/tools/vdb/inflate.js +334 -0
  337. package/dist/tools/vdb/inflate.js.map +1 -0
  338. package/dist/tools/vdb/metadata.d.ts +17 -0
  339. package/dist/tools/vdb/metadata.js +72 -0
  340. package/dist/tools/vdb/metadata.js.map +1 -0
  341. package/dist/tools/vdb/parse.d.ts +25 -0
  342. package/dist/tools/vdb/parse.js +171 -0
  343. package/dist/tools/vdb/parse.js.map +1 -0
  344. package/dist/tools/vdb/point-render-data.d.ts +31 -0
  345. package/dist/tools/vdb/point-render-data.js +57 -0
  346. package/dist/tools/vdb/point-render-data.js.map +1 -0
  347. package/dist/tools/vdb/points.d.ts +160 -0
  348. package/dist/tools/vdb/points.js +794 -0
  349. package/dist/tools/vdb/points.js.map +1 -0
  350. package/dist/tools/vdb/transform.d.ts +23 -0
  351. package/dist/tools/vdb/transform.js +54 -0
  352. package/dist/tools/vdb/transform.js.map +1 -0
  353. package/dist/tools/vdb/tree.d.ts +111 -0
  354. package/dist/tools/vdb/tree.js +228 -0
  355. package/dist/tools/vdb/tree.js.map +1 -0
  356. package/dist/tools/vdb/types.d.ts +138 -0
  357. package/dist/tools/vdb/types.js +3 -0
  358. package/dist/tools/vdb/types.js.map +1 -0
  359. package/dist/tools/wvdb/bake.d.ts +116 -0
  360. package/dist/tools/wvdb/bake.js +311 -0
  361. package/dist/tools/wvdb/bake.js.map +1 -0
  362. package/dist/tools/wvdb/dense.d.ts +112 -0
  363. package/dist/tools/wvdb/dense.js +309 -0
  364. package/dist/tools/wvdb/dense.js.map +1 -0
  365. package/dist/tools/wvdb/format.d.ts +161 -0
  366. package/dist/tools/wvdb/format.js +303 -0
  367. package/dist/tools/wvdb/format.js.map +1 -0
  368. package/dist/tools/wvdb/index.d.ts +13 -0
  369. package/dist/tools/wvdb/index.js +14 -0
  370. package/dist/tools/wvdb/index.js.map +1 -0
  371. package/dist/tools/wvdb/level-set.d.ts +48 -0
  372. package/dist/tools/wvdb/level-set.js +153 -0
  373. package/dist/tools/wvdb/level-set.js.map +1 -0
  374. package/dist/tools/wvdb/nanovdb.d.ts +54 -0
  375. package/dist/tools/wvdb/nanovdb.js +60 -0
  376. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  377. package/dist/tools/wvdb/read.d.ts +260 -0
  378. package/dist/tools/wvdb/read.js +743 -0
  379. package/dist/tools/wvdb/read.js.map +1 -0
  380. package/dist/tools/wvdb/sha256.d.ts +7 -0
  381. package/dist/tools/wvdb/sha256.js +76 -0
  382. package/dist/tools/wvdb/sha256.js.map +1 -0
  383. package/dist/tools/wvdb/write.d.ts +127 -0
  384. package/dist/tools/wvdb/write.js +396 -0
  385. package/dist/tools/wvdb/write.js.map +1 -0
  386. package/package.json +82 -4
  387. package/vendor/LICENSE +201 -0
  388. package/vendor/NOTICE +19 -0
  389. package/vendor/VENDOR.md +85 -0
  390. package/vendor/pnanovdb.wgsl +1539 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/core/wgsl/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAsC,MAAM,aAAa,CAAC;AACzG,OAAO,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,eAAe,EAAsB,MAAM,gCAAgC,CAAC;AAGrF,mDAAmD;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAC5B,8HAA8H,CAAC;AAEjI,wDAAwD;AACxD,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAE/C,iHAAiH;AACjH,MAAM,QAAQ,GAAgC,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACtF,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,yGAAyG;AACzG,MAAM,6BAA6B,GAAG,GAAG,GAAG,GAAG,CAAC;AAEhD,kFAAkF;AAClF,MAAM,OAAO,GAAiE;IAC5E,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IAC/B,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACrB,WAAW,EAAE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AC,CAAC;IAC7E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAChB,uBAAuB,EACvB,kBAAkB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B;YACzH,qGAAqG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAC1H,yGAAyG,CAC5G,CAAC;IACJ,CAAC;AACH,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,qBAAqB,CAAC,OAAyB;IAC7D,MAAM,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACrD,CAAC","sourcesContent":["/**\n * WGSL module generator (docs/dev/design/K1-core.md §3, task K1.4a).\n *\n * Roots for the profile and options (the vendored names the API layer uses)\n * -> closure over the declaration table extracted from the unmodified vendored\n * `pnanovdb.wgsl` -> generation transforms -> `pnanovdb_`→`vdb_` rename ->\n * append the API layer -> prepend one SPDX line.\n *\n * Generation transforms (each one is a row in vendor/VENDOR.md, \"Generation\n * transforms\"; none edits the vendored file):\n * 1. `pnanovdb_buf_read_uint32` reads through `vdb_load`, the module's single\n * buffer access site (§2).\n * 2. The 27-row `pnanovdb_grid_type_constants` array becomes\n * `fn vdb_gtc(grid_type)` returning only the compiled types' rows; its\n * `[grid_type]` call sites become `vdb_gtc(grid_type)`.\n * 3. `pnanovdb_read_float_typed` keeps only the compiled types' branches, so\n * the other decoders drop out of the closure.\n * 4. Declarations unreachable from the profile's roots are not emitted (the\n * `pnanovdb_sample_trilinear_{float,fp8,fpn}` wrappers among them).\n * 5. Every `pnanovdb_` / `PNANOVDB_` becomes `vdb_` / `VDB_`.\n * 6. Comments are dropped (done at extraction).\n * 7. `pnanovdb_leaf_get_stat_float` keeps only the compiled types' branch\n * (the Fp leaf-stats decode, K1.4b), so a Float-only module has no\n * uint16 decoder.\n *\n * Output is deterministic: the same options give the same bytes, and `types`\n * is a set (order and duplicates do not matter).\n */\n\nimport { VDBError } from \"../errors.js\";\nimport { VDB_GPU_LAYOUT_VERSION, vdbPoolLayoutWgsl } from \"../pool/layout.js\";\nimport { VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES, type VDBGridTypeName, type VDBSlot } from \"../types.js\";\nimport { apiWgsl, type ApiOptions } from \"./api.js\";\nimport { WGSL_KEYWORDS, WGSL_RESERVED_WORDS } from \"./reserved.js\";\nimport { PNANOVDB_CHUNKS, type PnanovdbChunk } from \"./pnanovdb.chunks.generated.js\";\nimport type { VDBModuleHelper, VDBModuleOptions, VDBModulePoolLike, VDBModuleProfile, VDBModuleTypeCheck } from \"./types.js\";\n\n/** First line of every generated module (§3.3). */\nexport const VDB_MODULE_BANNER =\n \"// SPDX-License-Identifier: Apache-2.0 AND MIT. Derived from PNanoVDB.h (OpenVDB) via emcfarlane/webgpu-nanovdb; see NOTICE.\";\n\n/** Name of the storage binding `slot` mode declares. */\nexport const VDB_POOL_BINDING_NAME = \"vdbPool\";\n\n/** Profiles in inclusion order; only the first `IMPLEMENTED_PROFILES` generate (`majorant` is deferred, D22). */\nconst PROFILES: readonly VDBModuleProfile[] = [\"read\", \"sample\", \"march\", \"majorant\"];\nconst IMPLEMENTED_PROFILES = 3;\n\n/** `GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE` (0x2 | 0x4); the global does not exist in Node. */\nconst SHADER_STAGE_FRAGMENT_COMPUTE = 0x2 | 0x4;\n\n/** Opt-in helpers in canonical order, with the lowest profile rank each needs. */\nconst HELPERS: Readonly<Record<VDBModuleHelper, { readonly rank: number }>> = {\n cellBoundTrilinear: { rank: 2 },\n hddaCellEnd: { rank: 2 },\n levelSet: { rank: 2 },\n nodeAverage: { rank: 2 },\n rayClipSupport: { rank: 1 },\n fastTrilinear: { rank: 1 },\n};\nconst HELPER_NAMES = Object.keys(HELPERS) as VDBModuleHelper[];\n\nconst IDENTIFIER = /[A-Za-z_][A-Za-z0-9_]*/g;\nconst BUFFER_EXPRESSION = /^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*$/;\n\ntype Binding = { readonly kind: \"slot\"; readonly slot: VDBSlot } | { readonly kind: \"buffer\"; readonly expression: string };\n\ninterface NormalizedOptions extends ApiOptions {\n readonly profile: VDBModuleProfile;\n readonly profileRank: number;\n readonly binding: Binding;\n}\n\nfunction bad(message: string): VDBError {\n return new VDBError(\"VDB_BAD_OPTION\", message);\n}\n\nfunction checkSlot(slot: unknown, where: string): VDBSlot {\n const s = slot as Partial<VDBSlot> | null | undefined;\n if (\n s === null ||\n typeof s !== \"object\" ||\n !Number.isInteger(s.group) ||\n !Number.isInteger(s.firstBinding) ||\n (s.group as number) < 0 ||\n (s.firstBinding as number) < 0\n ) {\n throw bad(`${where}: slot must be { group, firstBinding } with non-negative integers, got ${JSON.stringify(slot)}.`);\n }\n return { group: s.group as number, firstBinding: s.firstBinding as number };\n}\n\n/** The old bvh-style positional slot (`{ group, firstBinding }` at the top level of the module options) would be silently misread. */\nfunction rejectPositionalSlot(where: string, options: object): void {\n if (\"group\" in options || \"firstBinding\" in options) {\n throw bad(`${where}: got 'group' or 'firstBinding' at the top level. Pass { slot: { group, firstBinding } }.`);\n }\n}\n\nfunction normalizeHelpers(helpers: unknown, profile: VDBModuleProfile, profileRank: number, where: string): VDBModuleHelper[] {\n if (helpers === undefined) return [];\n if (helpers === null || typeof helpers === \"string\" || typeof (helpers as Iterable<unknown>)[Symbol.iterator] !== \"function\") {\n throw bad(`${where}: helpers must be an array or set of helper names (${HELPER_NAMES.join(\", \")}), got ${JSON.stringify(helpers)}.`);\n }\n const seen = new Set<string>();\n for (const h of helpers as Iterable<unknown>) {\n if (typeof h !== \"string\" || !(HELPER_NAMES as readonly string[]).includes(h)) {\n throw bad(`${where}: unknown helper ${JSON.stringify(h)}; use ${HELPER_NAMES.join(\", \")}.`);\n }\n const need = HELPERS[h as VDBModuleHelper].rank;\n if (profileRank < need) {\n throw bad(`${where}: helper '${h}' needs profile '${PROFILES[need]}' or above, got '${profile}'.`);\n }\n seen.add(h);\n }\n return HELPER_NAMES.filter((h) => seen.has(h));\n}\n\nfunction normalizeTypes(types: unknown, where: string): VDBGridTypeName[] {\n if (types === undefined || types === null || typeof types === \"string\" || typeof (types as Iterable<unknown>)[Symbol.iterator] !== \"function\") {\n throw bad(`${where}: types must be an array or set of grid type names (${VDB_GRID_TYPE_NAMES.join(\", \")}), e.g. [...pool.types].`);\n }\n const seen = new Set<string>();\n for (const t of types as Iterable<unknown>) {\n if (typeof t !== \"string\" || !(VDB_GRID_TYPE_NAMES as readonly string[]).includes(t)) {\n throw bad(`${where}: unknown grid type ${JSON.stringify(t)}; use ${VDB_GRID_TYPE_NAMES.join(\", \")}.`);\n }\n seen.add(t);\n }\n if (seen.size === 0) {\n throw bad(`${where}: types is empty. Compile at least one grid type, e.g. ['float'], or pass [...pool.types] after adding a grid.`);\n }\n return VDB_GRID_TYPE_NAMES.filter((t) => seen.has(t));\n}\n\nfunction normalize(options: VDBModuleOptions, where: string): NormalizedOptions {\n if (options === null || typeof options !== \"object\") {\n throw bad(`${where}: expected an options object { slot | buffer, types, profile }.`);\n }\n rejectPositionalSlot(where, options);\n\n const hasSlot = (options as { slot?: unknown }).slot !== undefined;\n const hasBuffer = (options as { buffer?: unknown }).buffer !== undefined;\n if (hasSlot === hasBuffer) {\n throw bad(`${where}: pass exactly one of slot: { group, firstBinding } (declares the binding) or buffer: '<wgsl expression>' (reads a host-declared array<u32>).`);\n }\n let binding: Binding;\n if (hasSlot) {\n binding = { kind: \"slot\", slot: checkSlot(options.slot, where) };\n } else {\n const expression: unknown = options.buffer;\n if (typeof expression !== \"string\" || !BUFFER_EXPRESSION.test(expression)) {\n throw bad(`${where}: buffer must be a WGSL identifier or member chain such as 'vdbPool.value', got ${JSON.stringify(expression)}.`);\n }\n for (const part of expression.split(\".\")) {\n if (part.startsWith(\"__\")) {\n throw bad(`${where}: buffer ${JSON.stringify(expression)} uses '${part}'; WGSL identifiers must not start with '__'. Rename the host binding.`);\n }\n if (part === \"_\" || WGSL_RESERVED_WORDS.has(part) || WGSL_KEYWORDS.has(part)) {\n throw bad(`${where}: buffer ${JSON.stringify(expression)} uses '${part}', which WGSL reserves. Rename the host binding (e.g. 'vdbPool.value').`);\n }\n }\n binding = { kind: \"buffer\", expression };\n }\n\n const profileRank = PROFILES.indexOf(options.profile);\n if (profileRank < 0) {\n throw bad(`${where}: profile must be one of ${PROFILES.map((p) => `'${p}'`).join(\", \")}, got ${JSON.stringify(options.profile)}.`);\n }\n if (profileRank >= IMPLEMENTED_PROFILES) {\n throw bad(`${where}: profile '${options.profile}' is deferred past 0.1 (D22). Use 'read', 'sample' or 'march'.`);\n }\n\n const sampler = options.sampler ?? \"trilinear\";\n if (sampler !== \"trilinear\" && sampler !== \"nearest\") {\n throw bad(`${where}: sampler must be 'trilinear' or 'nearest', got ${JSON.stringify(sampler)}.`);\n }\n const outside = options.outside ?? \"background\";\n if (outside !== \"background\" && outside !== \"zero\") {\n throw bad(`${where}: outside must be 'background' or 'zero', got ${JSON.stringify(outside)}.`);\n }\n const isActive = options.isActive ?? true;\n if (typeof isActive !== \"boolean\") {\n throw bad(`${where}: isActive must be a boolean, got ${JSON.stringify(isActive)}.`);\n }\n\n // Sample-only options do not change a `read` module; normalize them away so\n // equal modules share one cache key.\n const sampleOnly = profileRank >= 1;\n return {\n profile: options.profile,\n profileRank,\n binding,\n types: normalizeTypes(options.types, where),\n isActive,\n sampler: sampleOnly ? sampler : \"trilinear\",\n outside: sampleOnly ? outside : \"background\",\n helpers: checkHelperSampler(normalizeHelpers(options.helpers, options.profile, profileRank, where), sampleOnly ? sampler : \"trilinear\", where),\n };\n}\n\n/** `fastTrilinear` shares one leaf between the 8 trilinear taps; `nearest` has one tap. */\nfunction checkHelperSampler(helpers: VDBModuleHelper[], sampler: \"trilinear\" | \"nearest\", where: string): VDBModuleHelper[] {\n if (sampler === \"nearest\" && helpers.includes(\"fastTrilinear\")) {\n throw bad(`${where}: helper 'fastTrilinear' needs sampler 'trilinear' (nearest reads one voxel; call vdbSample).`);\n }\n return helpers;\n}\n\n// ---------------------------------------------------------------------------\n// Declaration table and transforms\n\nconst CHUNKS = new Map<string, PnanovdbChunk>(PNANOVDB_CHUNKS.map((c) => [c.name, c]));\nconst ORDER = new Map<string, number>(PNANOVDB_CHUNKS.map((c, i) => [c.name, i]));\n\nfunction chunk(name: string): PnanovdbChunk {\n const c = CHUNKS.get(name);\n if (!c) throw new Error(`@pmndrs/vdb: vendored declaration ${name} is missing; re-run scripts/extract-wgsl-chunks.mjs`);\n return c;\n}\n\nconst TYPE_TABLE = \"pnanovdb_grid_type_constants\";\nconst TYPE_TABLE_FN = \"pnanovdb_gtc\";\nconst TYPE_TABLE_CALL_SITE = /\\bpnanovdb_grid_type_constants\\[([^\\]]+)\\]/g;\n/** Names the transforms introduce, resolved to the declaration they replace. */\nconst ALIASES = new Map<string, string>([[TYPE_TABLE_FN, TYPE_TABLE]]);\n\nconst GRID_TYPE_CONSTANT_PRE: Readonly<Record<VDBGridTypeName, string>> = {\n float: \"PNANOVDB_GRID_TYPE_FLOAT\",\n fp4: \"PNANOVDB_GRID_TYPE_FP4\",\n fp8: \"PNANOVDB_GRID_TYPE_FP8\",\n fp16: \"PNANOVDB_GRID_TYPE_FP16\",\n fpn: \"PNANOVDB_GRID_TYPE_FPN\",\n};\n\n/** Field names of the vendored `pnanovdb_grid_type_constants_t`, in order. */\nconst TYPE_TABLE_FIELDS: readonly string[] = [...chunk(\"pnanovdb_grid_type_constants_t\").text.matchAll(/^\\s+(\\w+)\\s*:/gm)].map((m) => m[1] as string);\n\n/** The 27 rows of the vendored type table, as argument lists. */\nconst TYPE_TABLE_ROWS: readonly (readonly string[])[] = (() => {\n const rows = [...chunk(TYPE_TABLE).text.matchAll(/pnanovdb_grid_type_constants_t\\(([^)]*)\\)/g)].map((m) =>\n (m[1] as string).split(\",\").map((v) => v.trim()),\n );\n if (rows.length !== 27 || rows.some((r) => r.length !== TYPE_TABLE_FIELDS.length)) {\n throw new Error(`@pmndrs/vdb: unexpected vendored grid type table shape; re-check generate.ts against vendor/pnanovdb.wgsl`);\n }\n return rows;\n})();\n\n/**\n * Generation context: the options, plus the type-table fields the emitted\n * code reads (`null` = all, used for the first closure pass).\n */\ninterface Context {\n readonly o: NormalizedOptions;\n readonly fields: ReadonlySet<string> | null;\n}\n\n/** Transform 1: the single buffer access. */\nfunction bufReadOverride(): string {\n return `fn pnanovdb_buf_read_uint32(buf: pnanovdb_buf_t, byte_offset: u32) -> u32 {\n return vdb_load((buf.byte_offset >> 2u) + (byte_offset >> 2u));\n}`;\n}\n\n/**\n * Transform 2: the type table cut to the compiled types. Fields no emitted code\n * reads are written as 0u, and types whose remaining rows are equal share one\n * branch (Fp4/Fp8/Fp16/FpN differ only in the unread `leaf_size`). One distinct\n * row: a constant, no branch.\n */\nfunction typeTableOverride({ o, fields }: Context): string {\n const groups: { row: string; types: VDBGridTypeName[] }[] = [];\n for (const t of o.types) {\n const values = TYPE_TABLE_ROWS[VDB_GRID_TYPE_IDS[t]] as readonly string[];\n const row = `pnanovdb_grid_type_constants_t(${values\n .map((v, i) => (fields === null || fields.has(TYPE_TABLE_FIELDS[i] as string) ? v : \"0u\"))\n .join(\", \")})`;\n const group = groups.find((g) => g.row === row);\n if (group) group.types.push(t);\n else groups.push({ row, types: [t] });\n }\n const lines = [`fn ${TYPE_TABLE_FN}(grid_type: u32) -> pnanovdb_grid_type_constants_t {`];\n groups.forEach((g, i) => {\n if (i === groups.length - 1) {\n lines.push(` return ${g.row};`);\n } else {\n lines.push(` if ${g.types.map((t) => `grid_type == ${GRID_TYPE_CONSTANT_PRE[t]}`).join(\" || \")} {`);\n lines.push(` return ${g.row};`);\n lines.push(` }`);\n }\n });\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\n/** Transform 3: typed decode limited to the compiled types. */\nfunction readFloatTypedOverride({ o }: Context): string {\n const text = chunk(\"pnanovdb_read_float_typed\").text;\n const signature = text.slice(0, text.indexOf(\"{\") + 1);\n const fpTypes = o.types.filter((t) => t !== \"float\");\n const decode = (t: VDBGridTypeName) => `pnanovdb_root_${t}_read_float(buf, address, ijk, level)`;\n const lines = [signature];\n // Without Float, the last Fp type is the fallthrough: `ok` already rejects\n // every other type before a read reaches here.\n const branches = o.types.includes(\"float\") ? fpTypes : fpTypes.slice(0, -1);\n for (const t of branches) {\n lines.push(` if grid_type == ${GRID_TYPE_CONSTANT_PRE[t]} {`);\n lines.push(` return ${decode(t)};`);\n lines.push(` }`);\n }\n lines.push(o.types.includes(\"float\") ? \" return pnanovdb_read_float(buf, address);\" : ` return ${decode(fpTypes[fpTypes.length - 1] as VDBGridTypeName)};`);\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\n/**\n * Transform 7: the leaf-stat dispatch limited to the compiled types. No Fp type\n * compiled: a plain f32 read (the code decoder drops out). Only Fp types: the\n * decode, unconditionally. Both: one branch over the compiled Fp types.\n */\nfunction leafStatOverride({ o }: Context): string {\n const text = chunk(\"pnanovdb_leaf_get_stat_float\").text;\n const signature = text.slice(0, text.indexOf(\"{\") + 1);\n const fpTypes = o.types.filter((t) => t !== \"float\");\n const decode = \"return pnanovdb_leaf_fp_get_stat_float(grid_type, buf, node, address, with_minimum);\";\n const plain = \"return pnanovdb_read_float(buf, address);\";\n const lines = [signature];\n if (fpTypes.length === 0) {\n lines.push(` ${plain}`);\n } else if (!o.types.includes(\"float\")) {\n lines.push(` ${decode}`);\n } else {\n lines.push(` if ${fpTypes.map((t) => `grid_type == ${GRID_TYPE_CONSTANT_PRE[t]}`).join(\" || \")} {`);\n lines.push(` ${decode}`);\n lines.push(\" }\");\n lines.push(` ${plain}`);\n }\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\nconst OVERRIDES = new Map<string, (ctx: Context) => string>([\n [\"pnanovdb_buf_read_uint32\", bufReadOverride],\n [TYPE_TABLE, typeTableOverride],\n [\"pnanovdb_read_float_typed\", readFloatTypedOverride],\n [\"pnanovdb_leaf_get_stat_float\", leafStatOverride],\n]);\n\nfunction effectiveText(c: PnanovdbChunk, ctx: Context): string {\n const override = OVERRIDES.get(c.name);\n if (override) return override(ctx);\n return c.text.replace(TYPE_TABLE_CALL_SITE, `${TYPE_TABLE_FN}($1)`);\n}\n\nfunction referencedChunks(text: string, self?: string): string[] {\n const out = new Set<string>();\n for (const m of text.matchAll(IDENTIFIER)) {\n const name = ALIASES.get(m[0]) ?? m[0];\n if (name !== self && CHUNKS.has(name)) out.add(name);\n }\n return [...out];\n}\n\n/** Map a final (`vdb_` / `VDB_`) name back to its vendored declaration, if it is one. */\nfunction vendoredName(finalName: string): string | undefined {\n let name: string | undefined;\n if (finalName.startsWith(\"vdb_\")) name = `pnanovdb_${finalName.slice(4)}`;\n else if (finalName.startsWith(\"VDB_\")) name = `PNANOVDB_${finalName.slice(4)}`;\n if (name === undefined) return undefined;\n name = ALIASES.get(name) ?? name;\n return CHUNKS.has(name) ? name : undefined;\n}\n\nfunction rename(text: string): string {\n return text.replace(/\\bpnanovdb_/g, \"vdb_\").replace(/\\bPNANOVDB_/g, \"VDB_\");\n}\n\n/** Vendored declarations a module needs, in file order. */\nfunction closurePass(api: string, ctx: Context): string[] {\n const roots = new Set<string>();\n for (const m of api.matchAll(IDENTIFIER)) {\n const name = vendoredName(m[0]);\n if (name) roots.add(name);\n }\n const included = new Set<string>();\n const stack = [...roots];\n while (stack.length > 0) {\n const name = stack.pop() as string;\n if (included.has(name)) continue;\n included.add(name);\n const c = chunk(name);\n for (const d of referencedChunks(effectiveText(c, ctx), name)) if (!included.has(d)) stack.push(d);\n }\n return [...included].sort((a, b) => (ORDER.get(a) as number) - (ORDER.get(b) as number));\n}\n\n/**\n * Vendored declarations a module needs, in file order, and the context to\n * emit them with. Two passes: the first (whole type-table rows) finds which\n * type-table fields the closure reads; the second emits only those, which can\n * only shrink the closure.\n */\nfunction closure(api: string, o: NormalizedOptions): { names: string[]; ctx: Context } {\n const first = closurePass(api, { o, fields: null });\n const fields = new Set<string>();\n for (const name of first) {\n if (name === TYPE_TABLE || name === \"pnanovdb_grid_type_constants_t\") continue;\n for (const m of chunk(name).text.matchAll(/\\.([A-Za-z_]\\w*)/g)) {\n if (TYPE_TABLE_FIELDS.includes(m[1] as string)) fields.add(m[1] as string);\n }\n }\n const ctx: Context = { o, fields };\n return { names: closurePass(api, ctx), ctx };\n}\n\nconst cache = new Map<string, string>();\n\nfunction build(o: NormalizedOptions): string {\n const api = apiWgsl(o.profileRank, o);\n const access = o.binding.kind === \"slot\" ? VDB_POOL_BINDING_NAME : o.binding.expression;\n const load = `fn vdb_load(vdb_i: u32) -> u32 {\n return ${access}[vdb_i];\n}`;\n const { names, ctx } = closure(api, o);\n const vendored = names.map((name) => rename(effectiveText(chunk(name), ctx))).join(\"\\n\");\n const body = [vendored, load, api].join(\"\\n\");\n // Layout constants come from core/pool/layout.ts (one source of truth); keep\n // only the `const` lines the body references.\n const constants = vdbPoolLayoutWgsl()\n .split(\"\\n\")\n .filter((line) => {\n const name = /^const\\s+(\\w+)/.exec(line)?.[1];\n return name !== undefined && new RegExp(`\\\\b${name}\\\\b`).test(body);\n });\n const head = [VDB_MODULE_BANNER];\n if (o.binding.kind === \"slot\") {\n head.push(`@group(${o.binding.slot.group}) @binding(${o.binding.slot.firstBinding}) var<storage, read> ${VDB_POOL_BINDING_NAME}: array<u32>;`);\n }\n return [...head, ...constants, body].join(\"\\n\") + \"\\n\";\n}\n\n/**\n * Generate a WGSL module for the pool (docs/dev/design/K1-core.md §3.1).\n * Deterministic: the same options give the same string.\n *\n * `types` must cover every grid type the host may add to the pool, not just\n * the ones present now: a grid of a type the module wasn't generated for reads\n * as 0. Either generate for every type up front (`VDB_ALL_SCALAR_TYPES`, or\n * the host's known set) or regenerate the module and rebuild the pipeline when\n * `vdbCheckModule(pool, options)` throws `VDB_TYPE_NOT_COMPILED` after an `add`.\n *\n * @throws VDBError `VDB_BAD_OPTION` for invalid options.\n */\nexport function vdbModuleWgsl(options: VDBModuleOptions): string {\n const o = normalize(options, \"vdbModuleWgsl\");\n const key = JSON.stringify(o);\n let code = cache.get(key);\n if (code === undefined) {\n code = build(o);\n cache.set(key, code);\n }\n return code;\n}\n\n/**\n * The bind group layout entries a `slot` module declares: one read-only\n * storage buffer at `slot.firstBinding` (layout 1).\n *\n * Takes the same `VDBSlot` as `vdbModuleWgsl({ slot })` and\n * `pool.bindGroupEntry(slot)`, either bare or as `{ slot, visibility }`.\n * `visibility` defaults to `GPUShaderStage.COMPUTE | GPUShaderStage.FRAGMENT`\n * (read-only storage is legal in both stages), so render and compute hosts\n * both work without it; pass it to narrow the layout.\n *\n * @throws VDBError `VDB_BAD_OPTION` for a malformed slot.\n */\nexport function vdbModuleEntries(\n slotOrOptions: VDBSlot | { readonly slot: VDBSlot; readonly visibility?: GPUShaderStageFlags | undefined },\n): GPUBindGroupLayoutEntry[] {\n const where = \"vdbModuleEntries\";\n if (slotOrOptions === null || typeof slotOrOptions !== \"object\") throw bad(`${where}: expected a slot { group, firstBinding } or { slot, visibility? }.`);\n let slot: VDBSlot;\n let visibility: GPUShaderStageFlags = SHADER_STAGE_FRAGMENT_COMPUTE;\n if (\"slot\" in slotOrOptions) {\n rejectPositionalSlot(where, slotOrOptions);\n slot = checkSlot(slotOrOptions.slot, where);\n const v = slotOrOptions.visibility;\n if (v !== undefined) {\n if (!Number.isInteger(v) || v <= 0) throw bad(`${where}: visibility must be GPUShaderStage flags (a positive integer), got ${JSON.stringify(v)}.`);\n visibility = v;\n }\n } else {\n if (\"visibility\" in slotOrOptions) throw bad(`${where}: pass visibility as { slot: { group, firstBinding }, visibility }.`);\n slot = checkSlot(slotOrOptions, where);\n }\n return [{ binding: slot.firstBinding, visibility, buffer: { type: \"read-only-storage\" } }];\n}\n\n/**\n * Check that a module generated with `options` can read every grid in `pool`.\n *\n * `options` is either the full `vdbModuleWgsl` options (validated as such) or\n * just `{ types, layoutVersion? }` for a type/layout-only check, e.g. from an\n * engine adapter that builds its module elsewhere. `layoutVersion` is the\n * layout the module targets (default: this generator's,\n * `VDB_GPU_LAYOUT_VERSION`).\n *\n * After every `pool.add`: a module must be generated for every type the host\n * may add, or regenerated and its pipeline rebuilt.\n *\n * @throws VDBError `VDB_LAYOUT_MISMATCH` if the pool's layout is not the one\n * the module targets; `VDB_TYPE_NOT_COMPILED` if the pool holds a grid\n * type the module would not decode; `VDB_BAD_OPTION` for invalid options.\n */\nexport function vdbCheckModule(pool: VDBModulePoolLike, options: VDBModuleOptions | VDBModuleTypeCheck): void {\n const where = \"vdbCheckModule\";\n let o: { readonly types: readonly VDBGridTypeName[] };\n let target = VDB_GPU_LAYOUT_VERSION;\n if (options !== null && typeof options === \"object\" && !(\"slot\" in options) && !(\"buffer\" in options) && !(\"profile\" in options)) {\n // Type/layout-only form.\n o = { types: normalizeTypes(options.types, where) };\n const v = (options as VDBModuleTypeCheck).layoutVersion;\n if (v !== undefined) {\n if (!Number.isInteger(v) || v < 0) throw bad(`${where}: layoutVersion must be a non-negative integer, got ${JSON.stringify(v)}.`);\n target = v;\n }\n } else {\n o = normalize(options as VDBModuleOptions, where);\n }\n if (pool.layoutVersion !== target) {\n throw new VDBError(\n \"VDB_LAYOUT_MISMATCH\",\n `the pool uses layout ${pool.layoutVersion} but the module targets layout ${target}. Use one @pmndrs/vdb version for both.`,\n );\n }\n const missing = [...new Set(pool.types)].filter((t) => !o.types.includes(t));\n if (missing.length > 0) {\n throw new VDBError(\n \"VDB_TYPE_NOT_COMPILED\",\n `the pool holds ${missing.join(\", \")} grids but the module compiles only ${o.types.join(\", \")}; those grids would read 0. ` +\n `A module must be generated for every type the host may add: regenerate it with types that include ${missing.join(\", \")} ` +\n `(e.g. [...pool.types], or VDB_ALL_SCALAR_TYPES to never rebuild) and rebuild the pipeline that uses it.`,\n );\n }\n}\n\n/** @internal Vendored declarations (vendored names) a module with these options includes, in file order. For tests. */\nexport function vdbModuleDeclarations(options: VDBModuleOptions): string[] {\n const o = normalize(options, \"vdbModuleDeclarations\");\n return closure(apiWgsl(o.profileRank, o), o).names;\n}\n"]}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The opt-in `'levelSet'` helper (K3.7, R1 §6 Step 7): a zero-crossing finder
3
+ * for NanoVDB level sets on the sparse tree, and its gradient normal. Written
4
+ * in the generated module's final names (public `vdb*` API plus the vendored
5
+ * HDDA fields it reads), emitted only when `helpers` lists it.
6
+ *
7
+ * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345
8
+ * (`src/three-openvdb/levelset/webgpu/LevelSetSurfaceMaterial.js`: the sphere
9
+ * trace with a minimum step, the secant step between the last outside and the
10
+ * first inside sample, central-difference normals). Copyright (c)
11
+ * mjurczyk/openvdb contributors, MIT (see THIRD_PARTY_NOTICES.md). Changes: traced on
12
+ * the sparse NanoVDB tree (trilinear `vdbSample`, full resolution) instead of
13
+ * his dense 8-bit distance texture; an HDDA walk skips cells whose trilinear
14
+ * support is all tiles or background above zero; bisection before the secant
15
+ * step; normals through the grid's affine. See DIVERGES.md.
16
+ *
17
+ * CPU twins: `tools` `levelSetHit`, `levelSetGradient`, `levelSetNormal`
18
+ * (`tools/cpu/level-set.ts`), same walk, same sample positions.
19
+ */
20
+ /**
21
+ * The WGSL text of the `'levelSet'` helper (`march` profile).
22
+ *
23
+ * - `vdbLevelSetHit(g, o, d, t, sdfToIndex, maxSamples) -> bool`: the first
24
+ * `t` in `(*t).x .. (*t).y` (clipped to the trilinear support box
25
+ * `[min - 1, max + 1]`) where the trilinear SDF `vdbSample` goes below 0,
26
+ * along `o + d * t` in grid `g`'s index space (`d` need not be unit length).
27
+ * On a hit `(*t).x` is the crossing; a ray whose first sample is already
28
+ * inside hits at that sample. `sdfToIndex` converts SDF values to index
29
+ * voxels (1 / the grid's voxel size for a level set in its own world units);
30
+ * the step is `max(0.95 * v * sdfToIndex, 0.25)` voxels. `maxSamples` caps
31
+ * the samples (a ray that runs out misses).
32
+ * - `vdbLevelSetGradient(acc, xyz, h) -> vec3f`: central differences of
33
+ * `vdbSample` at +/- `h` voxels, in SDF units per index voxel.
34
+ * - `vdbLevelSetNormal(g, xyz, h) -> vec3f`: the outward unit normal in world
35
+ * space, `normalize(W^T * gradient)` with `W` the record's world-to-index
36
+ * linear part (correct under rotation and non-uniform scale).
37
+ *
38
+ * The walk: an HDDA over aligned cells of at least 8 voxels, the cell size
39
+ * following `vdbGetDim` at the cell corner (8 inside leaves and lower tiles,
40
+ * larger in upper and root tiles). A cell is skipped when the 2x2x2 block of
41
+ * same-size cells from its corner (every tap a trilinear sample in the cell can
42
+ * read) is all uniform (`vdbGetDim >= dim`) with values above 0: no sample in
43
+ * it can be inside. A larger cell that fails the test is walked again at 8.
44
+ * Other cells are sphere traced; a sample below 0 brackets the crossing with
45
+ * the previous sample, which 8 bisections and a secant step refine.
46
+ *
47
+ * Every `vdbSample` call site inlines the type-dispatched trilinear reader,
48
+ * so the gradient's six taps run in a loop (one site): with six sites a
49
+ * module took 98-168 s to compile on SwiftShader, with one 10-19 s. The hit
50
+ * keeps three sites (march, closing sample, bisection): folding them into one
51
+ * moded loop compiled faster again (6-11 s) but ran 2x slower on Metal
52
+ * (teapot frame 15.7 vs 8.0 ms). The sample sequence is the twin's.
53
+ */
54
+ export declare function levelSetWgsl(): string[];
@@ -0,0 +1,194 @@
1
+ /**
2
+ * The opt-in `'levelSet'` helper (K3.7, R1 §6 Step 7): a zero-crossing finder
3
+ * for NanoVDB level sets on the sparse tree, and its gradient normal. Written
4
+ * in the generated module's final names (public `vdb*` API plus the vendored
5
+ * HDDA fields it reads), emitted only when `helpers` lists it.
6
+ *
7
+ * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345
8
+ * (`src/three-openvdb/levelset/webgpu/LevelSetSurfaceMaterial.js`: the sphere
9
+ * trace with a minimum step, the secant step between the last outside and the
10
+ * first inside sample, central-difference normals). Copyright (c)
11
+ * mjurczyk/openvdb contributors, MIT (see THIRD_PARTY_NOTICES.md). Changes: traced on
12
+ * the sparse NanoVDB tree (trilinear `vdbSample`, full resolution) instead of
13
+ * his dense 8-bit distance texture; an HDDA walk skips cells whose trilinear
14
+ * support is all tiles or background above zero; bisection before the secant
15
+ * step; normals through the grid's affine. See DIVERGES.md.
16
+ *
17
+ * CPU twins: `tools` `levelSetHit`, `levelSetGradient`, `levelSetNormal`
18
+ * (`tools/cpu/level-set.ts`), same walk, same sample positions.
19
+ */
20
+ /**
21
+ * The WGSL text of the `'levelSet'` helper (`march` profile).
22
+ *
23
+ * - `vdbLevelSetHit(g, o, d, t, sdfToIndex, maxSamples) -> bool`: the first
24
+ * `t` in `(*t).x .. (*t).y` (clipped to the trilinear support box
25
+ * `[min - 1, max + 1]`) where the trilinear SDF `vdbSample` goes below 0,
26
+ * along `o + d * t` in grid `g`'s index space (`d` need not be unit length).
27
+ * On a hit `(*t).x` is the crossing; a ray whose first sample is already
28
+ * inside hits at that sample. `sdfToIndex` converts SDF values to index
29
+ * voxels (1 / the grid's voxel size for a level set in its own world units);
30
+ * the step is `max(0.95 * v * sdfToIndex, 0.25)` voxels. `maxSamples` caps
31
+ * the samples (a ray that runs out misses).
32
+ * - `vdbLevelSetGradient(acc, xyz, h) -> vec3f`: central differences of
33
+ * `vdbSample` at +/- `h` voxels, in SDF units per index voxel.
34
+ * - `vdbLevelSetNormal(g, xyz, h) -> vec3f`: the outward unit normal in world
35
+ * space, `normalize(W^T * gradient)` with `W` the record's world-to-index
36
+ * linear part (correct under rotation and non-uniform scale).
37
+ *
38
+ * The walk: an HDDA over aligned cells of at least 8 voxels, the cell size
39
+ * following `vdbGetDim` at the cell corner (8 inside leaves and lower tiles,
40
+ * larger in upper and root tiles). A cell is skipped when the 2x2x2 block of
41
+ * same-size cells from its corner (every tap a trilinear sample in the cell can
42
+ * read) is all uniform (`vdbGetDim >= dim`) with values above 0: no sample in
43
+ * it can be inside. A larger cell that fails the test is walked again at 8.
44
+ * Other cells are sphere traced; a sample below 0 brackets the crossing with
45
+ * the previous sample, which 8 bisections and a secant step refine.
46
+ *
47
+ * Every `vdbSample` call site inlines the type-dispatched trilinear reader,
48
+ * so the gradient's six taps run in a loop (one site): with six sites a
49
+ * module took 98-168 s to compile on SwiftShader, with one 10-19 s. The hit
50
+ * keeps three sites (march, closing sample, bisection): folding them into one
51
+ * moded loop compiled faster again (6-11 s) but ran 2x slower on Metal
52
+ * (teapot frame 15.7 vs 8.0 ms). The sample sequence is the twin's.
53
+ */
54
+ export function levelSetWgsl() {
55
+ return [
56
+ `fn vdb_ls_skip(acc: ptr<function, VdbAccessor>, c: vec3i, dim: u32) -> bool {
57
+ for (var k = 0u; k < 8u; k++) {
58
+ let p = c + vec3i(vec3u(k & 1u, (k >> 1u) & 1u, (k >> 2u) & 1u)) * i32(dim);
59
+ if vdbGetDim(acc, p) < dim {
60
+ return false;
61
+ }
62
+ if !(vdbReadValue(acc, p) > 0.0) {
63
+ return false;
64
+ }
65
+ }
66
+ return true;
67
+ }`,
68
+ `fn vdbLevelSetHit(g: u32, o: vec3f, d: vec3f, t: ptr<function, vec2f>, sdfToIndex: f32, maxSamples: u32) -> bool {
69
+ if !vdb_live(g) {
70
+ return false;
71
+ }
72
+ var t0 = (*t).x;
73
+ var t1 = (*t).y;
74
+ let clip = vdb_hdda_ray_clip(vec3f(vdbIndexMin(g)) - vec3f(1.0), vec3f(vdbIndexMax(g)) + vec3f(1.0), o, &t0, d, &t1);
75
+ if !clip || !(t0 <= t1) {
76
+ return false;
77
+ }
78
+ var acc = vdbAccessorInit(g);
79
+ if !acc.ok {
80
+ return false;
81
+ }
82
+ let inv = 1.0 / max(length(d), 1e-30);
83
+ let minStep = 0.25 * inv;
84
+ let k = 0.95 * sdfToIndex * inv;
85
+ var h: VdbHdda;
86
+ vdbHddaInit(&h, o, t0, d, t1, max(vdbGetDim(&acc, vec3i(floor(o + d * t0))), 8u));
87
+ var tc = t0;
88
+ var tp = t0;
89
+ var vp = 0.0;
90
+ var have = false;
91
+ var n = 0u;
92
+ var updates = 0u;
93
+ var fineUntil = -3.0e38;
94
+ var crossed = false;
95
+ var vc = 0.0;
96
+ for (var it = 0u; it < 8192u; it++) {
97
+ var want = max(vdbGetDim(&acc, h.voxel), 8u);
98
+ if h.tmin < fineUntil {
99
+ want = 8u;
100
+ }
101
+ if want != u32(h.dim) && updates < 2u {
102
+ vdbHddaUpdate(&h, o, d, want);
103
+ updates++;
104
+ continue;
105
+ }
106
+ updates = 0u;
107
+ let te = min(min(h.next.x, h.next.y), min(h.next.z, h.tmax));
108
+ if te >= tc {
109
+ let dim = u32(h.dim);
110
+ if vdb_ls_skip(&acc, h.voxel, dim) {
111
+ tc = te;
112
+ } else if dim > 8u && te > h.tmin {
113
+ fineUntil = te;
114
+ vdbHddaUpdate(&h, o, d, 8u);
115
+ continue;
116
+ } else {
117
+ loop {
118
+ if tc > te || n >= maxSamples {
119
+ break;
120
+ }
121
+ vc = vdbSample(&acc, o + d * tc);
122
+ n++;
123
+ if vc < 0.0 {
124
+ crossed = true;
125
+ break;
126
+ }
127
+ tp = tc;
128
+ vp = vc;
129
+ have = true;
130
+ tc += max(vc * k, minStep);
131
+ }
132
+ if crossed || n >= maxSamples {
133
+ break;
134
+ }
135
+ }
136
+ }
137
+ if !vdbHddaStep(&h) {
138
+ break;
139
+ }
140
+ }
141
+ if !crossed && have && tp < t1 && n < maxSamples {
142
+ tc = t1;
143
+ vc = vdbSample(&acc, o + d * tc);
144
+ crossed = vc < 0.0;
145
+ }
146
+ if !crossed {
147
+ return false;
148
+ }
149
+ if !have {
150
+ (*t).x = tc;
151
+ return true;
152
+ }
153
+ var lo = tp;
154
+ var hi = tc;
155
+ var vlo = vp;
156
+ var vhi = vc;
157
+ for (var i = 0u; i < 8u; i++) {
158
+ let m = 0.5 * (lo + hi);
159
+ let vm = vdbSample(&acc, o + d * m);
160
+ if vm < 0.0 {
161
+ hi = m;
162
+ vhi = vm;
163
+ } else {
164
+ lo = m;
165
+ vlo = vm;
166
+ }
167
+ }
168
+ (*t).x = lo + (hi - lo) * (vlo / (vlo - vhi));
169
+ return true;
170
+ }`,
171
+ `fn vdbLevelSetGradient(acc: ptr<function, VdbAccessor>, xyz: vec3f, h: f32) -> vec3f {
172
+ var gr = vec3f(0.0);
173
+ for (var i = 0u; i < 6u; i++) {
174
+ let axis = i >> 1u;
175
+ let sgn = select(-1.0, 1.0, (i & 1u) == 0u);
176
+ var e = vec3f(0.0);
177
+ e[axis] = sgn * h;
178
+ gr[axis] += sgn * vdbSample(acc, xyz + e);
179
+ }
180
+ return gr / (2.0 * h);
181
+ }`,
182
+ `fn vdbLevelSetNormal(g: u32, xyz: vec3f, h: f32) -> vec3f {
183
+ var acc = vdbAccessorInit(g);
184
+ let gi = vdbLevelSetGradient(&acc, xyz, h);
185
+ let n = vec3f(dot(vdbWorldToIndexDir(g, vec3f(1.0, 0.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 1.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 0.0, 1.0)), gi));
186
+ let l = length(n);
187
+ if !(l > 0.0) {
188
+ return vec3f(0.0, 1.0, 0.0);
189
+ }
190
+ return n / l;
191
+ }`,
192
+ ];
193
+ }
194
+ //# sourceMappingURL=level-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"level-set.js","sourceRoot":"","sources":["../../../src/core/wgsl/level-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL;;;;;;;;;;;EAWF;QACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsGF;QACE;;;;;;;;;;EAUF;QACE;;;;;;;;;EASF;KACC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The opt-in `'levelSet'` helper (K3.7, R1 §6 Step 7): a zero-crossing finder\n * for NanoVDB level sets on the sparse tree, and its gradient normal. Written\n * in the generated module's final names (public `vdb*` API plus the vendored\n * HDDA fields it reads), emitted only when `helpers` lists it.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/three-openvdb/levelset/webgpu/LevelSetSurfaceMaterial.js`: the sphere\n * trace with a minimum step, the secant step between the last outside and the\n * first inside sample, central-difference normals). Copyright (c)\n * mjurczyk/openvdb contributors, MIT (see THIRD_PARTY_NOTICES.md). Changes: traced on\n * the sparse NanoVDB tree (trilinear `vdbSample`, full resolution) instead of\n * his dense 8-bit distance texture; an HDDA walk skips cells whose trilinear\n * support is all tiles or background above zero; bisection before the secant\n * step; normals through the grid's affine. See DIVERGES.md.\n *\n * CPU twins: `tools` `levelSetHit`, `levelSetGradient`, `levelSetNormal`\n * (`tools/cpu/level-set.ts`), same walk, same sample positions.\n */\n\n/**\n * The WGSL text of the `'levelSet'` helper (`march` profile).\n *\n * - `vdbLevelSetHit(g, o, d, t, sdfToIndex, maxSamples) -> bool`: the first\n * `t` in `(*t).x .. (*t).y` (clipped to the trilinear support box\n * `[min - 1, max + 1]`) where the trilinear SDF `vdbSample` goes below 0,\n * along `o + d * t` in grid `g`'s index space (`d` need not be unit length).\n * On a hit `(*t).x` is the crossing; a ray whose first sample is already\n * inside hits at that sample. `sdfToIndex` converts SDF values to index\n * voxels (1 / the grid's voxel size for a level set in its own world units);\n * the step is `max(0.95 * v * sdfToIndex, 0.25)` voxels. `maxSamples` caps\n * the samples (a ray that runs out misses).\n * - `vdbLevelSetGradient(acc, xyz, h) -> vec3f`: central differences of\n * `vdbSample` at +/- `h` voxels, in SDF units per index voxel.\n * - `vdbLevelSetNormal(g, xyz, h) -> vec3f`: the outward unit normal in world\n * space, `normalize(W^T * gradient)` with `W` the record's world-to-index\n * linear part (correct under rotation and non-uniform scale).\n *\n * The walk: an HDDA over aligned cells of at least 8 voxels, the cell size\n * following `vdbGetDim` at the cell corner (8 inside leaves and lower tiles,\n * larger in upper and root tiles). A cell is skipped when the 2x2x2 block of\n * same-size cells from its corner (every tap a trilinear sample in the cell can\n * read) is all uniform (`vdbGetDim >= dim`) with values above 0: no sample in\n * it can be inside. A larger cell that fails the test is walked again at 8.\n * Other cells are sphere traced; a sample below 0 brackets the crossing with\n * the previous sample, which 8 bisections and a secant step refine.\n *\n * Every `vdbSample` call site inlines the type-dispatched trilinear reader,\n * so the gradient's six taps run in a loop (one site): with six sites a\n * module took 98-168 s to compile on SwiftShader, with one 10-19 s. The hit\n * keeps three sites (march, closing sample, bisection): folding them into one\n * moded loop compiled faster again (6-11 s) but ran 2x slower on Metal\n * (teapot frame 15.7 vs 8.0 ms). The sample sequence is the twin's.\n */\nexport function levelSetWgsl(): string[] {\n return [\n `fn vdb_ls_skip(acc: ptr<function, VdbAccessor>, c: vec3i, dim: u32) -> bool {\n for (var k = 0u; k < 8u; k++) {\n let p = c + vec3i(vec3u(k & 1u, (k >> 1u) & 1u, (k >> 2u) & 1u)) * i32(dim);\n if vdbGetDim(acc, p) < dim {\n return false;\n }\n if !(vdbReadValue(acc, p) > 0.0) {\n return false;\n }\n }\n return true;\n}`,\n `fn vdbLevelSetHit(g: u32, o: vec3f, d: vec3f, t: ptr<function, vec2f>, sdfToIndex: f32, maxSamples: u32) -> bool {\n if !vdb_live(g) {\n return false;\n }\n var t0 = (*t).x;\n var t1 = (*t).y;\n let clip = vdb_hdda_ray_clip(vec3f(vdbIndexMin(g)) - vec3f(1.0), vec3f(vdbIndexMax(g)) + vec3f(1.0), o, &t0, d, &t1);\n if !clip || !(t0 <= t1) {\n return false;\n }\n var acc = vdbAccessorInit(g);\n if !acc.ok {\n return false;\n }\n let inv = 1.0 / max(length(d), 1e-30);\n let minStep = 0.25 * inv;\n let k = 0.95 * sdfToIndex * inv;\n var h: VdbHdda;\n vdbHddaInit(&h, o, t0, d, t1, max(vdbGetDim(&acc, vec3i(floor(o + d * t0))), 8u));\n var tc = t0;\n var tp = t0;\n var vp = 0.0;\n var have = false;\n var n = 0u;\n var updates = 0u;\n var fineUntil = -3.0e38;\n var crossed = false;\n var vc = 0.0;\n for (var it = 0u; it < 8192u; it++) {\n var want = max(vdbGetDim(&acc, h.voxel), 8u);\n if h.tmin < fineUntil {\n want = 8u;\n }\n if want != u32(h.dim) && updates < 2u {\n vdbHddaUpdate(&h, o, d, want);\n updates++;\n continue;\n }\n updates = 0u;\n let te = min(min(h.next.x, h.next.y), min(h.next.z, h.tmax));\n if te >= tc {\n let dim = u32(h.dim);\n if vdb_ls_skip(&acc, h.voxel, dim) {\n tc = te;\n } else if dim > 8u && te > h.tmin {\n fineUntil = te;\n vdbHddaUpdate(&h, o, d, 8u);\n continue;\n } else {\n loop {\n if tc > te || n >= maxSamples {\n break;\n }\n vc = vdbSample(&acc, o + d * tc);\n n++;\n if vc < 0.0 {\n crossed = true;\n break;\n }\n tp = tc;\n vp = vc;\n have = true;\n tc += max(vc * k, minStep);\n }\n if crossed || n >= maxSamples {\n break;\n }\n }\n }\n if !vdbHddaStep(&h) {\n break;\n }\n }\n if !crossed && have && tp < t1 && n < maxSamples {\n tc = t1;\n vc = vdbSample(&acc, o + d * tc);\n crossed = vc < 0.0;\n }\n if !crossed {\n return false;\n }\n if !have {\n (*t).x = tc;\n return true;\n }\n var lo = tp;\n var hi = tc;\n var vlo = vp;\n var vhi = vc;\n for (var i = 0u; i < 8u; i++) {\n let m = 0.5 * (lo + hi);\n let vm = vdbSample(&acc, o + d * m);\n if vm < 0.0 {\n hi = m;\n vhi = vm;\n } else {\n lo = m;\n vlo = vm;\n }\n }\n (*t).x = lo + (hi - lo) * (vlo / (vlo - vhi));\n return true;\n}`,\n `fn vdbLevelSetGradient(acc: ptr<function, VdbAccessor>, xyz: vec3f, h: f32) -> vec3f {\n var gr = vec3f(0.0);\n for (var i = 0u; i < 6u; i++) {\n let axis = i >> 1u;\n let sgn = select(-1.0, 1.0, (i & 1u) == 0u);\n var e = vec3f(0.0);\n e[axis] = sgn * h;\n gr[axis] += sgn * vdbSample(acc, xyz + e);\n }\n return gr / (2.0 * h);\n}`,\n `fn vdbLevelSetNormal(g: u32, xyz: vec3f, h: f32) -> vec3f {\n var acc = vdbAccessorInit(g);\n let gi = vdbLevelSetGradient(&acc, xyz, h);\n let n = vec3f(dot(vdbWorldToIndexDir(g, vec3f(1.0, 0.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 1.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 0.0, 1.0)), gi));\n let l = length(n);\n if !(l > 0.0) {\n return vec3f(0.0, 1.0, 0.0);\n }\n return n / l;\n}`,\n ];\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /** One top-level declaration of the vendored `pnanovdb.wgsl`. */
2
+ export interface PnanovdbChunk {
3
+ /** Declared name (`pnanovdb_*` / `PNANOVDB_*`). */
4
+ readonly name: string;
5
+ readonly kind: "fn" | "struct" | "const" | "alias";
6
+ /** Names of other chunks this one references, in file order. */
7
+ readonly deps: readonly string[];
8
+ /** Declaration text, comments removed. */
9
+ readonly text: string;
10
+ }
11
+ /** SHA-256 of the vendored file this table was extracted from. */
12
+ export declare const PNANOVDB_SOURCE_SHA256 = "f28fe6927ea1eead9e4d4d619c9b2e1fe365ac75514e1d19738354ecaf56b4ca";
13
+ /** Every top-level declaration, in file order (296 declarations). */
14
+ export declare const PNANOVDB_CHUNKS: readonly PnanovdbChunk[];