@pmndrs/vdb 0.0.0-stage → 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 (570) hide show
  1. package/CHANGELOG.md +727 -0
  2. package/LICENSE +21 -0
  3. package/README.md +496 -2
  4. package/THIRD_PARTY_NOTICES.md +315 -0
  5. package/dist/core/compute/atlas.d.ts +102 -0
  6. package/dist/core/compute/atlas.js +103 -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/majorant-build.d.ts +45 -0
  12. package/dist/core/compute/majorant-build.js +193 -0
  13. package/dist/core/compute/majorant-build.js.map +1 -0
  14. package/dist/core/compute/multi-scale.d.ts +155 -0
  15. package/dist/core/compute/multi-scale.js +684 -0
  16. package/dist/core/compute/multi-scale.js.map +1 -0
  17. package/dist/core/compute/pyramid.d.ts +120 -0
  18. package/dist/core/compute/pyramid.js +468 -0
  19. package/dist/core/compute/pyramid.js.map +1 -0
  20. package/dist/core/compute/shared.d.ts +116 -0
  21. package/dist/core/compute/shared.js +211 -0
  22. package/dist/core/compute/shared.js.map +1 -0
  23. package/dist/core/compute/stats.d.ts +78 -0
  24. package/dist/core/compute/stats.js +193 -0
  25. package/dist/core/compute/stats.js.map +1 -0
  26. package/dist/core/compute/value-transform.d.ts +30 -0
  27. package/dist/core/compute/value-transform.js +64 -0
  28. package/dist/core/compute/value-transform.js.map +1 -0
  29. package/dist/core/errors.d.ts +21 -0
  30. package/dist/core/errors.js +17 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/frame/emission.d.ts +85 -0
  33. package/dist/core/frame/emission.js +422 -0
  34. package/dist/core/frame/emission.js.map +1 -0
  35. package/dist/core/frame/environment.d.ts +47 -0
  36. package/dist/core/frame/environment.js +178 -0
  37. package/dist/core/frame/environment.js.map +1 -0
  38. package/dist/core/frame/index.d.ts +39 -0
  39. package/dist/core/frame/index.js +27 -0
  40. package/dist/core/frame/index.js.map +1 -0
  41. package/dist/core/frame/kernels.d.ts +115 -0
  42. package/dist/core/frame/kernels.js +496 -0
  43. package/dist/core/frame/kernels.js.map +1 -0
  44. package/dist/core/frame/limits.d.ts +67 -0
  45. package/dist/core/frame/limits.js +109 -0
  46. package/dist/core/frame/limits.js.map +1 -0
  47. package/dist/core/frame/phase.d.ts +17 -0
  48. package/dist/core/frame/phase.js +53 -0
  49. package/dist/core/frame/phase.js.map +1 -0
  50. package/dist/core/frame/pipelines.d.ts +49 -0
  51. package/dist/core/frame/pipelines.js +147 -0
  52. package/dist/core/frame/pipelines.js.map +1 -0
  53. package/dist/core/frame/renderer.d.ts +122 -0
  54. package/dist/core/frame/renderer.js +1712 -0
  55. package/dist/core/frame/renderer.js.map +1 -0
  56. package/dist/core/frame/resources.d.ts +71 -0
  57. package/dist/core/frame/resources.js +100 -0
  58. package/dist/core/frame/resources.js.map +1 -0
  59. package/dist/core/frame/scattering.d.ts +97 -0
  60. package/dist/core/frame/scattering.js +332 -0
  61. package/dist/core/frame/scattering.js.map +1 -0
  62. package/dist/core/frame/settings.d.ts +243 -0
  63. package/dist/core/frame/settings.js +67 -0
  64. package/dist/core/frame/settings.js.map +1 -0
  65. package/dist/core/frame/shadows.d.ts +55 -0
  66. package/dist/core/frame/shadows.js +460 -0
  67. package/dist/core/frame/shadows.js.map +1 -0
  68. package/dist/core/frame/types.d.ts +415 -0
  69. package/dist/core/frame/types.js +49 -0
  70. package/dist/core/frame/types.js.map +1 -0
  71. package/dist/core/frame/uniforms.d.ts +105 -0
  72. package/dist/core/frame/uniforms.js +276 -0
  73. package/dist/core/frame/uniforms.js.map +1 -0
  74. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  75. package/dist/core/frame/wgsl/chunks.js +728 -0
  76. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  77. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  78. package/dist/core/frame/wgsl/emission.js +353 -0
  79. package/dist/core/frame/wgsl/emission.js.map +1 -0
  80. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  81. package/dist/core/frame/wgsl/environment.js +711 -0
  82. package/dist/core/frame/wgsl/environment.js.map +1 -0
  83. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  84. package/dist/core/frame/wgsl/gather.js +850 -0
  85. package/dist/core/frame/wgsl/gather.js.map +1 -0
  86. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  87. package/dist/core/frame/wgsl/integrate.js +213 -0
  88. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  89. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  90. package/dist/core/frame/wgsl/lighting.js +1636 -0
  91. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  92. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  93. package/dist/core/frame/wgsl/occluders.js +95 -0
  94. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  95. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  96. package/dist/core/frame/wgsl/resolve.js +205 -0
  97. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  98. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  99. package/dist/core/frame/wgsl/shadows.js +328 -0
  100. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  101. package/dist/core/half.d.ts +11 -0
  102. package/dist/core/half.js +22 -0
  103. package/dist/core/half.js.map +1 -0
  104. package/dist/core/index.d.ts +52 -0
  105. package/dist/core/index.js +46 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/internal.d.ts +31 -0
  108. package/dist/core/internal.js +32 -0
  109. package/dist/core/internal.js.map +1 -0
  110. package/dist/core/pool/affine.d.ts +34 -0
  111. package/dist/core/pool/affine.js +100 -0
  112. package/dist/core/pool/affine.js.map +1 -0
  113. package/dist/core/pool/allocator.d.ts +32 -0
  114. package/dist/core/pool/allocator.js +81 -0
  115. package/dist/core/pool/allocator.js.map +1 -0
  116. package/dist/core/pool/image-header.d.ts +93 -0
  117. package/dist/core/pool/image-header.js +194 -0
  118. package/dist/core/pool/image-header.js.map +1 -0
  119. package/dist/core/pool/layout.d.ts +198 -0
  120. package/dist/core/pool/layout.js +316 -0
  121. package/dist/core/pool/layout.js.map +1 -0
  122. package/dist/core/pool/limits.d.ts +41 -0
  123. package/dist/core/pool/limits.js +80 -0
  124. package/dist/core/pool/limits.js.map +1 -0
  125. package/dist/core/pool/pool.d.ts +384 -0
  126. package/dist/core/pool/pool.js +1184 -0
  127. package/dist/core/pool/pool.js.map +1 -0
  128. package/dist/core/reference/index.d.ts +6 -0
  129. package/dist/core/reference/index.js +7 -0
  130. package/dist/core/reference/index.js.map +1 -0
  131. package/dist/core/reference/renderer.d.ts +105 -0
  132. package/dist/core/reference/renderer.js +474 -0
  133. package/dist/core/reference/renderer.js.map +1 -0
  134. package/dist/core/reference/wgsl.d.ts +65 -0
  135. package/dist/core/reference/wgsl.js +803 -0
  136. package/dist/core/reference/wgsl.js.map +1 -0
  137. package/dist/core/sequence.d.ts +347 -0
  138. package/dist/core/sequence.js +548 -0
  139. package/dist/core/sequence.js.map +1 -0
  140. package/dist/core/source/brick-cache.d.ts +165 -0
  141. package/dist/core/source/brick-cache.js +627 -0
  142. package/dist/core/source/brick-cache.js.map +1 -0
  143. package/dist/core/source/dense-fill.d.ts +53 -0
  144. package/dist/core/source/dense-fill.js +377 -0
  145. package/dist/core/source/dense-fill.js.map +1 -0
  146. package/dist/core/source/dense.d.ts +50 -0
  147. package/dist/core/source/dense.js +384 -0
  148. package/dist/core/source/dense.js.map +1 -0
  149. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  150. package/dist/core/source/sparse-wgsl.js +481 -0
  151. package/dist/core/source/sparse-wgsl.js.map +1 -0
  152. package/dist/core/source/sparse.d.ts +192 -0
  153. package/dist/core/source/sparse.js +762 -0
  154. package/dist/core/source/sparse.js.map +1 -0
  155. package/dist/core/source/types.d.ts +120 -0
  156. package/dist/core/source/types.js +9 -0
  157. package/dist/core/source/types.js.map +1 -0
  158. package/dist/core/surface/index.d.ts +10 -0
  159. package/dist/core/surface/index.js +9 -0
  160. package/dist/core/surface/index.js.map +1 -0
  161. package/dist/core/surface/level-set-pass.d.ts +140 -0
  162. package/dist/core/surface/level-set-pass.js +291 -0
  163. package/dist/core/surface/level-set-pass.js.map +1 -0
  164. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  165. package/dist/core/surface/level-set-wgsl.js +99 -0
  166. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  167. package/dist/core/surface/points.d.ts +109 -0
  168. package/dist/core/surface/points.js +226 -0
  169. package/dist/core/surface/points.js.map +1 -0
  170. package/dist/core/types.d.ts +37 -0
  171. package/dist/core/types.js +32 -0
  172. package/dist/core/types.js.map +1 -0
  173. package/dist/core/wgsl/api.d.ts +65 -0
  174. package/dist/core/wgsl/api.js +546 -0
  175. package/dist/core/wgsl/api.js.map +1 -0
  176. package/dist/core/wgsl/generate.d.ts +90 -0
  177. package/dist/core/wgsl/generate.js +678 -0
  178. package/dist/core/wgsl/generate.js.map +1 -0
  179. package/dist/core/wgsl/lean.d.ts +50 -0
  180. package/dist/core/wgsl/lean.js +327 -0
  181. package/dist/core/wgsl/lean.js.map +1 -0
  182. package/dist/core/wgsl/level-set.d.ts +58 -0
  183. package/dist/core/wgsl/level-set.js +200 -0
  184. package/dist/core/wgsl/level-set.js.map +1 -0
  185. package/dist/core/wgsl/majorant.d.ts +62 -0
  186. package/dist/core/wgsl/majorant.js +381 -0
  187. package/dist/core/wgsl/majorant.js.map +1 -0
  188. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  189. package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
  190. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  191. package/dist/core/wgsl/reserved.d.ts +9 -0
  192. package/dist/core/wgsl/reserved.js +26 -0
  193. package/dist/core/wgsl/reserved.js.map +1 -0
  194. package/dist/core/wgsl/types.d.ts +198 -0
  195. package/dist/core/wgsl/types.js +2 -0
  196. package/dist/core/wgsl/types.js.map +1 -0
  197. package/dist/three/coarse-first.d.ts +207 -0
  198. package/dist/three/coarse-first.js +205 -0
  199. package/dist/three/coarse-first.js.map +1 -0
  200. package/dist/three/compute.d.ts +73 -0
  201. package/dist/three/compute.js +66 -0
  202. package/dist/three/compute.js.map +1 -0
  203. package/dist/three/device.d.ts +66 -0
  204. package/dist/three/device.js +62 -0
  205. package/dist/three/device.js.map +1 -0
  206. package/dist/three/frame/core-environment.d.ts +38 -0
  207. package/dist/three/frame/core-environment.js +154 -0
  208. package/dist/three/frame/core-environment.js.map +1 -0
  209. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  210. package/dist/three/frame/core-integrate-material.js +162 -0
  211. package/dist/three/frame/core-integrate-material.js.map +1 -0
  212. package/dist/three/frame/core-occluders.d.ts +53 -0
  213. package/dist/three/frame/core-occluders.js +193 -0
  214. package/dist/three/frame/core-occluders.js.map +1 -0
  215. package/dist/three/frame/core-structs.d.ts +34 -0
  216. package/dist/three/frame/core-structs.js +61 -0
  217. package/dist/three/frame/core-structs.js.map +1 -0
  218. package/dist/three/frame/core-textures.d.ts +41 -0
  219. package/dist/three/frame/core-textures.js +114 -0
  220. package/dist/three/frame/core-textures.js.map +1 -0
  221. package/dist/three/frame/emission-light.d.ts +117 -0
  222. package/dist/three/frame/emission-light.js +276 -0
  223. package/dist/three/frame/emission-light.js.map +1 -0
  224. package/dist/three/frame/index.d.ts +19 -0
  225. package/dist/three/frame/index.js +15 -0
  226. package/dist/three/frame/index.js.map +1 -0
  227. package/dist/three/frame/medium.d.ts +33 -0
  228. package/dist/three/frame/medium.js +29 -0
  229. package/dist/three/frame/medium.js.map +1 -0
  230. package/dist/three/frame/renderer.d.ts +97 -0
  231. package/dist/three/frame/renderer.js +480 -0
  232. package/dist/three/frame/renderer.js.map +1 -0
  233. package/dist/three/frame/spectrum.d.ts +4 -0
  234. package/dist/three/frame/spectrum.js +15 -0
  235. package/dist/three/frame/spectrum.js.map +1 -0
  236. package/dist/three/frame/three-internals.d.ts +60 -0
  237. package/dist/three/frame/three-internals.js +152 -0
  238. package/dist/three/frame/three-internals.js.map +1 -0
  239. package/dist/three/frame/volume-shadows.d.ts +139 -0
  240. package/dist/three/frame/volume-shadows.js +403 -0
  241. package/dist/three/frame/volume-shadows.js.map +1 -0
  242. package/dist/three/frame/volume.d.ts +230 -0
  243. package/dist/three/frame/volume.js +268 -0
  244. package/dist/three/frame/volume.js.map +1 -0
  245. package/dist/three/grid-node.d.ts +229 -0
  246. package/dist/three/grid-node.js +545 -0
  247. package/dist/three/grid-node.js.map +1 -0
  248. package/dist/three/index.d.ts +52 -0
  249. package/dist/three/index.js +58 -0
  250. package/dist/three/index.js.map +1 -0
  251. package/dist/three/internal.d.ts +20 -0
  252. package/dist/three/internal.js +18 -0
  253. package/dist/three/internal.js.map +1 -0
  254. package/dist/three/level-set-material.d.ts +185 -0
  255. package/dist/three/level-set-material.js +241 -0
  256. package/dist/three/level-set-material.js.map +1 -0
  257. package/dist/three/level-set-physical-material.d.ts +154 -0
  258. package/dist/three/level-set-physical-material.js +253 -0
  259. package/dist/three/level-set-physical-material.js.map +1 -0
  260. package/dist/three/level-set-velocity.d.ts +94 -0
  261. package/dist/three/level-set-velocity.js +208 -0
  262. package/dist/three/level-set-velocity.js.map +1 -0
  263. package/dist/three/material.d.ts +324 -0
  264. package/dist/three/material.js +502 -0
  265. package/dist/three/material.js.map +1 -0
  266. package/dist/three/points.d.ts +140 -0
  267. package/dist/three/points.js +261 -0
  268. package/dist/three/points.js.map +1 -0
  269. package/dist/three/sparse-source.d.ts +165 -0
  270. package/dist/three/sparse-source.js +405 -0
  271. package/dist/three/sparse-source.js.map +1 -0
  272. package/dist/three/volume-source.d.ts +22 -0
  273. package/dist/three/volume-source.js +110 -0
  274. package/dist/three/volume-source.js.map +1 -0
  275. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  276. package/dist/tools/cpu/brick-atlas.js +129 -0
  277. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  278. package/dist/tools/cpu/compute.d.ts +116 -0
  279. package/dist/tools/cpu/compute.js +239 -0
  280. package/dist/tools/cpu/compute.js.map +1 -0
  281. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  282. package/dist/tools/cpu/lean-reads.js +262 -0
  283. package/dist/tools/cpu/lean-reads.js.map +1 -0
  284. package/dist/tools/cpu/level-set.d.ts +111 -0
  285. package/dist/tools/cpu/level-set.js +313 -0
  286. package/dist/tools/cpu/level-set.js.map +1 -0
  287. package/dist/tools/cpu/majorant.d.ts +265 -0
  288. package/dist/tools/cpu/majorant.js +541 -0
  289. package/dist/tools/cpu/majorant.js.map +1 -0
  290. package/dist/tools/cpu/march.d.ts +297 -0
  291. package/dist/tools/cpu/march.js +726 -0
  292. package/dist/tools/cpu/march.js.map +1 -0
  293. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  294. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  295. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  296. package/dist/tools/cpu/points.d.ts +29 -0
  297. package/dist/tools/cpu/points.js +38 -0
  298. package/dist/tools/cpu/points.js.map +1 -0
  299. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  300. package/dist/tools/cpu/probe-coords.js +116 -0
  301. package/dist/tools/cpu/probe-coords.js.map +1 -0
  302. package/dist/tools/cpu/read-value.d.ts +44 -0
  303. package/dist/tools/cpu/read-value.js +351 -0
  304. package/dist/tools/cpu/read-value.js.map +1 -0
  305. package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
  306. package/dist/tools/cpu/sample-trilinear.js +168 -0
  307. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  308. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  309. package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
  310. package/dist/tools/cpu/stride-tables.generated.js +1267 -0
  311. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  312. package/dist/tools/cpu/stride-tables.js +78 -0
  313. package/dist/tools/cpu/stride-tables.js.map +1 -0
  314. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  315. package/dist/tools/cpu/surface-nets.js +597 -0
  316. package/dist/tools/cpu/surface-nets.js.map +1 -0
  317. package/dist/tools/errors.d.ts +66 -0
  318. package/dist/tools/errors.js +67 -0
  319. package/dist/tools/errors.js.map +1 -0
  320. package/dist/tools/frame/ambient.d.ts +98 -0
  321. package/dist/tools/frame/ambient.js +274 -0
  322. package/dist/tools/frame/ambient.js.map +1 -0
  323. package/dist/tools/frame/blackbody.d.ts +57 -0
  324. package/dist/tools/frame/blackbody.js +151 -0
  325. package/dist/tools/frame/blackbody.js.map +1 -0
  326. package/dist/tools/frame/brick-cache.d.ts +165 -0
  327. package/dist/tools/frame/brick-cache.js +326 -0
  328. package/dist/tools/frame/brick-cache.js.map +1 -0
  329. package/dist/tools/frame/emission.d.ts +137 -0
  330. package/dist/tools/frame/emission.js +290 -0
  331. package/dist/tools/frame/emission.js.map +1 -0
  332. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  333. package/dist/tools/frame/environment-gpu.js +280 -0
  334. package/dist/tools/frame/environment-gpu.js.map +1 -0
  335. package/dist/tools/frame/environment.d.ts +106 -0
  336. package/dist/tools/frame/environment.js +272 -0
  337. package/dist/tools/frame/environment.js.map +1 -0
  338. package/dist/tools/frame/froxel.d.ts +58 -0
  339. package/dist/tools/frame/froxel.js +115 -0
  340. package/dist/tools/frame/froxel.js.map +1 -0
  341. package/dist/tools/frame/grid.d.ts +392 -0
  342. package/dist/tools/frame/grid.js +802 -0
  343. package/dist/tools/frame/grid.js.map +1 -0
  344. package/dist/tools/frame/index.d.ts +150 -0
  345. package/dist/tools/frame/index.js +389 -0
  346. package/dist/tools/frame/index.js.map +1 -0
  347. package/dist/tools/frame/medium.d.ts +77 -0
  348. package/dist/tools/frame/medium.js +101 -0
  349. package/dist/tools/frame/medium.js.map +1 -0
  350. package/dist/tools/frame/mie-table.d.ts +6 -0
  351. package/dist/tools/frame/mie-table.js +16 -0
  352. package/dist/tools/frame/mie-table.js.map +1 -0
  353. package/dist/tools/frame/mie.d.ts +63 -0
  354. package/dist/tools/frame/mie.js +194 -0
  355. package/dist/tools/frame/mie.js.map +1 -0
  356. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  357. package/dist/tools/frame/mlp-nn.js +159 -0
  358. package/dist/tools/frame/mlp-nn.js.map +1 -0
  359. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  360. package/dist/tools/frame/mlp-tza.js +186 -0
  361. package/dist/tools/frame/mlp-tza.js.map +1 -0
  362. package/dist/tools/frame/mlp.d.ts +183 -0
  363. package/dist/tools/frame/mlp.js +434 -0
  364. package/dist/tools/frame/mlp.js.map +1 -0
  365. package/dist/tools/frame/ms-exit.d.ts +42 -0
  366. package/dist/tools/frame/ms-exit.js +90 -0
  367. package/dist/tools/frame/ms-exit.js.map +1 -0
  368. package/dist/tools/frame/multi-scale.d.ts +152 -0
  369. package/dist/tools/frame/multi-scale.js +302 -0
  370. package/dist/tools/frame/multi-scale.js.map +1 -0
  371. package/dist/tools/frame/neural-weights.d.ts +10 -0
  372. package/dist/tools/frame/neural-weights.js +244 -0
  373. package/dist/tools/frame/neural-weights.js.map +1 -0
  374. package/dist/tools/frame/neural.d.ts +80 -0
  375. package/dist/tools/frame/neural.js +150 -0
  376. package/dist/tools/frame/neural.js.map +1 -0
  377. package/dist/tools/frame/occluders.d.ts +51 -0
  378. package/dist/tools/frame/occluders.js +72 -0
  379. package/dist/tools/frame/occluders.js.map +1 -0
  380. package/dist/tools/frame/pyramid-layout.d.ts +55 -0
  381. package/dist/tools/frame/pyramid-layout.js +100 -0
  382. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  383. package/dist/tools/frame/shadows.d.ts +190 -0
  384. package/dist/tools/frame/shadows.js +468 -0
  385. package/dist/tools/frame/shadows.js.map +1 -0
  386. package/dist/tools/frame/sparse.d.ts +147 -0
  387. package/dist/tools/frame/sparse.js +432 -0
  388. package/dist/tools/frame/sparse.js.map +1 -0
  389. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  390. package/dist/tools/frame/spectral-stack.js +391 -0
  391. package/dist/tools/frame/spectral-stack.js.map +1 -0
  392. package/dist/tools/frame/spectral.d.ts +222 -0
  393. package/dist/tools/frame/spectral.js +572 -0
  394. package/dist/tools/frame/spectral.js.map +1 -0
  395. package/dist/tools/frame/stack.d.ts +115 -0
  396. package/dist/tools/frame/stack.js +290 -0
  397. package/dist/tools/frame/stack.js.map +1 -0
  398. package/dist/tools/frame/view.d.ts +131 -0
  399. package/dist/tools/frame/view.js +337 -0
  400. package/dist/tools/frame/view.js.map +1 -0
  401. package/dist/tools/index.d.ts +157 -0
  402. package/dist/tools/index.js +132 -0
  403. package/dist/tools/index.js.map +1 -0
  404. package/dist/tools/internal.d.ts +87 -0
  405. package/dist/tools/internal.js +85 -0
  406. package/dist/tools/internal.js.map +1 -0
  407. package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
  408. package/dist/tools/nanovdb/build-from-vdb.js +100 -0
  409. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  410. package/dist/tools/nanovdb/bytes.d.ts +233 -0
  411. package/dist/tools/nanovdb/bytes.js +388 -0
  412. package/dist/tools/nanovdb/bytes.js.map +1 -0
  413. package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
  414. package/dist/tools/nanovdb/coarse-first.js +92 -0
  415. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  416. package/dist/tools/nanovdb/half.d.ts +22 -0
  417. package/dist/tools/nanovdb/half.js +73 -0
  418. package/dist/tools/nanovdb/half.js.map +1 -0
  419. package/dist/tools/nanovdb/index.d.ts +34 -0
  420. package/dist/tools/nanovdb/index.js +25 -0
  421. package/dist/tools/nanovdb/index.js.map +1 -0
  422. package/dist/tools/nanovdb/inspect.d.ts +33 -0
  423. package/dist/tools/nanovdb/inspect.js +70 -0
  424. package/dist/tools/nanovdb/inspect.js.map +1 -0
  425. package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
  426. package/dist/tools/nanovdb/leaf-codec.js +356 -0
  427. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  428. package/dist/tools/nanovdb/quantize.d.ts +72 -0
  429. package/dist/tools/nanovdb/quantize.js +329 -0
  430. package/dist/tools/nanovdb/quantize.js.map +1 -0
  431. package/dist/tools/nanovdb/resample.d.ts +177 -0
  432. package/dist/tools/nanovdb/resample.js +692 -0
  433. package/dist/tools/nanovdb/resample.js.map +1 -0
  434. package/dist/tools/nanovdb/serialize.d.ts +176 -0
  435. package/dist/tools/nanovdb/serialize.js +439 -0
  436. package/dist/tools/nanovdb/serialize.js.map +1 -0
  437. package/dist/tools/nanovdb/stats.d.ts +87 -0
  438. package/dist/tools/nanovdb/stats.js +225 -0
  439. package/dist/tools/nanovdb/stats.js.map +1 -0
  440. package/dist/tools/nanovdb/transform.d.ts +30 -0
  441. package/dist/tools/nanovdb/transform.js +94 -0
  442. package/dist/tools/nanovdb/transform.js.map +1 -0
  443. package/dist/tools/nanovdb/tree.d.ts +186 -0
  444. package/dist/tools/nanovdb/tree.js +530 -0
  445. package/dist/tools/nanovdb/tree.js.map +1 -0
  446. package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
  447. package/dist/tools/nanovdb/write-nvdb.js +290 -0
  448. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  449. package/dist/tools/nvdb-file.d.ts +265 -0
  450. package/dist/tools/nvdb-file.js +763 -0
  451. package/dist/tools/nvdb-file.js.map +1 -0
  452. package/dist/tools/nvdb-stream.d.ts +154 -0
  453. package/dist/tools/nvdb-stream.js +409 -0
  454. package/dist/tools/nvdb-stream.js.map +1 -0
  455. package/dist/tools/reference/analytic.d.ts +41 -0
  456. package/dist/tools/reference/analytic.js +95 -0
  457. package/dist/tools/reference/analytic.js.map +1 -0
  458. package/dist/tools/reference/environment.d.ts +62 -0
  459. package/dist/tools/reference/environment.js +154 -0
  460. package/dist/tools/reference/environment.js.map +1 -0
  461. package/dist/tools/reference/index.d.ts +12 -0
  462. package/dist/tools/reference/index.js +13 -0
  463. package/dist/tools/reference/index.js.map +1 -0
  464. package/dist/tools/reference/media.d.ts +14 -0
  465. package/dist/tools/reference/media.js +30 -0
  466. package/dist/tools/reference/media.js.map +1 -0
  467. package/dist/tools/reference/rng.d.ts +20 -0
  468. package/dist/tools/reference/rng.js +30 -0
  469. package/dist/tools/reference/rng.js.map +1 -0
  470. package/dist/tools/reference/scene.d.ts +312 -0
  471. package/dist/tools/reference/scene.js +169 -0
  472. package/dist/tools/reference/scene.js.map +1 -0
  473. package/dist/tools/reference/tables.d.ts +98 -0
  474. package/dist/tools/reference/tables.js +264 -0
  475. package/dist/tools/reference/tables.js.map +1 -0
  476. package/dist/tools/reference/trace.d.ts +160 -0
  477. package/dist/tools/reference/trace.js +497 -0
  478. package/dist/tools/reference/trace.js.map +1 -0
  479. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  480. package/dist/tools/vdb/bit-utils.js +42 -0
  481. package/dist/tools/vdb/bit-utils.js.map +1 -0
  482. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  483. package/dist/tools/vdb/blosc-write.js +197 -0
  484. package/dist/tools/vdb/blosc-write.js.map +1 -0
  485. package/dist/tools/vdb/blosc.d.ts +86 -0
  486. package/dist/tools/vdb/blosc.js +287 -0
  487. package/dist/tools/vdb/blosc.js.map +1 -0
  488. package/dist/tools/vdb/blosclz.d.ts +33 -0
  489. package/dist/tools/vdb/blosclz.js +112 -0
  490. package/dist/tools/vdb/blosclz.js.map +1 -0
  491. package/dist/tools/vdb/byte-reader.d.ts +50 -0
  492. package/dist/tools/vdb/byte-reader.js +161 -0
  493. package/dist/tools/vdb/byte-reader.js.map +1 -0
  494. package/dist/tools/vdb/compression.d.ts +81 -0
  495. package/dist/tools/vdb/compression.js +260 -0
  496. package/dist/tools/vdb/compression.js.map +1 -0
  497. package/dist/tools/vdb/errors.d.ts +10 -0
  498. package/dist/tools/vdb/errors.js +11 -0
  499. package/dist/tools/vdb/errors.js.map +1 -0
  500. package/dist/tools/vdb/grid.d.ts +37 -0
  501. package/dist/tools/vdb/grid.js +153 -0
  502. package/dist/tools/vdb/grid.js.map +1 -0
  503. package/dist/tools/vdb/half-float.d.ts +9 -0
  504. package/dist/tools/vdb/half-float.js +24 -0
  505. package/dist/tools/vdb/half-float.js.map +1 -0
  506. package/dist/tools/vdb/index.d.ts +4 -0
  507. package/dist/tools/vdb/index.js +3 -0
  508. package/dist/tools/vdb/index.js.map +1 -0
  509. package/dist/tools/vdb/inflate.d.ts +24 -0
  510. package/dist/tools/vdb/inflate.js +334 -0
  511. package/dist/tools/vdb/inflate.js.map +1 -0
  512. package/dist/tools/vdb/lz4.d.ts +30 -0
  513. package/dist/tools/vdb/lz4.js +228 -0
  514. package/dist/tools/vdb/lz4.js.map +1 -0
  515. package/dist/tools/vdb/metadata.d.ts +17 -0
  516. package/dist/tools/vdb/metadata.js +72 -0
  517. package/dist/tools/vdb/metadata.js.map +1 -0
  518. package/dist/tools/vdb/parse.d.ts +47 -0
  519. package/dist/tools/vdb/parse.js +241 -0
  520. package/dist/tools/vdb/parse.js.map +1 -0
  521. package/dist/tools/vdb/point-render-data.d.ts +79 -0
  522. package/dist/tools/vdb/point-render-data.js +137 -0
  523. package/dist/tools/vdb/point-render-data.js.map +1 -0
  524. package/dist/tools/vdb/points.d.ts +186 -0
  525. package/dist/tools/vdb/points.js +835 -0
  526. package/dist/tools/vdb/points.js.map +1 -0
  527. package/dist/tools/vdb/transform.d.ts +23 -0
  528. package/dist/tools/vdb/transform.js +54 -0
  529. package/dist/tools/vdb/transform.js.map +1 -0
  530. package/dist/tools/vdb/tree.d.ts +111 -0
  531. package/dist/tools/vdb/tree.js +228 -0
  532. package/dist/tools/vdb/tree.js.map +1 -0
  533. package/dist/tools/vdb/types.d.ts +195 -0
  534. package/dist/tools/vdb/types.js +3 -0
  535. package/dist/tools/vdb/types.js.map +1 -0
  536. package/dist/tools/wvdb/bake.d.ts +145 -0
  537. package/dist/tools/wvdb/bake.js +361 -0
  538. package/dist/tools/wvdb/bake.js.map +1 -0
  539. package/dist/tools/wvdb/dense.d.ts +191 -0
  540. package/dist/tools/wvdb/dense.js +368 -0
  541. package/dist/tools/wvdb/dense.js.map +1 -0
  542. package/dist/tools/wvdb/format.d.ts +220 -0
  543. package/dist/tools/wvdb/format.js +306 -0
  544. package/dist/tools/wvdb/format.js.map +1 -0
  545. package/dist/tools/wvdb/index.d.ts +14 -0
  546. package/dist/tools/wvdb/index.js +15 -0
  547. package/dist/tools/wvdb/index.js.map +1 -0
  548. package/dist/tools/wvdb/level-set.d.ts +56 -0
  549. package/dist/tools/wvdb/level-set.js +153 -0
  550. package/dist/tools/wvdb/level-set.js.map +1 -0
  551. package/dist/tools/wvdb/nanovdb.d.ts +59 -0
  552. package/dist/tools/wvdb/nanovdb.js +64 -0
  553. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  554. package/dist/tools/wvdb/partial.d.ts +74 -0
  555. package/dist/tools/wvdb/partial.js +233 -0
  556. package/dist/tools/wvdb/partial.js.map +1 -0
  557. package/dist/tools/wvdb/read.d.ts +336 -0
  558. package/dist/tools/wvdb/read.js +766 -0
  559. package/dist/tools/wvdb/read.js.map +1 -0
  560. package/dist/tools/wvdb/sha256.d.ts +7 -0
  561. package/dist/tools/wvdb/sha256.js +76 -0
  562. package/dist/tools/wvdb/sha256.js.map +1 -0
  563. package/dist/tools/wvdb/write.d.ts +149 -0
  564. package/dist/tools/wvdb/write.js +403 -0
  565. package/dist/tools/wvdb/write.js.map +1 -0
  566. package/package.json +83 -4
  567. package/vendor/LICENSE +201 -0
  568. package/vendor/NOTICE +19 -0
  569. package/vendor/VENDOR.md +100 -0
  570. package/vendor/pnanovdb.wgsl +1577 -0
