@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":"coarse-first.js","sourceRoot":"","sources":["../../src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AC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CACvI,CAAC;AACJ,CAAC","sourcesContent":["/**\n * `vdbStreamCoarseFirst` (K4.16): stream a coarse-first `.nvdb`\n * (`vdbBakeCoarseFirst`, docs/dev/design/K4-5-coarse-first.md option a) into one\n * pool id. The preview is added as soon as its bytes are in, with the full\n * grid's size reserved, and each finer grid replaces it in place:\n *\n * const res = await fetch(url);\n * const { id } = await vdbStreamCoarseFirst(pool, res, {\n * onGrid: (e) => { if (e.final) console.log(\"full grid\"); },\n * });\n *\n * 1. `id = pool.add(preview, { capacity })`, where `capacity` is the largest\n * grid of the family announced so far (a segment lists every grid's\n * FileMetaData before any data, so the full grid's size is known);\n * 2. `pool.replace(id, finer)` for each finer grid, the full grid last.\n *\n * A file baked with `segments: 'per-grid'` (K7.12) announces each grid only\n * when its segment starts: the preview is added with its own size (the full\n * grid's `replace` then moves it to a larger range), and until the full grid's\n * segment starts `voxelRatio` is 1 and `types` lists only the grids seen.\n * Make a `VDBGridNode` with every type you bake, or bake the default layout.\n *\n * The id, its bind-group slot and any instance transform stay. Each image's\n * own Map places it, and a preview covers the full grid's world box, so the\n * world placement is unchanged. Things the caller re-derives after a swap\n * (the `onGrid` callback is the place, or the opt-in `bind` option, which does these\n * three steps for you after every swap):\n * - `replace` drops a brick majorant: call `pool.setMajorant` again;\n * - a `VDBVolumeMaterial` with an explicit `densityScale` (extinction per\n * index voxel): a preview with k-times larger voxels has 1/k the optical\n * depth at the same value, so scale it by `voxelRatio` while a preview\n * shows, and back to 1 at `final`. A material on its defaults needs nothing\n * (EX1a): its `opticalDepth` is relative to the grid's index box and mean\n * density, both of which it reads again after the swap;\n * - the proxy mesh: a new `vdbProxyGeometry(pool.info(id))` (the preview's\n * box is the full box grown to whole preview voxels).\n *\n * Into the froxel renderer (G16a): at the first event make the `VDBGridNode`\n * with `types: event.types` (every grid type of the family) and the sparse\n * source with `followImage: true`; the source re-reads its boxes after each\n * swap and the `VDBFrameVolume` follows, with no new node, source, volume or\n * shader. Froxels integrate in world space: no `voxelRatio` scale there.\n *\n * Without `bind` it touches only `pool.add` / `pool.replace`, so it works with\n * any `VDBGridPool` host. It lives in `./three` because `tools` may not import\n * the core (D20).\n */\n\nimport type * as THREE from \"three\";\n\nimport { VDBError } from \"../core/errors.js\";\nimport type { VDBBrickMajorant } from \"../core/index.js\";\nimport { VDB_GRID_TYPE_NAMES, type VDBGridTypeName } from \"../core/types.js\";\nimport { vdbProxyGeometry, type VDBProxyGridInfo } from \"./material.js\";\nimport { nvdbResponseLength } from \"../tools/nvdb-stream.js\";\nimport {\n NvdbStreamReader,\n parseNvdbLodName,\n type NvdbGridMetadata,\n type NvdbProgress,\n type NvdbStreamGrid,\n type NvdbStreamReaderOptions,\n} from \"../tools/index.js\";\n\n/** The part of a `VDBGridPool` the loader uses. */\nexport interface VDBCoarseFirstPoolLike {\n /**\n * Stages a grid image and returns its pool id (`VDBGridPool.add`).\n *\n * @param image The grid image.\n * @param options Reserved capacity and label.\n */\n add(image: Uint32Array, options?: { capacity?: number; label?: string }): number;\n /**\n * Stages a new image for grid `id` (`VDBGridPool.replace`).\n *\n * @param id The grid's pool id.\n * @param image The new grid image.\n */\n replace(id: number, image: Uint32Array): void;\n}\n\n/** The extra pool calls `bind` makes (a `VDBGridPool` has them all). */\nexport interface VDBCoarseFirstBindPoolLike {\n /** Writes the staged changes to the GPU (`VDBGridPool.flush`). */\n flush(): void;\n /** Reports a grid's index box and transform (`VDBGridPool.info`). */\n info(id: number): VDBProxyGridInfo;\n /**\n * Sets or clears a grid's brick-majorant bounds (`VDBGridPool.setMajorant`).\n *\n * @param id The grid's pool id.\n * @param majorant The brick bounds, or `null` to clear them.\n */\n setMajorant(id: number, majorant: VDBBrickMajorant | null): void;\n}\n\n/**\n * What to keep in step with the pool id after each swap (K5.4c). Every member is optional; the fields are read at\n * each swap, so they may be assigned later (for example in `onGrid`, once the first grid exists).\n */\nexport interface VDBCoarseFirstBind {\n /**\n * A material to scale: `material.densityScale.value = base * event.voxelRatio`, so a preview with k-times larger\n * voxels keeps the full grid's optical depth and the full grid gets `base` back. `base` is `densityScale` below,\n * else the material's value the first time `bind` is applied to it. A `VDBVolumeMaterial` on its defaults has\n * `densityScale` 0 (its `opticalDepth` follows the grid by itself), so it stays 0: nothing to scale.\n */\n material?: { densityScale: { value: number } };\n /** The base density scale for `material`. Default: the material's current value at the first swap. */\n densityScale?: number;\n /** A proxy mesh: its geometry is replaced (and the old one disposed) with `vdbProxyGeometry(pool.info(id))`. */\n mesh?: { geometry: THREE.BufferGeometry };\n /** `vdbProxyGeometry` padding for `mesh` (default 0). */\n proxyPad?: number;\n /** A `VDBGridNode`: `pool.flush()` then `grids.update()`, so its shaders see the swapped grid. */\n grids?: { update(): void };\n /**\n * Brick majorant for the grid just shown (`replace` drops the old one). Return `null` / `undefined` to leave the grid\n * without one, e.g. for a preview.\n */\n majorant?: (event: VDBCoarseFirstEvent) => VDBBrickMajorant | null | undefined;\n}\n\n/** What a coarse-first stream delivers. */\nexport type VDBCoarseFirstSource = Response | ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;\n\n/** One grid shown in the pool. */\nexport interface VDBCoarseFirstEvent {\n /** The pool id (the same for every grid of the family). */\n id: number;\n /** The grid as the stream reader emitted it (`lod` is null for the full grid). */\n grid: NvdbStreamGrid;\n /** True for the full grid: the last swap. */\n final: boolean;\n /** `'add'` for the first grid shown, `'replace'` after. */\n action: \"add\" | \"replace\";\n /** File bytes received when the grid was shown (decoded bytes; see the e2e for compressed counts). */\n bytesReceived: number;\n /** Expected file size when the grid was shown, or null if unknown (K4.20; see `NvdbProgress.bytesTotal`). */\n bytesTotal: number | null;\n /**\n * This grid's voxel size over the full grid's (x axis): 1 for the full grid, > 1 for a preview. 1 while the full\n * grid is not announced yet (a `segments: 'per-grid'` file, K7.12).\n */\n voxelRatio: number;\n /**\n * G16a: the grid types of the family's grids announced so far (a one-segment file lists every grid's metadata\n * before any data, so this holds the full grid's type from the first event on; a per-grid-segment file, K7.12, adds\n * each grid's type when its segment starts), in `VDB_GRID_TYPE_NAMES` order (`float, fp4, fp8, fp16, fpn, half`, not\n * alphabetical), each once. A `VDBGridNode` made with `types: event.types` decodes the\n * preview and the full grid with one module (a baked FpN preview and an Fp8 full grid differ), so a source made\n * with `followImage` swaps without a recompile.\n */\n types: VDBGridTypeName[];\n}\n\n/** Options of {@link vdbStreamCoarseFirst}. */\nexport interface VDBCoarseFirstOptions {\n /** Which family to load, by the full grid's name. Default: the first grid's family. */\n gridName?: string;\n /** Pool label for the id. Default: the full grid's name. */\n label?: string;\n /** Limits for the stream reader. */\n reader?: NvdbStreamReaderOptions;\n /**\n * Keeps a material, proxy mesh, grid node and majorant in step with each swap, before `onGrid` runs (see\n * {@link VDBCoarseFirstBind} and {@link vdbCoarseFirstApply}). Needs a pool with `flush` / `info` / `setMajorant`\n * (a `VDBGridPool`).\n */\n bind?: VDBCoarseFirstBind;\n /** Called after each `pool.add` / `pool.replace` (preview, then finer grids, then the full grid), after `bind`. */\n onGrid?: (event: VDBCoarseFirstEvent) => void;\n /** Called after every received chunk with the byte progress (K4.20). `bytesTotal` is the Response's Content-Length, else derived from the file's metadata. */\n onProgress?: (progress: NvdbProgress) => void;\n /** Aborts the read (rejects with the signal's reason; the id, if added, stays in the pool). */\n signal?: AbortSignal;\n}\n\n/** What {@link vdbStreamCoarseFirst} resolves with once the full grid is in the pool. */\nexport interface VDBCoarseFirstResult {\n /** The pool id the preview and every finer grid were shown in. */\n id: number;\n /** Every grid shown, in order (the preview(s), then the full grid). */\n shown: VDBCoarseFirstEvent[];\n /** File bytes received when the first grid was added. */\n firstBytes: number;\n /** File bytes received when the full grid replaced the preview. */\n fullBytes: number;\n /** Expected file size when the full grid arrived, or null if unknown. */\n bytesTotal: number | null;\n}\n\n/** The base density scale of each bound material (the value seen at its first swap, unless `bind.densityScale` says). */\nconst baseScale = new WeakMap<object, number>();\n\n/**\n * The work `bind` does after a swap, callable on its own from an async `onGrid` (or any code that shows a\n * {@link VDBCoarseFirstEvent}): majorant, proxy geometry, `pool.flush()` + `grids.update()`, density scale. It never\n * touches what `bind` leaves out.\n *\n * @param pool The pool the grid is in (with `flush`, `info` and `setMajorant` when `bind` needs them).\n * @param event The swap to follow, as passed to `onGrid`.\n * @param bind What to keep in step: material, proxy mesh, grid node, majorant.\n */\nexport function vdbCoarseFirstApply(\n pool: VDBCoarseFirstPoolLike & Partial<VDBCoarseFirstBindPoolLike>,\n event: VDBCoarseFirstEvent,\n bind: VDBCoarseFirstBind,\n): void {\n const need = <K extends keyof VDBCoarseFirstBindPoolLike>(name: K): NonNullable<VDBCoarseFirstBindPoolLike[K]> => {\n const fn = pool[name];\n if (typeof fn !== \"function\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `vdbStreamCoarseFirst: \\`bind\\` needs a pool with ${name}() (a VDBGridPool).`);\n }\n return fn.bind(pool) as NonNullable<VDBCoarseFirstBindPoolLike[K]>;\n };\n if (bind.majorant) {\n const majorant = bind.majorant(event);\n if (majorant) need(\"setMajorant\")(event.id, majorant);\n }\n if (bind.mesh) {\n const next = vdbProxyGeometry(need(\"info\")(event.id), bind.proxyPad === undefined ? {} : { pad: bind.proxyPad });\n bind.mesh.geometry.dispose();\n bind.mesh.geometry = next;\n }\n if (bind.grids) {\n need(\"flush\")();\n bind.grids.update();\n }\n const material = bind.material;\n if (material) {\n const base = bind.densityScale ?? baseScale.get(material) ?? material.densityScale.value;\n baseScale.set(material, base);\n material.densityScale.value = base * event.voxelRatio;\n }\n}\n\nconst familyOf = (name: string): string => parseNvdbLodName(name).baseName;\n\n/** Finest first: the full grid (lod null) beats any preview; a larger resolution beats a smaller. */\nfunction finer(a: NvdbStreamGrid, b: NvdbStreamGrid | null): boolean {\n if (b === null) return true;\n if (b.lod === null) return false;\n if (a.lod === null) return true;\n return a.lod > b.lod;\n}\n\nfunction chunks(source: VDBCoarseFirstSource): { iterate: AsyncIterable<Uint8Array>; cancel: () => Promise<void> } {\n const stream = source instanceof Response ? source.body : source;\n if (source instanceof Response && !source.ok) {\n throw new VDBError(\"VDB_BAD_OPTION\", `vdbStreamCoarseFirst: the response is ${source.status} ${source.statusText} (${source.url}).`);\n }\n if (stream === null) throw new VDBError(\"VDB_BAD_OPTION\", \"vdbStreamCoarseFirst: the response has no body.\");\n if (typeof (stream as ReadableStream<Uint8Array>).getReader === \"function\") {\n const reader = (stream as ReadableStream<Uint8Array>).getReader();\n return {\n iterate: {\n async *[Symbol.asyncIterator]() {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) return;\n yield value;\n }\n },\n },\n cancel: () => reader.cancel().catch(() => undefined),\n };\n }\n const iterable = stream as AsyncIterable<Uint8Array>;\n return { iterate: iterable, cancel: async () => undefined };\n}\n\n/**\n * Streams a coarse-first `.nvdb` into one pool id: `add` the first grid of the\n * family with the family's largest size reserved, then `replace` with each\n * finer grid. Resolves when the full grid is in the pool (the rest of the\n * stream is cancelled). Rejects with the reader's `NvdbFormatError` on bad\n * or truncated data.\n *\n * @param pool The pool the grid is added to and replaced in.\n * @param source A `fetch` `Response`, a byte `ReadableStream` or an async iterable of chunks.\n * @param options Family name, label, reader limits, `bind`, callbacks and an abort signal.\n */\nexport async function vdbStreamCoarseFirst(\n pool: VDBCoarseFirstPoolLike & Partial<VDBCoarseFirstBindPoolLike>,\n source: VDBCoarseFirstSource,\n options: VDBCoarseFirstOptions = {},\n): Promise<VDBCoarseFirstResult> {\n const signal = options.signal;\n signal?.throwIfAborted();\n const wire = source instanceof Response ? nvdbResponseLength(source) : null;\n const reader = new NvdbStreamReader({\n ...options.reader,\n ...(wire !== null && options.reader?.bytesTotal === undefined ? { bytesTotal: wire } : {}),\n ...(options.onProgress ? { onProgress: options.onProgress } : {}),\n });\n const { iterate, cancel } = chunks(source);\n\n let family = options.gridName ?? null;\n let id = -1;\n let current: NvdbStreamGrid | null = null;\n const shown: VDBCoarseFirstEvent[] = [];\n\n const familyGrids = (): NvdbGridMetadata[] => reader.grids.filter((g) => familyOf(g.name) === family);\n const fullVoxel = (grid: NvdbStreamGrid): number => {\n const full = familyGrids().find((g) => g.name === family);\n return full ? grid.metadata.voxelSize[0] / full.voxelSize[0] : 1;\n };\n // The reader accepts only the pool's scalar types (Float, Fp4, Fp8, Fp16, FpN, Half: the names in lower case).\n const familyTypes = (): VDBGridTypeName[] => {\n const names = new Set(familyGrids().map((g) => g.gridType.toLowerCase()));\n return VDB_GRID_TYPE_NAMES.filter((t) => names.has(t));\n };\n\n try {\n for await (const chunk of iterate) {\n signal?.throwIfAborted();\n for (const grid of reader.push(chunk)) {\n family ??= grid.baseName;\n if (grid.baseName !== family || !finer(grid, current)) continue;\n const final = grid.lod === null;\n let action: \"add\" | \"replace\";\n if (id < 0) {\n const capacity = Math.max(...familyGrids().map((g) => g.gridByteSize));\n id = pool.add(grid.image, { capacity, label: options.label ?? family });\n action = \"add\";\n } else {\n pool.replace(id, grid.image);\n action = \"replace\";\n }\n current = grid;\n const event: VDBCoarseFirstEvent = { id, grid, final, action, bytesReceived: grid.bytesReceived, bytesTotal: grid.bytesTotal, voxelRatio: fullVoxel(grid), types: familyTypes() };\n shown.push(event);\n if (options.bind) vdbCoarseFirstApply(pool, event, options.bind);\n options.onGrid?.(event);\n if (final) {\n await cancel();\n return { id, shown, firstBytes: shown[0]!.bytesReceived, fullBytes: grid.bytesReceived, bytesTotal: grid.bytesTotal };\n }\n }\n }\n reader.end();\n } catch (err) {\n await cancel();\n throw err;\n }\n throw new VDBError(\n \"VDB_BAD_IMAGE\",\n family === null\n ? \"vdbStreamCoarseFirst: the stream held no grid.\"\n : `vdbStreamCoarseFirst: the stream ended without the full grid \"${family}\" (grids: ${reader.grids.map((g) => g.name).join(\", \")}).`,\n );\n}\n"]}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * three.js wrappers over the core compute tools (K2.3). v1's raw-WebGPU
3
+ * kernels (`gridStats`, `valueTransform`, `decodeToAtlas` over a
4
+ * `NanoVDBGrid` and the vendored WGSL text) moved into the engine-free core
5
+ * (`core/compute/`) and now read grids from a `VDBGridPool`; these wrappers
6
+ * take the renderer instead of a device (`getDevice(renderer)`), submit their
7
+ * own encoder and return a promise.
8
+ *
9
+ * | v1 | core (`@pmndrs/vdb`) | this file (`@pmndrs/vdb/three`) |
10
+ * |---|---|---|
11
+ * | `vdbGridStatsGpu(device, grid, pnanovdbSource, opts)` | `vdbGridStats(device, pool, id, opts)` (core) → `VDBReadback` | `vdbGridStats(renderer, pool, id, opts)` → `Promise` |
12
+ * | `vdbDecodeToAtlasGpu(device, grid, pnanovdbSource, opts)` | `vdbDecodeToAtlas(device, pool, id, opts)` (core) → `VDBAtlasReadback` | `vdbDecodeToAtlas(renderer, pool, id, opts)` → `Promise`, plus a ready `Data3DTexture` |
13
+ * | `valueTransform(device, grid, pnanovdbSource, wgslBodyOrPreset)` | `vdbApplyValueTransform(pool, id, sourceImage, fnOrPreset)` (CPU + `pool.replace`) | — (use the core function) |
14
+ *
15
+ * The `vdb` prefix keeps these apart from the core functions of the same job
16
+ * (D17). For recording into your own encoder (the D8 pattern), use the core
17
+ * functions directly with `getDevice(renderer)`; then submit, and
18
+ * `job.submitted().read()`.
19
+ */
20
+ import { Data3DTexture } from "three";
21
+ import type { VDBGridPool } from "../core/pool/pool.js";
22
+ import { type VDBGridStats } from "../core/compute/stats.js";
23
+ import { type VDBAtlas, type VDBDecodeToAtlasOptions } from "../core/compute/atlas.js";
24
+ import { type VDBThreeRendererLike } from "./device.js";
25
+ /** Options of {@link vdbGridStats}. */
26
+ export interface VDBThreeGridStatsOptions {
27
+ /** Histogram bins over `[rootMin, rootMax]`. Default 256. */
28
+ histogramBins?: number;
29
+ }
30
+ /** What {@link vdbGridStats} resolves with: the core's `VDBGridStats` (v1's result plus the histogram `range`). */
31
+ export type VDBGridStatsResult = VDBGridStats;
32
+ /**
33
+ * Statistics of grid `gridId`: active-voxel min/max/mean/count and a histogram
34
+ * (see the core `gridStats`). The grid must be resident (`pool.flush()` or an
35
+ * update submitted) and the pool must live on the renderer's device. Records
36
+ * into its own encoder and submits it. Rejects (never throws) on bad input.
37
+ *
38
+ * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.
39
+ * @param pool The pool that holds the grid.
40
+ * @param gridId The grid's pool id; it must be resident.
41
+ * @param options Histogram bin count.
42
+ */
43
+ export declare function vdbGridStats(renderer: VDBThreeRendererLike, pool: VDBGridPool, gridId: number, options?: VDBThreeGridStatsOptions): Promise<VDBGridStatsResult>;
44
+ /** Options of {@link vdbDecodeToAtlas}: the core's, without the encoder/readback plumbing. */
45
+ export type VDBThreeDecodeToAtlasOptions = Omit<VDBDecodeToAtlasOptions, "encoder" | "readback">;
46
+ /** v1's result plus a `Data3DTexture` over `data`. */
47
+ export interface VDBDecodeToAtlasResult extends VDBAtlas {
48
+ /**
49
+ * `data` as a three `Data3DTexture`: `RedFormat`, `UnsignedByteType`
50
+ * (`uint8`) or `FloatType` (`float32`), linear filtering, `unpackAlignment`
51
+ * 1, `needsUpdate` set. Sample it with TSL `texture3D(texture, uvw).r`.
52
+ * Linear filtering of a `float32` atlas needs the `float32-filterable`
53
+ * feature; use `uint8` (the default) otherwise. Dispose it yourself.
54
+ *
55
+ * Texel `i` of an axis with `n` texels holds the grid at index
56
+ * `min + (i + 0.5) * (max - min + 1) / n - 0.5`: voxel `min + i` at full
57
+ * resolution (K2.6). The texture spans the voxel-centred box
58
+ * `[min - 0.5, max + 0.5]` of the index bbox (world: that box times the
59
+ * voxel size, through the grid transform).
60
+ */
61
+ texture: Data3DTexture;
62
+ }
63
+ /**
64
+ * Dense decode of grid `gridId`'s index bbox (see the core `decodeToAtlas`,
65
+ * including its voxel-centre sample convention), read back and wrapped in a
66
+ * `Data3DTexture`. Records into its own encoder and submits it.
67
+ *
68
+ * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.
69
+ * @param pool The pool that holds the grid.
70
+ * @param gridId The grid's pool id; it must be resident.
71
+ * @param options Resolution cap, filter, format and normalization range.
72
+ */
73
+ export declare function vdbDecodeToAtlas(renderer: VDBThreeRendererLike, pool: VDBGridPool, gridId: number, options?: VDBThreeDecodeToAtlasOptions): Promise<VDBDecodeToAtlasResult>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * three.js wrappers over the core compute tools (K2.3). v1's raw-WebGPU
3
+ * kernels (`gridStats`, `valueTransform`, `decodeToAtlas` over a
4
+ * `NanoVDBGrid` and the vendored WGSL text) moved into the engine-free core
5
+ * (`core/compute/`) and now read grids from a `VDBGridPool`; these wrappers
6
+ * take the renderer instead of a device (`getDevice(renderer)`), submit their
7
+ * own encoder and return a promise.
8
+ *
9
+ * | v1 | core (`@pmndrs/vdb`) | this file (`@pmndrs/vdb/three`) |
10
+ * |---|---|---|
11
+ * | `vdbGridStatsGpu(device, grid, pnanovdbSource, opts)` | `vdbGridStats(device, pool, id, opts)` (core) → `VDBReadback` | `vdbGridStats(renderer, pool, id, opts)` → `Promise` |
12
+ * | `vdbDecodeToAtlasGpu(device, grid, pnanovdbSource, opts)` | `vdbDecodeToAtlas(device, pool, id, opts)` (core) → `VDBAtlasReadback` | `vdbDecodeToAtlas(renderer, pool, id, opts)` → `Promise`, plus a ready `Data3DTexture` |
13
+ * | `valueTransform(device, grid, pnanovdbSource, wgslBodyOrPreset)` | `vdbApplyValueTransform(pool, id, sourceImage, fnOrPreset)` (CPU + `pool.replace`) | — (use the core function) |
14
+ *
15
+ * The `vdb` prefix keeps these apart from the core functions of the same job
16
+ * (D17). For recording into your own encoder (the D8 pattern), use the core
17
+ * functions directly with `getDevice(renderer)`; then submit, and
18
+ * `job.submitted().read()`.
19
+ */
20
+ import { Data3DTexture, FloatType, LinearFilter, RedFormat, UnsignedByteType } from "three";
21
+ import { vdbGridStats as vdbCoreGridStats } from "../core/compute/stats.js";
22
+ import { vdbDecodeToAtlas as vdbCoreDecodeToAtlas } from "../core/compute/atlas.js";
23
+ import { getDevice } from "./device.js";
24
+ /**
25
+ * Statistics of grid `gridId`: active-voxel min/max/mean/count and a histogram
26
+ * (see the core `gridStats`). The grid must be resident (`pool.flush()` or an
27
+ * update submitted) and the pool must live on the renderer's device. Records
28
+ * into its own encoder and submits it. Rejects (never throws) on bad input.
29
+ *
30
+ * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.
31
+ * @param pool The pool that holds the grid.
32
+ * @param gridId The grid's pool id; it must be resident.
33
+ * @param options Histogram bin count.
34
+ */
35
+ export function vdbGridStats(renderer, pool, gridId, options = {}) {
36
+ try {
37
+ return vdbCoreGridStats(getDevice(renderer), pool, gridId, options.histogramBins === undefined ? {} : { histogramBins: options.histogramBins }).read();
38
+ }
39
+ catch (e) {
40
+ return Promise.reject(e);
41
+ }
42
+ }
43
+ /**
44
+ * Dense decode of grid `gridId`'s index bbox (see the core `decodeToAtlas`,
45
+ * including its voxel-centre sample convention), read back and wrapped in a
46
+ * `Data3DTexture`. Records into its own encoder and submits it.
47
+ *
48
+ * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.
49
+ * @param pool The pool that holds the grid.
50
+ * @param gridId The grid's pool id; it must be resident.
51
+ * @param options Resolution cap, filter, format and normalization range.
52
+ */
53
+ export async function vdbDecodeToAtlas(renderer, pool, gridId, options = {}) {
54
+ const { encoder: _e, readback: _r, ...rest } = options;
55
+ const atlas = await vdbCoreDecodeToAtlas(getDevice(renderer), pool, gridId, rest).read();
56
+ const [dx, dy, dz] = atlas.dims;
57
+ const texture = new Data3DTexture(atlas.data, dx, dy, dz);
58
+ texture.format = RedFormat;
59
+ texture.type = atlas.data instanceof Uint8Array ? UnsignedByteType : FloatType;
60
+ texture.minFilter = LinearFilter;
61
+ texture.magFilter = LinearFilter;
62
+ texture.unpackAlignment = 1;
63
+ texture.needsUpdate = true;
64
+ return { ...atlas, texture };
65
+ }
66
+ //# sourceMappingURL=compute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.js","sourceRoot":"","sources":["../../src/three/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,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C,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,OAAO,CAAC,SAAS,GAAG,YAAY,CAAC;IACjC,OAAO,CAAC,SAAS,GAAG,YAAY,CAAC;IACjC,OAAO,CAAC,eAAe,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * three.js wrappers over the core compute tools (K2.3). v1's raw-WebGPU\n * kernels (`gridStats`, `valueTransform`, `decodeToAtlas` over a\n * `NanoVDBGrid` and the vendored WGSL text) moved into the engine-free core\n * (`core/compute/`) and now read grids from a `VDBGridPool`; these wrappers\n * take the renderer instead of a device (`getDevice(renderer)`), submit their\n * own encoder and return a promise.\n *\n * | v1 | core (`@pmndrs/vdb`) | this file (`@pmndrs/vdb/three`) |\n * |---|---|---|\n * | `vdbGridStatsGpu(device, grid, pnanovdbSource, opts)` | `vdbGridStats(device, pool, id, opts)` (core) → `VDBReadback` | `vdbGridStats(renderer, pool, id, opts)` → `Promise` |\n * | `vdbDecodeToAtlasGpu(device, grid, pnanovdbSource, opts)` | `vdbDecodeToAtlas(device, pool, id, opts)` (core) → `VDBAtlasReadback` | `vdbDecodeToAtlas(renderer, pool, id, opts)` → `Promise`, plus a ready `Data3DTexture` |\n * | `valueTransform(device, grid, pnanovdbSource, wgslBodyOrPreset)` | `vdbApplyValueTransform(pool, id, sourceImage, fnOrPreset)` (CPU + `pool.replace`) | — (use the core function) |\n *\n * The `vdb` prefix keeps these apart from the core functions of the same job\n * (D17). For recording into your own encoder (the D8 pattern), use the core\n * functions directly with `getDevice(renderer)`; then submit, and\n * `job.submitted().read()`.\n */\nimport { Data3DTexture, FloatType, LinearFilter, RedFormat, UnsignedByteType } from \"three\";\nimport type { VDBGridPool } from \"../core/pool/pool.js\";\nimport { vdbGridStats as vdbCoreGridStats, type VDBGridStats } from \"../core/compute/stats.js\";\nimport { vdbDecodeToAtlas as vdbCoreDecodeToAtlas, type VDBAtlas, type VDBDecodeToAtlasOptions } from \"../core/compute/atlas.js\";\nimport { getDevice, type VDBThreeRendererLike } from \"./device.js\";\n\n/** Options of {@link vdbGridStats}. */\nexport interface VDBThreeGridStatsOptions {\n /** Histogram bins over `[rootMin, rootMax]`. Default 256. */\n histogramBins?: number;\n}\n\n/** What {@link vdbGridStats} resolves with: the core's `VDBGridStats` (v1's result plus the histogram `range`). */\nexport type VDBGridStatsResult = VDBGridStats;\n\n/**\n * Statistics of grid `gridId`: active-voxel min/max/mean/count and a histogram\n * (see the core `gridStats`). The grid must be resident (`pool.flush()` or an\n * update submitted) and the pool must live on the renderer's device. Records\n * into its own encoder and submits it. Rejects (never throws) on bad input.\n *\n * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.\n * @param pool The pool that holds the grid.\n * @param gridId The grid's pool id; it must be resident.\n * @param options Histogram bin count.\n */\nexport function vdbGridStats(\n renderer: VDBThreeRendererLike,\n pool: VDBGridPool,\n gridId: number,\n options: VDBThreeGridStatsOptions = {},\n): Promise<VDBGridStatsResult> {\n try {\n return vdbCoreGridStats(getDevice(renderer), pool, gridId, options.histogramBins === undefined ? {} : { histogramBins: options.histogramBins }).read();\n } catch (e) {\n return Promise.reject(e);\n }\n}\n\n/** Options of {@link vdbDecodeToAtlas}: the core's, without the encoder/readback plumbing. */\nexport type VDBThreeDecodeToAtlasOptions = Omit<VDBDecodeToAtlasOptions, \"encoder\" | \"readback\">;\n\n/** v1's result plus a `Data3DTexture` over `data`. */\nexport interface VDBDecodeToAtlasResult extends VDBAtlas {\n /**\n * `data` as a three `Data3DTexture`: `RedFormat`, `UnsignedByteType`\n * (`uint8`) or `FloatType` (`float32`), linear filtering, `unpackAlignment`\n * 1, `needsUpdate` set. Sample it with TSL `texture3D(texture, uvw).r`.\n * Linear filtering of a `float32` atlas needs the `float32-filterable`\n * feature; use `uint8` (the default) otherwise. Dispose it yourself.\n *\n * Texel `i` of an axis with `n` texels holds the grid at index\n * `min + (i + 0.5) * (max - min + 1) / n - 0.5`: voxel `min + i` at full\n * resolution (K2.6). The texture spans the voxel-centred box\n * `[min - 0.5, max + 0.5]` of the index bbox (world: that box times the\n * voxel size, through the grid transform).\n */\n texture: Data3DTexture;\n}\n\n/**\n * Dense decode of grid `gridId`'s index bbox (see the core `decodeToAtlas`,\n * including its voxel-centre sample convention), read back and wrapped in a\n * `Data3DTexture`. Records into its own encoder and submits it.\n *\n * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.\n * @param pool The pool that holds the grid.\n * @param gridId The grid's pool id; it must be resident.\n * @param options Resolution cap, filter, format and normalization range.\n */\nexport async function vdbDecodeToAtlas(\n renderer: VDBThreeRendererLike,\n pool: VDBGridPool,\n gridId: number,\n options: VDBThreeDecodeToAtlasOptions = {},\n): Promise<VDBDecodeToAtlasResult> {\n const { encoder: _e, readback: _r, ...rest } = options as VDBDecodeToAtlasOptions;\n const atlas = await vdbCoreDecodeToAtlas(getDevice(renderer), pool, gridId, rest).read();\n const [dx, dy, dz] = atlas.dims;\n const texture = new Data3DTexture(atlas.data, dx, dy, dz);\n texture.format = RedFormat;\n texture.type = atlas.data instanceof Uint8Array ? UnsignedByteType : FloatType;\n texture.minFilter = LinearFilter;\n texture.magFilter = LinearFilter;\n texture.unpackAlignment = 1;\n texture.needsUpdate = true;\n return { ...atlas, texture };\n}\n"]}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The raw WebGPU handles behind a three.js `WebGPURenderer` (task K2.1).
3
+ *
4
+ * Same helpers and semantics as `@pmndrs/upscaler` and `@pmndrs/denoiser`
5
+ * (`getDevice`, `getGPUTexture`), so every pmndrs tool in a frame shares the
6
+ * renderer's one `GPUDevice`: create the pool with
7
+ * `VDBGridPool.create(getDevice(renderer))`.
8
+ *
9
+ * Typed structurally (`VDBThreeRendererLike`, the downsampler's pattern), so this
10
+ * file needs nothing from three at runtime. It reads two backend internals,
11
+ * checked against three r187 (the peer range):
12
+ * - `renderer.backend.device`: the `GPUDevice` (null until `renderer.init()`
13
+ * resolves; absent on the WebGL fallback backend);
14
+ * - `renderer.backend.get(texture).texture`: the `GPUTexture` behind a three
15
+ * texture once it is allocated.
16
+ *
17
+ * A renderer built without a `device` parameter owns its device and destroys
18
+ * it in `renderer.dispose()`, and with it every buffer on it (the pool's
19
+ * too). To keep a pool alive past the renderer, create the device yourself and
20
+ * pass it: `new WebGPURenderer({ device })`.
21
+ */
22
+ /** The parts of three's WebGPU backend the adapter reads (structural, three r187). */
23
+ export interface VDBThreeBackendLike {
24
+ /** True on three's WebGPU backend (false on the WebGL fallback). */
25
+ readonly isWebGPUBackend?: boolean;
26
+ /** The backend's `GPUDevice`, set once the renderer is initialized. */
27
+ readonly device?: GPUDevice | null;
28
+ /** three's per-object backend record (texture or buffer data). */
29
+ get(object: object): {
30
+ texture?: GPUTexture;
31
+ buffer?: GPUBuffer;
32
+ } & Record<string, unknown>;
33
+ }
34
+ /**
35
+ * The part of a three.js `WebGPURenderer` the adapter uses (structural, so
36
+ * `three` stays an optional peer). `backend` is typed loosely because
37
+ * `@types/three` does not declare the internals read here (`get`); they are
38
+ * checked at runtime instead.
39
+ */
40
+ export interface VDBThreeRendererLike {
41
+ /** The renderer's backend object (checked at runtime). */
42
+ readonly backend: object;
43
+ }
44
+ /** Throws unless `renderer` is an initialized `WebGPURenderer` on its WebGPU backend; returns that backend. */
45
+ export declare function webgpuBackendOf(renderer: unknown, what?: string): VDBThreeBackendLike & {
46
+ readonly device: GPUDevice;
47
+ };
48
+ /**
49
+ * The `GPUDevice` an initialized `WebGPURenderer` renders with. Create the
50
+ * pool (and the other pmndrs tools) on it so they share one device.
51
+ *
52
+ * @throws VDBError `VDB_UNSUPPORTED_DEVICE` before `await renderer.init()`, or on the WebGL fallback backend.
53
+ */
54
+ export declare function getDevice(renderer: VDBThreeRendererLike): GPUDevice;
55
+ /**
56
+ * The raw `GPUTexture` behind a three texture (render-target attachment,
57
+ * `DepthTexture`, `StorageTexture`...). It must already be allocated: render to
58
+ * it once or call `renderer.initTexture(texture)`.
59
+ *
60
+ * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.
61
+ * @param texture The three texture (or render-target attachment) to look up.
62
+ *
63
+ * @throws VDBError `VDB_UNSUPPORTED_DEVICE` for an uninitialized or non-WebGPU
64
+ * renderer; `VDB_BAD_OPTION` if the texture has no GPU allocation yet.
65
+ */
66
+ export declare function getGPUTexture(renderer: VDBThreeRendererLike, texture: object): GPUTexture;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The raw WebGPU handles behind a three.js `WebGPURenderer` (task K2.1).
3
+ *
4
+ * Same helpers and semantics as `@pmndrs/upscaler` and `@pmndrs/denoiser`
5
+ * (`getDevice`, `getGPUTexture`), so every pmndrs tool in a frame shares the
6
+ * renderer's one `GPUDevice`: create the pool with
7
+ * `VDBGridPool.create(getDevice(renderer))`.
8
+ *
9
+ * Typed structurally (`VDBThreeRendererLike`, the downsampler's pattern), so this
10
+ * file needs nothing from three at runtime. It reads two backend internals,
11
+ * checked against three r187 (the peer range):
12
+ * - `renderer.backend.device`: the `GPUDevice` (null until `renderer.init()`
13
+ * resolves; absent on the WebGL fallback backend);
14
+ * - `renderer.backend.get(texture).texture`: the `GPUTexture` behind a three
15
+ * texture once it is allocated.
16
+ *
17
+ * A renderer built without a `device` parameter owns its device and destroys
18
+ * it in `renderer.dispose()`, and with it every buffer on it (the pool's
19
+ * too). To keep a pool alive past the renderer, create the device yourself and
20
+ * pass it: `new WebGPURenderer({ device })`.
21
+ */
22
+ import { VDBError } from "../core/errors.js";
23
+ /** Throws unless `renderer` is an initialized `WebGPURenderer` on its WebGPU backend; returns that backend. */
24
+ export function webgpuBackendOf(renderer, what = "getDevice") {
25
+ const backend = renderer?.backend;
26
+ if (backend?.isWebGPUBackend !== true || !backend.device || typeof backend.get !== "function") {
27
+ throw new VDBError("VDB_UNSUPPORTED_DEVICE", `three adapter: ${what} requires an initialized WebGPURenderer (await renderer.init()) on its WebGPU backend; ` +
28
+ "the WebGL fallback backend has no GPUDevice.");
29
+ }
30
+ return backend;
31
+ }
32
+ /**
33
+ * The `GPUDevice` an initialized `WebGPURenderer` renders with. Create the
34
+ * pool (and the other pmndrs tools) on it so they share one device.
35
+ *
36
+ * @throws VDBError `VDB_UNSUPPORTED_DEVICE` before `await renderer.init()`, or on the WebGL fallback backend.
37
+ */
38
+ export function getDevice(renderer) {
39
+ return webgpuBackendOf(renderer, "getDevice").device;
40
+ }
41
+ /**
42
+ * The raw `GPUTexture` behind a three texture (render-target attachment,
43
+ * `DepthTexture`, `StorageTexture`...). It must already be allocated: render to
44
+ * it once or call `renderer.initTexture(texture)`.
45
+ *
46
+ * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.
47
+ * @param texture The three texture (or render-target attachment) to look up.
48
+ *
49
+ * @throws VDBError `VDB_UNSUPPORTED_DEVICE` for an uninitialized or non-WebGPU
50
+ * renderer; `VDB_BAD_OPTION` if the texture has no GPU allocation yet.
51
+ */
52
+ export function getGPUTexture(renderer, texture) {
53
+ const backend = webgpuBackendOf(renderer, "getGPUTexture");
54
+ const gpuTexture = backend.get(texture)?.texture;
55
+ if (!gpuTexture) {
56
+ const named = texture;
57
+ throw new VDBError("VDB_BAD_OPTION", `three adapter: no GPUTexture behind "${named.name || named.uuid || "texture"}" yet. ` +
58
+ "Render to it once or call renderer.initTexture(texture) first.");
59
+ }
60
+ return gpuTexture;
61
+ }
62
+ //# sourceMappingURL=device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/three/device.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAuB7C,+GAA+G;AAC/G,MAAM,UAAU,eAAe,CAAC,QAAiB,EAAE,IAAI,GAAG,WAAW;IACnE,MAAM,OAAO,GAAI,QAAiE,EAAE,OAAO,CAAC;IAC5F,IAAI,OAAO,EAAE,eAAe,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QAC9F,MAAM,IAAI,QAAQ,CAChB,wBAAwB,EACxB,kBAAkB,IAAI,yFAAyF;YAC7G,8CAA8C,CACjD,CAAC;IACJ,CAAC;IACD,OAAO,OAA+D,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,QAA8B;IACtD,OAAO,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC;AACvD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,QAA8B,EAAE,OAAe;IAC3E,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IACjD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,KAAK,GAAG,OAA2C,CAAC;QAC1D,MAAM,IAAI,QAAQ,CAChB,gBAAgB,EAChB,wCAAwC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,SAAS,SAAS;YACpF,gEAAgE,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/**\n * The raw WebGPU handles behind a three.js `WebGPURenderer` (task K2.1).\n *\n * Same helpers and semantics as `@pmndrs/upscaler` and `@pmndrs/denoiser`\n * (`getDevice`, `getGPUTexture`), so every pmndrs tool in a frame shares the\n * renderer's one `GPUDevice`: create the pool with\n * `VDBGridPool.create(getDevice(renderer))`.\n *\n * Typed structurally (`VDBThreeRendererLike`, the downsampler's pattern), so this\n * file needs nothing from three at runtime. It reads two backend internals,\n * checked against three r187 (the peer range):\n * - `renderer.backend.device`: the `GPUDevice` (null until `renderer.init()`\n * resolves; absent on the WebGL fallback backend);\n * - `renderer.backend.get(texture).texture`: the `GPUTexture` behind a three\n * texture once it is allocated.\n *\n * A renderer built without a `device` parameter owns its device and destroys\n * it in `renderer.dispose()`, and with it every buffer on it (the pool's\n * too). To keep a pool alive past the renderer, create the device yourself and\n * pass it: `new WebGPURenderer({ device })`.\n */\n\nimport { VDBError } from \"../core/errors.js\";\n\n/** The parts of three's WebGPU backend the adapter reads (structural, three r187). */\nexport interface VDBThreeBackendLike {\n /** True on three's WebGPU backend (false on the WebGL fallback). */\n readonly isWebGPUBackend?: boolean;\n /** The backend's `GPUDevice`, set once the renderer is initialized. */\n readonly device?: GPUDevice | null;\n /** three's per-object backend record (texture or buffer data). */\n get(object: object): { texture?: GPUTexture; buffer?: GPUBuffer } & Record<string, unknown>;\n}\n\n/**\n * The part of a three.js `WebGPURenderer` the adapter uses (structural, so\n * `three` stays an optional peer). `backend` is typed loosely because\n * `@types/three` does not declare the internals read here (`get`); they are\n * checked at runtime instead.\n */\nexport interface VDBThreeRendererLike {\n /** The renderer's backend object (checked at runtime). */\n readonly backend: object;\n}\n\n/** Throws unless `renderer` is an initialized `WebGPURenderer` on its WebGPU backend; returns that backend. */\nexport function webgpuBackendOf(renderer: unknown, what = \"getDevice\"): VDBThreeBackendLike & { readonly device: GPUDevice } {\n const backend = (renderer as { backend?: VDBThreeBackendLike } | null | undefined)?.backend;\n if (backend?.isWebGPUBackend !== true || !backend.device || typeof backend.get !== \"function\") {\n throw new VDBError(\n \"VDB_UNSUPPORTED_DEVICE\",\n `three adapter: ${what} requires an initialized WebGPURenderer (await renderer.init()) on its WebGPU backend; ` +\n \"the WebGL fallback backend has no GPUDevice.\",\n );\n }\n return backend as VDBThreeBackendLike & { readonly device: GPUDevice };\n}\n\n/**\n * The `GPUDevice` an initialized `WebGPURenderer` renders with. Create the\n * pool (and the other pmndrs tools) on it so they share one device.\n *\n * @throws VDBError `VDB_UNSUPPORTED_DEVICE` before `await renderer.init()`, or on the WebGL fallback backend.\n */\nexport function getDevice(renderer: VDBThreeRendererLike): GPUDevice {\n return webgpuBackendOf(renderer, \"getDevice\").device;\n}\n\n/**\n * The raw `GPUTexture` behind a three texture (render-target attachment,\n * `DepthTexture`, `StorageTexture`...). It must already be allocated: render to\n * it once or call `renderer.initTexture(texture)`.\n *\n * @param renderer The initialized `WebGPURenderer` whose device the pool lives on.\n * @param texture The three texture (or render-target attachment) to look up.\n *\n * @throws VDBError `VDB_UNSUPPORTED_DEVICE` for an uninitialized or non-WebGPU\n * renderer; `VDB_BAD_OPTION` if the texture has no GPU allocation yet.\n */\nexport function getGPUTexture(renderer: VDBThreeRendererLike, texture: object): GPUTexture {\n const backend = webgpuBackendOf(renderer, \"getGPUTexture\");\n const gpuTexture = backend.get(texture)?.texture;\n if (!gpuTexture) {\n const named = texture as { name?: string; uuid?: string };\n throw new VDBError(\n \"VDB_BAD_OPTION\",\n `three adapter: no GPUTexture behind \"${named.name || named.uuid || \"texture\"}\" yet. ` +\n \"Render to it once or call renderer.initTexture(texture) first.\",\n );\n }\n return gpuTexture;\n}\n"]}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * K6.2b: `scene.environment` as the core renderer's environment input (design §2.3, Q3). The core reads a host equirect
3
+ * or cube `GPUTexture` directly, so the adapter passes the scene environment's own texture (no readback, no PMREM):
4
+ *
5
+ * - an equirect texture (`EquirectangularReflectionMapping` / `RefractionMapping`): its GPUTexture; three uploads
6
+ * `flipY` images bottom row first, and three samples GPU row 0 at v = 0 (the nadir: `equirectUV`) for every equirect,
7
+ * `flipY` or not (a DataTexture's data row 0 is its v = 0): a reflection of y joins the rotation (K6.8: also for
8
+ * `flipY: false` textures, which K6.2b left unflipped, so a synthetic data sky lit the volume from below);
9
+ * - a cube texture: its GPUTexture as a 6-layer cube; three's WebGPU cube lookups negate x (`CubeTextureNode`), so a
10
+ * reflection of x joins the rotation;
11
+ * - anything else (a PMREM `CubeUVReflectionMapping` atlas, a render-target cube): drawn once into a 1024 × 512 float
12
+ * lat-long target through three's PMREM sampler at roughness 0 (the scene rotation applied there), and that target's
13
+ * GPUTexture is passed (redrawn only when the environment or its rotation changes).
14
+ *
15
+ * The rotation is `scene.environmentRotation` the way three applies it (`materialEnvRotation`: the transposed Euler
16
+ * matrix), so the core's lights and SH sit where three's PMREM lookups put them. Intensity: `scene.environmentIntensity`.
17
+ */
18
+ import * as THREE from "three";
19
+ import type { VDBFrameEnvironment } from "../../core/frame/types.js";
20
+ type SceneLike = THREE.Object3D & {
21
+ environment?: THREE.Texture | null;
22
+ environmentIntensity?: number;
23
+ environmentRotation?: THREE.Euler;
24
+ };
25
+ type RendererLike = {
26
+ initTexture?(t: THREE.Texture): void;
27
+ setRenderTarget(t: THREE.RenderTarget | null): void;
28
+ getRenderTarget(): THREE.RenderTarget | null;
29
+ render(s: THREE.Object3D, c: THREE.Camera): void;
30
+ };
31
+ /** @internal The environment input of the `./three` core backend. */
32
+ export declare class VDBCoreEnvironment {
33
+ #private;
34
+ /** The core input for `scene` (null without an environment). */
35
+ input(renderer: RendererLike, scene: SceneLike): VDBFrameEnvironment | null;
36
+ dispose(): void;
37
+ }
38
+ export {};
@@ -0,0 +1,154 @@
1
+ /**
2
+ * K6.2b: `scene.environment` as the core renderer's environment input (design §2.3, Q3). The core reads a host equirect
3
+ * or cube `GPUTexture` directly, so the adapter passes the scene environment's own texture (no readback, no PMREM):
4
+ *
5
+ * - an equirect texture (`EquirectangularReflectionMapping` / `RefractionMapping`): its GPUTexture; three uploads
6
+ * `flipY` images bottom row first, and three samples GPU row 0 at v = 0 (the nadir: `equirectUV`) for every equirect,
7
+ * `flipY` or not (a DataTexture's data row 0 is its v = 0): a reflection of y joins the rotation (K6.8: also for
8
+ * `flipY: false` textures, which K6.2b left unflipped, so a synthetic data sky lit the volume from below);
9
+ * - a cube texture: its GPUTexture as a 6-layer cube; three's WebGPU cube lookups negate x (`CubeTextureNode`), so a
10
+ * reflection of x joins the rotation;
11
+ * - anything else (a PMREM `CubeUVReflectionMapping` atlas, a render-target cube): drawn once into a 1024 × 512 float
12
+ * lat-long target through three's PMREM sampler at roughness 0 (the scene rotation applied there), and that target's
13
+ * GPUTexture is passed (redrawn only when the environment or its rotation changes).
14
+ *
15
+ * The rotation is `scene.environmentRotation` the way three applies it (`materialEnvRotation`: the transposed Euler
16
+ * matrix), so the core's lights and SH sit where three's PMREM lookups put them. Intensity: `scene.environmentIntensity`.
17
+ */
18
+ import * as THREE from "three";
19
+ import { NodeMaterial } from "three/webgpu";
20
+ import * as TSL from "three/tsl";
21
+ import { getGPUTexture } from "../device.js";
22
+ const { Fn, cos, float, pmremTexture, positionGeometry, screenCoordinate, sin, vec2, vec3, vec4 } = TSL;
23
+ /** The lat-long fallback's size: about one texel per PMREM mip-0 texel (0.35°), so a small sun is not lost between point samples. */
24
+ const LATLONG = [1024, 512];
25
+ /**
26
+ * A lat-long of the scene environment in the core's equirect convention (row 0 the zenith, u = atan2(z, x) / 2π + ½),
27
+ * through three's PMREM sampler at roughness 0 (his FrameEnvironmentMaterial: the PMREM node needs a texture, so a new
28
+ * or removed environment builds the shader again; no own envMap, so the PMREM rotation reads the pass scene's).
29
+ */
30
+ class VDBCoreLatLongMaterial extends NodeMaterial {
31
+ environment = null;
32
+ environmentNodes = [];
33
+ constructor() {
34
+ super();
35
+ this.envMap = null;
36
+ this.name = "VDBCoreLatLongMaterial";
37
+ this.vertexNode = vec4(positionGeometry.xy, 0.0, 1.0);
38
+ this.fragmentNode = this.createFragmentNode();
39
+ this.side = THREE.DoubleSide;
40
+ this.forceSinglePass = true;
41
+ this.depthTest = false;
42
+ this.depthWrite = false;
43
+ this.blending = THREE.NoBlending;
44
+ }
45
+ setEnvironment(environment) {
46
+ const next = environment ?? null;
47
+ if (!!next !== !!this.environment) {
48
+ this.environment = next;
49
+ this.environmentNodes = [];
50
+ this.fragmentNode = this.createFragmentNode();
51
+ this.needsUpdate = true;
52
+ }
53
+ else if (next && this.environment !== next) {
54
+ this.environment = next;
55
+ this.environmentNodes.forEach((node) => {
56
+ node.value = next;
57
+ });
58
+ }
59
+ }
60
+ // NOTE Radiance of the PMREM environment at the roughness. Rotation is from the pass scene, intensity is not applied.
61
+ environmentRadiance(direction, roughness) {
62
+ const node = pmremTexture(this.environment, direction, float(roughness));
63
+ this.environmentNodes.push(node);
64
+ return node;
65
+ }
66
+ createFragmentNode() {
67
+ return Fn(() => {
68
+ // WebGPU: screenCoordinate.y is the render target row (0 at the top)
69
+ const uv = vec2(screenCoordinate.x, screenCoordinate.y).div(vec2(LATLONG[0], LATLONG[1])).toVar();
70
+ const theta = uv.y.mul(Math.PI);
71
+ const phi = uv.x.sub(0.5).mul(2.0 * Math.PI);
72
+ const direction = vec3(sin(theta).mul(cos(phi)), cos(theta), sin(theta).mul(sin(phi)));
73
+ if (!this.environment)
74
+ return vec4(0.0, 0.0, 0.0, 1.0);
75
+ return vec4(this.environmentRadiance(direction, 0.0), float(1.0));
76
+ })();
77
+ }
78
+ }
79
+ /** @internal The environment input of the `./three` core backend. */
80
+ export class VDBCoreEnvironment {
81
+ #material = null;
82
+ #scene = null;
83
+ #camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
84
+ #target = null;
85
+ #drawnKey = "";
86
+ #drawn = 0;
87
+ #initialized = new WeakMap();
88
+ #euler = new THREE.Matrix4();
89
+ /** The core input for `scene` (null without an environment). */
90
+ input(renderer, scene) {
91
+ const env = scene.environment;
92
+ if (!env)
93
+ return null;
94
+ const intensity = scene.environmentIntensity ?? 1;
95
+ const t = env;
96
+ const equirect = (t.mapping === THREE.EquirectangularReflectionMapping || t.mapping === THREE.EquirectangularRefractionMapping) && !t.isRenderTargetTexture;
97
+ const cube = !!t.isCubeTexture && !t.isRenderTargetTexture && (t.mapping === THREE.CubeReflectionMapping || t.mapping === THREE.CubeRefractionMapping);
98
+ // three's lookup direction m = Rᵀ d (materialEnvRotation is the transposed Euler matrix)
99
+ this.#euler.makeRotationFromEuler(scene.environmentRotation ?? new THREE.Euler());
100
+ const e = this.#euler.elements;
101
+ if (equirect || cube) {
102
+ if (this.#initialized.get(t) !== t.version) {
103
+ renderer.initTexture?.(t);
104
+ this.#initialized.set(t, t.version);
105
+ }
106
+ // world → map: F · Rᵀ (column-major; Rᵀ's column c is R's row c)
107
+ const flip = cube ? [-1, 1, 1] : [1, -1, 1];
108
+ const rotation = new Float32Array(9);
109
+ for (let c = 0; c < 3; c++)
110
+ for (let r = 0; r < 3; r++)
111
+ rotation[c * 3 + r] = flip[r] * e[r * 4 + c];
112
+ return { id: t, revision: t.version, texture: getGPUTexture(renderer, t), projection: cube ? "cube" : "equirect", rotation, intensity };
113
+ }
114
+ // A PMREM atlas or a render-target cube: the lat-long fallback (rotation applied by three's PMREM sampler)
115
+ const r = scene.environmentRotation;
116
+ const key = `${t.uuid}:${t.version}:${r ? `${r.x}:${r.y}:${r.z}:${r.order}` : ""}`;
117
+ const target = this.#latLong(renderer, scene, key);
118
+ return { id: this, revision: this.#drawn, texture: getGPUTexture(renderer, target.texture), projection: "equirect", intensity };
119
+ }
120
+ #latLong(renderer, scene, key) {
121
+ if (!this.#target) {
122
+ this.#target = new THREE.RenderTarget(LATLONG[0], LATLONG[1], { type: THREE.HalfFloatType, depthBuffer: false, magFilter: THREE.NearestFilter, minFilter: THREE.NearestFilter, generateMipmaps: false });
123
+ this.#material = new VDBCoreLatLongMaterial();
124
+ this.#scene = new THREE.Scene();
125
+ const mesh = new THREE.Mesh(new THREE.BufferGeometry().setAttribute("position", new THREE.Float32BufferAttribute([-1, -1, 0, 3, -1, 0, -1, 3, 0], 3)), this.#material);
126
+ mesh.frustumCulled = false;
127
+ this.#scene.add(mesh);
128
+ }
129
+ if (key !== this.#drawnKey) {
130
+ const s = this.#scene;
131
+ s.environment = scene.environment ?? null;
132
+ s.environmentIntensity = 1;
133
+ if (scene.environmentRotation)
134
+ s.environmentRotation.copy(scene.environmentRotation);
135
+ this.#material.setEnvironment(scene.environment);
136
+ const previous = renderer.getRenderTarget();
137
+ renderer.setRenderTarget(this.#target);
138
+ renderer.render(s, this.#camera);
139
+ renderer.setRenderTarget(previous);
140
+ this.#drawnKey = key;
141
+ this.#drawn++;
142
+ }
143
+ return this.#target;
144
+ }
145
+ dispose() {
146
+ this.#target?.dispose();
147
+ this.#material?.dispose();
148
+ this.#target = null;
149
+ this.#material = null;
150
+ this.#scene = null;
151
+ this.#drawnKey = "";
152
+ }
153
+ }
154
+ //# sourceMappingURL=core-environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-environment.js","sourceRoot":"","sources":["../../../src/three/frame/core-environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAA4C,CAAC;AAEjJ,qIAAqI;AACrI,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,CAAU,CAAC;AAKrC;;;;GAIG;AACH,MAAM,sBAAuB,SAAQ,YAAY;IAC/C,WAAW,GAAyB,IAAI,CAAC;IACzC,gBAAgB,GAAiB,EAAE,CAAC;IAEpC;QACE,KAAK,EAAE,CAAC;QACP,IAAoD,CAAC,MAAM,GAAG,IAAI,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,UAA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AAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,IAAI,GAAG,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,MAAO,CAAC;YACvB,CAAC,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC;YAC1C,CAAC,CAAC,oBAAoB,GAAG,CAAC,CAAC;YAC3B,IAAI,KAAK,CAAC,mBAAmB;gBAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACrF,IAAI,CAAC,SAAU,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAClD,MAAM,QAAQ,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;YAC5C,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACjC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;YACrB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,OAAQ,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;CACF","sourcesContent":["/**\n * K6.2b: `scene.environment` as the core renderer's environment input (design §2.3, Q3). The core reads a host equirect\n * or cube `GPUTexture` directly, so the adapter passes the scene environment's own texture (no readback, no PMREM):\n *\n * - an equirect texture (`EquirectangularReflectionMapping` / `RefractionMapping`): its GPUTexture; three uploads\n * `flipY` images bottom row first, and three samples GPU row 0 at v = 0 (the nadir: `equirectUV`) for every equirect,\n * `flipY` or not (a DataTexture's data row 0 is its v = 0): a reflection of y joins the rotation (K6.8: also for\n * `flipY: false` textures, which K6.2b left unflipped, so a synthetic data sky lit the volume from below);\n * - a cube texture: its GPUTexture as a 6-layer cube; three's WebGPU cube lookups negate x (`CubeTextureNode`), so a\n * reflection of x joins the rotation;\n * - anything else (a PMREM `CubeUVReflectionMapping` atlas, a render-target cube): drawn once into a 1024 × 512 float\n * lat-long target through three's PMREM sampler at roughness 0 (the scene rotation applied there), and that target's\n * GPUTexture is passed (redrawn only when the environment or its rotation changes).\n *\n * The rotation is `scene.environmentRotation` the way three applies it (`materialEnvRotation`: the transposed Euler\n * matrix), so the core's lights and SH sit where three's PMREM lookups put them. Intensity: `scene.environmentIntensity`.\n */\n\nimport * as THREE from \"three\";\nimport { NodeMaterial } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport type { VDBFrameEnvironment } from \"../../core/frame/types.js\";\nimport { getGPUTexture } from \"../device.js\";\n\nconst { Fn, cos, float, pmremTexture, positionGeometry, screenCoordinate, sin, vec2, vec3, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\n/** The lat-long fallback's size: about one texel per PMREM mip-0 texel (0.35°), so a small sun is not lost between point samples. */\nconst LATLONG = [1024, 512] as const;\n\ntype SceneLike = THREE.Object3D & { environment?: THREE.Texture | null; environmentIntensity?: number; environmentRotation?: THREE.Euler };\ntype RendererLike = { initTexture?(t: THREE.Texture): void; setRenderTarget(t: THREE.RenderTarget | null): void; getRenderTarget(): THREE.RenderTarget | null; render(s: THREE.Object3D, c: THREE.Camera): void };\n\n/**\n * A lat-long of the scene environment in the core's equirect convention (row 0 the zenith, u = atan2(z, x) / 2π + ½),\n * through three's PMREM sampler at roughness 0 (his FrameEnvironmentMaterial: the PMREM node needs a texture, so a new\n * or removed environment builds the shader again; no own envMap, so the PMREM rotation reads the pass scene's).\n */\nclass VDBCoreLatLongMaterial extends NodeMaterial {\n environment: THREE.Texture | null = null;\n environmentNodes: VDBTslNode[] = [];\n\n constructor() {\n super();\n (this as unknown as { envMap: THREE.Texture | null }).envMap = null;\n this.name = \"VDBCoreLatLongMaterial\";\n this.vertexNode = vec4(positionGeometry.xy, 0.0, 1.0);\n this.fragmentNode = this.createFragmentNode();\n this.side = THREE.DoubleSide;\n this.forceSinglePass = true;\n this.depthTest = false;\n this.depthWrite = false;\n this.blending = THREE.NoBlending;\n }\n\n setEnvironment(environment: THREE.Texture | null | undefined): void {\n const next = environment ?? null;\n if (!!next !== !!this.environment) {\n this.environment = next;\n this.environmentNodes = [];\n this.fragmentNode = this.createFragmentNode();\n this.needsUpdate = true;\n } else if (next && this.environment !== next) {\n this.environment = next;\n this.environmentNodes.forEach((node) => {\n node.value = next;\n });\n }\n }\n\n // NOTE Radiance of the PMREM environment at the roughness. Rotation is from the pass scene, intensity is not applied.\n environmentRadiance(direction: VDBTslNode, roughness: number): VDBTslNode {\n const node = pmremTexture(this.environment, direction, float(roughness));\n this.environmentNodes.push(node);\n return node;\n }\n\n createFragmentNode(): VDBTslNode {\n return Fn(() => {\n // WebGPU: screenCoordinate.y is the render target row (0 at the top)\n const uv = vec2(screenCoordinate.x, screenCoordinate.y).div(vec2(LATLONG[0], LATLONG[1])).toVar();\n const theta = uv.y.mul(Math.PI);\n const phi = uv.x.sub(0.5).mul(2.0 * Math.PI);\n const direction = vec3(sin(theta).mul(cos(phi)), cos(theta), sin(theta).mul(sin(phi)));\n if (!this.environment) return vec4(0.0, 0.0, 0.0, 1.0);\n return vec4(this.environmentRadiance(direction, 0.0), float(1.0));\n })();\n }\n}\n\n/** @internal The environment input of the `./three` core backend. */\nexport class VDBCoreEnvironment {\n #material: VDBCoreLatLongMaterial | null = null;\n #scene: THREE.Scene | null = null;\n #camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);\n #target: THREE.RenderTarget | null = null;\n #drawnKey = \"\";\n #drawn = 0;\n #initialized = new WeakMap<THREE.Texture, number>();\n readonly #euler = new THREE.Matrix4();\n\n /** The core input for `scene` (null without an environment). */\n input(renderer: RendererLike, scene: SceneLike): VDBFrameEnvironment | null {\n const env = scene.environment;\n if (!env) return null;\n const intensity = scene.environmentIntensity ?? 1;\n const t = env as THREE.Texture & { isCubeTexture?: boolean; isRenderTargetTexture?: boolean; isDataTexture?: boolean };\n const equirect = (t.mapping === THREE.EquirectangularReflectionMapping || t.mapping === THREE.EquirectangularRefractionMapping) && !t.isRenderTargetTexture;\n const cube = !!t.isCubeTexture && !t.isRenderTargetTexture && (t.mapping === THREE.CubeReflectionMapping || t.mapping === THREE.CubeRefractionMapping);\n // three's lookup direction m = Rᵀ d (materialEnvRotation is the transposed Euler matrix)\n this.#euler.makeRotationFromEuler(scene.environmentRotation ?? new THREE.Euler());\n const e = this.#euler.elements;\n if (equirect || cube) {\n if (this.#initialized.get(t) !== t.version) {\n renderer.initTexture?.(t);\n this.#initialized.set(t, t.version);\n }\n // world → map: F · Rᵀ (column-major; Rᵀ's column c is R's row c)\n const flip = cube ? [-1, 1, 1] : [1, -1, 1];\n const rotation = new Float32Array(9);\n for (let c = 0; c < 3; c++) for (let r = 0; r < 3; r++) rotation[c * 3 + r] = flip[r]! * e[r * 4 + c]!;\n return { id: t, revision: t.version, texture: getGPUTexture(renderer as never, t), projection: cube ? \"cube\" : \"equirect\", rotation, intensity };\n }\n // A PMREM atlas or a render-target cube: the lat-long fallback (rotation applied by three's PMREM sampler)\n const r = scene.environmentRotation;\n const key = `${t.uuid}:${t.version}:${r ? `${r.x}:${r.y}:${r.z}:${r.order}` : \"\"}`;\n const target = this.#latLong(renderer, scene, key);\n return { id: this, revision: this.#drawn, texture: getGPUTexture(renderer as never, target.texture), projection: \"equirect\", intensity };\n }\n\n #latLong(renderer: RendererLike, scene: SceneLike, key: string): THREE.RenderTarget {\n if (!this.#target) {\n this.#target = new THREE.RenderTarget(LATLONG[0], LATLONG[1], { type: THREE.HalfFloatType, depthBuffer: false, magFilter: THREE.NearestFilter, minFilter: THREE.NearestFilter, generateMipmaps: false });\n this.#material = new VDBCoreLatLongMaterial();\n this.#scene = new THREE.Scene();\n const mesh = new THREE.Mesh(new THREE.BufferGeometry().setAttribute(\"position\", new THREE.Float32BufferAttribute([-1, -1, 0, 3, -1, 0, -1, 3, 0], 3)), this.#material as unknown as NodeMaterial);\n mesh.frustumCulled = false;\n this.#scene.add(mesh);\n }\n if (key !== this.#drawnKey) {\n const s = this.#scene!;\n s.environment = scene.environment ?? null;\n s.environmentIntensity = 1;\n if (scene.environmentRotation) s.environmentRotation.copy(scene.environmentRotation);\n this.#material!.setEnvironment(scene.environment);\n const previous = renderer.getRenderTarget();\n renderer.setRenderTarget(this.#target);\n renderer.render(s, this.#camera);\n renderer.setRenderTarget(previous);\n this.#drawnKey = key;\n this.#drawn++;\n }\n return this.#target!;\n }\n\n dispose(): void {\n this.#target?.dispose();\n this.#material?.dispose();\n this.#target = null;\n this.#material = null;\n this.#scene = null;\n this.#drawnKey = \"\";\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ import { NodeMaterial } from "three/webgpu";
2
+ import type { VDBTslNode } from "../grid-node.js";
3
+ import type { VDBFroxelLayout } from "../../core/frame/types.js";
4
+ export declare class VDBFrameCoreIntegrateMaterial extends NodeMaterial {
5
+ #private;
6
+ /** The prefix texture node: its `value` is the stand-in of `outputs.froxels.integrated`. */
7
+ readonly prefix: VDBTslNode;
8
+ /** K6.4: the alpha prefix (`outputs.froxels.integratedAlpha`: red, blue opacity) of spectral media. */
9
+ readonly alphaPrefix: VDBTslNode;
10
+ readonly frameGrid: any;
11
+ readonly frameRange: any;
12
+ readonly frameScreenRect: any;
13
+ readonly frameCameraNear: any;
14
+ readonly frameCameraFar: any;
15
+ readonly frameCameraOrthographic: any;
16
+ srgbBlending: boolean | null;
17
+ srgbClamp: boolean | null;
18
+ /** K6.4: spectral media composite themselves over the scene colour (no hardware blending). */
19
+ spectral: boolean;
20
+ constructor();
21
+ /** The froxel layout of the core outputs (each update). */
22
+ setLayout(layout: VDBFroxelLayout, camera: {
23
+ near: number;
24
+ far: number;
25
+ isOrthographicCamera?: boolean;
26
+ }): void;
27
+ /** K6.4: the spectral composite (the alpha prefix, his NoBlending) or the grey one. */
28
+ setSpectral(spectral: boolean): void;
29
+ /** As `VDBFrameIntegrateMaterial.setSrgbBlending` (his rules). */
30
+ setSrgbBlending(srgbBlending: boolean, srgbClamp: boolean): void;
31
+ private createSceneDepth;
32
+ private createFragmentNode;
33
+ private createSpectralFragmentNode;
34
+ }