@pmndrs/vdb 0.1.0 → 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 (576) hide show
  1. package/CHANGELOG.md +592 -2
  2. package/README.md +85 -37
  3. package/THIRD_PARTY_NOTICES.md +197 -29
  4. package/dist/core/compute/atlas.d.ts +10 -2
  5. package/dist/core/compute/atlas.js +6 -1
  6. package/dist/core/compute/atlas.js.map +1 -1
  7. package/dist/core/compute/index.d.ts +3 -3
  8. package/dist/core/compute/index.js +2 -2
  9. package/dist/core/compute/index.js.map +1 -1
  10. package/dist/core/compute/majorant-build.d.ts +45 -0
  11. package/dist/core/compute/majorant-build.js +193 -0
  12. package/dist/core/compute/majorant-build.js.map +1 -0
  13. package/dist/core/compute/multi-scale.d.ts +155 -0
  14. package/dist/core/compute/multi-scale.js +684 -0
  15. package/dist/core/compute/multi-scale.js.map +1 -0
  16. package/dist/core/compute/pyramid.d.ts +22 -7
  17. package/dist/core/compute/pyramid.js +22 -9
  18. package/dist/core/compute/pyramid.js.map +1 -1
  19. package/dist/core/compute/shared.d.ts +1 -0
  20. package/dist/core/compute/shared.js.map +1 -1
  21. package/dist/core/compute/stats.d.ts +10 -3
  22. package/dist/core/compute/stats.js +6 -1
  23. package/dist/core/compute/stats.js.map +1 -1
  24. package/dist/core/compute/value-transform.d.ts +8 -1
  25. package/dist/core/compute/value-transform.js +9 -3
  26. package/dist/core/compute/value-transform.js.map +1 -1
  27. package/dist/core/errors.d.ts +10 -0
  28. package/dist/core/errors.js +8 -0
  29. package/dist/core/errors.js.map +1 -1
  30. package/dist/core/frame/emission.d.ts +85 -0
  31. package/dist/core/frame/emission.js +422 -0
  32. package/dist/core/frame/emission.js.map +1 -0
  33. package/dist/core/frame/environment.d.ts +47 -0
  34. package/dist/core/frame/environment.js +178 -0
  35. package/dist/core/frame/environment.js.map +1 -0
  36. package/dist/core/frame/index.d.ts +39 -0
  37. package/dist/core/frame/index.js +27 -0
  38. package/dist/core/frame/index.js.map +1 -0
  39. package/dist/core/frame/kernels.d.ts +115 -0
  40. package/dist/core/frame/kernels.js +496 -0
  41. package/dist/core/frame/kernels.js.map +1 -0
  42. package/dist/core/frame/limits.d.ts +67 -0
  43. package/dist/core/frame/limits.js +109 -0
  44. package/dist/core/frame/limits.js.map +1 -0
  45. package/dist/core/frame/phase.d.ts +17 -0
  46. package/dist/core/frame/phase.js +53 -0
  47. package/dist/core/frame/phase.js.map +1 -0
  48. package/dist/core/frame/pipelines.d.ts +49 -0
  49. package/dist/core/frame/pipelines.js +147 -0
  50. package/dist/core/frame/pipelines.js.map +1 -0
  51. package/dist/core/frame/renderer.d.ts +122 -0
  52. package/dist/core/frame/renderer.js +1712 -0
  53. package/dist/core/frame/renderer.js.map +1 -0
  54. package/dist/core/frame/resources.d.ts +71 -0
  55. package/dist/core/frame/resources.js +100 -0
  56. package/dist/core/frame/resources.js.map +1 -0
  57. package/dist/core/frame/scattering.d.ts +97 -0
  58. package/dist/core/frame/scattering.js +332 -0
  59. package/dist/core/frame/scattering.js.map +1 -0
  60. package/dist/core/frame/settings.d.ts +243 -0
  61. package/dist/core/frame/settings.js +67 -0
  62. package/dist/core/frame/settings.js.map +1 -0
  63. package/dist/core/frame/shadows.d.ts +55 -0
  64. package/dist/core/frame/shadows.js +460 -0
  65. package/dist/core/frame/shadows.js.map +1 -0
  66. package/dist/core/frame/types.d.ts +415 -0
  67. package/dist/core/frame/types.js +49 -0
  68. package/dist/core/frame/types.js.map +1 -0
  69. package/dist/core/frame/uniforms.d.ts +105 -0
  70. package/dist/core/frame/uniforms.js +276 -0
  71. package/dist/core/frame/uniforms.js.map +1 -0
  72. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  73. package/dist/core/frame/wgsl/chunks.js +728 -0
  74. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  75. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  76. package/dist/core/frame/wgsl/emission.js +353 -0
  77. package/dist/core/frame/wgsl/emission.js.map +1 -0
  78. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  79. package/dist/core/frame/wgsl/environment.js +711 -0
  80. package/dist/core/frame/wgsl/environment.js.map +1 -0
  81. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  82. package/dist/core/frame/wgsl/gather.js +850 -0
  83. package/dist/core/frame/wgsl/gather.js.map +1 -0
  84. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  85. package/dist/core/frame/wgsl/integrate.js +213 -0
  86. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  87. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  88. package/dist/core/frame/wgsl/lighting.js +1636 -0
  89. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  90. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  91. package/dist/core/frame/wgsl/occluders.js +95 -0
  92. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  93. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  94. package/dist/core/frame/wgsl/resolve.js +205 -0
  95. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  96. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  97. package/dist/core/frame/wgsl/shadows.js +328 -0
  98. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  99. package/dist/core/half.d.ts +11 -0
  100. package/dist/core/half.js +22 -0
  101. package/dist/core/half.js.map +1 -0
  102. package/dist/core/index.d.ts +25 -3
  103. package/dist/core/index.js +23 -4
  104. package/dist/core/index.js.map +1 -1
  105. package/dist/core/internal.d.ts +17 -1
  106. package/dist/core/internal.js +18 -1
  107. package/dist/core/internal.js.map +1 -1
  108. package/dist/core/pool/image-header.d.ts +13 -2
  109. package/dist/core/pool/image-header.js +24 -5
  110. package/dist/core/pool/image-header.js.map +1 -1
  111. package/dist/core/pool/layout.d.ts +35 -1
  112. package/dist/core/pool/layout.js +51 -2
  113. package/dist/core/pool/layout.js.map +1 -1
  114. package/dist/core/pool/limits.d.ts +1 -0
  115. package/dist/core/pool/limits.js +1 -0
  116. package/dist/core/pool/limits.js.map +1 -1
  117. package/dist/core/pool/pool.d.ts +120 -15
  118. package/dist/core/pool/pool.js +255 -24
  119. package/dist/core/pool/pool.js.map +1 -1
  120. package/dist/core/reference/index.d.ts +6 -0
  121. package/dist/core/reference/index.js +7 -0
  122. package/dist/core/reference/index.js.map +1 -0
  123. package/dist/core/reference/renderer.d.ts +105 -0
  124. package/dist/core/reference/renderer.js +474 -0
  125. package/dist/core/reference/renderer.js.map +1 -0
  126. package/dist/core/reference/wgsl.d.ts +65 -0
  127. package/dist/core/reference/wgsl.js +803 -0
  128. package/dist/core/reference/wgsl.js.map +1 -0
  129. package/dist/{three → core}/sequence.d.ts +32 -2
  130. package/dist/{three → core}/sequence.js +24 -2
  131. package/dist/core/sequence.js.map +1 -0
  132. package/dist/core/source/brick-cache.d.ts +165 -0
  133. package/dist/core/source/brick-cache.js +627 -0
  134. package/dist/core/source/brick-cache.js.map +1 -0
  135. package/dist/core/source/dense-fill.d.ts +53 -0
  136. package/dist/core/source/dense-fill.js +377 -0
  137. package/dist/core/source/dense-fill.js.map +1 -0
  138. package/dist/core/source/dense.d.ts +33 -2
  139. package/dist/core/source/dense.js +121 -24
  140. package/dist/core/source/dense.js.map +1 -1
  141. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  142. package/dist/core/source/sparse-wgsl.js +481 -0
  143. package/dist/core/source/sparse-wgsl.js.map +1 -0
  144. package/dist/core/source/sparse.d.ts +192 -0
  145. package/dist/core/source/sparse.js +762 -0
  146. package/dist/core/source/sparse.js.map +1 -0
  147. package/dist/core/source/types.d.ts +59 -2
  148. package/dist/core/source/types.js.map +1 -1
  149. package/dist/core/surface/index.d.ts +10 -0
  150. package/dist/core/surface/index.js +9 -0
  151. package/dist/core/surface/index.js.map +1 -0
  152. package/dist/core/surface/level-set-pass.d.ts +140 -0
  153. package/dist/core/surface/level-set-pass.js +291 -0
  154. package/dist/core/surface/level-set-pass.js.map +1 -0
  155. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  156. package/dist/core/surface/level-set-wgsl.js +99 -0
  157. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  158. package/dist/core/surface/points.d.ts +109 -0
  159. package/dist/core/surface/points.js +226 -0
  160. package/dist/core/surface/points.js.map +1 -0
  161. package/dist/core/types.d.ts +12 -3
  162. package/dist/core/types.js +6 -2
  163. package/dist/core/types.js.map +1 -1
  164. package/dist/core/wgsl/api.d.ts +29 -5
  165. package/dist/core/wgsl/api.js +110 -27
  166. package/dist/core/wgsl/api.js.map +1 -1
  167. package/dist/core/wgsl/generate.d.ts +8 -0
  168. package/dist/core/wgsl/generate.js +195 -22
  169. package/dist/core/wgsl/generate.js.map +1 -1
  170. package/dist/core/wgsl/lean.d.ts +50 -0
  171. package/dist/core/wgsl/lean.js +327 -0
  172. package/dist/core/wgsl/lean.js.map +1 -0
  173. package/dist/core/wgsl/level-set.d.ts +5 -1
  174. package/dist/core/wgsl/level-set.js +11 -5
  175. package/dist/core/wgsl/level-set.js.map +1 -1
  176. package/dist/core/wgsl/majorant.d.ts +62 -0
  177. package/dist/core/wgsl/majorant.js +381 -0
  178. package/dist/core/wgsl/majorant.js.map +1 -0
  179. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
  180. package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
  181. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
  182. package/dist/core/wgsl/types.d.ts +97 -3
  183. package/dist/core/wgsl/types.js.map +1 -1
  184. package/dist/three/coarse-first.d.ts +53 -8
  185. package/dist/three/coarse-first.js +24 -6
  186. package/dist/three/coarse-first.js.map +1 -1
  187. package/dist/three/compute.d.ts +12 -2
  188. package/dist/three/compute.js +16 -6
  189. package/dist/three/compute.js.map +1 -1
  190. package/dist/three/device.d.ts +7 -0
  191. package/dist/three/device.js +3 -0
  192. package/dist/three/device.js.map +1 -1
  193. package/dist/three/frame/core-environment.d.ts +38 -0
  194. package/dist/three/frame/core-environment.js +154 -0
  195. package/dist/three/frame/core-environment.js.map +1 -0
  196. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  197. package/dist/three/frame/core-integrate-material.js +162 -0
  198. package/dist/three/frame/core-integrate-material.js.map +1 -0
  199. package/dist/three/frame/core-occluders.d.ts +53 -0
  200. package/dist/three/frame/core-occluders.js +193 -0
  201. package/dist/three/frame/core-occluders.js.map +1 -0
  202. package/dist/three/frame/core-structs.d.ts +34 -0
  203. package/dist/three/frame/core-structs.js +61 -0
  204. package/dist/three/frame/core-structs.js.map +1 -0
  205. package/dist/three/frame/core-textures.d.ts +41 -0
  206. package/dist/three/frame/core-textures.js +114 -0
  207. package/dist/three/frame/core-textures.js.map +1 -0
  208. package/dist/three/frame/emission-light.d.ts +64 -114
  209. package/dist/three/frame/emission-light.js +188 -567
  210. package/dist/three/frame/emission-light.js.map +1 -1
  211. package/dist/three/frame/index.d.ts +11 -31
  212. package/dist/three/frame/index.js +9 -29
  213. package/dist/three/frame/index.js.map +1 -1
  214. package/dist/three/frame/medium.d.ts +12 -0
  215. package/dist/three/frame/medium.js.map +1 -1
  216. package/dist/three/frame/renderer.d.ts +58 -454
  217. package/dist/three/frame/renderer.js +409 -1427
  218. package/dist/three/frame/renderer.js.map +1 -1
  219. package/dist/three/frame/spectrum.d.ts +0 -14
  220. package/dist/three/frame/spectrum.js +2 -23
  221. package/dist/three/frame/spectrum.js.map +1 -1
  222. package/dist/three/frame/three-internals.d.ts +3 -8
  223. package/dist/three/frame/three-internals.js +13 -11
  224. package/dist/three/frame/three-internals.js.map +1 -1
  225. package/dist/three/frame/volume-shadows.d.ts +93 -107
  226. package/dist/three/frame/volume-shadows.js +278 -631
  227. package/dist/three/frame/volume-shadows.js.map +1 -1
  228. package/dist/three/frame/volume.d.ts +91 -33
  229. package/dist/three/frame/volume.js +63 -51
  230. package/dist/three/frame/volume.js.map +1 -1
  231. package/dist/three/grid-node.d.ts +34 -1
  232. package/dist/three/grid-node.js +36 -1
  233. package/dist/three/grid-node.js.map +1 -1
  234. package/dist/three/index.d.ts +20 -11
  235. package/dist/three/index.js +21 -12
  236. package/dist/three/index.js.map +1 -1
  237. package/dist/three/internal.d.ts +14 -8
  238. package/dist/three/internal.js +11 -7
  239. package/dist/three/internal.js.map +1 -1
  240. package/dist/three/level-set-material.d.ts +81 -8
  241. package/dist/three/level-set-material.js +162 -125
  242. package/dist/three/level-set-material.js.map +1 -1
  243. package/dist/three/level-set-physical-material.d.ts +154 -0
  244. package/dist/three/level-set-physical-material.js +253 -0
  245. package/dist/three/level-set-physical-material.js.map +1 -0
  246. package/dist/three/level-set-velocity.d.ts +94 -0
  247. package/dist/three/level-set-velocity.js +208 -0
  248. package/dist/three/level-set-velocity.js.map +1 -0
  249. package/dist/three/material.d.ts +141 -11
  250. package/dist/three/material.js +161 -18
  251. package/dist/three/material.js.map +1 -1
  252. package/dist/three/points.d.ts +60 -4
  253. package/dist/three/points.js +140 -9
  254. package/dist/three/points.js.map +1 -1
  255. package/dist/three/sparse-source.d.ts +49 -117
  256. package/dist/three/sparse-source.js +109 -580
  257. package/dist/three/sparse-source.js.map +1 -1
  258. package/dist/three/volume-source.d.ts +11 -156
  259. package/dist/three/volume-source.js +29 -272
  260. package/dist/three/volume-source.js.map +1 -1
  261. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  262. package/dist/tools/cpu/brick-atlas.js +129 -0
  263. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  264. package/dist/tools/cpu/compute.d.ts +23 -4
  265. package/dist/tools/cpu/compute.js +35 -14
  266. package/dist/tools/cpu/compute.js.map +1 -1
  267. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  268. package/dist/tools/cpu/lean-reads.js +262 -0
  269. package/dist/tools/cpu/lean-reads.js.map +1 -0
  270. package/dist/tools/cpu/level-set.d.ts +42 -3
  271. package/dist/tools/cpu/level-set.js +59 -7
  272. package/dist/tools/cpu/level-set.js.map +1 -1
  273. package/dist/tools/cpu/majorant.d.ts +265 -0
  274. package/dist/tools/cpu/majorant.js +541 -0
  275. package/dist/tools/cpu/majorant.js.map +1 -0
  276. package/dist/tools/cpu/march.d.ts +93 -2
  277. package/dist/tools/cpu/march.js +165 -14
  278. package/dist/tools/cpu/march.js.map +1 -1
  279. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  280. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  281. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  282. package/dist/tools/cpu/points.d.ts +29 -0
  283. package/dist/tools/cpu/points.js +38 -0
  284. package/dist/tools/cpu/points.js.map +1 -0
  285. package/dist/tools/cpu/read-value.d.ts +19 -6
  286. package/dist/tools/cpu/read-value.js +32 -17
  287. package/dist/tools/cpu/read-value.js.map +1 -1
  288. package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
  289. package/dist/tools/cpu/sample-trilinear.js +19 -7
  290. package/dist/tools/cpu/sample-trilinear.js.map +1 -1
  291. package/dist/tools/cpu/stride-tables.d.ts +2 -2
  292. package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
  293. package/dist/tools/cpu/stride-tables.generated.js +7 -6
  294. package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
  295. package/dist/tools/cpu/stride-tables.js +1 -1
  296. package/dist/tools/cpu/stride-tables.js.map +1 -1
  297. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  298. package/dist/tools/cpu/surface-nets.js +597 -0
  299. package/dist/tools/cpu/surface-nets.js.map +1 -0
  300. package/dist/tools/errors.d.ts +9 -0
  301. package/dist/tools/errors.js +9 -0
  302. package/dist/tools/errors.js.map +1 -1
  303. package/dist/tools/frame/ambient.d.ts +98 -0
  304. package/dist/tools/frame/ambient.js +274 -0
  305. package/dist/tools/frame/ambient.js.map +1 -0
  306. package/dist/tools/frame/blackbody.d.ts +15 -0
  307. package/dist/tools/frame/blackbody.js +35 -0
  308. package/dist/tools/frame/blackbody.js.map +1 -1
  309. package/dist/tools/frame/brick-cache.d.ts +165 -0
  310. package/dist/tools/frame/brick-cache.js +326 -0
  311. package/dist/tools/frame/brick-cache.js.map +1 -0
  312. package/dist/tools/frame/emission.d.ts +9 -0
  313. package/dist/tools/frame/emission.js +9 -1
  314. package/dist/tools/frame/emission.js.map +1 -1
  315. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  316. package/dist/tools/frame/environment-gpu.js +280 -0
  317. package/dist/tools/frame/environment-gpu.js.map +1 -0
  318. package/dist/tools/frame/environment.d.ts +3 -2
  319. package/dist/tools/frame/environment.js +8 -4
  320. package/dist/tools/frame/environment.js.map +1 -1
  321. package/dist/tools/frame/froxel.d.ts +58 -0
  322. package/dist/tools/frame/froxel.js +115 -0
  323. package/dist/tools/frame/froxel.js.map +1 -0
  324. package/dist/tools/frame/grid.d.ts +90 -0
  325. package/dist/tools/frame/grid.js +112 -13
  326. package/dist/tools/frame/grid.js.map +1 -1
  327. package/dist/tools/frame/index.d.ts +14 -0
  328. package/dist/tools/frame/index.js +45 -4
  329. package/dist/tools/frame/index.js.map +1 -1
  330. package/dist/tools/frame/medium.d.ts +16 -0
  331. package/dist/tools/frame/medium.js +3 -1
  332. package/dist/tools/frame/medium.js.map +1 -1
  333. package/dist/tools/frame/mie.d.ts +9 -0
  334. package/dist/tools/frame/mie.js +18 -0
  335. package/dist/tools/frame/mie.js.map +1 -1
  336. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  337. package/dist/tools/frame/mlp-nn.js +159 -0
  338. package/dist/tools/frame/mlp-nn.js.map +1 -0
  339. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  340. package/dist/tools/frame/mlp-tza.js +186 -0
  341. package/dist/tools/frame/mlp-tza.js.map +1 -0
  342. package/dist/tools/frame/mlp.d.ts +183 -0
  343. package/dist/tools/frame/mlp.js +434 -0
  344. package/dist/tools/frame/mlp.js.map +1 -0
  345. package/dist/tools/frame/ms-exit.d.ts +42 -0
  346. package/dist/tools/frame/ms-exit.js +90 -0
  347. package/dist/tools/frame/ms-exit.js.map +1 -0
  348. package/dist/tools/frame/multi-scale.d.ts +152 -0
  349. package/dist/tools/frame/multi-scale.js +302 -0
  350. package/dist/tools/frame/multi-scale.js.map +1 -0
  351. package/dist/tools/frame/neural-weights.d.ts +6 -5
  352. package/dist/tools/frame/neural-weights.js +234 -235
  353. package/dist/tools/frame/neural-weights.js.map +1 -1
  354. package/dist/tools/frame/neural.js +1 -1
  355. package/dist/tools/frame/neural.js.map +1 -1
  356. package/dist/tools/frame/occluders.d.ts +51 -0
  357. package/dist/tools/frame/occluders.js +72 -0
  358. package/dist/tools/frame/occluders.js.map +1 -0
  359. package/dist/tools/frame/pyramid-layout.d.ts +17 -0
  360. package/dist/tools/frame/pyramid-layout.js +47 -0
  361. package/dist/tools/frame/pyramid-layout.js.map +1 -1
  362. package/dist/tools/frame/shadows.d.ts +110 -0
  363. package/dist/tools/frame/shadows.js +286 -0
  364. package/dist/tools/frame/shadows.js.map +1 -1
  365. package/dist/tools/frame/sparse.d.ts +82 -0
  366. package/dist/tools/frame/sparse.js +242 -1
  367. package/dist/tools/frame/sparse.js.map +1 -1
  368. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  369. package/dist/tools/frame/spectral-stack.js +391 -0
  370. package/dist/tools/frame/spectral-stack.js.map +1 -0
  371. package/dist/tools/frame/spectral.d.ts +21 -2
  372. package/dist/tools/frame/spectral.js +30 -8
  373. package/dist/tools/frame/spectral.js.map +1 -1
  374. package/dist/tools/frame/stack.d.ts +115 -0
  375. package/dist/tools/frame/stack.js +290 -0
  376. package/dist/tools/frame/stack.js.map +1 -0
  377. package/dist/tools/frame/view.d.ts +131 -0
  378. package/dist/tools/frame/view.js +337 -0
  379. package/dist/tools/frame/view.js.map +1 -0
  380. package/dist/tools/index.d.ts +66 -15
  381. package/dist/tools/index.js +55 -11
  382. package/dist/tools/index.js.map +1 -1
  383. package/dist/tools/internal.d.ts +58 -17
  384. package/dist/tools/internal.js +65 -11
  385. package/dist/tools/internal.js.map +1 -1
  386. package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
  387. package/dist/tools/nanovdb/build-from-vdb.js +10 -2
  388. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
  389. package/dist/tools/nanovdb/bytes.d.ts +17 -4
  390. package/dist/tools/nanovdb/bytes.js +46 -3
  391. package/dist/tools/nanovdb/bytes.js.map +1 -1
  392. package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
  393. package/dist/tools/nanovdb/coarse-first.js +7 -1
  394. package/dist/tools/nanovdb/coarse-first.js.map +1 -1
  395. package/dist/tools/nanovdb/half.d.ts +22 -0
  396. package/dist/tools/nanovdb/half.js +73 -0
  397. package/dist/tools/nanovdb/half.js.map +1 -0
  398. package/dist/tools/nanovdb/index.d.ts +3 -1
  399. package/dist/tools/nanovdb/index.js +2 -1
  400. package/dist/tools/nanovdb/index.js.map +1 -1
  401. package/dist/tools/nanovdb/inspect.d.ts +10 -1
  402. package/dist/tools/nanovdb/inspect.js +8 -1
  403. package/dist/tools/nanovdb/inspect.js.map +1 -1
  404. package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
  405. package/dist/tools/nanovdb/leaf-codec.js +40 -4
  406. package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
  407. package/dist/tools/nanovdb/quantize.d.ts +39 -10
  408. package/dist/tools/nanovdb/quantize.js +96 -44
  409. package/dist/tools/nanovdb/quantize.js.map +1 -1
  410. package/dist/tools/nanovdb/resample.d.ts +20 -3
  411. package/dist/tools/nanovdb/resample.js +20 -7
  412. package/dist/tools/nanovdb/resample.js.map +1 -1
  413. package/dist/tools/nanovdb/serialize.d.ts +34 -3
  414. package/dist/tools/nanovdb/serialize.js +51 -7
  415. package/dist/tools/nanovdb/serialize.js.map +1 -1
  416. package/dist/tools/nanovdb/stats.d.ts +34 -5
  417. package/dist/tools/nanovdb/stats.js +87 -11
  418. package/dist/tools/nanovdb/stats.js.map +1 -1
  419. package/dist/tools/nanovdb/transform.d.ts +4 -0
  420. package/dist/tools/nanovdb/transform.js +3 -0
  421. package/dist/tools/nanovdb/transform.js.map +1 -1
  422. package/dist/tools/nanovdb/tree.d.ts +14 -3
  423. package/dist/tools/nanovdb/tree.js +25 -13
  424. package/dist/tools/nanovdb/tree.js.map +1 -1
  425. package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
  426. package/dist/tools/nanovdb/write-nvdb.js +108 -28
  427. package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
  428. package/dist/tools/nvdb-file.d.ts +77 -7
  429. package/dist/tools/nvdb-file.js +177 -20
  430. package/dist/tools/nvdb-file.js.map +1 -1
  431. package/dist/tools/nvdb-stream.d.ts +23 -7
  432. package/dist/tools/nvdb-stream.js +78 -34
  433. package/dist/tools/nvdb-stream.js.map +1 -1
  434. package/dist/tools/reference/analytic.d.ts +41 -0
  435. package/dist/tools/reference/analytic.js +95 -0
  436. package/dist/tools/reference/analytic.js.map +1 -0
  437. package/dist/tools/reference/environment.d.ts +62 -0
  438. package/dist/tools/reference/environment.js +154 -0
  439. package/dist/tools/reference/environment.js.map +1 -0
  440. package/dist/tools/reference/index.d.ts +12 -0
  441. package/dist/tools/reference/index.js +13 -0
  442. package/dist/tools/reference/index.js.map +1 -0
  443. package/dist/tools/reference/media.d.ts +14 -0
  444. package/dist/tools/reference/media.js +30 -0
  445. package/dist/tools/reference/media.js.map +1 -0
  446. package/dist/tools/reference/rng.d.ts +20 -0
  447. package/dist/tools/reference/rng.js +30 -0
  448. package/dist/tools/reference/rng.js.map +1 -0
  449. package/dist/tools/reference/scene.d.ts +312 -0
  450. package/dist/tools/reference/scene.js +169 -0
  451. package/dist/tools/reference/scene.js.map +1 -0
  452. package/dist/tools/reference/tables.d.ts +98 -0
  453. package/dist/tools/reference/tables.js +264 -0
  454. package/dist/tools/reference/tables.js.map +1 -0
  455. package/dist/tools/reference/trace.d.ts +160 -0
  456. package/dist/tools/reference/trace.js +497 -0
  457. package/dist/tools/reference/trace.js.map +1 -0
  458. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  459. package/dist/tools/vdb/blosc-write.js +197 -0
  460. package/dist/tools/vdb/blosc-write.js.map +1 -0
  461. package/dist/tools/vdb/blosc.d.ts +35 -5
  462. package/dist/tools/vdb/blosc.js +82 -26
  463. package/dist/tools/vdb/blosc.js.map +1 -1
  464. package/dist/tools/vdb/blosclz.d.ts +33 -0
  465. package/dist/tools/vdb/blosclz.js +112 -0
  466. package/dist/tools/vdb/blosclz.js.map +1 -0
  467. package/dist/tools/vdb/byte-reader.d.ts +13 -3
  468. package/dist/tools/vdb/byte-reader.js +26 -4
  469. package/dist/tools/vdb/byte-reader.js.map +1 -1
  470. package/dist/tools/vdb/compression.d.ts +13 -5
  471. package/dist/tools/vdb/compression.js +13 -2
  472. package/dist/tools/vdb/compression.js.map +1 -1
  473. package/dist/tools/vdb/grid.js +8 -2
  474. package/dist/tools/vdb/grid.js.map +1 -1
  475. package/dist/tools/vdb/index.d.ts +2 -1
  476. package/dist/tools/vdb/index.js.map +1 -1
  477. package/dist/tools/vdb/lz4.d.ts +30 -0
  478. package/dist/tools/vdb/lz4.js +228 -0
  479. package/dist/tools/vdb/lz4.js.map +1 -0
  480. package/dist/tools/vdb/metadata.js +1 -1
  481. package/dist/tools/vdb/metadata.js.map +1 -1
  482. package/dist/tools/vdb/parse.d.ts +24 -2
  483. package/dist/tools/vdb/parse.js +102 -32
  484. package/dist/tools/vdb/parse.js.map +1 -1
  485. package/dist/tools/vdb/point-render-data.d.ts +49 -1
  486. package/dist/tools/vdb/point-render-data.js +91 -11
  487. package/dist/tools/vdb/point-render-data.js.map +1 -1
  488. package/dist/tools/vdb/points.d.ts +26 -0
  489. package/dist/tools/vdb/points.js +46 -5
  490. package/dist/tools/vdb/points.js.map +1 -1
  491. package/dist/tools/vdb/types.d.ts +59 -2
  492. package/dist/tools/vdb/types.js.map +1 -1
  493. package/dist/tools/wvdb/bake.d.ts +38 -9
  494. package/dist/tools/wvdb/bake.js +63 -13
  495. package/dist/tools/wvdb/bake.js.map +1 -1
  496. package/dist/tools/wvdb/dense.d.ts +80 -1
  497. package/dist/tools/wvdb/dense.js +67 -8
  498. package/dist/tools/wvdb/dense.js.map +1 -1
  499. package/dist/tools/wvdb/format.d.ts +59 -0
  500. package/dist/tools/wvdb/format.js +3 -0
  501. package/dist/tools/wvdb/format.js.map +1 -1
  502. package/dist/tools/wvdb/index.d.ts +1 -0
  503. package/dist/tools/wvdb/index.js +1 -0
  504. package/dist/tools/wvdb/index.js.map +1 -1
  505. package/dist/tools/wvdb/level-set.d.ts +10 -2
  506. package/dist/tools/wvdb/level-set.js.map +1 -1
  507. package/dist/tools/wvdb/nanovdb.d.ts +6 -1
  508. package/dist/tools/wvdb/nanovdb.js +5 -1
  509. package/dist/tools/wvdb/nanovdb.js.map +1 -1
  510. package/dist/tools/wvdb/partial.d.ts +74 -0
  511. package/dist/tools/wvdb/partial.js +233 -0
  512. package/dist/tools/wvdb/partial.js.map +1 -0
  513. package/dist/tools/wvdb/read.d.ts +77 -1
  514. package/dist/tools/wvdb/read.js +30 -7
  515. package/dist/tools/wvdb/read.js.map +1 -1
  516. package/dist/tools/wvdb/write.d.ts +23 -1
  517. package/dist/tools/wvdb/write.js +8 -1
  518. package/dist/tools/wvdb/write.js.map +1 -1
  519. package/package.json +2 -1
  520. package/vendor/VENDOR.md +21 -6
  521. package/vendor/pnanovdb.wgsl +52 -14
  522. package/dist/three/frame/blackbody.d.ts +0 -42
  523. package/dist/three/frame/blackbody.js +0 -74
  524. package/dist/three/frame/blackbody.js.map +0 -1
  525. package/dist/three/frame/chunks.d.ts +0 -157
  526. package/dist/three/frame/chunks.js +0 -559
  527. package/dist/three/frame/chunks.js.map +0 -1
  528. package/dist/three/frame/density-material.d.ts +0 -53
  529. package/dist/three/frame/density-material.js +0 -353
  530. package/dist/three/frame/density-material.js.map +0 -1
  531. package/dist/three/frame/environment-grid-material.d.ts +0 -21
  532. package/dist/three/frame/environment-grid-material.js +0 -184
  533. package/dist/three/frame/environment-grid-material.js.map +0 -1
  534. package/dist/three/frame/environment-material.d.ts +0 -22
  535. package/dist/three/frame/environment-material.js +0 -87
  536. package/dist/three/frame/environment-material.js.map +0 -1
  537. package/dist/three/frame/grid-mip-material.d.ts +0 -12
  538. package/dist/three/frame/grid-mip-material.js +0 -61
  539. package/dist/three/frame/grid-mip-material.js.map +0 -1
  540. package/dist/three/frame/inject-material.d.ts +0 -56
  541. package/dist/three/frame/inject-material.js +0 -424
  542. package/dist/three/frame/inject-material.js.map +0 -1
  543. package/dist/three/frame/integrate-material.d.ts +0 -26
  544. package/dist/three/frame/integrate-material.js +0 -198
  545. package/dist/three/frame/integrate-material.js.map +0 -1
  546. package/dist/three/frame/layout.d.ts +0 -34
  547. package/dist/three/frame/layout.js +0 -48
  548. package/dist/three/frame/layout.js.map +0 -1
  549. package/dist/three/frame/lighting-material.d.ts +0 -41
  550. package/dist/three/frame/lighting-material.js +0 -257
  551. package/dist/three/frame/lighting-material.js.map +0 -1
  552. package/dist/three/frame/lights.d.ts +0 -11
  553. package/dist/three/frame/lights.js +0 -16
  554. package/dist/three/frame/lights.js.map +0 -1
  555. package/dist/three/frame/neural.d.ts +0 -14
  556. package/dist/three/frame/neural.js +0 -105
  557. package/dist/three/frame/neural.js.map +0 -1
  558. package/dist/three/frame/phase.d.ts +0 -44
  559. package/dist/three/frame/phase.js +0 -80
  560. package/dist/three/frame/phase.js.map +0 -1
  561. package/dist/three/frame/shadow-density-material.d.ts +0 -30
  562. package/dist/three/frame/shadow-density-material.js +0 -123
  563. package/dist/three/frame/shadow-density-material.js.map +0 -1
  564. package/dist/three/frame/temporal-material.d.ts +0 -29
  565. package/dist/three/frame/temporal-material.js +0 -152
  566. package/dist/three/frame/temporal-material.js.map +0 -1
  567. package/dist/three/frame/transmittance-material.d.ts +0 -31
  568. package/dist/three/frame/transmittance-material.js +0 -315
  569. package/dist/three/frame/transmittance-material.js.map +0 -1
  570. package/dist/three/frame/view.d.ts +0 -103
  571. package/dist/three/frame/view.js +0 -296
  572. package/dist/three/frame/view.js.map +0 -1
  573. package/dist/three/frame/volume-shadow-material.d.ts +0 -36
  574. package/dist/three/frame/volume-shadow-material.js +0 -128
  575. package/dist/three/frame/volume-shadow-material.js.map +0 -1
  576. package/dist/three/sequence.js.map +0 -1