@@ -0,0 +1,422 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/core/FrameEmissionLight.js L138–287 (emitters, keys, slots, updateProbeGrid,
3
+ // prepareProbes); src/three-openvdb/frame/webgpu/FrameEmissionLight.js L540–658 (targets, updateProbes);
4
+ // src/three-openvdb/frame/core/frameBlackbody.js (the 'planck' / 'soot' table, via tools/frame/blackbody.ts).
5
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
6
+ // Changes: engine-free (K6.5, design §3.8): emission colour as data (LUT rows) plus a validated user WGSL hook; the
7
+ // emitter keys and probe cascades of his light, run by the core renderer on its volume records. Divergences:
8
+ // DIVERGES.md (K6.5 rows).
9
+ /**
10
+ * The CPU half of the core renderer's emission (K6.5):
11
+ *
12
+ * - Colour: each volume's `emissionColor` becomes a record code (white, a row of the LUT texture, or the user hook).
13
+ * Rows are made once per distinct colour (his blackbody table pre-blended to the soot exponent, or the caller's LUT).
14
+ * - Hooks: `vdbEmissionHookProblems` (names, reserved words, back-ticks, bindings) and `vdbValidateEmissionHook`
15
+ * (compiles under a validation scope) give `VDBError('VDB_BAD_WGSL')` naming the line.
16
+ * - Probes: his emitter keys and power-of-two slots, the probe cascades (tools/frame `vdbFrameEmissionProbeGrid`), the
17
+ * emitter list and probe grid uniforms, the direction / emitter / probe textures.
18
+ */
19
+ import { VDBError } from "../errors.js";
20
+ import { WGSL_RESERVED_WORDS } from "../wgsl/reserved.js";
21
+ import { vdbFrameEmissionLutRow, vdbFrameEmissionSpectrum } from "../../tools/frame/blackbody.js";
22
+ import { vdbFrameEmissionProbeGrid, vdbFrameEmitterBounds } from "../../tools/frame/emission.js";
23
+ import { vdbFrameStackLayout } from "../../tools/frame/stack.js";
24
+ import { vdbHashText } from "./pipelines.js";
25
+ import { BUFFER_USAGE, TEXTURE_USAGE } from "./resources.js";
26
+ import { VDBUniformWriter } from "./uniforms.js";
27
+ import { VDB_EMISSION_GRID, VDB_FRAME_EMISSION_DIRECTIONS, VDB_FRAME_EMISSION_LUT_SIZE, VDB_FRAME_EMISSION_MAX_CASCADES, VDB_FRAME_EMITTERS, VDB_FRAME_EMITTERS_STRIDE, VDB_FRAME_MAX_EMITTERS, } from "./wgsl/emission.js";
28
+ // ------------------------------------------------------------------ hooks
29
+ /** The line (1-based) of character `at` in `text`. */
30
+ const lineOf = (text, at) => text.slice(0, at).split("\n").length;
31
+ /**
32
+ * Static checks of a user emission hook (design §3.8): it defines `fn vdbUserEmissionColor(`, every top-level name
33
+ * starts with `vdbUser`, no reserved word is a name, no back-ticks, no bindings, entry points or directives.
34
+ * Returns the first problem with its line, or null.
35
+ */
36
+ export function vdbEmissionHookProblems(wgsl) {
37
+ if (typeof wgsl !== "string" || wgsl.trim() === "")
38
+ return "the hook is empty";
39
+ const tick = wgsl.indexOf("`");
40
+ if (tick >= 0)
41
+ return `line ${lineOf(wgsl, tick)}: back-ticks are not allowed`;
42
+ // strip comments (keep line breaks so lines stay right)
43
+ const code = wgsl.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " ")).replace(/\/\/[^\n]*/g, (m) => " ".repeat(m.length));
44
+ for (const m of code.matchAll(/@(group|binding|compute|vertex|fragment|workgroup_size)\b|\b(enable|requires|diagnostic)\b/g)) {
45
+ return `line ${lineOf(code, m.index)}: '${m[0]}' is not allowed in a hook (no bindings, entry points or directives)`;
46
+ }
47
+ // top-level declarations (brace depth 0) must be vdbUser*
48
+ let depth = 0;
49
+ for (let i = 0; i < code.length; i++) {
50
+ const c = code[i];
51
+ if (c === "{")
52
+ depth++;
53
+ else if (c === "}")
54
+ depth = Math.max(0, depth - 1);
55
+ else if (depth === 0) {
56
+ const m = /^(fn|struct|const|var|alias|override)\b(?:<[^>]*>)?\s+([A-Za-z_]\w*)/.exec(code.slice(i));
57
+ if (m && (i === 0 || /[\s;}]/.test(code[i - 1]))) {
58
+ if (!m[2].startsWith("vdbUser"))
59
+ return `line ${lineOf(code, i)}: top-level name '${m[2]}' must start with vdbUser`;
60
+ i += m[0].length - 1;
61
+ }
62
+ }
63
+ }
64
+ for (const m of code.matchAll(/\b(?:let|var|fn|const|struct|alias)\s*(?:<[^>]*>)?\s+([A-Za-z_]\w*)|\b([A-Za-z_]\w*)\s*:\s*[A-Za-z_]/g)) {
65
+ const name = m[1] ?? m[2];
66
+ if (WGSL_RESERVED_WORDS.has(name))
67
+ return `line ${lineOf(code, m.index)}: '${name}' is a reserved word`;
68
+ }
69
+ if (!/\bfn\s+vdbUserEmissionColor\s*\(/.test(code))
70
+ return "the hook must define fn vdbUserEmissionColor(t: f32, temperature: f32) -> vec3f";
71
+ return null;
72
+ }
73
+ const validations = new WeakMap();
74
+ /**
75
+ * Validates a user emission hook on `device` once (cached per text): {@link vdbEmissionHookProblems}, then
76
+ * `createShaderModule` + `getCompilationInfo` under `pushErrorScope('validation')` with a test entry that calls
77
+ * `vdbUserEmissionColor(0.5, 1000.0)` as a `vec3f`.
78
+ *
79
+ * @throws VDBError `VDB_BAD_WGSL` naming the line (of the hook text).
80
+ */
81
+ export function vdbValidateEmissionHook(device, wgsl) {
82
+ let byText = validations.get(device);
83
+ if (!byText)
84
+ validations.set(device, (byText = new Map()));
85
+ const hit = byText.get(wgsl);
86
+ if (hit)
87
+ return hit;
88
+ const problem = vdbEmissionHookProblems(wgsl);
89
+ const job = problem
90
+ ? Promise.reject(new VDBError("VDB_BAD_WGSL", `emission colour hook: ${problem}.`))
91
+ : (async () => {
92
+ const lines = wgsl.split("\n").length;
93
+ device.pushErrorScope("validation");
94
+ const module = device.createShaderModule({
95
+ label: "vdb frame emission hook check",
96
+ code: `${wgsl}\n@compute @workgroup_size(1, 1, 1)\nfn vdbUserHookCheckCs() {\n let color: vec3f = vdbUserEmissionColor(0.5, 1000.0);\n _ = color;\n}\n`,
97
+ });
98
+ const info = typeof module.getCompilationInfo === "function" ? await module.getCompilationInfo() : { messages: [] };
99
+ const scope = await device.popErrorScope();
100
+ const error = info.messages.find((m) => m.type === "error");
101
+ if (error) {
102
+ const where = error.lineNum > lines ? `the hook's call vdbUserEmissionColor(f32, f32) -> vec3f` : `line ${error.lineNum}`;
103
+ throw new VDBError("VDB_BAD_WGSL", `emission colour hook, ${where}: ${error.message}`);
104
+ }
105
+ if (scope)
106
+ throw new VDBError("VDB_BAD_WGSL", `emission colour hook: ${scope.message}`);
107
+ })();
108
+ job.catch(() => { });
109
+ byText.set(wgsl, job);
110
+ return job;
111
+ }
112
+ /** The emission colour LUT texture (rgba32float, 256 × rows) and the hooks of one renderer. */
113
+ export class VDBFrameEmissionColors {
114
+ /** +1 when `texture` is a new object (rebuild bind groups). */
115
+ version = 0;
116
+ #texture;
117
+ #capacity = 4;
118
+ #rows = new Map();
119
+ #data = [];
120
+ #lutKeys = new WeakMap();
121
+ #dirty = new Set();
122
+ #hooks = new Map();
123
+ #device;
124
+ #label;
125
+ #retire;
126
+ constructor(device, label, retire) {
127
+ this.#device = device;
128
+ this.#label = label;
129
+ this.#retire = retire;
130
+ this.#texture = this.#make(this.#capacity);
131
+ }
132
+ #make(rows) {
133
+ return this.#device.createTexture({
134
+ label: `${this.#label} emission colour LUT`,
135
+ size: [VDB_FRAME_EMISSION_LUT_SIZE, rows],
136
+ format: "rgba32float",
137
+ usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST,
138
+ });
139
+ }
140
+ /** The LUT texture after this update's new rows (uploaded here). */
141
+ texture() {
142
+ if (this.#data.length > this.#capacity) {
143
+ while (this.#capacity < this.#data.length)
144
+ this.#capacity *= 2;
145
+ this.#retire.retire(this.#texture);
146
+ this.#texture = this.#make(this.#capacity);
147
+ this.version++;
148
+ this.#data.forEach((_, i) => this.#dirty.add(i));
149
+ }
150
+ for (const row of this.#dirty) {
151
+ this.#device.queue.writeTexture({ texture: this.#texture, origin: [0, row, 0] }, this.#data[row], { bytesPerRow: VDB_FRAME_EMISSION_LUT_SIZE * 16 }, [VDB_FRAME_EMISSION_LUT_SIZE, 1]);
152
+ }
153
+ this.#dirty.clear();
154
+ return this.#texture;
155
+ }
156
+ #row(key, rgb) {
157
+ let row = this.#rows.get(key);
158
+ if (row === undefined) {
159
+ const values = rgb();
160
+ const rgba = new Float32Array(VDB_FRAME_EMISSION_LUT_SIZE * 4);
161
+ for (let i = 0; i < VDB_FRAME_EMISSION_LUT_SIZE; i++) {
162
+ rgba[i * 4] = values[i * 3];
163
+ rgba[i * 4 + 1] = values[i * 3 + 1];
164
+ rgba[i * 4 + 2] = values[i * 3 + 2];
165
+ rgba[i * 4 + 3] = 1;
166
+ }
167
+ row = this.#data.length;
168
+ this.#data.push(rgba);
169
+ this.#rows.set(key, row);
170
+ this.#dirty.add(row);
171
+ }
172
+ return row;
173
+ }
174
+ /**
175
+ * The record code of a colour (registers a LUT row, starts a hook's validation). A hook still validating draws white
176
+ * this frame (an invalid pipeline would invalidate the host's command buffer); a failed one throws.
177
+ */
178
+ codeOf(color) {
179
+ if (!color || color === "white")
180
+ return { code: 0, hook: null };
181
+ if (typeof color === "object" && "wgsl" in color) {
182
+ const state = this.#hookState(color.wgsl);
183
+ if (state instanceof VDBError)
184
+ throw state;
185
+ return state === "valid" ? { code: 2, hook: color.wgsl } : { code: 0, hook: null };
186
+ }
187
+ if (typeof color === "object" && "spectrum" in color) {
188
+ const [, exponent] = vdbFrameEmissionSpectrum(color.spectrum, color.exponent ?? 1.39);
189
+ return { code: 1 | (this.#row(`spectrum:${exponent}`, () => vdbFrameEmissionLutRow(exponent)) << 2), hook: null };
190
+ }
191
+ if (typeof color === "object" && "lut" in color) {
192
+ const lut = color.lut;
193
+ if (!lut || lut.length !== VDB_FRAME_EMISSION_LUT_SIZE * 3) {
194
+ throw new VDBError("VDB_BAD_OPTION", `emissionColor.lut: pass ${VDB_FRAME_EMISSION_LUT_SIZE} × rgb values (${VDB_FRAME_EMISSION_LUT_SIZE * 3} numbers) over log temperature 500–40,000 K.`);
195
+ }
196
+ // the LUT's content key, once per array object (a LUT is data: callers pass the same array each frame)
197
+ let key = typeof lut === "object" ? this.#lutKeys.get(lut) : undefined;
198
+ if (key === undefined) {
199
+ key = `lut:${vdbHashText(Array.from(lut, (v) => v.toPrecision(9)).join(","))}`;
200
+ this.#lutKeys.set(lut, key);
201
+ }
202
+ return { code: 1 | (this.#row(key, () => lut) << 2), hook: null };
203
+ }
204
+ throw new VDBError("VDB_BAD_OPTION", "emissionColor: pass 'white', { spectrum: 'planck' | 'soot', exponent }, { lut } or { wgsl }.");
205
+ }
206
+ #hookState(text) {
207
+ let state = this.#hooks.get(text);
208
+ if (state === undefined) {
209
+ const problem = vdbEmissionHookProblems(text);
210
+ if (problem)
211
+ throw new VDBError("VDB_BAD_WGSL", `emission colour hook: ${problem}.`);
212
+ this.#hooks.set(text, (state = "pending"));
213
+ vdbValidateEmissionHook(this.#device, text).then(() => this.#hooks.set(text, "valid"), (e) => this.#hooks.set(text, e instanceof VDBError ? e : new VDBError("VDB_BAD_WGSL", `emission colour hook: ${String(e)}`)));
214
+ }
215
+ return state;
216
+ }
217
+ /** Waits for every hook seen so far to validate (`prepare()`); throws the first failure. */
218
+ async settled(colors = []) {
219
+ for (const c of colors)
220
+ if (c && typeof c === "object" && "wgsl" in c)
221
+ this.#hookState(c.wgsl);
222
+ await Promise.all([...this.#hooks.keys()].map((text) => vdbValidateEmissionHook(this.#device, text)));
223
+ }
224
+ dispose() {
225
+ this.#retire.retire(this.#texture);
226
+ }
227
+ }
228
+ /** The emission probes of one renderer (his `FrameEmissionLight`, one per renderer; its `outputs` are `VDBFrameEmissionProbes`). */
229
+ export class VDBFrameEmissionProbeSet {
230
+ /** The renderer's `outputs.emissionProbes` (null until an update with emitters and an emission light). */
231
+ outputs = null;
232
+ /** +1 when a probe texture or buffer is a new object. */
233
+ version = 0;
234
+ #device;
235
+ #label;
236
+ #retire;
237
+ #slotCount = 0;
238
+ #slotKeys = [];
239
+ #probeKey = "";
240
+ #directions = null;
241
+ #emitters = null;
242
+ #probes = null;
243
+ #layout = null;
244
+ #resolution = 0;
245
+ #listBuffer;
246
+ #listWriter = new VDBUniformWriter(VDB_FRAME_EMITTERS_STRIDE);
247
+ #gridBuffer;
248
+ #gridWriter = new VDBUniformWriter(VDB_EMISSION_GRID.size);
249
+ constructor(device, label, retire) {
250
+ this.#device = device;
251
+ this.#label = label;
252
+ this.#retire = retire;
253
+ this.#listBuffer = device.createBuffer({ label: `${label} emitter list`, size: VDB_FRAME_EMITTERS_STRIDE, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });
254
+ // K6.8b: also STORAGE, so an engine that binds uniform data only through storage buffers (`./three`) can bind it as is
255
+ this.#gridBuffer = device.createBuffer({ label: `${label} emission grid`, size: VDB_EMISSION_GRID.size, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST });
256
+ }
257
+ get listBuffer() {
258
+ return this.#listBuffer;
259
+ }
260
+ get gridBuffer() {
261
+ return this.#gridBuffer;
262
+ }
263
+ get directionTexture() {
264
+ return this.#directions;
265
+ }
266
+ get emitterTexture() {
267
+ return this.#emitters;
268
+ }
269
+ get probeTexture() {
270
+ return this.#probes;
271
+ }
272
+ /** Slots of the direction and emitter textures (rows). */
273
+ get slots() {
274
+ return this.#slotCount;
275
+ }
276
+ /**
277
+ * His prepareProbes + updateProbeGrid: the emitters' slots and keys, the probe cascades around the emitters and the
278
+ * camera; writes the emitter list and the grid. Returns null when nothing is drawn this update.
279
+ */
280
+ plan(settings, emitters, cameraPosition, steps) {
281
+ if (!settings) {
282
+ this.#release();
283
+ return null;
284
+ }
285
+ const list = emitters.slice(0, VDB_FRAME_MAX_EMITTERS);
286
+ const count = list.length;
287
+ if (count > this.#slotCount) {
288
+ this.#slotCount = 2 ** Math.ceil(Math.log2(count));
289
+ this.#slotKeys = [];
290
+ this.#retire.retire(this.#directions);
291
+ this.#retire.retire(this.#emitters);
292
+ const make = (width, name) => this.#device.createTexture({ label: `${this.#label} emission ${name}`, size: [width, this.#slotCount], format: "rgba32float", usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_SRC });
293
+ this.#directions = make(2 * VDB_FRAME_EMISSION_DIRECTIONS, "directions");
294
+ this.#emitters = make(2, "emitters");
295
+ this.version++;
296
+ }
297
+ const resolution = Math.min(32, Math.max(2, Math.round(settings.resolution ?? 16)));
298
+ if (!this.#probes || resolution !== this.#resolution) {
299
+ this.#retire.retire(this.#probes);
300
+ this.#resolution = resolution;
301
+ this.#layout = vdbFrameStackLayout(resolution, 3 * VDB_FRAME_EMISSION_MAX_CASCADES, this.#device.limits?.maxTextureDimension3D ?? 2048);
302
+ this.#probes = this.#device.createTexture({
303
+ label: `${this.#label} emission probes`,
304
+ size: this.#layout.size,
305
+ dimension: "3d",
306
+ format: "rgba16float",
307
+ usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_SRC,
308
+ });
309
+ this.#probeKey = "";
310
+ this.version++;
311
+ }
312
+ const changed = [];
313
+ list.forEach((e, i) => {
314
+ if (this.#slotKeys[i] !== e.key) {
315
+ this.#slotKeys[i] = e.key;
316
+ changed.push({ item: e, slot: i });
317
+ }
318
+ });
319
+ const boxes = list.map((e) => vdbFrameEmitterBounds(e.matrixWorld));
320
+ const grid = count > 0
321
+ ? vdbFrameEmissionProbeGrid({ resolution, range: settings.range ?? 3, cascades: settings.cascades ?? 1, distance: settings.distance ?? 512 }, boxes.map((b) => ({ min: b.min, max: b.max })), cameraPosition)
322
+ : null;
323
+ const lastUpdate = { directions: 0, probes: false };
324
+ if (!grid) {
325
+ this.#probeKey = "";
326
+ this.#writeGrid(null, 0);
327
+ this.#publish(null, 0, lastUpdate);
328
+ return null;
329
+ }
330
+ const probeKey = `${count},${grid.key}`;
331
+ if (changed.length === 0 && probeKey === this.#probeKey) {
332
+ this.#publish(grid, count, lastUpdate);
333
+ return null;
334
+ }
335
+ this.#probeKey = probeKey;
336
+ // The emitter list: one segment per source group with changed emitters (a direction pass each, at a dynamic offset)
337
+ const byGroup = new Map();
338
+ for (const c of changed) {
339
+ const list = byGroup.get(c.item.group);
340
+ if (list)
341
+ list.push(c);
342
+ else
343
+ byGroup.set(c.item.group, [c]);
344
+ }
345
+ const segments = Math.max(1, byGroup.size);
346
+ if (this.#listBuffer.size < segments * VDB_FRAME_EMITTERS_STRIDE) {
347
+ this.#retire.retire(this.#listBuffer);
348
+ this.#listBuffer = this.#device.createBuffer({ label: `${this.#label} emitter list`, size: segments * VDB_FRAME_EMITTERS_STRIDE, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });
349
+ this.#listWriter = new VDBUniformWriter(segments * VDB_FRAME_EMITTERS_STRIDE);
350
+ this.version++;
351
+ }
352
+ const groups = new Map();
353
+ const w = this.#listWriter;
354
+ const L = VDB_FRAME_EMITTERS;
355
+ w.clear(0, segments * VDB_FRAME_EMITTERS_STRIDE);
356
+ // segment 0 always holds the slot count (the reduce reads it)
357
+ w.set(L, 0, "header", [0, Math.max(1, Math.round(steps)), this.#slotCount, 0]);
358
+ [...byGroup.entries()].forEach(([group, items], segment) => {
359
+ const base = segment * VDB_FRAME_EMITTERS_STRIDE;
360
+ groups.set(group, { segment, count: items.length });
361
+ w.set(L, base, "header", [items.length, Math.max(1, Math.round(steps)), this.#slotCount, 0]);
362
+ w.set(L, base, "info", items.flatMap(({ item, slot }) => [item.record, slot, 0, 0]));
363
+ w.set(L, base, "sphere", items.flatMap(({ item }) => {
364
+ const bb = boxes[list.indexOf(item)];
365
+ return [...bb.center, bb.radius];
366
+ }));
367
+ });
368
+ this.#device.queue.writeBuffer(this.#listBuffer, 0, w.buffer, 0, segments * VDB_FRAME_EMITTERS_STRIDE);
369
+ this.#writeGrid(grid, count);
370
+ lastUpdate.directions = changed.length;
371
+ lastUpdate.probes = true;
372
+ this.#publish(grid, count, lastUpdate, true);
373
+ return { groups, reduce: changed.length > 0, probes: true };
374
+ }
375
+ #writeGrid(grid, emitters) {
376
+ const w = this.#gridWriter;
377
+ const G = VDB_EMISSION_GRID;
378
+ w.clear(0, G.size);
379
+ if (grid) {
380
+ w.set(G, 0, "gridMin", grid.min.flatMap((m) => [...m, 0]));
381
+ w.set(G, 0, "gridSize", grid.size.flatMap((s) => [...s, 0]));
382
+ w.set(G, 0, "center", [...grid.center, emitters > 0 ? 1 : 0]);
383
+ w.set(G, 0, "info", [grid.count, grid.resolution, emitters, 0]);
384
+ }
385
+ w.set(G, 0, "origin", this.#layout.origins.flatMap((o) => [...o, 0]));
386
+ this.#device.queue.writeBuffer(this.#gridBuffer, 0, w.buffer);
387
+ }
388
+ #publish(grid, emitters, lastUpdate, drawn = false) {
389
+ const layout = this.#layout;
390
+ const prev = this.outputs;
391
+ this.outputs = {
392
+ texture: this.#probes,
393
+ grid: this.#gridBuffer,
394
+ layout: { size: layout.size, origins: layout.origins },
395
+ state: grid
396
+ ? { count: grid.count, resolution: grid.resolution, min: grid.min.map((m) => [...m]), size: grid.size.map((s) => [...s]), center: [...grid.center], emitters }
397
+ : { count: 0, resolution: this.#resolution, min: [], size: [], center: [0, 0, 0], emitters: 0 },
398
+ revision: (prev?.revision ?? 0) + (drawn ? 1 : 0),
399
+ lastUpdate,
400
+ };
401
+ }
402
+ #release() {
403
+ if (!this.outputs && !this.#probes)
404
+ return;
405
+ this.#retire.retire(this.#directions);
406
+ this.#retire.retire(this.#emitters);
407
+ this.#retire.retire(this.#probes);
408
+ this.#directions = this.#emitters = this.#probes = null;
409
+ this.#slotCount = 0;
410
+ this.#slotKeys = [];
411
+ this.#probeKey = "";
412
+ this.#resolution = 0;
413
+ this.outputs = null;
414
+ this.version++;
415
+ }
416
+ dispose() {
417
+ this.#release();
418
+ this.#retire.retire(this.#listBuffer);
419
+ this.#retire.retire(this.#gridBuffer);
420
+ }
421
+ }
422
+ //# sourceMappingURL=emission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emission.js","sourceRoot":"","sources":["../../../src/core/frame/emission.ts"],"names":[],"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–287 (emitters, keys, slots, updateProbeGrid,\n// prepareProbes); src/three-openvdb/frame/webgpu/FrameEmissionLight.js L540–658 (targets, updateProbes);\n// src/three-openvdb/frame/core/frameBlackbody.js (the 'planck' / 'soot' table, via tools/frame/blackbody.ts).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: engine-free (K6.5, design §3.8): emission colour as data (LUT rows) plus a validated user WGSL hook; the\n// emitter keys and probe cascades of his light, run by the core renderer on its volume records. Divergences:\n// DIVERGES.md (K6.5 rows).\n\n/**\n * The CPU half of the core renderer's emission (K6.5):\n *\n * - Colour: each volume's `emissionColor` becomes a record code (white, a row of the LUT texture, or the user hook).\n * Rows are made once per distinct colour (his blackbody table pre-blended to the soot exponent, or the caller's LUT).\n * - Hooks: `vdbEmissionHookProblems` (names, reserved words, back-ticks, bindings) and `vdbValidateEmissionHook`\n * (compiles under a validation scope) give `VDBError('VDB_BAD_WGSL')` naming the line.\n * - Probes: his emitter keys and power-of-two slots, the probe cascades (tools/frame `vdbFrameEmissionProbeGrid`), the\n * emitter list and probe grid uniforms, the direction / emitter / probe textures.\n */\n\nimport { VDBError } from \"../errors.js\";\nimport { WGSL_RESERVED_WORDS } from \"../wgsl/reserved.js\";\nimport { vdbFrameEmissionLutRow, vdbFrameEmissionSpectrum } from \"../../tools/frame/blackbody.js\";\nimport { vdbFrameEmissionProbeGrid, vdbFrameEmitterBounds } from \"../../tools/frame/emission.js\";\nimport { vdbFrameStackLayout, type VDBFrameStackLayout } from \"../../tools/frame/stack.js\";\nimport { vdbHashText } from \"./pipelines.js\";\nimport { BUFFER_USAGE, TEXTURE_USAGE, type VDBRetireQueue } from \"./resources.js\";\nimport type { VDBEmissionColor, VDBFrameEmissionLightSettings, VDBFrameEmissionProbes, VDBFrameVec3 } from \"./types.js\";\nimport { VDBUniformWriter } from \"./uniforms.js\";\nimport {\n VDB_EMISSION_GRID,\n VDB_FRAME_EMISSION_DIRECTIONS,\n VDB_FRAME_EMISSION_LUT_SIZE,\n VDB_FRAME_EMISSION_MAX_CASCADES,\n VDB_FRAME_EMITTERS,\n VDB_FRAME_EMITTERS_STRIDE,\n VDB_FRAME_MAX_EMITTERS,\n} from \"./wgsl/emission.js\";\n\ntype V3 = [number, number, number];\n\n// ------------------------------------------------------------------ hooks\n\n/** The line (1-based) of character `at` in `text`. */\nconst lineOf = (text: string, at: number) => text.slice(0, at).split(\"\\n\").length;\n\n/**\n * Static checks of a user emission hook (design §3.8): it defines `fn vdbUserEmissionColor(`, every top-level name\n * starts with `vdbUser`, no reserved word is a name, no back-ticks, no bindings, entry points or directives.\n * Returns the first problem with its line, or null.\n */\nexport function vdbEmissionHookProblems(wgsl: string): string | null {\n if (typeof wgsl !== \"string\" || wgsl.trim() === \"\") return \"the hook is empty\";\n const tick = wgsl.indexOf(\"`\");\n if (tick >= 0) return `line ${lineOf(wgsl, tick)}: back-ticks are not allowed`;\n // strip comments (keep line breaks so lines stay right)\n const code = wgsl.replace(/\\/\\*[\\s\\S]*?\\*\\//g, (m) => m.replace(/[^\\n]/g, \" \")).replace(/\\/\\/[^\\n]*/g, (m) => \" \".repeat(m.length));\n for (const m of code.matchAll(/@(group|binding|compute|vertex|fragment|workgroup_size)\\b|\\b(enable|requires|diagnostic)\\b/g)) {\n return `line ${lineOf(code, m.index!)}: '${m[0]}' is not allowed in a hook (no bindings, entry points or directives)`;\n }\n // top-level declarations (brace depth 0) must be vdbUser*\n let depth = 0;\n for (let i = 0; i < code.length; i++) {\n const c = code[i]!;\n if (c === \"{\") depth++;\n else if (c === \"}\") depth = Math.max(0, depth - 1);\n else if (depth === 0) {\n const m = /^(fn|struct|const|var|alias|override)\\b(?:<[^>]*>)?\\s+([A-Za-z_]\\w*)/.exec(code.slice(i));\n if (m && (i === 0 || /[\\s;}]/.test(code[i - 1]!))) {\n if (!m[2]!.startsWith(\"vdbUser\")) return `line ${lineOf(code, i)}: top-level name '${m[2]}' must start with vdbUser`;\n i += m[0].length - 1;\n }\n }\n }\n for (const m of code.matchAll(/\\b(?:let|var|fn|const|struct|alias)\\s*(?:<[^>]*>)?\\s+([A-Za-z_]\\w*)|\\b([A-Za-z_]\\w*)\\s*:\\s*[A-Za-z_]/g)) {\n const name = m[1] ?? m[2]!;\n if (WGSL_RESERVED_WORDS.has(name)) return `line ${lineOf(code, m.index!)}: '${name}' is a reserved word`;\n }\n if (!/\\bfn\\s+vdbUserEmissionColor\\s*\\(/.test(code)) return \"the hook must define fn vdbUserEmissionColor(t: f32, temperature: f32) -> vec3f\";\n return null;\n}\n\nconst validations = new WeakMap<GPUDevice, Map<string, Promise<void>>>();\n\n/**\n * Validates a user emission hook on `device` once (cached per text): {@link vdbEmissionHookProblems}, then\n * `createShaderModule` + `getCompilationInfo` under `pushErrorScope('validation')` with a test entry that calls\n * `vdbUserEmissionColor(0.5, 1000.0)` as a `vec3f`.\n *\n * @throws VDBError `VDB_BAD_WGSL` naming the line (of the hook text).\n */\nexport function vdbValidateEmissionHook(device: GPUDevice, wgsl: string): Promise<void> {\n let byText = validations.get(device);\n if (!byText) validations.set(device, (byText = new Map()));\n const hit = byText.get(wgsl);\n if (hit) return hit;\n const problem = vdbEmissionHookProblems(wgsl);\n const job = problem\n ? Promise.reject(new VDBError(\"VDB_BAD_WGSL\", `emission colour hook: ${problem}.`))\n : (async () => {\n const lines = wgsl.split(\"\\n\").length;\n device.pushErrorScope(\"validation\");\n const module = device.createShaderModule({\n label: \"vdb frame emission hook check\",\n code: `${wgsl}\\n@compute @workgroup_size(1, 1, 1)\\nfn vdbUserHookCheckCs() {\\n let color: vec3f = vdbUserEmissionColor(0.5, 1000.0);\\n _ = color;\\n}\\n`,\n });\n const info = typeof module.getCompilationInfo === \"function\" ? await module.getCompilationInfo() : { messages: [] as GPUCompilationMessage[] };\n const scope = await device.popErrorScope();\n const error = info.messages.find((m) => m.type === \"error\");\n if (error) {\n const where = error.lineNum > lines ? `the hook's call vdbUserEmissionColor(f32, f32) -> vec3f` : `line ${error.lineNum}`;\n throw new VDBError(\"VDB_BAD_WGSL\", `emission colour hook, ${where}: ${error.message}`);\n }\n if (scope) throw new VDBError(\"VDB_BAD_WGSL\", `emission colour hook: ${scope.message}`);\n })();\n job.catch(() => {});\n byText.set(wgsl, job);\n return job;\n}\n\n// ------------------------------------------------------------------ colour LUT\n\n/** The colour code of a volume: (mode, row) and the hook text when the mode is the hook. */\nexport interface VDBEmissionColorCode {\n readonly code: number;\n readonly hook: string | null;\n}\n\n/** The emission colour LUT texture (rgba32float, 256 × rows) and the hooks of one renderer. */\nexport class VDBFrameEmissionColors {\n /** +1 when `texture` is a new object (rebuild bind groups). */\n version = 0;\n #texture: GPUTexture;\n #capacity = 4;\n readonly #rows = new Map<string, number>();\n readonly #data: Float32Array<ArrayBuffer>[] = [];\n readonly #lutKeys = new WeakMap<object, string>();\n readonly #dirty = new Set<number>();\n readonly #hooks = new Map<string, \"pending\" | \"valid\" | VDBError>();\n readonly #device: GPUDevice;\n readonly #label: string;\n readonly #retire: VDBRetireQueue;\n\n constructor(device: GPUDevice, label: string, retire: VDBRetireQueue) {\n this.#device = device;\n this.#label = label;\n this.#retire = retire;\n this.#texture = this.#make(this.#capacity);\n }\n\n #make(rows: number): GPUTexture {\n return this.#device.createTexture({\n label: `${this.#label} emission colour LUT`,\n size: [VDB_FRAME_EMISSION_LUT_SIZE, rows],\n format: \"rgba32float\",\n usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST,\n });\n }\n\n /** The LUT texture after this update's new rows (uploaded here). */\n texture(): GPUTexture {\n if (this.#data.length > this.#capacity) {\n while (this.#capacity < this.#data.length) this.#capacity *= 2;\n this.#retire.retire(this.#texture);\n this.#texture = this.#make(this.#capacity);\n this.version++;\n this.#data.forEach((_, i) => this.#dirty.add(i));\n }\n for (const row of this.#dirty) {\n this.#device.queue.writeTexture({ texture: this.#texture, origin: [0, row, 0] }, this.#data[row]!, { bytesPerRow: VDB_FRAME_EMISSION_LUT_SIZE * 16 }, [VDB_FRAME_EMISSION_LUT_SIZE, 1]);\n }\n this.#dirty.clear();\n return this.#texture;\n }\n\n #row(key: string, rgb: () => ArrayLike<number>): number {\n let row = this.#rows.get(key);\n if (row === undefined) {\n const values = rgb();\n const rgba = new Float32Array(VDB_FRAME_EMISSION_LUT_SIZE * 4);\n for (let i = 0; i < VDB_FRAME_EMISSION_LUT_SIZE; i++) {\n rgba[i * 4] = values[i * 3]!;\n rgba[i * 4 + 1] = values[i * 3 + 1]!;\n rgba[i * 4 + 2] = values[i * 3 + 2]!;\n rgba[i * 4 + 3] = 1;\n }\n row = this.#data.length;\n this.#data.push(rgba);\n this.#rows.set(key, row);\n this.#dirty.add(row);\n }\n return row;\n }\n\n /**\n * The record code of a colour (registers a LUT row, starts a hook's validation). A hook still validating draws white\n * this frame (an invalid pipeline would invalidate the host's command buffer); a failed one throws.\n */\n codeOf(color: VDBEmissionColor | undefined): VDBEmissionColorCode {\n if (!color || color === \"white\") return { code: 0, hook: null };\n if (typeof color === \"object\" && \"wgsl\" in color) {\n const state = this.#hookState(color.wgsl);\n if (state instanceof VDBError) throw state;\n return state === \"valid\" ? { code: 2, hook: color.wgsl } : { code: 0, hook: null };\n }\n if (typeof color === \"object\" && \"spectrum\" in color) {\n const [, exponent] = vdbFrameEmissionSpectrum(color.spectrum, color.exponent ?? 1.39);\n return { code: 1 | (this.#row(`spectrum:${exponent}`, () => vdbFrameEmissionLutRow(exponent)) << 2), hook: null };\n }\n if (typeof color === \"object\" && \"lut\" in color) {\n const lut = color.lut;\n if (!lut || lut.length !== VDB_FRAME_EMISSION_LUT_SIZE * 3) {\n throw new VDBError(\"VDB_BAD_OPTION\", `emissionColor.lut: pass ${VDB_FRAME_EMISSION_LUT_SIZE} × rgb values (${VDB_FRAME_EMISSION_LUT_SIZE * 3} numbers) over log temperature 500–40,000 K.`);\n }\n // the LUT's content key, once per array object (a LUT is data: callers pass the same array each frame)\n let key = typeof lut === \"object\" ? this.#lutKeys.get(lut) : undefined;\n if (key === undefined) {\n key = `lut:${vdbHashText(Array.from(lut, (v) => v.toPrecision(9)).join(\",\"))}`;\n this.#lutKeys.set(lut, key);\n }\n return { code: 1 | (this.#row(key, () => lut) << 2), hook: null };\n }\n throw new VDBError(\"VDB_BAD_OPTION\", \"emissionColor: pass 'white', { spectrum: 'planck' | 'soot', exponent }, { lut } or { wgsl }.\");\n }\n\n #hookState(text: string): \"pending\" | \"valid\" | VDBError {\n let state = this.#hooks.get(text);\n if (state === undefined) {\n const problem = vdbEmissionHookProblems(text);\n if (problem) throw new VDBError(\"VDB_BAD_WGSL\", `emission colour hook: ${problem}.`);\n this.#hooks.set(text, (state = \"pending\"));\n vdbValidateEmissionHook(this.#device, text).then(\n () => this.#hooks.set(text, \"valid\"),\n (e: unknown) => this.#hooks.set(text, e instanceof VDBError ? e : new VDBError(\"VDB_BAD_WGSL\", `emission colour hook: ${String(e)}`)),\n );\n }\n return state;\n }\n\n /** Waits for every hook seen so far to validate (`prepare()`); throws the first failure. */\n async settled(colors: readonly (VDBEmissionColor | undefined)[] = []): Promise<void> {\n for (const c of colors) if (c && typeof c === \"object\" && \"wgsl\" in c) this.#hookState(c.wgsl);\n await Promise.all([...this.#hooks.keys()].map((text) => vdbValidateEmissionHook(this.#device, text)));\n }\n\n dispose(): void {\n this.#retire.retire(this.#texture);\n }\n}\n\n// ------------------------------------------------------------------ probes\n\n/** One emitting volume of an update (a volume record with an emission channel that is drawn). */\nexport interface VDBFrameEmitterInput {\n /** The volume record index this update. */\n readonly record: number;\n /** The record's source group index (direction passes run per source group). */\n readonly group: number;\n /** Unit box → world. */\n readonly matrixWorld: ArrayLike<number>;\n /** Changes when the volume's direction pass would draw differently. */\n readonly key: string;\n}\n\n/** The probe work of one update. */\nexport interface VDBFrameEmissionPlan {\n /** Per source group index: its segment of the emitter list and the count of its changed emitters (direction passes). */\n readonly groups: ReadonlyMap<number, { segment: number; count: number }>;\n readonly reduce: boolean;\n readonly probes: boolean;\n}\n\n/** The emission probes of one renderer (his `FrameEmissionLight`, one per renderer; its `outputs` are `VDBFrameEmissionProbes`). */\nexport class VDBFrameEmissionProbeSet {\n /** The renderer's `outputs.emissionProbes` (null until an update with emitters and an emission light). */\n outputs: { -readonly [K in keyof VDBFrameEmissionProbes]: VDBFrameEmissionProbes[K] } | null = null;\n /** +1 when a probe texture or buffer is a new object. */\n version = 0;\n readonly #device: GPUDevice;\n readonly #label: string;\n readonly #retire: VDBRetireQueue;\n #slotCount = 0;\n #slotKeys: string[] = [];\n #probeKey = \"\";\n #directions: GPUTexture | null = null;\n #emitters: GPUTexture | null = null;\n #probes: GPUTexture | null = null;\n #layout: VDBFrameStackLayout | null = null;\n #resolution = 0;\n #listBuffer: GPUBuffer;\n #listWriter = new VDBUniformWriter(VDB_FRAME_EMITTERS_STRIDE);\n readonly #gridBuffer: GPUBuffer;\n readonly #gridWriter = new VDBUniformWriter(VDB_EMISSION_GRID.size);\n\n constructor(device: GPUDevice, label: string, retire: VDBRetireQueue) {\n this.#device = device;\n this.#label = label;\n this.#retire = retire;\n this.#listBuffer = device.createBuffer({ label: `${label} emitter list`, size: VDB_FRAME_EMITTERS_STRIDE, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });\n // K6.8b: also STORAGE, so an engine that binds uniform data only through storage buffers (`./three`) can bind it as is\n this.#gridBuffer = device.createBuffer({ label: `${label} emission grid`, size: VDB_EMISSION_GRID.size, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST });\n }\n\n get listBuffer(): GPUBuffer {\n return this.#listBuffer;\n }\n get gridBuffer(): GPUBuffer {\n return this.#gridBuffer;\n }\n get directionTexture(): GPUTexture | null {\n return this.#directions;\n }\n get emitterTexture(): GPUTexture | null {\n return this.#emitters;\n }\n get probeTexture(): GPUTexture | null {\n return this.#probes;\n }\n /** Slots of the direction and emitter textures (rows). */\n get slots(): number {\n return this.#slotCount;\n }\n\n /**\n * His prepareProbes + updateProbeGrid: the emitters' slots and keys, the probe cascades around the emitters and the\n * camera; writes the emitter list and the grid. Returns null when nothing is drawn this update.\n */\n plan(settings: VDBFrameEmissionLightSettings | null | undefined, emitters: readonly VDBFrameEmitterInput[], cameraPosition: V3, steps: number): VDBFrameEmissionPlan | null {\n if (!settings) {\n this.#release();\n return null;\n }\n const list = emitters.slice(0, VDB_FRAME_MAX_EMITTERS);\n const count = list.length;\n if (count > this.#slotCount) {\n this.#slotCount = 2 ** Math.ceil(Math.log2(count));\n this.#slotKeys = [];\n this.#retire.retire(this.#directions);\n this.#retire.retire(this.#emitters);\n const make = (width: number, name: string) =>\n this.#device.createTexture({ label: `${this.#label} emission ${name}`, size: [width, this.#slotCount], format: \"rgba32float\", usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_SRC });\n this.#directions = make(2 * VDB_FRAME_EMISSION_DIRECTIONS, \"directions\");\n this.#emitters = make(2, \"emitters\");\n this.version++;\n }\n const resolution = Math.min(32, Math.max(2, Math.round(settings.resolution ?? 16)));\n if (!this.#probes || resolution !== this.#resolution) {\n this.#retire.retire(this.#probes);\n this.#resolution = resolution;\n this.#layout = vdbFrameStackLayout(resolution, 3 * VDB_FRAME_EMISSION_MAX_CASCADES, this.#device.limits?.maxTextureDimension3D ?? 2048);\n this.#probes = this.#device.createTexture({\n label: `${this.#label} emission probes`,\n size: this.#layout.size,\n dimension: \"3d\",\n format: \"rgba16float\",\n usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_SRC,\n });\n this.#probeKey = \"\";\n this.version++;\n }\n\n const changed: { item: VDBFrameEmitterInput; slot: number }[] = [];\n list.forEach((e, i) => {\n if (this.#slotKeys[i] !== e.key) {\n this.#slotKeys[i] = e.key;\n changed.push({ item: e, slot: i });\n }\n });\n\n const boxes = list.map((e) => vdbFrameEmitterBounds(e.matrixWorld));\n const grid =\n count > 0\n ? vdbFrameEmissionProbeGrid(\n { resolution, range: settings.range ?? 3, cascades: settings.cascades ?? 1, distance: settings.distance ?? 512 },\n boxes.map((b) => ({ min: b.min, max: b.max })),\n cameraPosition,\n )\n : null;\n const lastUpdate = { directions: 0, probes: false };\n if (!grid) {\n this.#probeKey = \"\";\n this.#writeGrid(null, 0);\n this.#publish(null, 0, lastUpdate);\n return null;\n }\n const probeKey = `${count},${grid.key}`;\n if (changed.length === 0 && probeKey === this.#probeKey) {\n this.#publish(grid, count, lastUpdate);\n return null;\n }\n this.#probeKey = probeKey;\n\n // The emitter list: one segment per source group with changed emitters (a direction pass each, at a dynamic offset)\n const byGroup = new Map<number, { item: VDBFrameEmitterInput; slot: number }[]>();\n for (const c of changed) {\n const list = byGroup.get(c.item.group);\n if (list) list.push(c);\n else byGroup.set(c.item.group, [c]);\n }\n const segments = Math.max(1, byGroup.size);\n if (this.#listBuffer.size < segments * VDB_FRAME_EMITTERS_STRIDE) {\n this.#retire.retire(this.#listBuffer);\n this.#listBuffer = this.#device.createBuffer({ label: `${this.#label} emitter list`, size: segments * VDB_FRAME_EMITTERS_STRIDE, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });\n this.#listWriter = new VDBUniformWriter(segments * VDB_FRAME_EMITTERS_STRIDE);\n this.version++;\n }\n const groups = new Map<number, { segment: number; count: number }>();\n const w = this.#listWriter;\n const L = VDB_FRAME_EMITTERS;\n w.clear(0, segments * VDB_FRAME_EMITTERS_STRIDE);\n // segment 0 always holds the slot count (the reduce reads it)\n w.set(L, 0, \"header\", [0, Math.max(1, Math.round(steps)), this.#slotCount, 0]);\n [...byGroup.entries()].forEach(([group, items], segment) => {\n const base = segment * VDB_FRAME_EMITTERS_STRIDE;\n groups.set(group, { segment, count: items.length });\n w.set(L, base, \"header\", [items.length, Math.max(1, Math.round(steps)), this.#slotCount, 0]);\n w.set(L, base, \"info\", items.flatMap(({ item, slot }) => [item.record, slot, 0, 0]));\n w.set(L, base, \"sphere\", items.flatMap(({ item }) => {\n const bb = boxes[list.indexOf(item)]!;\n return [...bb.center, bb.radius];\n }));\n });\n this.#device.queue.writeBuffer(this.#listBuffer, 0, w.buffer, 0, segments * VDB_FRAME_EMITTERS_STRIDE);\n this.#writeGrid(grid, count);\n lastUpdate.directions = changed.length;\n lastUpdate.probes = true;\n this.#publish(grid, count, lastUpdate, true);\n return { groups, reduce: changed.length > 0, probes: true };\n }\n\n #writeGrid(grid: ReturnType<typeof vdbFrameEmissionProbeGrid> | null, emitters: number): void {\n const w = this.#gridWriter;\n const G = VDB_EMISSION_GRID;\n w.clear(0, G.size);\n if (grid) {\n w.set(G, 0, \"gridMin\", grid.min.flatMap((m) => [...m, 0]));\n w.set(G, 0, \"gridSize\", grid.size.flatMap((s) => [...s, 0]));\n w.set(G, 0, \"center\", [...grid.center, emitters > 0 ? 1 : 0]);\n w.set(G, 0, \"info\", [grid.count, grid.resolution, emitters, 0]);\n }\n w.set(G, 0, \"origin\", this.#layout!.origins.flatMap((o) => [...o, 0]));\n this.#device.queue.writeBuffer(this.#gridBuffer, 0, w.buffer);\n }\n\n #publish(grid: ReturnType<typeof vdbFrameEmissionProbeGrid> | null, emitters: number, lastUpdate: { directions: number; probes: boolean }, drawn = false): void {\n const layout = this.#layout!;\n const prev = this.outputs;\n this.outputs = {\n texture: this.#probes!,\n grid: this.#gridBuffer,\n layout: { size: layout.size, origins: layout.origins },\n state: grid\n ? { count: grid.count, resolution: grid.resolution, min: grid.min.map((m) => [...m] as VDBFrameVec3), size: grid.size.map((s) => [...s] as VDBFrameVec3), center: [...grid.center] as VDBFrameVec3, emitters }\n : { count: 0, resolution: this.#resolution, min: [], size: [], center: [0, 0, 0], emitters: 0 },\n revision: (prev?.revision ?? 0) + (drawn ? 1 : 0),\n lastUpdate,\n };\n }\n\n #release(): void {\n if (!this.outputs && !this.#probes) return;\n this.#retire.retire(this.#directions);\n this.#retire.retire(this.#emitters);\n this.#retire.retire(this.#probes);\n this.#directions = this.#emitters = this.#probes = null;\n this.#slotCount = 0;\n this.#slotKeys = [];\n this.#probeKey = \"\";\n this.#resolution = 0;\n this.outputs = null;\n this.version++;\n }\n\n dispose(): void {\n this.#release();\n this.#retire.retire(this.#listBuffer);\n this.#retire.retire(this.#gridBuffer);\n }\n}\n"]}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The environment input of the core frame renderer (K6.2b, design §2.3, §3.5, Q3): a host equirect or cube
3
+ * `GPUTexture` reduced on the GPU (`envPrefilter`: the 128 × 64 work map and his 64 × 32 map; `envReduce`: lights and
4
+ * SH) into the environment buffer every later kernel binds as a uniform (group 0 binding 3). No CPU readback: the first
5
+ * frame already has its environment lights. Each stage reruns only when its inputs change (texture → work map,
6
+ * rotation → map, settings and intensity → buffer).
7
+ */
8
+ import type { VDBFrameSettings } from "./settings.js";
9
+ import type { VDBFrameEnvironment } from "./types.js";
10
+ /** The environment state an update reads. */
11
+ export interface VDBFrameEnvironmentInfo {
12
+ /** An environment is given this update. */
13
+ readonly present: boolean;
14
+ /** Its lighting mode (settings.environmentLighting). */
15
+ readonly mode: "outward" | "directional" | "spherical-harmonics";
16
+ /** +1 whenever the environment buffer may hold other values (signatures of the grids that read it). */
17
+ readonly version: number;
18
+ }
19
+ /** The projection of a host environment texture (design §2.3: 6 square layers → cube, else equirect). */
20
+ export declare function vdbFrameEnvironmentProjection(env: Pick<VDBFrameEnvironment, "texture" | "projection">): "equirect" | "cube";
21
+ /** @internal The environment buffer, its parameters and maps, and the kernels that fill them. */
22
+ export declare class VDBFrameEnvironmentState implements VDBFrameEnvironmentInfo {
23
+ #private;
24
+ readonly buffer: GPUBuffer;
25
+ present: boolean;
26
+ mode: VDBFrameEnvironmentInfo["mode"];
27
+ version: number;
28
+ /** Kernels recorded so far (tests, harness). */
29
+ readonly runs: {
30
+ prefilter: number;
31
+ blur: number;
32
+ reduce: number;
33
+ };
34
+ constructor(device: GPUDevice, label: string);
35
+ /** The work map and his map (harness probes); null before the first environment. */
36
+ get maps(): {
37
+ work: GPUTexture;
38
+ map: GPUTexture;
39
+ } | null;
40
+ /** Reads this update's environment and settings; decides which kernels {@link record} runs. */
41
+ prepare(env: VDBFrameEnvironment | null | undefined, s: Pick<VDBFrameSettings, "environmentLighting" | "environmentSamples" | "environmentShOrder" | "multipleScattering">): void;
42
+ /** Records the kernels {@link prepare} asked for into `pass` (before the kernels that read the buffer). */
43
+ record(pass: GPUComputePassEncoder): void;
44
+ /** Builds the environment pipelines (`prepare()`). */
45
+ specs(projections: readonly ("equirect" | "cube")[]): import("./pipelines.js").VDBComputeSpec[];
46
+ dispose(): void;
47
+ }