@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 @@
1
+ {"version":3,"file":"wgsl.js","sourceRoot":"","sources":["../../../src/core/reference/wgsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,yHAAyH;AACzH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;IACnD,aAAa,EAAE,CAAC;IAChB,iBAAiB,EAAE,EAAE;IACrB,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,UAAU,EAAE,GAAG;IACf,OAAO,EAAE,GAAG;IACZ,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,GAAG;IACf,SAAS,EAAE,GAAG;IACd,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,GAAG;IACf,WAAW,EAAE,GAAG;IAChB,EAAE,EAAE,GAAG;IACP,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,oBAAoB;AACpB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,uDAAuD;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,qHAAqH;AACrH,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAwD,MAAM,CAAC,MAAM,CAAC;IACxG,cAAc,EAAE,CAAC,qCAAqC,EAAE,2CAA2C,CAAC;IACpG,cAAc,EAAE,CAAC,8BAA8B,EAAE,eAAe,CAAC;IACjE,YAAY,EAAE,CAAC,0DAA0D,EAAE,uCAAuC,CAAC;IACnH,mBAAmB,EAAE,CAAC,uCAAuC,EAAE,2BAA2B,CAAC;IAC3F,iBAAiB,EAAE,CAAC,wBAAwB,EAAE,iCAAiC,CAAC;IAChF,cAAc,EAAE,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;IAC3D,QAAQ;IACR,eAAe,EAAE,CAAC,uBAAuB,EAAE,4CAA4C,CAAC;IACxF,oBAAoB,EAAE,CAAC,iFAAiF,EAAE,iFAAiF,CAAC;IAC5L,OAAO,EAAE,CAAC,kCAAkC,EAAE,+DAA+D,CAAC;IAC9G,4GAA4G;IAC5G,SAAS,EAAE,CAAC,wCAAwC,EAAE,4CAA4C,CAAC;IACnG,YAAY,EAAE,CAAC,iDAAiD,EAAE,UAAU,CAAC;IAC7E,wGAAwG;IACxG,iBAAiB,EAAE,CAAC,yCAAyC,EAAE,0CAA0C,CAAC;CAC3G,CAAC,CAAC;AAEH,wEAAwE;AACxE,MAAM,UAAU,sBAAsB,CAAC,CAA6H;IAClK,6GAA6G;IAC7G,MAAM,OAAO,GAAG,CAAC,CAAC,UAAU;QAC1B,CAAC,CAAC;;;oGAG8F;QAChG,CAAC,CAAC,mEAAmE,CAAC;IACxE,OAAO,UAAU,CAAC;;;iCAGa,CAAC,CAAC,QAAQ;gCACX,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA8CvB,CAAC,CAAC,cAAc;iCACZ,CAAC,CAAC,UAAU;+BACd,CAAC,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmNtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAwCc,CAAC,CAAC,UAAU;yBACZ,CAAC,CAAC,UAAU;yBACZ,CAAC,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAwCX,CAAC,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA0Kb,eAAe;;;;;;;;;;yBAUf,qBAAqB;;;;;;;;;;;yBAWrB,uBAAuB;;;;;;;;;;yBAUvB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAyCjB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEAqDY,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EpF,CAAC;AACF,CAAC","sourcesContent":["/**\n * K6.R: the reference renderer's compute kernel (`vdbRefTraceCs`) and its uniform layout. The algorithm, the random\n * stream and the draw order are those of the CPU twin (`tools/reference/trace.ts`), which documents them; this file\n * is that code in WGSL. One VDB source at group 2 (`vdbSrc*`, the K6 group-2 contract), so the kernel binds at most\n * the pool's one storage buffer (D10); the accumulation lives in rgba32float textures (group 1).\n *\n * Compile-time care (the K3.7 trap: inlined sample sites cost SwiftShader minutes): the path is a state machine whose\n * every ray query (primary transmittance, path segment, light visibility) goes through ONE call of `vdbRefTrack`, and\n * the source is read at one call site per channel.\n *\n * Group 0: `vdbRefU` (VdbRefUniforms), `vdbRefBatch` (dynamic offset, 256 B stride). Group 1: accumulation in\n * (sum, sum of squares; sampled, unfilterable), out (storage, write), the equirect environment map, and (K6.R1) the\n * table texture (one row per phase table: RGB + CDF; per emission colour table: RGB) and the majorant atlas (r32float\n * 3D: each volume's grid stacked along z). K6.R2: binding 7, the equirect map's sampling table (r32float; layout in\n * `tools/reference/environment.ts`), read when `flags` has `VDB_REF_FLAG_ENV_MIS`.\n */\n\n/** Uniform layout (bytes) of `VdbRefUniforms`; the packer is `core/reference/renderer.ts` `vdbReferencePackUniforms`. */\nexport const VDB_REF_UNIFORM_OFFSETS = Object.freeze({\n cameraToWorld: 0,\n projectionInverse: 64,\n size: 128,\n seed: 136,\n spp: 140,\n maxBounces: 144,\n rrStart: 148,\n volumeCount: 152,\n lightCount: 156,\n hemiCount: 160,\n flags: 164,\n envSize: 168,\n uniformEnv: 176,\n envRotation: 192,\n sh: 240,\n hemis: 384,\n volumes: 576,\n lights: 2112,\n size_: 3136,\n});\nexport const VDB_REF_HEMI_BYTES = 48;\nexport const VDB_REF_VOLUME_BYTES = 192;\nexport const VDB_REF_LIGHT_BYTES = 64;\n/** `flags` bits. */\nexport const VDB_REF_FLAG_BOX_FILTER = 1;\nexport const VDB_REF_FLAG_ORTHOGRAPHIC = 2;\nexport const VDB_REF_FLAG_EQUIRECT = 4;\n/** K6.R1: the environment has a light probe (`sh`). */\nexport const VDB_REF_FLAG_SH = 8;\n/** K6.R2: next-event estimation of the equirect map with MIS (`environmentSampling: 'mis'` and a map with light). */\nexport const VDB_REF_FLAG_ENV_MIS = 16;\n/** Stride of the per-dispatch batch records (dynamic uniform offsets: 256-byte aligned). */\nexport const VDB_REF_BATCH_STRIDE = 256;\n\n/**\n * The fail-before mutations (`?mutate=`): WGSL text patches, one per name, matching the CPU twin's\n * `VDBReferenceMutation`s. Each must make an analytic check fail.\n */\nexport const VDB_REFERENCE_MUTATIONS: Readonly<Record<string, readonly [string, string]>> = Object.freeze({\n \"ratio-weight\": [\"trans = trans * (1.0 - sum / sbar);\", \"trans = trans * (1.0 - 0.9 * sum / sbar);\"],\n \"delta-accept\": [\"let u = vdbRefRand() * sbar;\", \"let u = -1.0;\"],\n \"phase-norm\": [\"return (1.0 - g * g) / (4.0 * VDB_REF_PI * d * sqrt(d));\", \"return (1.0 - g * g) / (d * sqrt(d));\"],\n \"nee-transmittance\": [\"rad = rad + beta * neeLi * hit.trans;\", \"rad = rad + beta * neeLi;\"],\n \"emission-albedo\": [\"rad = rad + beta * le;\", \"rad = rad + beta * le * albedo;\"],\n \"escape-depth\": [\"if (depth > 0u) {\", \"if (depth == 1u) {\"],\n // K6.R1\n \"majorant-cell\": [\"let cellIndex = cell;\", \"let cellIndex = vec3u(cell.x, cell.y, 0u);\"],\n \"phase-table-weight\": [\"return VdbRefPhaseSample(cos(theta), vdbRefTableAt(row, size, u).xyz * s, pdf);\", \"return VdbRefPhaseSample(cos(theta), vdbRefTableAt(row, size, u).yyy * s, pdf);\"],\n falloff: [\"let mode = u32(l.extra.x + 0.5);\", \"let mode = select(u32(l.extra.x + 0.5), 0u, l.extra.x > 1.5);\"],\n // K6.R2: the map's density without each texel's own solid angle; the escape gathering the map with weight 1\n \"env-pdf\": [\"let omega = vdbRefEnvTable(y, h + 4u);\", \"let omega = 4.0 * VDB_REF_PI / f32(w * h);\"],\n \"mis-weight\": [\"w = vdbRefMisWeight(phasePdf, vdbRefEnvPdf(d));\", \"w = 1.0;\"],\n // Issue #2 (stochastic kernel on a sparse source): the upper voxel with probability 1 - frac, not frac.\n \"stochastic-pick\": [\"select(vec3i(0), vec3i(1), xi < p - b);\", \"select(vec3i(0), vec3i(1), xi >= p - b);\"],\n});\n\n/** The kernel's WGSL after the source's (`vdbSrc*`) and module text. */\nexport function vdbReferenceKernelWgsl(o: { maxVolumes: number; maxLights: number; maxHemispheres: number; maxSteps: number; ratioRr: number; stochastic?: boolean }): string {\n // Issue #2: the stochastic density draws xi (x, y, z, in that order) from the shared stream before the read.\n const density = o.stochastic\n ? `let xi0 = vdbRefRand();\n let xi1 = vdbRefRand();\n let xi2 = vdbRefRand();\n let value = vdbSrcDensityStochastic(v, uvw, 0.0, vec3f(xi0, xi1, xi2)) * vdbSrcMask(v, uvw, 0.0);`\n : \"let value = vdbSrcDensity(v, uvw, 0.0) * vdbSrcMask(v, uvw, 0.0);\";\n return /* wgsl */ `\n// ---- K6.R reference renderer (core/reference/wgsl.ts): brute-force volumetric path tracing -------------------\nconst VDB_REF_PI: f32 = 3.14159265358979;\nconst VDB_REF_MAX_STEPS: u32 = ${o.maxSteps}u;\nconst VDB_REF_RATIO_RR: f32 = ${o.ratioRr.toFixed(6)};\nconst VDB_REF_FAR: f32 = 1e30;\n\nstruct VdbRefHemi {\n sky: vec4f,\n ground: vec4f,\n up: vec4f,\n}\n\nstruct VdbRefVolume {\n worldToLocal: mat4x4f,\n params: vec4f,\n albedo: vec4f,\n phase: vec4f,\n emission: vec4f,\n temperature: vec4f,\n ids: vec4u,\n grid: vec4u,\n tables: vec4u,\n}\n\nstruct VdbRefLight {\n position: vec4f,\n direction: vec4f,\n color: vec4f,\n extra: vec4f,\n}\n\nstruct VdbRefUniforms {\n cameraToWorld: mat4x4f,\n projectionInverse: mat4x4f,\n size: vec2u,\n seed: u32,\n spp: u32,\n maxBounces: u32,\n rrStart: u32,\n volumeCount: u32,\n lightCount: u32,\n hemiCount: u32,\n flags: u32,\n envSize: vec2u,\n uniformEnv: vec4f,\n envRotation0: vec4f,\n envRotation1: vec4f,\n envRotation2: vec4f,\n sh: array<vec4f, 9>,\n hemis: array<VdbRefHemi, ${o.maxHemispheres}>,\n volumes: array<VdbRefVolume, ${o.maxVolumes}>,\n lights: array<VdbRefLight, ${o.maxLights}>,\n}\n\nstruct VdbRefBatch {\n batch: u32,\n accumulate: u32,\n pad0: u32,\n pad1: u32,\n}\n\n@group(0) @binding(0) var<uniform> vdbRefU: VdbRefUniforms;\n@group(0) @binding(1) var<uniform> vdbRefBatch: VdbRefBatch;\n@group(1) @binding(0) var vdbRefAccumIn0: texture_2d<f32>;\n@group(1) @binding(1) var vdbRefAccumIn1: texture_2d<f32>;\n@group(1) @binding(2) var vdbRefAccumOut0: texture_storage_2d<rgba32float, write>;\n@group(1) @binding(3) var vdbRefAccumOut1: texture_storage_2d<rgba32float, write>;\n@group(1) @binding(4) var vdbRefEnvMap: texture_2d<f32>;\n@group(1) @binding(5) var vdbRefTables: texture_2d<f32>;\n@group(1) @binding(6) var vdbRefMajorants: texture_3d<f32>;\n@group(1) @binding(7) var vdbRefEnvCdf: texture_2d<f32>;\n\n// ---- random stream (tools/reference/rng.ts) ----\nvar<private> vdbRefState: u32;\n\nfn vdbRefPcg(v: u32) -> u32 {\n let s = v * 747796405u + 2891336453u;\n let w = ((s >> ((s >> 28u) + 4u)) ^ s) * 277803737u;\n return (w >> 22u) ^ w;\n}\n\nfn vdbRefSeed(seed: u32, sampleIndex: u32, pixel: u32) {\n vdbRefState = vdbRefPcg(pixel + vdbRefPcg(seed ^ vdbRefPcg(sampleIndex)));\n}\n\nfn vdbRefRand() -> f32 {\n vdbRefState = vdbRefState * 747796405u + 2891336453u;\n let s = vdbRefState;\n let w = ((s >> ((s >> 28u) + 4u)) ^ s) * 277803737u;\n return f32(((w >> 22u) ^ w) >> 8u) * 5.9604644775390625e-8;\n}\n\n// ---- phase (tools/reference/trace.ts vdbRefHenyeyGreenstein, vdbRefPhase, vdbRefSampleHgCos) ----\nfn vdbRefHg(c: f32, g: f32) -> f32 {\n let d = 1.0 + g * g - 2.0 * g * c;\n return (1.0 - g * g) / (4.0 * VDB_REF_PI * d * sqrt(d));\n}\n\n// ---- tables (tools/reference/tables.ts): row r, linear blend at texel u·(size − 1) ----\nfn vdbRefTableAt(row: u32, size: u32, u: f32) -> vec4f {\n let texel = clamp(u, 0.0, 1.0) * f32(size - 1u);\n let i = min(u32(texel), size - 2u);\n let f = texel - f32(i);\n let a = textureLoad(vdbRefTables, vec2u(i, row), 0);\n let b = textureLoad(vdbRefTables, vec2u(i + 1u, row), 0);\n return a + (b - a) * f;\n}\n\n// The phase per steradian per channel: HG / dual-lobe, or the volume's table (vdbRefPhaseTableEval).\nfn vdbRefPhaseEval(c: f32, i: u32) -> vec3f {\n let rec = vdbRefU.volumes[i];\n if (rec.tables.x > 0u) {\n let u = sqrt(acos(clamp(c, -1.0, 1.0)) / VDB_REF_PI);\n return vdbRefTableAt(rec.tables.x - 1u, rec.tables.y, u).xyz / (4.0 * VDB_REF_PI);\n }\n let ph = rec.phase;\n let a = vdbRefHg(c, ph.x);\n if (ph.z > 0.0) {\n return vec3f(a + (vdbRefHg(c, ph.y) - a) * ph.z);\n }\n return vec3f(a);\n}\n\n// Inverse-CDF sample of a phase table (vdbRefPhaseTableSample): cos theta, the per-channel weight and (K6.R2) the\n// density per steradian.\nstruct VdbRefPhaseSample {\n cosTheta: f32,\n weight: vec3f,\n pdf: f32,\n}\n\nfn vdbRefPhaseTableSample(row: u32, size: u32, xi: f32) -> VdbRefPhaseSample {\n var lo = 0u;\n var hi = size - 1u;\n loop {\n if (hi - lo <= 1u) {\n break;\n }\n let mid = (lo + hi) >> 1u;\n if (textureLoad(vdbRefTables, vec2u(mid, row), 0).w <= xi) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n let c0 = textureLoad(vdbRefTables, vec2u(lo, row), 0).w;\n let c1 = textureLoad(vdbRefTables, vec2u(lo + 1u, row), 0).w;\n let f = (xi - c0) / (c1 - c0);\n let u = (f32(lo) + f) / f32(size - 1u);\n let pdfU = (c1 - c0) * f32(size - 1u);\n let theta = VDB_REF_PI * u * u;\n let sinTheta = sin(theta);\n let s = VDB_REF_PI * u * sinTheta / pdfU;\n let pdf = pdfU / max(4.0 * VDB_REF_PI * VDB_REF_PI * u * sinTheta, 1e-30);\n return VdbRefPhaseSample(cos(theta), vdbRefTableAt(row, size, u).xyz * s, pdf);\n}\n\n// K6.R2: the density per steradian of the phase sampling at cos theta (vdbRefPhaseTablePdf; HG / dual-lobe: the phase)\nfn vdbRefPhasePdf(c: f32, i: u32) -> f32 {\n let rec = vdbRefU.volumes[i];\n if (rec.tables.x > 0u) {\n let row = rec.tables.x - 1u;\n let size = rec.tables.y;\n let cc = clamp(c, -1.0, 1.0);\n let u = sqrt(acos(cc) / VDB_REF_PI);\n let j = min(u32(u * f32(size - 1u)), size - 2u);\n let pdfU = (textureLoad(vdbRefTables, vec2u(j + 1u, row), 0).w - textureLoad(vdbRefTables, vec2u(j, row), 0).w) * f32(size - 1u);\n return pdfU / max(4.0 * VDB_REF_PI * VDB_REF_PI * u * sqrt(max(0.0, 1.0 - cc * cc)), 1e-30);\n }\n return vdbRefPhaseEval(c, i).x;\n}\n\n// K6.R2: the power heuristic (beta 2) weight of density p against q, as a ratio of at most 1e15 (no f32 overflow)\nfn vdbRefMisWeight(p: f32, q: f32) -> f32 {\n let r = q / max(max(p, q * 1e-15), 1e-30);\n return 1.0 / (1.0 + r * r);\n}\n\nfn vdbRefSampleHgCos(g: f32, u: f32) -> f32 {\n if (abs(g) < 1e-3) {\n return 1.0 - 2.0 * u;\n }\n let s = (1.0 - g * g) / (1.0 - g + 2.0 * g * u);\n return clamp((1.0 + g * g - s * s) / (2.0 * g), -1.0, 1.0);\n}\n\nfn vdbRefDirectionAround(n: vec3f, cosTheta: f32, u: f32) -> vec3f {\n let sgn = select(-1.0, 1.0, n.z >= 0.0);\n let a = -1.0 / (sgn + n.z);\n let b = n.x * n.y * a;\n let b1 = vec3f(1.0 + sgn * n.x * n.x * a, sgn * b, -sgn * n.x);\n let b2 = vec3f(b, sgn + n.y * n.y * a, -n.y);\n let sinTheta = sqrt(max(0.0, 1.0 - cosTheta * cosTheta));\n let phi = 2.0 * VDB_REF_PI * u;\n return cos(phi) * sinTheta * b1 + sin(phi) * sinTheta * b2 + cosTheta * n;\n}\n\nfn vdbRefSmoothstep(e0: f32, e1: f32, x: f32) -> f32 {\n if (!(e1 > e0)) {\n return select(0.0, 1.0, x >= e0);\n }\n let t = clamp((x - e0) / (e1 - e0), 0.0, 1.0);\n return t * t * (3.0 - 2.0 * t);\n}\n\nfn vdbRefMax3(v: vec3f) -> f32 {\n return max(v.x, max(v.y, v.z));\n}\n\n// ---- geometry (vdbRefVolumeInterval, vdbRefCameraRay) ----\nfn vdbRefInterval(i: u32, o: vec3f, d: vec3f, tMax: f32) -> vec2f {\n let m = vdbRefU.volumes[i].worldToLocal;\n let lo = (m * vec4f(o, 1.0)).xyz;\n let ld = (m * vec4f(d, 0.0)).xyz;\n var t0 = -VDB_REF_FAR;\n var t1 = VDB_REF_FAR;\n if (vdbRefU.volumes[i].params.w > 0.5) {\n let a = dot(ld, ld);\n let b = dot(lo, ld);\n let c = dot(lo, lo) - 0.25;\n let disc = b * b - a * c;\n if (disc <= 0.0 || a <= 0.0) {\n return vec2f(1.0, 0.0);\n }\n let q = sqrt(disc);\n t0 = (-b - q) / a;\n t1 = (-b + q) / a;\n } else {\n for (var k = 0u; k < 3u; k = k + 1u) {\n if (abs(ld[k]) < 1e-12) {\n if (abs(lo[k]) > 0.5) {\n return vec2f(1.0, 0.0);\n }\n } else {\n let ta = (-0.5 - lo[k]) / ld[k];\n let tb = (0.5 - lo[k]) / ld[k];\n t0 = max(t0, min(ta, tb));\n t1 = min(t1, max(ta, tb));\n }\n }\n }\n t0 = max(t0, 0.0);\n t1 = min(t1, tMax);\n if (t0 < t1) {\n return vec2f(t0, t1);\n }\n return vec2f(1.0, 0.0);\n}\n\nfn vdbRefUnproject(ndc: vec3f) -> vec3f {\n let p = vdbRefU.projectionInverse * vec4f(ndc, 1.0);\n return p.xyz / p.w;\n}\n\n// ---- the medium (the renderer's sampleExtinction / sampleAlbedo / sampleEmission at level 0) ----\nfn vdbRefUvw(i: u32, x: vec3f) -> vec3f {\n return (vdbRefU.volumes[i].worldToLocal * vec4f(x, 1.0)).xyz + vec3f(0.5);\n}\n\nfn vdbRefSigma(i: u32, x: vec3f) -> f32 {\n let uvw = vdbRefUvw(i, x);\n let v = vdbRefU.volumes[i].ids.x;\n ${density}\n let p = vdbRefU.volumes[i].params;\n return select(0.0, value, value > p.z) * p.x;\n}\n\n// ---- majorant grids (vdbRefMajorantCell): the cell at t of the ray lo + t*ld (unit box), its majorant and exit ----\nfn vdbRefMajorantAt(i: u32, lo: vec3f, ld: vec3f, t: f32, t1: f32) -> vec2f {\n let rec = vdbRefU.volumes[i];\n let dims = rec.ids.yzw;\n if (dims.x == 0u) {\n return vec2f(rec.params.y, t1);\n }\n let n = vec3f(dims);\n let q = (lo + ld * t + vec3f(0.5)) * n;\n let nudge = select(select(vec3f(0.0), vec3f(-1e-4), ld < vec3f(0.0)), vec3f(1e-4), ld > vec3f(0.0));\n let cell = vec3u(clamp(floor(q + nudge), vec3f(0.0), n - vec3f(1.0)));\n var exit = VDB_REF_FAR;\n for (var k = 0u; k < 3u; k = k + 1u) {\n if (abs(ld[k]) > 1e-12) {\n let face = (f32(cell[k]) + select(0.0, 1.0, ld[k] > 0.0)) / n[k] - 0.5;\n exit = min(exit, (face - lo[k]) / ld[k]);\n }\n }\n if (!(exit > t)) {\n exit = t + 1e-6 * max(1.0, abs(t));\n }\n let cellIndex = cell;\n let bound = textureLoad(vdbRefMajorants, vec3u(cellIndex.x, cellIndex.y, cellIndex.z + rec.grid.x), 0).x;\n return vec2f(rec.params.x * bound, min(t1, exit));\n}\n\n// ---- tracking: delta (ratio false: the collision) or ratio (ratio true: T), piecewise majorants ----\nstruct VdbRefHit {\n escaped: bool,\n t: f32,\n vol: u32,\n trans: f32,\n}\n\nfn vdbRefTrack(o: vec3f, d: vec3f, tMax: f32, ratio: bool) -> VdbRefHit {\n var iv: array<vec2f, ${o.maxVolumes}>;\n var lo: array<vec3f, ${o.maxVolumes}>;\n var ld: array<vec3f, ${o.maxVolumes}>;\n let n = vdbRefU.volumeCount;\n for (var i = 0u; i < n; i = i + 1u) {\n iv[i] = vdbRefInterval(i, o, d, tMax);\n let m = vdbRefU.volumes[i].worldToLocal;\n lo[i] = (m * vec4f(o, 1.0)).xyz;\n ld[i] = (m * vec4f(d, 0.0)).xyz;\n }\n var t = 0.0;\n var trans = 1.0;\n for (var step = 0u; step < VDB_REF_MAX_STEPS; step = step + 1u) {\n var sbar = 0.0;\n var tb = tMax;\n for (var i = 0u; i < n; i = i + 1u) {\n let w = iv[i];\n if (w.x <= t && t < w.y) {\n let piece = vdbRefMajorantAt(i, lo[i], ld[i], t, w.y);\n sbar = sbar + piece.x;\n tb = min(tb, piece.y);\n } else if (w.x > t && w.x <= w.y) {\n tb = min(tb, w.x);\n }\n }\n if (!(sbar > 0.0)) {\n if (tb >= tMax) {\n return VdbRefHit(true, tMax, 0u, trans);\n }\n t = tb;\n continue;\n }\n let dt = -log(1.0 - vdbRefRand()) / sbar;\n if (t + dt >= tb) {\n t = tb;\n if (t >= tMax) {\n return VdbRefHit(true, tMax, 0u, trans);\n }\n continue;\n }\n t = t + dt;\n let x = o + t * d;\n var sig: array<f32, ${o.maxVolumes}>;\n var sum = 0.0;\n for (var i = 0u; i < n; i = i + 1u) {\n let w = iv[i];\n var s = 0.0;\n if (w.x <= t && t < w.y) {\n s = vdbRefSigma(i, x);\n }\n sig[i] = s;\n sum = sum + s;\n }\n if (!ratio) {\n let u = vdbRefRand() * sbar;\n var acc = 0.0;\n for (var i = 0u; i < n; i = i + 1u) {\n let w = iv[i];\n if (!(w.x <= t && t < w.y)) {\n continue;\n }\n acc = acc + sig[i];\n if (u < acc) {\n return VdbRefHit(false, t, i, trans);\n }\n }\n } else {\n trans = trans * (1.0 - sum / sbar);\n if (trans < VDB_REF_RATIO_RR) {\n if (vdbRefRand() >= 0.5) {\n return VdbRefHit(false, t, 0u, 0.0);\n }\n trans = trans * 2.0;\n }\n }\n }\n return VdbRefHit(true, t, 0u, select(0.0, trans, ratio));\n}\n\n// ---- lights and environment (vdbRefLightAt, vdbRefEnvironmentRadiance) ----\nstruct VdbRefNee {\n ok: bool,\n dir: vec3f,\n dist: f32,\n li: vec3f,\n}\n\nfn vdbRefLightAt(k: u32, x: vec3f) -> VdbRefNee {\n let l = vdbRefU.lights[k];\n let kind = u32(l.position.w + 0.5);\n if (kind == 0u) {\n return VdbRefNee(vdbRefMax3(l.color.xyz) > 0.0, l.direction.xyz, VDB_REF_FAR, l.color.xyz);\n }\n let to = l.position.xyz - x;\n let dist = length(to);\n if (!(dist > 0.0)) {\n return VdbRefNee(false, vec3f(0.0, 1.0, 0.0), 0.0, vec3f(0.0));\n }\n let dir = to / dist;\n // falloff (extra): mode 0 none ('volume' lighting), 1 inverse square, 2 three's getDistanceAttenuation (cutoff, decay)\n let mode = u32(l.extra.x + 0.5);\n var s = 1.0;\n if (mode == 1u) {\n s = 1.0 / (dist * dist);\n } else if (mode == 2u) {\n s = 1.0 / max(pow(dist, l.extra.z), 0.01);\n if (l.extra.y > 0.0) {\n let w = clamp(1.0 - pow(dist / l.extra.y, 4.0), 0.0, 1.0);\n s = s * w * w;\n }\n }\n if (kind == 2u) {\n s = s * vdbRefSmoothstep(l.direction.w, l.color.w, -dot(dir, l.direction.xyz));\n }\n let li = l.color.xyz * s;\n return VdbRefNee(s > 0.0 && vdbRefMax3(li) > 0.0, dir, dist, li);\n}\n\n// ---- K6.R2: the equirect map's texel lookup and importance sampling (tools/reference/environment.ts) ----\nfn vdbRefEnvTexelOf(d: vec3f) -> vec2u {\n let m = vec3f(dot(vdbRefU.envRotation0.xyz, d), dot(vdbRefU.envRotation1.xyz, d), dot(vdbRefU.envRotation2.xyz, d));\n let u = atan2(m.z, m.x) / (2.0 * VDB_REF_PI) + 0.5;\n let v = asin(clamp(m.y, -1.0, 1.0)) / VDB_REF_PI + 0.5;\n let size = vec2i(vdbRefU.envSize);\n let px = clamp(i32(floor(u * f32(size.x))), 0, size.x - 1);\n let py = clamp(i32(floor((1.0 - v) * f32(size.y))), 0, size.y - 1);\n return vec2u(u32(px), u32(py));\n}\n\nfn vdbRefEnvTable(x: u32, y: u32) -> f32 {\n return textureLoad(vdbRefEnvCdf, vec2u(x, y), 0).x;\n}\n\n// the interval j with t[j] <= xi < t[j + 1] of table row 'row' (t[0 .. n])\nfn vdbRefEnvSearch(row: u32, n: u32, xi: f32) -> u32 {\n var lo = 0u;\n var hi = n;\n loop {\n if (hi - lo <= 1u) {\n break;\n }\n let mid = (lo + hi) >> 1u;\n if (vdbRefEnvTable(mid, row) <= xi) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n return lo;\n}\n\n// density per steradian of texel (x, y): P(y) P(x | y) / omega_y (vdbRefEnvTexelPdf)\nfn vdbRefEnvTexelPdf(x: u32, y: u32) -> f32 {\n let w = vdbRefU.envSize.x;\n let h = vdbRefU.envSize.y;\n let py = vdbRefEnvTable(y + 1u, h) - vdbRefEnvTable(y, h);\n let px = vdbRefEnvTable(x + 1u, y) - vdbRefEnvTable(x, y);\n let omega = vdbRefEnvTable(y, h + 4u);\n return select(0.0, py * px / max(omega, 1e-30), omega > 0.0);\n}\n\nfn vdbRefEnvPdf(d: vec3f) -> f32 {\n let t = vdbRefEnvTexelOf(d);\n return vdbRefEnvTexelPdf(t.x, t.y);\n}\n\n// sin and cos of |a| <= 2 pi to f32 precision (WGSL sin / cos are only good to 2^-11): Taylor at a / 8, three doublings\nfn vdbRefSinCos(a: f32) -> vec2f {\n let h = a * 0.125;\n let h2 = h * h;\n var s = h * (1.0 - h2 / 6.0 * (1.0 - h2 / 20.0 * (1.0 - h2 / 42.0 * (1.0 - h2 / 72.0))));\n var c = 1.0 - h2 / 2.0 * (1.0 - h2 / 12.0 * (1.0 - h2 / 30.0 * (1.0 - h2 / 56.0 * (1.0 - h2 / 90.0))));\n for (var k = 0u; k < 3u; k = k + 1u) {\n let s2 = 2.0 * s * c;\n c = c * c - s * s;\n s = s2;\n }\n return vec2f(s, c);\n}\n\nstruct VdbRefEnvSample {\n dir: vec3f,\n radiance: vec3f,\n pdf: f32,\n}\n\n// a direction from the map (vdbRefEnvSample): row, column, azimuth and sin latitude in the texel; the SAMPLED texel's\n// radiance and density\nfn vdbRefEnvSample(xi: vec4f) -> VdbRefEnvSample {\n let w = vdbRefU.envSize.x;\n let h = vdbRefU.envSize.y;\n let y = vdbRefEnvSearch(h, h, xi.x);\n let x = vdbRefEnvSearch(y, w, xi.y);\n let sc = vdbRefSinCos(2.0 * VDB_REF_PI / f32(w) * xi.z);\n let c0 = vdbRefEnvTable(x, h + 1u);\n let s0 = vdbRefEnvTable(x, h + 2u);\n let cphi = c0 * sc.y - s0 * sc.x;\n let sphi = s0 * sc.y + c0 * sc.x;\n let top = vdbRefEnvTable(y, h + 3u);\n let bottom = vdbRefEnvTable(y + 1u, h + 3u);\n let my = bottom + (top - bottom) * xi.w;\n let r = sqrt(max(0.0, 1.0 - my * my));\n let m = vec3f(r * cphi, my, r * sphi);\n // d = R^T m (the lookup applies m = R d)\n let dir = normalize(m.x * vdbRefU.envRotation0.xyz + m.y * vdbRefU.envRotation1.xyz + m.z * vdbRefU.envRotation2.xyz);\n let radiance = textureLoad(vdbRefEnvMap, vec2u(x, y), 0).xyz * vdbRefU.uniformEnv.w;\n return VdbRefEnvSample(dir, radiance, vdbRefEnvTexelPdf(x, y));\n}\n\n// K6.R2: the equirect map's part weighted by mapWeight (its MIS weight on an escape)\nfn vdbRefEnvironment(d: vec3f, mapWeight: f32) -> vec3f {\n var e = vdbRefU.uniformEnv.xyz;\n if ((vdbRefU.flags & ${VDB_REF_FLAG_SH}u) != 0u) {\n let sh = vdbRefU.sh;\n e = e + sh[0].xyz * 0.282095 + sh[1].xyz * (0.488603 * d.y) + sh[2].xyz * (0.488603 * d.z) + sh[3].xyz * (0.488603 * d.x);\n e = e + sh[4].xyz * (1.092548 * d.x * d.y) + sh[5].xyz * (1.092548 * d.y * d.z) + sh[6].xyz * (0.315392 * (3.0 * d.z * d.z - 1.0));\n e = e + sh[7].xyz * (1.092548 * d.x * d.z) + sh[8].xyz * (0.546274 * (d.x * d.x - d.y * d.y));\n }\n for (var i = 0u; i < vdbRefU.hemiCount; i = i + 1u) {\n let h = vdbRefU.hemis[i];\n e = e + select(h.ground.xyz, h.sky.xyz, dot(d, h.up.xyz) >= 0.0);\n }\n if ((vdbRefU.flags & ${VDB_REF_FLAG_EQUIRECT}u) != 0u) {\n let t = vdbRefEnvTexelOf(d);\n e = e + textureLoad(vdbRefEnvMap, t, 0).xyz * (vdbRefU.uniformEnv.w * mapWeight);\n }\n return e;\n}\n\n// ---- one sample: the state machine (mode 0 primary T, 1 path segment, 2 light visibility) ----\nfn vdbRefSample(pixel: vec2u, sampleIndex: u32) -> vec4f {\n vdbRefSeed(vdbRefU.seed, sampleIndex, pixel.y * vdbRefU.size.x + pixel.x);\n var j = vec2f(0.5, 0.5);\n if ((vdbRefU.flags & ${VDB_REF_FLAG_BOX_FILTER}u) != 0u) {\n j.x = vdbRefRand();\n j.y = vdbRefRand();\n }\n let size = vec2f(vdbRefU.size);\n let ndc = vec2f((f32(pixel.x) + j.x) / size.x * 2.0 - 1.0, (1.0 - (f32(pixel.y) + j.y) / size.y) * 2.0 - 1.0);\n let pNear = vdbRefUnproject(vec3f(ndc, 0.0));\n let pFar = vdbRefUnproject(vec3f(ndc, 1.0));\n let dv = normalize(pFar - pNear);\n var ov = vec3f(0.0);\n if ((vdbRefU.flags & ${VDB_REF_FLAG_ORTHOGRAPHIC}u) != 0u) {\n ov = vdbRefUnproject(vec3f(ndc, -1.0));\n }\n var o = (vdbRefU.cameraToWorld * vec4f(ov, 1.0)).xyz;\n var d = normalize((vdbRefU.cameraToWorld * vec4f(dv, 0.0)).xyz);\n\n var rad = vec3f(0.0);\n var beta = vec3f(1.0);\n var primaryT = 1.0;\n var mode = 0u;\n var depth = 0u;\n var lightIndex = 0u;\n var x = o;\n var vol = 0u;\n var neeDir = vec3f(0.0, 1.0, 0.0);\n var neeDist = 0.0;\n var neeLi = vec3f(0.0);\n // K6.R2: the density of the phase sampling that gave d (the escape's MIS weight)\n var phasePdf = 0.0;\n loop {\n var ro = o;\n var rd = d;\n var tMax = VDB_REF_FAR;\n if (mode == 2u) {\n ro = x;\n rd = neeDir;\n tMax = neeDist;\n }\n let hit = vdbRefTrack(ro, rd, tMax, mode != 1u);\n if (mode == 0u) {\n primaryT = hit.trans;\n mode = 1u;\n continue;\n }\n if (mode == 2u) {\n rad = rad + beta * neeLi * hit.trans;\n lightIndex = lightIndex + 1u;\n } else {\n if (hit.escaped) {\n if (depth > 0u) {\n var w = 1.0;\n if ((vdbRefU.flags & ${VDB_REF_FLAG_ENV_MIS}u) != 0u) {\n w = vdbRefMisWeight(phasePdf, vdbRefEnvPdf(d));\n }\n rad = rad + beta * vdbRefEnvironment(d, w);\n }\n break;\n }\n // a collision past the cap ends the path (the last bounce's escape still gathered the environment above)\n if (depth >= vdbRefU.maxBounces) {\n break;\n }\n depth = depth + 1u;\n vol = hit.vol;\n x = o + hit.t * d;\n let uvw = vdbRefUvw(vol, x);\n let rec = vdbRefU.volumes[vol];\n let v = rec.ids.x;\n let albedo = rec.albedo.xyz * vdbSrcAlbedo(v, uvw, 0.0);\n var le = vec3f(0.0);\n if (rec.albedo.w > 0.5) {\n let temperature = mix(rec.temperature.x, rec.temperature.y, vdbSrcEmission(v, uvw, 0.0));\n if (temperature > 0.0) {\n le = rec.emission.xyz * pow(temperature / max(rec.temperature.y, 1.0), 4.0);\n if (rec.tables.z > 0u) {\n // the blackbody colour table over log temperature (vdbRefColorTableAt): log range in temperature.zw\n let lx = (log(max(temperature, 1e-3)) - rec.temperature.z) / (rec.temperature.w - rec.temperature.z);\n le = le * vdbRefTableAt(rec.tables.z - 1u, rec.tables.w, lx).xyz;\n }\n }\n }\n rad = rad + beta * le;\n beta = beta * albedo;\n if (!(vdbRefMax3(beta) > 0.0)) {\n break;\n }\n lightIndex = 0u;\n }\n // The next light that reaches x (dark ones draw nothing), then (K6.R2) the map's NEE once (lightIndex ==\n // lightCount; its visibility pass moves lightIndex past it), else finish the collision.\n var found = false;\n loop {\n if (lightIndex < vdbRefU.lightCount) {\n let nee = vdbRefLightAt(lightIndex, x);\n if (nee.ok) {\n neeDir = nee.dir;\n neeDist = nee.dist;\n neeLi = nee.li * vdbRefPhaseEval(dot(d, nee.dir), vol);\n found = true;\n break;\n }\n lightIndex = lightIndex + 1u;\n continue;\n }\n if (lightIndex == vdbRefU.lightCount && (vdbRefU.flags & ${VDB_REF_FLAG_ENV_MIS}u) != 0u) {\n let xi0 = vdbRefRand();\n let xi1 = vdbRefRand();\n let xi2 = vdbRefRand();\n let xi3 = vdbRefRand();\n let smp = vdbRefEnvSample(vec4f(xi0, xi1, xi2, xi3));\n let c = dot(d, smp.dir);\n var k = 0.0;\n if (smp.pdf > 0.0) {\n k = vdbRefMisWeight(smp.pdf, vdbRefPhasePdf(c, vol)) / smp.pdf;\n }\n let li = smp.radiance * vdbRefPhaseEval(c, vol) * k;\n if (vdbRefMax3(li) > 0.0) {\n neeDir = smp.dir;\n neeDist = VDB_REF_FAR;\n neeLi = li;\n found = true;\n break;\n }\n }\n lightIndex = vdbRefU.lightCount + 1u;\n break;\n }\n if (found) {\n mode = 2u;\n continue;\n }\n if (depth >= vdbRefU.rrStart) {\n let q = min(vdbRefMax3(beta), 1.0);\n if (q < 1.0) {\n if (vdbRefRand() >= q) {\n break;\n }\n beta = beta / q;\n }\n }\n let rec = vdbRefU.volumes[vol];\n let ph = rec.phase;\n let lobe = vdbRefRand();\n let u1 = vdbRefRand();\n let u2 = vdbRefRand();\n var cosTheta = 0.0;\n if (rec.tables.x > 0u) {\n let ts = vdbRefPhaseTableSample(rec.tables.x - 1u, rec.tables.y, u1);\n cosTheta = ts.cosTheta;\n beta = beta * ts.weight;\n phasePdf = ts.pdf;\n } else {\n let g = select(ph.x, ph.y, ph.z > 0.0 && lobe < ph.z);\n cosTheta = vdbRefSampleHgCos(g, u1);\n // the lobe mixture is sampled exactly: its density is the phase itself\n phasePdf = vdbRefPhaseEval(cosTheta, vol).x;\n }\n d = normalize(vdbRefDirectionAround(d, cosTheta, u2));\n o = x;\n mode = 1u;\n }\n return vec4f(rad, primaryT);\n}\n\n@compute @workgroup_size(8, 8, 1)\nfn vdbRefTraceCs(@builtin(global_invocation_id) gid: vec3u) {\n if (gid.x >= vdbRefU.size.x || gid.y >= vdbRefU.size.y) {\n return;\n }\n var m = vec4f(0.0);\n for (var s = 0u; s < vdbRefU.spp; s = s + 1u) {\n m = m + vdbRefSample(gid.xy, vdbRefBatch.batch * vdbRefU.spp + s);\n }\n m = m / f32(vdbRefU.spp);\n var s0 = m;\n var s1 = m * m;\n if (vdbRefBatch.accumulate != 0u) {\n s0 = s0 + textureLoad(vdbRefAccumIn0, gid.xy, 0);\n s1 = s1 + textureLoad(vdbRefAccumIn1, gid.xy, 0);\n }\n textureStore(vdbRefAccumOut0, gid.xy, s0);\n textureStore(vdbRefAccumOut1, gid.xy, s1);\n}\n`;\n}\n"]}
@@ -0,0 +1,347 @@
1
+ /**
2
+ * `VDBSequence`: manifest-driven animated-volume playback on a `VDBGridPool`
3
+ * (task K2.3; v1's `NanoVDBSequence`, docs/archive/v1/SPEC.md §3.5). Decodes per-frame grid
4
+ * images ahead of time into a bounded prefetch ring and swaps the shown one
5
+ * into ONE pool id with `pool.replace(id, image)`.
6
+ *
7
+ * ## The pool contract
8
+ *
9
+ * const id = pool.add(firstFrame, { capacity: largestFrameBytes });
10
+ * sequence.start({ pool, id });
11
+ * // every frame:
12
+ * sequence.update(performance.now()); // may call pool.replace(id, frame)
13
+ * pool.update(encoder) / pool.flush(); // writes the frame in place
14
+ * grids.update(); // VDBGridNode: rebinds only after a growth
15
+ * renderer.render(scene, camera);
16
+ *
17
+ * Reserve `capacity` for the largest frame: every `replace` then writes in
18
+ * place (no move, no `pool.version` change, no rebind, no new bind group). A
19
+ * frame larger than the capacity still works, but it moves the image, and the
20
+ * next `update` may grow the pool (a `version` bump), so keep calling
21
+ * `grids.update()` after the pool's update either way.
22
+ *
23
+ * **Frame arrays are held by reference.** `replace` keeps the image until the
24
+ * `update` that writes it, and until `pool.settled()` resolves while a growth
25
+ * is unconfirmed (the pool may have to stage it again after a rollback). The
26
+ * player never writes into a frame array, and its ring only drops references.
27
+ * A custom `loader` that recycles frame buffers must not reuse an array it
28
+ * returned before `await pool.settled()` after the update that wrote it.
29
+ *
30
+ * ## Design for testability (the scheduler is a pure clock consumer)
31
+ *
32
+ * The player never owns the animation loop or reads the wall clock itself.
33
+ * `update(now)` takes the current time in ms; the consumer calls it from its
34
+ * own `requestAnimationFrame` loop with `performance.now()`, and tests call it
35
+ * with a fake, hand-advanced clock. The pool is reached only through
36
+ * `replace(id, image)`, so tests pass a stub.
37
+ *
38
+ * ## Stall policy: never block the render loop
39
+ *
40
+ * If the frame that is due hasn't finished decoding, `update()` does not wait:
41
+ * it holds the last-shown frame, counts a stall, and returns. Decoding
42
+ * continues in the background; the next `update()` that finds the frame ready
43
+ * advances to wherever the clock now points (intermediate frames are dropped:
44
+ * real-time catch-up, not slow motion).
45
+ *
46
+ * ## Frame range and loop mode
47
+ *
48
+ * `range: [start, end]` (inclusive frame indices) limits playback to those frames; the default is all of them.
49
+ * `loopMode: 'repeat'` (default) wraps from `end` to `start`; `'pingpong'` plays forward then backward
50
+ * (`start .. end .. start`), with each end frame shown once per turn (no doubled frame at the ends); `'once'` plays
51
+ * to `end` and holds there. `start()` shows `range[0]`. `seek(i)` wraps `i` into the clip, then clamps it into the
52
+ * range. `setRange()` and `setLoopMode()` change them while playing (playback continues from the shown frame,
53
+ * clamped into the new range). The prefetch ring follows the playback order, so a swap is always a `pool.replace`
54
+ * of a frame the ring already holds.
55
+ *
56
+ * **Direction.** A ping-pong keeps its direction across `stop()` / `resume()`, `seek()` and `setRange()`: paused on
57
+ * the way back, it resumes on the way back. `start()` goes forward; `setLoopMode()` keeps the direction only when the
58
+ * new mode is `'pingpong'` (`'repeat'` and `'once'` only go forward).
59
+ *
60
+ * ## Failed frames: no retry until `seek` / `start`
61
+ *
62
+ * A frame whose loader rejects goes into a failed set: `onError` fires once,
63
+ * and the player does not ask the loader for it again (no retry storm from
64
+ * the per-frame prefetch). While the clock points at it, `update()` holds the
65
+ * last frame and counts stalls; playback moves on when the clock reaches the
66
+ * next decodable frame. `seek()` and `start()` clear the set, so they retry
67
+ * every failed frame (call `seek(stats.frame)` to retry in place).
68
+ * `stats.failed` counts the frames in the set.
69
+ *
70
+ * ## Disposal
71
+ *
72
+ * `dispose()` drops the ring and the in-flight tracking and bumps a
73
+ * generation token: decodes that finish later are dropped (no ring entry, no
74
+ * `onError`). `start`, `seek`, `resume` and `preload` after `dispose()` throw
75
+ * (or reject with) `VDB_DISPOSED`; `update` returns the last frame.
76
+ */
77
+ /** The part of a `VDBGridPool` the player uses. */
78
+ export interface VDBSequencePoolLike<TFrame = Uint32Array> {
79
+ /**
80
+ * Stages a new image for grid `id` (`VDBGridPool.replace`).
81
+ *
82
+ * @param id The grid's pool id.
83
+ * @param image The frame to show.
84
+ */
85
+ replace(id: number, image: TFrame): void;
86
+ }
87
+ /**
88
+ * Where frames go: grid `id` of `pool` (added with `capacity` for the largest frame), or (K5.9) a `source` with
89
+ * `replace(frame)`: a dense `.wvdb` source (`vdbDenseTextures`) playing `WvdbDenseVolume` frames, which a
90
+ * `VDBFrameVolume` over it follows by itself.
91
+ */
92
+ export type VDBSequenceTarget<TFrame = Uint32Array> = {
93
+ readonly pool: VDBSequencePoolLike<TFrame>;
94
+ readonly id: number;
95
+ } | {
96
+ readonly source: {
97
+ replace(frame: TFrame): void;
98
+ };
99
+ };
100
+ /** Decodes one frame's URL (or index) into a frame: a NanoVDB grid image by default. */
101
+ export type VDBSequenceFrameLoader<TFrame = Uint32Array> = (url: string, index: number) => Promise<TFrame>;
102
+ /**
103
+ * What playback does at the end of its range: wrap to the start (`'repeat'`), turn around (`'pingpong'`), or hold
104
+ * the end frame (`'once'`).
105
+ */
106
+ export type VDBSequenceLoopMode = "once" | "repeat" | "pingpong";
107
+ /** An inclusive `[start, end]` frame range. */
108
+ export type VDBSequenceRange = readonly [start: number, end: number];
109
+ /** Options of {@link VDBSequence}. */
110
+ export interface VDBSequenceOptions<TFrame = Uint32Array> {
111
+ /** Per-frame source URLs: an array, or `(i) => url`. Length/`frameCount` gate playback. */
112
+ urls: string[] | ((index: number) => string);
113
+ /** Total frame count. Defaults to `urls.length` when `urls` is an array (required otherwise). */
114
+ frameCount?: number;
115
+ /** Playback rate. Default 24. */
116
+ fps?: number;
117
+ /** How many frames to decode ahead of the current one. Default 3. */
118
+ prefetch?: number;
119
+ /**
120
+ * Inclusive `[start, end]` frames to play. Default `[0, frameCount - 1]` (all frames).
121
+ * @throws VDBError `VDB_BAD_OPTION` unless both are integers with `0 <= start <= end < frameCount`.
122
+ */
123
+ range?: VDBSequenceRange;
124
+ /**
125
+ * What playback does at the range end: `'repeat'` (default) wraps to the start; `'pingpong'` plays back to the
126
+ * start and forward again; `'once'` holds the end frame. Change it while playing with `setLoopMode()`.
127
+ * @throws VDBError `VDB_BAD_OPTION` for any other value.
128
+ */
129
+ loopMode?: VDBSequenceLoopMode;
130
+ /**
131
+ * Decode override. Default: `NvdbFile.fromURL(url)` -> `gridImage(0)`.
132
+ * The demo passes an in-memory loader (build frames on the fly, no fetch);
133
+ * the URL/fetch path is exercised via a Blob-URL manifest + this default.
134
+ */
135
+ loader?: VDBSequenceFrameLoader<TFrame>;
136
+ /** Clock source. Default `performance.now`. Injected as a fake in tests. */
137
+ now?: () => number;
138
+ /** Fired whenever a NEW frame is shown (after its `pool.replace`). */
139
+ onFrame?: (stats: Readonly<VDBSequenceStats>) => void;
140
+ /**
141
+ * Fired once when a frame fails to decode. The frame is not retried until
142
+ * `seek` or `start`; playback skips it (a stall while the clock points at it).
143
+ */
144
+ onError?: (error: unknown, index: number) => void;
145
+ }
146
+ /** Playback counters read through {@link VDBSequence.stats}. */
147
+ export interface VDBSequenceStats {
148
+ /** Frame index currently shown. -1 before the first frame binds. */
149
+ frame: number;
150
+ /** Decoded-and-ready frames sitting in the ring ahead of `frame`. */
151
+ decodedAhead: number;
152
+ /** Cumulative count of updates that found the due frame not yet decoded. */
153
+ stalls: number;
154
+ /** CPU time (ms) of the last `pool.replace` (staging only; the GPU write lands in the next pool update). */
155
+ replaceMs: number;
156
+ /** `pool.replace` calls since `start` (the initial frame 0 included). */
157
+ swaps: number;
158
+ /** Frames whose decode failed and that wait for a `seek` / `start` to be retried. */
159
+ failed: number;
160
+ }
161
+ /**
162
+ * Plays a frame sequence into ONE pool grid: decodes frames ahead into a
163
+ * bounded ring and `pool.replace`s the due one, driven by your clock. See the
164
+ * file comment for the pool contract, the stall policy, failed frames and
165
+ * disposal.
166
+ *
167
+ * const id = pool.add(firstFrame, { capacity: largestFrameBytes });
168
+ * const sequence = new VDBSequence({ urls, fps: 24 });
169
+ * sequence.start({ pool, id });
170
+ * // per frame: sequence.update(performance.now()); pool.update(encoder); grids.update(); render
171
+ */
172
+ export declare class VDBSequence<TFrame = Uint32Array> {
173
+ /** Total frames of the clip. */
174
+ readonly frameCount: number;
175
+ /** Playback rate in frames per second. */
176
+ readonly fps: number;
177
+ /** How many frames are decoded ahead of the shown one. */
178
+ readonly prefetch: number;
179
+ private _rangeStart;
180
+ private _rangeEnd;
181
+ private _loopMode;
182
+ /** Playback direction at the shown frame: +1, or -1 on the way back of a ping-pong. */
183
+ private _dir;
184
+ /** Direction at the clock anchor (`startFrame`): -1 when it was anchored on the way back of a ping-pong. */
185
+ private startDir;
186
+ private readonly urlFor;
187
+ private readonly loader;
188
+ private readonly hasLoader;
189
+ private readonly now;
190
+ private readonly onFrame;
191
+ private readonly onError;
192
+ private readonly frameDurationMs;
193
+ /** Decoded frame images by frame index. */
194
+ private readonly ring;
195
+ /** In-flight decode promises by frame index (dedupe + stall detection). */
196
+ private readonly inflight;
197
+ /** Frames whose decode failed: not retried until `seek` / `start`. */
198
+ private readonly failed;
199
+ /** Bumped by `dispose()`: a decode that finishes under an older generation is dropped. */
200
+ private generation;
201
+ private disposed;
202
+ private replaceFrame;
203
+ /** K5.9: a frame shown by `seek` while stopped once its decode lands. */
204
+ private pendingFrame;
205
+ /** The playback direction at `pendingFrame`. */
206
+ private pendingDir;
207
+ /** `pendingFrame` was asked for (start / seek / a range or mode change), not made due by the clock: it survives `stop()`. */
208
+ private pendingExplicit;
209
+ private playing;
210
+ private startNow;
211
+ private startFrame;
212
+ private _frame;
213
+ private _stalls;
214
+ private _replaceMs;
215
+ private _swaps;
216
+ /**
217
+ * Creates the player; nothing is loaded until `start`.
218
+ *
219
+ * @param opts URLs, frame count, rate, prefetch, range, loop mode, loader, clock and callbacks.
220
+ */
221
+ constructor(opts: VDBSequenceOptions<TFrame>);
222
+ /** A snapshot of the playback counters. */
223
+ get stats(): Readonly<VDBSequenceStats>;
224
+ /** True while the clock is running: after `start` or `resume`, until `stop`. */
225
+ get isPlaying(): boolean;
226
+ /** Wrap a raw (possibly negative or >= frameCount) index into [0, frameCount). */
227
+ private wrap;
228
+ /** The playback range, inclusive: `[0, frameCount - 1]` unless set. */
229
+ get range(): VDBSequenceRange;
230
+ /** What playback does at the range end (`'repeat'` unless set). */
231
+ get loopMode(): VDBSequenceLoopMode;
232
+ private checkRange;
233
+ private checkLoopMode;
234
+ /**
235
+ * Change the playback range (inclusive). While playing, playback continues from the shown frame, clamped into the
236
+ * new range (the clock re-anchors there; a ping-pong keeps its direction); the prefetch ring is refilled in the
237
+ * new order.
238
+ *
239
+ * @param range Inclusive `[start, end]` frame range.
240
+ * @param now Clock time in ms to re-anchor at (default: the injected clock).
241
+ *
242
+ * @throws VDBError `VDB_BAD_OPTION` for a bad range; `VDB_DISPOSED` after `dispose()`.
243
+ */
244
+ setRange(range: VDBSequenceRange, now?: number): void;
245
+ /**
246
+ * Change what playback does at the range end. Playback continues from the shown frame: going forward, or, when
247
+ * both the old and the new mode are `'pingpong'`, in its current direction. Switching to `'once'` at the range end
248
+ * holds there; switching from `'once'` held at the end to `'repeat'` or `'pingpong'` plays on.
249
+ *
250
+ * @param mode `'once'`, `'repeat'` or `'pingpong'`.
251
+ * @param now Clock time in ms to re-anchor at (default: the injected clock).
252
+ *
253
+ * @throws VDBError `VDB_BAD_OPTION` for an unknown mode; `VDB_DISPOSED` after `dispose()`.
254
+ */
255
+ setLoopMode(mode: VDBSequenceLoopMode, now?: number): void;
256
+ /** Re-anchor the clock at the shown frame (clamped into the range) after a range or mode change. */
257
+ private reanchor;
258
+ /** Anchor the clock at `frame` (clamped into the range) heading `dir` (forward unless ping-ponging) at `now`. */
259
+ private anchor;
260
+ private clampToRange;
261
+ /** The frame `steps` after `from` (absolute index) heading `dir`, with the direction there. */
262
+ private stepFrom;
263
+ /**
264
+ * The frame the clock points at `advanced` frames after the anchor, and the direction there.
265
+ *
266
+ * A ping-pong over `len` frames is a cycle of `period = 2 (len - 1)` steps: phase `q` in `[0, len - 1]` is frame
267
+ * `rs + q` on the way out, phase `q` in `(len - 1, period)` is frame `rs + period - q` on the way back. An anchor
268
+ * at offset `o = startFrame - rs` heading forward sits at phase `o`, heading back at phase `period - o` (the two
269
+ * agree at the ends: `o = len - 1` gives `len - 1` either way, `o = 0` gives 0 or `period`, the same phase).
270
+ */
271
+ private frameAt;
272
+ /**
273
+ * Ensure the frames `[from .. from+prefetch]` in playback order (wrapping or turning around in the range when
274
+ * looping) are decoding or decoded, and evict frames outside that window to bound memory.
275
+ */
276
+ private ensurePrefetch;
277
+ /**
278
+ * Start (or return) the decode of one frame; resolves into the ring. A
279
+ * failed frame is not retried (see the file comment); a decode that settles
280
+ * after `dispose()` is dropped.
281
+ */
282
+ private decodeFrame;
283
+ private assertLive;
284
+ private decodedAhead;
285
+ /**
286
+ * Decode the first `count` frames of the range (in playback order) and resolve once all are ready. Useful for
287
+ * a deterministic warm start (the demo's `?test=1` awaits this so playback has
288
+ * zero stalls). Does not start playback.
289
+ */
290
+ preload(count?: number): Promise<void>;
291
+ /**
292
+ * Begin playback into grid `target.id` of `target.pool`. Replaces it with
293
+ * the first frame of the range (frame 0 by default) at once if that is decoded (else the first `update` that finds it
294
+ * ready does), kicks off prefetch, and anchors the clock at `now` (defaults
295
+ * to the injected clock). Call `update(now)` every animation frame thereafter.
296
+ * Clears the failed set (failed frames are retried).
297
+ *
298
+ * @param target Where frames go: `{ pool, id }` or `{ source }`.
299
+ * @param now Clock time in ms the playback is anchored at (default: the injected clock).
300
+ *
301
+ * @throws VDBError `VDB_DISPOSED` after `dispose()`; `VDB_BAD_OPTION` for a bad target.
302
+ */
303
+ start(target: VDBSequenceTarget<TFrame>, now?: number): void;
304
+ /**
305
+ * Stop playback. The ring is preserved so `start`/`resume`/`seek` can resume cheaply. A frame the clock made due
306
+ * that is still decoding does not land after `stop()`; a frame asked for by `start`, `seek`, `setRange` or
307
+ * `setLoopMode` (before or after the stop) is shown when its decode lands.
308
+ */
309
+ stop(): void;
310
+ /**
311
+ * Resume after `stop()` WITHOUT resetting to frame 0 or clearing stats:
312
+ * re-anchors the clock at `now` from the currently-shown frame so playback
313
+ * continues from where it paused (a ping-pong in the direction it was going).
314
+ * No-op if `start()` was never called.
315
+ *
316
+ * @throws VDBError `VDB_DISPOSED` after `dispose()`.
317
+ */
318
+ resume(now?: number): void;
319
+ /**
320
+ * Jump to `index` (wrapped into the clip, then clamped into the range), re-anchoring the clock there so playback
321
+ * continues from it (a ping-pong keeps its direction). Clears the failed set (failed frames are retried).
322
+ *
323
+ * @param index The frame to jump to.
324
+ * @param now Clock time in ms to re-anchor at (default: the injected clock).
325
+ *
326
+ * @throws VDBError `VDB_DISPOSED` after `dispose()`.
327
+ */
328
+ seek(index: number, now?: number): void;
329
+ /**
330
+ * Advance the scheduler to time `now`. Replaces the grid with the frame the
331
+ * clock points at if it is decoded; otherwise holds the last frame and counts
332
+ * a stall. Never blocks. Returns the frame index currently shown.
333
+ */
334
+ update(now: number): number;
335
+ /**
336
+ * Show `index` (playback heading `dir` there) if decoded (`pool.replace`, counts a swap, fires `onFrame`,
337
+ * advances prefetch); otherwise count a stall and hold. Shared by start/seek/update.
338
+ */
339
+ private showFrame;
340
+ /**
341
+ * Stops playback and drops all decoded frames and in-flight tracking; later
342
+ * decodes are dropped when they settle. The pool keeps the grid (and the
343
+ * frame it shows). Further `start` / `seek` / `resume` / `preload` throw
344
+ * `VDB_DISPOSED`. Idempotent.
345
+ */
346
+ dispose(): void;
347
+ }