@@ -0,0 +1,193 @@
1
+ /**
2
+ * K6.5b: three's light shadow maps as the core renderer's occluder maps (mesh → volume shadows, design §3.7). For each
3
+ * directional, spot and point light with `castShadow` (and `renderer.shadowMap.enabled`) whose map three has drawn, the
4
+ * adapter passes the map's depth `GPUTexture` (a `'2d-array'` view: one layer, or the point light's 6 cube faces), the
5
+ * view-projections it was drawn with, `shadow.bias`, the renderer's reversed depth and the filter (`BasicShadowMap`:
6
+ * one texel, else 2 × 2 PCF).
7
+ *
8
+ * **No lag.** three draws a light's map inside its own render, when the first lit material of the frame draws (the
9
+ * light's `ShadowNode.updateBefore`). Before the core update the adapter calls that `updateBefore` itself, with three's
10
+ * frame id, so three draws (and submits) the map first and skips it later in the same frame; the core then reads this
11
+ * frame's map with this frame's matrices. A map three does not redraw this frame (`autoUpdate` off) is read as it is,
12
+ * with the matrices it was drawn with (they stay on the shadow camera), so map and matrices always agree.
13
+ *
14
+ * three r187 internals used, checked by a self-test per backend and map kind (`VDB_ENGINE_MISMATCH` otherwise):
15
+ * 1. `light.shadow.map.depthTexture`'s GPU texture (`backend.get(t).texture`): a depth format with `TEXTURE_BINDING`,
16
+ * 1 layer (directional, spot) or 6 (point, `CubeDepthTexture`);
17
+ * 2. `light.shadow.matrix` is the WebGPU bias matrix × `shadow.camera` projection × view of the last draw
18
+ * (`LightShadow._updateMatrix`); a point light's is the translation to the light of the last draw
19
+ * (`PointShadowNode.renderShadow`), which leaves `shadow.camera` on face 5, and its faces follow three's WebGPU
20
+ * table (checked on face 5);
21
+ * 3. the shared `AnalyticLightNode` of a light (`three-internals.ts` internal 1) has the `ShadowNode` in
22
+ * `shadowNode`, whose `updateBefore(frame)` draws the map once per frame and camera (`_cameraFrameId`), reading
23
+ * `frame.renderer / scene / camera / frameId`.
24
+ * Not supported: logarithmic depth buffers (the maps store log depth; warned, skipped); `CSMShadowNode` (its cascades
25
+ * are lights of their own; not mapped); `shadow.normalBias` (a volume has no normal).
26
+ */
27
+ import * as THREE from "three";
28
+ import { REVISION } from "three";
29
+ import { VDBError } from "../../core/errors.js";
30
+ import { vdbFrameSharedLightNode } from "./three-internals.js";
31
+ /** three r187 PointShadowNode's WebGPU cube faces: directions and ups (`_cubeDirectionsWebGPU`, `_cubeUpsWebGPU`). */
32
+ const CUBE_DIRECTIONS = [new THREE.Vector3(-1, 0, 0), new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, -1, 0), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 0, -1)];
33
+ const CUBE_UPS = [new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 0, -1), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0)];
34
+ /** `LightShadow._updateMatrix`'s WebGPU bias (uv = ndc · ½ + ½, z kept). */
35
+ const WEBGPU_BIAS = new THREE.Matrix4().set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
36
+ const TEXTURE_BINDING = 0x04;
37
+ const mismatch = (what) => new VDBError("VDB_ENGINE_MISMATCH", `three adapter (core occluder maps): three r${REVISION} ${what}. The frame renderer reads three's light shadow maps through three r187 ` +
38
+ "internals (peer range >=0.187.0 <0.188.0); this three version is unsupported for mesh → volume shadows (set frameRenderer.settings.occlusion = false).");
39
+ const near = (a, b, eps) => {
40
+ for (let i = 0; i < 16; i++)
41
+ if (Math.abs(a[i] - b[i]) > eps * Math.max(1, Math.abs(b[i])))
42
+ return false;
43
+ return true;
44
+ };
45
+ /** Self-test results per backend and kind ('2d' | 'cube' | 'flush'). */
46
+ const selfTested = new WeakMap();
47
+ function check(backend, kind, test) {
48
+ let byKind = selfTested.get(backend);
49
+ if (!byKind)
50
+ selfTested.set(backend, (byKind = new Map()));
51
+ const cached = byKind.get(kind);
52
+ if (cached === true)
53
+ return;
54
+ if (cached)
55
+ throw cached;
56
+ let problem;
57
+ try {
58
+ problem = test();
59
+ }
60
+ catch (e) {
61
+ problem = `failed the occluder self-test (${e instanceof Error ? e.message : String(e)})`;
62
+ }
63
+ const result = problem ? mismatch(problem) : true;
64
+ byKind.set(kind, result);
65
+ if (result !== true)
66
+ throw result;
67
+ }
68
+ /** The occluder inputs of a render (one instance per `VDBFrameRenderer`). */
69
+ export class VDBCoreOccluders {
70
+ #views = new WeakMap();
71
+ #state = new WeakMap();
72
+ #nodes = new WeakMap();
73
+ #camera = new THREE.PerspectiveCamera();
74
+ #warned = new Set();
75
+ /**
76
+ * The occluder maps of `lights` (three lights in the camera's layers that the core lights; ids = `light.id`) for this
77
+ * render: draws three's pending maps first (no lag), then reads each map that exists.
78
+ */
79
+ input(renderer, scene, camera, lights) {
80
+ if (!renderer.shadowMap?.enabled)
81
+ return [];
82
+ if (renderer.logarithmicDepthBuffer) {
83
+ this.#warnOnce("log", "mesh → volume shadows do not read logarithmic-depth shadow maps; occlusion is off.");
84
+ return [];
85
+ }
86
+ const backend = renderer.backend;
87
+ const frameId = renderer._nodes?.nodeFrame?.frameId;
88
+ const out = [];
89
+ for (const object of lights) {
90
+ const light = object;
91
+ if (!light.castShadow || !(light.isDirectionalLight || light.isSpotLight || light.isPointLight))
92
+ continue;
93
+ const shadow = light.shadow;
94
+ if (!shadow)
95
+ continue;
96
+ const state = this.#state.get(light) ?? { revision: 0, frame: -1 };
97
+ this.#state.set(light, state);
98
+ // three draws this frame's map now (if it will at all), so the core reads it in this render
99
+ if (this.#flush(renderer, scene, camera, light, frameId)) {
100
+ if (state.frame !== frameId)
101
+ state.revision++;
102
+ state.frame = frameId ?? -1;
103
+ }
104
+ const depthTexture = shadow.map?.depthTexture;
105
+ if (!depthTexture)
106
+ continue;
107
+ const gpu = backend.get(depthTexture)?.texture;
108
+ if (!gpu)
109
+ continue;
110
+ const point = !!light.isPointLight;
111
+ check(backend, point ? "cube" : "2d", () => {
112
+ if (!String(gpu.format).startsWith("depth"))
113
+ return `stores a light's shadow map as ${gpu.format}, not a depth format`;
114
+ if (!(gpu.usage & TEXTURE_BINDING))
115
+ return "made a shadow map without TEXTURE_BINDING";
116
+ if (gpu.depthOrArrayLayers !== (point ? 6 : 1))
117
+ return `made a ${point ? "point" : "directional / spot"} shadow map with ${gpu.depthOrArrayLayers} layers`;
118
+ return point ? this.#checkCube(light) : this.#check2d(shadow);
119
+ });
120
+ let view = this.#views.get(gpu);
121
+ if (!view)
122
+ this.#views.set(gpu, (view = gpu.createView({ dimension: "2d-array", aspect: "depth-only", label: `vdb occluder ${light.name || light.id}` })));
123
+ out.push({
124
+ light: light.id,
125
+ depth: view,
126
+ viewProjection: point ? this.#faces(light) : [new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse).elements],
127
+ bias: shadow.bias,
128
+ reversedDepth: !!renderer.reversedDepthBuffer,
129
+ filter: renderer.shadowMap.type === THREE.BasicShadowMap ? "nearest" : "bilinear",
130
+ revision: state.revision,
131
+ });
132
+ }
133
+ return out;
134
+ }
135
+ /**
136
+ * Runs the light's `ShadowNode.updateBefore` with three's frame (internal 3): three draws the map now if it would draw
137
+ * it this frame, and not again later. Returns whether the map was drawn this frame for this camera.
138
+ */
139
+ #flush(renderer, scene, camera, light, frameId) {
140
+ let lightNode = this.#nodes.get(light);
141
+ if (lightNode === undefined)
142
+ this.#nodes.set(light, (lightNode = vdbFrameSharedLightNode(light)));
143
+ const shadowNode = lightNode?.shadowNode;
144
+ // No shadow node: no lit material uses the light yet, so three has no map (nothing to read)
145
+ if (!shadowNode)
146
+ return false;
147
+ check(renderer.backend, "flush", () => {
148
+ if (typeof frameId !== "number")
149
+ return "has no renderer._nodes.nodeFrame.frameId";
150
+ if (typeof shadowNode.updateBefore !== "function")
151
+ return "has no ShadowNode.updateBefore";
152
+ if (!(shadowNode._cameraFrameId instanceof WeakMap))
153
+ return "has no ShadowNode._cameraFrameId (its once-per-frame guard)";
154
+ return null;
155
+ });
156
+ shadowNode.updateBefore({ renderer, scene, camera, frameId, renderId: renderer._nodes?.nodeFrame?.renderId });
157
+ return shadowNode._cameraFrameId.get(camera) === frameId;
158
+ }
159
+ /** Internal 2 for a directional or spot map: shadow.matrix = bias × the camera's projection × view. */
160
+ #check2d(shadow) {
161
+ const expected = new THREE.Matrix4().multiplyMatrices(WEBGPU_BIAS, new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse));
162
+ return near(shadow.matrix.elements, expected.elements, 1e-5) ? null : "keeps a shadow.matrix that is not bias × the shadow camera's projection × view (the map's draw state is unknown)";
163
+ }
164
+ /** Internal 2 for a point map: face 5 of the table from the light position of the last draw equals the shadow camera. */
165
+ #checkCube(light) {
166
+ const faces = this.#faceViews(light);
167
+ return near(faces[5].elements, light.shadow.camera.matrixWorldInverse.elements, 1e-5) ? null : "draws point shadow faces another way (face 5 does not match the shadow camera)";
168
+ }
169
+ /** The 6 face views of a point light's last draw (its position from `shadow.matrix`, three's WebGPU table). */
170
+ #faceViews(light) {
171
+ const position = new THREE.Vector3().setFromMatrixPosition(light.shadow.matrix).negate();
172
+ const c = this.#camera;
173
+ return CUBE_DIRECTIONS.map((direction, face) => {
174
+ c.position.copy(position);
175
+ c.up.copy(CUBE_UPS[face]);
176
+ c.lookAt(position.clone().add(direction));
177
+ c.updateMatrixWorld(true);
178
+ return c.matrixWorldInverse.clone();
179
+ });
180
+ }
181
+ /** The 6 face view-projections (one projection: the shadow camera's, as drawn). */
182
+ #faces(light) {
183
+ const projection = light.shadow.camera.projectionMatrix;
184
+ return this.#faceViews(light).map((view) => Float32Array.from(new THREE.Matrix4().multiplyMatrices(projection, view).elements));
185
+ }
186
+ #warnOnce(key, message) {
187
+ if (this.#warned.has(key))
188
+ return;
189
+ this.#warned.add(key);
190
+ console.warn(`@pmndrs/vdb/three: ${message}`);
191
+ }
192
+ }
193
+ //# sourceMappingURL=core-occluders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-occluders.js","sourceRoot":"","sources":["../../../src/three/frame/core-occluders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAe/D,sHAAsH;AACtH,MAAM,eAAe,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACpM,MAAM,QAAQ,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CA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,EAAE,CAAC,CAAC;IAChD,CAAC;CACF","sourcesContent":["/**\n * K6.5b: three's light shadow maps as the core renderer's occluder maps (mesh → volume shadows, design §3.7). For each\n * directional, spot and point light with `castShadow` (and `renderer.shadowMap.enabled`) whose map three has drawn, the\n * adapter passes the map's depth `GPUTexture` (a `'2d-array'` view: one layer, or the point light's 6 cube faces), the\n * view-projections it was drawn with, `shadow.bias`, the renderer's reversed depth and the filter (`BasicShadowMap`:\n * one texel, else 2 × 2 PCF).\n *\n * **No lag.** three draws a light's map inside its own render, when the first lit material of the frame draws (the\n * light's `ShadowNode.updateBefore`). Before the core update the adapter calls that `updateBefore` itself, with three's\n * frame id, so three draws (and submits) the map first and skips it later in the same frame; the core then reads this\n * frame's map with this frame's matrices. A map three does not redraw this frame (`autoUpdate` off) is read as it is,\n * with the matrices it was drawn with (they stay on the shadow camera), so map and matrices always agree.\n *\n * three r187 internals used, checked by a self-test per backend and map kind (`VDB_ENGINE_MISMATCH` otherwise):\n * 1. `light.shadow.map.depthTexture`'s GPU texture (`backend.get(t).texture`): a depth format with `TEXTURE_BINDING`,\n * 1 layer (directional, spot) or 6 (point, `CubeDepthTexture`);\n * 2. `light.shadow.matrix` is the WebGPU bias matrix × `shadow.camera` projection × view of the last draw\n * (`LightShadow._updateMatrix`); a point light's is the translation to the light of the last draw\n * (`PointShadowNode.renderShadow`), which leaves `shadow.camera` on face 5, and its faces follow three's WebGPU\n * table (checked on face 5);\n * 3. the shared `AnalyticLightNode` of a light (`three-internals.ts` internal 1) has the `ShadowNode` in\n * `shadowNode`, whose `updateBefore(frame)` draws the map once per frame and camera (`_cameraFrameId`), reading\n * `frame.renderer / scene / camera / frameId`.\n * Not supported: logarithmic depth buffers (the maps store log depth; warned, skipped); `CSMShadowNode` (its cascades\n * are lights of their own; not mapped); `shadow.normalBias` (a volume has no normal).\n */\n\nimport * as THREE from \"three\";\nimport { REVISION } from \"three\";\nimport { VDBError } from \"../../core/errors.js\";\nimport type { VDBFrameOccluder } from \"../../core/frame/types.js\";\nimport { vdbFrameSharedLightNode } from \"./three-internals.js\";\n\ninterface BackendLike {\n get(object: object): Record<string, unknown>;\n}\ntype RendererLike = THREE.EventDispatcher & {\n readonly backend: object;\n shadowMap: { enabled: boolean; type: THREE.ShadowMapType };\n reversedDepthBuffer?: boolean;\n logarithmicDepthBuffer?: boolean;\n _nodes?: { nodeFrame?: { frameId?: number; renderId?: number } };\n};\ntype ShadowLight = (THREE.DirectionalLight | THREE.SpotLight | THREE.PointLight) & { isDirectionalLight?: boolean; isSpotLight?: boolean; isPointLight?: boolean };\ntype ShadowNodeLike = { updateBefore?: (frame: object) => unknown; _cameraFrameId?: WeakMap<object, number> };\n\n/** three r187 PointShadowNode's WebGPU cube faces: directions and ups (`_cubeDirectionsWebGPU`, `_cubeUpsWebGPU`). */\nconst CUBE_DIRECTIONS = [new THREE.Vector3(-1, 0, 0), new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, -1, 0), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 0, -1)];\nconst CUBE_UPS = [new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 0, -1), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0)];\n/** `LightShadow._updateMatrix`'s WebGPU bias (uv = ndc · ½ + ½, z kept). */\nconst WEBGPU_BIAS = new THREE.Matrix4().set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);\nconst TEXTURE_BINDING = 0x04;\n\nconst mismatch = (what: string): VDBError =>\n new VDBError(\n \"VDB_ENGINE_MISMATCH\",\n `three adapter (core occluder maps): three r${REVISION} ${what}. The frame renderer reads three's light shadow maps through three r187 ` +\n \"internals (peer range >=0.187.0 <0.188.0); this three version is unsupported for mesh → volume shadows (set frameRenderer.settings.occlusion = false).\",\n );\n\nconst near = (a: ArrayLike<number>, b: ArrayLike<number>, eps: number) => {\n for (let i = 0; i < 16; i++) if (Math.abs(a[i]! - b[i]!) > eps * Math.max(1, Math.abs(b[i]!))) return false;\n return true;\n};\n\n/** Self-test results per backend and kind ('2d' | 'cube' | 'flush'). */\nconst selfTested = new WeakMap<object, Map<string, true | VDBError>>();\n\nfunction check(backend: object, kind: string, test: () => string | null): void {\n let byKind = selfTested.get(backend);\n if (!byKind) selfTested.set(backend, (byKind = new Map()));\n const cached = byKind.get(kind);\n if (cached === true) return;\n if (cached) throw cached;\n let problem: string | null;\n try {\n problem = test();\n } catch (e) {\n problem = `failed the occluder self-test (${e instanceof Error ? e.message : String(e)})`;\n }\n const result = problem ? mismatch(problem) : true;\n byKind.set(kind, result);\n if (result !== true) throw result;\n}\n\n/** One light's state across updates: its revision (bumped when three drew the map) and the frame that bumped it. */\ninterface LightState {\n revision: number;\n frame: number;\n}\n\n/** The occluder inputs of a render (one instance per `VDBFrameRenderer`). */\nexport class VDBCoreOccluders {\n readonly #views = new WeakMap<GPUTexture, GPUTextureView>();\n readonly #state = new WeakMap<object, LightState>();\n readonly #nodes = new WeakMap<object, { shadowNode?: unknown } | null>();\n readonly #camera = new THREE.PerspectiveCamera();\n #warned = new Set<string>();\n\n /**\n * The occluder maps of `lights` (three lights in the camera's layers that the core lights; ids = `light.id`) for this\n * render: draws three's pending maps first (no lag), then reads each map that exists.\n */\n input(renderer: RendererLike, scene: THREE.Object3D, camera: THREE.Camera, lights: readonly THREE.Light[]): VDBFrameOccluder[] {\n if (!renderer.shadowMap?.enabled) return [];\n if (renderer.logarithmicDepthBuffer) {\n this.#warnOnce(\"log\", \"mesh → volume shadows do not read logarithmic-depth shadow maps; occlusion is off.\");\n return [];\n }\n const backend = renderer.backend as BackendLike;\n const frameId = renderer._nodes?.nodeFrame?.frameId;\n const out: VDBFrameOccluder[] = [];\n for (const object of lights) {\n const light = object as ShadowLight;\n if (!light.castShadow || !(light.isDirectionalLight || light.isSpotLight || light.isPointLight)) continue;\n const shadow = light.shadow as THREE.LightShadow & { autoUpdate?: boolean; needsUpdate?: boolean };\n if (!shadow) continue;\n const state = this.#state.get(light) ?? { revision: 0, frame: -1 };\n this.#state.set(light, state);\n // three draws this frame's map now (if it will at all), so the core reads it in this render\n if (this.#flush(renderer, scene, camera, light, frameId)) {\n if (state.frame !== frameId) state.revision++;\n state.frame = frameId ?? -1;\n }\n const depthTexture = (shadow.map as (THREE.RenderTarget & { depthTexture?: THREE.Texture | null }) | null)?.depthTexture;\n if (!depthTexture) continue;\n const gpu = backend.get(depthTexture)?.texture as GPUTexture | undefined;\n if (!gpu) continue;\n const point = !!light.isPointLight;\n check(backend, point ? \"cube\" : \"2d\", () => {\n if (!String(gpu.format).startsWith(\"depth\")) return `stores a light's shadow map as ${gpu.format}, not a depth format`;\n if (!(gpu.usage & TEXTURE_BINDING)) return \"made a shadow map without TEXTURE_BINDING\";\n if (gpu.depthOrArrayLayers !== (point ? 6 : 1)) return `made a ${point ? \"point\" : \"directional / spot\"} shadow map with ${gpu.depthOrArrayLayers} layers`;\n return point ? this.#checkCube(light as THREE.PointLight) : this.#check2d(shadow);\n });\n let view = this.#views.get(gpu);\n if (!view) this.#views.set(gpu, (view = gpu.createView({ dimension: \"2d-array\", aspect: \"depth-only\", label: `vdb occluder ${light.name || light.id}` })));\n out.push({\n light: light.id,\n depth: view,\n viewProjection: point ? this.#faces(light as THREE.PointLight) : [new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse).elements],\n bias: shadow.bias,\n reversedDepth: !!renderer.reversedDepthBuffer,\n filter: renderer.shadowMap.type === THREE.BasicShadowMap ? \"nearest\" : \"bilinear\",\n revision: state.revision,\n });\n }\n return out;\n }\n\n /**\n * Runs the light's `ShadowNode.updateBefore` with three's frame (internal 3): three draws the map now if it would draw\n * it this frame, and not again later. Returns whether the map was drawn this frame for this camera.\n */\n #flush(renderer: RendererLike, scene: THREE.Object3D, camera: THREE.Camera, light: ShadowLight, frameId: number | undefined): boolean {\n let lightNode = this.#nodes.get(light);\n if (lightNode === undefined) this.#nodes.set(light, (lightNode = vdbFrameSharedLightNode(light) as { shadowNode?: unknown } | null));\n const shadowNode = lightNode?.shadowNode as ShadowNodeLike | null | undefined;\n // No shadow node: no lit material uses the light yet, so three has no map (nothing to read)\n if (!shadowNode) return false;\n check(renderer.backend, \"flush\", () => {\n if (typeof frameId !== \"number\") return \"has no renderer._nodes.nodeFrame.frameId\";\n if (typeof shadowNode.updateBefore !== \"function\") return \"has no ShadowNode.updateBefore\";\n if (!(shadowNode._cameraFrameId instanceof WeakMap)) return \"has no ShadowNode._cameraFrameId (its once-per-frame guard)\";\n return null;\n });\n shadowNode.updateBefore!({ renderer, scene, camera, frameId, renderId: renderer._nodes?.nodeFrame?.renderId });\n return shadowNode._cameraFrameId!.get(camera) === frameId;\n }\n\n /** Internal 2 for a directional or spot map: shadow.matrix = bias × the camera's projection × view. */\n #check2d(shadow: THREE.LightShadow): string | null {\n const expected = new THREE.Matrix4().multiplyMatrices(WEBGPU_BIAS, new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse));\n return near(shadow.matrix.elements, expected.elements, 1e-5) ? null : \"keeps a shadow.matrix that is not bias × the shadow camera's projection × view (the map's draw state is unknown)\";\n }\n\n /** Internal 2 for a point map: face 5 of the table from the light position of the last draw equals the shadow camera. */\n #checkCube(light: THREE.PointLight): string | null {\n const faces = this.#faceViews(light);\n return near(faces[5]!.elements, light.shadow.camera.matrixWorldInverse.elements, 1e-5) ? null : \"draws point shadow faces another way (face 5 does not match the shadow camera)\";\n }\n\n /** The 6 face views of a point light's last draw (its position from `shadow.matrix`, three's WebGPU table). */\n #faceViews(light: THREE.PointLight): THREE.Matrix4[] {\n const position = new THREE.Vector3().setFromMatrixPosition(light.shadow.matrix).negate();\n const c = this.#camera;\n return CUBE_DIRECTIONS.map((direction, face) => {\n c.position.copy(position);\n c.up.copy(CUBE_UPS[face]!);\n c.lookAt(position.clone().add(direction));\n c.updateMatrixWorld(true);\n return c.matrixWorldInverse.clone();\n });\n }\n\n /** The 6 face view-projections (one projection: the shadow camera's, as drawn). */\n #faces(light: THREE.PointLight): Float32Array[] {\n const projection = light.shadow.camera.projectionMatrix;\n return this.#faceViews(light).map((view) => Float32Array.from(new THREE.Matrix4().multiplyMatrices(projection, view).elements));\n }\n\n #warnOnce(key: string, message: string): void {\n if (this.#warned.has(key)) return;\n this.#warned.add(key);\n console.warn(`@pmndrs/vdb/three: ${message}`);\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * K6.8a / K6.8b: reading a core uniform struct from a buffer three binds as storage. three r187 binds a buffer it does not
3
+ * own only as storage (`vdbThreeStorageStandIn`, the `VDBGridNode` pattern): a uniform `BufferNode` uploads its own array.
4
+ * So the core buffer (a volume shadow map's `view`, the emission probes' `grid`) is read as `array<vec4u>` and a generated
5
+ * WGSL function unpacks it into the core's struct, field by field from the struct's layout, so a field the core adds is
6
+ * unpacked too. The struct's own WGSL comes with the core's receiver code (`vdbVolumeShadowWgsl()`, `vdbEmissionProbeWgsl()`).
7
+ */
8
+ import { CodeNode, type Node, type NodeBuilder } from "three/webgpu";
9
+ import type { VDBUniformStruct } from "../../core/frame/uniforms.js";
10
+ /** A three storage node (`storage(attribute, 'uvec4', words).toReadOnly()`). */
11
+ export type VDBFrameStorageNode = Node & {
12
+ value: unknown;
13
+ setName(name: string): unknown;
14
+ build(builder: NodeBuilder, output?: string): unknown;
15
+ };
16
+ /**
17
+ * WGSL `fn <fnName>() -> <struct.name>` that unpacks the struct from the `array<vec4u>` binding `ref`. Only 16-byte vector
18
+ * and `mat4x4f` fields unpack (every field of the structs three reads); another type throws.
19
+ */
20
+ export declare function vdbFrameStructLoaderWgsl(struct: VDBUniformStruct, fnName: string, ref: string): string;
21
+ /** `vec4u` words of a struct (its size is a multiple of 16). */
22
+ export declare const vdbFrameStructWords: (struct: VDBUniformStruct) => number;
23
+ /**
24
+ * One binding's loader: a code node over its storage node, generated per shader with the binding's reference (three names
25
+ * the binding per shader). Include it in the `wgslFn` that calls `fnName()`.
26
+ */
27
+ export declare class VDBFrameStructLoaderNode extends CodeNode {
28
+ /** Node-valued property: three sets it up and analyzes it as this node's child (the binding). */
29
+ vdbStructBuffer: VDBFrameStorageNode;
30
+ readonly fnName: string;
31
+ readonly struct: VDBUniformStruct;
32
+ constructor(buffer: VDBFrameStorageNode, struct: VDBUniformStruct, fnName: string);
33
+ generate(builder: NodeBuilder): string;
34
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * K6.8a / K6.8b: reading a core uniform struct from a buffer three binds as storage. three r187 binds a buffer it does not
3
+ * own only as storage (`vdbThreeStorageStandIn`, the `VDBGridNode` pattern): a uniform `BufferNode` uploads its own array.
4
+ * So the core buffer (a volume shadow map's `view`, the emission probes' `grid`) is read as `array<vec4u>` and a generated
5
+ * WGSL function unpacks it into the core's struct, field by field from the struct's layout, so a field the core adds is
6
+ * unpacked too. The struct's own WGSL comes with the core's receiver code (`vdbVolumeShadowWgsl()`, `vdbEmissionProbeWgsl()`).
7
+ */
8
+ import { CodeNode } from "three/webgpu";
9
+ /**
10
+ * WGSL `fn <fnName>() -> <struct.name>` that unpacks the struct from the `array<vec4u>` binding `ref`. Only 16-byte vector
11
+ * and `mat4x4f` fields unpack (every field of the structs three reads); another type throws.
12
+ */
13
+ export function vdbFrameStructLoaderWgsl(struct, fnName, ref) {
14
+ const lines = [`fn ${fnName}() -> ${struct.name} {`, ` var v: ${struct.name};`];
15
+ for (const f of struct.fields.values()) {
16
+ for (let e = 0; e < f.count; e++) {
17
+ const at = (f.offset + e * f.stride) / 16;
18
+ const lhs = f.count > 1 ? `v.${f.name}[${e}]` : `v.${f.name}`;
19
+ let rhs;
20
+ if (f.type === "mat4x4f")
21
+ rhs = `mat4x4f(${[0, 1, 2, 3].map((c) => `bitcast<vec4f>(${ref}[${at + c}])`).join(", ")})`;
22
+ else if (f.type === "vec4f")
23
+ rhs = `bitcast<vec4f>(${ref}[${at}])`;
24
+ else if (f.type === "vec4u")
25
+ rhs = `${ref}[${at}]`;
26
+ else
27
+ throw new Error(`vdbFrameStructLoaderWgsl: ${struct.name}.${f.name} is ${f.type}; only 16-byte vector and mat4x4f fields unpack`);
28
+ lines.push(` ${lhs} = ${rhs};`);
29
+ }
30
+ }
31
+ lines.push(" return v;", "}");
32
+ return lines.join("\n");
33
+ }
34
+ /** `vec4u` words of a struct (its size is a multiple of 16). */
35
+ export const vdbFrameStructWords = (struct) => struct.size / 16;
36
+ /**
37
+ * One binding's loader: a code node over its storage node, generated per shader with the binding's reference (three names
38
+ * the binding per shader). Include it in the `wgslFn` that calls `fnName()`.
39
+ */
40
+ export class VDBFrameStructLoaderNode extends CodeNode {
41
+ /** Node-valued property: three sets it up and analyzes it as this node's child (the binding). */
42
+ vdbStructBuffer;
43
+ fnName;
44
+ struct;
45
+ constructor(buffer, struct, fnName) {
46
+ super("", [], "wgsl");
47
+ this.vdbStructBuffer = buffer;
48
+ this.struct = struct;
49
+ this.fnName = fnName;
50
+ }
51
+ generate(builder) {
52
+ const ref = this.vdbStructBuffer.build(builder, "property");
53
+ if (typeof ref !== "string")
54
+ throw new Error(`VDBFrameStructLoaderNode: three built the ${this.struct.name} storage node to a non-string reference`);
55
+ const text = vdbFrameStructLoaderWgsl(this.struct, this.fnName, ref);
56
+ const nodeCode = builder.getCodeFromNode(this, this.getNodeType(builder));
57
+ nodeCode.code = text;
58
+ return text;
59
+ }
60
+ }
61
+ //# sourceMappingURL=core-structs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-structs.js","sourceRoot":"","sources":["../../../src/three/frame/core-structs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAA+B,MAAM,cAAc,CAAC;AAMrE;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAwB,EAAE,MAAc,EAAE,GAAW;IAC5F,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,SAA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. three r187 binds a buffer it does not\n * own only as storage (`vdbThreeStorageStandIn`, the `VDBGridNode` pattern): a uniform `BufferNode` uploads its own array.\n * So the core buffer (a volume shadow map's `view`, the emission probes' `grid`) is read as `array<vec4u>` and a generated\n * WGSL function unpacks it into the core's struct, field by field from the struct's layout, so a field the core adds is\n * unpacked too. The struct's own WGSL comes with the core's receiver code (`vdbVolumeShadowWgsl()`, `vdbEmissionProbeWgsl()`).\n */\n\nimport { CodeNode, type Node, type NodeBuilder } from \"three/webgpu\";\nimport type { VDBUniformStruct } from \"../../core/frame/uniforms.js\";\n\n/** A three storage node (`storage(attribute, 'uvec4', words).toReadOnly()`). */\nexport type VDBFrameStorageNode = Node & { value: unknown; setName(name: string): unknown; build(builder: NodeBuilder, output?: string): unknown };\n\n/**\n * WGSL `fn <fnName>() -> <struct.name>` that unpacks the struct from the `array<vec4u>` binding `ref`. Only 16-byte vector\n * and `mat4x4f` fields unpack (every field of the structs three reads); another type throws.\n */\nexport function vdbFrameStructLoaderWgsl(struct: VDBUniformStruct, fnName: string, ref: string): string {\n const lines = [`fn ${fnName}() -> ${struct.name} {`, ` var v: ${struct.name};`];\n for (const f of struct.fields.values()) {\n for (let e = 0; e < f.count; e++) {\n const at = (f.offset + e * f.stride) / 16;\n const lhs = f.count > 1 ? `v.${f.name}[${e}]` : `v.${f.name}`;\n let rhs: string;\n if (f.type === \"mat4x4f\") rhs = `mat4x4f(${[0, 1, 2, 3].map((c) => `bitcast<vec4f>(${ref}[${at + c}])`).join(\", \")})`;\n else if (f.type === \"vec4f\") rhs = `bitcast<vec4f>(${ref}[${at}])`;\n else if (f.type === \"vec4u\") rhs = `${ref}[${at}]`;\n else throw new Error(`vdbFrameStructLoaderWgsl: ${struct.name}.${f.name} is ${f.type}; only 16-byte vector and mat4x4f fields unpack`);\n lines.push(` ${lhs} = ${rhs};`);\n }\n }\n lines.push(\" return v;\", \"}\");\n return lines.join(\"\\n\");\n}\n\n/** `vec4u` words of a struct (its size is a multiple of 16). */\nexport const vdbFrameStructWords = (struct: VDBUniformStruct): number => struct.size / 16;\n\n/**\n * One binding's loader: a code node over its storage node, generated per shader with the binding's reference (three names\n * the binding per shader). Include it in the `wgslFn` that calls `fnName()`.\n */\nexport class VDBFrameStructLoaderNode extends CodeNode {\n /** Node-valued property: three sets it up and analyzes it as this node's child (the binding). */\n vdbStructBuffer: VDBFrameStorageNode;\n readonly fnName: string;\n readonly struct: VDBUniformStruct;\n\n constructor(buffer: VDBFrameStorageNode, struct: VDBUniformStruct, fnName: string) {\n super(\"\", [], \"wgsl\");\n this.vdbStructBuffer = buffer;\n this.struct = struct;\n this.fnName = fnName;\n }\n\n override generate(builder: NodeBuilder): string {\n const ref = this.vdbStructBuffer.build(builder, \"property\");\n if (typeof ref !== \"string\") throw new Error(`VDBFrameStructLoaderNode: three built the ${this.struct.name} storage node to a non-string reference`);\n const text = vdbFrameStructLoaderWgsl(this.struct, this.fnName, ref);\n const nodeCode = (builder as unknown as { getCodeFromNode(node: Node, type: string): { code: string } }).getCodeFromNode(this, this.getNodeType(builder));\n nodeCode.code = text;\n return text;\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Binding the core frame renderer's `GPUTexture`s into three r187 (K6.1, design §6; owner Q2): a stand-in
3
+ * per output, three's `ExternalTexture` (r187: `backend.createTexture` takes `sourceTexture` as the GPU
4
+ * texture and `destroyTexture` never destroys it) flagged `is3DTexture`, so a `texture3D()` node binds
5
+ * the core texture with a 3D view. When `outputs.version` moves, a new stand-in replaces the old one (three
6
+ * cannot re-point an initialized ExternalTexture) and the node's `value` swaps, which rebuilds its bind
7
+ * group. Once per backend a self-test puts a throwaway texture through the same path and checks three
8
+ * took it as given and did not destroy it, else `VDB_ENGINE_MISMATCH`.
9
+ */
10
+ import { ExternalTexture } from "three";
11
+ interface RendererLike {
12
+ readonly backend: object;
13
+ initTexture(texture: object): void;
14
+ }
15
+ /** Label of the once-per-backend self-test texture (1³; tests that count textures skip it). */
16
+ export declare const VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL = "@pmndrs/vdb/three core-texture self-test";
17
+ /** How three views a core texture: a 3D texture (froxels, probes), a 2d-array (volume shadow maps) or a cube (point maps). */
18
+ export type VDBCoreTextureKind = "3d" | "2d-array" | "cube";
19
+ /** A three stand-in for a core texture (K6.1: 3D; K6.5: 2d-array and cube views of the volume shadow maps). */
20
+ export declare function vdbCoreTextureStandIn(gpu: GPUTexture, kind?: VDBCoreTextureKind): ExternalTexture;
21
+ /**
22
+ * Checks once per backend that three binds an ExternalTexture's `sourceTexture` as given and never destroys
23
+ * it (dispose included).
24
+ *
25
+ * @throws VDBError `VDB_ENGINE_MISMATCH` when three's internals differ.
26
+ */
27
+ export declare function vdbCoreTextureSelfTest(renderer: RendererLike, device: GPUDevice): void;
28
+ /** One core output bound into three: `texture` follows the core texture (a new stand-in when it changes). */
29
+ export declare class VDBCoreTextureBinding {
30
+ #private;
31
+ constructor(kind?: VDBCoreTextureKind);
32
+ /** The current stand-in (null before the first {@link set}). */
33
+ get texture(): ExternalTexture | null;
34
+ /** The core texture of the current stand-in (null before the first {@link set}). */
35
+ get gpu(): GPUTexture | null;
36
+ /** Points the binding at `gpu`; returns true when the stand-in changed (swap the node's `value`). */
37
+ set(gpu: GPUTexture): boolean;
38
+ /** Drops the stand-in (the core texture belongs to the core renderer). */
39
+ dispose(): void;
40
+ }
41
+ export {};
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Binding the core frame renderer's `GPUTexture`s into three r187 (K6.1, design §6; owner Q2): a stand-in
3
+ * per output, three's `ExternalTexture` (r187: `backend.createTexture` takes `sourceTexture` as the GPU
4
+ * texture and `destroyTexture` never destroys it) flagged `is3DTexture`, so a `texture3D()` node binds
5
+ * the core texture with a 3D view. When `outputs.version` moves, a new stand-in replaces the old one (three
6
+ * cannot re-point an initialized ExternalTexture) and the node's `value` swaps, which rebuilds its bind
7
+ * group. Once per backend a self-test puts a throwaway texture through the same path and checks three
8
+ * took it as given and did not destroy it, else `VDB_ENGINE_MISMATCH`.
9
+ */
10
+ import { ClampToEdgeWrapping, CubeReflectionMapping, ExternalTexture, LinearFilter, REVISION } from "three";
11
+ import { VDBError } from "../../core/errors.js";
12
+ /** Label of the once-per-backend self-test texture (1³; tests that count textures skip it). */
13
+ export const VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL = "@pmndrs/vdb/three core-texture self-test";
14
+ const selfTested = new WeakMap();
15
+ const mismatch = (what) => new VDBError("VDB_ENGINE_MISMATCH", `three adapter: three r${REVISION} ${what}. The core frame renderer binds its GPUTextures into three through ExternalTexture ` +
16
+ "(written against three r187); this three version is unsupported for VDBFrameRenderer.");
17
+ /** A three stand-in for a core texture (K6.1: 3D; K6.5: 2d-array and cube views of the volume shadow maps). */
18
+ export function vdbCoreTextureStandIn(gpu, kind = "3d") {
19
+ const t = new ExternalTexture(gpu);
20
+ const f = t;
21
+ if (kind === "3d")
22
+ f.is3DTexture = true;
23
+ else if (kind === "2d-array")
24
+ f.isArrayTexture = true;
25
+ else {
26
+ f.isCubeTexture = true;
27
+ // K6.8a: a cube's mapping (three's default is UVMapping): CubeTextureNode logs "Mapping not supported" for any other
28
+ t.mapping = CubeReflectionMapping;
29
+ }
30
+ f.wrapR = ClampToEdgeWrapping;
31
+ t.wrapS = t.wrapT = ClampToEdgeWrapping;
32
+ t.minFilter = t.magFilter = LinearFilter;
33
+ t.generateMipmaps = false;
34
+ t.flipY = false;
35
+ t.name = gpu.label;
36
+ f.image = { width: gpu.width, height: gpu.height, depth: gpu.depthOrArrayLayers };
37
+ return t;
38
+ }
39
+ /**
40
+ * Checks once per backend that three binds an ExternalTexture's `sourceTexture` as given and never destroys
41
+ * it (dispose included).
42
+ *
43
+ * @throws VDBError `VDB_ENGINE_MISMATCH` when three's internals differ.
44
+ */
45
+ export function vdbCoreTextureSelfTest(renderer, device) {
46
+ const backend = renderer.backend;
47
+ const cached = selfTested.get(backend);
48
+ if (cached === true)
49
+ return;
50
+ if (cached)
51
+ throw cached;
52
+ let error = null;
53
+ const dummy = device.createTexture({ label: VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL, size: [1, 1, 1], dimension: "3d", format: "rgba16float", usage: 0x04 /* TEXTURE_BINDING */ });
54
+ const realDestroy = dummy.destroy;
55
+ let destroyedByThree = false;
56
+ dummy.destroy = () => {
57
+ destroyedByThree = true;
58
+ };
59
+ try {
60
+ if (typeof backend.get !== "function" || typeof renderer.initTexture !== "function")
61
+ throw mismatch("has no backend.get or renderer.initTexture");
62
+ const t = vdbCoreTextureStandIn(dummy);
63
+ renderer.initTexture(t);
64
+ if (backend.get(t).texture !== dummy)
65
+ error = mismatch("did not bind an ExternalTexture's sourceTexture as its GPU texture");
66
+ t.dispose();
67
+ if (!error && destroyedByThree)
68
+ error = mismatch("destroyed an ExternalTexture's sourceTexture on dispose");
69
+ }
70
+ catch (e) {
71
+ error = e instanceof VDBError ? e : mismatch(`failed the core-texture self-test (${e instanceof Error ? e.message : String(e)})`);
72
+ }
73
+ finally {
74
+ dummy.destroy = realDestroy;
75
+ dummy.destroy();
76
+ }
77
+ selfTested.set(backend, error ?? true);
78
+ if (error)
79
+ throw error;
80
+ }
81
+ /** One core output bound into three: `texture` follows the core texture (a new stand-in when it changes). */
82
+ export class VDBCoreTextureBinding {
83
+ #gpu = null;
84
+ #standIn = null;
85
+ #kind;
86
+ constructor(kind = "3d") {
87
+ this.#kind = kind;
88
+ }
89
+ /** The current stand-in (null before the first {@link set}). */
90
+ get texture() {
91
+ return this.#standIn;
92
+ }
93
+ /** The core texture of the current stand-in (null before the first {@link set}). */
94
+ get gpu() {
95
+ return this.#gpu;
96
+ }
97
+ /** Points the binding at `gpu`; returns true when the stand-in changed (swap the node's `value`). */
98
+ set(gpu) {
99
+ if (gpu === this.#gpu)
100
+ return false;
101
+ // ExternalTexture.dispose never destroys the core texture (the self-test checked it); the core retires it.
102
+ this.#standIn?.dispose();
103
+ this.#gpu = gpu;
104
+ this.#standIn = vdbCoreTextureStandIn(gpu, this.#kind);
105
+ return true;
106
+ }
107
+ /** Drops the stand-in (the core texture belongs to the core renderer). */
108
+ dispose() {
109
+ this.#standIn?.dispose();
110
+ this.#standIn = null;
111
+ this.#gpu = null;
112
+ }
113
+ }
114
+ //# sourceMappingURL=core-textures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-textures.js","sourceRoot":"","sources":["../../../src/three/frame/core-textures.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAUhD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,sCAAsC,GAAG,0CAA0C,CAAC;AAEjG,MAAM,UAAU,GAAG,IAAI,OAAO,EAA2B,CAAC;AAE1D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,IAAI,QAAQ,CACV,qBAAqB,EACrB,yBAAyB,QAAQ,IAAI,IAAI,qFAAqF;IAC5H,uFAAuF,CAC1F,CAAC;AAKJ,+GAA+G;AAC/G,MAAM,UAAU,qBAAqB,CAAC,GAAe,EAAE,OAA2B,IAAI;IACpF,MAAM,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,CAAuC,CAAC;IAClD,IAAI,IAAI,KAAK,IAAI;QAAE,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;SACnC,IAAI,IAAI,KAAK,UAAU;QAAE,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC;SACjD,CAAC;QACJ,CAAC,CAAC,aAAa,GAAG,IAAI,CAAC;QACvB,qHAAqH;QACrH,CAAC,CAAC,OAAO,GAAG,qBAAqB,CAAC;IACpC,CAAC;IACD,CAAC,CAAC,KAAK,GAAG,mBAAmB,CAAC;IAC9B,CAAC,CAAC,KAAK,GAAG,CA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oF;IACpF,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,qGAAqG;IACrG,GAAG,CAAC,GAAe;QACjB,IAAI,GAAG,KAAK,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QACpC,2GAA2G;QAC3G,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IAC1E,OAAO;QACL,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["/**\n * Binding the core frame renderer's `GPUTexture`s into three r187 (K6.1, design §6; owner Q2): a stand-in\n * per output, three's `ExternalTexture` (r187: `backend.createTexture` takes `sourceTexture` as the GPU\n * texture and `destroyTexture` never destroys it) flagged `is3DTexture`, so a `texture3D()` node binds\n * the core texture with a 3D view. When `outputs.version` moves, a new stand-in replaces the old one (three\n * cannot re-point an initialized ExternalTexture) and the node's `value` swaps, which rebuilds its bind\n * group. Once per backend a self-test puts a throwaway texture through the same path and checks three\n * took it as given and did not destroy it, else `VDB_ENGINE_MISMATCH`.\n */\n\nimport { ClampToEdgeWrapping, CubeReflectionMapping, ExternalTexture, LinearFilter, REVISION } from \"three\";\nimport { VDBError } from \"../../core/errors.js\";\n\ninterface BackendLike {\n get(object: object): Record<string, unknown>;\n}\ninterface RendererLike {\n readonly backend: object;\n initTexture(texture: object): void;\n}\n\n/** Label of the once-per-backend self-test texture (1³; tests that count textures skip it). */\nexport const VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL = \"@pmndrs/vdb/three core-texture self-test\";\n\nconst selfTested = new WeakMap<object, true | VDBError>();\n\nconst mismatch = (what: string) =>\n new VDBError(\n \"VDB_ENGINE_MISMATCH\",\n `three adapter: three r${REVISION} ${what}. The core frame renderer binds its GPUTextures into three through ExternalTexture ` +\n \"(written against three r187); this three version is unsupported for VDBFrameRenderer.\",\n );\n\n/** How three views a core texture: a 3D texture (froxels, probes), a 2d-array (volume shadow maps) or a cube (point maps). */\nexport type VDBCoreTextureKind = \"3d\" | \"2d-array\" | \"cube\";\n\n/** A three stand-in for a core texture (K6.1: 3D; K6.5: 2d-array and cube views of the volume shadow maps). */\nexport function vdbCoreTextureStandIn(gpu: GPUTexture, kind: VDBCoreTextureKind = \"3d\"): ExternalTexture {\n const t = new ExternalTexture(gpu);\n const f = t as unknown as Record<string, unknown>;\n if (kind === \"3d\") f.is3DTexture = true;\n else if (kind === \"2d-array\") f.isArrayTexture = true;\n else {\n f.isCubeTexture = true;\n // K6.8a: a cube's mapping (three's default is UVMapping): CubeTextureNode logs \"Mapping not supported\" for any other\n t.mapping = CubeReflectionMapping;\n }\n f.wrapR = ClampToEdgeWrapping;\n t.wrapS = t.wrapT = ClampToEdgeWrapping;\n t.minFilter = t.magFilter = LinearFilter;\n t.generateMipmaps = false;\n t.flipY = false;\n t.name = gpu.label;\n f.image = { width: gpu.width, height: gpu.height, depth: gpu.depthOrArrayLayers };\n return t;\n}\n\n/**\n * Checks once per backend that three binds an ExternalTexture's `sourceTexture` as given and never destroys\n * it (dispose included).\n *\n * @throws VDBError `VDB_ENGINE_MISMATCH` when three's internals differ.\n */\nexport function vdbCoreTextureSelfTest(renderer: RendererLike, device: GPUDevice): void {\n const backend = renderer.backend as BackendLike;\n const cached = selfTested.get(backend);\n if (cached === true) return;\n if (cached) throw cached;\n let error: VDBError | null = null;\n const dummy = device.createTexture({ label: VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL, size: [1, 1, 1], dimension: \"3d\", format: \"rgba16float\", usage: 0x04 /* TEXTURE_BINDING */ });\n const realDestroy = dummy.destroy;\n let destroyedByThree = false;\n (dummy as { destroy: () => void }).destroy = () => {\n destroyedByThree = true;\n };\n try {\n if (typeof backend.get !== \"function\" || typeof renderer.initTexture !== \"function\") throw mismatch(\"has no backend.get or renderer.initTexture\");\n const t = vdbCoreTextureStandIn(dummy);\n renderer.initTexture(t);\n if (backend.get(t).texture !== dummy) error = mismatch(\"did not bind an ExternalTexture's sourceTexture as its GPU texture\");\n t.dispose();\n if (!error && destroyedByThree) error = mismatch(\"destroyed an ExternalTexture's sourceTexture on dispose\");\n } catch (e) {\n error = e instanceof VDBError ? e : mismatch(`failed the core-texture self-test (${e instanceof Error ? e.message : String(e)})`);\n } finally {\n (dummy as { destroy: () => void }).destroy = realDestroy;\n dummy.destroy();\n }\n selfTested.set(backend, error ?? true);\n if (error) throw error;\n}\n\n/** One core output bound into three: `texture` follows the core texture (a new stand-in when it changes). */\nexport class VDBCoreTextureBinding {\n #gpu: GPUTexture | null = null;\n #standIn: ExternalTexture | null = null;\n readonly #kind: VDBCoreTextureKind;\n\n constructor(kind: VDBCoreTextureKind = \"3d\") {\n this.#kind = kind;\n }\n\n /** The current stand-in (null before the first {@link set}). */\n get texture(): ExternalTexture | null {\n return this.#standIn;\n }\n\n /** The core texture of the current stand-in (null before the first {@link set}). */\n get gpu(): GPUTexture | null {\n return this.#gpu;\n }\n\n /** Points the binding at `gpu`; returns true when the stand-in changed (swap the node's `value`). */\n set(gpu: GPUTexture): boolean {\n if (gpu === this.#gpu) return false;\n // ExternalTexture.dispose never destroys the core texture (the self-test checked it); the core retires it.\n this.#standIn?.dispose();\n this.#gpu = gpu;\n this.#standIn = vdbCoreTextureStandIn(gpu, this.#kind);\n return true;\n }\n\n /** Drops the stand-in (the core texture belongs to the core renderer). */\n dispose(): void {\n this.#standIn?.dispose();\n this.#standIn = null;\n this.#gpu = null;\n }\n}\n"]}