@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,403 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L34–1027 (the light shadow reset, FrameVolumeShadowNode, the
3
+ // filter install, dispose).
4
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
+ // Past the pin (K7.1): his 62a6e3e (lookups from the drawn state) and c13f2d5 (the budget counts only lights of the
6
+ // rendered scene; the core's maps).
7
+ // Changes: TypeScript; K6.8: the maps are the core's (`VDBVolumeShadowMap`, drawn by its kernels), three only receives
8
+ // them; K6.8a: the receivers call the core's WGSL (`vdbVolumeShadowWgsl`) with the core's view buffer bound through a
9
+ // storage stand-in, instead of a TSL port of the lookup; every three r187 internal goes through `three-internals.ts`
10
+ // or the `VDBGridNode` attribute self-test, which throw VDB_ENGINE_MISMATCH. Divergences: DIVERGES.md (K3.6, K6.5 rows).
11
+ /**
12
+ * K3.6 / K6.5: shadows of `VDBFrameVolume`s on meshes (`frameRenderer.settings.castShadows`, his `FrameVolumeShadows`).
13
+ * Each shadow-casting directional, spot or point light gets a Beer shadow map from the core frame renderer (its
14
+ * `outputs.volumeShadows`); the light's `shadow.filterNode` multiplies three's shadow by the volume transmittance at
15
+ * the receiver.
16
+ *
17
+ * K6.8a: the receiver is the core's own WGSL (`vdbVolumeShadow`, `…Rgb`, `…Cube`, `…CubeRgb` of `vdbVolumeShadowWgsl()`)
18
+ * through a `wgslFn`. Its inputs are the map texture (a 2d-array: directional cascades or a spot map; a point map through a
19
+ * cube view), the spectral rgb twin, and the map's `view` buffer, the state the map was drawn with (his 62a6e3e), which
20
+ * the core rewrites each update: three binds that buffer itself through a storage stand-in (the `VDBGridNode` pool-buffer
21
+ * pattern), read as `array<vec4u>` and unpacked into `VdbVolumeShadowView`. Each light's texture and storage nodes are
22
+ * made once and only their `value` follows the core (a new stand-in when the core made a new texture or buffer), so a
23
+ * receiver built at any time binds the core's current objects; while a light has no core map they bind a placeholder
24
+ * (a zero view: transmittance 1), never a texture or buffer the core retired (K6.10 finding 8).
25
+ *
26
+ * three: receivers need `receiveShadow`, the light `castShadow`, and `renderer.shadowMap.enabled`. The core update runs
27
+ * before the first receiver of each render (the node's `updateBefore`), so the maps are this render's.
28
+ */
29
+ import * as THREE from "three";
30
+ import { Node } from "three/webgpu";
31
+ import * as TSL from "three/tsl";
32
+ import { vdbThreeStorageStandIn } from "../grid-node.js";
33
+ import { getDevice } from "../device.js";
34
+ import { frameShadowCoarseMapSize } from "../../tools/frame/shadows.js";
35
+ import { vdbFrameCheckFilterInputs, vdbFrameCheckLightReset, vdbFrameRenderUpdateType, vdbFrameShadowFilters, vdbFrameSharedLightNode } from "./three-internals.js";
36
+ import { VDBCoreTextureBinding } from "./core-textures.js";
37
+ import { VDBFrameStructLoaderNode, vdbFrameStructLoaderWgsl, vdbFrameStructWords } from "./core-structs.js";
38
+ import { VDB_VOLUME_SHADOW_VIEW, vdbVolumeShadowWgsl } from "../../core/frame/wgsl/shadows.js";
39
+ const { code, cubeTexture, dot, positionView, positionWorld, sampler, storage, texture, vec3, wgslFn } = TSL;
40
+ const isShadowLight = (light) => {
41
+ const l = light;
42
+ return !!(l.isDirectionalLight || l.isSpotLight || l.isPointLight) && l.castShadow;
43
+ };
44
+ // NOTE The object is in a scene. A removed light is not.
45
+ const isInScene = (object) => {
46
+ let root = object;
47
+ while (root.parent)
48
+ root = root.parent;
49
+ return root.isScene === true;
50
+ };
51
+ // NOTE A light shadow node is built one time; a new filterNode has no effect until it is built again.
52
+ // disposeShadow of the shared light node makes the receivers build a new shadow node (three-internals.ts, internal 1).
53
+ // Returns the old shadow node, or null when there is none. Receivers can use it until the end of this render.
54
+ const resetLightShadow = (light) => {
55
+ vdbFrameCheckLightReset();
56
+ const lightNode = vdbFrameSharedLightNode(light);
57
+ if (!lightNode || !lightNode.shadowNode)
58
+ return null;
59
+ const { shadowNode } = lightNode;
60
+ // NOTE disposeShadow without the GPU dispose
61
+ lightNode.shadowNode = { dispose() { } };
62
+ lightNode.disposeShadow();
63
+ return shadowNode;
64
+ };
65
+ /** `vec4u` words of the view struct (every field is 16-byte aligned). */
66
+ const VIEW_WORDS = vdbFrameStructWords(VDB_VOLUME_SHADOW_VIEW);
67
+ /**
68
+ * WGSL that unpacks the view buffer (bound as `array<vec4u>` at `ref`) into the core's `VdbVolumeShadowView`, generated
69
+ * from the struct's layout, so a field the core adds is unpacked too (a type this cannot unpack throws).
70
+ */
71
+ export function vdbFrameShadowViewLoaderWgsl(fnName, ref) {
72
+ return vdbFrameStructLoaderWgsl(VDB_VOLUME_SHADOW_VIEW, fnName, ref);
73
+ }
74
+ /** The core's receiver functions and the view struct, one code node shared by every receiver (once per shader). */
75
+ let receiverCode = null;
76
+ const receiverCodeNode = () => (receiverCode ??= code(vdbVolumeShadowWgsl()));
77
+ /**
78
+ * Volume transmittance at a receiver from the light's core Beer shadow map: the core's `vdbVolumeShadow` /
79
+ * `vdbVolumeShadowCube` (K6.4 spectral maps: `…Rgb` / `…CubeRgb`, the channel mean in a ShadowMaterial, his rule) through
80
+ * a `wgslFn`, with the view the map was drawn with (twin `vdbFrameVolumeShadowLookup`). `updateBefore` runs the core
81
+ * update before the first receiver of each render.
82
+ */
83
+ export class VDBFrameVolumeShadowNode extends Node {
84
+ static get type() {
85
+ return "VDBFrameVolumeShadowNode";
86
+ }
87
+ shadows;
88
+ entry;
89
+ constructor(shadows, entry) {
90
+ super("float");
91
+ this.shadows = shadows;
92
+ this.entry = entry;
93
+ this.updateBeforeType = vdbFrameRenderUpdateType();
94
+ }
95
+ // NOTE Spectral maps: transmittance of each channel. ShadowMaterial has one shadow mask, so it gets the mean.
96
+ isSpectral(builder) {
97
+ return this.entry.rgbTexture !== null && builder.material?.isShadowNodeMaterial !== true;
98
+ }
99
+ getNodeType(builder) {
100
+ return this.isSpectral(builder) ? "vec3" : "float";
101
+ }
102
+ updateBefore(frame) {
103
+ const { renderer, scene, camera, renderId } = frame;
104
+ this.shadows.render(renderer, scene, camera, renderId);
105
+ return undefined;
106
+ }
107
+ setup(builder) {
108
+ const { entry } = this;
109
+ const nodes = this.shadows.nodesOf(entry);
110
+ const rgbKind = entry.rgbTexture !== null;
111
+ const fn = this.shadows.receiverFn(entry, rgbKind);
112
+ const inputs = { map: nodes.map, smp: sampler(nodes.map), world: positionWorld };
113
+ if (rgbKind)
114
+ inputs.rgb = nodes.rgb;
115
+ if (!entry.isPoint)
116
+ inputs.viewDepth = positionView.z.negate();
117
+ const value = fn(inputs);
118
+ // NOTE ShadowMaterial with spectral maps: mean transmittance of the channels
119
+ return rgbKind && !this.isSpectral(builder) ? dot(value, vec3(1.0 / 3.0)) : value;
120
+ }
121
+ }
122
+ /** The receivers of the core's volume shadow maps, owned by a {@link VDBFrameRenderer} (`frameRenderer.volumeShadows`). */
123
+ export class VDBFrameVolumeShadowReceivers {
124
+ entries = new Map();
125
+ frameRenderer;
126
+ // NOTE Replaced shadow nodes, stand-ins and attributes. update() runs mid-render, so the next update() disposes them.
127
+ retired = [];
128
+ renderCount = 0;
129
+ #renderId = -1;
130
+ #camera = null;
131
+ #renderer = null;
132
+ #names = 0;
133
+ #placeholders = null;
134
+ /** Map pieces drawn in the last update, and how many waited for the budget (not his; tests and timing). */
135
+ lastUpdate = { drawn: 0, waiting: 0 };
136
+ constructor(frameRenderer) {
137
+ this.frameRenderer = frameRenderer;
138
+ }
139
+ /**
140
+ * The map size of the settings (`castShadowMapSize`, or his coarse size). The core clamps it to the device's limits
141
+ * (K6.10a); `sync` takes the size of the map the core made.
142
+ */
143
+ getMapSize() {
144
+ const { settings } = this.frameRenderer;
145
+ return settings.castShadowCoarse ? frameShadowCoarseMapSize : Math.max(1, Math.round(settings.castShadowMapSize));
146
+ }
147
+ #entry(light) {
148
+ let entry = this.entries.get(light);
149
+ if (entry)
150
+ return entry;
151
+ const isPoint = light.isPointLight === true;
152
+ entry = {
153
+ light,
154
+ isPoint,
155
+ size: this.getMapSize(),
156
+ coreMap: null,
157
+ lastDraw: -1,
158
+ userFilter: null,
159
+ texture: null,
160
+ binding: new VDBCoreTextureBinding(isPoint ? "cube" : "2d-array"),
161
+ rgbTexture: null,
162
+ rgbBinding: new VDBCoreTextureBinding(isPoint ? "cube" : "2d-array"),
163
+ viewBuffer: null,
164
+ nodes: null,
165
+ };
166
+ this.entries.set(light, entry);
167
+ return entry;
168
+ }
169
+ #placeholdersOf(device) {
170
+ const p = this.#placeholders;
171
+ if (p && p.device === device)
172
+ return p;
173
+ this.#destroyPlaceholders();
174
+ const make = (layers, what) => device.createTexture({ label: `@pmndrs/vdb/three volume shadow placeholder ${what}`, size: [1, 1, layers], format: "rgba16float", usage: 0x04 /* TEXTURE_BINDING */ });
175
+ // A zero view: info.w (enabled) 0, so every receiver function returns 1 without sampling
176
+ const view = device.createBuffer({ label: "@pmndrs/vdb/three volume shadow placeholder view", size: VDB_VOLUME_SHADOW_VIEW.size, usage: 0x80 /* STORAGE */ });
177
+ return (this.#placeholders = { device, array: make(1, "2d-array"), cube: make(6, "cube"), view });
178
+ }
179
+ #destroyPlaceholders() {
180
+ const p = this.#placeholders;
181
+ if (!p)
182
+ return;
183
+ // NOTE A bind group of this render may still name them: destroy after the task that submits it
184
+ const destroy = () => {
185
+ p.array.destroy();
186
+ p.cube.destroy();
187
+ p.view.destroy();
188
+ };
189
+ setTimeout(destroy, 0);
190
+ this.#placeholders = null;
191
+ }
192
+ /**
193
+ * The light's texture and view nodes (made at its first receiver build, bound to placeholders until the core draws a
194
+ * map). @internal
195
+ */
196
+ nodesOf(entry) {
197
+ if (entry.nodes)
198
+ return entry.nodes;
199
+ const renderer = this.#renderer;
200
+ if (!renderer)
201
+ throw new Error("VDBFrameVolumeShadowReceivers: a receiver was built before update() saw the renderer");
202
+ const p = this.#placeholdersOf(getDevice(renderer));
203
+ entry.binding.set(entry.texture ?? (entry.isPoint ? p.cube : p.array));
204
+ entry.rgbBinding.set(entry.rgbTexture ?? (entry.isPoint ? p.cube : p.array));
205
+ const make = entry.isPoint ? cubeTexture : texture;
206
+ const k = this.#names++;
207
+ const view = storage(this.#viewStandIn(entry.viewBuffer ?? p.view, k), "uvec4", VIEW_WORDS).toReadOnly();
208
+ view.setName(`vdbShadowView${k}`);
209
+ entry.nodes = {
210
+ k,
211
+ map: make(entry.binding.texture),
212
+ rgb: make(entry.rgbBinding.texture),
213
+ view,
214
+ loader: new VDBFrameStructLoaderNode(view, VDB_VOLUME_SHADOW_VIEW, `vdbFrameShadowView${k}`),
215
+ fns: new Map(),
216
+ };
217
+ return entry.nodes;
218
+ }
219
+ #viewStandIn(buffer, k) {
220
+ return vdbThreeStorageStandIn(this.#renderer, buffer, `vdbShadowView${k}`);
221
+ }
222
+ /** The `wgslFn` of a light's receivers (grey or rgb; the point variants take no view depth). @internal */
223
+ receiverFn(entry, rgb) {
224
+ const nodes = this.nodesOf(entry);
225
+ const key = rgb ? "rgb" : "grey";
226
+ let fn = nodes.fns.get(key);
227
+ if (fn)
228
+ return fn;
229
+ const view = `${nodes.loader.fnName}()`;
230
+ const name = `${nodes.loader.fnName.replace("View", "Receiver")}${rgb ? "Rgb" : ""}`;
231
+ const map = entry.isPoint ? "texture_cube<f32>" : "texture_2d_array<f32>";
232
+ const source = entry.isPoint
233
+ ? rgb
234
+ ? `fn ${name}(map: ${map}, rgb: ${map}, smp: sampler, world: vec3f) -> vec3f {\n return vdbVolumeShadowCubeRgb(map, rgb, smp, ${view}, world);\n}`
235
+ : `fn ${name}(map: ${map}, smp: sampler, world: vec3f) -> f32 {\n return vdbVolumeShadowCube(map, smp, ${view}, world);\n}`
236
+ : rgb
237
+ ? `fn ${name}(map: ${map}, rgb: ${map}, smp: sampler, world: vec3f, viewDepth: f32) -> vec3f {\n return vdbVolumeShadowRgb(map, rgb, smp, ${view}, world, viewDepth);\n}`
238
+ : `fn ${name}(map: ${map}, smp: sampler, world: vec3f, viewDepth: f32) -> f32 {\n return vdbVolumeShadow(map, smp, ${view}, world, viewDepth);\n}`;
239
+ fn = wgslFn(source, [receiverCodeNode(), nodes.loader]);
240
+ nodes.fns.set(key, fn);
241
+ return fn;
242
+ }
243
+ // NOTE Frees a light's entry and puts back its own filter. Receivers build again without the volume shadow.
244
+ #free(entry) {
245
+ const { light } = entry;
246
+ const shadow = light.shadow;
247
+ // NOTE Receivers that still have the volume shadow node until they build again read the placeholders
248
+ this.#bind(entry, null);
249
+ if (shadow.filterNode?.isVDBFrameVolumeShadowFilter)
250
+ shadow.filterNode = entry.userFilter;
251
+ const old = resetLightShadow(light);
252
+ if (old)
253
+ this.retired.push(old);
254
+ this.retired.push(entry.binding, entry.rgbBinding);
255
+ if (entry.nodes)
256
+ this.retired.push(entry.nodes.view.value);
257
+ this.entries.delete(light);
258
+ }
259
+ #disposeRetired() {
260
+ this.retired.forEach((resource) => resource.dispose());
261
+ this.retired.length = 0;
262
+ }
263
+ /**
264
+ * Puts the volume filter on each shadow light (new lights and new filters are found each render); frees the entries
265
+ * of lights with no shadow or not in a scene, and all entries when `castShadows` is off.
266
+ */
267
+ update(renderer, scene) {
268
+ this.#disposeRetired();
269
+ this.#renderer = renderer;
270
+ if (!this.frameRenderer.settings.castShadows) {
271
+ this.entries.forEach((entry) => this.#free(entry));
272
+ return;
273
+ }
274
+ // NOTE The light-shadow reset (three internal) is self-tested before the first filter goes on a light
275
+ vdbFrameCheckLightReset();
276
+ this.entries.forEach((entry) => {
277
+ if (!isShadowLight(entry.light) || !isInScene(entry.light))
278
+ this.#free(entry);
279
+ });
280
+ scene.traverse((light) => {
281
+ if (isShadowLight(light))
282
+ this.#install(renderer, light);
283
+ });
284
+ }
285
+ #install(renderer, light) {
286
+ const shadow = light.shadow;
287
+ if (shadow.filterNode?.isVDBFrameVolumeShadowFilter)
288
+ return;
289
+ const entry = this.#entry(light);
290
+ const userFilter = shadow.filterNode ?? null;
291
+ const filters = vdbFrameShadowFilters();
292
+ entry.userFilter = userFilter;
293
+ // NOTE ShadowNode calls the filter when it builds. The base filter is three's or the user's.
294
+ // Point lights give the direction from the light (bd3D), other lights give shadowCoord. The volume shadow node
295
+ // does not use them: it finds its map coordinate from the drawn state.
296
+ const filter = (inputs) => {
297
+ vdbFrameCheckFilterInputs(inputs, entry.isPoint);
298
+ const type = renderer.shadowMap.type;
299
+ const baseFilter = (userFilter ?? (entry.isPoint ? (type === THREE.BasicShadowMap ? filters.basicPoint : filters.point) : filters.maps[type]));
300
+ if (!baseFilter)
301
+ throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");
302
+ // NOTE PointShadowNode calls the filter in a TSL function, and its parameter proxy loses the shadow object.
303
+ // So the base filter gets a plain object with the light shadow.
304
+ const baseInputs = entry.isPoint
305
+ ? { depthTexture: inputs.depthTexture, bd3D: inputs.bd3D, dp: inputs.dp, distance: inputs.distance }
306
+ : { depthTexture: inputs.depthTexture, shadowCoord: inputs.shadowCoord, depthLayer: inputs.depthLayer };
307
+ baseInputs.shadow = shadow;
308
+ return baseFilter(baseInputs).mul(new VDBFrameVolumeShadowNode(this, entry));
309
+ };
310
+ filter.isVDBFrameVolumeShadowFilter = true;
311
+ shadow.filterNode = filter;
312
+ // NOTE The map exists when the shadow node was built before this filter
313
+ if (shadow.map) {
314
+ const old = resetLightShadow(light);
315
+ if (old)
316
+ this.retired.push(old);
317
+ }
318
+ }
319
+ /** Called by the receivers of every light: the core update of this render (once per render and camera). */
320
+ render(renderer, scene, camera, renderId) {
321
+ if (this.#renderId === renderId && this.#camera === camera)
322
+ return;
323
+ this.#renderId = renderId;
324
+ this.#camera = camera;
325
+ this.frameRenderer.coreFrame(renderer, scene, camera);
326
+ }
327
+ /**
328
+ * Points a light's nodes at a core map (null: the placeholders). The texture and storage nodes keep their identity;
329
+ * a new core texture or buffer gets a new stand-in as the node's `value`, and the old attribute is disposed at the next
330
+ * update. Returns whether anything changed (the caller rebuilds the receivers: see `sync`).
331
+ */
332
+ #bind(entry, m) {
333
+ entry.coreMap = m;
334
+ const nodes = entry.nodes;
335
+ const p = nodes ? this.#placeholders : null;
336
+ const texture = m?.texture ?? null;
337
+ const rgb = m?.rgbTexture ?? null;
338
+ const view = m?.view ?? null;
339
+ const changed = texture !== entry.texture || rgb !== entry.rgbTexture || view !== entry.viewBuffer;
340
+ if (texture !== entry.texture) {
341
+ entry.texture = texture;
342
+ if (nodes && p)
343
+ this.#setTexture(entry.binding, nodes.map, texture ?? (entry.isPoint ? p.cube : p.array));
344
+ }
345
+ if (rgb !== entry.rgbTexture) {
346
+ entry.rgbTexture = rgb;
347
+ if (nodes && p)
348
+ this.#setTexture(entry.rgbBinding, nodes.rgb, rgb ?? (entry.isPoint ? p.cube : p.array));
349
+ }
350
+ if (view !== entry.viewBuffer) {
351
+ entry.viewBuffer = view;
352
+ if (nodes && p) {
353
+ const old = nodes.view.value;
354
+ nodes.view.value = this.#viewStandIn(view ?? p.view, nodes.k);
355
+ this.retired.push(old);
356
+ }
357
+ }
358
+ return changed;
359
+ }
360
+ // NOTE VDBCoreTextureBinding.set disposes the old stand-in at once; three keeps the GPU texture it bound (an
361
+ // ExternalTexture's dispose never destroys it) and rebinds the node's new value at the next draw
362
+ #setTexture(binding, node, gpu) {
363
+ if (binding.set(gpu))
364
+ node.value = binding.texture;
365
+ }
366
+ /**
367
+ * After a core update, each entry binds its core map (texture, rgb twin, view buffer) and reads the budget counters.
368
+ * The map size, the cascades and the drawn views live in the view buffer, so only a new core object (the first map, a
369
+ * new size, a spectral switch, a map that went away or came back) touches the receivers: their nodes get the new
370
+ * stand-ins and the light's receivers rebuild. The rebuild is needed: three r187 re-reads the object-group bindings
371
+ * (textures, storage buffers) of a plain material only on a full refresh, which a node `value` swap does not cause, so
372
+ * a receiver drawn with a shared refresh would keep the old bind group, and with it a texture the core retires
373
+ * (K6.10 finding 8). They rebuild at their next draw (the next render: this one may still draw with the old objects,
374
+ * which the core keeps alive for two more updates).
375
+ */
376
+ sync(maps, stats) {
377
+ this.renderCount++;
378
+ this.lastUpdate.drawn = stats.drawn;
379
+ this.lastUpdate.waiting = stats.waiting;
380
+ this.entries.forEach((entry) => {
381
+ const m = maps.get(entry.light.id) ?? null;
382
+ if (this.#bind(entry, m) && entry.nodes) {
383
+ const old = resetLightShadow(entry.light);
384
+ if (old)
385
+ this.retired.push(old);
386
+ }
387
+ if (!m)
388
+ return;
389
+ entry.size = m.size;
390
+ entry.lastDraw = m.lastDraw[0] ?? entry.lastDraw;
391
+ });
392
+ }
393
+ /** Puts back the filter of each light (a later render installs again). */
394
+ dispose() {
395
+ this.entries.forEach((entry) => this.#free(entry));
396
+ this.#disposeRetired();
397
+ this.#destroyPlaceholders();
398
+ this.#renderId = -1;
399
+ this.#camera = null;
400
+ this.#renderer = null;
401
+ }
402
+ }
403
+ //# sourceMappingURL=volume-shadows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"volume-shadows.js","sourceRoot":"","sources":["../../../src/three/frame/volume-shadows.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,sHAAsH;AACtH,8BAA8B;AAC9B,4GAA4G;AAC5G,oHAAoH;AACpH,oCAAoC;AACpC,uHAAuH;AACvH,sHAAsH;AACtH,qHAAqH;AACrH,yHAAyH;AAEzH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAoD,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAmB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpK,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,mBAAmB,EAA4B,MAAM,mBAAmB,CAAC;AACtI,OAAO,EAAE,s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AAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L34–1027 (the light shadow reset, FrameVolumeShadowNode, the\n// filter install, dispose).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Past the pin (K7.1): his 62a6e3e (lookups from the drawn state) and c13f2d5 (the budget counts only lights of the\n// rendered scene; the core's maps).\n// Changes: TypeScript; K6.8: the maps are the core's (`VDBVolumeShadowMap`, drawn by its kernels), three only receives\n// them; K6.8a: the receivers call the core's WGSL (`vdbVolumeShadowWgsl`) with the core's view buffer bound through a\n// storage stand-in, instead of a TSL port of the lookup; every three r187 internal goes through `three-internals.ts`\n// or the `VDBGridNode` attribute self-test, which throw VDB_ENGINE_MISMATCH. Divergences: DIVERGES.md (K3.6, K6.5 rows).\n\n/**\n * K3.6 / K6.5: shadows of `VDBFrameVolume`s on meshes (`frameRenderer.settings.castShadows`, his `FrameVolumeShadows`).\n * Each shadow-casting directional, spot or point light gets a Beer shadow map from the core frame renderer (its\n * `outputs.volumeShadows`); the light's `shadow.filterNode` multiplies three's shadow by the volume transmittance at\n * the receiver.\n *\n * K6.8a: the receiver is the core's own WGSL (`vdbVolumeShadow`, `…Rgb`, `…Cube`, `…CubeRgb` of `vdbVolumeShadowWgsl()`)\n * through a `wgslFn`. Its inputs are the map texture (a 2d-array: directional cascades or a spot map; a point map through a\n * cube view), the spectral rgb twin, and the map's `view` buffer, the state the map was drawn with (his 62a6e3e), which\n * the core rewrites each update: three binds that buffer itself through a storage stand-in (the `VDBGridNode` pool-buffer\n * pattern), read as `array<vec4u>` and unpacked into `VdbVolumeShadowView`. Each light's texture and storage nodes are\n * made once and only their `value` follows the core (a new stand-in when the core made a new texture or buffer), so a\n * receiver built at any time binds the core's current objects; while a light has no core map they bind a placeholder\n * (a zero view: transmittance 1), never a texture or buffer the core retired (K6.10 finding 8).\n *\n * three: receivers need `receiveShadow`, the light `castShadow`, and `renderer.shadowMap.enabled`. The core update runs\n * before the first receiver of each render (the node's `updateBefore`), so the maps are this render's.\n */\n\nimport * as THREE from \"three\";\nimport { Node, type StorageBufferAttribute, type WebGPURenderer } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport { vdbThreeStorageStandIn, type VDBTslNode } from \"../grid-node.js\";\nimport { getDevice } from \"../device.js\";\nimport { frameShadowCoarseMapSize } from \"../../tools/frame/shadows.js\";\nimport { vdbFrameCheckFilterInputs, vdbFrameCheckLightReset, vdbFrameRenderUpdateType, vdbFrameShadowFilters, vdbFrameSharedLightNode } from \"./three-internals.js\";\nimport type { VDBFrameRenderer } from \"./renderer.js\";\nimport { VDBCoreTextureBinding } from \"./core-textures.js\";\nimport { VDBFrameStructLoaderNode, vdbFrameStructLoaderWgsl, vdbFrameStructWords, type VDBFrameStorageNode } from \"./core-structs.js\";\nimport { VDB_VOLUME_SHADOW_VIEW, vdbVolumeShadowWgsl } from \"../../core/frame/wgsl/shadows.js\";\nimport type { VDBVolumeShadowMap } from \"../../core/frame/types.js\";\n\nconst { code, cubeTexture, dot, positionView, positionWorld, sampler, storage, texture, vec3, wgslFn } = TSL as unknown as Record<string, VDBTslNode>;\n\ntype N = VDBTslNode;\ntype RendererLike = WebGPURenderer & { isWebGPURenderer?: boolean };\ntype ShadowLight = THREE.DirectionalLight | THREE.SpotLight | THREE.PointLight;\ntype StorageNode = VDBFrameStorageNode;\n\nconst isShadowLight = (light: THREE.Object3D): light is ShadowLight => {\n const l = light as THREE.Light & { isDirectionalLight?: boolean; isSpotLight?: boolean; isPointLight?: boolean };\n return !!(l.isDirectionalLight || l.isSpotLight || l.isPointLight) && l.castShadow;\n};\n\n// NOTE The object is in a scene. A removed light is not.\nconst isInScene = (object: THREE.Object3D): boolean => {\n let root = object;\n while (root.parent) root = root.parent;\n return (root as THREE.Scene).isScene === true;\n};\n\n// NOTE A light shadow node is built one time; a new filterNode has no effect until it is built again.\n// disposeShadow of the shared light node makes the receivers build a new shadow node (three-internals.ts, internal 1).\n// Returns the old shadow node, or null when there is none. Receivers can use it until the end of this render.\nconst resetLightShadow = (light: ShadowLight): { dispose(): void } | null => {\n vdbFrameCheckLightReset();\n const lightNode = vdbFrameSharedLightNode(light) as { shadowNode: { dispose(): void } | null; disposeShadow(): void } | null;\n if (!lightNode || !lightNode.shadowNode) return null;\n const { shadowNode } = lightNode;\n // NOTE disposeShadow without the GPU dispose\n lightNode.shadowNode = { dispose() {} };\n lightNode.disposeShadow();\n return shadowNode;\n};\n\n/** `vec4u` words of the view struct (every field is 16-byte aligned). */\nconst VIEW_WORDS = vdbFrameStructWords(VDB_VOLUME_SHADOW_VIEW);\n\n/**\n * WGSL that unpacks the view buffer (bound as `array<vec4u>` at `ref`) into the core's `VdbVolumeShadowView`, generated\n * from the struct's layout, so a field the core adds is unpacked too (a type this cannot unpack throws).\n */\nexport function vdbFrameShadowViewLoaderWgsl(fnName: string, ref: string): string {\n return vdbFrameStructLoaderWgsl(VDB_VOLUME_SHADOW_VIEW, fnName, ref);\n}\n\n/** The core's receiver functions and the view struct, one code node shared by every receiver (once per shader). */\nlet receiverCode: N | null = null;\nconst receiverCodeNode = (): N => (receiverCode ??= code(vdbVolumeShadowWgsl()));\n\n/** The texture and buffer nodes of one light's receivers; made once, their values follow the core. */\ninterface EntryNodes {\n /** Unique per receivers object: names the storage binding and the WGSL functions. */\n k: number;\n map: N;\n rgb: N;\n view: StorageNode;\n loader: VDBFrameStructLoaderNode;\n fns: Map<string, (inputs: Record<string, N>) => N>;\n}\n\n/** What a light without a core map binds: a 1² 2d-array, a 1² cube (6 layers) and a zero view (enabled 0). */\ninterface Placeholders {\n device: GPUDevice;\n array: GPUTexture;\n cube: GPUTexture;\n view: GPUBuffer;\n}\n\n/** One shadow light's core map, as its receivers bind it. */\nexport interface VDBFrameShadowEntry {\n light: ShadowLight;\n isPoint: boolean;\n /** The map's size (texels per side) of the last core map; the settings' size before one. */\n size: number;\n /** The core map the receivers bind now (null: none yet, or the light has none this frame; they bind placeholders). */\n coreMap: VDBVolumeShadowMap | null;\n /** The core update count at the last draw of the map's first piece (his `lastDraw`; tests and the stale harness). */\n lastDraw: number;\n userFilter: ((inputs: unknown) => N) | null;\n /** The map texture bound now (the core's, or the placeholder). */\n texture: GPUTexture | null;\n binding: VDBCoreTextureBinding;\n /** K6.4 spectral: the optical depth rgb twin bound now (null: a grey map; the node binds the placeholder). */\n rgbTexture: GPUTexture | null;\n rgbBinding: VDBCoreTextureBinding;\n /** The view buffer bound now (the core's, or the placeholder). */\n viewBuffer: GPUBuffer | null;\n nodes: EntryNodes | null;\n}\n\n/**\n * Volume transmittance at a receiver from the light's core Beer shadow map: the core's `vdbVolumeShadow` /\n * `vdbVolumeShadowCube` (K6.4 spectral maps: `…Rgb` / `…CubeRgb`, the channel mean in a ShadowMaterial, his rule) through\n * a `wgslFn`, with the view the map was drawn with (twin `vdbFrameVolumeShadowLookup`). `updateBefore` runs the core\n * update before the first receiver of each render.\n */\nexport class VDBFrameVolumeShadowNode extends Node {\n static get type(): string {\n return \"VDBFrameVolumeShadowNode\";\n }\n\n readonly shadows: VDBFrameVolumeShadowReceivers;\n readonly entry: VDBFrameShadowEntry;\n\n constructor(shadows: VDBFrameVolumeShadowReceivers, entry: VDBFrameShadowEntry) {\n super(\"float\");\n this.shadows = shadows;\n this.entry = entry;\n (this as unknown as { updateBeforeType: string }).updateBeforeType = vdbFrameRenderUpdateType();\n }\n\n // NOTE Spectral maps: transmittance of each channel. ShadowMaterial has one shadow mask, so it gets the mean.\n isSpectral(builder: { material?: { isShadowNodeMaterial?: boolean } }): boolean {\n return this.entry.rgbTexture !== null && builder.material?.isShadowNodeMaterial !== true;\n }\n\n override getNodeType(builder: never): string {\n return this.isSpectral(builder) ? \"vec3\" : \"float\";\n }\n\n override updateBefore(frame: never): boolean | undefined {\n const { renderer, scene, camera, renderId } = frame as { renderer: RendererLike; scene: THREE.Scene; camera: THREE.Camera; renderId: number };\n this.shadows.render(renderer, scene, camera, renderId);\n return undefined;\n }\n\n override setup(builder: never): N {\n const { entry } = this;\n const nodes = this.shadows.nodesOf(entry);\n const rgbKind = entry.rgbTexture !== null;\n const fn = this.shadows.receiverFn(entry, rgbKind);\n const inputs: Record<string, N> = { map: nodes.map, smp: sampler(nodes.map), world: positionWorld };\n if (rgbKind) inputs.rgb = nodes.rgb;\n if (!entry.isPoint) inputs.viewDepth = positionView.z.negate();\n const value = fn(inputs);\n // NOTE ShadowMaterial with spectral maps: mean transmittance of the channels\n return rgbKind && !this.isSpectral(builder) ? dot(value, vec3(1.0 / 3.0)) : value;\n }\n}\n\n/** Shadow filter marker (his `isFrameVolumeShadowFilter`). */\ntype VolumeFilter = ((inputs: N) => N) & { isVDBFrameVolumeShadowFilter?: true };\n\n/** The receivers of the core's volume shadow maps, owned by a {@link VDBFrameRenderer} (`frameRenderer.volumeShadows`). */\nexport class VDBFrameVolumeShadowReceivers {\n readonly entries = new Map<THREE.Light, VDBFrameShadowEntry>();\n readonly frameRenderer: VDBFrameRenderer;\n // NOTE Replaced shadow nodes, stand-ins and attributes. update() runs mid-render, so the next update() disposes them.\n retired: { dispose(): void }[] = [];\n renderCount = 0;\n #renderId = -1;\n #camera: THREE.Camera | null = null;\n #renderer: RendererLike | null = null;\n #names = 0;\n #placeholders: Placeholders | null = null;\n /** Map pieces drawn in the last update, and how many waited for the budget (not his; tests and timing). */\n readonly lastUpdate = { drawn: 0, waiting: 0 };\n\n constructor(frameRenderer: VDBFrameRenderer) {\n this.frameRenderer = frameRenderer;\n }\n\n /**\n * The map size of the settings (`castShadowMapSize`, or his coarse size). The core clamps it to the device's limits\n * (K6.10a); `sync` takes the size of the map the core made.\n */\n getMapSize(): number {\n const { settings } = this.frameRenderer;\n return settings.castShadowCoarse ? frameShadowCoarseMapSize : Math.max(1, Math.round(settings.castShadowMapSize));\n }\n\n #entry(light: ShadowLight): VDBFrameShadowEntry {\n let entry = this.entries.get(light);\n if (entry) return entry;\n const isPoint = (light as THREE.PointLight).isPointLight === true;\n entry = {\n light,\n isPoint,\n size: this.getMapSize(),\n coreMap: null,\n lastDraw: -1,\n userFilter: null,\n texture: null,\n binding: new VDBCoreTextureBinding(isPoint ? \"cube\" : \"2d-array\"),\n rgbTexture: null,\n rgbBinding: new VDBCoreTextureBinding(isPoint ? \"cube\" : \"2d-array\"),\n viewBuffer: null,\n nodes: null,\n };\n this.entries.set(light, entry);\n return entry;\n }\n\n #placeholdersOf(device: GPUDevice): Placeholders {\n const p = this.#placeholders;\n if (p && p.device === device) return p;\n this.#destroyPlaceholders();\n const make = (layers: number, what: string) =>\n device.createTexture({ label: `@pmndrs/vdb/three volume shadow placeholder ${what}`, size: [1, 1, layers], format: \"rgba16float\", usage: 0x04 /* TEXTURE_BINDING */ });\n // A zero view: info.w (enabled) 0, so every receiver function returns 1 without sampling\n const view = device.createBuffer({ label: \"@pmndrs/vdb/three volume shadow placeholder view\", size: VDB_VOLUME_SHADOW_VIEW.size, usage: 0x80 /* STORAGE */ });\n return (this.#placeholders = { device, array: make(1, \"2d-array\"), cube: make(6, \"cube\"), view });\n }\n\n #destroyPlaceholders(): void {\n const p = this.#placeholders;\n if (!p) return;\n // NOTE A bind group of this render may still name them: destroy after the task that submits it\n const destroy = () => {\n p.array.destroy();\n p.cube.destroy();\n p.view.destroy();\n };\n setTimeout(destroy, 0);\n this.#placeholders = null;\n }\n\n /**\n * The light's texture and view nodes (made at its first receiver build, bound to placeholders until the core draws a\n * map). @internal\n */\n nodesOf(entry: VDBFrameShadowEntry): EntryNodes {\n if (entry.nodes) return entry.nodes;\n const renderer = this.#renderer;\n if (!renderer) throw new Error(\"VDBFrameVolumeShadowReceivers: a receiver was built before update() saw the renderer\");\n const p = this.#placeholdersOf(getDevice(renderer as never));\n entry.binding.set(entry.texture ?? (entry.isPoint ? p.cube : p.array));\n entry.rgbBinding.set(entry.rgbTexture ?? (entry.isPoint ? p.cube : p.array));\n const make = entry.isPoint ? cubeTexture : texture;\n const k = this.#names++;\n const view = storage(this.#viewStandIn(entry.viewBuffer ?? p.view, k), \"uvec4\", VIEW_WORDS).toReadOnly() as StorageNode;\n view.setName(`vdbShadowView${k}`);\n entry.nodes = {\n k,\n map: make(entry.binding.texture),\n rgb: make(entry.rgbBinding.texture),\n view,\n loader: new VDBFrameStructLoaderNode(view, VDB_VOLUME_SHADOW_VIEW, `vdbFrameShadowView${k}`),\n fns: new Map(),\n };\n return entry.nodes;\n }\n\n #viewStandIn(buffer: GPUBuffer, k: number): StorageBufferAttribute {\n return vdbThreeStorageStandIn(this.#renderer!, buffer, `vdbShadowView${k}`);\n }\n\n /** The `wgslFn` of a light's receivers (grey or rgb; the point variants take no view depth). @internal */\n receiverFn(entry: VDBFrameShadowEntry, rgb: boolean): (inputs: Record<string, N>) => N {\n const nodes = this.nodesOf(entry);\n const key = rgb ? \"rgb\" : \"grey\";\n let fn = nodes.fns.get(key);\n if (fn) return fn;\n const view = `${nodes.loader.fnName}()`;\n const name = `${nodes.loader.fnName.replace(\"View\", \"Receiver\")}${rgb ? \"Rgb\" : \"\"}`;\n const map = entry.isPoint ? \"texture_cube<f32>\" : \"texture_2d_array<f32>\";\n const source = entry.isPoint\n ? rgb\n ? `fn ${name}(map: ${map}, rgb: ${map}, smp: sampler, world: vec3f) -> vec3f {\\n return vdbVolumeShadowCubeRgb(map, rgb, smp, ${view}, world);\\n}`\n : `fn ${name}(map: ${map}, smp: sampler, world: vec3f) -> f32 {\\n return vdbVolumeShadowCube(map, smp, ${view}, world);\\n}`\n : rgb\n ? `fn ${name}(map: ${map}, rgb: ${map}, smp: sampler, world: vec3f, viewDepth: f32) -> vec3f {\\n return vdbVolumeShadowRgb(map, rgb, smp, ${view}, world, viewDepth);\\n}`\n : `fn ${name}(map: ${map}, smp: sampler, world: vec3f, viewDepth: f32) -> f32 {\\n return vdbVolumeShadow(map, smp, ${view}, world, viewDepth);\\n}`;\n fn = wgslFn(source, [receiverCodeNode(), nodes.loader]) as (inputs: Record<string, N>) => N;\n nodes.fns.set(key, fn);\n return fn;\n }\n\n // NOTE Frees a light's entry and puts back its own filter. Receivers build again without the volume shadow.\n #free(entry: VDBFrameShadowEntry): void {\n const { light } = entry;\n const shadow = light.shadow as THREE.LightShadow & { filterNode?: VolumeFilter | null };\n // NOTE Receivers that still have the volume shadow node until they build again read the placeholders\n this.#bind(entry, null);\n if (shadow.filterNode?.isVDBFrameVolumeShadowFilter) shadow.filterNode = entry.userFilter as VolumeFilter | null;\n const old = resetLightShadow(light);\n if (old) this.retired.push(old);\n this.retired.push(entry.binding, entry.rgbBinding);\n if (entry.nodes) this.retired.push(entry.nodes.view.value as StorageBufferAttribute);\n this.entries.delete(light);\n }\n\n #disposeRetired(): void {\n this.retired.forEach((resource) => resource.dispose());\n this.retired.length = 0;\n }\n\n /**\n * Puts the volume filter on each shadow light (new lights and new filters are found each render); frees the entries\n * of lights with no shadow or not in a scene, and all entries when `castShadows` is off.\n */\n update(renderer: RendererLike, scene: THREE.Object3D): void {\n this.#disposeRetired();\n this.#renderer = renderer;\n if (!this.frameRenderer.settings.castShadows) {\n this.entries.forEach((entry) => this.#free(entry));\n return;\n }\n // NOTE The light-shadow reset (three internal) is self-tested before the first filter goes on a light\n vdbFrameCheckLightReset();\n this.entries.forEach((entry) => {\n if (!isShadowLight(entry.light) || !isInScene(entry.light)) this.#free(entry);\n });\n scene.traverse((light) => {\n if (isShadowLight(light)) this.#install(renderer, light);\n });\n }\n\n #install(renderer: RendererLike, light: ShadowLight): void {\n const shadow = light.shadow as THREE.LightShadow & { filterNode?: VolumeFilter | null; map: THREE.RenderTarget | null };\n if (shadow.filterNode?.isVDBFrameVolumeShadowFilter) return;\n const entry = this.#entry(light);\n const userFilter = (shadow.filterNode as VolumeFilter | null | undefined) ?? null;\n const filters = vdbFrameShadowFilters();\n entry.userFilter = userFilter;\n // NOTE ShadowNode calls the filter when it builds. The base filter is three's or the user's.\n // Point lights give the direction from the light (bd3D), other lights give shadowCoord. The volume shadow node\n // does not use them: it finds its map coordinate from the drawn state.\n const filter: VolumeFilter = (inputs) => {\n vdbFrameCheckFilterInputs(inputs, entry.isPoint);\n const type = renderer.shadowMap.type as number;\n const baseFilter = (userFilter ?? (entry.isPoint ? (type === THREE.BasicShadowMap ? filters.basicPoint : filters.point) : filters.maps[type])) as ((i: unknown) => N) | null;\n if (!baseFilter) throw new Error(\"THREE.WebGPURenderer: Shadow map type not supported yet.\");\n // NOTE PointShadowNode calls the filter in a TSL function, and its parameter proxy loses the shadow object.\n // So the base filter gets a plain object with the light shadow.\n const baseInputs: Record<string, unknown> = entry.isPoint\n ? { depthTexture: inputs.depthTexture, bd3D: inputs.bd3D, dp: inputs.dp, distance: inputs.distance }\n : { depthTexture: inputs.depthTexture, shadowCoord: inputs.shadowCoord, depthLayer: inputs.depthLayer };\n baseInputs.shadow = shadow;\n return baseFilter(baseInputs).mul(new VDBFrameVolumeShadowNode(this, entry));\n };\n filter.isVDBFrameVolumeShadowFilter = true;\n shadow.filterNode = filter;\n // NOTE The map exists when the shadow node was built before this filter\n if (shadow.map) {\n const old = resetLightShadow(light);\n if (old) this.retired.push(old);\n }\n }\n\n /** Called by the receivers of every light: the core update of this render (once per render and camera). */\n render(renderer: RendererLike, scene: THREE.Scene, camera: THREE.Camera, renderId: number): void {\n if (this.#renderId === renderId && this.#camera === camera) return;\n this.#renderId = renderId;\n this.#camera = camera;\n this.frameRenderer.coreFrame(renderer as never, scene as never, camera);\n }\n\n /**\n * Points a light's nodes at a core map (null: the placeholders). The texture and storage nodes keep their identity;\n * a new core texture or buffer gets a new stand-in as the node's `value`, and the old attribute is disposed at the next\n * update. Returns whether anything changed (the caller rebuilds the receivers: see `sync`).\n */\n #bind(entry: VDBFrameShadowEntry, m: VDBVolumeShadowMap | null): boolean {\n entry.coreMap = m;\n const nodes = entry.nodes;\n const p = nodes ? this.#placeholders : null;\n const texture = m?.texture ?? null;\n const rgb = m?.rgbTexture ?? null;\n const view = m?.view ?? null;\n const changed = texture !== entry.texture || rgb !== entry.rgbTexture || view !== entry.viewBuffer;\n if (texture !== entry.texture) {\n entry.texture = texture;\n if (nodes && p) this.#setTexture(entry.binding, nodes.map, texture ?? (entry.isPoint ? p.cube : p.array));\n }\n if (rgb !== entry.rgbTexture) {\n entry.rgbTexture = rgb;\n if (nodes && p) this.#setTexture(entry.rgbBinding, nodes.rgb, rgb ?? (entry.isPoint ? p.cube : p.array));\n }\n if (view !== entry.viewBuffer) {\n entry.viewBuffer = view;\n if (nodes && p) {\n const old = nodes.view.value as StorageBufferAttribute;\n nodes.view.value = this.#viewStandIn(view ?? p.view, nodes.k);\n this.retired.push(old);\n }\n }\n return changed;\n }\n\n // NOTE VDBCoreTextureBinding.set disposes the old stand-in at once; three keeps the GPU texture it bound (an\n // ExternalTexture's dispose never destroys it) and rebinds the node's new value at the next draw\n #setTexture(binding: VDBCoreTextureBinding, node: N, gpu: GPUTexture): void {\n if (binding.set(gpu)) node.value = binding.texture;\n }\n\n /**\n * After a core update, each entry binds its core map (texture, rgb twin, view buffer) and reads the budget counters.\n * The map size, the cascades and the drawn views live in the view buffer, so only a new core object (the first map, a\n * new size, a spectral switch, a map that went away or came back) touches the receivers: their nodes get the new\n * stand-ins and the light's receivers rebuild. The rebuild is needed: three r187 re-reads the object-group bindings\n * (textures, storage buffers) of a plain material only on a full refresh, which a node `value` swap does not cause, so\n * a receiver drawn with a shared refresh would keep the old bind group, and with it a texture the core retires\n * (K6.10 finding 8). They rebuild at their next draw (the next render: this one may still draw with the old objects,\n * which the core keeps alive for two more updates).\n */\n sync(maps: ReadonlyMap<number | string, VDBVolumeShadowMap>, stats: { drawn: number; waiting: number }): void {\n this.renderCount++;\n this.lastUpdate.drawn = stats.drawn;\n this.lastUpdate.waiting = stats.waiting;\n this.entries.forEach((entry) => {\n const m = maps.get(entry.light.id) ?? null;\n if (this.#bind(entry, m) && entry.nodes) {\n const old = resetLightShadow(entry.light);\n if (old) this.retired.push(old);\n }\n if (!m) return;\n entry.size = m.size;\n entry.lastDraw = m.lastDraw[0] ?? entry.lastDraw;\n });\n }\n\n /** Puts back the filter of each light (a later render installs again). */\n dispose(): void {\n this.entries.forEach((entry) => this.#free(entry));\n this.#disposeRetired();\n this.#destroyPlaceholders();\n this.#renderId = -1;\n this.#camera = null;\n this.#renderer = null;\n }\n}\n"]}